diff --git a/example/example.qrc b/example/example.qrc
index c0cd9886..135e4636 100644
--- a/example/example.qrc
+++ b/example/example.qrc
@@ -199,12 +199,13 @@
qml/page/T_SplitLayout.qml
qml/window/FluentInitalizrWindow.qml
res/template/CMakeLists.txt.in
- res/template/App.qml.in
- res/template/logo.ico.in
- res/template/main.cpp.in
- res/template/main.qml.in
- res/template/qml.qrc.in
- res/template/en_US.ts.in
- res/template/zh_CN.ts.in
+ res/template/src/App.qml.in
+ res/template/src/CMakeLists.txt.in
+ res/template/src/en_US.ts.in
+ res/template/src/logo.ico.in
+ res/template/src/main.cpp.in
+ res/template/src/main.qml.in
+ res/template/src/qml.qrc.in
+ res/template/src/zh_CN.ts.in
diff --git a/example/res/template/CMakeLists.txt.in b/example/res/template/CMakeLists.txt.in
index 2d0ea5cf..9bda95e9 100644
--- a/example/res/template/CMakeLists.txt.in
+++ b/example/res/template/CMakeLists.txt.in
@@ -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)
\ No newline at end of file
diff --git a/example/res/template/App.qml.in b/example/res/template/src/App.qml.in
similarity index 100%
rename from example/res/template/App.qml.in
rename to example/res/template/src/App.qml.in
diff --git a/example/res/template/src/CMakeLists.txt.in b/example/res/template/src/CMakeLists.txt.in
new file mode 100644
index 00000000..a6278bf3
--- /dev/null
+++ b/example/res/template/src/CMakeLists.txt.in
@@ -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()
diff --git a/example/res/template/en_US.ts.in b/example/res/template/src/en_US.ts.in
similarity index 100%
rename from example/res/template/en_US.ts.in
rename to example/res/template/src/en_US.ts.in
diff --git a/example/res/template/logo.ico.in b/example/res/template/src/logo.ico.in
similarity index 100%
rename from example/res/template/logo.ico.in
rename to example/res/template/src/logo.ico.in
diff --git a/example/res/template/main.cpp.in b/example/res/template/src/main.cpp.in
similarity index 100%
rename from example/res/template/main.cpp.in
rename to example/res/template/src/main.cpp.in
diff --git a/example/res/template/main.qml.in b/example/res/template/src/main.qml.in
similarity index 100%
rename from example/res/template/main.qml.in
rename to example/res/template/src/main.qml.in
diff --git a/example/res/template/qml.qrc.in b/example/res/template/src/qml.qrc.in
similarity index 100%
rename from example/res/template/qml.qrc.in
rename to example/res/template/src/qml.qrc.in
diff --git a/example/res/template/zh_CN.ts.in b/example/res/template/src/zh_CN.ts.in
similarity index 100%
rename from example/res/template/zh_CN.ts.in
rename to example/res/template/src/zh_CN.ts.in
diff --git a/example/src/helper/InitalizrHelper.cpp b/example/src/helper/InitalizrHelper.cpp
index 74271b7e..0e4d285a 100644
--- a/example/src/helper/InitalizrHelper.cpp
+++ b/example/src/helper/InitalizrHelper.cpp
@@ -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)...);
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);
}
diff --git a/src/Qt5/imports/FluentUI/Controls/FluAutoSuggestBox.qml b/src/Qt5/imports/FluentUI/Controls/FluAutoSuggestBox.qml
index 54ab28f5..2e1dcf9c 100644
--- a/src/Qt5/imports/FluentUI/Controls/FluAutoSuggestBox.qml
+++ b/src/Qt5/imports/FluentUI/Controls/FluAutoSuggestBox.qml
@@ -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
- }
}
diff --git a/src/Qt6/imports/FluentUI/Controls/FluAutoSuggestBox.qml b/src/Qt6/imports/FluentUI/Controls/FluAutoSuggestBox.qml
index 6d089c69..0aaa8e03 100644
--- a/src/Qt6/imports/FluentUI/Controls/FluAutoSuggestBox.qml
+++ b/src/Qt6/imports/FluentUI/Controls/FluAutoSuggestBox.qml
@@ -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
- }
}