diff --git a/src/controls/private/GlobalDrawerActionItem.qml b/src/controls/private/GlobalDrawerActionItem.qml index e864cb8f..e171e7b8 100644 --- a/src/controls/private/GlobalDrawerActionItem.qml +++ b/src/controls/private/GlobalDrawerActionItem.qml @@ -1,151 +1,151 @@ /* * Copyright 2015 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.6 import QtQuick.Controls 2.0 as QQC2 import QtQuick.Layouts 1.2 import org.kde.kirigami 2.5 BasicListItem { id: listItem supportsMouseEvents: (!isExpandible || root.collapsed) readonly property bool wideMode: width > height * 2 readonly property bool isSeparator: modelData.hasOwnProperty("separator") && modelData.separator readonly property bool isExpandible: modelData && modelData.hasOwnProperty("expandible") && modelData.expandible reserveSpaceForIcon: !isSeparator reserveSpaceForLabel: !isSeparator checked: modelData.checked || (actionsMenu && actionsMenu.visible) width: parent.width icon: modelData.icon.name || modelData.icon.source iconColor: modelData.icon.color label: width > height * 2 ? MnemonicData.richTextLabel : "" MnemonicData.enabled: listItem.enabled && listItem.visible MnemonicData.controlType: MnemonicData.MenuItem MnemonicData.label: modelData.text property ActionsMenu actionsMenu: ActionsMenu { x: Qt.application.layoutDirection === Qt.RightToLeft ? -width : listItem.width actions: modelData.children submenuComponent: Component { ActionsMenu {} } onVisibleChanged: { if (visible) { stackView.openSubMenu = listItem.actionsMenu; } else if (stackView.openSubMenu === listItem.actionsMenu) { stackView.openSubMenu = null; } } } separatorVisible: false //TODO: animate the hide by collapse visible: (model ? model.visible || model.visible===undefined : modelData.visible) && opacity > 0 opacity: !root.collapsed || icon.length > 0 Behavior on opacity { OpacityAnimator { duration: Units.longDuration/2 easing.type: Easing.InOutQuad } } enabled: !isSeparator && ( (model && model.enabled !== undefined) ? model.enabled : modelData.enabled) hoverEnabled: (!isExpandible || root.collapsed) && !Settings.tabletMode sectionDelegate: isExpandible font.pointSize: isExpandible ? Theme.defaultFont.pointSize * 1.30 : Theme.defaultFont.pointSize Separator { id: separatorAction visible: listItem.isSeparator Layout.fillWidth: true } Icon { Shortcut { sequence: listItem.MnemonicData.sequence onActivated: listItem.clicked() } isMask: true Layout.alignment: Qt.AlignVCenter Layout.rightMargin: !Settings.isMobile && mainFlickable.contentHeight > mainFlickable.height ? Units.gridUnit : 0 Layout.leftMargin: !root.collapsed ? 0 : parent.width - listItem.width Layout.preferredHeight: !root.collapsed ? Units.iconSizes.smallMedium : Units.iconSizes.small/2 selected: listItem.checked || listItem.pressed Layout.preferredWidth: Layout.preferredHeight source: (LayoutMirroring.enabled ? "go-next-symbolic-rtl" : "go-next-symbolic") visible: (!isExpandible || root.collapsed) && !listItem.isSeparator && modelData.children!==undefined && modelData.children.length > 0 } data: [ QQC2.ToolTip { visible: !listItem.isSeparator && (modelData.tooltip.length || root.collapsed) && (!actionsMenu || !actionsMenu.visible) && listItem.hovered && text.length > 0 text: modelData.tooltip.length ? modelData.tooltip : modelData.text - delay: 1000 + delay: Units.toolTipDelay timeout: 5000 y: listItem.height/2 - height/2 x: Qt.application.layoutDirection === Qt.RightToLeft ? -width : listItem.width } ] onHoveredChanged: { if (!hovered) { return; } if (stackView.openSubMenu) { stackView.openSubMenu.visible = false; if (!listItem.actionsMenu.hasOwnProperty("count") || listItem.actionsMenu.count>0) { if (listItem.actionsMenu.hasOwnProperty("popup")) { listItem.actionsMenu.popup(listItem, listItem.width, 0) } else { listItem.actionsMenu.visible = true; } } } } onClicked: { if (!supportsMouseEvents) { return; } modelData.trigger(); if (modelData.children!==undefined && modelData.children.length > 0) { if (root.collapsed) { //fallbacks needed for Qt 5.9 if ((!listItem.actionsMenu.hasOwnProperty("count") || listItem.actionsMenu.count>0) && !listItem.actionsMenu.visible) { stackView.openSubMenu = listItem.actionsMenu; if (listItem.actionsMenu.hasOwnProperty("popup")) { listItem.actionsMenu.popup(listItem, listItem.width, 0) } else { listItem.actionsMenu.visible = true; } } } else { stackView.push(menuComponent, {model: modelData.children, level: level + 1, current: modelData }); } } else if (root.resetMenuOnTriggered) { root.resetMenu(); } checked = Qt.binding(function() { return modelData.checked || (actionsMenu && actionsMenu.visible) }); } } diff --git a/src/controls/private/PrivateActionToolButton.qml b/src/controls/private/PrivateActionToolButton.qml index cad58aca..36a6325c 100644 --- a/src/controls/private/PrivateActionToolButton.qml +++ b/src/controls/private/PrivateActionToolButton.qml @@ -1,125 +1,125 @@ /* * Copyright 2016 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.6 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.2 as Controls import org.kde.kirigami 2.4 Controls.ToolButton { id: control signal menuAboutToShow implicitWidth: menuArrow.visible || (showText && ( kirigamiAction ? kirigamiAction.text.length > 0 : text.length > 0)) ? Math.max(layout.implicitWidth + Units.largeSpacing*2, background.implicitWidth) : implicitHeight implicitHeight: background.implicitHeight Theme.colorSet: Theme.Button Theme.inherit: kirigamiAction && kirigamiAction.icon.color.a === 0 Theme.backgroundColor: kirigamiAction && kirigamiAction.icon.color.a ? kirigamiAction.icon.color : undefined Theme.textColor: kirigamiAction && !flat && kirigamiAction.icon.color.a ? Theme.highlightedTextColor : undefined hoverEnabled: true flat: !control.kirigamiAction || !control.kirigamiAction.icon.color.a //TODO: replace with upstream action when we depend on Qt 5.10 property Action kirigamiAction property bool showText: true property bool showMenuArrow: true property alias menu: menu //we need our own text delegate text: "" checkable: kirigamiAction && kirigamiAction.checkable checked: (kirigamiAction && kirigamiAction.checked) || menu.visible enabled: kirigamiAction && kirigamiAction.enabled opacity: enabled ? 1 : 0.4 visible: kirigamiAction && kirigamiAction.visible onClicked: { if (kirigamiAction) { kirigamiAction.trigger(); } if (kirigamiAction.children.length > 0 && !menu.visible) { control.menuAboutToShow(); menu.popup(control, 0, control.height) } } ActionsMenu { id: menu y: control.height actions: control.kirigamiAction ? control.kirigamiAction.children : null submenuComponent: Component { ActionsMenu {} } } contentItem: MouseArea { hoverEnabled: true onPressed: mouse.accepted = false Theme.colorSet: checked && (control.kirigamiAction && control.kirigamiAction.icon.color.a) ? Theme.Selection : control.Theme.colorSet Theme.inherit: control.kirigamiAction && Theme.colorSet != Theme.Selection && control.kirigamiAction.icon.color.a === 0 GridLayout { id: layout columns: control.display == Controls.ToolButton.TextUnderIcon ? 1 : 2 + (menuArrow.visible ? 1 : 0) rows: control.display == Controls.ToolButton.TextUnderIcon ? 2 : 1 anchors.centerIn: parent Icon { id: mainIcon Layout.alignment: Qt.AlignCenter Layout.minimumWidth: Units.iconSizes.smallMedium Layout.minimumHeight: Units.iconSizes.smallMedium source: control.kirigamiAction ? (control.kirigamiAction.icon ? control.kirigamiAction.icon.name : control.kirigamiAction.iconName) : "" visible: control.kirigamiAction && control.kirigamiAction.iconName != "" && control.display != Controls.ToolButton.TextOnly color: control.flat && control.kirigamiAction && control.kirigamiAction.icon && control.kirigamiAction.icon.color.a > 0 ? control.kirigamiAction.icon.color : label.color } Controls.Label { id: label MnemonicData.enabled: control.enabled MnemonicData.controlType: MnemonicData.ActionElement MnemonicData.label: control.kirigamiAction ? control.kirigamiAction.text : "" text: MnemonicData.richTextLabel visible: control.showText && text.length > 0 && control.display != Controls.ToolButton.IconOnly Shortcut { sequence: label.MnemonicData.sequence onActivated: control.clicked() } } Icon { id: menuArrow Layout.minimumWidth: Units.iconSizes.small Layout.minimumHeight: Units.iconSizes.small color: mainIcon.color source: "arrow-down" visible: showMenuArrow && menu.actions && menu.actions.length > 0 } } } Controls.ToolTip { visible: control.hovered && text.length > 0 && !menu.visible && !control.pressed text: kirigamiAction ? (kirigamiAction.tooltip.length ? kirigamiAction.tooltip : kirigamiAction.text) : "" - delay: 1000 + delay: Units.toolTipDelay timeout: 5000 y: control.height } } diff --git a/src/controls/templates/SwipeListItem.qml b/src/controls/templates/SwipeListItem.qml index 1064cca4..762279ce 100644 --- a/src/controls/templates/SwipeListItem.qml +++ b/src/controls/templates/SwipeListItem.qml @@ -1,475 +1,475 @@ /* * Copyright 2010 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 2.010-1301, USA. */ import QtQuick 2.7 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.7 as Controls import org.kde.kirigami 2.7 import "../private" import QtQuick.Templates 2.0 as T2 /** * An item delegate Intended to support extra actions obtainable * by uncovering them by dragging away the item with the handle * This acts as a container for normal list items. * Any subclass of AbstractListItem can be assigned as the contentItem property. * @code * ListView { * model: myModel * delegate: SwipeListItem { * QQC2.Label { * text: model.text * } * actions: [ * Action { * iconName: "document-decrypt" * onTriggered: print("Action 1 clicked") * }, * Action { * iconName: model.action2Icon * onTriggered: //do something * } * ] * } * * } * @endcode * * @inherit QtQuick.Templates.ItemDelegate */ T2.ItemDelegate { id: listItem //BEGIN properties /** * supportsMouseEvents: bool * Holds if the item emits signals related to mouse interaction. *TODO: remove * The default value is false. */ property alias supportsMouseEvents: listItem.hoverEnabled /** * containsMouse: bool * True when the user hover the mouse over the list item * NOTE: on mobile touch devices this will be true only when pressed is also true */ property alias containsMouse: listItem.hovered /** * alternatingBackground: bool * If true the background of the list items will be alternating between two * colors, helping readability with multiple column views. * Use it only when implementing a view which shows data visually in multiple columns * @ since 2.7 */ property bool alternatingBackground: false /** * sectionDelegate: bool * If true the item will be a delegate for a section, so will look like a * "title" for the items under it. */ property bool sectionDelegate: false /** * separatorVisible: bool * True if the separator between items is visible * default: true */ property bool separatorVisible: true /** * actionsVisible: bool * True if it's possible to see and access the item actions. * Actions should go completely out of the way for instance during * the editing of an item. * @since 2.5 */ property alias actionsVisible: behindItem.visible /** * actions: list * Defines the actions for the list item: at most 4 buttons will * contain the actions for the item, that can be revealed by * sliding away the list item. */ property list actions /** * textColor: color * Color for the text in the item * * Note: if custom text elements are inserted in an AbstractListItem, * their color property will have to be manually bound with this property */ property color textColor: Theme.textColor /** * backgroundColor: color * Color for the background of the item */ property color backgroundColor: Theme.backgroundColor /** * alternateBackgroundColor: color * The background color to use if alternatingBackground is true. * It is advised to leave the default. * @since 2.7 */ property color alternateBackgroundColor: Theme.alternateBackgroundColor /** * activeTextColor: color * Color for the text in the item when pressed or selected * It is advised to leave the default value (Theme.highlightedTextColor) * * Note: if custom text elements are inserted in an AbstractListItem, * their color property will have to be manually bound with this property */ property color activeTextColor: Theme.highlightedTextColor /** * activeBackgroundColor: color * Color for the background of the item when pressed or selected * It is advised to leave the default value (Theme.highlightColor) */ property color activeBackgroundColor: Theme.highlightColor default property alias _default: listItem.contentItem Theme.colorGroup: behindItem.indicateActiveFocus ? Theme.Active : Theme.Inactive hoverEnabled: true implicitWidth: contentItem ? contentItem.implicitWidth : Units.gridUnit * 12 width: parent ? parent.width : implicitWidth implicitHeight: Math.max(Units.gridUnit * 2, contentItem.implicitHeight, actionsLayout.implicitHeight) + topPadding + bottomPadding padding: Settings.tabletMode ? Units.largeSpacing : Units.smallSpacing leftPadding: padding * 2 rightPadding: padding * 2 + (handleMouse.visible ? handleMouse.width : (hovered || !supportsMouseEvents) * actionsLayout.width) + handleMouse.anchors.rightMargin topPadding: padding bottomPadding: padding //END properties Item { id: behindItem parent: listItem z: -1 //TODO: a global "open" state enabled: background.x !== 0 property bool indicateActiveFocus: listItem.pressed || Settings.tabletMode || listItem.activeFocus || (view ? view.activeFocus : false) property Flickable view: listItem.ListView.view || (listItem.parent ? (listItem.parent.ListView.view || listItem.parent) : null) property T2.ScrollBar flickableVerticalScrollbar: view ? (view.T2.ScrollBar.vertical ? view.T2.ScrollBar.vertical : null) : null property T2.ScrollBar scrollviewVerticalScrollbar: view ? (view.parent.T2.ScrollBar.vertical ? view.parent.T2.ScrollBar.vertical : null) : null onViewChanged: { if (view && Settings.tabletMode && !behindItem.view.parent.parent._swipeFilter) { var component = Qt.createComponent(Qt.resolvedUrl("../private/SwipeItemEventFilter.qml")); behindItem.view.parent.parent._swipeFilter = component.createObject(behindItem.view.parent.parent); } } // Some of the views use flickables, and some use scrollviews, so we // need to handle both when we determine whether or not to move items // over to the right so the scrollbar doesn't overlap them function calculateMargin() { if (scrollviewVerticalScrollbar && scrollviewVerticalScrollbar.visible) { return scrollviewVerticalScrollbar.width } else if (flickableVerticalScrollbar && flickableVerticalScrollbar.visible) { return flickableVerticalScrollbar.width } return Units.smallSpacing } anchors { fill: parent } Rectangle { id: shadowHolder color: Qt.darker(Theme.backgroundColor, 1.05); anchors.fill: parent } EdgeShadow { edge: Qt.TopEdge visible: background.x != 0 anchors { right: parent.right left: parent.left top: parent.top } } EdgeShadow { edge: LayoutMirroring.enabled ? Qt.RightEdge : Qt.LeftEdge x: LayoutMirroring.enabled ? listItem.background.x - width : (listItem.background.x + listItem.background.width) visible: background.x != 0 anchors { top: parent.top bottom: parent.bottom } } MouseArea { anchors.fill: parent preventStealing: true enabled: background.x != 0 onClicked: { positionAnimation.from = background.x; positionAnimation.to = 0; positionAnimation.running = true; } } Row { id: actionsLayout z: 1 visible: listItem.actionsVisible parent: Settings.tabletMode ? behindItem : listItem opacity: Settings.tabletMode || listItem.hovered || !listItem.supportsMouseEvents ? 1 : 0 Behavior on opacity { OpacityAnimator { duration: Units.longDuration easing.type: Easing.InOutQuad } } anchors { right: parent.right verticalCenter: parent.verticalCenter rightMargin: LayoutMirroring.enabled ? 0 : behindItem.calculateMargin() leftMargin: LayoutMirroring.enabled ? 0 : behindItem.calculateMargin() } height: Math.min( parent.height / 1.5, Units.iconSizes.smallMedium) width: childrenRect.width property bool exclusive: false property Item checkedButton spacing: Settings.tabletMode ? Units.largeSpacing : 0 property int visibleActions: 0 Repeater { model: { if (listItem.actions.length === 0) { return null; } else { return listItem.actions[0].text !== undefined && listItem.actions[0].trigger !== undefined ? listItem.actions : listItem.actions[0]; } } delegate: Controls.ToolButton { anchors.verticalCenter: parent.verticalCenter icon.name: modelData.iconName !== "" ? modelData.iconName : "" icon.source: modelData.iconSource !== "" ? modelData.iconSource : "" enabled: (modelData && modelData.enabled !== undefined) ? modelData.enabled : true; visible: (modelData && modelData.visible !== undefined) ? modelData.visible : true; onVisibleChanged: { if (visible) { actionsLayout.visibleActions++; } else { actionsLayout.visibleActions--; } } Component.onCompleted: { if (visible) { actionsLayout.visibleActions++; } } Component.onDestruction: { if (visible) { actionsLayout.visibleActions--; } } - Controls.ToolTip.delay: 1000 + Controls.ToolTip.delay: Units.toolTipDelay Controls.ToolTip.timeout: 5000 Controls.ToolTip.visible: listItem.visible && (Settings.tabletMode ? pressed : hovered) && Controls.ToolTip.text.length > 0 Controls.ToolTip.text: modelData.tooltip || modelData.text onClicked: { if (modelData && modelData.trigger !== undefined) { modelData.trigger(); } positionAnimation.from = background.x; positionAnimation.to = 0; positionAnimation.running = true; } } } } } MouseArea { id: handleMouse parent: listItem.background visible: Settings.tabletMode && listItem.actionsVisible && actionsLayout.visibleActions > 0 z: 99 anchors { right: parent.right verticalCenter: parent.verticalCenter rightMargin: LayoutMirroring.enabled ? 0 : behindItem.calculateMargin() leftMargin: LayoutMirroring.enabled ? 0 : behindItem.calculateMargin() } preventStealing: true width: Units.iconSizes.smallMedium height: width property var downTimestamp; property int startX property int startMouseX onClicked: { positionAnimation.from = background.x; if (listItem.background.x > -listItem.background.width/2) { positionAnimation.to = (LayoutMirroring.enabled ? -1 : +1) * (-listItem.width + height + handleMouse.anchors.rightMargin); } else { positionAnimation.to = 0; } positionAnimation.restart(); } onPressed: { downTimestamp = (new Date()).getTime(); startX = listItem.background.x; startMouseX = mouse.x; } onPositionChanged: { if (LayoutMirroring.enabled) { listItem.background.x = Math.max(0, Math.min(listItem.width - height, listItem.background.x - (startMouseX - mouse.x))); } else { listItem.background.x = Math.min(0, Math.max(-listItem.width + height, listItem.background.x - (startMouseX - mouse.x))); } } onReleased: { var speed = ((startX - listItem.background.x) / ((new Date()).getTime() - downTimestamp) * 1000); var absoluteDelta = startX - listItem.background.x; if (LayoutMirroring.enabled) { speed = -speed; absoluteDelta = -absoluteDelta; } if (Math.abs(speed) < Units.gridUnit) { return; } if (speed > listItem.width/2 || absoluteDelta > listItem.width/2) { positionAnimation.to = (LayoutMirroring.enabled ? -1 : +1) * (-listItem.width + height + handleMouse.anchors.rightMargin); } else { positionAnimation.to = 0; } positionAnimation.from = background.x; positionAnimation.running = true; } Icon { id: handleIcon anchors.fill: parent selected: listItem.checked || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate) source: (LayoutMirroring.enabled ? (listItem.background.x < listItem.background.width/2 ? "overflow-menu-right" : "overflow-menu-left") : (listItem.background.x < -listItem.background.width/2 ? "overflow-menu-right" : "overflow-menu-left")) } } NumberAnimation { id: positionAnimation property: "x" target: background duration: Units.longDuration easing.type: Easing.InOutQuad } //BEGIN signal handlers onContentItemChanged: { if (!contentItem) { return; } contentItem.parent = background; contentItem.anchors.top = background.top; contentItem.anchors.left = background.left; contentItem.anchors.right = background.right; contentItem.anchors.leftMargin = Qt.binding(function() {return listItem.leftPadding}); contentItem.anchors.rightMargin = Qt.binding(function() {return listItem.rightPadding}); contentItem.anchors.topMargin = Qt.binding(function() {return listItem.topPadding}); contentItem.z = 0; } Component.onCompleted: { //this will happen only once listItem.contentItemChanged(); } Connections { target: Settings onTabletModeChanged: { if (Settings.tabletMode) { if (!internal.swipeFilterItem) { var component = Qt.createComponent(Qt.resolvedUrl("../private/SwipeItemEventFilter.qml")); listItem.ListView.view.parent.parent._swipeFilter = component.createObject(listItem.ListView.view.parent.parent); } } else { if (listItem.ListView.view.parent.parent._swipeFilter) { listItem.ListView.view.parent.parent._swipeFilter.destroy(); positionAnimation.to = 0; positionAnimation.from = background.x; positionAnimation.running = true; } } } } QtObject { id: internal readonly property QtObject swipeFilterItem: (behindItem.view && behindItem.view.parent && behindItem.view.parent.parent && behindItem.view.parent.parent._swipeFilter) ? behindItem.view.parent.parent._swipeFilter : null readonly property bool edgeEnabled: swipeFilterItem ? swipeFilterItem.currentItem === listItem || swipeFilterItem.currentItem === listItem.parent : false } Connections { id: swipeFilterConnection target: internal.edgeEnabled ? internal.swipeFilterItem : null onPeekChanged: { if (!listItem.actionsVisible) { return; } if (listItem.LayoutMirroring.enabled) { listItem.background.x = (listItem.background.width - listItem.background.height) * (1 - internal.swipeFilterItem.peek); } else { listItem.background.x = -(listItem.background.width - listItem.background.height) * internal.swipeFilterItem.peek; } } onPressed: { if (internal.edgeEnabled) { handleMouse.onPressed(mouse); } } onClicked: { if (Math.abs(listItem.background.x) < Units.gridUnit && internal.edgeEnabled) { handleMouse.clicked(mouse); } } onReleased: { if (internal.edgeEnabled) { handleMouse.released(mouse); } } onCurrentItemChanged: { if (!internal.edgeEnabled) { positionAnimation.to = 0; positionAnimation.from = background.x; positionAnimation.running = true; } } } //END signal handlers Accessible.role: Accessible.ListItem } diff --git a/src/controls/templates/private/BackButton.qml b/src/controls/templates/private/BackButton.qml index 8f3b48fb..45fc2f74 100644 --- a/src/controls/templates/private/BackButton.qml +++ b/src/controls/templates/private/BackButton.qml @@ -1,52 +1,52 @@ /* * Copyright 2016 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.1 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.0 as Controls import org.kde.kirigami 2.4 Controls.ToolButton { id: button icon.name: (LayoutMirroring.enabled ? "go-previous-symbolic-rtl" : "go-previous-symbolic") enabled: applicationWindow().pageStack.layers.depth > 1 || (applicationWindow().pageStack.depth > 1 && (applicationWindow().pageStack.currentIndex > 0 || applicationWindow().pageStack.contentItem.contentX > 0)) visible: applicationWindow().pageStack.layers.depth > 1 || (applicationWindow().pageStack.contentItem.contentWidth > applicationWindow().pageStack.width && (globalToolBar.showNavigationButtons === true || (globalToolBar.showNavigationButtons & ApplicationHeaderStyle.ShowBackButton))) width: height height: parent.height onClicked: { if (applicationWindow().pageStack.layers && applicationWindow().pageStack.layers.depth > 1) { applicationWindow().pageStack.layers.pop(); } else { applicationWindow().pageStack.goBack(); } } Controls.ToolTip { visible: button.hovered text: qsTr("Navigate Back") - delay: 1000 + delay: Units.toolTipDelay timeout: 5000 y: button.height } } diff --git a/src/controls/templates/private/ForwardButton.qml b/src/controls/templates/private/ForwardButton.qml index 1a7460c2..7335a866 100644 --- a/src/controls/templates/private/ForwardButton.qml +++ b/src/controls/templates/private/ForwardButton.qml @@ -1,48 +1,48 @@ /* * Copyright 2016 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.1 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.0 as Controls import org.kde.kirigami 2.4 Controls.ToolButton { id: button icon.name: (LayoutMirroring.enabled ? "go-next-symbolic-rtl" : "go-next-symbolic") enabled: applicationWindow().pageStack.currentIndex < applicationWindow().pageStack.depth-1 visible: applicationWindow().pageStack.layers.depth == 1 && applicationWindow().pageStack.contentItem.contentWidth > applicationWindow().pageStack.width && (globalToolBar.showNavigationButtons === true || (globalToolBar.showNavigationButtons & ApplicationHeaderStyle.ShowForwardButton)) width: height height: parent.height onClicked: applicationWindow().pageStack.goForward(); Controls.ToolTip { visible: button.hovered text: qsTr("Navigate Forward") - delay: 1000 + delay: Units.toolTipDelay timeout: 5000 y: button.height } }