UserLine drafting, bugfixes, restuctures
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Fri, 10 Jan 2020 15:28:53 +0000 (16:28 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Fri, 10 Jan 2020 15:28:53 +0000 (16:28 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
src/gui/accountsettings.cpp
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 a7fd0f5a17732808ed73c5eb2ecc290b35b46d45..604abace1c51f7f34a093667c4debf3400a25226 100644 (file)
@@ -232,8 +232,6 @@ void AccountSettings::createAccountToolbox()
     menu->addAction(action);
 
     connect(action, &QAction::triggered, this, &AccountSettings::slotDeleteAccount);
-    connect(UserModel::instance(), &UserModel::removeAccount,
-        this, &AccountSettings::slotOpenAccountWizard);
 
     _ui->_accountToolbox->setText(tr("Account") + QLatin1Char(' '));
     _ui->_accountToolbox->setMenu(menu);
index 54dd1faac0c72d4c17d8697a4df9dcc1d43191a3..96718c22946c338c0c2cda5b91c6e69b72604a38 100644 (file)
@@ -110,12 +110,6 @@ ownCloudGui::ownCloudGui(Application *parent)
         this, &ownCloudGui::slotShowOptionalTrayMessage);
     connect(Logger::instance(), &Logger::guiMessage,
         this, &ownCloudGui::slotShowGuiMessage);
-
-
-    connect(UserModel::instance(), &UserModel::login,
-        this, &ownCloudGui::slotLogin);
-    connect(UserModel::instance(), &UserModel::logout,
-        this, &ownCloudGui::slotLogout);
 }
 
 #ifdef WITH_LIBCLOUDPROVIDERS
