QPopupMenu *KEdit::createPopupMenu(const QPoint &pos) { enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll }; QPopupMenu *menu = QMultiLineEdit::createPopupMenu(pos); if(isReadOnly()) menu->changeItem(menu->idAt(0), SmallIconSet("editcopy"), menu->text(menu->idAt(0))); else { int id = menu->idAt(0); menu->changeItem(id - IdUndo, SmallIconSet("undo"), menu->text(id - IdUndo)); menu->changeItem(id - IdRedo, SmallIconSet("redo"), menu->text(id - IdRedo)); menu->changeItem(id - IdCut, SmallIconSet("editcut"), menu->text(id - IdCut)); menu->changeItem(id - IdCopy, SmallIconSet("editcopy"), menu->text(id - IdCopy)); menu->changeItem(id - IdPaste, SmallIconSet("editpaste"), menu->text(id - IdPaste)); menu->changeItem(id - IdClear, SmallIconSet("editclear"), menu->text(id - IdClear)); } return menu; }
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 ); } }