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
Kate
Commits
6bb69ed2
Commit
6bb69ed2
authored
Jul 26, 2022
by
Pablo Rauzy
Committed by
Christoph Cullmann
Aug 14, 2022
Browse files
[WIP] better debug output using QKeySequence
parent
6bb0e485
Changes
1
Hide whitespace changes
Inline
Side-by-side
addons/keyboardmacros/keyboardmacrosplugin.cpp
View file @
6bb69ed2
...
...
@@ -8,6 +8,7 @@
#include
<QAction>
#include
<QCoreApplication>
#include
<QKeyEvent>
#include
<QKeySequence>
#include
<QList>
#include
<QString>
#include
<QtAlgorithms>
...
...
@@ -56,10 +57,11 @@ QObject *KeyboardMacrosPlugin::createView(KTextEditor::MainWindow *mainWindow)
bool
KeyboardMacrosPlugin
::
eventFilter
(
QObject
*
obj
,
QEvent
*
event
)
{
if
(
event
->
type
()
==
QEvent
::
KeyPress
)
{
if
(
event
->
type
()
==
QEvent
::
KeyPress
||
event
->
type
()
==
QEvent
::
ShortcutOverride
)
{
QKeyEvent
*
keyEvent
=
new
QKeyEvent
(
*
static_cast
<
QKeyEvent
*>
(
event
));
QKeySequence
s
(
keyEvent
->
key
()
|
keyEvent
->
modifiers
());
qDebug
(
"KeySeq: %s"
,
s
.
toString
().
toUtf8
().
data
());
m_keyEvents
.
append
(
keyEvent
);
qDebug
(
"Captured key press: %s"
,
keyEvent
->
text
().
toUtf8
().
data
());
return
true
;
// FIXME: this should let the event pass through by returning false
// but also capture keypress only once and only the relevant ones
...
...
@@ -107,10 +109,12 @@ bool KeyboardMacrosPlugin::run(KTextEditor::View *view)
}
if
(
!
m_keyEvents
.
isEmpty
())
{
QList
<
QKeyEvent
*>::
ConstIterator
keyEvent
;
for
(
keyEvent
=
m_keyEvents
.
constBegin
();
keyEvent
!=
m_keyEvents
.
constEnd
();
keyEvent
++
)
{
qDebug
(
"Emitting key press: %s"
,
(
*
keyEvent
)
->
text
().
toUtf8
().
data
());
QCoreApplication
::
sendEvent
(
QCoreApplication
::
instance
(),
*
keyEvent
);
QList
<
QKeyEvent
*>::
ConstIterator
it
;
for
(
it
=
m_keyEvents
.
constBegin
();
it
!=
m_keyEvents
.
constEnd
();
it
++
)
{
QKeyEvent
*
keyEvent
=
*
it
;
QKeySequence
s
(
keyEvent
->
key
()
|
keyEvent
->
modifiers
());
qDebug
(
"KeySeq: %s"
,
s
.
toString
().
toUtf8
().
data
());
QCoreApplication
::
sendEvent
(
QCoreApplication
::
instance
(),
keyEvent
);
// FIXME: the above doesn't work
}
}
...
...
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