// Prepare the global settings since logging needs them early on
pv::GlobalSettings settings;
- settings.save_default_palette();
+ settings.save_internal_defaults();
settings.set_defaults_where_needed();
settings.apply_theme();
#include <QScrollBar>
#include <QSpinBox>
#include <QString>
+#include <QStyleFactory>
#include <QTextBrowser>
#include <QTextDocument>
#include <QTextStream>
description_1->setAlignment(Qt::AlignRight);
general_layout->addRow(description_1);
+ QComboBox *style_cb = new QComboBox();
+ style_cb->addItem(tr("System Default"), "");
+ for (QString& s : QStyleFactory::keys())
+ style_cb->addItem(s, s);
+
+ const QString current_style =
+ settings.value(GlobalSettings::Key_General_Style).toString();
+ if (current_style.isEmpty())
+ style_cb->setCurrentIndex(0);
+ else
+ style_cb->setCurrentIndex(style_cb->findText(current_style, 0));
+
+ connect(style_cb, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(on_general_style_changed(int)));
+ general_layout->addRow(tr("Qt widget style"), style_cb);
+
+ QLabel *description_2 = new QLabel(tr("(Dark themes look best with the Fusion style)"));
+ description_2->setAlignment(Qt::AlignRight);
+ general_layout->addRow(description_2);
+
return form;
}
settings.apply_theme();
}
+void Settings::on_general_style_changed(int state)
+{
+ GlobalSettings settings;
+
+ if (state == 0)
+ settings.setValue(GlobalSettings::Key_General_Style, "");
+ else
+ settings.setValue(GlobalSettings::Key_General_Style,
+ QStyleFactory::keys().at(state - 1));
+
+ settings.apply_theme();
+}
+
void Settings::on_view_zoomToFitDuringAcq_changed(int state)
{
GlobalSettings settings;
private Q_SLOTS:
void on_page_changed(QListWidgetItem *current, QListWidgetItem *previous);
void on_general_theme_changed_changed(int state);
+ void on_general_style_changed(int state);
void on_view_zoomToFitDuringAcq_changed(int state);
void on_view_zoomToFitAfterAcq_changed(int state);
void on_view_triggerIsZero_changed(int state);
#include <QFontMetrics>
#include <QPixmapCache>
#include <QString>
-#include <QStyleFactory>
+#include <QStyle>
#include <QtGlobal>
using std::map;
};
const QString GlobalSettings::Key_General_Theme = "General_Theme";
+const QString GlobalSettings::Key_General_Style = "General_Style";
const QString GlobalSettings::Key_View_ZoomToFitDuringAcq = "View_ZoomToFitDuringAcq";
const QString GlobalSettings::Key_View_ZoomToFitAfterAcq = "View_ZoomToFitAfterAcq";
const QString GlobalSettings::Key_View_TriggerIsZeroTime = "View_TriggerIsZeroTime";
vector<GlobalSettingsInterface*> GlobalSettings::callbacks_;
bool GlobalSettings::tracking_ = false;
map<QString, QVariant> GlobalSettings::tracked_changes_;
+QString GlobalSettings::default_style_;
QPalette GlobalSettings::default_palette_;
GlobalSettings::GlobalSettings() :
// Use no theme by default
if (!contains(Key_General_Theme))
setValue(Key_General_Theme, 0);
+ if (!contains(Key_General_Style))
+ setValue(Key_General_Style, "");
// Enable zoom-to-fit after acquisition by default
if (!contains(Key_View_ZoomToFitAfterAcq))
setValue(Key_Log_NotifyOfStacktrace, true);
}
-void GlobalSettings::save_default_palette()
+void GlobalSettings::save_internal_defaults()
{
+ default_style_ = qApp->style()->objectName();
+ if (default_style_.isEmpty())
+ default_style_ = "fusion";
+
default_palette_ = QApplication::palette();
}
qApp->setPalette(default_palette_);
+ const QString style = value(Key_General_Style).toString();
+ if (style.isEmpty())
+ qApp->setStyle(default_style_);
+ else
+ qApp->setStyle(style);
+
if (theme_name.compare("QDarkStyleSheet") == 0) {
-#ifdef Q_OS_WIN
- qApp->setStyle(QStyleFactory::create("Fusion"));
-#endif
QPalette dark_palette;
dark_palette.setColor(QPalette::Window, QColor(53, 53, 53));
dark_palette.setColor(QPalette::WindowText, Qt::white);
dark_palette.setColor(QPalette::Highlight, QColor(42, 130, 218));
qApp->setPalette(dark_palette);
} else if (theme_name.compare("DarkStyle") == 0) {
-#ifdef Q_OS_WIN
- qApp->setStyle(QStyleFactory::create("Fusion"));
-#endif
QPalette dark_palette;
dark_palette.setColor(QPalette::Window, QColor(53, 53, 53));
dark_palette.setColor(QPalette::WindowText, Qt::white);
public:
static const QString Key_General_Theme;
+ static const QString Key_General_Style;
static const QString Key_View_ZoomToFitDuringAcq;
static const QString Key_View_ZoomToFitAfterAcq;
static const QString Key_View_TriggerIsZeroTime;
GlobalSettings();
void set_defaults_where_needed();
+ void save_internal_defaults();
- void save_default_palette();
void apply_theme();
static void add_change_handler(GlobalSettingsInterface *cb);
static bool tracking_;
static map<QString, QVariant> tracked_changes_;
+ static QString default_style_;
static QPalette default_palette_;
};