mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
homescreens/folio: Add dialog to confirm whether to delete a folder
This commit is contained in:
parent
8f39d156f1
commit
e84989afee
5 changed files with 57 additions and 5 deletions
|
|
@ -11,6 +11,7 @@ import org.kde.private.mobile.homescreen.folio 1.0 as Folio
|
|||
import org.kde.plasma.private.mobileshell as MobileShell
|
||||
import org.kde.kirigami 2.10 as Kirigami
|
||||
|
||||
import "./private"
|
||||
import "./delegate"
|
||||
|
||||
MouseArea {
|
||||
|
|
@ -199,7 +200,6 @@ MouseArea {
|
|||
contextMenu.open();
|
||||
}
|
||||
|
||||
// TODO don't use loader, and move outside to a page to make it more performant
|
||||
ContextMenuLoader {
|
||||
id: contextMenu
|
||||
|
||||
|
|
@ -218,9 +218,15 @@ MouseArea {
|
|||
Kirigami.Action {
|
||||
icon.name: "emblem-favorite"
|
||||
text: i18n("Remove")
|
||||
onTriggered: Folio.FavouritesModel.removeEntry(delegate.index)
|
||||
onTriggered: deleteDialog.open()
|
||||
}
|
||||
]
|
||||
|
||||
ConfirmDeleteFolderDialogLoader {
|
||||
id: deleteDialog
|
||||
parent: root.homeScreen
|
||||
onAccepted: Folio.FavouritesModel.removeEntry(delegate.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import org.kde.kirigami 2.20 as Kirigami
|
|||
import org.kde.plasma.private.mobileshell as MobileShell
|
||||
import org.kde.private.mobile.homescreen.folio 1.0 as Folio
|
||||
|
||||
import "./private"
|
||||
import "./delegate"
|
||||
|
||||
Folio.DelegateTouchArea {
|
||||
|
|
|
|||
|
|
@ -194,7 +194,6 @@ Item {
|
|||
contextMenu.open();
|
||||
}
|
||||
|
||||
// TODO don't use loader, and move outside to a page to make it more performant
|
||||
ContextMenuLoader {
|
||||
id: contextMenu
|
||||
|
||||
|
|
@ -274,7 +273,6 @@ Item {
|
|||
contextMenu.open();
|
||||
}
|
||||
|
||||
// TODO don't use loader, and move outside to a page to make it more performant
|
||||
ContextMenuLoader {
|
||||
id: contextMenu
|
||||
|
||||
|
|
@ -293,9 +291,15 @@ Item {
|
|||
Kirigami.Action {
|
||||
icon.name: "emblem-favorite"
|
||||
text: i18n("Remove")
|
||||
onTriggered: delegate.removeSelf()
|
||||
onTriggered: deleteDialog.open()
|
||||
}
|
||||
]
|
||||
|
||||
ConfirmDeleteFolderDialogLoader {
|
||||
id: deleteDialog
|
||||
parent: root.homeScreen
|
||||
onAccepted: delegate.removeSelf()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
// SPDX-FileCopyrightText: 2024 Devin Lin <devin@kde.org>
|
||||
// SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Window
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.plasma.components 3.0 as PC3
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
Loader {
|
||||
id: root
|
||||
active: false
|
||||
|
||||
// we expect the parent to be set to the homescreen, otherwise the dialog opens with no size
|
||||
anchors.fill: parent
|
||||
|
||||
signal accepted()
|
||||
|
||||
function open() {
|
||||
root.active = true;
|
||||
root.item.open();
|
||||
}
|
||||
|
||||
function close() {
|
||||
if (root.item) {
|
||||
root.item.close();
|
||||
}
|
||||
}
|
||||
|
||||
sourceComponent: Kirigami.PromptDialog {
|
||||
id: menu
|
||||
title: i18n('Confirm Folder Deletion')
|
||||
subtitle: i18n('Are you sure you want to delete this folder?')
|
||||
standardButtons: Kirigami.Dialog.Yes | Kirigami.Dialog.Cancel
|
||||
|
||||
onAccepted: root.accepted()
|
||||
onClosed: root.active = false
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue