소스 검색

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 3 년 전
부모
커밋
b0fbf25e24
2개의 변경된 파일8개의 추가작업 그리고 3개의 파일을 삭제
  1. 0 3
      UI/forms/source-toolbar/media-controls.ui
  2. 8 0
      UI/media-controls.cpp

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