]> git.lyx.org Git - lyx.git/commitdiff
add tool bar popup with three icon sizes: small, normal, big
authorPeter Kümmel <syntheticpp@gmx.net>
Wed, 29 Nov 2006 10:04:35 +0000 (10:04 +0000)
committerPeter Kümmel <syntheticpp@gmx.net>
Wed, 29 Nov 2006 10:04:35 +0000 (10:04 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16100 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.C
src/frontends/qt4/GuiView.h
src/lyx_main.C

index d98c52763708e263596d07834c70c93f29827b79..3f5b0535853bc02e254594f7aa9d8c1cffab9979 100644 (file)
@@ -107,17 +107,57 @@ struct GuiView::GuiViewPrivate
        GuiViewPrivate() : wt(0), posx_offset(0), posy_offset(0)
        {}
 
-       static int iconSizeXY_;
+       unsigned int smallIconSize;
+       unsigned int normalIconSize;
+       unsigned int bigIconSize;
+       // static needed by "New Window"
+       static unsigned int lastIconSize;
+
+       QMenu* toolBarPopup(GuiView *parent)
+       {
+               QMenu* menu = new QMenu(parent);
+               QActionGroup *iconSizeGroup = new QActionGroup(parent);
+
+               QAction *smallIcons = new QAction(iconSizeGroup);
+               smallIcons->setText("Small sized icons");
+               smallIcons->setCheckable(true);
+               QObject::connect(smallIcons, SIGNAL(triggered()), parent, SLOT(smallSizedIcons()));
+               menu->addAction(smallIcons);
+
+               QAction *normalIcons = new QAction(iconSizeGroup);
+               normalIcons->setText("Normal sized icons");
+               normalIcons->setCheckable(true);
+               QObject::connect(normalIcons, SIGNAL(triggered()), parent, SLOT(normalSizedIcons()));
+               menu->addAction(normalIcons);
+
+
+               QAction *bigIcons = new QAction(iconSizeGroup);
+               bigIcons->setText("Big sized icons");
+               bigIcons->setCheckable(true);
+               QObject::connect(bigIcons, SIGNAL(triggered()), parent, SLOT(bigSizedIcons()));
+               menu->addAction(bigIcons);
+
+               int cur = parent->iconSize().width();
+               if ( cur == parent->d.smallIconSize)
+                       smallIcons->setChecked(true);
+               else if (cur == parent->d.normalIconSize)
+                       normalIcons->setChecked(true);
+               else if (cur == parent->d.bigIconSize)
+                       bigIcons->setChecked(true);
+
+               return menu;
+       }
 };
 
-int GuiView::GuiViewPrivate::iconSizeXY_ = -1;
+unsigned int GuiView::GuiViewPrivate::lastIconSize = 0;
 
 GuiView::GuiView(int id)
        : QMainWindow(), LyXView(id), commandbuffer_(0), d(*new GuiViewPrivate)
 {
-       // static var needed by the "New Window", because setGeometry will not be called
-       if (GuiViewPrivate::iconSizeXY_ != -1)
-               setIconSize(QSize(GuiViewPrivate::iconSizeXY_, GuiViewPrivate::iconSizeXY_));
+       // hardcode here the platform specific icon size
+       d.smallIconSize = 14;   // scaling problems
+       d.normalIconSize = 20;  // ok, default
+       d.bigIconSize = 26;             // better for some math icons
 
        //bufferview_.reset(new BufferView(this, width, height));
 
@@ -144,8 +184,7 @@ void GuiView::close()
 
 QMenu* GuiView::createPopupMenu()
 {
-       // disable toolbar popup menu 
-       return 0;
+       return d.toolBarPopup(this);
 }
 
 void GuiView::init()
@@ -206,11 +245,13 @@ void GuiView::setGeometry(unsigned int width,
                                                                  bool maximize,
                                                                  unsigned int iconSizeXY)
 {
-       if (iconSizeXY > 8)
-               GuiViewPrivate::iconSizeXY_ = iconSizeXY;
+       // use last value (not at startup)
+       if (d.lastIconSize != 0)
+               setIconSize(d.lastIconSize);
+       else if (iconSizeXY != 0)
+               setIconSize(iconSizeXY);
        else
-               GuiViewPrivate::iconSizeXY_ = 28;
-       setIconSize(QSize(GuiViewPrivate::iconSizeXY_, GuiViewPrivate::iconSizeXY_));
+               setIconSize(d.normalIconSize);
 
        // only true when the -geometry option was NOT used
        if (width != 0 && height != 0) {
@@ -300,6 +341,27 @@ void GuiView::clearMessage()
        update_view_state_qt();
 }
 
+void GuiView::setIconSize(unsigned int size)
+{
+       d.lastIconSize = size;
+       QMainWindow::setIconSize(QSize(size, size));
+}
+
+void GuiView::smallSizedIcons()
+{
+       setIconSize(d.smallIconSize);
+}
+
+void GuiView::normalSizedIcons()
+{
+       setIconSize(d.normalIconSize);
+}
+
+void GuiView::bigSizedIcons()
+{
+       setIconSize(d.bigIconSize);
+}
+
 
 void GuiView::focus_command_widget()
 {
index 43d3e859ff10bdff699a0730bc1b25fd37bc5a59..40adbb420cb8c5743fad77af55d725cf870fea64 100644 (file)
@@ -7,6 +7,7 @@
  * \author Lars Gullik Bjornes
  * \author John Levon
  * \author Abdelrazak Younes
+ * \author Peter Kümmel
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -96,6 +97,11 @@ public Q_SLOTS:
 
        void currentTabChanged (int index); 
 
+       /// slots to change the icon size
+       void smallSizedIcons();
+       void normalSizedIcons();
+       void bigSizedIcons();
+
 protected:
        /// make sure we quit cleanly
        virtual void closeEvent(QCloseEvent * e);
@@ -127,6 +133,8 @@ private:
        ///
        QRect floatingGeometry_;
 
+       void setIconSize(unsigned int size);
+
        struct GuiViewPrivate;
        GuiViewPrivate& d;
 };
index 2a4955abf73e2ae3412fd6cd872e857a8c01c5d0..7d97fac6a15cb5e096b3093eefdc6f365954d048 100644 (file)
@@ -569,7 +569,7 @@ LyXView * LyX::newLyXView()
        unsigned int width = 690;
        unsigned int height = 510;
        // default icon size, will be overwritten by  stored session value
-       unsigned int iconSizeXY = 26;
+       unsigned int iconSizeXY = 0;
        bool maximize = false;
        // first try lyxrc
        if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {