ソースを参照

frontend: Highlight control dock buttons using style class

Checkable buttons are troublesome because QAccessible interprets them as
checkboxes, and doesn't pass the "clicked" signal to them (see
QTBUG-110737). Instead, we only get the "toggled" signal, which also
gets triggered by things other than user input (i.e., the button getting
changed by the program).

Making them uncheckable means that they behave like normal buttons
again. To style them, we can just add a class and address them that way.
Note that uncheckable here means *actually* not checkable - unlike the
cursed NonCheckableButton class previously used that makes a button
that *is* checkable ignore the user input (and only allow check state
changes via code, effectively making it solely a styling tool).
gxalpha 9 ヶ月 前
コミット
76e1818866

+ 14 - 12
frontend/data/themes/Yami.obt

@@ -1125,22 +1125,24 @@ QDoubleSpinBox::down-arrow {
 }
 
 /* Primary Control Button Checked Coloring */
-#streamButton:!hover:!pressed:checked,
-#recordButton:!hover:!pressed:checked,
-#replayBufferButton:!hover:!pressed:checked,
-#virtualCamButton:!hover:!pressed:checked,
-#modeSwitch:!hover:!pressed:checked,
-#broadcastButton:!hover:!pressed:checked {
+#streamButton:!hover:!pressed.state-active,
+#recordButton:!hover:!pressed.state-active,
+#pauseRecordButton:!hover:!pressed.state-active,
+#replayBufferButton:!hover:!pressed.state-active,
+#virtualCamButton:!hover:!pressed.state-active,
+#modeSwitch:!hover:!pressed.state-active,
+#broadcastButton:!hover:!pressed.state-active {
     background: var(--primary);
 }
 
 /* Primary Control Button Hover Coloring */
-#streamButton:hover:!pressed:checked,
-#recordButton:hover:!pressed:checked,
-#replayBufferButton:!pressed:checked,
-#virtualCamButton:!pressed:checked,
-#modeSwitch:hover:!pressed:checked,
-#broadcastButton:hover:!pressed:checked {
+#streamButton:hover:!pressed.state-active,
+#recordButton:hover:!pressed.state-active,
+#pauseRecordButton:hover:!pressed.state-active,
+#replayBufferButton:!pressed.state-active,
+#virtualCamButton:!pressed.state-active,
+#modeSwitch:hover:!pressed.state-active,
+#broadcastButton:hover:!pressed.state-active {
     background: var(--primary_light);
     color: var(--text);
 }

+ 21 - 18
frontend/data/themes/Yami_Acri.ovt

@@ -145,33 +145,36 @@ QTabBar QToolButton {
 }
 
 /* Primary Control Button Checked Coloring */
-#streamButton:!hover:!pressed:checked,
-#recordButton:!hover:!pressed:checked,
-#replayBufferButton:!hover:!pressed:checked,
-#virtualCamButton:!hover:!pressed:checked,
-#modeSwitch:!hover:!pressed:checked,
-#broadcastButton:!hover:!pressed:checked {
+#streamButton:!hover:!pressed.state-active,
+#recordButton:!hover:!pressed.state-active,
+#pauseRecordButton:!hover:!pressed.state-active,
+#replayBufferButton:!hover:!pressed.state-active,
+#virtualCamButton:!hover:!pressed.state-active,
+#modeSwitch:!hover:!pressed.state-active,
+#broadcastButton:!hover:!pressed.state-active {
     background: var(--button_bg_red);
     border-color: var(--button_bg_red);
 }
 
 /* Primary Control Button Hover Coloring */
-#streamButton:hover:!pressed:checked,
-#recordButton:hover:!pressed:checked,
-#replayBufferButton:hover:!pressed:checked,
-#virtualCamButton:hover:!pressed:checked,
-#modeSwitch:hover:!pressed:checked,
-#broadcastButton:hover:!pressed:checked {
+#streamButton:hover:!pressed.state-active,
+#recordButton:hover:!pressed.state-active,
+#pauseRecordButton:hover:!pressed.state-active,
+#replayBufferButton:hover:!pressed.state-active,
+#virtualCamButton:hover:!pressed.state-active,
+#modeSwitch:hover:!pressed.state-active,
+#broadcastButton:hover:!pressed.state-active {
     background: var(--button_bg_red_hover);
 }
 
 /* Primary Control Button Checked + Pressed Coloring */
-#streamButton:pressed:checked,
-#recordButton:pressed:checked,
-#replayBufferButton:pressed:checked,
-#virtualCamButton:pressed:checked,
-#modeSwitch:pressed:checked,
-#broadcastButton:pressed:checked {
+#streamButton:pressed.state-active,
+#recordButton:pressed.state-active,
+#pauseRecordButton:pressed.state-active,
+#replayBufferButton:pressed.state-active,
+#virtualCamButton:pressed.state-active,
+#modeSwitch:pressed.state-active,
+#broadcastButton:pressed.state-active {
     background: var(--button_bg_red_down);
 }
 

