Skip to content

Commit

Permalink
gui: fixed info button and menuControlButton
Browse files Browse the repository at this point in the history
- info button and m2k top buttons new look
- menuControlButton fix bad signal on double click

Signed-off-by: Andrei Popa <[email protected]>
  • Loading branch information
andrei47w committed Dec 19, 2024
1 parent 39b0f90 commit 3b494ff
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 33 deletions.
3 changes: 3 additions & 0 deletions gui/include/gui/widgets/toolbuttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ class SCOPY_GUI_EXPORT InfoBtn : public QPushButton
QPushButton *getDocumentationButton();
void generateInfoPopup(QWidget *parent);

virtual bool eventFilter(QObject *watched, QEvent *event);

private:
PopupWidget *m_popupWidget;
bool m_hasTutorial;
QString m_iconPath;
};

class SCOPY_GUI_EXPORT RunBtn : public QPushButton
Expand Down
2 changes: 1 addition & 1 deletion gui/src/widgets/menucontrolbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void MenuControlButton::setDoubleClickToOpenMenu(bool b)
dblClickToOpenMenu = connect(this, &MenuControlButton::doubleClicked, this, [=]() {
setChecked(true);
if(m_btn->isVisible()) {
m_btn->toggle();
m_btn->click();
}
});
} else {
Expand Down
30 changes: 23 additions & 7 deletions gui/src/widgets/toolbuttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,32 @@ InfoBtn::InfoBtn(QWidget *parent, bool hasTutorial)
, m_hasTutorial(hasTutorial)
{

QString iconPath = ":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) + "/icons/info.svg";
setIcon(Style::getPixmap(iconPath, Style::getColor(json::theme::content_default)));

connect(this, &QPushButton::toggled, this, [=](bool toggle) {
const char *color = toggle ? json::theme::content_inverse : json::theme::content_default;
setIcon(Style::getPixmap(iconPath, Style::getColor(color)));
});
m_iconPath = ":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) + "/icons/info.svg";
setIcon(Style::getPixmap(m_iconPath, Style::getColor(json::theme::content_default)));

setCheckable(false);
Style::setStyle(this, style::properties::button::squareIconButton);
installEventFilter(this);
}

bool InfoBtn::eventFilter(QObject *watched, QEvent *event)
{
QPushButton *button = qobject_cast<QPushButton *>(watched);
if(!button) {
return false;
}

if(event->type() == QEvent::Enter) {
setIcon(Style::getPixmap(m_iconPath, Style::getColor(json::theme::content_inverse)));
return true;
}

if(event->type() == QEvent::Leave) {
setIcon(Style::getPixmap(m_iconPath, Style::getColor(json::theme::content_default)));
return true;
}

return false;
}

bool InfoBtn::hasTutorial() { return m_hasTutorial; }
Expand Down
2 changes: 1 addition & 1 deletion gui/style/json/Harmonic dark.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"icon_theme_folder": "scopy-default",
"pixmap_color": "#FFFFFF",
"interactive_subtle_idle": "#9FA4AD",
"interactive_subtle_idle": "#797d85",
"interactive_subtle_hover": "#B7BBC3",
"interactive_subtle_pressed": "#c5c9d1",
"interactive_subtle_disabled": "#4B545D",
Expand Down
27 changes: 27 additions & 0 deletions gui/style/qss/properties/button/darkGrayButton.qss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
QPushButton[&&property&&=true] {
text-align:left;
height: &unit_3&;
background-color: #80&color_inverse_hexcode&;;
color: &white&;
border-radius: &radius_1&;
text-align:center;
}
QPushButton[&&property&&=true]:hover {
background-color: #C8&color_inverse_hexcode&;
color: &white&;
}

QPushButton[&&property&&=true]:pressed {
background-color: #C8&color_inverse_hexcode&;
color: &white&;
}

QPushButton[&&property&&=true]:checked {
background-color: #C8&color_inverse_hexcode&;
color: &white&;
}

QPushButton[&&property&&=true]:disabled {
background-color: #C8&color_inverse_hexcode&;
color: &white&;
}
5 changes: 2 additions & 3 deletions plugins/m2k/m2k-gui/src/linked_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ using namespace scopy;
LinkedButton::LinkedButton(QWidget *parent)
: QPushButton(parent)
{
setDynamicProperty(this, "info_button", true);

Style::setStyle(this, style::properties::button::darkGrayButton, true, true);
this->setIcon(Style::getPixmap(":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) +
"/icons/info.svg"));
this->setIconSize(QSize(32, 32));
this->setIconSize(QSize(40, 40));

this->setToolTip("See more info");

Expand Down
5 changes: 5 additions & 0 deletions plugins/m2k/src/old/logicanalyzer/logic_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,11 @@ void LogicAnalyzer::connectSignalsAndSlots()
updateStackDecoderButton();
});

Style::setStyle(ui->btnGroupChannels, style::properties::button::darkGrayButton, true, true);
ui->btnGroupChannels->setFixedHeight(40);

