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/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/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 7fbeb198d1..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) { @@ -2825,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..7d0748489f 100644 --- a/plugins/m2k/src/old/m2ktool.cpp +++ b/plugins/m2k/src/old/m2ktool.cpp @@ -59,17 +59,11 @@ 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(); - ; } 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 3a47f8d9c8..f39e6434b5 100644 --- a/plugins/m2k/src/old/network_analyzer.cpp +++ b/plugins/m2k/src/old/network_analyzer.cpp @@ -622,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 @@ -679,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"); @@ -850,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 d9d9886b09..a1d6c9edb8 100644 --- a/plugins/m2k/src/old/oscilloscope.cpp +++ b/plugins/m2k/src/old/oscilloscope.cpp @@ -989,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; @@ -1506,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 @@ -1933,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 @@ -2246,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 19f117eb50..d7a2ecc999 100644 --- a/plugins/m2k/src/old/patterngenerator/pattern_generator.cpp +++ b/plugins/m2k/src/old/patterngenerator/pattern_generator.cpp @@ -200,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); 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 a18cde74bb..85bd9b18e6 100644 --- a/plugins/m2k/src/old/spectrum_analyzer.cpp +++ b/plugins/m2k/src/old/spectrum_analyzer.cpp @@ -706,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 @@ -831,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(); @@ -859,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 @@ -1464,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();