void TabBar::setTabName(int tabIndex, const QString &tabName) { // Use tab data to store tab name because tab text can change externally, // e.g. Breeze theme adds missing accelerators (renames "test" to "&test). setTabData(tabIndex, tabName); QTabBar::setTabText(tabIndex, tabName); }
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(); } }
int PanelTabBar::addPanel(ListPanel *panel, bool setCurrent, KrPanel *nextTo) { int insertIndex = -1; if(nextTo) { for(int i = 0; i < count(); i++) { if(getPanel(i) == nextTo) { insertIndex = i + 1; break; } } } int newId; if(insertIndex != -1) { newId = insertTab(insertIndex, squeeze(DISPLAY(panel->virtualPath()))); } else newId = addTab(squeeze(DISPLAY(panel->virtualPath()))); QVariant v; v.setValue((long long)panel); setTabData(newId, v); // make sure all tabs lengths are correct layoutTabs(); if (setCurrent) setCurrentIndex(newId); connect(panel, &ListPanel::pathChanged, [=]() { updateTab(panel); }); return newId; }
void SeparateTabBar::SetTabData (int index) { if (index < 0 || index >= count () - 1) { qWarning () << Q_FUNC_INFO << "invalid index " << index; return; } setTabData (index, ++Id_); }
void TabBarWidget::addTab(int index, Window *window) { insertTab(index, window->getTitle()); setTabData(index, window->getIdentifier()); connect(window, SIGNAL(iconChanged(QIcon)), this, SLOT(updateTabs())); connect(window, SIGNAL(loadingStateChanged(WindowLoadingState)), this, SLOT(updateTabs())); connect(window, SIGNAL(isPinnedChanged(bool)), this, SLOT(updatePinnedTabsAmount())); if (window->isPinned()) { updatePinnedTabsAmount(); } updateTabs(index); }
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::addTab(int index, Window *window) { insertTab(index, window->getTitle()); setTabData(index, QVariant::fromValue(window)); connect(window, SIGNAL(iconChanged(QIcon)), this, SLOT(updateTabs())); connect(window, SIGNAL(loadingStateChanged(WindowLoadingState)), this, SLOT(updateTabs())); connect(window, SIGNAL(isPinnedChanged(bool)), this, SLOT(updatePinnedTabsAmount())); connect(tabButton(index, QTabBar::LeftSide), SIGNAL(destroyed()), window, SLOT(deleteLater())); if (window->isPinned()) { updatePinnedTabsAmount(); } updateTabs(index); }
void pTabBar::dropEvent( QDropEvent* event ) { if ( !event->mimeData()->hasUrls() ) { // get drop tab int ni = tabAt( event->pos() ); // if get it if ( ni != -1 ) { // get original tab infos int oi = event->mimeData()->data( "x-tabindex" ).toInt(); QVariant otd = tabData( oi ); QIcon oti = tabIcon( oi ); QString ott = tabText( oi ); QColor ottc = tabTextColor( oi ); QString ottt = tabToolTip( oi ); QString otwt = tabWhatsThis( oi ); // remove original tab removeTab( oi ); // insert new one with correct infos int i = insertTab( ni, oti, ott ); setTabData( i, otd ); setTabTextColor( i, ottc ); setTabToolTip( i, ottt ); setTabWhatsThis( i, otwt ); //accept event->acceptProposedAction(); // emit signal emit tabDropped( oi, i ); // set new current index setCurrentIndex( i ); } } else emit urlsDropped( event->mimeData()->urls () ); // default event QTabBar::dropEvent( event ); }
void TabBar::insertTab(int index, const QString &tabName) { const int i = QTabBar::insertTab(index, tabName); setTabData(i, tabName); }
void PanelTabBar::changePanel(int tabIdx, ListPanel *panel) { QVariant v; v.setValue((long long)panel); setTabData(tabIdx, v); }
ShopViewer::ShopViewer(AdamantShopPlugin* plugin, StashViewer* viewer, QWidget *parent) : QWidget(parent) , _plugin(plugin) , _stashViewer(viewer) , _currentShop(nullptr) , ui(new Ui::ShopViewer) , _tabWidePriceButton(new QPushButton("Set Tab-wide Price...")) { ui->setupUi(this); ui->viewWidget->hide(); QHeaderView* headerView = ui->tableWidget->horizontalHeader(); headerView->setSectionResizeMode(QHeaderView::Stretch); headerView->setSectionResizeMode(0, QHeaderView::Fixed); headerView->setSectionResizeMode(1, QHeaderView::Interactive); headerView->resizeSection(1, 96); headerView->resizeSection(1, 384); // generate some data: QVector<double> x(101), y(101); // initialize with entries 0..100 for (int i=0; i<101; ++i) { x[i] = i/50.0 - 1; // x goes from -1 to 1 y[i] = x[i]*x[i]; // let's plot a quadratic function } // create graph and assign data to it: ui->plot->addGraph(); ui->plot->graph(0)->setData(x, y); // give the axes some labels: ui->plot->xAxis->setLabel("x"); ui->plot->yAxis->setLabel("y"); // set axes ranges, so we see all data: ui->plot->xAxis->setRange(-1, 1); ui->plot->yAxis->setRange(0, 1); ui->plot->replot(); setupStashIntegration(); showShop(nullptr); connect(_plugin->Core()->forum(), &Session::ForumRequest::requestReady, this, [this](const ForumSubmission* submission) { if (!_submissions.contains(submission)) return; ForumSubmission* sub = (ForumSubmission*)submission; sub->data.insert("content", "actually no, this data!"); }); connect(_plugin->Core()->forum(), &Session::ForumRequest::requestError, this, [this](const ForumSubmission* submission, const QString &error) { if (!_submissions.contains(submission)) return; qDebug() << "Error!" << submission->threadId << error; _submissions.removeOne(submission); delete submission; }); connect(_plugin->Core()->forum(), &Session::ForumRequest::requestFinished, this, [this](const ForumSubmission* submission) { if (!_submissions.contains(submission)) return; qDebug() << "Finished!" << submission->threadId; _submissions.removeOne(submission); delete submission; }); connect(_tabWidePriceButton, &QPushButton::released, this, [this]() { QStringList selected = _stashViewer->getSelectedTabs(); auto shop = _plugin->getShop(_stashViewer->getCurrentLeague()); PriceDialog dialog(shop, selected, true, this); dialog.setWindowTitle("Set Tab-Wide Price"); if (dialog.exec()) { QString value; if (dialog.getType() == "@none") { value = ""; } else { value = QString("%1 %2 %3").arg(dialog.getType()).arg(dialog.getValue()).arg(dialog.getCurrency()); } for (QString id : selected) { if (value.isEmpty()) shop->clearTabData(id); else shop->setTabData(id, value); } _plugin->saveShop(shop); _stashViewer->update(); } }); auto setAction = GraphicItem::AddContextAction("Set Price..."); connect(setAction, &QAction::triggered, this, [this]() { QStringList selected = _stashViewer->getSelectedItems(); auto shop = _plugin->getShop(_stashViewer->getCurrentLeague()); PriceDialog dialog(shop, selected, false, this); dialog.setWindowTitle("Set Item Price"); if (dialog.exec()) { QString value; if (dialog.getType() == "@none") { value = ""; } else if (dialog.getType() == "@inherit") { value = "@inherit"; } else { value = QString("%1 %2 %3").arg(dialog.getType()).arg(dialog.getValue()).arg(dialog.getCurrency()); } for (QString id : selected) { if (value.isEmpty()) shop->clearItemData(id); else shop->setItemData(id, value); } _plugin->saveShop(shop); _stashViewer->update(); } }); auto clearAction = GraphicItem::AddContextAction("Clear Prices"); connect(clearAction, &QAction::triggered, this, [this]() { QStringList selected = _stashViewer->getSelectedItems(); auto shop = _plugin->getShop(_stashViewer->getCurrentLeague()); for (QString id : selected) { shop->clearItemData(id); } _plugin->saveShop(shop); _stashViewer->update(); }); }