diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-10-23 18:43:25 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-10-27 10:50:59 +0100 |
commit | 6dfbab409032516e05a63fbc777b9147d1deb4ec (patch) | |
tree | 5e7c7440e033d8aaee118cfd9ead61387af0f864 /sfx2 | |
parent | c070fac05fef41f788b53fe2c1f60519688a40b1 (diff) |
tdf#136555 apply window bg color for button boxes
The default background color of the frame is APPBACKGROUND, which
is matched to GetWorkspaceColor(). That color is visible in Writer
as the default document workspace background.
Originally I just saw the dark background of the button box in the
start center, and thought the workspace color in Qt is wrong and
changed it in the reverted commit, missing the change of the color
around the Writer document.
Now that the button boxes's background color isn't fixed via the
"branding" setting, we also must react to changed style settings,
so we override the DataChanged function.
This also reverts commit e0c72e31c1d455c26110c35e8780d420e17cdea6.
Regressed-by: a927e0964ba0442d53fffb22c577e54bcf183ed7
Change-Id: I62396355054523baef1197a8a8af61c2f0d29ef3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104740
Tested-by: Jenkins
Reviewed-by: Thorsten Wagner <thorsten.wagner.4@gmail.com>
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/backingwindow.cxx | 98 | ||||
-rw-r--r-- | sfx2/source/dialog/backingwindow.hxx | 8 |
2 files changed, 67 insertions, 39 deletions
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 44f53cfd8801..99c3990de072 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -62,7 +62,7 @@ using namespace ::com::sun::star::document; const char SERVICENAME_CFGREADACCESS[] = "com.sun.star.configuration.ConfigurationAccess"; // increase size of the text in the buttons on the left fMultiplier-times -float const fMultiplier = 1.4f; +float const g_fMultiplier = 1.4f; BackingWindow::BackingWindow(vcl::Window* i_pParent) : InterimItemWindow(i_pParent, "sfx/ui/startcenter.ui", "StartCenter", false) @@ -204,32 +204,77 @@ void BackingWindow::initControls() //initialize Template view mxLocalView->Hide(); - //set handlers mxLocalView->setCreateContextMenuHdl(LINK(this, BackingWindow, CreateContextMenuHdl)); mxLocalView->setOpenTemplateHdl(LINK(this, BackingWindow, OpenTemplateHdl)); mxLocalView->setEditTemplateHdl(LINK(this, BackingWindow, EditTemplateHdl)); mxLocalView->ShowTooltips( true ); - setupButton(*mxOpenButton); - setupButton(*mxRemoteButton); - setupButton(*mxRecentButton); - setupButton(*mxTemplateButton); - setupButton(*mxWriterAllButton); - setupButton(*mxDrawAllButton); - setupButton(*mxCalcAllButton); - setupButton(*mxDBAllButton); - setupButton(*mxImpressAllButton); - setupButton(*mxMathAllButton); - checkInstalledModules(); mxExtensionsButton->connect_clicked(LINK(this, BackingWindow, ExtLinkClickHdl)); - // setup larger font - vcl::Font aFont(mxCreateLabel->get_font()); - aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * fMultiplier)); - mxCreateLabel->set_font(aFont); + mxOpenButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); + mxRemoteButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); + mxRecentButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); + mxTemplateButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); + mxWriterAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); + mxDrawAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); + mxCalcAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); + mxDBAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); + mxImpressAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); + mxMathAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); + + mxRecentButton->connect_selected(LINK(this, BackingWindow, MenuSelectHdl)); + mxTemplateButton->connect_selected(LINK(this, BackingWindow, MenuSelectHdl)); + + ApplyStyleSettings(); +} + +void BackingWindow::DataChanged(const DataChangedEvent& rDCEvt) +{ + if ((rDCEvt.GetType() != DataChangedEventType::SETTINGS) + || !(rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) + { + InterimItemWindow::DataChanged(rDCEvt); + return; + } + + ApplyStyleSettings(); + Invalidate(); +} + +template <typename WidgetClass> +void BackingWindow::setLargerFont(WidgetClass& pWidget, const vcl::Font& rFont) +{ + vcl::Font aFont(rFont); + aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * g_fMultiplier)); + pWidget->set_font(aFont); +} + +void BackingWindow::ApplyStyleSettings() +{ + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + const Color aButtonsBackground(rStyleSettings.GetWindowColor()); + const vcl::Font& aButtonFont(rStyleSettings.GetPushButtonFont()); + const vcl::Font& aLabelFont(rStyleSettings.GetLabelFont()); + + // setup larger fonts + setLargerFont(mxOpenButton, aButtonFont); + setLargerFont(mxOpenButton, aButtonFont); + setLargerFont(mxRemoteButton, aButtonFont); + setLargerFont(mxRecentButton, aButtonFont); + setLargerFont(mxTemplateButton, aButtonFont); + setLargerFont(mxWriterAllButton, aButtonFont); + setLargerFont(mxDrawAllButton, aButtonFont); + setLargerFont(mxCalcAllButton, aButtonFont); + setLargerFont(mxDBAllButton, aButtonFont); + setLargerFont(mxImpressAllButton, aButtonFont); + setLargerFont(mxMathAllButton, aButtonFont); + setLargerFont(mxCreateLabel, aLabelFont); + + mxAllButtonsBox->set_background(aButtonsBackground); + mxSmallButtonsBox->set_background(aButtonsBackground); // compute the menubar height sal_Int32 nMenuHeight = 0; @@ -259,25 +304,6 @@ void BackingWindow::initializeLocalView() } } -void BackingWindow::setupButton(weld::Button& rButton) -{ - // the buttons should have a bit bigger font - vcl::Font aFont(rButton.get_font()); - aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * fMultiplier)); - rButton.set_font(aFont); - rButton.connect_clicked( LINK( this, BackingWindow, ClickHdl ) ); -} - -void BackingWindow::setupButton(weld::MenuButton& rButton) -{ - vcl::Font aFont(rButton.get_font()); - aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * fMultiplier)); - rButton.set_font(aFont); - - rButton.connect_clicked(LINK(this, BackingWindow, ClickHdl)); - rButton.connect_selected(LINK(this, BackingWindow, MenuSelectHdl)); -} - void BackingWindow::checkInstalledModules() { SvtModuleOptions aModuleOpt; diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx index f0a66edb5f77..391e582b9b22 100644 --- a/sfx2/source/dialog/backingwindow.hxx +++ b/sfx2/source/dialog/backingwindow.hxx @@ -78,9 +78,6 @@ class BackingWindow : public InterimItemWindow bool mbInitControls; std::unique_ptr<svt::AcceleratorExecute> mpAccExec; - void setupButton(weld::Button& rButton); - void setupButton(weld::MenuButton& rButton); - void dispatchURL(const OUString& i_rURL, const OUString& i_rTarget = OUString("_default"), const css::uno::Reference<css::frame::XDispatchProvider >& i_xProv = css::uno::Reference<css::frame::XDispatchProvider>(), @@ -100,6 +97,11 @@ class BackingWindow : public InterimItemWindow void checkInstalledModules(); + void DataChanged(const DataChangedEvent&) override; + + template <typename WidgetClass> void setLargerFont(WidgetClass&, const vcl::Font&); + void ApplyStyleSettings(); + public: explicit BackingWindow(vcl::Window* pParent); virtual ~BackingWindow() override; |