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) void DownloadManager::setFile(QString fileURL, const QString &channelName)
{ {
QString filePath = fileURL;
QString saveFilePath; QString saveFilePath;
QStringList filePathList = filePath.split('/');
saveFilePath = saveFilePath =
getPaths()->twitchProfileAvatars + "/twitch/" + channelName + ".png"; getPaths()->twitchProfileAvatars + "/twitch/" + channelName + ".png";
QNetworkRequest request; QNetworkRequest request;

View file

@ -31,12 +31,12 @@ int AccountModel::beforeInsert(const std::shared_ptr<Account> &item,
{ {
if (this->categoryCount_[item->getCategory()]++ == 0) if (this->categoryCount_[item->getCategory()]++ == 0)
{ {
auto row = this->createRow(); auto newRow = this->createRow();
setStringItem(row[0], item->getCategory(), false, false); setStringItem(newRow[0], item->getCategory(), false, false);
row[0]->setData(QFont("Segoe UI Light", 16), Qt::FontRole); 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; return proposedIndex + 1;
} }

View file

@ -463,19 +463,21 @@ QString CommandController::execCommand(const QString &textNoEmoji,
} }
} }
{
// check if custom command exists // check if custom command exists
auto it = this->commandsMap_.find(commandName); const auto it = this->commandsMap_.find(commandName);
if (it != this->commandsMap_.end()) if (it != this->commandsMap_.end())
{ {
return this->execCustomCommand(words, it.value(), dryRun); return this->execCustomCommand(words, it.value(), dryRun);
} }
}
auto maxSpaces = std::min(this->maxSpaces_, words.length() - 1); auto maxSpaces = std::min(this->maxSpaces_, words.length() - 1);
for (int i = 0; i < maxSpaces; ++i) for (int i = 0; i < maxSpaces; ++i)
{ {
commandName += ' ' + words[i + 1]; commandName += ' ' + words[i + 1];
auto it = this->commandsMap_.find(commandName); const auto it = this->commandsMap_.find(commandName);
if (it != this->commandsMap_.end()) if (it != this->commandsMap_.end())
{ {
return this->execCustomCommand(words, it.value(), dryRun); return this->execCustomCommand(words, it.value(), dryRun);

View file

@ -103,16 +103,10 @@ void NotificationController::playSound()
static auto player = new QMediaPlayer; static auto player = new QMediaPlayer;
static QUrl currentPlayerUrl; static QUrl currentPlayerUrl;
QUrl highlightSoundUrl; QUrl highlightSoundUrl = getSettings()->notificationCustomSound
if (getSettings()->notificationCustomSound) ? QUrl::fromLocalFile(getSettings()->notificationPathSound.getValue())
{ : QUrl("qrc:/sounds/ping2.wav");
highlightSoundUrl = QUrl::fromLocalFile(
getSettings()->notificationPathSound.getValue());
}
else
{
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
}
if (currentPlayerUrl != highlightSoundUrl) if (currentPlayerUrl != highlightSoundUrl)
{ {
player->setMedia(highlightSoundUrl); player->setMedia(highlightSoundUrl);

View file

@ -235,20 +235,12 @@ MessageBuilder::MessageBuilder(const UnbanAction &action)
this->message().timeoutUser = action.target.name; this->message().timeoutUser = action.target.name;
QString text; QString text = QString("%1 %2 %3.")
if (action.wasBan())
{
text = QString("%1 unbanned %2.") //
.arg(action.source.name) .arg(action.source.name)
.arg(QString(action.wasBan()
? "unbanned"
: "untimedout"))
.arg(action.target.name); .arg(action.target.name);
}
else
{
text = QString("%1 untimedout %2.") //
.arg(action.source.name)
.arg(action.target.name);
}
this->emplace<TextElement>(text, MessageElementFlag::Text, this->emplace<TextElement>(text, MessageElementFlag::Text,
MessageColor::System); MessageColor::System);

View file

@ -188,7 +188,7 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
for (Word &word : this->words_) for (Word &word : this->words_)
{ {
auto getTextLayoutElement = [&](QString text, int width, auto getTextLayoutElement = [&](QString text, int width,
bool trailingSpace) { bool hasTrailingSpace) {
auto color = this->color_.getColor(*app->themes); auto color = this->color_.getColor(*app->themes);
app->themes->normalizeColor(color); app->themes->normalizeColor(color);
@ -196,7 +196,7 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
*this, text, QSize(width, metrics.height()), *this, text, QSize(width, metrics.height()),
color, this->style_, container.getScale())) color, this->style_, container.getScale()))
->setLink(this->getLink()); ->setLink(this->getLink());
e->setTrailingSpace(trailingSpace); e->setTrailingSpace(hasTrailingSpace);
e->setText(text); e->setText(text);
// If URL link was changed, // If URL link was changed,

View file

@ -99,14 +99,14 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
return true; return true;
} }
void MessageLayout::actuallyLayout(int width, MessageElementFlags _flags) void MessageLayout::actuallyLayout(int width, MessageElementFlags flags)
{ {
this->layoutCount_++; this->layoutCount_++;
auto messageFlags = this->message_->flags; auto messageFlags = this->message_->flags;
if (this->flags.has(MessageLayoutFlag::Expanded) || if (this->flags.has(MessageLayoutFlag::Expanded) ||
(_flags.has(MessageElementFlag::ModeratorTools) && (flags.has(MessageElementFlag::ModeratorTools) &&
!this->message_->flags.has(MessageFlag::Disabled))) // !this->message_->flags.has(MessageFlag::Disabled))) //
{ {
messageFlags.unset(MessageFlag::Collapsed); messageFlags.unset(MessageFlag::Collapsed);
@ -121,7 +121,7 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags _flags)
{ {
continue; continue;
} }
element->addToContainer(*this->container_, _flags); element->addToContainer(*this->container_, flags);
} }
if (this->height_ != this->container_->getHeight()) if (this->height_ != this->container_->getHeight())

View file

@ -390,17 +390,17 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
int lineIndex2 = lineIndex + 1; int lineIndex2 = lineIndex + 1;
for (; lineIndex2 < this->lines_.size(); lineIndex2++) for (; lineIndex2 < this->lines_.size(); lineIndex2++)
{ {
Line &line = this->lines_[lineIndex2]; Line &line2 = this->lines_[lineIndex2];
QRect rect = line.rect; QRect rect = line2.rect;
rect.setTop(std::max(0, rect.top()) + yOffset); rect.setTop(std::max(0, rect.top()) + yOffset);
rect.setBottom( rect.setBottom(
std::min(this->height_, rect.bottom()) + std::min(this->height_, rect.bottom()) +
yOffset); yOffset);
rect.setLeft(this->elements_[line.startIndex] rect.setLeft(this->elements_[line2.startIndex]
->getRect() ->getRect()
.left()); .left());
rect.setRight(this->elements_[line.endIndex - 1] rect.setRight(this->elements_[line2.endIndex - 1]
->getRect() ->getRect()
.right()); .right());

View file

@ -36,9 +36,9 @@ namespace {
else else
{ {
const auto &shortCodes = unparsedEmoji["short_names"]; 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); std::lock_guard<std::mutex> lock(this->channelMutex);
auto connected = makeSystemMessage("connected"); auto connectedMsg = makeSystemMessage("connected");
connected->flags.set(MessageFlag::ConnectedMessage); connectedMsg->flags.set(MessageFlag::ConnectedMessage);
auto reconnected = makeSystemMessage("reconnected"); auto reconnected = makeSystemMessage("reconnected");
reconnected->flags.set(MessageFlag::ConnectedMessage); reconnected->flags.set(MessageFlag::ConnectedMessage);
@ -256,7 +256,7 @@ void AbstractIrcServer::onConnected()
continue; continue;
} }
chan->addMessage(connected); chan->addMessage(connectedMsg);
} }
this->falloffCounter_ = 1; this->falloffCounter_ = 1;
@ -268,7 +268,7 @@ void AbstractIrcServer::onDisconnected()
MessageBuilder b(systemMessage, "disconnected"); MessageBuilder b(systemMessage, "disconnected");
b->flags.set(MessageFlag::DisconnectedMessage); b->flags.set(MessageFlag::DisconnectedMessage);
auto disconnected = b.release(); auto disconnectedMsg = b.release();
for (std::weak_ptr<Channel> &weak : this->channels.values()) for (std::weak_ptr<Channel> &weak : this->channels.values())
{ {
@ -278,7 +278,7 @@ void AbstractIrcServer::onDisconnected()
continue; continue;
} }
chan->addMessage(disconnected); chan->addMessage(disconnectedMsg);
} }
} }

View file

@ -666,11 +666,11 @@ void TwitchChannel::refreshChatters()
{ {
// setting? // setting?
const auto streamStatus = this->accessStreamStatus(); const auto streamStatus = this->accessStreamStatus();
const auto viewerCount = static_cast<int>(streamStatus->viewerCount);
if (getSettings()->onlyFetchChattersForSmallerStreamers) if (getSettings()->onlyFetchChattersForSmallerStreamers)
{ {
if (streamStatus->live && if (streamStatus->live &&
streamStatus->viewerCount > getSettings()->smallStreamerLimit) viewerCount > getSettings()->smallStreamerLimit)
{ {
return; return;
} }
@ -722,8 +722,8 @@ void TwitchChannel::refreshBadges()
{ {
auto &versions = (*badgeSets)[jsonBadgeSet.key()]; auto &versions = (*badgeSets)[jsonBadgeSet.key()];
auto _ = jsonBadgeSet->toObject()["versions"].toObject(); auto _set = jsonBadgeSet->toObject()["versions"].toObject();
for (auto jsonVersion_ = _.begin(); jsonVersion_ != _.end(); for (auto jsonVersion_ = _set.begin(); jsonVersion_ != _set.end();
jsonVersion_++) jsonVersion_++)
{ {
auto jsonVersion = jsonVersion_->toObject(); auto jsonVersion = jsonVersion_->toObject();

View file

@ -334,13 +334,13 @@ MessagePtr TwitchMessageBuilder::build()
QRegularExpression emoteregex( QRegularExpression emoteregex(
"\\b" + std::get<2>(tup).string + "\\b", "\\b" + std::get<2>(tup).string + "\\b",
QRegularExpression::UseUnicodePropertiesOption); QRegularExpression::UseUnicodePropertiesOption);
auto match = emoteregex.match(midExtendedRef); auto _match = emoteregex.match(midExtendedRef);
if (match.hasMatch()) if (_match.hasMatch())
{ {
int last = match.lastCapturedIndex(); int last = _match.lastCapturedIndex();
for (int i = 0; i <= last; ++i) 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)); twitchEmotes.push_back(std::move(tup));
} }
} }
@ -781,16 +781,9 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
} }
// update the media player url if necessary // update the media player url if necessary
QUrl highlightSoundUrl; QUrl highlightSoundUrl = getSettings()->customHighlightSound
if (getSettings()->customHighlightSound) ? QUrl::fromLocalFile(getSettings()->pathHighlightSound.getValue())
{ : QUrl("qrc:/sounds/ping2.wav");
highlightSoundUrl =
QUrl::fromLocalFile(getSettings()->pathHighlightSound.getValue());
}
else
{
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
}
if (currentPlayerUrl != highlightSoundUrl) if (currentPlayerUrl != highlightSoundUrl)
{ {
@ -1040,11 +1033,11 @@ void TwitchMessageBuilder::appendTwitchBadges()
try try
{ {
if (twitchChannel) if (twitchChannel)
if (const auto &badge = this->twitchChannel->twitchBadge( if (const auto &_badge = this->twitchChannel->twitchBadge(
"bits", cheerAmount)) "bits", cheerAmount))
{ {
this->emplace<EmoteElement>( this->emplace<EmoteElement>(
badge.get(), MessageElementFlag::BadgeVanity) _badge.get(), MessageElementFlag::BadgeVanity)
->setTooltip(tooltip); ->setTooltip(tooltip);
continue; continue;
} }
@ -1055,10 +1048,10 @@ void TwitchMessageBuilder::appendTwitchBadges()
} }
// Use default bit badge // Use default bit badge
if (auto badge = this->twitchChannel->globalTwitchBadges().badge( if (auto _badge = this->twitchChannel->globalTwitchBadges().badge(
"bits", cheerAmount)) "bits", cheerAmount))
{ {
this->emplace<EmoteElement>(badge.get(), this->emplace<EmoteElement>(_badge.get(),
MessageElementFlag::BadgeVanity) MessageElementFlag::BadgeVanity)
->setTooltip(tooltip); ->setTooltip(tooltip);
} }
@ -1174,12 +1167,12 @@ void TwitchMessageBuilder::appendTwitchBadges()
->setTooltip((*badgeEmote)->tooltip.string); ->setTooltip((*badgeEmote)->tooltip.string);
continue; continue;
} }
if (auto badge = this->twitchChannel->globalTwitchBadges().badge( if (auto _badge = this->twitchChannel->globalTwitchBadges().badge(
splits[0], splits[1])) splits[0], splits[1]))
{ {
this->emplace<EmoteElement>(badge.get(), this->emplace<EmoteElement>(_badge.get(),
MessageElementFlag::BadgeVanity) MessageElementFlag::BadgeVanity)
->setTooltip((*badge)->tooltip.string); ->setTooltip((*_badge)->tooltip.string);
continue; continue;
} }
} }

View file

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

View file

@ -37,7 +37,7 @@ bool Paths::isPortable()
QString Paths::cacheDirectory() QString Paths::cacheDirectory()
{ {
static QStringSetting cachePathSetting = [] { static const auto path = [] {
QStringSetting cachePathSetting("/cache/path"); QStringSetting cachePathSetting("/cache/path");
cachePathSetting.connect([](const auto &newPath, auto) { cachePathSetting.connect([](const auto &newPath, auto) {
@ -45,11 +45,9 @@ QString Paths::cacheDirectory()
}); });
return cachePathSetting; return cachePathSetting;
}(); }().getValue();
auto path = cachePathSetting.getValue(); if (path.isEmpty())
if (path == "")
{ {
return this->cacheDirectory_; 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); return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a);
}; };
auto sat = qreal(0); const auto sat = qreal(0);
auto isLight_ = this->isLightTheme(); const auto isLight = this->isLightTheme();
auto flat = isLight_; const auto flat = isLight;
if (this->isLightTheme()) 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.border = getColor(0, sat, flat ? 1 : 0.85);
this->splits.header.text = this->messages.textColors.regular; this->splits.header.text = this->messages.textColors.regular;
this->splits.header.focusedText = 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.background = getColor(0, sat, flat ? 0.95 : 0.95);
this->splits.input.border = getColor(0, sat, flat ? 1 : 1); 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() + "border:" + this->tabs.selected.backgrounds.regular.color().name() +
";" + "color:" + this->messages.textColors.regular.name() + ";" + // ";" + "color:" + this->messages.textColors.regular.name() + ";" + //
"selection-background-color:" + "selection-background-color:" +
(isLight_ ? "#68B1FF" (isLight ? "#68B1FF"
: this->tabs.selected.backgrounds.regular.color().name()); : this->tabs.selected.backgrounds.regular.color().name());
this->splits.input.focusedLine = this->tabs.highlighted.line.regular; this->splits.input.focusedLine = this->tabs.highlighted.line.regular;
this->splits.messageSeperator = 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.background = getColor(0, sat, 1);
this->splits.dropPreview = QColor(0, 148, 255, 0x30); this->splits.dropPreview = QColor(0, 148, 255, 0x30);
this->splits.dropPreviewBorder = QColor(0, 148, 255, 0xff); this->splits.dropPreviewBorder = QColor(0, 148, 255, 0xff);

View file

@ -38,8 +38,9 @@ bool Toasts::isEnabled()
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
return WinToastLib::WinToast::isCompatible() && return WinToastLib::WinToast::isCompatible() &&
getSettings()->notificationToast; getSettings()->notificationToast;
#endif #else
return false; return false;
#endif
} }
QString Toasts::findStringFromReaction(const ToastReaction &reaction) QString Toasts::findStringFromReaction(const ToastReaction &reaction)

View file

@ -110,7 +110,7 @@ void Scrollbar::setSmallChange(qreal value)
void Scrollbar::setDesiredValue(qreal value, bool animated) void Scrollbar::setDesiredValue(qreal value, bool animated)
{ {
animated &= getSettings()->enableSmoothScrolling.getValue(); animated &= getSettings()->enableSmoothScrolling;
value = std::max(this->minimum_, value = std::max(this->minimum_,
std::min(this->maximum_ - this->largeChange_, value)); std::min(this->maximum_ - this->largeChange_, value));

View file

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

View file

@ -61,15 +61,10 @@ QString formatSize(qint64 size)
QString fetchLogDirectorySize() QString fetchLogDirectorySize()
{ {
QString logPathDirectory; QString logPathDirectory = getSettings()->logPath.getValue().isEmpty()
if (getSettings()->logPath == "") ? getPaths()->messageLogDirectory
{ : getSettings()->logPath;
logPathDirectory = getPaths()->messageLogDirectory;
}
else
{
logPathDirectory = getSettings()->logPath;
}
qint64 logsSize = dirSize(logPathDirectory); qint64 logsSize = dirSize(logPathDirectory);
QString logsSizeLabel = "Your logs currently take up "; QString logsSizeLabel = "Your logs currently take up ";
logsSizeLabel += formatSize(logsSize); logsSizeLabel += formatSize(logsSize);
@ -98,16 +93,9 @@ ModerationPage::ModerationPage()
// Logs (copied from LoggingMananger) // Logs (copied from LoggingMananger)
getSettings()->logPath.connect( getSettings()->logPath.connect(
[logsPathLabel](const QString &logPath, auto) mutable { [logsPathLabel](const QString &logPath, auto) mutable {
QString pathOriginal; QString pathOriginal = logPath.isEmpty()
? getPaths()->messageLogDirectory
if (logPath == "") : logPath;
{
pathOriginal = getPaths()->messageLogDirectory;
}
else
{
pathOriginal = logPath;
}
QString pathShortened = QString pathShortened =
"Logs are saved at <a href=\"file:///" + pathOriginal + "Logs are saved at <a href=\"file:///" + pathOriginal +
@ -120,7 +108,6 @@ ModerationPage::ModerationPage()
logsPathLabel->setTextFormat(Qt::RichText); logsPathLabel->setTextFormat(Qt::RichText);
logsPathLabel->setTextInteractionFlags(Qt::TextBrowserInteraction | logsPathLabel->setTextInteractionFlags(Qt::TextBrowserInteraction |
Qt::LinksAccessibleByKeyboard |
Qt::LinksAccessibleByKeyboard); Qt::LinksAccessibleByKeyboard);
logsPathLabel->setOpenExternalLinks(true); logsPathLabel->setOpenExternalLinks(true);
logs.append(this->createCheckBox("Enable logging", logs.append(this->createCheckBox("Enable logging",