2023-02-27 18:46:39 +08:00
|
|
|
|
#include "WindowHelper.h"
|
|
|
|
|
|
2023-03-13 21:18:51 +08:00
|
|
|
|
#include "FluRegister.h"
|
2023-04-11 23:12:31 +08:00
|
|
|
|
#include "FluApp.h"
|
|
|
|
|
#include "FluTheme.h"
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
#include <dwmapi.h>
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#include <windowsx.h>
|
|
|
|
|
enum class Style : DWORD
|
|
|
|
|
{
|
|
|
|
|
windowed = (WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CLIPCHILDREN),
|
|
|
|
|
aero_borderless = (WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CLIPCHILDREN)
|
|
|
|
|
};
|
|
|
|
|
#endif
|
2023-03-13 21:18:51 +08:00
|
|
|
|
|
2023-02-27 18:46:39 +08:00
|
|
|
|
WindowHelper::WindowHelper(QObject *parent)
|
|
|
|
|
: QObject{parent}
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-11 23:12:31 +08:00
|
|
|
|
void WindowHelper::initWindow(QQuickWindow* window){
|
2023-02-27 23:04:52 +08:00
|
|
|
|
this->window = window;
|
2023-04-12 00:15:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WindowHelper::firstUpdate(){
|
|
|
|
|
if(isFisrt){
|
2023-04-11 23:12:31 +08:00
|
|
|
|
#ifdef Q_OS_WIN
|
2023-04-12 00:15:38 +08:00
|
|
|
|
if(FluTheme::getInstance()->frameless()){
|
|
|
|
|
HWND wnd = (HWND)window->winId();
|
|
|
|
|
SetWindowLongPtr(wnd, GWL_STYLE, static_cast<LONG>(Style::aero_borderless));
|
|
|
|
|
const MARGINS shadow_on = { 1, 1, 1, 1 };
|
|
|
|
|
DwmExtendFrameIntoClientArea(wnd, &shadow_on);
|
|
|
|
|
SetWindowPos(wnd, Q_NULLPTR, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
|
|
|
|
|
ShowWindow(wnd, SW_SHOW);
|
|
|
|
|
window->setFlag(Qt::FramelessWindowHint,false);
|
|
|
|
|
}
|
2023-04-11 23:12:31 +08:00
|
|
|
|
#endif
|
2023-04-12 00:15:38 +08:00
|
|
|
|
isFisrt = false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-13 18:23:46 +08:00
|
|
|
|
}
|
2023-03-13 21:18:51 +08:00
|
|
|
|
|
2023-04-15 09:45:54 +08:00
|
|
|
|
QVariant WindowHelper::createRegister(QQuickWindow* window,const QString& path){
|
|
|
|
|
FluRegister *p = new FluRegister(window);
|
|
|
|
|
p->from(window);
|
2023-03-13 21:18:51 +08:00
|
|
|
|
p->path(path);
|
|
|
|
|
return QVariant::fromValue(p);
|
|
|
|
|
}
|
2023-04-11 23:12:31 +08:00
|
|
|
|
|
|
|
|
|
void WindowHelper::destoryWindow(){
|
|
|
|
|
if(this->window){
|
|
|
|
|
FluApp::getInstance()->wnds.remove(this->window->winId());
|
|
|
|
|
this->window->deleteLater();
|
|
|
|
|
}
|
|
|
|
|
}
|