Bug 160349 - Add toolbar icons to change UI and scheme to switch Light/Dark
Summary: Add toolbar icons to change UI and scheme to switch Light/Dark
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Justin L
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Notebookbar Dark-Mode
  Show dependency treegraph
 
Reported: 2024-03-25 10:43 UTC by Timur
Modified: 2024-05-01 12:27 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timur 2024-03-25 10:43:09 UTC
LO can change UI and document background colors scheme in Tools-Options but it takes time.
Especially for testers, it would be useful to have drop-down icons in toolbar to be able to change:

1. Tools > Options > LibreOffice > View
2. Tools > Options > LibreOffice > Appearance
Comment 1 Rafael Lima 2024-03-25 11:54:17 UTC
This might be useful not only for testers, but for users as well. I'm not sure this command should be visible by default though.

FTR this is not something that can be done via macro, because simply changing the value of the ApplicationAppearance entry won't automatically apply it.

The actual code to apply the changes are in ColorConfig_Impl::Load, which is not accessible to macros.
Comment 2 Heiko Tietze 2024-03-26 10:30:17 UTC
Strong -1 from my side to expose these configuration switches in the primary UI. Nothing to say against making the life easier for QA but it's quite some work and could be done per macro.
Comment 3 Rafael Lima 2024-04-04 13:26:35 UTC
FTR this is the macro that I created to change the Appearance option. It does change the appearance option in the registry, but it does not get applied until LO is restarted. Hence, AFAIK this cannot be achieved solely via macros.

Sub ToggleDarkLight
  Dim oConfigProvider As Object
  Dim oConfigAccess As Object
  Dim pNode(0) As New com.sun.star.beans.PropertyValue
  oConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider")
  pNode(0).Name = "nodepath"
  pNode(0).Value = "org.openoffice.Office.Common/Misc"
  oConfigAccess = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", pNode)
  Dim nCurValue As Integer
  nCurValue = oConfigAccess.ApplicationAppearance
  ' Values can be 0: Automatic; 1: Light; 2: Dark
  If nCurValue >= 2 Then
    oConfigAccess.ApplicationAppearance = 0
  Else
    oConfigAccess.ApplicationAppearance = nCurValue + 1
  End If
  oConfigAccess.CommitChanges()
End Sub
Comment 4 Heiko Tietze 2024-04-05 12:29:52 UTC
We discussed the topic in the design meeting.

The idea seems to be supported by the fact that MSO provides a mode switch, see
https://support.microsoft.com/en-gb/office/dark-mode-in-word-e17b79a3-762f-4280-a81c-a15a859a693a

The argument to not add rarely used functions to the primary UI, in particular not when the option is part of a user-defined list (color schemes can be added; dark/light change the value of Automatic) was rejected.

So let's add the command.
Comment 5 Justin L 2024-04-27 13:03:14 UTC
There appears to be an existing uno command to do this.
    .uno:ChangeTheme  (FN_CHANGE_THEME)
and is often used in unit tests.

sfx/sdi/sfx.sdi would need
AccelConfig = TRUE,  // keyboard shortcuts IIUC
MenuConfig = TRUE,   // Menu entry
ToolBoxConfig = TRUE // can be added to toolbar

and probably Toggle = TRUE as well as ReadOnlyDoc = TRUE

FN_CHANGE_THEME already knows the GetCurrentSchemeName (maybe), and if it is auto (system), then MiscSettings::GetUseDarkMode() might indicate if the OS is asking for dark mode.

MiscSettings::GetDarkMode() returns 0(system) 1(light) or 2(dark)
from officecfg::Office::Common::Misc::Appearance
and MiscSettings::SetDarkMode(0/1/2) triggers a redraw to the new mode.

The options page managing the AppearanceStyle is cui/source/options/optdlg.cxx.
Comment 6 Justin L 2024-04-27 17:14:05 UTC
proposed at https://gerrit.libreoffice.org/c/core/+/166781
Comment 7 Justin L 2024-05-01 12:27:23 UTC
(In reply to Justin L from comment #5)
> options page managing the AppearanceStyle is cui/source/options/optgdlg.cxx
The UI theme is hidden on the config page except for certain VCLs
    const bool bHasDarkMode = sToolKitName.startsWith("gtk")
        || sToolKitName == "osx" || sToolKitName == "win";
    if (!bHasDarkMode)
        m_xDarkModeFrame->hide();