From: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> Date: Sat, 25 Apr 2020 08:17:53 +0000 (+0200) Subject: Implemented share functionality in tray window and changed actions / button logic. X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~198^2~10 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4bd5e9d79b3669467fc6646095499d7b0e33959b;p=nextcloud-desktop.git Implemented share functionality in tray window and changed actions / button logic. Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> --- diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index d271059ab..bc340e542 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -89,6 +89,16 @@ ownCloudGui::ownCloudGui(Application *parent) connect(_tray.data(), &Systray::shutdown, this, &ownCloudGui::slotShutdown); + connect(_tray.data(), &Systray::openShareDialog, + this, [=](const QString &sharePath, const QString &localPath, const bool publicLink = false) + { + + if (publicLink) { + this->slotShowShareDialog(sharePath,localPath, ShareDialogStartPage::PublicLinks); + } else { + this->slotShowShareDialog(sharePath,localPath, ShareDialogStartPage::UsersAndGroups); + } + }); ProgressDispatcher *pd = ProgressDispatcher::instance(); connect(pd, &ProgressDispatcher::progressInfo, this, @@ -104,7 +114,6 @@ ownCloudGui::ownCloudGui(Application *parent) this, &ownCloudGui::slotShowOptionalTrayMessage); connect(Logger::instance(), &Logger::guiMessage, this, &ownCloudGui::slotShowGuiMessage); - } void ownCloudGui::createTray() diff --git a/src/gui/systray.h b/src/gui/systray.h index 8af3b5352..2710be568 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -69,6 +69,7 @@ signals: Q_INVOKABLE void hideWindow(); Q_INVOKABLE void showWindow(); + Q_INVOKABLE void openShareDialog(const QString &sharepath, const QString &localPath); public slots: void slotNewUserSelected(); diff --git a/src/gui/tray/ActivityListModel.cpp b/src/gui/tray/ActivityListModel.cpp index 1562b77a6..14381cbe9 100644 --- a/src/gui/tray/ActivityListModel.cpp +++ b/src/gui/tray/ActivityListModel.cpp @@ -45,6 +45,7 @@ QHash ActivityListModel::roleNames() const QHash roles; roles[DisplayPathRole] = "displaypath"; roles[PathRole] = "path"; + roles[AbsolutePathRole] = "abspath"; roles[LinkRole] = "link"; roles[MessageRole] = "message"; roles[ActionRole] = "type"; @@ -107,6 +108,25 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const } } return QString(); + case AbsolutePathRole: { + auto folder = FolderMan::instance()->folder(a._folder); + QString relPath(a._file); + if (!a._file.isEmpty()) { + if (folder) { + relPath.prepend(folder->remotePath()); + } + list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account()); + if (list.count() > 0) { + return QString(list.at(0)); + } else { + qWarning("File not local folders while processing absolute path request."); + return QString(); + } + } else { + qWarning("Received an absolute path request for an activity without a file path."); + return QString(); + } + } case ActionsLinksRole: { QList customList; foreach (ActivityLink customItem, a._links) { diff --git a/src/gui/tray/ActivityListModel.h b/src/gui/tray/ActivityListModel.h index 37a766907..8f6fba4e2 100644 --- a/src/gui/tray/ActivityListModel.h +++ b/src/gui/tray/ActivityListModel.h @@ -50,6 +50,7 @@ public: MessageRole, DisplayPathRole, PathRole, + AbsolutePathRole, LinkRole, PointInTimeRole, AccountConnectedRole, diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index e3f3ed1fc..1761ccf5f 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -554,22 +554,41 @@ Window { height: Style.trayWindowHeaderHeight spacing: 0 + MouseArea { + enabled: (path !== "") ? true : false + anchors.left: activityItem.left + anchors.right: ((shareButton.visible) ? shareButton.left : activityItem.right) + height: parent.height + anchors.margins: 2 + hoverEnabled: true + onClicked: Qt.openUrlExternally(path) + ToolTip.visible: hovered + ToolTip.delay: 1000 + ToolTip.text: qsTr("Open sync item locally") + Rectangle { + anchors.fill: parent + color: (parent.containsMouse ? Style.lightHover : "transparent") + } + } + Image { id: activityIcon - - Layout.leftMargin: 8 - Layout.rightMargin: 8 - Layout.preferredWidth: activityButton1.icon.width - Layout.preferredHeight: activityButton1.icon.height + anchors.left: activityItem.left + anchors.leftMargin: 8 + anchors.rightMargin: 8 + Layout.preferredWidth: shareButton.icon.width + Layout.preferredHeight: shareButton.icon.height verticalAlignment: Qt.AlignCenter cache: true source: icon sourceSize.height: 64 sourceSize.width: 64 } + Column { id: activityTextColumn - + anchors.left: activityIcon.right + anchors.leftMargin: 8 spacing: 4 Layout.alignment: Qt.AlignLeft Text { @@ -583,7 +602,7 @@ Window { Text { id: activityTextInfo - text: (type === "Activity" || type === "File" || type === "Sync") ? displaypath : message + text: (type === "Activity" || type === "Sync") ? displaypath : ((type === "File") ? subject : message) height: (text === "") ? 0 : activityTextTitle.height width: Style.activityLabelBaseWidth + ((path === "") ? activityItem.height : 0) + ((link === "") ? activityItem.height : 0) - 8 elide: Text.ElideRight @@ -600,43 +619,26 @@ Window { color: "#808080" } } - Item { - id: activityItemFiller - Layout.fillWidth: true - } Button { - id: activityButton1 + id: shareButton + anchors.right: activityItem.right Layout.preferredWidth: (path === "") ? 0 : parent.height Layout.preferredHeight: parent.height Layout.alignment: Qt.AlignRight flat: true - hoverEnabled: false + hoverEnabled: true visible: (path === "") ? false : true display: AbstractButton.IconOnly - icon.source: "qrc:///client/theme/files.svg" - icon.color: "transparent" - - onClicked: { - Qt.openUrlExternally(path) - } - } - Button { - id: activityButton2 - - Layout.preferredWidth: (link === "") ? 0 : parent.height - Layout.preferredHeight: parent.height - Layout.alignment: Qt.AlignRight - flat: true - hoverEnabled: false - visible: (link === "") ? false : true - display: AbstractButton.IconOnly icon.source: "qrc:///client/theme/public.svg" icon.color: "transparent" - - onClicked: { - Qt.openUrlExternally(link) + background: Rectangle { + color: parent.hovered ? Style.lightHover : "transparent" } + ToolTip.visible: hovered + ToolTip.delay: 1000 + ToolTip.text: qsTr("Open share dialog") + onClicked: systrayBackend.openShareDialog(displaypath,abspath) } } diff --git a/theme/Style/Style.qml b/theme/Style/Style.qml index 9d848bb07..5c173a917 100644 --- a/theme/Style/Style.qml +++ b/theme/Style/Style.qml @@ -7,6 +7,7 @@ QtObject { // Colors property color ncBlue: "#0082c9" property color ncBlueHover: "#009dd9" + property color lightHover: "#f7f7f7" // Fonts // We are using pixel size because this is cross platform comparable, point size isn't