diff --git a/src/controller.cpp b/src/controller.cpp index 190177646..ab6d6676e 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -346,7 +346,6 @@ void Controller::setActiveConnection(NeoChatConnection *connection) } NeoChatConfig::self()->save(); Q_EMIT activeConnectionChanged(); - Q_EMIT activeConnectionIndexChanged(); } void Controller::saveWindowGeometry() @@ -407,14 +406,6 @@ void Controller::setApplicationProxy() QNetworkProxy::setApplicationProxy(proxy); } -int Controller::activeConnectionIndex() const -{ - auto result = std::find_if(m_accountRegistry.accounts().begin(), m_accountRegistry.accounts().end(), [this](const auto &it) { - return it == m_connection; - }); - return result - m_accountRegistry.accounts().begin(); -} - bool Controller::isFlatpak() const { #ifdef NEOCHAT_FLATPAK diff --git a/src/controller.h b/src/controller.h index 00b711fde..63ee1a6c6 100644 --- a/src/controller.h +++ b/src/controller.h @@ -46,11 +46,6 @@ class Controller : public QObject */ Q_PROPERTY(NeoChatConnection *activeConnection READ activeConnection WRITE setActiveConnection NOTIFY activeConnectionChanged) - /** - * @brief The row number in the accounts directory of the active connection. - */ - Q_PROPERTY(int activeConnectionIndex READ activeConnectionIndex NOTIFY activeConnectionIndexChanged) - /** * @brief Whether the OS NeoChat is running on supports sytem tray icons. */ @@ -99,8 +94,6 @@ public: */ void dropConnection(NeoChatConnection *c); - int activeConnectionIndex() const; - /** * @brief Save an access token to the keychain for the given account. */ @@ -169,7 +162,6 @@ Q_SIGNALS: void passwordStatus(Controller::PasswordStatus status); void userConsentRequired(QUrl url); void isOnlineChanged(bool isOnline); - void activeConnectionIndexChanged(); public Q_SLOTS: void saveWindowGeometry(); diff --git a/src/qml/UserInfo.qml b/src/qml/UserInfo.qml index 4b18e6772..0a66d822f 100644 --- a/src/qml/UserInfo.qml +++ b/src/qml/UserInfo.qml @@ -160,8 +160,6 @@ RowLayout { id: accounts implicitHeight: contentHeight - currentIndex: Controller.activeConnectionIndex - header: Kirigami.Separator {} footer: Delegates.RoundedItemDelegate { @@ -227,6 +225,15 @@ RowLayout { } } + onVisibleChanged: { + for (let i = 0; i < accounts.count; i++) { + if (model.data(model.index(i, 0), Qt.DisplayRole) === root.connection.localUser.id) { + accounts.currentIndex = i; + break; + } + } + } + delegate: Delegates.RoundedItemDelegate { id: userDelegate