1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +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:
edouard 2010-09-14 20:27:39 +00:00 committed by edouard
parent 1cbd44f564
commit d280204dd8
4 changed files with 386 additions and 414 deletions

View File

@ -26,6 +26,8 @@
*/ */
#include "opmapgadgetconfiguration.h" #include "opmapgadgetconfiguration.h"
#include "utils/pathutils.h"
#include <QtCore/QDataStream> #include <QtCore/QDataStream>
#include <QDir> #include <QDir>
@ -74,7 +76,7 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteA
if (!accessMode.isEmpty()) m_accessMode = accessMode; if (!accessMode.isEmpty()) m_accessMode = accessMode;
m_useMemoryCache = useMemoryCache; 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; if (!accessMode.isEmpty()) m_accessMode = accessMode;
m_useMemoryCache = useMemoryCache; 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("showTileGridLines", m_showTileGridLines);
qSettings->setValue("accessMode", m_accessMode); qSettings->setValue("accessMode", m_accessMode);
qSettings->setValue("useMemoryCache", m_useMemoryCache); qSettings->setValue("useMemoryCache", m_useMemoryCache);
qSettings->setValue("cacheLocation", m_cacheLocation); qSettings->setValue("cacheLocation", Utils::PathUtils().RemoveDataPath(m_cacheLocation));
} }

View File

@ -77,27 +77,16 @@ QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
m_page->accessModeComboBox->setCurrentIndex(index); m_page->accessModeComboBox->setCurrentIndex(index);
m_page->checkBoxUseMemoryCache->setChecked(m_config->useMemoryCache()); 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())); connect(m_page->pushButtonCacheDefaults, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheDefaults_clicked()));
return w; 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() void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked()
{ {
int index = m_page->accessModeComboBox->findText("ServerAndCache"); int index = m_page->accessModeComboBox->findText("ServerAndCache");
@ -106,7 +95,8 @@ void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked()
m_page->checkBoxUseMemoryCache->setChecked(true); 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() void OPMapGadgetOptionsPage::apply()
@ -119,7 +109,7 @@ void OPMapGadgetOptionsPage::apply()
m_config->setShowTileGridLines(m_page->checkBoxShowTileGridLines->isChecked()); m_config->setShowTileGridLines(m_page->checkBoxShowTileGridLines->isChecked());
m_config->setAccessMode(m_page->accessModeComboBox->currentText()); m_config->setAccessMode(m_page->accessModeComboBox->currentText());
m_config->setUseMemoryCache(m_page->checkBoxUseMemoryCache->isChecked()); m_config->setUseMemoryCache(m_page->checkBoxUseMemoryCache->isChecked());
m_config->setCacheLocation(m_page->lineEditCacheLocation->text()); m_config->setCacheLocation(m_page->lineEditCacheLocation->path());
} }
void OPMapGadgetOptionsPage::finish() void OPMapGadgetOptionsPage::finish()

View File

@ -57,7 +57,6 @@ signals:
public slots: public slots:
private slots: private slots:
void on_pushButtonCacheLocation_clicked();
void on_pushButtonCacheDefaults_clicked(); void on_pushButtonCacheDefaults_clicked();
private: private:

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>521</width> <width>521</width>
<height>373</height> <height>384</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -57,19 +57,6 @@
</property> </property>
</widget> </widget>
</item> </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"> <item row="2" column="3">
<widget class="QDoubleSpinBox" name="latitudeSpinBox"> <widget class="QDoubleSpinBox" name="latitudeSpinBox">
<property name="minimumSize"> <property name="minimumSize">
@ -183,6 +170,19 @@
</property> </property>
</spacer> </spacer>
</item> </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> </layout>
</item> </item>
<item row="10" column="0"> <item row="10" column="0">
@ -223,49 +223,7 @@
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="7" column="0">
<layout class="QGridLayout" name="gridLayout_5"> <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>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
@ -320,35 +278,52 @@
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QLabel" name="label_5"> <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"> <property name="text">
<string>Cache location </string> <string>Cache location </string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditCacheLocation"> <widget class="Utils::PathChooser" name="lineEditCacheLocation" native="true">
<property name="autoFillBackground"> <property name="sizePolicy">
<bool>false</bool> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
</property> <horstretch>0</horstretch>
<property name="maxLength"> <verstretch>0</verstretch>
<number>512</number> </sizepolicy>
</property> </property>
</widget> </widget>
</item> </item>
<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"> <property name="cursor">
<cursorShape>OpenHandCursor</cursorShape> <cursorShape>OpenHandCursor</cursorShape>
</property> </property>
<property name="text"> <property name="toolTip">
<string/> <string>Restore default server and cache settings</string>
</property> </property>
<property name="icon"> <property name="text">
<iconset resource="../coreplugin/core.qrc"> <string> Default </string>
<normaloff>:/core/images/dir.png</normaloff>:/core/images/dir.png</iconset> </property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -386,8 +361,14 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> <customwidgets>
<include location="../coreplugin/core.qrc"/> <customwidget>
</resources> <class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header>utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/> <connections/>
</ui> </ui>