2018-01-12 23:09:05 +01:00
|
|
|
#include "accountspage.hpp"
|
|
|
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
#include "const.hpp"
|
|
|
|
#include "singletons/accountmanager.hpp"
|
|
|
|
#include "util/layoutcreator.hpp"
|
|
|
|
#include "widgets/logindialog.hpp"
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
namespace widgets {
|
|
|
|
namespace settingspages {
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
AccountsPage::AccountsPage()
|
|
|
|
: SettingsPage("Accounts", ":/images/accounts.svg")
|
|
|
|
{
|
|
|
|
util::LayoutCreator<AccountsPage> layoutCreator(this);
|
|
|
|
|
|
|
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
|
|
|
auto buttons = layout.emplace<QDialogButtonBox>();
|
|
|
|
{
|
|
|
|
this->addButton = buttons->addButton("Add", QDialogButtonBox::YesRole);
|
|
|
|
this->removeButton = buttons->addButton("Remove", QDialogButtonBox::NoRole);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto accountSwitch = layout.emplace<AccountSwitchWidget>(this).assign(&this->accSwitchWidget);
|
|
|
|
|
|
|
|
// ----
|
|
|
|
QObject::connect(this->addButton, &QPushButton::clicked, []() {
|
|
|
|
static auto loginWidget = new LoginWidget();
|
|
|
|
loginWidget->show();
|
|
|
|
});
|
|
|
|
|
|
|
|
QObject::connect(this->removeButton, &QPushButton::clicked, [this] {
|
|
|
|
auto selectedUser = this->accSwitchWidget->currentItem()->text();
|
|
|
|
if (selectedUser == ANONYMOUS_USERNAME_LABEL) {
|
|
|
|
// Do nothing
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
singletons::AccountManager::getInstance().Twitch.removeUser(selectedUser);
|
|
|
|
});
|
|
|
|
}
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
} // namespace settingspages
|
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|