Chore: Proper Lambda Formatting (#2167)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Leon Richardt 2020-11-08 12:02:19 +01:00 committed by GitHub
parent fbd5df53d8
commit 0eed45ae67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 712 additions and 415 deletions

View file

@ -4,6 +4,7 @@ AccessModifierOffset: -4
AlignEscapedNewlinesLeft: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakBeforeMultilineStrings: false

View file

@ -61,8 +61,9 @@ Application::Application(Settings &_settings, Paths &_paths)
{
this->instance = this;
this->fonts->fontChanged.connect(
[this]() { this->windows->layoutChannelViews(); });
this->fonts->fontChanged.connect([this]() {
this->windows->layoutChannelViews();
});
this->twitch.server = this->twitch2;
this->twitch.pubsub = this->twitch2->pubsub;
@ -137,14 +138,20 @@ int Application::run(QApplication &qtApp)
this->windows->getMainWindow().show();
getSettings()->betaUpdates.connect(
[] { Updates::instance().checkForUpdates(); }, false);
getSettings()->moderationActions.delayedItemsChanged.connect(
[this] { this->windows->forceLayoutChannelViews(); });
[] {
Updates::instance().checkForUpdates();
},
false);
getSettings()->moderationActions.delayedItemsChanged.connect([this] {
this->windows->forceLayoutChannelViews();
});
getSettings()->highlightedMessages.delayedItemsChanged.connect(
[this] { this->windows->forceLayoutChannelViews(); });
getSettings()->highlightedUsers.delayedItemsChanged.connect(
[this] { this->windows->forceLayoutChannelViews(); });
getSettings()->highlightedMessages.delayedItemsChanged.connect([this] {
this->windows->forceLayoutChannelViews();
});
getSettings()->highlightedUsers.delayedItemsChanged.connect([this] {
this->windows->forceLayoutChannelViews();
});
return qtApp.exec();
}
@ -184,7 +191,9 @@ void Application::initPubsub()
QString("%1 cleared the chat").arg(action.source.name);
auto msg = makeSystemMessage(text);
postToThread([chan, msg] { chan->addMessage(msg); });
postToThread([chan, msg] {
chan->addMessage(msg);
});
});
this->twitch.pubsub->signals_.moderation.modeChanged.connect(
@ -197,7 +206,7 @@ void Application::initPubsub()
}
QString text =
QString("%1 turned %2 %3 mode") //
QString("%1 turned %2 %3 mode")
.arg(action.source.name)
.arg(action.state == ModeChangedAction::State::On ? "on"
: "off")
@ -210,7 +219,9 @@ void Application::initPubsub()
}
auto msg = makeSystemMessage(text);
postToThread([chan, msg] { chan->addMessage(msg); });
postToThread([chan, msg] {
chan->addMessage(msg);
});
});
this->twitch.pubsub->signals_.moderation.moderationStateChanged.connect(
@ -236,7 +247,9 @@ void Application::initPubsub()
}
auto msg = makeSystemMessage(text);
postToThread([chan, msg] { chan->addMessage(msg); });
postToThread([chan, msg] {
chan->addMessage(msg);
});
});
this->twitch.pubsub->signals_.moderation.userBanned.connect(
@ -269,7 +282,9 @@ void Application::initPubsub()
auto msg = MessageBuilder(action).release();
postToThread([chan, msg] { chan->addMessage(msg); });
postToThread([chan, msg] {
chan->addMessage(msg);
});
});
this->twitch.pubsub->signals_.moderation.automodMessage.connect(
@ -301,7 +316,9 @@ void Application::initPubsub()
auto msg = MessageBuilder(action).release();
postToThread([chan, msg] { chan->addMessage(msg); });
postToThread([chan, msg] {
chan->addMessage(msg);
});
chan->deleteMessage(msg->id);
});
@ -334,7 +351,7 @@ void Application::initPubsub()
// moderation topics this->twitch.pubsub->UnlistenAllAuthedTopics();
this->twitch.server->pubsub->listenToWhispers(
this->accounts->twitch.getCurrent()); //
this->accounts->twitch.getCurrent());
};
this->accounts->twitch.currentUserChanged.connect(RequestModerationActions);

View file

@ -164,8 +164,9 @@ void runGui(QApplication &a, Paths &paths, Settings &settings)
initResources();
initSignalHandler();
settings.restartOnCrash.connect(
[](const bool &value) { restartOnSignal = value; });
settings.restartOnCrash.connect([](const bool &value) {
restartOnSignal = value;
});
auto thread = std::thread([dir = paths.miscDirectory] {
{
@ -186,7 +187,9 @@ void runGui(QApplication &a, Paths &paths, Settings &settings)
// Clear the cache 1 minute after start.
QTimer::singleShot(60 * 1000, [cachePath = paths.cacheDirectory()] {
QtConcurrent::run([cachePath]() { clearCache(cachePath); });
QtConcurrent::run([cachePath]() {
clearCache(cachePath);
});
});
chatterino::NetworkManager::init();

View file

@ -130,17 +130,17 @@ void Channel::addOrReplaceTimeout(MessagePtr message)
}
if (s->flags.has(MessageFlag::Timeout) &&
s->timeoutUser == message->timeoutUser) //
s->timeoutUser == message->timeoutUser)
{
if (message->flags.has(MessageFlag::PubSub) &&
!s->flags.has(MessageFlag::PubSub)) //
!s->flags.has(MessageFlag::PubSub))
{
this->replaceMessage(s, message);
addMessage = false;
break;
}
if (!message->flags.has(MessageFlag::PubSub) &&
s->flags.has(MessageFlag::PubSub)) //
s->flags.has(MessageFlag::PubSub))
{
addMessage = timeoutStackStyle == TimeoutStackStyle::DontStack;
break;

View file

@ -113,7 +113,9 @@ namespace {
job->setKey(set.name);
job->setTextData(set.credential);
QObject::connect(job, &QKeychain::Job::finished, qApp,
[](auto) { runNextJob(); });
[](auto) {
runNextJob();
});
job->start();
}
else // erase job
@ -123,7 +125,9 @@ namespace {
job->setAutoDelete(true);
job->setKey(erase.name);
QObject::connect(job, &QKeychain::Job::finished, qApp,
[](auto) { runNextJob(); });
[](auto) {
runNextJob();
});
job->start();
}

View file

@ -180,9 +180,10 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
if (data->onSuccess_)
{
if (data->executeConcurrently_)
QtConcurrent::run(
[onSuccess = std::move(data->onSuccess_),
result = std::move(result)] { onSuccess(result); });
QtConcurrent::run([onSuccess = std::move(data->onSuccess_),
result = std::move(result)] {
onSuccess(result);
});
else
data->onSuccess_(result);
}

View file

@ -28,8 +28,9 @@ public:
SignalVector()
: readOnly_(new std::vector<T>())
{
QObject::connect(&this->itemsChangedTimer_, &QTimer::timeout,
[this] { this->delayedItemsChanged.invoke(); });
QObject::connect(&this->itemsChangedTimer_, &QTimer::timeout, [this] {
this->delayedItemsChanged.invoke();
});
this->itemsChangedTimer_.setInterval(100);
this->itemsChangedTimer_.setSingleShot(true);
}

View file

@ -115,8 +115,11 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
}
}
} visitor;
boost::apply_visitor([&b](auto &&arg) { visitor(arg, b); },
variant);
boost::apply_visitor(
[&b](auto &&arg) {
visitor(arg, b);
},
variant);
} // emoji/text
}
}
@ -211,7 +214,7 @@ void CommandController::initialize(Settings &, Paths &paths)
// Update the setting when the vector of commands has been updated (most
// likely from the settings dialog)
this->items_.delayedItemsChanged.connect([this] { //
this->items_.delayedItemsChanged.connect([this] {
this->commandsSetting_->setValue(this->items_.raw());
});

View file

@ -11,8 +11,9 @@ public:
FilterSet()
{
this->listener_ =
getCSettings().filterRecords.delayedItemsChanged.connect(
[this] { this->reloadFilters(); });
getCSettings().filterRecords.delayedItemsChanged.connect([this] {
this->reloadFilters();
});
}
FilterSet(const QList<QUuid> &filterIds)
@ -25,8 +26,9 @@ public:
}
this->listener_ =
getCSettings().filterRecords.delayedItemsChanged.connect(
[this] { this->reloadFilters(); });
getCSettings().filterRecords.delayedItemsChanged.connect([this] {
this->reloadFilters();
});
}
~FilterSet()

View file

@ -29,7 +29,7 @@ void NotificationController::initialize(Settings &settings, Paths &paths)
this->channelMap[Platform::Twitch].append(channelName);
}
this->channelMap[Platform::Twitch].delayedItemsChanged.connect([this] { //
this->channelMap[Platform::Twitch].delayedItemsChanged.connect([this] {
this->twitchSetting_.setValue(this->channelMap[Platform::Twitch].raw());
});
/*
@ -37,7 +37,7 @@ void NotificationController::initialize(Settings &settings, Paths &paths)
this->channelMap[Platform::Mixer].appendItem(channelName);
}
this->channelMap[Platform::Mixer].delayedItemsChanged.connect([this] { //
this->channelMap[Platform::Mixer].delayedItemsChanged.connect([this] {
this->mixerSetting_.setValue(
this->channelMap[Platform::Mixer]);
});*/
@ -46,8 +46,9 @@ void NotificationController::initialize(Settings &settings, Paths &paths)
this->fetchFakeChannels();
QObject::connect(this->liveStatusTimer_, &QTimer::timeout,
[=] { this->fetchFakeChannels(); });
QObject::connect(this->liveStatusTimer_, &QTimer::timeout, [=] {
this->fetchFakeChannels();
});
this->liveStatusTimer_->start(60 * 1000);
}

View file

@ -38,13 +38,16 @@ namespace detail {
DebugCount::increase("animated images");
this->gifTimerConnection_ =
getApp()->emotes->gifTimer.signal.connect(
[this] { this->advance(); });
getApp()->emotes->gifTimer.signal.connect([this] {
this->advance();
});
}
auto totalLength = std::accumulate(
this->items_.begin(), this->items_.end(), 0UL,
[](auto init, auto &&frame) { return init + frame.duration; });
auto totalLength =
std::accumulate(this->items_.begin(), this->items_.end(), 0UL,
[](auto init, auto &&frame) {
return init + frame.duration;
});
if (totalLength == 0)
{
@ -222,7 +225,9 @@ Image::~Image()
// run destructor of Frames in gui thread
if (!isGuiThread())
{
postToThread([frames = this->frames_.release()]() { delete frames; });
postToThread([frames = this->frames_.release()]() {
delete frames;
});
}
}

View file

@ -352,7 +352,7 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
// QChar::isHighSurrogate(text[0].unicode()) ? 2 : 1
for (int i = 0; i < textLength; i++) //
for (int i = 0; i < textLength; i++)
{
auto isSurrogate = text.size() > i + 1 &&
QChar::isHighSurrogate(text[i].unicode());
@ -360,7 +360,7 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
auto charWidth = isSurrogate ? metrics.width(text.mid(i, 2))
: metrics.width(text[i]);
if (!container.fitsInLine(width + charWidth)) //
if (!container.fitsInLine(width + charWidth))
{
container.addElementNoLineBreak(getTextLayoutElement(
text.mid(wordStart, i - wordStart), width, false));
@ -621,7 +621,7 @@ void IrcTextElement::addToContainer(MessageLayoutContainer &container,
// QChar::isHighSurrogate(text[0].unicode()) ? 2 : 1
// XXX(pajlada): NOT TESTED
for (int i = 0; i < textLength; i++) //
for (int i = 0; i < textLength; i++)
{
auto isSurrogate = text.size() > i + 1 &&
QChar::isHighSurrogate(text[i].unicode());

View file

@ -356,7 +356,7 @@ void SharedMessageBuilder::appendChannelName()
Link link(Link::Url, this->channel->getName() + "\n" + this->message().id);
this->emplace<TextElement>(channelName, MessageElementFlag::ChannelName,
MessageColor::System) //
MessageColor::System)
->setLink(link);
}

View file

@ -119,7 +119,7 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags flags)
if (this->flags.has(MessageLayoutFlag::Expanded) ||
(flags.has(MessageElementFlag::ModeratorTools) &&
!this->message_->flags.has(MessageFlag::Disabled))) //
!this->message_->flags.has(MessageFlag::Disabled)))
{
messageFlags.unset(MessageFlag::Collapsed);
}

View file

@ -390,7 +390,7 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
// ends in same line
if (selection.selectionMax.messageIndex == messageIndex &&
line.endCharIndex >
/*=*/selection.selectionMax.charIndex) //
/*=*/selection.selectionMax.charIndex)
{
returnAfter = true;
index = line.startCharIndex;

View file

@ -217,7 +217,7 @@ void TextLayoutElement::listenToLinkChanges()
.linkChanged.connect([this]() {
// log("Old link: {}", this->getCreator().getLink().value);
// log("This link: {}", this->getLink().value);
this->setLink(this->getCreator().getLink()); //
this->setLink(this->getCreator().getLink());
}));
}

View file

@ -22,36 +22,47 @@ AbstractIrcServer::AbstractIrcServer()
this->writeConnection_->moveToThread(
QCoreApplication::instance()->thread());
QObject::connect(
this->writeConnection_.get(), &Communi::IrcConnection::messageReceived,
this, [this](auto msg) { this->writeConnectionMessageReceived(msg); });
QObject::connect(
this->writeConnection_.get(), &Communi::IrcConnection::connected, this,
[this] { this->onWriteConnected(this->writeConnection_.get()); });
QObject::connect(this->writeConnection_.get(),
&Communi::IrcConnection::messageReceived, this,
[this](auto msg) {
this->writeConnectionMessageReceived(msg);
});
QObject::connect(this->writeConnection_.get(),
&Communi::IrcConnection::connected, this, [this] {
this->onWriteConnected(this->writeConnection_.get());
});
// Listen to read connection message signals
this->readConnection_.reset(new IrcConnection);
this->readConnection_->moveToThread(QCoreApplication::instance()->thread());
QObject::connect(
this->readConnection_.get(), &Communi::IrcConnection::messageReceived,
this, [this](auto msg) { this->readConnectionMessageReceived(msg); });
QObject::connect(this->readConnection_.get(),
&Communi::IrcConnection::messageReceived, this,
[this](auto msg) {
this->readConnectionMessageReceived(msg);
});
QObject::connect(this->readConnection_.get(),
&Communi::IrcConnection::privateMessageReceived, this,
[this](auto msg) { this->privateMessageReceived(msg); });
QObject::connect(
this->readConnection_.get(), &Communi::IrcConnection::connected, this,
[this] { this->onReadConnected(this->readConnection_.get()); });
[this](auto msg) {
this->privateMessageReceived(msg);
});
QObject::connect(this->readConnection_.get(),
&Communi::IrcConnection::disconnected, this,
[this] { this->onDisconnected(); });
&Communi::IrcConnection::connected, this, [this] {
this->onReadConnected(this->readConnection_.get());
});
QObject::connect(this->readConnection_.get(),
&Communi::IrcConnection::socketError, this,
[this] { this->onSocketError(); });
&Communi::IrcConnection::disconnected, this, [this] {
this->onDisconnected();
});
QObject::connect(this->readConnection_.get(),
&Communi::IrcConnection::socketError, this, [this] {
this->onSocketError();
});
// listen to reconnect request
this->readConnection_->reconnectRequested.connect(
[this] { this->connect(); });
this->readConnection_->reconnectRequested.connect([this] {
this->connect();
});
// this->writeConnection->reconnectRequested.connect([this] {
// this->connect(); });
this->reconnectTimer_.setInterval(RECONNECT_BASE_INTERVAL);

View file

@ -137,7 +137,9 @@ Irc::Irc()
}
});
this->connections.delayedItemsChanged.connect([this] { this->save(); });
this->connections.delayedItemsChanged.connect([this] {
this->save();
});
}
QAbstractTableModel *Irc::newConnectionModel(QObject *parent)

View file

@ -33,9 +33,13 @@ Outcome invokeIrcCommand(const QString &commandName, const QString &allParams,
// CUSTOM COMMANDS
auto params = allParams.split(' ');
auto paramsAfter = [&](int i) { return params.mid(i + 1).join(' '); };
auto paramsAfter = [&](int i) {
return params.mid(i + 1).join(' ');
};
auto sendRaw = [&](QString str) { channel.server()->sendRawMessage(str); };
auto sendRaw = [&](QString str) {
channel.server()->sendRawMessage(str);
};
if (cmd == "msg")
{

View file

@ -45,8 +45,9 @@ IrcConnection::IrcConnection(QObject *parent)
}
});
QObject::connect(this, &Communi::IrcConnection::connected, this,
[this] { this->waitingForPong_ = false; });
QObject::connect(this, &Communi::IrcConnection::connected, this, [this] {
this->waitingForPong_ = false;
});
QObject::connect(this, &Communi::IrcConnection::pongMessageReceived,
[this](Communi::IrcPongMessage *message) {

View file

@ -702,7 +702,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
// channels
app->twitch.server->forEachChannelAndSpecialChannels(
[msg](const auto &c) {
c->addMessage(msg); //
c->addMessage(msg);
});
return;

View file

@ -166,7 +166,7 @@ namespace detail {
return;
}
self->ping(); //
self->ping();
});
}

View file

