refactor: fix clang-tidy auto*, const&, and curly braces (#5083)
This commit is contained in:
@@ -203,7 +203,7 @@ AboutPage::AboutPage()
|
||||
|
||||
const auto addLabels = [&contributorBox2, &usernameLabel,
|
||||
&roleLabel] {
|
||||
auto labelBox = new QVBoxLayout();
|
||||
auto *labelBox = new QVBoxLayout();
|
||||
contributorBox2->addLayout(labelBox);
|
||||
|
||||
labelBox->addWidget(usernameLabel);
|
||||
@@ -236,7 +236,7 @@ void AboutPage::addLicense(QFormLayout *form, const QString &name,
|
||||
parent);
|
||||
window->setWindowTitle("Chatterino - License for " + name);
|
||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
auto layout = new QVBoxLayout();
|
||||
auto *layout = new QVBoxLayout();
|
||||
auto *edit = new QTextEdit;
|
||||
|
||||
QFile file(licenseLink);
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace {
|
||||
|
||||
CommandPage::CommandPage()
|
||||
{
|
||||
auto app = getApp();
|
||||
auto *app = getApp();
|
||||
|
||||
LayoutCreator<CommandPage> layoutCreator(this);
|
||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||
@@ -54,7 +54,7 @@ CommandPage::CommandPage()
|
||||
// TODO: asyncronously check path
|
||||
if (QFile(c1settingsPath()).exists())
|
||||
{
|
||||
auto button = new QPushButton("Import commands from Chatterino 1");
|
||||
auto *button = new QPushButton("Import commands from Chatterino 1");
|
||||
view->addCustomButton(button);
|
||||
|
||||
QObject::connect(button, &QPushButton::clicked, this, [] {
|
||||
|
||||
@@ -54,7 +54,7 @@ FiltersPage::FiltersPage()
|
||||
}
|
||||
});
|
||||
|
||||
auto quickAddButton = new QPushButton("Quick Add");
|
||||
auto *quickAddButton = new QPushButton("Quick Add");
|
||||
QObject::connect(quickAddButton, &QPushButton::pressed, [] {
|
||||
getSettings()->filterRecords.append(std::make_shared<FilterRecord>(
|
||||
"My filter", "message.content contains \"hello\""));
|
||||
@@ -66,7 +66,7 @@ FiltersPage::FiltersPage()
|
||||
this->tableCellClicked(clicked, view);
|
||||
});
|
||||
|
||||
auto filterHelpLabel =
|
||||
auto *filterHelpLabel =
|
||||
new QLabel(QString("<a href='%1'><span "
|
||||
"style='color:#99f'>filter info</span></a>")
|
||||
.arg(FILTERS_DOCUMENTATION));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace chatterino {
|
||||
GeneralPageView::GeneralPageView(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
auto scrollArea = this->contentScrollArea_ =
|
||||
auto *scrollArea = this->contentScrollArea_ =
|
||||
makeScrollArea(this->contentLayout_ = new QVBoxLayout);
|
||||
scrollArea->setObjectName("generalSettingsScrollContent");
|
||||
|
||||
auto navigation =
|
||||
auto *navigation =
|
||||
wrapLayout(this->navigationLayout_ = makeLayout<QVBoxLayout>({}));
|
||||
navigation->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
||||
this->navigationLayout_->setAlignment(Qt::AlignTop);
|
||||
@@ -63,14 +63,16 @@ TitleLabel *GeneralPageView::addTitle(const QString &title)
|
||||
{
|
||||
// space
|
||||
if (!this->groups_.empty())
|
||||
{
|
||||
this->addWidget(this->groups_.back().space = new Space);
|
||||
}
|
||||
|
||||
// title
|
||||
auto label = new TitleLabel(title + ":");
|
||||
auto *label = new TitleLabel(title + ":");
|
||||
this->addWidget(label);
|
||||
|
||||
// navigation item
|
||||
auto navLabel = new NavigationLabel(title);
|
||||
auto *navLabel = new NavigationLabel(title);
|
||||
navLabel->setCursor(Qt::PointingHandCursor);
|
||||
this->navigationLayout_->addWidget(navLabel);
|
||||
|
||||
@@ -82,14 +84,16 @@ TitleLabel *GeneralPageView::addTitle(const QString &title)
|
||||
this->groups_.push_back(Group{title, label, navLabel, nullptr, {}});
|
||||
|
||||
if (this->groups_.size() == 1)
|
||||
{
|
||||
this->updateNavigationHighlighting();
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
SubtitleLabel *GeneralPageView::addSubtitle(const QString &title)
|
||||
{
|
||||
auto label = new SubtitleLabel(title + ":");
|
||||
auto *label = new SubtitleLabel(title + ":");
|
||||
this->addWidget(label);
|
||||
|
||||
this->groups_.back().widgets.push_back({label, {title}});
|
||||
@@ -101,7 +105,7 @@ QCheckBox *GeneralPageView::addCheckbox(const QString &text,
|
||||
BoolSetting &setting, bool inverse,
|
||||
QString toolTipText)
|
||||
{
|
||||
auto check = new QCheckBox(text);
|
||||
auto *check = new QCheckBox(text);
|
||||
this->addToolTip(*check, toolTipText);
|
||||
|
||||
// update when setting changes
|
||||
@@ -151,12 +155,12 @@ ComboBox *GeneralPageView::addDropdown(const QString &text,
|
||||
const QStringList &list,
|
||||
QString toolTipText)
|
||||
{
|
||||
auto layout = new QHBoxLayout;
|
||||
auto combo = new ComboBox;
|
||||
auto *layout = new QHBoxLayout;
|
||||
auto *combo = new ComboBox;
|
||||
combo->setFocusPolicy(Qt::StrongFocus);
|
||||
combo->addItems(list);
|
||||
|
||||
auto label = new QLabel(text + ":");
|
||||
auto *label = new QLabel(text + ":");
|
||||
layout->addWidget(label);
|
||||
layout->addStretch(1);
|
||||
layout->addWidget(combo);
|
||||
@@ -176,10 +180,12 @@ ComboBox *GeneralPageView::addDropdown(
|
||||
pajlada::Settings::Setting<QString> &setting, bool editable,
|
||||
QString toolTipText)
|
||||
{
|
||||
auto combo = this->addDropdown(text, items, toolTipText);
|
||||
auto *combo = this->addDropdown(text, items, toolTipText);
|
||||
|
||||
if (editable)
|
||||
{
|
||||
combo->setEditable(true);
|
||||
}
|
||||
|
||||
// update when setting changes
|
||||
setting.connect(
|
||||
@@ -201,9 +207,9 @@ ColorButton *GeneralPageView::addColorButton(
|
||||
const QString &text, const QColor &color,
|
||||
pajlada::Settings::Setting<QString> &setting, QString toolTipText)
|
||||
{
|
||||
auto colorButton = new ColorButton(color);
|
||||
auto layout = new QHBoxLayout();
|
||||
auto label = new QLabel(text + ":");
|
||||
auto *colorButton = new ColorButton(color);
|
||||
auto *layout = new QHBoxLayout();
|
||||
auto *label = new QLabel(text + ":");
|
||||
|
||||
layout->addWidget(label);
|
||||
layout->addStretch(1);
|
||||
@@ -238,12 +244,12 @@ QSpinBox *GeneralPageView::addIntInput(const QString &text, IntSetting &setting,
|
||||
int min, int max, int step,
|
||||
QString toolTipText)
|
||||
{
|
||||
auto layout = new QHBoxLayout;
|
||||
auto *layout = new QHBoxLayout;
|
||||
|
||||
auto label = new QLabel(text + ":");
|
||||
auto *label = new QLabel(text + ":");
|
||||
this->addToolTip(*label, toolTipText);
|
||||
|
||||
auto input = new QSpinBox;
|
||||
auto *input = new QSpinBox;
|
||||
input->setMinimum(min);
|
||||
input->setMaximum(max);
|
||||
|
||||
@@ -280,7 +286,7 @@ void GeneralPageView::addNavigationSpacing()
|
||||
|
||||
DescriptionLabel *GeneralPageView::addDescription(const QString &text)
|
||||
{
|
||||
auto label = new DescriptionLabel(text);
|
||||
auto *label = new DescriptionLabel(text);
|
||||
|
||||
label->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||
Qt::LinksAccessibleByKeyboard);
|
||||
@@ -310,7 +316,7 @@ bool GeneralPageView::filterElements(const QString &query)
|
||||
bool descriptionMatches{};
|
||||
for (auto &&widget : group.widgets)
|
||||
{
|
||||
if (auto x = dynamic_cast<DescriptionLabel *>(widget.element); x)
|
||||
if (auto *x = dynamic_cast<DescriptionLabel *>(widget.element); x)
|
||||
{
|
||||
if (x->text().contains(query, Qt::CaseInsensitive))
|
||||
{
|
||||
@@ -325,7 +331,9 @@ bool GeneralPageView::filterElements(const QString &query)
|
||||
descriptionMatches)
|
||||
{
|
||||
for (auto &&widget : group.widgets)
|
||||
{
|
||||
widget.element->show();
|
||||
}
|
||||
|
||||
group.title->show();
|
||||
group.navigationLink->show();
|
||||
@@ -342,11 +350,13 @@ bool GeneralPageView::filterElements(const QString &query)
|
||||
|
||||
for (auto &&widget : group.widgets)
|
||||
{
|
||||
if (auto x = dynamic_cast<SubtitleLabel *>(widget.element))
|
||||
if (auto *x = dynamic_cast<SubtitleLabel *>(widget.element))
|
||||
{
|
||||
currentSubtitleSearched = false;
|
||||
if (currentSubtitle)
|
||||
{
|
||||
currentSubtitle->setVisible(currentSubtitleVisible);
|
||||
}
|
||||
|
||||
currentSubtitleVisible = false;
|
||||
currentSubtitle = widget.element;
|
||||
@@ -375,10 +385,14 @@ bool GeneralPageView::filterElements(const QString &query)
|
||||
}
|
||||
|
||||
if (currentSubtitle)
|
||||
{
|
||||
currentSubtitle->setVisible(currentSubtitleVisible);
|
||||
}
|
||||
|
||||
if (group.space)
|
||||
{
|
||||
group.space->setVisible(groupAny);
|
||||
}
|
||||
|
||||
group.title->setVisible(groupAny);
|
||||
group.navigationLink->setVisible(groupAny);
|
||||
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
template <typename OnClick>
|
||||
QPushButton *makeButton(const QString &text, OnClick onClick)
|
||||
{
|
||||
auto button = new QPushButton(text);
|
||||
auto *button = new QPushButton(text);
|
||||
this->groups_.back().widgets.push_back({button, {text}});
|
||||
QObject::connect(button, &QPushButton::clicked, onClick);
|
||||
return button;
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
QPushButton *addButton(const QString &text, OnClick onClick)
|
||||
{
|
||||
auto button = makeButton(text, onClick);
|
||||
auto layout = new QHBoxLayout();
|
||||
auto *layout = new QHBoxLayout();
|
||||
layout->addWidget(button);
|
||||
layout->addStretch(1);
|
||||
this->addLayout(layout);
|
||||
@@ -155,19 +155,25 @@ public:
|
||||
{
|
||||
// QString
|
||||
if (!editable && !items2.contains(boost::get<QString>(selected)))
|
||||
{
|
||||
items2.insert(0, boost::get<QString>(selected));
|
||||
}
|
||||
}
|
||||
|
||||
auto combo = this->addDropdown(text, items2, toolTipText);
|
||||
auto *combo = this->addDropdown(text, items2, toolTipText);
|
||||
if (editable)
|
||||
{
|
||||
combo->setEditable(true);
|
||||
}
|
||||
|
||||
if (selected.which() == 0)
|
||||
{
|
||||
// int
|
||||
auto value = boost::get<int>(selected);
|
||||
if (value >= 0 && value < items2.size())
|
||||
{
|
||||
combo->setCurrentIndex(value);
|
||||
}
|
||||
}
|
||||
else if (selected.which() == 1)
|
||||
{
|
||||
@@ -179,7 +185,9 @@ public:
|
||||
[getValue = std::move(getValue), combo](const T &value, auto) {
|
||||
auto var = getValue(value);
|
||||
if (var.which() == 0)
|
||||
{
|
||||
combo->setCurrentIndex(boost::get<int>(var));
|
||||
}
|
||||
else
|
||||
{
|
||||
combo->setCurrentText(boost::get<QString>(var));
|
||||
|
||||
@@ -67,7 +67,7 @@ HighlightingPage::HighlightingPage()
|
||||
"Message highlights are prioritized over badge highlights "
|
||||
"and user highlights.");
|
||||
|
||||
auto view =
|
||||
auto *view =
|
||||
highlights
|
||||
.emplace<EditableModelView>(
|
||||
(new HighlightModel(nullptr))
|
||||
@@ -170,12 +170,12 @@ HighlightingPage::HighlightingPage()
|
||||
"user badges.\n"
|
||||
"Badge highlights are prioritzed under user and message "
|
||||
"highlights.");
|
||||
auto view = badgeHighlights
|
||||
.emplace<EditableModelView>(
|
||||
(new BadgeHighlightModel(nullptr))
|
||||
->initialized(
|
||||
&getSettings()->highlightedBadges))
|
||||
.getElement();
|
||||
auto *view = badgeHighlights
|
||||
.emplace<EditableModelView>(
|
||||
(new BadgeHighlightModel(nullptr))
|
||||
->initialized(
|
||||
&getSettings()->highlightedBadges))
|
||||
.getElement();
|
||||
view->setTitles({"Name", "Show In\nMentions", "Flash\ntaskbar",
|
||||
"Play\nsound", "Custom\nsound", "Color"});
|
||||
view->getTableView()->horizontalHeader()->setSectionResizeMode(
|
||||
|
||||
@@ -83,7 +83,7 @@ void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
|
||||
{
|
||||
anyways.emplace<QLabel>("Show messages from blocked users:");
|
||||
|
||||
auto combo = anyways.emplace<QComboBox>().getElement();
|
||||
auto *combo = anyways.emplace<QComboBox>().getElement();
|
||||
combo->addItems(
|
||||
{"Never", "If you are Moderator", "If you are Broadcaster"});
|
||||
|
||||
@@ -97,7 +97,9 @@ void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
[&setting](int index) {
|
||||
if (index != -1)
|
||||
{
|
||||
setting = index;
|
||||
}
|
||||
});
|
||||
|
||||
anyways->addStretch(1);
|
||||
|
||||
@@ -43,7 +43,9 @@ QString formatSize(qint64 size)
|
||||
for (i = 0; i < units.size() - 1; i++)
|
||||
{
|
||||
if (outputSize < 1024)
|
||||
{
|
||||
break;
|
||||
}
|
||||
outputSize = outputSize / 1024;
|
||||
}
|
||||
return QString("%0 %1").arg(outputSize, 0, 'f', 2).arg(units[i]);
|
||||
@@ -248,7 +250,7 @@ void ModerationPage::addModerationButtonSettings(
|
||||
const auto valueChanged = [=, this] {
|
||||
const auto index = QObject::sender()->objectName().toInt();
|
||||
|
||||
const auto line = this->durationInputs_[index];
|
||||
auto *const line = this->durationInputs_[index];
|
||||
const auto duration = line->text().toInt();
|
||||
const auto unit = this->unitInputs_[index]->currentText();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user