Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: hw access "led" in TME #1845

Open
wants to merge 41 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
504b7bf
core/device: Added iconPixmap method.
andreidanila1 Nov 21, 2024
20c03b6
gui/res: Added led icon.
andreidanila1 Nov 21, 2024
7d562a6
style/json/global: Added led_success and led_error colors.
andreidanila1 Dec 5, 2024
5734945
gui/widgets: Added LedButton class.
andreidanila1 Nov 21, 2024
f2e2271
iioutil: Create iioeventemitter interface.
andreidanila1 Nov 22, 2024
c80d840
gui/widgets/menucollapsesection: Create a new type of header widget.
andreidanila1 Nov 21, 2024
d32bbaf
pluginbase/toolmenuentry: Added iioEvent signal.
andreidanila1 Nov 21, 2024
046cd66
core/toolmenumanager: Use ToolMenuWidget for device section.
andreidanila1 Nov 21, 2024
dd39643
plugins/swiot: Emit iioEvent when needed.
andreidanila1 Nov 21, 2024
940745c
plugins/pqm: Emit iioEvent when needed.
andreidanila1 Nov 21, 2024
61a4546
plugins/dac: Emit iioEvent when needed.
andreidanila1 Nov 21, 2024
85ef998
plugins/debugger: Emit iioEvent when needed.
andreidanila1 Nov 21, 2024
7d49ff6
plugins/regmap: Emit iioEvent when needed.
andreidanila1 Nov 21, 2024
9b9910b
plugins/datalogger: Emit iioEvent when needed.
andreidanila1 Nov 21, 2024
98b1cf3
plugins/adc: Emit iioEvent when needed.
andreidanila1 Nov 21, 2024
e1cc054
plugins/m2k: Emit iioEvent when needed.
andreidanila1 Nov 22, 2024
9298818
core/toolmenumanager: Handle devicePressed signal.
andreidanila1 Nov 25, 2024
623c287
gui/style/json/global: Added border_width_2 dimension.
andreidanila1 Nov 26, 2024
683800c
gui/style/properties/widget: Added ledBorder qss.
andreidanila1 Nov 26, 2024
feb1dcc
core: Added device_menu_item preference.
andreidanila1 Nov 27, 2024
3925fdc
gui/toolmenuheaderwidget: Show connection status in menu item.
andreidanila1 Nov 26, 2024
b5eaab9
style/qss/properties/widget: Added deviceHeaderWidget style.
andreidanila1 Nov 28, 2024
1d08257
core/toolmenumanager: Highlight device header on hover and selection.
andreidanila1 Nov 28, 2024
93c8c9a
pluginbase: Added config page.
andreidanila1 Nov 28, 2024
1a96b70
core: Create device config page.
andreidanila1 Nov 28, 2024
393b9e6
core/scopymainwindow: Added collapseToolMenu method.
andreidanila1 Dec 2, 2024
fd827c5
core/toolmenu: Show icons when collapsed.
andreidanila1 Dec 2, 2024
806f8c9
gui/toolmenuheaderwidget: Changed blinking model.
andreidanila1 Dec 10, 2024
0e2682f
gui/utils: Changes to SVG handling.
andreidanila1 Dec 13, 2024
ec50dae
gui/res/icons: Added device shapes for DeviceIconBuilder.
andreidanila1 Dec 13, 2024
d9c0d1b
gui: Created DeviceIconBuilder class.
andreidanila1 Dec 13, 2024
7d769e5
style/qss/properties/label: Add qss styling for DeviceIcon-specific l…
andreidanila1 Dec 13, 2024
aca776f
plugins/adc: Create icon using DeviceIconBuilder.
andreidanila1 Dec 13, 2024
fc7bec4
plugins/dac: Create icon using DeviceIconBuilder.
andreidanila1 Dec 13, 2024
0d583e4
plugins/datalogger: Create icon using DeviceIconBuilder.
andreidanila1 Dec 13, 2024
72b6d02
plugins/debugger: Create icon using DeviceIconBuilder.
andreidanila1 Dec 13, 2024
1d16e98
plugins/pqm: Create icon using DeviceIconBuilder.
andreidanila1 Dec 13, 2024
1470616
plugins/regmap: Create icon using DeviceIconBuilder.
andreidanila1 Dec 13, 2024
4e6ea1a
plugins/swiot: Create icon using DeviceIconBuilder.
andreidanila1 Dec 13, 2024
2734022
core/deviceimpl: Create NO_PLUGIN icon using DeviceIconBuilder.
andreidanila1 Dec 13, 2024
22617de
core/devicebrowser: Added horizontal scroll bar.
andreidanila1 Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/include/core/browsemenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class SCOPY_CORE_EXPORT BrowseMenu : public QWidget
private:
void add(QWidget *w, QString name, MenuAlignment position);
void toggleCollapsed();
void hideBtnText(QPushButton *btn, QString name, bool hide);
QPushButton *createBtn(QString name, QString iconPath, QWidget *parent = nullptr);
QFrame *createHLine(QWidget *parent = nullptr);
QWidget *createHeader(QWidget *parent = nullptr);
Expand Down
2 changes: 2 additions & 0 deletions core/include/core/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ class SCOPY_CORE_EXPORT Device
virtual QString param() = 0;
virtual QString displayParam() = 0;
virtual QWidget *icon() = 0;
virtual QPixmap iconPixmap() = 0;

