diff --git a/gui/include/gui/widgets/popupwidget.h b/gui/include/gui/widgets/popupwidget.h index 542cf5d119..c9f5ce3b5d 100644 --- a/gui/include/gui/widgets/popupwidget.h +++ b/gui/include/gui/widgets/popupwidget.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace scopy { class SCOPY_GUI_EXPORT PopupWidget : public QWidget @@ -55,6 +56,8 @@ class SCOPY_GUI_EXPORT PopupWidget : public QWidget QPushButton *getExitBtn(); QPushButton *getContinueBtn(); + void enableCloseButton(bool en); + Q_SIGNALS: void continueButtonClicked(); void exitButtonClicked(); @@ -66,6 +69,8 @@ class SCOPY_GUI_EXPORT PopupWidget : public QWidget QTextBrowser *m_descriptionTextBrowser; QPushButton *m_exitButton; QPushButton *m_continueButton; + QPushButton *m_closeButton; + HoverWidget *m_closeHover; }; } // namespace scopy diff --git a/gui/include/gui/widgets/toolbuttons.h b/gui/include/gui/widgets/toolbuttons.h index 9eb62ece20..d515446dd3 100644 --- a/gui/include/gui/widgets/toolbuttons.h +++ b/gui/include/gui/widgets/toolbuttons.h @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -63,7 +64,16 @@ class SCOPY_GUI_EXPORT InfoBtn : public QPushButton { Q_OBJECT public: - InfoBtn(QWidget *parent = nullptr); + InfoBtn(QWidget *parent = nullptr, bool hasTutorial = false); + + bool hasTutorial(); + QPushButton *getTutorialButton(); + QPushButton *getDocumentationButton(); + void generateInfoPopup(QWidget *parent); + +private: + PopupWidget *m_popupWidget; + bool m_hasTutorial; }; class SCOPY_GUI_EXPORT RunBtn : public QPushButton diff --git a/gui/src/widgets/popupwidget.cpp b/gui/src/widgets/popupwidget.cpp index 95b35d44c6..7e515b8bda 100644 --- a/gui/src/widgets/popupwidget.cpp +++ b/gui/src/widgets/popupwidget.cpp @@ -78,6 +78,36 @@ void PopupWidget::initUI() Style::setStyle(m_continueButton, style::properties::button::basicButton, true, true); Style::setStyle(m_exitButton, style::properties::button::basicButton, true, true); Style::setStyle(this, style::properties::widget::overlayMenu); + + m_closeButton = nullptr; + m_closeHover = nullptr; +} + +void PopupWidget::enableCloseButton(bool en) +{ + if(en) { + m_closeButton = new QPushButton(this); + m_closeButton->setMaximumSize(20, 20); + m_closeButton->setIcon(Style::getPixmap(":/gui/icons/close_hovered.svg", + Style::getColor(json::theme::interactive_subtle_idle))); + Style::setStyle(m_closeButton, style::properties::widget::notInteractive); + + m_closeHover = new HoverWidget(m_closeButton, this, this); + m_closeHover->setAnchorPos(HoverPosition::HP_TOPRIGHT); + m_closeHover->setContentPos(HoverPosition::HP_CENTER); + m_closeHover->setAnchorOffset(QPoint(-20, 20)); + m_closeHover->setVisible(true); + m_closeHover->raise(); + + connect(m_closeButton, &QPushButton::clicked, this, [=]() { deleteLater(); }); + } else { + if(m_closeButton != nullptr) { + delete m_closeButton; + } + if(m_closeHover != nullptr) { + delete m_closeHover; + } + } } void PopupWidget::setFocusOnContinueButton() diff --git a/gui/src/widgets/toolbuttons.cpp b/gui/src/widgets/toolbuttons.cpp index dec5c7d2c2..4a13e6cd96 100644 --- a/gui/src/widgets/toolbuttons.cpp +++ b/gui/src/widgets/toolbuttons.cpp @@ -87,9 +87,11 @@ GearBtn::GearBtn(QWidget *parent) Style::setStyle(this, style::properties::button::squareIconButton); } -InfoBtn::InfoBtn(QWidget *parent) +InfoBtn::InfoBtn(QWidget *parent, bool hasTutorial) : QPushButton(parent) + , m_hasTutorial(hasTutorial) { + QString iconPath = ":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) + "/icons/info.svg"; setIcon(Style::getPixmap(iconPath, Style::getColor(json::theme::content_default))); @@ -102,6 +104,45 @@ InfoBtn::InfoBtn(QWidget *parent) Style::setStyle(this, style::properties::button::squareIconButton); } +bool InfoBtn::hasTutorial() { return m_hasTutorial; } + +void InfoBtn::generateInfoPopup(QWidget *parent) +{ + m_popupWidget = new PopupWidget(parent); + m_popupWidget->move(parent->rect().center() - m_popupWidget->rect().center()); + m_popupWidget->setTitle("Plugin Information"); + m_popupWidget->setDescription( + "To learn more about this plugin, check out the tutorial or read the online documentation."); + m_popupWidget->getExitBtn()->setText("Tutorial"); + m_popupWidget->getContinueBtn()->setText("Documentation"); + m_popupWidget->enableCloseButton(true); + + connect(m_popupWidget->getExitBtn(), &QPushButton::clicked, this, [=]() { m_popupWidget->deleteLater(); }); + + connect(m_popupWidget->getContinueBtn(), &QPushButton::clicked, this, [=]() { m_popupWidget->deleteLater(); }); + + m_popupWidget->enableTintedOverlay(true); + m_popupWidget->show(); + m_popupWidget->raise(); +} + +QPushButton *InfoBtn::getTutorialButton() +{ + if(m_hasTutorial) { + return m_popupWidget->getExitBtn(); + } + + return nullptr; +} + +QPushButton *InfoBtn::getDocumentationButton() +{ + if(m_hasTutorial) { + return m_popupWidget->getContinueBtn(); + } + return nullptr; +} + RunBtn::RunBtn(QWidget *parent) : QPushButton(parent) { diff --git a/plugins/dac/include/dac/dacplugin.h b/plugins/dac/include/dac/dacplugin.h index 19853a4997..3c99f1759a 100644 --- a/plugins/dac/include/dac/dacplugin.h +++ b/plugins/dac/include/dac/dacplugin.h @@ -48,8 +48,6 @@ class SCOPY_DAC_EXPORT DACPlugin : public QObject, public PluginBase QString about() override; QString version() override; QString description() override; - void initPreferences() override; - bool loadPreferencesPage() override; public Q_SLOTS: bool onConnect() override; diff --git a/plugins/dac/src/dacinstrument.cpp b/plugins/dac/src/dacinstrument.cpp index c6774bc9a3..59c14abad0 100644 --- a/plugins/dac/src/dacinstrument.cpp +++ b/plugins/dac/src/dacinstrument.cpp @@ -57,7 +57,7 @@ DacInstrument::DacInstrument(const Connection *conn, QWidget *parent) openLastMenuBtn = new OpenLastMenuBtn(dynamic_cast(tool->rightContainer()), true, this); rightMenuBtnGrp = dynamic_cast(openLastMenuBtn)->getButtonGroup(); - infoBtn = new InfoBtn(this); + infoBtn = new InfoBtn(this, true); settingsBtn = new GearBtn(this); devicesGroup = new QButtonGroup(this); @@ -70,10 +70,17 @@ DacInstrument::DacInstrument(const Connection *conn, QWidget *parent) rightMenuBtnGrp->addButton(settingsBtn); rightMenuBtnGrp->addButton(devicesBtn->button()); + connect(infoBtn, &InfoBtn::clicked, this, [=]() { + infoBtn->generateInfoPopup(this); - connect(infoBtn, &QAbstractButton::clicked, this, [=, this]() { - QDesktopServices::openUrl(QUrl("https://analogdevicesinc.github.io/scopy/plugins/dac/dac.html")); + connect(infoBtn->getTutorialButton(), &QPushButton::clicked, this, [=]() { this->startTutorial(); }); + + connect(infoBtn->getDocumentationButton(), &QAbstractButton::clicked, this, [=, this]() { + QDesktopServices::openUrl( + QUrl("https://analogdevicesinc.github.io/scopy/plugins/dac/dac.html")); + }); }); + connect(devicesBtn, &QPushButton::toggled, dynamic_cast(tool->leftContainer()), &MenuHAnim::toggleMenu); @@ -189,17 +196,6 @@ void DacInstrument::abortTutorial() &DacInstrument::startDdsTutorial); } -void DacInstrument::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); - - // Handle tutorial - if(Preferences::get("dacplugin_start_tutorial").toBool()) { - startTutorial(); - Preferences::set("dacplugin_start_tutorial", false); - } -} - void DacInstrument::setupDacDataManagers() { QStringList deviceList; diff --git a/plugins/dac/src/dacinstrument.h b/plugins/dac/src/dacinstrument.h index 6db4317c64..9ee604382d 100644 --- a/plugins/dac/src/dacinstrument.h +++ b/plugins/dac/src/dacinstrument.h @@ -82,8 +82,6 @@ public Q_SLOTS: const QString settingsMenuId = "settings"; const QString devicesMenuId = "devices"; const QString verticalChannelManagerId = "vcm"; - - void showEvent(QShowEvent *event) override; }; } // namespace dac } // namespace scopy diff --git a/plugins/dac/src/dacplugin.cpp b/plugins/dac/src/dacplugin.cpp index ef1190fe59..cf6e03f403 100644 --- a/plugins/dac/src/dacplugin.cpp +++ b/plugins/dac/src/dacplugin.cpp @@ -100,46 +100,6 @@ void DACPlugin::unload() QString DACPlugin::description() { return "Tool for generic IIO DAC control."; } -void DACPlugin::initPreferences() -{ - Preferences *p = Preferences::GetInstance(); - p->init("dacplugin_start_tutorial", true); -} - -bool DACPlugin::loadPreferencesPage() -{ - Preferences *p = Preferences::GetInstance(); - - m_preferencesPage = new QWidget(); - QVBoxLayout *lay = new QVBoxLayout(m_preferencesPage); - - MenuSectionWidget *generalWidget = new MenuSectionWidget(m_preferencesPage); - MenuCollapseSection *generalSection = new MenuCollapseSection( - "General", MenuCollapseSection::MHCW_NONE, MenuCollapseSection::MHW_BASEWIDGET, generalWidget); - generalWidget->contentLayout()->setSpacing(10); - generalWidget->contentLayout()->addWidget(generalSection); - generalSection->contentLayout()->setSpacing(10); - lay->setMargin(0); - lay->addWidget(generalWidget); - lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); - - QWidget *resetTutorialWidget = new QWidget(); - QHBoxLayout *resetTutorialWidgetLayout = new QHBoxLayout(); - - resetTutorialWidget->setLayout(resetTutorialWidgetLayout); - resetTutorialWidgetLayout->setMargin(0); - - QPushButton *resetTutorial = new QPushButton("Reset", generalSection); - Style::setStyle(resetTutorial, style::properties::button::basicButton); - connect(resetTutorial, &QPushButton::clicked, this, [=, this]() { p->set("dacplugin_start_tutorial", true); }); - - resetTutorialWidgetLayout->addWidget(new QLabel("DAC tutorial "), 6); - resetTutorialWidgetLayout->addWidget(resetTutorial, 1); - generalSection->contentLayout()->addWidget(resetTutorialWidget); - - return true; -} - QString DACPlugin::about() { QString content = "DAC plugin"; diff --git a/plugins/datalogger/include/datalogger/datamonitortool.h b/plugins/datalogger/include/datalogger/datamonitortool.h index 52f22777d6..8d4661cc52 100644 --- a/plugins/datalogger/include/datalogger/datamonitortool.h +++ b/plugins/datalogger/include/datalogger/datamonitortool.h @@ -93,8 +93,6 @@ class SCOPY_DATALOGGER_EXPORT DatamonitorTool : public QWidget void initTutorialProperties(); void startTutorial(); - - void showEvent(QShowEvent *event) override; }; } // namespace scopy::datamonitor #endif // DATAMONITORTOOL_H diff --git a/plugins/datalogger/src/dataloggerplugin.cpp b/plugins/datalogger/src/dataloggerplugin.cpp index 0372e4a7c4..e3a062660f 100644 --- a/plugins/datalogger/src/dataloggerplugin.cpp +++ b/plugins/datalogger/src/dataloggerplugin.cpp @@ -259,7 +259,6 @@ void DataLoggerPlugin::initPreferences() p->init("dataloggerplugin_data_storage_size", "10 Kb"); p->init("dataloggerplugin_read_interval", "1"); p->init("dataloggerplugin_date_time_format", "hh:mm:ss"); - p->init("dataloggerplugin_start_tutorial", true); } bool DataLoggerPlugin::loadPreferencesPage() @@ -289,21 +288,6 @@ bool DataLoggerPlugin::loadPreferencesPage() generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceEdit( p, "dataloggerplugin_date_time_format", "DateTime format :", generalSection)); - QWidget *resetTutorialWidget = new QWidget(); - QHBoxLayout *resetTutorialWidgetLayout = new QHBoxLayout(); - - resetTutorialWidget->setLayout(resetTutorialWidgetLayout); - resetTutorialWidgetLayout->setMargin(0); - - QPushButton *resetTutorial = new QPushButton("Reset", generalSection); - Style::setStyle(resetTutorial, style::properties::button::basicButton); - connect(resetTutorial, &QPushButton::clicked, this, - [=, this]() { p->set("dataloggerplugin_start_tutorial", true); }); - - resetTutorialWidgetLayout->addWidget(new QLabel("Data logger tutorial "), 6); - resetTutorialWidgetLayout->addWidget(resetTutorial, 1); - generalSection->contentLayout()->addWidget(resetTutorialWidget); - return true; } diff --git a/plugins/datalogger/src/datamonitortool.cpp b/plugins/datalogger/src/datamonitortool.cpp index 822d2359b3..137c9e7982 100644 --- a/plugins/datalogger/src/datamonitortool.cpp +++ b/plugins/datalogger/src/datamonitortool.cpp @@ -64,19 +64,23 @@ DatamonitorTool::DatamonitorTool(DataAcquisitionManager *dataAcquisitionManager, openLastMenuBtn = new OpenLastMenuBtn(dynamic_cast(tool->rightContainer()), true, this); rightMenuBtnGrp = dynamic_cast(openLastMenuBtn)->getButtonGroup(); - infoBtn = new InfoBtn(this); printplotManager = new PrintPlotManager(this); runBtn = new RunBtn(this); clearBtn = new QPushButton("Clear", this); PrintBtn *printBtn = new PrintBtn(this); - // connect(infoBtn, &QPushButton::clicked, this, &DatamonitorTool::startTutorial); - connect(infoBtn, &QAbstractButton::clicked, this, [=, this]() { - QDesktopServices::openUrl( - QUrl("https://analogdevicesinc.github.io/scopy/plugins/datalogger/datalogger.html")); - }); + infoBtn = new InfoBtn(this, true); + + connect(infoBtn, &InfoBtn::clicked, this, [=]() { + infoBtn->generateInfoPopup(this); + + connect(infoBtn->getTutorialButton(), &QPushButton::clicked, this, [=]() { this->startTutorial(); }); - // connect(infoBtn, &QPushButton::clicked, this, &DatamonitorTool::startTutorial); + connect(infoBtn->getDocumentationButton(), &QPushButton::clicked, this, [=]() { + QDesktopServices::openUrl( + QUrl("https://analogdevicesinc.github.io/scopy/plugins/datalogger/datalogger.html")); + }); + }); //// add monitors addMonitorButton = new AddBtn(this); @@ -356,15 +360,4 @@ void DatamonitorTool::startTutorial() datamonitorTutorial->start(); } -void DatamonitorTool::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); - - // Handle tutorial - if(Preferences::get("dataloggerplugin_start_tutorial").toBool()) { - startTutorial(); - Preferences::set("dataloggerplugin_start_tutorial", false); - } -} - #include "moc_datamonitortool.cpp" diff --git a/plugins/regmap/src/registermaptool.cpp b/plugins/regmap/src/registermaptool.cpp index 21ab2f0a09..baa56627d3 100644 --- a/plugins/regmap/src/registermaptool.cpp +++ b/plugins/regmap/src/registermaptool.cpp @@ -68,11 +68,23 @@ RegisterMapTool::RegisterMapTool(QWidget *parent) tool->centralContainer()->layout()->setSpacing(0); lay->addWidget(tool); - InfoBtn *infoBtn = new InfoBtn(this); + InfoBtn *infoBtn = new InfoBtn(this, true); tool->addWidgetToTopContainerHelper(infoBtn, TTA_LEFT); - connect(infoBtn, &QAbstractButton::clicked, this, [=]() { - QDesktopServices::openUrl( - QUrl("https://analogdevicesinc.github.io/scopy/plugins/registermap/registermap.html")); + + connect(infoBtn, &InfoBtn::clicked, this, [=]() { + infoBtn->generateInfoPopup(this); + connect(infoBtn->getTutorialButton(), &QPushButton::clicked, this, [=]() { + if(searchBarWidget->isVisible()) { + startTutorial(); + } else { + startSimpleTutorial(); + } + }); + + connect(infoBtn->getDocumentationButton(), &QAbstractButton::clicked, this, [=]() { + QDesktopServices::openUrl( + QUrl("https://analogdevicesinc.github.io/scopy/plugins/registermap/registermap.html")); + }); }); searchBarWidget = new SearchBarWidget(); @@ -253,19 +265,3 @@ void RegisterMapTool::toggleSearchBarEnabled(bool enabled) searchBarWidget->hide(); } } - -void RegisterMapTool::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); - - // Handle tutorial - if(Preferences::get("regmapplugin_start_tutorial").toBool()) { - if(searchBarWidget->isVisible()) { - - startTutorial(); - } else { - startSimpleTutorial(); - } - Preferences::set("regmapplugin_start_tutorial", false); - } -} diff --git a/plugins/regmap/src/registermaptool.hpp b/plugins/regmap/src/registermaptool.hpp index 0dd42f9cf4..2ffd734489 100644 --- a/plugins/regmap/src/registermaptool.hpp +++ b/plugins/regmap/src/registermaptool.hpp @@ -80,7 +80,6 @@ class SCOPY_REGMAP_EXPORT RegisterMapTool : public QWidget private Q_SLOTS: void updateActiveRegisterMap(QString registerName); void toggleSearchBarEnabled(bool enabled); - void showEvent(QShowEvent *event) override; }; } // namespace regmap } // namespace scopy diff --git a/plugins/regmap/src/regmapplugin.cpp b/plugins/regmap/src/regmapplugin.cpp index 66e1eb0e1d..3a5a1d8862 100644 --- a/plugins/regmap/src/regmapplugin.cpp +++ b/plugins/regmap/src/regmapplugin.cpp @@ -135,7 +135,6 @@ void RegmapPlugin::initPreferences() { Preferences *p = Preferences::GetInstance(); p->init("regmap_color_by_value", "Default"); - p->init("regmapplugin_start_tutorial", true); #if defined __APPLE__ p->init("additional_regmap_xml_path", QCoreApplication::applicationDirPath() + "/plugins/xmls"); #else @@ -167,21 +166,6 @@ bool RegmapPlugin::loadPreferencesPage() "Register background and Bitfield text", "Register text and Bitfield background"}, generalSection)); - QWidget *resetTutorialWidget = new QWidget(); - QHBoxLayout *resetTutorialWidgetLayout = new QHBoxLayout(); - - resetTutorialWidget->setLayout(resetTutorialWidgetLayout); - resetTutorialWidgetLayout->setMargin(0); - - QPushButton *resetTutorial = new QPushButton("Reset", generalSection); - Style::setStyle(resetTutorial, style::properties::button::basicButton); - connect(resetTutorial, &QPushButton::clicked, this, - [=, this]() { p->set("regmapplugin_start_tutorial", true); }); - - resetTutorialWidgetLayout->addWidget(new QLabel("Register map tutorial "), 6); - resetTutorialWidgetLayout->addWidget(resetTutorial, 1); - generalSection->contentLayout()->addWidget(resetTutorialWidget); - return true; } diff --git a/plugins/swiot/include/swiot/ad74413r/ad74413r.h b/plugins/swiot/include/swiot/ad74413r/ad74413r.h index 1f4a2cd285..68d2974f54 100644 --- a/plugins/swiot/include/swiot/ad74413r/ad74413r.h +++ b/plugins/swiot/include/swiot/ad74413r/ad74413r.h @@ -156,8 +156,6 @@ private Q_SLOTS: QTimer *m_rstAcqTimer; const QString channelsMenuId = "channels"; const QString measureMenuId = "measure"; - - void showEvent(QShowEvent *event) override; }; } // namespace swiot } // namespace scopy diff --git a/plugins/swiot/include/swiot/faults/faults.h b/plugins/swiot/include/swiot/faults/faults.h index cd529b48ce..0d86cf6dba 100644 --- a/plugins/swiot/include/swiot/faults/faults.h +++ b/plugins/swiot/include/swiot/faults/faults.h @@ -65,7 +65,6 @@ private Q_SLOTS: FaultsPage *m_faultsPage; ToolMenuEntry *m_tme; - void showEvent(QShowEvent *event) override; }; } // namespace scopy::swiot #endif // FAULTS_H diff --git a/plugins/swiot/include/swiot/max14906/max14906.h b/plugins/swiot/include/swiot/max14906/max14906.h index 6696db2b3c..0aaf4e6d73 100644 --- a/plugins/swiot/include/swiot/max14906/max14906.h +++ b/plugins/swiot/include/swiot/max14906/max14906.h @@ -89,8 +89,6 @@ private Q_SLOTS: static QMainWindow *createDockableMainWindow(const QString &title, DioDigitalChannel *digitalChannel, QWidget *parent); QPushButton *createConfigBtn(QWidget *parent = nullptr); - - void showEvent(QShowEvent *event) override; }; } // namespace scopy::swiot #endif // MAX14906_H diff --git a/plugins/swiot/include/swiot/swiotplugin.h b/plugins/swiot/include/swiot/swiotplugin.h index 8281f7ce15..af9c9307b3 100644 --- a/plugins/swiot/include/swiot/swiotplugin.h +++ b/plugins/swiot/include/swiot/swiotplugin.h @@ -55,8 +55,6 @@ class SCOPY_SWIOT_EXPORT SWIOTPlugin : public QObject, public PluginBase bool compatible(QString param, QString category) override; void initMetadata() override; QString description() override; - void initPreferences() override; - bool loadPreferencesPage() override; public Q_SLOTS: bool onConnect() override; diff --git a/plugins/swiot/src/ad74413r/ad74413r.cpp b/plugins/swiot/src/ad74413r/ad74413r.cpp index a1fa9d6e43..d385f27cbb 100644 --- a/plugins/swiot/src/ad74413r/ad74413r.cpp +++ b/plugins/swiot/src/ad74413r/ad74413r.cpp @@ -402,16 +402,6 @@ PlotAxis *Ad74413r::createYChnlAxis(QPen pen, QString unitType, int yMin, int yM return chYAxis; } -void Ad74413r::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); - - if(Preferences::get("ad74413r_start_tutorial").toBool()) { - startTutorial(); - Preferences::set("ad74413r_start_tutorial", false); - } -} - void Ad74413r::setupChannelBtn(MenuControlButton *btn, PlotChannel *ch, QString chnlId, int chnlIdx) { btn->setName(chnlId); @@ -609,7 +599,7 @@ void Ad74413r::setupToolTemplate() setupDeviceBtn(); m_tool->addWidgetToCentralContainerHelper(m_plot); - m_infoBtn = new InfoBtn(this); + m_infoBtn = new InfoBtn(this, true); m_infoBtn->installEventFilter(this); m_settingsBtn = new GearBtn(this); m_runBtn = new RunBtn(this); @@ -620,9 +610,13 @@ void Ad74413r::setupToolTemplate() m_singleBtn->setChecked(false); m_configBtn = createConfigBtn(); - connect(m_infoBtn, &QAbstractButton::clicked, this, [=, this]() { - QDesktopServices::openUrl( - QUrl("https://analogdevicesinc.github.io/scopy/plugins/swiot1l/ad74413r.html")); + connect(m_infoBtn, &InfoBtn::clicked, this, [=]() { + m_infoBtn->generateInfoPopup(this); + connect(m_infoBtn->getTutorialButton(), &QPushButton::clicked, this, [=]() { this->startTutorial(); }); + connect(m_infoBtn->getDocumentationButton(), &QAbstractButton::clicked, this, [=, this]() { + QDesktopServices::openUrl( + QUrl("https://analogdevicesinc.github.io/scopy/plugins/swiot1l/ad74413r.html")); + }); }); MenuControlButton *measure = new MenuControlButton(this); diff --git a/plugins/swiot/src/faults/faults.cpp b/plugins/swiot/src/faults/faults.cpp index 3608d7e1c7..3861822cde 100644 --- a/plugins/swiot/src/faults/faults.cpp +++ b/plugins/swiot/src/faults/faults.cpp @@ -54,12 +54,16 @@ Faults::Faults(QString uri, ToolMenuEntry *tme, QWidget *parent) layout->addWidget(m_tool); - InfoBtn *infoBtn = new InfoBtn(this); + InfoBtn *infoBtn = new InfoBtn(this, true); m_tool->addWidgetToTopContainerHelper(infoBtn, TTA_LEFT); - connect(infoBtn, &QAbstractButton::clicked, this, [=, this]() { - QDesktopServices::openUrl(QUrl("https://analogdevicesinc.github.io/scopy/plugins/swiot1l/faults.html")); + connect(infoBtn, &InfoBtn::clicked, this, [=]() { + infoBtn->generateInfoPopup(this); + connect(infoBtn->getTutorialButton(), &QPushButton::clicked, this, [=]() { this->startTutorial(); }); + connect(infoBtn->getDocumentationButton(), &QAbstractButton::clicked, this, [=, this]() { + QDesktopServices::openUrl( + QUrl("https://analogdevicesinc.github.io/scopy/plugins/swiot1l/faults.html")); + }); }); - m_configBtn = createConfigBtn(this); m_runBtn = new RunBtn(this); m_singleBtn = new SingleShotBtn(this); @@ -161,16 +165,6 @@ QPushButton *Faults::createConfigBtn(QWidget *parent) return configBtn; } -void Faults::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); - - if(Preferences::get("faults_start_tutorial").toBool()) { - startTutorial(); - Preferences::set("faults_start_tutorial", false); - } -} - void Faults::initTutorialProperties() { // initialize components that might be used for the Faults tutorial diff --git a/plugins/swiot/src/max14906/max14906.cpp b/plugins/swiot/src/max14906/max14906.cpp index 002935054a..b67a87e1a7 100644 --- a/plugins/swiot/src/max14906/max14906.cpp +++ b/plugins/swiot/src/max14906/max14906.cpp @@ -58,13 +58,17 @@ Max14906::Max14906(QString uri, ToolMenuEntry *tme, QWidget *parent) layout->addWidget(m_tool); - InfoBtn *infoBtn = new InfoBtn(this); + InfoBtn *infoBtn = new InfoBtn(this, true); m_tool->addWidgetToTopContainerHelper(infoBtn, TTA_LEFT); - connect(infoBtn, &QAbstractButton::clicked, this, [=, this]() { - QDesktopServices::openUrl( - QUrl("https://analogdevicesinc.github.io/scopy/plugins/swiot1l/max14906.html")); + connect(infoBtn, &InfoBtn::clicked, this, [=]() { + infoBtn->generateInfoPopup(this); + connect(infoBtn->getTutorialButton(), &QPushButton::clicked, this, [=]() { this->startTutorial(); }); + + connect(infoBtn->getDocumentationButton(), &QAbstractButton::clicked, this, [=, this]() { + QDesktopServices::openUrl( + QUrl("https://analogdevicesinc.github.io/scopy/plugins/swiot1l/max14906.html")); + }); }); - m_configBtn = createConfigBtn(this); m_runBtn = new RunBtn(this); m_gearBtn = new GearBtn(this); @@ -317,14 +321,4 @@ QPushButton *Max14906::createConfigBtn(QWidget *parent) return configBtn; } -void Max14906::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); - - if(Preferences::get("max14906_start_tutorial").toBool()) { - startTutorial(); - Preferences::set("max14906_start_tutorial", false); - } -} - #include "moc_max14906.cpp" diff --git a/plugins/swiot/src/swiotplugin.cpp b/plugins/swiot/src/swiotplugin.cpp index 7538b5768a..22c355b3db 100644 --- a/plugins/swiot/src/swiotplugin.cpp +++ b/plugins/swiot/src/swiotplugin.cpp @@ -373,95 +373,6 @@ void SWIOTPlugin::clearPingTask() QString SWIOTPlugin::description() { return "Adds functionality specific to SWIOT1L board"; } -void SWIOTPlugin::initPreferences() -{ - Preferences *p = Preferences::GetInstance(); - p->init("ad74413r_start_tutorial", true); - p->init("max14906_start_tutorial", true); - p->init("faults_start_tutorial", true); - p->init("swiote_config_start_tutorial", true); -} - -bool SWIOTPlugin::loadPreferencesPage() -{ - Preferences *p = Preferences::GetInstance(); - - m_preferencesPage = new QWidget(); - QVBoxLayout *lay = new QVBoxLayout(m_preferencesPage); - - MenuSectionWidget *generalWidget = new MenuSectionWidget(m_preferencesPage); - MenuCollapseSection *generalSection = new MenuCollapseSection( - "General", MenuCollapseSection::MHCW_NONE, MenuCollapseSection::MHW_BASEWIDGET, generalWidget); - generalWidget->contentLayout()->setSpacing(10); - generalWidget->contentLayout()->addWidget(generalSection); - generalSection->contentLayout()->setSpacing(10); - lay->setMargin(0); - lay->addWidget(generalWidget); - lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); - - QWidget *resetTutorialAd74413rWidget = new QWidget(); - QHBoxLayout *resetTutorialAd74413rWidgetLayout = new QHBoxLayout(); - - resetTutorialAd74413rWidget->setLayout(resetTutorialAd74413rWidgetLayout); - resetTutorialAd74413rWidgetLayout->setMargin(0); - - QPushButton *resetTutorialAd74413r = new QPushButton("Reset", generalSection); - connect(resetTutorialAd74413r, &QPushButton::clicked, this, - [=, this]() { p->set("ad74413r_start_tutorial", true); }); - - QWidget *resetTutorialMax14906Widget = new QWidget(); - QHBoxLayout *resetTutorialMax14906WidgetLayout = new QHBoxLayout(); - - resetTutorialMax14906Widget->setLayout(resetTutorialMax14906WidgetLayout); - resetTutorialMax14906WidgetLayout->setMargin(0); - - QPushButton *resetTutorialMax14906 = new QPushButton("Reset ", generalSection); - connect(resetTutorialMax14906, &QPushButton::clicked, this, - [=, this]() { p->set("max14906_start_tutorial", true); }); - - QWidget *resetTutorialFaultsWidget = new QWidget(); - QHBoxLayout *resetTutorialFaultsWidgetLayout = new QHBoxLayout(); - - resetTutorialFaultsWidget->setLayout(resetTutorialFaultsWidgetLayout); - resetTutorialFaultsWidgetLayout->setMargin(0); - - QPushButton *resetTutorialFaults = new QPushButton("Reset ", generalSection); - connect(resetTutorialFaults, &QPushButton::clicked, this, - [=, this]() { p->set("faults_start_tutorial", true); }); - - QWidget *resetTutorialConfigurationWidget = new QWidget(); - QHBoxLayout *resetTutorialConfigurationWidgetLayout = new QHBoxLayout(); - - resetTutorialConfigurationWidget->setLayout(resetTutorialConfigurationWidgetLayout); - resetTutorialConfigurationWidgetLayout->setMargin(0); - - QPushButton *resetTutorialConfig = new QPushButton("Reset ", generalSection); - connect(resetTutorialConfig, &QPushButton::clicked, this, - [=, this]() { p->set("swiote_config_start_tutorial", true); }); - - Style::setStyle(resetTutorialAd74413r, style::properties::button::basicButton); - resetTutorialMax14906WidgetLayout->addWidget(new QLabel("Ad74413r tutorial"), 6); - resetTutorialMax14906WidgetLayout->addWidget(resetTutorialAd74413r, 1); - generalSection->contentLayout()->addWidget(resetTutorialAd74413rWidget); - - Style::setStyle(resetTutorialMax14906, style::properties::button::basicButton); - resetTutorialAd74413rWidgetLayout->addWidget(new QLabel("Max14906 tutorial"), 6); - resetTutorialAd74413rWidgetLayout->addWidget(resetTutorialMax14906, 1); - generalSection->contentLayout()->addWidget(resetTutorialMax14906Widget); - - Style::setStyle(resetTutorialFaults, style::properties::button::basicButton); - resetTutorialFaultsWidgetLayout->addWidget(new QLabel("Faults tutorial"), 6); - resetTutorialFaultsWidgetLayout->addWidget(resetTutorialFaults, 1); - generalSection->contentLayout()->addWidget(resetTutorialFaultsWidget); - - Style::setStyle(resetTutorialConfig, style::properties::button::basicButton); - resetTutorialConfigurationWidgetLayout->addWidget(new QLabel("Configuration tutorial"), 6); - resetTutorialConfigurationWidgetLayout->addWidget(resetTutorialConfig, 1); - generalSection->contentLayout()->addWidget(resetTutorialConfigurationWidget); - - return true; -} - void SWIOTPlugin::initMetadata() { loadMetadata(