@ -153,7 +153,7 @@ void TwitchAccount::ignore(
{
const auto onUserFetched = [this, targetName,
onFinished](const auto &user) {
this->ignoreByID(user.id, targetName, onFinished); //
this->ignoreByID(user.id, targetName, onFinished);
};
const auto onUserFetchFailed = [] {};
@ -230,7 +230,7 @@ void TwitchAccount::unignore(
{
const auto onUserFetched = [this, targetName,
onFinished](const auto &user) {
this->unignoreByID(user.id, targetName, onFinished); //
this->unignoreByID(user.id, targetName, onFinished);
};
const auto onUserFetchFailed = [] {};

View file

@ -17,7 +17,7 @@ TwitchAccountManager::TwitchAccountManager()
currentUser->loadIgnores();
});
this->accounts.itemRemoved.connect([this](const auto &acc) { //
this->accounts.itemRemoved.connect([this](const auto &acc) {
this->removeUser(acc.item.get());
});
}

View file

@ -156,14 +156,18 @@ TwitchChannel::TwitchChannel(const QString &name,
}
});
this->managedConnect(getApp()->accounts->twitch.currentUserChanged,
[=] { this->setMod(false); });
this->managedConnect(getApp()->accounts->twitch.currentUserChanged, [=] {
this->setMod(false);
});
// pubsub
this->managedConnect(getApp()->accounts->twitch.currentUserChanged,
[=] { this->refreshPubsub(); });
this->managedConnect(getApp()->accounts->twitch.currentUserChanged, [=] {
this->refreshPubsub();
});
this->refreshPubsub();
this->userStateChanged.connect([this] { this->refreshPubsub(); });
this->userStateChanged.connect([this] {
this->refreshPubsub();
});
// room id loaded -> refresh live status
this->roomIdChanged.connect([this]() {
@ -177,12 +181,14 @@ TwitchChannel::TwitchChannel(const QString &name,
});
// timers
QObject::connect(&this->chattersListTimer_, &QTimer::timeout,
[=] { this->refreshChatters(); });
QObject::connect(&this->chattersListTimer_, &QTimer::timeout, [=] {
this->refreshChatters();
});
this->chattersListTimer_.start(5 * 60 * 1000);
QObject::connect(&this->liveStatusTimer_, &QTimer::timeout,
[=] { this->refreshLiveStatus(); });
QObject::connect(&this->liveStatusTimer_, &QTimer::timeout, [=] {
this->refreshLiveStatus();
});
this->liveStatusTimer_.start(60 * 1000);
// debugging

View file

@ -38,8 +38,11 @@ TwitchIrcServer::TwitchIrcServer()
void TwitchIrcServer::initialize(Settings &settings, Paths &paths)
{
getApp()->accounts->twitch.currentUserChanged.connect(
[this]() { postToThread([this] { this->connect(); }); });
getApp()->accounts->twitch.currentUserChanged.connect([this]() {
postToThread([this] {
this->connect();
});
});
this->twitchBadges.loadTwitchBadges();
this->bttv.loadEmotes();

View file

@ -295,7 +295,7 @@ MessagePtr TwitchMessageBuilder::build()
std::sort(twitchEmotes.begin(), twitchEmotes.end(),
[](const auto &a, const auto &b) {
return a.start < b.start; //
return a.start < b.start;
});
twitchEmotes.erase(std::unique(twitchEmotes.begin(), twitchEmotes.end(),
[](const auto &first, const auto &second) {
@ -399,7 +399,10 @@ void TwitchMessageBuilder::addWords(
for (auto &variant : getApp()->emotes->emojis.parse(preText))
{
boost::apply_visitor(
[&](auto &&arg) { this->addTextOrEmoji(arg); }, variant);
[&](auto &&arg) {
this->addTextOrEmoji(arg);
},
variant);
}
cursor += preText.size();
@ -415,8 +418,11 @@ void TwitchMessageBuilder::addWords(
// split words
for (auto &variant : getApp()->emotes->emojis.parse(word))
{
boost::apply_visitor([&](auto &&arg) { this->addTextOrEmoji(arg); },
variant);
boost::apply_visitor(
[&](auto &&arg) {
this->addTextOrEmoji(arg);
},
variant);
}
cursor += word.size() + 1;

View file

@ -11,8 +11,9 @@ Emotes::Emotes()
void Emotes::initialize(Settings &settings, Paths &paths)
{
getApp()->accounts->twitch.currentUserChanged.connect(
[] { getApp()->accounts->twitch.getCurrent()->loadEmotes(); });
getApp()->accounts->twitch.currentUserChanged.connect([] {
getApp()->accounts->twitch.getCurrent()->loadEmotes();
});
this->emojis.load();

View file

@ -44,7 +44,7 @@ QString Paths::cacheDirectory()
QStringSetting cachePathSetting("/cache/path");
cachePathSetting.connect([](const auto &newPath, auto) {
QDir().mkpath(newPath); //
QDir().mkpath(newPath);
});
return cachePathSetting;

View file

@ -125,7 +125,10 @@ Settings::Settings(const QString &settingsDirectory)
#ifdef USEWINSDK
this->autorun = isRegisteredForStartup();
this->autorun.connect(
[](bool autorun) { setRegisteredForStartup(autorun); }, false);
[](bool autorun) {
setRegisteredForStartup(autorun);
},
false);
#endif
}

View file

@ -13,8 +13,16 @@ Theme::Theme()
{
this->update();
this->themeName.connectSimple([this](auto) { this->update(); }, false);
this->themeHue.connectSimple([this](auto) { this->update(); }, false);
this->themeName.connectSimple(
[this](auto) {
this->update();
},
false);
this->themeHue.connectSimple(
[this](auto) {
this->update();
},
false);
}
// hue: theme color (0 - 1)
@ -60,7 +68,7 @@ void Theme::actuallyUpdate(double hue, double multiplier)
this->splits.input.styleSheet =
"background:" + this->splits.input.background.name() + ";" +
"border:" + this->tabs.selected.backgrounds.regular.color().name() +
";" + "color:" + this->messages.textColors.regular.name() + ";" + //
";" + "color:" + this->messages.textColors.regular.name() + ";" +
"selection-background-color:" +
(isLight ? "#68B1FF"
: this->tabs.selected.backgrounds.regular.color().name());

View file

@ -362,7 +362,9 @@ void Updates::setStatus_(Status status)
if (this->status_ != status)
{
this->status_ = status;
postToThread([this, status] { this->statusUpdated.invoke(status); });
postToThread([this, status] {
this->statusUpdated.invoke(status);
});
}
}

View file

@ -100,7 +100,7 @@ WindowManager::WindowManager()
this->wordFlagsListener_.addSetting(settings->boldUsernames);
this->wordFlagsListener_.addSetting(settings->lowercaseDomains);
this->wordFlagsListener_.setCB([this] {
this->updateWordTypeMask(); //
this->updateWordTypeMask();
});
this->saveTimer = new QTimer;
@ -108,13 +108,13 @@ WindowManager::WindowManager()
this->saveTimer->setSingleShot(true);
QObject::connect(this->saveTimer, &QTimer::timeout, [] {
getApp()->windows->save(); //
getApp()->windows->save();
});
this->miscUpdateTimer_.start(100);
QObject::connect(&this->miscUpdateTimer_, &QTimer::timeout, [this] {
this->miscUpdate.invoke(); //
this->miscUpdate.invoke();
});
}
@ -289,8 +289,9 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
{
assertInGuiThread();
getApp()->themes->repaintVisibleChatWidgets_.connect(
[this] { this->repaintVisibleChatWidgets(); });
getApp()->themes->repaintVisibleChatWidgets_.connect([this] {
this->repaintVisibleChatWidgets();
});
assert(!this->initialized_);
@ -309,22 +310,29 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
mainWindow_->getNotebook().addPage(true);
}
settings.timestampFormat.connect(
[this](auto, auto) { this->layoutChannelViews(); });
settings.timestampFormat.connect([this](auto, auto) {
this->layoutChannelViews();
});
settings.emoteScale.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
settings.emoteScale.connect([this](auto, auto) {
this->forceLayoutChannelViews();
});
settings.timestampFormat.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
settings.alternateMessages.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
settings.separateMessages.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
settings.collpseMessagesMinLines.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
settings.enableRedeemedHighlight.connect(
[this](auto, auto) { this->forceLayoutChannelViews(); });
settings.timestampFormat.connect([this](auto, auto) {
this->forceLayoutChannelViews();
});
settings.alternateMessages.connect([this](auto, auto) {
this->forceLayoutChannelViews();
});
settings.separateMessages.connect([this](auto, auto) {
this->forceLayoutChannelViews();
});
settings.collpseMessagesMinLines.connect([this](auto, auto) {
this->forceLayoutChannelViews();
});
settings.enableRedeemedHighlight.connect([this](auto, auto) {
this->forceLayoutChannelViews();
});
this->initialized_ = true;
}

View file

@ -58,9 +58,10 @@ void initUpdateButton(Button &button,
updateChange(Updates::instance().getStatus());
signalHolder.managedConnect(
Updates::instance().statusUpdated,
[updateChange](auto status) { updateChange(status); });
signalHolder.managedConnect(Updates::instance().statusUpdated,
[updateChange](auto status) {
updateChange(status);
});
}
} // namespace chatterino

View file

@ -69,7 +69,9 @@ private:
// the cast here should absolutely not be necessary, but gcc still requires it
this->conn_ =
QObject::connect((QObject *)other, &QObject::destroyed, qApp,
[this](QObject *) { this->set(nullptr); },
[this](QObject *) {
this->set(nullptr);
},
Qt::DirectConnection);
}

View file

@ -101,7 +101,7 @@ namespace {
QObject::connect(
p, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
[=](int res) {
p->deleteLater(); //
p->deleteLater();
});
return p;

View file

@ -31,8 +31,7 @@ AccountSwitchPopup::AccountSwitchPopup(QWidget *parent)
vbox->addLayout(hbox);
connect(manageAccountsButton, &QPushButton::clicked, [this]() {
SettingsDialog::showDialog(this,
SettingsDialogPreference::Accounts); //
SettingsDialog::showDialog(this, SettingsDialogPreference::Accounts);
});
this->getLayoutContainer()->setLayout(vbox);

View file

@ -137,7 +137,9 @@ void BaseWidget::childEvent(QChildEvent *event)
{
// find element to be removed
auto it = std::find_if(this->widgets_.begin(), this->widgets_.end(),
[&](auto &&x) { return x == event->child(); });
[&](auto &&x) {
return x == event->child();
});
// remove if found
if (it != this->widgets_.end())

View file

@ -83,15 +83,17 @@ BaseWindow::BaseWindow(FlagsEnum<Flags> _flags, QWidget *parent)
this->updateScale();
createWindowShortcut(this, "CTRL+0",
[] { getSettings()->uiScale.setValue(1); });
createWindowShortcut(this, "CTRL+0", [] {
getSettings()->uiScale.setValue(1);
});
this->resize(300, 150);
#ifdef USEWINSDK
this->useNextBounds_.setSingleShot(true);
QObject::connect(&this->useNextBounds_, &QTimer::timeout, this,
[this]() { this->currentBounds_ = this->nextBounds_; });
QObject::connect(&this->useNextBounds_, &QTimer::timeout, this, [this]() {
this->currentBounds_ = this->nextBounds_;
});
#endif
this->themeChangedEvent();
@ -154,9 +156,10 @@ void BaseWindow::init()
// title
Label *title = new Label;
QObject::connect(
this, &QWidget::windowTitleChanged,
[title](const QString &text) { title->setText(text); });
QObject::connect(this, &QWidget::windowTitleChanged,
[title](const QString &text) {
title->setText(text);
});
QSizePolicy policy(QSizePolicy::Ignored,
QSizePolicy::Preferred);
@ -187,7 +190,9 @@ void BaseWindow::init()
: Qt::WindowMaximized);
});
QObject::connect(_exitButton, &TitleBarButton::leftClicked,
this, [this] { this->close(); });
this, [this] {
this->close();
});
this->ui_.minButton = _minButton;
this->ui_.maxButton = _maxButton;
@ -460,8 +465,9 @@ TitleBarButton *BaseWindow::addTitleBarButton(const TitleBarButtonStyle &style,
this->ui_.titlebarBox->insertWidget(1, button);
button->setButtonStyle(style);
QObject::connect(button, &TitleBarButton::leftClicked, this,
[onClicked] { onClicked(); });
QObject::connect(button, &TitleBarButton::leftClicked, this, [onClicked] {
onClicked();
});
return button;
}
@ -474,8 +480,9 @@ EffectLabel *BaseWindow::addTitleBarLabel(std::function<void()> onClicked)
this->ui_.buttons.push_back(button);
this->ui_.titlebarBox->insertWidget(1, button);
QObject::connect(button, &EffectLabel::leftClicked, this,
[onClicked] { onClicked(); });
QObject::connect(button, &EffectLabel::leftClicked, this, [onClicked] {
onClicked();
});
return button;
}
@ -550,8 +557,9 @@ void BaseWindow::resizeEvent(QResizeEvent *)
::SetWindowPos((HWND)this->winId(), nullptr, 0, 0,
rect.right - rect.left, rect.bottom - rect.top,
SWP_NOMOVE | SWP_NOZORDER);
QTimer::singleShot(10, this,
[this] { this->isResizeFixing_ = false; });
QTimer::singleShot(10, this, [this] {
this->isResizeFixing_ = false;
});
});
}
#endif
@ -579,8 +587,9 @@ void BaseWindow::showEvent(QShowEvent *)
this->moveIntoDesktopRect(this, this->pos());
if (this->frameless_)
{
QTimer::singleShot(
30, this, [this] { this->moveIntoDesktopRect(this, this->pos()); });
QTimer::singleShot(30, this, [this] {
this->moveIntoDesktopRect(this, this->pos());
});
}
}

View file

@ -14,8 +14,9 @@ Label::Label(BaseWidget *parent, QString text, FontStyle style)
, text_(text)
, fontStyle_(style)
{
this->connections_.managedConnect(getFonts()->fontChanged,
[this] { this->updateSize(); });
this->connections_.managedConnect(getFonts()->fontChanged, [this] {
this->updateSize();
});
}
const QString &Label::getText() const

View file

