mirror-chatterino2/src/widgets/chatwidgetview.hpp

78 lines
1.8 KiB
C++
Raw Normal View History

2017-06-06 17:18:23 +02:00
#pragma once
2017-01-01 02:30:42 +01:00
2017-06-11 09:31:45 +02:00
#include "channel.hpp"
#include "messages/lazyloadedimage.hpp"
#include "messages/messageref.hpp"
#include "messages/word.hpp"
#include "widgets/accountpopup.hpp"
#include "widgets/basewidget.hpp"
2017-06-11 09:31:45 +02:00
#include "widgets/scrollbar.hpp"
2017-01-01 02:30:42 +01:00
2017-01-18 04:33:30 +01:00
#include <QPaintEvent>
2017-01-26 04:26:40 +01:00
#include <QScroller>
#include <QWheelEvent>
2017-01-18 04:33:30 +01:00
#include <QWidget>
2017-01-18 21:30:23 +01:00
namespace chatterino {
namespace widgets {
2017-01-17 00:15:44 +01:00
class ChatWidget;
class ChatWidgetView : public BaseWidget
2017-01-01 02:30:42 +01:00
{
public:
explicit ChatWidgetView(ChatWidget *_chatWidget);
2017-01-22 12:46:35 +01:00
~ChatWidgetView();
2017-01-05 16:07:20 +01:00
bool layoutMessages();
2017-04-12 17:46:44 +02:00
void updateGifEmotes();
ScrollBar &getScrollBar();
2017-02-07 00:03:15 +01:00
2017-01-03 21:19:33 +01:00
protected:
virtual void resizeEvent(QResizeEvent *) override;
2017-01-03 21:19:33 +01:00
virtual void paintEvent(QPaintEvent *) override;
virtual void wheelEvent(QWheelEvent *event) override;
2017-01-26 04:26:40 +01:00
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override;
2017-02-17 23:51:35 +01:00
2017-04-12 17:46:44 +02:00
bool tryGetMessageAt(QPoint p, std::shared_ptr<messages::MessageRef> &message,
2017-02-17 23:51:35 +01:00
QPoint &relativePos);
2017-01-18 04:33:30 +01:00
private:
2017-02-07 00:03:15 +01:00
struct GifEmoteData {
messages::LazyLoadedImage *image;
QRect rect;
};
std::vector<GifEmoteData> gifEmotes;
2017-04-12 17:46:44 +02:00
ChatWidget *const chatWidget;
2017-04-12 17:46:44 +02:00
ScrollBar scrollBar;
2017-02-07 00:03:15 +01:00
// This variable can be used to decide whether or not we should render the "Show latest
// messages" button
bool showingLatestMessages = true;
AccountPopupWidget userPopupWidget;
bool onlyUpdateEmotes = false;
2017-01-05 16:07:20 +01:00
2017-04-12 17:46:44 +02:00
// Mouse event variables
bool isMouseDown = false;
QPointF lastPressPosition;
2017-01-22 12:46:35 +01:00
private slots:
2017-04-12 17:46:44 +02:00
void wordTypeMaskChanged()
2017-01-22 12:46:35 +01:00
{
2017-02-17 23:51:35 +01:00
layoutMessages();
2017-02-07 00:03:15 +01:00
update();
2017-01-22 12:46:35 +01:00
}
2017-01-01 02:30:42 +01:00
};
2017-06-06 17:18:23 +02:00
2017-04-14 17:52:22 +02:00
} // namespace widgets
} // namespace chatterino