本文整理汇总了C++中KPopupMenu::exec方法的典型用法代码示例。如果您正苦于以下问题:C++ KPopupMenu::exec方法的具体用法?C++ KPopupMenu::exec怎么用?C++ KPopupMenu::exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KPopupMenu
的用法示例。
在下文中一共展示了KPopupMenu::exec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execContextMenu
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;
}
示例2: showPopupMenu
/*!
\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);
}
示例3: eventFilter
//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);
}
示例4: contextMenu
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);
}
示例5: showPopup
void ServiceLoader::showPopup(const QString &popup, const QPoint &point)
{
KPopupMenu *p = popups[popup];
if(p){
p->exec(point);
}
}
示例6: slotContextMenuRequested
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;
}
示例7: showMenuAt
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 );
}
示例8: popupMenu
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);
}
}
示例9: SmallIconSet
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
}
示例10: end
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;
}
}
示例11: if
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
}
}
示例12: eventFilter
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;
}
}
}
示例13: rect
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() );
}
}
//.........这里部分代码省略.........
示例14: openViewportContextMenu
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 <[email protected]>)
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()) {
//.........这里部分代码省略.........
示例15: openItemContextMenu
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 <[email protected]rg>)
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);
}
}
//.........这里部分代码省略.........