mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
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:
parent
f5300ad830
commit
69a81aecfa
90
lib/images/closetab.xpm
Normal file
90
lib/images/closetab.xpm
Normal 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_ ",
|
||||||
|
" ']}|{, ",
|
||||||
|
" "};
|
@ -53,6 +53,9 @@
|
|||||||
#include <QTabBar>
|
#include <QTabBar>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
@ -75,23 +78,55 @@ int const statusbar_timer_value = 3000;
|
|||||||
|
|
||||||
class TabWidget : public QWidget
|
class TabWidget : public QWidget
|
||||||
{
|
{
|
||||||
|
QHBoxLayout* hlayout;
|
||||||
public:
|
public:
|
||||||
QTabBar* tabbar;
|
QTabBar* tabbar;
|
||||||
|
QToolButton* closeTabButton;
|
||||||
|
|
||||||
|
void hideTabsIfNecessary()
|
||||||
|
{
|
||||||
|
if (tabbar->count() > 1) {
|
||||||
|
tabbar->show();
|
||||||
|
closeTabButton->show();
|
||||||
|
} else {
|
||||||
|
tabbar->hide();
|
||||||
|
closeTabButton->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TabWidget(QWidget* w, bool topTabBar)
|
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;
|
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) {
|
if (topTabBar) {
|
||||||
layout->addWidget(tabbar);
|
vlayout->addLayout(hlayout);
|
||||||
layout->addWidget(w);
|
vlayout->addWidget(w);
|
||||||
} else {
|
} else {
|
||||||
tabbar->setShape(QTabBar::RoundedSouth);
|
tabbar->setShape(QTabBar::RoundedSouth);
|
||||||
layout->addWidget(w);
|
vlayout->addWidget(w);
|
||||||
layout->addWidget(tabbar);
|
vlayout->addLayout(hlayout);
|
||||||
}
|
}
|
||||||
layout->setMargin(0);
|
vlayout->setMargin(0);
|
||||||
setLayout(layout);
|
hlayout->setMargin(0);
|
||||||
|
setLayout(vlayout);
|
||||||
|
hideTabsIfNecessary();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearTabbar()
|
void clearTabbar()
|
||||||
@ -141,7 +176,6 @@ struct GuiView::GuiViewPrivate
|
|||||||
QObject::connect(normalIcons, SIGNAL(triggered()), parent, SLOT(normalSizedIcons()));
|
QObject::connect(normalIcons, SIGNAL(triggered()), parent, SLOT(normalSizedIcons()));
|
||||||
menu->addAction(normalIcons);
|
menu->addAction(normalIcons);
|
||||||
|
|
||||||
|
|
||||||
QAction *bigIcons = new QAction(iconSizeGroup);
|
QAction *bigIcons = new QAction(iconSizeGroup);
|
||||||
bigIcons->setText(qt_("Big-sized icons"));
|
bigIcons->setText(qt_("Big-sized icons"));
|
||||||
bigIcons->setCheckable(true);
|
bigIcons->setCheckable(true);
|
||||||
@ -534,6 +568,8 @@ void GuiView::initTab(QWidget* workarea)
|
|||||||
setCentralWidget(d.tabWidget);
|
setCentralWidget(d.tabWidget);
|
||||||
QObject::connect(d.tabWidget->tabbar, SIGNAL(currentChanged(int)),
|
QObject::connect(d.tabWidget->tabbar, SIGNAL(currentChanged(int)),
|
||||||
this, SLOT(currentTabChanged(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);
|
tabbar.blockSignals(false);
|
||||||
|
d.tabWidget->hideTabsIfNecessary();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiView::closeCurrentTab()
|
||||||
|
{
|
||||||
|
dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,7 +98,8 @@ public Q_SLOTS:
|
|||||||
/// populate a toplevel menu and all its children on demand
|
/// populate a toplevel menu and all its children on demand
|
||||||
void updateMenu(QAction *);
|
void updateMenu(QAction *);
|
||||||
|
|
||||||
void currentTabChanged (int index);
|
void currentTabChanged(int index);
|
||||||
|
void closeCurrentTab();
|
||||||
|
|
||||||
/// slots to change the icon size
|
/// slots to change the icon size
|
||||||
void smallSizedIcons();
|
void smallSizedIcons();
|
||||||
|
Loading…
Reference in New Issue
Block a user