diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 8967b1f6c9f6a..a0458ea632a9a 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -1302,6 +1302,19 @@ QString Folder::fileFromLocalPath(const QString &localPath) const void Folder::setLockFileState(const QString &serverRelativePath, const SyncFileItem::LockStatus lock) { const auto job = new LockFileJob(accountState()->account(), &_journal, serverRelativePath, lock); + connect(job, &LockFileJob::finishedWithError, [lock, serverRelativePath](const int httpErrorCode, const QString &errorString, const QString &lockOwnerName) { + auto errorMessage = QString{}; + const auto filePath = serverRelativePath.mid(1); + + if (httpErrorCode == LockFileJob::LOCKED_HTTP_ERROR_CODE) { + errorMessage = tr("File %1 is already locked by %2.").arg(filePath, lockOwnerName); + } else if (lock == SyncFileItem::LockStatus::LockedItem) { + errorMessage = tr("Lock operation on %1 failed with error %2").arg(filePath, errorString); + } else if (lock == SyncFileItem::LockStatus::UnlockedItem) { + errorMessage = tr("Unlock operation on %1 failed with error %2").arg(filePath, errorString); + } + emit Systray::instance()->showErrorMessageDialog(errorMessage); + }); job->start(); } diff --git a/src/gui/systray.h b/src/gui/systray.h index 0b4aabc3ec79b..e3e974e6d4844 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -93,6 +93,7 @@ class Systray void openShareDialog(const QString &sharePath, const QString &localPath); void showFileActivityDialog(const QString &objectName, const int objectId); void sendChatMessage(const QString &token, const QString &message, const QString &replyTo); + void showErrorMessageDialog(const QString &error); public slots: void slotNewUserSelected(); diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index c1c56039cf794..cfb6aaacd40c4 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -5,6 +5,7 @@ import QtQuick.Window 2.3 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.2 import QtGraphicalEffects 1.0 +import Qt.labs.platform 1.1 as NativeDialogs import "../" // Custom qml modules are in /theme (and included by resources.qrc) @@ -62,6 +63,19 @@ Window { } } + Component { + id: errorMessageDialog + + NativeDialogs.MessageDialog { + id: dialog + + title: Systray.windowTitle + + onAccepted: destroy() + onRejected: destroy() + } + } + Connections { target: Systray function onShowWindow() { @@ -84,6 +98,12 @@ Window { function onShowFileActivityDialog(objectName, objectId) { openFileActivityDialog(objectName, objectId) } + + function onShowErrorMessageDialog(error) { + var newErrorDialog = errorMessageDialog.createObject(trayWindow) + newErrorDialog.text = error + newErrorDialog.open() + } } OpacityMask {