sfx2/source/dialog/backingwindow.cxx |   99 ++++++++++++++++++++++-------------
 sfx2/source/dialog/backingwindow.hxx |    8 ++
 vcl/qt5/Qt5Frame.cxx                 |    7 ++
 3 files changed, 76 insertions(+), 38 deletions(-)

New commits:
commit 804f051e8504338ada4ab1fe958aa7fc66a1297c
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Fri Oct 23 18:43:25 2020 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Oct 28 15:26:51 2020 +0100

    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 ef267dc5c1e46d236478ff32fc14925a0eeb0266.
    
    Regressed-by: a927e0964ba0442d53fffb22c577e54bcf183ed7
    Change-Id: I62396355054523baef1197a8a8af61c2f0d29ef3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104743
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/sfx2/source/dialog/backingwindow.cxx 
b/sfx2/source/dialog/backingwindow.cxx
index 7ee1b63e7604..caff3c45a832 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -63,7 +63,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 ) :
     Window( i_pParent ),
@@ -227,43 +227,82 @@ void BackingWindow::initControls()
     mpLocalView->SetStyle( mpLocalView->GetStyle() | WB_VSCROLL);
     mpLocalView->Hide();
 
-    mpTemplateButton->SetDelayMenu(true);
-    mpTemplateButton->SetDropDown(PushButtonDropdownStyle::SplitMenuButton);
-    mpRecentButton->SetDelayMenu(true);
-    mpRecentButton->SetDropDown(PushButtonDropdownStyle::SplitMenuButton);
-
     //set handlers
     mpLocalView->setCreateContextMenuHdl(LINK(this, BackingWindow, 
CreateContextMenuHdl));
     mpLocalView->setOpenTemplateHdl(LINK(this, BackingWindow, 
OpenTemplateHdl));
     mpLocalView->setEditTemplateHdl(LINK(this, BackingWindow, 
EditTemplateHdl));
     mpLocalView->ShowTooltips( true );
 
-    setupButton( mpOpenButton );
-    setupButton( mpRemoteButton );
-    setupButton( mpRecentButton );
-    setupButton( mpTemplateButton );
-    setupButton( mpWriterAllButton );
-    setupButton( mpDrawAllButton );
-    setupButton( mpCalcAllButton );
-    setupButton( mpDBAllButton );
-    setupButton( mpImpressAllButton );
-    setupButton( mpMathAllButton );
-
     checkInstalledModules();
 
     mpExtensionsButton->SetClickHdl(LINK(this, BackingWindow, 
ExtLinkClickHdl));
 
