From ca9da94109c7b26a9bab6c9dbfea03fb75dac596 Mon Sep 17 00:00:00 2001 From: AlexandraTrifan Date: Fri, 20 Dec 2024 11:37:20 +0200 Subject: [PATCH 1/2] preferences: add descriptions in all the preferences structure. Signed-off-by: AlexandraTrifan --- core/include/core/scopymainwindow_api.h | 1 + core/src/scopymainwindow_api.cpp | 10 ++ core/src/scopypreferencespage.cpp | 101 +++++++++++++----- gui/include/gui/preferenceshelper.h | 11 +- gui/src/preferenceshelper.cpp | 25 +++-- pluginbase/include/pluginbase/preferences.h | 14 +++ pluginbase/src/apiobject.cpp | 4 +- pluginbase/src/preferences.cpp | 14 +++ plugins/adc/src/adcplugin.cpp | 23 ++-- plugins/datalogger/src/dataloggerplugin.cpp | 6 +- plugins/debugger/src/debuggerplugin.cpp | 4 +- plugins/m2k/src/m2kplugin.cpp | 27 ++--- plugins/regmap/src/regmapplugin.cpp | 2 +- plugins/test/src/testplugin.cpp | 8 +- .../templates/pdk/pdk_src_template.mako | 32 +++--- 15 files changed, 191 insertions(+), 91 deletions(-) diff --git a/core/include/core/scopymainwindow_api.h b/core/include/core/scopymainwindow_api.h index e39b653d92..3d753e477f 100644 --- a/core/include/core/scopymainwindow_api.h +++ b/core/include/core/scopymainwindow_api.h @@ -56,6 +56,7 @@ class SCOPY_CORE_EXPORT ScopyMainWindow_API : public ApiObject Q_INVOKABLE QStringList getToolsForPlugin(QString plugin); Q_INVOKABLE QPair getPreference(QString prfName); Q_INVOKABLE QMap getPreferences(); + Q_INVOKABLE QVector getPreferenceDescription(QString prefName); Q_INVOKABLE void setPreference(QString preName, QVariant value); Q_INVOKABLE void aboutPage(); Q_INVOKABLE QStringList getPlugins(int idx); diff --git a/core/src/scopymainwindow_api.cpp b/core/src/scopymainwindow_api.cpp index 00449406c0..4625e0fa1e 100644 --- a/core/src/scopymainwindow_api.cpp +++ b/core/src/scopymainwindow_api.cpp @@ -376,6 +376,16 @@ QMap ScopyMainWindow_API::getPreferences() return prefMap; } +QVector ScopyMainWindow_API::getPreferenceDescription(QString prefName) +{ + Preferences *p = Preferences::GetInstance(); + QMap> prefMap = p->getPreferencesDescriptions(); + if(prefName != NULL) { + return prefMap[prefName]; + } + return {}; +} + void ScopyMainWindow_API::setPreference(QString prefName, QVariant value) { Preferences *p = Preferences::GetInstance(); diff --git a/core/src/scopypreferencespage.cpp b/core/src/scopypreferencespage.cpp index c8bf42f718..26132e694e 100644 --- a/core/src/scopypreferencespage.cpp +++ b/core/src/scopypreferencespage.cpp @@ -158,8 +158,10 @@ QWidget *ScopyPreferencesPage::buildSaveSessionPreference() QHBoxLayout *lay = new QHBoxLayout(w); lay->setMargin(0); - lay->addWidget( - PreferencesHelper::addPreferenceCheckBox(p, "general_save_session", "Save/Load Scopy session", this)); + lay->addWidget(PreferencesHelper::addPreferenceCheckBox(p, "general_save_session", "Save/Load Scopy session", + "Allow Scopy to automatically save/load the session" + "using .ini files into a predefined location.", + this)); lay->addSpacerItem(new QSpacerItem(40, 40, QSizePolicy::Expanding, QSizePolicy::Fixed)); lay->addWidget(new QLabel("Settings files location ", this)); QPushButton *navigateBtn = new QPushButton("Open", this); @@ -244,43 +246,85 @@ QWidget *ScopyPreferencesPage::buildGeneralPreferencesPage() generalSection->contentLayout()->addWidget(buildSaveSessionPreference()); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "general_save_attached", "Save/Load tool attached state", generalSection)); + p, "general_save_attached", "Save/Load tool attached state", + "Allow Scopy to save the state of all instruments, whether they were " + "detached/attached when the application was closed, and load this " + "state accordingly when the application restarts.", + generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "general_doubleclick_attach", "Doubleclick to attach/detach tool", generalSection)); + p, "general_doubleclick_attach", "Doubleclick to attach/detach tool", + "Indicates whether double-clicking attaches instruments in the application. " + "Enabling this option allows the user to quickly attach instruments by " + "double-clicking on them.", + generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "general_doubleclick_ctrl_opens_menu", "Doubleclick control buttons to open menu", generalSection)); + p, "general_doubleclick_ctrl_opens_menu", "Doubleclick control buttons to open menu", "", + generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "general_use_opengl", "Enable OpenGL plotting", generalSection)); + p, "general_use_opengl", "Enable OpenGL plotting", "", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "general_use_animations", "Enable menu animations", generalSection)); + p, "general_use_animations", "Enable menu animations", "", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "general_check_online_version", "Enable automatic online check for updates.", generalSection)); + p, "general_check_online_version", "Enable automatic online check for updates.", + "Indicates whether the application should check for online version updates. " + "Enabling this option allows the application to automatically check for and " + "notify the user of available updates at startup.", + generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( p, "general_show_status_bar", "Enable the status bar for displaying important messages.", + "Indicates whether the status bar should be displayed in the application. This setting " + "allows the user to enable or disable the status bar, which provides information about " + "the current state of the application." + "Important messages such as connection done or alerts are displayed here.", generalSection)); - generalSection->contentLayout()->addWidget( - PreferencesHelper::addPreferenceCheckBox(p, "show_grid", "Show Grid", generalSection)); - generalSection->contentLayout()->addWidget( - PreferencesHelper::addPreferenceCheckBox(p, "show_graticule", "Show Graticule", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "iiowidgets_use_lazy_loading", "Use Lazy Loading", generalSection)); + p, "show_grid", "Show Grid", + "Indicates whether the plot grid is visible across the application." + "The user can enable or disable this in order to configure the ", + generalSection)); + generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( + p, "show_graticule", "Show Graticule", + "This setting allows the user to enable or disable the display of the graticule " + "on all the plots in the application for better signal visualization.", + generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "general_use_native_dialogs", "Use native dialogs", generalSection)); + p, "iiowidgets_use_lazy_loading", "Use Lazy Loading", + "Indicates whether lazy loading should be used for IIO widgets. " + "Enabling this option allows the application to load IIO widgets only " + "when they are needed, improving startup performance.", + generalSection)); + generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( + p, "general_use_native_dialogs", "Use native dialogs", + "Indicates whether native dialogs should be used in the application." + "This setting allows the user to enable or disable the use of native file " + "dialogs and other system dialogs within the application.", + generalSection)); QWidget *autoConnectCb = PreferencesHelper::addPreferenceCheckBox( - p, "autoconnect_previous", "Auto-connect to previous session", generalSection); + p, "autoconnect_previous", "Auto-connect to previous session", "", generalSection); generalSection->contentLayout()->addWidget(autoConnectCb); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( - p, "font_scale", "Font scale (EXPERIMENTAL)", {"1", "1.15", "1.3", "1.45", "1.6", "1.75", "1.9"}, - generalSection)); + p, "font_scale", "Font scale (EXPERIMENTAL)", + "Scale factor for the font size used across the application, suitable for " + "different display settings", + {"1", "1.15", "1.3", "1.45", "1.6", "1.75", "1.9"}, generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( - p, "general_theme", "Theme", Style::GetInstance()->getThemeList(), generalSection)); + p, "general_theme", "Theme", + "Theme setting for the application interface." + "The user can choose between Harmonic style (light or dark) or Scopy style.", + Style::GetInstance()->getThemeList(), generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( - p, "general_language", "Language", t->getLanguages(), generalSection)); - generalSection->contentLayout()->addWidget( - PreferencesHelper::addPreferenceCheckBox(p, "general_connect_to_multiple_devices", - "Connect to multiple devices (EXPERIMENTAL)", generalSection)); + p, "general_language", "Language", + "Language setting for the application interface." + "Multiple options available, check out the documentation if a new language is needed", + t->getLanguages(), generalSection)); + generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( + p, "general_connect_to_multiple_devices", "Connect to multiple devices (EXPERIMENTAL)", + "Allows the application to connect to multiple devices simultaneously, providing a mechanism " + "to handle them separately using different sections in the left side menu." + "Due to not being tested using enough scenarios it is still marked as an experimental feature.", + generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "general_scan_for_devices", "Regularly scan for new devices", generalSection)); + p, "general_scan_for_devices", "Regularly scan for new devices", "", generalSection)); // Auto-connect m_autoConnectWidget = new MenuSectionCollapseWidget("Session devices", MenuCollapseSection::MHCW_NONE, @@ -310,10 +354,15 @@ QWidget *ScopyPreferencesPage::buildGeneralPreferencesPage() lay->addWidget(debugWidget); lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); - debugSection->contentLayout()->addWidget( - PreferencesHelper::addPreferenceCheckBox(p, "general_show_plot_fps", "Show plot FPS", debugSection)); + debugSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( + p, "general_show_plot_fps", "Show plot FPS", + "Indicates whether the frames per second should be displayed in plots " + "across the entire application.", + debugSection)); debugSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( - p, "general_plot_target_fps", "Plot target FPS", {"15", "20", "30", "60"}, debugSection)); + p, "general_plot_target_fps", "Plot target FPS", + "Select the Frames per second value for rendering plots in the entire application.", + {"15", "20", "30", "60"}, debugSection)); debugSection->contentLayout()->addWidget(buildResetScopyDefaultButton()); return page; diff --git a/gui/include/gui/preferenceshelper.h b/gui/include/gui/preferenceshelper.h index c491f1c999..dee69e4900 100644 --- a/gui/include/gui/preferenceshelper.h +++ b/gui/include/gui/preferenceshelper.h @@ -40,12 +40,13 @@ class SCOPY_GUI_EXPORT PreferencesHelper { public: - static QWidget *addPreferenceCheckBox(Preferences *p, QString id, QString description, + static QWidget *addPreferenceCheckBox(Preferences *p, QString id, QString title, QString description, QObject *parent = nullptr); - static QWidget *addPreferenceEdit(Preferences *p, QString id, QString description, QObject *parent = nullptr); - static QWidget *addPreferenceCombo(Preferences *p, QString id, QString description, QStringList options, - QObject *parent = nullptr); - static QWidget *addPreferenceComboList(Preferences *p, QString id, QString description, + static QWidget *addPreferenceEdit(Preferences *p, QString id, QString title, QString description, + QObject *parent = nullptr); + static QWidget *addPreferenceCombo(Preferences *p, QString id, QString title, QString description, + QStringList options, QObject *parent = nullptr); + static QWidget *addPreferenceComboList(Preferences *p, QString id, QString title, QString description, QList> options, QObject *parent); }; } // namespace scopy diff --git a/gui/src/preferenceshelper.cpp b/gui/src/preferenceshelper.cpp index 3e7ba37bb2..83a68805c7 100644 --- a/gui/src/preferenceshelper.cpp +++ b/gui/src/preferenceshelper.cpp @@ -26,7 +26,8 @@ #include using namespace scopy; -QWidget *PreferencesHelper::addPreferenceCheckBox(Preferences *p, QString id, QString description, QObject *parent) +QWidget *PreferencesHelper::addPreferenceCheckBox(Preferences *p, QString id, QString title, QString description, + QObject *parent) { QWidget *widget = new QWidget(); QHBoxLayout *layout = new QHBoxLayout(); @@ -39,9 +40,11 @@ QWidget *PreferencesHelper::addPreferenceCheckBox(Preferences *p, QString id, QS pref->setChecked(p->get(id).toBool()); parent->connect(pref, &SmallOnOffSwitch::toggled, parent, [p, id](bool b) { p->set(id, b); }); + p->initDescription(id, title, description); + QSpacerItem *space = new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed); - layout->addWidget(new QLabel(description, widget)); + layout->addWidget(new QLabel(title, widget)); layout->addSpacerItem(space); layout->addWidget(pref); widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); @@ -49,7 +52,8 @@ QWidget *PreferencesHelper::addPreferenceCheckBox(Preferences *p, QString id, QS return widget; } -QWidget *PreferencesHelper::addPreferenceEdit(Preferences *p, QString id, QString description, QObject *parent) +QWidget *PreferencesHelper::addPreferenceEdit(Preferences *p, QString id, QString title, QString description, + QObject *parent) { QWidget *widget = new QWidget(); QHBoxLayout *layout = new QHBoxLayout(); @@ -63,7 +67,8 @@ QWidget *PreferencesHelper::addPreferenceEdit(Preferences *p, QString id, QStrin pref->setText(pref1Val); parent->connect(pref, &QLineEdit::textChanged, parent, [p, id](QString b) { p->set(id, b); }); - QLabel *label = new QLabel(description); + QLabel *label = new QLabel(title); + p->initDescription(id, title, description); QSpacerItem *space = new QSpacerItem(20, 20, QSizePolicy::Preferred, QSizePolicy::Preferred); @@ -73,7 +78,7 @@ QWidget *PreferencesHelper::addPreferenceEdit(Preferences *p, QString id, QStrin return widget; } -QWidget *PreferencesHelper::addPreferenceComboList(Preferences *p, QString id, QString description, +QWidget *PreferencesHelper::addPreferenceComboList(Preferences *p, QString id, QString title, QString description, QList> options, QObject *parent) { QWidget *w = new QWidget(); @@ -82,7 +87,8 @@ QWidget *PreferencesHelper::addPreferenceComboList(Preferences *p, QString id, Q lay->setSpacing(0); lay->setMargin(0); w->setLayout(lay); - QLabel *lab = new QLabel(description); + QLabel *lab = new QLabel(title); + p->initDescription(id, title, description); QSpacerItem *space = new QSpacerItem(20, 20, QSizePolicy::Preferred, QSizePolicy::Preferred); QString pref1Val; @@ -106,15 +112,16 @@ QWidget *PreferencesHelper::addPreferenceComboList(Preferences *p, QString id, Q return w; } -QWidget *PreferencesHelper::addPreferenceCombo(Preferences *p, QString id, QString description, QStringList options, - QObject *parent) +QWidget *PreferencesHelper::addPreferenceCombo(Preferences *p, QString id, QString title, QString description, + QStringList options, QObject *parent) { QWidget *w = new QWidget(); QHBoxLayout *lay = new QHBoxLayout(); lay->setSpacing(0); lay->setMargin(0); w->setLayout(lay); - QLabel *lab = new QLabel(description); + QLabel *lab = new QLabel(title); + p->initDescription(id, title, description); QSpacerItem *space = new QSpacerItem(20, 20, QSizePolicy::Preferred, QSizePolicy::Preferred); QString pref1Val = p->get(id).toString(); QComboBox *pref = new QComboBox(); diff --git a/pluginbase/include/pluginbase/preferences.h b/pluginbase/include/pluginbase/preferences.h index 4e89601428..e61eeb5679 100644 --- a/pluginbase/include/pluginbase/preferences.h +++ b/pluginbase/include/pluginbase/preferences.h @@ -52,6 +52,18 @@ class SCOPY_PLUGINBASE_EXPORT Preferences : public QObject */ static void init(QString, QVariant); void _init(QString, QVariant); + + /** + * @brief initDescription + * Initialize a map with title and description for each preference + * to be later used in docs and hover widgets in the Scopy prefs page. + * @param k + * @param title + * @param description + */ + void initDescription(QString k, QString title, QString description); + void _initDescription(QString k, QString title, QString description); + /** * @brief clear * clears preferences table @@ -73,6 +85,7 @@ class SCOPY_PLUGINBASE_EXPORT Preferences : public QObject QMap getPreferences() const; void setPreferences(QMap s); + QMap> getPreferencesDescriptions() const; public Q_SLOTS: /** * @brief setPreferencesFilename @@ -109,6 +122,7 @@ public Q_SLOTS: private: QMap p; + QMap> pDescriptions; QSettings *s; static Preferences *pinstance_; }; diff --git a/pluginbase/src/apiobject.cpp b/pluginbase/src/apiobject.cpp index 7ddfa9ed5b..a2ca658944 100644 --- a/pluginbase/src/apiobject.cpp +++ b/pluginbase/src/apiobject.cpp @@ -31,7 +31,9 @@ using namespace scopy; ApiObject::ApiObject(QObject *parent) : QObject(parent) -{} +{ + qRegisterMetaType>("QPair"); +} ApiObject::~ApiObject() {} diff --git a/pluginbase/src/preferences.cpp b/pluginbase/src/preferences.cpp index bb85de575a..68acc9bfeb 100644 --- a/pluginbase/src/preferences.cpp +++ b/pluginbase/src/preferences.cpp @@ -47,6 +47,13 @@ void Preferences::_init(QString k, QVariant v) // else - map contains key so it is already initialized to the correct value, nothing to do } +void Preferences::_initDescription(QString k, QString title, QString description) +{ + if(!pDescriptions.contains(k)) { + pDescriptions.insert(k, QVector{title, description}); + } +} + QVariant Preferences::_get(QString k) { QVariant v = QVariant(); @@ -71,6 +78,8 @@ QVariant Preferences::get(QString val) { return Preferences::GetInstance()->_get QMap Preferences::getPreferences() const { return p; } +QMap> Preferences::getPreferencesDescriptions() const { return pDescriptions; } + void Preferences::setPreferences(QMap s) { p = s; } void Preferences::setPreferencesFilename(QString f) @@ -113,4 +122,9 @@ Preferences *Preferences::GetInstance() void Preferences::init(QString k, QVariant v) { return Preferences::GetInstance()->_init(k, v); } +void Preferences::initDescription(QString k, QString title, QString description) +{ + return Preferences::GetInstance()->_initDescription(k, title, description); +} + #include "moc_preferences.cpp" diff --git a/plugins/adc/src/adcplugin.cpp b/plugins/adc/src/adcplugin.cpp index c6ae0b4ba7..91038e8252 100644 --- a/plugins/adc/src/adcplugin.cpp +++ b/plugins/adc/src/adcplugin.cpp @@ -103,31 +103,32 @@ bool ADCPlugin::loadPreferencesPage() lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); auto adc_plot_xaxis_label_position = PreferencesHelper::addPreferenceComboList( - p, "adc_plot_xaxis_label_position", "Plot X-Axis scale position", + p, "adc_plot_xaxis_label_position", "Plot X-Axis scale position", "", {{"Top", QwtAxis::XTop}, {"Bottom", QwtAxis::XBottom}}, generalSection); auto adc_plot_yaxis_label_position = PreferencesHelper::addPreferenceComboList( - p, "adc_plot_yaxis_label_position", "Plot Y-Axis scale position", + p, "adc_plot_yaxis_label_position", "Plot Y-Axis scale position", "", {{"Left", QwtAxis::YLeft}, {"Right", QwtAxis::YRight}}, generalSection); auto adc_plot_yaxis_handle_position = PreferencesHelper::addPreferenceComboList( - p, "adc_plot_yaxis_handle_position", "Plot channel Y-handle position", + p, "adc_plot_yaxis_handle_position", "Plot channel Y-handle position", "", {{"Left", HandlePos::NORTH_OR_WEST}, {"Right", HandlePos::SOUTH_OR_EAST}}, generalSection); auto adc_plot_xcursor_position = PreferencesHelper::addPreferenceComboList( - p, "adc_plot_xcursor_position", "Plot X-Cursor position", + p, "adc_plot_xcursor_position", "Plot X-Cursor position", "", {{"Top", HandlePos::NORTH_OR_WEST}, {"Bottom", HandlePos::SOUTH_OR_EAST}}, generalSection); auto adc_plot_ycursor_position = PreferencesHelper::addPreferenceComboList( - p, "adc_plot_ycursor_position", "Plot Y-Curosr position", + p, "adc_plot_ycursor_position", "Plot Y-Curosr position", "", {{"Left", HandlePos::NORTH_OR_WEST}, {"Right", HandlePos::SOUTH_OR_EAST}}, generalSection); auto adc_plot_show_buffer_previewer = PreferencesHelper::addPreferenceCheckBox( - p, "adc_plot_show_buffer_previewer", "Show buffer previewer", m_preferencesPage); + p, "adc_plot_show_buffer_previewer", "Show buffer previewer", "", m_preferencesPage); - auto adc_default_y_mode = PreferencesHelper::addPreferenceComboList( - p, "adc_default_y_mode", "ADC Default Y-Mode", {{"ADC Count", 0}, {"% Full Scale", 1}}, generalSection); + auto adc_default_y_mode = + PreferencesHelper::addPreferenceComboList(p, "adc_default_y_mode", "ADC Default Y-Mode", "", + {{"ADC Count", 0}, {"% Full Scale", 1}}, generalSection); auto adc_acquisition_timeout = PreferencesHelper::addPreferenceEdit( - p, "adc_acquisition_timeout", "ADC Acquisition timeout", m_preferencesPage); + p, "adc_acquisition_timeout", "ADC Acquisition timeout", "", m_preferencesPage); auto adc_add_remove_plot = PreferencesHelper::addPreferenceCheckBox( - p, "adc_add_remove_plot", "Add/Remove plot feature (EXPERIMENTAL)", m_preferencesPage); + p, "adc_add_remove_plot", "Add/Remove plot feature (EXPERIMENTAL)", "", m_preferencesPage); auto adc_add_remove_instrument = PreferencesHelper::addPreferenceCheckBox( - p, "adc_add_remove_instrument", "Add/Remove instrument feature (EXPERIMENTAL)", m_preferencesPage); + p, "adc_add_remove_instrument", "Add/Remove instrument feature (EXPERIMENTAL)", "", m_preferencesPage); generalSection->contentLayout()->addWidget(adc_plot_xaxis_label_position); generalSection->contentLayout()->addWidget(adc_plot_yaxis_label_position); diff --git a/plugins/datalogger/src/dataloggerplugin.cpp b/plugins/datalogger/src/dataloggerplugin.cpp index e3a062660f..707b3dd83d 100644 --- a/plugins/datalogger/src/dataloggerplugin.cpp +++ b/plugins/datalogger/src/dataloggerplugin.cpp @@ -279,14 +279,14 @@ bool DataLoggerPlugin::loadPreferencesPage() lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( - p, "dataloggerplugin_data_storage_size", "Maximum data stored for each monitor", {"10 Kb", "1 Mb"}, + p, "dataloggerplugin_data_storage_size", "Maximum data stored for each monitor", "", {"10 Kb", "1 Mb"}, generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceEdit( - p, "dataloggerplugin_read_interval", "Read interval (seconds) ", generalSection)); + p, "dataloggerplugin_read_interval", "Read interval (seconds) ", "", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceEdit( - p, "dataloggerplugin_date_time_format", "DateTime format :", generalSection)); + p, "dataloggerplugin_date_time_format", "DateTime format :", "", generalSection)); return true; } diff --git a/plugins/debugger/src/debuggerplugin.cpp b/plugins/debugger/src/debuggerplugin.cpp index f360a0c555..c8fd9d5113 100644 --- a/plugins/debugger/src/debuggerplugin.cpp +++ b/plugins/debugger/src/debuggerplugin.cpp @@ -81,9 +81,9 @@ bool DebuggerPlugin::loadPreferencesPage() layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); auto use_debugger_v2 = PreferencesHelper::addPreferenceCheckBox(p, "plugins_use_debugger_v2", - "Use Debugger V2 plugin", generalSection); + "Use Debugger V2 plugin", "", generalSection); auto debugger_include_debugfs = PreferencesHelper::addPreferenceCheckBox( - p, "debugger_v2_include_debugfs", "Include debug attributes in IIO Explorer", generalSection); + p, "debugger_v2_include_debugfs", "Include debug attributes in IIO Explorer", "", generalSection); generalSection->contentLayout()->addWidget(use_debugger_v2); generalSection->contentLayout()->addWidget(debugger_include_debugfs); diff --git a/plugins/m2k/src/m2kplugin.cpp b/plugins/m2k/src/m2kplugin.cpp index 7491ba4f8c..b65c476e36 100644 --- a/plugins/m2k/src/m2kplugin.cpp +++ b/plugins/m2k/src/m2kplugin.cpp @@ -298,7 +298,7 @@ bool M2kPlugin::loadPreferencesPage() lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "m2k_instrument_notes_active", "Instrument Notes", generalSection)); + p, "m2k_instrument_notes_active", "Instrument Notes", "", generalSection)); // Analog tools preferences MenuSectionWidget *analogWidget = new MenuSectionWidget(m_preferencesPage); @@ -311,21 +311,22 @@ bool M2kPlugin::loadPreferencesPage() lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); analogSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "m2k_show_adc_filters", "Show ADC digital filter config", analogSection)); - analogSection->contentLayout()->addWidget( - PreferencesHelper::addPreferenceCheckBox(p, "m2k_show_graticule", "Enable graticule", analogSection)); + p, "m2k_show_adc_filters", "Show ADC digital filter config", "", analogSection)); analogSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "m2k_mini_histogram", "Enable mini histogram", analogSection)); + p, "m2k_show_graticule", "Enable graticule", "", analogSection)); analogSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "m2k_osc_filtering", "Enable sample rate filters", analogSection)); + p, "m2k_mini_histogram", "Enable mini histogram", "", analogSection)); analogSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "m2k_osc_label", "Enable labels on the plot", analogSection)); + p, "m2k_osc_filtering", "Enable sample rate filters", "", analogSection)); analogSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "m2k_spectrum_visible_peak_search", "Only search marker peaks in visible domain", analogSection)); + p, "m2k_osc_label", "Enable labels on the plot", "", analogSection)); analogSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "m2k_na_show_zero", "Always display 0db value on the graph", analogSection)); + p, "m2k_spectrum_visible_peak_search", "Only search marker peaks in visible domain", "", + analogSection)); + analogSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( + p, "m2k_na_show_zero", "Always display 0db value on the graph", "", analogSection)); analogSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceEdit( - p, "m2k_siggen_periods", "Number of displayed periods", analogSection)); + p, "m2k_siggen_periods", "Number of displayed periods", "", analogSection)); // Logic tools preferences MenuSectionWidget *logicWidget = new MenuSectionWidget(m_preferencesPage); @@ -338,11 +339,11 @@ bool M2kPlugin::loadPreferencesPage() lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); logicSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "m2k_logic_separate_annotations", "Separate decoder annotations when exporting", logicSection)); + p, "m2k_logic_separate_annotations", "Separate decoder annotations when exporting", "", logicSection)); logicSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "m2k_logic_display_sampling_points", "Display sampling points when zoomed", logicSection)); + p, "m2k_logic_display_sampling_points", "Display sampling points when zoomed", "", logicSection)); logicSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "m2k_logic_display_sample_time", "Show sample and time info in decoder table", logicSection)); + p, "m2k_logic_display_sample_time", "Show sample and time info in decoder table", "", logicSection)); return true; } diff --git a/plugins/regmap/src/regmapplugin.cpp b/plugins/regmap/src/regmapplugin.cpp index 3a5a1d8862..4516747bf5 100644 --- a/plugins/regmap/src/regmapplugin.cpp +++ b/plugins/regmap/src/regmapplugin.cpp @@ -160,7 +160,7 @@ bool RegmapPlugin::loadPreferencesPage() lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( - p, "regmap_color_by_value", "Use color to reflect value", + p, "regmap_color_by_value", "Use color to reflect value", "", {"Default", "Bitfield background", "Bitfield text", "Register background", "Register text", "Register background and Bitfield background", "Register text and Bitfield text", "Register background and Bitfield text", "Register text and Bitfield background"}, diff --git a/plugins/test/src/testplugin.cpp b/plugins/test/src/testplugin.cpp index 8edce74b8c..2a8d805f0d 100644 --- a/plugins/test/src/testplugin.cpp +++ b/plugins/test/src/testplugin.cpp @@ -84,13 +84,13 @@ bool TestPlugin::loadPreferencesPage() lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); generalSection->contentLayout()->addWidget( - PreferencesHelper::addPreferenceCheckBox(p, "pref1", "First Option", generalSection)); + PreferencesHelper::addPreferenceCheckBox(p, "pref1", "First Option", "", generalSection)); generalSection->contentLayout()->addWidget( - PreferencesHelper::addPreferenceCheckBox(p, "pref2", "Second Option", generalSection)); + PreferencesHelper::addPreferenceCheckBox(p, "pref2", "Second Option", "", generalSection)); generalSection->contentLayout()->addWidget( - PreferencesHelper::addPreferenceEdit(p, "prefstr", "PreferenceString", generalSection)); + PreferencesHelper::addPreferenceEdit(p, "prefstr", "PreferenceString", "", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( - p, "pref4", "languages", {"english", "french", "italian"}, generalSection)); + p, "pref4", "languages", "", {"english", "french", "italian"}, generalSection)); return true; } diff --git a/tools/plugingenerator/templates/pdk/pdk_src_template.mako b/tools/plugingenerator/templates/pdk/pdk_src_template.mako index afb0529353..775419112d 100644 --- a/tools/plugingenerator/templates/pdk/pdk_src_template.mako +++ b/tools/plugingenerator/templates/pdk/pdk_src_template.mako @@ -148,7 +148,7 @@ QWidget *PDKWindow::buildSaveSessionPreference() lay->setMargin(0); lay->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox(p, "general_save_session", - "Save/Load Scopy session", this)); + "Save/Load Scopy session", "", this)); lay->addSpacerItem(new QSpacerItem(40, 40, QSizePolicy::Expanding, QSizePolicy::Fixed)); lay->addWidget(new QLabel("Settings files location ", this)); QPushButton *navigateBtn = new QPushButton("Open", this); @@ -183,32 +183,32 @@ QWidget *PDKWindow::generalPreferences() generalSection->contentLayout()->addWidget(buildSaveSessionPreference()); generalSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox( - p, "general_save_attached", "Save/Load tool attached state", generalSection)); + p, "general_save_attached", "Save/Load tool attached state", "", generalSection)); generalSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox( - p, "general_doubleclick_attach", "Doubleclick to attach/detach tool", generalSection)); + p, "general_doubleclick_attach", "Doubleclick to attach/detach tool", "", generalSection)); generalSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox( - p, "general_doubleclick_ctrl_opens_menu", "Doubleclick control buttons to open menu", generalSection)); + p, "general_doubleclick_ctrl_opens_menu", "Doubleclick control buttons to open menu", "", generalSection)); generalSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox( - p, "general_use_opengl", "Enable OpenGL plotting", generalSection)); + p, "general_use_opengl", "Enable OpenGL plotting", "", generalSection)); generalSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox( - p, "general_use_animations", "Enable menu animations", generalSection)); + p, "general_use_animations", "Enable menu animations", "", generalSection)); generalSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox( - p, "general_check_online_version", "Enable automatic online check for updates.", generalSection)); + p, "general_check_online_version", "Enable automatic online check for updates.", "", generalSection)); generalSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox( p, "general_show_status_bar", "Enable the status bar for displaying important messages.", - generalSection)); + "", generalSection)); generalSection->contentLayout()->addWidget( - scopy::PreferencesHelper::addPreferenceCheckBox(p, "show_grid", "Show Grid", generalSection)); + scopy::PreferencesHelper::addPreferenceCheckBox(p, "show_grid", "Show Grid", "", generalSection)); generalSection->contentLayout()->addWidget( - scopy::PreferencesHelper::addPreferenceCheckBox(p, "show_graticule", "Show Graticule", generalSection)); + scopy::PreferencesHelper::addPreferenceCheckBox(p, "show_graticule", "Show Graticule", "", generalSection)); generalSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox( - p, "iiowidgets_use_lazy_loading", "Use Lazy Loading", generalSection)); + p, "iiowidgets_use_lazy_loading", "Use Lazy Loading", "", generalSection)); generalSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox( - p, "plugins_use_debugger_v2", "Use Debugger V2 plugin", generalSection)); + p, "plugins_use_debugger_v2", "Use Debugger V2 plugin", "", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "general_use_native_dialogs", "Use native dialogs", generalSection)); + p, "general_use_native_dialogs", "Use native dialogs", "", generalSection)); generalSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCombo( - p, "general_theme", "Theme", {"default", "light"}, generalSection)); + p, "general_theme", "Theme", {"default", "light"}, "", generalSection)); // Debug preferences scopy::MenuSectionWidget *debugWidget = new scopy::MenuSectionWidget(page); @@ -221,9 +221,9 @@ QWidget *PDKWindow::generalPreferences() lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); debugSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCheckBox( - p, "general_show_plot_fps", "Show plot FPS", debugSection)); + p, "general_show_plot_fps", "Show plot FPS", "", debugSection)); debugSection->contentLayout()->addWidget(scopy::PreferencesHelper::addPreferenceCombo( - p, "general_plot_target_fps", "Plot target FPS", {"15", "20", "30", "60"}, debugSection)); + p, "general_plot_target_fps", "Plot target FPS", "", {"15", "20", "30", "60"}, debugSection)); return page; } From 28d6b42205645365f8f085e4fc3d6bc2fda51e5e Mon Sep 17 00:00:00 2001 From: AlexandraTrifan Date: Fri, 20 Dec 2024 12:19:11 +0200 Subject: [PATCH 2/2] docs: add a .js script to run with scopy and update the prefs table doc. Signed-off-by: AlexandraTrifan --- docs/gen_prefs.js | 30 ++++++++++++++++++++++++++++++ docs/user_guide/preferences.rst | 26 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 docs/gen_prefs.js create mode 100644 docs/user_guide/preferences.rst diff --git a/docs/gen_prefs.js b/docs/gen_prefs.js new file mode 100644 index 0000000000..10afc2ae4e --- /dev/null +++ b/docs/gen_prefs.js @@ -0,0 +1,30 @@ +function main() { + var prefs = scopy.getPreferences(); + var keys = Object.keys(prefs); + var rst_data = ""; + var output_rst_file = "preferences_table.rst"; + rst_data += "Preferences\n"; + rst_data += "===========\n\n"; + rst_data += ".. list-table::\n"; + rst_data += " :header-rows: 1\n"; + rst_data += " :widths: 20 30 50\n\n"; + rst_data += " * - PreferenceId\n"; + rst_data += " - Title\n"; + rst_data += " - Description\n"; + + keys.forEach(element => { + var prefsDetails = scopy.getPreferenceDescription(element); + if (prefsDetails === undefined) { + printToConsole("Error: Preference details not found for " + element); + } + var title = (prefsDetails[0] !== undefined )? prefsDetails[0] : "---"; + var description = (prefsDetails[1] !== undefined )? prefsDetails[1] : "---"; + rst_data += " * - " + element + "\n"; + rst_data += " - " + title + "\n"; + rst_data += " - " + description + "\n"; + }); + fileIO.writeToFile(rst_data, output_rst_file); + printToConsole("Documentation has been generated in " + output_rst_file); +} + +main() \ No newline at end of file diff --git a/docs/user_guide/preferences.rst b/docs/user_guide/preferences.rst new file mode 100644 index 0000000000..20eaa0f022 --- /dev/null +++ b/docs/user_guide/preferences.rst @@ -0,0 +1,26 @@ +.. _preferences: + +============================================= +Scopy Preferences +============================================= + +.. image:: https://raw.githubusercontent.com/analogdevicesinc/scopy/doc_resources/resources/scopy-general-prefs.png + :align: center +.. + + Scopy Preferences can be accessed using the bottom left side **preferences + button**. On the right side of the page, preferences for each plugin + are available. More details can be found in their specific plugin + documentation section. + + The **Open** button will try to open the specific OS explorer in + order to find the preference storage file. + + Clicking the **Reset Scopy** button will reset the application to a default + configuration. + + Changing some of the listed preferences will require an application + restart. More details on each preference are listed below. + +.. include:: preferences_table.rst + \ No newline at end of file