-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockControl.qml
More file actions
97 lines (77 loc) · 2.45 KB
/
Copy pathDockControl.qml
File metadata and controls
97 lines (77 loc) · 2.45 KB
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
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 1.4
Item {
default property alias contents: content.children
property var dockWindow: null
property Item dockSpace: null
property bool titleVisible: true
property string dockTitle: "Dock title"
property real contentMargins: 1
id: dockItem
width: parent.width
height: parent.height
Rectangle {
anchors { fill: parent; margins: contentMargins }
Rectangle {
id: headerPanel
anchors { left: parent.left; right: parent.right; top: parent.top; }
border { width: 1; color: "gray" }
height: !dockWindow.visible && titleVisible ? 20 : 0
visible: !dockWindow.visible && titleVisible
Text {
anchors { left: parent.left; right: closeImage.left; top: parent.top; bottom: parent.bottom }
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: dockTitle
MouseArea {
anchors.fill: parent
onDoubleClicked: unDock()
}
}
Image {
id: closeImage
anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 5 }
source: "qrc:/close.svg"
width: 16
height: 16
MouseArea {
anchors.fill: parent
onClicked: hide()
}
}
}
Rectangle {
id: content
anchors { left: parent.left; right: parent.right; top: headerPanel.bottom; bottom: parent.bottom }
border { width: 1; color: "lightgray" }
}
}
Component {
id: dockComponent
Window {
title: dockTitle
width: 300
height: 200
visible: false
onVisibleChanged:
{
if(!visible) dockSpace.freeDock(dockItem);
}
}
}
Component.onCompleted: dockWindow = dockComponent.createObject(dockItem);
function hide()
{
if(dockSpace != null) dockSpace.hideDock(dockItem);
}
function unDock()
{
if(dockSpace != null)
{
dockSpace.unSplit(dockItem);
dockItem.parent = dockWindow.contentItem;
dockWindow.show();
}
}
}