Changeset View
Changeset View
Standalone View
Standalone View
src/controls/private/globaltoolbar/ToolBarPageHeader.qml
Show All 37 Lines | 27 | AbstractPageHeader { | |||
---|---|---|---|---|---|
38 | } | 38 | } | ||
39 | 39 | | |||
40 | Loader { | 40 | Loader { | ||
41 | id: titleLoader | 41 | id: titleLoader | ||
42 | 42 | | |||
43 | anchors { | 43 | anchors { | ||
44 | verticalCenter: parent.verticalCenter | 44 | verticalCenter: parent.verticalCenter | ||
45 | left: parent.left | 45 | left: parent.left | ||
46 | right: actionsLayout.left | 46 | right: parent.right | ||
47 | leftMargin: Units.largeSpacing | 47 | leftMargin: Units.largeSpacing | ||
48 | rightMargin: Units.smallSpacing | 48 | rightMargin: Units.smallSpacing | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | visible: width > item.Layout.minimumWidth | 51 | visible: pageRow.globalToolBar.toolbarActionAlignment == Qt.AlignRight && width > item.Layout.minimumWidth | ||
52 | 52 | | |||
53 | sourceComponent: page ? page.titleDelegate : null | 53 | sourceComponent: page ? page.titleDelegate : null | ||
54 | 54 | | |||
55 | Layout.preferredWidth: item | 55 | Layout.preferredWidth: item | ||
56 | ? (item.Layout.preferredWidth > 0 ? item.Layout.preferredWidth : item.implicitWidth) | 56 | ? (item.Layout.preferredWidth > 0 ? item.Layout.preferredWidth : item.implicitWidth) | ||
57 | : 0 | 57 | : 0 | ||
58 | } | 58 | } | ||
59 | 59 | | |||
60 | 60 | | |||
61 | TextMetrics { | 61 | TextMetrics { | ||
62 | id: buttonTextMetrics | 62 | id: buttonTextMetrics | ||
63 | text: (page.actions.left ? page.actions.left.text : "") + (page.actions.main ? page.actions.main.text : "") + (page.actions.right ? page.actions.right.text : "") | 63 | text: (page.actions.left ? page.actions.left.text : "") + (page.actions.main ? page.actions.main.text : "") + (page.actions.right ? page.actions.right.text : "") | ||
64 | 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) | 64 | 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) | ||
65 | readonly property int requiredWidth: width + collapsedButtonsWidth | 65 | readonly property int requiredWidth: width + collapsedButtonsWidth | ||
66 | } | 66 | } | ||
67 | 67 | | |||
68 | RowLayout { | 68 | RowLayout { | ||
69 | id: actionsLayout | 69 | id: actionsLayout | ||
70 | anchors { | 70 | anchors { | ||
71 | verticalCenter: parent.verticalCenter | 71 | verticalCenter: parent.verticalCenter | ||
72 | left: parent.left | ||||
72 | right: ctxActionsButton.visible ? ctxActionsButton.left : parent.right | 73 | right: ctxActionsButton.visible ? ctxActionsButton.left : parent.right | ||
mart: Perhaps a state machine with AnchorChange may make it a bit better and reliable | |||||
73 | } | 74 | } | ||
74 | 75 | | |||
75 | readonly property bool toobig: root.width - root.leftPadding - root.rightPadding - titleLoader.implicitWidth - Units.gridUnit < buttonTextMetrics.requiredWidth | 76 | readonly property bool toobig: root.width - root.leftPadding - root.rightPadding - titleLoader.implicitWidth - Units.gridUnit < buttonTextMetrics.requiredWidth | ||
76 | 77 | | |||
78 | Item { | ||||
79 | Layout.fillWidth: true | ||||
80 | visible: pageRow.globalToolBar.toolbarActionAlignment != Qt.AlignLeft | ||||
81 | } | ||||
77 | Private.PrivateActionToolButton { | 82 | Private.PrivateActionToolButton { | ||
78 | Layout.alignment: Qt.AlignVCenter | 83 | Layout.alignment: Qt.AlignVCenter | ||
79 | kirigamiAction: page && page.actions ? page.actions.left : null | 84 | kirigamiAction: page && page.actions ? page.actions.left : null | ||
80 | showText: !parent.toobig | 85 | showText: !parent.toobig | ||
81 | } | 86 | } | ||
82 | Private.PrivateActionToolButton { | 87 | Private.PrivateActionToolButton { | ||
83 | Layout.alignment: Qt.AlignVCenter | 88 | Layout.alignment: Qt.AlignVCenter | ||
84 | Layout.rightMargin: Units.smallSpacing | 89 | Layout.rightMargin: Units.smallSpacing | ||
85 | kirigamiAction: page && page.actions ? page.actions.main : null | 90 | kirigamiAction: page && page.actions ? page.actions.main : null | ||
86 | showText: !parent.toobig | 91 | showText: !parent.toobig | ||
87 | } | 92 | } | ||
88 | Private.PrivateActionToolButton { | 93 | Private.PrivateActionToolButton { | ||
89 | Layout.alignment: Qt.AlignVCenter | 94 | Layout.alignment: Qt.AlignVCenter | ||
90 | kirigamiAction: page && page.actions ? page.actions.right : null | 95 | kirigamiAction: page && page.actions ? page.actions.right : null | ||
91 | showText: !parent.toobig | 96 | showText: !parent.toobig | ||
92 | } | 97 | } | ||
98 | Item { | ||||
99 | Layout.fillWidth: true | ||||
100 | visible: pageRow.globalToolBar.toolbarActionAlignment != Qt.AlignRight | ||||
101 | } | ||||
93 | } | 102 | } | ||
94 | 103 | | |||
95 | Private.PrivateActionToolButton { | 104 | Private.PrivateActionToolButton { | ||
96 | id: ctxActionsButton | 105 | id: ctxActionsButton | ||
97 | showMenuArrow: page.actions.contextualActions.length == 1 | 106 | showMenuArrow: page.actions.contextualActions.length == 1 | ||
98 | onMenuAboutToShow: page.contextualActionsAboutToShow(); | 107 | onMenuAboutToShow: page.contextualActionsAboutToShow(); | ||
99 | anchors { | 108 | anchors { | ||
100 | right: parent.right | 109 | right: parent.right | ||
Show All 15 Lines |
Perhaps a state machine with AnchorChange may make it a bit better and reliable