void Configuration::setServiceMenu() { KMenu *menu = qobject_cast<KMenu*>(sender()); if (menu->actions().count() > 1) { return; } KServiceGroup::Ptr rootGroup = KServiceGroup::group(menu->actions()[0]->data().toString()); if (!rootGroup || !rootGroup->isValid() || rootGroup->noDisplay()) { return; } KServiceGroup::List list = rootGroup->entries(true, true, true, true); QAction *action = menu->addAction(KIcon("list-add"), i18n("Add This Menu")); action->setData(rootGroup->relPath()); menu->addSeparator(); for (int i = 0; i < list.count(); ++i) { if (list.at(i)->isType(KST_KService)) { const KService::Ptr service = KService::Ptr::staticCast(list.at(i)); action = menu->addAction(KIcon(service->icon()), service->name()); action->setEnabled(false); } else if (list.at(i)->isType(KST_KServiceGroup)) { const KServiceGroup::Ptr group = KServiceGroup::Ptr::staticCast(list.at(i)); if (group->noDisplay() || group->childCount() == 0) { continue; } KMenu *subMenu = new KMenu(menu); QAction *action = subMenu->addAction(QString()); action->setData(group->relPath()); action->setVisible(false); action = menu->addAction(KIcon(group->icon()), group->caption()); action->setMenu(subMenu); connect(subMenu, SIGNAL(aboutToShow()), this, SLOT(setServiceMenu())); } else if (list.at(i)->isType(KST_KServiceSeparator)) { menu->addSeparator(); } } }
void KUI_project::setupMenuFile() { KMenu *fileMenu = new KMenu(i18n("&File"),this); KAction *action = KStandardAction::openNew(this, SLOT(newProjectDialogSlot()), collection); fileMenu->addAction(collection->addAction("new_file", action)); fileMenu->addSeparator(); action = KStandardAction::open(this, SLOT(openFileSlot()), collection); fileMenu->addAction(collection->addAction("open_file", action)); action = KStandardAction::save(this, SLOT(saveFileSlot()), collection); action->setEnabled(false); //fileMenu->addAction(collection->addAction("save_file", action)); action = KStandardAction::saveAs(this, SLOT(saveAsFileSlot()), collection); action->setEnabled(false); //fileMenu->addAction(collection->addAction("save_as_file", action)); fileMenu->addSeparator(); action = KStandardAction::quit(this, SLOT(close()), collection); fileMenu->addAction(collection->addAction("quit", action)); menuBar->addMenu(fileMenu); }
void ActionWidget::slotContextMenu( K3ListView *, Q3ListViewItem *item, const QPoint& pos ) { if ( !item ) return; KMenu *menu = new KMenu; QAction* addCmd = menu->addAction( i18n("Add Command") ); QAction* rmCmd = menu->addAction( i18n("Remove Command") ); if ( !item->parent() ) {// no "command" item rmCmd->setEnabled( false ); item->setOpen( true ); } QAction* executed = menu->exec( pos ); if ( executed == addCmd ) { Q3ListViewItem *p = item->parent() ? item->parent() : item; Q3ListViewItem *cmdItem = new Q3ListViewItem( p, item, i18n("Click here to set the command to be executed"), i18n("<new command>") ); cmdItem->setPixmap( 0, SmallIcon( "exec" ) ); } else if ( executed == rmCmd ) delete item; delete menu; }
void Container::contextMenu( int currentTab, QPoint pos ) { KMenu menu; emit tabContextMenuRequested(viewForWidget(widget(currentTab)), &menu); menu.addSeparator(); QAction* closeTabAction = menu.addAction( KIcon("document-close"), i18n( "Close File" ) ); QAction* closeOtherTabsAction = menu.addAction( KIcon("document-close"), i18n( "Close Other Files" ) ); QAction* closeAllTabsAction = menu.addAction( KIcon("document-close"), i18n( "Close All Files" ) ); QAction* triggered = menu.exec(pos); if (triggered) { if ( triggered == closeTabAction ) { closeRequest(currentTab); } else if ( triggered == closeOtherTabsAction ) { // activate the remaining tab widgetActivated(currentTab); // first get the widgets to be closed since otherwise the indices will be wrong QList<QWidget*> otherTabs; for ( int i = 0; i < count(); ++i ) { if ( i != currentTab ) { otherTabs << widget(i); } } // finally close other tabs foreach( QWidget* tab, otherTabs ) { closeRequest(tab); } } else if ( triggered == closeAllTabsAction ) {
/** class Tray * Reimplementation of the KStatusNotifierItem class */ Tray::Tray(MainWindow * parent) : KStatusNotifierItem(parent) { // set up the context menu KMenu * cm = contextMenu(); cm->addAction( parent->actionCollection()->action("new_download") ); cm->addAction( parent->actionCollection()->action("import_links") ); cm->addSeparator(); cm->addAction( parent->actionCollection()->action("start_all_download") ); cm->addAction( parent->actionCollection()->action("stop_all_download") ); cm->addSeparator(); cm->addAction( parent->actionCollection()->action("konqueror_integration") ); cm->addAction( parent->actionCollection()->action("options_configure") ); // Set up basic tray parameters setCategory(ApplicationStatus); setIconByName("kget"); setTitle(i18n("KGet")); setContextMenu(cm); setAssociatedWidget(parent); setToolTipIconByName("kget"); setToolTipTitle(i18n("Download Manager")); // Not of much use atm, but maybe we want to set this later? // setToolTipSubTitle("[..]"); // filter middle mouse clicks to ask scheduler to paste URL connect( this, SIGNAL(secondaryActivateRequested(QPoint)), this, SLOT(slotActivated()) ); }
void SxEditor::on_editor_contextMenu( QMenu* menu, bool *pbContinue ) { KMenu *pMenu = qobject_cast<KMenu*>(menu); { QAction *action = pMenu->addAction("粗体", this, SLOT(on_common_command_clicked())); action->setObjectName("bold"); } { QAction *action = pMenu->addAction("斜体", this, SLOT(on_common_command_clicked())); action->setObjectName("italic"); } { QAction *action = pMenu->addAction("下划线", this, SLOT(on_common_command_clicked())); action->setObjectName("underline"); } { QAction *action = pMenu->addAction("删除线", this, SLOT(on_common_command_clicked())); action->setObjectName("throughout"); } { QAction *action = menu->addSeparator(); } { QAction *action = menu->addAction("选择全部", this, SLOT(on_common_command_clicked())); action->setObjectName("selectAll"); } { QAction *action = menu->addAction("粘贴", this, SLOT(on_common_command_clicked())); bool bEnable = false; QClipboard *clipboard = QApplication::clipboard(); if(clipboard ) { const QMimeData *mimedata = clipboard->mimeData(); if (mimedata->hasHtml() || mimedata->hasImage() || mimedata->hasText() || mimedata->hasUrls() || mimedata->hasFormat(KTextEditMime)) { bEnable = true; } } action->setEnabled(bEnable && !m_pTextEdit->isReadOnly()); action->setObjectName("paste"); } QTextCursor cursor = m_pTextEdit->textCursor(); bool hasText = !cursor.selection().isEmpty(); { QAction *action = menu->addAction("剪切", this, SLOT(on_common_command_clicked())); action->setEnabled(hasText && !m_pTextEdit->isReadOnly()); action->setObjectName("cut"); } { QAction *action = menu->addAction("复制", this, SLOT(on_common_command_clicked())); action->setEnabled(hasText); action->setObjectName("copy"); } *pbContinue = false; }
void Widget::themeMenuAboutToShow() { if ( !d->mStorageModel ) return; KMenu * menu = dynamic_cast< KMenu * >( sender() ); if ( !menu ) return; menu->clear(); menu->addTitle( i18n( "Theme" ) ); QActionGroup * grp = new QActionGroup( menu ); const QHash< QString, Theme * > & themes = Manager::instance()->themes(); QAction * act; QList< const Theme * > sortedThemes; for ( QHash< QString, Theme * >::ConstIterator ci = themes.constBegin(); ci != themes.constEnd(); ++ci ) { int idx = 0; int cnt = sortedThemes.count(); while ( idx < cnt ) { if ( sortedThemes.at( idx )->name() > ( *ci )->name() ) { sortedThemes.insert( idx, *ci ); break; } idx++; } if ( idx == cnt ) sortedThemes.append( *ci ); } for ( QList< const Theme * >::ConstIterator it = sortedThemes.constBegin(); it != sortedThemes.constEnd(); ++it ) { act = menu->addAction( ( *it )->name() ); act->setCheckable( true ); grp->addAction( act ); act->setChecked( d->mLastThemeId == ( *it )->id() ); act->setData( QVariant( ( *it )->id() ) ); connect( act, SIGNAL( triggered( bool ) ), SLOT( themeSelected( bool ) ) ); } menu->addSeparator(); act = menu->addAction( i18n( "Configure..." ) ); connect( act, SIGNAL( triggered( bool ) ), SLOT( configureThemes() ) ); }
DemoWidget() : QWidget() { menu = new KMenu("Popup Menu:"); menu->addAction( "Item1" ); menu->addAction( "Item2" ); menu->addSeparator(); QAction *a = new QAction( "Quit", this ); menu->addAction( a ); connect( a, SIGNAL(triggered()), qApp, SLOT(quit())); }
void TabBar::contextMenu(int tab, const QPoint &pos) { KActionMenu *closedTabsMenu = setupHistoryActions(); m_actualIndex = tab; KMenu menu; MainWindow *mainWindow = rApp->mainWindow(); menu.addAction(mainWindow->actionByName(QL1S("new_tab"))); menu.addAction(mainWindow->actionByName(QL1S("clone_tab"))); if (count() > 1) { menu.addAction(mainWindow->actionByName(QL1S("detach_tab"))); } menu.addAction(mainWindow->actionByName(QL1S("open_last_closed_tab"))); menu.addAction(closedTabsMenu); menu.addSeparator(); menu.addAction(mainWindow->actionByName(QL1S("close_tab"))); if (count() > 1) { menu.addAction(mainWindow->actionByName(QL1S("close_other_tabs"))); } menu.addSeparator(); menu.addAction(mainWindow->actionByName(QL1S("reload_tab"))); if (count() > 1) { menu.addAction(mainWindow->actionByName(QL1S("reload_all_tabs"))); } menu.exec(pos); }
void KUI_project::setupMenuSettings() { KMenu *settingsMenu = new KMenu(i18n("&Settings"),this); menuBar->addMenu(settingsMenu); KAction *action = KStandardAction::configureToolbars(this, SLOT(), collection); settingsMenu->addAction(collection->addAction("configure_toolbars", action)); action = KStandardAction::preferences(this, SLOT(), collection); settingsMenu->addAction(collection->addAction("configure_kui", action)); }
KMenu * ItemsViewDelegate::InstallMenu(const QToolButton* button, Entry::Status status) const { Q_UNUSED(button) KMenu * installMenu = new KMenu(NULL); QAction * action_install = installMenu->addAction(m_statusicons[Entry::Installed], i18n("Install")); QAction * action_uninstall = installMenu->addAction(m_statusicons[Entry::Deleted], i18n("Uninstall")); action_install->setData(DownloadDialog::kInstall); action_uninstall->setData(DownloadDialog::kUninstall); action_install->setVisible(status != Entry::Installed); action_uninstall->setVisible(status == Entry::Installed); return installMenu; }
KarbonLayerDocker::KarbonLayerDocker() : m_doc(0), m_model(0), m_updateTimer(this) { setWindowTitle(i18n("Layer view")); QWidget *mainWidget = new QWidget(this); QGridLayout* layout = new QGridLayout(mainWidget); layout->addWidget(m_layerView = new KoDocumentSectionView(mainWidget), 0, 0, 1, 6); QButtonGroup *buttonGroup = new QButtonGroup(mainWidget); buttonGroup->setExclusive(false); QPushButton *button = new QPushButton(mainWidget); button->setIcon(koIcon("list-add")); button->setToolTip(i18n("Add a new layer")); buttonGroup->addButton(button, Button_New); layout->addWidget(button, 1, 0); button = new QPushButton(mainWidget); button->setIcon(koIcon("list-remove")); button->setToolTip(i18n("Delete selected objects")); buttonGroup->addButton(button, Button_Delete); layout->addWidget(button, 1, 1); button = new QPushButton(mainWidget); button->setIcon(koIcon("go-up")); button->setToolTip(i18n("Raise selected objects")); buttonGroup->addButton(button, Button_Raise); layout->addWidget(button, 1, 2); button = new QPushButton(mainWidget); button->setIcon(koIcon("go-down")); button->setToolTip(i18n("Lower selected objects")); buttonGroup->addButton(button, Button_Lower); layout->addWidget(button, 1, 3); QToolButton * toolButton = new QToolButton(mainWidget); KMenu * menu = new KMenu(this); QActionGroup *group = new QActionGroup(this); m_viewModeActions.insert(KoDocumentSectionView::MinimalMode, menu->addAction(koIcon("view-list-text"), i18n("Minimal View"), this, SLOT(minimalView()))); m_viewModeActions.insert(KoDocumentSectionView::DetailedMode, menu->addAction(koIcon("view-list-details"), i18n("Detailed View"), this, SLOT(detailedView()))); m_viewModeActions.insert(KoDocumentSectionView::ThumbnailMode, menu->addAction(koIcon("view-preview"), i18n("Thumbnail View"), this, SLOT(thumbnailView()))); foreach(QAction* action, m_viewModeActions) { action->setCheckable(true); action->setActionGroup(group); }
void kMyMoneyCalendar::init(const QDate &dt) { styleControl = new QPushButton(i18n("Select Style"), this); yearForward = new QToolButton(this); yearBackward = new QToolButton(this); monthForward = new QToolButton(this); monthBackward = new QToolButton(this); selectMonth = new QToolButton(this); selectYear = new QToolButton(this); line = new KLineEdit(this); val = new KDateValidator(this); fontsize = 10; d->selectWeek = new QToolButton(this); KMenu* kpopupmenuNew = new KMenu(this); kpopupmenuNew->addAction(i18n("Week"), this, SLOT(slotSetStyleWeekly())); kpopupmenuNew->addAction(i18n("Month"), this, SLOT(slotSetStyleMonthly())); styleControl->setMenu(kpopupmenuNew); styleControl->setToolTip(i18n("Choose Style")); yearForward->setToolTip(i18n("Next year")); yearBackward->setToolTip(i18n("Previous year")); monthForward->setToolTip(i18n("Next month")); monthBackward->setToolTip(i18n("Previous month")); d->selectWeek->setToolTip(i18n("Select a week")); selectMonth->setToolTip(i18n("Select a month")); selectYear->setToolTip(i18n("Select a year")); // ----- setFontSize(10); line->setValidator(val); line->installEventFilter(this); yearForward->setIcon(QIcon(BarIcon("arrow-right-double"))); yearBackward->setIcon(QIcon(BarIcon("arrow-left-double"))); monthForward->setIcon(QIcon(BarIcon("arrow-right"))); monthBackward->setIcon(QIcon(BarIcon("arrow-left"))); setDate(dt); // set button texts connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); connect(d->selectWeek, SIGNAL(clicked()), SLOT(selectWeekClicked())); connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); if (table) table->setFocus(); }
void ArchiveMailWidget::customContextMenuRequested(const QPoint&) { const QList<QTreeWidgetItem *> listItems = mWidget->treeWidget->selectedItems(); KMenu menu; menu.addAction(i18n("Add..."),this,SLOT(slotAddItem())); if( !listItems.isEmpty() ) { if( listItems.count() == 1) { menu.addAction(i18n("Open Containing Folder..."),this,SLOT(slotOpenFolder())); } menu.addSeparator(); menu.addAction(i18n("Delete"),this,SLOT(slotRemoveItem())); } menu.exec(QCursor::pos()); }
void DockContainer::popupMenu(QPoint p) { KMenu *pm = new KMenu(this); QAction *kill = pm->addAction( i18n("Kill This Applet")); QAction *change = pm->addAction( i18n("Change Command")); QAction *r = pm->exec(p); /* pm is destroyed now .. if it is destroyed later, there is a risk that kill() double-frees it */ delete pm; if (r == kill) this->kill(); if (r == change) askNewCommand(false); }
/****************************************************************************** * Called when the New From Template action is clicked. * Creates a popup menu listing all alarm templates, in sorted name order. */ void TemplateMenuAction::slotInitMenu() { KMenu* m = menu(); m->clear(); mOriginalTexts.clear(); // Compile a sorted list of template names int i, end; QStringList sorted; KAEvent::List templates = KAlarm::templateList(); for (i = 0, end = templates.count(); i < end; ++i) { QString name = templates[i]->templateName(); int j = 0; for (int jend = sorted.count(); j < jend && QString::localeAwareCompare(name, sorted[j]) > 0; ++j) ; sorted.insert(j, name); } for (i = 0, end = sorted.count(); i < end; ++i) { QAction* act = m->addAction(sorted[i]); mOriginalTexts[act] = sorted[i]; // keep original text, since action text has shortcuts added } }
ComponentWidget::ComponentWidget(QWidget *parent, Clock *clock) : QWidget(parent), m_clock(clock), m_component(InvalidComponent) { m_componentUi.setupUi(this); KMenu *menu = new KMenu(m_componentUi.componentButton); for (int i = 1; i < LastComponent; ++i) { QAction *action = new QAction(Clock::getComponentName(static_cast<ClockComponent>(i)), this); action->setData(i); menu->addAction(action); } m_componentUi.componentButton->setMenu(menu); m_componentUi.optionsButton->setMenu(new KMenu(m_componentUi.optionsButton)); if (!parent) { m_componentUi.insertButton->hide(); m_componentUi.verticalLayout->addWidget(m_componentUi.previewLabel); } connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(selectComponent(QAction*))); connect(m_componentUi.insertButton, SIGNAL(clicked()), this, SLOT(insertComponent())); }
void OpmlDirectoryView::contextMenuEvent( QContextMenuEvent *event ) { QModelIndex idx = indexAt( event->pos() ); debug() << idx; event->accept(); QVariant data = model()->data( idx, OpmlDirectoryModel::ActionRole ); QActionList actions = data.value<QActionList>(); if( actions.isEmpty() ) { return; } KMenu menu; foreach( QAction *action, actions ) { if( action ) menu.addAction( action ); } menu.exec( mapToGlobal( event->pos() ) ); //We keep the items that the actions need to be applied to in the actions private data. //Clear the data from all actions now that the context menu has executed. foreach( QAction *action, actions ) action->setData( QVariant() ); }
void PlaylistBrowserNS::PlaylistBrowserView::contextMenuEvent( QContextMenuEvent *event ) { QModelIndex clickedIdx = indexAt( event->pos() ); QModelIndexList indices; if( clickedIdx.isValid() && selectedIndexes().contains( clickedIdx ) ) indices << selectedIndexes(); else if( clickedIdx.isValid() ) indices << clickedIdx; QActionList actions = actionsFor( indices ); if( actions.isEmpty() ) { resetActionTargets(); return; } KMenu menu; foreach( QAction *action, actions ) menu.addAction( action ); menu.exec( mapToGlobal( event->pos() ) ); // We keep the items that the action need to be applied to. // Clear the data from all actions now that the context menu has executed. resetActionTargets(); }
KisPaintOpPresetsChooserPopup::KisPaintOpPresetsChooserPopup(QWidget * parent) : QWidget(parent) , m_d(new Private()) { m_d->uiWdgPaintOpPresets.setupUi(this); KMenu* menu = new KMenu(this); QActionGroup *actionGroup = new QActionGroup(this); KisPresetChooser::ViewMode mode = (KisPresetChooser::ViewMode)KisConfig().presetChooserViewMode(); bool showAll = KisConfig().presetShowAllMode(); QAction* action = menu->addAction(koIcon("view-preview"), i18n("Thumbnails"), this, SLOT(slotThumbnailMode())); action->setCheckable(true); action->setChecked(mode == KisPresetChooser::THUMBNAIL); action->setActionGroup(actionGroup); action = menu->addAction(koIcon("view-list-details"), i18n("Details"), this, SLOT(slotDetailMode())); action->setCheckable(true); action->setChecked(mode == KisPresetChooser::DETAIL); action->setActionGroup(actionGroup); m_d->uiWdgPaintOpPresets.viewModeButton->setIcon(koIcon("view-choose")); m_d->uiWdgPaintOpPresets.viewModeButton->setMenu(menu); m_d->uiWdgPaintOpPresets.viewModeButton->setPopupMode(QToolButton::InstantPopup); m_d->uiWdgPaintOpPresets.wdgPresetChooser->setViewMode(mode); m_d->uiWdgPaintOpPresets.wdgPresetChooser->showTaggingBar(false,true); connect(m_d->uiWdgPaintOpPresets.wdgPresetChooser, SIGNAL(resourceSelected(KoResource*)), this, SIGNAL(resourceSelected(KoResource*))); connect(m_d->uiWdgPaintOpPresets.searchBar, SIGNAL(textChanged(QString)), m_d->uiWdgPaintOpPresets.wdgPresetChooser, SLOT(searchTextChanged(QString))); connect(m_d->uiWdgPaintOpPresets.searchBar, SIGNAL(textChanged(QString)), this, SLOT(setLineEditCompleter(QString))); connect(m_d->uiWdgPaintOpPresets.searchBar, SIGNAL(returnPressed(QString)), this, SLOT(returnKeyPressed(QString))); connect(m_d->uiWdgPaintOpPresets.showAllCheckBox, SIGNAL(toggled(bool)), m_d->uiWdgPaintOpPresets.wdgPresetChooser, SLOT(setShowAll(bool))); m_d->firstShown = true; m_d->uiWdgPaintOpPresets.showAllCheckBox->setChecked(showAll); }
void NepomukWidget::showTagContextMenu(const QString& tag) { m_currentTag = tag; KMenu *popup = new KMenu(this); if (m_nepHandler->tags().contains(tag)) { QAction *removeAction = popup->addAction(KIcon("list-remove"), i18n("Remove Tag")); connect(removeAction, SIGNAL(triggered()), SLOT(removeCurrentTag())); popup->popup(QCursor::pos()); } else { QAction *addAction = popup->addAction(KIcon("list-add"), i18n("Add Tag")); connect(addAction, SIGNAL(triggered()), SLOT(addCurrentTag())); popup->popup(QCursor::pos()); } }
void KUI_project::setupMenuWindow() { KMenu *windowMenu = new KMenu(i18n("&Window"),this); KAction *showDesktop = new KAction(i18n("Show &Desktop"),this); showDesktop->setCheckable(true); showDesktop->setChecked(true); //connect(showDesktop, SIGNAL(triggered(bool)), defaultCentral, SLOT(screenVis())); windowMenu->addAction(showDesktop); KAction *showCamera = new KAction(i18n("Show &Camera"),this); showCamera->setCheckable(true); showCamera->setChecked(true); windowMenu->addAction(showCamera); //connect(showCamera, SIGNAL(triggered(bool)), defaultCentral, SLOT(cameraVis())); menuBar->addMenu(windowMenu); }
void TodoView::contextMenuEvent(QContextMenuEvent *event) { QModelIndex index = currentIndex(); const QStandardItemModel *model = static_cast <const QStandardItemModel *> (index.model()); if (index.isValid() && model) { QString title = model->data(index, Qt::DisplayRole).toString(); KMenu *menu = new KMenu(title, this); /* if (model->data(index, TodoModel::PercentRole).toInt() < 100) { QAction *action = new QAction(i18n("Set task as completed ?"), this); action->setCheckable(true); action->setData(model->data(index, TodoModel::UIDRole).toString()); action->setObjectName(MARK_COMPLETE_ACTION_NAME); menu->addAction(action); menu->addSeparator(); } */ QAction editAction(i18n("Edit task"), this); editAction.setIcon(KIcon("document-edit")); editAction.setData(model->data(index, TodoModel::UIDRole).toString()); editAction.setObjectName(EDIT_ACTION_NAME); QAction viewAction(i18n("View task"), this); viewAction.setIcon(KIcon("view-task")); viewAction.setData(model->data(index, TodoModel::UIDRole).toString()); viewAction.setObjectName(OPEN_ACTION_NAME); QAction deleteAction(i18n("Delete task"), this); deleteAction.setIcon(KIcon("edit-delete")); deleteAction.setData(model->data(index, TodoModel::UIDRole).toString()); deleteAction.setObjectName(DELETE_ACTION_NAME); menu->addAction(&editAction); menu->addAction(&viewAction); menu->addAction(&deleteAction); connect(menu, SIGNAL(triggered(QAction *)), SLOT(slotActionClicked(QAction *))); menu->exec(event->globalPos()); } }
void AlbumsView::contextMenuEvent( QGraphicsSceneContextMenuEvent *event ) { KAction *appendAction = new KAction( KIcon( "media-track-add-amarok" ), i18n( "&Append to Playlist" ), this ); KAction *loadAction = new KAction( KIcon( "folder-open" ), i18nc( "Replace the currently loaded tracks with these", "&Load" ), this ); KAction *queueAction = new KAction( KIcon( "media-track-queue-amarok" ), i18n( "&Queue" ), this ); KAction *editAction = new KAction( KIcon( "media-track-edit-amarok" ), i18n( "Edit Track Details" ), this ); connect( appendAction, SIGNAL( triggered() ), this, SLOT( slotAppendSelected() ) ); connect( loadAction , SIGNAL( triggered() ), this, SLOT( slotPlaySelected() ) ); connect( queueAction , SIGNAL( triggered() ), this, SLOT( slotQueueSelected() ) ); connect( editAction , SIGNAL( triggered() ), this, SLOT( slotEditSelected() ) ); KMenu menu; menu.addAction( appendAction ); menu.addAction( loadAction ); menu.addAction( queueAction ); menu.addSeparator(); menu.addAction( editAction ); QModelIndex index = nativeWidget()->indexAt( event->pos().toPoint() ); if( index.isValid() ) { QStandardItem *item = static_cast<QStandardItemModel*>( model() )->itemFromIndex( index ); AlbumItem *album = dynamic_cast<AlbumItem*>(item); if( album ) { Meta::AlbumPtr albumPtr = album->album(); Meta::CustomActionsCapability *cac = albumPtr->create<Meta::CustomActionsCapability>(); if( cac ) { QList<PopupDropperAction *> actions = cac->customActions(); menu.addSeparator(); foreach( PopupDropperAction *action, actions ) menu.addAction( action ); } } } menu.exec( event->screenPos() ); }
void KTNEFMain::contextMenuEvent( QContextMenuEvent *event ) { QList<KTNEFAttach *> list = mView->getSelection(); if ( !list.count() ) { return; } QAction *view = 0; QAction *viewWith = 0; QAction *prop = 0; KMenu *menu = new KMenu(); if ( list.count() == 1 ) { view = menu->addAction( KIcon( "document-open" ), i18nc( "@action:inmenu", "View" ) ); viewWith = menu->addAction( i18nc( "@action:inmenu", "View With..." ) ); menu->addSeparator(); } QAction *extract = menu->addAction( i18nc( "@action:inmenu", "Extract" ) ); QAction *extractTo = menu->addAction( KIcon( "archive-extract" ), i18nc( "@action:inmenu", "Extract To..." ) ); if ( list.count() == 1 ) { menu->addSeparator(); prop = menu->addAction( KIcon( "document-properties" ), i18nc( "@action:inmenu", "Properties" ) ); } QAction *a = menu->exec( event->globalPos(), 0 ); if ( a ) { if ( a == view ) { viewFile(); } else if ( a == viewWith ) { viewFileAs(); } else if ( a == extract ) { extractFile(); } else if ( a == extractTo ) { extractFileTo(); } else if ( a == prop ) { propertiesFile(); } } delete menu; }
void HistoryPanel::contextMenuGroup(const QPoint &pos) { KMenu menu; KAction* action; action = new KAction(KIcon("tab-new"), i18n("Open Folder in Tabs"), this); connect(action, SIGNAL(triggered()), this, SLOT(openAll())); menu.addAction(action); menu.exec(panelTreeView()->mapToGlobal(pos)); }
void addActionToMenu(KMenu& popup, const char* name) { QAction* action = mActionCollection->action(name); if (!action) { kWarning() << "Unknown action" << name; return; } if (action->isEnabled()) { popup.addAction(action); } }
void PlayListTabBar::contextMenu(const QPoint& point){ // qDebug() << this << "contextMenu()"; int index=tabAt(point); KMenu menu; QAction *action; if(index!=-1){ action=menu.addAction(KIcon("edit-rename"), tr("Rename Playlist"), this, SLOT(renamePlayList())); action->setData(index); action=menu.addAction(KIcon("edit-clear-list"), tr("Clear Playlist"), this, SLOT(clearPlayList())); action->setData(index); action=menu.addAction(KIcon("dialog-close"), tr("Close Playlist"), this, SLOT(closePlayList())); action->setData(index); }else{ } menu.exec(QCursor::pos()); }
void TabBar::emptyAreaContextMenu(const QPoint &pos) { setupHistoryActions(); KMenu menu; MainWindow *mainWindow = Application::instance()->mainWindow(); menu.addAction(mainWindow->actionByName( QL1S("new_tab") )); menu.addAction(mainWindow->actionByName( QL1S("open_last_closed_tab") )); menu.addAction(mainWindow->actionByName( QL1S("closed_tab_menu") )); menu.addSeparator(); menu.addAction(mainWindow->actionByName( QL1S("reload_all_tabs") )); KToolBar *mainBar = mainWindow->toolBar("mainToolBar"); if(!mainBar->isVisible()) { menu.addAction( mainBar->toggleViewAction() ); } menu.exec(pos); }
void BlockAnalyzer::contextMenuEvent( QContextMenuEvent * ) { KMenu *menu = new KMenu( this ); menu->setTitle( i18n( "Framerate" ) ); QAction *a = menu->addAction( i18n("50 fps"), this, SLOT( set50fps() ) ); if( timeout() == 50 ) a->setChecked( true ); a = menu->addAction( i18n("33 fps"), this, SLOT( set33fps() ) ); if( timeout() == 33 ) a->setChecked( true ); a = menu->addAction( i18n("25 fps"), this, SLOT( set25fps() ) ); if( timeout() == 25 ) a->setChecked( true ); a = menu->addAction( i18n("20 fps"), this, SLOT( set20fps() ) ); if( timeout() == 20 ) a->setChecked( true ); a = menu->addAction( i18n("10 fps"), this, SLOT( set10fps() ) ); if( timeout() == 10 ) a->setChecked( true ); #if defined HAVE_LIBVISUAL menu->addSeparator(); menu->addAction( Amarok::actionCollection()->action( "visualizations" ) ); #endif menu->exec(); }