This commit is contained in:
zhuzichu 2023-10-10 15:06:44 +08:00
parent 79ab73105e
commit 54f52e0886
21 changed files with 201 additions and 182 deletions

View File

@ -189,5 +189,6 @@
<file>qml/page/T_Clip.qml</file>
<file>qml/page/T_3D.qml</file>
<file>res/obj/test.obj</file>
<file>qml/global/Lang.qml</file>
</qresource>
</RCC>

View File

@ -2,6 +2,7 @@ pragma Singleton
import QtQuick
import FluentUI
import "qrc:///example/qml/global"
FluObject{
@ -12,7 +13,7 @@ FluObject{
FluPaneItemSeparator{}
FluPaneItem{
title:lang.about
title:Lang.about
icon:FluentIcons.Contact
onDropped: { FluApp.navigate("/about") }
onTapListener:function(){
@ -21,7 +22,7 @@ FluObject{
}
FluPaneItem{
title:lang.settings
title:Lang.settings
icon:FluentIcons.Settings
url:"qrc:/example/qml/page/T_Settings.qml"
onDropped:{ FluApp.navigate("/pageWindow",{title:title,url:url}) }

View File

@ -2,6 +2,7 @@ pragma Singleton
import QtQuick
import FluentUI
import "qrc:///example/qml/global"
FluObject{
@ -16,7 +17,7 @@ FluObject{
FluPaneItem{
id:item_home
count: 9
title:lang.home
title:Lang.home
infoBadge:FluBadge{
count: item_home.count
}
@ -47,7 +48,7 @@ FluObject{
FluPaneItemExpander{
id:item_expander_basic_input
title:lang.basic_input
title:Lang.basic_input
icon:FluentIcons.CheckboxComposite
editDelegate: FluTextBox{
text:item_expander_basic_input.title
@ -137,7 +138,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.form
title:Lang.form
icon:FluentIcons.GridView
FluPaneItem{
title:"TextBox"
@ -172,7 +173,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.surface
title:Lang.surface
icon:FluentIcons.SurfaceHub
FluPaneItem{
title:"InfoBar"
@ -246,7 +247,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.popus
title:Lang.popus
icon:FluentIcons.ButtonMenu
FluPaneItem{
title:"Dialog"
@ -284,7 +285,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.navigation
title:Lang.navigation
icon:FluentIcons.AllApps
FluPaneItem{
title:"Pivot"
@ -353,7 +354,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.theming
title:Lang.theming
icon:FluentIcons.Brightness
FluPaneItem{
title:"Acrylic"
@ -393,7 +394,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.other
title:Lang.other
icon:FluentIcons.Shop
FluPaneItem{
title:"QRCode"

View File

@ -0,0 +1,77 @@
pragma Singleton
import QtQuick
QtObject {
property string home
property string basic_input
property string form
property string surface
property string popus
property string navigation
property string theming
property string media
property string dark_mode
property string sys_dark_mode
property string search
property string about
property string settings
property string locale
property string navigation_view_display_mode
property string other
function zh(){
home="首页"
basic_input="基本输入"
form="表单"
surface="表面"
popus="弹窗"
navigation="导航"
theming="主题"
media="媒体"
dark_mode="夜间模式"
sys_dark_mode="跟随系统"
search="查找"
about="关于"
settings="设置"
locale="语言环境"
navigation_view_display_mode="导航视图显示模式"
other="其他"
}
function en(){
home="Home"
basic_input="Basic Input"
form="Form"
surface="Surfaces"
popus="Popus"
navigation="Navigation"
theming="Theming"
media="Media"
dark_mode="Dark Mode"
sys_dark_mode="Sync with system"
search="Search"
about="About"
settings="Settings"
locale="Locale"
navigation_view_display_mode="NavigationView Display Mode"
other="Other"
}
property string __locale
property var __localeList: ["Zh","En"]
on__LocaleChanged: {
if(__locale === "Zh"){
zh()
}else{
en()
}
}
Component.onCompleted: {
__locale = "En"
}
}

View File

@ -1,2 +1,3 @@
singleton ItemsOriginal 1.0 ItemsOriginal.qml
singleton ItemsFooter 1.0 ItemsFooter.qml
singleton Lang 1.0 Lang.qml

View File

@ -101,7 +101,7 @@ FluScrollablePage{
left: parent.left
}
FluText{
text:lang.dark_mode
text:Lang.dark_mode
font: FluTextStyle.BodyStrong
Layout.bottomMargin: 4
}
@ -131,7 +131,7 @@ FluScrollablePage{
left: parent.left
}
FluText{
text:lang.navigation_view_display_mode
text:Lang.navigation_view_display_mode
font: FluTextStyle.BodyStrong
Layout.bottomMargin: 4
}
@ -162,7 +162,7 @@ FluScrollablePage{
}
FluText{
text:lang.locale
text:Lang.locale
font: FluTextStyle.BodyStrong
Layout.bottomMargin: 4
}
@ -170,12 +170,12 @@ FluScrollablePage{
Flow{
spacing: 5
Repeater{
model: ["Zh","En"]
model: Lang.__localeList
delegate: FluRadioButton{
checked: AppInfo.lang.objectName === modelData
checked: Lang.__locale === modelData
text:modelData
clickListener:function(){
AppInfo.changeLang(modelData)
Lang.__locale = modelData
}
}
}

View File

@ -38,8 +38,8 @@ FluWindow {
checkUpdate(false)
}
}
Component.onCompleted: {
console.debug(Lang.about)
FluTools.setQuitOnLastWindowClosed(false)
tour.open()
checkUpdate(true)
@ -119,7 +119,7 @@ FluWindow {
left: parent.left
right: parent.right
}
darkText: lang.dark_mode
darkText: Lang.dark_mode
showDark: true
z:7
darkClickListener:(button)=>handleDarkChanged(button)
@ -169,7 +169,7 @@ FluWindow {
left: parent.left
right: parent.right
}
darkText: lang.dark_mode
darkText: Lang.dark_mode
showDark: true
darkClickListener:(button)=>handleDarkChanged(button)
z:7
@ -202,7 +202,7 @@ FluWindow {
autoSuggestBox:FluAutoSuggestBox{
iconSource: FluentIcons.Search
items: ItemsOriginal.getSearchData()
placeholderText: lang.search
placeholderText: Lang.search
onItemClicked:
(data)=>{
ItemsOriginal.startPageByItem(data)

View File

@ -2,6 +2,7 @@ pragma Singleton
import QtQuick 2.15
import FluentUI 1.0
import "qrc:///example/qml/global"
FluObject{
@ -12,7 +13,7 @@ FluObject{
FluPaneItemSeparator{}
FluPaneItem{
title:lang.about
title:Lang.about
icon:FluentIcons.Contact
onDropped: { FluApp.navigate("/about") }
onTapListener:function(){
@ -21,7 +22,7 @@ FluObject{
}
FluPaneItem{
title:lang.settings
title:Lang.settings
icon:FluentIcons.Settings
url:"qrc:/example/qml/page/T_Settings.qml"
onDropped:{ FluApp.navigate("/pageWindow",{title:title,url:url}) }

View File

@ -2,6 +2,7 @@ pragma Singleton
import QtQuick 2.15
import FluentUI 1.0
import "qrc:///example/qml/global"
FluObject{
@ -16,7 +17,7 @@ FluObject{
FluPaneItem{
id:item_home
count: 9
title:lang.home
title:Lang.home
infoBadge:FluBadge{
count: item_home.count
}
@ -47,7 +48,7 @@ FluObject{
FluPaneItemExpander{
id:item_expander_basic_input
title:lang.basic_input
title:Lang.basic_input
icon:FluentIcons.CheckboxComposite
editDelegate: FluTextBox{
text:item_expander_basic_input.title
@ -137,7 +138,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.form
title:Lang.form
icon:FluentIcons.GridView
FluPaneItem{
title:"TextBox"
@ -172,7 +173,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.surface
title:Lang.surface
icon:FluentIcons.SurfaceHub
FluPaneItem{
title:"InfoBar"
@ -246,7 +247,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.popus
title:Lang.popus
icon:FluentIcons.ButtonMenu
FluPaneItem{
title:"Dialog"
@ -284,7 +285,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.navigation
title:Lang.navigation
icon:FluentIcons.AllApps
FluPaneItem{
title:"Pivot"
@ -353,7 +354,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.theming
title:Lang.theming
icon:FluentIcons.Brightness
FluPaneItem{
title:"Acrylic"
@ -393,7 +394,7 @@ FluObject{
}
FluPaneItemExpander{
title:lang.other
title:Lang.other
icon:FluentIcons.Shop
FluPaneItem{
title:"QRCode"

View File

@ -0,0 +1,77 @@
pragma Singleton
import QtQuick 2.15
QtObject {
property string home
property string basic_input
property string form
property string surface
property string popus
property string navigation
property string theming
property string media
property string dark_mode
property string sys_dark_mode
property string search
property string about
property string settings
property string locale
property string navigation_view_display_mode
property string other
function zh(){
home="首页"
basic_input="基本输入"
form="表单"
surface="表面"
popus="弹窗"
navigation="导航"
theming="主题"
media="媒体"
dark_mode="夜间模式"
sys_dark_mode="跟随系统"
search="查找"
about="关于"
settings="设置"
locale="语言环境"
navigation_view_display_mode="导航视图显示模式"
other="其他"
}
function en(){
home="Home"
basic_input="Basic Input"
form="Form"
surface="Surfaces"
popus="Popus"
navigation="Navigation"
theming="Theming"
media="Media"
dark_mode="Dark Mode"
sys_dark_mode="Sync with system"
search="Search"
about="About"
settings="Settings"
locale="Locale"
navigation_view_display_mode="NavigationView Display Mode"
other="Other"
}
property string __locale
property var __localeList: ["Zh","En"]
on__LocaleChanged: {
if(__locale === "Zh"){
zh()
}else{
en()
}
}
Component.onCompleted: {
__locale = "En"
}
}

View File

@ -1,2 +1,3 @@
singleton ItemsOriginal 1.0 ItemsOriginal.qml
singleton ItemsFooter 1.0 ItemsFooter.qml
singleton Lang 1.0 Lang.qml

View File

@ -104,7 +104,7 @@ FluScrollablePage{
left: parent.left
}
FluText{
text:lang.dark_mode
text:Lang.dark_mode
font: FluTextStyle.BodyStrong
Layout.bottomMargin: 4
}
@ -134,7 +134,7 @@ FluScrollablePage{
left: parent.left
}
FluText{
text:lang.navigation_view_display_mode
text:Lang.navigation_view_display_mode
font: FluTextStyle.BodyStrong
Layout.bottomMargin: 4
}
@ -165,7 +165,7 @@ FluScrollablePage{
}
FluText{
text:lang.locale
text:Lang.locale
font: FluTextStyle.BodyStrong
Layout.bottomMargin: 4
}
@ -173,12 +173,12 @@ FluScrollablePage{
Flow{
spacing: 5
Repeater{
model: ["Zh","En"]
model: Lang.__localeList
delegate: FluRadioButton{
checked: AppInfo.lang.objectName === modelData
checked: Lang.__locale === modelData
text:modelData
clickListener:function(){
AppInfo.changeLang(modelData)
Lang.__locale = modelData
}
}
}

View File

@ -121,7 +121,7 @@ FluWindow {
left: parent.left
right: parent.right
}
darkText: lang.dark_mode
darkText: Lang.dark_mode
showDark: true
z:7
darkClickListener:(button)=>handleDarkChanged(button)
@ -171,7 +171,7 @@ FluWindow {
left: parent.left
right: parent.right
}
darkText: lang.dark_mode
darkText: Lang.dark_mode
showDark: true
darkClickListener:(button)=>handleDarkChanged(button)
z:7
@ -204,7 +204,7 @@ FluWindow {
autoSuggestBox:FluAutoSuggestBox{
iconSource: FluentIcons.Search
items: ItemsOriginal.getSearchData()
placeholderText: lang.search
placeholderText: Lang.search
onItemClicked:
(data)=>{
ItemsOriginal.startPageByItem(data)

View File

@ -3,35 +3,14 @@
#include <QQmlContext>
#include <QDebug>
#include <QGuiApplication>
#include "lang/En.h"
#include "lang/Zh.h"
#include "Version.h"
AppInfo::AppInfo(QObject *parent)
: QObject{parent}
{
version(APPLICATION_VERSION);
lang(new En());
}
void AppInfo::init(QQmlApplicationEngine *engine){
QQmlContext * context = engine->rootContext();
Lang* lang = this->lang();
context->setContextProperty("lang",lang);
QObject::connect(this,&AppInfo::langChanged,this,[=]{
context->setContextProperty("lang",this->lang());
});
}
void AppInfo::changeLang(const QString& locale){
if(_lang){
_lang->deleteLater();
}
if(locale=="Zh"){
lang(new Zh());
}else if(locale=="En"){
lang(new En());
}else {
lang(new En());
}
engine->rootContext();
}

View File

@ -3,7 +3,6 @@
#include <QObject>
#include <QQmlApplicationEngine>
#include "lang/Lang.h"
#include "stdafx.h"
#include "singleton.h"
@ -11,13 +10,11 @@ class AppInfo : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(QString,version)
Q_PROPERTY_AUTO(Lang*,lang)
private:
explicit AppInfo(QObject *parent = nullptr);
public:
SINGLETONG(AppInfo)
void init(QQmlApplicationEngine *engine);
Q_INVOKABLE void changeLang(const QString& locale);
};
#endif // APPINFO_H

View File

@ -1,23 +0,0 @@
#include "En.h"
En::En(QObject *parent)
: Lang{parent}
{
setObjectName("En");
home("Home");
basic_input("Basic Input");
form("Form");
surface("Surfaces");
popus("Popus");
navigation("Navigation");
theming("Theming");
media("Media");
dark_mode("Dark Mode");
sys_dark_mode("Sync with system");
search("Search");
about("About");
settings("Settings");
locale("Locale");
navigation_view_display_mode("NavigationView Display Mode");
other("Other");
}

View File

@ -1,17 +0,0 @@
#ifndef EN_H
#define EN_H
#include <QObject>
#include "Lang.h"
class En : public Lang
{
Q_OBJECT
public:
explicit En(QObject *parent = nullptr);
signals:
};
#endif // EN_H

View File

@ -1,7 +0,0 @@
#include "Lang.h"
Lang::Lang(QObject *parent)
: QObject{parent}
{
}

View File

@ -1,31 +0,0 @@
#ifndef LANG_H
#define LANG_H
#include <QObject>
#include "../stdafx.h"
class Lang : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(QString,home);
Q_PROPERTY_AUTO(QString,basic_input);
Q_PROPERTY_AUTO(QString,form);
Q_PROPERTY_AUTO(QString,surface);
Q_PROPERTY_AUTO(QString,popus);
Q_PROPERTY_AUTO(QString,navigation);
Q_PROPERTY_AUTO(QString,theming);
Q_PROPERTY_AUTO(QString,media);
Q_PROPERTY_AUTO(QString,dark_mode);
Q_PROPERTY_AUTO(QString,sys_dark_mode);
Q_PROPERTY_AUTO(QString,search);
Q_PROPERTY_AUTO(QString,about);
Q_PROPERTY_AUTO(QString,settings);
Q_PROPERTY_AUTO(QString,navigation_view_display_mode);
Q_PROPERTY_AUTO(QString,locale);
Q_PROPERTY_AUTO(QString,other);
public:
explicit Lang(QObject *parent = nullptr);
};
#endif // LANG_H

View File

@ -1,23 +0,0 @@
#include "Zh.h"
Zh::Zh(QObject *parent)
: Lang{parent}
{
setObjectName("Zh");
home("首页");
basic_input("基本输入");
form("表单");
surface("表面");
popus("弹窗");
navigation("导航");
theming("主题");
media("媒体");
dark_mode("夜间模式");
sys_dark_mode("跟随系统");
search("查找");
about("关于");
settings("设置");
locale("语言环境");
navigation_view_display_mode("导航视图显示模式");
other("其他");
}

View File

@ -1,17 +0,0 @@
#ifndef ZH_H
#define ZH_H
#include <QObject>
#include "Lang.h"
class Zh : public Lang
{
Q_OBJECT
public:
explicit Zh(QObject *parent = nullptr);
signals:
};
#endif // ZH_H