From 38d82dfb5f6030fc3f336bfa9f6eadd164a4a4aa Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 13 Jul 2023 09:27:07 +0800 Subject: [PATCH 1/8] Add sharingAvailable property to FileDetails class Signed-off-by: Claudio Cambra --- src/gui/filedetails/filedetails.cpp | 5 +++++ src/gui/filedetails/filedetails.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/gui/filedetails/filedetails.cpp b/src/gui/filedetails/filedetails.cpp index 37ef696c60..2e24dc2659 100644 --- a/src/gui/filedetails/filedetails.cpp +++ b/src/gui/filedetails/filedetails.cpp @@ -172,4 +172,9 @@ void FileDetails::updateFileTagModel(const Folder * const folder) Q_EMIT fileTagModelChanged(); } +bool FileDetails::sharingAvailable() const +{ + return _sharingAvailable; +} + } // namespace OCC diff --git a/src/gui/filedetails/filedetails.h b/src/gui/filedetails/filedetails.h index a1fbf9ac57..2834981afb 100644 --- a/src/gui/filedetails/filedetails.h +++ b/src/gui/filedetails/filedetails.h @@ -38,6 +38,7 @@ class FileDetails : public QObject Q_PROPERTY(QString lockExpireString READ lockExpireString NOTIFY lockExpireStringChanged) Q_PROPERTY(bool isFolder READ isFolder NOTIFY isFolderChanged) Q_PROPERTY(FileTagModel* fileTagModel READ fileTagModel NOTIFY fileTagModelChanged) + Q_PROPERTY(bool sharingAvailable READ sharingAvailable NOTIFY fileChanged) public: explicit FileDetails(QObject *parent = nullptr); @@ -50,6 +51,7 @@ public: [[nodiscard]] QString lockExpireString() const; [[nodiscard]] bool isFolder() const; [[nodiscard]] FileTagModel *fileTagModel() const; + [[nodiscard]] bool sharingAvailable() const; public slots: void setLocalPath(const QString &localPath); @@ -80,6 +82,7 @@ private: QLocale _locale; std::unique_ptr _fileTagModel; + bool _sharingAvailable = true; }; } // namespace OCC From 4bcff7d991b37c911276eee87f4c8ef0c2b1f590 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 13 Jul 2023 09:28:54 +0800 Subject: [PATCH 2/8] Set sharingAvailable property in FileDetails from Folder account capabilities Signed-off-by: Claudio Cambra --- src/gui/filedetails/filedetails.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/filedetails/filedetails.cpp b/src/gui/filedetails/filedetails.cpp index 2e24dc2659..58c1854ea8 100644 --- a/src/gui/filedetails/filedetails.cpp +++ b/src/gui/filedetails/filedetails.cpp @@ -62,6 +62,7 @@ void FileDetails::setLocalPath(const QString &localPath) connect(&_fileWatcher, &QFileSystemWatcher::fileChanged, this, &FileDetails::refreshFileDetails); const auto folder = FolderMan::instance()->folderForPath(_localPath); + Q_ASSERT(folder); const auto file = _localPath.mid(folder->cleanPath().length() + 1); if (!folder->journalDb()->getFileRecord(file, &_fileRecord)) { @@ -74,6 +75,8 @@ void FileDetails::setLocalPath(const QString &localPath) updateLockExpireString(); updateFileTagModel(folder); + _sharingAvailable = folder->accountState()->account()->capabilities().shareAPI(); + Q_EMIT fileChanged(); } From ea5397865d31feb1166fd1d6ef2edf4c6a3c2ca7 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 13 Jul 2023 10:28:10 +0800 Subject: [PATCH 3/8] Do not display sharing entry if sharing is not available on server Signed-off-by: Claudio Cambra --- src/gui/filedetails/FileDetailsPage.qml | 35 ++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/gui/filedetails/FileDetailsPage.qml b/src/gui/filedetails/FileDetailsPage.qml index 0014911ca3..d241618edb 100644 --- a/src/gui/filedetails/FileDetailsPage.qml +++ b/src/gui/filedetails/FileDetailsPage.qml @@ -53,7 +53,7 @@ Page { swipeView.currentIndex = fileActivityView.swipeIndex; break; case Systray.FileDetailsPage.Sharing: - swipeView.currentIndex = shareView.swipeIndex; + swipeView.currentIndex = shareViewLoader.swipeIndex; break; } } @@ -229,8 +229,9 @@ Page { NCTabButton { svgCustomColorSource: "image://svgimage-custom-color/share.svg" text: qsTr("Sharing") - checked: swipeView.currentIndex === shareView.swipeIndex - onClicked: swipeView.currentIndex = shareView.swipeIndex + checked: swipeView.currentIndex === shareViewLoader.swipeIndex + onClicked: swipeView.currentIndex = shareViewLoader.swipeIndex + visible: root.fileDetails.sharingAvailable } } } @@ -253,18 +254,28 @@ Page { iconSize: root.iconSize } - ShareView { - id: shareView + Loader { + id: shareViewLoader property int swipeIndex: SwipeView.index - accountState: root.accountState - localPath: root.localPath - fileDetails: root.fileDetails - horizontalPadding: root.intendedPadding - iconSize: root.iconSize - rootStackView: root.rootStackView - backgroundsVisible: root.backgroundsVisible + width: swipeView.width + height: swipeView.height + active: root.fileDetails.sharingAvailable + + sourceComponent: ShareView { + id: shareView + + anchors.fill: parent + + accountState: root.accountState + localPath: root.localPath + fileDetails: root.fileDetails + horizontalPadding: root.intendedPadding + iconSize: root.iconSize + rootStackView: root.rootStackView + backgroundsVisible: root.backgroundsVisible + } } } } From 3fda519050a9bc638b26307e8d25a45f1fc81eaf Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 13 Jul 2023 10:28:31 +0800 Subject: [PATCH 4/8] Do not handle setting page to sharing page if sharing not available Signed-off-by: Claudio Cambra --- src/gui/filedetails/FileDetailsPage.qml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/filedetails/FileDetailsPage.qml b/src/gui/filedetails/FileDetailsPage.qml index d241618edb..091892de95 100644 --- a/src/gui/filedetails/FileDetailsPage.qml +++ b/src/gui/filedetails/FileDetailsPage.qml @@ -47,7 +47,11 @@ Page { Connections { target: Systray function onShowFileDetailsPage(fileLocalPath, page) { - if(fileLocalPath === root.localPath) { + if (!root.fileDetails.sharingAvailable && page == Systray.FileDetailsPage.Sharing) { + return; + } + + if (fileLocalPath === root.localPath) { switch(page) { case Systray.FileDetailsPage.Activity: swipeView.currentIndex = fileActivityView.swipeIndex; From 98ec8ff3024e95701a1781d5b3709960821f1645 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 13 Jul 2023 10:36:27 +0800 Subject: [PATCH 5/8] Fix background of tabbar in file details page Signed-off-by: Claudio Cambra --- src/gui/filedetails/FileDetailsPage.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/filedetails/FileDetailsPage.qml b/src/gui/filedetails/FileDetailsPage.qml index 091892de95..0b62177867 100644 --- a/src/gui/filedetails/FileDetailsPage.qml +++ b/src/gui/filedetails/FileDetailsPage.qml @@ -222,6 +222,7 @@ Page { Layout.rightMargin: root.intendedPadding padding: 0 + background: null NCTabButton { svgCustomColorSource: "image://svgimage-custom-color/activity.svg" From bccdb0e8f7a47a78b06c30c77c08823e00d43f52 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 13 Jul 2023 12:41:51 +0800 Subject: [PATCH 6/8] Make swipeIndex properties readonly Signed-off-by: Claudio Cambra --- src/gui/filedetails/FileDetailsPage.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/filedetails/FileDetailsPage.qml b/src/gui/filedetails/FileDetailsPage.qml index 0b62177867..83a64e1a80 100644 --- a/src/gui/filedetails/FileDetailsPage.qml +++ b/src/gui/filedetails/FileDetailsPage.qml @@ -250,7 +250,7 @@ Page { FileActivityView { id: fileActivityView - property int swipeIndex: SwipeView.index + readonly property int swipeIndex: SwipeView.index delegateHorizontalPadding: root.intendedPadding @@ -262,7 +262,7 @@ Page { Loader { id: shareViewLoader - property int swipeIndex: SwipeView.index + readonly property int swipeIndex: SwipeView.index width: swipeView.width height: swipeView.height From c1b2e07e8cce7c96b01d5ed661f753bf43db3681 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 13 Jul 2023 12:42:06 +0800 Subject: [PATCH 7/8] Compress share page tab button width and height when sharing API is disabled Signed-off-by: Claudio Cambra --- src/gui/filedetails/FileDetailsPage.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/filedetails/FileDetailsPage.qml b/src/gui/filedetails/FileDetailsPage.qml index 83a64e1a80..2868ad67ba 100644 --- a/src/gui/filedetails/FileDetailsPage.qml +++ b/src/gui/filedetails/FileDetailsPage.qml @@ -232,6 +232,8 @@ Page { } NCTabButton { + width: visible ? implicitWidth : 0 + height: visible ? implicitHeight : 0 svgCustomColorSource: "image://svgimage-custom-color/share.svg" text: qsTr("Sharing") checked: swipeView.currentIndex === shareViewLoader.swipeIndex From d6125ca3a197d5d7d60f38ef982f1e4a75b332e5 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 18 Jul 2023 16:40:33 +0800 Subject: [PATCH 8/8] Swap folder nullness assert for return Signed-off-by: Claudio Cambra --- src/gui/filedetails/filedetails.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/filedetails/filedetails.cpp b/src/gui/filedetails/filedetails.cpp index 58c1854ea8..67ebb554ce 100644 --- a/src/gui/filedetails/filedetails.cpp +++ b/src/gui/filedetails/filedetails.cpp @@ -62,7 +62,11 @@ void FileDetails::setLocalPath(const QString &localPath) connect(&_fileWatcher, &QFileSystemWatcher::fileChanged, this, &FileDetails::refreshFileDetails); const auto folder = FolderMan::instance()->folderForPath(_localPath); - Q_ASSERT(folder); + if (!folder) { + qCWarning(lcFileDetails) << "No folder found for path:" << _localPath << "will not load file details."; + return; + } + const auto file = _localPath.mid(folder->cleanPath().length() + 1); if (!folder->journalDb()->getFileRecord(file, &_fileRecord)) {