diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-02-06 20:53:55 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-02-08 16:11:25 +0000 |
commit | f7c03364e24da285ea95cea0cc688a7a120fc163 (patch) | |
tree | b6dc20e02654f5144daea807303dbdd71a72bba0 /cui | |
parent | 68ab2e109edf8b81c48e953f7c8d43841e07365a (diff) |
tdf#153229 add a switch to override honoring system dark mode
Change-Id: Iafb6182e05dc65d20d0809476ee58908f7426d39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146597
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/options/optgdlg.cxx | 33 | ||||
-rw-r--r-- | cui/source/options/optgdlg.hxx | 2 | ||||
-rw-r--r-- | cui/uiconfig/ui/optviewpage.ui | 106 |
3 files changed, 120 insertions, 21 deletions
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 4405fdb3e76b..5663d3912488 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -528,6 +528,8 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p , m_xIconSizeLB(m_xBuilder->weld_combo_box("iconsize")) , m_xSidebarIconSizeLB(m_xBuilder->weld_combo_box("sidebariconsize")) , m_xNotebookbarIconSizeLB(m_xBuilder->weld_combo_box("notebookbariconsize")) + , m_xDarkModeFrame(m_xBuilder->weld_widget("darkmode")) + , m_xAppearanceStyleLB(m_xBuilder->weld_combo_box("appearance")) , m_xIconStyleLB(m_xBuilder->weld_combo_box("iconstyle")) , m_xFontAntiAliasing(m_xBuilder->weld_check_button("aafont")) , m_xAAPointLimitLabel(m_xBuilder->weld_label("aafrom")) @@ -547,9 +549,14 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p , m_xMoreIcons(m_xBuilder->weld_button("btnMoreIcons")) , m_xRunGPTests(m_xBuilder->weld_button("btn_rungptest")) { - if (Application::GetToolkitName().startsWith("gtk")) + OUString sToolKitName(Application::GetToolkitName()); + if (sToolKitName.startsWith("gtk")) m_xMenuIconBox->hide(); + const bool bHasDarkMode = sToolKitName.startsWith("gtk") || sToolKitName == "osx" || sToolKitName == "win"; + if (!bHasDarkMode) + m_xDarkModeFrame->hide(); + m_xFontAntiAliasing->connect_toggled( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) ); m_xUseSkia->connect_toggled(LINK(this, OfaViewTabPage, OnUseSkiaToggled)); @@ -668,6 +675,7 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) { bool bModified = false; bool bMenuOptModified = false; + bool bDarkModeOptModified = false; bool bRepaintWindows(false); std::shared_ptr<comphelper::ConfigurationChanges> xChanges(comphelper::ConfigurationChanges::create()); @@ -781,6 +789,12 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) bAppearanceChanged = true; } + if (m_xAppearanceStyleLB->get_value_changed_from_saved()) + { + bDarkModeOptModified = true; + bModified = true; + } + if (m_xContextMenuShortcutsLB->get_value_changed_from_saved()) { officecfg::Office::Common::View::Menu::ShortcutsInContextMenus::set( @@ -824,12 +838,20 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) xChanges->commit(); - if( bMenuOptModified ) + if (bMenuOptModified || bDarkModeOptModified) { // Set changed settings to the application instance AllSettings aAllSettings = Application::GetSettings(); - StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); - aAllSettings.SetStyleSettings(aStyleSettings); + + if (bMenuOptModified) + { + StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); + aAllSettings.SetStyleSettings(aStyleSettings); + } + + if (bDarkModeOptModified) + MiscSettings::SetDarkMode(m_xAppearanceStyleLB->get_active()); + Application::MergeSystemSettings( aAllSettings ); Application::SetSettings(aAllSettings); } @@ -912,6 +934,9 @@ void OfaViewTabPage::Reset( const SfxItemSet* ) m_xIconStyleLB->set_active(nStyleLB_InitialSelection); m_xIconStyleLB->save_value(); + m_xAppearanceStyleLB->set_active(officecfg::Office::Common::Misc::Appearance::get()); + m_xAppearanceStyleLB->save_value(); + // Mouse Snap m_xMousePosLB->set_active(static_cast<sal_Int32>(pAppearanceCfg->GetSnapMode())); m_xMousePosLB->save_value(); diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx index a4c686cc2b27..870e3f39bccc 100644 --- a/cui/source/options/optgdlg.hxx +++ b/cui/source/options/optgdlg.hxx @@ -87,6 +87,8 @@ private: std::unique_ptr<weld::ComboBox> m_xIconSizeLB; std::unique_ptr<weld::ComboBox> m_xSidebarIconSizeLB; std::unique_ptr<weld::ComboBox> m_xNotebookbarIconSizeLB; + std::unique_ptr<weld::Widget> m_xDarkModeFrame; + std::unique_ptr<weld::ComboBox> m_xAppearanceStyleLB; std::unique_ptr<weld::ComboBox> m_xIconStyleLB; std::unique_ptr<weld::CheckButton> m_xFontAntiAliasing; diff --git a/cui/uiconfig/ui/optviewpage.ui b/cui/uiconfig/ui/optviewpage.ui index ac6b7fcde239..c0ea6b0f2bef 100644 --- a/cui/uiconfig/ui/optviewpage.ui +++ b/cui/uiconfig/ui/optviewpage.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.38.2 --> +<!-- Generated with glade 3.40.0 --> <interface domain="cui"> <requires lib="gtk+" version="3.20"/> <object class="GtkAdjustment" id="adjustment2"> @@ -18,7 +18,7 @@ <property name="border-width">6</property> <property name="column-spacing">24</property> <child> - <!-- n-columns=1 n-rows=4 --> + <!-- n-columns=1 n-rows=5 --> <object class="GtkGrid" id="grid2"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -126,7 +126,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">3</property> + <property name="top-attach">4</property> </packing> </child> <child> @@ -249,7 +249,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">2</property> + <property name="top-attach">3</property> </packing> </child> <child> @@ -390,7 +390,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">1</property> + <property name="top-attach">2</property> </packing> </child> <child> @@ -474,6 +474,76 @@ </object> <packing> <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="darkmode"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="label-xalign">0</property> + <property name="shadow-type">none</property> + <child> + <!-- n-columns=2 n-rows=1 --> + <object class="GtkGrid" id="refgrid2"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-start">12</property> + <property name="margin-top">6</property> + <property name="hexpand">True</property> + <property name="column-spacing">6</property> + <child> + <object class="GtkComboBoxText" id="appearance"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="active">0</property> + <items> + <item translatable="yes" context="optviewpage|appearance">Automatic</item> + <item translatable="yes" context="optviewpage|appearance">Light</item> + <item translatable="yes" context="optviewpage|appearance">Dark</item> + </items> + <child internal-child="accessible"> + <object class="AtkObject" id="appearance-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip | iconstyle">Specifies the icon style for icons in toolbars and dialogs.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="optviewpage|label7">Mode:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">iconstyle</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label16"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="optviewpage|label16">Appearance</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="left-attach">0</property> <property name="top-attach">0</property> </packing> </child> @@ -757,26 +827,28 @@ </object> <object class="GtkSizeGroup" id="sizegroupLabel"> <widgets> - <widget name="label6"/> - <widget name="label14"/> - <widget name="label8"/> - <widget name="label9"/> - <widget name="label13"/> - <widget name="label10"/> <widget name="label11"/> <widget name="label12"/> + <widget name="label13"/> + <widget name="label10"/> + <widget name="label8"/> + <widget name="label9"/> + <widget name="label14"/> + <widget name="label6"/> + <widget name="label7"/> </widgets> </object> <object class="GtkSizeGroup" id="sizegroupWidget"> <widgets> - <widget name="iconstyle"/> - <widget name="iconsize"/> - <widget name="notebookbariconsize"/> - <widget name="sidebariconsize"/> - <widget name="menuicons"/> - <widget name="contextmenushortcuts"/> <widget name="mousepos"/> <widget name="mousemiddle"/> + <widget name="menuicons"/> + <widget name="contextmenushortcuts"/> + <widget name="notebookbariconsize"/> + <widget name="sidebariconsize"/> + <widget name="iconsize"/> + <widget name="iconstyle"/> + <widget name="appearance"/> </widgets> </object> </interface> |