Implemented share functionality in tray window and changed actions / button logic.
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sat, 25 Apr 2020 08:17:53 +0000 (10:17 +0200)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sat, 25 Apr 2020 08:17:53 +0000 (10:17 +0200)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
src/gui/owncloudgui.cpp
src/gui/systray.h
src/gui/tray/ActivityListModel.cpp
src/gui/tray/ActivityListModel.h
src/gui/tray/Window.qml
theme/Style/Style.qml

index d271059ab01861f27cca1eaa7db2d147ffc9ae88..bc340e54225a2c4b80ddfde7f2c8c99d28baace9 100644 (file)
@@ -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()
index 8af3b5352a420906ab603972e6d10dbba28477aa..2710be568f50821f66a126908db926bac2574e90 100644 (file)
@@ -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();
index 1562b77a622772d35c5bfb6470a794ef91fb2c3c..14381cbe91f008e6da76c98b86e0c12a5837de6a 100644 (file)
@@ -45,6 +45,7 @@ QHash<int, QByteArray> ActivityListModel::roleNames() const
     QHash<int, QByteArray> 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<QVariant> customList;
         foreach (ActivityLink customItem, a._links) {
index 37a766907fb29ed08085faeca8cb70aafcfc5190..8f6fba4e2b778cad87c453ee85da69e2d4efaaf0 100644 (file)
@@ -50,6 +50,7 @@ public:
     MessageRole,
     DisplayPathRole,
     PathRole,
+    AbsolutePathRole,
     LinkRole,
     PointInTimeRole,
     AccountConnectedRole,
index e3f3ed1fc4c4dced4194620808003cd5b92beb63..1761ccf5fffe30c4a89141023c69f14dc7dfec6e 100644 (file)
@@ -554,22 +554,41 @@ Window {
                 height: Style.trayWindowHeaderHeight\r
                 spacing: 0\r
 \r
+                MouseArea {\r
+                    enabled: (path !== "") ? true : false\r
+                    anchors.left: activityItem.left\r
+                    anchors.right: ((shareButton.visible) ? shareButton.left : activityItem.right)\r
+                    height: parent.height\r
+                    anchors.margins: 2\r
+                    hoverEnabled: true\r
+                    onClicked: Qt.openUrlExternally(path)\r
+                    ToolTip.visible: hovered\r
+                    ToolTip.delay: 1000\r
+                    ToolTip.text: qsTr("Open sync item locally")\r
+                    Rectangle {\r
+                        anchors.fill: parent\r
+                        color: (parent.containsMouse ? Style.lightHover : "transparent")\r
+                    }\r
+                }\r
+\r
                 Image {\r
                     id: activityIcon\r
-\r
-                    Layout.leftMargin: 8\r
-                    Layout.rightMargin: 8\r
-                    Layout.preferredWidth: activityButton1.icon.width\r
-                    Layout.preferredHeight: activityButton1.icon.height\r
+                    anchors.left: activityItem.left\r
+                    anchors.leftMargin: 8\r
+                    anchors.rightMargin: 8\r
+                    Layout.preferredWidth: shareButton.icon.width\r
+                    Layout.preferredHeight: shareButton.icon.height\r
                     verticalAlignment: Qt.AlignCenter\r
                     cache: true\r
                     source: icon\r
                     sourceSize.height: 64\r
                     sourceSize.width: 64\r
                 }\r
+\r
                 Column {\r
                     id: activityTextColumn\r
-\r
+                    anchors.left: activityIcon.right\r
+                    anchors.leftMargin: 8\r
                     spacing: 4\r
                     Layout.alignment: Qt.AlignLeft\r
                     Text {\r
@@ -583,7 +602,7 @@ Window {
 \r
                     Text {\r
                         id: activityTextInfo\r
-                        text: (type === "Activity" || type === "File" || type === "Sync") ? displaypath : message\r
+                        text: (type === "Activity" || type === "Sync") ? displaypath : ((type === "File") ? subject : message)\r
                         height: (text === "") ? 0 : activityTextTitle.height\r
                         width: Style.activityLabelBaseWidth + ((path === "") ? activityItem.height : 0) + ((link === "") ? activityItem.height : 0) - 8\r
                         elide: Text.ElideRight\r
@@ -600,43 +619,26 @@ Window {
                         color: "#808080"\r
                     }\r
                 }\r
-                Item {\r
-                    id: activityItemFiller\r
-                    Layout.fillWidth: true\r
-                }\r
                 Button {\r
-                    id: activityButton1\r
+                    id: shareButton\r
+                    anchors.right: activityItem.right\r
 \r
                     Layout.preferredWidth: (path === "") ? 0 : parent.height\r
                     Layout.preferredHeight: parent.height\r
                     Layout.alignment: Qt.AlignRight\r
                     flat: true\r
-                    hoverEnabled: false\r
+                    hoverEnabled: true\r
                     visible: (path === "") ? false : true\r
                     display: AbstractButton.IconOnly\r
-                    icon.source: "qrc:///client/theme/files.svg"\r
-                    icon.color: "transparent"\r
-\r
-                    onClicked: {\r
-                         Qt.openUrlExternally(path)\r
-                    }\r
-                }\r
-                Button {\r
-                    id: activityButton2\r
-\r
-                    Layout.preferredWidth: (link === "") ? 0 : parent.height\r
-                    Layout.preferredHeight:  parent.height\r
-                    Layout.alignment: Qt.AlignRight\r
-                    flat: true\r
-                    hoverEnabled: false\r
-                    visible: (link === "") ? false : true\r
-                    display: AbstractButton.IconOnly\r
                     icon.source: "qrc:///client/theme/public.svg"\r
                     icon.color: "transparent"\r
-\r
-                    onClicked: {\r
-                        Qt.openUrlExternally(link)\r
+                    background: Rectangle {\r
+                        color: parent.hovered ? Style.lightHover : "transparent"\r
                     }\r
+                    ToolTip.visible: hovered\r
+                    ToolTip.delay: 1000\r
+                    ToolTip.text: qsTr("Open share dialog")\r
+                    onClicked: systrayBackend.openShareDialog(displaypath,abspath)\r
                 }\r
             }\r
 \r
index 9d848bb078a6ecc90102688e5977be5e4cb4f2f3..5c173a9175fdaccf8ad73d05c77f095dc6b8caab 100644 (file)
@@ -7,6 +7,7 @@ QtObject {
     // Colors\r
     property color ncBlue:      "#0082c9"\r
     property color ncBlueHover: "#009dd9"\r
+    property color lightHover:  "#f7f7f7"\r
 \r
     // Fonts\r
     // We are using pixel size because this is cross platform comparable, point size isn't\r