_addAccountAction = new QAction(tr("Add new"), this);
menu->addAction(_addAccountAction);
+
connect(_addAccountAction, &QAction::triggered, this, &AccountSettings::slotOpenAccountWizard);
+ connect(UserModel::instance(), &UserModel::addAccount,
+ this, &AccountSettings::slotOpenAccountWizard);
_toggleSignInOutAction = new QAction(tr("Log out"), this);
connect(_toggleSignInOutAction, &QAction::triggered, this, &AccountSettings::slotToggleSignInState);
QAction *action = new QAction(tr("Remove"), this);
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::slotLogin);
connect(UserModel::instance(), &UserModel::logout,
this, &ownCloudGui::slotLogout);
- connect(UserModel::instance(), &UserModel::addAccount,
- this, &ownCloudGui::slotNewAccountWizard);
}
#ifdef WITH_LIBCLOUDPROVIDERS
id: userLine
visible: true
- width: 220
+ width: 216
height: 60
//color: "transparent"
Button {
id: accountButton
- Layout.preferredWidth: 220
- Layout.preferredHeight: (userLineBackground.height)
+ anchors.centerIn: parent
+ Layout.preferredWidth: (userLine.width - 4)
+ Layout.preferredHeight: (userLineBackground.height - 2)
display: AbstractButton.IconOnly
flat: true
- MouseArea {
- id: accountBtnMouseArea
- anchors.centerIn: parent
- Layout.preferredWidth: (accountButton.width - 4)
- Layout.preferredHeight: (accountButton.height - 4)
- hoverEnabled: true
- onClicked:
- {
- //
- }
+ background: Rectangle {
+ color: "transparent"
+ }
+
+ onClicked: {
+ systrayBackend.switchUser(index)
}
RowLayout {
/*-------------------------------------------------------------------------------------*/
-UserModel* UserModel::_instance = nullptr;
+UserModel *UserModel::_instance = nullptr;
UserModel *UserModel::instance()
{
return;
}
+ refreshUserList();
+}
+
+void UserModel::refreshUserList()
+{
for (int i = 0; i < AccountManager::instance()->accounts().size(); i++) {
auto user = AccountManager::instance()->accounts().at(i);
- if (user->account()->id() != _currentUser->id()) {
+ if ((user->account()->id() != _currentUser->id())) {
addUser(user);
}
}
return _currentUser->server();
}
+Q_INVOKABLE void UserModel::switchUser(const int id)
+{
+ addCurrentUser(_users.at(id));
+ refreshUserList();
+ emit refreshCurrentUserGui();
+}
+
void UserModel::addUser(const User &user)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
Q_INVOKABLE QString currentUserAvatar();
Q_INVOKABLE QString currentUserName();
Q_INVOKABLE QString currentUserServer();
+ Q_INVOKABLE void switchUser(const int id);
enum UserRoles {
NameRole = Qt::UserRole + 1,
Q_INVOKABLE void addAccount();
Q_INVOKABLE void removeAccount();
+ Q_INVOKABLE void refreshCurrentUserGui();
+
protected:
QHash<int, QByteArray> roleNames() const;
UserModel(QObject *parent = 0);
QList<User> _users;
User *_currentUser;
+
+ void refreshUserList();
};
}
//setY(Screen.desktopAvailableHeight + height);
}
+ Connections {
+ target: systrayBackend
+ onRefreshCurrentUserGui: {
+ currentAccountAvatar.source = systrayBackend.currentUserAvatar()
+ currentAccountUser.text = systrayBackend.currentUserName()
+ currentAccountServer.text = systrayBackend.currentUserServer()
+ }
+ }
+
Rectangle {
id: trayWindowBackground
anchors.fill: parent
}
}
- /*Item {
- Layout.preferredWidth: 6
- }*/
-
Image {
Layout.alignment: Qt.AlignLeft
verticalAlignment: Qt.AlignCenter