Skip to content

Commit

Permalink
Tool browser: update style
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Popa <[email protected]>
  • Loading branch information
andrei47w committed Oct 23, 2024
1 parent 3d701d2 commit 7d8e693
Show file tree
Hide file tree
Showing 19 changed files with 257 additions and 166 deletions.
40 changes: 28 additions & 12 deletions core/src/browsemenu.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "browsemenu.h"
#include "style.h"

#include <QPushButton>
#include <stylehelper.h>
Expand Down Expand Up @@ -33,8 +34,12 @@ BrowseMenu::BrowseMenu(QWidget *parent)
m_toolMenu->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);

QPushButton *homeBtn = new QPushButton(tr("Home"), m_content);
homeBtn->setIcon(QIcon(":/gui/icons/scopy-default/icons/tool_home.svg"));
StyleHelper::ToolMenuHome(homeBtn, "toolMenuHome");
Style::setStyle(homeBtn, style::properties::button::toolButton);
homeBtn->setIcon(
QIcon(":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) + "/icons/tool_home.svg"));
homeBtn->setFixedHeight(Style::getDimension(json::global::unit_4));
homeBtn->setIconSize(QSize(32, 32));
homeBtn->setStyleSheet("text-align: left");
connect(homeBtn, &QPushButton::clicked, this, [=]() { Q_EMIT requestTool("home"); });

QWidget *saveLoadWidget = new QWidget(m_content);
Expand All @@ -43,22 +48,30 @@ BrowseMenu::BrowseMenu(QWidget *parent)
saveLoadWidget->layout()->setSpacing(0);
saveLoadWidget->layout()->setMargin(0);

QPushButton *saveBtn = createBtn("Save", ":/gui/icons/scopy-default/icons/save.svg", saveLoadWidget);
QPushButton *saveBtn = createBtn(
"Save", ":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) + "/icons/save.svg",
saveLoadWidget);
saveBtn->setCheckable(false);
connect(saveBtn, &QPushButton::clicked, this, &BrowseMenu::requestSave);

QPushButton *loadBtn = createBtn("Load", ":/gui/icons/scopy-default/icons/load.svg", saveLoadWidget);
QPushButton *loadBtn = createBtn(
"Load", ":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) + "/icons/load.svg",
saveLoadWidget);
loadBtn->setCheckable(false);
connect(loadBtn, &QPushButton::clicked, this, &BrowseMenu::requestLoad);

saveLoadWidget->layout()->addWidget(saveBtn);
saveLoadWidget->layout()->addWidget(loadBtn);

QPushButton *preferencesBtn =
createBtn("Preferences", ":/gui/icons/scopy-default/icons/preferences.svg", m_content);
QPushButton *preferencesBtn = createBtn("Preferences",
":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) +
"/icons/preferences.svg",
m_content);
connect(preferencesBtn, &QPushButton::clicked, this, [=]() { Q_EMIT requestTool("preferences"); });

QPushButton *aboutBtn = createBtn("About", ":/gui/icons/scopy-default/icons/info.svg", m_content);
QPushButton *aboutBtn = createBtn(
"About", ":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) + "/icons/info.svg",
m_content);
connect(aboutBtn, &QPushButton::clicked, this, [=]() { Q_EMIT requestTool("about"); });

QLabel *logo = createScopyLogo(m_content);
Expand Down Expand Up @@ -113,7 +126,7 @@ QPushButton *BrowseMenu::createBtn(QString name, QString iconPath, QWidget *pare
QPushButton *btn = new QPushButton(parent);
btn->setIcon(QIcon(iconPath));
btn->setText(tr(name.toStdString().c_str()));
StyleHelper::ToolMenuBtn(btn, name + "ToolMenuBtn");
Style::setStyle(btn, style::properties::button::toolButton);
return btn;
}

Expand All @@ -133,14 +146,17 @@ QWidget *BrowseMenu::createHeader(QWidget *parent)
headerLay->setSpacing(0);
headerLay->setMargin(0);
QPushButton *btnCollapseMini = new QPushButton(menuHeader);
StyleHelper::ToolMenuCollapseMini(btnCollapseMini, "CollapseMiniBtn");
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), Style::getDimension(json::global::unit_4));
headerLay->addWidget(btnCollapseMini);

m_btnCollapse = new QPushButton(menuHeader);
StyleHelper::ToolMenuCollapse(m_btnCollapse, "ToolMenuCollapse");
Style::setStyle(m_btnCollapse, style::properties::widget::toolMenuLogo);
Style::setStyle(m_btnCollapse, style::properties::widget::notInteractive);

