1 #include "AccountsPage.hpp" 2 3 #include "Application.hpp" 4 #include "controllers/accounts/AccountController.hpp" 5 #include "controllers/accounts/AccountModel.hpp" 6 #include "providers/twitch/TwitchCommon.hpp" 7 #include "util/LayoutCreator.hpp" 8 #include "widgets/dialogs/LoginDialog.hpp" 9 #include "widgets/helper/EditableModelView.hpp" 10 11 #include <QDialogButtonBox> 12 #include <QHeaderView> 13 #include <QTableView> 14 #include <QVBoxLayout> 15 #include <algorithm> 16 17 namespace chatterino { 18 AccountsPage()19AccountsPage::AccountsPage() 20 { 21 auto *app = getApp(); 22 23 LayoutCreator<AccountsPage> layoutCreator(this); 24 auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin(); 25 26 EditableModelView *view = 27 layout 28 .emplace<EditableModelView>(app->accounts->createModel(nullptr), 29 false) 30 .getElement(); 31 32 view->getTableView()->horizontalHeader()->setVisible(false); 33 view->getTableView()->horizontalHeader()->setStretchLastSection(true); 34 35 view->addButtonPressed.connect([this] { 36 static auto loginWidget = new LoginWidget(this); 37 38 loginWidget->show(); 39 loginWidget->raise(); 40 }); 41 42 view->getTableView()->setStyleSheet("background: #333"); 43 44 // auto buttons = layout.emplace<QDialogButtonBox>(); 45 // { 46 // this->addButton = buttons->addButton("Add", 47 // QDialogButtonBox::YesRole); this->removeButton = 48 // buttons->addButton("Remove", QDialogButtonBox::NoRole); 49 // } 50 51 // layout.emplace<AccountSwitchWidget>(this).assign(&this->accSwitchWidget); 52 53 // ---- 54 // QObject::connect(this->addButton, &QPushButton::clicked, []() { 55 // static auto loginWidget = new LoginWidget(); 56 // loginWidget->show(); 57 // }); 58 59 // QObject::connect(this->removeButton, &QPushButton::clicked, [this] { 60 // auto selectedUser = this->accSwitchWidget->currentItem()->text(); 61 // if (selectedUser == ANONYMOUS_USERNAME_LABEL) { 62 // // Do nothing 63 // return; 64 // } 65 66 // getApp()->accounts->Twitch.removeUser(selectedUser); 67 // }); 68 } 69 70 } // namespace chatterino 71