changed AccountManager to AccountController

This commit is contained in:
fourtf
2018-05-26 20:25:00 +02:00
parent b016f0fb88
commit 8c9be20f9b
41 changed files with 364 additions and 118 deletions
+36 -20
View File
@@ -2,11 +2,17 @@
#include "application.hpp"
#include "const.hpp"
#include "singletons/accountmanager.hpp"
#include "controllers/accounts/accountcontroller.hpp"
#include "controllers/accounts/accountmodel.hpp"
#include "util/layoutcreator.hpp"
#include "widgets/helper/editablemodelview.hpp"
#include "widgets/logindialog.hpp"
#include <algorithm>
#include <QDialogButtonBox>
#include <QHeaderView>
#include <QTableView>
#include <QVBoxLayout>
namespace chatterino {
@@ -16,32 +22,42 @@ namespace settingspages {
AccountsPage::AccountsPage()
: SettingsPage("Accounts", ":/images/accounts.svg")
{
auto *app = getApp();
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);
}
layout.emplace<AccountSwitchWidget>(this).assign(&this->accSwitchWidget);
helper::EditableModelView *view =
*layout.emplace<helper::EditableModelView>(app->accounts->createModel(nullptr));
view->setTitles({"Name"});
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
view->addButtonPressed.connect([] {});
// auto buttons = layout.emplace<QDialogButtonBox>();
// {
// this->addButton = buttons->addButton("Add", QDialogButtonBox::YesRole);
// this->removeButton = buttons->addButton("Remove", QDialogButtonBox::NoRole);
// }
// layout.emplace<AccountSwitchWidget>(this).assign(&this->accSwitchWidget);
// ----
QObject::connect(this->addButton, &QPushButton::clicked, []() {
static auto loginWidget = new LoginWidget();
loginWidget->show();
});
// 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;
}
// QObject::connect(this->removeButton, &QPushButton::clicked, [this] {
// auto selectedUser = this->accSwitchWidget->currentItem()->text();
// if (selectedUser == ANONYMOUS_USERNAME_LABEL) {
// // Do nothing
// return;
// }
getApp()->accounts->Twitch.removeUser(selectedUser);
});
// getApp()->accounts->Twitch.removeUser(selectedUser);
// });
}
} // namespace settingspages