X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fglobalsettings.hpp;h=51212b023ab19f2e79145d991117bf804c707904;hp=b7457963da88e462cdaa1a2e8202f5ae2a919fb0;hb=eaa02ef436fb9d8217a94076e1258da47d3cd8e0;hpb=bf9f12687c8d43422455cbdc27ec1cc5d4305149 diff --git a/pv/globalsettings.hpp b/pv/globalsettings.hpp index b7457963..51212b02 100644 --- a/pv/globalsettings.hpp +++ b/pv/globalsettings.hpp @@ -20,33 +20,88 @@ #ifndef PULSEVIEW_GLOBALSETTINGS_HPP #define PULSEVIEW_GLOBALSETTINGS_HPP -#include #include +#include + #include #include #include +using std::map; +using std::vector; + namespace pv { +class GlobalSettingsInterface +{ +public: + virtual void on_setting_changed(const QString &key, const QVariant &value) = 0; +}; + + class GlobalSettings : public QSettings { Q_OBJECT public: - static const QString Key_View_AlwaysZoomToFit; + static const QString Key_View_ZoomToFitDuringAcq; + static const QString Key_View_ZoomToFitAfterAcq; + static const QString Key_View_TriggerIsZeroTime; static const QString Key_View_ColouredBG; + static const QString Key_View_StickyScrolling; + static const QString Key_View_ShowSamplingPoints; + static const QString Key_View_ShowAnalogMinorGrid; + static const QString Key_View_ConversionThresholdDispMode; + static const QString Key_View_DefaultDivHeight; + static const QString Key_View_DefaultLogicHeight; + static const QString Key_Dec_InitialStateConfigurable; + static const QString Key_Log_BufferSize; + static const QString Key_Log_NotifyOfStacktrace; + + enum ConvThrDispMode { + ConvThrDispMode_None = 0, + ConvThrDispMode_Background, + ConvThrDispMode_Dots + }; public: GlobalSettings(); - static void register_change_handler(const QString key, - std::function cb); + void set_defaults_where_needed(); + + static void add_change_handler(GlobalSettingsInterface *cb); + static void remove_change_handler(GlobalSettingsInterface *cb); void setValue(const QString& key, const QVariant& value); + /** + * Begins the tracking of changes. All changes will + * be recorded until stop_tracking() is called. + * The change tracking is global and doesn't support nesting. + */ + void start_tracking(); + + /** + * Ends the tracking of changes without any changes to the settings. + */ + void stop_tracking(); + + /** + * Ends the tracking of changes, undoing the changes since the + * change tracking began. + */ + void undo_tracked_changes(); + + static void store_gvariant(QSettings &settings, GVariant *v); + + static GVariant* restore_gvariant(QSettings &settings); + private: - static std::multimap< QString, std::function > callbacks_; + static vector callbacks_; + + static bool tracking_; + static map tracked_changes_; }; } // namespace pv