void TabBarPrivate::layoutButtons() { int bw = tabbar->height(); int w = tabbar->width(); offset = bw * 4; if (tabbar->isLeftToRight()) { scrollFirstButton->setGeometry(0, 0, bw, bw); scrollFirstButton->setIcon(QIcon(QPixmap(arrow_leftmost_xpm))); scrollBackButton->setGeometry(bw, 0, bw, bw); scrollBackButton->setIcon(QIcon(QPixmap(arrow_left_xpm))); scrollForwardButton->setGeometry(bw*2, 0, bw, bw); scrollForwardButton->setIcon(QIcon(QPixmap(arrow_right_xpm))); scrollLastButton->setGeometry(bw*3, 0, bw, bw); scrollLastButton->setIcon(QIcon(QPixmap(arrow_rightmost_xpm))); } else { scrollFirstButton->setGeometry(w - bw, 0, bw, bw); scrollFirstButton->setIcon(QIcon(QPixmap(arrow_rightmost_xpm))); scrollBackButton->setGeometry(w - 2*bw, 0, bw, bw); scrollBackButton->setIcon(QIcon(QPixmap(arrow_right_xpm))); scrollForwardButton->setGeometry(w - 3*bw, 0, bw, bw); scrollForwardButton->setIcon(QIcon(QPixmap(arrow_left_xpm))); scrollLastButton->setGeometry(w - 4*bw, 0, bw, bw); scrollLastButton->setIcon(QIcon(QPixmap(arrow_leftmost_xpm))); } }
void TabBarPrivate::updateButtons() { scrollFirstButton->setEnabled(tabbar->canScrollBack()); scrollBackButton->setEnabled(tabbar->canScrollBack()); scrollForwardButton->setEnabled(tabbar->canScrollForward()); scrollLastButton->setEnabled(tabbar->canScrollForward()); }
// -- WIN32IDE --- TabBar* WIN32IDE :: createOutputBar() { TabBar* tabBar = new TabBar(_appWindow, Settings::tabWithAboveScore); _output = new Output(tabBar, _appWindow); _messageList = new MessageLog(tabBar); tabBar->addTabChild(OUTPUT_TAB, _output); tabBar->addTabChild(MESSAGES_TAB, _messageList); tabBar->_setHeight(120); Splitter* bottomSplitter = new Splitter(_appWindow, tabBar, false, IDM_LAYOUT_CHANGED); bottomSplitter->_setConstraint(60, 100); _appWindow->_getLayoutManager()->setAsBottom(bottomSplitter); controls.add(tabBar); controls.add(_output); controls.add(_messageList); controls.add(bottomSplitter); return tabBar; }
void MainWindow :: openCallList() { TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]); tabBar->addTabChild(CALLSTACK_TAB, (Control*)_controls[CTRL_CALLLIST]); tabBar->show(); tabBar->selectTabChild((Control*)_controls[CTRL_CALLLIST]); }
void MainWindow :: openMessageList() { TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]); tabBar->addTabChild(MESSAGES_TAB, (Control*)_controls[CTRL_MESSAGELIST]); tabBar->show(); tabBar->selectTabChild((Control*)_controls[CTRL_MESSAGELIST]); }
void MainWindow :: openOutput() { TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]); tabBar->addTabChild(OUTPUT_TAB, (Control*)_controls[CTRL_OUTPUT]); tabBar->selectTabChild((Control*)_controls[CTRL_OUTPUT]); tabBar->show(); }
void MainWindow :: closeOutput() { TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]); tabBar->removeTabChild((Control*)_controls[CTRL_OUTPUT]); if (tabBar->getTabCount() == 0) { tabBar->hide(); } }
void MainWindow::closeCallList() { TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]); tabBar->removeTabChild((Control*)_controls[CTRL_CALLLIST]); if (tabBar->getTabCount() == 0) { tabBar->hide(); } }
void MainWindow :: closeDebugWatch() { TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]); tabBar->removeTabChild((Control*)_controls[CTRL_CONTEXTBOWSER]); if (tabBar->getTabCount() == 0) { tabBar->hide(); } else tabBar->selectLastTabChild(); hideControl(CTRL_CONTEXTBOWSER); refresh(); }
void MainWindow :: openDebugWatch() { if (!isControlVisible(CTRL_CONTEXTBOWSER)) { TabBar* tabBar = ((TabBar*)_controls[CTRL_TABBAR]); tabBar->addTabChild(WATCH_TAB, (Control*)_controls[CTRL_CONTEXTBOWSER]); tabBar->selectTabChild((Control*)_controls[CTRL_CONTEXTBOWSER]); tabBar->show(); showControls(CTRL_CONTEXTBOWSER, CTRL_CONTEXTBOWSER); } refreshControl(CTRL_CONTEXTBOWSER); refresh(); }
void TabBarPrivate::layoutTabs() { tabRects.clear(); QFont f = font(true); QFontMetrics fm(f, tabbar); if (tabbar->isLeftToRight()) { // left to right int x = 0; for (int c = 0; c < tabs.count(); c++) { QRect rect; if (c >= firstTab - 1) { QString text = tabs[ c ]; int tw = fm.width(text) + 4; rect = QRect(x, 0, tw + 20, tabbar->height()); x = x + tw + 20; } tabRects.append(rect); } lastTab = tabRects.count(); for (int i = 0; i < tabRects.count(); i++) if (tabRects[i].right() - 10 + offset > tabbar->width()) { lastTab = i; break; } } else { // right to left int x = tabbar->width() - offset; for (int c = 0; c < tabs.count(); c++) { QRect rect; if (c >= firstTab - 1) { QString text = tabs[ c ]; int tw = fm.width(text) + 4; rect = QRect(x - tw - 20, 0, tw + 20, tabbar->height()); x = x - tw - 20; } tabRects.append(rect); } lastTab = tabRects.count(); for (int i = tabRects.count() - 1; i > 0; i--) if (tabRects[i].left() > 0) { lastTab = i + 1; break; } } }
QSize TabBar::tabSizeHint(int index) const { if (!isVisible()) { return QSize(-1, -1); } const int maxWidth = 250; const int minWidth = 100; const int minHeight = 27; TabBar* tabBar = const_cast<TabBar*>(this); QSize size = QTabBar::tabSizeHint(index); size.setHeight(qMax(size.height(), minHeight)); int availableWidth = width() - (m_addTabButton->isVisible() ? m_addTabButton->width() : 0); int tabCount = count(); int boundedWidthForTab = maxWidth; int activeTabWidth = boundedWidthForTab; if (tabCount > 0) { boundedWidthForTab = qBound(minWidth, availableWidth / tabCount, maxWidth); if (index == currentIndex()) { activeTabWidth = qBound(boundedWidthForTab, availableWidth - (tabCount - 1) * boundedWidthForTab, maxWidth); size.setWidth(activeTabWidth); } else { size.setWidth(boundedWidthForTab); } } if (index == tabCount - 1) { if (tabCount * boundedWidthForTab > availableWidth) { m_addTabButton->hide(); } else { int addTabButtonX = (tabCount - 1) * boundedWidthForTab + activeTabWidth; if (isRightToLeft()) { addTabButtonX = width() - addTabButtonX; } tabBar->moveAddTabButton(addTabButtonX); m_addTabButton->show(); } } return size; }
QSize TabBar::tabSizeHint(int index) const { QSize size = QTabBar::tabSizeHint(index); WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); TabBar* tabBar = const_cast <TabBar*>(this); tabBar->m_adjustingLastTab = false; if (webTab && webTab->isPinned()) { size.setWidth(PINNED_TAB_WIDTH); } else { int availableWidth = width() - (PINNED_TAB_WIDTH * m_pinnedTabsCount) - m_tabWidget->buttonListTabs()->width() - m_tabWidget->buttonAddTab()->width(); int normalTabsCount = count() - m_pinnedTabsCount; if (availableWidth >= MAXIMUM_TAB_WIDTH * normalTabsCount) { tabBar->m_normalTabWidth = MAXIMUM_TAB_WIDTH; size.setWidth(m_normalTabWidth); } else if (availableWidth < MINIMUM_TAB_WIDTH * normalTabsCount) { tabBar->m_normalTabWidth = MINIMUM_TAB_WIDTH; size.setWidth(m_normalTabWidth); } else { int maxWidthForTab = availableWidth / normalTabsCount; tabBar->m_normalTabWidth = maxWidthForTab; //Fill any empty space (we've got from rounding) with last tab if (index == count() - 1) { tabBar->m_lastTabWidth = (availableWidth - maxWidthForTab * normalTabsCount) + maxWidthForTab; tabBar->m_adjustingLastTab = true; size.setWidth(m_lastTabWidth); } else { tabBar->m_lastTabWidth = maxWidthForTab; size.setWidth(m_lastTabWidth); } } } if (index == count() - 1) { int xForAddTabButton = (PINNED_TAB_WIDTH * m_pinnedTabsCount) + (count() - m_pinnedTabsCount) * (m_normalTabWidth); if (m_adjustingLastTab) { xForAddTabButton += m_lastTabWidth - m_normalTabWidth; } emit tabBar->moveAddTabButton(xForAddTabButton); } return size; }
void TabBarPrivate::drawTab(QPainter& painter, QRect& rect, const QString& text, bool active) { QPolygon polygon; if (tabbar->isLeftToRight()) polygon << QPoint(rect.x(), rect.y()) << QPoint(rect.x(), rect.bottom() - 3) << QPoint(rect.x() + 2, rect.bottom()) << QPoint(rect.right() - 4, rect.bottom()) << QPoint(rect.right() - 2, rect.bottom() - 2) << QPoint(rect.right() + 5, rect.top()); else polygon << QPoint(rect.right(), rect.top()) << QPoint(rect.right(), rect.bottom() - 3) << QPoint(rect.right() - 2, rect.bottom()) << QPoint(rect.x() + 4, rect.bottom()) << QPoint(rect.x() + 2, rect.bottom() - 2) << QPoint(rect.x() - 5, rect.top()); painter.save(); // fill it first QBrush bg = tabbar->palette().background(); if (active) bg = tabbar->palette().base(); painter.setBrush(bg); painter.setPen(QPen(Qt::NoPen)); painter.drawPolygon(polygon); // draw the lines painter.setPen(tabbar->palette().color(QPalette::Dark)); painter.setRenderHint(QPainter::Antialiasing); if (!active) { const bool reverseLayout = tabbar->isRightToLeft(); painter.drawLine(rect.x() - (reverseLayout ? 5 : 0), rect.y(), rect.right() + (reverseLayout ? 0 : 5), rect.top()); } painter.drawPolyline(polygon); painter.setPen(tabbar->palette().color(QPalette::ButtonText)); QFont f = font(active); painter.setFont(f); QFontMetrics fm = painter.fontMetrics(); int tx = rect.x() + (rect.width() - fm.width(text)) / 2; int ty = rect.y() + (rect.height() - fm.height()) / 2 + fm.ascent(); painter.drawText(tx, ty, text); painter.restore(); }
void TabBar::mouseMoveEvent(QMouseEvent* event) { // while dragging if (event->buttons() & Qt::LeftButton) { // If we call winId() here, drag no longer works. // qDebug() << "mouseMoveEvent. pos:" << event->pos() << "globalPos:" << event->globalPos(); // qDebug() << "mouseMoveEvent" << event; // first mouse enter event after dragging if (m_dragInitiated && geometry().contains(event->pos())) { qDebug("first mouse enter event"); finishDrag(); // Start mouse move emit onDetachTabEntered(event->screenPos().toPoint()); return QTabBar::mouseMoveEvent(event); } // dragging tab is over an another tab bar. TabBar* anotherTabBar = App::tabBarAt(event->screenPos().x(), event->screenPos().y()); if (m_dragInitiated && anotherTabBar && anotherTabBar != this) { qDebug("dragging tab is over an another tab bar."); finishDrag(); // NOTE: dirty Hack!!! // // TabView A TabView B // tab1 tab2 tab3 // // When starting to move a tab1, in QTabBarPrivate d->pressedIndex is 0 // When tab1 passes tab2, d->pressedIndex is 1 // When tab1 moves to TabView B, this code block is executed and onDetachTabEntered is // emitted // In TabView::detachTabEntered, insertTab is called with tab1 // TabView B becomes the parent of tab1 and TabView A removes tab1 becaues it's no longer // parent // In paintEvent of TabView A, it tries to paint d->tabList[d->pressedIndex] but crash occurs // because it's out of range // // In mouseReleaseEvent below, it resets d->pressedIndex to -1 to avoid the situation above mouseReleaseEvent(new QMouseEvent(QEvent::MouseButtonRelease, event->screenPos().toPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier)); emit anotherTabBar->onDetachTabEntered(event->screenPos().toPoint()); anotherTabBar->m_sourceTabBar = this; anotherTabBar->grabMouse(); return; } if (m_dragInitiated && m_fakeWindow) { m_fakeWindow->moveWithOffset(event->globalPos()); return QTabBar::mouseMoveEvent(event); } // qDebug() << "manhattanLength? " << ((event->pos() - m_dragStartPos).manhattanLength() < // QApplication::startDragDistance()) << "outside of tabbar? " << // !geometry().contains(event->pos()); if (!m_dragStartPos.isNull() && ((event->buttons() & Qt::LeftButton)) && ((event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance()) && (!geometry().contains(event->pos()))) { m_dragInitiated = true; // Stop the move to be able to convert to a drag QMouseEvent finishMoveEvent(QEvent::MouseMove, event->pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); QTabBar::mouseMoveEvent(&finishMoveEvent); // Initiate Drag qDebug("start dragging a tab"); m_fakeWindow = new FakeWindow(this, m_dragStartPos); m_fakeWindow->show(); emit onDetachTabStarted(tabAt(m_dragStartPos), event->screenPos().toPoint()); } else { QTabBar::mouseMoveEvent(event); } // not dragging } else { showCloseButtonOnActiveTab(event->pos()); } }
QSize TabBar::tabSizeHint(int index) const { if (!isVisible()) { // Don't calculate it when tabbar is not visible // It produces invalid size anyway return QSize(-1, -1); } static int PINNED_TAB_WIDTH = -1; static int MINIMUM_ACTIVE_TAB_WIDTH = -1; if (PINNED_TAB_WIDTH == -1) { PINNED_TAB_WIDTH = 16 + style()->pixelMetric(QStyle::PM_TabBarTabHSpace, 0, this); MINIMUM_ACTIVE_TAB_WIDTH = PINNED_TAB_WIDTH + style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this); // just a hack: we want to be sure buttonAddTab and buttonListTabs can't cover the active tab MINIMUM_ACTIVE_TAB_WIDTH = qMax(MINIMUM_ACTIVE_TAB_WIDTH, 6 + m_tabWidget->buttonListTabs()->width() + m_tabWidget->buttonAddTab()->width()); } QSize size = QTabBar::tabSizeHint(index); WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); TabBar* tabBar = const_cast <TabBar*>(this); bool adjustingActiveTab = false; if (webTab && webTab->isPinned()) { size.setWidth(PINNED_TAB_WIDTH); } else { int availableWidth = width() - (PINNED_TAB_WIDTH * m_pinnedTabsCount) - m_tabWidget->buttonListTabs()->width() - m_tabWidget->buttonAddTab()->width(); int normalTabsCount = count() - m_pinnedTabsCount; if (availableWidth >= MAXIMUM_TAB_WIDTH * normalTabsCount) { m_normalTabWidth = MAXIMUM_TAB_WIDTH; size.setWidth(m_normalTabWidth); } else if (availableWidth < MINIMUM_TAB_WIDTH * normalTabsCount) { // Tabs don't fit at all in tabbar even with MINIMUM_TAB_WIDTH // We will try to use as low width of tabs as possible // to try avoid overflowing tabs into tabbar buttons int maxWidthForTab = availableWidth / normalTabsCount; m_activeTabWidth = maxWidthForTab; if (m_activeTabWidth < MINIMUM_ACTIVE_TAB_WIDTH) { maxWidthForTab = (availableWidth - MINIMUM_ACTIVE_TAB_WIDTH) / (normalTabsCount - 1); m_activeTabWidth = MINIMUM_ACTIVE_TAB_WIDTH; adjustingActiveTab = true; } if (maxWidthForTab < PINNED_TAB_WIDTH) { // FIXME: It overflows now m_normalTabWidth = PINNED_TAB_WIDTH; if (index == currentIndex()) { size.setWidth(m_activeTabWidth); } else { size.setWidth(m_normalTabWidth); } } else { m_normalTabWidth = maxWidthForTab; // Fill any empty space (we've got from rounding) with active tab if (index == currentIndex()) { if (adjustingActiveTab) { m_activeTabWidth = (availableWidth - MINIMUM_ACTIVE_TAB_WIDTH - maxWidthForTab * (normalTabsCount - 1)) + m_activeTabWidth; } else { m_activeTabWidth = (availableWidth - maxWidthForTab * normalTabsCount) + maxWidthForTab; } adjustingActiveTab = true; size.setWidth(m_activeTabWidth); } else { size.setWidth(m_normalTabWidth); } if (tabsClosable()) { // Hiding close buttons to save some space tabBar->setTabsClosable(false); tabBar->showCloseButton(currentIndex()); } } } else { int maxWidthForTab = availableWidth / normalTabsCount; m_activeTabWidth = maxWidthForTab; if (m_activeTabWidth < MINIMUM_ACTIVE_TAB_WIDTH) { maxWidthForTab = (availableWidth - MINIMUM_ACTIVE_TAB_WIDTH) / (normalTabsCount - 1); m_activeTabWidth = MINIMUM_ACTIVE_TAB_WIDTH; adjustingActiveTab = true; } m_normalTabWidth = maxWidthForTab; // Fill any empty space (we've got from rounding) with active tab if (index == currentIndex()) { if (adjustingActiveTab) { m_activeTabWidth = (availableWidth - MINIMUM_ACTIVE_TAB_WIDTH - maxWidthForTab * (normalTabsCount - 1)) + m_activeTabWidth; } else { m_activeTabWidth = (availableWidth - maxWidthForTab * normalTabsCount) + maxWidthForTab; } adjustingActiveTab = true; size.setWidth(m_activeTabWidth); } else { size.setWidth(m_normalTabWidth); } // Restore close buttons according to preferences if (!tabsClosable()) { tabBar->setTabsClosable(true); // Hide close buttons on pinned tabs for (int i = 0; i < count(); ++i) { tabBar->updatePinnedTabCloseButton(i); } } } } if (index == currentIndex()) { int xForAddTabButton = (PINNED_TAB_WIDTH * m_pinnedTabsCount) + (count() - m_pinnedTabsCount) * (m_normalTabWidth); if (adjustingActiveTab) { xForAddTabButton += m_activeTabWidth - m_normalTabWidth; } // RTL Support if (QApplication::layoutDirection() == Qt::RightToLeft) { xForAddTabButton = width() - xForAddTabButton; } emit tabBar->moveAddTabButton(xForAddTabButton); } return size; }
QSize TabBar::tabSizeHint(int index, bool fast) const { if (!m_window->isVisible()) { // Don't calculate it when window is not visible // It produces invalid size anyway return QSize(-1, -1); } const int pinnedTabWidth = comboTabBarPixelMetric(ComboTabBar::PinnedTabWidth); const int minTabWidth = comboTabBarPixelMetric(ComboTabBar::NormalTabMinimumWidth); QSize size = ComboTabBar::tabSizeHint(index); // The overflowed tabs have same size and we can use this fast method if (fast) { size.setWidth(index >= pinnedTabsCount() ? minTabWidth : pinnedTabWidth); return size; } WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); TabBar* tabBar = const_cast <TabBar*>(this); if (webTab && webTab->isPinned()) { size.setWidth(pinnedTabWidth); } else { int availableWidth = mainTabBarWidth() - comboTabBarPixelMetric(ExtraReservedWidth); if (availableWidth < 0) { return QSize(-1, -1); } const int normalTabsCount = ComboTabBar::normalTabsCount(); const int maxTabWidth = comboTabBarPixelMetric(ComboTabBar::NormalTabMaximumWidth); if (availableWidth >= maxTabWidth * normalTabsCount) { m_normalTabWidth = maxTabWidth; size.setWidth(m_normalTabWidth); } else if (normalTabsCount > 0) { const int minActiveTabWidth = comboTabBarPixelMetric(ComboTabBar::ActiveTabMinimumWidth); int maxWidthForTab = availableWidth / normalTabsCount; int realTabWidth = maxWidthForTab; bool adjustingActiveTab = false; if (realTabWidth < minActiveTabWidth) { maxWidthForTab = normalTabsCount > 1 ? (availableWidth - minActiveTabWidth) / (normalTabsCount - 1) : 0; realTabWidth = minActiveTabWidth; adjustingActiveTab = true; } bool tryAdjusting = availableWidth >= minTabWidth * normalTabsCount; if (m_showCloseOnInactive != 1 && tabsClosable() && availableWidth < (minTabWidth + 25) * normalTabsCount) { // Hiding close buttons to save some space tabBar->setTabsClosable(false); tabBar->showCloseButton(currentIndex()); } if (m_showCloseOnInactive == 1) { // Always showing close buttons tabBar->setTabsClosable(true); tabBar->showCloseButton(currentIndex()); } if (tryAdjusting) { m_normalTabWidth = maxWidthForTab; // Fill any empty space (we've got from rounding) with active tab if (index == mainTabBarCurrentIndex()) { if (adjustingActiveTab) { m_activeTabWidth = (availableWidth - minActiveTabWidth - maxWidthForTab * (normalTabsCount - 1)) + realTabWidth; } else { m_activeTabWidth = (availableWidth - maxWidthForTab * normalTabsCount) + maxWidthForTab; } size.setWidth(m_activeTabWidth); } else { size.setWidth(m_normalTabWidth); } } } // Restore close buttons according to preferences if (m_showCloseOnInactive != 2 && !tabsClosable() && availableWidth >= (minTabWidth + 25) * normalTabsCount) { tabBar->setTabsClosable(true); // Hide close buttons on pinned tabs for (int i = 0; i < count(); ++i) { tabBar->updatePinnedTabCloseButton(i); } } } if (index == count() - 1) { WebTab* lastMainActiveTab = qobject_cast<WebTab*>(m_tabWidget->widget(mainTabBarCurrentIndex())); int xForAddTabButton = cornerWidth(Qt::TopLeftCorner) + pinTabBarWidth() + normalTabsCount() * m_normalTabWidth; if (lastMainActiveTab && m_activeTabWidth > m_normalTabWidth) { xForAddTabButton += m_activeTabWidth - m_normalTabWidth; } if (QApplication::layoutDirection() == Qt::RightToLeft) { xForAddTabButton = width() - xForAddTabButton; } emit tabBar->moveAddTabButton(xForAddTabButton); } return size; }
/** Default constructor. */ TabPlaylist::TabPlaylist(QWidget *parent) : QTabWidget(parent), _closePlaylistPopup(new ClosePlaylistPopup(this)), _mainWindow(NULL) { TabBar *tabBar = new TabBar(this); this->setTabBar(tabBar); this->setMovable(true); messageBox = new TracksNotFoundMessageBox(this); //SettingsPrivate *settings = SettingsPrivate::instance(); // Add a new playlist connect(this, &QTabWidget::currentChanged, this, [=]() { emit updatePlaybackModeButton(); }); // Removing a playlist connect(_closePlaylistPopup->buttonBox, &QDialogButtonBox::clicked, this, &TabPlaylist::execActionFromClosePopup); connect(this, &QTabWidget::tabCloseRequested, this, &TabPlaylist::closePlaylist); /// FIXME: when changing font for saved and untouched playlists, overwritting to normal instead of disabled /// Reducing size is ok, inreasing size is ko /*connect(settings, &SettingsPrivate::fontHasChanged, this, [=](const SettingsPrivate::FontFamily ff, const QFont &) { if (ff == SettingsPrivate::FF_Playlist) { for (int i = 0; i < count() - 1; i++) { if (playlist(i)->mediaPlaylist()->isEmpty()) { this->setTabIcon(i, this->defaultIcon(QIcon::Disabled)); } else { this->setTabIcon(i, this->defaultIcon(QIcon::Normal)); } } } });*/ // Context menu to add few actions for each playlist _contextMenu = new QMenu(this); QAction *renamePlaylist = new QAction(tr("Rename playlist"), _contextMenu); QAction *loadBackground = new QAction(tr("Load background..."), _contextMenu); QAction *clearBackground = new QAction(tr("Clear background"), _contextMenu); loadBackground->setEnabled(false); clearBackground->setEnabled(false); _contextMenu->addAction(renamePlaylist); _contextMenu->addSeparator(); _contextMenu->addAction(loadBackground); _contextMenu->addAction(clearBackground); connect(renamePlaylist, &QAction::triggered, this, [=]() { QPoint p = _contextMenu->property("mouseRightClickPos").toPoint(); int index = tabBar->tabAt(p); this->setCurrentIndex(index); tabBar->editTab(index); }); connect(loadBackground, &QAction::triggered, this, [=]() { qDebug() << Q_FUNC_INFO << "Load background not implemented yet"; }); this->setAcceptDrops(true); CornerWidget *corner = new CornerWidget(this); this->setCornerWidget(corner, Qt::TopRightCorner); connect(corner, &CornerWidget::innerButtonClicked, this, &TabPlaylist::addPlaylist); corner->installEventFilter(this); }