From 3f170ec08c934fbe8a5f7f56d7216c44578b007b Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Mon, 5 Oct 2009 23:06:29 +0000 Subject: [PATCH] Fix bug #5977 - Make Close button on tabs configurable 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 | 12 ++++++++++++ src/LyXRC.h | 3 +++ src/frontends/qt4/GuiPrefs.cpp | 10 ++++++++++ src/frontends/qt4/GuiWorkArea.cpp | 12 ++++++------ src/frontends/qt4/GuiWorkArea.h | 2 -- src/frontends/qt4/ui/PrefUi.ui | 10 ++++++++++ 6 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 1d8ad46008..97259a7cde 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -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(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(single_close_tab_button) + << '\n'; + } if (tag != RC_LAST) break; diff --git a/src/LyXRC.h b/src/LyXRC.h index 337fb71ada..cc57cffb97 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -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; }; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 5b78e76874..4f96241485 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -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); } diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 2efc36bcd7..eacbc142a7 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -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 } diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index 9d6bfe78f1..5f5eec9bc1 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -336,10 +336,8 @@ private Q_SLOTS: private: /// int clicked_tab_; -#if QT_VERSION < 0x040500 /// QToolButton * closeBufferButton; -#endif }; // TabWorkArea diff --git a/src/frontends/qt4/ui/PrefUi.ui b/src/frontends/qt4/ui/PrefUi.ui index 8ac971a546..08818760c3 100644 --- a/src/frontends/qt4/ui/PrefUi.ui +++ b/src/frontends/qt4/ui/PrefUi.ui @@ -185,6 +185,16 @@ + + + + Whether to place close button on each tab or only one in the top left. + + + &Single close-tab button + + +