headerLay->addWidget(m_btnCollapse);
connect(m_btnCollapse, &QPushButton::clicked, this, &BrowseMenu::toggleCollapsed);
connect(btnCollapseMini, &QPushButton::clicked, this, &BrowseMenu::toggleCollapsed);

return menuHeader;
Expand All @@ -149,7 +165,7 @@ QWidget *BrowseMenu::createHeader(QWidget *parent)
QLabel *BrowseMenu::createScopyLogo(QWidget *parent)
{
QLabel *logo = new QLabel(m_content);
StyleHelper::ScopyLogo(logo, "logo");
Style::setStyle(logo, style::properties::widget::logo);
return logo;
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/toolmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ToolMenu::ToolMenu(QWidget *parent)

m_layScroll = new QVBoxLayout();
m_layScroll->setMargin(0);
m_layScroll->setSpacing(10);
m_layScroll->setSpacing(20);

wScroll->setLayout(m_layScroll);
m_scroll->setWidgetResizable(true);
Expand Down
10 changes: 5 additions & 5 deletions core/src/toolmenuitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ToolMenuItem::ToolMenuItem(QString uuid, QString name, QString icon, QWidget *pa
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
QVBoxLayout *lay = new QVBoxLayout(this);
setLayout(lay);
setFixedHeight(50);
setFixedHeight(Style::getDimension(json::global::unit_3));
lay->setSpacing(0);
lay->setContentsMargins(0, 0, 0, 0);

Expand All @@ -45,13 +45,11 @@ ToolMenuItem::ToolMenuItem(QString uuid, QString name, QString icon, QWidget *pa
toolLay->addWidget(m_toolBtn, Qt::AlignLeft);
toolLay->addWidget(m_toolRunBtn);

setDynamicProperty(m_toolRunBtn, "stopButton", true);
m_toolRunBtn->setMaximumSize(32, 32);
m_toolBtn->setMinimumHeight(42);
m_toolRunBtn->setMaximumWidth(Style::getDimension(json::global::unit_3));

m_toolBtn->setIcon(QIcon::fromTheme(m_icon));
m_toolBtn->setCheckable(true);
m_toolBtn->setIconSize(QSize(32, 32));
m_toolBtn->setIconSize(QSize(Style::getDimension(json::global::unit_2_5), Style::getDimension(json::global::unit_2_5)));

m_toolRunBtn->setCheckable(true);
m_toolRunBtn->setText("");
Expand All @@ -66,7 +64,9 @@ ToolMenuItem::ToolMenuItem(QString uuid, QString name, QString icon, QWidget *pa
setDynamicProperty(this, "allowHover", false);
#else
m_toolBtn->setStyleSheet("text-align:left;");
Style::setStyle(m_toolRunBtn, style::properties::button::stopButton);
Style::setStyle(m_toolRunBtn, style::properties::widget::notInteractive);
Style::setStyle(m_toolBtn, style::properties::button::toolButton);

enableDoubleClick(true);
#endif
Expand Down
1 change: 1 addition & 0 deletions core/src/toolmenumanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void ToolMenuManager::addMenuItem(QString deviceId, QString devName, QList<ToolM
QString param;
MenuSectionCollapseWidget *devSection = new MenuSectionCollapseWidget(
devName, MenuCollapseSection::MHCW_ARROW, MenuCollapseSection::MHW_COMPOSITEWIDGET, m_toolMenu);
devSection->contentLayout()->setSpacing(0);
QLayoutItem *sItem = devSection->layout()->itemAt(0);
if(sItem) {
MenuSectionWidget *sWidget = dynamic_cast<MenuSectionWidget *>(sItem->widget());
Expand Down
7 changes: 0 additions & 7 deletions gui/include/gui/stylehelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ class SCOPY_GUI_EXPORT StyleHelper : public QObject
static void IIOCompactLabel(QLabel *label, QString objectName = "");
static void GrayButton(QPushButton *btn, QString objectName = "");

static void RoundedCornersWidget(QWidget *w, QString objectName = "");
static void ToolMenuBtn(QPushButton *btn, QString objectName = "");
static void ToolMenuHome(QPushButton *btn, QString objectName = "");
static void ToolMenuCollapseMini(QPushButton *btn, QString objectName = "");
static void ToolMenuCollapse(QPushButton *btn, QString objectName = "");
static void ScopyLogo(QLabel *label, QString objectName = "");

private:
QMap<QString, QString> colorMap;
static StyleHelper *pinstance_;
Expand Down
Loading

0 comments on commit 7d8e693

Please sign in to comment.