X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fglobalsettings.cpp;h=1573a9f2ba165b23c2582de93aa0aba05ef794c1;hb=79a37ed84b4021736ee7cac75fa3a255b5453dda;hp=f7df48021f481eafd062bb0f5ad653fb6aaa83c8;hpb=6a26fc4417798ab21654197e105e707a14d462f0;p=pulseview.git diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index f7df4802..1573a9f2 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -18,6 +18,7 @@ */ #include "globalsettings.hpp" +#include "application.hpp" #include #include @@ -42,6 +43,7 @@ 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"; @@ -60,6 +62,8 @@ const QString GlobalSettings::Key_View_DefaultLogicHeight = "View_DefaultLogicHe 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_View_CursorShowFrequency = "View_CursorShowFrequency"; +const QString GlobalSettings::Key_View_CursorShowInterval = "View_CursorShowInterval"; const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable"; const QString GlobalSettings::Key_Dec_ExportFormat = "Dec_ExportFormat"; const QString GlobalSettings::Key_Dec_AlwaysShowAllRows = "Dec_AlwaysShowAllRows"; @@ -90,6 +94,14 @@ 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); @@ -130,6 +142,12 @@ void GlobalSettings::set_defaults_where_needed() if (!contains(Key_View_SnapDistance)) setValue(Key_View_SnapDistance, 15); + if (!contains(Key_View_CursorShowInterval)) + setValue(Key_View_CursorShowInterval, true); + + if (!contains(Key_View_CursorShowFrequency)) + setValue(Key_View_CursorShowFrequency, true); + // %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") @@ -231,6 +249,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);