]> git.lyx.org Git - features.git/commitdiff
Fix bug #5977 - Make Close button on tabs configurable
authorPavel Sanda <sanda@lyx.org>
Mon, 5 Oct 2009 23:06:29 +0000 (23:06 +0000)
committerPavel Sanda <sanda@lyx.org>
Mon, 5 Oct 2009 23:06:29 +0000 (23:06 +0000)
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg154950.html

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

src/LyXRC.cpp
src/LyXRC.h
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea.h
src/frontends/qt4/ui/PrefUi.ui

index 1d8ad46008acec35c7c8e9708727f3c65c3a9ccc..97259a7cde6c99da9db5dcac57836112fd1e43f2 100644 (file)
@@ -170,6 +170,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\serverpipe", LyXRC::RC_SERVERPIPE },
        { "\\set_color", LyXRC::RC_SET_COLOR },
        { "\\show_banner", LyXRC::RC_SHOW_BANNER },
+       { "\\single_close_tab_button", LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON },
        { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
        { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
        { "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
@@ -316,6 +317,7 @@ void LyXRC::setDefaults()
        user_name = to_utf8(support::user_name());
        user_email = to_utf8(support::user_email());
        open_buffers_in_tabs = true;
+       single_close_tab_button = false;
 
        // Fullscreen settings
        full_screen_limit = false;
@@ -1141,6 +1143,9 @@ int LyXRC::read(Lexer & lexrc)
                case RC_OPEN_BUFFERS_IN_TABS:
                        lexrc >> open_buffers_in_tabs;
                        break;
+               case RC_SINGLE_CLOSE_TAB_BUTTON:
+                       lexrc >> single_close_tab_button;
+                       break;
 
                // Obsoteted in 1.4.0
                case RC_USETEMPDIR:
@@ -1833,6 +1838,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                           << convert<string>(open_buffers_in_tabs)
                           << '\n';
                }
+       case RC_SINGLE_CLOSE_TAB_BUTTON:
+               if (ignore_system_lyxrc ||
+                   single_close_tab_button != system_lyxrc.single_close_tab_button) {
+                       os << "\\single_close_tab_button "
+                          << convert<string>(single_close_tab_button)
+                          << '\n';
+               }
                if (tag != RC_LAST)
                        break;
 
index 337fb71ada7fe629f704ef184bfe09b14b5dd22c..cc57cffb97c5212a45983d79dd51db5b4c478904 100644 (file)
@@ -113,6 +113,7 @@ public:
                RC_NOMENCL_COMMAND,
                RC_NUMLASTFILES,
                RC_OPEN_BUFFERS_IN_TABS,
+               RC_SINGLE_CLOSE_TAB_BUTTON,
                RC_PARAGRAPH_MARKERS,
                RC_PATH_PREFIX,
                RC_PERS_DICT,
@@ -478,6 +479,8 @@ public:
        bool completion_popup_after_complete;
        ///
        bool open_buffers_in_tabs;
+       ///
+       bool single_close_tab_button;
 };
 
 
index 5b78e768741c3c44505dc5449d71f18fba3e1fbb..4f96241485969e7855c64824504125df148c359c 100644 (file)
@@ -2154,6 +2154,11 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form)
                TextLabel1, SLOT(setEnabled(bool)));
        connect(openDocumentsInTabsCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
+#if QT_VERSION < 0x040500
+       openDocumentsInTabsCB.setEnabled(false);
+#endif
+       connect(singleCloseTabButtonCB, SIGNAL(clicked()),
+               this, SIGNAL(changed()));
        connect(uiFilePB, SIGNAL(clicked()),
                this, SLOT(selectUi()));
        connect(uiFileED, SIGNAL(textChanged(QString)),
@@ -2189,6 +2194,10 @@ void PrefUserInterface::apply(LyXRC & rc) const
        rc.num_lastfiles = lastfilesSB->value();
        rc.use_tooltip = tooltipCB->isChecked();
        rc.open_buffers_in_tabs = openDocumentsInTabsCB->isChecked();
+       rc.single_close_tab_button = singleCloseTabButtonCB->isChecked();
+#if QT_VERSION < 0x040500
+       rc.single_close_tab_button = true;
+#endif
 }
 
 
@@ -2210,6 +2219,7 @@ void PrefUserInterface::update(LyXRC const & rc)
        lastfilesSB->setValue(rc.num_lastfiles);
        tooltipCB->setChecked(rc.use_tooltip);
        openDocumentsInTabsCB->setChecked(rc.open_buffers_in_tabs);
+       singleCloseTabButtonCB->setChecked(rc.single_close_tab_button);
 }
 
 
