added brace wrapping after if and for
This commit is contained in:
@@ -29,14 +29,18 @@ namespace {
|
||||
builder->flags.set(MessageFlag::Centered);
|
||||
builder->flags.set(MessageFlag::DisableCompactEmotes);
|
||||
|
||||
if (!map.empty()) {
|
||||
for (const auto &emote : map) {
|
||||
if (!map.empty())
|
||||
{
|
||||
for (const auto &emote : map)
|
||||
{
|
||||
builder
|
||||
.emplace<EmoteElement>(emote.second,
|
||||
MessageElementFlag::AlwaysShow)
|
||||
->setLink(Link(Link::InsertText, emote.first.string));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.emplace<TextElement>("no emotes available",
|
||||
MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
@@ -50,7 +54,8 @@ namespace {
|
||||
{
|
||||
QMap<QString, QPair<bool, std::vector<MessagePtr>>> mapOfSets;
|
||||
|
||||
for (const auto &set : sets) {
|
||||
for (const auto &set : sets)
|
||||
{
|
||||
// TITLE
|
||||
auto channelName = set->channelName;
|
||||
auto text =
|
||||
@@ -62,13 +67,15 @@ namespace {
|
||||
builder->flags.set(MessageFlag::DisableCompactEmotes);
|
||||
|
||||
// If value of map is empty, create init pair and add title.
|
||||
if (mapOfSets.find(channelName) == mapOfSets.end()) {
|
||||
if (mapOfSets.find(channelName) == mapOfSets.end())
|
||||
{
|
||||
std::vector<MessagePtr> b;
|
||||
b.push_back(makeTitleMessage(text));
|
||||
mapOfSets[channelName] = qMakePair(set->key == "0", b);
|
||||
}
|
||||
|
||||
for (const auto &emote : set->emotes) {
|
||||
for (const auto &emote : set->emotes)
|
||||
{
|
||||
builder
|
||||
.emplace<EmoteElement>(
|
||||
getApp()->emotes->twitch.getOrCreateEmote(emote.id,
|
||||
@@ -82,9 +89,11 @@ namespace {
|
||||
|
||||
// Output to channel all created messages,
|
||||
// That contain title or emotes.
|
||||
foreach (auto pair, mapOfSets) {
|
||||
foreach (auto pair, mapOfSets)
|
||||
{
|
||||
auto &channel = pair.first ? globalChannel : subChannel;
|
||||
for (auto message : pair.second) {
|
||||
for (auto message : pair.second)
|
||||
{
|
||||
channel.addMessage(message);
|
||||
}
|
||||
}
|
||||
@@ -131,7 +140,8 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
this->setWindowTitle("Emotes in #" + _channel->getName());
|
||||
|
||||
auto twitchChannel = dynamic_cast<TwitchChannel *>(_channel.get());
|
||||
if (twitchChannel == nullptr) return;
|
||||
if (twitchChannel == nullptr)
|
||||
return;
|
||||
|
||||
auto addEmotes = [&](Channel &channel, const EmoteMap &map,
|
||||
const QString &title) {
|
||||
@@ -162,7 +172,8 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
this->subEmotesView_->setChannel(subChannel);
|
||||
this->channelEmotesView_->setChannel(channelChannel);
|
||||
|
||||
if (subChannel->getMessageSnapshot().getLength() == 0) {
|
||||
if (subChannel->getMessageSnapshot().getLength() == 0)
|
||||
{
|
||||
MessageBuilder builder;
|
||||
builder->flags.set(MessageFlag::Centered);
|
||||
builder->flags.set(MessageFlag::DisableCompactEmotes);
|
||||
|
||||
@@ -28,20 +28,25 @@ namespace {
|
||||
{
|
||||
QStringList errors;
|
||||
|
||||
if (userID.empty()) {
|
||||
if (userID.empty())
|
||||
{
|
||||
errors.append("Missing user ID");
|
||||
}
|
||||
if (username.empty()) {
|
||||
if (username.empty())
|
||||
{
|
||||
errors.append("Missing username");
|
||||
}
|
||||
if (clientID.empty()) {
|
||||
if (clientID.empty())
|
||||
{
|
||||
errors.append("Missing Client ID");
|
||||
}
|
||||
if (oauthToken.empty()) {
|
||||
if (oauthToken.empty())
|
||||
{
|
||||
errors.append("Missing OAuth Token");
|
||||
}
|
||||
|
||||
if (errors.length() > 0) {
|
||||
if (errors.length() > 0)
|
||||
{
|
||||
QMessageBox messageBox;
|
||||
messageBox.setIcon(QMessageBox::Critical);
|
||||
messageBox.setText(errors.join("<br />"));
|
||||
@@ -96,23 +101,34 @@ BasicLoginWidget::BasicLoginWidget()
|
||||
|
||||
std::string oauthToken, clientID, username, userID;
|
||||
|
||||
for (const auto ¶m : parameters) {
|
||||
for (const auto ¶m : parameters)
|
||||
{
|
||||
QStringList kvParameters = param.split('=');
|
||||
if (kvParameters.size() != 2) {
|
||||
if (kvParameters.size() != 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QString key = kvParameters[0];
|
||||
QString value = kvParameters[1];
|
||||
|
||||
if (key == "oauth_token") {
|
||||
if (key == "oauth_token")
|
||||
{
|
||||
oauthToken = value.toStdString();
|
||||
} else if (key == "client_id") {
|
||||
}
|
||||
else if (key == "client_id")
|
||||
{
|
||||
clientID = value.toStdString();
|
||||
} else if (key == "username") {
|
||||
}
|
||||
else if (key == "username")
|
||||
{
|
||||
username = value.toStdString();
|
||||
} else if (key == "user_id") {
|
||||
}
|
||||
else if (key == "user_id")
|
||||
{
|
||||
userID = value.toStdString();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Unknown key in code: " << key;
|
||||
}
|
||||
}
|
||||
@@ -212,9 +228,12 @@ void AdvancedLoginWidget::refreshButtons()
|
||||
if (this->ui_.userIDInput.text().isEmpty() ||
|
||||
this->ui_.usernameInput.text().isEmpty() ||
|
||||
this->ui_.clientIDInput.text().isEmpty() ||
|
||||
this->ui_.oauthTokenInput.text().isEmpty()) {
|
||||
this->ui_.oauthTokenInput.text().isEmpty())
|
||||
{
|
||||
this->ui_.buttonUpperRow.addUserButton.setEnabled(false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.buttonUpperRow.addUserButton.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QButtonGroup>
|
||||
@@ -16,6 +15,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ void LogsPopup::getRoomID()
|
||||
{
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
if (twitchChannel == nullptr) {
|
||||
if (twitchChannel == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -84,7 +85,8 @@ void LogsPopup::getLogviewerLogs()
|
||||
{
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
if (twitchChannel == nullptr) {
|
||||
if (twitchChannel == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,7 +109,8 @@ void LogsPopup::getLogviewerLogs()
|
||||
|
||||
QJsonValue before = data.value("before");
|
||||
|
||||
for (auto i : before.toArray()) {
|
||||
for (auto i : before.toArray())
|
||||
{
|
||||
auto messageObject = i.toObject();
|
||||
QString message = messageObject.value("text").toString();
|
||||
|
||||
@@ -137,7 +140,8 @@ void LogsPopup::getOverrustleLogs()
|
||||
{
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
if (twitchChannel == nullptr) {
|
||||
if (twitchChannel == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -164,9 +168,11 @@ void LogsPopup::getOverrustleLogs()
|
||||
req.onSuccess([this, channelName](auto result) -> Outcome {
|
||||
auto data = result.parseJson();
|
||||
std::vector<MessagePtr> messages;
|
||||
if (data.contains("lines")) {
|
||||
if (data.contains("lines"))
|
||||
{
|
||||
QJsonArray dataMessages = data.value("lines").toArray();
|
||||
for (auto i : dataMessages) {
|
||||
for (auto i : dataMessages)
|
||||
{
|
||||
QJsonObject singleMessage = i.toObject();
|
||||
QTime timeStamp = QDateTime::fromSecsSinceEpoch(
|
||||
singleMessage.value("timestamp").toInt())
|
||||
|
||||
@@ -33,11 +33,14 @@ void NotificationPopup::updatePosition()
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
const QRect rect = desktop->availableGeometry();
|
||||
|
||||
switch (location) {
|
||||
case BottomRight: {
|
||||
switch (location)
|
||||
{
|
||||
case BottomRight:
|
||||
{
|
||||
this->move(rect.right() - this->width(),
|
||||
rect.bottom() - this->height());
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,12 @@ void QualityPopup::okButtonClicked()
|
||||
{
|
||||
QString channelURL = "twitch.tv/" + this->channelName_;
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
openStreamlink(channelURL, this->ui_.selector.currentText());
|
||||
} catch (const Exception &ex) {
|
||||
}
|
||||
catch (const Exception &ex)
|
||||
{
|
||||
log("Exception caught trying to open streamlink: {}", ex.what());
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
|
||||
QObject::connect(channel_btn.getElement(), &QRadioButton::toggled,
|
||||
[=](bool enabled) mutable {
|
||||
if (enabled) {
|
||||
if (enabled)
|
||||
{
|
||||
channel_edit->setFocus();
|
||||
channel_edit->setSelection(
|
||||
0, channel_edit->text().length());
|
||||
@@ -176,25 +177,35 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
||||
|
||||
this->selectedChannel_ = channel;
|
||||
|
||||
switch (_channel.getType()) {
|
||||
case Channel::Type::Twitch: {
|
||||
switch (_channel.getType())
|
||||
{
|
||||
case Channel::Type::Twitch:
|
||||
{
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.channel->setFocus();
|
||||
this->ui_.twitch.channelName->setText(channel->getName());
|
||||
} break;
|
||||
case Channel::Type::TwitchWatching: {
|
||||
}
|
||||
break;
|
||||
case Channel::Type::TwitchWatching:
|
||||
{
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.watching->setFocus();
|
||||
} break;
|
||||
case Channel::Type::TwitchMentions: {
|
||||
}
|
||||
break;
|
||||
case Channel::Type::TwitchMentions:
|
||||
{
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.mentions->setFocus();
|
||||
} break;
|
||||
case Channel::Type::TwitchWhispers: {
|
||||
}
|
||||
break;
|
||||
case Channel::Type::TwitchWhispers:
|
||||
{
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.whispers->setFocus();
|
||||
} break;
|
||||
default: {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.channel->setFocus();
|
||||
}
|
||||
@@ -205,22 +216,32 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
||||
|
||||
IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
||||
{
|
||||
if (!this->hasSelectedChannel_) {
|
||||
if (!this->hasSelectedChannel_)
|
||||
{
|
||||
return this->selectedChannel_;
|
||||
}
|
||||
|
||||
auto app = getApp();
|
||||
|
||||
switch (this->ui_.notebook->getSelectedIndex()) {
|
||||
case TAB_TWITCH: {
|
||||
if (this->ui_.twitch.channel->isChecked()) {
|
||||
switch (this->ui_.notebook->getSelectedIndex())
|
||||
{
|
||||
case TAB_TWITCH:
|
||||
{
|
||||
if (this->ui_.twitch.channel->isChecked())
|
||||
{
|
||||
return app->twitch.server->getOrAddChannel(
|
||||
this->ui_.twitch.channelName->text().trimmed());
|
||||
} else if (this->ui_.twitch.watching->isChecked()) {
|
||||
}
|
||||
else if (this->ui_.twitch.watching->isChecked())
|
||||
{
|
||||
return app->twitch.server->watchingChannel;
|
||||
} else if (this->ui_.twitch.mentions->isChecked()) {
|
||||
}
|
||||
else if (this->ui_.twitch.mentions->isChecked())
|
||||
{
|
||||
return app->twitch.server->mentionsChannel;
|
||||
} else if (this->ui_.twitch.whispers->isChecked()) {
|
||||
}
|
||||
else if (this->ui_.twitch.whispers->isChecked())
|
||||
{
|
||||
return app->twitch.server->whispersChannel;
|
||||
}
|
||||
}
|
||||
@@ -239,54 +260,74 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
|
||||
{
|
||||
auto *widget = (QWidget *)watched;
|
||||
|
||||
if (event->type() == QEvent::FocusIn) {
|
||||
if (event->type() == QEvent::FocusIn)
|
||||
{
|
||||
widget->grabKeyboard();
|
||||
|
||||
auto *radio = dynamic_cast<QRadioButton *>(watched);
|
||||
if (radio) {
|
||||
if (radio)
|
||||
{
|
||||
radio->setChecked(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (event->type() == QEvent::FocusOut) {
|
||||
}
|
||||
else if (event->type() == QEvent::FocusOut)
|
||||
{
|
||||
widget->releaseKeyboard();
|
||||
return false;
|
||||
} else if (event->type() == QEvent::KeyPress) {
|
||||
}
|
||||
else if (event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent *event_key = static_cast<QKeyEvent *>(event);
|
||||
if ((event_key->key() == Qt::Key_Tab ||
|
||||
event_key->key() == Qt::Key_Down) &&
|
||||
event_key->modifiers() == Qt::NoModifier) {
|
||||
if (widget == this->dialog->ui_.twitch.channelName) {
|
||||
event_key->modifiers() == Qt::NoModifier)
|
||||
{
|
||||
if (widget == this->dialog->ui_.twitch.channelName)
|
||||
{
|
||||
this->dialog->ui_.twitch.whispers->setFocus();
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
widget->nextInFocusChain()->setFocus();
|
||||
}
|
||||
return true;
|
||||
} else if (((event_key->key() == Qt::Key_Tab ||
|
||||
event_key->key() == Qt::Key_Backtab) &&
|
||||
event_key->modifiers() == Qt::ShiftModifier) ||
|
||||
((event_key->key() == Qt::Key_Up) &&
|
||||
event_key->modifiers() == Qt::NoModifier)) {
|
||||
if (widget == this->dialog->ui_.twitch.channelName) {
|
||||
}
|
||||
else if (((event_key->key() == Qt::Key_Tab ||
|
||||
event_key->key() == Qt::Key_Backtab) &&
|
||||
event_key->modifiers() == Qt::ShiftModifier) ||
|
||||
((event_key->key() == Qt::Key_Up) &&
|
||||
event_key->modifiers() == Qt::NoModifier))
|
||||
{
|
||||
if (widget == this->dialog->ui_.twitch.channelName)
|
||||
{
|
||||
this->dialog->ui_.twitch.watching->setFocus();
|
||||
return true;
|
||||
} else if (widget == this->dialog->ui_.twitch.whispers) {
|
||||
}
|
||||
else if (widget == this->dialog->ui_.twitch.whispers)
|
||||
{
|
||||
this->dialog->ui_.twitch.channel->setFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
widget->previousInFocusChain()->setFocus();
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (event->type() == QEvent::KeyRelease) {
|
||||
}
|
||||
else if (event->type() == QEvent::KeyRelease)
|
||||
{
|
||||
QKeyEvent *event_key = static_cast<QKeyEvent *>(event);
|
||||
if ((event_key->key() == Qt::Key_Backtab ||
|
||||
event_key->key() == Qt::Key_Down) &&
|
||||
event_key->modifiers() == Qt::NoModifier) {
|
||||
event_key->modifiers() == Qt::NoModifier)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -303,10 +344,13 @@ void SelectChannelDialog::themeChangedEvent()
|
||||
{
|
||||
BaseWindow::themeChangedEvent();
|
||||
|
||||
if (this->theme->isLightTheme()) {
|
||||
if (this->theme->isLightTheme())
|
||||
{
|
||||
this->setStyleSheet(
|
||||
"QRadioButton { color: #000 } QLabel { color: #000 }");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setStyleSheet(
|
||||
"QRadioButton { color: #fff } QLabel { color: #fff }");
|
||||
}
|
||||
|
||||
@@ -121,7 +121,8 @@ void SettingsDialog::addTab(SettingsPage *page, Qt::Alignment alignment)
|
||||
this->ui_.tabContainer->addWidget(tab, 0, alignment);
|
||||
this->tabs_.push_back(tab);
|
||||
|
||||
if (this->tabs_.size() == 1) {
|
||||
if (this->tabs_.size() == 1)
|
||||
{
|
||||
this->selectTab(tab);
|
||||
}
|
||||
}
|
||||
@@ -130,7 +131,8 @@ void SettingsDialog::selectTab(SettingsDialogTab *tab)
|
||||
{
|
||||
this->ui_.pageStack->setCurrentWidget(tab->getSettingsPage());
|
||||
|
||||
if (this->selectedTab_ != nullptr) {
|
||||
if (this->selectedTab_ != nullptr)
|
||||
{
|
||||
this->selectedTab_->setSelected(false);
|
||||
this->selectedTab_->setStyleSheet("color: #FFF");
|
||||
}
|
||||
@@ -145,10 +147,13 @@ void SettingsDialog::showDialog(PreferredTab preferredTab)
|
||||
static SettingsDialog *instance = new SettingsDialog();
|
||||
instance->refresh();
|
||||
|
||||
switch (preferredTab) {
|
||||
case SettingsDialog::PreferredTab::Accounts: {
|
||||
switch (preferredTab)
|
||||
{
|
||||
case SettingsDialog::PreferredTab::Accounts:
|
||||
{
|
||||
instance->selectTab(instance->tabs_.at(0));
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
instance->show();
|
||||
@@ -161,7 +166,8 @@ void SettingsDialog::refresh()
|
||||
{
|
||||
getSettings()->saveSnapshot();
|
||||
|
||||
for (auto *tab : this->tabs_) {
|
||||
for (auto *tab : this->tabs_)
|
||||
{
|
||||
tab->getSettingsPage()->onShow();
|
||||
}
|
||||
}
|
||||
@@ -174,7 +180,8 @@ void SettingsDialog::scaleChangedEvent(float newDpi)
|
||||
styleSheet.replace("<font-size>", QString::number(int(14 * newDpi)));
|
||||
styleSheet.replace("<checkbox-size>", QString::number(int(14 * newDpi)));
|
||||
|
||||
for (SettingsDialogTab *tab : this->tabs_) {
|
||||
for (SettingsDialogTab *tab : this->tabs_)
|
||||
{
|
||||
tab->setFixedHeight(int(30 * newDpi));
|
||||
}
|
||||
|
||||
@@ -200,7 +207,8 @@ void SettingsDialog::onOkClicked()
|
||||
|
||||
void SettingsDialog::onCancelClicked()
|
||||
{
|
||||
for (auto &tab : this->tabs_) {
|
||||
for (auto &tab : this->tabs_)
|
||||
{
|
||||
tab->getSettingsPage()->cancel();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,31 +43,42 @@ void UpdateDialog::updateStatusChanged(Updates::Status status)
|
||||
{
|
||||
this->ui_.installButton->setVisible(status == Updates::UpdateAvailable);
|
||||
|
||||
switch (status) {
|
||||
case Updates::UpdateAvailable: {
|
||||
switch (status)
|
||||
{
|
||||
case Updates::UpdateAvailable:
|
||||
{
|
||||
this->ui_.label->setText(
|
||||
QString("An update (%1) is available.\n\nDo you want to "
|
||||
"download and install it?")
|
||||
.arg(Updates::getInstance().getOnlineVersion()));
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Updates::SearchFailed: {
|
||||
case Updates::SearchFailed:
|
||||
{
|
||||
this->ui_.label->setText("Failed to load version information.");
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Updates::Downloading: {
|
||||
case Updates::Downloading:
|
||||
{
|
||||
this->ui_.label->setText(
|
||||
"Downloading updates.\n\nChatterino will restart "
|
||||
"automatically when the download is done.");
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Updates::DownloadFailed: {
|
||||
case Updates::DownloadFailed:
|
||||
{
|
||||
this->ui_.label->setText("Failed to download the update.");
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Updates::WriteFileFailed: {
|
||||
case Updates::WriteFileFailed:
|
||||
{
|
||||
this->ui_.label->setText("Failed to save the update to disk.");
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,8 @@ UserInfoPopup::UserInfoPopup()
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
if (twitchChannel)
|
||||
{
|
||||
qDebug() << this->userName_;
|
||||
|
||||
bool isMyself =
|
||||
@@ -140,7 +141,8 @@ UserInfoPopup::UserInfoPopup()
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
if (twitchChannel)
|
||||
{
|
||||
lineMod->setVisible(twitchChannel->hasModRights());
|
||||
timeout->setVisible(twitchChannel->hasModRights());
|
||||
}
|
||||
@@ -151,25 +153,35 @@ UserInfoPopup::UserInfoPopup()
|
||||
int arg;
|
||||
std::tie(action, arg) = item;
|
||||
|
||||
switch (action) {
|
||||
case TimeoutWidget::Ban: {
|
||||
if (this->channel_) {
|
||||
switch (action)
|
||||
{
|
||||
case TimeoutWidget::Ban:
|
||||
{
|
||||
if (this->channel_)
|
||||
{
|
||||
this->channel_->sendMessage("/ban " + this->userName_);
|
||||
}
|
||||
} break;
|
||||
case TimeoutWidget::Unban: {
|
||||
if (this->channel_) {
|
||||
}
|
||||
break;
|
||||
case TimeoutWidget::Unban:
|
||||
{
|
||||
if (this->channel_)
|
||||
{
|
||||
this->channel_->sendMessage("/unban " +
|
||||
this->userName_);
|
||||
}
|
||||
} break;
|
||||
case TimeoutWidget::Timeout: {
|
||||
if (this->channel_) {
|
||||
}
|
||||
break;
|
||||
case TimeoutWidget::Timeout:
|
||||
{
|
||||
if (this->channel_)
|
||||
{
|
||||
this->channel_->sendMessage("/timeout " +
|
||||
this->userName_ + " " +
|
||||
QString::number(arg));
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -204,9 +216,12 @@ void UserInfoPopup::installEvents()
|
||||
};
|
||||
|
||||
this->ui_.follow->setEnabled(false);
|
||||
if (this->ui_.follow->isChecked()) {
|
||||
if (this->ui_.follow->isChecked())
|
||||
{
|
||||
currentUser->followUser(this->userId_, reenableFollowCheckbox);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
currentUser->unfollowUser(this->userId_,
|
||||
reenableFollowCheckbox);
|
||||
}
|
||||
@@ -218,7 +233,8 @@ void UserInfoPopup::installEvents()
|
||||
QObject::connect(
|
||||
this->ui_.ignore, &QCheckBox::stateChanged,
|
||||
[this, ignoreNext, hack](int) mutable {
|
||||
if (*ignoreNext) {
|
||||
if (*ignoreNext)
|
||||
{
|
||||
*ignoreNext = false;
|
||||
return;
|
||||
}
|
||||
@@ -226,24 +242,31 @@ void UserInfoPopup::installEvents()
|
||||
this->ui_.ignore->setEnabled(false);
|
||||
|
||||
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
||||
if (this->ui_.ignore->isChecked()) {
|
||||
if (this->ui_.ignore->isChecked())
|
||||
{
|
||||
currentUser->ignoreByID(
|
||||
this->userId_, this->userName_,
|
||||
[=](auto result, const auto &message) mutable {
|
||||
if (hack.lock()) {
|
||||
if (result == IgnoreResult_Failed) {
|
||||
if (hack.lock())
|
||||
{
|
||||
if (result == IgnoreResult_Failed)
|
||||
{
|
||||
*ignoreNext = true;
|
||||
this->ui_.ignore->setChecked(false);
|
||||
}
|
||||
this->ui_.ignore->setEnabled(true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
currentUser->unignoreByID(
|
||||
this->userId_, this->userName_,
|
||||
[=](auto result, const auto &message) mutable {
|
||||
if (hack.lock()) {
|
||||
if (result == UnignoreResult_Failed) {
|
||||
if (hack.lock())
|
||||
{
|
||||
if (result == UnignoreResult_Failed)
|
||||
{
|
||||
*ignoreNext = true;
|
||||
this->ui_.ignore->setChecked(true);
|
||||
}
|
||||
@@ -259,24 +282,32 @@ void UserInfoPopup::installEvents()
|
||||
[this](bool checked) mutable {
|
||||
this->ui_.ignoreHighlights->setEnabled(false);
|
||||
|
||||
if (checked) {
|
||||
if (checked)
|
||||
{
|
||||
getApp()->highlights->blacklistedUsers.insertItem(
|
||||
HighlightBlacklistUser{this->userName_, false});
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto &vector =
|
||||
getApp()->highlights->blacklistedUsers.getVector();
|
||||
|
||||
for (int i = 0; i < vector.size(); i++) {
|
||||
if (this->userName_ == vector[i].getPattern()) {
|
||||
for (int i = 0; i < vector.size(); i++)
|
||||
{
|
||||
if (this->userName_ == vector[i].getPattern())
|
||||
{
|
||||
getApp()->highlights->blacklistedUsers.removeItem(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if (getApp()->highlights->blacklistContains(this->userName_)) {
|
||||
if (getApp()->highlights->blacklistContains(this->userName_))
|
||||
{
|
||||
this->ui_.ignoreHighlights->setToolTip(
|
||||
"Name matched by regex");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
}
|
||||
}
|
||||
@@ -329,8 +360,10 @@ void UserInfoPopup::updateUserData()
|
||||
|
||||
// get follow state
|
||||
currentUser->checkFollow(id, [this, hack](auto result) {
|
||||
if (hack.lock()) {
|
||||
if (result != FollowResult_Failed) {
|
||||
if (hack.lock())
|
||||
{
|
||||
if (result != FollowResult_Failed)
|
||||
{
|
||||
this->ui_.follow->setEnabled(true);
|
||||
this->ui_.follow->setChecked(result ==
|
||||
FollowResult_Following);
|
||||
@@ -340,8 +373,10 @@ void UserInfoPopup::updateUserData()
|
||||
|
||||
// get ignore state
|
||||
bool isIgnoring = false;
|
||||
for (const auto &ignoredUser : currentUser->getIgnores()) {
|
||||
if (id == ignoredUser.id) {
|
||||
for (const auto &ignoredUser : currentUser->getIgnores())
|
||||
{
|
||||
if (id == ignoredUser.id)
|
||||
{
|
||||
isIgnoring = true;
|
||||
break;
|
||||
}
|
||||
@@ -350,16 +385,21 @@ void UserInfoPopup::updateUserData()
|
||||
// get ignoreHighlights state
|
||||
bool isIgnoringHighlights = false;
|
||||
const auto &vector = getApp()->highlights->blacklistedUsers.getVector();
|
||||
for (int i = 0; i < vector.size(); i++) {
|
||||
if (this->userName_ == vector[i].getPattern()) {
|
||||
for (int i = 0; i < vector.size(); i++)
|
||||
{
|
||||
if (this->userName_ == vector[i].getPattern())
|
||||
{
|
||||
isIgnoringHighlights = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (getApp()->highlights->blacklistContains(this->userName_) &&
|
||||
!isIgnoringHighlights) {
|
||||
!isIgnoringHighlights)
|
||||
{
|
||||
this->ui_.ignoreHighlights->setToolTip("Name matched by regex");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
}
|
||||
this->ui_.ignore->setEnabled(true);
|
||||
@@ -381,14 +421,17 @@ void UserInfoPopup::loadAvatar(const QUrl &url)
|
||||
auto *reply = manager->get(req);
|
||||
|
||||
QObject::connect(reply, &QNetworkReply::finished, this, [=] {
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
if (reply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
const auto data = reply->readAll();
|
||||
|
||||
// might want to cache the avatar image
|
||||
QPixmap avatar;
|
||||
avatar.loadFromData(data);
|
||||
this->ui_.avatarButton->setPixmap(avatar);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.avatarButton->setPixmap(QPixmap());
|
||||
}
|
||||
});
|
||||
@@ -454,13 +497,17 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||
auto hbox = vbox.emplace<QHBoxLayout>().withoutMargin();
|
||||
hbox->setSpacing(0);
|
||||
|
||||
for (const auto &item : items) {
|
||||
for (const auto &item : items)
|
||||
{
|
||||
auto a = hbox.emplace<EffectLabel2>();
|
||||
a->getLabel().setText(std::get<0>(item));
|
||||
|
||||
if (std::get<0>(item).length() > 1) {
|
||||
if (std::get<0>(item).length() > 1)
|
||||
{
|
||||
a->setScaleIndependantSize(buttonWidth2, buttonHeight);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
a->setScaleIndependantSize(buttonWidth, buttonHeight);
|
||||
}
|
||||
a->setBorderColor(color1);
|
||||
|
||||
Reference in New Issue
Block a user