From 8b36cf10518c54d76134686a3e079bbde176022b Mon Sep 17 00:00:00 2001 From: willemferguson Date: Sun, 1 Nov 2020 20:43:54 +0200 Subject: desktop: offer different colors for info tab titles Add a preference option to set the color of the text on the information tab to either MediumBlue, LightBlue or Black. The last two of these colors are meant to enable areadable font contrast on displays with dark mode. The choice is saved with the other preferences. [Dirk Hohndel: this isn't really about dark mode, so changed many of the types and variable names, changed the user visible texts, and addressed some whitespace issues] Signed-off-by: willemferguson Signed-off-by: Dirk Hohndel --- .../preferences/preferences_defaults.cpp | 3 + .../preferences/preferences_defaults.ui | 73 ++++++++++++++++++++++ desktop-widgets/tab-widgets/TabDiveInformation.cpp | 19 +++++- 3 files changed, 92 insertions(+), 3 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp index ca1b51acb..3fba8e1b8 100644 --- a/desktop-widgets/preferences/preferences_defaults.cpp +++ b/desktop-widgets/preferences/preferences_defaults.cpp @@ -24,6 +24,7 @@ PreferencesDefaults::~PreferencesDefaults() void PreferencesDefaults::refreshSettings() { + prefs.headerstyle_color == BLACK ? ui->black_text->setChecked(true) : (prefs.headerstyle_color == LIGHTBLUE ? ui->lightblue_text->setChecked(true) : ui->mediumblue_text->setChecked(true)); ui->font->setCurrentFont(qPrefDisplay::divelist_font()); ui->fontsize->setValue(qPrefDisplay::font_size()); ui->velocitySlider->setValue(qPrefDisplay::animation_speed()); @@ -35,4 +36,6 @@ void PreferencesDefaults::syncSettings() qPrefDisplay::set_divelist_font(ui->font->currentFont().toString()); qPrefDisplay::set_font_size(ui->fontsize->value()); qPrefDisplay::set_animation_speed(ui->velocitySlider->value()); + qPrefDisplay::set_headerstyle_color(ui->black_text->isChecked() ? BLACK : (ui->lightblue_text->isChecked() ? LIGHTBLUE : MEDIUMBLUE)); + } diff --git a/desktop-widgets/preferences/preferences_defaults.ui b/desktop-widgets/preferences/preferences_defaults.ui index 030bb77d6..b6104b256 100644 --- a/desktop-widgets/preferences/preferences_defaults.ui +++ b/desktop-widgets/preferences/preferences_defaults.ui @@ -120,6 +120,77 @@ + + + Header text colors + + + + 5 + + + + + + + + + true + + + Depending on the display mode, sometimes the blue text used in headers in the various information panes is not clearly visible. Select a color that fits the current theme of your computer. For dark mode, select either Light Blue or Black (rendered white using a dark theme). The default is Medium Blue. + + + + + + + + + + + Medium Blue + + + + + + + + Light Blue + + + + + + + + Black + + + + + + + + + + + + + + + Qt::Vertical + + + + 0 + 195 + + + + + Qt::Vertical @@ -132,8 +203,10 @@ + + diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index 5baec3694..78bc7b485 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -23,7 +23,18 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne connect(&diveListNotifier, &DiveListNotifier::cylinderAdded, this, &TabDiveInformation::cylinderChanged); connect(&diveListNotifier, &DiveListNotifier::cylinderRemoved, this, &TabDiveInformation::cylinderChanged); connect(&diveListNotifier, &DiveListNotifier::cylinderEdited, this, &TabDiveInformation::cylinderChanged); + + // 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 + " ;}"; + QString CSSLabelColor = "QLabel { color: " + lastpart; + QString CSSTitleColor = "QGroupBox::title { color: " + lastpart ; QStringList atmPressTypes { "mbar", get_depth_unit() ,tr("Use DC")}; + QString CSSSetSmallLabel = "QLabel { color: "; + CSSSetSmallLabel.append(colorText + "; font-size: "); + CSSSetSmallLabel.append(QString::number((int)(0.5 + ui->diveHeadingLabel->geometry().height() * 0.66)) + "px;}"); ui->atmPressType->insertItems(0, atmPressTypes); pressTypeIndex = 0; ui->waterTypeCombo->insertItems(0, getWaterTypesAsString()); @@ -34,8 +45,10 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne types.append(gettextFromC::tr(divemode_text_ui[i])); ui->diveType->insertItems(0, types); connect(ui->diveType, SIGNAL(currentIndexChanged(int)), this, SLOT(diveModeChanged(int))); - QString CSSSetSmallLabel = "QLabel { font-size: " + // Using label height - QString::number((int)(0.5 + ui->diveHeadingLabel->geometry().height() * 0.66)) + "px;}"; // .. set CSS font size of star widget subscripts + 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); @@ -55,7 +68,7 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne updateWaterTypeWidget(); QPixmap warning (":salinity-warning-icon"); ui->salinityOverWrittenIcon->setPixmap(warning); - ui->salinityOverWrittenIcon->setToolTip("Water type differs from that of dc"); + ui->salinityOverWrittenIcon->setToolTip(CSSSetSmallLabel); ui->salinityOverWrittenIcon->setToolTipDuration(2500); ui->salinityOverWrittenIcon->setVisible(false); } -- cgit v1.2.3-70-g09d2