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