37 template <
typename T2>
40 this->addItem(this->getOrCreateLayout(), _item);
45 template <
typename T2,
typename...
Args>
51 T2 *t =
new T2(std::forward<Args>(args)...);
53 this->addItem(this->getOrCreateLayout(), t);
58 template <
typename Q = T,
59 typename std::enable_if<std::is_base_of<QScrollArea, Q>::value,
63 QWidget *widget =
new QWidget;
64 this->item_->setWidget(widget);
68 template <
typename T2,
typename Q = T,
69 typename std::enable_if<std::is_base_of<QWidget, Q>::value,
71 typename std::enable_if<std::is_base_of<QLayout, T2>::value,
77 this->item_->setLayout(layout);
89 template <
typename Q = T,
90 typename std::enable_if<std::is_base_of<QLayout, Q>::value,
94 this->item_->setContentsMargins(0, 0, 0, 0);
101 this->item_->setSpacing(0);
106 template <
typename Q = T,
107 typename std::enable_if<std::is_base_of<QWidget, Q>::value,
111 this->item_->setVisible(
false);
116 template <
typename Q = T,
typename T2,
117 typename std::enable_if<std::is_same<QTabWidget, Q>::value,
121 static_assert(std::is_base_of<QLayout, T2>::value,
122 "needs to be QLayout");
124 QWidget *widget =
new QWidget;
125 widget->setLayout(item);
127 this->item_->addTab(widget, title);
132 template <
typename Slot,
typename Func>
135 QObject::connect(this->
getElement(), slot, receiver, func);
139 template <
typename Func>
142 QObject::connect(this->
getElement(), &T::clicked, receiver, func);
149 template <
typename T2,
150 typename std::enable_if<std::is_base_of<QWidget, T2>::value,
152 void addItem(QLayout *layout, T2 *item)
154 layout->addWidget(item);
157 template <
typename T2,
158 typename std::enable_if<std::is_base_of<QLayout, T2>::value,
160 void addItem(QLayout *layout, T2 *item)
162 QWidget *widget =
new QWidget();
163 widget->setLayout(item);
164 layout->addWidget(widget);
167 template <
typename Q = T,
168 typename std::enable_if<std::is_base_of<QLayout, Q>::value,
170 QLayout *getOrCreateLayout()
175 template <
typename Q = T,
176 typename std::enable_if<std::is_base_of<QWidget, Q>::value,
178 QLayout *getOrCreateLayout()
180 if (!this->item_->layout())
182 this->item_->setLayout(
new QHBoxLayout());
185 return this->item_->layout();
189 template <
typename T,
typename...
Args>
195 T *t =
new T(std::forward<Args>(args)...);
196 t->setAttribute(Qt::WA_DeleteOnClose);
LayoutCreator< T2 > setLayoutType()
Definition: LayoutCreator.hpp:73
LayoutCreator< T > assign(T **ptr)
Definition: LayoutCreator.hpp:82
LayoutCreator< T > connect(Slot slot, QObject *receiver, Func func)
Definition: LayoutCreator.hpp:133
LayoutCreator(T *_item)
Definition: LayoutCreator.hpp:17
T * operator->()
Definition: LayoutCreator.hpp:22
LayoutCreator< T > makeDialog(Args &&...args)
Definition: LayoutCreator.hpp:192
Definition: Application.cpp:48
LayoutCreator< T > withoutMargin()
Definition: LayoutCreator.hpp:92
LayoutCreator< QWidget > emplaceScrollAreaWidget()
Definition: LayoutCreator.hpp:61
T & operator*()
Definition: LayoutCreator.hpp:27
Command line arguments passed to Chatterino.
Definition: Args.hpp:10
LayoutCreator< T2 > append(T2 *_item)
Definition: LayoutCreator.hpp:38
LayoutCreator< T > withoutSpacing()
Definition: LayoutCreator.hpp:99
T * getElement()
Definition: LayoutCreator.hpp:32
Definition: LayoutCreator.hpp:14
LayoutCreator< T > onClick(QObject *receiver, Func func)
Definition: LayoutCreator.hpp:140
LayoutCreator< T2 > appendTab(T2 *item, const QString &title)
Definition: LayoutCreator.hpp:119
LayoutCreator< T2 > emplace(Args &&...args)
Definition: LayoutCreator.hpp:48
LayoutCreator< T > hidden()
Definition: LayoutCreator.hpp:109