diff options
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/TabBase.cpp | 4 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabBase.h | 1 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.cpp | 47 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.h | 1 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveStatistics.cpp | 2 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 9 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.h | 1 |
7 files changed, 42 insertions, 23 deletions
diff --git a/desktop-widgets/tab-widgets/TabBase.cpp b/desktop-widgets/tab-widgets/TabBase.cpp index a0bfb2251..602480253 100644 --- a/desktop-widgets/tab-widgets/TabBase.cpp +++ b/desktop-widgets/tab-widgets/TabBase.cpp @@ -4,3 +4,7 @@ TabBase::TabBase(QWidget *parent) : QWidget(parent) { } + +void TabBase::updateUi() +{ +} diff --git a/desktop-widgets/tab-widgets/TabBase.h b/desktop-widgets/tab-widgets/TabBase.h index 054bc9f30..3f8d9bf85 100644 --- a/desktop-widgets/tab-widgets/TabBase.h +++ b/desktop-widgets/tab-widgets/TabBase.h @@ -13,6 +13,7 @@ public: TabBase(QWidget *parent = 0); virtual void updateData() = 0; virtual void clear() = 0; + virtual void updateUi(); }; #endif diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index 78bc7b485..057bd3ad6 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -24,17 +24,7 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne 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()); @@ -45,15 +35,6 @@ 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))); - 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); if (!prefs.extraEnvironmentalDefault) // if extraEnvironmental preference is turned off showCurrentWidget(false, 0); // Show current star widget at lefthand side QAction *action = new QAction(tr("OK"), this); @@ -68,7 +49,6 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne updateWaterTypeWidget(); QPixmap warning (":salinity-warning-icon"); ui->salinityOverWrittenIcon->setPixmap(warning); - ui->salinityOverWrittenIcon->setToolTip(CSSSetSmallLabel); ui->salinityOverWrittenIcon->setToolTipDuration(2500); ui->salinityOverWrittenIcon->setVisible(false); } @@ -241,7 +221,7 @@ void TabDiveInformation::updateData() if (prefs.salinityEditDefault) { //If edit-salinity is enabled then set correct water type in combobox: ui->waterTypeCombo->setCurrentIndex(updateSalinityComboIndex(salinity_value)); } else { // If water salinity is not editable: show water type as a text label - ui->waterTypeText->setText(get_water_type_string(salinity_value)); + ui->waterTypeText->setText(get_water_type_string(salinity_value)); } ui->salinityText->setText(get_salinity_string(salinity_value)); } else { @@ -263,6 +243,31 @@ void TabDiveInformation::updateData() showCurrentWidget(false, 0); // Show current star widget at lefthand side } +void TabDiveInformation::updateUi() +{ + // 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 ; + QString CSSSetSmallLabel = "QLabel { 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); + +} + // From the index of the water type combo box, set the dive->salinity to an appropriate value void TabDiveInformation::on_waterTypeCombo_activated(int index) { diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.h b/desktop-widgets/tab-widgets/TabDiveInformation.h index 8efa71d44..2beaa98ac 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.h +++ b/desktop-widgets/tab-widgets/TabDiveInformation.h @@ -16,6 +16,7 @@ public: ~TabDiveInformation(); void updateData() override; void clear() override; + void updateUi() override; private slots: void divesChanged(const QVector<dive *> &dives, DiveField field); void cylinderChanged(dive *d); diff --git a/desktop-widgets/tab-widgets/TabDiveStatistics.cpp b/desktop-widgets/tab-widgets/TabDiveStatistics.cpp index ce8eba13c..da0587802 100644 --- a/desktop-widgets/tab-widgets/TabDiveStatistics.cpp +++ b/desktop-widgets/tab-widgets/TabDiveStatistics.cpp @@ -112,7 +112,7 @@ void TabDiveStatistics::updateData() bool is_freedive = current_dive && current_dive->dc.divemode == FREEDIVE; ui->divesAllText->setText(QString::number(stats_selection.selection_size)); ui->totalTimeAllText->setText(get_dive_duration_string(stats_selection.total_time.seconds, tr("h"), tr("min"), tr("sec"), " ", is_freedive)); - + int seconds = stats_selection.total_time.seconds; if (stats_selection.selection_size) seconds /= stats_selection.selection_size; diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index ff5cb4121..0a9799b65 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -34,6 +34,7 @@ #include "TabDiveStatistics.h" #include "TabDiveSite.h" #include "TabDiveComputer.h" +#include "core/settings/qPrefDisplay.h" #include <QCompleter> #include <QScrollBar> @@ -89,7 +90,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), // Alas, this is not the case. When the user switches to system-format, the preferences sends the according // signal. However, the correct date and time format is set by the preferences dialog later. This should be fixed. connect(PreferencesDialog::instance(), &PreferencesDialog::settingsChanged, this, &MainTab::updateDateTimeFields); - + connect(qPrefDisplay::instance(), &qPrefDisplay::headerstyle_colorChanged, this, &MainTab::colorsChanged); QAction *action = new QAction(tr("Apply changes"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges())); ui.diveNotesMessage->addAction(action); @@ -699,3 +700,9 @@ void MainTab::clearTabs() for (auto widget: extraWidgets) widget->clear(); } + +void MainTab::colorsChanged() +{ + for (TabBase *widget: extraWidgets) + widget->updateUi(); +} diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h index a2fc111e9..ea7240d08 100644 --- a/desktop-widgets/tab-widgets/maintab.h +++ b/desktop-widgets/tab-widgets/maintab.h @@ -64,6 +64,7 @@ slots: void enableEdition(); void escDetected(void); void updateDateTimeFields(); + void colorsChanged(); private: Ui::MainTab ui; bool editMode; |