Warning, /frameworks/kirigami/src/controls/templates/private/BackButton.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Controls as QQC2
0009 import org.kde.kirigami as Kirigami
0010 
0011 QQC2.ToolButton {
0012     id: button
0013 
0014     icon.name: (LayoutMirroring.enabled ? "go-previous-symbolic-rtl" : "go-previous-symbolic")
0015 
0016     enabled: {
0017         const pageStack = applicationWindow().pageStack;
0018 
0019         if (pageStack.layers.depth > 1) {
0020             return true;
0021         }
0022 
0023         if (pageStack.depth > 1) {
0024             if (pageStack.currentIndex > 0) {
0025                 return true;
0026             }
0027 
0028             const view = pageStack.columnView;
0029             if (LayoutMirroring.enabled) {
0030                 return view.contentWidth - view.width < view.contentX
0031             } else {
0032                 return view.contentX > 0;
0033             }
0034         }
0035 
0036         return false;
0037     }
0038 
0039     // The gridUnit wiggle room is used to not flicker the button visibility during an animated resize for instance due to a sidebar collapse
0040     visible: {
0041         const pageStack = applicationWindow().pageStack;
0042         const showNavButtons = globalToolBar?.showNavigationButtons ?? Kirigami.ApplicationHeaderStyle.NoNavigationButtons;
0043         return pageStack.layers.depth > 1 || (pageStack.contentItem.contentWidth > pageStack.width + Kirigami.Units.gridUnit && (showNavButtons & Kirigami.ApplicationHeaderStyle.ShowBackButton));
0044     }
0045 
0046     onClicked: {
0047         applicationWindow().pageStack.goBack();
0048     }
0049 
0050     text: qsTr("Navigate Back")
0051     display: QQC2.ToolButton.IconOnly
0052 
0053     QQC2.ToolTip {
0054         visible: button.hovered
0055         text: button.text
0056         delay: Kirigami.Units.toolTipDelay
0057         timeout: 5000
0058         y: button.height
0059     }
0060 }