officecfg/registry/data/org/openoffice/Office/Common.xcu   |    3 
 officecfg/registry/schema/org/openoffice/Office/Common.xcs |    5 
 sfx2/source/dialog/backingwindow.cxx                       |   95 +++++++++++--
 sfx2/source/dialog/backingwindow.hxx                       |    5 
 sfx2/uiconfig/ui/startcenter.ui                            |    9 -
 5 files changed, 98 insertions(+), 19 deletions(-)

New commits:
commit af8ec08e70767c6e8b5a4ba19b4ebab56f59cc8d
Author:     Heiko Tietze <tietze.he...@gmail.com>
AuthorDate: Tue Jan 19 14:37:19 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Jan 28 15:32:59 2021 +0100

    Make brand image clickable
    
    and link to LibreOffice volunteer page
    
    Change-Id: Ie422983d0e23faa16c2e2364b25798b938712a43
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109637
    Tested-by: Jenkins
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    (cherry picked from commit 35713de9d0b4981a019edd25591285d0bc6107db)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109972
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu 
b/officecfg/registry/data/org/openoffice/Office/Common.xcu
index 08b39475df5c..816d22bc993c 100644
--- a/officecfg/registry/data/org/openoffice/Office/Common.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu
@@ -368,6 +368,9 @@
     <prop oor:name="InstallJavaURL" oor:type="xs:string">
       <value>https://hub.libreoffice.org/InstallJava/</value>
     </prop>
+    <prop oor:name="VolunteerURL" oor:type="xs:string">
+      <value>https://hub.libreoffice.org/volunteersupport/</value>
+    </prop>
   </node>
   <node oor:name="Forms">
     <node oor:name="ControlLayout">
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index ac14fc3e5d7d..99b4104f6499 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -2120,6 +2120,11 @@
           <desc>Specifies the URL used with the UNO command SendFeedback 
(SID_SEND_FEEDBACK).</desc>
         </info>
       </prop>
+      <prop oor:name="VolunteerURL" oor:type="xs:string" oor:nillable="false">
+        <info>
+          <desc>Specifies the URL opened per click on the brand image at the 
start center.</desc>
+        </info>
+      </prop>
       <prop oor:name="QA_URL" oor:type="xs:string" oor:nillable="false">
         <info>
           <desc>Specifies the URL used with the UNO command QuestionAnswers 
(SID_Q_AND_A).</desc>
diff --git a/sfx2/source/dialog/backingwindow.cxx 
b/sfx2/source/dialog/backingwindow.cxx
index 39183c2a748c..01d8923978c8 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -21,6 +21,8 @@
 #include <vcl/accel.hxx>
 #include <vcl/event.hxx>
 #include <vcl/help.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/ptrstyle.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/syswin.hxx>
@@ -36,6 +38,7 @@
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertysequence.hxx>
 #include <sfx2/app.hxx>
+#include <officecfg/Office/Common.hxx>
 
 #include <tools/diagnose_ex.h>
 
@@ -61,6 +64,73 @@ using namespace ::com::sun::star::document;
 
 const char SERVICENAME_CFGREADACCESS[] = 
"com.sun.star.configuration.ConfigurationAccess";
 
+class BrandImage final : public weld::CustomWidgetController
+{
+private:
+    BitmapEx maBrandImage;
+    bool mbIsDark = false;
+
+public:
+    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
+    {
+        weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
+        SetPointer(PointerStyle::RefHand);
+    }
+
+    virtual void Resize() override
+    {
+        auto nWidth = GetOutputSizePixel().Width();
+        if (maBrandImage.GetSizePixel().Width() != nWidth)
+            LoadImageForWidth(nWidth);
+        weld::CustomWidgetController::Resize();
+    }
+
+    void LoadImageForWidth(int nWidth)
+    {
+        mbIsDark = 
Application::GetSettings().GetStyleSettings().GetDialogColor().IsDark();
+        SfxApplication::loadBrandSvg(mbIsDark ? "shell/logo-sc_inverted" : 
"shell/logo-sc",
+                                    maBrandImage, nWidth);
+    }
+
+    void ConfigureForWidth(int nWidth)
+    {
+        if (maBrandImage.GetSizePixel().Width() == nWidth)
+            return;
+        LoadImageForWidth(nWidth);
+        const Size aBmpSize(maBrandImage.GetSizePixel());
+        set_size_request(aBmpSize.Width(), aBmpSize.Height());
+    }
+
+    virtual void StyleUpdated() override
+    {
+        const bool bIsDark = 
Application::GetSettings().GetStyleSettings().GetDialogColor().IsDark();
+        if (bIsDark != mbIsDark)
+            LoadImageForWidth(GetOutputSizePixel().Width());
+        weld::CustomWidgetController::StyleUpdated();
+    }
+
+    virtual bool MouseButtonUp(const MouseEvent& rMEvt) override
+    {
+        if (rMEvt.IsLeft())
+        {
+            OUString sURL = 
officecfg::Office::Common::Menus::VolunteerURL::get();
+            localizeWebserviceURI(sURL);
+
+            Reference<css::system::XSystemShellExecute> const 
xSystemShellExecute(
+                css::system::SystemShellExecute::create(
+                    ::comphelper::getProcessComponentContext()));
+            xSystemShellExecute->execute(sURL, OUString(),
+                                         
css::system::SystemShellExecuteFlags::URIS_ONLY);
+        }
+        return true;
+    }
+
+    virtual void Paint(vcl::RenderContext& rRenderContext, const 
tools::Rectangle&) override
+    {
+        rRenderContext.DrawBitmapEx(Point(0, 0), maBrandImage);
+    }
+};
+
 // increase size of the text in the buttons on the left fMultiplier-times
 float const g_fMultiplier = 1.4f;
 