virtual QWidget *page() = 0;
virtual QWidget *configPage() = 0;

virtual QList<ToolMenuEntry *> toolList() = 0;
virtual void init() = 0;
Expand Down
2 changes: 2 additions & 0 deletions core/include/core/devicebrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ private Q_SLOTS:
void updateSelectedDeviceIdx(QString);
void forwardRequestDeviceWithDirection();

void onScrollRangeChanged(int min, int max);

private:
void initBtns();
DeviceIcon *buildDeviceIcon(Device *d, QWidget *parent = nullptr);
Expand Down
5 changes: 5 additions & 0 deletions core/include/core/deviceimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QCheckBox>
#include <QObject>
#include <QPushButton>
#include <QTabWidget>

namespace scopy {

Expand All @@ -48,7 +49,9 @@ class SCOPY_CORE_EXPORT DeviceImpl : public QObject, public Device
QString category() override;
QString param() override;
QWidget *icon() override;
QPixmap iconPixmap() override;
QWidget *page() override;
QWidget *configPage() override;
QList<ToolMenuEntry *> toolList() override;
virtual void init() override;
virtual void preload() override;
Expand Down Expand Up @@ -84,6 +87,7 @@ public Q_SLOTS:
void loadName();
void loadIcons();
void loadPages();
void loadConfigPage();
void loadToolList();
void loadBadges();
void setPingPlugin(Plugin *plugin);
Expand All @@ -102,6 +106,7 @@ public Q_SLOTS:
QString m_param;
QWidget *m_icon;
QWidget *m_page;
QTabWidget *m_configPage;
QPushButton *connbtn, *discbtn;
Plugin *m_pingPlugin = nullptr;
};
Expand Down
1 change: 1 addition & 0 deletions core/include/core/scopymainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public Q_SLOTS:
void handleScanner();
void enableScanner();
void deviceAutoconnect();
void collapseToolMenu(bool collapse);

protected:
void closeEvent(QCloseEvent *event) override;
Expand Down
2 changes: 1 addition & 1 deletion core/include/core/toolmenuitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ class ToolMenuItem : public QPushButton
public Q_SLOTS:
void setDisabled(bool disabled);
void updateItem();
void onCollapsed(bool collapsed);

protected:
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);

private:
// QPushButton *m_toolBtn;
CustomPushButton *m_toolRunBtn;

QString m_uuid;
Expand Down
25 changes: 23 additions & 2 deletions core/include/core/toolmenumanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,24 @@
#include "scopy-core_export.h"

