tdf#103654: Make git hash clickable in the About dialog
This doesn't affect the About Dialog if the build id is not a valid git hash. Change-Id: Ie44f455dbfd0191cf6953091f28a42bccb67a4cb Reviewed-on: https://gerrit.libreoffice.org/33652 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
This commit is contained in:
committed by
Michael Meeks
parent
b4b989b59c
commit
c7e1c9dc63
@@ -47,6 +47,7 @@
|
||||
#include <sfx2/app.hxx>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <vcl/bitmap.hxx>
|
||||
#include <cctype>
|
||||
|
||||
#if HAVE_FEATURE_OPENCL
|
||||
#include <opencl/openclwrapper.hxx>
|
||||
@@ -65,6 +66,7 @@ AboutDialog::AboutDialog(vcl::Window* pParent)
|
||||
get(m_pVersion, "version");
|
||||
get(m_pDescriptionText, "description");
|
||||
get(m_pCopyrightText, "copyright");
|
||||
get(m_pBuildIdLink, "buildIdLink");
|
||||
m_aCopyrightTextStr = m_pCopyrightText->GetText();
|
||||
get(m_pWebsiteButton, "website");
|
||||
get(m_pCreditsButton, "credits");
|
||||
@@ -75,12 +77,15 @@ AboutDialog::AboutDialog(vcl::Window* pParent)
|
||||
m_aBasedTextStr = get<FixedText>("libreoffice")->GetText();
|
||||
m_aBasedDerivedTextStr = get<FixedText>("derived")->GetText();
|
||||
m_aLocaleStr = get<FixedText>("locale")->GetText();
|
||||
m_buildIdLinkString = m_pBuildIdLink->GetText();
|
||||
|
||||
m_pVersion->SetText(GetVersionString());
|
||||
|
||||
OUString aCopyrightString = GetCopyrightString();
|
||||
m_pCopyrightText->SetText( aCopyrightString );
|
||||
|
||||
SetBuildIdLink();
|
||||
|
||||
StyleControls();
|
||||
|
||||
SetLogo();
|
||||
@@ -106,6 +111,7 @@ void AboutDialog::dispose()
|
||||
m_pLogoReplacement.clear();
|
||||
m_pCreditsButton.clear();
|
||||
m_pWebsiteButton.clear();
|
||||
m_pBuildIdLink.clear();
|
||||
SfxModalDialog::dispose();
|
||||
}
|
||||
|
||||
@@ -142,6 +148,27 @@ IMPL_LINK( AboutDialog, HandleClick, Button*, pButton, void )
|
||||
}
|
||||
}
|
||||
|
||||
void AboutDialog::SetBuildIdLink()
|
||||
{
|
||||
const OUString buildId = GetBuildId();
|
||||
|
||||
if (IsStringValidGitHash(buildId))
|
||||
{
|
||||
if (m_buildIdLinkString.indexOf("$GITHASH") == -1)
|
||||
{
|
||||
SAL_WARN( "cui.dialogs", "translated git hash string in translations doesn't contain $GITHASH placeholder" );
|
||||
m_buildIdLinkString += " $GITHASH";
|
||||
}
|
||||
|
||||
m_pBuildIdLink->SetText(m_buildIdLinkString.replaceAll("$GITHASH", buildId));
|
||||
m_pBuildIdLink->SetURL("https://gerrit.libreoffice.org/gitweb?p=core.git;a=log;h=" + buildId);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pBuildIdLink->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
void AboutDialog::StyleControls()
|
||||
{
|
||||
// Make all the controls have a transparent background
|
||||
@@ -264,6 +291,19 @@ OUString AboutDialog::GetLocaleString()
|
||||
return aLocaleStr;
|
||||
}
|
||||
|
||||
bool AboutDialog::IsStringValidGitHash(const OUString& hash)
|
||||
{
|
||||
for (int i = 0; i < hash.getLength(); i++)
|
||||
{
|
||||
if (!std::isxdigit(hash[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
OUString AboutDialog::GetVersionString()
|
||||
{
|
||||
OUString sVersion = m_aVersionTextStr;
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <vcl/accel.hxx>
|
||||
#include <vcl/button.hxx>
|
||||
#include <vcl/fixed.hxx>
|
||||
#include <vcl/fixedhyper.hxx>
|
||||
#include <vcl/vclmedit.hxx>
|
||||
#include <sfx2/basedlgs.hxx>
|
||||
#include <vector>
|
||||
@@ -35,6 +36,7 @@ private:
|
||||
BitmapEx aLogoBitmap;
|
||||
|
||||
VclPtr<VclMultiLineEdit> m_pVersion;
|
||||
VclPtr<FixedHyperlink> m_pBuildIdLink;
|
||||
VclPtr<FixedText> m_pDescriptionText;
|
||||
VclPtr<FixedText> m_pCopyrightText;
|
||||
VclPtr<FixedImage> m_pLogoImage;
|
||||
@@ -50,7 +52,9 @@ private:
|
||||
OUString m_aCreditsLinkStr;
|
||||
OUString m_sBuildStr;
|
||||
OUString m_aLocaleStr;
|
||||
OUString m_buildIdLinkString;
|
||||
|
||||
void SetBuildIdLink();
|
||||
void StyleControls();
|
||||
void SetLogo();
|
||||
|
||||
@@ -58,6 +62,7 @@ private:
|
||||
OUString GetVersionString();
|
||||
OUString GetCopyrightString();
|
||||
static OUString GetLocaleString();
|
||||
static bool IsStringValidGitHash(const OUString& hash);
|
||||
|
||||
protected:
|
||||
virtual bool Close() override;
|
||||
|
@@ -169,6 +169,20 @@
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLinkButton" id="buildIdLink">
|
||||
<property name="label" translatable="yes">See Log: $GITHASH</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="relief">none</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="description">
|
||||
<property name="visible">True</property>
|
||||
@@ -182,7 +196,7 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@@ -252,7 +266,7 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@@ -264,7 +278,7 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
Reference in New Issue
Block a user