diff --git a/chatterino.pro b/chatterino.pro
index 13819c5e2..98817218c 100644
--- a/chatterino.pro
+++ b/chatterino.pro
@@ -55,7 +55,8 @@ SOURCES += main.cpp\
windows.cpp \
messages/messageref.cpp \
logging/loggingmanager.cpp \
- logging/loggingchannel.cpp
+ logging/loggingchannel.cpp \
+ widgets/userpopupwidget.cpp
HEADERS += account.h \
asyncexec.h \
@@ -101,7 +102,8 @@ HEADERS += account.h \
messages/limitedqueuesnapshot.h \
messages/messageref.h \
logging/loggingmanager.h \
- logging/loggingchannel.h
+ logging/loggingchannel.h \
+ widgets/userpopupwidget.h
PRECOMPILED_HEADER =
@@ -118,3 +120,6 @@ win32 {
macx {
INCLUDEPATH += /usr/local/include
}
+
+FORMS += \
+ forms/userpopup.ui
diff --git a/forms/userpopup.ui b/forms/userpopup.ui
new file mode 100644
index 000000000..8b32b504d
--- /dev/null
+++ b/forms/userpopup.ui
@@ -0,0 +1,124 @@
+
+
+ UserPopup
+
+
+
+ 0
+ 0
+ 400
+ 131
+
+
+
+
+ 0
+ 0
+
+
+
+ UserPopup
+
+
+ -
+
+
+ Purge
+
+
+
+ -
+
+
-
+
+
+ Views
+
+
+
+ -
+
+
+ 420
+
+
+
+ -
+
+
+ Followers
+
+
+
+ -
+
+
+ 69
+
+
+
+ -
+
+
+ Account Age
+
+
+
+ -
+
+
+ 6 years
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 14
+ 75
+ true
+
+
+
+ USERNAME
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Close
+
+
+
+
+
+ -
+
+
+ AVATAR
+
+
+
+
+
+
+
+
diff --git a/widgets/chatwidgetview.cpp b/widgets/chatwidgetview.cpp
index 8fd4fbefb..f959c3a00 100644
--- a/widgets/chatwidgetview.cpp
+++ b/widgets/chatwidgetview.cpp
@@ -4,6 +4,7 @@
#include "messages/message.h"
#include "messages/wordpart.h"
#include "settings.h"
+#include "ui_userpopup.h"
#include "widgets/chatwidget.h"
#include
@@ -20,7 +21,7 @@ ChatWidgetView::ChatWidgetView(ChatWidget *parent)
: QWidget()
, chatWidget(parent)
, scrollbar(this)
- , onlyUpdateEmotes(false)
+ , userPopupWidget(this->chatWidget->getChannel())
{
this->setAttribute(Qt::WA_OpaquePaintEvent);
this->scrollbar.setSmallChange(5);
@@ -311,16 +312,78 @@ ChatWidgetView::mouseMoveEvent(QMouseEvent *event)
int index = message->getSelectionIndex(relativePos);
- qDebug() << index;
-
if (hoverWord.getLink().getIsValid()) {
this->setCursor(Qt::PointingHandCursor);
- qDebug() << hoverWord.getLink().getValue();
} else {
this->setCursor(Qt::ArrowCursor);
}
}
+void
+ChatWidgetView::mousePressEvent(QMouseEvent *event)
+{
+ this->mouseDown = true;
+ this->latestPressPosition = event->screenPos();
+}
+
+static float
+distanceBetweenPoints(const QPointF &p1, const QPointF &p2)
+{
+ QPointF tmp = p1 - p2;
+
+ float distance = 0.f;
+ distance += tmp.x() * tmp.x();
+ distance += tmp.y() * tmp.y();
+
+ return std::sqrt(distance);
+}
+
+void
+ChatWidgetView::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (!this->mouseDown) {
+ // We didn't grab the mouse press, so we shouldn't be handling the mouse
+ // release
+ return;
+ }
+
+ this->mouseDown = false;
+
+ float distance =
+ distanceBetweenPoints(this->latestPressPosition, event->screenPos());
+
+ qDebug() << "Distance: " << distance;
+
+ if (std::fabsf(distance) > 15.f) {
+ // It wasn't a proper click, so we don't care about that here
+ return;
+ }
+
+ // If you clicked and released less than X pixels away, it counts
+ // as a click!
+
+ // show user thing pajaW
+
+ std::shared_ptr message;
+ QPoint relativePos;
+
+ if (!tryGetMessageAt(event->pos(), message, relativePos)) {
+ // No message at clicked position
+ this->userPopupWidget.hide();
+ return;
+ }
+
+ auto _message = message->getMessage();
+ auto user = _message->getUserName();
+
+ qDebug() << "Clicked " << user << "s message";
+
+ this->userPopupWidget.setName(user);
+ this->userPopupWidget.move(event->screenPos().toPoint());
+ this->userPopupWidget.show();
+ this->userPopupWidget.setFocus();
+}
+
bool
ChatWidgetView::tryGetMessageAt(QPoint p,
std::shared_ptr &_message,
diff --git a/widgets/chatwidgetview.h b/widgets/chatwidgetview.h
index fdbf834b8..1fbcc153b 100644
--- a/widgets/chatwidgetview.h
+++ b/widgets/chatwidgetview.h
@@ -6,6 +6,7 @@
#include "messages/messageref.h"
#include "messages/word.h"
#include "widgets/scrollbar.h"
+#include "widgets/userpopupwidget.h"
#include
#include
@@ -40,6 +41,8 @@ protected:
void wheelEvent(QWheelEvent *event);
void mouseMoveEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
bool tryGetMessageAt(QPoint p,
std::shared_ptr &message,
@@ -56,7 +59,13 @@ private:
ChatWidget *chatWidget;
ScrollBar scrollbar;
- bool onlyUpdateEmotes;
+
+ UserPopupWidget userPopupWidget;
+ bool onlyUpdateEmotes = false;
+
+ // Mouse event variables
+ bool mouseDown = false;
+ QPointF latestPressPosition;
private slots:
void
diff --git a/widgets/userpopupwidget.cpp b/widgets/userpopupwidget.cpp
new file mode 100644
index 000000000..98dc3581e
--- /dev/null
+++ b/widgets/userpopupwidget.cpp
@@ -0,0 +1,42 @@
+#include "userpopupwidget.h"
+#include "channel.h"
+#include "ui_userpopup.h"
+
+#include
+
+namespace chatterino {
+namespace widgets {
+
+UserPopupWidget::UserPopupWidget(std::shared_ptr &&_channel)
+ : QWidget(nullptr)
+ , ui(new Ui::UserPopup)
+ , channel(std::move(_channel))
+{
+ this->ui->setupUi(this);
+
+ this->resize(0, 0);
+
+ this->setWindowFlags(Qt::FramelessWindowHint);
+
+ // Close button
+ connect(this->ui->btnClose, &QPushButton::clicked, [=]() {
+ this->hide(); //
+ });
+
+ connect(this->ui->btnPurge, &QPushButton::clicked, [=]() {
+ qDebug() << "xD: " << this->channel->getName();
+ /*
+ this->channel->sendMessage(
+ QString(".timeout %1 0").arg(this->ui->lblUsername->text()));
+ */
+ });
+}
+
+void
+UserPopupWidget::setName(const QString &name)
+{
+ this->ui->lblUsername->setText(name);
+}
+
+} // namespace widgets
+} // namespace chatterino
diff --git a/widgets/userpopupwidget.h b/widgets/userpopupwidget.h
new file mode 100644
index 000000000..11aae122b
--- /dev/null
+++ b/widgets/userpopupwidget.h
@@ -0,0 +1,35 @@
+#ifndef USERPOPUPWIDGET_H
+#define USERPOPUPWIDGET_H
+
+#include
+
+#include
+
+namespace Ui {
+class UserPopup;
+}
+
+namespace chatterino {
+
+class Channel;
+
+namespace widgets {
+
+class UserPopupWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ UserPopupWidget(std::shared_ptr &&_channel);
+
+ void setName(const QString &name);
+
+private:
+ Ui::UserPopup *ui;
+
+ std::shared_ptr channel;
+};
+
+} // namespace widgets
+} // namespace chatterino
+
+#endif // USERPOPUPWIDGET_H