33 #include <QDoubleSpinBox>
34 #include <QHBoxLayout>
35 #include <QVBoxLayout>
39 #include "ui_opmapgadgetoptionspage.h"
44 : IOptionsPage(parent)
53 m_page =
new Ui::OPMapGadgetOptionsPage();
54 QWidget *w =
new QWidget(parent);
58 m_page->providerComboBox->clear();
62 m_page->accessModeComboBox->clear();
65 index = m_page->providerComboBox->findText(m_config->
mapProvider());
66 index = (index >= 0) ? index : 0;
67 m_page->providerComboBox->setCurrentIndex(index);
71 m_page->zoomSpinBox->setMaximum(32);
75 m_page->languageComboBox->clear();
77 index = m_page->languageComboBox->findText(m_config->
geoLanguage());
78 index = (index >= 0) ? index : 0;
79 m_page->languageComboBox->setCurrentIndex(index);
82 m_page->maxUpdateRateComboBox->clear();
83 m_page->maxUpdateRateComboBox->addItem(
"100ms", 100);
84 m_page->maxUpdateRateComboBox->addItem(
"200ms", 200);
85 m_page->maxUpdateRateComboBox->addItem(
"500ms", 500);
86 m_page->maxUpdateRateComboBox->addItem(
"1 sec", 1000);
87 m_page->maxUpdateRateComboBox->addItem(
"2 sec", 2000);
88 m_page->maxUpdateRateComboBox->addItem(
"5 sec", 5000);
90 index = m_page->maxUpdateRateComboBox->findData(m_config->
maxUpdateRate());
91 index = (index >= 0) ? index : 4;
92 m_page->maxUpdateRateComboBox->setCurrentIndex(index);
94 m_page->zoomSpinBox->setValue(m_config->
zoom());
95 m_page->latitudeSpinBox->setValue(m_config->
latitude());
96 m_page->longitudeSpinBox->setValue(m_config->
longitude());
100 index = m_page->accessModeComboBox->findText(m_config->
accessMode());
101 index = (index >= 0) ? index : 0;
102 m_page->accessModeComboBox->setCurrentIndex(index);
104 m_page->checkBoxUseMemoryCache->setChecked(m_config->
useMemoryCache());
106 m_page->lineEditCacheLocation->setExpectedKind(Utils::PathChooser::Directory);
107 m_page->lineEditCacheLocation->setPromptDialogTitle(tr(
"Choose Cache Directory"));
108 m_page->lineEditCacheLocation->setPath(m_config->
cacheLocation());
113 QDir dir(
":/uavs/images/");
114 QStringList list = dir.entryList();
115 foreach (QString
i, list) {
116 QIcon
icon(QPixmap(
":/uavs/images/" + i));
117 m_page->uavSymbolComboBox->addItem(icon, QString(), i);
119 for (
int x = 0;
x < m_page->uavSymbolComboBox->count(); ++
x) {
120 if (m_page->uavSymbolComboBox->itemData(
x).toString() == m_config->
uavSymbol()) {
121 m_page->uavSymbolComboBox->setCurrentIndex(
x);
125 connect(m_page->pushButtonCacheDefaults, &QAbstractButton::clicked,
this,
126 &OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked);
127 connect(m_page->providerComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
128 &OPMapGadgetOptionsPage::on_providerComboBox_changed);
131 on_providerComboBox_changed();
136 void OPMapGadgetOptionsPage::on_providerComboBox_changed()
138 if (m_page->providerComboBox->currentText() ==
"UserImage") {
139 m_page->CacheLocationLabel->setText(
"Map file location");
140 m_page->zoomSpinBox->setMaximum(32);
141 m_page->userImageScalingGroupBox->show();
142 m_page->lineEditCacheLocation->setExpectedKind(Utils::PathChooser::File);
143 m_page->lineEditCacheLocation->setPromptDialogTitle(tr(
"Choose Map File"));
145 m_page->CacheLocationLabel->setText(
"Cache location");
146 m_page->zoomSpinBox->setMaximum(21);
147 m_page->userImageScalingGroupBox->hide();
148 m_page->lineEditCacheLocation->setExpectedKind(Utils::PathChooser::Directory);
149 m_page->lineEditCacheLocation->setPromptDialogTitle(tr(
"Choose Cache Directory"));
153 void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked()
155 int index = m_page->accessModeComboBox->findText(
"ServerAndCache");
156 index = (index >= 0) ? index : 0;
157 m_page->accessModeComboBox->setCurrentIndex(index);
159 m_page->checkBoxUseMemoryCache->setChecked(
true);
160 m_page->lineEditCacheLocation->setPath(
Utils::PathUtils().GetStoragePath() +
"mapscache"
161 + QDir::separator());
166 m_config->
setMapProvider(m_page->providerComboBox->currentText());
167 m_config->
setZoom(m_page->zoomSpinBox->value());
168 m_config->
setLatitude(m_page->latitudeSpinBox->value());
169 m_config->
setLongitude(m_page->longitudeSpinBox->value());
171 m_config->
setAccessMode(m_page->accessModeComboBox->currentText());
178 m_page->uavSymbolComboBox->itemData(m_page->uavSymbolComboBox->currentIndex()).toString());
180 m_page->maxUpdateRateComboBox->itemData(m_page->maxUpdateRateComboBox->currentIndex())
182 m_config->
setGeoLanguage(m_page->languageComboBox->currentText());
void setCacheLocation(QString cacheLocation)
void setGeoLanguage(QString language)
OPMapGadgetOptionsPage(OPMapGadgetConfiguration *config, QObject *parent=nullptr)
float getUserImageHorizontalScale()
void setUserImageLocation(QString userImageLocation)
void setUserImageHorizontalScale(float userImageHorizontalScale)
float getUserImageVerticalScale()
void setUavSymbol(QString symbol)
void setLatitude(double latitude)
void setUseMemoryCache(bool useMemoryCache)
void setUserImageVerticalScale(float userImageVerticalScale)
QWidget * createPage(QWidget *parent)
void setShowTileGridLines(bool showTileGridLines)
void setLongitude(double longitude)
void setMapProvider(QString provider)
void setAccessMode(QString accessMode)
void setMaxUpdateRate(int update_rate)