X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fglobalsettings.cpp;h=1c23e04c39a85929ed17de14d4e23878caeaca58;hb=0466001be51e779b23aaebec1cc9361305c07be9;hp=1cd6566530590f2d5d52ba14c0d06fe9ccf39f72;hpb=a42d2514a57051f971e7b239bc3765ebf93669ae;p=pulseview.git diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index 1cd65665..1c23e04c 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -18,6 +18,7 @@ */ #include "globalsettings.hpp" +#include "application.hpp" #include #include @@ -42,8 +43,10 @@ const vector< pair > Themes { {"DarkStyle", ":/themes/darkstyle/darkstyle.qss"} }; +const QString GlobalSettings::Key_General_Language = "General_Language"; const QString GlobalSettings::Key_General_Theme = "General_Theme"; const QString GlobalSettings::Key_General_Style = "General_Style"; +const QString GlobalSettings::Key_General_SaveWithSetup = "General_SaveWithSetup"; const QString GlobalSettings::Key_View_ZoomToFitDuringAcq = "View_ZoomToFitDuringAcq"; const QString GlobalSettings::Key_View_ZoomToFitAfterAcq = "View_ZoomToFitAfterAcq"; const QString GlobalSettings::Key_View_TriggerIsZeroTime = "View_TriggerIsZeroTime"; @@ -58,20 +61,22 @@ const QString GlobalSettings::Key_View_DefaultDivHeight = "View_DefaultDivHeight const QString GlobalSettings::Key_View_DefaultLogicHeight = "View_DefaultLogicHeight"; const QString GlobalSettings::Key_View_ShowHoverMarker = "View_ShowHoverMarker"; const QString GlobalSettings::Key_View_SnapDistance = "View_SnapDistance"; +const QString GlobalSettings::Key_View_CursorFillColor = "View_CursorFillColor"; const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable"; const QString GlobalSettings::Key_Dec_ExportFormat = "Dec_ExportFormat"; +const QString GlobalSettings::Key_Dec_AlwaysShowAllRows = "Dec_AlwaysShowAllRows"; const QString GlobalSettings::Key_Log_BufferSize = "Log_BufferSize"; const QString GlobalSettings::Key_Log_NotifyOfStacktrace = "Log_NotifyOfStacktrace"; vector GlobalSettings::callbacks_; bool GlobalSettings::tracking_ = false; +bool GlobalSettings::is_dark_theme_ = false; map GlobalSettings::tracked_changes_; QString GlobalSettings::default_style_; QPalette GlobalSettings::default_palette_; GlobalSettings::GlobalSettings() : - QSettings(), - is_dark_theme_(false) + QSettings() { beginGroup("Settings"); } @@ -87,12 +92,24 @@ void GlobalSettings::save_internal_defaults() void GlobalSettings::set_defaults_where_needed() { + if (!contains(Key_General_Language)) { + // Determine and set default UI language + QString language = QLocale().uiLanguages().first(); // May return e.g. en-Latn-US + language = language.split("-").first(); + + setValue(Key_General_Language, language); + } + // Use no theme by default if (!contains(Key_General_Theme)) setValue(Key_General_Theme, 0); if (!contains(Key_General_Style)) setValue(Key_General_Style, ""); + // Save setup with .sr files by default + if (!contains(Key_General_SaveWithSetup)) + setValue(Key_General_SaveWithSetup, true); + // Enable zoom-to-fit after acquisition by default if (!contains(Key_View_ZoomToFitAfterAcq)) setValue(Key_View_ZoomToFitAfterAcq, true); @@ -123,8 +140,10 @@ void GlobalSettings::set_defaults_where_needed() if (!contains(Key_View_SnapDistance)) setValue(Key_View_SnapDistance, 15); - if (!contains(Key_Dec_ExportFormat)) - setValue(Key_Dec_ExportFormat, "%s %d: %c: %1"); + // %c was used for the row name in the past so we need to transition such users + if (!contains(Key_Dec_ExportFormat) || + value(Key_Dec_ExportFormat).toString() == "%s %d: %c: %1") + setValue(Key_Dec_ExportFormat, "%s %d: %r: %1"); // Default to 500 lines of backlog if (!contains(Key_Log_BufferSize)) @@ -134,20 +153,27 @@ void GlobalSettings::set_defaults_where_needed() if (!contains(Key_Log_NotifyOfStacktrace)) setValue(Key_Log_NotifyOfStacktrace, true); - // Default theme is bright, so use its color scheme - set_bright_theme_default_colors(); + // Default theme is bright, so use its color scheme if undefined + if (!contains(Key_View_CursorFillColor)) + set_bright_theme_default_colors(); } void GlobalSettings::set_bright_theme_default_colors() { setValue(Key_View_FillSignalHighAreaColor, QColor(0, 0, 0, 5 * 256 / 100).rgba()); + + setValue(Key_View_CursorFillColor, + QColor(220, 231, 243).rgba()); } void GlobalSettings::set_dark_theme_default_colors() { setValue(Key_View_FillSignalHighAreaColor, QColor(188, 188, 188, 9 * 256 / 100).rgba()); + + setValue(Key_View_CursorFillColor, + QColor(60, 60, 60).rgba()); } bool GlobalSettings::current_theme_is_dark() @@ -215,6 +241,12 @@ void GlobalSettings::apply_theme() QPixmapCache::clear(); } +void GlobalSettings::apply_language() +{ + Application* a = qobject_cast(QApplication::instance()); + a->switch_language(value(Key_General_Language).toString()); +} + void GlobalSettings::add_change_handler(GlobalSettingsInterface *cb) { callbacks_.push_back(cb);