/******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2013 Martin Gräßlin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include #include #include #include #include #include // Qt #include #include bool migrateRulesShortcut() { const QString KEY = "shortcut"; const QString ALT = "Alt"; const QString CTRL = "Ctrl"; const QString META = "Meta"; const QString SHIFT = "Shift"; KConfig config("kwinrulesrc"); if (config.groupList().isEmpty()) { return false; } bool updated = false; Q_FOREACH (const QString &groupName, config.groupList()) { KConfigGroup group = config.group(groupName); if (!group.hasKey(KEY)) { continue; } const QString value = group.readEntry(KEY, QString()); if (value.contains(" - ")) { // already migrated continue; } if (!value.contains(' ')) { // nothing to migrate continue; } // space might be either the shortcut separator or part of the shortcut // let's try to detect it properly const QStringList shortcuts = value.split(' '); // let's take the first part as it is QString newValue = shortcuts.first(); for (int i=1; i