Connected AccountWizard with new account action in tray menu, minor fixes
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Wed, 4 Dec 2019 13:19:23 +0000 (14:19 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Wed, 4 Dec 2019 13:19:23 +0000 (14:19 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
src/gui/owncloudgui.cpp
src/gui/tray/UserLine.qml
src/gui/tray/UserModel.cpp
src/gui/tray/UserModel.h
src/gui/tray/window.qml

index 3d328403cf0d199628f930336b753fb0dc181477..7823fe75f90c631acf694d51a68dedd9b02cdb0e 100644 (file)
@@ -119,6 +119,8 @@ ownCloudGui::ownCloudGui(Application *parent)
         this, &ownCloudGui::slotLogin);
     connect(UserModel::instance(), &UserModel::logout,
         this, &ownCloudGui::slotLogout);
+    connect(UserModel::instance(), &UserModel::addAccount,
+        this, &ownCloudGui::slotNewAccountWizard);
 }
 
 #ifdef WITH_LIBCLOUDPROVIDERS
index 3b6ff0b0f6670131090da09bb1ab095b2cbd9148..ffc9884864c9403bfed30e4f1e0c506110c337d6 100644 (file)
@@ -23,7 +23,7 @@ MenuItem {
             anchors.fill: parent
 
             Button {
-                id: currentAccountButton
+                id: accountButton
                 Layout.preferredWidth: 220
                 Layout.preferredHeight: (userLineBackground.height)
                 display: AbstractButton.IconOnly
@@ -31,7 +31,9 @@ MenuItem {
 
                 MouseArea {
                     id: accountBtnMouseArea
-                    anchors.fill: parent
+                    anchors.centerIn: parent
+                    Layout.preferredWidth: (accountButton.width - 4)
+                    Layout.preferredHeight: (accountButton.height - 4)
                     hoverEnabled: true
                     onClicked:
                     {
@@ -41,11 +43,11 @@ MenuItem {
 
                 RowLayout {
                     id: accountControlRowLayout
-                    height: currentAccountButton.height
-                    width: currentAccountButton.width
+                    height: accountButton.height
+                    width: accountButton.width
                     spacing: 0
                     Image {
-                        id: currentAccountAvatar
+                        id: accountAvatar
                         Layout.leftMargin: 6
                         verticalAlignment: Qt.AlignCenter
                         source: avatar
@@ -59,14 +61,14 @@ MenuItem {
                         Layout.alignment: Qt.AlignLeft
                         Layout.leftMargin: 12
                         Label {
-                            id: currentAccountUser
+                            id: accountUser
                             text: name
                             color: "black"
                             font.pointSize: 9
                             font.bold: true
                         }
                         Label {
-                            id: currentAccountServer
+                            id: accountServer
                             text: server
                             color: "black"
                             font.pointSize: 8
index aec5287c493dc21f3a171b966ac50f0b72d621f4..36709b31620eb131ed0929739b91833e94e91421 100644 (file)
@@ -14,7 +14,15 @@ User::User(const AccountStatePtr &account)
 QString User::name() const
 {
     // If davDisplayName is empty (can be several reasons, simplest is missing login at startup), fall back to username
-    return (_account->account()->davDisplayName() == "") ? _account->account()->credentials()->user() : _account->account()->davDisplayName();
+    QString name = _account->account()->davDisplayName();
+    if (name == "") {
+        name = _account->account()->credentials()->user();
+    }
+    if (name.size() > 19) {
+        name.truncate(17);
+        name.append("...");
+    }
+    return name;
 }
 
 QString User::server() const
@@ -22,6 +30,10 @@ QString User::server() const
     QString serverUrl = _account->account()->url().toString();
     serverUrl.replace(QLatin1String("https://"), QLatin1String(""));
     serverUrl.replace(QLatin1String("http://"), QLatin1String(""));
+    if (serverUrl.size() > 24) {
+        serverUrl.truncate(22);
+        serverUrl.append("...");
+    }
     return serverUrl;
 }
 
@@ -55,17 +67,6 @@ bool User::isConnected() const
     return (_account->connectionStatus() == AccountState::ConnectionStatus::Connected);
 }
 
-void User::login()
-{
-    _account->account()->resetRejectedCertificates();
-    _account->signIn();
-}
-
-void User::logout()
-{
-    _account->signOutByUi();
-}
-
 /*-------------------------------------------------------------------------------------*/
 
 UserModel* UserModel::_instance = nullptr;
index f2fb8f16daf1c88a351c8f8868fa0b9909e8a320..8e299690e3eafc2e354463a11e5ee9e68579d539 100644 (file)
@@ -40,9 +40,6 @@ public:
 
     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
-   
-    Q_INVOKABLE void logout();
-
     Q_INVOKABLE int numUsers();
     Q_INVOKABLE bool isCurrentUserConnected();
     Q_INVOKABLE QString currentUserAvatar();
@@ -58,6 +55,8 @@ public:
 signals:
     Q_INVOKABLE void login();
     Q_INVOKABLE void logout();
+    Q_INVOKABLE void addAccount();
+    Q_INVOKABLE void removeAccount();
 
 protected:
     QHash<int, QByteArray> roleNames() const;
index 7c9add790e8a7e41f8407fdef9fb73c3c6e53617..a6532af2ed286bc3164cf95025350aec55c362a7 100644 (file)
@@ -73,7 +73,7 @@ Window {
 
                             background: Rectangle {
                                 border.color: "#0082c9"
-                                radius: 4
+                                radius: 2
                             }
 
                             Instantiator {
@@ -91,8 +91,14 @@ Window {
                                             ? systrayBackend.logout()
                                             : systrayBackend.login() )
                             }
-                            MenuItem { text: "Add Account" }
-                            MenuItem { text: "Remove Account" }
+                            MenuItem {
+                                text: "Add Account"
+                                onClicked: systrayBackend.addAccount()
+                            }
+                            MenuItem {
+                                text: "Remove Account"
+                                onClicked: systrayBackend.removeAccount()
+                            }
 
                             Component.onCompleted: {
                                 if(systrayBackend.numUsers() === 0) {