void Monitor::mousePressEvent(QMouseEvent* e) { if (e->button() & RightButton) { QString dir; _app->settings()->get(KEY_SYSTEM_DIR, dir); dir += QString("/") + PIXMAPPATH; QPopupMenu* menu; menu = new QPopupMenu; menu->setCheckable(false); QPopupMenu* displayMenu; displayMenu = new QPopupMenu(); displayMenu->setCheckable(true); displayMenu->insertItem("&Absolute", ID_ABSOLUTE); displayMenu->insertItem("&Relative to Device", ID_RELATIVE); displayMenu->setItemChecked(s_displayStyle, true); QPopupMenu* speedMenu; speedMenu = new QPopupMenu(); speedMenu->setCheckable(true); speedMenu->insertItem("16Hz", ID_16HZ); speedMenu->insertItem("32Hz", ID_32HZ); speedMenu->insertItem("64Hz", ID_64HZ); speedMenu->setItemChecked(s_updateFrequency, true); menu->insertItem(QPixmap(dir + "/monitor.xpm"), "Channel &Display", displayMenu); menu->insertItem(QPixmap(dir + "/clock.xpm"), "&Update Speed", speedMenu); menu->insertSeparator(); menu->insertItem(QPixmap(dir + "/move.xpm"), "&Resize to Default", ID_RESIZE_SQUARE); menu->insertItem(QPixmap(dir + "/rename.xpm"), "Choose &Font", ID_CHOOSE_FONT); connect(menu, SIGNAL(activated(int)), this, SLOT(slotMenuCallback(int))); connect(displayMenu, SIGNAL(activated(int)), this, SLOT(slotMenuCallback(int))); connect(speedMenu, SIGNAL(activated(int)), this, SLOT(slotMenuCallback(int))); menu->exec(mapToGlobal(e->pos())); delete displayMenu; delete speedMenu; delete menu; }
QPopupMenu* KDiffTextEdit::createPopupMenu( const QPoint& p ) { QPopupMenu* popup = QTextEdit::createPopupMenu( p ); if ( !popup ) popup = new QPopupMenu( this ); int i = 0; for ( QStringList::Iterator it = extPartsTranslated.begin(); it != extPartsTranslated.end(); ++it ) { popup->insertItem( i18n( "Show in %1" ).arg( *it ), i + POPUP_BASE, i ); i++; } if ( !extPartsTranslated.isEmpty() ) popup->insertSeparator( i ); connect( popup, SIGNAL(activated(int)), this, SLOT(popupActivated(int)) ); popup->insertItem( SmallIconSet( "filesaveas" ), i18n( "&Save As..." ), this, SLOT(saveAs()), CTRL + Key_S, POPUP_BASE - 2, 0 ); popup->setItemEnabled( POPUP_BASE - 2, length() > 0 ); popup->insertSeparator( 1 ); popup->insertItem( i18n( "Highlight Syntax" ), this, SLOT(toggleSyntaxHighlight()), 0, POPUP_BASE - 1, 2 ); popup->setItemChecked( POPUP_BASE - 1, _highlight ); popup->insertSeparator( 3 ); popup->insertSeparator(); popup->insertItem( i18n("Hide view"), parent(), SLOT(hideView()) ); return popup; }
QPopupMenu *KRomajiEdit::createPopupMenu() { QPopupMenu *popup = KLineEdit::createPopupMenu(); popup->insertSeparator(); popup->insertItem(i18n("English"), 0); popup->insertItem(i18n("Kana"), 1); if (kana == "english") popup->setItemChecked(0, true); else if (kana == "hiragana") popup->setItemChecked(1, true); connect(popup, SIGNAL(activated(int)), SLOT(setKana(int))); emit aboutToShowContextMenu(popup); return popup; }
wmMenuWidget::wmMenuWidget( QWidget *parent, const char *name ) : QWidget( parent, name ){ QPopupMenu *file = new QPopupMenu; CHECK_PTR( file ); file->insertItem( "Run", this, SLOT(run()) ); file->insertItem( "Restart", this, SLOT(restart()) ); file->insertItem( "Exit", kapp , SLOT(quit()) ); view = new QPopupMenu; CHECK_PTR( view ); view->insertItem( "Page 1", this, SLOT(page1()) ); view->insertItem( "Page 2", this, SLOT(page2()) ); view->insertItem( "Page 3", this, SLOT(page3()) ); view->insertItem( "Page 4", this, SLOT(page4()) ); QPopupMenu *help = new QPopupMenu; CHECK_PTR( help ); help->insertItem( "KWM Help", this, SLOT(kwmhelp()) ); help->insertSeparator(); help->insertItem( "About", this, SLOT(about()) ); windows = new QPopupMenu; CHECK_PTR( help ); QPopupMenu *options = new QPopupMenu; CHECK_PTR( help ); int checkT = options->insertItem( "Transparent Move", this, SLOT(transpMove()) ); options->setItemChecked(checkT,TRUE); int checkO = options->insertItem( "Opaque Move", this, SLOT(opaqueMove()) ); options->insertItem( "Titlebar", this, SLOT(changeTitlebar()) ); // options->insertSeparator(); // int enableSO = options->insertItem( "Save Options", kapp, SLOT(saveOptions()) ); // options->setItemEnabled( enableSO, FALSE); menu = new QMenuBar( this ); CHECK_PTR( menu ); menu->insertItem( "File", file ); menu->insertItem( "View", view ); menu->insertItem( "Windows", windows ); menu->insertItem( "Options", options ); menu->insertSeparator(); menu->insertItem( "Help", help ); menu->setGeometry( 0, 0, 300, 22); setGeometry(0,0,308,28); } /* end wmMenuWidget::wmMenuWidget */
QPopupMenu *KLineEdit::createPopupMenu() { enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll }; QPopupMenu *popup = QLineEdit::createPopupMenu(); int id = popup->idAt(0); popup->changeItem( id - IdUndo, SmallIconSet("undo"), popup->text( id - IdUndo) ); popup->changeItem( id - IdRedo, SmallIconSet("redo"), popup->text( id - IdRedo) ); popup->changeItem( id - IdCut, SmallIconSet("editcut"), popup->text( id - IdCut) ); popup->changeItem( id - IdCopy, SmallIconSet("editcopy"), popup->text( id - IdCopy) ); popup->changeItem( id - IdPaste, SmallIconSet("editpaste"), popup->text( id - IdPaste) ); popup->changeItem( id - IdClear, SmallIconSet("editclear"), popup->text( id - IdClear) ); // If a completion object is present and the input // widget is not read-only, show the Text Completion // menu item. if ( compObj() && !isReadOnly() && kapp->authorize("lineedit_text_completion") ) { QPopupMenu *subMenu = new QPopupMenu( popup ); connect( subMenu, SIGNAL( activated( int ) ), this, SLOT( completionMenuActivated( int ) ) ); popup->insertSeparator(); popup->insertItem( SmallIconSet("completion"), i18n("Text Completion"), subMenu ); subMenu->insertItem( i18n("None"), NoCompletion ); subMenu->insertItem( i18n("Manual"), ShellCompletion ); subMenu->insertItem( i18n("Automatic"), AutoCompletion ); subMenu->insertItem( i18n("Dropdown List"), PopupCompletion ); subMenu->insertItem( i18n("Short Automatic"), ShortAutoCompletion ); subMenu->insertItem( i18n("Dropdown List && Automatic"), PopupAutoCompletion ); subMenu->setAccel( KStdAccel::completion(), ShellCompletion ); KGlobalSettings::Completion mode = completionMode(); subMenu->setItemChecked( NoCompletion, mode == KGlobalSettings::CompletionNone ); subMenu->setItemChecked( ShellCompletion, mode == KGlobalSettings::CompletionShell ); subMenu->setItemChecked( PopupCompletion, mode == KGlobalSettings::CompletionPopup ); subMenu->setItemChecked( AutoCompletion, mode == KGlobalSettings::CompletionAuto ); subMenu->setItemChecked( ShortAutoCompletion, mode == KGlobalSettings::CompletionMan ); subMenu->setItemChecked( PopupAutoCompletion, mode == KGlobalSettings::CompletionPopupAuto ); if ( mode != KGlobalSettings::completionMode() ) { subMenu->insertSeparator(); subMenu->insertItem( i18n("Default"), Default ); } }
void KOEditorFreeBusy::showAttendeeStatusMenu() { if ( mGanttView->mapFromGlobal( QCursor::pos() ).x() > 22 ) return; QPopupMenu popup; popup.insertItem( SmallIcon( "help" ), Attendee::statusName( Attendee::NeedsAction ), Attendee::NeedsAction ); popup.insertItem( KOGlobals::self()->smallIcon( "ok" ), Attendee::statusName( Attendee::Accepted ), Attendee::Accepted ); popup.insertItem( KOGlobals::self()->smallIcon( "no" ), Attendee::statusName( Attendee::Declined ), Attendee::Declined ); popup.insertItem( KOGlobals::self()->smallIcon( "apply" ), Attendee::statusName( Attendee::Tentative ), Attendee::Tentative ); popup.insertItem( KOGlobals::self()->smallIcon( "mail_forward" ), Attendee::statusName( Attendee::Delegated ), Attendee::Delegated ); popup.insertItem( Attendee::statusName( Attendee::Completed ), Attendee::Completed ); popup.insertItem( KOGlobals::self()->smallIcon( "help" ), Attendee::statusName( Attendee::InProcess ), Attendee::InProcess ); popup.setItemChecked( currentAttendee()->status(), true ); int status = popup.exec( QCursor::pos() ); if ( status >= 0 ) { currentAttendee()->setStatus( (Attendee::PartStat)status ); updateCurrentItem(); updateAttendeeInput(); } }
QPopupMenu *KOTodoView::getCategoryPopupMenu( KOTodoViewItem *todoItem ) { QPopupMenu *tempMenu = new QPopupMenu( this ); QStringList checkedCategories = todoItem->todo()->categories(); tempMenu->setCheckable( true ); QStringList::Iterator it; for ( it = KOPrefs::instance()->mCustomCategories.begin(); it != KOPrefs::instance()->mCustomCategories.end(); ++it ) { int index = tempMenu->insertItem( *it ); mCategory[ index ] = *it; if ( checkedCategories.find( *it ) != checkedCategories.end() ) tempMenu->setItemChecked( index, true ); } connect ( tempMenu, SIGNAL( activated( int ) ), SLOT( changedCategories( int ) ) ); return tempMenu; }
Main::Main(QCanvas& c, QWidget* parent, const char* name, WFlags f) : QMainWindow(parent,name,f), canvas(c) { editor = new FigureEditor(canvas,this); // 繼承canvas view而來 QMenuBar* menu = menuBar(); QPopupMenu* file = new QPopupMenu( menu ); // 當parent被刪除,則子類別也會被刪除 file->insertItem("&Fill canvas", this, SLOT(init()), CTRL+Key_F); file->insertItem("&Erase canvas", this, SLOT(clear()), CTRL+Key_E); file->insertItem("&New view", this, SLOT(newView()), CTRL+Key_N); file->insertSeparator(); file->insertItem("&Print...", this, SLOT(print()), CTRL+Key_P); file->insertSeparator(); file->insertItem("E&xit", qApp, SLOT(quit()), CTRL+Key_Q); menu->insertItem("&File", file); // 建立一個工具列名為File的label QPopupMenu* edit = new QPopupMenu( menu ); edit->insertItem("Add &Circle", this, SLOT(addCircle()), ALT+Key_C); edit->insertItem("Add &Hexagon", this, SLOT(addHexagon()), ALT+Key_H); edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), ALT+Key_P); edit->insertItem("Add Spl&ine", this, SLOT(addSpline()), ALT+Key_I); edit->insertItem("Add &Text", this, SLOT(addText()), ALT+Key_T); edit->insertItem("Add &Line", this, SLOT(addLine()), ALT+Key_L); edit->insertItem("Add &Rectangle", this, SLOT(addRectangle()), ALT+Key_R); edit->insertItem("Add &Sprite", this, SLOT(addSprite()), ALT+Key_S); edit->insertItem("Create &Mesh", this, SLOT(addMesh()), ALT+Key_M ); edit->insertItem("Add &Alpha-blended image", this, SLOT(addButterfly()), ALT+Key_A); menu->insertItem("&Edit", edit); QPopupMenu* view = new QPopupMenu( menu ); view->insertItem("&Enlarge", this, SLOT(enlarge()), SHIFT+CTRL+Key_Plus); view->insertItem("Shr&ink", this, SLOT(shrink()), SHIFT+CTRL+Key_Minus); view->insertSeparator(); view->insertItem("&Rotate clockwise", this, SLOT(rotateClockwise()), CTRL+Key_PageDown); view->insertItem("Rotate &counterclockwise", this, SLOT(rotateCounterClockwise()), CTRL+Key_PageUp); view->insertItem("&Zoom in", this, SLOT(zoomIn()), CTRL+Key_Plus); view->insertItem("Zoom &out", this, SLOT(zoomOut()), CTRL+Key_Minus); view->insertItem("Translate left", this, SLOT(moveL()), CTRL+Key_Left); view->insertItem("Translate right", this, SLOT(moveR()), CTRL+Key_Right); view->insertItem("Translate up", this, SLOT(moveU()), CTRL+Key_Up); view->insertItem("Translate down", this, SLOT(moveD()), CTRL+Key_Down); view->insertItem("&Mirror", this, SLOT(mirror()), CTRL+Key_Home); menu->insertItem("&View", view); options = new QPopupMenu( menu ); dbf_id = options->insertItem("Double buffer", this, SLOT(toggleDoubleBuffer())); options->setItemChecked(dbf_id, TRUE); menu->insertItem("&Options",options); menu->insertSeparator(); QPopupMenu* help = new QPopupMenu( menu ); help->insertItem("&About", this, SLOT(help()), Key_F1); help->setItemChecked(dbf_id, TRUE); // 很奇怪,當TRUE時,把dbf_id打勾,不懂 menu->insertItem("&Help",help); statusBar(); // 返回這個窗口的狀態條。如果沒有的話 // statusBar()會創建一個空的狀態條,並且如果需要也創建一個工具提示組。 setCentralWidget(editor); printer = 0; init(); }
void kdvi::makeMenuBar() { if (menuBar) delete menuBar; menuBar = new KMenuBar( this ); CHECK_PTR( menuBar ); QPopupMenu *p = new QPopupMenu; CHECK_PTR( p ); m_fn = p->insertItem( i18n("&New"), this, SLOT(fileNew()) ); m_fo = p->insertItem( i18n("&Open ..."), this, SLOT(fileOpen()) ); recentmenu = new QPopupMenu; CHECK_PTR( recentmenu ); connect( recentmenu, SIGNAL(activated(int)), SLOT(openRecent(int)) ); m_fr = p->insertItem( i18n("Open &recent"), recentmenu ); m_fp = p->insertItem( i18n("&Print ..."), this, SLOT(filePrint())); m_fx = p->insertItem( i18n("E&xit"), this, SLOT(fileExit())); m_f = p; menuBar->insertItem( i18n("&File"), p, -2 ); p = new QPopupMenu; CHECK_PTR( p ); m_vi = p->insertItem( i18n("Zoom &in"), dviwin, SLOT(prevShrink()) ); m_vo = p->insertItem( i18n("Zoom &out"), dviwin, SLOT(nextShrink()) ); m_vf = p->insertItem( i18n("&Fit to page"), this, SLOT(viewFitPage()) ); m_vw = p->insertItem( i18n("Fit to page &width"), this, SLOT(viewFitPageWidth())); p->insertSeparator(); m_vr = p->insertItem( i18n("&Redraw page"), dviwin, SLOT(drawPage()) ); m_v = p; menuBar->insertItem( i18n("&View"), p, -2 ); p = new QPopupMenu; CHECK_PTR( p ); m_pp = p->insertItem( i18n("&Previous"), dviwin, SLOT(prevPage()) ); m_pn = p->insertItem( i18n("&Next"), dviwin, SLOT(nextPage()) ); m_pf = p->insertItem( i18n("&First"), dviwin, SLOT(firstPage()) ); m_pl = p->insertItem( i18n("&Last"), dviwin, SLOT(lastPage()) ); m_pg = p->insertItem( i18n("&Go to ..."), this, SLOT(pageGoto()) ); m_p = p; menuBar->insertItem( i18n("&Page"), p, -2 ); p = new QPopupMenu; CHECK_PTR( p ); p->setCheckable( TRUE ); m_op = p->insertItem( i18n("&Preferences ..."), this, SLOT(optionsPreferences())); m_ok = p->insertItem( i18n("&Keys ..."), this, SLOT(configKeys())); p->insertSeparator(); m_of = p->insertItem( i18n("Make PK-&fonts"), this, SLOT(toggleMakePK()) ); p->setItemChecked( m_of, makepk ); m_o0 = p->insertItem( i18n("Show PS"), this, SLOT(toggleShowPS())); p->setItemChecked( m_o0, showPS ); m_om = p->insertItem( i18n("Show &Menubar"), this, SLOT(toggleShowMenubar()) ); p->setItemChecked( m_om, !hideMenubar ); m_ob = p->insertItem( i18n("Show &Buttons"), this, SLOT(toggleShowButtons()) ); p->setItemChecked( m_ob, !hideButtons ); m_ot = p->insertItem( i18n("Show Page Lis&t"), this, SLOT(toggleVertToolbar()) ); p->setItemChecked( m_ol, vertToolbar ); m_os = p->insertItem( i18n("Show &Statusbar"), this, SLOT(toggleShowStatusbar()) ); p->setItemChecked( m_os, !hideStatusbar ); m_ol = p->insertItem( i18n("Show Scro&llbars"), this, SLOT(toggleShowScrollbars()) ); p->setItemChecked( m_ol, !hideScrollbars ); m_o = p; menuBar->insertItem( i18n("&Options"), p, -2 ); optionsmenu = p; menuBar->insertSeparator(); QPopupMenu *help = kapp->getHelpMenu(true, QString(i18n("DVI Viewer")) + " " + KDVI_VERSION + i18n("\n\nby Markku Hihnala") + " ([email protected])"); m_h = p; menuBar->insertItem( i18n("&Help"), help ); if ( hideMenubar ) menuBar->hide(); setMenu( menuBar ); }