This commit is contained in:
朱子楚\zhuzi 2024-03-11 00:02:11 +08:00
parent ea69589c0a
commit d79a7df389
20 changed files with 454 additions and 117 deletions

View File

@ -13,20 +13,10 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/.cmake/)
include(GetGitRevisionDescription)
option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
set(QT_SDK_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../..")
cmake_path(SET QT_SDK_DIR NORMALIZE ${QT_SDK_DIR})
#QML<QT_SDK_DIR_PATH>\qml\FluentUI
set(FLUENTUI_QML_PLUGIN_DIRECTORY "" CACHE PATH "Path to FluentUI plugin")
if(NOT FLUENTUI_QML_PLUGIN_DIRECTORY)
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${QT_SDK_DIR}/qml/FluentUI)
endif()
add_subdirectory(src)
#Release

View File

@ -39,13 +39,13 @@ endif()
#
find_program(QT_LUPDATE NAMES lupdate)
find_program(QT_LRELEASE NAMES lrelease)
if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_en.qm)
execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_en.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_en.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
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.qm)
execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_zh.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_zh.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
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)
@ -86,7 +86,7 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
endforeach(filepath)
#
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.obj)
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.in)
foreach(filepath ${RES_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND resource_files ${filename})

View File

@ -198,5 +198,13 @@
<file>qml/window/CrashWindow.qml</file>
<file>qml/page/T_SplitLayout.qml</file>
<file>qml/window/FluentInitalizrWindow.qml</file>
<file>res/template/CMakeLists.txt.in</file>
<file>res/template/App.qml.in</file>
<file>res/template/logo.ico.in</file>
<file>res/template/main.cpp.in</file>
<file>res/template/main.qml.in</file>
<file>res/template/qml.qrc.in</file>
<file>res/template/en_US.ts.in</file>
<file>res/template/zh_CN.ts.in</file>
</qresource>
</RCC>

View File

@ -102,20 +102,25 @@
<context>
<name>InitalizrHelper</name>
<message>
<location filename="src/helper/InitalizrHelper.cpp" line="15"/>
<location filename="src/helper/InitalizrHelper.cpp" line="48"/>
<source>The name cannot be empty</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/helper/InitalizrHelper.cpp" line="19"/>
<location filename="src/helper/InitalizrHelper.cpp" line="52"/>
<source>The creation path cannot be empty</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/helper/InitalizrHelper.cpp" line="24"/>
<location filename="src/helper/InitalizrHelper.cpp" line="57"/>
<source>The path does not exist</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/helper/InitalizrHelper.cpp" line="63"/>
<source>%1 folder already exists</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ItemsFooter</name>
@ -630,9 +635,9 @@
<name>MainWindow</name>
<message>
<location filename="qml/window/MainWindow.qml" line="24"/>
<location filename="qml/window/MainWindow.qml" line="322"/>
<location filename="qml/window/MainWindow.qml" line="321"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="24"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="322"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="321"/>
<source>Dark Mode</source>
<translation type="unfinished"></translation>
</message>
@ -670,87 +675,87 @@
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="106"/>
<location filename="qml/window/MainWindow.qml" line="351"/>
<location filename="qml/window/MainWindow.qml" line="350"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="106"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="351"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="350"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="118"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="118"/>
<location filename="qml/window/MainWindow.qml" line="117"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="117"/>
<source>Open in Separate Window</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="215"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="215"/>
<location filename="qml/window/MainWindow.qml" line="214"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="214"/>
<source>Click Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="225"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="225"/>
<location filename="qml/window/MainWindow.qml" line="224"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="224"/>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="315"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="315"/>
<source>Finish</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="316"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="316"/>
<source>Finish</source>
<source>Next</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="317"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="317"/>
<source>Next</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="318"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="318"/>
<source>Previous</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="322"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="322"/>
<location filename="qml/window/MainWindow.qml" line="321"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="321"/>
<source>Here you can switch to night mode.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="324"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="324"/>
<location filename="qml/window/MainWindow.qml" line="323"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="323"/>
<source>Hide Easter eggs</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="324"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="324"/>
<location filename="qml/window/MainWindow.qml" line="323"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="323"/>
<source>Try a few more clicks!!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="347"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="347"/>
<source>Upgrade Tips</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="348"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="348"/>
<source>Upgrade Tips</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="349"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="349"/>
<source>FluentUI is currently up to date </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="349"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="349"/>
<location filename="qml/window/MainWindow.qml" line="348"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="348"/>
<source> -- The current app version</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="349"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="349"/>
<location filename="qml/window/MainWindow.qml" line="348"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="348"/>
<source>
Now go and download the new version
@ -759,20 +764,20 @@ Updated content:
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="352"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="352"/>
<location filename="qml/window/MainWindow.qml" line="351"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="351"/>
<source>OK</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="379"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="379"/>
<location filename="qml/window/MainWindow.qml" line="378"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="378"/>
<source>The current version is already the latest</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="386"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="386"/>
<location filename="qml/window/MainWindow.qml" line="385"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="385"/>
<source>The network is abnormal</source>
<translation type="unfinished"></translation>
</message>

View File

@ -102,20 +102,25 @@
<context>
<name>InitalizrHelper</name>
<message>
<location filename="src/helper/InitalizrHelper.cpp" line="15"/>
<location filename="src/helper/InitalizrHelper.cpp" line="48"/>
<source>The name cannot be empty</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/helper/InitalizrHelper.cpp" line="19"/>
<location filename="src/helper/InitalizrHelper.cpp" line="52"/>
<source>The creation path cannot be empty</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/helper/InitalizrHelper.cpp" line="24"/>
<location filename="src/helper/InitalizrHelper.cpp" line="57"/>
<source>The path does not exist</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/helper/InitalizrHelper.cpp" line="63"/>
<source>%1 folder already exists</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ItemsFooter</name>
@ -630,9 +635,9 @@
<name>MainWindow</name>
<message>
<location filename="qml/window/MainWindow.qml" line="24"/>
<location filename="qml/window/MainWindow.qml" line="322"/>
<location filename="qml/window/MainWindow.qml" line="321"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="24"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="322"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="321"/>
<source>Dark Mode</source>
<translation type="unfinished"></translation>
</message>
@ -670,87 +675,87 @@
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="106"/>
<location filename="qml/window/MainWindow.qml" line="351"/>
<location filename="qml/window/MainWindow.qml" line="350"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="106"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="351"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="350"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="118"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="118"/>
<location filename="qml/window/MainWindow.qml" line="117"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="117"/>
<source>Open in Separate Window</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="215"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="215"/>
<location filename="qml/window/MainWindow.qml" line="214"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="214"/>
<source>Click Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="225"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="225"/>
<location filename="qml/window/MainWindow.qml" line="224"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="224"/>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="316"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="316"/>
<location filename="qml/window/MainWindow.qml" line="315"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="315"/>
<source>Finish</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="317"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="317"/>
<location filename="qml/window/MainWindow.qml" line="316"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="316"/>
<source>Next</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="318"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="318"/>
<location filename="qml/window/MainWindow.qml" line="317"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="317"/>
<source>Previous</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="322"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="322"/>
<location filename="qml/window/MainWindow.qml" line="321"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="321"/>
<source>Here you can switch to night mode.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="324"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="324"/>
<location filename="qml/window/MainWindow.qml" line="323"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="323"/>
<source>Hide Easter eggs</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="324"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="324"/>
<location filename="qml/window/MainWindow.qml" line="323"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="323"/>
<source>Try a few more clicks!!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="348"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="348"/>
<location filename="qml/window/MainWindow.qml" line="347"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="347"/>
<source>Upgrade Tips</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="349"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="349"/>
<location filename="qml/window/MainWindow.qml" line="348"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="348"/>
<source>FluentUI is currently up to date </source>
<translation type="unfinished">FluentUI </translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="349"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="349"/>
<location filename="qml/window/MainWindow.qml" line="348"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="348"/>
<source> -- The current app version</source>
<translation type="unfinished"> -- </translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="349"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="349"/>
<location filename="qml/window/MainWindow.qml" line="348"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="348"/>
<source>
Now go and download the new version
@ -763,20 +768,20 @@ Updated content:
</translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="352"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="352"/>
<location filename="qml/window/MainWindow.qml" line="351"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="351"/>
<source>OK</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="379"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="379"/>
<location filename="qml/window/MainWindow.qml" line="378"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="378"/>
<source>The current version is already the latest</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/window/MainWindow.qml" line="386"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="386"/>
<location filename="qml/window/MainWindow.qml" line="385"/>
<location filename="qml-Qt6/window/MainWindow.qml" line="385"/>
<source>The network is abnormal</source>
<translation type="unfinished"></translation>
</message>

View File

@ -12,7 +12,7 @@ FluWindow {
width: 600
height: 400
fixSize: true
// modality: Qt.ApplicationModal
modality: Qt.ApplicationModal
launchMode: FluWindowType.SingleTask
showStayTop: false
@ -21,8 +21,9 @@ FluWindow {
function onError(message){
showError(message)
}
function onSuccess(){
showSuccess("创建成功")
function onSuccess(path){
FluTools.showFileInFolder(path+"/CMakeLists.txt")
window.close()
}
}

View File

@ -12,7 +12,7 @@ FluWindow {
width: 600
height: 400
fixSize: true
// modality: Qt.ApplicationModal
modality: Qt.ApplicationModal
launchMode: FluWindowType.SingleTask
showStayTop: false
@ -21,8 +21,9 @@ FluWindow {
function onError(message){
showError(message)
}
function onSuccess(){
showSuccess("创建成功")
function onSuccess(path){
FluTools.showFileInFolder(path+"/CMakeLists.txt")
window.close()
}
}

View 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("/")
}
}

View 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()

View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

View 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();
}

View 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")
}
}
}
}

