mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-02 08:05:29 +08:00
update
This commit is contained in:
17
example/res/template/App.qml.in
Normal file
17
example/res/template/App.qml.in
Normal file
@ -0,0 +1,17 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Window 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Item {
|
||||
id: app
|
||||
Component.onCompleted: {
|
||||
FluApp.init(app)
|
||||
FluApp.windowIcon = "qrc:/logo.ico"
|
||||
FluApp.routes = {
|
||||
"/":"qrc:/main.qml",
|
||||
}
|
||||
FluApp.navigate("/")
|
||||
}
|
||||
}
|
90
example/res/template/CMakeLists.txt.in
Normal file
90
example/res/template/CMakeLists.txt.in
Normal file
@ -0,0 +1,90 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(%1 VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(APPLICATION_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/debug)
|
||||
else()
|
||||
set(APPLICATION_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/release)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(APPLICATION_REAL_PATH ${APPLICATION_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app/Contents/MacOS)
|
||||
else()
|
||||
set(APPLICATION_REAL_PATH ${APPLICATION_OUTPUT_DIRECTORY})
|
||||
endif()
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick)
|
||||
|
||||
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 ${APPLICATION_REAL_PATH}/i18n)
|
||||
|
||||
|
||||
set(PROJECT_SOURCES
|
||||
main.cpp
|
||||
qml.qrc
|
||||
)
|
||||
|
||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
qt_add_executable(${PROJECT_NAME}
|
||||
MANUAL_FINALIZATION
|
||||
${PROJECT_SOURCES}
|
||||
)
|
||||
else()
|
||||
add_executable(${PROJECT_NAME}
|
||||
${PROJECT_SOURCES}
|
||||
)
|
||||
endif()
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${APPLICATION_OUTPUT_DIRECTORY}"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${APPLICATION_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
fluentuiplugin
|
||||
)
|
||||
|
||||
if(${QT_VERSION} VERSION_LESS 6.1.0)
|
||||
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.${PROJECT_NAME})
|
||||
endif()
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
${BUNDLE_ID_OPTION}
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
MACOSX_BUNDLE TRUE
|
||||
WIN32_EXECUTABLE TRUE
|
||||
)
|
||||
|
||||
add_subdirectory(FluentUI)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
if(QT_VERSION_MAJOR EQUAL 6)
|
||||
qt_import_qml_plugins(${PROJECT_NAME})
|
||||
qt_finalize_executable(${PROJECT_NAME})
|
||||
endif()
|
22
example/res/template/en_US.ts.in
Normal file
22
example/res/template/en_US.ts.in
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en_US">
|
||||
<context>
|
||||
<name>main</name>
|
||||
<message>
|
||||
<location filename="main.qml" line="10"/>
|
||||
<source>%1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="main.qml" line="22"/>
|
||||
<source>Welcome to FluentUI</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="main.qml" line="27"/>
|
||||
<source>Learn FluentUI</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
BIN
example/res/template/logo.ico.in
Normal file
BIN
example/res/template/logo.ico.in
Normal file
Binary file not shown.
After Width: | Height: | Size: 116 KiB |
32
example/res/template/main.cpp.in
Normal file
32
example/res/template/main.cpp.in
Normal file
@ -0,0 +1,32 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QTranslator>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#endif
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QTranslator translator;
|
||||
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
||||
for (const QString &locale : uiLanguages) {
|
||||
const QString baseName = "%1_" + QLocale(locale).name();
|
||||
if (translator.load("./i18n/"+ baseName)) {
|
||||
app.installTranslator(&translator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
const QUrl url(QStringLiteral("qrc:/App.qml"));
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||
if (!obj && url == objUrl)
|
||||
QCoreApplication::exit(-1);
|
||||
}, Qt::QueuedConnection);
|
||||
engine.load(url);
|
||||
|
||||
return app.exec();
|
||||
}
|
35
example/res/template/main.qml.in
Normal file
35
example/res/template/main.qml.in
Normal file
@ -0,0 +1,35 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Window 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
FluWindow {
|
||||
width: 640
|
||||
height: 480
|
||||
minimumWidth: 320
|
||||
minimumHeight: 240
|
||||
title: qsTr("%1")
|
||||
|
||||
Column{
|
||||
anchors.centerIn: parent
|
||||
spacing: 15
|
||||
Image{
|
||||
width: 60
|
||||
height: 60
|
||||
source: "qrc:/logo.ico"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
FluText{
|
||||
text: qsTr("Welcome to FluentUI")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
font: FluTextStyle.Title
|
||||
}
|
||||
FluFilledButton{
|
||||
text: qsTr("Learn FluentUI")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
onClicked: {
|
||||
Qt.openUrlExternally("https://space.bilibili.com/275661059")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
7
example/res/template/qml.qrc.in
Normal file
7
example/res/template/qml.qrc.in
Normal file
@ -0,0 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
<file>App.qml</file>
|
||||
<file>logo.ico</file>
|
||||
</qresource>
|
||||
</RCC>
|
22
example/res/template/zh_CN.ts.in
Normal file
22
example/res/template/zh_CN.ts.in
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN">
|
||||
<context>
|
||||
<name>main</name>
|
||||
<message>
|
||||
<location filename="main.qml" line="10"/>
|
||||
<source>%1</source>
|
||||
<translation type="unfinished">%1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="main.qml" line="22"/>
|
||||
<source>Welcome to FluentUI</source>
|
||||
<translation type="unfinished">欢迎使用FluentUI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="main.qml" line="27"/>
|
||||
<source>Learn FluentUI</source>
|
||||
<translation type="unfinished">学习FluentUI</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
Reference in New Issue
Block a user