]> git.lyx.org Git - features.git/commitdiff
Amend fix for #10428
authorEnrico Forestieri <forenr@lyx.org>
Wed, 23 Nov 2016 16:30:49 +0000 (17:30 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 23 Nov 2016 16:30:49 +0000 (17:30 +0100)
- Allow using logical values for icon sizes as the standard sizes may
  differ among different icon sets
- Do not allow setting sizes smaller than smallIconSize

When the logical sizes differ and the icon set is changed, the correct
sizes are established only after a restart.

lib/ui/stdcontext.inc
lib/ui/stdmenus.inc
src/LyXAction.cpp
src/frontends/qt4/GuiView.cpp

index abba2650318ca494c8eff93c2869d8ef8c61d840..a229b4af4bd45aa6e214de1ce857b5436f7b7efc 100644 (file)
@@ -665,11 +665,11 @@ Menuset
        Menu "context-toolbars"
                Toolbars
                Separator
-               Item "Small-sized Icons" "icon-size 16"
-               Item "Normal-sized Icons" "icon-size 20"
-               Item "Big-sized Icons" "icon-size 26"
-               Item "Huge-sized Icons" "icon-size 32"
-               Item "Giant-sized Icons" "icon-size 48"
+               Item "Small-sized Icons" "icon-size small"
+               Item "Normal-sized Icons" "icon-size normal"
+               Item "Big-sized Icons" "icon-size big"
+               Item "Huge-sized Icons" "icon-size huge"
+               Item "Giant-sized Icons" "icon-size giant"
        End
 
 End
index 06614c89970e2ba6a5e2d9259718b115cf63a5aa..3404fa8afc3eb43c9843bb0c1831467701da36ff 100644 (file)
@@ -351,11 +351,11 @@ Menuset
        Menu "toolbars"
                Toolbars
                Separator
-               Item "Small-sized Icons" "icon-size 16"
-               Item "Normal-sized Icons" "icon-size 20"
-               Item "Big-sized Icons" "icon-size 26"
-               Item "Huge-sized Icons" "icon-size 32"
-               Item "Giant-sized Icons" "icon-size 48"
+               Item "Small-sized Icons" "icon-size small"
+               Item "Normal-sized Icons" "icon-size normal"
+               Item "Big-sized Icons" "icon-size big"
+               Item "Huge-sized Icons" "icon-size huge"
+               Item "Giant-sized Icons" "icon-size giant"
        End
 #
 # INSERT MENU
index cf113184f39df7fbf93cfc4a5ca1450211418837..9fe591785059c8f6e53150b2b442bc17f80a4423 100644 (file)
@@ -2749,7 +2749,9 @@ void LyXAction::init()
  * \var lyx::FuncCode lyx::LFUN_ICON_SIZE
  * \li Action: Sets icon size of toolbars.
  * \li Syntax: icon-size [<SIZE>]
- * \li Params: <SIZE> : the icon size in px, the default is 20 (normalIconSize).
+ * \li Params: <SIZE> : the icon size in px or one of the logical settings
+                        small|normal|big|huge|giant, the default is normal
+                        (whose size in px is icon set dependent).
  * \li Origin: 11 July 2016
  * \endvar
  */
index 432da37d533600d094af9aeab794c810d254787a..a6a96e269c2ffc0ef146f0d161cbdbea1b303899 100644 (file)
@@ -383,6 +383,60 @@ public:
                processing_thread_watcher_.setFuture(f);
        }
 
+       QSize iconSize(docstring const & icon_size)
+       {
+               int size;
+               if (icon_size == "small")
+                       size = smallIconSize;
+               else if (icon_size == "normal")
+                       size = normalIconSize;
+               else if (icon_size == "big")
+                       size = bigIconSize;
+               else if (icon_size == "huge")
+                       size = hugeIconSize;
+               else if (icon_size == "giant")
+                       size = giantIconSize;
+               else
+                       size = icon_size.empty() ? normalIconSize : convert<int>(icon_size);
+
+               if (size < smallIconSize)
+                       size = smallIconSize;
+
+               return QSize(size, size);
+       }
+
+       QSize iconSize(QString const & icon_size)
+       {
+               return iconSize(qstring_to_ucs4(icon_size));
+       }
+
+       string & iconSize(QSize const & qsize)
+       {
+               LATTEST(qsize.width() == qsize.height());
+
+               static string icon_size;
+
+               int size = qsize.width();
+
+               if (size < smallIconSize)
+                       size = smallIconSize;
+
+               if (size == smallIconSize)
+                       icon_size = "small";
+               else if (size == normalIconSize)
+                       icon_size = "normal";
+               else if (size == bigIconSize)
+                       icon_size = "big";
+               else if (size == hugeIconSize)
+                       icon_size = "huge";
+               else if (size == giantIconSize)
+                       icon_size = "giant";
+               else
+                       icon_size = convert<string>(size);
+
+               return icon_size;
+       }
+
 public:
        GuiView * gv_;
        GuiWorkArea * current_work_area_;
@@ -668,7 +722,7 @@ void GuiView::saveLayout() const
        settings.setValue("geometry", saveGeometry());
 #endif
        settings.setValue("layout", saveState(0));
-       settings.setValue("icon_size", iconSize());
+       settings.setValue("icon_size", toqstr(d.iconSize(iconSize())));
 }
 
 
@@ -695,9 +749,7 @@ bool GuiView::restoreLayout()
                return false;
 
        //code below is skipped when when ~/.config/LyX is (re)created
-       QSize icon_size = settings.value(icon_key).toSize();
-       // Check whether session size changed.
-       setIconSize(icon_size);
+       setIconSize(d.iconSize(settings.value(icon_key).toString()));
 
 #if defined(Q_WS_X11) || defined(QPA_XCB)
        QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
@@ -1828,11 +1880,9 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                break;
        }
 
-       case LFUN_ICON_SIZE: {
-               int const size = cmd.argument().empty() ? d.normalIconSize : convert<int>(cmd.argument());
-               flag.setOnOff(QSize(size, size) == iconSize());
+       case LFUN_ICON_SIZE:
+               flag.setOnOff(d.iconSize(cmd.argument()) == iconSize());
                break;
-       }
 
        case LFUN_DROP_LAYOUTS_CHOICE:
                enable = buf != 0;
@@ -3729,20 +3779,10 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                }
 
                case LFUN_ICON_SIZE: {
-                       int const size = cmd.argument().empty() ? d.normalIconSize : convert<int>(cmd.argument());
-                       setIconSize(QSize(size, size));
-                       if (size == d.smallIconSize)
-                               dr.setMessage("Icon size set to small");
-                       else if (size == d.normalIconSize)
-                               dr.setMessage("Icon size set to normal");
-                       else if (size == d.bigIconSize)
-                               dr.setMessage("Icon size set to big");
-                       else if (size == d.hugeIconSize)
-                               dr.setMessage("Icon size set to huge");
-                       else if (size == d.giantIconSize)
-                               dr.setMessage("Icon size set to giant");
-                       else
-                               dr.setMessage(bformat(_("Icon size set to %1$d"), size));
+                       QSize size = d.iconSize(cmd.argument());
+                       setIconSize(size);
+                       dr.setMessage(bformat(_("Icon size set to %1$dx%2$d."),
+                                               size.width(), size.height()));
                        break;
                }