added roommodes to the splitheader
This commit is contained in:
@@ -63,6 +63,16 @@ SplitHeader::SplitHeader(Split *_split)
|
||||
|
||||
layout->addStretch(1);
|
||||
|
||||
// mode button
|
||||
auto mode = layout.emplace<RippleEffectLabel>(this).assign(&this->modeButton);
|
||||
|
||||
mode->getLabel().setText("dank\nmemes");
|
||||
|
||||
// QObject::connect(mode.getElement(), &RippleEffectButton::clicked, this, [this]
|
||||
// {
|
||||
// //
|
||||
// });
|
||||
|
||||
// moderation mode
|
||||
auto moderator = layout.emplace<RippleEffectButton>(this).assign(&this->moderationButton);
|
||||
|
||||
@@ -167,7 +177,7 @@ void SplitHeader::updateChannelText()
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
|
||||
if (twitchChannel != nullptr) {
|
||||
const auto &streamStatus = twitchChannel->GetStreamStatus();
|
||||
const auto &streamStatus = twitchChannel->getStreamStatus();
|
||||
|
||||
if (streamStatus.live) {
|
||||
this->isLive = true;
|
||||
@@ -216,6 +226,45 @@ void SplitHeader::updateModerationModeIcon()
|
||||
this->moderationButton->setVisible(modButtonVisible);
|
||||
}
|
||||
|
||||
void SplitHeader::updateModes()
|
||||
{
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(this->split->getChannel().get());
|
||||
if (tc == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
TwitchChannel::RoomModes roomModes = tc->getRoomModes();
|
||||
|
||||
QString text;
|
||||
|
||||
if (roomModes.r9k) {
|
||||
text += "r9k, ";
|
||||
}
|
||||
if (roomModes.slowMode) {
|
||||
text += QString("slow(%1), ").arg(QString::number(roomModes.slowMode));
|
||||
}
|
||||
if (roomModes.emoteOnly) {
|
||||
text += "emote, ";
|
||||
}
|
||||
if (roomModes.submode) {
|
||||
text += "sub, ";
|
||||
}
|
||||
|
||||
if (text.length() > 2) {
|
||||
text = text.mid(0, text.size() - 2);
|
||||
}
|
||||
|
||||
qDebug() << text;
|
||||
|
||||
static QRegularExpression commaReplacement("^.+?, .+?,( ).+$");
|
||||
QRegularExpressionMatch match = commaReplacement.match(text);
|
||||
if (match.hasMatch()) {
|
||||
text = text.mid(0, match.capturedStart(1)) + '\n' + text.mid(match.capturedEnd(1));
|
||||
}
|
||||
|
||||
this->modeButton->getLabel().setText(text);
|
||||
}
|
||||
|
||||
void SplitHeader::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
// Update channel text from chat widget
|
||||
void updateChannelText();
|
||||
void updateModerationModeIcon();
|
||||
void updateModes();
|
||||
|
||||
protected:
|
||||
virtual void scaleChangedEvent(float) override;
|
||||
@@ -59,6 +60,7 @@ private:
|
||||
RippleEffectButton *dropdownButton;
|
||||
// Label *titleLabel;
|
||||
SignalLabel *titleLabel;
|
||||
RippleEffectLabel *modeButton;
|
||||
RippleEffectButton *moderationButton;
|
||||
|
||||
QMenu dropdownMenu;
|
||||
|
||||
@@ -129,15 +129,10 @@ Split::Split(QWidget *parent)
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
this->managedConnect(modifierStatusChanged, [this](Qt::KeyboardModifiers status) {
|
||||
|
||||
qDebug() << "xD" << status;
|
||||
|
||||
if ((status == Qt::AltModifier || status == (Qt::AltModifier | Qt::ControlModifier)) &&
|
||||
this->isMouseOver) {
|
||||
qDebug() << "show";
|
||||
this->overlay->show();
|
||||
} else {
|
||||
qDebug() << "hide";
|
||||
this->overlay->hide();
|
||||
}
|
||||
});
|
||||
@@ -187,6 +182,7 @@ void Split::setChannel(IndirectChannel newChannel)
|
||||
this->view.setChannel(newChannel.get());
|
||||
|
||||
this->usermodeChangedConnection.disconnect();
|
||||
this->roomModeChangedConnection.disconnect();
|
||||
this->indirectChannelChangedConnection.disconnect();
|
||||
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(newChannel.get().get());
|
||||
@@ -194,6 +190,9 @@ void Split::setChannel(IndirectChannel newChannel)
|
||||
if (tc != nullptr) {
|
||||
this->usermodeChangedConnection =
|
||||
tc->userStateChanged.connect([this] { this->header.updateModerationModeIcon(); });
|
||||
|
||||
this->roomModeChangedConnection =
|
||||
tc->roomModesChanged.connect([this] { this->header.updateModes(); });
|
||||
}
|
||||
|
||||
this->indirectChannelChangedConnection = newChannel.getChannelChanged().connect([this] { //
|
||||
@@ -202,6 +201,7 @@ void Split::setChannel(IndirectChannel newChannel)
|
||||
|
||||
this->header.updateModerationModeIcon();
|
||||
this->header.updateChannelText();
|
||||
this->header.updateModes();
|
||||
|
||||
this->channelChanged.invoke();
|
||||
}
|
||||
|
||||
@@ -100,6 +100,8 @@ private:
|
||||
|
||||
pajlada::Signals::Connection channelIDChangedConnection;
|
||||
pajlada::Signals::Connection usermodeChangedConnection;
|
||||
pajlada::Signals::Connection roomModeChangedConnection;
|
||||
|
||||
pajlada::Signals::Connection indirectChannelChangedConnection;
|
||||
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
|
||||
|
||||
Reference in New Issue
Block a user