This commit is contained in:
朱子楚\zhuzi 2023-04-12 00:15:38 +08:00
parent 2acb3c34bd
commit cd984fddf5
4 changed files with 28 additions and 11 deletions

View File

@ -63,14 +63,14 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
}
properties.insert("argument",argument);
QQuickWindow *view = qobject_cast<QQuickWindow*>(component.createWithInitialProperties(properties));
if(FluTheme::getInstance()->frameless()){
view->setFlag(Qt::FramelessWindowHint,true);
}
wnds.insert(view->winId(),view);
if(fluRegister){
fluRegister->to(view);
}
view->setColor(QColor(Qt::transparent));
if(view->maximumWidth()==view->minimumWidth()&&view->maximumHeight()==view->minimumHeight()){
view->resize(view->minimumSize());
}
view->show();
}

View File

@ -23,16 +23,24 @@ WindowHelper::WindowHelper(QObject *parent)
void WindowHelper::initWindow(QQuickWindow* window){
this->window = window;
}
void WindowHelper::firstUpdate(){
if(isFisrt){
#ifdef Q_OS_WIN
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);
}
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);
}
#endif
isFisrt = false;
}
}
QVariant WindowHelper::createRegister(const QString& path){

View File

@ -18,8 +18,11 @@ public:
Q_INVOKABLE void destoryWindow();
Q_INVOKABLE QVariant createRegister(const QString& path);
Q_INVOKABLE void firstUpdate();
private:
QQuickWindow* window;
bool isFisrt=true;
};
#endif // WINDOWHELPER_H

View File

@ -32,6 +32,12 @@ ApplicationWindow {
clip: true
}
onActiveChanged: {
if(active){
helper.firstUpdate()
}
}
onClosing:
(event)=>{
//