blob: e8489a169a01f94f0bc544504429cf55243a16bf (
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
|
import QtQuick 1.0
import "custom" as Components
import "plugin"
Item{
id: tabWidget
width:100
height:100
property TabBar tabbar
property int current: 0
property int count: stack.children.length
property bool frame:true
property bool tabsVisible: true
property string position: "North"
default property alias tabs : stack.children
onCurrentChanged: __setOpacities()
Component.onCompleted: __setOpacities()
onTabbarChanged: {
tabbar.tabFrame = tabWidget
tabbar.anchors.top = tabWidget.top
tabbar.anchors.left = tabWidget.left
tabbar.anchors.right = tabWidget.right
}
property int __baseOverlap : style.pixelMetric("tabbaseoverlap");
function __setOpacities() {
for (var i = 0; i < stack.children.length; ++i) {
stack.children[i].opacity = (i == current ? 1 : 0)
}
}
QStyleBackground {
id: frame
z:-1
style: QStyleItem {
id:style
elementType: "tabframe"
text: position
value: tabbar && tabsVisible && tabbar.tab(current) ? tabbar.tab(current).x : 0
minimum: tabbar && tabsVisible && tabbar.tab(current) ? tabbar.tab(current).width : 0
}
anchors.fill:parent
Item {
id:stack
anchors.fill:parent
anchors.margins: frame ? 2 : 0
}
anchors.topMargin: tabbar && tabsVisible && position == "North" ? tabbar.height - __baseOverlap : 0
states: [
State {
name: "South"
when: position == "South" && tabbar!= undefined
PropertyChanges {
target: frame
anchors.topMargin: 0
anchors.bottomMargin: tabbar ? tabbar.height - __baseOverlap: 0
}
PropertyChanges {
target: tabbar
anchors.topMargin: -__baseOverlap
}
AnchorChanges {
target: tabbar
anchors.top: frame.bottom
anchors.bottom: undefined
}
}
]
}
}
|