Warning, /plasma/plasma-desktop/applets/kickoff/package/contents/ui/BasePage.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2011 Martin Gräßlin <mgraesslin@kde.org>
0003     SPDX-FileCopyrightText: 2012 Marco Martin <mart@kde.org>
0004     SPDX-FileCopyrightText: 2015-2018 Eike Hein <hein@kde.org>
0005     SPDX-FileCopyrightText: 2021 Mikel Johnson <mikel5764@gmail.com>
0006     SPDX-FileCopyrightText: 2021 Noah Davis <noahadvs@gmail.com>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 import QtQuick 2.15
0011 import QtQuick.Layouts 1.15
0012 import QtQuick.Templates 2.15 as T
0013 import QtQml 2.15
0014 import org.kde.ksvg 1.0 as KSvg
0015 import org.kde.plasma.workspace.trianglemousefilter 1.0
0016 
0017 FocusScope {
0018     id: root
0019     property real preferredSideBarWidth: implicitSideBarWidth
0020     property real preferredSideBarHeight: implicitSideBarHeight
0021 
0022     property alias sideBarComponent: sideBarLoader.sourceComponent
0023     property alias sideBarItem: sideBarLoader.item
0024     property alias contentAreaComponent: contentAreaLoader.sourceComponent
0025     property alias contentAreaItem: contentAreaLoader.item
0026 
0027     property alias implicitSideBarWidth: sideBarLoader.implicitWidth
0028     property alias implicitSideBarHeight: sideBarLoader.implicitHeight
0029 
0030     implicitWidth: root.preferredSideBarWidth + separator.implicitWidth + contentAreaLoader.implicitWidth
0031     implicitHeight: Math.max(root.preferredSideBarHeight, contentAreaLoader.implicitHeight)
0032 
0033     TriangleMouseFilter {
0034         id: sideBarFilter
0035         anchors {
0036             left: parent.left
0037             top: parent.top
0038             bottom: parent.bottom
0039         }
0040         LayoutMirroring.enabled: kickoff.sideBarOnRight
0041         implicitWidth: root.preferredSideBarWidth
0042         implicitHeight: root.preferredSideBarHeight
0043         edge: kickoff.sideBarOnRight ? Qt.LeftEdge : Qt.RightEdge
0044         blockFirstEnter: true
0045         Loader {
0046             id: sideBarLoader
0047             anchors.fill: parent
0048             // When positioned after the content area, Tab should go to the start of the footer focus chain
0049             Keys.onTabPressed: event => {
0050                 (kickoff.paneSwap ? kickoff.footer.nextItemInFocusChain() : contentAreaLoader)
0051                     .forceActiveFocus(Qt.TabFocusReason);
0052             }
0053             Keys.onBacktabPressed: event => {
0054                 (kickoff.paneSwap ? contentAreaLoader : kickoff.header.pinButton)
0055                     .forceActiveFocus(Qt.BacktabFocusReason);
0056             }
0057             Keys.onLeftPressed: event => {
0058                 if (kickoff.sideBarOnRight) {
0059                     contentAreaLoader.forceActiveFocus();
0060                 }
0061             }
0062             Keys.onRightPressed: event => {
0063                 if (!kickoff.sideBarOnRight) {
0064                     contentAreaLoader.forceActiveFocus();
0065                 }
0066             }
0067             Keys.onUpPressed: event => {
0068                 kickoff.header.nextItemInFocusChain()
0069                     .forceActiveFocus(Qt.BacktabFocusReason);
0070             }
0071             Keys.onDownPressed: event => {
0072                 (kickoff.paneSwap ? kickoff.footer.leaveButtons.nextItemInFocusChain() : kickoff.footer.tabBar)
0073                     .forceActiveFocus(Qt.TabFocusReason);
0074             }
0075         }
0076     }
0077     KSvg.SvgItem {
0078         id: separator
0079         anchors {
0080             left: sideBarFilter.right
0081             top: parent.top
0082             bottom: parent.bottom
0083         }
0084         LayoutMirroring.enabled: kickoff.sideBarOnRight
0085         implicitWidth: naturalSize.width
0086         implicitHeight: implicitWidth
0087         elementId: "vertical-line"
0088         svg: KickoffSingleton.lineSvg
0089     }
0090     Loader {
0091         id: contentAreaLoader
0092         focus: true
0093         anchors {
0094             left: separator.right
0095             right: parent.right
0096             top: parent.top
0097             bottom: parent.bottom
0098         }
0099         LayoutMirroring.enabled: kickoff.sideBarOnRight
0100         // When positioned after the sidebar, Tab should go to the start of the footer focus chain
0101         Keys.onTabPressed: event => {
0102             (kickoff.paneSwap ? sideBarLoader : kickoff.footer.nextItemInFocusChain())
0103                 .forceActiveFocus(Qt.TabFocusReason)
0104         }
0105         Keys.onBacktabPressed: event => {
0106             (kickoff.paneSwap ? kickoff.header.avatar : sideBarLoader)
0107                 .forceActiveFocus(Qt.BacktabFocusReason)
0108         }
0109         Keys.onLeftPressed: event => {
0110             if (!kickoff.sideBarOnRight) {
0111                 sideBarLoader.forceActiveFocus();
0112             }
0113         }
0114         Keys.onRightPressed: event => {
0115             if (kickoff.sideBarOnRight) {
0116                 sideBarLoader.forceActiveFocus();
0117             }
0118         }
0119         Keys.onUpPressed: event => {
0120             kickoff.searchField.forceActiveFocus(Qt.BacktabFocusReason);
0121         }
0122         Keys.onDownPressed: event => {
0123             (kickoff.paneSwap ? kickoff.footer.tabBar : kickoff.footer.leaveButtons.nextItemInFocusChain())
0124                 .forceActiveFocus(Qt.TabFocusReason)
0125         }
0126     }
0127 }