fix: delete dialog
This commit is contained in:
parent
8319832a92
commit
7998c3d94f
3 changed files with 41 additions and 26 deletions
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "foldermodel.h"
|
#include "foldermodel.h"
|
||||||
#include "dirlister.h"
|
#include "dirlister.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
#include "../dialogs/filepropertiesdialog.h"
|
#include "../dialogs/filepropertiesdialog.h"
|
||||||
#include "../dialogs/createfolderdialog.h"
|
#include "../dialogs/createfolderdialog.h"
|
||||||
|
@ -106,10 +107,15 @@ FolderModel::FolderModel(QObject *parent)
|
||||||
, m_mimeAppManager(MimeAppManager::self())
|
, m_mimeAppManager(MimeAppManager::self())
|
||||||
, m_sizeJob(nullptr)
|
, m_sizeJob(nullptr)
|
||||||
, m_currentIndex(-1)
|
, m_currentIndex(-1)
|
||||||
|
, m_updateNeedSelectTimer(new QTimer(this))
|
||||||
{
|
{
|
||||||
QSettings settings("cutefishos", qApp->applicationName());
|
QSettings settings("cutefishos", qApp->applicationName());
|
||||||
m_showHiddenFiles = settings.value("showHiddenFiles", false).toBool();
|
m_showHiddenFiles = settings.value("showHiddenFiles", false).toBool();
|
||||||
|
|
||||||
|
m_updateNeedSelectTimer->setSingleShot(true);
|
||||||
|
m_updateNeedSelectTimer->setInterval(500);
|
||||||
|
connect(m_updateNeedSelectTimer, &QTimer::timeout, this, &FolderModel::updateNeedSelectUrls);
|
||||||
|
|
||||||
m_dirLister = new DirLister(this);
|
m_dirLister = new DirLister(this);
|
||||||
m_dirLister->setDelayedMimeTypes(true);
|
m_dirLister->setDelayedMimeTypes(true);
|
||||||
m_dirLister->setAutoErrorHandlingEnabled(false, nullptr);
|
m_dirLister->setAutoErrorHandlingEnabled(false, nullptr);
|
||||||
|
@ -973,7 +979,7 @@ void FolderModel::paste()
|
||||||
}
|
}
|
||||||
|
|
||||||
KIO::Job *job = KIO::paste(data, m_dirModel->dirLister()->url());
|
KIO::Job *job = KIO::paste(data, m_dirModel->dirLister()->url());
|
||||||
connect(job, &KIO::Job::finished, this, &FolderModel::delayUpdateNeedSelectUrls);
|
// connect(job, &KIO::Job::finished, this, &FolderModel::delayUpdateNeedSelectUrls);
|
||||||
job->start();
|
job->start();
|
||||||
|
|
||||||
// Clear system clipboard.
|
// Clear system clipboard.
|
||||||
|
@ -1371,22 +1377,9 @@ void FolderModel::openChangeWallpaperDialog()
|
||||||
|
|
||||||
void FolderModel::openDeleteDialog()
|
void FolderModel::openDeleteDialog()
|
||||||
{
|
{
|
||||||
QQuickView *view = new QQuickView;
|
Window *w = new Window;
|
||||||
view->setModality(Qt::ApplicationModal);
|
w->load(QUrl("qrc:/qml/Dialogs/DeleteDialog.qml"));
|
||||||
view->setFlags(Qt::Dialog);
|
w->rootContext()->setContextProperty("model", this);
|
||||||
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::openInNewWindow(const QString &url)
|
void FolderModel::openInNewWindow(const QString &url)
|
||||||
|
@ -1578,6 +1571,10 @@ void FolderModel::dragSelectedInternal(int x, int y)
|
||||||
|
|
||||||
void FolderModel::onRowsInserted(const QModelIndex &parent, int first, int last)
|
void FolderModel::onRowsInserted(const QModelIndex &parent, int first, int last)
|
||||||
{
|
{
|
||||||
|
if (m_updateNeedSelectTimer->isActive()) {
|
||||||
|
m_updateNeedSelectTimer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
QModelIndex changeIdx;
|
QModelIndex changeIdx;
|
||||||
|
|
||||||
for (int i = first; i <= last; ++i) {
|
for (int i = first; i <= last; ++i) {
|
||||||
|
@ -1602,6 +1599,8 @@ void FolderModel::onRowsInserted(const QModelIndex &parent, int first, int last)
|
||||||
emit requestRename();
|
emit requestRename();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_updateNeedSelectTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderModel::delayUpdateNeedSelectUrls()
|
void FolderModel::delayUpdateNeedSelectUrls()
|
||||||
|
@ -1624,6 +1623,11 @@ void FolderModel::updateNeedSelectUrls()
|
||||||
|
|
||||||
m_needSelectUrls.clear();
|
m_needSelectUrls.clear();
|
||||||
|
|
||||||
|
// If the selected item already exists, clear it immediately.
|
||||||
|
if (!needSelectList.isEmpty()) {
|
||||||
|
clearSelection();
|
||||||
|
}
|
||||||
|
|
||||||
for (const QModelIndex &idx : needSelectList) {
|
for (const QModelIndex &idx : needSelectList) {
|
||||||
setSelected(idx.row());
|
setSelected(idx.row());
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,6 +326,8 @@ private:
|
||||||
CFileSizeJob *m_sizeJob;
|
CFileSizeJob *m_sizeJob;
|
||||||
|
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
|
|
||||||
|
QTimer *m_updateNeedSelectTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FOLDERMODEL_H
|
#endif // FOLDERMODEL_H
|
||||||
|
|
|
@ -24,16 +24,25 @@ import QtQuick.Layouts 1.12
|
||||||
import FishUI 1.0 as FishUI
|
import FishUI 1.0 as FishUI
|
||||||
import Cutefish.FileManager 1.0
|
import Cutefish.FileManager 1.0
|
||||||
|
|
||||||
Item {
|
FishUI.Window {
|
||||||
id: control
|
id: control
|
||||||
|
|
||||||
width: 300 + FishUI.Units.largeSpacing * 2
|
flags: Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
|
||||||
height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 2
|
minimizeButtonVisible: false
|
||||||
|
visible: true
|
||||||
|
|
||||||
Rectangle {
|
width: contentWidth
|
||||||
anchors.fill: parent
|
height: contentHeight
|
||||||
color: FishUI.Theme.secondBackgroundColor
|
|
||||||
}
|
minimumWidth: contentWidth
|
||||||
|
minimumHeight: contentHeight
|
||||||
|
maximumWidth: contentWidth
|
||||||
|
maximumHeight: contentHeight
|
||||||
|
|
||||||
|
property var contentWidth: _mainLayout.implicitWidth + FishUI.Units.largeSpacing * 2
|
||||||
|
property var contentHeight: _mainLayout.implicitHeight + control.header.height + FishUI.Units.largeSpacing * 2
|
||||||
|
|
||||||
|
background.color: FishUI.Theme.secondBackgroundColor
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: _mainLayout
|
id: _mainLayout
|
||||||
|
@ -55,7 +64,7 @@ Item {
|
||||||
Button {
|
Button {
|
||||||
text: qsTr("Cancel")
|
text: qsTr("Cancel")
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
onClicked: view.close()
|
onClicked: control.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
@ -63,7 +72,7 @@ Item {
|
||||||
focus: true
|
focus: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
view.close()
|
control.close()
|
||||||
model.deleteSelected()
|
model.deleteSelected()
|
||||||
}
|
}
|
||||||
flat: true
|
flat: true
|
||||||
|
|
Loading…
Reference in a new issue