mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-01 18:29:16 +01:00
OP-151 Use PathChooser in all plugins, and update pathutils to behave consistently across platforms by always using "/" as its internal format. Should solve the issues we have been having with windows paths not being removed properly.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1618 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
6cc702b394
commit
1cbd44f564
@ -38,36 +38,46 @@ namespace Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the base path of the share directory
|
Returns the base path of the share directory.
|
||||||
|
|
||||||
|
Path is in Qt/Unix conventions, separated by "/".
|
||||||
*/
|
*/
|
||||||
QString PathUtils::GetDataPath()
|
QString PathUtils::GetDataPath()
|
||||||
{
|
{
|
||||||
// Figure out root: Up one from 'bin'
|
// This routine works with "/" as the standard:
|
||||||
QDir rootDir = QApplication::applicationDirPath();
|
// Figure out root: Up one from 'bin'
|
||||||
rootDir.cdUp();
|
QDir rootDir = QApplication::applicationDirPath();
|
||||||
const QString rootDirPath = rootDir.canonicalPath();
|
rootDir.cdUp();
|
||||||
QString pluginPath = rootDirPath;
|
const QString rootDirPath = rootDir.canonicalPath();
|
||||||
pluginPath += QLatin1Char('/');
|
QString dataPath = rootDirPath;
|
||||||
pluginPath += QLatin1String(GCS_DATA_BASENAME);
|
dataPath += QLatin1Char('/');
|
||||||
pluginPath += QLatin1Char('/');
|
dataPath += QLatin1String(GCS_DATA_BASENAME);
|
||||||
return pluginPath;
|
dataPath += QLatin1Char('/');
|
||||||
|
return dataPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Cuts the standard data path from the 'path' argument. If path does not start
|
Cuts the standard data path from the 'path' argument. If path does not start
|
||||||
with the standard data path, then do nothing.
|
with the standard data path, then do nothing.
|
||||||
|
|
||||||
|
Always returns a path converted to "/".
|
||||||
*/
|
*/
|
||||||
QString PathUtils::RemoveDataPath(QString path)
|
QString PathUtils::RemoveDataPath(QString path)
|
||||||
{
|
{
|
||||||
if (path.startsWith(GetDataPath())) {
|
// Depending on the platform, we might get either "/" or "\"
|
||||||
int i = path.length()- GetDataPath().length();
|
// so we need to go to the standard ("/")
|
||||||
return QString("%%DATAPATH%%") + path.right(i);
|
QString goodPath = QDir::fromNativeSeparators(path);
|
||||||
|
if (goodPath.startsWith(GetDataPath())) {
|
||||||
|
int i = goodPath.length()- GetDataPath().length();
|
||||||
|
return QString("%%DATAPATH%%") + goodPath.right(i);
|
||||||
} else
|
} else
|
||||||
return path;
|
return goodPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Inserts the data path (only if the path starts with %%DATAPATH%%)
|
Inserts the data path (only if the path starts with %%DATAPATH%%)
|
||||||
|
|
||||||
|
Returns a "/" or "\" separated path depending on platform conventions.
|
||||||
*/
|
*/
|
||||||
QString PathUtils::InsertDataPath(QString path)
|
QString PathUtils::InsertDataPath(QString path)
|
||||||
{
|
{
|
||||||
@ -75,9 +85,9 @@ QString PathUtils::InsertDataPath(QString path)
|
|||||||
{
|
{
|
||||||
QString newPath = GetDataPath();
|
QString newPath = GetDataPath();
|
||||||
newPath += path.right(path.length()-12);
|
newPath += path.right(path.length()-12);
|
||||||
return newPath;
|
return QDir::toNativeSeparators(newPath);
|
||||||
}
|
}
|
||||||
return path;
|
return QDir::toNativeSeparators(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,11 @@ QWidget *DialGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
options_page->moveNeedle3->addItem("Vertical");
|
options_page->moveNeedle3->addItem("Vertical");
|
||||||
|
|
||||||
// Restore the contents from the settings:
|
// Restore the contents from the settings:
|
||||||
options_page->svgSourceFile->setText(m_config->dialFile());
|
|
||||||
|
options_page->svgSourceFile->setExpectedKind(Utils::PathChooser::File);
|
||||||
|
options_page->svgSourceFile->setPromptDialogFilter(tr("SVG image (*.svg)"));
|
||||||
|
options_page->svgSourceFile->setPromptDialogTitle(tr("Choose SVG image"));
|
||||||
|
options_page->svgSourceFile->setPath(m_config->dialFile());
|
||||||
options_page->backgroundID->setText(m_config->dialBackground());
|
options_page->backgroundID->setText(m_config->dialBackground());
|
||||||
options_page->foregroundID->setText(m_config->dialForeground());
|
options_page->foregroundID->setText(m_config->dialForeground());
|
||||||
options_page->needle1ID->setText(m_config->dialNeedle1());
|
options_page->needle1ID->setText(m_config->dialNeedle1());
|
||||||
@ -143,7 +147,6 @@ QWidget *DialGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
}
|
}
|
||||||
connect(options_page->uavObject3, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_uavObject3_currentIndexChanged(QString)));
|
connect(options_page->uavObject3, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_uavObject3_currentIndexChanged(QString)));
|
||||||
|
|
||||||
connect(options_page->loadFile, SIGNAL(clicked()), this, SLOT(on_loadFile_clicked()));
|
|
||||||
connect(options_page->fontPicker, SIGNAL(clicked()), this, SLOT(on_fontPicker_clicked()));
|
connect(options_page->fontPicker, SIGNAL(clicked()), this, SLOT(on_fontPicker_clicked()));
|
||||||
|
|
||||||
return optionsPageWidget;
|
return optionsPageWidget;
|
||||||
@ -157,7 +160,7 @@ QWidget *DialGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
*/
|
*/
|
||||||
void DialGadgetOptionsPage::apply()
|
void DialGadgetOptionsPage::apply()
|
||||||
{
|
{
|
||||||
m_config->setDialFile(options_page->svgSourceFile->text());
|
m_config->setDialFile(options_page->svgSourceFile->path());
|
||||||
m_config->setDialBackgroundID(options_page->backgroundID->text());
|
m_config->setDialBackgroundID(options_page->backgroundID->text());
|
||||||
m_config->setDialForegroundID(options_page->foregroundID->text());
|
m_config->setDialForegroundID(options_page->foregroundID->text());
|
||||||
m_config->setDialNeedleID1(options_page->needle1ID->text());
|
m_config->setDialNeedleID1(options_page->needle1ID->text());
|
||||||
@ -242,25 +245,6 @@ void DialGadgetOptionsPage::on_uavObject3_currentIndexChanged(QString val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Opens an open file dialog.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void DialGadgetOptionsPage::on_loadFile_clicked()
|
|
||||||
{
|
|
||||||
QFileDialog::Options options;
|
|
||||||
QString selectedFilter;
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(qobject_cast<QWidget*>(this),
|
|
||||||
tr("QFileDialog::getOpenFileName()"),
|
|
||||||
options_page->svgSourceFile->text(),
|
|
||||||
tr("All Files (*);;SVG Files (*.svg)"),
|
|
||||||
&selectedFilter,
|
|
||||||
options);
|
|
||||||
if (!fileName.isEmpty()) options_page->svgSourceFile->setText(fileName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DialGadgetOptionsPage::finish()
|
void DialGadgetOptionsPage::finish()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -64,7 +64,6 @@ private:
|
|||||||
QFont font;
|
QFont font;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_loadFile_clicked();
|
|
||||||
void on_fontPicker_clicked();
|
void on_fontPicker_clicked();
|
||||||
void on_uavObject1_currentIndexChanged(QString val);
|
void on_uavObject1_currentIndexChanged(QString val);
|
||||||
void on_uavObject2_currentIndexChanged(QString val);
|
void on_uavObject2_currentIndexChanged(QString val);
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
@ -57,23 +57,35 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Dial SVG: </string>
|
<string>Dial SVG: </string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="svgSourceFile"/>
|
<widget class="Utils::PathChooser" name="svgSourceFile" native="true">
|
||||||
</item>
|
<property name="sizePolicy">
|
||||||
<item>
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
<widget class="QPushButton" name="loadFile">
|
<horstretch>0</horstretch>
|
||||||
<property name="text">
|
<verstretch>0</verstretch>
|
||||||
<string>Load file...</string>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_28">
|
<widget class="QLabel" name="label_28">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Dial font:</string>
|
<string>Dial font:</string>
|
||||||
</property>
|
</property>
|
||||||
@ -762,6 +774,14 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>Utils::PathChooser</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>utils/pathchooser.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -51,7 +51,10 @@ QWidget *ImportExportGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
options_page->setupUi(optionsPageWidget);
|
options_page->setupUi(optionsPageWidget);
|
||||||
|
|
||||||
// Restore the contents from the settings:
|
// Restore the contents from the settings:
|
||||||
options_page->svgSourceFile->setText(m_config->getDialFile());
|
options_page->svgSourceFile->setExpectedKind(Utils::PathChooser::File);
|
||||||
|
options_page->svgSourceFile->setPromptDialogFilter(tr("INI file (*.ini)"));
|
||||||
|
options_page->svgSourceFile->setPromptDialogTitle(tr("Choose configuration file"));
|
||||||
|
options_page->svgSourceFile->setPath(m_config->getDialFile());
|
||||||
|
|
||||||
return optionsPageWidget;
|
return optionsPageWidget;
|
||||||
}
|
}
|
||||||
@ -64,7 +67,7 @@ QWidget *ImportExportGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
*/
|
*/
|
||||||
void ImportExportGadgetOptionsPage::apply()
|
void ImportExportGadgetOptionsPage::apply()
|
||||||
{
|
{
|
||||||
m_config->setDialFile(options_page->svgSourceFile->text());
|
m_config->setDialFile(options_page->svgSourceFile->path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
@ -63,12 +63,12 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="svgSourceFile"/>
|
<widget class="Utils::PathChooser" name="svgSourceFile" native="true">
|
||||||
</item>
|
<property name="sizePolicy">
|
||||||
<item>
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
<widget class="QPushButton" name="loadFile">
|
<horstretch>0</horstretch>
|
||||||
<property name="text">
|
<verstretch>0</verstretch>
|
||||||
<string>Load file...</string>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -90,6 +90,14 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>Utils::PathChooser</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>utils/pathchooser.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -55,7 +55,10 @@ QWidget *LineardialGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
options_page->setupUi(optionsPageWidget);
|
options_page->setupUi(optionsPageWidget);
|
||||||
|
|
||||||
// Restore the contents from the settings:
|
// Restore the contents from the settings:
|
||||||
options_page->svgSourceFile->setText(m_config->getDialFile());
|
options_page->svgSourceFile->setExpectedKind(Utils::PathChooser::File);
|
||||||
|
options_page->svgSourceFile->setPromptDialogFilter(tr("SVG image (*.svg)"));
|
||||||
|
options_page->svgSourceFile->setPromptDialogTitle(tr("Choose SVG image"));
|
||||||
|
options_page->svgSourceFile->setPath(m_config->getDialFile());
|
||||||
options_page->minValue->setValue(m_config->getMin());
|
options_page->minValue->setValue(m_config->getMin());
|
||||||
options_page->maxValue->setValue(m_config->getMax());
|
options_page->maxValue->setValue(m_config->getMax());
|
||||||
options_page->greenMin->setValue(m_config->getGreenMin());
|
options_page->greenMin->setValue(m_config->getGreenMin());
|
||||||
@ -93,7 +96,6 @@ QWidget *LineardialGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(options_page->objectName, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_objectName_currentIndexChanged(QString)));
|
connect(options_page->objectName, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_objectName_currentIndexChanged(QString)));
|
||||||
connect(options_page->loadFile, SIGNAL(clicked()), this, SLOT(on_loadFile_clicked()));
|
|
||||||
connect(options_page->fontPicker, SIGNAL(clicked()), this, SLOT(on_fontPicker_clicked()));
|
connect(options_page->fontPicker, SIGNAL(clicked()), this, SLOT(on_fontPicker_clicked()));
|
||||||
|
|
||||||
return optionsPageWidget;
|
return optionsPageWidget;
|
||||||
@ -107,7 +109,7 @@ QWidget *LineardialGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
*/
|
*/
|
||||||
void LineardialGadgetOptionsPage::apply()
|
void LineardialGadgetOptionsPage::apply()
|
||||||
{
|
{
|
||||||
m_config->setDialFile(options_page->svgSourceFile->text());
|
m_config->setDialFile(options_page->svgSourceFile->path());
|
||||||
m_config->setRange(options_page->minValue->value(),options_page->maxValue->value());
|
m_config->setRange(options_page->minValue->value(),options_page->maxValue->value());
|
||||||
m_config->setGreenRange(options_page->greenMin->value(),options_page->greenMax->value());
|
m_config->setGreenRange(options_page->greenMin->value(),options_page->greenMax->value());
|
||||||
m_config->setYellowRange(options_page->yellowMin->value(),options_page->yellowMax->value());
|
m_config->setYellowRange(options_page->yellowMin->value(),options_page->yellowMax->value());
|
||||||
@ -130,25 +132,6 @@ void LineardialGadgetOptionsPage::on_fontPicker_clicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Opens an open file dialog.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void LineardialGadgetOptionsPage::on_loadFile_clicked()
|
|
||||||
{
|
|
||||||
QFileDialog::Options options;
|
|
||||||
QString selectedFilter;
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(qobject_cast<QWidget*>(this),
|
|
||||||
tr("QFileDialog::getOpenFileName()"),
|
|
||||||
options_page->svgSourceFile->text(),
|
|
||||||
tr("All Files (*);;SVG Files (*.svg)"),
|
|
||||||
&selectedFilter,
|
|
||||||
options);
|
|
||||||
if (!fileName.isEmpty()) options_page->svgSourceFile->setText(fileName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Fills in the field1 combo box when value is changed in the
|
Fills in the field1 combo box when value is changed in the
|
||||||
object1 field
|
object1 field
|
||||||
|
@ -62,7 +62,6 @@ private:
|
|||||||
QFont font;
|
QFont font;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_loadFile_clicked();
|
|
||||||
void on_fontPicker_clicked();
|
void on_fontPicker_clicked();
|
||||||
void on_objectName_currentIndexChanged(QString val);
|
void on_objectName_currentIndexChanged(QString val);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>-1</x>
|
<x>-1</x>
|
||||||
<y>-1</y>
|
<y>-1</y>
|
||||||
<width>491</width>
|
<width>533</width>
|
||||||
<height>321</height>
|
<height>321</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
@ -63,12 +63,12 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="svgSourceFile"/>
|
<widget class="Utils::PathChooser" name="svgSourceFile" native="true">
|
||||||
</item>
|
<property name="sizePolicy">
|
||||||
<item>
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
<widget class="QPushButton" name="loadFile">
|
<horstretch>0</horstretch>
|
||||||
<property name="text">
|
<verstretch>0</verstretch>
|
||||||
<string>Load file...</string>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -512,6 +512,14 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>Utils::PathChooser</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>utils/pathchooser.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -56,11 +56,13 @@ QWidget *PFDGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
|
|
||||||
|
|
||||||
// Restore the contents from the settings:
|
// Restore the contents from the settings:
|
||||||
options_page->svgSourceFile->setText(m_config->dialFile());
|
options_page->svgSourceFile->setExpectedKind(Utils::PathChooser::File);
|
||||||
|
options_page->svgSourceFile->setPromptDialogFilter(tr("SVG image (*.svg)"));
|
||||||
|
options_page->svgSourceFile->setPromptDialogTitle(tr("Choose SVG image"));
|
||||||
|
options_page->svgSourceFile->setPath(m_config->dialFile());
|
||||||
options_page->useOpenGL->setChecked(m_config->useOpenGL());
|
options_page->useOpenGL->setChecked(m_config->useOpenGL());
|
||||||
options_page->hqText->setChecked(m_config->getHqFonts());
|
options_page->hqText->setChecked(m_config->getHqFonts());
|
||||||
|
|
||||||
connect(options_page->loadFile, SIGNAL(clicked()), this, SLOT(on_loadFile_clicked()));
|
|
||||||
return optionsPageWidget;
|
return optionsPageWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,30 +74,12 @@ QWidget *PFDGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
*/
|
*/
|
||||||
void PFDGadgetOptionsPage::apply()
|
void PFDGadgetOptionsPage::apply()
|
||||||
{
|
{
|
||||||
m_config->setDialFile(options_page->svgSourceFile->text());
|
m_config->setDialFile(options_page->svgSourceFile->path());
|
||||||
m_config->setUseOpenGL(options_page->useOpenGL->checkState());
|
m_config->setUseOpenGL(options_page->useOpenGL->checkState());
|
||||||
m_config->setHqFonts(options_page->hqText->checkState());
|
m_config->setHqFonts(options_page->hqText->checkState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Opens an open file dialog.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void PFDGadgetOptionsPage::on_loadFile_clicked()
|
|
||||||
{
|
|
||||||
QFileDialog::Options options;
|
|
||||||
QString selectedFilter;
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(qobject_cast<QWidget*>(this),
|
|
||||||
tr("QFileDialog::getOpenFileName()"),
|
|
||||||
options_page->svgSourceFile->text(),
|
|
||||||
tr("All Files (*);;SVG Files (*.svg)"),
|
|
||||||
&selectedFilter,
|
|
||||||
options);
|
|
||||||
if (!fileName.isEmpty()) options_page->svgSourceFile->setText(fileName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PFDGadgetOptionsPage::finish()
|
void PFDGadgetOptionsPage::finish()
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,6 @@ private:
|
|||||||
PFDGadgetConfiguration *m_config;
|
PFDGadgetConfiguration *m_config;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_loadFile_clicked();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PFDGADGETOPTIONSPAGE_H
|
#endif // PFDGADGETOPTIONSPAGE_H
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<height>331</height>
|
<height>331</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,1,0">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetMinimumSize</enum>
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
@ -63,12 +63,12 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="svgSourceFile"/>
|
<widget class="Utils::PathChooser" name="svgSourceFile" native="true">
|
||||||
</item>
|
<property name="sizePolicy">
|
||||||
<item>
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
<widget class="QPushButton" name="loadFile">
|
<horstretch>0</horstretch>
|
||||||
<property name="text">
|
<verstretch>0</verstretch>
|
||||||
<string>Load file...</string>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -131,6 +131,14 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>Utils::PathChooser</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>utils/pathchooser.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user