ProfileSettingsPage.qml 3.62 KB
Newer Older
1
/*
2
 *  Copyright 2013-2018  Andreas Cord-Landwehr <cordlandwehr@kde.org>
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 *
 *  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) version 3 or any later version
 *  accepted by the membership of KDE e.V. (or its successor approved
 *  by the membership of KDE e.V.), which shall act as a proxy
 *  defined in Section 14 of version 3 of the license.
 *
 *  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, see <http://www.gnu.org/licenses/>.
 */

import QtQuick 2.1
22
import QtQuick.Controls 2.0 as QQC2
23
import org.kde.kirigami 2.0 as Kirigami
24
25
26
import QtQuick.Layouts 1.2
import artikulate 1.0

27
Kirigami.Page {
28
    id: root
29
    Layout.fillWidth: true
30

Andreas Cord-Landwehr's avatar
Andreas Cord-Landwehr committed
31
    title: i18n("Configure Profile")
32
33
34
    background: Rectangle {
        color: "#ffffff"
    }
35

36
37
38
39
40
41
42
43
44
45
    readonly property Learner profile: g_profileManager.activeProfile

    signal deletionRequest()

    actions {
        main: Kirigami.Action {
            id: editorAction
            text: i18n("Edit")
            iconName: "document-edit"
            checkable: true
46
        }
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    }

    actions.contextualActions: [
        Kirigami.Action {
            iconName: "insert-image"
            text: i18n("Select Image")
            onTriggered: {
                g_profileManager.openImageFileDialog()
            }
        },
        Kirigami.Action {
            iconName: "edit-clear"
            text: i18n("Clear Image")
            onTriggered: {
                g_profileManager.activeProfile.clearImage()
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
        },
        Kirigami.Action {
            text: i18n("Delete User")
            iconName: "edit-delete"
            enabled: root.state == "editor" && g_profileManager.profileCount > 1 //TODO handle this situation gracefully by allowing removal of last profile
            onTriggered: deletionRequest()
        }
    ]


    // image
    MouseArea {
        id: image
        height: 120
        width: height

        anchors {
            top: parent.top
            right: parent.right
            topMargin: 30
            leftMargin: 30
        }

        ProfileUserImageItem {
            anchors.centerIn: parent
            profile: root.profile
89
        }
90
91

        onClicked: g_profileManager.openImageFileDialog()
92
    }
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

    Text {
        id: learnerNameText
        anchors {
            horizontalCenter: parent.horizontalCenter
            top: image.bottom
            topMargin: 30
        }
        height: paintedHeight
        font.pointSize: theme.fontPointSize * 1.2
        text: root.profile != null ? root.profile.name : ""
    }

    QQC2.TextField {
        id: learnerNameTextEdit
        anchors {
            horizontalCenter: parent.horizontalCenter
            top: image.bottom
            topMargin: 30
        }
        visible: false
        width: parent.width
        placeholderText: i18n("Name")
        text: learnerNameText.text
        onTextChanged: {
            root.profile.name = text
            g_profileManager.sync(root.profile)
        }
    }

    states: [
        State {
            name: "editor"
            when: editorAction.checked
            PropertyChanges {
                target: learnerNameTextEdit
                visible: true
            }
        }
    ]
133
}