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 0ccc13e3c..4d8383a6e 100644 Binary files a/sdrbase/resources/preset-save.png and b/sdrbase/resources/preset-save.png differ diff --git a/sdrbase/resources/preset-update.png b/sdrbase/resources/preset-update.png new file mode 100644 index 000000000..83f31c249 Binary files /dev/null and b/sdrbase/resources/preset-update.png differ 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