changed to 80 max column

This commit is contained in:
fourtf
2018-08-06 21:17:03 +02:00
parent defa7e41fa
commit f71ff08e68
203 changed files with 3792 additions and 2405 deletions
+61 -36
View File
@@ -33,17 +33,20 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
auto vbox = obj.setLayoutType<QVBoxLayout>();
// channel_btn
auto channel_btn = vbox.emplace<QRadioButton>("Channel").assign(&this->ui_.twitch.channel);
auto channel_lbl = vbox.emplace<QLabel>("Join a twitch channel by its name.").hidden();
auto channel_btn = vbox.emplace<QRadioButton>("Channel").assign(
&this->ui_.twitch.channel);
auto channel_lbl =
vbox.emplace<QLabel>("Join a twitch channel by its name.").hidden();
channel_lbl->setWordWrap(true);
auto channel_edit =
vbox.emplace<QLineEdit>().hidden().assign(&this->ui_.twitch.channelName);
auto channel_edit = vbox.emplace<QLineEdit>().hidden().assign(
&this->ui_.twitch.channelName);
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->setSelection(
0, channel_edit->text().length());
}
channel_edit->setVisible(enabled);
@@ -54,50 +57,60 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
channel_edit->installEventFilter(&this->tabFilter_);
// whispers_btn
auto whispers_btn =
vbox.emplace<QRadioButton>("Whispers").assign(&this->ui_.twitch.whispers);
auto whispers_btn = vbox.emplace<QRadioButton>("Whispers")
.assign(&this->ui_.twitch.whispers);
auto whispers_lbl =
vbox.emplace<QLabel>("Shows the whispers that you receive while chatterino is running.")
vbox.emplace<QLabel>("Shows the whispers that you receive while "
"chatterino is running.")
.hidden();
whispers_lbl->setWordWrap(true);
whispers_btn->installEventFilter(&this->tabFilter_);
QObject::connect(whispers_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { whispers_lbl->setVisible(enabled); });
QObject::connect(
whispers_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { whispers_lbl->setVisible(enabled); });
// mentions_btn
auto mentions_btn =
vbox.emplace<QRadioButton>("Mentions").assign(&this->ui_.twitch.mentions);
auto mentions_btn = vbox.emplace<QRadioButton>("Mentions")
.assign(&this->ui_.twitch.mentions);
auto mentions_lbl =
vbox.emplace<QLabel>("Shows all the messages that highlight you from any channel.")
vbox.emplace<QLabel>("Shows all the messages that highlight you "
"from any channel.")
.hidden();
mentions_lbl->setWordWrap(true);
mentions_btn->installEventFilter(&this->tabFilter_);
QObject::connect(mentions_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { mentions_lbl->setVisible(enabled); });
QObject::connect(
mentions_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { mentions_lbl->setVisible(enabled); });
// watching_btn
auto watching_btn =
vbox.emplace<QRadioButton>("Watching").assign(&this->ui_.twitch.watching);
auto watching_btn = vbox.emplace<QRadioButton>("Watching")
.assign(&this->ui_.twitch.watching);
auto watching_lbl =
vbox.emplace<QLabel>("Requires the chatterino browser extension.").hidden();
vbox.emplace<QLabel>("Requires the chatterino browser extension.")
.hidden();
watching_lbl->setWordWrap(true);
watching_btn->installEventFilter(&this->tabFilter_);
QObject::connect(watching_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { watching_lbl->setVisible(enabled); });
QObject::connect(
watching_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { watching_lbl->setVisible(enabled); });
vbox->addStretch(1);
// tabbing order
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());
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());
@@ -117,12 +130,15 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
layout->setStretchFactor(notebook.getElement(), 1);
auto buttons = layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
auto buttons =
layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
{
auto *button_ok = buttons->addButton(QDialogButtonBox::Ok);
QObject::connect(button_ok, &QPushButton::clicked, [=](bool) { this->ok(); });
QObject::connect(button_ok, &QPushButton::clicked,
[=](bool) { this->ok(); });
auto *button_cancel = buttons->addButton(QDialogButtonBox::Cancel);
QObject::connect(button_cancel, &QAbstractButton::clicked, [=](bool) { this->close(); });
QObject::connect(button_cancel, &QAbstractButton::clicked,
[=](bool) { this->close(); });
}
this->setScaleIndependantSize(300, 210);
@@ -133,7 +149,8 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
auto *shortcut_ok = new QShortcut(QKeySequence("Return"), this);
QObject::connect(shortcut_ok, &QShortcut::activated, [=] { this->ok(); });
auto *shortcut_cancel = new QShortcut(QKeySequence("Esc"), this);
QObject::connect(shortcut_cancel, &QShortcut::activated, [=] { this->close(); });
QObject::connect(shortcut_cancel, &QShortcut::activated,
[=] { this->close(); });
}
void SelectChannelDialog::ok()
@@ -188,7 +205,8 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
switch (this->ui_.notebook->getSelectedIndex()) {
case TAB_TWITCH: {
if (this->ui_.twitch.channel->isChecked()) {
return app->twitch.server->getOrAddChannel(this->ui_.twitch.channelName->text());
return app->twitch.server->getOrAddChannel(
this->ui_.twitch.channelName->text());
} else if (this->ui_.twitch.watching->isChecked()) {
return app->twitch.server->watchingChannel;
} else if (this->ui_.twitch.mentions->isChecked()) {
@@ -207,7 +225,8 @@ bool SelectChannelDialog::hasSeletedChannel() const
return this->hasSelectedChannel_;
}
bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *event)
bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
QEvent *event)
{
auto *widget = (QWidget *)watched;
@@ -225,7 +244,8 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *eve
return false;
} else if (event->type() == QEvent::KeyPress) {
QKeyEvent *event_key = static_cast<QKeyEvent *>(event);
if ((event_key->key() == Qt::Key_Tab || event_key->key() == Qt::Key_Down) &&
if ((event_key->key() == Qt::Key_Tab ||
event_key->key() == Qt::Key_Down) &&
event_key->modifiers() == Qt::NoModifier) {
if (widget == this->dialog->ui_.twitch.channelName) {
this->dialog->ui_.twitch.whispers->setFocus();
@@ -234,9 +254,11 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *eve
widget->nextInFocusChain()->setFocus();
}
return true;
} else if (((event_key->key() == Qt::Key_Tab || event_key->key() == Qt::Key_Backtab) &&
} else if (((event_key->key() == Qt::Key_Tab ||
event_key->key() == Qt::Key_Backtab) &&
event_key->modifiers() == Qt::ShiftModifier) ||
((event_key->key() == Qt::Key_Up) && event_key->modifiers() == Qt::NoModifier)) {
((event_key->key() == Qt::Key_Up) &&
event_key->modifiers() == Qt::NoModifier)) {
if (widget == this->dialog->ui_.twitch.channelName) {
this->dialog->ui_.twitch.watching->setFocus();
return true;
@@ -253,7 +275,8 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *eve
return true;
} else if (event->type() == QEvent::KeyRelease) {
QKeyEvent *event_key = static_cast<QKeyEvent *>(event);
if ((event_key->key() == Qt::Key_Backtab || event_key->key() == Qt::Key_Down) &&
if ((event_key->key() == Qt::Key_Backtab ||
event_key->key() == Qt::Key_Down) &&
event_key->modifiers() == Qt::NoModifier) {
return true;
}
@@ -272,9 +295,11 @@ void SelectChannelDialog::themeChangedEvent()
BaseWindow::themeChangedEvent();
if (this->theme->isLightTheme()) {
this->setStyleSheet("QRadioButton { color: #000 } QLabel { color: #000 }");
this->setStyleSheet(
"QRadioButton { color: #000 } QLabel { color: #000 }");
} else {
this->setStyleSheet("QRadioButton { color: #fff } QLabel { color: #fff }");
this->setStyleSheet(
"QRadioButton { color: #fff } QLabel { color: #fff }");
}
}