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);
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
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
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
}\r
Label {\r
id: accountServer\r
- width: 120\r
+ width: 128\r
text: server\r
elide: Text.ElideRight\r
color: "black"\r
}\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
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
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);
bool hasActivities() const;
QImage avatar() const;
QString id() const;
+ void login() const;
+ void logout() const;
private:
AccountStatePtr _account;
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();
};
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();
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
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