diff --git a/src/controls/ToolBarApplicationHeader.qml b/src/controls/ToolBarApplicationHeader.qml --- a/src/controls/ToolBarApplicationHeader.qml +++ b/src/controls/ToolBarApplicationHeader.qml @@ -42,17 +42,58 @@ pageDelegate: Item { id: delegateItem readonly property bool current: __appWindow.pageStack.currentIndex == index + implicitWidth: titleTextMetrics.width/2 + buttonTextMetrics.collapsedButtonsWidth RowLayout { - id: actionsLayout - anchors.verticalCenter: parent.verticalCenter - - readonly property bool toobig: Units.iconSizes.medium * 8 > parent.width/3 + id: titleLayout + anchors { + verticalCenter: parent.verticalCenter + left: parent.left + right: actionsLayout.left + } Separator { - anchors.verticalCenter: parent.verticalCenter + id: separator Layout.preferredHeight: parent.height * 0.6 - visible: index > 0 + //assumption on the internal structure of the parent + visible: index > 0 || delegateItem.parent.x > 0 } + + Heading { + id: title + Layout.fillWidth: true + + Layout.preferredWidth: implicitWidth + Layout.minimumWidth: Math.min(titleTextMetrics.width, delegateItem.width - buttonTextMetrics.requiredWidth) + leftPadding: delegateItem.parent.x > 0 ? 0 : Units.largeSpacing + opacity: delegateItem.current ? 1 : 0.4 + maximumLineCount: 1 + color: Theme.textColor + elide: Text.ElideRight + text: page ? page.title : "" + } + } + + TextMetrics { + id: titleTextMetrics + text: page ? page.title : "" + font: title.font + } + TextMetrics { + id: buttonTextMetrics + text: (page.actions.left ? page.actions.left.text : "") + (page.actions.main ? page.actions.main.text : "") + (page.actions.right ? page.actions.right.text : "") + 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) + readonly property int requiredWidth: width + collapsedButtonsWidth + } + + RowLayout { + id: actionsLayout + anchors { + verticalCenter: parent.verticalCenter + right: ctxActionsButton.visible ? ctxActionsButton.left : parent.right + } + + readonly property bool toobig: delegateItem.width - titleTextMetrics.width - Units.gridUnit < buttonTextMetrics.requiredWidth + PrivateActionToolButton { anchors.verticalCenter: parent.verticalCenter kirigamiAction: page && page.actions ? page.actions.left : null @@ -70,34 +111,18 @@ } } - Heading { - anchors { - left: actionsLayout.right - verticalCenter: parent.verticalCenter - } - - width: parent.width - Math.max(ctxActions.width, actionsLayout.width) - leftPadding: units.gridUnit - opacity: delegateItem.current ? 1 : 0.4 - maximumLineCount: 1 - color: Theme.textColor - elide: Text.ElideRight - text: page ? page.title : "" - font.pointSize: Math.max(1, (parent.height / 1.6) / Units.devicePixelRatio) - } - - PrivateActionToolButton { - id: ctxActions - showMenuArrow: false + id: ctxActionsButton + showMenuArrow: page.actions.contextualActions.length == 1 anchors { right: parent.right verticalCenter: parent.verticalCenter rightMargin: Units.smallSpacing } Action { id: overflowAction icon.name: "overflow-menu" + tooltip: qsTr("More Actions") visible: children.length > 0 children: page && page.actions.contextualActions ? page.actions.contextualActions : null } diff --git a/src/controls/private/PrivateActionToolButton.qml b/src/controls/private/PrivateActionToolButton.qml --- a/src/controls/private/PrivateActionToolButton.qml +++ b/src/controls/private/PrivateActionToolButton.qml @@ -25,7 +25,7 @@ Controls.ToolButton { id: control - implicitWidth: showText && ( kirigamiAction.text.length > 0 || text.length > 0) ? Math.max(background.implicitWidth, layout.implicitWidth + 16) : implicitHeight + implicitWidth: showText && ( kirigamiAction ? kirigamiAction.text.length > 0 : text.length > 0) ? Math.max(background.implicitWidth, layout.implicitWidth + 16) : implicitHeight implicitHeight: background.implicitHeight hoverEnabled: true diff --git a/src/controls/templates/AbstractListItem.qml b/src/controls/templates/AbstractListItem.qml --- a/src/controls/templates/AbstractListItem.qml +++ b/src/controls/templates/AbstractListItem.qml @@ -100,10 +100,10 @@ Theme.colorGroup: internal.indicateActiveFocus ? Theme.Active : Theme.Inactive - leftPadding: !LayoutMirroring.enabled && internal.view && internal.view.T2.ScrollBar.vertical ? internal.view.T2.ScrollBar.vertical.width : Units.smallSpacing * 2 - topPadding: Units.smallSpacing * 2 - rightPadding: LayoutMirroring.enabled && internal.view && internal.view.T2.ScrollBar.vertical ? internal.view.T2.ScrollBar.vertical.width : Units.smallSpacing * 2 - bottomPadding: Units.smallSpacing * 2 + leftPadding: LayoutMirroring.enabled && internal.view && internal.view.T2.ScrollBar.vertical ? internal.view.T2.ScrollBar.vertical.width : Units.largeSpacing + topPadding: Units.largeSpacing + rightPadding: !LayoutMirroring.enabled && internal.view && internal.view.T2.ScrollBar.vertical ? internal.view.T2.ScrollBar.vertical.width : Units.largeSpacing + bottomPadding: Units.largeSpacing implicitWidth: contentItem ? contentItem.implicitWidth : Units.gridUnit * 12 diff --git a/src/controls/templates/ApplicationHeader.qml b/src/controls/templates/ApplicationHeader.qml --- a/src/controls/templates/ApplicationHeader.qml +++ b/src/controls/templates/ApplicationHeader.qml @@ -270,7 +270,7 @@ Loader { id: delegateLoader height: parent.height - x: titleList.wideMode || headerStyle == ApplicationHeaderStyle.Titles ? (Math.min(delegate.width - implicitWidth, Math.max(0, titleList.contentX - delegate.x + navButtons.width))) : 0 + x: titleList.wideMode || headerStyle == ApplicationHeaderStyle.Titles ? (Math.min(delegate.width - implicitWidth, Math.max(0, titleList.contentX - delegate.x + navButtons.width + (navButtons.width > 0 ? Units.smallSpacing : 0)))) : 0 width: parent.width - x Connections {