void WBTabBar::contextMenuRequested(const QPoint &position) { QMenu menu; menu.addAction(tr("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); int index = tabAt(position); if (-1 != index) { QAction *action = menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab())); action->setData(index); menu.addSeparator(); action = menu.addAction(tr("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); action->setData(index); action = menu.addAction(tr("Close &Other Tabs"), this, SLOT(closeOtherTabs())); action->setData(index); menu.addSeparator(); action = menu.addAction(tr("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); action->setData(index); } else { menu.addSeparator(); } menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); menu.exec(QCursor::pos()); }
void WBTabBar::cloneTab() { if (QAction *action = qobject_cast<QAction*>(sender())) { int index = action->data().toInt(); emit cloneTab(index); } }
void TabBarWidget::contextMenuEvent(QContextMenuEvent *event) { m_clickedTab = tabAt(event->pos()); hidePreview(); QMenu menu(this); menu.addAction(ActionsManager::getAction(QLatin1String("NewTab"), this)); menu.addAction(ActionsManager::getAction(QLatin1String("NewTabPrivate"), this)); if (m_clickedTab >= 0) { const bool isPinned = getTabProperty(m_clickedTab, QLatin1String("isPinned"), false).toBool(); menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab()))->setEnabled(getTabProperty(m_clickedTab, QLatin1String("canClone"), false).toBool()); menu.addAction((isPinned ? tr("Unpin Tab") : tr("Pin Tab")), this, SLOT(pinTab())); menu.addSeparator(); menu.addAction(tr("Detach Tab"), this, SLOT(detachTab()))->setEnabled(count() > 1); menu.addSeparator(); if (isPinned) { QAction *closeAction = menu.addAction(Utils::getIcon(QLatin1String("tab-close")), tr("Close Tab")); ActionsManager::setupLocalAction(ActionsManager::getAction(QLatin1String("CloseTab"), this), closeAction, true); closeAction->setEnabled(false); } else { menu.addAction(ActionsManager::getAction(QLatin1String("CloseTab"), this)); } const int amount = (count() - getPinnedTabsAmount()); menu.addAction(Utils::getIcon(QLatin1String("tab-close-other")), tr("Close Other Tabs"), this, SLOT(closeOther()))->setEnabled(amount > 0 && !(amount == 1 && !isPinned)); } menu.exec(event->globalPos()); m_clickedTab = -1; if (underMouse()) { m_previewTimer = startTimer(250); } }
void Panel::OnNcLButtonUp( UINT nHitTest, CPoint point ) { int lastBut = buttonDown_; buttonDown_ = 0; paintCaptionButtons( nHitTest ); switch ( nHitTest ) { case BUT_CLOSE: if ( lastBut != nHitTest ) break; if ( onClose() ) { if ( tabCount() == 0 ) Manager::instance().dock()->removePanel( this ); return; } break; case BUT_ROLLUP: if ( lastBut != nHitTest ) break; setExpanded( !isExpanded_ ); SetFocus(); activate(); break; case BUT_CLONE: if ( lastBut != nHitTest ) break; if ( activeTab_ ) { CRect rect; GetWindowRect( &rect ); // position is hand-hacked, but should work well in all cases cloneTab( activeTab_->getContent(), ( rect.left + 10 ) % (GetSystemMetrics( SM_CXMAXIMIZED ) - 64), ( rect.top ) % (GetSystemMetrics( SM_CYMAXIMIZED ) - 64) ); } break; } }
void FooTabBar::contextMenuRequested (const QPoint &position) { /* Renane Playlist Remove Playlist Add New Playlist --- Move Left Move Right --- Save All Playlists... Save Playlist... Load Playlist... --- "<playlist-name>" Contents > -- odpuścić na razie */ QMenu menu; menu.addAction(tr("New Playlist..."), this, SIGNAL(newTab()), QKeySequence::New); int index = tabAt(position); if (-1 != index) { menu.addAction(tr("&Duplicate Playlist"), this, SLOT(cloneTab()))->setData(index); menu.addSeparator(); menu.addAction(tr("&Close Playlist"), this, SLOT(closeTab()), QKeySequence::Close)->setData(index); menu.addSeparator(); menu.addAction (tr ("Close &Other Playlists"), this, SLOT (closeOtherTabs()))->setData(index); menu.addSeparator(); menu.addAction (tr ("&Rename Playlist"), this, SLOT(renameTab()))->setData(index); } menu.exec (QCursor::pos()); }
void TabBar::contextMenuRequested(const QPoint &position) { QMenu menu; TabWidget *tabWidget = qobject_cast<TabWidget *>(parentWidget()); if (!tabWidget) return; menu.addAction(tabWidget->newTabAction()); int index = tabAt(position); if (-1 != index) { QAction *action = menu.addAction(tr("Duplicate Tab"), this, SLOT(cloneTab())); action->setData(index); menu.addSeparator(); action = menu.addAction(tr("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); action->setData(index); action = menu.addAction(tr("Close &Other Tabs"), this, SLOT(closeOtherTabs())); action->setData(index); menu.addSeparator(); action = menu.addAction(tr("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); action->setData(index); } else { menu.addSeparator(); } menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); menu.addSeparator(); menu.addAction(tabWidget->bookmarkTabsAction()); menu.exec(QCursor::pos()); }
void TabBar::cloneTab() { emit cloneTab(m_actualIndex); m_actualIndex = -1; }
void TabBarWidget::contextMenuEvent(QContextMenuEvent *event) { m_clickedTab = tabAt(event->pos()); if (m_previewWidget && m_previewWidget->isVisible()) { m_previewWidget->hide(); } if (m_previewTimer > 0) { killTimer(m_previewTimer); m_previewTimer = 0; } QMenu menu(this); menu.addAction(ActionsManager::getAction(QLatin1String("NewTab"))); menu.addAction(ActionsManager::getAction(QLatin1String("NewTabPrivate"))); if (m_clickedTab >= 0) { const bool isPinned = getTabProperty(m_clickedTab, QLatin1String("isPinned"), false).toBool(); int amount = 0; for (int i = 0; i < count(); ++i) { if (getTabProperty(i, QLatin1String("isPinned"), false).toBool() || i == m_clickedTab) { continue; } ++amount; } menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab()))->setEnabled(getTabProperty(m_clickedTab, QLatin1String("canClone"), false).toBool()); menu.addAction((isPinned ? tr("Unpin Tab") : tr("Pin Tab")), this, SLOT(pinTab())); menu.addSeparator(); menu.addAction(tr("Detach Tab"), this, SLOT(detachTab()))->setEnabled(count() > 1); menu.addSeparator(); if (isPinned) { QAction *closeAction = menu.addAction(QString()); ActionsManager::setupLocalAction(closeAction, QLatin1String("CloseTab"), true); closeAction->setEnabled(false); } else { menu.addAction(ActionsManager::getAction(QLatin1String("CloseTab"))); } menu.addAction(QIcon(":/icons/tab-close-other.png"), tr("Close Other Tabs"), this, SLOT(closeOther()))->setEnabled(amount > 0); } menu.exec(event->globalPos()); m_clickedTab = -1; if (underMouse()) { m_previewTimer = startTimer(250); } }
void TabBarWidget::contextMenuEvent(QContextMenuEvent *event) { m_clickedTab = tabAt(event->pos()); hidePreview(); QMenu menu(this); menu.addAction(ActionsManager::getAction(ActionsManager::NewTabAction, this)); menu.addAction(ActionsManager::getAction(ActionsManager::NewTabPrivateAction, this)); if (m_clickedTab >= 0) { const bool isPinned = getTabProperty(m_clickedTab, QLatin1String("isPinned"), false).toBool(); Action *cloneTabAction = new Action(ActionsManager::CloneTabAction, &menu); cloneTabAction->setEnabled(getTabProperty(m_clickedTab, QLatin1String("canClone"), false).toBool()); Action *pinTabAction = new Action(ActionsManager::PinTabAction, &menu); pinTabAction->setOverrideText(isPinned ? QT_TRANSLATE_NOOP("actions", "Unpin Tab") : QT_TRANSLATE_NOOP("actions", "Pin Tab")); Action *detachTabAction = new Action(ActionsManager::DetachTabAction, &menu); detachTabAction->setEnabled(count() > 1); menu.addAction(cloneTabAction); menu.addAction(pinTabAction); menu.addSeparator(); menu.addAction(detachTabAction); menu.addSeparator(); if (isPinned) { Action *closeTabAction = new Action(ActionsManager::CloseTabAction, &menu); closeTabAction->setEnabled(false); menu.addAction(closeTabAction); } else { menu.addAction(ActionsManager::getAction(ActionsManager::CloseTabAction, this)); } const int amount = (count() - getPinnedTabsAmount()); Action *closeOtherTabsAction = new Action(ActionsManager::CloseOtherTabsAction, &menu); closeOtherTabsAction->setEnabled(amount > 0 && !(amount == 1 && !isPinned)); menu.addAction(closeOtherTabsAction); menu.addAction(ActionsManager::getAction(ActionsManager::ClosePrivateTabsAction, this)); connect(cloneTabAction, SIGNAL(triggered()), this, SLOT(cloneTab())); connect(pinTabAction, SIGNAL(triggered()), this, SLOT(pinTab())); connect(detachTabAction, SIGNAL(triggered()), this, SLOT(detachTab())); connect(closeOtherTabsAction, SIGNAL(triggered()), this, SLOT(closeOtherTabs())); } menu.addSeparator(); QMenu *arrangeMenu = menu.addMenu(tr("Arrange")); arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::RestoreTabAction, this)); arrangeMenu->addSeparator(); arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::RestoreAllAction, this)); arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::MaximizeAllAction, this)); arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::MinimizeAllAction, this)); arrangeMenu->addSeparator(); arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::CascadeAllAction, this)); arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::TileAllAction, this)); QAction *cycleAction = new QAction(tr("Switch tabs using the mouse wheel"), this); cycleAction->setCheckable(true); cycleAction->setChecked(!SettingsManager::getValue(QLatin1String("TabBar/RequireModifierToSwitchTabOnScroll")).toBool()); connect(cycleAction, SIGNAL(toggled(bool)), this, SLOT(setCycle(bool))); ToolBarWidget *toolBar = qobject_cast<ToolBarWidget*>(parentWidget()); if (toolBar) { QList<QAction*> actions; actions.append(cycleAction); menu.addMenu(ToolBarWidget::createCustomizationMenu(ToolBarsManager::TabBar, actions, &menu)); } else { QMenu *customizationMenu = menu.addMenu(tr("Customize")); customizationMenu->addAction(cycleAction); customizationMenu->addSeparator(); customizationMenu->addAction(ActionsManager::getAction(ActionsManager::LockToolBarsAction, this)); } menu.exec(event->globalPos()); cycleAction->deleteLater(); m_clickedTab = -1; if (underMouse()) { m_previewTimer = startTimer(250); } }