UI: Fix media controls shortcuts being global

The play, pause and restart shortcuts were being called as global
shortcuts, being triggered no matter what. This fixes this by calling
the shortcut actions only when the media controls widget has focus.
This commit is contained in:
cg2121
2023-03-06 03:24:55 -06:00
committed by Jim
parent 73dea7c475
commit b0fbf25e24
2 changed files with 8 additions and 3 deletions
@@ -71,9 +71,6 @@
<height>20</height>
</size>
</property>
<property name="shortcut">
<string>Space</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
+8
View File
@@ -69,6 +69,7 @@ MediaControls::MediaControls(QWidget *parent)
"MediaControlsCountdownTimer");
QAction *restartAction = new QAction(this);
restartAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
restartAction->setShortcut({Qt::Key_R});
connect(restartAction, SIGNAL(triggered()), this, SLOT(RestartMedia()));
addAction(restartAction);
@@ -86,6 +87,13 @@ MediaControls::MediaControls(QWidget *parent)
SLOT(MoveSliderBackwards()));
sliderBack->setShortcut({Qt::Key_Left});
addAction(sliderBack);
QAction *playPause = new QAction(this);
playPause->setShortcutContext(Qt::WidgetWithChildrenShortcut);
connect(playPause, SIGNAL(triggered()), this,
SLOT(on_playPauseButton_clicked()));
playPause->setShortcut({Qt::Key_Space});
addAction(playPause);
}
MediaControls::~MediaControls() {}