diff --git a/src/common/Channel.cpp b/src/common/Channel.cpp index 3fe8f74d7..9ee3370f8 100644 --- a/src/common/Channel.cpp +++ b/src/common/Channel.cpp @@ -203,6 +203,12 @@ bool Channel::isBroadcaster() const return false; } +bool Channel::hasModRights() const +{ + // fourtf: check if staff + return this->isMod() || this->isBroadcaster(); +} + std::shared_ptr Channel::getEmpty() { static std::shared_ptr channel(new Channel("", None)); diff --git a/src/common/Channel.hpp b/src/common/Channel.hpp index efa5b57c2..a56349345 100644 --- a/src/common/Channel.hpp +++ b/src/common/Channel.hpp @@ -61,6 +61,7 @@ public: virtual void sendMessage(const QString &message); virtual bool isMod() const; virtual bool isBroadcaster() const; + virtual bool hasModRights() const; static std::shared_ptr getEmpty(); diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 579a8a8f8..11ad3f645 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -197,12 +197,6 @@ bool TwitchChannel::isBroadcaster() const return this->name == app->accounts->twitch.getCurrent()->getUserName(); } -bool TwitchChannel::hasModRights() -{ - // fourtf: check if staff - return this->isMod() || this->isBroadcaster(); -} - void TwitchChannel::addRecentChatter(const std::shared_ptr &message) { assert(!message->loginName.isEmpty()); diff --git a/src/providers/twitch/TwitchChannel.hpp b/src/providers/twitch/TwitchChannel.hpp index a4be63188..595085819 100644 --- a/src/providers/twitch/TwitchChannel.hpp +++ b/src/providers/twitch/TwitchChannel.hpp @@ -54,10 +54,9 @@ public: bool canSendMessage() const override; void sendMessage(const QString &message) override; - bool isMod() const override; + virtual bool isMod() const override; void setMod(bool value); - bool isBroadcaster() const override; - bool hasModRights(); + virtual bool isBroadcaster() const override; void addRecentChatter(const std::shared_ptr &message) final; void addJoinedUser(const QString &user); diff --git a/src/widgets/helper/RippleEffectButton.cpp b/src/widgets/helper/RippleEffectButton.cpp index 07e95d656..31fc4ffc4 100644 --- a/src/widgets/helper/RippleEffectButton.cpp +++ b/src/widgets/helper/RippleEffectButton.cpp @@ -46,6 +46,18 @@ bool RippleEffectButton::getDim() const return this->dimPixmap_; } +void RippleEffectButton::setEnable(bool value) +{ + this->enabled_ = value; + + this->update(); +} + +bool RippleEffectButton::getEnable() const +{ + return this->enabled_; +} + qreal RippleEffectButton::getCurrentDimAmount() const { return this->dimPixmap_ && !this->mouseOver_ ? 0.7 : 1; @@ -54,6 +66,8 @@ qreal RippleEffectButton::getCurrentDimAmount() const void RippleEffectButton::setBorderColor(const QColor &color) { this->borderColor_ = color; + + this->update(); } const QColor &RippleEffectButton::getBorderColor() const @@ -68,7 +82,7 @@ void RippleEffectButton::paintEvent(QPaintEvent *) painter.setRenderHint(QPainter::SmoothPixmapTransform); if (!this->pixmap_.isNull()) { - if (!this->mouseOver_ && this->dimPixmap_) { + if (!this->mouseOver_ && this->dimPixmap_ && this->enabled_) { painter.setOpacity(this->getCurrentDimAmount()); } @@ -96,6 +110,10 @@ void RippleEffectButton::paintEvent(QPaintEvent *) void RippleEffectButton::fancyPaint(QPainter &painter) { + if (!this->enabled_) { + return; + } + painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.setRenderHint(QPainter::Antialiasing); QColor c; @@ -144,6 +162,10 @@ void RippleEffectButton::leaveEvent(QEvent *) void RippleEffectButton::mousePressEvent(QMouseEvent *event) { + if (!this->enabled_) { + return; + } + if (event->button() != Qt::LeftButton) { return; } @@ -151,10 +173,16 @@ void RippleEffectButton::mousePressEvent(QMouseEvent *event) this->clickEffects_.push_back(ClickEffect(event->pos())); this->mouseDown_ = true; + + emit this->leftMousePress(); } void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event) { + if (!this->enabled_) { + return; + } + if (event->button() != Qt::LeftButton) { return; } @@ -168,6 +196,10 @@ void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event) void RippleEffectButton::mouseMoveEvent(QMouseEvent *event) { + if (!this->enabled_) { + return; + } + this->mousePos_ = event->pos(); this->update(); diff --git a/src/widgets/helper/RippleEffectButton.hpp b/src/widgets/helper/RippleEffectButton.hpp index 924cfb817..583ea52a1 100644 --- a/src/widgets/helper/RippleEffectButton.hpp +++ b/src/widgets/helper/RippleEffectButton.hpp @@ -37,13 +37,18 @@ public: bool getDim() const; qreal getCurrentDimAmount() const; + void setEnable(bool value); + bool getEnable() const; + void setBorderColor(const QColor &color); const QColor &getBorderColor() const; signals: void clicked(); + void leftMousePress(); protected: + bool enabled_ = true; bool selected_ = false; bool mouseOver_ = false; bool mouseDown_ = false; diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 873383cd8..079937125 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -193,11 +193,13 @@ void Split::setChannel(IndirectChannel newChannel) TwitchChannel *tc = dynamic_cast(newChannel.get().get()); if (tc != nullptr) { - this->usermodeChangedConnection = - tc->userStateChanged.connect([this] { this->header.updateModerationModeIcon(); }); + this->usermodeChangedConnection = tc->userStateChanged.connect([this] { + this->header.updateModerationModeIcon(); + this->header.updateRoomModes(); + }); this->roomModeChangedConnection = - tc->roomModesChanged.connect([this] { this->header.updateModes(); }); + tc->roomModesChanged.connect([this] { this->header.updateRoomModes(); }); } this->indirectChannelChangedConnection = newChannel.getChannelChanged().connect([this] { // @@ -206,7 +208,7 @@ void Split::setChannel(IndirectChannel newChannel) this->header.updateModerationModeIcon(); this->header.updateChannelText(); - this->header.updateModes(); + this->header.updateRoomModes(); this->channelChanged.invoke(); } diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index df244378a..66c6a1e9d 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -44,15 +44,23 @@ SplitHeader::SplitHeader(Split *_split) title->setHasOffset(false); // mode button - auto mode = layout.emplace