]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Fix server adress retreival in tray window buttons
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Fri, 3 Jan 2020 13:00:07 +0000 (14:00 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Fri, 3 Jan 2020 13:00:07 +0000 (14:00 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
src/gui/tray/UserModel.cpp
src/gui/tray/UserModel.h
src/gui/tray/Window.qml

index 9ee8ae42a7fe8fd95f4942ae453f805ecbfdf8b4..b7c6d5fc711e57b3af3d369e42b2cefeaf3a43bd 100644 (file)
@@ -57,14 +57,16 @@ QString User::name() const
     return name;
 }
 
-QString User::server() const
+QString User::server(bool shortened) const
 {
     QString serverUrl = _account->account()->url().toString();
-    serverUrl.replace(QLatin1String("https://"), QLatin1String(""));
-    serverUrl.replace(QLatin1String("http://"), QLatin1String(""));
-    if (serverUrl.size() > 21) {
-        serverUrl.truncate(19);
-        serverUrl.append("...");
+    if (shortened) {
+        serverUrl.replace(QLatin1String("https://"), QLatin1String(""));
+        serverUrl.replace(QLatin1String("http://"), QLatin1String(""));
+        if (serverUrl.size() > 21) {
+            serverUrl.truncate(19);
+            serverUrl.append("...");
+        }
     }
     return serverUrl;
 }
@@ -181,6 +183,24 @@ Q_INVOKABLE void UserModel::openCurrentAccountLocalFolder()
     _users[_currentUserId].openLocalFolder();
 }
 
+Q_INVOKABLE void UserModel::openCurrentAccountTalk()
+{
+    QString url = _users[_currentUserId].server(false) + "/apps/spreed";
+    if (!(url.contains("http://") || url.contains("https://"))) {
+        url = "https://" + _users[_currentUserId].server(false) + "/apps/spreed";
+    }
+    QDesktopServices::openUrl(QUrl(url));
+}
+
+Q_INVOKABLE void UserModel::openCurrentAccountServer()
+{
+    QString url = _users[_currentUserId].server(false);
+    if (! (url.contains("http://") || url.contains("https://")) ) {
+        url = "https://" + _users[_currentUserId].server(false);
+    }
+    QDesktopServices::openUrl(QUrl(url));
+}
+
 Q_INVOKABLE void UserModel::switchCurrentUser(const int &id)
 {
     _users[_currentUserId].setCurrentUser(false);
index f93d33d8de0a8b0123724aa9c87006bff58e6e43..4b5008ead19ae460885d40acfac722081d05b592 100644 (file)
@@ -26,7 +26,7 @@ public:
     ActivityListModel *getActivityModel();
     void openLocalFolder();
     QString name() const;
-    QString server() const;
+    QString server(bool shortened = true) const;
     bool serverHasTalk() const;
     QImage avatar() const;
     QString id() const;
@@ -54,6 +54,8 @@ public:
     QImage avatarById(const int &id);
 
     Q_INVOKABLE void openCurrentAccountLocalFolder();
+    Q_INVOKABLE void openCurrentAccountTalk();
+    Q_INVOKABLE void openCurrentAccountServer();
     Q_INVOKABLE QImage currentUserAvatar();
     Q_INVOKABLE int numUsers();
     Q_INVOKABLE bool isCurrentUserConnected();
index 0735d61613ac809eadcbd29944a85773c17d041f..37e8658e01bbf525f6c02d67a5a4d83d7c9723f0 100644 (file)
@@ -285,6 +285,7 @@ Window {
                         hoverEnabled: true\r
                         onClicked:\r
                         {\r
+                            userModelBackend.openCurrentAccountTalk();\r
                         }\r
                     }\r
 \r
@@ -302,7 +303,6 @@ Window {
                     Layout.preferredWidth: (trayWindowHeaderBackground.height)\r
                     Layout.preferredHeight: (trayWindowHeaderBackground.height)\r
                     flat: true\r
-                    visible: false\r
 \r
                     icon.source: "qrc:///client/theme/white/more-apps.svg"\r
                     icon.color: "transparent"\r
@@ -313,6 +313,7 @@ Window {
                         hoverEnabled: true\r
                         onClicked:\r
                         {\r
+                            userModelBackend.openCurrentAccountServer();\r
                         }\r
                     }\r
 \r