GlobalSettings settings;
settings.setValue(GlobalSettings::Key_General_Theme, state);
settings.apply_theme();
+
+ QMessageBox msg(this);
+ msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+ msg.setIcon(QMessageBox::Question);
+
+ if (settings.current_theme_is_dark()) {
+ msg.setText(tr("You selected a dark theme.\n" \
+ "Should I set the user-adjustable colors to better suit your choice?\n\n" \
+ "Please keep in mind that PulseView may need a restart to display correctly."));
+ if (msg.exec() == QMessageBox::Yes)
+ settings.set_dark_theme_default_colors();
+ } else {
+ msg.setText(tr("You selected a bright theme.\n" \
+ "Should I set the user-adjustable colors to better suit your choice?\n\n" \
+ "Please keep in mind that PulseView may need a restart to display correctly."));
+ if (msg.exec() == QMessageBox::Yes)
+ settings.set_bright_theme_default_colors();
+ }
}
void Settings::on_general_style_changed(int state)
QPalette GlobalSettings::default_palette_;
GlobalSettings::GlobalSettings() :
- QSettings()
+ QSettings(),
+ is_dark_theme_(false)
{
beginGroup("Settings");
}
+void GlobalSettings::save_internal_defaults()
+{
+ default_style_ = qApp->style()->objectName();
+ if (default_style_.isEmpty())
+ default_style_ = "fusion";
+
+ default_palette_ = QApplication::palette();
+}
+
void GlobalSettings::set_defaults_where_needed()
{
// Use no theme by default
// Enable filling logic signal high areas by default
if (!contains(Key_View_FillSignalHighAreas))
setValue(Key_View_FillSignalHighAreas, true);
- if (!contains(Key_View_FillSignalHighAreaColor))
- setValue(Key_View_FillSignalHighAreaColor,
- QColor(0, 0, 0, 5 * 256 / 100).rgba());
if (!contains(Key_View_DefaultDivHeight))
setValue(Key_View_DefaultDivHeight,
// Notify user of existing stack trace by default
if (!contains(Key_Log_NotifyOfStacktrace))
setValue(Key_Log_NotifyOfStacktrace, true);
+
+ // Default theme is bright, so use its color scheme
+ set_bright_theme_default_colors();
}
-void GlobalSettings::save_internal_defaults()
+void GlobalSettings::set_bright_theme_default_colors()
{
- default_style_ = qApp->style()->objectName();
- if (default_style_.isEmpty())
- default_style_ = "fusion";
+ setValue(Key_View_FillSignalHighAreaColor,
+ QColor(0, 0, 0, 5 * 256 / 100).rgba());
+}
- default_palette_ = QApplication::palette();
+void GlobalSettings::set_dark_theme_default_colors()
+{
+ setValue(Key_View_FillSignalHighAreaColor,
+ QColor(188, 188, 188, 9 * 256 / 100).rgba());
+}
+
+bool GlobalSettings::current_theme_is_dark()
+{
+ return is_dark_theme_;
}
void GlobalSettings::apply_theme()
else
qApp->setStyle(style);
+ is_dark_theme_ = false;
+
if (theme_name.compare("QDarkStyleSheet") == 0) {
QPalette dark_palette;
dark_palette.setColor(QPalette::Window, QColor(53, 53, 53));
dark_palette.setColor(QPalette::Dark, QColor(35, 35, 35));
dark_palette.setColor(QPalette::Highlight, QColor(42, 130, 218));
qApp->setPalette(dark_palette);
+ is_dark_theme_ = true;
} else if (theme_name.compare("DarkStyle") == 0) {
QPalette dark_palette;
dark_palette.setColor(QPalette::Window, QColor(53, 53, 53));
dark_palette.setColor(QPalette::HighlightedText, Qt::white);
dark_palette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(127, 127, 127));
qApp->setPalette(dark_palette);
+ is_dark_theme_ = true;
}
QPixmapCache::clear();