mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added basic new user popup
This commit is contained in:
parent
f542a5b999
commit
86e4a669ad
|
@ -216,7 +216,8 @@ SOURCES += \
|
||||||
src/controllers/taggedusers/taggeduser.cpp \
|
src/controllers/taggedusers/taggeduser.cpp \
|
||||||
src/controllers/taggedusers/taggedusersmodel.cpp \
|
src/controllers/taggedusers/taggedusersmodel.cpp \
|
||||||
src/util/emotemap.cpp \
|
src/util/emotemap.cpp \
|
||||||
src/providers/irc/ircconnection2.cpp
|
src/providers/irc/ircconnection2.cpp \
|
||||||
|
src/widgets/accountpopup2.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/precompiled_header.hpp \
|
src/precompiled_header.hpp \
|
||||||
|
@ -374,7 +375,8 @@ HEADERS += \
|
||||||
src/controllers/taggedusers/taggedusersmodel.hpp \
|
src/controllers/taggedusers/taggedusersmodel.hpp \
|
||||||
src/util/qstringhash.hpp \
|
src/util/qstringhash.hpp \
|
||||||
src/util/mutexvalue.hpp \
|
src/util/mutexvalue.hpp \
|
||||||
src/providers/irc/ircconnection2.hpp
|
src/providers/irc/ircconnection2.hpp \
|
||||||
|
src/widgets/accountpopup2.hpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources/resources.qrc
|
resources/resources.qrc
|
||||||
|
|
BIN
resources/images/buttons/ban.png
Normal file
BIN
resources/images/buttons/ban.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
resources/images/buttons/mod.png
Normal file
BIN
resources/images/buttons/mod.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 376 B |
BIN
resources/images/buttons/unban.png
Normal file
BIN
resources/images/buttons/unban.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
resources/images/buttons/unmod.png
Normal file
BIN
resources/images/buttons/unmod.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 349 B |
|
@ -61,6 +61,10 @@
|
||||||
<file>licenses/rapidjson.txt</file>
|
<file>licenses/rapidjson.txt</file>
|
||||||
<file>licenses/websocketpp.txt</file>
|
<file>licenses/websocketpp.txt</file>
|
||||||
<file>emoji.json</file>
|
<file>emoji.json</file>
|
||||||
|
<file>images/buttons/ban.png</file>
|
||||||
|
<file>images/buttons/mod.png</file>
|
||||||
|
<file>images/buttons/unban.png</file>
|
||||||
|
<file>images/buttons/unmod.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/qt/etc">
|
<qresource prefix="/qt/etc">
|
||||||
<file>qt.conf</file>
|
<file>qt.conf</file>
|
||||||
|
|
|
@ -294,6 +294,12 @@ ResourceManager::ResourceManager()
|
||||||
this->split.up = QIcon(":/images/split/splitup.png");
|
this->split.up = QIcon(":/images/split/splitup.png");
|
||||||
this->split.down = QIcon(":/images/split/splitdown.png");
|
this->split.down = QIcon(":/images/split/splitdown.png");
|
||||||
this->split.move = QIcon(":/images/split/splitmove.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";
|
qDebug() << "init ResourceManager";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,13 @@ public:
|
||||||
QIcon move;
|
QIcon move;
|
||||||
} split;
|
} split;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
QPixmap ban;
|
||||||
|
QPixmap unban;
|
||||||
|
QPixmap mod;
|
||||||
|
QPixmap unmod;
|
||||||
|
} buttons;
|
||||||
|
|
||||||
messages::Image *badgeStaff;
|
messages::Image *badgeStaff;
|
||||||
messages::Image *badgeAdmin;
|
messages::Image *badgeAdmin;
|
||||||
messages::Image *badgeGlobalModerator;
|
messages::Image *badgeGlobalModerator;
|
||||||
|
|
|
@ -28,6 +28,9 @@ public:
|
||||||
this->vector = vec;
|
this->vector = vec;
|
||||||
|
|
||||||
auto insert = [this](const SignalVectorItemArgs<TVectorItem> &args) {
|
auto insert = [this](const SignalVectorItemArgs<TVectorItem> &args) {
|
||||||
|
if (args.caller == this) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// get row index
|
// get row index
|
||||||
int index = this->getModelIndexFromVectorIndex(args.index);
|
int index = this->getModelIndexFromVectorIndex(args.index);
|
||||||
assert(index >= 0 && index <= this->rows.size());
|
assert(index >= 0 && index <= this->rows.size());
|
||||||
|
@ -54,6 +57,10 @@ public:
|
||||||
this->managedConnect(vec->itemInserted, insert);
|
this->managedConnect(vec->itemInserted, insert);
|
||||||
|
|
||||||
this->managedConnect(vec->itemRemoved, [this](auto args) {
|
this->managedConnect(vec->itemRemoved, [this](auto args) {
|
||||||
|
if (args.caller == this) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int row = this->getModelIndexFromVectorIndex(args.index);
|
int row = this->getModelIndexFromVectorIndex(args.index);
|
||||||
assert(row >= 0 && row <= this->rows.size());
|
assert(row >= 0 && row <= this->rows.size());
|
||||||
|
|
||||||
|
|
172
src/widgets/accountpopup2.cpp
Normal file
172
src/widgets/accountpopup2.cpp
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
#include "accountpopup2.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
|
#include "singletons/resourcemanager.hpp"
|
||||||
|
#include "util/layoutcreator.hpp"
|
||||||
|
#include "widgets/helper/rippleeffectlabel.hpp"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace widgets {
|
||||||
|
|
||||||
|
AccountPopup2::AccountPopup2()
|
||||||
|
: BaseWindow(nullptr, BaseWindow::Frameless)
|
||||||
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
|
auto layout = util::LayoutCreator<AccountPopup2>(this).setLayoutType<QVBoxLayout>();
|
||||||
|
|
||||||
|
// first line
|
||||||
|
auto head = layout.emplace<QHBoxLayout>();
|
||||||
|
{
|
||||||
|
// avatar
|
||||||
|
auto avatar = head.emplace<QLabel>("Avatar").assign(&this->ui.label);
|
||||||
|
avatar->setFixedSize(100, 100);
|
||||||
|
|
||||||
|
// items on the right
|
||||||
|
auto vbox = head.emplace<QVBoxLayout>();
|
||||||
|
{
|
||||||
|
vbox.emplace<QLabel>("Name");
|
||||||
|
vbox.emplace<QLabel>("Views");
|
||||||
|
vbox.emplace<QLabel>("Followers");
|
||||||
|
vbox.emplace<QLabel>("Create date");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// second line
|
||||||
|
auto user = layout.emplace<QHBoxLayout>();
|
||||||
|
{
|
||||||
|
user->addStretch(1);
|
||||||
|
|
||||||
|
auto ignore = user.emplace<RippleEffectLabel>();
|
||||||
|
ignore->getLabel().setText("Ignore");
|
||||||
|
ignore->setScaleIndependantHeight(24);
|
||||||
|
|
||||||
|
auto ignoreHighlights = user.emplace<RippleEffectLabel>();
|
||||||
|
ignoreHighlights->getLabel().setText("Ignore highlights");
|
||||||
|
ignoreHighlights->setScaleIndependantHeight(24);
|
||||||
|
|
||||||
|
user->addStretch(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// third line
|
||||||
|
auto moderation = layout.emplace<QHBoxLayout>();
|
||||||
|
moderation->setSpacing(0);
|
||||||
|
{
|
||||||
|
auto unban = moderation.emplace<RippleEffectLabel>();
|
||||||
|
unban->setPixmap(app->resources->buttons.unban);
|
||||||
|
unban->setScaleIndependantSize(32, 32);
|
||||||
|
unban->setBorderColor(QColor(255, 255, 255, 127));
|
||||||
|
|
||||||
|
moderation.emplace<TimeoutWidget>();
|
||||||
|
|
||||||
|
auto ban = moderation.emplace<RippleEffectLabel>();
|
||||||
|
ban->setPixmap(app->resources->buttons.ban);
|
||||||
|
ban->setScaleIndependantSize(32, 32);
|
||||||
|
ban->setBorderColor(QColor(255, 255, 255, 127));
|
||||||
|
|
||||||
|
// auto mod = moderation.emplace<RippleEffectButton>(this);
|
||||||
|
// mod->setPixmap(app->resources->buttons.mod);
|
||||||
|
// mod->setScaleIndependantSize(30, 30);
|
||||||
|
// auto unmod = moderation.emplace<RippleEffectLabel>();
|
||||||
|
// 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<TimeoutWidget>(this).setLayoutType<QHBoxLayout>();
|
||||||
|
|
||||||
|
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<RippleEffectLabel>();
|
||||||
|
a->getLabel().setText("1s");
|
||||||
|
a->setScaleIndependantSize(buttonWidth, buttonHeight);
|
||||||
|
a->setBorderColor(color1);
|
||||||
|
auto a1 = layout.emplace<RippleEffectLabel>(nullptr);
|
||||||
|
// a1->getLabel().setText("1m");
|
||||||
|
a1->setScaleIndependantSize(buttonWidth2, buttonHeight);
|
||||||
|
a1->setBorderColor(color2);
|
||||||
|
auto a2 = layout.emplace<RippleEffectLabel>(nullptr);
|
||||||
|
// a2->getLabel().setText("5m");
|
||||||
|
a2->setScaleIndependantSize(buttonWidth2, buttonHeight);
|
||||||
|
a2->setBorderColor(color2);
|
||||||
|
|
||||||
|
auto b = layout.emplace<RippleEffectLabel>();
|
||||||
|
b->getLabel().setText("10m");
|
||||||
|
b->setScaleIndependantSize(buttonWidth, buttonHeight);
|
||||||
|
b->setBorderColor(color1);
|
||||||
|
auto b1 = layout.emplace<RippleEffectLabel>(nullptr);
|
||||||
|
b1->setScaleIndependantSize(buttonWidth2, buttonHeight);
|
||||||
|
b1->setBorderColor(color2);
|
||||||
|
// b1->getLabel().setText("1h");
|
||||||
|
auto b2 = layout.emplace<RippleEffectLabel>(nullptr);
|
||||||
|
b2->setScaleIndependantSize(buttonWidth2, buttonHeight);
|
||||||
|
b2->setBorderColor(color2);
|
||||||
|
// b2->getLabel().setText("4h");
|
||||||
|
|
||||||
|
auto c = layout.emplace<RippleEffectLabel>();
|
||||||
|
c->getLabel().setText("1d");
|
||||||
|
c->setScaleIndependantSize(buttonWidth, buttonHeight);
|
||||||
|
c->setBorderColor(color1);
|
||||||
|
auto c1 = layout.emplace<RippleEffectLabel>(nullptr);
|
||||||
|
// c1->getLabel().setText("3d");
|
||||||
|
c1->setScaleIndependantSize(buttonWidth2, buttonHeight);
|
||||||
|
c1->setBorderColor(color2);
|
||||||
|
auto c2 = layout.emplace<RippleEffectLabel>(nullptr);
|
||||||
|
// c2->getLabel().setText("1w");
|
||||||
|
c2->setScaleIndependantSize(buttonWidth2, buttonHeight);
|
||||||
|
c2->setBorderColor(color2);
|
||||||
|
|
||||||
|
auto d = layout.emplace<RippleEffectLabel>();
|
||||||
|
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
|
45
src/widgets/accountpopup2.hpp
Normal file
45
src/widgets/accountpopup2.hpp
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "channel.hpp"
|
||||||
|
#include "widgets/basewindow.hpp"
|
||||||
|
|
||||||
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
|
||||||
|
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
|
|
@ -36,7 +36,7 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
|
||||||
: BaseWidget(parent,
|
: BaseWidget(parent,
|
||||||
Qt::Window | ((_flags & TopMost) ? Qt::WindowStaysOnTopHint : Qt::WindowFlags(0)))
|
Qt::Window | ((_flags & TopMost) ? Qt::WindowStaysOnTopHint : Qt::WindowFlags(0)))
|
||||||
, enableCustomFrame(_flags & EnableCustomFrame)
|
, enableCustomFrame(_flags & EnableCustomFrame)
|
||||||
, frameless(_flags & FrameLess)
|
, frameless(_flags & Frameless)
|
||||||
, flags(_flags)
|
, flags(_flags)
|
||||||
{
|
{
|
||||||
if (this->frameless) {
|
if (this->frameless) {
|
||||||
|
@ -447,8 +447,22 @@ void BaseWindow::showEvent(QShowEvent *event)
|
||||||
BaseWidget::showEvent(event);
|
BaseWidget::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseWindow::scaleChangedEvent(float)
|
||||||
|
{
|
||||||
|
this->calcButtonsSizes();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void BaseWindow::paintEvent(QPaintEvent *)
|
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()) {
|
if (this->hasCustomWindowFrame()) {
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
|
@ -457,13 +471,8 @@ void BaseWindow::paintEvent(QPaintEvent *)
|
||||||
painter.fillRect(QRect(0, 1, this->width() - 0, this->height() - 0),
|
painter.fillRect(QRect(0, 1, this->width() - 0, this->height() - 0),
|
||||||
this->themeManager->window.background);
|
this->themeManager->window.background);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void BaseWindow::scaleChangedEvent(float)
|
|
||||||
{
|
|
||||||
this->calcButtonsSizes();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void BaseWindow::calcButtonsSizes()
|
void BaseWindow::calcButtonsSizes()
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@ class BaseWindow : public BaseWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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);
|
explicit BaseWindow(QWidget *parent = nullptr, Flags flags = None);
|
||||||
|
|
||||||
|
@ -39,10 +39,11 @@ protected:
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
void showEvent(QShowEvent *) override;
|
void showEvent(QShowEvent *) override;
|
||||||
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
||||||
void paintEvent(QPaintEvent *) override;
|
|
||||||
void scaleChangedEvent(float) override;
|
void scaleChangedEvent(float) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
|
||||||
void changeEvent(QEvent *) override;
|
void changeEvent(QEvent *) override;
|
||||||
void leaveEvent(QEvent *) override;
|
void leaveEvent(QEvent *) override;
|
||||||
void resizeEvent(QResizeEvent *) override;
|
void resizeEvent(QResizeEvent *) override;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "ui_accountpopupform.h"
|
#include "ui_accountpopupform.h"
|
||||||
#include "util/benchmark.hpp"
|
#include "util/benchmark.hpp"
|
||||||
#include "util/distancebetweenpoints.hpp"
|
#include "util/distancebetweenpoints.hpp"
|
||||||
|
#include "widgets/accountpopup2.hpp"
|
||||||
#include "widgets/split.hpp"
|
#include "widgets/split.hpp"
|
||||||
#include "widgets/tooltipwidget.hpp"
|
#include "widgets/tooltipwidget.hpp"
|
||||||
|
|
||||||
|
@ -1104,10 +1105,16 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link
|
||||||
switch (link.type) {
|
switch (link.type) {
|
||||||
case messages::Link::UserInfo: {
|
case messages::Link::UserInfo: {
|
||||||
auto user = link.value;
|
auto user = link.value;
|
||||||
this->userPopupWidget.setName(user);
|
auto *userPopup = new AccountPopup2;
|
||||||
this->userPopupWidget.moveTo(this, event->screenPos().toPoint());
|
userPopup->setChannel(this->channel);
|
||||||
this->userPopupWidget.show();
|
userPopup->setName(user);
|
||||||
this->userPopupWidget.setFocus();
|
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";
|
qDebug() << "Clicked " << user << "s message";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -32,7 +32,7 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
||||||
QColor background;
|
QColor background;
|
||||||
QColor foreground;
|
QColor foreground;
|
||||||
|
|
||||||
if (mouseDown || mouseOver) {
|
if (mouseDown_ || mouseOver_) {
|
||||||
background = this->themeManager->tabs.regular.backgrounds.hover.color();
|
background = this->themeManager->tabs.regular.backgrounds.hover.color();
|
||||||
foreground = this->themeManager->tabs.regular.text;
|
foreground = this->themeManager->tabs.regular.text;
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,7 +47,7 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
||||||
if (icon == IconPlus) {
|
if (icon == IconPlus) {
|
||||||
painter.setPen([&] {
|
painter.setPen([&] {
|
||||||
QColor tmp = foreground;
|
QColor tmp = foreground;
|
||||||
if (!this->mouseOver) {
|
if (!this->mouseOver_) {
|
||||||
tmp.setAlpha(180);
|
tmp.setAlpha(180);
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
|
@ -103,7 +103,7 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
||||||
void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
mouseDown = false;
|
mouseDown_ = false;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
||||||
|
|
||||||
void NotebookButton::dragLeaveEvent(QDragLeaveEvent *)
|
void NotebookButton::dragLeaveEvent(QDragLeaveEvent *)
|
||||||
{
|
{
|
||||||
this->mouseDown = true;
|
this->mouseDown_ = true;
|
||||||
this->update();
|
this->update();
|
||||||
|
|
||||||
auto e = new QMouseEvent(QMouseEvent::MouseButtonRelease,
|
auto e = new QMouseEvent(QMouseEvent::MouseButtonRelease,
|
||||||
|
|
|
@ -32,7 +32,7 @@ signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPoint mousePos;
|
QPoint mousePos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace widgets
|
} // namespace widgets
|
||||||
|
|
|
@ -10,28 +10,37 @@ namespace widgets {
|
||||||
|
|
||||||
RippleEffectButton::RippleEffectButton(BaseWidget *parent)
|
RippleEffectButton::RippleEffectButton(BaseWidget *parent)
|
||||||
: 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_.setInterval(20);
|
||||||
this->effectTimer.start();
|
this->effectTimer_.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RippleEffectButton::setMouseEffectColor(boost::optional<QColor> color)
|
void RippleEffectButton::setMouseEffectColor(boost::optional<QColor> color)
|
||||||
{
|
{
|
||||||
this->mouseEffectColor = color;
|
this->mouseEffectColor_ = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RippleEffectButton::setPixmap(const QPixmap *_pixmap)
|
void RippleEffectButton::setPixmap(const QPixmap &_pixmap)
|
||||||
{
|
{
|
||||||
this->pixmap = const_cast<QPixmap *>(_pixmap);
|
this->pixmap_ = _pixmap;
|
||||||
this->update();
|
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 *)
|
void RippleEffectButton::paintEvent(QPaintEvent *)
|
||||||
|
@ -42,16 +51,22 @@ void RippleEffectButton::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
this->fancyPaint(painter);
|
this->fancyPaint(painter);
|
||||||
|
|
||||||
if (this->pixmap != nullptr) {
|
if (!this->pixmap_.isNull()) {
|
||||||
QRect rect = this->rect();
|
QRect rect = this->rect();
|
||||||
int xD = 6 * this->getScale();
|
int s = int(6 * this->getScale());
|
||||||
|
|
||||||
rect.moveLeft(xD);
|
rect.moveLeft(s);
|
||||||
rect.setRight(rect.right() - xD - xD);
|
rect.setRight(rect.right() - s - s);
|
||||||
rect.moveTop(xD);
|
rect.moveTop(s);
|
||||||
rect.setBottom(rect.bottom() - xD - xD);
|
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);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
QColor c;
|
QColor c;
|
||||||
|
|
||||||
if (this->mouseEffectColor) {
|
if (this->mouseEffectColor_) {
|
||||||
c = this->mouseEffectColor.get();
|
c = this->mouseEffectColor_.get();
|
||||||
} else {
|
} else {
|
||||||
c = this->themeManager->isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255);
|
c = this->themeManager->isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->hoverMultiplier > 0) {
|
if (this->hoverMultiplier_ > 0) {
|
||||||
QRadialGradient gradient(mousePos.x(), mousePos.y(), 50, mousePos.x(), mousePos.y());
|
QRadialGradient gradient(mousePos_.x(), mousePos_.y(), 50, mousePos_.x(), mousePos_.y());
|
||||||
|
|
||||||
gradient.setColorAt(
|
gradient.setColorAt(0,
|
||||||
0, QColor(c.red(), c.green(), c.blue(), (int)(24 * this->hoverMultiplier)));
|
QColor(c.red(), c.green(), c.blue(), int(24 * this->hoverMultiplier_)));
|
||||||
gradient.setColorAt(
|
gradient.setColorAt(1,
|
||||||
1, QColor(c.red(), c.green(), c.blue(), (int)(12 * this->hoverMultiplier)));
|
QColor(c.red(), c.green(), c.blue(), int(12 * this->hoverMultiplier_)));
|
||||||
|
|
||||||
painter.fillRect(this->rect(), gradient);
|
painter.fillRect(this->rect(), gradient);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto effect : this->clickEffects) {
|
for (auto effect : this->clickEffects_) {
|
||||||
QRadialGradient gradient(effect.position.x(), effect.position.y(),
|
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());
|
effect.position.y());
|
||||||
|
|
||||||
gradient.setColorAt(
|
gradient.setColorAt(0,
|
||||||
0, QColor(c.red(), c.green(), c.blue(), (int)((1 - effect.progress) * 95)));
|
QColor(c.red(), c.green(), c.blue(), int((1 - effect.progress) * 95)));
|
||||||
gradient.setColorAt(
|
gradient.setColorAt(0.9999,
|
||||||
0.9999, QColor(c.red(), c.green(), c.blue(), (int)((1 - effect.progress) * 95)));
|
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(1, QColor(c.red(), c.green(), c.blue(), int(0)));
|
||||||
|
|
||||||
painter.fillRect(this->rect(), gradient);
|
painter.fillRect(this->rect(), gradient);
|
||||||
}
|
}
|
||||||
|
@ -95,12 +110,12 @@ void RippleEffectButton::fancyPaint(QPainter &painter)
|
||||||
|
|
||||||
void RippleEffectButton::enterEvent(QEvent *)
|
void RippleEffectButton::enterEvent(QEvent *)
|
||||||
{
|
{
|
||||||
this->mouseOver = true;
|
this->mouseOver_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RippleEffectButton::leaveEvent(QEvent *)
|
void RippleEffectButton::leaveEvent(QEvent *)
|
||||||
{
|
{
|
||||||
this->mouseOver = false;
|
this->mouseOver_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RippleEffectButton::mousePressEvent(QMouseEvent *event)
|
void RippleEffectButton::mousePressEvent(QMouseEvent *event)
|
||||||
|
@ -109,9 +124,9 @@ void RippleEffectButton::mousePressEvent(QMouseEvent *event)
|
||||||
return;
|
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)
|
void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
@ -120,7 +135,7 @@ void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->mouseDown = false;
|
this->mouseDown_ = false;
|
||||||
|
|
||||||
if (this->rect().contains(event->pos())) {
|
if (this->rect().contains(event->pos())) {
|
||||||
emit clicked();
|
emit clicked();
|
||||||
|
@ -129,38 +144,38 @@ void RippleEffectButton::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void RippleEffectButton::mouseMoveEvent(QMouseEvent *event)
|
void RippleEffectButton::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
this->mousePos = event->pos();
|
this->mousePos_ = event->pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RippleEffectButton::onMouseEffectTimeout()
|
void RippleEffectButton::onMouseEffectTimeout()
|
||||||
{
|
{
|
||||||
bool performUpdate = false;
|
bool performUpdate = false;
|
||||||
|
|
||||||
if (selected) {
|
if (selected_) {
|
||||||
if (this->hoverMultiplier != 0) {
|
if (this->hoverMultiplier_ != 0) {
|
||||||
this->hoverMultiplier = std::max(0.0, this->hoverMultiplier - 0.1);
|
this->hoverMultiplier_ = std::max(0.0, this->hoverMultiplier_ - 0.1);
|
||||||
performUpdate = true;
|
performUpdate = true;
|
||||||
}
|
}
|
||||||
} else if (mouseOver) {
|
} else if (mouseOver_) {
|
||||||
if (this->hoverMultiplier != 1) {
|
if (this->hoverMultiplier_ != 1) {
|
||||||
this->hoverMultiplier = std::min(1.0, this->hoverMultiplier + 0.5);
|
this->hoverMultiplier_ = std::min(1.0, this->hoverMultiplier_ + 0.5);
|
||||||
performUpdate = true;
|
performUpdate = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this->hoverMultiplier != 0) {
|
if (this->hoverMultiplier_ != 0) {
|
||||||
this->hoverMultiplier = std::max(0.0, this->hoverMultiplier - 0.3);
|
this->hoverMultiplier_ = std::max(0.0, this->hoverMultiplier_ - 0.3);
|
||||||
performUpdate = true;
|
performUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->clickEffects.size() != 0) {
|
if (this->clickEffects_.size() != 0) {
|
||||||
performUpdate = true;
|
performUpdate = true;
|
||||||
|
|
||||||
for (auto it = this->clickEffects.begin(); it != this->clickEffects.end();) {
|
for (auto it = this->clickEffects_.begin(); it != this->clickEffects_.end();) {
|
||||||
(*it).progress += mouseDown ? 0.02 : 0.07;
|
(*it).progress += mouseDown_ ? 0.02 : 0.07;
|
||||||
|
|
||||||
if ((*it).progress >= 1.0) {
|
if ((*it).progress >= 1.0) {
|
||||||
it = this->clickEffects.erase(it);
|
it = this->clickEffects_.erase(it);
|
||||||
} else {
|
} else {
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,16 +31,19 @@ public:
|
||||||
RippleEffectButton(BaseWidget *parent);
|
RippleEffectButton(BaseWidget *parent);
|
||||||
|
|
||||||
void setMouseEffectColor(boost::optional<QColor> color);
|
void setMouseEffectColor(boost::optional<QColor> color);
|
||||||
void setPixmap(const QPixmap *pixmap);
|
void setPixmap(const QPixmap &pixmap_);
|
||||||
const QPixmap *getPixmap() const;
|
const QPixmap &getPixmap() const;
|
||||||
|
|
||||||
|
void setBorderColor(const QColor &color);
|
||||||
|
const QColor &getBorderColor() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool selected = false;
|
bool selected_ = false;
|
||||||
bool mouseOver = false;
|
bool mouseOver_ = false;
|
||||||
bool mouseDown = false;
|
bool mouseDown_ = false;
|
||||||
|
|
||||||
virtual void paintEvent(QPaintEvent *) override;
|
virtual void paintEvent(QPaintEvent *) override;
|
||||||
virtual void enterEvent(QEvent *) override;
|
virtual void enterEvent(QEvent *) override;
|
||||||
|
@ -52,12 +55,13 @@ protected:
|
||||||
void fancyPaint(QPainter &painter);
|
void fancyPaint(QPainter &painter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap *pixmap;
|
QColor borderColor_;
|
||||||
QPoint mousePos;
|
QPixmap pixmap_;
|
||||||
double hoverMultiplier = 0.0;
|
QPoint mousePos_;
|
||||||
QTimer effectTimer;
|
double hoverMultiplier_ = 0.0;
|
||||||
std::vector<ClickEffect> clickEffects;
|
QTimer effectTimer_;
|
||||||
boost::optional<QColor> mouseEffectColor = boost::none;
|
std::vector<ClickEffect> clickEffects_;
|
||||||
|
boost::optional<QColor> mouseEffectColor_ = boost::none;
|
||||||
|
|
||||||
void onMouseEffectTimeout();
|
void onMouseEffectTimeout();
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,7 +38,7 @@ SplitHeader::SplitHeader(Split *_split)
|
||||||
// dropdown label
|
// dropdown label
|
||||||
auto dropdown = layout.emplace<RippleEffectButton>(this).assign(&this->dropdownButton);
|
auto dropdown = layout.emplace<RippleEffectButton>(this).assign(&this->dropdownButton);
|
||||||
dropdown->setMouseTracking(true);
|
dropdown->setMouseTracking(true);
|
||||||
dropdown->setPixmap(app->resources->splitHeaderContext->getPixmap());
|
dropdown->setPixmap(*app->resources->splitHeaderContext->getPixmap());
|
||||||
this->addDropdownItems(dropdown.getElement());
|
this->addDropdownItems(dropdown.getElement());
|
||||||
QObject::connect(dropdown.getElement(), &RippleEffectButton::clicked, this, [this] {
|
QObject::connect(dropdown.getElement(), &RippleEffectButton::clicked, this, [this] {
|
||||||
QTimer::singleShot(80, [&] {
|
QTimer::singleShot(80, [&] {
|
||||||
|
@ -219,8 +219,8 @@ void SplitHeader::updateModerationModeIcon()
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
this->moderationButton->setPixmap(this->split->getModerationMode()
|
this->moderationButton->setPixmap(this->split->getModerationMode()
|
||||||
? app->resources->moderationmode_enabled->getPixmap()
|
? *app->resources->moderationmode_enabled->getPixmap()
|
||||||
: app->resources->moderationmode_disabled->getPixmap());
|
: *app->resources->moderationmode_disabled->getPixmap());
|
||||||
|
|
||||||
bool modButtonVisible = false;
|
bool modButtonVisible = false;
|
||||||
ChannelPtr channel = this->split->getChannel();
|
ChannelPtr channel = this->split->getChannel();
|
||||||
|
|
|
@ -276,7 +276,8 @@ void SplitInput::editTextChanged()
|
||||||
// set textLengthLabel value
|
// set textLengthLabel value
|
||||||
QString text = this->ui.textEdit->toPlainText();
|
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();
|
QString lastUser = app->twitch.server->lastUserThatWhisperedMe.get();
|
||||||
if (!lastUser.isEmpty()) {
|
if (!lastUser.isEmpty()) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
NotificationPopup::NotificationPopup()
|
NotificationPopup::NotificationPopup()
|
||||||
: BaseWindow((QWidget *)nullptr, BaseWindow::FrameLess)
|
: BaseWindow((QWidget *)nullptr, BaseWindow::Frameless)
|
||||||
, channel(std::make_shared<Channel>("notifications", Channel::None))
|
, channel(std::make_shared<Channel>("notifications", Channel::None))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue