safer way of creating actions, according to mjansen
svn path=/trunk/KDE/kdelibs/; revision=963095
This commit is contained in:
parent
0768ea626d
commit
233e220ad9
@ -1417,15 +1417,15 @@ KActionCollection* AppletPrivate::defaultActions(QObject *parent)
|
|||||||
KActionCollection *actions = new KActionCollection(parent);
|
KActionCollection *actions = new KActionCollection(parent);
|
||||||
actions->setConfigGroup("Shortcuts-Applet");
|
actions->setConfigGroup("Shortcuts-Applet");
|
||||||
|
|
||||||
KAction *configAction = new KAction(i18n("Widget Settings"), actions);
|
KAction *configAction = actions->addAction("configure");
|
||||||
|
configAction->setText(i18n("Widget Settings"));
|
||||||
configAction->setIcon(KIcon("configure"));
|
configAction->setIcon(KIcon("configure"));
|
||||||
configAction->setShortcut(KShortcut("alt+d, s"));
|
configAction->setShortcut(KShortcut("alt+d, s"));
|
||||||
actions->addAction("configure", configAction);
|
|
||||||
|
|
||||||
KAction *closeApplet = new KAction("Remove this Widget", actions);
|
KAction *closeApplet = actions->addAction("remove");
|
||||||
|
closeApplet->setText("Remove this Widget");
|
||||||
closeApplet->setIcon(KIcon("edit-delete"));
|
closeApplet->setIcon(KIcon("edit-delete"));
|
||||||
closeApplet->setShortcut(KShortcut("alt+d, r"));
|
closeApplet->setShortcut(KShortcut("alt+d, r"));
|
||||||
actions->addAction("remove", closeApplet);
|
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
@ -226,26 +226,26 @@ void ContainmentPrivate::addDefaultActions(KActionCollection *actions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//add our own actions
|
//add our own actions
|
||||||
KAction *appletBrowserAction = new KAction(i18n("Add Widgets..."), actions);
|
KAction *appletBrowserAction = actions->addAction("add widgets");
|
||||||
|
appletBrowserAction->setText(i18n("Add Widgets..."));
|
||||||
appletBrowserAction->setIcon(KIcon("list-add"));
|
appletBrowserAction->setIcon(KIcon("list-add"));
|
||||||
appletBrowserAction->setShortcut(KShortcut("alt+d, a"));
|
appletBrowserAction->setShortcut(KShortcut("alt+d, a"));
|
||||||
actions->addAction("add widgets", appletBrowserAction);
|
|
||||||
|
|
||||||
KAction *action = new KAction(i18n("Next Widget"), actions);
|
KAction *action = actions->addAction("next applet");
|
||||||
|
action->setText(i18n("Next Widget"));
|
||||||
//no icon
|
//no icon
|
||||||
action->setShortcut(KShortcut("alt+d, n"));
|
action->setShortcut(KShortcut("alt+d, n"));
|
||||||
actions->addAction("next applet", action);
|
|
||||||
|
|
||||||
action = new KAction(i18n("Previous Widget"), actions);
|
action = actions->addAction("previous applet");
|
||||||
|
action->setText(i18n("Previous Widget"));
|
||||||
//no icon
|
//no icon
|
||||||
action->setShortcut(KShortcut("alt+d, p"));
|
action->setShortcut(KShortcut("alt+d, p"));
|
||||||
actions->addAction("previous applet", action);
|
|
||||||
|
|
||||||
KAction *zoomAction = new KAction(i18n("Zoom In"), actions);
|
KAction *zoomAction = actions->addAction("zoom in");
|
||||||
|
zoomAction->setText(i18n("Zoom In"));
|
||||||
zoomAction->setIcon(KIcon("zoom-in"));
|
zoomAction->setIcon(KIcon("zoom-in"));
|
||||||
//two shortcuts because I hate ctrl-+ but others expect it
|
//two shortcuts because I hate ctrl-+ but others expect it
|
||||||
zoomAction->setShortcuts(KShortcut("alt+d, +; alt+d, ="));
|
zoomAction->setShortcuts(KShortcut("alt+d, +; alt+d, ="));
|
||||||
actions->addAction("zoom in", zoomAction);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
corona.cpp
13
corona.cpp
@ -84,24 +84,24 @@ public:
|
|||||||
//some common actions
|
//some common actions
|
||||||
actions.setConfigGroup("Shortcuts");
|
actions.setConfigGroup("Shortcuts");
|
||||||
|
|
||||||
KAction *lockAction = new KAction(i18n("Lock Widgets"), q);
|
KAction *lockAction = actions.addAction("lock widgets");
|
||||||
|
lockAction->setText(i18n("Lock Widgets"));
|
||||||
lockAction->setIcon(KIcon("object-locked"));
|
lockAction->setIcon(KIcon("object-locked"));
|
||||||
QObject::connect(lockAction, SIGNAL(triggered(bool)),
|
QObject::connect(lockAction, SIGNAL(triggered(bool)),
|
||||||
q, SLOT(toggleImmutability()));
|
q, SLOT(toggleImmutability()));
|
||||||
lockAction->setShortcut(KShortcut("alt+d, l"));
|
lockAction->setShortcut(KShortcut("alt+d, l"));
|
||||||
lockAction->setShortcutContext(Qt::ApplicationShortcut);
|
lockAction->setShortcutContext(Qt::ApplicationShortcut);
|
||||||
actions.addAction("lock widgets", lockAction);
|
|
||||||
|
|
||||||
//FIXME this doesn't really belong here. desktop KCM maybe?
|
//FIXME this doesn't really belong here. desktop KCM maybe?
|
||||||
//but should the shortcuts be per-app or really-global?
|
//but should the shortcuts be per-app or really-global?
|
||||||
//I don't know how to make kactioncollections use plasmarc
|
//I don't know how to make kactioncollections use plasmarc
|
||||||
KAction *action = new KAction(i18n("Shortcut Settings"), q);
|
KAction *action = actions.addAction("configure shortcuts");
|
||||||
|
action->setText(i18n("Shortcut Settings"));
|
||||||
action->setIcon(KIcon("configure"));
|
action->setIcon(KIcon("configure"));
|
||||||
QObject::connect(action, SIGNAL(triggered()),
|
QObject::connect(action, SIGNAL(triggered()),
|
||||||
q, SLOT(showShortcutConfig()));
|
q, SLOT(showShortcutConfig()));
|
||||||
//action->setShortcut(KShortcut("ctrl+h"));
|
//action->setShortcut(KShortcut("ctrl+h"));
|
||||||
action->setShortcutContext(Qt::ApplicationShortcut);
|
action->setShortcutContext(Qt::ApplicationShortcut);
|
||||||
actions.addAction("configure shortcuts", action);
|
|
||||||
|
|
||||||
actions.readSettings();
|
actions.readSettings();
|
||||||
|
|
||||||
@ -685,6 +685,11 @@ void Corona::addAction(QString name, QAction *action)
|
|||||||
d->actions.addAction(name, action);
|
d->actions.addAction(name, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KAction* Corona::addAction(QString name)
|
||||||
|
{
|
||||||
|
return d->actions.addAction(name);
|
||||||
|
}
|
||||||
|
|
||||||
QList<QAction*> Corona::actions() const
|
QList<QAction*> Corona::actions() const
|
||||||
{
|
{
|
||||||
return d->actions.actions();
|
return d->actions.actions();
|
||||||
|
11
corona.h
11
corona.h
@ -30,6 +30,8 @@
|
|||||||
class QGraphicsGridLayout;
|
class QGraphicsGridLayout;
|
||||||
class QAction;
|
class QAction;
|
||||||
|
|
||||||
|
class KAction;
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -201,6 +203,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
void addShortcuts(KActionCollection *newShortcuts);
|
void addShortcuts(KActionCollection *newShortcuts);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 4.3
|
||||||
|
* Creates an action in our collection under the given name
|
||||||
|
* @return the new action
|
||||||
|
* FIXME I'm wrapping so much of kactioncollection API now, maybe I should just expose the
|
||||||
|
* collection itself :P
|
||||||
|
*/
|
||||||
|
KAction* addAction(QString name);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Initializes the layout from a config file. This will first clear any existing
|
* Initializes the layout from a config file. This will first clear any existing
|
||||||
|
Loading…
Reference in New Issue
Block a user