Skip to content

Commit

Permalink
regmap: 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 003960c commit 00df16a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 37 deletions.
36 changes: 16 additions & 20 deletions plugins/regmap/src/registermaptool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}
1 change: 0 additions & 1 deletion plugins/regmap/src/registermaptool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions plugins/regmap/src/regmapplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 00df16a

Please sign in to comment.