index be8a63775f4e9998183e8ac84f5e9e0e30437149..aeabdfea5f935b7e1e705eb48627b8d6b0fdcf04 100644 (file)
@@ -4,33 +4,19 @@ import QtQuick.Controls 2.2
 import QtQuick.Layouts 1.2\r
 \r
 MenuItem {\r
-\r
-    Connections {\r
-        target: userModelBackend\r
-        onRefreshUserMenu: {\r
-        }\r
-    }\r
-\r
     id: userLine\r
-    width: 220\r
     height: 60\r
 \r
-    Rectangle {\r
-        id: userLineBackground\r
-        height: userLine.height\r
-        anchors.fill: parent\r
-        color: "transparent"\r
-\r
         RowLayout {\r
             id: userLineLayout\r
             spacing: 0\r
-            anchors.fill: parent\r
+            width: 220\r
+            height: 60\r
 \r
             Button {\r
                 id: accountButton\r
-                anchors.centerIn: parent\r
-                Layout.preferredWidth: (userLine.width - 4)\r
-                Layout.preferredHeight: (userLineBackground.height - 2)\r
+                Layout.preferredWidth: (userLineLayout.width * (5/6))\r
+                Layout.preferredHeight: (userLineLayout.height)\r
                 display: AbstractButton.IconOnly\r
                 flat: true\r
 \r
@@ -49,21 +35,22 @@ MenuItem {
                     spacing: 0\r
                     Image {\r
                         id: accountAvatar\r
-                        Layout.leftMargin: 2\r
+                        Layout.leftMargin: 4\r
                         verticalAlignment: Qt.AlignCenter\r
+                        cache: false\r
                         source: ("image://avatars/" + index)\r
-                        Layout.preferredHeight: (userLineBackground.height -16)\r
-                        Layout.preferredWidth: (userLineBackground.height -16)\r
+                        Layout.preferredHeight: (userLineLayout.height -16)\r
+                        Layout.preferredWidth: (userLineLayout.height -16)\r
                     }\r
 \r
                     Column {\r
                         id: accountLabels\r
                         spacing: 4\r
                         Layout.alignment: Qt.AlignLeft\r
-                        Layout.leftMargin: 12\r
+                        Layout.leftMargin: 6\r
                         Label {\r
                             id: accountUser\r
-                            width: 120\r
+                            width: 128\r
                             text: name\r
                             elide: Text.ElideRight\r
                             color: "black"\r
@@ -72,7 +59,7 @@ MenuItem {
                         }\r
                         Label {\r
                             id: accountServer\r
-                            width: 120\r
+                            width: 128\r
                             text: server\r
                             elide: Text.ElideRight\r
                             color: "black"\r
@@ -81,6 +68,51 @@ MenuItem {
                     }\r
                 }\r
             } // accountButton\r
+\r
+            Button {\r
+                id: userMoreButton\r
+                Layout.preferredWidth: (userLineLayout.width * (1/6))\r
+                Layout.preferredHeight: userLineLayout.height\r
+                flat: true\r
+\r
+                icon.source: "qrc:///client/resources/more.svg"\r
+                icon.color: "transparent"\r
+\r
+                MouseArea {\r
+                    id: userMoreButtonMouseArea\r
+                    anchors.fill: parent\r
+                    hoverEnabled: true\r
+                    onClicked:\r
+                    {\r
+                        userMoreButtonMenu.popup()\r
+                    }\r
+                }\r
+                background:\r
+                    Rectangle {\r
+                    color: userMoreButtonMouseArea.containsMouse ? "grey" : "transparent"\r
+                    opacity: 0.2\r
+                }\r
+\r
+                Menu {\r
+                    id: userMoreButtonMenu\r
+                    width: 100\r
+\r
+                    background: Rectangle {\r
+                        border.color: "#0082c9"\r
+                        radius: 2\r
+                    }\r
+\r
+                    MenuItem {\r
+                        text: userModelBackend.isCurrentUserConnected() ? "Log out" : "Log in"\r
+                        onClicked: {\r
+                            userModelBackend.isCurrentUserConnected() ? userModelBackend.logout(index) : userModelBackend.logout(index)\r
+                        }\r
+                    }\r
+\r
+                    MenuItem {\r
+                        text: "Remove Account"\r
+                    }\r
+                }\r
+            }\r
         }\r
-    }   // Rectangle userLineBackground\r
 }   // MenuItem userLine\r
index 22b49396bcfb5bf16b98c10544e13feccafee55b..1c285d0e10e6f90e4446c0df4bec5470fa3762df 100644 (file)
@@ -43,6 +43,16 @@ void User::openLocalFolder()
     QDesktopServices::openUrl(this->getFolder()->path());
 }
 
+void User::login() const
+{
+    _account->signIn();
+}
+
+void User::logout() const
+{
+    _account->signOutByUi();
+}
+
 QString User::name() const
 {
     // If davDisplayName is empty (can be several reasons, simplest is missing login at startup), fall back to username
@@ -208,6 +218,20 @@ Q_INVOKABLE void UserModel::switchCurrentUser(const int &id)
     emit refreshCurrentUserGui();
 }
 
+Q_INVOKABLE void UserModel::login(const int &id) {
+    _users[id].login();
+}
+
+Q_INVOKABLE void UserModel::logout(const int &id)
+{
+    _users[id].logout();
+}
+
+Q_INVOKABLE void UserModel::removeAccount(const int &id)
+{
+    _users[id].logout();
+}
+
 int UserModel::rowCount(const QModelIndex &parent) const
 {
     Q_UNUSED(parent);
index d68c2bc9bbc34db837dfc581f50df4a6c3434238..fc6f63989498634c96108c4b37f79e513d13a270 100644 (file)
@@ -31,6 +31,8 @@ public:
     bool hasActivities() const;
     QImage avatar() const;
     QString id() const;
+    void login() const;
+    void logout() const;
 
 private:
     AccountStatePtr _account;
@@ -65,6 +67,9 @@ public:
     Q_INVOKABLE bool currentUserHasActivities();
     Q_INVOKABLE bool currentServerHasTalk();
     Q_INVOKABLE void switchCurrentUser(const int &id);
+    Q_INVOKABLE void login(const int &id);
+    Q_INVOKABLE void logout(const int &id);
+    Q_INVOKABLE void removeAccount(const int &id);
 
     ActivityListModel *currentActivityModel();
 
@@ -76,11 +81,7 @@ public:
     };
 
 signals:
-    Q_INVOKABLE void login();
-    Q_INVOKABLE void logout();
     Q_INVOKABLE void addAccount();
-    Q_INVOKABLE void removeAccount();
-
     Q_INVOKABLE void refreshCurrentUserGui();
     Q_INVOKABLE void newUserSelected();
     Q_INVOKABLE void refreshUserMenu();
index 2e918319dfc73300fd1e6f9c6e7f59b085208a98..9c54a46511b74cfa4f98e23a5c516a5762395691 100644 (file)
@@ -108,7 +108,7 @@ Window {
                             id: accountMenu\r
                             x: (currentAccountButton.x + 2)\r
                             y: (currentAccountButton.y + currentAccountButton.height + 2)\r
-                            width: (currentAccountButton.width)\r
+                            width: (currentAccountButton.width - 2)\r
                             closePolicy: "CloseOnPressOutside"\r
 \r
                             background: Rectangle {\r
@@ -116,7 +116,13 @@ Window {
                                 radius: 2\r
                             }\r
 \r
+                            onClosed: {\r
+                                userLineInstantiator.active = false;\r
+                                userLineInstantiator.active = true;\r
+                            }\r
+\r
                             Instantiator {\r
+                                id: userLineInstantiator\r
                                 model: userModelBackend\r
                                 delegate: UserLine {}\r
                                 onObjectAdded: accountMenu.insertItem(index, object)\r