-    // setup nice colors
-    vcl::Font 
aFont(mpCreateLabel->GetSettings().GetStyleSettings().GetLabelFont());
-    aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * fMultiplier));
-    mpCreateLabel->SetControlFont(aFont);
+    mpOpenButton->SetClickHdl(LINK(this, BackingWindow, ClickHdl));
+    mpRemoteButton->SetClickHdl(LINK(this, BackingWindow, ClickHdl));
+    mpWriterAllButton->SetClickHdl(LINK(this, BackingWindow, ClickHdl));
+    mpDrawAllButton->SetClickHdl(LINK(this, BackingWindow, ClickHdl));
+    mpCalcAllButton->SetClickHdl(LINK(this, BackingWindow, ClickHdl));
+    mpDBAllButton->SetClickHdl(LINK(this, BackingWindow, ClickHdl));
+    mpImpressAllButton->SetClickHdl(LINK(this, BackingWindow, ClickHdl));
+    mpMathAllButton->SetClickHdl(LINK(this, BackingWindow, ClickHdl));
+
+    setupMenuButton(mpRecentButton);
+    setupMenuButton(mpTemplateButton);
+
+    ApplyStyleSettings();
+}
+
+void BackingWindow::DataChanged(const DataChangedEvent& rDCEvt)
+{
+    if ((rDCEvt.GetType() != DataChangedEventType::SETTINGS)
+            || !(rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
+    {
+        vcl::Window::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->SetControlFont(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(mpOpenButton, aButtonFont);
+    setLargerFont(mpOpenButton, aButtonFont);
+    setLargerFont(mpRemoteButton, aButtonFont);
+    setLargerFont(mpRecentButton, aButtonFont);
+    setLargerFont(mpTemplateButton, aButtonFont);
+    setLargerFont(mpWriterAllButton, aButtonFont);
+    setLargerFont(mpDrawAllButton, aButtonFont);
+    setLargerFont(mpCalcAllButton, aButtonFont);
+    setLargerFont(mpDBAllButton, aButtonFont);
+    setLargerFont(mpImpressAllButton, aButtonFont);
+    setLargerFont(mpMathAllButton, aButtonFont);
+    setLargerFont(mpCreateLabel, aLabelFont);
 
     // motif image under the buttons
     Wallpaper aWallpaper(get<FixedImage>("motif")->GetImage().GetBitmapEx());
     aWallpaper.SetStyle(WallpaperStyle::BottomRight);
-
+    aWallpaper.SetColor(aButtonsBackground);
     mpButtonsBox->SetBackground(aWallpaper);
 
+    mpAllButtonsBox->SetBackground(aButtonsBackground);
+    mpSmallButtonsBox->SetBackground(aButtonsBackground);
+
     Resize();
 
     // compute the menubar height
@@ -291,20 +330,10 @@ void BackingWindow::initializeLocalView()
     }
 }
 
-void BackingWindow::setupButton( PushButton* pButton )
-{
-    // the buttons should have a bit bigger font
-    vcl::Font 
aFont(pButton->GetSettings().GetStyleSettings().GetPushButtonFont());
-    aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * fMultiplier));
-    pButton->SetControlFont(aFont);
-    pButton->SetClickHdl( LINK( this, BackingWindow, ClickHdl ) );
-}
-
-void BackingWindow::setupButton( MenuToggleButton* pButton )
+void BackingWindow::setupMenuButton(MenuToggleButton* pButton)
 {
-    vcl::Font 
aFont(pButton->GetSettings().GetStyleSettings().GetPushButtonFont());
-    aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * fMultiplier));
-    pButton->SetControlFont(aFont);
+    pButton->SetDelayMenu(true);
+    pButton->SetDropDown(PushButtonDropdownStyle::SplitMenuButton);
 
     PopupMenu* pMenu = pButton->GetPopupMenu();
     pMenu->SetMenuFlags(pMenu->GetMenuFlags() | 
MenuFlags::AlwaysShowDisabledEntries);
diff --git a/sfx2/source/dialog/backingwindow.hxx 
b/sfx2/source/dialog/backingwindow.hxx
index 99d7bd6b7ccc..16f92c29dc2b 100644
--- a/sfx2/source/dialog/backingwindow.hxx
+++ b/sfx2/source/dialog/backingwindow.hxx
@@ -83,8 +83,7 @@ class BackingWindow : public vcl::Window, public 
VclBuilderContainer
     bool mbInitControls;
     std::unique_ptr<svt::AcceleratorExecute> mpAccExec;
 
-    void setupButton(PushButton* pButton);
-    void setupButton(MenuToggleButton* pButton);
+    void setupMenuButton(MenuToggleButton* pButton);
 
     void dispatchURL(const OUString& i_rURL,
                      const OUString& i_rTarget = OUString("_default"),
@@ -104,6 +103,11 @@ class BackingWindow : public vcl::Window, public 
VclBuilderContainer
 
     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;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index eb39d6016bfa..936216b9de68 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -1022,6 +1022,7 @@ void Qt5Frame::UpdateSettings(AllSettings& rSettings)
     Color aText = toColor(pal.color(QPalette::Active, QPalette::Text));
     Color aBase = toColor(pal.color(QPalette::Active, QPalette::Base));
     Color aButn = toColor(pal.color(QPalette::Active, QPalette::ButtonText));
+    Color aMid = toColor(pal.color(QPalette::Active, QPalette::Mid));
     Color aHigh = toColor(pal.color(QPalette::Active, QPalette::Highlight));
     Color aHighText = toColor(pal.color(QPalette::Active, 
QPalette::HighlightedText));
     Color aLink = toColor(pal.color(QPalette::Active, QPalette::Link));
@@ -1045,7 +1046,6 @@ void Qt5Frame::UpdateSettings(AllSettings& rSettings)
     style.SetFieldColor(aBase);
     style.SetWindowColor(aBase);
     style.SetActiveTabColor(aBase);
-    style.SetWorkspaceColor(aBase);
     style.SetAlternatingRowColor(toColor(pal.color(QPalette::Active, 
QPalette::AlternateBase)));
 
     // Buttons
@@ -1077,9 +1077,14 @@ void Qt5Frame::UpdateSettings(AllSettings& rSettings)
     style.BatchSetBackgrounds(aBack);
     style.SetInactiveTabColor(aBack);
 
+    // Workspace
+    style.SetWorkspaceColor(aMid);
+
     // Selection
     style.SetHighlightColor(aHigh);
     style.SetHighlightTextColor(aHighText);
+    style.SetActiveColor(aHigh);
+    style.SetActiveTextColor(aHighText);
 
     // Links
     style.SetLinkColor(aLink);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to