changed to 80 max column
This commit is contained in:
@@ -19,9 +19,11 @@ EmotePopup::EmotePopup()
|
||||
this->viewEmojis_ = new ChannelView();
|
||||
|
||||
this->viewEmotes_->setOverrideFlags(MessageElement::Flags(
|
||||
MessageElement::Default | MessageElement::AlwaysShow | MessageElement::EmoteImages));
|
||||
MessageElement::Default | MessageElement::AlwaysShow |
|
||||
MessageElement::EmoteImages));
|
||||
this->viewEmojis_->setOverrideFlags(MessageElement::Flags(
|
||||
MessageElement::Default | MessageElement::AlwaysShow | MessageElement::EmoteImages));
|
||||
MessageElement::Default | MessageElement::AlwaysShow |
|
||||
MessageElement::EmoteImages));
|
||||
|
||||
this->viewEmotes_->setEnableScrollingToBottom(false);
|
||||
this->viewEmojis_->setEnableScrollingToBottom(false);
|
||||
@@ -56,7 +58,8 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
|
||||
ChannelPtr emoteChannel(new Channel("", Channel::Type::None));
|
||||
|
||||
auto addEmotes = [&](const EmoteMap &map, const QString &title, const QString &emoteDesc) {
|
||||
auto addEmotes = [&](const EmoteMap &map, const QString &title,
|
||||
const QString &emoteDesc) {
|
||||
// TITLE
|
||||
MessageBuilder builder1;
|
||||
|
||||
@@ -71,8 +74,10 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
builder2.getMessage()->flags |= Message::DisableCompactEmotes;
|
||||
|
||||
for (auto emote : map) {
|
||||
builder2.append((new EmoteElement(emote.second, MessageElement::Flags::AlwaysShow))
|
||||
->setLink(Link(Link::InsertText, emote.first.string)));
|
||||
builder2.append(
|
||||
(new EmoteElement(emote.second,
|
||||
MessageElement::Flags::AlwaysShow))
|
||||
->setLink(Link(Link::InsertText, emote.first.string)));
|
||||
}
|
||||
|
||||
emoteChannel->addMessage(builder2.getMessage());
|
||||
@@ -80,9 +85,10 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
|
||||
auto app = getApp();
|
||||
|
||||
// fourtf: the entire emote manager needs to be refactored so there's no point in trying to
|
||||
// fix this pile of garbage
|
||||
for (const auto &set : app->accounts->twitch.getCurrent()->accessEmotes()->emoteSets) {
|
||||
// fourtf: the entire emote manager needs to be refactored so there's no
|
||||
// point in trying to fix this pile of garbage
|
||||
for (const auto &set :
|
||||
app->accounts->twitch.getCurrent()->accessEmotes()->emoteSets) {
|
||||
// TITLE
|
||||
MessageBuilder builder1;
|
||||
|
||||
@@ -109,18 +115,21 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||
|
||||
for (const auto &emote : set->emotes) {
|
||||
builder2.append(
|
||||
(new EmoteElement(app->emotes->twitch.getOrCreateEmote(emote.id, emote.name),
|
||||
MessageElement::Flags::AlwaysShow))
|
||||
(new EmoteElement(
|
||||
app->emotes->twitch.getOrCreateEmote(emote.id, emote.name),
|
||||
MessageElement::Flags::AlwaysShow))
|
||||
->setLink(Link(Link::InsertText, emote.name.string)));
|
||||
}
|
||||
|
||||
emoteChannel->addMessage(builder2.getMessage());
|
||||
}
|
||||
|
||||
addEmotes(*app->emotes->bttv.accessGlobalEmotes(), "BetterTTV Global Emotes",
|
||||
"BetterTTV Global Emote");
|
||||
addEmotes(*channel->accessBttvEmotes(), "BetterTTV Channel Emotes", "BetterTTV Channel Emote");
|
||||
// addEmotes(*app->emotes->ffz.accessGlobalEmotes(), "FrankerFaceZ Global Emotes",
|
||||
addEmotes(*app->emotes->bttv.accessGlobalEmotes(),
|
||||
"BetterTTV Global Emotes", "BetterTTV Global Emote");
|
||||
addEmotes(*channel->accessBttvEmotes(), "BetterTTV Channel Emotes",
|
||||
"BetterTTV Channel Emote");
|
||||
// addEmotes(*app->emotes->ffz.accessGlobalEmotes(), "FrankerFaceZ Global
|
||||
// Emotes",
|
||||
// "FrankerFaceZ Global Emote");
|
||||
addEmotes(*channel->accessFfzEmotes(), "FrankerFaceZ Channel Emotes",
|
||||
"FrankerFaceZ Channel Emote");
|
||||
@@ -149,7 +158,8 @@ void EmotePopup::loadEmojis()
|
||||
emojis.each([&builder](const auto &key, const auto &value) {
|
||||
builder.append(
|
||||
(new EmoteElement(value->emote, MessageElement::Flags::AlwaysShow))
|
||||
->setLink(Link(Link::Type::InsertText, ":" + value->shortCodes[0] + ":")));
|
||||
->setLink(Link(Link::Type::InsertText,
|
||||
":" + value->shortCodes[0] + ":")));
|
||||
});
|
||||
emojiChannel->addMessage(builder.getMessage());
|
||||
|
||||
|
||||
@@ -16,10 +16,11 @@ LastRunCrashDialog::LastRunCrashDialog()
|
||||
this->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||
this->setWindowTitle("Chatterino");
|
||||
|
||||
auto layout = LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
|
||||
auto layout =
|
||||
LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
|
||||
|
||||
layout.emplace<QLabel>(
|
||||
"The application wasn't terminated properly the last time it was executed.");
|
||||
layout.emplace<QLabel>("The application wasn't terminated properly the "
|
||||
"last time it was executed.");
|
||||
|
||||
layout->addSpacing(16);
|
||||
|
||||
@@ -28,7 +29,8 @@ LastRunCrashDialog::LastRunCrashDialog()
|
||||
|
||||
// auto *installUpdateButton = buttons->addButton("Install Update",
|
||||
// QDialogButtonBox::NoRole); installUpdateButton->setEnabled(false);
|
||||
// QObject::connect(installUpdateButton, &QPushButton::clicked, [this, update]() mutable {
|
||||
// QObject::connect(installUpdateButton, &QPushButton::clicked, [this,
|
||||
// update]() mutable {
|
||||
// auto &updateManager = UpdateManager::getInstance();
|
||||
|
||||
// updateManager.installUpdates();
|
||||
@@ -36,8 +38,10 @@ LastRunCrashDialog::LastRunCrashDialog()
|
||||
// update->setText("Downloading updates...");
|
||||
// });
|
||||
|
||||
auto *okButton = buttons->addButton("Ignore", QDialogButtonBox::ButtonRole::NoRole);
|
||||
QObject::connect(okButton, &QPushButton::clicked, [this] { this->accept(); });
|
||||
auto *okButton =
|
||||
buttons->addButton("Ignore", QDialogButtonBox::ButtonRole::NoRole);
|
||||
QObject::connect(okButton, &QPushButton::clicked,
|
||||
[this] { this->accept(); });
|
||||
|
||||
// Updates
|
||||
// auto updateUpdateLabel = [update]() mutable {
|
||||
@@ -57,28 +61,31 @@ LastRunCrashDialog::LastRunCrashDialog()
|
||||
// update->setText("No update abailable.");
|
||||
// } break;
|
||||
// case UpdateManager::SearchFailed: {
|
||||
// update->setText("Error while searching for update.\nEither the update service
|
||||
// is "
|
||||
// "temporarily down or there is an issue with your
|
||||
// installation.");
|
||||
// update->setText("Error while searching for update.\nEither
|
||||
// the update service is "
|
||||
// "temporarily down or there is an issue
|
||||
// with your installation.");
|
||||
// } break;
|
||||
// case UpdateManager::Downloading: {
|
||||
// update->setText(
|
||||
// "Downloading the update. Chatterino will close once the download is
|
||||
// done.");
|
||||
// "Downloading the update. Chatterino will close once
|
||||
// the download is done.");
|
||||
// } break;
|
||||
// case UpdateManager::DownloadFailed: {
|
||||
// update->setText("Download failed.");
|
||||
// } break;
|
||||
// case UpdateManager::WriteFileFailed: {
|
||||
// update->setText("Writing the update file to the hard drive failed.");
|
||||
// update->setText("Writing the update file to the hard drive
|
||||
// failed.");
|
||||
// } break;
|
||||
// }
|
||||
// };
|
||||
|
||||
// updateUpdateLabel();
|
||||
// this->managedConnect(updateManager.statusUpdated, [updateUpdateLabel](auto) mutable {
|
||||
// postToThread([updateUpdateLabel]() mutable { updateUpdateLabel(); });
|
||||
// this->managedConnect(updateManager.statusUpdated,
|
||||
// [updateUpdateLabel](auto) mutable {
|
||||
// postToThread([updateUpdateLabel]() mutable { updateUpdateLabel();
|
||||
// });
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,10 @@ namespace chatterino {
|
||||
|
||||
namespace {
|
||||
|
||||
void LogInWithCredentials(const std::string &userID, const std::string &username,
|
||||
const std::string &clientID, const std::string &oauthToken)
|
||||
void LogInWithCredentials(const std::string &userID,
|
||||
const std::string &username,
|
||||
const std::string &clientID,
|
||||
const std::string &oauthToken)
|
||||
{
|
||||
QStringList errors;
|
||||
|
||||
@@ -49,12 +51,16 @@ void LogInWithCredentials(const std::string &userID, const std::string &username
|
||||
|
||||
// QMessageBox messageBox;
|
||||
// messageBox.setIcon(QMessageBox::Information);
|
||||
// messageBox.setText("Successfully logged in with user <b>" + qS(username) + "</b>!");
|
||||
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/username", username);
|
||||
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/userID", userID);
|
||||
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/clientID", clientID);
|
||||
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/oauthToken",
|
||||
oauthToken);
|
||||
// messageBox.setText("Successfully logged in with user <b>" +
|
||||
// qS(username) + "</b>!");
|
||||
pajlada::Settings::Setting<std::string>::set(
|
||||
"/accounts/uid" + userID + "/username", username);
|
||||
pajlada::Settings::Setting<std::string>::set(
|
||||
"/accounts/uid" + userID + "/userID", userID);
|
||||
pajlada::Settings::Setting<std::string>::set(
|
||||
"/accounts/uid" + userID + "/clientID", clientID);
|
||||
pajlada::Settings::Setting<std::string>::set(
|
||||
"/accounts/uid" + userID + "/oauthToken", oauthToken);
|
||||
|
||||
getApp()->accounts->twitch.reloadUsers();
|
||||
|
||||
@@ -142,46 +148,59 @@ 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
|
||||
|
||||
this->ui_.buttonUpperRow.addUserButton.setText("Add user");
|
||||
this->ui_.buttonUpperRow.clearFieldsButton.setText("Clear fields");
|
||||
|
||||
this->ui_.buttonUpperRow.layout.addWidget(&this->ui_.buttonUpperRow.addUserButton);
|
||||
this->ui_.buttonUpperRow.layout.addWidget(&this->ui_.buttonUpperRow.clearFieldsButton);
|
||||
this->ui_.buttonUpperRow.layout.addWidget(
|
||||
&this->ui_.buttonUpperRow.addUserButton);
|
||||
this->ui_.buttonUpperRow.layout.addWidget(
|
||||
&this->ui_.buttonUpperRow.clearFieldsButton);
|
||||
|
||||
connect(&this->ui_.buttonUpperRow.clearFieldsButton, &QPushButton::clicked, [=]() {
|
||||
this->ui_.userIDInput.clear();
|
||||
this->ui_.usernameInput.clear();
|
||||
this->ui_.clientIDInput.clear();
|
||||
this->ui_.oauthTokenInput.clear();
|
||||
});
|
||||
connect(&this->ui_.buttonUpperRow.clearFieldsButton, &QPushButton::clicked,
|
||||
[=]() {
|
||||
this->ui_.userIDInput.clear();
|
||||
this->ui_.usernameInput.clear();
|
||||
this->ui_.clientIDInput.clear();
|
||||
this->ui_.oauthTokenInput.clear();
|
||||
});
|
||||
|
||||
connect(&this->ui_.buttonUpperRow.addUserButton, &QPushButton::clicked, [=]() {
|
||||
std::string userID = this->ui_.userIDInput.text().toStdString();
|
||||
std::string username = this->ui_.usernameInput.text().toStdString();
|
||||
std::string clientID = this->ui_.clientIDInput.text().toStdString();
|
||||
std::string oauthToken = this->ui_.oauthTokenInput.text().toStdString();
|
||||
connect(
|
||||
&this->ui_.buttonUpperRow.addUserButton, &QPushButton::clicked, [=]() {
|
||||
std::string userID = this->ui_.userIDInput.text().toStdString();
|
||||
std::string username = this->ui_.usernameInput.text().toStdString();
|
||||
std::string clientID = this->ui_.clientIDInput.text().toStdString();
|
||||
std::string oauthToken =
|
||||
this->ui_.oauthTokenInput.text().toStdString();
|
||||
|
||||
LogInWithCredentials(userID, username, clientID, oauthToken);
|
||||
});
|
||||
LogInWithCredentials(userID, username, clientID, oauthToken);
|
||||
});
|
||||
|
||||
/// Lower button row
|
||||
this->ui_.buttonLowerRow.fillInUserIDButton.setText("Get user ID from username");
|
||||
this->ui_.buttonLowerRow.fillInUserIDButton.setText(
|
||||
"Get user ID from username");
|
||||
|
||||
this->ui_.buttonLowerRow.layout.addWidget(&this->ui_.buttonLowerRow.fillInUserIDButton);
|
||||
this->ui_.buttonLowerRow.layout.addWidget(
|
||||
&this->ui_.buttonLowerRow.fillInUserIDButton);
|
||||
|
||||
connect(&this->ui_.buttonLowerRow.fillInUserIDButton, &QPushButton::clicked, [=]() {
|
||||
const auto onIdFetched = [=](const QString &userID) {
|
||||
this->ui_.userIDInput.setText(userID); //
|
||||
};
|
||||
PartialTwitchUser::byName(this->ui_.usernameInput.text()).getId(onIdFetched, this);
|
||||
});
|
||||
connect(&this->ui_.buttonLowerRow.fillInUserIDButton, &QPushButton::clicked,
|
||||
[=]() {
|
||||
const auto onIdFetched = [=](const QString &userID) {
|
||||
this->ui_.userIDInput.setText(userID); //
|
||||
};
|
||||
PartialTwitchUser::byName(this->ui_.usernameInput.text())
|
||||
.getId(onIdFetched, this);
|
||||
});
|
||||
}
|
||||
|
||||
void AdvancedLoginWidget::refreshButtons()
|
||||
@@ -189,8 +208,10 @@ void AdvancedLoginWidget::refreshButtons()
|
||||
this->ui_.buttonLowerRow.fillInUserIDButton.setEnabled(
|
||||
!this->ui_.usernameInput.text().isEmpty());
|
||||
|
||||
if (this->ui_.userIDInput.text().isEmpty() || this->ui_.usernameInput.text().isEmpty() ||
|
||||
this->ui_.clientIDInput.text().isEmpty() || this->ui_.oauthTokenInput.text().isEmpty()) {
|
||||
if (this->ui_.userIDInput.text().isEmpty() ||
|
||||
this->ui_.usernameInput.text().isEmpty() ||
|
||||
this->ui_.clientIDInput.text().isEmpty() ||
|
||||
this->ui_.oauthTokenInput.text().isEmpty()) {
|
||||
this->ui_.buttonUpperRow.addUserButton.setEnabled(false);
|
||||
} else {
|
||||
this->ui_.buttonUpperRow.addUserButton.setEnabled(true);
|
||||
@@ -214,9 +235,10 @@ LoginWidget::LoginWidget()
|
||||
|
||||
this->ui_.buttonBox.setStandardButtons(QDialogButtonBox::Close);
|
||||
|
||||
QObject::connect(&this->ui_.buttonBox, &QDialogButtonBox::rejected, [this]() {
|
||||
this->close(); //
|
||||
});
|
||||
QObject::connect(&this->ui_.buttonBox, &QDialogButtonBox::rejected,
|
||||
[this]() {
|
||||
this->close(); //
|
||||
});
|
||||
|
||||
this->ui_.mainLayout.addWidget(&this->ui_.buttonBox);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ void LogsPopup::setInfo(ChannelPtr channel, QString userName)
|
||||
this->channel_ = channel;
|
||||
this->userName_ = userName;
|
||||
this->getRoomID();
|
||||
this->setWindowTitle(this->userName_ + "'s logs in #" + this->channel_->getName());
|
||||
this->setWindowTitle(this->userName_ + "'s logs in #" +
|
||||
this->channel_->getName());
|
||||
this->getLogviewerLogs();
|
||||
}
|
||||
|
||||
@@ -49,7 +50,8 @@ void LogsPopup::setMessages(std::vector<MessagePtr> &messages)
|
||||
|
||||
void LogsPopup::getRoomID()
|
||||
{
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
if (twitchChannel == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -78,7 +80,8 @@ void LogsPopup::getRoomID()
|
||||
|
||||
void LogsPopup::getLogviewerLogs()
|
||||
{
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
if (twitchChannel == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -108,12 +111,15 @@ void LogsPopup::getLogviewerLogs()
|
||||
|
||||
// Hacky way to fix the timestamp
|
||||
message.insert(1, "historical=1;");
|
||||
message.insert(1, QString("tmi-sent-ts=%10000;").arg(messageObject["time"].toInt()));
|
||||
message.insert(1, QString("tmi-sent-ts=%10000;")
|
||||
.arg(messageObject["time"].toInt()));
|
||||
message.insert(1, QString("room-id=%1;").arg(this->roomID_));
|
||||
|
||||
MessageParseArgs args;
|
||||
auto ircMessage = Communi::IrcMessage::fromData(message.toUtf8(), nullptr);
|
||||
auto privMsg = static_cast<Communi::IrcPrivateMessage *>(ircMessage);
|
||||
auto ircMessage =
|
||||
Communi::IrcMessage::fromData(message.toUtf8(), nullptr);
|
||||
auto privMsg =
|
||||
static_cast<Communi::IrcPrivateMessage *>(ircMessage);
|
||||
TwitchMessageBuilder builder(this->channel_.get(), privMsg, args);
|
||||
messages.push_back(builder.build());
|
||||
};
|
||||
@@ -127,22 +133,25 @@ void LogsPopup::getLogviewerLogs()
|
||||
|
||||
void LogsPopup::getOverrustleLogs()
|
||||
{
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
if (twitchChannel == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString channelName = twitchChannel->getName();
|
||||
|
||||
QString url = QString("https://overrustlelogs.net/api/v1/stalk/%1/%2.json?limit=500")
|
||||
.arg(channelName, this->userName_);
|
||||
QString url =
|
||||
QString("https://overrustlelogs.net/api/v1/stalk/%1/%2.json?limit=500")
|
||||
.arg(channelName, this->userName_);
|
||||
|
||||
NetworkRequest req(url);
|
||||
req.setCaller(QThread::currentThread());
|
||||
req.onError([this, channelName](int errorCode) {
|
||||
this->close();
|
||||
QMessageBox *box = new QMessageBox(QMessageBox::Information, "Error getting logs",
|
||||
"No logs could be found for channel " + channelName);
|
||||
QMessageBox *box = new QMessageBox(
|
||||
QMessageBox::Information, "Error getting logs",
|
||||
"No logs could be found for channel " + channelName);
|
||||
box->setAttribute(Qt::WA_DeleteOnClose);
|
||||
box->show();
|
||||
box->raise();
|
||||
@@ -157,15 +166,18 @@ void LogsPopup::getOverrustleLogs()
|
||||
QJsonArray dataMessages = data.value("lines").toArray();
|
||||
for (auto i : dataMessages) {
|
||||
QJsonObject singleMessage = i.toObject();
|
||||
QTime timeStamp =
|
||||
QDateTime::fromSecsSinceEpoch(singleMessage.value("timestamp").toInt()).time();
|
||||
QTime timeStamp = QDateTime::fromSecsSinceEpoch(
|
||||
singleMessage.value("timestamp").toInt())
|
||||
.time();
|
||||
|
||||
MessagePtr message(new Message);
|
||||
message->addElement(new TimestampElement(timeStamp));
|
||||
message->addElement(new TextElement(this->userName_, MessageElement::Username,
|
||||
message->addElement(new TextElement(this->userName_,
|
||||
MessageElement::Username,
|
||||
MessageColor::System));
|
||||
message->addElement(new TextElement(singleMessage.value("text").toString(),
|
||||
MessageElement::Text, MessageColor::Text));
|
||||
message->addElement(
|
||||
new TextElement(singleMessage.value("text").toString(),
|
||||
MessageElement::Text, MessageColor::Text));
|
||||
messages.push_back(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ void NotificationPopup::updatePosition()
|
||||
|
||||
switch (location) {
|
||||
case BottomRight: {
|
||||
this->move(rect.right() - this->width(), rect.bottom() - this->height());
|
||||
this->move(rect.right() - this->width(),
|
||||
rect.bottom() - this->height());
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ QualityPopup::QualityPopup(const QString &_channelName, QStringList options)
|
||||
QObject::connect(&this->ui_.cancelButton, &QPushButton::clicked, this,
|
||||
&QualityPopup::cancelButtonClicked);
|
||||
|
||||
this->ui_.buttonBox.addButton(&this->ui_.okButton, QDialogButtonBox::ButtonRole::AcceptRole);
|
||||
this->ui_.buttonBox.addButton(&this->ui_.okButton,
|
||||
QDialogButtonBox::ButtonRole::AcceptRole);
|
||||
this->ui_.buttonBox.addButton(&this->ui_.cancelButton,
|
||||
QDialogButtonBox::ButtonRole::RejectRole);
|
||||
|
||||
|
||||
@@ -33,17 +33,20 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
auto vbox = obj.setLayoutType<QVBoxLayout>();
|
||||
|
||||
// channel_btn
|
||||
auto channel_btn = vbox.emplace<QRadioButton>("Channel").assign(&this->ui_.twitch.channel);
|
||||
auto channel_lbl = vbox.emplace<QLabel>("Join a twitch channel by its name.").hidden();
|
||||
auto channel_btn = vbox.emplace<QRadioButton>("Channel").assign(
|
||||
&this->ui_.twitch.channel);
|
||||
auto channel_lbl =
|
||||
vbox.emplace<QLabel>("Join a twitch channel by its name.").hidden();
|
||||
channel_lbl->setWordWrap(true);
|
||||
auto channel_edit =
|
||||
vbox.emplace<QLineEdit>().hidden().assign(&this->ui_.twitch.channelName);
|
||||
auto channel_edit = vbox.emplace<QLineEdit>().hidden().assign(
|
||||
&this->ui_.twitch.channelName);
|
||||
|
||||
QObject::connect(channel_btn.getElement(), &QRadioButton::toggled,
|
||||
[=](bool enabled) mutable {
|
||||
if (enabled) {
|
||||
channel_edit->setFocus();
|
||||
channel_edit->setSelection(0, channel_edit->text().length());
|
||||
channel_edit->setSelection(
|
||||
0, channel_edit->text().length());
|
||||
}
|
||||
|
||||
channel_edit->setVisible(enabled);
|
||||
@@ -54,50 +57,60 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
channel_edit->installEventFilter(&this->tabFilter_);
|
||||
|
||||
// whispers_btn
|
||||
auto whispers_btn =
|
||||
vbox.emplace<QRadioButton>("Whispers").assign(&this->ui_.twitch.whispers);
|
||||
auto whispers_btn = vbox.emplace<QRadioButton>("Whispers")
|
||||
.assign(&this->ui_.twitch.whispers);
|
||||
auto whispers_lbl =
|
||||
vbox.emplace<QLabel>("Shows the whispers that you receive while chatterino is running.")
|
||||
vbox.emplace<QLabel>("Shows the whispers that you receive while "
|
||||
"chatterino is running.")
|
||||
.hidden();
|
||||
|
||||
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").assign(&this->ui_.twitch.mentions);
|
||||
auto mentions_btn = vbox.emplace<QRadioButton>("Mentions")
|
||||
.assign(&this->ui_.twitch.mentions);
|
||||
auto mentions_lbl =
|
||||
vbox.emplace<QLabel>("Shows all the messages that highlight you from any channel.")
|
||||
vbox.emplace<QLabel>("Shows all the messages that highlight you "
|
||||
"from any channel.")
|
||||
.hidden();
|
||||
|
||||
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").assign(&this->ui_.twitch.watching);
|
||||
auto watching_btn = vbox.emplace<QRadioButton>("Watching")
|
||||
.assign(&this->ui_.twitch.watching);
|
||||
auto watching_lbl =
|
||||
vbox.emplace<QLabel>("Requires the chatterino browser extension.").hidden();
|
||||
vbox.emplace<QLabel>("Requires the chatterino browser extension.")
|
||||
.hidden();
|
||||
|
||||
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);
|
||||
|
||||
// tabbing order
|
||||
QWidget::setTabOrder(watching_btn.getElement(), channel_btn.getElement());
|
||||
QWidget::setTabOrder(channel_btn.getElement(), whispers_btn.getElement());
|
||||
QWidget::setTabOrder(whispers_btn.getElement(), mentions_btn.getElement());
|
||||
QWidget::setTabOrder(mentions_btn.getElement(), watching_btn.getElement());
|
||||
QWidget::setTabOrder(watching_btn.getElement(),
|
||||
channel_btn.getElement());
|
||||
QWidget::setTabOrder(channel_btn.getElement(),
|
||||
whispers_btn.getElement());
|
||||
QWidget::setTabOrder(whispers_btn.getElement(),
|
||||
mentions_btn.getElement());
|
||||
QWidget::setTabOrder(mentions_btn.getElement(),
|
||||
watching_btn.getElement());
|
||||
|
||||
// tab
|
||||
NotebookTab *tab = notebook->addPage(obj.getElement());
|
||||
@@ -117,12 +130,15 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
|
||||
layout->setStretchFactor(notebook.getElement(), 1);
|
||||
|
||||
auto buttons = layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
|
||||
auto buttons =
|
||||
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->setScaleIndependantSize(300, 210);
|
||||
@@ -133,7 +149,8 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
auto *shortcut_ok = new QShortcut(QKeySequence("Return"), this);
|
||||
QObject::connect(shortcut_ok, &QShortcut::activated, [=] { this->ok(); });
|
||||
auto *shortcut_cancel = new QShortcut(QKeySequence("Esc"), this);
|
||||
QObject::connect(shortcut_cancel, &QShortcut::activated, [=] { this->close(); });
|
||||
QObject::connect(shortcut_cancel, &QShortcut::activated,
|
||||
[=] { this->close(); });
|
||||
}
|
||||
|
||||
void SelectChannelDialog::ok()
|
||||
@@ -188,7 +205,8 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
||||
switch (this->ui_.notebook->getSelectedIndex()) {
|
||||
case TAB_TWITCH: {
|
||||
if (this->ui_.twitch.channel->isChecked()) {
|
||||
return app->twitch.server->getOrAddChannel(this->ui_.twitch.channelName->text());
|
||||
return app->twitch.server->getOrAddChannel(
|
||||
this->ui_.twitch.channelName->text());
|
||||
} else if (this->ui_.twitch.watching->isChecked()) {
|
||||
return app->twitch.server->watchingChannel;
|
||||
} else if (this->ui_.twitch.mentions->isChecked()) {
|
||||
@@ -207,7 +225,8 @@ bool SelectChannelDialog::hasSeletedChannel() const
|
||||
return this->hasSelectedChannel_;
|
||||
}
|
||||
|
||||
bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *event)
|
||||
bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
|
||||
QEvent *event)
|
||||
{
|
||||
auto *widget = (QWidget *)watched;
|
||||
|
||||
@@ -225,7 +244,8 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *eve
|
||||
return false;
|
||||
} 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) &&
|
||||
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) {
|
||||
this->dialog->ui_.twitch.whispers->setFocus();
|
||||
@@ -234,9 +254,11 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *eve
|
||||
widget->nextInFocusChain()->setFocus();
|
||||
}
|
||||
return true;
|
||||
} else if (((event_key->key() == Qt::Key_Tab || event_key->key() == Qt::Key_Backtab) &&
|
||||
} 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)) {
|
||||
((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;
|
||||
@@ -253,7 +275,8 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *eve
|
||||
return true;
|
||||
} 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) &&
|
||||
if ((event_key->key() == Qt::Key_Backtab ||
|
||||
event_key->key() == Qt::Key_Down) &&
|
||||
event_key->modifiers() == Qt::NoModifier) {
|
||||
return true;
|
||||
}
|
||||
@@ -272,9 +295,11 @@ void SelectChannelDialog::themeChangedEvent()
|
||||
BaseWindow::themeChangedEvent();
|
||||
|
||||
if (this->theme->isLightTheme()) {
|
||||
this->setStyleSheet("QRadioButton { color: #000 } QLabel { color: #000 }");
|
||||
this->setStyleSheet(
|
||||
"QRadioButton { color: #000 } QLabel { color: #000 }");
|
||||
} else {
|
||||
this->setStyleSheet("QRadioButton { color: #fff } QLabel { color: #fff }");
|
||||
this->setStyleSheet(
|
||||
"QRadioButton { color: #fff } QLabel { color: #fff }");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,12 +49,16 @@ void SettingsDialog::initUi()
|
||||
// right side layout
|
||||
auto right = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
||||
{
|
||||
right.emplace<QStackedLayout>().assign(&this->ui_.pageStack).withoutMargin();
|
||||
right.emplace<QStackedLayout>()
|
||||
.assign(&this->ui_.pageStack)
|
||||
.withoutMargin();
|
||||
|
||||
auto buttons = right.emplace<QDialogButtonBox>(Qt::Horizontal);
|
||||
{
|
||||
this->ui_.okButton = buttons->addButton("Ok", QDialogButtonBox::YesRole);
|
||||
this->ui_.cancelButton = buttons->addButton("Cancel", QDialogButtonBox::NoRole);
|
||||
this->ui_.okButton =
|
||||
buttons->addButton("Ok", QDialogButtonBox::YesRole);
|
||||
this->ui_.cancelButton =
|
||||
buttons->addButton("Cancel", QDialogButtonBox::NoRole);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +66,8 @@ void SettingsDialog::initUi()
|
||||
this->ui_.tabContainerContainer->setObjectName("tabWidget");
|
||||
this->ui_.pageStack->setObjectName("pages");
|
||||
|
||||
QObject::connect(this->ui_.okButton, &QPushButton::clicked, this, &SettingsDialog::onOkClicked);
|
||||
QObject::connect(this->ui_.okButton, &QPushButton::clicked, this,
|
||||
&SettingsDialog::onOkClicked);
|
||||
QObject::connect(this->ui_.cancelButton, &QPushButton::clicked, this,
|
||||
&SettingsDialog::onCancelClicked);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ public:
|
||||
Accounts,
|
||||
};
|
||||
|
||||
static void showDialog(PreferredTab preferredTab = PreferredTab::NoPreference);
|
||||
static void showDialog(
|
||||
PreferredTab preferredTab = PreferredTab::NoPreference);
|
||||
|
||||
protected:
|
||||
virtual void scaleChangedEvent(float newDpi) override;
|
||||
|
||||
@@ -15,13 +15,16 @@ TextInputDialog::TextInputDialog(QWidget *parent)
|
||||
this->buttonBox_.addWidget(&okButton_);
|
||||
this->buttonBox_.addWidget(&cancelButton_);
|
||||
|
||||
QObject::connect(&this->okButton_, SIGNAL(clicked()), this, SLOT(okButtonClicked()));
|
||||
QObject::connect(&this->cancelButton_, SIGNAL(clicked()), this, SLOT(cancelButtonClicked()));
|
||||
QObject::connect(&this->okButton_, SIGNAL(clicked()), this,
|
||||
SLOT(okButtonClicked()));
|
||||
QObject::connect(&this->cancelButton_, SIGNAL(clicked()), this,
|
||||
SLOT(cancelButtonClicked()));
|
||||
|
||||
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
this->setWindowFlags((this->windowFlags() & ~(Qt::WindowContextHelpButtonHint)) | Qt::Dialog |
|
||||
Qt::MSWindowsFixedSizeDialogHint);
|
||||
this->setWindowFlags(
|
||||
(this->windowFlags() & ~(Qt::WindowContextHelpButtonHint)) |
|
||||
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
|
||||
}
|
||||
|
||||
QString TextInputDialog::getText() const
|
||||
|
||||
@@ -11,27 +11,32 @@
|
||||
namespace chatterino {
|
||||
|
||||
UpdateDialog::UpdateDialog()
|
||||
: BaseWindow(nullptr, BaseWindow::Flags(BaseWindow::Frameless | BaseWindow::TopMost |
|
||||
BaseWindow::EnableCustomFrame))
|
||||
: BaseWindow(nullptr,
|
||||
BaseWindow::Flags(BaseWindow::Frameless | BaseWindow::TopMost |
|
||||
BaseWindow::EnableCustomFrame))
|
||||
{
|
||||
auto layout = LayoutCreator<UpdateDialog>(this).setLayoutType<QVBoxLayout>();
|
||||
auto layout =
|
||||
LayoutCreator<UpdateDialog>(this).setLayoutType<QVBoxLayout>();
|
||||
|
||||
layout.emplace<Label>("You shouldn't be seeing this dialog.").assign(&this->ui_.label);
|
||||
layout.emplace<Label>("You shouldn't be seeing this dialog.")
|
||||
.assign(&this->ui_.label);
|
||||
|
||||
auto buttons = layout.emplace<QDialogButtonBox>();
|
||||
auto install = buttons->addButton("Install", QDialogButtonBox::AcceptRole);
|
||||
this->ui_.installButton = install;
|
||||
auto dismiss = buttons->addButton("Dismiss", QDialogButtonBox::RejectRole);
|
||||
|
||||
QObject::connect(install, &QPushButton::clicked, this, [this] { this->close(); });
|
||||
QObject::connect(install, &QPushButton::clicked, this,
|
||||
[this] { this->close(); });
|
||||
QObject::connect(dismiss, &QPushButton::clicked, this, [this] {
|
||||
this->buttonClicked.invoke(Dismiss);
|
||||
this->close();
|
||||
});
|
||||
|
||||
this->updateStatusChanged(Updates::getInstance().getStatus());
|
||||
this->connections_.managedConnect(Updates::getInstance().statusUpdated,
|
||||
[this](auto status) { this->updateStatusChanged(status); });
|
||||
this->connections_.managedConnect(
|
||||
Updates::getInstance().statusUpdated,
|
||||
[this](auto status) { this->updateStatusChanged(status); });
|
||||
}
|
||||
|
||||
void UpdateDialog::updateStatusChanged(Updates::Status status)
|
||||
@@ -41,7 +46,8 @@ void UpdateDialog::updateStatusChanged(Updates::Status status)
|
||||
switch (status) {
|
||||
case Updates::UpdateAvailable: {
|
||||
this->ui_.label->setText(
|
||||
QString("An update (%1) is available.\n\nDo you want to download and install it?")
|
||||
QString("An update (%1) is available.\n\nDo you want to "
|
||||
"download and install it?")
|
||||
.arg(Updates::getInstance().getOnlineVersion()));
|
||||
} break;
|
||||
|
||||
@@ -50,8 +56,9 @@ void UpdateDialog::updateStatusChanged(Updates::Status status)
|
||||
} break;
|
||||
|
||||
case Updates::Downloading: {
|
||||
this->ui_.label->setText("Downloading updates.\n\nChatterino will restart "
|
||||
"automatically when the download is done.");
|
||||
this->ui_.label->setText(
|
||||
"Downloading updates.\n\nChatterino will restart "
|
||||
"automatically when the download is done.");
|
||||
} break;
|
||||
|
||||
case Updates::DownloadFailed: {
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
namespace chatterino {
|
||||
|
||||
UserInfoPopup::UserInfoPopup()
|
||||
: BaseWindow(nullptr, BaseWindow::Flags(BaseWindow::Frameless | BaseWindow::FramelessDraggable))
|
||||
: BaseWindow(nullptr, BaseWindow::Flags(BaseWindow::Frameless |
|
||||
BaseWindow::FramelessDraggable))
|
||||
, hack_(new bool)
|
||||
{
|
||||
this->setStayInScreenRect(true);
|
||||
@@ -38,17 +39,21 @@ UserInfoPopup::UserInfoPopup()
|
||||
|
||||
auto app = getApp();
|
||||
|
||||
auto layout = LayoutCreator<UserInfoPopup>(this).setLayoutType<QVBoxLayout>();
|
||||
auto layout =
|
||||
LayoutCreator<UserInfoPopup>(this).setLayoutType<QVBoxLayout>();
|
||||
|
||||
// first line
|
||||
auto head = layout.emplace<QHBoxLayout>().withoutMargin();
|
||||
{
|
||||
// avatar
|
||||
auto avatar = head.emplace<RippleEffectButton>(nullptr).assign(&this->ui_.avatarButton);
|
||||
auto avatar = head.emplace<RippleEffectButton>(nullptr).assign(
|
||||
&this->ui_.avatarButton);
|
||||
avatar->setScaleIndependantSize(100, 100);
|
||||
QObject::connect(avatar.getElement(), &RippleEffectButton::clicked, [this] {
|
||||
QDesktopServices::openUrl(QUrl("https://twitch.tv/" + this->userName_));
|
||||
});
|
||||
QObject::connect(avatar.getElement(), &RippleEffectButton::clicked,
|
||||
[this] {
|
||||
QDesktopServices::openUrl(
|
||||
QUrl("https://twitch.tv/" + this->userName_));
|
||||
});
|
||||
|
||||
// items on the right
|
||||
auto vbox = head.emplace<QVBoxLayout>();
|
||||
@@ -59,8 +64,10 @@ UserInfoPopup::UserInfoPopup()
|
||||
font.setBold(true);
|
||||
name->setFont(font);
|
||||
vbox.emplace<Label>(TEXT_VIEWS).assign(&this->ui_.viewCountLabel);
|
||||
vbox.emplace<Label>(TEXT_FOLLOWERS).assign(&this->ui_.followerCountLabel);
|
||||
vbox.emplace<Label>(TEXT_CREATED).assign(&this->ui_.createdDateLabel);
|
||||
vbox.emplace<Label>(TEXT_FOLLOWERS)
|
||||
.assign(&this->ui_.followerCountLabel);
|
||||
vbox.emplace<Label>(TEXT_CREATED)
|
||||
.assign(&this->ui_.createdDateLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +80,8 @@ UserInfoPopup::UserInfoPopup()
|
||||
|
||||
user.emplace<QCheckBox>("Follow").assign(&this->ui_.follow);
|
||||
user.emplace<QCheckBox>("Ignore").assign(&this->ui_.ignore);
|
||||
user.emplace<QCheckBox>("Ignore highlights").assign(&this->ui_.ignoreHighlights);
|
||||
user.emplace<QCheckBox>("Ignore highlights")
|
||||
.assign(&this->ui_.ignoreHighlights);
|
||||
auto viewLogs = user.emplace<RippleEffectLabel2>(this);
|
||||
viewLogs->getLabel().setText("Logs");
|
||||
|
||||
@@ -86,32 +94,39 @@ UserInfoPopup::UserInfoPopup()
|
||||
|
||||
user->addStretch(1);
|
||||
|
||||
QObject::connect(viewLogs.getElement(), &RippleEffectButton::clicked, [this] {
|
||||
auto logs = new LogsPopup();
|
||||
logs->setInfo(this->channel_, this->userName_);
|
||||
logs->setAttribute(Qt::WA_DeleteOnClose);
|
||||
logs->show();
|
||||
});
|
||||
QObject::connect(viewLogs.getElement(), &RippleEffectButton::clicked,
|
||||
[this] {
|
||||
auto logs = new LogsPopup();
|
||||
logs->setInfo(this->channel_, this->userName_);
|
||||
logs->setAttribute(Qt::WA_DeleteOnClose);
|
||||
logs->show();
|
||||
});
|
||||
|
||||
QObject::connect(mod.getElement(), &RippleEffectButton::clicked,
|
||||
[this] { this->channel_->sendMessage("/mod " + this->userName_); });
|
||||
QObject::connect(unmod.getElement(), &RippleEffectButton::clicked,
|
||||
[this] { this->channel_->sendMessage("/unmod " + this->userName_); });
|
||||
QObject::connect(
|
||||
mod.getElement(), &RippleEffectButton::clicked,
|
||||
[this] { this->channel_->sendMessage("/mod " + this->userName_); });
|
||||
QObject::connect(
|
||||
unmod.getElement(), &RippleEffectButton::clicked, [this] {
|
||||
this->channel_->sendMessage("/unmod " + this->userName_);
|
||||
});
|
||||
|
||||
// userstate
|
||||
this->userStateChanged_.connect([this, mod, unmod]() mutable {
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
qDebug() << this->userName_;
|
||||
|
||||
bool isMyself =
|
||||
QString::compare(getApp()->accounts->twitch.getCurrent()->getUserName(),
|
||||
this->userName_, Qt::CaseInsensitive) == 0;
|
||||
QString::compare(
|
||||
getApp()->accounts->twitch.getCurrent()->getUserName(),
|
||||
this->userName_, Qt::CaseInsensitive) == 0;
|
||||
|
||||
mod->setVisible(twitchChannel->isBroadcaster() && !isMyself);
|
||||
unmod->setVisible((twitchChannel->isBroadcaster() && !isMyself) ||
|
||||
(twitchChannel->isMod() && isMyself));
|
||||
unmod->setVisible(
|
||||
(twitchChannel->isBroadcaster() && !isMyself) ||
|
||||
(twitchChannel->isMod() && isMyself));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -124,7 +139,8 @@ UserInfoPopup::UserInfoPopup()
|
||||
auto timeout = moderation.emplace<TimeoutWidget>();
|
||||
|
||||
this->userStateChanged_.connect([this, lineMod, timeout]() mutable {
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
TwitchChannel *twitchChannel =
|
||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
lineMod->setVisible(twitchChannel->hasModRights());
|
||||
@@ -145,12 +161,14 @@ UserInfoPopup::UserInfoPopup()
|
||||
} break;
|
||||
case TimeoutWidget::Unban: {
|
||||
if (this->channel_) {
|
||||
this->channel_->sendMessage("/unban " + this->userName_);
|
||||
this->channel_->sendMessage("/unban " +
|
||||
this->userName_);
|
||||
}
|
||||
} break;
|
||||
case TimeoutWidget::Timeout: {
|
||||
if (this->channel_) {
|
||||
this->channel_->sendMessage("/timeout " + this->userName_ + " " +
|
||||
this->channel_->sendMessage("/timeout " +
|
||||
this->userName_ + " " +
|
||||
QString::number(arg));
|
||||
}
|
||||
} break;
|
||||
@@ -175,29 +193,33 @@ void UserInfoPopup::installEvents()
|
||||
std::weak_ptr<bool> hack = this->hack_;
|
||||
|
||||
// follow
|
||||
QObject::connect(this->ui_.follow, &QCheckBox::stateChanged, [this](int) mutable {
|
||||
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
||||
QObject::connect(
|
||||
this->ui_.follow, &QCheckBox::stateChanged, [this](int) mutable {
|
||||
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
||||
|
||||
QUrl requestUrl("https://api.twitch.tv/kraken/users/" + currentUser->getUserId() +
|
||||
"/follows/channels/" + this->userId_);
|
||||
QUrl requestUrl("https://api.twitch.tv/kraken/users/" +
|
||||
currentUser->getUserId() + "/follows/channels/" +
|
||||
this->userId_);
|
||||
|
||||
const auto reenableFollowCheckbox = [this] {
|
||||
this->ui_.follow->setEnabled(true); //
|
||||
};
|
||||
const auto reenableFollowCheckbox = [this] {
|
||||
this->ui_.follow->setEnabled(true); //
|
||||
};
|
||||
|
||||
this->ui_.follow->setEnabled(false);
|
||||
if (this->ui_.follow->isChecked()) {
|
||||
currentUser->followUser(this->userId_, reenableFollowCheckbox);
|
||||
} else {
|
||||
currentUser->unfollowUser(this->userId_, reenableFollowCheckbox);
|
||||
}
|
||||
});
|
||||
this->ui_.follow->setEnabled(false);
|
||||
if (this->ui_.follow->isChecked()) {
|
||||
currentUser->followUser(this->userId_, reenableFollowCheckbox);
|
||||
} else {
|
||||
currentUser->unfollowUser(this->userId_,
|
||||
reenableFollowCheckbox);
|
||||
}
|
||||
});
|
||||
|
||||
std::shared_ptr<bool> ignoreNext = std::make_shared<bool>(false);
|
||||
|
||||
// ignore
|
||||
QObject::connect(
|
||||
this->ui_.ignore, &QCheckBox::stateChanged, [this, ignoreNext, hack](int) mutable {
|
||||
this->ui_.ignore, &QCheckBox::stateChanged,
|
||||
[this, ignoreNext, hack](int) mutable {
|
||||
if (*ignoreNext) {
|
||||
*ignoreNext = false;
|
||||
return;
|
||||
@@ -207,54 +229,60 @@ void UserInfoPopup::installEvents()
|
||||
|
||||
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
||||
if (this->ui_.ignore->isChecked()) {
|
||||
currentUser->ignoreByID(this->userId_, this->userName_,
|
||||
[=](auto result, const auto &message) mutable {
|
||||
if (hack.lock()) {
|
||||
if (result == IgnoreResult_Failed) {
|
||||
*ignoreNext = true;
|
||||
this->ui_.ignore->setChecked(false);
|
||||
}
|
||||
this->ui_.ignore->setEnabled(true);
|
||||
}
|
||||
});
|
||||
currentUser->ignoreByID(
|
||||
this->userId_, this->userName_,
|
||||
[=](auto result, const auto &message) mutable {
|
||||
if (hack.lock()) {
|
||||
if (result == IgnoreResult_Failed) {
|
||||
*ignoreNext = true;
|
||||
this->ui_.ignore->setChecked(false);
|
||||
}
|
||||
this->ui_.ignore->setEnabled(true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
currentUser->unignoreByID(this->userId_, this->userName_,
|
||||
[=](auto result, const auto &message) mutable {
|
||||
if (hack.lock()) {
|
||||
if (result == UnignoreResult_Failed) {
|
||||
*ignoreNext = true;
|
||||
this->ui_.ignore->setChecked(true);
|
||||
}
|
||||
this->ui_.ignore->setEnabled(true);
|
||||
}
|
||||
});
|
||||
currentUser->unignoreByID(
|
||||
this->userId_, this->userName_,
|
||||
[=](auto result, const auto &message) mutable {
|
||||
if (hack.lock()) {
|
||||
if (result == UnignoreResult_Failed) {
|
||||
*ignoreNext = true;
|
||||
this->ui_.ignore->setChecked(true);
|
||||
}
|
||||
this->ui_.ignore->setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// ignore highlights
|
||||
QObject::connect(this->ui_.ignoreHighlights, &QCheckBox::clicked, [this](bool checked) mutable {
|
||||
this->ui_.ignoreHighlights->setEnabled(false);
|
||||
QObject::connect(
|
||||
this->ui_.ignoreHighlights, &QCheckBox::clicked,
|
||||
[this](bool checked) mutable {
|
||||
this->ui_.ignoreHighlights->setEnabled(false);
|
||||
|
||||
if (checked) {
|
||||
getApp()->highlights->blacklistedUsers.insertItem(
|
||||
HighlightBlacklistUser{this->userName_, false});
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
} else {
|
||||
const auto &vector = getApp()->highlights->blacklistedUsers.getVector();
|
||||
if (checked) {
|
||||
getApp()->highlights->blacklistedUsers.insertItem(
|
||||
HighlightBlacklistUser{this->userName_, false});
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
} else {
|
||||
const auto &vector =
|
||||
getApp()->highlights->blacklistedUsers.getVector();
|
||||
|
||||
for (int i = 0; i < vector.size(); i++) {
|
||||
if (this->userName_ == vector[i].getPattern()) {
|
||||
getApp()->highlights->blacklistedUsers.removeItem(i);
|
||||
i--;
|
||||
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_)) {
|
||||
this->ui_.ignoreHighlights->setToolTip(
|
||||
"Name matched by regex");
|
||||
} else {
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
}
|
||||
}
|
||||
if (getApp()->highlights->blacklistContains(this->userName_)) {
|
||||
this->ui_.ignoreHighlights->setToolTip("Name matched by regex");
|
||||
} else {
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void UserInfoPopup::setData(const QString &name, const ChannelPtr &channel)
|
||||
@@ -285,12 +313,14 @@ void UserInfoPopup::updateUserData()
|
||||
|
||||
request.onSuccess([this](auto result) -> Outcome {
|
||||
auto obj = result.parseJson();
|
||||
this->ui_.followerCountLabel->setText(TEXT_FOLLOWERS +
|
||||
QString::number(obj.value("followers").toInt()));
|
||||
this->ui_.viewCountLabel->setText(TEXT_VIEWS +
|
||||
QString::number(obj.value("views").toInt()));
|
||||
this->ui_.followerCountLabel->setText(
|
||||
TEXT_FOLLOWERS +
|
||||
QString::number(obj.value("followers").toInt()));
|
||||
this->ui_.viewCountLabel->setText(
|
||||
TEXT_VIEWS + QString::number(obj.value("views").toInt()));
|
||||
this->ui_.createdDateLabel->setText(
|
||||
TEXT_CREATED + obj.value("created_at").toString().section("T", 0, 0));
|
||||
TEXT_CREATED +
|
||||
obj.value("created_at").toString().section("T", 0, 0));
|
||||
|
||||
this->loadAvatar(QUrl(obj.value("logo").toString()));
|
||||
|
||||
@@ -304,7 +334,8 @@ void UserInfoPopup::updateUserData()
|
||||
if (hack.lock()) {
|
||||
if (result != FollowResult_Failed) {
|
||||
this->ui_.follow->setEnabled(true);
|
||||
this->ui_.follow->setChecked(result == FollowResult_Following);
|
||||
this->ui_.follow->setChecked(result ==
|
||||
FollowResult_Following);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -327,7 +358,8 @@ void UserInfoPopup::updateUserData()
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (getApp()->highlights->blacklistContains(this->userName_) && !isIgnoringHighlights) {
|
||||
if (getApp()->highlights->blacklistContains(this->userName_) &&
|
||||
!isIgnoringHighlights) {
|
||||
this->ui_.ignoreHighlights->setToolTip("Name matched by regex");
|
||||
} else {
|
||||
this->ui_.ignoreHighlights->setEnabled(true);
|
||||
@@ -370,7 +402,9 @@ void UserInfoPopup::loadAvatar(const QUrl &url)
|
||||
UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||
: BaseWidget(nullptr)
|
||||
{
|
||||
auto layout = LayoutCreator<TimeoutWidget>(this).setLayoutType<QHBoxLayout>().withoutMargin();
|
||||
auto layout = LayoutCreator<TimeoutWidget>(this)
|
||||
.setLayoutType<QHBoxLayout>()
|
||||
.withoutMargin();
|
||||
|
||||
QColor color1(255, 255, 255, 80);
|
||||
QColor color2(255, 255, 255, 0);
|
||||
@@ -381,7 +415,8 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||
|
||||
layout->setSpacing(16);
|
||||
|
||||
auto addButton = [&](Action action, const QString &text, const QPixmap &pixmap) {
|
||||
auto addButton = [&](Action action, const QString &text,
|
||||
const QPixmap &pixmap) {
|
||||
auto vbox = layout.emplace<QVBoxLayout>().withoutMargin();
|
||||
{
|
||||
auto title = vbox.emplace<QHBoxLayout>().withoutMargin();
|
||||
@@ -399,9 +434,11 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||
button->setScaleIndependantSize(buttonHeight, buttonHeight);
|
||||
button->setBorderColor(QColor(255, 255, 255, 127));
|
||||
|
||||
QObject::connect(button.getElement(), &RippleEffectButton::clicked, [this, action] {
|
||||
this->buttonClicked.invoke(std::make_pair(action, -1));
|
||||
});
|
||||
QObject::connect(
|
||||
button.getElement(), &RippleEffectButton::clicked,
|
||||
[this, action] {
|
||||
this->buttonClicked.invoke(std::make_pair(action, -1));
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -431,11 +468,11 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
||||
}
|
||||
a->setBorderColor(color1);
|
||||
|
||||
QObject::connect(
|
||||
a.getElement(), &RippleEffectLabel2::clicked,
|
||||
[this, timeout = std::get<1>(item)] {
|
||||
this->buttonClicked.invoke(std::make_pair(Action::Timeout, timeout));
|
||||
});
|
||||
QObject::connect(a.getElement(), &RippleEffectLabel2::clicked,
|
||||
[this, timeout = std::get<1>(item)] {
|
||||
this->buttonClicked.invoke(std::make_pair(
|
||||
Action::Timeout, timeout));
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -470,7 +507,8 @@ void UserInfoPopup::TimeoutWidget::paintEvent(QPaintEvent *)
|
||||
|
||||
// painter.setPen(QColor(255, 255, 255, 63));
|
||||
|
||||
// painter.drawLine(0, this->height() / 2, this->width(), this->height() / 2);
|
||||
// painter.drawLine(0, this->height() / 2, this->width(), this->height()
|
||||
// / 2);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user