mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-01-23 04:14:35 +08:00
update
This commit is contained in:
parent
38ea91964e
commit
f973f006d2
@ -5,6 +5,7 @@
|
||||
#ifdef Q_OS_WIN
|
||||
#pragma comment(lib, "user32.lib")
|
||||
#include <windows.h>
|
||||
|
||||
static inline QByteArray qtNativeEventType()
|
||||
{
|
||||
static const auto result = "windows_generic_MSG";
|
||||
@ -26,6 +27,7 @@ static inline bool isCompositionEnabled(){
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
FramelessEventFilter::FramelessEventFilter(QQuickWindow* window){
|
||||
@ -183,7 +185,7 @@ void FluFrameless::componentComplete(){
|
||||
o = o->parent();
|
||||
}
|
||||
if(!_window.isNull()){
|
||||
_window->setFlag(Qt::FramelessWindowHint,true);
|
||||
_window->setFlags(Qt::FramelessWindowHint|Qt::Window|Qt::WindowTitleHint|Qt::WindowMinMaxButtonsHint|Qt::WindowCloseButtonHint);
|
||||
#ifdef Q_OS_WIN
|
||||
_nativeEvent =new FramelessEventFilter(_window);
|
||||
qApp->installNativeEventFilter(_nativeEvent);
|
||||
@ -193,24 +195,39 @@ void FluFrameless::componentComplete(){
|
||||
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
|
||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION &~ WS_SYSMENU);
|
||||
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE |SWP_FRAMECHANGED);
|
||||
_stayTop = QQmlProperty(_window,"stayTop");
|
||||
_stayTop.connectNotifySignal(this,SLOT(_stayTopChange()));
|
||||
#endif
|
||||
_stayTop = QQmlProperty(_window,"stayTop");
|
||||
_stayTop.connectNotifySignal(this,SLOT(_onStayTopChange()));
|
||||
_screen = QQmlProperty(_window,"screen");
|
||||
_screen.connectNotifySignal(this,SLOT(_onScreenChanged()));
|
||||
_window->installEventFilter(this);
|
||||
}
|
||||
}
|
||||
|
||||
void FluFrameless::_stayTopChange(){
|
||||
void FluFrameless::_onScreenChanged(){
|
||||
_window->update();
|
||||
QGuiApplication::processEvents();
|
||||
}
|
||||
|
||||
void FluFrameless::_onStayTopChange(){
|
||||
bool isStayTop = _stayTop.read().toBool();
|
||||
#ifdef Q_OS_WIN
|
||||
HWND hwnd = reinterpret_cast<HWND>(_window->winId());
|
||||
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
|
||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION &~ WS_SYSMENU);
|
||||
if(isStayTop){
|
||||
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
}else{
|
||||
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
}
|
||||
#else
|
||||
_window->setFlag(Qt::WindowStaysOnTopHint,isStayTop)
|
||||
#endif
|
||||
}
|
||||
|
||||
FluFrameless::~FluFrameless(){
|
||||
if (!_window.isNull()) {
|
||||
_window->setFlag(Qt::FramelessWindowHint,false);
|
||||
_window->setFlags(Qt::Window);
|
||||
#ifdef Q_OS_WIN
|
||||
qApp->removeNativeEventFilter(_nativeEvent);
|
||||
#endif
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QQmlProperty>
|
||||
#include "stdafx.h"
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
using QT_NATIVE_EVENT_RESULT_TYPE = qintptr;
|
||||
@ -39,11 +38,13 @@ protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
private:
|
||||
void updateCursor(int edges);
|
||||
Q_SLOT void _stayTopChange();
|
||||
Q_SLOT void _onStayTopChange();
|
||||
Q_SLOT void _onScreenChanged();
|
||||
private:
|
||||
QPointer<QQuickWindow> _window = nullptr;
|
||||
FramelessEventFilter* _nativeEvent = nullptr;
|
||||
QQmlProperty _stayTop;
|
||||
QQmlProperty _screen;
|
||||
};
|
||||
|
||||
#endif // FLUFRAMELESS_H
|
||||
|
@ -53,15 +53,11 @@ Window {
|
||||
signal initArgument(var argument)
|
||||
signal firstVisible()
|
||||
id:window
|
||||
flags: Qt.Window | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint
|
||||
maximumWidth: fixSize ? width : 16777215
|
||||
maximumHeight: fixSize ? height : 16777215
|
||||
minimumWidth: fixSize ? width : 0
|
||||
minimumHeight: fixSize ? height : 0
|
||||
color:"transparent"
|
||||
onStayTopChanged: {
|
||||
d.changedStayTop()
|
||||
}
|
||||
Component.onCompleted: {
|
||||
useSystemAppBar = FluApp.useSystemAppBar
|
||||
if(!useSystemAppBar){
|
||||
@ -89,22 +85,6 @@ Window {
|
||||
QtObject{
|
||||
id:d
|
||||
property bool isFirstVisible: true
|
||||
function changedStayTop(){
|
||||
function toggleStayTop(){
|
||||
if(window.stayTop){
|
||||
window.flags = window.flags | Qt.WindowStaysOnTopHint
|
||||
}else{
|
||||
window.flags = window.flags &~ Qt.WindowStaysOnTopHint
|
||||
}
|
||||
}
|
||||
if(window.visibility === Window.Maximized){
|
||||
window.visibility = Window.Windowed
|
||||
toggleStayTop()
|
||||
window.visibility = Window.Maximized
|
||||
}else{
|
||||
toggleStayTop()
|
||||
}
|
||||
}
|
||||
}
|
||||
Connections{
|
||||
target: window
|
||||
@ -196,13 +176,25 @@ Window {
|
||||
id:loader_frameless
|
||||
}
|
||||
Item{
|
||||
anchors.fill: parent
|
||||
anchors.margins: {
|
||||
if(FluTools.isWin() && !window.useSystemAppBar){
|
||||
return window.visibility === Window.Maximized ? 8 : 0
|
||||
property int offsetX: {
|
||||
if(window.visibility === Window.Maximized){
|
||||
return Math.abs(window.x-Screen.virtualX)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
property int offsetY: {
|
||||
if(window.visibility === Window.Maximized){
|
||||
return Math.abs(window.y-Screen.virtualY)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
anchors{
|
||||
fill:parent
|
||||
leftMargin: offsetX
|
||||
rightMargin: offsetX
|
||||
topMargin: offsetY
|
||||
bottomMargin: offsetY
|
||||
}
|
||||
onWidthChanged: {
|
||||
window.appBar.width = width
|
||||
}
|
||||
|
@ -52,15 +52,11 @@ Window {
|
||||
signal initArgument(var argument)
|
||||
signal firstVisible()
|
||||
id:window
|
||||
flags: Qt.Window | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint
|
||||
maximumWidth: fixSize ? width : 16777215
|
||||
maximumHeight: fixSize ? height : 16777215
|
||||
minimumWidth: fixSize ? width : 0
|
||||
minimumHeight: fixSize ? height : 0
|
||||
color:"transparent"
|
||||
onStayTopChanged: {
|
||||
d.changedStayTop()
|
||||
}
|
||||
Component.onCompleted: {
|
||||
useSystemAppBar = FluApp.useSystemAppBar
|
||||
if(!useSystemAppBar){
|
||||
@ -88,22 +84,6 @@ Window {
|
||||
QtObject{
|
||||
id:d
|
||||
property bool isFirstVisible: true
|
||||
function changedStayTop(){
|
||||
function toggleStayTop(){
|
||||
if(window.stayTop){
|
||||
window.flags = window.flags | Qt.WindowStaysOnTopHint
|
||||
}else{
|
||||
window.flags = window.flags &~ Qt.WindowStaysOnTopHint
|
||||
}
|
||||
}
|
||||
if(window.visibility === Window.Maximized){
|
||||
window.visibility = Window.Windowed
|
||||
toggleStayTop()
|
||||
window.visibility = Window.Maximized
|
||||
}else{
|
||||
toggleStayTop()
|
||||
}
|
||||
}
|
||||
}
|
||||
Connections{
|
||||
target: window
|
||||
@ -195,13 +175,25 @@ Window {
|
||||
id:loader_frameless
|
||||
}
|
||||
Item{
|
||||
anchors.fill: parent
|
||||
anchors.margins: {
|
||||
if(FluTools.isWin() && !window.useSystemAppBar){
|
||||
return window.visibility === Window.Maximized ? 8 : 0
|
||||
property int offsetX: {
|
||||
if(window.visibility === Window.Maximized){
|
||||
return Math.abs(window.x-Screen.virtualX)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
property int offsetY: {
|
||||
if(window.visibility === Window.Maximized){
|
||||
return Math.abs(window.y-Screen.virtualY)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
anchors{
|
||||
fill:parent
|
||||
leftMargin: offsetX
|
||||
rightMargin: offsetX
|
||||
topMargin: offsetY
|
||||
bottomMargin: offsetY
|
||||
}
|
||||
onWidthChanged: {
|
||||
window.appBar.width = width
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user