Compare commits
171 Commits
Author | SHA1 | Date | |
---|---|---|---|
73518fb831 | |||
312aebae73 | |||
3c349da98f | |||
dba7332d89 | |||
3fefb08140 | |||
1c69d5daab | |||
ec76240aed | |||
0a967ca47b | |||
8dbbf4e547 | |||
ebad24e809 | |||
b7acae1470 | |||
f8340bdf59 | |||
e4fb9989d0 | |||
9bd98c68e4 | |||
7cd9b7c6bc | |||
dde817923c | |||
ceaae1276e | |||
29c57bcdc3 | |||
7ba60ee570 | |||
f531f5b138 | |||
4f27ff41b9 | |||
42f058ca69 | |||
502044ebd2 | |||
5d902dc66e | |||
b22e79148b | |||
7122407b0b | |||
be7b2dcc34 | |||
db805ef85d | |||
d0e283747e | |||
2d8a05f310 | |||
2d855e1aaa | |||
56188cfa51 | |||
169ca17a6a | |||
e4908e409b | |||
f141af154a | |||
10da873701 | |||
c23c0b5f42 | |||
4d78262277 | |||
2b88634c2f | |||
59f9495f31 | |||
29329d10df | |||
d014997d52 | |||
98e0aafb44 | |||
4b3548563b | |||
47c84ed60e | |||
d5ca38dec2 | |||
cb50c31e1e | |||
561b4ec8c0 | |||
4df6800ea4 | |||
1ecc1bd569 | |||
0810572e27 | |||
5ac0ba7463 | |||
596457cf59 | |||
8595b2fdec | |||
2337680aaf | |||
ba06480436 | |||
0d87dadc61 | |||
7290b98fdb | |||
78815224fe | |||
6275c161fe | |||
9f24cdaebd | |||
e2ff752ed9 | |||
ea88707366 | |||
112bb6e07a | |||
26ad581072 | |||
03771cd7c9 | |||
9223d5f937 | |||
a273aa4588 | |||
fbcb65f549 | |||
082fd79c51 | |||
80619f6974 | |||
ad4d077480 | |||
ff93a6204a | |||
5a7dfeea6e | |||
0240244bba | |||
887fd2c02b | |||
e625b91b08 | |||
a5cf6f734b | |||
414bc14996 | |||
7276eb5f2f | |||
b6c689e0ec | |||
a48bc51edc | |||
b2d0975ed7 | |||
7dea573069 | |||
0d4dd483da | |||
d1656cfb63 | |||
73cc5bccc8 | |||
9ff81251c8 | |||
74940665ae | |||
21ddc79f3f | |||
64bbae9266 | |||
bbb6fe9329 | |||
c42f3ef70f | |||
f13f1727af | |||
9f9e48659b | |||
294606d019 | |||
bfa5c93d40 | |||
9656b3dd95 | |||
8a52f143d7 | |||
dc3b1acaa5 | |||
1a8d06331f | |||
d09414db1b | |||
bf3006415b | |||
cdba8b7921 | |||
192c65a510 | |||
90943674b3 | |||
157dc9166b | |||
a7e8a5e4cf | |||
96071ac8d7 | |||
e25b944704 | |||
1566e3934e | |||
16e71f01b1 | |||
e54c161aa6 | |||
2147965b00 | |||
3a940466d5 | |||
564b27cd02 | |||
4be2ad6ba0 | |||
1d9f6f5eff | |||
0610f63f26 | |||
d741b3eb4f | |||
cb7d2097f2 | |||
dff77d3d4f | |||
6d0834c653 | |||
059a1b17cc | |||
e1096b8e22 | |||
cd577c5599 | |||
d43532986a | |||
4c9e576072 | |||
b254064e26 | |||
ffd8072826 | |||
9a1db0b230 | |||
9786e69fc2 | |||
82be3b12e3 | |||
1c0f5acaf8 | |||
243f8aa248 | |||
cbb8c3122b | |||
9f2c58306c | |||
adc3558e02 | |||
98d73eb6cb | |||
b442696f92 | |||
82f606dd65 | |||
4efb91084a | |||
103dbe9d56 | |||
b829fa572f | |||
d2c5cc779b | |||
5acf664492 | |||
75d226947f | |||
752ff3c4f2 | |||
e591c483d5 | |||
fdff068752 | |||
24f28d8945 | |||
ed51143e9b | |||
9d94bc65d5 | |||
7bfa9f0191 | |||
6db144c751 | |||
a574cd9230 | |||
8c45c125e6 | |||
aab4802d7e | |||
441c1ab03c | |||
91f4f508cc | |||
94f8047508 | |||
d926a84f72 | |||
c07011408c | |||
4f9ec6abf2 | |||
c3b3dc904e | |||
2a5acb45a1 | |||
d29580f8f2 | |||
fd0ddbf5aa | |||
ac602c5afa | |||
8dbfcfd994 | |||
c5ce34cbc3 |
308
.cmake/GetGitRevisionDescription.cmake
Normal file
@ -0,0 +1,308 @@
|
|||||||
|
if(__get_git_revision_description)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(__get_git_revision_description YES)
|
||||||
|
|
||||||
|
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||||
|
|
||||||
|
function(_git_find_closest_git_dir _start_dir _git_dir_var)
|
||||||
|
set(cur_dir "${_start_dir}")
|
||||||
|
set(git_dir "${_start_dir}/.git")
|
||||||
|
while(NOT EXISTS "${git_dir}")
|
||||||
|
set(git_previous_parent "${cur_dir}")
|
||||||
|
get_filename_component(cur_dir ${cur_dir} DIRECTORY)
|
||||||
|
if(cur_dir STREQUAL git_previous_parent)
|
||||||
|
set(${_git_dir_var}
|
||||||
|
""
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(git_dir "${cur_dir}/.git")
|
||||||
|
endwhile()
|
||||||
|
set(${_git_dir_var}
|
||||||
|
"${git_dir}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(get_git_head_revision _refspecvar _hashvar)
|
||||||
|
_git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)
|
||||||
|
|
||||||
|
if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR")
|
||||||
|
set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE)
|
||||||
|
else()
|
||||||
|
set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE)
|
||||||
|
endif()
|
||||||
|
if(NOT "${GIT_DIR}" STREQUAL "")
|
||||||
|
file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}"
|
||||||
|
"${GIT_DIR}")
|
||||||
|
if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)
|
||||||
|
set(GIT_DIR "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if("${GIT_DIR}" STREQUAL "")
|
||||||
|
set(${_refspecvar}
|
||||||
|
"GITDIR-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
set(${_hashvar}
|
||||||
|
"GITDIR-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT IS_DIRECTORY ${GIT_DIR})
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" rev-parse
|
||||||
|
--show-superproject-working-tree
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT "${out}" STREQUAL "")
|
||||||
|
file(READ ${GIT_DIR} submodule)
|
||||||
|
string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE
|
||||||
|
${submodule})
|
||||||
|
string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE)
|
||||||
|
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
||||||
|
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE}
|
||||||
|
ABSOLUTE)
|
||||||
|
set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
|
||||||
|
else()
|
||||||
|
file(READ ${GIT_DIR} worktree_ref)
|
||||||
|
string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir
|
||||||
|
${worktree_ref})
|
||||||
|
string(STRIP ${git_worktree_dir} git_worktree_dir)
|
||||||
|
_git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR)
|
||||||
|
set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
|
||||||
|
endif()
|
||||||
|
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||||
|
if(NOT EXISTS "${GIT_DATA}")
|
||||||
|
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS "${HEAD_SOURCE_FILE}")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||||
|
configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY)
|
||||||
|
|
||||||
|
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||||
|
"${GIT_DATA}/grabRef.cmake" @ONLY)
|
||||||
|
include("${GIT_DATA}/grabRef.cmake")
|
||||||
|
|
||||||
|
set(${_refspecvar}
|
||||||
|
"${HEAD_REF}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
set(${_hashvar}
|
||||||
|
"${HEAD_HASH}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_latest_tag _var)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
find_package(Git QUIET)
|
||||||
|
endif()
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
set(${_var}
|
||||||
|
"GIT-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" describe --abbrev=0 --tag
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE res
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT res EQUAL 0)
|
||||||
|
set(out "GIT-TAG-NOTFOUND")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${_var}
|
||||||
|
"${out}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_commit_counts _var)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
find_package(Git QUIET)
|
||||||
|
endif()
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
set(${_var}
|
||||||
|
"GIT-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" rev-list HEAD --count
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE res
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT res EQUAL 0)
|
||||||
|
set(out "GIT-TAG-NOTFOUND")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${_var}
|
||||||
|
"${out}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_describe _var)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
find_package(Git QUIET)
|
||||||
|
endif()
|
||||||
|
get_git_head_revision(refspec hash ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
set(${_var}
|
||||||
|
"GIT-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
if(NOT hash)
|
||||||
|
set(${_var}
|
||||||
|
"HEAD-HASH-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN}
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE res
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT res EQUAL 0)
|
||||||
|
set(out "${out}-${res}-NOTFOUND")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${_var}
|
||||||
|
"${out}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_release_version _var)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
find_package(Git QUIET)
|
||||||
|
endif()
|
||||||
|
get_git_head_revision(refspec hash ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
set(${_var}
|
||||||
|
"GIT-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
if(NOT hash)
|
||||||
|
set(${_var}
|
||||||
|
"HEAD-HASH-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" symbolic-ref --short -q HEAD
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE res
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT res EQUAL 0)
|
||||||
|
set(out "${out}-${res}-NOTFOUND")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(FIND ${out} "release/" found})
|
||||||
|
if(${out} MATCHES "^release/.+$")
|
||||||
|
string(REPLACE "release/" "" tmp_out ${out})
|
||||||
|
set(${_var} "${tmp_out}" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${_var} "" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_describe_working_tree _var)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
find_package(Git QUIET)
|
||||||
|
endif()
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
set(${_var}
|
||||||
|
"GIT-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN}
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE res
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT res EQUAL 0)
|
||||||
|
set(out "${out}-${res}-NOTFOUND")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${_var}
|
||||||
|
"${out}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_get_exact_tag _var)
|
||||||
|
git_describe(out --exact-match ${ARGN})
|
||||||
|
set(${_var}
|
||||||
|
"${out}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_local_changes _var)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
find_package(Git QUIET)
|
||||||
|
endif()
|
||||||
|
get_git_head_revision(refspec hash)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
set(${_var}
|
||||||
|
"GIT-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
if(NOT hash)
|
||||||
|
set(${_var}
|
||||||
|
"HEAD-HASH-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD --
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE res
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(res EQUAL 0)
|
||||||
|
set(${_var}
|
||||||
|
"CLEAN"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${_var}
|
||||||
|
"DIRTY"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
git_release_version(GIT_TAG)
|
||||||
|
git_get_exact_tag(GIT_EXACT_TAG)
|
||||||
|
if(GIT_TAG STREQUAL "")
|
||||||
|
git_latest_tag(GIT_TAG)
|
||||||
|
endif()
|
||||||
|
if(GIT_TAG STREQUAL "GIT-TAG-NOTFOUND")
|
||||||
|
set(GIT_TAG "1.0.0")
|
||||||
|
endif ()
|
||||||
|
git_describe(GIT_DESCRIBE)
|
||||||
|
git_commit_counts(GIT_COMMIT_COUNT)
|
||||||
|
string(REPLACE "." "," GIT_TAG_WITH_COMMA ${GIT_TAG})
|
||||||
|
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" GIT_SEMVER "${GIT_TAG}")
|
||||||
|
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" SEMVER_SPLITED "${GIT_SEMVER}")
|
||||||
|
set(MAJOR_VERSION ${CMAKE_MATCH_1})
|
||||||
|
set(MINOR_VERSION ${CMAKE_MATCH_2})
|
||||||
|
set(PATCH_VERSION ${CMAKE_MATCH_3})
|
||||||
|
MATH(EXPR VERSION_COUNTER "${MAJOR_VERSION} * 10000 + ${MINOR_VERSION} * 100 + ${PATCH_VERSION}")
|
||||||
|
message(STATUS "Current git tag: ${GIT_TAG}, commit count: ${GIT_COMMIT_COUNT}, describe: ${GIT_DESCRIBE}")
|
||||||
|
message(STATUS "Current semver: major: ${MAJOR_VERSION}, minor: ${MINOR_VERSION}, patch: ${PATCH_VERSION}, counter: ${VERSION_COUNTER}")
|
43
.cmake/GetGitRevisionDescription.cmake.in
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#
|
||||||
|
# Internal file for GetGitRevisionDescription.cmake
|
||||||
|
#
|
||||||
|
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright 2009-2012, Iowa State University
|
||||||
|
# Copyright 2011-2015, Contributors
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
# SPDX-License-Identifier: BSL-1.0
|
||||||
|
|
||||||
|
set(HEAD_HASH)
|
||||||
|
|
||||||
|
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
||||||
|
|
||||||
|
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
||||||
|
if(HEAD_CONTENTS MATCHES "ref")
|
||||||
|
# named branch
|
||||||
|
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
||||||
|
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
||||||
|
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||||
|
else()
|
||||||
|
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
|
||||||
|
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
|
||||||
|
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
|
||||||
|
set(HEAD_HASH "${CMAKE_MATCH_1}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# detached HEAD
|
||||||
|
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT HEAD_HASH)
|
||||||
|
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
||||||
|
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
||||||
|
endif()
|
12
.cmake/Version.h.in
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// 应用程序版本信息
|
||||||
|
// 请勿修改此头文件,因为这个文件是自动生成的
|
||||||
|
#ifndef VERSION_H
|
||||||
|
#define VERSION_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#define APPLICATION_VERSION "${GIT_SEMVER}.${GIT_COMMIT_COUNT}"
|
||||||
|
#define VERSION_COUNTER ${GIT_COMMIT_COUNT}
|
||||||
|
#define COMMIT_HASH "${GIT_DESCRIBE}"
|
||||||
|
|
||||||
|
#endif // VERSION_H
|
32
.cmake/version_dll.rc.in
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
1 VERSIONINFO
|
||||||
|
FILEVERSION ${GIT_TAG_WITH_COMMA},${GIT_COMMIT_COUNT}
|
||||||
|
PRODUCTVERSION ${GIT_TAG_WITH_COMMA},${GIT_COMMIT_COUNT}
|
||||||
|
FILEFLAGSMASK 0x3fL
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x40004L
|
||||||
|
FILETYPE 0x2L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "080404b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "CompanyName", "ZhuZiChu"
|
||||||
|
VALUE "FileDescription", "${PROJECT_DESCRIPTION}"
|
||||||
|
VALUE "FileVersion", "${GIT_SEMVER}.${GIT_COMMIT_COUNT}"
|
||||||
|
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"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x804, 1200
|
||||||
|
END
|
||||||
|
END
|
34
.cmake/version_exe.rc.in
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
1 VERSIONINFO
|
||||||
|
FILEVERSION ${GIT_TAG_WITH_COMMA},${GIT_COMMIT_COUNT}
|
||||||
|
PRODUCTVERSION ${GIT_TAG_WITH_COMMA},${GIT_COMMIT_COUNT}
|
||||||
|
FILEFLAGSMASK 0x3fL
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x40004L
|
||||||
|
FILETYPE 0x2L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "080404b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "CompanyName", "ZhuZiChu"
|
||||||
|
VALUE "FileDescription", "${PROJECT_DESCRIPTION}"
|
||||||
|
VALUE "FileVersion", "${GIT_SEMVER}.${GIT_COMMIT_COUNT}"
|
||||||
|
VALUE "InternalName", "${PROJECT_NAME}.exe"
|
||||||
|
VALUE "LegalCopyright", "Copyright (C) 2023 ZhuZiChu. All rights reserved."
|
||||||
|
VALUE "OriginalFilename", "${PROJECT_NAME}.exe"
|
||||||
|
VALUE "ProductName", "${PROJECT_NAME}"
|
||||||
|
VALUE "ProductVersion", "${GIT_SEMVER}.0"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x804, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
IDI_ICON1 ICON DISCARDABLE "${CMAKE_SOURCE_DIR}/example/favicon.ico"
|
3
.gitignore
vendored
@ -31,9 +31,10 @@ target_wrapper.*
|
|||||||
# QtCreator CMake
|
# QtCreator CMake
|
||||||
CMakeLists.txt.user*
|
CMakeLists.txt.user*
|
||||||
|
|
||||||
src/build-preset/plugins.qmltypes
|
|
||||||
bin
|
bin
|
||||||
.DS_Store
|
.DS_Store
|
||||||
build
|
build
|
||||||
cmake-build-*
|
cmake-build-*
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
example/Version.h
|
3
.gitmodules
vendored
@ -1,3 +1,6 @@
|
|||||||
[submodule "framelesshelper"]
|
[submodule "framelesshelper"]
|
||||||
path = framelesshelper
|
path = framelesshelper
|
||||||
url = https://github.com/zhuzichu520/framelesshelper.git
|
url = https://github.com/zhuzichu520/framelesshelper.git
|
||||||
|
[submodule "zxing-cpp"]
|
||||||
|
path = zxing-cpp
|
||||||
|
url = https://github.com/zhuzichu520/zxing-cpp.git
|
@ -2,9 +2,39 @@ cmake_minimum_required(VERSION 3.20)
|
|||||||
|
|
||||||
project(FluentUI VERSION 0.1 LANGUAGES CXX)
|
project(FluentUI VERSION 0.1 LANGUAGES CXX)
|
||||||
|
|
||||||
add_subdirectory(src)
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/.cmake/")
|
||||||
add_subdirectory(example)
|
|
||||||
|
|
||||||
add_definitions(-DFRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT)
|
include(GetGitRevisionDescription)
|
||||||
add_definitions(-DFRAMELESSHELPER_QUICK_NO_DEBUG_OUTPUT)
|
|
||||||
add_subdirectory(framelesshelper)
|
option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
|
||||||
|
option(FLUENTUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
|
||||||
|
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
|
||||||
|
|
||||||
|
#设置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 ${CMAKE_PREFIX_PATH}/qml/FluentUI)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
add_subdirectory(zxing-cpp)
|
||||||
|
|
||||||
|
if (FLUENTUI_BUILD_EXAMPLES)
|
||||||
|
add_subdirectory(example)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (FLUENTUI_BUILD_FRAMELESSHEPLER)
|
||||||
|
set(FRAMELESSHELPER_BUILD_STATIC ON)
|
||||||
|
set(FRAMELESSHELPER_NO_SUMMARY OFF)
|
||||||
|
set(FRAMELESSHELPER_NO_DEBUG_OUTPUT OFF)
|
||||||
|
set(FRAMELESSHELPER_BUILD_WIDGETS OFF)
|
||||||
|
add_definitions(-DFRAMELESSHELPER_CORE_NO_DEBUG_OUTPUT)
|
||||||
|
add_definitions(-DFRAMELESSHELPER_QUICK_NO_DEBUG_OUTPUT)
|
||||||
|
add_subdirectory(framelesshelper)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
message("------------------------ FluentUI ------------------------")
|
||||||
|
message("Build FluentUI demo applications.: ${FLUENTUI_BUILD_EXAMPLES}")
|
||||||
|
message("Build FramelessHelper.: ${FLUENTUI_BUILD_FRAMELESSHEPLER}")
|
||||||
|
message("Build static library.: ${FLUENTUI_BUILD_STATIC_LIB}")
|
||||||
|
message("Path to FluentUI plugin.: ${FLUENTUI_QML_PLUGIN_DIRECTORY}")
|
||||||
|
@ -115,5 +115,9 @@ View more [`here`](doc/md/all_components.md)!
|
|||||||
|
|
||||||
This FluentUI library currently licensed under [MIT License](./License)
|
This FluentUI library currently licensed under [MIT License](./License)
|
||||||
|
|
||||||
|
## Star History
|
||||||
|
|
||||||
|
[](https://star-history.com/#zhuzichu520/FluentUI&Date)
|
||||||
|
|
||||||
## ⚡ Visitor count
|
## ⚡ Visitor count
|
||||||

|

|
||||||
|
0
doc/preview/demo_content_dialog.png
Executable file → Normal file
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
0
doc/preview/demo_filledbtn.png
Executable file → Normal file
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
0
doc/preview/demo_icon.png
Executable file → Normal file
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
0
doc/preview/demo_infobar.png
Executable file → Normal file
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
0
doc/preview/demo_large.png
Executable file → Normal file
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 192 KiB |
0
doc/preview/demo_multiline_textbox.png
Executable file → Normal file
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
0
doc/preview/demo_progress_bar_ring.png
Executable file → Normal file
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
0
doc/preview/demo_radiobtn.png
Executable file → Normal file
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
0
doc/preview/demo_rectangle.png
Executable file → Normal file
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
0
doc/preview/demo_slider.png
Executable file → Normal file
Before Width: | Height: | Size: 997 B After Width: | Height: | Size: 997 B |
0
doc/preview/demo_standardbtn.png
Executable file → Normal file
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
0
doc/preview/demo_textbox.png
Executable file → Normal file
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
0
doc/preview/demo_textbtn.png
Executable file → Normal file
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
0
doc/preview/demo_toggle_switch.png
Executable file → Normal file
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
0
doc/preview/demo_tooltip.png
Executable file → Normal file
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
0
doc/preview/demo_tree_view.png
Executable file → Normal file
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
0
doc/preview/qt_creator_project.png
Executable file → Normal file
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
@ -3,12 +3,19 @@ cmake_minimum_required(VERSION 3.20)
|
|||||||
project(example VERSION 0.1 LANGUAGES CXX)
|
project(example VERSION 0.1 LANGUAGES CXX)
|
||||||
|
|
||||||
#配置通用编译
|
#配置通用编译
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#导入exmaple的QML位置,不然import example有时候会爆红
|
||||||
|
set(QML_IMPORT_PATH ${CMAKE_BINARY_DIR}/example CACHE STRING "Qt Creator extra QML import paths" FORCE)
|
||||||
|
|
||||||
|
#判断FluentUI库类型
|
||||||
|
if(FLUENTUI_BUILD_STATIC_LIB)
|
||||||
|
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
|
||||||
|
endif()
|
||||||
|
|
||||||
#设置可执行文件输出目录
|
#设置可执行文件输出目录
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/debug)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/debug)
|
||||||
@ -19,10 +26,22 @@ endif()
|
|||||||
#获取文件路径分隔符(解决执行命令的时候有些平台会报错)
|
#获取文件路径分隔符(解决执行命令的时候有些平台会报错)
|
||||||
file(TO_CMAKE_PATH "/" PATH_SEPARATOR)
|
file(TO_CMAKE_PATH "/" PATH_SEPARATOR)
|
||||||
|
|
||||||
#设置版本号
|
find_package(Qt6 REQUIRED COMPONENTS Quick Svg Network)
|
||||||
add_definitions(-DVERSION=1,3,3,0)
|
|
||||||
|
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Quick REQUIRED)
|
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
||||||
|
qt_standard_project_setup()
|
||||||
|
else()
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
##生成版本信息头文件
|
||||||
|
set(HEADER_FILE_VERSION_PATH ${CMAKE_SOURCE_DIR}/example/Version.h)
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_SOURCE_DIR}/.cmake/Version.h.in
|
||||||
|
${HEADER_FILE_VERSION_PATH}
|
||||||
|
)
|
||||||
|
|
||||||
#遍历所有Cpp文件
|
#遍历所有Cpp文件
|
||||||
file(GLOB_RECURSE CPP_FILES *.cpp *.h)
|
file(GLOB_RECURSE CPP_FILES *.cpp *.h)
|
||||||
@ -45,11 +64,21 @@ foreach(filepath ${RES_PATHS})
|
|||||||
list(APPEND resource_files ${filename})
|
list(APPEND resource_files ${filename})
|
||||||
endforeach(filepath)
|
endforeach(filepath)
|
||||||
|
|
||||||
|
#如果是Windows平台,则生成rc文件
|
||||||
|
set(EXAMPLE_VERSION_RC_PATH "")
|
||||||
|
if(WIN32)
|
||||||
|
set(EXAMPLE_VERSION_RC_PATH ${CMAKE_BINARY_DIR}/version_${PROJECT_NAME}.rc)
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_SOURCE_DIR}/.cmake/version_exe.rc.in
|
||||||
|
${EXAMPLE_VERSION_RC_PATH}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
#添加可执行文件
|
#添加可执行文件
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if (WIN32)
|
||||||
qt_add_executable(example
|
qt_add_executable(example
|
||||||
${sources_files}
|
${sources_files}
|
||||||
example.rc
|
${EXAMPLE_VERSION_RC_PATH}
|
||||||
)
|
)
|
||||||
else ()
|
else ()
|
||||||
qt_add_executable(example
|
qt_add_executable(example
|
||||||
@ -75,12 +104,17 @@ endif()
|
|||||||
|
|
||||||
#添加qml模块
|
#添加qml模块
|
||||||
qt_add_qml_module(example
|
qt_add_qml_module(example
|
||||||
URI example
|
URI "example"
|
||||||
VERSION 1.0
|
VERSION 1.0
|
||||||
QML_FILES ${qml_files}
|
QML_FILES ${qml_files}
|
||||||
RESOURCES ${resource_files}
|
RESOURCES ${resource_files}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#导入component头文件,不然通过QML_NAMED_ELEMENT生成的c++类会找不到头文件报错
|
||||||
|
target_include_directories(example PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/component
|
||||||
|
)
|
||||||
|
|
||||||
#设置属性
|
#设置属性
|
||||||
set_target_properties(example PROPERTIES
|
set_target_properties(example PROPERTIES
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
||||||
@ -91,14 +125,30 @@ set_target_properties(example PROPERTIES
|
|||||||
)
|
)
|
||||||
|
|
||||||
#链接库
|
#链接库
|
||||||
target_link_libraries(example PRIVATE
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
|
target_link_libraries(example PRIVATE
|
||||||
Qt6::Quick
|
Qt6::Quick
|
||||||
|
Qt6::Svg
|
||||||
|
Qt6::Network
|
||||||
|
fluentui
|
||||||
fluentuiplugin
|
fluentuiplugin
|
||||||
FramelessHelper::Core
|
FramelessHelper::Core
|
||||||
FramelessHelper::Quick
|
FramelessHelper::Quick
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
target_link_libraries(example PRIVATE
|
||||||
|
Qt6::Quick
|
||||||
|
Qt6::Svg
|
||||||
|
Qt6::Network
|
||||||
|
fluentuiplugin
|
||||||
|
FramelessHelper::Core
|
||||||
|
FramelessHelper::Quick
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
#安装
|
#安装
|
||||||
install(TARGETS example
|
install(TARGETS example
|
||||||
BUNDLE DESTINATION .
|
BUNDLE DESTINATION .
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
#include <windows.h>
|
|
||||||
|
|
||||||
IDI_ICON1 ICON "favicon.ico"
|
|
||||||
|
|
||||||
#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_((VERSION))
|
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
|
||||||
FILEVERSION VERSION
|
|
||||||
PRODUCTVERSION VERSION
|
|
||||||
FILEFLAGSMASK 0x3fL
|
|
||||||
#ifdef _DEBUG
|
|
||||||
FILEFLAGS VS_FF_DEBUG
|
|
||||||
#else
|
|
||||||
FILEFLAGS 0x0L
|
|
||||||
#endif
|
|
||||||
FILEOS VOS_NT_WINDOWS32
|
|
||||||
FILETYPE VFT_APP
|
|
||||||
FILESUBTYPE VFT2_UNKNOWN
|
|
||||||
BEGIN
|
|
||||||
BLOCK "StringFileInfo"
|
|
||||||
BEGIN
|
|
||||||
BLOCK "040904b0"
|
|
||||||
BEGIN
|
|
||||||
VALUE "Comments", "Built by the FluentUI."
|
|
||||||
VALUE "CompanyName", "zhuzichu"
|
|
||||||
VALUE "FileDescription", "example"
|
|
||||||
VALUE "FileVersion", VER_STR
|
|
||||||
VALUE "InternalName", ""
|
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2023"
|
|
||||||
VALUE "OriginalFilename", ""
|
|
||||||
VALUE "ProductName", "example"
|
|
||||||
VALUE "ProductVersion", VER_STR
|
|
||||||
END
|
|
||||||
END
|
|
||||||
BLOCK "VarFileInfo"
|
|
||||||
BEGIN
|
|
||||||
VALUE "Translation", 0x409, 1200
|
|
||||||
END
|
|
||||||
END
|
|
@ -5,20 +5,40 @@ import QtQuick.Layouts
|
|||||||
import FluentUI
|
import FluentUI
|
||||||
|
|
||||||
Window {
|
Window {
|
||||||
id:app
|
id: app
|
||||||
|
flags: Qt.SplashScreen
|
||||||
|
|
||||||
|
FluHttpInterceptor{
|
||||||
|
id:interceptor
|
||||||
|
function onIntercept(request){
|
||||||
|
if(request.method === "get"){
|
||||||
|
request.params["method"] = "get"
|
||||||
|
}
|
||||||
|
if(request.method === "post"){
|
||||||
|
request.params["method"] = "post"
|
||||||
|
}
|
||||||
|
request.headers["token"] ="yyds"
|
||||||
|
request.headers["os"] ="pc"
|
||||||
|
console.debug(JSON.stringify(request))
|
||||||
|
return request
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
FluApp.init(app)
|
FluApp.init(app)
|
||||||
FluTheme.darkMode = FluDarkMode.System
|
FluTheme.darkMode = FluThemeType.System
|
||||||
|
FluTheme.enableAnimation = true
|
||||||
FluApp.routes = {
|
FluApp.routes = {
|
||||||
"/":"qrc:/example/qml/window/MainWindow.qml",
|
"/":"qrc:/example/qml/window/MainWindow.qml",
|
||||||
"/about":"qrc:/example/qml/window/AboutWindow.qml",
|
"/about":"qrc:/example/qml/window/AboutWindow.qml",
|
||||||
"/login":"qrc:/example/qml/window/LoginWindow.qml",
|
"/login":"qrc:/example/qml/window/LoginWindow.qml",
|
||||||
"/media":"qrc:/example/qml/window/MediaWindow.qml",
|
"/hotload":"qrc:/example/qml/window/HotloadWindow.qml",
|
||||||
"/singleTaskWindow":"qrc:/example/qml/window/SingleTaskWindow.qml",
|
"/singleTaskWindow":"qrc:/example/qml/window/SingleTaskWindow.qml",
|
||||||
"/standardWindow":"qrc:/example/qml/window/StandardWindow.qml",
|
"/standardWindow":"qrc:/example/qml/window/StandardWindow.qml",
|
||||||
"/singleInstanceWindow":"qrc:/example/qml/window/SingleInstanceWindow.qml"
|
"/singleInstanceWindow":"qrc:/example/qml/window/SingleInstanceWindow.qml"
|
||||||
}
|
}
|
||||||
FluApp.initialRoute = "/"
|
FluApp.initialRoute = "/"
|
||||||
|
FluApp.httpInterceptor = interceptor
|
||||||
FluApp.run()
|
FluApp.run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,8 @@ FluExpander{
|
|||||||
rightMargin: 5
|
rightMargin: 5
|
||||||
topMargin: 5
|
topMargin: 5
|
||||||
}
|
}
|
||||||
onActiveFocusChanged: {
|
|
||||||
if(activeFocus){
|
|
||||||
control.expand = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onClicked:{
|
onClicked:{
|
||||||
FluTools.clipText(content.text)
|
FluTools.clipText(FluTools.html2PlantText(content.text))
|
||||||
showSuccess("复制成功")
|
showSuccess("复制成功")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,13 +125,19 @@ FluExpander{
|
|||||||
"FluBreadcrumbBar",
|
"FluBreadcrumbBar",
|
||||||
"FluCopyableText",
|
"FluCopyableText",
|
||||||
"FluAcrylic",
|
"FluAcrylic",
|
||||||
"FluRemoteLoader"
|
"FluRemoteLoader",
|
||||||
|
"FluMenuBar",
|
||||||
|
"FluPagination",
|
||||||
|
"FluRadioButtons",
|
||||||
|
"FluImage",
|
||||||
|
"FluSpinBox",
|
||||||
|
"FluHttp",
|
||||||
|
"FluWatermark",
|
||||||
|
"FluTour",
|
||||||
|
"FluQRCode"
|
||||||
];
|
];
|
||||||
code = code.replace(/\n/g, "<br>");
|
code = code.replace(/\n/g, "<br>");
|
||||||
code = code.replace(/ /g, " ");
|
code = code.replace(/ /g, " ");
|
||||||
return code.replace(RegExp("\\b(" + qmlKeywords.join("|") + ")\\b", "g"), "<span style='color: #c23a80'>$1</span>");
|
return code.replace(RegExp("\\b(" + qmlKeywords.join("|") + ")\\b", "g"), "<span style='color: #c23a80'>$1</span>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,11 @@ import FluentUI
|
|||||||
import org.wangwenx190.FramelessHelper
|
import org.wangwenx190.FramelessHelper
|
||||||
|
|
||||||
FluWindow {
|
FluWindow {
|
||||||
|
|
||||||
id:window
|
id:window
|
||||||
|
|
||||||
property bool fixSize
|
property bool fixSize
|
||||||
property alias titleVisible: title_bar.titleVisible
|
property alias titleVisible: title_bar.titleVisible
|
||||||
property bool appBarVisible: true
|
property bool appBarVisible: true
|
||||||
default property alias content: container.data
|
default property alias content: container.data
|
||||||
|
|
||||||
FluAppBar {
|
FluAppBar {
|
||||||
id: title_bar
|
id: title_bar
|
||||||
title: window.title
|
title: window.title
|
||||||
@ -23,7 +20,6 @@ FluWindow {
|
|||||||
}
|
}
|
||||||
darkText: lang.dark_mode
|
darkText: lang.dark_mode
|
||||||
}
|
}
|
||||||
|
|
||||||
Item{
|
Item{
|
||||||
id:container
|
id:container
|
||||||
anchors{
|
anchors{
|
||||||
@ -34,7 +30,6 @@ FluWindow {
|
|||||||
}
|
}
|
||||||
clip: true
|
clip: true
|
||||||
}
|
}
|
||||||
|
|
||||||
FramelessHelper{
|
FramelessHelper{
|
||||||
id:framless_helper
|
id:framless_helper
|
||||||
onReady: {
|
onReady: {
|
||||||
@ -59,13 +54,10 @@ FluWindow {
|
|||||||
FramelessUtils.systemTheme = FramelessHelperConstants.Light
|
FramelessUtils.systemTheme = FramelessHelperConstants.Light
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setHitTestVisible(com){
|
function setHitTestVisible(com){
|
||||||
framless_helper.setHitTestVisible(com)
|
framless_helper.setHitTestVisible(com)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTitleBarItem(com){
|
function setTitleBarItem(com){
|
||||||
framless_helper.setTitleBarItem(com)
|
framless_helper.setTitleBarItem(com)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,17 @@ FluObject{
|
|||||||
property var navigationView
|
property var navigationView
|
||||||
|
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
|
id:item_home
|
||||||
|
count: 9
|
||||||
title:lang.home
|
title:lang.home
|
||||||
|
infoBadge:FluBadge{
|
||||||
|
count: item_home.count
|
||||||
|
}
|
||||||
icon:FluentIcons.Home
|
icon:FluentIcons.Home
|
||||||
// cusIcon: Image{
|
|
||||||
// anchors.centerIn: parent
|
|
||||||
// source: FluTheme.dark ? "qrc:/example/res/svg/home_dark.svg" : "qrc:/example/res/svg/home.svg"
|
|
||||||
// sourceSize: Qt.size(30,30)
|
|
||||||
// width: 18
|
|
||||||
// height: 18
|
|
||||||
// }
|
|
||||||
onTap:{
|
onTap:{
|
||||||
|
if(navigationView.getCurrentUrl()){
|
||||||
|
item_home.count = 0
|
||||||
|
}
|
||||||
navigationView.push("qrc:/example/qml/page/T_Home.qml")
|
navigationView.push("qrc:/example/qml/page/T_Home.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,20 +27,39 @@ FluObject{
|
|||||||
title:lang.basic_input
|
title:lang.basic_input
|
||||||
icon:FluentIcons.CheckboxComposite
|
icon:FluentIcons.CheckboxComposite
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
|
id:item_buttons
|
||||||
|
count: 99
|
||||||
|
infoBadge:FluBadge{
|
||||||
|
count: item_buttons.count
|
||||||
|
}
|
||||||
title:"Buttons"
|
title:"Buttons"
|
||||||
image:"qrc:/example/res/image/control/Button.png"
|
image:"qrc:/example/res/image/control/Button.png"
|
||||||
recentlyUpdated:true
|
recentlyUpdated:true
|
||||||
desc:"A control that responds to user input and raisesa Click event."
|
desc:"A control that responds to user input and raisesa Click event."
|
||||||
onTap:{
|
onTap:{
|
||||||
|
item_buttons.count = 0
|
||||||
navigationView.push("qrc:/example/qml/page/T_Buttons.qml")
|
navigationView.push("qrc:/example/qml/page/T_Buttons.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
|
id:item_text
|
||||||
title:"Text"
|
title:"Text"
|
||||||
|
count: 5
|
||||||
|
infoBadge:FluBadge{
|
||||||
|
count: item_text.count
|
||||||
|
color: Qt.rgba(82/255,196/255,26/255,1)
|
||||||
|
}
|
||||||
onTap:{
|
onTap:{
|
||||||
|
item_text.count = 0
|
||||||
navigationView.push("qrc:/example/qml/page/T_Text.qml")
|
navigationView.push("qrc:/example/qml/page/T_Text.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluPaneItem{
|
||||||
|
title:"Image"
|
||||||
|
onTap:{
|
||||||
|
navigationView.push("qrc:/example/qml/page/T_Image.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
title:"Slider"
|
title:"Slider"
|
||||||
image:"qrc:/example/res/image/control/Slider.png"
|
image:"qrc:/example/res/image/control/Slider.png"
|
||||||
@ -58,6 +78,12 @@ FluObject{
|
|||||||
navigationView.push("qrc:/example/qml/page/T_CheckBox.qml")
|
navigationView.push("qrc:/example/qml/page/T_CheckBox.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluPaneItem{
|
||||||
|
title:"RadioButton"
|
||||||
|
onTap:{
|
||||||
|
navigationView.push("qrc:/example/qml/page/T_RadioButton.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
title:"ToggleSwitch"
|
title:"ToggleSwitch"
|
||||||
onTap:{
|
onTap:{
|
||||||
@ -155,6 +181,12 @@ FluObject{
|
|||||||
navigationView.push("qrc:/example/qml/page/T_Expander.qml")
|
navigationView.push("qrc:/example/qml/page/T_Expander.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluPaneItem{
|
||||||
|
title:"Watermark"
|
||||||
|
onTap:{
|
||||||
|
navigationView.push("qrc:/example/qml/page/T_Watermark.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluPaneItemExpander{
|
FluPaneItemExpander{
|
||||||
@ -167,8 +199,15 @@ FluObject{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
|
id:item_combobox
|
||||||
title:"ComboBox"
|
title:"ComboBox"
|
||||||
|
count: 9
|
||||||
|
infoBadge:FluBadge{
|
||||||
|
count: item_combobox.count
|
||||||
|
color: Qt.rgba(250/255,173/255,20/255,1)
|
||||||
|
}
|
||||||
onTap:{
|
onTap:{
|
||||||
|
item_combobox.count = 0
|
||||||
navigationView.push("qrc:/example/qml/page/T_ComboBox.qml")
|
navigationView.push("qrc:/example/qml/page/T_ComboBox.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,6 +270,12 @@ FluObject{
|
|||||||
navigationView.push("qrc:/example/qml/page/T_TableView.qml")
|
navigationView.push("qrc:/example/qml/page/T_TableView.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluPaneItem{
|
||||||
|
title:"Pagination"
|
||||||
|
onTap:{
|
||||||
|
navigationView.push("qrc:/example/qml/page/T_Pagination.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
title:"MultiWindow"
|
title:"MultiWindow"
|
||||||
onTap:{
|
onTap:{
|
||||||
@ -278,31 +323,51 @@ FluObject{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluPaneItemExpander{
|
FluPaneItemSeparator{
|
||||||
title:lang.media
|
spacing:20
|
||||||
icon:FluentIcons.Media
|
size:1
|
||||||
FluPaneItem{
|
|
||||||
title:"MediaPlayer"
|
|
||||||
image:"qrc:/example/res/image/control/MediaPlayerElement.png"
|
|
||||||
recentlyAdded:true
|
|
||||||
order:0
|
|
||||||
desc:"A control to display video and image content."
|
|
||||||
onTap:{
|
|
||||||
navigationView.push("qrc:/example/qml/page/T_MediaPlayer.qml")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FluPaneItemExpander{
|
FluPaneItemExpander{
|
||||||
title:lang.other
|
title:lang.other
|
||||||
icon:FluentIcons.Shop
|
icon:FluentIcons.Shop
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
title:"RemoteLoader"
|
title:"QRCode"
|
||||||
onTap:{
|
onTap:{
|
||||||
|
navigationView.push("qrc:/example/qml/page/T_QRCode.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluPaneItem{
|
||||||
|
title:"Tour"
|
||||||
|
onTap:{
|
||||||
|
navigationView.push("qrc:/example/qml/page/T_Tour.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluPaneItem{
|
||||||
|
title:"Http"
|
||||||
|
onTap:{
|
||||||
|
navigationView.push("qrc:/example/qml/page/T_Http.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluPaneItem{
|
||||||
|
id:item_other
|
||||||
|
title:"RemoteLoader"
|
||||||
|
count: 99
|
||||||
|
infoBadge:FluBadge{
|
||||||
|
count: item_other.count
|
||||||
|
color: Qt.rgba(82/255,196/255,26/255,1)
|
||||||
|
}
|
||||||
|
onTap:{
|
||||||
|
item_other.count = 0
|
||||||
navigationView.push("qrc:/example/qml/page/T_RemoteLoader.qml")
|
navigationView.push("qrc:/example/qml/page/T_RemoteLoader.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluPaneItem{
|
||||||
|
title:"HotLoader"
|
||||||
|
tapFunc:function(){
|
||||||
|
FluApp.navigate("/hotload")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRecentlyAddedData(){
|
function getRecentlyAddedData(){
|
||||||
@ -343,6 +408,11 @@ FluObject{
|
|||||||
for(var i=0;i<items.length;i++){
|
for(var i=0;i<items.length;i++){
|
||||||
var item = items[i]
|
var item = items[i]
|
||||||
if(item instanceof FluPaneItem){
|
if(item instanceof FluPaneItem){
|
||||||
|
if (item.parent instanceof FluPaneItemExpander)
|
||||||
|
{
|
||||||
|
arr.push({title:`${item.parent.title} -> ${item.title}`,key:item.key})
|
||||||
|
}
|
||||||
|
else
|
||||||
arr.push({title:item.title,key:item.key})
|
arr.push({title:item.title,key:item.key})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,5 +5,5 @@ import QtQuick.Controls
|
|||||||
import FluentUI
|
import FluentUI
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
property int displayMode : FluNavigationView.Auto
|
property int displayMode : FluNavigationViewType.Auto
|
||||||
}
|
}
|
||||||
|
@ -9,35 +9,84 @@ FluScrollablePage{
|
|||||||
|
|
||||||
title:"Acrylic"
|
title:"Acrylic"
|
||||||
|
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
Layout.topMargin: 20
|
||||||
|
FluText{
|
||||||
|
text:"tintColor:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluColorPicker{
|
||||||
|
id:color_picker
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
FluText{
|
||||||
|
text:"tintOpacity:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluSlider{
|
||||||
|
id:slider_tint_opacity
|
||||||
|
value: 65
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
FluText{
|
||||||
|
text:"blurRadius:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluSlider{
|
||||||
|
id:slider_blur_radius
|
||||||
|
value: 32
|
||||||
|
}
|
||||||
|
}
|
||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 20
|
height: 1200/4+20
|
||||||
height: 1200/5+20
|
|
||||||
paddings: 10
|
paddings: 10
|
||||||
|
Layout.topMargin: 10
|
||||||
FluRectangle{
|
FluRectangle{
|
||||||
width: 1920/5
|
width: 1920/4
|
||||||
height: 1200/5
|
height: 1200/4
|
||||||
radius:[15,15,15,15]
|
radius:[15,15,15,15]
|
||||||
Image {
|
Image {
|
||||||
id:image
|
id:image
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
source: "qrc:/example/res/image/banner_3.jpg"
|
source: "qrc:/example/res/image/bg_scenic.png"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
sourceSize: Qt.size(2*width,2*height)
|
sourceSize: Qt.size(2*width,2*height)
|
||||||
}
|
}
|
||||||
FluAcrylic {
|
FluAcrylic {
|
||||||
sourceItem:image
|
id:acrylic
|
||||||
anchors.bottom: parent.bottom
|
target: image
|
||||||
anchors.right: parent.right
|
width: 200
|
||||||
width: 100
|
height: 200
|
||||||
height: 100
|
tintOpacity: slider_tint_opacity.value/100
|
||||||
|
tintColor: color_picker.colorValue
|
||||||
|
blurRadius: slider_blur_radius.value
|
||||||
|
x:(image.width-width)/2
|
||||||
|
y:(image.height-height)/2
|
||||||
FluText {
|
FluText {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: "Acrylic"
|
text: "Acrylic"
|
||||||
color: "#FFFFFF"
|
color: "#FFFFFF"
|
||||||
font.bold: true
|
font.bold: true
|
||||||
}
|
}
|
||||||
|
MouseArea {
|
||||||
|
property point clickPos: Qt.point(0,0)
|
||||||
|
id:drag_area
|
||||||
|
anchors.fill: parent
|
||||||
|
onPressed: (mouse)=>{
|
||||||
|
clickPos = Qt.point(mouse.x, mouse.y)
|
||||||
|
}
|
||||||
|
onPositionChanged: (mouse)=>{
|
||||||
|
var delta = Qt.point(mouse.x - clickPos.x,mouse.y - clickPos.y)
|
||||||
|
acrylic.x = acrylic.x + delta.x
|
||||||
|
acrylic.y = acrylic.y + delta.y
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
}
|
}
|
||||||
@ -54,10 +103,11 @@ FluScrollablePage{
|
|||||||
radius: 8
|
radius: 8
|
||||||
}
|
}
|
||||||
FluAcrylic{
|
FluAcrylic{
|
||||||
sourceItem:image
|
target:image
|
||||||
width: 100
|
width: 100
|
||||||
height: 100
|
height: 100
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
}
|
||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ FluContentPage {
|
|||||||
cellWidth: 80
|
cellWidth: 80
|
||||||
cellHeight: 80
|
cellHeight: 80
|
||||||
clip: true
|
clip: true
|
||||||
|
boundsBehavior: GridView.StopAtBounds
|
||||||
model:FluApp.awesomelist()
|
model:FluApp.awesomelist()
|
||||||
ScrollBar.vertical: FluScrollBar {}
|
ScrollBar.vertical: FluScrollBar {}
|
||||||
anchors{
|
anchors{
|
||||||
|
@ -33,6 +33,8 @@ FluScrollablePage{
|
|||||||
radius: 8
|
radius: 8
|
||||||
color: Qt.rgba(191/255,191/255,191/255,1)
|
color: Qt.rgba(191/255,191/255,191/255,1)
|
||||||
FluBadge{
|
FluBadge{
|
||||||
|
topRight: true
|
||||||
|
showZero: true
|
||||||
count:0
|
count:0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,6 +45,8 @@ FluScrollablePage{
|
|||||||
radius: 8
|
radius: 8
|
||||||
color: Qt.rgba(191/255,191/255,191/255,1)
|
color: Qt.rgba(191/255,191/255,191/255,1)
|
||||||
FluBadge{
|
FluBadge{
|
||||||
|
topRight: true
|
||||||
|
showZero: true
|
||||||
count:5
|
count:5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,6 +56,8 @@ FluScrollablePage{
|
|||||||
radius: 8
|
radius: 8
|
||||||
color: Qt.rgba(191/255,191/255,191/255,1)
|
color: Qt.rgba(191/255,191/255,191/255,1)
|
||||||
FluBadge{
|
FluBadge{
|
||||||
|
topRight: true
|
||||||
|
showZero: true
|
||||||
count:50
|
count:50
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,6 +67,8 @@ FluScrollablePage{
|
|||||||
radius: 8
|
radius: 8
|
||||||
color: Qt.rgba(191/255,191/255,191/255,1)
|
color: Qt.rgba(191/255,191/255,191/255,1)
|
||||||
FluBadge{
|
FluBadge{
|
||||||
|
topRight: true
|
||||||
|
showZero: true
|
||||||
count:100
|
count:100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,6 +78,8 @@ FluScrollablePage{
|
|||||||
radius: 8
|
radius: 8
|
||||||
color: Qt.rgba(191/255,191/255,191/255,1)
|
color: Qt.rgba(191/255,191/255,191/255,1)
|
||||||
FluBadge{
|
FluBadge{
|
||||||
|
topRight: true
|
||||||
|
showZero: true
|
||||||
isDot:true
|
isDot:true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,6 +89,8 @@ FluScrollablePage{
|
|||||||
radius: 8
|
radius: 8
|
||||||
color: Qt.rgba(191/255,191/255,191/255,1)
|
color: Qt.rgba(191/255,191/255,191/255,1)
|
||||||
FluBadge{
|
FluBadge{
|
||||||
|
topRight: true
|
||||||
|
showZero: true
|
||||||
count:99
|
count:99
|
||||||
color: Qt.rgba(250/255,173/255,20/255,1)
|
color: Qt.rgba(250/255,173/255,20/255,1)
|
||||||
}
|
}
|
||||||
@ -89,6 +101,8 @@ FluScrollablePage{
|
|||||||
radius: 8
|
radius: 8
|
||||||
color: Qt.rgba(191/255,191/255,191/255,1)
|
color: Qt.rgba(191/255,191/255,191/255,1)
|
||||||
FluBadge{
|
FluBadge{
|
||||||
|
topRight: true
|
||||||
|
showZero: true
|
||||||
count:99
|
count:99
|
||||||
color: Qt.rgba(82/255,196/255,26/255,1)
|
color: Qt.rgba(82/255,196/255,26/255,1)
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ FluScrollablePage{
|
|||||||
FluTextButton{
|
FluTextButton{
|
||||||
disabled:text_button_switch.checked
|
disabled:text_button_switch.checked
|
||||||
text:"Text Button"
|
text:"Text Button"
|
||||||
|
contentDescription: "文本按钮"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
showInfo("点击Text Button")
|
showInfo("点击Text Button")
|
||||||
}
|
}
|
||||||
@ -210,20 +211,21 @@ FluScrollablePage{
|
|||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
left: parent.left
|
left: parent.left
|
||||||
}
|
}
|
||||||
items:[
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Menu_1"
|
text:"Menu_1"
|
||||||
},
|
}
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Menu_2"
|
text:"Menu_2"
|
||||||
},
|
}
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Menu_3"
|
text:"Menu_3"
|
||||||
},
|
}
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Menu_4"
|
text:"Menu_4"
|
||||||
|
onClicked: {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
id:drop_down_button_switch
|
id:drop_down_button_switch
|
||||||
@ -239,7 +241,6 @@ FluScrollablePage{
|
|||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
code:'FluDropDownButton{
|
code:'FluDropDownButton{
|
||||||
text:"DropDownButton"
|
text:"DropDownButton"
|
||||||
items:[
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Menu_1"
|
text:"Menu_1"
|
||||||
},
|
},
|
||||||
@ -252,7 +253,6 @@ FluScrollablePage{
|
|||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Menu_4"
|
text:"Menu_4"
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,24 +261,23 @@ FluScrollablePage{
|
|||||||
height: 100
|
height: 100
|
||||||
paddings: 10
|
paddings: 10
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
ColumnLayout{
|
FluRadioButtons{
|
||||||
spacing: 8
|
spacing: 8
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
left: parent.left
|
left: parent.left
|
||||||
}
|
}
|
||||||
Repeater{
|
FluRadioButton{
|
||||||
id:repeater
|
|
||||||
property int selecIndex : 0
|
|
||||||
model: 3
|
|
||||||
delegate: FluRadioButton{
|
|
||||||
checked : repeater.selecIndex===index
|
|
||||||
disabled:radio_button_switch.checked
|
disabled:radio_button_switch.checked
|
||||||
text:"Radio Button_"+index
|
text:"Radio Button_1"
|
||||||
clickListener:function(){
|
|
||||||
repeater.selecIndex = index
|
|
||||||
}
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
disabled:radio_button_switch.checked
|
||||||
|
text:"Radio Button_2"
|
||||||
}
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
disabled:radio_button_switch.checked
|
||||||
|
text:"Radio Button_3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
|
@ -9,6 +9,19 @@ FluScrollablePage{
|
|||||||
|
|
||||||
title:"Carousel"
|
title:"Carousel"
|
||||||
|
|
||||||
|
ListModel{
|
||||||
|
id:data_model
|
||||||
|
ListElement{
|
||||||
|
url:"qrc:/example/res/image/banner_1.jpg"
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
url:"qrc:/example/res/image/banner_2.jpg"
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
url:"qrc:/example/res/image/banner_3.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: 370
|
height: 370
|
||||||
@ -24,23 +37,95 @@ FluScrollablePage{
|
|||||||
text:"轮播图,支持无限轮播,无限滑动,用ListView实现的组件"
|
text:"轮播图,支持无限轮播,无限滑动,用ListView实现的组件"
|
||||||
}
|
}
|
||||||
FluCarousel{
|
FluCarousel{
|
||||||
id:carousel
|
radius:[5,5,5,5]
|
||||||
|
delegate: Component{
|
||||||
|
Image {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: model.url
|
||||||
|
asynchronous: true
|
||||||
|
fillMode:Image.PreserveAspectCrop
|
||||||
|
}
|
||||||
|
}
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
Layout.leftMargin: 5
|
Layout.leftMargin: 5
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
carousel.setData([{url:"qrc:/example/res/image/banner_1.jpg"},{url:"qrc:/example/res/image/banner_2.jpg"},{url:"qrc:/example/res/image/banner_3.jpg"}])
|
model = [{url:"qrc:/example/res/image/banner_1.jpg"},{url:"qrc:/example/res/image/banner_2.jpg"},{url:"qrc:/example/res/image/banner_3.jpg"}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
height: 340
|
||||||
|
paddings: 10
|
||||||
|
Layout.topMargin: 10
|
||||||
|
Column{
|
||||||
|
spacing: 15
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left:parent.left
|
||||||
|
}
|
||||||
|
FluCarousel{
|
||||||
|
radius:[15,15,15,15]
|
||||||
|
loopTime:1500
|
||||||
|
indicatorGravity: Qt.AlignHCenter | Qt.AlignTop
|
||||||
|
indicatorMarginTop:15
|
||||||
|
delegate: Component{
|
||||||
|
Item{
|
||||||
|
anchors.fill: parent
|
||||||
|
Image {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: model.url
|
||||||
|
asynchronous: true
|
||||||
|
fillMode:Image.PreserveAspectCrop
|
||||||
|
}
|
||||||
|
Rectangle{
|
||||||
|
height: 40
|
||||||
|
width: parent.width
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
color: "#33000000"
|
||||||
|
FluText{
|
||||||
|
anchors.fill: parent
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
|
text:model.title
|
||||||
|
color: FluColors.Grey10
|
||||||
|
font.pixelSize: 15
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Layout.topMargin: 20
|
||||||
|
Layout.leftMargin: 5
|
||||||
|
Component.onCompleted: {
|
||||||
|
var arr = []
|
||||||
|
arr.push({url:"qrc:/example/res/image/banner_1.jpg",title:"共同应对全球性问题"})
|
||||||
|
arr.push({url:"qrc:/example/res/image/banner_2.jpg",title:"三小只全程没互动"})
|
||||||
|
arr.push({url:"qrc:/example/res/image/banner_3.jpg",title:"有效投资扩大 激发增长动能"})
|
||||||
|
model = arr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CodeExpander{
|
CodeExpander{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
code:'FluCarousel{
|
code:'FluCarousel{
|
||||||
|
id:carousel
|
||||||
width: 400
|
width: 400
|
||||||
height: 300
|
height: 300
|
||||||
|
delegate: Component{
|
||||||
|
Image {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: model.url
|
||||||
|
asynchronous: true
|
||||||
|
fillMode:Image.PreserveAspectCrop
|
||||||
|
}
|
||||||
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
setData([{url:"qrc:/example/res/image/banner_1.jpg"},{url:"qrc:/example/res/image/banner_2.jpg"},{url:"qrc:/example/res/image/banner_3.jpg"}])
|
carousel.model = [{url:"qrc:/example/res/image/banner_1.jpg"},{url:"qrc:/example/res/image/banner_2.jpg"},{url:"qrc:/example/res/image/banner_3.jpg"}]
|
||||||
}
|
}
|
||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,12 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
FluCheckBox{
|
FluCheckBox{
|
||||||
disabled: check_box_switch.checked
|
disabled: check_box_switch.checked
|
||||||
text:"Text"
|
text:"Right"
|
||||||
|
}
|
||||||
|
FluCheckBox{
|
||||||
|
disabled: check_box_switch.checked
|
||||||
|
text:"Left"
|
||||||
|
textRight: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
|
@ -23,8 +23,6 @@ FluScrollablePage{
|
|||||||
text:"此颜色组件是Github上的开源项目"
|
text:"此颜色组件是Github上的开源项目"
|
||||||
}
|
}
|
||||||
FluTextButton{
|
FluTextButton{
|
||||||
leftPadding: 0
|
|
||||||
rightPadding: 0
|
|
||||||
text:"https://github.com/rshest/qml-colorpicker"
|
text:"https://github.com/rshest/qml-colorpicker"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Qt.openUrlExternally(text)
|
Qt.openUrlExternally(text)
|
||||||
|
@ -28,10 +28,6 @@ FluScrollablePage{
|
|||||||
ListElement { text: "Apple" }
|
ListElement { text: "Apple" }
|
||||||
ListElement { text: "Coconut" }
|
ListElement { text: "Coconut" }
|
||||||
}
|
}
|
||||||
onAccepted: {
|
|
||||||
if (find(editText) === -1)
|
|
||||||
model_1.append({text: editText})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,6 +46,7 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
FluComboBox {
|
FluComboBox {
|
||||||
editable: true
|
editable: true
|
||||||
|
font:FluTextStyle.BodyStrong
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
id: model_2
|
id: model_2
|
||||||
ListElement { text: "Banana" }
|
ListElement { text: "Banana" }
|
||||||
|
@ -23,6 +23,9 @@ FluScrollablePage{
|
|||||||
text:"showYear=true"
|
text:"showYear=true"
|
||||||
}
|
}
|
||||||
FluDatePicker{
|
FluDatePicker{
|
||||||
|
onCurrentChanged: {
|
||||||
|
showSuccess(current.toLocaleDateString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,7 +53,9 @@ FluScrollablePage{
|
|||||||
|
|
||||||
FluDatePicker{
|
FluDatePicker{
|
||||||
showYear:false
|
showYear:false
|
||||||
|
onCurrentChanged: {
|
||||||
|
showSuccess(current.toLocaleDateString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ FluScrollablePage{
|
|||||||
title:"友情提示"
|
title:"友情提示"
|
||||||
message:"确定要退出程序么?"
|
message:"确定要退出程序么?"
|
||||||
negativeText:"取消"
|
negativeText:"取消"
|
||||||
buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
|
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
|
||||||
onNegativeClicked:{
|
onNegativeClicked:{
|
||||||
showSuccess("点击取消按钮")
|
showSuccess("点击取消按钮")
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ FluScrollablePage{
|
|||||||
id:double_btn_dialog
|
id:double_btn_dialog
|
||||||
title:"友情提示"
|
title:"友情提示"
|
||||||
message:"确定要退出程序么?"
|
message:"确定要退出程序么?"
|
||||||
buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
|
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
|
||||||
negativeText:"取消"
|
negativeText:"取消"
|
||||||
onNegativeClicked:{
|
onNegativeClicked:{
|
||||||
showSuccess("点击取消按钮")
|
showSuccess("点击取消按钮")
|
||||||
@ -80,7 +80,7 @@ FluScrollablePage{
|
|||||||
title:"友情提示"
|
title:"友情提示"
|
||||||
message:"确定要退出程序么?"
|
message:"确定要退出程序么?"
|
||||||
negativeText:"取消"
|
negativeText:"取消"
|
||||||
buttonFlags: FluContentDialog.NeutralButton | FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
|
buttonFlags: FluContentDialogType.NeutralButton | FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
|
||||||
negativeText:"取消"
|
negativeText:"取消"
|
||||||
onNegativeClicked:{
|
onNegativeClicked:{
|
||||||
showSuccess("点击取消按钮")
|
showSuccess("点击取消按钮")
|
||||||
@ -101,7 +101,7 @@ FluScrollablePage{
|
|||||||
id:triple_btn_dialog
|
id:triple_btn_dialog
|
||||||
title:"友情提示"
|
title:"友情提示"
|
||||||
message:"确定要退出程序么?"
|
message:"确定要退出程序么?"
|
||||||
buttonFlags: FluContentDialog.NeutralButton | FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
|
buttonFlags: FluContentDialogType.NeutralButton | FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
|
||||||
negativeText:"取消"
|
negativeText:"取消"
|
||||||
onNegativeClicked:{
|
onNegativeClicked:{
|
||||||
showSuccess("点击取消按钮")
|
showSuccess("点击取消按钮")
|
||||||
|
@ -27,7 +27,7 @@ FluScrollablePage{
|
|||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
Item{
|
Item{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
ColumnLayout{
|
FluRadioButtons{
|
||||||
spacing: 8
|
spacing: 8
|
||||||
anchors{
|
anchors{
|
||||||
top: parent.top
|
top: parent.top
|
||||||
@ -35,17 +35,14 @@ FluScrollablePage{
|
|||||||
topMargin: 15
|
topMargin: 15
|
||||||
leftMargin: 15
|
leftMargin: 15
|
||||||
}
|
}
|
||||||
Repeater{
|
FluRadioButton{
|
||||||
id:repeater
|
text:"Radio Button_1"
|
||||||
property int selecIndex : 0
|
|
||||||
model: 3
|
|
||||||
delegate: FluRadioButton{
|
|
||||||
checked : repeater.selecIndex===index
|
|
||||||
text:"Radio Button_"+index
|
|
||||||
clickListener:function() {
|
|
||||||
repeater.selecIndex = index
|
|
||||||
}
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
text:"Radio Button_2"
|
||||||
}
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
text:"Radio Button_3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,6 @@ FluScrollablePage{
|
|||||||
Image{
|
Image{
|
||||||
source: "qrc:/example/res/image/banner_1.jpg"
|
source: "qrc:/example/res/image/banner_1.jpg"
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
sourceSize: Qt.size(400,300)
|
|
||||||
fillMode:Image.PreserveAspectCrop
|
fillMode:Image.PreserveAspectCrop
|
||||||
}
|
}
|
||||||
Image{
|
Image{
|
||||||
|
@ -7,7 +7,8 @@ import FluentUI
|
|||||||
|
|
||||||
FluScrollablePage{
|
FluScrollablePage{
|
||||||
|
|
||||||
pageMode: FluNavigationView.SingleTask
|
launchMode: FluPageType.SingleTask
|
||||||
|
animDisabled: true
|
||||||
|
|
||||||
ListModel{
|
ListModel{
|
||||||
id:model_header
|
id:model_header
|
||||||
@ -17,7 +18,6 @@ FluScrollablePage{
|
|||||||
desc:"The latest FluentUI controls and styles for your applications."
|
desc:"The latest FluentUI controls and styles for your applications."
|
||||||
url:"https://github.com/zhuzichu520/FluentUI"
|
url:"https://github.com/zhuzichu520/FluentUI"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item{
|
Item{
|
||||||
@ -68,19 +68,16 @@ FluScrollablePage{
|
|||||||
id: control
|
id: control
|
||||||
width: 220
|
width: 220
|
||||||
height: 240
|
height: 240
|
||||||
FluArea{
|
FluItem{
|
||||||
radius: 8
|
radius: [8,8,8,8]
|
||||||
width: 200
|
width: 200
|
||||||
height: 220
|
height: 220
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color: 'transparent'
|
FluAcrylic{
|
||||||
FluAcrylic {
|
|
||||||
sourceItem:bg
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: FluTheme.dark ? Window.active ? Qt.rgba(38/255,44/255,54/255,1) : Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
|
tintColor: FluTheme.dark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
|
||||||
rectX: list.x-list.contentX+10+(control.width)*index
|
target: bg
|
||||||
rectY: list.y+10
|
targetRect: Qt.rect(list.x-list.contentX+10+(control.width)*index,list.y+10,width,height)
|
||||||
acrylicOpacity:0.8
|
|
||||||
}
|
}
|
||||||
Rectangle{
|
Rectangle{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -99,7 +96,6 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout{
|
ColumnLayout{
|
||||||
Image {
|
Image {
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
|
214
example/qml/page/T_Http.qml
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Qt.labs.platform
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Window
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Dialogs
|
||||||
|
import FluentUI
|
||||||
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
|
FluContentPage{
|
||||||
|
|
||||||
|
title:"Http"
|
||||||
|
|
||||||
|
FluHttp{
|
||||||
|
id:http
|
||||||
|
}
|
||||||
|
|
||||||
|
Flickable{
|
||||||
|
id:layout_flick
|
||||||
|
width: 160
|
||||||
|
clip: true
|
||||||
|
anchors{
|
||||||
|
top: parent.top
|
||||||
|
topMargin: 20
|
||||||
|
bottom: parent.bottom
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
ScrollBar.vertical: FluScrollBar {}
|
||||||
|
contentHeight:layout_column.height
|
||||||
|
Column{
|
||||||
|
spacing: 2
|
||||||
|
id:layout_column
|
||||||
|
width: parent.width
|
||||||
|
FluButton{
|
||||||
|
implicitWidth: parent.width
|
||||||
|
implicitHeight: 36
|
||||||
|
text: "Get请求"
|
||||||
|
onClicked: {
|
||||||
|
var callable = {}
|
||||||
|
callable.onStart = function(){
|
||||||
|
showLoading()
|
||||||
|
}
|
||||||
|
callable.onFinish = function(){
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
callable.onSuccess = function(result){
|
||||||
|
text_info.text = result
|
||||||
|
console.debug(result)
|
||||||
|
}
|
||||||
|
callable.onError = function(status,errorString){
|
||||||
|
console.debug(status+";"+errorString)
|
||||||
|
}
|
||||||
|
http.get("https://httpbingo.org/get",callable)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluButton{
|
||||||
|
implicitWidth: parent.width
|
||||||
|
implicitHeight: 36
|
||||||
|
text: "Post表单请求"
|
||||||
|
onClicked: {
|
||||||
|
var callable = {}
|
||||||
|
callable.onStart = function(){
|
||||||
|
showLoading()
|
||||||
|
}
|
||||||
|
callable.onFinish = function(){
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
callable.onSuccess = function(result){
|
||||||
|
text_info.text = result
|
||||||
|
console.debug(result)
|
||||||
|
}
|
||||||
|
callable.onError = function(status,errorString){
|
||||||
|
console.debug(status+";"+errorString)
|
||||||
|
}
|
||||||
|
var param = {}
|
||||||
|
param.custname = "朱子楚"
|
||||||
|
param.custtel = "1234567890"
|
||||||
|
param.custemail = "zhuzichu520@gmail.com"
|
||||||
|
http.post("https://httpbingo.org/post",callable,param)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluButton{
|
||||||
|
implicitWidth: parent.width
|
||||||
|
implicitHeight: 36
|
||||||
|
text: "Post Json请求"
|
||||||
|
onClicked: {
|
||||||
|
var callable = {}
|
||||||
|
callable.onStart = function(){
|
||||||
|
showLoading()
|
||||||
|
}
|
||||||
|
callable.onFinish = function(){
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
callable.onSuccess = function(result){
|
||||||
|
text_info.text = result
|
||||||
|
console.debug(result)
|
||||||
|
}
|
||||||
|
callable.onError = function(status,errorString){
|
||||||
|
console.debug(status+";"+errorString)
|
||||||
|
}
|
||||||
|
var param = {}
|
||||||
|
param.custname = "朱子楚"
|
||||||
|
param.custtel = "1234567890"
|
||||||
|
param.custemail = "zhuzichu520@gmail.com"
|
||||||
|
http.postJson("https://httpbingo.org/post",callable,param)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluButton{
|
||||||
|
implicitWidth: parent.width
|
||||||
|
implicitHeight: 36
|
||||||
|
text: "Post String请求"
|
||||||
|
onClicked: {
|
||||||
|
var callable = {}
|
||||||
|
callable.onStart = function(){
|
||||||
|
showLoading()
|
||||||
|
}
|
||||||
|
callable.onFinish = function(){
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
callable.onSuccess = function(result){
|
||||||
|
text_info.text = result
|
||||||
|
console.debug(result)
|
||||||
|
}
|
||||||
|
callable.onError = function(status,errorString){
|
||||||
|
console.debug(status+";"+errorString)
|
||||||
|
}
|
||||||
|
var param = "我命由我不由天"
|
||||||
|
http.postString("https://httpbingo.org/post",callable,param)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluButton{
|
||||||
|
id:btn_download
|
||||||
|
implicitWidth: parent.width
|
||||||
|
implicitHeight: 36
|
||||||
|
text: "下载文件"
|
||||||
|
onClicked: {
|
||||||
|
file_dialog.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FolderDialog {
|
||||||
|
id: file_dialog
|
||||||
|
currentFolder: StandardPaths.standardLocations(StandardPaths.DownloadLocation)[0]
|
||||||
|
onAccepted: {
|
||||||
|
var callable = {}
|
||||||
|
callable.onStart = function(){
|
||||||
|
btn_download.disabled = true
|
||||||
|
}
|
||||||
|
callable.onFinish = function(){
|
||||||
|
btn_download.disabled = false
|
||||||
|
btn_download.text = "下载文件"
|
||||||
|
layout_file_size.visible = false
|
||||||
|
text_file_size.text = ""
|
||||||
|
}
|
||||||
|
callable.onSuccess = function(result){
|
||||||
|
showSuccess(result)
|
||||||
|
}
|
||||||
|
callable.onError = function(status,errorString){
|
||||||
|
showError(errorString)
|
||||||
|
}
|
||||||
|
callable.onDownloadProgress = function(recv,total){
|
||||||
|
var locale = Qt.locale()
|
||||||
|
var precent = (recv/total * 100).toFixed(0) + "%"
|
||||||
|
btn_download.text = "下载中..."+precent
|
||||||
|
text_file_size.text = "%1/%2".arg(locale.formattedDataSize(recv)).arg(locale.formattedDataSize(total))
|
||||||
|
layout_file_size.visible = true
|
||||||
|
}
|
||||||
|
var path = FluTools.toLocalPath(currentFolder)+ "/big_buck_bunny.mp4"
|
||||||
|
http.download("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",callable,path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
anchors{
|
||||||
|
top: layout_flick.top
|
||||||
|
bottom: layout_flick.bottom
|
||||||
|
left: layout_flick.right
|
||||||
|
right: parent.right
|
||||||
|
leftMargin: 8
|
||||||
|
}
|
||||||
|
Flickable{
|
||||||
|
clip: true
|
||||||
|
id:scrollview
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
|
contentWidth: width
|
||||||
|
contentHeight: text_info.height
|
||||||
|
ScrollBar.vertical: FluScrollBar {}
|
||||||
|
FluText{
|
||||||
|
id:text_info
|
||||||
|
width: scrollview.width
|
||||||
|
wrapMode: Text.WrapAnywhere
|
||||||
|
padding: 14
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluRectangle{
|
||||||
|
id:layout_file_size
|
||||||
|
radius: [4,4,4,4]
|
||||||
|
height: 36
|
||||||
|
width: 160
|
||||||
|
visible: false
|
||||||
|
x:layout_flick.width
|
||||||
|
y: 173 - layout_flick.contentY
|
||||||
|
FluText{
|
||||||
|
id:text_file_size
|
||||||
|
anchors.centerIn: parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
48
example/qml/page/T_Image.qml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Window
|
||||||
|
import QtQuick.Controls
|
||||||
|
import FluentUI
|
||||||
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
|
FluScrollablePage{
|
||||||
|
|
||||||
|
title:"Image"
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
height: 260
|
||||||
|
paddings: 10
|
||||||
|
Layout.topMargin: 20
|
||||||
|
Column{
|
||||||
|
spacing: 15
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left:parent.left
|
||||||
|
}
|
||||||
|
FluImage{
|
||||||
|
width: 384
|
||||||
|
height: 240
|
||||||
|
source: "https://gitee.com/zhu-zichu/zhu-zichu/raw/74f075efe2f8d3c3bb7ba3c2259e403450e4050b/image/banner_4.jpg"
|
||||||
|
onStatusChanged:{
|
||||||
|
if(status === Image.Error){
|
||||||
|
showError("图片加载失败,请重新加载")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clickErrorListener: function(){
|
||||||
|
source = "https://gitee.com/zhu-zichu/zhu-zichu/raw/74f075efe2f8d3c3bb7ba3c2259e403450e4050b/image/banner_1.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CodeExpander{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: -1
|
||||||
|
code:'FluImage{
|
||||||
|
width: 400
|
||||||
|
height: 300
|
||||||
|
source: "https://gitee.com/zhu-zichu/zhu-zichu/raw/74f075efe2f8d3c3bb7ba3c2259e403450e4050b/image/banner_1.jpg"
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,7 +12,7 @@ FluScrollablePage{
|
|||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
height: 200
|
height: 240
|
||||||
paddings: 10
|
paddings: 10
|
||||||
ColumnLayout{
|
ColumnLayout{
|
||||||
spacing: 14
|
spacing: 14
|
||||||
@ -44,6 +44,12 @@ FluScrollablePage{
|
|||||||
showSuccess("这是一个Success样式的InfoBar这是一个Success样式的InfoBar")
|
showSuccess("这是一个Success样式的InfoBar这是一个Success样式的InfoBar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluButton{
|
||||||
|
text:"Loading"
|
||||||
|
onClicked: {
|
||||||
|
showLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CodeExpander{
|
CodeExpander{
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import QtQuick.Controls
|
|
||||||
import QtQuick.Layouts
|
|
||||||
import QtQuick.Window
|
|
||||||
import FluentUI
|
|
||||||
import "qrc:///example/qml/component"
|
|
||||||
|
|
||||||
FluScrollablePage{
|
|
||||||
|
|
||||||
title:"MediaPlayer"
|
|
||||||
|
|
||||||
onVisibleChanged: {
|
|
||||||
if(visible){
|
|
||||||
player.play()
|
|
||||||
}else{
|
|
||||||
player.pause()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FluArea{
|
|
||||||
Layout.fillWidth: true
|
|
||||||
height: 320
|
|
||||||
Layout.topMargin: 20
|
|
||||||
paddings: 10
|
|
||||||
ColumnLayout{
|
|
||||||
anchors{
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
left:parent.left
|
|
||||||
}
|
|
||||||
FluMediaPlayer{
|
|
||||||
id:player
|
|
||||||
source:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CodeExpander{
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: -1
|
|
||||||
code:'FluMediaPlayer{
|
|
||||||
id:player
|
|
||||||
source:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
|
|
||||||
}
|
|
||||||
'
|
|
||||||
}
|
|
||||||
FluArea{
|
|
||||||
Layout.fillWidth: true
|
|
||||||
height: 68
|
|
||||||
Layout.topMargin: 20
|
|
||||||
paddings: 10
|
|
||||||
FluButton{
|
|
||||||
text:"跳转到视频播放器窗口"
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
onClicked:{
|
|
||||||
FluApp.navigate("/media",{source:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -9,6 +9,36 @@ FluScrollablePage{
|
|||||||
|
|
||||||
title:"Menu"
|
title:"Menu"
|
||||||
|
|
||||||
|
FluMenu {
|
||||||
|
id:menu
|
||||||
|
title: qsTr("File")
|
||||||
|
Action { text: qsTr("New...")}
|
||||||
|
Action { text: qsTr("Open...") }
|
||||||
|
Action { text: qsTr("Save") }
|
||||||
|
FluMenuSeparator { }
|
||||||
|
Action {
|
||||||
|
text: qsTr("Quit")
|
||||||
|
onTriggered: {
|
||||||
|
showError("Quit")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Action {
|
||||||
|
text: qsTr("Disable")
|
||||||
|
enabled:false
|
||||||
|
onTriggered: {
|
||||||
|
showError("Disable")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluMenuSeparator { }
|
||||||
|
Action { text: qsTr("Check");checkable: true;checked: true}
|
||||||
|
FluMenu{
|
||||||
|
title: "Save As..."
|
||||||
|
Action { text: qsTr("Doc") }
|
||||||
|
Action { text: qsTr("PDF") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: 100
|
height: 100
|
||||||
@ -22,28 +52,19 @@ FluScrollablePage{
|
|||||||
left:parent.left
|
left:parent.left
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluText{
|
||||||
|
text:"Menu"
|
||||||
|
}
|
||||||
|
|
||||||
FluButton{
|
FluButton{
|
||||||
text:"左击菜单"
|
text:"Show Menu Popup"
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
onClicked:{
|
onClicked:{
|
||||||
menu.popup()
|
menu.popup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluButton{
|
|
||||||
text:"右击菜单"
|
|
||||||
Layout.topMargin: 20
|
|
||||||
onClicked: {
|
|
||||||
showSuccess("请按鼠标右击")
|
|
||||||
}
|
|
||||||
MouseArea{
|
|
||||||
anchors.fill: parent
|
|
||||||
acceptedButtons: Qt.RightButton
|
|
||||||
onClicked: {
|
|
||||||
menu.popup()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,20 +90,78 @@ menu.popup()
|
|||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
height: 100
|
||||||
|
paddings: 10
|
||||||
|
Layout.topMargin: 20
|
||||||
|
Column{
|
||||||
|
spacing: 15
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left:parent.left
|
||||||
|
}
|
||||||
|
|
||||||
|
FluText{
|
||||||
|
text:"MenuBar"
|
||||||
|
}
|
||||||
|
|
||||||
|
FluMenuBar {
|
||||||
|
id:menu_bar
|
||||||
|
FluMenu {
|
||||||
|
title: qsTr("File")
|
||||||
|
Action { text: qsTr("New...") }
|
||||||
|
Action { text: qsTr("Open...") }
|
||||||
|
Action { text: qsTr("Save") }
|
||||||
|
FluMenuSeparator { }
|
||||||
|
Action { text: qsTr("Quit") }
|
||||||
|
Action {
|
||||||
|
text: qsTr("Disable")
|
||||||
|
enabled:false
|
||||||
|
}
|
||||||
FluMenu{
|
FluMenu{
|
||||||
id:menu
|
title: "Save As..."
|
||||||
FluMenuItem{
|
Action { text: qsTr("Doc") }
|
||||||
text:"删除"
|
Action { text: qsTr("PDF") }
|
||||||
onClicked: {
|
|
||||||
showError("删除")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluMenuItem{
|
FluMenu {
|
||||||
text:"修改"
|
title: qsTr("Edit")
|
||||||
onClicked: {
|
Action { text: qsTr("Cut") }
|
||||||
showInfo("修改")
|
Action { text: qsTr("Copy") }
|
||||||
|
Action { text: qsTr("Paste") }
|
||||||
}
|
}
|
||||||
|
FluMenu {
|
||||||
|
title: qsTr("Help")
|
||||||
|
Action { text: qsTr("About") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeExpander{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: -1
|
||||||
|
code:'FluMenuBar{
|
||||||
|
id:menu
|
||||||
|
FluMenu:{
|
||||||
|
title:"File"
|
||||||
|
Action { text: qsTr("New...") }
|
||||||
|
}
|
||||||
|
FluMenu:{
|
||||||
|
title:"Edit"
|
||||||
|
Action { text: qsTr("Cut") }
|
||||||
|
Action { text: qsTr("Copy") }
|
||||||
|
Action { text: qsTr("Paste") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menu.popup()
|
||||||
|
'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -93,9 +93,9 @@ FluScrollablePage{
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
code:'FluWindow{
|
code:'FluWindow{
|
||||||
//launchMode: FluWindow.Standard
|
//launchMode: FluWindowType.Standard
|
||||||
//launchMode: FluWindow.SingleTask
|
//launchMode: FluWindowType.SingleTask
|
||||||
launchMode: FluWindow.SingleInstance
|
launchMode: FluWindowType.SingleInstance
|
||||||
}
|
}
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
49
example/qml/page/T_Pagination.qml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Window
|
||||||
|
import QtQuick.Controls
|
||||||
|
import "qrc:///example/qml/component"
|
||||||
|
import FluentUI
|
||||||
|
|
||||||
|
FluScrollablePage{
|
||||||
|
|
||||||
|
title:"Pagination"
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
height: 200
|
||||||
|
paddings: 10
|
||||||
|
Layout.topMargin: 20
|
||||||
|
ColumnLayout{
|
||||||
|
spacing: 20
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
FluPagination{
|
||||||
|
pageCurrent: 1
|
||||||
|
pageButtonCount: 5
|
||||||
|
itemCount: 5000
|
||||||
|
}
|
||||||
|
FluPagination{
|
||||||
|
pageCurrent: 2
|
||||||
|
itemCount: 5000
|
||||||
|
pageButtonCount: 7
|
||||||
|
}
|
||||||
|
FluPagination{
|
||||||
|
pageCurrent: 3
|
||||||
|
itemCount: 5000
|
||||||
|
pageButtonCount: 9
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
CodeExpander{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: -1
|
||||||
|
code:'FluPagination{
|
||||||
|
pageCurrent: 1
|
||||||
|
itemCount: 1000
|
||||||
|
pageButtonCount: 9
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -76,5 +76,4 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,33 +12,22 @@ FluScrollablePage{
|
|||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
height: 260
|
height: 130
|
||||||
paddings: 10
|
paddings: 10
|
||||||
|
|
||||||
ColumnLayout{
|
ColumnLayout{
|
||||||
spacing: 20
|
spacing: 10
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
left: parent.left
|
left: parent.left
|
||||||
}
|
}
|
||||||
|
FluText{
|
||||||
|
text: "indeterminate = true"
|
||||||
|
}
|
||||||
FluProgressBar{
|
FluProgressBar{
|
||||||
}
|
}
|
||||||
FluProgressRing{
|
FluProgressRing{
|
||||||
}
|
}
|
||||||
FluProgressBar{
|
|
||||||
id:progress_bar
|
|
||||||
indeterminate: false
|
|
||||||
}
|
|
||||||
FluProgressRing{
|
|
||||||
id:progress_ring
|
|
||||||
indeterminate: false
|
|
||||||
}
|
|
||||||
FluSlider{
|
|
||||||
value:50
|
|
||||||
onValueChanged:{
|
|
||||||
progress_bar.progress = value/100
|
|
||||||
progress_ring.progress = value/100
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CodeExpander{
|
CodeExpander{
|
||||||
@ -47,20 +36,68 @@ FluScrollablePage{
|
|||||||
code:'FluProgressBar{
|
code:'FluProgressBar{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FluProgressRing{
|
FluProgressRing{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
'
|
||||||
|
}
|
||||||
|
|
||||||
FluProgressBar{
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 20
|
||||||
|
height: 286
|
||||||
|
paddings: 10
|
||||||
|
|
||||||
|
ColumnLayout{
|
||||||
|
spacing: 10
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
text: "indeterminate = false"
|
||||||
|
}
|
||||||
|
FluProgressBar{
|
||||||
|
indeterminate: false
|
||||||
|
value:slider.value/100
|
||||||
|
Layout.topMargin: 10
|
||||||
|
}
|
||||||
|
FluProgressBar{
|
||||||
|
indeterminate: false
|
||||||
|
value:slider.value/100
|
||||||
|
progressVisible: true
|
||||||
|
Layout.topMargin: 10
|
||||||
|
}
|
||||||
|
FluProgressRing{
|
||||||
|
indeterminate: false
|
||||||
|
value: slider.value/100
|
||||||
|
Layout.topMargin: 10
|
||||||
|
}
|
||||||
|
FluProgressRing{
|
||||||
|
progressVisible: true
|
||||||
|
indeterminate: false
|
||||||
|
value: slider.value/100
|
||||||
|
}
|
||||||
|
FluSlider{
|
||||||
|
id:slider
|
||||||
|
Component.onCompleted: {
|
||||||
|
value = 50
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CodeExpander{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: -1
|
||||||
|
code:'FluProgressBar{
|
||||||
indeterminate: false
|
indeterminate: false
|
||||||
}
|
}
|
||||||
|
|
||||||
FluProgressRing{
|
FluProgressRing{
|
||||||
indeterminate: false
|
indeterminate: false
|
||||||
}'
|
progressVisible: true
|
||||||
|
}
|
||||||
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
75
example/qml/page/T_QRCode.qml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Window
|
||||||
|
import FluentUI
|
||||||
|
import Qt5Compat.GraphicalEffects
|
||||||
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
|
FluScrollablePage{
|
||||||
|
|
||||||
|
title:"QRCode"
|
||||||
|
|
||||||
|
FluQRCode{
|
||||||
|
id:qrcode
|
||||||
|
Layout.topMargin: 20
|
||||||
|
size:slider_size.value
|
||||||
|
text:text_box.text
|
||||||
|
color:color_picker.colorValue
|
||||||
|
Layout.preferredWidth: size
|
||||||
|
Layout.preferredHeight: size
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
Layout.topMargin: 20
|
||||||
|
FluText{
|
||||||
|
text:"text:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluTextBox{
|
||||||
|
id:text_box
|
||||||
|
text:"会磨刀的小猪"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
Layout.topMargin: 10
|
||||||
|
FluText{
|
||||||
|
text:"color:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluColorPicker{
|
||||||
|
id:color_picker
|
||||||
|
Component.onCompleted: {
|
||||||
|
setColor(Qt.rgba(0,0,0,1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
FluText{
|
||||||
|
text:"size:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluSlider{
|
||||||
|
id:slider_size
|
||||||
|
from:60
|
||||||
|
to:260
|
||||||
|
value: 120
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeExpander{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 20
|
||||||
|
code:'FluQRCode{
|
||||||
|
color:"red"
|
||||||
|
text:"会磨刀的小猪"
|
||||||
|
size:100
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
101
example/qml/page/T_RadioButton.qml
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Window
|
||||||
|
import QtQuick.Controls
|
||||||
|
import FluentUI
|
||||||
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
|
FluScrollablePage{
|
||||||
|
|
||||||
|
title:"RadioButton"
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
height: 68
|
||||||
|
paddings: 10
|
||||||
|
Layout.topMargin: 20
|
||||||
|
Row{
|
||||||
|
spacing: 30
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
FluRadioButton{
|
||||||
|
disabled: radio_button_switch.checked
|
||||||
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
disabled: radio_button_switch.checked
|
||||||
|
text:"Right"
|
||||||
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
disabled: radio_button_switch.checked
|
||||||
|
text:"Left"
|
||||||
|
textRight: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluToggleSwitch{
|
||||||
|
id:radio_button_switch
|
||||||
|
anchors{
|
||||||
|
right: parent.right
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
text:"Disabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CodeExpander{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: -1
|
||||||
|
code:'FluRadioButton{
|
||||||
|
text:"Text"
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
height: 100
|
||||||
|
paddings: 10
|
||||||
|
Layout.topMargin: 20
|
||||||
|
FluRadioButtons{
|
||||||
|
spacing: 8
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
disabled: radio_button_switch2.checked
|
||||||
|
text:"Radio Button_1"
|
||||||
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
disabled: radio_button_switch2.checked
|
||||||
|
text:"Radio Button_2"
|
||||||
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
disabled: radio_button_switch2.checked
|
||||||
|
text:"Radio Button_3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluToggleSwitch{
|
||||||
|
id:radio_button_switch2
|
||||||
|
anchors{
|
||||||
|
right: parent.right
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
text:"Disabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CodeExpander{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: -1
|
||||||
|
code:'FluRadioButtons{
|
||||||
|
spacing: 8
|
||||||
|
FluRadioButton{
|
||||||
|
text:"Radio Button_1"
|
||||||
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
text:"Radio Button_2"
|
||||||
|
}
|
||||||
|
FluRadioButton{
|
||||||
|
text:"Radio Button_3"
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,7 +12,7 @@ FluScrollablePage{
|
|||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
height: 480
|
height: 460
|
||||||
paddings: 10
|
paddings: 10
|
||||||
|
|
||||||
Column{
|
Column{
|
||||||
|
@ -5,8 +5,10 @@ import QtQuick.Controls
|
|||||||
import FluentUI
|
import FluentUI
|
||||||
import "qrc:///example/qml/component"
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
FluRemoteLoader{
|
FluPage{
|
||||||
property int pageMode: FluNavigationView.Standard
|
launchMode: FluPageType.SingleTop
|
||||||
property string url: ''
|
FluRemoteLoader{
|
||||||
|
anchors.fill: parent
|
||||||
source: "https://zhu-zichu.gitee.io/T_RemoteLoader.qml"
|
source: "https://zhu-zichu.gitee.io/T_RemoteLoader.qml"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@ FluScrollablePage{
|
|||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
height: 136
|
height: 128
|
||||||
paddings: 10
|
paddings: 10
|
||||||
|
|
||||||
ColumnLayout{
|
ColumnLayout{
|
||||||
spacing: 10
|
spacing: 5
|
||||||
anchors{
|
anchors{
|
||||||
top: parent.top
|
top: parent.top
|
||||||
left: parent.left
|
left: parent.left
|
||||||
@ -28,7 +28,7 @@ FluScrollablePage{
|
|||||||
Layout.bottomMargin: 4
|
Layout.bottomMargin: 4
|
||||||
}
|
}
|
||||||
Repeater{
|
Repeater{
|
||||||
model: [{title:"System",mode:FluDarkMode.System},{title:"Light",mode:FluDarkMode.Light},{title:"Dark",mode:FluDarkMode.Dark}]
|
model: [{title:"System",mode:FluThemeType.System},{title:"Light",mode:FluThemeType.Light},{title:"Dark",mode:FluThemeType.Dark}]
|
||||||
delegate: FluRadioButton{
|
delegate: FluRadioButton{
|
||||||
checked : FluTheme.darkMode === modelData.mode
|
checked : FluTheme.darkMode === modelData.mode
|
||||||
text:modelData.title
|
text:modelData.title
|
||||||
@ -43,23 +43,22 @@ FluScrollablePage{
|
|||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
height: 168
|
height: 160
|
||||||
paddings: 10
|
paddings: 10
|
||||||
|
|
||||||
ColumnLayout{
|
ColumnLayout{
|
||||||
spacing: 10
|
spacing: 5
|
||||||
anchors{
|
anchors{
|
||||||
top: parent.top
|
top: parent.top
|
||||||
left: parent.left
|
left: parent.left
|
||||||
}
|
}
|
||||||
|
|
||||||
FluText{
|
FluText{
|
||||||
text:lang.navigation_view_display_mode
|
text:lang.navigation_view_display_mode
|
||||||
font: FluTextStyle.BodyStrong
|
font: FluTextStyle.BodyStrong
|
||||||
Layout.bottomMargin: 4
|
Layout.bottomMargin: 4
|
||||||
}
|
}
|
||||||
Repeater{
|
Repeater{
|
||||||
model: [{title:"Open",mode:FluNavigationView.Open},{title:"Compact",mode:FluNavigationView.Compact},{title:"Minimal",mode:FluNavigationView.Minimal},{title:"Auto",mode:FluNavigationView.Auto}]
|
model: [{title:"Open",mode:FluNavigationViewType.Open},{title:"Compact",mode:FluNavigationViewType.Compact},{title:"Minimal",mode:FluNavigationViewType.Minimal},{title:"Auto",mode:FluNavigationViewType.Auto}]
|
||||||
delegate: FluRadioButton{
|
delegate: FluRadioButton{
|
||||||
checked : MainEvent.displayMode===modelData.mode
|
checked : MainEvent.displayMode===modelData.mode
|
||||||
text:modelData.title
|
text:modelData.title
|
||||||
|
@ -15,7 +15,6 @@ FluScrollablePage{
|
|||||||
paddings: 10
|
paddings: 10
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
FluSlider{
|
FluSlider{
|
||||||
value: 50
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,17 +26,14 @@ FluScrollablePage{
|
|||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: 200
|
height: 200
|
||||||
paddings: 10
|
paddings: 10
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
FluSlider{
|
FluSlider{
|
||||||
value: 50
|
orientation: Qt.Vertical
|
||||||
vertical:true
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 20
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,7 +41,7 @@ FluScrollablePage{
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
code:'FluSlider{
|
code:'FluSlider{
|
||||||
vertical:true
|
orientation: Qt.Vertical
|
||||||
value:50
|
value:50
|
||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
@ -21,36 +21,34 @@ FluScrollablePage{
|
|||||||
id:btn_status_mode
|
id:btn_status_mode
|
||||||
Layout.preferredWidth: 140
|
Layout.preferredWidth: 140
|
||||||
text:"Loading"
|
text:"Loading"
|
||||||
items:[
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Loading"
|
text:"Loading"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_status_mode.text = text
|
btn_status_mode.text = text
|
||||||
status_view.statusMode = FluStatusView.Loading
|
status_view.statusMode = FluStatusViewType.Loading
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Empty"
|
text:"Empty"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_status_mode.text = text
|
btn_status_mode.text = text
|
||||||
status_view.statusMode = FluStatusView.Empty
|
status_view.statusMode = FluStatusViewType.Empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Error"
|
text:"Error"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_status_mode.text = text
|
btn_status_mode.text = text
|
||||||
status_view.statusMode = FluStatusView.Error
|
status_view.statusMode = FluStatusViewType.Error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Success"
|
text:"Success"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_status_mode.text = text
|
btn_status_mode.text = text
|
||||||
status_view.statusMode = FluStatusView.Success
|
status_view.statusMode = FluStatusViewType.Success
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +75,7 @@ FluScrollablePage{
|
|||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
code:'FluStatusView{
|
code:'FluStatusView{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
statusMode: FluStatusView.Loading
|
statusMode: FluStatusViewType.Loading
|
||||||
Rectangle{
|
Rectangle{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color:FluTheme.primaryColor.dark
|
color:FluTheme.primaryColor.dark
|
||||||
|
@ -40,57 +40,53 @@ FluScrollablePage{
|
|||||||
id:btn_tab_width_behavior
|
id:btn_tab_width_behavior
|
||||||
Layout.preferredWidth: 140
|
Layout.preferredWidth: 140
|
||||||
text:"Equal"
|
text:"Equal"
|
||||||
items:[
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Equal"
|
text:"Equal"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_tab_width_behavior.text = text
|
btn_tab_width_behavior.text = text
|
||||||
tab_view.tabWidthBehavior = FluTabView.Equal
|
tab_view.tabWidthBehavior = FluTabViewType.Equal
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"SizeToContent"
|
text:"SizeToContent"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_tab_width_behavior.text = text
|
btn_tab_width_behavior.text = text
|
||||||
tab_view.tabWidthBehavior = FluTabView.SizeToContent
|
tab_view.tabWidthBehavior = FluTabViewType.SizeToContent
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Compact"
|
text:"Compact"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_tab_width_behavior.text = text
|
btn_tab_width_behavior.text = text
|
||||||
tab_view.tabWidthBehavior = FluTabView.Compact
|
tab_view.tabWidthBehavior = FluTabViewType.Compact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
FluDropDownButton{
|
FluDropDownButton{
|
||||||
id:btn_close_button_visibility
|
id:btn_close_button_visibility
|
||||||
text:"Always"
|
text:"Always"
|
||||||
Layout.preferredWidth: 120
|
Layout.preferredWidth: 120
|
||||||
items:[
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Nerver"
|
text:"Nerver"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_close_button_visibility.text = text
|
btn_close_button_visibility.text = text
|
||||||
tab_view.closeButtonVisibility = FluTabView.Nerver
|
tab_view.closeButtonVisibility = FluTabViewType.Nerver
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Always"
|
text:"Always"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_close_button_visibility.text = text
|
btn_close_button_visibility.text = text
|
||||||
tab_view.closeButtonVisibility = FluTabView.Always
|
tab_view.closeButtonVisibility = FluTabViewType.Always
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"OnHover"
|
text:"OnHover"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_close_button_visibility.text = text
|
btn_close_button_visibility.text = text
|
||||||
tab_view.closeButtonVisibility = FluTabView.OnHover
|
tab_view.closeButtonVisibility = FluTabViewType.OnHover
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,141 +5,173 @@ import QtQuick.Window
|
|||||||
import FluentUI
|
import FluentUI
|
||||||
import "qrc:///example/qml/component"
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
FluScrollablePage{
|
FluContentPage{
|
||||||
|
|
||||||
title:"TableView"
|
title:"TableView"
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
const columns = [
|
loadData(1,1000)
|
||||||
{
|
|
||||||
title: '姓名',
|
|
||||||
dataIndex: 'name',
|
|
||||||
width:100
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '年龄',
|
|
||||||
dataIndex: 'age',
|
|
||||||
width:100
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '住址',
|
|
||||||
dataIndex: 'address',
|
|
||||||
width:200
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '别名',
|
|
||||||
dataIndex: 'nickname',
|
|
||||||
width:100
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '操作',
|
|
||||||
dataIndex: 'action',
|
|
||||||
width:120
|
|
||||||
},
|
|
||||||
];
|
|
||||||
table_view.columns = columns
|
|
||||||
loadData(1,10)
|
|
||||||
}
|
|
||||||
|
|
||||||
FluTableView{
|
|
||||||
id:table_view
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 20
|
|
||||||
pageCurrent:1
|
|
||||||
pageCount:10
|
|
||||||
itemCount: 1000
|
|
||||||
onRequestPage:
|
|
||||||
(page,count)=> {
|
|
||||||
loadData(page,count)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
id:com_action
|
id:com_action
|
||||||
Item{
|
Item{
|
||||||
Row{
|
RowLayout{
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: 10
|
FluButton{
|
||||||
|
text:"删除"
|
||||||
|
onClicked: {
|
||||||
|
table_view.closeEditor()
|
||||||
|
tableModel.removeRow(row)
|
||||||
|
}
|
||||||
|
}
|
||||||
FluFilledButton{
|
FluFilledButton{
|
||||||
text:"编辑"
|
text:"编辑"
|
||||||
horizontalPadding: 6
|
onClicked: {
|
||||||
onClicked:{
|
showSuccess(JSON.stringify(tableModel.getRow(row)))
|
||||||
showSuccess(JSON.stringify(dataObject))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FluFilledButton{
|
|
||||||
text:"删除"
|
|
||||||
horizontalPadding: 6
|
|
||||||
onClicked:{
|
|
||||||
showError(JSON.stringify(dataObject))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeExpander{
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 10
|
|
||||||
code:'FluTableView{
|
|
||||||
id:table_view
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 20
|
|
||||||
pageCurrent:1
|
|
||||||
pageCount:10
|
|
||||||
itemCount: 1000
|
|
||||||
onRequestPage:
|
|
||||||
(page,count)=> {
|
|
||||||
loadData(page,count)
|
|
||||||
}
|
|
||||||
Component.onCompleted: {
|
|
||||||
const columns = [
|
|
||||||
{
|
|
||||||
title: "姓名",
|
|
||||||
dataIndex: "name",
|
|
||||||
width:100
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "年龄",
|
|
||||||
dataIndex: "age",
|
|
||||||
width:100
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "住址",
|
|
||||||
dataIndex: "address",
|
|
||||||
width:200
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "别名",
|
|
||||||
dataIndex: "nickname",
|
|
||||||
width:100
|
|
||||||
}
|
|
||||||
];
|
|
||||||
table_view.columns = columns
|
|
||||||
const dataSource = [
|
|
||||||
{
|
|
||||||
name: "孙悟空”,
|
|
||||||
age: 500,
|
|
||||||
address:"钟灵毓秀的花果山,如神仙仙境的水帘洞",
|
|
||||||
nickname:"齐天大圣"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
table_view.dataSource = columns
|
|
||||||
}
|
|
||||||
}'
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadData(page,count){
|
function loadData(page,count){
|
||||||
|
var numbers = [100, 300, 500, 1000];
|
||||||
|
function getRandomAge() {
|
||||||
|
var randomIndex = Math.floor(Math.random() * numbers.length);
|
||||||
|
return numbers[randomIndex];
|
||||||
|
}
|
||||||
|
var names = ["孙悟空", "猪八戒", "沙和尚", "唐僧","白骨夫人","金角大王","熊山君","黄风怪","银角大王"];
|
||||||
|
function getRandomName(){
|
||||||
|
var randomIndex = Math.floor(Math.random() * names.length);
|
||||||
|
return names[randomIndex];
|
||||||
|
}
|
||||||
|
var nicknames = ["复海大圣","混天大圣","移山大圣","通风大圣","驱神大圣","齐天大圣","平天大圣"]
|
||||||
|
function getRandomNickname(){
|
||||||
|
var randomIndex = Math.floor(Math.random() * nicknames.length);
|
||||||
|
return nicknames[randomIndex];
|
||||||
|
}
|
||||||
|
var addresses = ["傲来国界花果山水帘洞","傲来国界坎源山脏水洞","大唐国界黑风山黑风洞","大唐国界黄风岭黄风洞","大唐国界骷髅山白骨洞","宝象国界碗子山波月洞","宝象国界平顶山莲花洞","宝象国界压龙山压龙洞","乌鸡国界号山枯松涧火云洞","乌鸡国界衡阳峪黑水河河神府"]
|
||||||
|
function getRandomAddresses(){
|
||||||
|
var randomIndex = Math.floor(Math.random() * addresses.length);
|
||||||
|
return addresses[randomIndex];
|
||||||
|
}
|
||||||
const dataSource = []
|
const dataSource = []
|
||||||
for(var i=0;i<count;i++){
|
for(var i=0;i<count;i++){
|
||||||
dataSource.push({
|
dataSource.push({
|
||||||
name: "孙悟空%1".arg(((page-1)*count+i)),
|
name: getRandomName(),
|
||||||
age: 500,
|
age:getRandomAge(),
|
||||||
address: "钟灵毓秀的花果山,如神仙仙境的水帘洞",
|
address: getRandomAddresses(),
|
||||||
nickname: "齐天大圣",
|
nickname: getRandomNickname(),
|
||||||
|
longstring:"你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好",
|
||||||
|
height:42,
|
||||||
|
minimumHeight:42,
|
||||||
|
maximumHeight:300,
|
||||||
action:com_action
|
action:com_action
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
table_view.dataSource = dataSource
|
table_view.dataSource = dataSource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component{
|
||||||
|
id:com_combobox
|
||||||
|
FluComboBox {
|
||||||
|
anchors.fill: parent
|
||||||
|
focus: true
|
||||||
|
currentIndex: display
|
||||||
|
editable: true
|
||||||
|
model: ListModel {
|
||||||
|
ListElement { text: 100 }
|
||||||
|
ListElement { text: 300 }
|
||||||
|
ListElement { text: 500 }
|
||||||
|
ListElement { text: 1000 }
|
||||||
|
}
|
||||||
|
Component.onCompleted: {
|
||||||
|
currentIndex=[100,300,500,1000].findIndex((element) => element === Number(display))
|
||||||
|
selectAll()
|
||||||
|
}
|
||||||
|
onCommit: {
|
||||||
|
display = editText
|
||||||
|
tableView.closeEditor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluTableView{
|
||||||
|
id:table_view
|
||||||
|
anchors{
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
top: parent.top
|
||||||
|
bottom: gagination.top
|
||||||
|
}
|
||||||
|
anchors.topMargin: 20
|
||||||
|
columnSource:[
|
||||||
|
{
|
||||||
|
title: '姓名',
|
||||||
|
dataIndex: 'name',
|
||||||
|
width:100,
|
||||||
|
minimumWidth:80,
|
||||||
|
maximumWidth:200,
|
||||||
|
readOnly:true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '年龄',
|
||||||
|
dataIndex: 'age',
|
||||||
|
editDelegate:com_combobox,
|
||||||
|
width:100,
|
||||||
|
minimumWidth:100,
|
||||||
|
maximumWidth:100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '住址',
|
||||||
|
dataIndex: 'address',
|
||||||
|
width:200,
|
||||||
|
minimumWidth:100,
|
||||||
|
maximumWidth:250
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '别名',
|
||||||
|
dataIndex: 'nickname',
|
||||||
|
width:100,
|
||||||
|
minimumWidth:80,
|
||||||
|
maximumWidth:200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '长字符串',
|
||||||
|
dataIndex: 'longstring',
|
||||||
|
width:200,
|
||||||
|
minimumWidth:100,
|
||||||
|
maximumWidth:300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
dataIndex: 'action',
|
||||||
|
width:160,
|
||||||
|
minimumWidth:160,
|
||||||
|
maximumWidth:160
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
FluPagination{
|
||||||
|
id:gagination
|
||||||
|
anchors{
|
||||||
|
bottom: parent.bottom
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
pageCurrent: 1
|
||||||
|
itemCount: 100000
|
||||||
|
pageButtonCount: 7
|
||||||
|
__itemPerPage: 1000
|
||||||
|
onRequestPage:
|
||||||
|
(page,count)=> {
|
||||||
|
table_view.closeEditor()
|
||||||
|
loadData(page,count)
|
||||||
|
table_view.resetPosition()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@ import "qrc:///example/qml/component"
|
|||||||
|
|
||||||
FluScrollablePage{
|
FluScrollablePage{
|
||||||
|
|
||||||
title:"TextBox"
|
launchMode: FluPageType.SingleInstance
|
||||||
|
|
||||||
|
title:"TextBox"
|
||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: 68
|
height: 68
|
||||||
@ -16,29 +17,24 @@ FluScrollablePage{
|
|||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
|
|
||||||
FluTextBox{
|
FluTextBox{
|
||||||
Layout.topMargin: 20
|
|
||||||
placeholderText: "单行输入框"
|
placeholderText: "单行输入框"
|
||||||
Layout.preferredWidth: 300
|
|
||||||
disabled:text_box_switch.checked
|
disabled:text_box_switch.checked
|
||||||
|
cleanEnabled: true
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
left: parent.left
|
left: parent.left
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row{
|
FluToggleSwitch{
|
||||||
spacing: 5
|
id:text_box_switch
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
right: parent.right
|
right: parent.right
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
|
||||||
id:text_box_switch
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
text:"Disabled"
|
text:"Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
CodeExpander{
|
CodeExpander{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
@ -54,29 +50,22 @@ FluScrollablePage{
|
|||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
|
|
||||||
FluPasswordBox{
|
FluPasswordBox{
|
||||||
Layout.topMargin: 20
|
|
||||||
placeholderText: "请输入密码"
|
placeholderText: "请输入密码"
|
||||||
Layout.preferredWidth: 300
|
|
||||||
disabled:password_box_switch.checked
|
disabled:password_box_switch.checked
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
left: parent.left
|
left: parent.left
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluToggleSwitch{
|
||||||
Row{
|
id:password_box_switch
|
||||||
spacing: 5
|
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
right: parent.right
|
right: parent.right
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
|
||||||
id:password_box_switch
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
text:"Disabled"
|
text:"Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
CodeExpander{
|
CodeExpander{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
@ -94,9 +83,7 @@ FluScrollablePage{
|
|||||||
|
|
||||||
FluMultilineTextBox{
|
FluMultilineTextBox{
|
||||||
id:multiine_textbox
|
id:multiine_textbox
|
||||||
Layout.topMargin: 20
|
|
||||||
placeholderText: "多行输入框"
|
placeholderText: "多行输入框"
|
||||||
Layout.preferredWidth: 300
|
|
||||||
disabled:text_box_multi_switch.checked
|
disabled:text_box_multi_switch.checked
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
@ -104,19 +91,15 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row{
|
FluToggleSwitch{
|
||||||
spacing: 5
|
id:text_box_multi_switch
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
right: parent.right
|
right: parent.right
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
|
||||||
id:text_box_multi_switch
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
text:"Disabled"
|
text:"Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
CodeExpander{
|
CodeExpander{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
@ -125,17 +108,13 @@ FluScrollablePage{
|
|||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: 68
|
height: 68
|
||||||
paddings: 10
|
paddings: 10
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
|
|
||||||
FluAutoSuggestBox{
|
FluAutoSuggestBox{
|
||||||
Layout.topMargin: 20
|
|
||||||
placeholderText: "AutoSuggestBox"
|
placeholderText: "AutoSuggestBox"
|
||||||
Layout.preferredWidth: 300
|
|
||||||
items:generateRandomNames(100)
|
items:generateRandomNames(100)
|
||||||
disabled:text_box_suggest_switch.checked
|
disabled:text_box_suggest_switch.checked
|
||||||
anchors{
|
anchors{
|
||||||
@ -143,20 +122,15 @@ FluScrollablePage{
|
|||||||
left: parent.left
|
left: parent.left
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluToggleSwitch{
|
||||||
Row{
|
id:text_box_suggest_switch
|
||||||
spacing: 5
|
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
right: parent.right
|
right: parent.right
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
|
||||||
id:text_box_suggest_switch
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
text:"Disabled"
|
text:"Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
CodeExpander{
|
CodeExpander{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
@ -165,6 +139,34 @@ FluScrollablePage{
|
|||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
height: 68
|
||||||
|
paddings: 10
|
||||||
|
Layout.topMargin: 20
|
||||||
|
FluSpinBox{
|
||||||
|
disabled: spin_box_switch.checked
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluToggleSwitch{
|
||||||
|
id:spin_box_switch
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
text:"Disabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CodeExpander{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: -1
|
||||||
|
code:'FluSpinBox{
|
||||||
|
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
function generateRandomNames(numNames) {
|
function generateRandomNames(numNames) {
|
||||||
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
@ -12,7 +12,7 @@ FluScrollablePage{
|
|||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
height: 210
|
height: 270
|
||||||
paddings: 10
|
paddings: 10
|
||||||
ColumnLayout{
|
ColumnLayout{
|
||||||
spacing:0
|
spacing:0
|
||||||
@ -55,9 +55,9 @@ FluScrollablePage{
|
|||||||
checked: FluTheme.dark
|
checked: FluTheme.dark
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(FluTheme.dark){
|
if(FluTheme.dark){
|
||||||
FluTheme.darkMode = FluDarkMode.Light
|
FluTheme.darkMode = FluThemeType.Light
|
||||||
}else{
|
}else{
|
||||||
FluTheme.darkMode = FluDarkMode.Dark
|
FluTheme.darkMode = FluThemeType.Dark
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,6 +72,17 @@ FluScrollablePage{
|
|||||||
FluTheme.nativeText = !FluTheme.nativeText
|
FluTheme.nativeText = !FluTheme.nativeText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluText{
|
||||||
|
text:"开启动画效果"
|
||||||
|
Layout.topMargin: 20
|
||||||
|
}
|
||||||
|
FluToggleSwitch{
|
||||||
|
Layout.topMargin: 5
|
||||||
|
checked: FluTheme.enableAnimation
|
||||||
|
onClicked: {
|
||||||
|
FluTheme.enableAnimation = !FluTheme.enableAnimation
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CodeExpander{
|
CodeExpander{
|
||||||
|
@ -8,7 +8,7 @@ import "qrc:///example/qml/component"
|
|||||||
FluScrollablePage{
|
FluScrollablePage{
|
||||||
|
|
||||||
title:"TimePicker"
|
title:"TimePicker"
|
||||||
|
launchMode: FluPageType.SingleInstance
|
||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
@ -23,10 +23,13 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
FluText{
|
FluText{
|
||||||
text:"hourFormat=FluTimePicker.H"
|
text:"hourFormat=FluTimePickerType.H"
|
||||||
}
|
}
|
||||||
|
|
||||||
FluTimePicker{
|
FluTimePicker{
|
||||||
|
onCurrentChanged: {
|
||||||
|
showSuccess(current.toLocaleTimeString(Qt.locale("de_DE")))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -53,11 +56,14 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
FluText{
|
FluText{
|
||||||
text:"hourFormat=FluTimePicker.H"
|
text:"hourFormat=FluTimePickerType.HH"
|
||||||
}
|
}
|
||||||
|
|
||||||
FluTimePicker{
|
FluTimePicker{
|
||||||
hourFormat:FluTimePicker.HH
|
hourFormat:FluTimePickerType.HH
|
||||||
|
onCurrentChanged: {
|
||||||
|
showSuccess(current.toLocaleTimeString(Qt.locale("de_DE")))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -66,7 +72,7 @@ FluScrollablePage{
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
code:'FluTimePicker{
|
code:'FluTimePicker{
|
||||||
hourFormat:FluTimePicker.HH
|
hourFormat:FluTimePickerType.HH
|
||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,12 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
disabled: toggle_switch.checked
|
disabled: toggle_switch.checked
|
||||||
|
text:"Right"
|
||||||
|
}
|
||||||
|
FluToggleSwitch{
|
||||||
|
disabled: toggle_switch.checked
|
||||||
|
text:"Left"
|
||||||
|
textRight: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
|
80
example/qml/page/T_Tour.qml
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Window
|
||||||
|
import QtQuick.Controls
|
||||||
|
import FluentUI
|
||||||
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
|
FluScrollablePage{
|
||||||
|
|
||||||
|
title:"Tour"
|
||||||
|
|
||||||
|
FluTour{
|
||||||
|
id:tour
|
||||||
|
steps:[
|
||||||
|
{title:"Upload File",description: "Put your files here.",target:()=>btn_upload},
|
||||||
|
{title:"Save",description: "Save your changes.",target:()=>btn_save},
|
||||||
|
{title:"Other Actions",description: "Click to see other actions.",target:()=>btn_more}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
height: 130
|
||||||
|
paddings: 10
|
||||||
|
Layout.topMargin: 20
|
||||||
|
|
||||||
|
FluFilledButton{
|
||||||
|
anchors{
|
||||||
|
top: parent.top
|
||||||
|
topMargin: 14
|
||||||
|
}
|
||||||
|
text:"Begin Tour"
|
||||||
|
onClicked: {
|
||||||
|
tour.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row{
|
||||||
|
spacing: 20
|
||||||
|
anchors{
|
||||||
|
top: parent.top
|
||||||
|
topMargin: 60
|
||||||
|
}
|
||||||
|
FluButton{
|
||||||
|
id:btn_upload
|
||||||
|
text:"Upload"
|
||||||
|
onClicked: {
|
||||||
|
showInfo("Upload")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluFilledButton{
|
||||||
|
id:btn_save
|
||||||
|
text:"Save"
|
||||||
|
onClicked: {
|
||||||
|
showInfo("Save")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluIconButton{
|
||||||
|
id:btn_more
|
||||||
|
iconSource: FluentIcons.More
|
||||||
|
onClicked: {
|
||||||
|
showInfo("More")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CodeExpander{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: -1
|
||||||
|
code:'FluTour{
|
||||||
|
id:tour
|
||||||
|
steps:[
|
||||||
|
{title:"Upload File",description: "Put your files here.",target:()=>btn_upload},
|
||||||
|
{title:"Save",description: "Save your changes.",target:()=>btn_save},
|
||||||
|
{title:"Other Actions",description: "Click to see other actions.",target:()=>btn_more}
|
||||||
|
]
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -60,44 +60,42 @@ FluScrollablePage {
|
|||||||
id:btn_selection_model
|
id:btn_selection_model
|
||||||
Layout.preferredWidth: 140
|
Layout.preferredWidth: 140
|
||||||
text:"None"
|
text:"None"
|
||||||
items:[
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"None"
|
text:"None"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_selection_model.text = text
|
btn_selection_model.text = text
|
||||||
tree_view.selectionMode = FluTabView.Equal
|
tree_view.selectionMode = FluTabViewType.Equal
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Single"
|
text:"Single"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_selection_model.text = text
|
btn_selection_model.text = text
|
||||||
tree_view.selectionMode = FluTabView.SizeToContent
|
tree_view.selectionMode = FluTabViewType.SizeToContent
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
FluMenuItem{
|
FluMenuItem{
|
||||||
text:"Muiltple"
|
text:"Muiltple"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
btn_selection_model.text = text
|
btn_selection_model.text = text
|
||||||
tree_view.selectionMode = FluTabView.Compact
|
tree_view.selectionMode = FluTabViewType.Compact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
FluFilledButton{
|
FluFilledButton{
|
||||||
text:"获取选中的数据"
|
text:"获取选中的数据"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(tree_view.selectionMode === FluTreeView.None){
|
if(tree_view.selectionMode === FluTreeViewType.None){
|
||||||
showError("当前非选择模式,没有选中的数据")
|
showError("当前非选择模式,没有选中的数据")
|
||||||
}
|
}
|
||||||
if(tree_view.selectionMode === FluTreeView.Single){
|
if(tree_view.selectionMode === FluTreeViewType.Single){
|
||||||
if(!tree_view.signleData()){
|
if(!tree_view.signleData()){
|
||||||
showError("没有选中数据")
|
showError("没有选中数据")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
showSuccess(tree_view.signleData().text)
|
showSuccess(tree_view.signleData().text)
|
||||||
}
|
}
|
||||||
if(tree_view.selectionMode === FluTreeView.Multiple){
|
if(tree_view.selectionMode === FluTreeViewType.Multiple){
|
||||||
if(tree_view.multipData().length===0){
|
if(tree_view.multipData().length===0){
|
||||||
showError("没有选中数据")
|
showError("没有选中数据")
|
||||||
return
|
return
|
||||||
|
@ -10,10 +10,6 @@ FluContentPage {
|
|||||||
title: "Typography"
|
title: "Typography"
|
||||||
rightPadding: 10
|
rightPadding: 10
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
slider.seek(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
FluArea{
|
FluArea{
|
||||||
anchors{
|
anchors{
|
||||||
top:parent.top
|
top:parent.top
|
||||||
@ -73,7 +69,7 @@ FluContentPage {
|
|||||||
|
|
||||||
FluSlider{
|
FluSlider{
|
||||||
id:slider
|
id:slider
|
||||||
vertical:true
|
orientation: Qt.Vertical
|
||||||
anchors{
|
anchors{
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: 45
|
rightMargin: 45
|
||||||
|
132
example/qml/page/T_Watermark.qml
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Window
|
||||||
|
import FluentUI
|
||||||
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
|
FluContentPage{
|
||||||
|
|
||||||
|
title:"Watermark"
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.topMargin: 20
|
||||||
|
|
||||||
|
ColumnLayout{
|
||||||
|
anchors{
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 14
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
Layout.topMargin: 14
|
||||||
|
FluText{
|
||||||
|
text:"text:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluTextBox{
|
||||||
|
id:text_box
|
||||||
|
text:"会磨刀的小猪"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
FluText{
|
||||||
|
text:"textSize:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluSlider{
|
||||||
|
id:slider_text_size
|
||||||
|
value: 20
|
||||||
|
from: 13
|
||||||
|
to:50
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
FluText{
|
||||||
|
text:"gapX:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluSlider{
|
||||||
|
id:slider_gap_x
|
||||||
|
value: 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
FluText{
|
||||||
|
text:"gapY:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluSlider{
|
||||||
|
id:slider_gap_y
|
||||||
|
value: 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
FluText{
|
||||||
|
text:"offsetX:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluSlider{
|
||||||
|
id:slider_offset_x
|
||||||
|
value: 50
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
FluText{
|
||||||
|
text:"offsetY:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluSlider{
|
||||||
|
id:slider_offset_y
|
||||||
|
value: 50
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
FluText{
|
||||||
|
text:"rotate:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluSlider{
|
||||||
|
id:slider_rotate
|
||||||
|
value: 22
|
||||||
|
from: 0
|
||||||
|
to:360
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout{
|
||||||
|
spacing: 10
|
||||||
|
FluText{
|
||||||
|
text:"textColor:"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluColorPicker{
|
||||||
|
id:color_picker
|
||||||
|
Component.onCompleted: {
|
||||||
|
setColor(Qt.rgba(0,0,0,0.1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluWatermark{
|
||||||
|
id:water_mark
|
||||||
|
anchors.fill: parent
|
||||||
|
text:text_box.text
|
||||||
|
textColor: color_picker.colorValue
|
||||||
|
textSize: slider_text_size.value
|
||||||
|
rotate: slider_rotate.value
|
||||||
|
gap:Qt.point(slider_gap_x.value,slider_gap_y.value)
|
||||||
|
offset: Qt.point(slider_offset_x.value,slider_offset_y.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,7 +11,7 @@ CustomWindow {
|
|||||||
width: 600
|
width: 600
|
||||||
height: 600
|
height: 600
|
||||||
fixSize: true
|
fixSize: true
|
||||||
launchMode: FluWindow.SingleTask
|
launchMode: FluWindowType.SingleTask
|
||||||
|
|
||||||
ColumnLayout{
|
ColumnLayout{
|
||||||
anchors{
|
anchors{
|
||||||
|
85
example/qml/window/HotloadWindow.qml
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import FluentUI
|
||||||
|
import example
|
||||||
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
|
CustomWindow {
|
||||||
|
|
||||||
|
id:window
|
||||||
|
title:"热加载"
|
||||||
|
width: 800
|
||||||
|
height: 600
|
||||||
|
minimumWidth: 520
|
||||||
|
minimumHeight: 200
|
||||||
|
launchMode: FluWindowType.SingleTask
|
||||||
|
FileWatcher{
|
||||||
|
id:watcher
|
||||||
|
onFileChanged: {
|
||||||
|
loader.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
FluRemoteLoader{
|
||||||
|
id:loader
|
||||||
|
anchors.fill: parent
|
||||||
|
statusMode: FluStatusViewType.Success
|
||||||
|
lazy: true
|
||||||
|
errorItem: Item{
|
||||||
|
FluText{
|
||||||
|
text:loader.itemLodaer().sourceComponent.errorString()
|
||||||
|
color:"red"
|
||||||
|
anchors.fill: parent
|
||||||
|
wrapMode: Text.WrapAnywhere
|
||||||
|
padding: 20
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
text:"拖入qml文件"
|
||||||
|
font.pixelSize: 26
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: !loader.itemLodaer().item && loader.statusMode === FluStatusViewType.Success
|
||||||
|
}
|
||||||
|
Rectangle{
|
||||||
|
radius: 4
|
||||||
|
anchors.fill: parent
|
||||||
|
color: "#33333333"
|
||||||
|
visible: drop_area.containsDrag
|
||||||
|
}
|
||||||
|
DropArea{
|
||||||
|
id:drop_area
|
||||||
|
anchors.fill: parent
|
||||||
|
onEntered:
|
||||||
|
(event)=>{
|
||||||
|
if(!event.hasUrls){
|
||||||
|
event.accepted = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (event.urls.length !== 1) {
|
||||||
|
event.accepted = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var url = event.urls[0].toString()
|
||||||
|
var fileExtension = url.substring(url.lastIndexOf(".") + 1)
|
||||||
|
if (fileExtension !== "qml") {
|
||||||
|
event.accepted = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
onDropped:
|
||||||
|
(event)=>{
|
||||||
|
var path = event.urls[0].toString()
|
||||||
|
loader.source = path
|
||||||
|
watcher.path = path
|
||||||
|
loader.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ import QtQuick.Controls
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Qt.labs.platform
|
import Qt.labs.platform
|
||||||
import FluentUI
|
import FluentUI
|
||||||
|
import example
|
||||||
import "qrc:///example/qml/component"
|
import "qrc:///example/qml/component"
|
||||||
import "qrc:///example/qml/global"
|
import "qrc:///example/qml/global"
|
||||||
|
|
||||||
@ -15,22 +16,18 @@ CustomWindow {
|
|||||||
height: 640
|
height: 640
|
||||||
closeDestory:false
|
closeDestory:false
|
||||||
minimumWidth: 520
|
minimumWidth: 520
|
||||||
minimumHeight: 460
|
minimumHeight: 200
|
||||||
appBarVisible: false
|
appBarVisible: false
|
||||||
launchMode: FluWindow.SingleTask
|
launchMode: FluWindowType.SingleTask
|
||||||
|
|
||||||
closeFunc:function(event){
|
closeFunc:function(event){
|
||||||
close_app.open()
|
dialog_close.open()
|
||||||
event.accepted = false
|
event.accepted = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections{
|
Component.onCompleted: {
|
||||||
target: appInfo
|
FluTools.setQuitOnLastWindowClosed(false)
|
||||||
function onActiveWindow(){
|
tour.open()
|
||||||
window.show()
|
|
||||||
window.raise()
|
|
||||||
window.requestActivate()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemTrayIcon {
|
SystemTrayIcon {
|
||||||
@ -58,18 +55,17 @@ CustomWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FluContentDialog{
|
FluContentDialog{
|
||||||
id:close_app
|
id:dialog_close
|
||||||
title:"退出"
|
title:"退出"
|
||||||
message:"确定要退出程序吗?"
|
message:"确定要退出程序吗?"
|
||||||
negativeText:"最小化"
|
negativeText:"最小化"
|
||||||
buttonFlags: FluContentDialog.NeutralButton | FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
|
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.NeutralButton | FluContentDialogType.PositiveButton
|
||||||
onNegativeClicked:{
|
onNegativeClicked:{
|
||||||
window.hide()
|
window.hide()
|
||||||
system_tray.showMessage("友情提示","FluentUI已隐藏至托盘,点击托盘可再次激活窗口");
|
system_tray.showMessage("友情提示","FluentUI已隐藏至托盘,点击托盘可再次激活窗口");
|
||||||
}
|
}
|
||||||
positiveText:"退出"
|
positiveText:"退出"
|
||||||
neutralText:"取消"
|
neutralText:"取消"
|
||||||
blurSource: nav_view
|
|
||||||
onPositiveClicked:{
|
onPositiveClicked:{
|
||||||
window.deleteWindow()
|
window.deleteWindow()
|
||||||
FluApp.closeApp()
|
FluApp.closeApp()
|
||||||
@ -94,7 +90,7 @@ CustomWindow {
|
|||||||
when: flipable.flipped
|
when: flipable.flipped
|
||||||
}
|
}
|
||||||
transitions: Transition {
|
transitions: Transition {
|
||||||
NumberAnimation { target: flipable; property: "flipAngle"; duration: 1000 ; easing.type: Easing.OutQuad}
|
NumberAnimation { target: flipable; property: "flipAngle"; duration: 1000 ; easing.type: Easing.OutCubic}
|
||||||
}
|
}
|
||||||
back: Item{
|
back: Item{
|
||||||
anchors.fill: flipable
|
anchors.fill: flipable
|
||||||
@ -112,6 +108,12 @@ CustomWindow {
|
|||||||
}
|
}
|
||||||
Row{
|
Row{
|
||||||
z:8
|
z:8
|
||||||
|
anchors{
|
||||||
|
top: parent.top
|
||||||
|
left: parent.left
|
||||||
|
topMargin: FluTools.isMacos() ? 20 : 5
|
||||||
|
leftMargin: 5
|
||||||
|
}
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
iconSource: FluentIcons.ChromeBack
|
iconSource: FluentIcons.ChromeBack
|
||||||
width: 30
|
width: 30
|
||||||
@ -134,8 +136,9 @@ CustomWindow {
|
|||||||
|
|
||||||
FluRemoteLoader{
|
FluRemoteLoader{
|
||||||
id:loader
|
id:loader
|
||||||
|
lazy: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
// source: "http://localhost:9000/RemoteComponent.qml"
|
// source: "http://localhost:9000/RemoteComponent.qml"
|
||||||
source: "https://zhu-zichu.gitee.io/RemoteComponent.qml"
|
source: "https://zhu-zichu.gitee.io/RemoteComponent.qml"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,6 +147,7 @@ CustomWindow {
|
|||||||
visible: flipable.flipAngle !== 180
|
visible: flipable.flipAngle !== 180
|
||||||
anchors.fill: flipable
|
anchors.fill: flipable
|
||||||
FluAppBar {
|
FluAppBar {
|
||||||
|
id:app_bar_front
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
left: parent.left
|
left: parent.left
|
||||||
@ -160,21 +164,20 @@ CustomWindow {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
z:999
|
z:999
|
||||||
|
//Stack模式,每次切换都会将页面压入栈中,随着栈的页面增多,消耗的内存也越多,内存消耗多就会卡顿,这时候就需要按返回将页面pop掉,释放内存。该模式可以配合FluPage中的launchMode属性,设置页面的启动模式
|
||||||
|
pageMode: FluNavigationViewType.Stack
|
||||||
|
//NoStack模式,每次切换都会销毁之前的页面然后创建一个新的页面,只需消耗少量内存(推荐)
|
||||||
|
// pageMode: FluNavigationViewType.NoStack
|
||||||
items: ItemsOriginal
|
items: ItemsOriginal
|
||||||
footerItems:ItemsFooter
|
footerItems:ItemsFooter
|
||||||
topPadding:FluTools.isMacos() ? 20 : 5
|
topPadding:FluTools.isMacos() ? 20 : 5
|
||||||
displayMode:MainEvent.displayMode
|
displayMode:MainEvent.displayMode
|
||||||
logo: "qrc:/example/res/image/favicon.ico"
|
logo: "qrc:/example/res/image/favicon.ico"
|
||||||
title:"FluentUI"
|
title:"FluentUI"
|
||||||
Behavior on rotation {
|
onLogoClicked:{
|
||||||
NumberAnimation{
|
|
||||||
duration: 167
|
|
||||||
}
|
|
||||||
}
|
|
||||||
transformOrigin: Item.Center
|
|
||||||
onLoginClicked:{
|
|
||||||
clickCount += 1
|
clickCount += 1
|
||||||
if(clickCount === 1){
|
showSuccess("点击%1次".arg(clickCount))
|
||||||
|
if(clickCount === 5){
|
||||||
loader.reload()
|
loader.reload()
|
||||||
flipable.flipped = true
|
flipable.flipped = true
|
||||||
clickCount = 0
|
clickCount = 0
|
||||||
@ -200,55 +203,25 @@ CustomWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Image{
|
Component{
|
||||||
id:img_cache
|
id:com_reveal
|
||||||
visible: false
|
CircularReveal{
|
||||||
|
id:reveal
|
||||||
|
target:window.contentItem
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
onAnimationFinished:{
|
||||||
|
//动画结束后释放资源
|
||||||
|
loader_reveal.sourceComponent = undefined
|
||||||
|
}
|
||||||
|
onImageChanged: {
|
||||||
|
changeDark()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Canvas{
|
Loader{
|
||||||
id:canvas
|
id:loader_reveal
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
property int centerX: canvas.width / 2
|
|
||||||
property int centerY: canvas.height / 2
|
|
||||||
property real radius: 0
|
|
||||||
property int maxRadius: 0
|
|
||||||
property url imageUrl
|
|
||||||
Behavior on radius{
|
|
||||||
id:anim_radius
|
|
||||||
NumberAnimation {
|
|
||||||
target: canvas
|
|
||||||
property: "radius"
|
|
||||||
duration: 666
|
|
||||||
easing.type: Easing.OutCubic
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onRadiusChanged: {
|
|
||||||
canvas.requestPaint()
|
|
||||||
}
|
|
||||||
onPaint: {
|
|
||||||
var ctx = canvas.getContext("2d");
|
|
||||||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
||||||
ctx.clearRect(0, 0, canvasSize.width, canvasSize.height);
|
|
||||||
ctx.save()
|
|
||||||
if(img_cache.source.toString().length!==0){
|
|
||||||
try{
|
|
||||||
ctx.drawImage(img_cache, 0, 0, canvasSize.width, canvasSize.height, 0, 0, canvasSize.width, canvasSize.height)
|
|
||||||
}catch(e){
|
|
||||||
img_cache.source = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
clearArc(ctx, centerX, centerY, radius)
|
|
||||||
ctx.restore()
|
|
||||||
}
|
|
||||||
function clearArc(ctx,x, y, radius, startAngle, endAngle) {
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.globalCompositeOperation = 'destination-out'
|
|
||||||
ctx.fillStyle = 'black'
|
|
||||||
ctx.arc(x, y, radius, 0, 2*Math.PI);
|
|
||||||
ctx.fill();
|
|
||||||
ctx.closePath();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function distance(x1,y1,x2,y2){
|
function distance(x1,y1,x2,y2){
|
||||||
@ -256,32 +229,25 @@ CustomWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleDarkChanged(button){
|
function handleDarkChanged(button){
|
||||||
var changeDark = function(){
|
if(FluTools.isMacos() || !FluTheme.enableAnimation){
|
||||||
if(FluTheme.dark){
|
changeDark()
|
||||||
FluTheme.darkMode = FluDarkMode.Light
|
|
||||||
}else{
|
}else{
|
||||||
FluTheme.darkMode = FluDarkMode.Dark
|
loader_reveal.sourceComponent = com_reveal
|
||||||
}
|
|
||||||
}
|
|
||||||
if(FluTools.isWin()){
|
|
||||||
var target = window.contentItem
|
var target = window.contentItem
|
||||||
var pos = button.mapToItem(target,0,0)
|
var pos = button.mapToItem(target,0,0)
|
||||||
var mouseX = pos.x
|
var mouseX = pos.x
|
||||||
var mouseY = pos.y
|
var mouseY = pos.y
|
||||||
canvas.maxRadius = Math.max(distance(mouseX,mouseY,0,0),distance(mouseX,mouseY,target.width,0),distance(mouseX,mouseY,0,target.height),distance(mouseX,mouseY,target.width,target.height))
|
var radius = Math.max(distance(mouseX,mouseY,0,0),distance(mouseX,mouseY,target.width,0),distance(mouseX,mouseY,0,target.height),distance(mouseX,mouseY,target.width,target.height))
|
||||||
target.grabToImage(function(result) {
|
var reveal = loader_reveal.item
|
||||||
img_cache.source = result.url
|
reveal.start(reveal.width*Screen.devicePixelRatio,reveal.height*Screen.devicePixelRatio,Qt.point(mouseX,mouseY),radius)
|
||||||
canvas.requestPaint()
|
}
|
||||||
changeDark()
|
}
|
||||||
canvas.centerX = mouseX
|
|
||||||
canvas.centerY = mouseY
|
function changeDark(){
|
||||||
anim_radius.enabled = false
|
if(FluTheme.dark){
|
||||||
canvas.radius = 0
|
FluTheme.darkMode = FluThemeType.Light
|
||||||
anim_radius.enabled = true
|
|
||||||
canvas.radius = canvas.maxRadius
|
|
||||||
},canvas.canvasSize)
|
|
||||||
}else{
|
}else{
|
||||||
changeDark()
|
FluTheme.darkMode = FluThemeType.Dark
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,5 +261,20 @@ CustomWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Shortcut {
|
||||||
|
sequence: "F6"
|
||||||
|
context: Qt.WindowShortcut
|
||||||
|
onActivated: {
|
||||||
|
tour.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluTour{
|
||||||
|
id:tour
|
||||||
|
steps:[
|
||||||
|
{title:"夜间模式",description: "这里可以切换夜间模式.",target:()=>app_bar_front.darkButton()},
|
||||||
|
{title:"隐藏彩蛋",description: "多点几下试试!!",target:()=>nav_view.logoButton()}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import QtQuick.Controls
|
|
||||||
import QtQuick.Layouts
|
|
||||||
import FluentUI
|
|
||||||
import "qrc:///example/qml/component"
|
|
||||||
|
|
||||||
CustomWindow {
|
|
||||||
|
|
||||||
title:"视频播放器"
|
|
||||||
width: 640
|
|
||||||
height: 480
|
|
||||||
minimumWidth: 640
|
|
||||||
minimumHeight: 480
|
|
||||||
|
|
||||||
onInitArgument:
|
|
||||||
(argument)=>{
|
|
||||||
player.source = argument.source
|
|
||||||
}
|
|
||||||
|
|
||||||
FluMediaPlayer{
|
|
||||||
id:player
|
|
||||||
anchors{
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
top: parent.top
|
|
||||||
bottom: parent.bottom
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ CustomWindow {
|
|||||||
width: 500
|
width: 500
|
||||||
height: 600
|
height: 600
|
||||||
fixSize: true
|
fixSize: true
|
||||||
launchMode: FluWindow.SingleInstance
|
launchMode: FluWindowType.SingleInstance
|
||||||
|
|
||||||
FluTextBox{
|
FluTextBox{
|
||||||
anchors{
|
anchors{
|
||||||
|
@ -11,7 +11,7 @@ CustomWindow {
|
|||||||
width: 500
|
width: 500
|
||||||
height: 600
|
height: 600
|
||||||
fixSize: true
|
fixSize: true
|
||||||
launchMode: FluWindow.SingleTask
|
launchMode: FluWindowType.SingleTask
|
||||||
|
|
||||||
FluText{
|
FluText{
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
@ -11,7 +11,29 @@ CustomWindow {
|
|||||||
width: 500
|
width: 500
|
||||||
height: 600
|
height: 600
|
||||||
fixSize: true
|
fixSize: true
|
||||||
launchMode: FluWindow.Standard
|
launchMode: FluWindowType.Standard
|
||||||
|
|
||||||
|
FluMenuBar {
|
||||||
|
FluMenu {
|
||||||
|
title: qsTr("File")
|
||||||
|
Action { text: qsTr("New...") }
|
||||||
|
Action { text: qsTr("Open...") }
|
||||||
|
Action { text: qsTr("Save") }
|
||||||
|
Action { text: qsTr("Save As...") }
|
||||||
|
FluMenuSeparator { }
|
||||||
|
Action { text: qsTr("Quit") }
|
||||||
|
}
|
||||||
|
FluMenu {
|
||||||
|
title: qsTr("Edit")
|
||||||
|
Action { text: qsTr("Cut") }
|
||||||
|
Action { text: qsTr("Copy") }
|
||||||
|
Action { text: qsTr("Paste") }
|
||||||
|
}
|
||||||
|
FluMenu {
|
||||||
|
title: qsTr("Help")
|
||||||
|
Action { text: qsTr("About") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FluText{
|
FluText{
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
BIN
example/res/image/bg_scenic.png
Normal file
After Width: | Height: | Size: 5.1 MiB |
@ -4,16 +4,12 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "lang/En.h"
|
#include "lang/En.h"
|
||||||
#include "lang/Zh.h"
|
#include "lang/Zh.h"
|
||||||
|
#include "Version.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_((VERSION))
|
|
||||||
|
|
||||||
AppInfo::AppInfo(QObject *parent)
|
AppInfo::AppInfo(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
{
|
{
|
||||||
version(VER_STR);
|
version(APPLICATION_VERSION);
|
||||||
lang(new En());
|
lang(new En());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,18 +35,3 @@ void AppInfo::changeLang(const QString& locale){
|
|||||||
lang(new En());
|
lang(new En());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppInfo::isOwnerProcess(IPC *ipc){
|
|
||||||
QString activeWindowEvent = "activeWindow";
|
|
||||||
if(!ipc->isCurrentOwner()){
|
|
||||||
ipc->postEvent(activeWindowEvent,QString().toUtf8(),0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(ipc->isAttached()){
|
|
||||||
ipc->registerEventHandler(activeWindowEvent,[=](const QByteArray&){
|
|
||||||
Q_EMIT this->activeWindow();
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include "tool/IPC.h"
|
|
||||||
#include "lang/Lang.h"
|
#include "lang/Lang.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
@ -15,9 +14,7 @@ class AppInfo : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit AppInfo(QObject *parent = nullptr);
|
explicit AppInfo(QObject *parent = nullptr);
|
||||||
void init(QQmlApplicationEngine *engine);
|
void init(QQmlApplicationEngine *engine);
|
||||||
bool isOwnerProcess(IPC *ipc);
|
|
||||||
Q_INVOKABLE void changeLang(const QString& locale);
|
Q_INVOKABLE void changeLang(const QString& locale);
|
||||||
Q_SIGNAL void activeWindow();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPINFO_H
|
#endif // APPINFO_H
|
||||||
|
48
example/src/component/CircularReveal.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include "CircularReveal.h"
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QQuickItemGrabResult>
|
||||||
|
#include <QPainterPath>
|
||||||
|
|
||||||
|
CircularReveal::CircularReveal(QQuickItem* parent) : QQuickPaintedItem(parent)
|
||||||
|
{
|
||||||
|
setVisible(false);
|
||||||
|
_anim.setDuration(333);
|
||||||
|
_anim.setEasingCurve(QEasingCurve::OutCubic);
|
||||||
|
connect(&_anim, &QPropertyAnimation::finished,this,[=](){
|
||||||
|
update();
|
||||||
|
setVisible(false);
|
||||||
|
Q_EMIT animationFinished();
|
||||||
|
});
|
||||||
|
connect(this,&CircularReveal::radiusChanged,this,[=](){
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void CircularReveal::paint(QPainter* painter)
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
painter->eraseRect(boundingRect());
|
||||||
|
painter->drawImage(QRect(0, 0, static_cast<int>(width()), static_cast<int>(height())), _source);
|
||||||
|
QPainterPath path;
|
||||||
|
path.moveTo(_center.x(),_center.y());
|
||||||
|
path.addEllipse(QPointF(_center.x(),_center.y()), _radius, _radius);
|
||||||
|
painter->setCompositionMode(QPainter::CompositionMode_Clear);
|
||||||
|
painter->fillPath(path, Qt::black);
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CircularReveal::start(int w,int h,const QPoint& center,int radius){
|
||||||
|
_anim.setStartValue(0);
|
||||||
|
_anim.setEndValue(radius);
|
||||||
|
_center = center;
|
||||||
|
_grabResult = _target->grabToImage(QSize(w,h));
|
||||||
|
connect(_grabResult.data(), &QQuickItemGrabResult::ready, this, &CircularReveal::handleGrabResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CircularReveal::handleGrabResult(){
|
||||||
|
_grabResult.data()->image().swap(_source);
|
||||||
|
update();
|
||||||
|
setVisible(true);
|
||||||
|
Q_EMIT imageChanged();
|
||||||
|
_anim.start();
|
||||||
|
}
|
30
example/src/component/CircularReveal.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef CIRCULARREVEAL_H
|
||||||
|
#define CIRCULARREVEAL_H
|
||||||
|
|
||||||
|
#include <QQuickItem>
|
||||||
|
#include <QQuickPaintedItem>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPropertyAnimation>
|
||||||
|
#include "src/stdafx.h"
|
||||||
|
|
||||||
|
class CircularReveal : public QQuickPaintedItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY_AUTO(QQuickItem*,target)
|
||||||
|
Q_PROPERTY_AUTO(int,radius)
|
||||||
|
QML_NAMED_ELEMENT(CircularReveal)
|
||||||
|
public:
|
||||||
|
CircularReveal(QQuickItem* parent = nullptr);
|
||||||
|
void paint(QPainter* painter) override;
|
||||||
|
Q_INVOKABLE void start(int w,int h,const QPoint& center,int radius);
|
||||||
|
Q_SIGNAL void imageChanged();
|
||||||
|
Q_SIGNAL void animationFinished();
|
||||||
|
Q_SLOT void handleGrabResult();
|
||||||
|
private:
|
||||||
|
QImage _source;
|
||||||
|
QPropertyAnimation _anim = QPropertyAnimation(this, "radius", this);
|
||||||
|
QPoint _center;
|
||||||
|
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CIRCULARREVEAL_H
|
24
example/src/component/FileWatcher.cpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include "FileWatcher.h"
|
||||||
|
|
||||||
|
FileWatcher::FileWatcher(QObject *parent)
|
||||||
|
: QObject{parent}
|
||||||
|
{
|
||||||
|
connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path){
|
||||||
|
Q_EMIT fileChanged();
|
||||||
|
clean();
|
||||||
|
_watcher.addPath(_path);
|
||||||
|
});
|
||||||
|
connect(this,&FileWatcher::pathChanged,this,[=](){
|
||||||
|
clean();
|
||||||
|
_watcher.addPath(_path.replace("file:///",""));
|
||||||
|
});
|
||||||
|
if(!_path.isEmpty()){
|
||||||
|
_watcher.addPath(_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileWatcher::clean(){
|
||||||
|
foreach (const QString &item, _watcher.files()) {
|
||||||
|
_watcher.removePath(item);
|
||||||
|
}
|
||||||
|
}
|
23
example/src/component/FileWatcher.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef FILEWATCHER_H
|
||||||
|
#define FILEWATCHER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QFileSystemWatcher>
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
|
#include "src/stdafx.h"
|
||||||
|
|
||||||
|
class FileWatcher : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY_AUTO(QString,path);
|
||||||
|
QML_NAMED_ELEMENT(FileWatcher)
|
||||||
|
public:
|
||||||
|
explicit FileWatcher(QObject *parent = nullptr);
|
||||||
|
Q_SIGNAL void fileChanged();
|
||||||
|
private:
|
||||||
|
void clean();
|
||||||
|
private:
|
||||||
|
QFileSystemWatcher _watcher;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FILEWATCHER_H
|
@ -3,6 +3,8 @@
|
|||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
|
#include <QNetworkProxy>
|
||||||
|
#include <QSslConfiguration>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
||||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||||
@ -10,7 +12,7 @@
|
|||||||
|
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
//将样式设置为Basic,不然会导致组件显示异常
|
//将样式设置为Basic,不然会导致组件显示异常
|
||||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||||
@ -30,13 +32,11 @@ int main(int argc, char *argv[])
|
|||||||
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false);
|
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false);
|
||||||
#endif
|
#endif
|
||||||
AppInfo* appInfo = new AppInfo();
|
AppInfo* appInfo = new AppInfo();
|
||||||
IPC ipc(0);
|
|
||||||
if(!appInfo->isOwnerProcess(&ipc)){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
app.setQuitOnLastWindowClosed(false);
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
FramelessHelper::Quick::registerTypes(&engine);
|
FramelessHelper::Quick::registerTypes(&engine);
|
||||||
|
#ifdef FLUENTUI_BUILD_STATIC_LIB
|
||||||
|
engine.addImportPath("qrc:/"); // 让静态资源可以被QML引擎搜索到
|
||||||
|
#endif
|
||||||
appInfo->init(&engine);
|
appInfo->init(&engine);
|
||||||
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
||||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||||
|
@ -1,250 +0,0 @@
|
|||||||
#include "IPC.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QThread>
|
|
||||||
#include <ctime>
|
|
||||||
#include <random>
|
|
||||||
|
|
||||||
|
|
||||||
IPC::IPC(uint32_t profileId)
|
|
||||||
: profileId{profileId}
|
|
||||||
, globalMemory{"ipc-" IPC_PROTOCOL_VERSION}
|
|
||||||
{
|
|
||||||
qRegisterMetaType<IPCEventHandler>("IPCEventHandler");
|
|
||||||
timer.setInterval(EVENT_TIMER_MS);
|
|
||||||
timer.setSingleShot(true);
|
|
||||||
connect(&timer, &QTimer::timeout, this, &IPC::processEvents);
|
|
||||||
std::default_random_engine randEngine((std::random_device())());
|
|
||||||
std::uniform_int_distribution<uint64_t> distribution;
|
|
||||||
globalId = distribution(randEngine);
|
|
||||||
qDebug() << "Our global IPC ID is " << globalId;
|
|
||||||
if (globalMemory.create(sizeof(IPCMemory))) {
|
|
||||||
if (globalMemory.lock()) {
|
|
||||||
IPCMemory* mem = global();
|
|
||||||
memset(mem, 0, sizeof(IPCMemory));
|
|
||||||
mem->globalId = globalId;
|
|
||||||
mem->lastProcessed = time(nullptr);
|
|
||||||
globalMemory.unlock();
|
|
||||||
} else {
|
|
||||||
qWarning() << "Couldn't lock to take ownership";
|
|
||||||
}
|
|
||||||
} else if (globalMemory.attach()) {
|
|
||||||
qDebug() << "Attaching to the global shared memory";
|
|
||||||
} else {
|
|
||||||
qDebug() << "Failed to attach to the global shared memory, giving up. Error:"
|
|
||||||
<< globalMemory.error();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
processEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::~IPC()
|
|
||||||
{
|
|
||||||
if (!globalMemory.lock()) {
|
|
||||||
qWarning() << "Failed to lock in ~IPC";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isCurrentOwnerNoLock()) {
|
|
||||||
global()->globalId = 0;
|
|
||||||
}
|
|
||||||
globalMemory.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t IPC::postEvent(const QString& name, const QByteArray& data, uint32_t dest)
|
|
||||||
{
|
|
||||||
QByteArray binName = name.toUtf8();
|
|
||||||
if (binName.length() > (int32_t)sizeof(IPCEvent::name)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.length() > (int32_t)sizeof(IPCEvent::data)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!globalMemory.lock()) {
|
|
||||||
qDebug() << "Failed to lock in postEvent()";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPCEvent* evt = nullptr;
|
|
||||||
IPCMemory* mem = global();
|
|
||||||
time_t result = 0;
|
|
||||||
|
|
||||||
for (uint32_t i = 0; !evt && i < EVENT_QUEUE_SIZE; ++i) {
|
|
||||||
if (mem->events[i].posted == 0) {
|
|
||||||
evt = &mem->events[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (evt) {
|
|
||||||
memset(evt, 0, sizeof(IPCEvent));
|
|
||||||
memcpy(evt->name, binName.constData(), binName.length());
|
|
||||||
memcpy(evt->data, data.constData(), data.length());
|
|
||||||
mem->lastEvent = evt->posted = result = qMax(mem->lastEvent + 1, time(nullptr));
|
|
||||||
evt->dest = dest;
|
|
||||||
evt->sender = qApp->applicationPid();
|
|
||||||
qDebug() << "postEvent " << name << "to" << dest;
|
|
||||||
}
|
|
||||||
globalMemory.unlock();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPC::isCurrentOwner()
|
|
||||||
{
|
|
||||||
if (globalMemory.lock()) {
|
|
||||||
const bool isOwner = isCurrentOwnerNoLock();
|
|
||||||
globalMemory.unlock();
|
|
||||||
return isOwner;
|
|
||||||
} else {
|
|
||||||
qWarning() << "isCurrentOwner failed to lock, returning false";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IPC::registerEventHandler(const QString& name, IPCEventHandler handler)
|
|
||||||
{
|
|
||||||
eventHandlers[name] = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPC::isEventAccepted(time_t time)
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
if (!globalMemory.lock()) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (difftime(global()->lastProcessed, time) > 0) {
|
|
||||||
IPCMemory* mem = global();
|
|
||||||
for (uint32_t i = 0; i < EVENT_QUEUE_SIZE; ++i) {
|
|
||||||
if (mem->events[i].posted == time && mem->events[i].processed) {
|
|
||||||
result = mem->events[i].accepted;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
globalMemory.unlock();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPC::waitUntilAccepted(time_t postTime, int32_t timeout /*=-1*/)
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
time_t start = time(nullptr);
|
|
||||||
forever
|
|
||||||
{
|
|
||||||
result = isEventAccepted(postTime);
|
|
||||||
if (result || (timeout > 0 && difftime(time(nullptr), start) >= timeout)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
qApp->processEvents();
|
|
||||||
QThread::msleep(0);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPC::isAttached() const
|
|
||||||
{
|
|
||||||
return globalMemory.isAttached();
|
|
||||||
}
|
|
||||||
|
|
||||||
void IPC::setProfileId(uint32_t profileId)
|
|
||||||
{
|
|
||||||
this->profileId = profileId;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::IPCEvent* IPC::fetchEvent()
|
|
||||||
{
|
|
||||||
IPCMemory* mem = global();
|
|
||||||
for (uint32_t i = 0; i < EVENT_QUEUE_SIZE; ++i) {
|
|
||||||
IPCEvent* evt = &mem->events[i];
|
|
||||||
if ((evt->processed && difftime(time(nullptr), evt->processed) > EVENT_GC_TIMEOUT)
|
|
||||||
|| (!evt->processed && difftime(time(nullptr), evt->posted) > EVENT_GC_TIMEOUT)) {
|
|
||||||
memset(evt, 0, sizeof(IPCEvent));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (evt->posted && !evt->processed && evt->sender != qApp->applicationPid()
|
|
||||||
&& (evt->dest == profileId || (evt->dest == 0 && isCurrentOwnerNoLock()))) {
|
|
||||||
return evt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPC::runEventHandler(IPCEventHandler handler, const QByteArray& arg)
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
if (QThread::currentThread() == qApp->thread()) {
|
|
||||||
result = handler(arg);
|
|
||||||
} else {
|
|
||||||
QMetaObject::invokeMethod(this, "runEventHandler", Qt::BlockingQueuedConnection,
|
|
||||||
Q_RETURN_ARG(bool, result), Q_ARG(IPCEventHandler, handler),
|
|
||||||
Q_ARG(const QByteArray&, arg));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IPC::processEvents()
|
|
||||||
{
|
|
||||||
if (!globalMemory.lock()) {
|
|
||||||
timer.start();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPCMemory* mem = global();
|
|
||||||
|
|
||||||
if (mem->globalId == globalId) {
|
|
||||||
mem->lastProcessed = time(nullptr);
|
|
||||||
} else {
|
|
||||||
if (difftime(time(nullptr), mem->lastProcessed) >= OWNERSHIP_TIMEOUT_S) {
|
|
||||||
qDebug() << "Previous owner timed out, taking ownership" << mem->globalId << "->"
|
|
||||||
<< globalId;
|
|
||||||
memset(mem, 0, sizeof(IPCMemory));
|
|
||||||
mem->globalId = globalId;
|
|
||||||
mem->lastProcessed = time(nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (IPCEvent* evt = fetchEvent()) {
|
|
||||||
QString name = QString::fromUtf8(evt->name);
|
|
||||||
auto it = eventHandlers.find(name);
|
|
||||||
if (it != eventHandlers.end()) {
|
|
||||||
evt->accepted = runEventHandler(it.value(), evt->data);
|
|
||||||
qDebug() << "Processed event:" << name << "posted:" << evt->posted
|
|
||||||
<< "accepted:" << evt->accepted;
|
|
||||||
if (evt->dest == 0) {
|
|
||||||
if (evt->accepted) {
|
|
||||||
evt->processed = time(nullptr);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
evt->processed = time(nullptr);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
qDebug() << "Received event:" << name << "without handler";
|
|
||||||
qDebug() << "Available handlers:" << eventHandlers.keys();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
globalMemory.unlock();
|
|
||||||
timer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPC::isCurrentOwnerNoLock()
|
|
||||||
{
|
|
||||||
const void* const data = globalMemory.data();
|
|
||||||
if (!data) {
|
|
||||||
qWarning() << "isCurrentOwnerNoLock failed to access the memory, returning false";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (*static_cast<const uint64_t*>(data) == globalId);
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::IPCMemory* IPC::global()
|
|
||||||
{
|
|
||||||
return static_cast<IPCMemory*>(globalMemory.data());
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
#ifndef IPC_H
|
|
||||||
#define IPC_H
|
|
||||||
|
|
||||||
#include <QMap>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QSharedMemory>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <ctime>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
using IPCEventHandler = std::function<bool(const QByteArray&)>;
|
|
||||||
|
|
||||||
#define IPC_PROTOCOL_VERSION "1"
|
|
||||||
|
|
||||||
class IPC : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static const int EVENT_TIMER_MS = 1000;
|
|
||||||
static const int EVENT_GC_TIMEOUT = 5;
|
|
||||||
static const int EVENT_QUEUE_SIZE = 32;
|
|
||||||
static const int OWNERSHIP_TIMEOUT_S = 5;
|
|
||||||
|
|
||||||
public:
|
|
||||||
IPC(uint32_t profileId);
|
|
||||||
~IPC();
|
|
||||||
|
|
||||||
struct IPCEvent
|
|
||||||
{
|
|
||||||
uint32_t dest;
|
|
||||||
int32_t sender;
|
|
||||||
char name[16];
|
|
||||||
char data[128];
|
|
||||||
time_t posted;
|
|
||||||
time_t processed;
|
|
||||||
uint32_t flags;
|
|
||||||
bool accepted;
|
|
||||||
bool global;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IPCMemory
|
|
||||||
{
|
|
||||||
uint64_t globalId;
|
|
||||||
time_t lastEvent;
|
|
||||||
time_t lastProcessed;
|
|
||||||
IPCEvent events[IPC::EVENT_QUEUE_SIZE];
|
|
||||||
};
|
|
||||||
|
|
||||||
time_t postEvent(const QString& name, const QByteArray& data = QByteArray(), uint32_t dest = 0);
|
|
||||||
bool isCurrentOwner();
|
|
||||||
void registerEventHandler(const QString& name, IPCEventHandler handler);
|
|
||||||
bool isEventAccepted(time_t time);
|
|
||||||
bool waitUntilAccepted(time_t time, int32_t timeout = -1);
|
|
||||||
bool isAttached() const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setProfileId(uint32_t profileId);
|
|
||||||
|
|
||||||
private:
|
|
||||||
IPCMemory* global();
|
|
||||||
bool runEventHandler(IPCEventHandler handler, const QByteArray& arg);
|
|
||||||
IPCEvent* fetchEvent();
|
|
||||||
void processEvents();
|
|
||||||
bool isCurrentOwnerNoLock();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QTimer timer;
|
|
||||||
uint64_t globalId;
|
|
||||||
uint32_t profileId;
|
|
||||||
QSharedMemory globalMemory;
|
|
||||||
QMap<QString, IPCEventHandler> eventHandlers;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // IPC_H
|
|
@ -1,21 +1,25 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
project(fluentuiplugin LANGUAGES CXX)
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
|
project(fluentui LANGUAGES CXX)
|
||||||
|
else()
|
||||||
|
project(fluentuiplugin LANGUAGES CXX)
|
||||||
|
endif()
|
||||||
#配置通用编译
|
#配置通用编译
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#设置QML插件输出目录->D:\Qt\6.4.3\msvc2019_64\qml\FluentUI
|
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
|
||||||
set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI)
|
|
||||||
|
|
||||||
#设置版本号
|
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
||||||
add_definitions(-DVERSION=1,3,3,0)
|
qt_standard_project_setup()
|
||||||
|
else()
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml ShaderTools)
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
#遍历所有Cpp文件
|
#遍历所有Cpp文件
|
||||||
file(GLOB_RECURSE CPP_FILES *.cpp *.h)
|
file(GLOB_RECURSE CPP_FILES *.cpp *.h)
|
||||||
@ -32,7 +36,7 @@ foreach(filepath ${QML_PATHS})
|
|||||||
endforeach(filepath)
|
endforeach(filepath)
|
||||||
|
|
||||||
#遍历所有资源文件
|
#遍历所有资源文件
|
||||||
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.qsb *.metainfo)
|
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp qmldir)
|
||||||
foreach(filepath ${RES_PATHS})
|
foreach(filepath ${RES_PATHS})
|
||||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
|
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
|
||||||
list(APPEND resource_files ${filename})
|
list(APPEND resource_files ${filename})
|
||||||
@ -45,38 +49,49 @@ foreach(filepath IN LISTS qml_files resource_files)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
#添加qml模块
|
#添加qml模块
|
||||||
qt_add_library(fluentuiplugin SHARED)
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
qt_add_qml_module(fluentuiplugin
|
set(LIB_TYPE "STATIC")
|
||||||
#没有下面这行代码就会生成fluentuiplugin.dll与fluentuipluginplugin.dll两个动态库
|
else()
|
||||||
PLUGIN_TARGET fluentuiplugin
|
set(LIB_TYPE "SHARED")
|
||||||
OUTPUT_DIRECTORY ${QML_PLUGIN_DIRECTORY}
|
endif()
|
||||||
|
qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
|
||||||
|
|
||||||
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
|
set(PLUGIN_TARGET_NAME "")
|
||||||
|
else()
|
||||||
|
#如果是动态库,则使用插件目标作为其自己的支持目标来定义 QML 模块,在这种情况下,模块必须在运行时动态加载,并且不能由其他目标直接链接到
|
||||||
|
set(PLUGIN_TARGET_NAME ${PROJECT_NAME})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#如果是Windows平台,则生成rc文件
|
||||||
|
set(FLUENTUI_VERSION_RC_PATH "")
|
||||||
|
if(WIN32)
|
||||||
|
set(FLUENTUI_VERSION_RC_PATH ${CMAKE_BINARY_DIR}/version_${PROJECT_NAME}.rc)
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_SOURCE_DIR}/.cmake/version_dll.rc.in
|
||||||
|
${FLUENTUI_VERSION_RC_PATH}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
qt_add_qml_module(${PROJECT_NAME}
|
||||||
|
PLUGIN_TARGET ${PLUGIN_TARGET_NAME}
|
||||||
|
OUTPUT_DIRECTORY ${FLUENTUI_QML_PLUGIN_DIRECTORY}
|
||||||
VERSION 1.0
|
VERSION 1.0
|
||||||
URI "FluentUI"
|
URI "FluentUI"
|
||||||
#修改qmltypes文件名称。默认fluentuiplugin.qmltypes,使用默认名称有时候import FluentUI会爆红,所以修改成plugins.qmltypes
|
#修改qmltypes文件名称。默认fluentuiplugin.qmltypes,使用默认名称有时候import FluentUI会爆红,所以修改成plugins.qmltypes
|
||||||
TYPEINFO "plugins.qmltypes"
|
TYPEINFO "plugins.qmltypes"
|
||||||
SOURCES ${sources_files} fluentui.rc
|
SOURCES ${sources_files} ${FLUENTUI_VERSION_RC_PATH}
|
||||||
QML_FILES ${qml_files}
|
QML_FILES ${qml_files}
|
||||||
RESOURCES ${resource_files}
|
RESOURCES ${resource_files}
|
||||||
#支持designer
|
|
||||||
DESIGNER_SUPPORTED
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#链接库
|
#链接库
|
||||||
target_link_libraries(fluentuiplugin PUBLIC
|
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||||
Qt::CorePrivate
|
Qt::CorePrivate
|
||||||
Qt::QuickPrivate
|
Qt::QuickPrivate
|
||||||
Qt::QmlPrivate
|
Qt::QmlPrivate
|
||||||
|
ZXing
|
||||||
)
|
)
|
||||||
|
|
||||||
#链接库 win32库 不然mingw会编译错误
|
#安装
|
||||||
if(WIN32)
|
install(DIRECTORY ${FLUENTUI_QML_PLUGIN_DIRECTORY} DESTINATION ${CMAKE_INSTALL_PREFIX}/imports)
|
||||||
target_link_libraries(fluentuiplugin PRIVATE dwmapi user32)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#如果是debug,则生成的库文件名后面拼接d
|
|
||||||
# 在MinGW和GCC/Clang中, 默认不会链接带`d`后缀的动态库
|
|
||||||
if(MSVC)
|
|
||||||
set_target_properties(fluentuiplugin PROPERTIES DEBUG_POSTFIX "d")
|
|
||||||
endif(MSVC)
|
|
||||||
|
|
||||||
|
|
||||||
|
126
src/Def.h
@ -4,15 +4,127 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtQml/qqml.h>
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
namespace Fluent_DarkMode {
|
namespace FluThemeType {
|
||||||
Q_NAMESPACE
|
Q_NAMESPACE
|
||||||
enum Fluent_DarkModeType {
|
enum DarkMode {
|
||||||
System = 0x0,
|
System = 0x0000,
|
||||||
Light = 0x1,
|
Light = 0x0001,
|
||||||
Dark = 0x2,
|
Dark = 0x0002,
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(Fluent_DarkModeType)
|
Q_ENUM_NS(DarkMode)
|
||||||
QML_NAMED_ELEMENT(FluDarkMode)
|
QML_NAMED_ELEMENT(FluThemeType)
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FluPageType {
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum LaunchMode {
|
||||||
|
Standard = 0x0000,
|
||||||
|
SingleTask = 0x0001,
|
||||||
|
SingleTop = 0x0002,
|
||||||
|
SingleInstance = 0x0004
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(LaunchMode)
|
||||||
|
QML_NAMED_ELEMENT(FluPageType)
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FluWindowType {
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum LaunchMode {
|
||||||
|
Standard = 0x0000,
|
||||||
|
SingleTask = 0x0001,
|
||||||
|
SingleInstance = 0x0002
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(LaunchMode)
|
||||||
|
QML_NAMED_ELEMENT(FluWindowType)
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FluTreeViewType {
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum SelectionMode {
|
||||||
|
None = 0x0000,
|
||||||
|
Single = 0x0001,
|
||||||
|
Multiple = 0x0002
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(SelectionMode)
|
||||||
|
QML_NAMED_ELEMENT(FluTreeViewType)
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FluStatusViewType {
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum StatusMode {
|
||||||
|
Loading = 0x0000,
|
||||||
|
Empty = 0x0001,
|
||||||
|
Error = 0x0002,
|
||||||
|
Success = 0x0004
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(StatusMode)
|
||||||
|
QML_NAMED_ELEMENT(FluStatusViewType)
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FluContentDialogType {
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum ButtonFlag {
|
||||||
|
NeutralButton = 0x0001,
|
||||||
|
NegativeButton = 0x0002,
|
||||||
|
PositiveButton = 0x0004
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(ButtonFlag)
|
||||||
|
QML_NAMED_ELEMENT(FluContentDialogType)
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FluTimePickerType {
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum HourFormat {
|
||||||
|
H = 0x0000,
|
||||||
|
HH = 0x0001
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(HourFormat)
|
||||||
|
QML_NAMED_ELEMENT(FluTimePickerType)
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FluCalendarViewType {
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum DisplayMode {
|
||||||
|
Month = 0x0000,
|
||||||
|
Year = 0x0001,
|
||||||
|
Decade = 0x0002
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(DisplayMode)
|
||||||
|
QML_NAMED_ELEMENT(FluCalendarViewType)
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FluTabViewType {
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum TabWidthBehavior {
|
||||||
|
Equal = 0x0000,
|
||||||
|
SizeToContent = 0x0001,
|
||||||
|
Compact = 0x0002
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(TabWidthBehavior)
|
||||||
|
enum CloseButtonVisibility {
|
||||||
|
Nerver = 0x0000,
|
||||||
|
Always = 0x0001,
|
||||||
|
OnHover = 0x0002
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(CloseButtonVisibility)
|
||||||
|
QML_NAMED_ELEMENT(FluTabViewType)
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FluNavigationViewType {
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum DisplayMode {
|
||||||
|
Open = 0x0000,
|
||||||
|
Compact = 0x0001,
|
||||||
|
Minimal = 0x0002,
|
||||||
|
Auto = 0x0004
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(DisplayMode)
|
||||||
|
enum PageMode {
|
||||||
|
Stack = 0x0000,
|
||||||
|
NoStack = 0x0001
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(PageMode)
|
||||||
|
QML_NAMED_ELEMENT(FluNavigationViewType)
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Fluent_Awesome {
|
namespace Fluent_Awesome {
|
||||||
|
@ -23,6 +23,7 @@ FluApp *FluApp::getInstance()
|
|||||||
FluApp::FluApp(QObject *parent)
|
FluApp::FluApp(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
{
|
{
|
||||||
|
httpInterceptor(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
FluApp::~FluApp(){
|
FluApp::~FluApp(){
|
||||||
@ -38,11 +39,15 @@ void FluApp::run(){
|
|||||||
|
|
||||||
void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegister* fluRegister){
|
void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegister* fluRegister){
|
||||||
if(!routes().contains(route)){
|
if(!routes().contains(route)){
|
||||||
qErrnoWarning("没有找到当前路由");
|
qCritical()<<"No route found "<<route;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QQmlEngine *engine = qmlEngine(appWindow);
|
QQmlEngine *engine = qmlEngine(appWindow);
|
||||||
QQmlComponent component(engine, routes().value(route).toString());
|
QQmlComponent component(engine, routes().value(route).toString());
|
||||||
|
if (component.isError()) {
|
||||||
|
qCritical() << component.errors();
|
||||||
|
return;
|
||||||
|
}
|
||||||
QVariantMap properties;
|
QVariantMap properties;
|
||||||
properties.insert("route",route);
|
properties.insert("route",route);
|
||||||
if(fluRegister){
|
if(fluRegister){
|
||||||
@ -105,3 +110,11 @@ QJsonArray FluApp::awesomelist(const QString& keyword)
|
|||||||
void FluApp::closeApp(){
|
void FluApp::closeApp(){
|
||||||
qApp->exit(0);
|
qApp->exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FluApp::deleteWindow(QQuickWindow* window){
|
||||||
|
if(window){
|
||||||
|
wnds.remove(window->winId());
|
||||||
|
window->deleteLater();
|
||||||
|
window = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include "FluRegister.h"
|
#include "FluRegister.h"
|
||||||
|
#include "FluHttpInterceptor.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,6 +28,11 @@ class FluApp : public QObject
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY_AUTO(QJsonObject,routes);
|
Q_PROPERTY_AUTO(QJsonObject,routes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief http拦截器
|
||||||
|
*/
|
||||||
|
Q_PROPERTY_AUTO(FluHttpInterceptor*,httpInterceptor);
|
||||||
|
|
||||||
QML_NAMED_ELEMENT(FluApp)
|
QML_NAMED_ELEMENT(FluApp)
|
||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
private:
|
private:
|
||||||
@ -73,6 +79,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE void closeApp();
|
Q_INVOKABLE void closeApp();
|
||||||
|
|
||||||
|
Q_INVOKABLE void deleteWindow(QQuickWindow* window);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief wnds
|
* @brief wnds
|
||||||
|
305
src/FluHttp.cpp
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
#include "FluHttp.h"
|
||||||
|
|
||||||
|
#include <QThreadPool>
|
||||||
|
#include <QEventLoop>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QUrlQuery>
|
||||||
|
#include <QHttpMultiPart>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include "MainThread.h"
|
||||||
|
#include "FluApp.h"
|
||||||
|
|
||||||
|
FluHttp::FluHttp(QObject *parent)
|
||||||
|
: QObject{parent}
|
||||||
|
{
|
||||||
|
retry(3);
|
||||||
|
timeout(15000);
|
||||||
|
}
|
||||||
|
|
||||||
|
FluHttp::~FluHttp(){
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::cancel(){
|
||||||
|
foreach (QPointer<QNetworkReply> item, _cache) {
|
||||||
|
if(item){
|
||||||
|
item->abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::handleReply(QNetworkReply* reply){
|
||||||
|
_cache.append(reply);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::post(QString url,QJSValue callable,QMap<QString, QVariant> params,QMap<QString, QVariant> headers){
|
||||||
|
QMap<QString, QVariant> data = invokeIntercept(params,headers,"post").toMap();
|
||||||
|
QThreadPool::globalInstance()->start([=](){
|
||||||
|
onStart(callable);
|
||||||
|
for (int i = 0; i < retry(); ++i) {
|
||||||
|
QNetworkAccessManager manager;
|
||||||
|
manager.setTransferTimeout(timeout());
|
||||||
|
QUrl _url(url);
|
||||||
|
QNetworkRequest request(_url);
|
||||||
|
addHeaders(&request,data["headers"].toMap());
|
||||||
|
QHttpMultiPart multiPart(QHttpMultiPart::FormDataType);
|
||||||
|
QString contentType = QString("multipart/form-data;boundary=%1").arg(multiPart.boundary());
|
||||||
|
request.setHeader(QNetworkRequest::ContentTypeHeader, contentType);
|
||||||
|
for (const auto& each : data["params"].toMap().toStdMap())
|
||||||
|
{
|
||||||
|
const QString& key = each.first;
|
||||||
|
const QString& value = each.second.toString();
|
||||||
|
QString dispositionHeader = QString("form-data; name=\"%1\"").arg(key);
|
||||||
|
QHttpPart part;
|
||||||
|
part.setHeader(QNetworkRequest::ContentDispositionHeader, dispositionHeader);
|
||||||
|
part.setBody(value.toUtf8());
|
||||||
|
multiPart.append(part);
|
||||||
|
}
|
||||||
|
QEventLoop loop;
|
||||||
|
QNetworkReply* reply = manager.post(request,&multiPart);
|
||||||
|
_cache.append(reply);
|
||||||
|
connect(&manager,&QNetworkAccessManager::finished,this,[&loop](QNetworkReply *reply){
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
loop.exec();
|
||||||
|
QString result = QString::fromUtf8(reply->readAll());
|
||||||
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
QString errorString = reply->errorString();
|
||||||
|
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||||
|
_cache.removeOne(reply);
|
||||||
|
reply->deleteLater();
|
||||||
|
reply = nullptr;
|
||||||
|
if (isSuccess) {
|
||||||
|
onSuccess(callable,result);
|
||||||
|
break;
|
||||||
|
}else{
|
||||||
|
if(i == retry()-1){
|
||||||
|
onError(callable,status,errorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onFinish(callable);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::postString(QString url,QJSValue callable,QString params,QMap<QString, QVariant> headers){
|
||||||
|
QMap<QString, QVariant> data = invokeIntercept(params,headers,"postString").toMap();
|
||||||
|
QThreadPool::globalInstance()->start([=](){
|
||||||
|
onStart(callable);
|
||||||
|
for (int i = 0; i < retry(); ++i) {
|
||||||
|
QNetworkAccessManager manager;
|
||||||
|
manager.setTransferTimeout(timeout());
|
||||||
|
QUrl _url(url);
|
||||||
|
QNetworkRequest request(_url);
|
||||||
|
addHeaders(&request,data["headers"].toMap());
|
||||||
|
QString contentType = QString("text/plain;charset=utf-8");
|
||||||
|
request.setHeader(QNetworkRequest::ContentTypeHeader, contentType);
|
||||||
|
QEventLoop loop;
|
||||||
|
QNetworkReply* reply = manager.post(request,params.toUtf8());
|
||||||
|
_cache.append(reply);
|
||||||
|
connect(&manager,&QNetworkAccessManager::finished,this,[&loop](QNetworkReply *reply){
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
loop.exec();
|
||||||
|
QString result = QString::fromUtf8(reply->readAll());
|
||||||
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
QString errorString = reply->errorString();
|
||||||
|
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||||
|
_cache.removeOne(reply);
|
||||||
|
reply->deleteLater();
|
||||||
|
reply = nullptr;
|
||||||
|
if (isSuccess) {
|
||||||
|
onSuccess(callable,result);
|
||||||
|
break;
|
||||||
|
}else{
|
||||||
|
if(i == retry()-1){
|
||||||
|
onError(callable,status,errorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onFinish(callable);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::postJson(QString url,QJSValue callable,QMap<QString, QVariant> params,QMap<QString, QVariant> headers){
|
||||||
|
QMap<QString, QVariant> data = invokeIntercept(params,headers,"postJson").toMap();
|
||||||
|
QThreadPool::globalInstance()->start([=](){
|
||||||
|
onStart(callable);
|
||||||
|
for (int i = 0; i < retry(); ++i) {
|
||||||
|
QNetworkAccessManager manager;
|
||||||
|
manager.setTransferTimeout(timeout());
|
||||||
|
QUrl _url(url);
|
||||||
|
QNetworkRequest request(_url);
|
||||||
|
addHeaders(&request,data["headers"].toMap());
|
||||||
|
QString contentType = QString("application/json;charset=utf-8");
|
||||||
|
request.setHeader(QNetworkRequest::ContentTypeHeader, contentType);
|
||||||
|
QEventLoop loop;
|
||||||
|
QNetworkReply* reply = manager.post(request,QJsonDocument::fromVariant(data["params"]).toJson());
|
||||||
|
_cache.append(reply);
|
||||||
|
connect(&manager,&QNetworkAccessManager::finished,this,[&loop](QNetworkReply *reply){
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
loop.exec();
|
||||||
|
QString result = QString::fromUtf8(reply->readAll());
|
||||||
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
QString errorString = reply->errorString();
|
||||||
|
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||||
|
_cache.removeOne(reply);
|
||||||
|
reply->deleteLater();
|
||||||
|
reply = nullptr;
|
||||||
|
if (isSuccess) {
|
||||||
|
onSuccess(callable,result);
|
||||||
|
break;
|
||||||
|
}else{
|
||||||
|
if(i == retry()-1){
|
||||||
|
onError(callable,status,errorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onFinish(callable);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::get(QString url,QJSValue callable,QMap<QString, QVariant> params,QMap<QString, QVariant> headers){
|
||||||
|
QMap<QString, QVariant> data = invokeIntercept(params,headers,"get").toMap();
|
||||||
|
QThreadPool::globalInstance()->start([=](){
|
||||||
|
for (int i = 0; i < retry(); ++i) {
|
||||||
|
onStart(callable);
|
||||||
|
QNetworkAccessManager manager;
|
||||||
|
manager.setTransferTimeout(timeout());
|
||||||
|
QUrl _url(url);
|
||||||
|
addQueryParam(&_url,data["params"].toMap());
|
||||||
|
QNetworkRequest request(_url);
|
||||||
|
addHeaders(&request,data["headers"].toMap());
|
||||||
|
QEventLoop loop;
|
||||||
|
QNetworkReply* reply = manager.get(request);
|
||||||
|
_cache.append(reply);
|
||||||
|
connect(&manager,&QNetworkAccessManager::finished,this,[&loop](QNetworkReply *reply){
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
loop.exec();
|
||||||
|
QString result = QString::fromUtf8(reply->readAll());
|
||||||
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
QString errorString = reply->errorString();
|
||||||
|
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||||
|
_cache.removeOne(reply);
|
||||||
|
reply->deleteLater();
|
||||||
|
reply = nullptr;
|
||||||
|
if (isSuccess) {
|
||||||
|
onSuccess(callable,result);
|
||||||
|
break;
|
||||||
|
}else{
|
||||||
|
if(i == retry()-1){
|
||||||
|
onError(callable,status,errorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onFinish(callable);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::download(QString url,QJSValue callable,QString filePath,QMap<QString, QVariant> params,QMap<QString, QVariant> headers){
|
||||||
|
QMap<QString, QVariant> data = invokeIntercept(params,headers,"download").toMap();
|
||||||
|
QThreadPool::globalInstance()->start([=](){
|
||||||
|
onStart(callable);
|
||||||
|
QNetworkAccessManager manager;
|
||||||
|
QUrl _url(url);
|
||||||
|
addQueryParam(&_url,data["params"].toMap());
|
||||||
|
QNetworkRequest request(_url);
|
||||||
|
addHeaders(&request,data["headers"].toMap());
|
||||||
|
QSharedPointer<QFile> file(new QFile(filePath));
|
||||||
|
QIODevice::OpenMode mode = QIODevice::WriteOnly|QIODevice::Truncate;
|
||||||
|
if (!file->open(mode))
|
||||||
|
{
|
||||||
|
onError(callable,-1,QString("Url: %1 %2 Non-Writable").arg(request.url().toString(),file->fileName()));
|
||||||
|
onFinish(callable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QEventLoop loop;
|
||||||
|
connect(&manager,&QNetworkAccessManager::finished,this,[&loop](QNetworkReply *reply){
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
QPointer<QNetworkReply> reply = manager.get(request);
|
||||||
|
_cache.append(reply);
|
||||||
|
connect(reply,&QNetworkReply::downloadProgress,this,[=](qint64 bytesReceived, qint64 bytesTotal){
|
||||||
|
onDownloadProgress(callable,bytesReceived,bytesTotal);
|
||||||
|
});
|
||||||
|
loop.exec();
|
||||||
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
|
file->write(reply->readAll());
|
||||||
|
onSuccess(callable,filePath);
|
||||||
|
}else{
|
||||||
|
onError(callable,reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(),reply->errorString());
|
||||||
|
}
|
||||||
|
_cache.removeOne(reply);
|
||||||
|
reply->deleteLater();
|
||||||
|
reply = nullptr;
|
||||||
|
onFinish(callable);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant FluHttp::invokeIntercept(const QVariant& params,const QVariant& headers,const QString& method){
|
||||||
|
QMap<QString, QVariant> requet = {
|
||||||
|
{"params",params},
|
||||||
|
{"headers",headers},
|
||||||
|
{"method",method}
|
||||||
|
};
|
||||||
|
if(!FluApp::getInstance()->httpInterceptor()){
|
||||||
|
return requet;
|
||||||
|
}
|
||||||
|
QVariant target;
|
||||||
|
QMetaObject::invokeMethod(FluApp::getInstance()->httpInterceptor(), "onIntercept",Q_RETURN_ARG(QVariant,target),Q_ARG(QVariant, requet));
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){
|
||||||
|
QMapIterator<QString, QVariant> iter(params);
|
||||||
|
QUrlQuery urlQuery(*url);
|
||||||
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
|
iter.next();
|
||||||
|
urlQuery.addQueryItem(iter.key(), iter.value().toString());
|
||||||
|
}
|
||||||
|
url->setQuery(urlQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers){
|
||||||
|
QMapIterator<QString, QVariant> iter(headers);
|
||||||
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
|
iter.next();
|
||||||
|
request->setRawHeader(iter.key().toUtf8(), iter.value().toString().toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::onStart(const QJSValue& callable){
|
||||||
|
QJSValue onStart = callable.property("onStart");
|
||||||
|
MainThread::post([=](){onStart.call();});
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::onFinish(const QJSValue& callable){
|
||||||
|
QJSValue onFinish = callable.property("onFinish");
|
||||||
|
MainThread::post([=](){onFinish.call();});
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::onError(const QJSValue& callable,int status,QString errorString){
|
||||||
|
QJSValue onError = callable.property("onError");
|
||||||
|
QJSValueList args;
|
||||||
|
args<<status<<errorString;
|
||||||
|
MainThread::post([=](){onError.call(args);});
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::onSuccess(const QJSValue& callable,QString result){
|
||||||
|
QJSValueList args;
|
||||||
|
args<<result;
|
||||||
|
QJSValue onSuccess = callable.property("onSuccess");
|
||||||
|
MainThread::post([=](){onSuccess.call(args);});
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluHttp::onDownloadProgress(const QJSValue& callable,qint64 recv, qint64 total){
|
||||||
|
QJSValueList args;
|
||||||
|
args<<static_cast<double>(recv);
|
||||||
|
args<<static_cast<double>(total);
|
||||||
|
QJSValue onDownloadProgress = callable.property("onDownloadProgress");
|
||||||
|
MainThread::post([=](){onDownloadProgress.call(args);});
|
||||||
|
}
|
40
src/FluHttp.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#ifndef FLUHTTP_H
|
||||||
|
#define FLUHTTP_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
class FluHttp : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY_AUTO(int,retry);
|
||||||
|
Q_PROPERTY_AUTO(int,timeout)
|
||||||
|
QML_NAMED_ELEMENT(FluHttp)
|
||||||
|
private:
|
||||||
|
QVariant invokeIntercept(const QVariant& params,const QVariant& headers,const QString& method);
|
||||||
|
void handleReply(QNetworkReply* reply);
|
||||||
|
void addQueryParam(QUrl* url,const QMap<QString, QVariant>& params);
|
||||||
|
void addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& params);
|
||||||
|
void onStart(const QJSValue& callable);
|
||||||
|
void onFinish(const QJSValue& callable);
|
||||||
|
void onError(const QJSValue& callable,int status,QString errorString);
|
||||||
|
void onSuccess(const QJSValue& callable,QString result);
|
||||||
|
void onDownloadProgress(const QJSValue& callable,qint64 recv, qint64 total);
|
||||||
|
public:
|
||||||
|
explicit FluHttp(QObject *parent = nullptr);
|
||||||
|
~FluHttp();
|
||||||
|
//神坑!!! 如果参数使用QVariantMap会有问题,在6.4.3版本中QML一调用就会编译失败。所以改用QMap<QString, QVariant>
|
||||||
|
Q_INVOKABLE void get(QString url,QJSValue callable,QMap<QString, QVariant> = {},QMap<QString, QVariant> headers = {});
|
||||||
|
Q_INVOKABLE void post(QString url,QJSValue callable,QMap<QString, QVariant> = {},QMap<QString, QVariant> headers = {});
|
||||||
|
Q_INVOKABLE void postString(QString url,QJSValue callable,QString params = "",QMap<QString, QVariant> headers = {});
|
||||||
|
Q_INVOKABLE void postJson(QString url,QJSValue callable,QMap<QString, QVariant> params = {},QMap<QString, QVariant> headers = {});
|
||||||
|
Q_INVOKABLE void download(QString url,QJSValue callable,QString filePath,QMap<QString, QVariant> params = {},QMap<QString, QVariant> headers = {});
|
||||||
|
Q_INVOKABLE void cancel();
|
||||||
|
private:
|
||||||
|
QList<QPointer<QNetworkReply>> _cache;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FLUHTTP_H
|
7
src/FluHttpInterceptor.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "FluHttpInterceptor.h"
|
||||||
|
|
||||||
|
FluHttpInterceptor::FluHttpInterceptor(QObject *parent)
|
||||||
|
: QObject{parent}
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
18
src/FluHttpInterceptor.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef FLUHTTPINTERCEPTOR_H
|
||||||
|
#define FLUHTTPINTERCEPTOR_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
|
class FluHttpInterceptor : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
QML_NAMED_ELEMENT(FluHttpInterceptor)
|
||||||
|
public:
|
||||||
|
explicit FluHttpInterceptor(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FLUHTTPINTERCEPTOR_H
|
53
src/FluQRCode.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#include "FluQRCode.h"
|
||||||
|
|
||||||
|
#include "BarcodeFormat.h"
|
||||||
|
#include "BitMatrix.h"
|
||||||
|
#include "MultiFormatWriter.h"
|
||||||
|
|
||||||
|
using namespace ZXing;
|
||||||
|
|
||||||
|
FluQRCode::FluQRCode(QQuickItem* parent) : QQuickPaintedItem(parent)
|
||||||
|
{
|
||||||
|
color(QColor(0,0,0,255));
|
||||||
|
size(100);
|
||||||
|
setWidth(_size);
|
||||||
|
setHeight(_size);
|
||||||
|
connect(this,&FluQRCode::textChanged,this,[=]{update();});
|
||||||
|
connect(this,&FluQRCode::colorChanged,this,[=]{update();});
|
||||||
|
connect(this,&FluQRCode::sizeChanged,this,[=]{
|
||||||
|
setWidth(_size);
|
||||||
|
setHeight(_size);
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FluQRCode::paint(QPainter* painter)
|
||||||
|
{
|
||||||
|
if(_text.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(_text.length()>1108){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
painter->save();
|
||||||
|
painter->eraseRect(boundingRect());
|
||||||
|
auto format = ZXing::BarcodeFormatFromString("QRCode");
|
||||||
|
auto writer = MultiFormatWriter(format);
|
||||||
|
writer.setMargin(0);
|
||||||
|
writer.setEncoding(ZXing::CharacterSet::UTF8);
|
||||||
|
auto matrix = writer.encode(_text.toUtf8().constData(), 0, 0);
|
||||||
|
auto bitmap = ToMatrix<uint8_t>(matrix);
|
||||||
|
auto image = QImage(bitmap.data(), bitmap.width(), bitmap.height(), bitmap.width(), QImage::Format::Format_Grayscale8).copy();
|
||||||
|
QImage rgbImage = image.convertToFormat(QImage::Format_ARGB32);
|
||||||
|
for (int y = 0; y < rgbImage.height(); ++y) {
|
||||||
|
for (int x = 0; x < rgbImage.width(); ++x) {
|
||||||
|
QRgb pixel = rgbImage.pixel(x, y);
|
||||||
|
if (qRed(pixel) == 0 && qGreen(pixel) == 0 && qBlue(pixel) == 0) {
|
||||||
|
rgbImage.setPixelColor(x, y, _color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
painter->drawImage(QRect(0, 0, static_cast<int>(width()), static_cast<int>(height())), rgbImage);
|
||||||
|
painter->restore();
|
||||||
|
}
|
22
src/FluQRCode.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef FLUQRCODE_H
|
||||||
|
#define FLUQRCODE_H
|
||||||
|
|
||||||
|
#include <QQuickItem>
|
||||||
|
#include <QQuickPaintedItem>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
class FluQRCode : public QQuickPaintedItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY_AUTO(QString,text)
|
||||||
|
Q_PROPERTY_AUTO(QColor,color)
|
||||||
|
Q_PROPERTY_AUTO(int,size);
|
||||||
|
QML_NAMED_ELEMENT(FluQRCode)
|
||||||
|
public:
|
||||||
|
explicit FluQRCode(QQuickItem *parent = nullptr);
|
||||||
|
void paint(QPainter* painter) override;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FLUQRCODE_H
|