refactor: fix clang-tidy auto*, const&, and curly braces (#5083)

This commit is contained in:
pajlada
2024-01-14 17:54:52 +01:00
committed by GitHub
parent 292f9b9734
commit 5b6675abb4
78 changed files with 647 additions and 228 deletions
+75 -7
View File
@@ -89,12 +89,12 @@ namespace {
GeneralPage::GeneralPage()
{
auto y = new QVBoxLayout;
auto x = new QHBoxLayout;
auto view = new GeneralPageView;
auto *y = new QVBoxLayout;
auto *x = new QHBoxLayout;
auto *view = new GeneralPageView;
this->view_ = view;
x->addWidget(view);
auto z = new QFrame;
auto *z = new QFrame;
z->setLayout(x);
y->addWidget(z);
this->setLayout(y);
@@ -107,9 +107,13 @@ GeneralPage::GeneralPage()
bool GeneralPage::filterElements(const QString &query)
{
if (this->view_)
{
return this->view_->filterElements(query) || query.isEmpty();
}
else
{
return false;
}
}
void GeneralPage::initLayout(GeneralPageView &layout)
@@ -154,9 +158,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.uiScale,
[](auto val) {
if (val == 1)
{
return QString("Default");
}
else
{
return QString::number(val) + "x";
}
},
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
@@ -280,20 +288,32 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.pauseOnHoverDuration,
[](auto val) {
if (val < -0.5f)
{
return QString("Indefinite");
}
else if (val < 0.001f)
{
return QString("Disabled");
}
else
{
return QString::number(val) + "s";
}
},
[](auto args) {
if (args.index == 0)
{
return 0.0f;
}
else if (args.value == "Indefinite")
{
return -1.0f;
}
else
{
return fuzzyToFloat(args.value,
std::numeric_limits<float>::infinity());
}
});
addKeyboardModifierSetting(layout, "Pause while holding a key",
s.pauseChatModifier);
@@ -302,9 +322,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.mouseScrollMultiplier,
[](auto val) {
if (val == 1)
{
return QString("Default");
}
else
{
return QString::number(val) + "x";
}
},
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
@@ -492,9 +516,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.emoteScale,
[](auto val) {
if (val == 1)
{
return QString("Default");
}
else
{
return QString::number(val) + "x";
}
},
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
@@ -631,23 +659,39 @@ void GeneralPage::initLayout(GeneralPageView &layout)
{"Off", "Small", "Medium", "Large"}, s.thumbnailSize,
[](auto val) {
if (val == 0)
{
return QString("Off");
}
else if (val == 100)
{
return QString("Small");
}
else if (val == 200)
{
return QString("Medium");
}
else if (val == 300)
{
return QString("Large");
}
else
{
return QString::number(val);
}
},
[](auto args) {
if (args.value == "Small")
{
return 100;
}
else if (args.value == "Medium")
{
return 200;
}
else if (args.value == "Large")
{
return 300;
}
return fuzzyToInt(args.value, 0);
});
@@ -656,23 +700,39 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.thumbnailSizeStream,
[](auto val) {
if (val == 0)
{
return QString("Off");
}
else if (val == 1)
{
return QString("Small");
}
else if (val == 2)
{
return QString("Medium");
}
else if (val == 3)
{
return QString("Large");
}
else
{
return QString::number(val);
}
},
[](auto args) {
if (args.value == "Small")
{
return 1;
}
else if (args.value == "Medium")
{
return 2;
}
else if (args.value == "Large")
{
return 3;
}
return fuzzyToInt(args.value, 0);
});
@@ -742,7 +802,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"Files that are used often (such as emotes) are saved to disk to "
"reduce bandwidth usage and to speed up loading.");
auto cachePathLabel = layout.addDescription("placeholder :D");
auto *cachePathLabel = layout.addDescription("placeholder :D");
getSettings()->cachePath.connect([cachePathLabel](const auto &,
auto) mutable {
QString newPath = getPaths()->cacheDirectory();
@@ -756,7 +816,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
// Choose and reset buttons
{
auto box = new QHBoxLayout;
auto *box = new QHBoxLayout;
box->addWidget(layout.makeButton("Choose cache path", [this]() {
getSettings()->cachePath = QFileDialog::getExistingDirectory(this);
@@ -964,9 +1024,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"Username font weight", {"50", "Default", "75", "100"}, s.boldScale,
[](auto val) {
if (val == 63)
{
return QString("Default");
}
else
{
return QString::number(val);
}
},
[](auto args) {
return fuzzyToFloat(args.value, 63.f);
@@ -1156,7 +1220,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addStretch();
// invisible element for width
auto inv = new BaseWidget(this);
auto *inv = new BaseWidget(this);
// inv->setScaleIndependantWidth(600);
layout.addWidget(inv);
}
@@ -1192,9 +1256,13 @@ QString GeneralPage::getFont(const DropdownArgs &args) const
auto font = dialog.getFont(&ok, this->window());
if (ok)
{
return font.family();
}
else
{
return args.combobox->itemText(0);
}
}
return args.value;
}