diff --git a/src/controller.cpp b/src/controller.cpp index e3c037dd1..7ace239f2 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -97,8 +97,6 @@ Controller::Controller(QObject *parent) } #endif - connect(&m_accountRegistry, &AccountRegistry::accountCountChanged, this, &Controller::activeConnectionIndexChanged); - static int oldAccountCount = 0; connect(&m_accountRegistry, &AccountRegistry::accountCountChanged, this, [this]() { if (m_accountRegistry.size() > oldAccountCount) { @@ -165,15 +163,14 @@ void Controller::addConnection(NeoChatConnection *c) c->sync(); Q_EMIT connectionAdded(c); - Q_EMIT accountCountChanged(); } void Controller::dropConnection(NeoChatConnection *c) { Q_ASSERT_X(c, __FUNCTION__, "Attempt to drop a null connection"); + m_accountRegistry.drop(c); Q_EMIT connectionDropped(c); - Q_EMIT accountCountChanged(); } void Controller::invokeLogin() @@ -297,11 +294,6 @@ bool Controller::supportSystemTray() const #endif } -int Controller::accountCount() const -{ - return m_accountRegistry.count(); -} - void Controller::setQuitOnLastWindowClosed() { #ifndef Q_OS_ANDROID diff --git a/src/controller.h b/src/controller.h index 5cdfeee10..2f2a36bd3 100644 --- a/src/controller.h +++ b/src/controller.h @@ -41,11 +41,6 @@ class Controller : public QObject { Q_OBJECT - /** - * @brief The number of logged in accounts. - */ - Q_PROPERTY(int accountCount READ accountCount NOTIFY accountCountChanged) - /** * @brief The current connection for the rest of NeoChat to use. */ @@ -96,8 +91,6 @@ public: static Controller &instance(); - [[nodiscard]] int accountCount() const; - void setActiveConnection(NeoChatConnection *connection); [[nodiscard]] NeoChatConnection *activeConnection() const; @@ -215,7 +208,6 @@ Q_SIGNALS: void syncDone(); void connectionAdded(NeoChatConnection *connection); void connectionDropped(NeoChatConnection *connection); - void accountCountChanged(); void initiated(); void notificationClicked(const QString &_t1, const QString &_t2); void quitOnLastWindowClosedChanged(); diff --git a/src/qml/Menu/GlobalMenu.qml b/src/qml/Menu/GlobalMenu.qml index a81a69c35..f0fe6a5da 100644 --- a/src/qml/Menu/GlobalMenu.qml +++ b/src/qml/Menu/GlobalMenu.qml @@ -40,12 +40,12 @@ Labs.MenuBar { Labs.MenuItem { text: i18nc("menu", "New Private Chat…") - enabled: pageStack.layers.currentItem.title !== i18n("Start a Chat") && Controller.accountCount > 0 + enabled: pageStack.layers.currentItem.title !== i18n("Start a Chat") && AccountRegistry.accountCount > 0 onTriggered: pushReplaceLayer("qrc:/StartChatPage.qml", {connection: Controller.activeConnection}) } Labs.MenuItem { text: i18nc("menu", "New Group…") - enabled: pageStack.layers.currentItem.title !== i18n("Start a Chat") && Controller.accountCount > 0 + enabled: pageStack.layers.currentItem.title !== i18n("Start a Chat") && AccountRegistry.accountCount > 0 shortcut: StandardKey.New onTriggered: { const dialog = createRoomDialog.createObject(root.overlay) diff --git a/src/qml/Settings/AccountsPage.qml b/src/qml/Settings/AccountsPage.qml index 7a3d87d88..5c711de17 100644 --- a/src/qml/Settings/AccountsPage.qml +++ b/src/qml/Settings/AccountsPage.qml @@ -79,7 +79,7 @@ FormCard.FormCardPage { Dialog.ConfirmLogout { connection: model.connection onAccepted: { - if (Controller.accountCount === 1) { + if (AccountRegistry.accountCount === 1) { root.Window.window.close() } } diff --git a/src/qml/main.qml b/src/qml/main.qml index a32e12180..a5421c895 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -236,7 +236,7 @@ Kirigami.ApplicationWindow { target: Controller function onInitiated() { - if (Controller.accountCount === 0) { + if (AccountRegistry.accountCount === 0) { pageStack.replace("qrc:/WelcomePage.qml", {}); } else if (!roomListLoaded) { pageStack.replace(roomListComponent, {