浏览代码

Implemented share functionality in tray window and changed actions / button logic.

Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Dominique Fuchs 5 年之前
父节点
当前提交
4bd5e9d79b
共有 6 个文件被更改,包括 68 次插入34 次删除
  1. 10 1
      src/gui/owncloudgui.cpp
  2. 1 0
      src/gui/systray.h
  3. 20 0
      src/gui/tray/ActivityListModel.cpp
  4. 1 0
      src/gui/tray/ActivityListModel.h
  5. 35 33
      src/gui/tray/Window.qml
  6. 1 0
      theme/Style/Style.qml

+ 10 - 1
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()

+ 1 - 0
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();

+ 20 - 0
src/gui/tray/ActivityListModel.cpp

@@ -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) {

+ 1 - 0
src/gui/tray/ActivityListModel.h

@@ -50,6 +50,7 @@ public:
     MessageRole,
     DisplayPathRole,
     PathRole,
+    AbsolutePathRole,
     LinkRole,
     PointInTimeRole,
     AccountConnectedRole,

+ 35 - 33
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)
                 }
             }
 

+ 1 - 0
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