void TabBar::setTabItemCount(const QString &tabName, const QString &itemCount) { const int i = tabIndex(tabName, *this); if (i == -1) return; QWidget *tabCountLabel = tabButton(i, QTabBar::RightSide); if ( itemCount.isEmpty() ) { if (tabCountLabel) { tabCountLabel->deleteLater(); setTabButton(i, QTabBar::RightSide, nullptr); } } else { if (!tabCountLabel) { tabCountLabel = new QLabel(this); tabCountLabel->setObjectName("tab_item_counter"); setDefaultTabItemCounterStyle(tabCountLabel); setTabButton(i, QTabBar::RightSide, tabCountLabel); } tabCountLabel->setProperty("text", itemCount); tabCountLabel->adjustSize(); } updateTabStyle(i); }
void TabBarWidget::tabInserted(int index) { setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); QTabBar::tabInserted(index); if (m_showUrlIcon) { QLabel *label = new QLabel(); label->setFixedSize(QSize(16, 16)); setTabButton(index, m_iconButtonPosition, label); } else { setTabButton(index, m_iconButtonPosition, NULL); } if (m_showCloseButton || getTabProperty(index, QLatin1String("isPinned"), false).toBool()) { QLabel *label = new QLabel(); label->setFixedSize(QSize(16, 16)); label->installEventFilter(this); setTabButton(index, m_closeButtonPosition, label); } updateTabs(); emit tabsAmountChanged(count()); }
void PlaylistTabBar::InsertTab(int id, int index, const QString& text, bool favorite) { suppress_current_changed_ = true; insertTab(index, text); setTabData(index, id); setTabToolTip(index, text); FavoriteWidget* widget = new FavoriteWidget(id, favorite); widget->setToolTip( tr("Click here to favorite this playlist so it will be saved and remain " "accessible " "through the \"Playlists\" panel on the left side bar")); connect(widget, SIGNAL(FavoriteStateChanged(int, bool)), SIGNAL(PlaylistFavorited(int, bool))); setTabButton(index, QTabBar::LeftSide, widget); suppress_current_changed_ = false; // If we are still starting up, we don't need to do this, as the // tab ordering after startup will be the same as was already in the db. if (initialized_) { if (currentIndex() == index) emit CurrentIdChanged(id); // Update playlist tab order/visibility TabMoved(); } }
void TabBarWidget::tabInserted(int index) { QTabBar::tabInserted(index); QLabel *label = new QLabel(); label->setFixedSize(QSize(16, 16)); setTabButton(index, QTabBar::LeftSide, label); updateTabs(); }
void TabBarWidget::tabInserted(int index) { QTabBar::tabInserted(index); QLabel *label = new QLabel(); label->setFixedSize(QSize(16, 16)); setTabButton(index, m_iconButtonPosition, label); updateTabs(); }
void MyTabBar::setupMoveButtons() { for (int i = 0; i < count(); i++) { QFrame *leftFrame = new QFrame(this); QHBoxLayout *leftSide = new QHBoxLayout; leftSide->setContentsMargins(0, 0, 0, 0); leftSide->setSpacing(2); MyCheckBox *chActive = new MyCheckBox(this); chActive->setObjectName(QString("checkBox_fractal_enable_%1").arg(i + 1)); leftSide->addWidget(chActive); connect(chActive, SIGNAL(stateChanged(int)), this, SLOT(slotToggleActive(int))); chActive->setChecked(i == 0); if (i > 0) { QToolButton *tbMoveLeft = new QToolButton(this); QIcon arrowLeft = this->style()->standardIcon(QStyle::SP_ArrowLeft); tbMoveLeft->setIcon(arrowLeft); tbMoveLeft->setIconSize(QSize(10, 10)); tbMoveLeft->setObjectName(QString::number(i)); connect(tbMoveLeft, SIGNAL(clicked()), this, SLOT(slotMoveLeft())); leftSide->addWidget(tbMoveLeft); } leftFrame->setLayout(leftSide); setTabButton(i, QTabBar::LeftSide, leftFrame); if (i < count() - 1) { QToolButton *tbMoveRight = new QToolButton(this); QIcon arrowRight = this->style()->standardIcon(QStyle::SP_ArrowRight); tbMoveRight->setIcon(arrowRight); tbMoveRight->setIconSize(QSize(10, 10)); tbMoveRight->setObjectName(QString::number(i)); setTabButton(i, QTabBar::RightSide, tbMoveRight); connect(tbMoveRight, SIGNAL(clicked()), this, SLOT(slotMoveRight())); } } }
void SeparateTabBar::SetTabClosable (int index, bool closable, QWidget *closeButton) { if (index < 0 || index >= count ()) { qWarning () << Q_FUNC_INFO << "invalid index " << index; return; } setTabButton (index, GetCloseButtonPosition (), closeButton); }
void TabBar::hideCloseButton(int index) { if (!validIndex(index) || tabsClosable()) { return; } CloseButton* button = qobject_cast<CloseButton*>(tabButton(index, closeButtonPosition())); if (!button) { return; } setTabButton(index, closeButtonPosition(), 0); button->deleteLater(); }
void TabBar::showCloseButton(int index) { if (!validIndex(index)) { return; } WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); QAbstractButton* button = qobject_cast<QAbstractButton*>(tabButton(index, QTabBar::RightSide)); if (button || (webTab && webTab->isPinned())) { return; } QAbstractButton* closeButton = new CloseButton(this); connect(closeButton, SIGNAL(clicked()), this, SLOT(closeTabFromButton())); setTabButton(index, QTabBar::RightSide, closeButton); }
void PlaylistTabBar::InsertTab(int id, int index, const QString& text, bool favorite) { suppress_current_changed_ = true; insertTab(index, text); setTabData(index, id); setTabToolTip(index, text); FavoriteWidget* widget = new FavoriteWidget(id, favorite); connect(widget, SIGNAL(FavoriteStateChanged(int, bool)), SIGNAL(PlaylistFavorited(int, bool))); setTabButton(index, QTabBar::LeftSide, widget); suppress_current_changed_ = false; if (currentIndex() == index) emit CurrentIdChanged(id); // Update playlist tab order/visibility TabMoved(); }
void TabBarWidget::optionChanged(const QString &option, const QVariant &value) { if (option == QLatin1String("TabBar/ShowCloseButton")) { const bool showCloseButton = value.toBool(); if (showCloseButton != m_showCloseButton) { for (int i = 0; i < count(); ++i) { if (showCloseButton) { QLabel *label = new QLabel(); label->setFixedSize(QSize(16, 16)); setTabButton(i, m_closeButtonPosition, label); } else { setTabButton(i, m_closeButtonPosition, NULL); } } updateTabs(); } m_showCloseButton = showCloseButton; } else if (option == QLatin1String("TabBar/ShowUrlIcon")) { const bool showUrlIcon = value.toBool(); if (showUrlIcon != m_showUrlIcon) { for (int i = 0; i < count(); ++i) { if (showUrlIcon) { QLabel *label = new QLabel(); label->setFixedSize(QSize(16, 16)); setTabButton(i, m_iconButtonPosition, label); } else { setTabButton(i, m_iconButtonPosition, NULL); } } updateTabs(); } m_showUrlIcon = showUrlIcon; } else if (option == QLatin1String("TabBar/EnablePreviews")) { m_enablePreviews = value.toBool(); } else if (option == QLatin1String("TabBar/MaximumTabSize")) { const int oldValue = m_maximumTabSize; m_maximumTabSize = value.toInt(); if (m_maximumTabSize < 0) { m_maximumTabSize = 250; } if (m_maximumTabSize != oldValue) { updateGeometry(); updateTabs(); } } else if (option == QLatin1String("TabBar/MinimumTabSize") && value.toInt() != m_minimumTabSize) { const int oldValue = m_minimumTabSize; m_minimumTabSize = value.toInt(); if (m_minimumTabSize < 0) { m_minimumTabSize = 40; } if (m_minimumTabSize != oldValue) { updateGeometry(); updateTabs(); } } }
void SeparateTabBar::SetAddTabButton (QWidget *w) { AddTabButton_ = w; setTabButton (count () - 1, GetAntiCloseButtonPosition (), w); }