mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-22 19:00:07 +08:00
update
This commit is contained in:
parent
099e966d9b
commit
d420282dd8
@ -199,12 +199,13 @@
|
||||
<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>
|
||||
<file>res/template/src/App.qml.in</file>
|
||||
<file>res/template/src/CMakeLists.txt.in</file>
|
||||
<file>res/template/src/en_US.ts.in</file>
|
||||
<file>res/template/src/logo.ico.in</file>
|
||||
<file>res/template/src/main.cpp.in</file>
|
||||
<file>res/template/src/main.qml.in</file>
|
||||
<file>res/template/src/qml.qrc.in</file>
|
||||
<file>res/template/src/zh_CN.ts.in</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -1,90 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(%1 VERSION 0.1 LANGUAGES CXX)
|
||||
project(%1 VERSION 1.0)
|
||||
|
||||
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
|
||||
)
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
|
||||
|
||||
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()
|
||||
add_subdirectory(src)
|
88
example/res/template/src/CMakeLists.txt.in
Normal file
88
example/res/template/src/CMakeLists.txt.in
Normal file
@ -0,0 +1,88 @@
|
||||
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
|
||||
)
|
||||
|
||||
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()
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
@ -50,6 +50,10 @@ void InitalizrHelper::templateToFile(const QString& source,const QString& dest,A
|
||||
QTextStream in(&file);
|
||||
QString content = in.readAll().arg(std::forward<Args>(args)...);
|
||||
file.close();
|
||||
QDir outputDir = QFileInfo(dest).absoluteDir();
|
||||
if(!outputDir.exists()){
|
||||
outputDir.mkpath(outputDir.absolutePath());
|
||||
}
|
||||
QFile outputFile(dest);
|
||||
if (outputFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QTextStream out(&outputFile);
|
||||
@ -92,12 +96,13 @@ void InitalizrHelper::generate(const QString& name,const QString& path){
|
||||
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"));
|
||||
templateToFile(":/example/res/template/src/CMakeLists.txt.in",projectDir.filePath("src/CMakeLists.txt"),name);
|
||||
templateToFile(":/example/res/template/src/main.cpp.in",projectDir.filePath("src/main.cpp"),name);
|
||||
templateToFile(":/example/res/template/src/main.qml.in",projectDir.filePath("src/main.qml"),name);
|
||||
templateToFile(":/example/res/template/src/en_US.ts.in",projectDir.filePath("src/"+name+"_en_US.ts"),name);
|
||||
templateToFile(":/example/res/template/src/zh_CN.ts.in",projectDir.filePath("src/"+name+"_zh_CN.ts"),name);
|
||||
copyFile(":/example/res/template/src/App.qml.in",projectDir.filePath("src/App.qml"));
|
||||
copyFile(":/example/res/template/src/qml.qrc.in",projectDir.filePath("src/qml.qrc"));
|
||||
copyFile(":/example/res/template/src/logo.ico.in",projectDir.filePath("src/logo.ico"));
|
||||
return this->success(projectPath);
|
||||
}
|
||||
|
@ -7,16 +7,44 @@ FluTextBox{
|
||||
property var items:[]
|
||||
property string emptyText: qsTr("No results found")
|
||||
property int autoSuggestBoxReplacement: FluentIcons.Search
|
||||
property var filter: function(item){
|
||||
if(item.title.indexOf(control.text)!==-1){
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
signal itemClicked(var data)
|
||||
signal handleClicked
|
||||
id:control
|
||||
Component.onCompleted: {
|
||||
loadData()
|
||||
d.loadData()
|
||||
}
|
||||
Item{
|
||||
id:d
|
||||
property bool flagVisible: true
|
||||
property var window : Window.window
|
||||
function handleClick(modelData){
|
||||
control_popup.visible = false
|
||||
control.itemClicked(modelData)
|
||||
d.updateText(modelData.title)
|
||||
}
|
||||
function updateText(text){
|
||||
d.flagVisible = false
|
||||
control.text = text
|
||||
d.flagVisible = true
|
||||
}
|
||||
function loadData(){
|
||||
var result = []
|
||||
if(items==null){
|
||||
list_view.model = result
|
||||
return
|
||||
}
|
||||
items.map(function(item){
|
||||
if(control.filter(item)){
|
||||
result.push(item)
|
||||
}
|
||||
})
|
||||
list_view.model = result
|
||||
}
|
||||
}
|
||||
onActiveFocusChanged: {
|
||||
if(!activeFocus){
|
||||
@ -66,7 +94,7 @@ FluTextBox{
|
||||
height: 38
|
||||
width: control.width
|
||||
onClicked:{
|
||||
handleClick(modelData)
|
||||
d.handleClick(modelData)
|
||||
}
|
||||
background: Rectangle{
|
||||
FluFocusRectangle{
|
||||
@ -96,7 +124,7 @@ FluTextBox{
|
||||
}
|
||||
}
|
||||
onTextChanged: {
|
||||
loadData()
|
||||
d.loadData()
|
||||
if(d.flagVisible){
|
||||
var pos = control.mapToItem(null, 0, 0)
|
||||
if(d.window.height>pos.y+control.height+container.implicitHeight){
|
||||
@ -109,27 +137,4 @@ FluTextBox{
|
||||
control_popup.visible = true
|
||||
}
|
||||
}
|
||||
function handleClick(modelData){
|
||||
control_popup.visible = false
|
||||
control.itemClicked(modelData)
|
||||
updateText(modelData.title)
|
||||
}
|
||||
function updateText(text){
|
||||
d.flagVisible = false
|
||||
control.text = text
|
||||
d.flagVisible = true
|
||||
}
|
||||
function loadData(){
|
||||
var result = []
|
||||
if(items==null){
|
||||
list_view.model = result
|
||||
return
|
||||
}
|
||||
items.map(function(item){
|
||||
if(item.title.indexOf(control.text)!==-1){
|
||||
result.push(item)
|
||||
}
|
||||
})
|
||||
list_view.model = result
|
||||
}
|
||||
}
|
||||
|
@ -6,16 +6,44 @@ FluTextBox{
|
||||
property var items:[]
|
||||
property string emptyText: qsTr("No results found")
|
||||
property int autoSuggestBoxReplacement: FluentIcons.Search
|
||||
property var filter: function(item){
|
||||
if(item.title.indexOf(control.text)!==-1){
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
signal itemClicked(var data)
|
||||
signal handleClicked
|
||||
id:control
|
||||
Component.onCompleted: {
|
||||
loadData()
|
||||
d.loadData()
|
||||
}
|
||||
Item{
|
||||
id:d
|
||||
property bool flagVisible: true
|
||||
property var window : Window.window
|
||||
function handleClick(modelData){
|
||||
control_popup.visible = false
|
||||
control.itemClicked(modelData)
|
||||
d.updateText(modelData.title)
|
||||
}
|
||||
function updateText(text){
|
||||
d.flagVisible = false
|
||||
control.text = text
|
||||
d.flagVisible = true
|
||||
}
|
||||
function loadData(){
|
||||
var result = []
|
||||
if(items==null){
|
||||
list_view.model = result
|
||||
return
|
||||
}
|
||||
items.map(function(item){
|
||||
if(control.filter(item)){
|
||||
result.push(item)
|
||||
}
|
||||
})
|
||||
list_view.model = result
|
||||
}
|
||||
}
|
||||
onActiveFocusChanged: {
|
||||
if(!activeFocus){
|
||||
@ -65,7 +93,7 @@ FluTextBox{
|
||||
height: 38
|
||||
width: control.width
|
||||
onClicked:{
|
||||
handleClick(modelData)
|
||||
d.handleClick(modelData)
|
||||
}
|
||||
background: Rectangle{
|
||||
FluFocusRectangle{
|
||||
@ -95,7 +123,7 @@ FluTextBox{
|
||||
}
|
||||
}
|
||||
onTextChanged: {
|
||||
loadData()
|
||||
d.loadData()
|
||||
if(d.flagVisible){
|
||||
var pos = control.mapToItem(null, 0, 0)
|
||||
if(d.window.height>pos.y+control.height+container.implicitHeight){
|
||||
@ -108,27 +136,4 @@ FluTextBox{
|
||||
control_popup.visible = true
|
||||
}
|
||||
}
|
||||
function handleClick(modelData){
|
||||
control_popup.visible = false
|
||||
control.itemClicked(modelData)
|
||||
updateText(modelData.title)
|
||||
}
|
||||
function updateText(text){
|
||||
d.flagVisible = false
|
||||
control.text = text
|
||||
d.flagVisible = true
|
||||
}
|
||||
function loadData(){
|
||||
var result = []
|
||||
if(items==null){
|
||||
list_view.model = result
|
||||
return
|
||||
}
|
||||
items.map(function(item){
|
||||
if(item.title.indexOf(control.text)!==-1){
|
||||
result.push(item)
|
||||
}
|
||||
})
|
||||
list_view.model = result
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user