mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-01-23 04:14:35 +08:00
update
This commit is contained in:
parent
9dd9d10049
commit
d817782526
@ -1,7 +1,7 @@
|
|||||||
#include "FluFramelessHelper.h"
|
#include "FluFramelessHelper.h"
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QOperatingSystemVersion>
|
#include "FluTools.h"
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#pragma comment (lib,"user32.lib")
|
#pragma comment (lib,"user32.lib")
|
||||||
#pragma comment (lib,"dwmapi.lib")
|
#pragma comment (lib,"dwmapi.lib")
|
||||||
@ -104,7 +104,7 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}else if(uMsg == WM_NCHITTEST){
|
}else if(uMsg == WM_NCHITTEST){
|
||||||
if(_helper->hoverMaxBtn() && _helper->resizeable()){
|
if(FluTools::getInstance()->isWindows11OrGreater() && _helper->hoverMaxBtn() && _helper->resizeable()){
|
||||||
if (*result == HTNOWHERE) {
|
if (*result == HTNOWHERE) {
|
||||||
*result = HTZOOM;
|
*result = HTZOOM;
|
||||||
}
|
}
|
||||||
@ -112,14 +112,14 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}else if(uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN){
|
}else if(uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN){
|
||||||
if(_helper->hoverMaxBtn() && _helper->resizeable()){
|
if(FluTools::getInstance()->isWindows11OrGreater() && _helper->hoverMaxBtn() && _helper->resizeable()){
|
||||||
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
||||||
QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
|
QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}else if(uMsg == WM_NCLBUTTONUP || uMsg == WM_NCRBUTTONUP){
|
}else if(uMsg == WM_NCLBUTTONUP || uMsg == WM_NCRBUTTONUP){
|
||||||
if(_helper->hoverMaxBtn() && _helper->resizeable()){
|
if(FluTools::getInstance()->isWindows11OrGreater() && _helper->hoverMaxBtn() && _helper->resizeable()){
|
||||||
QMouseEvent event = QMouseEvent(QEvent::MouseButtonRelease, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
QMouseEvent event = QMouseEvent(QEvent::MouseButtonRelease, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
||||||
QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
|
QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ void FluFramelessHelper::showSystemMenu(){
|
|||||||
}else{
|
}else{
|
||||||
EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_DISABLED);
|
EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_DISABLED);
|
||||||
}
|
}
|
||||||
const int result = TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), point.x(), point.y(), 0, hwnd, nullptr);
|
const int result = TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), point.x()*window->devicePixelRatio(), point.y()*window->devicePixelRatio(), 0, hwnd, nullptr);
|
||||||
if (result != FALSE) {
|
if (result != FALSE) {
|
||||||
PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
FluTools::FluTools(QObject *parent):QObject{parent}{
|
FluTools::FluTools(QObject *parent):QObject{parent}{
|
||||||
|
|
||||||
@ -194,3 +195,23 @@ int FluTools::cursorScreenIndex(){
|
|||||||
}
|
}
|
||||||
return screenIndex;
|
return screenIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FluTools::isWindows11OrGreater(){
|
||||||
|
static QVariant var;
|
||||||
|
if(var.isNull()){
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
QSettings regKey {QString::fromUtf8("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), QSettings::NativeFormat};
|
||||||
|
if (regKey.contains(QString::fromUtf8("CurrentBuildNumber"))) {
|
||||||
|
auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt();
|
||||||
|
if(buildNumber>=22000){
|
||||||
|
var = QVariant::fromValue(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
var = QVariant::fromValue(false);
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return var.toBool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -51,6 +51,7 @@ public:
|
|||||||
Q_INVOKABLE QPoint cursorPos();
|
Q_INVOKABLE QPoint cursorPos();
|
||||||
Q_INVOKABLE QIcon windowIcon();
|
Q_INVOKABLE QIcon windowIcon();
|
||||||
Q_INVOKABLE int cursorScreenIndex();
|
Q_INVOKABLE int cursorScreenIndex();
|
||||||
|
Q_INVOKABLE bool isWindows11OrGreater();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUTOOLS_H
|
#endif // FLUTOOLS_H
|
||||||
|
@ -233,7 +233,7 @@ Rectangle{
|
|||||||
if(pressed){
|
if(pressed){
|
||||||
return maximizePressColor
|
return maximizePressColor
|
||||||
}
|
}
|
||||||
if(FluTools.isWin() && !FluApp.useSystemAppBar){
|
if(FluTools.isWindows11OrGreater()){
|
||||||
return d.hoverMaxBtn ? maximizeHoverColor : maximizeNormalColor
|
return d.hoverMaxBtn ? maximizeHoverColor : maximizeNormalColor
|
||||||
}
|
}
|
||||||
return hovered ? maximizeHoverColor : maximizeNormalColor
|
return hovered ? maximizeHoverColor : maximizeNormalColor
|
||||||
@ -286,7 +286,7 @@ Rectangle{
|
|||||||
var pos = btn_maximize.mapToGlobal(0,0)
|
var pos = btn_maximize.mapToGlobal(0,0)
|
||||||
if(btn_maximize.visible){
|
if(btn_maximize.visible){
|
||||||
var rect = Qt.rect(pos.x,pos.y,btn_maximize.width,btn_maximize.height)
|
var rect = Qt.rect(pos.x,pos.y,btn_maximize.width,btn_maximize.height)
|
||||||
pos = FluTools.cursorPos()
|
pos = FluTools.cursorPos()
|
||||||
if(pos.x>rect.x && pos.x<(rect.x+rect.width) && pos.y>rect.y && pos.y<(rect.y+rect.height)){
|
if(pos.x>rect.x && pos.x<(rect.x+rect.width) && pos.y>rect.y && pos.y<(rect.y+rect.height)){
|
||||||
hover = true;
|
hover = true;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ Rectangle{
|
|||||||
if(pressed){
|
if(pressed){
|
||||||
return maximizePressColor
|
return maximizePressColor
|
||||||
}
|
}
|
||||||
if(FluTools.isWin() && !FluApp.useSystemAppBar){
|
if(FluTools.isWindows11OrGreater()){
|
||||||
return d.hoverMaxBtn ? maximizeHoverColor : maximizeNormalColor
|
return d.hoverMaxBtn ? maximizeHoverColor : maximizeNormalColor
|
||||||
}
|
}
|
||||||
return hovered ? maximizeHoverColor : maximizeNormalColor
|
return hovered ? maximizeHoverColor : maximizeNormalColor
|
||||||
@ -286,7 +286,7 @@ Rectangle{
|
|||||||
var pos = btn_maximize.mapToGlobal(0,0)
|
var pos = btn_maximize.mapToGlobal(0,0)
|
||||||
if(btn_maximize.visible){
|
if(btn_maximize.visible){
|
||||||
var rect = Qt.rect(pos.x,pos.y,btn_maximize.width,btn_maximize.height)
|
var rect = Qt.rect(pos.x,pos.y,btn_maximize.width,btn_maximize.height)
|
||||||
pos = FluTools.cursorPos()
|
pos = FluTools.cursorPos()
|
||||||
if(pos.x>rect.x && pos.x<(rect.x+rect.width) && pos.y>rect.y && pos.y<(rect.y+rect.height)){
|
if(pos.x>rect.x && pos.x<(rect.x+rect.width) && pos.y>rect.y && pos.y<(rect.y+rect.height)){
|
||||||
hover = true;
|
hover = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user