This commit is contained in:
zhuzihcu
2023-03-02 18:21:43 +08:00
parent 91be0e4da2
commit 1b5223a7d5
23 changed files with 746 additions and 361 deletions

12
example/InstallHelper.cpp Normal file
View File

@ -0,0 +1,12 @@
#include "InstallHelper.h"
InstallHelper::InstallHelper(QObject *parent)
: QObject{parent}
{
installing(false);
}
void InstallHelper::install(const QString& path,bool isHome,bool isStartMenu){
installing(true);
qDebug()<<path;
}

20
example/InstallHelper.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef INSTALLHELPER_H
#define INSTALLHELPER_H
#include <QObject>
#include <QDebug>
#include "stdafx.h"
class InstallHelper : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(bool,installing)
public:
explicit InstallHelper(QObject *parent = nullptr);
Q_INVOKABLE void install(const QString& path,bool isHome,bool isStartMenu);
signals:
};
#endif // INSTALLHELPER_H

View File

@ -1,5 +1,8 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Dialogs 1.3 as Dialogs
import Qt.labs.platform 1.1
import UI 1.0
import FluentUI 1.0
FluWindow {
@ -7,15 +10,37 @@ FluWindow {
id:window
width: 800
height: 400
maximumSize: Qt.size(800,400)
minimumSize: Qt.size(800,400)
minimumWidth:800
maximumWidth:800
minimumHeight:400
maximumHeight:400
title:"安装向导"
property string installPath: "C:\\Program Files"
property string installName: "FluentUI"
FluAppBar{
id:appbar
title: "安装向导"
}
Item{
id:data
InstallHelper{
id:helper
}
Dialogs.FileDialog {
id: fileDialog
selectFolder: true
folder: "file:///"+installPath
onAccepted: {
installPath = String(fileDialog.fileUrls[0]).replace("file:///","").replace(RegExp("/",'g'),"\\")
}
}
}
ColumnLayout{
width: parent.width
@ -36,18 +61,37 @@ FluWindow {
}
FluTextBox{
id:textbox_path
Layout.preferredHeight: 40
Layout.fillWidth: true
text:"C:\\Program Files\\RustDesk"
text:installPath+ "\\" +installName
readOnly:true
}
FluButton{
text:"更改路径"
Layout.rightMargin: 30
onClicked: {
fileDialog.open()
}
}
}
FluCheckBox{
id:checkbox_startmenu
Layout.topMargin: 20
Layout.leftMargin: 30
checked: true
text:"创建启动菜单快捷方式"
}
FluCheckBox{
id:checkbox_home
Layout.leftMargin: 30
Layout.topMargin: 5
checked: true
text:"创建桌面图标"
}
Item{
width: 1
Layout.fillHeight: true
@ -77,6 +121,9 @@ FluWindow {
}
FluFilledButton{
text:"同意并安装"
onClicked: {
helper.install(textbox_path.text,checkbox_home.checked,checkbox_startmenu.checked)
}
}
FluButton{
text:"不安装直接运行"
@ -88,4 +135,34 @@ FluWindow {
}
}
}
Rectangle{
anchors.fill: parent
visible: helper.installing
color: "#80000000"
MouseArea{
anchors.fill: parent
hoverEnabled: true
}
FluProgressBar{
id:progress
anchors.centerIn: parent
}
FluText{
text:"正在安装..."
color:"#FFFFFF"
font.pixelSize: 20
anchors{
horizontalCenter: progress.horizontalCenter
bottom: progress.top
bottomMargin: 10
}
}
}
}

View File

@ -3,6 +3,7 @@ import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.15
import FluentUI 1.0
FluWindow {
@ -10,51 +11,79 @@ FluWindow {
width: 800
height: 600
title: "FluentUI"
minimumSize: Qt.size(600,400)
// property var maximumSize
minimumWidth: 600
minimumHeight: 400
FluAppBar{
id:appbar
title: "FluentUI"
}
ListModel{
id:nav_items
ListElement{
text:"Buttons"
page:"qrc:/T_Buttons.qml"
Item{
id:data
ListModel{
id:nav_items
ListElement{
text:"Buttons"
page:"qrc:/T_Buttons.qml"
}
ListElement{
text:"TextBox"
page:"qrc:/T_TextBox.qml"
}
ListElement{
text:"ToggleSwitch"
page:"qrc:/T_ToggleSwitch.qml"
}
ListElement{
text:"Slider"
page:"qrc:/T_Slider.qml"
}
ListElement{
text:"InfoBar"
page:"qrc:/T_InfoBar.qml"
}
ListElement{
text:"Progress"
page:"qrc:/T_Progress.qml"
}
ListElement{
text:"Rectangle"
page:"qrc:/T_Rectangle.qml"
}
ListElement{
text:"Awesome"
page:"qrc:/T_Awesome.qml"
}
ListElement{
text:"Typography"
page:"qrc:/T_Typography.qml"
}
}
ListElement{
text:"TextBox"
page:"qrc:/T_TextBox.qml"
FluMenu{
id:menu
FluMenuItem{
text:"123"
}
FluMenuItem{
text:"456"
}
}
ListElement{
text:"ToggleSwitch"
page:"qrc:/T_ToggleSwitch.qml"
}
FluIconButton{
icon:FluentIcons.FA_navicon
anchors{
left: parent.left
bottom: parent.bottom
leftMargin: 12
bottomMargin: 12
}
ListElement{
text:"Slider"
page:"qrc:/T_Slider.qml"
}
ListElement{
text:"InfoBar"
page:"qrc:/T_InfoBar.qml"
}
ListElement{
text:"Progress"
page:"qrc:/T_Progress.qml"
}
ListElement{
text:"Rectangle"
page:"qrc:/T_Rectangle.qml"
}
ListElement{
text:"Awesome"
page:"qrc:/T_Awesome.qml"
}
ListElement{
text:"Typography"
page:"qrc:/T_Typography.qml"
onClicked:{
menu.popup()
}
}
@ -64,8 +93,9 @@ FluWindow {
top: appbar.bottom
bottom: parent.bottom
topMargin: 20
bottomMargin: 20
bottomMargin: 52
}
clip: true
width: 160
model: nav_items
delegate: Item{

View File

@ -1,4 +1,5 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import FluentUI 1.0
@ -13,18 +14,32 @@ Item {
FluTextBox{
id:text_box
placeholderText: "搜索"
placeholderText: "请输入关键字"
anchors{
topMargin: 20
top:title.bottom
}
}
FluFilledButton{
text:"搜索"
anchors{
left: text_box.right
verticalCenter: text_box.verticalCenter
leftMargin: 14
}
onClicked: {
grid_view.model = FluApp.awesomelist(text_box.text)
}
}
GridView{
id:grid_view
cellWidth: 120
cellHeight: 60
clip: true
model:FluApp.awesomelist()
ScrollBar.vertical: FluScrollBar {}
anchors{
topMargin: 10
top:text_box.bottom

View File

@ -4,6 +4,7 @@ CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS QT_NO_WARNING_OUTPUT
SOURCES += \
InstallHelper.cpp \
main.cpp
RESOURCES += qml.qrc
@ -42,3 +43,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
# PRE_TARGETDEPS += $$OUT_PWD/../bin/FluentUI/lib$${LIBNAME}.a
### 注意:静态库 .so .dylib .dll 是自动安装的Qt qml plugin目录中不需要此步配置
HEADERS += \
InstallHelper.h \
stdafx.h

View File

@ -1,5 +1,6 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "InstallHelper.h"
#if defined(STATICLIB)
#include <FluentUI.h>
@ -7,6 +8,10 @@
int main(int argc, char *argv[])
{
QCoreApplication::setOrganizationName("ZhuZiChu");
QCoreApplication::setOrganizationDomain("https://zhuzichu520.github.io");
QCoreApplication::setApplicationName("FluentUI");
qputenv("QSG_RENDER_LOOP","basic");
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
@ -16,12 +21,15 @@ int main(int argc, char *argv[])
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
#endif
// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
#if defined(STATICLIB)
FluentUI::create(&engine);
#endif
qmlRegisterType<InstallHelper>("UI",1,0,"InstallHelper");
#if defined(STATICLIB)
FluentUI::create(&engine);
#endif
const QUrl url(QStringLiteral("qrc:/App.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {

21
example/stdafx.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef STDAFX_H
#define STDAFX_H
#define Q_PROPERTY_AUTO(TYPE, M) \
Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed) \
public: \
Q_SIGNAL void M##Changed(); \
void M(TYPE in_##M) \
{ \
_##M = in_##M; \
Q_EMIT M##Changed(); \
} \
TYPE M() \
{ \
return _##M; \
} \
\
private: \
TYPE _##M;
#endif // STDAFX_H