2023-12-19 20:02:15 +08:00
|
|
|
#ifndef FLUFRAMELESSHELPER_H
|
|
|
|
#define FLUFRAMELESSHELPER_H
|
2023-12-11 23:47:03 +08:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QQuickWindow>
|
|
|
|
#include <QtQml/qqml.h>
|
|
|
|
#include <QAbstractNativeEventFilter>
|
2023-12-18 22:24:24 +08:00
|
|
|
#include <QQmlProperty>
|
2023-12-11 23:47:03 +08:00
|
|
|
|
2023-12-13 21:28:21 +08:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
|
|
using QT_NATIVE_EVENT_RESULT_TYPE = qintptr;
|
|
|
|
using QT_ENTER_EVENT_TYPE = QEnterEvent;
|
|
|
|
#else
|
|
|
|
using QT_NATIVE_EVENT_RESULT_TYPE = long;
|
|
|
|
using QT_ENTER_EVENT_TYPE = QEvent;
|
|
|
|
#endif
|
|
|
|
|
2023-12-22 01:30:25 +08:00
|
|
|
class FluFramelessHelper;
|
|
|
|
|
2023-12-13 21:28:21 +08:00
|
|
|
class FramelessEventFilter : public QAbstractNativeEventFilter
|
|
|
|
{
|
|
|
|
public:
|
2023-12-22 01:30:25 +08:00
|
|
|
FramelessEventFilter(FluFramelessHelper* helper);
|
2023-12-13 21:28:21 +08:00
|
|
|
bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
|
|
|
|
public:
|
2023-12-22 01:30:25 +08:00
|
|
|
QPointer<FluFramelessHelper> _helper = nullptr;
|
2023-12-13 21:28:21 +08:00
|
|
|
qint64 _current = 0;
|
|
|
|
};
|
|
|
|
|
2023-12-19 20:02:15 +08:00
|
|
|
class FluFramelessHelper : public QObject, public QQmlParserStatus
|
2023-12-11 23:47:03 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-12-19 20:02:15 +08:00
|
|
|
QML_NAMED_ELEMENT(FluFramelessHelper)
|
2023-12-11 23:47:03 +08:00
|
|
|
public:
|
2023-12-19 20:02:15 +08:00
|
|
|
explicit FluFramelessHelper(QObject *parent = nullptr);
|
|
|
|
~FluFramelessHelper();
|
2023-12-11 23:47:03 +08:00
|
|
|
void classBegin() override;
|
|
|
|
void componentComplete() override;
|
2023-12-22 01:30:25 +08:00
|
|
|
bool hoverMaxBtn();
|
|
|
|
bool resizeable();
|
|
|
|
QObject* maximizeButton();
|
2023-12-29 17:38:04 +08:00
|
|
|
void setOriginalPos(QVariant pos);
|
2023-12-22 01:30:25 +08:00
|
|
|
Q_INVOKABLE void showSystemMenu();
|
2024-01-02 16:56:28 +08:00
|
|
|
Q_SIGNAL void loadCompleted();
|
2023-12-11 23:47:03 +08:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
|
|
private:
|
2023-12-22 01:30:25 +08:00
|
|
|
void _updateCursor(int edges);
|
|
|
|
bool _maximized();
|
|
|
|
bool _fullScreen();
|
2023-12-19 18:01:49 +08:00
|
|
|
Q_SLOT void _onStayTopChange();
|
|
|
|
Q_SLOT void _onScreenChanged();
|
2023-12-22 01:30:25 +08:00
|
|
|
public:
|
|
|
|
QPointer<QQuickWindow> window = nullptr;
|
2023-12-11 23:47:03 +08:00
|
|
|
private:
|
2023-12-13 21:28:21 +08:00
|
|
|
FramelessEventFilter* _nativeEvent = nullptr;
|
2023-12-18 22:24:24 +08:00
|
|
|
QQmlProperty _stayTop;
|
2023-12-19 18:01:49 +08:00
|
|
|
QQmlProperty _screen;
|
2023-12-29 17:38:04 +08:00
|
|
|
QQmlProperty _originalPos;
|
2023-12-29 23:09:46 +08:00
|
|
|
QQmlProperty _fixSize;
|
2024-01-01 20:01:46 +08:00
|
|
|
QQmlProperty _realHeight;
|
|
|
|
QQmlProperty _realWidth;
|
|
|
|
QQmlProperty _appBarHeight;
|
2023-12-11 23:47:03 +08:00
|
|
|
};
|
|
|
|
|
2023-12-19 20:02:15 +08:00
|
|
|
#endif // FLUFRAMELESSHELPER_H
|