| 1 |
/* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]> |
| 2 |
|
| 3 |
This file is part of Dekko email client for Ubuntu devices |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU General Public License as |
| 7 |
published by the Free Software Foundation; either version 2 of |
| 8 |
the License or (at your option) version 3 |
| 9 |
|
| 10 |
This program is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
import QtQuick 2.4 |
| 19 |
import Lomiri.Components 1.3 |
| 20 |
import Dekko.Mail.API 1.0 |
| 21 |
import Dekko.Mail.Stores.Settings 1.0 |
| 22 |
import PlugMan 1.0 |
| 23 |
import Dekko.Lomiri.Components 1.0 |
| 24 |
|
| 25 |
DekkoPage { |
| 26 |
pageHeader.title: qsTr("Notification Settings: %1").arg(SettingsStore.selectedAccount.name) |
| 27 |
pageHeader.backAction: Action { |
| 28 |
iconName: "back" |
| 29 |
onTriggered: { |
| 30 |
ViewActions.popStageArea(ViewKeys.settingsStack1) |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
function isEnabled() { |
| 35 |
var val = getCustomSetting('enabled') |
| 36 |
if (val !== "") { |
| 37 |
return parseInt(val) > 0; |
| 38 |
} |
| 39 |
return false; |
| 40 |
} |
| 41 |
|
| 42 |
function getCustomSetting(key) { |
| 43 |
return SettingsStore.selectedAccount.customValue('dekko-notify', key); |
| 44 |
} |
| 45 |
|
| 46 |
function setCustomSetting(key, value) { |
| 47 |
SettingsStore.selectedAccount.setCustomValue('dekko-notify', key, value); |
| 48 |
} |
| 49 |
|
| 50 |
PageFlickable { |
| 51 |
LabeledSwitch { |
| 52 |
text: qsTr("Enabled") |
| 53 |
onCheckedChanged: { |
| 54 |
if (checked !== isEnabled()) { |
| 55 |
setCustomSetting('enabled', checked ? '1' : '0'); |
| 56 |
} |
| 57 |
} |
| 58 |
Component.onCompleted: { |
| 59 |
checked = isEnabled() |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
} |