open settings when right clicking moderation button

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