fix: svgify moderation button (#6398)
This commit is contained in:
@@ -18,6 +18,7 @@ SvgButton::SvgButton(Src source, BaseWidget *parent, QSize padding)
|
||||
|
||||
void SvgButton::setSource(Src source)
|
||||
{
|
||||
// TODO: compare sources before trying to load / invalidate?
|
||||
this->source_ = std::move(source);
|
||||
this->loadSource();
|
||||
this->invalidateContent();
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||
#include "singletons/Resources.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/StreamerMode.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
@@ -22,7 +21,6 @@
|
||||
#include "util/LayoutHelper.hpp"
|
||||
#include "widgets/buttons/DrawnButton.hpp"
|
||||
#include "widgets/buttons/LabelButton.hpp"
|
||||
#include "widgets/buttons/PixmapButton.hpp"
|
||||
#include "widgets/buttons/SvgButton.hpp"
|
||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||
#include "widgets/helper/CommonTexts.hpp"
|
||||
@@ -290,6 +288,13 @@ void SplitHeader::initializeLayout()
|
||||
{
|
||||
assert(this->layout() == nullptr);
|
||||
|
||||
this->moderationButton_ = new SvgButton(
|
||||
{
|
||||
.dark = ":/buttons/moderationDisabled-darkMode.svg",
|
||||
.light = ":/buttons/moderationDisabled-lightMode.svg",
|
||||
},
|
||||
this, {5, 5});
|
||||
|
||||
this->chattersButton_ = new SvgButton(
|
||||
{
|
||||
.dark = ":/buttons/chatters-darkMode.svg",
|
||||
@@ -336,42 +341,7 @@ void SplitHeader::initializeLayout()
|
||||
w->setMenu(this->createChatModeMenu());
|
||||
}),
|
||||
// moderator
|
||||
this->moderationButton_ = makeWidget<PixmapButton>([&](auto w) {
|
||||
QObject::connect(
|
||||
w, &Button::clicked, this,
|
||||
[this, w](Qt::MouseButton button) mutable {
|
||||
switch (button)
|
||||
{
|
||||
case Qt::LeftButton:
|
||||
if (getSettings()->moderationActions.empty())
|
||||
{
|
||||
getApp()->getWindows()->showSettingsDialog(
|
||||
this, SettingsDialogPreference::
|
||||
ModerationActions);
|
||||
this->split_->setModerationMode(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto moderationMode =
|
||||
this->split_->getModerationMode();
|
||||
|
||||
this->split_->setModerationMode(
|
||||
!moderationMode);
|
||||
w->setDim(moderationMode
|
||||
? DimButton::Dim::Some
|
||||
: DimButton::Dim::None);
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::RightButton:
|
||||
case Qt::MiddleButton:
|
||||
getApp()->getWindows()->showSettingsDialog(
|
||||
this,
|
||||
SettingsDialogPreference::ModerationActions);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}),
|
||||
this->moderationButton_,
|
||||
// chatter list
|
||||
this->chattersButton_,
|
||||
// dropdown
|
||||
@@ -380,6 +350,37 @@ void SplitHeader::initializeLayout()
|
||||
this->addButton_,
|
||||
});
|
||||
|
||||
QObject::connect(
|
||||
this->moderationButton_, &Button::clicked, this,
|
||||
[this](Qt::MouseButton button) mutable {
|
||||
auto *w = this->moderationButton_;
|
||||
switch (button)
|
||||
{
|
||||
case Qt::LeftButton:
|
||||
if (getSettings()->moderationActions.empty())
|
||||
{
|
||||
getApp()->getWindows()->showSettingsDialog(
|
||||
this, SettingsDialogPreference::ModerationActions);
|
||||
this->split_->setModerationMode(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto moderationMode = this->split_->getModerationMode();
|
||||
|
||||
this->split_->setModerationMode(!moderationMode);
|
||||
// w->setDim(moderationMode ? DimButton::Dim::Some
|
||||
// : DimButton::Dim::None);
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::RightButton:
|
||||
case Qt::MiddleButton:
|
||||
getApp()->getWindows()->showSettingsDialog(
|
||||
this, SettingsDialogPreference::ModerationActions);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(this->chattersButton_, &Button::leftClicked, this,
|
||||
[this]() {
|
||||
this->split_->openChatterList();
|
||||
@@ -923,9 +924,20 @@ void SplitHeader::updateIcons()
|
||||
auto moderationMode = this->split_->getModerationMode() &&
|
||||
!getSettings()->moderationActions.empty();
|
||||
|
||||
this->moderationButton_->setPixmap(
|
||||
moderationMode ? getResources().buttons.modModeEnabled
|
||||
: getResources().buttons.modModeDisabled);
|
||||
if (moderationMode)
|
||||
{
|
||||
this->moderationButton_->setSource({
|
||||
.dark = ":/buttons/moderationEnabled-darkMode.svg",
|
||||
.light = ":/buttons/moderationEnabled-lightMode.svg",
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this->moderationButton_->setSource({
|
||||
.dark = ":/buttons/moderationDisabled-darkMode.svg",
|
||||
.light = ":/buttons/moderationDisabled-lightMode.svg",
|
||||
});
|
||||
}
|
||||
|
||||
if (twitchChannel->hasModRights() || moderationMode)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace chatterino {
|
||||
|
||||
class SvgButton;
|
||||
class DrawnButton;
|
||||
class PixmapButton;
|
||||
class LabelButton;
|
||||
class Label;
|
||||
class Split;
|
||||
@@ -87,7 +86,7 @@ private:
|
||||
QAction *modeActionSetR9k{};
|
||||
QAction *modeActionSetFollowers{};
|
||||
|
||||
PixmapButton *moderationButton_{};
|
||||
SvgButton *moderationButton_{};
|
||||
SvgButton *chattersButton_{};
|
||||
DrawnButton *addButton_{};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user