mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
open settings when right clicking moderation button
This commit is contained in:
parent
1872163ec4
commit
3db0b5f95c
|
@ -11,7 +11,7 @@ void initUpdateButton(Button &button,
|
|||
button.hide();
|
||||
|
||||
// show update prompt when clicking the button
|
||||
QObject::connect(&button, &Button::clicked, [&button] {
|
||||
QObject::connect(&button, &Button::leftClicked, [&button] {
|
||||
auto dialog = new UpdateDialog();
|
||||
dialog->setActionOnFocusLoss(BaseWindow::Delete);
|
||||
dialog->move(button.mapToGlobal(
|
||||
|
|
|
@ -120,19 +120,19 @@ void BaseWindow::init()
|
|||
TitleBarButton *_exitButton = new TitleBarButton;
|
||||
_exitButton->setButtonStyle(TitleBarButtonStyle::Close);
|
||||
|
||||
QObject::connect(_minButton, &TitleBarButton::clicked, this,
|
||||
QObject::connect(_minButton, &TitleBarButton::leftClicked, this,
|
||||
[this] {
|
||||
this->setWindowState(Qt::WindowMinimized |
|
||||
this->windowState());
|
||||
});
|
||||
QObject::connect(
|
||||
_maxButton, &TitleBarButton::clicked, this, [this] {
|
||||
_maxButton, &TitleBarButton::leftClicked, this, [this] {
|
||||
this->setWindowState(this->windowState() ==
|
||||
Qt::WindowMaximized
|
||||
? Qt::WindowActive
|
||||
: Qt::WindowMaximized);
|
||||
});
|
||||
QObject::connect(_exitButton, &TitleBarButton::clicked, this,
|
||||
QObject::connect(_exitButton, &TitleBarButton::leftClicked, this,
|
||||
[this] { this->close(); });
|
||||
|
||||
this->ui_.minButton = _minButton;
|
||||
|
@ -398,7 +398,7 @@ TitleBarButton *BaseWindow::addTitleBarButton(const TitleBarButtonStyle &style,
|
|||
this->ui_.titlebarBox->insertWidget(1, button);
|
||||
button->setButtonStyle(style);
|
||||
|
||||
QObject::connect(button, &TitleBarButton::clicked, this,
|
||||
QObject::connect(button, &TitleBarButton::leftClicked, this,
|
||||
[onClicked] { onClicked(); });
|
||||
|
||||
return button;
|
||||
|
@ -412,7 +412,7 @@ EffectLabel *BaseWindow::addTitleBarLabel(std::function<void()> onClicked)
|
|||
this->ui_.buttons.push_back(button);
|
||||
this->ui_.titlebarBox->insertWidget(1, button);
|
||||
|
||||
QObject::connect(button, &EffectLabel::clicked, this,
|
||||
QObject::connect(button, &EffectLabel::leftClicked, this,
|
||||
[onClicked] { onClicked(); });
|
||||
|
||||
return button;
|
||||
|
|
|
@ -484,7 +484,7 @@ NotebookTab *Notebook::getTabFromPage(QWidget *page)
|
|||
SplitNotebook::SplitNotebook(Window *parent)
|
||||
: Notebook(parent)
|
||||
{
|
||||
this->connect(this->getAddButton(), &NotebookButton::clicked, [this]() {
|
||||
this->connect(this->getAddButton(), &NotebookButton::leftClicked, [this]() {
|
||||
QTimer::singleShot(80, this, [this] { this->addPage(true); });
|
||||
});
|
||||
|
||||
|
@ -508,7 +508,7 @@ void SplitNotebook::addCustomButtons()
|
|||
|
||||
settingsBtn->setIcon(NotebookButton::Settings);
|
||||
|
||||
QObject::connect(settingsBtn, &NotebookButton::clicked,
|
||||
QObject::connect(settingsBtn, &NotebookButton::leftClicked,
|
||||
[] { getApp()->windows->showSettingsDialog(); });
|
||||
|
||||
// account
|
||||
|
@ -519,7 +519,7 @@ void SplitNotebook::addCustomButtons()
|
|||
this->connections_);
|
||||
|
||||
userBtn->setIcon(NotebookButton::User);
|
||||
QObject::connect(userBtn, &NotebookButton::clicked, [this, userBtn] {
|
||||
QObject::connect(userBtn, &NotebookButton::leftClicked, [this, userBtn] {
|
||||
getApp()->windows->showAccountSelectPopup(
|
||||
this->mapToGlobal(userBtn->rect().bottomRight()));
|
||||
});
|
||||
|
|
|
@ -50,7 +50,7 @@ UserInfoPopup::UserInfoPopup()
|
|||
auto avatar =
|
||||
head.emplace<Button>(nullptr).assign(&this->ui_.avatarButton);
|
||||
avatar->setScaleIndependantSize(100, 100);
|
||||
QObject::connect(avatar.getElement(), &Button::clicked, [this] {
|
||||
QObject::connect(avatar.getElement(), &Button::leftClicked, [this] {
|
||||
QDesktopServices::openUrl(
|
||||
QUrl("https://twitch.tv/" + this->userName_.toLower()));
|
||||
});
|
||||
|
@ -94,17 +94,17 @@ UserInfoPopup::UserInfoPopup()
|
|||
|
||||
user->addStretch(1);
|
||||
|
||||
QObject::connect(viewLogs.getElement(), &Button::clicked, [this] {
|
||||
QObject::connect(viewLogs.getElement(), &Button::leftClicked, [this] {
|
||||
auto logs = new LogsPopup();
|
||||
logs->setInfo(this->channel_, this->userName_);
|
||||
logs->setAttribute(Qt::WA_DeleteOnClose);
|
||||
logs->show();
|
||||
});
|
||||
|
||||
QObject::connect(mod.getElement(), &Button::clicked, [this] {
|
||||
QObject::connect(mod.getElement(), &Button::leftClicked, [this] {
|
||||
this->channel_->sendMessage("/mod " + this->userName_);
|
||||
});
|
||||
QObject::connect(unmod.getElement(), &Button::clicked, [this] {
|
||||
QObject::connect(unmod.getElement(), &Button::leftClicked, [this] {
|
||||
this->channel_->sendMessage("/unmod " + this->userName_);
|
||||
});
|
||||
|
||||
|
@ -476,7 +476,7 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
|||
button->setBorderColor(QColor(255, 255, 255, 127));
|
||||
|
||||
QObject::connect(
|
||||
button.getElement(), &Button::clicked, [this, action] {
|
||||
button.getElement(), &Button::leftClicked, [this, action] {
|
||||
this->buttonClicked.invoke(std::make_pair(action, -1));
|
||||
});
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
|
|||
}
|
||||
a->setBorderColor(color1);
|
||||
|
||||
QObject::connect(a.getElement(), &EffectLabel2::clicked,
|
||||
QObject::connect(a.getElement(), &EffectLabel2::leftClicked,
|
||||
[this, timeout = std::get<1>(item)] {
|
||||
this->buttonClicked.invoke(std::make_pair(
|
||||
Action::Timeout, timeout));
|
||||
|
|
|
@ -230,33 +230,27 @@ void Button::mousePressEvent(QMouseEvent *event)
|
|||
void Button::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!this->enabled_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->button() != Qt::LeftButton)
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
this->mouseDown_ = false;
|
||||
|
||||
if (this->rect().contains(event->pos()))
|
||||
emit leftClicked();
|
||||
}
|
||||
|
||||
this->mouseDown_ = false;
|
||||
|
||||
if (this->rect().contains(event->pos()))
|
||||
{
|
||||
emit clicked();
|
||||
}
|
||||
emit clicked(event->button());
|
||||
}
|
||||
|
||||
void Button::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!this->enabled_)
|
||||
if (this->enabled_)
|
||||
{
|
||||
return;
|
||||
this->mousePos_ = event->pos();
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
||||
this->mousePos_ = event->pos();
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
||||
void Button::onMouseEffectTimeout()
|
||||
|
|
|
@ -50,7 +50,8 @@ public:
|
|||
void setMenu(std::unique_ptr<QMenu> menu);
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
void leftClicked();
|
||||
void clicked(Qt::MouseButton button);
|
||||
void leftMousePress();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -139,7 +139,7 @@ void ChannelView::initializeLayout()
|
|||
this->goToBottom_->getLabel().setText("More messages below");
|
||||
this->goToBottom_->setVisible(false);
|
||||
|
||||
QObject::connect(this->goToBottom_, &EffectLabel::clicked, this, [=] {
|
||||
QObject::connect(this->goToBottom_, &EffectLabel::leftClicked, this, [=] {
|
||||
QTimer::singleShot(180, [=] {
|
||||
this->scrollBar_->scrollToBottom(
|
||||
getSettings()->enableSmoothScrollingNewMessages.getValue());
|
||||
|
|
|
@ -150,7 +150,7 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
|||
|
||||
update();
|
||||
|
||||
emit clicked();
|
||||
emit leftClicked();
|
||||
}
|
||||
|
||||
Button::mouseReleaseEvent(event);
|
||||
|
|
|
@ -32,7 +32,7 @@ protected:
|
|||
virtual void showEvent(QShowEvent *) override;
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
void leftClicked();
|
||||
|
||||
private:
|
||||
Notebook *parent_ = nullptr;
|
||||
|
|
|
@ -268,12 +268,9 @@ void Split::setChannel(IndirectChannel newChannel)
|
|||
|
||||
void Split::setModerationMode(bool value)
|
||||
{
|
||||
if (value != this->moderationMode_)
|
||||
{
|
||||
this->moderationMode_ = value;
|
||||
this->header_->updateModerationModeIcon();
|
||||
this->view_->layoutMessages();
|
||||
}
|
||||
this->moderationMode_ = value;
|
||||
this->header_->updateModerationModeIcon();
|
||||
this->view_->layoutMessages();
|
||||
}
|
||||
|
||||
bool Split::getModerationMode() const
|
||||
|
|
|
@ -167,25 +167,40 @@ void SplitHeader::initializeLayout()
|
|||
}),
|
||||
// moderator
|
||||
this->moderationButton_ = makeWidget<Button>([&](auto w) {
|
||||
QObject::connect(w, &Button::clicked, this, [this, w]() mutable {
|
||||
if (this->split_->getModerationMode())
|
||||
this->split_->setModerationMode(false);
|
||||
else
|
||||
{
|
||||
if (getApp()->moderationActions->items.getVector().empty())
|
||||
QObject::connect(
|
||||
w, &Button::clicked, this,
|
||||
[this, w](Qt::MouseButton button) mutable {
|
||||
switch (button)
|
||||
{
|
||||
getApp()->windows->showSettingsDialog(
|
||||
SettingsDialogPreference::ModerationActions);
|
||||
this->split_->setModerationMode(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->split_->setModerationMode(true);
|
||||
}
|
||||
}
|
||||
case Qt::LeftButton:
|
||||
if (getApp()
|
||||
->moderationActions->items.getVector()
|
||||
.empty())
|
||||
{
|
||||
getApp()->windows->showSettingsDialog(
|
||||
SettingsDialogPreference::
|
||||
ModerationActions);
|
||||
this->split_->setModerationMode(true);
|
||||
w->setDim(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto moderationMode =
|
||||
this->split_->getModerationMode();
|
||||
|
||||
w->setDim(!this->split_->getModerationMode());
|
||||
});
|
||||
this->split_->setModerationMode(
|
||||
!moderationMode);
|
||||
w->setDim(moderationMode);
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::RightButton:
|
||||
case Qt::MiddleButton:
|
||||
getApp()->windows->showSettingsDialog(
|
||||
SettingsDialogPreference::ModerationActions);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}),
|
||||
// dropdown
|
||||
this->dropdownButton_ = makeWidget<Button>(
|
||||
|
@ -195,11 +210,26 @@ void SplitHeader::initializeLayout()
|
|||
w->setPixmap(getApp()->resources->buttons.addSplitDark);
|
||||
w->setEnableMargin(false);
|
||||
|
||||
QObject::connect(w, &Button::clicked, this,
|
||||
QObject::connect(w, &Button::leftClicked, this,
|
||||
[this]() { this->split_->addSibling(); });
|
||||
}),
|
||||
});
|
||||
|
||||
// update moderation button when items changed
|
||||
this->managedConnect(
|
||||
getApp()->moderationActions->items.delayedItemsChanged, [this] {
|
||||
if (getApp()->moderationActions->items.getVector().empty())
|
||||
{
|
||||
if (this->split_->getModerationMode())
|
||||
this->split_->setModerationMode(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->split_->getModerationMode())
|
||||
this->split_->setModerationMode(true);
|
||||
}
|
||||
});
|
||||
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
this->setLayout(layout);
|
||||
|
@ -447,10 +477,13 @@ void SplitHeader::updateChannelText()
|
|||
|
||||
void SplitHeader::updateModerationModeIcon()
|
||||
{
|
||||
auto moderationMode =
|
||||
this->split_->getModerationMode() &&
|
||||
!getApp()->moderationActions->items.getVector().empty();
|
||||
|
||||
this->moderationButton_->setPixmap(
|
||||
this->split_->getModerationMode()
|
||||
? getApp()->resources->buttons.modModeEnabled
|
||||
: getApp()->resources->buttons.modModeDisabled);
|
||||
moderationMode ? getApp()->resources->buttons.modModeEnabled
|
||||
: getApp()->resources->buttons.modModeDisabled);
|
||||
|
||||
auto channel = this->split_->getChannel();
|
||||
auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
|
|
|
@ -84,7 +84,7 @@ void SplitInput::initLayout()
|
|||
}));
|
||||
|
||||
// open emote popup
|
||||
QObject::connect(this->ui_.emoteButton, &EffectLabel::clicked,
|
||||
QObject::connect(this->ui_.emoteButton, &EffectLabel::leftClicked,
|
||||
[=] { this->openEmotePopup(); });
|
||||
|
||||
// clear channelview selection when selecting in the input
|
||||
|
|
Loading…
Reference in a new issue