| 1 |
/* |
| 2 |
* This file is based on work taken from Ubuntu Weather app as on September 2019. Copyright (C) 2019 UBports |
| 3 |
* Copyright (C) 2019 Joan Cibersheep |
| 4 |
* |
| 5 |
* |
| 6 |
* This App is free software: you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License version 3 as |
| 8 |
* published by the Free Software Foundation. |
| 9 |
* |
| 10 |
* |
| 11 |
* This App is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
import QtQuick 2.9 |
| 22 |
import Lomiri.Components 1.3 |
| 23 |
|
| 24 |
import Qt.labs.settings 1.0 |
| 25 |
import QtQuick.LocalStorage 2.0 |
| 26 |
|
| 27 |
Item { |
| 28 |
height: themeSetting.height |
| 29 |
|
| 30 |
property string selectedTheme: theming.themeName == "" |
| 31 |
? "System Theme" |
| 32 |
: theming.themeName == "Lomiri.Components.Themes.Ambiance" |
| 33 |
? "Ambiance" |
| 34 |
: "Suru Dark" |
| 35 |
|
| 36 |
property string themeToBe |
| 37 |
|
| 38 |
ListModel { |
| 39 |
id: themeModel |
| 40 |
|
| 41 |
function initialize() { |
| 42 |
themeModel.append([ |
| 43 |
{ "text": "Ambiance", |
| 44 |
"theme": "Lomiri.Components.Themes.Ambiance" |
| 45 |
}, |
| 46 |
{ "text": "Suru Dark", |
| 47 |
"theme": "Lomiri.Components.Themes.SuruDark" |
| 48 |
}, |
| 49 |
{ "text": i18n.tr("System Theme"), |
| 50 |
"theme": "" |
| 51 |
} |
| 52 |
]); |
| 53 |
} |
| 54 |
|
| 55 |
Component.onCompleted: initialize() |
| 56 |
} |
| 57 |
|
| 58 |
ExpandableListItem { |
| 59 |
id: themeSetting |
| 60 |
listViewHeight: themeModel.count * units.gu(6.1) |
| 61 |
model: themeModel |
| 62 |
title.text: selectedTheme |
| 63 |
|
| 64 |
delegate: StandardListItem { |
| 65 |
id: rrr |
| 66 |
title.text: model.text |
| 67 |
icon.name: "ok" |
| 68 |
icon.visible: selectedTheme === model.text |
| 69 |
|
| 70 |
onClicked: { |
| 71 |
themeToBe = model.theme; |
| 72 |
selectedTheme = model.text; |
| 73 |
themeSetting.toggleExpansion(); |
| 74 |
themeTimer.start() |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
Timer { |
| 80 |
id: themeTimer |
| 81 |
//intervall needs to be a minimum of 200, otherwise toggleExpansion is not entirely finished |
| 82 |
interval: 175 |
| 83 |
running: false |
| 84 |
repeat: false |
| 85 |
|
| 86 |
onTriggered: { |
| 87 |
theming.themeName = themeToBe |
| 88 |
} |
| 89 |
} |
| 90 |
} |