@ -181,14 +181,17 @@ void Notebook::select(QWidget *page)
bool Notebook::containsPage(QWidget *page)
{
return std::any_of(this->items_.begin(), this->items_.end(),
[page](const auto &item) { return item.page == page; });
[page](const auto &item) {
return item.page == page;
});
}
Notebook::Item &Notebook::findItem(QWidget *page)
{
auto it =
std::find_if(this->items_.begin(), this->items_.end(),
[page](const auto &item) { return page == item.page; });
auto it = std::find_if(this->items_.begin(), this->items_.end(),
[page](const auto &item) {
return page == item.page;
});
assert(it != this->items_.end());
return *it;
}
@ -617,7 +620,9 @@ SplitNotebook::SplitNotebook(Window *parent)
: Notebook(parent)
{
this->connect(this->getAddButton(), &NotebookButton::leftClicked, [this]() {
QTimer::singleShot(80, this, [this] { this->addPage(true); });
QTimer::singleShot(80, this, [this] {
this->addPage(true);
});
});
// add custom buttons if they are not in the parent window frame
@ -646,19 +651,24 @@ void SplitNotebook::addCustomButtons()
settingsBtn->setVisible(!getSettings()->hidePreferencesButton.getValue());
getSettings()->hidePreferencesButton.connect(
[settingsBtn](bool hide, auto) { settingsBtn->setVisible(!hide); },
[settingsBtn](bool hide, auto) {
settingsBtn->setVisible(!hide);
},
this->connections_);
settingsBtn->setIcon(NotebookButton::Settings);
QObject::connect(settingsBtn, &NotebookButton::leftClicked,
[this] { getApp()->windows->showSettingsDialog(this); });
QObject::connect(settingsBtn, &NotebookButton::leftClicked, [this] {
getApp()->windows->showSettingsDialog(this);
});
// account
auto userBtn = this->addCustomButton();
userBtn->setVisible(!getSettings()->hideUserButton.getValue());
getSettings()->hideUserButton.connect(
[userBtn](bool hide, auto) { userBtn->setVisible(!hide); },
[userBtn](bool hide, auto) {
userBtn->setVisible(!hide);
},
this->connections_);
userBtn->setIcon(NotebookButton::User);

View file

@ -43,8 +43,9 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
layout->addWidget(displayText_);
this->setLayout(layout);
this->fontChangedConnection_ =
getFonts()->fontChanged.connect([this] { this->updateFont(); });
this->fontChangedConnection_ = getFonts()->fontChanged.connect([this] {
this->updateFont();
});
}
TooltipWidget::~TooltipWidget()

View file

@ -58,8 +58,9 @@ Window::Window(WindowType type)
#endif
this->signalHolder_.managedConnect(
getApp()->accounts->twitch.currentUserChanged,
[this] { this->onAccountSelected(); });
getApp()->accounts->twitch.currentUserChanged, [this] {
this->onAccountSelected();
});
this->onAccountSelected();
if (type == WindowType::Main)
@ -159,7 +160,7 @@ void Window::addCustomTitlebarButtons()
// settings
this->addTitleBarButton(TitleBarButtonStyle::Settings, [this] {
getApp()->windows->showSettingsDialog(this); //
getApp()->windows->showSettingsDialog(this);
});
// updates
@ -293,7 +294,7 @@ void Window::addShortcuts()
/// Initialize program-wide hotkeys
// Open settings
createWindowShortcut(this, "CTRL+P", [this] {
SettingsDialog::showDialog(this); //
SettingsDialog::showDialog(this);
});
// Switch tab
@ -306,17 +307,22 @@ void Window::addShortcuts()
{
char hotkey[7];
std::sprintf(hotkey, "CTRL+%d", i + 1);
const auto openTab = [this, i] { this->notebook_->selectIndex(i); };
const auto openTab = [this, i] {
this->notebook_->selectIndex(i);
};
createWindowShortcut(this, hotkey, openTab);
}
createWindowShortcut(this, "CTRL+9",
[this] { this->notebook_->selectLastTab(); });
createWindowShortcut(this, "CTRL+9", [this] {
this->notebook_->selectLastTab();
});
createWindowShortcut(this, "CTRL+TAB",
[this] { this->notebook_->selectNextTab(); });
createWindowShortcut(this, "CTRL+SHIFT+TAB",
[this] { this->notebook_->selectPreviousTab(); });
createWindowShortcut(this, "CTRL+TAB", [this] {
this->notebook_->selectNextTab();
});
createWindowShortcut(this, "CTRL+SHIFT+TAB", [this] {
this->notebook_->selectPreviousTab();
});
createWindowShortcut(this, "CTRL+N", [this] {
if (auto page = dynamic_cast<SplitContainer *>(
@ -350,12 +356,14 @@ void Window::addShortcuts()
}
// New tab
createWindowShortcut(this, "CTRL+SHIFT+T",
[this] { this->notebook_->addPage(true); });
createWindowShortcut(this, "CTRL+SHIFT+T", [this] {
this->notebook_->addPage(true);
});
// Close tab
createWindowShortcut(this, "CTRL+SHIFT+W",
[this] { this->notebook_->removeCurrentPage(); });
createWindowShortcut(this, "CTRL+SHIFT+W", [this] {
this->notebook_->removeCurrentPage();
});
// Reopen last closed split
createWindowShortcut(this, "CTRL+G", [this] {
@ -402,7 +410,7 @@ void Window::addMenuBar()
QAction *prefs = menu->addAction(QString());
prefs->setMenuRole(QAction::PreferencesRole);
connect(prefs, &QAction::triggered, this, [this] {
SettingsDialog::showDialog(this); //
SettingsDialog::showDialog(this);
});
// Window menu.
@ -410,13 +418,15 @@ void Window::addMenuBar()
QAction *nextTab = windowMenu->addAction(QString("Select next tab"));
nextTab->setShortcuts({QKeySequence("Meta+Tab")});
connect(nextTab, &QAction::triggered, this,
[=] { this->notebook_->selectNextTab(); });
connect(nextTab, &QAction::triggered, this, [=] {
this->notebook_->selectNextTab();
});
QAction *prevTab = windowMenu->addAction(QString("Select previous tab"));
prevTab->setShortcuts({QKeySequence("Meta+Shift+Tab")});
connect(prevTab, &QAction::triggered, this,
[=] { this->notebook_->selectPreviousTab(); });
connect(prevTab, &QAction::triggered, this, [=] {
this->notebook_->selectPreviousTab();
});
}
void Window::onAccountSelected()

View file

@ -103,7 +103,7 @@ ChannelFilterEditorDialog::ValueSpecifier::ValueSpecifier()
this->layout_->addWidget(this->valueInput_, 1);
this->layout_->setContentsMargins(5, 5, 5, 5);
QObject::connect( //
QObject::connect(
this->typeCombo_, QOverload<int>::of(&QComboBox::currentIndexChanged),
[this](int index) {
const auto isNumber = (index == 1);
@ -183,7 +183,7 @@ ChannelFilterEditorDialog::BinaryOperationSpecifier::BinaryOperationSpecifier(
this->layout_->addLayout(this->right_->layout());
this->layout_->setContentsMargins(5, 5, 5, 5);
QObject::connect( //
QObject::connect(
this->opCombo_, QOverload<int>::of(&QComboBox::currentIndexChanged),
[this](int index) {
// disable if set to "(nothing)"

View file

@ -90,11 +90,13 @@ ColorPickerDialog::ColorPickerDialog(const QColor &initial, QWidget *parent)
layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
{
auto *button_ok = buttons->addButton(QDialogButtonBox::Ok);
QObject::connect(button_ok, &QPushButton::clicked,
[=](bool) { this->ok(); });
QObject::connect(button_ok, &QPushButton::clicked, [=](bool) {
this->ok();
});
auto *button_cancel = buttons->addButton(QDialogButtonBox::Cancel);
QObject::connect(button_cancel, &QAbstractButton::clicked,
[=](bool) { this->close(); });
QObject::connect(button_cancel, &QAbstractButton::clicked, [=](bool) {
this->close();
});
}
this->themeChangedEvent();
@ -216,8 +218,9 @@ void ColorPickerDialog::initRecentColors(LayoutCreator<QWidget> &creator)
grid->addWidget(button, rowInd, columnInd);
QObject::connect(button, &QPushButton::clicked,
[=] { this->selectColor(button->color(), false); });
QObject::connect(button, &QPushButton::clicked, [=] {
this->selectColor(button->color(), false);
});
++it;
++ind;
@ -249,8 +252,9 @@ void ColorPickerDialog::initDefaultColors(LayoutCreator<QWidget> &creator)
grid->addWidget(button, rowInd, columnInd);
QObject::connect(button, &QPushButton::clicked,
[=] { this->selectColor(button->color(), false); });
QObject::connect(button, &QPushButton::clicked, [=] {
this->selectColor(button->color(), false);
});
++it;
++ind;

View file

@ -132,7 +132,9 @@ EmotePopup::EmotePopup(QWidget *parent)
layout->addWidget(notebook);
layout->setMargin(0);
auto clicked = [this](const Link &link) { this->linkClicked.invoke(link); };
auto clicked = [this](const Link &link) {
this->linkClicked.invoke(link);
};
auto makeView = [&](QString tabTitle) {
auto view = new ChannelView();
@ -154,9 +156,12 @@ EmotePopup::EmotePopup(QWidget *parent)
this->loadEmojis();
createWindowShortcut(this, "CTRL+Tab", [=] { notebook->selectNextTab(); });
createWindowShortcut(this, "CTRL+Shift+Tab",
[=] { notebook->selectPreviousTab(); });
createWindowShortcut(this, "CTRL+Tab", [=] {
notebook->selectNextTab();
});
createWindowShortcut(this, "CTRL+Shift+Tab", [=] {
notebook->selectPreviousTab();
});
}
void EmotePopup::loadChannel(ChannelPtr _channel)

View file

@ -40,8 +40,9 @@ LastRunCrashDialog::LastRunCrashDialog()
auto *okButton =
buttons->addButton("Ignore", QDialogButtonBox::ButtonRole::NoRole);
QObject::connect(okButton, &QPushButton::clicked,
[this] { this->accept(); });
QObject::connect(okButton, &QPushButton::clicked, [this] {
this->accept();
});
// Updates
// auto updateUpdateLabel = [update]() mutable {

View file

@ -187,14 +187,18 @@ AdvancedLoginWidget::AdvancedLoginWidget()
this->ui_.oauthTokenInput.setEchoMode(QLineEdit::Password);
connect(&this->ui_.userIDInput, &QLineEdit::textChanged,
[=]() { this->refreshButtons(); });
connect(&this->ui_.usernameInput, &QLineEdit::textChanged,
[=]() { this->refreshButtons(); });
connect(&this->ui_.clientIDInput, &QLineEdit::textChanged,
[=]() { this->refreshButtons(); });
connect(&this->ui_.oauthTokenInput, &QLineEdit::textChanged,
[=]() { this->refreshButtons(); });
connect(&this->ui_.userIDInput, &QLineEdit::textChanged, [=]() {
this->refreshButtons();
});
connect(&this->ui_.usernameInput, &QLineEdit::textChanged, [=]() {
this->refreshButtons();
});
connect(&this->ui_.clientIDInput, &QLineEdit::textChanged, [=]() {
this->refreshButtons();
});
connect(&this->ui_.oauthTokenInput, &QLineEdit::textChanged, [=]() {
this->refreshButtons();
});
/// Upper button row
@ -259,7 +263,7 @@ LoginWidget::LoginWidget()
QObject::connect(&this->ui_.buttonBox, &QDialogButtonBox::rejected,
[this]() {
this->close(); //
this->close();
});
this->ui_.mainLayout.addWidget(&this->ui_.buttonBox);

View file

@ -80,9 +80,10 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
whispers_lbl->setWordWrap(true);
whispers_btn->installEventFilter(&this->tabFilter_);
QObject::connect(
whispers_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { whispers_lbl->setVisible(enabled); });
QObject::connect(whispers_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable {
whispers_lbl->setVisible(enabled);
});
// mentions_btn
auto mentions_btn = vbox.emplace<QRadioButton>("Mentions")
@ -95,9 +96,10 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
mentions_lbl->setWordWrap(true);
mentions_btn->installEventFilter(&this->tabFilter_);
QObject::connect(
mentions_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { mentions_lbl->setVisible(enabled); });
QObject::connect(mentions_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable {
mentions_lbl->setVisible(enabled);
});
// watching_btn
auto watching_btn = vbox.emplace<QRadioButton>("Watching")
@ -109,9 +111,10 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
watching_lbl->setWordWrap(true);
watching_btn->installEventFilter(&this->tabFilter_);
QObject::connect(
watching_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable { watching_lbl->setVisible(enabled); });
QObject::connect(watching_btn.getElement(), &QRadioButton::toggled,
[=](bool enabled) mutable {
watching_lbl->setVisible(enabled);
});
vbox->addStretch(1);
@ -204,11 +207,13 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
{
auto *button_ok = buttons->addButton(QDialogButtonBox::Ok);
QObject::connect(button_ok, &QPushButton::clicked,
[=](bool) { this->ok(); });
QObject::connect(button_ok, &QPushButton::clicked, [=](bool) {
this->ok();
});
auto *button_cancel = buttons->addButton(QDialogButtonBox::Cancel);
QObject::connect(button_cancel, &QAbstractButton::clicked,
[=](bool) { this->close(); });
QObject::connect(button_cancel, &QAbstractButton::clicked, [=](bool) {
this->close();
});
}
this->setMinimumSize(300, 310);
@ -217,10 +222,10 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
// Shortcuts
createWindowShortcut(this, "Return", [=] {
this->ok(); //
this->ok();
});
createWindowShortcut(this, "Esc", [=] {
this->close(); //
this->close();
});
// restore ui state
@ -229,10 +234,10 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
{
this->ui_.notebook->selectIndex(getSettings()->lastSelectChannelTab);
createWindowShortcut(this, "Ctrl+Tab", [=] {
this->ui_.notebook->selectNextTab(); //
this->ui_.notebook->selectNextTab();
});
createWindowShortcut(this, "CTRL+Shift+Tab", [=] {
this->ui_.notebook->selectPreviousTab(); //
this->ui_.notebook->selectPreviousTab();
});
}

View file

@ -35,9 +35,10 @@ UpdateDialog::UpdateDialog()
});
this->updateStatusChanged(Updates::instance().getStatus());
this->connections_.managedConnect(
Updates::instance().statusUpdated,
[this](auto status) { this->updateStatusChanged(status); });
this->connections_.managedConnect(Updates::instance().statusUpdated,
[this](auto status) {
this->updateStatusChanged(status);
});
this->setScaleIndependantHeight(150);
this->setScaleIndependantWidth(500);

View file

@ -131,7 +131,9 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent)
this->setAttribute(Qt::WA_DeleteOnClose);
// Close the popup when Escape is pressed
createWindowShortcut(this, "Escape", [this] { this->deleteLater(); });
createWindowShortcut(this, "Escape", [this] {
this->deleteLater();
});
auto layout = LayoutCreator<QWidget>(this->getLayoutContainer())
.setLayoutType<QVBoxLayout>();
@ -213,8 +215,9 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent)
"/viewercard/" + this->userName_);
});
QObject::connect(refresh.getElement(), &Button::leftClicked,
[this] { this->updateLatestMessages(); });
QObject::connect(refresh.getElement(), &Button::leftClicked, [this] {
this->updateLatestMessages();
});
QObject::connect(mod.getElement(), &Button::leftClicked, [this] {
this->channel_->sendMessage("/mod " + this->userName_);
});
@ -367,7 +370,7 @@ void UserInfoPopup::installEvents()
auto currentUser = getApp()->accounts->twitch.getCurrent();
const auto reenableFollowCheckbox = [this] {
this->ui_.follow->setEnabled(true); //
this->ui_.follow->setEnabled(true);
};
if (!this->ui_.follow->isEnabled())
@ -502,7 +505,9 @@ void UserInfoPopup::setData(const QString &name, const ChannelPtr &channel)
this->userStateChanged_.invoke();
this->updateLatestMessages();
QTimer::singleShot(1, this, [this] { this->setStayInScreenRect(true); });
QTimer::singleShot(1, this, [this] {
this->setStayInScreenRect(true);
});
}
void UserInfoPopup::updateLatestMessages()
@ -825,9 +830,10 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
const auto pair =
std::make_pair(Action::Timeout, calculateTimeoutDuration(item));
QObject::connect(
a.getElement(), &EffectLabel2::leftClicked,
[this, pair] { this->buttonClicked.invoke(pair); });
QObject::connect(a.getElement(), &EffectLabel2::leftClicked,
[this, pair] {
this->buttonClicked.invoke(pair);
});
//auto addTimeouts = [&](const QString &title_,
// const std::vector<std::pair<QString, int>> &items) {

View file

@ -72,8 +72,9 @@ void QuickSwitcherPopup::initWidgets()
listView->setModel(&this->switcherModel_);
QObject::connect(listView.getElement(),
&GenericListView::closeRequested, this,
[this] { this->close(); });
&GenericListView::closeRequested, this, [this] {
this->close();
});
this->ui_.searchEdit->installEventFilter(listView.getElement());
}
@ -128,7 +129,9 @@ void QuickSwitcherPopup::updateSuggestions(const QString &text)
* Timeout interval 0 means the call will be delayed until all window events
* have been processed (cf. https://doc.qt.io/qt-5/qtimer.html#interval-prop).
*/
QTimer::singleShot(0, [this] { this->adjustSize(); });
QTimer::singleShot(0, [this] {
this->adjustSize();
});
}
void QuickSwitcherPopup::themeChangedEvent()

View file

@ -119,8 +119,9 @@ void Button::setMenu(std::unique_ptr<QMenu> menu)
new FunctionEventFilter(this, [this](QObject *, QEvent *event) {
if (event->type() == QEvent::Hide)
{
QTimer::singleShot(20, this,
[this] { this->menuVisible_ = false; });
QTimer::singleShot(20, this, [this] {
this->menuVisible_ = false;
});
}
return false;
}));
@ -243,7 +244,9 @@ void Button::mousePressEvent(QMouseEvent *event)
if (this->menu_ && !this->menuVisible_)
{
QTimer::singleShot(80, this, [this] { this->showMenu(); });
QTimer::singleShot(80, this, [this] {
this->showMenu();
});
this->mouseDown_ = false;
this->mouseOver_ = false;
}

