Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
Itinerary
Commits
7ab650d1
Commit
7ab650d1
authored
Dec 27, 2018
by
Volker Krause
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add settings for live data auto-polling
parent
6c2c7919
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
0 deletions
+87
-0
src/app/SettingsPage.qml
src/app/SettingsPage.qml
+34
-0
src/app/settings.cpp
src/app/settings.cpp
+42
-0
src/app/settings.h
src/app/settings.h
+11
-0
No files found.
src/app/SettingsPage.qml
View file @
7ab650d1
...
...
@@ -33,6 +33,11 @@ Kirigami.ScrollablePage {
Kirigami.FormLayout
{
width
:
root
.
width
Kirigami.Separator
{
Kirigami.FormData.isSection
:
true
Kirigami.FormData.label
:
i18n
(
"
Home
"
)
}
QQC2.ComboBox
{
Kirigami.FormData.label
:
i18n
(
"
Home Country
"
)
model
:
countryModel
...
...
@@ -41,6 +46,35 @@ Kirigami.ScrollablePage {
onActivated
:
_settings
.
homeCountryIsoCode
=
countryModel
.
isoCodeFromIndex
(
currentIndex
)
}
Kirigami.Separator
{
Kirigami.FormData.isSection
:
true
Kirigami.FormData.label
:
i18n
(
"
Online Services
"
)
}
QQC2.Switch
{
Kirigami.FormData.label
:
i18n
(
"
Query Traffic Data
"
)
checked
:
_settings
.
queryLiveData
onToggled
:
_settings
.
queryLiveData
=
checked
}
QQC2.Label
{
Kirigami.FormData.isSection
:
true
Layout.fillWidth
:
true
wrapMode
:
Text
.
WordWrap
text
:
i18n
(
"
When enabled, this will query transport provider online services for changes such as delays or gate and platform changes.
"
)
}
QQC2.Switch
{
Kirigami.FormData.label
:
i18n
(
"
Use insecure services
"
)
checked
:
_settings
.
allowInsecureServices
onToggled
:
_settings
.
allowInsecureServices
=
checked
}
QQC2.Label
{
Kirigami.FormData.isSection
:
true
Layout.fillWidth
:
true
wrapMode
:
Text
.
WordWrap
text
:
i18n
(
"
Enabling this will also use online services that do not offer transport encryption. This is not recommended, but might be unavoidable when relying on live data from certain providers.
"
)
color
:
Kirigami
.
Theme
.
negativeTextColor
}
QQC2.Switch
{
id
:
weatherSwitch
Kirigami.FormData.label
:
i18n
(
"
Weather Forecast
"
)
...
...
src/app/settings.cpp
View file @
7ab650d1
...
...
@@ -32,6 +32,9 @@ Settings::Settings(QObject *parent)
const
auto
currentCountry
=
KContacts
::
Address
::
countryToISO
(
QLocale
::
countryToString
(
QLocale
().
country
())).
toUpper
();
m_homeCountry
=
s
.
value
(
QLatin1String
(
"HomeCountry"
),
currentCountry
).
toString
();
m_queryLiveData
=
s
.
value
(
QLatin1String
(
"QueryLiveData"
),
false
).
toBool
();
m_allowInsecureServices
=
s
.
value
(
QLatin1String
(
"AllowInsecureServices"
),
false
).
toBool
();
}
Settings
::~
Settings
()
=
default
;
...
...
@@ -73,3 +76,42 @@ void Settings::setHomeCountryIsoCode(const QString& isoCode)
emit
homeCountryIsoCodeChanged
(
isoCode
);
}
bool
Settings
::
queryLiveData
()
const
{
return
m_queryLiveData
;
}
void
Settings
::
setQueryLiveData
(
bool
queryLiveData
)
{
if
(
m_queryLiveData
==
queryLiveData
)
{
return
;
}
m_queryLiveData
=
queryLiveData
;
QSettings
s
;
s
.
beginGroup
(
QLatin1String
(
"Settings"
));
s
.
setValue
(
QLatin1String
(
"QueryLiveData"
),
queryLiveData
);
emit
queryLiveDataChanged
();
}
bool
Settings
::
allowInsecureServices
()
const
{
return
m_allowInsecureServices
;
}
void
Settings
::
setAllowInsecureServices
(
bool
allowInsecure
)
{
if
(
m_allowInsecureServices
==
allowInsecure
)
{
return
;
}
m_allowInsecureServices
=
allowInsecure
;
QSettings
s
;
s
.
beginGroup
(
QLatin1String
(
"Settings"
));
s
.
setValue
(
QLatin1String
(
"AllowInsecureServices"
),
allowInsecure
);
emit
allowInsecureServicesChanged
();
}
src/app/settings.h
View file @
7ab650d1
...
...
@@ -26,6 +26,8 @@ class Settings : public QObject
Q_OBJECT
Q_PROPERTY
(
bool
weatherForecastEnabled
READ
weatherForecastEnabled
WRITE
setWeatherForecastEnabled
NOTIFY
weatherForecastEnabledChanged
)
Q_PROPERTY
(
QString
homeCountryIsoCode
READ
homeCountryIsoCode
WRITE
setHomeCountryIsoCode
NOTIFY
homeCountryIsoCodeChanged
)
Q_PROPERTY
(
bool
queryLiveData
READ
queryLiveData
WRITE
setQueryLiveData
NOTIFY
queryLiveDataChanged
)
Q_PROPERTY
(
bool
allowInsecureServices
READ
allowInsecureServices
WRITE
setAllowInsecureServices
NOTIFY
allowInsecureServicesChanged
)
public:
explicit
Settings
(
QObject
*
parent
=
nullptr
);
~
Settings
();
...
...
@@ -36,13 +38,22 @@ public:
QString
homeCountryIsoCode
()
const
;
void
setHomeCountryIsoCode
(
const
QString
&
isoCode
);
bool
queryLiveData
()
const
;
void
setQueryLiveData
(
bool
queryLiveData
);
bool
allowInsecureServices
()
const
;
void
setAllowInsecureServices
(
bool
allowInsecure
);
signals:
void
weatherForecastEnabledChanged
(
bool
enabled
);
void
homeCountryIsoCodeChanged
(
const
QString
&
isoCode
);
void
queryLiveDataChanged
();
void
allowInsecureServicesChanged
();
private:
QString
m_homeCountry
;
bool
m_weatherEnabled
=
false
;
bool
m_queryLiveData
=
false
;
bool
m_allowInsecureServices
=
false
;
};
#endif // SETTINGS_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment