mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
refactor: fix clang-tidy auto*, const&, and curly braces (#5083)
This commit is contained in:
parent
292f9b9734
commit
5b6675abb4
12
scripts/check-clang-tidy.sh
Executable file
12
scripts/check-clang-tidy.sh
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
clang-tidy --version
|
||||||
|
|
||||||
|
find \
|
||||||
|
src/ \
|
||||||
|
tests/src/ \
|
||||||
|
benchmarks/src/ \
|
||||||
|
mocks/include/ \
|
||||||
|
-type f \( -name "*.hpp" -o -name "*.cpp" \) -print0 | parallel -0 -j16 -I {} clang-tidy --quiet "$@" "{}"
|
|
@ -162,7 +162,7 @@ void Application::initialize(Settings &settings, Paths &paths)
|
||||||
getSettings()->currentVersion.getValue() != "" &&
|
getSettings()->currentVersion.getValue() != "" &&
|
||||||
getSettings()->currentVersion.getValue() != CHATTERINO_VERSION)
|
getSettings()->currentVersion.getValue() != CHATTERINO_VERSION)
|
||||||
{
|
{
|
||||||
auto box = new QMessageBox(QMessageBox::Information, "Chatterino 2",
|
auto *box = new QMessageBox(QMessageBox::Information, "Chatterino 2",
|
||||||
"Show changelog?",
|
"Show changelog?",
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
box->setAttribute(Qt::WA_DeleteOnClose);
|
box->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -193,10 +193,10 @@ void Application::initialize(Settings &settings, Paths &paths)
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
if (!this->args_.isFramelessEmbed && this->args_.crashRecovery)
|
if (!this->args_.isFramelessEmbed && this->args_.crashRecovery)
|
||||||
{
|
{
|
||||||
if (auto selected =
|
if (auto *selected =
|
||||||
this->windows->getMainWindow().getNotebook().getSelectedPage())
|
this->windows->getMainWindow().getNotebook().getSelectedPage())
|
||||||
{
|
{
|
||||||
if (auto container = dynamic_cast<SplitContainer *>(selected))
|
if (auto *container = dynamic_cast<SplitContainer *>(selected))
|
||||||
{
|
{
|
||||||
for (auto &&split : container->getSplits())
|
for (auto &&split : container->getSplits())
|
||||||
{
|
{
|
||||||
|
@ -459,7 +459,7 @@ void Application::initPubSub()
|
||||||
|
|
||||||
for (int i = snapshotLength - 1; i >= end; --i)
|
for (int i = snapshotLength - 1; i >= end; --i)
|
||||||
{
|
{
|
||||||
auto &s = snapshot[i];
|
const auto &s = snapshot[i];
|
||||||
if (!s->flags.has(MessageFlag::PubSub) &&
|
if (!s->flags.has(MessageFlag::PubSub) &&
|
||||||
s->timeoutUser == msg->timeoutUser)
|
s->timeoutUser == msg->timeoutUser)
|
||||||
{
|
{
|
||||||
|
@ -749,7 +749,7 @@ void Application::initPubSub()
|
||||||
auto reward = ChannelPointReward(data);
|
auto reward = ChannelPointReward(data);
|
||||||
|
|
||||||
postToThread([chan, reward] {
|
postToThread([chan, reward] {
|
||||||
if (auto channel = dynamic_cast<TwitchChannel *>(chan.get()))
|
if (auto *channel = dynamic_cast<TwitchChannel *>(chan.get()))
|
||||||
{
|
{
|
||||||
channel->addChannelPointReward(reward);
|
channel->addChannelPointReward(reward);
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,9 @@ void Args::applyCustomChannelLayout(const QString &argValue)
|
||||||
for (const WindowDescriptor &window : configLayout.windows_)
|
for (const WindowDescriptor &window : configLayout.windows_)
|
||||||
{
|
{
|
||||||
if (window.type_ != WindowType::Main)
|
if (window.type_ != WindowType::Main)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return window.geometry_;
|
return window.geometry_;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +214,9 @@ void Args::applyCustomChannelLayout(const QString &argValue)
|
||||||
for (const QString &channelArg : channelArgList)
|
for (const QString &channelArg : channelArgList)
|
||||||
{
|
{
|
||||||
if (channelArg.isEmpty())
|
if (channelArg.isEmpty())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Twitch is default platform
|
// Twitch is default platform
|
||||||
QString platform = "t";
|
QString platform = "t";
|
||||||
|
|
|
@ -82,7 +82,7 @@ LimitedQueueSnapshot<MessagePtr> Channel::getMessageSnapshot()
|
||||||
void Channel::addMessage(MessagePtr message,
|
void Channel::addMessage(MessagePtr message,
|
||||||
std::optional<MessageFlags> overridingFlags)
|
std::optional<MessageFlags> overridingFlags)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
MessagePtr deleted;
|
MessagePtr deleted;
|
||||||
|
|
||||||
if (!overridingFlags || !overridingFlags->has(MessageFlag::DoNotLog))
|
if (!overridingFlags || !overridingFlags->has(MessageFlag::DoNotLog))
|
||||||
|
@ -135,7 +135,7 @@ void Channel::disableAllMessages()
|
||||||
int snapshotLength = snapshot.size();
|
int snapshotLength = snapshot.size();
|
||||||
for (int i = 0; i < snapshotLength; i++)
|
for (int i = 0; i < snapshotLength; i++)
|
||||||
{
|
{
|
||||||
auto &message = snapshot[i];
|
const auto &message = snapshot[i];
|
||||||
if (message->flags.hasAny({MessageFlag::System, MessageFlag::Timeout,
|
if (message->flags.hasAny({MessageFlag::System, MessageFlag::Timeout,
|
||||||
MessageFlag::Whisper}))
|
MessageFlag::Whisper}))
|
||||||
{
|
{
|
||||||
|
@ -179,7 +179,7 @@ void Channel::fillInMissingMessages(const std::vector<MessagePtr> &messages)
|
||||||
existingMessageIds.reserve(snapshot.size());
|
existingMessageIds.reserve(snapshot.size());
|
||||||
|
|
||||||
// First, collect the ids of every message already present in the channel
|
// First, collect the ids of every message already present in the channel
|
||||||
for (auto &msg : snapshot)
|
for (const auto &msg : snapshot)
|
||||||
{
|
{
|
||||||
if (msg->flags.has(MessageFlag::System) || msg->id.isEmpty())
|
if (msg->flags.has(MessageFlag::System) || msg->id.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -196,7 +196,7 @@ void Channel::fillInMissingMessages(const std::vector<MessagePtr> &messages)
|
||||||
// being able to insert just-loaded historical messages at the end
|
// being able to insert just-loaded historical messages at the end
|
||||||
// in the correct place.
|
// in the correct place.
|
||||||
auto lastMsg = snapshot[snapshot.size() - 1];
|
auto lastMsg = snapshot[snapshot.size() - 1];
|
||||||
for (auto &msg : messages)
|
for (const auto &msg : messages)
|
||||||
{
|
{
|
||||||
// check if message already exists
|
// check if message already exists
|
||||||
if (existingMessageIds.count(msg->id) != 0)
|
if (existingMessageIds.count(msg->id) != 0)
|
||||||
|
@ -208,7 +208,7 @@ void Channel::fillInMissingMessages(const std::vector<MessagePtr> &messages)
|
||||||
anyInserted = true;
|
anyInserted = true;
|
||||||
|
|
||||||
bool insertedFlag = false;
|
bool insertedFlag = false;
|
||||||
for (auto &snapshotMsg : snapshot)
|
for (const auto &snapshotMsg : snapshot)
|
||||||
{
|
{
|
||||||
if (snapshotMsg->flags.has(MessageFlag::System))
|
if (snapshotMsg->flags.has(MessageFlag::System))
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,12 +27,16 @@ void ChatterSet::updateOnlineChatters(
|
||||||
for (auto &&chatter : lowerCaseUsernames)
|
for (auto &&chatter : lowerCaseUsernames)
|
||||||
{
|
{
|
||||||
if (this->items.exists(chatter))
|
if (this->items.exists(chatter))
|
||||||
|
{
|
||||||
tmp.put(chatter, this->items.get(chatter));
|
tmp.put(chatter, this->items.get(chatter));
|
||||||
|
|
||||||
// Less chatters than the limit => try to preserve as many as possible.
|
// Less chatters than the limit => try to preserve as many as possible.
|
||||||
|
}
|
||||||
else if (lowerCaseUsernames.size() < chatterLimit)
|
else if (lowerCaseUsernames.size() < chatterLimit)
|
||||||
|
{
|
||||||
tmp.put(chatter, chatter);
|
tmp.put(chatter, chatter);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->items = std::move(tmp);
|
this->items = std::move(tmp);
|
||||||
}
|
}
|
||||||
|
@ -50,8 +54,10 @@ std::vector<QString> ChatterSet::filterByPrefix(const QString &prefix) const
|
||||||
for (auto &&item : this->items)
|
for (auto &&item : this->items)
|
||||||
{
|
{
|
||||||
if (item.first.startsWith(lowerPrefix))
|
if (item.first.startsWith(lowerPrefix))
|
||||||
|
{
|
||||||
result.push_back(item.second);
|
result.push_back(item.second);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,14 @@ public:
|
||||||
void set(T flag, bool value)
|
void set(T flag, bool value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
|
{
|
||||||
this->set(flag);
|
this->set(flag);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
this->unset(flag);
|
this->unset(flag);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool has(T flag) const
|
bool has(T flag) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -308,10 +308,12 @@ public:
|
||||||
for (auto &&x : list)
|
for (auto &&x : list)
|
||||||
{
|
{
|
||||||
if (x.row() != list.first().row())
|
if (x.row() != list.first().row())
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto data = new QMimeData;
|
auto *data = new QMimeData;
|
||||||
data->setData("chatterino_row_id", QByteArray::number(list[0].row()));
|
data->setData("chatterino_row_id", QByteArray::number(list[0].row()));
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ AccountController::AccountController()
|
||||||
this->twitch.accounts.itemRemoved.connect([this](const auto &args) {
|
this->twitch.accounts.itemRemoved.connect([this](const auto &args) {
|
||||||
if (args.caller != this)
|
if (args.caller != this)
|
||||||
{
|
{
|
||||||
auto &accs = this->twitch.accounts.raw();
|
const auto &accs = this->twitch.accounts.raw();
|
||||||
auto it = std::find(accs.begin(), accs.end(), args.item);
|
auto it = std::find(accs.begin(), accs.end(), args.item);
|
||||||
assert(it != accs.end());
|
assert(it != accs.end());
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ QString sendShoutout(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto *twitchChannel = ctx.twitchChannel;
|
auto *twitchChannel = ctx.twitchChannel;
|
||||||
auto channel = ctx.channel;
|
auto channel = ctx.channel;
|
||||||
auto words = &ctx.words;
|
const auto *words = &ctx.words;
|
||||||
|
|
||||||
if (twitchChannel == nullptr)
|
if (twitchChannel == nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,8 +19,10 @@ FilterSet::FilterSet(const QList<QUuid> &filterIds)
|
||||||
for (const auto &f : *filters)
|
for (const auto &f : *filters)
|
||||||
{
|
{
|
||||||
if (filterIds.contains(f->getId()))
|
if (filterIds.contains(f->getId()))
|
||||||
|
{
|
||||||
this->filters_.insert(f->getId(), f);
|
this->filters_.insert(f->getId(), f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->listener_ =
|
this->listener_ =
|
||||||
getSettings()->filterRecords.delayedItemsChanged.connect([this] {
|
getSettings()->filterRecords.delayedItemsChanged.connect([this] {
|
||||||
|
@ -36,14 +38,18 @@ FilterSet::~FilterSet()
|
||||||
bool FilterSet::filter(const MessagePtr &m, ChannelPtr channel) const
|
bool FilterSet::filter(const MessagePtr &m, ChannelPtr channel) const
|
||||||
{
|
{
|
||||||
if (this->filters_.size() == 0)
|
if (this->filters_.size() == 0)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
filters::ContextMap context = filters::buildContextMap(m, channel.get());
|
filters::ContextMap context = filters::buildContextMap(m, channel.get());
|
||||||
for (const auto &f : this->filters_.values())
|
for (const auto &f : this->filters_.values())
|
||||||
{
|
{
|
||||||
if (!f->valid() || !f->filter(context))
|
if (!f->valid() || !f->filter(context))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,9 @@ QString Tokenizer::current() const
|
||||||
QString Tokenizer::preview() const
|
QString Tokenizer::preview() const
|
||||||
{
|
{
|
||||||
if (this->hasNext())
|
if (this->hasNext())
|
||||||
|
{
|
||||||
return this->tokens_.at(this->i_);
|
return this->tokens_.at(this->i_);
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,51 +174,97 @@ const QStringList Tokenizer::allTokens()
|
||||||
TokenType Tokenizer::tokenize(const QString &text)
|
TokenType Tokenizer::tokenize(const QString &text)
|
||||||
{
|
{
|
||||||
if (text == "&&")
|
if (text == "&&")
|
||||||
|
{
|
||||||
return TokenType::AND;
|
return TokenType::AND;
|
||||||
|
}
|
||||||
else if (text == "||")
|
else if (text == "||")
|
||||||
|
{
|
||||||
return TokenType::OR;
|
return TokenType::OR;
|
||||||
|
}
|
||||||
else if (text == "(")
|
else if (text == "(")
|
||||||
|
{
|
||||||
return TokenType::LP;
|
return TokenType::LP;
|
||||||
|
}
|
||||||
else if (text == ")")
|
else if (text == ")")
|
||||||
|
{
|
||||||
return TokenType::RP;
|
return TokenType::RP;
|
||||||
|
}
|
||||||
else if (text == "{")
|
else if (text == "{")
|
||||||
|
{
|
||||||
return TokenType::LIST_START;
|
return TokenType::LIST_START;
|
||||||
|
}
|
||||||
else if (text == "}")
|
else if (text == "}")
|
||||||
|
{
|
||||||
return TokenType::LIST_END;
|
return TokenType::LIST_END;
|
||||||
|
}
|
||||||
else if (text == ",")
|
else if (text == ",")
|
||||||
|
{
|
||||||
return TokenType::COMMA;
|
return TokenType::COMMA;
|
||||||
|
}
|
||||||
else if (text == "+")
|
else if (text == "+")
|
||||||
|
{
|
||||||
return TokenType::PLUS;
|
return TokenType::PLUS;
|
||||||
|
}
|
||||||
else if (text == "-")
|
else if (text == "-")
|
||||||
|
{
|
||||||
return TokenType::MINUS;
|
return TokenType::MINUS;
|
||||||
|
}
|
||||||
else if (text == "*")
|
else if (text == "*")
|
||||||
|
{
|
||||||
return TokenType::MULTIPLY;
|
return TokenType::MULTIPLY;
|
||||||
|
}
|
||||||
else if (text == "/")
|
else if (text == "/")
|
||||||
|
{
|
||||||
return TokenType::DIVIDE;
|
return TokenType::DIVIDE;
|
||||||
|
}
|
||||||
else if (text == "==")
|
else if (text == "==")
|
||||||
|
{
|
||||||
return TokenType::EQ;
|
return TokenType::EQ;
|
||||||
|
}
|
||||||
else if (text == "!=")
|
else if (text == "!=")
|
||||||
|
{
|
||||||
return TokenType::NEQ;
|
return TokenType::NEQ;
|
||||||
|
}
|
||||||
else if (text == "%")
|
else if (text == "%")
|
||||||
|
{
|
||||||
return TokenType::MOD;
|
return TokenType::MOD;
|
||||||
|
}
|
||||||
else if (text == "<")
|
else if (text == "<")
|
||||||
|
{
|
||||||
return TokenType::LT;
|
return TokenType::LT;
|
||||||
|
}
|
||||||
else if (text == ">")
|
else if (text == ">")
|
||||||
|
{
|
||||||
return TokenType::GT;
|
return TokenType::GT;
|
||||||
|
}
|
||||||
else if (text == "<=")
|
else if (text == "<=")
|
||||||
|
{
|
||||||
return TokenType::LTE;
|
return TokenType::LTE;
|
||||||
|
}
|
||||||
else if (text == ">=")
|
else if (text == ">=")
|
||||||
|
{
|
||||||
return TokenType::GTE;
|
return TokenType::GTE;
|
||||||
|
}
|
||||||
else if (text == "contains")
|
else if (text == "contains")
|
||||||
|
{
|
||||||
return TokenType::CONTAINS;
|
return TokenType::CONTAINS;
|
||||||
|
}
|
||||||
else if (text == "startswith")
|
else if (text == "startswith")
|
||||||
|
{
|
||||||
return TokenType::STARTS_WITH;
|
return TokenType::STARTS_WITH;
|
||||||
|
}
|
||||||
else if (text == "endswith")
|
else if (text == "endswith")
|
||||||
|
{
|
||||||
return TokenType::ENDS_WITH;
|
return TokenType::ENDS_WITH;
|
||||||
|
}
|
||||||
else if (text == "match")
|
else if (text == "match")
|
||||||
|
{
|
||||||
return TokenType::MATCH;
|
return TokenType::MATCH;
|
||||||
|
}
|
||||||
else if (text == "!")
|
else if (text == "!")
|
||||||
|
{
|
||||||
return TokenType::NOT;
|
return TokenType::NOT;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((text.startsWith("r\"") || text.startsWith("ri\"")) &&
|
if ((text.startsWith("r\"") || text.startsWith("ri\"")) &&
|
||||||
|
@ -226,15 +274,21 @@ TokenType Tokenizer::tokenize(const QString &text)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.front() == '"' && text.back() == '"')
|
if (text.front() == '"' && text.back() == '"')
|
||||||
|
{
|
||||||
return TokenType::STRING;
|
return TokenType::STRING;
|
||||||
|
}
|
||||||
|
|
||||||
if (validIdentifiersMap.keys().contains(text))
|
if (validIdentifiersMap.keys().contains(text))
|
||||||
|
{
|
||||||
return TokenType::IDENTIFIER;
|
return TokenType::IDENTIFIER;
|
||||||
|
}
|
||||||
|
|
||||||
bool flag;
|
bool flag;
|
||||||
if (text.toInt(&flag); flag)
|
if (text.toInt(&flag); flag)
|
||||||
|
{
|
||||||
return TokenType::INT;
|
return TokenType::INT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TokenType::NONE;
|
return TokenType::NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,27 +69,39 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
return 0;
|
return 0;
|
||||||
case MINUS:
|
case MINUS:
|
||||||
if (convertVariantTypes(left, right, QMetaType::Int))
|
if (convertVariantTypes(left, right, QMetaType::Int))
|
||||||
|
{
|
||||||
return left.toInt() - right.toInt();
|
return left.toInt() - right.toInt();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case MULTIPLY:
|
case MULTIPLY:
|
||||||
if (convertVariantTypes(left, right, QMetaType::Int))
|
if (convertVariantTypes(left, right, QMetaType::Int))
|
||||||
|
{
|
||||||
return left.toInt() * right.toInt();
|
return left.toInt() * right.toInt();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case DIVIDE:
|
case DIVIDE:
|
||||||
if (convertVariantTypes(left, right, QMetaType::Int))
|
if (convertVariantTypes(left, right, QMetaType::Int))
|
||||||
|
{
|
||||||
return left.toInt() / right.toInt();
|
return left.toInt() / right.toInt();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case MOD:
|
case MOD:
|
||||||
if (convertVariantTypes(left, right, QMetaType::Int))
|
if (convertVariantTypes(left, right, QMetaType::Int))
|
||||||
|
{
|
||||||
return left.toInt() % right.toInt();
|
return left.toInt() % right.toInt();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case OR:
|
case OR:
|
||||||
if (convertVariantTypes(left, right, QMetaType::Bool))
|
if (convertVariantTypes(left, right, QMetaType::Bool))
|
||||||
|
{
|
||||||
return left.toBool() || right.toBool();
|
return left.toBool() || right.toBool();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
case AND:
|
case AND:
|
||||||
if (convertVariantTypes(left, right, QMetaType::Bool))
|
if (convertVariantTypes(left, right, QMetaType::Bool))
|
||||||
|
{
|
||||||
return left.toBool() && right.toBool();
|
return left.toBool() && right.toBool();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
case EQ:
|
case EQ:
|
||||||
if (variantTypesMatch(left, right, QMetaType::QString))
|
if (variantTypesMatch(left, right, QMetaType::QString))
|
||||||
|
@ -107,19 +119,27 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
return !looselyCompareVariants(left, right);
|
return !looselyCompareVariants(left, right);
|
||||||
case LT:
|
case LT:
|
||||||
if (convertVariantTypes(left, right, QMetaType::Int))
|
if (convertVariantTypes(left, right, QMetaType::Int))
|
||||||
|
{
|
||||||
return left.toInt() < right.toInt();
|
return left.toInt() < right.toInt();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
case GT:
|
case GT:
|
||||||
if (convertVariantTypes(left, right, QMetaType::Int))
|
if (convertVariantTypes(left, right, QMetaType::Int))
|
||||||
|
{
|
||||||
return left.toInt() > right.toInt();
|
return left.toInt() > right.toInt();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
case LTE:
|
case LTE:
|
||||||
if (convertVariantTypes(left, right, QMetaType::Int))
|
if (convertVariantTypes(left, right, QMetaType::Int))
|
||||||
|
{
|
||||||
return left.toInt() <= right.toInt();
|
return left.toInt() <= right.toInt();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
case GTE:
|
case GTE:
|
||||||
if (convertVariantTypes(left, right, QMetaType::Int))
|
if (convertVariantTypes(left, right, QMetaType::Int))
|
||||||
|
{
|
||||||
return left.toInt() >= right.toInt();
|
return left.toInt() >= right.toInt();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
case CONTAINS:
|
case CONTAINS:
|
||||||
if (variantIs(left, QMetaType::QStringList) &&
|
if (variantIs(left, QMetaType::QStringList) &&
|
||||||
|
@ -215,23 +235,31 @@ QVariant BinaryOperation::execute(const ContextMap &context) const
|
||||||
|
|
||||||
// list must be two items
|
// list must be two items
|
||||||
if (list.size() != 2)
|
if (list.size() != 2)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// list must be a regular expression and an int
|
// list must be a regular expression and an int
|
||||||
if (variantIsNot(list.at(0),
|
if (variantIsNot(list.at(0),
|
||||||
QMetaType::QRegularExpression) ||
|
QMetaType::QRegularExpression) ||
|
||||||
variantIsNot(list.at(1), QMetaType::Int))
|
variantIsNot(list.at(1), QMetaType::Int))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto match =
|
auto match =
|
||||||
list.at(0).toRegularExpression().match(matching);
|
list.at(0).toRegularExpression().match(matching);
|
||||||
|
|
||||||
// if matched, return nth capture group. Otherwise, return ""
|
// if matched, return nth capture group. Otherwise, return ""
|
||||||
if (match.hasMatch())
|
if (match.hasMatch())
|
||||||
|
{
|
||||||
return match.captured(list.at(1).toInt());
|
return match.captured(list.at(1).toInt());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -263,9 +291,13 @@ PossibleType BinaryOperation::synthesizeType(const TypingContext &context) const
|
||||||
{
|
{
|
||||||
case PLUS:
|
case PLUS:
|
||||||
if (left == Type::String)
|
if (left == Type::String)
|
||||||
|
{
|
||||||
return TypeClass{Type::String}; // String concatenation
|
return TypeClass{Type::String}; // String concatenation
|
||||||
|
}
|
||||||
else if (left == Type::Int && right == Type::Int)
|
else if (left == Type::Int && right == Type::Int)
|
||||||
|
{
|
||||||
return TypeClass{Type::Int};
|
return TypeClass{Type::Int};
|
||||||
|
}
|
||||||
|
|
||||||
return IllTyped{this, "Can only add Ints or concatenate a String"};
|
return IllTyped{this, "Can only add Ints or concatenate a String"};
|
||||||
case MINUS:
|
case MINUS:
|
||||||
|
@ -273,13 +305,17 @@ PossibleType BinaryOperation::synthesizeType(const TypingContext &context) const
|
||||||
case DIVIDE:
|
case DIVIDE:
|
||||||
case MOD:
|
case MOD:
|
||||||
if (left == Type::Int && right == Type::Int)
|
if (left == Type::Int && right == Type::Int)
|
||||||
|
{
|
||||||
return TypeClass{Type::Int};
|
return TypeClass{Type::Int};
|
||||||
|
}
|
||||||
|
|
||||||
return IllTyped{this, "Can only perform operation with Ints"};
|
return IllTyped{this, "Can only perform operation with Ints"};
|
||||||
case OR:
|
case OR:
|
||||||
case AND:
|
case AND:
|
||||||
if (left == Type::Bool && right == Type::Bool)
|
if (left == Type::Bool && right == Type::Bool)
|
||||||
|
{
|
||||||
return TypeClass{Type::Bool};
|
return TypeClass{Type::Bool};
|
||||||
|
}
|
||||||
|
|
||||||
return IllTyped{this,
|
return IllTyped{this,
|
||||||
"Can only perform logical operations with Bools"};
|
"Can only perform logical operations with Bools"};
|
||||||
|
@ -292,37 +328,53 @@ PossibleType BinaryOperation::synthesizeType(const TypingContext &context) const
|
||||||
case LTE:
|
case LTE:
|
||||||
case GTE:
|
case GTE:
|
||||||
if (left == Type::Int && right == Type::Int)
|
if (left == Type::Int && right == Type::Int)
|
||||||
|
{
|
||||||
return TypeClass{Type::Bool};
|
return TypeClass{Type::Bool};
|
||||||
|
}
|
||||||
|
|
||||||
return IllTyped{this, "Can only perform comparisons with Ints"};
|
return IllTyped{this, "Can only perform comparisons with Ints"};
|
||||||
case STARTS_WITH:
|
case STARTS_WITH:
|
||||||
case ENDS_WITH:
|
case ENDS_WITH:
|
||||||
if (isList(left))
|
if (isList(left))
|
||||||
|
{
|
||||||
return TypeClass{Type::Bool};
|
return TypeClass{Type::Bool};
|
||||||
|
}
|
||||||
if (left == Type::String && right == Type::String)
|
if (left == Type::String && right == Type::String)
|
||||||
|
{
|
||||||
return TypeClass{Type::Bool};
|
return TypeClass{Type::Bool};
|
||||||
|
}
|
||||||
|
|
||||||
return IllTyped{
|
return IllTyped{
|
||||||
this,
|
this,
|
||||||
"Can only perform starts/ends with a List or two Strings"};
|
"Can only perform starts/ends with a List or two Strings"};
|
||||||
case CONTAINS:
|
case CONTAINS:
|
||||||
if (isList(left) || left == Type::Map)
|
if (isList(left) || left == Type::Map)
|
||||||
|
{
|
||||||
return TypeClass{Type::Bool};
|
return TypeClass{Type::Bool};
|
||||||
|
}
|
||||||
if (left == Type::String && right == Type::String)
|
if (left == Type::String && right == Type::String)
|
||||||
|
{
|
||||||
return TypeClass{Type::Bool};
|
return TypeClass{Type::Bool};
|
||||||
|
}
|
||||||
|
|
||||||
return IllTyped{
|
return IllTyped{
|
||||||
this,
|
this,
|
||||||
"Can only perform contains with a List, a Map, or two Strings"};
|
"Can only perform contains with a List, a Map, or two Strings"};
|
||||||
case MATCH: {
|
case MATCH: {
|
||||||
if (left != Type::String)
|
if (left != Type::String)
|
||||||
|
{
|
||||||
return IllTyped{this,
|
return IllTyped{this,
|
||||||
"Left argument of match must be a String"};
|
"Left argument of match must be a String"};
|
||||||
|
}
|
||||||
|
|
||||||
if (right == Type::RegularExpression)
|
if (right == Type::RegularExpression)
|
||||||
|
{
|
||||||
return TypeClass{Type::Bool};
|
return TypeClass{Type::Bool};
|
||||||
if (right == Type::MatchingSpecifier) // group capturing
|
}
|
||||||
|
if (right == Type::MatchingSpecifier)
|
||||||
|
{ // group capturing
|
||||||
return TypeClass{Type::String};
|
return TypeClass{Type::String};
|
||||||
|
}
|
||||||
|
|
||||||
return IllTyped{this, "Can only match on a RegularExpression or a "
|
return IllTyped{this, "Can only match on a RegularExpression or a "
|
||||||
"MatchingSpecifier"};
|
"MatchingSpecifier"};
|
||||||
|
|
|
@ -123,7 +123,9 @@ struct Deserialize<chatterino::HighlightBadge> {
|
||||||
|
|
||||||
auto _color = QColor(encodedColor);
|
auto _color = QColor(encodedColor);
|
||||||
if (!_color.isValid())
|
if (!_color.isValid())
|
||||||
|
{
|
||||||
_color = chatterino::HighlightBadge::FALLBACK_HIGHLIGHT_COLOR;
|
_color = chatterino::HighlightBadge::FALLBACK_HIGHLIGHT_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
return chatterino::HighlightBadge(_name, _displayName, _showInMentions,
|
return chatterino::HighlightBadge(_name, _displayName, _showInMentions,
|
||||||
_hasAlert, _hasSound, _soundUrl,
|
_hasAlert, _hasSound, _soundUrl,
|
||||||
|
|
|
@ -164,7 +164,9 @@ struct Deserialize<chatterino::HighlightPhrase> {
|
||||||
|
|
||||||
auto _color = QColor(encodedColor);
|
auto _color = QColor(encodedColor);
|
||||||
if (!_color.isValid())
|
if (!_color.isValid())
|
||||||
|
{
|
||||||
_color = chatterino::HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR;
|
_color = chatterino::HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
return chatterino::HighlightPhrase(_pattern, _showInMentions, _hasAlert,
|
return chatterino::HighlightPhrase(_pattern, _showInMentions, _hasAlert,
|
||||||
_hasSound, _isRegex,
|
_hasSound, _isRegex,
|
||||||
|
|
|
@ -66,7 +66,7 @@ std::vector<QShortcut *> HotkeyController::shortcutsForCategory(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto createShortcutFromKeySeq = [&](QKeySequence qs) {
|
auto createShortcutFromKeySeq = [&](QKeySequence qs) {
|
||||||
auto s = new QShortcut(qs, parent);
|
auto *s = new QShortcut(qs, parent);
|
||||||
s->setContext(hotkey->getContext());
|
s->setContext(hotkey->getContext());
|
||||||
auto functionPointer = target->second;
|
auto functionPointer = target->second;
|
||||||
QObject::connect(s, &QShortcut::activated, parent,
|
QObject::connect(s, &QShortcut::activated, parent,
|
||||||
|
@ -101,7 +101,7 @@ void HotkeyController::save()
|
||||||
|
|
||||||
std::shared_ptr<Hotkey> HotkeyController::getHotkeyByName(QString name)
|
std::shared_ptr<Hotkey> HotkeyController::getHotkeyByName(QString name)
|
||||||
{
|
{
|
||||||
for (auto &hotkey : this->hotkeys_)
|
for (const auto &hotkey : this->hotkeys_)
|
||||||
{
|
{
|
||||||
if (hotkey->name() == name)
|
if (hotkey->name() == name)
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ int HotkeyController::replaceHotkey(QString oldName,
|
||||||
std::shared_ptr<Hotkey> newHotkey)
|
std::shared_ptr<Hotkey> newHotkey)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto &hotkey : this->hotkeys_)
|
for (const auto &hotkey : this->hotkeys_)
|
||||||
{
|
{
|
||||||
if (hotkey->name() == oldName)
|
if (hotkey->name() == oldName)
|
||||||
{
|
{
|
||||||
|
@ -544,7 +544,7 @@ void HotkeyController::tryAddDefault(std::set<QString> &addedHotkeys,
|
||||||
void HotkeyController::showHotkeyError(const std::shared_ptr<Hotkey> &hotkey,
|
void HotkeyController::showHotkeyError(const std::shared_ptr<Hotkey> &hotkey,
|
||||||
QString warning)
|
QString warning)
|
||||||
{
|
{
|
||||||
auto msgBox = new QMessageBox(
|
auto *msgBox = new QMessageBox(
|
||||||
QMessageBox::Icon::Warning, "Hotkey error",
|
QMessageBox::Icon::Warning, "Hotkey error",
|
||||||
QString(
|
QString(
|
||||||
"There was an error while executing your hotkey named \"%1\": \n%2")
|
"There was an error while executing your hotkey named \"%1\": \n%2")
|
||||||
|
|
|
@ -143,12 +143,16 @@ const std::optional<ImagePtr> &ModerationAction::getImage() const
|
||||||
if (this->imageToLoad_ != 0)
|
if (this->imageToLoad_ != 0)
|
||||||
{
|
{
|
||||||
if (this->imageToLoad_ == 1)
|
if (this->imageToLoad_ == 1)
|
||||||
|
{
|
||||||
this->image_ =
|
this->image_ =
|
||||||
Image::fromResourcePixmap(getResources().buttons.ban);
|
Image::fromResourcePixmap(getResources().buttons.ban);
|
||||||
|
}
|
||||||
else if (this->imageToLoad_ == 2)
|
else if (this->imageToLoad_ == 2)
|
||||||
|
{
|
||||||
this->image_ =
|
this->image_ =
|
||||||
Image::fromResourcePixmap(getResources().buttons.trashCan);
|
Image::fromResourcePixmap(getResources().buttons.trashCan);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this->image_;
|
return this->image_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ void NotificationController::removeFakeChannel(const QString channelName)
|
||||||
|
|
||||||
for (int i = snapshotLength - 1; i >= end; --i)
|
for (int i = snapshotLength - 1; i >= end; --i)
|
||||||
{
|
{
|
||||||
auto &s = snapshot[i];
|
const auto &s = snapshot[i];
|
||||||
|
|
||||||
if (s->messageText == liveMessageSearchText)
|
if (s->messageText == liveMessageSearchText)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,9 @@ EmotePtr cachedOrMakeEmotePtr(Emote &&emote, const EmoteMap &cache)
|
||||||
// reuse old shared_ptr if nothing changed
|
// reuse old shared_ptr if nothing changed
|
||||||
auto it = cache.find(emote.name);
|
auto it = cache.find(emote.name);
|
||||||
if (it != cache.end() && *it->second == emote)
|
if (it != cache.end() && *it->second == emote)
|
||||||
|
{
|
||||||
return it->second;
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
return std::make_shared<Emote>(std::move(emote));
|
return std::make_shared<Emote>(std::move(emote));
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,9 @@ namespace detail {
|
||||||
// https://github.com/SevenTV/chatterino7/issues/46#issuecomment-1010595231
|
// https://github.com/SevenTV/chatterino7/issues/46#issuecomment-1010595231
|
||||||
int duration = reader.nextImageDelay();
|
int duration = reader.nextImageDelay();
|
||||||
if (duration <= 10)
|
if (duration <= 10)
|
||||||
|
{
|
||||||
duration = 100;
|
duration = 100;
|
||||||
|
}
|
||||||
duration = std::max(20, duration);
|
duration = std::max(20, duration);
|
||||||
frames.push_back(Frame<QImage>{std::move(image), duration});
|
frames.push_back(Frame<QImage>{std::move(image), duration});
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,13 @@ const std::shared_ptr<Image> &getImagePriv(const ImageSet &set, float scale)
|
||||||
int quality = 1;
|
int quality = 1;
|
||||||
|
|
||||||
if (scale > 2.001f)
|
if (scale > 2.001f)
|
||||||
|
{
|
||||||
quality = 3;
|
quality = 3;
|
||||||
|
}
|
||||||
else if (scale > 1.001f)
|
else if (scale > 1.001f)
|
||||||
|
{
|
||||||
quality = 2;
|
quality = 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (!set.getImage3()->isEmpty() && quality == 3)
|
if (!set.getImage3()->isEmpty() && quality == 3)
|
||||||
{
|
{
|
||||||
|
@ -92,18 +96,28 @@ const ImagePtr &ImageSet::getImageOrLoaded(float scale) const
|
||||||
|
|
||||||
// prefer other image if selected image is not loaded yet
|
// prefer other image if selected image is not loaded yet
|
||||||
if (result->loaded())
|
if (result->loaded())
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
else if (this->imageX3_ && !this->imageX3_->isEmpty() &&
|
else if (this->imageX3_ && !this->imageX3_->isEmpty() &&
|
||||||
this->imageX3_->loaded())
|
this->imageX3_->loaded())
|
||||||
|
{
|
||||||
return this->imageX3_;
|
return this->imageX3_;
|
||||||
|
}
|
||||||
else if (this->imageX2_ && !this->imageX2_->isEmpty() &&
|
else if (this->imageX2_ && !this->imageX2_->isEmpty() &&
|
||||||
this->imageX2_->loaded())
|
this->imageX2_->loaded())
|
||||||
|
{
|
||||||
return this->imageX2_;
|
return this->imageX2_;
|
||||||
|
}
|
||||||
else if (this->imageX1_->loaded())
|
else if (this->imageX1_->loaded())
|
||||||
|
{
|
||||||
return this->imageX1_;
|
return this->imageX1_;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ImagePtr &ImageSet::getImage(float scale) const
|
const ImagePtr &ImageSet::getImage(float scale) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -637,11 +637,11 @@ void MessageBuilder::addLink(const ParsedLink &parsedLink)
|
||||||
auto linkElement = Link(Link::Url, matchedLink);
|
auto linkElement = Link(Link::Url, matchedLink);
|
||||||
|
|
||||||
auto textColor = MessageColor(MessageColor::Link);
|
auto textColor = MessageColor(MessageColor::Link);
|
||||||
auto linkMELowercase =
|
auto *linkMELowercase =
|
||||||
this->emplace<TextElement>(lowercaseLinkString,
|
this->emplace<TextElement>(lowercaseLinkString,
|
||||||
MessageElementFlag::LowercaseLink, textColor)
|
MessageElementFlag::LowercaseLink, textColor)
|
||||||
->setLink(linkElement);
|
->setLink(linkElement);
|
||||||
auto linkMEOriginal =
|
auto *linkMEOriginal =
|
||||||
this->emplace<TextElement>(origLink, MessageElementFlag::OriginalLink,
|
this->emplace<TextElement>(origLink, MessageElementFlag::OriginalLink,
|
||||||
textColor)
|
textColor)
|
||||||
->setLink(linkElement);
|
->setLink(linkElement);
|
||||||
|
|
|
@ -212,7 +212,9 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container,
|
||||||
auto image =
|
auto image =
|
||||||
this->emote_->images.getImageOrLoaded(container.getScale());
|
this->emote_->images.getImageOrLoaded(container.getScale());
|
||||||
if (image->isEmpty())
|
if (image->isEmpty())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto emoteScale = getSettings()->emoteScale.getValue();
|
auto emoteScale = getSettings()->emoteScale.getValue();
|
||||||
|
|
||||||
|
@ -420,7 +422,9 @@ void BadgeElement::addToContainer(MessageLayoutContainer &container,
|
||||||
auto image =
|
auto image =
|
||||||
this->emote_->images.getImageOrLoaded(container.getScale());
|
this->emote_->images.getImageOrLoaded(container.getScale());
|
||||||
if (image->isEmpty())
|
if (image->isEmpty())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto size = QSize(int(container.getScale() * image->width()),
|
auto size = QSize(int(container.getScale() * image->width()),
|
||||||
int(container.getScale() * image->height()));
|
int(container.getScale() * image->height()));
|
||||||
|
@ -437,7 +441,7 @@ EmotePtr BadgeElement::getEmote() const
|
||||||
MessageLayoutElement *BadgeElement::makeImageLayoutElement(
|
MessageLayoutElement *BadgeElement::makeImageLayoutElement(
|
||||||
const ImagePtr &image, const QSize &size)
|
const ImagePtr &image, const QSize &size)
|
||||||
{
|
{
|
||||||
auto element =
|
auto *element =
|
||||||
(new ImageLayoutElement(*this, image, size))->setLink(this->getLink());
|
(new ImageLayoutElement(*this, image, size))->setLink(this->getLink());
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
|
@ -455,7 +459,7 @@ MessageLayoutElement *ModBadgeElement::makeImageLayoutElement(
|
||||||
{
|
{
|
||||||
static const QColor modBadgeBackgroundColor("#34AE0A");
|
static const QColor modBadgeBackgroundColor("#34AE0A");
|
||||||
|
|
||||||
auto element = (new ImageWithBackgroundLayoutElement(
|
auto *element = (new ImageWithBackgroundLayoutElement(
|
||||||
*this, image, size, modBadgeBackgroundColor))
|
*this, image, size, modBadgeBackgroundColor))
|
||||||
->setLink(this->getLink());
|
->setLink(this->getLink());
|
||||||
|
|
||||||
|
@ -472,7 +476,7 @@ VipBadgeElement::VipBadgeElement(const EmotePtr &data,
|
||||||
MessageLayoutElement *VipBadgeElement::makeImageLayoutElement(
|
MessageLayoutElement *VipBadgeElement::makeImageLayoutElement(
|
||||||
const ImagePtr &image, const QSize &size)
|
const ImagePtr &image, const QSize &size)
|
||||||
{
|
{
|
||||||
auto element =
|
auto *element =
|
||||||
(new ImageLayoutElement(*this, image, size))->setLink(this->getLink());
|
(new ImageLayoutElement(*this, image, size))->setLink(this->getLink());
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
|
@ -489,7 +493,7 @@ FfzBadgeElement::FfzBadgeElement(const EmotePtr &data,
|
||||||
MessageLayoutElement *FfzBadgeElement::makeImageLayoutElement(
|
MessageLayoutElement *FfzBadgeElement::makeImageLayoutElement(
|
||||||
const ImagePtr &image, const QSize &size)
|
const ImagePtr &image, const QSize &size)
|
||||||
{
|
{
|
||||||
auto element =
|
auto *element =
|
||||||
(new ImageWithBackgroundLayoutElement(*this, image, size, this->color))
|
(new ImageWithBackgroundLayoutElement(*this, image, size, this->color))
|
||||||
->setLink(this->getLink());
|
->setLink(this->getLink());
|
||||||
|
|
||||||
|
@ -513,7 +517,7 @@ TextElement::TextElement(const QString &text, MessageElementFlags flags,
|
||||||
void TextElement::addToContainer(MessageLayoutContainer &container,
|
void TextElement::addToContainer(MessageLayoutContainer &container,
|
||||||
MessageElementFlags flags)
|
MessageElementFlags flags)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
if (flags.hasAny(this->getFlags()))
|
if (flags.hasAny(this->getFlags()))
|
||||||
{
|
{
|
||||||
|
@ -527,7 +531,7 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
|
||||||
auto color = this->color_.getColor(*app->themes);
|
auto color = this->color_.getColor(*app->themes);
|
||||||
app->themes->normalizeColor(color);
|
app->themes->normalizeColor(color);
|
||||||
|
|
||||||
auto e = (new TextLayoutElement(
|
auto *e = (new TextLayoutElement(
|
||||||
*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());
|
||||||
|
@ -596,15 +600,19 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
|
||||||
width = charWidth;
|
width = charWidth;
|
||||||
|
|
||||||
if (isSurrogate)
|
if (isSurrogate)
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
width += charWidth;
|
width += charWidth;
|
||||||
|
|
||||||
if (isSurrogate)
|
if (isSurrogate)
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//add the final piece of wrapped text
|
//add the final piece of wrapped text
|
||||||
container.addElementNoLineBreak(getTextLayoutElement(
|
container.addElementNoLineBreak(getTextLayoutElement(
|
||||||
text.mid(wordStart), width, this->hasTrailingSpace()));
|
text.mid(wordStart), width, this->hasTrailingSpace()));
|
||||||
|
@ -629,7 +637,7 @@ SingleLineTextElement::SingleLineTextElement(const QString &text,
|
||||||
void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
||||||
MessageElementFlags flags)
|
MessageElementFlags flags)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
if (flags.hasAny(this->getFlags()))
|
if (flags.hasAny(this->getFlags()))
|
||||||
{
|
{
|
||||||
|
@ -641,7 +649,7 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
||||||
auto color = this->color_.getColor(*app->themes);
|
auto color = this->color_.getColor(*app->themes);
|
||||||
app->themes->normalizeColor(color);
|
app->themes->normalizeColor(color);
|
||||||
|
|
||||||
auto e = (new TextLayoutElement(
|
auto *e = (new TextLayoutElement(
|
||||||
*this, text, QSize(width, metrics.height()), color,
|
*this, text, QSize(width, metrics.height()), color,
|
||||||
this->style_, container.getScale()))
|
this->style_, container.getScale()))
|
||||||
->setLink(this->getLink());
|
->setLink(this->getLink());
|
||||||
|
@ -837,7 +845,9 @@ void ScalingImageElement::addToContainer(MessageLayoutContainer &container,
|
||||||
const auto &image =
|
const auto &image =
|
||||||
this->images_.getImageOrLoaded(container.getScale());
|
this->images_.getImageOrLoaded(container.getScale());
|
||||||
if (image->isEmpty())
|
if (image->isEmpty())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto size = QSize(image->width() * container.getScale(),
|
auto size = QSize(image->width() * container.getScale(),
|
||||||
image->height() * container.getScale());
|
image->height() * container.getScale());
|
||||||
|
|
|
@ -78,7 +78,7 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
|
||||||
{
|
{
|
||||||
// BenchmarkGuard benchmark("MessageLayout::layout()");
|
// BenchmarkGuard benchmark("MessageLayout::layout()");
|
||||||
|
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
bool layoutRequired = false;
|
bool layoutRequired = false;
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,7 @@ size_t TextLayoutElement::getSelectionIndexCount() const
|
||||||
void TextLayoutElement::paint(QPainter &painter,
|
void TextLayoutElement::paint(QPainter &painter,
|
||||||
const MessageColors & /*messageColors*/)
|
const MessageColors & /*messageColors*/)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
QString text = this->getText();
|
QString text = this->getText();
|
||||||
if (text.isRightToLeft() || this->reversedNeutral)
|
if (text.isRightToLeft() || this->reversedNeutral)
|
||||||
{
|
{
|
||||||
|
@ -461,7 +461,7 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
auto metrics = app->fonts->getFontMetrics(this->style_, this->scale_);
|
auto metrics = app->fonts->getFontMetrics(this->style_, this->scale_);
|
||||||
auto x = this->getRect().left();
|
auto x = this->getRect().left();
|
||||||
|
@ -495,7 +495,7 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||||
|
|
||||||
int TextLayoutElement::getXFromIndex(size_t index)
|
int TextLayoutElement::getXFromIndex(size_t index)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
QFontMetrics metrics =
|
QFontMetrics metrics =
|
||||||
app->fonts->getFontMetrics(this->style_, this->scale_);
|
app->fonts->getFontMetrics(this->style_, this->scale_);
|
||||||
|
|
|
@ -391,7 +391,7 @@ QString AbstractIrcServer::cleanChannelName(const QString &dirtyChannelName)
|
||||||
|
|
||||||
void AbstractIrcServer::addFakeMessage(const QString &data)
|
void AbstractIrcServer::addFakeMessage(const QString &data)
|
||||||
{
|
{
|
||||||
auto fakeMessage = Communi::IrcMessage::fromData(
|
auto *fakeMessage = Communi::IrcMessage::fromData(
|
||||||
data.toUtf8(), this->readConnection_.get());
|
data.toUtf8(), this->readConnection_.get());
|
||||||
|
|
||||||
if (fakeMessage->command() == "PRIVMSG")
|
if (fakeMessage->command() == "PRIVMSG")
|
||||||
|
|
|
@ -104,10 +104,16 @@ Irc::Irc()
|
||||||
|
|
||||||
// set server of abandoned channels
|
// set server of abandoned channels
|
||||||
for (auto weak : ab->second)
|
for (auto weak : ab->second)
|
||||||
|
{
|
||||||
if (auto shared = weak.lock())
|
if (auto shared = weak.lock())
|
||||||
if (auto ircChannel =
|
{
|
||||||
|
if (auto *ircChannel =
|
||||||
dynamic_cast<IrcChannel *>(shared.get()))
|
dynamic_cast<IrcChannel *>(shared.get()))
|
||||||
|
{
|
||||||
ircChannel->setServer(server.get());
|
ircChannel->setServer(server.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add new server with abandoned channels
|
// add new server with abandoned channels
|
||||||
this->servers_.emplace(args.item.id, std::move(server));
|
this->servers_.emplace(args.item.id, std::move(server));
|
||||||
|
@ -132,10 +138,16 @@ Irc::Irc()
|
||||||
|
|
||||||
// set server of abandoned servers to nullptr
|
// set server of abandoned servers to nullptr
|
||||||
for (auto weak : abandoned)
|
for (auto weak : abandoned)
|
||||||
|
{
|
||||||
if (auto shared = weak.lock())
|
if (auto shared = weak.lock())
|
||||||
if (auto ircChannel =
|
{
|
||||||
|
if (auto *ircChannel =
|
||||||
dynamic_cast<IrcChannel *>(shared.get()))
|
dynamic_cast<IrcChannel *>(shared.get()))
|
||||||
|
{
|
||||||
ircChannel->setServer(nullptr);
|
ircChannel->setServer(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->abandonedChannels_[args.item.id] = abandoned;
|
this->abandonedChannels_[args.item.id] = abandoned;
|
||||||
this->servers_.erase(server);
|
this->servers_.erase(server);
|
||||||
|
@ -156,7 +168,7 @@ Irc::Irc()
|
||||||
|
|
||||||
QAbstractTableModel *Irc::newConnectionModel(QObject *parent)
|
QAbstractTableModel *Irc::newConnectionModel(QObject *parent)
|
||||||
{
|
{
|
||||||
auto model = new Model(parent);
|
auto *model = new Model(parent);
|
||||||
model->initialize(&this->connections);
|
model->initialize(&this->connections);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +246,9 @@ void Irc::save()
|
||||||
void Irc::load()
|
void Irc::load()
|
||||||
{
|
{
|
||||||
if (this->loaded_)
|
if (this->loaded_)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
this->loaded_ = true;
|
this->loaded_ = true;
|
||||||
|
|
||||||
QString config = configPath();
|
QString config = configPath();
|
||||||
|
|
|
@ -100,7 +100,9 @@ bool IrcChannel::canReconnect() const
|
||||||
void IrcChannel::reconnect()
|
void IrcChannel::reconnect()
|
||||||
{
|
{
|
||||||
if (this->server())
|
if (this->server())
|
||||||
|
{
|
||||||
this->server()->connect();
|
this->server()->connect();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -261,7 +261,7 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
|
||||||
switch (message->type())
|
switch (message->type())
|
||||||
{
|
{
|
||||||
case Communi::IrcMessage::Join: {
|
case Communi::IrcMessage::Join: {
|
||||||
auto x = static_cast<Communi::IrcJoinMessage *>(message);
|
auto *x = static_cast<Communi::IrcJoinMessage *>(message);
|
||||||
|
|
||||||
if (auto it = this->channels.find(x->channel());
|
if (auto it = this->channels.find(x->channel());
|
||||||
it != this->channels.end())
|
it != this->channels.end())
|
||||||
|
@ -274,17 +274,19 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (auto c =
|
if (auto *c =
|
||||||
dynamic_cast<ChannelChatters *>(shared.get()))
|
dynamic_cast<ChannelChatters *>(shared.get()))
|
||||||
|
{
|
||||||
c->addJoinedUser(x->nick());
|
c->addJoinedUser(x->nick());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Communi::IrcMessage::Part: {
|
case Communi::IrcMessage::Part: {
|
||||||
auto x = static_cast<Communi::IrcPartMessage *>(message);
|
auto *x = static_cast<Communi::IrcPartMessage *>(message);
|
||||||
|
|
||||||
if (auto it = this->channels.find(x->channel());
|
if (auto it = this->channels.find(x->channel());
|
||||||
it != this->channels.end())
|
it != this->channels.end())
|
||||||
|
@ -297,12 +299,14 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (auto c =
|
if (auto *c =
|
||||||
dynamic_cast<ChannelChatters *>(shared.get()))
|
dynamic_cast<ChannelChatters *>(shared.get()))
|
||||||
|
{
|
||||||
c->addPartedUser(x->nick());
|
c->addPartedUser(x->nick());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,8 +331,10 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
|
||||||
for (auto &&weak : this->channels)
|
for (auto &&weak : this->channels)
|
||||||
{
|
{
|
||||||
if (auto shared = weak.lock())
|
if (auto shared = weak.lock())
|
||||||
|
{
|
||||||
shared->addMessage(msg);
|
shared->addMessage(msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,7 +442,9 @@ std::optional<ChannelPointReward> TwitchChannel::channelPointReward(
|
||||||
auto it = rewards->find(rewardId);
|
auto it = rewards->find(rewardId);
|
||||||
|
|
||||||
if (it == rewards->end())
|
if (it == rewards->end())
|
||||||
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
}
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,7 +574,7 @@ void TwitchChannel::roomIdChanged()
|
||||||
|
|
||||||
QString TwitchChannel::prepareMessage(const QString &message) const
|
QString TwitchChannel::prepareMessage(const QString &message) const
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
QString parsedMessage = app->emotes->emojis.replaceShortCodes(message);
|
QString parsedMessage = app->emotes->emojis.replaceShortCodes(message);
|
||||||
|
|
||||||
parsedMessage = parsedMessage.simplified();
|
parsedMessage = parsedMessage.simplified();
|
||||||
|
@ -618,7 +620,7 @@ QString TwitchChannel::prepareMessage(const QString &message) const
|
||||||
|
|
||||||
void TwitchChannel::sendMessage(const QString &message)
|
void TwitchChannel::sendMessage(const QString &message)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
if (!app->accounts->twitch.isLoggedIn())
|
if (!app->accounts->twitch.isLoggedIn())
|
||||||
{
|
{
|
||||||
if (!message.isEmpty())
|
if (!message.isEmpty())
|
||||||
|
@ -652,7 +654,7 @@ void TwitchChannel::sendMessage(const QString &message)
|
||||||
|
|
||||||
void TwitchChannel::sendReply(const QString &message, const QString &replyId)
|
void TwitchChannel::sendReply(const QString &message, const QString &replyId)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
if (!app->accounts->twitch.isLoggedIn())
|
if (!app->accounts->twitch.isLoggedIn())
|
||||||
{
|
{
|
||||||
if (!message.isEmpty())
|
if (!message.isEmpty())
|
||||||
|
@ -803,7 +805,9 @@ std::optional<EmotePtr> TwitchChannel::bttvEmote(const EmoteName &name) const
|
||||||
auto it = emotes->find(name);
|
auto it = emotes->find(name);
|
||||||
|
|
||||||
if (it == emotes->end())
|
if (it == emotes->end())
|
||||||
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
}
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,7 +817,9 @@ std::optional<EmotePtr> TwitchChannel::ffzEmote(const EmoteName &name) const
|
||||||
auto it = emotes->find(name);
|
auto it = emotes->find(name);
|
||||||
|
|
||||||
if (it == emotes->end())
|
if (it == emotes->end())
|
||||||
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
}
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1181,11 +1187,15 @@ void TwitchChannel::loadRecentMessages()
|
||||||
[weak](const auto &messages) {
|
[weak](const auto &messages) {
|
||||||
auto shared = weak.lock();
|
auto shared = weak.lock();
|
||||||
if (!shared)
|
if (!shared)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto tc = dynamic_cast<TwitchChannel *>(shared.get());
|
auto *tc = dynamic_cast<TwitchChannel *>(shared.get());
|
||||||
if (!tc)
|
if (!tc)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tc->addMessagesAtStart(messages);
|
tc->addMessagesAtStart(messages);
|
||||||
tc->loadingRecentMessages_.clear();
|
tc->loadingRecentMessages_.clear();
|
||||||
|
@ -1208,11 +1218,15 @@ void TwitchChannel::loadRecentMessages()
|
||||||
[weak]() {
|
[weak]() {
|
||||||
auto shared = weak.lock();
|
auto shared = weak.lock();
|
||||||
if (!shared)
|
if (!shared)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto tc = dynamic_cast<TwitchChannel *>(shared.get());
|
auto *tc = dynamic_cast<TwitchChannel *>(shared.get());
|
||||||
if (!tc)
|
if (!tc)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tc->loadingRecentMessages_.clear();
|
tc->loadingRecentMessages_.clear();
|
||||||
},
|
},
|
||||||
|
@ -1253,11 +1267,15 @@ void TwitchChannel::loadRecentMessagesReconnect()
|
||||||
[weak](const auto &messages) {
|
[weak](const auto &messages) {
|
||||||
auto shared = weak.lock();
|
auto shared = weak.lock();
|
||||||
if (!shared)
|
if (!shared)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto tc = dynamic_cast<TwitchChannel *>(shared.get());
|
auto *tc = dynamic_cast<TwitchChannel *>(shared.get());
|
||||||
if (!tc)
|
if (!tc)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tc->fillInMissingMessages(messages);
|
tc->fillInMissingMessages(messages);
|
||||||
tc->loadingRecentMessages_.clear();
|
tc->loadingRecentMessages_.clear();
|
||||||
|
@ -1265,11 +1283,15 @@ void TwitchChannel::loadRecentMessagesReconnect()
|
||||||
[weak]() {
|
[weak]() {
|
||||||
auto shared = weak.lock();
|
auto shared = weak.lock();
|
||||||
if (!shared)
|
if (!shared)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto tc = dynamic_cast<TwitchChannel *>(shared.get());
|
auto *tc = dynamic_cast<TwitchChannel *>(shared.get());
|
||||||
if (!tc)
|
if (!tc)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tc->loadingRecentMessages_.clear();
|
tc->loadingRecentMessages_.clear();
|
||||||
},
|
},
|
||||||
|
|
|
@ -395,11 +395,15 @@ std::shared_ptr<Channel> TwitchIrcServer::getChannelOrEmptyByID(
|
||||||
{
|
{
|
||||||
auto channel = weakChannel.lock();
|
auto channel = weakChannel.lock();
|
||||||
if (!channel)
|
if (!channel)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto twitchChannel = std::dynamic_pointer_cast<TwitchChannel>(channel);
|
auto twitchChannel = std::dynamic_pointer_cast<TwitchChannel>(channel);
|
||||||
if (!twitchChannel)
|
if (!twitchChannel)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (twitchChannel->roomId() == channelId &&
|
if (twitchChannel->roomId() == channelId &&
|
||||||
twitchChannel->getName().count(':') < 2)
|
twitchChannel->getName().count(':') < 2)
|
||||||
|
@ -414,10 +418,14 @@ std::shared_ptr<Channel> TwitchIrcServer::getChannelOrEmptyByID(
|
||||||
QString TwitchIrcServer::cleanChannelName(const QString &dirtyChannelName)
|
QString TwitchIrcServer::cleanChannelName(const QString &dirtyChannelName)
|
||||||
{
|
{
|
||||||
if (dirtyChannelName.startsWith('#'))
|
if (dirtyChannelName.startsWith('#'))
|
||||||
|
{
|
||||||
return dirtyChannelName.mid(1).toLower();
|
return dirtyChannelName.mid(1).toLower();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return dirtyChannelName.toLower();
|
return dirtyChannelName.toLower();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool TwitchIrcServer::hasSeparateWriteConnection() const
|
bool TwitchIrcServer::hasSeparateWriteConnection() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -1233,7 +1233,9 @@ std::unordered_map<QString, QString> TwitchMessageBuilder::parseBadgeInfoTag(
|
||||||
|
|
||||||
auto infoIt = tags.constFind("badge-info");
|
auto infoIt = tags.constFind("badge-info");
|
||||||
if (infoIt == tags.end())
|
if (infoIt == tags.end())
|
||||||
|
{
|
||||||
return infoMap;
|
return infoMap;
|
||||||
|
}
|
||||||
|
|
||||||
auto info = infoIt.value().toString().split(',', Qt::SkipEmptyParts);
|
auto info = infoIt.value().toString().split(',', Qt::SkipEmptyParts);
|
||||||
|
|
||||||
|
@ -1651,7 +1653,7 @@ void TwitchMessageBuilder::listOfUsersSystemMessage(QString prefix,
|
||||||
builder->emplace<TextElement>(prefix, MessageElementFlag::Text,
|
builder->emplace<TextElement>(prefix, MessageElementFlag::Text,
|
||||||
MessageColor::System);
|
MessageColor::System);
|
||||||
bool isFirst = true;
|
bool isFirst = true;
|
||||||
auto tc = dynamic_cast<TwitchChannel *>(channel);
|
auto *tc = dynamic_cast<TwitchChannel *>(channel);
|
||||||
for (const QString &username : users)
|
for (const QString &username : users)
|
||||||
{
|
{
|
||||||
if (!isFirst)
|
if (!isFirst)
|
||||||
|
|
|
@ -52,7 +52,7 @@ void Logging::addMessage(const QString &channelName, MessagePtr message,
|
||||||
auto platIt = this->loggingChannels_.find(platformName);
|
auto platIt = this->loggingChannels_.find(platformName);
|
||||||
if (platIt == this->loggingChannels_.end())
|
if (platIt == this->loggingChannels_.end())
|
||||||
{
|
{
|
||||||
auto channel = new LoggingChannel(channelName, platformName);
|
auto *channel = new LoggingChannel(channelName, platformName);
|
||||||
channel->addMessage(message);
|
channel->addMessage(message);
|
||||||
auto map = std::map<QString, std::unique_ptr<LoggingChannel>>();
|
auto map = std::map<QString, std::unique_ptr<LoggingChannel>>();
|
||||||
this->loggingChannels_[platformName] = std::move(map);
|
this->loggingChannels_[platformName] = std::move(map);
|
||||||
|
@ -63,7 +63,7 @@ void Logging::addMessage(const QString &channelName, MessagePtr message,
|
||||||
auto chanIt = platIt->second.find(channelName);
|
auto chanIt = platIt->second.find(channelName);
|
||||||
if (chanIt == platIt->second.end())
|
if (chanIt == platIt->second.end())
|
||||||
{
|
{
|
||||||
auto channel = new LoggingChannel(channelName, platformName);
|
auto *channel = new LoggingChannel(channelName, platformName);
|
||||||
channel->addMessage(message);
|
channel->addMessage(message);
|
||||||
platIt->second.emplace(channelName, std::move(channel));
|
platIt->second.emplace(channelName, std::move(channel));
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,10 @@ bool Settings::isHighlightedUser(const QString &username)
|
||||||
for (const auto &highlightedUser : *items)
|
for (const auto &highlightedUser : *items)
|
||||||
{
|
{
|
||||||
if (highlightedUser.isMatch(username))
|
if (highlightedUser.isMatch(username))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -67,8 +69,10 @@ bool Settings::isBlacklistedUser(const QString &username)
|
||||||
for (const auto &blacklistedUser : *items)
|
for (const auto &blacklistedUser : *items)
|
||||||
{
|
{
|
||||||
if (blacklistedUser.isMatch(username))
|
if (blacklistedUser.isMatch(username))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +212,7 @@ void Settings::saveSnapshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
rapidjson::Value key(setting->getPath().c_str(), a);
|
rapidjson::Value key(setting->getPath().c_str(), a);
|
||||||
auto curVal = setting->unmarshalJSON();
|
auto *curVal = setting->unmarshalJSON();
|
||||||
if (curVal == nullptr)
|
if (curVal == nullptr)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -97,7 +97,7 @@ WindowManager::WindowManager()
|
||||||
{
|
{
|
||||||
qCDebug(chatterinoWindowmanager) << "init WindowManager";
|
qCDebug(chatterinoWindowmanager) << "init WindowManager";
|
||||||
|
|
||||||
auto settings = getSettings();
|
auto *settings = getSettings();
|
||||||
|
|
||||||
this->wordFlagsListener_.addSetting(settings->showTimestamps);
|
this->wordFlagsListener_.addSetting(settings->showTimestamps);
|
||||||
this->wordFlagsListener_.addSetting(settings->showBadgesGlobalAuthority);
|
this->wordFlagsListener_.addSetting(settings->showBadgesGlobalAuthority);
|
||||||
|
@ -135,7 +135,7 @@ MessageElementFlags WindowManager::getWordFlags()
|
||||||
void WindowManager::updateWordTypeMask()
|
void WindowManager::updateWordTypeMask()
|
||||||
{
|
{
|
||||||
using MEF = MessageElementFlag;
|
using MEF = MessageElementFlag;
|
||||||
auto settings = getSettings();
|
auto *settings = getSettings();
|
||||||
|
|
||||||
// text
|
// text
|
||||||
auto flags = MessageElementFlags(MEF::Text);
|
auto flags = MessageElementFlags(MEF::Text);
|
||||||
|
@ -630,7 +630,7 @@ void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Channel::Type::Irc: {
|
case Channel::Type::Irc: {
|
||||||
if (auto ircChannel =
|
if (auto *ircChannel =
|
||||||
dynamic_cast<IrcChannel *>(channel.get().get()))
|
dynamic_cast<IrcChannel *>(channel.get().get()))
|
||||||
{
|
{
|
||||||
obj.insert("type", "irc");
|
obj.insert("type", "irc");
|
||||||
|
@ -664,7 +664,7 @@ IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor)
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
if (descriptor.type_ == "twitch")
|
if (descriptor.type_ == "twitch")
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,15 +13,21 @@ void GIFTimer::initialize()
|
||||||
|
|
||||||
getSettings()->animateEmotes.connect([this](bool enabled, auto) {
|
getSettings()->animateEmotes.connect([this](bool enabled, auto) {
|
||||||
if (enabled)
|
if (enabled)
|
||||||
|
{
|
||||||
this->timer.start();
|
this->timer.start();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
this->timer.stop();
|
this->timer.stop();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(&this->timer, &QTimer::timeout, [this] {
|
QObject::connect(&this->timer, &QTimer::timeout, [this] {
|
||||||
if (getSettings()->animationsWhenFocused &&
|
if (getSettings()->animationsWhenFocused &&
|
||||||
qApp->activeWindow() == nullptr)
|
qApp->activeWindow() == nullptr)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this->position_ += GIF_FRAME_LENGTH;
|
this->position_ += GIF_FRAME_LENGTH;
|
||||||
this->signal.invoke();
|
this->signal.invoke();
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace chatterino {
|
||||||
|
|
||||||
void crossPlatformCopy(const QString &text)
|
void crossPlatformCopy(const QString &text)
|
||||||
{
|
{
|
||||||
auto clipboard = QApplication::clipboard();
|
auto *clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
clipboard->setText(text);
|
clipboard->setText(text);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ void initUpdateButton(Button &button,
|
||||||
|
|
||||||
// show update prompt when clicking the button
|
// show update prompt when clicking the button
|
||||||
QObject::connect(&button, &Button::leftClicked, [&button] {
|
QObject::connect(&button, &Button::leftClicked, [&button] {
|
||||||
auto dialog = new UpdateDialog();
|
auto *dialog = new UpdateDialog();
|
||||||
dialog->setActionOnFocusLoss(BaseWindow::Delete);
|
dialog->setActionOnFocusLoss(BaseWindow::Delete);
|
||||||
|
|
||||||
auto globalPoint = button.mapToGlobal(
|
auto globalPoint = button.mapToGlobal(
|
||||||
|
@ -54,7 +54,7 @@ void initUpdateButton(Button &button,
|
||||||
auto updateChange = [&button](auto) {
|
auto updateChange = [&button](auto) {
|
||||||
button.setVisible(Updates::instance().shouldShowUpdateButton());
|
button.setVisible(Updates::instance().shouldShowUpdateButton());
|
||||||
|
|
||||||
auto imageUrl = Updates::instance().isError()
|
const auto *imageUrl = Updates::instance().isError()
|
||||||
? ":/buttons/updateError.png"
|
? ":/buttons/updateError.png"
|
||||||
: ":/buttons/update.png";
|
: ":/buttons/update.png";
|
||||||
button.setPixmap(QPixmap(imageUrl));
|
button.setPixmap(QPixmap(imageUrl));
|
||||||
|
|
|
@ -7,14 +7,14 @@ namespace chatterino {
|
||||||
|
|
||||||
QWidget *wrapLayout(QLayout *layout)
|
QWidget *wrapLayout(QLayout *layout)
|
||||||
{
|
{
|
||||||
auto widget = new QWidget;
|
auto *widget = new QWidget;
|
||||||
widget->setLayout(layout);
|
widget->setLayout(layout);
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScrollArea *makeScrollArea(WidgetOrLayout item)
|
QScrollArea *makeScrollArea(WidgetOrLayout item)
|
||||||
{
|
{
|
||||||
auto area = new QScrollArea();
|
auto *area = new QScrollArea();
|
||||||
|
|
||||||
switch (item.which())
|
switch (item.which())
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@ T *makeLayout(std::initializer_list<LayoutItem> items)
|
||||||
{
|
{
|
||||||
auto t = new T;
|
auto t = new T;
|
||||||
|
|
||||||
for (auto &item : items)
|
for (const auto &item : items)
|
||||||
{
|
{
|
||||||
switch (item.which())
|
switch (item.which())
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,9 @@ inline void persist(SignalVector<T> &vec, const std::string &name)
|
||||||
auto setting = std::make_unique<ChatterinoSetting<std::vector<T>>>(name);
|
auto setting = std::make_unique<ChatterinoSetting<std::vector<T>>>(name);
|
||||||
|
|
||||||
for (auto &&item : setting->getValue())
|
for (auto &&item : setting->getValue())
|
||||||
|
{
|
||||||
vec.append(item);
|
vec.append(item);
|
||||||
|
}
|
||||||
|
|
||||||
vec.delayedItemsChanged.connect([setting = setting.get(), vec = &vec] {
|
vec.delayedItemsChanged.connect([setting = setting.get(), vec = &vec] {
|
||||||
setting->setValue(vec->raw());
|
setting->setValue(vec->raw());
|
||||||
|
|
|
@ -70,7 +70,9 @@ QStringList chatterino::splitCommand(QStringView command)
|
||||||
if (quoteCount)
|
if (quoteCount)
|
||||||
{
|
{
|
||||||
if (quoteCount == 1)
|
if (quoteCount == 1)
|
||||||
|
{
|
||||||
inQuote = !inQuote;
|
inQuote = !inQuote;
|
||||||
|
}
|
||||||
quoteCount = 0;
|
quoteCount = 0;
|
||||||
}
|
}
|
||||||
if (!inQuote && command.at(i).isSpace())
|
if (!inQuote && command.at(i).isSpace())
|
||||||
|
@ -87,7 +89,9 @@ QStringList chatterino::splitCommand(QStringView command)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!tmp.isEmpty())
|
if (!tmp.isEmpty())
|
||||||
|
{
|
||||||
args += tmp;
|
args += tmp;
|
||||||
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ AccountSwitchPopup::AccountSwitchPopup(QWidget *parent)
|
||||||
this->ui_.accountSwitchWidget->setFocusPolicy(Qt::NoFocus);
|
this->ui_.accountSwitchWidget->setFocusPolicy(Qt::NoFocus);
|
||||||
vbox->addWidget(this->ui_.accountSwitchWidget);
|
vbox->addWidget(this->ui_.accountSwitchWidget);
|
||||||
|
|
||||||
auto hbox = new QHBoxLayout();
|
auto *hbox = new QHBoxLayout();
|
||||||
auto manageAccountsButton = new QPushButton(this);
|
auto *manageAccountsButton = new QPushButton(this);
|
||||||
manageAccountsButton->setText("Manage Accounts");
|
manageAccountsButton->setText("Manage Accounts");
|
||||||
manageAccountsButton->setFocusPolicy(Qt::NoFocus);
|
manageAccountsButton->setFocusPolicy(Qt::NoFocus);
|
||||||
hbox->addWidget(manageAccountsButton);
|
hbox->addWidget(manageAccountsButton);
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace chatterino {
|
||||||
AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||||
: QListWidget(parent)
|
: QListWidget(parent)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ void AccountSwitchWidget::refreshSelection()
|
||||||
// Select the currently logged in user
|
// Select the currently logged in user
|
||||||
if (this->count() > 0)
|
if (this->count() > 0)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
auto currentUser = app->accounts->twitch.getCurrent();
|
auto currentUser = app->accounts->twitch.getCurrent();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ BaseWidget::BaseWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
}
|
}
|
||||||
void BaseWidget::clearShortcuts()
|
void BaseWidget::clearShortcuts()
|
||||||
{
|
{
|
||||||
for (auto shortcut : this->shortcuts_)
|
for (auto *shortcut : this->shortcuts_)
|
||||||
{
|
{
|
||||||
shortcut->setKey(QKeySequence());
|
shortcut->setKey(QKeySequence());
|
||||||
shortcut->removeEventFilter(this);
|
shortcut->removeEventFilter(this);
|
||||||
|
@ -122,7 +122,7 @@ void BaseWidget::setScaleIndependantHeight(int value)
|
||||||
|
|
||||||
float BaseWidget::qtFontScale() const
|
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
|
// ensure no div by 0
|
||||||
return this->scale() / std::max<float>(0.01f, window->nativeScale_);
|
return this->scale() / std::max<float>(0.01f, window->nativeScale_);
|
||||||
|
@ -138,7 +138,7 @@ void BaseWidget::childEvent(QChildEvent *event)
|
||||||
if (event->added())
|
if (event->added())
|
||||||
{
|
{
|
||||||
// add element if it's a basewidget
|
// 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);
|
this->widgets_.push_back(widget);
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,7 +373,7 @@ void BaseWindow::mousePressEvent(QMouseEvent *event)
|
||||||
if (this->flags_.has(FramelessDraggable))
|
if (this->flags_.has(FramelessDraggable))
|
||||||
{
|
{
|
||||||
this->movingRelativePos = event->localPos();
|
this->movingRelativePos = event->localPos();
|
||||||
if (auto widget =
|
if (auto *widget =
|
||||||
this->childAt(event->localPos().x(), event->localPos().y()))
|
this->childAt(event->localPos().x(), event->localPos().y()))
|
||||||
{
|
{
|
||||||
std::function<bool(QWidget *)> recursiveCheckMouseTracking;
|
std::function<bool(QWidget *)> recursiveCheckMouseTracking;
|
||||||
|
@ -735,7 +735,7 @@ void BaseWindow::updateScale()
|
||||||
|
|
||||||
this->setScale(scale);
|
this->setScale(scale);
|
||||||
|
|
||||||
for (auto child : this->findChildren<BaseWidget *>())
|
for (auto *child : this->findChildren<BaseWidget *>())
|
||||||
{
|
{
|
||||||
child->setScale(scale);
|
child->setScale(scale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ FramelessEmbedWindow::FramelessEmbedWindow()
|
||||||
: BaseWindow({BaseWindow::Frameless, BaseWindow::DisableLayoutSave})
|
: BaseWindow({BaseWindow::Frameless, BaseWindow::DisableLayoutSave})
|
||||||
{
|
{
|
||||||
this->split_ = new Split((QWidget *)nullptr);
|
this->split_ = new Split((QWidget *)nullptr);
|
||||||
auto layout = new QHBoxLayout;
|
auto *layout = new QHBoxLayout;
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->addWidget(this->split_);
|
layout->addWidget(this->split_);
|
||||||
|
|
||||||
|
|
|
@ -785,7 +785,9 @@ void Notebook::performLayout(bool animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->visibleButtonCount() > 0)
|
if (this->visibleButtonCount() > 0)
|
||||||
|
{
|
||||||
y = tabHeight + lineThickness; // account for divider line
|
y = tabHeight + lineThickness; // account for divider line
|
||||||
|
}
|
||||||
|
|
||||||
int totalButtonWidths = x;
|
int totalButtonWidths = x;
|
||||||
const int top = y + tabSpacer; // add margin
|
const int top = y + tabSpacer; // add margin
|
||||||
|
@ -829,7 +831,9 @@ void Notebook::performLayout(bool animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLastColumn && largestWidth + x < totalButtonWidths)
|
if (isLastColumn && largestWidth + x < totalButtonWidths)
|
||||||
|
{
|
||||||
largestWidth = totalButtonWidths - x;
|
largestWidth = totalButtonWidths - x;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = tabStart; i < tabEnd; i++)
|
for (int i = tabStart; i < tabEnd; i++)
|
||||||
{
|
{
|
||||||
|
@ -877,7 +881,7 @@ void Notebook::performLayout(bool animated)
|
||||||
for (auto btnIt = this->customButtons_.rbegin();
|
for (auto btnIt = this->customButtons_.rbegin();
|
||||||
btnIt != this->customButtons_.rend(); ++btnIt)
|
btnIt != this->customButtons_.rend(); ++btnIt)
|
||||||
{
|
{
|
||||||
auto btn = *btnIt;
|
auto *btn = *btnIt;
|
||||||
if (!btn->isVisible())
|
if (!btn->isVisible())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -889,7 +893,9 @@ void Notebook::performLayout(bool animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->visibleButtonCount() > 0)
|
if (this->visibleButtonCount() > 0)
|
||||||
|
{
|
||||||
y = tabHeight + lineThickness; // account for divider line
|
y = tabHeight + lineThickness; // account for divider line
|
||||||
|
}
|
||||||
|
|
||||||
int consumedButtonWidths = right - x;
|
int consumedButtonWidths = right - x;
|
||||||
const int top = y + tabSpacer; // add margin
|
const int top = y + tabSpacer; // add margin
|
||||||
|
@ -936,7 +942,9 @@ void Notebook::performLayout(bool animated)
|
||||||
|
|
||||||
if (isLastColumn &&
|
if (isLastColumn &&
|
||||||
largestWidth + distanceFromRight < consumedButtonWidths)
|
largestWidth + distanceFromRight < consumedButtonWidths)
|
||||||
|
{
|
||||||
largestWidth = consumedButtonWidths - distanceFromRight;
|
largestWidth = consumedButtonWidths - distanceFromRight;
|
||||||
|
}
|
||||||
|
|
||||||
x -= largestWidth + lineThickness;
|
x -= largestWidth + lineThickness;
|
||||||
|
|
||||||
|
@ -1288,7 +1296,7 @@ SplitNotebook::SplitNotebook(Window *parent)
|
||||||
getApp()->windows->selectSplit, [this](Split *split) {
|
getApp()->windows->selectSplit, [this](Split *split) {
|
||||||
for (auto &&item : this->items())
|
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();
|
auto &&splits = sc->getSplits();
|
||||||
if (std::find(splits.begin(), splits.end(), split) !=
|
if (std::find(splits.begin(), splits.end(), split) !=
|
||||||
|
@ -1312,7 +1320,7 @@ SplitNotebook::SplitNotebook(Window *parent)
|
||||||
[this](const MessagePtr &message) {
|
[this](const MessagePtr &message) {
|
||||||
for (auto &&item : this->items())
|
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())
|
for (auto *split : sc->getSplits())
|
||||||
{
|
{
|
||||||
|
@ -1352,7 +1360,7 @@ void SplitNotebook::showEvent(QShowEvent * /*event*/)
|
||||||
void SplitNotebook::addCustomButtons()
|
void SplitNotebook::addCustomButtons()
|
||||||
{
|
{
|
||||||
// settings
|
// settings
|
||||||
auto settingsBtn = this->addCustomButton();
|
auto *settingsBtn = this->addCustomButton();
|
||||||
|
|
||||||
// This is to ensure you can't lock yourself out of the settings
|
// This is to ensure you can't lock yourself out of the settings
|
||||||
if (getApp()->getArgs().safeMode)
|
if (getApp()->getArgs().safeMode)
|
||||||
|
@ -1378,7 +1386,7 @@ void SplitNotebook::addCustomButtons()
|
||||||
});
|
});
|
||||||
|
|
||||||
// account
|
// account
|
||||||
auto userBtn = this->addCustomButton();
|
auto *userBtn = this->addCustomButton();
|
||||||
userBtn->setVisible(!getSettings()->hideUserButton.getValue());
|
userBtn->setVisible(!getSettings()->hideUserButton.getValue());
|
||||||
getSettings()->hideUserButton.connect(
|
getSettings()->hideUserButton.connect(
|
||||||
[userBtn](bool hide, auto) {
|
[userBtn](bool hide, auto) {
|
||||||
|
@ -1393,7 +1401,7 @@ void SplitNotebook::addCustomButtons()
|
||||||
});
|
});
|
||||||
|
|
||||||
// updates
|
// updates
|
||||||
auto updateBtn = this->addCustomButton();
|
auto *updateBtn = this->addCustomButton();
|
||||||
|
|
||||||
initUpdateButton(*updateBtn, this->signalHolder_);
|
initUpdateButton(*updateBtn, this->signalHolder_);
|
||||||
|
|
||||||
|
@ -1439,8 +1447,8 @@ void SplitNotebook::themeChangedEvent()
|
||||||
|
|
||||||
SplitContainer *SplitNotebook::addPage(bool select)
|
SplitContainer *SplitNotebook::addPage(bool select)
|
||||||
{
|
{
|
||||||
auto container = new SplitContainer(this);
|
auto *container = new SplitContainer(this);
|
||||||
auto tab = Notebook::addPage(container, QString(), select);
|
auto *tab = Notebook::addPage(container, QString(), select);
|
||||||
container->setTab(tab);
|
container->setTab(tab);
|
||||||
tab->setParent(this);
|
tab->setParent(this);
|
||||||
return container;
|
return container;
|
||||||
|
|
|
@ -119,9 +119,9 @@ void TooltipWidget::set(const std::vector<TooltipEntry> &entries,
|
||||||
|
|
||||||
for (int i = 0; i < entries.size(); ++i)
|
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->setImage(entry.image);
|
||||||
entryWidget->setText(entry.text);
|
entryWidget->setText(entry.text);
|
||||||
entryWidget->setImageScale(entry.customWidth, entry.customHeight);
|
entryWidget->setImageScale(entry.customWidth, entry.customHeight);
|
||||||
|
@ -306,7 +306,7 @@ void TooltipWidget::setWordWrap(bool wrap)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this->visibleEntries_; ++i)
|
for (int i = 0; i < this->visibleEntries_; ++i)
|
||||||
{
|
{
|
||||||
auto entry = this->entryAt(i);
|
auto *entry = this->entryAt(i);
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
entry->setWordWrap(wrap);
|
entry->setWordWrap(wrap);
|
||||||
|
|
|
@ -136,7 +136,7 @@ void Window::closeEvent(QCloseEvent *)
|
||||||
{
|
{
|
||||||
if (this->type_ == WindowType::Main)
|
if (this->type_ == WindowType::Main)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
app->windows->save();
|
app->windows->save();
|
||||||
app->windows->closeAll();
|
app->windows->closeAll();
|
||||||
}
|
}
|
||||||
|
@ -171,9 +171,13 @@ void Window::addLayout()
|
||||||
void Window::addCustomTitlebarButtons()
|
void Window::addCustomTitlebarButtons()
|
||||||
{
|
{
|
||||||
if (!this->hasCustomWindowFrame())
|
if (!this->hasCustomWindowFrame())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (this->type_ != WindowType::Main)
|
if (this->type_ != WindowType::Main)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
this->addTitleBarButton(TitleBarButtonStyle::Settings, [this] {
|
this->addTitleBarButton(TitleBarButtonStyle::Settings, [this] {
|
||||||
|
@ -181,7 +185,7 @@ void Window::addCustomTitlebarButtons()
|
||||||
});
|
});
|
||||||
|
|
||||||
// updates
|
// updates
|
||||||
auto update = this->addTitleBarButton(TitleBarButtonStyle::None, [] {});
|
auto *update = this->addTitleBarButton(TitleBarButtonStyle::None, [] {});
|
||||||
|
|
||||||
initUpdateButton(*update, this->signalHolder_);
|
initUpdateButton(*update, this->signalHolder_);
|
||||||
|
|
||||||
|
@ -384,10 +388,10 @@ void Window::addShortcuts()
|
||||||
}
|
}
|
||||||
if (arguments.at(0) == "split")
|
if (arguments.at(0) == "split")
|
||||||
{
|
{
|
||||||
if (auto page = dynamic_cast<SplitContainer *>(
|
if (auto *page = dynamic_cast<SplitContainer *>(
|
||||||
this->notebook_->getSelectedPage()))
|
this->notebook_->getSelectedPage()))
|
||||||
{
|
{
|
||||||
if (auto split = page->getSelectedSplit())
|
if (auto *split = page->getSelectedSplit())
|
||||||
{
|
{
|
||||||
split->popup();
|
split->popup();
|
||||||
}
|
}
|
||||||
|
@ -395,7 +399,7 @@ void Window::addShortcuts()
|
||||||
}
|
}
|
||||||
else if (arguments.at(0) == "window")
|
else if (arguments.at(0) == "window")
|
||||||
{
|
{
|
||||||
if (auto page = dynamic_cast<SplitContainer *>(
|
if (auto *page = dynamic_cast<SplitContainer *>(
|
||||||
this->notebook_->getSelectedPage()))
|
this->notebook_->getSelectedPage()))
|
||||||
{
|
{
|
||||||
page->popup();
|
page->popup();
|
||||||
|
|
|
@ -14,8 +14,8 @@ BadgePickerDialog::BadgePickerDialog(QList<DisplayBadge> badges,
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
this->dropdown_ = new QComboBox;
|
this->dropdown_ = new QComboBox;
|
||||||
auto vbox = new QVBoxLayout(this);
|
auto *vbox = new QVBoxLayout(this);
|
||||||
auto buttonBox =
|
auto *buttonBox =
|
||||||
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
vbox->addWidget(this->dropdown_);
|
vbox->addWidget(this->dropdown_);
|
||||||
|
@ -61,7 +61,9 @@ BadgePickerDialog::BadgePickerDialog(QList<DisplayBadge> badges,
|
||||||
badges,
|
badges,
|
||||||
[&dropdown = this->dropdown_](QString identifier, const QIconPtr icon) {
|
[&dropdown = this->dropdown_](QString identifier, const QIconPtr icon) {
|
||||||
if (!dropdown)
|
if (!dropdown)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int index = dropdown->findData(identifier);
|
int index = dropdown->findData(identifier);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
|
|
|
@ -21,16 +21,16 @@ namespace {
|
||||||
ChannelFilterEditorDialog::ChannelFilterEditorDialog(QWidget *parent)
|
ChannelFilterEditorDialog::ChannelFilterEditorDialog(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
auto vbox = new QVBoxLayout(this);
|
auto *vbox = new QVBoxLayout(this);
|
||||||
auto filterVbox = new QVBoxLayout;
|
auto *filterVbox = new QVBoxLayout;
|
||||||
auto buttonBox = new QHBoxLayout;
|
auto *buttonBox = new QHBoxLayout;
|
||||||
auto okButton = new QPushButton("Ok");
|
auto *okButton = new QPushButton("Ok");
|
||||||
auto cancelButton = new QPushButton("Cancel");
|
auto *cancelButton = new QPushButton("Cancel");
|
||||||
|
|
||||||
okButton->setDefault(true);
|
okButton->setDefault(true);
|
||||||
cancelButton->setDefault(false);
|
cancelButton->setDefault(false);
|
||||||
|
|
||||||
auto helpLabel =
|
auto *helpLabel =
|
||||||
new QLabel(QString("<a href='%1'><span "
|
new QLabel(QString("<a href='%1'><span "
|
||||||
"style='color:#99f'>variable help</span></a>")
|
"style='color:#99f'>variable help</span></a>")
|
||||||
.arg("https://wiki.chatterino.com/Filters/#variables"));
|
.arg("https://wiki.chatterino.com/Filters/#variables"));
|
||||||
|
@ -55,16 +55,16 @@ ChannelFilterEditorDialog::ChannelFilterEditorDialog(QWidget *parent)
|
||||||
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
|
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
|
||||||
this->setWindowTitle("Channel Filter Creator");
|
this->setWindowTitle("Channel Filter Creator");
|
||||||
|
|
||||||
auto titleInput = new QLineEdit;
|
auto *titleInput = new QLineEdit;
|
||||||
titleInput->setPlaceholderText("Filter name");
|
titleInput->setPlaceholderText("Filter name");
|
||||||
titleInput->setText("My filter");
|
titleInput->setText("My filter");
|
||||||
|
|
||||||
this->titleInput_ = titleInput;
|
this->titleInput_ = titleInput;
|
||||||
filterVbox->addWidget(titleInput);
|
filterVbox->addWidget(titleInput);
|
||||||
|
|
||||||
auto left = new ChannelFilterEditorDialog::ValueSpecifier;
|
auto *left = new ChannelFilterEditorDialog::ValueSpecifier;
|
||||||
auto right = new ChannelFilterEditorDialog::ValueSpecifier;
|
auto *right = new ChannelFilterEditorDialog::ValueSpecifier;
|
||||||
auto exp =
|
auto *exp =
|
||||||
new ChannelFilterEditorDialog::BinaryOperationSpecifier(left, right);
|
new ChannelFilterEditorDialog::BinaryOperationSpecifier(left, right);
|
||||||
|
|
||||||
this->expressionSpecifier_ = exp;
|
this->expressionSpecifier_ = exp;
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
class IrcConnectionEditor;
|
class IrcConnectionEditor;
|
||||||
}
|
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ class IrcConnectionEditor : public QDialog
|
||||||
public:
|
public:
|
||||||
explicit IrcConnectionEditor(const IrcServerData &data, bool isAdd = false,
|
explicit IrcConnectionEditor(const IrcServerData &data, bool isAdd = false,
|
||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
|
IrcConnectionEditor(const IrcConnectionEditor &) = delete;
|
||||||
|
IrcConnectionEditor(IrcConnectionEditor &&) = delete;
|
||||||
|
IrcConnectionEditor &operator=(const IrcConnectionEditor &) = delete;
|
||||||
|
IrcConnectionEditor &operator=(IrcConnectionEditor &&) = delete;
|
||||||
~IrcConnectionEditor() override;
|
~IrcConnectionEditor() override;
|
||||||
|
|
||||||
IrcServerData data();
|
IrcServerData data();
|
||||||
|
|
|
@ -171,7 +171,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||||
QWidget::setTabOrder(live_btn.getElement(), automod_btn.getElement());
|
QWidget::setTabOrder(live_btn.getElement(), automod_btn.getElement());
|
||||||
|
|
||||||
// tab
|
// tab
|
||||||
auto tab = notebook->addPage(obj.getElement());
|
auto *tab = notebook->addPage(obj.getElement());
|
||||||
tab->setCustomTitle("Twitch");
|
tab->setCustomTitle("Twitch");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||||
auto outerBox = obj.setLayoutType<QFormLayout>();
|
auto outerBox = obj.setLayoutType<QFormLayout>();
|
||||||
|
|
||||||
{
|
{
|
||||||
auto view = this->ui_.irc.servers =
|
auto *view = this->ui_.irc.servers =
|
||||||
new EditableModelView(Irc::instance().newConnectionModel(this));
|
new EditableModelView(Irc::instance().newConnectionModel(this));
|
||||||
|
|
||||||
view->setTitles({"host", "port", "ssl", "user", "nick", "real",
|
view->setTitles({"host", "port", "ssl", "user", "nick", "real",
|
||||||
|
@ -199,7 +199,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||||
auto unique = IrcServerData{};
|
auto unique = IrcServerData{};
|
||||||
unique.id = Irc::instance().uniqueId();
|
unique.id = Irc::instance().uniqueId();
|
||||||
|
|
||||||
auto editor = new IrcConnectionEditor(unique);
|
auto *editor = new IrcConnectionEditor(unique);
|
||||||
if (editor->exec() == QDialog::Accepted)
|
if (editor->exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
Irc::instance().connections.append(editor->data());
|
Irc::instance().connections.append(editor->data());
|
||||||
|
@ -209,7 +209,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
view->getTableView(), &QTableView::doubleClicked,
|
view->getTableView(), &QTableView::doubleClicked,
|
||||||
[](const QModelIndex &index) {
|
[](const QModelIndex &index) {
|
||||||
auto editor = new IrcConnectionEditor(
|
auto *editor = new IrcConnectionEditor(
|
||||||
Irc::instance().connections.raw()[size_t(index.row())]);
|
Irc::instance().connections.raw()[size_t(index.row())]);
|
||||||
|
|
||||||
if (editor->exec() == QDialog::Accepted)
|
if (editor->exec() == QDialog::Accepted)
|
||||||
|
@ -235,7 +235,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||||
|
|
||||||
outerBox->addRow("Channel: #", this->ui_.irc.channel = new QLineEdit);
|
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)");
|
tab->setCustomTitle("Irc (Beta)");
|
||||||
|
|
||||||
if (!getSettings()->enableExperimentalIrc)
|
if (!getSettings()->enableExperimentalIrc)
|
||||||
|
@ -338,10 +338,10 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
||||||
this->ui_.notebook->selectIndex(TAB_IRC);
|
this->ui_.notebook->selectIndex(TAB_IRC);
|
||||||
this->ui_.irc.channel->setText(_channel.get()->getName());
|
this->ui_.irc.channel->setText(_channel.get()->getName());
|
||||||
|
|
||||||
if (auto ircChannel =
|
if (auto *ircChannel =
|
||||||
dynamic_cast<IrcChannel *>(_channel.get().get()))
|
dynamic_cast<IrcChannel *>(_channel.get().get()))
|
||||||
{
|
{
|
||||||
if (auto server = ircChannel->server())
|
if (auto *server = ircChannel->server())
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto &&conn : Irc::instance().connections)
|
for (auto &&conn : Irc::instance().connections)
|
||||||
|
@ -375,7 +375,7 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
||||||
return this->selectedChannel_;
|
return this->selectedChannel_;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
switch (this->ui_.notebook->getSelectedIndex())
|
switch (this->ui_.notebook->getSelectedIndex())
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,16 +15,16 @@ SelectChannelFiltersDialog::SelectChannelFiltersDialog(
|
||||||
const QList<QUuid> &previousSelection, QWidget *parent)
|
const QList<QUuid> &previousSelection, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
auto vbox = new QVBoxLayout(this);
|
auto *vbox = new QVBoxLayout(this);
|
||||||
auto itemVbox = new QVBoxLayout;
|
auto *itemVbox = new QVBoxLayout;
|
||||||
auto buttonBox = new QHBoxLayout;
|
auto *buttonBox = new QHBoxLayout;
|
||||||
auto okButton = new QPushButton("Ok");
|
auto *okButton = new QPushButton("Ok");
|
||||||
auto cancelButton = new QPushButton("Cancel");
|
auto *cancelButton = new QPushButton("Cancel");
|
||||||
|
|
||||||
auto scrollAreaContent = new QWidget;
|
auto *scrollAreaContent = new QWidget;
|
||||||
scrollAreaContent->setLayout(itemVbox);
|
scrollAreaContent->setLayout(itemVbox);
|
||||||
|
|
||||||
auto scrollArea = new QScrollArea;
|
auto *scrollArea = new QScrollArea;
|
||||||
scrollArea->setWidgetResizable(true);
|
scrollArea->setWidgetResizable(true);
|
||||||
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
scrollArea->setWidget(scrollAreaContent);
|
scrollArea->setWidget(scrollAreaContent);
|
||||||
|
@ -53,14 +53,14 @@ SelectChannelFiltersDialog::SelectChannelFiltersDialog(
|
||||||
|
|
||||||
if (availableFilters->size() == 0)
|
if (availableFilters->size() == 0)
|
||||||
{
|
{
|
||||||
auto text = new QLabel("No filters defined");
|
auto *text = new QLabel("No filters defined");
|
||||||
itemVbox->addWidget(text);
|
itemVbox->addWidget(text);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (const auto &f : *availableFilters)
|
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());
|
bool alreadySelected = previousSelection.contains(f->getId());
|
||||||
checkbox->setCheckState(alreadySelected
|
checkbox->setCheckState(alreadySelected
|
||||||
? Qt::CheckState::Checked
|
? Qt::CheckState::Checked
|
||||||
|
|
|
@ -190,8 +190,8 @@ void SettingsDialog::filterElements(const QString &text)
|
||||||
|
|
||||||
for (int i = 0; i < this->ui_.tabContainer->count(); i++)
|
for (int i = 0; i < this->ui_.tabContainer->count(); i++)
|
||||||
{
|
{
|
||||||
auto item = this->ui_.tabContainer->itemAt(i);
|
auto *item = this->ui_.tabContainer->itemAt(i);
|
||||||
if (auto x = dynamic_cast<QSpacerItem *>(item); x)
|
if (auto *x = dynamic_cast<QSpacerItem *>(item); x)
|
||||||
{
|
{
|
||||||
x->changeSize(10, shouldShowSpace ? int(16 * this->scale()) : 0);
|
x->changeSize(10, shouldShowSpace ? int(16 * this->scale()) : 0);
|
||||||
shouldShowSpace = false;
|
shouldShowSpace = false;
|
||||||
|
@ -257,7 +257,8 @@ void SettingsDialog::addTab(std::function<SettingsPage *()> page,
|
||||||
const QString &name, const QString &iconPath,
|
const QString &name, const QString &iconPath,
|
||||||
SettingsTabId id, Qt::Alignment alignment)
|
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_));
|
tab->setFixedHeight(static_cast<int>(30 * this->dpi_));
|
||||||
|
|
||||||
this->ui_.tabContainer->addWidget(tab, 0, alignment);
|
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
|
// add page if it's not been added yet
|
||||||
[&] {
|
[&] {
|
||||||
for (int i = 0; i < this->ui_.pageStack->count(); i++)
|
for (int i = 0; i < this->ui_.pageStack->count(); i++)
|
||||||
|
{
|
||||||
if (this->ui_.pageStack->itemAt(i)->widget() == tab->page())
|
if (this->ui_.pageStack->itemAt(i)->widget() == tab->page())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->ui_.pageStack->addWidget(tab->page());
|
this->ui_.pageStack->addWidget(tab->page());
|
||||||
}();
|
}();
|
||||||
|
@ -301,10 +306,12 @@ void SettingsDialog::selectTab(SettingsDialogTab *tab, bool byUser)
|
||||||
|
|
||||||
void SettingsDialog::selectTab(SettingsTabId id)
|
void SettingsDialog::selectTab(SettingsTabId id)
|
||||||
{
|
{
|
||||||
auto t = this->tab(id);
|
auto *t = this->tab(id);
|
||||||
assert(t);
|
assert(t);
|
||||||
if (!t)
|
if (!t)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this->selectTab(t);
|
this->selectTab(t);
|
||||||
}
|
}
|
||||||
|
@ -312,8 +319,12 @@ void SettingsDialog::selectTab(SettingsTabId id)
|
||||||
SettingsDialogTab *SettingsDialog::tab(SettingsTabId id)
|
SettingsDialogTab *SettingsDialog::tab(SettingsTabId id)
|
||||||
{
|
{
|
||||||
for (auto &&tab : this->tabs_)
|
for (auto &&tab : this->tabs_)
|
||||||
|
{
|
||||||
if (tab->id() == id)
|
if (tab->id() == id)
|
||||||
|
{
|
||||||
return tab;
|
return tab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -325,7 +336,9 @@ void SettingsDialog::showDialog(QWidget *parent,
|
||||||
static SettingsDialog *instance = new SettingsDialog(parent);
|
static SettingsDialog *instance = new SettingsDialog(parent);
|
||||||
static bool hasShownBefore = false;
|
static bool hasShownBefore = false;
|
||||||
if (hasShownBefore)
|
if (hasShownBefore)
|
||||||
|
{
|
||||||
instance->refresh();
|
instance->refresh();
|
||||||
|
}
|
||||||
hasShownBefore = true;
|
hasShownBefore = true;
|
||||||
|
|
||||||
switch (preferredTab)
|
switch (preferredTab)
|
||||||
|
@ -335,10 +348,10 @@ void SettingsDialog::showDialog(QWidget *parent,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SettingsDialogPreference::ModerationActions:
|
case SettingsDialogPreference::ModerationActions:
|
||||||
if (auto tab = instance->tab(SettingsTabId::Moderation))
|
if (auto *tab = instance->tab(SettingsTabId::Moderation))
|
||||||
{
|
{
|
||||||
instance->selectTab(tab);
|
instance->selectTab(tab);
|
||||||
if (auto page = dynamic_cast<ModerationPage *>(tab->page()))
|
if (auto *page = dynamic_cast<ModerationPage *>(tab->page()))
|
||||||
{
|
{
|
||||||
page->selectModerationActions();
|
page->selectModerationActions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ UpdateDialog::UpdateDialog()
|
||||||
.assign(&this->ui_.label);
|
.assign(&this->ui_.label);
|
||||||
|
|
||||||
auto buttons = layout.emplace<QDialogButtonBox>();
|
auto buttons = layout.emplace<QDialogButtonBox>();
|
||||||
auto install = buttons->addButton("Install", QDialogButtonBox::AcceptRole);
|
auto *install = buttons->addButton("Install", QDialogButtonBox::AcceptRole);
|
||||||
this->ui_.installButton = install;
|
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] {
|
QObject::connect(install, &QPushButton::clicked, this, [this] {
|
||||||
Updates::instance().installUpdates();
|
Updates::instance().installUpdates();
|
||||||
|
|
|
@ -75,7 +75,9 @@ namespace {
|
||||||
bool checkMessageUserName(const QString &userName, MessagePtr message)
|
bool checkMessageUserName(const QString &userName, MessagePtr message)
|
||||||
{
|
{
|
||||||
if (message->flags.has(MessageFlag::Whisper))
|
if (message->flags.has(MessageFlag::Whisper))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isSubscription = message->flags.has(MessageFlag::Subscription) &&
|
bool isSubscription = message->flags.has(MessageFlag::Subscription) &&
|
||||||
message->loginName.isEmpty() &&
|
message->loginName.isEmpty() &&
|
||||||
|
@ -296,10 +298,10 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
|
||||||
menu->addAction(
|
menu->addAction(
|
||||||
"Open channel in a new popup window", this,
|
"Open channel in a new popup window", this,
|
||||||
[loginName] {
|
[loginName] {
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
auto &window = app->windows->createWindow(
|
auto &window = app->windows->createWindow(
|
||||||
WindowType::Popup, true);
|
WindowType::Popup, true);
|
||||||
auto split = window.getNotebook()
|
auto *split = window.getNotebook()
|
||||||
.getOrAddSelectedPage()
|
.getOrAddSelectedPage()
|
||||||
->appendNewSplit(false);
|
->appendNewSplit(false);
|
||||||
split->setChannel(app->twitch->getOrAddChannel(
|
split->setChannel(app->twitch->getOrAddChannel(
|
||||||
|
@ -771,7 +773,9 @@ void UserInfoPopup::updateLatestMessages()
|
||||||
this->underlyingChannel_->messageAppended.connect(
|
this->underlyingChannel_->messageAppended.connect(
|
||||||
[this, hasMessages](auto message, auto) {
|
[this, hasMessages](auto message, auto) {
|
||||||
if (!checkMessageUserName(this->userName_, message))
|
if (!checkMessageUserName(this->userName_, message))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasMessages)
|
if (hasMessages)
|
||||||
{
|
{
|
||||||
|
@ -961,7 +965,7 @@ void UserInfoPopup::updateUserData()
|
||||||
void UserInfoPopup::loadAvatar(const QUrl &url)
|
void UserInfoPopup::loadAvatar(const QUrl &url)
|
||||||
{
|
{
|
||||||
QNetworkRequest req(url);
|
QNetworkRequest req(url);
|
||||||
static auto manager = new QNetworkAccessManager();
|
static auto *manager = new QNetworkAccessManager();
|
||||||
auto *reply = manager->get(req);
|
auto *reply = manager->get(req);
|
||||||
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, this, [=, this] {
|
QObject::connect(reply, &QNetworkReply::finished, this, [=, this] {
|
||||||
|
|
|
@ -16,11 +16,15 @@ namespace {
|
||||||
const QSize &size) -> QPixmap
|
const QSize &size) -> QPixmap
|
||||||
{
|
{
|
||||||
if (resized.size() == size)
|
if (resized.size() == size)
|
||||||
|
{
|
||||||
return resized;
|
return resized;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return current.scaled(size, Qt::IgnoreAspectRatio,
|
return current.scaled(size, Qt::IgnoreAspectRatio,
|
||||||
Qt::SmoothTransformation);
|
Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -92,12 +96,18 @@ bool Button::getEnableMargin() const
|
||||||
qreal Button::getCurrentDimAmount() const
|
qreal Button::getCurrentDimAmount() const
|
||||||
{
|
{
|
||||||
if (this->dimPixmap_ == Dim::None || this->mouseOver_)
|
if (this->dimPixmap_ == Dim::None || this->mouseOver_)
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
else if (this->dimPixmap_ == Dim::Some)
|
else if (this->dimPixmap_ == Dim::Some)
|
||||||
|
{
|
||||||
return 0.7;
|
return 0.7;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return 0.15;
|
return 0.15;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Button::setBorderColor(const QColor &color)
|
void Button::setBorderColor(const QColor &color)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +124,9 @@ const QColor &Button::getBorderColor() const
|
||||||
void Button::setMenu(std::unique_ptr<QMenu> menu)
|
void Button::setMenu(std::unique_ptr<QMenu> menu)
|
||||||
{
|
{
|
||||||
if (this->menu_)
|
if (this->menu_)
|
||||||
|
{
|
||||||
this->menu_.release()->deleteLater();
|
this->menu_.release()->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
this->menu_ = std::move(menu);
|
this->menu_ = std::move(menu);
|
||||||
|
|
||||||
|
@ -362,7 +374,9 @@ void Button::onMouseEffectTimeout()
|
||||||
void Button::showMenu()
|
void Button::showMenu()
|
||||||
{
|
{
|
||||||
if (!this->menu_)
|
if (!this->menu_)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto menuSizeHint = this->menu_->sizeHint();
|
auto menuSizeHint = this->menu_->sizeHint();
|
||||||
auto point = this->mapToGlobal(
|
auto point = this->mapToGlobal(
|
||||||
|
|
|
@ -56,10 +56,14 @@ void ComboBoxItemDelegate::setModelData(QWidget *editor,
|
||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (QComboBox *cb = qobject_cast<QComboBox *>(editor))
|
if (QComboBox *cb = qobject_cast<QComboBox *>(editor))
|
||||||
|
{
|
||||||
// save the current text of the combo box as the current value of the
|
// save the current text of the combo box as the current value of the
|
||||||
// item
|
// item
|
||||||
model->setData(index, cb->currentText(), Qt::EditRole);
|
model->setData(index, cb->currentText(), Qt::EditRole);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
QStyledItemDelegate::setModelData(editor, model, index);
|
QStyledItemDelegate::setModelData(editor, model, index);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -53,12 +53,16 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
|
||||||
// Remove rows backwards so indices don't shift.
|
// Remove rows backwards so indices don't shift.
|
||||||
std::vector<int> rows;
|
std::vector<int> rows;
|
||||||
for (auto &&index : selected)
|
for (auto &&index : selected)
|
||||||
|
{
|
||||||
rows.push_back(index.row());
|
rows.push_back(index.row());
|
||||||
|
}
|
||||||
|
|
||||||
std::sort(rows.begin(), rows.end(), std::greater{});
|
std::sort(rows.begin(), rows.end(), std::greater{});
|
||||||
|
|
||||||
for (auto &&row : rows)
|
for (auto &&row : rows)
|
||||||
|
{
|
||||||
model_->removeRow(row);
|
model_->removeRow(row);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (movable)
|
if (movable)
|
||||||
|
@ -135,7 +139,7 @@ void EditableModelView::addCustomButton(QWidget *widget)
|
||||||
|
|
||||||
void EditableModelView::addRegexHelpLink()
|
void EditableModelView::addRegexHelpLink()
|
||||||
{
|
{
|
||||||
auto regexHelpLabel =
|
auto *regexHelpLabel =
|
||||||
new QLabel("<a href='"
|
new QLabel("<a href='"
|
||||||
"https://chatterino.com/help/regex'>"
|
"https://chatterino.com/help/regex'>"
|
||||||
"<span style='color:#99f'>regex info</span></a>");
|
"<span style='color:#99f'>regex info</span></a>");
|
||||||
|
@ -152,7 +156,9 @@ void EditableModelView::moveRow(int dir)
|
||||||
(row = selected.at(0).row()) + dir >=
|
(row = selected.at(0).row()) + dir >=
|
||||||
this->model_->rowCount(QModelIndex()) ||
|
this->model_->rowCount(QModelIndex()) ||
|
||||||
row + dir < 0)
|
row + dir < 0)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
model_->moveRows(model_->index(row, 0), row, selected.size(),
|
model_->moveRows(model_->index(row, 0), row, selected.size(),
|
||||||
model_->index(row + dir, 0), row + dir);
|
model_->index(row + dir, 0), row + dir);
|
||||||
|
|
|
@ -158,11 +158,13 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
||||||
void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
||||||
{
|
{
|
||||||
if (!event->mimeData()->hasFormat("chatterino/split"))
|
if (!event->mimeData()->hasFormat("chatterino/split"))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
|
||||||
auto e = new QMouseEvent(QMouseEvent::MouseButtonPress,
|
auto *e = new QMouseEvent(QMouseEvent::MouseButtonPress,
|
||||||
QPointF(this->width() / 2, this->height() / 2),
|
QPointF(this->width() / 2, this->height() / 2),
|
||||||
Qt::LeftButton, Qt::LeftButton, {});
|
Qt::LeftButton, Qt::LeftButton, {});
|
||||||
Button::mousePressEvent(e);
|
Button::mousePressEvent(e);
|
||||||
|
@ -174,7 +176,7 @@ void NotebookButton::dragLeaveEvent(QDragLeaveEvent *)
|
||||||
this->mouseDown_ = true;
|
this->mouseDown_ = true;
|
||||||
this->update();
|
this->update();
|
||||||
|
|
||||||
auto e = new QMouseEvent(QMouseEvent::MouseButtonRelease,
|
auto *e = new QMouseEvent(QMouseEvent::MouseButtonRelease,
|
||||||
QPointF(this->width() / 2, this->height() / 2),
|
QPointF(this->width() / 2, this->height() / 2),
|
||||||
Qt::LeftButton, Qt::LeftButton, {});
|
Qt::LeftButton, Qt::LeftButton, {});
|
||||||
Button::mouseReleaseEvent(e);
|
Button::mouseReleaseEvent(e);
|
||||||
|
|
|
@ -99,7 +99,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
this->menu_.addAction(
|
this->menu_.addAction(
|
||||||
"Popup Tab",
|
"Popup Tab",
|
||||||
[this]() {
|
[this]() {
|
||||||
if (auto container = dynamic_cast<SplitContainer *>(this->page))
|
if (auto *container = dynamic_cast<SplitContainer *>(this->page))
|
||||||
{
|
{
|
||||||
container->popup();
|
container->popup();
|
||||||
}
|
}
|
||||||
|
@ -124,11 +124,11 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
|
|
||||||
void NotebookTab::showRenameDialog()
|
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->setText(this->getCustomTitle());
|
||||||
lineEdit->setPlaceholderText(this->getDefaultTitle());
|
lineEdit->setPlaceholderText(this->getDefaultTitle());
|
||||||
lineEdit->selectAll();
|
lineEdit->selectAll();
|
||||||
|
@ -137,7 +137,7 @@ void NotebookTab::showRenameDialog()
|
||||||
vbox->addWidget(lineEdit);
|
vbox->addWidget(lineEdit);
|
||||||
vbox->addStretch(1);
|
vbox->addStretch(1);
|
||||||
|
|
||||||
auto buttonBox =
|
auto *buttonBox =
|
||||||
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
vbox->addWidget(buttonBox);
|
vbox->addWidget(buttonBox);
|
||||||
|
@ -423,7 +423,7 @@ void NotebookTab::moveAnimated(QPoint pos, bool animated)
|
||||||
|
|
||||||
void NotebookTab::paintEvent(QPaintEvent *)
|
void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
float scale = this->scale();
|
float scale = this->scale();
|
||||||
|
|
||||||
|
@ -439,13 +439,21 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
Theme::TabColors colors;
|
Theme::TabColors colors;
|
||||||
|
|
||||||
if (this->selected_)
|
if (this->selected_)
|
||||||
|
{
|
||||||
colors = this->theme->tabs.selected;
|
colors = this->theme->tabs.selected;
|
||||||
|
}
|
||||||
else if (this->highlightState_ == HighlightState::Highlighted)
|
else if (this->highlightState_ == HighlightState::Highlighted)
|
||||||
|
{
|
||||||
colors = this->theme->tabs.highlighted;
|
colors = this->theme->tabs.highlighted;
|
||||||
|
}
|
||||||
else if (this->highlightState_ == HighlightState::NewMessage)
|
else if (this->highlightState_ == HighlightState::NewMessage)
|
||||||
|
{
|
||||||
colors = this->theme->tabs.newMessage;
|
colors = this->theme->tabs.newMessage;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
colors = this->theme->tabs.regular;
|
colors = this->theme->tabs.regular;
|
||||||
|
}
|
||||||
|
|
||||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ bool ResizingTextEdit::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto ev = static_cast<QKeyEvent *>(event);
|
auto *ev = static_cast<QKeyEvent *>(event);
|
||||||
ev->ignore();
|
ev->ignore();
|
||||||
if ((ev->key() == Qt::Key_C || ev->key() == Qt::Key_Insert) &&
|
if ((ev->key() == Qt::Key_C || ev->key() == Qt::Key_Insert) &&
|
||||||
ev->modifiers() == Qt::ControlModifier)
|
ev->modifiers() == Qt::ControlModifier)
|
||||||
|
|
|
@ -42,7 +42,9 @@ void SettingsDialogTab::setSelected(bool _selected)
|
||||||
SettingsPage *SettingsDialogTab::page()
|
SettingsPage *SettingsDialogTab::page()
|
||||||
{
|
{
|
||||||
if (this->page_)
|
if (this->page_)
|
||||||
|
{
|
||||||
return this->page_;
|
return this->page_;
|
||||||
|
}
|
||||||
|
|
||||||
this->page_ = this->lazyPage_();
|
this->page_ = this->lazyPage_();
|
||||||
this->page_->setTab(this);
|
this->page_->setTab(this);
|
||||||
|
|
|
@ -22,7 +22,9 @@ void SwitcherItemDelegate::paint(QPainter *painter,
|
||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
if (option.state & QStyle::State_Selected)
|
if (option.state & QStyle::State_Selected)
|
||||||
|
{
|
||||||
painter->fillRect(option.rect, option.palette.highlight());
|
painter->fillRect(option.rect, option.palette.highlight());
|
||||||
|
}
|
||||||
|
|
||||||
item->paint(painter, option.rect);
|
item->paint(painter, option.rect);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ GenericListView::GenericListView()
|
||||||
|
|
||||||
void GenericListView::setModel(QAbstractItemModel *model)
|
void GenericListView::setModel(QAbstractItemModel *model)
|
||||||
{
|
{
|
||||||
auto casted = dynamic_cast<GenericListModel *>(model);
|
auto *casted = dynamic_cast<GenericListModel *>(model);
|
||||||
assert(casted);
|
assert(casted);
|
||||||
this->setModel(casted);
|
this->setModel(casted);
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ AboutPage::AboutPage()
|
||||||
|
|
||||||
const auto addLabels = [&contributorBox2, &usernameLabel,
|
const auto addLabels = [&contributorBox2, &usernameLabel,
|
||||||
&roleLabel] {
|
&roleLabel] {
|
||||||
auto labelBox = new QVBoxLayout();
|
auto *labelBox = new QVBoxLayout();
|
||||||
contributorBox2->addLayout(labelBox);
|
contributorBox2->addLayout(labelBox);
|
||||||
|
|
||||||
labelBox->addWidget(usernameLabel);
|
labelBox->addWidget(usernameLabel);
|
||||||
|
@ -236,7 +236,7 @@ void AboutPage::addLicense(QFormLayout *form, const QString &name,
|
||||||
parent);
|
parent);
|
||||||
window->setWindowTitle("Chatterino - License for " + name);
|
window->setWindowTitle("Chatterino - License for " + name);
|
||||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
auto layout = new QVBoxLayout();
|
auto *layout = new QVBoxLayout();
|
||||||
auto *edit = new QTextEdit;
|
auto *edit = new QTextEdit;
|
||||||
|
|
||||||
QFile file(licenseLink);
|
QFile file(licenseLink);
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace {
|
||||||
|
|
||||||
CommandPage::CommandPage()
|
CommandPage::CommandPage()
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
LayoutCreator<CommandPage> layoutCreator(this);
|
LayoutCreator<CommandPage> layoutCreator(this);
|
||||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||||
|
@ -54,7 +54,7 @@ CommandPage::CommandPage()
|
||||||
// TODO: asyncronously check path
|
// TODO: asyncronously check path
|
||||||
if (QFile(c1settingsPath()).exists())
|
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);
|
view->addCustomButton(button);
|
||||||
|
|
||||||
QObject::connect(button, &QPushButton::clicked, this, [] {
|
QObject::connect(button, &QPushButton::clicked, this, [] {
|
||||||
|
|
|
@ -54,7 +54,7 @@ FiltersPage::FiltersPage()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
auto quickAddButton = new QPushButton("Quick Add");
|
auto *quickAddButton = new QPushButton("Quick Add");
|
||||||
QObject::connect(quickAddButton, &QPushButton::pressed, [] {
|
QObject::connect(quickAddButton, &QPushButton::pressed, [] {
|
||||||
getSettings()->filterRecords.append(std::make_shared<FilterRecord>(
|
getSettings()->filterRecords.append(std::make_shared<FilterRecord>(
|
||||||
"My filter", "message.content contains \"hello\""));
|
"My filter", "message.content contains \"hello\""));
|
||||||
|
@ -66,7 +66,7 @@ FiltersPage::FiltersPage()
|
||||||
this->tableCellClicked(clicked, view);
|
this->tableCellClicked(clicked, view);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto filterHelpLabel =
|
auto *filterHelpLabel =
|
||||||
new QLabel(QString("<a href='%1'><span "
|
new QLabel(QString("<a href='%1'><span "
|
||||||
"style='color:#99f'>filter info</span></a>")
|
"style='color:#99f'>filter info</span></a>")
|
||||||
.arg(FILTERS_DOCUMENTATION));
|
.arg(FILTERS_DOCUMENTATION));
|
||||||
|
|
|
@ -89,12 +89,12 @@ namespace {
|
||||||
|
|
||||||
GeneralPage::GeneralPage()
|
GeneralPage::GeneralPage()
|
||||||
{
|
{
|
||||||
auto y = new QVBoxLayout;
|
auto *y = new QVBoxLayout;
|
||||||
auto x = new QHBoxLayout;
|
auto *x = new QHBoxLayout;
|
||||||
auto view = new GeneralPageView;
|
auto *view = new GeneralPageView;
|
||||||
this->view_ = view;
|
this->view_ = view;
|
||||||
x->addWidget(view);
|
x->addWidget(view);
|
||||||
auto z = new QFrame;
|
auto *z = new QFrame;
|
||||||
z->setLayout(x);
|
z->setLayout(x);
|
||||||
y->addWidget(z);
|
y->addWidget(z);
|
||||||
this->setLayout(y);
|
this->setLayout(y);
|
||||||
|
@ -107,10 +107,14 @@ GeneralPage::GeneralPage()
|
||||||
bool GeneralPage::filterElements(const QString &query)
|
bool GeneralPage::filterElements(const QString &query)
|
||||||
{
|
{
|
||||||
if (this->view_)
|
if (this->view_)
|
||||||
|
{
|
||||||
return this->view_->filterElements(query) || query.isEmpty();
|
return this->view_->filterElements(query) || query.isEmpty();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralPage::initLayout(GeneralPageView &layout)
|
void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
{
|
{
|
||||||
|
@ -154,9 +158,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
s.uiScale,
|
s.uiScale,
|
||||||
[](auto val) {
|
[](auto val) {
|
||||||
if (val == 1)
|
if (val == 1)
|
||||||
|
{
|
||||||
return QString("Default");
|
return QString("Default");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return QString::number(val) + "x";
|
return QString::number(val) + "x";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[](auto args) {
|
[](auto args) {
|
||||||
return fuzzyToFloat(args.value, 1.f);
|
return fuzzyToFloat(args.value, 1.f);
|
||||||
|
@ -280,20 +288,32 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
s.pauseOnHoverDuration,
|
s.pauseOnHoverDuration,
|
||||||
[](auto val) {
|
[](auto val) {
|
||||||
if (val < -0.5f)
|
if (val < -0.5f)
|
||||||
|
{
|
||||||
return QString("Indefinite");
|
return QString("Indefinite");
|
||||||
|
}
|
||||||
else if (val < 0.001f)
|
else if (val < 0.001f)
|
||||||
|
{
|
||||||
return QString("Disabled");
|
return QString("Disabled");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return QString::number(val) + "s";
|
return QString::number(val) + "s";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[](auto args) {
|
[](auto args) {
|
||||||
if (args.index == 0)
|
if (args.index == 0)
|
||||||
|
{
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
}
|
||||||
else if (args.value == "Indefinite")
|
else if (args.value == "Indefinite")
|
||||||
|
{
|
||||||
return -1.0f;
|
return -1.0f;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return fuzzyToFloat(args.value,
|
return fuzzyToFloat(args.value,
|
||||||
std::numeric_limits<float>::infinity());
|
std::numeric_limits<float>::infinity());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
addKeyboardModifierSetting(layout, "Pause while holding a key",
|
addKeyboardModifierSetting(layout, "Pause while holding a key",
|
||||||
s.pauseChatModifier);
|
s.pauseChatModifier);
|
||||||
|
@ -302,9 +322,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
s.mouseScrollMultiplier,
|
s.mouseScrollMultiplier,
|
||||||
[](auto val) {
|
[](auto val) {
|
||||||
if (val == 1)
|
if (val == 1)
|
||||||
|
{
|
||||||
return QString("Default");
|
return QString("Default");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return QString::number(val) + "x";
|
return QString::number(val) + "x";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[](auto args) {
|
[](auto args) {
|
||||||
return fuzzyToFloat(args.value, 1.f);
|
return fuzzyToFloat(args.value, 1.f);
|
||||||
|
@ -492,9 +516,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
s.emoteScale,
|
s.emoteScale,
|
||||||
[](auto val) {
|
[](auto val) {
|
||||||
if (val == 1)
|
if (val == 1)
|
||||||
|
{
|
||||||
return QString("Default");
|
return QString("Default");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return QString::number(val) + "x";
|
return QString::number(val) + "x";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[](auto args) {
|
[](auto args) {
|
||||||
return fuzzyToFloat(args.value, 1.f);
|
return fuzzyToFloat(args.value, 1.f);
|
||||||
|
@ -631,23 +659,39 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
{"Off", "Small", "Medium", "Large"}, s.thumbnailSize,
|
{"Off", "Small", "Medium", "Large"}, s.thumbnailSize,
|
||||||
[](auto val) {
|
[](auto val) {
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
|
{
|
||||||
return QString("Off");
|
return QString("Off");
|
||||||
|
}
|
||||||
else if (val == 100)
|
else if (val == 100)
|
||||||
|
{
|
||||||
return QString("Small");
|
return QString("Small");
|
||||||
|
}
|
||||||
else if (val == 200)
|
else if (val == 200)
|
||||||
|
{
|
||||||
return QString("Medium");
|
return QString("Medium");
|
||||||
|
}
|
||||||
else if (val == 300)
|
else if (val == 300)
|
||||||
|
{
|
||||||
return QString("Large");
|
return QString("Large");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return QString::number(val);
|
return QString::number(val);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[](auto args) {
|
[](auto args) {
|
||||||
if (args.value == "Small")
|
if (args.value == "Small")
|
||||||
|
{
|
||||||
return 100;
|
return 100;
|
||||||
|
}
|
||||||
else if (args.value == "Medium")
|
else if (args.value == "Medium")
|
||||||
|
{
|
||||||
return 200;
|
return 200;
|
||||||
|
}
|
||||||
else if (args.value == "Large")
|
else if (args.value == "Large")
|
||||||
|
{
|
||||||
return 300;
|
return 300;
|
||||||
|
}
|
||||||
|
|
||||||
return fuzzyToInt(args.value, 0);
|
return fuzzyToInt(args.value, 0);
|
||||||
});
|
});
|
||||||
|
@ -656,23 +700,39 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
s.thumbnailSizeStream,
|
s.thumbnailSizeStream,
|
||||||
[](auto val) {
|
[](auto val) {
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
|
{
|
||||||
return QString("Off");
|
return QString("Off");
|
||||||
|
}
|
||||||
else if (val == 1)
|
else if (val == 1)
|
||||||
|
{
|
||||||
return QString("Small");
|
return QString("Small");
|
||||||
|
}
|
||||||
else if (val == 2)
|
else if (val == 2)
|
||||||
|
{
|
||||||
return QString("Medium");
|
return QString("Medium");
|
||||||
|
}
|
||||||
else if (val == 3)
|
else if (val == 3)
|
||||||
|
{
|
||||||
return QString("Large");
|
return QString("Large");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return QString::number(val);
|
return QString::number(val);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[](auto args) {
|
[](auto args) {
|
||||||
if (args.value == "Small")
|
if (args.value == "Small")
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
else if (args.value == "Medium")
|
else if (args.value == "Medium")
|
||||||
|
{
|
||||||
return 2;
|
return 2;
|
||||||
|
}
|
||||||
else if (args.value == "Large")
|
else if (args.value == "Large")
|
||||||
|
{
|
||||||
return 3;
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
return fuzzyToInt(args.value, 0);
|
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 "
|
"Files that are used often (such as emotes) are saved to disk to "
|
||||||
"reduce bandwidth usage and to speed up loading.");
|
"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 &,
|
getSettings()->cachePath.connect([cachePathLabel](const auto &,
|
||||||
auto) mutable {
|
auto) mutable {
|
||||||
QString newPath = getPaths()->cacheDirectory();
|
QString newPath = getPaths()->cacheDirectory();
|
||||||
|
@ -756,7 +816,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
|
|
||||||
// Choose and reset buttons
|
// Choose and reset buttons
|
||||||
{
|
{
|
||||||
auto box = new QHBoxLayout;
|
auto *box = new QHBoxLayout;
|
||||||
|
|
||||||
box->addWidget(layout.makeButton("Choose cache path", [this]() {
|
box->addWidget(layout.makeButton("Choose cache path", [this]() {
|
||||||
getSettings()->cachePath = QFileDialog::getExistingDirectory(this);
|
getSettings()->cachePath = QFileDialog::getExistingDirectory(this);
|
||||||
|
@ -964,9 +1024,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
"Username font weight", {"50", "Default", "75", "100"}, s.boldScale,
|
"Username font weight", {"50", "Default", "75", "100"}, s.boldScale,
|
||||||
[](auto val) {
|
[](auto val) {
|
||||||
if (val == 63)
|
if (val == 63)
|
||||||
|
{
|
||||||
return QString("Default");
|
return QString("Default");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return QString::number(val);
|
return QString::number(val);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[](auto args) {
|
[](auto args) {
|
||||||
return fuzzyToFloat(args.value, 63.f);
|
return fuzzyToFloat(args.value, 63.f);
|
||||||
|
@ -1156,7 +1220,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
layout.addStretch();
|
layout.addStretch();
|
||||||
|
|
||||||
// invisible element for width
|
// invisible element for width
|
||||||
auto inv = new BaseWidget(this);
|
auto *inv = new BaseWidget(this);
|
||||||
// inv->setScaleIndependantWidth(600);
|
// inv->setScaleIndependantWidth(600);
|
||||||
layout.addWidget(inv);
|
layout.addWidget(inv);
|
||||||
}
|
}
|
||||||
|
@ -1192,10 +1256,14 @@ QString GeneralPage::getFont(const DropdownArgs &args) const
|
||||||
auto font = dialog.getFont(&ok, this->window());
|
auto font = dialog.getFont(&ok, this->window());
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
|
{
|
||||||
return font.family();
|
return font.family();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return args.combobox->itemText(0);
|
return args.combobox->itemText(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return args.value;
|
return args.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,11 @@ namespace chatterino {
|
||||||
GeneralPageView::GeneralPageView(QWidget *parent)
|
GeneralPageView::GeneralPageView(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
auto scrollArea = this->contentScrollArea_ =
|
auto *scrollArea = this->contentScrollArea_ =
|
||||||
makeScrollArea(this->contentLayout_ = new QVBoxLayout);
|
makeScrollArea(this->contentLayout_ = new QVBoxLayout);
|
||||||
scrollArea->setObjectName("generalSettingsScrollContent");
|
scrollArea->setObjectName("generalSettingsScrollContent");
|
||||||
|
|
||||||
auto navigation =
|
auto *navigation =
|
||||||
wrapLayout(this->navigationLayout_ = makeLayout<QVBoxLayout>({}));
|
wrapLayout(this->navigationLayout_ = makeLayout<QVBoxLayout>({}));
|
||||||
navigation->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
navigation->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
||||||
this->navigationLayout_->setAlignment(Qt::AlignTop);
|
this->navigationLayout_->setAlignment(Qt::AlignTop);
|
||||||
|
@ -63,14 +63,16 @@ TitleLabel *GeneralPageView::addTitle(const QString &title)
|
||||||
{
|
{
|
||||||
// space
|
// space
|
||||||
if (!this->groups_.empty())
|
if (!this->groups_.empty())
|
||||||
|
{
|
||||||
this->addWidget(this->groups_.back().space = new Space);
|
this->addWidget(this->groups_.back().space = new Space);
|
||||||
|
}
|
||||||
|
|
||||||
// title
|
// title
|
||||||
auto label = new TitleLabel(title + ":");
|
auto *label = new TitleLabel(title + ":");
|
||||||
this->addWidget(label);
|
this->addWidget(label);
|
||||||
|
|
||||||
// navigation item
|
// navigation item
|
||||||
auto navLabel = new NavigationLabel(title);
|
auto *navLabel = new NavigationLabel(title);
|
||||||
navLabel->setCursor(Qt::PointingHandCursor);
|
navLabel->setCursor(Qt::PointingHandCursor);
|
||||||
this->navigationLayout_->addWidget(navLabel);
|
this->navigationLayout_->addWidget(navLabel);
|
||||||
|
|
||||||
|
@ -82,14 +84,16 @@ TitleLabel *GeneralPageView::addTitle(const QString &title)
|
||||||
this->groups_.push_back(Group{title, label, navLabel, nullptr, {}});
|
this->groups_.push_back(Group{title, label, navLabel, nullptr, {}});
|
||||||
|
|
||||||
if (this->groups_.size() == 1)
|
if (this->groups_.size() == 1)
|
||||||
|
{
|
||||||
this->updateNavigationHighlighting();
|
this->updateNavigationHighlighting();
|
||||||
|
}
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
SubtitleLabel *GeneralPageView::addSubtitle(const QString &title)
|
SubtitleLabel *GeneralPageView::addSubtitle(const QString &title)
|
||||||
{
|
{
|
||||||
auto label = new SubtitleLabel(title + ":");
|
auto *label = new SubtitleLabel(title + ":");
|
||||||
this->addWidget(label);
|
this->addWidget(label);
|
||||||
|
|
||||||
this->groups_.back().widgets.push_back({label, {title}});
|
this->groups_.back().widgets.push_back({label, {title}});
|
||||||
|
@ -101,7 +105,7 @@ QCheckBox *GeneralPageView::addCheckbox(const QString &text,
|
||||||
BoolSetting &setting, bool inverse,
|
BoolSetting &setting, bool inverse,
|
||||||
QString toolTipText)
|
QString toolTipText)
|
||||||
{
|
{
|
||||||
auto check = new QCheckBox(text);
|
auto *check = new QCheckBox(text);
|
||||||
this->addToolTip(*check, toolTipText);
|
this->addToolTip(*check, toolTipText);
|
||||||
|
|
||||||
// update when setting changes
|
// update when setting changes
|
||||||
|
@ -151,12 +155,12 @@ ComboBox *GeneralPageView::addDropdown(const QString &text,
|
||||||
const QStringList &list,
|
const QStringList &list,
|
||||||
QString toolTipText)
|
QString toolTipText)
|
||||||
{
|
{
|
||||||
auto layout = new QHBoxLayout;
|
auto *layout = new QHBoxLayout;
|
||||||
auto combo = new ComboBox;
|
auto *combo = new ComboBox;
|
||||||
combo->setFocusPolicy(Qt::StrongFocus);
|
combo->setFocusPolicy(Qt::StrongFocus);
|
||||||
combo->addItems(list);
|
combo->addItems(list);
|
||||||
|
|
||||||
auto label = new QLabel(text + ":");
|
auto *label = new QLabel(text + ":");
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
layout->addWidget(combo);
|
layout->addWidget(combo);
|
||||||
|
@ -176,10 +180,12 @@ ComboBox *GeneralPageView::addDropdown(
|
||||||
pajlada::Settings::Setting<QString> &setting, bool editable,
|
pajlada::Settings::Setting<QString> &setting, bool editable,
|
||||||
QString toolTipText)
|
QString toolTipText)
|
||||||
{
|
{
|
||||||
auto combo = this->addDropdown(text, items, toolTipText);
|
auto *combo = this->addDropdown(text, items, toolTipText);
|
||||||
|
|
||||||
if (editable)
|
if (editable)
|
||||||
|
{
|
||||||
combo->setEditable(true);
|
combo->setEditable(true);
|
||||||
|
}
|
||||||
|
|
||||||
// update when setting changes
|
// update when setting changes
|
||||||
setting.connect(
|
setting.connect(
|
||||||
|
@ -201,9 +207,9 @@ ColorButton *GeneralPageView::addColorButton(
|
||||||
const QString &text, const QColor &color,
|
const QString &text, const QColor &color,
|
||||||
pajlada::Settings::Setting<QString> &setting, QString toolTipText)
|
pajlada::Settings::Setting<QString> &setting, QString toolTipText)
|
||||||
{
|
{
|
||||||
auto colorButton = new ColorButton(color);
|
auto *colorButton = new ColorButton(color);
|
||||||
auto layout = new QHBoxLayout();
|
auto *layout = new QHBoxLayout();
|
||||||
auto label = new QLabel(text + ":");
|
auto *label = new QLabel(text + ":");
|
||||||
|
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
|
@ -238,12 +244,12 @@ QSpinBox *GeneralPageView::addIntInput(const QString &text, IntSetting &setting,
|
||||||
int min, int max, int step,
|
int min, int max, int step,
|
||||||
QString toolTipText)
|
QString toolTipText)
|
||||||
{
|
{
|
||||||
auto layout = new QHBoxLayout;
|
auto *layout = new QHBoxLayout;
|
||||||
|
|
||||||
auto label = new QLabel(text + ":");
|
auto *label = new QLabel(text + ":");
|
||||||
this->addToolTip(*label, toolTipText);
|
this->addToolTip(*label, toolTipText);
|
||||||
|
|
||||||
auto input = new QSpinBox;
|
auto *input = new QSpinBox;
|
||||||
input->setMinimum(min);
|
input->setMinimum(min);
|
||||||
input->setMaximum(max);
|
input->setMaximum(max);
|
||||||
|
|
||||||
|
@ -280,7 +286,7 @@ void GeneralPageView::addNavigationSpacing()
|
||||||
|
|
||||||
DescriptionLabel *GeneralPageView::addDescription(const QString &text)
|
DescriptionLabel *GeneralPageView::addDescription(const QString &text)
|
||||||
{
|
{
|
||||||
auto label = new DescriptionLabel(text);
|
auto *label = new DescriptionLabel(text);
|
||||||
|
|
||||||
label->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
label->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||||
Qt::LinksAccessibleByKeyboard);
|
Qt::LinksAccessibleByKeyboard);
|
||||||
|
@ -310,7 +316,7 @@ bool GeneralPageView::filterElements(const QString &query)
|
||||||
bool descriptionMatches{};
|
bool descriptionMatches{};
|
||||||
for (auto &&widget : group.widgets)
|
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))
|
if (x->text().contains(query, Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
|
@ -325,7 +331,9 @@ bool GeneralPageView::filterElements(const QString &query)
|
||||||
descriptionMatches)
|
descriptionMatches)
|
||||||
{
|
{
|
||||||
for (auto &&widget : group.widgets)
|
for (auto &&widget : group.widgets)
|
||||||
|
{
|
||||||
widget.element->show();
|
widget.element->show();
|
||||||
|
}
|
||||||
|
|
||||||
group.title->show();
|
group.title->show();
|
||||||
group.navigationLink->show();
|
group.navigationLink->show();
|
||||||
|
@ -342,11 +350,13 @@ bool GeneralPageView::filterElements(const QString &query)
|
||||||
|
|
||||||
for (auto &&widget : group.widgets)
|
for (auto &&widget : group.widgets)
|
||||||
{
|
{
|
||||||
if (auto x = dynamic_cast<SubtitleLabel *>(widget.element))
|
if (auto *x = dynamic_cast<SubtitleLabel *>(widget.element))
|
||||||
{
|
{
|
||||||
currentSubtitleSearched = false;
|
currentSubtitleSearched = false;
|
||||||
if (currentSubtitle)
|
if (currentSubtitle)
|
||||||
|
{
|
||||||
currentSubtitle->setVisible(currentSubtitleVisible);
|
currentSubtitle->setVisible(currentSubtitleVisible);
|
||||||
|
}
|
||||||
|
|
||||||
currentSubtitleVisible = false;
|
currentSubtitleVisible = false;
|
||||||
currentSubtitle = widget.element;
|
currentSubtitle = widget.element;
|
||||||
|
@ -375,10 +385,14 @@ bool GeneralPageView::filterElements(const QString &query)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentSubtitle)
|
if (currentSubtitle)
|
||||||
|
{
|
||||||
currentSubtitle->setVisible(currentSubtitleVisible);
|
currentSubtitle->setVisible(currentSubtitleVisible);
|
||||||
|
}
|
||||||
|
|
||||||
if (group.space)
|
if (group.space)
|
||||||
|
{
|
||||||
group.space->setVisible(groupAny);
|
group.space->setVisible(groupAny);
|
||||||
|
}
|
||||||
|
|
||||||
group.title->setVisible(groupAny);
|
group.title->setVisible(groupAny);
|
||||||
group.navigationLink->setVisible(groupAny);
|
group.navigationLink->setVisible(groupAny);
|
||||||
|
|
|
@ -123,7 +123,7 @@ public:
|
||||||
template <typename OnClick>
|
template <typename OnClick>
|
||||||
QPushButton *makeButton(const QString &text, OnClick 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}});
|
this->groups_.back().widgets.push_back({button, {text}});
|
||||||
QObject::connect(button, &QPushButton::clicked, onClick);
|
QObject::connect(button, &QPushButton::clicked, onClick);
|
||||||
return button;
|
return button;
|
||||||
|
@ -133,7 +133,7 @@ public:
|
||||||
QPushButton *addButton(const QString &text, OnClick onClick)
|
QPushButton *addButton(const QString &text, OnClick onClick)
|
||||||
{
|
{
|
||||||
auto button = makeButton(text, onClick);
|
auto button = makeButton(text, onClick);
|
||||||
auto layout = new QHBoxLayout();
|
auto *layout = new QHBoxLayout();
|
||||||
layout->addWidget(button);
|
layout->addWidget(button);
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
this->addLayout(layout);
|
this->addLayout(layout);
|
||||||
|
@ -155,20 +155,26 @@ public:
|
||||||
{
|
{
|
||||||
// QString
|
// QString
|
||||||
if (!editable && !items2.contains(boost::get<QString>(selected)))
|
if (!editable && !items2.contains(boost::get<QString>(selected)))
|
||||||
|
{
|
||||||
items2.insert(0, 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)
|
if (editable)
|
||||||
|
{
|
||||||
combo->setEditable(true);
|
combo->setEditable(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (selected.which() == 0)
|
if (selected.which() == 0)
|
||||||
{
|
{
|
||||||
// int
|
// int
|
||||||
auto value = boost::get<int>(selected);
|
auto value = boost::get<int>(selected);
|
||||||
if (value >= 0 && value < items2.size())
|
if (value >= 0 && value < items2.size())
|
||||||
|
{
|
||||||
combo->setCurrentIndex(value);
|
combo->setCurrentIndex(value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (selected.which() == 1)
|
else if (selected.which() == 1)
|
||||||
{
|
{
|
||||||
// QString
|
// QString
|
||||||
|
@ -179,7 +185,9 @@ public:
|
||||||
[getValue = std::move(getValue), combo](const T &value, auto) {
|
[getValue = std::move(getValue), combo](const T &value, auto) {
|
||||||
auto var = getValue(value);
|
auto var = getValue(value);
|
||||||
if (var.which() == 0)
|
if (var.which() == 0)
|
||||||
|
{
|
||||||
combo->setCurrentIndex(boost::get<int>(var));
|
combo->setCurrentIndex(boost::get<int>(var));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
combo->setCurrentText(boost::get<QString>(var));
|
combo->setCurrentText(boost::get<QString>(var));
|
||||||
|
|
|
@ -67,7 +67,7 @@ HighlightingPage::HighlightingPage()
|
||||||
"Message highlights are prioritized over badge highlights "
|
"Message highlights are prioritized over badge highlights "
|
||||||
"and user highlights.");
|
"and user highlights.");
|
||||||
|
|
||||||
auto view =
|
auto *view =
|
||||||
highlights
|
highlights
|
||||||
.emplace<EditableModelView>(
|
.emplace<EditableModelView>(
|
||||||
(new HighlightModel(nullptr))
|
(new HighlightModel(nullptr))
|
||||||
|
@ -170,7 +170,7 @@ HighlightingPage::HighlightingPage()
|
||||||
"user badges.\n"
|
"user badges.\n"
|
||||||
"Badge highlights are prioritzed under user and message "
|
"Badge highlights are prioritzed under user and message "
|
||||||
"highlights.");
|
"highlights.");
|
||||||
auto view = badgeHighlights
|
auto *view = badgeHighlights
|
||||||
.emplace<EditableModelView>(
|
.emplace<EditableModelView>(
|
||||||
(new BadgeHighlightModel(nullptr))
|
(new BadgeHighlightModel(nullptr))
|
||||||
->initialized(
|
->initialized(
|
||||||
|
|
|
@ -83,7 +83,7 @@ void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
|
||||||
{
|
{
|
||||||
anyways.emplace<QLabel>("Show messages from blocked users:");
|
anyways.emplace<QLabel>("Show messages from blocked users:");
|
||||||
|
|
||||||
auto combo = anyways.emplace<QComboBox>().getElement();
|
auto *combo = anyways.emplace<QComboBox>().getElement();
|
||||||
combo->addItems(
|
combo->addItems(
|
||||||
{"Never", "If you are Moderator", "If you are Broadcaster"});
|
{"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),
|
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
[&setting](int index) {
|
[&setting](int index) {
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
|
{
|
||||||
setting = index;
|
setting = index;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
anyways->addStretch(1);
|
anyways->addStretch(1);
|
||||||
|
|
|
@ -43,7 +43,9 @@ QString formatSize(qint64 size)
|
||||||
for (i = 0; i < units.size() - 1; i++)
|
for (i = 0; i < units.size() - 1; i++)
|
||||||
{
|
{
|
||||||
if (outputSize < 1024)
|
if (outputSize < 1024)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
outputSize = outputSize / 1024;
|
outputSize = outputSize / 1024;
|
||||||
}
|
}
|
||||||
return QString("%0 %1").arg(outputSize, 0, 'f', 2).arg(units[i]);
|
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 valueChanged = [=, this] {
|
||||||
const auto index = QObject::sender()->objectName().toInt();
|
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 duration = line->text().toInt();
|
||||||
const auto unit = this->unitInputs_[index]->currentText();
|
const auto unit = this->unitInputs_[index]->currentText();
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,15 @@ void InputCompletionItem::action()
|
||||||
if (this->action_)
|
if (this->action_)
|
||||||
{
|
{
|
||||||
if (this->emote_)
|
if (this->emote_)
|
||||||
|
{
|
||||||
this->action_(this->emote_->name.string);
|
this->action_(this->emote_->name.string);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
this->action_(this->text_);
|
this->action_(this->text_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InputCompletionItem::paint(QPainter *painter, const QRect &rect) const
|
void InputCompletionItem::paint(QPainter *painter, const QRect &rect) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -199,11 +199,11 @@ namespace {
|
||||||
parent);
|
parent);
|
||||||
window->setWindowTitle("Chatterino - " + title);
|
window->setWindowTitle("Chatterino - " + title);
|
||||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
auto layout = new QVBoxLayout();
|
auto *layout = new QVBoxLayout();
|
||||||
layout->addWidget(new QLabel(description));
|
layout->addWidget(new QLabel(description));
|
||||||
auto label = new QLabel(window);
|
auto *label = new QLabel(window);
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
auto movie = new QMovie(label);
|
auto *movie = new QMovie(label);
|
||||||
movie->setFileName(source);
|
movie->setFileName(source);
|
||||||
label->setMovie(movie);
|
label->setMovie(movie);
|
||||||
movie->start();
|
movie->start();
|
||||||
|
@ -805,7 +805,7 @@ void Split::refreshModerationMode()
|
||||||
|
|
||||||
void Split::openChannelInBrowserPlayer(ChannelPtr channel)
|
void Split::openChannelInBrowserPlayer(ChannelPtr channel)
|
||||||
{
|
{
|
||||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl(
|
QDesktopServices::openUrl(
|
||||||
"https://player.twitch.tv/?parent=twitch.tv&channel=" +
|
"https://player.twitch.tv/?parent=twitch.tv&channel=" +
|
||||||
|
@ -918,7 +918,7 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dialog = new SelectChannelDialog(this);
|
auto *dialog = new SelectChannelDialog(this);
|
||||||
if (!empty)
|
if (!empty)
|
||||||
{
|
{
|
||||||
dialog->setSelectedChannel(this->getIndirectChannel());
|
dialog->setSelectedChannel(this->getIndirectChannel());
|
||||||
|
@ -1065,7 +1065,7 @@ void Split::explainSplitting()
|
||||||
|
|
||||||
void Split::popup()
|
void Split::popup()
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
Window &window = app->windows->createWindow(WindowType::Popup);
|
Window &window = app->windows->createWindow(WindowType::Popup);
|
||||||
|
|
||||||
Split *split = new Split(static_cast<SplitContainer *>(
|
Split *split = new Split(static_cast<SplitContainer *>(
|
||||||
|
@ -1088,7 +1088,7 @@ void Split::openInBrowser()
|
||||||
{
|
{
|
||||||
auto channel = this->getChannel();
|
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/" +
|
QDesktopServices::openUrl("https://twitch.tv/" +
|
||||||
twitchChannel->getName());
|
twitchChannel->getName());
|
||||||
|
@ -1111,7 +1111,7 @@ void Split::openModViewInBrowser()
|
||||||
{
|
{
|
||||||
auto channel = this->getChannel();
|
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/" +
|
QDesktopServices::openUrl("https://twitch.tv/moderator/" +
|
||||||
twitchChannel->getName());
|
twitchChannel->getName());
|
||||||
|
@ -1131,9 +1131,9 @@ void Split::openWithCustomScheme()
|
||||||
return;
|
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")
|
QDesktopServices::openUrl(QString("%1https://twitch.tv/%2")
|
||||||
.arg(scheme)
|
.arg(scheme)
|
||||||
|
@ -1422,7 +1422,7 @@ void Split::openSubPage()
|
||||||
{
|
{
|
||||||
ChannelPtr channel = this->getChannel();
|
ChannelPtr channel = this->getChannel();
|
||||||
|
|
||||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl(twitchChannel->subscriptionUrl());
|
QDesktopServices::openUrl(twitchChannel->subscriptionUrl());
|
||||||
}
|
}
|
||||||
|
@ -1466,8 +1466,8 @@ void Split::showSearch(bool singleChannel)
|
||||||
auto ¬ebook = getApp()->windows->getMainWindow().getNotebook();
|
auto ¬ebook = getApp()->windows->getMainWindow().getNotebook();
|
||||||
for (int i = 0; i < notebook.getPageCount(); ++i)
|
for (int i = 0; i < notebook.getPageCount(); ++i)
|
||||||
{
|
{
|
||||||
auto container = dynamic_cast<SplitContainer *>(notebook.getPageAt(i));
|
auto *container = dynamic_cast<SplitContainer *>(notebook.getPageAt(i));
|
||||||
for (auto split : container->getSplits())
|
for (auto *split : container->getSplits())
|
||||||
{
|
{
|
||||||
if (split->channel_.getType() != Channel::Type::TwitchAutomod)
|
if (split->channel_.getType() != Channel::Type::TwitchAutomod)
|
||||||
{
|
{
|
||||||
|
@ -1484,7 +1484,7 @@ void Split::reloadChannelAndSubscriberEmotes()
|
||||||
auto channel = this->getChannel();
|
auto channel = this->getChannel();
|
||||||
getApp()->accounts->twitch.getCurrent()->loadEmotes(channel);
|
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->refreshBTTVChannelEmotes(true);
|
||||||
twitchChannel->refreshFFZChannelEmotes(true);
|
twitchChannel->refreshFFZChannelEmotes(true);
|
||||||
|
@ -1551,8 +1551,8 @@ void Split::drag()
|
||||||
startDraggingSplit();
|
startDraggingSplit();
|
||||||
|
|
||||||
auto originalLocation = container->releaseSplit(this);
|
auto originalLocation = container->releaseSplit(this);
|
||||||
auto drag = new QDrag(this);
|
auto *drag = new QDrag(this);
|
||||||
auto mimeData = new QMimeData;
|
auto *mimeData = new QMimeData;
|
||||||
|
|
||||||
mimeData->setData("chatterino/split", "xD");
|
mimeData->setData("chatterino/split", "xD");
|
||||||
drag->setMimeData(mimeData);
|
drag->setMimeData(mimeData);
|
||||||
|
|
|
@ -50,13 +50,13 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
|
||||||
this->installEventFilter(this);
|
this->installEventFilter(this);
|
||||||
this->initLayout();
|
this->initLayout();
|
||||||
|
|
||||||
auto completer =
|
auto *completer =
|
||||||
new QCompleter(&this->split_->getChannel()->completionModel);
|
new QCompleter(&this->split_->getChannel()->completionModel);
|
||||||
this->ui_.textEdit->setCompleter(completer);
|
this->ui_.textEdit->setCompleter(completer);
|
||||||
|
|
||||||
this->signalHolder_.managedConnect(this->split_->channelChanged, [this] {
|
this->signalHolder_.managedConnect(this->split_->channelChanged, [this] {
|
||||||
auto channel = this->split_->getChannel();
|
auto channel = this->split_->getChannel();
|
||||||
auto completer = new QCompleter(&channel->completionModel);
|
auto *completer = new QCompleter(&channel->completionModel);
|
||||||
this->ui_.textEdit->setCompleter(completer);
|
this->ui_.textEdit->setCompleter(completer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
|
||||||
|
|
||||||
void SplitInput::initLayout()
|
void SplitInput::initLayout()
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
LayoutCreator<SplitInput> layoutCreator(this);
|
LayoutCreator<SplitInput> layoutCreator(this);
|
||||||
|
|
||||||
auto layout =
|
auto layout =
|
||||||
|
@ -202,7 +202,7 @@ void SplitInput::initLayout()
|
||||||
|
|
||||||
void SplitInput::scaleChangedEvent(float scale)
|
void SplitInput::scaleChangedEvent(float scale)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
// update the icon size of the buttons
|
// update the icon size of the buttons
|
||||||
this->updateEmoteButton();
|
this->updateEmoteButton();
|
||||||
this->updateCancelReplyButton();
|
this->updateCancelReplyButton();
|
||||||
|
@ -328,7 +328,9 @@ QString SplitInput::handleSendMessage(std::vector<QString> &arguments)
|
||||||
{
|
{
|
||||||
auto c = this->split_->getChannel();
|
auto c = this->split_->getChannel();
|
||||||
if (c == nullptr)
|
if (c == nullptr)
|
||||||
|
{
|
||||||
return "";
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
if (!c->isTwitchChannel() || this->replyThread_ == nullptr)
|
if (!c->isTwitchChannel() || this->replyThread_ == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -347,7 +349,7 @@ QString SplitInput::handleSendMessage(std::vector<QString> &arguments)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Reply to message
|
// Reply to message
|
||||||
auto tc = dynamic_cast<TwitchChannel *>(c.get());
|
auto *tc = dynamic_cast<TwitchChannel *>(c.get());
|
||||||
if (!tc)
|
if (!tc)
|
||||||
{
|
{
|
||||||
// this should not fail
|
// this should not fail
|
||||||
|
@ -635,7 +637,7 @@ bool SplitInput::eventFilter(QObject *obj, QEvent *event)
|
||||||
if (event->type() == QEvent::ShortcutOverride ||
|
if (event->type() == QEvent::ShortcutOverride ||
|
||||||
event->type() == QEvent::Shortcut)
|
event->type() == QEvent::Shortcut)
|
||||||
{
|
{
|
||||||
if (auto popup = this->inputCompletionPopup_.data())
|
if (auto *popup = this->inputCompletionPopup_.data())
|
||||||
{
|
{
|
||||||
if (popup->isVisible())
|
if (popup->isVisible())
|
||||||
{
|
{
|
||||||
|
@ -906,7 +908,7 @@ bool SplitInput::isHidden() const
|
||||||
|
|
||||||
void SplitInput::editTextChanged()
|
void SplitInput::editTextChanged()
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
// set textLengthLabel value
|
// set textLengthLabel value
|
||||||
QString text = this->ui_.textEdit->toPlainText();
|
QString text = this->ui_.textEdit->toPlainText();
|
||||||
|
|
Loading…
Reference in a new issue