コード例 #1
0
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();
}
コード例 #2
0
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);
            }
        }
    }
}
コード例 #3
0
ファイル: mainwindow.cpp プロジェクト: scim-im/skim
void MainWindow::updateProperties (bool isFrontEndProperties) {
    KActionPtrList exta = isFrontEndProperties ?
            m_defaultActionCollection->frontendPropertyActions() : m_defaultActionCollection->guiPropertyActions();
    m_actionListName = isFrontEndProperties ? ACTIONLIST_FRONTEND : ACTIONLIST_GUI;

    m_insertedActions.clear();
    for(uint i=0; i<exta.size(); i++) {
        bool visible = true;
        if(ScimAction * action = dynamic_cast<ScimAction *>(exta[i])){
            if(!action->visible() || !action->currentShown())
                visible = false;
        }
        if(visible)
            m_insertedActions.append(exta[i]);
    }

    if(m_insertedActions.count())
        m_updatePropertiesNeeded = true;

    unplugActionList(m_actionListName);

    if(m_updatePropertiesNeeded && m_contentIsVisible)
        show();

    //FIXME: see the FIXME in MainWindow::show()
    if(isVisible())
        QTimer::singleShot( 100, this, SLOT( adjustSize() ) );
}
コード例 #4
0
ファイル: snippetdlg.cpp プロジェクト: serghei/kde3-kdepim
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;
}
コード例 #5
0
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 );
}
コード例 #6
0
ファイル: playlistwindow.cpp プロジェクト: tmarques/waheela
/**
 * 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 );
}
コード例 #7
0
void KKbdAccessExtensions::displayAccessKeys()
{
    // Build a list of valid access keys that don't collide with shortcuts.
    QString availableAccessKeys = "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
    QPtrList<KXMLGUIClient> allClients = d->mainWindow->factory()->clients();
    QPtrListIterator<KXMLGUIClient> it( allClients );
    KXMLGUIClient *client;
    while( (client=it.current()) !=0 )
    {
        ++it;
        KActionPtrList actions = client->actionCollection()->actions();
        for (int j = 0; j < (int)actions.count(); j++) {
            KAction* action = actions[j];
            KShortcut sc = action->shortcut();
            for (int i = 0; i < (int)sc.count(); i++) {
                KKeySequence seq = sc.seq(i);
                if (seq.count() == 1) {
                    QString s = seq.toString();
                    if (availableAccessKeys.contains(s))
                        availableAccessKeys.remove(s);
                }
            }
        }
    }
    // Find all visible, focusable widgets and create a QLabel for each.  Don't exceed
    // available list of access keys.
    QWidgetList* allWidgets = kapp->allWidgets();
    QWidget* widget = allWidgets->first();
    int accessCount = 0;
    int maxAccessCount = availableAccessKeys.length();
    int overlap = 20;
    QPoint prevGlobalPos = QPoint(-overlap, -overlap);
    while (widget && (accessCount < maxAccessCount)) {
        if (widget->isVisible() && widget->isFocusEnabled() ) {
            QRect r = widget->rect();
            QPoint p(r.x(), r.y());
            // Don't display an access key if within overlap pixels of previous one.
            QPoint globalPos = widget->mapToGlobal(p);
            QPoint diffPos = globalPos - prevGlobalPos;
            if (diffPos.manhattanLength() > overlap) {
                accessCount++;
                QLabel* lab=new QLabel(widget, "", widget, 0, Qt::WDestructiveClose);
                lab->setPalette(QToolTip::palette());
                lab->setLineWidth(2);
                lab->setFrameStyle(QFrame::Box | QFrame::Plain);
                lab->setMargin(3);
                lab->adjustSize();
                lab->move(p);
                if (!d->accessKeyLabels) {
                    d->accessKeyLabels = new QPtrList<QLabel>;
                    d->accessKeyLabels->setAutoDelete(true);
                }
                d->accessKeyLabels->append(lab);
                prevGlobalPos = globalPos;
            }
        }
        widget = allWidgets->next();
    }
    if (accessCount > 0) {
        // Sort the access keys from left to right and down the screen.
        QValueList<KSortedLabel> sortedLabels;
        for (int i = 0; i < accessCount; i++)
            sortedLabels.append(KSortedLabel(d->accessKeyLabels->at(i)));
        qHeapSort( sortedLabels );
        // Assign access key labels.
        for (int i = 0; i < accessCount; i++) {
            QLabel* lab = sortedLabels[i].label();
            QChar s = availableAccessKeys[i];
            lab->setText(s);
            lab->adjustSize();
            lab->show();
        }
    }
}