diff --git a/core/src/emuwidget.cpp b/core/src/emuwidget.cpp index 52fa476d2c..5ef4117a9d 100644 --- a/core/src/emuwidget.cpp +++ b/core/src/emuwidget.cpp @@ -338,9 +338,11 @@ void EmuWidget::setEnableDemo(bool en) void EmuWidget::browseFile(QLineEdit *lineEditPath) { - QString filePath = - QFileDialog::getOpenFileName(this, "Open a file", "directoryToOpen", - "All (*);;XML Files (*.xml);;Text Files (*.txt);;BIN Files (*.bin)"); + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); + QString filePath = QFileDialog::getOpenFileName( + this, "Open a file", "directoryToOpen", + "All (*);;XML Files (*.xml);;Text Files (*.txt);;BIN Files (*.bin)", nullptr, + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); lineEditPath->setText(filePath); m_enDemoBtn->setFocus(); } diff --git a/core/src/scopymainwindow.cpp b/core/src/scopymainwindow.cpp index f3c6b3f016..8497b6a395 100644 --- a/core/src/scopymainwindow.cpp +++ b/core/src/scopymainwindow.cpp @@ -256,16 +256,22 @@ void ScopyMainWindow::deviceAutoconnect() void ScopyMainWindow::save() { + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString selectedFilter; - QString fileName = QFileDialog::getSaveFileName(this, tr("Save"), "", "", &selectedFilter); + QString fileName = QFileDialog::getSaveFileName( + this, tr("Save"), "", "", &selectedFilter, + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); save(fileName); ScopyTitleManager::setIniFileName(fileName); } void ScopyMainWindow::load() { + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString selectedFilter; - QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), "", "", &selectedFilter); + QString fileName = QFileDialog::getOpenFileName( + this, tr("Open"), "", "", &selectedFilter, + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); load(fileName); ScopyTitleManager::setIniFileName(fileName); } diff --git a/core/src/scopypreferencespage.cpp b/core/src/scopypreferencespage.cpp index c8bf42f718..d649aa0978 100644 --- a/core/src/scopypreferencespage.cpp +++ b/core/src/scopypreferencespage.cpp @@ -242,7 +242,6 @@ QWidget *ScopyPreferencesPage::buildGeneralPreferencesPage() lay->addWidget(generalWidget); lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); - generalSection->contentLayout()->addWidget(buildSaveSessionPreference()); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( p, "general_save_attached", "Save/Load tool attached state", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( @@ -266,9 +265,6 @@ QWidget *ScopyPreferencesPage::buildGeneralPreferencesPage() p, "iiowidgets_use_lazy_loading", "Use Lazy Loading", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( p, "general_use_native_dialogs", "Use native dialogs", generalSection)); - QWidget *autoConnectCb = PreferencesHelper::addPreferenceCheckBox( - p, "autoconnect_previous", "Auto-connect to previous session", generalSection); - generalSection->contentLayout()->addWidget(autoConnectCb); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( p, "font_scale", "Font scale (EXPERIMENTAL)", {"1", "1.15", "1.3", "1.45", "1.6", "1.75", "1.9"}, generalSection)); @@ -283,20 +279,30 @@ QWidget *ScopyPreferencesPage::buildGeneralPreferencesPage() p, "general_scan_for_devices", "Regularly scan for new devices", generalSection)); // Auto-connect - m_autoConnectWidget = new MenuSectionCollapseWidget("Session devices", MenuCollapseSection::MHCW_NONE, + m_autoConnectWidget = new MenuSectionCollapseWidget("Session ", MenuCollapseSection::MHCW_NONE, MenuCollapseSection::MHW_COMPOSITEWIDGET, page); MenuCollapseHeader *autoConnectHeader = dynamic_cast(m_autoConnectWidget->collapseSection()->header()); - autoConnectHeader->headerWidget()->layout()->addWidget( - new QLabel("At each auto-connect session, it will try to connect to the checked devices")); m_autoConnectWidget->contentLayout()->setSpacing(10); lay->addWidget(m_autoConnectWidget); lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); + QWidget *autoConnectCb = PreferencesHelper::addPreferenceCheckBox( + p, "autoconnect_previous", "Auto-connect to previous session", generalSection); + m_autoConnectWidget->contentLayout()->addWidget(autoConnectCb); + + m_autoConnectWidget->contentLayout()->addWidget(buildSaveSessionPreference()); + m_devRefresh = new QPushButton("Refresh", m_autoConnectWidget); m_devRefresh->setMaximumWidth(Style::getDimension(json::global::unit_5)); - Style::setStyle(m_devRefresh, style::properties::button::basicButton); - m_autoConnectWidget->add(m_devRefresh); + Style::setStyle(m_devRefresh, style::properties::button::borderButton); + QWidget *refreshWidget = new QWidget(m_autoConnectWidget); + QHBoxLayout *refreshLayout = new QHBoxLayout(refreshWidget); + refreshLayout->setMargin(0); + refreshLayout->addWidget( + new QLabel("At each auto-connect session, it will try to connect to the checked devices")); + refreshLayout->addWidget(m_devRefresh); + m_autoConnectWidget->contentLayout()->addWidget(refreshWidget); connect(m_devRefresh, &QPushButton::pressed, this, &ScopyPreferencesPage::refreshDevicesPressed); diff --git a/gui/include/gui/stylehelper.h b/gui/include/gui/stylehelper.h index 967c512e1c..5a5141e9e2 100644 --- a/gui/include/gui/stylehelper.h +++ b/gui/include/gui/stylehelper.h @@ -89,14 +89,9 @@ class SCOPY_GUI_EXPORT StyleHelper : public QObject static void MeasurementSelectorItemWidget(QString iconPath, MeasurementSelectorItem *w, QString objectName = ""); static void HoverWidget(QWidget *w, bool draggable = false, QString objectName = ""); - static void TransparentWidget(QWidget *w, QString objectName = ""); static void HoverToolTip(QWidget *w, QString info, QString objectName = ""); static void NoBackgroundIconButton(QPushButton *w, QIcon icon, QString objectName = ""); static void BrowseButton(QPushButton *btn, QString objectName = ""); - static void OrangeWidget(QWidget *w, QString objectName = ""); - static void ActiveStoredLabel(QLabel *w, QString objectName = ""); - static void FaultsFrame(QFrame *w, QString objectName = ""); - static void FaultsExplanation(QWidget *w, QString objectName = ""); private: static StyleHelper *pinstance_; diff --git a/gui/include/gui/widgets/menulineedit.h b/gui/include/gui/widgets/menulineedit.h index 6739558d33..4c9d3c64e7 100644 --- a/gui/include/gui/widgets/menulineedit.h +++ b/gui/include/gui/widgets/menulineedit.h @@ -40,7 +40,6 @@ class SCOPY_GUI_EXPORT MenuLineEdit : public QWidget virtual ~MenuLineEdit(); QLineEdit *edit(); - void applyStylesheet(); private: QLineEdit *m_edit; diff --git a/gui/include/gui/widgets/toolbuttons.h b/gui/include/gui/widgets/toolbuttons.h index d515446dd3..09127e38dd 100644 --- a/gui/include/gui/widgets/toolbuttons.h +++ b/gui/include/gui/widgets/toolbuttons.h @@ -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 diff --git a/gui/src/plotnavigator.cpp b/gui/src/plotnavigator.cpp index 3ce7b6d13f..07ea822c3c 100644 --- a/gui/src/plotnavigator.cpp +++ b/gui/src/plotnavigator.cpp @@ -106,7 +106,6 @@ void PlotNavigator::initResetButton() m_resetButton = new QPushButton(m_plot->canvas()); QIcon icon(QPixmap(":/gui/icons/search_crossed.svg")); m_resetButton->setFlat(true); - StyleHelper::TransparentWidget(m_resetButton); m_resetButton->setIcon(icon); m_resetButton->hide(); diff --git a/gui/src/plotwidget.cpp b/gui/src/plotwidget.cpp index 5dd81cee80..b71106644f 100644 --- a/gui/src/plotwidget.cpp +++ b/gui/src/plotwidget.cpp @@ -78,7 +78,6 @@ PlotWidget::PlotWidget(QWidget *parent) setupPlotButtonManager(); m_plot->canvas()->installEventFilter(this); - Style::setBackgroundColor(m_plot, QString("transparent")); Style::setBackgroundColor(m_plot->canvas(), json::theme::background_plot, true); } diff --git a/gui/src/printplotmanager.cpp b/gui/src/printplotmanager.cpp index f135373184..8953daf65f 100644 --- a/gui/src/printplotmanager.cpp +++ b/gui/src/printplotmanager.cpp @@ -25,6 +25,7 @@ #include #include #include +#include using namespace scopy; @@ -35,9 +36,12 @@ PrintPlotManager::PrintPlotManager(QObject *parent) void PrintPlotManager::printPlots(QList plotList, QString toolName) { // select folder where to save - QString folderPath = QFileDialog::getExistingDirectory( - nullptr, "Select Folder", "", - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog); + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); + QString folderPath = QFileDialog::getExistingDirectory(nullptr, "Select Folder", "", + (useNativeDialogs ? QFileDialog::Options() + : QFileDialog::ShowDirsOnly | + QFileDialog::DontResolveSymlinks | + QFileDialog::DontUseNativeDialog)); if(!folderPath.isEmpty()) { // use current date and tool name to crete the file name diff --git a/gui/src/stylehelper.cpp b/gui/src/stylehelper.cpp index 0eee1e32c0..1c021c2a4b 100644 --- a/gui/src/stylehelper.cpp +++ b/gui/src/stylehelper.cpp @@ -303,14 +303,6 @@ void StyleHelper::HoverWidget(QWidget *w, bool draggable, QString objectName) w->setStyleSheet(style); } -void StyleHelper::TransparentWidget(QWidget *w, QString objectName) -{ - if(!objectName.isEmpty()) - w->setObjectName(objectName); - QString style = QString(R"css(background-color: transparent;)css"); - w->setStyleSheet(style); -} - void StyleHelper::HoverToolTip(QWidget *w, QString info, QString objectName) { if(!objectName.isEmpty()) @@ -362,61 +354,4 @@ void StyleHelper::BrowseButton(QPushButton *btn, QString objectName) btn->setFixedSize(size, size); } -// TODO: move these functions to SWIOT specicfic style structure -// SWIOT ------------------------------------------------------- -void StyleHelper::OrangeWidget(QWidget *w, QString objectName) -{ - if(!objectName.isEmpty()) - w->setObjectName(objectName); - QString style = QString(R"css( - QWidget{ - color:&&orange&& - } - )css"); - style.replace("&&orange&&", Style::getAttribute(json::theme::interactive_primary_idle)); - w->setStyleSheet(style); -} - -void StyleHelper::ActiveStoredLabel(QLabel *w, QString objectName) -{ - if(!objectName.isEmpty()) - w->setObjectName(objectName); - QString style = QString(R"css( - QLabel{ - background-color: transparent; width: 40px; height: 14px; border: 2px solid ; border-radius: 8px; border-color: &&content_default&&; - } - QLabel[high=false] { border-color: &&content_default&&; background-color: transparent; } - QLabel[high=true] { border-color: &&content_default&&; background-color: &&content_default&&; } - )css"); - style.replace("&&content_default&&", Style::getAttribute(json::theme::content_default)); - w->setStyleSheet(style); -} - -void StyleHelper::FaultsFrame(QFrame *w, QString objectName) -{ - if(!objectName.isEmpty()) - w->setObjectName(objectName); - QString style = QString(R"css( - QFrame[pressed=true] { background-color: &&elementHighlight&&; border: 1px solid &&elementBackground&&; border-radius:5px; } - )css"); - style.replace("&&elementHighlight&&", Style::getAttribute(json::theme::content_subtle)); - style.replace("&&elementBackground&&", Style::getAttribute(json::theme::background_primary)); - - w->setStyleSheet(style); -} - -void StyleHelper::FaultsExplanation(QWidget *w, QString objectName) -{ - if(!objectName.isEmpty()) - w->setObjectName(objectName); - QString style = QString(R"css( - QWidget[highlighted=true]{color:&&content_default&&;} - QWidget{color:&&defaultColor&&;} - )css"); - style.replace("&&defaultColor&&", Style::getAttribute(json::theme::interactive_subtle_idle)); - style.replace("&&content_default&&", Style::getAttribute(json::theme::content_default)); - w->setStyleSheet(style); -} -// SWIOT ------------------------------------------------------- - #include "moc_stylehelper.cpp" diff --git a/gui/src/tooltemplate.cpp b/gui/src/tooltemplate.cpp index 8f991db261..331f39cfe8 100644 --- a/gui/src/tooltemplate.cpp +++ b/gui/src/tooltemplate.cpp @@ -52,7 +52,6 @@ ToolTemplate::ToolTemplate(QWidget *parent) m_rightStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_topStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_bottomStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - Style::setBackgroundColor(m_ui->leftContainer, QString("transparent")); Style::setBackgroundColor(m_ui->topContainerMenuControl, json::theme::background_primary); } diff --git a/gui/src/widgets/cursorsettings.cpp b/gui/src/widgets/cursorsettings.cpp index 55ca6b9fc9..63ac43077c 100644 --- a/gui/src/widgets/cursorsettings.cpp +++ b/gui/src/widgets/cursorsettings.cpp @@ -40,7 +40,6 @@ CursorSettings::~CursorSettings() {} void CursorSettings::initUI() { setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - StyleHelper::TransparentWidget(this, "cursorSettings"); setFixedWidth(200); layout = new QVBoxLayout(this); layout->setMargin(0); diff --git a/gui/src/widgets/menucontrolbutton.cpp b/gui/src/widgets/menucontrolbutton.cpp index 20e6c849af..ee27e0d49c 100644 --- a/gui/src/widgets/menucontrolbutton.cpp +++ b/gui/src/widgets/menucontrolbutton.cpp @@ -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 { diff --git a/gui/src/widgets/menulineedit.cpp b/gui/src/widgets/menulineedit.cpp index 1dd943f52a..8c0e7d17f2 100644 --- a/gui/src/widgets/menulineedit.cpp +++ b/gui/src/widgets/menulineedit.cpp @@ -36,17 +36,11 @@ MenuLineEdit::MenuLineEdit(QWidget *parent) m_edit = new QLineEdit(this); lay->addWidget(m_edit); - applyStylesheet(); + Style::setStyle(m_edit, style::properties::lineedit::menuLineEdit); } MenuLineEdit::~MenuLineEdit() {} QLineEdit *MenuLineEdit::edit() { return m_edit; } -void MenuLineEdit::applyStylesheet() -{ - Style::setStyle(m_edit, style::properties::lineedit::menuLineEdit); - Style::setBackgroundColor(this, QString("transparent")); -} - #include "moc_menulineedit.cpp" diff --git a/gui/src/widgets/plotcursorreadouts.cpp b/gui/src/widgets/plotcursorreadouts.cpp index 785c02df5f..0727289f3b 100644 --- a/gui/src/widgets/plotcursorreadouts.cpp +++ b/gui/src/widgets/plotcursorreadouts.cpp @@ -19,6 +19,7 @@ * */ +#include #include using namespace scopy; @@ -143,7 +144,7 @@ void PlotCursorReadouts::initContent() x_contents_lay->addWidget(invDeltaX_val, 3, 1); for(auto w : this->findChildren()) { - StyleHelper::TransparentWidget(w); + Style::setBackgroundColor(w, QString("transparent"), true); } } diff --git a/gui/src/widgets/scopystatusbar.cpp b/gui/src/widgets/scopystatusbar.cpp index fcd0250b22..86fd5a517e 100644 --- a/gui/src/widgets/scopystatusbar.cpp +++ b/gui/src/widgets/scopystatusbar.cpp @@ -61,7 +61,6 @@ void ScopyStatusBar::initUi() m_stackedWidget = new QStackedWidget(this); layout()->addWidget(m_stackedWidget); - Style::setStyle(this, style::properties::widget::basicComponent); hide(); } diff --git a/gui/src/widgets/toolbuttons.cpp b/gui/src/widgets/toolbuttons.cpp index a49e775773..14be8d5eba 100644 --- a/gui/src/widgets/toolbuttons.cpp +++ b/gui/src/widgets/toolbuttons.cpp @@ -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(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; } diff --git a/gui/style/json/Harmonic dark.json b/gui/style/json/Harmonic dark.json index b4d1c94386..ccacf92592 100644 --- a/gui/style/json/Harmonic dark.json +++ b/gui/style/json/Harmonic dark.json @@ -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", diff --git a/gui/style/qss/properties/button/darkGrayButton.qss b/gui/style/qss/properties/button/darkGrayButton.qss new file mode 100644 index 0000000000..2e4fc8f32e --- /dev/null +++ b/gui/style/qss/properties/button/darkGrayButton.qss @@ -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&; +} diff --git a/plugins/datalogger/src/menus/dataloggingmenu.cpp b/plugins/datalogger/src/menus/dataloggingmenu.cpp index ad49592bf0..e029ffdcc3 100644 --- a/plugins/datalogger/src/menus/dataloggingmenu.cpp +++ b/plugins/datalogger/src/menus/dataloggingmenu.cpp @@ -27,6 +27,7 @@ #include #include #include +#include using namespace scopy; using namespace datamonitor; @@ -130,10 +131,11 @@ void DataLoggingMenu::chooseFile() // turn off live data logging when switching files liveDataLoggingButton->onOffswitch()->setChecked(false); + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString selectedFilter; filename = QFileDialog::getSaveFileName( this, tr("Export"), "", tr("Comma-separated values files (*.csv);;All Files(*)"), &selectedFilter, - QFileDialog::Options(QFileDialog::DontUseNativeDialog)); + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); dataLoggingFilePath->getLineEdit()->setText(filename); } diff --git a/plugins/m2k/m2k-gui/include/m2k-gui/printableplot.h b/plugins/m2k/m2k-gui/include/m2k-gui/printableplot.h index e3d9486087..b04488b943 100644 --- a/plugins/m2k/m2k-gui/include/m2k-gui/printableplot.h +++ b/plugins/m2k/m2k-gui/include/m2k-gui/printableplot.h @@ -41,7 +41,6 @@ class SCOPY_M2K_GUI_EXPORT PrintablePlot : public BasicPlot PrintablePlot(QWidget *parent); void dropBackground(bool drop); - void setUseNativeDialog(bool nativeDialog); public Q_SLOTS: void printPlot(const QString &toolName = ""); @@ -49,7 +48,6 @@ public Q_SLOTS: private: QwtPlotRenderer d_plotRenderer; QwtLegend *legendDisplay; - bool d_useNativeDialog; }; } // namespace scopy diff --git a/plugins/m2k/m2k-gui/src/linked_button.cpp b/plugins/m2k/m2k-gui/src/linked_button.cpp index 32136dd30b..66ed288a98 100644 --- a/plugins/m2k/m2k-gui/src/linked_button.cpp +++ b/plugins/m2k/m2k-gui/src/linked_button.cpp @@ -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"); diff --git a/plugins/m2k/m2k-gui/src/printableplot.cpp b/plugins/m2k/m2k-gui/src/printableplot.cpp index 72a1e8a92d..392859344d 100644 --- a/plugins/m2k/m2k-gui/src/printableplot.cpp +++ b/plugins/m2k/m2k-gui/src/printableplot.cpp @@ -23,13 +23,13 @@ #include #include #include +#include using namespace scopy; PrintablePlot::PrintablePlot(QWidget *parent) : BasicPlot(parent) , d_plotRenderer(new QwtPlotRenderer(this)) - , d_useNativeDialog(true) { dropBackground(true); } @@ -40,8 +40,6 @@ void PrintablePlot::dropBackground(bool drop) d_plotRenderer.setDiscardFlag(QwtPlotRenderer::DiscardCanvasBackground, drop); } -void PrintablePlot::setUseNativeDialog(bool nativeDialog) { d_useNativeDialog = nativeDialog; } - void PrintablePlot::printPlot(const QString &toolName) { legendDisplay = new QwtLegend(this); @@ -71,10 +69,11 @@ void PrintablePlot::printPlot(const QString &toolName) } } + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString selectedFilter = QString("PDF ") + tr("Documents") + " (*.pdf)"; fileName = QFileDialog::getSaveFileName( nullptr, tr("Export File Name"), fileName, filter.join(";;"), &selectedFilter, - (d_useNativeDialog ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); if(fileName.split(".").size() <= 1) { // file name w/o extension. Let's append it diff --git a/plugins/m2k/src/old/logicanalyzer/decoder_table.cpp b/plugins/m2k/src/old/logicanalyzer/decoder_table.cpp index 89bdf3ee0f..5acd4a6a89 100644 --- a/plugins/m2k/src/old/logicanalyzer/decoder_table.cpp +++ b/plugins/m2k/src/old/logicanalyzer/decoder_table.cpp @@ -95,8 +95,10 @@ void DecoderTable::exportData() filter += QString(tr("Comma-separated row per sample (*.csv)")); filter += QString(tr("Tab-delimited row per annotation (*.txt)")); - QString fileName = QFileDialog::getSaveFileName(this, tr("Export"), "", filter.join(";;"), &selectedFilter, - QFileDialog::DontUseNativeDialog); + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); + QString fileName = QFileDialog::getSaveFileName( + this, tr("Export"), "", filter.join(";;"), &selectedFilter, + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); if(fileName.isEmpty()) { return; diff --git a/plugins/m2k/src/old/logicanalyzer/logic_analyzer.cpp b/plugins/m2k/src/old/logicanalyzer/logic_analyzer.cpp index df05a2638b..bc3b7f76b3 100644 --- a/plugins/m2k/src/old/logicanalyzer/logic_analyzer.cpp +++ b/plugins/m2k/src/old/logicanalyzer/logic_analyzer.cpp @@ -277,12 +277,6 @@ LogicAnalyzer::~LogicAnalyzer() delete ui; } -void LogicAnalyzer::setNativeDialogs(bool nativeDialogs) -{ - M2kTool::setNativeDialogs(nativeDialogs); - m_plot.setUseNativeDialog(nativeDialogs); -} - void LogicAnalyzer::setData(const uint16_t *const data, int size) { @@ -1772,6 +1766,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) { @@ -2820,9 +2819,10 @@ void LogicAnalyzer::exportData() filter += QString(tr("Value Change Dump(*.vcd)")); filter += QString(tr("All Files(*)")); + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString fileName = QFileDialog::getSaveFileName( this, tr("Export"), "", filter.join(";;"), &selectedFilter, - (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); if(fileName.isEmpty()) { return; diff --git a/plugins/m2k/src/old/logicanalyzer/logic_analyzer.h b/plugins/m2k/src/old/logicanalyzer/logic_analyzer.h index 8ca66e6f3f..1e6adbbdb8 100644 --- a/plugins/m2k/src/old/logicanalyzer/logic_analyzer.h +++ b/plugins/m2k/src/old/logicanalyzer/logic_analyzer.h @@ -80,7 +80,6 @@ class LogicAnalyzer : public M2kTool explicit LogicAnalyzer(libm2k::context::M2k *m2k, Filter *filt, ToolMenuEntry *toolMenuItem, QJSEngine *engine, QWidget *parent, bool offline_mode_ = 0); ~LogicAnalyzer(); - void setNativeDialogs(bool nativeDialogs) override; public: // Mixed Signal View Interface // enable mixed signal view diff --git a/plugins/m2k/src/old/m2ktool.cpp b/plugins/m2k/src/old/m2ktool.cpp index b8a2afdeba..c458f9cda8 100644 --- a/plugins/m2k/src/old/m2ktool.cpp +++ b/plugins/m2k/src/old/m2ktool.cpp @@ -59,18 +59,9 @@ void M2kTool::setName(const QString &name) { this->name = name; } void M2kTool::settingsLoaded() {} -/* Tools that use file dialogs should overload this method -to ensure their file dialogs are configured correspondingly */ -void M2kTool::setNativeDialogs(bool nativeDialogs) { m_useNativeDialogs = nativeDialogs; } - ApiObject *M2kTool::getApi() { return api; } -void M2kTool::readPreferences() -{ - saveOnExit = p->get("general_save_on_exit").toBool(); - m_useNativeDialogs = p->get("general_native_dialogs").toBool(); - ; -} +void M2kTool::readPreferences() { saveOnExit = p->get("general_save_on_exit").toBool(); } ToolMenuEntry *M2kTool::getTme() const { return tme; } diff --git a/plugins/m2k/src/old/m2ktool.hpp b/plugins/m2k/src/old/m2ktool.hpp index 7939d2cfff..c668e7d0c9 100644 --- a/plugins/m2k/src/old/m2ktool.hpp +++ b/plugins/m2k/src/old/m2ktool.hpp @@ -58,7 +58,6 @@ class M2kTool : public QWidget, public ResourceUser const QString &getName(); void setName(const QString &name); virtual void settingsLoaded(); - virtual void setNativeDialogs(bool nativeDialogs); ApiObject *getApi(); @@ -83,7 +82,6 @@ public Q_SLOTS: QMainWindow *window; ToolMenuEntry *tme; Preferences *p; - bool m_useNativeDialogs; QWidget *m_centralWidget; }; } // namespace m2k diff --git a/plugins/m2k/src/old/manualcalibration.cpp b/plugins/m2k/src/old/manualcalibration.cpp index 2d2e4ae7ab..8dd1dbca5b 100644 --- a/plugins/m2k/src/old/manualcalibration.cpp +++ b/plugins/m2k/src/old/manualcalibration.cpp @@ -530,10 +530,11 @@ void ManualCalibration::on_saveButton_clicked() QString fileName; QString selectedFilter; + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); if(calibrationFilePath == "") { fileName = QFileDialog::getSaveFileName( this, tr("Save file"), "", tr("Ini files (*.ini)"), &selectedFilter, - (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); } else { fileName = calibrationFilePath; } diff --git a/plugins/m2k/src/old/network_analyzer.cpp b/plugins/m2k/src/old/network_analyzer.cpp index 4d02d68a19..f39e6434b5 100644 --- a/plugins/m2k/src/old/network_analyzer.cpp +++ b/plugins/m2k/src/old/network_analyzer.cpp @@ -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); @@ -620,10 +622,11 @@ NetworkAnalyzer::NetworkAnalyzer(libm2k::context::M2k *m2k, QString uri, Filter } } + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString selectedFilter = filter[0]; QString fileName = QFileDialog::getSaveFileName( this, tr("Save to"), fileNameHint, filter.join(";;"), &selectedFilter, - (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); if(fileName.split(".").size() <= 1) { // file name w/o extension. Let's append it @@ -677,11 +680,12 @@ NetworkAnalyzer::NetworkAnalyzer(libm2k::context::M2k *m2k, QString uri, Filter }); connect(ui->importBtn, &QPushButton::clicked, [=]() { + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString fileName = QFileDialog::getOpenFileName( this, tr("Import"), "", tr("Comma-separated values files (*.csv);;" "Tab-delimited values files (*.txt)"), - nullptr, (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + nullptr, (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); FileManager fm("Network Analyzer"); @@ -848,9 +852,10 @@ void NetworkAnalyzer::on_btnExport_clicked() QString selectedFilter = filter[0]; + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString fileName = QFileDialog::getSaveFileName( this, tr("Export"), "", filter.join(";;"), &selectedFilter, - (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); if(fileName.split(".").size() <= 1) { // file name w/o extension. Let's append it diff --git a/plugins/m2k/src/old/oscilloscope.cpp b/plugins/m2k/src/old/oscilloscope.cpp index 46b8a643af..a1d6c9edb8 100644 --- a/plugins/m2k/src/old/oscilloscope.cpp +++ b/plugins/m2k/src/old/oscilloscope.cpp @@ -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 @@ -987,12 +989,6 @@ void Oscilloscope::remove_ref_waveform(QString name) } } -void Oscilloscope::setNativeDialogs(bool nativeDialogs) -{ - M2kTool::setNativeDialogs(nativeDialogs); - plot.setUseNativeDialog(nativeDialogs); -} - void Oscilloscope::setLogicAnalyzer(logic::LogicAnalyzer *la) { qDebug() << "Logic Analyzer: " << la; @@ -1504,9 +1500,10 @@ void Oscilloscope::init_channel_settings() QString selectedFilter = filter[0]; + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString fileName = QFileDialog::getSaveFileName( this, tr("Export"), "", filter.join(";;"), &selectedFilter, - (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); if(fileName.split(".").size() <= 1) { // file name w/o extension. Let's append it @@ -1931,9 +1928,10 @@ void Oscilloscope::btnExport_clicked() QString selectedFilter = filter[0]; + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString fileName = QFileDialog::getSaveFileName( this, tr("Export"), "", filter.join(";;"), &selectedFilter, - (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); if(fileName.split(".").size() <= 1) { // file name w/o extension. Let's append it @@ -2096,6 +2094,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(); @@ -2242,11 +2242,12 @@ void Oscilloscope::create_add_channel_panel() void Oscilloscope::import() { + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString fileName = QFileDialog::getOpenFileName( this, tr("Import"), "", tr("Comma-separated values files (*.csv);;" "Tab-delimited values files (*.txt)"), - nullptr, (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + nullptr, (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); FileManager fm("Oscilloscope"); diff --git a/plugins/m2k/src/old/oscilloscope.hpp b/plugins/m2k/src/old/oscilloscope.hpp index 01f05c4b10..67d2289dc8 100644 --- a/plugins/m2k/src/old/oscilloscope.hpp +++ b/plugins/m2k/src/old/oscilloscope.hpp @@ -136,7 +136,6 @@ class Oscilloscope : public M2kTool void add_ref_waveform(QString name, QVector xData, QVector yData, unsigned int sampleRate); void remove_ref_waveform(QString name); - void setNativeDialogs(bool nativeDialogs) override; void setLogicAnalyzer(logic::LogicAnalyzer *la); diff --git a/plugins/m2k/src/old/patterngenerator/pattern_generator.cpp b/plugins/m2k/src/old/patterngenerator/pattern_generator.cpp index a02b25181b..d7a2ecc999 100644 --- a/plugins/m2k/src/old/patterngenerator/pattern_generator.cpp +++ b/plugins/m2k/src/old/patterngenerator/pattern_generator.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -199,12 +200,6 @@ PatternGenerator::~PatternGenerator() delete m_ui; } -void PatternGenerator::setNativeDialogs(bool nativeDialogs) -{ - M2kTool::setNativeDialogs(nativeDialogs); - m_plot.setUseNativeDialog(nativeDialogs); -} - void PatternGenerator::setupUi() { m_ui->setupUi(this); @@ -923,6 +918,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, [=]() { diff --git a/plugins/m2k/src/old/patterngenerator/pattern_generator.h b/plugins/m2k/src/old/patterngenerator/pattern_generator.h index 057f3b7078..79481d4064 100644 --- a/plugins/m2k/src/old/patterngenerator/pattern_generator.h +++ b/plugins/m2k/src/old/patterngenerator/pattern_generator.h @@ -70,7 +70,6 @@ class PatternGenerator : public M2kTool explicit PatternGenerator(libm2k::context::M2k *m2k, Filter *filt, ToolMenuEntry *tme, QJSEngine *engine, DIOManager *diom, QWidget *parent); ~PatternGenerator(); - void setNativeDialogs(bool nativeDialogs) override; Q_SIGNALS: void dataAvailable(uint64_t, uint64_t, uint16_t *data); diff --git a/plugins/m2k/src/old/signal_generator.cpp b/plugins/m2k/src/old/signal_generator.cpp index bdd306308b..d7005b52fb 100644 --- a/plugins/m2k/src/old/signal_generator.cpp +++ b/plugins/m2k/src/old/signal_generator.cpp @@ -1291,13 +1291,14 @@ void SignalGenerator::loadFileFromPath(QString filename) void SignalGenerator::loadFile() { + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString fileName = QFileDialog::getOpenFileName( this, tr("Open File"), "", tr("Comma-separated values files (*.csv);;" "Tab-delimited values files (*.txt);;" "Waveform Audio File Format (*.wav);;" "Matlab files (*.mat)"), - nullptr, (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + nullptr, (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); if(fileName.isEmpty()) { // user hit cancel return; diff --git a/plugins/m2k/src/old/spectrum_analyzer.cpp b/plugins/m2k/src/old/spectrum_analyzer.cpp index 4db1b3dc3a..85bd9b18e6 100644 --- a/plugins/m2k/src/old/spectrum_analyzer.cpp +++ b/plugins/m2k/src/old/spectrum_analyzer.cpp @@ -72,6 +72,7 @@ #include "m2kpluginExceptionHandler.h" #include +#include #include #include @@ -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); }); @@ -704,9 +706,10 @@ SpectrumAnalyzer::SpectrumAnalyzer(libm2k::context::M2k *m2k, QString uri, Filte QString selectedFilter = filter[0]; + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString fileName = QFileDialog::getSaveFileName( this, tr("Export"), "", filter.join(";;"), &selectedFilter, - (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); if(fileName.split(".").size() <= 1) { // file name w/o extension. Let's append it @@ -829,13 +832,6 @@ SpectrumAnalyzer::~SpectrumAnalyzer() QPushButton *SpectrumAnalyzer::getRunButton() { return ui->runSingleWidget->getRunButton(); } -void SpectrumAnalyzer::setNativeDialogs(bool nativeDialogs) -{ - M2kTool::setNativeDialogs(nativeDialogs); - fft_plot->setUseNativeDialog(nativeDialogs); - waterfall_plot->setUseNativeDialog(nativeDialogs); -} - void SpectrumAnalyzer::readPreferences() { Preferences *p = Preferences::GetInstance(); @@ -857,9 +853,10 @@ void SpectrumAnalyzer::btnExportClicked() QString selectedFilter = filter[0]; + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString fileName = QFileDialog::getSaveFileName( this, tr("Export"), "", filter.join(";;"), &selectedFilter, - (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); if(fileName.split(".").size() <= 1) { // file name w/o extension. Let's append it @@ -1462,11 +1459,12 @@ void SpectrumAnalyzer::on_btnAddRef_toggled(bool checked) void SpectrumAnalyzer::on_btnBrowseFile_clicked() { + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); QString fileName = QFileDialog::getOpenFileName( this, tr("Export"), "", tr("Comma-separated values files (*.csv);;" "Tab-delimited values files (*.txt)"), - nullptr, (m_useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); + nullptr, (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog)); FileManager fm("Spectrum Analyzer"); diff --git a/plugins/m2k/src/old/spectrum_analyzer.hpp b/plugins/m2k/src/old/spectrum_analyzer.hpp index c23bc788c9..0896491c9b 100644 --- a/plugins/m2k/src/old/spectrum_analyzer.hpp +++ b/plugins/m2k/src/old/spectrum_analyzer.hpp @@ -124,7 +124,6 @@ class SpectrumAnalyzer : public M2kTool m2k_iio_manager *m2k_man, QJSEngine *engine, QWidget *parent); ~SpectrumAnalyzer(); QPushButton *getRunButton(); - void setNativeDialogs(bool nativeDialogs) override; void setCurrentAverageIndexLabel(uint chnIdx); public Q_SLOTS: void readPreferences(); diff --git a/plugins/m2k/ui/logic_analyzer.ui b/plugins/m2k/ui/logic_analyzer.ui index c19d931e52..01485437ef 100644 --- a/plugins/m2k/ui/logic_analyzer.ui +++ b/plugins/m2k/ui/logic_analyzer.ui @@ -124,9 +124,6 @@ true - - true - diff --git a/plugins/m2k/ui/network_analyzer.ui b/plugins/m2k/ui/network_analyzer.ui index 48914fbfea..daa5779d86 100644 --- a/plugins/m2k/ui/network_analyzer.ui +++ b/plugins/m2k/ui/network_analyzer.ui @@ -109,9 +109,6 @@ true - - true - diff --git a/plugins/m2k/ui/oscilloscope.ui b/plugins/m2k/ui/oscilloscope.ui index b471ee6391..ddc14857e0 100644 --- a/plugins/m2k/ui/oscilloscope.ui +++ b/plugins/m2k/ui/oscilloscope.ui @@ -125,9 +125,6 @@ 10 - - true - @@ -148,9 +145,6 @@ Enable Mixed Signal View - - true - diff --git a/plugins/m2k/ui/pattern_generator.ui b/plugins/m2k/ui/pattern_generator.ui index cefa52fc3f..7ff5fa8f9f 100644 --- a/plugins/m2k/ui/pattern_generator.ui +++ b/plugins/m2k/ui/pattern_generator.ui @@ -121,9 +121,6 @@ 10 - - true - @@ -145,9 +142,6 @@ true - - true - diff --git a/plugins/m2k/ui/spectrum_analyzer.ui b/plugins/m2k/ui/spectrum_analyzer.ui index d8e14c74a4..bfa7ca68ef 100644 --- a/plugins/m2k/ui/spectrum_analyzer.ui +++ b/plugins/m2k/ui/spectrum_analyzer.ui @@ -119,9 +119,6 @@ 10 - - true - diff --git a/plugins/regmap/src/registermapsettingsmenu.cpp b/plugins/regmap/src/registermapsettingsmenu.cpp index b42835185a..f9e62cfe77 100644 --- a/plugins/regmap/src/registermapsettingsmenu.cpp +++ b/plugins/regmap/src/registermapsettingsmenu.cpp @@ -39,6 +39,8 @@ #include #include +#include + using namespace scopy; using namespace regmap; @@ -125,8 +127,12 @@ RegisterMapSettingsMenu::RegisterMapSettingsMenu(QWidget *parent) filePath->setPlaceholderText("File path"); pathButton = new QPushButton("Find path"); - QObject::connect(pathButton, &QPushButton::clicked, this, - [=]() { filePath->setText(QFileDialog::getOpenFileName(this, ("Open File"), "")); }); + QObject::connect(pathButton, &QPushButton::clicked, this, [=]() { + bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool(); + filePath->setText(QFileDialog::getOpenFileName( + this, ("Open File"), "", QString(), nullptr, + (useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog))); + }); findPathLayout->addWidget(filePath); findPathLayout->addWidget(pathButton); @@ -189,7 +195,7 @@ void RegisterMapSettingsMenu::startTutorial() auto settingsTutorialFinish = connect(settingsTutorial, &gui::TutorialBuilder::finished, this, &RegisterMapSettingsMenu::tutorialDone, Qt::UniqueConnection); - connect(settingsTutorial, &gui::TutorialBuilder::aborted, this, [=, this]() { + connect(settingsTutorial, &gui::TutorialBuilder::aborted, this, [settingsTutorialFinish, this]() { disconnect(settingsTutorialFinish); Q_EMIT tutorialAborted(); }); diff --git a/plugins/regmap/src/registermaptool.cpp b/plugins/regmap/src/registermaptool.cpp index baa56627d3..5ed1498711 100644 --- a/plugins/regmap/src/registermaptool.cpp +++ b/plugins/regmap/src/registermaptool.cpp @@ -193,7 +193,7 @@ void RegisterMapTool::startTutorial() controllerTutorial = connect( settings, &RegisterMapSettingsMenu::tutorialDone, this, - [=, this]() { deviceList->value(activeRegisterMap)->startTutorial(); }, Qt::UniqueConnection); + [this]() { deviceList->value(activeRegisterMap)->startTutorial(); }, Qt::UniqueConnection); connect(deviceList->value(activeRegisterMap), &DeviceRegisterMap::tutorialFinished, this, &RegisterMapTool::tutorialAborted); @@ -220,7 +220,7 @@ void RegisterMapTool::startSimpleTutorial() controllerTutorial = connect( settings, &RegisterMapSettingsMenu::tutorialDone, this, - [=, this]() { deviceList->value(activeRegisterMap)->startSimpleTutorial(); }, Qt::UniqueConnection); + [this]() { deviceList->value(activeRegisterMap)->startSimpleTutorial(); }, Qt::UniqueConnection); connect(deviceList->value(activeRegisterMap), &DeviceRegisterMap::simpleTutorialFinished, this, &RegisterMapTool::tutorialAborted); diff --git a/plugins/swiot/CMakeLists.txt b/plugins/swiot/CMakeLists.txt index 6fc2b7227f..806f26cc64 100644 --- a/plugins/swiot/CMakeLists.txt +++ b/plugins/swiot/CMakeLists.txt @@ -78,6 +78,9 @@ file( include/${SCOPY_MODULE}/config/*.hpp ) +include(ScopyStyle) +generate_style("--plugin" ${CMAKE_CURRENT_SOURCE_DIR}/style ${CMAKE_CURRENT_SOURCE_DIR}/include/swiot) + if(ENABLE_TESTING) add_subdirectory(test) endif() diff --git a/plugins/swiot/src/ad74413r/ad74413r.cpp b/plugins/swiot/src/ad74413r/ad74413r.cpp index 49f169ec31..9e65b11ca9 100644 --- a/plugins/swiot/src/ad74413r/ad74413r.cpp +++ b/plugins/swiot/src/ad74413r/ad74413r.cpp @@ -611,6 +611,7 @@ void Ad74413r::setupToolTemplate() connect(m_infoBtn, &InfoBtn::clicked, this, [this]() { m_infoBtn->generateInfoPopup(this); + connect(m_infoBtn->getTutorialButton(), &QPushButton::clicked, this, &Ad74413r::startTutorial); connect(m_infoBtn->getDocumentationButton(), &QAbstractButton::clicked, this, [=, this]() { QDesktopServices::openUrl( diff --git a/plugins/swiot/src/config/configchannelview.cpp b/plugins/swiot/src/config/configchannelview.cpp index c336d8ab62..793c0af2cf 100644 --- a/plugins/swiot/src/config/configchannelview.cpp +++ b/plugins/swiot/src/config/configchannelview.cpp @@ -46,12 +46,12 @@ ConfigChannelView::ConfigChannelView(int channelIndex, QWidget *parent) m_deviceOptions = new QComboBox(this); m_deviceOptions->setFixedWidth(DEVICE_COMBO_WIDTH); - StyleHelper::TransparentWidget(m_deviceOptions, "deviceOptions"); + Style::setBackgroundColor(m_deviceOptions, QString("transparent"), true); Style::setStyle(m_deviceOptions, style::properties::widget::solidBorder); m_functionOptions = new QComboBox(this); + Style::setBackgroundColor(m_functionOptions, QString("transparent"), true); m_functionOptions->setFixedWidth(FUNCTION_COMBO_WIDTH); - StyleHelper::TransparentWidget(m_functionOptions, "functionOptions"); Style::setStyle(m_functionOptions, style::properties::widget::solidBorder); layout->addWidget(m_chnlLabel); diff --git a/plugins/swiot/src/faults/faults.cpp b/plugins/swiot/src/faults/faults.cpp index 6e00ad41cc..e12bc20387 100644 --- a/plugins/swiot/src/faults/faults.cpp +++ b/plugins/swiot/src/faults/faults.cpp @@ -56,6 +56,7 @@ Faults::Faults(QString uri, ToolMenuEntry *tme, QWidget *parent) InfoBtn *infoBtn = new InfoBtn(this, true); m_tool->addWidgetToTopContainerHelper(infoBtn, TTA_LEFT); + connect(infoBtn, &InfoBtn::clicked, this, [this, infoBtn]() { infoBtn->generateInfoPopup(this); connect(infoBtn->getTutorialButton(), &QPushButton::clicked, this, &Faults::startTutorial); diff --git a/plugins/swiot/src/faults/faultsdevice.cpp b/plugins/swiot/src/faults/faultsdevice.cpp index 78cf615160..04418de6ee 100644 --- a/plugins/swiot/src/faults/faultsdevice.cpp +++ b/plugins/swiot/src/faults/faultsdevice.cpp @@ -32,6 +32,7 @@ #include #include #include +#include "style_properties.h" #define FAULT_CHANNEL_NAME "voltage" #define SWIOT_NB_CHANNELS 4 @@ -114,12 +115,6 @@ void FaultsDevice::updateExplanations() if(selected.empty()) { for(int i = 0; i < m_faultExplanationWidgets.size(); ++i) { m_faultExplanationWidgets[i]->show(); - - if(actives.contains(i)) { - setDynamicProperty(m_faultExplanationWidgets[i], "highlighted", true); - } else { - setDynamicProperty(m_faultExplanationWidgets[i], "highlighted", false); - } } } else { for(int i = 0; i < m_faultExplanationWidgets.size(); ++i) { @@ -128,12 +123,6 @@ void FaultsDevice::updateExplanations() } else { m_faultExplanationWidgets[i]->hide(); } - - if(actives.contains(i)) { - setDynamicProperty(m_faultExplanationWidgets[i], "highlighted", true); - } else { - setDynamicProperty(m_faultExplanationWidgets[i], "highlighted", false); - } } } @@ -326,7 +315,7 @@ QWidget *FaultsDevice::createExplanationSection(QWidget *parent) auto widget = new QLabel(item, m_faultsExplanation); widget->setTextFormat(Qt::PlainText); widget->setWordWrap(true); - StyleHelper::FaultsExplanation(widget); + Style::setStyle(widget, style::properties::label::subtle); m_faultExplanationWidgets.push_back(widget); m_faultsExplanation->layout()->addWidget(widget); diff --git a/plugins/swiot/src/faults/faultwidget.cpp b/plugins/swiot/src/faults/faultwidget.cpp index cae7741e9e..fc86dc173d 100644 --- a/plugins/swiot/src/faults/faultwidget.cpp +++ b/plugins/swiot/src/faults/faultwidget.cpp @@ -24,6 +24,7 @@ #include #include #include +#include "style_properties.h" using namespace scopy::swiot; @@ -41,11 +42,11 @@ FaultWidget::FaultWidget(unsigned int id, QString name, QString faultExplanation m_activeLabel = new QLabel(this); m_activeLabel->setMinimumSize(50, 20); - StyleHelper::ActiveStoredLabel(m_activeLabel); + Style::setStyle(m_activeLabel, style::properties::swiot::activeStoredLabel, "low", true); m_storedLabel = new QLabel(this); m_storedLabel->setMinimumSize(50, 20); - StyleHelper::ActiveStoredLabel(m_storedLabel); + Style::setStyle(m_storedLabel, style::properties::swiot::activeStoredLabel, "low", true); m_titleLabel = new QLabel(this); m_titleLabel->setText("Bit" + QString::number(m_id)); @@ -56,7 +57,6 @@ FaultWidget::FaultWidget(unsigned int id, QString name, QString faultExplanation layout->addWidget(m_titleLabel, 0, Qt::AlignCenter); installEventFilter(this); - StyleHelper::FaultsFrame(this); } FaultWidget::~FaultWidget() {} @@ -66,7 +66,7 @@ bool FaultWidget::isStored() const { return m_stored; } void FaultWidget::setStored(bool stored) { FaultWidget::m_stored = stored; - m_storedLabel->setProperty("high", m_stored); + Style::setStyle(m_storedLabel, style::properties::swiot::activeStoredLabel, stored ? "high" : "low", true); m_storedLabel->setStyle(m_storedLabel->style()); } @@ -75,7 +75,7 @@ bool FaultWidget::isActive() const { return m_active; } void FaultWidget::setActive(bool active) { FaultWidget::m_active = active; - m_activeLabel->setProperty("high", m_active); + Style::setStyle(m_activeLabel, style::properties::swiot::activeStoredLabel, active ? "high" : "low", true); m_activeLabel->setStyle(m_activeLabel->style()); } @@ -101,7 +101,7 @@ bool FaultWidget::isPressed() const { return m_pressed; } void FaultWidget::setPressed(bool pressed) { FaultWidget::m_pressed = pressed; - scopy::setDynamicProperty(this, "pressed", pressed); + Style::setStyle(this, style::properties::swiot::faultsFrame, pressed); } void FaultWidget::specialFaultUpdated(int index, QString channelFunction) @@ -119,7 +119,7 @@ void FaultWidget::specialFaultUpdated(int index, QString channelFunction) bool FaultWidget::eventFilter(QObject *object, QEvent *event) { if(event->type() == QEvent::MouseButtonPress) { - setPressed(!scopy::getDynamicProperty(this, "pressed")); + setPressed(!scopy::getDynamicProperty(this, style::properties::swiot::faultsFrame)); Q_EMIT faultSelected(m_id); } diff --git a/plugins/swiot/src/max14906/diodigitalchannel.cpp b/plugins/swiot/src/max14906/diodigitalchannel.cpp index 58132bc58c..0629c65d5d 100644 --- a/plugins/swiot/src/max14906/diodigitalchannel.cpp +++ b/plugins/swiot/src/max14906/diodigitalchannel.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "style_properties.h" using namespace scopy::swiot; @@ -183,7 +184,7 @@ QWidget *DioDigitalChannel::createBottomContainer(QWidget *parent) m_lcdNumber->setPrecision(0); m_lcdNumber->setSegmentStyle(QLCDNumber::Flat); m_lcdNumber->setFrameShape(QFrame::NoFrame); - StyleHelper::OrangeWidget(m_lcdNumber); + Style::setStyle(m_lcdNumber, style::properties::swiot::lcdNumber); readBackWidget->layout()->addWidget(m_lcdNumber); layout->addWidget(readBackWidget); diff --git a/plugins/swiot/style/qss/properties/swiot/activeStoredLabel.qss b/plugins/swiot/style/qss/properties/swiot/activeStoredLabel.qss new file mode 100644 index 0000000000..af277af7cc --- /dev/null +++ b/plugins/swiot/style/qss/properties/swiot/activeStoredLabel.qss @@ -0,0 +1,17 @@ +QLabel[&&property&&="low"] { + width: 40px; + height: 14px; + border: 2px solid; + border-radius: 8px; + border-color: &content_default&; + background-color: transparent; +} +QLabel[&&property&&="high"] { + width: 40px; + height: 14px; + border: 2px solid; + border-radius: 8px; + border-color: &content_default&; + background-color: &content_default&; +} + diff --git a/plugins/swiot/style/qss/properties/swiot/faultsFrame.qss b/plugins/swiot/style/qss/properties/swiot/faultsFrame.qss new file mode 100644 index 0000000000..3dd186f51d --- /dev/null +++ b/plugins/swiot/style/qss/properties/swiot/faultsFrame.qss @@ -0,0 +1,5 @@ +QFrame[&&property&&=true] { + background-color: &content_subtle&; + border: 1px solid &background_primary&; + border-radius:5px; +} diff --git a/plugins/swiot/style/qss/properties/swiot/lcdNumber.qss b/plugins/swiot/style/qss/properties/swiot/lcdNumber.qss new file mode 100644 index 0000000000..c7dbdd659f --- /dev/null +++ b/plugins/swiot/style/qss/properties/swiot/lcdNumber.qss @@ -0,0 +1,3 @@ +QWidget[&&property&&=true] { + color: &interactive_primary_idle& +}