ukui-menu-extensions/ 0000775 0001750 0001750 00000000000 15160453541 013620 5 ustar feng feng ukui-menu-extensions/LICENSE 0000664 0001750 0001750 00000104513 15160453524 014632 0 ustar feng feng GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
ukui-menu-extensions/README.md 0000664 0001750 0001750 00000000103 15160453524 015072 0 ustar feng feng # ukui-menu-extensions
#### 介绍
ukui-menu的一些扩插件。
ukui-menu-extensions/CMakeLists.txt 0000664 0001750 0001750 00000000175 15160453524 016364 0 ustar feng feng cmake_minimum_required(VERSION 3.16)
project(ukui-menu-extensions)
add_subdirectory(recent-file)
add_subdirectory(ernie-bot)
ukui-menu-extensions/ernie-bot/ 0000775 0001750 0001750 00000000000 15160453524 015505 5 ustar feng feng ukui-menu-extensions/ernie-bot/src/ 0000775 0001750 0001750 00000000000 15160453524 016274 5 ustar feng feng ukui-menu-extensions/ernie-bot/src/message-action.cpp 0000664 0001750 0001750 00000002631 15160453524 021701 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#include "message-action.h"
#include
MessageAction::MessageAction(QObject *parent) : QObject(parent)
{
}
MessageAction::MessageAction(QString text, QString name, QObject *parent) : QObject(parent), m_text(std::move(text)), m_name(std::move(name))
{
}
void MessageAction::exec()
{
Q_EMIT actionExecuted();
}
bool MessageAction::isValid()
{
return m_text.isEmpty() && m_name.isEmpty();
}
const QString &MessageAction::text() const
{
return m_text;
}
void MessageAction::setText(const QString &text)
{
m_text = text;
}
const QString &MessageAction::name() const
{
return m_name;
}
void MessageAction::setName(const QString &name)
{
m_name = name;
}
ukui-menu-extensions/ernie-bot/src/message.cpp 0000664 0001750 0001750 00000003420 15160453524 020423 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#include "message.h"
#include
#include
Message::Message(Message::Type type, QString content, QObject *parent) : QObject(parent), m_type(type), m_content(std::move(content))
{
}
const QString &Message::content() const
{
return m_content;
}
void Message::setContent(const QString &content)
{
m_content = content;
}
const Message::Type &Message::type() const
{
return m_type;
}
void Message::setType(const Message::Type &type)
{
m_type = type;
}
const QList &Message::actions() const
{
return m_actions;
}
void Message::setAction(const QList &actions)
{
m_actions = actions;
}
const QString &Message::header() const
{
return m_header;
}
void Message::setHeader(const QString &header)
{
m_header = header;
}
QHash Message::roleNames()
{
QHash hash;
hash.insert(MessageType, "type");
hash.insert(MessageHeader, "header");
hash.insert(MessageContent, "content");
hash.insert(MessageActions, "actions");
return hash;
}
ukui-menu-extensions/ernie-bot/src/session-manager.h 0000664 0001750 0001750 00000003412 15160453524 021540 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#ifndef ERNIE_BOT_SESSION_MANAGER_H
#define ERNIE_BOT_SESSION_MANAGER_H
#include
#include
#include
#include
// TODO: 更优雅的实现?
#include "chat.h"
class QSettings;
class Session;
class SessionManager : public QObject
{
Q_OBJECT
Q_PROPERTY(bool apiReady READ apiReady NOTIFY apiReadyChanged)
public:
explicit SessionManager(QObject *parent = nullptr);
bool apiReady() const;
public Q_SLOTS:
int newSession();
QVariantList sessionIds();
Session *getSession(int sessionId) const;
void checkApiReady();
void exitSessionApi();
void setSessionKeys(const QString& key, const QString& secret);
Q_SIGNALS:
void sessionAdded(int sessionId);
void sessionRemoved(int sessionId);
void apiReadyChanged();
void apiError(QString error);
private:
bool m_apiReady = false;
QPointer m_chat;
QString m_key;
QString m_secret;
QSettings *m_settings {nullptr};
QMap m_sessions;
};
#endif //ERNIE_BOT_SESSION_MANAGER_H
ukui-menu-extensions/ernie-bot/src/message.h 0000664 0001750 0001750 00000003456 15160453524 020101 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#ifndef ERNIE_BOT_MESSAGE_H
#define ERNIE_BOT_MESSAGE_H
#include
#include
#include "message-action.h"
class Message : public QObject
{
Q_OBJECT
public:
enum Type {
TipMessage = 0,
LoadTipMessage,
TimeMessage,
SentMessage,
ReceivedMessage,
ErrorMessage
};
Q_ENUM(Type)
enum Key {
MessageType,
MessageHeader,
MessageContent,
MessageActions
};
Q_ENUM(Key)
static QHash roleNames();
Message(Type type, QString content, QObject *parent = nullptr);
const QString &content() const;
void setContent(const QString &content);
const QString &header() const;
void setHeader(const QString &header);
const Type &type() const;
void setType(const Type &type);
const QList &actions() const;
void setAction(const QList &actions);
private:
Type m_type {SentMessage};
QString m_header;
QString m_content;
QList m_actions;
};
#endif //ERNIE_BOT_MESSAGE_H
ukui-menu-extensions/ernie-bot/src/session-manager.cpp 0000664 0001750 0001750 00000010025 15160453524 022071 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*
*/
#include "session-manager.h"
#include "session.h"
#include
#include
#include
#include
#include
SessionManager::SessionManager(QObject *parent) : QObject(parent)
{
qRegisterMetaType("Session*");
qRegisterMetaType("MessageAction*");
qmlRegisterUncreatableType("org.ukui.menu.aiAssistant", 1, 0, "Message", "Enum");
QString path(QDir::homePath() + "/.config/ukui-menu/ai-assistant/");
if (!QDir(path).exists()) {
QDir().mkpath(path);
}
path += "ai-assistant.conf";
if (!QFile::exists(path)) {
QFile file(path);
file.open(QFile::WriteOnly);
file.close();
}
QSettings *settings = new QSettings(path, QSettings::IniFormat);
settings->sync();
settings->beginGroup("Api Setting");
QStringList keys = settings->allKeys();
if (settings->contains("key")) {
m_key = settings->value("key").toString();
}
if (settings->contains("secret")) {
m_secret = settings->value("secret").toString();
}
settings->endGroup();
m_settings = settings;
}
Session *SessionManager::getSession(int sessionId) const
{
return m_sessions.value(sessionId, nullptr);
}
int SessionManager::newSession()
{
if (!m_apiReady) {
return -1;
}
int sessionId = m_sessions.isEmpty() ? 0 : m_sessions.lastKey() + 1;
auto session = new Session(sessionId, m_key, m_secret, this);
m_sessions.insert(sessionId, session);
session->openChatSession();
Q_EMIT sessionAdded(sessionId);
return sessionId;
}
QVariantList SessionManager::sessionIds()
{
QVariantList list;
QMutableMapIterator iterator(m_sessions);
while (iterator.hasNext()) {
iterator.next();
list << iterator.key();
}
return list;
}
void SessionManager::setSessionKeys(const QString& key, const QString& secret)
{
if (m_apiReady || key.isEmpty() || secret.isEmpty()) {
return;
}
m_key = key;
m_secret = secret;
m_settings->beginGroup("Api Setting");
m_settings->setValue("key", m_key);
m_settings->setValue("secret", m_secret);
m_settings->endGroup();
checkApiReady();
}
bool SessionManager::apiReady() const
{
return m_apiReady;
}
void SessionManager::checkApiReady()
{
if (m_key.isEmpty() || m_secret.isEmpty() || m_chat || m_apiReady) {
return;
}
Chat *chat = new Chat(this);
connect(chat, &Chat::readyToChat, this, [this, chat] {
chat->deleteLater();
m_apiReady = true;
Q_EMIT apiReadyChanged();
});
connect(chat, &Chat::error, this, [this, chat] (const QString &errorMsg) {
chat->deleteLater();
Q_EMIT apiError(errorMsg);
});
m_chat = chat;
chat->newChat(m_key, m_secret);
}
void SessionManager::exitSessionApi()
{
QList keys = m_sessions.keys();
for (const auto &id : keys) {
Session *session = m_sessions.take(id);
if (session) {
Q_EMIT sessionRemoved(id);
delete session;
}
}
m_key = "";
m_secret = "";
m_settings->beginGroup("Api Setting");
m_settings->setValue("key", "");
m_settings->setValue("secret", "");
m_settings->endGroup();
m_apiReady = false;
Q_EMIT apiReadyChanged();
}
ukui-menu-extensions/ernie-bot/src/chat.h 0000664 0001750 0001750 00000003212 15160453524 017362 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: iaom
*/
#ifndef UKUI_MENU_CHAT_H
#define UKUI_MENU_CHAT_H
#include
class ChatPrivate;
class Chat : public QObject
{
Q_OBJECT
public:
explicit Chat(QObject *parent = nullptr);
Q_DISABLE_COPY(Chat)
/**
* 开启一个新会话
* @param clientId
* @param clientSecret
* @return
*/
void newChat(const QString &clientId = {}, const QString &clientSecret = {});
/**
* 清除对话历史
* @return
*/
void clear();
/**
* @brief 检查访问是否有效
*/
bool isValid() const;
public Q_SLOTS:
/**
* @brief 发送用户消息
* @param content 用户输入的对话内容
*/
void talk(const QString& content);
Q_SIGNALS:
void readyToChat();
void response(const QString& content);
void expired();
void error(const QString &errorMsg);
private:
ChatPrivate *d = nullptr;
};
#endif //UKUI_MENU_CHAT_H
ukui-menu-extensions/ernie-bot/src/chat.cpp 0000664 0001750 0001750 00000015311 15160453524 017720 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: iaom
*/
#include "chat.h"
#include
#include
#include
#include
#include
#include
#include
#include
// 百度文心API端点定义
static const QString ERNIEBOT("https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions");
static const QString ERNIEBOT_TURBO("https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant");
static const QString GET_TOKEN_URL("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials");
/**
* @brief 对话功能的私有实现类
* @details 封装网络请求细节,实现数据与接口分离
*/
class ChatPrivate: public QObject {
friend class Chat;
Q_OBJECT
explicit ChatPrivate(QObject *parent = nullptr);
private Q_SLOTS:
/**
* @brief 处理获取访问令牌的响应
* @param reply 网络响应对象
*/
void onGetAccessTokenReply(QNetworkReply *reply);
/**
* @brief 处理对话API响应
* @param reply 包含响应数据的网络对象
*/
void onResponse(QNetworkReply *reply);
private:
QNetworkAccessManager *m_nm = nullptr;
QString m_accessToken;
QDateTime m_tokenGetTime;
int m_tokenExpiresIn = 0;
QJsonArray m_cache;
bool m_isWaitingForToken = false;
bool m_isWaitingForResponse = false;
Chat *q = nullptr;
};
ChatPrivate::ChatPrivate(QObject *parent) : QObject(parent)
{
q = qobject_cast(parent);
}
void ChatPrivate::onGetAccessTokenReply(QNetworkReply *reply)
{
if(reply->error() != QNetworkReply::NoError) {
Q_EMIT q->error(reply->errorString());
qWarning() << reply->errorString();
m_isWaitingForToken = false;
return;
}
QJsonParseError errRpt{};
QJsonDocument jsonDocument(QJsonDocument::fromJson(reply->readAll(), &errRpt));
if (errRpt.error == QJsonParseError::NoError) {
QJsonObject replyObject = jsonDocument.object();
QString error = replyObject.value("error").toString();
if(!error.isEmpty()) {
qWarning() << "Get access token error:" << error << replyObject.value("error_description").toString();
Q_EMIT q->error(replyObject.value("error_description").toString());
} else {
m_accessToken = replyObject.value("access_token").toString();
m_tokenExpiresIn = replyObject.value("expires_in").toInt();
m_tokenGetTime = QDateTime::currentDateTime();
qDebug() << m_accessToken << m_tokenExpiresIn << m_tokenGetTime;
connect(m_nm, &QNetworkAccessManager::finished, this, &ChatPrivate::onResponse);
Q_EMIT q->readyToChat();
}
} else {
Q_EMIT q->error(errRpt.errorString());
qWarning() << "Parse error at GetAccessTokenReply" << errRpt.errorString();
}
reply->deleteLater();
m_isWaitingForToken = false;
}
void ChatPrivate::onResponse(QNetworkReply *reply)
{
if(reply->error() != QNetworkReply::NoError) {
qWarning() << reply->errorString();
m_cache.removeLast();
Q_EMIT q->error(reply->errorString());
} else {
QJsonParseError errRpt{};
QJsonDocument jsonDocument(QJsonDocument::fromJson(reply->readAll(), &errRpt));
if (errRpt.error == QJsonParseError::NoError) {
QJsonObject replyObject = jsonDocument.object();
QString error = replyObject.value("error_code").toString();
if(!error.isEmpty()) {
qWarning() << "Response error:" << error << replyObject.value("error_msg").toString();
m_cache.removeLast();
Q_EMIT q->error(replyObject.value("error_msg").toString());
} else {
const QString &result = replyObject.value("result").toString();
QJsonObject tmp;
tmp.insert("content", result);
tmp.insert("role", "assistant");
m_cache.append(tmp);
Q_EMIT q->response(result);
}
} else {
m_cache.removeLast();
Q_EMIT q->error(errRpt.errorString());
qWarning() << "Parse error at onResponse" << errRpt.errorString();
}
}
m_isWaitingForResponse = false;
reply->deleteLater();
}
Chat::Chat(QObject *parent) : QObject(parent), d(new ChatPrivate(this))
{
d->m_nm = new QNetworkAccessManager(this);
connect(d->m_nm, &QNetworkAccessManager::finished, d, &ChatPrivate::onResponse);
}
void Chat::newChat(const QString &clientId, const QString &clientSecret)
{
if(d->m_isWaitingForToken) {
return;
}
disconnect(d->m_nm, &QNetworkAccessManager::finished, d, &ChatPrivate::onResponse);
QNetworkRequest request(QUrl(GET_TOKEN_URL + "&client_id=" + clientId + "&client_secret=" + clientSecret));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QNetworkReply *reply = d->m_nm->post(request, "");
d->m_isWaitingForToken = true;
QObject::connect(reply, &QNetworkReply::finished, [reply, this](){
d->onGetAccessTokenReply(reply);
});
}
bool Chat::isValid() const
{
return d->m_tokenExpiresIn >= d->m_tokenGetTime.secsTo(QDateTime::currentDateTime());
}
void Chat::clear()
{
QJsonArray tmp;
d->m_cache.swap(tmp);
}
void Chat::talk(const QString &content)
{
if(d->m_isWaitingForResponse) {
qWarning() << "Waiting for response, please try later.";
return;
}
if(!isValid()) {
Q_EMIT this->expired();
return;
}
QJsonObject tmp;
tmp.insert("content", content);
tmp.insert("role", "user");
d->m_cache.append(tmp);
QNetworkRequest request(ERNIEBOT + "?access_token=" + d->m_accessToken);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QJsonObject body;
body.insert("messages", d->m_cache);
qDebug() << "post"<< QJsonDocument(body).toJson();
d->m_nm->post(request, QJsonDocument(body).toJson());
d->m_isWaitingForResponse = true;
}
#include "chat.moc"
ukui-menu-extensions/ernie-bot/src/ernie-bot.h 0000664 0001750 0001750 00000003244 15160453524 020334 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#ifndef ERNIE_BOT_ERNIE_BOT_H
#define ERNIE_BOT_ERNIE_BOT_H
#include
#include
class ErnieBotPrivate;
class ErnieBotPlugin : public UkuiMenu::MenuExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_MENU_EXTENSION_I_FACE_IID FILE "metadata.json")
Q_INTERFACES(UkuiMenu::MenuExtensionPlugin)
public:
~ErnieBotPlugin() override;
QString id() override;
UkuiMenu::WidgetExtension *createWidgetExtension() override;
UkuiMenu::ContextMenuExtension *createContextMenuExtension() override;
};
class ErnieBot : public UkuiMenu::WidgetExtension
{
Q_OBJECT
public:
explicit ErnieBot(QObject *parent = nullptr);
int index() const override;
UkuiMenu::MetadataMap metadata() const override;
QVariantMap data() override;
void receive(const QVariantMap &data) override;
private:
ErnieBotPrivate *d {nullptr};
};
#endif //ERNIE_BOT_ERNIE_BOT_H
ukui-menu-extensions/ernie-bot/src/ernie-bot.cpp 0000664 0001750 0001750 00000006371 15160453524 020673 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#include "ernie-bot.h"
#include "message-model.h"
#include "session-manager.h"
#include
#include
#include
class ErnieBotPrivate
{
public:
UkuiMenu::MetadataMap metadata;
MessageModel *model {nullptr};
SessionManager *sessionManager {nullptr};
};
ErnieBot::ErnieBot(QObject *parent) : WidgetExtension(parent), d(new ErnieBotPrivate)
{
QString translationFile("/usr/share/ukui-menu/extensions/translations/ernie-bot_" + QLocale::system().name() + ".qm");
if (QFile::exists(translationFile)) {
auto translator = new QTranslator(this);
translator->load(translationFile);
QCoreApplication::installTranslator(translator);
}
d->metadata.insert(UkuiMenu::WidgetMetadata::Id, "ernie-bot");
d->metadata.insert(UkuiMenu::WidgetMetadata::Name, tr("AI Assistant"));
d->metadata.insert(UkuiMenu::WidgetMetadata::Tooltip, tr("AI Assistant"));
d->metadata.insert(UkuiMenu::WidgetMetadata::Version, "1.0.0");
d->metadata.insert(UkuiMenu::WidgetMetadata::Description, "ernie-bot");
d->metadata.insert(UkuiMenu::WidgetMetadata::Main, "qrc:///ernie-bot/content/ui/Main.qml");
d->metadata.insert(UkuiMenu::WidgetMetadata::Type, UkuiMenu::WidgetMetadata::Widget);
d->metadata.insert(UkuiMenu::WidgetMetadata::Flag, UkuiMenu::WidgetMetadata::OnlySmallScreen);
qRegisterMetaType("MessageModel*");
d->sessionManager = new SessionManager(this);
d->model = new MessageModel(this);
connect(d->sessionManager, &SessionManager::sessionAdded, this, [this] (int sessionId) {
d->model->setSession(d->sessionManager->getSession(sessionId));
});
connect(d->sessionManager, &SessionManager::sessionRemoved, this, [this] (int sessionId) {
d->model->removeSession(sessionId);
});
}
int ErnieBot::index() const
{
return 100;
}
UkuiMenu::MetadataMap ErnieBot::metadata() const
{
return d->metadata;
}
QVariantMap ErnieBot::data()
{
QVariantMap data;
data.insert("messageModel", QVariant::fromValue(d->model));
data.insert("sessionManager", QVariant::fromValue(d->sessionManager));
return data;
}
void ErnieBot::receive(const QVariantMap &data)
{
d->model->talk(data.value("message").toString());
}
ErnieBotPlugin::~ErnieBotPlugin()
{
}
QString ErnieBotPlugin::id()
{
return "ernie-bot";
}
UkuiMenu::WidgetExtension *ErnieBotPlugin::createWidgetExtension()
{
return new ErnieBot;
}
UkuiMenu::ContextMenuExtension *ErnieBotPlugin::createContextMenuExtension()
{
return nullptr;
}
ukui-menu-extensions/ernie-bot/src/session.h 0000664 0001750 0001750 00000005301 15160453524 020127 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#ifndef UKUI_MENU_EXTENSIONS_SESSION_H
#define UKUI_MENU_EXTENSIONS_SESSION_H
#include
#include
#include
#include "message.h"
class SessionPrivate;
class Session : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int sessionId READ sessionId)
Q_PROPERTY(bool sessionIsReady READ sessionIsReady NOTIFY sessionIsReadyChanged)
Q_PROPERTY(bool responseIsReady READ responseIsReady NOTIFY responseIsReadyChanged)
Q_PROPERTY(QString sessionName READ sessionName NOTIFY sessionNameChanged)
Q_PROPERTY(QDateTime lastTalkTime READ lastTalkTime NOTIFY lastTalkTimeChanged)
public:
explicit Session(int sessionId, const QString& key, const QString& secret, QObject *parent = nullptr);
~Session() override;
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QHash roleNames() const override;
int sessionId() const;
bool sessionIsReady() const;
bool responseIsReady() const;
QString sessionName() const;
const QDateTime &lastTalkTime() const;
void openChatSession();
Q_SIGNALS:
void sessionIsReadyChanged();
void responseIsReadyChanged();
void lastTalkTimeChanged();
void sessionNameChanged();
public Q_SLOTS:
void talk(const QString &message);
void appendMessage(Message *message);
void exportSession();
void clearSession();
void exitSession();
private Q_SLOTS:
void onReadyToChat();
void onResponse(const QString& content);
void onError(const QString& error);
private:
void setSessionIsReady(bool isReady);
void setResponseIsReady(bool isReady);
void updateTalkTime();
private:
bool m_sessionIsReady {false};
bool m_responseIsReady {true};
int m_sessionId {-1};
QString m_key;
QString m_secret;
SessionPrivate *d;
QVector m_messages;
QDateTime m_lastTalkTime;
};
#endif //UKUI_MENU_EXTENSIONS_SESSION_H
ukui-menu-extensions/ernie-bot/src/message-action.h 0000664 0001750 0001750 00000003012 15160453524 021340 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#ifndef ERNIE_BOT_MESSAGE_ACTION_H
#define ERNIE_BOT_MESSAGE_ACTION_H
#include
class MessageAction : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString text READ text NOTIFY textChanged)
public:
MessageAction() = delete;
explicit MessageAction(QObject *parent = nullptr);
MessageAction(QString text, QString name, QObject *parent = nullptr);
const QString &text() const;
void setText(const QString &text);
const QString &name() const;
void setName(const QString &name);
public Q_SLOTS:
void exec();
bool isValid();
Q_SIGNALS:
void nameChanged();
void textChanged();
void actionExecuted();
private:
QString m_text;
QString m_name;
};
#endif //ERNIE_BOT_MESSAGE_ACTION_H
ukui-menu-extensions/ernie-bot/src/metadata.json 0000664 0001750 0001750 00000000076 15160453524 020752 0 ustar feng feng {
"Type": "UKUI_MENU_EXTENSION",
"Version": "1.0.2"
}
ukui-menu-extensions/ernie-bot/src/message-model.cpp 0000664 0001750 0001750 00000003031 15160453524 021517 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#include "message-model.h"
#include "session.h"
#include
#include
MessageModel::MessageModel(QObject *parent) : QSortFilterProxyModel(parent)
{
}
void MessageModel::talk(const QString &message)
{
if (!m_session) {
return;
}
m_session->talk(message);
}
void MessageModel::setSession(Session *session)
{
if (session == m_session) {
return;
}
beginResetModel();
m_session = session;
setSourceModel(session);
endResetModel();
Q_EMIT currentSessionIdChanged();
}
void MessageModel::removeSession(int sessionId)
{
if (m_session && sessionId == m_session->sessionId()) {
setSession(nullptr);
}
}
int MessageModel::currentSessionId() const
{
if (m_session) {
return m_session->sessionId();
}
return -1;
}
ukui-menu-extensions/ernie-bot/src/session.cpp 0000664 0001750 0001750 00000016557 15160453524 020501 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#include "session.h"
#include "chat.h"
class SessionPrivate
{
friend class Session;
public:
explicit SessionPrivate(Session *parent = nullptr) : chat(new Chat(parent)) {}
private:
Chat *chat {nullptr};
};
Session::Session(int sessionId, const QString& key, const QString& secret, QObject *parent)
: QAbstractListModel(parent), d(new SessionPrivate(this)), m_sessionId(sessionId), m_key(key), m_secret(secret)
{
connect(d->chat, &Chat::readyToChat, this, &Session::onReadyToChat);
connect(d->chat, &Chat::response, this, &Session::onResponse);
connect(d->chat, &Chat::error, this, &Session::onError);
connect(d->chat, &Chat::expired, this, [this] {
setSessionIsReady(false);
openChatSession();
});
// append tip message
auto message = new Message(Message::TipMessage, tr("You can try asking me:"), this);
int hour = QTime::currentTime().hour();
QString hello;
if (hour < 0) {
hello = tr("How are you today!");
}
else if (hour < 13) {
hello = tr("Good morning!");
}
else {
hello = tr("Good afternoon!");
}
message->setHeader(tr("Hi, %1").arg(hello));
auto action1 = new MessageAction(tr("What can AI do?"), tr("Give it a try"), message);
auto action2 = new MessageAction(tr("Help me write a product requirements document."), tr("Give it a try"), message);
auto action3 = new MessageAction(tr("What gift to give on Mother's Day is more intentional?"), tr("Give it a try"), message);
message->setAction({action1, action2, action3});
connect(action1, &MessageAction::actionExecuted, this, [this, action1] {
talk(action1->text());
});
connect(action2, &MessageAction::actionExecuted, this, [this, action2] {
talk(action2->text());
});
connect(action3, &MessageAction::actionExecuted, this, [this, action3] {
talk(action3->text());
});
appendMessage(message);
}
int Session::rowCount(const QModelIndex &parent) const
{
return m_messages.size();
}
QVariant Session::data(const QModelIndex &index, int role) const
{
if (!checkIndex(index, CheckIndexOption::IndexIsValid)) {
return {};
}
int messageIndex = index.row();
switch (role) {
case Message::MessageType:
return m_messages.at(messageIndex)->type();
case Message::MessageContent:
return m_messages.at(messageIndex)->content();
case Message::MessageHeader:
return m_messages.at(messageIndex)->header();
case Message::MessageActions: {
QVariantList list;
QListIterator iterator(m_messages.at(messageIndex)->actions());
while (iterator.hasNext()) {
list << QVariant::fromValue(iterator.next());
}
return list;
}
default:
break;
}
return {};
}
QHash Session::roleNames() const
{
return Message::roleNames();
}
int Session::sessionId() const
{
return m_sessionId;
}
bool Session::sessionIsReady() const
{
return m_sessionIsReady;
}
bool Session::responseIsReady() const
{
return m_responseIsReady;
}
QString Session::sessionName() const
{
return tr("Session: %1").arg(m_sessionId);
}
const QDateTime &Session::lastTalkTime() const
{
return m_lastTalkTime;
}
void Session::openChatSession()
{
if (d->chat && !m_sessionIsReady) {
d->chat->newChat(m_key, m_secret);
}
}
void Session::talk(const QString &message)
{
if (message.isEmpty() || !m_sessionIsReady || !m_responseIsReady || !d->chat) {
return;
}
// 过滤特殊字符
QString msg(message);
msg.replace("<", "<");
msg.replace(">", ">");
updateTalkTime();
setResponseIsReady(false);
appendMessage(new Message(Message::SentMessage, msg, this));
appendMessage(new Message(Message::LoadTipMessage, "", this));
d->chat->talk(msg);
}
void Session::appendMessage(Message *message)
{
beginInsertRows(QModelIndex(), m_messages.size(), m_messages.size());
m_messages.append(message);
endInsertRows();
}
void Session::exportSession()
{
// TODO: 导出全部消息到文件
}
void Session::clearSession()
{
if (!m_sessionIsReady || !m_responseIsReady || !d->chat) {
return;
}
int rows = m_messages.size() - 1;
beginRemoveRows(QModelIndex(), 1, rows);
m_lastTalkTime = QDateTime();
for (int i = rows; i > 0; --i) {
delete m_messages.takeAt(i);
}
d->chat->clear();
endRemoveRows();
}
void Session::exitSession()
{
setSessionIsReady(false);
setResponseIsReady(false);
}
void Session::onReadyToChat()
{
setSessionIsReady(true);
}
void Session::onResponse(const QString &content)
{
setResponseIsReady(true);
if (!m_messages.isEmpty() && m_messages.last()->type() == Message::LoadTipMessage) {
m_messages.last()->setType(Message::ReceivedMessage);
m_messages.last()->setContent(content);
QModelIndex index = Session::index(m_messages.size() - 1);
dataChanged(index, index);
} else {
appendMessage(new Message(Message::ReceivedMessage, content, this));
}
}
void Session::onError(const QString &error)
{
if (!m_messages.isEmpty() && m_messages.last()->type() == Message::LoadTipMessage) {
beginRemoveRows(QModelIndex(), m_messages.size(), m_messages.size());
delete m_messages.takeLast();
endRemoveRows();
}
auto message = new Message(Message::ErrorMessage, "Error: " + error, this);
if (!m_sessionIsReady) {
message->setContent(tr("The current network is not good, please check the network.\n\nError: ") + error);
QList actions;
auto action = new MessageAction("retry", tr("Retry"), message);
actions << action;
connect(actions.last(), &MessageAction::actionExecuted, this, [this, action] {
openChatSession();
});
message->setAction(actions);
}
appendMessage(message);
setResponseIsReady(true);
}
void Session::setSessionIsReady(bool isReady)
{
m_sessionIsReady = isReady;
Q_EMIT sessionIsReadyChanged();
}
void Session::setResponseIsReady(bool isReady)
{
m_responseIsReady = isReady;
Q_EMIT responseIsReadyChanged();
}
void Session::updateTalkTime()
{
QDateTime currentTime = QDateTime::currentDateTime();
if (m_lastTalkTime.isValid() && (m_lastTalkTime.secsTo(currentTime) < 5 * 60)) {
return;
}
m_lastTalkTime = currentTime;
appendMessage(new Message(Message::TimeMessage, m_lastTalkTime.toString("hh:mm"), this));
}
Session::~Session()
{
exitSession();
if (d) {
delete d;
d = nullptr;
}
}
ukui-menu-extensions/ernie-bot/src/message-model.h 0000664 0001750 0001750 00000002565 15160453524 021177 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
#ifndef ERNIE_BOT_MESSAGE_MODEL_H
#define ERNIE_BOT_MESSAGE_MODEL_H
#include
#include
class Session;
class MessageModel : public QSortFilterProxyModel
{
Q_OBJECT
Q_PROPERTY(int currentSessionId READ currentSessionId NOTIFY currentSessionIdChanged)
public:
explicit MessageModel(QObject *parent = nullptr);
void removeSession(int sessionId);
int currentSessionId() const;
Q_SIGNALS:
void currentSessionIdChanged();
public Q_SLOTS:
void setSession(Session *session);
void talk(const QString &message);
private:
Session *m_session {nullptr};
};
#endif //ERNIE_BOT_MESSAGE_MODEL_H
ukui-menu-extensions/ernie-bot/translations/ 0000775 0001750 0001750 00000000000 15160453524 020226 5 ustar feng feng ukui-menu-extensions/ernie-bot/translations/ernie-bot_mn_MN.ts 0000664 0001750 0001750 00000014715 15160453524 023556 0 ustar feng feng
ErnieBotAI AssistantAI ᠬᠠᠪᠰᠤᠷᠤᠭᠴᠢMessageBarCopyᠺᠤᠫᠢᠳᠠᠬᠤMessageInputYou can ask me any questions~ᠴᠢ ᠨᠠᠳᠠ ᠠᠴᠠ ᠶᠠᠮᠠᠷ ᠴᠤ ᠠᠰᠠᠭᠤᠳᠠᠯ ᠢ ᠠᠰᠠᠭᠤᠵᠤ ᠪᠣᠯᠣᠨᠠ ~SessionYou can try asking me:ᠴᠢ ᠨᠠᠳᠠ ᠠᠴᠠ ᠠᠰᠠᠭᠤᠬᠤ ᠪᠠᠷ ᠲᠤᠷᠰᠢᠵᠤ ᠪᠣᠯᠣᠨᠠHow are you today!ᠴᠢ ᠥᠨᠥᠳᠥᠷ ᠶᠠᠮᠠᠷ ᠰᠢᠤ ᠰᠠᠨᠠᠭᠳᠠᠵᠤ ᠪᠠᠢ᠌ᠨᠠ !Good morning!ᠡᠷᠲᠡ ᠶᠢᠨ ᠮᠡᠨᠳᠦ!Good afternoon!ᠦᠳᠡ ᠶᠢᠨ ᠬᠣᠢ᠌ᠨᠠ ᠰᠠᠢ᠌ᠨ !Hi, %1Hi, %1What can AI do?AI ᠶᠠᠭᠤ ᠬᠢᠵᠦ ᠪᠣᠯᠬᠤ ᠪᠤᠢ ?Give it a tryᠲᠤᠷᠰᠢᠵᠤ ᠦᠵᠡᠶᠡHelp me write a product requirements document.ᠨᠠᠳᠠᠳᠤ ᠨᠢᠭᠡ ᠬᠣᠪᠢ ᠦᠢᠯᠡᠳᠬᠦᠨ ᠦ ᠬᠡᠷᠡᠭ᠍ᠴᠡᠭᠡ ᠱᠠᠭᠠᠷᠳᠠᠯᠭᠠ ᠶᠢᠨ ᠪᠢᠴᠢᠭ᠌ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠪᠢᠴᠢWhat gift to give on Mother's Day is more intentional?ᠡᠵᠢ ᠶᠢᠨ ᠪᠠᠶᠠᠷ ᠲᠤ ᠶᠠᠮᠠᠷ ᠪᠡᠯᠡᠭ ᠬᠦᠷᠭᠡᠬᠦ ᠨᠢ ᠨᠡᠩ ᠰᠡᠳᠭᠢᠯ ᠲᠠᠯᠪᠢᠬᠤ ᠪᠤᠢ ?Session: %1ᠬᠤᠷᠠᠯ ᠤᠨ ᠦᠭᠡ ᠄ %1The current network is not good, please check the network.
Error: ᠣᠳᠣᠬᠠᠨ ᠳᠤ ᠰᠦᠯᠵᠢᠶᠡ ᠮᠠᠭᠤ ᠪᠠᠶᠢᠨᠠ᠂ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠦ ᠬᠣᠯᠪᠣᠯᠲᠠ ᠶᠢ ᠪᠠᠶᠢᠴᠠᠭᠠᠬᠤ ᠪᠣᠯᠪᠠᠤ᠃
Error: Retryᠳᠠᠬᠢᠵᠤ ᠨᠢᠬᠡ ᠳᠤᠷᠱᠢᠭᠠᠷᠠᠢSessionLoginPageAi AssistantAi ᠬᠠᠪᠰᠤᠷᠤᠭᠴᠢAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.AI ᠬᠠᠪᠰᠤᠷᠤᠭᠴᠢ ᠪᠣᠯ ᠬᠥᠮᠦᠨ ᠦ ᠬᠦᠴᠦᠨ ᠦ ᠶᠡᠬᠡ ᠬᠡᠯᠡᠨ ᠦ ᠵᠠᠭᠪᠤᠷ ᠂ ᠬᠡᠪ ᠵᠠᠭᠪᠤᠷ ᠠᠯᠤᠰᠯᠠᠭᠰᠠᠨ ᠂ ᠦᠭᠡ ᠠᠯᠤᠰᠯᠠᠭᠰᠠᠨ ᠭᠦᠨ ᠬᠡᠯᠡᠨ ᠦ ᠤᠳᠬᠠ ᠶᠢᠨ ᠣᠶᠢᠯᠠᠭᠠᠯᠲᠠ ᠪᠣᠯᠣᠨ ᠪᠤᠶ ᠪᠣᠯᠬᠤ ᠴᠢᠳᠠᠪᠤᠷᠢ ᠲᠠᠶ ᠂ ᠲᠠᠪᠤᠨ ᠶᠡᠬᠡ ᠴᠢᠳᠠᠪᠤᠷᠢ ᠲᠠᠶ ᠂ ᠤᠳᠬᠠ ᠵᠣᠬᠢᠶᠠᠯ ᠵᠣᠬᠢᠶᠠᠨ ᠪᠦᠲᠦᠭᠡᠬᠦ ᠂ ᠬᠤᠳᠠᠯᠳᠤᠭᠠᠨ ᠤ ᠪᠢᠴᠢᠭ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠤᠨ ᠲᠥᠰᠥᠯ ᠢ ᠵᠣᠬᠢᠶᠠᠨ ᠪᠦᠲᠦᠭᠡᠬᠦ ᠂ ᠲᠣᠭᠠ ᠶᠢᠨ ᠤᠬᠠᠭᠠᠨ ᠯᠣᠭᠢᠭ ᠤᠨ ᠪᠤᠲᠤᠯᠲᠠ ᠂ ᠬᠢᠲᠠᠳ ᠬᠡᠯᠡᠨ ᠤ ᠤᠶᠢᠯᠠᠭᠠᠯᠲᠠ ᠂ ᠤᠯᠠᠨ ᠵᠠᠭᠪᠤᠷ ᠠᠮᠢ ᠠᠬᠤᠢ ᠠᠮᠢᠲᠤᠷᠠᠯ ᠪᠦᠲᠦᠭᠰᠡᠨ ᠪᠦᠭᠡᠳ ᠲᠡᠭᠦᠨ ᠤ ᠡᠷᠢᠯᠲᠡ ᠶᠢᠨ ᠠᠰᠠᠭᠤᠯᠲᠠ ᠬᠠᠷᠢᠭᠤᠯᠬᠤ ᠂ ᠠᠭᠤᠯᠭᠠ ᠶᠢᠨ ᠵᠤᠭᠢᠶᠠᠨ ᠪᠦᠲᠦᠬᠡᠭᠦ ᠂ ᠤᠶᠤᠨᠴᠢ ᠪᠡᠷ ᠠᠵᠢᠯᠯᠠᠬᠤ ᠵᠡᠷᠬᠡ ᠤᠯᠠᠨ ᠬᠦᠷᠢᠶᠡᠨ ᠳᠤ ᠨᠡᠩ ᠦᠷᠬᠡᠨ ᠠᠭᠤᠲᠠᠮ ᠪᠤᠲᠤᠯᠭᠢᠯᠠᠬᠤ ᠤᠷᠤᠨ ᠵᠠᠢ ᠲᠠᠢ ᠪᠠᠶᠢᠲᠠᠭ ᠃Input API KeyAPI ᠺᠧᠷᠦ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠤᠨᠠInput Secret KeySecret ᠺᠧᠷᠦ ᠶᠢ ᠣᠷᠣᠭᠤᠯᠤᠨᠠConfirmᠪᠠᠳᠤᠯᠠᠬᠤSessionPageSelect Sessionᠬᠤᠷᠠᠯ ᠤᠨ ᠦᠭᠡ ᠶᠢ ᠰᠣᠩᠭᠣᠨᠠNew Sessionᠰᠢᠨᠡ ᠪᠡᠷ ᠪᠠᠢ᠌ᠭᠤᠯᠬᠤ ᠬᠤᠷᠠᠯ ᠤᠨ ᠦᠭᠡClear Sessionᠠᠭᠠᠷ ᠤᠨ ᠦᠭᠡ ᠶᠢ ᠴᠡᠪᠡᠷᠯᠡᠨᠡExit IDID ᠭᠠᠷᠤᠨᠠ
ukui-menu-extensions/ernie-bot/translations/ernie-bot_ug_CN.ts 0000664 0001750 0001750 00000012204 15160453524 023534 0 ustar feng feng
ErnieBotAI Assistantياردەمچىسى AIMessageBarCopyكۆچۈرۈشMessageInputYou can ask me any questions~مەندىن ھەرقانداق سوئال سورىسىڭىز بولىدۇ~SessionYou can try asking me::مەندىن سورىسىڭىز بولىدۇHow are you today!!بۈگۈن كەيپىياتىڭىز قانداقراقGood morning!!خەيرلىك سەھەرGood afternoon!!چۈشتىن كېيىنلىكىڭىز خەيرلىك بولسۇنHi, %1ھەي، %1What can AI do?نېمە قىلالايدۇ؟ AIGive it a tryسىناپ بېقىڭHelp me write a product requirements document.ماڭا بىر پارچە مەھسۇلات ئېھتىياج ھۆججىتى يېزىپ بېرىڭ.What gift to give on Mother's Day is more intentional?ئانىلار بايرىمىدا قانداق سوۋغات بەرسە تېخىمۇ ياخشى؟Session: %1سۆزلىشىش : %1The current network is not good, please check the network.
Error: ھازىر تور ياخشى ئەمەس ، تور ئۇلىنىشىنى تەكشۈرۈڭ.
Error: Retryقايتا سىناشSessionLoginPageAi Assistantياردەمچىسى AiAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.AI ياردەمچىسى سۈنئىي ئەقلىي ئىقتىدارلىق تىل قېلىپى بولۇپ، مودال ھالقىغان، تىل ھالقىغان چوڭقۇر سېمانتىكىلىق چۈشىنىش ۋە ھاسىل قىلىش ئىقتىدارىغا ئىگە، ئەدەبىيات ئىجادىيىتى، سودا يېزىقچىلىق ئىجادىيىتى، ماتېماتىكىلىق لوگىكىلىق ھېسابلاش، دۆلەت تىلىدا چۈشىنىش، كۆپ مودال ھاسىل قىلىشتىن ئىبارەت بەش چوڭ ئىقتىدارى بار، سوئال-جاۋاپ ئىزدەش، مەزمۇن ئىجادىيىتى ھاسىل قىلىش، ئەقلىي ئىقتىدارلىق ئىش بېجىرىش قاتارلىق نۇرغۇنلىغان ساھەلەردە تېخىمۇ كەڭ تەسەۋۋۇر بوشلۇقىغا ئىگە.Input API Keyنى كىرگۈزۈڭ APIKeyInput Secret Keyنى كىرگۈزۈڭ Secret KeyConfirmجەزملەشتۈرۈشSessionPageSelect Sessionسۆزلىشىشنى تاللاشNew Sessionيېڭىدىن سۆزلىشىشClear Sessionسۆزلىشىشنى بىكار قىلىشExit IDدىن چېكىنىش ID
ukui-menu-extensions/ernie-bot/translations/ernie-bot_zh_HK.ts 0000664 0001750 0001750 00000007417 15160453524 023556 0 ustar feng feng
ErnieBotAI AssistantMessageBarCopy複製MessageInputYou can ask me any questions~SessionYou can try asking me:How are you today!Good morning!Good afternoon!Hi, %1What can AI do?Give it a tryHelp me write a product requirements document.What gift to give on Mother's Day is more intentional?Session: %1The current network is not good, please check the network.
Error: Retry重試SessionLoginPageAi AssistantAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.Input API KeyInput Secret KeyConfirm確定SessionPageSelect SessionNew SessionClear SessionExit ID
ukui-menu-extensions/ernie-bot/translations/ernie-bot_de_DE.ts 0000664 0001750 0001750 00000010722 15160453524 023504 0 ustar feng feng
ErnieBotAI AssistantKI-AssistentenMessageBarCopyKopierenMessageInputYou can ask me any questions~Du kannst mich alles fragen~SessionYou can try asking me:Sie können versuchen, mich zu fragen:How are you today!Wie fühlst du dich heute?Good morning!Guten Morgen!Good afternoon!Guten Tag!Hi, %1Hallo, %1What can AI do?Was kann KI?Give it a trySich die Füße nass machenHelp me write a product requirements document.Helfen Sie mir, ein Produktanforderungsdokument zu schreiben.What gift to give on Mother's Day is more intentional?Welches Geschenk sollte man am Muttertag sorgfältiger machen?Session: %1Sitzung: %1The current network is not good, please check the network.
Error: Das aktuelle Netzwerk ist nicht gut, bitte überprüfen Sie den Netzwerklink.
Fehler: RetryWiederholenSessionLoginPageAi AssistantKI-AssistentAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.Der KI-Assistent ist ein großes Sprachmodell mit künstlicher Intelligenz und verfügt über modal- und sprachübergreifende Fähigkeiten für tiefes semantisches Verständnis und Generierung, verfügt über fünf Funktionen: literarische Erstellung, Verfassen von Geschäftstexten, mathematische Logikberechnung, chinesisches Verständnis, multimodale Generierung, es hat einen breiteren Vorstellungsraum in vielen Bereichen wie Suche und Antwort, Erstellung und Generierung von Inhalten, intelligentes Büro usw.Input API KeyGeben Sie den API-Schlüssel einInput Secret KeyGeben Sie den geheimen Schlüssel einConfirmBestätigenSessionPageSelect SessionSitzungen auswählenNew SessionErstellen einer neuen SitzungClear SessionBeenden Sie die SitzungExit IDExit-ID
ukui-menu-extensions/ernie-bot/translations/ernie-bot_bo_CN.ts 0000664 0001750 0001750 00000012534 15160453524 023527 0 ustar feng feng
ErnieBotAI AssistantAIལག་རོགས་པ།MessageBarCopyའདྲ་བཟོ།MessageInputYou can ask me any questions~ཁྱོད་ཀྱིས་ང་ལ་གནད་དོན་ཅི་ཡང་དྲིས་ཆོགSessionYou can try asking me:ཁྱོད་ཀྱིས་ང་ལ་ཚོད་ལྟ་ཞིག་བྱས་ཆོགHow are you today!དེ་རིང་ཁྱོད་ཀྱི་ཚོར་སྣང་ཇི་འདྲ་རེདGood morning!ཞོགས་པ་བདེ་ལེགས།Good afternoon!ཕྱི་དྲོ་བདེ་ལེགས།Hi, %1Hi, %1What can AI do?AIཡིས་ཅི་ཞིག་བྱས་ན་འགྲིག་གམ།Give it a tryཚོད་ལྟ་ཞིག་བྱོས།Help me write a product requirements document.ང་ལ་ཐོན་རྫས་ཀྱི་དགོས་མཁོའི་ཡིག་ཚགས་ཤིག་འབྲི་རོགས།།What gift to give on Mother's Day is more intentional?ཨ་མའི་དུས་ཆེན་ལ་ལེགས་སྐྱེས་ཅི་ཞིག་སྟེར་དགོས་སམ།Session: %1ཚོགས་འདུའི་གཏམ། 1The current network is not good, please check the network.
Error: མིག་སྔར་དྲ་རྒྱ་མི་བཟང་བས་དྲ་རྒྱའི་སྦྲེལ་མཐུད་ལ་ཞིབ་བཤེར་གནང་རོགས།
Error: Retryབསྐྱར་རྒྱུགས།SessionLoginPageAi AssistantAIལག་རོགས་པ།AI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.AIལག་རོགས་པ་ནི་མིའི་བློ་རིག་གི་སྐད་ཆའི་དཔེ་དབྱིབས་ཆེན་པོ་ཡིན་པ་དང་། དཔེ་དབྱིབས་ལས་བརྒལ་བ་དང་། སྐད་ཆ་ལས་བརྒལ་བའི་གཏིང་ཟབ་པའི་ཚིག་དོན་གོ་བ་ལེན་པ་Input API KeyAPIEeཡི་ནང་འཇུག་བྱས་པ་རེད།Input Secret Keyནང་འཇུག་Secetteཡིན།Confirmགཏན་འཁེལ་བྱ་དགོས།SessionPageSelect Sessionགཏམ་གླེང་བདམས་པ།New Sessionགསར་དུ་བཙུགས་པའི་གཏམ།Clear Sessionསྐད་ཆ་སྟོང་པ་བཤད་པ།Exit IDIDཕྱིར་འཐེན་བྱས་པ།
ukui-menu-extensions/ernie-bot/translations/ernie-bot_ky_KG.ts 0000664 0001750 0001750 00000012365 15160453524 023555 0 ustar feng feng
ErnieBotAI Assistantجاردامچىسى AIMessageBarCopyگۅچۉرۉشMessageInputYou can ask me any questions~مەندەن ارقانداي سۇروو سورىسىڭىز بولوت ~SessionYou can try asking me::مەندەن سورىسىڭىز بولوتHow are you today!!بۉگۉن كەيپىياتىڭىز قانداقراقGood morning!!خەيرلىك سەھەرGood afternoon!!تۉشتۅن كېيىنلىكىڭىز خەيرلىك بولسۇنHi, %1اي، %1What can AI do?ەمنە قىلا الات؟ AIGive it a tryسىناپ باعىڭHelp me write a product requirements document.ماعا بىر پارچا تۉشۉم ەتىياج ۅجۅتۉۉ جازىپ بەرىڭ.What gift to give on Mother's Day is more intentional?ئانىلار بايرىمىدا قانداي سوۋغات بەرسە داعى ەلە جاقشى؟Session: %1سۉيلۅشۉۉ : %1The current network is not good, please check the network.
Error: ازىر تور جاقشى ەمەس ، تور جالعانىشتى تەكشەرىڭ.
Error: Retryقايرا سىنووSessionLoginPageAi Assistantجاردامچىسى AiAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.AI جاردامچىسى جاسالما روحىي جۅندۅمدۉلۉك تىل نۇسقاسى بولۇپ، مودال القىعان، تىل القىعان تەرەڭ سېمانتىكىلىق تۉشۅنۉۉ جانا پايدا قىلۇۇ جاسوو ،اتقارۇۇ قۇرباتىنا ەە بولموق ، ئەدەبىيات ئىجادىيىتى، سوودا يېزىقچىلىق ئىجادىيىتى، ماتەماتىكالىق لوگىكالىق ەسەپتۅۅ ، ماملەكەت تىلدە تۉشۅنۉۉ، كۅپ مودال پايدا قىلۇۇ جاسوو ،اتقارۇۇ تىن دان تۇرات بەش چوڭ قۇرباتى بار، سۇروو-جووپ ىزدۅۅ، مازمۇن ئىجادىيىتى پايدا قىلۇۇ جاسوو ،اتقارۇۇ ، روحىي جۅندۅمدۉلۉك ىش بەجىرۉۉ قاتارلۇۇ كۅپتۅگۅن ساھەلەردە داعى ەلە كەڭ جورومول بوشتۇعۇنا ەە بولموق .Input API Keyنى كىرگىزىڭ APIKeyInput Secret Keyنى كىرگىزىڭ Secret KeyConfirmبەكىتۉۉSessionPageSelect Sessionسۉيلۅشۉۉنۉ تانداشNew Sessionجاڭىدان سۉيلۅشۉۉClear Sessionسۉيلۅشۉۉنۉ بەكەر جاسوو ،اتقارۇۇExit IDنان جانىش ، قايتىش ID
ukui-menu-extensions/ernie-bot/translations/ernie-bot_ar.ts 0000664 0001750 0001750 00000015276 15160453524 023157 0 ustar feng feng
ChatSessionYou can try asking me:你可以试着问我:How are you today!你今天感觉如何!Good morning!早上好!Good afternoon!下午好!Hi, %1Hi, %1What can AI do?AI 可以做什么?Give it a try试一试Help me write a product requirements document.帮我写一份产品需求文档。What gift to give on Mother's Day is more intentional?在母亲节送什么礼物更用心?Session: %1会话: %1The current network is not good, please check the network.
Error: 当前网络不佳,请检查网络链接。
Error: Retry重试ErnieBotAI Assistantمساعد الذكاء الاصطناعيMessageBarCopyنسخMessageInputYou can ask me any questions~يمكنك أن تسألني أي أسئلة ~SessionSession: %1الجلسة: ٪1The current network is not good, please check the network.
Error: الشبكة الحالية ليست جيدة ، يرجى التحقق من الشبكة.
خطأ: Retryاعاده المحاولهYou can try asking me:يمكنك محاولة سؤالي:How are you today!كيف حالك الآن!Good morning!صباح الخير!Good afternoon!مساء الخير!Hi, %1مرحبا، ٪1What can AI do?ما الذي يمكن أن يفعله الذكاء الاصطناعي؟Give it a tryجربهاHelp me write a product requirements document.ساعدني في كتابة مستند متطلبات المنتج.What gift to give on Mother's Day is more intentional?ما هي الهدية التي يجب تقديمها في عيد الأم أكثر تعمدا؟SessionLoginPageAi Assistantمساعد الذكاء الاصطناعيConfirmأكدInput API Keyمفتاح واجهة برمجة تطبيقات الإدخالInput Secret Keyمفتاح الإدخال السريAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.مساعد الذكاء الاصطناعي هو نموذج لغوي كبير للذكاء الاصطناعي ، لديه القدرة على الفهم الدلالي العميق والتوليد عبر الأوضاع واللغات. لديها خمس قدرات: الإبداع الأدبي ، وإنشاء النسخ التجارية ، وحساب المنطق الرياضي ، والفهم الصيني ، والتوليد متعدد الوسائط ، وما إلى ذلك. لديها مساحة خيال أوسع في العديد من المجالات ، مثل سؤال البحث والإجابة ، وإنشاء المحتوى ، والمكتب الذكي ، وما إلى ذلك.SessionPageSelect Sessionحدد الجلسةNew Sessionجلسة جديدةClear Sessionجلسة واضحةExit IDمعرف الخروج
ukui-menu-extensions/ernie-bot/translations/ernie-bot_es_ES.ts 0000664 0001750 0001750 00000010622 15160453524 023541 0 ustar feng feng
ErnieBotAI AssistantAsistentes de IAMessageBarCopyCopiarMessageInputYou can ask me any questions~Puedes preguntarme cualquier cosa ~SessionYou can try asking me:Puedes intentar preguntarme:How are you today!¡Cómo te sientes hoy!Good morning!¡Buenos días!Good afternoon!¡Buenas tardes!Hi, %1Hola, %1What can AI do?¿Qué puede hacer la IA?Give it a tryTomarle el pulsoHelp me write a product requirements document.Ayúdame a escribir un documento de requisitos del producto.What gift to give on Mother's Day is more intentional?¿Qué regalo dar con más cuidado en el Día de la Madre?Session: %1Sesión: %1The current network is not good, please check the network.
Error: La red actual no es buena, verifique el enlace de red.
Error: RetryReintentarSessionLoginPageAi AssistantAsistente de IAAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.El asistente de IA es un modelo de lenguaje grande de inteligencia artificial, con capacidades de generación y comprensión semántica profunda entre modales, entre idiomas, tiene cinco capacidades, creación literaria, redacción de textos publicitarios comerciales, cálculo de lógica matemática, comprensión china, generación multimodal, tiene un espacio de imaginación más amplio en muchos campos, como búsqueda y respuesta, creación y generación de contenido, oficina inteligente, etc.Input API KeyIntroduzca la clave de APIInput Secret KeyIntroduzca la clave secretaConfirmConfirmarSessionPageSelect SessionSeleccionar sesionesNew SessionCrear una nueva sesiónClear SessionBorrar la sesiónExit IDID de salida
ukui-menu-extensions/ernie-bot/translations/ernie-bot_fr_FR.ts 0000664 0001750 0001750 00000011006 15160453524 023536 0 ustar feng feng
ErnieBotAI AssistantAssistants IAMessageBarCopyCopierMessageInputYou can ask me any questions~Vous pouvez me demander n’importe quoi ~SessionYou can try asking me:Vous pouvez essayer de me demander :How are you today!Comment vous sentez-vous aujourd’hui ?Good morning!Bonjour!Good afternoon!Bonne après-midi!Hi, %1Salut, %1What can AI do?Que peut faire l’IA ?Give it a tryVous mettre dans le bainHelp me write a product requirements document.Aidez-moi à rédiger un document d’exigences relatives au produit.What gift to give on Mother's Day is more intentional?Quel cadeau offrir plus prudemment à l’occasion de la fête des mères ?Session: %1Séance : %1The current network is not good, please check the network.
Error: Le réseau actuel n’est pas bon, veuillez vérifier le lien réseau.
Erreur: RetryRéessayerSessionLoginPageAi AssistantAssistant IAAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.L’assistant AI est un grand modèle de langage d’intelligence artificielle, avec des capacités de compréhension et de génération sémantiques profondes intermodales et interlinguistiques, a cinq capacités, la création littéraire, la rédaction commerciale, le calcul logique mathématique, la compréhension chinoise, la génération multimodale, il dispose d’un espace d’imagination plus large dans de nombreux domaines tels que la recherche et la réponse, la création et la génération de contenu, le bureau intelligent, etc.Input API KeyEntrez la clé APIInput Secret KeyEntrez la clé secrèteConfirmConfirmerSessionPageSelect SessionSélectionner des sessionsNew SessionCréer une nouvelle sessionClear SessionEffacer la sessionExit IDID de sortie
ukui-menu-extensions/ernie-bot/translations/ernie-bot_zh_CN.ts 0000664 0001750 0001750 00000013633 15160453524 023551 0 ustar feng feng
ChatSessionYou can try asking me:你可以试着问我:How are you today!你今天感觉如何!Good morning!早上好!Good afternoon!下午好!Hi, %1Hi, %1What can AI do?AI 可以做什么?Give it a try试一试Help me write a product requirements document.帮我写一份产品需求文档。What gift to give on Mother's Day is more intentional?在母亲节送什么礼物更用心?Session: %1会话: %1The current network is not good, please check the network.
Error: 当前网络不佳,请检查网络链接。
Error: Retry重试ErnieBotAI AssistantAI 助手MessageBarCopy复制MessageInputYou can ask me any questions~你可以问我任何问题~SessionSession: %1会话: %1The current network is not good, please check the network.
Error: 当前网络不佳,请检查网络链接。
Error: Retry重试You can try asking me:你可以试着问我:How are you today!你今天感觉如何!Good morning!早上好!Good afternoon!下午好!Hi, %1Hi, %1What can AI do?AI 可以做什么?Give it a try试一试Help me write a product requirements document.帮我写一份产品需求文档。What gift to give on Mother's Day is more intentional?在母亲节送什么礼物更用心?SessionLoginPageAi AssistantAi 助手Confirm确认Input API Key输入 API KeyInput Secret Key输入 Secret KeyAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.AI 助手是人工智能大语言模型,具备跨模态、跨语言的深度语义理解与生成能力,有五大能力,文学创作、商业文案创作、数理逻辑推算、中文理解、多模态生成,其在搜索问答、内容创作生成、智能办公等众多领域都有更广阔的想象空间。SessionPageSelect Session选择会话New Session新建会话Clear Session清空会话Exit ID退出 ID
ukui-menu-extensions/ernie-bot/translations/ernie-bot_kk_KZ.ts 0000664 0001750 0001750 00000012117 15160453524 023555 0 ustar feng feng
ErnieBotAI Assistantكومەكشىسى AIMessageBarCopyكوشىرۋMessageInputYou can ask me any questions~كورىنسى ٴارقانداي سۇراۋ سورىسىڭىز بولادٸ~SessionYou can try asking me::كورىنسى سورىسىڭىز بولادٸHow are you today!!بوگٸن كەيپىياتىڭىز قانداقراقGood morning!!خەيرلىك تاڭGood afternoon!!تۇسٸرۋدەن كېيىنلىكىڭىز خەيرلىك بولسٸنHi, %1ٴاي، %1What can AI do?نە ورىنداي الادى؟ AIGive it a tryسىناپ كورHelp me write a product requirements document.جۇرەيىك بٸر پارشا تاۋار مۇقتاج حۇجاتى جازىپ بەر.What gift to give on Mother's Day is more intentional?ئانىلار بايرىمىدا قانداق كاسايا بەرسە الٸدە جاقسى؟Session: %1سويلەسۋ : %1The current network is not good, please check the network.
Error: قازىر تور جاقسى ەمەس ، تور جالعانۋدٸ تەسەرٸڭٸز.
Error: Retryقاتە سىناۋSessionLoginPageAi Assistantكومەكشىسى AiAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.AI كومەكشىسى جاساندى وي قابٸلەتتٸ ٴتٸل قالىپى بولىپ، مودال اسقان، ٴتٸل اسقان تەرڭ سېمانتىكىلىق تۇسنىس ۋا پايدابولعان ەتۋ قابٸلەتكە يە، ادەبيەت جاسامپازدىعى، ساۋدا يېزىقچىلىق جاسامپازدىعى، ماتەماتيكالىق لوگيكالىق ەسەپتەۋگە، مەملەكەت ٴتٸلىدا تۇسنىس، كوپ مودال پايدابولعان ەتۋتىن قاتارلى بەس ۇلكەن رولدارٸ بار، سۇراۋ-جاۋاب ٸزدەۋ، مازمۇن جاسامپازدىعى پايدابولعان ەتۋ، وي قابٸلەتتٸ جۇمس ورىنداۋ قاتارلى كوپتەگەن ساھەلەردە الٸدە كەڭ قٸيال بوستعٸنا يە.Input API Keyنى كىرگىزىڭىز APIKeyInput Secret Keyنى كىرگىزىڭىز Secret KeyConfirmتۇراقتاندىرۋSessionPageSelect Sessionسويلەسۋدى تالداۋNew Sessionجاڭادان سويلەسۋClear Sessionسويلەسۋدى بوس ەتۋExit IDدان شەگىنۋ ID
ukui-menu-extensions/ernie-bot/translations/ernie-bot_vi.ts 0000664 0001750 0001750 00000014415 15160453524 023165 0 ustar feng feng
ChatSessionYou can try asking me:你可以试着问我:How are you today!你今天感觉如何!Good morning!早上好!Good afternoon!下午好!Hi, %1Hi, %1What can AI do?AI 可以做什么?Give it a try试一试Help me write a product requirements document.帮我写一份产品需求文档。What gift to give on Mother's Day is more intentional?在母亲节送什么礼物更用心?Session: %1会话: %1The current network is not good, please check the network.
Error: 当前网络不佳,请检查网络链接。
Error: Retry重试ErnieBotAI AssistantTrợ lý AIMessageBarCopyBản saoMessageInputYou can ask me any questions~Bạn có thể hỏi tôi bất kỳ câu hỏi nào ~SessionSession: %1Phiên: %1The current network is not good, please check the network.
Error: Mạng hiện tại không tốt, vui lòng kiểm tra mạng.
Lỗi: RetryThử lạiYou can try asking me:Bạn có thể thử hỏi tôi:How are you today!Hôm nay, bạn có khoẻ không!Good morning!Xin chào!Good afternoon!Chào bạn!Hi, %1Xin chào, %1What can AI do?AI có thể làm gì?Give it a tryHãy thửHelp me write a product requirements document.Giúp tôi viết tài liệu yêu cầu sản phẩm.What gift to give on Mother's Day is more intentional?Tặng món quà nào vào Ngày của Mẹ có chủ đích hơn?SessionLoginPageAi AssistantTrợ lý AiConfirmXác nhậnInput API KeyKhóa API đầu vàoInput Secret KeyKhóa bí mật nhập liệuAI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.Trợ lý AI là một mô hình ngôn ngữ lớn của trí tuệ nhân tạo, có khả năng hiểu và tạo ngữ nghĩa sâu trên các chế độ và ngôn ngữ. Nó có năm khả năng: sáng tạo văn học, tạo bản sao thương mại, tính toán logic toán học, hiểu biết tiếng Trung, tạo đa phương thức, v.v. Nó có một không gian tưởng tượng rộng hơn trong nhiều lĩnh vực, chẳng hạn như tìm kiếm câu hỏi và câu trả lời, tạo nội dung, văn phòng thông minh, v.v.SessionPageSelect SessionChọn phiênNew SessionPhiên mớiClear SessionXóa phiênExit IDID thoát
ukui-menu-extensions/ernie-bot/content/ 0000775 0001750 0001750 00000000000 15160453524 017157 5 ustar feng feng ukui-menu-extensions/ernie-bot/content/content.qrc 0000664 0001750 0001750 00000002470 15160453524 021343 0 ustar feng feng
ui/Main.qmlui/MessageInput.qmlui/MessageBar.qmlui/TimeMessage.qmlui/TipMessage.qmlui/LoadTipMessage.qmlui/ContextMenu.qmlui/SessionPage.qmlui/SessionLoginPage.qmlui/Input.qmlicon/send.svgicon/warn.svgicon/menu.svg
ukui-menu-extensions/ernie-bot/content/ui/ 0000775 0001750 0001750 00000000000 15160453524 017574 5 ustar feng feng ukui-menu-extensions/ernie-bot/content/ui/Main.qml 0000664 0001750 0001750 00000002717 15160453524 021202 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
import QtQuick 2.12
import QtQuick.Layouts 1.12
import org.ukui.menu.extension 1.0
import QtQuick.Controls 2.12
/**
* property var extensionData;
* signal send(var data);
*/
UkuiMenuExtension {
id: root
Component.onCompleted: {
extensionData.sessionManager.checkApiReady();
}
Loader {
anchors.fill: parent
property var mainPage: root
property var extensionData: root.extensionData
property bool apiReady: root.extensionData.sessionManager.apiReady
sourceComponent: apiReady ? sessionPage : sessionLoginPage
}
Component {
id: sessionLoginPage
SessionLoginPage {}
}
Component {
id: sessionPage
SessionPage {}
}
}
ukui-menu-extensions/ernie-bot/content/ui/MessageBar.qml 0000664 0001750 0001750 00000007470 15160453524 022330 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
import QtQuick 2.12
import QtQuick.Controls 2.12
Item {
id: root
property double padding: 12
// TODO: use enum
property bool alignRight: true
property alias color: messageBackgroud.color
property alias border: messageBackgroud.border
property alias radius: messageBackgroud.radius
property alias messageColor: messageContent.color
property alias selectionColor: messageContent.selectionColor
readonly property Rectangle backgroud: messageBackgroud
height: childrenRect.height
// 更新内容宽高
onWidthChanged: adjustContentWidth()
Component.onCompleted: adjustContentWidth()
Component {
id: textComponent
Text {}
}
function adjustContentWidth() {
let text = null;
let backgroundWidth = 0;
if (textComponent.status === Component.Ready) {
text = textComponent.createObject(null, {text: content});
let contentWidth = Math.ceil(text.contentWidth);
backgroundWidth = contentWidth > (width - padding*2) ? width : (contentWidth + padding*2);
text.destroy();
}
messageBackgroud.width = backgroundWidth;
}
Rectangle {
id: messageBackgroud
anchors {
left: root.alignRight ? undefined : parent.left
right: root.alignRight ? parent.right : undefined
}
height: messageContent.contentHeight + padding * 2
TextEdit {
id: messageContent
z: 100
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
anchors.leftMargin: root.padding
anchors.topMargin: root.padding
anchors.rightMargin: root.padding
text: content
// textFormat: Text.AutoText
textFormat: TextEdit.MarkdownText
selectByMouse: true
selectByKeyboard: true
readOnly: true
wrapMode: Text.WrapAnywhere
onTextChanged: root.adjustContentWidth()
}
MouseArea {
anchors.fill: parent
z: 50
acceptedButtons: Qt.RightButton | Qt.LeftButton
onClicked: function(event) {
if (event.button === Qt.LeftButton) {
messageContent.deselect();
} else {
let start = messageContent.selectionStart;
let end = messageContent.selectionEnd;
if (messageContent.selectedText.length === 0) {
start = 0;
end = messageContent.length;
}
contextMenu.popup();
messageContent.select(start, end);
event.accepted = true;
}
}
ContextMenu {
id: contextMenu
width: 120
Action {
text: qsTr("Copy")
onTriggered: {
messageContent.copy();
}
}
}
}
}
}
ukui-menu-extensions/ernie-bot/content/ui/ContextMenu.qml 0000664 0001750 0001750 00000002716 15160453524 022566 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
import QtQuick 2.12
import QtQuick.Controls 2.12
Menu {
id: sessionMenu
padding: 6
background: Rectangle {
border.color: "#dedede"
border.width: 1
radius: 6
}
delegate: MenuItem {
id: menuItem
height: 30
background: Rectangle {
color: menuItem.highlighted ? "#3790FA" : "#ffffff"
radius: 4
}
contentItem: Text {
text: menuItem.text
font: menuItem.font
opacity: enabled ? 1.0 : 0.3
color: menuItem.highlighted ? "#ffffff" : "#000000"
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
}
ukui-menu-extensions/ernie-bot/content/ui/SessionLoginPage.qml 0000664 0001750 0001750 00000010324 15160453524 023520 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
import QtQuick 2.12
Item {
Component.onCompleted: {
extensionData.sessionManager.apiError.connect(showErrorMsg);
}
Component.onDestruction: {
extensionData.sessionManager.apiError.disconnect(showErrorMsg);
}
function showErrorMsg(msg) {
errorMessage.text = msg;
}
Rectangle {
id: body
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
anchors.leftMargin: 8
// anchors.topMargin: 8
anchors.rightMargin: 8
height: childrenRect.height + 32
radius: 8
color: Qt.rgba(255, 255, 255, 0.45)
Column {
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
anchors.leftMargin: 16
anchors.topMargin: 16
anchors.rightMargin: 16
height: childrenRect.height
spacing: 16
Text {
width: parent.width
height: 40
verticalAlignment: Text.AlignVCenter
text: qsTr("Ai Assistant")
font.bold: true
font.pixelSize: 18
}
Text {
width: parent.width
height: contentHeight
text: qsTr("AI assistant is a large language model of artificial intelligence, which has the ability of deep semantic understanding and generation across modes and languages. It has five abilities: literary creation, commercial copy creation, mathematical logic calculation, Chinese understanding, multimodal generation, and so on. It has a broader imagination space in many fields, such as search question and answer, content creation, intelligent office and so on.")
wrapMode: Text.WordWrap
color: Qt.rgba(0, 0, 0, 0.55)
}
Rectangle {
width: parent.width
height: 1
color: Qt.rgba(38, 38, 38, 0.2)
}
Input {
id: keyInput
width: parent.width
height: 40
radius: 8
placeholder: qsTr("Input API Key")
color: Qt.rgba(38, 38, 38, 0.45)
}
Input {
id: secretInput
width: parent.width
height: 40
radius: 8
placeholder: qsTr("Input Secret Key")
color: Qt.rgba(38, 38, 38, 0.45)
}
Rectangle {
width: parent.width
height: 40
radius: 8
color: "#3790FA"
Text {
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: qsTr("Confirm")
color: "#ffffff"
}
MouseArea {
anchors.fill: parent
onClicked: {
extensionData.sessionManager.setSessionKeys(keyInput.text, secretInput.text);
}
}
}
}
}
Text {
id: errorMessage
anchors.top: body.bottom
anchors.topMargin: 16
width: parent.width
height: contentHeight
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: "#E41A2B"
}
}
ukui-menu-extensions/ernie-bot/content/ui/Input.qml 0000664 0001750 0001750 00000003220 15160453524 021403 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
import QtQuick 2.12
import QtQuick.Layouts 1.12
Rectangle {
id: root
property bool disableInput: false
property alias text: messageInput.text
property alias placeholder: tipText.text
readonly property alias textInput: messageInput
Item {
anchors.fill: parent
anchors.leftMargin: 8
anchors.rightMargin: 8
clip: true
TextInput {
id: messageInput
anchors.fill: parent
z: 10
verticalAlignment: TextInput.AlignVCenter
selectByMouse: true
selectionColor: "#3790FA"
maximumLength: 500
rightPadding: 4
readOnly: root.disableInput
}
Text {
id: tipText
anchors.fill: parent
visible: messageInput.length === 0
verticalAlignment: Text.AlignVCenter
color: Qt.rgba(0, 0, 0, 0.3)
}
}
}
ukui-menu-extensions/ernie-bot/content/ui/MessageInput.qml 0000664 0001750 0001750 00000005325 15160453524 022720 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
import QtQuick 2.12
import QtQuick.Layouts 1.12
Rectangle {
id: root
border.width: 1
border.color: "#dedede"
property bool disableInput: false
signal messageSend(string message)
function sendMessage(message) {
if (message.length > 0) {
messageSend(message);
messageInput.clear();
}
}
RowLayout {
anchors.fill: parent
spacing: 0
Item {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.leftMargin: 8
Layout.rightMargin: 4
clip: true
TextInput {
id: messageInput
anchors.fill: parent
z: 10
verticalAlignment: TextInput.AlignVCenter
selectByMouse: true
selectionColor: "#3790FA"
maximumLength: 500
rightPadding: 4
readOnly: root.disableInput
onAccepted: {
root.sendMessage(text);
}
}
Text {
anchors.fill: parent
visible: messageInput.length === 0
verticalAlignment: Text.AlignVCenter
color: Qt.rgba(0, 0, 0, 0.3)
text: qsTr("You can ask me any questions~")
}
}
Rectangle {
Layout.fillHeight: true
Layout.preferredWidth: 1
color: "#dedede"
}
Item {
Layout.fillHeight: true
Layout.preferredWidth: parent.height
Image {
width: 16
height: 16
anchors.centerIn: parent
enabled: !root.disableInput;
source: "qrc:///ernie-bot/content/icon/send.svg"
}
MouseArea {
anchors.fill: parent
onClicked: {
root.sendMessage(messageInput.text);
}
}
}
}
}
ukui-menu-extensions/ernie-bot/content/ui/TimeMessage.qml 0000664 0001750 0001750 00000002131 15160453524 022507 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
import QtQuick 2.12
import QtQuick.Layouts 1.12
Item {
height: childrenRect.height
Text {
id: timeContent
width: parent.width
height: contentHeight
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 16
color: Qt.rgba(0, 0, 0, 0.3)
text: content
}
}
ukui-menu-extensions/ernie-bot/content/ui/TipMessage.qml 0000664 0001750 0001750 00000007163 15160453524 022357 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
import QtQuick 2.12
import QtQuick.Layouts 1.12
Rectangle {
readonly property int padding: 16
height: tipLayout.height + padding*2
radius: 8
color: Qt.rgba(255, 255, 255, 0.45)
border.width: 1
border.color: Qt.rgba(0, 0, 0, 0.1)
ColumnLayout {
id: tipLayout
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: parent.padding
anchors.rightMargin: parent.padding
anchors.topMargin: parent.padding
spacing: 8
onChildrenRectChanged: {
height = childrenRect.height;
}
Text {
Layout.fillWidth: true
Layout.preferredHeight: contentHeight
wrapMode: Text.WrapAnywhere
font.bold: true
text: header
}
Text {
Layout.fillWidth: true
Layout.preferredHeight: contentHeight
wrapMode: Text.WrapAnywhere
text: content
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 1
Layout.maximumHeight: 1
color: Qt.rgba(38, 38, 38, 0.2)
}
ListView {
Layout.fillWidth: true
Layout.leftMargin: 8
Layout.rightMargin: 8
Layout.preferredHeight: contentHeight
cacheBuffer: count
interactive: false
spacing: 8
model: actions
delegate: Item {
width: ListView.view.width
height: 32
RowLayout {
anchors.fill: parent
Text {
Layout.fillWidth: true
Layout.fillHeight: true
verticalAlignment: Text.AlignVCenter
elide: Text.ElideMiddle
text: "\"" + modelData.text + "\""
}
Rectangle {
Layout.fillWidth: true
Layout.maximumWidth: 70
Layout.minimumWidth: 70
Layout.fillHeight: true
radius: 8
color: "#263790FA"
Text {
anchors.fill: parent
text: modelData.name
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
color: "#3790FA"
}
MouseArea {
anchors.fill: parent
onClicked: {
modelData.exec();
}
}
}
}
}
}
}
}
ukui-menu-extensions/ernie-bot/content/ui/LoadTipMessage.qml 0000664 0001750 0001750 00000003642 15160453524 023155 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
import QtQuick 2.12
import QtQuick.Layouts 1.12
Rectangle {
color: Qt.rgba(255, 255, 255, 0.45)
border.width: 1
border.color: Qt.rgba(0, 0, 0, 0.1)
radius: 6
Component.onCompleted: {
animation.start();
}
RotationAnimation {
id: animation
target: pathView
to: 360
duration: 1500
direction: RotationAnimation.Clockwise
onStopped: {
if (pathView.rotation === 360) {
pathView.rotation = 0;
}
start();
}
}
PathView {
id: pathView
anchors.centerIn: parent
width: 20; height: 20
path: Path {
startX: 10; startY: 0
PathArc {
x: 10; y: 20
radiusX: 10
radiusY: 10
useLargeArc: true
}
PathArc {
x: 10; y: 0
radiusX: 10
radiusY: 10
useLargeArc: true
}
}
interactive: false
model: 8
delegate: Rectangle {
width: 5; height: 5
radius: width/2
color: "#BF3790FA"
}
}
}
ukui-menu-extensions/ernie-bot/content/ui/SessionPage.qml 0000664 0001750 0001750 00000036674 15160453524 022547 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: hxf
*/
import QtQuick 2.12
import QtQuick.Layouts 1.12
import org.ukui.menu.aiAssistant 1.0
import QtQuick.Controls 2.12
Item {
id: root
property var session: null
Component {
id: openContextMenu
Item {
Image {
anchors.centerIn: parent
width: 16
height: 16
source: "qrc:///ernie-bot/content/icon/menu.svg"
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
sessionSubMenu.contentItem.model = extensionData.sessionManager.sessionIds();
sessionMenu.popup();
}
}
}
}
function updateSession() {
var sessionId = extensionData.messageModel.currentSessionId;
if (session !== null) {
session.sessionIsReadyChanged.disconnect(pauseSession);
session.responseIsReadyChanged.disconnect(pauseSession);
}
session = extensionData.sessionManager.getSession(sessionId);
if (session !== null) {
session.sessionIsReadyChanged.connect(pauseSession);
session.responseIsReadyChanged.connect(pauseSession);
pauseSession();
}
}
function pauseSession() {
sessionUnReadyItem.visible =!session.sessionIsReady;
messageInput.disableInput = !session.responseIsReady || !session.sessionIsReady;
}
Component.onCompleted: {
messageView.model = extensionData.messageModel
if (extensionData.messageModel.currentSessionId === -1) {
extensionData.sessionManager.newSession();
}
updateSession();
extensionData.messageModel.currentSessionIdChanged.connect(updateSession);
mainPage.extensionMenu = openContextMenu;
}
Component.onDestruction: {
extensionData.messageModel.currentSessionIdChanged.disconnect(updateSession);
mainPage.extensionMenu = null;
}
ContextMenu {
id: sessionMenu
width: 120
ContextMenu {
id: sessionSubMenu
title: qsTr("Select Session")
width: 120
contentItem: ListView {
width: sessionSubMenu.width
spacing: 0
onContentHeightChanged: {
height = childrenRect.height;
sessionSubMenu.height = height + sessionSubMenu.padding*2;
}
delegate: Rectangle {
width: ListView.view.width
height: 30
radius: 4
color: mouseArea.containsMouse ? "#3790FA" : "#ffffff"
Rectangle {
width: 8; height: 8
anchors.left: parent.left
anchors.leftMargin: 4
anchors.verticalCenter: parent.verticalCenter
radius: 4
visible: modelData === extensionData.messageModel.currentSessionId
color: mouseArea.containsMouse ? "#ffffff" : "#3790FA"
}
Text {
anchors.fill: parent
anchors.leftMargin: 16
anchors.rightMargin: 6
text: extensionData.sessionManager.getSession(modelData).sessionName;
color: mouseArea.containsMouse ? "#ffffff" : "#000000"
verticalAlignment: Text.AlignVCenter
elide: Text.ElideMiddle
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
extensionData.messageModel.setSession(extensionData.sessionManager.getSession(modelData));
sessionMenu.close();
}
}
}
}
}
MenuSeparator {
contentItem: Rectangle {
implicitWidth: 120
implicitHeight: 1
color: "#dedede"
}
}
Action {
text: qsTr("New Session")
onTriggered: {
extensionData.sessionManager.newSession();
}
}
Action {
text: qsTr("Clear Session")
onTriggered: {
root.session.clearSession()
}
}
Action {
text: qsTr("Exit ID")
onTriggered: {
extensionData.sessionManager.exitSessionApi();
}
}
}
ColumnLayout {
anchors.fill: parent
anchors.leftMargin: 8
anchors.rightMargin: 8
anchors.bottomMargin: 8
Item {
Layout.fillWidth: true
Layout.fillHeight: true
Loader {
id: sessionUnReadyItem
anchors.centerIn: parent
width: 50; height: 50
visible: false
z: 100
active: visible
focus: false
sourceComponent: Component {
Item {
Component.onCompleted: {
animation.start();
}
RotationAnimation {
id: animation
target: pathView
to: 360
duration: 1500
direction: RotationAnimation.Clockwise
onStopped: {
if (pathView.rotation === 360) {
pathView.rotation = 0;
}
start();
}
}
PathView {
id: pathView
anchors.fill: parent
path: Path {
startX: 25; startY: 0
PathArc {
x: 25; y: 50
radiusX: 25
radiusY: 25
useLargeArc: true
}
PathArc {
x: 25; y: 0
radiusX: 25
radiusY: 25
useLargeArc: true
}
}
interactive: false
model: 8
delegate: Rectangle {
width: 10; height: 10
radius: 5
color: "#BF3790FA"
}
}
}
}
}
ListView {
id: messageView
anchors.fill: parent
z: 50
focus: true
clip: true
// model: extensionData.messageModel
spacing: 10
cacheBuffer: count * 100
boundsBehavior: Flickable.StopAtBounds
highlightMoveDuration: 500
highlightMoveVelocity: -1
onCountChanged: {
currentIndex = count - 1;
}
delegate: Loader {
property string header: model.header
property string content: model.content
property var actions: model.actions
property var view: ListView.view
width: ListView.view.width
height: childrenRect.height
focus: true
sourceComponent: {
let type = model.type;
if (type === Message.SentMessage) {
return sentMessage;
}
if (type === Message.ReceivedMessage) {
return receivedMessage;
}
if (type === Message.TimeMessage) {
return timeMessage;
}
if (type === Message.TipMessage) {
return tipMessage;
}
if (type === Message.LoadTipMessage) {
return loading;
}
if (type === Message.ErrorMessage) {
return errorMessage;
}
}
}
Component {
id: loading
Item {
height: childrenRect.height
LoadTipMessage {
width: 100
height: 45
anchors.left: parent.left
}
}
}
Component {
id: sentMessage
MessageBar {
color: "#3790FA"
radius: 6
messageColor: "#ffffff"
selectionColor: Qt.rgba(0, 0, 0, 1)
}
}
Component {
id: receivedMessage
MessageBar {
alignRight: false
color: Qt.rgba(255, 255, 255, 0.45)
radius: 6
border.width: 1
border.color: Qt.rgba(0, 0, 0, 0.1)
messageColor: "#000000"
selectionColor: "#3790FA"
}
}
Component {
id: errorMessage
Rectangle {
height: childrenRect.height
radius: 6
color: Qt.rgba(255, 255, 255, 0.45)
border.width: 1
border.color: Qt.rgba(0, 0, 0, 0.1)
Column {
width: parent.width
height: childrenRect.height
Item {
width: parent.width
height: errorMessageBar.height
Image {
width: 16
height: 16
anchors.left: parent.left
anchors.leftMargin: 12
anchors.verticalCenter: parent.verticalCenter
enabled: !root.disableInput;
source: "qrc:///ernie-bot/content/icon/warn.svg"
}
MessageBar {
id: errorMessageBar
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 28
alignRight: false
color: "transparent"
radius: 6
messageColor: "#3790FA"
selectionColor: "#808080"
}
}
Rectangle {
width: parent.width
height: 1
color: Qt.rgba(38, 38, 38, 0.2)
}
Item {
width: parent.width
height: 40
visible: errorActions.count > 0
ListView {
id: errorActions
anchors.horizontalCenter: parent.horizontalCenter
width: childrenRect.width
height: parent.height
orientation: ListView.Horizontal
model: actions
delegate: Item {
width: 80
height: ListView.view.height
Text {
anchors.fill: parent
text: modelData.name
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
color: "#3790FA"
}
MouseArea {
anchors.fill: parent
onClicked: {
modelData.exec();
}
}
}
}
}
}
}
}
Component {
id: timeMessage
TimeMessage {}
}
Component {
id: tipMessage
TipMessage {}
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (mouse.button === Qt.RightButton) {
sessionSubMenu.contentItem.model = extensionData.sessionManager.sessionIds();
sessionMenu.popup();
}
}
}
}
MessageInput {
id: messageInput
Layout.fillWidth: true
Layout.preferredHeight: 40
radius: 6
onMessageSend: function(message) {
messageView.model.talk(message);
}
}
}
}
ukui-menu-extensions/ernie-bot/content/icon/ 0000775 0001750 0001750 00000000000 15160453524 020107 5 ustar feng feng ukui-menu-extensions/ernie-bot/content/icon/send.svg 0000664 0001750 0001750 00000000517 15160453524 021564 0 ustar feng feng
ukui-menu-extensions/ernie-bot/content/icon/warn.svg 0000664 0001750 0001750 00000000654 15160453524 021604 0 ustar feng feng
ukui-menu-extensions/ernie-bot/content/icon/menu.svg 0000664 0001750 0001750 00000001306 15160453524 021574 0 ustar feng feng
ukui-menu-extensions/ernie-bot/CMakeLists.txt 0000664 0001750 0001750 00000003200 15160453524 020240 0 ustar feng feng cmake_minimum_required(VERSION 3.16)
project(ernie-bot)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(QT NAMES Qt6 Qt5
COMPONENTS Core Gui Quick Widgets Network LinguistTools REQUIRED)
find_package(Qt${QT_VERSION_MAJOR}
COMPONENTS Core Gui Quick Widgets Network LinguistTools REQUIRED)
find_package(ukui-menu REQUIRED)
set(QRC_FILES "content/content.qrc")
# 翻译文件
file(GLOB TS_FILES "translations/*.ts")
# 更新翻译并创建.qm文件
if(COMMAND qt_create_translation)
qt_create_translation(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES})
else()
qt5_create_translation(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES})
endif()
set(SOURCE
src/ernie-bot.h src/ernie-bot.cpp
src/chat.h src/chat.cpp
src/message.cpp src/message.h
src/message-model.cpp src/message-model.h
src/message-action.cpp src/message-action.h
src/session-manager.cpp src/session-manager.h
src/session.cpp src/session.h
)
add_library(ernie-bot SHARED ${SOURCE} ${QM_FILES} ${QRC_FILES})
target_link_libraries(ernie-bot PRIVATE
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Network
ukui-menu
)
install(TARGETS ernie-bot LIBRARY DESTINATION "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-menu/extensions")
install(FILES ${QM_FILES} DESTINATION "/usr/share/ukui-menu/extensions/translations/")
if (BUILD_TEST)
add_subdirectory(test)
endif ()
ukui-menu-extensions/ernie-bot/test/ 0000775 0001750 0001750 00000000000 15160453524 016464 5 ustar feng feng ukui-menu-extensions/ernie-bot/test/CMakeLists.txt 0000664 0001750 0001750 00000000526 15160453524 021227 0 ustar feng feng include_directories(${CMAKE_SOURCE_DIR}/src/)
set(ernieTest_SRCS
${CMAKE_SOURCE_DIR}/src/chat.cpp
${CMAKE_SOURCE_DIR}/src/chat.h
main.cpp)
add_executable(ernie-test ${ernieTest_SRCS})
target_link_libraries(ernie-test PRIVATE
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Quick Qt5::Network
ernie-bot
) ukui-menu-extensions/ernie-bot/test/main.cpp 0000664 0001750 0001750 00000001065 15160453524 020116 0 ustar feng feng //
// Created by zpf on 2023/6/12.
//
#include
#include
#include
#include "chat.h"
int main(int argc, char *argv[]) {
QCoreApplication app(argc, argv);
auto chat = new Chat;
QObject::connect(chat, &Chat::readyToChat, [chat](){
qDebug() << chat->isValid();
if(chat->isValid()) {
chat->talk("hello");
}
});
QObject::connect(chat, &Chat::response, [&](const QString &content){
qDebug() << content;
});
chat->newChat();
return QCoreApplication::exec();
} ukui-menu-extensions/recent-file/ 0000775 0001750 0001750 00000000000 15160453541 016015 5 ustar feng feng ukui-menu-extensions/recent-file/translations/ 0000775 0001750 0001750 00000000000 15160453541 020536 5 ustar feng feng ukui-menu-extensions/recent-file/translations/recent-file_es_ES.ts 0000664 0001750 0001750 00000001664 15160453524 024371 0 ustar feng feng
RecentFileExtensionPath: UkuiMenu::RecentFileExtensionRecent FilesOpenAbrirRemove from listClear listBorrar listaOpen the directory where the file is located
ukui-menu-extensions/recent-file/translations/recent-file_vi.ts 0000664 0001750 0001750 00000001707 15160453524 024007 0 ustar feng feng
RecentFileExtensionPath: Con đường: UkuiMenu::RecentFileExtensionRecent FilesTệp gần đâyOpenMởRemove from listXóa khỏi danh sáchClear listDanh sách rõ ràngOpen the directory where the file is locatedMở thư mục nơi đặt tệp
ukui-menu-extensions/recent-file/translations/recent-file_zh_Hant.ts 0000664 0001750 0001750 00000001650 15160453541 024760 0 ustar feng feng
RecentFileExtensionPath: 路徑: UkuiMenu::RecentFileExtensionRecent Files最近Open打開Remove from list從清單中删除Clear all清空全部Open the directory where the file is located打開文件所在目錄
ukui-menu-extensions/recent-file/translations/recent-file_kk_KZ.ts 0000664 0001750 0001750 00000001752 15160453524 024402 0 ustar feng feng
RecentFileExtensionPath: جول: UkuiMenu::RecentFileExtensionRecent Filesجاقىنعى حۇجاتتارOpenٸشٸۋRemove this recordبۇ يازبىنى ئالغاچۇClear all recordsبۇ بارلىق يازبىلارنى تازالاOpen file locationفایل جايىن ئاچۇ
ukui-menu-extensions/recent-file/translations/recent-file_zh_HK.ts 0000664 0001750 0001750 00000001646 15160453541 024375 0 ustar feng feng
RecentFileExtensionPath: 路徑: UkuiMenu::RecentFileExtensionRecent Files最近Open打開Remove from list從清單中删除Clear all清空全部Open the directory where the file is located打開文件所在目錄
ukui-menu-extensions/recent-file/translations/recent-file_zh_CN.ts 0000664 0001750 0001750 00000001646 15160453541 024373 0 ustar feng feng
RecentFileExtensionPath: 路径: UkuiMenu::RecentFileExtensionRecent Files最近Open打开Remove from list从列表中删除Clear all清空全部Open the directory where the file is located打开文件所在目录
ukui-menu-extensions/recent-file/translations/recent-file_fr_FR.ts 0000664 0001750 0001750 00000001671 15160453524 024367 0 ustar feng feng
RecentFileExtensionPath: UkuiMenu::RecentFileExtensionRecent FilesOpenOuvrirRemove from listClear listEffacer la listeOpen the directory where the file is located
ukui-menu-extensions/recent-file/translations/recent-file_ar.ts 0000664 0001750 0001750 00000001763 15160453524 023775 0 ustar feng feng
RecentFileExtensionPath: مسار: UkuiMenu::RecentFileExtensionRecent Filesالملفات الحديثةOpenمفتوحRemove from listإزالة من القائمةClear listقائمة واضحةOpen the directory where the file is locatedافتح الدليل الذي يوجد به الملف
ukui-menu-extensions/recent-file/translations/recent-file_ug_CN.ts 0000664 0001750 0001750 00000002003 15160453524 024352 0 ustar feng feng
RecentFileExtensionPath: يول: UkuiMenu::RecentFileExtensionRecent Filesيېقىنقى ھۆججەتلەرOpenئېچىشRemove this recordبۇ خاتىرىنى چىقىرىۋەتمەكClear all recordsبارلىق خاتىرىلەرنى تازىلاشOpen file locationھۆججەت ئورنىنى ئېچىش
ukui-menu-extensions/recent-file/translations/recent-file_ky_KG.ts 0000664 0001750 0001750 00000001745 15160453524 024377 0 ustar feng feng
RecentFileExtensionPath: جول: UkuiMenu::RecentFileExtensionRecent Filesجاقىندا ۅجۅتتۅرOpenاچۇۇRemove this recordبۇ يازبىنى جويۇClear all recordsبۇ بارلىق يازبىلارنى تازالاOpen file locationفايل جايىنى ئاچُ
ukui-menu-extensions/recent-file/translations/recent-file_bo_CN.ts 0000664 0001750 0001750 00000002260 15160453524 024344 0 ustar feng feng
RecentFileExtensionPath: ཐབས་ལམ་ནི། UkuiMenu::RecentFileExtensionRecent Filesཆེས་ཉེའི་ཡིག་ཆ།Openའབྱེད་པ།Remove this recordདོན་ཚན་འདི་རྩིས་མེད་དུ་གཏོང་།Clear all recordsཟིན་ཐོ་ཡོད་ཚད་གཙང་སེལ་བྱ་དགོས།Open file locationཡིག་ཆའི་གོ་གནས་ཀྱི་ཁ་ཕྱེ་བ།
ukui-menu-extensions/recent-file/translations/recent-file_mn_MN.ts 0000664 0001750 0001750 00000002343 15160453524 024372 0 ustar feng feng
RecentFileExtensionPath: ᠵᠠᠮ ᠮᠥᠷ ᠄ UkuiMenu::RecentFileExtensionRecent Filesᠤᠢᠷᠠ ᠵᠢᠨ ᠹᠠᠢᠯOpenᠨᠡᠬᠡᠬᠡᠬᠦRemove this recordᠡᠨᠡ ᠲᠡᠮᠳᠡᠭᠯᠡᠯ ᠢ ᠠᠷᠢᠯᠭᠠᠬᠤ ᠬᠡᠷᠡᠭᠲᠡᠶ ᠃Clear all recordsᠪᠤᠢ ᠪᠥᠬᠥᠢ ᠲᠡᠮᠳᠡᠭ᠍ᠯᠡᠯ ᠢ ᠠᠷᠢᠯᠭᠠᠬᠤ ᠬᠡᠷᠡᠭᠲᠡᠢ ᠃Open file locationᠪᠢᠴᠢᠭ᠌ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠤᠨ ᠪᠠᠢ᠌ᠷᠢ ᠶᠢ ᠨᠡᠭᠡᠭᠡᠨᠡ ᠃
ukui-menu-extensions/recent-file/translations/recent-file_de_DE.ts 0000664 0001750 0001750 00000001666 15160453524 024335 0 ustar feng feng
RecentFileExtensionPath: UkuiMenu::RecentFileExtensionRecent FilesOpenOffenRemove from listClear listListe löschenOpen the directory where the file is located
ukui-menu-extensions/recent-file/event-track.h 0000664 0001750 0001750 00000002333 15160453524 020413 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
#ifndef EVENT_TRACK_H
#define EVENT_TRACK_H
#include
namespace UkuiMenu {
class EventTrack : public QObject
{
Q_OBJECT
public:
static EventTrack *instance();
Q_INVOKABLE void sendClickEvent(const QString& event, const QString& page);
Q_INVOKABLE void sendDefaultEvent(const QString& event, const QString& page);
Q_INVOKABLE void sendSearchEvent(const QString& event, const QString& page, const QString& content);
private:
explicit EventTrack(QObject *parent = nullptr);
};
}
#endif //EVENT_TRACK_H
ukui-menu-extensions/recent-file/recent-file-extension.h 0000664 0001750 0001750 00000005167 15160453524 022407 0 ustar feng feng /*
* Copyright (C) 2022, 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 UKUI_MENU_RECENT_FILE_EXTENSION_H
#define UKUI_MENU_RECENT_FILE_EXTENSION_H
#include
#include
class QThread;
#include
#include
namespace UkuiMenu {
class RecentFilesModel;
class RecentFileProvider;
/**
* @brief 最近文件项数据结构,表示单个最近访问文件的信息
*/
class RecentFile
{
public:
quint64 accessTime{0};
QString uri;
QString name;
QString icon;
QString infoId;
};
class RecentFileExtensionPlugin : public MenuExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_MENU_EXTENSION_I_FACE_TYPE FILE "metadata.json")
Q_INTERFACES(UkuiMenu::MenuExtensionPlugin)
public:
~RecentFileExtensionPlugin() override;
QString id() override;
WidgetExtension *createWidgetExtension() override;
ContextMenuExtension *createContextMenuExtension() override;
};
class RecentFileExtension : public WidgetExtension
{
Q_OBJECT
public:
explicit RecentFileExtension(QObject *parent = nullptr);
~RecentFileExtension() override;
MetadataMap metadata() const override;
int index() const override;
QVariantMap data() override;
void receive(const QVariantMap &data) override;
private:
MetadataMap m_metadata;
QPointer m_contextMenu;
QVector m_recentFile;
QVariantMap m_data;
RecentFilesModel *m_recentFilesModel = nullptr;
QThread *m_recentFilesProviderThread = nullptr;
RecentFileProvider *m_recentFileProvider = nullptr;
void openFile(const QString& fileUrl);
void creatContextMenu(const QString &path, const int &index);
void creatEmptyAreaContextMenu();
QString getDefaultAppForUrl(const std::string &url);
QIcon getAppIcon(const QString &desktoFile);
Q_SIGNALS:
void loadRecentFiles();
void openFileASync(const QString &path);
};
} // UkuiMenu
#endif //UKUI_MENU_RECENT_FILE_EXTENSION_H
ukui-menu-extensions/recent-file/CMakeLists.txt 0000664 0001750 0001750 00000004177 15160453524 020567 0 ustar feng feng cmake_minimum_required(VERSION 3.16)
project(recent-file)
set(EXTENSION_NAME "recent-file")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(QT NAMES Qt6 Qt5
COMPONENTS Core Gui Quick Widgets DBus LinguistTools REQUIRED)
find_package(Qt${QT_VERSION_MAJOR}
COMPONENTS Core Gui Quick Widgets DBus LinguistTools REQUIRED)
find_package(ukui-menu REQUIRED)
set(SOURCE recent-file-extension.cpp recent-file-extension.h
event-track.cpp event-track.h
)
if (QT_VERSION_MAJOR EQUAL 5)
find_package(Qt5Xdg REQUIRED)
elseif(QT_VERSION_MAJOR EQUAL 6)
find_package(Qt6Xdg REQUIRED)
endif()
find_package(PkgConfig REQUIRED)
set(EXTERNAL_LIBS "")
set(PC_PKGS glib-2.0 gio-unix-2.0 kysdk-datacollect kysdk-systime)
foreach(lib IN ITEMS ${PC_PKGS})
pkg_check_modules(${lib} REQUIRED ${lib})
if(${${lib}_FOUND})
include_directories(${${lib}_INCLUDE_DIRS})
link_directories(${${lib}_LIBRARY_DIRS})
list(APPEND EXTERNAL_LIBS ${${lib}_LIBRARIES})
endif()
endforeach()
set(QRC_FILES qml/qml.qrc)
# 翻译文件
file(GLOB TS_FILES "translations/*.ts")
# 更新翻译并创建.qm文件
if(COMMAND qt_create_translation)
qt_create_translation(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES})
else()
qt5_create_translation(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES})
endif()
set(RECENT_FILE_TRANSLATION_DIR "/usr/share/ukui-menu/extensions/translations/")
add_compile_definitions(RECENT_FILE_TRANSLATION_DIR="${RECENT_FILE_TRANSLATION_DIR}")
add_library(${EXTENSION_NAME} SHARED ${SOURCE} ${QM_FILES} ${QRC_FILES})
target_link_libraries(${EXTENSION_NAME} PRIVATE
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::DBus
${EXTERNAL_LIBS}
ukui-menu
Qt${QT_VERSION_MAJOR}Xdg
)
install(TARGETS ${EXTENSION_NAME} LIBRARY DESTINATION "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-menu/extensions")
install(FILES ${QM_FILES} DESTINATION ${RECENT_FILE_TRANSLATION_DIR})
ukui-menu-extensions/recent-file/qml/ 0000775 0001750 0001750 00000000000 15160453541 016606 5 ustar feng feng ukui-menu-extensions/recent-file/qml/RecentFileExtension.qml 0000664 0001750 0001750 00000016274 15160453541 023250 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
import QtQuick 2.0
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.12
import org.ukui.menu.extension 1.0
import AppControls2 1.0 as AppControls2
import org.ukui.quick.items 1.0 as UkuiItems
import org.ukui.quick.platform 1.0 as Platform
UkuiMenuExtension {
property bool isVisible: mainWindow.visible
Component.onCompleted: {
recentFileView.model = extensionData.recentFilesModel
extensionData.recentFilesModel.updateData()
}
onIsVisibleChanged: {
if (isVisible) {
extensionData.recentFilesModel.updateData();
}
}
Item {
anchors.fill: parent
MouseArea {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
onContainsMouseChanged: {
if (containsMouse) {
scrollBar.visible = true
}
else {
scrollBar.visible = false
}
}
onClicked: {
var data = {};
data["action"] = mouse.button === Qt.LeftButton ? "closeMenu" : "emptyAreaContextMenu"
send(data);
}
UkuiItems.DtThemeBackground {
anchors.top: parent.top
width: parent.width; height: 1
useStyleTransparency: false
backgroundColor: Platform.GlobalTheme.kContainAlphaClick
visible: recentFileView.contentY > 0
z: 1
}
ListView {
id: recentFileView
anchors.fill: parent
anchors.leftMargin: 12
spacing: 4
focus: true
highlightMoveDuration: 0
onActiveFocusChanged: {
if (activeFocus) {
currentIndex = 0;
} else {
currentIndex = -1;
}
}
onCountChanged: currentIndex = -1
keyNavigationWraps: true
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: AppControls2.ScrollBar {
id: scrollBar
visible: false
width: 14
height: recentFileView.height
}
delegate: UkuiItems.DtThemeBackground {
id: delegateItem
width: ListView.view.width - 18
height: 40
useStyleTransparency: false
backgroundColor: itemArea.containsPress ? Platform.GlobalTheme.kContainAlphaClick
: itemArea.containsMouse ? Platform.GlobalTheme.kContainAlphaHover
: Platform.GlobalTheme.kContainGeneralAlphaNormal
radius: Platform.GlobalTheme.kRadiusMax
focus: true
states: State {
when: index === recentFileView.currentIndex
PropertyChanges {
target: delegateItem
borderColor: Platform.GlobalTheme.highlightActive
border.width: 2
}
}
RowLayout {
anchors.fill: parent
anchors.leftMargin: 8
anchors.rightMargin: 10
spacing: 8
UkuiItems.Icon {
Layout.preferredWidth: 32
Layout.preferredHeight: 32
Layout.alignment: Qt.AlignVCenter
source: model.icon
}
UkuiItems.DtThemeText {
id: fileText
Layout.fillWidth: true
Layout.fillHeight: true
text: model.name
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
textColor: Platform.GlobalTheme.kFontPrimary
}
UkuiItems.DtThemeText {
Layout.preferredWidth: contentWidth
Layout.fillHeight: true
text: model.date
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
textColor: Platform.GlobalTheme.kFontPrimaryDisable
}
}
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
var data = {
"url": model.uri,
"index": model.index
}
data["action"] = "openFile"
send(data)
}
}
MouseArea {
id: itemArea
property bool hovered
acceptedButtons: Qt.LeftButton | Qt.RightButton
anchors.fill: parent
hoverEnabled: true
onEntered: {
hovered = true
}
onExited: {
hovered = false
}
onClicked: {
var data = {
"url": model.uri,
"index": model.index
}
data["action"] = mouse.button === Qt.RightButton ? "contextMenu" : "openFile"
send(data)
}
UkuiItems.Tooltip {
anchors.fill: parent
posFollowCursor: true
mainText: !fileText.truncated ? qsTr("Path: ") + model.path
: model.name + "\n" + qsTr("Path: ") + model.path
visible: itemArea.containsMouse
}
}
}
}
}
}
}
ukui-menu-extensions/recent-file/qml/qml.qrc 0000664 0001750 0001750 00000000160 15160453524 020104 0 ustar feng feng RecentFileExtension.qml
ukui-menu-extensions/recent-file/recent-file-extension.cpp 0000664 0001750 0001750 00000060102 15160453541 022727 0 ustar feng feng /*
* Copyright (C) 2022, 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
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "recent-file-extension.h"
#include "event-track.h"
#include "libkydate.h"
#define KYLIN_APP_MANAGER_NAME "com.kylin.ProcessManager"
#define KYLIN_APP_MANAGER_PATH "/com/kylin/ProcessManager/AppLauncher"
#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.ProcessManager.AppLauncher"
#define FREEDESKTOP_FILEMANAGER_NAME "org.freedesktop.FileManager1"
#define FREEDESKTOP_FILEMANAGER_PATH "/org/freedesktop/FileManager1"
#define FREEDESKTOP_FILEMANAGER_INTERFACE "org.freedesktop.FileManager1"
namespace UkuiMenu {
/**
* @brief 提供最近文件数据的类
* @details 负责从GVFS异步获取最近文件数据并进行处理
*/
class RecentFileProvider : public QObject
{
Q_OBJECT
public:
explicit RecentFileProvider(QObject *parent = nullptr);
/**
* @brief 处理原始文件数据并进行排序
* @param recentFiles 待处理的原始文件数据
*/
void dataProcess(QVector &recentFiles);
public Q_SLOT:
/// 获取最近文件数据的槽函数
void getRecentData();
/**
* @brief 通过GFile打开文件的槽函数
* @param fileUrl 文件URL
*/
void openFileByGFile(const QString &fileUrl);
Q_SIGNALS:
/// 数据加载完成信号,携带处理后的文件数据
void dataLoadCompleted(QVector recentFiles);
};
/**
* @brief 最近文件数据模型类
* @details 继承自QAbstractListModel,为QML提供列表数据
*/
class RecentFilesModel : public QAbstractListModel
{
Q_OBJECT
public:
enum RoleMessage
{
UriRole = Qt::UserRole,
NameRole,
IconRole,
PathRole,
DateRole
};
explicit RecentFilesModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QHash roleNames() const override;
/// 获取指定索引文件的id
QString getInfoId(const int &index);
/// 获取所有文件的id列表
QStringList getAllInfoId();
/// 触发数据更新的方法
Q_INVOKABLE void updateData();
public Q_SLOTS:
/// 更新模型数据的槽函数
void updateRecentFiles(QVector recentFiles);
private Q_SLOTS:
/// 设置日期显示格式
void setDateFormat(QString formate = "");
private:
QDBusInterface* m_dateInterface = nullptr;
QVector m_recentFileData;
QString m_dateFormat;
Q_SIGNALS:
/// 触发数据更新的信号
void updateRecentData();
};
/**
* @brief GVFS最近文件操作工具类
* @details 封装GVFS相关操作,使用C语言API实现文件监控和查询
*/
class GVFSRecentFileData
{
public:
static int s_queryFileNum;
static GFile *s_recentFileRootDir;
static GFileMonitor *s_recentFileMonitor;
/**
* @brief 异步加载最近文件数据
* @param p_recentFileProvider 提供最近文件数据的对象
*/
static void loadRecentFileASync(RecentFileProvider *p_recentFileProvider);
/**
* @brief 初始化文件监控
* @param p_recentFileProvider 监控事件接收对象
*/
static void fileMonitor(RecentFileProvider *p_recentFileProvider);
/**
* @brief 通过infoId删除最近文件
* @param infoId 文件唯一标识
*/
static void removeRecentFileByInfoId(const QString &infoId);
private:
// 异步回调函数
static GAsyncReadyCallback enumerateFinish(GFile *file, GAsyncResult *res, RecentFileProvider *p_recentFileProvider);
static GAsyncReadyCallback parseRecentFiles(GFileEnumerator *enumerator, GAsyncResult *res, RecentFileProvider *p_recentFileProvider);
static void fileChangedCallback(GFileMonitor *monitor,
GFile *file,
GFile *other_file,
GFileMonitorEvent event_type,
RecentFileProvider *p_recentFileProvider);
};
// 静态成员初始化
int GVFSRecentFileData::s_queryFileNum = 100;
GFile *GVFSRecentFileData::s_recentFileRootDir = g_file_new_for_uri("recent:///");
GFileMonitor *GVFSRecentFileData::s_recentFileMonitor = nullptr;
void GVFSRecentFileData::fileMonitor(RecentFileProvider *p_recentFileProvider)
{
GError *error = nullptr;
s_recentFileMonitor = g_file_monitor_directory(GVFSRecentFileData::s_recentFileRootDir,
G_FILE_MONITOR_NONE,
nullptr,
&error);
if (error) {
qWarning() << "recentFile monitor creat error";
g_error_free(error);
return;
}
g_signal_connect(s_recentFileMonitor, "changed", G_CALLBACK(fileChangedCallback), p_recentFileProvider);
}
void GVFSRecentFileData::fileChangedCallback(GFileMonitor *monitor,
GFile *file,
GFile *other_file,
GFileMonitorEvent event_type,
RecentFileProvider *p_recentFileProvider)
{
Q_UNUSED(monitor);
Q_UNUSED(file);
Q_UNUSED(other_file);
switch (event_type) {
case G_FILE_MONITOR_EVENT_DELETED:
case G_FILE_MONITOR_EVENT_CREATED: {
loadRecentFileASync(p_recentFileProvider);
break;
}
default:
break;
}
}
void GVFSRecentFileData::removeRecentFileByInfoId(const QString &infoId)
{
GFile *file = g_file_new_for_uri(infoId.toUtf8().constData());
GError *err = nullptr;
g_file_delete(file, nullptr, &err);
g_object_unref(file);
if (err) {
qWarning() << "Recentfile Delete Error";
}
}
void GVFSRecentFileData::loadRecentFileASync(RecentFileProvider *p_recentFileProvider)
{
if (!s_recentFileRootDir) {
qWarning() << "Can not find 'recent:///' dir.";
return;
}
g_file_enumerate_children_async(s_recentFileRootDir,
"*",
G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT,
nullptr, GAsyncReadyCallback(enumerateFinish),
p_recentFileProvider);
}
GAsyncReadyCallback
GVFSRecentFileData::enumerateFinish(GFile *file, GAsyncResult *res, RecentFileProvider *p_recentFileProvider)
{
GError *error = nullptr;
GFileEnumerator *enumerator = g_file_enumerate_children_finish(file, res, &error);
if (error) {
qWarning() << "GVFSRecentFileData::enumerateFinish Error:" << error->message;
g_error_free(error);
return nullptr;
}
g_file_enumerator_next_files_async(enumerator, s_queryFileNum, G_PRIORITY_DEFAULT,
nullptr, GAsyncReadyCallback(parseRecentFiles), p_recentFileProvider);
g_object_unref(enumerator);
return nullptr;
}
GAsyncReadyCallback
GVFSRecentFileData::parseRecentFiles(GFileEnumerator *enumerator, GAsyncResult *res,
RecentFileProvider *p_recentFileProvider)
{
GError *error = nullptr;
GList *fileList = g_file_enumerator_next_files_finish(enumerator, res, &error);
if (error) {
qWarning() << "GVFSRecentFileData::parseRecentFiles Error:" << error->message;
g_error_free(error);
return nullptr;
}
QVector recentFiles;
if (!fileList) {
p_recentFileProvider->dataProcess(recentFiles);
return nullptr;
}
auto listIterator = fileList;
while (listIterator) {
RecentFile recentFile;
GFileInfo *info = static_cast(listIterator->data);
GFile *file = g_file_enumerator_get_child(enumerator, info);
recentFile.infoId = g_file_get_uri(file);
g_object_unref(file);
char *attribute = g_file_info_get_attribute_as_string(info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
if (attribute) {
recentFile.uri = attribute;
g_free(attribute);
}
const char *fileName = g_file_info_get_display_name(info);
if (fileName) {
recentFile.name = fileName;
}
// in seconds since the UNIX epoch.
recentFile.accessTime = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
GIcon *icon = g_file_info_get_icon(info);
if (icon) {
const gchar *const *iconNames = g_themed_icon_get_names(G_THEMED_ICON(icon));
if (iconNames) {
auto iconNameIterator = iconNames;
while (*iconNameIterator) {
if (QIcon::hasThemeIcon(*iconNameIterator)) {
recentFile.icon = QString(*iconNameIterator);
break;
} else {
++iconNameIterator;
}
}
}
g_object_unref(icon);
}
if (recentFile.icon.isEmpty()) {
recentFile.icon = "text-plain";
}
recentFiles.append(recentFile);
info = nullptr;
listIterator = listIterator->next;
}
g_list_free(fileList);
p_recentFileProvider->dataProcess(recentFiles);
return nullptr;
}
// RecentFileExtension
RecentFileExtension::RecentFileExtension(QObject *parent) : WidgetExtension(parent)
{
// 添加翻译
QString translationFile(QString(RECENT_FILE_TRANSLATION_DIR) + "recent-file_" + QLocale::system().name() + ".qm");
if (QFile::exists(translationFile)) {
QTranslator *translator = new QTranslator(this);
translator->load(translationFile);
QCoreApplication::installTranslator(translator);
}
m_metadata.insert(WidgetMetadata::Id, "recent-file");
m_metadata.insert(WidgetMetadata::Name, tr("Recent Files"));
m_metadata.insert(WidgetMetadata::Tooltip, tr("Recent Files"));
m_metadata.insert(WidgetMetadata::Version, "1.0.0");
m_metadata.insert(WidgetMetadata::Description, "recent-file");
m_metadata.insert(WidgetMetadata::Main, "qrc:///extensions/RecentFileExtension.qml");
m_metadata.insert(WidgetMetadata::Type, WidgetMetadata::Widget);
m_metadata.insert(WidgetMetadata::Flag, WidgetMetadata::OnlySmallScreen);
qRegisterMetaType("RecentFilesModel*");
qRegisterMetaType >("QVector");
m_recentFilesProviderThread = new QThread(this);
m_recentFilesModel = new RecentFilesModel(this);
m_recentFileProvider = new RecentFileProvider();
if (!m_recentFilesProviderThread || !m_recentFilesModel || !m_recentFileProvider) {
qWarning() << "recentfile construction error";
return;
}
// 数据加载放到线程里执行
m_recentFilesProviderThread->start();
m_recentFileProvider->moveToThread(m_recentFilesProviderThread);
connect(this, &RecentFileExtension::loadRecentFiles, m_recentFileProvider, &RecentFileProvider::getRecentData);
connect(m_recentFilesModel, &RecentFilesModel::updateRecentData, m_recentFileProvider,
&RecentFileProvider::getRecentData);
connect(m_recentFileProvider, &RecentFileProvider::dataLoadCompleted, m_recentFilesModel,
&RecentFilesModel::updateRecentFiles);
connect(this, &RecentFileExtension::openFileASync, m_recentFileProvider, &RecentFileProvider::openFileByGFile);
m_data.insert("recentFilesModel", QVariant::fromValue(m_recentFilesModel));
GVFSRecentFileData::fileMonitor(m_recentFileProvider);
Q_EMIT loadRecentFiles();
}
RecentFileExtension::~RecentFileExtension()
{
if (m_recentFilesProviderThread) {
m_recentFilesProviderThread->quit();
m_recentFilesProviderThread->wait();
}
if (m_recentFileProvider) {
delete m_recentFileProvider;
m_recentFileProvider = nullptr;
}
if (GVFSRecentFileData::s_recentFileRootDir) {
g_object_unref(GVFSRecentFileData::s_recentFileRootDir);
}
if (GVFSRecentFileData::s_recentFileMonitor) {
g_object_unref(GVFSRecentFileData::s_recentFileMonitor);
}
}
MetadataMap RecentFileExtension::metadata() const
{
return m_metadata;
}
int RecentFileExtension::index() const
{
return 1;
}
QVariantMap RecentFileExtension::data()
{
return m_data;
}
void RecentFileExtension::receive(const QVariantMap &data)
{
if (data.value("action").toString() == "contextMenu") {
QString path = data.value("url").toString();
int index = data.value("index").toInt();
creatContextMenu(path, index);
return;
}
if (data.value("action").toString() == "closeMenu") {
if (m_contextMenu) {
m_contextMenu.data()->close();
}
}
if (data.value("action").toString() == "emptyAreaContextMenu") {
creatEmptyAreaContextMenu();
return;
}
if (data.value("action").toString() == "openFile") {
QString path = data.value("url").toString();
openFile(path);
}
}
/// 打开指定文件
void RecentFileExtension::openFile(const QString &fileUrl)
{
QDBusMessage message = QDBusMessage::createMethodCall(KYLIN_APP_MANAGER_NAME, KYLIN_APP_MANAGER_PATH, KYLIN_APP_MANAGER_INTERFACE, "LaunchDefaultAppWithUrl");
message << fileUrl;
auto watcher = new QDBusPendingCallWatcher(QDBusConnection::sessionBus().asyncCall(message), this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [fileUrl, this] (QDBusPendingCallWatcher *self) {
if (self->isError()) {
Q_EMIT openFileASync(fileUrl);
}
self->deleteLater();
});
}
/// 创建指定文件项的右键菜单
void RecentFileExtension::creatContextMenu(const QString &path, const int &index)
{
if (m_contextMenu) {
m_contextMenu.data()->close();
return;
}
QMenu *menu = new QMenu;
menu->setAttribute(Qt::WA_DeleteOnClose);
QAction *open = new QAction(getAppIcon(getDefaultAppForUrl(path.toStdString())), tr("Open"), menu);
QAction *directory = new QAction(QIcon::fromTheme("document-open-symbolic"), tr("Open the directory where the file is located"), menu);
QAction *remove = new QAction(QIcon::fromTheme("edit-delete-symbolic"), tr("Remove from list"), menu);
QAction *clear = new QAction(QIcon::fromTheme("user-trash-symbolic"), tr("Clear all"), menu);
connect(open, &QAction::triggered, this, [this, path]() {
openFile(path);
});
connect(directory, &QAction::triggered, this, [this, path]() {
QDBusMessage message = QDBusMessage::createMethodCall(FREEDESKTOP_FILEMANAGER_NAME,
FREEDESKTOP_FILEMANAGER_PATH,
FREEDESKTOP_FILEMANAGER_INTERFACE, "ShowFolders");
message << QStringList(path) << "ukui-menu-recent-file";
QDBusConnection::sessionBus().asyncCall(message);
});
connect(remove, &QAction::triggered, this, [this, index]() {
GVFSRecentFileData::removeRecentFileByInfoId(m_recentFilesModel->getInfoId(index));
EventTrack::instance()->sendDefaultEvent("remove_recent_file", "RightClickMenu");
});
connect(clear, &QAction::triggered, this, [this]() {
QStringList infoIdList = m_recentFilesModel->getAllInfoId();
for (const QString &infoId : infoIdList) {
GVFSRecentFileData::removeRecentFileByInfoId(infoId);
}
EventTrack::instance()->sendDefaultEvent("clear_recent_files", "RightClickMenu");
});
menu->addAction(open);
menu->addAction(directory);
menu->addSeparator();
menu->addAction(remove);
menu->addAction(clear);
m_contextMenu = menu;
menu->popup(QCursor::pos());
}
/// 创建空白区域的右键菜单
void RecentFileExtension::creatEmptyAreaContextMenu()
{
if (m_contextMenu) {
m_contextMenu.data()->close();
return;
}
QMenu *menu = new QMenu;
menu->setAttribute(Qt::WA_DeleteOnClose);
QAction *clear = new QAction(QIcon::fromTheme("user-trash-symbolic"), tr("Clear all"), menu);
connect(clear, &QAction::triggered, this, [this]() {
QStringList infoIdList = m_recentFilesModel->getAllInfoId();
for (const QString &infoId : infoIdList) {
GVFSRecentFileData::removeRecentFileByInfoId(infoId);
}
EventTrack::instance()->sendDefaultEvent("clear_recent_files", "RightClickMenu");
});
menu->addAction(clear);
m_contextMenu = menu;
menu->popup(QCursor::pos());
}
QString RecentFileExtension::getDefaultAppForUrl(const std::string &url)
{
GAppInfo *appInfo = nullptr;
char *uriScheme = g_uri_parse_scheme(url.c_str());
if (uriScheme && uriScheme[0] != '\0') {
appInfo = g_app_info_get_default_for_uri_scheme(uriScheme);
}
g_free(uriScheme);
if (!appInfo) {
GFile *file = g_file_new_for_uri(url.c_str());
appInfo = g_file_query_default_handler(file, nullptr, nullptr);
g_object_unref(file);
}
if (appInfo) {
QString appId = g_app_info_get_id(appInfo);
g_object_unref(appInfo);
QString desktopFile = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, appId);
return desktopFile;
}
return QString();
}
QIcon RecentFileExtension::getAppIcon(const QString &desktoFile)
{
if (desktoFile.isEmpty()) {
return QIcon::fromTheme("unk-app-symbolic");
}
XdgDesktopFile xdf;
xdf.load(desktoFile);
QString iconName;
iconName = xdf.iconName();
if(iconName.startsWith("/")) {
if(QFile::exists(iconName)) {
return QIcon(iconName);
}
} else {
return QIcon::fromTheme(iconName).isNull() ? XdgIcon::fromTheme(iconName) : QIcon::fromTheme(iconName);
}
return QIcon::fromTheme("unk-app-symbolic");
}
RecentFilesModel::RecentFilesModel(QObject *parent) : QAbstractListModel(parent)
{
QDBusConnection::sessionBus().connect("com.kylin.kysdk.DateServer",
"/com/kylin/kysdk/Date",
"com.kylin.kysdk.DateInterface",
"ShortDateSignal",
this, SLOT(setDateFormat(QString)));
setDateFormat();
}
int RecentFilesModel::rowCount(const QModelIndex &parent) const
{
return m_recentFileData.count();
}
QVariant RecentFilesModel::data(const QModelIndex &index, int role) const
{
int row = index.row();
if (row < 0 || row >= m_recentFileData.count()) {
return {};
}
switch (role) {
case UriRole:
return m_recentFileData.at(row).uri;
case NameRole:
return m_recentFileData.at(row).name;
case IconRole:
return m_recentFileData.at(row).icon;
case PathRole: {
QUrl baseUrl(m_recentFileData.at(row).uri);
return baseUrl.adjusted(QUrl::RemoveFilename).path();
}
case DateRole: {
QDateTime time = QDateTime::fromSecsSinceEpoch(m_recentFileData.at(row).accessTime);
return time.toString(m_dateFormat);
}
default:
break;
}
return {};
}
QHash RecentFilesModel::roleNames() const
{
QHash names;
names.insert(UriRole, "uri");
names.insert(NameRole, "name");
names.insert(IconRole, "icon");
names.insert(PathRole, "path");
names.insert(DateRole, "date");
return names;
}
QString RecentFilesModel::getInfoId(const int &index)
{
return m_recentFileData.at(index).infoId;
}
QStringList RecentFilesModel::getAllInfoId()
{
QStringList infoIdList;
for (const RecentFile &data : m_recentFileData) {
infoIdList.append(data.infoId);
}
return infoIdList;
}
void RecentFilesModel::updateData()
{
Q_EMIT updateRecentData();
}
void RecentFilesModel::updateRecentFiles(QVector recentFiles)
{
beginResetModel();
m_recentFileData.swap(recentFiles);
endResetModel();
}
void RecentFilesModel::setDateFormat(QString formate)
{
if (formate == "") {
char* date = kdk_system_get_shortformat();
m_dateFormat = date;
free(date);
} else {
m_dateFormat = formate;
}
QVector vec;
vec.append(RoleMessage::DateRole);
Q_EMIT dataChanged(index(0,0), index(m_recentFileData.length() - 1, 0), vec);
}
RecentFileProvider::RecentFileProvider(QObject *parent) : QObject(parent)
{
}
void RecentFileProvider::dataProcess(QVector &recentFiles)
{
std::sort(recentFiles.begin(), recentFiles.end(), [](const RecentFile &a, const RecentFile &b) {
return a.accessTime > b.accessTime;
});
Q_EMIT dataLoadCompleted(recentFiles);
}
void RecentFileProvider::getRecentData()
{
GVFSRecentFileData::loadRecentFileASync(this);
}
void RecentFileProvider::openFileByGFile(const QString &fileUrl)
{
GFile *file = g_file_new_for_uri(fileUrl.toUtf8().constData());
if (!file) {
return;
}
GFileInfo *fileInfo = g_file_query_info(file, "standard::*," G_FILE_ATTRIBUTE_ID_FILE, G_FILE_QUERY_INFO_NONE, nullptr, nullptr);
if (!fileInfo) {
g_object_unref(file);
return;
}
QString mimeType(g_file_info_get_content_type(fileInfo));
if (mimeType.isEmpty()) {
if (g_file_info_has_attribute(fileInfo, "standard::fast-content-type")) {
mimeType = g_file_info_get_attribute_string(fileInfo, "standard::fast-content-type");
}
}
GError *error = NULL;
GAppInfo *info = NULL;
QString mimeAppsListPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/mimeapps.list";
GKeyFile *keyfile = g_key_file_new();
gboolean ret = g_key_file_load_from_file(keyfile, mimeAppsListPath.toUtf8(), G_KEY_FILE_NONE, &error);
if (!ret) {
qWarning() << "load mimeapps list error msg" << error->message;
info = g_app_info_get_default_for_type(mimeType.toUtf8().constData(), false);
g_error_free(error);
} else {
gchar *desktopApp = g_key_file_get_string(keyfile, "Default Applications", mimeType.toUtf8(), &error);
if (NULL == desktopApp) {
info = g_app_info_get_default_for_type(mimeType.toUtf8().constData(), false);
} else {
info = (GAppInfo *) g_desktop_app_info_new(desktopApp);
g_free(desktopApp);
}
}
g_key_file_free(keyfile);
bool success = false;
if (G_IS_APP_INFO(info)) {
GList *files = g_list_alloc();
g_list_append(files, file);
success = g_app_info_launch(info, files, nullptr, nullptr);
g_list_free(files);
}
if (!success) {
QDesktopServices::openUrl(fileUrl);
}
g_object_unref(file);
g_object_unref(info);
}
RecentFileExtensionPlugin::~RecentFileExtensionPlugin()
{
}
QString RecentFileExtensionPlugin::id()
{
return "recent-file";
}
WidgetExtension *RecentFileExtensionPlugin::createWidgetExtension()
{
return new RecentFileExtension;
}
ContextMenuExtension *RecentFileExtensionPlugin::createContextMenuExtension()
{
return nullptr;
}
} // UkuiMenu
#include "recent-file-extension.moc"
ukui-menu-extensions/recent-file/event-track.cpp 0000664 0001750 0001750 00000003444 15160453541 020751 0 ustar feng feng /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
#include "event-track.h"
#include
using namespace UkuiMenu;
EventTrack::EventTrack(QObject *parent) : QObject(parent)
{
}
EventTrack *EventTrack::instance()
{
static EventTrack eventTrack;
return &eventTrack;
}
void EventTrack::sendClickEvent(const QString &event, const QString &page)
{
KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK);
kdk_dia_upload_default(data, event.toUtf8().data(), page.toUtf8().data());
kdk_dia_data_free(data);
}
void EventTrack::sendDefaultEvent(const QString& event, const QString& page)
{
KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CUSTOM);
kdk_dia_upload_default(data, event.toUtf8().data(), page.toUtf8().data());
kdk_dia_data_free(data);
}
void EventTrack::sendSearchEvent(const QString &event, const QString &page, const QString &content)
{
KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_SEARCH);
kdk_dia_upload_search_content(data, event.toUtf8().data(), page.toUtf8().data(), content.toUtf8().data());
kdk_dia_data_free(data);
}
ukui-menu-extensions/recent-file/metadata.json 0000664 0001750 0001750 00000000076 15160453524 020474 0 ustar feng feng {
"Type": "UKUI_MENU_EXTENSION",
"Version": "1.0.2"
}
ukui-menu-extensions/.gitignore 0000664 0001750 0001750 00000001206 15160453524 015610 0 ustar feng feng # C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.so.*
*.dll
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
*.qm
*.prl
# Qt unit tests
target_wrapper.*
# QtCreator
*.autosave
# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCreator CMake
CMakeLists.txt.user*
# QtCreator 4.8< compilation database
compile_commands.json
# QtCreator local machine specific files for imported projects
*creator.user*
*_qmlcache.qrc
*.idea
build
*/build