Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
朱子楚\zhuzi committed Sep 12, 2023
1 parent fd30819 commit 79a7c97
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 231 deletions.
1 change: 1 addition & 0 deletions example/example.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
19 changes: 17 additions & 2 deletions example/qml-Qt6/page/T_TextBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ import QtQuick.Layouts
import QtQuick.Window
import FluentUI
import "qrc:///example/qml/component"
import "qrc:///example/qml/viewmodel"

FluScrollablePage{
title:"TextBox"

launchMode: FluPageType.SingleInstance
TextBoxViewModel{
id:viewModel
}

Component.onDestruction: {
console.debug("T_TextBox页面销毁了")
}

title:"TextBox"
FluArea{
Layout.fillWidth: true
height: 68
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion example/qml-Qt6/viewmodel/SettingsViewModel.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import QtQuick
import FluentUI
import "qrc:///example/qml/component"

FluViewModel{

Expand Down
8 changes: 8 additions & 0 deletions example/qml-Qt6/viewmodel/TextBoxViewModel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import QtQuick
import FluentUI

FluViewModel {
objectName: "TextBoxView"
property string text1
property string text2
}
20 changes: 18 additions & 2 deletions example/qml/page/T_TextBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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{
title:"TextBox"

launchMode: FluPageType.SingleInstance
TextBoxViewModel{
id:viewModel
}

Component.onDestruction: {
console.debug("T_TextBox页面销毁了")
}

title:"TextBox"
FluArea{
Layout.fillWidth: true
height: 68
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion example/qml/viewmodel/SettingsViewModel.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import QtQuick 2.15
import FluentUI 1.0
import "qrc:///example/qml/component"

FluViewModel{

Expand Down
8 changes: 8 additions & 0 deletions example/qml/viewmodel/TextBoxViewModel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import QtQuick 2.15
import FluentUI 1.0

FluViewModel {
objectName: "TextBoxView"
property string text1
property string text2
}
7 changes: 0 additions & 7 deletions src/Def.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
50 changes: 0 additions & 50 deletions src/FluApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -48,50 +32,16 @@ class FluApp : public QObject
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;
};

Expand Down
24 changes: 17 additions & 7 deletions src/FluHttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/FluHttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FluHttp : public QObject
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);
Expand Down
16 changes: 0 additions & 16 deletions src/FluRegister.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 0 additions & 20 deletions src/FluTheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -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=0、Light=1、Dark=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:
Expand Down
Loading

0 comments on commit 79a7c97

Please sign in to comment.