diff --git a/src/controllers/accounts/accountcontroller.cpp b/src/controllers/accounts/accountcontroller.cpp index 9de7e3ffd..c07d28628 100644 --- a/src/controllers/accounts/accountcontroller.cpp +++ b/src/controllers/accounts/accountcontroller.cpp @@ -8,6 +8,9 @@ namespace accounts { AccountController::AccountController() { + this->twitch.accounts.itemInserted.connect([this](const auto &args) { + accounts.insertItem(std::dynamic_pointer_cast(args.item)); + }); } void AccountController::load() diff --git a/src/util/signalvector2.hpp b/src/util/signalvector2.hpp index 9196c7acb..d26878fa5 100644 --- a/src/util/signalvector2.hpp +++ b/src/util/signalvector2.hpp @@ -11,6 +11,13 @@ namespace chatterino { namespace util { +template +struct SignalVectorItemArgs { + const TVectorItem &item; + int index; + void *caller; +}; + template class ReadOnlySignalVector : boost::noncopyable { @@ -24,14 +31,8 @@ public: } virtual ~ReadOnlySignalVector() = default; - struct ItemArgs { - const TVectorItem &item; - int index; - void *caller; - }; - - pajlada::Signals::Signal itemInserted; - pajlada::Signals::Signal itemRemoved; + pajlada::Signals::Signal> itemInserted; + pajlada::Signals::Signal> itemRemoved; pajlada::Signals::NoArgSignal delayedItemsChanged; const std::vector &getVector() const @@ -69,7 +70,7 @@ public: TVectorItem item = this->vector[index]; this->vector.erase(this->vector.begin() + index); - typename ReadOnlySignalVector::ItemArgs args{item, index, caller}; + SignalVectorItemArgs args{item, index, caller}; this->itemRemoved.invoke(args); this->invokeDelayedItemsChanged(); @@ -96,7 +97,7 @@ public: this->vector.insert(this->vector.begin() + index, item); - typename ReadOnlySignalVector::ItemArgs args{item, index, caller}; + SignalVectorItemArgs args{item, index, caller}; this->itemInserted.invoke(args); this->invokeDelayedItemsChanged(); return index; @@ -115,7 +116,7 @@ public: int index = it - this->vector.begin(); this->vector.insert(it, item); - typename ReadOnlySignalVector::ItemArgs args{item, index, caller}; + SignalVectorItemArgs args{item, index, caller}; this->itemInserted.invoke(args); this->invokeDelayedItemsChanged(); return index; diff --git a/src/util/signalvectormodel.hpp b/src/util/signalvectormodel.hpp index c686f6760..6548a60f4 100644 --- a/src/util/signalvectormodel.hpp +++ b/src/util/signalvectormodel.hpp @@ -27,7 +27,7 @@ public: { this->vector = vec; - auto insert = [this](const typename BaseSignalVector::ItemArgs &args) { + auto insert = [this](const SignalVectorItemArgs &args) { if (args.caller == this) { return; } @@ -50,7 +50,7 @@ public: int i = 0; for (const TVectorItem &item : vec->getVector()) { - typename BaseSignalVector::ItemArgs args{item, i++, 0}; + SignalVectorItemArgs args{item, i++, 0}; insert(args); } diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 3172fc1ce..1b85ac8ec 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -579,7 +579,7 @@ bool ChannelView::isPaused() void ChannelView::paintEvent(QPaintEvent * /*event*/) { - // BenchmarkGuard benchmark("paint event"); + BenchmarkGuard benchmark("paint event"); QPainter painter(this); diff --git a/src/widgets/settingspages/accountspage.cpp b/src/widgets/settingspages/accountspage.cpp index a07134dc0..91acbd2d1 100644 --- a/src/widgets/settingspages/accountspage.cpp +++ b/src/widgets/settingspages/accountspage.cpp @@ -33,7 +33,10 @@ AccountsPage::AccountsPage() view->setTitles({"Name"}); view->getTableView()->horizontalHeader()->setStretchLastSection(true); - view->addButtonPressed.connect([] {}); + view->addButtonPressed.connect([] { + static auto loginWidget = new LoginWidget(); + loginWidget->show(); + }); // auto buttons = layout.emplace(); // {