Error notification

This commit is contained in:
reionwong 2021-09-01 05:31:38 +08:00
parent d74c013309
commit 631a45394e
4 changed files with 17 additions and 0 deletions

View file

@ -85,6 +85,7 @@ FolderModel::FolderModel(QObject *parent)
DirLister *dirLister = new DirLister(this);
dirLister->setDelayedMimeTypes(true);
dirLister->setAutoErrorHandlingEnabled(false, nullptr);
// connect(dirLister, &DirLister::error, this, &FolderModel::notification);
m_dirModel = new KDirModel(this);
m_dirModel->setDirLister(dirLister);
@ -242,6 +243,11 @@ void FolderModel::setUrl(const QString &url)
const QUrl &resolvedNewUrl = resolve(url);
if (!QFile::exists(resolvedNewUrl.toLocalFile()) && !url.startsWith("trash:/")) {
emit notification(tr("The file or folder %1 does not exist.").arg(url));
return;
}
// Refresh this directory.
if (url == m_url) {
m_dirModel->dirLister()->updateDirectory(resolvedNewUrl);

View file

@ -217,6 +217,8 @@ signals:
void filterPatternChanged();
void filterMimeTypesChanged();
void notification(const QString &message);
private slots:
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
void dragSelectedInternal(int x, int y);

View file

@ -158,6 +158,7 @@ Item {
focus: true
flat: true
text: qsTr("Open")
enabled: listView.count > 0
Layout.fillWidth: true
onClicked: control.openApp()
}

View file

@ -150,6 +150,14 @@ Item {
}
}
Connections {
target: dirModel
function onNotification(text) {
root.showPassiveNotification(text, 3000)
}
}
FM.ItemViewAdapter {
id: viewAdapter
adapterView: _viewLoader.item