From 18b635507227a442487f748c071043b32bab13f8 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 11 May 2025 22:58:52 -0400 Subject: [PATCH] Add disabled theme for QSlider --- resources/themes/dark.qss | 21 +++++++++++++++++++++ resources/themes/default.qss | 19 +++++++++++++++++++ resources/themes/midnight.qss | 21 +++++++++++++++++++++ src/mainwindow.cpp | 7 ------- 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/resources/themes/dark.qss b/resources/themes/dark.qss index 69dc7cd5..ecb45957 100644 --- a/resources/themes/dark.qss +++ b/resources/themes/dark.qss @@ -387,3 +387,24 @@ QHeaderView { margin: 0px; font: 12px; } + +/* Sliders */ + +/* Qt doesn't change the style of disabled sliders, so we do it ourselves */ +QSlider::groove:horizontal:disabled { + border: 1px solid gray; + border-radius: 3px; + height: 2px; + background: none; +} +QSlider::sub-page:horizontal:disabled { + background: #B1B1B1; +} +QSlider::handle:horizontal:disabled { + border: 1px solid #444444; + border-radius: 3px; + width: 10px; + height: 9px; + margin: -5px -1px; + background: #5C5C5C; +} diff --git a/resources/themes/default.qss b/resources/themes/default.qss index 89f02c88..25baa4af 100644 --- a/resources/themes/default.qss +++ b/resources/themes/default.qss @@ -23,3 +23,22 @@ QAbstractSpinBox { QAbstractSpinBox:disabled { color: gray; } + +/* Qt doesn't change the style of disabled sliders, so we do it ourselves */ +QSlider::groove:horizontal:disabled { + border: 1px solid gray; + border-radius: 3px; + height: 2px; + background: none; +} +QSlider::sub-page:horizontal:disabled { + background: #B1B1B1; +} +QSlider::handle:horizontal:disabled { + border: 1px solid #444444; + border-radius: 3px; + width: 10px; + height: 9px; + margin: -5px -1px; + background: #5C5C5C; +} diff --git a/resources/themes/midnight.qss b/resources/themes/midnight.qss index 734dffa1..4c2a9761 100644 --- a/resources/themes/midnight.qss +++ b/resources/themes/midnight.qss @@ -388,3 +388,24 @@ QHeaderView { margin: 0px; font: 12px; } + +/* Sliders */ + +/* Qt doesn't change the style of disabled sliders, so we do it ourselves */ +QSlider::groove:horizontal:disabled { + border: 1px solid gray; + border-radius: 3px; + height: 2px; + background: none; +} +QSlider::sub-page:horizontal:disabled { + background: #B1B1B1; +} +QSlider::handle:horizontal:disabled { + border: 1px solid #444444; + border-radius: 3px; + width: 10px; + height: 9px; + margin: -5px -1px; + background: #5C5C5C; +} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c4cf83c5..27109aa7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2490,13 +2490,6 @@ void MainWindow::on_groupBox_DiveMapOpacity_toggled(bool on) { } void MainWindow::setDivingMapsVisible(bool visible) { - // Qt doesn't change the style of disabled sliders, so we do it ourselves - QString stylesheet = visible ? "" : "QSlider::groove:horizontal {border: 1px solid #999999; border-radius: 3px; height: 2px; background: #B1B1B1;}" - "QSlider::handle:horizontal {border: 1px solid #444444; border-radius: 3px; width: 10px; height: 9px; margin: -5px -1px; background: #5C5C5C; }"; - ui->slider_DiveEmergeMapOpacity->setStyleSheet(stylesheet); - ui->slider_DiveMapOpacity->setStyleSheet(stylesheet); - ui->slider_EmergeMapOpacity->setStyleSheet(stylesheet); - // Sync UI toggle elements const QSignalBlocker blocker1(ui->groupBox_DiveMapOpacity); const QSignalBlocker blocker2(ui->actionDive_Emerge_Map);