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