]> git.lyx.org Git - features.git/commitdiff
Implement ui style selection dialog 12832 attempt 2
authorEugene Chornyi <yu_jin@lyx.org>
Sun, 15 Oct 2023 06:46:12 +0000 (08:46 +0200)
committerEugene Chornyi <yu_jin@lyx.org>
Sun, 15 Oct 2023 06:46:12 +0000 (08:46 +0200)
lib/RELEASE-NOTES
lib/configure.py
lib/doc/UserGuide.lyx
lib/scripts/prefs2prefs_prefs.py
src/LyX.cpp
src/LyXRC.cpp
src/LyXRC.h
src/frontends/Application.h
src/frontends/qt/GuiApplication.cpp
src/frontends/qt/GuiPrefs.cpp
src/frontends/qt/ui/PrefUi.ui

index 9b939b736d1ba1f94d0a5e3f2c7a3ea516d921b9..cc5a3e19fcde845fe89a92d4dbba3862a3559973 100644 (file)
@@ -53,6 +53,9 @@
 
 * Edit > Paste operation now preserves newlines in text by default.
 
+* Dark mode on Windows is possible now by choosing "fusion" user interface style
+  in the user interface preferences dialog, your system style has to be set to dark.
+
 
 !!Documents compilation process and images conversion
 
index e5f71f7a2a5d3bb29eb95b0e8af94bd981a51cdc..5d0806e2678af99e8d3935ff8919d0182b4c9d71 100644 (file)
@@ -2004,7 +2004,7 @@ if __name__ == '__main__':
     lyx_check_config = True
     lyx_kpsewhich = True
     outfile = 'lyxrc.defaults'
-    lyxrc_fileformat = 37
+    lyxrc_fileformat = 38
     rc_entries = ''
     lyx_keep_temps = False
     version_suffix = ''
index 1239e73704a03561e7ddb5383b478b9a3a09c90f..a4a53cff676592ba5f80290ae74be55cdbebf209 100644 (file)
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 618
+\lyxformat 620
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -167,6 +167,7 @@ logicalmkup
 \author 5863208 "ab"
 \author 5863344 "Enrico Forestieri"
 \author 244031559 "Yuriy"
+\author 258250489 "eugen"
 \author 274215730 "scott"
 \author 630872221 "Jean-Pierre Chrétien" jeanpierre.chretien@free.fr
 \author 1064312605 "Udi Fogiel"
@@ -58115,6 +58116,33 @@ literal "false"
 \end_inset
 
 .
+\change_inserted 258250489 1697053558
+
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted 258250489 1697054388
+
+\family sans
+User
+\begin_inset space ~
+\end_inset
+
+interface
+\begin_inset space ~
+\end_inset
+
+style
+\family default
+ allows you to change the look and feel of \SpecialChar LyX
+'s user interface control elements.
+ There may be different choices available on different operating systems.
+ On certain operating systems some styles may support dark mode while others don't.
+ In order to use dark mode in \SpecialChar LyX
+ you may first need to enable it in your system's settings.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Subsubsection
index a5a3a7dbf1bc418bffd00c0afce51047520dd82f..69b97fd30ef146709cf6c4d1118297aa4787415d 100644 (file)
 #  Add \screen_width
 #  Add \screen_limit
 
+# Incremented to format 38, by ec
+#   Add option to configure ui style
+#   No conversion necessary.
+
 # NOTE: The format should also be updated in LYXRC.cpp and
 # in configure.py (search for lyxrc_fileformat).
 
@@ -555,5 +559,6 @@ conversions = [
        [ 34, [rename_cyrillic_kmap_files]],
        [ 35, [add_dark_color]],
        [ 36, [add_spellcheck_default]],
-       [ 37, [remove_fullscreen_widthlimit]]
+       [ 37, [remove_fullscreen_widthlimit]],
+       [ 38, []]
 ]
index 04c1dd4f257e49e962cba22f24452b0f94dd96da..d077771b8dddbe80992195cbced4ae9e324ca4c0 100644 (file)
@@ -997,6 +997,7 @@ bool LyX::init()
        // This one is edited through the preferences dialog.
        if (!readRcFile("preferences", true))
                return false;
+       pimpl_->application_->applyPrefs();
 
        // The language may have been set to someting useful through prefs
        setLocale();
