add tab close button

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18739 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Peter Kümmel 2007-06-11 14:53:36 +00:00
parent f5300ad830
commit 69a81aecfa
3 changed files with 143 additions and 9 deletions

90
lib/images/closetab.xpm Normal file
View File

@ -0,0 +1,90 @@
/* XPM */
static char * closetab_xpm[] = {
"16 16 71 1",
" c None",
". c #272727",
"+ c #2C2C2C",
"@ c #393939",
"# c #3E3F3F",
"$ c #3F3F3F",
"% c #2C2C2C",
"& c #2D2D2D",
"* c #404040",
"= c #414141",
"- c #2B2B2B",
"; c #333333",
"> c #3E3E3E",
", c #444544",
"' c #454545",
") c #2D2D2D",
"! c #3A3A3A",
"~ c #414141",
"{ c #484748",
"] c #484848",
"^ c #323232",
"/ c #373737",
"( c #474747",
"_ c #484848",
": c #2F2F2F",
"< c #3F3F3F",
"[ c #424242",
"} c #484949",
"| c #494949",
"1 c #363636",
"2 c #494949",
"3 c #FFFFFF",
"4 c #4A4A4A",
"5 c #4F4F4F",
"6 c #505050",
"7 c #525252",
"8 c #3C3C3C",
"9 c #404040",
"0 c #4D4D4D",
"a c #4E4E4E",
"b c #414141",
"c c #424242",
"d c #5A5A5A",
"e c #5D5D5D",
"f c #E0E0E0",
"g c #E2E2E2",
"h c #E3E3E3",
"i c #E5E5E5",
"j c #E7E7E7",
"k c #3E3E3E",
"l c #5B5B5B",
"m c #4B4B4B",
"n c #373737",
"o c #434343",
"p c #5E5E5E",
"q c #626262",
"r c #444444",
"s c #6A6A6A",
"t c #6B6B6B",
"u c #737373",
"v c #878787",
"w c #999999",
"x c #9B9B9B",
"y c #9C9C9C",
"z c #DEDEDE",
"A c #454545",
"B c #474747",
"C c #494949",
"D c #545454",
"E c #555555",
"F c #414140",
" ",
" -)::)- ",
" ^n8kk8n^ ",
" 19Ca77aC91 ",
" /r5ytqqty5r/ ",
" ;b5x3iuui3x5b; ",
" !4Eef3jj3feE4! ",
" <5d7mg33gm7d5< ",
" [7eplg33glpe7[ ",
" ~6dsh3ff3hsd6~ ",
" >0Dw3z88z3wD0> ",
" (acvobFovca( ",
" 2B9A66A9B2 ",
" _406604_ ",
" ']}|{, ",
" "};

View File

@ -53,6 +53,9 @@
#include <QTabBar>
#include <QDesktopWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QToolButton>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
@ -75,23 +78,55 @@ int const statusbar_timer_value = 3000;
class TabWidget : public QWidget
{
QHBoxLayout* hlayout;
public:
QTabBar* tabbar;
QToolButton* closeTabButton;
void hideTabsIfNecessary()
{
if (tabbar->count() > 1) {
tabbar->show();
closeTabButton->show();
} else {
tabbar->hide();
closeTabButton->hide();
}
}
TabWidget(QWidget* w, bool topTabBar)
{
closeTabButton = new QToolButton(this);
FileName const file = support::libFileSearch("images", "closetab", "xpm");
if (!file.empty()) {
QPixmap pm(toqstr(file.absFilename()));
closeTabButton->setIcon(QIcon(pm));
} else {
closeTabButton->setText("Close");
}
closeTabButton->setCursor(Qt::ArrowCursor);
closeTabButton->setAutoRaise(true);
closeTabButton->setToolTip(tr("Close tab"));
closeTabButton->setEnabled(true);
tabbar = new QTabBar;
QVBoxLayout* layout = new QVBoxLayout;
hlayout = new QHBoxLayout;
QVBoxLayout* vlayout = new QVBoxLayout;
hlayout->addWidget(tabbar);
hlayout->addStretch(1);
hlayout->addWidget(closeTabButton);
if (topTabBar) {
layout->addWidget(tabbar);
layout->addWidget(w);
vlayout->addLayout(hlayout);
vlayout->addWidget(w);
} else {
tabbar->setShape(QTabBar::RoundedSouth);
layout->addWidget(w);
layout->addWidget(tabbar);
vlayout->addWidget(w);
vlayout->addLayout(hlayout);
}
layout->setMargin(0);
setLayout(layout);
vlayout->setMargin(0);
hlayout->setMargin(0);
setLayout(vlayout);
hideTabsIfNecessary();
}
void clearTabbar()
@ -141,7 +176,6 @@ struct GuiView::GuiViewPrivate
QObject::connect(normalIcons, SIGNAL(triggered()), parent, SLOT(normalSizedIcons()));
menu->addAction(normalIcons);
QAction *bigIcons = new QAction(iconSizeGroup);
bigIcons->setText(qt_("Big-sized icons"));
bigIcons->setCheckable(true);
@ -534,6 +568,8 @@ void GuiView::initTab(QWidget* workarea)
setCentralWidget(d.tabWidget);
QObject::connect(d.tabWidget->tabbar, SIGNAL(currentChanged(int)),
this, SLOT(currentTabChanged(int)));
QObject::connect(d.tabWidget->closeTabButton, SIGNAL(clicked()),
this, SLOT(closeCurrentTab()));
}
@ -571,6 +607,13 @@ void GuiView::updateTab()
}
}
tabbar.blockSignals(false);
d.tabWidget->hideTabsIfNecessary();
}
void GuiView::closeCurrentTab()
{
dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
}

View File

@ -98,7 +98,8 @@ public Q_SLOTS:
/// populate a toplevel menu and all its children on demand
void updateMenu(QAction *);
void currentTabChanged (int index);
void currentTabChanged(int index);
void closeCurrentTab();
/// slots to change the icon size
void smallSizedIcons();