mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
Merge branch 'bugfix-ground' of git.openpilot.org:OpenPilot into bugfix-ground
This commit is contained in:
commit
54d57f1815
@ -37,6 +37,7 @@
|
||||
#include <QSettings>
|
||||
#include <QMessageBox>
|
||||
#include <QFileInfo>
|
||||
#include <QFileDialog>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QDir>
|
||||
@ -47,10 +48,8 @@ ImportExportGadgetWidget::ImportExportGadgetWidget(QWidget *parent) :
|
||||
{
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
ui->setupUi(this);
|
||||
ui->configFile->setExpectedKind(Utils::PathChooser::File);
|
||||
ui->configFile->setPromptDialogFilter(tr("XML file (*.xml)"));
|
||||
ui->configFile->setPromptDialogTitle(tr("Choose configuration file"));
|
||||
|
||||
filename = "";
|
||||
}
|
||||
|
||||
ImportExportGadgetWidget::~ImportExportGadgetWidget()
|
||||
@ -72,35 +71,21 @@ void ImportExportGadgetWidget::changeEvent(QEvent *e)
|
||||
|
||||
void ImportExportGadgetWidget::on_exportButton_clicked()
|
||||
{
|
||||
QString file = ui->configFile->path();
|
||||
if (file.isEmpty()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("Empty File name."));
|
||||
msgBox.setInformativeText(tr("Please choose an export file name."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
// Add a "XML" extension to the file in case it does not exist:
|
||||
if (!file.endsWith(".xml"))
|
||||
QString file = filename;
|
||||
QString filter = tr("GCS Settings file (*.xml)");
|
||||
file = QFileDialog::getSaveFileName(this, tr("Save GCS Settings too file .."), QFileInfo(file).absoluteFilePath(), filter).trimmed();
|
||||
if (file.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add a "XML" extension to the file in case it does not exist:
|
||||
if (!file.toLower().endsWith(".xml"))
|
||||
file.append(".xml");
|
||||
|
||||
filename = file;
|
||||
|
||||
qDebug() << "Export pressed! Write to file " << QFileInfo(file).absoluteFilePath();
|
||||
|
||||
if ( QFileInfo(file).exists() ){
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("File already exists."));
|
||||
msgBox.setInformativeText(tr("Do you want to overwrite the existing file?"));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
if ( msgBox.exec() == QMessageBox::Ok ){
|
||||
QFileInfo(file).absoluteDir().remove(QFileInfo(file).fileName());
|
||||
}
|
||||
else{
|
||||
qDebug() << "Export canceled!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
QMessageBox msgBox;
|
||||
QDir dir = QFileInfo(file).absoluteDir();
|
||||
if (! dir.exists()) {
|
||||
@ -163,8 +148,17 @@ void ImportExportGadgetWidget::writeError(const QString& msg) const
|
||||
|
||||
void ImportExportGadgetWidget::on_importButton_clicked()
|
||||
{
|
||||
QString file = ui->configFile->path();
|
||||
QString file = filename;
|
||||
QString filter = tr("GCS Settings file (*.xml)");
|
||||
file = QFileDialog::getOpenFileName(this, tr("Load GCS Settings from file .."), QFileInfo(file).absoluteFilePath(), filter).trimmed();
|
||||
if (file.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
filename = file;
|
||||
|
||||
qDebug() << "Import pressed! Read from file " << QFileInfo(file).absoluteFilePath();
|
||||
|
||||
QMessageBox msgBox;
|
||||
if (! QFileInfo(file).isReadable()) {
|
||||
msgBox.setText(tr("Can't read file ") + QFileInfo(file).absoluteFilePath());
|
||||
|
@ -41,8 +41,10 @@ private:
|
||||
void importConfiguration(const QString& fileName);
|
||||
QList<Core::IConfigurablePlugin*> getConfigurables();
|
||||
|
||||
QString filename;
|
||||
|
||||
private slots:
|
||||
void on_resetButton_clicked();
|
||||
void on_resetButton_clicked();
|
||||
void on_helpButton_clicked();
|
||||
void on_importButton_clicked();
|
||||
void on_exportButton_clicked();
|
||||
|
@ -7,162 +7,118 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>483</width>
|
||||
<height>271</height>
|
||||
<height>154</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Config File</string>
|
||||
<widget class="QGroupBox" name="groupBoxItems">
|
||||
<property name="title">
|
||||
<string>Items</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxGeneral">
|
||||
<property name="text">
|
||||
<string>General (Workspace, Key-Bindings)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxAllGadgets">
|
||||
<property name="text">
|
||||
<string>All Gadgets</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxPlugins">
|
||||
<property name="text">
|
||||
<string>Plugins</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Utils::PathChooser" name="configFile" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBoxItems">
|
||||
<property name="title">
|
||||
<string>Items</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxGeneral">
|
||||
<property name="text">
|
||||
<string>General (Workspace, Key-Bindings)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxAllGadgets">
|
||||
<property name="text">
|
||||
<string>All Gadgets</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxPlugins">
|
||||
<property name="text">
|
||||
<string>Plugins</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<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="QPushButton" name="helpButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../coreplugin/core.qrc">
|
||||
<normaloff>:/core/images/helpicon.svg</normaloff>:/core/images/helpicon.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="exportButton">
|
||||
<property name="toolTip">
|
||||
<string>Export the GCS settings selected in the checkboxes above.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="importButton">
|
||||
<property name="toolTip">
|
||||
<string>Import settings from the config file, only for the items checked above.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Import</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetButton">
|
||||
<property name="toolTip">
|
||||
<string>Resets your GCS configuration to its default configuration.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset Config</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="helpButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../coreplugin/core.qrc">
|
||||
<normaloff>:/core/images/helpicon.svg</normaloff>:/core/images/helpicon.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="exportButton">
|
||||
<property name="toolTip">
|
||||
<string>Export the GCS settings selected in the checkboxes above.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="importButton">
|
||||
<property name="toolTip">
|
||||
<string>Import settings from the config file, only for the items checked above.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Import</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetButton">
|
||||
<property name="toolTip">
|
||||
<string>Resets your GCS configuration to its default configuration.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset Config</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Utils::PathChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>utils/pathchooser.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../coreplugin/core.qrc"/>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user