diff --git a/src/common/DownloadManager.cpp b/src/common/DownloadManager.cpp index 286150a7c..5adc8ef32 100644 --- a/src/common/DownloadManager.cpp +++ b/src/common/DownloadManager.cpp @@ -20,9 +20,7 @@ DownloadManager::~DownloadManager() void DownloadManager::setFile(QString fileURL, const QString &channelName) { - QString filePath = fileURL; QString saveFilePath; - QStringList filePathList = filePath.split('/'); saveFilePath = getPaths()->twitchProfileAvatars + "/twitch/" + channelName + ".png"; QNetworkRequest request; diff --git a/src/controllers/accounts/AccountModel.cpp b/src/controllers/accounts/AccountModel.cpp index 6e1d2a5df..875efbdc5 100644 --- a/src/controllers/accounts/AccountModel.cpp +++ b/src/controllers/accounts/AccountModel.cpp @@ -31,12 +31,12 @@ int AccountModel::beforeInsert(const std::shared_ptr &item, { if (this->categoryCount_[item->getCategory()]++ == 0) { - auto row = this->createRow(); + auto newRow = this->createRow(); - setStringItem(row[0], item->getCategory(), false, false); - row[0]->setData(QFont("Segoe UI Light", 16), Qt::FontRole); + setStringItem(newRow[0], item->getCategory(), false, false); + newRow[0]->setData(QFont("Segoe UI Light", 16), Qt::FontRole); - this->insertCustomRow(std::move(row), proposedIndex); + this->insertCustomRow(std::move(newRow), proposedIndex); return proposedIndex + 1; } diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index e96a7a174..69a6195f4 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -463,11 +463,13 @@ QString CommandController::execCommand(const QString &textNoEmoji, } } - // check if custom command exists - auto it = this->commandsMap_.find(commandName); - if (it != this->commandsMap_.end()) { - return this->execCustomCommand(words, it.value(), dryRun); + // check if custom command exists + const auto it = this->commandsMap_.find(commandName); + if (it != this->commandsMap_.end()) + { + return this->execCustomCommand(words, it.value(), dryRun); + } } auto maxSpaces = std::min(this->maxSpaces_, words.length() - 1); @@ -475,7 +477,7 @@ QString CommandController::execCommand(const QString &textNoEmoji, { commandName += ' ' + words[i + 1]; - auto it = this->commandsMap_.find(commandName); + const auto it = this->commandsMap_.find(commandName); if (it != this->commandsMap_.end()) { return this->execCustomCommand(words, it.value(), dryRun); diff --git a/src/controllers/notifications/NotificationController.cpp b/src/controllers/notifications/NotificationController.cpp index 395de1974..435fb8fa1 100644 --- a/src/controllers/notifications/NotificationController.cpp +++ b/src/controllers/notifications/NotificationController.cpp @@ -103,16 +103,10 @@ void NotificationController::playSound() static auto player = new QMediaPlayer; static QUrl currentPlayerUrl; - QUrl highlightSoundUrl; - if (getSettings()->notificationCustomSound) - { - highlightSoundUrl = QUrl::fromLocalFile( - getSettings()->notificationPathSound.getValue()); - } - else - { - highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav"); - } + QUrl highlightSoundUrl = getSettings()->notificationCustomSound + ? QUrl::fromLocalFile(getSettings()->notificationPathSound.getValue()) + : QUrl("qrc:/sounds/ping2.wav"); + if (currentPlayerUrl != highlightSoundUrl) { player->setMedia(highlightSoundUrl); diff --git a/src/messages/MessageBuilder.cpp b/src/messages/MessageBuilder.cpp index 3040b535a..3fe89ccf6 100644 --- a/src/messages/MessageBuilder.cpp +++ b/src/messages/MessageBuilder.cpp @@ -235,20 +235,12 @@ MessageBuilder::MessageBuilder(const UnbanAction &action) this->message().timeoutUser = action.target.name; - QString text; - - if (action.wasBan()) - { - text = QString("%1 unbanned %2.") // + QString text = QString("%1 %2 %3.") .arg(action.source.name) + .arg(QString(action.wasBan() + ? "unbanned" + : "untimedout")) .arg(action.target.name); - } - else - { - text = QString("%1 untimedout %2.") // - .arg(action.source.name) - .arg(action.target.name); - } this->emplace(text, MessageElementFlag::Text, MessageColor::System); diff --git a/src/messages/MessageElement.cpp b/src/messages/MessageElement.cpp index f480a747c..871bbfffe 100644 --- a/src/messages/MessageElement.cpp +++ b/src/messages/MessageElement.cpp @@ -188,7 +188,7 @@ void TextElement::addToContainer(MessageLayoutContainer &container, for (Word &word : this->words_) { auto getTextLayoutElement = [&](QString text, int width, - bool trailingSpace) { + bool hasTrailingSpace) { auto color = this->color_.getColor(*app->themes); app->themes->normalizeColor(color); @@ -196,7 +196,7 @@ void TextElement::addToContainer(MessageLayoutContainer &container, *this, text, QSize(width, metrics.height()), color, this->style_, container.getScale())) ->setLink(this->getLink()); - e->setTrailingSpace(trailingSpace); + e->setTrailingSpace(hasTrailingSpace); e->setText(text); // If URL link was changed, diff --git a/src/messages/layouts/MessageLayout.cpp b/src/messages/layouts/MessageLayout.cpp index 808d40d94..5bafe8c19 100644 --- a/src/messages/layouts/MessageLayout.cpp +++ b/src/messages/layouts/MessageLayout.cpp @@ -99,14 +99,14 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags) return true; } -void MessageLayout::actuallyLayout(int width, MessageElementFlags _flags) +void MessageLayout::actuallyLayout(int width, MessageElementFlags flags) { this->layoutCount_++; auto messageFlags = this->message_->flags; if (this->flags.has(MessageLayoutFlag::Expanded) || - (_flags.has(MessageElementFlag::ModeratorTools) && + (flags.has(MessageElementFlag::ModeratorTools) && !this->message_->flags.has(MessageFlag::Disabled))) // { messageFlags.unset(MessageFlag::Collapsed); @@ -121,7 +121,7 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags _flags) { continue; } - element->addToContainer(*this->container_, _flags); + element->addToContainer(*this->container_, flags); } if (this->height_ != this->container_->getHeight()) diff --git a/src/messages/layouts/MessageLayoutContainer.cpp b/src/messages/layouts/MessageLayoutContainer.cpp index f421b053a..599564787 100644 --- a/src/messages/layouts/MessageLayoutContainer.cpp +++ b/src/messages/layouts/MessageLayoutContainer.cpp @@ -390,17 +390,17 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, int lineIndex2 = lineIndex + 1; for (; lineIndex2 < this->lines_.size(); lineIndex2++) { - Line &line = this->lines_[lineIndex2]; - QRect rect = line.rect; + Line &line2 = this->lines_[lineIndex2]; + QRect rect = line2.rect; rect.setTop(std::max(0, rect.top()) + yOffset); rect.setBottom( std::min(this->height_, rect.bottom()) + yOffset); - rect.setLeft(this->elements_[line.startIndex] + rect.setLeft(this->elements_[line2.startIndex] ->getRect() .left()); - rect.setRight(this->elements_[line.endIndex - 1] + rect.setRight(this->elements_[line2.endIndex - 1] ->getRect() .right()); diff --git a/src/providers/emoji/Emojis.cpp b/src/providers/emoji/Emojis.cpp index f835413db..f510d697f 100644 --- a/src/providers/emoji/Emojis.cpp +++ b/src/providers/emoji/Emojis.cpp @@ -36,9 +36,9 @@ namespace { else { const auto &shortCodes = unparsedEmoji["short_names"]; - for (const auto &shortCode : shortCodes.GetArray()) + for (const auto &_shortCode : shortCodes.GetArray()) { - emojiData->shortCodes.emplace_back(shortCode.GetString()); + emojiData->shortCodes.emplace_back(_shortCode.GetString()); } } diff --git a/src/providers/irc/AbstractIrcServer.cpp b/src/providers/irc/AbstractIrcServer.cpp index d803fdbe9..eb1d0def9 100644 --- a/src/providers/irc/AbstractIrcServer.cpp +++ b/src/providers/irc/AbstractIrcServer.cpp @@ -231,8 +231,8 @@ void AbstractIrcServer::onConnected() { std::lock_guard lock(this->channelMutex); - auto connected = makeSystemMessage("connected"); - connected->flags.set(MessageFlag::ConnectedMessage); + auto connectedMsg = makeSystemMessage("connected"); + connectedMsg->flags.set(MessageFlag::ConnectedMessage); auto reconnected = makeSystemMessage("reconnected"); reconnected->flags.set(MessageFlag::ConnectedMessage); @@ -256,7 +256,7 @@ void AbstractIrcServer::onConnected() continue; } - chan->addMessage(connected); + chan->addMessage(connectedMsg); } this->falloffCounter_ = 1; @@ -268,7 +268,7 @@ void AbstractIrcServer::onDisconnected() MessageBuilder b(systemMessage, "disconnected"); b->flags.set(MessageFlag::DisconnectedMessage); - auto disconnected = b.release(); + auto disconnectedMsg = b.release(); for (std::weak_ptr &weak : this->channels.values()) { @@ -278,7 +278,7 @@ void AbstractIrcServer::onDisconnected() continue; } - chan->addMessage(disconnected); + chan->addMessage(disconnectedMsg); } } diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index a40859791..c3a795fff 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -666,11 +666,11 @@ void TwitchChannel::refreshChatters() { // setting? const auto streamStatus = this->accessStreamStatus(); - + const auto viewerCount = static_cast(streamStatus->viewerCount); if (getSettings()->onlyFetchChattersForSmallerStreamers) { if (streamStatus->live && - streamStatus->viewerCount > getSettings()->smallStreamerLimit) + viewerCount > getSettings()->smallStreamerLimit) { return; } @@ -722,8 +722,8 @@ void TwitchChannel::refreshBadges() { auto &versions = (*badgeSets)[jsonBadgeSet.key()]; - auto _ = jsonBadgeSet->toObject()["versions"].toObject(); - for (auto jsonVersion_ = _.begin(); jsonVersion_ != _.end(); + auto _set = jsonBadgeSet->toObject()["versions"].toObject(); + for (auto jsonVersion_ = _set.begin(); jsonVersion_ != _set.end(); jsonVersion_++) { auto jsonVersion = jsonVersion_->toObject(); diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 8bccc6ea7..c39889aba 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -334,13 +334,13 @@ MessagePtr TwitchMessageBuilder::build() QRegularExpression emoteregex( "\\b" + std::get<2>(tup).string + "\\b", QRegularExpression::UseUnicodePropertiesOption); - auto match = emoteregex.match(midExtendedRef); - if (match.hasMatch()) + auto _match = emoteregex.match(midExtendedRef); + if (_match.hasMatch()) { - int last = match.lastCapturedIndex(); + int last = _match.lastCapturedIndex(); for (int i = 0; i <= last; ++i) { - std::get<0>(tup) = from + match.capturedStart(); + std::get<0>(tup) = from + _match.capturedStart(); twitchEmotes.push_back(std::move(tup)); } } @@ -781,16 +781,9 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg) } // update the media player url if necessary - QUrl highlightSoundUrl; - if (getSettings()->customHighlightSound) - { - highlightSoundUrl = - QUrl::fromLocalFile(getSettings()->pathHighlightSound.getValue()); - } - else - { - highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav"); - } + QUrl highlightSoundUrl = getSettings()->customHighlightSound + ? QUrl::fromLocalFile(getSettings()->pathHighlightSound.getValue()) + : QUrl("qrc:/sounds/ping2.wav"); if (currentPlayerUrl != highlightSoundUrl) { @@ -1040,11 +1033,11 @@ void TwitchMessageBuilder::appendTwitchBadges() try { if (twitchChannel) - if (const auto &badge = this->twitchChannel->twitchBadge( + if (const auto &_badge = this->twitchChannel->twitchBadge( "bits", cheerAmount)) { this->emplace( - badge.get(), MessageElementFlag::BadgeVanity) + _badge.get(), MessageElementFlag::BadgeVanity) ->setTooltip(tooltip); continue; } @@ -1055,10 +1048,10 @@ void TwitchMessageBuilder::appendTwitchBadges() } // Use default bit badge - if (auto badge = this->twitchChannel->globalTwitchBadges().badge( + if (auto _badge = this->twitchChannel->globalTwitchBadges().badge( "bits", cheerAmount)) { - this->emplace(badge.get(), + this->emplace(_badge.get(), MessageElementFlag::BadgeVanity) ->setTooltip(tooltip); } @@ -1174,12 +1167,12 @@ void TwitchMessageBuilder::appendTwitchBadges() ->setTooltip((*badgeEmote)->tooltip.string); continue; } - if (auto badge = this->twitchChannel->globalTwitchBadges().badge( + if (auto _badge = this->twitchChannel->globalTwitchBadges().badge( splits[0], splits[1])) { - this->emplace(badge.get(), + this->emplace(_badge.get(), MessageElementFlag::BadgeVanity) - ->setTooltip((*badge)->tooltip.string); + ->setTooltip((*_badge)->tooltip.string); continue; } } diff --git a/src/providers/twitch/TwitchServer.cpp b/src/providers/twitch/TwitchServer.cpp index 2a63b1eb7..58f98494c 100644 --- a/src/providers/twitch/TwitchServer.cpp +++ b/src/providers/twitch/TwitchServer.cpp @@ -223,7 +223,7 @@ std::shared_ptr TwitchServer::getCustomChannel( { static auto channel = std::make_shared("$$$", chatterino::Channel::Type::Misc); - static auto timer = [&] { + static auto getTimer = [&] { for (auto i = 0; i < 1000; i++) { channel->addMessage(makeSystemMessage(QString::number(i + 1))); diff --git a/src/singletons/Paths.cpp b/src/singletons/Paths.cpp index 3114cf2d6..7c5e4266d 100644 --- a/src/singletons/Paths.cpp +++ b/src/singletons/Paths.cpp @@ -37,7 +37,7 @@ bool Paths::isPortable() QString Paths::cacheDirectory() { - static QStringSetting cachePathSetting = [] { + static const auto path = [] { QStringSetting cachePathSetting("/cache/path"); cachePathSetting.connect([](const auto &newPath, auto) { @@ -45,11 +45,9 @@ QString Paths::cacheDirectory() }); return cachePathSetting; - }(); + }().getValue(); - auto path = cachePathSetting.getValue(); - - if (path == "") + if (path.isEmpty()) { return this->cacheDirectory_; } diff --git a/src/singletons/Theme.cpp b/src/singletons/Theme.cpp index 1c1411ec2..6fb31e352 100644 --- a/src/singletons/Theme.cpp +++ b/src/singletons/Theme.cpp @@ -27,9 +27,9 @@ void Theme::actuallyUpdate(double hue, double multiplier) return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a); }; - auto sat = qreal(0); - auto isLight_ = this->isLightTheme(); - auto flat = isLight_; + const auto sat = qreal(0); + const auto isLight = this->isLightTheme(); + const auto flat = isLight; if (this->isLightTheme()) { @@ -61,7 +61,7 @@ void Theme::actuallyUpdate(double hue, double multiplier) this->splits.header.border = getColor(0, sat, flat ? 1 : 0.85); this->splits.header.text = this->messages.textColors.regular; this->splits.header.focusedText = - isLight_ ? QColor("#198CFF") : QColor("#84C1FF"); + isLight ? QColor("#198CFF") : QColor("#84C1FF"); this->splits.input.background = getColor(0, sat, flat ? 0.95 : 0.95); this->splits.input.border = getColor(0, sat, flat ? 1 : 1); @@ -71,13 +71,13 @@ void Theme::actuallyUpdate(double hue, double multiplier) "border:" + this->tabs.selected.backgrounds.regular.color().name() + ";" + "color:" + this->messages.textColors.regular.name() + ";" + // "selection-background-color:" + - (isLight_ ? "#68B1FF" + (isLight ? "#68B1FF" : this->tabs.selected.backgrounds.regular.color().name()); this->splits.input.focusedLine = this->tabs.highlighted.line.regular; this->splits.messageSeperator = - isLight_ ? QColor(127, 127, 127) : QColor(60, 60, 60); + isLight ? QColor(127, 127, 127) : QColor(60, 60, 60); this->splits.background = getColor(0, sat, 1); this->splits.dropPreview = QColor(0, 148, 255, 0x30); this->splits.dropPreviewBorder = QColor(0, 148, 255, 0xff); diff --git a/src/singletons/Toasts.cpp b/src/singletons/Toasts.cpp index 9dcbd6516..a9dccc614 100644 --- a/src/singletons/Toasts.cpp +++ b/src/singletons/Toasts.cpp @@ -38,8 +38,9 @@ bool Toasts::isEnabled() #ifdef Q_OS_WIN return WinToastLib::WinToast::isCompatible() && getSettings()->notificationToast; -#endif +#else return false; +#endif } QString Toasts::findStringFromReaction(const ToastReaction &reaction) diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index a202dcd5c..4c7efeede 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -110,7 +110,7 @@ void Scrollbar::setSmallChange(qreal value) void Scrollbar::setDesiredValue(qreal value, bool animated) { - animated &= getSettings()->enableSmoothScrolling.getValue(); + animated &= getSettings()->enableSmoothScrolling; value = std::max(this->minimum_, std::min(this->maximum_ - this->largeChange_, value)); diff --git a/src/widgets/dialogs/SelectChannelDialog.cpp b/src/widgets/dialogs/SelectChannelDialog.cpp index 2d8218e69..f965ccb5c 100644 --- a/src/widgets/dialogs/SelectChannelDialog.cpp +++ b/src/widgets/dialogs/SelectChannelDialog.cpp @@ -319,7 +319,6 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, { return false; } - return true; } else if (event->type() == QEvent::KeyRelease) { diff --git a/src/widgets/settingspages/ModerationPage.cpp b/src/widgets/settingspages/ModerationPage.cpp index b44e73274..02580ebeb 100644 --- a/src/widgets/settingspages/ModerationPage.cpp +++ b/src/widgets/settingspages/ModerationPage.cpp @@ -61,15 +61,10 @@ QString formatSize(qint64 size) QString fetchLogDirectorySize() { - QString logPathDirectory; - if (getSettings()->logPath == "") - { - logPathDirectory = getPaths()->messageLogDirectory; - } - else - { - logPathDirectory = getSettings()->logPath; - } + QString logPathDirectory = getSettings()->logPath.getValue().isEmpty() + ? getPaths()->messageLogDirectory + : getSettings()->logPath; + qint64 logsSize = dirSize(logPathDirectory); QString logsSizeLabel = "Your logs currently take up "; logsSizeLabel += formatSize(logsSize); @@ -98,16 +93,9 @@ ModerationPage::ModerationPage() // Logs (copied from LoggingMananger) getSettings()->logPath.connect( [logsPathLabel](const QString &logPath, auto) mutable { - QString pathOriginal; - - if (logPath == "") - { - pathOriginal = getPaths()->messageLogDirectory; - } - else - { - pathOriginal = logPath; - } + QString pathOriginal = logPath.isEmpty() + ? getPaths()->messageLogDirectory + : logPath; QString pathShortened = "Logs are saved at setTextFormat(Qt::RichText); logsPathLabel->setTextInteractionFlags(Qt::TextBrowserInteraction | - Qt::LinksAccessibleByKeyboard | Qt::LinksAccessibleByKeyboard); logsPathLabel->setOpenExternalLinks(true); logs.append(this->createCheckBox("Enable logging",