2019-09-08 22:27:57 +02:00
|
|
|
#include "AccountsPage.hpp"
|
|
|
|
|
|
|
|
#include "Application.hpp"
|
|
|
|
#include "controllers/accounts/AccountController.hpp"
|
|
|
|
#include "controllers/accounts/AccountModel.hpp"
|
|
|
|
#include "providers/twitch/TwitchCommon.hpp"
|
|
|
|
#include "util/LayoutCreator.hpp"
|
|
|
|
#include "widgets/dialogs/LoginDialog.hpp"
|
|
|
|
#include "widgets/helper/EditableModelView.hpp"
|
|
|
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QTableView>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
AccountsPage::AccountsPage()
|
|
|
|
{
|
|
|
|
auto *app = getApp();
|
|
|
|
|
|
|
|
LayoutCreator<AccountsPage> layoutCreator(this);
|
|
|
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
|
|
|
|
|
|
|
EditableModelView *view =
|
2020-10-22 20:02:14 +02:00
|
|
|
layout
|
|
|
|
.emplace<EditableModelView>(app->accounts->createModel(nullptr),
|
|
|
|
false)
|
2019-09-08 22:27:57 +02:00
|
|
|
.getElement();
|
|
|
|
|
|
|
|
view->getTableView()->horizontalHeader()->setVisible(false);
|
|
|
|
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
|
2020-11-29 10:48:23 +01:00
|
|
|
view->addButtonPressed.connect([this] {
|
|
|
|
static auto loginWidget = new LoginWidget(this);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
loginWidget->show();
|
|
|
|
loginWidget->raise();
|
|
|
|
});
|
|
|
|
|
|
|
|
view->getTableView()->setStyleSheet("background: #333");
|
|
|
|
|
|
|
|
// 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->removeButton, &QPushButton::clicked, [this] {
|
|
|
|
// auto selectedUser = this->accSwitchWidget->currentItem()->text();
|
|
|
|
// if (selectedUser == ANONYMOUS_USERNAME_LABEL) {
|
|
|
|
// // Do nothing
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// getApp()->accounts->Twitch.removeUser(selectedUser);
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace chatterino
|