View File

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>App.qml</file>
<file>logo.ico</file>
</qresource>
</RCC>

View 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>

View File

@ -1,6 +1,7 @@
#include "InitalizrHelper.h"
#include <QDir>
#include <QGuiApplication>
InitalizrHelper::InitalizrHelper(QObject *parent) : QObject(parent)
{
@ -9,6 +10,63 @@ InitalizrHelper::InitalizrHelper(QObject *parent) : QObject(parent)
InitalizrHelper::~InitalizrHelper() = default;
bool InitalizrHelper::copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists){
QDir _formDir = fromDir;
QDir _toDir = toDir;
if(!_toDir.exists())
{
if(!_toDir.mkdir(toDir.absolutePath()))
return false;
}
QFileInfoList fileInfoList = _formDir.entryInfoList();
foreach(QFileInfo fileInfo, fileInfoList)
{
if(fileInfo.fileName() == "." || fileInfo.fileName() == "..")
continue;
if(fileInfo.isDir())
{
if(!copyDir(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()),true))
return false;
}
else
{
if(coverIfFileExists && _toDir.exists(fileInfo.fileName()))
{
_toDir.remove(fileInfo.fileName());
}
if(!QFile::copy(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName())))
{
return false;
}
}
}
return true;
}
template <typename...Args>
void InitalizrHelper::templateToFile(const QString& source,const QString& dest,Args &&...args){
QFile file(source);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&file);
QString content = in.readAll().arg(std::forward<Args>(args)...);
file.close();
QFile outputFile(dest);
if (outputFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream out(&outputFile);
out << content;
outputFile.close();
} else {
qDebug() << "Failed to open output file.";
}
} else {
qDebug() << "Failed to open resource file.";
}
}
void InitalizrHelper::copyFile(const QString& source,const QString& dest){
QFile::copy(source,dest);
QFile::setPermissions(dest, QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther);
}
void InitalizrHelper::generate(const QString& name,const QString& path){
if(name.isEmpty()){
@ -19,10 +77,27 @@ void InitalizrHelper::generate(const QString& name,const QString& path){
error(tr("The creation path cannot be empty"));
return;
}
QDir projectDir(path);
if(!projectDir.exists()){
QDir projectRootDir(path);
if(!projectRootDir.exists()){
error(tr("The path does not exist"));
return;
}
return success();
QString projectPath = projectRootDir.filePath(name);
QDir projectDir(projectPath);
if(projectDir.exists()){
error(tr("%1 folder already exists").arg(name));
return;
}
projectDir.mkpath(projectPath);
QDir fluentDir(projectDir.filePath("FluentUI"));
copyDir(QDir(QGuiApplication::applicationDirPath()+"/source"),fluentDir);
templateToFile(":/example/res/template/CMakeLists.txt.in",projectDir.filePath("CMakeLists.txt"),name);
templateToFile(":/example/res/template/main.cpp.in",projectDir.filePath("main.cpp"),name);
templateToFile(":/example/res/template/main.qml.in",projectDir.filePath("main.qml"),name);
templateToFile(":/example/res/template/en_US.ts.in",projectDir.filePath(name+"_en_US.ts"),name);
templateToFile(":/example/res/template/zh_CN.ts.in",projectDir.filePath(name+"_zh_CN.ts"),name);
copyFile(":/example/res/template/App.qml.in",projectDir.filePath("App.qml"));
copyFile(":/example/res/template/qml.qrc.in",projectDir.filePath("qml.qrc"));
copyFile(":/example/res/template/logo.ico.in",projectDir.filePath("logo.ico"));
return this->success(projectPath);
}

View File

@ -3,6 +3,7 @@
#include <QObject>
#include <QtQml/qqml.h>
#include <QDir>
#include "src/singleton.h"
class InitalizrHelper : public QObject
@ -10,12 +11,16 @@ class InitalizrHelper : public QObject
Q_OBJECT
private:
explicit InitalizrHelper(QObject* parent = nullptr);
bool copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists = true);
void copyFile(const QString& source,const QString& dest);
template <typename...Args>
void templateToFile(const QString& source,const QString& dest,Args &&...args);
public:
SINGLETON(InitalizrHelper)
~InitalizrHelper() override;
Q_INVOKABLE void generate(const QString& name,const QString& path);
Q_SIGNAL void error(const QString& message);
Q_SIGNAL void success();
Q_SIGNAL void success(const QString& path);
};
#endif // INITALIZRHELPER_H

