The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 147dcb4cb9911ff46af273bc687da3828d28a77c
Author: Vincent van Ravesteijn <v...@lyx.org>
Date:   Tue May 8 17:55:59 2012 +0200

    Make the use of system's theme icons configurable
    
    A lyxrc variable is added and a checkbox is added to the LyX->preferences
    dialog.

diff --git a/lib/scripts/prefs2prefs_prefs.py b/lib/scripts/prefs2prefs_prefs.py
index 3c0e10e..662f650 100644
--- a/lib/scripts/prefs2prefs_prefs.py
+++ b/lib/scripts/prefs2prefs_prefs.py
@@ -53,6 +53,10 @@
 # Incremented to format 11, by gb
 #   Split pdf format into pdf and pdf6
 
+# Incremented to format 12, by vfr
+#   Add option to use the system's theme icons
+#   No conversion necessary.
+
 import re
 
 ###########################################################
@@ -308,5 +312,6 @@ conversions = [
        [ 8, []],
        [ 9, [ remove_default_language ]],
        [ 10, []],
-       [ 11, [split_pdf_format]]
+       [ 11, [split_pdf_format]],
+       [ 12, []]
 ]
diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index e7e7593..d270b0e 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -55,7 +55,7 @@ namespace os = support::os;
 
 namespace {
 
-static unsigned int const LYXRC_FILEFORMAT = 11; // gb: Split pdf format into 
pdf and pdf6
+static unsigned int const LYXRC_FILEFORMAT = 12; // vfr: System theme's icons
 
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
@@ -203,6 +203,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\use_qimage", LyXRC::RC_USE_QIMAGE },
        // compatibility with versions older than 1.4.0 only
        { "\\use_system_colors", LyXRC::RC_USE_SYSTEM_COLORS },
+       { "\\use_system_theme_icons", LyXRC::RC_USE_SYSTEM_THEME_ICONS },
        { "\\use_tooltip", LyXRC::RC_USE_TOOLTIP },
        { "\\user_email", LyXRC::RC_USER_EMAIL },
        { "\\user_name", LyXRC::RC_USER_NAME },
@@ -228,6 +229,7 @@ LyXRC::LyXRC()
 void LyXRC::setDefaults()
 {
        icon_set = string();
+       use_system_theme_icons = false;
        bind_file = "cua";
        def_file = "default";
        ui_file = "default";
@@ -833,6 +835,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool 
check_format)
                        lexrc >> icon_set;
                        break;
 
+               case RC_USE_SYSTEM_THEME_ICONS:
+                       lexrc >> use_system_theme_icons;
+                       break;
+
                case RC_SCREEN_FONT_ROMAN:
                        if (lexrc.next()) {
                                roman_font_name = lexrc.getString();
@@ -1701,6 +1707,16 @@ void LyXRC::write(ostream & os, bool 
ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
 
+       case RC_USE_SYSTEM_THEME_ICONS:
+               if (ignore_system_lyxrc ||
+                         use_system_theme_icons != 
system_lyxrc.use_system_theme_icons) {
+                       os << "\\use_system_theme_icons "
+                               << convert<string>(use_system_theme_icons)
+                               << "\n";
+               }
+               if (tag != RC_LAST)
+                       break;
+
        case RC_SCREEN_DPI:
                if (ignore_system_lyxrc ||
                    dpi != system_lyxrc.dpi) {
@@ -3023,6 +3039,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC 
const & lyxrc_new)
        case LyXRC::RC_USE_TOOLTIP:
        case LyXRC::RC_USE_PIXMAP_CACHE:
        case LyXRC::RC_USE_QIMAGE:
+       case LyXRC::RC_USE_SYSTEM_THEME_ICONS:
        case LyXRC::RC_VIEWDVI_PAPEROPTION:
        case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
        case LyXRC::RC_SINGLE_INSTANCE:
diff --git a/src/LyXRC.h b/src/LyXRC.h
index 25e1fc1..de7fc64 100644
--- a/src/LyXRC.h
+++ b/src/LyXRC.h
@@ -185,6 +185,7 @@ public:
                RC_USE_TOOLTIP,
                RC_USE_PIXMAP_CACHE,
                RC_USE_QIMAGE,
+               RC_USE_SYSTEM_THEME_ICONS,
                RC_VIEWDVI_PAPEROPTION,
                RC_VIEWER,
                RC_VIEWER_ALTERNATIVES,
@@ -465,6 +466,8 @@ public:
        std::string user_email;
        /// icon set name
        std::string icon_set;
+       /// whether to use the icons from the theme
+       bool use_system_theme_icons;
        /// True if the TeX engine cannot handle posix paths
        bool windows_style_tex_paths;
        /// True if the TeX engine can handle file names containing spaces
diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index de09a1b..136b6e9 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -549,12 +549,14 @@ QPixmap getPixmap(QString const & path, QString const & 
name, QString const & ex
 QIcon getIcon(FuncRequest const & f, bool unknown)
 {
 #if (QT_VERSION >= 0x040600)
-       QString action = toqstr(lyxaction.getActionName(f.action()));
-       if (!f.argument().empty())
-               action += " " + toqstr(f.argument());
-       QString const theme_icon = themeIconName(action);
-       if (QIcon::hasThemeIcon(theme_icon))
-               return QIcon::fromTheme(theme_icon);
+       if (lyxrc.use_system_theme_icons) {
+               QString action = toqstr(lyxaction.getActionName(f.action()));
+               if (!f.argument().empty())
+                       action += " " + toqstr(f.argument());
+               QString const theme_icon = themeIconName(action);
+               if (QIcon::hasThemeIcon(theme_icon))
+                       return QIcon::fromTheme(theme_icon);
+       }
 #endif
 
        QString icon = iconName(f, unknown);
diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp
index e099d02..4d3e61c 100644
--- a/src/frontends/qt4/GuiPrefs.cpp
+++ b/src/frontends/qt4/GuiPrefs.cpp
@@ -2513,6 +2513,8 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * 
form)
                this, SIGNAL(changed()));
        connect(iconSetCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
+       connect(useSystemThemeIconsCB, SIGNAL(clicked()),
+               this, SIGNAL(changed()));
        connect(lastfilesSB, SIGNAL(valueChanged(int)),
                this, SIGNAL(changed()));
        connect(tooltipCB, SIGNAL(toggled(bool)),
@@ -2531,6 +2533,7 @@ void PrefUserInterface::apply(LyXRC & rc) const
                iconSetCO->currentIndex()).toString());
 
        rc.ui_file = internal_path(fromqstr(uiFileED->text()));
+       rc.use_system_theme_icons = useSystemThemeIconsCB->isChecked();
        rc.num_lastfiles = lastfilesSB->value();
        rc.use_tooltip = tooltipCB->isChecked();
 }
@@ -2542,6 +2545,11 @@ void PrefUserInterface::update(LyXRC const & rc)
        if (iconset < 0)
                iconset = 0;
        iconSetCO->setCurrentIndex(iconset);
+#if (QT_VERSION < 0x040600)
+       useSystemThemeIconsCB->hide();
+       themeIconsLA->hide();
+#endif
+       useSystemThemeIconsCB->setChecked(rc.use_system_theme_icons);
        uiFileED->setText(toqstr(external_path(rc.ui_file)));
        lastfilesSB->setValue(rc.num_lastfiles);
        tooltipCB->setChecked(rc.use_tooltip);
diff --git a/src/frontends/qt4/ui/PrefUi.ui b/src/frontends/qt4/ui/PrefUi.ui
index 1e6a7de..4b55628 100644
--- a/src/frontends/qt4/ui/PrefUi.ui
+++ b/src/frontends/qt4/ui/PrefUi.ui
@@ -100,6 +100,23 @@
         </item>
        </layout>
       </item>
+      <item row="2" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_4">
+        <item>
+         <widget class="QLabel" name="themeIconsLA">
+          <property name="text" >
+           <string>Use icons from system's &amp;theme:</string>
+          </property>
+          <property name="buddy" >
+           <cstring>useSystemThemeIconsCB</cstring>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="useSystemThemeIconsCB"/>
+        </item>
+       </layout>
+      </item>
      </layout>
     </widget>
    </item>
@@ -200,6 +217,7 @@
   <tabstop>uiFileED</tabstop>
   <tabstop>uiFilePB</tabstop>
   <tabstop>iconSetCO</tabstop>
+  <tabstop>useSystemThemeIconsCB</tabstop>
   <tabstop>tooltipCB</tabstop>
  </tabstops>
  <includes>

-----------------------------------------------------------------------

Summary of changes:
 lib/scripts/prefs2prefs_prefs.py     |    7 ++++++-
 src/LyXRC.cpp                        |   19 ++++++++++++++++++-
 src/LyXRC.h                          |    3 +++
 src/frontends/qt4/GuiApplication.cpp |   14 ++++++++------
 src/frontends/qt4/GuiPrefs.cpp       |    8 ++++++++
 src/frontends/qt4/ui/PrefUi.ui       |   18 ++++++++++++++++++
 6 files changed, 61 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to