mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-26 21:37:04 +08:00
update
This commit is contained in:
parent
99ff310448
commit
42f0987e73
@ -98,6 +98,20 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}else if(uMsg == WM_NCCALCSIZE){
|
}else if(uMsg == WM_NCCALCSIZE){
|
||||||
|
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
||||||
|
const LONG originalTop = clientRect->top;
|
||||||
|
const LONG originalLeft = clientRect->left;
|
||||||
|
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
|
||||||
|
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
|
||||||
|
*result = hitTestResult;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(IsZoomed(hwnd)){
|
||||||
|
_helper->setOriginalPos(QPoint(originalLeft,originalTop));
|
||||||
|
}else{
|
||||||
|
_helper->setOriginalPos({});
|
||||||
|
}
|
||||||
|
clientRect->top = originalTop;
|
||||||
*result = WVR_REDRAW;
|
*result = WVR_REDRAW;
|
||||||
return true;
|
return true;
|
||||||
}else if(uMsg == WM_NCPAINT){
|
}else if(uMsg == WM_NCPAINT){
|
||||||
@ -243,7 +257,7 @@ void FluFramelessHelper::componentComplete(){
|
|||||||
}
|
}
|
||||||
if(!window.isNull()){
|
if(!window.isNull()){
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
window->setFlags(window->flags() | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
|
// window->setFlags(window->flags() | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
|
||||||
_nativeEvent =new FramelessEventFilter(this);
|
_nativeEvent =new FramelessEventFilter(this);
|
||||||
qApp->installNativeEventFilter(_nativeEvent);
|
qApp->installNativeEventFilter(_nativeEvent);
|
||||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||||
@ -254,12 +268,12 @@ void FluFramelessHelper::componentComplete(){
|
|||||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
|
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
|
||||||
}
|
}
|
||||||
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
||||||
showShadow(hwnd);
|
|
||||||
#else
|
#else
|
||||||
window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window);
|
window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window);
|
||||||
#endif
|
#endif
|
||||||
_stayTop = QQmlProperty(window,"stayTop");
|
_stayTop = QQmlProperty(window,"stayTop");
|
||||||
_screen = QQmlProperty(window,"screen");
|
_screen = QQmlProperty(window,"screen");
|
||||||
|
_originalPos = QQmlProperty(window,"_originalPos");
|
||||||
_onStayTopChange();
|
_onStayTopChange();
|
||||||
_stayTop.connectNotifySignal(this,SLOT(_onStayTopChange()));
|
_stayTop.connectNotifySignal(this,SLOT(_onStayTopChange()));
|
||||||
_screen.connectNotifySignal(this,SLOT(_onScreenChanged()));
|
_screen.connectNotifySignal(this,SLOT(_onScreenChanged()));
|
||||||
@ -353,6 +367,10 @@ QObject* FluFramelessHelper::maximizeButton(){
|
|||||||
return var.value<QObject*>();
|
return var.value<QObject*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FluFramelessHelper::setOriginalPos(QVariant pos){
|
||||||
|
_originalPos.write(pos);
|
||||||
|
}
|
||||||
|
|
||||||
bool FluFramelessHelper::resizeable(){
|
bool FluFramelessHelper::resizeable(){
|
||||||
return !(window->width() == window->maximumWidth() && window->width() == window->minimumWidth() && window->height() == window->maximumHeight() && window->height() == window->minimumHeight());
|
return !(window->width() == window->maximumWidth() && window->width() == window->minimumWidth() && window->height() == window->maximumHeight() && window->height() == window->minimumHeight());
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ public:
|
|||||||
bool hoverMaxBtn();
|
bool hoverMaxBtn();
|
||||||
bool resizeable();
|
bool resizeable();
|
||||||
QObject* maximizeButton();
|
QObject* maximizeButton();
|
||||||
|
void setOriginalPos(QVariant pos);
|
||||||
Q_INVOKABLE void showSystemMenu();
|
Q_INVOKABLE void showSystemMenu();
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
@ -54,6 +55,7 @@ private:
|
|||||||
FramelessEventFilter* _nativeEvent = nullptr;
|
FramelessEventFilter* _nativeEvent = nullptr;
|
||||||
QQmlProperty _stayTop;
|
QQmlProperty _stayTop;
|
||||||
QQmlProperty _screen;
|
QQmlProperty _screen;
|
||||||
|
QQmlProperty _originalPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUFRAMELESSHELPER_H
|
#endif // FLUFRAMELESSHELPER_H
|
||||||
|
@ -54,6 +54,7 @@ Window {
|
|||||||
signal initArgument(var argument)
|
signal initArgument(var argument)
|
||||||
signal firstVisible()
|
signal firstVisible()
|
||||||
property point _offsetXY : Qt.point(0,0)
|
property point _offsetXY : Qt.point(0,0)
|
||||||
|
property var _originalPos
|
||||||
id:window
|
id:window
|
||||||
color:"transparent"
|
color:"transparent"
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
@ -73,12 +74,12 @@ Window {
|
|||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
lifecycle.onDestruction()
|
lifecycle.onDestruction()
|
||||||
}
|
}
|
||||||
onVisibilityChanged: {
|
on_OriginalPosChanged: {
|
||||||
if(visibility === Window.Maximized || visibility === Window.FullScreen){
|
if(_originalPos){
|
||||||
var dx = window.x-Screen.virtualX
|
var dx = (_originalPos.x - screen.virtualX)/screen.devicePixelRatio
|
||||||
var dy = window.y-Screen.virtualY
|
var dy = _originalPos.y - screen.virtualY/screen.devicePixelRatio
|
||||||
if(dx<0 && dy<0){
|
if(dx<0 && dy<0){
|
||||||
_offsetXY = Qt.point(Math.abs(dx+1),Math.abs(dy+1))
|
_offsetXY = Qt.point(Math.abs(dx),Math.abs(dy))
|
||||||
}else{
|
}else{
|
||||||
_offsetXY = Qt.point(0,0)
|
_offsetXY = Qt.point(0,0)
|
||||||
}
|
}
|
||||||
@ -191,10 +192,7 @@ Window {
|
|||||||
id:layout_container
|
id:layout_container
|
||||||
anchors{
|
anchors{
|
||||||
fill:parent
|
fill:parent
|
||||||
leftMargin: _offsetXY.x
|
topMargin: _offsetXY.x
|
||||||
rightMargin: _offsetXY.x
|
|
||||||
topMargin: _offsetXY.y
|
|
||||||
bottomMargin: _offsetXY.y
|
|
||||||
}
|
}
|
||||||
onWidthChanged: {
|
onWidthChanged: {
|
||||||
window.appBar.width = width
|
window.appBar.width = width
|
||||||
|
@ -53,6 +53,7 @@ Window {
|
|||||||
signal initArgument(var argument)
|
signal initArgument(var argument)
|
||||||
signal firstVisible()
|
signal firstVisible()
|
||||||
property point _offsetXY : Qt.point(0,0)
|
property point _offsetXY : Qt.point(0,0)
|
||||||
|
property var _originalPos
|
||||||
id:window
|
id:window
|
||||||
color:"transparent"
|
color:"transparent"
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
@ -72,12 +73,12 @@ Window {
|
|||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
lifecycle.onDestruction()
|
lifecycle.onDestruction()
|
||||||
}
|
}
|
||||||
onVisibilityChanged: {
|
on_OriginalPosChanged: {
|
||||||
if(visibility === Window.Maximized || visibility === Window.FullScreen){
|
if(_originalPos){
|
||||||
var dx = window.x-Screen.virtualX
|
var dx = (_originalPos.x - screen.virtualX)/screen.devicePixelRatio
|
||||||
var dy = window.y-Screen.virtualY
|
var dy = _originalPos.y - screen.virtualY/screen.devicePixelRatio
|
||||||
if(dx<0 && dy<0){
|
if(dx<0 && dy<0){
|
||||||
_offsetXY = Qt.point(Math.abs(dx+1),Math.abs(dy+1))
|
_offsetXY = Qt.point(Math.abs(dx),Math.abs(dy))
|
||||||
}else{
|
}else{
|
||||||
_offsetXY = Qt.point(0,0)
|
_offsetXY = Qt.point(0,0)
|
||||||
}
|
}
|
||||||
@ -190,10 +191,7 @@ Window {
|
|||||||
id:layout_container
|
id:layout_container
|
||||||
anchors{
|
anchors{
|
||||||
fill:parent
|
fill:parent
|
||||||
leftMargin: _offsetXY.x
|
topMargin: _offsetXY.x
|
||||||
rightMargin: _offsetXY.x
|
|
||||||
topMargin: _offsetXY.y
|
|
||||||
bottomMargin: _offsetXY.y
|
|
||||||
}
|
}
|
||||||
onWidthChanged: {
|
onWidthChanged: {
|
||||||
window.appBar.width = width
|
window.appBar.width = width
|
||||||
|
Loading…
Reference in New Issue
Block a user