View File

@ -7,8 +7,8 @@
TranslateHelper::TranslateHelper(QObject *parent) : QObject(parent)
{
_languages<<"en";
_languages<<"zh";
_languages<<"en_US";
_languages<<"zh_CN";
_current = SettingsHelper::getInstance()->getLanguage();
}

View File

@ -1,6 +1,13 @@
1 VERSIONINFO
FILEVERSION ${GIT_TAG_WITH_COMMA},${GIT_COMMIT_COUNT}
PRODUCTVERSION ${GIT_TAG_WITH_COMMA},${GIT_COMMIT_COUNT}
#include <windows.h>
#define STR(x) #x
#define VER_JOIN(a,b,c,d) STR(a.b.c.d)
#define VER_JOIN_(x) VER_JOIN x
#define VER_STR VER_JOIN_((FLUENTUI_VERSION))
VS_VERSION_INFO VERSIONINFO
FILEVERSION FLUENTUI_VERSION
PRODUCTVERSION FLUENTUI_VERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -16,13 +23,13 @@ BEGIN
BLOCK "080404b0"
BEGIN
VALUE "CompanyName", "ZhuZiChu"
VALUE "FileDescription", "${PROJECT_DESCRIPTION}"
VALUE "FileVersion", "${GIT_SEMVER}.${GIT_COMMIT_COUNT}"
VALUE "FileDescription", "https://github.com/zhuzichu520/FluentUI"
VALUE "FileVersion", VER_STR
VALUE "InternalName", "${PROJECT_NAME}.dll"
VALUE "LegalCopyright", "Copyright (C) 2023 ZhuZiChu. All rights reserved."
VALUE "OriginalFilename", "${PROJECT_NAME}.dll"
VALUE "ProductName", "${PROJECT_NAME}"
VALUE "ProductVersion", "${GIT_SEMVER}.0"
VALUE "ProductVersion", VER_STR
END
END
BLOCK "VarFileInfo"

View File

@ -12,14 +12,29 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.cmake/)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#
add_definitions(-DFLUENTUI_VERSION=1,6,9,0)
if (FLUENTUI_BUILD_STATIC_LIB)
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
endif()
#
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
#Qt
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick Qml)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick Qml)
set(QT_SDK_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../..")
cmake_path(SET QT_SDK_DIR NORMALIZE ${QT_SDK_DIR})
#QML<QT_SDK_DIR_PATH>\qml\FluentUI
set(FLUENTUI_QML_PLUGIN_DIRECTORY "" CACHE PATH "Path to FluentUI plugin")
if(NOT FLUENTUI_QML_PLUGIN_DIRECTORY)
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${QT_SDK_DIR}/qml/FluentUI)
endif()
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
qt_standard_project_setup()
else()