Changeset View
Changeset View
Standalone View
Standalone View
src/controls/ToolBarApplicationHeader.qml
Show All 36 Lines | 32 | ApplicationHeader { | |||
---|---|---|---|---|---|
37 | headerStyle: ApplicationHeaderStyle.Titles | 37 | headerStyle: ApplicationHeaderStyle.Titles | ||
38 | 38 | | |||
39 | //FIXME: needs a property difinition to have its own type in qml | 39 | //FIXME: needs a property difinition to have its own type in qml | ||
40 | property string _internal: "" | 40 | property string _internal: "" | ||
41 | 41 | | |||
42 | pageDelegate: Item { | 42 | pageDelegate: Item { | ||
43 | id: delegateItem | 43 | id: delegateItem | ||
44 | readonly property bool current: __appWindow.pageStack.currentIndex == index | 44 | readonly property bool current: __appWindow.pageStack.currentIndex == index | ||
45 | implicitWidth: titleTextMetrics.width/2 + buttonTextMetrics.collapsedButtonsWidth | ||||
45 | 46 | | |||
46 | RowLayout { | 47 | RowLayout { | ||
47 | id: actionsLayout | 48 | id: titleLayout | ||
48 | anchors.verticalCenter: parent.verticalCenter | 49 | anchors { | ||
49 | 50 | verticalCenter: parent.verticalCenter | |||
50 | readonly property bool toobig: Units.iconSizes.medium * 8 > parent.width/3 | 51 | left: parent.left | ||
52 | right: actionsLayout.left | ||||
53 | } | ||||
51 | Separator { | 54 | Separator { | ||
52 | anchors.verticalCenter: parent.verticalCenter | 55 | id: separator | ||
53 | Layout.preferredHeight: parent.height * 0.6 | 56 | Layout.preferredHeight: parent.height * 0.6 | ||
54 | visible: index > 0 | 57 | //assumption on the internal structure of the parent | ||
58 | visible: index > 0 || delegateItem.parent.x > 0 | ||||
59 | } | ||||
60 | | ||||
61 | Heading { | ||||
62 | id: title | ||||
63 | Layout.fillWidth: true | ||||
64 | | ||||
65 | Layout.preferredWidth: implicitWidth | ||||
66 | Layout.minimumWidth: Math.min(titleTextMetrics.width, delegateItem.width - buttonTextMetrics.requiredWidth) | ||||
67 | leftPadding: delegateItem.parent.x > 0 ? 0 : units.gridUnit | ||||
68 | opacity: delegateItem.current ? 1 : 0.4 | ||||
69 | maximumLineCount: 1 | ||||
70 | color: Theme.textColor | ||||
71 | elide: Text.ElideRight | ||||
72 | text: page ? page.title : "" | ||||
73 | } | ||||
74 | } | ||||
75 | | ||||
76 | TextMetrics { | ||||
77 | id: titleTextMetrics | ||||
78 | text: page ? page.title : "" | ||||
79 | font: title.font | ||||
80 | } | ||||
81 | TextMetrics { | ||||
82 | id: buttonTextMetrics | ||||
83 | text: (page.actions.left ? page.actions.left.text : "") + (page.actions.main ? page.actions.main.text : "") + (page.actions.right ? page.actions.right.text : "") | ||||
84 | readonly property int collapsedButtonsWidth: ctxActionsButton.width + (page.actions.left ? ctxActionsButton.width + Units.gridUnit : 0) + (page.actions.main ? ctxActionsButton.width + Units.gridUnit : 0) + (page.actions.right ? ctxActionsButton.width + Units.gridUnit : 0) | ||||
85 | readonly property int requiredWidth: width + collapsedButtonsWidth | ||||
55 | } | 86 | } | ||
87 | | ||||
88 | RowLayout { | ||||
89 | id: actionsLayout | ||||
90 | anchors { | ||||
91 | verticalCenter: parent.verticalCenter | ||||
92 | right: ctxActionsButton.visible ? ctxActionsButton.left : parent.right | ||||
93 | } | ||||
94 | | ||||
95 | readonly property bool toobig: delegateItem.width - titleTextMetrics.width - Units.gridUnit < buttonTextMetrics.requiredWidth | ||||
96 | | ||||
56 | PrivateActionToolButton { | 97 | PrivateActionToolButton { | ||
57 | anchors.verticalCenter: parent.verticalCenter | 98 | anchors.verticalCenter: parent.verticalCenter | ||
58 | kirigamiAction: page && page.actions ? page.actions.left : null | 99 | kirigamiAction: page && page.actions ? page.actions.left : null | ||
59 | showText: !parent.toobig | 100 | showText: !parent.toobig | ||
60 | } | 101 | } | ||
61 | PrivateActionToolButton { | 102 | PrivateActionToolButton { | ||
62 | anchors.verticalCenter: parent.verticalCenter | 103 | anchors.verticalCenter: parent.verticalCenter | ||
63 | kirigamiAction: page && page.actions ? page.actions.main : null | 104 | kirigamiAction: page && page.actions ? page.actions.main : null | ||
64 | showText: !parent.toobig | 105 | showText: !parent.toobig | ||
65 | } | 106 | } | ||
66 | PrivateActionToolButton { | 107 | PrivateActionToolButton { | ||
67 | anchors.verticalCenter: parent.verticalCenter | 108 | anchors.verticalCenter: parent.verticalCenter | ||
68 | kirigamiAction: page && page.actions ? page.actions.right : null | 109 | kirigamiAction: page && page.actions ? page.actions.right : null | ||
69 | showText: !parent.toobig | 110 | showText: !parent.toobig | ||
70 | } | 111 | } | ||
71 | } | 112 | } | ||
72 | 113 | | |||
73 | Heading { | | |||
74 | anchors { | | |||
75 | left: actionsLayout.right | | |||
76 | verticalCenter: parent.verticalCenter | | |||
77 | } | | |||
78 | | ||||
79 | width: parent.width - Math.max(ctxActions.width, actionsLayout.width) | | |||
80 | leftPadding: units.gridUnit | | |||
81 | opacity: delegateItem.current ? 1 : 0.4 | | |||
82 | maximumLineCount: 1 | | |||
83 | color: Theme.textColor | | |||
84 | elide: Text.ElideRight | | |||
85 | text: page ? page.title : "" | | |||
86 | font.pointSize: Math.max(1, (parent.height / 1.6) / Units.devicePixelRatio) | | |||
87 | } | | |||
88 | | ||||
89 | | ||||
90 | PrivateActionToolButton { | 114 | PrivateActionToolButton { | ||
91 | id: ctxActions | 115 | id: ctxActionsButton | ||
92 | showMenuArrow: false | 116 | showMenuArrow: page.actions.contextualActions.length == 1 | ||
93 | anchors { | 117 | anchors { | ||
94 | right: parent.right | 118 | right: parent.right | ||
95 | verticalCenter: parent.verticalCenter | 119 | verticalCenter: parent.verticalCenter | ||
96 | rightMargin: Units.smallSpacing | 120 | rightMargin: Units.smallSpacing | ||
97 | } | 121 | } | ||
98 | Action { | 122 | Action { | ||
99 | id: overflowAction | 123 | id: overflowAction | ||
100 | icon.name: "overflow-menu" | 124 | icon.name: "overflow-menu" | ||
125 | tooltip: qsTr("More Actions") | ||||
101 | visible: children.length > 0 | 126 | visible: children.length > 0 | ||
102 | children: page && page.actions.contextualActions ? page.actions.contextualActions : null | 127 | children: page && page.actions.contextualActions ? page.actions.contextualActions : null | ||
103 | } | 128 | } | ||
104 | 129 | | |||
105 | kirigamiAction: page && page.actions.contextualActions.length === 1 ? page.actions.contextualActions[0] : overflowAction | 130 | kirigamiAction: page && page.actions.contextualActions.length === 1 ? page.actions.contextualActions[0] : overflowAction | ||
106 | } | 131 | } | ||
107 | } | 132 | } | ||
108 | } | 133 | } |