refactor: fix clang-tidy auto*, const&, and curly braces (#5083)
This commit is contained in:
@@ -16,10 +16,14 @@ namespace {
|
||||
const QSize &size) -> QPixmap
|
||||
{
|
||||
if (resized.size() == size)
|
||||
{
|
||||
return resized;
|
||||
}
|
||||
else
|
||||
{
|
||||
return current.scaled(size, Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -92,11 +96,17 @@ bool Button::getEnableMargin() const
|
||||
qreal Button::getCurrentDimAmount() const
|
||||
{
|
||||
if (this->dimPixmap_ == Dim::None || this->mouseOver_)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (this->dimPixmap_ == Dim::Some)
|
||||
{
|
||||
return 0.7;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.15;
|
||||
}
|
||||
}
|
||||
|
||||
void Button::setBorderColor(const QColor &color)
|
||||
@@ -114,7 +124,9 @@ const QColor &Button::getBorderColor() const
|
||||
void Button::setMenu(std::unique_ptr<QMenu> menu)
|
||||
{
|
||||
if (this->menu_)
|
||||
{
|
||||
this->menu_.release()->deleteLater();
|
||||
}
|
||||
|
||||
this->menu_ = std::move(menu);
|
||||
|
||||
@@ -362,7 +374,9 @@ void Button::onMouseEffectTimeout()
|
||||
void Button::showMenu()
|
||||
{
|
||||
if (!this->menu_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto menuSizeHint = this->menu_->sizeHint();
|
||||
auto point = this->mapToGlobal(
|
||||
|
||||
@@ -56,10 +56,14 @@ void ComboBoxItemDelegate::setModelData(QWidget *editor,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
if (QComboBox *cb = qobject_cast<QComboBox *>(editor))
|
||||
{
|
||||
// save the current text of the combo box as the current value of the
|
||||
// item
|
||||
model->setData(index, cb->currentText(), Qt::EditRole);
|
||||
}
|
||||
else
|
||||
{
|
||||
QStyledItemDelegate::setModelData(editor, model, index);
|
||||
}
|
||||
}
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -53,12 +53,16 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
|
||||
// Remove rows backwards so indices don't shift.
|
||||
std::vector<int> rows;
|
||||
for (auto &&index : selected)
|
||||
{
|
||||
rows.push_back(index.row());
|
||||
}
|
||||
|
||||
std::sort(rows.begin(), rows.end(), std::greater{});
|
||||
|
||||
for (auto &&row : rows)
|
||||
{
|
||||
model_->removeRow(row);
|
||||
}
|
||||
});
|
||||
|
||||
if (movable)
|
||||
@@ -135,7 +139,7 @@ void EditableModelView::addCustomButton(QWidget *widget)
|
||||
|
||||
void EditableModelView::addRegexHelpLink()
|
||||
{
|
||||
auto regexHelpLabel =
|
||||
auto *regexHelpLabel =
|
||||
new QLabel("<a href='"
|
||||
"https://chatterino.com/help/regex'>"
|
||||
"<span style='color:#99f'>regex info</span></a>");
|
||||
@@ -152,7 +156,9 @@ void EditableModelView::moveRow(int dir)
|
||||
(row = selected.at(0).row()) + dir >=
|
||||
this->model_->rowCount(QModelIndex()) ||
|
||||
row + dir < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
model_->moveRows(model_->index(row, 0), row, selected.size(),
|
||||
model_->index(row + dir, 0), row + dir);
|
||||
|
||||
@@ -158,13 +158,15 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (!event->mimeData()->hasFormat("chatterino/split"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event->acceptProposedAction();
|
||||
|
||||
auto e = new QMouseEvent(QMouseEvent::MouseButtonPress,
|
||||
QPointF(this->width() / 2, this->height() / 2),
|
||||
Qt::LeftButton, Qt::LeftButton, {});
|
||||
auto *e = new QMouseEvent(QMouseEvent::MouseButtonPress,
|
||||
QPointF(this->width() / 2, this->height() / 2),
|
||||
Qt::LeftButton, Qt::LeftButton, {});
|
||||
Button::mousePressEvent(e);
|
||||
delete e;
|
||||
}
|
||||
@@ -174,9 +176,9 @@ void NotebookButton::dragLeaveEvent(QDragLeaveEvent *)
|
||||
this->mouseDown_ = true;
|
||||
this->update();
|
||||
|
||||
auto e = new QMouseEvent(QMouseEvent::MouseButtonRelease,
|
||||
QPointF(this->width() / 2, this->height() / 2),
|
||||
Qt::LeftButton, Qt::LeftButton, {});
|
||||
auto *e = new QMouseEvent(QMouseEvent::MouseButtonRelease,
|
||||
QPointF(this->width() / 2, this->height() / 2),
|
||||
Qt::LeftButton, Qt::LeftButton, {});
|
||||
Button::mouseReleaseEvent(e);
|
||||
delete e;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
this->menu_.addAction(
|
||||
"Popup Tab",
|
||||
[this]() {
|
||||
if (auto container = dynamic_cast<SplitContainer *>(this->page))
|
||||
if (auto *container = dynamic_cast<SplitContainer *>(this->page))
|
||||
{
|
||||
container->popup();
|
||||
}
|
||||
@@ -124,11 +124,11 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
|
||||
void NotebookTab::showRenameDialog()
|
||||
{
|
||||
auto dialog = new QDialog(this);
|
||||
auto *dialog = new QDialog(this);
|
||||
|
||||
auto vbox = new QVBoxLayout;
|
||||
auto *vbox = new QVBoxLayout;
|
||||
|
||||
auto lineEdit = new QLineEdit;
|
||||
auto *lineEdit = new QLineEdit;
|
||||
lineEdit->setText(this->getCustomTitle());
|
||||
lineEdit->setPlaceholderText(this->getDefaultTitle());
|
||||
lineEdit->selectAll();
|
||||
@@ -137,7 +137,7 @@ void NotebookTab::showRenameDialog()
|
||||
vbox->addWidget(lineEdit);
|
||||
vbox->addStretch(1);
|
||||
|
||||
auto buttonBox =
|
||||
auto *buttonBox =
|
||||
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
vbox->addWidget(buttonBox);
|
||||
@@ -423,7 +423,7 @@ void NotebookTab::moveAnimated(QPoint pos, bool animated)
|
||||
|
||||
void NotebookTab::paintEvent(QPaintEvent *)
|
||||
{
|
||||
auto app = getApp();
|
||||
auto *app = getApp();
|
||||
QPainter painter(this);
|
||||
float scale = this->scale();
|
||||
|
||||
@@ -439,13 +439,21 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
Theme::TabColors colors;
|
||||
|
||||
if (this->selected_)
|
||||
{
|
||||
colors = this->theme->tabs.selected;
|
||||
}
|
||||
else if (this->highlightState_ == HighlightState::Highlighted)
|
||||
{
|
||||
colors = this->theme->tabs.highlighted;
|
||||
}
|
||||
else if (this->highlightState_ == HighlightState::NewMessage)
|
||||
{
|
||||
colors = this->theme->tabs.newMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
colors = this->theme->tabs.regular;
|
||||
}
|
||||
|
||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ bool ResizingTextEdit::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto ev = static_cast<QKeyEvent *>(event);
|
||||
auto *ev = static_cast<QKeyEvent *>(event);
|
||||
ev->ignore();
|
||||
if ((ev->key() == Qt::Key_C || ev->key() == Qt::Key_Insert) &&
|
||||
ev->modifiers() == Qt::ControlModifier)
|
||||
|
||||
@@ -42,7 +42,9 @@ void SettingsDialogTab::setSelected(bool _selected)
|
||||
SettingsPage *SettingsDialogTab::page()
|
||||
{
|
||||
if (this->page_)
|
||||
{
|
||||
return this->page_;
|
||||
}
|
||||
|
||||
this->page_ = this->lazyPage_();
|
||||
this->page_->setTab(this);
|
||||
|
||||
Reference in New Issue
Block a user