View file

@ -71,9 +71,10 @@ namespace {
auto addImageLink = [&](const ImagePtr &image, char scale) {
if (!image->isEmpty())
{
copyMenu->addAction(
QString(scale) + "x link",
[url = image->url()] { crossPlatformCopy(url.string); });
copyMenu->addAction(QString(scale) + "x link",
[url = image->url()] {
crossPlatformCopy(url.string);
});
openMenu->addAction(
QString(scale) + "x link", [url = image->url()] {
QDesktopServices::openUrl(QUrl(url.string));
@ -90,13 +91,14 @@ namespace {
copyMenu->addSeparator();
openMenu->addSeparator();
copyMenu->addAction(
"Copy " + name + " emote link",
[url = emote.homePage] { crossPlatformCopy(url.string); });
openMenu->addAction(
"Open " + name + " emote link", [url = emote.homePage] {
QDesktopServices::openUrl(QUrl(url.string)); //
});
copyMenu->addAction("Copy " + name + " emote link",
[url = emote.homePage] {
crossPlatformCopy(url.string);
});
openMenu->addAction("Open " + name + " emote link",
[url = emote.homePage] {
QDesktopServices::openUrl(QUrl(url.string));
});
};
if (creatorFlags.has(MessageElementFlag::BttvEmote))
@ -134,8 +136,9 @@ ChannelView::ChannelView(BaseWidget *parent)
});
auto shortcut = new QShortcut(QKeySequence::StandardKey::Copy, this);
QObject::connect(shortcut, &QShortcut::activated,
[this] { crossPlatformCopy(this->getSelectedText()); });
QObject::connect(shortcut, &QShortcut::activated, [this] {
crossPlatformCopy(this->getSelectedText());
});
this->clickTimer_ = new QTimer(this);
this->clickTimer_->setSingleShot(true);
@ -181,10 +184,14 @@ void ChannelView::initializeSignals()
}));
getSettings()->showLastMessageIndicator.connect(
[this](auto, auto) { this->update(); }, this->connections_);
[this](auto, auto) {
this->update();
},
this->connections_);
connections_.push_back(getApp()->windows->gifRepaintRequested.connect(
[&] { this->queueUpdate(); }));
connections_.push_back(getApp()->windows->gifRepaintRequested.connect([&] {
this->queueUpdate();
}));
connections_.push_back(
getApp()->windows->layoutRequested.connect([&](Channel *channel) {
@ -195,8 +202,9 @@ void ChannelView::initializeSignals()
}
}));
connections_.push_back(
getApp()->fonts->fontChanged.connect([this] { this->queueLayout(); }));
connections_.push_back(getApp()->fonts->fontChanged.connect([this] {
this->queueLayout();
}));
}
bool ChannelView::pausable() const
@ -272,7 +280,9 @@ void ChannelView::updatePauses()
this->queueLayout();
}
else if (std::any_of(this->pauses_.begin(), this->pauses_.end(),
[](auto &&value) { return !value.second; }))
[](auto &&value) {
return !value.second;
}))
{
/// Some of the pauses are infinite
this->pauseEnd_ = boost::none;
@ -282,9 +292,10 @@ void ChannelView::updatePauses()
{
/// Get the maximum pause
auto pauseEnd =
std::max_element(
this->pauses_.begin(), this->pauses_.end(),
[](auto &&a, auto &&b) { return a.second > b.second; })
std::max_element(this->pauses_.begin(), this->pauses_.end(),
[](auto &&a, auto &&b) {
return a.second > b.second;
})
->second.get();
if (pauseEnd != this->pauseEnd_)
@ -605,11 +616,11 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
underlyingChannel->messagesAddedAtStart.connect(
[this](std::vector<MessagePtr> &messages) {
std::vector<MessagePtr> filtered;
std::copy_if( //
messages.begin(), messages.end(),
std::back_inserter(filtered), [this](MessagePtr msg) {
return this->shouldIncludeMessage(msg);
});
std::copy_if(messages.begin(), messages.end(),
std::back_inserter(filtered),
[this](MessagePtr msg) {
return this->shouldIncludeMessage(msg);
});
if (!filtered.empty())
this->channel_->addMessagesAtStart(filtered);
@ -689,7 +700,7 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
if (auto tc = dynamic_cast<TwitchChannel *>(underlyingChannel.get()))
{
this->connections_.push_back(tc->liveStatusChanged.connect([this]() {
this->liveStatusChanged.invoke(); //
this->liveStatusChanged.invoke();
}));
}
}
@ -1813,15 +1824,19 @@ void ChannelView::addContextMenuItems(
QString url = hoveredElement->getLink().value;
// open link
menu->addAction("Open link",
[url] { QDesktopServices::openUrl(QUrl(url)); });
menu->addAction("Open link", [url] {
QDesktopServices::openUrl(QUrl(url));
});
// open link default
if (supportsIncognitoLinks())
{
menu->addAction("Open link incognito",
[url] { openLinkIncognito(url); });
menu->addAction("Open link incognito", [url] {
openLinkIncognito(url);
});
}
menu->addAction("Copy link", [url] { crossPlatformCopy(url); });
menu->addAction("Copy link", [url] {
crossPlatformCopy(url);
});
menu->addSeparator();
}
@ -1829,8 +1844,9 @@ void ChannelView::addContextMenuItems(
// Copy actions
if (!this->selection_.isEmpty())
{
menu->addAction("Copy selection",
[this] { crossPlatformCopy(this->getSelectedText()); });
menu->addAction("Copy selection", [this] {
crossPlatformCopy(this->getSelectedText());
});
}
menu->addAction("Copy message", [layout] {

View file

@ -16,8 +16,9 @@ DebugPopup::DebugPopup()
auto *timer = new QTimer(this);
timer->setInterval(300);
QObject::connect(timer, &QTimer::timeout,
[text] { text->setText(DebugCount::getDebugText()); });
QObject::connect(timer, &QTimer::timeout, [text] {
text->setText(DebugCount::getDebugText());
});
timer->start();
text->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));

View file

@ -36,8 +36,9 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
// add
QPushButton *add = new QPushButton("Add");
buttons->addWidget(add);
QObject::connect(add, &QPushButton::clicked,
[this] { this->addButtonPressed.invoke(); });
QObject::connect(add, &QPushButton::clicked, [this] {
this->addButtonPressed.invoke();
});
// remove
QPushButton *remove = new QPushButton("Remove");
@ -61,22 +62,25 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
// move up
QPushButton *moveUp = new QPushButton("Move up");
buttons->addWidget(moveUp);
QObject::connect(moveUp, &QPushButton::clicked, this,
[this] { this->moveRow(-1); });
QObject::connect(moveUp, &QPushButton::clicked, this, [this] {
this->moveRow(-1);
});
// move down
QPushButton *moveDown = new QPushButton("Move down");
buttons->addWidget(moveDown);
QObject::connect(moveDown, &QPushButton::clicked, this,
[this] { this->moveRow(1); });
QObject::connect(moveDown, &QPushButton::clicked, this, [this] {
this->moveRow(1);
});
}
buttons->addStretch();
QObject::connect(this->model_, &QAbstractTableModel::rowsMoved, this,
[this](const QModelIndex &parent, int start, int end,
const QModelIndex &destination,
int row) { this->selectRow(row); });
const QModelIndex &destination, int row) {
this->selectRow(row);
});
// add tableview
vbox->addWidget(this->tableView_);

View file

@ -46,23 +46,30 @@ NotebookTab::NotebookTab(Notebook *notebook)
getSettings()->showTabCloseButton.connectSimple(
boost::bind(&NotebookTab::hideTabXChanged, this),
this->managedConnections_);
getSettings()->showTabLive.connect([this](auto, auto) { this->update(); },
this->managedConnections_);
getSettings()->showTabLive.connect(
[this](auto, auto) {
this->update();
},
this->managedConnections_);
this->setMouseTracking(true);
this->menu_.addAction("Rename", [this]() { this->showRenameDialog(); });
this->menu_.addAction("Rename", [this]() {
this->showRenameDialog();
});
this->menu_.addAction("Close",
[=]() { this->notebook_->removePage(this->page); });
this->menu_.addAction("Close", [=]() {
this->notebook_->removePage(this->page);
});
highlightNewMessagesAction_ =
new QAction("Enable highlights on new messages", &this->menu_);
highlightNewMessagesAction_->setCheckable(true);
highlightNewMessagesAction_->setChecked(highlightEnabled_);
QObject::connect(
highlightNewMessagesAction_, &QAction::triggered,
[this](bool checked) { this->highlightEnabled_ = checked; });
QObject::connect(highlightNewMessagesAction_, &QAction::triggered,
[this](bool checked) {
this->highlightEnabled_ = checked;
});
this->menu_.addAction(highlightNewMessagesAction_);
}
@ -559,7 +566,7 @@ void NotebookTab::dragEnterEvent(QDragEnterEvent *event)
void NotebookTab::mouseMoveEvent(QMouseEvent *event)
{
if (getSettings()->showTabCloseButton &&
this->notebook_->getAllowUserTabManagement()) //
this->notebook_->getAllowUserTabManagement())
{
bool overX = this->getXRect().contains(event->pos());
@ -575,7 +582,7 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
QPoint relPoint = this->mapToParent(event->pos());
if (this->mouseDown_ && !this->getDesiredRect().contains(relPoint) &&
this->notebook_->getAllowUserTabManagement()) //
this->notebook_->getAllowUserTabManagement())
{
int index;
QWidget *clickedPage =

View file

@ -21,8 +21,9 @@ ResizingTextEdit::ResizingTextEdit()
// Whenever the setting for emote completion changes, force a
// refresh on the completion model the next time "Tab" is pressed
getSettings()->prefixOnlyEmoteCompletion.connect(
[this] { this->completionInProgress_ = false; });
getSettings()->prefixOnlyEmoteCompletion.connect([this] {
this->completionInProgress_ = false;
});
this->setFocusPolicy(Qt::ClickFocus);
}