+ 7 - 6
frontend/data/themes/Yami_Rachni.ovt

@@ -221,11 +221,12 @@ VolumeMeter {
 }
 
 /* Primary Control Button Checked Coloring */
-#streamButton:!hover:!pressed:checked,
-#recordButton:!hover:!pressed:checked,
-#replayBufferButton:!hover:!pressed:checked,
-#virtualCamButton:!hover:!pressed:checked,
-#modeSwitch:!hover:!pressed:checked,
-#broadcastButton:!hover:!pressed:checked {
+#streamButton:!hover:!pressed.state-active,
+#recordButton:!hover:!pressed.state-active,
+#pauseRecordButton:!hover:!pressed.state-active,
+#replayBufferButton:!hover:!pressed.state-active,
+#virtualCamButton:!hover:!pressed.state-active,
+#modeSwitch:!hover:!pressed.state-active,
+#broadcastButton:!hover:!pressed.state-active {
     background: var(--primary_light);
 }

+ 6 - 34
frontend/forms/OBSBasicControls.ui

@@ -47,7 +47,7 @@
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout_7">
         <item>
-         <widget class="NonCheckableButton" name="streamButton">
+         <widget class="QPushButton" name="streamButton">
           <property name="enabled">
            <bool>true</bool>
           </property>
@@ -66,13 +66,10 @@
           <property name="text">
            <string>Basic.Main.StartStreaming</string>
           </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
          </widget>
         </item>
         <item>
-         <widget class="NonCheckableButton" name="broadcastButton">
+         <widget class="QPushButton" name="broadcastButton">
           <property name="enabled">
            <bool>true</bool>
           </property>
@@ -91,9 +88,6 @@
           <property name="text">
            <string>Basic.Main.StartBroadcast</string>
           </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
          </widget>
         </item>
        </layout>
@@ -116,7 +110,7 @@
          <number>0</number>
         </property>
         <item>
-         <widget class="NonCheckableButton" name="recordButton">
+         <widget class="QPushButton" name="recordButton">
           <property name="enabled">
            <bool>true</bool>
           </property>
@@ -135,9 +129,6 @@
           <property name="text">
            <string>Basic.Main.StartRecording</string>
           </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
          </widget>
         </item>
         <item>
@@ -161,9 +152,6 @@
            <iconset resource="obs.qrc">
             <normaloff>:/res/images/media-pause.svg</normaloff>:/res/images/media-pause.svg</iconset>
           </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
           <property name="class" stdset="0">
            <string>icon-media-pause</string>
           </property>
@@ -189,7 +177,7 @@
          <number>0</number>
         </property>
         <item>
-         <widget class="NonCheckableButton" name="replayBufferButton">
+         <widget class="QPushButton" name="replayBufferButton">
           <property name="enabled">
            <bool>true</bool>
           </property>
@@ -208,9 +196,6 @@
           <property name="text">
            <string>Basic.Main.StartReplayBuffer</string>
           </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
          </widget>
         </item>
         <item>
@@ -259,7 +244,7 @@
          <number>0</number>
         </property>
         <item>
-         <widget class="NonCheckableButton" name="virtualCamButton">
+         <widget class="QPushButton" name="virtualCamButton">
           <property name="enabled">
            <bool>true</bool>
           </property>
@@ -278,9 +263,6 @@
           <property name="text">
            <string>Basic.Main.StartVirtualCam</string>
           </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
          </widget>
         </item>
         <item>
@@ -312,7 +294,7 @@
        </layout>
       </item>
       <item>
-       <widget class="NonCheckableButton" name="modeSwitch">
+       <widget class="QPushButton" name="modeSwitch">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Ignored" vsizetype="Fixed">
           <horstretch>0</horstretch>
@@ -328,9 +310,6 @@
         <property name="text">
          <string>Basic.TogglePreviewProgramMode</string>
         </property>
-        <property name="checkable">
-         <bool>true</bool>
-        </property>
        </widget>
       </item>
       <item>
@@ -370,13 +349,6 @@
    </item>
   </layout>
  </widget>
- <customwidgets>
-  <customwidget>
-   <class>NonCheckableButton</class>
-   <extends>QPushButton</extends>
-   <header>components/NonCheckableButton.hpp</header>
-  </customwidget>
- </customwidgets>
  <resources>
   <include location="obs.qrc"/>
  </resources>

+ 13 - 12
frontend/widgets/OBSBasicControls.cpp

@@ -1,5 +1,6 @@
 #include "OBSBasicControls.hpp"
 #include "OBSBasic.hpp"
+#include "qt-wrappers.hpp"
 
 #include "moc_OBSBasicControls.cpp"
 
