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
+2 -2
View File
@@ -29,8 +29,8 @@ AccountSwitchPopup::AccountSwitchPopup(QWidget *parent)
this->ui_.accountSwitchWidget->setFocusPolicy(Qt::NoFocus);
vbox->addWidget(this->ui_.accountSwitchWidget);
auto hbox = new QHBoxLayout();
auto manageAccountsButton = new QPushButton(this);
auto *hbox = new QHBoxLayout();
auto *manageAccountsButton = new QPushButton(this);
manageAccountsButton->setText("Manage Accounts");
manageAccountsButton->setFocusPolicy(Qt::NoFocus);
hbox->addWidget(manageAccountsButton);
+2 -2
View File
@@ -11,7 +11,7 @@ namespace chatterino {
AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
: QListWidget(parent)
{
auto app = getApp();
auto *app = getApp();
this->addItem(ANONYMOUS_USERNAME_LABEL);
@@ -69,7 +69,7 @@ void AccountSwitchWidget::refreshSelection()
// Select the currently logged in user
if (this->count() > 0)
{
auto app = getApp();
auto *app = getApp();
auto currentUser = app->accounts->twitch.getCurrent();
+3 -3
View File
@@ -28,7 +28,7 @@ BaseWidget::BaseWidget(QWidget *parent, Qt::WindowFlags f)
}
void BaseWidget::clearShortcuts()
{
for (auto shortcut : this->shortcuts_)
for (auto *shortcut : this->shortcuts_)
{
shortcut->setKey(QKeySequence());
shortcut->removeEventFilter(this);
@@ -122,7 +122,7 @@ void BaseWidget::setScaleIndependantHeight(int value)
float BaseWidget::qtFontScale() const
{
if (auto window = dynamic_cast<BaseWindow *>(this->window()))
if (auto *window = dynamic_cast<BaseWindow *>(this->window()))
{
// ensure no div by 0
return this->scale() / std::max<float>(0.01f, window->nativeScale_);
@@ -138,7 +138,7 @@ void BaseWidget::childEvent(QChildEvent *event)
if (event->added())
{
// add element if it's a basewidget
if (auto widget = dynamic_cast<BaseWidget *>(event->child()))
if (auto *widget = dynamic_cast<BaseWidget *>(event->child()))
{
this->widgets_.push_back(widget);
}
+2 -2
View File
@@ -373,7 +373,7 @@ void BaseWindow::mousePressEvent(QMouseEvent *event)
if (this->flags_.has(FramelessDraggable))
{
this->movingRelativePos = event->localPos();
if (auto widget =
if (auto *widget =
this->childAt(event->localPos().x(), event->localPos().y()))
{
std::function<bool(QWidget *)> recursiveCheckMouseTracking;
@@ -735,7 +735,7 @@ void BaseWindow::updateScale()
this->setScale(scale);
for (auto child : this->findChildren<BaseWidget *>())
for (auto *child : this->findChildren<BaseWidget *>())
{
child->setScale(scale);
}
+1 -1
View File
@@ -19,7 +19,7 @@ FramelessEmbedWindow::FramelessEmbedWindow()
: BaseWindow({BaseWindow::Frameless, BaseWindow::DisableLayoutSave})
{
this->split_ = new Split((QWidget *)nullptr);
auto layout = new QHBoxLayout;
auto *layout = new QHBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(this->split_);
+16 -8
View File
@@ -785,7 +785,9 @@ void Notebook::performLayout(bool animated)
}
if (this->visibleButtonCount() > 0)
{
y = tabHeight + lineThickness; // account for divider line
}
int totalButtonWidths = x;
const int top = y + tabSpacer; // add margin
@@ -829,7 +831,9 @@ void Notebook::performLayout(bool animated)
}
if (isLastColumn && largestWidth + x < totalButtonWidths)
{
largestWidth = totalButtonWidths - x;
}
for (int i = tabStart; i < tabEnd; i++)
{
@@ -877,7 +881,7 @@ void Notebook::performLayout(bool animated)
for (auto btnIt = this->customButtons_.rbegin();
btnIt != this->customButtons_.rend(); ++btnIt)
{
auto btn = *btnIt;
auto *btn = *btnIt;
if (!btn->isVisible())
{
continue;
@@ -889,7 +893,9 @@ void Notebook::performLayout(bool animated)
}
if (this->visibleButtonCount() > 0)
{
y = tabHeight + lineThickness; // account for divider line
}
int consumedButtonWidths = right - x;
const int top = y + tabSpacer; // add margin
@@ -936,7 +942,9 @@ void Notebook::performLayout(bool animated)
if (isLastColumn &&
largestWidth + distanceFromRight < consumedButtonWidths)
{
largestWidth = consumedButtonWidths - distanceFromRight;
}
x -= largestWidth + lineThickness;
@@ -1288,7 +1296,7 @@ SplitNotebook::SplitNotebook(Window *parent)
getApp()->windows->selectSplit, [this](Split *split) {
for (auto &&item : this->items())
{
if (auto sc = dynamic_cast<SplitContainer *>(item.page))
if (auto *sc = dynamic_cast<SplitContainer *>(item.page))
{
auto &&splits = sc->getSplits();
if (std::find(splits.begin(), splits.end(), split) !=
@@ -1312,7 +1320,7 @@ SplitNotebook::SplitNotebook(Window *parent)
[this](const MessagePtr &message) {
for (auto &&item : this->items())
{
if (auto sc = dynamic_cast<SplitContainer *>(item.page))
if (auto *sc = dynamic_cast<SplitContainer *>(item.page))
{
for (auto *split : sc->getSplits())
{
@@ -1352,7 +1360,7 @@ void SplitNotebook::showEvent(QShowEvent * /*event*/)
void SplitNotebook::addCustomButtons()
{
// settings
auto settingsBtn = this->addCustomButton();
auto *settingsBtn = this->addCustomButton();
// This is to ensure you can't lock yourself out of the settings
if (getApp()->getArgs().safeMode)
@@ -1378,7 +1386,7 @@ void SplitNotebook::addCustomButtons()
});
// account
auto userBtn = this->addCustomButton();
auto *userBtn = this->addCustomButton();
userBtn->setVisible(!getSettings()->hideUserButton.getValue());
getSettings()->hideUserButton.connect(
[userBtn](bool hide, auto) {
@@ -1393,7 +1401,7 @@ void SplitNotebook::addCustomButtons()
});
// updates
auto updateBtn = this->addCustomButton();
auto *updateBtn = this->addCustomButton();
initUpdateButton(*updateBtn, this->signalHolder_);
@@ -1439,8 +1447,8 @@ void SplitNotebook::themeChangedEvent()
SplitContainer *SplitNotebook::addPage(bool select)
{
auto container = new SplitContainer(this);
auto tab = Notebook::addPage(container, QString(), select);
auto *container = new SplitContainer(this);
auto *tab = Notebook::addPage(container, QString(), select);
container->setTab(tab);
tab->setParent(this);
return container;
+3 -3
View File
@@ -119,9 +119,9 @@ void TooltipWidget::set(const std::vector<TooltipEntry> &entries,
for (int i = 0; i < entries.size(); ++i)
{
if (auto entryWidget = this->entryAt(i))
if (auto *entryWidget = this->entryAt(i))
{
auto &entry = entries[i];
const auto &entry = entries[i];
entryWidget->setImage(entry.image);
entryWidget->setText(entry.text);
entryWidget->setImageScale(entry.customWidth, entry.customHeight);
@@ -306,7 +306,7 @@ void TooltipWidget::setWordWrap(bool wrap)
{
for (int i = 0; i < this->visibleEntries_; ++i)
{
auto entry = this->entryAt(i);
auto *entry = this->entryAt(i);
if (entry)
{
entry->setWordWrap(wrap);
+9 -5
View File
@@ -136,7 +136,7 @@ void Window::closeEvent(QCloseEvent *)
{
if (this->type_ == WindowType::Main)
{
auto app = getApp();
auto *app = getApp();
app->windows->save();
app->windows->closeAll();
}
@@ -171,9 +171,13 @@ void Window::addLayout()
void Window::addCustomTitlebarButtons()
{
if (!this->hasCustomWindowFrame())
{
return;
}
if (this->type_ != WindowType::Main)
{
return;
}
// settings
this->addTitleBarButton(TitleBarButtonStyle::Settings, [this] {
@@ -181,7 +185,7 @@ void Window::addCustomTitlebarButtons()
});
// updates
auto update = this->addTitleBarButton(TitleBarButtonStyle::None, [] {});
auto *update = this->addTitleBarButton(TitleBarButtonStyle::None, [] {});
initUpdateButton(*update, this->signalHolder_);
@@ -384,10 +388,10 @@ void Window::addShortcuts()
}
if (arguments.at(0) == "split")
{
if (auto page = dynamic_cast<SplitContainer *>(
if (auto *page = dynamic_cast<SplitContainer *>(
this->notebook_->getSelectedPage()))
{
if (auto split = page->getSelectedSplit())
if (auto *split = page->getSelectedSplit())
{
split->popup();
}
@@ -395,7 +399,7 @@ void Window::addShortcuts()
}
else if (arguments.at(0) == "window")
{
if (auto page = dynamic_cast<SplitContainer *>(
if (auto *page = dynamic_cast<SplitContainer *>(
this->notebook_->getSelectedPage()))
{
page->popup();
+4 -2
View File
@@ -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;
+7 -3
View File
@@ -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();
+8 -8
View File
@@ -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
+19 -6
View File
@@ -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();
}
+2 -2
View File
@@ -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();
+9 -5
View File
@@ -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] {
+14
View File
@@ -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
+7 -1
View File
@@ -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);
+8 -6
View File
@@ -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;
}
+14 -6
View File
@@ -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();
+1 -1
View File
@@ -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)
+2
View File
@@ -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);
@@ -22,7 +22,9 @@ void SwitcherItemDelegate::paint(QPainter *painter,
if (item)
{
if (option.state & QStyle::State_Selected)
{
painter->fillRect(option.rect, option.palette.highlight());
}
item->paint(painter, option.rect);
}
+1 -1
View File
@@ -25,7 +25,7 @@ GenericListView::GenericListView()
void GenericListView::setModel(QAbstractItemModel *model)
{
auto casted = dynamic_cast<GenericListModel *>(model);
auto *casted = dynamic_cast<GenericListModel *>(model);
assert(casted);
this->setModel(casted);
}
+2 -2
View File
@@ -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);
+2 -2
View File
@@ -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, [] {
+2 -2
View File
@@ -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));
+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;
}
+33 -19
View File
@@ -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);
+11 -3
View File
@@ -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(
+3 -1
View File
@@ -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);
+3 -1
View File
@@ -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();
@@ -19,9 +19,13 @@ void InputCompletionItem::action()
if (this->action_)
{
if (this->emote_)
{
this->action_(this->emote_->name.string);
}
else
{
this->action_(this->text_);
}
}
}
+16 -16
View File
@@ -199,11 +199,11 @@ namespace {
parent);
window->setWindowTitle("Chatterino - " + title);
window->setAttribute(Qt::WA_DeleteOnClose);
auto layout = new QVBoxLayout();
auto *layout = new QVBoxLayout();
layout->addWidget(new QLabel(description));
auto label = new QLabel(window);
auto *label = new QLabel(window);
layout->addWidget(label);
auto movie = new QMovie(label);
auto *movie = new QMovie(label);
movie->setFileName(source);
label->setMovie(movie);
movie->start();
@@ -805,7 +805,7 @@ void Split::refreshModerationMode()
void Split::openChannelInBrowserPlayer(ChannelPtr channel)
{
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
{
QDesktopServices::openUrl(
"https://player.twitch.tv/?parent=twitch.tv&channel=" +
@@ -918,7 +918,7 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
return;
}
auto dialog = new SelectChannelDialog(this);
auto *dialog = new SelectChannelDialog(this);
if (!empty)
{
dialog->setSelectedChannel(this->getIndirectChannel());
@@ -1065,7 +1065,7 @@ void Split::explainSplitting()
void Split::popup()
{
auto app = getApp();
auto *app = getApp();
Window &window = app->windows->createWindow(WindowType::Popup);
Split *split = new Split(static_cast<SplitContainer *>(
@@ -1088,7 +1088,7 @@ void Split::openInBrowser()
{
auto channel = this->getChannel();
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
{
QDesktopServices::openUrl("https://twitch.tv/" +
twitchChannel->getName());
@@ -1111,7 +1111,7 @@ void Split::openModViewInBrowser()
{
auto channel = this->getChannel();
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
{
QDesktopServices::openUrl("https://twitch.tv/moderator/" +
twitchChannel->getName());
@@ -1131,9 +1131,9 @@ void Split::openWithCustomScheme()
return;
}
const auto channel = this->getChannel().get();
auto *const channel = this->getChannel().get();
if (const auto twitchChannel = dynamic_cast<TwitchChannel *>(channel))
if (auto *const twitchChannel = dynamic_cast<TwitchChannel *>(channel))
{
QDesktopServices::openUrl(QString("%1https://twitch.tv/%2")
.arg(scheme)
@@ -1422,7 +1422,7 @@ void Split::openSubPage()
{
ChannelPtr channel = this->getChannel();
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
{
QDesktopServices::openUrl(twitchChannel->subscriptionUrl());
}
@@ -1466,8 +1466,8 @@ void Split::showSearch(bool singleChannel)
auto &notebook = getApp()->windows->getMainWindow().getNotebook();
for (int i = 0; i < notebook.getPageCount(); ++i)
{
auto container = dynamic_cast<SplitContainer *>(notebook.getPageAt(i));
for (auto split : container->getSplits())
auto *container = dynamic_cast<SplitContainer *>(notebook.getPageAt(i));
for (auto *split : container->getSplits())
{
if (split->channel_.getType() != Channel::Type::TwitchAutomod)
{
@@ -1484,7 +1484,7 @@ void Split::reloadChannelAndSubscriberEmotes()
auto channel = this->getChannel();
getApp()->accounts->twitch.getCurrent()->loadEmotes(channel);
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
{
twitchChannel->refreshBTTVChannelEmotes(true);
twitchChannel->refreshFFZChannelEmotes(true);
@@ -1551,8 +1551,8 @@ void Split::drag()
startDraggingSplit();
auto originalLocation = container->releaseSplit(this);
auto drag = new QDrag(this);
auto mimeData = new QMimeData;
auto *drag = new QDrag(this);
auto *mimeData = new QMimeData;
mimeData->setData("chatterino/split", "xD");
drag->setMimeData(mimeData);
+9 -7
View File
@@ -50,13 +50,13 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
this->installEventFilter(this);
this->initLayout();
auto completer =
auto *completer =
new QCompleter(&this->split_->getChannel()->completionModel);
this->ui_.textEdit->setCompleter(completer);
this->signalHolder_.managedConnect(this->split_->channelChanged, [this] {
auto channel = this->split_->getChannel();
auto completer = new QCompleter(&channel->completionModel);
auto *completer = new QCompleter(&channel->completionModel);
this->ui_.textEdit->setCompleter(completer);
});
@@ -78,7 +78,7 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
void SplitInput::initLayout()
{
auto app = getApp();
auto *app = getApp();
LayoutCreator<SplitInput> layoutCreator(this);
auto layout =
@@ -202,7 +202,7 @@ void SplitInput::initLayout()
void SplitInput::scaleChangedEvent(float scale)
{
auto app = getApp();
auto *app = getApp();
// update the icon size of the buttons
this->updateEmoteButton();
this->updateCancelReplyButton();
@@ -328,7 +328,9 @@ QString SplitInput::handleSendMessage(std::vector<QString> &arguments)
{
auto c = this->split_->getChannel();
if (c == nullptr)
{
return "";
}
if (!c->isTwitchChannel() || this->replyThread_ == nullptr)
{
@@ -347,7 +349,7 @@ QString SplitInput::handleSendMessage(std::vector<QString> &arguments)
else
{
// Reply to message
auto tc = dynamic_cast<TwitchChannel *>(c.get());
auto *tc = dynamic_cast<TwitchChannel *>(c.get());
if (!tc)
{
// this should not fail
@@ -635,7 +637,7 @@ bool SplitInput::eventFilter(QObject *obj, QEvent *event)
if (event->type() == QEvent::ShortcutOverride ||
event->type() == QEvent::Shortcut)
{
if (auto popup = this->inputCompletionPopup_.data())
if (auto *popup = this->inputCompletionPopup_.data())
{
if (popup->isVisible())
{
@@ -906,7 +908,7 @@ bool SplitInput::isHidden() const
void SplitInput::editTextChanged()
{
auto app = getApp();
auto *app = getApp();
// set textLengthLabel value
QString text = this->ui_.textEdit->toPlainText();