Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show file details within the tray dialog, rather than in a separate dialog #5139

Merged
merged 5 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions src/gui/filedetails/FileDetailsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import "../tray"
Page {
id: root

signal closeButtonClicked

property var accountState: ({})
property string localPath: ""

Expand All @@ -34,6 +36,8 @@ Page {
property int intendedPadding: Style.standardSpacing * 2
property int iconSize: 32
property StackView rootStackView: StackView {}
property bool showCloseButton: false
property bool backgroundsVisible: true

property FileDetails fileDetails: FileDetails {
id: fileDetails
Expand Down Expand Up @@ -61,6 +65,7 @@ Page {

background: Rectangle {
color: Style.backgroundColor
visible: root.backgroundsVisible
}

header: ColumnLayout {
Expand All @@ -70,11 +75,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
Expand All @@ -100,19 +106,37 @@ Page {
id: fileNameLabel

Layout.fillWidth: true
Layout.rightMargin: root.intendedPadding
Layout.rightMargin: headerGridLayout.textRightMargin

text: root.fileDetails.name
color: Style.ncTextColor
font.bold: true
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
Expand All @@ -123,7 +147,7 @@ Page {
id: fileLockedLabel

Layout.fillWidth: true
Layout.rightMargin: root.intendedPadding
Layout.rightMargin: headerGridLayout.textRightMargin

text: root.fileDetails.lockExpireString
color: Style.ncSecondaryTextColor
Expand Down Expand Up @@ -188,6 +212,7 @@ Page {
horizontalPadding: root.intendedPadding
iconSize: root.iconSize
rootStackView: root.rootStackView
backgroundsVisible: root.backgroundsVisible
}
}
}
18 changes: 14 additions & 4 deletions src/gui/filedetails/FileDetailsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
2 changes: 2 additions & 0 deletions src/gui/filedetails/ShareDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -221,6 +222,7 @@ GridLayout {

width: parent.width
height: parent.height
backgroundsVisible: root.backgroundsVisible

fileDetails: root.fileDetails
shareModelData: model
Expand Down
3 changes: 3 additions & 0 deletions src/gui/filedetails/ShareDetailsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Page {
signal setPassword(string password)
signal setNote(string note)

property bool backgroundsVisible: true

property FileDetails fileDetails: FileDetails {}
property var shareModelData: ({})

Expand Down Expand Up @@ -177,6 +179,7 @@ Page {

background: Rectangle {
color: Style.backgroundColor
visible: root.backgroundsVisible
}

header: ColumnLayout {
Expand Down
2 changes: 2 additions & 0 deletions src/gui/filedetails/ShareView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -225,6 +226,7 @@ ColumnLayout {
iconSize: root.iconSize
fileDetails: root.fileDetails
rootStackView: root.rootStackView
backgroundsVisible: root.backgroundsVisible
canCreateLinkShares: root.publicLinkSharingPossible

onCreateNewLinkShare: {
Expand Down
12 changes: 12 additions & 0 deletions src/gui/systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions src/gui/systray.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions src/gui/tray/ActivityItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ ItemDelegate {

activityData: model

onShareButtonClicked: Systray.createShareDialog(model.openablePath)

onDismissButtonClicked: activityModel.slotTriggerDismiss(model.activityIndex)
}

Expand Down
11 changes: 0 additions & 11 deletions src/gui/tray/ActivityItemActions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,6 @@ RowLayout {
moreActionsButtonContextMenu.close();
}
}

ActivityItemContextMenu {
id: moreActionsButtonContextMenu

maxActionButtons: root.maxActionButtons
linksContextMenu: root.linksContextMenu

onMenuEntryTriggered: function(entryIndex) {
root.triggerAction(entryIndex)
}
}
}
}
}
21 changes: 9 additions & 12 deletions src/gui/tray/ActivityItemContent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -195,20 +194,18 @@ RowLayout {
}

CustomButton {
id: shareButton
id: fileDetailsButton
claucambra marked this conversation as resolved.
Show resolved Hide resolved

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)
}
}
65 changes: 65 additions & 0 deletions src/gui/tray/Window.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,6 +78,7 @@ ApplicationWindow {

function onIsOpenChanged() {
userStatusDrawer.close()
fileDetailsDrawer.close();

if(Systray.isOpen) {
accountMenu.close();
Expand All @@ -88,6 +91,10 @@ ApplicationWindow {
newErrorDialog.text = error
newErrorDialog.open()
}

function onShowFileDetails(accountState, localPath, fileDetailsPage) {
fileDetailsDrawer.openFileDetails(accountState, localPath, fileDetailsPage);
}
}

OpacityMask {
Expand Down Expand Up @@ -140,6 +147,64 @@ ApplicationWindow {
}
}

Drawer {
id: fileDetailsDrawer
width: parent.width - Style.trayDrawerMargin
height: parent.height
padding: 0
edge: Qt.RightEdge
modal: true
visible: false
clip: true

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}`);
claucambra marked this conversation as resolved.
Show resolved Hide resolved
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: FileDetailsView {
id: fileDetails

width: parent.width
height: parent.height

backgroundsVisible: false
accountState: fileDetailsDrawer.folderAccountState
localPath: fileDetailsDrawer.fileLocalPath
showCloseButton: true

onCloseButtonClicked: fileDetailsDrawer.close()
}
}
}

Item {
id: trayWindowMainItem

Expand Down
Loading