Change the way Twitch accounts are stored in AccountManager
This is done in a way which should simplify abstracting it to other types of accounts if needed in the future Remove comment about removing singletons - we're keeping them (and probably restoring some) IrcManager now updates its "account" reference automatically through the AccountManager.Twitch.userChanged-signal Remove unused IrcManager getUser-method IrcManager::beginConnecting is no longer called asynchronously. This might want to be reverted in a more controlled asynchronous manner. User Accounts are now stored as Shared Pointers instead of using references/copies everywhere
This commit is contained in:
@@ -129,13 +129,13 @@ QVBoxLayout *SettingsDialog::createAccountsTab()
|
||||
// listview
|
||||
auto listWidget = new QListWidget(this);
|
||||
|
||||
for (auto &user : AccountManager::getInstance().getTwitchUsers()) {
|
||||
listWidget->addItem(user.getUserName());
|
||||
for (const auto &userName : AccountManager::getInstance().Twitch.getUsernames()) {
|
||||
listWidget->addItem(userName);
|
||||
}
|
||||
|
||||
// Select the currently logged in user
|
||||
if (listWidget->count() > 0) {
|
||||
const auto ¤tUser = AccountManager::getInstance().getTwitchUser();
|
||||
QString currentUsername = currentUser.getUserName();
|
||||
const QString ¤tUsername = AccountManager::getInstance().Twitch.getCurrent()->getUserName();
|
||||
for (int i = 0; i < listWidget->count(); ++i) {
|
||||
QString itemText = listWidget->item(i)->text();
|
||||
if (itemText.compare(currentUsername, Qt::CaseInsensitive) == 0) {
|
||||
@@ -147,7 +147,8 @@ QVBoxLayout *SettingsDialog::createAccountsTab()
|
||||
|
||||
QObject::connect(listWidget, &QListWidget::clicked, this, [&, listWidget] {
|
||||
if (!listWidget->selectedItems().isEmpty()) {
|
||||
AccountManager::getInstance().setCurrentTwitchUser(listWidget->currentItem()->text());
|
||||
QString newUsername = listWidget->currentItem()->text();
|
||||
AccountManager::getInstance().Twitch.currentUsername = newUsername.toStdString();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user