1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

TabManager: show add tab button on window item under mouse.

This commit is contained in:
srazi 2017-04-07 01:20:10 +04:30
parent 457d32ae82
commit 47e2c8c1f0
4 changed files with 9 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

View File

@ -64,12 +64,13 @@ void TabManagerDelegate::paint(QPainter* painter, const QStyleOptionViewItem &op
// draw close button
if (index.column() == 1) {
if (index.parent().isValid() && opt.state & QStyle::State_MouseOver) {
if (opt.state & QStyle::State_MouseOver) {
static const int buttonSize = 16;
static const QPixmap closeTabButton(":tabmanager/data/closetab.png");
static const QPixmap addTabButton(":tabmanager/data/addtab.png");
const QRect rect(opt.rect.right() - buttonSize, (opt.rect.height() - buttonSize) / 2 + opt.rect.y(), buttonSize, buttonSize);
painter->drawPixmap(style->visualRect(direction, opt.rect, rect), closeTabButton);
painter->drawPixmap(style->visualRect(direction, opt.rect, rect), (index.parent().isValid() ? closeTabButton : addTabButton));
}
painter->restore();

View File

@ -8,6 +8,7 @@
<file>data/tab-pinned.png</file>
<file>data/side-by-side.png</file>
<file>data/closetab.png</file>
<file>data/addtab.png</file>
<file>locale/ar_SA.qm</file>
<file>locale/bg_BG.qm</file>
<file>locale/ca_ES.qm</file>

View File

@ -222,8 +222,11 @@ void TabManagerWidget::onItemActivated(QTreeWidgetItem* item, int column)
return;
}
if (column == 1 && item->childCount() == 0 && tabWidget) {
mainWindow->tabWidget()->requestCloseTab(mainWindow->tabWidget()->indexOf(tabWidget));
if (column == 1) {
if (item->childCount() == 0 && tabWidget)
mainWindow->tabWidget()->requestCloseTab(mainWindow->tabWidget()->indexOf(tabWidget));
else if (item->childCount() > 0)
QMetaObject::invokeMethod(mainWindow, "addTab");
return;
}