pax_global_header 0000666 0000000 0000000 00000000064 15210506206 0014507 g ustar 00root root 0000000 0000000 52 comment=0a6884b2f657cfea03d17510883ca5d48b793fe3
ukui-quick-4.22.0.1/ 0000775 0000000 0000000 00000000000 15210506206 0014022 5 ustar 00root root 0000000 0000000 ukui-quick-4.22.0.1/.gitignore 0000664 0000000 0000000 00000000461 15210506206 0016013 0 ustar 00root root 0000000 0000000 # Ignore the following files
.vscode
*~
*.[oa]
*.diff
*.kate-swp
*.kdev4
.kdev_include_paths
*.kdevelop.pcs
*.moc
*.moc.cpp
*.orig
*.user
.*.swp
.swp.*
Doxyfile
Makefile
avail
random_seed
/build*/
CMakeLists.txt.user*
*.unc-backup*
.clang-format
/compile_commands.json
.clangd
.idea
/cmake-build*
.cache
ukui-quick-4.22.0.1/CMakeLists.txt 0000664 0000000 0000000 00000002111 15210506206 0016555 0 ustar 00root root 0000000 0000000 cmake_minimum_required(VERSION 3.16)
project(ukui-quick)
set(ROOT_PROJECT_NAME ukui-quick)
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_MICRO 0)
set(UKUI_QUICK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO})
include(CMakePackageConfigHelpers)
add_subdirectory(core)
add_subdirectory(items)
add_subdirectory(platform)
add_subdirectory(framework)
add_subdirectory(modules)
add_subdirectory(cmake-extend)
set(CMAKE_CONFIG_INSTALL_DIR "/usr/share/cmake/ukui-quick")
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/ukui-quick-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-config.cmake
INSTALL_DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-config-version.cmake
VERSION ${UKUI_QUICK_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-config-version.cmake
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}
COMPONENT Devel
)
ukui-quick-4.22.0.1/COPYING 0000664 0000000 0000000 00000104515 15210506206 0015063 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
ukui-quick-4.22.0.1/README.md 0000664 0000000 0000000 00000044567 15210506206 0015321 0 ustar 00root root 0000000 0000000 # ukui-quick
限时置顶:实现一个任务栏插件的步骤
## 介绍
ukui-quick是ukui桌面环境的一个组件库,用于为qml应用程序或QT应用程序提供ukui桌面环境的特色功能组件。
* qml应用程序可以通过import 对应模块的uri进行使用。
* C++应用程序也可以通过cmake导入并使用ukui-quick提供的程序库。
## 主要模块
### [core](core)
ukui-quick项目的通用数据和数据结构定义。
### [items](items)
ukui-quick的qml组件库。
items是qml import的主要入口点,用于向qml应用程序提供ukui-quick的各种功能和组件。
### [framework](framework)
### 1. 简介
ukui-quick作为一个基于Qt Quick的UI开发功能集合,其中提供了一个基于插件模式的UI开发框架,目的在于实现对桌面通用插件的定义,加载以及统一配置管理等功能,
此框架的特点包括:
- 可实现桌面组件一定程度上的功能解耦与功能复用
- 插件和宿主应用(Host)之间不会强制有二进制依赖关系,插件的开发相对更加独立,不易产生版本迭代时插件不兼容的情况.
- 插件开发门槛低,无需了解宿主应用全部功能即可开发插件.
- 通用性,可以实现不同桌面组件之间无缝共享插件
- 统一的配置管理模块,便于应用和插件的统一配置管理
#### 1.1 基本概念
插件框架整体由4个主要部分组成: Widget(插件),Container(容器),Island(窗口) ,Config(配置),
Widget表示一个桌面插件,Container为可用于放置插件的容器,Island为基于QQuickWindow的通用窗口,继承了加载Container的功能.Config为统一的配置接口,提供了上述3个结构共用的配置管理功能.
基于此框架开发的一个应用的典型结构如下图所示:

此应用包含两个窗口,其中窗口2为插件框架中的Island,而Island中包含了一个主Container(mainView)作为UI的根节点,根节点与其所有子节点共同组成一个树形结构.通过统一配置管理接口,应用(Island)可以生成属于自己的本地配置,也可以访问属于其插件的全局配置.
#### 1.2 设计模式
整体插件框架分为两部分,一部分是负责保存和处理信息的后端(Widget/Container/Island),另一部分就是负责显示的前端(WidgetQuickItem/WidgetContainerItem/IslandView):

框架类似Composite模式:
Widget:定义了插件和插件容器的公共接口,并实现了相关的默认行为,同时也作为插件(leaf&Component)
Container:继承自Widget,作为UI结构中的分支节点对象(Composite),负责管理所有子widget的生命周期
client表示宿主应用,client在调用插件框架时,可以选择直接使用封装好的Island窗口作为应用窗口,也可以选择直接初始化Container作为插件加载根节点.

