mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-24 23:31:36 +08:00
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).
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user