From 1c2916052d4ab9e4645443fda70d7aa4c94c412f Mon Sep 17 00:00:00 2001 From: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> Date: Sun, 12 Jan 2020 17:52:51 +0100 Subject: [PATCH] Bunch of fixes and optimizations for activityList Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> --- src/gui/accountsettings.cpp | 4 ++++ src/gui/systray.cpp | 6 +----- src/gui/systray.h | 2 +- src/gui/tray/UserLine.qml | 6 +++++- src/gui/tray/Window.qml | 8 ++++---- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 604abace1c..c28096b968 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -192,6 +192,10 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) connect(_accountState, &AccountState::stateChanged, this, &AccountSettings::slotAccountStateChanged); slotAccountStateChanged(); + if (!AccountManager::instance()->accounts().isEmpty()) { + Systray::instance()->slotChangeActivityModel(); + } + connect(&_quotaInfo, &QuotaInfo::quotaUpdated, this, &AccountSettings::slotUpdateQuota); diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index a241e5fc28..f26ad8717d 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -61,10 +61,6 @@ Systray::Systray() _trayComponent = new QQmlComponent(_trayEngine, QUrl(QStringLiteral("qrc:/qml/src/gui/tray/Window.qml"))); - if (!AccountManager::instance()->accounts().isEmpty()) { - slotChangeActivityModel(); - } - connect(UserModel::instance(), &UserModel::newUserSelected, this, &Systray::slotChangeActivityModel); @@ -83,7 +79,7 @@ void Systray::create() void Systray::slotChangeActivityModel() { _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel()); - emit currentUserChanged(); + //UserModel::instance()->currentActivityModel()->slotRefreshActivity(); } bool Systray::isOpen() diff --git a/src/gui/systray.h b/src/gui/systray.h index 60a44a3f91..7125c10902 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -69,7 +69,7 @@ signals: Q_INVOKABLE void hideWindow(); Q_INVOKABLE void showWindow(); -private slots: +public slots: void slotChangeActivityModel(); private: diff --git a/src/gui/tray/UserLine.qml b/src/gui/tray/UserLine.qml index 6d41fc7d94..700951fefd 100644 --- a/src/gui/tray/UserLine.qml +++ b/src/gui/tray/UserLine.qml @@ -25,7 +25,11 @@ MenuItem { } onClicked: { - userModelBackend.switchCurrentUser(index) + if (!isCurrentUser) { + userModelBackend.switchCurrentUser(id) + } else { + accountMenu.close() + } } RowLayout { diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index a909476157..1cc2dd542d 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -31,6 +31,10 @@ Window { currentAccountStateIndicator.source = "" currentAccountStateIndicator.source = userModelBackend.isUserConnected(userModelBackend.currentUserId()) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg" + if (userModelBackend.isUserConnected(userModelBackend.currentUserId())) { + systrayBackend.slotChangeActivityModel() + } + userLineInstantiator.active = false; userLineInstantiator.active = true; } @@ -535,10 +539,6 @@ Window { } focus: true - - // For interactive ListView/Animation testing only - //Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) - //Keys.onTabPressed: model.remove(3) } } // Rectangle trayWindowBackground