@@ -121,7 +122,7 @@ void OBSBasicControls::StreamingStarting(bool broadcastAutoStart)
 void OBSBasicControls::StreamingStarted(bool withDelay)
 {
 	ui->streamButton->setEnabled(true);
-	ui->streamButton->setChecked(true);
+	setClasses(ui->streamButton, "state-active");
 	ui->streamButton->setText(QTStr("Basic.Main.StopStreaming"));
 
 	if (withDelay) {
@@ -139,7 +140,7 @@ void OBSBasicControls::StreamingStopping()
 void OBSBasicControls::StreamingStopped(bool withDelay)
 {
 	ui->streamButton->setEnabled(true);
-	ui->streamButton->setChecked(false);
+	setClasses(ui->streamButton, "");
 	ui->streamButton->setText(QTStr("Basic.Main.StartStreaming"));
 
 	if (withDelay) {
@@ -155,7 +156,7 @@ void OBSBasicControls::StreamingStopped(bool withDelay)
 
 void OBSBasicControls::BroadcastStreamReady(bool ready)
 {
-	ui->broadcastButton->setChecked(ready);
+	setClasses(ui->broadcastButton, ready ? "state-active" : "");
 }
 
 void OBSBasicControls::BroadcastStreamActive()
@@ -176,7 +177,7 @@ void OBSBasicControls::BroadcastStreamStarted(bool autoStop)
 
 void OBSBasicControls::RecordingStarted(bool pausable)
 {
-	ui->recordButton->setChecked(true);
+	setClasses(ui->recordButton, "state-active");
 	ui->recordButton->setText(QTStr("Basic.Main.StopRecording"));
 
 	if (pausable) {
@@ -189,7 +190,7 @@ void OBSBasicControls::RecordingPaused()
 {
 	QString text = QTStr("Basic.Main.UnpauseRecording");
 
-	ui->pauseRecordButton->setChecked(true);
+	setClasses(ui->pauseRecordButton, "icon-media-pause state-active");
 	ui->pauseRecordButton->setAccessibleName(text);
 	ui->pauseRecordButton->setToolTip(text);
 
@@ -200,7 +201,7 @@ void OBSBasicControls::RecordingUnpaused()
 {
 	QString text = QTStr("Basic.Main.PauseRecording");
 
-	ui->pauseRecordButton->setChecked(false);
+	setClasses(ui->pauseRecordButton, "icon-media-pause");
 	ui->pauseRecordButton->setAccessibleName(text);
 	ui->pauseRecordButton->setToolTip(text);
 
@@ -214,7 +215,7 @@ void OBSBasicControls::RecordingStopping()
 
 void OBSBasicControls::RecordingStopped()
 {
-	ui->recordButton->setChecked(false);
+	setClasses(ui->recordButton, "");
 	ui->recordButton->setText(QTStr("Basic.Main.StartRecording"));
 
 	ui->pauseRecordButton->setVisible(false);
@@ -222,7 +223,7 @@ void OBSBasicControls::RecordingStopped()
 
 void OBSBasicControls::ReplayBufferStarted()
 {
-	ui->replayBufferButton->setChecked(true);
+	setClasses(ui->replayBufferButton, "state-active");
 	ui->replayBufferButton->setText(QTStr("Basic.Main.StopReplayBuffer"));
 
 	ui->saveReplayButton->setVisible(true);
@@ -235,7 +236,7 @@ void OBSBasicControls::ReplayBufferStopping()
 
 void OBSBasicControls::ReplayBufferStopped()
 {
-	ui->replayBufferButton->setChecked(false);
+	setClasses(ui->replayBufferButton, "");
 	ui->replayBufferButton->setText(QTStr("Basic.Main.StartReplayBuffer"));
 
 	ui->saveReplayButton->setVisible(false);
@@ -243,19 +244,19 @@ void OBSBasicControls::ReplayBufferStopped()
 
 void OBSBasicControls::VirtualCamStarted()
 {
-	ui->virtualCamButton->setChecked(true);
+	setClasses(ui->virtualCamButton, "state-active");
 	ui->virtualCamButton->setText(QTStr("Basic.Main.StopVirtualCam"));
 }
 
 void OBSBasicControls::VirtualCamStopped()
 {
-	ui->virtualCamButton->setChecked(false);
+	setClasses(ui->virtualCamButton, "");
 	ui->virtualCamButton->setText(QTStr("Basic.Main.StartVirtualCam"));
 }
 
 void OBSBasicControls::UpdateStudioModeState(bool enabled)
 {
-	ui->modeSwitch->setChecked(enabled);
+	setClasses(ui->modeSwitch, enabled ? "state-active" : "");
 }
 
 void OBSBasicControls::EnableBroadcastFlow(bool enabled)