Store multiple shortcuts separated by " - " instead of space
Space is a valid shortcut part. E.g. "Volume Up". KConfig update script for 4.11 is added to migrate existing and erroneous rules taking into account that space is a valid key. BUG: 305434 FIXED-IN: 4.11 REVIEW: 108942
This commit is contained in:
parent
8a2e7fee56
commit
3809f58dbb
5 changed files with 113 additions and 5 deletions
|
@ -46,11 +46,22 @@ target_link_libraries( kwin_update_settings_410 ${KDE4_KDECORE_LIBS} )
|
||||||
|
|
||||||
install( TARGETS kwin_update_settings_410 DESTINATION ${LIB_INSTALL_DIR}/kconf_update_bin/ )
|
install( TARGETS kwin_update_settings_410 DESTINATION ${LIB_INSTALL_DIR}/kconf_update_bin/ )
|
||||||
|
|
||||||
|
########### next target ###############
|
||||||
|
set( kwin_update_settings_411_SRCS update_kwin_411.cpp )
|
||||||
|
|
||||||
|
kde4_add_executable( kwin_update_settings_411 ${kwin_update_settings_411_SRCS} )
|
||||||
|
|
||||||
|
target_link_libraries( kwin_update_settings_411 ${KDE4_KDECORE_LIBS} )
|
||||||
|
|
||||||
|
install( TARGETS kwin_update_settings_411 DESTINATION ${LIB_INSTALL_DIR}/kconf_update_bin/ )
|
||||||
|
|
||||||
########### install files ###############
|
########### install files ###############
|
||||||
|
|
||||||
install( FILES fsp_workarounds_1.kwinrules DESTINATION ${DATA_INSTALL_DIR}/kwin/default_rules )
|
install( FILES fsp_workarounds_1.kwinrules DESTINATION ${DATA_INSTALL_DIR}/kwin/default_rules )
|
||||||
install( FILES pop.wav DESTINATION ${SOUND_INSTALL_DIR} )
|
install( FILES pop.wav DESTINATION ${SOUND_INSTALL_DIR} )
|
||||||
install( FILES kwin_fsp_workarounds_1.upd kwin_update_tabbox_settings.upd kwin_remove_effects.upd kwin_update_tabbox_qml_settings.upd kwin_remove_delay_focus.upd kwin_update_49.upd kwin_update_410.upd kwin_translate_activity_rule.upd DESTINATION ${KCONF_UPDATE_INSTALL_DIR} )
|
install( FILES kwin_fsp_workarounds_1.upd kwin_update_tabbox_settings.upd kwin_remove_effects.upd kwin_update_tabbox_qml_settings.upd kwin_remove_delay_focus.upd kwin_update_49.upd kwin_update_410.upd kwin_translate_activity_rule.upd
|
||||||
|
kwin_update_411.upd
|
||||||
|
DESTINATION ${KCONF_UPDATE_INSTALL_DIR} )
|
||||||
install( PROGRAMS kwin_remove_delay_focus.sh kwin_translate_activity_rule.sh DESTINATION ${KCONF_UPDATE_INSTALL_DIR} )
|
install( PROGRAMS kwin_remove_delay_focus.sh kwin_translate_activity_rule.sh DESTINATION ${KCONF_UPDATE_INSTALL_DIR} )
|
||||||
install( FILES stripTitle.js DESTINATION ${DATA_INSTALL_DIR}/kwin )
|
install( FILES stripTitle.js DESTINATION ${DATA_INSTALL_DIR}/kwin )
|
||||||
|
|
||||||
|
|
2
data/kwin_update_411.upd
Normal file
2
data/kwin_update_411.upd
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Id=Kwin-4.11_0
|
||||||
|
Script=kwin_update_settings_411
|
95
data/update_kwin_411.cpp
Normal file
95
data/update_kwin_411.cpp
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
/********************************************************************
|
||||||
|
KWin - the KDE window manager
|
||||||
|
This file is part of the KDE project.
|
||||||
|
|
||||||
|
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
*********************************************************************/
|
||||||
|
#include <KDE/KAboutData>
|
||||||
|
#include <KDE/KCmdLineArgs>
|
||||||
|
#include <KDE/KComponentData>
|
||||||
|
#include <KDE/KConfigGroup>
|
||||||
|
#include <KDE/KGlobal>
|
||||||
|
#include <KDE/KLocalizedString>
|
||||||
|
// Qt
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusMessage>
|
||||||
|
|
||||||
|
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<shortcuts.length(); ++i) {
|
||||||
|
const QString &cs = shortcuts.at(i);
|
||||||
|
if (cs.contains('+') && (cs.contains(ALT) || cs.contains(CTRL) || cs.contains(META) || cs.contains(SHIFT))) {
|
||||||
|
// our shortcuts consist of at least one modifier and a key, so having a plus and a modifier means it's a shortcut
|
||||||
|
newValue.append(" - ");
|
||||||
|
} else {
|
||||||
|
// otherwise it's part of a key like "Volume Up"
|
||||||
|
newValue.append(' ');
|
||||||
|
}
|
||||||
|
newValue.append(cs);
|
||||||
|
}
|
||||||
|
group.writeEntry(KEY, newValue);
|
||||||
|
group.sync();
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
if (updated) {
|
||||||
|
config.sync();
|
||||||
|
}
|
||||||
|
return updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char* argv[] )
|
||||||
|
{
|
||||||
|
KAboutData about( "kwin_update_settings_4_11", "kwin", KLocalizedString(), 0 );
|
||||||
|
KCmdLineArgs::init( argc, argv, &about );
|
||||||
|
KComponentData inst( &about );
|
||||||
|
Q_UNUSED( KGlobal::locale() ); // jump-start locales to get to translated descriptions
|
||||||
|
bool reload = migrateRulesShortcut();
|
||||||
|
// Send signal to all kwin instances
|
||||||
|
if (reload) {
|
||||||
|
QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
||||||
|
QDBusConnection::sessionBus().send(message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
<widget class="QLabel" name="textLabel2" >
|
<widget class="QLabel" name="textLabel2" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>A single shortcut can be easily assigned or cleared using the two buttons. Only shortcuts with modifiers can be used.<p>
|
<string>A single shortcut can be easily assigned or cleared using the two buttons. Only shortcuts with modifiers can be used.<p>
|
||||||
It is possible to have several possible shortcuts, and the first available shortcut will be used. The shortcuts are specified using space-separated shortcut sets. One set is specified as <i>base</i>+(<i>list</i>), where base are modifiers and list is a list of keys.<br>
|
It is possible to have several possible shortcuts, and the first available shortcut will be used. The shortcuts are specified using shortcut sets separated by " - ". One set is specified as <i>base</i>+(<i>list</i>), where base are modifiers and list is a list of keys.<br>
|
||||||
For example "<b>Shift+Alt+(123) Shift+Ctrl+(ABC)</b>" will first try <b>Shift+Alt+1</b>, then others with <b>Shift+Ctrl+C</b> as the last one.</string>
|
For example "<b>Shift+Alt+(123) Shift+Ctrl+(ABC)</b>" will first try <b>Shift+Alt+1</b>, then others with <b>Shift+Ctrl+C</b> as the last one.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat" >
|
<property name="textFormat" >
|
||||||
|
|
|
@ -1795,8 +1795,8 @@ void Client::setShortcut(const QString& _cut)
|
||||||
return setShortcutInternal(KShortcut());
|
return setShortcutInternal(KShortcut());
|
||||||
// Format:
|
// Format:
|
||||||
// base+(abcdef)<space>base+(abcdef)
|
// base+(abcdef)<space>base+(abcdef)
|
||||||
// E.g. Alt+Ctrl+(ABCDEF) Win+X,Win+(ABCDEF)
|
// E.g. Alt+Ctrl+(ABCDEF);Meta+X,Meta+(ABCDEF)
|
||||||
if (!cut.contains('(') && !cut.contains(')') && !cut.contains(' ')) {
|
if (!cut.contains('(') && !cut.contains(')') && !cut.contains(" - ")) {
|
||||||
if (workspace()->shortcutAvailable(KShortcut(cut), this))
|
if (workspace()->shortcutAvailable(KShortcut(cut), this))
|
||||||
setShortcutInternal(KShortcut(cut));
|
setShortcutInternal(KShortcut(cut));
|
||||||
else
|
else
|
||||||
|
@ -1804,7 +1804,7 @@ void Client::setShortcut(const QString& _cut)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QList< KShortcut > keys;
|
QList< KShortcut > keys;
|
||||||
QStringList groups = cut.split(' ');
|
QStringList groups = cut.split(" - ");
|
||||||
for (QStringList::ConstIterator it = groups.constBegin();
|
for (QStringList::ConstIterator it = groups.constBegin();
|
||||||
it != groups.constEnd();
|
it != groups.constEnd();
|
||||||
++it) {
|
++it) {
|
||||||
|
|
Loading…
Reference in a new issue