Style::setStyle(ui->printBtn, style::properties::button::darkGrayButton, true, true);
ui->printBtn->setFixedHeight(40);
connect(ui->printBtn, &QPushButton::clicked, [=]() { m_plot.printWithNoBackground("Logic Analyzer"); });

connect(ui->decoderTableView, &DecoderTable::clicked, [=](const QModelIndex &index) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/m2k/src/old/network_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,8 @@ NetworkAnalyzer::NetworkAnalyzer(libm2k::context::M2k *m2k, QString uri, Filter

wheelEventGuard->installEventRecursively(ui->mainWidget);

Style::setStyle(ui->btnPrint, style::properties::button::darkGrayButton, true, true);
ui->btnPrint->setFixedHeight(40);
connect(ui->btnPrint, &QPushButton::clicked, [=]() {
QWidget *widget = ui->stackedWidget->currentWidget();
QImage img(widget->width(), widget->height(), QImage::Format_ARGB32);
Expand Down
4 changes: 4 additions & 0 deletions plugins/m2k/src/old/oscilloscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,8 @@ Oscilloscope::Oscilloscope(libm2k::context::M2k *m2k, QString uri, Filter *filt,

readPreferences();

Style::setStyle(ui->printBtn, style::properties::button::darkGrayButton, true, true);
ui->printBtn->setFixedHeight(40);
connect(ui->printBtn, &QPushButton::clicked, [=]() { plot.printWithNoBackground(api->objectName()); });

// workaround for a bug that selected channel settings for disabled channels
Expand Down Expand Up @@ -2096,6 +2098,8 @@ void Oscilloscope::create_add_channel_panel()

tabWidget->addTab(logic, tr("Logic"));

Style::setStyle(ui->mixedSignalBtn, style::properties::button::darkGrayButton, true, true);
ui->mixedSignalBtn->setFixedHeight(40);
connect(ui->mixedSignalBtn, &QPushButton::clicked, [=]() {
if(!m_mixedSignalViewEnabled) {
ui->btnAddMath->click();
Expand Down
7 changes: 7 additions & 0 deletions plugins/m2k/src/old/patterngenerator/pattern_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include <QDebug>
#include <QDockWidget>
#include <style.h>
#include <stylehelper.h>

#include <libm2k/m2kexceptions.hpp>
Expand Down Expand Up @@ -923,6 +924,12 @@ void PatternGenerator::connectSignalsAndSlots()
m_plotCurves[m_selectedChannel]->setName(text);
});

Style::setStyle(m_ui->btnGroupChannels, style::properties::button::darkGrayButton, true, true);
m_ui->btnGroupChannels->setFixedHeight(40);

Style::setStyle(m_ui->printBtn, style::properties::button::darkGrayButton, true, true);
m_ui->printBtn->setFixedHeight(40);

connect(m_ui->printBtn, &QPushButton::clicked, [=]() { m_plot.printWithNoBackground("Pattern Generator"); });

connect(m_singleTimer, &QTimer::timeout, [=]() {
Expand Down
2 changes: 2 additions & 0 deletions plugins/m2k/src/old/spectrum_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#include "m2kpluginExceptionHandler.h"

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

#include <libm2k/contextbuilder.hpp>
#include <libm2k/m2kexceptions.hpp>
Expand Down Expand Up @@ -646,6 +647,7 @@ SpectrumAnalyzer::SpectrumAnalyzer(libm2k::context::M2k *m2k, QString uri, Filte
connect(ui->rightMenu, &MenuHAnim::finished, this, &SpectrumAnalyzer::rightMenuFinished);
menuOrder.push_back(ui->btnSweep);

Style::setStyle(ui->btnPrint, style::properties::button::darkGrayButton, true, true);
connect(ui->btnPrint, &QPushButton::clicked,
[=]() { fft_plot->printWithNoBackground(api->objectName(), false); });

Expand Down
3 changes: 0 additions & 3 deletions plugins/m2k/ui/logic_analyzer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@
<property name="menu_blue_button" stdset="0">
<bool>true</bool>
</property>
<property name="blue_button" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down
3 changes: 0 additions & 3 deletions plugins/m2k/ui/network_analyzer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@
<property name="menu_blue_button" stdset="0">
<bool>true</bool>
</property>
<property name="blue_button" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down
6 changes: 0 additions & 6 deletions plugins/m2k/ui/oscilloscope.ui
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@
<height>10</height>
</size>
</property>
<property name="blue_button" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand All @@ -148,9 +145,6 @@
<string>Enable Mixed
Signal View</string>
</property>
<property name="blue_button" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down
6 changes: 0 additions & 6 deletions plugins/m2k/ui/pattern_generator.ui
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@
<height>10</height>
</size>
</property>
<property name="blue_button" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand All @@ -145,9 +142,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="blue_button" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down
3 changes: 0 additions & 3 deletions plugins/m2k/ui/spectrum_analyzer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@
<height>10</height>
</size>
</property>
<property name="blue_button" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down

0 comments on commit 3b494ff

Please sign in to comment.