Add delete confirm dialog
This commit is contained in:
parent
422fc5d6f9
commit
794f9ed1c7
6 changed files with 184 additions and 47 deletions
|
@ -52,6 +52,7 @@
|
|||
|
||||
// Qt Quick
|
||||
#include <QQuickItem>
|
||||
#include <QQmlContext>
|
||||
|
||||
// KIO
|
||||
#include <KIO/CopyJob>
|
||||
|
@ -871,13 +872,8 @@ void FolderModel::deleteSelected()
|
|||
}
|
||||
}
|
||||
|
||||
const QList<QUrl> urls = selectedUrls();
|
||||
KIO::JobUiDelegate uiDelegate;
|
||||
|
||||
if (uiDelegate.askDeleteConfirmation(urls, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {
|
||||
KIO::Job *job = KIO::del(urls);
|
||||
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
|
||||
}
|
||||
KIO::DeleteJob *job = KIO::del(selectedUrls());
|
||||
job->start();
|
||||
}
|
||||
|
||||
void FolderModel::moveSelectedToTrash()
|
||||
|
@ -912,7 +908,7 @@ void FolderModel::keyDeletePress()
|
|||
if (!m_selectionModel->hasSelection())
|
||||
return;
|
||||
|
||||
resolvedUrl().scheme() == "trash" ? deleteSelected() : moveSelectedToTrash();
|
||||
resolvedUrl().scheme() == "trash" ? openDeleteDialog() : moveSelectedToTrash();
|
||||
}
|
||||
|
||||
void FolderModel::setDragHotSpotScrollOffset(int x, int y)
|
||||
|
@ -1084,6 +1080,26 @@ void FolderModel::openChangeWallpaperDialog()
|
|||
QProcess::startDetached("cutefish-settings", QStringList() << "-m" << "background");
|
||||
}
|
||||
|
||||
void FolderModel::openDeleteDialog()
|
||||
{
|
||||
QQuickView *view = new QQuickView;
|
||||
view->setModality(Qt::ApplicationModal);
|
||||
view->setFlags(Qt::Dialog);
|
||||
view->setTitle(tr("File Manager"));
|
||||
view->setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
view->setSource(QUrl("qrc:/qml/Dialogs/DeleteDialog.qml"));
|
||||
view->rootContext()->setContextProperty("model", this);
|
||||
view->rootContext()->setContextProperty("view", view);
|
||||
|
||||
connect(view, &QQuickView::visibleChanged, this, [=] {
|
||||
if (!view->isVisible()) {
|
||||
view->deleteLater();
|
||||
}
|
||||
});
|
||||
|
||||
view->show();
|
||||
}
|
||||
|
||||
void FolderModel::restoreFromTrash()
|
||||
{
|
||||
if (!m_selectionModel->hasSelection())
|
||||
|
@ -1287,7 +1303,7 @@ void FolderModel::createActions()
|
|||
connect(emptyTrash, &QAction::triggered, this, &FolderModel::emptyTrash);
|
||||
|
||||
QAction *del = new QAction(tr("Delete"), this);
|
||||
connect(del, &QAction::triggered, this, &FolderModel::deleteSelected);
|
||||
connect(del, &QAction::triggered, this, &FolderModel::openDeleteDialog);
|
||||
|
||||
QAction *rename = new QAction(tr("Rename"), this);
|
||||
connect(rename, &QAction::triggered, this, &FolderModel::requestRename);
|
||||
|
|
|
@ -196,6 +196,7 @@ public:
|
|||
Q_INVOKABLE void openPropertiesDialog();
|
||||
Q_INVOKABLE void openInTerminal();
|
||||
Q_INVOKABLE void openChangeWallpaperDialog();
|
||||
Q_INVOKABLE void openDeleteDialog();
|
||||
|
||||
void restoreFromTrash();
|
||||
|
||||
|
|
1
qml.qrc
1
qml.qrc
|
@ -58,5 +58,6 @@
|
|||
<file>images/dark/drive-optical.svg</file>
|
||||
<file>images/light/drive-optical.svg</file>
|
||||
<file>qml/Dialogs/OpenWithDialog.qml</file>
|
||||
<file>qml/Dialogs/DeleteDialog.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
73
qml/Dialogs/DeleteDialog.qml
Normal file
73
qml/Dialogs/DeleteDialog.qml
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: Reion Wong <reionwong@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Window 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import FishUI 1.0 as FishUI
|
||||
import Cutefish.FileManager 1.0
|
||||
|
||||
Item {
|
||||
id: control
|
||||
|
||||
width: 300 + FishUI.Units.largeSpacing * 2
|
||||
height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 2
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: FishUI.Theme.secondBackgroundColor
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: _mainLayout
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: FishUI.Units.largeSpacing
|
||||
anchors.rightMargin: FishUI.Units.largeSpacing
|
||||
anchors.bottomMargin: FishUI.Units.smallSpacing
|
||||
spacing: FishUI.Units.largeSpacing
|
||||
|
||||
Label {
|
||||
text: qsTr("Do you want to delete it permanently?")
|
||||
Layout.fillWidth: true
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: FishUI.Units.largeSpacing
|
||||
|
||||
Button {
|
||||
text: qsTr("Cancel")
|
||||
Layout.fillWidth: true
|
||||
onClicked: view.close()
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("Delete")
|
||||
focus: true
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
view.close()
|
||||
model.deleteSelected()
|
||||
}
|
||||
flat: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -62,6 +62,24 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DeleteDialog</name>
|
||||
<message>
|
||||
<location filename="../qml/Dialogs/DeleteDialog.qml" line="47"/>
|
||||
<source>Do you want to delete it permanently?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Dialogs/DeleteDialog.qml" line="56"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Dialogs/DeleteDialog.qml" line="62"/>
|
||||
<source>Delete</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DesktopView</name>
|
||||
<message>
|
||||
|
@ -109,97 +127,102 @@
|
|||
<context>
|
||||
<name>FolderModel</name>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="183"/>
|
||||
<location filename="../model/foldermodel.cpp" line="184"/>
|
||||
<source>%1 item</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="183"/>
|
||||
<location filename="../model/foldermodel.cpp" line="184"/>
|
||||
<source>%1 items</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="248"/>
|
||||
<location filename="../model/foldermodel.cpp" line="249"/>
|
||||
<source>The file or folder %1 does not exist.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="985"/>
|
||||
<location filename="../model/foldermodel.cpp" line="981"/>
|
||||
<source>Select All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1265"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1088"/>
|
||||
<source>File Manager</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1281"/>
|
||||
<source>Open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1268"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1284"/>
|
||||
<source>Open with</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1271"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1287"/>
|
||||
<source>Cut</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1274"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1290"/>
|
||||
<source>Copy</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1277"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1293"/>
|
||||
<source>Paste</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1280"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1296"/>
|
||||
<source>New Folder</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1283"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1299"/>
|
||||
<source>Move To Trash</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1286"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1302"/>
|
||||
<source>Empty Trash</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1289"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1305"/>
|
||||
<source>Delete</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1292"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1308"/>
|
||||
<source>Rename</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1295"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1311"/>
|
||||
<source>Open in Terminal</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1298"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1314"/>
|
||||
<source>Set as Wallpaper</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1301"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1317"/>
|
||||
<source>Properties</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1304"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1320"/>
|
||||
<source>Change background</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1307"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1323"/>
|
||||
<source>Restore</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -62,6 +62,24 @@
|
|||
<translation>%1天前</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DeleteDialog</name>
|
||||
<message>
|
||||
<location filename="../qml/Dialogs/DeleteDialog.qml" line="47"/>
|
||||
<source>Do you want to delete it permanently?</source>
|
||||
<translation>是否要永久删除?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Dialogs/DeleteDialog.qml" line="56"/>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Dialogs/DeleteDialog.qml" line="62"/>
|
||||
<source>Delete</source>
|
||||
<translation>删除</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DesktopView</name>
|
||||
<message>
|
||||
|
@ -109,97 +127,102 @@
|
|||
<context>
|
||||
<name>FolderModel</name>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="183"/>
|
||||
<location filename="../model/foldermodel.cpp" line="184"/>
|
||||
<source>%1 item</source>
|
||||
<translation>%1 项</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="183"/>
|
||||
<location filename="../model/foldermodel.cpp" line="184"/>
|
||||
<source>%1 items</source>
|
||||
<translation>%1 项</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="248"/>
|
||||
<location filename="../model/foldermodel.cpp" line="249"/>
|
||||
<source>The file or folder %1 does not exist.</source>
|
||||
<translation>文件或文件夹 %1 不存在</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="985"/>
|
||||
<location filename="../model/foldermodel.cpp" line="981"/>
|
||||
<source>Select All</source>
|
||||
<translation>全选</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1265"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1088"/>
|
||||
<source>File Manager</source>
|
||||
<translation type="unfinished">文件管理器</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1281"/>
|
||||
<source>Open</source>
|
||||
<translation>打开</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1268"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1284"/>
|
||||
<source>Open with</source>
|
||||
<translation>打开方式</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1271"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1287"/>
|
||||
<source>Cut</source>
|
||||
<translation>剪切</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1274"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1290"/>
|
||||
<source>Copy</source>
|
||||
<translation>复制</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1277"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1293"/>
|
||||
<source>Paste</source>
|
||||
<translation>粘贴</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1280"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1296"/>
|
||||
<source>New Folder</source>
|
||||
<translation>新建文件夹</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1283"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1299"/>
|
||||
<source>Move To Trash</source>
|
||||
<translation>移动到回收站</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1286"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1302"/>
|
||||
<source>Empty Trash</source>
|
||||
<translation>清空回收站</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1289"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1305"/>
|
||||
<source>Delete</source>
|
||||
<translation>删除</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1292"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1308"/>
|
||||
<source>Rename</source>
|
||||
<translation>重命名</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1295"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1311"/>
|
||||
<source>Open in Terminal</source>
|
||||
<translation>在终端中打开</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1298"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1314"/>
|
||||
<source>Set as Wallpaper</source>
|
||||
<translation>设置为壁纸</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1301"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1317"/>
|
||||
<source>Properties</source>
|
||||
<translation>属性</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1304"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1320"/>
|
||||
<source>Change background</source>
|
||||
<translation>更改桌面背景</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../model/foldermodel.cpp" line="1307"/>
|
||||
<location filename="../model/foldermodel.cpp" line="1323"/>
|
||||
<source>Restore</source>
|
||||
<translation>恢复</translation>
|
||||
</message>
|
||||
|
|
Loading…
Reference in a new issue