From 814cda718365823654c7d13f2e24f31ac58ddb45 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 2 Nov 2020 12:36:29 -0800 Subject: 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 --- desktop-widgets/tab-widgets/TabDiveEquipment.ui | 3 +++ desktop-widgets/tab-widgets/TabDiveInformation.cpp | 22 +++++---------- desktop-widgets/tab-widgets/TabDiveInformation.ui | 9 +++++++ desktop-widgets/tab-widgets/TabDiveSite.ui | 3 +++ desktop-widgets/tab-widgets/maintab.cpp | 27 +++++++++++++++++++ desktop-widgets/tab-widgets/maintab.ui | 31 ++++++++++++++++++++++ 6 files changed, 80 insertions(+), 15 deletions(-) (limited to 'desktop-widgets/tab-widgets') diff --git a/desktop-widgets/tab-widgets/TabDiveEquipment.ui b/desktop-widgets/tab-widgets/TabDiveEquipment.ui index d81df5914..01dd1cd2d 100644 --- a/desktop-widgets/tab-widgets/TabDiveEquipment.ui +++ b/desktop-widgets/tab-widgets/TabDiveEquipment.ui @@ -73,6 +73,9 @@ Suit + + true + diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index 057bd3ad6..b9b504403 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -249,23 +249,15 @@ void TabDiveInformation::updateUi() QStringList colors = { "mediumblue", "lightblue", "black" }; // If using dark theme, set color appropriately QString colorText = colors[prefs.headerstyle_color]; - QString lastpart = colorText + " ;}"; - QString CSSLabelcolor = "QLabel { color: " + lastpart; - QString CSSTitlecolor = "QGroupBox::title { color: " + lastpart ; - QString CSSSetSmallLabel = "QLabel { color: "; + QString CSSSetSmallLabel = "QLabel:enabled { color: "; CSSSetSmallLabel.append(colorText + "; font-size: "); CSSSetSmallLabel.append(QString::number((int)(0.5 + ui->diveHeadingLabel->geometry().height() * 0.66)) + "px;}"); - ui->scrollAreaWidgetContents_3->setStyleSheet(CSSTitlecolor); - ui->diveHeadingLabel->setStyleSheet(CSSLabelcolor); - ui->gasHeadingLabel->setStyleSheet(CSSLabelcolor); - ui->environmentHeadingLabel->setStyleSheet(CSSLabelcolor); - ui->groupBox_visibility->setStyleSheet(CSSSetSmallLabel); - ui->groupBox_current->setStyleSheet(CSSSetSmallLabel); - ui->groupBox_wavesize->setStyleSheet(CSSSetSmallLabel); - ui->groupBox_surge->setStyleSheet(CSSSetSmallLabel); - ui->groupBox_chill->setStyleSheet(CSSSetSmallLabel); - ui->salinityOverWrittenIcon->setToolTip(CSSSetSmallLabel); - + ui->groupBox_visibility->setStyleSheet(ui->groupBox_visibility->styleSheet() + CSSSetSmallLabel); + ui->groupBox_current->setStyleSheet(ui->groupBox_current->styleSheet() + CSSSetSmallLabel); + ui->groupBox_wavesize->setStyleSheet(ui->groupBox_wavesize->styleSheet() + CSSSetSmallLabel); + ui->groupBox_surge->setStyleSheet(ui->groupBox_surge->styleSheet() + CSSSetSmallLabel); + ui->groupBox_chill->setStyleSheet(ui->groupBox_chill->styleSheet() + CSSSetSmallLabel); + ui->salinityOverWrittenIcon->setToolTip(ui->salinityOverWrittenIcon->styleSheet() + CSSSetSmallLabel); } // From the index of the water type combo box, set the dive->salinity to an appropriate value diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.ui b/desktop-widgets/tab-widgets/TabDiveInformation.ui index e31344529..d2619bada 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.ui +++ b/desktop-widgets/tab-widgets/TabDiveInformation.ui @@ -62,6 +62,9 @@ DIVE + + true + @@ -208,6 +211,9 @@ GAS + + true + @@ -363,6 +369,9 @@ ENVIRONMENT + + true + diff --git a/desktop-widgets/tab-widgets/TabDiveSite.ui b/desktop-widgets/tab-widgets/TabDiveSite.ui index 316527e04..adb16f598 100644 --- a/desktop-widgets/tab-widgets/TabDiveSite.ui +++ b/desktop-widgets/tab-widgets/TabDiveSite.ui @@ -21,6 +21,9 @@ Filter + + true + 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 + QListgroupBoxes = this->findChildren(); + for (QGroupBox *gb: groupBoxes) + gb->setStyleSheet(QString(CSSTitlecolor)); + + // apply to all labels that are marked as headers in the .ui file + QListlabels = this->findChildren(); + 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(); } diff --git a/desktop-widgets/tab-widgets/maintab.ui b/desktop-widgets/tab-widgets/maintab.ui index 7e3d4c9b3..aa8371dad 100644 --- a/desktop-widgets/tab-widgets/maintab.ui +++ b/desktop-widgets/tab-widgets/maintab.ui @@ -82,6 +82,10 @@ Date + + true + + 1 @@ -98,6 +102,9 @@ Time + + true + 1 @@ -133,6 +140,9 @@ Depth + + true + @@ -146,6 +156,9 @@ Duration (h:mm) + + true + @@ -230,6 +243,9 @@ Location + + true + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft @@ -302,6 +318,9 @@ Divemaster + + true + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft @@ -312,6 +331,9 @@ Buddy + + true + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft @@ -348,6 +370,9 @@ Tags + + true + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft @@ -396,6 +421,9 @@ Rating + + true + @@ -425,6 +453,9 @@ Notes + + true + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft -- cgit v1.2.3-70-g09d2