mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 03:10:10 +08:00
fix bug #455
This commit is contained in:
parent
d79a7df389
commit
38a277801d
@ -72,10 +72,8 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
||||||
const LONG originalTop = clientRect->top;
|
const LONG originalTop = clientRect->top;
|
||||||
const LONG originalLeft = clientRect->left;
|
const LONG originalLeft = clientRect->left;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
|
||||||
const LONG originalRight = clientRect->right;
|
const LONG originalRight = clientRect->right;
|
||||||
const LONG originalBottom = clientRect->bottom;
|
const LONG originalBottom = clientRect->bottom;
|
||||||
#endif
|
|
||||||
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
|
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
|
||||||
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
|
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
|
||||||
*result = hitTestResult;
|
*result = hitTestResult;
|
||||||
@ -85,23 +83,19 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
bool isMaximum = ::IsZoomed(hwnd);
|
bool isMaximum = ::IsZoomed(hwnd);
|
||||||
offsetXY = QPoint(abs(clientRect->left - originalLeft),abs(clientRect->top - originalTop));
|
offsetXY = QPoint(abs(clientRect->left - originalLeft),abs(clientRect->top - originalTop));
|
||||||
if(isMaximum || _helper->fullScreen()){
|
if(isMaximum || _helper->fullScreen()){
|
||||||
_helper->setOriginalPos(QPoint(originalLeft,originalTop));
|
|
||||||
offsetSize = 0;
|
offsetSize = 0;
|
||||||
}else{
|
}else{
|
||||||
_helper->setOriginalPos({});
|
|
||||||
offsetSize = 1;
|
offsetSize = 1;
|
||||||
}
|
}
|
||||||
if(!isCompositionEnabled()){
|
if(!isCompositionEnabled()){
|
||||||
offsetSize = 0;
|
offsetSize = 0;
|
||||||
}
|
}
|
||||||
clientRect->top = originalTop+offsetSize;
|
if (!isMaximum || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) {
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
clientRect->top = originalTop + offsetSize;
|
||||||
if(!isMaximum){
|
clientRect->bottom = originalBottom - offsetSize;
|
||||||
clientRect->bottom = originalBottom-offsetSize;
|
clientRect->left = originalLeft + offsetSize;
|
||||||
clientRect->left = originalLeft+offsetSize;
|
clientRect->right = originalRight - offsetSize;
|
||||||
clientRect->right = originalRight-offsetSize;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
*result = WVR_REDRAW;
|
*result = WVR_REDRAW;
|
||||||
return true;
|
return true;
|
||||||
}if(uMsg == WM_NCHITTEST){
|
}if(uMsg == WM_NCHITTEST){
|
||||||
@ -172,13 +166,11 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
*result = ::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
|
*result = ::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
|
||||||
return true;
|
return true;
|
||||||
}else if(uMsg == WM_GETMINMAXINFO){
|
}else if(uMsg == WM_GETMINMAXINFO){
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6,2,4)
|
|
||||||
MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
||||||
auto pixelRatio = _helper->window->devicePixelRatio();
|
auto pixelRatio = _helper->window->devicePixelRatio();
|
||||||
auto geometry = _helper->window->screen()->availableGeometry();
|
auto geometry = _helper->window->screen()->availableGeometry();
|
||||||
minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x()*2;
|
minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2;
|
||||||
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y()*2;
|
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2;
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}else if(uMsg == WM_NCRBUTTONDOWN){
|
}else if(uMsg == WM_NCRBUTTONDOWN){
|
||||||
if (wParam == HTCAPTION) {
|
if (wParam == HTCAPTION) {
|
||||||
@ -302,7 +294,6 @@ void FluFramelessHelper::componentComplete(){
|
|||||||
_stayTop = QQmlProperty(window,"stayTop");
|
_stayTop = QQmlProperty(window,"stayTop");
|
||||||
_screen = QQmlProperty(window,"screen");
|
_screen = QQmlProperty(window,"screen");
|
||||||
_fixSize = QQmlProperty(window,"fixSize");
|
_fixSize = QQmlProperty(window,"fixSize");
|
||||||
_originalPos = QQmlProperty(window,"_originalPos");
|
|
||||||
_realHeight = QQmlProperty(window,"_realHeight");
|
_realHeight = QQmlProperty(window,"_realHeight");
|
||||||
_realWidth = QQmlProperty(window,"_realWidth");
|
_realWidth = QQmlProperty(window,"_realWidth");
|
||||||
_appBarHeight = QQmlProperty(window,"_appBarHeight");
|
_appBarHeight = QQmlProperty(window,"_appBarHeight");
|
||||||
@ -311,7 +302,7 @@ void FluFramelessHelper::componentComplete(){
|
|||||||
if(!_appBar.isNull()){
|
if(!_appBar.isNull()){
|
||||||
_appBar.value<QObject*>()->setProperty("systemMoveEnable",false);
|
_appBar.value<QObject*>()->setProperty("systemMoveEnable",false);
|
||||||
}
|
}
|
||||||
window->setFlags((window->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
|
window->setFlags((window->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
|
||||||
if(resizeable()){
|
if(resizeable()){
|
||||||
window->setFlag(Qt::WindowMaximizeButtonHint);
|
window->setFlag(Qt::WindowMaximizeButtonHint);
|
||||||
}
|
}
|
||||||
@ -324,9 +315,6 @@ void FluFramelessHelper::componentComplete(){
|
|||||||
}else{
|
}else{
|
||||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
|
||||||
}
|
}
|
||||||
LONG exstyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
|
||||||
exstyle = exstyle | 0x02000000;
|
|
||||||
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, exstyle);
|
|
||||||
#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);
|
||||||
window->installEventFilter(this);
|
window->installEventFilter(this);
|
||||||
@ -382,6 +370,13 @@ void FluFramelessHelper::showSystemMenu(QPoint point){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FluFramelessHelper::showMaximized(){
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||||
|
::ShowWindow(hwnd,3);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void FluFramelessHelper::_onStayTopChange(){
|
void FluFramelessHelper::_onStayTopChange(){
|
||||||
bool isStayTop = _stayTop.read().toBool();
|
bool isStayTop = _stayTop.read().toBool();
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@ -457,10 +452,6 @@ 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 !_fixSize.read().toBool();
|
return !_fixSize.read().toBool();
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
QObject* maximizeButton();
|
QObject* maximizeButton();
|
||||||
void setOriginalPos(QVariant pos);
|
void setOriginalPos(QVariant pos);
|
||||||
Q_INVOKABLE void showSystemMenu(QPoint point);
|
Q_INVOKABLE void showSystemMenu(QPoint point);
|
||||||
|
Q_INVOKABLE void showMaximized();
|
||||||
Q_SIGNAL void loadCompleted();
|
Q_SIGNAL void loadCompleted();
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
@ -67,7 +68,6 @@ private:
|
|||||||
FramelessEventFilter* _nativeEvent = nullptr;
|
FramelessEventFilter* _nativeEvent = nullptr;
|
||||||
QQmlProperty _stayTop;
|
QQmlProperty _stayTop;
|
||||||
QQmlProperty _screen;
|
QQmlProperty _screen;
|
||||||
QQmlProperty _originalPos;
|
|
||||||
QQmlProperty _fixSize;
|
QQmlProperty _fixSize;
|
||||||
QQmlProperty _realHeight;
|
QQmlProperty _realHeight;
|
||||||
QQmlProperty _realWidth;
|
QQmlProperty _realWidth;
|
||||||
|
@ -37,19 +37,19 @@ Rectangle{
|
|||||||
property var maxClickListener : function(){
|
property var maxClickListener : function(){
|
||||||
if(FluTools.isMacos()){
|
if(FluTools.isMacos()){
|
||||||
if (d.win.visibility === Window.FullScreen)
|
if (d.win.visibility === Window.FullScreen)
|
||||||
d.win.visibility = Window.Windowed
|
d.win.showNormal()
|
||||||
else
|
else
|
||||||
d.win.visibility = Window.FullScreen
|
d.win.showFullScreen()
|
||||||
}else{
|
}else{
|
||||||
if (d.win.visibility === Window.Maximized)
|
if (d.win.visibility === Window.Maximized)
|
||||||
d.win.visibility = Window.Windowed
|
d.win.showNormal()
|
||||||
else
|
else
|
||||||
d.win.visibility = Window.Maximized
|
d.win.showMaximized()
|
||||||
d.hoverMaxBtn = false
|
d.hoverMaxBtn = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
property var minClickListener: function(){
|
property var minClickListener: function(){
|
||||||
d.win.visibility = Window.Minimized
|
d.win.showMinimized()
|
||||||
}
|
}
|
||||||
property var closeClickListener : function(){
|
property var closeClickListener : function(){
|
||||||
d.win.close()
|
d.win.close()
|
||||||
|
@ -58,8 +58,6 @@ Window {
|
|||||||
signal showSystemMenu
|
signal showSystemMenu
|
||||||
signal initArgument(var argument)
|
signal initArgument(var argument)
|
||||||
signal firstVisible()
|
signal firstVisible()
|
||||||
property point _offsetXY : Qt.point(0,0)
|
|
||||||
property var _originalPos
|
|
||||||
property int _realHeight
|
property int _realHeight
|
||||||
property int _realWidth
|
property int _realWidth
|
||||||
property int _appBarHeight: appBar.height
|
property int _appBarHeight: appBar.height
|
||||||
@ -91,19 +89,6 @@ Window {
|
|||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
lifecycle.onDestruction()
|
lifecycle.onDestruction()
|
||||||
}
|
}
|
||||||
on_OriginalPosChanged: {
|
|
||||||
if(_originalPos){
|
|
||||||
var dx = (_originalPos.x - screen.virtualX)/screen.devicePixelRatio
|
|
||||||
var dy = (_originalPos.y - screen.virtualY)/screen.devicePixelRatio
|
|
||||||
if(dx<0 && dy<0){
|
|
||||||
_offsetXY = Qt.point(Math.abs(dx)-1,Math.abs(dy)-1)
|
|
||||||
}else{
|
|
||||||
_offsetXY = Qt.point(0,0)
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
_offsetXY = Qt.point(0,0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onShowSystemMenu: {
|
onShowSystemMenu: {
|
||||||
if(loader_frameless_helper.item){
|
if(loader_frameless_helper.item){
|
||||||
loader_frameless_helper.item.showSystemMenu()
|
loader_frameless_helper.item.showSystemMenu()
|
||||||
@ -223,7 +208,6 @@ Window {
|
|||||||
id:layout_container
|
id:layout_container
|
||||||
anchors{
|
anchors{
|
||||||
fill:parent
|
fill:parent
|
||||||
topMargin: _offsetXY.y
|
|
||||||
}
|
}
|
||||||
onWidthChanged: {
|
onWidthChanged: {
|
||||||
window.appBar.width = width
|
window.appBar.width = width
|
||||||
@ -337,4 +321,13 @@ Window {
|
|||||||
function layoutContent(){
|
function layoutContent(){
|
||||||
return layout_content
|
return layout_content
|
||||||
}
|
}
|
||||||
|
function showMaximized(){
|
||||||
|
if(FluTools.isWin()){
|
||||||
|
if(loader_frameless_helper.item){
|
||||||
|
loader_frameless_helper.item.showMaximized()
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
window.visibility = Qt.WindowMaximized
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,19 +37,19 @@ Rectangle{
|
|||||||
property var maxClickListener : function(){
|
property var maxClickListener : function(){
|
||||||
if(FluTools.isMacos()){
|
if(FluTools.isMacos()){
|
||||||
if (d.win.visibility === Window.FullScreen)
|
if (d.win.visibility === Window.FullScreen)
|
||||||
d.win.visibility = Window.Windowed
|
d.win.showNormal()
|
||||||
else
|
else
|
||||||
d.win.visibility = Window.FullScreen
|
d.win.showFullScreen()
|
||||||
}else{
|
}else{
|
||||||
if (d.win.visibility === Window.Maximized)
|
if (d.win.visibility === Window.Maximized)
|
||||||
d.win.visibility = Window.Windowed
|
d.win.showNormal()
|
||||||
else
|
else
|
||||||
d.win.visibility = Window.Maximized
|
d.win.showMaximized()
|
||||||
d.hoverMaxBtn = false
|
d.hoverMaxBtn = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
property var minClickListener: function(){
|
property var minClickListener: function(){
|
||||||
d.win.visibility = Window.Minimized
|
d.win.showMinimized()
|
||||||
}
|
}
|
||||||
property var closeClickListener : function(){
|
property var closeClickListener : function(){
|
||||||
d.win.close()
|
d.win.close()
|
||||||
|
@ -57,8 +57,6 @@ Window {
|
|||||||
signal showSystemMenu
|
signal showSystemMenu
|
||||||
signal initArgument(var argument)
|
signal initArgument(var argument)
|
||||||
signal firstVisible()
|
signal firstVisible()
|
||||||
property point _offsetXY : Qt.point(0,0)
|
|
||||||
property var _originalPos
|
|
||||||
property int _realHeight
|
property int _realHeight
|
||||||
property int _realWidth
|
property int _realWidth
|
||||||
property int _appBarHeight: appBar.height
|
property int _appBarHeight: appBar.height
|
||||||
@ -90,19 +88,6 @@ Window {
|
|||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
lifecycle.onDestruction()
|
lifecycle.onDestruction()
|
||||||
}
|
}
|
||||||
on_OriginalPosChanged: {
|
|
||||||
if(_originalPos){
|
|
||||||
var dx = (_originalPos.x - screen.virtualX)/screen.devicePixelRatio
|
|
||||||
var dy = (_originalPos.y - screen.virtualY)/screen.devicePixelRatio
|
|
||||||
if(dx<0 && dy<0){
|
|
||||||
_offsetXY = Qt.point(Math.abs(dx)-1,Math.abs(dy)-1)
|
|
||||||
}else{
|
|
||||||
_offsetXY = Qt.point(0,0)
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
_offsetXY = Qt.point(0,0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onShowSystemMenu: {
|
onShowSystemMenu: {
|
||||||
if(loader_frameless_helper.item){
|
if(loader_frameless_helper.item){
|
||||||
loader_frameless_helper.item.showSystemMenu()
|
loader_frameless_helper.item.showSystemMenu()
|
||||||
@ -222,7 +207,6 @@ Window {
|
|||||||
id:layout_container
|
id:layout_container
|
||||||
anchors{
|
anchors{
|
||||||
fill:parent
|
fill:parent
|
||||||
topMargin: _offsetXY.y
|
|
||||||
}
|
}
|
||||||
onWidthChanged: {
|
onWidthChanged: {
|
||||||
window.appBar.width = width
|
window.appBar.width = width
|
||||||
@ -336,4 +320,13 @@ Window {
|
|||||||
function layoutContent(){
|
function layoutContent(){
|
||||||
return layout_content
|
return layout_content
|
||||||
}
|
}
|
||||||
|
function showMaximized(){
|
||||||
|
if(FluTools.isWin()){
|
||||||
|
if(loader_frameless_helper.item){
|
||||||
|
loader_frameless_helper.item.showMaximized()
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
window.visibility = Qt.WindowMaximized
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user