2023-10-22 03:59:27 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Window
|
|
|
|
|
import QtQuick.Layouts
|
2023-10-22 17:17:09 +00:00
|
|
|
import QtQuick.Dialogs
|
2023-10-22 03:59:27 +00:00
|
|
|
import QtQuick.Controls as QQC2
|
|
|
|
|
|
|
|
|
|
import org.kde.kirigami 2.20 as Kirigami
|
|
|
|
|
|
|
|
|
|
import org.kde.private.mobile.homescreen.folio 1.0 as Folio
|
|
|
|
|
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
|
|
|
|
|
|
|
|
|
import '../delegate'
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
Window {
|
2023-10-22 03:59:27 +00:00
|
|
|
id: root
|
2024-06-21 04:42:14 +00:00
|
|
|
property Folio.HomeScreen folio
|
|
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
flags: Qt.FramelessWindowHint
|
2023-11-05 17:46:17 +00:00
|
|
|
color: 'transparent'
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
onVisibleChanged: {
|
|
|
|
|
if (visible) {
|
|
|
|
|
opacityAnim.to = 1;
|
|
|
|
|
opacityAnim.restart();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onClosing: (close) => {
|
|
|
|
|
if (applicationItem.opacity !== 0) {
|
|
|
|
|
close.accepted = false;
|
|
|
|
|
opacityAnim.to = 0;
|
|
|
|
|
opacityAnim.restart();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
|
|
|
|
|
signal requestConfigureMenu()
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
Kirigami.ApplicationItem {
|
|
|
|
|
id: applicationItem
|
|
|
|
|
anchors.fill: parent
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
opacity: 0
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
NumberAnimation on opacity {
|
|
|
|
|
id: opacityAnim
|
|
|
|
|
duration: 200
|
|
|
|
|
easing.type: Easing.OutCubic
|
|
|
|
|
onFinished: {
|
|
|
|
|
if (applicationItem.opacity === 0) {
|
|
|
|
|
root.close();
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
scale: 0.7 + 0.3 * applicationItem.opacity
|
|
|
|
|
|
|
|
|
|
pageStack.globalToolBar.style: Kirigami.ApplicationHeaderStyle.ToolBar
|
|
|
|
|
pageStack.globalToolBar.showNavigationButtons: Kirigami.ApplicationHeaderStyle.NoNavigationButtons;
|
|
|
|
|
|
|
|
|
|
pageStack.initialPage: Kirigami.ScrollablePage {
|
|
|
|
|
id: page
|
|
|
|
|
opacity: applicationItem.opacity
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
titleDelegate: RowLayout {
|
|
|
|
|
QQC2.ToolButton {
|
|
|
|
|
Layout.leftMargin: -Kirigami.Units.gridUnit + Kirigami.Units.smallSpacing
|
|
|
|
|
icon.name: "arrow-left"
|
|
|
|
|
onClicked: root.close()
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
Kirigami.Heading {
|
|
|
|
|
level: 1
|
|
|
|
|
text: page.title
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
title: i18n("Homescreen Settings")
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
topPadding: 0
|
|
|
|
|
bottomPadding: 0
|
|
|
|
|
leftPadding: 0
|
|
|
|
|
rightPadding: 0
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
ColumnLayout {
|
|
|
|
|
FormCard.FormHeader {
|
|
|
|
|
title: i18n("Icons")
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormCard {
|
|
|
|
|
Kirigami.Theme.inherit: false
|
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
|
|
|
|
|
|
|
|
|
|
Item {
|
2024-06-21 04:42:14 +00:00
|
|
|
Layout.preferredHeight: folio.HomeScreenState.pageCellHeight
|
2023-11-05 17:46:17 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
|
|
AbstractDelegate {
|
2024-06-21 04:42:14 +00:00
|
|
|
folio: root.folio
|
2023-11-05 17:46:17 +00:00
|
|
|
anchors.centerIn: parent
|
2024-06-21 04:42:14 +00:00
|
|
|
implicitHeight: folio.HomeScreenState.pageCellHeight
|
|
|
|
|
implicitWidth: folio.HomeScreenState.pageCellWidth
|
2023-11-05 17:46:17 +00:00
|
|
|
name: i18n('Application')
|
|
|
|
|
|
|
|
|
|
contentItem: DelegateAppIcon {
|
2024-06-21 04:42:14 +00:00
|
|
|
height: folio.FolioSettings.delegateIconSize
|
|
|
|
|
width: folio.FolioSettings.delegateIconSize
|
2023-11-05 17:46:17 +00:00
|
|
|
source: 'applications-system'
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormCard {
|
|
|
|
|
id: iconsCard
|
2024-06-21 04:42:14 +00:00
|
|
|
readonly property bool isVerticalOrientation: folio.HomeScreenState.pageOrientation === Folio.HomeScreenState.RegularPosition ||
|
|
|
|
|
folio.HomeScreenState.pageOrientation === Folio.HomeScreenState.RotateUpsideDown
|
2023-11-05 17:46:17 +00:00
|
|
|
|
|
|
|
|
readonly property string numOfRowsText: i18n("Number of rows")
|
|
|
|
|
readonly property string numOfColumnsText: i18n("Number of columns")
|
|
|
|
|
|
|
|
|
|
FormCard.FormSpinBoxDelegate {
|
|
|
|
|
id: iconSizeSpinBox
|
|
|
|
|
label: i18n("Size of icons on homescreen")
|
|
|
|
|
from: 16
|
|
|
|
|
to: 128
|
2024-06-21 04:42:14 +00:00
|
|
|
value: folio.FolioSettings.delegateIconSize
|
2023-11-05 17:46:17 +00:00
|
|
|
onValueChanged: {
|
2024-06-21 04:42:14 +00:00
|
|
|
if (value !== folio.FolioSettings.delegateIconSize) {
|
|
|
|
|
folio.FolioSettings.delegateIconSize = value;
|
2023-11-05 17:46:17 +00:00
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormSpinBoxDelegate {
|
|
|
|
|
id: rowsSpinBox
|
|
|
|
|
label: iconsCard.isVerticalOrientation ? iconsCard.numOfRowsText : iconsCard.numOfColumnsText
|
|
|
|
|
from: 3
|
|
|
|
|
to: 10
|
2024-06-21 04:42:14 +00:00
|
|
|
value: folio.FolioSettings.homeScreenRows
|
2023-11-05 17:46:17 +00:00
|
|
|
onValueChanged: {
|
2024-06-21 04:42:14 +00:00
|
|
|
if (value !== folio.FolioSettings.homeScreenRows) {
|
|
|
|
|
folio.FolioSettings.homeScreenRows = value;
|
2023-11-05 17:46:17 +00:00
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormSpinBoxDelegate {
|
|
|
|
|
id: columnsSpinBox
|
|
|
|
|
label: iconsCard.isVerticalOrientation ? iconsCard.numOfColumnsText : iconsCard.numOfRowsText
|
|
|
|
|
from: 3
|
|
|
|
|
to: 10
|
2024-06-21 04:42:14 +00:00
|
|
|
value: folio.FolioSettings.homeScreenColumns
|
2023-11-05 17:46:17 +00:00
|
|
|
onValueChanged: {
|
2024-06-21 04:42:14 +00:00
|
|
|
if (value !== folio.FolioSettings.homeScreenColumns) {
|
|
|
|
|
folio.FolioSettings.homeScreenColumns = value;
|
2023-11-05 17:46:17 +00:00
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormSectionText {
|
|
|
|
|
text: i18n("The rows and columns will swap depending on the screen rotation.")
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormHeader {
|
|
|
|
|
title: i18n("Homescreen")
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormCard {
|
|
|
|
|
FormCard.FormSwitchDelegate {
|
|
|
|
|
id: showLabelsOnHomeScreen
|
|
|
|
|
text: i18n("Show labels on homescreen")
|
2024-06-21 04:42:14 +00:00
|
|
|
checked: folio.FolioSettings.showPagesAppLabels
|
2023-11-05 17:46:17 +00:00
|
|
|
onCheckedChanged: {
|
2024-06-21 04:42:14 +00:00
|
|
|
if (checked != folio.FolioSettings.showPagesAppLabels) {
|
|
|
|
|
folio.FolioSettings.showPagesAppLabels = checked;
|
2023-11-05 17:46:17 +00:00
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormDelegateSeparator { above: showLabelsOnHomeScreen; below: showLabelsInFavourites }
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormSwitchDelegate {
|
|
|
|
|
id: showLabelsInFavourites
|
|
|
|
|
text: i18n("Show labels in favorites bar")
|
2024-06-21 04:42:14 +00:00
|
|
|
checked: folio.FolioSettings.showFavouritesAppLabels
|
2023-11-05 17:46:17 +00:00
|
|
|
onCheckedChanged: {
|
2024-06-21 04:42:14 +00:00
|
|
|
if (checked != folio.FolioSettings.showFavouritesAppLabels) {
|
|
|
|
|
folio.FolioSettings.showFavouritesAppLabels = checked;
|
2023-11-05 17:46:17 +00:00
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
2023-10-22 19:34:02 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormDelegateSeparator { above: showLabelsInFavourites; below: pageTransitionCombobox }
|
|
|
|
|
|
|
|
|
|
FormCard.FormComboBoxDelegate {
|
|
|
|
|
id: pageTransitionCombobox
|
|
|
|
|
text: i18n("Page transition effect")
|
|
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
currentIndex: indexOfValue(folio.FolioSettings.pageTransitionEffect)
|
2023-11-05 17:46:17 +00:00
|
|
|
model: ListModel {
|
|
|
|
|
// we can't use i18n with ListElement
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
append({"name": i18n("Slide"), "value": Folio.FolioSettings.SlideTransition});
|
|
|
|
|
append({"name": i18n("Cube"), "value": Folio.FolioSettings.CubeTransition});
|
|
|
|
|
append({"name": i18n("Fade"), "value": Folio.FolioSettings.FadeTransition});
|
|
|
|
|
append({"name": i18n("Stack"), "value": Folio.FolioSettings.StackTransition});
|
|
|
|
|
append({"name": i18n("Rotation"), "value": Folio.FolioSettings.RotationTransition});
|
|
|
|
|
|
|
|
|
|
// indexOfValue doesn't bind to model changes unfortunately, set currentIndex manually here
|
2024-06-21 04:42:14 +00:00
|
|
|
pageTransitionCombobox.currentIndex = pageTransitionCombobox.indexOfValue(folio.FolioSettings.pageTransitionEffect)
|
2023-11-05 17:46:17 +00:00
|
|
|
}
|
2023-10-22 19:34:02 +00:00
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
textRole: "name"
|
|
|
|
|
valueRole: "value"
|
2023-10-22 19:34:02 +00:00
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
onCurrentValueChanged: folio.FolioSettings.pageTransitionEffect = currentValue
|
2023-11-05 17:46:17 +00:00
|
|
|
}
|
2023-10-22 19:34:02 +00:00
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormHeader {
|
|
|
|
|
title: i18n("Favorites Bar")
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormCard {
|
|
|
|
|
FormCard.FormSwitchDelegate {
|
|
|
|
|
text: i18n('Show background')
|
|
|
|
|
icon.name: 'draw-rectangle'
|
2024-06-21 04:42:14 +00:00
|
|
|
checked: folio.FolioSettings.showFavouritesBarBackground
|
2023-11-05 17:46:17 +00:00
|
|
|
onCheckedChanged: {
|
2024-06-21 04:42:14 +00:00
|
|
|
if (checked !== folio.FolioSettings.showFavouritesBarBackground) {
|
|
|
|
|
folio.FolioSettings.showFavouritesBarBackground = checked;
|
2023-11-05 17:46:17 +00:00
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-08 17:10:55 +00:00
|
|
|
FormCard.FormHeader {
|
|
|
|
|
title: i18nc("@title:group settings group", "Wallpaper")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FormCard.FormCard {
|
|
|
|
|
FormCard.FormSwitchDelegate {
|
|
|
|
|
id: showWallpaperBlur
|
|
|
|
|
text: i18nc("@option:check", "Show wallpaper blur effect")
|
2024-06-21 04:42:14 +00:00
|
|
|
checked: folio.FolioSettings.showWallpaperBlur
|
2024-02-08 17:10:55 +00:00
|
|
|
onCheckedChanged: {
|
2024-06-21 04:42:14 +00:00
|
|
|
if (checked != folio.FolioSettings.showWallpaperBlur) {
|
|
|
|
|
folio.FolioSettings.showWallpaperBlur = checked;
|
2024-02-08 17:10:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormHeader {
|
|
|
|
|
title: i18n("General")
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormCard {
|
|
|
|
|
Layout.bottomMargin: Kirigami.Units.gridUnit
|
|
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
|
id: containmentSettings
|
2024-02-08 17:10:55 +00:00
|
|
|
text: i18nc("@action:button", "Switch between homescreens and more wallpaper options")
|
2023-11-05 17:46:17 +00:00
|
|
|
icon.name: 'settings-configure'
|
|
|
|
|
onClicked: root.requestConfigureMenu()
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormDelegateSeparator { above: containmentSettings; below: exportSettings }
|
|
|
|
|
|
|
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
|
id: exportSettings
|
|
|
|
|
text: i18n('Export layout')
|
|
|
|
|
icon.name: 'document-export'
|
|
|
|
|
onClicked: exportFileDialog.open()
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormDelegateSeparator { above: exportSettings; below: importSettings }
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FormCard.FormButtonDelegate {
|
|
|
|
|
id: importSettings
|
|
|
|
|
text: i18n('Import layout')
|
|
|
|
|
icon.name: 'document-import'
|
|
|
|
|
onClicked: importFileDialog.open()
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
2023-10-22 17:17:09 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FileDialog {
|
|
|
|
|
id: exportFileDialog
|
|
|
|
|
title: i18n("Export layout to")
|
|
|
|
|
fileMode: FileDialog.SaveFile
|
|
|
|
|
defaultSuffix: 'json'
|
|
|
|
|
nameFilters: ["JSON files (*.json)"]
|
|
|
|
|
onAccepted: {
|
|
|
|
|
console.log('saving layout to ' + selectedFile);
|
|
|
|
|
if (selectedFile) {
|
2024-06-21 04:42:14 +00:00
|
|
|
let status = folio.FolioSettings.saveLayoutToFile(selectedFile);
|
2023-11-05 17:46:17 +00:00
|
|
|
if (status) {
|
|
|
|
|
exportedSuccessfullyPrompt.open();
|
|
|
|
|
} else {
|
|
|
|
|
exportFailedPrompt.open();
|
|
|
|
|
}
|
2023-10-22 17:17:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
FileDialog {
|
|
|
|
|
id: importFileDialog
|
2023-12-15 07:04:25 +00:00
|
|
|
title: i18n("Import layout from")
|
2023-11-05 17:46:17 +00:00
|
|
|
fileMode: FileDialog.OpenFile
|
|
|
|
|
nameFilters: ["JSON files (*.json)"]
|
|
|
|
|
onAccepted: {
|
|
|
|
|
console.log('about to load layout from ' + selectedFile);
|
|
|
|
|
confirmImportPrompt.open();
|
|
|
|
|
}
|
2023-10-22 17:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
Kirigami.PromptDialog {
|
|
|
|
|
id: exportFailedPrompt
|
|
|
|
|
title: i18n("Export Status")
|
|
|
|
|
subtitle: i18n("Failed to export to %1", String(exportFileDialog.selectedFile).substring('file://'.length))
|
|
|
|
|
standardButtons: Kirigami.Dialog.Close
|
|
|
|
|
}
|
2023-10-22 17:17:09 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
Kirigami.PromptDialog {
|
|
|
|
|
id: exportedSuccessfullyPrompt
|
|
|
|
|
title: i18n("Export Status")
|
|
|
|
|
subtitle: i18n("Homescreen layout exported successfully to %1", String(exportFileDialog.selectedFile).substring('file://'.length))
|
|
|
|
|
standardButtons: Kirigami.Dialog.Close
|
|
|
|
|
}
|
2023-10-22 17:17:09 +00:00
|
|
|
|
2023-11-05 17:46:17 +00:00
|
|
|
Kirigami.PromptDialog {
|
|
|
|
|
id: confirmImportPrompt
|
|
|
|
|
title: i18n("Confirm Import")
|
|
|
|
|
subtitle: i18n("This will overwrite your existing homescreen layout!")
|
|
|
|
|
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
|
2024-06-21 04:42:14 +00:00
|
|
|
onAccepted: folio.FolioSettings.loadLayoutFromFile(importFileDialog.selectedFile);
|
2023-11-05 17:46:17 +00:00
|
|
|
}
|
2023-10-22 17:17:09 +00:00
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|