mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-01-23 04:14:35 +08:00
update
This commit is contained in:
parent
2f1689acd0
commit
eb276e7179
@ -184,7 +184,14 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
return false;
|
return false;
|
||||||
}else if(uMsg == WM_NCRBUTTONDOWN){
|
}else if(uMsg == WM_NCRBUTTONDOWN){
|
||||||
if (wParam == HTCAPTION) {
|
if (wParam == HTCAPTION) {
|
||||||
_helper->showSystemMenu();
|
_helper->showSystemMenu(QCursor::pos());
|
||||||
|
}
|
||||||
|
}else if(uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN){
|
||||||
|
const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0));
|
||||||
|
const bool spacePressed = ((wParam == VK_SPACE) || (::GetKeyState(VK_SPACE) < 0));
|
||||||
|
if (altPressed && spacePressed) {
|
||||||
|
auto pos = _helper->window->position();
|
||||||
|
_helper->showSystemMenu(QPoint(pos.x(),pos.y()+_helper->getAppBarHeight()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -306,7 +313,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);
|
window->setFlags((window->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
|
||||||
_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());
|
||||||
@ -336,7 +343,9 @@ void FluFramelessHelper::componentComplete(){
|
|||||||
#endif
|
#endif
|
||||||
int w = _realWidth.read().toInt();
|
int w = _realWidth.read().toInt();
|
||||||
int h = _realHeight.read().toInt()+_appBarHeight.read().toInt();
|
int h = _realHeight.read().toInt()+_appBarHeight.read().toInt();
|
||||||
if(!resizeable()){
|
if(resizeable()){
|
||||||
|
window->setFlag(Qt::WindowMaximizeButtonHint);
|
||||||
|
}else{
|
||||||
window->setMaximumSize(QSize(w,h));
|
window->setMaximumSize(QSize(w,h));
|
||||||
window->setMinimumSize(QSize(w,h));
|
window->setMinimumSize(QSize(w,h));
|
||||||
}
|
}
|
||||||
@ -357,9 +366,8 @@ void FluFramelessHelper::_onScreenChanged(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluFramelessHelper::showSystemMenu(){
|
void FluFramelessHelper::showSystemMenu(QPoint point){
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QPoint point = QCursor::pos();
|
|
||||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||||
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
|
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
|
||||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
|
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
|
||||||
@ -439,6 +447,17 @@ QVariant FluFramelessHelper::getAppBar(){
|
|||||||
return _appBar;
|
return _appBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FluFramelessHelper::getAppBarHeight(){
|
||||||
|
if(_appBar.isNull()){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
QVariant var = _appBar.value<QObject*>()->property("height");
|
||||||
|
if(var.isNull()){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return var.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
QObject* FluFramelessHelper::maximizeButton(){
|
QObject* FluFramelessHelper::maximizeButton(){
|
||||||
if(_appBar.isNull()){
|
if(_appBar.isNull()){
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -49,10 +49,11 @@ public:
|
|||||||
int getMargins();
|
int getMargins();
|
||||||
bool maximized();
|
bool maximized();
|
||||||
bool fullScreen();
|
bool fullScreen();
|
||||||
|
int getAppBarHeight();
|
||||||
QVariant getAppBar();
|
QVariant getAppBar();
|
||||||
QObject* maximizeButton();
|
QObject* maximizeButton();
|
||||||
void setOriginalPos(QVariant pos);
|
void setOriginalPos(QVariant pos);
|
||||||
Q_INVOKABLE void showSystemMenu();
|
Q_INVOKABLE void showSystemMenu(QPoint point);
|
||||||
Q_SIGNAL void loadCompleted();
|
Q_SIGNAL void loadCompleted();
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user