[kwin] Do not use a KActionCollection for Workspace's global shortcut actions

The ActionCollection was only used for two features:
* setting the object name
* finding the action for retrieving it's shortcut

This can also be achieved by just setting the object name and searching
for the children of the Workspace singleton.
icc-effect-5.14.5
Martin Gräßlin 2013-12-10 10:01:13 +01:00
parent edeb8051e9
commit a6f32bf3e8
5 changed files with 5 additions and 25 deletions

View File

@ -420,7 +420,7 @@ void Compositor::toggleCompositing()
slotToggleCompositing(); // TODO only operate on script level here?
if (m_suspended) {
// when disabled show a shortcut how the user can get back compositing
const auto shortcuts = KGlobalAccel::self()->shortcut(workspace()->actionCollection()->action(QStringLiteral("Suspend Compositing")));
const auto shortcuts = KGlobalAccel::self()->shortcut(workspace()->findChild<QAction*>(QStringLiteral("Suspend Compositing")));
if (!shortcuts.isEmpty()) {
// display notification only if there is the shortcut
const QString message = i18n("Desktop effects have been suspended by another application.<br/>"

View File

@ -37,17 +37,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
initShortcut(QStringLiteral(name).arg(value), i18n(name, value), key, &Workspace::fnSlot, value);
a = actionCollection->addAction(QStringLiteral("Program:kwin"));
a->setText(i18n("System"));
a = actionCollection->addAction(QStringLiteral("Group:Navigation"));
a->setText(i18n("Navigation"));
DEF(I18N_NOOP("Walk Through Window Tabs"), 0, slotActivateNextTab);
DEF(I18N_NOOP("Walk Through Window Tabs (Reverse)"), 0, slotActivatePrevTab);
DEF(I18N_NOOP("Remove Window From Group"), 0, slotUntab);
a = actionCollection->addAction(QStringLiteral("Group:Windows"));
a->setText(i18n("Windows"));
DEF(I18N_NOOP("Window Operations Menu"),
Qt::ALT + Qt::Key_F3, slotWindowOperations);
DEF2("Window Close", I18N_NOOP("Close Window"),
@ -125,8 +118,6 @@ DEF2("Increase Opacity", I18N_NOOP("Increase Opacity of Active Window by 5 %"),
DEF2("Decrease Opacity", I18N_NOOP("Decrease Opacity of Active Window by 5 %"),
0, slotLowerWindowOpacity);
a = actionCollection->addAction(QStringLiteral("Group:Window Desktop"));
a->setText(i18n("Window & Desktop"));
DEF2("Window On All Desktops", I18N_NOOP("Keep Window on All Desktops"),
0, slotWindowOnAllDesktops);
@ -154,8 +145,6 @@ for (int i = 0; i < 8; ++i) {
DEF(I18N_NOOP("Switch to Next Screen"), 0, slotSwitchToNextScreen);
DEF(I18N_NOOP("Switch to Previous Screen"), 0, slotSwitchToPrevScreen);
a = actionCollection->addAction(QStringLiteral("Group:Miscellaneous"));
a->setText(i18n("Miscellaneous"));
DEF(I18N_NOOP("Kill Window"), Qt::CTRL + Qt::ALT + Qt::Key_Escape, slotKillWindow);
DEF(I18N_NOOP("Suspend Compositing"), Qt::SHIFT + Qt::ALT + Qt::Key_F12, slotToggleCompositing);
DEF(I18N_NOOP("Invert Screen Colors"), 0, slotInvertScreen);

View File

@ -183,8 +183,7 @@ void UserActionsMenu::helperDialog(const QString& message, const QWeakPointer<Cl
QStringList args;
QString type;
auto shortcut = [](const QString &name) {
KActionCollection *keys = Workspace::self()->actionCollection();
QAction* action = keys->action(name);
QAction* action = Workspace::self()->findChild<QAction*>(name);
assert(action != NULL);
const auto shortcuts = KGlobalAccel::self()->shortcut(action);
return QStringLiteral("%1 (%2)").arg(action->text())
@ -268,7 +267,7 @@ void UserActionsMenu::init()
});
auto setShortcut = [](QAction *action, const QString &actionName) {
const auto shortcuts = KGlobalAccel::self()->shortcut(Workspace::self()->actionCollection()->action(actionName));
const auto shortcuts = KGlobalAccel::self()->shortcut(Workspace::self()->findChild<QAction*>(actionName));
if (!shortcuts.isEmpty()) {
action->setShortcut(shortcuts.first());
}
@ -940,7 +939,8 @@ void Workspace::closeActivePopup()
template <typename Slot>
void Workspace::initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, Slot slot, const QVariant &data)
{
QAction *a = keys->addAction(actionName);
QAction *a = new QAction(this);
a->setObjectName(actionName);
a->setText(description);
if (data.isValid()) {
a->setData(data);
@ -955,10 +955,6 @@ void Workspace::initShortcut(const QString &actionName, const QString &descripti
*/
void Workspace::initShortcuts()
{
keys = new KActionCollection(this);
KActionCollection* actionCollection = keys;
QAction* a = 0L;
#define IN_KWIN
#include "kwinbindings.cpp"
#ifdef KWIN_BUILD_TABBOX

View File

@ -147,7 +147,6 @@ Workspace::Workspace(bool restore)
, session_saving(false)
, block_focus(0)
, m_userActionsMenu(new UserActionsMenu(this))
, keys(0)
, client_keys(NULL)
, client_keys_dialog(NULL)
, client_keys_client(NULL)

View File

@ -191,9 +191,6 @@ public:
int oldDisplayWidth() const;
int oldDisplayHeight() const;
KActionCollection* actionCollection() const {
return keys;
}
KActionCollection* clientKeys() const {
return client_keys;
}
@ -507,7 +504,6 @@ private:
void modalActionsSwitch(bool enabled);
KActionCollection* keys;
KActionCollection* client_keys;
ShortcutDialog* client_keys_dialog;
Client* client_keys_client;