Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
ef25284a
Commit
ef25284a
authored
Jan 12, 2022
by
Vlad Zahorodnii
Browse files
Register global shortcut using KGlobalAccel
khotkeys is obsolete.
parent
4a26a4d6
Pipeline
#128489
passed with stage
in 2 minutes and 6 seconds
Changes
7
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
ef25284a
...
...
@@ -116,6 +116,7 @@ option(ENABLE_PLUGIN_SSHMANAGER "Build the SSHManager plugin" ON)
add_subdirectory
(
src
)
add_subdirectory
(
data
)
add_subdirectory
(
desktop
)
add_subdirectory
(
kconf_update
)
if
(
KF5DocTools_FOUND
)
add_subdirectory
(
doc/manual
)
endif
()
...
...
desktop/CMakeLists.txt
View file @
ef25284a
...
...
@@ -11,5 +11,4 @@ if(KF5KIO_VERSION VERSION_GREATER_EQUAL "5.85.0")
else
()
install
(
FILES konsolerun.desktop DESTINATION
${
KDE_INSTALL_KSERVICES5DIR
}
/ServiceMenus
)
endif
()
install
(
FILES konsole.khotkeys DESTINATION
${
KDE_INSTALL_DATADIR
}
/khotkeys
)
install
(
FILES konsole.notifyrc DESTINATION
${
KDE_INSTALL_KNOTIFY5RCDIR
}
)
desktop/konsole.khotkeys
deleted
100644 → 0
View file @
4a26a4d6
[Main]
ImportId=konsole
Version=2
Autostart=true
Disabled=false
[Data]
DataCount=1
[Data_1]
Comment=Global keyboard shortcut to launch Konsole
Enabled=true
Name=Launch Konsole
Type=MENUENTRY_SHORTCUT_ACTION_DATA
[Data_1Actions]
ActionsCount=1
[Data_1Actions0]
CommandURL=org.kde.konsole.desktop
Type=MENUENTRY
[Data_1Conditions]
Comment=
ConditionsCount=0
[Data_1Triggers]
Comment=Simple_action
TriggersCount=1
[Data_1Triggers0]
Key=Ctrl+Alt+T
Type=SHORTCUT
desktop/org.kde.konsole.desktop
View file @
ef25284a
...
...
@@ -10,6 +10,7 @@ X-DocPath=konsole/index.html
X-DBUS-StartupType=Unique
StartupNotify=true
X-KDE-AuthorizeAction=shell_access
X-KDE-Shortcuts=Ctrl+Alt+T
StartupWMClass=konsole
Keywords=terminal;console;script;run;execute;command;command-line;commandline;cli;bash;sh;shell;zsh
Keywords[ar]=طرفية;كونسول;سكربت;شغل;نفذ;أوامر;سطر-الأوامر;سطر الأوامر;cli;باش;صدفة;شل;zsh
...
...
kconf_update/CMakeLists.txt
0 → 100644
View file @
ef25284a
add_executable
(
konsole_globalaccel
konsole_globalaccel.cpp
)
target_link_libraries
(
konsole_globalaccel PRIVATE
KF5::ConfigCore
KF5::GlobalAccel
KF5::Service
)
install
(
TARGETS konsole_globalaccel DESTINATION
${
KDE_INSTALL_LIBDIR
}
/kconf_update_bin
)
install
(
FILES konsole_globalaccel.upd DESTINATION
${
KDE_INSTALL_KCONFUPDATEDIR
}
)
kconf_update/konsole_globalaccel.cpp
0 → 100644
View file @
ef25284a
#include
<QAction>
#include
<QCoreApplication>
#include
<QKeySequence>
#include
<KConfig>
#include
<KConfigGroup>
#include
<KGlobalAccel>
#include
<KService>
static
void
migrateShortcut
(
const
QString
&
desktopFile
,
const
QList
<
QKeySequence
>
&
shortcuts
)
{
const
KService
::
Ptr
service
=
KService
::
serviceByStorageId
(
desktopFile
);
QAction
action
(
service
->
name
());
action
.
setProperty
(
"componentName"
,
desktopFile
);
action
.
setProperty
(
"componentDisplayName"
,
service
->
name
());
action
.
setObjectName
(
QStringLiteral
(
"_launch"
));
// Tell kglobalaccel that the action is active.
KGlobalAccel
::
self
()
->
setShortcut
(
&
action
,
shortcuts
);
action
.
setProperty
(
"isConfigurationAction"
,
true
);
KGlobalAccel
::
self
()
->
setShortcut
(
&
action
,
shortcuts
,
KGlobalAccel
::
NoAutoloading
);
}
int
main
(
int
argc
,
char
**
argv
)
{
QCoreApplication
app
(
argc
,
argv
);
KConfig
khotkeysrc
(
QStringLiteral
(
"khotkeysrc"
),
KConfig
::
SimpleConfig
);
const
int
dataCount
=
KConfigGroup
(
&
khotkeysrc
,
"Data"
).
readEntry
(
"DataCount"
,
0
);
bool
foundKmenuedit
=
false
;
int
kmenueditIndex
;
KConfigGroup
kmenueditGroup
;
for
(
int
i
=
1
;
i
<=
dataCount
;
++
i
)
{
kmenueditGroup
=
KConfigGroup
(
&
khotkeysrc
,
QStringLiteral
(
"Data_%1"
).
arg
(
i
));
if
(
kmenueditGroup
.
readEntry
(
"Name"
)
==
QLatin1String
(
"KMenuEdit"
))
{
foundKmenuedit
=
true
;
kmenueditIndex
=
i
;
break
;
}
}
if
(
!
foundKmenuedit
)
{
return
0
;
}
const
int
shortcutCount
=
kmenueditGroup
.
readEntry
(
"DataCount"
,
0
);
for
(
int
i
=
1
;
i
<=
shortcutCount
;
++
i
)
{
const
QString
groupName
=
QStringLiteral
(
"Data_%1_%2"
).
arg
(
kmenueditIndex
).
arg
(
i
);
if
(
KConfigGroup
(
&
khotkeysrc
,
groupName
).
readEntry
(
"Type"
)
==
QLatin1String
(
"MENUENTRY_SHORTCUT_ACTION_DATA"
))
{
const
QString
desktopFile
=
KConfigGroup
(
&
khotkeysrc
,
groupName
+
QStringLiteral
(
"Actions0"
)).
readEntry
(
"CommandURL"
);
if
(
desktopFile
==
QLatin1String
(
"org.kde.konsole.desktop"
))
{
const
QString
shortcutId
=
KConfigGroup
(
&
khotkeysrc
,
groupName
+
QStringLiteral
(
"Triggers0"
)).
readEntry
(
"Uuid"
);
const
QList
<
QKeySequence
>
shortcuts
=
KGlobalAccel
::
self
()
->
globalShortcut
(
QStringLiteral
(
"khotkeys"
),
shortcutId
);
// Unset old shortcut. setShortcut() is needed to make the action active.
QAction
action
;
action
.
setObjectName
(
shortcutId
);
action
.
setProperty
(
"componentName"
,
QStringLiteral
(
"khotkeys"
));
KGlobalAccel
::
self
()
->
setShortcut
(
&
action
,
{});
KGlobalAccel
::
self
()
->
removeAllShortcuts
(
&
action
);
// Migrate to kglobalaccel.
migrateShortcut
(
desktopFile
,
shortcuts
);
// khotkeys will automagically update the DataCount key.
khotkeysrc
.
deleteGroup
(
groupName
);
khotkeysrc
.
deleteGroup
(
groupName
+
QStringLiteral
(
"Actions"
));
khotkeysrc
.
deleteGroup
(
groupName
+
QStringLiteral
(
"Actions0"
));
khotkeysrc
.
deleteGroup
(
groupName
+
QStringLiteral
(
"Conditions"
));
khotkeysrc
.
deleteGroup
(
groupName
+
QStringLiteral
(
"Triggers"
));
khotkeysrc
.
deleteGroup
(
groupName
+
QStringLiteral
(
"Triggers0"
));
}
}
}
khotkeysrc
.
sync
();
return
0
;
}
kconf_update/konsole_globalaccel.upd
0 → 100644
View file @
ef25284a
Version=5
Id=konsole_globalaccel
File=khotkeysrc
Script=konsole_globalaccel
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment