30 #include "ui_importexportgadgetwidget.h"
38 #include <QMessageBox>
40 #include <QFileDialog>
41 #include <QDesktopServices>
49 setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
62 QWidget::changeEvent(e);
64 case QEvent::LanguageChange:
65 ui->retranslateUi(
this);
72 void ImportExportGadgetWidget::on_exportButton_clicked()
74 QString
file = filename;
75 QString filter = tr(
"GCS Settings file (*.xml)");
76 file = QFileDialog::getSaveFileName(
this, tr(
"Save GCS Settings to file .."),
77 QFileInfo(file).absoluteFilePath(), filter)
84 if (!file.toLower().endsWith(
".xml"))
89 qDebug() <<
"Export pressed! Write to file " << QFileInfo(file).absoluteFilePath();
91 QMessageBox msgBox(
this);
92 QDir dir = QFileInfo(file).absoluteDir();
94 msgBox.setText(tr(
"Can't write file ") + QFileInfo(file).absoluteFilePath()
95 +
" since directory " + dir.absolutePath() +
" doesn't exist!");
99 exportConfiguration(file);
101 msgBox.setText(tr(
"The settings have been exported to ") + QFileInfo(file).absoluteFilePath());
111 ExtensionSystem::PluginManager::instance()->plugins();
114 dynamic_cast<Core::IConfigurablePlugin *>(spec->
plugin())) {
115 qDebug() <<
"Configurable: " << plugin->metaObject()->className();
116 configurables.append(plugin);
119 return configurables;
122 void ImportExportGadgetWidget::exportConfiguration(
const QString &fileName)
124 bool doGeneral = ui->checkBoxGeneral->isChecked();
125 bool doAllGadgets = ui->checkBoxAllGadgets->isChecked();
126 bool doPlugins = ui->checkBoxPlugins->isChecked();
129 QSettings qs(fileName, format);
143 qDebug() <<
"Export ended";
146 void ImportExportGadgetWidget::writeError(
const QString &msg)
const
148 qWarning() <<
"ERROR: " << msg;
151 void ImportExportGadgetWidget::on_importButton_clicked()
153 QString file = filename;
154 QString filter = tr(
"GCS Settings file (*.xml)");
155 file = QFileDialog::getOpenFileName(
this, tr(
"Load GCS Settings from file .."),
156 QFileInfo(file).absoluteFilePath(), filter)
158 if (file.isEmpty()) {
164 qDebug() <<
"Import pressed! Read from file " << QFileInfo(file).absoluteFilePath();
166 QMessageBox msgBox(
this);
167 if (!QFileInfo(file).isReadable()) {
168 msgBox.setText(tr(
"Can't read file ") + QFileInfo(file).absoluteFilePath());
172 importConfiguration(file);
175 msgBox.setText(tr(
"The settings have been imported from ") + QFileInfo(file).absoluteFilePath()
176 + tr(
". Restart the application."));
181 void ImportExportGadgetWidget::importConfiguration(
const QString &fileName)
183 bool doGeneral = ui->checkBoxGeneral->isChecked();
184 bool doAllGadgets = ui->checkBoxAllGadgets->isChecked();
185 bool doPlugins = ui->checkBoxPlugins->isChecked();
201 qDebug() <<
"Import ended";
204 void ImportExportGadgetWidget::on_helpButton_clicked()
206 qDebug() <<
"Show Help";
207 QDesktopServices::openUrl(
208 QUrl(
"https://github.com/d-ronin/dRonin/wiki/OnlineHelp:-Import-Export"));
211 void ImportExportGadgetWidget::on_resetButton_clicked()
213 QMessageBox msgBox(
this);
214 msgBox.setText(tr(
"All your settings will be deleted!"));
215 msgBox.setInformativeText(tr(
"You must restart the GCS in order to activate the changes."));
216 msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
217 msgBox.setDefaultButton(QMessageBox::Ok);
218 if (msgBox.exec() == QMessageBox::Ok) {
219 qDebug() <<
"Reset requested!";
222 qDebug() <<
"Reset canceled!";
ImportExportGadgetWidget(QWidget *parent=nullptr)
virtual void readMainSettings(QSettings *qs, bool workspaceDiffOnly=false)=0
virtual void readSettings(IConfigurablePlugin *plugin, QSettings *qs=nullptr)=0
~ImportExportGadgetWidget()
void readSettings(QSettings *qs)
void saveSettings(QSettings *qs)
virtual void deleteSettings()=0
static ICore * instance()
Contains the information of the plugins xml description file and information about the plugin's curre...
static const QSettings::Format XmlSettingsFormat
virtual void saveSettings(IConfigurablePlugin *plugin, QSettings *qs=nullptr)=0
virtual UAVGadgetInstanceManager * uavGadgetInstanceManager() const =0
virtual void saveMainSettings(QSettings *qs)=0
void changeEvent(QEvent *e)