added basic new user popup

This commit is contained in:
fourtf
2018-06-06 10:46:23 +02:00
parent f542a5b999
commit 86e4a669ad
21 changed files with 365 additions and 85 deletions
+11 -4
View File
@@ -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;
+4 -4
View File
@@ -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,
+1 -1
View File
@@ -32,7 +32,7 @@ signals:
void clicked();
private:
QPoint mousePos;
QPoint mousePos_;
};
} // namespace widgets
+64 -49
View File
@@ -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<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();
}
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++;
}
+15 -11
View File
@@ -31,16 +31,19 @@ public:
RippleEffectButton(BaseWidget *parent);
void setMouseEffectColor(boost::optional<QColor> 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<ClickEffect> clickEffects;
boost::optional<QColor> mouseEffectColor = boost::none;
QColor borderColor_;
QPixmap pixmap_;
QPoint mousePos_;
double hoverMultiplier_ = 0.0;
QTimer effectTimer_;
std::vector<ClickEffect> clickEffects_;
boost::optional<QColor> mouseEffectColor_ = boost::none;
void onMouseEffectTimeout();
};
+3 -3
View File
@@ -38,7 +38,7 @@ SplitHeader::SplitHeader(Split *_split)
// dropdown label
auto dropdown = layout.emplace<RippleEffectButton>(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();
+2 -1
View File
@@ -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()) {