Fix account adding and account removing.

This needs to be fully tested before I'm comfortable closing #9

The "advanced" tab also needs testing

We might also want to move the login website to chatterino.com and make
it look nicer
This commit is contained in:
Rasmus Karlsson
2017-12-19 15:12:33 +01:00
parent 1e3aca1b7a
commit 324dfc9ee9
5 changed files with 170 additions and 38 deletions
+16
View File
@@ -15,6 +15,22 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
this->addItem(userName);
}
AccountManager::getInstance().Twitch.userListUpdated.connect([this]() {
this->blockSignals(true);
this->clear();
this->addItem(anonUsername);
for (const auto &userName : AccountManager::getInstance().Twitch.getUsernames()) {
this->addItem(userName);
}
this->refreshSelection();
this->blockSignals(false);
});
this->refreshSelection();
QObject::connect(this, &QListWidget::clicked, [this] {
+15 -1
View File
@@ -1,9 +1,11 @@
#include "widgets/logindialog.hpp"
#include "common.hpp"
#include "util/urlfetch.hpp"
#include <QClipboard>
#include <QDebug>
#include <QDesktopServices>
#include <QMessageBox>
#include <QUrl>
#include <pajlada/settings/setting.hpp>
@@ -56,8 +58,16 @@ BasicLoginWidget::BasicLoginWidget()
}
if (oauthToken.empty() || clientID.empty() || username.empty() || userID.empty()) {
qDebug() << "Missing variables!!!!!!!!!";
QMessageBox messageBox;
messageBox.setText("Bad values");
messageBox.setInformativeText("Missing values from the clipboard.<br />Ensure you "
"copied all text and try again.");
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
} else {
QMessageBox messageBox;
messageBox.setText("Success!");
messageBox.setInformativeText("Successfully added user " + qS(username) + "!");
qDebug() << "Success! mr";
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/username",
username);
@@ -67,6 +77,10 @@ BasicLoginWidget::BasicLoginWidget()
clientID);
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/oauthToken",
oauthToken);
AccountManager::getInstance().Twitch.reloadUsers();
messageBox.exec();
}
});
}
+10 -4
View File
@@ -120,10 +120,6 @@ QVBoxLayout *SettingsDialog::createAccountsTab()
loginWidget->show();
});
connect(removeButton, &QPushButton::clicked, []() {
qDebug() << "TODO: Implement"; //
});
buttonBox->addButton(addButton, QDialogButtonBox::YesRole);
buttonBox->addButton(removeButton, QDialogButtonBox::NoRole);
@@ -131,6 +127,16 @@ QVBoxLayout *SettingsDialog::createAccountsTab()
this->ui.accountSwitchWidget = new AccountSwitchWidget(this);
connect(removeButton, &QPushButton::clicked, [this]() {
qDebug() << "TODO: Implement"; //
auto selectedUser = this->ui.accountSwitchWidget->currentItem()->text();
if (selectedUser == " - anonymous - ") {
// Do nothing
return;
}
AccountManager::getInstance().Twitch.removeUser(selectedUser);
});
layout->addWidget(this->ui.accountSwitchWidget);
return layout;