1
0
Эх сурвалжийг харах

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.
cg2121 2 жил өмнө
parent
commit
b0fbf25e24

+ 0 - 3
UI/forms/source-toolbar/media-controls.ui

@@ -71,9 +71,6 @@
        <height>20</height>
       </size>
      </property>
-     <property name="shortcut">
-      <string>Space</string>
-     </property>
      <property name="flat">
       <bool>true</bool>
      </property>

+ 8 - 0
UI/media-controls.cpp

@@ -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() {}