summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-11-02 12:36:29 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-11-03 23:08:39 -0800
commit814cda718365823654c7d13f2e24f31ac58ddb45 (patch)
tree3105952e46c724795ff439accd41f569b333a03f /desktop-widgets/tab-widgets/maintab.cpp
parent7d18a525f178c2c47ec72a96fbda92d5595f95d9 (diff)
downloadsubsurface-814cda718365823654c7d13f2e24f31ac58ddb45.tar.gz
desktop: generalize the colorization of the tab widget
Instead of doing it just for the Information tab, do it for all of the tabs. There's still room for improvement. But this certainly feels more consistent. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/tab-widgets/maintab.cpp')
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 0a9799b65..ab4b4f28b 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -72,6 +72,9 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
extraWidgets << new TabDiveComputer(this);
ui.tabWidget->addTab(extraWidgets.last(), tr("Device names"));
+ // call colorsChanged() for the initial setup now that the extraWidgets are loaded
+ colorsChanged();
+
updateDateTimeFields();
closeMessage();
@@ -701,8 +704,32 @@ void MainTab::clearTabs()
widget->clear();
}
+// setup the colors of 'header' elements in the tab widget
void MainTab::colorsChanged()
{
+ // Put together appropriate CSS stylesheets: NB: colors below in same order as the enum in prefs.h
+ QStringList colors = { "mediumblue", "lightblue", "black" }; // If using dark theme, set color appropriately
+ QString colorText = colors[prefs.headerstyle_color];
+
+ QString lastpart = colorText + " ;}";
+
+ // only set the color if the widget is enabled
+ QString CSSLabelcolor = "QLabel:enabled { color: " + lastpart;
+ QString CSSTitlecolor = "QGroupBox::title:enabled { color: " + lastpart ;
+
+ // apply to all the group boxes
+ QList<QGroupBox *>groupBoxes = this->findChildren<QGroupBox *>();
+ for (QGroupBox *gb: groupBoxes)
+ gb->setStyleSheet(QString(CSSTitlecolor));
+
+ // apply to all labels that are marked as headers in the .ui file
+ QList<QLabel *>labels = this->findChildren<QLabel *>();
+ for (QLabel *ql: labels) {
+ if (ql->property("isHeader").toBool())
+ ql->setStyleSheet(QString(CSSLabelcolor));
+ }
+
+ // finally call the individual updateUi() functions so they can overwrite these style sheets
for (TabBase *widget: extraWidgets)
widget->updateUi();
}