index fa50d4a51d8aa2832ac8781bc93b5c85e6b947dd..73aec189f30cc38b6e7cb28e73167cbf85c4fd73 100644 (file)
@@ -60,7 +60,7 @@ namespace {
 
 // The format should also be updated in configure.py, and conversion code
 // should be added to prefs2prefs_prefs.py.
-static unsigned int const LYXRC_FILEFORMAT = 37; // chillenb: screen_width and screen_limit
+static unsigned int const LYXRC_FILEFORMAT = 38; // chillenb: screen_width and screen_limit
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
        { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
@@ -197,6 +197,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\texinputs_prefix", LyXRC::RC_TEXINPUTS_PREFIX },
        { "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH },
        { "\\ui_file", LyXRC::RC_UIFILE },
+       { "\\ui_style", LyXRC::RC_UI_STYLE },
        { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
        { "\\use_converter_needauth", LyXRC::RC_USE_CONVERTER_NEEDAUTH },
        { "\\use_converter_needauth_forbidden", LyXRC::RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN },
@@ -603,6 +604,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                        lexrc >> icon_set;
                        break;
 
+               case RC_UI_STYLE:
+                       lexrc >> ui_style;
+                       break;
+
                case RC_USE_SYSTEM_THEME_ICONS:
                        lexrc >> use_system_theme_icons;
                        break;
@@ -1624,6 +1629,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
                // fall through
+       case RC_UI_STYLE:
+               if (ignore_system_lyxrc ||
+                       ui_style != system_lyxrc.ui_style) {
+                       os << "\\ui_style \"" << ui_style
+                               << "\"\n";
+               }
+               if (tag != RC_LAST)
+                       break;
+               // fall through
        case RC_USE_SYSTEM_THEME_ICONS:
                if (ignore_system_lyxrc ||
                          use_system_theme_icons != system_lyxrc.use_system_theme_icons) {
@@ -2950,6 +2964,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_GROUP_LAYOUTS:
        case LyXRC::RC_HUNSPELLDIR_PATH:
        case LyXRC::RC_ICON_SET:
+       case LyXRC::RC_UI_STYLE:
        case LyXRC::RC_INDEX_ALTERNATIVES:
        case LyXRC::RC_INDEX_COMMAND:
        case LyXRC::RC_JBIBTEX_COMMAND:
index c196d579f13f5776062d4ee8c8606d60d14bfc12..039cf5658ce6a0a700b5d5b51ff96d8abcbe0730 100644 (file)
@@ -173,6 +173,7 @@ public:
                RC_TEXINPUTS_PREFIX,
                RC_THESAURUSDIRPATH,
                RC_UIFILE,
+               RC_UI_STYLE,
                RC_USELASTFILEPOS,
                RC_USER_EMAIL,
                RC_USER_INITIALS,
@@ -473,6 +474,8 @@ public:
        std::string user_initials;
        /// icon set name
        std::string icon_set;
+       /// ui style name
+       std::string ui_style = "default";
        /// whether to use the icons from the theme
        bool use_system_theme_icons = false;
        /// True if the TeX engine cannot handle posix paths
index 053a699f8c4a8e39c680bf55968bf66c519d3be0..75298ca67af4e77f1032746a44d20c3e1f3c8519 100644 (file)
@@ -253,6 +253,8 @@ public:
 
        // Add a buffer to the current view, do not switch to it.
        virtual bool unhide(Buffer * buf) = 0;
+       // Apply preferences at the start
+       static void applyPrefs();
 };
 
 /// Return the list of loadable formats.
index b7abd4297fca1e6b3cfa917f7265892ebda35599..d1c91fbb0113c245989dad3e0740bcf5241db9f4 100644 (file)
@@ -1268,6 +1268,11 @@ docstring Application::mathIcon(docstring const & c)
        return qstring_to_ucs4(findImg(toqstr(c)));
 }
 
+void Application::applyPrefs()
+{
+       if (lyxrc.ui_style != system_lyxrc.ui_style)
+               lyx::frontend::GuiApplication::setStyle(toqstr(lyxrc.ui_style));
+}
 
 FuncStatus GuiApplication::getStatus(FuncRequest const & cmd) const
 {
index 9836086a9282db067dd1f2b2d11376ab698c5910..405f255787e2206c867a6a116c3850d90097217c 100644 (file)
@@ -63,6 +63,7 @@
 #include <QPushButton>
 #include <QSpinBox>
 #include <QString>
+#include <QStyleFactory>
 #include <QTreeWidget>
 #include <QTreeWidgetItem>
 #include <QValidator>
@@ -2494,6 +2495,8 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(iconSetCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
+       connect(uiStyleCO, SIGNAL(activated(int)),
+               this, SIGNAL(changed()));
        connect(useSystemThemeIconsCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(lastfilesSB, SIGNAL(valueChanged(int)),
@@ -2516,6 +2519,12 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form)
        iconSetCO->addItem(qt_("Classic"), "classic");
        iconSetCO->addItem(qt_("Oxygen"), "oxygen");
 
+       uiStyleCO->addItem(toqstr(system_lyxrc.ui_style));
+       for (const auto& style : QStyleFactory::keys())
+       {
+               uiStyleCO->addItem(style.toLower());
+       }
+
        if (guiApp->platformName() != "xcb"
            && !guiApp->platformName().contains("wayland"))
                useSystemThemeIconsCB->hide();
@@ -2527,6 +2536,10 @@ void PrefUserInterface::applyRC(LyXRC & rc) const
        rc.icon_set = fromqstr(iconSetCO->itemData(
                iconSetCO->currentIndex()).toString());
 
+       rc.ui_style = fromqstr(uiStyleCO->currentText());
+       if (rc.ui_style!=system_lyxrc.ui_style)
+               frontend::GuiApplication::setStyle(uiStyleCO->currentText());
+
        rc.ui_file = internal_path(fromqstr(uiFileED->text()));
        rc.use_system_theme_icons = useSystemThemeIconsCB->isChecked();
        rc.num_lastfiles = lastfilesSB->value();
@@ -2545,6 +2558,7 @@ void PrefUserInterface::updateRC(LyXRC const & rc)
        if (iconset < 0)
                iconset = 0;
        iconSetCO->setCurrentIndex(iconset);
+       uiStyleCO->setCurrentIndex(uiStyleCO->findText(toqstr(rc.ui_style)));
        useSystemThemeIconsCB->setChecked(rc.use_system_theme_icons);
        uiFileED->setText(toqstr(external_path(rc.ui_file)));
        lastfilesSB->setValue(rc.num_lastfiles);
index d7551cbb3d55d362aafd8cc758a067665da64573..7a2c8d4711f188803f4d0abd7e08991f9850e828 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>556</width>
-    <height>476</height>
+    <height>502</height>
    </rect>
   </property>
   <property name="sizePolicy">
       </item>
       <item row="0" column="0">
        <layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0">
+        <item row="1" column="2">
+         <layout class="QHBoxLayout" name="horizontalLayout"/>
+        </item>
+        <item row="0" column="2">
+         <widget class="QPushButton" name="uiFilePB">
+          <property name="text">
+           <string>Bro&amp;wse...</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="1">
+         <widget class="QComboBox" name="iconSetCO">
+          <property name="toolTip">
+           <string>The icon set to use. Warning: normal size of icons may be wrong until you save the preferences and restart LyX.</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="0">
+         <widget class="QLabel" name="iconSetLA">
+          <property name="text">
+           <string>&amp;Icon set:</string>
+          </property>
+          <property name="buddy">
+           <cstring>iconSetCO</cstring>
+          </property>
+         </widget>
+        </item>
         <item row="0" column="0">
          <widget class="QLabel" name="uiFileLA">
           <property name="text">
         <item row="0" column="1">
          <widget class="QLineEdit" name="uiFileED"/>
         </item>
-        <item row="0" column="2">
-         <widget class="QPushButton" name="uiFilePB">
+        <item row="2" column="0">
+         <widget class="QLabel" name="uiStyleLA">
           <property name="text">
-           <string>Bro&amp;wse...</string>
-          </property>
-         </widget>
-        </item>
-        <item row="1" column="0">
-         <widget class="QLabel" name="iconSetLA">
-          <property name="text">
-           <string>&amp;Icon set:</string>
+           <string>User interface &amp;style:</string>
           </property>
           <property name="buddy">
-           <cstring>iconSetCO</cstring>
+           <cstring>uiStyleCO</cstring>
           </property>
          </widget>
         </item>
-        <item row="1" column="1">
-         <widget class="QComboBox" name="iconSetCO">
+        <item row="2" column="1">
+         <widget class="QComboBox" name="uiStyleCO">
           <property name="toolTip">
-           <string>The icon set to use. Warning: normal size of icons may be wrong until you save the preferences and restart LyX.</string>
+           <string>Only certain styles may support dark mode, e.g. fusion on Windows</string>
           </property>
          </widget>
         </item>
-        <item row="1" column="2">
-         <layout class="QHBoxLayout" name="horizontalLayout"/>
+        <item row="2" column="2">
+         <layout class="QHBoxLayout" name="horizontalLayout_2"/>
         </item>
        </layout>
       </item>