Changeset View
Changeset View
Standalone View
Standalone View
src/controls/ToolBarApplicationHeader.qml
Show All 16 Lines | |||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.5 | 20 | import QtQuick 2.5 | ||
21 | import QtQuick.Controls 1.3 as Controls | 21 | import QtQuick.Controls 1.3 as Controls | ||
22 | import QtQuick.Layouts 1.2 | 22 | import QtQuick.Layouts 1.2 | ||
23 | import QtQuick.Controls.Private 1.0 | 23 | import QtQuick.Controls.Private 1.0 | ||
24 | import "private" | 24 | import "private" | ||
25 | import org.kde.kirigami 1.0 | 25 | import org.kde.kirigami 2.0 | ||
26 | 26 | | |||
27 | 27 | | |||
28 | /** | 28 | /** | ||
29 | * | 29 | * | ||
30 | */ | 30 | */ | ||
31 | ApplicationHeader { | 31 | ApplicationHeader { | ||
32 | id: header | 32 | id: header | ||
33 | 33 | | |||
34 | preferredHeight: 34//spacer.height | 34 | preferredHeight: 38 | ||
35 | maximumHeight: preferredHeight | 35 | maximumHeight: preferredHeight | ||
36 | 36 | | |||
37 | Controls.ToolButton { | | |||
38 | id: spacer | | |||
39 | iconName: "go-previous" | | |||
40 | visible: false | | |||
41 | } | | |||
42 | | ||||
43 | //FIXME: needs a property difinition to have its own type in qml | 37 | //FIXME: needs a property difinition to have its own type in qml | ||
44 | property string _internal: "" | 38 | property string _internal: "" | ||
45 | 39 | | |||
46 | pageDelegate: Item { | 40 | pageDelegate: Item { | ||
47 | id: delegateItem | 41 | id: delegateItem | ||
48 | readonly property Page page: applicationWindow().pageStack.get(modelData) | 42 | readonly property Page page: applicationWindow().pageStack.get(modelData) | ||
49 | property ListView view: ListView.view | 43 | property ListView view: ListView.view | ||
50 | readonly property bool current: __appWindow.pageStack.currentIndex == index | 44 | readonly property bool current: __appWindow.pageStack.currentIndex == index | ||
51 | property Row layout | 45 | property Row layout | ||
52 | 46 | | |||
53 | width: { | 47 | width: { | ||
54 | //more columns shown? | 48 | //more columns shown? | ||
55 | if (__appWindow.wideScreen) { | 49 | if (__appWindow.wideScreen) { | ||
56 | if (modelData == 0 && view.x > 0) { | 50 | if (modelData == 0 && view.x > 0) { | ||
57 | return page.width - Math.max(0, view.x - __appWindow.contentItem.x); | 51 | return page.width - view.x; | ||
58 | } else { | 52 | } else { | ||
59 | return page.width; | 53 | return page.width; | ||
60 | } | 54 | } | ||
61 | } else { | 55 | } else { | ||
62 | return Math.min(view.width, delegateRoot.implicitWidth + Units.smallSpacing); | 56 | return Math.min(view.width, delegateRoot.implicitWidth + Units.smallSpacing); | ||
63 | } | 57 | } | ||
64 | } | 58 | } | ||
65 | height: view.height | 59 | height: view.height | ||
66 | 60 | | |||
67 | Component.onCompleted: { | 61 | Component.onCompleted: { | ||
68 | layout = toolbarComponent.createObject(delegateItem) | 62 | layout = toolbarComponent.createObject(delegateItem) | ||
69 | } | 63 | } | ||
70 | Component { | 64 | Component { | ||
71 | id: toolbarComponent | 65 | id: toolbarComponent | ||
72 | Row { | 66 | Row { | ||
73 | id: layout | 67 | id: layout | ||
68 | anchors.verticalCenter: parent.verticalCenter | ||||
74 | x: __appWindow.wideScreen ? (Math.min(delegateItem.width - width, Math.max(0, delegateItem.view.contentX - delegateItem.x))) : 0 | 69 | x: __appWindow.wideScreen ? (Math.min(delegateItem.width - width, Math.max(0, delegateItem.view.contentX - delegateItem.x))) : 0 | ||
70 | spacing: 2 | ||||
75 | 71 | | |||
76 | Rectangle { | 72 | Rectangle { | ||
77 | anchors.verticalCenter: parent.verticalCenter | 73 | anchors.verticalCenter: parent.verticalCenter | ||
78 | color: Theme.textColor | 74 | color: Theme.textColor | ||
79 | opacity: 0.3 | 75 | opacity: 0.3 | ||
80 | width: Units.devicePixelRatio | 76 | width: Units.devicePixelRatio | ||
81 | height: parent.height * 0.6 | 77 | height: parent.height * 0.6 | ||
82 | } | 78 | } | ||
83 | Controls.ToolButton { | 79 | PrivateActionToolButton { | ||
84 | anchors.verticalCenter: parent.verticalCenter | 80 | anchors.verticalCenter: parent.verticalCenter | ||
85 | iconName: page && page.actions && page.actions.main ? page.actions.main.iconName : "" | 81 | action: page && page.actions ? page.actions.left : null | ||
86 | text: page && page.actions && page.actions.main ? page.actions.main.text : "" | 82 | showText: false | ||
87 | tooltip: page && page.actions && page.actions.main ? page.actions.main.text : "" | | |||
88 | checkable: page && page.actions && page.actions.main && page.actions.main.checkable | | |||
89 | checked: page && page.actions && page.actions.main && page.actions.main.checked | | |||
90 | enabled: page && page.actions && page.actions.main && page.actions.main.enabled | | |||
91 | opacity: enabled ? 1 : 0.4 | | |||
92 | visible: page && page.actions && page.actions.main && page.actions.main.visible | | |||
93 | onClicked: page.actions.main.trigger(); | | |||
94 | } | 83 | } | ||
95 | Controls.ToolButton { | 84 | PrivateActionToolButton { | ||
96 | anchors.verticalCenter: parent.verticalCenter | 85 | anchors.verticalCenter: parent.verticalCenter | ||
97 | iconName: page && page.actions && page.actions.left ? page.actions.left.iconName : "" | 86 | action: page && page.actions ? page.actions.main : null | ||
98 | text: page && page.actions && page.actions.left ? page.actions.left.text : "" | 87 | showText: false | ||
99 | tooltip: page && page.actions && page.actions.left ? page.actions.left.text : "" | | |||
100 | checkable: page && page.actions && page.actions.left && page.actions.left.checkable | | |||
101 | checked: page && page.actions && page.actions.left && page.actions.left.checked | | |||
102 | enabled: page && page.actions && page.actions.left && page.actions.left.enabled | | |||
103 | opacity: enabled ? 1 : 0.4 | | |||
104 | visible: page && page.actions && page.actions.left && page.actions.left && page.actions.left.visible | | |||
105 | onClicked: page.actions.left.trigger(); | | |||
106 | } | 88 | } | ||
107 | Controls.ToolButton { | 89 | PrivateActionToolButton { | ||
108 | anchors.verticalCenter: parent.verticalCenter | 90 | anchors.verticalCenter: parent.verticalCenter | ||
109 | iconName: page && page.actions && page.actions.right ? page.actions.right.iconName : "" | 91 | action: page && page.actions ? page.actions.right : null | ||
110 | text: page && page.actions && page.actions.right ? page.actions.right.text : "" | 92 | showText: false | ||
111 | tooltip: page && page.actions && page.actions.right ? page.actions.right.text : "" | | |||
112 | checkable: page && page.actions && page.actions.right && page.actions.right.checkable | | |||
113 | checked: page && page.actions && page.actions.right && page.actions.right.checked | | |||
114 | enabled: page && page.actions && page.actions.right && page.actions.right.enabled | | |||
115 | opacity: enabled ? 1 : 0.4 | | |||
116 | visible: page && page.actions && page.actions.right && page.actions.right && page.actions.right.visible | | |||
117 | onClicked: page.actions.right.trigger(); | | |||
118 | } | 93 | } | ||
119 | Rectangle { | 94 | Rectangle { | ||
120 | anchors.verticalCenter: parent.verticalCenter | 95 | anchors.verticalCenter: parent.verticalCenter | ||
121 | color: Theme.textColor | 96 | color: Theme.textColor | ||
122 | opacity: 0.3 | 97 | opacity: 0.3 | ||
123 | width: Units.devicePixelRatio | 98 | width: Units.devicePixelRatio | ||
124 | height: parent.height * 0.6 | 99 | height: parent.height * 0.6 | ||
125 | } | 100 | } | ||
126 | Repeater { | 101 | Repeater { | ||
127 | id: repeater | 102 | id: repeater | ||
128 | model: page && page.actions.contextualActions ? page.actions.contextualActions : null | 103 | model: page && page.actions.contextualActions ? page.actions.contextualActions : null | ||
129 | delegate: Controls.ToolButton { | 104 | delegate: PrivateActionToolButton { | ||
130 | anchors.verticalCenter: parent.verticalCenter | 105 | anchors.verticalCenter: parent.verticalCenter | ||
131 | iconName: modelData.iconName | 106 | action: modelData | ||
132 | text: modelData.text | | |||
133 | tooltip: modelData.text | | |||
134 | checkable: modelData.checkable | | |||
135 | checked: modelData.checked | | |||
136 | enabled: modelData.enabled | | |||
137 | opacity: enabled ? 1 : 0.4 | | |||
138 | visible: modelData.visible && x+layout.x+width*2 < delegateItem.width | 107 | visible: modelData.visible && x+layout.x+width*2 < delegateItem.width | ||
139 | onClicked: modelData.trigger(); | | |||
140 | } | 108 | } | ||
141 | } | 109 | } | ||
142 | } | 110 | } | ||
143 | } | 111 | } | ||
144 | Heading { | 112 | Heading { | ||
145 | x: __appWindow.wideScreen ? (Math.min(delegateItem.width - width, Math.max(0, delegateItem.view.contentX - delegateItem.x))) : 0 | 113 | x: __appWindow.wideScreen ? (Math.min(delegateItem.width - width, Math.max(0, delegateItem.view.contentX - delegateItem.x))) : 0 | ||
146 | anchors.verticalCenter: parent.verticalCenter | 114 | anchors.verticalCenter: parent.verticalCenter | ||
147 | visible: layout.width <= 0 | 115 | visible: layout.width <= 0 | ||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |