/*! \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 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; }
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; } } }
KPopupMenu *ClassToolWidget::createPopup() { KPopupMenu *popup = contextItem? contextItem->createPopup() : 0; if (!popup) { popup = new KPopupMenu(this); popup->insertTitle(i18n("Class Tool")); } return popup; }
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 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; } }
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))); }
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); } }
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() ); } } }
/** * @short Initialize * @author Rene Schmidt <*****@*****.**> * @version 0.1 */ KLAidWidget::KLAidWidget(QWidget* parent, const char* name, WFlags fl) : KLAidWidgetBase(parent,name,fl) { this->setCaption(i18n("K Learning Aid %1").arg(VER)); cfgOkay = FALSE; oldRepVal = 1; // Center window QDesktopWidget *d = QApplication::desktop(); int dW = d->width(); int dH = d->height(); int wW = this->width(); int wH = this->height(); this->setGeometry((dW-wW)/2, (dH-wH)/2, wW, wH); // Create tray icon tray = new KSystemTray(this, "TimerTray"); tray->setPixmap(SmallIcon("ktimer")); tray->show(); QToolTip::add(tray, i18n("K Learning Aid %1").arg(VER)); // Create logic backend aut = new KLAid(this); aut->desktopWidth = d->width(); aut->setCentralWidget(tray); QObject::connect(aut, SIGNAL(loopExpired()), this, SLOT(reportExpired())); QObject::connect(aut, SIGNAL(popNow( QString&, QString&, uint&)), this, SLOT(showPopUp(QString&, QString&, uint&))); // Add some tray menu items KPopupMenu * TrayMenu = tray->contextMenu(); enPopAction = new KToggleAction( i18n("&Enable PopUps"), 0, this, SLOT(toggleTimer()), parentWidget(), TOGGLE_ITEM); KAction * AboutAction = new KAction( i18n("&About"), 0, this, SLOT(about()), parentWidget(), ABOUT_ITEM); TrayMenu->removeItemAt(0); TrayMenu->insertTitle(SmallIcon("ktimer"), QString("KLAid"), 0, 0); enPopAction->plug(TrayMenu, 1); enPopAction->setEnabled(FALSE); AboutAction->plug(TrayMenu, 2); connect(popUpInterval, SIGNAL(valueChanged(const QString&)), this, SLOT(sanitizeMinStay())); connect(urlLine, SIGNAL(urlSelected(const QString&)), this, SLOT(enableOKButton())); connect(minStay, SIGNAL(valueChanged(const QString&)), this, SLOT(sanitizeMinStay())); connect(pIntvalUnit, SIGNAL(activated(const QString&)), this, SLOT(sanitizeMinStay())); connect(overlapPops, SIGNAL(stateChanged(int)), this, SLOT(sanitizeMinStay())); connect(rndSeqBox, SIGNAL(stateChanged(int)), this, SLOT(turnOffUniq())); connect(repModeBox, SIGNAL(activated(const QString&)), this, SLOT(changeRepMode())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked())); connect(okButton, SIGNAL(clicked()), this, SLOT(okClicked())); // connect(defaultsButton, SIGNAL(clicked()), this, SLOT(resetConfig())); // Set default fonts for popups fntCaption = new QFont(); fntCaption->setBold(TRUE); kFontRequester1->setFont(*fntCaption); fntBody = new QFont(); kFontRequester2->setFont(*fntBody); // Set default fonts for popups tmpFgColor = new QColor(this->foregroundColor()); tmpBgColor = new QColor(this->backgroundColor()); fgCol->setColor(this->foregroundColor()); bgCol->setColor(this->backgroundColor()); this->_readConfig(); this->show(); }
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; }
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 ); } }
//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()); }