summaryrefslogtreecommitdiff
path: root/raveos-calamares-theme/etc/calamares/branding/raveos/localeq.qml
blob: 5386c82c33e8fa851ddd07ebd6e3f915ff7d425d (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
89
90
91
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
import io.calamares.core 1.0
import io.calamares.ui 1.0

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import "RaveOS"

Rectangle {
    id: hely
    color: Stilus.hatter

    readonly property string lcSor: config.currentLCCode || config.currentLanguageCode
    readonly property string lcKod: kod(lcSor)

    function szinkronRegio() {
        if (!config.currentLocation)
            return
        var i = regio.indexOfValue(config.currentLocation.region)
        if (i >= 0) {
            regio.currentIndex = i
            config.regionalZonesModel.region = config.currentLocation.region
            Qt.callLater(varosraGorget)
        }
    }

    function varosraGorget() {
        var m = config.regionalZonesModel
        for (var i = 0; i < m.rowCount(); ++i) {
            if (m.data(m.index(i, 0), Qt.UserRole) === config.currentLocation.zone) {
                varosok.positionViewAtIndex(i, ListView.Center)
                return
            }
        }
    }

    Connections {
        target: config
        function onCurrentLocationChanged() {
            hely.szinkronRegio()
        }
    }

    function kod(sor) {
        return (sor || "").split(" ")[0]
    }

    function nyelvNev(sor) {
        var k = kod(sor)
        var nev = Qt.locale(k.split(".")[0]).nativeLanguageName
        if (!nev)
            return k
        return nev.charAt(0).toUpperCase() + nev.slice(1) + " (" + k + ")"
    }

    function indexOf(lista, ertek) {
        for (var i = 0; i < lista.length; ++i) {
            if (lista[i] === ertek || kod(lista[i]) === kod(ertek))
                return i
        }
        return -1
    }

    component Cimke: Text {
        color: Stilus.szovegHalvany
        font.family: Stilus.font
        font.pixelSize: 12
    }

    component SzakaszCim: Text {
        color: Stilus.szovegHalvany
        font.family: Stilus.font
        font.pixelSize: 12
        font.weight: Font.Medium
        font.letterSpacing: 1
        font.capitalization: Font.AllUppercase
    }

    component ElonezetSor: RowLayout {
        property string nev: ""
        property string ertek: ""
        Layout.fillWidth: true
        spacing: 16

        Text {
            Layout.preferredWidth: 120
            text: parent.nev
            color: Stilus.szovegHalvany
            font.family: Stilus.mono
            font.pixelSize: 12
        }

        Text {
            Layout.fillWidth: true
            text: parent.ertek
            elide: Text.ElideRight
            color: Stilus.szoveg
            font.family: Stilus.mono
            font.pixelSize: 12
        }
    }

    ColumnLayout {
        anchors.fill: parent
        anchors.topMargin: 48
        anchors.bottomMargin: 32
        anchors.leftMargin: 56
        anchors.rightMargin: 56
        spacing: 28

        Fejlec {
            Layout.fillWidth: true
            felirat: qsTr("LOCATION")
            cim: qsTr("TIME ZONE AND FORMATS")
        }

        RowLayout {
            Layout.fillWidth: true
            Layout.fillHeight: true
            spacing: 32

            ColumnLayout {
                Layout.fillWidth: true
                Layout.fillHeight: true
                Layout.preferredWidth: 1
                spacing: 10

                SzakaszCim { text: qsTr("Time zone") }

                Cimke { text: qsTr("Region") }

                Valaszto {
                    id: regio
                    Layout.fillWidth: true
                    model: config.regionModel
                    textRole: "name"
                    valueRole: "key"
                    Component.onCompleted: hely.szinkronRegio()
                    onActivated: {
                        config.regionalZonesModel.region = currentValue
                        varosok.positionViewAtBeginning()
                    }
                }

                Rectangle {
                    Layout.fillWidth: true
                    Layout.fillHeight: true
                    color: Stilus.felulet
                    border.width: 1
                    border.color: Stilus.keret

                    ListView {
                        id: varosok
                        anchors.fill: parent
                        anchors.margins: 1
                        clip: true
                        model: config.regionalZonesModel
                        boundsBehavior: Flickable.StopAtBounds
                        ScrollBar.vertical: Gorgeto {}

                        delegate: Rectangle {
                            readonly property bool kivalasztva: config.currentLocation
                                && config.currentLocation.region === config.regionalZonesModel.region
                                && config.currentLocation.zone === model.key
                            width: varosok.width
                            height: 40
                            color: kivalasztva ? Stilus.zold : (koppintas.hovered ? Stilus.aktiv : "transparent")

                            Rectangle {
                                anchors.left: parent.left
                                anchors.right: parent.right
                                anchors.bottom: parent.bottom
                                height: 1
                                color: Stilus.aktiv
                            }

                            Text {
                                anchors.left: parent.left
                                anchors.leftMargin: 14
                                anchors.right: parent.right
                                anchors.rightMargin: 24
                                anchors.verticalCenter: parent.verticalCenter
                                text: model.name
                                elide: Text.ElideRight
                                color: parent.kivalasztva ? Stilus.zoldonSzoveg : Stilus.szoveg
                                font.family: Stilus.font
                                font.pixelSize: 14
                                font.weight: parent.kivalasztva ? Font.DemiBold : Font.Normal
                            }

                            HoverHandler { id: koppintas }

                            TapHandler {
                                onTapped: config.setCurrentLocation(config.regionalZonesModel.region, model.key)
                            }
                        }
                    }
                }
            }

            ColumnLayout {
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignTop
                Layout.preferredWidth: 1
                spacing: 16

                SzakaszCim { text: qsTr("Language and formats") }

                ColumnLayout {
                    Layout.fillWidth: true
                    spacing: 6

                    Cimke { text: qsTr("System language") }

                    Valaszto {
                        Layout.fillWidth: true
                        model: config.supportedLocales.map(hely.nyelvNev)
                        currentIndex: hely.indexOf(config.supportedLocales, config.currentLanguageCode)
                        onActivated: config.currentLanguageCode = config.supportedLocales[index]
                    }
                }

                ColumnLayout {
                    Layout.fillWidth: true
                    spacing: 6

                    Cimke { text: qsTr("Number and date format") }

                    Valaszto {
                        Layout.fillWidth: true
                        model: config.supportedLocales.map(hely.nyelvNev)
                        currentIndex: hely.indexOf(config.supportedLocales, hely.lcSor)
                        onActivated: config.currentLCCode = config.supportedLocales[index]
                    }
                }

                Rectangle {
                    Layout.fillWidth: true
                    Layout.preferredHeight: elonezet.implicitHeight + 28
                    color: "#141516"
                    border.width: 1
                    border.color: Stilus.keret

                    ColumnLayout {
                        id: elonezet
                        anchors.fill: parent
                        anchors.margins: 14
                        spacing: 10

                        ElonezetSor {
                            nev: qsTr("Time zone")
                            ertek: config.currentLocation ? config.currentLocation.region + "/" + config.currentLocation.zone : ""
                        }

                        ElonezetSor {
                            nev: qsTr("Date")
                            ertek: new Date().toLocaleDateString(Qt.locale(hely.lcKod.split(".")[0]), Locale.ShortFormat)
                        }

                        ElonezetSor {
                            nev: qsTr("Number")
                            ertek: Number(1234567.89).toLocaleString(Qt.locale(hely.lcKod.split(".")[0]), "f", 2)
                        }

                        ElonezetSor {
                            nev: qsTr("Currency")
                            ertek: Number(1234).toLocaleCurrencyString(Qt.locale(hely.lcKod.split(".")[0]))
                        }
                    }
                }
            }
        }
    }
}