mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
moved menu code to ripple effect button
This commit is contained in:
parent
e1b8faacc9
commit
7a9af4ae84
13 changed files with 198 additions and 170 deletions
|
@ -2,11 +2,12 @@
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "common/NetworkManager.hpp"
|
#include "common/NetworkManager.hpp"
|
||||||
|
#include "debug/Log.hpp"
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
|
#include "util/DebugCount.hpp"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -165,6 +166,8 @@ Outcome NetworkRequest::tryLoadCachedFile()
|
||||||
|
|
||||||
void NetworkRequest::doRequest()
|
void NetworkRequest::doRequest()
|
||||||
{
|
{
|
||||||
|
DebugCount::increase("http request started");
|
||||||
|
|
||||||
NetworkRequester requester;
|
NetworkRequester requester;
|
||||||
NetworkWorker *worker = new NetworkWorker;
|
NetworkWorker *worker = new NetworkWorker;
|
||||||
|
|
||||||
|
@ -223,6 +226,8 @@ void NetworkRequest::doRequest()
|
||||||
data->writeToCache(bytes);
|
data->writeToCache(bytes);
|
||||||
|
|
||||||
NetworkResult result(bytes);
|
NetworkResult result(bytes);
|
||||||
|
|
||||||
|
DebugCount::increase("http request success");
|
||||||
data->onSuccess_(result);
|
data->onSuccess_(result);
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include <messages/Image.hpp>
|
||||||
|
|
||||||
using namespace chatterino;
|
using namespace chatterino;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|
|
@ -96,8 +96,6 @@ void TwitchServer::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||||
|
|
||||||
void TwitchServer::messageReceived(Communi::IrcMessage *message)
|
void TwitchServer::messageReceived(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
qDebug() << message->toData();
|
|
||||||
|
|
||||||
// this->readConnection
|
// this->readConnection
|
||||||
if (message->type() == Communi::IrcMessage::Type::Private) {
|
if (message->type() == Communi::IrcMessage::Type::Private) {
|
||||||
// We already have a handler for private messages
|
// We already have a handler for private messages
|
||||||
|
|
|
@ -220,8 +220,8 @@ void Theme::actuallyUpdate(double hue, double multiplier)
|
||||||
this->scrollbars.background = QColor(0, 0, 0, 0);
|
this->scrollbars.background = QColor(0, 0, 0, 0);
|
||||||
// this->scrollbars.background = splits.background;
|
// this->scrollbars.background = splits.background;
|
||||||
// this->scrollbars.background.setAlphaF(qreal(0.2));
|
// this->scrollbars.background.setAlphaF(qreal(0.2));
|
||||||
this->scrollbars.thumb = getColor(0, sat, 0.80);
|
this->scrollbars.thumb = getColor(0, sat, 0.70);
|
||||||
this->scrollbars.thumbSelected = getColor(0, sat, 0.7);
|
this->scrollbars.thumbSelected = getColor(0, sat, 0.65);
|
||||||
|
|
||||||
// tooltip
|
// tooltip
|
||||||
this->tooltip.background = QColor(0, 0, 0);
|
this->tooltip.background = QColor(0, 0, 0);
|
||||||
|
|
|
@ -147,8 +147,8 @@ void LogsPopup::getOverrustleLogs()
|
||||||
|
|
||||||
NetworkRequest req(url);
|
NetworkRequest req(url);
|
||||||
req.setCaller(QThread::currentThread());
|
req.setCaller(QThread::currentThread());
|
||||||
req.onError([this, channelName](int errorCode) {
|
req.onError([channelName](int errorCode) {
|
||||||
this->close();
|
// this->close();
|
||||||
auto box = new QMessageBox(
|
auto box = new QMessageBox(
|
||||||
QMessageBox::Information, "Error getting logs",
|
QMessageBox::Information, "Error getting logs",
|
||||||
"No logs could be found for channel " + channelName);
|
"No logs could be found for channel " + channelName);
|
||||||
|
|
|
@ -83,7 +83,7 @@ UserInfoPopup::UserInfoPopup()
|
||||||
user.emplace<QCheckBox>("Ignore highlights")
|
user.emplace<QCheckBox>("Ignore highlights")
|
||||||
.assign(&this->ui_.ignoreHighlights);
|
.assign(&this->ui_.ignoreHighlights);
|
||||||
auto viewLogs = user.emplace<RippleEffectLabel2>(this);
|
auto viewLogs = user.emplace<RippleEffectLabel2>(this);
|
||||||
viewLogs->getLabel().setText("Logs");
|
viewLogs->getLabel().setText("Online logs");
|
||||||
|
|
||||||
auto mod = user.emplace<RippleEffectButton>(this);
|
auto mod = user.emplace<RippleEffectButton>(this);
|
||||||
mod->setPixmap(app->resources->buttons.mod);
|
mod->setPixmap(app->resources->buttons.mod);
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#include "RippleEffectButton.hpp"
|
#include "RippleEffectButton.hpp"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDesktopWidget>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
|
#include "util/FunctionEventFilter.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
@ -76,6 +79,20 @@ const QColor &RippleEffectButton::getBorderColor() const
|
||||||
return this->borderColor_;
|
return this->borderColor_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RippleEffectButton::setMenu(std::unique_ptr<QMenu> menu)
|
||||||
|
{
|
||||||
|
this->menu_ = std::move(menu);
|
||||||
|
|
||||||
|
this->menu_->installEventFilter(
|
||||||
|
new FunctionEventFilter(this, [this](QObject *, QEvent *event) {
|
||||||
|
if (event->type() == QEvent::Hide) {
|
||||||
|
QTimer::singleShot(20, this,
|
||||||
|
[this] { this->menuVisible_ = false; });
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
void RippleEffectButton::paintEvent(QPaintEvent *)
|
void RippleEffectButton::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
@ -177,6 +194,10 @@ void RippleEffectButton::mousePressEvent(QMouseEvent *event)
|
||||||
this->mouseDown_ = true;
|
this->mouseDown_ = true;
|
||||||
|
|
||||||
emit this->leftMousePress();
|
emit this->leftMousePress();
|
||||||
|
|
||||||
|
if (this->menu_ && !this->menuVisible_) {
|
||||||
|
QTimer::singleShot(80, this, [this] { this->showMenu(); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event)
|
void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
@ -251,4 +272,26 @@ void RippleEffectButton::onMouseEffectTimeout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RippleEffectButton::showMenu()
|
||||||
|
{
|
||||||
|
if (!this->menu_) return;
|
||||||
|
|
||||||
|
auto point = [this] {
|
||||||
|
auto bounds = QApplication::desktop()->availableGeometry(this);
|
||||||
|
|
||||||
|
auto point = this->mapToGlobal(
|
||||||
|
QPoint(this->width() - this->menu_->width(), this->height()));
|
||||||
|
|
||||||
|
if (point.y() + this->menu_->height() > bounds.bottom()) {
|
||||||
|
point.setY(point.y() - this->menu_->height() - this->height());
|
||||||
|
}
|
||||||
|
|
||||||
|
return point;
|
||||||
|
};
|
||||||
|
|
||||||
|
this->menu_->popup(point());
|
||||||
|
this->menu_->move(point());
|
||||||
|
this->menuVisible_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "widgets/BaseWidget.hpp"
|
#include "widgets/BaseWidget.hpp"
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
@ -43,6 +44,8 @@ public:
|
||||||
void setBorderColor(const QColor &color);
|
void setBorderColor(const QColor &color);
|
||||||
const QColor &getBorderColor() const;
|
const QColor &getBorderColor() const;
|
||||||
|
|
||||||
|
void setMenu(std::unique_ptr<QMenu> menu);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
void leftMousePress();
|
void leftMousePress();
|
||||||
|
@ -57,22 +60,25 @@ protected:
|
||||||
|
|
||||||
void fancyPaint(QPainter &painter);
|
void fancyPaint(QPainter &painter);
|
||||||
|
|
||||||
bool enabled_ = true;
|
bool enabled_{true};
|
||||||
bool selected_ = false;
|
bool selected_{false};
|
||||||
bool mouseOver_ = false;
|
bool mouseOver_{false};
|
||||||
bool mouseDown_ = false;
|
bool mouseDown_{false};
|
||||||
|
bool menuVisible_{false};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onMouseEffectTimeout();
|
void onMouseEffectTimeout();
|
||||||
|
void showMenu();
|
||||||
|
|
||||||
QColor borderColor_;
|
QColor borderColor_{};
|
||||||
QPixmap pixmap_;
|
QPixmap pixmap_{};
|
||||||
bool dimPixmap_ = true;
|
bool dimPixmap_{true};
|
||||||
QPoint mousePos_;
|
QPoint mousePos_{};
|
||||||
double hoverMultiplier_ = 0.0;
|
double hoverMultiplier_{0.0};
|
||||||
QTimer effectTimer_;
|
QTimer effectTimer_{};
|
||||||
std::vector<ClickEffect> clickEffects_;
|
std::vector<ClickEffect> clickEffects_{};
|
||||||
boost::optional<QColor> mouseEffectColor_ = boost::none;
|
boost::optional<QColor> mouseEffectColor_{};
|
||||||
|
std::unique_ptr<QMenu> menu_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1140,9 +1140,13 @@ void SplitContainer::ResizeHandle::paintEvent(QPaintEvent *)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitContainer::ResizeHandle::mousePressEvent(QMouseEvent *)
|
void SplitContainer::ResizeHandle::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
this->isMouseDown_ = true;
|
this->isMouseDown_ = true;
|
||||||
|
|
||||||
|
if (event->button() == Qt::RightButton) {
|
||||||
|
this->resetFlex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitContainer::ResizeHandle::mouseReleaseEvent(QMouseEvent *)
|
void SplitContainer::ResizeHandle::mouseReleaseEvent(QMouseEvent *)
|
||||||
|
@ -1211,6 +1215,11 @@ void SplitContainer::ResizeHandle::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
|
this->resetFlex();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplitContainer::ResizeHandle::resetFlex()
|
||||||
|
{
|
||||||
for (auto &sibling : this->node->getParent()->getChildren()) {
|
for (auto &sibling : this->node->getParent()->getChildren()) {
|
||||||
sibling->flexH_ = 1;
|
sibling->flexH_ = 1;
|
||||||
sibling->flexV_ = 1;
|
sibling->flexV_ = 1;
|
||||||
|
|
|
@ -161,6 +161,8 @@ private:
|
||||||
friend class SplitContainer;
|
friend class SplitContainer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void resetFlex();
|
||||||
|
|
||||||
bool vertical_;
|
bool vertical_;
|
||||||
bool isMouseDown_ = false;
|
bool isMouseDown_ = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
#include "singletons/Resources.hpp"
|
#include "singletons/Resources.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
#include "util/FunctionEventFilter.hpp"
|
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
#include "widgets/Label.hpp"
|
#include "widgets/Label.hpp"
|
||||||
#include "widgets/TooltipWidget.hpp"
|
#include "widgets/TooltipWidget.hpp"
|
||||||
|
@ -17,6 +16,7 @@
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
#include <QMenu>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
@ -55,15 +55,7 @@ SplitHeader::SplitHeader(Split *_split)
|
||||||
|
|
||||||
this->setupModeLabel(*mode);
|
this->setupModeLabel(*mode);
|
||||||
|
|
||||||
QObject::connect(
|
mode->setMenu(this->createChatModeMenu());
|
||||||
mode.getElement(), &RippleEffectLabel::clicked, this, [this] {
|
|
||||||
QTimer::singleShot(80, this, [&, this] {
|
|
||||||
ChannelPtr _channel = this->split_->getChannel();
|
|
||||||
if (_channel->hasModRights()) {
|
|
||||||
this->modeMenu_.popup(QCursor::pos());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// moderation mode
|
// moderation mode
|
||||||
auto moderator = layout.emplace<RippleEffectButton>(this).assign(
|
auto moderator = layout.emplace<RippleEffectButton>(this).assign(
|
||||||
|
@ -86,14 +78,9 @@ SplitHeader::SplitHeader(Split *_split)
|
||||||
dropdown->setMouseTracking(true);
|
dropdown->setMouseTracking(true);
|
||||||
// dropdown->setPixmap(*app->resources->splitHeaderContext->getPixmap());
|
// dropdown->setPixmap(*app->resources->splitHeaderContext->getPixmap());
|
||||||
// dropdown->setScaleIndependantSize(23, 23);
|
// dropdown->setScaleIndependantSize(23, 23);
|
||||||
this->addDropdownItems(dropdown.getElement());
|
dropdown->setMenu(this->createMainMenu());
|
||||||
QObject::connect(dropdown.getElement(),
|
QObject::connect(dropdown.getElement(),
|
||||||
&RippleEffectButton::leftMousePress, this, [this] {
|
&RippleEffectButton::leftMousePress, this, [this] {});
|
||||||
if (!this->menuVisible_) {
|
|
||||||
QTimer::singleShot(
|
|
||||||
80, this, [this] { this->showMenu(); });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- misc
|
// ---- misc
|
||||||
|
@ -111,8 +98,6 @@ SplitHeader::SplitHeader(Split *_split)
|
||||||
this->managedConnect(app->accounts->twitch.currentUserChanged,
|
this->managedConnect(app->accounts->twitch.currentUserChanged,
|
||||||
[this] { this->updateModerationModeIcon(); });
|
[this] { this->updateModerationModeIcon(); });
|
||||||
|
|
||||||
this->addModeActions(this->modeMenu_);
|
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
// Update title on title-settings-change
|
// Update title on title-settings-change
|
||||||
|
@ -128,15 +113,6 @@ SplitHeader::SplitHeader(Split *_split)
|
||||||
getSettings()->showUptime.connect(
|
getSettings()->showUptime.connect(
|
||||||
[this](const auto &, const auto &) { this->updateChannelText(); },
|
[this](const auto &, const auto &) { this->updateChannelText(); },
|
||||||
this->managedConnections_);
|
this->managedConnections_);
|
||||||
|
|
||||||
this->dropdownMenu_.installEventFilter(
|
|
||||||
new FunctionEventFilter(this, [this](QObject *, QEvent *event) {
|
|
||||||
if (event->type() == QEvent::Hide) {
|
|
||||||
QTimer::singleShot(20, this,
|
|
||||||
[this] { this->menuVisible_ = false; });
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SplitHeader::~SplitHeader()
|
SplitHeader::~SplitHeader()
|
||||||
|
@ -144,63 +120,129 @@ SplitHeader::~SplitHeader()
|
||||||
this->onlineStatusChangedConnection_.disconnect();
|
this->onlineStatusChangedConnection_.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitHeader::addDropdownItems(RippleEffectButton *)
|
std::unique_ptr<QMenu> SplitHeader::createMainMenu()
|
||||||
{
|
{
|
||||||
// clang-format off
|
auto menu = std::make_unique<QMenu>();
|
||||||
this->dropdownMenu_.addAction("New split", this->split_, &Split::doAddSplit, QKeySequence(tr("Ctrl+T")));
|
menu->addAction("New split", this->split_, &Split::doAddSplit,
|
||||||
this->dropdownMenu_.addAction("Close split", this->split_, &Split::doCloseSplit, QKeySequence(tr("Ctrl+W")));
|
QKeySequence(tr("Ctrl+T")));
|
||||||
this->dropdownMenu_.addAction("Change channel", this->split_, &Split::doChangeChannel, QKeySequence(tr("Ctrl+R")));
|
menu->addAction("Close split", this->split_, &Split::doCloseSplit,
|
||||||
this->dropdownMenu_.addSeparator();
|
QKeySequence(tr("Ctrl+W")));
|
||||||
this->dropdownMenu_.addAction("Viewer list", this->split_, &Split::showViewerList);
|
menu->addAction("Change channel", this->split_, &Split::doChangeChannel,
|
||||||
this->dropdownMenu_.addAction("Search", this->split_, &Split::showSearchPopup, QKeySequence(tr("Ctrl+F")));
|
QKeySequence(tr("Ctrl+R")));
|
||||||
this->dropdownMenu_.addSeparator();
|
menu->addSeparator();
|
||||||
this->dropdownMenu_.addAction("Popup", this->split_, &Split::doPopup);
|
menu->addAction("Viewer list", this->split_, &Split::showViewerList);
|
||||||
|
menu->addAction("Search", this->split_, &Split::showSearchPopup,
|
||||||
|
QKeySequence(tr("Ctrl+F")));
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction("Popup", this->split_, &Split::doPopup);
|
||||||
#ifdef USEWEBENGINE
|
#ifdef USEWEBENGINE
|
||||||
this->dropdownMenu.addAction("Start watching", this, [this]{
|
this->dropdownMenu.addAction("Start watching", this, [this] {
|
||||||
ChannelPtr _channel = this->split->getChannel();
|
ChannelPtr _channel = this->split->getChannel();
|
||||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_channel.get());
|
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(_channel.get());
|
||||||
|
|
||||||
if (tc != nullptr) {
|
if (tc != nullptr) {
|
||||||
StreamView *view = new StreamView(_channel, "https://player.twitch.tv/?channel=" + tc->name);
|
StreamView *view = new StreamView(
|
||||||
|
_channel, "https://player.twitch.tv/?channel=" + tc->name);
|
||||||
view->setAttribute(Qt::WA_DeleteOnClose, true);
|
view->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
view->show();
|
view->show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
this->dropdownMenu_.addAction("Open browser", this->split_, &Split::openInBrowser);
|
menu->addAction("Open in browser", this->split_, &Split::openInBrowser);
|
||||||
#ifndef USEWEBENGINE
|
#ifndef USEWEBENGINE
|
||||||
this->dropdownMenu_.addAction("Open browser popup", this->split_, &Split::openInPopupPlayer);
|
menu->addAction("Open player in browser", this->split_,
|
||||||
|
&Split::openInPopupPlayer);
|
||||||
#endif
|
#endif
|
||||||
this->dropdownMenu_.addAction("Open streamlink", this->split_, &Split::openInStreamlink);
|
menu->addAction("Open streamlink", this->split_, &Split::openInStreamlink);
|
||||||
this->dropdownMenu_.addSeparator();
|
menu->addSeparator();
|
||||||
this->dropdownMenu_.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
|
menu->addAction("Reload channel emotes", this,
|
||||||
this->dropdownMenu_.addAction("Reconnect", this, SLOT(menuManualReconnect()));
|
SLOT(menuReloadChannelEmotes()));
|
||||||
this->dropdownMenu_.addAction("Clear messages", this->split_, &Split::doClearChat);
|
menu->addAction("Reconnect", this, SLOT(menuManualReconnect()));
|
||||||
// this->dropdownMenu.addSeparator();
|
// menu->addAction("Clear messages", this->split_, &Split::doClearChat);
|
||||||
// this->dropdownMenu.addAction("Show changelog", this, SLOT(menuShowChangelog()));
|
// menu->addSeparator();
|
||||||
// clang-format on
|
// menu->addAction("Show changelog", this, SLOT(menuShowChangelog()));
|
||||||
|
|
||||||
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitHeader::showMenu()
|
std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
|
||||||
{
|
{
|
||||||
auto point = [this] {
|
auto menu = std::make_unique<QMenu>();
|
||||||
auto bounds = QApplication::desktop()->availableGeometry(this);
|
|
||||||
|
|
||||||
auto point = this->dropdownButton_->mapToGlobal(
|
auto setSub = new QAction("Subscriber only", this);
|
||||||
QPoint(this->dropdownButton_->width() - this->dropdownMenu_.width(),
|
auto setEmote = new QAction("Emote only", this);
|
||||||
this->dropdownButton_->height()));
|
auto setSlow = new QAction("Slow", this);
|
||||||
|
auto setR9k = new QAction("R9K", this);
|
||||||
|
|
||||||
if (point.y() + this->dropdownMenu_.height() > bounds.bottom()) {
|
setSub->setCheckable(true);
|
||||||
point.setY(point.y() - this->dropdownMenu_.height() -
|
setEmote->setCheckable(true);
|
||||||
this->dropdownButton_->height());
|
setSlow->setCheckable(true);
|
||||||
|
setR9k->setCheckable(true);
|
||||||
|
|
||||||
|
menu->addAction(setEmote);
|
||||||
|
menu->addAction(setSub);
|
||||||
|
menu->addAction(setSlow);
|
||||||
|
menu->addAction(setR9k);
|
||||||
|
|
||||||
|
this->managedConnections_.push_back(this->modeUpdateRequested_.connect( //
|
||||||
|
[this, setSub, setEmote, setSlow, setR9k]() {
|
||||||
|
auto twitchChannel =
|
||||||
|
dynamic_cast<TwitchChannel *>(this->split_->getChannel().get());
|
||||||
|
if (twitchChannel == nullptr) {
|
||||||
|
this->modeButton_->hide();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return point;
|
auto roomModes = twitchChannel->accessRoomModes();
|
||||||
|
|
||||||
|
setR9k->setChecked(roomModes->r9k);
|
||||||
|
setSlow->setChecked(roomModes->slowMode);
|
||||||
|
setEmote->setChecked(roomModes->emoteOnly);
|
||||||
|
setSub->setChecked(roomModes->submode);
|
||||||
|
}));
|
||||||
|
|
||||||
|
auto toggle = [this](const QString &_command, QAction *action) mutable {
|
||||||
|
QString command = _command;
|
||||||
|
|
||||||
|
if (!action->isChecked()) {
|
||||||
|
command += "off";
|
||||||
|
};
|
||||||
|
action->setChecked(!action->isChecked());
|
||||||
|
|
||||||
|
qDebug() << command;
|
||||||
|
this->split_->getChannel().get()->sendMessage(command);
|
||||||
};
|
};
|
||||||
|
|
||||||
this->dropdownMenu_.popup(point());
|
QObject::connect(
|
||||||
this->dropdownMenu_.move(point());
|
setSub, &QAction::triggered, this,
|
||||||
this->menuVisible_ = true;
|
[setSub, toggle]() mutable { toggle("/subscribers", setSub); });
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
setEmote, &QAction::triggered, this,
|
||||||
|
[setEmote, toggle]() mutable { toggle("/emoteonly", setEmote); });
|
||||||
|
|
||||||
|
QObject::connect(setSlow, &QAction::triggered, this, [setSlow, this]() {
|
||||||
|
if (!setSlow->isChecked()) {
|
||||||
|
this->split_->getChannel().get()->sendMessage("/slowoff");
|
||||||
|
setSlow->setChecked(false);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
bool ok;
|
||||||
|
int slowSec = QInputDialog::getInt(this, "", "Seconds:", 10, 0, 500, 1,
|
||||||
|
&ok, Qt::FramelessWindowHint);
|
||||||
|
if (ok) {
|
||||||
|
this->split_->getChannel().get()->sendMessage(
|
||||||
|
QString("/slow %1").arg(slowSec));
|
||||||
|
} else {
|
||||||
|
setSlow->setChecked(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
setR9k, &QAction::triggered, this,
|
||||||
|
[setR9k, toggle]() mutable { toggle("/r9kbeta", setR9k); });
|
||||||
|
|
||||||
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitHeader::updateRoomModes()
|
void SplitHeader::updateRoomModes()
|
||||||
|
@ -263,82 +305,6 @@ void SplitHeader::setupModeLabel(RippleEffectLabel &label)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitHeader::addModeActions(QMenu &menu)
|
|
||||||
{
|
|
||||||
auto setSub = new QAction("Subscriber only", this);
|
|
||||||
auto setEmote = new QAction("Emote only", this);
|
|
||||||
auto setSlow = new QAction("Slow", this);
|
|
||||||
auto setR9k = new QAction("R9K", this);
|
|
||||||
|
|
||||||
setSub->setCheckable(true);
|
|
||||||
setEmote->setCheckable(true);
|
|
||||||
setSlow->setCheckable(true);
|
|
||||||
setR9k->setCheckable(true);
|
|
||||||
|
|
||||||
menu.addAction(setEmote);
|
|
||||||
menu.addAction(setSub);
|
|
||||||
menu.addAction(setSlow);
|
|
||||||
menu.addAction(setR9k);
|
|
||||||
|
|
||||||
this->managedConnections_.push_back(this->modeUpdateRequested_.connect( //
|
|
||||||
[this, setSub, setEmote, setSlow, setR9k]() {
|
|
||||||
auto twitchChannel =
|
|
||||||
dynamic_cast<TwitchChannel *>(this->split_->getChannel().get());
|
|
||||||
if (twitchChannel == nullptr) {
|
|
||||||
this->modeButton_->hide();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto roomModes = twitchChannel->accessRoomModes();
|
|
||||||
|
|
||||||
setR9k->setChecked(roomModes->r9k);
|
|
||||||
setSlow->setChecked(roomModes->slowMode);
|
|
||||||
setEmote->setChecked(roomModes->emoteOnly);
|
|
||||||
setSub->setChecked(roomModes->submode);
|
|
||||||
}));
|
|
||||||
|
|
||||||
auto toggle = [this](const QString &_command, QAction *action) mutable {
|
|
||||||
QString command = _command;
|
|
||||||
|
|
||||||
if (!action->isChecked()) {
|
|
||||||
command += "off";
|
|
||||||
};
|
|
||||||
action->setChecked(!action->isChecked());
|
|
||||||
|
|
||||||
qDebug() << command;
|
|
||||||
this->split_->getChannel().get()->sendMessage(command);
|
|
||||||
};
|
|
||||||
|
|
||||||
QObject::connect(
|
|
||||||
setSub, &QAction::triggered, this,
|
|
||||||
[setSub, toggle]() mutable { toggle("/subscribers", setSub); });
|
|
||||||
|
|
||||||
QObject::connect(
|
|
||||||
setEmote, &QAction::triggered, this,
|
|
||||||
[setEmote, toggle]() mutable { toggle("/emoteonly", setEmote); });
|
|
||||||
|
|
||||||
QObject::connect(setSlow, &QAction::triggered, this, [setSlow, this]() {
|
|
||||||
if (!setSlow->isChecked()) {
|
|
||||||
this->split_->getChannel().get()->sendMessage("/slowoff");
|
|
||||||
setSlow->setChecked(false);
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
bool ok;
|
|
||||||
int slowSec = QInputDialog::getInt(this, "", "Seconds:", 10, 0, 500, 1,
|
|
||||||
&ok, Qt::FramelessWindowHint);
|
|
||||||
if (ok) {
|
|
||||||
this->split_->getChannel().get()->sendMessage(
|
|
||||||
QString("/slow %1").arg(slowSec));
|
|
||||||
} else {
|
|
||||||
setSlow->setChecked(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
QObject::connect(
|
|
||||||
setR9k, &QAction::triggered, this,
|
|
||||||
[setR9k, toggle]() mutable { toggle("/r9kbeta", setR9k); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void SplitHeader::initializeChannelSignals()
|
void SplitHeader::initializeChannelSignals()
|
||||||
{
|
{
|
||||||
// Disconnect any previous signal first
|
// Disconnect any previous signal first
|
||||||
|
@ -438,9 +404,9 @@ void SplitHeader::updateModerationModeIcon()
|
||||||
bool modButtonVisible = false;
|
bool modButtonVisible = false;
|
||||||
ChannelPtr channel = this->split_->getChannel();
|
ChannelPtr channel = this->split_->getChannel();
|
||||||
|
|
||||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(channel.get());
|
auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||||
|
|
||||||
if (tc != nullptr && tc->hasModRights()) {
|
if (twitchChannel != nullptr && twitchChannel->hasModRights()) {
|
||||||
modButtonVisible = true;
|
modButtonVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,12 +51,11 @@ protected:
|
||||||
private:
|
private:
|
||||||
void rightButtonClicked();
|
void rightButtonClicked();
|
||||||
void initializeChannelSignals();
|
void initializeChannelSignals();
|
||||||
void addModeActions(QMenu &menu);
|
|
||||||
void setupModeLabel(RippleEffectLabel &label);
|
void setupModeLabel(RippleEffectLabel &label);
|
||||||
void addDropdownItems(RippleEffectButton *label);
|
std::unique_ptr<QMenu> createMainMenu();
|
||||||
void showMenu();
|
std::unique_ptr<QMenu> createChatModeMenu();
|
||||||
|
|
||||||
Split *const split_;
|
Split *split_;
|
||||||
|
|
||||||
QPoint dragStart_;
|
QPoint dragStart_;
|
||||||
bool dragging_ = false;
|
bool dragging_ = false;
|
||||||
|
@ -71,9 +70,6 @@ private:
|
||||||
RippleEffectLabel *modeButton_{};
|
RippleEffectLabel *modeButton_{};
|
||||||
RippleEffectButton *moderationButton_{};
|
RippleEffectButton *moderationButton_{};
|
||||||
|
|
||||||
QMenu dropdownMenu_;
|
|
||||||
QMenu modeMenu_;
|
|
||||||
|
|
||||||
bool menuVisible_{};
|
bool menuVisible_{};
|
||||||
|
|
||||||
pajlada::Signals::NoArgSignal modeUpdateRequested_;
|
pajlada::Signals::NoArgSignal modeUpdateRequested_;
|
||||||
|
|
1
tools/windows-fix-directory-case-sensitivity.sh
Normal file
1
tools/windows-fix-directory-case-sensitivity.sh
Normal file
|
@ -0,0 +1 @@
|
||||||
|
find . -not -path "*.git*" -exec fsutil.exe file setCaseSensitiveInfo {} disable \;
|
Loading…
Reference in a new issue