Warning, /plasma/plasma-mobile/containments/homescreens/folio/package/contents/ui/settings/SettingsComponent.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 import QtQuick
0005 import QtQuick.Window
0006 import QtQuick.Layouts
0007 import QtQuick.Controls as QQC2
0008 
0009 import org.kde.kirigami 2.20 as Kirigami
0010 
0011 import org.kde.plasma.components 3.0 as PC3
0012 import org.kde.plasma.private.mobileshell as MobileShell
0013 import org.kde.private.mobile.homescreen.folio 1.0 as Folio
0014 
0015 import '../delegate'
0016 
0017 Item {
0018     id: root
0019 
0020     property var homeScreen
0021     property real settingsModeHomeScreenScale
0022 
0023     readonly property bool homeScreenInteractive: !appletListViewer.open
0024 
0025     MouseArea {
0026         id: closeSettings
0027 
0028         anchors.top: parent.top
0029         anchors.left: parent.left
0030         anchors.right: parent.right
0031         anchors.bottom: settingsBar.top
0032 
0033         onClicked: {
0034             Folio.HomeScreenState.closeSettingsView();
0035         }
0036     }
0037 
0038     Item {
0039         id: settingsBar
0040 
0041         Kirigami.Theme.inherit: false
0042         Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0043 
0044         anchors.left: parent.left
0045         anchors.right: parent.right
0046         anchors.bottom: parent.bottom
0047         anchors.bottomMargin: Kirigami.Units.largeSpacing
0048         height: root.height * (1 - settingsModeHomeScreenScale)
0049 
0050         RowLayout {
0051             id: settingsOptions
0052             anchors.centerIn: parent
0053             spacing: Kirigami.Units.largeSpacing
0054 
0055             PC3.ToolButton {
0056                 opacity: 0.9
0057                 implicitHeight: Kirigami.Units.gridUnit * 4
0058                 implicitWidth: Kirigami.Units.gridUnit * 5
0059 
0060                 contentItem: ColumnLayout {
0061                     spacing: Kirigami.Units.largeSpacing
0062 
0063                     Kirigami.Icon {
0064                         Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
0065                         implicitWidth: Kirigami.Units.iconSizes.smallMedium
0066                         implicitHeight: Kirigami.Units.iconSizes.smallMedium
0067                         source: 'edit-image'
0068                     }
0069                     
0070                     QQC2.Label {
0071                         Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
0072                         text: i18n('Wallpapers')
0073                         font.bold: true
0074                     }
0075                 }
0076 
0077                 onClicked: {
0078                     wallpaperSelectorLoader.active = true;
0079                     Folio.HomeScreenState.closeSettingsView();
0080                 }
0081             }
0082 
0083             PC3.ToolButton {
0084                 opacity: 0.9
0085                 implicitHeight: Kirigami.Units.gridUnit * 4
0086                 implicitWidth: Kirigami.Units.gridUnit * 5
0087 
0088                 contentItem: ColumnLayout {
0089                     spacing: Kirigami.Units.largeSpacing
0090 
0091                     Kirigami.Icon {
0092                         Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
0093                         implicitWidth: Kirigami.Units.iconSizes.smallMedium
0094                         implicitHeight: Kirigami.Units.iconSizes.smallMedium
0095                         source: 'settings-configure'
0096                     }
0097                     
0098                     QQC2.Label {
0099                         Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
0100                         text: i18n('Settings')
0101                         font.bold: true
0102                     }
0103                 }
0104 
0105                 onClicked: {
0106                     // ensure that if the window is already opened, it gets raised to the top
0107                     settingsWindow.hide();
0108                     settingsWindow.showMaximized();
0109                 }
0110             }
0111 
0112             PC3.ToolButton {
0113                 opacity: 0.9
0114                 implicitHeight: Kirigami.Units.gridUnit * 4
0115                 implicitWidth: Kirigami.Units.gridUnit * 5
0116 
0117                 contentItem: ColumnLayout {
0118                     spacing: Kirigami.Units.largeSpacing
0119 
0120                     Kirigami.Icon {
0121                         Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
0122                         implicitWidth: Kirigami.Units.iconSizes.smallMedium
0123                         implicitHeight: Kirigami.Units.iconSizes.smallMedium
0124                         source: 'widget-alternatives'
0125                     }
0126                     
0127                     QQC2.Label {
0128                         Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
0129                         text: i18n('Widgets')
0130                         font.bold: true
0131                     }
0132                 }
0133 
0134                 onClicked: {
0135                     appletListViewer.open = true;
0136                 }
0137             }
0138         }
0139     }
0140 
0141     AppletListViewer {
0142         id: appletListViewer
0143         width: parent.width
0144         height: parent.height
0145 
0146         property bool open: false
0147         onRequestClose: open = false
0148 
0149         opacity: open ? 1 : 0
0150 
0151         // move the settings out of the way if it is not visible
0152         // NOTE: we do this instead of setting visible to false, because
0153         //       it doesn't mess with widget drag and drop
0154         y: (opacity === 0) ? appletListViewer.height : 0
0155 
0156         homeScreen: root.homeScreen
0157 
0158         Behavior on opacity {
0159             NumberAnimation { duration: Kirigami.Units.shortDuration }
0160         }
0161     }
0162 
0163     SettingsWindow {
0164         id: settingsWindow
0165         visible: false
0166 
0167         onRequestConfigureMenu: {
0168             homeScreen.openConfigure()
0169         }
0170     }
0171 
0172     Loader {
0173         id: wallpaperSelectorLoader
0174         asynchronous: true
0175         active: false
0176 
0177         onLoaded: {
0178             wallpaperSelectorLoader.item.open();
0179         }
0180 
0181         sourceComponent: MobileShell.WallpaperSelector {
0182             horizontal: root.width > root.height
0183             edge: horizontal ? Qt.LeftEdge : Qt.BottomEdge
0184             bottomMargin: root.homeScreen.bottomMargin
0185             leftMargin: root.homeScreen.leftMargin
0186             rightMargin: root.homeScreen.rightMargin
0187             onClosed: {
0188                 wallpaperSelectorLoader.active = false;
0189             }
0190         }
0191     }
0192 }