28 changed files with 1397 additions and 41 deletions
@ -0,0 +1,79 @@
@@ -0,0 +1,79 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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 "util/simpleserializer.h" |
||||
|
||||
#include "pluginpreset.h" |
||||
|
||||
PluginPreset::PluginPreset() |
||||
{ |
||||
resetToDefaults(); |
||||
} |
||||
|
||||
PluginPreset::PluginPreset(const PluginPreset& other) : |
||||
m_group(other.m_group), |
||||
m_description(other.m_description), |
||||
m_pluginIdURI(other.m_pluginIdURI), |
||||
m_config(other.m_config) |
||||
{} |
||||
|
||||
void PluginPreset::resetToDefaults() |
||||
{ |
||||
m_group = "default"; |
||||
m_description = "no name"; |
||||
m_pluginIdURI = ""; |
||||
m_config = QByteArray(); |
||||
} |
||||
|
||||
QByteArray PluginPreset::serialize() const |
||||
{ |
||||
SimpleSerializer s(1); |
||||
|
||||
s.writeString(1, m_group); |
||||
s.writeString(2, m_description); |
||||
s.writeString(3, m_pluginIdURI); |
||||
s.writeBlob(4, m_config); |
||||
|
||||
return s.final(); |
||||
} |
||||
|
||||
bool PluginPreset::deserialize(const QByteArray& data) |
||||
{ |
||||
SimpleDeserializer d(data); |
||||
|
||||
if (!d.isValid()) |
||||
{ |
||||
resetToDefaults(); |
||||
return false; |
||||
} |
||||
|
||||
if (d.getVersion() == 1) |
||||
{ |
||||
d.readString(1, &m_group, "default"); |
||||
d.readString(2, &m_description, "no name"); |
||||
d.readString(3, &m_pluginIdURI, ""); |
||||
d.readBlob(4, &m_config); |
||||
|
||||
return true; |
||||
} |
||||
else |
||||
{ |
||||
resetToDefaults(); |
||||
return false; |
||||
} |
||||
} |
||||
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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 SDRBASE_SETTINGS_PLUGINPRESET_H_ |
||||
#define SDRBASE_SETTINGS_PLUGINPRESET_H_ |
||||
|
||||
#include <QString> |
||||
#include <QByteArray> |
||||
#include <QMetaType> |
||||
|
||||
#include "export.h" |
||||
|
||||
class SDRBASE_API PluginPreset { |
||||
public: |
||||
|
||||
PluginPreset(); |
||||
PluginPreset(const PluginPreset& other); |
||||
void resetToDefaults(); |
||||
|
||||
QByteArray serialize() const; |
||||
bool deserialize(const QByteArray& data); |
||||
|
||||
void setGroup(const QString& group) { m_group = group; } |
||||
const QString& getGroup() const { return m_group; } |
||||
void setDescription(const QString& description) { m_description = description; } |
||||
const QString& getDescription() const { return m_description; } |
||||
void setConfig(const QString& pluginIdURI, const QByteArray& config) { m_pluginIdURI = pluginIdURI; m_config = config; } |
||||
const QByteArray& getConfig() const { return m_config; } |
||||
const QString& getPluginIdURI() const { return m_pluginIdURI; } |
||||
|
||||
static bool presetCompare(const PluginPreset *p1, PluginPreset *p2) |
||||
{ |
||||
if (p1->m_group != p2->m_group) |
||||
{ |
||||
return p1->m_group < p2->m_group; |
||||
} |
||||
else |
||||
{ |
||||
return p1->m_description < p2->m_description; |
||||
} |
||||
} |
||||
|
||||
private: |
||||
// group and preset description
|
||||
QString m_group; |
||||
QString m_description; |
||||
QString m_pluginIdURI; //!< Plugin type ID in URI form
|
||||
QByteArray m_config; |
||||
|
||||
}; |
||||
|
||||
Q_DECLARE_METATYPE(const PluginPreset*) |
||||
Q_DECLARE_METATYPE(PluginPreset*) |
||||
|
||||
#endif // SDRBASE_SETTINGS_PLUGINPRESET_H_
|
||||
@ -0,0 +1,430 @@
@@ -0,0 +1,430 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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 <QMessageBox> |
||||
#include <QDebug> |
||||
|
||||
#include "gui/addpresetdialog.h" |
||||
#include "settings/serializableinterface.h" |
||||
#include "settings/pluginpreset.h" |
||||
#include "maincore.h" |
||||
|
||||
#include "pluginpresetsdialog.h" |
||||
#include "ui_pluginpresetsdialog.h" |
||||
|
||||
PluginPresetsDialog::PluginPresetsDialog(const QString& pluginId, QWidget* parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::PluginPresetsDialog), |
||||
m_pluginId(pluginId), |
||||
m_pluginPresets(nullptr), |
||||
m_serializableInterface(nullptr), |
||||
m_presetLoaded(false) |
||||
{ |
||||
ui->setupUi(this); |
||||
} |
||||
|
||||
PluginPresetsDialog::~PluginPresetsDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void PluginPresetsDialog::populateTree() |
||||
{ |
||||
if (!m_pluginPresets) { |
||||
return; |
||||
} |
||||
|
||||
QList<PluginPreset*>::const_iterator it = m_pluginPresets->begin(); |
||||
int middleIndex = m_pluginPresets->size() / 2; |
||||
QTreeWidgetItem *treeItem; |
||||
ui->presetsTree->clear(); |
||||
|
||||
for (int i = 0; it != m_pluginPresets->end(); ++it, i++) |
||||
{ |
||||
const PluginPreset *preset = *it; |
||||
treeItem = addPresetToTree(preset); |
||||
|
||||
if (i == middleIndex) { |
||||
ui->presetsTree->setCurrentItem(treeItem); |
||||
} |
||||
} |
||||
|
||||
updatePresetControls(); |
||||
} |
||||
|
||||
QTreeWidgetItem* PluginPresetsDialog::addPresetToTree(const PluginPreset* preset) |
||||
{ |
||||
QTreeWidgetItem* group = nullptr; |
||||
|
||||
for (int i = 0; i < ui->presetsTree->topLevelItemCount(); i++) |
||||
{ |
||||
if (ui->presetsTree->topLevelItem(i)->text(0) == preset->getGroup()) |
||||
{ |
||||
group = ui->presetsTree->topLevelItem(i); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (!group) |
||||
{ |
||||
QStringList sl; |
||||
sl.append(preset->getGroup()); |
||||
group = new QTreeWidgetItem(ui->presetsTree, sl, PGroup); |
||||
group->setFirstColumnSpanned(true); |
||||
group->setExpanded(true); |
||||
ui->presetsTree->sortByColumn(0, Qt::AscendingOrder); |
||||
// Only show group when it contains presets for this pluging
|
||||
if (preset->getPluginIdURI() != m_pluginId) { |
||||
group->setHidden(true); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
if (preset->getPluginIdURI() == m_pluginId) { |
||||
group->setHidden(false); |
||||
} |
||||
} |
||||
|
||||
QStringList sl; |
||||
sl.append(preset->getDescription()); |
||||
QTreeWidgetItem* item = new QTreeWidgetItem(group, sl, PItem); // description column
|
||||
item->setTextAlignment(0, Qt::AlignLeft); |
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(preset)); |
||||
// Only show presets for this plugin
|
||||
if (preset->getPluginIdURI() != m_pluginId) { |
||||
item->setHidden(true); |
||||
} |
||||
|
||||
updatePresetControls(); |
||||
return item; |
||||
} |
||||
|
||||
void PluginPresetsDialog::updatePresetControls() |
||||
{ |
||||
ui->presetsTree->resizeColumnToContents(0); |
||||
|
||||
if (ui->presetsTree->currentItem()) |
||||
{ |
||||
ui->presetDelete->setEnabled(true); |
||||
ui->presetLoad->setEnabled(true); |
||||
} |
||||
else |
||||
{ |
||||
ui->presetDelete->setEnabled(false); |
||||
ui->presetLoad->setEnabled(false); |
||||
} |
||||
} |
||||
|
||||
void PluginPresetsDialog::on_presetSave_clicked() |
||||
{ |
||||
QStringList groups; |
||||
QString group; |
||||
QString description = ""; |
||||
|
||||
for (int i = 0; i < ui->presetsTree->topLevelItemCount(); i++) { |
||||
groups.append(ui->presetsTree->topLevelItem(i)->text(0)); |
||||
} |
||||
|
||||
QTreeWidgetItem* item = ui->presetsTree->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) |
||||
{ |
||||
PluginPreset* preset = newPreset(dlg.group(), dlg.description()); |
||||
savePresetSettings(preset); |
||||
ui->presetsTree->setCurrentItem(addPresetToTree(preset)); |
||||
} |
||||
|
||||
sortPresets(); |
||||
} |
||||
|
||||
void PluginPresetsDialog::on_presetUpdate_clicked() |
||||
{ |
||||
QTreeWidgetItem* item = ui->presetsTree->currentItem(); |
||||
const PluginPreset* changedPreset = nullptr; |
||||
|
||||
if (item) |
||||
{ |
||||
if( item->type() == PItem) |
||||
{ |
||||
const PluginPreset* preset = qvariant_cast<const PluginPreset*>(item->data(0, Qt::UserRole)); |
||||
|
||||
if (preset) |
||||
{ |
||||
PluginPreset* preset_mod = const_cast<PluginPreset*>(preset); |
||||
savePresetSettings(preset_mod); |
||||
changedPreset = preset; |
||||
} |
||||
} |
||||
} |
||||
|
||||
sortPresets(); |
||||
ui->presetsTree->clear(); |
||||
|
||||
for (int i = 0; i < m_pluginPresets->size(); ++i) |
||||
{ |
||||
QTreeWidgetItem *item_x = addPresetToTree(m_pluginPresets->at(i)); |
||||
const PluginPreset* preset_x = qvariant_cast<const PluginPreset*>(item_x->data(0, Qt::UserRole)); |
||||
|
||||
if (changedPreset && (preset_x == changedPreset)) { // set cursor on changed preset
|
||||
ui->presetsTree->setCurrentItem(item_x); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void PluginPresetsDialog::on_presetEdit_clicked() |
||||
{ |
||||
QTreeWidgetItem* item = ui->presetsTree->currentItem(); |
||||
QStringList groups; |
||||
bool change = false; |
||||
const PluginPreset *changedPreset = nullptr; |
||||
QString newGroupName; |
||||
|
||||
for (int i = 0; i < ui->presetsTree->topLevelItemCount(); i++) { |
||||
groups.append(ui->presetsTree->topLevelItem(i)->text(0)); |
||||
} |
||||
|
||||
if (item) |
||||
{ |
||||
if (item->type() == PItem) |
||||
{ |
||||
const PluginPreset* preset = qvariant_cast<const PluginPreset*>(item->data(0, Qt::UserRole)); |
||||
AddPresetDialog dlg(groups, preset->getGroup(), this); |
||||
dlg.setDescription(preset->getDescription()); |
||||
|
||||
if (dlg.exec() == QDialog::Accepted) |
||||
{ |
||||
PluginPreset* preset_mod = const_cast<PluginPreset*>(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) |
||||
{ |
||||
renamePresetGroup(item->text(0), dlg.group()); |
||||
newGroupName = dlg.group(); |
||||
change = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (change) |
||||
{ |
||||
sortPresets(); |
||||
ui->presetsTree->clear(); |
||||
|
||||
for (int i = 0; i < m_pluginPresets->size(); ++i) |
||||
{ |
||||
QTreeWidgetItem *item_x = addPresetToTree(m_pluginPresets->at(i)); |
||||
const PluginPreset* preset_x = qvariant_cast<const PluginPreset*>(item_x->data(0, Qt::UserRole)); |
||||
|
||||
if (changedPreset && (preset_x == changedPreset)) { // set cursor on changed preset
|
||||
ui->presetsTree->setCurrentItem(item_x); |
||||
} |
||||
} |
||||
|
||||
if (!changedPreset) // on group name change set cursor on the group that has been changed
|
||||
{ |
||||
for(int i = 0; i < ui->presetsTree->topLevelItemCount(); i++) |
||||
{ |
||||
QTreeWidgetItem* item = ui->presetsTree->topLevelItem(i); |
||||
|
||||
if (item->text(0) == newGroupName) { |
||||
ui->presetsTree->setCurrentItem(item); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void PluginPresetsDialog::on_presetDelete_clicked() |
||||
{ |
||||
QTreeWidgetItem* item = ui->presetsTree->currentItem(); |
||||
|
||||
if (item == 0) |
||||
{ |
||||
updatePresetControls(); |
||||
return; |
||||
} |
||||
else |
||||
{ |
||||
if (item->type() == PItem) |
||||
{ |
||||
const PluginPreset* preset = qvariant_cast<const PluginPreset*>(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; |
||||
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) |
||||
{ |
||||
deletePresetGroup(item->text(0)); |
||||
|
||||
ui->presetsTree->clear(); |
||||
|
||||
for (int i = 0; i < m_pluginPresets->size(); ++i) { |
||||
addPresetToTree(m_pluginPresets->at(i)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void PluginPresetsDialog::on_presetLoad_clicked() |
||||
{ |
||||
qDebug() << "PluginPresetsDialog::on_presetLoad_clicked"; |
||||
|
||||
QTreeWidgetItem* item = ui->presetsTree->currentItem(); |
||||
|
||||
if (!item) |
||||
{ |
||||
qDebug("PluginPresetsDialog::on_presetLoad_clicked: item null"); |
||||
updatePresetControls(); |
||||
return; |
||||
} |
||||
|
||||
const PluginPreset* preset = qvariant_cast<const PluginPreset*>(item->data(0, Qt::UserRole)); |
||||
|
||||
if (!preset) |
||||
{ |
||||
qDebug("PluginPresetsDialog::on_presetLoad_clicked: preset null"); |
||||
return; |
||||
} |
||||
|
||||
loadPresetSettings(preset); |
||||
} |
||||
|
||||
void PluginPresetsDialog::on_presetTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous) |
||||
{ |
||||
(void) current; |
||||
(void) previous; |
||||
updatePresetControls(); |
||||
} |
||||
|
||||
void PluginPresetsDialog::on_presetTree_itemActivated(QTreeWidgetItem *item, int column) |
||||
{ |
||||
(void) item; |
||||
(void) column; |
||||
on_presetLoad_clicked(); |
||||
} |
||||
|
||||
PluginPreset* PluginPresetsDialog::newPreset(const QString& group, const QString& description) |
||||
{ |
||||
PluginPreset* preset = new PluginPreset(); |
||||
preset->setGroup(group); |
||||
preset->setDescription(description); |
||||
addPreset(preset); |
||||
return preset; |
||||
} |
||||
|
||||
void PluginPresetsDialog::addPreset(PluginPreset *preset) |
||||
{ |
||||
m_pluginPresets->append(preset); |
||||
} |
||||
|
||||
void PluginPresetsDialog::savePresetSettings(PluginPreset* preset) |
||||
{ |
||||
qDebug("PluginPresetsDialog::savePresetSettings: preset [%s | %s]", |
||||
qPrintable(preset->getGroup()), |
||||
qPrintable(preset->getDescription())); |
||||
|
||||
preset->setConfig(m_pluginId, m_serializableInterface->serialize()); |
||||
} |
||||
|
||||
void PluginPresetsDialog::loadPresetSettings(const PluginPreset* preset) |
||||
{ |
||||
qDebug("PluginPresetsDialog::loadPresetSettings: preset [%s | %s]", |
||||
qPrintable(preset->getGroup()), |
||||
qPrintable(preset->getDescription())); |
||||
|
||||
m_serializableInterface->deserialize(preset->getConfig()); |
||||
|
||||
m_presetLoaded = true; |
||||
} |
||||
|
||||
void PluginPresetsDialog::sortPresets() |
||||
{ |
||||
std::sort(m_pluginPresets->begin(), m_pluginPresets->end(), PluginPreset::presetCompare); |
||||
} |
||||
|
||||
void PluginPresetsDialog::renamePresetGroup(const QString& oldGroupName, const QString& newGroupName) |
||||
{ |
||||
for (int i = 0; i < m_pluginPresets->size(); i++) |
||||
{ |
||||
if (m_pluginPresets->at(i)->getGroup() == oldGroupName) |
||||
{ |
||||
PluginPreset *preset_mod = const_cast<PluginPreset*>(m_pluginPresets->at(i)); |
||||
preset_mod->setGroup(newGroupName); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void PluginPresetsDialog::deletePreset(const PluginPreset* preset) |
||||
{ |
||||
m_pluginPresets->removeAll((PluginPreset*) preset); |
||||
delete (PluginPreset*) preset; |
||||
} |
||||
|
||||
void PluginPresetsDialog::deletePresetGroup(const QString& groupName) |
||||
{ |
||||
QList<PluginPreset*>::iterator it = m_pluginPresets->begin(); |
||||
|
||||
while (it != m_pluginPresets->end()) |
||||
{ |
||||
if ((*it)->getGroup() == groupName) { |
||||
it = m_pluginPresets->erase(it); |
||||
} else { |
||||
++it; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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_PLUGINPRESETSDIALOG_H_ |
||||
#define SDRGUI_GUI_PLUGINPRESETSDIALOG_H_ |
||||
|
||||
#include <QDialog> |
||||
#include <QList> |
||||
#include <QTreeWidgetItem> |
||||
|
||||
#include "export.h" |
||||
|
||||
class PluginPreset; |
||||
class SerializableInterface; |
||||
class WebAPIAdapterInterface; |
||||
class PluginAPI; |
||||
class Workspace; |
||||
|
||||
namespace Ui { |
||||
class PluginPresetsDialog; |
||||
} |
||||
|
||||
class SDRGUI_API PluginPresetsDialog : public QDialog { |
||||
Q_OBJECT |
||||
public: |
||||
explicit PluginPresetsDialog(const QString& pluginId, QWidget* parent = nullptr); |
||||
~PluginPresetsDialog(); |
||||
void setPresets(QList<PluginPreset*>* presets) { m_pluginPresets = presets; } |
||||
void setSerializableInterface(SerializableInterface *serializableInterface) { m_serializableInterface = serializableInterface; } |
||||
void populateTree(); |
||||
bool wasPresetLoaded() const { return m_presetLoaded; } |
||||
|
||||
private: |
||||
enum { |
||||
PGroup, |
||||
PItem |
||||
}; |
||||
|
||||
Ui::PluginPresetsDialog* ui; |
||||
QString m_pluginId; |
||||
QList<PluginPreset*> *m_pluginPresets; |
||||
SerializableInterface *m_serializableInterface; |
||||
bool m_presetLoaded; |
||||
|
||||
QTreeWidgetItem* addPresetToTree(const PluginPreset* preset); |
||||
void updatePresetControls(); |
||||
PluginPreset* newPreset(const QString& group, const QString& description); |
||||
void addPreset(PluginPreset *preset); |
||||
void savePresetSettings(PluginPreset* preset); |
||||
void loadPresetSettings(const PluginPreset* preset); |
||||
void sortPresets(); |
||||
void renamePresetGroup(const QString& oldGroupName, const QString& newGroupName); |
||||
void deletePreset(const PluginPreset* preset); |
||||
void deletePresetGroup(const QString& groupName); |
||||
|
||||
private slots: |
||||
void on_presetSave_clicked(); |
||||
void on_presetUpdate_clicked(); |
||||
void on_presetEdit_clicked(); |
||||
void on_presetDelete_clicked(); |
||||
void on_presetLoad_clicked(); |
||||
void on_presetTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); |
||||
void on_presetTree_itemActivated(QTreeWidgetItem *item, int column); |
||||
}; |
||||
|
||||
#endif // SDRGUI_GUI_PLUGINPRESETSDIALOG_H_
|
||||
@ -0,0 +1,235 @@
@@ -0,0 +1,235 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>PluginPresetsDialog</class> |
||||
<widget class="QDialog" name="PluginPresetsDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>376</width> |
||||
<height>399</height> |
||||
</rect> |
||||
</property> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="font"> |
||||
<font> |
||||
<family>Liberation Sans</family> |
||||
<pointsize>9</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Plugin presets</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||
<item> |
||||
<widget class="QWidget" name="widget" native="true"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QTreeWidget" name="presetsTree"> |
||||
<property name="indentation"> |
||||
<number>5</number> |
||||
</property> |
||||
<property name="allColumnsShowFocus"> |
||||
<bool>true</bool> |
||||
</property> |
||||
<property name="columnCount"> |
||||
<number>1</number> |
||||
</property> |
||||
<attribute name="headerMinimumSectionSize"> |
||||
<number>5</number> |
||||
</attribute> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Description</string> |
||||
</property> |
||||
</column> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</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> |
||||
<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="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>PluginPresetsDialog</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>PluginPresetsDialog</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> |
||||
Loading…
Reference in new issue