Warning, /frameworks/kirigami/src/controls/OverlayDrawer.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.Templates as T
0009 import org.kde.kirigami as Kirigami
0010 import "private" as KP
0011 import "templates" as KT
0012 
0013 /**
0014  * Overlay Drawers are used to expose additional UI elements needed for
0015  * small secondary tasks for which the main UI elements are not needed.
0016  * For example in Okular Mobile, an Overlay Drawer is used to display
0017  * thumbnails of all pages within a document along with a search field.
0018  * This is used for the distinct task of navigating to another page.
0019  *
0020  * @inherit org::kde::kirigami::templates::OverlayDrawer
0021  */
0022 KT.OverlayDrawer {
0023     id: root
0024 
0025 //BEGIN Properties
0026     focus: false
0027     modal: true
0028     drawerOpen: !modal
0029     closePolicy: modal ? T.Popup.CloseOnEscape | T.Popup.CloseOnReleaseOutside : T.Popup.NoAutoClose
0030     handleVisible: interactive && (modal || !drawerOpen) && (typeof(applicationWindow)===typeof(Function) && applicationWindow() ? applicationWindow().controlsVisible : true)
0031 
0032     // FIXME: set to false when it does not lead to blocking closePolicy.
0033     // See Kirigami bug: 454119
0034     interactive: true
0035 
0036     onPositionChanged: {
0037         if (!modal && !root.peeking && !root.animating) {
0038             position = 1;
0039         }
0040     }
0041 
0042     background: Rectangle {
0043         color: Kirigami.Theme.backgroundColor
0044 
0045         Item {
0046             parent: root.handle
0047             anchors.fill: parent
0048 
0049             Kirigami.ShadowedRectangle {
0050                 id: handleGraphics
0051                 anchors.centerIn: parent
0052 
0053                 Kirigami.Theme.colorSet: parent.parent.handleAnchor && parent.parent.handleAnchor.visible ? parent.parent.handleAnchor.Kirigami.Theme.colorSet : Kirigami.Theme.Button
0054 
0055                 Kirigami.Theme.backgroundColor: parent.parent.handleAnchor && parent.parent.handleAnchor.visible ? parent.parent.handleAnchor.Kirigami.Theme.backgroundColor : undefined
0056 
0057                 Kirigami.Theme.textColor: parent.parent.handleAnchor && parent.parent.handleAnchor.visible ? parent.parent.handleAnchor.Kirigami.Theme.textColor : undefined
0058 
0059                 Kirigami.Theme.inherit: false
0060                 color: root.handle.pressed ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor
0061 
0062                 visible: !parent.parent.handleAnchor || !parent.parent.handleAnchor.visible || root.handle.pressed || (root.modal && root.position > 0)
0063 
0064                 shadow.color: Qt.rgba(0, 0, 0, root.handle.pressed ? 0.6 : 0.4)
0065                 shadow.yOffset: 1
0066                 shadow.size: Kirigami.Units.gridUnit / 2
0067 
0068                 width: Kirigami.Units.iconSizes.smallMedium + Kirigami.Units.smallSpacing * 2
0069                 height: width
0070                 radius: 2
0071                 Behavior on color {
0072                     ColorAnimation {
0073                         duration: Kirigami.Units.longDuration
0074                         easing.type: Easing.InOutQuad
0075                     }
0076                 }
0077             }
0078             Loader {
0079                 anchors.centerIn: handleGraphics
0080                 width: height
0081                 height: Kirigami.Units.iconSizes.smallMedium
0082 
0083                 Kirigami.Theme.colorSet: handleGraphics.Kirigami.Theme.colorSet
0084                 Kirigami.Theme.backgroundColor: handleGraphics.Kirigami.Theme.backgroundColor
0085                 Kirigami.Theme.textColor: handleGraphics.Kirigami.Theme.textColor
0086 
0087                 asynchronous: true
0088 
0089                 source: {
0090                     let edge = root.edge;
0091                     if (Qt.application.layoutDirection === Qt.RightToLeft) {
0092                         if (edge === Qt.LeftEdge) {
0093                             edge = Qt.RightEdge;
0094                         } else {
0095                             edge = Qt.LeftEdge;
0096                         }
0097                     }
0098 
0099                     if ((root.handleClosedIcon.source || root.handleClosedIcon.name)
0100                         && (root.handleOpenIcon.source || root.handleOpenIcon.name)) {
0101                         return Qt.resolvedUrl("templates/private/GenericDrawerIcon.qml");
0102                     } else if (edge === Qt.LeftEdge) {
0103                         return Qt.resolvedUrl("templates/private/MenuIcon.qml");
0104                     } else if (edge === Qt.RightEdge && root instanceof Kirigami.ContextDrawer) {
0105                         return Qt.resolvedUrl("templates/private/ContextIcon.qml");
0106                     } else {
0107                         return "";
0108                     }
0109                 }
0110                 onItemChanged: {
0111                     if (item) {
0112                         item.drawer = root;
0113                         item.color = Qt.binding(() => root.handle.pressed
0114                             ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor);
0115                     }
0116                 }
0117             }
0118         }
0119 
0120         Kirigami.Separator {
0121             LayoutMirroring.enabled: false
0122             // LayoutMirroring.childrenInherit: true
0123             anchors {
0124                 right: root.edge === Qt.RightEdge ? parent.left : (root.edge === Qt.LeftEdge ? undefined : parent.right)
0125                 left: root.edge === Qt.LeftEdge ? parent.right : (root.edge === Qt.RightEdge ? undefined : parent.left)
0126                 top: root.edge === Qt.TopEdge ? parent.bottom : (root.edge === Qt.BottomEdge ? undefined : parent.top)
0127                 bottom: root.edge === Qt.BottomEdge ? parent.top : (root.edge === Qt.TopEdge ? undefined : parent.bottom)
0128             }
0129             visible: !root.modal
0130             Kirigami.Theme.inherit: false
0131             Kirigami.Theme.colorSet: Kirigami.Theme.Header
0132         }
0133         KP.EdgeShadow {
0134             z: -2
0135             visible: root.modal
0136             edge: root.edge
0137             anchors {
0138                 right: root.edge === Qt.RightEdge ? parent.left : (root.edge === Qt.LeftEdge ? undefined : parent.right)
0139                 left: root.edge === Qt.LeftEdge ? parent.right : (root.edge === Qt.RightEdge ? undefined : parent.left)
0140                 top: root.edge === Qt.TopEdge ? parent.bottom : (root.edge === Qt.BottomEdge ? undefined : parent.top)
0141                 bottom: root.edge === Qt.BottomEdge ? parent.top : (root.edge === Qt.TopEdge ? undefined : parent.bottom)
0142             }
0143 
0144             opacity: root.position === 0 ? 0 : 1
0145 
0146             Behavior on opacity {
0147                 NumberAnimation {
0148                     duration: Kirigami.Units.longDuration
0149                     easing.type: Easing.InOutQuad
0150                 }
0151             }
0152         }
0153     }
0154 }