2018-06-26 14:09:39 +02:00
|
|
|
#include "AccountsPage.hpp"
|
|
|
|
|
|
|
|
#include "Application.hpp"
|
2018-06-26 15:11:45 +02:00
|
|
|
#include "providers/twitch/Const.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "controllers/accounts/AccountController.hpp"
|
|
|
|
#include "controllers/accounts/AccountModel.hpp"
|
|
|
|
#include "util/LayoutCreator.hpp"
|
|
|
|
#include "widgets/helper/EditableModelView.hpp"
|
2018-06-26 15:11:45 +02:00
|
|
|
#include "widgets/dialogs/LoginDialog.hpp"
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
#include <QDialogButtonBox>
|
2018-05-26 20:25:00 +02:00
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QTableView>
|
2018-04-27 22:11:19 +02:00
|
|
|
#include <QVBoxLayout>
|
2018-06-21 22:02:35 +02:00
|
|
|
#include <algorithm>
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
namespace chatterino {
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
AccountsPage::AccountsPage()
|
|
|
|
: SettingsPage("Accounts", ":/images/accounts.svg")
|
|
|
|
{
|
2018-05-26 20:25:00 +02:00
|
|
|
auto *app = getApp();
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-06-26 17:06:17 +02:00
|
|
|
LayoutCreator<AccountsPage> layoutCreator(this);
|
2018-01-12 23:09:05 +01:00
|
|
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
|
|
|
|
2018-06-26 17:06:17 +02:00
|
|
|
EditableModelView *view =
|
|
|
|
layout.emplace<EditableModelView>(app->accounts->createModel(nullptr)).getElement();
|
2018-05-26 20:25:00 +02:00
|
|
|
|
2018-05-28 08:34:54 +02:00
|
|
|
view->getTableView()->horizontalHeader()->setVisible(false);
|
2018-05-26 20:25:00 +02:00
|
|
|
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
|
2018-05-27 03:17:33 +02:00
|
|
|
view->addButtonPressed.connect([] {
|
|
|
|
static auto loginWidget = new LoginWidget();
|
2018-05-28 08:34:54 +02:00
|
|
|
|
2018-05-27 03:17:33 +02:00
|
|
|
loginWidget->show();
|
2018-06-06 20:15:33 +02:00
|
|
|
loginWidget->raise();
|
2018-05-27 03:17:33 +02:00
|
|
|
});
|
2018-05-26 20:25:00 +02:00
|
|
|
|
2018-05-28 08:34:54 +02:00
|
|
|
view->getTableView()->setStyleSheet("background: #333");
|
|
|
|
|
2018-05-26 20:25:00 +02:00
|
|
|
// 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);
|
2018-01-12 23:09:05 +01:00
|
|
|
|
|
|
|
// ----
|
2018-05-26 20:25:00 +02:00
|
|
|
// 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);
|
|
|
|
// });
|
2018-01-12 23:09:05 +01:00
|
|
|
}
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
} // namespace chatterino
|