]> git.lyx.org Git - features.git/commitdiff
* copy icon size to new GuiView from the last GuiView
authorStefan Schimanski <sts@lyx.org>
Fri, 14 Mar 2008 16:39:34 +0000 (16:39 +0000)
committerStefan Schimanski <sts@lyx.org>
Fri, 14 Mar 2008 16:39:34 +0000 (16:39 +0000)
* use small Mac combobox widget for small icon size. Otherwise the combobox is bigger than the icons.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23720 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiToolbar.cpp
src/frontends/qt4/GuiToolbar.h

index e76f726904ef7f06cc8cde122bac6a2043947227..0289eb61a28a8d7f07840c4603d9aafb7fcd3a1a 100644 (file)
@@ -315,16 +315,25 @@ static void updateIds(map<int, GuiView *> const & stdmap, vector<int> & ids)
 
 void GuiApplication::createView(QString const & geometry_arg)
 {
+       if (global_menubar_)
+               global_menubar_->releaseKeyboard();
+
+       // create new view
        updateIds(views_, view_ids_);
        int id = 0;
        while (views_.find(id) != views_.end())
                id++;
-       views_[id] = new GuiView(id);
-       updateIds(views_, view_ids_);
+       GuiView * view = new GuiView(id);
+       
+       // copy the icon size from old view
+       if (viewCount() > 0)
+               view->setIconSize(current_view_->iconSize());
 
-       GuiView * view  = views_[id];
+       // register view
+       views_[id] = view;
+       updateIds(views_, view_ids_);
+       
        theLyXFunc().setLyXView(view);
-
        view->show();
        if (!geometry_arg.isEmpty()) {
 #ifdef Q_WS_WIN
index 577d1094333a004442f04a1b8f11c10d20fd0e7f..24d1e77cdc71d41779be7776a2f036e045ec7837 100644 (file)
@@ -464,8 +464,9 @@ public:
 };
 
 
-GuiLayoutBox::GuiLayoutBox(GuiView & owner)
-       : owner_(owner), lastSel_(-1), layoutItemDelegate_(new LayoutItemDelegate(this)),
+GuiLayoutBox::GuiLayoutBox(GuiToolbar * bar, GuiView & owner)
+       : owner_(owner), bar_(bar), lastSel_(-1),
+         layoutItemDelegate_(new LayoutItemDelegate(this)),
          visibleCategories_(0), inShowPopup_(false)
 {
        setSizeAdjustPolicy(QComboBox::AdjustToContents);
@@ -486,7 +487,10 @@ GuiLayoutBox::GuiLayoutBox(GuiView & owner)
        view()->setItemDelegateForColumn(0, layoutItemDelegate_);
        
        QObject::connect(this, SIGNAL(activated(int)),
-                        this, SLOT(selected(int)));
+               this, SLOT(selected(int)));
+       QObject::connect(bar_, SIGNAL(iconSizeChanged(QSize)),
+               this, SLOT(setIconSize(QSize)));
+
        owner_.setLayoutDialog(this);
        updateContents(true);
 }
@@ -652,6 +656,14 @@ bool GuiLayoutBox::eventFilter(QObject * o, QEvent * e)
        return QComboBox::eventFilter(o, e);
 }
 
+       
+void GuiLayoutBox::setIconSize(QSize size)
+{
+       bool small = size.height() < 20;
+       setAttribute(Qt::WA_MacSmallSize, small);
+       setAttribute(Qt::WA_MacNormalSize, !small);
+}
+
 
 void GuiLayoutBox::set(docstring const & layout)
 {
@@ -962,7 +974,7 @@ void GuiToolbar::add(ToolbarItem const & item)
                addSeparator();
                break;
        case ToolbarItem::LAYOUTS:
-               layout_ = new GuiLayoutBox(owner_);
+               layout_ = new GuiLayoutBox(this, owner_);
                addWidget(layout_);
                break;
        case ToolbarItem::MINIBUFFER:
index f616410658cc3c4358375fad71becdf14533840f..57650ac8eff18664b23ac36badc77dc40350e60f 100644 (file)
@@ -44,7 +44,7 @@ class GuiLayoutBox : public QComboBox
 {
        Q_OBJECT
 public:
-       GuiLayoutBox(GuiView &);
+       GuiLayoutBox(GuiToolbar * bar, GuiView &);
 
        /// select the right layout in the combobox.
        void set(docstring const & layout);
@@ -65,6 +65,8 @@ public:
 private Q_SLOTS:
        ///
        void selected(int index);
+       ///
+       void setIconSize(QSize size);
 
 private:
        friend class LayoutItemDelegate;
@@ -81,6 +83,8 @@ private:
        ///
        GuiView & owner_;
        ///
+       GuiToolbar * bar_;
+       ///
        DocumentClass const * text_class_;
        ///
        Inset const * inset_;
@@ -119,17 +123,22 @@ public:
        ///
        GuiCommandBuffer * commandBuffer() { return command_buffer_; }
 
+       ///
        Action * addItem(ToolbarItem const & item);
 
 Q_SIGNALS:
+       ///
        void updated();
 
 private:
-
+       ///
        QList<Action *> actions_;
+       ///
        GuiView & owner_;
 
+       ///
        GuiLayoutBox * layout_;
+       ///
        GuiCommandBuffer * command_buffer_;
 };