Skip to content

Commit

Permalink
core/toolmenumanager: Highlight device header on hover and selection.
Browse files Browse the repository at this point in the history
Signed-off-by: andreidanila1 <[email protected]>
  • Loading branch information
andreidanila1 committed Nov 28, 2024
1 parent 8082ef3 commit 4f24239
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/src/toolmenumanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ MenuSectionCollapseWidget *ToolMenuManager::createMenuSectionItem(const DeviceIn
if(collapseHeader) {
initHeaderWidget(type, collapseHeader, dInfo);
Style::setStyle(collapseHeader, style::properties::widget::bottomBorder);
Style::setStyle(collapseHeader, style::properties::widget::deviceHeaderWidget, "idle");
}
section->setCollapsed(false);
section->hide();
Expand All @@ -326,6 +327,7 @@ void ToolMenuManager::initToolMenuHeaderWidget(MenuCollapseHeader *header, const
{
bool isConnected = m_connectedDev.contains(dInfo.id);
ToolMenuHeaderWidget *thw = dynamic_cast<ToolMenuHeaderWidget *>(header->headerWidget());
QButtonGroup *menuBtnGroup = m_toolMenu->btnGroup();
if(!thw) {
return;
}
Expand All @@ -335,7 +337,15 @@ void ToolMenuManager::initToolMenuHeaderWidget(MenuCollapseHeader *header, const
thw->layout()->setContentsMargins(Style::getDimension(json::global::unit_1), 0, 0, 0);
Style::setStyle(header, style::properties::widget::ledBorder, isConnected);

connect(thw->deviceBtn(), &QPushButton::pressed, this, [this, dInfo]() { Q_EMIT requestDevicePage(dInfo.id); });
menuBtnGroup->addButton(thw->deviceBtn());
connect(thw->deviceBtn(), &QPushButton::toggled, this, [=](bool en) {
if(en) {
Style::setStyle(header, style::properties::widget::deviceHeaderWidget, "selected");
Q_EMIT requestDevicePage(dInfo.id);
} else {
Style::setStyle(header, style::properties::widget::deviceHeaderWidget, "idle");
}
});
connect(this, &ToolMenuManager::connState, thw, &ToolMenuHeaderWidget::connState);
}

Expand Down
1 change: 1 addition & 0 deletions gui/src/widgets/toolmenuheaderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ToolMenuHeaderWidget::ToolMenuHeaderWidget(QString title, QWidget *parent)
hLay->setSpacing(10);

m_deviceBtn = new QPushButton(this);
m_deviceBtn->setCheckable(true);

QWidget *titleWidget = new QWidget(this);
QVBoxLayout *titleLay = new QVBoxLayout(titleWidget);
Expand Down

0 comments on commit 4f24239

Please sign in to comment.