main
朱子楚\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); properties.insert("argument",argument);
QQuickWindow *view = qobject_cast<QQuickWindow*>(component.createWithInitialProperties(properties)); QQuickWindow *view = qobject_cast<QQuickWindow*>(component.createWithInitialProperties(properties));
if(FluTheme::getInstance()->frameless()){
view->setFlag(Qt::FramelessWindowHint,true);
}
wnds.insert(view->winId(),view); wnds.insert(view->winId(),view);
if(fluRegister){ if(fluRegister){
fluRegister->to(view); fluRegister->to(view);
} }
view->setColor(QColor(Qt::transparent)); view->setColor(QColor(Qt::transparent));
if(view->maximumWidth()==view->minimumWidth()&&view->maximumHeight()==view->minimumHeight()){
view->resize(view->minimumSize());
}
view->show(); view->show();
} }

View File

@ -23,6 +23,10 @@ WindowHelper::WindowHelper(QObject *parent)
void WindowHelper::initWindow(QQuickWindow* window){ void WindowHelper::initWindow(QQuickWindow* window){
this->window = window; this->window = window;
}
void WindowHelper::firstUpdate(){
if(isFisrt){
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if(FluTheme::getInstance()->frameless()){ if(FluTheme::getInstance()->frameless()){
HWND wnd = (HWND)window->winId(); HWND wnd = (HWND)window->winId();
@ -31,8 +35,12 @@ void WindowHelper::initWindow(QQuickWindow* window){
DwmExtendFrameIntoClientArea(wnd, &shadow_on); DwmExtendFrameIntoClientArea(wnd, &shadow_on);
SetWindowPos(wnd, Q_NULLPTR, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); SetWindowPos(wnd, Q_NULLPTR, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
ShowWindow(wnd, SW_SHOW); ShowWindow(wnd, SW_SHOW);
window->setFlag(Qt::FramelessWindowHint,false);
} }
#endif #endif
isFisrt = false;
}
} }
QVariant WindowHelper::createRegister(const QString& path){ QVariant WindowHelper::createRegister(const QString& path){

View File

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

View File

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