#pragma once #include #include class QWidget; class QScrollArea; namespace chatterino { using LayoutItem = boost::variant; QWidget *wrapLayout(QLayout *layout); QScrollArea *makeScrollArea(LayoutItem item); template T *makeLayout(std::initializer_list items) { auto t = new T; for (auto &item : items) { switch (item.which()) { case 0: t->addItem(new QWidgetItem(boost::get(item))); break; case 1: t->addItem(boost::get(item)); break; } } t->setContentsMargins(0, 0, 0, 0); return t; } template T *makeStretchingLayout(std::initializer_list items) { auto layout = makeLayout(items); layout->addStretch(1); return layout; } template T *makeWidget(With with) { auto t = new T; with(t); return t; } } // namespace chatterino