officecfg/registry/data/org/openoffice/Office/Common.xcu | 3 officecfg/registry/schema/org/openoffice/Office/Common.xcs | 5 sfx2/source/dialog/backingwindow.cxx | 94 +++++++++++-- sfx2/source/dialog/backingwindow.hxx | 5 sfx2/uiconfig/ui/startcenter.ui | 10 - 5 files changed, 97 insertions(+), 20 deletions(-)
New commits: commit 35713de9d0b4981a019edd25591285d0bc6107db Author: Heiko Tietze <tietze.he...@gmail.com> AuthorDate: Tue Jan 19 14:37:19 2021 +0100 Commit: Heiko Tietze <heiko.tie...@documentfoundation.org> CommitDate: Tue Jan 26 14:43:06 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> diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu index 83335726c843..237348be96cb 100644 --- a/officecfg/registry/data/org/openoffice/Office/Common.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu @@ -363,6 +363,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 de96a9477b37..be60d3d19ec3 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2111,6 +2111,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 45aec2821c4d..01b29e4dc197 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -22,6 +22,7 @@ #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> @@ -37,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> @@ -60,6 +62,73 @@ using namespace ::com::sun::star::document; constexpr OUStringLiteral SERVICENAME_CFGREADACCESS = u"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; @@ -77,7 +146,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")) @@ -96,19 +166,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)); @@ -169,6 +226,7 @@ void BackingWindow::dispose() mxDrawAllButton.reset(); mxDBAllButton.reset(); mxMathAllButton.reset(); + mxBrandImageWeld.reset(); mxBrandImage.reset(); mxHelpButton.reset(); mxExtensionsButton.reset(); @@ -304,6 +362,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_start() + pDrawingArea->get_margin_end())); + // 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 224678a970c8..e65eba9e9aba 100644 --- a/sfx2/uiconfig/ui/startcenter.ui +++ b/sfx2/uiconfig/ui/startcenter.ui @@ -417,17 +417,17 @@ </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="icon-name">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