This commit is contained in:
朱子楚\zhuzi 2023-09-12 22:55:42 +08:00
parent fd30819393
commit 79a7c97fe8
17 changed files with 106 additions and 233 deletions

View File

@ -186,5 +186,6 @@
<file>qml/window/PageWindow.qml</file>
<file>qml/page/T_StaggeredView.qml</file>
<file>qml/viewmodel/SettingsViewModel.qml</file>
<file>qml/viewmodel/TextBoxViewModel.qml</file>
</qresource>
</RCC>

View File

@ -4,12 +4,19 @@ import QtQuick.Layouts
import QtQuick.Window
import FluentUI
import "qrc:///example/qml/component"
import "qrc:///example/qml/viewmodel"
FluScrollablePage{
launchMode: FluPageType.SingleInstance
title:"TextBox"
TextBoxViewModel{
id:viewModel
}
Component.onDestruction: {
console.debug("T_TextBox页面销毁了")
}
FluArea{
Layout.fillWidth: true
height: 68
@ -20,6 +27,10 @@ FluScrollablePage{
placeholderText: "单行输入框"
disabled:text_box_switch.checked
cleanEnabled: true
text:viewModel.text1
onTextChanged: {
viewModel.text1 = text
}
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
@ -84,6 +95,10 @@ FluScrollablePage{
FluMultilineTextBox{
id:multiine_textbox
placeholderText: "多行输入框"
text:viewModel.text2
onTextChanged: {
viewModel.text2 = text
}
disabled:text_box_multi_switch.checked
anchors{
verticalCenter: parent.verticalCenter

View File

@ -1,6 +1,5 @@
import QtQuick
import FluentUI
import "qrc:///example/qml/component"
FluViewModel{

View File

@ -0,0 +1,8 @@
import QtQuick
import FluentUI
FluViewModel {
objectName: "TextBoxView"
property string text1
property string text2
}

View File

@ -4,13 +4,21 @@ import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import FluentUI 1.0
import "qrc:///example/qml/component"
import "qrc:///example/qml/viewmodel"
import "../component"
import "../viewmodel"
FluScrollablePage{
launchMode: FluPageType.SingleInstance
title:"TextBox"
TextBoxViewModel{
id:viewModel
}
Component.onDestruction: {
console.debug("T_TextBox页面销毁了")
}
FluArea{
Layout.fillWidth: true
height: 68
@ -21,6 +29,10 @@ FluScrollablePage{
placeholderText: "单行输入框"
disabled:text_box_switch.checked
cleanEnabled: true
text:viewModel.text1
onTextChanged: {
viewModel.text1 = text
}
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
@ -85,6 +97,10 @@ FluScrollablePage{
FluMultilineTextBox{
id:multiine_textbox
placeholderText: "多行输入框"
text:viewModel.text2
onTextChanged: {
viewModel.text2 = text
}
disabled:text_box_multi_switch.checked
anchors{
verticalCenter: parent.verticalCenter

View File

@ -1,6 +1,5 @@
import QtQuick 2.15
import FluentUI 1.0
import "qrc:///example/qml/component"
FluViewModel{

View File

@ -0,0 +1,8 @@
import QtQuick 2.15
import FluentUI 1.0
FluViewModel {
objectName: "TextBoxView"
property string text1
property string text2
}

View File

@ -17,16 +17,9 @@ QML_NAMED_ELEMENT(FluViewModelType)
namespace FluHttpType {
Q_NAMESPACE
enum CacheMode {
/** 不使用缓存 */
NoCache = 0x0000,
/** 请求网络失败后,读取缓存 */
RequestFailedReadCache = 0x0001,
/** 如果缓存不存在才请求网络,否则使用缓存 */
IfNoneCacheRequest = 0x0002,
/** 先使用缓存,不管是否存在,仍然请求网络 */
FirstCacheThenRequest = 0x0004,
};
Q_ENUM_NS(CacheMode)

View File

@ -18,28 +18,12 @@
class FluApp : public QObject
{
Q_OBJECT
/**
* @brief initialRoute
*/
Q_PROPERTY_AUTO(QString,initialRoute);
/**
* @brief routes
*/
Q_PROPERTY_AUTO(QJsonObject,routes);
/**
* @brief http拦截器
*/
Q_PROPERTY_AUTO(FluHttpInterceptor*,httpInterceptor);
QML_NAMED_ELEMENT(FluApp)
QML_SINGLETON
private:
/**
* @brief FluApp qml创建单例就会走create工厂方法创建单例
* @param parent
*/
explicit FluApp(QObject *parent = nullptr);
public:
~FluApp();
@ -48,50 +32,16 @@ public:
return getInstance();
}
static FluApp *getInstance();
/**
* @brief run
*/
Q_INVOKABLE void run();
/**
* @brief navigate
* @param route
* @param argument
* @param fluRegister
*/
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
/**
* @brief init
* @param window
*/
Q_INVOKABLE void init(QQuickWindow *window);
/**
* @brief awesomelist
* @param keyword
* @return
*/
Q_INVOKABLE QJsonArray awesomelist(const QString& keyword = "");
/**
* @brief closeApp
*/
Q_INVOKABLE void closeApp();
Q_INVOKABLE void deleteWindow(QQuickWindow* window);
public:
/**
* @brief wnds
*/
QMap<quint64, QQuickWindow*> wnds;
private:
static FluApp* m_instance;
/**
* @brief appWindow
*/
QWindow *appWindow;
};

View File

@ -82,7 +82,9 @@ void FluHttp::cancel(){
}
}
void FluHttp::post(HttpRequest* request,HttpCallable* callable){
void FluHttp::post(HttpRequest* r,HttpCallable* c){
auto request = QPointer(r);
auto callable = QPointer(c);
request->method("post");
auto requestMap = request->toMap();
auto httpId = request->httpId();
@ -143,7 +145,9 @@ void FluHttp::post(HttpRequest* request,HttpCallable* callable){
});
}
void FluHttp::postString(HttpRequest* request,HttpCallable* callable){
void FluHttp::postString(HttpRequest* r,HttpCallable* c){
auto request = QPointer(r);
auto callable = QPointer(c);
request->method("postString");
auto requestMap = request->toMap();
auto httpId = request->httpId();
@ -196,7 +200,9 @@ void FluHttp::postString(HttpRequest* request,HttpCallable* callable){
});
}
void FluHttp::postJson(HttpRequest* request,HttpCallable* callable){
void FluHttp::postJson(HttpRequest* r,HttpCallable* c){
auto request = QPointer(r);
auto callable = QPointer(c);
request->method("postJson");
auto requestMap = request->toMap();
auto httpId = request->httpId();
@ -248,7 +254,9 @@ void FluHttp::postJson(HttpRequest* request,HttpCallable* callable){
});
}
void FluHttp::get(HttpRequest* request,HttpCallable* callable){
void FluHttp::get(HttpRequest* r,HttpCallable* c){
auto request = QPointer(r);
auto callable = QPointer(c);
request->method("get");
auto requestMap = request->toMap();
auto httpId = request->httpId();
@ -299,7 +307,9 @@ void FluHttp::get(HttpRequest* request,HttpCallable* callable){
});
}
void FluHttp::download(HttpRequest* request,HttpCallable* callable){
void FluHttp::download(HttpRequest* r,HttpCallable* c){
auto request = QPointer(r);
auto callable = QPointer(c);
request->method("download");
auto requestMap = request->toMap();
auto httpId = request->httpId();
@ -535,11 +545,11 @@ void FluHttp::onStart(QPointer<HttpCallable> callable){
}
}
void FluHttp::onFinish(QPointer<HttpCallable> callable,HttpRequest* request){
void FluHttp::onFinish(QPointer<HttpCallable> callable,QPointer<HttpRequest> request){
if(callable){
Q_EMIT callable->finish();
}
if(request->parent()->inherits("FluHttp")){
if(request&&request->parent()->inherits("FluHttp")){
request->deleteLater();
}
}

View File

@ -53,7 +53,7 @@ private:
bool cacheExists(const QString& httpId);
QString getCacheFilePath(const QString& httpId);
void onStart(QPointer<HttpCallable> callable);
void onFinish(QPointer<HttpCallable> callable,HttpRequest* request);
void onFinish(QPointer<HttpCallable> callable,QPointer<HttpRequest> request);
void onError(QPointer<HttpCallable> callable,int status,QString errorString,QString result);
void onSuccess(QPointer<HttpCallable> callable,QString result);
void onCache(QPointer<HttpCallable> callable,QString result);

View File

@ -17,25 +17,9 @@ class FluRegister : public QObject
Q_PROPERTY_AUTO(QString,path);
public:
explicit FluRegister(QObject *parent = nullptr);
/**
* @brief launch
* @param argument
*/
Q_INVOKABLE void launch(const QJsonObject& argument = {});
/**
* @brief onResult
* @param data
*/
Q_INVOKABLE void onResult(const QJsonObject& data = {});
/**
* @brief result
* @param data
*/
Q_SIGNAL void result(const QJsonObject& data);
};
#endif // FLUREGISTER_H

View File

@ -12,31 +12,11 @@
class FluTheme : public QObject
{
Q_OBJECT
/**
* @brief dark darkMode切换
*/
Q_PROPERTY(bool dark READ dark NOTIFY darkChanged)
/**
* @brief primaryColor
*/
Q_PROPERTY_AUTO(FluColorSet*,primaryColor)
/**
* @brief darkMode System=0Light=1Dark=2
*/
Q_PROPERTY_AUTO(int,darkMode);
/**
* @brief nativeText
*/
Q_PROPERTY_AUTO(bool,nativeText);
/**
* @brief
*/
Q_PROPERTY_AUTO(bool,enableAnimation);
QML_NAMED_ELEMENT(FluTheme)
QML_SINGLETON
private:

View File

@ -25,172 +25,56 @@ public:
}
static FluTools *getInstance();
/**
* @brief qtMajor Qt Major版本
* @return
*/
Q_INVOKABLE int qtMajor();
/**
* @brief qtMajor Qt Minor版本
* @return
*/
Q_INVOKABLE int qtMinor();
/**
* @brief isMacos Macos系统
* @return
*/
Q_INVOKABLE bool isMacos();
/**
* @brief isLinux Linux系统
* @return
*/
Q_INVOKABLE bool isLinux();
/**
* @brief isWin Windows系统
* @return
*/
Q_INVOKABLE bool isWin();
/**
* @brief clipText
* @param text
*/
Q_INVOKABLE void clipText(const QString& text);
/**
* @brief uuid uuid
* @return
*/
Q_INVOKABLE QString uuid();
/**
* @brief readFile
* @param fileName
* @return
*/
Q_INVOKABLE QString readFile(const QString& fileName);
/**
* @brief setQuitOnLastWindowClosed 退
* @param val
*/
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
/**
* @brief setOverrideCursor
* @param shape
*/
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
/**
* @brief restoreOverrideCursor
*/
Q_INVOKABLE void restoreOverrideCursor();
/**
* @brief html2PlantText html转换成纯文本
* @param html
*/
Q_INVOKABLE QString html2PlantText(const QString& html);
/**
* @brief toLocalPath windows系统下的file:///macos下的file://
* @param url
* @return
*/
Q_INVOKABLE QString toLocalPath(const QUrl& url);
/**
* @brief deleteItem Item对象
* @param p
*/
Q_INVOKABLE void deleteItem(QObject *p);
/**
* @brief getFileNameByUrl
* @param url
* @return
*/
Q_INVOKABLE QString getFileNameByUrl(const QUrl& url);
/**
* @brief getVirtualGeometry
* @return
*/
Q_INVOKABLE QRect getVirtualGeometry();
/**
* @brief getApplicationDirPath
* @return
*/
Q_INVOKABLE QString getApplicationDirPath();
/**
* @brief getUrlByFilePath
* @param path
* @return
*/
Q_INVOKABLE QUrl getUrlByFilePath(const QString& path);
/**
* @brief colorAlpha
* @param color
* @param alpha
* @return
*/
Q_INVOKABLE QColor colorAlpha(const QColor&,qreal alpha);
/**
* @brief md5
* @param text
* @return
*/
Q_INVOKABLE QString md5(QString text);
/**
* @brief sha256
* @param text
* @return
*/
Q_INVOKABLE QString sha256(QString text);
/**
* @brief toBase64
* @param text
* @return
*/
Q_INVOKABLE QString toBase64(QString text);
/**
* @brief fromBase64
* @param text
* @return
*/
Q_INVOKABLE QString fromBase64(QString text);
/**
* @brief removeDir
* @param dirPath
* @return
*/
Q_INVOKABLE bool removeDir(QString dirPath);
/**
* @brief removeFile
* @param filePath
* @return
*/
Q_INVOKABLE bool removeFile(QString filePath);
/**
* @brief showFileInFolder
* @param path
*/
Q_INVOKABLE void showFileInFolder(QString path);
};

View File

@ -21,7 +21,6 @@ Model::Model(QObject *parent)
Model::~Model()
{
qDebug()<<"Model delete~";
}
ViewModelManager::ViewModelManager(QObject *parent)
@ -68,7 +67,6 @@ PropertyObserver::PropertyObserver(QString name,QObject* model,QObject *parent)
}
PropertyObserver::~PropertyObserver(){
qDebug()<<"PropertyObserver delete~";
}
void PropertyObserver::_propertyChange(){

View File

@ -163,6 +163,7 @@ void FluentUI::registerTypes(const char *uri){
qmlRegisterUncreatableMetaObject(FluNavigationViewType::staticMetaObject, uri,major,minor,"FluNavigationViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTimelineType::staticMetaObject, uri,major,minor,"FluTimelineType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluScreenshotType::staticMetaObject, uri,major,minor,"FluScreenshotType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluViewModelType::staticMetaObject, uri,major,minor,"FluViewModelType", "Access to enums & flags only");
qmlRegisterModule(uri,major,minor);
}

View File

@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
// 'qmlplugindump -nonrelocatable FluentUI 1.0 D:/QtProjects/build-FluentUI-Desktop_Qt_5_15_2_MSVC2019_64bit-Release/src'
// 'qmlplugindump -nonrelocatable FluentUI 1.0 D:\QtProjects\build-FluentUI-Desktop_Qt_5_15_2_MSVC2019_64bit-Release\src'
Module {
dependencies: ["QtQuick 2.0"]
@ -290,6 +290,28 @@ Module {
}
}
}
Component {
name: "FluViewModel"
prototype: "QObject"
exports: ["FluentUI/FluViewModel 1.0"]
exportMetaObjectRevisions: [0]
Property { name: "scope"; type: "int" }
Property { name: "target"; type: "QObject"; isPointer: true }
Signal { name: "initData" }
}
Component {
name: "FluViewModelType"
exports: ["FluentUI/FluViewModelType 1.0"]
isCreatable: false
exportMetaObjectRevisions: [0]
Enum {
name: "Scope"
values: {
"Window": 0,
"Application": 1
}
}
}
Component {
name: "FluWatermark"
defaultProperty: "data"
@ -2624,8 +2646,8 @@ Module {
Property { name: "topPadding"; type: "int" }
Property { name: "navWidth"; type: "int" }
Property { name: "pageMode"; type: "int" }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_45"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_45"; isPointer: true }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_48"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_48"; isPointer: true }
Signal { name: "logoClicked" }
Method { name: "collapseAll"; type: "QVariant" }
Method {
@ -2801,14 +2823,19 @@ Module {
}
}
Component {
prototype: "QQuickItem"
prototype: "QQuickPage"
name: "FluentUI/FluPivot 1.0"
exports: ["FluentUI/FluPivot 1.0"]
exportMetaObjectRevisions: [0]
isComposite: true
defaultProperty: "content"
Property { name: "normalColor"; type: "QColor" }
Property { name: "hoverColor"; type: "QColor" }
Property { name: "textNormalColor"; type: "QColor" }
Property { name: "textHoverColor"; type: "QColor" }
Property { name: "textSize"; type: "int" }
Property { name: "textBold"; type: "bool" }
Property { name: "textSpacing"; type: "int" }
Property { name: "headerSpacing"; type: "int" }
Property { name: "headerHeight"; type: "int" }
Property { name: "content"; type: "QObject"; isList: true; isReadonly: true }
Property { name: "currentIndex"; type: "int" }
}