File: layerOverDrawer.qml

package info (click to toggle)
kf6-kirigami 6.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,156 kB
  • sloc: cpp: 12,852; xml: 109; sh: 53; makefile: 5
file content (67 lines) | stat: -rw-r--r-- 1,802 bytes parent folder | download
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
/*
 *  SPDX-FileCopyrightText: 2023 Marco Martin <mart@kde.org>
 *
 *  SPDX-License-Identifier: LGPL-2.0-or-later
 */

import QtQuick
import QtQuick.Controls as QQC2
import org.kde.kirigami as Kirigami

/*!
 * This example show how to do a sidebar of an application what gets covered by new layers that might get pushed
 * in the PageRow layer system.
 * When a drawer is in sidebar mode, when it goes modal (for instance when on mobile) will still behave like a drawer
 */
Kirigami.ApplicationWindow {
    id: root

    Kirigami.GlobalDrawer {
        id: drawer
        modal: false

        actions: [
            Kirigami.Action {
                text: "Push Layer"
                onTriggered: root.pageStack.layers.push(layerComponent)
            },
            Kirigami.Action {
                text: "Modal"
                checked: drawer.modal
                checkable: true
                onTriggered: drawer.modal = checked
            }
        ]
    }
    contextDrawer: Kirigami.ContextDrawer {
        id: contextDrawer
    }

    pageStack.initialPage: mainPageComponent
    pageStack.leftSidebar: drawer

    Component {
        id: mainPageComponent
        Kirigami.ScrollablePage {
            title: "Hello"
            QQC2.Pane {
                anchors.fill: parent
                QQC2.Label {
                    text: "Main page: push a layer to cover both this and the sidebar"
                }
            }
        }
    }
    Component {
        id: layerComponent
        Kirigami.ScrollablePage {
            title: "Layer 1"
            QQC2.Pane {
                anchors.fill: parent
                QQC2.Label {
                    text: "Layer page: this should cover the whole window: main page and sidebar"
                }
            }
        }
    }
}