added add account login back in

This commit is contained in:
fourtf 2018-05-27 03:17:33 +02:00
parent 7e68e662e3
commit 0fed9ca5d2
5 changed files with 22 additions and 15 deletions

View file

@ -8,6 +8,9 @@ namespace accounts {
AccountController::AccountController() AccountController::AccountController()
{ {
this->twitch.accounts.itemInserted.connect([this](const auto &args) {
accounts.insertItem(std::dynamic_pointer_cast<Account>(args.item));
});
} }
void AccountController::load() void AccountController::load()

View file

@ -11,6 +11,13 @@
namespace chatterino { namespace chatterino {
namespace util { namespace util {
template <typename TVectorItem>
struct SignalVectorItemArgs {
const TVectorItem &item;
int index;
void *caller;
};
template <typename TVectorItem> template <typename TVectorItem>
class ReadOnlySignalVector : boost::noncopyable class ReadOnlySignalVector : boost::noncopyable
{ {
@ -24,14 +31,8 @@ public:
} }
virtual ~ReadOnlySignalVector() = default; virtual ~ReadOnlySignalVector() = default;
struct ItemArgs { pajlada::Signals::Signal<SignalVectorItemArgs<TVectorItem>> itemInserted;
const TVectorItem &item; pajlada::Signals::Signal<SignalVectorItemArgs<TVectorItem>> itemRemoved;
int index;
void *caller;
};
pajlada::Signals::Signal<ItemArgs> itemInserted;
pajlada::Signals::Signal<ItemArgs> itemRemoved;
pajlada::Signals::NoArgSignal delayedItemsChanged; pajlada::Signals::NoArgSignal delayedItemsChanged;
const std::vector<TVectorItem> &getVector() const const std::vector<TVectorItem> &getVector() const
@ -69,7 +70,7 @@ public:
TVectorItem item = this->vector[index]; TVectorItem item = this->vector[index];
this->vector.erase(this->vector.begin() + index); this->vector.erase(this->vector.begin() + index);
typename ReadOnlySignalVector<TVectorItem>::ItemArgs args{item, index, caller}; SignalVectorItemArgs<TVectorItem> args{item, index, caller};
this->itemRemoved.invoke(args); this->itemRemoved.invoke(args);
this->invokeDelayedItemsChanged(); this->invokeDelayedItemsChanged();
@ -96,7 +97,7 @@ public:
this->vector.insert(this->vector.begin() + index, item); this->vector.insert(this->vector.begin() + index, item);
typename ReadOnlySignalVector<TVectorItem>::ItemArgs args{item, index, caller}; SignalVectorItemArgs<TVectorItem> args{item, index, caller};
this->itemInserted.invoke(args); this->itemInserted.invoke(args);
this->invokeDelayedItemsChanged(); this->invokeDelayedItemsChanged();
return index; return index;
@ -115,7 +116,7 @@ public:
int index = it - this->vector.begin(); int index = it - this->vector.begin();
this->vector.insert(it, item); this->vector.insert(it, item);
typename ReadOnlySignalVector<TVectorItem>::ItemArgs args{item, index, caller}; SignalVectorItemArgs<TVectorItem> args{item, index, caller};
this->itemInserted.invoke(args); this->itemInserted.invoke(args);
this->invokeDelayedItemsChanged(); this->invokeDelayedItemsChanged();
return index; return index;

View file

@ -27,7 +27,7 @@ public:
{ {
this->vector = vec; this->vector = vec;
auto insert = [this](const typename BaseSignalVector<TVectorItem>::ItemArgs &args) { auto insert = [this](const SignalVectorItemArgs<TVectorItem> &args) {
if (args.caller == this) { if (args.caller == this) {
return; return;
} }
@ -50,7 +50,7 @@ public:
int i = 0; int i = 0;
for (const TVectorItem &item : vec->getVector()) { for (const TVectorItem &item : vec->getVector()) {
typename BaseSignalVector<TVectorItem>::ItemArgs args{item, i++, 0}; SignalVectorItemArgs<TVectorItem> args{item, i++, 0};
insert(args); insert(args);
} }

View file

@ -579,7 +579,7 @@ bool ChannelView::isPaused()
void ChannelView::paintEvent(QPaintEvent * /*event*/) void ChannelView::paintEvent(QPaintEvent * /*event*/)
{ {
// BenchmarkGuard benchmark("paint event"); BenchmarkGuard benchmark("paint event");
QPainter painter(this); QPainter painter(this);

View file

@ -33,7 +33,10 @@ AccountsPage::AccountsPage()
view->setTitles({"Name"}); view->setTitles({"Name"});
view->getTableView()->horizontalHeader()->setStretchLastSection(true); view->getTableView()->horizontalHeader()->setStretchLastSection(true);
view->addButtonPressed.connect([] {}); view->addButtonPressed.connect([] {
static auto loginWidget = new LoginWidget();
loginWidget->show();
});
// auto buttons = layout.emplace<QDialogButtonBox>(); // auto buttons = layout.emplace<QDialogButtonBox>();
// { // {