Add empty-trash dialog
This commit is contained in:
parent
39f8e9da82
commit
24ee16ad99
7 changed files with 150 additions and 8 deletions
|
@ -37,6 +37,7 @@ add_executable(cutefish-filemanager
|
|||
helper/datehelper.cpp
|
||||
helper/thumbnailer.cpp
|
||||
helper/pathhistory.cpp
|
||||
helper/fm.cpp
|
||||
|
||||
desktopiconprovider.cpp
|
||||
|
||||
|
|
32
helper/fm.cpp
Normal file
32
helper/fm.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: revenmartin <revenmartin@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/>.
|
||||
*/
|
||||
|
||||
#include "fm.h"
|
||||
#include <KIO/EmptyTrashJob>
|
||||
|
||||
Fm::Fm(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Fm::emptyTrash()
|
||||
{
|
||||
KIO::Job *job = KIO::emptyTrash();
|
||||
job->start();
|
||||
}
|
35
helper/fm.h
Normal file
35
helper/fm.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: revenmartin <revenmartin@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/>.
|
||||
*/
|
||||
|
||||
#ifndef FM_H
|
||||
#define FM_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Fm : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Fm(QObject *parent = nullptr);
|
||||
|
||||
Q_INVOKABLE static void emptyTrash();
|
||||
};
|
||||
|
||||
#endif // FM_H
|
12
main.cpp
12
main.cpp
|
@ -35,6 +35,7 @@
|
|||
#include "desktop/desktopview.h"
|
||||
#include "helper/thumbnailer.h"
|
||||
#include "helper/datehelper.h"
|
||||
#include "helper/fm.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -64,6 +65,7 @@ int main(int argc, char *argv[])
|
|||
qmlRegisterType<RubberBand>(uri, 1, 0, "RubberBand");
|
||||
qmlRegisterType<ItemViewAdapter>(uri, 1, 0, "ItemViewAdapter");
|
||||
qmlRegisterType<DesktopSettings>(uri, 1, 0, "DesktopSettings");
|
||||
qmlRegisterType<Fm>(uri, 1, 0, "Fm");
|
||||
qmlRegisterAnonymousType<QAction>(uri, 1);
|
||||
|
||||
QCommandLineParser parser;
|
||||
|
@ -74,6 +76,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
QCommandLineOption desktopOption(QStringList() << "d" << "desktop" << "Desktop Mode");
|
||||
parser.addOption(desktopOption);
|
||||
|
||||
QCommandLineOption emptyTrashOption(QStringList() << "e" << "empty-trash" << "Empty Trash");
|
||||
parser.addOption(emptyTrashOption);
|
||||
|
||||
parser.process(app);
|
||||
|
||||
if (parser.isSet(desktopOption)) {
|
||||
|
@ -81,6 +87,12 @@ int main(int argc, char *argv[])
|
|||
DesktopView view;
|
||||
view.show();
|
||||
return app.exec();
|
||||
} else if (parser.isSet(emptyTrashOption)) {
|
||||
// Empty Dialog
|
||||
QQmlApplicationEngine engine;
|
||||
const QUrl url(QStringLiteral("qrc:/qml/Dialogs/EmptyTrashDialog.qml"));
|
||||
engine.load(url);
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <QPainter>
|
||||
#include <QDrag>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
|
||||
// Qt Quick
|
||||
#include <QQuickItem>
|
||||
|
@ -54,7 +55,6 @@
|
|||
#include <KIO/PreviewJob>
|
||||
#include <KIO/DeleteJob>
|
||||
#include <KIO/DropJob>
|
||||
#include <KIO/EmptyTrashJob>
|
||||
#include <KIO/FileUndoManager>
|
||||
#include <KIO/JobUiDelegate>
|
||||
#include <KIO/Paste>
|
||||
|
@ -749,13 +749,7 @@ void FolderModel::moveSelectedToTrash()
|
|||
|
||||
void FolderModel::emptyTrash()
|
||||
{
|
||||
KIO::JobUiDelegate uiDelegate;
|
||||
uiDelegate.setWindow(QApplication::desktop());
|
||||
|
||||
if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
|
||||
KIO::Job *job = KIO::emptyTrash();
|
||||
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
|
||||
}
|
||||
QProcess::startDetached("cutefish-filemanager", QStringList() << "-e");
|
||||
}
|
||||
|
||||
void FolderModel::keyDeletePress()
|
||||
|
|
1
qml.qrc
1
qml.qrc
|
@ -43,5 +43,6 @@
|
|||
<file>qml/OptionsMenu.qml</file>
|
||||
<file>images/light/up.svg</file>
|
||||
<file>images/dark/up.svg</file>
|
||||
<file>qml/Dialogs/EmptyTrashDialog.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
67
qml/Dialogs/EmptyTrashDialog.qml
Normal file
67
qml/Dialogs/EmptyTrashDialog.qml
Normal file
|
@ -0,0 +1,67 @@
|
|||
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
|
||||
|
||||
Window {
|
||||
id: control
|
||||
|
||||
title: qsTr("File Manager")
|
||||
flags: Qt.Dialog
|
||||
visible: true
|
||||
|
||||
width: 300 + FishUI.Units.largeSpacing * 2
|
||||
height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 3
|
||||
|
||||
minimumWidth: width
|
||||
minimumHeight: height
|
||||
maximumWidth: width
|
||||
maximumHeight: height
|
||||
|
||||
Fm {
|
||||
id: fm
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: FishUI.Theme.backgroundColor
|
||||
}
|
||||
|
||||
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 permanently delete all files from the Trash?")
|
||||
Layout.fillWidth: true
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: FishUI.Units.largeSpacing
|
||||
|
||||
Button {
|
||||
text: qsTr("Cancel")
|
||||
Layout.fillWidth: true
|
||||
onClicked: control.close()
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("Empty Trash")
|
||||
focus: true
|
||||
Layout.fillWidth: true
|
||||
onClicked: {
|
||||
fm.emptyTrash()
|
||||
control.close()
|
||||
}
|
||||
flat: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue