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
This commit is contained in:
Pavel Sanda 2009-10-05 23:06:29 +00:00
parent 8661b320ce
commit 3f170ec08c
6 changed files with 41 additions and 8 deletions

View 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;

View 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;
};

View 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);
}

View 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
}

View File

@ -336,10 +336,8 @@ private Q_SLOTS:
private:
///
int clicked_tab_;
#if QT_VERSION < 0x040500
///
QToolButton * closeBufferButton;
#endif
}; // TabWorkArea

View File

@ -185,6 +185,16 @@
</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>