View file

@ -109,7 +109,9 @@ void SearchPopup::initLayout()
this->searchInput_ = new QLineEdit(this);
layout2->addWidget(this->searchInput_);
QObject::connect(this->searchInput_, &QLineEdit::returnPressed,
[this] { this->search(); });
[this] {
this->search();
});
}
// SEARCH BUTTON
@ -117,8 +119,9 @@ void SearchPopup::initLayout()
QPushButton *searchButton = new QPushButton(this);
searchButton->setText("Search");
layout2->addWidget(searchButton);
QObject::connect(searchButton, &QPushButton::clicked,
[this] { this->search(); });
QObject::connect(searchButton, &QPushButton::clicked, [this] {
this->search();
});
}
layout1->addLayout(layout2);

View file

@ -71,7 +71,7 @@ ExternalToolsPage::ExternalToolsPage()
getSettings()->streamlinkUseCustomPath.connect(
[=](const auto &value, auto) {
customPath->setEnabled(value); //
customPath->setEnabled(value);
},
this->managedConnections_);
}

View file

@ -110,13 +110,22 @@ void GeneralPage::initLayout(GeneralPageView &layout)
getApp()->themes->themeName);
layout.addDropdown<QString>(
"Font", {"Segoe UI", "Arial", "Choose..."},
getApp()->fonts->chatFontFamily, [](auto val) { return val; },
[this](auto args) { return this->getFont(args); });
getApp()->fonts->chatFontFamily,
[](auto val) {
return val;
},
[this](auto args) {
return this->getFont(args);
});
layout.addDropdown<int>(
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
getApp()->fonts->chatFontSize,
[](auto val) { return QString::number(val) + "pt"; },
[](auto args) { return fuzzyToInt(args.value, 10); });
[](auto val) {
return QString::number(val) + "pt";
},
[](auto args) {
return fuzzyToInt(args.value, 10);
});
layout.addDropdown<float>(
"Zoom",
{"0.5x", "0.6x", "0.7x", "0.8x", "0.9x", "Default", "1.2x", "1.4x",
@ -128,7 +137,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
else
return QString::number(val) + "x";
},
[](auto args) { return fuzzyToFloat(args.value, 1.f); });
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
});
layout.addDropdown<int>(
"Tab layout", {"Horizontal", "Vertical"}, s.tabDirection,
[](auto val) {
@ -201,7 +212,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
else
return QString::number(val) + "x";
},
[](auto args) { return fuzzyToFloat(args.value, 1.f); });
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
});
layout.addCheckbox("Smooth scrolling", s.enableSmoothScrolling);
layout.addCheckbox("Smooth scrolling on new messages",
s.enableSmoothScrollingNewMessages);
@ -266,7 +279,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
[](auto val) {
return val ? QString::number(val) + " lines" : QString("Never");
},
[](auto args) { return fuzzyToInt(args.value, 0); });
[](auto args) {
return fuzzyToInt(args.value, 0);
});
layout.addTitle("Emotes");
layout.addCheckbox("Enable", s.enableEmoteImages);
@ -284,12 +299,20 @@ void GeneralPage::initLayout(GeneralPageView &layout)
else
return QString::number(val) + "x";
},
[](auto args) { return fuzzyToFloat(args.value, 1.f); });
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
});
layout.addDropdown<int>(
"Show info on hover", {"Don't show", "Always show", "Hold shift"},
s.emotesTooltipPreview, [](int index) { return index; },
[](auto args) { return args.index; }, false);
s.emotesTooltipPreview,
[](int index) {
return index;
},
[](auto args) {
return args.index;
},
false);
layout.addDropdown("Emoji style",
{"EmojiOne 2", "EmojiOne 3", "Twitter", "Facebook",
"Apple", "Google", "Messenger"},
@ -304,7 +327,10 @@ void GeneralPage::initLayout(GeneralPageView &layout)
ComboBox *dankDropdown =
layout.addDropdown<std::underlying_type<StreamerModeSetting>::type>(
"Enable Streamer Mode", {"No", "Yes", "Detect OBS (Windows only)"},
s.enableStreamerMode, [](int value) { return value; },
s.enableStreamerMode,
[](int value) {
return value;
},
[](DropdownArgs args) {
return static_cast<StreamerModeSetting>(args.index);
},
@ -445,8 +471,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
box->addWidget(layout.makeButton("Choose cache path", [this]() {
getSettings()->cachePath = QFileDialog::getExistingDirectory(this);
}));
box->addWidget(layout.makeButton(
"Reset", []() { getSettings()->cachePath = ""; }));
box->addWidget(layout.makeButton("Reset", []() {
getSettings()->cachePath = "";
}));
box->addStretch(1);
layout.addLayout(box);
@ -471,21 +498,36 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addCheckbox("Receive notification sounds from hidden messages",
s.shownSimilarTriggerHighlights);
s.hideSimilar.connect(
[]() { getApp()->windows->forceLayoutChannelViews(); }, false);
[]() {
getApp()->windows->forceLayoutChannelViews();
},
false);
layout.addDropdown<float>(
"Similarity threshold", {"0.5", "0.75", "0.9"}, s.similarityPercentage,
[](auto val) { return QString::number(val); },
[](auto args) { return fuzzyToFloat(args.value, 0.9f); });
[](auto val) {
return QString::number(val);
},
[](auto args) {
return fuzzyToFloat(args.value, 0.9f);
});
layout.addDropdown<int>(
"Maximum delay between messages",
{"5s", "10s", "15s", "30s", "60s", "120s"}, s.hideSimilarMaxDelay,
[](auto val) { return QString::number(val) + "s"; },
[](auto args) { return fuzzyToInt(args.value, 5); });
[](auto val) {
return QString::number(val) + "s";
},
[](auto args) {
return fuzzyToInt(args.value, 5);
});
layout.addDropdown<int>(
"Amount of previous messages to check", {"1", "2", "3", "4", "5"},
s.hideSimilarMaxMessagesToCheck,
[](auto val) { return QString::number(val); },
[](auto args) { return fuzzyToInt(args.value, 3); });
[](auto val) {
return QString::number(val);
},
[](auto args) {
return fuzzyToInt(args.value, 3);
});
layout.addSubtitle("Visible badges");
layout.addCheckbox("Authority (staff, admin)",
@ -540,7 +582,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
else
return QString::number(val);
},
[](auto args) { return fuzzyToFloat(args.value, 63.f); });
[](auto args) {
return fuzzyToFloat(args.value, 63.f);
});
layout.addCheckbox("Double click to open links and other elements in chat",
s.linksDoubleClickOnly);
layout.addCheckbox("Unshorten links", s.unshortLinks);
@ -563,8 +607,14 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.showUnhandledIrcMessages);
layout.addDropdown<int>(
"Stack timeouts", {"Stack", "Stack until timeout", "Don't stack"},
s.timeoutStackStyle, [](int index) { return index; },
[](auto args) { return args.index; }, false);
s.timeoutStackStyle,
[](int index) {
return index;
},
[](auto args) {
return args.index;
},
false);
layout.addCheckbox("Combine multiple bit tips into one", s.stackBits);
layout.addCheckbox("Ask for confirmation when uploading an image",
s.askOnImageUpload);

