2020-01-02 07:45:25 +00:00
|
|
|
#pragma once
|
2020-02-28 07:01:01 +00:00
|
|
|
#include "common/types.h"
|
2020-06-29 16:46:57 +00:00
|
|
|
#include "common/window_info.h"
|
2020-03-12 03:53:51 +00:00
|
|
|
#include <QtWidgets/QWidget>
|
2020-06-29 16:46:57 +00:00
|
|
|
#include <optional>
|
2020-01-02 07:45:25 +00:00
|
|
|
|
2020-04-22 11:13:51 +00:00
|
|
|
class QtDisplayWidget final : public QWidget
|
2020-01-02 07:45:25 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-04-22 11:13:51 +00:00
|
|
|
QtDisplayWidget(QWidget* parent);
|
|
|
|
~QtDisplayWidget();
|
2020-03-12 03:53:51 +00:00
|
|
|
|
2020-04-22 11:13:51 +00:00
|
|
|
QPaintEngine* paintEngine() const override;
|
2020-01-02 09:14:16 +00:00
|
|
|
|
2020-04-08 14:14:19 +00:00
|
|
|
int scaledWindowWidth() const;
|
|
|
|
int scaledWindowHeight() const;
|
2020-04-22 11:13:51 +00:00
|
|
|
qreal devicePixelRatioFromScreen() const;
|
2020-04-08 14:14:19 +00:00
|
|
|
|
2020-06-29 16:46:57 +00:00
|
|
|
std::optional<WindowInfo> getWindowInfo() const;
|
|
|
|
|
2020-12-27 04:08:13 +00:00
|
|
|
void setRelativeMode(bool enabled);
|
|
|
|
|
2020-01-02 09:14:16 +00:00
|
|
|
Q_SIGNALS:
|
2021-02-25 02:51:43 +00:00
|
|
|
void windowFocusEvent();
|
2020-01-02 09:14:16 +00:00
|
|
|
void windowResizedEvent(int width, int height);
|
2020-03-22 11:50:49 +00:00
|
|
|
void windowRestoredEvent();
|
2020-04-22 11:13:51 +00:00
|
|
|
void windowClosedEvent();
|
|
|
|
void windowKeyEvent(int key_code, bool pressed);
|
2020-04-26 07:36:49 +00:00
|
|
|
void windowMouseMoveEvent(int x, int y);
|
|
|
|
void windowMouseButtonEvent(int button, bool pressed);
|
2021-02-25 16:42:20 +00:00
|
|
|
void windowMouseWheelEvent(const QPoint& angle_delta);
|
2020-01-02 09:14:16 +00:00
|
|
|
|
2020-01-02 07:45:25 +00:00
|
|
|
protected:
|
2020-04-22 11:13:51 +00:00
|
|
|
bool event(QEvent* event) override;
|
2020-12-27 04:08:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QPoint m_relative_mouse_start_position{};
|
|
|
|
QPoint m_relative_mouse_last_position{};
|
|
|
|
bool m_relative_mouse_enabled = false;
|
2020-01-02 07:45:25 +00:00
|
|
|
};
|