X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fglobalsettings.cpp;h=38017f3b14569444c8f1ab45b5d32624bac67e69;hb=4aaa5b800184118b9db5f071c1e83ecc90e8a338;hp=1c23e04c39a85929ed17de14d4e23878caeaca58;hpb=0466001be51e779b23aaebec1cc9361305c07be9;p=pulseview.git diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index 1c23e04c..38017f3b 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -17,8 +17,9 @@ * along with this program; if not, see . */ -#include "globalsettings.hpp" -#include "application.hpp" +#include +#include +#include #include #include @@ -30,9 +31,13 @@ #include #include +#include "globalsettings.hpp" +#include "application.hpp" + using std::map; using std::pair; using std::string; +using std::stringstream; using std::vector; namespace pv { @@ -47,11 +52,13 @@ 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_General_StartAllSessions = "General_StartAllSessions"; const QString GlobalSettings::Key_View_ZoomToFitDuringAcq = "View_ZoomToFitDuringAcq"; const QString GlobalSettings::Key_View_ZoomToFitAfterAcq = "View_ZoomToFitAfterAcq"; const QString GlobalSettings::Key_View_TriggerIsZeroTime = "View_TriggerIsZeroTime"; const QString GlobalSettings::Key_View_ColoredBG = "View_ColoredBG"; const QString GlobalSettings::Key_View_StickyScrolling = "View_StickyScrolling"; +const QString GlobalSettings::Key_View_AllowVerticalDragging = "View_AllowVerticalDragging"; const QString GlobalSettings::Key_View_ShowSamplingPoints = "View_ShowSamplingPoints"; const QString GlobalSettings::Key_View_FillSignalHighAreas = "View_FillSignalHighAreas"; const QString GlobalSettings::Key_View_FillSignalHighAreaColor = "View_FillSignalHighAreaColor"; @@ -62,6 +69,9 @@ 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_View_CursorShowSamples = "View_CursorShowSamples"; const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable"; const QString GlobalSettings::Key_Dec_ExportFormat = "Dec_ExportFormat"; const QString GlobalSettings::Key_Dec_AlwaysShowAllRows = "Dec_AlwaysShowAllRows"; @@ -94,10 +104,11 @@ 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 + QString language = QLocale().uiLanguages().first(); // May return e.g. en-Latn-US // clazy:exclude=detaching-temporary language = language.split("-").first(); setValue(Key_General_Language, language); + apply_language(); } // Use no theme by default @@ -114,6 +125,10 @@ void GlobalSettings::set_defaults_where_needed() if (!contains(Key_View_ZoomToFitAfterAcq)) setValue(Key_View_ZoomToFitAfterAcq, true); + // Allow vertical dragging by default + if (!contains(Key_View_AllowVerticalDragging)) + setValue(Key_View_AllowVerticalDragging, true); + // Enable colored trace backgrounds by default if (!contains(Key_View_ColoredBG)) setValue(Key_View_ColoredBG, true); @@ -140,6 +155,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") @@ -321,8 +342,11 @@ GVariant* GlobalSettings::restore_gvariant(QSettings &settings) QByteArray data = settings.value("value").toByteArray(); - gpointer var_data = g_memdup((gconstpointer)data.constData(), - (guint)data.size()); +#if GLIB_CHECK_VERSION(2, 67, 3) // See https://discourse.gnome.org/t/port-your-module-from-g-memdup-to-g-memdup2-now/5538 + gpointer var_data = g_memdup2((gconstpointer)data.constData(), (gsize)data.size()); +#else + gpointer var_data = g_memdup((gconstpointer)data.constData(), (guint)data.size()); +#endif GVariant *value = g_variant_new_from_data(var_type, var_data, data.size(), false, g_free, var_data); @@ -347,8 +371,11 @@ Glib::VariantBase GlobalSettings::restore_variantbase(QSettings &settings) QByteArray data = settings.value("value").toByteArray(); - gpointer var_data = g_memdup((gconstpointer)data.constData(), - (guint)data.size()); +#if GLIB_CHECK_VERSION(2, 67, 3) // See https://discourse.gnome.org/t/port-your-module-from-g-memdup-to-g-memdup2-now/5538 + gpointer var_data = g_memdup2((gconstpointer)data.constData(), (gsize)data.size()); +#else + gpointer var_data = g_memdup((gconstpointer)data.constData(), (guint)data.size()); +#endif GVariant *value = g_variant_new_from_data(var_type, var_data, data.size(), false, g_free, var_data); @@ -361,4 +388,28 @@ Glib::VariantBase GlobalSettings::restore_variantbase(QSettings &settings) return ret_val; } +void GlobalSettings::store_timestamp(QSettings &settings, const char *name, const pv::util::Timestamp &ts) +{ + stringstream ss; + boost::archive::text_oarchive oa(ss); + oa << boost::serialization::make_nvp(name, ts); + settings.setValue(name, QString::fromStdString(ss.str())); +} + +pv::util::Timestamp GlobalSettings::restore_timestamp(QSettings &settings, const char *name) +{ + util::Timestamp result; + stringstream ss; + ss << settings.value(name).toString().toStdString(); + + try { + boost::archive::text_iarchive ia(ss); + ia >> boost::serialization::make_nvp(name, result); + } catch (boost::archive::archive_exception&) { + qDebug() << "Could not restore setting" << name; + } + + return result; +} + } // namespace pv