void FxLine::contextMenuEvent( QContextMenuEvent * ) { FxMixer * mix = engine::fxMixer(); QPointer<captionMenu> contextMenu = new captionMenu( mix->effectChannel( m_channelIndex )->m_name ); if( m_channelIndex != 0 ) // no move-options in master { contextMenu->addAction( tr( "Move &left" ), this, SLOT( moveChannelLeft() ) ); contextMenu->addAction( tr( "Move &right" ), this, SLOT( moveChannelRight() ) ); } contextMenu->addAction( tr( "Rename &channel" ), this, SLOT( renameChannel() ) ); contextMenu->addSeparator(); if( m_channelIndex != 0 ) // no remove-option in master { contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "R&emove channel" ), this, SLOT( removeChannel() ) ); contextMenu->addSeparator(); } contextMenu->addAction( embed::getIconPixmap( "help" ), tr( "&Help" ), this, SLOT( displayHelp() ) ); contextMenu->exec( QCursor::pos() ); delete contextMenu; }
void ModuleDockWidget::contextMenu(QPoint point) { m_point = point; QPointer<QMenu> contextMenu = new QMenu(ui->treeView_module); contextMenu->setObjectName("contextMenu"); QAction *actionOpen = new QAction(QIcon::fromTheme("document-open", QIcon(":/icons/16x16/document-open.png")), tr("Open module"), contextMenu); actionOpen->setObjectName("actionOpen"); connect(actionOpen, SIGNAL(triggered()), this, SLOT(open())); QAction *actionOpenInNewTab = new QAction(QIcon::fromTheme("tab-new", QIcon(":/icons/16x16/tab-new.png")), tr("Open module in new tab"), contextMenu); actionOpenInNewTab->setObjectName("actionPaste"); connect(actionOpenInNewTab, SIGNAL(triggered()), this, SLOT(openInNewTab())); QAction *actionSettings = new QAction(QIcon::fromTheme("configure", QIcon(":/icons/16x16/configure.png")), tr("Configure"), contextMenu); actionSettings->setObjectName("actionNew"); connect(actionSettings, SIGNAL(triggered()), this, SLOT(configure())); contextMenu->addAction(actionOpen); contextMenu->addAction(actionOpenInNewTab); contextMenu->addSeparator(); contextMenu->addAction(actionSettings); contextMenu->exec(QCursor::pos()); delete contextMenu; }
void EffectView::contextMenuEvent( QContextMenuEvent * ) { QPointer<CaptionMenu> contextMenu = new CaptionMenu( model()->displayName(), this ); contextMenu->addAction( embed::getIconPixmap( "arp_up" ), tr( "Move &up" ), this, SLOT( moveUp() ) ); contextMenu->addAction( embed::getIconPixmap( "arp_down" ), tr( "Move &down" ), this, SLOT( moveDown() ) ); contextMenu->addSeparator(); contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "&Remove this plugin" ), this, SLOT( deletePlugin() ) ); contextMenu->addSeparator(); contextMenu->exec( QCursor::pos() ); delete contextMenu; }
void ControllerView::contextMenuEvent( QContextMenuEvent * ) { QPointer<CaptionMenu> contextMenu = new CaptionMenu( model()->displayName(), this ); contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "&Remove this controller" ), this, SLOT( deleteController() ) ); contextMenu->addAction( tr("Re&name this controller"), this, SLOT( renameController() )); contextMenu->addSeparator(); contextMenu->exec( QCursor::pos() ); delete contextMenu; }
void FxLine::contextMenuEvent( QContextMenuEvent * ) { QPointer<CaptionMenu> contextMenu = new CaptionMenu( Engine::fxMixer()->effectChannel( m_channelIndex )->m_name, this ); if( m_channelIndex != 0 ) // no move-options in master { contextMenu->addAction( tr( "Move &left" ), this, SLOT( moveChannelLeft() ) ); contextMenu->addAction( tr( "Move &right" ), this, SLOT( moveChannelRight() ) ); } contextMenu->addAction( tr( "Rename &channel" ), this, SLOT( renameChannel() ) ); contextMenu->addSeparator(); if( m_channelIndex != 0 ) // no remove-option in master { contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "R&emove channel" ), this, SLOT( removeChannel() ) ); contextMenu->addSeparator(); } contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "Remove &unused channels" ), this, SLOT( removeUnusedChannels() ) ); contextMenu->exec( QCursor::pos() ); delete contextMenu; }
/*! \reimp */ void QScrollBar::contextMenuEvent(QContextMenuEvent *event) { if (!style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, 0, this)) { QAbstractSlider::contextMenuEvent(event); return ; } #ifndef QT_NO_MENU bool horiz = HORIZONTAL; QPointer<QMenu> menu = new QMenu(this); QAction *actScrollHere = menu->addAction(tr("Scroll here")); menu->addSeparator(); QAction *actScrollTop = menu->addAction(horiz ? tr("Left edge") : tr("Top")); QAction *actScrollBottom = menu->addAction(horiz ? tr("Right edge") : tr("Bottom")); menu->addSeparator(); QAction *actPageUp = menu->addAction(horiz ? tr("Page left") : tr("Page up")); QAction *actPageDn = menu->addAction(horiz ? tr("Page right") : tr("Page down")); menu->addSeparator(); QAction *actScrollUp = menu->addAction(horiz ? tr("Scroll left") : tr("Scroll up")); QAction *actScrollDn = menu->addAction(horiz ? tr("Scroll right") : tr("Scroll down")); QAction *actionSelected = menu->exec(event->globalPos()); delete menu; if (actionSelected == 0) /* do nothing */ ; else if (actionSelected == actScrollHere) setValue(d_func()->pixelPosToRangeValue(horiz ? event->pos().x() : event->pos().y())); else if (actionSelected == actScrollTop) triggerAction(QAbstractSlider::SliderToMinimum); else if (actionSelected == actScrollBottom) triggerAction(QAbstractSlider::SliderToMaximum); else if (actionSelected == actPageUp) triggerAction(QAbstractSlider::SliderPageStepSub); else if (actionSelected == actPageDn) triggerAction(QAbstractSlider::SliderPageStepAdd); else if (actionSelected == actScrollUp) triggerAction(QAbstractSlider::SliderSingleStepSub); else if (actionSelected == actScrollDn) triggerAction(QAbstractSlider::SliderSingleStepAdd); #endif // QT_NO_MENU }
void ControllerView::contextMenuEvent( QContextMenuEvent * ) { QPointer<captionMenu> contextMenu = new captionMenu( model()->displayName() ); contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "&Remove this plugin" ), this, SLOT( deleteController() ) ); contextMenu->addSeparator(); contextMenu->addAction( embed::getIconPixmap( "help" ), tr( "&Help" ), this, SLOT( displayHelp() ) ); contextMenu->exec( QCursor::pos() ); delete contextMenu; }
RecentFiles::RecentFiles(QPointer<MainWindow> mainWindow, QPointer<QMenu> menuRecent, QPointer<QAction> actionClearRecentMenu) : QObject(mainWindow), mainWindow(mainWindow), menuRecent(menuRecent) { menuRecent->connect(menuRecent, &QMenu::aboutToShow, this, &RecentFiles::updateActions); for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActs[i] = menuRecent->addAction(QString(), this, &RecentFiles::recentFileActionTriggered); recentFileActs[i]->setVisible(false); } menuRecent->addSeparator(); menuRecent->addAction(actionClearRecentMenu); menuRecent->setEnabled(this->empty()); }
void KUrlNavigator::Private::openPathSelectorMenu() { if (m_navButtons.count() <= 0) { return; } const KUrl firstVisibleUrl = m_navButtons.first()->url(); QString spacer; QPointer<KMenu> popup = new KMenu(q); popup->setLayoutDirection(Qt::LeftToRight); const QString placePath = retrievePlacePath(); int idx = placePath.count(QLatin1Char('/')); // idx points to the first directory // after the place path const QString path = m_history[m_historyIndex].url.pathOrUrl(); QString dirName = path.section(QLatin1Char('/'), idx, idx); if (dirName.isEmpty()) { dirName = QLatin1Char('/'); } do { const QString text = spacer + dirName; QAction* action = new QAction(text, popup); const KUrl currentUrl = buttonUrl(idx); if (currentUrl == firstVisibleUrl) { popup->addSeparator(); } action->setData(QVariant(currentUrl.prettyUrl())); popup->addAction(action); ++idx; spacer.append(" "); dirName = path.section('/', idx, idx); } while (!dirName.isEmpty()); const QPoint pos = q->mapToGlobal(m_dropDownButton->geometry().bottomRight()); const QAction* activatedAction = popup->exec(pos); if (activatedAction != 0) { const KUrl url = KUrl(activatedAction->data().toString()); q->setLocationUrl(url); } // Delete the menu, unless it has been deleted in its own nested event loop already. if (popup) { popup->deleteLater(); } }
void FxLineLcdSpinBox::contextMenuEvent(QContextMenuEvent* event) { // for the case, the user clicked right while pressing left mouse- // button, the context-menu appears while mouse-cursor is still hidden // and it isn't shown again until user does something which causes // an QApplication::restoreOverrideCursor()-call... mouseReleaseEvent(nullptr); QPointer<CaptionMenu> contextMenu = new CaptionMenu(model()->displayName(), this); if (QMenu *fxMenu = m_tv->createFxMenu( tr("Assign to:"), tr("New FX Channel"))) { contextMenu->addMenu(fxMenu); contextMenu->addSeparator(); } addDefaultActions(contextMenu); contextMenu->exec(QCursor::pos()); }
virtual void contextMenuEvent( QContextMenuEvent* event ) { // for the case, the user clicked right while pressing left mouse- // button, the context-menu appears while mouse-cursor is still hidden // and it isn't shown again until user does something which causes // an QApplication::restoreOverrideCursor()-call... mouseReleaseEvent( NULL ); QPointer<CaptionMenu> contextMenu = new CaptionMenu( model()->displayName(), this ); // This condition is here just as a safety check, fxLineLcdSpinBox is aways // created inside a TabWidget inside an InstrumentTrackWindow if ( InstrumentTrackWindow* window = dynamic_cast<InstrumentTrackWindow*>( (QWidget *)this->parent()->parent() ) ) { QMenu *fxMenu = window->instrumentTrackView()->createFxMenu( tr( "Assign to:" ), tr( "New FX Channel" ) ); contextMenu->addMenu( fxMenu ); contextMenu->addSeparator(); } addDefaultActions( contextMenu ); contextMenu->exec( QCursor::pos() ); }
void CustomWebView::contextMenuEvent (QGraphicsSceneContextMenuEvent *e) { QPointer<QMenu> menu (new QMenu ()); QWebHitTestResult r = page ()-> mainFrame ()->hitTestContent (e->pos ().toPoint ()); IHookProxy_ptr proxy (new Util::DefaultHookProxy ()); emit hookWebViewContextMenu (proxy, this, e, r, menu, WVSStart); if (!r.linkUrl ().isEmpty ()) { QUrl url = r.linkUrl (); QString text = r.linkText (); if (XmlSettingsManager::Instance ()-> property ("TryToDetectRSSLinks").toBool ()) { bool hasAtom = text.contains ("Atom"); bool hasRSS = text.contains ("RSS"); if (hasAtom || hasRSS) { LeechCraft::Entity e; if (hasAtom) { e.Additional_ ["UserVisibleName"] = "Atom"; e.Mime_ = "application/atom+xml"; } else { e.Additional_ ["UserVisibleName"] = "RSS"; e.Mime_ = "application/rss+xml"; } e.Entity_ = url; e.Parameters_ = LeechCraft::FromUserInitiated | LeechCraft::OnlyHandle; bool ch = false; emit couldHandle (e, &ch); if (ch) { QList<QVariant> datalist; datalist << url << e.Mime_; menu->addAction (tr ("Subscribe"), this, SLOT (subscribeToLink ()))->setData (datalist); menu->addSeparator (); } } } menu->addAction (tr ("Open &here"), this, SLOT (openLinkHere ()))->setData (url); menu->addAction (tr ("Open in new &tab"), this, SLOT (openLinkInNewTab ()))->setData (url); menu->addSeparator (); menu->addAction (tr ("&Save link..."), this, SLOT (saveLink ())); QList<QVariant> datalist; datalist << url << text; menu->addAction (tr ("&Bookmark link..."), this, SLOT (bookmarkLink ()))->setData (datalist); menu->addSeparator (); if (!page ()->selectedText ().isEmpty ()) menu->addAction (pageAction (QWebPage::Copy)); menu->addAction (tr ("&Copy link"), this, SLOT (copyLink ())); if (page ()->settings ()->testAttribute (QWebSettings::DeveloperExtrasEnabled)) menu->addAction (pageAction (QWebPage::InspectElement)); } else if (page ()->selectedText ().contains (UrlInText)) { menu->addAction (tr ("Open as link"), this, SLOT (openLinkInNewTab ()))-> setData (page ()->selectedText ()); } emit hookWebViewContextMenu (proxy, this, e, r, menu, WVSAfterLink); if (!r.imageUrl ().isEmpty ()) { if (!menu->isEmpty ()) menu->addSeparator (); menu->addAction (tr ("Open image here"), this, SLOT (openImageHere ()))->setData (r.imageUrl ()); menu->addAction (tr ("Open image in new tab"), this, SLOT (openImageInNewTab ())); menu->addSeparator (); menu->addAction (tr ("Save image..."), this, SLOT (saveImage ())); QAction *spx = menu->addAction (tr ("Save pixmap..."), this, SLOT (savePixmap ())); spx->setToolTip (tr ("Saves the rendered pixmap without redownloading.")); spx->setProperty ("Poshuku/OrigPX", r.pixmap ()); spx->setProperty ("Poshuku/OrigURL", r.imageUrl ()); menu->addAction (tr ("Copy image"), this, SLOT (copyImage ())); menu->addAction (tr ("Copy image location"), this, SLOT (copyImageLocation ()))->setData (r.imageUrl ()); } emit hookWebViewContextMenu (proxy, this, e, r, menu, WVSAfterImage); bool hasSelected = !page ()->selectedText ().isEmpty (); if (hasSelected) { if (!menu->isEmpty ()) menu->addSeparator (); menu->addAction (pageAction (QWebPage::Copy)); } if (r.isContentEditable ()) menu->addAction (pageAction (QWebPage::Paste)); if (hasSelected) { Browser_->Find_->setData (page ()->selectedText ()); menu->addAction (Browser_->Find_); menu->addAction (tr ("Search..."), this, SLOT (searchSelectedText ())); } emit hookWebViewContextMenu (proxy, this, e, r, menu, WVSAfterSelectedText); if (menu->isEmpty ()) menu = page ()->createStandardContextMenu (); if (!menu->isEmpty ()) menu->addSeparator (); menu->addAction (Browser_->Add2Favorites_); menu->addSeparator (); menu->addAction (Browser_->Print_); menu->addAction (Browser_->PrintPreview_); menu->addSeparator (); menu->addAction (Browser_->ViewSources_); menu->addAction (Browser_->SavePage_); menu->addSeparator (); menu->addAction (pageAction (QWebPage::ReloadAndBypassCache)); menu->addAction (Browser_->ReloadPeriodically_); menu->addAction (Browser_->NotifyWhenFinished_); menu->addSeparator (); menu->addAction (Browser_->ChangeEncoding_->menuAction ()); emit hookWebViewContextMenu (proxy, this, e, r, menu, WVSAfterFinish); if (!menu->isEmpty ()) menu->exec (Browser_->GetGraphicsView ()->viewport ()-> mapToGlobal (e->pos ().toPoint ())); else QGraphicsWebView::contextMenuEvent (e); if (menu) delete menu; }
void KUrlNavigator::Private::openContextMenu() { q->setActive(true); QPointer<KMenu> popup = new KMenu(q); // provide 'Copy' action, which copies the current URL of // the URL navigator into the clipboard QAction* copyAction = popup->addAction(KIcon("edit-copy"), i18n("Copy")); // provide 'Paste' action, which copies the current clipboard text // into the URL navigator QAction* pasteAction = popup->addAction(KIcon("edit-paste"), i18n("Paste")); QClipboard* clipboard = QApplication::clipboard(); pasteAction->setEnabled(!clipboard->text().isEmpty()); popup->addSeparator(); // provide radiobuttons for toggling between the edit and the navigation mode QAction* editAction = popup->addAction(i18n("Edit")); editAction->setCheckable(true); QAction* navigateAction = popup->addAction(i18n("Navigate")); navigateAction->setCheckable(true); QActionGroup* modeGroup = new QActionGroup(popup); modeGroup->addAction(editAction); modeGroup->addAction(navigateAction); if (q->isUrlEditable()) { editAction->setChecked(true); } else { navigateAction->setChecked(true); } popup->addSeparator(); // allow showing of the full path QAction* showFullPathAction = popup->addAction(i18n("Show Full Path")); showFullPathAction->setCheckable(true); showFullPathAction->setChecked(q->showFullPath()); QAction* activatedAction = popup->exec(QCursor::pos()); if (activatedAction == copyAction) { QMimeData* mimeData = new QMimeData(); mimeData->setText(q->locationUrl().pathOrUrl()); clipboard->setMimeData(mimeData); } else if (activatedAction == pasteAction) { q->setLocationUrl(KUrl(clipboard->text())); } else if (activatedAction == editAction) { q->setUrlEditable(true); } else if (activatedAction == navigateAction) { q->setUrlEditable(false); } else if (activatedAction == showFullPathAction) { q->setShowFullPath(showFullPathAction->isChecked()); } // Delete the menu, unless it has been deleted in its own nested event loop already. if (popup) { popup->deleteLater(); } }