mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-30 07:03:46 +08:00
update
This commit is contained in:
parent
7d7cd4144c
commit
a89d36fd14
@ -94,6 +94,8 @@ set_target_properties(example PROPERTIES
|
||||
target_link_libraries(example PRIVATE
|
||||
Qt6::Quick
|
||||
fluentuiplugin
|
||||
FramelessHelper::Core
|
||||
FramelessHelper::Quick
|
||||
)
|
||||
|
||||
#安装
|
||||
|
62
example/qml/component/CustomWindow.qml
Normal file
62
example/qml/component/CustomWindow.qml
Normal file
@ -0,0 +1,62 @@
|
||||
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
|
||||
|
||||
onFixSizeChanged: {
|
||||
framless_helper.setWindowFixedSize(fixSize)
|
||||
title_bar.maximizeButton.visible = !fixSize
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
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())
|
||||
window.visible = true
|
||||
}
|
||||
}
|
||||
|
||||
function setHitTestVisible(com){
|
||||
framless_helper.setHitTestVisible(com)
|
||||
}
|
||||
|
||||
function setTitleBarItem(com){
|
||||
framless_helper.setTitleBarItem(com)
|
||||
}
|
||||
|
||||
}
|
@ -2,17 +2,15 @@
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title:"关于"
|
||||
width: 600
|
||||
height: 600
|
||||
minimumWidth: 600
|
||||
minimumHeight: 600
|
||||
maximumWidth: 600
|
||||
maximumHeight: 600
|
||||
fixSize: true
|
||||
launchMode: FluWindow.SingleTask
|
||||
|
||||
ColumnLayout{
|
||||
|
@ -2,17 +2,15 @@
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title:"登录"
|
||||
width: 400
|
||||
height: 400
|
||||
minimumWidth: 400
|
||||
minimumHeight: 400
|
||||
maximumWidth: 400
|
||||
maximumHeight: 400
|
||||
fixSize: true
|
||||
|
||||
onInitArgument:
|
||||
(argument)=>{
|
||||
|
@ -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"
|
||||
@ -15,6 +16,7 @@ FluWindow {
|
||||
closeDestory:false
|
||||
minimumWidth: 520
|
||||
minimumHeight: 460
|
||||
appBarVisible: false
|
||||
launchMode: FluWindow.SingleTask
|
||||
|
||||
closeFunc:function(event){
|
||||
@ -71,12 +73,33 @@ FluWindow {
|
||||
window.deleteWindow()
|
||||
FluApp.closeApp()
|
||||
}
|
||||
}
|
||||
|
||||
FluAppBar {
|
||||
id: title_bar
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
showDark: true
|
||||
Component.onCompleted: {
|
||||
setTitleBarItem(title_bar)
|
||||
setHitTestVisible(title_bar.minimizeButton())
|
||||
setHitTestVisible(title_bar.maximizeButton())
|
||||
setHitTestVisible(title_bar.closeButton())
|
||||
}
|
||||
}
|
||||
|
||||
FluNavigationView{
|
||||
id:nav_view
|
||||
anchors.fill: parent
|
||||
anchors{
|
||||
top: title_bar.bottom
|
||||
topMargin: -20
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
items: ItemsOriginal
|
||||
footerItems:ItemsFooter
|
||||
z:11
|
||||
@ -94,32 +117,10 @@ FluWindow {
|
||||
ItemsOriginal.startPageByItem(data)
|
||||
}
|
||||
}
|
||||
actionItem:Item{
|
||||
height: 40
|
||||
width: 148
|
||||
RowLayout{
|
||||
anchors.centerIn: parent
|
||||
spacing: 5
|
||||
FluText{
|
||||
text:lang.dark_mode
|
||||
}
|
||||
FluToggleSwitch{
|
||||
selected: FluTheme.dark
|
||||
clickFunc:function(){
|
||||
if(FluTheme.dark){
|
||||
FluTheme.darkMode = FluDarkMode.Light
|
||||
}else{
|
||||
FluTheme.darkMode = FluDarkMode.Dark
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
ItemsOriginal.navigationView = nav_view
|
||||
ItemsFooter.navigationView = nav_view
|
||||
nav_view.setCurrentIndex(0)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,9 @@
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
title:"视频播放器"
|
||||
width: 640
|
||||
|
@ -2,17 +2,15 @@
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title:"SingleInstance"
|
||||
width: 500
|
||||
height: 600
|
||||
minimumWidth: 500
|
||||
minimumHeight: 600
|
||||
maximumWidth: 500
|
||||
maximumHeight: 600
|
||||
fixSize: true
|
||||
launchMode: FluWindow.SingleInstance
|
||||
|
||||
FluTextBox{
|
||||
@ -35,4 +33,9 @@ FluWindow {
|
||||
text:"我是一个SingleInstance模式的窗口,如果我存在,我会销毁之前的窗口,并创建一个新窗口"
|
||||
}
|
||||
|
||||
FluAppBar{
|
||||
id:appbar
|
||||
width: parent.width
|
||||
height: 30
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,15 @@
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title:"SingleTask"
|
||||
width: 500
|
||||
height: 600
|
||||
minimumWidth: 500
|
||||
minimumHeight: 600
|
||||
maximumWidth: 500
|
||||
maximumHeight: 600
|
||||
fixSize: true
|
||||
launchMode: FluWindow.SingleTask
|
||||
|
||||
FluText{
|
||||
|
@ -2,17 +2,15 @@
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import "../component"
|
||||
|
||||
FluWindow {
|
||||
CustomWindow {
|
||||
|
||||
id:window
|
||||
title:"Standard"
|
||||
width: 500
|
||||
height: 600
|
||||
minimumWidth: 500
|
||||
minimumHeight: 600
|
||||
maximumWidth: 500
|
||||
maximumHeight: 600
|
||||
fixSize: true
|
||||
launchMode: FluWindow.Standard
|
||||
|
||||
FluText{
|
||||
|
@ -4,21 +4,31 @@
|
||||
#include <QDir>
|
||||
#include <QQuickWindow>
|
||||
#include <QProcess>
|
||||
#include <FluentUI/FluentUI.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[])
|
||||
{
|
||||
FramelessHelper::Quick::initialize();
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||
//6.4及以下监听系统深色模式变化
|
||||
#ifdef Q_OS_WIN
|
||||
qputenv("QT_QPA_PLATFORM","windows:darkmode=2");
|
||||
#endif
|
||||
//将样式设置为Basic,不然会导致组件显示异常
|
||||
FluentUI::preInit();
|
||||
QGuiApplication::setOrganizationName("ZhuZiChu");
|
||||
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
|
||||
QGuiApplication::setApplicationName("FluentUI");
|
||||
// QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
|
||||
QGuiApplication app(argc, argv);
|
||||
FluentUI::postInit();
|
||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
// FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
// FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
AppInfo* appInfo = new AppInfo();
|
||||
IPC ipc(0);
|
||||
QString activeWindowEvent = "activeWindow";
|
||||
@ -35,7 +45,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);
|
||||
|
@ -44,8 +44,6 @@ foreach(filepath IN LISTS qml_files resource_files)
|
||||
set_source_files_properties(${filepath} PROPERTIES QT_RESOURCE_ALIAS ${filename})
|
||||
endforeach()
|
||||
|
||||
set_source_files_properties(FluentUI.h PROPERTIES QT_RESOURCE_ALIAS "../../include/FluentUI/FluentUI.h")
|
||||
|
||||
#添加qml模块
|
||||
qt_add_library(fluentuiplugin SHARED)
|
||||
qt_add_qml_module(fluentuiplugin
|
||||
@ -56,7 +54,7 @@ qt_add_qml_module(fluentuiplugin
|
||||
URI "FluentUI"
|
||||
SOURCES ${sources_files} fluentui.rc
|
||||
QML_FILES ${qml_files}
|
||||
RESOURCES ${resource_files} FluentUI.h
|
||||
RESOURCES ${resource_files}
|
||||
#支持designer
|
||||
DESIGNER_SUPPORTED
|
||||
)
|
||||
@ -66,8 +64,6 @@ target_link_libraries(fluentuiplugin PUBLIC
|
||||
Qt::Core
|
||||
Qt::Quick
|
||||
Qt::Qml
|
||||
FramelessHelper::Core
|
||||
FramelessHelper::Quick
|
||||
)
|
||||
|
||||
#链接库 win32库 不然mingw会编译错误
|
||||
|
@ -1,25 +0,0 @@
|
||||
#include "FluentUI.h"
|
||||
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||
|
||||
FRAMELESSHELPER_USE_NAMESPACE;
|
||||
|
||||
void FluentUI::preInit(){
|
||||
qDebug()<<"FluentUI init";
|
||||
FramelessHelper::Quick::initialize();
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||
//6.4及以下监听系统深色模式变化
|
||||
#ifdef Q_OS_WIN
|
||||
qputenv("QT_QPA_PLATFORM","windows:darkmode=2");
|
||||
#endif
|
||||
}
|
||||
|
||||
void FluentUI::postInit(){
|
||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
}
|
||||
|
||||
void FluentUI::initEngine(QQmlApplicationEngine *engine){
|
||||
FramelessHelper::Quick::registerTypes(engine);
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
#ifndef FLUENTUI_H
|
||||
#define FLUENTUI_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QDebug>
|
||||
|
||||
class Q_DECL_EXPORT FluentUI
|
||||
{
|
||||
|
||||
public:
|
||||
static void preInit();
|
||||
static void postInit();
|
||||
static void initEngine(QQmlApplicationEngine *engine);
|
||||
};
|
||||
|
||||
#endif // FLUENTUI_H
|
@ -19,10 +19,10 @@ Rectangle{
|
||||
property color closeNormalColor: Qt.rgba(0,0,0,0)
|
||||
property color closeHoverColor: Qt.rgba(251/255,115/255,115/255,1)
|
||||
property bool showDark: false
|
||||
property bool titleVisible: true
|
||||
property color borerlessColor : FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
||||
id:root
|
||||
color: Qt.rgba(0,0,0,0)
|
||||
visible: false
|
||||
height: visible ? 30 : 0
|
||||
opacity: visible
|
||||
z: 65535
|
||||
@ -33,7 +33,7 @@ Rectangle{
|
||||
property bool resizable: win && !(win.minimumHeight === win.maximumHeight && win.maximumWidth === win.minimumWidth)
|
||||
}
|
||||
TapHandler {
|
||||
onTapped: if (tapCount === 2) toggleMaximized()
|
||||
onTapped: if (tapCount === 2) btn_maximize.clicked()
|
||||
gesturePolicy: TapHandler.DragThreshold
|
||||
}
|
||||
DragHandler {
|
||||
@ -48,6 +48,7 @@ Rectangle{
|
||||
left: parent.left
|
||||
leftMargin: 10
|
||||
}
|
||||
visible: root.titleVisible
|
||||
color:root.textColor
|
||||
}
|
||||
RowLayout{
|
||||
@ -75,6 +76,7 @@ Rectangle{
|
||||
}
|
||||
}
|
||||
FluIconButton{
|
||||
id:btn_minimize
|
||||
width: 40
|
||||
height: 30
|
||||
iconSource : FluentIcons.ChromeMinimize
|
||||
@ -85,10 +87,11 @@ Rectangle{
|
||||
iconColor: root.textColor
|
||||
color: hovered ? minimizeHoverColor : minimizeNormalColor
|
||||
onClicked: {
|
||||
d.win.showMinimized()
|
||||
d.win.visibility = Window.Minimized
|
||||
}
|
||||
}
|
||||
FluIconButton{
|
||||
id:btn_maximize
|
||||
width: 40
|
||||
height: 30
|
||||
iconSource : d.isRestore ? FluentIcons.ChromeRestore : FluentIcons.ChromeMaximize
|
||||
@ -100,10 +103,14 @@ Rectangle{
|
||||
text:d.isRestore?restoreText:maximizeText
|
||||
iconSize: 11
|
||||
onClicked: {
|
||||
toggleMaximized()
|
||||
if (d.win.visibility === Window.Maximized)
|
||||
d.win.visibility = Window.Windowed
|
||||
else
|
||||
d.win.visibility = Window.Maximized
|
||||
}
|
||||
}
|
||||
FluIconButton{
|
||||
id:btn_close
|
||||
iconSource : FluentIcons.ChromeClose
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
text:closeText
|
||||
@ -118,13 +125,17 @@ Rectangle{
|
||||
}
|
||||
}
|
||||
}
|
||||
function toggleMaximized() {
|
||||
if(!d.resizable)
|
||||
return
|
||||
if (d.win.visibility === Window.Maximized) {
|
||||
d.win.showNormal();
|
||||
} else {
|
||||
d.win.showMaximized();
|
||||
|
||||
function minimizeButton(){
|
||||
return btn_minimize
|
||||
}
|
||||
|
||||
function maximizeButton(){
|
||||
return btn_maximize
|
||||
}
|
||||
|
||||
function closeButton(){
|
||||
return btn_close
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import QtQuick.Window
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import FluentUI
|
||||
import org.wangwenx190.FramelessHelper
|
||||
|
||||
Window {
|
||||
enum LaunchMode {
|
||||
@ -25,7 +24,6 @@ Window {
|
||||
event.accepted = false
|
||||
}
|
||||
}
|
||||
visible: true
|
||||
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)
|
||||
@ -49,26 +47,9 @@ Window {
|
||||
}
|
||||
}
|
||||
}
|
||||
// StandardTitleBar {
|
||||
// id: title_bar
|
||||
// z:999
|
||||
// anchors {
|
||||
// top: parent.top
|
||||
// topMargin: window.visibility === Window.Windowed ? 1 : 0
|
||||
// left: parent.left
|
||||
// right: parent.right
|
||||
// }
|
||||
// // windowIcon: "qrc:///images/microsoft.svg"
|
||||
// windowIconVisible: false
|
||||
// }
|
||||
Item{
|
||||
id:container
|
||||
anchors{
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
}
|
||||
FluInfoBar{
|
||||
@ -78,16 +59,6 @@ Window {
|
||||
WindowHelper{
|
||||
id:helper
|
||||
}
|
||||
// FramelessHelper.onReady: {
|
||||
// FramelessHelper.titleBarItem = title_bar
|
||||
// FramelessHelper.moveWindowToDesktopCenter()
|
||||
// if (Qt.platform.os !== "macos") {
|
||||
// FramelessHelper.setSystemButton(title_bar.minimizeButton, FramelessHelperConstants.Minimize);
|
||||
// FramelessHelper.setSystemButton(title_bar.maximizeButton, FramelessHelperConstants.Maximize);
|
||||
// FramelessHelper.setSystemButton(title_bar.closeButton, FramelessHelperConstants.Close);
|
||||
// }
|
||||
// window.visible = true
|
||||
// }
|
||||
function showSuccess(text,duration,moremsg){
|
||||
infoBar.showSuccess(text,duration,moremsg)
|
||||
}
|
||||
@ -111,5 +82,4 @@ Window {
|
||||
pageRegister.onResult(data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user