From f07934cc80ccd9c6d005c84bbf49ab1fc4f51e61 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 9 May 2015 10:51:02 +0200 Subject: [PATCH] Added button and logic to update an existing preset with the current configuration --- .gitignore | 2 + include-gpl/gui/addpresetdialog.h | 2 + include-gpl/mainwindow.h | 3 +- include-gpl/settings/preset.h | 3 +- sdrbase/gui/addpresetdialog.cpp | 10 ++++ sdrbase/mainwindow.cpp | 61 +++++++++++++------- sdrbase/mainwindow.ui | 85 ++++++++++++++++++++++++---- sdrbase/resources/preset-save.png | Bin 996 -> 1250 bytes sdrbase/resources/preset-update.png | Bin 0 -> 1254 bytes sdrbase/resources/res.qrc | 1 + 10 files changed, 136 insertions(+), 31 deletions(-) create mode 100644 sdrbase/resources/preset-update.png diff --git a/.gitignore b/.gitignore index f859d569c..588976d8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ CMakeLists.txt.user* build/* LOCAL/* +.cproject +.project diff --git a/include-gpl/gui/addpresetdialog.h b/include-gpl/gui/addpresetdialog.h index 8d3a7ee28..0273544ce 100644 --- a/include-gpl/gui/addpresetdialog.h +++ b/include-gpl/gui/addpresetdialog.h @@ -16,6 +16,8 @@ public: QString group() const; QString description() const; + void setGroup(QString& group); + void setDescription(QString& description); private: enum Audio { diff --git a/include-gpl/mainwindow.h b/include-gpl/mainwindow.h index 691c98462..d2beede0e 100644 --- a/include-gpl/mainwindow.h +++ b/include-gpl/mainwindow.h @@ -48,7 +48,7 @@ class SDRANGELOVE_API MainWindow : public QMainWindow { Q_OBJECT public: - explicit MainWindow(QWidget* parent = NULL); + explicit MainWindow(QWidget* parent = 0); ~MainWindow(); MessageQueue* getMessageQueue() { return m_messageQueue; } @@ -121,6 +121,7 @@ private slots: void on_iqImbalance_toggled(bool checked); void on_action_View_Fullscreen_toggled(bool checked); void on_presetSave_clicked(); + void on_presetUpdate_clicked(); void on_presetLoad_clicked(); void on_presetDelete_clicked(); void on_presetTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); diff --git a/include-gpl/settings/preset.h b/include-gpl/settings/preset.h index 1396e2388..330bdfde8 100644 --- a/include-gpl/settings/preset.h +++ b/include-gpl/settings/preset.h @@ -93,6 +93,7 @@ protected: QByteArray m_layout; }; -Q_DECLARE_METATYPE(const Preset*) +Q_DECLARE_METATYPE(const Preset*); +Q_DECLARE_METATYPE(Preset*); #endif // INCLUDE_PRESET_H diff --git a/sdrbase/gui/addpresetdialog.cpp b/sdrbase/gui/addpresetdialog.cpp index c4d037bed..390fae2f6 100644 --- a/sdrbase/gui/addpresetdialog.cpp +++ b/sdrbase/gui/addpresetdialog.cpp @@ -24,3 +24,13 @@ QString AddPresetDialog::description() const { return ui->description->text(); } + +void AddPresetDialog::setGroup(QString& group) +{ + ui->group->lineEdit()->setText(group); +} + +void AddPresetDialog::setDescription(QString& description) +{ + ui->description->setText(description); +} diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index 5c09b2dca..6ec9966ca 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -45,8 +45,8 @@ MainWindow::MainWindow(QWidget* parent) : m_dspEngine(new DSPEngine(m_messageQueue)), m_lastEngineState((DSPEngine::State)-1), m_startOsmoSDRUpdateAfterStop(false), - m_scopeWindow(NULL), - m_inputGUI(NULL), + m_scopeWindow(0), + m_inputGUI(0), m_sampleRate(0), m_centerFrequency(0), m_pluginManager(new PluginManager(this, m_dspEngine)) @@ -122,9 +122,9 @@ MainWindow::~MainWindow() m_dspEngine->removeSink(m_spectrumVis); delete m_spectrumVis; - if(m_scopeWindow != NULL) { + if(m_scopeWindow != 0) { delete m_scopeWindow; - m_scopeWindow = NULL; + m_scopeWindow = 0; } delete m_pluginManager; @@ -165,9 +165,9 @@ void MainWindow::removeChannelMarker(ChannelMarker* channelMarker) void MainWindow::setInputGUI(QWidget* gui) { - if(m_inputGUI != NULL) + if(m_inputGUI != 0) ui->inputDock->widget()->layout()->removeWidget(m_inputGUI); - if(gui != NULL) + if(gui != 0) ui->inputDock->widget()->layout()->addWidget(gui); m_inputGUI = gui; } @@ -251,14 +251,14 @@ void MainWindow::updateSampleRate() { ui->glSpectrum->setSampleRate(m_sampleRate); m_sampleRateWidget->setText(tr("Rate: %1 kHz").arg((float)m_sampleRate / 1000)); - if(m_scopeWindow != NULL) + if(m_scopeWindow != 0) m_scopeWindow->setSampleRate(m_sampleRate); } void MainWindow::updatePresets() { ui->presetTree->resizeColumnToContents(0); - if(ui->presetTree->currentItem() != NULL) { + if(ui->presetTree->currentItem() != 0) { ui->presetDelete->setEnabled(true); ui->presetLoad->setEnabled(true); } else { @@ -269,14 +269,14 @@ void MainWindow::updatePresets() QTreeWidgetItem* MainWindow::addPresetToTree(const Preset* preset) { - QTreeWidgetItem* group = NULL; + QTreeWidgetItem* group = 0; for(int i = 0; i < ui->presetTree->topLevelItemCount(); i++) { if(ui->presetTree->topLevelItem(i)->text(0) == preset->getGroup()) { group = ui->presetTree->topLevelItem(i); break; } } - if(group == NULL) { + if(group == 0) { QStringList sl; sl.append(preset->getGroup()); group = new QTreeWidgetItem(ui->presetTree, sl, PGroup); @@ -305,7 +305,7 @@ void MainWindow::applySettings() void MainWindow::handleMessages() { Message* message; - while((message = m_messageQueue->accept()) != NULL) { + while((message = m_messageQueue->accept()) != 0) { qDebug("Message: %s", message->getIdentifier()); if(DSPEngineReport::match(message)) { DSPEngineReport* rep = (DSPEngineReport*)message; @@ -363,7 +363,7 @@ void MainWindow::scopeWindowDestroyed() { ui->action_Oscilloscope->setChecked(false); m_settings.getCurrent()->setShowScope(false); - m_scopeWindow = NULL; + m_scopeWindow = 0; } void MainWindow::on_action_Start_triggered() @@ -399,19 +399,26 @@ void MainWindow::on_presetSave_clicked() { QStringList groups; QString group; + QString description = ""; for(int i = 0; i < ui->presetTree->topLevelItemCount(); i++) groups.append(ui->presetTree->topLevelItem(i)->text(0)); QTreeWidgetItem* item = ui->presetTree->currentItem(); - if(item != NULL) { + if(item != 0) { if(item->type() == PGroup) group = item->text(0); - else if(item->type() == PItem) + else if(item->type() == PItem) { group = item->parent()->text(0); + description = item->text(0); + } } AddPresetDialog dlg(groups, group, this); + if (description.length() > 0) { + dlg.setDescription(description); + } + if(dlg.exec() == QDialog::Accepted) { Preset* preset = m_settings.newPreset(dlg.group(), dlg.description()); saveSettings(preset); @@ -420,16 +427,32 @@ void MainWindow::on_presetSave_clicked() } } +void MainWindow::on_presetUpdate_clicked() +{ + QTreeWidgetItem* item = ui->presetTree->currentItem(); + + if(item != 0) { + if(item->type() == PItem) { + const Preset* preset = qvariant_cast(item->data(0, Qt::UserRole)); + if (preset != 0) { + Preset* preset_mod = const_cast(preset); + saveSettings(preset_mod); + } + } + } +} + void MainWindow::on_presetLoad_clicked() { QTreeWidgetItem* item = ui->presetTree->currentItem(); - if(item == NULL) { + if(item == 0) { updatePresets(); return; } const Preset* preset = qvariant_cast(item->data(0, Qt::UserRole)); - if(preset == NULL) + if(preset == 0) { return; + } loadSettings(preset); applySettings(); @@ -438,12 +461,12 @@ void MainWindow::on_presetLoad_clicked() void MainWindow::on_presetDelete_clicked() { QTreeWidgetItem* item = ui->presetTree->currentItem(); - if(item == NULL) { + if(item == 0) { updatePresets(); return; } const Preset* preset = qvariant_cast(item->data(0, Qt::UserRole)); - if(preset == NULL) + if(preset == 0) return; if(QMessageBox::question(this, tr("Delete Preset"), tr("Do you want to delete preset '%1'?").arg(preset->getDescription()), QMessageBox::No | QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { @@ -464,7 +487,7 @@ void MainWindow::on_presetTree_itemActivated(QTreeWidgetItem *item, int column) void MainWindow::on_action_Oscilloscope_triggered() { - if(m_scopeWindow != NULL) { + if(m_scopeWindow != 0) { ((QWidget*)m_scopeWindow->parent())->raise(); return; } diff --git a/sdrbase/mainwindow.ui b/sdrbase/mainwindow.ui index 9ff0fb29a..e6ab61270 100644 --- a/sdrbase/mainwindow.ui +++ b/sdrbase/mainwindow.ui @@ -22,7 +22,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -112,7 +121,16 @@ - + + 2 + + + 2 + + + 2 + + 2 @@ -121,7 +139,7 @@ - Save current settings as preset + Save current settings as new preset ... @@ -138,7 +156,7 @@ - + Load selected preset @@ -158,7 +176,7 @@ - + Qt::Horizontal @@ -171,7 +189,7 @@ - + Delete selected preset @@ -191,7 +209,7 @@ - + true @@ -208,6 +226,26 @@ + + + + Update selected preset with current settings + + + ... + + + + :/preset-update.png:/preset-update.png + + + + 16 + 16 + + + + @@ -229,7 +267,16 @@ 3 - + + 2 + + + 2 + + + 2 + + 2 @@ -295,7 +342,16 @@ 3 - + + 2 + + + 2 + + + 2 + + 2 @@ -320,7 +376,16 @@ 3 - + + 2 + + + 2 + + + 2 + + 2 diff --git a/sdrbase/resources/preset-save.png b/sdrbase/resources/preset-save.png index 0ccc13e3cbb457223ade0bca0cb3223cc567e736..4d8383a6e8a5995ffd4d044a02e9d03e7454ad14 100644 GIT binary patch literal 1250 zcmZvae`u9u6vvO(b-ih}+ZJe(oXp44oUs{h&ROK`Iz2hvs*Q|_%?yX_o(PIU|8O@A zbLnE7m}qcUECNwywAcxD8(VBE>za$%3Oi~R8PpJUm+P+uPtTnoySu&cJkNPvp7VUZ z=X;*U$_;B~PS2SR05frI@M*XDlf&nAb8g&j0+}QR@yIB5CLW&0z@$XcSu16gn|!EC6c-?>o1IjvqQb(&goFl-SYc%nLPkS|Et3)o8a8AJ)txYC(TwM-PNJd6L?AKW zW;%avVV#yF+40lOvsP4D#3dq;JHe_Xg3K-^Rd>G&P}R-Grm44Ll~qU>nVep>N-8Mq z>L9DA;_5@IuI^-ZD$F@Ek>?D&jdabuMRigfcpRVR9Hctuwi8Q9HrcW$u^_QQ0;7|> z1}Aia-9Vy~GLXd*E0XI0gQ3)NlW&BrkTQzv90IvIQ(pr@YJZ$aPzE7z$1R8g3lO_! zD;8Lt1aP47Z}1^c2EddE23J)rkA3<<&))1+_lA4EocqGijrmP=Z(VK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^JSs}kvK?InA2oS;i-ysDR5C$e71T^lZkhD;|6;Wm(Vni~=GAofFvWtln zQCxtiZgx_wiV6!86A~IUVuh7S2pJ6-woFPWXxNY?RCmIlMKhDHI**1Tvw_5XgX#Ra zj&)jsWXBIR&stGs5toQW?gXon2r|2vRNeh9Kvg#z8=~HdRaPNkWO91hDyg8btAnhf zimMN;y1Ikeb79Vz**s_94Ww)Cb*hu%z%%#|=U}dLZace_V3RG25(^R=BrrP9Yj8qm z*$pH*F9TUDu_C!1Fc_L!Zt#t;6;eiVokJj3=iJwTFtiFi5#w)73d)_#;wKLFub8P8tg`ci@_w13p zz?)44??)xpEs0O6O<0_I>#tS2ragDmEsXefU}>g*q-5QSv5Sqr*ZKol)c4qi{VNka+g3hvOIp@*MG-Bv_ig{MN0KT&oA!9UJG|d*d9?81h3VNzFMnUZIebG=*XPME=GJc;`*M5p zbVqd5OP;;!BL_C`ANVCDf9+(%*wsT*qpw6qKYqM6VeH<53G+i$U-5zbMaOraI&mR7 z^6BZuo$X)5RF6zunrto0IdS=)oX$F1xyax1L|plwXFPw@TwQ!_W8KlLjJB{RH;pGA zJw4geGkj0YNL$hZ`0d&D*M};zPZ#B17~VJ9aBSV7sdrx3)jZxGQL`t1$m8dh+y|G% zww|ob5ATZeCLcbxF?GfASNFtSDdv+;WtJpxUix6p<+t-Z{;%RMr4CoOycXk|XvkTb z`%~UsjsITTJCTwCR~q`3eSCgPQg;7)6~3ERr`=yV)zK98$@71Gv-Vo&Xs~Ozs?>L^ HuxiJDpc+V8 literal 0 HcmV?d00001 diff --git a/sdrbase/resources/res.qrc b/sdrbase/resources/res.qrc index 12a209a70..a4976fbe2 100644 --- a/sdrbase/resources/res.qrc +++ b/sdrbase/resources/res.qrc @@ -5,6 +5,7 @@ waterfall.png preset-load.png preset-save.png + preset-update.png preset-delete.png horizontal.png vertical.png