From: Claudio Cambra Date: Mon, 7 Nov 2022 13:05:20 +0000 (+0100) Subject: Show file details within the tray dialog, rather than in a separate dialog X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~11^2~77^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d25ce28a1b8a85c1e271a994aa659f9b22fd877c;p=nextcloud-desktop.git Show file details within the tray dialog, rather than in a separate dialog Signed-off-by: Claudio Cambra --- diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index f9106ea8d..c45b870b0 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 e2d4d7388..99a18296d 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -102,6 +102,7 @@ signals: 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 09e847a78..6369b4f7c 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 f363bc5c3..a940a6858 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