1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-99 Add a Path chooser to the name of the INI file for better ease of use.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2119 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-11-14 11:13:10 +00:00 committed by edouard
parent b8b1fd61b7
commit 213e582f56
2 changed files with 30 additions and 4 deletions

View File

@ -45,6 +45,11 @@ ImportExportGadgetWidget::ImportExportGadgetWidget(QWidget *parent) :
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
ui->setupUi(this);
ui->configFile->setExpectedKind(Utils::PathChooser::File);
ui->configFile->setPromptDialogFilter(tr("INI file (*.ini);; XML file (*.xml)"));
ui->configFile->setPromptDialogTitle(tr("Choose filename"));
}
ImportExportGadgetWidget::~ImportExportGadgetWidget()
@ -68,12 +73,12 @@ void ImportExportGadgetWidget::loadConfiguration(const ImportExportGadgetConfigu
if ( !config )
return;
ui->configFile->setText(config->getIniFile());
ui->configFile->setPath(config->getIniFile());
}
void ImportExportGadgetWidget::on_exportButton_clicked()
{
QString file = ui->configFile->text();
QString file = ui->configFile->path();
qDebug() << "Export pressed! Write to file " << QFileInfo(file).absoluteFilePath();
if ( QFileInfo(file).exists() ){
@ -142,7 +147,7 @@ void ImportExportGadgetWidget::writeError(const QString& msg) const
void ImportExportGadgetWidget::on_importButton_clicked()
{
QString file = ui->configFile->text();
QString file = ui->configFile->path();
qDebug() << "Import pressed! Read from file " << QFileInfo(file).absoluteFilePath();
QMessageBox msgBox;
if (! QFileInfo(file).isReadable()) {

View File

@ -18,13 +18,26 @@
<layout class="QHBoxLayout" name="horizontalLayout_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>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="configFile"/>
<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>
@ -110,6 +123,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header>utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>