void TaskJuggler::enableActions(bool enable) { if (!enable) enabledActionsBuf.clear(); KActionPtrList actionList = actionCollection()->actions(); for (KActionPtrList::iterator it = actionList.begin(); it != actionList.end(); ++it) { /* The "stop" action will be handled opposite to all other actions. */ if (strcmp((*it)->name(), "stop") == 0) { (*it)->setEnabled(!enable); continue; } if (enable) { if (enabledActionsBuf.find((*it)->name()) != enabledActionsBuf.end()) (*it)->setEnabled(true); } else { if ((*it)->isEnabled()) { enabledActionsBuf.insert((*it)->name()); (*it)->setEnabled(false); } } } }
void Slider::contextMenuEvent(QContextMenuEvent *e) { QWidget * childWidget = directChildAt(e->pos()); _currentApplet = childWidget ? findApplet(childWidget) : 0L; if (_currentApplet) { if (_appletMenu) delete _appletMenu; _appletMenu = new KActionMenu(_currentApplet->name(), this, "AppletMenu"); KActionPtrList actionList = _currentApplet->contextActions(childWidget, e->pos()); KActionPtrList::Iterator iter; for (iter = actionList.begin(); iter != actionList.end(); iter++) _appletMenu->insert(*iter); _appletMenu->insert(_removeAppletAction); _appletMenu->popup(e->globalPos()); } else _hostMenu->popup(e->globalPos()); e->accept(); }
static bool shortcutIsValid(const KActionCollection *actionCollection, const KShortcut &sc) { KActionPtrList actions = actionCollection->actions(); KActionPtrList::Iterator it(actions.begin()); for(; it != actions.end(); it++) { if((*it)->shortcut() == sc) return false; } return true; }
void LapsusPanelMain::showContextMenu() { _popMenu = new KPopupMenu( this ); _popMenu->insertTitle( SmallIcon( "laptop" ), i18n("Switches") ); KActionPtrList list = _actions->actions(); qHeapSort( list ); if (list.size() > 0) { for(KActionPtrList::iterator it = list.begin(); it != list.end(); ++it) { (*it)->plug(_popMenu); } } QPoint pos = QCursor::pos(); _popMenu->popup( pos ); }
/** * Create the amarok gui from the xml file. */ void PlaylistWindow::createGUI() { setUpdatesEnabled( false ); m_toolbar->clear(); //KActions don't unplug themselves when the widget that is plugged is deleted! //we need to unplug to detect if the menu is plugged in App::applySettings() //TODO report to bugs.kde.org //we unplug after clear as otherwise it crashes! dunno why.. KActionPtrList actions = actionCollection()->actions(); for( KActionPtrList::Iterator it = actions.begin(), end = actions.end(); it != end; ++it ) { (*it)->unplug( m_toolbar ); } KXMLGUIBuilder builder( this ); KXMLGUIFactory factory( &builder, this ); //build Toolbar, plug actions factory.addClient( this ); //TEXT ON RIGHT HACK //KToolBarButtons have independent settings for their appearance. //KToolBarButton::modeChange() causes that button to set its mode to that of its parent KToolBar //KToolBar::setIconText() calls modeChange() for children, unless 2nd param is false QStringList list; list << "toolbutton_playlist_add" // << "toolbutton_playlist_clear" // << "toolbutton_playlist_shuffle" // << "toolbutton_playlist_show" << "toolbutton_burn_menu" << "toolbutton_amarok_menu"; m_toolbar->setIconText( KToolBar::IconTextRight, false ); //we want some buttons to have text on right const QStringList::ConstIterator end = list.constEnd(); const QStringList::ConstIterator last = list.fromLast(); for( QStringList::ConstIterator it = list.constBegin(); it != end; ++it ) { KToolBarButton* const button = static_cast<KToolBarButton*>( m_toolbar->child( (*it).latin1() ) ); if ( it == last ) { //if the user has no PlayerWindow, he MUST have the menu action plugged //NOTE this is not saved to the local XMLFile, which is what the user will want if ( !AmarokConfig::showPlayerWindow() && !AmarokConfig::showMenuBar() && !button ) actionCollection()->action( "amarok_menu" )->plug( m_toolbar ); } if ( button ) { button->modeChange(); button->setFocusPolicy( QWidget::NoFocus ); } } if ( AmarokConfig::showMenuBar() ) { if ( actionCollection()->action( "amarok_menu" )->isPlugged() ) actionCollection()->action( "amarok_menu" )->unplugAll(); } m_toolbar->setIconText( KToolBar::IconOnly, false ); //default appearance conserveMemory(); setUpdatesEnabled( true ); }