Skip to content

Commit

Permalink
dac: info button added options for tutorial and documentation
Browse files Browse the repository at this point in the history
Signed-off-by: IonutMuthi <[email protected]>
  • Loading branch information
IonutMuthi authored and adisuciu committed Nov 22, 2024
1 parent 00df16a commit 375105d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 58 deletions.
2 changes: 0 additions & 2 deletions plugins/dac/include/dac/dacplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 10 additions & 14 deletions plugins/dac/src/dacinstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ DacInstrument::DacInstrument(const Connection *conn, QWidget *parent)
openLastMenuBtn = new OpenLastMenuBtn(dynamic_cast<MenuHAnim *>(tool->rightContainer()), true, this);
rightMenuBtnGrp = dynamic_cast<OpenLastMenuBtn *>(openLastMenuBtn)->getButtonGroup();

infoBtn = new InfoBtn(this);
infoBtn = new InfoBtn(this, true);
settingsBtn = new GearBtn(this);

devicesGroup = new QButtonGroup(this);
Expand All @@ -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<MenuHAnim *>(tool->leftContainer()),
&MenuHAnim::toggleMenu);

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions plugins/dac/src/dacinstrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 0 additions & 40 deletions plugins/dac/src/dacplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 375105d

Please sign in to comment.