Renamed variables to clear some warnings.

This commit is contained in:
23rd 2019-05-08 09:51:14 +03:00 committed by pajlada
parent efec76df5b
commit 9654650bee
19 changed files with 73 additions and 109 deletions

View file

@ -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;

View file

@ -31,12 +31,12 @@ int AccountModel::beforeInsert(const std::shared_ptr<Account> &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;
}

View file

@ -463,19 +463,21 @@ QString CommandController::execCommand(const QString &textNoEmoji,
}
}
{
// check if custom command exists
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);
}
}
auto maxSpaces = std::min(this->maxSpaces_, words.length() - 1);
for (int i = 0; i < maxSpaces; ++i)
{
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);

View file

@ -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);

View file

@ -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<TextElement>(text, MessageElementFlag::Text,
MessageColor::System);

View file

@ -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,

View file

@ -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())

View file

@ -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());

View file

@ -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());
}
}

View file

@ -231,8 +231,8 @@ void AbstractIrcServer::onConnected()
{
std::lock_guard<std::mutex> 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<Channel> &weak : this->channels.values())
{
@ -278,7 +278,7 @@ void AbstractIrcServer::onDisconnected()
continue;
}
chan->addMessage(disconnected);
chan->addMessage(disconnectedMsg);
}
}

View file

@ -666,11 +666,11 @@ void TwitchChannel::refreshChatters()
{
// setting?
const auto streamStatus = this->accessStreamStatus();
const auto viewerCount = static_cast<int>(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();

View file

@ -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<EmoteElement>(
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<EmoteElement>(badge.get(),
this->emplace<EmoteElement>(_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<EmoteElement>(badge.get(),
this->emplace<EmoteElement>(_badge.get(),
MessageElementFlag::BadgeVanity)
->setTooltip((*badge)->tooltip.string);
->setTooltip((*_badge)->tooltip.string);
continue;
}
}

View file

@ -223,7 +223,7 @@ std::shared_ptr<Channel> TwitchServer::getCustomChannel(
{
static auto channel =
std::make_shared<Channel>("$$$", chatterino::Channel::Type::Misc);
static auto timer = [&] {
static auto getTimer = [&] {
for (auto i = 0; i < 1000; i++)
{
channel->addMessage(makeSystemMessage(QString::number(i + 1)));

View file

@ -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_;
}

View file

@ -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);

View file

@ -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)

View file

@ -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));

View file

@ -319,7 +319,6 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
{
return false;
}
return true;
}
else if (event->type() == QEvent::KeyRelease)
{

View file

@ -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 <a href=\"file:///" + pathOriginal +
@ -120,7 +108,6 @@ ModerationPage::ModerationPage()
logsPathLabel->setTextFormat(Qt::RichText);
logsPathLabel->setTextInteractionFlags(Qt::TextBrowserInteraction |
Qt::LinksAccessibleByKeyboard |
Qt::LinksAccessibleByKeyboard);
logsPathLabel->setOpenExternalLinks(true);
logs.append(this->createCheckBox("Enable logging",