diff options
author | Sahil Gautam <sahil.gautam.extern@allotropia.de> | 2024-12-19 22:06:10 +0530 |
---|---|---|
committer | Sahil Gautam <sahil.gautam.extern@allotropia.de> | 2024-12-19 20:26:13 +0100 |
commit | f1130f7f8aef49c86c39b9fbd377eab6d0346d21 (patch) | |
tree | bd416ab68fd06fe800d0c419bc9d4f086cc50070 | |
parent | d9e99472767428d190c6a1100c6a0221cc229859 (diff) |
tdf#163620 Allow users to modify "Appearance" for Automatic scheme
Disabling "Appearance" options for Automatic scheme is pointless
and it's bad UX as the users don't have any clue about what's
going on.
"Normal user should have our old feature - to select
dark/light/system theme in only one action. Customizing theme is
absolutely another thing" -- Kompilainenn (LO Design Team)
Change-Id: I181420daefd29e0f7a7d638d9c7a26034c40c566
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178828
Reviewed-by: Sahil Gautam <sahil.gautam.extern@allotropia.de>
Tested-by: Jenkins
(cherry picked from commit e87b50fb4936c221bdfb0fe6e8efd15251f6f38f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178835
-rw-r--r-- | cui/source/options/appearance.cxx | 53 | ||||
-rw-r--r-- | cui/source/options/appearance.hxx | 1 |
2 files changed, 39 insertions, 15 deletions
diff --git a/cui/source/options/appearance.cxx b/cui/source/options/appearance.cxx index c2630cfaade0..3f4c7c6ca247 100644 --- a/cui/source/options/appearance.cxx +++ b/cui/source/options/appearance.cxx @@ -35,7 +35,7 @@ struct BitmapData std::vector<BitmapData> const& getBitmapList() { - static std::vector<BitmapData> m_aBitmapList = { + static const std::vector<BitmapData> aBitmapList = { { CuiResId(BMP_FUZZY_LIGHTGREY), "fuzzy-lightgrey.jpg" }, { CuiResId(BMP_ICE_LIGHT), "ice-light.jpg" }, { CuiResId(BMP_PAINTED_WHITE), "painted-white.jpg" }, @@ -82,7 +82,7 @@ std::vector<BitmapData> const& getBitmapList() { CuiResId(BMP_TIGER), "tiger.jpg" }, { CuiResId(BMP_ZEBRA), "zebra.png" }, }; - return m_aBitmapList; + return aBitmapList; } } @@ -120,9 +120,6 @@ void SvxAppearanceTabPage::UpdateControlsState() { // in case of AUTOMATIC_COLOR_SCHEME, disable all the controls bool bEnableControls = m_xSchemeList->get_active_id() != AUTOMATIC_COLOR_SCHEME; - m_xAppearanceSystem->set_sensitive(bEnableControls); - m_xAppearanceLight->set_sensitive(bEnableControls); - m_xAppearanceDark->set_sensitive(bEnableControls); m_xColorEntryBtn->set_sensitive(bEnableControls); m_xColorChangeBtn->set_sensitive(bEnableControls); m_xShowInDocumentChkBtn->set_sensitive(bEnableControls); @@ -184,6 +181,12 @@ bool SvxAppearanceTabPage::FillItemSet(SfxItemSet* /* rSet */) { MiscSettings::SetAppColorMode(static_cast<int>(eCurrentAppearanceMode)); m_bRestartRequired = true; + // for automatic scheme, restart is not required as customizations section is disabled + if (pColorConfig->GetCurrentSchemeName() == AUTOMATIC_COLOR_SCHEME) + { + UpdateOldAppearance(); + m_bRestartRequired = false; + } } // commit ColorConfig @@ -563,6 +566,26 @@ void SvxAppearanceTabPage::UpdateColorDropdown() m_xColorChangeBtn->SelectEntry(rCurrentEntryColor.nLightColor); } +// if the user changes appearance options for automatic theme, then follow the old behaviour +// and change the document colors to light/dark based on the choice. +void SvxAppearanceTabPage::UpdateOldAppearance() +{ + if (pColorConfig->GetCurrentSchemeName() != AUTOMATIC_COLOR_SCHEME) + return; + + ColorConfigValue aValue; + bool bIsDarkModeEnabled = IsDarkModeEnabled(); + for (size_t i = 0; i < WINDOWCOLOR; ++i) + { + if (bIsDarkModeEnabled) + aValue.nDarkColor = ColorConfig::GetDefaultColor(static_cast<ColorConfigEntry>(i), 1); + else + aValue.nLightColor = ColorConfig::GetDefaultColor(static_cast<ColorConfigEntry>(i), 0); + + pColorConfig->SetColorValue(static_cast<ColorConfigEntry>(i), aValue); + } +} + bool SvxAppearanceTabPage::IsDarkModeEnabled() { return eCurrentAppearanceMode == Appearance::DARK @@ -571,7 +594,7 @@ bool SvxAppearanceTabPage::IsDarkModeEnabled() void SvxAppearanceTabPage::FillItemsList() { - static std::map<ColorConfigEntry, OUString> m_aRegistryEntries + static const std::map<ColorConfigEntry, OUString> aRegistryEntries = { { DOCCOLOR, CuiResId(REG_DOCCOLOR) }, { DOCBOUNDARIES, CuiResId(REG_DOCBOUNDARIES) }, { APPBACKGROUND, CuiResId(REG_APPBACKGROUND) }, @@ -667,45 +690,45 @@ void SvxAppearanceTabPage::FillItemsList() for (size_t i = DOCCOLOR; i <= SHADOWCOLOR; ++i) m_xColorEntryBtn->append(OUString(cNames[i].cName), - m_aRegistryEntries[static_cast<ColorConfigEntry>(i)]); + aRegistryEntries.at(static_cast<ColorConfigEntry>(i))); m_xColorEntryBtn->append_separator("SeparatorID"); for (size_t i = WRITERTEXTGRID; i <= WRITERNONPRINTCHARS; ++i) m_xColorEntryBtn->append(OUString(cNames[i].cName), - m_aRegistryEntries[static_cast<ColorConfigEntry>(i)]); + aRegistryEntries.at(static_cast<ColorConfigEntry>(i))); m_xColorEntryBtn->append_separator("SeparatorID"); for (size_t i = HTMLSGML; i <= HTMLUNKNOWN; ++i) m_xColorEntryBtn->append(OUString(cNames[i].cName), - m_aRegistryEntries[static_cast<ColorConfigEntry>(i)]); + aRegistryEntries.at(static_cast<ColorConfigEntry>(i))); m_xColorEntryBtn->append_separator("SeparatorID"); for (size_t i = CALCGRID; i <= CALCPROTECTEDBACKGROUND; ++i) m_xColorEntryBtn->append(OUString(cNames[i].cName), - m_aRegistryEntries[static_cast<ColorConfigEntry>(i)]); + aRegistryEntries.at(static_cast<ColorConfigEntry>(i))); m_xColorEntryBtn->append_separator("SeparatorID"); - m_xColorEntryBtn->append(OUString(cNames[DRAWGRID].cName), m_aRegistryEntries[DRAWGRID]); + m_xColorEntryBtn->append(OUString(cNames[DRAWGRID].cName), aRegistryEntries.at(DRAWGRID)); m_xColorEntryBtn->append_separator("SeparatorID"); for (size_t i = AUTHOR1; i <= AUTHOR9; ++i) m_xColorEntryBtn->append(OUString(cNames[i].cName), - m_aRegistryEntries[static_cast<ColorConfigEntry>(i)]); + aRegistryEntries.at(static_cast<ColorConfigEntry>(i))); m_xColorEntryBtn->append_separator("SeparatorID"); for (size_t i = BASICEDITOR; i <= BASICERROR; ++i) m_xColorEntryBtn->append(OUString(cNames[i].cName), - m_aRegistryEntries[static_cast<ColorConfigEntry>(i)]); + aRegistryEntries.at(static_cast<ColorConfigEntry>(i))); m_xColorEntryBtn->append_separator("SeparatorID"); for (size_t i = SQLIDENTIFIER; i <= SQLCOMMENT; ++i) m_xColorEntryBtn->append(OUString(cNames[i].cName), - m_aRegistryEntries[static_cast<ColorConfigEntry>(i)]); + aRegistryEntries.at(static_cast<ColorConfigEntry>(i))); m_xColorEntryBtn->append_separator("SeparatorID"); for (size_t i = WINDOWCOLOR; i <= INACTIVEBORDERCOLOR; ++i) m_xColorEntryBtn->append(OUString(cNames[i].cName), - m_aRegistryEntries[static_cast<ColorConfigEntry>(i)]); + aRegistryEntries.at(static_cast<ColorConfigEntry>(i))); } size_t SvxAppearanceTabPage::GetActiveEntry() diff --git a/cui/source/options/appearance.hxx b/cui/source/options/appearance.hxx index 05d9a99b52c5..7675d54e3bc4 100644 --- a/cui/source/options/appearance.hxx +++ b/cui/source/options/appearance.hxx @@ -85,6 +85,7 @@ private: void UpdateRemoveBtnState(); void EnableImageControls(bool bEnabled); void UpdateColorDropdown(); + void UpdateOldAppearance(); bool IsDarkModeEnabled(); void FillItemsList(); size_t GetActiveEntry(); |