Hide chatter list button for non-moderators (#5245)

This commit is contained in:
pajlada
2024-03-10 12:46:26 +01:00
committed by GitHub
parent 9d02fa14ed
commit a958619860
5 changed files with 63 additions and 44 deletions
+4 -13
View File
@@ -331,7 +331,7 @@ Split::Split(QWidget *parent)
},
this->signalHolder_);
this->header_->updateModerationModeIcon();
this->header_->updateIcons();
this->overlay_->hide();
this->setSizePolicy(QSizePolicy::MinimumExpanding,
@@ -813,7 +813,7 @@ void Split::joinChannelInNewTab(ChannelPtr channel)
void Split::refreshModerationMode()
{
this->header_->updateModerationModeIcon();
this->header_->updateIcons();
this->view_->queueLayout();
}
@@ -865,7 +865,7 @@ void Split::setChannel(IndirectChannel newChannel)
if (tc != nullptr)
{
this->usermodeChangedConnection_ = tc->userStateChanged.connect([this] {
this->header_->updateModerationModeIcon();
this->header_->updateIcons();
this->header_->updateRoomModes();
});
@@ -881,19 +881,10 @@ void Split::setChannel(IndirectChannel newChannel)
});
});
this->header_->updateModerationModeIcon();
this->header_->updateIcons();
this->header_->updateChannelText();
this->header_->updateRoomModes();
if (newChannel.getType() == Channel::Type::Twitch)
{
this->header_->setChattersButtonVisible(true);
}
else
{
this->header_->setChattersButtonVisible(false);
}
this->channelSignalHolder_.managedConnect(
this->channel_.get()->displayNameChanged, [this] {
this->actionRequested.invoke(Action::RefreshTab);
+29 -18
View File
@@ -230,7 +230,7 @@ SplitHeader::SplitHeader(Split *split)
this->setMouseTracking(true);
this->updateChannelText();
this->handleChannelChanged();
this->updateModerationModeIcon();
this->updateIcons();
// The lifetime of these signals are tied to the lifetime of the Split.
// Since the SplitHeader is owned by the Split, they will always be destroyed
@@ -247,7 +247,7 @@ SplitHeader::SplitHeader(Split *split)
this->bSignals_.emplace_back(
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->updateModerationModeIcon();
this->updateIcons();
}));
auto _ = [this](const auto &, const auto &) {
@@ -755,11 +755,6 @@ void SplitHeader::setAddButtonVisible(bool value)
this->addButton_->setVisible(value);
}
void SplitHeader::setChattersButtonVisible(bool value)
{
this->chattersButton_->setVisible(value);
}
void SplitHeader::updateChannelText()
{
auto indirectChannel = this->split_->getIndirectChannel();
@@ -838,26 +833,42 @@ void SplitHeader::updateChannelText()
this->titleLabel_->setText(title.isEmpty() ? "<empty>" : title);
}
void SplitHeader::updateModerationModeIcon()
void SplitHeader::updateIcons()
{
auto moderationMode = this->split_->getModerationMode() &&
!getSettings()->moderationActions.empty();
this->moderationButton_->setPixmap(
moderationMode ? getResources().buttons.modModeEnabled
: getResources().buttons.modModeDisabled);
auto channel = this->split_->getChannel();
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
if (twitchChannel != nullptr &&
(twitchChannel->hasModRights() || moderationMode))
if (twitchChannel != nullptr)
{
this->moderationButton_->show();
auto moderationMode = this->split_->getModerationMode() &&
!getSettings()->moderationActions.empty();
this->moderationButton_->setPixmap(
moderationMode ? getResources().buttons.modModeEnabled
: getResources().buttons.modModeDisabled);
if (twitchChannel->hasModRights() || moderationMode)
{
this->moderationButton_->show();
}
else
{
this->moderationButton_->hide();
}
if (twitchChannel->hasModRights())
{
this->chattersButton_->show();
}
else
{
this->chattersButton_->hide();
}
}
else
{
this->moderationButton_->hide();
this->chattersButton_->hide();
}
}
+1 -2
View File
@@ -29,10 +29,9 @@ public:
explicit SplitHeader(Split *split);
void setAddButtonVisible(bool value);
void setChattersButtonVisible(bool value);
void updateChannelText();
void updateModerationModeIcon();
void updateIcons();
// Invoked when SplitHeader should update anything refering to a TwitchChannel's mode
// has changed (e.g. sub mode toggled)
void updateRoomModes();