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
a63fc8c6
Commit
a63fc8c6
authored
Jul 31, 2022
by
Pablo Rauzy
Committed by
Christoph Cullmann
Aug 14, 2022
Browse files
fixed bug when recording and switching focus to another app
parent
60c837b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/keyboardmacros/keyboardmacrosplugin.cpp
View file @
a63fc8c6
...
...
@@ -47,7 +47,7 @@ void KeyboardMacrosPlugin::sendMessage(const QString &text, bool error)
{
QVariantMap
genericMessage
;
genericMessage
.
insert
(
QStringLiteral
(
"type"
),
error
?
QStringLiteral
(
"Error"
)
:
QStringLiteral
(
"Info"
));
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Macros"
));
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"
Keyboard
Macros"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
QIcon
::
fromTheme
(
QStringLiteral
(
"input-keyboard"
)));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
text
);
Q_EMIT
message
(
genericMessage
);
...
...
@@ -94,10 +94,14 @@ void KeyboardMacrosPlugin::record()
m_recording
=
true
;
m_recordAction
->
setText
(
i18n
(
"End Macro &Recording"
));
m_cancelAction
->
setEnabled
(
true
);
// connect applicationStateChanged
connect
(
qApp
,
&
QGuiApplication
::
applicationStateChanged
,
this
,
&
KeyboardMacrosPlugin
::
applicationStateChanged
);
}
void
KeyboardMacrosPlugin
::
stop
(
bool
save
)
{
// disconnect applicationStateChanged
disconnect
(
qApp
,
&
QGuiApplication
::
applicationStateChanged
,
this
,
&
KeyboardMacrosPlugin
::
applicationStateChanged
);
// stop recording
qDebug
(
"[KeyboardMacrosPlugin] %s recording"
,
save
?
"end"
:
"cancel"
);
m_focusWidget
->
removeEventFilter
(
this
);
...
...
@@ -139,6 +143,25 @@ bool KeyboardMacrosPlugin::play()
return
true
;
}
void
KeyboardMacrosPlugin
::
applicationStateChanged
(
Qt
::
ApplicationState
state
)
{
switch
(
state
)
{
case
Qt
::
ApplicationSuspended
:
sendMessage
(
i18n
(
"Application suspended, aborting record."
),
true
);
cancel
();
break
;
case
Qt
::
ApplicationHidden
:
case
Qt
::
ApplicationInactive
:
// FIXME: would be nice to be able to pause recording
sendMessage
(
i18n
(
"Application lost focus, aborting record."
),
true
);
cancel
();
break
;
case
Qt
::
ApplicationActive
:
// and resume it here
break
;
}
}
void
KeyboardMacrosPlugin
::
slotRecord
()
{
if
(
m_recording
)
{
...
...
addons/keyboardmacros/keyboardmacrosplugin.h
View file @
a63fc8c6
...
...
@@ -55,6 +55,8 @@ private:
void
cancel
();
bool
play
();
void
applicationStateChanged
(
Qt
::
ApplicationState
state
);
public
Q_SLOTS
:
void
slotRecord
();
void
slotCancel
();
...
...
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