main
朱子楚\zhuzi 2023-05-19 07:57:23 +08:00
parent 2129301cd2
commit 15f90471dc
17 changed files with 108 additions and 165 deletions

View File

@ -90,18 +90,12 @@ set_target_properties(example PROPERTIES
WIN32_EXECUTABLE TRUE WIN32_EXECUTABLE TRUE
) )
# #
target_link_libraries(example PRIVATE target_link_libraries(example PRIVATE
Qt6::Quick Qt6::Quick
fluentuiplugin fluentuiplugin
) FramelessHelper::Core
FramelessHelper::Quick
#
set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI)
target_include_directories(
example PRIVATE
${QML_PLUGIN_DIRECTORY}
) )
# #

View File

@ -0,0 +1,60 @@
import QtQuick
import QtQuick.Layouts
import FluentUI
import org.wangwenx190.FramelessHelper
FluWindow {
id:window
property bool fixSize
property alias titleVisible: title_bar.titleVisible
property bool appBarVisible: true
default property alias content: container.data
FluAppBar {
id: title_bar
title: window.title
visible: window.appBarVisible
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)
framless_helper.moveWindowToDesktopCenter()
setHitTestVisible(title_bar.minimizeButton())
setHitTestVisible(title_bar.maximizeButton())
setHitTestVisible(title_bar.closeButton())
framless_helper.setWindowFixedSize(fixSize)
title_bar.maximizeButton.visible = !fixSize
window.visible = true
}
}
function setHitTestVisible(com){
framless_helper.setHitTestVisible(com)
}
function setTitleBarItem(com){
framless_helper.setTitleBarItem(com)
}
}

View File

@ -2,8 +2,9 @@
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import "../component"
FluWindow { CustomWindow {
id:window id:window
title:"关于" title:"关于"

View File

@ -2,8 +2,9 @@
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Controls import QtQuick.Controls
import FluentUI import FluentUI
import "../component"
FluWindow { CustomWindow {
id:window id:window
title:"登录" title:"登录"

View File

@ -4,9 +4,10 @@ import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import Qt.labs.platform import Qt.labs.platform
import FluentUI import FluentUI
import "../component"
import "qrc:///example/qml/global/" import "qrc:///example/qml/global/"
FluWindow { CustomWindow {
id:window id:window
title: "FluentUI" title: "FluentUI"
@ -97,7 +98,7 @@ FluWindow {
z:999 z:999
items: ItemsOriginal items: ItemsOriginal
footerItems:ItemsFooter footerItems:ItemsFooter
topPadding:FluTools.isMacos() ? 20 : 5 topPadding:Qt.platform.os === FluTools.isMacos() ? 20 : 5
displayMode:MainEvent.displayMode displayMode:MainEvent.displayMode
logo: "qrc:/example/res/image/favicon.ico" logo: "qrc:/example/res/image/favicon.ico"
title:"FluentUI" title:"FluentUI"

View File

@ -2,8 +2,9 @@
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import "../component"
FluWindow { CustomWindow {
title:"视频播放器" title:"视频播放器"
width: 640 width: 640

View File

@ -2,8 +2,9 @@
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import "../component"
FluWindow { CustomWindow {
id:window id:window
title:"SingleInstance" title:"SingleInstance"

View File

@ -2,8 +2,9 @@
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import "../component"
FluWindow { CustomWindow {
id:window id:window
title:"SingleTask" title:"SingleTask"

View File

@ -2,8 +2,9 @@
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import "../component"
FluWindow { CustomWindow {
id:window id:window
title:"Standard" title:"Standard"

View File

@ -4,20 +4,23 @@
#include <QDir> #include <QDir>
#include <QQuickWindow> #include <QQuickWindow>
#include <QProcess> #include <QProcess>
#include <FluGlobal.h> #include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
#include "lang/Lang.h" #include "lang/Lang.h"
#include "AppInfo.h" #include "AppInfo.h"
#include "tool/IPC.h" #include "tool/IPC.h"
FRAMELESSHELPER_USE_NAMESPACE
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
FluentUI::preInit(); //将样式设置为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");
// QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
FluentUI::postInit();
AppInfo* appInfo = new AppInfo(); AppInfo* appInfo = new AppInfo();
IPC ipc(0); IPC ipc(0);
QString activeWindowEvent = "activeWindow"; QString activeWindowEvent = "activeWindow";
@ -34,7 +37,7 @@ int main(int argc, char *argv[])
} }
app.setQuitOnLastWindowClosed(false); app.setQuitOnLastWindowClosed(false);
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
FluentUI::initEngine(&engine); FramelessHelper::Quick::registerTypes(&engine);
QQmlContext * context = engine.rootContext(); QQmlContext * context = engine.rootContext();
Lang* lang = appInfo->lang(); Lang* lang = appInfo->lang();
context->setContextProperty("lang",lang); context->setContextProperty("lang",lang);

View File

@ -54,11 +54,9 @@ qt_add_qml_module(fluentuiplugin
URI "FluentUI" URI "FluentUI"
SOURCES ${sources_files} fluentui.rc SOURCES ${sources_files} fluentui.rc
QML_FILES ${qml_files} QML_FILES ${qml_files}
RESOURCES ${resource_files} FluGlobal.h RESOURCES ${resource_files}
#designer #designer
DESIGNER_SUPPORTED DESIGNER_SUPPORTED
DEPENDENCIES
org.wangwenx190.FramelessHelper/auto
) )
# #
@ -66,8 +64,6 @@ target_link_libraries(fluentuiplugin PUBLIC
Qt::CorePrivate Qt::CorePrivate
Qt::QuickPrivate Qt::QuickPrivate
Qt::QmlPrivate Qt::QmlPrivate
FramelessHelper::Core
FramelessHelper::Quick
) )
# win32 mingw # win32 mingw

View File

@ -1,29 +0,0 @@
#include "FluGlobal.h"
#include<QDebug>
#include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
FRAMELESSHELPER_USE_NAMESPACE;
namespace FluentUI {
void preInit(){
qDebug()<<"preInit";
FramelessHelper::Quick::initialize();
//将样式设置为Basic不然会导致组件显示异常
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
}
void postInit(){
qDebug()<<"postInit";
FramelessHelper::Core::setApplicationOSThemeAware();
// FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
// FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
}
void initEngine(QQmlApplicationEngine* engine){
qDebug()<<"initEngine";
FramelessHelper::Quick::registerTypes(engine);
qDebug()<<"FramelessHelper::Quick::registerTypes(engine)";
}
}

View File

@ -1,13 +0,0 @@
#ifndef FLUGLOBAL_H
#define FLUGLOBAL_H
#include <QtGlobal>
#include <QQmlApplicationEngine>
namespace FluentUI {
Q_DECL_EXPORT void preInit();
Q_DECL_EXPORT void postInit();
Q_DECL_EXPORT void initEngine(QQmlApplicationEngine* engine);
}
#endif // FLUGLOBAL_H

View File

@ -1,37 +1,3 @@
//#include "FluTheme.h"
//#include "Def.h"
//#include "FluColors.h"
//#include <QPalette>
//#include <QtGui/qpa/qplatformtheme.h>
//#include <QtGui/private/qguiapplication_p.h>
//#include <QGuiApplication>
//#include <FramelessHelper/Core/utils.h>
//#include <FramelessHelper/Core/framelessmanager.h>
//FRAMELESSHELPER_USE_NAMESPACE;
//FluTheme* FluTheme::m_instance = nullptr;
//FluTheme *FluTheme::getInstance()
//{
// if(FluTheme::m_instance == nullptr){
// FluTheme::m_instance = new FluTheme;
// }
// return FluTheme::m_instance;
//}
//FluTheme::FluTheme(QObject *parent)
// : QObject{parent}
//{
// primaryColor(FluColors::getInstance()->Blue());
// nativeText(false);
// dark(FramelessManager::instance()->systemTheme() == Global::SystemTheme::Dark);
// connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, [this](){
// dark(Utils::getSystemTheme()==Global::SystemTheme::Dark);
// });
//}
#include "FluTheme.h" #include "FluTheme.h"
#include "Def.h" #include "Def.h"
@ -40,11 +6,6 @@
#include <QtGui/qpa/qplatformtheme.h> #include <QtGui/qpa/qplatformtheme.h>
#include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qguiapplication_p.h>
#include <QGuiApplication> #include <QGuiApplication>
#include <FramelessHelper/Core/utils.h>
#include <FramelessHelper/Core/framelessmanager.h>
FRAMELESSHELPER_USE_NAMESPACE;
FluTheme* FluTheme::m_instance = nullptr; FluTheme* FluTheme::m_instance = nullptr;
@ -82,10 +43,12 @@ bool FluTheme::eventFilter(QObject *obj, QEvent *event)
return false; return false;
} }
bool FluTheme::systemDark() bool FluTheme::systemDark()
{ {
return Utils::getSystemTheme()==Global::SystemTheme::Dark; if (const QPlatformTheme * const theme = QGuiApplicationPrivate::platformTheme()) {
return (theme->appearance() == QPlatformTheme::Appearance::Dark);
}
return false;
} }
bool FluTheme::dark(){ bool FluTheme::dark(){

View File

@ -63,3 +63,4 @@ bool FluTools::isWin(){
#endif #endif
} }

View File

@ -623,7 +623,15 @@ Item {
if(d.isMinimal || d.isCompactAndPanel){ if(d.isMinimal || d.isCompactAndPanel){
return FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(243/255,243/255,243/255,1) return FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(243/255,243/255,243/255,1)
} }
return "transparent" if(Window.window.active){
return FluTheme.dark ? Qt.rgba(26/255,34/255,41/255,1) : Qt.rgba(238/255,244/255,249/255,1)
}
return FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
}
Behavior on color{
ColorAnimation {
duration: 300
}
} }
x: { x: {
if(d.displayMode !== FluNavigationView.Minimal) if(d.displayMode !== FluNavigationView.Minimal)

View File

@ -1,10 +1,8 @@
import QtQuick import QtQuick
import QtQuick.Window import QtQuick.Window
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Controls.Basic
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import org.wangwenx190.FramelessHelper
Window { Window {
enum LaunchMode { enum LaunchMode {
@ -13,9 +11,6 @@ Window {
SingleInstance SingleInstance
} }
default property alias content: container.data default property alias content: container.data
property bool fixSize
property alias titleVisible: title_bar.titleVisible
property bool appBarVisible: true
property bool closeDestory: true property bool closeDestory: true
property int launchMode: FluWindow.Standard property int launchMode: FluWindow.Standard
property string route property string route
@ -29,15 +24,15 @@ Window {
event.accepted = false event.accepted = false
} }
} }
property color backgroundColor: {
if(active){
return FluTheme.dark ? Qt.rgba(26/255,34/255,40/255,1) : Qt.rgba(238/255,244/255,249/255,1)
}
return FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
}
signal initArgument(var argument) signal initArgument(var argument)
id:window id:window
property color backgroundColor: { color:"transparent"
if(active){
return FluTheme.dark ? Qt.rgba(26/255,34/255,40/255,1) : Qt.rgba(238/255,244/255,249/255,1)
}
return FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
}
color: "transparent"
onClosing:(event)=>closeFunc(event) onClosing:(event)=>closeFunc(event)
Component.onCompleted: { Component.onCompleted: {
helper.initWindow(window) helper.initWindow(window)
@ -46,57 +41,21 @@ Window {
Rectangle{ Rectangle{
anchors.fill: parent anchors.fill: parent
color: backgroundColor color: backgroundColor
visible: {
if(!FramelessHelper.blurBehindWindowEnabled)
return true
return FluTheme.darkMode !== FluDarkMode.System && !FramelessHelper.blurBehindWindowEnabled
}
Behavior on color{ Behavior on color{
ColorAnimation { ColorAnimation {
duration: 300 duration: 300
} }
} }
} }
FluAppBar {
id: title_bar
title: window.title
visible: window.appBarVisible
anchors {
top: parent.top
left: parent.left
right: parent.right
}
}
Item{ Item{
id:container id:container
anchors{ anchors.fill: parent
top: title_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
clip: true clip: true
} }
FluInfoBar{ FluInfoBar{
id:infoBar id:infoBar
root: window root: window
} }
FramelessHelper{
id:framless_helper
onReady: {
setTitleBarItem(title_bar)
title_bar.maximizeButton.visible = false
title_bar.minimizeButton.visible = false
title_bar.closeButton.visible = false
framless_helper.moveWindowToDesktopCenter()
setHitTestVisible(title_bar.minimizeButton())
setHitTestVisible(title_bar.maximizeButton())
setHitTestVisible(title_bar.closeButton())
framless_helper.setWindowFixedSize(fixSize)
title_bar.maximizeButton.visible = !fixSize
window.visible = true
}
}
WindowHelper{ WindowHelper{
id:helper id:helper
} }
@ -118,12 +77,6 @@ Window {
function deleteWindow(){ function deleteWindow(){
helper.deleteWindow() helper.deleteWindow()
} }
function setHitTestVisible(com){
framless_helper.setHitTestVisible(com)
}
function setTitleBarItem(com){
framless_helper.setTitleBarItem(com)
}
function onResult(data){ function onResult(data){
if(pageRegister){ if(pageRegister){
pageRegister.onResult(data) pageRegister.onResult(data)