### 2.概要设计
#### 2.1 关键组件
##### 2.1.1 Widget与WidgeQuicktItem
Widget类定义了一个插件的基础信息接口,提供对插件包元数据进行访问的接口以及虽配置文件进行访问的接口.
WidgeQuicktItem继承自QQuickItem,是插件框架中的一个基本UI元素(插件),是插件UI的入口,也是插件UI树的根节点.
在一个插件的生命周期开始时,Widget会先被创建,基于Widget提供的数据,一个WidgetItem会被创建然后被加载到UI树中.(翻译文件会在UI初始化之前被加载)
要卸载插件时,在Widget被删除前,UI中的WidgetItem会先执行析构.
##### 2.1.2 WidgetContainer和WidgetContainerItem
WidgetContainer与WidgetContainerItem的关系和Widget与WidgeQuicktItem的关系类似.
WidgetContainer继承自Widget,在其基础上增加了一些用于插件容器的属性,如屏幕信息,边距等,实现了插件加载和配置文件自动加载功能.一般情况下,WidgetContainer用于加载Widget,但一个WidgetContainer还可能与Island有关联(作为island的主视图)。
WidgetContainerItem是容器的主入口,容器负责管理和控制WidgetItem,并将他们放置在某种布局中。
WidgeQuicktItem和WidgetContainerItem只是UI组件,并不包含各种原始信息,那如何在界面上访问对应的Widget和Container呢?
为了满足这个需求,我们为每一个WidgetItem添加了一个附加属性"Widget",在qml文件中可以通过这个附加属性访问Widget的全部属性。同样的ContainerItem也有一个附加属性"WidgetContainer",可以访问Container的全部属性。
如何注册附加属性:使用 qmlRegisterUncreatableType(uri, 1, 0, "Widget", "For widgetItem attached prop.");
更新版的QT可以使用:QML_ATTACHED 宏进行标记注册,但是qt5版本并不推荐
##### 2.1.3 Island和IslandView
Island表示一个应用程序(或应用程序支持加载插件的部分),一个Island中包含一个"mainView",即一个主"WidgetContainer"作为当前的主视图,一个Island同一时间只能加载一个主视图.
IslandView是一个QQuickView窗口,封装了加载和显示Island的主"WidgetContainer"对应的WidgetContainerItem的功能。
IslandView提供两种模式,一种是在加载mainView时直接初始化UI,一种是先在加载后台所有数据,由用户决定在何时初始化UI,前者适合开发一些功能比较简单的应用,而后者便于可以在将UI需要依赖的所有数据都初始化好之后再加载UI,一定程度上防止一些UI显示异常甚至报错.
Island需要配合Config机制使用,实际上,island与Config几乎是强绑定状态,需要使用者理解Config并处理好初始配置。
##### 2.1.4 WidgetInterface
WidgetInterface是一个插件接口定义,插件可以选择实现这个接口以实现某些特性功能,如增加自定义右键菜单项等.这是一个可选接口,但可以脱离qmlUI单独加载,即可以实现一个不包含UI的插件,仅包含一个动态库的插件.
##### 2.1.5 WidgetMetadata
WidgetMetadata表示一个插件的原始元数据信息,所谓原始元数据,就是插件在打包时安装的metadata.json文件中提供的信息.原始元数据在插件框架中非常重要,它用于描述一个插件,包括插件的名称,ID,介绍等基础信息,还有插件的类型(Host),国际化,UI入口等信息.实际上,他可以类比为原生linux应用的"desktop"文件.
WidgetMetaData在一个Widget首次加载时加载,并且在同一个插件被多次加载时共享.Widget提供了在运行时访问全部metadata信息的功能,并可以修改部分信息,如Tooltip文本等(仅在运行时生效,不会直接修改json文件)。
##### 2.1.6 WidgetLoader
插件加载器,WidgetLoader用于根据插件ID加载插件,默认加载路径为:
```
":/ukui/widgets"
"/usr/share/ukui/widgets"
"~/.local/share/ukui/widgets"
```
可在运行时临时增加查找目录
还继承了插件种类判断功能,插件元数据中有一个类型(host)字段,可以通过指定插件加载器所在的应用(宿主)类型,可以自动过滤掉不属于当前类型的插件.例如,在某个应用的插件选择页面只显示可以被加载到当前应用的插件.
插件加载器的扫描路径逻辑可以根据需求进行扩充,例如不同分类的插件可以区分不同目录等
#### 2.2 引擎和上下文
在基于IslandView的应用中,所有IslandView窗口都在同一个Qml Engine中渲染,但他们各自拥有独立的上下文(QQmlContext)用于初始化IslandView中的根容器(MainContainer)。
同时,每个widget(Container也是widget)拥有自己独立的上下文,继承父上下文中所有的属性,同时可以设置独享数据,与其他widget互不干扰。
#### 2.3 插件包
一个完整的Widget插件又称作Widget包,在安装时的基本目录结构如下:
```
// 插件的基本目录结构如下:
org.ukui.widget / # 插件顶级目录
├── metadata.json # 元数据
├──translations
│ └── *.qm
└── ui
└── main.qml #UI入口文件(根控件)
```
其中目录名称需要与插件的唯一ID保持一致,一般使用域名反写。
其中metadata.json为插件的元数据文件或描述文件,一个典型的元数据文件如下:
```json
{
"Authors": [
{
"Name": "iaom",
"Email": "zhangpengfei@kylinos.cn"
}
],
"Id": "org.ukui.testWidget",
"Icon": "kylin-search",
"Name": "test-widget",
"Name[zh_CN]": "测试插件",
"Tooltip": "这是一个测试插件",
"Tooltip[zh_CN]": "这是一个测试插件",
"Description": "test-widget",
"Description[zh_CN]": "这是一个测试插件",
"Version": "1.0",
"Website": "https://ukui.org",
"BugReport": "https://gitee.com/openkylin/ukui-quick/issues",
"ShowIn": "All",
"ApplicationId": ["peony"],
"Thumbnail": "path to/thumbnail.png",
"Contents": {
"Main": "ui/main.qml",
"I18n": "translations/org.ukui.testWidget",
"Plugin": "/home/iaom/git/ukui-quick/cmake-build-debug/framework/test/org.ukui.testWidget/libtest-plugin.so",
"PluginVersion": "1.0.0",
"PluginPreload": false,
"Config": "LocalOnly"
}
}
```
比较重要的几个字段:
- Id:必须,表示插件的唯一Id,插件加载器根据Id区分每个插件,插件目录需要满足"插件加载路径/id"的结构.
- I18n:翻译文件路径,格式为"相对路径/配置文件前缀"
- ShowIn: 表示插件可以显示在哪些宿主应用,目前包括:Panel, SideBar, Desktop, TaskManager, All(前面所有, 默认)
- ApplicationId: 当插件可以显示的宿主应用包含TaskManager时 ,需要指定此字段,任务栏上的taskManager插件会根据此字段判断其对应的应用,格式为desktop文件名,不带“.desktop”后缀。此字段为数组格式,即一个插件可以匹配多个应用
- Thumbnail:插件的缩略图
- Contents/Main: 必须,表示插件UI入口,为插件目录相对路径, 也可以制定qrc资源文件路径.
- Contents/Plugin:so插件路径,可继承WidgetInterface实现一个so插件(基于QtPlugin机制),目前支持增加自定义右键菜单项
- Contents/PluginVersion:插件接口版本(Plugin字段不为空时必须指定接口版本)
- Contents/PluginPreload:true表示插件在加载时即加载so插件,否则会在调用so插件功能时加载
- Config:配置文件行为,"LoclOnly"表示插件的配置文件将记录在宿主应用中,为空时将生成全局配置文件
#### 2.4 配置
配置模块用于为widget/WidgetContainer/Island提供配置读取和存储功能。设计目标是提供一个统一的配置文件管理机制,可以将插件框架中各个模块的配置文件实现统一管理.配置文件通过专门的配置文件加载器(ConfigLoader)获取,加载器负责初始化配置并处理节点映射等工作。
配置文件为json格式,一个典型的配置配置文件实例如下所示:
```json
{
"_views": [
{
"id": "org.ukui.panel",
"instanceId": 0,
"panelSize": 48,
"widgets": [
{
"id": "org.ukui.menu.starter",
"instanceId": 0
},
{
"id": "org.ukui.panel.search",
"instanceId": 1
},
{
"id": "org.ukui.panel.taskView",
"instanceId": 2
}
]
},
{
"disabledInstances": [
0
],
"id": "org.ukui.panelNext",
"instanceId": 1,
"panelSize": 56,
"widgets": [
{
"id": "org.ukui.dataIsland",
"instanceId": 0,
"maximumWidth": 208,
"minimumWidth": 64,
"type": "data",
"widgets": [
{
"id": "org.ukui.menu.starter",
"instanceId": 0
},
{
"id": "org.ukui.panel.taskView",
"instanceId": 1
}
]
},
{
"id": "org.ukui.appIsland",
"instanceId": 1,
"maximumWidth": 16777215,
"minimumWidth": 64,
"type": "app",
"widgets": [
{
"id": "org.ukui.panel.taskManager",
"instanceId": 0
},
{
"id": "org.ukui.panel.search",
"instanceId": 1
}
]
}
]
}
],
"panelConfigVersion": "1.0"
}
```
##### 2.4.1 节点(child)
配置文件为Json格式,一个完整的Config由多个节点组成,而它本身也表示一个节点,一个完整的Config是一个树形结构。
在上面的示例中,_views 所在的对象为根节点,该节点有个2个属性(_views, panelConfigVersion)。
##### 2.4.2 分组信息(groupInfo)
想要Config变成树形结构,我们需要指定如何生成这颗树,而分组就是我们生成树的依据。
ConfigGroupInfo就是Config对节点进行解析的依据,它指定了进行分组的属性和区分分组中各个子对象的主键属性(用于区分不同对象的属性).有了依据,Config就可以将配置文件中的对应属性当作一个组,将组内的对象作为节点读取出来作为几个单独的Config,并与当前的Config形成树形结构 .
需要注意的是,指定进行分组的属性一般是一个json数组,如果在设置分组信息时,原本的数据不是数组,那么这个属性的数据会被全部清空。
对于上述的Json,我们可以指定分组信息为:
```c++
// 设置组信息的对应方法是:
config.addGroupInfo("_views", "instanceId");
```
设置好Config的分组信息后,我们的Config就得到了两个子Config:
```
// 子Config 1
{
"id": "org.ukui.panel",
"instanceId": 0,
...
}
// 子Config 2
{
"id": "org.ukui.panelNext",
"instanceId": 1,
...
}
```
该分组信息的意思是:将当前Config对象的_views属性作为一个分组,并且该分组中的对象以instanceId属性进行区分
Config类有这几个方法用于处理子Config
```c++
// 是否是根节点,只有根节点能读取和保存配置文件
bool isRoot() const;
// 当前Config的主键属性的值
const QVariant &id() const;
// 当前Config属于的组
const QString &group() const;
// 当前的分组信息
const ConfigGroupInfo &groupInfo() const;
// 添加一条分组信息
void addGroupInfo(const QString &group, const QString &key);
// 获取某个组下的全部子Config
ConfigList children(const QString &group) const;
// 某个组下有多少Config
int numberOfChildren(const QString &group) const;
// 通过组名和组内对象主键的值拿到子Config
Config *child(const QString &group, const QVariant &id) const;
/**
* 添加子节点
* @param group 组名
* @param childData 数据
*/
void addChild(const QString &group, const QVariantMap &childData);
/**
* 删除一个子节点
* @param group 组名
* @param id 主键值
*/
void removeChild(const QString &group, const QVariant &id);
/**
* 删除一个key
* @param key 要删除的键
*/
void removeKey(const QString &key);
```
需要注意的是,当我们对Config进行分组操作后,我们就不能再通过getValue方法去读取这些组节点了,必须使用child或children去获取子节点配置(Config).
可以通过以下方法获取子节点:
```c++
// 获取一个分组下的所有子节点:
QList c = config.children("_views");
// 获取某个子节点
Config *c = config.child("_view", 0)
修改上面第一个"instanceId = 0"节点的"panelSize"属性,需要:
// 'panelSize'配置在 '_views' 组中,并且这个组的主键属性为'instanceId'
Config c = config.child("_views", 0);
c.setValue("panelSize", 56);
也可以在已有分组下增加一个新的子节点:
QVariantMap wData;
wData.insert(QStringLiteral("id"), "panel-neo");
wData.insert(QStringLiteral("instanceId"), 2);
//添加新的子节点
config->addChild(QStringLiteral("widgets"), wData);
```
如果没有将child属性作为组,此时的child只是一个普通的json数组数据,想要修改某个属性就需要遍历这个child数组,并找到对应的json对象修改数据。
TODO:多进程间共享的插件全局配置文件监听与通知机制
##### 2.4.3 应用
在插件框架中,Widget的Config是WidgetContainer的子Config,而WidgetContainer的Config又是Island的子Config。
Island的Config的分组信息是:{ "_views", "instanceId" },在实际使用时,Id(主Container的id)也作为唯一属性
WidgetContainer的Config的分组信息是:{ "widgets", "instanceId" }
Widget的Config已经是最底层的节点,目前没有分组信息。
Island在加载mainView(主Container)时,会根据mainView的Id在配置文件的"_view"节点寻找对应的id,将找到的第一个符合的配置节点作为需要加载的WidgetContainer的配置节点:
```c++
/**
* 加载配置文件中的一个view
* @param id view的ID
* @return 加载成功返回true,否则返回false
*/
bool loadMainView(const QString &id);
```
这里参数是Id而不是instanceId,因为一个主Container也是一个打包为一个Widget包的插件.
TODO:增加bool loadMainView(const QString &id, int instanceId);之类的接口,使得_views分组下可以有同Id的不同WidgetContainer
随后WidgetContainer会根据配置文件内容自动加载属于自己的内容,即分析自己的widgets分组并加载其中的Widget.
### 3. 开发示例
[一个简单的插件&一个基础的容器&以及一个基于插件框架开发的应用](https://gitee.com/openkylin/ukui-quick/tree/upstream/framework/test/)
[一个简单的时钟显示插件:](https://gi43l7c2w7z.feishu.cn/docx/YXVYdLS8So81Mpx4O85ck3ZQnNd?from=from_copylink)
[实现一个任务栏插件的步骤](https://yayqg9ul2g.feishu.cn/docx/GBq9dVTmLodP7ExXr6kc8yLsnDf?from=from_copylink)
### [platform](platform)
ukui桌面环境特有组件库,提供一些能够与ukui桌面环境进行交互的组件。
core,items和framework模块都有使用platform提供的功能。
### [modules](modules)
* #### [window-thumbnail](window-thumbnail)
窗口动态预览控件,支持x和wayland环境
### [widgets](widgets)
为ukui-quick插件框架开发的一些插件或qml模块库。
### 其他
截止目前,ukui-quick仍在快速迭代中,文档相对来说不是那么完善。想要参与ukui-quick的开发,可以通过提交issue或PR与我们进行交流。
ukui-quick-4.22.0.1/cmake-extend/ 0000775 0000000 0000000 00000000000 15210506206 0016367 5 ustar 00root root 0000000 0000000 ukui-quick-4.22.0.1/cmake-extend/CMakeLists.txt 0000664 0000000 0000000 00000002644 15210506206 0021135 0 ustar 00root root 0000000 0000000 cmake_minimum_required(VERSION 3.14)
project(cmake-extend)
set(MODULES_CMAKE_EXTEND_INSTALL_DIR "/usr/share/cmake/ukui-quick-cmake-extend/modules/")
set(CONFIG_CMAKE_EXTEND_INSTALL_DIR "/usr/share/cmake/ukui-quick-cmake-extend/cmake/")
set(STYLE_CMAKE_EXTEND_INSTALL_DIR "/usr/share/cmake/ukui-quick-cmake-extend/style/")
file(GLOB installCMakeExtendFiles ${CMAKE_CURRENT_SOURCE_DIR}/modules/*)
install(FILES ${installCMakeExtendFiles} DESTINATION ${MODULES_CMAKE_EXTEND_INSTALL_DIR})
file(GLOB installCMakeExtendStyleFiles ${CMAKE_CURRENT_SOURCE_DIR}/style/*.css)
install(FILES ${installCMakeExtendStyleFiles} DESTINATION ${STYLE_CMAKE_EXTEND_INSTALL_DIR})
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/ukui-quick-cmake-extend-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-cmake-extend-config.cmake"
INSTALL_DESTINATION ${CONFIG_CMAKE_EXTEND_INSTALL_DIR}
PATH_VARS MODULES_CMAKE_EXTEND_INSTALL_DIR STYLE_CMAKE_EXTEND_INSTALL_DIR
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-cmake-extend-config-version.cmake
VERSION ${UKUI_QUICK_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-cmake-extend-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-cmake-extend-config-version.cmake
DESTINATION ${CONFIG_CMAKE_EXTEND_INSTALL_DIR})
ukui-quick-4.22.0.1/cmake-extend/modules/ 0000775 0000000 0000000 00000000000 15210506206 0020037 5 ustar 00root root 0000000 0000000 ukui-quick-4.22.0.1/cmake-extend/modules/QDocConfig.qdocconf.in 0000664 0000000 0000000 00000006445 15210506206 0024147 0 ustar 00root root 0000000 0000000 project = @QDOC_QHP_PROJECT_NAME@
description = @QDOC_PROJECT_NAME@ API 参考文档
url = qthelp://@QDOC_NAMESPACE@.@QDOC_NAME@/@QDOC_NAME@
version = @QDOC_PROJECT_VERSION@
#源码
sourcedirs += @QDOC_SOURCE_DIRS@
sources += @QDOC_SOURCES@
#头文件目录
headerdirs += @QDOC_HEADER_DIRS@
headers += @QDOC_HEADERS@
#图片
imagedirs += @QDOC_IMAGE_DIRS@
images += @QDOC_IMAGES@
#示例
exampledirs += @QDOC_EXAMPLE_DIRS@
examples += @QDOC_EXAMPLES@
#排除的文件
excludedirs += @QDOC_EXCLUDE_DIRS@
excludefiles += @QDOC_EXCLUDE_FILES@
#包含的文件
includepaths = @QDOC_INCLUDE_DIRS@
headers.fileextensions = "*.ch *.h *.h++ *.hh *.hpp *.hxx"
sources.fileextensions = "*.c++ *.cc *.cpp *.cxx *.mm *.qml *.qdoc"
examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml *.css *.glsl"
examples.imageextensions = "*.png *.jpg *.gif"
#索引文件
indexes += @QDOC_INDEX_FILES@
depends += @QDOC_DEPEND_QCHS@
#输出格式
outputformats = HTML
########################## html 样式
HTML.stylesheets = @QDOC_HTML_STYLE_FILE@
#for including files into the qch file
HTML.headerstyles = \
" \n"
HTML.endheader = \
"\n"
HTML.postheader = \
"\n" \
"
\n"\
"
\n" \
"
\n" \
"
\n"\
"
\n"\
HTML.postpostheader = \
"
\n"\
"
\n" \
"
\n" \
"
\n" \
"
\n" \
"
\n" \
###############################################
#输出目录
outputdir = @QDOC_OUTPUT_DIR@
tagfile = @QDOC_TAGS_FILE@
outputencoding = UTF-8
sourceencoding = UTF-8
naturallanguage = zh-Hans
#qhp
qhp.projects = @QDOC_QHP_PROJECT_NAME@
qhp.extraFiles += style/@STYLE_NAME@
qhp.@QDOC_QHP_PROJECT_NAME@.file = @QDOC_NAME@.qhp
qhp.@QDOC_QHP_PROJECT_NAME@.namespace = @QDOC_NAMESPACE@.@QDOC_NAME@
qhp.@QDOC_QHP_PROJECT_NAME@.virtualFolder = @QDOC_NAME@
qhp.@QDOC_QHP_PROJECT_NAME@.indexTitle = @QDOC_PROJECT_NAME@
qhp.@QDOC_QHP_PROJECT_NAME@.indexRoot =
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects = qmltypes classes examples
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.qmltypes.title = QML Types
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.qmltypes.indexTitle = @QDOC_PROJECT_NAME@ QML Types
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.qmltypes.selectors = qmlclass
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.qmltypes.sortPages = true
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.classes.title = C++ Classes
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.classes.indexTitle = @QDOC_PROJECT_NAME@ C++ Classes
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.classes.selectors = class fake:headerfile
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.classes.sortPages = true
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.examples.title = Examples
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.examples.indexTitle = @QDOC_PROJECT_NAME@ Examples and Tutorials
qhp.@QDOC_QHP_PROJECT_NAME@.subprojects.examples.selectors = fake:example
navigation.landingpage = "@QDOC_PROJECT_NAME@"
navigation.cppclassespage = "@QDOC_PROJECT_NAME@ C++ Classes"
navigation.qmltypespage = "@QDOC_PROJECT_NAME@ QML Types"
syntaxhighlighting = true ukui-quick-4.22.0.1/cmake-extend/modules/UkuiQDocAddQch.cmake 0000664 0000000 0000000 00000045320 15210506206 0023576 0 ustar 00root root 0000000 0000000 #[=======================================================================[.rst:
当前模块提供了 ‘ukui_qdoc_add_qch’ 函数用于自动化生成Qt风格的API文档。
以及ukui_install_qch_export 函数用于导出文档的CMake目标,用于查找和创建指向QCH文件的链接
ukui_qdoc_add_qch(
NAME
DOC_NAME
VERSION
[NAMESPACE ]
QCH_INSTALL_DESTINATION
TAGFILE_INSTALL_DESTINATION
[CONFIG_TEMPLATE ]
[STYLE_FILE ]
[SOURCES [ [...]]]
[SOURCE_DIRS [ [...]]]
[HEADERS [ [...]]]
[HEADER_DIRS [ [...]]]
[INCLUDE_DIRS [ [...]]]
[IMAGES [ [...]]]
[IMAGE_DIRS [ [...]]]
[EXAMPLES [ [...]]]
[EXAMPLE_DIRS [ [...]]]
[EXCLUDE_FILES [ [...]]]
[EXCLUDE_DIRS [ [...]]]
[DEPEND_QCHS [ [...]]]
)
’NAME’ 用于显示的名称
‘DOC_NAME’ 文档名称
‘VERSION’ 版本号
‘NAMESPACE’ 命名空间
‘QCH_INSTALL_DESTINATION’ qch 文件安装路径
‘TAGFILE_INSTALL_DESTINATION’ tags 文件安装路径
‘CONFIG_TEMPLATE’ 配置模板文件,可参考QDOCConfig.qdocconf.in 编写
‘STYLE_FILE’ 指定文档样式文件,如不显示指定,默认(default.css)和Qt文档风格一致
‘SOURCES’ 源码文件,可以和SOURCE_DIRS 一起使用,指定源码文件也需要同步指定对应的头文件
‘SOURCE_DIRS’ 源文件目录
‘HEADERS’ 头文件,可以和HEADER_DIRS 一起使用
‘HEADER_DIRS’ 头文件目录
‘INCLUDE_DIRS’ 包含目录
‘IMAGES’ 图片文件,文档注释中使用的图片文件
‘IMAGE_DIRS’ 图片文件目录
‘EXAMPLES’ 示例文件
‘EXAMPLE_DIRS’ 示例文件目录
‘EXCLUDE_FILES’ 扫描注释时排除的文件
‘EXCLUDE_DIRS’ 排除目录
‘DEPEND_QCHS’ 依赖的 qch 文件, 链接指定模块的文档
‘DEPEND_DIRS’ 一般与DEPEND_QCHS一起使用, 如果 DEPEND_QCHS 指定的模块文档在默认目录下(/usr/share/qt5/doc/),无需显式指定当前变量;
如果依赖的模块文档不在默认目录下,需要通过DEPEND_DIRS 指定依赖的文档目录, 然后通过DEPEND_QCHS指定模块即可
‘INDEX_FILES’ 文档索引文件,通过指定依赖的文档索引,来建立和文档的链接, 一般不和DEPEND_QCHS 一起使用。
#use example
qdoc_add_qch(ukui-_quick-core-doc
NAME "ukui-quick-core"
DOC_NAME ukui-quick-core
VERSION ${UKUI_QUICK_VERSION}
NAMESPACE org.ukui.
QCH_INSTALL_DESTINATION "/usr/share/qt5/doc"
SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
HEADER_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
::
ukui_install_qch_export(
TARGETS [ [ [...]]]
FILE
DESTINATION
[COMPONENT ]
)
'TARGETS' 指定要导出的文档目标
‘FILE’ 指定生成的 CMake 文件名
‘DESTINATION’ 指定 CMake 文件的安装目录
‘COMPONENT’ 指定安装规则关联的组件名称
Example usage:
ukui_install_qch_export(
TARGETS MyLib_QCH
FILE MyLibQCHTargets.cmake
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/MyLib"
COMPONENT Devel
)
#]=======================================================================]
include(FeatureSummary)
if (TARGET Qt5::Core)
set(QT_MAJOR_VERSION 5)
else ()
set(QT_MAJOR_VERSION 6)
endif ()
function(ukui_qdoc_add_qch target_name)
set(options VERBOSE)
set(oneValueArgs NAME DOC_NAME VERSION NAMESPACE QCH_INSTALL_DESTINATION TAGFILE_INSTALL_DESTINATION CONFIG_TEMPLATE STYLE_FILE)
set(multiValueArgs SOURCES SOURCE_DIRS HEADERS HEADER_DIRS INCLUDE_DIRS IMAGES IMAGE_DIRS EXAMPLES EXAMPLE_DIRS EXCLUDE_FILES EXCLUDE_DIRS DEPEND_QCHS DEPEND_DIRS INDEX_FILES)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
#---------------------------------------------------------
# 检查必要参数
#---------------------------------------------------------
foreach (arg_name NAME DOC_NAME VERSION QCH_INSTALL_DESTINATION)
if(NOT DEFINED ARGS_${arg_name})
message(FATAL_ERROR "${arg_name} needs to be defined when calling ukui_qdoc_add_qch")
endif()
endforeach ()
if(NOT DEFINED ARGS_SOURCE_DIRS AND NOT DEFINED ARGS_SOURCES)
message(FATAL_ERROR "SOURCE_DIRS or SOURCES needs to be defined when calling ukui_qdoc_add_qch")
endif()
if(NOT DEFINED ARGS_HEADER_DIRS AND NOT DEFINED ARGS_HEADERS)
message(FATAL_ERROR "HEADER_DIRS or HEADERS needs to be defined when calling ukui_qdoc_add_qch")
endif()
#---------------------------------------------------------
# 查找qdoc qhelpgenerator 工具
#---------------------------------------------------------
if (QT_VERSION_MAJOR EQUAL 5)
find_program(QDoc_EXECUTABLE NAMES qdoc qdoc-qt5)
set_package_properties(QDoc_EXECUTABLE PROPERTIES
TYPE REQUIRED
PURPOSE "Needed for API dox QCH file generation"
DESCRIPTION "Part of Qt5 tools"
)
find_program(QHelpGenerator_EXECUTABLE NAMES qhelpgenerator qhelpgenerator-qt5)
set_package_properties(QHelpGenerator_EXECUTABLE PROPERTIES
TYPE REQUIRED
PURPOSE "Needed for API dox QCH file generation"
DESCRIPTION "Part of Qt5 tools"
)
else()
find_package(Qt6 COMPONENTS ToolsTools CONFIG REQUIRED)
set_package_properties(Qt6ToolsTools PROPERTIES
TYPE REQUIRED
PURPOSE "Needed for API dox QCH file generation"
DESCRIPTION "qhelpgenerator from Qt6 tools"
)
if(TARGET Qt6::qdoc)
get_target_property(QDoc_EXECUTABLE Qt6::qdoc LOCATION)
endif()
if(TARGET Qt6::qhelpgenerator)
get_target_property(QHelpGenerator_EXECUTABLE Qt6::qhelpgenerator LOCATION)
endif()
endif()
set(missing_tools)
if (NOT QDoc_EXECUTABLE AND NOT TARGET Qt6::qdoc)
list(APPEND missing_tools "qdoc")
endif()
if (NOT QHelpGenerator_EXECUTABLE AND NOT TARGET Qt6::qhelpgenerator)
list(APPEND missing_tools "qhelpgenerator")
endif()
if (missing_tools)
message(WARNING "API dox QCH file will not be generated, tools missing: ${missing_tools}!")
else()
#---------------------------------------------------------
# 配置模板文件参数
#---------------------------------------------------------
set(QDOC_PROJECT_NAME "${ARGS_NAME}")
string(REPLACE "-" "" qhp_project_name "${ARGS_NAME}")
string(REPLACE " " "" qhp_project_name "${qhp_project_name}")
set(QDOC_QHP_PROJECT_NAME "${qhp_project_name}")
if (DEFINED ARGS_DOC_NAME)
string(TOLOWER "${ARGS_DOC_NAME}" doc_name)
string(REGEX REPLACE "[ _-]" "" doc_name "${doc_name}")
else()
string(TOLOWER "${qhp_project_name}" doc_name)
string(REGEX REPLACE "[ _-]" "" doc_name "${doc_name}")
endif()
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/doc/${doc_name}")
set(QDOC_OUTPUT_DIR "${output_dir}")
set(QDOC_NAME "${doc_name}")
set(QDOC_PROJECT_VERSION ${ARGS_VERSION})
set(QDOC_NAMESPACE ${ARGS_NAMESPACE})
#qch 安装路径
set(qch_install_destination ${ARGS_QCH_INSTALL_DESTINATION})
#tagfile 安装路径
if (DEFINED ARGS_TAGFILE_INSTALL_DESTINATION)
set(tagfile_install_destination ${ARGS_TAGFILE_INSTALL_DESTINATION})
else ()
set(tagfile_install_destination "${qch_install_destination}/${doc_name}")
endif ()
#index 安装路径
set(index_install_destination "${qch_install_destination}/${doc_name}")
#其他模块引用当前index的路径
set(index_depend_path "${qch_install_destination}")
#tags
set(qdoc_output_tags_file "${output_dir}/${doc_name}.tags")
set(QDOC_TAGS_FILE "${qdoc_output_tags_file}")
if (DEFINED ARGS_CONFIG_TEMPLATE)
set(qdoc_config_template_file ${ARGS_CONFIG_TEMPLATE})
else()
set(qdoc_config_template_file "${UKUI_QUICK_CMAKE_EXTEND_DIR}/QDocConfig.qdocconf.in")
endif()
#style
if (DEFINED ARGS_STYLE_FILE)
set(qdoc_style_file ${ARGS_STYLE_FILE})
else()
set(qdoc_style_file "${UKUI_QUICK_CMAKE_EXTEND_STYLE_DIR}default.css")
endif()
set(QDOC_HTML_STYLE_FILE "${qdoc_style_file}")
get_filename_component(STYLE_NAME "${qdoc_style_file}" NAME)
set(qdoc_config_file "${CMAKE_CURRENT_BINARY_DIR}/${doc_name}.qdocconf")
#sources source_dirs
set(QDOC_SOURCE_DIRS)
foreach(source_dir IN LISTS ARGS_SOURCE_DIRS)
if (NOT IS_ABSOLUTE ${source_dir})
set(source_dir "${CMAKE_CURRENT_SOURCE_DIR}/${source_dir}")
endif()
set(QDOC_SOURCE_DIRS "${QDOC_SOURCE_DIRS} \\\n\"${source_dir}\"")
endforeach()
set(QDOC_SOURCES)
foreach(source IN LISTS ARGS_SOURCES)
if (NOT IS_ABSOLUTE ${source})
set(source "${CMAKE_CURRENT_SOURCE_DIR}/${source}")
endif()
list(APPEND sources "${source}")
endforeach()
foreach(source IN LISTS sources)
set(QDOC_SOURCES "${QDOC_SOURCES} \\\n\"${source}\"")
endforeach()
#headers header_dirs
set(QDOC_HEADER_DIRS)
foreach(header_dir IN LISTS ARGS_HEADER_DIRS)
if (NOT IS_ABSOLUTE ${header_dir})
set(header_dir "${CMAKE_CURRENT_SOURCE_DIR}/${header_dir}")
endif()
set(QDOC_HEADER_DIRS "${QDOC_HEADER_DIRS} \\\n\"${header_dir}\"")
endforeach()
set(QDOC_HEADERS)
foreach(header IN LISTS ARGS_HEADERS)
if (NOT IS_ABSOLUTE ${header})
set(header "${CMAKE_CURRENT_SOURCE_DIR}/${header}")
endif()
list(APPEND headers "${header}")
endforeach()
foreach(header IN LISTS headers)
set(QDOC_HEADERS "${QDOC_HEADERS} \\\n\"${header}\"")
endforeach()
#include_dirs
set(QDOC_INCLUDE_DIRS)
foreach(include_dir IN LISTS ARGS_INCLUDE_DIRS)
if (NOT IS_ABSOLUTE ${include_dir})
set(include_dir "${CMAKE_CURRENT_SOURCE_DIR}/${include_dir}")
endif()
set(QDOC_INCLUDE_DIRS "${QDOC_INCLUDE_DIRS} \\\n\"${include_dir}\"")
endforeach()
#images
set(QDOC_IMAGE_DIRS)
foreach(image_dir IN LISTS ARGS_IMAGE_DIRS)
if (NOT IS_ABSOLUTE ${image_dir})
set(image_dir "${CMAKE_CURRENT_SOURCE_DIR}/${image_dir}")
endif()
set(QDOC_IMAGE_DIRS "${QDOC_IMAGE_DIRS} \\\n\"${image_dir}\"")
endforeach()
set(QDOC_IMAGES)
foreach(image IN LISTS ARGS_IMAGES)
if (NOT IS_ABSOLUTE ${image})
set(image "${CMAKE_CURRENT_SOURCE_DIR}/${image}")
endif()
list(APPEND images "${image}")
endforeach()
foreach(image IN LISTS images)
set(QDOC_IMAGES "${QDOC_IMAGES} \\\n\"${image}\"")
endforeach()
#example_dirs examples 示例目录
set(QDOC_EXAMPLE_DIRS)
foreach(example_dir IN LISTS ARGS_EXAMPLE_DIRS)
if (NOT IS_ABSOLUTE ${example_dir})
set(example_dir "${CMAKE_CURRENT_SOURCE_DIR}/${example_dir}")
endif()
set(QDOC_EXAMPLE_DIRS "${QDOC_EXAMPLE_DIRS} \\\n\"${example_dir}\"")
endforeach()
set(QDOC_EXAMPLES)
foreach(example IN LISTS ARGS_EXAMPLES)
if (NOT IS_ABSOLUTE ${example})
set(example "${CMAKE_CURRENT_SOURCE_DIR}/${example}")
endif()
list(APPEND examples "${example}")
endforeach()
foreach(example IN LISTS examples)
set(QDOC_EXAMPLES "${QDOC_EXAMPLES} \\\n\"${example}\"")
endforeach()
#exclude_files exclude_dirs 需要排除的文件
set(QDOC_EXCLUDE_DIRS)
foreach(exclude_dir IN LISTS ARGS_EXCLUDE_DIRS)
if (NOT IS_ABSOLUTE ${exclude_dir})
set(exclude_dir "${CMAKE_CURRENT_SOURCE_DIR}/${exclude_dir}")
endif()
set(QDOC_EXCLUDE_DIRS "${QDOC_EXCLUDE_DIRS} \\\n\"${exclude_dir}\"")
endforeach()
set(QDOC_EXCLUDE_FILES)
foreach(exclude_file IN LISTS ARGS_EXCLUDE_FILES)
if (NOT IS_ABSOLUTE ${exclude_file})
set(exclude_file "${CMAKE_CURRENT_SOURCE_DIR}/${exclude_file}")
endif()
list(APPEND exclude_files "${exclude_file}")
endforeach()
foreach(exclude_file IN LISTS exclude_files)
set(QDOC_EXCLUDE_FILES "${QDOC_EXCLUDE_FILES} \\\n\"${exclude_file}\"")
endforeach()
#depends_qchs
set(QDOC_DEPEND_QCHS)
foreach(depend_qch IN LISTS ARGS_DEPEND_QCHS)
set(QDOC_DEPEND_QCHS "${QDOC_DEPEND_QCHS} \\\n${depend_qch}")
endforeach()
#depend_dirs 依赖的目录, 如果依赖文档没有安装在默认目录(/usr/share/qt5/doc/),通过当前变量指定
set(depend_dirs)
#增加默认的依赖目录
list(APPEND ARGS_DEPEND_DIRS ${qch_install_destination})
#去重
list(REMOVE_DUPLICATES ARGS_DEPEND_DIRS)
foreach(depend_dir IN LISTS ARGS_DEPEND_DIRS)
if (NOT IS_ABSOLUTE ${depend_dir})
set(depend_dir "${CMAKE_CURRENT_SOURCE_DIR}/${depend_dir}")
endif()
list(APPEND depend_dirs "-indexdir" "${depend_dir}")
endforeach()
set(QDOC_INDEX_FILES)
foreach(index_file IN LISTS ARGS_INDEX_FILES)
set(QDOC_INDEX_FILES "${QDOC_INDEX_FILES} \\\n${index_file}")
endforeach()
#----------------------------------
# finally create qdoc config file
configure_file(
"${qdoc_config_template_file}"
"${qdoc_config_file}"
@ONLY
)
set(qdoc_output_qhp_file "${output_dir}/${doc_name}.qhp")
set(qdoc_output_qch_file "${output_dir}/${doc_name}.qch")
set(qdoc_output_index_file "${output_dir}/${doc_name}.index")
# 开启VERBOSE输出日志到终端,默认输出到文件
if(ARGS_VERBOSE)
set(qdoc_log_command)
set(qhelp_log_command)
else()
set(log_file "${CMAKE_CURRENT_BINARY_DIR}/qdoc_log.log")
set(qdoc_log_command ">" ${log_file} "2>&1")
set(qhelp_log_command ">>" ${log_file} "2>&1")
endif()
add_custom_command(
OUTPUT ${qdoc_output_qhp_file} ${qdoc_output_qch_file}
COMMENT "Generating ${_relative_qch_file}, ${_relative_tags_file}"
COMMAND cmake -E remove_directory "${output_dir}"
COMMAND cmake -E make_directory "${output_dir}"
COMMAND ${QDoc_EXECUTABLE} "${qdoc_config_file}" ${depend_dirs} ${qdoc_log_command}
COMMAND ${QHelpGenerator_EXECUTABLE} "${qdoc_output_qhp_file}" -o "${qdoc_output_qch_file}" ${qhelp_log_command}
DEPENDS
${qdoc_config_file}
${depend_qchs}
)
add_custom_target(${target_name} ALL DEPENDS ${qdoc_output_qhp_file} ${qdoc_output_qch_file})
#设置被引用的模块名和安装路径
set_target_properties(${target_name} PROPERTIES
DEPEND_QCH_MODULE ${doc_name}
DEPEND_QCH_PATH ${index_depend_path}
DEPEND_QCH_INDEX "${index_install_destination}/${doc_name}.index"
)
# setup installation
install(FILES
${qdoc_output_qch_file}
DESTINATION ${qch_install_destination}
)
install(FILES
${qdoc_output_tags_file}
DESTINATION ${tagfile_install_destination}
)
install(FILES
${qdoc_output_index_file}
DESTINATION ${index_install_destination}
)
endif ()
endfunction()
# Imitation ECM ecm_install_qch_export
function(ukui_install_qch_export)
set(options )
set(oneValueArgs FILE DESTINATION COMPONENT)
set(multiValueArgs TARGETS)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT DEFINED ARGS_FILE)
message(FATAL_ERROR "FILE needs to be defined when calling ukui_qdoc_qch_export().")
endif()
if(NOT DEFINED ARGS_DESTINATION)
message(FATAL_ERROR "DESTINATION needs to be defined when calling ukui_qdoc_qch_export().")
endif()
set(_content
"# This file was generated by ukui_install_qch_export(). DO NOT EDIT!
"
)
foreach(_target IN LISTS ARGS_TARGETS)
set(_target_usable TRUE)
if (NOT TARGET ${_target})
message(STATUS "No such target ${_target} when calling ukui_install_qch_export().")
set(_target_usable FALSE)
else()
get_target_property(depend_qch_module ${_target} DEPEND_QCH_MODULE)
get_target_property(depend_qch_path ${_target} DEPEND_QCH_PATH)
get_target_property(depend_qch_index ${_target} DEPEND_QCH_INDEX)
if(NOT depend_qch_module)
message(STATUS "No depend_qch_module for ${_target}.")
set(_target_usable FALSE)
endif()
if(NOT depend_qch_path)
message(STATUS "No depend_qch_path for ${_target}.")
set(_target_usable FALSE)
endif()
if(NOT depend_qch_index)
message(STATUS "No depend_qch_index for ${_target}.")
set(_target_usable FALSE)
endif()
endif()
if(_target_usable)
set(_content "${_content}
if (NOT TARGET ${_target})
add_custom_target(${_target})
set_target_properties(${_target} PROPERTIES
DEPEND_QCH_MODULE \"${depend_qch_module}\"
DEPEND_QCH_PATH \"${depend_qch_path}\"
DEPEND_QCH_INDEX \"${depend_qch_index}\"
)
endif()
"
)
else()
message(STATUS "No target exported for ${_target}.")
endif()
endforeach()
if (NOT IS_ABSOLUTE ${ARGS_FILE})
set(ARGS_FILE "${CMAKE_CURRENT_BINARY_DIR}/${ARGS_FILE}")
endif()
file(GENERATE
OUTPUT "${ARGS_FILE}"
CONTENT "${_content}"
)
if (DEFINED ARGS_COMPONENT)
set(_component COMPONENT ${ARGS_COMPONENT})
else()
set(_component)
endif()
install(
FILES "${ARGS_FILE}"
DESTINATION "${ARGS_DESTINATION}"
${_component}
)
endfunction() ukui-quick-4.22.0.1/cmake-extend/style/ 0000775 0000000 0000000 00000000000 15210506206 0017527 5 ustar 00root root 0000000 0000000 ukui-quick-4.22.0.1/cmake-extend/style/default.css 0000664 0000000 0000000 00000030715 15210506206 0021673 0 ustar 00root root 0000000 0000000
/*
* from qt offline.css
*/
body {
font: normal 400 1rem/1.2 Arial;
margin-top: 50px;
font-family: Arial, Helvetica;
text-align: left;
margin-left: 5px;
margin-right: 5px;
background-color: #fff;
}
p {
line-height: 20px
}
img {
margin-left: 0px;
max-width: 800px;
height: auto;
}
.content .border img {
box-shadow:3px 3px 8px 3px rgba(200,200,200,0.5)
}
.content .border .player {
box-shadow:3px 3px 8px 3px rgba(200,200,200,0.5)
}
.content .indexboxcont li {
font: normal bold 13px/1 Verdana
}
.content .normallist li {
font: normal 13px/1 Verdana
}
.descr {
margin-top: 35px;
margin-bottom: 45px;
margin-left: 5px;
text-align: left;
vertical-align: top;
}
.name {
max-width: 75%;
font-weight: 100;
}
tt {
text-align: left
}
/*
-----------
links
-----------
*/
a:link {
color: #007330;
text-decoration: none;
text-align: left;
}
a.qa-mark:target:before {
content: "***";
color: #ff0000;
}
a:hover {
color: #44a51c;
text-align: left;
}
a:visited {
color: #007330;
text-align: left;
}
a:visited:hover {
color: #44a51c;
text-align: left;
}
/*
-----------
offline viewing: HTML links display an icon
-----------
*/
a[href*="http://"], a[href*="ftp://"], a[href*="https://"] {
text-decoration: none;
background-image: url(../images/ico_out.png);
background-repeat: no-repeat;
background-position: left;
padding-left: 20px;
text-align: left;
}
.flags {
text-decoration: none;
text-height: 24px;
}
.flags:target {
background-color: #FFFFD6;
}
/*
-------------------------------
NOTE styles
-------------------------------
*/
.admonition {
padding: 5px 0 5px 40px;
border: #ccc 1px solid;
}
.admonition.note, .admonition.important {
background: #f2f2f2 3px 6px no-repeat url(../images/ico_note.png);
}
.admonition.warning {
background: #f2f2f2 3px 6px no-repeat url(../images/ico_note_attention.png);
}
/*
-------------------------------
Top navigation
-------------------------------
*/
.qtref {
display: block;
position: relative;
height: 15px;
z-index: 1;
font-size: 11px;
padding-right: 10px;
float: right;
}
.naviNextPrevious {
clear: both;
display: block;
position: relative;
text-align: right;
top: -30px;
float: right;
height: 20px;
z-index: 1;
padding-right: 10px;
padding-top: 2px;
vertical-align: top;
margin: 0px;
}
.naviNextPrevious > a:first-child {
background-image: url(../images/btn_prev.png);
background-repeat: no-repeat;
background-position: left;
padding-left: 20px;
height: 20px;
padding-left: 20px;
}
.naviNextPrevious > a:last-child {
background-image: url(../images/btn_next.png);
background-repeat: no-repeat;
background-position: right;
padding-right: 20px;
height: 20px;
margin-left: 30px;
}
.naviSeparator { display: none }
/*
-----------
footer and license
-----------
*/
.footer {
text-align: left;
padding-top: 45px;
padding-left: 5px;
margin-top: 45px;
margin-bottom: 45px;
font-size: 10px;
border-top: 1px solid #999;
}
.footer p {
line-height: 14px;
font-size: 11px;
padding: 0;
margin: 0;
}
.footer a[href*="http://"], a[href*="ftp://"], a[href*="https://"] {
font-weight: bold;
}
.footerNavi {
width: auto;
text-align: right;
margin-top: 50px;
z-index: 1;
}
.navigationbar {
display: block;
position: relative;
border-top: 1px solid #cecece;
border-bottom: 1px solid #cecece;
background-color: #F2F2F2;
z-index: 1;
height: 20px;
padding-left: 7px;
margin: 0px;
padding-top: 2px;
margin-left: -5px;
margin-right: -5px;
}
.navigationbar .first {
background: url(../images/home.png);
background-position: left;
background-repeat: no-repeat;
padding-left: 20px;
}
.navigationbar ul {
margin: 0px;
padding: 0px;
}
.navigationbar ul li {
list-style-type: none;
padding-top: 2px;
padding-left: 4px;
margin: 0;
height: 20px;
}
.navigationbar li {
float: left
}
.navigationbar li a, .navigationbar td a {
display: block;
text-decoration: none;
background: url(../images/arrow_bc.png);
background-repeat: no-repeat;
background-position: right;
padding-right: 17px;
}
table.buildversion {
float: right;
margin-top: -18px !important;
}
.navigationbar table {
border-radius: 0;
border: 0 none;
background-color: #F2F2F2;
margin: 0;
}
.navigationbar table td {
padding: 0;
border: 0 none;
}
#buildversion {
font-style: italic;
float: right;
margin-right: 5px;
}
#buildversion a {
background: none;
}
/*
/* table of content
no display
*/
/*
-----------
headers
-----------
*/
@media screen {
.title {
color: #313131;
font-size: 20px;
font-weight: normal;
left: 0;
padding-bottom: 15px;
padding-left: 10px;
padding-top: 15px;
position: absolute;
right: 0;
top: 0;
background-color: #E6E6E6;
border-bottom: 1px #CCC solid;
font-weight: bold;
margin-left: 0px;
margin-right: 0px;
}
.subtitle, .small-subtitle {
display: block;
clear: left;
}
}
h1 {
margin: 0
}
h2, p.h2 {
font: 500 16px/1.2 Arial;
font-weight: 100;
background-color: #F2F3F4;
padding: 4px;
margin-bottom: 15px;
margin-top: 30px;
border-top: #E0E0DE 1px solid;
border-bottom: #E0E0DE 1px solid;
max-width: 99%;
}
h2:target {
background-color: #F2F3D4;
}
h3 {
font: 500 14px/1.2 Arial;
font-weight: 100;
text-decoration: underline;
margin-bottom: 15px;
margin-top: 30px;
}
h3.fn, span.fn {
border-width: 1px;
border-style: solid;
border-color: #E6E6E6;
-moz-border-radius: 7px 7px 7px 7px;
-webkit-border-radius: 7px 7px 7px 7px;
border-radius: 7px 7px 7px 7px;
background-color: #F6F6F6;
word-spacing: 3px;
padding: 5px 5px;
text-decoration: none;
font-weight: bold;
max-width: 75%;
font-size: 14px;
margin: 0px;
margin-top: 30px;
}
.fngroup h3.fngroupitem {
margin-bottom: 5px;
}
h3.fn code {
float: right;
}
h3.fn:target {
background-color: #F6F6D6;
}
.name {
color: #1A1A1A
}
.type {
color: #808080
}
@media print {
.title {
color: #0066CB;
font-family: Arial, Helvetica;
font-size: 32px;
font-weight: normal;
left: 0;
position: absolute;
right: 0;
top: 0;
}
}
/*
-----------------
table styles
-----------------
*/
.table img {
border: none;
margin-left: 0px;
-moz-box-shadow: 0px 0px 0px #fff;
-webkit-box-shadow: 0px 0px 0px #fff;
box-shadow: 0px 0px 0px #fff;
}
/* table with border alternative colours*/
table, pre, .LegaleseLeft {
-moz-border-radius: 7px 7px 7px 7px;
-webkit-border-radius: 7px 7px 7px 7px;
border-radius: 7px 7px 7px 7px;
background-color: #F6F6F6;
border: 1px solid #E6E6E6;
border-collapse: separate;
margin-bottom: 25px;
margin-left: 15px;
font-size: 1rem;
line-height: 1.2;
}
table tr.even {
background-color: white;
color: #66666E;
}
table tr.odd {
background-color: #F6F6F6;
color: #66666E;
}
table tr:target {
background-color: #F6F6D6;
}
table thead {
text-align: left;
padding-left: 20px;
background-color: #e1e0e0;
border-left: none;
border-right: none;
}
table thead th {
padding-top: 5px;
padding-left: 10px;
padding-bottom: 5px;
border-bottom: 2px solid #D1D1D1;
padding-right: 10px;
}
table th {
text-align: left;
padding-left: 20px;
}
table td {
padding: 3px 15px 3px 20px;
border-bottom: #CCC dotted 1px;
}
table p {
margin: 0px
}
.LegaleseLeft {
font-family: monospace;
white-space: pre-wrap;
}
/* table bodless & white*/
.borderless {
border-radius: 0px 0px 0px 0px;
background-color: #fff;
border: 1px solid #fff;
}
.borderless tr {
background-color: #FFF;
color: #66666E;
}
.borderless td {
border: none;
border-bottom: #fff dotted 1px;
}
/*
-----------
List
-----------
*/
ul {
margin-top: 10px;
}
li {
margin-bottom: 10px;
padding-left: 8px;
list-style: outside;
text-align: left;
}
ul > li {
list-style-type: square;
}
ol {
margin: 10px;
padding: 0;
}
ol.A > li {
list-style-type: upper-alpha;
}
ol.a > li{
list-style-type: lower-alpha;
}
ol > li {
margin-left: 30px;
padding-left: 8px;
list-style: decimal;
}
.centerAlign {
text-align: left
}
.cpp, .LegaleseLeft {
display: block;
margin: 10px;
overflow: auto;
padding: 20px 20px 20px 20px;
}
.js {
display: block;
margin: 10px;
overflow: auto;
padding: 20px 20px 20px 20px;
}
.memItemLeft {
padding-right: 3px
}
.memItemRight {
padding: 3px 15px 3px 0
}
.qml {
display: block;
margin: 10px;
overflow: auto;
padding: 20px 20px 20px 20px;
}
.qmldefault {
padding-left: 5px;
float: right;
color: red;
}
.qmlreadonly {
padding-left: 5px;
float: right;
color: #254117;
}
.rightAlign {
padding: 3px 5px 3px 10px;
text-align: right;
}
.qmldoc {
margin-left: 15px
}
.flowList {
padding: 25px
}
.flowList dd {
display: inline-block;
margin-left: 10px;
width: 255px;
line-height: 1.15em;
overflow-x: hidden;
text-overflow: ellipsis
}
.alphaChar {
font-size: 2em;
position: relative
}
/*
-----------
Content table
-----------
*/
@media print {
.toc {
float: right;
clear: right;
padding-bottom: 10px;
padding-top: 50px;
width: 100%;
background-image: url(../images/bgrContent.png);
background-position: top;
background-repeat: no-repeat;
}
}
@media screen {
.toc {
float: right;
clear: right;
vertical-align: top;
-moz-border-radius: 7px 7px 7px 7px;
-webkit-border-radius: 7px 7px 7px 7px;
border-radius: 7px 7px 7px 7px;
background: #FFF url('../images/bgrContent.png');
background-position: top;
background-repeat: repeat-x;
border: 1px solid #E6E6E6;
padding-left: 5px;
padding-bottom: 10px;
height: auto;
width: 200px;
text-align: left;
margin-left: 20px;
margin-top: 5px;
}
}
.toc h3 {
text-decoration: none
}
.toc h3 {
font: 500 14px/1.2 Arial;
font-weight: 100;
padding: 0px;
margin: 0px;
padding-top: 5px;
padding-left: 5px;
}
.toc ul {
padding-left: 10px;
padding-right: 5px;
}
.toc ul li {
margin-left: 15px;
list-style-image: url(../images/bullet_dn.png);
marker-offset: 0px;
margin-bottom: 8px;
padding-left: 0px;
}
.toc .level1 {
border: none
}
.toc .level2 {
border: none;
margin-left: 25px;
}
.level3 {
border: none;
margin-left: 30px;
}
.clearfix {
clear: both
}
/*
-----------
Landing page
-----------
*/
.col-group {
white-space: nowrap;
vertical-align: top;
}
.landing h2 {
background-color: transparent;
border: none;
margin-bottom: 0px;
font-size: 18px;
}
.landing a, .landing li {
font-size: 13px;
font-weight: bold !important;
}
.col-1 {
display: inline-block;
white-space: normal;
width: 70%;
height: 100%;
float: left;
}
.col-2 {
display: inline-block;
white-space: normal;
width: 20%;
margin-left: 5%;
position: relative;
top: -20px;
}
.col-1 h1 {
margin: 20px 0 0 0;
}
.col-1 h2 {
font-size: 18px;
font-weight: bold !important;
}
.landingicons {
display: inline-block;
width: 100%;
}
.icons1of3 {
display: inline-block;
width: 33.3333%;
float: left;
}
.icons1of3 h2, .doc-column h2 {
font-size: 15px;
margin: 0px;
padding: 0px;
}
div.multi-column {
position: relative;
}
div.multi-column div {
display: -moz-inline-box;
display: inline-block;
vertical-align: top;
margin-top: 1em;
margin-right: 4em;
width: 24em;
}
.mainContent .video {
width:40%;
max-width:640px;
margin: 15px 0 0 15px;
position:relative;
display:table
}
.mainContent .video > .vspan {
padding-top:60%;
display:block
}
.mainContent .video iframe {
width:100%;
height:100%;
position:absolute;
top:0;
left:0
}
ukui-quick-4.22.0.1/cmake-extend/ukui-quick-cmake-extend-config.cmake.in 0000664 0000000 0000000 00000000355 15210506206 0025676 0 ustar 00root root 0000000 0000000 @PACKAGE_INIT@
set(UKUI_QUICK_CMAKE_EXTEND_DIR "@PACKAGE_MODULES_CMAKE_EXTEND_INSTALL_DIR@")
set(UKUI_QUICK_CMAKE_EXTEND_STYLE_DIR "@PACKAGE_STYLE_CMAKE_EXTEND_INSTALL_DIR@")
list(APPEND CMAKE_MODULE_PATH ${UKUI_QUICK_CMAKE_EXTEND_DIR})
ukui-quick-4.22.0.1/core/ 0000775 0000000 0000000 00000000000 15210506206 0014752 5 ustar 00root root 0000000 0000000 ukui-quick-4.22.0.1/core/CMakeLists.txt 0000664 0000000 0000000 00000007342 15210506206 0017520 0 ustar 00root root 0000000 0000000 cmake_minimum_required(VERSION 3.14)
project(core)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick Qml REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick Qml REQUIRED)
set(UKUI_QUICK_CORE_SRCS
margin.cpp
types.cpp
shared-engine-view.cpp
shared-qml-engine.cpp
shared-engine-component.cpp
)
set(HEADERS
margin.h
types.h
shared-engine-view.h
shared-qml-engine.h
shared-engine-component.h
)
add_library(${PROJECT_NAME} SHARED
${UKUI_QUICK_CORE_SRCS}
)
add_library(ukui-quick::core ALIAS ${PROJECT_NAME})
add_library(${ROOT_PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Qml
)
set(HEADERS_INSTALL_DIR /usr/include/ukui-quick/core)
target_include_directories(${PROJECT_NAME}
PUBLIC
$
)
#文档
include(../cmake-extend/modules/UkuiQDocAddQch.cmake)
set(include_dirs
"/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}/qt${QT_VERSION_MAJOR}/"
"/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}/qt${QT_VERSION_MAJOR}/QtCore"
"/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}/qt${QT_VERSION_MAJOR}/QtQml"
"/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}/qt${QT_VERSION_MAJOR}/QtQuick"
)
#文档
ukui_qdoc_add_qch(ukui-quick-core-doc VERBOSE
NAME ukui-quick-core
DOC_NAME ukui-quick-core
VERSION ${UKUI_QUICK_VERSION}
NAMESPACE org.ukui
QCH_INSTALL_DESTINATION "/usr/share/qt${QT_VERSION_MAJOR}/doc"
SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
HEADER_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
CONFIG_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/../cmake-extend/modules/QDocConfig.qdocconf.in"
INCLUDE_DIRS ${include_dirs}
DEPEND_QCHS qtcore qtqml qtquick
STYLE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../cmake-extend/style/default.css"
)
include(CMakePackageConfigHelpers)
set(CMAKE_CONFIG_INSTALL_DIR "/usr/share/cmake/ukui-quick-core")
set(PC_INSTALL_DIR "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/ukui-quick-core-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-core-config.cmake"
INSTALL_DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-core-config-version.cmake
VERSION ${UKUI_QUICK_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/ukui-quick-core.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-core.pc"
INSTALL_DESTINATION ${PC_INSTALL_DIR})
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${UKUI_QUICK_VERSION}
SOVERSION ${VERSION_MAJOR}
OUTPUT_NAME ${ROOT_PROJECT_NAME}-${PROJECT_NAME}
)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}
PUBLIC_HEADER DESTINATION ${HEADERS_INSTALL_DIR}
LIBRARY DESTINATION /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
)
install(EXPORT ${PROJECT_NAME}
FILE ukui-quick-core-targets.cmake
NAMESPACE ${ROOT_PROJECT_NAME}::
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})
install(FILES ${HEADERS} DESTINATION ${HEADERS_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-core.pc DESTINATION ${PC_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-core-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-core-config-version.cmake
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})
ukui-quick-4.22.0.1/core/doc/ 0000775 0000000 0000000 00000000000 15210506206 0015517 5 ustar 00root root 0000000 0000000 ukui-quick-4.22.0.1/core/doc/ukui-quick-core.qdoc 0000664 0000000 0000000 00000000361 15210506206 0021404 0 ustar 00root root 0000000 0000000 /*!
\module UkuiQuickCore
\title Ukui Quick Core C++ Classes
\brief 提供Ukui Quick Core模块的C++类实现.
*/
/*!
\page ukui-quick-core.html
\title Ukui Quick Core
ukui-quick项目的通用定义和核心类
*/ ukui-quick-4.22.0.1/core/margin.cpp 0000664 0000000 0000000 00000004374 15210506206 0016743 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#include "margin.h"
/*!
\namespace UkuiQuick
\inmodule UkuiQuickCore
\keyword UkuiQuick Namespace
\brief The UkuiQuick namespace.
*/
/*!
\class UkuiQuick::Margin
\inmodule UkuiQuickCore
\inheaderfile margin.h
\brief 包含四向边距值的工具类.
*/
namespace UkuiQuick {
Margin::Margin(QObject *parent) : QObject(parent)
{
}
Margin::Margin(int l, int t, int r, int b, QObject *parent) : QObject(parent), m_left(l), m_top(t), m_right(r), m_bottom(b)
{
}
/*!
\property Margin::left
\brief 该属性控制元素的左侧边距大小
*/
int Margin::left() const
{
return m_left;
}
void Margin::setLeft(int l)
{
if (l == m_left) {
return;
}
m_left = l;
Q_EMIT leftChanged();
}
/*!
\property Margin::top
\brief 该属性控制元素的顶部边距大小
*/
int Margin::top() const
{
return m_top;
}
void Margin::setTop(int t)
{
if (t == m_top) {
return;
}
m_top = t;
Q_EMIT topChanged();
}
/*!
\property Margin::right
\brief 该属性控制元素的右侧边距大小
*/
int Margin::right() const
{
return m_right;
}
void Margin::setRight(int r)
{
if (r == m_right) {
return;
}
m_right = r;
Q_EMIT rightChanged();
}
/*!
\property Margin::bottom
\brief 该属性控制元素的底部边距大小
*/
int Margin::bottom() const
{
return m_bottom;
}
void Margin::setBottom(int b)
{
if (b == m_bottom) {
return;
}
m_bottom = b;
Q_EMIT bottomChanged();
}
} // UkuiQuick ukui-quick-4.22.0.1/core/margin.h 0000664 0000000 0000000 00000003336 15210506206 0016405 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#ifndef UKUI_QUICK_ITEMS_MARGIN_H
#define UKUI_QUICK_ITEMS_MARGIN_H
#include
namespace UkuiQuick {
class Margin : public QObject
{
Q_OBJECT
Q_PROPERTY(int left READ left WRITE setLeft NOTIFY leftChanged)
Q_PROPERTY(int top READ top WRITE setTop NOTIFY topChanged)
Q_PROPERTY(int right READ right WRITE setRight NOTIFY rightChanged)
Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomChanged)
public:
explicit Margin(QObject *parent = nullptr);
Margin(int l, int t, int r, int b, QObject *parent = nullptr);
int left() const;
void setLeft(int l);
int top() const;
void setTop(int t);
int right() const;
void setRight(int r);
int bottom() const;
void setBottom(int b);
Q_SIGNALS:
void leftChanged();
void topChanged();
void rightChanged();
void bottomChanged();
private:
int m_left {0};
int m_top {0};
int m_right {0};
int m_bottom {0};
};
} // UkuiQuick
#endif //UKUI_QUICK_ITEMS_MARGIN_H
ukui-quick-4.22.0.1/core/shared-engine-component.cpp 0000664 0000000 0000000 00000015020 15210506206 0022165 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#include "shared-engine-component.h"
#include "shared-qml-engine.h"
#include
namespace UkuiQuick {
class SharedEngineComponentPrivate
{
public:
// raw
QUrl source;
SharedEngineComponent *q {nullptr};
// env
QVariantMap initData;
QQmlComponent *component {nullptr};
QQmlContext *rootContext {nullptr};
// generate
QObject *rootObject {nullptr};
// func
explicit SharedEngineComponentPrivate(SharedEngineComponent *parent);
void printComponentError() const;
void beginCreateRootObject();
};
SharedEngineComponentPrivate::SharedEngineComponentPrivate(SharedEngineComponent *parent) : q(parent)
{
}
void SharedEngineComponentPrivate::printComponentError() const
{
const QList errorList = component->errors();
for (const QQmlError &error : errorList) {
QMessageLogger(error.url().toString().toLatin1().constData(), error.line(), nullptr).warning() << error;
}
}
void SharedEngineComponentPrivate::beginCreateRootObject()
{
delete component;
component = new QQmlComponent(SharedEngineComponent::sharedEngine(), q);
QObject::connect(component, &QQmlComponent::statusChanged, q, &SharedEngineComponent::componentStatusChanged);
component->loadUrl(source);
// rootObject = component->beginCreate(rootContext ? rootContext : SharedEngineComponent::sharedEngine()->rootContext());
rootObject = component->beginCreate(rootContext);
if (component->isReady() || component->isError()) {
q->completedCreateRootObject();
} else {
QObject::connect(component, &QQmlComponent::statusChanged, q, &SharedEngineComponent::completedCreateRootObject);
}
}
/*!
\class UkuiQuick::SharedEngineComponent
\inmodule UkuiQuickCore
\inheaderfile shared-engine-component.h
\brief 基于共享QML引擎的组件加载器.
一个Component,用于加载并实例化一个qml文件的顶级对象,该对象为 \c rootObject。
基本功能由 \l QQmlComponent 提供。所有通过 \l SharedEngineComponent 实例化的 \c object 都运行在同一个共享 \c engine 中。
每个 \c object 在创建前都需要一个上下文,如果未指定那么会从共享 \c engine 根上下文创建一个。
可以在构造 \l SharedEngineComponent 时传入初始化参数,用于初始化 \c rootObject 的属性。
\sa QQmlComponent
*/
// ====== SharedEngineComponent ====== //
/*!
\fn QQmlEngine* SharedEngineComponent::sharedEngine()
获取全局共享的QML引擎实例.
\sa SharedQmlEngine
*/
QQmlEngine *SharedEngineComponent::sharedEngine()
{
return SharedQmlEngine::sharedQmlEngine();
}
/*!
\fn SharedEngineComponent::SharedEngineComponent(QQmlContext *rootContext, QObject *parent)
\brief 构造函数, \a rootContext 为组件的QML上下文, \a parent 为父对象.
*/
SharedEngineComponent::SharedEngineComponent(QQmlContext *rootContext, QObject *parent)
: QObject(parent),
d(new SharedEngineComponentPrivate(this))
{
if (!rootContext) {
rootContext = new QQmlContext(SharedEngineComponent::sharedEngine());
}
d->rootContext = rootContext;
}
/*!
\fn SharedEngineComponent::SharedEngineComponent(const QVariantMap &initData, QQmlContext *rootContext, QObject *parent)
\brief 构造函数, \a initData 作为初始化数据, \a rootContext 作为组件的QML上下文、
*/
SharedEngineComponent::SharedEngineComponent(const QVariantMap &initData, QQmlContext *rootContext, QObject *parent)
: SharedEngineComponent(rootContext, parent)
{
d->initData = initData;
}
SharedEngineComponent::~SharedEngineComponent()
{
if (d) {
delete d;
d = nullptr;
}
}
/*!
\fn void SharedEngineComponent::setSource(const QUrl &source)
\brief 设置组件的QML文件路径, \a source QML文件路径
*/
void SharedEngineComponent::setSource(const QUrl &source)
{
if (source.isEmpty()) {
return;
}
d->source = source;
d->beginCreateRootObject();
}
/*!
\fn QUrl SharedEngineComponent::source() const
\brief 获取组件的QML文件路径.
*/
QUrl SharedEngineComponent::source() const
{
return d->source;
}
/*!
\fn QObject *SharedEngineComponent::rootObject() const
\brief 获取组件的根对象.
*/
QObject *SharedEngineComponent::rootObject() const
{
return d->rootObject;
}
/*!
\fn QQmlComponent *SharedEngineComponent::component() const
\brief 获取内部管理的QQmlComponent组件实例.
*/
QQmlComponent *SharedEngineComponent::component() const
{
return d->component;
}
/*!
\fn QQmlContext *SharedEngineComponent::rootContext() const
\brief 获取组件的QML上下文.
\sa QQmlContext
*/
QQmlContext *SharedEngineComponent::rootContext() const
{
return d->rootContext;
}
/*!
\fn QVariantMap SharedEngineComponent::initializeData() const
\brief 获取组件的初始化数据.
*/
QVariantMap SharedEngineComponent::initializeData() const
{
return d->initData;
}
void SharedEngineComponent::completedCreateRootObject()
{
if (!d->component) {
qWarning() << "SharedEngineComponent: Component is null, source:" << d->source;
return;
}
disconnect(d->component, &QQmlComponent::statusChanged, this, &SharedEngineComponent::completedCreateRootObject);
if (!d->component->isReady() || d->component->isError()) {
d->printComponentError();
return;
}
QVariantMap::const_iterator iterator = d->initData.constBegin();
for (; iterator != d->initData.constEnd() ; ++iterator) {
d->rootObject->setProperty(iterator.key().toUtf8().data(), iterator.value());
}
d->component->completeCreate();
}
/*!
\fn void SharedEngineComponent::componentStatusChanged(QQmlComponent::Status status)
\brief 此信号在组件状态发生变化时触发,\a status 为组件的新状态.
*/
} // UkuiQuick
ukui-quick-4.22.0.1/core/shared-engine-component.h 0000664 0000000 0000000 00000004627 15210506206 0021645 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#ifndef UKUI_QUICK_SHARED_ENGINE_COMPONENT_H
#define UKUI_QUICK_SHARED_ENGINE_COMPONENT_H
#include
#include
#include
#include
#include
#include
namespace UkuiQuick {
class SharedEngineComponentPrivate;
/**
* @class SharedEngineComponent
*
* 一个Component,用于加载并实例化一个qml文件的顶级对象,该对象为rootObject。
* 基本功能由QQmlComponent提供。
*
* 所有通过SharedEngineComponent实例化的object都运行在同一个共享engine中。
* 每个object在创建前都需要一个上下文,如果未指定那么会从共享engine根上下文创建一个。
* 可以在构造SharedEngineComponent时传入初始化参数,用于初始化rootObject的属性。
*
*/
class SharedEngineComponent : public QObject
{
Q_OBJECT
public:
static QQmlEngine *sharedEngine();
explicit SharedEngineComponent(QQmlContext *rootContext = nullptr, QObject *parent = nullptr);
explicit SharedEngineComponent(const QVariantMap &initData, QQmlContext *rootContext, QObject *parent = nullptr);
~SharedEngineComponent() override;
// raw materials
QUrl source() const;
void setSource(const QUrl &source);
QQmlContext *rootContext() const;
QVariantMap initializeData() const;
// products
QObject *rootObject() const;
QQmlComponent *component() const;
Q_SIGNALS:
void componentStatusChanged(QQmlComponent::Status status);
private Q_SLOTS:
void completedCreateRootObject();
private:
SharedEngineComponentPrivate *d {nullptr};
friend class SharedEngineComponentPrivate;
};
} // UkuiQuick
#endif //UKUI_QUICK_SHARED_ENGINE_COMPONENT_H
ukui-quick-4.22.0.1/core/shared-engine-view.cpp 0000664 0000000 0000000 00000021216 15210506206 0021141 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#include "shared-engine-view.h"
#include "shared-qml-engine.h"
#include
#include
namespace UkuiQuick {
class SharedEngineViewPrivate
{
public:
SharedEngineViewPrivate() = delete;
SharedEngineViewPrivate(QQmlEngine *e, SharedEngineView *q);
void createObject();
bool setRootObject(QObject *obj);
void initResizeSignal() const;
void updateSize() const;
void printComponentError() const;
// env
SharedEngineView *view {nullptr};
QQmlEngine *engine {nullptr};
QQmlContext *rootContext {nullptr};
SharedEngineView::ResizeMode resizeMode {SharedEngineView::SizeRootObjectToView};
// object item
QUrl source;
QQuickItem *rootItem {nullptr};
QQmlComponent *component {nullptr};
};
SharedEngineViewPrivate::SharedEngineViewPrivate(QQmlEngine *e, SharedEngineView *q)
: view(q), engine(e), rootContext(new QQmlContext(engine->rootContext(), q))
{
}
void SharedEngineViewPrivate::createObject()
{
if (!engine) {
qWarning() << "SharedEngineView: invalid qml engine.";
return;
}
if (rootItem) {
delete rootItem;
rootItem = nullptr;
}
if (component) {
delete component;
component = nullptr;
}
if (source.isEmpty()) {
return;
}
component = new QQmlComponent(engine, source, view);
if (component->isLoading()) {
QObject::connect(component, &QQmlComponent::statusChanged, view, &SharedEngineView::continueCreate);
} else {
view->continueCreate();
}
}
bool SharedEngineViewPrivate::setRootObject(QObject *obj)
{
if (rootItem == obj) {
return true;
}
delete rootItem;
if (!obj) {
return true;
}
if (auto item = qobject_cast(obj)) {
rootItem = item;
item->setParentItem(view->contentItem());
item->setParent(view->contentItem());
initResizeSignal();
return true;
}
if (qobject_cast(obj)) {
qWarning() << "SharedEngineView does not support using a window as a root item." << Qt::endl
<< Qt::endl
<< "If you wish to create your root window from QML, consider using QQmlApplicationEngine instead." << Qt::endl;
return false;
}
qWarning() << "SharedEngineView only supports loading of root objects that derive from QQuickItem." << Qt::endl
<< Qt::endl
<< "Ensure your QML code is written for QtQuick 2, and uses a root that is or" << Qt::endl
<< "inherits from QtQuick's Item (not a Timer, QtObject, etc)." << Qt::endl;
return false;
}
void SharedEngineViewPrivate::initResizeSignal() const
{
if (!rootItem) {
return;
}
if (resizeMode == SharedEngineView::SizeViewToRootObject) {
QObject::connect(rootItem, &QQuickItem::widthChanged, view, &SharedEngineView::updateViewSize);
QObject::connect(rootItem, &QQuickItem::heightChanged, view, &SharedEngineView::updateViewSize);
} else {
QObject::disconnect(rootItem, &QQuickItem::widthChanged, view, &SharedEngineView::updateViewSize);
QObject::disconnect(rootItem, &QQuickItem::heightChanged, view, &SharedEngineView::updateViewSize);
}
updateSize();
}
void SharedEngineViewPrivate::updateSize() const
{
if (!rootItem) {
return;
}
if (resizeMode == SharedEngineView::SizeViewToRootObject) {
QSize size;
// 最小为1x1
size.setWidth(rootItem->width() < 1 ? 1 : (int)rootItem->width());
size.setHeight(rootItem->height() < 1 ? 1 : (int)rootItem->height());
if (size.isValid() && size != view->size()) {
view->resize(size);
}
} else {
bool updateWidth = rootItem->width() != view->width();
bool updateHeight = rootItem->height() != view->height();
if (updateWidth && updateHeight) {
rootItem->setSize(view->size());
} else if (updateWidth) {
rootItem->setWidth(view->width());
} else if (updateHeight) {
rootItem->setHeight(view->height());
}
}
}
void SharedEngineViewPrivate::printComponentError() const
{
const QList errorList = component->errors();
for (const QQmlError &error : errorList) {
QMessageLogger(error.url().toString().toLatin1().constData(), error.line(), nullptr).warning() << error;
}
}
/*!
\class UkuiQuick::SharedEngineView
\inmodule UkuiQuickCore
\inheaderfile shared-engine-view.h
\brief 提供基于共享QML引擎的视图容器,用于高效加载和显示QML内容.
主要功能:
\list
\li 复用全局共享的QQmlEngine实例,减少资源消耗
\li 支持动态加载QML文件作为根内容
\li 提供灵活的尺寸调整策略(视图适应内容或内容适应视图)
\li 自动管理QML对象的生命周期
用于定义SharedEngineView的类,用于定义SharedEngineView的源文件、大小、调整模式等.
\endlist
*/
/*!
\enum SharedEngineView::ResizeMode
\brief 定义视图与内容的尺寸调整策略.
\value SizeViewToRootObject 视图尺寸适应内容尺寸
\value SizeRootObjectToView 内容尺寸适应视图尺寸
*/
// ====== SharedEngineView Begin ======//
/*!
\fn QQmlEngine *SharedEngineView::sharedEngine()
\brief 获取全局共享的QML引擎实例.
*/
QQmlEngine *SharedEngineView::sharedEngine()
{
return SharedQmlEngine::sharedQmlEngine();
}
/*!
\fn SharedEngineView::SharedEngineView(QWindow *parent)
\brief 构造函数, \a parent 父窗口
*/
SharedEngineView::SharedEngineView(QWindow *parent)
: QQuickWindow(parent), d(new SharedEngineViewPrivate(SharedEngineView::sharedEngine(), this))
{
}
/*!
\fn QQmlEngine* SharedEngineView::engine() const
\brief 获取当前视图关联的QML引擎实例。
*/
QQmlEngine *SharedEngineView::engine() const
{
return d->engine;
}
/*!
\fn QQmlContext* SharedEngineView::rootContext() const
\brief 获取QML上下文实例。
*/
QQmlContext *SharedEngineView::rootContext() const
{
return d->rootContext;
}
/*!
\fn void SharedEngineView::setSource(const QUrl &source) const
\brief 设置QML文件 \a source.
*/
void SharedEngineView::setSource(const QUrl &source) const
{
d->source = source;
d->createObject();
}
void SharedEngineView::continueCreate() const
{
QObject::disconnect(d->component, &QQmlComponent::statusChanged, this, &SharedEngineView::continueCreate);
if (d->component->isError()) {
d->printComponentError();
return;
}
// 改为beginCreate
QObject *obj = d->component->create(d->rootContext ? d->rootContext : d->engine->rootContext());
if (d->component->isError()) {
d->printComponentError();
if (obj) {
obj->deleteLater();
}
return;
}
d->setRootObject(obj);
}
/*!
\fn void SharedEngineView::setResizeMode(SharedEngineView::ResizeMode resizeMode)
\brief 设置视图与内容的尺寸调整策略 \a resizeMode.
\sa ResizeMode
*/
void SharedEngineView::setResizeMode(SharedEngineView::ResizeMode resizeMode)
{
if (d->resizeMode == resizeMode) {
return;
}
d->resizeMode = resizeMode;
if (d->rootItem) {
d->initResizeSignal();
}
}
void SharedEngineView::updateViewSize() const
{
d->updateSize();
}
void SharedEngineView::resizeEvent(QResizeEvent *event)
{
if (d->resizeMode == SizeRootObjectToView) {
d->updateSize();
}
QQuickWindow::resizeEvent(event);
}
/*!
\fn QQuickItem* SharedEngineView::rootObject() const
\brief 获取QML文件中根对象实例.
*/
QQuickItem *SharedEngineView::rootObject() const
{
return d->rootItem;
}
/*!
\fn SharedEngineView::ResizeMode SharedEngineView::resizeMode() const
\brief 获取当前视图的调整模式.
*/
SharedEngineView::ResizeMode SharedEngineView::resizeMode() const
{
return d->resizeMode;
}
} // UkuiQuick
ukui-quick-4.22.0.1/core/shared-engine-view.h 0000664 0000000 0000000 00000003402 15210506206 0020603 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#ifndef UKUI_QUICK_ITEMS_SHARED_ENGINE_VIEW_H
#define UKUI_QUICK_ITEMS_SHARED_ENGINE_VIEW_H
#include
#include
#include
namespace UkuiQuick {
class SharedEngineViewPrivate;
class SharedEngineView : public QQuickWindow
{
Q_OBJECT
friend class SharedEngineViewPrivate;
public:
enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView };
static QQmlEngine *sharedEngine();
explicit SharedEngineView(QWindow *parent = nullptr);
QQmlEngine *engine() const;
QQmlContext *rootContext() const;
QQuickItem *rootObject() const;
void setResizeMode(SharedEngineView::ResizeMode resizeMode);
SharedEngineView::ResizeMode resizeMode() const;
public Q_SLOTS:
void setSource(const QUrl &source) const;
protected:
void resizeEvent(QResizeEvent *event) override;
private Q_SLOTS:
void continueCreate() const;
void updateViewSize() const;
private:
SharedEngineViewPrivate *d {nullptr};
};
} // UkuiQuick
#endif //UKUI_QUICK_ITEMS_SHARED_ENGINE_VIEW_H
ukui-quick-4.22.0.1/core/shared-qml-engine.cpp 0000664 0000000 0000000 00000002504 15210506206 0020757 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#include "shared-qml-engine.h"
/*!
\class UkuiQuick::SharedQmlEngine
\inmodule UkuiQuickCore
\inheaderfile types.h
\brief 提供一个全局的 QQmlEngine 实例,用于在多个组件之间共享 QML 引擎.
*/
namespace UkuiQuick {
/*!
\fn QQmlEngine *SharedQmlEngine::sharedQmlEngine()
\brief 返回全局的 QQmlEngine* 实例.
用法:
\code
QQmlEngine *engine = SharedEngineComponent::sharedEngine();
\endcode
\sa QQmlEngine
*/
QQmlEngine *SharedQmlEngine::sharedQmlEngine()
{
static QQmlEngine engine;
return &engine;
}
} // UkuiQuick
ukui-quick-4.22.0.1/core/shared-qml-engine.h 0000664 0000000 0000000 00000001754 15210506206 0020432 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#ifndef UKUI_QUICK_SHARED_QML_ENGINE_H
#define UKUI_QUICK_SHARED_QML_ENGINE_H
#include
namespace UkuiQuick {
class SharedQmlEngine
{
public:
static QQmlEngine *sharedQmlEngine();
};
} // UkuiQuick
#endif //UKUI_QUICK_SHARED_QML_ENGINE_H
ukui-quick-4.22.0.1/core/types.cpp 0000664 0000000 0000000 00000004507 15210506206 0016630 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#include "types.h"
/*!
\class UkuiQuick::Types
\inmodule UkuiQuickCore
\inheaderfile types.h
\brief 提供一系列枚举类型,用于描述 UI 元素的位置、方向和类型等.
*/
/*!
\enum Types::Pos
UI 元素的位置.
\value NoPosition 无特定位置,由布局系统自动决定
\value Left 紧贴容器左侧
\value Top 紧贴容器顶部
\value Right 紧贴容器右侧
\value Bottom 紧贴容器底部
\value TopLeft 容器左上角
\value TopRight 容器右上角
\value BottomRight 容器右下角
\value BottomLeft 容器左下角
\value Center 容器正中心
\value LeftCenter 容器左侧垂直居中
\value TopCenter 容器顶部水平居中
\value RightCenter 容器右侧垂直居中
\value BottomCenter 容器底部水平居中
*/
/*!
\enum Types::Orientation
UI 元素的布局方向,影响子元素的排列方式.
\value Vertical 垂直方向
\value Horizontal 水平方向
*/
/*!
\enum Types::WidgetType
UI 元素的类型.
\value Widget 小部件
\value Container 容器
*/
/*!
\enum Types::PopupLocation
定义了 UI 弹出元素(如对话框、菜单等)在屏幕上的定位方式
\value Floating 自由浮动,不固定位置和层级
\value Desktop 平铺在桌面层,全屏延伸
\value FullScreen 全屏显示
\value TopEdge 固定在屏幕顶部边缘
\value BottomEdge 固定在屏幕底部边缘
\value LeftEdge 固定在屏幕左侧边缘
\value RightEdge 固定在屏幕右侧边缘
*/
namespace UkuiQuick {
} // global
ukui-quick-4.22.0.1/core/types.h 0000664 0000000 0000000 00000004174 15210506206 0016275 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#ifndef UKUI_QUICK_ITEMS_TYPES_H
#define UKUI_QUICK_ITEMS_TYPES_H
#include
namespace UkuiQuick {
class Types
{
Q_GADGET
public:
enum Pos {
NoPosition = 0,
Left,
Top,
Right,
Bottom,
TopLeft,
TopRight,
BottomRight,
BottomLeft,
Center,
LeftCenter,
TopCenter,
RightCenter,
BottomCenter
};
Q_ENUM(Pos)
enum Orientation {
Vertical,
Horizontal
};
Q_ENUM(Orientation)
enum WidgetType {
Widget,
Container
};
Q_ENUM(WidgetType)
/**
* The Location enumeration describes where on screen an element, such as an
* Applet or its managing container, is positioned on the screen.
**/
enum PopupLocation {
Floating = 0, /**< Free floating. Neither geometry or z-ordering
is described precisely by this value. */
Desktop, /**< On the planar desktop layer, extending across
the full screen from edge to edge */
FullScreen, /**< Full screen */
TopEdge, /**< Along the top of the screen*/
BottomEdge, /**< Along the bottom of the screen*/
LeftEdge, /**< Along the left side of the screen */
RightEdge, /**< Along the right side of the screen */
};
Q_ENUM(PopupLocation)
};
} // global
#endif //UKUI_QUICK_ITEMS_TYPES_H
ukui-quick-4.22.0.1/core/ukui-quick-core-config.cmake.in 0000664 0000000 0000000 00000000550 15210506206 0022641 0 ustar 00root root 0000000 0000000 @PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(Qt@QT_VERSION_MAJOR@Core "@REQUIRED_QT_VERSION@")
find_dependency(Qt@QT_VERSION_MAJOR@Qml @REQUIRED_QT_VERSION@)
find_dependency(Qt@QT_VERSION_MAJOR@Quick @REQUIRED_QT_VERSION@)
find_dependency(ukui-quick COMPONENTS platform)
include("${CMAKE_CURRENT_LIST_DIR}/ukui-quick-core-targets.cmake")
ukui-quick-4.22.0.1/core/ukui-quick-core.pc.in 0000664 0000000 0000000 00000000453 15210506206 0020722 0 ustar 00root root 0000000 0000000 prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/@CMAKE_LIBRARY_ARCHITECTURE@
includedir=${prefix}/include/ukui-quick/core
Name: ukui-quick-core
Description: ukui-quick-core header files
URL: https://www.ukui.org/
Version: @VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lukui-quick-core ukui-quick-4.22.0.1/framework/ 0000775 0000000 0000000 00000000000 15210506206 0016017 5 ustar 00root root 0000000 0000000 ukui-quick-4.22.0.1/framework/CMakeLists.txt 0000664 0000000 0000000 00000010314 15210506206 0020556 0 ustar 00root root 0000000 0000000 cmake_minimum_required(VERSION 3.16)
project(framework)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
# 依赖Widgets是为了使用QAction,在高版本qt中,QAction已挪到Gui模块,不需要依赖Widgets
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick Widgets REQUIRED)
set(PROJECT_SOURCES
widget/island.cpp widget/island.h
widget/widget.cpp widget/widget.h
widget/widget-loader.cpp widget/widget-loader.h
widget/widget-metadata.cpp widget/widget-metadata.h
widget/widget-content.cpp widget/widget-content.h
widget/widget-container.cpp widget/widget-container.h
widget/widget-interface.h
widget-ui/widget-item.cpp widget-ui/widget-item.h
widget-ui/widget-item-engine.cpp widget-ui/widget-item-engine.h
widget-ui/widget-item-context.cpp widget-ui/widget-item-context.h
widget-ui/widget-item-attached.cpp widget-ui/widget-item-attached.h
widget-ui/widget-container-item.cpp widget-ui/widget-container-item.h
config/config.h config/config.cpp
config/ini-config.h config/ini-config.cpp
config/config-loader.h config/config-loader.cpp
config/config-property-map.cpp config/config-property-map.h
view/island-view.cpp view/island-view.h
)
set(HEADERS
widget/island.h
widget/widget.h
widget/widget-loader.h
widget/widget-metadata.h
widget/widget-container.h
widget/widget-content.h
widget/widget-interface.h
widget-ui/widget-item.h
widget-ui/widget-container-item.h
config/config.h
config/ini-config.h
config/config-loader.h
config/config-property-map.h
view/island-view.h
)
add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCES})
add_library(${ROOT_PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
include_directories(config)
include_directories(widget)
include_directories(widget-ui)
include_directories(../core)
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Widgets
ukui-quick::core
)
include(CMakePackageConfigHelpers)
set(CMAKE_CONFIG_INSTALL_DIR "/usr/share/cmake/ukui-quick-framework")
set(HEADERS_INSTALL_DIR "/usr/include/ukui-quick/framework")
set(PC_INSTALL_DIR "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
target_include_directories(${PROJECT_NAME}
INTERFACE
$
)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/ukui-quick-framework-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-framework-config.cmake"
INSTALL_DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-framework-config-version.cmake
VERSION ${UKUI_QUICK_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/ukui-quick-framework.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-framework.pc"
INSTALL_DESTINATION ${PC_INSTALL_DIR}
)
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${UKUI_QUICK_VERSION}
SOVERSION ${VERSION_MAJOR}
OUTPUT_NAME ${ROOT_PROJECT_NAME}-${PROJECT_NAME}
)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}
PUBLIC_HEADER DESTINATION ${HEADERS_INSTALL_DIR}
LIBRARY DESTINATION /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
)
install(EXPORT ${PROJECT_NAME}
FILE ukui-quick-framework-targets.cmake
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}
NAMESPACE ${ROOT_PROJECT_NAME}::
)
install(FILES ${HEADERS} DESTINATION ${HEADERS_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-framework.pc DESTINATION ${PC_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-framework-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/ukui-quick-framework-config-version.cmake
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})
if(BUILD_TEST)
add_subdirectory(test)
endif ()
ukui-quick-4.22.0.1/framework/config/ 0000775 0000000 0000000 00000000000 15210506206 0017264 5 ustar 00root root 0000000 0000000 ukui-quick-4.22.0.1/framework/config/config-loader.cpp 0000664 0000000 0000000 00000007101 15210506206 0022500 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#include "config-loader.h"
#include
#include
#include
#include
#include
#include
/*!
\class UkuiQuick::ConfigLoader
\inheaderfile config-loader.h
\inmodule UkuiQuickFramework
\brief 配置加载器,该类用于加载配置文件.
*/
/*!
\enum ConfigLoader::Domain
\brief 配置文件域.
\value Local 本地配置文件域
\value Global 全局配置文件域
*/
/*!
\enum ConfigLoader::Type
\brief 配置文件格式.
\value Json JSON格式
\value Ini INI格式
*/
namespace UkuiQuick {
QMap> ConfigLoader::globalCache = QMap>();
/*!
\fn Config *ConfigLoader::getConfig(const QString &id, ConfigLoader::Domain domain, const QString &appid)
\brief 获取配置文件.
\a id 配置文件 \ cid ,\a domain 配置文件域 , \a appid 应用 \c id
*/
Config *ConfigLoader::getConfig(const QString &id, ConfigLoader::Domain domain, const QString &appid)
{
QString filename = getFullFileName(id, Json, domain, appid);
if (filename.isEmpty()) {
return nullptr;
}
const QString cacheKey = (domain == Local) ? (appid + QStringLiteral("_") + id) : id;
auto &cache = ConfigLoader::globalCache[domain];
if (cache.contains(cacheKey)) {
return cache.value(cacheKey);
}
auto config = new Config(filename);
cache.insert(cacheKey, config);
return config;
}
/*!
\brief 获取配置文件的完整路径.
\a id 配置文件 \c id, \a type 配置文件格式, \a domain 配置文件域, \a appid 应用 \c id
*/
QString ConfigLoader::getFullFileName(const QString &id, Type type, Domain domain, const QString &appid)
{
const QString filename = ConfigLoader::getConfigFileName(id, type);
if (filename.isEmpty()) {
return {};
}
if (domain == Global) {
return ConfigLoader::globalConfigPath() + filename;
}
if (appid.isEmpty()) {
return {};
}
return ConfigLoader::localConfigPath() + appid + QStringLiteral("/") + filename;
}
/*!
\brief 获取全局配置文件的完整路径.
*/
QString ConfigLoader::globalConfigPath()
{
return QDir::homePath() + QStringLiteral("/.config/org.ukui/_ukui-config-global/");
}
/*!
\brief 获取本地配置文件的完整路径.
*/
QString ConfigLoader::localConfigPath()
{
return QDir::homePath() + QStringLiteral("/.config/org.ukui/");
}
/*!
\brief 获取配置文件的文件名.
\a id 配置文件 \c id, \a type 配置文件格式
*/
QString ConfigLoader::getConfigFileName(const QString &id, ConfigLoader::Type type)
{
if (id.isEmpty()) {
return {};
}
if (type == Json) {
return id + QStringLiteral(".json");
}
return id + QStringLiteral(".conf");
}
} // UkuiQuick
ukui-quick-4.22.0.1/framework/config/config-loader.h 0000664 0000000 0000000 00000004035 15210506206 0022150 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#ifndef UKUI_QUICK_CONFIG_LOADER_H
#define UKUI_QUICK_CONFIG_LOADER_H
#include
#include "config.h"
namespace UkuiQuick {
/**
* 获取从文件系统加载配置文件
* 此处负责处理文件的加载路径
* 根据Domain进行映射:domain {
* Local: ~/.config/org.ukui/appid/id.json
* Global: ~/.config/org.ukui/_ukui-config-global/id.json
* }
*/
class ConfigLoader
{
public:
enum Domain {
Local = 0,
Global
};
enum Type {
Json = 0,
Ini
};
/**
* 加载配置文件
* @param id 配置文件ID,对应id.json
* @param app 应用名称
* @param domain {
* Local: ~/.config/org.ukui/appid/id.json
* Global: ~/.config/org.ukui/_ukui-config-global/id.json
* }
* @return config
*/
static Config *getConfig(const QString &id, Domain domain = Global, const QString &appid = QString());
static QString getFullFileName(const QString &id, Type type = Json, Domain domain = Global, const QString &appid = QString());
static QString globalConfigPath();
static QString localConfigPath();
static QString getConfigFileName(const QString &id, Type type = Json);
private:
static QMap> globalCache;
};
} // UkuiQuick
#endif //UKUI_QUICK_CONFIG_LOADER_H
ukui-quick-4.22.0.1/framework/config/config-property-map.cpp 0000664 0000000 0000000 00000004225 15210506206 0023675 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: baijunjie
*
*/
#include "config-property-map.h"
#include
#include
using namespace UkuiQuick;
class UkuiQuick::ConfigPropertyMapPrivate
{
public:
explicit ConfigPropertyMapPrivate(ConfigPropertyMap *map) : q(map) {};
void loadConfig() const;
ConfigPropertyMap *q;
QPointer config;
};
void ConfigPropertyMapPrivate::loadConfig() const
{
if (!config) {
return;
}
for (const auto& key : config->keys()) {
q->insert(key, config->getValue(key));
}
}
/*!
\class UkuiQuick::ConfigPropertyMap
\inmodule UkuiQuickFramework
\inheaderfile config-property-map.h
\brief 提供配置属性映射功能,用于将配置数据与QML属性进行绑定.
*/
ConfigPropertyMap::ConfigPropertyMap(Config *config, QObject *parent) : QQmlPropertyMap(this, parent), d(new ConfigPropertyMapPrivate(this))
{
Q_ASSERT(config);
d->config = config;
d->loadConfig();
connect(d->config, &Config::configChanged, this, [this](const QString& key) {
insert(key, d->config->getValue(key));
});
connect(this, &ConfigPropertyMap::valueChanged, this, [this] (const QString &key, const QVariant &value) {
d->config->setValue(key, value);
});
}
QVariant ConfigPropertyMap::updateValue(const QString &key, const QVariant &input)
{
d->config->setValue(key, input);
d->config->forceSync();
return input;
}
#include "moc_config-property-map.cpp"
ukui-quick-4.22.0.1/framework/config/config-property-map.h 0000664 0000000 0000000 00000002425 15210506206 0023342 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: baijunjie
*
*/
#ifndef UKUI_QUICK_CONFIGPROPERTYMAP_H
#define UKUI_QUICK_CONFIGPROPERTYMAP_H
#include
#include
#include "config.h"
namespace UkuiQuick {
class ConfigPropertyMapPrivate;
class ConfigPropertyMap : public QQmlPropertyMap
{
Q_OBJECT
public:
explicit ConfigPropertyMap(Config* config, QObject *parent = nullptr);
protected:
QVariant updateValue(const QString &key, const QVariant &input) override;
private:
std::unique_ptr const d;
};
}
#endif //UKUI_QUICK_CONFIGPROPERTYMAP_H
ukui-quick-4.22.0.1/framework/config/config.cpp 0000664 0000000 0000000 00000031771 15210506206 0021246 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#include "config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
//#include
namespace UkuiQuick {
ConfigIFace::ConfigIFace(QObject *parent) : QObject(parent)
{
}
// ====== ConfigPrivate ====== //
class ConfigPrivate
{
public:
explicit ConfigPrivate(QString file);
explicit ConfigPrivate(QVariantMap d, Config *p);
void loadConfigFile();
void save();
static QFileInfo getFileInfo(const QString &filename);
QJsonObject toJsonObject();
static Config *findConfig(const ConfigList &configList, const QString &key, const QVariant &value);
// 配置文件全路径
QString configFile;
QString configLockFile;
bool requestUpdate {false};
// 所属组
QString group;
// 当前配置的ID值
QVariant id;
// 当前节点的分组信息
ConfigGroupInfo groupInfo;
// 配置数据核心
QVariantMap data;
// 全部子节点
QHash children;
// 父节点,如果是来自于父配置的话
Config *parentConfig {nullptr};
private:
friend class Config;
};
ConfigPrivate::ConfigPrivate(QString file)
: configFile(std::move(file)), configLockFile(file + QStringLiteral(".lock")), id(QStringLiteral("_root"))
{
loadConfigFile();
}
ConfigPrivate::ConfigPrivate(QVariantMap d, Config *p)
: data(std::move(d)), parentConfig(p)
{
}
QFileInfo ConfigPrivate::getFileInfo(const QString &filename)
{
QFileInfo fileInfo(filename);
QDir dir = fileInfo.dir();
if (!dir.exists()) {
bool mpb = dir.mkpath(fileInfo.path());
qDebug() << "Config: mkPath:" << fileInfo.path() << mpb;
}
return fileInfo;
}
void ConfigPrivate::loadConfigFile()
{
QByteArray jsonData("{}");
QFileInfo fileInfo = ConfigPrivate::getFileInfo(configFile);
if (!fileInfo.exists()) {
QFile file(fileInfo.absoluteFilePath());
if (file.open(QFile::ReadWrite | QFile::Text)) {
file.write(jsonData);
file.flush();
file.close();
}
qDebug() << "Config: File does not exist, initializing to default values:" << jsonData << fileInfo.fileName();
return;
}
if (!fileInfo.isReadable()) {
qWarning() << "Config: Permission denied to read file:" << configFile;
return;
}
QFile file(fileInfo.absoluteFilePath());
if (file.open(QFile::ReadOnly)) {
jsonData = file.readAll();
file.close();
}
QJsonParseError parseError {};
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonData, &parseError);
if (jsonDocument.isNull()) {
qWarning() << "Config: Failed to parse JSON:" << parseError.errorString() << configFile;
return;
}
if (!jsonDocument.isObject()) {
qWarning() << "Config: Configuration file format error." << configFile;
return;
}
data = jsonDocument.object().toVariantMap();
}
void ConfigPrivate::save()
{
if (configFile.isEmpty()) {
return;
}
// 1.读取文件信息,是否只读
QFileInfo fileInfo = getFileInfo(configFile);
if (!fileInfo.isWritable()) {
qWarning() << "Config: No permission to write to the file:" << fileInfo.fileName();
return;
}
// 2.获取lockfile信息
QLockFile lockFile(configLockFile);
if (!lockFile.lock()) {
return;
}
QJsonDocument jsonDocument(toJsonObject());
if (jsonDocument.isObject()) {
QFile file(fileInfo.absoluteFilePath());
if (file.open(QFile::ReadWrite | QFile::Truncate | QFile::Text)) {
qint64 writeLength = file.write(jsonDocument.toJson());
if (writeLength == -1) {
qWarning() << "Config::save: File write failure," << file.errorString() << configFile;
} else {
qDebug() << "Config::save: File write succeed," << writeLength;
file.flush();
}
file.close();
} else {
qWarning() << "Config::save: File open failed," << file.errorString() << configFile;
}
} else {
qWarning() << "Config::save: Failed to parse JSON";
}
lockFile.unlock();
}
QJsonObject ConfigPrivate::toJsonObject()
{
if (children.isEmpty()) {
return QJsonObject::fromVariantMap(data);
}
QJsonObject tempObj = QJsonObject::fromVariantMap(data);
QHashIterator iterator(children);
while (iterator.hasNext()) {
iterator.next();
QJsonArray jsonArray;
for (const auto &config : iterator.value()) {
jsonArray.append(config->d->toJsonObject());
}
tempObj.insert(iterator.key(), jsonArray);
}
return tempObj;
}
Config *ConfigPrivate::findConfig(const ConfigList& configList, const QString &key, const QVariant &value)
{
auto it = std::find_if(configList.constBegin(), configList.constEnd(), [&key, &value] (const Config *config) {
return config->getValue(key) == value;
});
if (it == configList.constEnd()) {
return nullptr;
}
return *it;
}
/*!
\class UkuiQuick::Config
\inheaderfile config.h
\inmodule UkuiQuickFramework
\brief 配置类,该类用于加载配置文件内容.
一个配置文件节点,如果从文件或者一个Map生成,那么就是一个根节点。
如果由父配置构造,那么就是一个子节点,并且有一个指向父节点的指针。
构造方式:
\list
\li 1.从文件加载
\li 2.从VariantMap加载
\li 3.从父节点获取
\endlist
*/
/*!
\typedef ConfigGroupInfo
\relates QString
同 QHash
*/
/*!
\typedef ConfigList
\relates Config
同 QList
*/
// ====== Config ====== //
/*!
\brief 从文件加载配置.
\a file 配置文件路径
*/
Config::Config(const QString &file, QObject *parent)
: ConfigIFace(parent), d(new ConfigPrivate(file))
{
}
/*!
\brief 从VariantMap加载配置.
\a data 配置数据
*/
Config::Config(const QVariantMap &data, QObject *parent)
: ConfigIFace(parent), d(new ConfigPrivate(data, nullptr))
{
}
Config::Config(const QVariantMap &data, Config *parent)
: ConfigIFace(parent), d(new ConfigPrivate(data, parent))
{
}
Config::~Config()
{
if (d) {
delete d;
d = nullptr;
}
}
/*!
\brief 提取所有子节点配置
根据当前配置的groupInfo信息,遍历所有分组并提取对应的子节点配置。
每个分组会调用extractGroup方法处理具体的子节点提取逻辑。
\note 如果groupInfo为空则直接返回,不做任何处理
*/
void Config::extractChildren()
{
if (d->groupInfo.isEmpty()) {
return;
}
QHashIterator iterator(d->groupInfo);
while (iterator.hasNext()) {
iterator.next();
extractGroup(iterator.key(), iterator.value());
}
}
/*!
\brief 提取指定分组配置
*/
void Config::extractGroup(const QString &group, const QString &key)
{
if (d->data.contains(group)) {
auto &value = d->data[group];
QJsonArray jsonArray = value.toJsonArray();
for (const auto &jsonObjectRef : jsonArray) {
if (!jsonObjectRef.isObject()) {
continue;
}
QVariantMap data = jsonObjectRef.toObject().toVariantMap();
addChild(group, data);
}
// 清空生成子Config的节点
value = QVariantList();
}
}
/*!
\brief 返回当前配置ID值
*/
const QVariant &Config::id() const
{
return d->id;
}
/*!
\brief 返回当前配置分组
*/
const QString &Config::group() const
{
return d->group;
}
void Config::setId(const QVariant &id)
{
if (d->id == id) {
return;
}
d->id = id;
}
void Config::setGroup(const QString &group)
{
if (d->group == group) {
return;
}
d->group = group;
}
/*!
\brief 返回配置分组信息
*/
const ConfigGroupInfo &Config::groupInfo() const
{
return d->groupInfo;
}
//void Config::setGroupInfo(const ConfigGroupInfo &groupInfo)
//{
// if (d->groupInfo.isEmpty() && d->children.isEmpty()) {
// d->groupInfo = groupInfo;
// // 将子组存放到children中
// extractChildren();
// }
//}
/*!
\brief 添加分组信息
*/
void Config::addGroupInfo(const QString &group, const QString &key)
{
if (key.isEmpty() || d->groupInfo.contains(group)) {
return;
}
d->groupInfo.insert(group, key);
extractGroup(group, key);
}
/*!
\brief 返回指定分组的子节点列表
*/
ConfigList Config::children(const QString &group) const
{
if (d->children.contains(group)) {
return d->children[group];
}
return {};
}
/*!
\brief 返回指定分组的子节点数量
*/
int Config::numberOfChildren(const QString &group) const
{
if (d->children.contains(group)) {
return static_cast(d->children[group].count());
}
return 0;
}
Config *Config::child(const QString &group, const QVariant &id) const
{
if (!d->children.contains(group)) {
return nullptr;
}
const auto key = d->groupInfo.value(group);
const ConfigList &children = d->children[group];
return ConfigPrivate::findConfig(children, key, id);
}
/*!
\brief 返回配置是否为根节点
*/
bool Config::isRoot() const
{
return d->parentConfig == nullptr;
}
/*!
\brief 返回配置是否为空
*/
bool Config::isNull() const
{
return d->data.isEmpty();
}
/*!
\brief 强制同步配置数据
*/
void Config::forceSync()
{
requestUpdate();
}
/*!
\brief 返回所有键值列表
*/
QStringList Config::keys() const
{
return d->data.keys();
}
/*!
\brief 返回配置数据
*/
const QVariantMap &Config::data() const
{
return d->data;
}
/*!
\brief 根据指定键值返回配置值
*/
QVariant Config::getValue(const QString &key) const
{
return d->data.value(key);
}
/*!
\brief 设置指定键的值
*/
void Config::setValue(const QString &key, const QVariant &value)
{
if (d->groupInfo.contains(key)) {
return;
}
d->data.insert(key, value);
Q_EMIT configChanged(key);
requestUpdate();
}
/*!
\brief 添加子节点配置.
\a group 分组名称,\a childData 子节点数据
*/
void Config::addChild(const QString &group, const QVariantMap &childData)
{
const QString key = d->groupInfo.value(group);
if (key.isEmpty() || !childData.contains(key)) {
return;
}
const auto id = childData.value(key);
if (id.isNull()) {
return;
}
auto &children = d->children[group];
auto config = ConfigPrivate::findConfig(children, key, id);
if (config) {
return;
}
// create childData
config = new Config(childData, this);
config->setGroup(group);
config->setId(id);
children.append(config);
requestUpdate();
Q_EMIT childAdded(group, id);
}
/*!
\brief 删除指定分组的子节点配置
\a group 分组名称,\a id 子节点ID
*/
void Config::removeChild(const QString &group, const QVariant &id)
{
if (!d->children.contains(group)) {
return;
}
auto &children = d->children[group];
const auto config = ConfigPrivate::findConfig(children, d->groupInfo[group], id);
if (!config) {
return;
}
children.removeOne(config);
requestUpdate();
Q_EMIT childRemoved(group, id);
}
/*!
\brief 删除指定键值的配置
*/
void Config::removeKey(const QString& key)
{
d->data.remove(key);
requestUpdate();
}
bool Config::event(QEvent *event)
{
if (event->type() == QEvent::UpdateRequest) {
d->save();
d->requestUpdate = false;
}
return QObject::event(event);
}
void Config::requestUpdate()
{
if (d->parentConfig) {
d->parentConfig->requestUpdate();
return;
}
// do sync
if (!d->requestUpdate) {
d->requestUpdate = true;
auto ev = new QEvent(QEvent::UpdateRequest);
QCoreApplication::postEvent(this, ev);
}
}
/*!
\brief 配置是否包含指定键值
*/
bool Config::contains(const QString &key) const
{
return d->data.contains(key);
}
} // UkuiQuick
ukui-quick-4.22.0.1/framework/config/config.h 0000664 0000000 0000000 00000011022 15210506206 0020676 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#ifndef UKUI_QUICK_CONFIG_H
#define UKUI_QUICK_CONFIG_H
#include
#include
#include
#include
#include
namespace UkuiQuick {
class ConfigIFace : public QObject
{
Q_OBJECT
public:
explicit ConfigIFace(QObject *parent = nullptr);
Q_INVOKABLE virtual QStringList keys() const = 0;
Q_INVOKABLE virtual QVariant getValue(const QString &key) const = 0;
Q_INVOKABLE virtual void setValue(const QString &key, const QVariant &value) = 0;
/**
* 从数据源同步数据或写入数据
*/
Q_INVOKABLE virtual void forceSync() = 0;
Q_SIGNALS:
void configChanged(const QString &key);
};
class Config;
/**
* 一个组必须是一个数组,数组中的对象顺序不限
* 第一个String是组的名称
* 第二个String是组内对象的主键名称,唯一标识一个对象
*/
typedef QHash ConfigGroupInfo;
typedef QList ConfigList;
/**
* 一个配置文件节点。
* 如果从文件或者一个Map生成,那么就是一个根节点。
* 如果由父配置构造,那么就是一个子节点,并且有一个指向父节点的指针。
*
* 构造方式:
* 1.从文件加载
* 2.从VariantMap加载
* 3.从父节点获取
*
*/
class ConfigPrivate;
class Config : public ConfigIFace
{
Q_OBJECT
public:
/**
* 从文件加载数据
* @param file 一个json文件
* @param groupInfo 分组信息
* @param parent 父对象
*/
explicit Config(const QString &file, QObject *parent = nullptr);
/**
* 从VariantMap加载数据
* @param data 数据
* @param groupInfo 分组信息
* @param parent 父节点
*/
explicit Config(const QVariantMap &data, QObject *parent = nullptr);
~Config() override;
// Apis
const QVariantMap &data() const;
bool contains(const QString &key) const;
QStringList keys() const override;
QVariant getValue(const QString &key) const override;
void setValue(const QString &key, const QVariant &value) override;
void forceSync() override;
bool isRoot() const;
bool isNull() const;
const QVariant &id() const;
const QString &group() const;
const ConfigGroupInfo &groupInfo() const;
// void setGroupInfo(const ConfigGroupInfo &groupInfo);
void addGroupInfo(const QString &group, const QString &key);
// TODO: remove group
// void removeGroupInfo(const QString &group);
ConfigList children(const QString &group) const;
int numberOfChildren(const QString &group) const;
Config *child(const QString &group, const QVariant &id) const;
/**
* 添加子节点
* @param group 组名
* @param childData 数据
*/
void addChild(const QString &group, const QVariantMap &childData);
/**
* 删除一个子节点
* @param group 组名
* @param id 主键值
*/
void removeChild(const QString &group, const QVariant &id);
/**
* 删除一个key
* @param key 要删除的键
*/
void removeKey(const QString &key);
Q_SIGNALS:
void childAdded(const QString &group, const QVariant &id);
void childRemoved(const QString &group, const QVariant &id);
public:
bool event(QEvent *event) override;
private:
/**
* 从父节点继承数据
* 作为私有构造函数,由内部函数调用
* @param data 数据
* @param groupInfo 分组信息
* @param parent 父节点
*/
explicit Config(const QVariantMap &data, Config *parent = nullptr);
void extractChildren();
void extractGroup(const QString &group, const QString &key);
void setId(const QVariant &id);
void setGroup(const QString &group);
void requestUpdate();
private:
ConfigPrivate *d {nullptr};
friend class ConfigPrivate;
};
} // UkuiQuick
#endif //UKUI_QUICK_CONFIG_H
ukui-quick-4.22.0.1/framework/config/ini-config.cpp 0000664 0000000 0000000 00000004451 15210506206 0022016 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#include "ini-config.h"
#include
#include
namespace UkuiQuick {
class IniConfigPrivate
{
public:
explicit IniConfigPrivate(const QString &file, IniConfig *q);
QSettings *settings {nullptr};
};
IniConfigPrivate::IniConfigPrivate(const QString &file, IniConfig *q)
{
settings = new QSettings(file, QSettings::IniFormat, q);
}
// ===== IniConfig ===== //
/*!
\class UkuiQuick::IniConfig
\inmodule UkuiQuickFramework
\inheaderfile ini-config.h
\brief 基于 INI 格式文件的配置实现.
*/
IniConfig::IniConfig(const QString &filename, QObject *parent) : ConfigIFace(parent), d(new IniConfigPrivate(filename, this))
{
}
/*!
\brief 根据 \a key 获取指定键的值.
*/
QVariant IniConfig::getValue(const QString &key) const
{
if (d->settings) {
return d->settings->value(key);
}
return {};
}
/*!
\brief 设置指定键 \a key 的值 \a value.
*/
void IniConfig::setValue(const QString &key, const QVariant &value)
{
if (d->settings) {
d->settings->setValue(key, value);
Q_EMIT configChanged(key);
}
}
/*!
\brief 调用该函数会立即将内存中的配置同步到文件中.
*/
void IniConfig::forceSync()
{
if (d->settings) {
d->settings->sync();
}
}
/*!
\brief 获取内部的 \c QSettings 对象.
*/
QSettings *IniConfig::settings() const
{
return d->settings;
}
/*!
\brief 获取所有配置键名.
*/
QStringList IniConfig::keys() const
{
if (d->settings) {
return d->settings->allKeys();
}
return {};
}
} // UkuiQuick
ukui-quick-4.22.0.1/framework/config/ini-config.h 0000664 0000000 0000000 00000002526 15210506206 0021464 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#ifndef UKUI_QUICK_INI_CONFIG_H
#define UKUI_QUICK_INI_CONFIG_H
#include "config.h"
class QSettings;
namespace UkuiQuick {
class IniConfigPrivate;
class IniConfig : public ConfigIFace
{
Q_OBJECT
public:
explicit IniConfig(const QString &filename, QObject *parent = nullptr);
QStringList keys() const override;
QVariant getValue(const QString &key) const override;
void setValue(const QString &key, const QVariant &value) override;
void forceSync() override;
QSettings *settings() const;
private:
IniConfigPrivate *d {nullptr};
};
} // UkuiQuick
#endif //UKUI_QUICK_INI_CONFIG_H
ukui-quick-4.22.0.1/framework/doc/ 0000775 0000000 0000000 00000000000 15210506206 0016564 5 ustar 00root root 0000000 0000000 ukui-quick-4.22.0.1/framework/doc/images/ 0000775 0000000 0000000 00000000000 15210506206 0020031 5 ustar 00root root 0000000 0000000 ukui-quick-4.22.0.1/framework/doc/images/framework.png 0000664 0000000 0000000 00000234163 15210506206 0022545 0 ustar 00root root 0000000 0000000 PNG
IHDR \ cHRM z&