namespace scopy {

typedef struct
{
QString id;
QString name;
QString param;
QPixmap icon;
QList<ToolMenuEntry *> tools;
} DeviceInfo;

class SCOPY_CORE_EXPORT ToolMenuManager : public QObject
{
Q_OBJECT
public:
ToolMenuManager(ToolStack *ts, DetachedToolWindowManager *dtm, ToolMenu *toolMenu, QObject *parent = nullptr);
~ToolMenuManager();

void addMenuItem(QString deviceId, QString devName, QList<ToolMenuEntry *> tools, int itemIndex = -1);
void addMenuItem(DeviceInfo dInfo, int itemIndex = -1);
void removeMenuItem(QString deviceId);
void changeToolListContents(QString deviceId, QList<ToolMenuEntry *> tools);

Expand All @@ -52,13 +62,17 @@ public Q_SLOTS:
void deviceConnected(QString id);
void deviceDisconnected(QString id);
void onDisplayNameChanged(QString id, QString devName);
void onIioEvent(QString id, int retCode, IIOCallType type);

Q_SIGNALS:
void requestToolSelect(QString id);
void connState(QString id, bool isConnected);
void menuCollapsed(bool collapsed);

private Q_SLOTS:
void updateTool(QWidget *old);
void updateToolAttached(bool oldAttach, ToolMenuItem *toolMenuItem);
void setCollapsed(bool collapse);

private:
void loadToolAttachedState(ToolMenuEntry *tme);
Expand All @@ -68,15 +82,22 @@ private Q_SLOTS:
void showTool(ToolMenuItem *toolMenuItem);
void selectTool(ToolMenuItem *toolMenuItem, bool on);
void setTmeAttached(ToolMenuEntry *tme);
MenuSectionCollapseWidget *createMenuSectionItem(QString deviceName, QString uri = "");
MenuSectionCollapseWidget *createMenuSectionItem(const DeviceInfo &dInfo);
ToolMenuItem *createToolMenuItem(ToolMenuEntry *tme, QWidget *parent = nullptr);
MenuCollapseHeader *getCollapseSectionHeader(MenuSectionCollapseWidget *section);
void initHeaderWidget(MenuCollapseSection::MenuHeaderWidgetType type, MenuCollapseHeader *header,
const DeviceInfo &dInfo);
void initToolMenuHeaderWidget(MenuCollapseHeader *header, const DeviceInfo &dInfo);
void initCompositeHeaderWidget(MenuCollapseHeader *header, const DeviceInfo &dInfo);

bool m_collapsed;
QString m_prevItem;
QStringList m_connectedDev;
ToolStack *m_ts;
DetachedToolWindowManager *m_dtm;
ToolMenu *m_toolMenu;
QMap<QString, MenuSectionCollapseWidget *> m_itemMap;
QMap<QString, DeviceInfo> m_dInfoMap;
};
} // namespace scopy

Expand Down
21 changes: 18 additions & 3 deletions core/src/browsemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ BrowseMenu::BrowseMenu(QWidget *parent)
homeBtn->setIconSize(QSize(32, 32));
homeBtn->setStyleSheet("text-align: left");
connect(homeBtn, &QPushButton::clicked, this, [=]() { Q_EMIT requestTool("home"); });
connect(this, &BrowseMenu::collapsed, homeBtn,
[this, homeBtn](bool collapsed) { hideBtnText(homeBtn, tr("Home"), collapsed); });

QWidget *saveLoadWidget = new QWidget(m_content);
saveLoadWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
Expand Down Expand Up @@ -93,6 +95,8 @@ BrowseMenu::BrowseMenu(QWidget *parent)
QPushButton *aboutBtn = createBtn(
"About", ":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) + "/icons/info.svg",
m_content);
aboutBtn->setIconSize(
QSize(Style::getDimension(json::global::unit_2), Style::getDimension(json::global::unit_2)));
connect(aboutBtn, &QPushButton::clicked, this, [=]() { Q_EMIT requestTool("about"); });
aboutBtn->setCheckable(true);

