Chore: Proper Lambda Formatting (#2167)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Leon Richardt
2020-11-08 12:02:19 +01:00
committed by GitHub
parent fbd5df53d8
commit 0eed45ae67
71 changed files with 712 additions and 415 deletions
@@ -71,7 +71,7 @@ ExternalToolsPage::ExternalToolsPage()
getSettings()->streamlinkUseCustomPath.connect(
[=](const auto &value, auto) {
customPath->setEnabled(value); //
customPath->setEnabled(value);
},
this->managedConnections_);
}
+73 -23
View File
@@ -110,13 +110,22 @@ void GeneralPage::initLayout(GeneralPageView &layout)
getApp()->themes->themeName);
layout.addDropdown<QString>(
"Font", {"Segoe UI", "Arial", "Choose..."},
getApp()->fonts->chatFontFamily, [](auto val) { return val; },
[this](auto args) { return this->getFont(args); });
getApp()->fonts->chatFontFamily,
[](auto val) {
return val;
},
[this](auto args) {
return this->getFont(args);
});
layout.addDropdown<int>(
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
getApp()->fonts->chatFontSize,
[](auto val) { return QString::number(val) + "pt"; },
[](auto args) { return fuzzyToInt(args.value, 10); });
[](auto val) {
return QString::number(val) + "pt";
},
[](auto args) {
return fuzzyToInt(args.value, 10);
});
layout.addDropdown<float>(
"Zoom",
{"0.5x", "0.6x", "0.7x", "0.8x", "0.9x", "Default", "1.2x", "1.4x",
@@ -128,7 +137,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
else
return QString::number(val) + "x";
},
[](auto args) { return fuzzyToFloat(args.value, 1.f); });
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
});
layout.addDropdown<int>(
"Tab layout", {"Horizontal", "Vertical"}, s.tabDirection,
[](auto val) {
@@ -201,7 +212,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
else
return QString::number(val) + "x";
},
[](auto args) { return fuzzyToFloat(args.value, 1.f); });
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
});
layout.addCheckbox("Smooth scrolling", s.enableSmoothScrolling);
layout.addCheckbox("Smooth scrolling on new messages",
s.enableSmoothScrollingNewMessages);
@@ -266,7 +279,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
[](auto val) {
return val ? QString::number(val) + " lines" : QString("Never");
},
[](auto args) { return fuzzyToInt(args.value, 0); });
[](auto args) {
return fuzzyToInt(args.value, 0);
});
layout.addTitle("Emotes");
layout.addCheckbox("Enable", s.enableEmoteImages);
@@ -284,12 +299,20 @@ void GeneralPage::initLayout(GeneralPageView &layout)
else
return QString::number(val) + "x";
},
[](auto args) { return fuzzyToFloat(args.value, 1.f); });
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
});
layout.addDropdown<int>(
"Show info on hover", {"Don't show", "Always show", "Hold shift"},
s.emotesTooltipPreview, [](int index) { return index; },
[](auto args) { return args.index; }, false);
s.emotesTooltipPreview,
[](int index) {
return index;
},
[](auto args) {
return args.index;
},
false);
layout.addDropdown("Emoji style",
{"EmojiOne 2", "EmojiOne 3", "Twitter", "Facebook",
"Apple", "Google", "Messenger"},
@@ -304,7 +327,10 @@ void GeneralPage::initLayout(GeneralPageView &layout)
ComboBox *dankDropdown =
layout.addDropdown<std::underlying_type<StreamerModeSetting>::type>(
"Enable Streamer Mode", {"No", "Yes", "Detect OBS (Windows only)"},
s.enableStreamerMode, [](int value) { return value; },
s.enableStreamerMode,
[](int value) {
return value;
},
[](DropdownArgs args) {
return static_cast<StreamerModeSetting>(args.index);
},
@@ -445,8 +471,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
box->addWidget(layout.makeButton("Choose cache path", [this]() {
getSettings()->cachePath = QFileDialog::getExistingDirectory(this);
}));
box->addWidget(layout.makeButton(
"Reset", []() { getSettings()->cachePath = ""; }));
box->addWidget(layout.makeButton("Reset", []() {
getSettings()->cachePath = "";
}));
box->addStretch(1);
layout.addLayout(box);
@@ -471,21 +498,36 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addCheckbox("Receive notification sounds from hidden messages",
s.shownSimilarTriggerHighlights);
s.hideSimilar.connect(
[]() { getApp()->windows->forceLayoutChannelViews(); }, false);
[]() {
getApp()->windows->forceLayoutChannelViews();
},
false);
layout.addDropdown<float>(
"Similarity threshold", {"0.5", "0.75", "0.9"}, s.similarityPercentage,
[](auto val) { return QString::number(val); },
[](auto args) { return fuzzyToFloat(args.value, 0.9f); });
[](auto val) {
return QString::number(val);
},
[](auto args) {
return fuzzyToFloat(args.value, 0.9f);
});
layout.addDropdown<int>(
"Maximum delay between messages",
{"5s", "10s", "15s", "30s", "60s", "120s"}, s.hideSimilarMaxDelay,
[](auto val) { return QString::number(val) + "s"; },
[](auto args) { return fuzzyToInt(args.value, 5); });
[](auto val) {
return QString::number(val) + "s";
},
[](auto args) {
return fuzzyToInt(args.value, 5);
});
layout.addDropdown<int>(
"Amount of previous messages to check", {"1", "2", "3", "4", "5"},
s.hideSimilarMaxMessagesToCheck,
[](auto val) { return QString::number(val); },
[](auto args) { return fuzzyToInt(args.value, 3); });
[](auto val) {
return QString::number(val);
},
[](auto args) {
return fuzzyToInt(args.value, 3);
});
layout.addSubtitle("Visible badges");
layout.addCheckbox("Authority (staff, admin)",
@@ -540,7 +582,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
else
return QString::number(val);
},
[](auto args) { return fuzzyToFloat(args.value, 63.f); });
[](auto args) {
return fuzzyToFloat(args.value, 63.f);
});
layout.addCheckbox("Double click to open links and other elements in chat",
s.linksDoubleClickOnly);
layout.addCheckbox("Unshorten links", s.unshortLinks);
@@ -563,8 +607,14 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.showUnhandledIrcMessages);
layout.addDropdown<int>(
"Stack timeouts", {"Stack", "Stack until timeout", "Don't stack"},
s.timeoutStackStyle, [](int index) { return index; },
[](auto args) { return args.index; }, false);
s.timeoutStackStyle,
[](int index) {
return index;
},
[](auto args) {
return args.index;
},
false);
layout.addCheckbox("Combine multiple bit tips into one", s.stackBits);
layout.addCheckbox("Ask for confirmation when uploading an image",
s.askOnImageUpload);
+10 -5
View File
@@ -27,7 +27,9 @@ GeneralPageView::GeneralPageView(QWidget *parent)
{scrollArea, new QSpacerItem(16, 1), navigation}));
QObject::connect(scrollArea->verticalScrollBar(), &QScrollBar::valueChanged,
this, [=] { this->updateNavigationHighlighting(); });
this, [=] {
this->updateNavigationHighlighting();
});
}
void GeneralPageView::addWidget(QWidget *widget)
@@ -96,9 +98,10 @@ QCheckBox *GeneralPageView::addCheckbox(const QString &text,
this->managedConnections_);
// update setting on toggle
QObject::connect(
check, &QCheckBox::toggled, this,
[&setting, inverse](bool state) { setting = inverse ^ state; });
QObject::connect(check, &QCheckBox::toggled, this,
[&setting, inverse](bool state) {
setting = inverse ^ state;
});
this->addWidget(check);
@@ -141,7 +144,9 @@ ComboBox *GeneralPageView::addDropdown(
// update when setting changes
setting.connect(
[combo](const QString &value, auto) { combo->setCurrentText(value); },
[combo](const QString &value, auto) {
combo->setCurrentText(value);
},
this->managedConnections_);
QObject::connect(combo, &QComboBox::currentTextChanged,
+3 -2
View File
@@ -86,8 +86,9 @@ void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
auto &setting = getSettings()->showIgnoredUsersMessages;
setting.connect(
[combo](const int value) { combo->setCurrentIndex(value); });
setting.connect([combo](const int value) {
combo->setCurrentIndex(value);
});
QObject::connect(combo,
QOverload<int>::of(&QComboBox::currentIndexChanged),
+16 -13
View File
@@ -120,21 +120,23 @@ ModerationPage::ModerationPage()
// Show how big (size-wise) the logs are
auto logsPathSizeLabel = logs.emplace<QLabel>();
logsPathSizeLabel->setText(
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
logsPathSizeLabel->setText(QtConcurrent::run([] {
return fetchLogDirectorySize();
}));
// Select event
QObject::connect(
selectDir.getElement(), &QPushButton::clicked, this,
[this, logsPathSizeLabel]() mutable {
auto dirName = QFileDialog::getExistingDirectory(this);
QObject::connect(selectDir.getElement(), &QPushButton::clicked, this,
[this, logsPathSizeLabel]() mutable {
auto dirName =
QFileDialog::getExistingDirectory(this);
getSettings()->logPath = dirName;
getSettings()->logPath = dirName;
// Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText(
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
});
// Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText(QtConcurrent::run([] {
return fetchLogDirectorySize();
}));
});
buttons->addSpacing(16);
@@ -144,8 +146,9 @@ ModerationPage::ModerationPage()
getSettings()->logPath = "";
// Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText(QtConcurrent::run(
[] { return fetchLogDirectorySize(); }));
logsPathSizeLabel->setText(QtConcurrent::run([] {
return fetchLogDirectorySize();
}));
});
} // logs end
+18 -10
View File
@@ -96,7 +96,7 @@ QCheckBox *SettingsPage::createCheckBox(
// update when setting changes
setting.connect(
[checkbox](const bool &value, auto) {
checkbox->setChecked(value); //
checkbox->setChecked(value);
},
this->managedConnections_);
@@ -120,12 +120,15 @@ QComboBox *SettingsPage::createComboBox(
// update when setting changes
setting.connect(
[combo](const QString &value, auto) { combo->setCurrentText(value); },
[combo](const QString &value, auto) {
combo->setCurrentText(value);
},
this->managedConnections_);
QObject::connect(
combo, &QComboBox::currentTextChanged,
[&setting](const QString &newValue) { setting = newValue; });
QObject::connect(combo, &QComboBox::currentTextChanged,
[&setting](const QString &newValue) {
setting = newValue;
});
return combo;
}
@@ -138,9 +141,10 @@ QLineEdit *SettingsPage::createLineEdit(
edit->setText(setting);
// update when setting changes
QObject::connect(
edit, &QLineEdit::textChanged,
[&setting](const QString &newValue) { setting = newValue; });
QObject::connect(edit, &QLineEdit::textChanged,
[&setting](const QString &newValue) {
setting = newValue;
});
return edit;
}
@@ -153,9 +157,13 @@ QSpinBox *SettingsPage::createSpinBox(pajlada::Settings::Setting<int> &setting,
w->setMinimum(min);
w->setMaximum(max);
setting.connect([w](const int &value, auto) { w->setValue(value); });
setting.connect([w](const int &value, auto) {
w->setValue(value);
});
QObject::connect(w, QOverload<int>::of(&QSpinBox::valueChanged),
[&setting](int value) { setting.setValue(value); });
[&setting](int value) {
setting.setValue(value);
});
return w;
}