This commit is contained in:
zhuzichu
2023-10-08 18:19:08 +08:00
parent e631465231
commit 29f363afdd
15 changed files with 90 additions and 84 deletions

View File

@ -129,6 +129,8 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::QuickPrivate
Qt${QT_VERSION_MAJOR}::QmlPrivate
ZXing
FramelessHelper::Core
FramelessHelper::Quick
)
#安装

View File

@ -8,6 +8,10 @@
#include <QUuid>
#include <QFontDatabase>
#include <QClipboard>
#include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
FRAMELESSHELPER_USE_NAMESPACE
FluApp::FluApp(QObject *parent):QObject{parent}{
httpInterceptor(nullptr);
@ -18,6 +22,21 @@ FluApp::~FluApp(){
void FluApp::init(QQuickWindow *window){
this->_application = window;
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
FramelessHelper::Quick::initialize();
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
#ifdef Q_OS_WIN
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,false);
#endif
#ifdef Q_OS_MACOS
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false);
#endif
QQmlEngine *engine = qmlEngine(_application);
FramelessHelper::Quick::registerTypes(engine);
}
void FluApp::run(){

View File

@ -2,6 +2,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import FluentUI
import org.wangwenx190.FramelessHelper
Window {
default property alias content: container.data
@ -9,7 +10,9 @@ Window {
property int launchMode: FluWindowType.Standard
property var argument:({})
property var background : com_background
property bool fixSize: false
property Component loadingItem: com_loading
property var appBar: com_app_bar
property color backgroundColor: {
if(active){
return FluTheme.dark ? Qt.rgba(26/255,34/255,40/255,1) : Qt.rgba(243/255,243/255,243/255,1)
@ -27,6 +30,7 @@ Window {
}
}
signal initArgument(var argument)
property bool showSystemAppBar: true
id:window
color:"transparent"
Component.onCompleted: {
@ -49,13 +53,33 @@ Window {
color: window.backgroundColor
}
}
Component{
id:com_app_bar
FluAppBar {
title: window.title
}
}
Loader{
anchors.fill: parent
sourceComponent: background
}
Loader{
id: loader_title_bar
anchors {
top: parent.top
left: parent.left
right: parent.right
}
sourceComponent: window.appBar
}
Item{
id:container
anchors.fill: parent
anchors{
top: loader_title_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
clip: true
}
Loader{
@ -64,10 +88,6 @@ Window {
id:loader_loading
anchors.fill: container
}
FluInfoBar{
id:infoBar
root: window
}
Component{
id:com_loading
Popup{
@ -131,6 +151,37 @@ Window {
}
}
}
FluInfoBar{
id:infoBar
root: window
}
Connections{
target: FluTheme
function onDarkChanged(){
if (FluTheme.dark)
FramelessUtils.systemTheme = FramelessHelperConstants.Dark
else
FramelessUtils.systemTheme = FramelessHelperConstants.Light
}
}
FramelessHelper{
id:framless_helper
onReady: {
if(appBar && !showSystemAppBar){
var title_bar = loader_title_bar.item
setTitleBarItem(title_bar)
moveWindowToDesktopCenter()
setHitTestVisible(title_bar.minimizeButton())
setHitTestVisible(title_bar.maximizeButton())
setHitTestVisible(title_bar.closeButton())
setWindowFixedSize(fixSize)
title_bar.maximizeButton.visible = !fixSize
if (blurBehindWindowEnabled)
window.background = undefined
}
window.show()
}
}
WindowLifecycle{
id:lifecycle
}