index 2efc36bcd7de9f6bb8466581ba073d1a266953c7..eacbc142a7f2edbfd35c4f0e1ffcead5373f8955 100644 (file)
@@ -1319,6 +1319,9 @@ TabWorkArea::TabWorkArea(QWidget * parent)
 #ifdef Q_WS_MACX
        setStyle(&noTabFrameMacStyle);
 #endif
+#if QT_VERSION < 0x040500
+       lyxrc.single_close_tab_button = true;
+#endif
 
        QPalette pal = palette();
        pal.setColor(QPalette::Active, QPalette::Button,
@@ -1331,7 +1334,6 @@ TabWorkArea::TabWorkArea(QWidget * parent)
        QObject::connect(this, SIGNAL(currentChanged(int)),
                this, SLOT(on_currentTabChanged(int)));
 
-#if QT_VERSION < 0x040500
        closeBufferButton = new QToolButton(this);
        closeBufferButton->setPalette(pal);
        // FIXME: rename the icon to closebuffer.png
@@ -1344,7 +1346,6 @@ TabWorkArea::TabWorkArea(QWidget * parent)
        QObject::connect(closeBufferButton, SIGNAL(clicked()),
                this, SLOT(closeCurrentBuffer()));
        setCornerWidget(closeBufferButton, Qt::TopRightCorner);
-#endif
 
        // setup drag'n'drop
        QTabBar* tb = new DragTabBar;
@@ -1382,9 +1383,8 @@ void TabWorkArea::showBar(bool show)
 {
        tabBar()->setEnabled(show);
        tabBar()->setVisible(show);
-#if QT_VERSION < 0x040500
-       closeBufferButton->setVisible(show);    
-#endif
+       closeBufferButton->setVisible(show && lyxrc.single_close_tab_button);
+       setTabsClosable(!lyxrc.single_close_tab_button);
 }
 
 
@@ -1773,7 +1773,7 @@ DragTabBar::DragTabBar(QWidget* parent)
 {
        setAcceptDrops(true);
 #if QT_VERSION >= 0x040500
-       setTabsClosable(true);
+       setTabsClosable(!lyxrc.single_close_tab_button);
 #endif
 }
 
index 9d6bfe78f1574a7f73356d24e5f866b8e8df47c1..5f5eec9bc13792ed485b3eb55076b4b880d99f3c 100644 (file)
@@ -336,10 +336,8 @@ private Q_SLOTS:
 private:
        ///
        int clicked_tab_;
-#if QT_VERSION < 0x040500
        ///
        QToolButton * closeBufferButton;
-#endif
 }; // TabWorkArea
 
 
index 8ac971a546abc4fdaf2b3d9edcfc93d52cb0dcf1..08818760c3092419214fa250541b1a1788acfd6a 100644 (file)
         </property>
        </widget>
       </item>
+      <item row="5" column="0" >
+       <widget class="QCheckBox" name="singleCloseTabButtonCB" >
+        <property name="toolTip" >
+         <string>Whether to place close button on each tab or only one in the top left.</string>
+        </property>
+        <property name="text" >
+         <string>&amp;Single close-tab button</string>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>