mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-151 Also update OPMap widget to use PathChooser, and make it use the path translation utilities. Not relevant on every platform, since typically on a Unix, the share path will not be user writeable. Still, doesn't hurt.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1619 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
1cbd44f564
commit
d280204dd8
@ -26,6 +26,8 @@
|
||||
*/
|
||||
|
||||
#include "opmapgadgetconfiguration.h"
|
||||
#include "utils/pathutils.h"
|
||||
|
||||
#include <QtCore/QDataStream>
|
||||
#include <QDir>
|
||||
|
||||
@ -74,7 +76,7 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteA
|
||||
|
||||
if (!accessMode.isEmpty()) m_accessMode = accessMode;
|
||||
m_useMemoryCache = useMemoryCache;
|
||||
if (!cacheLocation.isEmpty()) m_cacheLocation = cacheLocation;
|
||||
if (!cacheLocation.isEmpty()) m_cacheLocation = Utils::PathUtils().InsertDataPath(cacheLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +114,7 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings*
|
||||
|
||||
if (!accessMode.isEmpty()) m_accessMode = accessMode;
|
||||
m_useMemoryCache = useMemoryCache;
|
||||
if (!cacheLocation.isEmpty()) m_cacheLocation = cacheLocation;
|
||||
if (!cacheLocation.isEmpty()) m_cacheLocation = Utils::PathUtils().InsertDataPath(cacheLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,5 +144,5 @@ void OPMapGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("showTileGridLines", m_showTileGridLines);
|
||||
qSettings->setValue("accessMode", m_accessMode);
|
||||
qSettings->setValue("useMemoryCache", m_useMemoryCache);
|
||||
qSettings->setValue("cacheLocation", m_cacheLocation);
|
||||
qSettings->setValue("cacheLocation", Utils::PathUtils().RemoveDataPath(m_cacheLocation));
|
||||
}
|
||||
|
@ -77,27 +77,16 @@ QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
|
||||
m_page->accessModeComboBox->setCurrentIndex(index);
|
||||
|
||||
m_page->checkBoxUseMemoryCache->setChecked(m_config->useMemoryCache());
|
||||
m_page->lineEditCacheLocation->setText(m_config->cacheLocation());
|
||||
|
||||
connect(m_page->pushButtonCacheLocation, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheLocation_clicked()));
|
||||
m_page->lineEditCacheLocation->setExpectedKind(Utils::PathChooser::Directory);
|
||||
m_page->lineEditCacheLocation->setPromptDialogTitle(tr("Choose Cache Directory"));
|
||||
m_page->lineEditCacheLocation->setPath(m_config->cacheLocation());
|
||||
|
||||
connect(m_page->pushButtonCacheDefaults, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheDefaults_clicked()));
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
void OPMapGadgetOptionsPage::on_pushButtonCacheLocation_clicked()
|
||||
{
|
||||
QString dir = m_page->lineEditCacheLocation->text();
|
||||
|
||||
// QDir dirPath(dir);
|
||||
// dir = dirPath.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||
// if (!dir.isEmpty()) m_page->lineEditCacheLocation->setText(dir);
|
||||
|
||||
QFileDialog::Options options(QFileDialog::ShowDirsOnly);
|
||||
QString path = QFileDialog::getExistingDirectory(qobject_cast<QWidget*>(this), tr("Choose a cache directory"), dir, options);
|
||||
if (!path.isEmpty()) m_page->lineEditCacheLocation->setText(path);
|
||||
}
|
||||
|
||||
void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked()
|
||||
{
|
||||
int index = m_page->accessModeComboBox->findText("ServerAndCache");
|
||||
@ -106,7 +95,8 @@ void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked()
|
||||
|
||||
m_page->checkBoxUseMemoryCache->setChecked(true);
|
||||
|
||||
m_page->lineEditCacheLocation->setText(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator());
|
||||
m_page->lineEditCacheLocation->setPath(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator());
|
||||
|
||||
}
|
||||
|
||||
void OPMapGadgetOptionsPage::apply()
|
||||
@ -119,7 +109,7 @@ void OPMapGadgetOptionsPage::apply()
|
||||
m_config->setShowTileGridLines(m_page->checkBoxShowTileGridLines->isChecked());
|
||||
m_config->setAccessMode(m_page->accessModeComboBox->currentText());
|
||||
m_config->setUseMemoryCache(m_page->checkBoxUseMemoryCache->isChecked());
|
||||
m_config->setCacheLocation(m_page->lineEditCacheLocation->text());
|
||||
m_config->setCacheLocation(m_page->lineEditCacheLocation->path());
|
||||
}
|
||||
|
||||
void OPMapGadgetOptionsPage::finish()
|
||||
|
@ -57,7 +57,6 @@ signals:
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void on_pushButtonCacheLocation_clicked();
|
||||
void on_pushButtonCacheDefaults_clicked();
|
||||
|
||||
private:
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>521</width>
|
||||
<height>373</height>
|
||||
<height>384</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -57,19 +57,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="3">
|
||||
<widget class="QCheckBox" name="checkBoxUseOpenGL">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use OpenGL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QDoubleSpinBox" name="latitudeSpinBox">
|
||||
<property name="minimumSize">
|
||||
@ -183,6 +170,19 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QCheckBox" name="checkBoxUseOpenGL">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use OpenGL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
@ -223,49 +223,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="pushButtonCacheDefaults">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>OpenHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Restore default server and cache settings</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> Default </string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<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>
|
||||
</layout>
|
||||
<layout class="QGridLayout" name="gridLayout_5"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
@ -320,35 +278,52 @@
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cache location </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEditCacheLocation">
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>512</number>
|
||||
<widget class="Utils::PathChooser" name="lineEditCacheLocation" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonCacheLocation">
|
||||
<widget class="QPushButton" name="pushButtonCacheDefaults">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>OpenHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<property name="toolTip">
|
||||
<string>Restore default server and cache settings</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../coreplugin/core.qrc">
|
||||
<normaloff>:/core/images/dir.png</normaloff>:/core/images/dir.png</iconset>
|
||||
<property name="text">
|
||||
<string> Default </string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -386,8 +361,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../coreplugin/core.qrc"/>
|
||||
</resources>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Utils::PathChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>utils/pathchooser.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user