@@ -78,7 +148,8 @@ BackingWindow::BackingWindow(vcl::Window* i_pParent)
     , mxDrawAllButton(m_xBuilder->weld_button("draw_all"))
     , mxDBAllButton(m_xBuilder->weld_button("database_all"))
     , mxMathAllButton(m_xBuilder->weld_button("math_all"))
-    , mxBrandImage(m_xBuilder->weld_image("imBrand"))
+    , mxBrandImage(new BrandImage)
+    , mxBrandImageWeld(new weld::CustomWeld(*m_xBuilder, "daBrand", 
*mxBrandImage))
     , mxHelpButton(m_xBuilder->weld_button("help"))
     , mxExtensionsButton(m_xBuilder->weld_button("extensions"))
     , mxAllButtonsBox(m_xBuilder->weld_container("all_buttons_box"))
@@ -97,19 +168,6 @@ BackingWindow::BackingWindow(vcl::Window* i_pParent)
     SetPaintTransparent(false);
     
SetBackground(svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND).nColor);
 
-    //brand image
-    BitmapEx aBackgroundBitmap;
-    bool bIsDark = 
Application::GetSettings().GetStyleSettings().GetDialogColor().IsDark();
-    if (SfxApplication::loadBrandSvg(bIsDark ? "shell/logo-sc_inverted" : 
"shell/logo-sc",
-                                     aBackgroundBitmap, 
mxButtonsBox->get_preferred_size().Width()))
-    {
-        ScopedVclPtr<VirtualDevice> m_pVirDev = 
mxBrandImage->create_virtual_device();
-        m_pVirDev->SetOutputSizePixel(aBackgroundBitmap.GetSizePixel());
-        m_pVirDev->DrawBitmapEx(Point(0, 0), aBackgroundBitmap);
-        mxBrandImage->set_image(m_pVirDev.get());
-        m_pVirDev.disposeAndClear();
-    }
-
     //set an alternative help label that doesn't hotkey the H of the Help menu
     mxHelpButton->set_label(mxAltHelpLabel->get_label());
     mxHelpButton->connect_clicked(LINK(this, BackingWindow, ClickHelpHdl));
@@ -170,6 +228,7 @@ void BackingWindow::dispose()
     mxDrawAllButton.reset();
     mxDBAllButton.reset();
     mxMathAllButton.reset();
+    mxBrandImageWeld.reset();
     mxBrandImage.reset();
     mxHelpButton.reset();
     mxExtensionsButton.reset();
@@ -305,6 +364,14 @@ void BackingWindow::ApplyStyleSettings()
     // control, at this point all the controls have updated settings (i.e. 
font).
     Size aPrefSize(mxAllButtonsBox->get_preferred_size());
     set_width_request(aPrefSize.Width());
+
+    // Now set a brand image wide enough to fill this width
+    weld::DrawingArea* pDrawingArea = mxBrandImage->GetDrawingArea();
+    mxBrandImage->ConfigureForWidth(aPrefSize.Width() -
+                                    (pDrawingArea->get_margin_left() + 
pDrawingArea->get_margin_right()));
+    // Refetch because the brand image height to match this width is now set
+    aPrefSize = mxAllButtonsBox->get_preferred_size();
+
     set_height_request(nMenuHeight + aPrefSize.Height());
 }
 
diff --git a/sfx2/source/dialog/backingwindow.hxx 
b/sfx2/source/dialog/backingwindow.hxx
index a1f6860c60dc..358055c66aae 100644
--- a/sfx2/source/dialog/backingwindow.hxx
+++ b/sfx2/source/dialog/backingwindow.hxx
@@ -36,6 +36,8 @@
 
 #include <memory>
 
+class BrandImage;
+
 class BackingWindow : public InterimItemWindow
 {
     css::uno::Reference<css::uno::XComponentContext> mxContext;
@@ -59,7 +61,8 @@ class BackingWindow : public InterimItemWindow
     std::unique_ptr<weld::Button> mxDrawAllButton;
     std::unique_ptr<weld::Button> mxDBAllButton;
     std::unique_ptr<weld::Button> mxMathAllButton;
-    std::unique_ptr<weld::Image> mxBrandImage;
+    std::unique_ptr<BrandImage> mxBrandImage;
+    std::unique_ptr<weld::CustomWeld> mxBrandImageWeld;
 
     std::unique_ptr<weld::Button> mxHelpButton;
     std::unique_ptr<weld::Button> mxExtensionsButton;
diff --git a/sfx2/uiconfig/ui/startcenter.ui b/sfx2/uiconfig/ui/startcenter.ui
index c1beeff7f433..67c8ee4d2b2d 100644
--- a/sfx2/uiconfig/ui/startcenter.ui
+++ b/sfx2/uiconfig/ui/startcenter.ui
@@ -417,17 +417,18 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkImage" id="imBrand">
+                  <object class="GtkDrawingArea" id="daBrand">
                     <property name="visible">True</property>
                     <property name="can-focus">False</property>
-                    <property name="halign">center</property>
                     <property name="valign">center</property>
-                    <property name="margin-bottom">6</property>
                     <property name="stock">gtk-missing-image</property>
+                    <property name="margin-start">12</property>
+                    <property name="margin-end">12</property>
+                    <property name="margin-bottom">12</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
-                    <property name="fill">False</property>
+                    <property name="fill">True</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to