Expand Down Expand Up @@ -139,16 +143,26 @@ void BrowseMenu::toggleCollapsed()
{
m_collapsed = !m_collapsed;
m_btnCollapse->setHidden(m_collapsed);
m_content->setHidden(m_collapsed);
Q_EMIT collapsed(m_collapsed);
}

void BrowseMenu::hideBtnText(QPushButton *btn, QString name, bool hide)
{
if(hide) {
btn->setText("");
} else {
btn->setText(name);
}
}

QPushButton *BrowseMenu::createBtn(QString name, QString iconPath, QWidget *parent)
{
QPushButton *btn = new QPushButton(parent);
btn->setIcon(QIcon(iconPath));
btn->setText(tr(name.toStdString().c_str()));
Style::setStyle(btn, style::properties::button::toolButton);
Style::setStyle(btn, style::properties::button::toolButton, true);
connect(this, &BrowseMenu::collapsed, btn,
[this, btn, name](bool collapsed) { hideBtnText(btn, tr(name.toStdString().c_str()), collapsed); });
return btn;
}

Expand All @@ -172,7 +186,7 @@ QWidget *BrowseMenu::createHeader(QWidget *parent)
Style::setStyle(btnCollapseMini, style::properties::widget::toolMenu);
Style::setStyle(btnCollapseMini, style::properties::button::toolButton);
btnCollapseMini->setCheckable(true);
btnCollapseMini->setFixedSize(Style::getDimension(json::global::unit_4),
btnCollapseMini->setFixedSize(Style::getDimension(json::global::unit_4_5),
Style::getDimension(json::global::unit_4));
headerLay->addWidget(btnCollapseMini);

Expand All @@ -190,6 +204,7 @@ QLabel *BrowseMenu::createScopyLogo(QWidget *parent)
{
QLabel *logo = new QLabel(m_content);
Style::setStyle(logo, style::properties::widget::logo);
connect(this, &BrowseMenu::collapsed, logo, &QWidget::setHidden);
return logo;
}

Expand Down
32 changes: 28 additions & 4 deletions core/src/devicebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include <QDebug>
#include <QLoggingCategory>
#include <qscrollbar.h>
#include <style.h>

Q_LOGGING_CATEGORY(CAT_DEVBROWSER, "DeviceBrowser")
Expand All @@ -45,13 +46,19 @@ DeviceBrowser::DeviceBrowser(QWidget *parent)
this->setFixedHeight(185);

auto dbm = ui->wDeviceBrowserMenu;
layout = new QHBoxLayout(dbm);
layout = dynamic_cast<QHBoxLayout *>(dbm->layout());

auto scrollArea = ui->scrollArea;
scrollArea->horizontalScrollBar()->setVisible(false);

initBtns();

connect(ui->btnHome, SIGNAL(clicked()), this, SLOT(forwardRequestDeviceWithDirection()));
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(forwardRequestDeviceWithDirection()));
connect(this, SIGNAL(requestDevice(QString, int)), this, SLOT(updateSelectedDeviceIdx(QString)));

connect(scrollArea->horizontalScrollBar(), &QScrollBar::rangeChanged, this,
&DeviceBrowser::onScrollRangeChanged);
}

DeviceBrowser::~DeviceBrowser()
Expand Down Expand Up @@ -96,13 +103,16 @@ void DeviceBrowser::addDevice(QString id, Device *d, int position)
{
qInfo(CAT_DEVBROWSER) << "adding device " << id;
auto w = dynamic_cast<QAbstractButton *>(buildDeviceIcon(d, this));
int spacerIndex = layout->indexOf(ui->hSpacer);
w->setProperty(devBrowserId, id);
layout->insertWidget(position, w);
bg->addButton(w);
if(position == -1)
if(position == -1) {
layout->insertWidget(spacerIndex, w);
list.append(w);
else
} else {
layout->insertWidget(position, w);
list.insert(position, w);
}

connect(w, &QAbstractButton::clicked, this, &DeviceBrowser::forwardRequestDeviceWithDirection);
}
Expand Down Expand Up @@ -230,6 +240,20 @@ DeviceIcon *DeviceBrowser::buildDeviceIcon(Device *d, QWidget *parent)
return devIcon;
}

