mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
LayoutCreator<T>::operator * now returns a reference
This commit is contained in:
parent
a5b48d713a
commit
440a3c41fe
9 changed files with 59 additions and 55 deletions
|
@ -25,9 +25,9 @@ public:
|
||||||
return this->item;
|
return this->item;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *operator*()
|
T &operator*()
|
||||||
{
|
{
|
||||||
return this->item;
|
return *this->item;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *getElement()
|
T *getElement()
|
||||||
|
|
|
@ -40,7 +40,8 @@ SelectChannelDialog::SelectChannelDialog()
|
||||||
auto channel_edit =
|
auto channel_edit =
|
||||||
vbox.emplace<QLineEdit>().hidden().assign(&this->ui_.twitch.channelName);
|
vbox.emplace<QLineEdit>().hidden().assign(&this->ui_.twitch.channelName);
|
||||||
|
|
||||||
QObject::connect(*channel_btn, &QRadioButton::toggled, [=](bool enabled) mutable {
|
QObject::connect(channel_btn.getElement(), &QRadioButton::toggled,
|
||||||
|
[=](bool enabled) mutable {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
channel_edit->setFocus();
|
channel_edit->setFocus();
|
||||||
channel_edit->setSelection(0, channel_edit->text().length());
|
channel_edit->setSelection(0, channel_edit->text().length());
|
||||||
|
@ -63,7 +64,7 @@ SelectChannelDialog::SelectChannelDialog()
|
||||||
whispers_lbl->setWordWrap(true);
|
whispers_lbl->setWordWrap(true);
|
||||||
whispers_btn->installEventFilter(&this->tabFilter);
|
whispers_btn->installEventFilter(&this->tabFilter);
|
||||||
|
|
||||||
QObject::connect(*whispers_btn, &QRadioButton::toggled,
|
QObject::connect(whispers_btn.getElement(), &QRadioButton::toggled,
|
||||||
[=](bool enabled) mutable { whispers_lbl->setVisible(enabled); });
|
[=](bool enabled) mutable { whispers_lbl->setVisible(enabled); });
|
||||||
|
|
||||||
// mentions_btn
|
// mentions_btn
|
||||||
|
@ -76,7 +77,7 @@ SelectChannelDialog::SelectChannelDialog()
|
||||||
mentions_lbl->setWordWrap(true);
|
mentions_lbl->setWordWrap(true);
|
||||||
mentions_btn->installEventFilter(&this->tabFilter);
|
mentions_btn->installEventFilter(&this->tabFilter);
|
||||||
|
|
||||||
QObject::connect(*mentions_btn, &QRadioButton::toggled,
|
QObject::connect(mentions_btn.getElement(), &QRadioButton::toggled,
|
||||||
[=](bool enabled) mutable { mentions_lbl->setVisible(enabled); });
|
[=](bool enabled) mutable { mentions_lbl->setVisible(enabled); });
|
||||||
|
|
||||||
// watching_btn
|
// watching_btn
|
||||||
|
@ -88,16 +89,16 @@ SelectChannelDialog::SelectChannelDialog()
|
||||||
watching_lbl->setWordWrap(true);
|
watching_lbl->setWordWrap(true);
|
||||||
watching_btn->installEventFilter(&this->tabFilter);
|
watching_btn->installEventFilter(&this->tabFilter);
|
||||||
|
|
||||||
QObject::connect(*watching_btn, &QRadioButton::toggled,
|
QObject::connect(watching_btn.getElement(), &QRadioButton::toggled,
|
||||||
[=](bool enabled) mutable { watching_lbl->setVisible(enabled); });
|
[=](bool enabled) mutable { watching_lbl->setVisible(enabled); });
|
||||||
|
|
||||||
vbox->addStretch(1);
|
vbox->addStretch(1);
|
||||||
|
|
||||||
// tabbing order
|
// tabbing order
|
||||||
QWidget::setTabOrder(*watching_btn, *channel_btn);
|
QWidget::setTabOrder(watching_btn.getElement(), channel_btn.getElement());
|
||||||
QWidget::setTabOrder(*channel_btn, *whispers_btn);
|
QWidget::setTabOrder(channel_btn.getElement(), whispers_btn.getElement());
|
||||||
QWidget::setTabOrder(*whispers_btn, *mentions_btn);
|
QWidget::setTabOrder(whispers_btn.getElement(), mentions_btn.getElement());
|
||||||
QWidget::setTabOrder(*mentions_btn, *watching_btn);
|
QWidget::setTabOrder(mentions_btn.getElement(), watching_btn.getElement());
|
||||||
|
|
||||||
// tab
|
// tab
|
||||||
NotebookTab *tab = notebook->addPage(obj.getElement());
|
NotebookTab *tab = notebook->addPage(obj.getElement());
|
||||||
|
@ -115,7 +116,7 @@ SelectChannelDialog::SelectChannelDialog()
|
||||||
tab->setTitle("Irc");
|
tab->setTitle("Irc");
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
layout->setStretchFactor(*notebook, 1);
|
layout->setStretchFactor(notebook.getElement(), 1);
|
||||||
|
|
||||||
auto buttons = layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
|
auto buttons = layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ AboutPage::AboutPage()
|
||||||
|
|
||||||
auto scroll = layoutCreator.emplace<QScrollArea>();
|
auto scroll = layoutCreator.emplace<QScrollArea>();
|
||||||
auto widget = scroll.emplaceScrollAreaWidget();
|
auto widget = scroll.emplaceScrollAreaWidget();
|
||||||
util::removeScrollAreaBackground(*scroll, *widget);
|
util::removeScrollAreaBackground(scroll.getElement(), widget.getElement());
|
||||||
|
|
||||||
auto layout = widget.setLayoutType<QVBoxLayout>();
|
auto layout = widget.setLayoutType<QVBoxLayout>();
|
||||||
{
|
{
|
||||||
|
@ -73,18 +73,22 @@ AboutPage::AboutPage()
|
||||||
{
|
{
|
||||||
auto form = licenses.emplace<QFormLayout>();
|
auto form = licenses.emplace<QFormLayout>();
|
||||||
|
|
||||||
addLicense(*form, "Qt Framework", "https://www.qt.io", ":/licenses/qt_lgpl-3.0.txt");
|
addLicense(form.getElement(), "Qt Framework", "https://www.qt.io",
|
||||||
addLicense(*form, "Boost", "https://www.boost.org/", ":/licenses/boost_boost.txt");
|
":/licenses/qt_lgpl-3.0.txt");
|
||||||
addLicense(*form, "Fmt", "http://fmtlib.net/", ":/licenses/fmt_bsd2.txt");
|
addLicense(form.getElement(), "Boost", "https://www.boost.org/",
|
||||||
addLicense(*form, "LibCommuni", "https://github.com/communi/libcommuni",
|
":/licenses/boost_boost.txt");
|
||||||
|
addLicense(form.getElement(), "Fmt", "http://fmtlib.net/", ":/licenses/fmt_bsd2.txt");
|
||||||
|
addLicense(form.getElement(), "LibCommuni", "https://github.com/communi/libcommuni",
|
||||||
":/licenses/libcommuni_BSD3.txt");
|
":/licenses/libcommuni_BSD3.txt");
|
||||||
addLicense(*form, "OpenSSL", "https://www.openssl.org/", ":/licenses/openssl.txt");
|
addLicense(form.getElement(), "OpenSSL", "https://www.openssl.org/",
|
||||||
addLicense(*form, "RapidJson", "http://rapidjson.org/", ":/licenses/rapidjson.txt");
|
":/licenses/openssl.txt");
|
||||||
addLicense(*form, "Pajlada/Settings", "https://github.com/pajlada/settings",
|
addLicense(form.getElement(), "RapidJson", "http://rapidjson.org/",
|
||||||
|
":/licenses/rapidjson.txt");
|
||||||
|
addLicense(form.getElement(), "Pajlada/Settings", "https://github.com/pajlada/settings",
|
||||||
":/licenses/pajlada_settings.txt");
|
":/licenses/pajlada_settings.txt");
|
||||||
addLicense(*form, "Pajlada/Signals", "https://github.com/pajlada/signals",
|
addLicense(form.getElement(), "Pajlada/Signals", "https://github.com/pajlada/signals",
|
||||||
":/licenses/pajlada_signals.txt");
|
":/licenses/pajlada_signals.txt");
|
||||||
addLicense(*form, "Websocketpp", "https://www.zaphoyd.com/websocketpp/",
|
addLicense(form.getElement(), "Websocketpp", "https://www.zaphoyd.com/websocketpp/",
|
||||||
":/licenses/websocketpp.txt");
|
":/licenses/websocketpp.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ AccountsPage::AccountsPage()
|
||||||
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
||||||
|
|
||||||
helper::EditableModelView *view =
|
helper::EditableModelView *view =
|
||||||
*layout.emplace<helper::EditableModelView>(app->accounts->createModel(nullptr));
|
layout.emplace<helper::EditableModelView>(app->accounts->createModel(nullptr)).getElement();
|
||||||
|
|
||||||
view->getTableView()->horizontalHeader()->setVisible(false);
|
view->getTableView()->horizontalHeader()->setVisible(false);
|
||||||
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
|
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
|
|
@ -41,7 +41,7 @@ AppearancePage::AppearancePage()
|
||||||
|
|
||||||
auto scroll = layoutCreator.emplace<QScrollArea>();
|
auto scroll = layoutCreator.emplace<QScrollArea>();
|
||||||
auto widget = scroll.emplaceScrollAreaWidget();
|
auto widget = scroll.emplaceScrollAreaWidget();
|
||||||
util::removeScrollAreaBackground(*scroll, *widget);
|
util::removeScrollAreaBackground(scroll.getElement(), widget.getElement());
|
||||||
|
|
||||||
auto layout = widget.setLayoutType<QVBoxLayout>();
|
auto layout = widget.setLayoutType<QVBoxLayout>();
|
||||||
|
|
||||||
|
@ -131,7 +131,8 @@ AppearancePage::AppearancePage()
|
||||||
|
|
||||||
auto scaleLabel = scaleBox.emplace<QLabel>("1.0");
|
auto scaleLabel = scaleBox.emplace<QLabel>("1.0");
|
||||||
scaleLabel->setFixedWidth(100);
|
scaleLabel->setFixedWidth(100);
|
||||||
QObject::connect(*emoteScale, &QSlider::valueChanged, [scaleLabel](int value) mutable {
|
QObject::connect(emoteScale.getElement(), &QSlider::valueChanged,
|
||||||
|
[scaleLabel](int value) mutable {
|
||||||
float f = (float)value / 10.f;
|
float f = (float)value / 10.f;
|
||||||
scaleLabel->setText(QString::number(f));
|
scaleLabel->setText(QString::number(f));
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ CommandPage::CommandPage()
|
||||||
warning.getElement()->setStyleSheet("color: #f00");
|
warning.getElement()->setStyleSheet("color: #f00");
|
||||||
|
|
||||||
helper::EditableModelView *view =
|
helper::EditableModelView *view =
|
||||||
*layout.emplace<helper::EditableModelView>(app->commands->createModel(nullptr));
|
layout.emplace<helper::EditableModelView>(app->commands->createModel(nullptr)).getElement();
|
||||||
|
|
||||||
view->setTitles({"Trigger", "Command"});
|
view->setTitles({"Trigger", "Command"});
|
||||||
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
|
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
@ -54,7 +54,7 @@ CommandPage::CommandPage()
|
||||||
layout.append(this->createCheckBox("Also match the trigger at the end of the message",
|
layout.append(this->createCheckBox("Also match the trigger at the end of the message",
|
||||||
app->settings->allowCommandsAtEnd));
|
app->settings->allowCommandsAtEnd));
|
||||||
|
|
||||||
QLabel *text = *layout.emplace<QLabel>(TEXT);
|
QLabel *text = layout.emplace<QLabel>(TEXT).getElement();
|
||||||
text->setWordWrap(true);
|
text->setWordWrap(true);
|
||||||
text->setStyleSheet("color: #bbb");
|
text->setStyleSheet("color: #bbb");
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,10 @@ HighlightingPage::HighlightingPage()
|
||||||
// HIGHLIGHTS
|
// HIGHLIGHTS
|
||||||
auto highlights = tabs.appendTab(new QVBoxLayout, "Highlights");
|
auto highlights = tabs.appendTab(new QVBoxLayout, "Highlights");
|
||||||
{
|
{
|
||||||
helper::EditableModelView *view = *highlights.emplace<helper::EditableModelView>(
|
helper::EditableModelView *view =
|
||||||
app->highlights->createModel(nullptr));
|
highlights
|
||||||
|
.emplace<helper::EditableModelView>(app->highlights->createModel(nullptr))
|
||||||
|
.getElement();
|
||||||
|
|
||||||
view->setTitles({"Pattern", "Flash taskbar", "Play sound", "Regex"});
|
view->setTitles({"Pattern", "Flash taskbar", "Play sound", "Regex"});
|
||||||
view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
#include <QHeaderView>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -65,7 +66,8 @@ IgnoreUsersPage::IgnoreUsersPage()
|
||||||
auto messages = tabs.appendTab(new QVBoxLayout, "Messages");
|
auto messages = tabs.appendTab(new QVBoxLayout, "Messages");
|
||||||
{
|
{
|
||||||
helper::EditableModelView *view =
|
helper::EditableModelView *view =
|
||||||
*messages.emplace<helper::EditableModelView>(app->ignores->createModel(nullptr));
|
messages.emplace<helper::EditableModelView>(app->ignores->createModel(nullptr))
|
||||||
|
.getElement();
|
||||||
view->setTitles({"Pattern", "Regex"});
|
view->setTitles({"Pattern", "Regex"});
|
||||||
view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
||||||
view->getTableView()->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
|
|
|
@ -40,7 +40,7 @@ UserInfoPopup::UserInfoPopup()
|
||||||
// avatar
|
// avatar
|
||||||
auto avatar = head.emplace<RippleEffectButton>(nullptr).assign(&this->ui_.avatarButton);
|
auto avatar = head.emplace<RippleEffectButton>(nullptr).assign(&this->ui_.avatarButton);
|
||||||
avatar->setScaleIndependantSize(100, 100);
|
avatar->setScaleIndependantSize(100, 100);
|
||||||
QObject::connect(*avatar, &RippleEffectButton::clicked, [this] {
|
QObject::connect(avatar.getElement(), &RippleEffectButton::clicked, [this] {
|
||||||
QDesktopServices::openUrl(QUrl("https://twitch.tv/" + this->userName_));
|
QDesktopServices::openUrl(QUrl("https://twitch.tv/" + this->userName_));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||||
button->setScaleIndependantSize(buttonHeight, buttonHeight);
|
button->setScaleIndependantSize(buttonHeight, buttonHeight);
|
||||||
button->setBorderColor(QColor(255, 255, 255, 127));
|
button->setBorderColor(QColor(255, 255, 255, 127));
|
||||||
|
|
||||||
QObject::connect(*button, &RippleEffectButton::clicked, [this, action] {
|
QObject::connect(button.getElement(), &RippleEffectButton::clicked, [this, action] {
|
||||||
this->buttonClicked.invoke(std::make_pair(action, -1));
|
this->buttonClicked.invoke(std::make_pair(action, -1));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -367,10 +367,9 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||||
}
|
}
|
||||||
a->setBorderColor(color1);
|
a->setBorderColor(color1);
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(a.getElement(), &RippleEffectLabel2::clicked, [
|
||||||
*a, &RippleEffectLabel2::clicked, [this, timeout = std::get<1>(item)] {
|
this, timeout = std::get<1>(item)
|
||||||
this->buttonClicked.invoke(std::make_pair(Action::Timeout, timeout));
|
] { this->buttonClicked.invoke(std::make_pair(Action::Timeout, timeout)); });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -379,21 +378,16 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||||
|
|
||||||
addTimeouts("sec", {{"1", 1}});
|
addTimeouts("sec", {{"1", 1}});
|
||||||
addTimeouts("min", {
|
addTimeouts("min", {
|
||||||
{"1", 1 * 60},
|
{"1", 1 * 60}, {"5", 5 * 60}, {"10", 10 * 60},
|
||||||
{"5", 5 * 60},
|
|
||||||
{"10", 10 * 60},
|
|
||||||
});
|
});
|
||||||
addTimeouts("hour", {
|
addTimeouts("hour", {
|
||||||
{"1", 1 * 60 * 60},
|
{"1", 1 * 60 * 60}, {"4", 4 * 60 * 60},
|
||||||
{"4", 4 * 60 * 60},
|
|
||||||
});
|
});
|
||||||
addTimeouts("days", {
|
addTimeouts("days", {
|
||||||
{"1", 1 * 60 * 60 * 24},
|
{"1", 1 * 60 * 60 * 24}, {"3", 3 * 60 * 60 * 24},
|
||||||
{"3", 3 * 60 * 60 * 24},
|
|
||||||
});
|
});
|
||||||
addTimeouts("weeks", {
|
addTimeouts("weeks", {
|
||||||
{"1", 1 * 60 * 60 * 24 * 7},
|
{"1", 1 * 60 * 60 * 24 * 7}, {"2", 2 * 60 * 60 * 24 * 7},
|
||||||
{"2", 2 * 60 * 60 * 24 * 7},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton(Ban, "ban", getApp()->resources->buttons.ban);
|
addButton(Ban, "ban", getApp()->resources->buttons.ban);
|
||||||
|
|
Loading…
Reference in a new issue