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; }
/*! \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); }
//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); }
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); }
void ServiceLoader::showPopup(const QString &popup, const QPoint &point) { KPopupMenu *p = popups[popup]; if(p){ p->exec(point); } }
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 KasLoadItem::showMenuAt( QPoint p ) { mouseLeave(); kasbar()->updateMouseOver(); KasTasker *bar = dynamic_cast<KasTasker *> (KasItem::kasbar()); if ( !bar ) return; KPopupMenu *menu = bar->contextMenu(); menu->exec( p ); }
void GrepViewWidget::popupMenu(QListBoxItem*, const QPoint& p) { if(m_curOutput->isRunning()) return; KPopupMenu rmbMenu; if(KAction *findAction = m_part->actionCollection()->action("edit_grep")) { rmbMenu.insertTitle(i18n("Find in Files")); findAction->plug(&rmbMenu); rmbMenu.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 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; } }
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 } }
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; } } }
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() ); } } }
bool KPixmapRegionSelectorWidget::eventFilter(QObject *obj, QEvent *ev) { if ( ev->type() == QEvent::MouseButtonPress ) { QMouseEvent *mev= (QMouseEvent *)(ev); //kdDebug() << QString("click at %1,%2").arg( mev->x() ).arg( mev->y() ) << endl; if ( mev->button() == RightButton ) { KPopupMenu *popup = createPopupMenu( ); popup->exec( mev->globalPos() ); delete popup; return TRUE; }; QCursor cursor; if ( m_selectedRegion.contains( mev->pos() ) && m_selectedRegion!=m_originalPixmap.rect() ) { m_state=Moving; cursor=QCursor(Qt::SizeAllCursor); } else { m_state=Resizing; cursor=QCursor(Qt::CrossCursor); } QApplication::setOverrideCursor(cursor); m_tempFirstClick=mev->pos(); return TRUE; } if ( ev->type() == QEvent::MouseMove ) { QMouseEvent *mev= (QMouseEvent *)(ev); //kdDebug() << QString("move to %1,%2").arg( mev->x() ).arg( mev->y() ) << endl; if ( m_state == Resizing ) { setSelectedRegion ( calcSelectionRectangle( m_tempFirstClick, mev->pos() ) ); } else if (m_state == Moving ) { int mevx = mev->x(); int mevy = mev->y(); bool mouseOutside=false; if ( mevx < 0 ) { m_selectedRegion.moveBy(-m_selectedRegion.x(),0); mouseOutside=true; } else if ( mevx > m_originalPixmap.width() ) { m_selectedRegion.moveBy(m_originalPixmap.width()-m_selectedRegion.width()-m_selectedRegion.x(),0); mouseOutside=true; } if ( mevy < 0 ) { m_selectedRegion.moveBy(0,-m_selectedRegion.y()); mouseOutside=true; } else if ( mevy > m_originalPixmap.height() ) { m_selectedRegion.moveBy(0,m_originalPixmap.height()-m_selectedRegion.height()-m_selectedRegion.y()); mouseOutside=true; } if (mouseOutside) { updatePixmap(); return TRUE; }; m_selectedRegion.moveBy( mev->x()-m_tempFirstClick.x(), mev->y()-m_tempFirstClick.y() ); // Check that the region has not fallen outside the image if (m_selectedRegion.x() < 0) m_selectedRegion.moveBy(-m_selectedRegion.x(),0); else if (m_selectedRegion.right() > m_originalPixmap.width()) m_selectedRegion.moveBy(-(m_selectedRegion.right()-m_originalPixmap.width()),0); if (m_selectedRegion.y() < 0) m_selectedRegion.moveBy(0,-m_selectedRegion.y()); else if (m_selectedRegion.bottom() > m_originalPixmap.height()) m_selectedRegion.moveBy(0,-(m_selectedRegion.bottom()-m_originalPixmap.height())); m_tempFirstClick=mev->pos(); updatePixmap(); } return TRUE; } if ( ev->type() == QEvent::MouseButtonRelease ) { QMouseEvent *mev= (QMouseEvent *)(ev); if ( m_state == Resizing && mev->pos() == m_tempFirstClick) resetSelection(); m_state=None; QApplication::restoreOverrideCursor(); return TRUE; } QWidget::eventFilter(obj, ev); return FALSE; }
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(); }
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 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 ); } }
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; } }
/** * 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; }