View file

@ -27,7 +27,9 @@ GeneralPageView::GeneralPageView(QWidget *parent)
{scrollArea, new QSpacerItem(16, 1), navigation}));
QObject::connect(scrollArea->verticalScrollBar(), &QScrollBar::valueChanged,
this, [=] { this->updateNavigationHighlighting(); });
this, [=] {
this->updateNavigationHighlighting();
});
}
void GeneralPageView::addWidget(QWidget *widget)
@ -96,9 +98,10 @@ QCheckBox *GeneralPageView::addCheckbox(const QString &text,
this->managedConnections_);
// update setting on toggle
QObject::connect(
check, &QCheckBox::toggled, this,
[&setting, inverse](bool state) { setting = inverse ^ state; });
QObject::connect(check, &QCheckBox::toggled, this,
[&setting, inverse](bool state) {
setting = inverse ^ state;
});
this->addWidget(check);
@ -141,7 +144,9 @@ ComboBox *GeneralPageView::addDropdown(
// update when setting changes
setting.connect(
[combo](const QString &value, auto) { combo->setCurrentText(value); },
[combo](const QString &value, auto) {
combo->setCurrentText(value);
},
this->managedConnections_);
QObject::connect(combo, &QComboBox::currentTextChanged,

View file

@ -86,8 +86,9 @@ void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
auto &setting = getSettings()->showIgnoredUsersMessages;
setting.connect(
[combo](const int value) { combo->setCurrentIndex(value); });
setting.connect([combo](const int value) {
combo->setCurrentIndex(value);
});
QObject::connect(combo,
QOverload<int>::of(&QComboBox::currentIndexChanged),

View file

@ -120,21 +120,23 @@ ModerationPage::ModerationPage()
// Show how big (size-wise) the logs are
auto logsPathSizeLabel = logs.emplace<QLabel>();
logsPathSizeLabel->setText(
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
logsPathSizeLabel->setText(QtConcurrent::run([] {
return fetchLogDirectorySize();
}));
// Select event
QObject::connect(
selectDir.getElement(), &QPushButton::clicked, this,
[this, logsPathSizeLabel]() mutable {
auto dirName = QFileDialog::getExistingDirectory(this);
QObject::connect(selectDir.getElement(), &QPushButton::clicked, this,
[this, logsPathSizeLabel]() mutable {
auto dirName =
QFileDialog::getExistingDirectory(this);
getSettings()->logPath = dirName;
getSettings()->logPath = dirName;
// Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText(
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
});
// Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText(QtConcurrent::run([] {
return fetchLogDirectorySize();
}));
});
buttons->addSpacing(16);
@ -144,8 +146,9 @@ ModerationPage::ModerationPage()
getSettings()->logPath = "";
// Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText(QtConcurrent::run(
[] { return fetchLogDirectorySize(); }));
logsPathSizeLabel->setText(QtConcurrent::run([] {
return fetchLogDirectorySize();
}));
});
} // logs end

View file

@ -96,7 +96,7 @@ QCheckBox *SettingsPage::createCheckBox(
// update when setting changes
setting.connect(
[checkbox](const bool &value, auto) {
checkbox->setChecked(value); //
checkbox->setChecked(value);
},
this->managedConnections_);
@ -120,12 +120,15 @@ QComboBox *SettingsPage::createComboBox(
// update when setting changes
setting.connect(
[combo](const QString &value, auto) { combo->setCurrentText(value); },
[combo](const QString &value, auto) {
combo->setCurrentText(value);
},
this->managedConnections_);
QObject::connect(
combo, &QComboBox::currentTextChanged,
[&setting](const QString &newValue) { setting = newValue; });
QObject::connect(combo, &QComboBox::currentTextChanged,
[&setting](const QString &newValue) {
setting = newValue;
});
return combo;
}
@ -138,9 +141,10 @@ QLineEdit *SettingsPage::createLineEdit(
edit->setText(setting);
// update when setting changes
QObject::connect(
edit, &QLineEdit::textChanged,
[&setting](const QString &newValue) { setting = newValue; });
QObject::connect(edit, &QLineEdit::textChanged,
[&setting](const QString &newValue) {
setting = newValue;
});
return edit;
}
@ -153,9 +157,13 @@ QSpinBox *SettingsPage::createSpinBox(pajlada::Settings::Setting<int> &setting,
w->setMinimum(min);
w->setMaximum(max);
setting.connect([w](const int &value, auto) { w->setValue(value); });
setting.connect([w](const int &value, auto) {
w->setValue(value);
});
QObject::connect(w, QOverload<int>::of(&QSpinBox::valueChanged),
[&setting](int value) { setting.setValue(value); });
[&setting](int value) {
setting.setValue(value);
});
return w;
}

View file

@ -8,9 +8,11 @@ std::vector<ClosedSplits::SplitInfo> ClosedSplits::closedSplits_;
void ClosedSplits::invalidateTab(NotebookTab *const tab)
{
std::lock_guard<std::mutex> lk(ClosedSplits::m_);
auto it = std::find_if(
ClosedSplits::closedSplits_.begin(), ClosedSplits::closedSplits_.end(),
[tab](const auto &item) -> bool { return item.tab == tab; });
auto it = std::find_if(ClosedSplits::closedSplits_.begin(),
ClosedSplits::closedSplits_.end(),
[tab](const auto &item) -> bool {
return item.tab == tab;
});
if (it == ClosedSplits::closedSplits_.end())
{
return;

View file

@ -66,7 +66,9 @@ void EmoteInputPopup::initLayout()
listView->setModel(&this->model_);
QObject::connect(listView.getElement(), &GenericListView::closeRequested,
this, [this] { this->close(); });
this, [this] {
this->close();
});
}
void EmoteInputPopup::updateEmotes(const QString &text, ChannelPtr channel)

View file

