refactor: fix clang-tidy auto*, const&, and curly braces (#5083)
This commit is contained in:
@@ -14,8 +14,8 @@ BadgePickerDialog::BadgePickerDialog(QList<DisplayBadge> badges,
|
||||
: QDialog(parent)
|
||||
{
|
||||
this->dropdown_ = new QComboBox;
|
||||
auto vbox = new QVBoxLayout(this);
|
||||
auto buttonBox =
|
||||
auto *vbox = new QVBoxLayout(this);
|
||||
auto *buttonBox =
|
||||
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
vbox->addWidget(this->dropdown_);
|
||||
@@ -61,7 +61,9 @@ BadgePickerDialog::BadgePickerDialog(QList<DisplayBadge> badges,
|
||||
badges,
|
||||
[&dropdown = this->dropdown_](QString identifier, const QIconPtr icon) {
|
||||
if (!dropdown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int index = dropdown->findData(identifier);
|
||||
if (index != -1)
|
||||
|
||||
@@ -21,16 +21,16 @@ namespace {
|
||||
ChannelFilterEditorDialog::ChannelFilterEditorDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
auto vbox = new QVBoxLayout(this);
|
||||
auto filterVbox = new QVBoxLayout;
|
||||
auto buttonBox = new QHBoxLayout;
|
||||
auto okButton = new QPushButton("Ok");
|
||||
auto cancelButton = new QPushButton("Cancel");
|
||||
auto *vbox = new QVBoxLayout(this);
|
||||
auto *filterVbox = new QVBoxLayout;
|
||||
auto *buttonBox = new QHBoxLayout;
|
||||
auto *okButton = new QPushButton("Ok");
|
||||
auto *cancelButton = new QPushButton("Cancel");
|
||||
|
||||
okButton->setDefault(true);
|
||||
cancelButton->setDefault(false);
|
||||
|
||||
auto helpLabel =
|
||||
auto *helpLabel =
|
||||
new QLabel(QString("<a href='%1'><span "
|
||||
"style='color:#99f'>variable help</span></a>")
|
||||
.arg("https://wiki.chatterino.com/Filters/#variables"));
|
||||
@@ -55,16 +55,16 @@ ChannelFilterEditorDialog::ChannelFilterEditorDialog(QWidget *parent)
|
||||
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
|
||||
this->setWindowTitle("Channel Filter Creator");
|
||||
|
||||
auto titleInput = new QLineEdit;
|
||||
auto *titleInput = new QLineEdit;
|
||||
titleInput->setPlaceholderText("Filter name");
|
||||
titleInput->setText("My filter");
|
||||
|
||||
this->titleInput_ = titleInput;
|
||||
filterVbox->addWidget(titleInput);
|
||||
|
||||
auto left = new ChannelFilterEditorDialog::ValueSpecifier;
|
||||
auto right = new ChannelFilterEditorDialog::ValueSpecifier;
|
||||
auto exp =
|
||||
auto *left = new ChannelFilterEditorDialog::ValueSpecifier;
|
||||
auto *right = new ChannelFilterEditorDialog::ValueSpecifier;
|
||||
auto *exp =
|
||||
new ChannelFilterEditorDialog::BinaryOperationSpecifier(left, right);
|
||||
|
||||
this->expressionSpecifier_ = exp;
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace Ui {
|
||||
|
||||
class IrcConnectionEditor;
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -22,6 +22,10 @@ class IrcConnectionEditor : public QDialog
|
||||
public:
|
||||
explicit IrcConnectionEditor(const IrcServerData &data, bool isAdd = false,
|
||||
QWidget *parent = nullptr);
|
||||
IrcConnectionEditor(const IrcConnectionEditor &) = delete;
|
||||
IrcConnectionEditor(IrcConnectionEditor &&) = delete;
|
||||
IrcConnectionEditor &operator=(const IrcConnectionEditor &) = delete;
|
||||
IrcConnectionEditor &operator=(IrcConnectionEditor &&) = delete;
|
||||
~IrcConnectionEditor() override;
|
||||
|
||||
IrcServerData data();
|
||||
|
||||
@@ -171,7 +171,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
QWidget::setTabOrder(live_btn.getElement(), automod_btn.getElement());
|
||||
|
||||
// tab
|
||||
auto tab = notebook->addPage(obj.getElement());
|
||||
auto *tab = notebook->addPage(obj.getElement());
|
||||
tab->setCustomTitle("Twitch");
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
auto outerBox = obj.setLayoutType<QFormLayout>();
|
||||
|
||||
{
|
||||
auto view = this->ui_.irc.servers =
|
||||
auto *view = this->ui_.irc.servers =
|
||||
new EditableModelView(Irc::instance().newConnectionModel(this));
|
||||
|
||||
view->setTitles({"host", "port", "ssl", "user", "nick", "real",
|
||||
@@ -199,7 +199,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
auto unique = IrcServerData{};
|
||||
unique.id = Irc::instance().uniqueId();
|
||||
|
||||
auto editor = new IrcConnectionEditor(unique);
|
||||
auto *editor = new IrcConnectionEditor(unique);
|
||||
if (editor->exec() == QDialog::Accepted)
|
||||
{
|
||||
Irc::instance().connections.append(editor->data());
|
||||
@@ -209,7 +209,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
QObject::connect(
|
||||
view->getTableView(), &QTableView::doubleClicked,
|
||||
[](const QModelIndex &index) {
|
||||
auto editor = new IrcConnectionEditor(
|
||||
auto *editor = new IrcConnectionEditor(
|
||||
Irc::instance().connections.raw()[size_t(index.row())]);
|
||||
|
||||
if (editor->exec() == QDialog::Accepted)
|
||||
@@ -235,7 +235,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
|
||||
outerBox->addRow("Channel: #", this->ui_.irc.channel = new QLineEdit);
|
||||
|
||||
auto tab = notebook->addPage(obj.getElement());
|
||||
auto *tab = notebook->addPage(obj.getElement());
|
||||
tab->setCustomTitle("Irc (Beta)");
|
||||
|
||||
if (!getSettings()->enableExperimentalIrc)
|
||||
@@ -338,10 +338,10 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
||||
this->ui_.notebook->selectIndex(TAB_IRC);
|
||||
this->ui_.irc.channel->setText(_channel.get()->getName());
|
||||
|
||||
if (auto ircChannel =
|
||||
if (auto *ircChannel =
|
||||
dynamic_cast<IrcChannel *>(_channel.get().get()))
|
||||
{
|
||||
if (auto server = ircChannel->server())
|
||||
if (auto *server = ircChannel->server())
|
||||
{
|
||||
int i = 0;
|
||||
for (auto &&conn : Irc::instance().connections)
|
||||
@@ -375,7 +375,7 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
||||
return this->selectedChannel_;
|
||||
}
|
||||
|
||||
auto app = getApp();
|
||||
auto *app = getApp();
|
||||
|
||||
switch (this->ui_.notebook->getSelectedIndex())
|
||||
{
|
||||
|
||||
@@ -15,16 +15,16 @@ SelectChannelFiltersDialog::SelectChannelFiltersDialog(
|
||||
const QList<QUuid> &previousSelection, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
auto vbox = new QVBoxLayout(this);
|
||||
auto itemVbox = new QVBoxLayout;
|
||||
auto buttonBox = new QHBoxLayout;
|
||||
auto okButton = new QPushButton("Ok");
|
||||
auto cancelButton = new QPushButton("Cancel");
|
||||
auto *vbox = new QVBoxLayout(this);
|
||||
auto *itemVbox = new QVBoxLayout;
|
||||
auto *buttonBox = new QHBoxLayout;
|
||||
auto *okButton = new QPushButton("Ok");
|
||||
auto *cancelButton = new QPushButton("Cancel");
|
||||
|
||||
auto scrollAreaContent = new QWidget;
|
||||
auto *scrollAreaContent = new QWidget;
|
||||
scrollAreaContent->setLayout(itemVbox);
|
||||
|
||||
auto scrollArea = new QScrollArea;
|
||||
auto *scrollArea = new QScrollArea;
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
scrollArea->setWidget(scrollAreaContent);
|
||||
@@ -53,14 +53,14 @@ SelectChannelFiltersDialog::SelectChannelFiltersDialog(
|
||||
|
||||
if (availableFilters->size() == 0)
|
||||
{
|
||||
auto text = new QLabel("No filters defined");
|
||||
auto *text = new QLabel("No filters defined");
|
||||
itemVbox->addWidget(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto &f : *availableFilters)
|
||||
{
|
||||
auto checkbox = new QCheckBox(f->getName(), this);
|
||||
auto *checkbox = new QCheckBox(f->getName(), this);
|
||||
bool alreadySelected = previousSelection.contains(f->getId());
|
||||
checkbox->setCheckState(alreadySelected
|
||||
? Qt::CheckState::Checked
|
||||
|
||||
@@ -190,8 +190,8 @@ void SettingsDialog::filterElements(const QString &text)
|
||||
|
||||
for (int i = 0; i < this->ui_.tabContainer->count(); i++)
|
||||
{
|
||||
auto item = this->ui_.tabContainer->itemAt(i);
|
||||
if (auto x = dynamic_cast<QSpacerItem *>(item); x)
|
||||
auto *item = this->ui_.tabContainer->itemAt(i);
|
||||
if (auto *x = dynamic_cast<QSpacerItem *>(item); x)
|
||||
{
|
||||
x->changeSize(10, shouldShowSpace ? int(16 * this->scale()) : 0);
|
||||
shouldShowSpace = false;
|
||||
@@ -257,7 +257,8 @@ void SettingsDialog::addTab(std::function<SettingsPage *()> page,
|
||||
const QString &name, const QString &iconPath,
|
||||
SettingsTabId id, Qt::Alignment alignment)
|
||||
{
|
||||
auto tab = new SettingsDialogTab(this, std::move(page), name, iconPath, id);
|
||||
auto *tab =
|
||||
new SettingsDialogTab(this, std::move(page), name, iconPath, id);
|
||||
tab->setFixedHeight(static_cast<int>(30 * this->dpi_));
|
||||
|
||||
this->ui_.tabContainer->addWidget(tab, 0, alignment);
|
||||
@@ -274,8 +275,12 @@ void SettingsDialog::selectTab(SettingsDialogTab *tab, bool byUser)
|
||||
// add page if it's not been added yet
|
||||
[&] {
|
||||
for (int i = 0; i < this->ui_.pageStack->count(); i++)
|
||||
{
|
||||
if (this->ui_.pageStack->itemAt(i)->widget() == tab->page())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this->ui_.pageStack->addWidget(tab->page());
|
||||
}();
|
||||
@@ -301,10 +306,12 @@ void SettingsDialog::selectTab(SettingsDialogTab *tab, bool byUser)
|
||||
|
||||
void SettingsDialog::selectTab(SettingsTabId id)
|
||||
{
|
||||
auto t = this->tab(id);
|
||||
auto *t = this->tab(id);
|
||||
assert(t);
|
||||
if (!t)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->selectTab(t);
|
||||
}
|
||||
@@ -312,8 +319,12 @@ void SettingsDialog::selectTab(SettingsTabId id)
|
||||
SettingsDialogTab *SettingsDialog::tab(SettingsTabId id)
|
||||
{
|
||||
for (auto &&tab : this->tabs_)
|
||||
{
|
||||
if (tab->id() == id)
|
||||
{
|
||||
return tab;
|
||||
}
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return nullptr;
|
||||
@@ -325,7 +336,9 @@ void SettingsDialog::showDialog(QWidget *parent,
|
||||
static SettingsDialog *instance = new SettingsDialog(parent);
|
||||
static bool hasShownBefore = false;
|
||||
if (hasShownBefore)
|
||||
{
|
||||
instance->refresh();
|
||||
}
|
||||
hasShownBefore = true;
|
||||
|
||||
switch (preferredTab)
|
||||
@@ -335,10 +348,10 @@ void SettingsDialog::showDialog(QWidget *parent,
|
||||
break;
|
||||
|
||||
case SettingsDialogPreference::ModerationActions:
|
||||
if (auto tab = instance->tab(SettingsTabId::Moderation))
|
||||
if (auto *tab = instance->tab(SettingsTabId::Moderation))
|
||||
{
|
||||
instance->selectTab(tab);
|
||||
if (auto page = dynamic_cast<ModerationPage *>(tab->page()))
|
||||
if (auto *page = dynamic_cast<ModerationPage *>(tab->page()))
|
||||
{
|
||||
page->selectModerationActions();
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ UpdateDialog::UpdateDialog()
|
||||
.assign(&this->ui_.label);
|
||||
|
||||
auto buttons = layout.emplace<QDialogButtonBox>();
|
||||
auto install = buttons->addButton("Install", QDialogButtonBox::AcceptRole);
|
||||
auto *install = buttons->addButton("Install", QDialogButtonBox::AcceptRole);
|
||||
this->ui_.installButton = install;
|
||||
auto dismiss = buttons->addButton("Dismiss", QDialogButtonBox::RejectRole);
|
||||
auto *dismiss = buttons->addButton("Dismiss", QDialogButtonBox::RejectRole);
|
||||
|
||||
QObject::connect(install, &QPushButton::clicked, this, [this] {
|
||||
Updates::instance().installUpdates();
|
||||
|
||||
@@ -75,7 +75,9 @@ namespace {
|
||||
bool checkMessageUserName(const QString &userName, MessagePtr message)
|
||||
{
|
||||
if (message->flags.has(MessageFlag::Whisper))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isSubscription = message->flags.has(MessageFlag::Subscription) &&
|
||||
message->loginName.isEmpty() &&
|
||||
@@ -296,12 +298,12 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
|
||||
menu->addAction(
|
||||
"Open channel in a new popup window", this,
|
||||
[loginName] {
|
||||
auto app = getApp();
|
||||
auto *app = getApp();
|
||||
auto &window = app->windows->createWindow(
|
||||
WindowType::Popup, true);
|
||||
auto split = window.getNotebook()
|
||||
.getOrAddSelectedPage()
|
||||
->appendNewSplit(false);
|
||||
auto *split = window.getNotebook()
|
||||
.getOrAddSelectedPage()
|
||||
->appendNewSplit(false);
|
||||
split->setChannel(app->twitch->getOrAddChannel(
|
||||
loginName.toLower()));
|
||||
});
|
||||
@@ -771,7 +773,9 @@ void UserInfoPopup::updateLatestMessages()
|
||||
this->underlyingChannel_->messageAppended.connect(
|
||||
[this, hasMessages](auto message, auto) {
|
||||
if (!checkMessageUserName(this->userName_, message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasMessages)
|
||||
{
|
||||
@@ -961,7 +965,7 @@ void UserInfoPopup::updateUserData()
|
||||
void UserInfoPopup::loadAvatar(const QUrl &url)
|
||||
{
|
||||
QNetworkRequest req(url);
|
||||
static auto manager = new QNetworkAccessManager();
|
||||
static auto *manager = new QNetworkAccessManager();
|
||||
auto *reply = manager->get(req);
|
||||
|
||||
QObject::connect(reply, &QNetworkReply::finished, this, [=, this] {
|
||||
|
||||
Reference in New Issue
Block a user