]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
Mention style-dependency of of features in the tooltips, part 2
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index 432da37d533600d094af9aeab794c810d254787a..a6b5877be1e67a9f8a114c65d378ef828136e273 100644 (file)
@@ -227,7 +227,7 @@ private:
        /// Current ratio between physical pixels and device-independent pixels
        double pixelRatio() const {
 #if QT_VERSION >= 0x050000
-               return devicePixelRatio();
+               return qt_scale_factor * devicePixelRatio();
 #else
                return 1.0;
 #endif
@@ -383,6 +383,60 @@ public:
                processing_thread_watcher_.setFuture(f);
        }
 
+       QSize iconSize(docstring const & icon_size)
+       {
+               unsigned 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;
+
+               unsigned 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();
@@ -1289,7 +1341,7 @@ void GuiView::resetCommandExecute()
 double GuiView::pixelRatio() const
 {
 #if QT_VERSION >= 0x050000
-       return devicePixelRatio();
+       return qt_scale_factor * devicePixelRatio();
 #else
        return 1.0;
 #endif
@@ -1600,6 +1652,10 @@ void GuiView::updateTocItem(string const & type, DocIterator const & dit)
 
 void GuiView::structureChanged()
 {
+       // This is called from the Buffer, which has no way to ensure that cursors
+       // in BufferView remain valid.
+       if (documentBufferView())
+               documentBufferView()->cursor().sanitize();
        // FIXME: This is slightly expensive, though less than the tocBackend update
        // (#9880). This also resets the view in the Toc Widget (#6675).
        d.toc_models_.reset(documentBufferView());
@@ -1828,11 +1884,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;
@@ -3315,7 +3369,7 @@ bool GuiView::goToFileRow(string const & argument)
 }
 
 
-void GuiView::toolBarPopup(const QPoint & pos)
+void GuiView::toolBarPopup(const QPoint & /*pos*/)
 {
        QMenu * menu = new QMenu;
        menu = guiApp->menus().menu(toqstr("context-toolbars"), * this);
@@ -3729,20 +3783,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;
                }