From cd461628ab90af085d2fdb4ff462f0e48c376775 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Mon, 14 Nov 2022 02:30:06 +0100 Subject: [PATCH] Account switcher fixes, part 1 - Make account index notifyable - Give login window a title - Fix height of account list --- src/controller.cpp | 3 +++ src/controller.h | 3 ++- src/qml/Component/UserInfo.qml | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index 3368be4e0..18263a277 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -121,6 +121,8 @@ Controller::Controller(QObject *parent) } #endif + connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, &Controller::activeConnectionIndexChanged); + #ifdef QUOTIENT_07 static int oldAccountCount = 0; connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, [=]() { @@ -688,6 +690,7 @@ void Controller::setActiveConnection(Connection *connection) } NeoChatConfig::self()->save(); Q_EMIT activeConnectionChanged(); + Q_EMIT activeConnectionIndexChanged(); } void Controller::saveWindowGeometry() diff --git a/src/controller.h b/src/controller.h index 72f7f0946..38193a235 100644 --- a/src/controller.h +++ b/src/controller.h @@ -41,7 +41,7 @@ class Controller : public QObject Q_PROPERTY(bool hasWindowSystem READ hasWindowSystem CONSTANT) Q_PROPERTY(bool isOnline READ isOnline NOTIFY isOnlineChanged) Q_PROPERTY(bool encryptionSupported READ encryptionSupported CONSTANT) - Q_PROPERTY(int activeConnectionIndex READ activeConnectionIndex CONSTANT) + Q_PROPERTY(int activeConnectionIndex READ activeConnectionIndex NOTIFY activeConnectionIndexChanged) public: static Controller &instance(); @@ -154,6 +154,7 @@ Q_SIGNALS: void keyVerificationStart(); void keyVerificationAccept(const QString &commitment); void keyVerificationKey(const QString &sas); + void activeConnectionIndexChanged(); public Q_SLOTS: void logout(Quotient::Connection *conn, bool serverSideLogout); diff --git a/src/qml/Component/UserInfo.qml b/src/qml/Component/UserInfo.qml index 25b651f1b..3c5f967bb 100644 --- a/src/qml/Component/UserInfo.qml +++ b/src/qml/Component/UserInfo.qml @@ -58,7 +58,7 @@ QQC2.ToolBar { text: i18n("Add Account") subtitle: i18n("Log in to an existing account") onClicked: { - pageStack.pushDialogLayer("qrc:/WelcomePage.qml") + pageStack.pushDialogLayer("qrc:/WelcomePage.qml", {}, {title: i18nc("@title:window", "Login")}) userInfo.accountsListVisible = false accounts.currentIndex = Controller.activeConnectionIndex } @@ -100,7 +100,7 @@ QQC2.ToolBar { } width: parent.width - height: contentHeight + Layout.preferredHeight: contentHeight delegate: Kirigami.BasicListItem { leftPadding: topPadding leading: Kirigami.Avatar {