This commit is contained in:
zhuzihcu
2023-05-17 18:15:15 +08:00
parent 7d7cd4144c
commit a89d36fd14
15 changed files with 150 additions and 144 deletions

View File

@ -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会编译错误

View File

@ -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);
}

View File

@ -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

View File

@ -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
}
}

View File

@ -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)
}
}
}