summaryrefslogtreecommitdiffstats
path: root/examples/demos/todolist/content/SettingsView.qml
blob: 2829edd05d106ec19815f392e0c8a04362895cbe (plain)
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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls
import ToDoList

SettingsViewForm {

    tasksSettingsModel:[{
        "name": qsTr("Remove done tasks"),
        "checked": AppSettings.removeDoneTasks,
        "actionOnClicked": function() {
            AppSettings.removeDoneTasks = !AppSettings.removeDoneTasks
        }
    }]

    themeSettingsModel:[{
        "name": qsTr("Dark mode"),
        "checked": Constants.isDarkModeActive,
        "actionOnClicked": function() {
            if (AppSettings.theme == "Dark") {
                AppSettings.theme = "Light"
            } else {
                AppSettings.theme = "Dark"
            }
        }
    }]

    isThemeOptionAvailable: AppSettings.style !== "iOS"
                            && AppSettings.style !== "Basic"

    backButton.onClicked: StackView.view.pop()

    Component.onCompleted: {
        if (!isThemeOptionAvailable) {
            AppSettings.theme = Qt.binding( function() {
                return  Qt.styleHints.colorScheme === Qt.Dark ? "Dark" : "Light"
            })
        }
    }
}