pax_global_header 0000666 0000000 0000000 00000000064 15205774371 0014525 g ustar 00root root 0000000 0000000 52 comment=ddbce3daa48d0b278a9c5db40da51ea979ebd738
kylin-aiassistant-3.0.0.0/ 0000775 0000000 0000000 00000000000 15205774371 0015332 5 ustar 00root root 0000000 0000000 kylin-aiassistant-3.0.0.0/.gitignore 0000664 0000000 0000000 00000000164 15205774371 0017323 0 ustar 00root root 0000000 0000000 *.o
moc_*
.qmake.*
qrc_*
translations/*.qm
Makefile.*
Makefile
kylin-aiassistant.pro.user
debian/files
.vscode
*.so
kylin-aiassistant-3.0.0.0/COPYING 0000664 0000000 0000000 00000104515 15205774371 0016373 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
.
kylin-aiassistant-3.0.0.0/common.json 0000664 0000000 0000000 00000000033 15205774371 0017511 0 ustar 00root root 0000000 0000000 {
"version": "3.2.2"
}
kylin-aiassistant-3.0.0.0/common.pri 0000664 0000000 0000000 00000000064 15205774371 0017336 0 ustar 00root root 0000000 0000000 INCLUDEPATH += $$PWD
DISTFILES += $$PWD/common.json
kylin-aiassistant-3.0.0.0/kylin-aiassistant.pro 0000664 0000000 0000000 00000000143 15205774371 0021521 0 ustar 00root root 0000000 0000000 TEMPLATE = subdirs
SUBDIRS += \
kylin-aiassistant \
# peony-menu-plugin-kylin-aiassistant
kylin-aiassistant-3.0.0.0/kylin-aiassistant/ 0000775 0000000 0000000 00000000000 15205774371 0021001 5 ustar 00root root 0000000 0000000 kylin-aiassistant-3.0.0.0/kylin-aiassistant/README.md 0000664 0000000 0000000 00000002450 15205774371 0022261 0 ustar 00root root 0000000 0000000 # kylin-assistant
#### 介绍
{**以下是 Gitee 平台说明,您可以替换此简介**
Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
kylin-aiassistant-3.0.0.0/kylin-aiassistant/aiservicedialog.cpp 0000664 0000000 0000000 00000007054 15205774371 0024645 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#include "aiservicedialog.h"
#include
#include
#include
#include
#include
#include
AiServiceDialog::AiServiceDialog(QWidget *parent) : QDialog(parent)
{
initLayout();
initConnect();
}
AiServiceDialog::~AiServiceDialog()
{
}
void AiServiceDialog::initLayout()
{
this->setWindowTitle(QString(" "));
this->setFixedSize(452, 182);
this->setStyleSheet("QDialog { background-color: white; }");
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(24, 10, 24, 24);
mainLayout->setSpacing(8);
QHBoxLayout *TitleLayout = new QHBoxLayout(this);
QHBoxLayout *contentLayout = new QHBoxLayout(this);
contentLayout->setContentsMargins(20, 0, 0, 0);
iconLabel = new QLabel(this);
iconLabel->setPixmap(QPixmap(":/icon/icon/hint.svg").scaled(16, 16));
iconLabel->setContentsMargins(28, 12, 0, 144);
titleLabel = new QLabel(tr("AI service unavailable"));
titleLabel->setFixedSize(380, 20);
TitleLayout->addWidget(iconLabel);
TitleLayout->addWidget(titleLabel);
mainLayout->addLayout(TitleLayout);
detailLabel = new QLabel(tr("The AI subsystem is not detected. The AI service of the application cannot be used. Please go to System Settings > AI Module Management page to install it."));
detailLabel->setWordWrap(true);
detailLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
contentLayout->addWidget(detailLabel);
mainLayout->addLayout(contentLayout);
QHBoxLayout *buttonLayout = new QHBoxLayout(this);
cancelButton = new QPushButton(tr("Cancel"));
cancelButton->setAccessibleName("kylin-aiassistant_QQPushButton_cancelButton");
cancelButton->setFixedSize(94, 36);
goButton = new QPushButton(tr("go now"));
goButton->setAccessibleName("kylin-aiassistant_QPushButton_okButton");
goButton->setProperty("isImportant", true);
goButton->setDefault(true);
buttonLayout->addStretch();
buttonLayout->addWidget(cancelButton);
buttonLayout->addWidget(goButton);
mainLayout->addStretch();
mainLayout->addLayout(buttonLayout);
}
void AiServiceDialog::initConnect()
{
connect(cancelButton, &QPushButton::clicked, this, &AiServiceDialog::reject);
connect(goButton, &QPushButton::clicked, this, &AiServiceDialog::openUkuiControlCenter);
}
void AiServiceDialog::openUkuiControlCenter()
{
QProcess process;
QString command = "ukui-control-center";
QStringList arguments;
arguments << "-m" << "aisubsystem";
process.startDetached(command, arguments);
process.waitForFinished(-1);
// 检查进程是否正常退出
if (process.exitStatus() == QProcess::NormalExit) {
KyInfo() << "ukui-control-center successfully!";
} else {
KyInfo() << "Failed to open ukui-control-center";
}
this->close();
}
kylin-aiassistant-3.0.0.0/kylin-aiassistant/aiservicedialog.h 0000664 0000000 0000000 00000002321 15205774371 0024302 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#ifndef AISERVICEDIALOG_H
#define AISERVICEDIALOG_H
#include
#include
#include
class AiServiceDialog : public QDialog
{
Q_OBJECT
public:
explicit AiServiceDialog(QWidget *parent = nullptr);
~AiServiceDialog();
private:
void initLayout();
void initConnect();
void openUkuiControlCenter();
private:
QPushButton *cancelButton;
QPushButton *goButton;
QLabel *iconLabel;
QLabel *titleLabel;
QLabel *detailLabel;
signals:
};
#endif // AISERVICEDIALOG_H
kylin-aiassistant-3.0.0.0/kylin-aiassistant/chatdatabase.cpp 0000775 0000000 0000000 00000022410 15205774371 0024113 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#include "chatdatabase.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define CREATE_TABLE_RECORD_SQL "CREATE TABLE IF NOT EXISTS RECORD(ID INT AUTO_INCREMENT, sessionID VARCHAR(36), msgIndex INT, message TEXT, operateTime INTEGER,PRIMARY KEY (ID))"
#define CREATE_TABLE_HISTORY_ID_SQL "CREATE TABLE IF NOT EXISTS HISTORY_ID(ID INT AUTO_INCREMENT, history_id INT, PRIMARY KEY (ID))"
#define INSERT_HISTORY_ID_SQL "INSERT INTO HISTORY_ID(ID, history_id) VALUES (1, 0)"
static ChatDatabase *g_chatDatabase = nullptr;
class ChatDatabase::Private
{
public:
bool is_open;
QSqlDatabase base;
};
ChatDatabase::ChatDatabase():
d(std::make_shared())
{
initBase();
createTable();
}
ChatDatabase::~ChatDatabase()
{
if (d->is_open)
d->base.close();
}
bool ChatDatabase::insertOne(QString sessionID, int index, QString message)
{
if (!d->is_open)
return false;
QSqlQuery query(d->base);
QString str = ("INSERT INTO RECORD(sessionID, msgIndex, message, operateTime) VALUES (?, ?, ?, ?)");
// 获取当前时间戳
qint64 timestamp = QDateTime::currentDateTime().toSecsSinceEpoch();
query.prepare(str);
query.addBindValue(sessionID);
query.addBindValue(index);
query.addBindValue(message);
query.addBindValue(timestamp);
bool flag = query.exec();
if(!flag){
KyInfo() << "Error: insert record error";
return false;
}
return true;
}
bool ChatDatabase::updateOperateTime(QString sessionID, int index)
{
if (!d->is_open)
return false;
QSqlQuery query(d->base);
QString str = ("UPDATE RECORD SET operateTime = ? WHERE sessionID = ? and msgIndex = ?");
// 获取当前时间戳
qint64 timestamp = QDateTime::currentDateTime().toSecsSinceEpoch();
query.prepare(str);
query.addBindValue(timestamp);
query.addBindValue(sessionID);
query.addBindValue(0);
bool flag = query.exec();
if(!flag){
KyInfo() << "Error: UPDATE record operateTime error";
return false;
}
return true;
}
bool ChatDatabase::deleteBySessionID(QString sessionID)
{
if (!d->is_open)
return false;
QSqlQuery query(d->base);
QString str = ("DELETE FROM RECORD WHERE sessionID = ?");
query.prepare(str);
query.addBindValue(sessionID);
bool flag = query.exec();
if(!flag){
KyInfo() << "Error: delete record error";
return false;
}
return true;
}
bool ChatDatabase::updateFeedback(QString sessionID, int index, QString message)
{
if (!d->is_open)
return false;
QSqlQuery query(d->base);
QString str = ("UPDATE RECORD SET message = ? WHERE sessionID = ? and msgIndex = ?");
query.prepare(str);
query.addBindValue(message);
query.addBindValue(sessionID);
query.addBindValue(index);
bool flag = query.exec();
if(!flag){
KyInfo() << "Error: UPDATE record message error";
return false;
}
return true;
}
QStringList ChatDatabase::selectBySessionID(QString sessionID)
{
if (!d->is_open)
return {};
QStringList result;
QSqlQuery query(d->base);
QString str = ("SELECT message FROM RECORD WHERE sessionID = ?");
query.prepare(str);
query.addBindValue(sessionID);
bool flag = query.exec();
if(!flag){
KyInfo() << "Error: select record error";
return {};
}
while(query.next()){
QString str = query.value(0).toString();
result.append(str);
}
return result;
}
QStringList ChatDatabase::selectAll()
{
if (!d->is_open)
return {};
QStringList result;
QSqlQuery query(d->base);
bool flag = query.exec(QString("SELECT message FROM RECORD"));
if(!flag){
KyInfo() << "Error: select record error";
return {};
}
while(query.next()){
QString str = query.value(0).toString();
result.append(str);
}
return result;
}
QStringList ChatDatabase::selectAllDialogue()
{
if (!d->is_open)
return {};
QSqlQuery query(d->base);
QStringList dialogueList;
QSet addedSessions;
// 查询所有记录,准备遍历
bool flag = query.exec(QString("SELECT sessionID, msgIndex, message, operateTime FROM RECORD where msgIndex = 0 ORDER BY operateTime desc"));
if (!flag) {
KyInfo() << "Error: select record error";
return {};
}
// 遍历每一项,检查 msgIndex 是否为 0,且 sessionID 是否已添加
while (query.next()) {
QString sessionID = query.value("sessionID").toString();
int msgIndex = query.value("msgIndex").toInt();
QString messageJson = query.value("message").toString();
//KyInfo() << "sessionID==" << sessionID << "msgIndex===" << msgIndex << "messageJson===" <is_open)
return 0;
QStringList result;
QSqlQuery query(d->base);
QString str = ("SELECT history_id FROM HISTORY_ID WHERE id = 1");
query.prepare(str);
bool flag = query.exec();
if(!flag){
KyInfo() << "Error: select selectMaxHistoryId error";
return {};
}
int history_id = 0;
if(query.next()){
history_id = query.value(0).toInt();
}
return history_id;
}
void ChatDatabase::updateMaxHistoryId(int history_id)
{
KyInfo() << "UPDATE HISTORY_ID ==" << history_id;
if (!d->is_open)
return;
QSqlQuery query(d->base);
QString str = ("UPDATE HISTORY_ID SET history_id = ? WHERE ID = 1");
query.prepare(str);
query.addBindValue(history_id);
bool flag = query.exec();
if(!flag){
KyInfo() << "Error: UPDATE HISTORY_ID error";
}
}
ChatDatabase *ChatDatabase::getChatDatabase()
{
if (g_chatDatabase== nullptr) {
g_chatDatabase = new ChatDatabase;
}
return g_chatDatabase;
}
void ChatDatabase::initBase()
{
d->base = QSqlDatabase::addDatabase("QSQLITE");
QString config_path = QDir::homePath().append("/.config/kylin-aiassistant");
if (!QDir().exists(config_path))
QDir().mkdir(config_path);
d->base.setDatabaseName(config_path.append("/kylin_aiassistant_database.db"));
if(!d->base.open())
KyInfo() << "Error: open database failed!";
d->is_open = d->base.isOpen();
}
void ChatDatabase::createTable()
{
if(!d->is_open){
KyInfo() << "Error: open database failed!";
}
QSqlQuery sql_query(d->base);
if (!sql_query.exec(CREATE_TABLE_RECORD_SQL))
{
KyInfo() << "create table record error";
}
if (!sql_query.exec(CREATE_TABLE_HISTORY_ID_SQL))
{
KyInfo() << "create table HISTORY_ID error";
}else{
if (!sql_query.exec(INSERT_HISTORY_ID_SQL)){
KyInfo() << "insert HISTORY_ID error";
}
}
}
kylin-aiassistant-3.0.0.0/kylin-aiassistant/chatdatabase.h 0000775 0000000 0000000 00000002747 15205774371 0023573 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#ifndef CHATDATABASE_H
#define CHATDATABASE_H
#include
#include
#include
class ChatDatabase
{
public:
ChatDatabase();
~ChatDatabase();
bool insertOne(QString sessionID, int index, QString message);
bool updateOperateTime(QString sessionID, int index);
bool deleteBySessionID(QString sessionID);
bool updateFeedback(QString sessionID, int index, QString message);
QStringList selectBySessionID(QString sessionID);
QStringList selectAll();
QStringList selectAllDialogue();
int selectMaxHistoryId();
void updateMaxHistoryId(int history_id);
static ChatDatabase* getChatDatabase();
private:
void initBase();
void createTable();
private:
class Private;
std::shared_ptr d;
};
#endif // CHATDATABASE_H
kylin-aiassistant-3.0.0.0/kylin-aiassistant/cmainwnd.cpp 0000775 0000000 0000000 00000141335 15205774371 0023317 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#include "cmainwnd.h"
#include
#include
#include
#include
#include
CMainWnd::CMainWnd(QWidget *parent)
: KWidget(parent)
{
disconnect(this->windowButtonBar(), &KWindowButtonBar::doubleClick, 0, 0);
disconnect(this->iconBar(), &KIconBar::doubleClick, 0, 0);
connect(kdk::WindowManager::self(), &kdk::WindowManager::windowAdded, this, [=](const kdk::WindowId &window_id) {
if(getpid() == kdk::WindowManager::getPid(window_id) && m_window_id == 0)
{
m_window_id = window_id.toULongLong();
}
});
#ifdef UKUI_WINDOWHELPER_SUPPORT
m_ukuiWindowHelper = new UkuiWindowHelper(this);
m_ukuiWindowHelper->removeTitleBar();
initTopping(); // 初始化置顶
#else
connect(kdk::WindowManager::self(), &kdk::WindowManager::windowAdded, this, [=](const kdk::WindowId &window_id) {
if(getpid() == kdk::WindowManager::getPid(window_id) && m_window_id == 0)
{
m_window_id = window_id.toULongLong();
// 旧版窗管接口依赖kdk::WindowManager::windowAdded信号响应之后拿到窗口id
initTopping(); // 初始化置顶
}
});
kdk::UkuiStyleHelper::self()->removeHeader(this);
#endif
createAllChildWnd();
initGlobalSetting();
initCtrl();
initTrayIcon();
initTrayIconMenu();
initSolts();
initLayout();
initScribeWords();
initScribeWordsSetting();
initPosition();
initShortcut();
checkTheme();
initTimer();
initTopping(); // 初始化置顶
//设置窗口标题
this->setWindowTitle(tr("kylin-aiassistant"));
this->setWindowIcon(QIcon(":/icon/icon/AI-Writing.svg"));
}
CMainWnd::~CMainWnd()
{
}
void CMainWnd::createAllChildWnd()
{
#define NEW_OBJECT(pObj, TYPE) \
if(NULL == pObj) \
{ \
pObj = new TYPE(this); \
}
NEW_OBJECT(m_leftBtnWidget, QWidget);
m_leftBtnWidget->setAccessibleName("kylin-aiassistant_QWidget_m_leftBtnWidget");
NEW_OBJECT(m_btnSideBar, CPushButtonEx);
m_btnSideBar->setAccessibleName("kylin-aiassistant_CPushButtonEx_m_btnSideBar");
NEW_OBJECT(m_btnBack, QPushButton);
m_btnBack->setAccessibleName("kylin-aiassistant_QPushButton_m_btnBack");
NEW_OBJECT(m_btnStick, QPushButton);
m_btnStick->setAccessibleName("kylin-aiassistant_QPushButton_m_btnStick");
connect(m_btnStick, &QPushButton::clicked, this, &CMainWnd::slotToTop);
m_msgPane = new CMsgPane();
NEW_OBJECT(m_dbusOperator, KADBusOperator);
//不继承父窗口的属性
m_settingPage = new SettingDialog(this);
// fix bug #301003 【需求33947】【AI助手】设置窗口支持拖拽调整大小,双击后窗口最大化
// 问题描述:由于sdk KWidget嵌套KWidget的实现机制问题,直接通过构造函数setFixedSize会失效
// 解决方案:为避免此问题,采用规避方案:1. 不在构造函数中调用setFixedSize,改为在对象创建后设置固定大小 2. 在构造函数中首先调用resize,否则获取宽高时会出现问题
m_settingPage->setFixedSize(744, 460);
m_settingPage->setAccessibleName("kylin-aiassistant_SettingDialog_m_settingPage");
SettingDialog::sharedInstance = m_settingPage;
NEW_OBJECT(m_mainQml, QQuickWidget);
NEW_OBJECT(m_introductionView, IntroductionView);
return;
}
void CMainWnd::initCtrl()
{
//禁止父窗口样式影响子控件样式
setAttribute(Qt::WA_StyledBackground);
//设置主窗体颜色,修改this->palette可能会导致其他问题,bug #I9QUZV
QPalette pale;
pale.setColor(QPalette::Base, QColor("#F5F5F5"));
this->setPalette(pale);
//焦点不在窗口上时鼠标悬浮可显示tooltips
this->setAttribute(Qt::WA_AlwaysShowToolTips);
// 按照设计稿设计,窗口按钮大小为 32x32
m_btnSideBar->setFixedSize(32, 32);
m_btnSideBar->setIcon(QIcon(QString(":/icon/icon/window.svg")));
m_btnSideBar->setIconSize(QSize(16, 16));
m_btnSideBar->setProperty("isWindowButton", 0x1);
m_btnSideBar->setProperty("useIconHighlightEffect", 0x2);
m_btnSideBar->setProperty("windowMode", WINDOW_MODE_NORMAL);
m_btnSideBar->setFlat(true);
m_btnSideBar->setToolTip(tr("sidebar"));
m_btnBack->setFixedSize(32, 32);
m_btnBack->setIcon(QIcon(QString(":/icon/icon/back.svg")));
m_btnBack->setIconSize(QSize(16, 16));
m_btnBack->setProperty("isWindowButton", 0x1);
m_btnBack->setProperty("useIconHighlightEffect", 0x2);
m_btnBack->setProperty("windowMode", WINDOW_MODE_NORMAL);
m_btnBack->setFlat(true);
m_btnBack->setVisible(false);
m_btnBack->setToolTip(tr("Back to homepage"));
QHBoxLayout *leftBtnLayout = new QHBoxLayout;
leftBtnLayout->setContentsMargins(6, 0, 0, 0);
leftBtnLayout->addWidget(m_btnSideBar);
leftBtnLayout->addWidget(m_btnBack);
leftBtnLayout->setSpacing(0);
leftBtnLayout->addSpacerItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Minimum));
m_leftBtnWidget->setFixedSize(70, 32);
m_leftBtnWidget->setLayout(leftBtnLayout);
// 按照设计稿设计,置顶按钮大小为 32x32
m_btnStick->setFixedSize(32, 32);
m_btnStick->setProperty("isWindowButton", 0x1);
m_btnStick->setProperty("useIconHighlightEffect", 0x2);
m_btnStick->setFlat(true);
m_btnStick->setIcon(QIcon::fromTheme("ukui-fixed-symbolic"));
m_btnStick->setToolTip(tr("fixed"));
m_btnStick->setFocusPolicy(Qt::NoFocus);
m_btnStick->setVisible(true);
// 固定按钮先隐藏,后续小窗口会用到这个按钮。
//标题栏菜单
QMenu *menuConfig = new QMenu(this);
menuConfig->setAccessibleName("kylin-aiassistant-QMenu_menuConfig");
windowButtonBar()->menuButton()->setMenu(menuConfig);
QActionGroup * actGroup = new QActionGroup(this);
actGroup->setExclusive(true);
int winMode = g_configManager->getConfigValue("win-mode").toInt();
//视图模式
QMenu * viewMode = new QMenu;
viewMode->setAccessibleName("kylin-aiassistant-QMenu_viewMode");
viewMode->menuAction()->setText(tr("ViewModel"));
QAction * sidebarMode = new QAction(tr("SidebarMode"), this);
sidebarMode->setCheckable(true);
if(winMode == WINDOW_MODE_SIDEMODE){
sidebarMode->setChecked(true);
}
actGroup->addAction(sidebarMode);
connect(sidebarMode, &QAction::triggered, this, &CMainWnd::switchToSideMode);
QAction * wndMode = new QAction(tr("WindowMode"), this);
wndMode->setCheckable(true);
if(winMode == WINDOW_MODE_WINDOWMODE){
wndMode->setChecked(true);
}
actGroup->addAction(wndMode);
connect(wndMode, &QAction::triggered, this, &CMainWnd::switchToWindowMode);
viewMode->addActions(actGroup->actions());
//根据主题版本判断是否开启大窗口模式切换入口
menuConfig->addMenu(viewMode);
//设置
confAction = new QAction(tr("Setting"), this);
menuConfig->addAction(confAction);
//帮助
QAction * helpAct = new QAction(tr("Help"), this);
//2412 产品要求隐藏帮助按钮
menuConfig->addAction(helpAct);
connect(helpAct, &QAction::triggered, this, &CMainWnd::onShowHelp);
QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_F1), this);
connect(shortcut, &QShortcut::activated, this, &CMainWnd::onShowHelp);
//关于
QAction * aboutAct = new QAction(tr("About"), this);
menuConfig->addAction(aboutAct);
connect(aboutAct, &QAction::triggered, this, &CMainWnd::onShowAbout);
//退出
QAction *act_exit = new QAction(tr("Exit"), this);
menuConfig->addAction(act_exit);
connect(act_exit, &QAction::triggered, this, &CMainWnd::onExitActionTriggled);
// qml主页面
m_mainQml->rootContext()->setContextProperty("msgPane",m_msgPane);
m_mainQml->rootContext()->setContextProperty("commandTemplateListModel", CommandTemplateList::originalCommandListModel);
m_mainQml->setSource(QUrl(QStringLiteral("qrc:/qml/qml/main.qml")));
// 监听全局焦点变化
connect(qApp, &QApplication::focusChanged, this, &CMainWnd::onFocusChanged);
}
void CMainWnd::initSolts()
{
connect(confAction, SIGNAL(triggered()), this, SLOT(onConfActionTriggered()));
connect(m_dbusOperator, &KADBusOperator::sigSetup, [this] {
onConfActionTriggered();
});
connect(m_msgPane, &CMsgPane::sigSetup, [this] {
onConfActionTriggered();
});
connect(m_btnSideBar, &QPushButton::clicked, this, &CMainWnd::onSideBarBtnClicked);
connect(m_btnBack, &QPushButton::clicked, this, &CMainWnd::onBackBtnClicked);
connect(m_msgPane,&CMsgPane::showPage,this,&CMainWnd::onPageChanged);
connect(m_msgPane, &CMsgPane::sigLoadMyMessageBox, this, &CMainWnd::onShowCustomMessageBox);
// 当聊天界面保存了历史会话到文件,则需要通知历史会话界面更新。
// connect(m_msgPane, SIGNAL(sigSaveDialog(QString)), m_sideBar, SLOT(onSaveDialog(QString)));
// 点击插件的时候需要加载对应插件的历史会话界面。
// connect(m_sideBar, SIGNAL(sigPluginItemClicked(QString)), m_msgPane, SLOT(loadPlugin(QString)));
connect(this, &CMainWnd::sigThemeChanged, m_settingPage, &SettingDialog::onThemeChanged);
connect(m_msgPane,&CMsgPane::showSettingPage,this,&CMainWnd::onConfActionTriggered);
connect(m_introductionView,&IntroductionView::showSettingPage,this,&CMainWnd::onConfActionTriggered);
connect(m_introductionView,&IntroductionView::openUKUIControlCenterView,m_msgPane,&CMsgPane::openUkuiControlCenter);
// 连接信号与槽
connect(m_msgPane, &CMsgPane::activateMainWindowSignal, this, &CMainWnd::onActivateMainWindow);
connect(m_msgPane, &CMsgPane::sigSaveAs, this, &CMainWnd::onSaveAs);
connect(m_msgPane, &CMsgPane::sigOpenFile, this, &CMainWnd::onOpenFile);
}
void CMainWnd::initLayout()
{
QHBoxLayout *layoutRMain = new QHBoxLayout(baseBar());
layoutRMain->addWidget(m_mainQml);
layoutRMain->setSpacing(0);
layoutRMain->setContentsMargins(0, 0, 0, 0);
KWindowButtonBar *button_bar = windowButtonBar();
button_bar->minimumButton()->hide();
button_bar->maximumButton()->hide();
((QHBoxLayout *)button_bar->layout())->insertWidget(0, m_leftBtnWidget);
// ((QHBoxLayout *)button_bar->layout())->insertWidget(0, m_btnBack);
// ((QHBoxLayout *)button_bar->layout())->insertWidget(1, m_btnSideBar);
((QHBoxLayout *)button_bar->layout())->insertWidget(1, m_btnStick);
KIconBar *iconbar = iconBar();
iconbar->setFixedWidth(200);
iconbar->setIcon(QIcon(":/icon/icon/AI-Writing.svg"));
iconbar->setWidgetName(tr("kylin-aiassistant"));
iconbar->setStyleSheet("background-color: white;"); // 用palette不生效
iconbar->setVisible(false);
//窗口模式存在抖动现象,后续解决
m_mainQml->setResizeMode(QQuickWidget::ResizeMode::SizeRootObjectToView);
int winMode = g_configManager->getConfigValue("win-mode").toInt();
if(winMode == 2){
switchToSideMode();
}else if (winMode == 3){
switchToWindowMode();
}else{
switchToSideMode();
}
//关于窗口初始化
appVersion = getAiAssistantVersion();
aboutWindow = new kdk::KAboutDialog(this,
QIcon(":/icon/icon/AI-Writing.svg"),
tr(appShowingName.toLocal8Bit()),
tr("Version: ") + appVersion /*APP_VERSION*/
);
aboutWindow->setAccessibleName("kylin-aiassistant_kdk::KAboutDialog_aboutWindow");
aboutWindow->setBodyText(tr("kylin-aiassistant is a tool to help users..."));
aboutWindow->setBodyTextVisiable(false);
}
void CMainWnd::switchToSideMode()
{
Q_EMIT m_msgPane->changeWinModeToChat(2);
m_isMouseDragMove = false; //恢复窗口不触发移动记住位置
m_msgPane->m_windowMode = WINDOW_MODE_SIDEMODE;
g_configManager->updateConfig("win-mode", WINDOW_MODE_SIDEMODE);
// slotToTopChangeWinMode();
//根据主题版本去判断是否启用该接口
if(isSupportWindowMode){
this->topLevelWidget()->setProperty("useStyleWindowManager", false);
}
iconBar()->setVisible(false);
// m_btnStick->setVisible(false);
m_btnSideBar->setVisible(true);
QRect screenRect = QGuiApplication::primaryScreen()->availableGeometry();
setFixedSize(402, screenRect.height());
//根据活跃模块内容切换到对应显示界面
ActiveModule module = m_msgPane->getCurrentActiveModule();
if(ActiveModule::MODULE_PLUGIN == module)
{
Q_EMIT m_msgPane->showPage(2);
}
else if(ActiveModule::MODULE_CHAT == module)
{
Q_EMIT m_msgPane->showPage(0);
}
//通过信号实现控制前端页面大小
//Q_EMIT m_msgPane->showPage(0);
Q_EMIT m_msgPane->changeToSideMode(402, screenRect.height() - windowButtonBar()->height());
//移动窗口到可用位置的最右侧
// setGeometry(screenRect.right() - 402, screenRect.top(), 402, screenRect.height());
KyInfo() << "=======setGeometry====availableGeometry.right" << screenRect.right() << "availableGeometry.top" << screenRect.top() << "availableGeometry.height" << screenRect.height();
this->setGeometry(QRect(screenRect.right() - 402, screenRect.top(), 402, screenRect.height()));
WindowManager::setGeometry(this->windowHandle(),QRect(screenRect.right() - 402, screenRect.top(), 402, screenRect.height()));
}
void CMainWnd::switchToWindowMode()
{
Q_EMIT m_msgPane->changeWinModeToChat(3);
m_isMouseDragMove = false; //恢复窗口不触发移动记住位置
m_msgPane->m_windowMode = WINDOW_MODE_WINDOWMODE;
g_configManager->updateConfig("win-mode", WINDOW_MODE_WINDOWMODE);
// slotToTopChangeWinMode();
//根据主题版本去判断是否启用该接口
if(isSupportWindowMode){
this->topLevelWidget()->setProperty("useStyleWindowManager", true);
}
iconBar()->setVisible(true);
// m_btnStick->setVisible(true);
m_btnSideBar->setVisible(false);
m_btnBack->setVisible(false);
QRect screenRect = QGuiApplication::primaryScreen()->availableGeometry();
setMinimumSize(768, 568);
setMaximumSize(16777215, 16777215);
int length = g_configManager->getConfigValue("window-mode-length").toInt();
int wide = g_configManager->getConfigValue("window-mode-wide").toInt();
resize(length, wide);
//根据活跃模块内容并进行对应的显示
ActiveModule module = m_msgPane->getCurrentActiveModule();
if(ActiveModule::MODULE_PLUGIN == module)
{
Q_EMIT m_msgPane->showPage(4);
}
else if(ActiveModule::MODULE_CHAT == module)
{
Q_EMIT m_msgPane->showPage(4);
}
Q_EMIT m_msgPane->changeToWinMode(568 - windowButtonBar()->height());
//窗口在屏幕居中
// setGeometry((screenRect.width() - this->width()) / 2 , (screenRect.height() - this->height()) / 2, this->width(), this->height());
int x = g_configManager->getConfigValue("window-mode-x").toInt();
int y = g_configManager->getConfigValue("window-mode-y").toInt();
if(x < 0){
WindowManager::setGeometry(this->windowHandle(),QRect((screenRect.width() - this->width()) / 2 , (screenRect.height() - this->height()) / 2, this->width(), this->height()));
}else{
WindowManager::setGeometry(this->windowHandle(),QRect(x , y, this->width(), this->height()));
}
}
void CMainWnd::initTrayIcon()
{
// 系统托盘
m_trayIcon = new QSystemTrayIcon(this);
m_trayIcon->setObjectName("kylin-aiassistant_QSystemTrayIcon_m_trayIcon");
m_trayIcon->setToolTip(QString(tr("AI Assistant")));
m_trayIcon->setIcon(QIcon(":/icon/icon/AI-Writing.svg"));
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &CMainWnd::onTrayIconActivated);
m_trayIcon->show();
}
void CMainWnd::initTrayIconMenu()
{
m_trayIconMenu = new QMenu();
m_trayIconMenu->setAccessibleName("kylin-aiassistant_QMenu_m_trayIconMenu");
QAction * quitAction = new QAction(tr("Quit"));
connect(quitAction, &QAction::triggered, [&](){
exit(0);
});
m_trayIconMenu->addAction(quitAction);
m_trayIcon->setContextMenu(m_trayIconMenu);
}
void CMainWnd::initScribeWords()
{
m_selectwid = new SelectWidget;
m_selectwid->setAccessibleName("kylin-aiassistant_SelectWidget_m_selectwid");
#ifdef UKUI_WINDOWHELPER_SUPPORT
UkuiWindowHelper *ukuiWindowHelper = new UkuiWindowHelper(this);
ukuiWindowHelper->removeTitleBar();
#else
kdk::UkuiStyleHelper::self()->removeHeader(this);
#endif
m_selectclip = new Clipboard;
m_selectclip->setObjectName("kylin-aiassistant_Clipboard_m_selectclip");
selectTimer = new QTimer;
selectTimer->setInterval(30);
connect(selectTimer,&QTimer::timeout,this,&CMainWnd::onStartSendSelectMsg,Qt::UniqueConnection);
connect(m_msgPane, &CMsgPane::copyToClipboard, m_selectclip, &Clipboard::setText);
connect(m_msgPane, &CMsgPane::copyToClipboard, [=](){
TipWidget::showTip(tr("Copy Successful"), 3000, QSize(120, 48), this, TipWidget::OK);
});
connect(m_msgPane, &CMsgPane::copyImageToClipboard, [=](){
TipWidget::showTip(tr("Copy Successful"), 3000, QSize(120, 48), this, TipWidget::OK);
});
connect(m_msgPane, &CMsgPane::copySuccess, [=](){
TipWidget::showTip(tr("Copy Successful"), 3000, QSize(120, 48), this, TipWidget::OK);
});
connect(m_msgPane, &CMsgPane::tipsContinueDialog, [=](){
TipWidget::showTip(tr("Dialogue is being generated, please try again later"), 3000, QSize(120, 48), this, TipWidget::WARNING);
});
connect(m_msgPane, &CMsgPane::sigLikeAction, [=](){
TipWidget::showTip(tr("Thanks for your feedback"), 3000, QSize(120, 48), this, TipWidget::OK);
});
connect(m_selectwid, &SelectWidget::sigbuttontext, this, &CMainWnd::handleClicpText);
connect(m_selectwid, &SelectWidget::signalSendClicpText, this, &CMainWnd::handleClicpText);
connect(m_selectwid, &SelectWidget::sigHomePageShow, this, [=]() {
showView();
m_selectwid->hide();
});
connect(m_selectwid, &SelectWidget::sigSettingShow, this, [=]() {
onConfActionTriggered();
m_selectwid->hide();
});
connect(m_selectwid, &SelectWidget::sigDisableScribe, this, [=]() {
KTrackData *node = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK);
kdk_dia_upload_default(node, "send_disable_scribe_words_click_event", "scribeWordsPage");
kdk_dia_data_free(node);
//关闭划词界面
m_selectwid->hide();
g_configManager->updateConfig("is-stroke-word", false);
//设置界面关闭划词按钮
if(m_settingPage)
{
m_settingPage->scribeWordsDisabled();
}
});
}
void CMainWnd::initScribeWordsSetting()
{
// 点击是否禁用划词按钮
connect(m_settingPage, &SettingDialog::sigEnableScribeWords, this,[=]{
g_configManager->updateConfig("is-stroke-word", true);
});
connect(m_settingPage, &SettingDialog::sigDisableScribeWords, this, [=]() {
KTrackData *node = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK);
kdk_dia_upload_default(node, "send_setting_disable_scribe_words_button_click_event", "scribeWordsPage");
kdk_dia_data_free(node);
m_selectwid->hide();
g_configManager->updateConfig("is-stroke-word", false);
});
}
void CMainWnd::handleClicpText()
{
QString buttonText = m_selectwid->getButtonText();
QString clipText = m_selectclip->getClipText();
int promptId = m_selectwid->getCurrentId();
if(clipText != "")
{
bool isEnd = m_msgPane->getIsEnd();
if(!isEnd) //如果回答未结束则打断回答并启动计时器查询是否结束
{
m_msgPane->onStopReply();
selectTimer->start();
}
else
{
QJsonObject jsonObjToWeb;
jsonObjToWeb["msgHead"] = buttonText;
jsonObjToWeb["promptId"] = promptId;
QJsonDocument aiJsonSendWebDoc(jsonObjToWeb);
QString jsonMsgHeadToWeb = aiJsonSendWebDoc.toJson(QJsonDocument::Indented);
m_msgPane->onStartReplyingToChat();// 划词更新前端isReplying状态为true
m_msgPane->onSendMsg(jsonMsgHeadToWeb, clipText);
Q_EMIT m_msgPane->moveScrollBar();
}
}
showView();
int curWinMode = m_msgPane->getCurWinMode();
if(curWinMode == 2)
{
m_msgPane->showPage(1);
}
else if (curWinMode == 3)
{
m_msgPane->showPage(4);
}
Q_EMIT m_msgPane->moveScrollBar();
m_selectwid->hide();
}
void CMainWnd::onStartSendSelectMsg()
{
QString buttonText = m_selectwid->getButtonText();
QString clipText = m_selectclip->getClipText();
int promptId = m_selectwid->getCurrentId();
bool currentEnd = m_msgPane->getIsEnd();
if(currentEnd)
{
QJsonObject jsonObjToWeb;
jsonObjToWeb["msgHead"] = buttonText;
jsonObjToWeb["promptId"] = promptId;
QJsonDocument aiJsonSendWebDoc(jsonObjToWeb);
QString jsonMsgHeadToWeb = aiJsonSendWebDoc.toJson(QJsonDocument::Indented);
m_msgPane->onStartReplyingToChat();// 划词更新前端isReplying状态为true
m_msgPane->onSendMsg(jsonMsgHeadToWeb, clipText);
Q_EMIT m_msgPane->moveScrollBar();
selectTimer->stop();
}
showView();
int curWinMode = m_msgPane->getCurWinMode();
if(curWinMode == 2)
{
m_msgPane->showPage(1);
}
else if (curWinMode == 3)
{
m_msgPane->showPage(4);
}
Q_EMIT m_msgPane->moveScrollBar();
m_selectwid->hide();
}
void CMainWnd::onShotCutActionTriggled() { }
void CMainWnd::onAboutActionTriggled() { }
void CMainWnd::onExitActionTriggled()
{
// QCoreApplication::quit();
close();
}
void CMainWnd::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
KyInfo() << "QSystemTrayIcon::ActivationReason" << reason;
KyInfo() << "isHidden:" << this->isHidden()
<< "isMinimized" << this->isMinimized()
<< "isVisible" << this->isVisible();
if (reason == QSystemTrayIcon::DoubleClick || reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::MiddleClick) {
KTrackData *node = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK);
kdk_dia_upload_default(node, "system_tray_icon_click_event", "systemTrayIcon");
kdk_dia_data_free(node);
if (this->isMinimized() == false && this->isVisible() == true) {
// 可见但不是最小化
hideView();
} else {
showView();
}
}
}
void CMainWnd::onAppRestarted(const QString &message)
{
if (message == "selected") {
if(!this->isVisible()){
showView();
}
onShowScribeWord();
} else if (message == "running") {
showOrHideWindow();
} else {//当做文件路径处理
QUrl url(message);
m_msgPane->onShowDocument(url.path());
}
}
void CMainWnd::closeEvent(QCloseEvent *e)
{
e->ignore();
hide();
}
void CMainWnd::resizeEvent(QResizeEvent *event)
{
// 重写 resizeEvent 方法以监听窗口大小变化
QWidget::resizeEvent(event); // 调用基类方法
// 在这里记录新的大小值
// 例如,保存到成员变量或文件中
int winMode = g_configManager->getConfigValue("win-mode").toInt();
if(winMode == 3){
resizeTimer->stop();
resizeTimer->start(100); // 设置一个短暂的延迟,比如100毫秒
}
}
void CMainWnd::moveEvent(QMoveEvent *event)
{
//QWidget::moveEvent(event); // 调用基类方法
int winMode = g_configManager->getConfigValue("win-mode").toInt();
if(winMode == 3 || winMode == 2){
//KyInfo() << "=================qqqqq";
moveTimer->stop();
moveTimer->start(100); // 设置一个短暂的延迟,比如100毫秒
//event->accept();
KWidget::moveEvent(event);
}
}
void CMainWnd::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
// 处理回车键的事件
//KyInfo() << "Enter key pressed!";
m_msgPane->keyReturnPressed();
}
// 调用基类的 keyPressEvent(),以便处理其他按键事件
KWidget::keyPressEvent(event);
}
bool CMainWnd::eventFilter(QObject *obj, QEvent *event) {
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent = static_cast(event);
if (mouseEvent->button() == Qt::LeftButton) {
m_msgPane->sendFocusChanged();
}
}
return QWidget::eventFilter(obj, event);
}
void CMainWnd::showView()
{
// 设置跳过多任务视图
//kdk::WindowManager::setSkipSwitcher(this->windowHandle(), true);
// 设置跳过任务栏
//kdk::WindowManager::setSkipTaskBar(this->windowHandle(), true);
kdk::WindowManager::activateWindow(m_window_id);
KWindowSystem::activateWindow(this->windowHandle());
KyInfo() << "force Active Window";
this->show();
this->raise();
this->activateWindow();
if(m_settingPage != nullptr && isSettingOpen == true)
{
showSettingPage();
}
// 置顶模式
if(m_isTop)
QTimer::singleShot(500, [this] {
kdk::WindowManager::keepWindowAbove(m_window_id);
});
KyInfo() << "showView end";
}
void CMainWnd::hideView()
{
if((m_settingPage != nullptr && isSettingOpen == true) || isMsgBoxOpen || (aboutWindow != nullptr && aboutWindow->isVisible()))
{
return;
}
hide();
}
void CMainWnd::onFocusChanged(QWidget *oldWidget, QWidget *newWidget) {
// 如果新窗口为空,说明 QWidget 失去焦点
if (!newWidget) {
m_msgPane->sendFocusChanged();
}
}
void CMainWnd::slotToTop()
{
kdk::WindowManager::keepWindowAbove(m_window_id);
m_isTop = !kdk::WindowManager::getwindowInfo(m_window_id).isKeepAbove();
if(m_isTop){
g_configManager->updateConfig("is-window-mode-topping", true);
}else{
g_configManager->updateConfig("is-window-mode-topping", false);
}
m_btnStick->setIcon(QIcon::fromTheme(m_isTop ? "ukui-unfixed-symbolic" : "ukui-fixed-symbolic"));
m_btnStick->setToolTip(m_isTop ? tr("unfixed") : tr("fixed"));
}
void CMainWnd::slotToTopChangeWinMode()
{
int curWinMode = m_msgPane->getCurWinMode();
if(curWinMode == 2)
{
bool isTopping = g_configManager->getConfigValue("is-window-mode-topping").toBool();
if(m_isTop){
kdk::WindowManager::keepWindowAbove(m_window_id);
}
}
else if (curWinMode == 3){ // 窗口模式
bool isTopping = g_configManager->getConfigValue("is-window-mode-topping").toBool();
if(isTopping){
kdk::WindowManager::keepWindowAbove(m_window_id);
m_isTop = !kdk::WindowManager::getwindowInfo(m_window_id).isKeepAbove();
}
}
m_btnStick->setIcon(QIcon::fromTheme(m_isTop ? "ukui-unfixed-symbolic" : "ukui-fixed-symbolic"));
m_btnStick->setToolTip(m_isTop ? tr("unfixed") : tr("fixed"));
}
void CMainWnd::onSideBarBtnClicked()
{
ActiveModule activateModule = m_msgPane->getCurrentActiveModule();
if (activateModule == ActiveModule::MODULE_PLUGIN) {
// 当前在侧边栏
if (m_previousModule == ActiveModule::MODULE_CHAT) {
// KyInfo() << "返回助手主页";
Q_EMIT m_msgPane->showPage(1);
} else {
}
} else {
Q_EMIT m_msgPane->cancelVoiceStopReplying();//停止语音更新状态
Q_EMIT m_msgPane->cancelSendAudio();//停止语音恢复UI
// 切换到侧边栏
m_previousModule = activateModule;
Q_EMIT m_msgPane->showPage(2);
}
return;
}
void CMainWnd::onBackBtnClicked()
{
m_msgPane->onBackBtnClicked();
}
void CMainWnd::onPageChanged(const int pageNumber)
{
//在主页和侧边栏时无需显示返回按钮
if(pageNumber == 0 || pageNumber ==1 || pageNumber == 2 || pageNumber ==4)
{
m_btnBack->setVisible(false);
}
//在非侧边栏界面需要显示侧边栏按钮
if(pageNumber == 0 || pageNumber == 1 ||pageNumber ==3)
{
m_btnSideBar->setVisible(true);
}
PageType newPage;
//侧边栏模式控制前端显示页面 0显示全部 1显示主页面 2显示侧边栏 4窗口模式下显示主界面
switch (pageNumber) {
case 0:
newPage = PageType::MAIN_PAGE_SIDEBAR_MODE;
m_btnBack->setVisible(false);
break;
case 1:
newPage = PageType::MAIN_PAGE_SIDEBAR_MODE;
m_btnBack->setVisible(false);
break;
case 2:
newPage = PageType::SHOW_SIDEBAR;
pageNumber == 2;
break;
case 4:
newPage = PageType::MAIN_PAGE_WINDOW_MODE;
m_btnBack->setVisible(false);
break;
default:
newPage = PageType::MAIN_PAGE_SIDEBAR_MODE;
m_btnBack->setVisible(false);
break;
}
g_currentPage = newPage; // 更新全局页面状态
}
void CMainWnd::onShowCustomMessageBox(const QVariantList &strings) {
//KyInfo() << "删除确认弹窗打开";
CustomMessageBox msgBox(this);
msgBox.setMessage(tr("After deleting the conversation, it cannot be restored. Do you want to continue deleting?"));
msgBox.setButtons(CustomMessageBox::OkButton | CustomMessageBox::CancelButton);
//窗口居中
msgBox.move(this->x() + (this->width() - msgBox.width()) / 2 , this->y() + (this->height() - msgBox.height()) / 2);
KyInfo() << "*********** msgBox : " <deleteSessionList(strings);
}
isMsgBoxOpen = false;
} else {
//KyInfo() << "cancelClick";
m_msgPane->modifyDialogueList(strings);
isMsgBoxOpen = false;
}
}
void CMainWnd::onConfActionTriggered()
{
showSettingPage();
m_settingPage->resetIndex();
isSettingOpen = true;
}
void CMainWnd::onCreateDialog()
{
// 先保存当前会话
m_msgPane->saveDialog();
// 然后清除当前会话
m_msgPane->clearDialog();
// 隐藏历史会话界面
// m_sideBar->hide();
return;
}
void CMainWnd::showOrHideWindow()
{
if(isVisible()){
if(m_introductionView->isVisible()){
m_introductionView->hideView();
}
hideView();
}else
{
showView();
if(!m_introductionView->isClosed()){
m_introductionView->showView();
}
}
}
void CMainWnd::onShowHelp()
{
kdk::UserManual aiAssistantUserManual;
if (!aiAssistantUserManual.callUserManual("kylin-aiassistant")) {
qCritical() << "user manual call fail!";
}
return;
}
void CMainWnd::onShowAbout()
{
aboutWindow->exec();
return;
}
// 用于记录窗口大小改变后的值
void CMainWnd::onResizeEnd()
{
int finalWidth = width();
int finalHeight = height();
//KyInfo() << "Final window size:" << finalWidth << "x" << finalHeight;
g_configManager->updateConfig("window-mode-length", finalWidth);
g_configManager->updateConfig("window-mode-wide", finalHeight);
// g_gsettings->set("window-mode-length", 902);
// g_gsettings->set("window-mode-wide", 568);
}
// 用于记录窗口位置改变后的值
void CMainWnd::onMoveEnd()
{
int finalX = pos().x();
int finalY = pos().y();
//KyInfo() << "Final window position:" << finalX << "," << finalY;
if(finalX < 0){
finalX = 0;
}
if(finalY < 0){
finalY = 0;
}
int curWinMode = m_msgPane->getCurWinMode();
if(m_isMouseDragMove){
if(curWinMode == 2)
{
g_configManager->updateConfig("side-mode-x", finalX);
g_configManager->updateConfig("side-mode-y", finalY);
}
else if (curWinMode == 3){
g_configManager->updateConfig("window-mode-x", finalX);
g_configManager->updateConfig("window-mode-y", finalY);
}
}
m_isMouseDragMove = true;
// g_gsettings->set("window-mode-x", -1);
// g_gsettings->set("window-mode-y", -1);
}
void CMainWnd::onActivateMainWindow()
{
this->activateWindow();
this->setFocus();
}
void CMainWnd::onSaveAs(const QString &base64Image)
{
bool ok = false;
QPixmap pixmap;
// 去掉前缀
QStringList parts = base64Image.split(",");
if(parts.length() == 2)
{
QString imageData = parts.at(1);
QByteArray byteArray = QByteArray::fromBase64(imageData.toLocal8Bit());
pixmap.loadFromData(byteArray);
}
if(pixmap.isNull())
{
KyInfo() << "pixmap is null";
return;
}
// 获取当前时间
QDateTime currentTime = QDateTime::currentDateTime();
QString formattedTime = currentTime.toString("yyyyMMdd_hhmmss");
// 使用格式化后的时间作为文件名
QString fileName = "aiassistant_" + formattedTime + ".png";
QString path = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).at(0);
if(path.endsWith("/"))
{
path += fileName;
}
else
{
path += "/" + fileName;
}
//wayland环境下,构造函数必须加this, setModal(true)
QFileDialog *fileDialog = new QFileDialog(this); // 设置窗口标题属性自定义
fileDialog->setAccessibleName("kylin-aiassistant_QFileDialog_fileDialog");
fileDialog->setModal(true);
fileDialog->setNameFilter(QLatin1String("PNG(*.png);;BMP(*.bmp);;JPE(*.jpe);;JPG(*.jpg);;GIF(*.gif);;WEBP(*.webp);;JPEG(*.jpeg);;ICO(*.ico)"));
fileDialog->setDirectory(QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).at(0));
fileDialog->setAcceptMode(QFileDialog::AcceptSave);
fileDialog->selectFile(path);
if(fileDialog->exec() == QFileDialog::Accepted)
{
QString savePath = fileDialog->selectedFiles().at(0);
QFileInfo fileName(savePath);
if(savePath.isNull())
{
return;
}
if(fileName.suffix().isNull())
{
savePath += QLatin1String(".png");
}
fileName.setFile(savePath);
QString name = fileName.fileName();
QString msg;
QString message;
if(!name.startsWith(QChar('.'), Qt::CaseInsensitive))
{
QFileInfo fileInfo(savePath);
// 用于解决jpe文件保存报错问题
if(fileInfo.suffix() == "jpe"){
QStringList parts = base64Image.split(",");
// 解码 Base64 字符串
QByteArray decodedData;
if(parts.length() == 2)
{
QString imageData = parts.at(1);
decodedData = QByteArray::fromBase64(imageData.toLocal8Bit());
}
// 使用 QImage 加载解码后的数据
QImage img;
if (img.loadFromData(decodedData)) {
// 保存为 .jpe 格式(实际上是 JPEG 格式)
if (img.save(savePath, "JPEG")) {
ok = true;
} else {
ok = false;
}
} else {
qDebug() << "Failed to load image from decoded data.";
}
//ok = img.save(savePath, "JPEG");
}else{
ok = pixmap.save(savePath);
}
}
if(ok)
{
QString pathNoFile = savePath.left(savePath.lastIndexOf(QLatin1String("/")));
message = QObject::tr("Image saved as ") + savePath;
msg = "" + message + "";
}
else
{
if(name.contains(QChar('/')))
{
msg = QObject::tr("file name can not contains '/'");
}
else if(name.startsWith(QChar('.'), Qt::CaseInsensitive))
{
msg = QObject::tr("can not save file as hide file");
}
else if(name.length() > 255)
{
msg = QObject::tr("can not save because filename too long");
}
else
{
// message = QObject::tr("Error trying to save as ") + savePath;
// msg = "" + message + "";
msg = QObject::tr("Error trying to save as ") + savePath;
}
QMessageBox saveErrBox(QMessageBox::Warning, QObject::tr("Save Error"), msg);
saveErrBox.exec();
}
}
return;
}
void CMainWnd::onOpenFile(int typeNum)
{
FileType type = FileType(typeNum);
//wayland环境下,构造函数必须加this, setModal(true)
QFileDialog m_fileDialog(this);
m_fileDialog.setModal(true);
m_fileDialog.update();
QList list = m_fileDialog.sidebarUrls();
int sidebarNum = 8; //最大添加U盘数,可以自己定义
QString home = QDir::homePath().section("/", -1, -1);
QString mnt = "/media/" + home + "/";
QDir mntDir(mnt);
mntDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
QFileInfoList filist = mntDir.entryInfoList();
QList mntUrlList;
for(int i = 0; i < sidebarNum && i < filist.size(); ++i)
{
QFileInfo fi = filist.at(i);
//华为990、9a0需要屏蔽最小系统挂载的目录
if(fi.fileName() == "2691-6AB8")
continue;
mntUrlList << QUrl("file://" + fi.filePath());
}
QFileSystemWatcher fsw(&m_fileDialog);
fsw.addPath("/media/" + home + "/");
connect(&fsw, &QFileSystemWatcher::directoryChanged, &m_fileDialog, [=, &sidebarNum, &mntUrlList, &list, &m_fileDialog](const QString path) {
QDir wmntDir(path);
wmntDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
QFileInfoList wfilist = wmntDir.entryInfoList();
mntUrlList.clear();
for(int i = 0; i < sidebarNum && i < wfilist.size(); ++i)
{
QFileInfo fi = wfilist.at(i);
//华为990、9a0需要屏蔽最小系统挂载的目录
if(fi.fileName() == "2691-6AB8")
continue;
mntUrlList << QUrl("file://" + fi.filePath());
}
m_fileDialog.setSidebarUrls(list + mntUrlList);
m_fileDialog.update();
});
connect(&m_fileDialog, &QFileDialog::finished, &m_fileDialog, [=, &list, &m_fileDialog]() {
m_fileDialog.setSidebarUrls(list);
});
//这行要添加,设置左侧导航
m_fileDialog.setSidebarUrls(list + mntUrlList);
//设置视图模式
m_fileDialog.setViewMode(QFileDialog::Detail);
//设置可以选择多个文件,默认为只能选择一个文件QFileDialog::ExistingFiles
m_fileDialog.setFileMode(QFileDialog::ExistingFile);
m_fileDialog.setOption(QFileDialog::HideNameFilterDetails);
QString file_path;
QString format;
QString openFile = tr("Open Image");
QStringList supportFile = { "txt","pdf","docx","pptx"};
QStringList supportFormats = { "bmp", "jpe", "jpeg", "jpg", "pbm", "pgm", "png", "ppm", "tiff", "webp"};
if(type == IMAGE)
{
//构造打开条件
format = "(";
for(const QString &str: supportFormats)
format += "*." + str + " ";
format += ");;";
const QString supportFormatsClassify = "(*.bmp);;"
"(*.jpe *.jpeg *.jpg);;"
"(*.pbm *.pgm);;"
"(*.png);;"
"(*.ppm);;"
"(*.tiff);;"
"(*.webp)";
//所有类型都放在一起,类型名显示不全,故增加分层,将同一类型的放在一起,分层显示
format = format + supportFormatsClassify;
QVariant imagePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
//打开文件夹中的图片文件
file_path = m_fileDialog.getOpenFileName(this, openFile, imagePath.toString(), format);
}
else if(type == DOCUMENT)
{
format = "(";
for(const QString &str: supportFile)
format += "*." + str + " ";
format += ");;";
const QString supportFormatsClassify = "(*.txt);;"
"(*.pdf);;"
"(*.docx);;"
"(*.pptx)";
//所有类型都放在一起,类型名显示不全,故增加分层,将同一类型的放在一起,分层显示
format = format + supportFormatsClassify;
QVariant path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
//打开文件夹中的图片文件
file_path = m_fileDialog.getOpenFileName(this, openFile, path.toString(), format);
}
//空校验,点击“取消”
if(file_path.isEmpty())
{
return;
}
// 目前文件对话框无法限制不能选中超过一个文件,多选的时候只上传第一张
// else if(file_path.size() > 1)
// {
// onShowErrorMoreImage();
// return;
// }
else
{
QFileInfo fileInfo(file_path);
//判断文件后缀
if(!supportFormats.contains(fileInfo.suffix().toLower()) && !supportFile.contains(fileInfo.suffix().toLower()))
{
if(type == IMAGE)
{
m_msgPane->onShowErrorFormatImage();
}
else if(type == DOCUMENT)
{
m_msgPane->onShowErrorFormatFile();
}
return;
}
//判断文件大小
else if(fileInfo.size() > MAXIMAGESIZE)
{
m_msgPane->onShowErrorSizeImage();
return;
}
else
{
if(type == IMAGE)
{
m_msgPane->onShowImage(file_path, 1);
}
else if(type == DOCUMENT)
{
m_msgPane->onShowDocument(file_path);
}
}
}
}
void CMainWnd::onShowScribeWord()
{
//如果禁用划词则直接返回
bool isSelectDisable = g_configManager->getConfigValue("is-stroke-word").toBool();
// KyInfo() << "当前禁用划词显示的标志位为"<< isSelectDisable;
if(!isSelectDisable){
return;
}
// if(isWayland){
//// WindowManager::setOpenUnderCursor(m_selectwid->windowHandle());
// m_selectwid->show();
// }
// else{
// m_selectwid->showScribeWordsAtCursorPosition();
// }
m_selectwid->showScribeWordsAtCursorPosition();
}
void CMainWnd::initPosition()
{
QScreen *primaryScreen = QGuiApplication::primaryScreen();
globals::scaleFactor = primaryScreen->devicePixelRatio();
//监听分辨率变化,TODO:独占模式也会导致分辨率变化,后续需要加判断
connect(primaryScreen, &QScreen::availableGeometryChanged, this, &CMainWnd::changeScreenResolution);
return;
}
void CMainWnd::changeScreenResolution(){
int curWinMode = m_msgPane->getCurWinMode();
if(curWinMode == 2)
{
// 侧边栏模式
switchToSideMode();
}
else if (curWinMode == 3){
// 窗口模式
switchToWindowMode();
}
}
void CMainWnd::initTimer()
{
resizeTimer = new QTimer(this);
moveTimer = new QTimer(this);
resizeTimer->setSingleShot(true);
connect(resizeTimer, &QTimer::timeout, this, &CMainWnd::onResizeEnd);
moveTimer->setSingleShot(true);
connect(moveTimer, &QTimer::timeout, this, &CMainWnd::onMoveEnd);
}
void CMainWnd::initTopping()
{
bool isTopping = g_configManager->getConfigValue("is-window-mode-topping").toBool();
qInfo() << "isTopping " << isTopping;
if(isTopping){
m_isTop = true;
keepWindowAbove(true);
}
//openkylin临时注释
//m_btnStick->setIcon(QIcon::fromTheme(m_isTop ? "ukui-unfixed-symbolic" : "ukui-fixed-symbolic"));
//m_btnStick->setToolTip(m_isTop ? tr("unfixed") : tr("fixed"));
}
void CMainWnd::showSettingPage()
{
m_settingPage->show();
QScreen *screen = QApplication::primaryScreen();
int screenWidth = screen->size().width();
int screenHeight = screen->size().height();
int widgetWidth = m_settingPage->width();
int widgetHeight = m_settingPage->height();
int x = (screenWidth - widgetWidth) / 2;
int y = (screenHeight - widgetHeight) / 2;
m_settingPage->move(x, y);
if (!m_settingPage->isActiveWindow()) {
KyInfo() << "m_settingPage isActiveWindow false";
KWindowSystem::activateWindow(m_settingPage->windowHandle());
}
}
void CMainWnd::initShortcut()
{
//设置划词快捷键
if(m_actionShowScribeWord){
KGlobalAccel::self()->removeAllShortcuts(m_actionShowScribeWord);
delete m_actionShowScribeWord;
}
m_actionShowScribeWord = new QAction(this);
m_actionShowScribeWord->setObjectName("Action showScribeWord");
//这两行必须写,否则注册快捷键的模块名为中文,会导致快捷键注册失败
m_actionShowScribeWord->setProperty("componentName", "kylin-aiassistant");
m_actionShowScribeWord->setProperty("componentDisplayName", "AI aiassistant");
//移除之前需要set一次,估计是bug
KGlobalAccel::self()->setShortcut(m_actionShowScribeWord, QList{QKeySequence(Qt::ALT | Qt::META | Qt::Key_C)});
KGlobalAccel::self()->removeAllShortcuts(m_actionShowScribeWord);
connect(m_actionShowScribeWord, &QAction::triggered, this, &CMainWnd::onShowScribeWord);
KGlobalAccel::self()->setShortcut(m_actionShowScribeWord, QList{QKeySequence(Qt::ALT | Qt::META | Qt::Key_C)});
//设置助手显示弹窗快捷键
if(m_actionShowView){
KGlobalAccel::self()->removeAllShortcuts(m_actionShowView);
delete m_actionShowView;
}
m_actionShowView = new QAction(this);
m_actionShowView->setObjectName("Action showView");
//这两行必须写,否则注册快捷键的模块名为中文,会导致快捷键注册失败
m_actionShowView->setProperty("componentName", "kylin-aiassistant");
m_actionShowView->setProperty("componentDisplayName", "AI aiassistant");
//移除之前需要set一次,估计是bug
KGlobalAccel::self()->setShortcut(m_actionShowView, QList{Qt::META + Qt::Key_C});
KGlobalAccel::self()->removeAllShortcuts(m_actionShowView);
// connect(m_actionShowView, &QAction::triggered, this, &CMainWnd::showOrHideWindow);
// KGlobalAccel::self()->setShortcut(m_actionShowView, QList{Qt::META + Qt::Key_C});
}
QString CMainWnd::getAiAssistantVersion()
{
FILE *pp = NULL;
char *line = NULL;
size_t len = 0;
ssize_t read;
char *q = NULL;
QString version = tr("none");
pp = popen("dpkg -l kylin-aiassistant", "r");
if(NULL == pp)
return version;
while((read = getline(&line, &len, pp)) != -1){
q = strrchr(line, '\n');
*q = '\0';
QString content = line;
QStringList list = content.split(" ");
list.removeAll("");
if (list.size() >= 3)
version = list.at(2);
}
free(line);
pclose(pp);
return version;
}
void CMainWnd::initGlobalSetting()
{
isSupportWindowMode = globals::getIsSupportWindowMode();
}
void CMainWnd::checkTheme()
{
// Use default theme (globals::themeColor=0, globals::fontSize=11.0 from kaglobal)
}
void CMainWnd::keepWindowAbove(bool needTokeepAbove)
{
qInfo() << "needTokeepAbove " << needTokeepAbove;
#ifdef UKUI_WINDOWHELPER_SUPPORT
UkuiWindowHelper::States states;
states |= UkuiWindowHelper::State::Minimizable;
states |= UkuiWindowHelper::State::Maximizable;
states |= UkuiWindowHelper::State::Closeable;
states |= UkuiWindowHelper::State::Fullscreenable;
states |= UkuiWindowHelper::State::Resizable;
states |= UkuiWindowHelper::State::Focusable;
states |= UkuiWindowHelper::State::Activatable;
int winMode = g_configManager->getConfigValue("win-mode").toInt();
qInfo() << "winMode " << winMode;
if (winMode == 3){
states |= UkuiWindowHelper::State::Movable;
}
if (needTokeepAbove) {
states |= UkuiWindowHelper::State::KeepAbove;
}
m_ukuiWindowHelper->setWindowState(states);
#else
qInfo() << "m_window_id " << m_window_id;
kdk::WindowManager::keepWindowAbove(m_window_id);
#endif
return;
}
kylin-aiassistant-3.0.0.0/kylin-aiassistant/cmainwnd.h 0000775 0000000 0000000 00000014123 15205774371 0022756 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#ifndef CMAINWND_H
#define CMAINWND_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "msgpane.h"
#include "cpushbuttonex.h"
#include "setting/settingdialog.h"
#include "dbus/kadbusoperator.h"
#include "textselect/clipboard.h"
#include "textselect/selection.h"
#include "setting/scribewordpage.h"
#include "sqlconversationmodel.h"
#include "global/kaglobal.h"
#include "tipwidget.h"
#include "textselect/selection.h"
#include "commandtemplatelist.h"
#include
#include
#include
#include
#include
#include
#include "global/kaglobal.h"
#include "introductionview.h"
#include "kaboutdialog.h"
#include
#include
#include
#include
using namespace kdk;
#define SIDEBAR_WIDTH 402
class CPushButtonEx;
enum MainWndViewType
{
TABTITLE_MESSAGE = 0, // 消息会话
TABTITLE_VOICE = 1, // 通讯录
};
class CMainWnd : public KWidget
{
Q_OBJECT
public:
explicit CMainWnd(QWidget *parent = nullptr);
~CMainWnd();
void checkTheme();
IntroductionView * m_introductionView = nullptr; //新手引导页面
void keepWindowAbove(bool needTokeepAbove);
public slots:
void onFocusChanged(QWidget *oldWidget, QWidget *newWidget);
void slotToTop();
void slotToTopChangeWinMode();
void onConfActionTriggered();
void onShotCutActionTriggled();
void onAboutActionTriggled();
void onExitActionTriggled();
void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
void onAppRestarted(const QString &message);
void onSideBarBtnClicked();
void onBackBtnClicked();
void onPageChanged(const int pageNumber);
void handleClicpText();
void onStartSendSelectMsg();
void onCreateDialog();
void onShowScribeWord();
void onShowCustomMessageBox(const QVariantList &strings);
void showOrHideWindow();
void onShowHelp();
void onShowAbout();
void onResizeEnd();
void onMoveEnd();
void onActivateMainWindow();
void onSaveAs(const QString &base64Image); //响应qml发来的下载图片文件选择框
void onOpenFile(int typeNum); //响应qml发来的添加图片/文档文件选择框
signals:
void sigThemeChanged();
private:
void createAllChildWnd();
void initCtrl();
void initSolts();
void initLayout();
void switchToWindowMode();
void switchToSideMode();
void initTrayIcon();
void initTrayIconMenu();
void showView();
void hideView();
void initScribeWords();
void initPosition();
void initScribeWordsSetting();
void showSettingPage();
void initShortcut();
void changeScreenResolution(); // 切换屏幕分辨率修改窗口大小和位置
QString getAiAssistantVersion();
void initTimer();
void initTopping();
void initGlobalSetting(); //初始化全局设置
protected:
void closeEvent(QCloseEvent *e) override;
protected:
void resizeEvent(QResizeEvent *event) override;
void moveEvent(QMoveEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
bool eventFilter(QObject *obj, QEvent *event) override;
private:
bool m_isTop = false;
quint64 m_window_id = 0;
bool isMsgBoxOpen = false;
QWidget *m_leftBtnWidget = nullptr;
CPushButtonEx *m_btnSideBar = nullptr;
QPushButton *m_btnBack = nullptr;
QPushButton *m_btnStick = nullptr;
QAction *confAction = nullptr;
SettingDialog *m_settingPage = nullptr;
KADBusOperator *m_dbusOperator = nullptr;
QAction *m_shotcutAction = nullptr;
QAction *m_aboutAction = nullptr;
QAction *m_exitAction = nullptr;
QMenu *m_trayIconMenu = nullptr;
QSystemTrayIcon *m_trayIcon = nullptr;
CMsgPane *m_msgPane = nullptr;
Clipboard *m_selectclip = nullptr;
SelectWidget *m_selectwid = nullptr;
QFileSystemWatcher *m_fileWatcher = nullptr;
QQuickWidget *m_mainQml = nullptr; // QML主页面
QAction *m_actionShowScribeWord = nullptr; //划词快捷键
QAction *m_actionShowView = nullptr; //显示助手快捷键
ActiveModule m_previousModule = ActiveModule::MODULE_CHAT;
QString appVersion = nullptr;
QString appShowingName = tr("AI Assistant");
kdk::KAboutDialog *aboutWindow;
QTimer *resizeTimer = nullptr;
QTimer *moveTimer = nullptr;
QTimer *selectTimer = nullptr;
bool m_isMouseDragMove = true; // 是否是鼠标拖动
#ifdef UKUI_WINDOWHELPER_SUPPORT
UkuiWindowHelper *m_ukuiWindowHelper = nullptr;
#else
quint64 m_window_id = 0;
#endif
};
#endif // CMAINWND_H
kylin-aiassistant-3.0.0.0/kylin-aiassistant/commandtemplatelist.cpp 0000664 0000000 0000000 00000022103 15205774371 0025551 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#include "commandtemplatelist.h"
#include
#include
//CommandTemplateList* CommandTemplateList::m_commandTemplateListModel = nullptr;
CommandTemplateList* CommandTemplateList::originalCommandListModel = nullptr;
CommandTemplateList::CommandTemplateList(QObject *parent)
: QAbstractListModel{parent}
{
}
int CommandTemplateList::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return m_commandTemplateList.count();
}
QVariant CommandTemplateList::data(const QModelIndex &index, int role) const
{
if(index.row() < 0 || m_commandTemplateList.size() <= index.row()) {
return QVariant();
}
CommandTemplateItem item = m_commandTemplateList.at(index.row());
switch (role) {
case CommandTemplateRoleType::NameRole:
return item.name;
case CommandTemplateRoleType::ActorRole:
return item.actorId;
case CommandTemplateRoleType::ContentRole:
return item.content;
case CommandTemplateRoleType::CommandTypeRole:
return item.commandType;
case CommandTemplateRoleType::IconRole:
return item.iconPath;
default:
break;
}
return QVariant();
}
QHash CommandTemplateList::roleNames() const
{
QHash roles;
roles[CommandTemplateRoleType::NameRole]="name";
roles[CommandTemplateRoleType::ActorRole]="actorId";
roles[CommandTemplateRoleType::ContentRole]="content";
roles[CommandTemplateRoleType::CommandTypeRole]="commandType";
roles[CommandTemplateRoleType::IconRole] = "iconPath";
return roles;
}
//CommandTemplateList *CommandTemplateList::getInstance()
//{
// if(m_commandTemplateListModel == nullptr) {
// m_commandTemplateListModel = new CommandTemplateList;
// }
// return m_commandTemplateListModel;
//}
QList CommandTemplateList::getCommandTemplateList()
{
return m_commandTemplateList;
}
QVariant CommandTemplateList::getData(const int row, int role) const
{
CommandTemplateItem item = m_commandTemplateList.at(row);
switch (role) {
case 0:
return item.name;
case 1:
return item.actorId;
case 2:
return row;
case 3:
return item.content;
case 4:
return item.commandType;
case 5:
return item.iconPath;
default:
break;
}
}
int CommandTemplateList::getPromptId(QString name)
{
int promptId = -2; // -2返回为一个无意义的值,为了和promptId默认为-1区分开,防止模型没有整理周报功能去生成周报
for (int i = 0; i < m_commandTemplateList.size(); ++i) {
CommandTemplateItem &item = m_commandTemplateList[i];
if (item.name == name) {
promptId = item.actorId;
break;
}
}
if (promptId == -2) {
KyInfo() << "获取promptId失败";
} else {
KyInfo() << "获取promptId成功" << promptId;
}
return promptId;
}
int CommandTemplateList::count()
{
return m_commandTemplateList.count();
}
void CommandTemplateList::initData(std::vector promptList)
{
// actorId 到图标路径的映射
QMap iconMap = {
{1, "qrc:/icon/icon/setting/text-expend.svg"},
{2, "qrc:/icon/icon/setting/text-polish.svg"},
{3, "qrc:/icon/icon/setting/translate.svg"},
{4, "qrc:/icon/icon/setting/system-QA.svg"},
{5, "qrc:/icon/icon/setting/todo-generate.svg"},
{6, "qrc:/icon/icon/setting/weekly-report.svg"},
{7, "qrc:/icon/icon/setting/new-schedule.svg"},
{8, "qrc:/icon/icon/setting/text-proofread.svg"},
{9, "qrc:/icon/icon/setting/summary.svg"},
{13, "qrc:/icon/icon/setting/system-control.svg"}
};
for (const auto& prompt : promptList) {
CommandTemplateItem item;
item.actorId = prompt.id;
item.name = QString::fromStdString(prompt.name);
item.content = QString::fromStdString(prompt.content);
if(prompt.type == PromptContentAccessType::ReadOnly || prompt.type == PromptContentAccessType::NoAccess)
{
continue;
}
item.commandType = prompt.type;
item.iconPath = iconMap.value(item.actorId, "qrc:/icon/icon/setting/prompt.svg");
beginInsertRows(QModelIndex(), m_commandTemplateList.count(), m_commandTemplateList.count());
m_commandTemplateList << item;
endInsertRows();
}
}
void CommandTemplateList::loadData(QList commandTemplateList)
{
// 清空现有数据
beginResetModel();
m_commandTemplateList.clear();
endResetModel();
for (const auto& item : commandTemplateList) {
beginInsertRows(QModelIndex(), m_commandTemplateList.count(), m_commandTemplateList.count());
m_commandTemplateList.append(item);
endInsertRows();
}
}
void CommandTemplateList::resetAllData()
{
QList list = m_commandTemplateList;
beginResetModel();
m_commandTemplateList.clear();
m_commandTemplateList = list;
endResetModel();
}
void CommandTemplateList::createCommand(const QString &name, const QString &content)
{
emit sigCreateCommand(name, content);
}
void CommandTemplateList::updateCommand(int actorId, const QString &name, const QString &content)
{
for (int i = 0; i < m_commandTemplateList.size(); ++i) {
CommandTemplateItem &item = m_commandTemplateList[i];
if (item.actorId == actorId) {
emit sigUpdateCommand(actorId, name, content);
}
}
}
void CommandTemplateList::deleteCommand(int actorId, const QString &name)
{
KyInfo() << "deletecommand";
emit sigDeleteActiveCommand(actorId, name);
}
void CommandTemplateList::moveCommand(int fromIndex, int toIndex)
{
if (fromIndex < 0 || fromIndex >= m_commandTemplateList.count() ||
toIndex < 0 || toIndex >= m_commandTemplateList.count() || fromIndex == toIndex) {
return;
}
beginMoveRows(QModelIndex(), fromIndex, fromIndex, QModelIndex(), toIndex > fromIndex ? toIndex + 1 : toIndex);
m_commandTemplateList.move(fromIndex, toIndex);
endMoveRows();
emit dataChanged(index(0, 0), index(m_commandTemplateList.count() - 1, 0)); // 更新整个列表
}
void CommandTemplateList::addData(PromptContentAccessType commandType, int actorId, const QString &name, const QString &content)
{
CommandTemplateItem item;
item.commandType = commandType;
item.actorId = actorId;
item.name = name;
item.content = content;
item.iconPath = "qrc:/icon/icon/setting/prompt.svg";
beginInsertRows(QModelIndex(), m_commandTemplateList.count(), m_commandTemplateList.count());
m_commandTemplateList << item;
endInsertRows();
resetAllData();
// emit sigUpdateUI();
}
void CommandTemplateList::updateData(int actorId, const QString &name, const QString &content)
{
for (int i = 0; i < m_commandTemplateList.size(); ++i) {
CommandTemplateItem &item = m_commandTemplateList[i];
if (item.actorId == actorId) {
item.name = name;
item.content = content;
QModelIndex modelIndex = this->index(i);
emit dataChanged(modelIndex, modelIndex);
// emit sigUpdateUI();
emit sigUpdateActiveCommand(actorId, name);
KyInfo() << "提示词编辑完成" << actorId << name;
break;
}
}
}
void CommandTemplateList::removeData(int actorId, const QString &name)
{
for (int i = 0; i < m_commandTemplateList.size(); ++i) {
CommandTemplateItem &item = m_commandTemplateList[i];
if (item.actorId == actorId && item.name == name) {
beginRemoveRows(QModelIndex(), i, i);
m_commandTemplateList.removeAt(i);
endRemoveRows();
// emit sigUpdateUI();
KyInfo() << "提示词删除完成" << actorId << name;
break;
}
}
}
// operator<< 格式化输出
QDebug operator<<(QDebug debug, const CommandTemplateItem &item)
{
QDebugStateSaver saver(debug); // 保存 debug 的状态
debug.nospace() << "CommandTemplateItem: "
<< ", commandType: " << item.commandType
<< ", actorId: " << item.actorId
<< ", name: " << item.name
<< ", content: " << item.content
<< ", iconPath: " << item.iconPath << ")";
return debug;
}
kylin-aiassistant-3.0.0.0/kylin-aiassistant/commandtemplatelist.h 0000664 0000000 0000000 00000006644 15205774371 0025232 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#ifndef COMMANDTEMPLATELIST_H
#define COMMANDTEMPLATELIST_H
#include
#include
#include
#include
#include "global/kaglobal.h"
using namespace kyai::assistant;
// sdk提示词类型
//enum PromptContentAccessType {
// ReadOnly = 1, // 预设的提示词——文本扩写、文本润色、中英互译、内容校对、总结概括,仅支持查看不可修改内容
// ReadWrite, // 自定义提示词
// NoAccess // 预设提示词——系统助手、生成代办、整理周报、新建日程,不可进行提示词查看
//};
typedef struct {
// int index;
int actorId;
QString name;
QString content;
PromptContentAccessType commandType;
QString iconPath;
} CommandTemplateItem;
class CommandTemplateList : public QAbstractListModel
{
Q_OBJECT
public:
enum CommandTemplateRoleType {
NameRole = Qt::UserRole+1,
ActorRole,
ContentRole,
CommandTypeRole,
IconRole
};
Q_ENUM(CommandTemplateRoleType)
explicit CommandTemplateList(QObject *parent = nullptr);
// static CommandTemplateList *getInstance();
static CommandTemplateList *originalCommandListModel;
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QHash roleNames() const;
QList getCommandTemplateList();
Q_INVOKABLE QVariant getData(const int row,int role) const;
int getPromptId(QString name);
Q_INVOKABLE int count();
void createCommand(const QString &name, const QString &content);
void updateCommand(int actorId, const QString &name, const QString &content);
Q_INVOKABLE void moveCommand(const int fromIndex,const int toIndex);
void initData(std::vector promptList);
void loadData(QList commandTemplateList);
void resetAllData();
void addData(PromptContentAccessType commandType, int actorId, const QString &name, const QString &content);
void updateData(int actorId, const QString &name, const QString &content);
public slots:
void deleteCommand(int actorId, const QString &name);
void removeData(int actorId, const QString &name);
signals:
void sigCreateCommand(QString name, QString content);
void sigUpdateCommand(int actorId, QString name, QString content);
void sigUpdateUI();
// 更新qml主页选中提示词
void sigUpdateActiveCommand(int actorId, QString name);
void sigDeleteActiveCommand(int actorId, QString name);
private:
// static CommandTemplateList *m_commandTemplateListModel;
QList m_commandTemplateList;
};
#endif // COMMANDTEMPLATELIST_H
kylin-aiassistant-3.0.0.0/kylin-aiassistant/configmanager.cpp 0000664 0000000 0000000 00000004610 15205774371 0024306 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#include "configmanager.h"
#include
#include
#include
#include
ConfigManager::ConfigManager(const QString &configFilePath)
{
// 创建 QSettings 对象,指定 INI 格式
m_settings = new QSettings(configFilePath, QSettings::IniFormat);
// 检查文件是否存在
if (!QFile::exists(configFilePath)) {
KyInfo() << "配置文件不存在,创建新的配置文件...";
createDefaultConfig();
}
// 从配置文件读取值
//loadConfig();
}
ConfigManager::~ConfigManager()
{
delete m_settings;
}
QVariant ConfigManager::getConfigValue(const QString &key, const QVariant &defaultValue)
{
return m_settings->value(key, defaultValue); // 获取指定键的值
}
void ConfigManager::updateConfig(const QString &key, const QVariant &value)
{
m_settings->setValue(key, value); // 设置新的配置值
m_settings->sync(); // 强制写入
KyInfo() << "配置已更新:" << key << "=" << value;
}
void ConfigManager::createDefaultConfig()
{
m_settings->setValue("is-stroke-word", true);
m_settings->setValue("history-id", 0);
m_settings->setValue("win-mode", 2);
m_settings->setValue("is-side-mode-abreast", false);
m_settings->setValue("is-window-mode-topping", false);
m_settings->setValue("window-mode-length", 902);
m_settings->setValue("window-mode-wide", 568);
m_settings->setValue("window-mode-x", -1);
m_settings->setValue("window-mode-y", -1);
m_settings->setValue("is-first-install", true);
m_settings->setValue("side-mode-x", -1);
m_settings->setValue("side-mode-y", -1);
m_settings->setValue("is-privacy-detection", false);
m_settings->sync(); // 强制写入
}
kylin-aiassistant-3.0.0.0/kylin-aiassistant/configmanager.h 0000664 0000000 0000000 00000002503 15205774371 0023752 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#ifndef CONFIGMANAGER_H
#define CONFIGMANAGER_H
#include
#include
#include
class ConfigManager
{
public:
explicit ConfigManager(const QString &configFilePath); // 构造函数
~ConfigManager(); // 析构函数
// 获取配置值
QVariant getConfigValue(const QString &key, const QVariant &defaultValue = QVariant());
// 修改配置值
void updateConfig(const QString &key, const QVariant &value);
private:
QSettings *m_settings; // QSettings 对象,用于操作 INI 配置文件
// 创建默认配置文件
void createDefaultConfig();
};
#endif // CONFIGMANAGER_H
kylin-aiassistant-3.0.0.0/kylin-aiassistant/cpushbuttonex.cpp 0000775 0000000 0000000 00000003405 15205774371 0024425 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#include "cpushbuttonex.h"
#include
#include
CPushButtonEx::CPushButtonEx(QWidget *parent) : QPushButton(parent)
{
m_varData = 0;
m_bExArea = false;
m_fRadio = 0.0;
m_bRadio = false;
setCursor(Qt::ArrowCursor); //设置鼠标样式
}
CPushButtonEx::~CPushButtonEx()
{
}
void CPushButtonEx::mouseReleaseEvent( QMouseEvent *e )
{
if (!m_bExArea)
return QPushButton::mouseReleaseEvent(e);
QRect rcEx = rect();
rcEx.setTopLeft(QPoint(rcEx.bottom() / 4 * 3, rcEx.right() / 4 * 3));
if (!rcEx.contains(e->pos()))
Q_EMIT SignalClicked();
else
Q_EMIT SignalClickedExArea();
return QPushButton::mouseReleaseEvent(e);
}
void CPushButtonEx::resizeEvent(QResizeEvent *event)
{
if (m_bRadio)
{
setFixedHeight(width() / m_fRadio);
this->setStyleSheet(QString("QPushButton{font: bold %1px;} QPushButton:hover{font: bold %2px;} QPushButton:pressed{font: bold %3px;}")
.arg(this->height() / 2).arg(this->height() / 2 + 6).arg(this->height() / 2 + 2));
}
}
kylin-aiassistant-3.0.0.0/kylin-aiassistant/cpushbuttonex.h 0000775 0000000 0000000 00000003012 15205774371 0024064 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#ifndef CPUSHBUTTON_H
#define CPUSHBUTTON_H
#include
#include
#include
class CPushButtonEx : public QPushButton
{
Q_OBJECT
public:
explicit CPushButtonEx(QWidget *parent = 0);
~CPushButtonEx();
public:
QVariant Data() { return m_varData; }
void SetData(QVariant varData) { m_varData = varData; }
void SetExArea(bool bExArea) { m_bExArea = bExArea; }
void SetAspectRatio(double fRadio) { m_bRadio = true; m_fRadio = fRadio; }
protected:
void mouseReleaseEvent(QMouseEvent *e);
void resizeEvent(QResizeEvent *event);
signals:
void SignalClicked(); // 点击正常区域
void SignalClickedExArea(); // 点击扩展区域
private:
QVariant m_varData;
bool m_bExArea;
bool m_bRadio;
double m_fRadio;
};
#endif // CPUSHBUTTON_H
kylin-aiassistant-3.0.0.0/kylin-aiassistant/ctrl.cpp 0000664 0000000 0000000 00000011274 15205774371 0022456 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#include "ctrl.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "usdbrightness.h"
#include
#include
#include
#include
#include
#include
#include
ctrl::ctrl() : QObject()
{
if (QGSettings::isSchemaInstalled(QByteArray("org.ukui.control-center.panel.plugins"))) {
QGSettings gsettings(QByteArray("org.ukui.control-center.panel.plugins"), QByteArray(), this);
// gsettings.set("gammaforbrightness", true);
}
QObject::connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished,
[&](KScreen::ConfigOperation *op) {
const KScreen::ConfigPtr config = qobject_cast(op)->config();
KScreen::ConfigMonitor::instance()->addConfig(config);
for (KScreen::OutputPtr output : config.data()->connectedOutputs()) {
qInfo() << "Starting config screen name: " << output->name();
m_screenNameList.append(output->name());
}
});
}
void ctrl::controlMprisPlayerDbus(const QString funcName)
{
if (m_dbusMprisInterface == nullptr) {
m_dbusMprisInterface = new QDBusInterface(SESSION_DBUS_NAME_STR_FIELD, SESSION_DBUS_PLAYER_PATH,
SESSION_DBUS_PLAYER_INTERFACE, QDBusConnection::sessionBus());
}
if (m_dbusMprisInterface->isValid()) {
if (funcName.startsWith("seek")) {
QStringList itemList = funcName.trimmed().split(':');
bool ok;
qlonglong value = itemList.value(1).toLongLong(&ok);
if (ok) {
m_dbusMprisInterface->asyncCall("operation", itemList.value(0), QVariantList() << value);
}
return;
}
if (funcName.startsWith("setRate")) {
QStringList itemList = funcName.trimmed().split(':');
bool ok;
double value = itemList.value(1).toDouble(&ok);
if (ok) {
m_dbusMprisInterface->asyncCall("operation", itemList.value(0), QVariantList() << value);
}
return;
}
m_dbusMprisInterface->asyncCall("operation", funcName, QVariantList());
}
}
void ctrl::setBrightness(bool isUp)
{
if (m_dbusBrightnessInterface == nullptr) {
m_dbusBrightnessInterface = new QDBusInterface(SESSION_DBUS_NAME_BRIGHTNESS, SESSION_DBUS_BRIGHTNESS_PATH,
SESSION_DBUS_BRIGHTNESS_INTERFACE, QDBusConnection::sessionBus());
}
QDBusMessage res =m_dbusBrightnessInterface->call("getPrimaryBrightness");
int value = res.arguments().first().toUInt();
qInfo() << "get screen brightness: " << value;
if (isUp) {
if (value >= 100) {
value = 100;
} else {
value += 10;
}
} else {
if (value <= 0) {
value = 0;
} else {
value -= 10;
}
}
qInfo() << "set screen brightness: " << value;
res = m_dbusBrightnessInterface->call("setPrimaryBrightness", (quint32)value);
}
void ctrl::setDefaultAdapterSwitchStatus(bool power)
{
QDBusMessage dbusMsg = QDBusMessage::createMethodCall(SYSTEM_DBUS_BLE_SERVICE, SYSTEM_DBUS_BLE_PATH,
SYSTEM_DBUS_BLE_INTERFACE, "setDefaultAdapterAttr");
QMap adpAttr;
adpAttr.insert("Powered", QVariant(power));
dbusMsg << adpAttr;
QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock);
if (response.type() == QDBusMessage::ReplyMessage) {
qInfo() << "set Ble status:" << response.arguments().takeFirst().toBool();
}
}
kylin-aiassistant-3.0.0.0/kylin-aiassistant/ctrl.h 0000664 0000000 0000000 00000004522 15205774371 0022121 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#ifndef CTRL_H
#define CTRL_H
#include
#include
#include
#include
#include
#include
// 音视频session dbus
#define SESSION_DBUS_NAME_STR_FIELD "org.ukui.SettingsDaemon"
#define SESSION_DBUS_PLAYER_PATH "/mpris/controller"
#define SESSION_DBUS_PLAYER_INTERFACE "org.ukui.mpris.controller"
// 亮度session dbus
#define SESSION_DBUS_NAME_BRIGHTNESS "org.ukui.SettingsDaemon"
#define SESSION_DBUS_BRIGHTNESS_PATH "/GlobalBrightness"
#define SESSION_DBUS_BRIGHTNESS_INTERFACE "org.ukui.SettingsDaemon.Brightness"
//日历session dbus
#define SESSION_DBUS_NAME_CALENDAR "org.ukui.calendar.Notifications"
#define SESSION_DBUS_PATH_CALENDAR "/org/ukui/calendar/Notifications"
#define SESSION_DBUS_INTERFACE_CALENDAR "org.ukui.calendar.Notifications"
const QString SYSTEM_DBUS_BLE_SERVICE = "com.ukui.bluetooth";
const QString SYSTEM_DBUS_BLE_PATH = "/com/ukui/bluetooth";
const QString SYSTEM_DBUS_BLE_INTERFACE = "com.ukui.bluetooth";
class ctrl : public QObject
{
Q_OBJECT
public:
ctrl();
void controlMprisPlayerDbus(const QString funcName);
void setBrightness(bool isUp);
void setDefaultAdapterSwitchStatus(bool power);
private:
QDBusInterface *m_dbusMprisInterface = nullptr;
QDBusInterface *m_dbusBrightnessInterface = nullptr;
QGSettings *m_powerGSettings = nullptr;
QDBusInterface *m_usdInterface = nullptr;
QDBusInterface *m_scheduleInterface = nullptr;
QStringList m_screenNameList;
int m_scheduleDay;
int m_scheduleMonth;
int m_scheduleYear;
int m_TodoListDay;
int m_TodoListMonth;
int m_TodoListYear;
};
#endif // CTRL_H
kylin-aiassistant-3.0.0.0/kylin-aiassistant/custommessagebox.cpp 0000664 0000000 0000000 00000012403 15205774371 0025075 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#include "custommessagebox.h"
#include
#include
#include
#include
#include
CustomMessageBox::CustomMessageBox(QWidget *parent)
: QDialog(parent), m_clickedButton(0)
{
initLayout();
initConnect();
checkTheme();
}
void CustomMessageBox::initLayout()
{
this->setWindowTitle(QString(" "));
setFixedSize(376, 156);
setWindowFlags(Qt::Dialog);
#ifdef UKUI_WINDOWHELPER_SUPPORT
UkuiWindowHelper *ukuiWindowHelper = new UkuiWindowHelper(this);
ukuiWindowHelper->removeTitleBar();
#else
kdk::UkuiStyleHelper::self()->removeHeader(this);
#endif
// 焦点不在窗口上时鼠标悬浮可显示tooltips
this->setAttribute(Qt::WA_AlwaysShowToolTips);
closeButton = new QPushButton;
closeButton->setAccessibleName("kylin-aiassistant_QPushButton_closeButton");
closeButton->setFlat(true);
closeButton->setFixedSize(32, 32);
closeButton->setProperty("isWindowButton", 0x2);
closeButton->setProperty("useIconHighlightEffect", 0x8);
closeButton->setIcon(QIcon::fromTheme("window-close-symbolic"));
closeButton->setToolTip(tr("Close"));
QWidget *titleWidget = new QWidget();
titleWidget->setAccessibleName("kylin-aiassistant_QWidget_titleWidget");
titleWidget->setFixedSize(376, 40);
QHBoxLayout *titleHLayout = new QHBoxLayout(titleWidget);
titleHLayout->setContentsMargins(8, 0, 4, 0);
titleHLayout->addStretch();
titleHLayout->addWidget(closeButton);
// 提示
iconLabel = new QLabel(this);
iconLabel->setAccessibleName("kylin-aiassistant_QLabel_iconLabel");
iconLabel->setFixedSize(24, 24);
QPixmap pixmap(":/icon/icon/tips.svg");
pixmap.scaled(iconLabel->size(), Qt::KeepAspectRatio,Qt::SmoothTransformation);
iconLabel->setScaledContents(true);
iconLabel->setPixmap(pixmap);//设置图标
messageLabel = new QLabel(this);
messageLabel->setAccessibleName("kylin-aiassistant_QLabel_messageLabel");
messageLabel->setFixedSize(294, 22);
messageLabel->setWordWrap(true);
QHBoxLayout *tipsLayout = new QHBoxLayout();
tipsLayout->setContentsMargins(24, 8, 24, 0);
tipsLayout->setSpacing(8);
tipsLayout->addWidget(iconLabel);
tipsLayout->addWidget(messageLabel);
tipsLayout->addStretch();
// 按钮
cancelButton = new QPushButton(tr("Cancel"), this);
cancelButton->setAccessibleName("kylin-aiassistant_QQPushButton_cancelButton");
cancelButton->setFixedSize(94, 36);
okButton = new QPushButton(tr("Delete"), this);
okButton->setAccessibleName("kylin-aiassistant_QPushButton_okButton");
okButton->setFixedSize(94, 36);
okButton->setProperty("isImportant", true);
okButton->setDefault(true);
QHBoxLayout *buttonLayout = new QHBoxLayout();
buttonLayout->setContentsMargins(24, 0, 24, 24);
buttonLayout->setSpacing(16);
buttonLayout->addStretch();
buttonLayout->addWidget(cancelButton);
buttonLayout->addWidget(okButton);
// 主布局
QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
mainLayout->addWidget(titleWidget);
mainLayout->addLayout(tipsLayout);
mainLayout->addStretch();
mainLayout->addLayout(buttonLayout);
this->setLayout(mainLayout);
}
void CustomMessageBox::initConnect()
{
connect(closeButton, &QPushButton::clicked, this, &CustomMessageBox::onCancelClicked);
connect(cancelButton, &QPushButton::clicked, this, &CustomMessageBox::onCancelClicked);
connect(okButton, &QPushButton::clicked, this, &CustomMessageBox::onOkClicked);
}
void CustomMessageBox::setMessage(const QString &message) {
messageLabel->setText(message);
}
void CustomMessageBox::setButtons(int buttons) {
okButton->setVisible(buttons & OkButton);
cancelButton->setVisible(buttons & CancelButton);
}
int CustomMessageBox::clickedButton() const {
return m_clickedButton;
}
void CustomMessageBox::onOkClicked() {
m_clickedButton = OkButton;
accept();
}
void CustomMessageBox::onCancelClicked() {
m_clickedButton = CancelButton;
reject();
}
void CustomMessageBox::resizeEvent(QResizeEvent *event) {
QDialog::resizeEvent(event);
// Center the messageLabel within the dialog
//messageLabel->setGeometry(0, 0, width(), messageLabel->height());
}
void CustomMessageBox::changeTheme()
{
QPalette p = this->palette();
QColor color = p.color(QPalette::Base);
p.setColor(QPalette::Window, color);
this->setPalette(p);
}
void CustomMessageBox::checkTheme()
{
changeTheme();
}
kylin-aiassistant-3.0.0.0/kylin-aiassistant/custommessagebox.h 0000664 0000000 0000000 00000003077 15205774371 0024551 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2020, 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 .
*/
#ifndef CUSTOMMESSAGEBOX_H
#define CUSTOMMESSAGEBOX_H
#include
#include
#include
class CustomMessageBox : public QDialog {
Q_OBJECT
public:
enum MessageBoxButton {
OkButton = 1,
CancelButton = 2,
CloseButton =3
};
explicit CustomMessageBox(QWidget *parent = nullptr);
void setMessage(const QString &message);
void setButtons(int buttons);
int clickedButton() const;
protected:
void resizeEvent(QResizeEvent *event) override;
private:
void initLayout();
void initConnect();
void checkTheme();
private slots:
void onOkClicked();
void onCancelClicked();
void changeTheme();
private:
QLabel *messageLabel;
QLabel *iconLabel;
QPushButton *okButton;
QPushButton *cancelButton;
QPushButton *closeButton;
int m_clickedButton;
};
#endif // CUSTOMMESSAGEBOX_H
kylin-aiassistant-3.0.0.0/kylin-aiassistant/data/ 0000775 0000000 0000000 00000000000 15205774371 0021712 5 ustar 00root root 0000000 0000000 kylin-aiassistant-3.0.0.0/kylin-aiassistant/data/com.kylin.aiassistant.service 0000664 0000000 0000000 00000000125 15205774371 0027517 0 ustar 00root root 0000000 0000000 [D-BUS Service]
Name=com.kylin.aiassistant
Exec=/usr/bin/kylin-aiassistant --silence
kylin-aiassistant-3.0.0.0/kylin-aiassistant/data/guide/ 0000775 0000000 0000000 00000000000 15205774371 0023007 5 ustar 00root root 0000000 0000000 kylin-aiassistant-3.0.0.0/kylin-aiassistant/data/guide/kylin-aiassistant/ 0000775 0000000 0000000 00000000000 15205774371 0026456 5 ustar 00root root 0000000 0000000 kylin-aiassistant-3.0.0.0/kylin-aiassistant/data/guide/kylin-aiassistant/en_US/ 0000775 0000000 0000000 00000000000 15205774371 0027467 5 ustar 00root root 0000000 0000000 kylin-aiassistant-3.0.0.0/kylin-aiassistant/data/guide/kylin-aiassistant/en_US/image/ 0000775 0000000 0000000 00000000000 15205774371 0030551 5 ustar 00root root 0000000 0000000 会议助手入口.jpg 0000664 0000000 0000000 00000056365 15205774371 0037560 0 ustar 00root root 0000000 0000000 kylin-aiassistant-3.0.0.0/kylin-aiassistant/data/guide/kylin-aiassistant/en_US/image JFIF ` ` C
$.' ",#(7),01444'9=82<.342 C
2!!22222222222222222222222222222222222222222222222222
"
} !1AQa"q2#BR$3br
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz
w !1AQaq"2B #3Rbr
$4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ? 6ӡ5y&ැe{3=28bG"ưh DP`%V8bC$z**ҭYTٝ:ql_AQ}\,{{;6f` ۍF[s+JVUѵࡑ#10 {ھjʖ M?*6OO<Qw*I= q"+@ay W~Tm_AR@ }F- W~Tm_AR@ }F- W~Tm_AR@ }F- W~Tm_AR@ }F- W~Tm_AR@ }F- W~Tm_AR@ }F- W~Tm_AR@ }F- W~Tm_AR@ }F-f
{O 6%LaQE im_AQ}KE &W~TPm_AQ}KE &W~TŖ7wDY : ;jWAi#V