diff --git a/src/controls/ActionToolBar.qml b/src/controls/ActionToolBar.qml --- a/src/controls/ActionToolBar.qml +++ b/src/controls/ActionToolBar.qml @@ -82,11 +82,8 @@ : Controls.ToolBar.Header implicitHeight: actionsLayout.implicitHeight - implicitWidth: actionsLayout.implicitWidth - - Layout.minimumWidth: moreButton.implicitWidth - Layout.maximumWidth: placeholderLayout.implicitWidth + moreButton.width + Layout.minimumWidth: moreButton.visible ? moreButton.implicitWidth : 0 RowLayout { id: actionsLayout diff --git a/src/controls/Page.qml b/src/controls/Page.qml --- a/src/controls/Page.qml +++ b/src/controls/Page.qml @@ -240,18 +240,12 @@ id: title level: 1 Layout.fillWidth: true - - Layout.preferredWidth: titleTextMetrics.width - Layout.minimumWidth: titleTextMetrics.width + Layout.maximumWidth: implicitWidth + 1 // The +1 is to make sure we do not trigger eliding at max width + Layout.minimumWidth: 0 opacity: root.isCurrentPage ? 1 : 0.4 maximumLineCount: 1 elide: Text.ElideRight text: root.title - TextMetrics { - id: titleTextMetrics - text: root.title - font: title.font - } } /** diff --git a/src/controls/private/globaltoolbar/ToolBarPageHeader.qml b/src/controls/private/globaltoolbar/ToolBarPageHeader.qml --- a/src/controls/private/globaltoolbar/ToolBarPageHeader.qml +++ b/src/controls/private/globaltoolbar/ToolBarPageHeader.qml @@ -27,66 +27,66 @@ AbstractPageHeader { id: root - implicitWidth: titleLoader.implcitWidth + toolBar.implicitWidth + Units.smallSpacing * 3 - + implicitWidth: layout.implcitWidth + Units.smallSpacing * 2 Layout.preferredHeight: Math.max(titleLoader.implicitHeight, toolBar.implicitHeight) + Units.smallSpacing * 2 MouseArea { anchors.fill: parent onClicked: page.forceActiveFocus() } - Loader { - id: titleLoader - - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - leftMargin: Units.smallSpacing - rightMargin: Units.smallSpacing - } - - visible: pageRow.globalToolBar.toolbarActionAlignment == Qt.AlignRight && width > item.Layout.minimumWidth + RowLayout { + id: layout + anchors.fill: parent + anchors.leftMargin: Units.smallSpacing + anchors.rightMargin: Units.smallSpacing + spacing: Units.smallSpacing - sourceComponent: page ? page.titleDelegate : null - } + Loader { + id: titleLoader - ActionToolBar { - id: toolBar + Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter + Layout.fillWidth: item ? item.Layout.fillWidth : undefined + Layout.minimumWidth: item ? item.Layout.minimumWidth : undefined + Layout.preferredWidth: item ? item.Layout.preferredWidth : undefined + Layout.maximumWidth: item ? item.Layout.maximumWidth : undefined - anchors { - left: titleLoader.right - leftMargin: Units.smallSpacing - right: parent.right - rightMargin: Units.smallSpacing - verticalCenter: parent.verticalCenter + sourceComponent: page ? page.titleDelegate : null } - alignment: pageRow.globalToolBar.toolbarActionAlignment - display: buttonTextMetrics.toobig ? Controls.Button.IconOnly : Controls.Button.TextBesideIcon - - actions: { - var result = [] - - if (page) { - if (page.actions.main) { - result.push(page.actions.main) - } - if (page.actions.left) { - result.push(page.actions.left) - } - if (page.actions.right) { - result.push(page.actions.right) - } - if (page.actions.contextualActions.length > 0 && !buttonTextMetrics.toobig) { - result = result.concat(Array.prototype.map.call(page.actions.contextualActions, function(item) { return item })) + ActionToolBar { + id: toolBar + + Layout.alignment: Qt.AlignVCenter + Layout.fillWidth: true + + visible: width > 0 + alignment: pageRow.globalToolBar.toolbarActionAlignment + display: buttonTextMetrics.toobig ? Controls.Button.IconOnly : Controls.Button.TextBesideIcon + + actions: { + var result = [] + + if (page) { + if (page.actions.main) { + result.push(page.actions.main) + } + if (page.actions.left) { + result.push(page.actions.left) + } + if (page.actions.right) { + result.push(page.actions.right) + } + if (page.actions.contextualActions.length > 0 && !buttonTextMetrics.toobig) { + result = result.concat(Array.prototype.map.call(page.actions.contextualActions, function(item) { return item })) + } } + + return result } - return result + hiddenActions: page && buttonTextMetrics.toobig ? page.actions.contextualActions : [] } - - hiddenActions: page && buttonTextMetrics.toobig ? page.actions.contextualActions : [] }