forked from chozabu/FriendMap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFriendMapConfigPage.cpp
115 lines (104 loc) · 4.21 KB
/
FriendMapConfigPage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*!
* @file FriendMapConfigPage.cpp
* @author RetroShare Team
*
* Copyright (C) 2014 - RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "FriendMapConfigPage.h"
#include <QCheckBox>
#include "ui_FriendMapConfigPage.h"
//!
//! \brief FriendMapConfigPage::FriendMapConfigPage
//! \param settings
//!
FriendMapConfigPage::FriendMapConfigPage(FriendMapSettings* settings) : ui(new Ui::FriendMapConfigPage) {
ui->setupUi(this);
connect(ui->detached_window, SIGNAL(toggled(bool)), this, SLOT(detached_toggled(bool)));
this->settings = settings;
load();
}
//!
//! \brief FriendMapConfigPage::~FriendMapConfigPage
//! Destructor - destroys the user interface
//
FriendMapConfigPage::~FriendMapConfigPage() {
delete ui;
}
//!
//! \brief FriendMapConfigPage::load
//!
void FriendMapConfigPage::load() {
int themeindex = ui->theme_dgml->findText(QString::fromStdString(settings->map_theme_id));
if (themeindex < 0) {
themeindex = 0;
}
ui->theme_dgml->setCurrentIndex(themeindex);
ui->projection_box->setCurrentIndex(settings->getProjection());
ui->show_grid->setChecked(settings->show_grid);
ui->show_links->setChecked(settings->show_links);
ui->show_borders->setChecked(settings->show_borders);
ui->show_cities->setChecked(settings->show_cities);
ui->show_ice_layer->setChecked(settings->show_ice_layer);
ui->show_clouds->setChecked(settings->show_clouds);
ui->show_city_lights->setChecked(settings->show_city_lights);
ui->show_sun_shading->setChecked(settings->show_sun_shading);
ui->show_avatars->setChecked(settings->show_avatars);
ui->detached_window->setChecked(settings->detached);
ui->geoip_path_line->setText(QString::fromStdString(settings->geoip_data_path));
ui->marble_path_line->setText(settings->marble_path);
}
//!
//! \brief FriendMapConfigPage::save
//! \param errmsg
//! \return
//!
bool FriendMapConfigPage::save(QString& errmsg) {
settings->show_grid = ui->show_grid->isChecked();
settings->show_links = ui->show_links->isChecked();
settings->show_borders = ui->show_borders->isChecked();
settings->show_cities = ui->show_cities->isChecked();
settings->show_ice_layer = ui->show_ice_layer->isChecked();
settings->show_clouds = ui->show_clouds->isChecked();
settings->show_city_lights = ui->show_city_lights->isChecked();
settings->show_sun_shading = ui->show_sun_shading->isChecked();
settings->show_avatars = ui->show_avatars->isChecked();
settings->detached = ui->detached_window->isChecked();
settings->projection = static_cast<Marble::Projection>(ui->projection_box->currentIndex());
settings->map_theme_id = ui->theme_dgml->currentText().toStdString();
settings->geoip_data_path = ui->geoip_path_line->text().toStdString();
#ifdef WIN32
// why is this just for windows? On Linux returns warning for unused variable
QString dir = QDir::fromNativeSeparators(ui->marble_path_line->text());
if (!settings->setMarblePath(QDir(dir))) {
errmsg = "invalid marble path";
return false;
}
#endif
emit configChanged();
settings->processSettings(false);
errmsg = ""; // set errmsg to a null string
return true;
}
void FriendMapConfigPage::detached_toggled(bool state) {
if (settings->getDetached() == state) {
ui->detached_window->setText(QString(""));
} else {
ui->detached_window->setText(QString("Restart is required to take effect"));
}
}
// eof