From 86e4a669ad35914d07a9b39eace91dc4610507d0 Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 6 Jun 2018 10:46:23 +0200 Subject: [PATCH] added basic new user popup --- chatterino.pro | 6 +- resources/images/buttons/ban.png | Bin 0 -> 1956 bytes resources/images/buttons/mod.png | Bin 0 -> 376 bytes resources/images/buttons/unban.png | Bin 0 -> 1974 bytes resources/images/buttons/unmod.png | Bin 0 -> 349 bytes resources/resources.qrc | 4 + src/singletons/resourcemanager.cpp | 6 + src/singletons/resourcemanager.hpp | 7 + src/util/signalvectormodel.hpp | 7 + src/widgets/accountpopup2.cpp | 172 ++++++++++++++++++++++ src/widgets/accountpopup2.hpp | 45 ++++++ src/widgets/basewindow.cpp | 23 ++- src/widgets/basewindow.hpp | 5 +- src/widgets/helper/channelview.cpp | 15 +- src/widgets/helper/notebookbutton.cpp | 8 +- src/widgets/helper/notebookbutton.hpp | 2 +- src/widgets/helper/rippleeffectbutton.cpp | 113 ++++++++------ src/widgets/helper/rippleeffectbutton.hpp | 26 ++-- src/widgets/helper/splitheader.cpp | 6 +- src/widgets/helper/splitinput.cpp | 3 +- src/widgets/notificationpopup.cpp | 2 +- 21 files changed, 365 insertions(+), 85 deletions(-) create mode 100644 resources/images/buttons/ban.png create mode 100644 resources/images/buttons/mod.png create mode 100644 resources/images/buttons/unban.png create mode 100644 resources/images/buttons/unmod.png create mode 100644 src/widgets/accountpopup2.cpp create mode 100644 src/widgets/accountpopup2.hpp diff --git a/chatterino.pro b/chatterino.pro index 7ea3c72ce..b70038ee4 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -216,7 +216,8 @@ SOURCES += \ src/controllers/taggedusers/taggeduser.cpp \ src/controllers/taggedusers/taggedusersmodel.cpp \ src/util/emotemap.cpp \ - src/providers/irc/ircconnection2.cpp + src/providers/irc/ircconnection2.cpp \ + src/widgets/accountpopup2.cpp HEADERS += \ src/precompiled_header.hpp \ @@ -374,7 +375,8 @@ HEADERS += \ src/controllers/taggedusers/taggedusersmodel.hpp \ src/util/qstringhash.hpp \ src/util/mutexvalue.hpp \ - src/providers/irc/ircconnection2.hpp + src/providers/irc/ircconnection2.hpp \ + src/widgets/accountpopup2.hpp RESOURCES += \ resources/resources.qrc diff --git a/resources/images/buttons/ban.png b/resources/images/buttons/ban.png new file mode 100644 index 0000000000000000000000000000000000000000..af6b1ac6a951a1763562662faa2925f21a028f88 GIT binary patch literal 1956 zcmV;V2V3}wP)004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00009 za7bBm000id000id0mpBsWB>pF2XskIMF-&l4HX0##4Mk+0000PbVXQnQ*UN;cVTj6 z0B~VxZgehgWpp4kE-)@KG4UX2l>h(+;z>k7RCr$PTT5>oMG*FxU?+BLuf2XlCMbWz z;?A$&A0UKK*1PuZ%o>nm?BK|PARgLXuOqksijV*a83C6_ToDf;5+oi65Y7?4Z>D?G z8rSUh%=A7$F6q-u)-%;r)z#HiHJ!0@I;V5$JH1jq7`rq5n0GvV;e~c#qI^`Gs<)PA zc3aD{`yp_Dv@o^JzwsG9Tie)IZ~sRrRCwm`7h6lSdyOZTK7fM1$i{ywf)Rvax{zORgNHNY4nM-+;}HCN|vx92bY zB`M(o?YWB&n`^~)=~?*q@V&w>?}x6=b=*(IC19D{#nr2pZz^d9OdOo+6R!TPDcB&v zr2(&~;NB};KU9+SnS#ozq4JpV_e^1iiKF7=hq!w6YM$mY>rtV?jcC}+29QFU6m&PX7aWH0^>)xdj4h( zBXBLLR8$-!2`Wf>L7u@C)uPz5j!F2{9K#0mq|8gfFDchwoc=D(I0>9}4vKrvf9@s4 zDLZK|fDB)oJdH+$q;Y4`?yuw|fRyt6l zbfKy$aBOEk3^Wxt&5K$o8r!Av8f>%#Hgbk*Kia-TMkZ8l;G`_g>h|rzgjM2%gzF6} zFU7-5dVY*Eh=Z<=tCOvcf{|BR+ApW;Fup@9AMZt7KjVcfYQOyRCi3xg% zi*;|L*{PL3E<}MB_b*G&#KE3pSDE=o8~0c70Yyi?*;h$UX61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M6ShH~5Q+RXxYPMkA7r2|Cx{I-5KaA!r?*x* zTwLh2*_#ADR`~$WGsOWY7s6W{HqjJ|Ako@iKg?cJD-^cKVj=f^Jmbss%8YpIEHcpG zp@q2&iYY5OE|e#+-pB1(>cd3GD3(9kFj6Nr9!)+|gqP9mNkL&lS?<`qXdh9`S0~=; zH~_W<5pJ1$AD{a+^CZf^_+IKKidOxy-2jmAqBmC?`zhKu3gvK?`mH>8asoOY-YDPZ zv4GN+$kb*T5J``#4wTPm_L?XwlD_RLL}k<@U%zmn<7(NxHkLpa(IV8DJAw9 z1$LWU;xkJQ0uu*`p)Fj`JY@pkM9M>kJv@^i-UPbbY_TIq=!WuK^R{MBSbP3BVy9RJ zyoV=t5C%eQsG^&3JUD2LTLu4^Ql@9T+h2&_dPiy&xBVwe|W+m{V}eVl0w=`8mHS zcHn%-SnSjWT$3zavwF+I1kIXYC5Ocf=JP7T6x-VX{CIUY)y1r~WbD0}2BDkK%KJ!= zxMUoeYSrNX2bsQT$#Vwm@3(j}LtRb~6^w#eC<~a37wBj3o#(HljOPb| z{9NcXIfJa0#LT=By}Z;C1rt33 zJtM=93Yk-Ziq3kvIEGmGCr79sa%EezbX&2j<^6b@c7+a(#N6Y_haXmTTrE3so;Q*| z@Yc5*vlhLyjGx0j@zBcL_JwS-<_U97EQl1zeSNf2u}626QAQQt&s_(nG75HWi=O}0o6N}!#dsHH@3vgX{vv9JiC#;A oii`A|Zh1vkPR$OTT%{NWxf$J@ZKjdmfF5J;boFyt=akR{0C-V*W&i*H literal 0 HcmV?d00001 diff --git a/resources/resources.qrc b/resources/resources.qrc index 19383a849..56f593835 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -61,6 +61,10 @@ licenses/rapidjson.txt licenses/websocketpp.txt emoji.json + images/buttons/ban.png + images/buttons/mod.png + images/buttons/unban.png + images/buttons/unmod.png qt.conf diff --git a/src/singletons/resourcemanager.cpp b/src/singletons/resourcemanager.cpp index b989261c7..c37504ab2 100644 --- a/src/singletons/resourcemanager.cpp +++ b/src/singletons/resourcemanager.cpp @@ -294,6 +294,12 @@ ResourceManager::ResourceManager() this->split.up = QIcon(":/images/split/splitup.png"); this->split.down = QIcon(":/images/split/splitdown.png"); this->split.move = QIcon(":/images/split/splitmove.png"); + + this->buttons.ban = QPixmap(":/images/buttons/ban.png"); + this->buttons.unban = QPixmap(":/images/buttons/unban.png"); + this->buttons.mod = QPixmap(":/images/buttons/mod.png"); + this->buttons.unmod = QPixmap(":/images/buttons/unmod.png"); + qDebug() << "init ResourceManager"; } diff --git a/src/singletons/resourcemanager.hpp b/src/singletons/resourcemanager.hpp index 487b0f410..240aa4ae3 100644 --- a/src/singletons/resourcemanager.hpp +++ b/src/singletons/resourcemanager.hpp @@ -29,6 +29,13 @@ public: QIcon move; } split; + struct { + QPixmap ban; + QPixmap unban; + QPixmap mod; + QPixmap unmod; + } buttons; + messages::Image *badgeStaff; messages::Image *badgeAdmin; messages::Image *badgeGlobalModerator; diff --git a/src/util/signalvectormodel.hpp b/src/util/signalvectormodel.hpp index 3ab94a26a..7c5c72f08 100644 --- a/src/util/signalvectormodel.hpp +++ b/src/util/signalvectormodel.hpp @@ -28,6 +28,9 @@ public: this->vector = vec; auto insert = [this](const SignalVectorItemArgs &args) { + if (args.caller == this) { + return; + } // get row index int index = this->getModelIndexFromVectorIndex(args.index); assert(index >= 0 && index <= this->rows.size()); @@ -54,6 +57,10 @@ public: this->managedConnect(vec->itemInserted, insert); this->managedConnect(vec->itemRemoved, [this](auto args) { + if (args.caller == this) { + return; + } + int row = this->getModelIndexFromVectorIndex(args.index); assert(row >= 0 && row <= this->rows.size()); diff --git a/src/widgets/accountpopup2.cpp b/src/widgets/accountpopup2.cpp new file mode 100644 index 000000000..1f67344eb --- /dev/null +++ b/src/widgets/accountpopup2.cpp @@ -0,0 +1,172 @@ +#include "accountpopup2.hpp" + +#include "application.hpp" +#include "singletons/resourcemanager.hpp" +#include "util/layoutcreator.hpp" +#include "widgets/helper/rippleeffectlabel.hpp" + +#include + +namespace chatterino { +namespace widgets { + +AccountPopup2::AccountPopup2() + : BaseWindow(nullptr, BaseWindow::Frameless) +{ + auto app = getApp(); + + auto layout = util::LayoutCreator(this).setLayoutType(); + + // first line + auto head = layout.emplace(); + { + // avatar + auto avatar = head.emplace("Avatar").assign(&this->ui.label); + avatar->setFixedSize(100, 100); + + // items on the right + auto vbox = head.emplace(); + { + vbox.emplace("Name"); + vbox.emplace("Views"); + vbox.emplace("Followers"); + vbox.emplace("Create date"); + } + } + + // second line + auto user = layout.emplace(); + { + user->addStretch(1); + + auto ignore = user.emplace(); + ignore->getLabel().setText("Ignore"); + ignore->setScaleIndependantHeight(24); + + auto ignoreHighlights = user.emplace(); + ignoreHighlights->getLabel().setText("Ignore highlights"); + ignoreHighlights->setScaleIndependantHeight(24); + + user->addStretch(1); + } + + // third line + auto moderation = layout.emplace(); + moderation->setSpacing(0); + { + auto unban = moderation.emplace(); + unban->setPixmap(app->resources->buttons.unban); + unban->setScaleIndependantSize(32, 32); + unban->setBorderColor(QColor(255, 255, 255, 127)); + + moderation.emplace(); + + auto ban = moderation.emplace(); + ban->setPixmap(app->resources->buttons.ban); + ban->setScaleIndependantSize(32, 32); + ban->setBorderColor(QColor(255, 255, 255, 127)); + + // auto mod = moderation.emplace(this); + // mod->setPixmap(app->resources->buttons.mod); + // mod->setScaleIndependantSize(30, 30); + // auto unmod = moderation.emplace(); + // unmod->setPixmap(app->resources->buttons.unmod); + // unmod->setScaleIndependantSize(30, 30); + + this->userStateChanged.connect([=]() mutable { + // mod->setVisible(this->isBroadcaster_); + // unmod->setVisible(this->isBroadcaster_); + + ban->setVisible(this->isMod_); + unban->setVisible(this->isMod_); + }); + } + + this->setStyleSheet("font-size: 12pt"); +} + +// void AccountPopup2::scaleChangedEvent(float newScale) +//{ +//} + +void AccountPopup2::setName(const QString &name) +{ +} + +void AccountPopup2::setChannel(const ChannelPtr &_channel) +{ +} + +// +// TimeoutWidget +// +AccountPopup2::TimeoutWidget::TimeoutWidget() + : BaseWidget(nullptr) +{ + auto layout = util::LayoutCreator(this).setLayoutType(); + + QColor color1(255, 255, 255, 127); + QColor color2(255, 255, 255, 80); + + int buttonWidth = 40; + int buttonWidth2 = 20; + int buttonHeight = 32; + + layout->setSpacing(1); + + auto a = layout.emplace(); + a->getLabel().setText("1s"); + a->setScaleIndependantSize(buttonWidth, buttonHeight); + a->setBorderColor(color1); + auto a1 = layout.emplace(nullptr); + // a1->getLabel().setText("1m"); + a1->setScaleIndependantSize(buttonWidth2, buttonHeight); + a1->setBorderColor(color2); + auto a2 = layout.emplace(nullptr); + // a2->getLabel().setText("5m"); + a2->setScaleIndependantSize(buttonWidth2, buttonHeight); + a2->setBorderColor(color2); + + auto b = layout.emplace(); + b->getLabel().setText("10m"); + b->setScaleIndependantSize(buttonWidth, buttonHeight); + b->setBorderColor(color1); + auto b1 = layout.emplace(nullptr); + b1->setScaleIndependantSize(buttonWidth2, buttonHeight); + b1->setBorderColor(color2); + // b1->getLabel().setText("1h"); + auto b2 = layout.emplace(nullptr); + b2->setScaleIndependantSize(buttonWidth2, buttonHeight); + b2->setBorderColor(color2); + // b2->getLabel().setText("4h"); + + auto c = layout.emplace(); + c->getLabel().setText("1d"); + c->setScaleIndependantSize(buttonWidth, buttonHeight); + c->setBorderColor(color1); + auto c1 = layout.emplace(nullptr); + // c1->getLabel().setText("3d"); + c1->setScaleIndependantSize(buttonWidth2, buttonHeight); + c1->setBorderColor(color2); + auto c2 = layout.emplace(nullptr); + // c2->getLabel().setText("1w"); + c2->setScaleIndependantSize(buttonWidth2, buttonHeight); + c2->setBorderColor(color2); + + auto d = layout.emplace(); + d->getLabel().setText("2w"); + d->setScaleIndependantSize(buttonWidth, buttonHeight); + d->setBorderColor(color1); +} + +void AccountPopup2::TimeoutWidget::paintEvent(QPaintEvent *) +{ + // QPainter painter(this); + + // painter.setPen(QColor(255, 255, 255, 63)); + + // painter.drawLine(0, this->height() / 2, this->width(), this->height() / 2); +} + +} // namespace widgets +} // namespace chatterino diff --git a/src/widgets/accountpopup2.hpp b/src/widgets/accountpopup2.hpp new file mode 100644 index 000000000..7b68c9762 --- /dev/null +++ b/src/widgets/accountpopup2.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include "channel.hpp" +#include "widgets/basewindow.hpp" + +#include + +class QLabel; + +namespace chatterino { +namespace widgets { + +class AccountPopup2 final : public BaseWindow +{ +public: + AccountPopup2(); + + void setName(const QString &name); + void setChannel(const ChannelPtr &_channel); + + struct { + QLabel *label = nullptr; + } ui; + +protected: + // virtual void scaleChangedEvent(float newScale) override; + +private: + bool isMod_; + bool isBroadcaster_; + + pajlada::Signals::NoArgSignal userStateChanged; + + class TimeoutWidget : public BaseWidget + { + public: + TimeoutWidget(); + + protected: + void paintEvent(QPaintEvent *event) override; + }; +}; + +} // namespace widgets +} // namespace chatterino diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index 5e533357b..1bda125f8 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -36,7 +36,7 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags) : BaseWidget(parent, Qt::Window | ((_flags & TopMost) ? Qt::WindowStaysOnTopHint : Qt::WindowFlags(0))) , enableCustomFrame(_flags & EnableCustomFrame) - , frameless(_flags & FrameLess) + , frameless(_flags & Frameless) , flags(_flags) { if (this->frameless) { @@ -447,8 +447,22 @@ void BaseWindow::showEvent(QShowEvent *event) BaseWidget::showEvent(event); } +void BaseWindow::scaleChangedEvent(float) +{ + this->calcButtonsSizes(); +} +#endif + void BaseWindow::paintEvent(QPaintEvent *) { + if (this->frameless) { + QPainter painter(this); + + painter.setPen(QColor("#999")); + painter.drawRect(0, 0, this->width() - 1, this->height() - 1); + } + +#ifdef USEWINSDK if (this->hasCustomWindowFrame()) { QPainter painter(this); @@ -457,13 +471,8 @@ void BaseWindow::paintEvent(QPaintEvent *) painter.fillRect(QRect(0, 1, this->width() - 0, this->height() - 0), this->themeManager->window.background); } -} - -void BaseWindow::scaleChangedEvent(float) -{ - this->calcButtonsSizes(); -} #endif +} void BaseWindow::calcButtonsSizes() { diff --git a/src/widgets/basewindow.hpp b/src/widgets/basewindow.hpp index ec5776b6c..ccd06f39b 100644 --- a/src/widgets/basewindow.hpp +++ b/src/widgets/basewindow.hpp @@ -19,7 +19,7 @@ class BaseWindow : public BaseWidget Q_OBJECT public: - enum Flags { None = 0, EnableCustomFrame = 1, FrameLess = 2, TopMost = 4 }; + enum Flags { None = 0, EnableCustomFrame = 1, Frameless = 2, TopMost = 4 }; explicit BaseWindow(QWidget *parent = nullptr, Flags flags = None); @@ -39,10 +39,11 @@ protected: #ifdef USEWINSDK void showEvent(QShowEvent *) override; bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; - void paintEvent(QPaintEvent *) override; void scaleChangedEvent(float) override; #endif + void paintEvent(QPaintEvent *) override; + void changeEvent(QEvent *) override; void leaveEvent(QEvent *) override; void resizeEvent(QResizeEvent *) override; diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 9c0482ca6..57be91e71 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -12,6 +12,7 @@ #include "ui_accountpopupform.h" #include "util/benchmark.hpp" #include "util/distancebetweenpoints.hpp" +#include "widgets/accountpopup2.hpp" #include "widgets/split.hpp" #include "widgets/tooltipwidget.hpp" @@ -1104,10 +1105,16 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link switch (link.type) { case messages::Link::UserInfo: { auto user = link.value; - this->userPopupWidget.setName(user); - this->userPopupWidget.moveTo(this, event->screenPos().toPoint()); - this->userPopupWidget.show(); - this->userPopupWidget.setFocus(); + auto *userPopup = new AccountPopup2; + userPopup->setChannel(this->channel); + userPopup->setName(user); + userPopup->setAttribute(Qt::WA_DeleteOnClose); + userPopup->show(); + + // this->userPopupWidget.setName(user); + // this->userPopupWidget.moveTo(this, event->screenPos().toPoint()); + // this->userPopupWidget.show(); + // this->userPopupWidget.setFocus(); qDebug() << "Clicked " << user << "s message"; break; diff --git a/src/widgets/helper/notebookbutton.cpp b/src/widgets/helper/notebookbutton.cpp index 5a3b651b8..05ebb273d 100644 --- a/src/widgets/helper/notebookbutton.cpp +++ b/src/widgets/helper/notebookbutton.cpp @@ -32,7 +32,7 @@ void NotebookButton::paintEvent(QPaintEvent *) QColor background; QColor foreground; - if (mouseDown || mouseOver) { + if (mouseDown_ || mouseOver_) { background = this->themeManager->tabs.regular.backgrounds.hover.color(); foreground = this->themeManager->tabs.regular.text; } else { @@ -47,7 +47,7 @@ void NotebookButton::paintEvent(QPaintEvent *) if (icon == IconPlus) { painter.setPen([&] { QColor tmp = foreground; - if (!this->mouseOver) { + if (!this->mouseOver_) { tmp.setAlpha(180); } return tmp; @@ -103,7 +103,7 @@ void NotebookButton::paintEvent(QPaintEvent *) void NotebookButton::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - mouseDown = false; + mouseDown_ = false; update(); @@ -129,7 +129,7 @@ void NotebookButton::dragEnterEvent(QDragEnterEvent *event) void NotebookButton::dragLeaveEvent(QDragLeaveEvent *) { - this->mouseDown = true; + this->mouseDown_ = true; this->update(); auto e = new QMouseEvent(QMouseEvent::MouseButtonRelease, diff --git a/src/widgets/helper/notebookbutton.hpp b/src/widgets/helper/notebookbutton.hpp index 3a53af514..ddd86c4f5 100644 --- a/src/widgets/helper/notebookbutton.hpp +++ b/src/widgets/helper/notebookbutton.hpp @@ -32,7 +32,7 @@ signals: void clicked(); private: - QPoint mousePos; + QPoint mousePos_; }; } // namespace widgets diff --git a/src/widgets/helper/rippleeffectbutton.cpp b/src/widgets/helper/rippleeffectbutton.cpp index 78f80a4c1..232a01d33 100644 --- a/src/widgets/helper/rippleeffectbutton.cpp +++ b/src/widgets/helper/rippleeffectbutton.cpp @@ -10,28 +10,37 @@ namespace widgets { RippleEffectButton::RippleEffectButton(BaseWidget *parent) : BaseWidget(parent) - , pixmap(nullptr) { - connect(&effectTimer, &QTimer::timeout, this, &RippleEffectButton::onMouseEffectTimeout); + connect(&effectTimer_, &QTimer::timeout, this, &RippleEffectButton::onMouseEffectTimeout); - this->effectTimer.setInterval(20); - this->effectTimer.start(); + this->effectTimer_.setInterval(20); + this->effectTimer_.start(); } void RippleEffectButton::setMouseEffectColor(boost::optional color) { - this->mouseEffectColor = color; + this->mouseEffectColor_ = color; } -void RippleEffectButton::setPixmap(const QPixmap *_pixmap) +void RippleEffectButton::setPixmap(const QPixmap &_pixmap) { - this->pixmap = const_cast(_pixmap); + this->pixmap_ = _pixmap; this->update(); } -const QPixmap *RippleEffectButton::getPixmap() const +const QPixmap &RippleEffectButton::getPixmap() const { - return this->pixmap; + return this->pixmap_; +} + +void RippleEffectButton::setBorderColor(const QColor &color) +{ + this->borderColor_ = color; +} + +const QColor &RippleEffectButton::getBorderColor() const +{ + return this->borderColor_; } void RippleEffectButton::paintEvent(QPaintEvent *) @@ -42,16 +51,22 @@ void RippleEffectButton::paintEvent(QPaintEvent *) this->fancyPaint(painter); - if (this->pixmap != nullptr) { + if (!this->pixmap_.isNull()) { QRect rect = this->rect(); - int xD = 6 * this->getScale(); + int s = int(6 * this->getScale()); - rect.moveLeft(xD); - rect.setRight(rect.right() - xD - xD); - rect.moveTop(xD); - rect.setBottom(rect.bottom() - xD - xD); + rect.moveLeft(s); + rect.setRight(rect.right() - s - s); + rect.moveTop(s); + rect.setBottom(rect.bottom() - s - s); - painter.drawPixmap(rect, *this->pixmap); + painter.drawPixmap(rect, this->pixmap_); + } + + if (this->borderColor_.isValid()) { + painter.setRenderHint(QPainter::Antialiasing, false); + painter.setPen(this->borderColor_); + painter.drawRect(0, 0, this->width() - 1, this->height() - 1); } } @@ -61,33 +76,33 @@ void RippleEffectButton::fancyPaint(QPainter &painter) painter.setRenderHint(QPainter::Antialiasing); QColor c; - if (this->mouseEffectColor) { - c = this->mouseEffectColor.get(); + if (this->mouseEffectColor_) { + c = this->mouseEffectColor_.get(); } else { c = this->themeManager->isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255); } - if (this->hoverMultiplier > 0) { - QRadialGradient gradient(mousePos.x(), mousePos.y(), 50, mousePos.x(), mousePos.y()); + if (this->hoverMultiplier_ > 0) { + QRadialGradient gradient(mousePos_.x(), mousePos_.y(), 50, mousePos_.x(), mousePos_.y()); - gradient.setColorAt( - 0, QColor(c.red(), c.green(), c.blue(), (int)(24 * this->hoverMultiplier))); - gradient.setColorAt( - 1, QColor(c.red(), c.green(), c.blue(), (int)(12 * this->hoverMultiplier))); + gradient.setColorAt(0, + QColor(c.red(), c.green(), c.blue(), int(24 * this->hoverMultiplier_))); + gradient.setColorAt(1, + QColor(c.red(), c.green(), c.blue(), int(12 * this->hoverMultiplier_))); painter.fillRect(this->rect(), gradient); } - for (auto effect : this->clickEffects) { + for (auto effect : this->clickEffects_) { QRadialGradient gradient(effect.position.x(), effect.position.y(), - effect.progress * (float)width() * 2, effect.position.x(), + effect.progress * float(width()) * 2, effect.position.x(), effect.position.y()); - gradient.setColorAt( - 0, QColor(c.red(), c.green(), c.blue(), (int)((1 - effect.progress) * 95))); - gradient.setColorAt( - 0.9999, QColor(c.red(), c.green(), c.blue(), (int)((1 - effect.progress) * 95))); - gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), (int)(0))); + gradient.setColorAt(0, + QColor(c.red(), c.green(), c.blue(), int((1 - effect.progress) * 95))); + gradient.setColorAt(0.9999, + QColor(c.red(), c.green(), c.blue(), int((1 - effect.progress) * 95))); + gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), int(0))); painter.fillRect(this->rect(), gradient); } @@ -95,12 +110,12 @@ void RippleEffectButton::fancyPaint(QPainter &painter) void RippleEffectButton::enterEvent(QEvent *) { - this->mouseOver = true; + this->mouseOver_ = true; } void RippleEffectButton::leaveEvent(QEvent *) { - this->mouseOver = false; + this->mouseOver_ = false; } void RippleEffectButton::mousePressEvent(QMouseEvent *event) @@ -109,9 +124,9 @@ void RippleEffectButton::mousePressEvent(QMouseEvent *event) return; } - this->clickEffects.push_back(ClickEffect(event->pos())); + this->clickEffects_.push_back(ClickEffect(event->pos())); - this->mouseDown = true; + this->mouseDown_ = true; } void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event) @@ -120,7 +135,7 @@ void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event) return; } - this->mouseDown = false; + this->mouseDown_ = false; if (this->rect().contains(event->pos())) { emit clicked(); @@ -129,38 +144,38 @@ void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event) void RippleEffectButton::mouseMoveEvent(QMouseEvent *event) { - this->mousePos = event->pos(); + this->mousePos_ = event->pos(); } void RippleEffectButton::onMouseEffectTimeout() { bool performUpdate = false; - if (selected) { - if (this->hoverMultiplier != 0) { - this->hoverMultiplier = std::max(0.0, this->hoverMultiplier - 0.1); + if (selected_) { + if (this->hoverMultiplier_ != 0) { + this->hoverMultiplier_ = std::max(0.0, this->hoverMultiplier_ - 0.1); performUpdate = true; } - } else if (mouseOver) { - if (this->hoverMultiplier != 1) { - this->hoverMultiplier = std::min(1.0, this->hoverMultiplier + 0.5); + } else if (mouseOver_) { + if (this->hoverMultiplier_ != 1) { + this->hoverMultiplier_ = std::min(1.0, this->hoverMultiplier_ + 0.5); performUpdate = true; } } else { - if (this->hoverMultiplier != 0) { - this->hoverMultiplier = std::max(0.0, this->hoverMultiplier - 0.3); + if (this->hoverMultiplier_ != 0) { + this->hoverMultiplier_ = std::max(0.0, this->hoverMultiplier_ - 0.3); performUpdate = true; } } - if (this->clickEffects.size() != 0) { + if (this->clickEffects_.size() != 0) { performUpdate = true; - for (auto it = this->clickEffects.begin(); it != this->clickEffects.end();) { - (*it).progress += mouseDown ? 0.02 : 0.07; + for (auto it = this->clickEffects_.begin(); it != this->clickEffects_.end();) { + (*it).progress += mouseDown_ ? 0.02 : 0.07; if ((*it).progress >= 1.0) { - it = this->clickEffects.erase(it); + it = this->clickEffects_.erase(it); } else { it++; } diff --git a/src/widgets/helper/rippleeffectbutton.hpp b/src/widgets/helper/rippleeffectbutton.hpp index 5806ff4a4..67ac71093 100644 --- a/src/widgets/helper/rippleeffectbutton.hpp +++ b/src/widgets/helper/rippleeffectbutton.hpp @@ -31,16 +31,19 @@ public: RippleEffectButton(BaseWidget *parent); void setMouseEffectColor(boost::optional color); - void setPixmap(const QPixmap *pixmap); - const QPixmap *getPixmap() const; + void setPixmap(const QPixmap &pixmap_); + const QPixmap &getPixmap() const; + + void setBorderColor(const QColor &color); + const QColor &getBorderColor() const; signals: void clicked(); protected: - bool selected = false; - bool mouseOver = false; - bool mouseDown = false; + bool selected_ = false; + bool mouseOver_ = false; + bool mouseDown_ = false; virtual void paintEvent(QPaintEvent *) override; virtual void enterEvent(QEvent *) override; @@ -52,12 +55,13 @@ protected: void fancyPaint(QPainter &painter); private: - QPixmap *pixmap; - QPoint mousePos; - double hoverMultiplier = 0.0; - QTimer effectTimer; - std::vector clickEffects; - boost::optional mouseEffectColor = boost::none; + QColor borderColor_; + QPixmap pixmap_; + QPoint mousePos_; + double hoverMultiplier_ = 0.0; + QTimer effectTimer_; + std::vector clickEffects_; + boost::optional mouseEffectColor_ = boost::none; void onMouseEffectTimeout(); }; diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp index 389c7af1f..7c178cf24 100644 --- a/src/widgets/helper/splitheader.cpp +++ b/src/widgets/helper/splitheader.cpp @@ -38,7 +38,7 @@ SplitHeader::SplitHeader(Split *_split) // dropdown label auto dropdown = layout.emplace(this).assign(&this->dropdownButton); dropdown->setMouseTracking(true); - dropdown->setPixmap(app->resources->splitHeaderContext->getPixmap()); + dropdown->setPixmap(*app->resources->splitHeaderContext->getPixmap()); this->addDropdownItems(dropdown.getElement()); QObject::connect(dropdown.getElement(), &RippleEffectButton::clicked, this, [this] { QTimer::singleShot(80, [&] { @@ -219,8 +219,8 @@ void SplitHeader::updateModerationModeIcon() auto app = getApp(); this->moderationButton->setPixmap(this->split->getModerationMode() - ? app->resources->moderationmode_enabled->getPixmap() - : app->resources->moderationmode_disabled->getPixmap()); + ? *app->resources->moderationmode_enabled->getPixmap() + : *app->resources->moderationmode_disabled->getPixmap()); bool modButtonVisible = false; ChannelPtr channel = this->split->getChannel(); diff --git a/src/widgets/helper/splitinput.cpp b/src/widgets/helper/splitinput.cpp index 803c36086..c8ac8c89b 100644 --- a/src/widgets/helper/splitinput.cpp +++ b/src/widgets/helper/splitinput.cpp @@ -276,7 +276,8 @@ void SplitInput::editTextChanged() // set textLengthLabel value QString text = this->ui.textEdit->toPlainText(); - if (text.startsWith("/r ") && this->split->getChannel()->isTwitchChannel()) // + if (text.startsWith("/r ", Qt::CaseInsensitive) && + this->split->getChannel()->isTwitchChannel()) // { QString lastUser = app->twitch.server->lastUserThatWhisperedMe.get(); if (!lastUser.isEmpty()) { diff --git a/src/widgets/notificationpopup.cpp b/src/widgets/notificationpopup.cpp index aa21c5ec5..31c1deb63 100644 --- a/src/widgets/notificationpopup.cpp +++ b/src/widgets/notificationpopup.cpp @@ -10,7 +10,7 @@ namespace chatterino { namespace widgets { NotificationPopup::NotificationPopup() - : BaseWindow((QWidget *)nullptr, BaseWindow::FrameLess) + : BaseWindow((QWidget *)nullptr, BaseWindow::Frameless) , channel(std::make_shared("notifications", Channel::None)) {