mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
7d18a525f1
commit
814cda7183
6 changed files with 80 additions and 15 deletions
|
@ -73,6 +73,9 @@
|
|||
<property name="text">
|
||||
<string>Suit</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="suit">
|
||||
<property name="readOnly">
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -62,6 +62,9 @@
|
|||
<property name="text">
|
||||
<string>DIVE</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
|
@ -208,6 +211,9 @@
|
|||
<property name="text">
|
||||
<string>GAS</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
|
@ -363,6 +369,9 @@
|
|||
<property name="text">
|
||||
<string>ENVIRONMENT</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
<property name="text">
|
||||
<string>Filter</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -82,6 +82,10 @@
|
|||
<property name="text">
|
||||
<string>Date</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>1</horstretch>
|
||||
|
@ -98,6 +102,9 @@
|
|||
<property name="text">
|
||||
<string>Time</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>1</horstretch>
|
||||
|
@ -133,6 +140,9 @@
|
|||
<property name="text">
|
||||
<string>Depth</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
|
@ -146,6 +156,9 @@
|
|||
<property name="text">
|
||||
<string>Duration (h:mm)</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
@ -230,6 +243,9 @@
|
|||
<property name="text">
|
||||
<string>Location</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
|
@ -302,6 +318,9 @@
|
|||
<property name="text">
|
||||
<string>Divemaster</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
|
@ -312,6 +331,9 @@
|
|||
<property name="text">
|
||||
<string>Buddy</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
|
@ -348,6 +370,9 @@
|
|||
<property name="text">
|
||||
<string>Tags</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
|
@ -396,6 +421,9 @@
|
|||
<property name="text">
|
||||
<string>Rating</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" alignment="Qt::AlignVCenter">
|
||||
|
@ -425,6 +453,9 @@
|
|||
<property name="text">
|
||||
<string>Notes</string>
|
||||
</property>
|
||||
<property name="isHeader" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
|
|
Loading…
Reference in a new issue