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 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; } }