// Used to display the scrollbar when needed and to maintain its size in the scroll area when not needed.
// We chose this approach because for the Qt::ScrollBarAsNeeded policy the size of the scrollball cannot be retained
// with Util::retainWidgetSizeWhenHidden because the resizing of the scrollbar is done dynamically (withoud using the
// show/hide default functions).
void DeviceBrowser::onScrollRangeChanged(int min, int max)
{
auto scrollArea = ui->scrollArea;
if(max > min) {
scrollArea->horizontalScrollBar()->setVisible(true);
} else {
scrollArea->horizontalScrollBar()->setVisible(false);
}
}

/*
auto &&is = ui->wInfoPageStack;
auto &&hc = is->getHomepageControls();
Expand Down
42 changes: 39 additions & 3 deletions core/src/deviceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <QTextBrowser>
#include <QThread>
#include <QtConcurrent/QtConcurrent>
#include <deviceiconbuilder.h>
#include <style.h>

#include <common/scopyconfig.h>
Expand All @@ -45,6 +46,7 @@
Q_LOGGING_CATEGORY(CAT_DEVICEIMPL, "Device")

namespace scopy {

DeviceImpl::DeviceImpl(QString param, PluginManager *p, QString category, QObject *parent)
: QObject{parent}
, m_param(param)
Expand Down Expand Up @@ -89,6 +91,7 @@ void DeviceImpl::loadPlugins()
loadIcons();
loadBadges();
loadPages();
loadConfigPage();
loadToolList();
if(m_plugins.isEmpty()) {
connbtn->hide();
Expand Down Expand Up @@ -156,17 +159,22 @@ void DeviceImpl::loadName()
void DeviceImpl::loadIcons()
{
m_icon = new QWidget();
QHBoxLayout *lay = new QHBoxLayout(m_icon);
m_icon->setFixedHeight(100);
m_icon->setFixedWidth(100);
new QHBoxLayout(m_icon);
for(auto &p : m_plugins) {
if(p->loadIcon()) {
m_icon->layout()->addWidget(p->icon());
lay->addWidget(p->icon());
return;
}
}

new QLabel("No PLUGIN", m_icon);
QLabel *header = new QLabel("No Plugin");
Style::setStyle(header, style::properties::label::deviceIcon, true);

QWidget *noPluginIcon =
DeviceIconBuilder().shape(DeviceIconBuilder::SQUARE).color("gray").headerWidget(header).build();
lay->addWidget(noPluginIcon);
}

void DeviceImpl::loadPages()
Expand Down Expand Up @@ -215,6 +223,18 @@ void DeviceImpl::loadPages()
}
}

void DeviceImpl::loadConfigPage()
{
m_configPage = new QTabWidget();
m_configPage->setTabPosition(QTabWidget::South);

for(auto &&p : plugins()) {
if(p->loadConfigPage()) {
m_configPage->addTab(p->configPage(), p->name());
}
}
}

void DeviceImpl::loadToolList()
{
for(auto &&p : m_plugins) {
Expand Down Expand Up @@ -435,6 +455,22 @@ QString DeviceImpl::param() { return m_param; }

QWidget *DeviceImpl::icon() { return m_icon; }

QPixmap DeviceImpl::iconPixmap()
{
QPixmap pixmap;
QLayoutItem *item = m_icon->layout()->itemAt(0);
if(!item || !item->widget()) {
return pixmap;
}
QLabel *iconLabel = dynamic_cast<QLabel *>(item->widget());
if(iconLabel) {
pixmap = iconLabel->grab();
}
return pixmap;
}

QWidget *DeviceImpl::configPage() { return m_configPage; }

QWidget *DeviceImpl::page() { return m_page; }

QList<ToolMenuEntry *> DeviceImpl::toolList()
Expand Down
Loading
Loading