15 #include "ui_MarbleCacheSettingsWidget.h"
16 #include "ui_MarbleViewSettingsWidget.h"
17 #include "ui_MarbleNavigationSettingsWidget.h"
18 #include "ui_MarbleTimeSettingsWidget.h"
19 #include "ui_MarbleCloudSyncSettingsWidget.h"
24 #include <QNetworkProxy>
25 #include <QApplication>
26 #include <QDialogButtonBox>
27 #include <QMessageBox>
28 #include <QStandardItem>
30 #include <QVBoxLayout>
51 class QtMarbleConfigDialogPrivate
54 QtMarbleConfigDialogPrivate(
MarbleWidget *marbleWidget )
56 ui_navigationSettings(),
59 m_marbleWidget( marbleWidget ),
61 m_cloudSyncSettings( 0 ),
62 m_cloudSyncTabIndex( -1 ),
67 Ui::MarbleViewSettingsWidget ui_viewSettings;
68 Ui::MarbleNavigationSettingsWidget ui_navigationSettings;
69 Ui::MarbleTimeSettingsWidget ui_timeSettings;
70 Ui::MarbleCacheSettingsWidget ui_cacheSettings;
71 Ui::MarbleCloudSyncSettingsWidget ui_cloudSyncSettings;
72 MarblePluginSettingsWidget *w_pluginSettings;
78 RenderPluginModel m_pluginModel;
80 QHash< int, int > m_timezone;
86 int m_cloudSyncTabIndex;
87 QTabWidget* m_tabWidget;
92 d( new QtMarbleConfigDialogPrivate( marbleWidget ) )
94 d->m_tabWidget =
new QTabWidget(
this );
95 QDialogButtonBox *buttons =
96 new QDialogButtonBox( QDialogButtonBox::Ok
97 | QDialogButtonBox::Apply
98 | QDialogButtonBox::Cancel,
104 connect( buttons, SIGNAL(accepted()),
this, SLOT(accept()) );
105 connect( buttons, SIGNAL(rejected()),
this, SLOT(reject()) );
106 connect( buttons->button( QDialogButtonBox::Apply ),SIGNAL(clicked()),
109 connect(
this, SIGNAL(accepted()),
this, SLOT(
writeSettings()) );
114 d->ui_viewSettings.setupUi( w_viewSettings );
115 d->m_tabWidget->addTab( w_viewSettings, tr(
"View" ) );
121 QString nativeString ( tr(
"Native") );
124 nativeString = tr(
"Native (X11)" );
127 nativeString = tr(
"Native (Mac OS X Core Graphics)" );
135 d->ui_navigationSettings.setupUi( w_navigationSettings );
136 d->m_tabWidget->addTab( w_navigationSettings, tr(
"Navigation" ) );
141 d->ui_cacheSettings.setupUi( w_cacheSettings );
142 d->m_tabWidget->addTab( w_cacheSettings, tr(
"Cache and Proxy" ) );
149 d->ui_timeSettings.setupUi( w_timeSettings );
150 d->m_tabWidget->addTab( w_timeSettings, tr(
"Date and Time" ) );
154 d->m_tabWidget->addTab( w_routingSettings, tr(
"Routing" ) );
157 d->m_pluginModel.setRenderPlugins( d->m_marbleWidget->renderPlugins() );
159 d->w_pluginSettings->setModel( &d->m_pluginModel );
160 d->w_pluginSettings->setObjectName(
"plugin_page" );
161 d->m_tabWidget->addTab( d->w_pluginSettings, tr(
"Plugins" ) );
164 d->w_pluginSettings->setAboutIcon( QIcon(
":/icons/help-about.png") );
165 d->w_pluginSettings->setConfigIcon( QIcon(
":/icons/settings-configure.png") );
167 connect(
this, SIGNAL(rejected()), &d->m_pluginModel, SLOT(retrievePluginState()) );
168 connect(
this, SIGNAL(accepted()), &d->m_pluginModel, SLOT(applyPluginState()) );
170 d->m_cloudSyncSettings =
new QWidget;
171 d->ui_cloudSyncSettings.setupUi( d->m_cloudSyncSettings );
172 d->ui_cloudSyncSettings.button_syncNow->setEnabled(
syncBookmarks() );
173 connect( d->ui_cloudSyncSettings.button_syncNow, SIGNAL(clicked()), SIGNAL(
syncNowClicked()) );
176 QVBoxLayout *layout =
new QVBoxLayout(
this );
177 layout->addWidget( d->m_tabWidget );
178 layout->addWidget( buttons );
180 this->setLayout( layout );
183 connect(
this, SIGNAL(
settingsChanged()),
this, SLOT(syncSettings()) );
193 void QtMarbleConfigDialog::syncSettings()
195 d->m_settings.sync();
201 proxy.setType( QNetworkProxy::NoProxy );
210 mDebug() <<
"Unknown proxy type! Using Http Proxy instead.";
223 QNetworkProxy::setApplicationProxy(proxy);
229 d->m_previousGraphicsSystem = d->m_initialGraphicsSystem;
236 d->ui_viewSettings.kcfg_angleUnit->setCurrentIndex(
angleUnit() );
237 d->ui_viewSettings.kcfg_stillQuality->setCurrentIndex(
stillQuality() );
238 d->ui_viewSettings.kcfg_animationQuality->setCurrentIndex(
animationQuality() );
239 d->ui_viewSettings.kcfg_labelLocalization->setCurrentIndex(
Marble::Native );
240 d->ui_viewSettings.kcfg_mapFont->setCurrentFont(
mapFont() );
241 d->ui_viewSettings.kcfg_graphicsSystem->setCurrentIndex(
graphicsSystem() );
245 d->ui_navigationSettings.kcfg_onStartup->setCurrentIndex(
onStartup() );
256 d->ui_navigationSettings.kcfg_externalMapEditor->setCurrentIndex( editorIndex );
261 d->ui_cacheSettings.kcfg_proxyUrl->setText(
proxyUrl() );
262 d->ui_cacheSettings.kcfg_proxyPort->setValue(
proxyPort() );
263 d->ui_cacheSettings.kcfg_proxyUser->setText(
proxyUser() );
264 d->ui_cacheSettings.kcfg_proxyPass->setText(
proxyPass() );
265 d->ui_cacheSettings.kcfg_proxyType->setCurrentIndex(
proxyType() );
266 d->ui_cacheSettings.kcfg_proxyAuth->setChecked(
proxyAuth() );
269 d->ui_timeSettings.kcfg_systemTimezone->setChecked(
systemTimezone() );
270 d->ui_timeSettings.kcfg_customTimezone->setChecked(
customTimezone() );
271 d->ui_timeSettings.kcfg_chosenTimezone->setCurrentIndex(
chosenTimezone() );
272 d->ui_timeSettings.kcfg_utc->setChecked(
UTC() );
273 d->ui_timeSettings.kcfg_systemTime->setChecked(
systemTime() );
274 d->ui_timeSettings.kcfg_lastSessionTime->setChecked(
lastSessionTime() );
277 QDateTime localTime = QDateTime::currentDateTime().toLocalTime();
278 localTime.setTimeSpec( Qt::UTC );
279 d->m_marbleWidget->model()->setClockTimezone( QDateTime::currentDateTime().toUTC().secsTo( localTime ) );
281 else if(
UTC() ==
true )
283 d->m_marbleWidget->model()->setClockTimezone( 0 );
287 d->m_marbleWidget->model()->setClockTimezone( d->m_timezone.value(
chosenTimezone() ) );
293 d->ui_cloudSyncSettings.kcfg_enableSync->setChecked(
syncEnabled() );
294 d->ui_cloudSyncSettings.kcfg_syncBookmarks->setChecked(
syncBookmarks() );
295 d->ui_cloudSyncSettings.kcfg_syncRoutes->setChecked(
syncRoutes() );
296 d->ui_cloudSyncSettings.kcfg_owncloudServer->setText(
owncloudServer() );
297 d->ui_cloudSyncSettings.kcfg_owncloudUsername->setText(
owncloudUsername() );
298 d->ui_cloudSyncSettings.kcfg_owncloudPassword->setText(
owncloudPassword() );
301 d->m_marbleWidget->readPluginSettings( d->m_settings );
312 QString graphicsSystemString;
313 switch ( d->ui_viewSettings.kcfg_graphicsSystem->currentIndex() )
316 graphicsSystemString =
"raster";
319 graphicsSystemString =
"opengl";
323 graphicsSystemString =
"native";
327 d->m_settings.beginGroup(
"View" );
328 d->m_settings.setValue(
"distanceUnit", d->ui_viewSettings.kcfg_distanceUnit->currentIndex() );
329 d->m_settings.setValue(
"angleUnit", d->ui_viewSettings.kcfg_angleUnit->currentIndex() );
330 d->m_settings.setValue(
"stillQuality", d->ui_viewSettings.kcfg_stillQuality->currentIndex() );
331 d->m_settings.setValue(
"animationQuality", d->ui_viewSettings.kcfg_animationQuality->currentIndex() );
332 d->m_settings.setValue(
"mapFont", d->ui_viewSettings.kcfg_mapFont->currentFont() );
333 d->m_settings.setValue(
"graphicsSystem", graphicsSystemString );
334 d->m_settings.endGroup();
336 d->m_settings.beginGroup(
"Navigation" );
337 d->m_settings.setValue(
"onStartup", d->ui_navigationSettings.kcfg_onStartup->currentIndex() );
338 d->m_settings.setValue(
"inertialEarthRotation", d->ui_navigationSettings.kcfg_inertialEarthRotation->isChecked() );
339 d->m_settings.setValue(
"animateTargetVoyage", d->ui_navigationSettings.kcfg_animateTargetVoyage->isChecked() );
340 if( d->ui_navigationSettings.kcfg_externalMapEditor->currentIndex() == 0 ) {
341 d->m_settings.setValue(
"externalMapEditor",
"" );
342 }
else if( d->ui_navigationSettings.kcfg_externalMapEditor->currentIndex() == 1 ) {
343 d->m_settings.setValue(
"externalMapEditor",
"potlatch" );
344 }
else if( d->ui_navigationSettings.kcfg_externalMapEditor->currentIndex() == 2 ) {
345 d->m_settings.setValue(
"externalMapEditor",
"josm" );
346 }
else if( d->ui_navigationSettings.kcfg_externalMapEditor->currentIndex() == 3 ) {
347 d->m_settings.setValue(
"externalMapEditor",
"merkaartor" );
349 Q_ASSERT(
false &&
"Unexpected index of the external editor setting" );
351 d->m_settings.endGroup();
353 d->m_settings.beginGroup(
"Cache" );
354 d->m_settings.setValue(
"volatileTileCacheLimit", d->ui_cacheSettings.kcfg_volatileTileCacheLimit->value() );
355 d->m_settings.setValue(
"persistentTileCacheLimit", d->ui_cacheSettings.kcfg_persistentTileCacheLimit->value() );
356 d->m_settings.setValue(
"proxyUrl", d->ui_cacheSettings.kcfg_proxyUrl->text() );
357 d->m_settings.setValue(
"proxyPort", d->ui_cacheSettings.kcfg_proxyPort->value() );
358 d->m_settings.setValue(
"proxyType", d->ui_cacheSettings.kcfg_proxyType->currentIndex() );
359 if ( d->ui_cacheSettings.kcfg_proxyAuth->isChecked() ) {
360 d->m_settings.setValue(
"proxyAuth",
true );
361 d->m_settings.setValue(
"proxyUser", d->ui_cacheSettings.kcfg_proxyUser->text() );
362 d->m_settings.setValue(
"proxyPass", d->ui_cacheSettings.kcfg_proxyPass->text() );
364 d->m_settings.setValue(
"proxyAuth",
false );
366 d->m_settings.endGroup();
368 d->m_settings.beginGroup(
"Time" );
369 d->m_settings.setValue(
"systemTimezone", d->ui_timeSettings.kcfg_systemTimezone->isChecked() );
370 d->m_settings.setValue(
"UTC", d->ui_timeSettings.kcfg_utc->isChecked() );
371 d->m_settings.setValue(
"customTimezone", d->ui_timeSettings.kcfg_customTimezone->isChecked() );
372 d->m_settings.setValue(
"systemTime", d->ui_timeSettings.kcfg_systemTime->isChecked() );
373 d->m_settings.setValue(
"lastSessionTime", d->ui_timeSettings.kcfg_lastSessionTime->isChecked() );
374 d->m_settings.setValue(
"chosenTimezone", d->ui_timeSettings.kcfg_chosenTimezone->currentIndex() );
375 d->m_settings.endGroup();
377 d->m_settings.beginGroup(
"CloudSync" );
378 d->m_settings.setValue(
"enableSync", d->ui_cloudSyncSettings.kcfg_enableSync->isChecked() );
379 d->m_settings.setValue(
"syncBackend",
"owncloud" );
380 d->m_settings.setValue(
"syncBookmarks", d->ui_cloudSyncSettings.kcfg_syncBookmarks->isChecked() );
381 d->m_settings.setValue(
"syncRoutes", d->ui_cloudSyncSettings.kcfg_syncRoutes->isChecked() );
382 d->m_settings.setValue(
"owncloudServer", d->ui_cloudSyncSettings.kcfg_owncloudServer->text() );
383 d->m_settings.setValue(
"owncloudUsername", d->ui_cloudSyncSettings.kcfg_owncloudUsername->text() );
384 d->m_settings.setValue(
"owncloudPassword", d->ui_cloudSyncSettings.kcfg_owncloudPassword->text() );
385 d->m_settings.endGroup();
388 d->m_marbleWidget->writePluginSettings( d->m_settings );
394 QMessageBox::information (
this, tr(
"Graphics System Change"),
395 tr(
"You have decided to run Marble with a different graphics system.\n"
396 "For this change to become effective, Marble has to be restarted.\n"
397 "Please close the application and start Marble again.") );
404 if( d->m_settings.contains(
"View/distanceUnit" ) ) {
405 return (QLocale::MeasurementSystem) d->m_settings.value(
"View/distanceUnit" ).toInt();
432 return d->m_settings.value(
"View/mapFont", QApplication::font() ).value<QFont>();
437 QString graphicsSystemString = d->m_settings.value(
"View/graphicsSystem",
"raster" ).toString();
450 return d->m_settings.value(
"Navigation/onStartup", defaultValue ).toInt();
455 return d->m_settings.value(
"Navigation/externalMapEditor",
"" ).toString();
461 return d->m_settings.value(
"Navigation/animateTargetVoyage", smallScreen ).toBool();
466 return d->m_settings.value(
"Navigation/inertialEarthRotation",
true ).toBool();
472 return d->m_settings.value(
"Cache/volatileTileCacheLimit", defaultValue ).toInt();
477 return d->m_settings.value(
"Cache/persistentTileCacheLimit", 0 ).toInt();
482 return d->m_settings.value(
"Cache/proxyUrl",
"" ).toString();
487 return d->m_settings.value(
"Cache/proxyPort", 8080 ).toInt();
492 return d->m_settings.value(
"Cache/proxyUser",
"" ).toString();
497 return d->m_settings.value(
"Cache/proxyPass",
"" ).toString();
507 return d->m_settings.value(
"Cache/proxyAuth",
false ).toBool();
512 return d->m_settings.value(
"Time/systemTimezone",
true ).toBool();
517 return d->m_settings.value(
"Time/customTimezone",
false ).toBool();
522 return d->m_settings.value(
"Time/UTC",
false ).toBool();
527 return d->m_settings.value(
"Time/systemTime",
true ).toBool();
532 return d->m_settings.value(
"Time/lastSessionTime",
false ).toBool();
537 return d->m_settings.value(
"Time/chosenTimezone", 0 ).toInt();
542 if( d->m_timezone.count() == 0)
544 d->m_timezone.insert( 0, 0 );
545 d->m_timezone.insert( 1, 3600 );
546 d->m_timezone.insert( 2, 7200 );
547 d->m_timezone.insert( 3, 7200 );
548 d->m_timezone.insert( 4, 10800 );
549 d->m_timezone.insert( 5, 12600 );
550 d->m_timezone.insert( 6, 14400 );
551 d->m_timezone.insert( 7, 18000 );
552 d->m_timezone.insert( 8, 19800 );
553 d->m_timezone.insert( 9, 21600 );
554 d->m_timezone.insert( 10, 25200 );
555 d->m_timezone.insert( 11, 28800 );
556 d->m_timezone.insert( 12, 32400 );
557 d->m_timezone.insert( 13, 34200 );
558 d->m_timezone.insert( 14, 36000 );
559 d->m_timezone.insert( 15, 39600 );
560 d->m_timezone.insert( 16, 43200 );
561 d->m_timezone.insert( 17, -39600 );
562 d->m_timezone.insert( 18, -36000 );
563 d->m_timezone.insert( 19, -32400 );
564 d->m_timezone.insert( 20, -28800 );
565 d->m_timezone.insert( 21, -25200 );
566 d->m_timezone.insert( 22, -25200 );
567 d->m_timezone.insert( 23, -21600 );
568 d->m_timezone.insert( 24, -18000 );
569 d->m_timezone.insert( 25, -18000 );
570 d->m_timezone.insert( 26, -14400 );
571 d->m_timezone.insert( 27, -12600 );
572 d->m_timezone.insert( 28, -10800 );
573 d->m_timezone.insert( 29, -10800 );
574 d->m_timezone.insert( 30, -3600 );
580 if ( show && d->m_cloudSyncTabIndex < 0 ) {
581 d->m_cloudSyncTabIndex = d->m_tabWidget->addTab( d->m_cloudSyncSettings, tr(
"Synchronization" ) );
582 }
else if ( !show && d->m_cloudSyncTabIndex >= 0 ) {
583 d->m_tabWidget->removeTab( d->m_cloudSyncTabIndex );
584 d->m_cloudSyncTabIndex = -1;
590 return d->m_settings.value(
"CloudSync/enableSync",
false ).toBool();
595 return d->m_settings.value(
"CloudSync/syncBackend",
"" ).toString();
600 return d->m_settings.value(
"CloudSync/syncBookmarks",
true ).toBool();
605 return d->m_settings.value(
"CloudSync/syncRoutes",
true ).toBool();
610 return d->m_settings.value(
"CloudSync/owncloudServer",
"" ).toString();
615 return d->m_settings.value(
"CloudSync/owncloudUsername",
"" ).toString();
620 return d->m_settings.value(
"CloudSync/owncloudPassword",
"" ).toString();
625 #include "QtMarbleConfigDialog.moc"
Renders everything onto a pixmap.
void clearPersistentCacheClicked()
The user clicked on the button to clear persistent tile cache.
Show home location on startup.
bool animateTargetVoyage() const
void initializeCustomTimezone()
QLocale::MeasurementSystem measurementSystem() const
Keep planet axis vertically.
QString proxyUser() const
This file contains the headers for MarbleModel.
QString owncloudServer() const
MapQuality
This enum is used to choose the map quality shown in the view.
QString owncloudPassword() const
QString proxyPass() const
Uses the native graphics system of the OS.
void setShowCloudSync(bool show)
Low resolution (e.g. interlaced)
int persistentTileCacheLimit() const
int chosenTimezone() const
Read the value of 'Time/chosenTimezone' key from settings.
Display the name in the official language and glyphs of the labeled place.
bool inertialEarthRotation() const
MarbleLocale * locale() const
static MarbleGlobal * getInstance()
A class that contains all localization stuff for Marble.
bool customTimezone() const
Read the value of 'Time/customTimezone' key from settings.
Show last location visited on quit.
QString syncBackend() const
QLocale::MeasurementSystem measurementSystem() const
bool lastSessionTime() const
Read the value of 'Time/lastSessionTime' key from settings.
QString externalMapEditor() const
AngleUnit
This enum is used to choose the unit chosen to measure angles.
High quality (e.g. antialiasing for lines)
void readSettings()
Read settings and update interface.
bool systemTimezone() const
Read the value of 'Time/systemTimezone' key from settings.
QString owncloudUsername() const
Profiles profiles() const
void settingsChanged()
This signal is emitted when when the loaded settings were changed.
void syncNowClicked()
The user clicked on the button to manually synchronize bookmarks.
void clearVolatileCacheClicked()
The user clicked on the button to clear volatile tile cache.
bool systemTime() const
Read the value of 'Time/systemTime' key from settings.
bool UTC() const
Read the value of 'Time/UTC' key from settings.
void writeSettings()
Write settings to disk.
GraphicsSystem
This enum is used to choose which graphics system Qt is using.
bool syncBookmarks() const
Marble::AngleUnit angleUnit() const
int volatileTileCacheLimit() const
Marble::MapQuality animationQuality() const
QDebug mDebug()
a function to replace qDebug() in Marble library code
QtMarbleConfigDialog(MarbleWidget *marbleWidget, QWidget *parent=0)
Marble::MapQuality stillQuality() const
Marble::GraphicsSystem graphicsSystem() const