summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold Dumas <arnold@dumas.at>2017-01-28 18:00:57 +0100
committerMichael Meeks <michael.meeks@collabora.com>2017-01-30 09:46:58 +0000
commitc7e1c9dc63a5986fc70fd86f36c8755b6c2a1f98 (patch)
tree6aaedaa4bb7d51f7e018a0f13405361f9bd13e1a
parentb4b989b59cc5841fdf4635b19b975cae3a88430f (diff)
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>
-rw-r--r--cui/source/dialogs/about.cxx40
-rw-r--r--cui/source/inc/about.hxx5
-rw-r--r--cui/uiconfig/ui/aboutdialog.ui20
3 files changed, 62 insertions, 3 deletions
diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx
index 336951b3a7f3..5d155dc9333a 100644
--- a/cui/source/dialogs/about.cxx
+++ b/cui/source/dialogs/about.cxx
@@ -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;
diff --git a/cui/source/inc/about.hxx b/cui/source/inc/about.hxx
index 80fda68b6552..e3b50e1b5377 100644
--- a/cui/source/inc/about.hxx
+++ b/cui/source/inc/about.hxx
@@ -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;
diff --git a/cui/uiconfig/ui/aboutdialog.ui b/cui/uiconfig/ui/aboutdialog.ui
index d55acee02e4d..dbbb9d4faa7e 100644
--- a/cui/uiconfig/ui/aboutdialog.ui
+++ b/cui/uiconfig/ui/aboutdialog.ui
@@ -170,6 +170,20 @@
</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>
<property name="can_focus">False</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>