1
0
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:
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

@ -1,393 +1,374 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>OPMapGadgetOptionsPage</class> <class>OPMapGadgetOptionsPage</class>
<widget class="QWidget" name="OPMapGadgetOptionsPage"> <widget class="QWidget" name="OPMapGadgetOptionsPage">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<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">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="margin"> <property name="margin">
<number>5</number> <number>5</number>
</property> </property>
<item row="1" column="0"> <item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0,0"> <layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0,0">
<item row="4" column="2"> <item row="4" column="2">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string>Default longitude </string> <string>Default longitude </string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="3"> <item row="4" column="3">
<widget class="QDoubleSpinBox" name="longitudeSpinBox"> <widget class="QDoubleSpinBox" name="longitudeSpinBox">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>120</width> <width>120</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="frame"> <property name="frame">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="decimals"> <property name="decimals">
<number>8</number> <number>8</number>
</property> </property>
<property name="minimum"> <property name="minimum">
<double>-180.000000000000000</double> <double>-180.000000000000000</double>
</property> </property>
<property name="maximum"> <property name="maximum">
<double>180.000000000000000</double> <double>180.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="3"> <item row="2" column="3">
<widget class="QCheckBox" name="checkBoxUseOpenGL"> <widget class="QDoubleSpinBox" name="latitudeSpinBox">
<property name="enabled"> <property name="minimumSize">
<bool>true</bool> <size>
</property> <width>120</width>
<property name="layoutDirection"> <height>0</height>
<enum>Qt::RightToLeft</enum> </size>
</property> </property>
<property name="text"> <property name="frame">
<string>Use OpenGL</string> <bool>true</bool>
</property> </property>
</widget> <property name="decimals">
</item> <number>8</number>
<item row="2" column="3"> </property>
<widget class="QDoubleSpinBox" name="latitudeSpinBox"> <property name="minimum">
<property name="minimumSize"> <double>-90.000000000000000</double>
<size> </property>
<width>120</width> <property name="maximum">
<height>0</height> <double>90.000000000000000</double>
</size> </property>
</property> </widget>
<property name="frame"> </item>
<bool>true</bool> <item row="2" column="2">
</property> <widget class="QLabel" name="label_3">
<property name="decimals"> <property name="text">
<number>8</number> <string>Default latitude </string>
</property> </property>
<property name="minimum"> <property name="alignment">
<double>-90.000000000000000</double> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="maximum"> </widget>
<double>90.000000000000000</double> </item>
</property> <item row="1" column="3">
</widget> <widget class="QSpinBox" name="zoomSpinBox">
</item> <property name="maximumSize">
<item row="2" column="2"> <size>
<widget class="QLabel" name="label_3"> <width>50</width>
<property name="text"> <height>16777215</height>
<string>Default latitude </string> </size>
</property> </property>
<property name="alignment"> <property name="frame">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <bool>true</bool>
</property> </property>
</widget> <property name="minimum">
</item> <number>2</number>
<item row="1" column="3"> </property>
<widget class="QSpinBox" name="zoomSpinBox"> <property name="maximum">
<property name="maximumSize"> <number>18</number>
<size> </property>
<width>50</width> </widget>
<height>16777215</height> </item>
</size> <item row="1" column="2">
</property> <widget class="QLabel" name="label_2">
<property name="frame"> <property name="text">
<bool>true</bool> <string>Default zoom </string>
</property> </property>
<property name="minimum"> <property name="alignment">
<number>2</number> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="maximum"> </widget>
<number>18</number> </item>
</property> <item row="0" column="3">
</widget> <widget class="QComboBox" name="providerComboBox">
</item> <property name="cursor">
<item row="1" column="2"> <cursorShape>OpenHandCursor</cursorShape>
<widget class="QLabel" name="label_2"> </property>
<property name="text"> <property name="maxVisibleItems">
<string>Default zoom </string> <number>15</number>
</property> </property>
<property name="alignment"> <property name="frame">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="0" column="2">
<widget class="QComboBox" name="providerComboBox"> <widget class="QLabel" name="label">
<property name="cursor"> <property name="text">
<cursorShape>OpenHandCursor</cursorShape> <string>Map type </string>
</property> </property>
<property name="maxVisibleItems"> <property name="alignment">
<number>15</number> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="frame"> </widget>
<bool>true</bool> </item>
</property> <item row="6" column="3">
</widget> <widget class="QCheckBox" name="checkBoxShowTileGridLines">
</item> <property name="enabled">
<item row="0" column="2"> <bool>true</bool>
<widget class="QLabel" name="label"> </property>
<property name="text"> <property name="mouseTracking">
<string>Map type </string> <bool>true</bool>
</property> </property>
<property name="alignment"> <property name="layoutDirection">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <enum>Qt::RightToLeft</enum>
</property> </property>
</widget> <property name="text">
</item> <string>Show Tile Grid Lines</string>
<item row="6" column="3"> </property>
<widget class="QCheckBox" name="checkBoxShowTileGridLines"> </widget>
<property name="enabled"> </item>
<bool>true</bool> <item row="2" column="0">
</property> <spacer name="horizontalSpacer_4">
<property name="mouseTracking"> <property name="orientation">
<bool>true</bool> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="layoutDirection"> <property name="sizeHint" stdset="0">
<enum>Qt::RightToLeft</enum> <size>
</property> <width>40</width>
<property name="text"> <height>20</height>
<string>Show Tile Grid Lines</string> </size>
</property> </property>
</widget> </spacer>
</item> </item>
<item row="2" column="0"> <item row="6" column="2">
<spacer name="horizontalSpacer_4"> <widget class="QCheckBox" name="checkBoxUseOpenGL">
<property name="orientation"> <property name="enabled">
<enum>Qt::Horizontal</enum> <bool>true</bool>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="layoutDirection">
<size> <enum>Qt::RightToLeft</enum>
<width>40</width> </property>
<height>20</height> <property name="text">
</size> <string>Use OpenGL</string>
</property> </property>
</spacer> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="10" column="0"> <item row="10" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>40</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="text"> <property name="text">
<string>Server and Cache</string> <string>Server and Cache</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0"> <item row="9" column="0">
<widget class="Line" name="line_2"> <widget class="Line" name="line_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</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"> </item>
<widget class="QPushButton" name="pushButtonCacheDefaults"> <item row="4" column="0">
<property name="sizePolicy"> <layout class="QHBoxLayout" name="horizontalLayout">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <item>
<horstretch>0</horstretch> <spacer name="horizontalSpacer_3">
<verstretch>0</verstretch> <property name="orientation">
</sizepolicy> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="cursor"> <property name="sizeHint" stdset="0">
<cursorShape>OpenHandCursor</cursorShape> <size>
</property> <width>40</width>
<property name="toolTip"> <height>20</height>
<string>Restore default server and cache settings</string> </size>
</property> </property>
<property name="text"> </spacer>
<string> Default </string> </item>
</property> <item>
<property name="checkable"> <widget class="QLabel" name="label_6">
<bool>false</bool> <property name="text">
</property> <string>Access mode </string>
<property name="checked"> </property>
<bool>false</bool> <property name="alignment">
</property> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="flat"> </property>
<bool>false</bool> </widget>
</property> </item>
</widget> <item>
</item> <widget class="QComboBox" name="accessModeComboBox">
<item row="5" column="0"> <property name="sizePolicy">
<spacer name="horizontalSpacer_2"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<property name="orientation"> <horstretch>0</horstretch>
<enum>Qt::Horizontal</enum> <verstretch>0</verstretch>
</property> </sizepolicy>
<property name="sizeHint" stdset="0"> </property>
<size> <property name="minimumSize">
<width>40</width> <size>
<height>20</height> <width>160</width>
</size> <height>0</height>
</property> </size>
</spacer> </property>
</item> <property name="cursor">
</layout> <cursorShape>OpenHandCursor</cursorShape>
</item> </property>
<item row="4" column="0"> <property name="frame">
<layout class="QHBoxLayout" name="horizontalLayout"> <bool>true</bool>
<item> </property>
<spacer name="horizontalSpacer_3"> </widget>
<property name="orientation"> </item>
<enum>Qt::Horizontal</enum> </layout>
</property> </item>
<property name="sizeHint" stdset="0"> <item row="6" column="0">
<size> <layout class="QHBoxLayout" name="horizontalLayout_3">
<width>40</width> <item>
<height>20</height> <widget class="QLabel" name="label_5">
</size> <property name="sizePolicy">
</property> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
</spacer> <horstretch>0</horstretch>
</item> <verstretch>0</verstretch>
<item> </sizepolicy>
<widget class="QLabel" name="label_6"> </property>
<property name="text"> <property name="text">
<string>Access mode </string> <string>Cache location </string>
</property> </property>
<property name="alignment"> </widget>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </item>
</property> <item>
</widget> <widget class="Utils::PathChooser" name="lineEditCacheLocation" native="true">
</item> <property name="sizePolicy">
<item> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<widget class="QComboBox" name="accessModeComboBox"> <horstretch>0</horstretch>
<property name="sizePolicy"> <verstretch>0</verstretch>
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> </sizepolicy>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> </widget>
</sizepolicy> </item>
</property> <item>
<property name="minimumSize"> <widget class="QPushButton" name="pushButtonCacheDefaults">
<size> <property name="sizePolicy">
<width>160</width> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<height>0</height> <horstretch>0</horstretch>
</size> <verstretch>0</verstretch>
</property> </sizepolicy>
<property name="cursor"> </property>
<cursorShape>OpenHandCursor</cursorShape> <property name="cursor">
</property> <cursorShape>OpenHandCursor</cursorShape>
<property name="frame"> </property>
<bool>true</bool> <property name="toolTip">
</property> <string>Restore default server and cache settings</string>
</widget> </property>
</item> <property name="text">
</layout> <string> Default </string>
</item> </property>
<item row="6" column="0"> <property name="checkable">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <bool>false</bool>
<item> </property>
<widget class="QLabel" name="label_5"> <property name="checked">
<property name="text"> <bool>false</bool>
<string>Cache location </string> </property>
</property> <property name="flat">
</widget> <bool>false</bool>
</item> </property>
<item> </widget>
<widget class="QLineEdit" name="lineEditCacheLocation"> </item>
<property name="autoFillBackground"> </layout>
<bool>false</bool> </item>
</property> <item row="5" column="0">
<property name="maxLength"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<number>512</number> <item>
</property> <spacer name="horizontalSpacer">
</widget> <property name="orientation">
</item> <enum>Qt::Horizontal</enum>
<item> </property>
<widget class="QPushButton" name="pushButtonCacheLocation"> <property name="sizeHint" stdset="0">
<property name="cursor"> <size>
<cursorShape>OpenHandCursor</cursorShape> <width>40</width>
</property> <height>20</height>
<property name="text"> </size>
<string/> </property>
</property> </spacer>
<property name="icon"> </item>
<iconset resource="../coreplugin/core.qrc"> <item>
<normaloff>:/core/images/dir.png</normaloff>:/core/images/dir.png</iconset> <widget class="QCheckBox" name="checkBoxUseMemoryCache">
</property> <property name="enabled">
<property name="flat"> <bool>true</bool>
<bool>true</bool> </property>
</property> <property name="layoutDirection">
</widget> <enum>Qt::RightToLeft</enum>
</item> </property>
</layout> <property name="text">
</item> <string>Use Memory Cache</string>
<item row="5" column="0"> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> </widget>
<item> </item>
<spacer name="horizontalSpacer"> </layout>
<property name="orientation"> </item>
<enum>Qt::Horizontal</enum> </layout>
</property> </widget>
<property name="sizeHint" stdset="0"> <customwidgets>
<size> <customwidget>
<width>40</width> <class>Utils::PathChooser</class>
<height>20</height> <extends>QWidget</extends>
</size> <header>utils/pathchooser.h</header>
</property> <container>1</container>
</spacer> </customwidget>
</item> </customwidgets>
<item> <resources/>
<widget class="QCheckBox" name="checkBoxUseMemoryCache"> <connections/>
<property name="enabled"> </ui>
<bool>true</bool>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Use Memory Cache</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../coreplugin/core.qrc"/>
</resources>
<connections/>
</ui>