Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
朱子楚\zhuzi committed Mar 13, 2024
1 parent e11f1a1 commit 099e966
Show file tree
Hide file tree
Showing 46 changed files with 793 additions and 479 deletions.
259 changes: 81 additions & 178 deletions example/example_en_US.ts

Large diffs are not rendered by default.

239 changes: 95 additions & 144 deletions example/example_zh_CN.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/qml-Qt6/App.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Item {
FluNetwork.setInterceptor(function(param){
param.addHeader("Token","000000000000000000000")
})
FluApp.init(app)
FluApp.init(app,Qt.locale(TranslateHelper.current))
FluApp.windowIcon = "qrc:/example/res/image/favicon.ico"
FluApp.useSystemAppBar = SettingsHelper.getUseSystemAppBar()
FluTheme.darkMode = SettingsHelper.getDarkMode()
Expand Down
5 changes: 0 additions & 5 deletions example/qml-Qt6/page/T_DatePicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ FluScrollablePage{
}
FluDatePicker{
current: new Date()
yearText: qsTr("Year")
monthText: qsTr("Month")
dayText: qsTr("Day")
cancelText: qsTr("Cancel")
okText: qsTr("OK")
onAccepted: {
showSuccess(current.toLocaleDateString())
}
Expand Down
1 change: 0 additions & 1 deletion example/qml-Qt6/page/T_Image.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ FluScrollablePage{
width: 384
height: 240
source: "https://gitee.com/zhu-zichu/zhu-zichu/raw/74f075efe2f8d3c3bb7ba3c2259e403450e4050b/image/banner_4.jpg"
errorButtonText: qsTr("Reload")
onStatusChanged:{
if(status === Image.Error){
showError(qsTr("The image failed to load, please reload"))
Expand Down
2 changes: 1 addition & 1 deletion example/qml-Qt6/page/T_InfoBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ FluScrollablePage{
FluButton{
text:"Loading"
onClicked: {
showLoading(qsTr("Loading..."))
showLoading()
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions example/qml-Qt6/page/T_Pagination.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,16 @@ FluScrollablePage{
pageCurrent: 1
pageButtonCount: 5
itemCount: 5000
previousText: qsTr("<Previous")
nextText: qsTr("Next>")
}
FluPagination{
pageCurrent: 2
itemCount: 5000
pageButtonCount: 7
previousText: qsTr("<Previous")
nextText: qsTr("Next>")
}
FluPagination{
pageCurrent: 3
itemCount: 5000
pageButtonCount: 9
previousText: qsTr("<Previous")
nextText: qsTr("Next>")
}
}

Expand Down
5 changes: 0 additions & 5 deletions example/qml-Qt6/page/T_ShortcutPicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ FluScrollablePage{
paddings: 10
FluShortcutPicker{
anchors.verticalCenter: parent.verticalCenter
title: qsTr("Activate the Shortcut")
message: qsTr("Press the key combination to change the shortcut")
positiveText: qsTr("Save")
neutralText: qsTr("Cancel")
negativeText: qsTr("Reset")
}
}
CodeExpander{
Expand Down
3 changes: 0 additions & 3 deletions example/qml-Qt6/page/T_Tour.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ FluScrollablePage{

FluTour{
id:tour
finishText: qsTr("Finish")
nextText: qsTr("Next")
previousText: qsTr("Previous")
steps:[
{title:qsTr("Upload File"),description: qsTr("Put your files here."),target:()=>btn_upload},
{title:qsTr("Save"),description: qsTr("Save your changes."),target:()=>btn_save},
Expand Down
2 changes: 1 addition & 1 deletion example/qml/App.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Item {
FluNetwork.setInterceptor(function(param){
param.addHeader("Token","000000000000000000000")
})
FluApp.init(app)
FluApp.init(app,Qt.locale(TranslateHelper.current))
FluApp.windowIcon = "qrc:/example/res/image/favicon.ico"
FluApp.useSystemAppBar = SettingsHelper.getUseSystemAppBar()
FluTheme.darkMode = SettingsHelper.getDarkMode()
Expand Down
10 changes: 0 additions & 10 deletions example/qml/page/T_DatePicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ FluScrollablePage{
}
FluDatePicker{
current: new Date()
yearText: qsTr("Year")
monthText: qsTr("Month")
dayText: qsTr("Day")
cancelText: qsTr("Cancel")
okText: qsTr("OK")
onAccepted: {
showSuccess(current.toLocaleDateString())
}
Expand Down Expand Up @@ -58,11 +53,6 @@ FluScrollablePage{
}
FluDatePicker{
showYear: false
yearText: qsTr("Year")
monthText: qsTr("Month")
dayText: qsTr("Day")
cancelText: qsTr("Cancel")
okText: qsTr("OK")
onAccepted: {
showSuccess(current.toLocaleDateString())
}
Expand Down
1 change: 0 additions & 1 deletion example/qml/page/T_Image.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ FluScrollablePage{
width: 384
height: 240
source: "https://gitee.com/zhu-zichu/zhu-zichu/raw/74f075efe2f8d3c3bb7ba3c2259e403450e4050b/image/banner_4.jpg"
errorButtonText: qsTr("Reload")
onStatusChanged:{
if(status === Image.Error){
showError(qsTr("The image failed to load, please reload"))
Expand Down
2 changes: 1 addition & 1 deletion example/qml/page/T_InfoBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ FluScrollablePage{
FluButton{
text:"Loading"
onClicked: {
showLoading(qsTr("Loading..."))
showLoading()
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions example/qml/page/T_Pagination.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,16 @@ FluScrollablePage{
pageCurrent: 1
pageButtonCount: 5
itemCount: 5000
previousText: qsTr("<Previous")
nextText: qsTr("Next>")
}
FluPagination{
pageCurrent: 2
itemCount: 5000
pageButtonCount: 7
previousText: qsTr("<Previous")
nextText: qsTr("Next>")
}
FluPagination{
pageCurrent: 3
itemCount: 5000
pageButtonCount: 9
previousText: qsTr("<Previous")
nextText: qsTr("Next>")
}
}

Expand Down
5 changes: 0 additions & 5 deletions example/qml/page/T_ShortcutPicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ FluScrollablePage{
paddings: 10
FluShortcutPicker{
anchors.verticalCenter: parent.verticalCenter
title: qsTr("Activate the Shortcut")
message: qsTr("Press the key combination to change the shortcut")
positiveText: qsTr("Save")
neutralText: qsTr("Cancel")
negativeText: qsTr("Reset")
}
}
CodeExpander{
Expand Down
3 changes: 0 additions & 3 deletions example/qml/page/T_Tour.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ FluScrollablePage{

FluTour{
id:tour
finishText: qsTr("Finish")
nextText: qsTr("Next")
previousText: qsTr("Previous")
steps:[
{title:qsTr("Upload File"),description: qsTr("Put your files here."),target:()=>btn_upload},
{title:qsTr("Save"),description: qsTr("Save your changes."),target:()=>btn_save},
Expand Down
17 changes: 16 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ else()
set(CMAKE_AUTOUIC ON)
endif()

#国际化
find_program(QT_LUPDATE NAMES lupdate)
find_program(QT_LRELEASE NAMES lrelease)
if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_en_US.qm)
execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
endif ()
if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_zh_CN.qm)
execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
endif ()

file(GLOB QM_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.qm)
file(COPY ${QM_FILE_PATHS} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/Qt${QT_VERSION_MAJOR}/imports/FluentUI/i18n")

#遍历所有Cpp文件
file(GLOB_RECURSE CPP_FILES *.cpp *.h)
foreach(filepath ${CPP_FILES})
Expand All @@ -67,7 +82,7 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
endforeach(filepath)

#遍历所有资源文件
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.js)
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.js *.qm)
foreach(filepath ${RES_PATHS})
if(${filepath} MATCHES "Qt${QT_VERSION_MAJOR}/")
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
Expand Down
13 changes: 12 additions & 1 deletion src/FluApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QUuid>
#include <QFontDatabase>
#include <QClipboard>
#include <QTranslator>

FluApp::FluApp(QObject *parent):QObject{parent}{
useSystemAppBar(false);
Expand All @@ -16,8 +17,18 @@ FluApp::FluApp(QObject *parent):QObject{parent}{
FluApp::~FluApp(){
}

void FluApp::init(QObject *target){
void FluApp::init(QObject *target,QLocale locale){
_engine = qmlEngine(target);
_translator = new QTranslator(this);
qApp->installTranslator(_translator);
const QStringList uiLanguages = locale.uiLanguages();
for (const QString &name : uiLanguages) {
const QString baseName = "fluentuiplugin_" + QLocale(name).name();
if (_translator->load(":/qt/qml/FluentUI/i18n/"+ baseName)) {
_engine->retranslate();
break;
}
}
}

void FluApp::run(){
Expand Down
4 changes: 3 additions & 1 deletion src/FluApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QQmlContext>
#include <QJsonObject>
#include <QQmlEngine>
#include <QTranslator>
#include "FluWindowRegister.h"
#include "stdafx.h"
#include "singleton.h"
Expand All @@ -32,14 +33,15 @@ class FluApp : public QObject
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE void run();
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluWindowRegister* windowRegister = nullptr);
Q_INVOKABLE void init(QObject *target);
Q_INVOKABLE void init(QObject *target,QLocale locale = QLocale::system());
Q_INVOKABLE void exit(int retCode = 0);
Q_INVOKABLE QVariant createWindowRegister(QQuickWindow* window,const QString& path);
void addWindow(QQuickWindow* window);
void removeWindow(QQuickWindow* window);
private:
QMap<quint64, QQuickWindow*> _windows;
QQmlEngine *_engine;
QTranslator* _translator = nullptr;
};

#endif // FLUAPP_H
6 changes: 3 additions & 3 deletions src/FluTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ void FluTheme::refreshColors(){
fontSecondaryColor(isDark ? QColor(222,222,222,255) : QColor(102,102,102,255));
fontTertiaryColor(isDark ? QColor(200,200,200,255) : QColor(153,153,153,255));
itemNormalColor(isDark ? QColor(255,255,255,0) : QColor(0,0,0,0));
itemHoverColor(isDark ? QColor(255,255,255,255*0.03) : QColor(0,0,0,255*0.03));
itemPressColor(isDark ? QColor(255,255,255,255*0.06) : QColor(0,0,0,255*0.06));
itemCheckColor(isDark ? QColor(255,255,255,255*0.09) : QColor(0,0,0,255*0.09));
itemHoverColor(isDark ? QColor(255,255,255,255*0.06) : QColor(0,0,0,255*0.03));
itemPressColor(isDark ? QColor(255,255,255,255*0.09) : QColor(0,0,0,255*0.06));
itemCheckColor(isDark ? QColor(255,255,255,255*0.12) : QColor(0,0,0,255*0.09));
}

bool FluTheme::eventFilter(QObject *obj, QEvent *event){
Expand Down
16 changes: 8 additions & 8 deletions src/Qt5/imports/FluentUI/Controls/FluAppBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import FluentUI 1.0

Rectangle{
property string title: ""
property string darkText : "深色"
property string lightText : "浅色"
property string minimizeText : "最小化"
property string restoreText : "向下还原"
property string maximizeText : "最大化"
property string closeText : "关闭"
property string stayTopText : "置顶"
property string stayTopCancelText : "取消置顶"
property string darkText : qsTr("Dark")
property string lightText : qsTr("Light")
property string minimizeText : qsTr("Minimize")
property string restoreText : qsTr("Restore")
property string maximizeText : qsTr("Maximize")
property string closeText : qsTr("Close")
property string stayTopText : qsTr("Sticky on Top")
property string stayTopCancelText : qsTr("Sticky on Top cancelled")
property color textColor: FluTheme.dark ? "#FFFFFF" : "#000000"
property color minimizeNormalColor: FluTheme.itemNormalColor
property color minimizeHoverColor: FluTheme.itemHoverColor
Expand Down
6 changes: 3 additions & 3 deletions src/Qt5/imports/FluentUI/Controls/FluAutoSuggestBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import FluentUI 1.0

FluTextBox{
property var items:[]
property string emptyText: "没有找到结果"
property string emptyText: qsTr("No results found")
property int autoSuggestBoxReplacement: FluentIcons.Search
signal itemClicked(var data)
signal handleClicked
Expand Down Expand Up @@ -99,12 +99,12 @@ FluTextBox{
loadData()
if(d.flagVisible){
var pos = control.mapToItem(null, 0, 0)
if(window.height>pos.y+control.height+container.implicitHeight){
if(d.window.height>pos.y+control.height+container.implicitHeight){
control_popup.y = control.height
} else if(pos.y>container.implicitHeight){
control_popup.y = -container.implicitHeight
} else {
control_popup.y = window.height-(pos.y+container.implicitHeight)
control_popup.y = d.window.height-(pos.y+container.implicitHeight)
}
control_popup.visible = true
}
Expand Down
2 changes: 1 addition & 1 deletion src/Qt5/imports/FluentUI/Controls/FluCalendarPicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Rectangle {
property color dividerColor: FluTheme.dark ? Qt.rgba(77/255,77/255,77/255,1) : Qt.rgba(239/255,239/255,239/255,1)
property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
property color normalColor: FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1)
property string text: "请选择日期"
property string text: qsTr("Please select a date")
property var current
signal accepted()
id:control
Expand Down
6 changes: 3 additions & 3 deletions src/Qt5/imports/FluentUI/Controls/FluContentDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ FluPopup {
id: control
property string title: ""
property string message: ""
property string neutralText: "Close"
property string negativeText: "Cancel"
property string positiveText: "OK"
property string neutralText: qsTr("Close")
property string negativeText: qsTr("Cancel")
property string positiveText: qsTr("OK")
property int messageTextFormart: Text.AutoText
property int delayTime: 100
property int buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
Expand Down
10 changes: 5 additions & 5 deletions src/Qt5/imports/FluentUI/Controls/FluDatePicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Rectangle {
property color normalColor: FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1)
property bool showYear: true
property var current
property string yearText: ""
property string monthText: ""
property string dayText: ""
property string cancelText: "取消"
property string okText: "确定"
property string yearText: qsTr("Year")
property string monthText: qsTr("Month")
property string dayText: qsTr("Day")
property string cancelText: qsTr("Cancel")
property string okText: qsTr("OK")
signal accepted()
id:control
color: {
Expand Down
2 changes: 1 addition & 1 deletion src/Qt5/imports/FluentUI/Controls/FluImage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import QtQuick.Controls 2.15
import FluentUI 1.0

Image {
property string errorButtonText: "重新加载"
property string errorButtonText: qsTr("Reload")
property var clickErrorListener : function(){
image.source = ""
image.source = control.source
Expand Down
4 changes: 2 additions & 2 deletions src/Qt5/imports/FluentUI/Controls/FluPagination.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import FluentUI 1.0

Item {
signal requestPage(int page,int count)
property string previousText: "<上一页"
property string nextText: "下一页>"
property string previousText: qsTr("<Previous")
property string nextText: qsTr("Next>")
property int pageCurrent: 0
property int itemCount: 0
property int pageButtonCount: 5
Expand Down
10 changes: 5 additions & 5 deletions src/Qt5/imports/FluentUI/Controls/FluShortcutPicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import FluentUI 1.0
FluIconButton {
id:control
property var current : ["Ctrl","Shift","A"]
property string title: "激活快捷键"
property string message: "按下组合键以更改此快捷键"
property string positiveText: "保存"
property string neutralText: "取消"
property string negativeText: "重置"
property string title: qsTr("Activate the Shortcut")
property string message: qsTr("Press the key combination to change the shortcut")
property string positiveText: qsTr("Save")
property string neutralText: qsTr("Cancel")
property string negativeText: qsTr("Reset")
signal accepted()
QtObject{
id: d
Expand Down
Loading

0 comments on commit 099e966

Please sign in to comment.