PanelPage.qml 6,3 КБ
Newer Older
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
1
2
3
// SPDX-FileCopyrightText: Copyright 2013 Jolla Ltd
// SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
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

import QtQuick 2.0
import Sailfish.Silica 1.0

Page {
    id: page

    DockedPanel {
        id: controlPanel

        width: page.isPortrait ? parent.width : Theme.itemSizeExtraLarge + Theme.paddingLarge
        height: page.isPortrait ? Theme.itemSizeExtraLarge + Theme.paddingLarge : parent.height

        dock: page.isPortrait ? Dock.Top : Dock.Left

        Flow {
            width: isPortrait ? undefined : Theme.itemSizeExtraLarge

            anchors.centerIn: parent

            Switch {
                icon.source: "image://theme/icon-m-shuffle"
            }
            Switch {
                icon.source: "image://theme/icon-m-repeat"
            }
            Switch {
                icon.source: "image://theme/icon-m-share"
            }
        }
    }

    Drawer {
        id: drawer

        anchors.fill: parent
        dock: page.isPortrait ? Dock.Top : Dock.Left

        background: SilicaListView {
            anchors.fill: parent
            model: 5

Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
46
47
            //% "Drawer"
            header: PageHeader { title: qsTrId("ui-component-gallery-panel-drawer") }
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
48
49
50

            PullDownMenu {
                MenuItem {
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
51
52
                    //% "Option 1"
                    text: qsTrId("ui-component-gallery-panel-option-1")
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
53
54
                }
                MenuItem {
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
55
56
                    //% "Option 2"
                    text: qsTrId("ui-component-gallery-panel-option-2")
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
57
58
59
60
61
62
63
64
65
                }
            }
            VerticalScrollDecorator {}

            delegate: ListItem {
                id: listItem

                Label {
                    x: Theme.horizontalPageMargin
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
66
67
                    //% "List Item "
                    text: qsTrId("ui-component-gallery-panel-list-item") + modelData
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
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
                    anchors.verticalCenter: parent.verticalCenter
                    highlighted: listItem.highlighted
                }
            }
        }

        SilicaFlickable {
            anchors {
                fill: parent
                leftMargin: page.isPortrait ? 0 : controlPanel.visibleSize
                topMargin: page.isPortrait ? controlPanel.visibleSize : 0
                rightMargin: page.isPortrait ? 0 : progressPanel.visibleSize
                bottomMargin: page.isPortrait ? progressPanel.visibleSize : 0
            }

            clip: isPortrait && (controlPanel.expanded || progressPanel.expanded)

            contentHeight: column.height + Theme.paddingLarge

            VerticalScrollDecorator {}

            MouseArea {
                enabled: drawer.open
                anchors.fill: column
                onClicked: drawer.open = false
            }

            Column {
                id: column
                spacing: Theme.paddingLarge
                width: parent.width
                enabled: !drawer.opened

Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
101
102
                //% "Panels and sections"
                PageHeader { title: qsTrId("ui-component-gallery-panel-panels-and-sections") }
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
103
104

                SectionHeader {
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
105
106
                    //% "Panels"
                    text: qsTrId("ui-component-gallery-panel-panels")
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
107
108
                }
                Button {
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
109
110
111
112
113
                    text: controlPanel.open ?
                              //% "Hide controls"
                              qsTrId("ui-component-gallery-panel-hide-controls") :
                              //% "Show controls"
                              qsTrId("ui-component-gallery-panel-show-controls")
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
114
115
116
117
118
                    onClicked: controlPanel.open = !controlPanel.open
                    anchors.horizontalCenter: parent.horizontalCenter
                }

                Button {
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
119
120
121
122
123
                    text: progressPanel.open ?
                              //% "Hide progress"
                              qsTrId("ui-component-gallery-panel-hide-progress") :
                              //% "Show progress"
                              qsTrId("ui-component-gallery-panel-show-progress")
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
124
125
126
127
128
                    onClicked: progressPanel.open = !progressPanel.open
                    anchors.horizontalCenter: parent.horizontalCenter
                }

                Button {
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
129
130
                    //% "Open drawer"
                    text: qsTrId("ui-component-gallery-panel-open-drawer")
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
131
132
133
134
135
                    onClicked: drawer.open = true
                    anchors.horizontalCenter: parent.horizontalCenter
                }

                SectionHeader {
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
136
137
                    //% "Expanding sections"
                    text: qsTrId("ui-component-gallery-panel-expanding-sections")
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
138
139
140
141
142
143
144
145
146
147
148
                }
                ExpandingSectionGroup {
                    currentIndex: 0

                    Repeater {
                        model: 5

                        ExpandingSection {
                            id: section

                            property int sectionIndex: model.index
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
149
150
                            //% "Section "
                            title: qsTrId("ui-component-gallery-panel-section") + (model.index + 1)
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
151
152
153
154
155
156
157
158

                            content.sourceComponent: Column {
                                width: section.width

                                Repeater {
                                    model: (section.sectionIndex + 1) * 2

                                    TextSwitch {
Alexey Andreyev's avatar
Alexey Andreyev включено в состав коммита
159
160
                                        //% "Option "
                                        text: qsTrId("ui-component-gallery-panel-option") + (model.index + 1)
Alexey Andreev's avatar
Alexey Andreev включено в состав коммита
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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    DockedPanel {
        id: progressPanel

        width: page.isPortrait ? parent.width : Theme.itemSizeExtraLarge + Theme.paddingLarge
        height: page.isPortrait ? Theme.itemSizeExtraLarge + Theme.paddingLarge : parent.height

        dock: page.isPortrait ? Dock.Bottom : Dock.Right

        ProgressCircle {
            id: progressCircle

            anchors.centerIn: parent

            NumberAnimation on value {
                from: 0
                to: 1
                duration: 1000
                running: progressPanel.expanded
                loops: Animation.Infinite
            }
        }
    }
}