main
zhuzihcu 2023-05-17 12:49:41 +08:00
parent 09dd381bbc
commit b93f91a73f
8 changed files with 63 additions and 18 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "framelesshelper"]
path = framelesshelper
url = https://github.com/zhuzichu520/framelesshelper.git

View File

@ -4,3 +4,4 @@ project(FluentUI VERSION 0.1 LANGUAGES CXX)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(example) add_subdirectory(example)
add_subdirectory(framelesshelper)

View File

@ -12,17 +12,13 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
//将样式设置为Basic不然会导致组件显示异常 //将样式设置为Basic不然会导致组件显示异常
FluentUI::init(); FluentUI::preInit();
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
//6.4及以下监听系统深色模式变化
#ifdef Q_OS_WIN
qputenv("QT_QPA_PLATFORM","windows:darkmode=2");
#endif
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); // 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";

View File

@ -66,6 +66,8 @@ target_link_libraries(fluentuiplugin PUBLIC
Qt::Core Qt::Core
Qt::Quick Qt::Quick
Qt::Qml Qt::Qml
FramelessHelper::Core
FramelessHelper::Quick
) )
# win32 mingw # win32 mingw

View File

@ -78,7 +78,6 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
fluRegister->to(view); fluRegister->to(view);
} }
view->setColor(QColor(Qt::transparent)); view->setColor(QColor(Qt::transparent));
view->show();
} }
QJsonArray FluApp::awesomelist(const QString& keyword) QJsonArray FluApp::awesomelist(const QString& keyword)

View File

@ -1,5 +1,21 @@
#include "FluentUI.h" #include "FluentUI.h"
#include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
void FluentUI::init(){ FRAMELESSHELPER_USE_NAMESPACE;
void FluentUI::preInit(){
qDebug()<<"FluentUI init"; 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);
} }

View File

@ -8,8 +8,8 @@ class Q_DECL_EXPORT FluentUI
{ {
public: public:
static void init(); static void preInit();
static void postInit();
}; };
#endif // FLUENTUI_H #endif // FLUENTUI_H

View File

@ -3,8 +3,9 @@ import QtQuick.Window
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import FluentUI import FluentUI
import org.wangwenx190.FramelessHelper
Window { FramelessWindow {
enum LaunchMode { enum LaunchMode {
Standard, Standard,
SingleTask, SingleTask,
@ -32,7 +33,7 @@ Window {
} }
signal initArgument(var argument) signal initArgument(var argument)
id:window id:window
color:Qt.rgba(0,0,0,0) color:"transparent"
onClosing:(event)=>closeFunc(event) onClosing:(event)=>closeFunc(event)
Component.onCompleted: { Component.onCompleted: {
helper.initWindow(window) helper.initWindow(window)
@ -47,9 +48,26 @@ 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{ Item{
id:container id:container
anchors.fill: parent anchors{
top: title_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
clip: true clip: true
} }
FluInfoBar{ FluInfoBar{
@ -59,17 +77,27 @@ Window {
WindowHelper{ WindowHelper{
id:helper 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){ function showSuccess(text,duration,moremsg){
infoBar.showSuccess(text,duration,moremsg); infoBar.showSuccess(text,duration,moremsg)
} }
function showInfo(text,duration,moremsg){ function showInfo(text,duration,moremsg){
infoBar.showInfo(text,duration,moremsg); infoBar.showInfo(text,duration,moremsg)
} }
function showWarning(text,duration,moremsg){ function showWarning(text,duration,moremsg){
infoBar.showWarning(text,duration,moremsg); infoBar.showWarning(text,duration,moremsg)
} }
function showError(text,duration,moremsg){ function showError(text,duration,moremsg){
infoBar.showError(text,duration,moremsg); infoBar.showError(text,duration,moremsg)
} }
function registerForWindowResult(path){ function registerForWindowResult(path){
return helper.createRegister(window,path) return helper.createRegister(window,path)