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 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 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 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 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; }
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 VcsChangesView::popupContextMenu( const QPoint &pos ) { KUrl::List urls; QList<IProject*> projects; QModelIndexList selectionIdxs = selectedIndexes(); if(selectionIdxs.isEmpty()) return; foreach(const QModelIndex& idx, selectionIdxs) { if(idx.column()==0) { if(idx.parent().isValid()) urls += idx.data(KDevelop::VcsFileChangesModel::VcsStatusInfoRole).value<VcsStatusInfo>().url(); else projects += ICore::self()->projectController()->findProjectByName(idx.data().toString()); } } QPointer<KMenu> menu = new KMenu; QAction* refreshAction = menu->addAction(KIcon("view-refresh"), i18n("Refresh")); QList<ContextMenuExtension> extensions; if(!urls.isEmpty()) { KDevelop::FileContext context(urls); extensions = ICore::self()->pluginController()->queryPluginsForContextMenuExtensions( &context ); } else { QList<ProjectBaseItem*> items; foreach(IProject* p, projects) items += p->projectItem(); KDevelop::ProjectItemContext context(items); extensions = ICore::self()->pluginController()->queryPluginsForContextMenuExtensions( &context ); } QList<QAction*> buildActions; QList<QAction*> vcsActions; QList<QAction*> extActions; QList<QAction*> projectActions; QList<QAction*> fileActions; QList<QAction*> runActions; foreach( const ContextMenuExtension& ext, extensions ) { buildActions += ext.actions(ContextMenuExtension::BuildGroup); fileActions += ext.actions(ContextMenuExtension::FileGroup); projectActions += ext.actions(ContextMenuExtension::ProjectGroup); vcsActions += ext.actions(ContextMenuExtension::VcsGroup); extActions += ext.actions(ContextMenuExtension::ExtensionGroup); runActions += ext.actions(ContextMenuExtension::RunGroup); }
void ArticleListView::showHeaderMenu(const QPoint& pos) { if ( !model() ) return; QPointer<KMenu> menu = new KMenu( this ); menu->addTitle( i18n( "Columns" ) ); menu->setAttribute( Qt::WA_DeleteOnClose ); const int colCount = model()->columnCount(); int visibleColumns = 0; // number of column currently shown QAction *visibleColumnsAction = 0; for ( int i = 0; i < colCount; ++i ) { QAction* act = menu->addAction( model()->headerData( i, Qt::Horizontal ).toString() ); act->setCheckable( true ); act->setData( i ); bool sectionVisible = !header()->isSectionHidden( i ); act->setChecked( sectionVisible ); if ( sectionVisible ) { ++visibleColumns; visibleColumnsAction = act; } } // Avoid that the last shown column is also hidden if ( visibleColumns == 1 ) { visibleColumnsAction->setEnabled( false ); } QPointer<QObject> that( this ); QAction * const action = menu->exec( header()->mapToGlobal( pos ) ); if ( that && action ) { const int col = action->data().toInt(); if ( action->isChecked() ) header()->showSection( col ); else header()->hideSection( col ); } delete menu; }
/*! \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 Akregator::SubscriptionListView::showHeaderMenu( const QPoint& pos ) { if( ! model() ) return; QPointer<KMenu> menu = new KMenu( this ); menu->addTitle( i18n( "Columns" ) ); menu->setAttribute( Qt::WA_DeleteOnClose ); connect(menu, SIGNAL( triggered( QAction* ) ), this, SLOT( headerMenuItemTriggered( QAction* ) ) ); for (int i = 0; i < model()->columnCount(); i++) { if ( SubscriptionListModel::TitleColumn == i ) { continue; } QString col = model()->headerData( i, Qt::Horizontal, Qt::DisplayRole ).toString(); QAction* act = menu->addAction( col ); act->setCheckable( true ); act->setChecked( !header()->isSectionHidden( i ) ); act->setData( i ); } menu->popup( header()->mapToGlobal( 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 QToolButtonPrivate::popupTimerDone() { Q_Q(QToolButton); popupTimer.stop(); if (!menuButtonDown && !down) return; menuButtonDown = true; QPointer<QMenu> actualMenu; bool mustDeleteActualMenu = false; if(menuAction) { actualMenu = menuAction->menu(); } else if (defaultAction && defaultAction->menu()) { actualMenu = defaultAction->menu(); } else { actualMenu = new QMenu(q); mustDeleteActualMenu = true; for(int i = 0; i < actions.size(); i++) actualMenu->addAction(actions.at(i)); } repeat = q->autoRepeat(); q->setAutoRepeat(false); bool horizontal = true; #if !defined(QT_NO_TOOLBAR) QToolBar *tb = qobject_cast<QToolBar*>(parent); if (tb && tb->orientation() == Qt::Vertical) horizontal = false; #endif QPoint p; QRect screen = QApplication::desktop()->availableGeometry(q); QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint(); QRect rect = q->rect(); if (horizontal) { if (q->isRightToLeft()) { if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) { p = q->mapToGlobal(rect.bottomRight()); } else { p = q->mapToGlobal(rect.topRight() - QPoint(0, sh.height())); } p.rx() -= sh.width(); } else { if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) { p = q->mapToGlobal(rect.bottomLeft()); } else { p = q->mapToGlobal(rect.topLeft() - QPoint(0, sh.height())); } } } else { if (q->isRightToLeft()) { if (q->mapToGlobal(QPoint(rect.left(), 0)).x() - sh.width() <= screen.x()) { p = q->mapToGlobal(rect.topRight()); } else { p = q->mapToGlobal(rect.topLeft()); p.rx() -= sh.width(); } } else { if (q->mapToGlobal(QPoint(rect.right(), 0)).x() + sh.width() <= screen.right()) { p = q->mapToGlobal(rect.topRight()); } else { p = q->mapToGlobal(rect.topLeft() - QPoint(sh.width(), 0)); } } } p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width())); p.ry() += 1; QPointer<QToolButton> that = q; actualMenu->setNoReplayFor(q); if (!mustDeleteActualMenu) //only if action are not in this widget QObject::connect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*))); QObject::connect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown())); actualMenu->d_func()->causedPopup.widget = q; actualMenu->d_func()->causedPopup.action = defaultAction; actionsCopy = q->actions(); //(the list of action may be modified in slots) actualMenu->exec(p); QObject::disconnect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown())); if (mustDeleteActualMenu) delete actualMenu; else QObject::disconnect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*))); if (!that) return; actionsCopy.clear(); if (repeat) q->setAutoRepeat(true); }
//Init the dialog void QxMainWindow::initDialog() { // Menu QPointer<QMenu> pFileMenu = menuBar()->addMenu("File"); QPointer<QMenu> pViewMenu = menuBar()->addMenu("View"); QPointer<QMenu> pHelpMenu = menuBar()->addMenu("Help"); m_pOpenAction = pFileMenu->addAction("Open"); m_pDecodeAction = pFileMenu->addAction("Decode Selected"); m_pDecodeAllAction = pFileMenu->addAction("Decode All"); m_pRemoveAction = pFileMenu->addAction("Remove Selected"); m_pClearListAction = pFileMenu->addAction("Remove All"); m_pHidePreviewAction = pViewMenu->addAction("Hide Preview"); m_pAboutAction = pHelpMenu->addAction("About gntDecoder"); m_pOpenAction->setIcon(QIcon(":/Resources/open.ico")); m_pDecodeAllAction->setIcon(QIcon(":/Resources/save_all.ico")); m_pAboutAction->setIcon(QIcon(":/Resources/about.ico")); m_pDecodeAction->setIcon(QIcon(":/Resources/save.png")); m_pRemoveAction->setIcon(QIcon(":/Resources/remove.ico")); m_pClearListAction->setIcon(QIcon(":/Resources/clear.ico")); m_pHidePreviewAction->setIcon(QIcon(":/Resources/hide.png")); m_pOpenAction->setToolTip("Add .gnt files to file list"); m_pDecodeAction->setToolTip("Decode selected file"); m_pDecodeAllAction->setToolTip("Decode all files in the file list"); m_pRemoveAction->setToolTip("Remove selected file from file list(Do nothing with local files)"); m_pClearListAction->setToolTip("Clear file list(Do nothing with local files)"); m_pHidePreviewAction->setToolTip("Hide preview image"); // Toolbar m_pToolBar = new QToolBar; addToolBar(m_pToolBar); m_pToolBar->addAction(m_pOpenAction); m_pToolBar->addAction(m_pDecodeAction); m_pToolBar->addAction(m_pDecodeAllAction); m_pToolBar->addAction(m_pRemoveAction); m_pToolBar->addAction(m_pClearListAction); m_pToolBar->addAction(m_pHidePreviewAction); // window widgets m_pFileListWidget = new QListWidget; m_pPreviewLabel = new QLabel; m_pPreviewLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QPointer<QSplitter> pSplitter = new QSplitter(Qt::Horizontal); pSplitter->addWidget(m_pFileListWidget); pSplitter->addWidget(m_pPreviewLabel); // window style setCentralWidget(pSplitter); setWindowFlags(windowFlags() & ~Qt::WindowMinMaxButtonsHint); // connect signals/slots connect(m_pOpenAction.data(), &QAction::triggered, this, &QxMainWindow::setFileList); connect(m_pDecodeAction.data(), &QAction::triggered, this, &QxMainWindow::decodeSelected); connect(m_pDecodeAllAction.data(), &QAction::triggered, this, &QxMainWindow::decodeAll); connect(m_pClearListAction.data(), &QAction::triggered, this, &QxMainWindow::clearFileList); connect(m_pRemoveAction.data(), &QAction::triggered, this, &QxMainWindow::removeSelectedFile); connect(m_pHidePreviewAction.data(), &QAction::triggered, this, &QxMainWindow::closePreview); connect(m_pFileListWidget.data(), &QListWidget::itemSelectionChanged, this, &QxMainWindow::preview); connect(m_pAboutAction.data(), &QAction::triggered, this, &QxMainWindow::showAboutDialog); }
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(); } }