summaryrefslogtreecommitdiff
path: root/qml/Main.qml
blob: c3470fcd9f10a613eec24f3166b1096a1428055f (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
import QtQuick
import QtWayland.Compositor
import QtWayland.Compositor.XdgShell
import QtQuick.Window
import QtQuick.Controls
import org.kazoe.desktop
import org.kazoe.xdg

WaylandCompositor {
    id: comp
    property string defaultTitle: ""
    property int appHeight: win.height - statusBar.height
    property int appWidth: win.width
    property bool showHomepage: true
    property string statusBarModel: "StatusBar"
    property alias statusBarHeight: statusBar.height

    SystemPalette {
        id: currentTheme
        colorGroup: SystemPalette.Active
    }

    DesktopEntries {
        id: xdgEntries

        onRaiseProcess: {
            manager.currentSurface = waylandEntries.getSurface(pid)
        }
    }

    AutoStart {
        id: autostarter
        Component.onCompleted: {
            autostarter.start("Desktop Entry/X-DESKTOPMGR-AUTOSTART", "true")
        }
    }

    DesktopFilter {
        id: sysbar
        section: "X-DESKTOPMGR-SYSBAR"
        showAll: true
        model: xdgEntries
    }

    DesktopFilter {
        id: systray
        section: "X-DESKTOPMGR-SYSTRAY"
        showAll: true
        model: xdgEntries
    }

    WaylandEntries {
        id: entries
    }

    Connections {
        target: manager
        function onCurrentSurfaceChanged() {
            comp.showHomepage = false
        }

        function onGotoHome() {
            comp.showHomepage = true
        }
    }


    WaylandOutput {
        id: output
        sizeFollowsWindow: true
        transform: WaylandOutput.Transform90
        scaleFactor: 4
        window: Window {
            id: win
            visible: true
            width: 800
            height: 480

            VKeyboard {
                id: keyboard
                anchors.fill: parent
            }

            Flickable {
                anchors.fill: parent
                id: appZoneView
                clip: true
                contentWidth: win.width
                contentHeight: win.height
                flickableDirection: Flickable.VerticalFlick
                interactive: false

                property int textInputY: keyboard.textInputY
                property int textInputHeight: keyboard.textInputHeight
                property bool keyboardActive: keyboard.active
                property int keyboardHeight: keyboard.implicitHeight
                property int wantOffset: (appZoneView.height - keyboardHeight) / 2

                onTextInputYChanged: {
                    if(appZoneView.keyboardActive && appZoneView.contentY == 0)
                    {
                        if(textInputY > (appZoneView.height - keyboardHeight))
                        {
                            appZoneView.contentY = textInputY - textInputHeight - wantOffset
                        }
                    }
                }

                onKeyboardActiveChanged: {
                    appZoneView.contentY = 0
                }

                StatusBar {
                    id: statusBar
                    width: parent.width
                    z: 20
                }

                HomePage {
                    id: homepageview
                    anchors.top: statusBar.bottom
                    anchors.bottom: parent.bottom
                    anchors.left: parent.left
                    anchors.right: parent.right
                    visible: comp.showHomepage
                }

                ShellSurfaceItem {
                    id: appZone
                    visible: !comp.showHomepage
                    anchors.top: statusBar.bottom
                    anchors.bottom: parent.bottom
                    anchors.left: parent.left
                    anchors.right: parent.right

                    shellSurface: manager.currentSurface
                    autoCreatePopupItems: true

                    onWidthChanged: {
                        if(manager.currentSurface)
                            manager.currentSurface.toplevel.sendResizing(Qt.size(appZone.width, appZone.height))
                    }

                    onHeightChanged: {
                        if(manager.currentSurface)
                            manager.currentSurface.toplevel.sendResizing(Qt.size(appZone.width, appZone.height))
                    }
                }
            }
        }
    }

    XdgShell {
        onToplevelCreated: function(toplevel, xdgSurface) {
            toplevel.sendResizing(Qt.size(appZone.width, appZone.height));
            entries.addSurface(xdgSurface)
            manager.currentSurface = xdgSurface
        }
    }

    XdgDecorationManagerV1 {
        preferredMode: XdgToplevel.ServerSideDecoration
    }

    // Extension for Input Method (QT_IM_MODULE) support at compositor-side
    TextInputManager {}
}