void VariablesListView::slotContextMenuRequested(QListViewItem* item, const QPoint& p, int) { // if(col != NameCol) return; enum { CopyVarItem, CopyValueItem }; KPopupMenu* menu = new KPopupMenu(this); menu->insertItem("Copy variable", CopyVarItem); menu->insertItem("Copy value", CopyValueItem); int selection = menu->exec(p); if(selection == -1) { delete menu; return; } QClipboard* clip = kapp->clipboard(); VariablesListViewItem* converted = dynamic_cast<VariablesListViewItem*>(item); switch(selection) { case CopyVarItem: clip->setText(converted->variable()->toString(), QClipboard::Clipboard); break; case CopyValueItem: clip->setText(converted->variable()->value()->toString(), QClipboard::Clipboard); break; } delete menu; }
void KSysTrayCmd::execContextMenu( const QPoint &pos ) { KPopupMenu *menu = new KPopupMenu(); menu->insertTitle( *pixmap(), i18n( "KSysTrayCmd" ) ); int hideShowId = menu->insertItem( isVisible ? i18n( "&Hide" ) : i18n( "&Restore" ) ); int undockId = menu->insertItem( SmallIcon("close"), i18n( "&Undock" ) ); int quitId = menu->insertItem( SmallIcon("exit"), i18n( "&Quit" ) ); int cmd = menu->exec( pos ); if ( cmd == quitId ) quitClient(); else if ( cmd == undockId ) quit(); else if ( cmd == hideShowId ) { if ( lazyStart && ( !hasRunningClient() ) ) { start(); isVisible=true; } else if ( quitOnHide && ( hasRunningClient() ) && isVisible ) { NETRootInfo ri( qt_xdisplay(), NET::CloseWindow ); ri.closeWindowRequest( win ); isVisible=false; } else toggleWindow(); } delete menu; }
void KstDataManagerI::contextMenu(QListViewItem *i, const QPoint& p, int col) { Q_UNUSED(col) KstObjectItem *koi = static_cast<KstObjectItem*>(i); KstBaseCurve *c; if (koi->rtti() == RTTI_OBJ_OBJECT || koi->rtti() == RTTI_OBJ_DATA_VECTOR) { KPopupMenu *m = new KPopupMenu(this); m->setTitle(koi->text(0)); int id = m->insertItem(i18n("&Edit..."), this, SLOT(edit_I())); //m->setItemEnabled(id, RTTI_OBJ_VECTOR != koi->rtti()); if (koi->rtti() == RTTI_OBJ_DATA_VECTOR) { id = m->insertItem(i18n("&Make Curve..."), koi, SLOT(makeCurve())); } else if ((c = dynamic_cast<KstBaseCurve*>(koi->dataObject().data()))) { KPopupMenu *addMenu = new KPopupMenu(this); KPopupMenu *removeMenu = new KPopupMenu(this); PlotMap.clear(); id = 100; bool haveAdd = false, haveRemove = false; for (KstPlot *p = KST::plotList.first(); p; p = KST::plotList.next()) { if (!p->Curves.contains(c)) { addMenu->insertItem(p->tagName(), koi, SLOT(addToPlot(int)), 0, id); haveAdd = true; } else {
void FavoriteFolderView::contextMenu(QListViewItem *item, const QPoint &point) { KMFolderTree *ft = mainWidget()->folderTree(); assert(ft); KMFolderTreeItem *fti = static_cast<KMFolderTreeItem *>(item); mContextMenuItem = fti; KPopupMenu contextMenu; if(fti && fti->folder()) { contextMenu.insertItem(SmallIconSet("editdelete"), i18n("Remove From Favorites"), this, SLOT(removeFolder())); contextMenu.insertItem(SmallIconSet("edit"), i18n("Rename Favorite"), this, SLOT(renameFolder())); contextMenu.insertSeparator(); mainWidget()->action("mark_all_as_read")->plug(&contextMenu); if(fti->folder()->folderType() == KMFolderTypeImap || fti->folder()->folderType() == KMFolderTypeCachedImap) mainWidget()->action("refresh_folder")->plug(&contextMenu); if(fti->folder()->isMailingListEnabled()) mainWidget()->action("post_message")->plug(&contextMenu); contextMenu.insertItem(SmallIconSet("configure_shortcuts"), i18n("&Assign Shortcut..."), fti, SLOT(assignShortcut())); contextMenu.insertItem(i18n("Expire..."), fti, SLOT(slotShowExpiryProperties())); mainWidget()->action("modify")->plug(&contextMenu); } else { contextMenu.insertItem(SmallIconSet("bookmark_add"), i18n("Add Favorite Folder..."), this, SLOT(addFolder())); } contextMenu.exec(point, 0); }
UIServerSystemTray(UIServer *uis) : KSystemTray(uis) { KPopupMenu *pop = contextMenu(); pop->insertItem(i18n("Settings..."), uis, SLOT(slotConfigure())); pop->insertItem(i18n("Remove"), uis, SLOT(slotRemoveSystemTrayIcon())); setPixmap(loadIcon("filesave")); // actionCollection()->action("file_quit")->setEnabled(true); KStdAction::quit(uis, SLOT(slotQuit()), actionCollection()); }
void ScriptManager::slotShowContextMenu( QListViewItem* item, const QPoint& pos ) { const bool isCategory = item == m_generalCategory || item == m_lyricsCategory || item == m_scoreCategory || item == m_transcodeCategory; if( !item || isCategory ) return; // Look up script entry in our map ScriptMap::Iterator it; ScriptMap::Iterator end( m_scripts.end() ); for( it = m_scripts.begin(); it != end; ++it ) if( it.data().li == item ) break; enum { SHOW_LOG, EDIT }; KPopupMenu menu; menu.insertTitle( i18n( "Debugging" ) ); menu.insertItem( SmallIconSet( amaroK::icon( "clock" ) ), i18n( "Show Output &Log" ), SHOW_LOG ); menu.insertItem( SmallIconSet( amaroK::icon( "edit" ) ), i18n( "&Edit" ), EDIT ); menu.setItemEnabled( SHOW_LOG, it.data().process ); const int id = menu.exec( pos ); switch( id ) { case EDIT: KRun::runCommand( "kwrite " + it.data().url.path() ); break; case SHOW_LOG: QString line; while( it.data().process->readln( line ) != -1 ) it.data().log += line; KTextEdit* editor = new KTextEdit( it.data().log ); kapp->setTopWidget( editor ); editor->setCaption( kapp->makeStdCaption( i18n( "Output Log for %1" ).arg( it.key() ) ) ); editor->setReadOnly( true ); QFont font( "fixed" ); font.setFixedPitch( true ); font.setStyleHint( QFont::TypeWriter ); editor->setFont( font ); editor->setTextFormat( QTextEdit::PlainText ); editor->resize( 500, 380 ); editor->show(); break; } }
//Credit to amaroK for this //Seems like it can become the next plugin to do since amarok is really cool (just missing plugin arch) bool SongList::eventFilter(QObject *o, QEvent *e ) { if(o == header() && e->type() == QEvent::MouseButtonPress && static_cast<QMouseEvent*>(e)->button() == Qt::RightButton ) { KPopupMenu popup; //popup.setFont(this->font()); popup.setCheckable(true); popup.insertTitle(i18n("Available Columns")); int colcount=columns(); for( int i = 0; i < colcount; ++i ) //columns() references a property { popup.insertItem(columnText(i),i,i+1 ); popup.setItemChecked(i,columnWidth(i)!=0); } int col = popup.exec( static_cast<QMouseEvent *>(e)->globalPos() ); if( col != -1 ) { //TODO can result in massively wide column appearing! if( columnWidth( col ) == 0 ) { adjustColumn( col ); header()->setResizeEnabled( true, col ); } else hideColumn( col ); } //determine first visible column again, since it has changed //eat event return TRUE; } return KListView::eventFilter(o,e); }
bool Sidebar::eventFilter(QObject *obj, QEvent *ev) { if (ev->type()==QEvent::ContextMenu) { QContextMenuEvent *e = (QContextMenuEvent *) ev; KMultiTabBarTab *bt = dynamic_cast<KMultiTabBarTab*>(obj); if (bt) { kdDebug()<<"Request for popup"<<endl; m_popupButton = bt->id(); ToolView *w = m_idToWidget[m_popupButton]; if (w) { KPopupMenu *p = new KPopupMenu (this); p->insertTitle(SmallIcon("view_remove"), i18n("Behavior"), 50); p->insertItem(w->persistent ? SmallIconSet("window_nofullscreen") : SmallIconSet("window_fullscreen"), w->persistent ? i18n("Make Non-Persistent") : i18n("Make Persistent"), 10); p->insertTitle(SmallIcon("move"), i18n("Move To"), 51); if (position() != 0) p->insertItem(SmallIconSet("back"), i18n("Left Sidebar"),0); if (position() != 1) p->insertItem(SmallIconSet("forward"), i18n("Right Sidebar"),1); if (position() != 2) p->insertItem(SmallIconSet("up"), i18n("Top Sidebar"),2); if (position() != 3) p->insertItem(SmallIconSet("down"), i18n("Bottom Sidebar"),3); connect(p, SIGNAL(activated(int)), this, SLOT(buttonPopupActivate(int))); p->exec(e->globalPos()); delete p; return true; } } }
ICNView::ICNView(ICNDocument *icnDocument, ViewContainer *viewContainer, uint viewAreaId, const char *name) : ItemView(icnDocument, viewContainer, viewAreaId, name) { bool manualRouting = (icnDocument->m_cmManager->cmState() & CMManager::cms_manual_route); KActionCollection * ac = actionCollection(); //BEGIN Routing Actions // These actions get inserted into the main menu m_pAutoRoutingAction = new KRadioAction(i18n("Automatic"), "", 0, this, SLOT(slotSetRoutingAuto()), ac, "routing_mode_auto"); m_pAutoRoutingAction->setExclusiveGroup("routing_mode"); if (!manualRouting) m_pAutoRoutingAction->setChecked(true); m_pManualRoutingAction = new KRadioAction(i18n("Manual"), "", 0, this, SLOT(slotSetRoutingManual()), ac, "routing_mode_manual"); m_pManualRoutingAction->setExclusiveGroup("routing_mode"); if (manualRouting) m_pManualRoutingAction->setChecked(true); // This popup gets inserted into the toolbar m_pRoutingModeToolbarPopup = new KToolBarPopupAction(i18n("Connection Routing Mode"), "pencil", 0, 0, 0, ac, "routing_mode"); m_pRoutingModeToolbarPopup->setDelayed(false); KPopupMenu *m = m_pRoutingModeToolbarPopup->popupMenu(); m->insertTitle(i18n("Connection Routing Mode")); m->insertItem(/*KGlobal::iconLoader()->loadIcon( "routing_mode_auto", KIcon::Small ), */i18n("Automatic"), 0); m->insertItem(/*KGlobal::iconLoader()->loadIcon( "routing_mode_manual", KIcon::Small ),*/ i18n("Manual"), 1); m->setCheckable(true); m->setItemChecked(manualRouting ? 1 : 0, true); connect(m, SIGNAL(activated(int)), this, SLOT(slotSetRoutingMode(int))); //END Routing Actions connect(icnDocument->m_cmManager, SIGNAL(manualRoutingChanged(bool)), this, SLOT(slotUpdateRoutingToggles(bool))); }
/*! \fn SnippetWidget::showPopupMenu( QListViewItem * item, const QPoint & p, int ) Shows the Popup-Menu depending item is a valid pointer */ void SnippetWidget::showPopupMenu( QListViewItem * item, const QPoint & p, int ) { KPopupMenu popup; SnippetItem * selectedItem = static_cast<SnippetItem *>(item); if ( item ) { popup.insertTitle( selectedItem->getName() ); popup.insertItem( i18n("Add Item..."), this, SLOT( slotAdd() ) ); popup.insertItem( i18n("Add Group..."), this, SLOT( slotAddGroup() ) ); if (dynamic_cast<SnippetGroup*>(item)) { popup.insertItem( i18n("Edit..."), this, SLOT( slotEditGroup() ) ); } else { popup.insertItem( i18n("Edit..."), this, SLOT( slotEdit() ) ); } popup.insertItem( i18n("Remove"), this, SLOT( slotRemove() ) ); } else { popup.insertTitle(i18n("Code Snippets")); popup.insertItem( i18n("Add Group..."), this, SLOT( slotAddGroup() ) ); } popup.exec(p); }
void AnalyzerContainer::contextMenuEvent( QContextMenuEvent *e) { #if defined HAVE_LIBVISUAL KPopupMenu menu; menu.insertItem( SmallIconSet( Amarok::icon( "visualizations" ) ), i18n("&Visualizations"), Menu::ID_SHOW_VIS_SELECTOR ); if( menu.exec( mapToGlobal( e->pos() ) ) == Menu::ID_SHOW_VIS_SELECTOR ) Menu::instance()->slotActivated( Menu::ID_SHOW_VIS_SELECTOR ); #else Q_UNUSED(e); #endif }
//void OutputText::contextMenuEvent(QContextMenuEvent* e) QPopupMenu* OutputText::createPopupMenu(const QPoint&) { KPopupMenu* popup = new KPopupMenu; int id = popup->insertItem(i18n("Show Internal Commands"), this, SLOT(toggleShowInternalCommands())); popup->setItemChecked(id, parent_->showInternalCommands_); popup->setWhatsThis( id, i18n( "Controls if commands issued internally by KDevelop " "will be shown or not.<br>" "This option will affect only future commands, it won't " "add or remove already issued commands from the view.")); popup->insertItem(i18n("Copy All"), this, SLOT(copyAll())); return popup; }
k2send::k2send() : KMainWindow( 0, "k2send" ), m_printer(0) { m_config = new KConfig("k2send"); m_view = new k2sendWidget(this,"k2sendwidget",0,m_config); setAcceptDrops(FALSE); setCentralWidget(m_view); setupActions(); statusBar()->show(); setAutoSaveSettings(); statusBar()->insertFixedItem("9999 Files", 0, true); statusBar()->insertFixedItem("00:00:00", 1, true); statusBar()->insertFixedItem("000 kbit/s", 2, true); statusBar()->insertFixedItem("Loud: 0", 3, true); statusBar()->insertFixedItem("00:00:00:00:00:00 ", 4, true); statusBar()->changeItem ("0 Files", 0); statusBar()->changeItem ("0 kbit/s", 2); trayicon = new KSystemTray(this, "k2sendtray"); trayicon->show(); trayicon->setPixmap (DesktopIcon( "k2send", 24)); KPopupMenu * pop = trayicon->contextMenu() ; pop->insertItem(DesktopIcon( "player_play", 16 ), "Play", m_view, SLOT(slotPlay()), CTRL+Key_P ,1,1); pop->insertItem(DesktopIcon( "player_stop", 16 ), "Stop", m_view, SLOT(slotStop()), CTRL+Key_S ,2,2); pop->insertItem(DesktopIcon( "player_fwd", 16 ), "Next", m_view, SLOT(slotSkip()), CTRL+Key_N ,3,3); pop->insertItem( "Loundess", m_view, SLOT(slotLoudness()), CTRL+Key_L ,4,4); connect(m_view, SIGNAL(signalChangeStatusbar(const QString&)), this, SLOT(changeStatusbar(const QString&))); connect(m_view, SIGNAL(signalChangeCaption(const QString&)), this, SLOT(changeCaption(const QString&))); }
void AnalyzerContainer::mousePressEvent( QMouseEvent *e) { if( e->button() == Qt::LeftButton ) { AmarokConfig::setCurrentPlaylistAnalyzer( AmarokConfig::currentPlaylistAnalyzer() + 1 ); changeAnalyzer(); } else if( e->button() == Qt::RightButton ) { #if defined HAVE_XMMS || defined HAVE_LIBVISUAL KPopupMenu menu; menu.insertItem( SmallIconSet( "visualizations" ), i18n("&Visualizations"), Menu::ID_SHOW_VIS_SELECTOR ); if( menu.exec( mapToGlobal( e->pos() ) ) == Menu::ID_SHOW_VIS_SELECTOR ) Menu::instance()->slotActivated( Menu::ID_SHOW_VIS_SELECTOR ); #endif } }
void ChatBase::initMenuBar() { // Icons: /opt/kde2/share/icons/hicolor/16x16/actions menuBar()->clear(); KPopupMenu* fileMenu = new KPopupMenu(menuBar(), "FileMenu"); fileMenu->insertItem(SmallIcon("filesave"), i18n("&Save (Formatted)"), this, SLOT(saveHTML()), ALT+Key_S ); fileMenu->insertItem(SmallIcon("filesave"), i18n("S&ave (Unformatted)"), this, SLOT(saveText()), ALT+Key_A ); fileMenu->insertItem( i18n("&Close"), this, SLOT(quit()) ); menuBar()->insertItem( i18n("&File"), fileMenu ); KPopupMenu* editMenu = new KPopupMenu(menuBar(), "EditMenu"); editMenu->insertItem(SmallIcon("editcopy"), i18n("&Copy"), this, SLOT(copy()), CTRL+Key_C ); editMenu->insertItem(SmallIcon("editcut"), i18n("C&ut"), this, SLOT(cut()), CTRL+Key_X ); editMenu->insertItem(SmallIcon("editpaste"), i18n("&Paste"), this, SLOT(paste()), CTRL+Key_V ); menuBar()->insertItem( i18n("&Edit"), editMenu); #if 0 KPopupMenu* buddyMenu = new KPopupMenu(menuBar(), "BuddyMenu"); buddyMenu->insertItem("&Profile",this,SLOT(profile()),CTRL+Key_P); menuBar()->insertItem("&Buddy", buddyMenu); KPopupMenu viewMenu = new KPopupMenu(menuBar, "ViewMenu"); menuBar->insertItem("&View", viewMenu); KPopupMenu insertMenu = new KPopupMenu(menuBar, "InsertMenu"); menuBar->insertItem("&Insert", insertMenu); KPopupMenu insertFaceMenu = new KPopupMenu(insertMenu, "FaceMenu"); KPopupMenu helpMenu = new KPopupMenu(kmenuBar, "HelpMenu"); menuBar->insertItem("&Help", helpMenu); #endif } // initMenuBar
void PerforcePart::contextMenu(QPopupMenu *popup, const Context *context) { if (context->hasType( Context::FileContext )) { const FileContext *fcontext = static_cast<const FileContext*>(context); popupfile = fcontext->urls().first().path(); QFileInfo fi( popupfile ); popup->insertSeparator(); KPopupMenu *sub = new KPopupMenu(popup); QString name = fi.fileName(); sub->insertTitle( i18n("Actions for %1").arg(name) ); int id = sub->insertItem( i18n("Edit"), this, SLOT(slotEdit()) ); sub->setWhatsThis(id, i18n("<b>Edit</b><p>Opens file(s) in a client workspace for edit.")); id = sub->insertItem( i18n("Revert"), this, SLOT(slotRevert()) ); sub->setWhatsThis(id, i18n("<b>Revert</b><p>Discards changes made to open files.")); id = sub->insertItem( i18n("Submit"), this, SLOT(slotCommit()) ); sub->setWhatsThis(id, i18n("<b>Submit</b><p>Sends changes made to open files to the depot.")); id = sub->insertItem( i18n("Sync"), this, SLOT(slotUpdate()) ); sub->setWhatsThis(id, i18n("<b>Sync</b><p>Copies files from the depot into the workspace.")); sub->insertSeparator(); id = sub->insertItem( i18n("Diff Against Repository"), this, SLOT(slotDiff()) ); sub->setWhatsThis(id, i18n("<b>Diff against repository</b><p>Compares a client workspace file to a revision in the depot.")); id = sub->insertItem( i18n("Add to Repository"), this, SLOT(slotAdd()) ); sub->setWhatsThis(id, i18n("<b>Add to repository</b><p>Open file(s) in a client workspace for addition to the depot.")); id = sub->insertItem( i18n("Remove From Repository"), this, SLOT(slotRemove()) ); sub->setWhatsThis(id, i18n("<b>Remove from repository</b><p>Open file(s) in a client workspace for deletion from the depot.")); id = popup->insertItem(i18n("Perforce"), sub); } }
//BEGIN class ItemView ItemView::ItemView(ItemDocument * itemDocument, ViewContainer *viewContainer, uint viewAreaId, const char *name) : View(itemDocument, viewContainer, viewAreaId, name) { KActionCollection * ac = actionCollection(); KStdAction::selectAll(itemDocument, SLOT(selectAll()), ac); KStdAction::zoomIn(this, SLOT(zoomIn()), ac); KStdAction::zoomOut(this, SLOT(zoomOut()), ac); KStdAction::actualSize(this, SLOT(actualSize()), ac)->setEnabled(false); KAccel *pAccel = new KAccel(this); pAccel->insert("Cancel", i18n("Cancel"), i18n("Cancel the current operation"), Qt::Key_Escape, itemDocument, SLOT(cancelCurrentOperation())); pAccel->readSettings(); new KAction(i18n("Delete"), "editdelete", Qt::Key_Delete, itemDocument, SLOT(deleteSelection()), ac, "edit_delete"); new KAction(i18n("Export as Image..."), 0, 0, itemDocument, SLOT(exportToImage()), ac, "file_export_image"); //BEGIN Item Alignment actions new KAction(i18n("Align Horizontally"), 0, 0, itemDocument, SLOT(alignHorizontally()), ac, "align_horizontally"); new KAction(i18n("Align Vertically"), 0, 0, itemDocument, SLOT(alignVertically()), ac, "align_vertically"); new KAction(i18n("Distribute Horizontally"), 0, 0, itemDocument, SLOT(distributeHorizontally()), ac, "distribute_horizontally"); new KAction(i18n("Distribute Vertically"), 0, 0, itemDocument, SLOT(distributeVertically()), ac, "distribute_vertically"); //END Item Alignment actions //BEGIN Draw actions KToolBarPopupAction * pa = new KToolBarPopupAction(i18n("Draw"), "paintbrush", 0, 0, 0, ac, "edit_draw"); pa->setDelayed(false); KPopupMenu * m = pa->popupMenu(); m->insertTitle(i18n("Draw")); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_text", KIcon::Small), i18n("Text"), DrawPart::da_text); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_line", KIcon::Small), i18n("Line"), DrawPart::da_line); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_arrow", KIcon::Small), i18n("Arrow"), DrawPart::da_arrow); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_ellipse", KIcon::Small), i18n("Ellipse"), DrawPart::da_ellipse); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_rectangle", KIcon::Small), i18n("Rectangle"), DrawPart::da_rectangle); m->insertItem(KGlobal::iconLoader()->loadIcon("imagegallery", KIcon::Small), i18n("Image"), DrawPart::da_image); connect(m, SIGNAL(activated(int)), itemDocument, SLOT(slotSetDrawAction(int))); //END Draw actions //BEGIN Item Control actions new KAction(i18n("Raise Selection"), "bring_forward", Qt::Key_PageUp, itemDocument, SLOT(raiseZ()), ac, "edit_raise"); new KAction(i18n("Lower Selection"), "send_backward", Qt::Key_PageDown, itemDocument, SLOT(lowerZ()), ac, "edit_lower"); //END Item Control actions KAction * na = new KAction("", 0, 0, 0, 0, ac, "null_action"); na->setEnabled(false); setXMLFile("ktechlabitemviewui.rc"); m_pUpdateStatusTmr = new QTimer(this); connect(m_pUpdateStatusTmr, SIGNAL(timeout()), this, SLOT(updateStatus())); connect(this, SIGNAL(unfocused()), this, SLOT(stopUpdatingStatus())); m_pDragItem = 0l; p_itemDocument = itemDocument; m_zoomLevel = 1.; m_CVBEditor = new CVBEditor(p_itemDocument->canvas(), this, "cvbEditor"); m_CVBEditor->setLineWidth(1); connect(m_CVBEditor, SIGNAL(horizontalSliderReleased()), itemDocument, SLOT(requestCanvasResize())); connect(m_CVBEditor, SIGNAL(verticalSliderReleased()), itemDocument, SLOT(requestCanvasResize())); m_layout->insertWidget(0, m_CVBEditor); setAcceptDrops(true); setFocusWidget(m_CVBEditor->viewport()); }
void RadialMap::Widget::mousePressEvent( QMouseEvent *e ) { //m_tip is hidden already by event filter //m_focus is set correctly (I've been strict, I assure you it is correct!) enum { Konqueror, Konsole, Center, Open, Copy, Delete }; if (m_focus && !m_focus->isFake()) { const KURL url = Widget::url( m_focus->file() ); const bool isDir = m_focus->file()->isDirectory(); if( e->button() == Qt::RightButton ) { KPopupMenu popup; popup.insertTitle( m_focus->file()->fullPath( m_tree ) ); if (isDir) { popup.insertItem( SmallIconSet( "konqueror" ), i18n( "Open &Konqueror Here" ), Konqueror ); if( url.protocol() == "file" ) popup.insertItem( SmallIconSet( "konsole" ), i18n( "Open &Konsole Here" ), Konsole ); if (m_focus->file() != m_tree) { popup.insertSeparator(); popup.insertItem( SmallIconSet( "viewmag" ), i18n( "&Center Map Here" ), Center ); } } else popup.insertItem( SmallIconSet( "fileopen" ), i18n( "&Open" ), Open ); popup.insertSeparator(); popup.insertItem( SmallIconSet( "editcopy" ), i18n( "&Copy to clipboard" ), Copy ); popup.insertSeparator(); popup.insertItem( SmallIconSet( "editdelete" ), i18n( "&Delete" ), Delete ); switch (popup.exec( e->globalPos(), 1 )) { case Konqueror: //KRun::runCommand will show an error message if there was trouble KRun::runCommand( QString( "kfmclient openURL \"%1\"" ).arg( url.url() ) ); break; case Konsole: // --workdir only works for local file paths KRun::runCommand( QString( "konsole --workdir \"%1\"" ).arg( url.path() ) ); break; case Center: case Open: goto section_two; case Copy: QApplication::clipboard()->setData( new KURLDrag( KURL::List( url ) ) ); break; case Delete: { const KURL url = Widget::url( m_focus->file() ); const QString message = m_focus->file()->isDirectory() ? i18n( "<qt>The directory at <i>'%1'</i> will be <b>recursively</b> and <b>permanently</b> deleted." ) : i18n( "<qt><i>'%1'</i> will be <b>permanently</b> deleted." ); const int userIntention = KMessageBox::warningContinueCancel( this, message.arg( url.prettyURL() ), QString::null, KGuiItem( i18n("&Delete"), "editdelete" ) ); if (userIntention == KMessageBox::Continue) { KIO::Job *job = KIO::del( url ); job->setWindow( this ); connect( job, SIGNAL(result( KIO::Job* )), SLOT(deleteJobFinished( KIO::Job* )) ); QApplication::setOverrideCursor( KCursor::workingCursor() ); } } default: //ensure m_focus is set for new mouse position sendFakeMouseEvent(); } } else { // not right mouse button section_two: const QRect rect( e->x() - 20, e->y() - 20, 40, 40 ); m_tip->hide(); // user expects this if (!isDir || e->button() == Qt::MidButton) { KIconEffect::visualActivate( this, rect ); new KRun( url, this, true ); //FIXME see above } else if (m_focus->file() != m_tree) { // is left click KIconEffect::visualActivate( this, rect ); emit activated( url ); //activate first, this will cause UI to prepare itself createFromCache( (Directory *)m_focus->file() ); } else emit giveMeTreeFor( url.upURL() ); } } }
void QueueLabel::mousePressEvent( QMouseEvent* mouseEvent ) { hideToolTip(); if( m_timer.isActive() ) // if the user clicks again when (right after) the menu is open, { // (s)he probably wants to close it m_timer.stop(); return; } Playlist *pl = Playlist::instance(); PLItemList &queue = pl->m_nextTracks; if( queue.isEmpty() ) return; int length = 0; for( QPtrListIterator<PlaylistItem> it( queue ); *it; ++it ) { const int s = (*it)->length(); if( s > 0 ) length += s; } QPtrList<KPopupMenu> menus; menus.setAutoDelete( true ); KPopupMenu *menu = new KPopupMenu; menus.append( menu ); const uint count = queue.count(); if( length ) menu->insertTitle( i18n( "1 Queued Track (%1)", "%n Queued Tracks (%1)", count ) .arg( MetaBundle::prettyLength( length, true ) ) ); else menu->insertTitle( i18n( "1 Queued Track", "%n Queued Tracks", count ) ); Pana::actionCollection()->action( "queue_manager" )->plug( menu ); menu->insertItem( SmallIconSet( Pana::icon( "rewind" ) ), count > 1 ? i18n( "&Dequeue All Tracks" ) : i18n( "&Dequeue Track" ), 0 ); menu->insertSeparator(); uint i = 1; QPtrListIterator<PlaylistItem> it( queue ); it.toFirst(); while( i <= count ) { for( uint n = kMin( i + MAX_TO_SHOW - 1, count ); i <= n; ++i, ++it ) menu->insertItem( KStringHandler::rsqueeze( i18n( "%1. %2" ).arg( i ).arg( veryNiceTitle( *it ) ), 50 ), i ); if( i < count ) { menus.append( new KPopupMenu ); menu->insertSeparator(); menu->insertItem( i18n( "1 More Track", "%n More Tracks", count - i + 1 ), menus.getLast() ); menu = menus.getLast(); } } menu = menus.getFirst(); int mx, my; const int mw = menu->sizeHint().width(), mh = menu->sizeHint().height(), sy = mapFrom( Pana::StatusBar::instance(), QPoint( 0, 0 ) ).y(), sheight = Pana::StatusBar::instance()->height(); const QRect dr = QApplication::desktop()->availableGeometry( this ); if( mapYToGlobal( sy ) - mh > dr.y() ) my = mapYToGlobal( sy ) - mh; else if( mapYToGlobal( sy + sheight ) + mh < dr.y() + dr.height() ) my = mapYToGlobal( sy + sheight ); else my = mapToGlobal( mouseEvent->pos() ).y(); mx = mapXToGlobal( 0 ) - ( mw - width() ) / 2; int id = menu->exec( QPoint( mx, my ) ); if( id < 0 ) m_timer.start( 50, true ); else if( id == 0 ) //dequeue { const PLItemList dequeued = queue; while( !queue.isEmpty() ) pl->queue( queue.getLast(), true ); emit queueChanged( PLItemList(), dequeued ); } else { PlaylistItem *selected = queue.at( id - 1 ); if( selected ) pl->ensureItemCentered( selected ); } }
KToolBar * xQGanttBarViewPort::toolbar(QMainWindow *mw) { if(_toolbar || mw == 0) return _toolbar; _toolbar = new KToolBar(mw, QMainWindow::DockTop); mw->addToolBar(_toolbar); // KIconLoader* iconloader = new KIconLoader("kgantt"); _toolbar->insertButton("ganttSelect.png", 0, SIGNAL(clicked()), this, SLOT(setSelect()), true, i18n("Select")); KPopupMenu *selectMenu = new KPopupMenu(_toolbar); /* select all items */ QPixmap pix = _iconloader->loadIcon("ganttSelecttask.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("ganttSelecttask.png not found !\n"); selectMenu->insertItem(pix, i18n("Select All"), this, SLOT(selectAll())); /* unselect all items */ pix = _iconloader->loadIcon("ganttUnselecttask", KIcon::Toolbar , 16); if(pix.isNull()) printf("ganttUnselecttask.png not found !\n"); selectMenu->insertItem(pix, i18n("Unselect All"), this, SLOT(unselectAll())); KToolBarButton *b = _toolbar->getButton(0); b->setDelayedPopup(selectMenu); _toolbar->insertButton("viewmag.png", 1, SIGNAL(clicked()), this, SLOT(setZoom()), true, i18n("Zoom")); KPopupMenu *zoomMenu = new KPopupMenu(_toolbar); pix = _iconloader->loadIcon("viewmag.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("viewmag.png not found !\n"); zoomMenu->insertItem(pix, i18n("Zoom All"), this, SLOT(zoomAll())); zoomMenu->insertSeparator(); pix = _iconloader->loadIcon("viewmag+.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("viewmag+.png not found !\n"); zoomMenu->insertItem(pix, i18n("Zoom In +"), this, SLOT(zoomIn())); pix = _iconloader->loadIcon("viewmag-.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("viewmag-.png not found !\n"); zoomMenu->insertItem(pix, i18n("Zoom Out -"), this, SLOT(zoomOut())); b = _toolbar->getButton(1); b->setDelayedPopup(zoomMenu); _toolbar->insertButton("move.png", 2, SIGNAL(clicked()), this, SLOT(setMove()), true, i18n("Move")); return _toolbar; }
void DolphinContextMenu::openViewportContextMenu() { // Parts of the following code have been taken // from the class KonqOperations located in // libqonq/konq_operations.h of Konqueror. // (Copyright (C) 2000 David Faure <*****@*****.**>) assert(m_fileInfo == 0); const int propertiesID = 100; const int bookmarkID = 101; KPopupMenu* popup = new KPopupMenu(m_dolphinView); Dolphin& dolphin = Dolphin::mainWin(); // setup 'Create New' menu KPopupMenu* createNewMenu = new KPopupMenu(); KAction* createFolderAction = dolphin.actionCollection()->action("create_folder"); if (createFolderAction != 0) { createFolderAction->plug(createNewMenu); } createNewMenu->insertSeparator(); KAction* action = 0; QPtrListIterator<KAction> fileGrouptIt(dolphin.fileGroupActions()); while ((action = fileGrouptIt.current()) != 0) { action->plug(createNewMenu); ++fileGrouptIt; } // TODO: not used yet. See documentation of Dolphin::linkGroupActions() // and Dolphin::linkToDeviceActions() in the header file for details. // //createNewMenu->insertSeparator(); // //QPtrListIterator<KAction> linkGroupIt(dolphin.linkGroupActions()); //while ((action = linkGroupIt.current()) != 0) { // action->plug(createNewMenu); // ++linkGroupIt; //} // //KPopupMenu* linkToDeviceMenu = new KPopupMenu(); //QPtrListIterator<KAction> linkToDeviceIt(dolphin.linkToDeviceActions()); //while ((action = linkToDeviceIt.current()) != 0) { // action->plug(linkToDeviceMenu); // ++linkToDeviceIt; //} // //createNewMenu->insertItem(i18n("Link to Device"), linkToDeviceMenu); const KURL& url = dolphin.activeView()->url(); if (url.protocol() == "trash") { popup->insertItem(i18n("Empty Deleted Items Folder"), emptyID); } else { popup->insertItem(SmallIcon("filenew"), i18n("Create New"), createNewMenu); } popup->insertSeparator(); KAction* pasteAction = dolphin.actionCollection()->action(KStdAction::stdName(KStdAction::Paste)); pasteAction->plug(popup); // setup 'View Mode' menu KPopupMenu* viewModeMenu = new KPopupMenu(); KAction* iconsMode = dolphin.actionCollection()->action("icons"); iconsMode->plug(viewModeMenu); KAction* detailsMode = dolphin.actionCollection()->action("details"); detailsMode->plug(viewModeMenu); KAction* previewsMode = dolphin.actionCollection()->action("previews"); previewsMode->plug(viewModeMenu); popup->insertItem(i18n("View Mode"), viewModeMenu); popup->insertSeparator(); popup->insertItem(i18n("Bookmark this folder"), bookmarkID); popup->insertSeparator(); popup->insertItem(i18n("Properties..."), propertiesID); int id = popup->exec(m_pos); if (id == emptyID) { KonqOperations::emptyTrash(); } else if (id == propertiesID) { new KPropertiesDialog(dolphin.activeView()->url()); } else if (id == bookmarkID) { const KURL& url = dolphin.activeView()->url(); KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add folder as bookmark"), url.filename(), url, "bookmark"); if (!bookmark.isNull()) { KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager(); KBookmarkGroup root = manager->root(); root.addBookmark(manager, bookmark); manager->emitChanged(root); } } popup->deleteLater(); }
/** * Deal with right click's */ void KBinaryClock::openContextMenu() { bool bImmutable = config()->isImmutable(); KPopupMenu *menu = new KPopupMenu(); menu->insertTitle( SmallIcon( "clock" ), i18n( "KBinaryClock" ) ); KLocale *loc = KGlobal::locale(); QDateTime dt = QDateTime::currentDateTime(); KPopupMenu *copyMenu = new KPopupMenu( menu ); copyMenu->insertItem(loc->formatDateTime(dt), 201); copyMenu->insertItem(loc->formatDate(dt.date()), 202); copyMenu->insertItem(loc->formatDate(dt.date(), true), 203); copyMenu->insertItem(loc->formatTime(dt.time()), 204); copyMenu->insertItem(loc->formatTime(dt.time(), true), 205); copyMenu->insertItem(dt.date().toString(), 206); copyMenu->insertItem(dt.time().toString(), 207); copyMenu->insertItem(dt.toString(), 208); connect( copyMenu, SIGNAL( activated(int) ), this, SLOT( slotCopyMenuActivated(int) ) ); if (!bImmutable) { if (kapp->authorize("user/root")) { menu->insertItem(SmallIcon("date"), i18n("&Adjust Date && Time..."), 103, 4); } menu->insertItem(SmallIcon("kcontrol"), i18n("Date && Time &Format..."), 104, 5); } menu->insertItem(SmallIcon("editcopy"), i18n("C&opy to Clipboard"), copyMenu, 105, 6); if (!bImmutable) { menu->insertSeparator(7); menu->insertItem(SmallIcon("configure"), i18n("&Configure KBinaryClock..."), 102, 8); } int result = menu->exec( QCursor::pos() ); KProcess proc; switch (result) { case 102: preferences(); break; case 103: proc << locate("exe", "kdesu"); proc << "--nonewdcop"; proc << QString("%1 clock --lang %2") .arg(locate("exe", "kcmshell")) .arg(KGlobal::locale()->language()); proc.start(KProcess::DontCare); break; case 104: proc << locate("exe", "kcmshell"); proc << "language"; proc.start(KProcess::DontCare); break; case 110: preferences(); break; } /* switch() */ delete menu; }
void DolphinContextMenu::insertActionItems(KPopupMenu* popup, QValueVector<KDEDesktopMimeType::Service>& actionsVector) { KPopupMenu* actionsMenu = new KPopupMenu(); int actionsIndex = 0; QStringList dirs = KGlobal::dirs()->findDirs("data", "d3lphin/servicemenus/"); KPopupMenu* menu = 0; for (QStringList::ConstIterator dirIt = dirs.begin(); dirIt != dirs.end(); ++dirIt) { QDir dir(*dirIt); QStringList entries = dir.entryList("*.desktop", QDir::Files); for (QStringList::ConstIterator entryIt = entries.begin(); entryIt != entries.end(); ++entryIt) { KSimpleConfig cfg(*dirIt + *entryIt, true); cfg.setDesktopGroup(); if ((cfg.hasKey("Actions") || cfg.hasKey("X-KDE-GetActionMenu")) && cfg.hasKey("ServiceTypes")) { const QStringList types = cfg.readListEntry("ServiceTypes"); for (QStringList::ConstIterator it = types.begin(); it != types.end(); ++it) { // check whether the mime type is equal or whether the // mimegroup (e. g. image/*) is supported bool insert = false; if ((*it) == "all/allfiles") { // The service type is valid for all files, but not for directories. // Check whether the selected items only consist of files... const KFileItemList* list = m_dolphinView->selectedItems(); assert(list != 0); KFileItemListIterator mimeIt(*list); KFileItem* item = 0; insert = true; while (insert && ((item = mimeIt.current()) != 0)) { insert = !item->isDir(); ++mimeIt; } } if (!insert) { // Check whether the MIME types of all selected files match // to the mimetype of the service action. As soon as one MIME // type does not match, no service menu is shown at all. const KFileItemList* list = m_dolphinView->selectedItems(); assert(list != 0); KFileItemListIterator mimeIt(*list); KFileItem* item = 0; insert = true; while (insert && ((item = mimeIt.current()) != 0)) { const QString mimeType((*mimeIt)->mimetype()); const QString mimeGroup(mimeType.left(mimeType.find('/'))); insert = (*it == mimeType) || ((*it).right(1) == "*") && ((*it).left((*it).find('/')) == mimeGroup); ++mimeIt; } } if (insert) { menu = actionsMenu; const QString submenuName = cfg.readEntry( "X-KDE-Submenu" ); if (!submenuName.isEmpty()) { menu = new KPopupMenu(); actionsMenu->insertItem(submenuName, menu, submenuID); } QValueList<KDEDesktopMimeType::Service> userServices = KDEDesktopMimeType::userDefinedServices(*dirIt + *entryIt, true); QValueList<KDEDesktopMimeType::Service>::Iterator serviceIt; for (serviceIt = userServices.begin(); serviceIt != userServices.end(); ++serviceIt) { KDEDesktopMimeType::Service service = (*serviceIt); if (!service.m_strIcon.isEmpty()) { menu->insertItem(SmallIcon(service.m_strIcon), service.m_strName, actionsIDStart + actionsIndex); } else { menu->insertItem(service.m_strName, actionsIDStart + actionsIndex); } actionsVector.append(service); ++actionsIndex; } } } } } } const int itemsCount = actionsMenu->count(); if (itemsCount == 0) { // no actions are available at all, hence show the "Actions" // submenu disabled actionsMenu->setEnabled(false); } if (itemsCount == 1) { // Exactly one item is available. Instead of showing a sub menu with // only one item, show the item directly in the root menu. if (menu == actionsMenu) { // The item is an action, hence show the action in the root menu. const int id = actionsMenu->idAt(0); const QString text(actionsMenu->text(id)); const QIconSet* iconSet = actionsMenu->iconSet(id); if (iconSet == 0) { popup->insertItem(text, id); } else { popup->insertItem(*iconSet, text, id); } } else { // The item is a sub menu, hence show the sub menu in the root menu. popup->insertItem(actionsMenu->text(submenuID), menu); } actionsMenu->deleteLater(); actionsMenu = 0; } else { popup->insertItem(i18n("Actions"), actionsMenu); } }
int DolphinContextMenu::insertOpenWithItems(KPopupMenu* popup, QValueVector<KService::Ptr>& openWithVector) { // Prepare 'Open With' sub menu. Usually a sub menu is created, where all applications // are listed which are registered to open the item. As last entry "Other..." will be // attached which allows to select a custom application. If no applications are registered // no sub menu is created at all, only "Open With..." will be offered. const KFileItemList* list = m_dolphinView->selectedItems(); assert(list != 0); bool insertOpenWithItems = true; const QString contextMimeType(m_fileInfo->mimetype()); KFileItemListIterator mimeIt(*list); KFileItem* item = 0; while (insertOpenWithItems && ((item = mimeIt.current()) != 0)) { insertOpenWithItems = (contextMimeType == item->mimetype()); ++mimeIt; } int openWithID = -1; if (insertOpenWithItems) { // fill the 'Open with' sub menu with application types const KMimeType::Ptr mimePtr = KMimeType::findByURL(m_fileInfo->url()); KTrader::OfferList offers = KTrader::self()->query(mimePtr->name(), "Type == 'Application'"); int index = openWithIDStart; if (offers.count() > 0) { KTrader::OfferList::Iterator it; KPopupMenu* openWithMenu = new KPopupMenu(); for(it = offers.begin(); it != offers.end(); ++it) { // The offer list from the KTrader returns duplicate // application entries. Although this seems to be a configuration // problem outside the scope of Dolphin, duplicated entries just // will be skipped here. const QString appName((*it)->name()); if (!containsEntry(openWithMenu, appName)) { openWithMenu->insertItem((*it)->pixmap(KIcon::Small), appName, index); openWithVector.append(*it); ++index; } } openWithMenu->insertSeparator(); openWithMenu->insertItem(i18n("&Other..."), index); popup->insertItem(i18n("Open With"), openWithMenu); } else { // No applications are registered, hence just offer // a "Open With..." item instead of a sub menu containing // only one entry. popup->insertItem(i18n("Open With..."), openWithIDStart); } openWithID = index; } else { // At least one of the selected items has a different MIME type. In this case // just show a disabled "Open With..." entry. popup->insertItem(i18n("Open With..."), openWithIDStart); popup->setItemEnabled(openWithIDStart, false); } popup->setItemEnabled(openWithID, insertOpenWithItems); return openWithID; }
void DolphinContextMenu::openItemContextMenu() { // Parts of the following code have been taken // from the class KonqOperations located in // libqonq/konq_operations.h of Konqueror. // (Copyright (C) 2000 David Faure <*****@*****.**>) assert(m_fileInfo != 0); KPopupMenu* popup = new KPopupMenu(m_dolphinView); Dolphin& dolphin = Dolphin::mainWin(); const KURL::List urls = m_dolphinView->selectedURLs(); const KURL& url = dolphin.activeView()->url(); if (url.protocol() == "trash") { popup->insertItem(i18n("&Restore"), restoreID); } // insert 'Cut', 'Copy' and 'Paste' const KStdAction::StdAction actionNames[] = { KStdAction::Cut, KStdAction::Copy, KStdAction::Paste }; const int count = sizeof(actionNames) / sizeof(KStdAction::StdAction); for (int i = 0; i < count; ++i) { KAction* action = dolphin.actionCollection()->action(KStdAction::stdName(actionNames[i])); if (action != 0) { action->plug(popup); } } popup->insertSeparator(); // insert 'Rename' KAction* renameAction = dolphin.actionCollection()->action("rename"); renameAction->plug(popup); // insert 'Move to Trash' for local URLs, otherwise insert 'Delete' if (url.isLocalFile()) { KAction* moveToTrashAction = dolphin.actionCollection()->action("move_to_trash"); moveToTrashAction->plug(popup); } else { KAction* deleteAction = dolphin.actionCollection()->action("delete"); deleteAction->plug(popup); } // insert 'Bookmark this folder...' entry // urls is a list of selected items, so insert boolmark menu if // urls contains only one item, i.e. no multiple selection made if (m_fileInfo->isDir() && (urls.count() == 1)) { popup->insertItem(i18n("Bookmark this folder"), bookmarkID); } popup->insertSeparator(); // Insert 'Open With...' sub menu QValueVector<KService::Ptr> openWithVector; const int openWithID = insertOpenWithItems(popup, openWithVector); // Insert 'Actions' sub menu QValueVector<KDEDesktopMimeType::Service> actionsVector; insertActionItems(popup, actionsVector); // insert 'Properties...' entry popup->insertSeparator(); KAction* propertiesAction = dolphin.actionCollection()->action("properties"); propertiesAction->plug(popup); int id = popup->exec(m_pos); if (id == restoreID ) { KonqOperations::restoreTrashedItems(urls); } else if (id == bookmarkID) { const KURL selectedURL(m_fileInfo->url()); KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add folder as bookmark"), selectedURL.filename(), selectedURL, "bookmark"); if (!bookmark.isNull()) { KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager(); KBookmarkGroup root = manager->root(); root.addBookmark(manager, bookmark); manager->emitChanged(root); } } else if (id >= actionsIDStart) { // one of the 'Actions' items has been selected KDEDesktopMimeType::executeService(urls, actionsVector[id - actionsIDStart]); } else if (id >= openWithIDStart) { // one of the 'Open With' items has been selected if (id == openWithID) { // the item 'Other...' has been selected KRun::displayOpenWithDialog(urls); } else { KService::Ptr servicePtr = openWithVector[id - openWithIDStart]; KRun::run(*servicePtr, urls); } } openWithVector.clear(); actionsVector.clear(); popup->deleteLater(); }
void Amarok::coverContextMenu( QWidget *parent, QPoint point, const QString &artist, const QString &album, bool showCoverManager ) { KPopupMenu menu; enum { SHOW, FETCH, CUSTOM, DELETE, MANAGER }; menu.insertTitle( i18n( "Cover Image" ) ); menu.insertItem( SmallIconSet( Amarok::icon( "zoom" ) ), i18n( "&Show Fullsize" ), SHOW ); menu.insertItem( SmallIconSet( Amarok::icon( "download" ) ), i18n( "&Fetch From amazon.%1" ).arg( CoverManager::amazonTld() ), FETCH ); menu.insertItem( SmallIconSet( Amarok::icon( "files" ) ), i18n( "Set &Custom Cover" ), CUSTOM ); bool disable = !album.isEmpty(); // disable setting covers for unknown albums menu.setItemEnabled( FETCH, disable ); menu.setItemEnabled( CUSTOM, disable ); menu.insertSeparator(); menu.insertItem( SmallIconSet( Amarok::icon( "remove" ) ), i18n( "&Unset Cover" ), DELETE ); if ( showCoverManager ) { menu.insertSeparator(); menu.insertItem( SmallIconSet( Amarok::icon( "covermanager" ) ), i18n( "Cover &Manager" ), MANAGER ); } #ifndef AMAZON_SUPPORT menu.setItemEnabled( FETCH, false ); #endif disable = !CollectionDB::instance()->albumImage( artist, album, 0 ).contains( "nocover" ); menu.setItemEnabled( SHOW, disable ); menu.setItemEnabled( DELETE, disable ); switch( menu.exec( point ) ) { case SHOW: CoverManager::viewCover( artist, album, parent ); break; case DELETE: { const int button = KMessageBox::warningContinueCancel( parent, i18n( "Are you sure you want to remove this cover from the Collection?" ), QString::null, KStdGuiItem::del() ); if ( button == KMessageBox::Continue ) CollectionDB::instance()->removeAlbumImage( artist, album ); break; } case FETCH: #ifdef AMAZON_SUPPORT CollectionDB::instance()->fetchCover( parent, artist, album, false ); break; #endif case CUSTOM: { QString artist_id; artist_id.setNum( CollectionDB::instance()->artistID( artist ) ); QString album_id; album_id.setNum( CollectionDB::instance()->albumID( album ) ); QStringList values = CollectionDB::instance()->albumTracks( artist_id, album_id ); QString startPath = ":homedir"; if ( !values.isEmpty() ) { KURL url; url.setPath( values.first() ); startPath = url.directory(); } KURL file = KFileDialog::getImageOpenURL( startPath, parent, i18n("Select Cover Image File") ); if ( !file.isEmpty() ) CollectionDB::instance()->setAlbumImage( artist, album, file ); break; } case MANAGER: CoverManager::showOnce( album ); break; } }
void subversionPart::contextMenu( QPopupMenu *popup, const Context *context ) { //no project, no subversion. Don't test on projectDirectory() here. If the user wants this project to have subversion support //give it to him. e.g. for out of root subprojects like with qmake if(!project()) return; kdDebug(9036) << "contextMenu()" << endl; if (context->hasType( Context::FileContext ) || context->hasType( Context::EditorContext )) { if (context->hasType( Context::FileContext )) { kdDebug(9036) << "Requested for a FileContext" << endl; const FileContext *fcontext = static_cast<const FileContext*>( context ); m_urls = fcontext->urls(); } else { kdDebug(9036) << "Requested for an EditorContext" << endl; const EditorContext *editorContext = static_cast<const EditorContext*>( context ); m_urls = editorContext->url(); } // THis stuff should end up into prepareOperation() URLUtil::dump( m_urls ); if (m_urls.count() <= 0) return; KPopupMenu *subMenu = new KPopupMenu( popup ); if (context->hasType( Context::FileContext )) popup->insertSeparator(); int id = subMenu->insertItem( actionCommit->text(), this, SLOT(slotCommit()) ); // CvsService let to do log and diff operations only on one file (or directory) at time /* if (m_urls.count() == 1) { subMenu->insertItem( actionDiff->text(), this, SLOT(slotDiff()) ); subMenu->insertItem( actionLog->text(), this, SLOT(slotLog()) ); }*/ subMenu->setWhatsThis(id, i18n("<b>Commit file(s)</b><p>Commits file to repository if modified.")); id = subMenu->insertItem( actionAdd->text(), this, SLOT(slotAdd()) ); subMenu->setWhatsThis(id, i18n("<b>Add file to repository</b><p>Adds file to repository.")); id = subMenu->insertItem( actionRemove->text(), this, SLOT(slotDel()) ); subMenu->setWhatsThis(id, i18n("<b>Remove from repository</b><p>Removes file(s) from repository.")); id = subMenu->insertItem( actionLog->text(), this, SLOT(slotLog()) ); subMenu->setWhatsThis(id, i18n("<b>Show logs..</b><p>View Logs")); id = subMenu->insertItem( actionBlame->text(), this, SLOT(slotBlame()) ); subMenu->setWhatsThis(id, i18n("<b>Blame 0:HEAD </b><p>Show Annotate")); subMenu->insertSeparator(); id = subMenu->insertItem( actionDiffLocal->text(), this, SLOT(slotDiffLocal()) ); subMenu->setWhatsThis(id, i18n("<b>Diff</b><p>Diff file to local disk.")); id = subMenu->insertItem( actionDiffHead->text(), this, SLOT(slotDiffHead()) ); subMenu->setWhatsThis(id, i18n("<b>Diff</b><p>Diff file to repository.")); id = subMenu->insertItem( actionUpdate->text(), this, SLOT(slotUpdate()) ); subMenu->setWhatsThis(id, i18n("<b>Update</b><p>Updates file(s) from repository.")); id = subMenu->insertItem( actionRevert->text(), this, SLOT(slotRevert()) ); subMenu->setWhatsThis(id, i18n("<b>Revert</b><p>Undo local changes.") ); id = subMenu->insertItem( actionResolve->text(), this, SLOT(slotResolve()) ); subMenu->setWhatsThis(id, i18n("<b>Resolve</b><p>Resolve conflicting state.") ); id = subMenu->insertItem( actionSwitch->text(), this, SLOT(slotSwitch()) ); subMenu->setWhatsThis(id, i18n("<b>Switch</b><p>Switch working tree.") ); id = subMenu->insertItem( actionCopy->text(), this, SLOT(slotCopy()) ); subMenu->setWhatsThis(id, i18n("<b>Copy</b><p>Copy from/between path/URLs") ); id = subMenu->insertItem( actionMerge->text(), this, SLOT(slotMerge()) ); subMenu->setWhatsThis(id, i18n("<b>Merge</b><p>Merge difference to working copy") ); /* subMenu->insertSeparator(); id = subMenu->insertItem( actionAddToIgnoreList->text(), this, SLOT(slotAddToIgnoreList()) ); subMenu->setWhatsThis(id, i18n("<b>Ignore in Subversion operations</b><p>Ignores file(s).")); id = subMenu->insertItem( actionRemoveFromIgnoreList->text(), this, SLOT(slotRemoveFromIgnoreList()) ); subMenu->setWhatsThis(id, i18n("<b>Do not ignore in Subversion operations</b><p>Do not ignore file(s).")); */ // Now insert in parent menu popup->insertItem( i18n("Subversion"), subMenu ); } }