From d25ce28a1b8a85c1e271a994aa659f9b22fd877c Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 7 Nov 2022 14:05:20 +0100 Subject: [PATCH 1/5] Show file details within the tray dialog, rather than in a separate dialog Signed-off-by: Claudio Cambra --- src/gui/systray.cpp | 12 +++++ src/gui/systray.h | 3 ++ src/gui/tray/ActivityItem.qml | 2 +- src/gui/tray/Window.qml | 93 +++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 1 deletion(-) diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index f9106ea8d6939..c45b870b09cb9 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -382,6 +382,18 @@ void Systray::createFileActivityDialog(const QString &localPath) Q_EMIT showFileDetailsPage(localPath, FileDetailsPage::Activity); } +void Systray::presentShareViewInTray(const QString &localPath) +{ + const auto folder = FolderMan::instance()->folderForPath(localPath); + if (!folder) { + qCWarning(lcSystray) << "Could not open file details view in tray for" << localPath << "no responsible folder found"; + return; + } + qCDebug(lcSystray) << "Opening file details view in tray for " << localPath; + + Q_EMIT showFileDetails(folder->accountState(), localPath, FileDetailsPage::Sharing); +} + void Systray::slotCurrentUserChanged() { if (_trayEngine) { diff --git a/src/gui/systray.h b/src/gui/systray.h index e2d4d738820aa..99a18296dff1c 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -102,6 +102,7 @@ class Systray void shutdown(); void showFileDetailsPage(const QString &fileLocalPath, const OCC::Systray::FileDetailsPage page); + void showFileDetails(AccountState *accountState, const QString &localPath, const OCC::Systray::FileDetailsPage fileDetailsPage); void sendChatMessage(const QString &token, const QString &message, const QString &replyTo); void showErrorMessageDialog(const QString &error); @@ -141,6 +142,8 @@ public slots: void createShareDialog(const QString &localPath); void createFileActivityDialog(const QString &localPath); + void presentShareViewInTray(const QString &localPath); + private slots: void slotUnpauseAllFolders(); void slotPauseAllFolders(); diff --git a/src/gui/tray/ActivityItem.qml b/src/gui/tray/ActivityItem.qml index 09e847a78a198..6369b4f7c71f4 100644 --- a/src/gui/tray/ActivityItem.qml +++ b/src/gui/tray/ActivityItem.qml @@ -51,7 +51,7 @@ ItemDelegate { activityData: model - onShareButtonClicked: Systray.createShareDialog(model.openablePath) + onShareButtonClicked: Systray.presentShareViewInTray(model.openablePath) onDismissButtonClicked: activityModel.slotTriggerDismiss(model.activityIndex) } diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index f363bc5c31b8b..a940a6858d689 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -4,7 +4,9 @@ import QtQuick.Controls 2.3 import QtQuick.Layouts 1.2 import QtGraphicalEffects 1.0 import Qt.labs.platform 1.1 as NativeDialogs + import "../" +import "../filedetails/" // Custom qml modules are in /theme (and included by resources.qrc) import Style 1.0 @@ -76,6 +78,7 @@ ApplicationWindow { function onIsOpenChanged() { userStatusDrawer.close() + fileDetailsDrawer.close(); if(Systray.isOpen) { accountMenu.close(); @@ -88,6 +91,10 @@ ApplicationWindow { newErrorDialog.text = error newErrorDialog.open() } + + function onShowFileDetails(accountState, localPath, fileDetailsPage) { + fileDetailsDrawer.openFileDetails(accountState, localPath, fileDetailsPage); + } } OpacityMask { @@ -140,6 +147,92 @@ ApplicationWindow { } } + Drawer { + id: fileDetailsDrawer + width: parent.width + height: parent.height + padding: 0 + edge: Qt.RightEdge + modal: false + visible: false + + background: Rectangle { + radius: Systray.useNormalWindow ? 0.0 : Style.trayWindowRadius + border.width: Style.trayWindowBorderWidth + border.color: Style.menuBorder + color: Style.backgroundColor + } + + property var folderAccountState: ({}) + property string fileLocalPath: "" + property var pageToShow: Systray.FileDetailsPage.Activity + + function openFileDetails(accountState, localPath, fileDetailsPage) { + console.log(`About to show file details view in tray for ${localPath}`); + folderAccountState = accountState; + fileLocalPath = localPath; + pageToShow = fileDetailsPage; + + if(!opened) { + open(); + } + } + + Loader { + id: fileDetailsContents + anchors.fill: parent + active: fileDetailsDrawer.visible + onActiveChanged: { + if (active) { + Systray.showFileDetailsPage(fileDetailsDrawer.fileLocalPath, + fileDetailsDrawer.pageToShow); + } + } + sourceComponent: ColumnLayout { + anchors.fill: parent + + FileDetailsPage { + id: fileDetails + + Layout.fillWidth: true + Layout.fillHeight: true + + background: null + accountState: fileDetailsDrawer.folderAccountState + localPath: fileDetailsDrawer.fileLocalPath + } + + CustomButton { + FontMetrics { + id: doneButtonFm + font: parent.contentsFont + } + + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + Layout.topMargin: fileDetails.intendedPadding + Layout.bottomMargin: fileDetails.intendedPadding + Layout.leftMargin: fileDetails.intendedPadding + Layout.rightMargin: fileDetails.intendedPadding + Layout.preferredWidth: doneButtonFm.boundingRect(text).width + + leftPadding + + rightPadding + + Style.standardSpacing * 2 + + text: qsTr("Done") + contentsFont.bold: true + bgColor: Style.currentUserHeaderColor + textColor: Style.adjustedCurrentUserHeaderColor + textColorHovered: Style.currentUserHeaderTextColor + onClicked: fileDetailsDrawer.close() + + Accessible.role: Accessible.Button + Accessible.name: qsTr("Close the file details view") + Accessible.onPressAction: clicked() + } + } + } + } + Item { id: trayWindowMainItem From ca74c2b27fbc755cbbbd78846dc43a96fad0f23e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 9 Nov 2022 12:21:07 +0100 Subject: [PATCH 2/5] Make drawer modal, reduce width Signed-off-by: Claudio Cambra --- src/gui/tray/Window.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index a940a6858d689..331cb69c91e0e 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -149,11 +149,11 @@ ApplicationWindow { Drawer { id: fileDetailsDrawer - width: parent.width + width: parent.width - Style.trayDrawerMargin height: parent.height padding: 0 edge: Qt.RightEdge - modal: false + modal: true visible: false background: Rectangle { From a16fc9ffcc63e2df823826dd4a8ee1edfa569944 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 9 Nov 2022 12:50:33 +0100 Subject: [PATCH 3/5] Replace drawer 'Done' button at bottom-right with close button at top-right Signed-off-by: Claudio Cambra --- src/gui/filedetails/FileDetailsPage.qml | 30 +++++++++++++--- src/gui/tray/Window.qml | 46 +++++-------------------- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/gui/filedetails/FileDetailsPage.qml b/src/gui/filedetails/FileDetailsPage.qml index 85eb57c3fff3a..3147bbd648286 100644 --- a/src/gui/filedetails/FileDetailsPage.qml +++ b/src/gui/filedetails/FileDetailsPage.qml @@ -23,6 +23,8 @@ import "../tray" Page { id: root + signal closeButtonClicked + property var accountState: ({}) property string localPath: "" @@ -34,6 +36,7 @@ Page { property int intendedPadding: Style.standardSpacing * 2 property int iconSize: 32 property StackView rootStackView: StackView {} + property bool showCloseButton: false property FileDetails fileDetails: FileDetails { id: fileDetails @@ -70,11 +73,12 @@ Page { id: headerGridLayout readonly property bool showFileLockedString: root.fileDetails.lockExpireString !== "" + readonly property int textRightMargin: root.showCloseButton ? root.intendedPadding : 0 Layout.fillWidth: parent Layout.topMargin: root.topPadding - columns: 2 + columns: root.showCloseButton ? 3 : 2 rows: showFileLockedString ? 3 : 2 rowSpacing: Style.standardSpacing / 2 @@ -100,7 +104,7 @@ Page { id: fileNameLabel Layout.fillWidth: true - Layout.rightMargin: root.intendedPadding + Layout.rightMargin: headerGridLayout.textRightMargin text: root.fileDetails.name color: Style.ncTextColor @@ -108,11 +112,29 @@ Page { wrapMode: Text.Wrap } + CustomButton { + id: closeButton + + Layout.rowSpan: headerGridLayout.rows + Layout.preferredWidth: Style.iconButtonWidth + Layout.preferredHeight: width + Layout.rightMargin: headerGridLayout.textRightMargin + + imageSource: "image://svgimage-custom-color/clear.svg" + "/" + Style.ncTextColor + bgColor: Style.lightHover + bgNormalOpacity: 0 + toolTipText: qsTr("Dismiss") + + visible: root.showCloseButton + + onClicked: root.closeButtonClicked() + } + EnforcedPlainTextLabel { id: fileDetailsLabel Layout.fillWidth: true - Layout.rightMargin: root.intendedPadding + Layout.rightMargin: headerGridLayout.textRightMargin text: `${root.fileDetails.sizeString} ยท ${root.fileDetails.lastChangedString}` color: Style.ncSecondaryTextColor @@ -123,7 +145,7 @@ Page { id: fileLockedLabel Layout.fillWidth: true - Layout.rightMargin: root.intendedPadding + Layout.rightMargin: headerGridLayout.textRightMargin text: root.fileDetails.lockExpireString color: Style.ncSecondaryTextColor diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index 331cb69c91e0e..a084efa74ffb6 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -188,47 +188,17 @@ ApplicationWindow { fileDetailsDrawer.pageToShow); } } - sourceComponent: ColumnLayout { - anchors.fill: parent - - FileDetailsPage { - id: fileDetails - - Layout.fillWidth: true - Layout.fillHeight: true - - background: null - accountState: fileDetailsDrawer.folderAccountState - localPath: fileDetailsDrawer.fileLocalPath - } + sourceComponent:FileDetailsPage { + id: fileDetails - CustomButton { - FontMetrics { - id: doneButtonFm - font: parent.contentsFont - } + anchors.fill: parent - Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - Layout.topMargin: fileDetails.intendedPadding - Layout.bottomMargin: fileDetails.intendedPadding - Layout.leftMargin: fileDetails.intendedPadding - Layout.rightMargin: fileDetails.intendedPadding - Layout.preferredWidth: doneButtonFm.boundingRect(text).width + - leftPadding + - rightPadding + - Style.standardSpacing * 2 - - text: qsTr("Done") - contentsFont.bold: true - bgColor: Style.currentUserHeaderColor - textColor: Style.adjustedCurrentUserHeaderColor - textColorHovered: Style.currentUserHeaderTextColor - onClicked: fileDetailsDrawer.close() + background: null + accountState: fileDetailsDrawer.folderAccountState + localPath: fileDetailsDrawer.fileLocalPath + showCloseButton: true - Accessible.role: Accessible.Button - Accessible.name: qsTr("Close the file details view") - Accessible.onPressAction: clicked() - } + onCloseButtonClicked: fileDetailsDrawer.close() } } } From 373a0017746eee7386c5fae80ae4bee536b231ad Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 9 Nov 2022 13:10:59 +0100 Subject: [PATCH 4/5] Replace share button with file details button Signed-off-by: Claudio Cambra --- src/gui/tray/ActivityItem.qml | 2 -- src/gui/tray/ActivityItemActions.qml | 11 ----------- src/gui/tray/ActivityItemContent.qml | 21 +++++++++------------ src/gui/tray/Window.qml | 5 +++-- src/gui/tray/activitylistmodel.cpp | 4 ++-- src/gui/tray/activitylistmodel.h | 2 +- 6 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/gui/tray/ActivityItem.qml b/src/gui/tray/ActivityItem.qml index 6369b4f7c71f4..ebbac6e5a24ca 100644 --- a/src/gui/tray/ActivityItem.qml +++ b/src/gui/tray/ActivityItem.qml @@ -51,8 +51,6 @@ ItemDelegate { activityData: model - onShareButtonClicked: Systray.presentShareViewInTray(model.openablePath) - onDismissButtonClicked: activityModel.slotTriggerDismiss(model.activityIndex) } diff --git a/src/gui/tray/ActivityItemActions.qml b/src/gui/tray/ActivityItemActions.qml index 1b7ffc4f9b58b..908aab9d6b372 100644 --- a/src/gui/tray/ActivityItemActions.qml +++ b/src/gui/tray/ActivityItemActions.qml @@ -89,17 +89,6 @@ RowLayout { moreActionsButtonContextMenu.close(); } } - - ActivityItemContextMenu { - id: moreActionsButtonContextMenu - - maxActionButtons: root.maxActionButtons - linksContextMenu: root.linksContextMenu - - onMenuEntryTriggered: function(entryIndex) { - root.triggerAction(entryIndex) - } - } } } } diff --git a/src/gui/tray/ActivityItemContent.qml b/src/gui/tray/ActivityItemContent.qml index 6a049ca9dc7e4..88caedaea48c6 100644 --- a/src/gui/tray/ActivityItemContent.qml +++ b/src/gui/tray/ActivityItemContent.qml @@ -15,12 +15,11 @@ RowLayout { property bool showDismissButton: false - property bool childHovered: shareButton.hovered || dismissActionButton.hovered + property bool childHovered: fileDetailsButton.hovered || dismissActionButton.hovered property int iconSize: Style.trayListItemIconSize signal dismissButtonClicked() - signal shareButtonClicked() spacing: Style.trayHorizontalMargin @@ -182,7 +181,7 @@ RowLayout { Layout.preferredWidth: Style.trayListItemIconSize Layout.preferredHeight: Style.trayListItemIconSize - visible: root.showDismissButton && !shareButton.visible + visible: root.showDismissButton && !fileDetailsButton.visible imageSource: "image://svgimage-custom-color/clear.svg" + "/" + Style.ncTextColor imageSourceHover: "image://svgimage-custom-color/clear.svg" + "/" + UserModel.currentUser.headerTextColor @@ -195,20 +194,18 @@ RowLayout { } CustomButton { - id: shareButton + id: fileDetailsButton Layout.preferredWidth: Style.trayListItemIconSize Layout.preferredHeight: Style.trayListItemIconSize - visible: root.activityData.isShareable - - imageSource: "image://svgimage-custom-color/share.svg" + "/" + Style.adjustedCurrentUserHeaderColor - imageSourceHover: "image://svgimage-custom-color/share.svg" + "/" + Style.currentUserHeaderTextColor - - toolTipText: qsTr("Open share dialog") - + imageSource: "image://svgimage-custom-color/more.svg" + "/" + Style.adjustedCurrentUserHeaderColor + imageSourceHover: "image://svgimage-custom-color/more.svg" + "/" + Style.currentUserHeaderTextColor + toolTipText: qsTr("Open file details") bgColor: Style.currentUserHeaderColor - onClicked: root.shareButtonClicked() + visible: model.showFileDetails + + onClicked: Systray.presentShareViewInTray(model.openablePath) } } diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index a084efa74ffb6..fdf96a64f5e64 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -188,10 +188,11 @@ ApplicationWindow { fileDetailsDrawer.pageToShow); } } - sourceComponent:FileDetailsPage { + sourceComponent: FileDetailsPage { id: fileDetails - anchors.fill: parent + width: parent.width + height: parent.height background: null accountState: fileDetailsDrawer.folderAccountState diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index 352f23a559e28..5e16645d6a75e 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -76,7 +76,7 @@ QHash ActivityListModel::roleNames() const roles[ObjectNameRole] = "objectName"; roles[PointInTimeRole] = "dateTime"; roles[DisplayActions] = "displayActions"; - roles[ShareableRole] = "isShareable"; + roles[ShowFileDetailsRole] = "showFileDetails"; roles[IsCurrentUserFileActivityRole] = "isCurrentUserFileActivity"; roles[IsCurrentUserFileActivityRole] = "isCurrentUserFileActivity"; roles[ThumbnailRole] = "thumbnail"; @@ -342,7 +342,7 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const return (ast && ast->isConnected()); case DisplayActions: return _displayActions; - case ShareableRole: + case ShowFileDetailsRole: return !data(index, PathRole).toString().isEmpty() && a._objectType == QStringLiteral("files") && _displayActions && diff --git a/src/gui/tray/activitylistmodel.h b/src/gui/tray/activitylistmodel.h index 3ec5955557683..17f1557db9fcd 100644 --- a/src/gui/tray/activitylistmodel.h +++ b/src/gui/tray/activitylistmodel.h @@ -65,7 +65,7 @@ class ActivityListModel : public QAbstractListModel PointInTimeRole, AccountConnectedRole, DisplayActions, - ShareableRole, + ShowFileDetailsRole, IsCurrentUserFileActivityRole, ThumbnailRole, TalkNotificationConversationTokenRole, From 5930fb4ac912d33ba431a017cef103c9cf8cbc6c Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 9 Dec 2022 13:42:29 +0100 Subject: [PATCH 5/5] Adapt changes from share details page changes Signed-off-by: Claudio Cambra --- src/gui/filedetails/FileDetailsPage.qml | 3 +++ src/gui/filedetails/FileDetailsView.qml | 18 ++++++++++++++---- src/gui/filedetails/ShareDelegate.qml | 2 ++ src/gui/filedetails/ShareDetailsPage.qml | 3 +++ src/gui/filedetails/ShareView.qml | 2 ++ src/gui/tray/Window.qml | 5 +++-- 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/gui/filedetails/FileDetailsPage.qml b/src/gui/filedetails/FileDetailsPage.qml index 3147bbd648286..ead5cd075c0c1 100644 --- a/src/gui/filedetails/FileDetailsPage.qml +++ b/src/gui/filedetails/FileDetailsPage.qml @@ -37,6 +37,7 @@ Page { property int iconSize: 32 property StackView rootStackView: StackView {} property bool showCloseButton: false + property bool backgroundsVisible: true property FileDetails fileDetails: FileDetails { id: fileDetails @@ -64,6 +65,7 @@ Page { background: Rectangle { color: Style.backgroundColor + visible: root.backgroundsVisible } header: ColumnLayout { @@ -210,6 +212,7 @@ Page { horizontalPadding: root.intendedPadding iconSize: root.iconSize rootStackView: root.rootStackView + backgroundsVisible: root.backgroundsVisible } } } diff --git a/src/gui/filedetails/FileDetailsView.qml b/src/gui/filedetails/FileDetailsView.qml index 8c9edbaf5a817..de5fec16e399a 100644 --- a/src/gui/filedetails/FileDetailsView.qml +++ b/src/gui/filedetails/FileDetailsView.qml @@ -22,14 +22,24 @@ import Style 1.0 StackView { id: root - property var accountState: ({}) - property string localPath: "" + signal closeButtonClicked + + property alias accountState: fileDetailsPage.accountState + property alias localPath: fileDetailsPage.localPath + property alias showCloseButton: fileDetailsPage.showCloseButton + property bool backgroundsVisible: true + + background: Rectangle { + color: Style.backgroundColor + visible: root.backgroundsVisible + } initialItem: FileDetailsPage { + id: fileDetailsPage width: parent.width height: parent.height - accountState: root.accountState - localPath: root.localPath + backgroundsVisible: root.backgroundsVisible rootStackView: root + onCloseButtonClicked: root.closeButtonClicked() } } diff --git a/src/gui/filedetails/ShareDelegate.qml b/src/gui/filedetails/ShareDelegate.qml index 2f0f324056830..5768cc44de347 100644 --- a/src/gui/filedetails/ShareDelegate.qml +++ b/src/gui/filedetails/ShareDelegate.qml @@ -47,6 +47,7 @@ GridLayout { property int iconSize: 32 property FileDetails fileDetails: FileDetails {} property StackView rootStackView: StackView {} + property bool backgroundsVisible: true property bool canCreateLinkShares: true @@ -221,6 +222,7 @@ GridLayout { width: parent.width height: parent.height + backgroundsVisible: root.backgroundsVisible fileDetails: root.fileDetails shareModelData: model diff --git a/src/gui/filedetails/ShareDetailsPage.qml b/src/gui/filedetails/ShareDetailsPage.qml index 3b52cac308b56..9c5618fece24c 100644 --- a/src/gui/filedetails/ShareDetailsPage.qml +++ b/src/gui/filedetails/ShareDetailsPage.qml @@ -41,6 +41,8 @@ Page { signal setPassword(string password) signal setNote(string note) + property bool backgroundsVisible: true + property FileDetails fileDetails: FileDetails {} property var shareModelData: ({}) @@ -177,6 +179,7 @@ Page { background: Rectangle { color: Style.backgroundColor + visible: root.backgroundsVisible } header: ColumnLayout { diff --git a/src/gui/filedetails/ShareView.qml b/src/gui/filedetails/ShareView.qml index 8bc90ba66ad83..e2cb0d658d912 100644 --- a/src/gui/filedetails/ShareView.qml +++ b/src/gui/filedetails/ShareView.qml @@ -30,6 +30,7 @@ ColumnLayout { property FileDetails fileDetails: FileDetails {} property int horizontalPadding: 0 property int iconSize: 32 + property bool backgroundsVisible: true readonly property bool sharingPossible: shareModel && shareModel.canShare && shareModel.sharingEnabled readonly property bool userGroupSharingPossible: sharingPossible && shareModel.userGroupSharingEnabled @@ -225,6 +226,7 @@ ColumnLayout { iconSize: root.iconSize fileDetails: root.fileDetails rootStackView: root.rootStackView + backgroundsVisible: root.backgroundsVisible canCreateLinkShares: root.publicLinkSharingPossible onCreateNewLinkShare: { diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index fdf96a64f5e64..356479f30bbef 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -155,6 +155,7 @@ ApplicationWindow { edge: Qt.RightEdge modal: true visible: false + clip: true background: Rectangle { radius: Systray.useNormalWindow ? 0.0 : Style.trayWindowRadius @@ -188,13 +189,13 @@ ApplicationWindow { fileDetailsDrawer.pageToShow); } } - sourceComponent: FileDetailsPage { + sourceComponent: FileDetailsView { id: fileDetails width: parent.width height: parent.height - background: null + backgroundsVisible: false accountState: fileDetailsDrawer.folderAccountState localPath: fileDetailsDrawer.fileLocalPath showCloseButton: true