mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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 <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1ff488a439
commit
8b36cf1051
6 changed files with 133 additions and 8 deletions
17
core/pref.h
17
core/pref.h
|
@ -66,6 +66,12 @@ enum unit_system_values {
|
|||
PERSONALIZE
|
||||
};
|
||||
|
||||
enum headerstyle_color_values {
|
||||
MEDIUMBLUE,
|
||||
LIGHTBLUE,
|
||||
BLACK
|
||||
};
|
||||
|
||||
// ********** PREFERENCES **********
|
||||
// This struct is kept global for all of ssrf
|
||||
// most of the fields are loaded from git as
|
||||
|
@ -100,11 +106,12 @@ struct preferences {
|
|||
dive_computer_prefs_t dive_computer4;
|
||||
|
||||
// ********** Display *************
|
||||
bool display_invalid_dives;
|
||||
const char *divelist_font;
|
||||
double font_size;
|
||||
double mobile_scale;
|
||||
bool show_developer;
|
||||
bool display_invalid_dives;
|
||||
const char *divelist_font;
|
||||
double font_size;
|
||||
double mobile_scale;
|
||||
bool show_developer;
|
||||
enum headerstyle_color_values headerstyle_color;
|
||||
|
||||
// ********** Equipment tab *******
|
||||
const char *default_cylinder;
|
||||
|
|
|
@ -55,6 +55,7 @@ void qPrefDisplay::loadSync(bool doSync)
|
|||
disk_mobile_scale(doSync);
|
||||
disk_display_invalid_dives(doSync);
|
||||
disk_show_developer(doSync);
|
||||
disk_headerstyle_color(doSync);
|
||||
if (!doSync) {
|
||||
load_tooltip_position();
|
||||
load_theme();
|
||||
|
@ -176,6 +177,29 @@ void qPrefDisplay::setCorrectFont()
|
|||
prefs.display_invalid_dives = qPrefPrivate::propValue(keyFromGroupAndName(group, "displayinvalid"), default_prefs.display_invalid_dives).toBool();
|
||||
}
|
||||
|
||||
void qPrefDisplay::set_headerstyle_color(enum headerstyle_color_values value)
|
||||
{
|
||||
if (value != prefs.headerstyle_color) {
|
||||
prefs.headerstyle_color = value;
|
||||
disk_headerstyle_color(true);
|
||||
emit instance()->headerstyle_colorChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
void qPrefDisplay::disk_headerstyle_color(bool doSync)
|
||||
{
|
||||
static enum headerstyle_color_values current_state;
|
||||
if (doSync) {
|
||||
if (current_state != prefs.headerstyle_color) {
|
||||
current_state = prefs.headerstyle_color;
|
||||
qPrefPrivate::propSetValue(keyFromGroupAndName(group, "headerstyle_color"), prefs.headerstyle_color, default_prefs.headerstyle_color);
|
||||
}
|
||||
} else {
|
||||
prefs.headerstyle_color = (enum headerstyle_color_values)qPrefPrivate::propValue(keyFromGroupAndName(group, "headerstyle_color"), default_prefs.headerstyle_color).toInt();
|
||||
current_state = prefs.headerstyle_color;
|
||||
}
|
||||
}
|
||||
|
||||
HANDLE_PROP_QSTRING(Display, "FileDialog/LastDir", lastDir);
|
||||
|
||||
HANDLE_PROP_QSTRING(Display, "Theme/currentTheme", theme);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
class qPrefDisplay : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(enum headerstyle_color_values headerstyle_color READ headerstyle_color WRITE set_headerstyle_color NOTIFY headerstyle_colorChanged)
|
||||
Q_PROPERTY(int animation_speed READ animation_speed WRITE set_animation_speed NOTIFY animation_speedChanged)
|
||||
Q_PROPERTY(QString divelist_font READ divelist_font WRITE set_divelist_font NOTIFY divelist_fontChanged)
|
||||
Q_PROPERTY(double font_size READ font_size WRITE set_font_size NOTIFY font_sizeChanged)
|
||||
|
@ -35,6 +36,7 @@ public:
|
|||
static void sync() { loadSync(true); }
|
||||
|
||||
public:
|
||||
static enum headerstyle_color_values headerstyle_color() { return prefs.headerstyle_color; }
|
||||
static int animation_speed() { return prefs.animation_speed; }
|
||||
static QString divelist_font() { return prefs.divelist_font; }
|
||||
static double font_size() { return prefs.font_size; }
|
||||
|
@ -54,6 +56,7 @@ public:
|
|||
static bool singleColumnPortrait() { return st_singleColumnPortrait; }
|
||||
|
||||
public slots:
|
||||
static void set_headerstyle_color(enum headerstyle_color_values value);
|
||||
static void set_animation_speed(int value);
|
||||
static void set_divelist_font(const QString &value);
|
||||
static void set_font_size(double value);
|
||||
|
@ -73,6 +76,7 @@ public slots:
|
|||
static void set_singleColumnPortrait(bool value);
|
||||
|
||||
signals:
|
||||
void headerstyle_colorChanged(enum headerstyle_color_values value);
|
||||
void animation_speedChanged(int value);
|
||||
void divelist_fontChanged(const QString &value);
|
||||
void font_sizeChanged(double value);
|
||||
|
@ -95,6 +99,7 @@ private:
|
|||
qPrefDisplay() {}
|
||||
|
||||
// functions to load/sync variable with disk
|
||||
static void disk_headerstyle_color(bool doSync);
|
||||
static void disk_animation_speed(bool doSync);
|
||||
static void disk_divelist_font(bool doSync);
|
||||
static void disk_font_size(bool doSync);
|
||||
|
|
|
@ -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));
|
||||
|
||||
}
|
||||
|
|
|
@ -120,6 +120,77 @@
|
|||
</item>
|
||||
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_headerstyle">
|
||||
<property name="title">
|
||||
<string>Header text colors</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="headerModeLayout_4">
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
|
||||
<item>
|
||||
<widget class="QLabel" name="label_help_header">
|
||||
<property name="toolTip">
|
||||
<string extracomment="Help info header"/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="darkmodeLayout_5">
|
||||
|
||||
<item>
|
||||
<widget class="QRadioButton" name="mediumblue_text">
|
||||
<property name="text">
|
||||
<string>Medium Blue</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<widget class="QRadioButton" name="lightblue_text">
|
||||
<property name="text">
|
||||
<string>Light Blue</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<widget class="QRadioButton" name="black_text">
|
||||
<property name="text">
|
||||
<string>Black</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>195</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -132,8 +203,10 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue