diff --git a/core/src/scopypreferencespage.cpp b/core/src/scopypreferencespage.cpp index c5e38db2b5..8dec85d1bf 100644 --- a/core/src/scopypreferencespage.cpp +++ b/core/src/scopypreferencespage.cpp @@ -210,8 +210,6 @@ QWidget *ScopyPreferencesPage::buildGeneralPreferencesPage() PreferencesHelper::addPreferenceCheckBox(p, "show_graticule", "Show Graticule", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( p, "iiowidgets_use_lazy_loading", "Use Lazy Loading", generalSection)); - generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( - p, "plugins_use_debugger_v2", "Use Debugger V2 plugin", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( p, "general_theme", "Theme", {"default", "light"}, generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( diff --git a/iio-widgets/include/iio-widgets/iiowidgetbuilder.h b/iio-widgets/include/iio-widgets/iiowidgetbuilder.h index df84e12453..7b9657654c 100644 --- a/iio-widgets/include/iio-widgets/iiowidgetbuilder.h +++ b/iio-widgets/include/iio-widgets/iiowidgetbuilder.h @@ -90,6 +90,14 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject */ IIOWidgetBuilder &compactMode(bool isCompact); + /** + * @brief includeDebugAttributes If set to true, the buildAll function will + * also include the debugfs attributes when creating the IIOWidgets. + * @param isIncluded Default value is false. + * @return + */ + IIOWidgetBuilder &includeDebugAttributes(bool isIncluded); + /** * @brief Sets the context that will be used, if no iio_device or iio_channel * is set, the build functions will work with the context. @@ -161,6 +169,7 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject Connection *m_connection; bool m_isCompact; + bool m_includeDebugAttrs; struct iio_context *m_context; struct iio_device *m_device; struct iio_channel *m_channel; diff --git a/iio-widgets/src/iiowidgetbuilder.cpp b/iio-widgets/src/iiowidgetbuilder.cpp index 74aa37612f..c3e2bed926 100644 --- a/iio-widgets/src/iiowidgetbuilder.cpp +++ b/iio-widgets/src/iiowidgetbuilder.cpp @@ -29,6 +29,7 @@ #include "datastrategy/cmdqdeviceattrdatastrategy.h" #include "guistrategy/comboguistrategy.h" #include "guistrategy/rangeguistrategy.h" +#include #include #include @@ -40,6 +41,7 @@ IIOWidgetBuilder::IIOWidgetBuilder(QObject *parent) : QObject(parent) , m_connection(nullptr) , m_isCompact(false) + , m_includeDebugAttrs(Preferences::get("debugger_v2_include_debugfs").toBool()) , m_context(nullptr) , m_device(nullptr) , m_channel(nullptr) @@ -143,6 +145,34 @@ QList IIOWidgetBuilder::buildAll() m_attribute = ""; m_optionsAttribute = ""; } + + if(m_includeDebugAttrs) { + attrCount = iio_device_get_debug_attrs_count(m_device); + for(ssize_t i = 0; i < attrCount; ++i) { + attrName = iio_device_get_debug_attr(m_device, i); + + if(!attrName) { + qWarning(CAT_ATTRBUILDER) + << "Could not read the device DEBUG attribute name with index" << i; + continue; + } + + m_attribute = attrName; + if(QString(attrName).endsWith("_available")) { + continue; + } + + availableAttr = iio_device_find_debug_attr( + m_device, (QString(attrName) + "_available").toStdString().c_str()); + if(availableAttr) { + m_optionsAttribute = availableAttr; + } + + result.append(buildSingle()); + m_attribute = ""; + m_optionsAttribute = ""; + } + } } else if(m_context) { attrCount = iio_context_get_attrs_count(m_context); for(ssize_t i = 0; i < attrCount; ++i) { @@ -199,6 +229,12 @@ IIOWidgetBuilder &IIOWidgetBuilder::compactMode(bool isCompact) return *this; } +IIOWidgetBuilder &IIOWidgetBuilder::includeDebugAttributes(bool isIncluded) +{ + m_includeDebugAttrs = isIncluded; + return *this; +} + IIOWidgetBuilder &IIOWidgetBuilder::context(iio_context *context) { m_context = context; diff --git a/plugins/debugger/include/debugger/debuggerplugin.h b/plugins/debugger/include/debugger/debuggerplugin.h index 5e55419589..218dbdff51 100644 --- a/plugins/debugger/include/debugger/debuggerplugin.h +++ b/plugins/debugger/include/debugger/debuggerplugin.h @@ -21,7 +21,9 @@ class SCOPY_DEBUGGER_EXPORT DebuggerPlugin : public QObject, public PluginBase public: friend class IIODebugPlugin_API; + void initPreferences() override; bool compatible(QString m_param, QString category) override; + bool loadPreferencesPage() override; bool loadPage() override; bool loadIcon() override; void loadToolList() override; diff --git a/plugins/debugger/src/debuggerplugin.cpp b/plugins/debugger/src/debuggerplugin.cpp index 71e615f740..9ee68292f6 100644 --- a/plugins/debugger/src/debuggerplugin.cpp +++ b/plugins/debugger/src/debuggerplugin.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -22,6 +23,13 @@ using namespace scopy::debugger; Q_LOGGING_CATEGORY(CAT_DEBUGGERPLUGIN, "DEBUGGERPLUGIN"); Q_LOGGING_CATEGORY(CAT_BENCHMARK, "Benchmark"); +void DebuggerPlugin::initPreferences() +{ + Preferences *p = Preferences::GetInstance(); + p->init("debugger_v2_include_debugfs", true); + p->init("plugins_use_debugger_v2", true); +} + bool DebuggerPlugin::compatible(QString m_param, QString category) { bool ret = true; @@ -34,6 +42,31 @@ bool DebuggerPlugin::compatible(QString m_param, QString category) return ret; } +bool DebuggerPlugin::loadPreferencesPage() +{ + Preferences *p = Preferences::GetInstance(); + + m_preferencesPage = new QWidget(); + QVBoxLayout *layout = new QVBoxLayout(m_preferencesPage); + + MenuSectionCollapseWidget *generalSection = + new MenuSectionCollapseWidget("General", MenuCollapseSection::MHCW_NONE); + generalSection->contentLayout()->setSpacing(10); + layout->addWidget(generalSection); + layout->setSpacing(0); + 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); + auto debugger_include_debugfs = PreferencesHelper::addPreferenceCheckBox( + p, "debugger_v2_include_debugfs", "Include debug attributes in IIO Explorer", generalSection); + + generalSection->contentLayout()->addWidget(use_debugger_v2); + generalSection->contentLayout()->addWidget(debugger_include_debugfs); + + return true; +} + void DebuggerPlugin::loadToolList() { m_toolList.append(