diff --git a/src/controls/Heading.qml b/src/controls/Heading.qml index ef7d6fed..19f3b379 100644 --- a/src/controls/Heading.qml +++ b/src/controls/Heading.qml @@ -1,82 +1,88 @@ /* * Copyright 2012 by Sebastian Kügler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ import QtQuick 2.0 import QtQuick.Controls 2.0 as QQC2 import org.kde.kirigami 2.4 /** * A heading label used for subsections of texts. * * The characteristics of the text will be automatically set according to the * plasma Theme. Use this components for section titles or headings in your UI, * for example page or section titles. * * Example usage: * * @code * import org.kde.kirigami 2.4 as Kirigami * [...] * Column { * Kirigami.Heading { * text: "Apples in the sunlight" * level: 2 * } * [...] * } * @endcode * * The most important property is "text", which applies to the text property of * Label. See PlasmaComponents Label and primitive QML Text element API for * additional properties, methods and signals. * @inherits QtQuick.Controls.Label */ QQC2.Label { id: heading /** * level: int * The level determines how big the section header is display, values * between 1 (big) and 5 (small) are accepted */ property int level: 1 /** * step: int * adjust the point size in between a level and another. + * DEPRECATED */ - property int step: 2 + property int step: 0 font.pointSize: headerPointSize(level) font.weight: level <= 4 ? Font.Light : Font.Normal + font.styleName: level <= 4 ? "Light" : "Regular" wrapMode: Text.WordWrap function headerPointSize(l) { var n = Theme.defaultFont.pointSize; var s; - if (l > 4) { - s = n - } else if (l < 2) { - s = n + (5*step) - } else { - s = n + ((5-level)*2) + switch (l) { + case 1: + return Math.round(n * 1.80) + step; + case 2: + return Math.round(n * 1.30) + step; + case 3: + return Math.round(n * 1.20) + step; + case 4: + return Math.round(n * 1.10) + step; + default: + return n + step; } - return s; } } diff --git a/src/controls/private/globaltoolbar/ToolBarPageHeader.qml b/src/controls/private/globaltoolbar/ToolBarPageHeader.qml index 3cc39db2..f21b88e2 100644 --- a/src/controls/private/globaltoolbar/ToolBarPageHeader.qml +++ b/src/controls/private/globaltoolbar/ToolBarPageHeader.qml @@ -1,119 +1,120 @@ /* * Copyright 2018 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.5 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 import org.kde.kirigami 2.4 import "../" as Private AbstractPageHeader { id: root implicitWidth: titleTextMetrics.width/2 + buttonTextMetrics.collapsedButtonsWidth Layout.minimumWidth: ctxActionsButton.width*4 MouseArea { anchors.fill: parent onClicked: page.forceActiveFocus() } RowLayout { id: titleLayout anchors { verticalCenter: parent.verticalCenter left: parent.left right: actionsLayout.left } Heading { id: title + level: 1 Layout.fillWidth: true Layout.preferredWidth: implicitWidth Layout.minimumWidth: Math.min(titleTextMetrics.width, root.width - buttonTextMetrics.requiredWidth) leftPadding: Units.largeSpacing opacity: root.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: root.width - root.leftPadding - root.rightPadding - titleTextMetrics.width - Units.gridUnit < buttonTextMetrics.requiredWidth Private.PrivateActionToolButton { Layout.alignment: Qt.AlignVCenter kirigamiAction: page && page.actions ? page.actions.left : null showText: !parent.toobig } Private.PrivateActionToolButton { Layout.alignment: Qt.AlignVCenter Layout.rightMargin: Units.smallSpacing kirigamiAction: page && page.actions ? page.actions.main : null showText: !parent.toobig flat: false } Private.PrivateActionToolButton { Layout.alignment: Qt.AlignVCenter kirigamiAction: page && page.actions ? page.actions.right : null showText: !parent.toobig } } Private.PrivateActionToolButton { 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 } kirigamiAction: page && page.actions.contextualActions.length === 1 ? page.actions.contextualActions[0] : overflowAction } }