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

@ -35,6 +35,7 @@ endif ()
if (FLUENTUI_BUILD_FRAMELESSHEPLER) if (FLUENTUI_BUILD_FRAMELESSHEPLER)
set(FRAMELESSHELPER_BUILD_STATIC ON) set(FRAMELESSHELPER_BUILD_STATIC ON)
set(FRAMELESSHELPER_NO_DEBUG_OUTPUT ON) set(FRAMELESSHELPER_NO_DEBUG_OUTPUT ON)
set(FRAMELESSHELPER_BUILD_WIDGETS OFF)
add_subdirectory(framelesshelper) add_subdirectory(framelesshelper)
endif () endif ()

View File

@ -160,8 +160,6 @@ target_link_libraries(example PRIVATE
Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Svg
Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Network
fluentuiplugin fluentuiplugin
FramelessHelper::Core
FramelessHelper::Quick
) )
# #

View File

@ -1,64 +1,15 @@
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import org.wangwenx190.FramelessHelper
FluWindow { FluWindow {
id:window id:window
property bool fixSize property bool fixSize
property alias titleVisible: title_bar.titleVisible property bool titleVisible: true
property bool appBarVisible: true property bool appBarVisible: true
default property alias content: container.data
FluAppBar {
id: title_bar
title: window.title
visible: window.appBarVisible
icon:"qrc:/example/res/image/favicon.ico"
anchors {
top: parent.top
left: parent.left
right: parent.right
}
darkText: lang.dark_mode
}
Item{
id:container
anchors{
top: title_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
clip: true
}
FramelessHelper{
id:framless_helper
onReady: {
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()
}
}
Connections{
target: FluTheme
function onDarkChanged(){
if (FluTheme.dark)
FramelessUtils.systemTheme = FramelessHelperConstants.Dark
else
FramelessUtils.systemTheme = FramelessHelperConstants.Light
}
}
function setHitTestVisible(com){ function setHitTestVisible(com){
framless_helper.setHitTestVisible(com)
} }
function setTitleBarItem(com){ function setTitleBarItem(com){
framless_helper.setTitleBarItem(com)
} }
} }

View File

@ -4,7 +4,7 @@ import QtQuick.Layouts
import FluentUI import FluentUI
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
CustomWindow { FluWindow {
id:window id:window
title:"关于" title:"关于"

View File

@ -5,7 +5,7 @@ import FluentUI
import example import example
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
CustomWindow { FluWindow {
id:window id:window
title:"热加载" title:"热加载"

View File

@ -4,7 +4,7 @@ import QtQuick.Controls
import FluentUI import FluentUI
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
CustomWindow { FluWindow {
id:window id:window
title:"登录" title:"登录"

View File

@ -9,7 +9,7 @@ import "qrc:///example/qml/component"
import "qrc:///example/qml/global" import "qrc:///example/qml/global"
import "qrc:///example/qml/viewmodel" import "qrc:///example/qml/viewmodel"
CustomWindow { FluWindow {
id:window id:window
title: "FluentUI" title: "FluentUI"
@ -18,9 +18,10 @@ CustomWindow {
closeDestory:false closeDestory:false
minimumWidth: 520 minimumWidth: 520
minimumHeight: 200 minimumHeight: 200
appBarVisible: false
launchMode: FluWindowType.SingleTask launchMode: FluWindowType.SingleTask
appBar: undefined
SettingsViewModel{ SettingsViewModel{
id:viewmodel_settings id:viewmodel_settings
} }

View File

@ -5,7 +5,7 @@ import FluentUI
import example import example
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
CustomWindow { FluWindow {
id:window id:window
width: 800 width: 800

View File

@ -4,7 +4,7 @@ import QtQuick.Layouts
import FluentUI import FluentUI
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
CustomWindow { FluWindow {
id:window id:window
title:"SingleInstance" title:"SingleInstance"

View File

@ -4,7 +4,7 @@ import QtQuick.Layouts
import FluentUI import FluentUI
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
CustomWindow { FluWindow {
id:window id:window
title:"SingleTask" title:"SingleTask"

View File

@ -4,7 +4,7 @@ import QtQuick.Layouts
import FluentUI import FluentUI
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
CustomWindow { FluWindow {
id:window id:window
title:"Standard" title:"Standard"

View File

@ -6,8 +6,6 @@
#include <QNetworkProxy> #include <QNetworkProxy>
#include <QSslConfiguration> #include <QSslConfiguration>
#include <QProcess> #include <QProcess>
#include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
#include <QtQml/qqmlextensionplugin.h> #include <QtQml/qqmlextensionplugin.h>
#include <QLoggingCategory> #include <QLoggingCategory>
#include "AppInfo.h" #include "AppInfo.h"
@ -23,8 +21,6 @@ Q_IMPORT_QML_PLUGIN(FluentUIPlugin)
#include <FluentUI.h> #include <FluentUI.h>
#endif #endif
FRAMELESSHELPER_USE_NAMESPACE
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy); QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
@ -36,7 +32,6 @@ int main(int argc, char *argv[])
#endif #endif
#endif #endif
qputenv("QT_QUICK_CONTROLS_STYLE","Basic"); qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
FramelessHelper::Quick::initialize();
QGuiApplication::setOrganizationName("ZhuZiChu"); QGuiApplication::setOrganizationName("ZhuZiChu");
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io"); QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
QGuiApplication::setApplicationName("FluentUI"); QGuiApplication::setApplicationName("FluentUI");
@ -51,22 +46,10 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
// QLoggingCategory::setFilterRules(QStringLiteral("qt.scenegraph.general=true")); // QLoggingCategory::setFilterRules(QStringLiteral("qt.scenegraph.general=true"));
// qSetMessagePattern("%{category}: %{message}"); // qSetMessagePattern("%{category}: %{message}");
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
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
AppInfo::getInstance()->init(&engine); AppInfo::getInstance()->init(&engine);
engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance()); engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance());
engine.rootContext()->setContextProperty("SettingsHelper",SettingsHelper::getInstance()); engine.rootContext()->setContextProperty("SettingsHelper",SettingsHelper::getInstance());
FramelessHelper::Quick::registerTypes(&engine);
#ifdef FLUENTUI_BUILD_STATIC_LIB #ifdef FLUENTUI_BUILD_STATIC_LIB
FluentUI::getInstance()->registerTypes(&engine); FluentUI::getInstance()->registerTypes(&engine);
#endif #endif

View File

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

View File

@ -8,6 +8,10 @@
#include <QUuid> #include <QUuid>
#include <QFontDatabase> #include <QFontDatabase>
#include <QClipboard> #include <QClipboard>
#include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
FRAMELESSHELPER_USE_NAMESPACE
FluApp::FluApp(QObject *parent):QObject{parent}{ FluApp::FluApp(QObject *parent):QObject{parent}{
httpInterceptor(nullptr); httpInterceptor(nullptr);
@ -18,6 +22,21 @@ FluApp::~FluApp(){
void FluApp::init(QQuickWindow *window){ void FluApp::init(QQuickWindow *window){
this->_application = 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(){ void FluApp::run(){

View File

@ -2,6 +2,7 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import org.wangwenx190.FramelessHelper
Window { Window {
default property alias content: container.data default property alias content: container.data
@ -9,7 +10,9 @@ Window {
property int launchMode: FluWindowType.Standard property int launchMode: FluWindowType.Standard
property var argument:({}) property var argument:({})
property var background : com_background property var background : com_background
property bool fixSize: false
property Component loadingItem: com_loading property Component loadingItem: com_loading
property var appBar: com_app_bar
property color backgroundColor: { property color backgroundColor: {
if(active){ if(active){
return FluTheme.dark ? Qt.rgba(26/255,34/255,40/255,1) : Qt.rgba(243/255,243/255,243/255,1) 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) signal initArgument(var argument)
property bool showSystemAppBar: true
id:window id:window
color:"transparent" color:"transparent"
Component.onCompleted: { Component.onCompleted: {
@ -49,13 +53,33 @@ Window {
color: window.backgroundColor color: window.backgroundColor
} }
} }
Component{
id:com_app_bar
FluAppBar {
title: window.title
}
}
Loader{ Loader{
anchors.fill: parent anchors.fill: parent
sourceComponent: background sourceComponent: background
} }
Loader{
id: loader_title_bar
anchors {
top: parent.top
left: parent.left
right: parent.right
}
sourceComponent: window.appBar
}
Item{ Item{
id:container id:container
anchors.fill: parent anchors{
top: loader_title_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
clip: true clip: true
} }
Loader{ Loader{
@ -64,10 +88,6 @@ Window {
id:loader_loading id:loader_loading
anchors.fill: container anchors.fill: container
} }
FluInfoBar{
id:infoBar
root: window
}
Component{ Component{
id:com_loading id:com_loading
Popup{ 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{ WindowLifecycle{
id:lifecycle id:lifecycle
} }