plasma: create key sequence objects from the key enums

create QKeySequence from string involves decoding the string (splitting it
into bits and pieces and matching it to a well known list of strings and
then create integer out of the decoded bits which is sub-optimal

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-30 20:48:43 +03:00
parent e418ca826b
commit a2530529a4
3 changed files with 13 additions and 13 deletions

View file

@ -1673,21 +1673,21 @@ KActionCollection* AppletPrivate::defaultActions(QObject *parent)
configAction->setAutoRepeat(false);
configAction->setText(i18n("Widget Settings"));
configAction->setIcon(KIcon("configure"));
configAction->setShortcut(KShortcut("alt+s"));
configAction->setShortcut(KShortcut(Qt::ALT + Qt::Key_S));
configAction->setData(AbstractToolBox::ConfigureTool);
KAction *closeApplet = actions->addAction("remove");
closeApplet->setAutoRepeat(false);
closeApplet->setText(i18n("Remove this Widget"));
closeApplet->setIcon(KIcon("edit-delete"));
closeApplet->setShortcut(KShortcut("alt+r"));
closeApplet->setShortcut(KShortcut(Qt::ALT + Qt::Key_R));
closeApplet->setData(AbstractToolBox::DestructiveTool);
KAction *runAssociatedApplication = actions->addAction("run associated application");
runAssociatedApplication->setAutoRepeat(false);
runAssociatedApplication->setText(i18n("Run the Associated Application"));
runAssociatedApplication->setIcon(KIcon("system-run"));
runAssociatedApplication->setShortcut(KShortcut("alt+t"));
runAssociatedApplication->setShortcut(KShortcut(Qt::ALT + Qt::Key_T));
runAssociatedApplication->setVisible(false);
runAssociatedApplication->setEnabled(false);
runAssociatedApplication->setData(AbstractToolBox::ControlTool);

View file

@ -230,7 +230,7 @@ void ContainmentPrivate::addDefaultActions(KActionCollection *actions, Containme
//adjust applet actions
KAction *appAction = qobject_cast<KAction*>(actions->action("remove"));
appAction->setShortcut(KShortcut("alt+r"));
appAction->setShortcut(KShortcut(Qt::ALT + Qt::Key_R));
if (c && c->d->isPanelContainment()) {
appAction->setText(i18n("Remove this Panel"));
}
@ -240,19 +240,19 @@ void ContainmentPrivate::addDefaultActions(KActionCollection *actions, Containme
appletBrowserAction->setAutoRepeat(false);
appletBrowserAction->setText(i18n("Add Widgets..."));
appletBrowserAction->setIcon(KIcon("list-add"));
appletBrowserAction->setShortcut(KShortcut("alt+a"));
appletBrowserAction->setShortcut(KShortcut(Qt::ALT + Qt::Key_A));
appletBrowserAction->setData(AbstractToolBox::AddTool);
KAction *action = actions->addAction("next applet");
action->setText(i18n("Next Widget"));
//no icon
action->setShortcut(KShortcut("alt+n"));
action->setShortcut(KShortcut(Qt::ALT + Qt::Key_N));
action->setData(AbstractToolBox::ControlTool);
action = actions->addAction("previous applet");
action->setText(i18n("Previous Widget"));
//no icon
action->setShortcut(KShortcut("alt+p"));
action->setShortcut(KShortcut(Qt::ALT + Qt::Key_P));
action->setData(AbstractToolBox::ControlTool);
}

View file

@ -779,22 +779,22 @@ void CoronaPrivate::init()
lockAction->setAutoRepeat(true);
lockAction->setIcon(KIcon("object-locked"));
lockAction->setData(AbstractToolBox::ControlTool);
lockAction->setShortcut(KShortcut("alt+l"));
lockAction->setShortcut(KShortcut(Qt::ALT + Qt::Key_L));
lockAction->setShortcutContext(Qt::ApplicationShortcut);
//FIXME this doesn't really belong here. desktop KCM maybe?
//but should the shortcuts be per-app or really-global?
//I don't know how to make kactioncollections use plasmarc
// FIXME this doesn't really belong here. desktop KCM maybe?
// but should the shortcuts be per-app or really-global?
// I don't know how to make kactioncollections use plasmarc
KAction *action = actions.addAction("configure shortcuts");
QObject::connect(action, SIGNAL(triggered()), q, SLOT(showShortcutConfig()));
action->setText(i18n("Shortcut Settings"));
action->setIcon(KIcon("configure-shortcuts"));
action->setAutoRepeat(false);
action->setData(AbstractToolBox::ConfigureTool);
//action->setShortcut(KShortcut("ctrl+h"));
// action->setShortcut(KShortcut(Qt::CTRL + Qt::Key_H));
action->setShortcutContext(Qt::ApplicationShortcut);
//fake containment/applet actions
// fake containment/applet actions
KActionCollection *containmentActions = AppletPrivate::defaultActions(q); //containment has to start with applet stuff
ContainmentPrivate::addDefaultActions(containmentActions); //now it's really containment
actionCollections << &actions << AppletPrivate::defaultActions(q) << containmentActions;