mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 14:36:01 +03:00
connected UserModel login/logout signals, minor fixes
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
parent
4e0997dbdf
commit
3a0ccf3697
5 changed files with 29 additions and 22 deletions
|
@ -89,6 +89,9 @@ private:
|
|||
// Adds an account to the tracked list, emitting accountAdded()
|
||||
void addAccountState(AccountState *accountState);
|
||||
|
||||
AccountManager() {}
|
||||
QList<AccountStatePtr> _accounts;
|
||||
|
||||
public slots:
|
||||
/// Saves account data, not including the credentials
|
||||
void saveAccount(Account *a);
|
||||
|
@ -104,9 +107,5 @@ Q_SIGNALS:
|
|||
void accountAdded(AccountState *account);
|
||||
void accountRemoved(AccountState *account);
|
||||
void removeAccountFolders(AccountState *account);
|
||||
|
||||
private:
|
||||
AccountManager() {}
|
||||
QList<AccountStatePtr> _accounts;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -113,6 +113,12 @@ 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
|
||||
|
|
|
@ -43,7 +43,7 @@ Systray::Systray() // TODO: make singleton, provide ::instance()
|
|||
QQmlComponent systray(engine, QUrl(QStringLiteral("qrc:/qml/src/gui/tray/init.qml")));
|
||||
_trayContext = engine->contextForObject(systray.create());
|
||||
|
||||
_accountMenuModel = new UserModel();
|
||||
_accountMenuModel = UserModel::instance();
|
||||
systray.engine()->rootContext()->setContextProperty("systrayBackend", _accountMenuModel);
|
||||
|
||||
// TODO: hack to pass the icon to QML
|
||||
|
|
|
@ -68,6 +68,16 @@ void User::logout()
|
|||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
|
||||
UserModel* UserModel::_instance = nullptr;
|
||||
|
||||
UserModel *UserModel::instance()
|
||||
{
|
||||
if (_instance == nullptr) {
|
||||
_instance = new UserModel();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
UserModel::UserModel(QObject *parent)
|
||||
: QAbstractListModel()
|
||||
, _currentUser(nullptr)
|
||||
|
@ -88,20 +98,6 @@ UserModel::UserModel(QObject *parent)
|
|||
}
|
||||
}
|
||||
|
||||
UserModel::~UserModel()
|
||||
{
|
||||
}
|
||||
|
||||
Q_INVOKABLE void UserModel::login()
|
||||
{
|
||||
_currentUser->login();
|
||||
}
|
||||
|
||||
Q_INVOKABLE void UserModel::logout()
|
||||
{
|
||||
_currentUser->logout();
|
||||
}
|
||||
|
||||
Q_INVOKABLE int UserModel::numUsers()
|
||||
{
|
||||
auto test = _users.size();
|
||||
|
|
|
@ -30,8 +30,8 @@ class UserModel : public QAbstractListModel
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UserModel(QObject *parent = 0);
|
||||
virtual ~UserModel();
|
||||
static UserModel *instance();
|
||||
virtual ~UserModel() {};
|
||||
|
||||
void addUser(const User &user);
|
||||
void addCurrentUser(const User &user);
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
|
||||
Q_INVOKABLE void login();
|
||||
|
||||
Q_INVOKABLE void logout();
|
||||
|
||||
Q_INVOKABLE int numUsers();
|
||||
|
@ -55,10 +55,16 @@ public:
|
|||
AvatarRole
|
||||
};
|
||||
|
||||
signals:
|
||||
Q_INVOKABLE void login();
|
||||
Q_INVOKABLE void logout();
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
|
||||
private:
|
||||
static UserModel *_instance;
|
||||
UserModel(QObject *parent = 0);
|
||||
QList<User> _users;
|
||||
User *_currentUser;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue