mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-26 13:27:05 +08:00
update
This commit is contained in:
parent
2129301cd2
commit
15f90471dc
@ -90,18 +90,12 @@ set_target_properties(example PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
)
|
||||
|
||||
|
||||
#链接库
|
||||
target_link_libraries(example PRIVATE
|
||||
Qt6::Quick
|
||||
fluentuiplugin
|
||||
)
|
||||
|
||||
#导入头文件
|
||||
set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI)
|
||||
target_include_directories(
|
||||
example PRIVATE
|
||||
${QML_PLUGIN_DIRECTORY}
|
||||
FramelessHelper::Core
|
||||
FramelessHelper::Quick
|
||||
)
|
||||
|
||||
#安装
|
||||
|
60
example/qml/component/CustomWindow.qml
Normal file
60
example/qml/component/CustomWindow.qml
Normal 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)
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,9 @@
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title:"关于"
|
||||
|
@ -2,8 +2,9 @@
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title:"登录"
|
||||
|
@ -4,9 +4,10 @@ import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Qt.labs.platform
|
||||
import FluentUI
|
||||
import "../component"
|
||||
import "qrc:///example/qml/global/"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title: "FluentUI"
|
||||
@ -97,7 +98,7 @@ FluWindow {
|
||||
z:999
|
||||
items: ItemsOriginal
|
||||
footerItems:ItemsFooter
|
||||
topPadding:FluTools.isMacos() ? 20 : 5
|
||||
topPadding:Qt.platform.os === FluTools.isMacos() ? 20 : 5
|
||||
displayMode:MainEvent.displayMode
|
||||
logo: "qrc:/example/res/image/favicon.ico"
|
||||
title:"FluentUI"
|
||||
|
@ -2,8 +2,9 @@
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
title:"视频播放器"
|
||||
width: 640
|
||||
|
@ -2,8 +2,9 @@
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title:"SingleInstance"
|
||||
|
@ -2,8 +2,9 @@
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title:"SingleTask"
|
||||
|
@ -2,8 +2,9 @@
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title:"Standard"
|
||||
|
@ -4,20 +4,23 @@
|
||||
#include <QDir>
|
||||
#include <QQuickWindow>
|
||||
#include <QProcess>
|
||||
#include <FluGlobal.h>
|
||||
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||
#include "lang/Lang.h"
|
||||
#include "AppInfo.h"
|
||||
#include "tool/IPC.h"
|
||||
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FluentUI::preInit();
|
||||
//将样式设置为Basic,不然会导致组件显示异常
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||
FramelessHelper::Quick::initialize();
|
||||
QGuiApplication::setOrganizationName("ZhuZiChu");
|
||||
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
|
||||
QGuiApplication::setApplicationName("FluentUI");
|
||||
// QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
|
||||
QGuiApplication app(argc, argv);
|
||||
FluentUI::postInit();
|
||||
AppInfo* appInfo = new AppInfo();
|
||||
IPC ipc(0);
|
||||
QString activeWindowEvent = "activeWindow";
|
||||
@ -34,7 +37,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
QQmlApplicationEngine engine;
|
||||
FluentUI::initEngine(&engine);
|
||||
FramelessHelper::Quick::registerTypes(&engine);
|
||||
QQmlContext * context = engine.rootContext();
|
||||
Lang* lang = appInfo->lang();
|
||||
context->setContextProperty("lang",lang);
|
||||
|
@ -54,11 +54,9 @@ qt_add_qml_module(fluentuiplugin
|
||||
URI "FluentUI"
|
||||
SOURCES ${sources_files} fluentui.rc
|
||||
QML_FILES ${qml_files}
|
||||
RESOURCES ${resource_files} FluGlobal.h
|
||||
RESOURCES ${resource_files}
|
||||
#支持designer
|
||||
DESIGNER_SUPPORTED
|
||||
DEPENDENCIES
|
||||
org.wangwenx190.FramelessHelper/auto
|
||||
)
|
||||
|
||||
#链接库
|
||||
@ -66,8 +64,6 @@ target_link_libraries(fluentuiplugin PUBLIC
|
||||
Qt::CorePrivate
|
||||
Qt::QuickPrivate
|
||||
Qt::QmlPrivate
|
||||
FramelessHelper::Core
|
||||
FramelessHelper::Quick
|
||||
)
|
||||
|
||||
#链接库 win32库 不然mingw会编译错误
|
||||
|
@ -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)";
|
||||
}
|
||||
|
||||
}
|
@ -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
|
@ -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 "Def.h"
|
||||
@ -40,11 +6,6 @@
|
||||
#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;
|
||||
|
||||
@ -82,10 +43,12 @@ bool FluTheme::eventFilter(QObject *obj, QEvent *event)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
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(){
|
||||
|
@ -63,3 +63,4 @@ bool FluTools::isWin(){
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -623,7 +623,15 @@ Item {
|
||||
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 "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: {
|
||||
if(d.displayMode !== FluNavigationView.Minimal)
|
||||
|
@ -1,10 +1,8 @@
|
||||
import QtQuick
|
||||
import QtQuick.Window
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Basic
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import org.wangwenx190.FramelessHelper
|
||||
|
||||
Window {
|
||||
enum LaunchMode {
|
||||
@ -13,9 +11,6 @@ Window {
|
||||
SingleInstance
|
||||
}
|
||||
default property alias content: container.data
|
||||
property bool fixSize
|
||||
property alias titleVisible: title_bar.titleVisible
|
||||
property bool appBarVisible: true
|
||||
property bool closeDestory: true
|
||||
property int launchMode: FluWindow.Standard
|
||||
property string route
|
||||
@ -29,15 +24,15 @@ Window {
|
||||
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)
|
||||
id:window
|
||||
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)
|
||||
}
|
||||
color: "transparent"
|
||||
color:"transparent"
|
||||
onClosing:(event)=>closeFunc(event)
|
||||
Component.onCompleted: {
|
||||
helper.initWindow(window)
|
||||
@ -46,57 +41,21 @@ Window {
|
||||
Rectangle{
|
||||
anchors.fill: parent
|
||||
color: backgroundColor
|
||||
visible: {
|
||||
if(!FramelessHelper.blurBehindWindowEnabled)
|
||||
return true
|
||||
return FluTheme.darkMode !== FluDarkMode.System && !FramelessHelper.blurBehindWindowEnabled
|
||||
}
|
||||
Behavior on color{
|
||||
ColorAnimation {
|
||||
duration: 300
|
||||
}
|
||||
}
|
||||
}
|
||||
FluAppBar {
|
||||
id: title_bar
|
||||
title: window.title
|
||||
visible: window.appBarVisible
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
}
|
||||
Item{
|
||||
id:container
|
||||
anchors{
|
||||
top: title_bar.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
}
|
||||
FluInfoBar{
|
||||
id:infoBar
|
||||
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{
|
||||
id:helper
|
||||
}
|
||||
@ -118,12 +77,6 @@ Window {
|
||||
function deleteWindow(){
|
||||
helper.deleteWindow()
|
||||
}
|
||||
function setHitTestVisible(com){
|
||||
framless_helper.setHitTestVisible(com)
|
||||
}
|
||||
function setTitleBarItem(com){
|
||||
framless_helper.setTitleBarItem(com)
|
||||
}
|
||||
function onResult(data){
|
||||
if(pageRegister){
|
||||
pageRegister.onResult(data)
|
||||
|
Loading…
Reference in New Issue
Block a user