Remove Controller::accountCount in favor of AccountRegistry::accountCount
This commit is contained in:
@@ -97,8 +97,6 @@ Controller::Controller(QObject *parent)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connect(&m_accountRegistry, &AccountRegistry::accountCountChanged, this, &Controller::activeConnectionIndexChanged);
|
|
||||||
|
|
||||||
static int oldAccountCount = 0;
|
static int oldAccountCount = 0;
|
||||||
connect(&m_accountRegistry, &AccountRegistry::accountCountChanged, this, [this]() {
|
connect(&m_accountRegistry, &AccountRegistry::accountCountChanged, this, [this]() {
|
||||||
if (m_accountRegistry.size() > oldAccountCount) {
|
if (m_accountRegistry.size() > oldAccountCount) {
|
||||||
@@ -165,15 +163,14 @@ void Controller::addConnection(NeoChatConnection *c)
|
|||||||
c->sync();
|
c->sync();
|
||||||
|
|
||||||
Q_EMIT connectionAdded(c);
|
Q_EMIT connectionAdded(c);
|
||||||
Q_EMIT accountCountChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::dropConnection(NeoChatConnection *c)
|
void Controller::dropConnection(NeoChatConnection *c)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(c, __FUNCTION__, "Attempt to drop a null connection");
|
Q_ASSERT_X(c, __FUNCTION__, "Attempt to drop a null connection");
|
||||||
|
|
||||||
|
m_accountRegistry.drop(c);
|
||||||
Q_EMIT connectionDropped(c);
|
Q_EMIT connectionDropped(c);
|
||||||
Q_EMIT accountCountChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::invokeLogin()
|
void Controller::invokeLogin()
|
||||||
@@ -297,11 +294,6 @@ bool Controller::supportSystemTray() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int Controller::accountCount() const
|
|
||||||
{
|
|
||||||
return m_accountRegistry.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Controller::setQuitOnLastWindowClosed()
|
void Controller::setQuitOnLastWindowClosed()
|
||||||
{
|
{
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef Q_OS_ANDROID
|
||||||
|
|||||||
@@ -41,11 +41,6 @@ class Controller : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
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.
|
* @brief The current connection for the rest of NeoChat to use.
|
||||||
*/
|
*/
|
||||||
@@ -96,8 +91,6 @@ public:
|
|||||||
|
|
||||||
static Controller &instance();
|
static Controller &instance();
|
||||||
|
|
||||||
[[nodiscard]] int accountCount() const;
|
|
||||||
|
|
||||||
void setActiveConnection(NeoChatConnection *connection);
|
void setActiveConnection(NeoChatConnection *connection);
|
||||||
[[nodiscard]] NeoChatConnection *activeConnection() const;
|
[[nodiscard]] NeoChatConnection *activeConnection() const;
|
||||||
|
|
||||||
@@ -215,7 +208,6 @@ Q_SIGNALS:
|
|||||||
void syncDone();
|
void syncDone();
|
||||||
void connectionAdded(NeoChatConnection *connection);
|
void connectionAdded(NeoChatConnection *connection);
|
||||||
void connectionDropped(NeoChatConnection *connection);
|
void connectionDropped(NeoChatConnection *connection);
|
||||||
void accountCountChanged();
|
|
||||||
void initiated();
|
void initiated();
|
||||||
void notificationClicked(const QString &_t1, const QString &_t2);
|
void notificationClicked(const QString &_t1, const QString &_t2);
|
||||||
void quitOnLastWindowClosedChanged();
|
void quitOnLastWindowClosedChanged();
|
||||||
|
|||||||
@@ -40,12 +40,12 @@ Labs.MenuBar {
|
|||||||
|
|
||||||
Labs.MenuItem {
|
Labs.MenuItem {
|
||||||
text: i18nc("menu", "New Private Chat…")
|
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})
|
onTriggered: pushReplaceLayer("qrc:/StartChatPage.qml", {connection: Controller.activeConnection})
|
||||||
}
|
}
|
||||||
Labs.MenuItem {
|
Labs.MenuItem {
|
||||||
text: i18nc("menu", "New Group…")
|
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
|
shortcut: StandardKey.New
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
const dialog = createRoomDialog.createObject(root.overlay)
|
const dialog = createRoomDialog.createObject(root.overlay)
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ FormCard.FormCardPage {
|
|||||||
Dialog.ConfirmLogout {
|
Dialog.ConfirmLogout {
|
||||||
connection: model.connection
|
connection: model.connection
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if (Controller.accountCount === 1) {
|
if (AccountRegistry.accountCount === 1) {
|
||||||
root.Window.window.close()
|
root.Window.window.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ Kirigami.ApplicationWindow {
|
|||||||
target: Controller
|
target: Controller
|
||||||
|
|
||||||
function onInitiated() {
|
function onInitiated() {
|
||||||
if (Controller.accountCount === 0) {
|
if (AccountRegistry.accountCount === 0) {
|
||||||
pageStack.replace("qrc:/WelcomePage.qml", {});
|
pageStack.replace("qrc:/WelcomePage.qml", {});
|
||||||
} else if (!roomListLoaded) {
|
} else if (!roomListLoaded) {
|
||||||
pageStack.replace(roomListComponent, {
|
pageStack.replace(roomListComponent, {
|
||||||
|
|||||||
Reference in New Issue
Block a user