mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-21 03:55:04 +00:00
chore: change class frameless name
This commit is contained in:
parent
9b4484a599
commit
2d81950e3f
8 changed files with 68 additions and 68 deletions
|
@ -15,7 +15,7 @@ Window {
|
|||
property color backgroundColor: "#2E2F30"
|
||||
property color backgroundBorderColor: "#555656"
|
||||
|
||||
WindowFramelessHelperMac {
|
||||
WindowFramelessHelper {
|
||||
target: root;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include "dialog.h"
|
||||
#include "mousetap/mousetap.h"
|
||||
#include "stream.h"
|
||||
#include "windownativeeventfilter.h"
|
||||
#include "windowframelesshelper.h"
|
||||
#include "windowframelesshelpermac.h"
|
||||
|
||||
static Dialog *g_mainDlg = Q_NULLPTR;
|
||||
|
||||
|
@ -76,12 +76,12 @@ int main(int argc, char *argv[])
|
|||
Stream::init();
|
||||
QApplication app(argc, argv);
|
||||
|
||||
qmlRegisterType<WindowFramelessHelperMac>("barry.uibase", 1, 0, "WindowFramelessHelperMac");
|
||||
qmlRegisterType<WindowFramelessHelper>("barry.uibase", 1, 0, "WindowFramelessHelper");
|
||||
|
||||
QQmlApplicationEngine engine("qrc:/MainWindow.qml");
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
WindowFramelessHelper::Instance()->Init();
|
||||
WindowNativeEventFilter::Instance()->Init();
|
||||
#endif
|
||||
|
||||
// windows下通过qmake VERSION变量或者rc设置版本号和应用名称后,这里可以直接拿到
|
||||
|
|
|
@ -4,11 +4,11 @@ HEADERS += \
|
|||
$$PWD/keepratiowidget.h \
|
||||
$$PWD/magneticwidget.h \
|
||||
$$PWD/windowframelesshelper.h \
|
||||
$$PWD/windowframelesshelpermac.h
|
||||
$$PWD/windownativeeventfilter.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/keepratiowidget.cpp \
|
||||
$$PWD/magneticwidget.cpp \
|
||||
$$PWD/windowframelesshelper.cpp \
|
||||
$$PWD/windowframelesshelpermac.mm
|
||||
$$PWD/windowframelesshelper.mm \
|
||||
$$PWD/windownativeeventfilter.cpp
|
||||
|
|
|
@ -1,32 +1,24 @@
|
|||
#pragma once
|
||||
#include <QWindow>
|
||||
#ifndef WindowFramelessHelper_H
|
||||
#define WindowFramelessHelper_H
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QMargins>
|
||||
#include <QQuickWindow>
|
||||
|
||||
class WindowFramelessHelper : public QAbstractNativeEventFilter
|
||||
class WindowFramelessHelper : public QObject
|
||||
{
|
||||
protected:
|
||||
WindowFramelessHelper();
|
||||
~WindowFramelessHelper() override;
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QQuickWindow * target READ target WRITE setTarget NOTIFY targetChanged)
|
||||
|
||||
public:
|
||||
static WindowFramelessHelper *Instance();
|
||||
explicit WindowFramelessHelper(QObject *parent = nullptr);
|
||||
|
||||
void Init();
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
|
||||
QQuickWindow *target() const;
|
||||
void setTarget(QQuickWindow *target);
|
||||
|
||||
signals:
|
||||
void targetChanged();
|
||||
|
||||
private:
|
||||
bool processNcHitTest(void *message, long *result);
|
||||
bool processNcLButtonDown(void *message, long *result);
|
||||
bool processSetCursor(void *message, long *result);
|
||||
|
||||
QWindow *getWindow(WId wndId);
|
||||
|
||||
private:
|
||||
bool m_inited = false;
|
||||
QMargins m_windowMargin = QMargins(0, 0, 0, 0);
|
||||
QQuickWindow* m_target = nullptr;
|
||||
};
|
||||
|
||||
#endif // Q_OS_WIN
|
||||
#endif // WindowFramelessHelper_H
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
#include "windowframelesshelpermac.h"
|
||||
#include "windowframelesshelper.h"
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <QOperatingSystemVersion>
|
||||
|
||||
WindowFramelessHelperMac::WindowFramelessHelperMac(QObject *parent) : QObject(parent)
|
||||
WindowFramelessHelper::WindowFramelessHelper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QQuickWindow *WindowFramelessHelperMac::target() const
|
||||
QQuickWindow *WindowFramelessHelper::target() const
|
||||
{
|
||||
return m_target;
|
||||
}
|
||||
|
||||
void WindowFramelessHelperMac::setTarget(QQuickWindow *target)
|
||||
void WindowFramelessHelper::setTarget(QQuickWindow *target)
|
||||
{
|
||||
if (target == m_target) {
|
||||
return;
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef WINDOWFRAMELESSHELPERMAC_H
|
||||
#define WINDOWFRAMELESSHELPERMAC_H
|
||||
|
||||
#include <QQuickWindow>
|
||||
|
||||
class WindowFramelessHelperMac : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QQuickWindow * target READ target WRITE setTarget NOTIFY targetChanged)
|
||||
|
||||
public:
|
||||
explicit WindowFramelessHelperMac(QObject *parent = nullptr);
|
||||
|
||||
QQuickWindow *target() const;
|
||||
void setTarget(QQuickWindow *target);
|
||||
|
||||
signals:
|
||||
void targetChanged();
|
||||
|
||||
private:
|
||||
QQuickWindow* m_target = nullptr;
|
||||
};
|
||||
|
||||
#endif // WINDOWFRAMELESSHELPERMAC_H
|
|
@ -1,4 +1,4 @@
|
|||
#include "windowframelesshelper.h"
|
||||
#include "windownativeeventfilter.h"
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <QCursor>
|
||||
|
@ -7,20 +7,20 @@
|
|||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
WindowFramelessHelper::WindowFramelessHelper() {}
|
||||
WindowNativeEventFilter::WindowNativeEventFilter() {}
|
||||
|
||||
WindowFramelessHelper::~WindowFramelessHelper()
|
||||
WindowNativeEventFilter::~WindowNativeEventFilter()
|
||||
{
|
||||
// do nothing, because this object is static instance
|
||||
}
|
||||
|
||||
WindowFramelessHelper *WindowFramelessHelper::Instance()
|
||||
WindowNativeEventFilter *WindowNativeEventFilter::Instance()
|
||||
{
|
||||
static WindowFramelessHelper g_windowNativeEventFilter;
|
||||
static WindowNativeEventFilter g_windowNativeEventFilter;
|
||||
return &g_windowNativeEventFilter;
|
||||
}
|
||||
|
||||
void WindowFramelessHelper::Init()
|
||||
void WindowNativeEventFilter::Init()
|
||||
{
|
||||
if (!m_inited) {
|
||||
m_inited = true;
|
||||
|
@ -28,7 +28,7 @@ void WindowFramelessHelper::Init()
|
|||
}
|
||||
}
|
||||
|
||||
bool WindowFramelessHelper::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
||||
bool WindowNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
|
||||
{
|
||||
Q_UNUSED(eventType);
|
||||
|
||||
|
@ -60,7 +60,7 @@ bool WindowFramelessHelper::nativeEventFilter(const QByteArray &eventType, void
|
|||
return false;
|
||||
}
|
||||
|
||||
bool WindowFramelessHelper::processNcHitTest(void *message, long *result)
|
||||
bool WindowNativeEventFilter::processNcHitTest(void *message, long *result)
|
||||
{
|
||||
MSG *param = static_cast<MSG *>(message);
|
||||
if (!param) {
|
||||
|
@ -126,7 +126,7 @@ bool WindowFramelessHelper::processNcHitTest(void *message, long *result)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool WindowFramelessHelper::processNcLButtonDown(void *message, long *result)
|
||||
bool WindowNativeEventFilter::processNcLButtonDown(void *message, long *result)
|
||||
{
|
||||
Q_UNUSED(result);
|
||||
|
||||
|
@ -173,7 +173,7 @@ bool WindowFramelessHelper::processNcLButtonDown(void *message, long *result)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool WindowFramelessHelper::processSetCursor(void *message, long *result)
|
||||
bool WindowNativeEventFilter::processSetCursor(void *message, long *result)
|
||||
{
|
||||
Q_UNUSED(result);
|
||||
|
||||
|
@ -240,7 +240,7 @@ bool WindowFramelessHelper::processSetCursor(void *message, long *result)
|
|||
return true;
|
||||
}
|
||||
|
||||
QWindow *WindowFramelessHelper::getWindow(WId wndId)
|
||||
QWindow *WindowNativeEventFilter::getWindow(WId wndId)
|
||||
{
|
||||
QWindowList windows = QGuiApplication::topLevelWindows();
|
||||
for (int i = 0; i < windows.size(); ++i) {
|
32
QtScrcpy/uibase/windownativeeventfilter.h
Normal file
32
QtScrcpy/uibase/windownativeeventfilter.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
#include <QWindow>
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QMargins>
|
||||
|
||||
class WindowNativeEventFilter : public QAbstractNativeEventFilter
|
||||
{
|
||||
protected:
|
||||
WindowNativeEventFilter();
|
||||
~WindowNativeEventFilter() override;
|
||||
|
||||
public:
|
||||
static WindowNativeEventFilter *Instance();
|
||||
|
||||
void Init();
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
|
||||
|
||||
private:
|
||||
bool processNcHitTest(void *message, long *result);
|
||||
bool processNcLButtonDown(void *message, long *result);
|
||||
bool processSetCursor(void *message, long *result);
|
||||
|
||||
QWindow *getWindow(WId wndId);
|
||||
|
||||
private:
|
||||
bool m_inited = false;
|
||||
QMargins m_windowMargin = QMargins(0, 0, 0, 0);
|
||||
};
|
||||
|
||||
#endif // Q_OS_WIN
|
Loading…
Add table
Reference in a new issue