diff --git a/src/FluFramelessHelper.cpp b/src/FluFramelessHelper.cpp index 943197b4..9a009a21 100644 --- a/src/FluFramelessHelper.cpp +++ b/src/FluFramelessHelper.cpp @@ -113,6 +113,14 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void * QGuiApplication::sendEvent(_helper->maximizeButton(),&event); } return false; + }else if(uMsg == WM_GETMINMAXINFO){ + if(IsZoomed(hwnd)){ + RECT frame = {0,0,0,0}; + AdjustWindowRectEx(&frame,WS_OVERLAPPEDWINDOW,FALSE,0); + _helper->setOffsetXY(QPoint(floor(abs(frame.left)/_helper->window->devicePixelRatio()),floor(abs(frame.bottom)/_helper->window->devicePixelRatio()))); + }else{ + _helper->setOffsetXY(QPoint(0,0)); + } } return false; #endif @@ -222,18 +230,26 @@ void FluFramelessHelper::componentComplete(){ o = o->parent(); } if(!window.isNull()){ - window->setFlags(Qt::FramelessWindowHint|Qt::Window|Qt::WindowTitleHint|Qt::WindowMinMaxButtonsHint|Qt::WindowCloseButtonHint); #ifdef Q_OS_WIN + window->setFlags(window->flags() | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint); _nativeEvent =new FramelessEventFilter(this); qApp->installNativeEventFilter(_nativeEvent); HWND hwnd = reinterpret_cast(window->winId()); - SetWindowPos(hwnd,0,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER); + DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); + if(resizeable()){ + SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION); + }else{ + SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION); + } showShadow(hwnd); +#else + window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window); #endif _stayTop = QQmlProperty(window,"stayTop"); + _screen = QQmlProperty(window,"screen"); + _offsetXY = QQmlProperty(window,"_offsetXY"); _onStayTopChange(); _stayTop.connectNotifySignal(this,SLOT(_onStayTopChange())); - _screen = QQmlProperty(window,"screen"); _screen.connectNotifySignal(this,SLOT(_onScreenChanged())); window->installEventFilter(this); } @@ -278,8 +294,6 @@ void FluFramelessHelper::_onStayTopChange(){ bool isStayTop = _stayTop.read().toBool(); #ifdef Q_OS_WIN HWND hwnd = reinterpret_cast(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{ @@ -327,6 +341,10 @@ QObject* FluFramelessHelper::maximizeButton(){ return var.value(); } +void FluFramelessHelper::setOffsetXY(QPoint val){ + _offsetXY.write(val); +} + bool FluFramelessHelper::resizeable(){ return !(window->width() == window->maximumWidth() && window->width() == window->minimumWidth() && window->height() == window->maximumHeight() && window->height() == window->minimumHeight()); } diff --git a/src/FluFramelessHelper.h b/src/FluFramelessHelper.h index 09334533..0943f96b 100644 --- a/src/FluFramelessHelper.h +++ b/src/FluFramelessHelper.h @@ -39,6 +39,7 @@ public: bool hoverMaxBtn(); bool resizeable(); QObject* maximizeButton(); + void setOffsetXY(QPoint val); Q_INVOKABLE void showSystemMenu(); protected: bool eventFilter(QObject *obj, QEvent *event) override; @@ -54,6 +55,7 @@ private: FramelessEventFilter* _nativeEvent = nullptr; QQmlProperty _stayTop; QQmlProperty _screen; + QQmlProperty _offsetXY; }; #endif // FLUFRAMELESSHELPER_H diff --git a/src/Qt5/imports/FluentUI/Controls/FluCopyableText.qml b/src/Qt5/imports/FluentUI/Controls/FluCopyableText.qml index cb902881..1f1dea3c 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluCopyableText.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluCopyableText.qml @@ -26,6 +26,7 @@ TextEdit { anchors.fill: parent cursorShape: Qt.IBeamCursor acceptedButtons: Qt.RightButton + visible: !readOnly onClicked: control.echoMode !== TextInput.Password && menu.popup() } FluTextBoxMenu{ diff --git a/src/Qt5/imports/FluentUI/Controls/FluMultilineTextBox.qml b/src/Qt5/imports/FluentUI/Controls/FluMultilineTextBox.qml index 6cf3da86..c600d2c6 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluMultilineTextBox.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluMultilineTextBox.qml @@ -64,6 +64,7 @@ TextArea{ anchors.fill: parent cursorShape: Qt.IBeamCursor acceptedButtons: Qt.RightButton + visible: !readOnly onClicked: control.echoMode !== TextInput.Password && menu.popup() } FluTextBoxMenu{ diff --git a/src/Qt5/imports/FluentUI/Controls/FluTextBox.qml b/src/Qt5/imports/FluentUI/Controls/FluTextBox.qml index f914a476..8ad43bd7 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluTextBox.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluTextBox.qml @@ -62,6 +62,7 @@ TextField{ anchors.fill: parent cursorShape: Qt.IBeamCursor acceptedButtons: Qt.RightButton + visible: !readOnly onClicked: control.echoMode !== TextInput.Password && menu.popup() } RowLayout{ diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index 074462e8..7bf8f890 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -53,6 +53,7 @@ Window { signal showSystemMenu signal initArgument(var argument) signal firstVisible() + property point _offsetXY : Qt.point(0,0) id:window color:"transparent" Component.onCompleted: { @@ -175,30 +176,12 @@ Window { } Item{ id:layout_container - property int offsetX: { - if(window.visibility === Window.Maximized){ - var dx = window.x-Screen.virtualX - if(dx<0){ - return Math.abs(dx+1) - } - } - return 0 - } - property int offsetY: { - if(window.visibility === Window.Maximized){ - var dy = window.y-Screen.virtualY - if(dy<0){ - return Math.abs(dy+1) - } - } - return 0 - } anchors{ fill:parent - leftMargin: offsetX - rightMargin: offsetX - topMargin: offsetY - bottomMargin: offsetY + leftMargin: _offsetXY.x + rightMargin: _offsetXY.x + topMargin: _offsetXY.y + bottomMargin: _offsetXY.y } onWidthChanged: { window.appBar.width = width diff --git a/src/Qt6/imports/FluentUI/Controls/FluCopyableText.qml b/src/Qt6/imports/FluentUI/Controls/FluCopyableText.qml index 34c1fc7f..90d40775 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluCopyableText.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluCopyableText.qml @@ -26,6 +26,7 @@ TextEdit { anchors.fill: parent cursorShape: Qt.IBeamCursor acceptedButtons: Qt.RightButton + visible: !readOnly onClicked: control.echoMode !== TextInput.Password && menu.popup() } FluTextBoxMenu{ diff --git a/src/Qt6/imports/FluentUI/Controls/FluMultilineTextBox.qml b/src/Qt6/imports/FluentUI/Controls/FluMultilineTextBox.qml index 2d67900a..dad1ac9b 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluMultilineTextBox.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluMultilineTextBox.qml @@ -65,6 +65,7 @@ TextArea{ anchors.fill: parent cursorShape: Qt.IBeamCursor acceptedButtons: Qt.RightButton + visible: !readOnly onClicked: control.echoMode !== TextInput.Password && menu.popup() } FluTextBoxMenu{ diff --git a/src/Qt6/imports/FluentUI/Controls/FluTextBox.qml b/src/Qt6/imports/FluentUI/Controls/FluTextBox.qml index 7a3521a4..395b1d57 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluTextBox.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluTextBox.qml @@ -63,6 +63,7 @@ TextField{ anchors.fill: parent cursorShape: Qt.IBeamCursor acceptedButtons: Qt.RightButton + visible: !readOnly onClicked: control.echoMode !== TextInput.Password && menu.popup() } RowLayout{ diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index 4c7c7c13..4a43568b 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -52,6 +52,7 @@ Window { signal showSystemMenu signal initArgument(var argument) signal firstVisible() + property point _offsetXY : Qt.point(0,0) id:window color:"transparent" Component.onCompleted: { @@ -174,30 +175,12 @@ Window { } Item{ id:layout_container - property int offsetX: { - if(window.visibility === Window.Maximized){ - var dx = window.x-Screen.virtualX - if(dx<0){ - return Math.abs(dx+1) - } - } - return 0 - } - property int offsetY: { - if(window.visibility === Window.Maximized){ - var dy = window.y-Screen.virtualY - if(dy<0){ - return Math.abs(dy+1) - } - } - return 0 - } anchors{ fill:parent - leftMargin: offsetX - rightMargin: offsetX - topMargin: offsetY - bottomMargin: offsetY + leftMargin: _offsetXY.x + rightMargin: _offsetXY.x + topMargin: _offsetXY.y + bottomMargin: _offsetXY.y } onWidthChanged: { window.appBar.width = width