diff options
author | Heiko Tietze <tietze.heiko@gmail.com> | 2021-01-19 14:37:19 +0100 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2021-01-26 14:43:06 +0100 |
commit | 35713de9d0b4981a019edd25591285d0bc6107db (patch) | |
tree | 2091340c2e245fdc1cdf1a4e01017ae452473699 /sfx2/source/dialog | |
parent | 6226d29d576c87a6bea03690badb4cef18ec4a88 (diff) |
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.tietze@documentfoundation.org>
Diffstat (limited to 'sfx2/source/dialog')
-rw-r--r-- | sfx2/source/dialog/backingwindow.cxx | 94 | ||||
-rw-r--r-- | sfx2/source/dialog/backingwindow.hxx | 5 |
2 files changed, 84 insertions, 15 deletions
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; |