kopia lustrzana https://github.com/f4exb/sdrangel
Massive UI revamping (v7): device set presets
rodzic
af13b31d85
commit
c797060a7d
|
@ -744,6 +744,7 @@ public:
|
||||||
friend class MainWindow;
|
friend class MainWindow;
|
||||||
friend class WebAPIAdapter;
|
friend class WebAPIAdapter;
|
||||||
friend class CommandsDialog;
|
friend class CommandsDialog;
|
||||||
|
friend class DeviceSetPresetsDialog;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceSetAdded(int index, DeviceAPI *device);
|
void deviceSetAdded(int index, DeviceAPI *device);
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
void clearPresets();
|
void clearPresets();
|
||||||
const Preset& getWorkingPresetConst() const { return m_workingPreset; }
|
const Preset& getWorkingPresetConst() const { return m_workingPreset; }
|
||||||
Preset* getWorkingPreset() { return &m_workingPreset; }
|
Preset* getWorkingPreset() { return &m_workingPreset; }
|
||||||
|
QList<Preset*> *getPresets() { return &m_presets; }
|
||||||
|
|
||||||
void addCommand(Command *command);
|
void addCommand(Command *command);
|
||||||
void deleteCommand(const Command* command);
|
void deleteCommand(const Command* command);
|
||||||
|
|
|
@ -29,6 +29,7 @@ set(sdrgui_SOURCES
|
||||||
gui/cwkeyergui.cpp
|
gui/cwkeyergui.cpp
|
||||||
gui/datetimedelegate.cpp
|
gui/datetimedelegate.cpp
|
||||||
gui/decimaldelegate.cpp
|
gui/decimaldelegate.cpp
|
||||||
|
gui/devicesetpresetsdialog.cpp
|
||||||
gui/devicestreamselectiondialog.cpp
|
gui/devicestreamselectiondialog.cpp
|
||||||
gui/deviceuserargsdialog.cpp
|
gui/deviceuserargsdialog.cpp
|
||||||
gui/dmsspinbox.cpp
|
gui/dmsspinbox.cpp
|
||||||
|
@ -130,6 +131,7 @@ set(sdrgui_HEADERS
|
||||||
gui/cwkeyergui.h
|
gui/cwkeyergui.h
|
||||||
gui/datetimedelegate.h
|
gui/datetimedelegate.h
|
||||||
gui/decimaldelegate.h
|
gui/decimaldelegate.h
|
||||||
|
gui/devicesetpresetsdialog.h
|
||||||
gui/devicestreamselectiondialog.h
|
gui/devicestreamselectiondialog.h
|
||||||
gui/deviceuserargsdialog.h
|
gui/deviceuserargsdialog.h
|
||||||
gui/dmsspinbox.h
|
gui/dmsspinbox.h
|
||||||
|
@ -220,6 +222,7 @@ set(sdrgui_FORMS
|
||||||
gui/commandoutputdialog.ui
|
gui/commandoutputdialog.ui
|
||||||
gui/configurationsdialog.ui
|
gui/configurationsdialog.ui
|
||||||
gui/cwkeyergui.ui
|
gui/cwkeyergui.ui
|
||||||
|
gui/devicesetpresetsdialog.ui
|
||||||
gui/devicestreamselectiondialog.ui
|
gui/devicestreamselectiondialog.ui
|
||||||
gui/deviceuserargsdialog.ui
|
gui/deviceuserargsdialog.ui
|
||||||
gui/editcommanddialog.ui
|
gui/editcommanddialog.ui
|
||||||
|
|
|
@ -169,6 +169,7 @@ DeviceGUI::DeviceGUI(QWidget *parent) :
|
||||||
connect(m_changeDeviceButton, SIGNAL(clicked()), this, SLOT(openChangeDeviceDialog()));
|
connect(m_changeDeviceButton, SIGNAL(clicked()), this, SLOT(openChangeDeviceDialog()));
|
||||||
connect(m_reloadDeviceButton, SIGNAL(clicked()), this, SLOT(deviceReload()));
|
connect(m_reloadDeviceButton, SIGNAL(clicked()), this, SLOT(deviceReload()));
|
||||||
connect(m_addChannelsButton, SIGNAL(clicked()), this, SLOT(openAddChannelsDialog()));
|
connect(m_addChannelsButton, SIGNAL(clicked()), this, SLOT(openAddChannelsDialog()));
|
||||||
|
connect(m_deviceSetPresetsButton, SIGNAL(clicked()), this, SLOT(deviceSetPresetsDialog()));
|
||||||
connect(m_helpButton, SIGNAL(clicked()), this, SLOT(showHelp()));
|
connect(m_helpButton, SIGNAL(clicked()), this, SLOT(showHelp()));
|
||||||
connect(m_moveButton, SIGNAL(clicked()), this, SLOT(openMoveToWorkspaceDialog()));
|
connect(m_moveButton, SIGNAL(clicked()), this, SLOT(openMoveToWorkspaceDialog()));
|
||||||
connect(m_shrinkButton, SIGNAL(clicked()), this, SLOT(shrinkWindow()));
|
connect(m_shrinkButton, SIGNAL(clicked()), this, SLOT(shrinkWindow()));
|
||||||
|
@ -305,6 +306,12 @@ void DeviceGUI::shrinkWindow()
|
||||||
adjustSize();
|
adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceGUI::deviceSetPresetsDialog()
|
||||||
|
{
|
||||||
|
QPoint p = mapFromGlobal(QCursor::pos());
|
||||||
|
emit deviceSetPresetsDialogRequested(p, this);
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceGUI::setTitle(const QString& title)
|
void DeviceGUI::setTitle(const QString& title)
|
||||||
{
|
{
|
||||||
m_titleLabel->setText(title);
|
m_titleLabel->setText(title);
|
||||||
|
|
|
@ -131,6 +131,7 @@ private slots:
|
||||||
void openMoveToWorkspaceDialog();
|
void openMoveToWorkspaceDialog();
|
||||||
void showSpectrumHandler();
|
void showSpectrumHandler();
|
||||||
void showAllChannelsHandler();
|
void showAllChannelsHandler();
|
||||||
|
void deviceSetPresetsDialog();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void forceClose();
|
void forceClose();
|
||||||
|
@ -142,6 +143,7 @@ signals:
|
||||||
void showSpectrum(int deviceSetIndex);
|
void showSpectrum(int deviceSetIndex);
|
||||||
void showAllChannels(int deviceSetIndex);
|
void showAllChannels(int deviceSetIndex);
|
||||||
void addChannelEmitted(int channelIndex);
|
void addChannelEmitted(int channelIndex);
|
||||||
|
void deviceSetPresetsDialogRequested(QPoint, DeviceGUI*);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_DEVICEGUI_H
|
#endif // INCLUDE_DEVICEGUI_H
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
~DeviceUISet();
|
~DeviceUISet();
|
||||||
|
|
||||||
void setIndex(int deviceSetIndex);
|
void setIndex(int deviceSetIndex);
|
||||||
|
int getIndex() const { return m_deviceSetIndex; }
|
||||||
GLSpectrum *getSpectrum() { return m_spectrum; } //!< Direct spectrum getter
|
GLSpectrum *getSpectrum() { return m_spectrum; } //!< Direct spectrum getter
|
||||||
void setSpectrumScalingFactor(float scalef);
|
void setSpectrumScalingFactor(float scalef);
|
||||||
void addChannelMarker(ChannelMarker* channelMarker); //!< Add channel marker to spectrum
|
void addChannelMarker(ChannelMarker* channelMarker); //!< Add channel marker to spectrum
|
||||||
|
|
|
@ -0,0 +1,468 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2022 F4EXB //
|
||||||
|
// written by Edouard Griffiths //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// (at your option) any later version. //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "settings/preset.h"
|
||||||
|
#include "gui/presetitem.h"
|
||||||
|
#include "gui/addpresetdialog.h"
|
||||||
|
#include "device/deviceuiset.h"
|
||||||
|
#include "maincore.h"
|
||||||
|
|
||||||
|
#include "devicesetpresetsdialog.h"
|
||||||
|
#include "ui_devicesetpresetsdialog.h"
|
||||||
|
|
||||||
|
DeviceSetPresetsDialog::DeviceSetPresetsDialog(QWidget* parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::DeviceSetPresetsDialog),
|
||||||
|
m_deviceSetPresets(nullptr),
|
||||||
|
m_deviceUISet(nullptr),
|
||||||
|
m_pluginAPI(nullptr),
|
||||||
|
m_currentWorkspace(nullptr),
|
||||||
|
m_workspaces(nullptr),
|
||||||
|
m_presetLoaded(false)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceSetPresetsDialog::~DeviceSetPresetsDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::populateTree(int deviceType)
|
||||||
|
{
|
||||||
|
if (!m_deviceSetPresets) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Preset*>::const_iterator it = m_deviceSetPresets->begin();
|
||||||
|
QList<QTreeWidgetItem*> treeItems;
|
||||||
|
ui->presetTree->clear();
|
||||||
|
|
||||||
|
for (int i = 0; it != m_deviceSetPresets->end(); ++it, i++)
|
||||||
|
{
|
||||||
|
if (((*it)->isSourcePreset() && (deviceType == 0)) ||
|
||||||
|
((*it)->isSinkPreset() && (deviceType == 1)) ||
|
||||||
|
((*it)->isMIMOPreset() && (deviceType == 2)))
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *treeItem = addPresetToTree(*it);
|
||||||
|
treeItems.push_back(treeItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (treeItems.size() > 0) {
|
||||||
|
ui->presetTree->setCurrentItem(treeItems.at(treeItems.size()/2));
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePresetControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem* DeviceSetPresetsDialog::addPresetToTree(const Preset* preset)
|
||||||
|
{
|
||||||
|
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 == 0)
|
||||||
|
{
|
||||||
|
QStringList sl;
|
||||||
|
sl.append(preset->getGroup());
|
||||||
|
group = new QTreeWidgetItem(ui->presetTree, sl, PGroup);
|
||||||
|
group->setFirstColumnSpanned(true);
|
||||||
|
group->setExpanded(true);
|
||||||
|
ui->presetTree->sortByColumn(0, Qt::AscendingOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList sl;
|
||||||
|
sl.append(QString("%1").arg(preset->getCenterFrequency() / 1e6f, 0, 'f', 3)); // frequency column
|
||||||
|
sl.append(QString("%1").arg(preset->isSourcePreset() ? 'R' : preset->isSinkPreset() ? 'T' : preset->isMIMOPreset() ? 'M' : 'X')); // mode column
|
||||||
|
sl.append(preset->getDescription()); // description column
|
||||||
|
PresetItem* item = new PresetItem(group, sl, preset->getCenterFrequency(), PItem);
|
||||||
|
item->setTextAlignment(0, Qt::AlignRight);
|
||||||
|
item->setData(0, Qt::UserRole, QVariant::fromValue(preset));
|
||||||
|
ui->presetTree->resizeColumnToContents(0); // Resize frequency column to minimum
|
||||||
|
ui->presetTree->resizeColumnToContents(1); // Resize mode column to minimum
|
||||||
|
|
||||||
|
updatePresetControls();
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::updatePresetControls()
|
||||||
|
{
|
||||||
|
ui->presetTree->resizeColumnToContents(0);
|
||||||
|
|
||||||
|
if (ui->presetTree->currentItem() != 0)
|
||||||
|
{
|
||||||
|
ui->presetDelete->setEnabled(true);
|
||||||
|
ui->presetLoad->setEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->presetDelete->setEnabled(false);
|
||||||
|
ui->presetLoad->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::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)
|
||||||
|
{
|
||||||
|
if (item->type() == PGroup)
|
||||||
|
{
|
||||||
|
group = item->text(0);
|
||||||
|
}
|
||||||
|
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 = MainCore::instance()->m_settings.newPreset(dlg.group(), dlg.description());
|
||||||
|
m_deviceUISet->saveDeviceSetSettings(preset);
|
||||||
|
ui->presetTree->setCurrentItem(addPresetToTree(preset));
|
||||||
|
}
|
||||||
|
|
||||||
|
MainCore::instance()->m_settings.sortPresets();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::on_presetUpdate_clicked()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* item = ui->presetTree->currentItem();
|
||||||
|
const Preset* changedPreset = 0;
|
||||||
|
|
||||||
|
if(item != 0)
|
||||||
|
{
|
||||||
|
if(item->type() == PItem)
|
||||||
|
{
|
||||||
|
const Preset* preset = qvariant_cast<const Preset*>(item->data(0, Qt::UserRole));
|
||||||
|
|
||||||
|
if (preset != 0)
|
||||||
|
{
|
||||||
|
Preset* preset_mod = const_cast<Preset*>(preset);
|
||||||
|
m_deviceUISet->saveDeviceSetSettings(preset_mod);
|
||||||
|
changedPreset = preset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MainCore::instance()->m_settings.sortPresets();
|
||||||
|
ui->presetTree->clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < MainCore::instance()->m_settings.getPresetCount(); ++i)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *item_x = addPresetToTree(MainCore::instance()->m_settings.getPreset(i));
|
||||||
|
const Preset* preset_x = qvariant_cast<const Preset*>(item_x->data(0, Qt::UserRole));
|
||||||
|
|
||||||
|
if (changedPreset && (preset_x == changedPreset)) { // set cursor on changed preset
|
||||||
|
ui->presetTree->setCurrentItem(item_x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::on_presetEdit_clicked()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* item = ui->presetTree->currentItem();
|
||||||
|
QStringList groups;
|
||||||
|
bool change = false;
|
||||||
|
const Preset *changedPreset = 0;
|
||||||
|
QString newGroupName;
|
||||||
|
|
||||||
|
for(int i = 0; i < ui->presetTree->topLevelItemCount(); i++) {
|
||||||
|
groups.append(ui->presetTree->topLevelItem(i)->text(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
if (item->type() == PItem)
|
||||||
|
{
|
||||||
|
const Preset* preset = qvariant_cast<const Preset*>(item->data(0, Qt::UserRole));
|
||||||
|
AddPresetDialog dlg(groups, preset->getGroup(), this);
|
||||||
|
dlg.setDescription(preset->getDescription());
|
||||||
|
|
||||||
|
if (dlg.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
Preset* preset_mod = const_cast<Preset*>(preset);
|
||||||
|
preset_mod->setGroup(dlg.group());
|
||||||
|
preset_mod->setDescription(dlg.description());
|
||||||
|
change = true;
|
||||||
|
changedPreset = preset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (item->type() == PGroup)
|
||||||
|
{
|
||||||
|
AddPresetDialog dlg(groups, item->text(0), this);
|
||||||
|
dlg.showGroupOnly();
|
||||||
|
dlg.setDialogTitle("Edit preset group");
|
||||||
|
|
||||||
|
if (dlg.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
MainCore::instance()->m_settings.renamePresetGroup(item->text(0), dlg.group());
|
||||||
|
newGroupName = dlg.group();
|
||||||
|
change = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (change)
|
||||||
|
{
|
||||||
|
MainCore::instance()->m_settings.sortPresets();
|
||||||
|
ui->presetTree->clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < MainCore::instance()->m_settings.getPresetCount(); ++i)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *item_x = addPresetToTree(MainCore::instance()->m_settings.getPreset(i));
|
||||||
|
const Preset* preset_x = qvariant_cast<const Preset*>(item_x->data(0, Qt::UserRole));
|
||||||
|
|
||||||
|
if (changedPreset && (preset_x == changedPreset)) { // set cursor on changed preset
|
||||||
|
ui->presetTree->setCurrentItem(item_x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!changedPreset) // on group name change set cursor on the group that has been changed
|
||||||
|
{
|
||||||
|
for(int i = 0; i < ui->presetTree->topLevelItemCount(); i++)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* item = ui->presetTree->topLevelItem(i);
|
||||||
|
|
||||||
|
if (item->text(0) == newGroupName) {
|
||||||
|
ui->presetTree->setCurrentItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::on_presetExport_clicked()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* item = ui->presetTree->currentItem();
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
if (item->type() == PItem)
|
||||||
|
{
|
||||||
|
const Preset* preset = qvariant_cast<const Preset*>(item->data(0, Qt::UserRole));
|
||||||
|
QString base64Str = preset->serialize().toBase64();
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(
|
||||||
|
this,
|
||||||
|
tr("Open preset export file"),
|
||||||
|
".",
|
||||||
|
tr("Preset export files (*.prex)"),
|
||||||
|
0,
|
||||||
|
QFileDialog::DontUseNativeDialog
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fileName != "")
|
||||||
|
{
|
||||||
|
QFileInfo fileInfo(fileName);
|
||||||
|
|
||||||
|
if (fileInfo.suffix() != "prex") {
|
||||||
|
fileName += ".prex";
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile exportFile(fileName);
|
||||||
|
|
||||||
|
if (exportFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
QTextStream outstream(&exportFile);
|
||||||
|
outstream << base64Str;
|
||||||
|
exportFile.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, tr("Message"), tr("Cannot open file for writing"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::on_presetImport_clicked()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* item = ui->presetTree->currentItem();
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
QString group;
|
||||||
|
|
||||||
|
if (item->type() == PGroup) {
|
||||||
|
group = item->text(0);
|
||||||
|
} else if (item->type() == PItem) {
|
||||||
|
group = item->parent()->text(0);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
tr("Open preset export file"),
|
||||||
|
".",
|
||||||
|
tr("Preset export files (*.prex)"),
|
||||||
|
0,
|
||||||
|
QFileDialog::DontUseNativeDialog
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fileName != "")
|
||||||
|
{
|
||||||
|
QFile exportFile(fileName);
|
||||||
|
|
||||||
|
if (exportFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
QByteArray base64Str;
|
||||||
|
QTextStream instream(&exportFile);
|
||||||
|
instream >> base64Str;
|
||||||
|
exportFile.close();
|
||||||
|
|
||||||
|
Preset* preset = MainCore::instance()->m_settings.newPreset("", "");
|
||||||
|
preset->deserialize(QByteArray::fromBase64(base64Str));
|
||||||
|
preset->setGroup(group); // override with current group
|
||||||
|
|
||||||
|
ui->presetTree->setCurrentItem(addPresetToTree(preset));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, tr("Message"), tr("Cannot open file for reading"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::on_presetLoad_clicked()
|
||||||
|
{
|
||||||
|
qDebug() << "DeviceSetPresetsDialog::on_presetLoad_clicked";
|
||||||
|
|
||||||
|
QTreeWidgetItem* item = ui->presetTree->currentItem();
|
||||||
|
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
qDebug("DeviceSetPresetsDialog::on_presetLoad_clicked: item null");
|
||||||
|
updatePresetControls();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Preset* preset = qvariant_cast<const Preset*>(item->data(0, Qt::UserRole));
|
||||||
|
|
||||||
|
if (!preset)
|
||||||
|
{
|
||||||
|
qDebug("DeviceSetPresetsDialog::on_presetLoad_clicked: preset null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadDeviceSetPresetSettings(preset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::on_presetDelete_clicked()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* item = ui->presetTree->currentItem();
|
||||||
|
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
updatePresetControls();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (item->type() == PItem)
|
||||||
|
{
|
||||||
|
const Preset* preset = qvariant_cast<const Preset*>(item->data(0, Qt::UserRole));
|
||||||
|
|
||||||
|
if (preset)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
delete item;
|
||||||
|
MainCore::instance()->m_settings.deletePreset(preset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (item->type() == PGroup)
|
||||||
|
{
|
||||||
|
if (QMessageBox::question(
|
||||||
|
this,
|
||||||
|
tr("Delete preset group"),
|
||||||
|
tr("Do you want to delete preset group '%1'?").arg(item->text(0)),
|
||||||
|
QMessageBox::No | QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
MainCore::instance()->m_settings.deletePresetGroup(item->text(0));
|
||||||
|
|
||||||
|
ui->presetTree->clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < MainCore::instance()->m_settings.getPresetCount(); ++i) {
|
||||||
|
addPresetToTree(MainCore::instance()->m_settings.getPreset(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::on_presetTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||||
|
{
|
||||||
|
(void) current;
|
||||||
|
(void) previous;
|
||||||
|
updatePresetControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::on_presetTree_itemActivated(QTreeWidgetItem *item, int column)
|
||||||
|
{
|
||||||
|
(void) item;
|
||||||
|
(void) column;
|
||||||
|
on_presetLoad_clicked();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceSetPresetsDialog::loadDeviceSetPresetSettings(const Preset* preset)
|
||||||
|
{
|
||||||
|
qDebug("DeviceSetPresetsDialog::loadPresetSettings: preset [%s | %s]",
|
||||||
|
qPrintable(preset->getGroup()),
|
||||||
|
qPrintable(preset->getDescription()));
|
||||||
|
|
||||||
|
m_deviceUISet->loadDeviceSetSettings(preset, m_pluginAPI, m_workspaces, m_currentWorkspace);
|
||||||
|
m_presetLoaded = true;
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2022 F4EXB //
|
||||||
|
// written by Edouard Griffiths //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// (at your option) any later version. //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef SDRGUI_GUI_DEVICESETPRESETDIALOG_H_
|
||||||
|
#define SDRGUI_GUI_DEVICESETPRESETDIALOG_H_
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
#include "export.h"
|
||||||
|
|
||||||
|
class Preset;
|
||||||
|
class DeviceUISet;
|
||||||
|
class PluginAPI;
|
||||||
|
class Workspace;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DeviceSetPresetsDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SDRGUI_API DeviceSetPresetsDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit DeviceSetPresetsDialog(QWidget* parent = nullptr);
|
||||||
|
~DeviceSetPresetsDialog();
|
||||||
|
|
||||||
|
void setPresets(QList<Preset*>* presets) { m_deviceSetPresets = presets; }
|
||||||
|
void setDeviceUISet(DeviceUISet *deviceUISet) { m_deviceUISet = deviceUISet; }
|
||||||
|
void setPluginAPI(PluginAPI *pluginAPI) { m_pluginAPI = pluginAPI; }
|
||||||
|
void setCurrentWorkspace(Workspace *workspace) { m_currentWorkspace = workspace; }
|
||||||
|
void setWorkspaces(QList<Workspace*> *workspaces) { m_workspaces = workspaces; }
|
||||||
|
void populateTree(int deviceType);
|
||||||
|
bool wasPresetLoaded() const { return m_presetLoaded; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum {
|
||||||
|
PGroup,
|
||||||
|
PItem
|
||||||
|
};
|
||||||
|
|
||||||
|
Ui::DeviceSetPresetsDialog* ui;
|
||||||
|
QList<Preset*> *m_deviceSetPresets;
|
||||||
|
DeviceUISet *m_deviceUISet;
|
||||||
|
PluginAPI *m_pluginAPI;
|
||||||
|
Workspace *m_currentWorkspace;
|
||||||
|
QList<Workspace*> *m_workspaces;
|
||||||
|
bool m_presetLoaded;
|
||||||
|
|
||||||
|
QTreeWidgetItem* addPresetToTree(const Preset* preset);
|
||||||
|
void updatePresetControls();
|
||||||
|
void loadDeviceSetPresetSettings(const Preset* preset);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_presetSave_clicked();
|
||||||
|
void on_presetUpdate_clicked();
|
||||||
|
void on_presetEdit_clicked();
|
||||||
|
void on_presetExport_clicked();
|
||||||
|
void on_presetImport_clicked();
|
||||||
|
void on_presetLoad_clicked();
|
||||||
|
void on_presetDelete_clicked();
|
||||||
|
void on_presetTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||||
|
void on_presetTree_itemActivated(QTreeWidgetItem *item, int column);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SDRGUI_GUI_DEVICESETPRESETDIALOG_H_
|
|
@ -0,0 +1,264 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DeviceSetPresetsDialog</class>
|
||||||
|
<widget class="QDialog" name="DeviceSetPresetsDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>396</width>
|
||||||
|
<height>396</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Liberation Sans</family>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Device Set Presets</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeWidget" name="presetTree">
|
||||||
|
<property name="indentation">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="allColumnsShowFocus">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="headerMinimumSectionSize">
|
||||||
|
<number>5</number>
|
||||||
|
</attribute>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Freq (MHz)</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Center frequency in MHz</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>M</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Mode: R: Rx or source, T: Tx or sink</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Description</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="presetsControl">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="presetSave">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Save current settings as new preset</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/res.qrc">
|
||||||
|
<normaloff>:/create.png</normaloff>:/create.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="presetUpdate">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Update selected preset with current settings</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/res.qrc">
|
||||||
|
<normaloff>:/recycle.png</normaloff>:/recycle.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="presetEdit">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Edit preset details</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/res.qrc">
|
||||||
|
<normaloff>:/edit.png</normaloff>:/edit.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="presetExport">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Export current preset to file</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/res.qrc">
|
||||||
|
<normaloff>:/export.png</normaloff>:/export.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="presetImport">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Import preset from file into current group</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/res.qrc">
|
||||||
|
<normaloff>:/import.png</normaloff>:/import.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="presetDelete">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Delete selected preset</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/res.qrc">
|
||||||
|
<normaloff>:/bin.png</normaloff>:/bin.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="presetLoad">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Load selected preset</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/res.qrc">
|
||||||
|
<normaloff>:/load.png</normaloff>:/load.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../resources/res.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>DeviceSetPresetsDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>DeviceSetPresetsDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -6,10 +6,16 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>392</width>
|
<width>376</width>
|
||||||
<height>414</height>
|
<height>399</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<family>Liberation Sans</family>
|
<family>Liberation Sans</family>
|
||||||
|
@ -19,187 +25,175 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Feature presets</string>
|
<string>Feature presets</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<property name="geometry">
|
<item>
|
||||||
<rect>
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<x>40</x>
|
<property name="sizePolicy">
|
||||||
<y>380</y>
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<width>341</width>
|
<horstretch>0</horstretch>
|
||||||
<height>32</height>
|
<verstretch>0</verstretch>
|
||||||
</rect>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<enum>Qt::Horizontal</enum>
|
<item>
|
||||||
</property>
|
<widget class="QTreeWidget" name="presetsTree">
|
||||||
<property name="standardButtons">
|
<property name="indentation">
|
||||||
<set>QDialogButtonBox::Close</set>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="allColumnsShowFocus">
|
||||||
<widget class="QWidget" name="widget" native="true">
|
<bool>true</bool>
|
||||||
<property name="geometry">
|
</property>
|
||||||
<rect>
|
<property name="columnCount">
|
||||||
<x>0</x>
|
<number>1</number>
|
||||||
<y>10</y>
|
</property>
|
||||||
<width>392</width>
|
<attribute name="headerMinimumSectionSize">
|
||||||
<height>310</height>
|
<number>5</number>
|
||||||
</rect>
|
</attribute>
|
||||||
</property>
|
<column>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<property name="text">
|
||||||
<item>
|
<string>Description</string>
|
||||||
<widget class="QTreeWidget" name="presetsTree">
|
</property>
|
||||||
<property name="indentation">
|
</column>
|
||||||
<number>5</number>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="allColumnsShowFocus">
|
</layout>
|
||||||
<bool>true</bool>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="columnCount">
|
<item>
|
||||||
<number>1</number>
|
<layout class="QHBoxLayout" name="presetsControl">
|
||||||
</property>
|
<item>
|
||||||
<attribute name="headerMinimumSectionSize">
|
<widget class="QToolButton" name="presetSave">
|
||||||
<number>5</number>
|
<property name="toolTip">
|
||||||
</attribute>
|
<string>Save current settings as new preset</string>
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Description</string>
|
|
||||||
</property>
|
</property>
|
||||||
</column>
|
<property name="text">
|
||||||
</widget>
|
<string>...</string>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
<property name="icon">
|
||||||
</widget>
|
<iconset resource="../resources/res.qrc">
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<normaloff>:/create.png</normaloff>:/create.png</iconset>
|
||||||
<property name="geometry">
|
</property>
|
||||||
<rect>
|
<property name="iconSize">
|
||||||
<x>0</x>
|
<size>
|
||||||
<y>330</y>
|
<width>16</width>
|
||||||
<width>392</width>
|
<height>16</height>
|
||||||
<height>34</height>
|
</size>
|
||||||
</rect>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<layout class="QHBoxLayout" name="presetsControl">
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="presetSave">
|
<widget class="QToolButton" name="presetUpdate">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Save current settings as new preset</string>
|
<string>Update selected preset with current settings</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../resources/res.qrc">
|
<iconset resource="../resources/res.qrc">
|
||||||
<normaloff>:/create.png</normaloff>:/create.png</iconset>
|
<normaloff>:/recycle.png</normaloff>:/recycle.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
<width>16</width>
|
<width>16</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="presetUpdate">
|
<widget class="QToolButton" name="presetEdit">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Update selected preset with current settings</string>
|
<string>Edit preset details</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../resources/res.qrc">
|
<iconset resource="../resources/res.qrc">
|
||||||
<normaloff>:/recycle.png</normaloff>:/recycle.png</iconset>
|
<normaloff>:/edit.png</normaloff>:/edit.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
</widget>
|
||||||
<size>
|
</item>
|
||||||
<width>16</width>
|
<item>
|
||||||
<height>16</height>
|
<spacer name="horizontalSpacer">
|
||||||
</size>
|
<property name="orientation">
|
||||||
</property>
|
<enum>Qt::Horizontal</enum>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
<property name="sizeHint" stdset="0">
|
||||||
<item>
|
<size>
|
||||||
<widget class="QToolButton" name="presetEdit">
|
<width>40</width>
|
||||||
<property name="toolTip">
|
<height>20</height>
|
||||||
<string>Edit preset details</string>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
</spacer>
|
||||||
<string/>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
<property name="icon">
|
<widget class="QToolButton" name="presetDelete">
|
||||||
<iconset resource="../resources/res.qrc">
|
<property name="toolTip">
|
||||||
<normaloff>:/edit.png</normaloff>:/edit.png</iconset>
|
<string>Delete selected preset</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="text">
|
||||||
</item>
|
<string>...</string>
|
||||||
<item>
|
</property>
|
||||||
<spacer name="horizontalSpacer">
|
<property name="icon">
|
||||||
<property name="orientation">
|
<iconset resource="../resources/res.qrc">
|
||||||
<enum>Qt::Horizontal</enum>
|
<normaloff>:/bin.png</normaloff>:/bin.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>16</width>
|
||||||
<height>20</height>
|
<height>16</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="presetDelete">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="toolTip">
|
<property name="orientation">
|
||||||
<string>Delete selected preset</string>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="sizeHint" stdset="0">
|
||||||
<string>...</string>
|
<size>
|
||||||
</property>
|
<width>40</width>
|
||||||
<property name="icon">
|
<height>20</height>
|
||||||
<iconset resource="../resources/res.qrc">
|
</size>
|
||||||
<normaloff>:/bin.png</normaloff>:/bin.png</iconset>
|
</property>
|
||||||
</property>
|
</spacer>
|
||||||
<property name="iconSize">
|
</item>
|
||||||
<size>
|
<item>
|
||||||
<width>16</width>
|
<widget class="QToolButton" name="presetLoad">
|
||||||
<height>16</height>
|
<property name="toolTip">
|
||||||
</size>
|
<string>Load selected preset</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="text">
|
||||||
</item>
|
<string>...</string>
|
||||||
<item>
|
</property>
|
||||||
<spacer name="horizontalSpacer_2">
|
<property name="icon">
|
||||||
<property name="orientation">
|
<iconset resource="../resources/res.qrc">
|
||||||
<enum>Qt::Horizontal</enum>
|
<normaloff>:/load.png</normaloff>:/load.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>16</width>
|
||||||
<height>20</height>
|
<height>16</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
<widget class="QToolButton" name="presetLoad">
|
</item>
|
||||||
<property name="toolTip">
|
<item>
|
||||||
<string>Load selected preset</string>
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
</property>
|
<property name="orientation">
|
||||||
<property name="text">
|
<enum>Qt::Horizontal</enum>
|
||||||
<string>...</string>
|
</property>
|
||||||
</property>
|
<property name="standardButtons">
|
||||||
<property name="icon">
|
<set>QDialogButtonBox::Close</set>
|
||||||
<iconset resource="../resources/res.qrc">
|
</property>
|
||||||
<normaloff>:/load.png</normaloff>:/load.png</iconset>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="iconSize">
|
</layout>
|
||||||
<size>
|
|
||||||
<width>16</width>
|
|
||||||
<height>16</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../resources/res.qrc"/>
|
<include location="../resources/res.qrc"/>
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
#include "gui/ambedevicesdialog.h"
|
#include "gui/ambedevicesdialog.h"
|
||||||
#include "gui/workspace.h"
|
#include "gui/workspace.h"
|
||||||
#include "gui/featurepresetsdialog.h"
|
#include "gui/featurepresetsdialog.h"
|
||||||
|
#include "gui/devicesetpresetsdialog.h"
|
||||||
#include "gui/commandsdialog.h"
|
#include "gui/commandsdialog.h"
|
||||||
#include "gui/configurationsdialog.h"
|
#include "gui/configurationsdialog.h"
|
||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
|
@ -542,6 +543,12 @@ void MainWindow::sampleSourceCreate(
|
||||||
this,
|
this,
|
||||||
[=](){ this->removeDeviceSet(deviceGUI->getIndex()); }
|
[=](){ this->removeDeviceSet(deviceGUI->getIndex()); }
|
||||||
);
|
);
|
||||||
|
QObject::connect(
|
||||||
|
deviceGUI,
|
||||||
|
&DeviceGUI::deviceSetPresetsDialogRequested,
|
||||||
|
this,
|
||||||
|
&MainWindow::openDeviceSetPresetsDialog
|
||||||
|
);
|
||||||
|
|
||||||
deviceAPI->getSampleSource()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
|
deviceAPI->getSampleSource()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
|
||||||
deviceUISet->m_deviceGUI = deviceGUI;
|
deviceUISet->m_deviceGUI = deviceGUI;
|
||||||
|
@ -753,6 +760,13 @@ void MainWindow::sampleSinkCreate(
|
||||||
this,
|
this,
|
||||||
[=](){ this->removeDeviceSet(deviceGUI->getIndex()); }
|
[=](){ this->removeDeviceSet(deviceGUI->getIndex()); }
|
||||||
);
|
);
|
||||||
|
QObject::connect(
|
||||||
|
deviceGUI,
|
||||||
|
&DeviceGUI::deviceSetPresetsDialogRequested,
|
||||||
|
this,
|
||||||
|
&MainWindow::openDeviceSetPresetsDialog
|
||||||
|
);
|
||||||
|
|
||||||
deviceAPI->getSampleSink()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
|
deviceAPI->getSampleSink()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
|
||||||
deviceUISet->m_deviceGUI = deviceGUI;
|
deviceUISet->m_deviceGUI = deviceGUI;
|
||||||
const PluginInterface::SamplingDevice *selectedDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
|
const PluginInterface::SamplingDevice *selectedDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
|
||||||
|
@ -937,6 +951,13 @@ void MainWindow::sampleMIMOCreate(
|
||||||
this,
|
this,
|
||||||
[=](){ this->removeDeviceSet(deviceGUI->getIndex()); }
|
[=](){ this->removeDeviceSet(deviceGUI->getIndex()); }
|
||||||
);
|
);
|
||||||
|
QObject::connect(
|
||||||
|
deviceGUI,
|
||||||
|
&DeviceGUI::deviceSetPresetsDialogRequested,
|
||||||
|
this,
|
||||||
|
&MainWindow::openDeviceSetPresetsDialog
|
||||||
|
);
|
||||||
|
|
||||||
deviceAPI->getSampleMIMO()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
|
deviceAPI->getSampleMIMO()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
|
||||||
deviceUISet->m_deviceGUI = deviceGUI;
|
deviceUISet->m_deviceGUI = deviceGUI;
|
||||||
const PluginInterface::SamplingDevice *selectedDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
|
const PluginInterface::SamplingDevice *selectedDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
|
||||||
|
@ -1591,44 +1612,6 @@ void MainWindow::updatePresetControls()
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem* MainWindow::addPresetToTree(const Preset* preset)
|
|
||||||
{
|
|
||||||
// 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 == 0)
|
|
||||||
// {
|
|
||||||
// QStringList sl;
|
|
||||||
// sl.append(preset->getGroup());
|
|
||||||
// group = new QTreeWidgetItem(ui->presetTree, sl, PGroup);
|
|
||||||
// group->setFirstColumnSpanned(true);
|
|
||||||
// group->setExpanded(true);
|
|
||||||
// ui->presetTree->sortByColumn(0, Qt::AscendingOrder);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// QStringList sl;
|
|
||||||
// sl.append(QString("%1").arg(preset->getCenterFrequency() / 1e6f, 0, 'f', 3)); // frequency column
|
|
||||||
// sl.append(QString("%1").arg(preset->isSourcePreset() ? 'R' : preset->isSinkPreset() ? 'T' : preset->isMIMOPreset() ? 'M' : 'X')); // mode column
|
|
||||||
// sl.append(preset->getDescription()); // description column
|
|
||||||
// PresetItem* item = new PresetItem(group, sl, preset->getCenterFrequency(), PItem);
|
|
||||||
// item->setTextAlignment(0, Qt::AlignRight);
|
|
||||||
// item->setData(0, Qt::UserRole, QVariant::fromValue(preset));
|
|
||||||
// ui->presetTree->resizeColumnToContents(0); // Resize frequency column to minimum
|
|
||||||
// ui->presetTree->resizeColumnToContents(1); // Resize mode column to minimum
|
|
||||||
|
|
||||||
// updatePresetControls();
|
|
||||||
// return item;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::applySettings()
|
void MainWindow::applySettings()
|
||||||
{
|
{
|
||||||
// loadDeviceSetPresetSettings(m_mainCore->m_settings.getWorkingPreset(), 0);
|
// loadDeviceSetPresetSettings(m_mainCore->m_settings.getWorkingPreset(), 0);
|
||||||
|
@ -1664,7 +1647,15 @@ bool MainWindow::handleMessage(const Message& cmd)
|
||||||
if (MainCore::MsgLoadPreset::match(cmd))
|
if (MainCore::MsgLoadPreset::match(cmd))
|
||||||
{
|
{
|
||||||
MainCore::MsgLoadPreset& notif = (MainCore::MsgLoadPreset&) cmd;
|
MainCore::MsgLoadPreset& notif = (MainCore::MsgLoadPreset&) cmd;
|
||||||
loadDeviceSetPresetSettings(notif.getPreset(), notif.getDeviceSetIndex());
|
int deviceSetIndex = notif.getDeviceSetIndex();
|
||||||
|
const Preset *preset = notif.getPreset();
|
||||||
|
|
||||||
|
if (deviceSetIndex < (int) m_deviceUIs.size())
|
||||||
|
{
|
||||||
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
||||||
|
deviceUISet->loadDeviceSetSettings(preset, m_pluginManager->getPluginAPI(), &m_workspaces, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (MainCore::MsgSavePreset::match(cmd))
|
else if (MainCore::MsgSavePreset::match(cmd))
|
||||||
|
@ -2303,14 +2294,14 @@ void MainWindow::on_presetTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
||||||
{
|
{
|
||||||
(void) current;
|
(void) current;
|
||||||
(void) previous;
|
(void) previous;
|
||||||
updatePresetControls();
|
// updatePresetControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_presetTree_itemActivated(QTreeWidgetItem *item, int column)
|
void MainWindow::on_presetTree_itemActivated(QTreeWidgetItem *item, int column)
|
||||||
{
|
{
|
||||||
(void) item;
|
(void) item;
|
||||||
(void) column;
|
(void) column;
|
||||||
on_presetLoad_clicked();
|
// on_presetLoad_clicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_action_Quick_Start_triggered()
|
void MainWindow::on_action_Quick_Start_triggered()
|
||||||
|
@ -2787,6 +2778,36 @@ void MainWindow::openFeaturePresetsDialog(QPoint p, Workspace *workspace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::openDeviceSetPresetsDialog(QPoint p, DeviceGUI *deviceGUI)
|
||||||
|
{
|
||||||
|
Workspace *workspace = m_workspaces[deviceGUI->getWorkspaceIndex()];
|
||||||
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceGUI->getIndex()];
|
||||||
|
|
||||||
|
DeviceSetPresetsDialog dialog;
|
||||||
|
dialog.setDeviceUISet(deviceUISet);
|
||||||
|
dialog.setPresets(m_mainCore->m_settings.getPresets());
|
||||||
|
dialog.setPluginAPI(m_pluginManager->getPluginAPI());
|
||||||
|
dialog.setCurrentWorkspace(workspace);
|
||||||
|
dialog.setWorkspaces(&m_workspaces);
|
||||||
|
dialog.populateTree((int) deviceGUI->getDeviceType());
|
||||||
|
dialog.move(p);
|
||||||
|
dialog.exec();
|
||||||
|
|
||||||
|
// if (dialog.wasPresetLoaded())
|
||||||
|
// {
|
||||||
|
// for (int i = 0; i < m_featureUIs[0]->getNumberOfFeatures(); i++)
|
||||||
|
// {
|
||||||
|
// FeatureGUI *gui = m_featureUIs[0]->getFeatureGuiAt(i);
|
||||||
|
// QObject::connect(
|
||||||
|
// gui,
|
||||||
|
// &FeatureGUI::moveToWorkspace,
|
||||||
|
// this,
|
||||||
|
// [=](int wsIndexDest){ this->featureMove(gui, wsIndexDest); }
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::deleteFeature(int featureSetIndex, int featureIndex)
|
void MainWindow::deleteFeature(int featureSetIndex, int featureIndex)
|
||||||
{
|
{
|
||||||
if ((featureSetIndex >= 0) && (featureSetIndex < (int) m_featureUIs.size()))
|
if ((featureSetIndex >= 0) && (featureSetIndex < (int) m_featureUIs.size()))
|
||||||
|
|
|
@ -138,7 +138,6 @@ private:
|
||||||
void createStatusBar();
|
void createStatusBar();
|
||||||
void closeEvent(QCloseEvent*);
|
void closeEvent(QCloseEvent*);
|
||||||
void updatePresetControls();
|
void updatePresetControls();
|
||||||
QTreeWidgetItem* addPresetToTree(const Preset* preset);
|
|
||||||
void applySettings();
|
void applySettings();
|
||||||
|
|
||||||
void removeDeviceSet(int deviceSetIndex);
|
void removeDeviceSet(int deviceSetIndex);
|
||||||
|
@ -215,6 +214,7 @@ private slots:
|
||||||
void mainSpectrumMove(MainSpectrumGUI *gui, int wsIndexDestnation);
|
void mainSpectrumMove(MainSpectrumGUI *gui, int wsIndexDestnation);
|
||||||
void mainSpectrumShow(MainSpectrumGUI *gui);
|
void mainSpectrumShow(MainSpectrumGUI *gui);
|
||||||
void showAllChannels(int deviceSetIndex);
|
void showAllChannels(int deviceSetIndex);
|
||||||
|
void openDeviceSetPresetsDialog(QPoint p, DeviceGUI *deviceGUI);
|
||||||
void on_action_Quick_Start_triggered();
|
void on_action_Quick_Start_triggered();
|
||||||
void on_action_Main_Window_triggered();
|
void on_action_Main_Window_triggered();
|
||||||
void on_action_Loaded_Plugins_triggered();
|
void on_action_Loaded_Plugins_triggered();
|
||||||
|
|
Ładowanie…
Reference in New Issue