@ -134,11 +134,12 @@ Split::Split(QWidget *parent)
this->input_->ui_.textEdit->installEventFilter(parent);
this->signalHolder_.managedConnect(
getApp()->accounts->twitch.currentUserChanged,
[this] { this->onAccountSelected(); });
getApp()->accounts->twitch.currentUserChanged, [this] {
this->onAccountSelected();
});
this->onAccountSelected();
this->view_->mouseDown.connect([this](QMouseEvent *) { //
this->view_->mouseDown.connect([this](QMouseEvent *) {
this->giveFocus(Qt::MouseFocusReason);
});
this->view_->selectionChanged.connect([this]() {
@ -212,10 +213,12 @@ Split::Split(QWidget *parent)
}
});
this->input_->ui_.textEdit->focused.connect(
[this] { this->focused.invoke(); });
this->input_->ui_.textEdit->focusLost.connect(
[this] { this->focusLost.invoke(); });
this->input_->ui_.textEdit->focused.connect([this] {
this->focused.invoke();
});
this->input_->ui_.textEdit->focusLost.connect([this] {
this->focusLost.invoke();
});
this->input_->ui_.textEdit->imagePasted.connect(
[this](const QMimeData *source) {
if (!getSettings()->imageUploaderEnabled)
@ -249,7 +252,9 @@ Split::Split(QWidget *parent)
});
getSettings()->imageUploaderEnabled.connect(
[this](const bool &val) { this->setAcceptDrops(val); },
[this](const bool &val) {
this->setAcceptDrops(val);
},
this->managedConnections_);
}
@ -306,7 +311,7 @@ void Split::onAccountSelected()
this->updateTooltipColor();
this->signalHolder_.managedConnect(this->theme->updated, [this]() {
this->updateTooltipColor(); //
this->updateTooltipColor();
});
}
@ -347,13 +352,16 @@ void Split::setChannel(IndirectChannel newChannel)
this->header_->updateRoomModes();
});
this->roomModeChangedConnection_ = tc->roomModesChanged.connect(
[this] { this->header_->updateRoomModes(); });
this->roomModeChangedConnection_ = tc->roomModesChanged.connect([this] {
this->header_->updateRoomModes();
});
}
this->indirectChannelChangedConnection_ =
newChannel.getChannelChanged().connect([this] { //
QTimer::singleShot(0, [this] { this->setChannel(this->channel_); });
newChannel.getChannelChanged().connect([this] {
QTimer::singleShot(0, [this] {
this->setChannel(this->channel_);
});
});
this->header_->updateModerationModeIcon();
@ -544,8 +552,9 @@ void Split::deleteFromContainer()
{
this->container_->deleteSplit(this);
auto *tab = this->getContainer()->getTab();
tab->connect(tab, &QWidget::destroyed,
[tab]() mutable { ClosedSplits::invalidateTab(tab); });
tab->connect(tab, &QWidget::destroyed, [tab]() mutable {
ClosedSplits::invalidateTab(tab);
});
ClosedSplits::push({this->getChannel()->getName(), tab});
}
}
@ -747,8 +756,9 @@ void Split::showViewerList()
}
});
QObject::connect(viewerDock, &QDockWidget::topLevelChanged, this,
[=]() { viewerDock->setMinimumWidth(300); });
QObject::connect(viewerDock, &QDockWidget::topLevelChanged, this, [=]() {
viewerDock->setMinimumWidth(300);
});
auto listDoubleClick = [=](QString userName) {
if (!labels.contains(userName) && !userName.isEmpty())

View file

@ -220,10 +220,12 @@ void SplitContainer::addSplit(Split *split)
});
split->getChannelView().liveStatusChanged.connect([this]() {
this->refreshTabLiveStatus(); //
this->refreshTabLiveStatus();
});
split->focused.connect([this, split] { this->setSelected(split); });
split->focused.connect([this, split] {
this->setSelected(split);
});
this->layout();
}
@ -318,9 +320,10 @@ void SplitContainer::selectSplitRecursive(Node *node, Direction direction)
{
auto &siblings = node->parent_->children_;
auto it = std::find_if(
siblings.begin(), siblings.end(),
[node](const auto &other) { return other.get() == node; });
auto it = std::find_if(siblings.begin(), siblings.end(),
[node](const auto &other) {
return other.get() == node;
});
assert(it != siblings.end());
if (direction == Direction::Left || direction == Direction::Above)
@ -993,8 +996,10 @@ void SplitContainer::Node::insertNextToThis(Split *_split, Direction _direction)
this->geometry_ = QRect(0, 0, int(width), int(height));
}
auto it = std::find_if(siblings.begin(), siblings.end(),
[this](auto &node) { return this == node.get(); });
auto it =
std::find_if(siblings.begin(), siblings.end(), [this](auto &node) {
return this == node.get();
});
assert(it != siblings.end());
if (_direction == Direction::Right || _direction == Direction::Below)
@ -1035,8 +1040,9 @@ SplitContainer::Position SplitContainer::Node::releaseSplit()
auto &siblings = this->parent_->children_;
auto it =
std::find_if(begin(siblings), end(siblings),
[this](auto &node) { return this == node.get(); });
std::find_if(begin(siblings), end(siblings), [this](auto &node) {
return this == node.get();
});
assert(it != siblings.end());
Position position;

View file

@ -191,15 +191,23 @@ SplitHeader::SplitHeader(Split *_split)
this->handleChannelChanged();
this->updateModerationModeIcon();
this->split_->focused.connect([this]() { this->themeChangedEvent(); });
this->split_->focusLost.connect([this]() { this->themeChangedEvent(); });
this->split_->channelChanged.connect(
[this]() { this->handleChannelChanged(); });
this->split_->focused.connect([this]() {
this->themeChangedEvent();
});
this->split_->focusLost.connect([this]() {
this->themeChangedEvent();
});
this->split_->channelChanged.connect([this]() {
this->handleChannelChanged();
});
this->managedConnect(getApp()->accounts->twitch.currentUserChanged,
[this] { this->updateModerationModeIcon(); });
this->managedConnect(getApp()->accounts->twitch.currentUserChanged, [this] {
this->updateModerationModeIcon();
});
auto _ = [this](const auto &, const auto &) { this->updateChannelText(); };
auto _ = [this](const auto &, const auto &) {
this->updateChannelText();
};
getSettings()->headerViewerCount.connect(_, this->managedConnections_);
getSettings()->headerStreamTitle.connect(_, this->managedConnections_);
getSettings()->headerGame.connect(_, this->managedConnections_);
@ -210,8 +218,9 @@ void SplitHeader::initializeLayout()
{
auto layout = makeLayout<QHBoxLayout>({
// space
makeWidget<BaseWidget>(
[](auto w) { w->setScaleIndependantSize(8, 4); }),
makeWidget<BaseWidget>([](auto w) {
w->setScaleIndependantSize(8, 4);
}),
// title
this->titleLabel_ = makeWidget<Label>([](auto w) {
w->setSizePolicy(QSizePolicy::MinimumExpanding,
@ -220,8 +229,9 @@ void SplitHeader::initializeLayout()
w->setHasOffset(false);
}),
// space
makeWidget<BaseWidget>(
[](auto w) { w->setScaleIndependantSize(8, 4); }),
makeWidget<BaseWidget>([](auto w) {
w->setScaleIndependantSize(8, 4);
}),
// mode
this->modeButton_ = makeWidget<EffectLabel>([&](auto w) {
w->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
@ -266,8 +276,9 @@ void SplitHeader::initializeLayout()
}),
// viewer list
this->viewersButton_ = makeWidget<Button>([&](auto w) {
QObject::connect(w, &Button::leftClicked, this,
[this]() { this->split_->showViewerList(); });
QObject::connect(w, &Button::leftClicked, this, [this]() {
this->split_->showViewerList();
});
}),
// dropdown
this->dropdownButton_ = makeWidget<Button>([&](auto w) {
@ -281,8 +292,9 @@ void SplitHeader::initializeLayout()
w->setPixmap(getResources().buttons.addSplitDark);
w->setEnableMargin(false);
QObject::connect(w, &Button::leftClicked, this,
[this]() { this->split_->addSibling(); });
QObject::connect(w, &Button::leftClicked, this, [this]() {
this->split_->addSibling();
});
}),
});
@ -476,7 +488,7 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
menu->addAction(setR9k);
menu->addAction(setFollowers);
this->managedConnections_.push_back(this->modeUpdateRequested_.connect( //
this->managedConnections_.push_back(this->modeUpdateRequested_.connect(
[this, setSub, setEmote, setSlow, setR9k, setFollowers]() {
auto twitchChannel =
dynamic_cast<TwitchChannel *>(this->split_->getChannel().get());
@ -501,13 +513,15 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
action->setChecked(!action->isChecked());
};
QObject::connect(
setSub, &QAction::triggered, this,
[setSub, toggle]() mutable { toggle("/subscribers", setSub); });
QObject::connect(setSub, &QAction::triggered, this,
[setSub, toggle]() mutable {
toggle("/subscribers", setSub);
});
QObject::connect(
setEmote, &QAction::triggered, this,
[setEmote, toggle]() mutable { toggle("/emoteonly", setEmote); });
QObject::connect(setEmote, &QAction::triggered, this,
[setEmote, toggle]() mutable {
toggle("/emoteonly", setEmote);
});
QObject::connect(setSlow, &QAction::triggered, this, [setSlow, this]() {
if (!setSlow->isChecked())
@ -554,9 +568,10 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
}
});
QObject::connect(
setR9k, &QAction::triggered, this,
[setR9k, toggle]() mutable { toggle("/r9kbeta", setR9k); });
QObject::connect(setR9k, &QAction::triggered, this,
[setR9k, toggle]() mutable {
toggle("/r9kbeta", setR9k);
});
return menu;
}
@ -569,8 +584,8 @@ void SplitHeader::updateRoomModes()
void SplitHeader::initializeModeSignals(EffectLabel &label)
{
this->modeUpdateRequested_.connect([this, &label] {
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(
this->split_->getChannel().get())) //
if (auto twitchChannel =
dynamic_cast<TwitchChannel *>(this->split_->getChannel().get()))
{
label.setEnable(twitchChannel->hasModRights());
@ -608,7 +623,7 @@ void SplitHeader::handleChannelChanged()
{
this->channelConnections_.emplace_back(
twitchChannel->liveStatusChanged.connect([this]() {
this->updateChannelText(); //
this->updateChannelText();
}));
}
}

View file

@ -43,7 +43,9 @@ SplitInput::SplitInput(Split *_chatWidget)
// misc
this->installKeyPressedEvent();
this->ui_.textEdit->focusLost.connect([this] { this->hideColonMenu(); });
this->ui_.textEdit->focusLost.connect([this] {
this->hideColonMenu();
});
this->scaleChangedEvent(this->scale());
}
@ -90,8 +92,9 @@ void SplitInput::initLayout()
}));
// open emote popup
QObject::connect(this->ui_.emoteButton, &EffectLabel::leftClicked,
[=] { this->openEmotePopup(); });
QObject::connect(this->ui_.emoteButton, &EffectLabel::leftClicked, [=] {
this->openEmotePopup();
});
// clear channelview selection when selecting in the input
QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable,
@ -599,7 +602,7 @@ void SplitInput::editTextChanged()
QString text = this->ui_.textEdit->toPlainText();
if (text.startsWith("/r ", Qt::CaseInsensitive) &&
this->split_->getChannel()->isTwitchChannel()) //
this->split_->getChannel()->isTwitchChannel())
{
QString lastUser = app->twitch.server->lastUserThatWhisperedMe.get();
if (!lastUser.isEmpty())