Import Upstream version 3.20.1.17

This commit is contained in:
jzxc95 2022-12-08 14:00:51 +08:00
commit 8a29c5293a
394 changed files with 51316 additions and 0 deletions

1
AUTHORS Normal file
View File

@ -0,0 +1 @@
shine <shenghuang@ubuntukylin.com>

674
COPYING Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 <http://www.gnu.org/licenses/>.
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:
<program> Copyright (C) <year> <name of author>
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
<http://www.gnu.org/licenses/>.
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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

189
README.md Normal file
View File

@ -0,0 +1,189 @@
## kylin-nm介绍
### 简介
麒麟网络工具kylin-network-manager简称kylin-nm是操作系统的网络前端其主要功能有
1、托盘栏图标及右键菜单
查看当前网络状态
左键点击托盘网络图标显示kylin-nm主界面
右键点击托盘网络图标显示右键菜单
2、对有线网络的管理
有线网络界面管理
连接/断开网络
网线拔插
多有线网卡支持
打开或关闭有线开关
查看或修改无线网络基本信息
3、对无线网络的管理
切换及刷新无线界面
查看无线网络列表
连接/断开无需密码的无线网
连接/断开有密码类型的无线网
无线网卡插拔
多无线网卡支持
打开或关闭无线开关
查看或修改无线网络基本信息
4、连接隐藏无线网络
连接无安全性的无线网络
连接WPA及WPA2个人安全性的无线网络
连接WPA及WPA2企业安全性的无线网络
连接WPA3个人安全性的无线网络
5、窗口样式调节
深色与浅色窗口样式切换
调节网络工具窗口透明度
普通窗口与具有毛玻璃效果的窗口的切换
### 运行
麒麟网络工具的进程为kylin-nm默认开机自启依赖NetworkManger
### 命令行和dbus接口
kylin-nm进程的命令行如下
Usage: kylin-nm
#### dbus接口
DBUS类型SESSION BUS
DBUS名称com.kylin.network
OBJECT路径/
接口名称com.kylin.network
#### dbus方法
getWirelessList
参数:无
返回值QMap<QString, QVector<QStringList>>
键:网卡名称
值:无线网络的集合(第一项为已连接网络信息,若无连接则为"--",否则为"名称/信号强度/加密类型/Uuid/是否为本机开放热点";其余为未连接的网络信息,为"名称/信号强度/加密类型/是否为本机开放热点"
功能:获取无线列表及每个对应无线网络的信号强度、加密类型等信息。
getWiredList
参数:无
返回值QMap<QString, QVector<QStringList>>
键:网卡名称
值:有线网络的集合("名称/UUID/对应DBUS路径"),若无已连接网络则第一项默认为"--"
功能获取有线列表及每个对应的有线网络的uuid及dbus路径
setWiredSwitchEnable(bool enable)
参数:(bool开启有线总开关true关闭有线总开关false
返回值:无
功能:打开或关闭有线总开关
setWirelessSwitchEnable(bool enable)
参数:(bool开启无线总开关true关闭无线总开关false
返回值:无
功能:打开或关闭无线总开关
setDeviceEnable(QString devName, bool enable)
参数QStringdevName 设备名称bool enable 开启/关闭
返回值:无
功能:打开或关闭单个有线网卡开关
activateConnectint type, QString devName, QString ssid
参数:根据网卡类型 参数1 0:lan 1:wlan 参数2网卡名称 参数3uuid/ssid
返回值:无
功能:激活一个网络连接
deActivateConnect(int type, QString devName, QString ssid)
参数:根据网卡类型 参数1 0:lan 1:wlan 参数2网卡名称 参数3uuid/ssid
返回值:无
功能:断开一个网络连接
getDeviceListAndEnabled(int devType)
参数int devType 0:lan 1:wlan
返回值QMap<QString, bool>
键:设备名称
bool 开启true关闭 false
功能:获取设备列表和启用/禁用状态
getWirelessDeviceCap
返回值QMap<QString, int>
键:设备名称
int 0不支持热点 3支持2.4GHz 7支持5GHz&&2.4Ghz
功能:获取无线设备能力(2.4G/5G)
showPropertyWidget(QString devName, QString ssid)
参数QString devName 设备名称 QString ssid 根据网卡类型 有线为uuid/无线为ssid
返回值:无
功能:唤起对应网络连接的属性页,可以对基础信息的显示或修改
showCreateWiredConnectWidget(QString devName)
参数QString devName 有线网卡名称
返回值:无
功能:唤起新建有线连接界面
activeWirelessAp(const QString apName,
const QString apPassword,
const QString band,
const QString apDevice)
参数QString apName 热点名称
QString apPassword 热点密码
QString band 频带
QString apDevice
返回值:无
功能:开启移动热点
deactiveWirelessAp(const QString apName, const QString uuid)
参数QStringList名称/密码/设备名称/状态/UUID/频带)
返回值:无
功能: 断开移动热点
getStoredApInfo
参数QStringList名称/密码/设备名称/状态/UUID/频带)
返回值:无
功能:获取已保存的移动热点信息
getApInfoBySsid(QString devName, QString ssid)
参数QString devName 设备名称 QString ssid
返回值:无
功能:通过名称获取已保存的移动热点信息
reScan()
参数:无
返回值:无
功能:申请重新进行无线扫描
keyRingInit()
参数QString apName 热点名称 QString uuid
返回值:无
功能:断开移动热点
keyRingClear()
参数:无
返回值:无
功能: 断开移动热点
### 原理与主要使用的技术
kylin-nm主要与NetworkManager进行交互通过对应的dbus信号驱动UI界面的更新。并通过提供的dbus方法来进行网络相关功能的调用。
麒麟网络工具按照功能划分成两层UI层和逻辑层。UI层实现网络资源的显示以及用户的交互逻辑层通过NetworkManager提供的Dbus接口完成网络资源的管理及其配置。
### 配置文件
kylin-nm的配置文件保存在如下路径
~/.config/ukui/kylin-nm.conf 有线无线开关状态 设备状态
org.ukui.kylin-nm.switch 对应的gsetting值 (有线无线开关状态)
### 编译
cd kylin-nm
mkdir build
cd build
qmake ..
make
sudo make install 
### 运行命令
./kylin-nm
### 调试
kylin-nm目前并采用ukui-log4qt模块的日志功能。日志默认保存在~/.log/kylin-nm.log中

1162
debian/changelog vendored Normal file

File diff suppressed because it is too large Load Diff

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
9

48
debian/control vendored Normal file
View File

@ -0,0 +1,48 @@
Source: kylin-nm
Section: utils
Priority: optional
Maintainer: Kylin Team <team+kylin@tracker.debian.org>
Uploaders: handsome_feng <jianfengli@ubuntukylin.com>
Build-Depends: debhelper (>=9),
qtbase5-dev,
qt5-qmake,
qtchooser,
qtscript5-dev,
qttools5-dev-tools,
qtbase5-dev-tools,
libqt5x11extras5-dev,
libgsettings-qt-dev,
libkf5windowsystem-dev,
libx11-dev,
libqt5svg5-dev,
libkf5networkmanagerqt-dev (>= 5.36.0),
libnm-dev,
libcap-dev,
libnma-dev,
libsecret-1-dev,
libgtk-3-dev,
libukcc-dev (>= 3.1.1+1217),
libukui-log4qt-dev,
libkysdk-qtwidgets-dev(>= 1.2.0),
libkysdk-sysinfo-dev,
libkysdk-waylandhelper-dev(>= 1.2.0kylin2),
libkysec-dev,
Standards-Version: 4.5.0
Rules-Requires-Root: no
Homepage: https://github.com/ukui/kylin-nm
Vcs-Git: https://github.com/ukui/kylin-nm.git
Vcs-Browser: https://github.com/ukui/kylin-nm
Package: kylin-nm
Architecture: any
Depends: network-manager (>= 1.22.10-1kylin29k3.6),
ukui-control-center (>= 3.1.1+1217),
libkysdk-qtwidgets(>= 1.2.0),
libkysdk-waylandhelper(>= 1.2.0kylin2),
libkysdk-sysinfo,
${shlibs:Depends},
${misc:Depends}
Description: Gui Applet tool for display and edit network simply
Kylin NM is a Applet tool for managing network settings simply.
It has beautiful UI and very comfortable to use.
It's better work together with UKUI.

25
debian/copyright vendored Normal file
View File

@ -0,0 +1,25 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: kylin-nm
Upstream-Contact: Kylin Team <ukui@kylinos.cn>
Source: https://github.com/ukui/kylin-nm
Files: *
Copyright: 2019, Tianjin KYLIN Information Technology Co., Ltd.
License: GPL-3+
License: GPL-3+
This package 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 package 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 Genaral Public License for more details.
.
You should have received a copy og the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".

1
debian/kylin-nm.manpages vendored Normal file
View File

@ -0,0 +1 @@
man/kylin-nm.1

14
debian/kylin-nm.postinst vendored Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
set -e
PROGRAM=$(dpkg-divert --truename /usr/bin/kylin-nm)
if setcap cap_net_raw+ep $PROGRAM; then
chmod u-s $PROGRAM
fi
echo "kylin nm set cap success"
exit 0

9
debian/kylin-nm.preinst vendored Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
set -e
path="/usr/lib/`/usr/bin/dpkg-architecture -qDEB_TARGET_MULTIARCH`/ukui-control-center/libnetconnect.so"
dpkg-divert --package kylin-nm --rename --divert "$path"".old" --add $path
path2="/usr/lib/`/usr/bin/dpkg-architecture -qDEB_TARGET_MULTIARCH`/ukui-control-center/libproxy.so"
dpkg-divert --package kylin-nm --rename --divert "$path2"".old" --add $path2

34
debian/rules vendored Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/make -f
export QT_SELECT=5
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
QMAKE_OPTS = DEFINES+=NO_DEBUG_ON_CONSOLE
MAKE_OPTS = PREFIX=/usr QMAKE=qmake LRELEASE=lrelease QMAKE_OPTS="$(QMAKE_OPTS)"
override_dh_auto_configure:
QT_SELECT=qt5 dh_auto_configure \
-- "QMAKE_CXXFLAGS=$(CFLAGS)" \
kylin-nm.pro
%:
dh $@
override_dh_install:
dh_install
override_dh_missing:
dh_missing --fail-missing
override_dh_auto_clean:
[ ! -d .moc ] || $(RM) -r .moc
[ ! -d .obj ] || $(RM) -r .obj
[ ! -d .ui ] || $(RM) -r .ui
[ ! -f Makefile ] || dh_auto_clean
override_dh_auto_build:
dh_auto_build -- $(MAKE_OPTS)
override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (native)

2
debian/watch vendored Normal file
View File

@ -0,0 +1,2 @@
version=4
https://github.com/ukui/kylin-nm/releases .*/kylin-nm_(\d\S+)\.orig\.tar\.gz

14
kylin-nm.pro Normal file
View File

@ -0,0 +1,14 @@
TEMPLATE = subdirs
CONFIG += ordered \
qt
SUBDIRS = \
plugins/plugin.pro \
src \
TRANSLATIONS += \
translations/kylin-nm_zh_CN.ts \
translations/kylin-nm_tr.ts \
translations/kylin-nm_bo.ts \
translations/kylin-nm_bo_CN.ts

20
man/kylin-nm.1 Normal file
View File

@ -0,0 +1,20 @@
.\" Man page for Kylin-nm
.TH KYLIN-NM 1 "20 September 2019" "UKUI Desktop Environment"
.\" Please adjust this date when revising the manpage.
.\"
.SH "NAME"
kylin-nm \- The tool for the UKUI Desktop Environment
.SH "SYNOPSIS"
.B kylin-nm
.SH "DESCRIPTION"
The \fBkylin-nm\fR program is a part of the ukui-indicators, It provides network manager for the the UKUI Desktop Environment. Detect the system disk automatically, Can pop up and open the device.
.PP
This manual page documents the \fBkylin-nm\fR command.
.P
.SH "BUGS"
.SS Should you encounter any bugs, they may be reported at:
https://github.com/ukui/kylin-nm/issues
.SH "AUTHORS"
.SS This Man Page has been written for the UKUI Desktop Environment by:
shine <shenghuang@ubuntukylin.com> (2019)
.SH "SEE ALSO"

133
nmqrc.qrc Normal file
View File

@ -0,0 +1,133 @@
<RCC>
<qresource prefix="/">
<file>res/g/down_arrow.png</file>
<file>res/s/rescan/1.png</file>
<file>res/s/rescan/2.png</file>
<file>res/s/rescan/3.png</file>
<file>res/s/rescan/4.png</file>
<file>res/s/rescan/5.png</file>
<file>res/s/rescan/6.png</file>
<file>res/s/rescan/7.png</file>
<file>res/s/rescan/8.png</file>
<file>res/s/rescan/9.png</file>
<file>res/s/rescan/10.png</file>
<file>res/s/rescan/11.png</file>
<file>res/s/rescan/12.png</file>
<file>res/h/hide-pwd.png</file>
<file>res/h/right-pwd.png</file>
<file>res/h/show-pwd.png</file>
<file>res/h/no-pwd-wifi.png</file>
<file>translations/kylin-nm_bo.qm</file>
<file>translations/kylin-nm_tr.qm</file>
<file>translations/kylin-nm_zh_CN.qm</file>
<file>res/x/fly-mode-off.svg</file>
<file>res/x/fly-mode-on.svg</file>
<file>res/x/hot-spot-off.svg</file>
<file>res/x/hot-spot-on.svg</file>
<file>res/x/net-list-bg.svg</file>
<file>res/x/wifi-list-bg.svg</file>
<file>res/x/load-down.png</file>
<file>res/x/load-up.png</file>
<file>res/l/network-offline.png</file>
<file>res/l/network-offline.svg</file>
<file>res/l/network-online.png</file>
<file>res/l/network-online.svg</file>
<file>res/w/wifi-full.png</file>
<file>res/w/wifi-full-pwd.png</file>
<file>res/w/wifi-high.png</file>
<file>res/w/wifi-high-pwd.png</file>
<file>res/w/wifi-low.png</file>
<file>res/w/wifi-low-pwd.png</file>
<file>res/w/wifi-medium.png</file>
<file>res/w/wifi-medium-pwd.png</file>
<file>res/w/wifi-none.png</file>
<file>res/w/wifi-none-pwd.png</file>
<file>res/s/conning-a/1.png</file>
<file>res/s/conning-a/2.png</file>
<file>res/s/conning-a/3.png</file>
<file>res/s/conning-a/4.png</file>
<file>res/s/conning-a/5.png</file>
<file>res/s/conning-a/6.png</file>
<file>res/s/conning-a/7.png</file>
<file>res/s/conning-a/8.png</file>
<file>res/g/close_black.png</file>
<file>res/g/close_white.png</file>
<file>res/s/conning-s/1.png</file>
<file>res/s/conning-s/2.png</file>
<file>res/s/conning-s/3.png</file>
<file>res/s/conning-s/4.png</file>
<file>res/s/conning-s/5.png</file>
<file>res/s/conning-s/6.png</file>
<file>res/s/conning-s/7.png</file>
<file>res/s/conning-s/8.png</file>
<file>res/s/conning-s/9.png</file>
<file>res/s/conning-s/10.png</file>
<file>res/s/conning-s/11.png</file>
<file>res/s/conning-s/12.png</file>
<file>res/x/setup.png</file>
<file>res/x/control.svg</file>
<file>res/w/wifi6-full-pwd.png</file>
<file>res/w/wifi6-full.png</file>
<file>res/w/wifi6-high-pwd.png</file>
<file>res/w/wifi6-high.png</file>
<file>res/w/wifi6-low-pwd.png</file>
<file>res/w/wifi6-low.png</file>
<file>res/w/wifi6-medium-pwd.png</file>
<file>res/w/wifi6-medium.png</file>
<file>res/w/wifi6-none.png</file>
<file>res/w/wifi6+-none.png</file>
<file>res/w/wifi6+-meidum-pwd.png</file>
<file>res/w/wifi6+-medium.png</file>
<file>res/w/wifi6+-medium-pwd.png</file>
<file>res/w/wifi6+-low.png</file>
<file>res/w/wifi6+-low-pwd.png</file>
<file>res/w/wifi6+-high.png</file>
<file>res/w/wifi6+-high-pwd.png</file>
<file>res/w/wifi6+-full.png</file>
<file>res/w/wifi6+-full-pwd.png</file>
<file>res/w/wifi6-none-pwd.png</file>
<file>res/hw/wifi-full-pwd.png</file>
<file>res/hw/wifi-full.png</file>
<file>res/hw/wifi-high-pwd.png</file>
<file>res/hw/wifi-high.png</file>
<file>res/hw/wifi-low-pwd.png</file>
<file>res/hw/wifi-low.png</file>
<file>res/hw/wifi-medium-pwd.png</file>
<file>res/hw/wifi-medium.png</file>
<file>res/hw/wifi-none-pwd.png</file>
<file>res/hw/wifi-none.png</file>
<file>res/hw/wifi6-full-pwd.png</file>
<file>res/hw/wifi6-full.png</file>
<file>res/hw/wifi6-high-pwd.png</file>
<file>res/hw/wifi6-high.png</file>
<file>res/hw/wifi6-low-pwd.png</file>
<file>res/hw/wifi6-low.png</file>
<file>res/hw/wifi6-medium-pwd.png</file>
<file>res/hw/wifi6-medium.png</file>
<file>res/hw/wifi6-none-pwd.png</file>
<file>res/hw/wifi6-none.png</file>
<file>res/hw/wifi6+-full-pwd.png</file>
<file>res/hw/wifi6+-full.png</file>
<file>res/hw/wifi6+-high-pwd.png</file>
<file>res/hw/wifi6+-high.png</file>
<file>res/hw/wifi6+-low-pwd.png</file>
<file>res/hw/wifi6+-low.png</file>
<file>res/hw/wifi6+-medium-pwd.png</file>
<file>res/hw/wifi6+-medium.png</file>
<file>res/hw/wifi6+-none-pwd.png</file>
<file>res/hw/wifi6+-none.png</file>
<file>res/s/conning-b/1.png</file>
<file>res/s/conning-b/2.png</file>
<file>res/s/conning-b/3.png</file>
<file>res/s/conning-b/4.png</file>
<file>res/s/conning-b/5.png</file>
<file>res/s/conning-b/6.png</file>
<file>res/s/conning-b/7.png</file>
<file>res/s/conning-b/8.png</file>
<file>res/s/conning-b/9.png</file>
<file>res/s/conning-b/10.png</file>
<file>res/s/conning-b/11.png</file>
<file>res/s/conning-b/12.png</file>
<file>translations/kylin-nm_bo_CN.qm</file>
</qresource>
</RCC>

View File

@ -0,0 +1,110 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "addnetbtn.h"
#include <QEvent>
#include <QHBoxLayout>
#include <QLabel>
#include <QVariant>
#include <QPainter>
#include <QPainterPath>
#define RADIUS 6.0
AddNetBtn::AddNetBtn(bool isWlan, QWidget *parent) : QPushButton(parent)
{
this->setObjectName("this");
this->setMinimumSize(QSize(580, 60));
this->setMaximumSize(QSize(16777215, 60));
this->setProperty("useButtonPalette", true);
this->setFlat(true);
QPalette pal = this->palette();
QColor color = pal.color(QPalette::Button);
color.setAlphaF(0.5);
pal.setColor(QPalette::Button, color);
this->setPalette(pal);
QHBoxLayout *addLyt = new QHBoxLayout;
QLabel *iconLabel = new QLabel();
QLabel *textLabel = new QLabel();
if (isWlan) {
textLabel->setText(tr("Add Others"));
addLyt->addSpacing(8);
addLyt->addWidget(textLabel);
} else {
textLabel->setText(tr("Add WiredNetork"));
QIcon mAddIcon = QIcon::fromTheme("list-add-symbolic");
iconLabel->setPixmap(mAddIcon.pixmap(mAddIcon.actualSize(QSize(24, 24))));
iconLabel->setProperty("useIconHighlightEffect", true);
iconLabel->setProperty("iconHighlightEffectMode", 1);
addLyt->addStretch();
addLyt->addWidget(iconLabel);
addLyt->addWidget(textLabel);
}
addLyt->addStretch();
this->setLayout(addLyt);
}
AddNetBtn::~AddNetBtn()
{
}
void AddNetBtn::enterEvent(QEvent *event){
Q_EMIT enterWidget();
QPushButton::enterEvent(event);
}
void AddNetBtn::leaveEvent(QEvent *event){
Q_EMIT leaveWidget();
QPushButton::leaveEvent(event);
}
void AddNetBtn::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
painter.setBrush(pal.color(QPalette::Base));
QRect rect = this->rect();
QPainterPath path;
//设置起点
path.moveTo(rect.topLeft().x(), rect.topLeft().y());
path.lineTo(rect.bottomLeft().x(), rect.bottomLeft().y() - RADIUS);
//绘制圆角 圆弧以外切圆的270度位置为起点逆时针画圆弧运行90度结束
path.arcTo(QRect(QPoint(rect.bottomLeft().x(), rect.bottomLeft().y() - (RADIUS * 2)), QSize(RADIUS * 2, RADIUS * 2)), 180, 90);
path.lineTo(rect.bottomRight().x() - RADIUS, rect.bottomRight().y());
//画圆弧
path.arcTo(QRect(QPoint(rect.bottomRight().x() - (RADIUS * 2), rect.bottomRight().y() - (RADIUS * 2)), QSize(RADIUS * 2, RADIUS * 2)), 270, 90);
path.lineTo(rect.topRight());
path.lineTo(rect.topLeft());
painter.drawPath(path);
QPushButton::paintEvent(event);
}

View File

@ -0,0 +1,46 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef ADDNETBTN_H
#define ADDNETBTN_H
#include <QObject>
#include <QWidget>
#include <QPushButton>
#include <QTranslator>
#include <QApplication>
class AddNetBtn : public QPushButton
{
Q_OBJECT
public:
AddNetBtn(bool isWlan, QWidget *parent = nullptr);
~AddNetBtn();
protected:
virtual void leaveEvent(QEvent * event);
virtual void enterEvent(QEvent * event);
void paintEvent(QPaintEvent *event);
Q_SIGNALS:
void enterWidget();
void leaveWidget();
};
#endif // ADDNETBTN_H

View File

@ -0,0 +1,33 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "grayinfobutton.h"
#include <QVariant>
#define BUTTON_SIZE 36,36
#define ICON_SIZE 16,16
GrayInfoButton::GrayInfoButton(QWidget *parent): QPushButton(parent)
{
this->setFixedSize(BUTTON_SIZE);
this->setIcon(QIcon::fromTheme("preferences-system-details-symbolic"));
this->setProperty("useButtonPalette", true);
this->setFlat(true);
}

View File

@ -0,0 +1,34 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef GRAYINFOBUTTON_H
#define GRAYINFOBUTTON_H
#include <QPushButton>
#include <QIcon>
class GrayInfoButton : public QPushButton
{
Q_OBJECT
public:
explicit GrayInfoButton(QWidget * parent = nullptr);
~GrayInfoButton() = default;
};
#endif // GRAYINFOBUTTON_H

View File

@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "drownlabel.h"
#include "deviceframe.h"
#define ICONSIZE 16,16
DrownLabel::DrownLabel(QString devName, QWidget * parent) : QLabel(parent)
{
m_devName = devName;
setFixedSize(36,36);
loadPixmap(isChecked);
this->setProperty("useIconHighlightEffect", 0x2);
}
DrownLabel::~DrownLabel()
{
}
void DrownLabel::setDropDownStatus(bool status)
{
isChecked = status;
loadPixmap(isChecked);
}
void DrownLabel::loadPixmap(bool isChecked)
{
if (isChecked) {
setPixmap(QIcon::fromTheme("ukui-up-symbolic").pixmap(ICONSIZE));
} else {
setPixmap(QIcon::fromTheme("ukui-down-symbolic").pixmap(ICONSIZE));
}
}
void DrownLabel::mouseReleaseEvent(QMouseEvent *event)
{
emit labelClicked();
QWidget::mouseReleaseEvent(event);
}

View File

@ -0,0 +1,46 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef DROWNLABEL_H
#define DROWNLABEL_H
#include <QObject>
#include <QLabel>
#include <QWidget>
#include <QMouseEvent>
class DrownLabel : public QLabel
{
Q_OBJECT
public:
explicit DrownLabel(QString devName, QWidget * parent = nullptr);
~DrownLabel();
void setDropDownStatus(bool status);
QString m_devName;
bool isChecked = true;
private:
void loadPixmap(bool isChecked);
protected:
virtual void mouseReleaseEvent(QMouseEvent * event);
Q_SIGNALS:
void labelClicked();
};
#endif // DROWNLABEL_H

View File

@ -0,0 +1,124 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "infobutton.h"
#include <QEvent>
#include <QPainter>
#include <QApplication>
#include <QDebug>
#define BUTTON_SIZE 36,36
#define ICON_SIZE 16,16
#define BACKGROUND_COLOR QColor(0,0,0,0)
#define FOREGROUND_COLOR_NORMAL qApp->palette().text().color()
#define FOREGROUND_COLOR_HOVER QColor(55,144,250,255)
#define FOREGROUND_COLOR_PRESS QColor(36,109,212,255)
#define OUTER_PATH 8,8,16,16
#define INNER_PATH 9,9,14,14
#define TEXT_POS 14,5,16,16,0
#define BUTTON_SIZE 36,36
#define THEME_SCHAME "org.ukui.style"
#define COLOR_THEME "styleName"
InfoButton::InfoButton(QWidget *parent) : QPushButton(parent)
{
this->setFixedSize(BUTTON_SIZE);
initUI();
const QByteArray style_id(THEME_SCHAME);
if (QGSettings::isSchemaInstalled(style_id)) {
m_styleGsettings = new QGSettings(style_id);
connect(m_styleGsettings, &QGSettings::changed, this, &InfoButton::onGSettingChaned);
} else {
qDebug() << "Gsettings interface \"org.ukui.style\" is not exist!";
}
}
void InfoButton::initUI()
{
this->setFixedSize(BUTTON_SIZE);
m_backgroundColor = BACKGROUND_COLOR;
m_foregroundColor = FOREGROUND_COLOR_NORMAL;
}
void InfoButton::onGSettingChaned(const QString &key)
{
if (key == COLOR_THEME) {
m_foregroundColor = FOREGROUND_COLOR_NORMAL;
this->repaint();
}
}
void InfoButton::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
pal.setColor(QPalette::Base, m_backgroundColor);
pal.setColor(QPalette::Text, m_foregroundColor);
QPainterPath cPath;
cPath.addRect(0, 0, ICON_SIZE);
cPath.addEllipse(0, 0, ICON_SIZE);
QPainterPath outerPath;
outerPath.addEllipse(OUTER_PATH);
QPainterPath innerPath;
innerPath.addEllipse(INNER_PATH);
outerPath -= innerPath;
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
painter.setBrush(pal.color(QPalette::Base));
painter.drawPath(cPath);
painter.fillPath(outerPath, pal.color(QPalette::Text));
painter.setPen(m_foregroundColor);
QFont font("Noto Sans CJK SC", 11, QFont::Normal, false);
painter.setFont(font);
painter.drawText(TEXT_POS, "i");
}
void InfoButton::enterEvent(QEvent *event)
{
m_foregroundColor = FOREGROUND_COLOR_HOVER;
this->repaint();
}
void InfoButton::leaveEvent(QEvent *event)
{
m_foregroundColor = FOREGROUND_COLOR_NORMAL;
this->repaint();
}
void InfoButton::mousePressEvent(QMouseEvent *event)
{
m_foregroundColor = FOREGROUND_COLOR_PRESS;
this->repaint();
return QPushButton::mousePressEvent(event);
}
void InfoButton::mouseReleaseEvent(QMouseEvent *event)
{
m_foregroundColor = FOREGROUND_COLOR_HOVER;
this->repaint();
return QPushButton::mouseReleaseEvent(event);
}

View File

@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef INFOBUTTON_H
#define INFOBUTTON_H
#include <QPushButton>
#include <QIcon>
#include <QGSettings>
class InfoButton : public QPushButton
{
Q_OBJECT
public:
explicit InfoButton(QWidget * parent = nullptr);
~InfoButton() = default;
protected:
void paintEvent(QPaintEvent *event);
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
private:
void initUI();
private:
QColor m_backgroundColor;
QColor m_foregroundColor;
//监听主题的Gsettings
QGSettings * m_styleGsettings = nullptr;
private slots:
void onGSettingChaned(const QString &key);
};
#endif // INFOBUTTON_H

View File

@ -0,0 +1,327 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "switchbutton.h"
#include <QDebug>
#define THEME_QT_SCHEMA "org.ukui.style"
#define THEME_GTK_SCHEMA "org.mate.interface"
#define TIMER_INTERVAL 5 //每隔5ms动画移动一次
#define MOVING_STEPS 40 //动画总共移动40次
SwitchButton::SwitchButton(QWidget *parent, bool useDisableStyle) :
QWidget(parent)
{
// this->resize(QSize(52, 24));
this->setFixedSize(QSize(50, 24));
checked = false;
hover = false;
disabled = false;
isMoving = false;
isAnimation = true;
m_useDisableStyle = useDisableStyle;
space = 4;
rectRadius = height()/2;
mStep = width()/MOVING_STEPS;//也就是40次动画就可以走完每次时间间隔是固定的5ms
mStartX = 0;
mEndX= 0;
mTimer = new QTimer(this);
mTimer->setInterval(TIMER_INTERVAL);//动画更新时间
connect(mTimer, SIGNAL(timeout()), this, SLOT(updatevalue()));
if(QGSettings::isSchemaInstalled(THEME_GTK_SCHEMA) && QGSettings::isSchemaInstalled(THEME_QT_SCHEMA)) {
QByteArray qtThemeID(THEME_QT_SCHEMA);
QByteArray gtkThemeID(THEME_GTK_SCHEMA);
m_gtkThemeSetting = new QGSettings(gtkThemeID,QByteArray(),this);
m_qtThemeSetting = new QGSettings(qtThemeID,QByteArray(),this);
QString style = m_qtThemeSetting->get("styleName").toString();
changeColor(style);
connect(m_qtThemeSetting,&QGSettings::changed, [this] (const QString &key) {
QString style = m_qtThemeSetting->get("styleName").toString();
if (key == "styleName") {
changeColor(style);
}
});
}
}
SwitchButton::~SwitchButton()
{
}
void SwitchButton::paintEvent(QPaintEvent *){
QPainter painter(this);
//启用反锯齿
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setCompositionMode(QPainter::CompositionMode_Source);
drawBg(&painter);
if(!isAnimation)//动画如果禁用则圆形滑块isMoving始终为false
isMoving =false;
if(isMoving)
animation(&painter);
drawSlider(&painter);
painter.end();
}
void SwitchButton::changeColor(const QString &themes) {
if (hover) {
return ;//在鼠标下,禁止切换颜色鼠标离开时切换颜色
}
if (themes == "ukui-dark" || themes == "ukui-black") {
bgColorOff = QColor(OFF_BG_DARK_COLOR);
bgColorOn = QColor(ON_BG_DARK_COLOR);
rectColorEnabled = QColor(ENABLE_RECT_DARK_COLOR);
rectColorDisabled = QColor(DISABLE_RECT_DARK_COLOR);
sliderColorDisabled = QColor(DISABLE_RECT_DARK_COLOR);
sliderColorEnabled = QColor(ENABLE_RECT_DARK_COLOR);
bgHoverOnColor = QColor(ON_HOVER_BG_DARK_COLOR);
bgHoverOffColor = QColor(OFF_HOVER_BG_DARK_COLOR);
bgColorDisabled = QColor(DISABLE_DARK_COLOR);
} else {
bgColorOff = QColor(OFF_BG_LIGHT_COLOR);
bgColorOn = QColor(ON_BG_LIGHT_COLOR);
rectColorEnabled = QColor(ENABLE_RECT_LIGHT_COLOR);
rectColorDisabled = QColor(DISABLE_RECT_LIGHT_COLOR);
sliderColorDisabled = QColor(DISABLE_RECT_LIGHT_COLOR);
sliderColorEnabled = QColor(ENABLE_RECT_LIGHT_COLOR);
bgHoverOnColor = QColor(ON_HOVER_BG_LIGHT_COLOR);
bgHoverOffColor = QColor(OFF_HOVER_BG_LIGHT_COLOR);
bgColorDisabled = QColor(DISABLE_LIGHT_COLOR);
}
}
//动画绘制
void SwitchButton::animation(QPainter *painter){
painter->save();
int h = height();
int w = width();
painter->setPen(Qt::NoPen);
//颜色设置
if(checked){
//开关在左侧时
painter->setBrush(bgColorOn);
rect.setRect(0,0,h+mStartX,h);
}else{
painter->setBrush(bgColorOff);
rect.setRect(mStartX,0,w-mStartX,h);
}
painter->drawRoundedRect(rect,rectRadius,rectRadius);
painter->restore();
}
//绘制背景
void SwitchButton::drawBg(QPainter *painter){
int w = width();
int h = height();
painter->save();
painter->setPen(Qt::NoPen);
if (disabled && m_useDisableStyle) {
painter->setPen(Qt::NoPen);
painter->setBrush(bgColorDisabled);
} else {
if(checked){
if(isMoving){
painter->setBrush(bgColorOff);
rect.setRect(mStartX,0,w-mStartX,h);
}else {
painter->setBrush(bgColorOn);
rect.setRect(0, 0, w, h);
}
}else{
if(isMoving){
painter->setBrush(bgColorOn);
rect.setRect(0,0,mStartX+h,h);
}
else {
painter->setBrush(bgColorOff);
rect.setRect(0, 0, w, h);
}
}
}
//半径为高度的一半
painter->drawRoundedRect(rect,rectRadius,rectRadius);
painter->restore();
}
//绘制滑块,也就是圆形按钮
void SwitchButton::drawSlider(QPainter *painter){
painter->save();
painter->setPen(Qt::NoPen);
if (!disabled || !m_useDisableStyle){
painter->setBrush(sliderColorEnabled);
}
else
painter->setBrush(sliderColorDisabled);
if (disabled) {
if (!checked){
QRect smallRect(8, height() / 2 - 2, 10 , 4);
painter->drawRoundedRect(smallRect,3,3);
}else{
QRect smallRect(width() - 8 * 2, height() / 2 - 2, 10 , 4);
painter->drawRoundedRect(smallRect,3,3);
}
}
QRect rect(0, 0, width(), height());
int sliderWidth = rect.height() - space * 2;
QRect sliderRect(mStartX + space, space, sliderWidth, sliderWidth);
painter->drawEllipse(sliderRect);
painter->restore();
}
void SwitchButton::mousePressEvent(QMouseEvent *){
qDebug()<<isMoving<<checked<<disabled;
if (isMoving) {
return ;
}
if(disabled){
mEndX = 0;
Q_EMIT disabledClick();
return ;
}else{
checked = !checked;
Q_EMIT checkedChanged(checked);
mStep = width() / MOVING_STEPS;
if (checked){
//circle out
// endX = width() - height() + space;
//circle in
mEndX = width() - height();
}
else {
mEndX = 0;
}
mTimer->start();
isMoving = true;
}
}
void SwitchButton::resizeEvent(QResizeEvent *){
//每次开始的x坐标都是跳过圆角从直线的地方开始计算
mStep = width() / MOVING_STEPS;
if (checked){
//circle out
// startX = width() - height() + space;
//circle in
mStartX = width() - height();
}
else
mStartX = 0;
rectRadius = height()/2;
update();
}
void SwitchButton::enterEvent(QEvent *event) {
bgColorOn = bgHoverOnColor;
bgColorOff = bgHoverOffColor;
hover = true;
update();
return QWidget::enterEvent(event);
}
void SwitchButton::leaveEvent(QEvent *event) {
hover = false;
QString style = m_qtThemeSetting->get("styleName").toString();
changeColor(style);
update();
return QWidget::leaveEvent(event);
}
//根据事件向左还是向右移动
void SwitchButton::updatevalue(){
if (checked)
if (mStartX < mEndX-mStep){
mStartX = mStartX + mStep;
}
else{
mStartX = mEndX;
mTimer->stop();
isMoving = false;
}
else{
if (mStartX > mEndX+mStep){
mStartX = mStartX - mStep;
}
else{
mStartX = mEndX;
mTimer->stop();
isMoving = false;
}
}
update();
}
void SwitchButton::setChecked(bool checked){
if (this->checked != checked){
this->checked = checked;
Q_EMIT checkedChanged(checked);
update();
}
mStep = width() / MOVING_STEPS;
if (checked){
//circle out
// endX = width() - height() + space;
//circle in
mEndX = width() - height();
}
else{
mEndX = 0;
}
mTimer->start();
isMoving = true;
}
bool SwitchButton::isChecked(){
return this->checked;
}
void SwitchButton::setDisabledFlag(bool value)
{
disabled = value;
update();
}
bool SwitchButton::getDisabledFlag()
{
return disabled;
}
void SwitchButton::setAnimation(bool on){
isAnimation = on;
}

View File

@ -0,0 +1,121 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef SWITCHBUTTON_H
#define SWITCHBUTTON_H
#include <QWidget>
#include <QTimer>
#include <QPainter>
#include <QPainterPath>
#include <QEvent>
#include <QGSettings/QGSettings>
#define OFF_BG_DARK_COLOR "#404040"
#define OFF_HOVER_BG_DARK_COLOR "#666666"
#define ON_BG_DARK_COLOR "#3790FA"
#define ON_HOVER_BG_DARK_COLOR "#40A9FB"
#define DISABLE_DARK_COLOR "#474747"
#define DISABLE_RECT_DARK_COLOR "#6E6E6E"
#define ENABLE_RECT_DARK_COLOR "#FFFFFF"
#define OFF_BG_LIGHT_COLOR "#E0E0E0"
#define OFF_HOVER_BG_LIGHT_COLOR "#B3B3B3"
#define ON_BG_LIGHT_COLOR "#3790FA"
#define ON_HOVER_BG_LIGHT_COLOR "#40A9FB"
#define DISABLE_LIGHT_COLOR "#E9E9E9"
#define DISABLE_RECT_LIGHT_COLOR "#B3B3B3"
#define ENABLE_RECT_LIGHT_COLOR "#FFFFFF"
class SwitchButton : public QWidget
{
Q_OBJECT
public:
SwitchButton(QWidget *parent = 0, bool useDisableStyle = true);
~SwitchButton();
void setChecked(bool checked);
void setAnimation(bool on);
bool isChecked();
void setDisabledFlag(bool);
bool getDisabledFlag();
protected:
void mousePressEvent(QMouseEvent *);
void resizeEvent(QResizeEvent *);
void paintEvent(QPaintEvent *);
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
void drawBg(QPainter * painter);
void drawSlider(QPainter * painter);
void changeColor(const QString &themes);
private:
bool checked; //切换的判断
bool disabled;
void animation(QPainter *painter);
QRect rect;
bool isMoving; //滑块动作判断
bool isAnimation; // 是否允许动画执行
QColor bgColorOff;
QColor bgColorOn;
QColor bgHoverOnColor;
QColor bgHoverOffColor;
QColor bgColorDisabled;
QColor sliderColorEnabled;
QColor sliderColorDisabled;
QColor rectColorEnabled;
QColor rectColorDisabled;
QColor sliderColorOff;
QColor sliderColorOn;
QGSettings *m_qtThemeSetting;
QGSettings *m_gtkThemeSetting;
int space; //滑块离背景间隔
int rectRadius; //圆角角度
int mStep; //移动步长
int mStartX;
int mEndX;
bool hover;
QTimer * mTimer;
bool m_useDisableStyle;
private Q_SLOTS:
void updatevalue();
Q_SIGNALS:
void checkedChanged(bool checked);
void disabledClick();
};
#endif // SWITCHBUTTON_H

View File

@ -0,0 +1,11 @@
#LIBINTERFACE_NAME = $$qtLibraryTarget(addnetbtn)
SOURCES += \
$$PWD/AddBtn/addnetbtn.cpp \
$$PWD/AddBtn/grayinfobutton.cpp
HEADERS += \
$$PWD/AddBtn/addnetbtn.h \
$$PWD/AddBtn/grayinfobutton.h

View File

@ -0,0 +1,9 @@
#LIBINTERFACE_NAME = $$qtLibraryTarget(drownlabel)
SOURCES += \
$$PWD/DrownLabel/drownlabel.cpp \
HEADERS += \
$$PWD/DrownLabel/drownlabel.h \

View File

@ -0,0 +1,9 @@
#LIBINTERFACE_NAME = $$qtLibraryTarget(infobutton)
SOURCES += \
$$PWD/InfoButton/infobutton.cpp \
HEADERS += \
$$PWD/InfoButton/infobutton.h \

View File

@ -0,0 +1,8 @@
#LIBINTERFACE_NAME = $$qtLibraryTarget(switchbutton)
SOURCES += \
$$PWD/SwitchButton/switchbutton.cpp \
HEADERS += \
$$PWD/SwitchButton/switchbutton.h \

View File

@ -0,0 +1,70 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "blacklistitem.h"
#include <QDebug>
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0
#define ITEM_FRAME_MARGINS 0,0,0,0
#define ITEM_FRAME_SPACING 10
#define FRAME_WIDTH 395
#define INFO_ICON_WIDTH 16
#define INFO_ICON_HEIGHT 16
#define LIGHT_HOVER_COLOR QColor(240,240,240,255)
#define DARK_HOVER_COLOR QColor(15,15,15,255)
#define FRAME_MIN_SIZE 550, 60
#define CONTECT_FRAME_MAX_SIZE 16777215, 60
#define LABLE_MIN_WIDTH 188
#define ITEM_MARGINS 16, 0, 16, 0
BlacklistItem::BlacklistItem(QString staMac, QString staName, QWidget *parent) :
QFrame(parent),
m_mac(staMac),
m_hostName(staName)
{
this->setMinimumHeight(60);
this->setFixedHeight(60);
QHBoxLayout *hItemLayout = new QHBoxLayout(this);
hItemLayout->setContentsMargins(ITEM_MARGINS);
QLabel *nameLabel = new QLabel(staName, this);
m_removeFromBlacklistBtn = new KBorderlessButton(this);
m_removeFromBlacklistBtn->setText(tr("Remove"));
hItemLayout->setSpacing(0);
hItemLayout->addWidget(nameLabel, Qt::AlignLeft);
hItemLayout->addStretch();
hItemLayout->addWidget(m_removeFromBlacklistBtn, Qt::AlignRight);
m_removeFromBlacklistBtn->installEventFilter(this);
this->setLayout(hItemLayout);
}
bool BlacklistItem::eventFilter(QObject *w, QEvent *e)
{
if (e->type() == QEvent::MouseButtonRelease) {
if (w == m_removeFromBlacklistBtn) {
emit onBtnClicked(m_mac, m_hostName);
return true;
}
}
return QWidget::eventFilter(w,e);
}

View File

@ -0,0 +1,52 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef BLACKLISTITEM_H
#define BLACKLISTITEM_H
#include <QFrame>
#include <QEvent>
#include <QHBoxLayout>
#include <QDebug>
#include <QMouseEvent>
#include <QMenu>
#include <QLabel>
#include "kborderlessbutton.h"
using namespace kdk;
class BlacklistItem : public QFrame
{
Q_OBJECT
public:
BlacklistItem(QString staMac, QString staName, QWidget *parent = nullptr);
protected:
KBorderlessButton *m_removeFromBlacklistBtn = nullptr;
QString m_mac;
QString m_hostName;
bool eventFilter(QObject *w, QEvent *e);
signals:
void onBtnClicked(QString staMac, QString staName);
};
#endif // LISTITEM_H

View File

@ -0,0 +1,200 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "blacklistpage.h"
#include <QDebug>
#define CONTENTS_MARGINS 0, 0, 0, 0
#define FRAME_MIN_SIZE 550, 60
#define FRAME_MAX_SIZE 16777215, 16777215
#define LINE_MAX_SIZE 16777215, 1
#define LINE_MIN_SIZE 0, 1
#define LOG_HEAD "[BlacklistPage]"
BlacklistPage::BlacklistPage(QWidget *parent) : QWidget(parent)
{
QVBoxLayout *Vlayout = new QVBoxLayout(this);
Vlayout->setContentsMargins(CONTENTS_MARGINS);
Vlayout->setSpacing(0);
QFrame *blacklistFrame = new QFrame(this);
blacklistFrame->setMinimumSize(FRAME_MIN_SIZE);
blacklistFrame->setMaximumSize(FRAME_MAX_SIZE);
blacklistFrame->setFrameShape(QFrame::Box);
m_blacklistLayout = new QVBoxLayout(blacklistFrame);
m_blacklistLayout->setContentsMargins(0, 0, 0, 0);
m_blacklistLayout->setSpacing(0);
m_titleLabel = new TitleLabel(this);
m_titleLabel->setText(tr("Blacklist"));
Vlayout->addWidget(m_titleLabel);
Vlayout->addSpacing(8);
Vlayout->addWidget(blacklistFrame);
}
QFrame* BlacklistPage::myLine()
{
QFrame *line = new QFrame(this);
line->setMinimumSize(QSize(LINE_MIN_SIZE));
line->setMaximumSize(QSize(LINE_MAX_SIZE));
line->setLineWidth(0);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
return line;
}
void BlacklistPage::getBlacklistDevice(QMap<QString, QString> &blacklistMap)
{
if (m_settingPathInterface == nullptr || !m_settingPathInterface->isValid()) {
qDebug() << LOG_HEAD << "dbus interface m_settingPathInterface is invaild";
return;
}
QDBusMessage reply = m_settingPathInterface->call("Getblacklist");
if(reply.type() == QDBusMessage::ErrorMessage)
{
qWarning() << LOG_HEAD << "Getblacklist error:" << reply.errorMessage();
return;
}
if (reply.arguments().isEmpty()
|| reply.arguments().at(0).toString() == ""
|| reply.arguments().at(1).toString() == "") {
qDebug() << LOG_HEAD << "Dbus interface call Getblacklist return is empty!";
return;
}
QStringList macList = reply.arguments().at(0).toString().split(";");
QStringList hostNameList = reply.arguments().at(1).toString().split(";");
for (int index = 0; index < macList.count() && macList.at(index) != nullptr; index ++) {
QString macTemp = macList.at(index);
macTemp = macTemp.trimmed();
if (!blacklistMap.contains(macTemp)) {
blacklistMap[macTemp] = hostNameList.at(index);
}
}
}
void BlacklistPage::initBlacklistDev()
{
QMap<QString, QString>::const_iterator item = m_blacklistMap.cbegin();
while (item != m_blacklistMap.cend()) {
addBlacklistDevFrame(item.key(), item.value());
item ++;
if (item != m_blacklistMap.cend()) {
m_blacklistLayout->addWidget(myLine());
}
}
}
void BlacklistPage::onsetStaIntoBlacklist(QString staMac, QString staName)
{
if (m_settingPathInterface == nullptr || !m_settingPathInterface->isValid()) {
qDebug() << LOG_HEAD << LOG_HEAD << "dbus interface m_settingPathInterface is invaild";
return;
}
QDBusMessage reply = m_settingPathInterface->call("Addblacklist", staMac, staName);
if(reply.type() == QDBusMessage::ErrorMessage)
{
qWarning() << LOG_HEAD << "Addblacklist error:" << reply.errorMessage();
return;
}
refreshBlacklist();
}
void BlacklistPage::addBlacklistDevFrame(QString staMac, QString staName)
{
BlacklistItem *itemFrame = new BlacklistItem(staMac, staName, m_blacklistLayout->widget());
m_blacklistLayout->addWidget(itemFrame);
connect(itemFrame, &BlacklistItem::onBtnClicked, this, &BlacklistPage::onRemoveFromBlacklistBtnClicked);
}
void BlacklistPage::clearBlacklistLayout()
{
if (m_blacklistLayout->layout() != NULL) {
QLayoutItem* layoutItem;
while ((layoutItem = m_blacklistLayout->layout()->takeAt(0)) != NULL) {
delete layoutItem->widget();
delete layoutItem;
}
}
}
bool BlacklistPage::removeStaFromBlacklist(QString staMac, QString staName)
{
if (m_settingPathInterface == nullptr || !m_settingPathInterface->isValid()) {
qDebug() << LOG_HEAD << "dbus interface m_settingPathInterface is invaild";
return false;
}
QDBusMessage reply = m_settingPathInterface->call("Delblacklist", staMac, staName);
if(reply.type() == QDBusMessage::ErrorMessage)
{
qWarning() << LOG_HEAD << "Delblacklist error:" << reply.errorMessage();
return false;
}
return true;
}
void BlacklistPage::resetLayoutHight()
{
int height = 0;
for (int i = 0; i < m_blacklistLayout->count(); i ++) {
QWidget *w = m_blacklistLayout->itemAt(i)->widget();
if (w != nullptr) {
height += w->height();
}
}
this->setFixedHeight(height + m_titleLabel->height() + 8);
if (m_blacklistMap.isEmpty()) {
this->hide();
} else {
this->show();
}
this->update();
}
void BlacklistPage::refreshBlacklist()
{
m_blacklistMap.clear();
getBlacklistDevice(m_blacklistMap);
clearBlacklistLayout();
initBlacklistDev();
resetLayoutHight();
}
void BlacklistPage::onRemoveFromBlacklistBtnClicked(QString staMac, QString staName)
{
if (staMac.isNull()
|| staMac.isEmpty()
|| staName.isNull()
|| staName.isEmpty()) {
qDebug() << LOG_HEAD <<"On remove from blacklist button clicked error! sta mac or name is empty!";
return;
}
removeStaFromBlacklist(staMac, staName);
refreshBlacklist();
}

View File

@ -0,0 +1,73 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef BLACKLISTPAGE_H
#define BLACKLISTPAGE_H
#include <QWidget>
#include <QLabel>
#include <QHBoxLayout>
#include <QDBusMessage>
#include <QDBusObjectPath>
#include <QDBusInterface>
#include <QDBusReply>
#include <QDBusMetaType>
#include "titlelabel.h"
#include "blacklistitem.h"
using namespace kdk;
class BlacklistPage : public QWidget
{
Q_OBJECT
public:
explicit BlacklistPage(QWidget *parent = nullptr);
void refreshBlacklist();
bool setStaIntoBlacklist(QString staMac);
inline void setInterface(QDBusInterface *settingInterface) {
m_settingPathInterface = settingInterface;
}
private:
QFrame* myLine();
TitleLabel *m_titleLabel = nullptr;
QVBoxLayout *m_blacklistLayout = nullptr;
QMap<QString, QString> m_blacklistMap;
QDBusInterface *m_settingPathInterface = nullptr;
void getBlacklistDevice(QMap<QString, QString> &blacklistMap);
bool removeStaFromBlacklist(QString staMac, QString staName);
void initBlacklistDev();
void addBlacklistDevFrame(QString staMac, QString staName);
void clearBlacklistLayout();
void resetLayoutHight();
private slots:
void onsetStaIntoBlacklist(QString staMac, QString staName);
void onRemoveFromBlacklistBtnClicked(QString staMac, QString staName);
};
#endif // MOBILEHOTSPOTWIDGET_H

View File

@ -0,0 +1,70 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "connectdevlistitem.h"
#include <QDebug>
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0
#define ITEM_FRAME_MARGINS 0,0,0,0
#define ITEM_FRAME_SPACING 10
#define FRAME_WIDTH 395
#define INFO_ICON_WIDTH 16
#define INFO_ICON_HEIGHT 16
#define LIGHT_HOVER_COLOR QColor(240,240,240,255)
#define DARK_HOVER_COLOR QColor(15,15,15,255)
#define FRAME_MIN_SIZE 550, 60
#define CONTECT_FRAME_MAX_SIZE 16777215, 60
#define LABLE_MIN_WIDTH 188
#define ITEM_MARGINS 16, 0, 16, 0
ConnectDevListItem::ConnectDevListItem(QString staMac, QString staName, QWidget *parent) :
QFrame(parent),
m_mac(staMac),
m_hostName(staName)
{
this->setMinimumSize(FRAME_MIN_SIZE);
this->setFixedHeight(60);
QHBoxLayout *hItemLayout = new QHBoxLayout(this);
hItemLayout->setContentsMargins(ITEM_MARGINS);
QLabel *nameLabel = new QLabel(staName, this);
m_dragIntoBlackListBtn = new KBorderlessButton(this);
m_dragIntoBlackListBtn->setText(tr("drag into blacklist"));
hItemLayout->setSpacing(0);
hItemLayout->addWidget(nameLabel, Qt::AlignLeft);
hItemLayout->addStretch();
hItemLayout->addWidget(m_dragIntoBlackListBtn, Qt::AlignRight);
m_dragIntoBlackListBtn->installEventFilter(this);
this->setLayout(hItemLayout);
}
bool ConnectDevListItem::eventFilter(QObject *w, QEvent *e)
{
if (e->type() == QEvent::MouseButtonRelease) {
if (w == m_dragIntoBlackListBtn) {
emit onBtnClicked(m_mac, m_hostName);
return true;
}
}
return QWidget::eventFilter(w,e);
}

View File

@ -0,0 +1,52 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef CONNECTDEVLISTITEM_H
#define CONNECTDEVLISTITEM_H
#include <QFrame>
#include <QEvent>
#include <QHBoxLayout>
#include <QDebug>
#include <QMouseEvent>
#include <QMenu>
#include <QLabel>
#include "kborderlessbutton.h"
using namespace kdk;
class ConnectDevListItem : public QFrame
{
Q_OBJECT
public:
ConnectDevListItem(QString staMac, QString staName, QWidget *parent = nullptr);
protected:
KBorderlessButton *m_dragIntoBlackListBtn = nullptr;
QString m_mac;
QString m_hostName;
bool eventFilter(QObject *w, QEvent *e);
signals:
void onBtnClicked(QString staMac, QString staName);
};
#endif // LISTITEM_H

View File

@ -0,0 +1,191 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "connectdevpage.h"
#include <QDebug>
#define CONTENTS_MARGINS 0, 0, 0, 0
#define FRAME_MIN_SIZE 550, 60
#define FRAME_MAX_SIZE 16777215, 16777215
#define LINE_MAX_SIZE 16777215, 1
#define LINE_MIN_SIZE 0, 1
#define LOG_HEAD "[ConnectdevPage]"
ConnectdevPage::ConnectdevPage(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout *Vlayout = new QVBoxLayout(this);
Vlayout->setContentsMargins(CONTENTS_MARGINS);
Vlayout->setSpacing(0);
QFrame *staistFrame = new QFrame(this);
staistFrame->setMinimumSize(FRAME_MIN_SIZE);
staistFrame->setMaximumSize(FRAME_MAX_SIZE);
staistFrame->setFrameShape(QFrame::Box);
m_staListLayout = new QVBoxLayout(staistFrame);
m_staListLayout->setContentsMargins(0, 0, 0, 0);
m_staListLayout->setSpacing(0);
m_titleLabel = new TitleLabel(this);
m_titleLabel->setText(tr("Connect device"));
Vlayout->addWidget(m_titleLabel);
Vlayout->addSpacing(8);
Vlayout->addWidget(staistFrame);
}
QFrame* ConnectdevPage::myLine()
{
QFrame *line = new QFrame(this);
line->setMinimumSize(QSize(LINE_MIN_SIZE));
line->setMaximumSize(QSize(LINE_MAX_SIZE));
line->setLineWidth(0);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
return line;
}
void ConnectdevPage::getConnectStaDevice(QMap<QString, QString> &staMap)
{
staMap.clear();
if (m_activePathInterface == nullptr || !m_activePathInterface->isValid()) {
qDebug() << LOG_HEAD << "dbus interface m_activePathInterface is invaild";
return;
}
QDBusMessage reply = m_activePathInterface->call("Getstainfo");
if(reply.type() == QDBusMessage::ErrorMessage)
{
qWarning() << LOG_HEAD << "Getstainfo error:" << reply.errorMessage();
return;
}
if (reply.arguments().isEmpty()
|| reply.arguments().at(0).toString() == ""
|| reply.arguments().at(0).toString() == "[Invalid UTF-8]"
|| reply.arguments().at(1).toString() == "") {
qDebug() << LOG_HEAD << "Dbus interface call Getstainfo return is empty!";
return;
}
QStringList macList = reply.arguments().at(0).toString().split(";");
QStringList hostNameList = reply.arguments().at(1).toString().split(";");
for (int index = 0; index < macList.count() && macList.at(index) != nullptr; index ++) {
if (!staMap.contains(macList.at(index))) {
staMap[macList.at(index)] = hostNameList.at(index);
}
}
}
void ConnectdevPage::initStaDev()
{
QMap<QString, QString>::const_iterator item = m_staMap.cbegin();
while (item != m_staMap.cend()) {
addStaDevFrame(item.key(), item.value());
item ++;
if (item != m_staMap.cend()) {
m_staListLayout->addWidget(myLine());
}
}
}
void ConnectdevPage::addStaDevFrame(QString staMac, QString staName)
{
ConnectDevListItem *itemFrame = new ConnectDevListItem(staMac, staName, m_staListLayout->widget());
m_staListLayout->addWidget(itemFrame);
connect(itemFrame, &ConnectDevListItem::onBtnClicked, this, &ConnectdevPage::onDropIntoBlacklistBtnClicked);
}
void ConnectdevPage::clearStaListLayout()
{
if (m_staListLayout->layout() != NULL) {
QLayoutItem* layoutItem;
while ((layoutItem = m_staListLayout->layout()->takeAt(0)) != NULL) {
delete layoutItem->widget();
delete layoutItem;
}
}
}
void ConnectdevPage::onStaDevAdded(bool istrue, QString staMac, QString staName)
{
if (!m_staMap.contains(staMac)) {
m_staMap.insert(staMac, staName);
clearStaListLayout();
initStaDev();
resetLayoutHight();
}
}
void ConnectdevPage::onStaDevRemoved(bool istrue, QString staMac, QString staName)
{
if (m_staMap.contains(staMac)) {
if (m_staMap.remove(staMac)) {
clearStaListLayout();
initStaDev();
resetLayoutHight();
}
}
}
void ConnectdevPage::resetLayoutHight()
{
int height = 0;
for (int i = 0; i < m_staListLayout->count(); i ++) {
QWidget *w = m_staListLayout->itemAt(i)->widget();
if (w != nullptr) {
height += w->height();
}
}
this->setFixedHeight(height + m_titleLabel->height() + 8);
if (m_staMap.isEmpty()) {
this->hide();
} else {
this->show();
}
this->update();
}
void ConnectdevPage::refreshStalist()
{
m_staMap.clear();
getConnectStaDevice(m_staMap);
clearStaListLayout();
initStaDev();
resetLayoutHight();
}
void ConnectdevPage::onDropIntoBlacklistBtnClicked(QString staMac, QString staName)
{
if (staMac.isNull()
|| staMac.isEmpty()
|| staName.isNull()
|| staName.isEmpty()) {
qDebug() << LOG_HEAD <<"On drop into blacklist button clicked error! sta mac or name is empty!";
return;
}
emit setStaIntoBlacklist(staMac, staName);
}

View File

@ -0,0 +1,81 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef CONNECTDEVPAGE_H
#define CONNECTDEVPAGE_H
#include <QWidget>
#include <QLabel>
#include <QHBoxLayout>
#include <QDBusMessage>
#include <QDBusObjectPath>
#include <QDBusInterface>
#include <QDBusReply>
#include <QDBusMetaType>
#include "titlelabel.h"
#include "connectdevlistitem.h"
using namespace kdk;
class ConnectdevPage : public QWidget
{
Q_OBJECT
public:
explicit ConnectdevPage(QWidget *parent = nullptr);
void refreshStalist();
inline void setInterface(QDBusInterface *activeInterface) {
m_activePathInterface = activeInterface;
}
private:
QFrame* myLine();
TitleLabel *m_titleLabel = nullptr;
QVBoxLayout *m_staListLayout = nullptr;
QMap<QString, QString> m_staMap;
QDBusInterface *m_activePathInterface = nullptr;
void getConnectStaDevice(QMap<QString, QString> &blacklistMap);
bool removeStaFromBlacklist(QString staMac);
void initStaDev();
void addStaDevFrame(QString staMac, QString staName);
void clearStaListLayout();
QString getActivePathByUuid(QDBusInterface *interface);
void initNmDbus(QDBusInterface *interface);
void onStaDevChanged(bool istrue, QString staMac, QString staName);
void resetLayoutHight();
signals:
void setStaIntoBlacklist(QString staMac, QString staName);
public slots:
void onStaDevAdded(bool istrue, QString staMac, QString staName);
void onStaDevRemoved(bool istrue, QString staMac, QString staName);
private slots:
void onDropIntoBlacklistBtnClicked(QString staMac, QString staName);
};
#endif // MOBILEHOTSPOTWIDGET_H

View File

@ -0,0 +1,155 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "mobilehotspot.h"
#include <QDebug>
MobileHotspot::MobileHotspot() : mFirstLoad(true) {
QTranslator* translator = new QTranslator(this);
qDebug() << "/usr/share/kylin-nm/mobilehotspot/" + QLocale::system().name();
if (!translator->load("/usr/share/kylin-nm/mobilehotspot/" + QLocale::system().name())) {
qDebug() << "load failed";
}
QApplication::installTranslator(translator);
pluginName = tr("MobileHotspot");
qDebug() << pluginName;
pluginType = NETWORK;
qDBusRegisterMetaType<QMap<QString, bool> >();
qDBusRegisterMetaType<QMap<QString, int> >();
needLoad = isExitWirelessDevice();
}
MobileHotspot::~MobileHotspot()
{
if (!mFirstLoad) {
// delete pluginWidget;
// pluginWidget = nullptr;
}
}
QString MobileHotspot::plugini18nName() {
return pluginName;
}
int MobileHotspot::pluginTypes() {
return pluginType;
}
QWidget *MobileHotspot::pluginUi() {
if (mFirstLoad) {
mFirstLoad = false;
pluginWidget = new MobileHotspotWidget;
pluginWidget->setAttribute(Qt::WA_DeleteOnClose);
}
return pluginWidget;
}
const QString MobileHotspot::name() const {
return QStringLiteral("mobilehotspot");
}
bool MobileHotspot::isEnable() const
{
qDebug() << needLoad;
return needLoad;
}
bool MobileHotspot::isShowOnHomePage() const
{
return false;
}
QIcon MobileHotspot::icon() const
{
return QIcon::fromTheme("ukui-hotspot-symbolic");
}
QString MobileHotspot::translationPath() const
{
return "/usr/share/kylin-nm/mobilehotspot/%1.ts";
}
void MobileHotspot::initSearchText()
{
//~ contents_path /mobilehotspot/mobilehotspot
tr("mobilehotspot");
//~ contents_path /mobilehotspot/mobilehotspot open
tr("mobilehotspot open");
}
bool MobileHotspot::isExitWirelessDevice()
{
QDBusInterface *interface = new QDBusInterface("com.kylin.network", "/com/kylin/network",
"com.kylin.network",
QDBusConnection::sessionBus());
if (!interface->isValid()) {
qDebug() << "/com/kylin/network is invalid";
return false;
}
QDBusMessage result = interface->call(QStringLiteral("getDeviceListAndEnabled"),1);
if(result.type() == QDBusMessage::ErrorMessage) {
qWarning() << "getWirelessDeviceList error:" << result.errorMessage();
return false;
}
auto dbusArg = result.arguments().at(0).value<QDBusArgument>();
QMap<QString, bool> deviceListMap;
dbusArg >> deviceListMap;
QDBusReply<QMap<QString, int> > capReply = interface->call("getWirelessDeviceCap");
if (!capReply.isValid()) {
qDebug()<<"execute dbus method 'getWirelessDeviceCap' is invalid in func initInterfaceInfo()" <<capReply.error().type() ;
return false;
}
QMap<QString, int> devCapMap = capReply.value();
if (deviceListMap.isEmpty()) {
qDebug() << "no wireless device";
return false;
} else {
QMap<QString, bool>::Iterator iter = deviceListMap.begin();
while (iter != deviceListMap.end()) {
QString interfaceName = iter.key();
if (!devCapMap.contains(interfaceName)) {
iter++;
continue;
}
if (deviceListMap[interfaceName] & 0x01) {
qDebug() << "wireless device" << interfaceName << "support hotspot";
return true;
}
iter++;
}
}
qDebug() << "no wireless device support hotspot";
return false;
}

View File

@ -0,0 +1,78 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef MOBILEHOTSPOT_H
#define MOBILEHOTSPOT_H
#include <QObject>
#include <QtPlugin>
#include <QTranslator>
#include <QApplication>
#include <QDBusMessage>
#include <QDBusObjectPath>
#include <QDBusInterface>
#include <QDBusReply>
#include <QDBusMetaType>
#include "interface.h"
#include "switchbutton.h"
#include "hoverbtn.h"
#include "mobilehotspotwidget.h"
namespace Ui {
class MobileHotspot;
}
class MobileHotspot : public QObject, CommonInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
Q_INTERFACES(CommonInterface)
public:
MobileHotspot();
~MobileHotspot();
QString plugini18nName() Q_DECL_OVERRIDE;
int pluginTypes() Q_DECL_OVERRIDE;
QWidget * pluginUi() Q_DECL_OVERRIDE;
const QString name() const Q_DECL_OVERRIDE;
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
QIcon icon() const Q_DECL_OVERRIDE;
bool isEnable() const Q_DECL_OVERRIDE;
QString translationPath() const Q_DECL_OVERRIDE;
private:
void initSearchText();
bool isExitWirelessDevice();
QString pluginName;
int pluginType;
MobileHotspotWidget *pluginWidget;
private:
bool mFirstLoad;
bool needLoad;
};
#endif // MOBILEHOTSPOT_H

View File

@ -0,0 +1,52 @@
QT += widgets network dbus gui core
TEMPLATE = lib
CONFIG += plugin
TARGET = $$qtLibraryTarget(mobilehotspot)
DESTDIR = ../..
target.path = $$[QT_INSTALL_LIBS]/ukui-control-center
trans.files = translations/*
trans.path = /usr/share/kylin-nm/mobilehotspot/
INCLUDEPATH += \
$$PROJECT_COMPONENTSOURCE \
$$PROJECT_ROOTDIR \
/usr/include/ukcc/interface \
/usr/include/ukcc/widgets
LIBS += -L$$[QT_INSTALL_LIBS] -lgsettings-qt -lukcc
CONFIG += c++11 \
link_pkgconfig \
PKGCONFIG += gsettings-qt \
kysdk-qtwidgets \
#DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
blacklistpage.cpp \
blacklistitem.cpp \
connectdevpage.cpp \
connectdevlistitem.cpp \
mobilehotspot.cpp \
mobilehotspotwidget.cpp
HEADERS += \
blacklistpage.h \
blacklistitem.h \
connectdevpage.h \
connectdevlistitem.h \
mobilehotspot.h \
mobilehotspotwidget.h \
libukcc_global.h
INSTALLS += target \
trans
TRANSLATIONS += \
translations/zh_CN.ts \
translations/tr.ts \
translations/bo.ts\
translations/bo_CN.ts

View File

@ -0,0 +1,888 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "mobilehotspotwidget.h"
#include <QDebug>
#include <QFormLayout>
#define LABEL_RECT 17, 0, 105, 23
#define CONTENTS_MARGINS 0, 0, 0, 0
#define ITEM_MARGINS 16, 0, 16, 0
#define FRAME_MIN_SIZE 550, 60
#define FRAME_MAX_SIZE 16777215, 16777215
#define CONTECT_FRAME_MAX_SIZE 16777215, 60
#define HINT_TEXT_MARGINS 8, 0, 0, 0
#define FRAME_MIN_SIZE 550, 60
#define LABLE_MIN_WIDTH 188
#define COMBOBOX_MIN_WIDTH 200
#define LINE_MAX_SIZE 16777215, 1
#define LINE_MIN_SIZE 0, 1
#define ICON_SIZE 24,24
#define PASSWORD_FRAME_MIN_HIGHT 60
#define PASSWORD_FRAME_FIX_HIGHT 80
#define PASSWORD_FRAME_MIN_SIZE 550, 60
#define PASSWORD_FRAME_MAX_SIZE 16777215, 86
#define PASSWORD_ITEM_MARGINS 16, 12, 16, 14
#define WIRELESS 1
#define AP_NAME_MAX_LENGTH 32
#define REFRESH_MSEC 20*1000
#define LOG_HEAD "[MobileHotspotWidget]"
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
const QString WIRELESS_SWITCH = "wirelessswitch";
void MobileHotspotWidget::showDesktopNotify(const QString &message)
{
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
args<<(tr("ukui control center"))
<<((unsigned int) 0)
<<QString("ukui-control-center")
<<tr("ukui control center desktop message") //显示的是什么类型的信息
<<message //显示的具体信息
<<QStringList()
<<QVariantMap()
<<(int)-1;
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
}
#define HOTSPOT_CONTROL
MobileHotspotWidget::MobileHotspotWidget(QWidget *parent) : QWidget(parent)
{
m_Vlayout = new QVBoxLayout(this);
m_Vlayout->setContentsMargins(CONTENTS_MARGINS);
m_Vlayout->setSpacing(0);
qDBusRegisterMetaType<QMap<QString, bool> >();
qDBusRegisterMetaType<QMap<QString, int> >();
qDBusRegisterMetaType<QVector<QStringList> >();
qDBusRegisterMetaType<QMap<QString, QVector<QStringList> >>();
initUI();
#ifdef HOTSPOT_CONTROL
initConnectDevPage();
initBlackListPage();
#endif
m_switchBtn->installEventFilter(this);
m_interface = new QDBusInterface("com.kylin.network", "/com/kylin/network",
"com.kylin.network",
QDBusConnection::sessionBus());
if(!m_interface->isValid()) {
qDebug() << LOG_HEAD << "dbus interface com.kylin.network is invaild";
m_switchBtn->setChecked(false);
setUiEnabled(false);
}
m_hostName = getHostName();
initDbusConnect();
initInterfaceInfo();
getApInfo();
#ifdef HOTSPOT_CONTROL
initNmDbus();
#endif
this->setLayout(m_Vlayout);
m_Vlayout->addStretch();
connect(m_switchBtn, &KSwitchButton::stateChanged, this, &MobileHotspotWidget::setUiEnabled);
connect(m_interfaceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [=]() {
m_interfaceName = m_interfaceComboBox->currentText();
updateBandCombox();
});
#ifdef HOTSPOT_CONTROL
m_connectDevPage->refreshStalist();
m_blacklistPage->refreshBlacklist();
#endif
this->update();
}
MobileHotspotWidget::~MobileHotspotWidget()
{
deleteActivePathInterface();
deleteSettingPathInterface();
delete m_interface;
}
bool MobileHotspotWidget::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::MouseButtonDblClick && watched == m_switchBtn) {
return true;
}
if (watched == m_switchBtn) {
if (event->type() == QEvent::MouseButtonRelease) {
if (!m_interface->isValid()) {
return true;
}
if (!m_switchBtn->isCheckable()) {
showDesktopNotify(tr("wirless switch is close or no wireless device"));
return true;
}
if (m_switchBtn->isChecked()) {
// showDesktopNotify(tr("start to close hotspot"));
QDBusReply<void> reply = m_interface->call("deactiveWirelessAp", m_apNameLine->text(), m_uuid);
if (!reply.isValid()) {
qDebug() << LOG_HEAD << "call deactiveWirelessAp failed ";
return true;
}
#ifdef HOTSPOT_CONTROL
deleteActivePathInterface();
m_connectDevPage->setInterface(nullptr);
m_connectDevPage->refreshStalist();
m_blacklistPage->refreshBlacklist();
#endif
this->update();
} else {
if (m_apNameLine->text().isEmpty() || m_interfaceName.isEmpty())
{
showDesktopNotify(tr("hotpots name or device is invalid"));
return true;
}
if (m_pwdNameLine->text().length() < 8) {
// showDesktopNotify(tr("can not create hotspot with password length less than eight!"));
return true;
}
// showDesktopNotify(tr("start to open hotspot ") + m_apNameLine->text());
QDBusReply<void> reply = m_interface->call("activeWirelessAp",
m_apNameLine->text(),
m_pwdNameLine->text(),
m_freqBandComboBox->currentText(),
m_interfaceComboBox->currentText());
if (!reply.isValid()) {
qDebug() << LOG_HEAD << "call activeWirelessAp failed ";
return true;
}
}
return true;
}
}
return QWidget::eventFilter(watched, event);
}
void MobileHotspotWidget::paintEvent(QPaintEvent *event)
{
QWidget::paintEvent(event);
}
void MobileHotspotWidget::resetFrameSize()
{
int height = 0;
for (int i = 0; i < m_hotspotFrame->layout()->count(); i ++) {
QWidget *w = m_hotspotFrame->layout()->itemAt(i)->widget();
if (w != nullptr && !w->isHidden()) {
height += w->height();
}
}
m_hotspotFrame->setFixedHeight(height);
}
void MobileHotspotWidget::initUI()
{
m_hotspotFrame = new QFrame(this);
m_hotspotFrame->setMinimumSize(FRAME_MIN_SIZE);
m_hotspotFrame->setMaximumSize(FRAME_MAX_SIZE);
m_hotspotFrame->setFrameShape(QFrame::Box);
QVBoxLayout *hotspotLyt = new QVBoxLayout(this);
hotspotLyt->setContentsMargins(0, 0, 0, 0);
m_hotspotFrame->setLayout(hotspotLyt);
m_hotspotTitleLabel = new TitleLabel(this);
m_hotspotTitleLabel->setText(tr("Hotspot"));
setSwitchFrame();
setApNameFrame();
setPasswordFrame();
setFreqBandFrame();
setInterFaceFrame();
switchAndApNameLine = myLine();
apNameAndPwdLine = myLine();
pwdAndfreqBandLine = myLine();
freqBandAndInterfaceLine = myLine();
hotspotLyt->addWidget(m_switchFrame);
hotspotLyt->addWidget(switchAndApNameLine);
hotspotLyt->addWidget(m_ApNameFrame);
hotspotLyt->addWidget(apNameAndPwdLine);
hotspotLyt->addWidget(m_passwordFrame);
hotspotLyt->addWidget(pwdAndfreqBandLine);
hotspotLyt->addWidget(m_freqBandFrame);
hotspotLyt->addWidget(freqBandAndInterfaceLine);
hotspotLyt->addWidget(m_interfaceFrame);
hotspotLyt->setSpacing(0);
resetFrameSize();
m_Vlayout->addWidget(m_hotspotTitleLabel);
m_Vlayout->addSpacing(8);
m_Vlayout->addWidget(m_hotspotFrame);
}
void MobileHotspotWidget::initDbusConnect()
{
if(m_interface->isValid()) {
connect(m_interface,SIGNAL(activateFailed(QString)), this, SLOT(onActivateFailed(QString)), Qt::QueuedConnection);
connect(m_interface,SIGNAL(deactivateFailed(QString)), this, SLOT(onDeactivateFailed(QString)), Qt::QueuedConnection);
connect(m_interface,SIGNAL(deviceStatusChanged()), this, SLOT(onDeviceStatusChanged()), Qt::QueuedConnection);
connect(m_interface,SIGNAL(deviceNameChanged(QString, QString, int)), this, SLOT(onDeviceNameChanged(QString, QString, int)), Qt::QueuedConnection);
connect(m_interface,SIGNAL(hotspotDeactivated(QString, QString)), this, SLOT(onHotspotDeactivated(QString, QString)), Qt::QueuedConnection);
connect(m_interface,SIGNAL(hotspotActivated(QString, QString, QString, QString, QString)), this, SLOT(onHotspotActivated(QString, QString, QString, QString, QString)), Qt::QueuedConnection);
connect(m_interface, SIGNAL(wlanactiveConnectionStateChanged(QString, QString, QString, int)), this, SLOT(onActiveConnectionChanged(QString, QString, QString, int)), Qt::QueuedConnection);
connect(m_interface, SIGNAL(wirelessSwitchBtnChanged(bool)), this, SLOT(onWirelessBtnChanged(bool)), Qt::QueuedConnection);
}
connect(m_apNameLine, &QLineEdit::textEdited, this, &MobileHotspotWidget::onApLineEditTextEdit);
#ifdef HOTSPOT_CONTROL
connect(m_connectDevPage, SIGNAL(setStaIntoBlacklist(QString, QString)), m_blacklistPage, SLOT(onsetStaIntoBlacklist(QString, QString)));
#endif
connect(m_pwdNameLine, SIGNAL(textChanged(QString)), this, SLOT(onPwdTextChanged()));
}
void MobileHotspotWidget::onApLineEditTextEdit(QString text)
{
int count = 0;
int i = 0;
for ( ; i < text.length(); ++i) {
count += text.mid(i,1).toLocal8Bit().length();
if (count > AP_NAME_MAX_LENGTH) {
break;
}
}
m_apNameLine->setText(text.left(i));
}
void MobileHotspotWidget::onPwdTextChanged()
{
if (m_pwdNameLine->text().length() < 8) {
m_passwordFrame->setFixedHeight(PASSWORD_FRAME_FIX_HIGHT);
m_pwdHintLabel->show();
} else {
m_passwordFrame->setFixedHeight(PASSWORD_FRAME_MIN_HIGHT);
m_pwdHintLabel->hide();
}
resetFrameSize();
this->update();
}
void MobileHotspotWidget::onActiveConnectionChanged(QString deviceName, QString ssid, QString uuid, int status)
{
if(m_uuid == uuid && status == 4) {
showDesktopNotify(tr("hotspot already close"));
m_switchBtn->setChecked(false);
setUiEnabled(false);
m_uuid.clear();
}
}
void MobileHotspotWidget::onWirelessBtnChanged(bool state)
{
if (!state) {
m_switchBtn->setChecked(state);
m_uuid.clear();
m_switchBtn->setCheckable(false);
} else {
m_switchBtn->setCheckable(true);
}
}
void MobileHotspotWidget::initInterfaceInfo()
{
if(!m_interface->isValid()) {
return;
}
m_interfaceComboBox->clear();
QDBusReply<QMap<QString, bool> > reply = m_interface->call("getDeviceListAndEnabled",WIRELESS);
if (!reply.isValid()) {
qDebug() << LOG_HEAD <<"execute dbus method 'getDeviceListAndEnabled' is invalid in func initInterfaceInfo()";
setWidgetHidden(true);
return;
}
QMap<QString, bool> devMap = reply.value();
QDBusReply<QMap<QString, int> > capReply = m_interface->call("getWirelessDeviceCap");
if (!capReply.isValid()) {
qDebug() << LOG_HEAD <<"execute dbus method 'getWirelessDeviceCap' is invalid in func initInterfaceInfo()" <<capReply.error().type() ;
setWidgetHidden(true);
return;
}
QMap<QString, int> devCapMap = capReply.value();
if (devMap.isEmpty()) {
qDebug() << LOG_HEAD << "no wireless device";
setWidgetHidden(true);
m_switchBtn->setCheckable(false);
} else {
QMap<QString, bool>::Iterator iter = devMap.begin();
while (iter != devMap.end()) {
QString interfaceName = iter.key();
if (devCapMap[interfaceName] & 0x01) {
m_interfaceComboBox->addItem(interfaceName);
}
iter++;
}
if (m_interfaceComboBox->count() > 0) {
setWidgetHidden(false);
m_interfaceName = m_interfaceComboBox->currentText();
if (m_interfaceComboBox->count() == 1) {
updateBandCombox();
}
} else {
qDebug() << LOG_HEAD << "no useable wireless device";
setWidgetHidden(true);
}
}
}
void MobileHotspotWidget::getApInfo()
{
if (!m_interface->isValid()) {
return;
}
if (m_interfaceComboBox->count() <= 0) {
m_switchBtn->setChecked(false);
setWidgetHidden(true);
qWarning() << LOG_HEAD << "getApInfo but interface is empty";
return;
}
QDBusReply<QStringList> reply = m_interface->call("getStoredApInfo");
if (!reply.isValid()) {
qDebug() << LOG_HEAD <<"execute dbus method 'getStoredApInfo' is invalid in func getObjectPath()";
}
QStringList apInfo = reply.value();
if (apInfo.isEmpty()) {
qDebug() << LOG_HEAD << "no stored hotspot info";
m_apNameLine->setText(m_hostName);
m_pwdNameLine->setText("12345678");
return;
} else {
int index = m_interfaceComboBox->findText(apInfo.at(2));
if (index >= 0) {
m_apNameLine->setText(apInfo.at(0));
m_pwdNameLine->setText(apInfo.at(1));
m_interfaceComboBox->setCurrentIndex(index);
m_interfaceName = apInfo.at(2);
if (apInfo.at(3) == "true") {
m_switchBtn->setChecked(true);
setUiEnabled(true);
m_uuid = apInfo.at(4);
} else {
m_switchBtn->setChecked(false);
setUiEnabled(false);
m_uuid = apInfo.at(4);
}
} else {
qDebug() << LOG_HEAD << "no such interface " << apInfo.at(2);
}
}
}
void MobileHotspotWidget::setSwitchFrame()
{
/* Open */
m_switchFrame = new QFrame(this);
m_switchFrame->setFrameShape(QFrame::Shape::NoFrame);
m_switchFrame->setMinimumSize(FRAME_MIN_SIZE);
m_switchFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
QHBoxLayout *switchLayout = new QHBoxLayout(m_switchFrame);
m_switchLabel = new QLabel(tr("Open"), this);
m_switchLabel->setMinimumWidth(LABLE_MIN_WIDTH);
m_switchBtn = new KSwitchButton(this);
switchLayout->setContentsMargins(ITEM_MARGINS);
switchLayout->addWidget(m_switchLabel);
switchLayout->addStretch();
switchLayout->addWidget(m_switchBtn);
m_switchFrame->setLayout(switchLayout);
}
void MobileHotspotWidget::setApNameFrame()
{
/* ApName */
m_ApNameFrame = new QFrame(this);
m_ApNameFrame->setFrameShape(QFrame::Shape::NoFrame);
m_ApNameFrame->setMinimumSize(FRAME_MIN_SIZE);
m_ApNameFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
QHBoxLayout *apNameHLayout = new QHBoxLayout(m_ApNameFrame);
m_apNameLabel = new QLabel(tr("Wi-Fi Name"), this);
m_apNameLabel->setMinimumWidth(LABLE_MIN_WIDTH);
m_apNameLine = new QLineEdit(this);
m_apNameLine->setMinimumWidth(COMBOBOX_MIN_WIDTH);
m_apNameLine->setMaxLength(AP_NAME_MAX_LENGTH);
apNameHLayout->setContentsMargins(ITEM_MARGINS);
apNameHLayout->setSpacing(0);
apNameHLayout->addWidget(m_apNameLabel);
apNameHLayout->addWidget(m_apNameLine);
m_ApNameFrame->setLayout(apNameHLayout);
}
void MobileHotspotWidget::setPasswordFrame()
{
/* Password */
m_passwordFrame = new QFrame(this);
m_passwordFrame->setFrameShape(QFrame::Shape::NoFrame);
m_passwordFrame->setMinimumSize(PASSWORD_FRAME_MIN_SIZE);
m_passwordFrame->setMaximumSize(PASSWORD_FRAME_MAX_SIZE);
m_pwdLabel = new QLabel(tr("Password"), this);
m_pwdLabel->setMinimumWidth(LABLE_MIN_WIDTH);
m_pwdNameLine = new KPasswordEdit(this);
m_pwdNameLine->setClearButtonEnabled(false);//禁用ClearBtn按钮X
m_pwdNameLine->setMinimumWidth(COMBOBOX_MIN_WIDTH);
m_pwdHintLabel= new QLabel(this);
m_pwdHintLabel->setFixedHeight(20);
m_pwdHintLabel->setContentsMargins(HINT_TEXT_MARGINS);
QPalette hintTextColor;
hintTextColor.setColor(QPalette::WindowText, Qt::red);
m_pwdHintLabel->setPalette(hintTextColor);
m_pwdHintLabel->setText(tr("Contains at least 8 characters")); //至少包含8个字符
QWidget *pwdInputWidget = new QWidget(m_passwordFrame);
QVBoxLayout *pwdInputVLayout = new QVBoxLayout(pwdInputWidget);
pwdInputVLayout->setContentsMargins(CONTENTS_MARGINS);
pwdInputVLayout->setSpacing(0);
pwdInputVLayout->addWidget(m_pwdNameLine);
pwdInputVLayout->addWidget(m_pwdHintLabel);
QFormLayout *pwdLayout = new QFormLayout(m_passwordFrame);
pwdLayout->setContentsMargins(PASSWORD_ITEM_MARGINS);
pwdLayout->setSpacing(0);
pwdLayout->addRow(m_pwdLabel, pwdInputWidget);
m_passwordFrame->setLayout(pwdLayout);
m_pwdNameLine->installEventFilter(this);
}
void MobileHotspotWidget::setFreqBandFrame()
{
/* frequency band */
m_freqBandFrame = new QFrame(this);
m_freqBandFrame->setFrameShape(QFrame::Shape::NoFrame);
m_freqBandFrame->setMinimumSize(FRAME_MIN_SIZE);
m_freqBandFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
QHBoxLayout *freqBandHLayout = new QHBoxLayout(m_freqBandFrame);
m_freqBandLabel = new QLabel(tr("Frequency band"), this);
m_freqBandLabel->setMinimumWidth(LABLE_MIN_WIDTH);
m_freqBandComboBox = new QComboBox(this);
m_freqBandComboBox->setInsertPolicy(QComboBox::NoInsert);
m_freqBandComboBox->setMinimumWidth(COMBOBOX_MIN_WIDTH);
m_freqBandComboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
m_freqBandComboBox->addItem("2.4GHz");
m_freqBandComboBox->addItem("5GHz");
freqBandHLayout->setContentsMargins(ITEM_MARGINS);
freqBandHLayout->setSpacing(0);
freqBandHLayout->addWidget(m_freqBandLabel);
freqBandHLayout->addWidget(m_freqBandComboBox);
m_freqBandFrame->setLayout(freqBandHLayout);
}
void MobileHotspotWidget::setInterFaceFrame()
{
/* key tips */
m_interfaceFrame = new QFrame(this);
m_interfaceFrame->setFrameShape(QFrame::Shape::NoFrame);
m_interfaceFrame->setMinimumSize(FRAME_MIN_SIZE);
m_interfaceFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
QHBoxLayout *interfaceHLayout = new QHBoxLayout(m_interfaceFrame);
m_interfaceLabel = new QLabel(tr("Net card"), this);
m_interfaceLabel->setMinimumWidth(LABLE_MIN_WIDTH);
m_interfaceComboBox = new QComboBox(this);
m_interfaceComboBox->setInsertPolicy(QComboBox::NoInsert);
m_interfaceComboBox->setMinimumWidth(COMBOBOX_MIN_WIDTH);
m_interfaceComboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
interfaceHLayout->setContentsMargins(ITEM_MARGINS);
interfaceHLayout->setSpacing(0);
interfaceHLayout->addWidget(m_interfaceLabel);
interfaceHLayout->addWidget(m_interfaceComboBox);
m_interfaceFrame->setLayout(interfaceHLayout);
}
void MobileHotspotWidget::onActivateFailed(QString errorMessage)
{
if (errorMessage.indexOf("hotspot")) {
//todo
// showDesktopNotify(errorMessage);
}
}
void MobileHotspotWidget::onDeactivateFailed(QString errorMessage)
{
if (errorMessage.indexOf("hotspot")) {
// showDesktopNotify(errorMessage);
}
}
//设备插拔
void MobileHotspotWidget::onDeviceStatusChanged()
{
initInterfaceInfo();
getApInfo();
}
void MobileHotspotWidget::onDeviceNameChanged(QString oldName, QString newName, int type)
{
if (WIRELESS != type) {
return;
}
int index = m_interfaceComboBox->findText(oldName);
if (index >= 0) {
m_interfaceComboBox->setItemText(index, newName);
if (m_interfaceName == oldName) {
m_interfaceName = newName;
}
}
}
//热点断开
void MobileHotspotWidget::onHotspotDeactivated(QString devName, QString ssid)
{
if (!m_switchBtn->isChecked()) {
return;
}
if (devName == m_interfaceComboBox->currentText() && ssid == m_apNameLine->text()) {
m_switchBtn->setChecked(false);
m_uuid.clear();
// setUiEnabled(true);
showDesktopNotify(tr("hotspot already close"));
}
}
//热点连接
void MobileHotspotWidget::onHotspotActivated(QString devName, QString ssid, QString uuid, QString activePath, QString settingPath)
{
qDebug() << LOG_HEAD << "onHotspotActivated" <<devName << ssid << uuid;
if (m_switchBtn->isChecked()) {
return;
}
#ifdef HOTSPOT_CONTROL
if (activePath != nullptr) {
deleteActivePathInterface();
initActivePathInterface(activePath);
}
if (settingPath != nullptr) {
deleteSettingPathInterface();
initSettingPathInterface(settingPath);
}
m_connectDevPage->refreshStalist();
m_blacklistPage->refreshBlacklist();
#endif
this->update();
if (devName == m_interfaceComboBox->currentText() && ssid == m_apNameLine->text()) {
m_switchBtn->setChecked(true);
m_uuid = uuid;
// setUiEnabled(false);
showDesktopNotify(tr("hotspot already open"));
} else {
QStringList info;
if (!getApInfoBySsid(devName, ssid, info)) {
return;
}
int index = m_interfaceComboBox->findText(devName);
if (index >= 0) {
showDesktopNotify(tr("hotspot already open"));
m_apNameLine->setText(ssid);
m_interfaceComboBox->setCurrentIndex(index);
m_switchBtn->setChecked(true);
m_switchBtn->setCheckable(true);
m_pwdNameLine->setText(info.at(0));
m_interfaceName = devName;
updateBandCombox();
index = m_freqBandComboBox->findText(info.at(1));
if (index >= 0) {
m_freqBandComboBox->setCurrentIndex(index);
}
m_uuid = uuid;
} else {
qDebug() << "no such device in combo box";
}
}
}
bool MobileHotspotWidget::getApInfoBySsid(QString devName, QString ssid, QStringList &info)
{
info.clear();
if(!m_interface->isValid()) {
return false;
}
QDBusReply<QStringList> reply = m_interface->call("getApInfoBySsid", devName, ssid);
if (!reply.isValid()) {
qDebug()<<"execute dbus method 'getApInfoBySsid' is invalid in func getApInfoBySsid()";
}
info = reply.value();
if (info.size() != 2) {
return false;
} else {
return true;
}
}
void MobileHotspotWidget::setUiEnabled(bool enable)
{
qDebug() << "switch mode change to " << enable;
if (enable) {
m_pwdNameLine->setEnabled(false);
m_freqBandComboBox->setEnabled(false);
m_interfaceComboBox->setEnabled(false);
m_apNameLine->setEnabled(false);
} else {
m_pwdNameLine->setEnabled(true);
m_freqBandComboBox->setEnabled(true);
m_interfaceComboBox->setEnabled(true);
m_apNameLine->setEnabled(true);
}
}
void MobileHotspotWidget::setWidgetHidden(bool isHidden)
{
m_ApNameFrame->setHidden(isHidden);
m_passwordFrame->setHidden(isHidden);
m_freqBandFrame->setHidden(isHidden);
m_interfaceFrame->setHidden(isHidden);
switchAndApNameLine->setHidden(isHidden);
apNameAndPwdLine->setHidden(isHidden);
pwdAndfreqBandLine->setHidden(isHidden);
freqBandAndInterfaceLine->setHidden(isHidden);
if (isHidden) {
m_switchBtn->setChecked(false);
m_switchBtn->setCheckable(false);
m_interfaceName = "";
m_uuid = "";
} else {
m_switchBtn->setCheckable(true);
QDBusReply<bool> reply = m_interface->call("getWirelessSwitchBtnState");
bool state = reply.value();
onWirelessBtnChanged(state);
}
resetFrameSize();
}
void MobileHotspotWidget::updateBandCombox()
{
m_freqBandComboBox->clear();
QDBusReply<QMap<QString, int> > capReply = m_interface->call("getWirelessDeviceCap");
if (!capReply.isValid()) {
qDebug()<<"execute dbus method 'getWirelessDeviceCap' is invalid in func initInterfaceInfo()" << capReply.error().message();
setWidgetHidden(true);
return;
}
QMap<QString, int> devCapMap = capReply.value();
if (devCapMap[m_interfaceName] & 0x02) {
m_freqBandComboBox->addItem("2.4GHz");
}
if (devCapMap[m_interfaceName] & 0x04) {
m_freqBandComboBox->addItem("5GHz");
}
}
QFrame* MobileHotspotWidget::myLine()
{
QFrame *line = new QFrame(this);
line->setMinimumSize(QSize(LINE_MIN_SIZE));
line->setMaximumSize(QSize(LINE_MAX_SIZE));
line->setLineWidth(0);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
return line;
}
QString MobileHotspotWidget::getHostName()
{
int count = 0;
while (count < 3) {
QDBusInterface hostInterface("org.freedesktop.hostname1",
"/org/freedesktop/hostname1",
"org.freedesktop.hostname1",
QDBusConnection::systemBus());
if (hostInterface.isValid()) {
return hostInterface.property("Hostname").value<QString>();
} else {
count++;
}
}
return "default";
}
QString MobileHotspotWidget::getSettingPathByUuid()
{
if (!m_interface->isValid()) {
return nullptr;
}
QDBusReply<QString> reply = m_interface->call("getApConnectionPath", m_uuid);
if (!reply.isValid()) {
return nullptr;
}
return reply.value();
}
QString MobileHotspotWidget::getActivePathByUuid()
{
if (!m_interface->isValid()) {
return nullptr;
}
QDBusReply<QString> reply = m_interface->call("getActiveConnectionPath", m_uuid);
if (!reply.isValid()) {
return nullptr;
}
return reply.value();
}
void MobileHotspotWidget::initNmDbus()
{
QString activePath = getActivePathByUuid();
QString settingPath = getSettingPathByUuid();
if (activePath != nullptr) {
m_activePathInterface = new QDBusInterface("org.freedesktop.NetworkManager",
activePath,
"org.freedesktop.NetworkManager.Connection.Active",
QDBusConnection::systemBus());
if (m_activePathInterface->isValid()) {
m_connectDevPage->setInterface(m_activePathInterface);
connect(m_activePathInterface, SIGNAL(NewStaConnected(bool, QString, QString)), m_connectDevPage, SLOT(onStaDevAdded(bool, QString, QString)), Qt::QueuedConnection);
connect(m_activePathInterface, SIGNAL(StaRemoved(bool, QString, QString)), m_connectDevPage, SLOT(onStaDevRemoved(bool, QString, QString)), Qt::QueuedConnection);
}
}
if (settingPath != nullptr) {
m_settingPathInterface = new QDBusInterface("org.freedesktop.NetworkManager",
settingPath,
"org.freedesktop.NetworkManager.Settings.Connection",
QDBusConnection::systemBus());
if (m_settingPathInterface->isValid()) {
m_blacklistPage->setInterface(m_settingPathInterface);
}
}
}
void MobileHotspotWidget::initActivePathInterface(QString path)
{
if (path != nullptr){
m_activePathInterface = new QDBusInterface("org.freedesktop.NetworkManager",
path,
"org.freedesktop.NetworkManager.Connection.Active",
QDBusConnection::systemBus());
if (m_activePathInterface->isValid()) {
m_connectDevPage->setInterface(m_activePathInterface);
connect(m_activePathInterface, SIGNAL(NewStaConnected(bool, QString, QString)), m_connectDevPage, SLOT(onStaDevAdded(bool, QString, QString)), Qt::QueuedConnection);
connect(m_activePathInterface, SIGNAL(StaRemoved(bool, QString, QString)), m_connectDevPage, SLOT(onStaDevRemoved(bool, QString, QString)), Qt::QueuedConnection);
}
}
}
void MobileHotspotWidget::deleteActivePathInterface()
{
if (m_activePathInterface != nullptr){
disconnect(m_activePathInterface);
delete m_activePathInterface;
m_activePathInterface = nullptr;
}
}
void MobileHotspotWidget::initSettingPathInterface(QString path)
{
if (path != nullptr){
m_settingPathInterface = new QDBusInterface("org.freedesktop.NetworkManager",
path,
"org.freedesktop.NetworkManager.Settings.Connection",
QDBusConnection::systemBus());
if (m_settingPathInterface->isValid()) {
m_blacklistPage->setInterface(m_settingPathInterface);
}
}
}
void MobileHotspotWidget::deleteSettingPathInterface()
{
if (m_settingPathInterface != nullptr){
disconnect(m_settingPathInterface);
delete m_settingPathInterface;
m_settingPathInterface = nullptr;
}
}
void MobileHotspotWidget::initConnectDevPage()
{
m_connectDevPage = new ConnectdevPage(this);
m_Vlayout->addSpacing(32);
m_Vlayout->addWidget(m_connectDevPage);
}
void MobileHotspotWidget::initBlackListPage()
{
m_blacklistPage = new BlacklistPage(this);
m_Vlayout->addSpacing(32);
m_Vlayout->addWidget(m_blacklistPage);
}

View File

@ -0,0 +1,163 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef MOBILEHOTSPOTWIDGET_H
#define MOBILEHOTSPOTWIDGET_H
#include <QWidget>
#include <QLabel>
#include <QHBoxLayout>
#include <QPushButton>
#include <QComboBox>
#include <QLineEdit>
#include <QCheckBox>
#include <QTranslator>
#include <QApplication>
#include <QTimer>
#include <QDBusMessage>
#include <QDBusObjectPath>
#include <QDBusInterface>
#include <QDBusReply>
#include <QDBusMetaType>
#include <QScrollArea>
#include "titlelabel.h"
#include "kwidget.h"
#include "kswitchbutton.h"
#include "kpasswordedit.h"
#include "connectdevlistitem.h"
#include "blacklistpage.h"
#include "connectdevpage.h"
using namespace kdk;
class MobileHotspotWidget : public QWidget
{
Q_OBJECT
public:
explicit MobileHotspotWidget(QWidget *parent = nullptr);
~MobileHotspotWidget();
private:
QFrame *m_hotspotFrame = nullptr;
QFrame *m_switchFrame = nullptr; //开关
QFrame *m_ApNameFrame = nullptr; //wifi名称
QFrame *m_passwordFrame = nullptr; //密码
QFrame *m_freqBandFrame = nullptr; //频带
QFrame *m_interfaceFrame = nullptr; //网卡
KSwitchButton *m_switchBtn;
TitleLabel *m_hotspotTitleLabel;
QLabel *m_switchLabel;
QLabel *m_apNameLabel;
QLabel *m_pwdLabel;
QLabel *m_pwdHintLabel;
QLabel *m_freqBandLabel;
QLabel *m_interfaceLabel;
QFrame *switchAndApNameLine;
QFrame *apNameAndPwdLine;
QFrame *pwdAndfreqBandLine;
QFrame *freqBandAndInterfaceLine;
QVBoxLayout *m_Vlayout;
QLineEdit *m_apNameLine;
KPasswordEdit *m_pwdNameLine;
QComboBox *m_freqBandComboBox;
QComboBox *m_interfaceComboBox;
QDBusInterface *m_interface = nullptr;
QString m_interfaceName = "";
QGSettings *m_switchGsettings = nullptr;
QString m_uuid = "";
QString m_hostName = "";
void resetFrameSize();
void initUI();
void initDbusConnect();
void initInterfaceInfo();
void getApInfo();
bool getApInfoBySsid(QString devName, QString ssid, QStringList &info);
void setSwitchFrame();
void setApNameFrame();
void setPasswordFrame();
void setFreqBandFrame();
void setInterFaceFrame();
void setUiEnabled(bool enable);
void setWidgetHidden(bool isHidden);
void showDesktopNotify(const QString &message);
void updateBandCombox();
QString getHostName();
bool eventFilter(QObject *watched, QEvent *event);
void paintEvent(QPaintEvent *event);
QFrame* myLine();
QDBusInterface *m_activePathInterface = nullptr;
QDBusInterface *m_settingPathInterface = nullptr;
ConnectdevPage * m_connectDevPage = nullptr;
BlacklistPage *m_blacklistPage = nullptr;
QString getActivePathByUuid();
QString getSettingPathByUuid();
void initNmDbus();
void initActivePathInterface(QString path);
void deleteActivePathInterface();
void initSettingPathInterface(QString path);
void deleteSettingPathInterface();
void initConnectDevPage();
void initBlackListPage();
signals:
private slots:
void onActivateFailed(QString errorMessage);
void onDeactivateFailed(QString errorMessage);
//设备插拔
void onDeviceStatusChanged();
void onDeviceNameChanged(QString oldName, QString newName, int type);
//热点断开
void onHotspotDeactivated(QString devName, QString ssid);
//热点连接
void onHotspotActivated(QString devName, QString ssid, QString uuid, QString activePath, QString settingPath);
void onWirelessBtnChanged(bool state);
void onActiveConnectionChanged(QString deviceName, QString ssid, QString uuid, int status);
void onApLineEditTextEdit(QString text);
void onPwdTextChanged();
};
#endif // MOBILEHOTSPOTWIDGET_H

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>BlacklistItem</name>
<message>
<location filename="../blacklistitem.cpp" line="49"/>
<source>Remove</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BlacklistPage</name>
<message>
<location filename="../blacklistpage.cpp" line="45"/>
<source>Blacklist</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectDevListItem</name>
<message>
<location filename="../connectdevlistitem.cpp" line="49"/>
<source>drag into blacklist</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectdevPage</name>
<message>
<location filename="../connectdevpage.cpp" line="46"/>
<source>Connect device</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MobileHotspot</name>
<message>
<location filename="../mobilehotspot.cpp" line="35"/>
<source>MobileHotspot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspot.cpp" line="101"/>
<source>mobilehotspot</source>
<translation type="unfinished"></translation>
<extra-contents_path>/mobilehotspot/mobilehotspot</extra-contents_path>
</message>
<message>
<location filename="../mobilehotspot.cpp" line="103"/>
<source>mobilehotspot open</source>
<translation type="unfinished"></translation>
<extra-contents_path>/mobilehotspot/mobilehotspot open</extra-contents_path>
</message>
</context>
<context>
<name>MobileHotspotWidget</name>
<message>
<location filename="../mobilehotspotwidget.cpp" line="59"/>
<source>ukui control center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="62"/>
<source>ukui control center desktop message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="138"/>
<source>wirless switch is close or no wireless device</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="142"/>
<source>start to close hotspot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="151"/>
<source>hotpots name or device is invalid</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="158"/>
<source>start to open hotspot </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="489"/>
<source>Contains at least 8 characters</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="205"/>
<source>Hotspot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="295"/>
<location filename="../mobilehotspotwidget.cpp" line="610"/>
<source>hotspot already close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="435"/>
<source>Open</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="456"/>
<source>Wi-Fi Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="477"/>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="518"/>
<source>Frequency band</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="544"/>
<source>Net card</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="639"/>
<location filename="../mobilehotspotwidget.cpp" line="647"/>
<source>hotspot already open</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="bo_CN">
<context>
<name>BlacklistItem</name>
<message>
<location filename="../blacklistitem.cpp" line="49"/>
<source>Remove</source>
<translation></translation>
</message>
</context>
<context>
<name>BlacklistPage</name>
<message>
<location filename="../blacklistpage.cpp" line="45"/>
<source>Blacklist</source>
<translation></translation>
</message>
</context>
<context>
<name>ConnectDevListItem</name>
<message>
<location filename="../connectdevlistitem.cpp" line="49"/>
<source>drag into blacklist</source>
<translation></translation>
</message>
</context>
<context>
<name>ConnectdevPage</name>
<message>
<location filename="../connectdevpage.cpp" line="46"/>
<source>Connect device</source>
<translation></translation>
</message>
</context>
<context>
<name>MobileHotspot</name>
<message>
<location filename="../mobilehotspot.cpp" line="35"/>
<source>MobileHotspot</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspot.cpp" line="101"/>
<source>mobilehotspot</source>
<translation></translation>
<extra-contents_path>/mobilehotspot/mobilehotspot</extra-contents_path>
</message>
<message>
<location filename="../mobilehotspot.cpp" line="103"/>
<source>mobilehotspot open</source>
<translation></translation>
<extra-contents_path>/mobilehotspot/mobilehotspot open</extra-contents_path>
</message>
</context>
<context>
<name>MobileHotspotWidget</name>
<message>
<location filename="../mobilehotspotwidget.cpp" line="59"/>
<source>ukui control center</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="62"/>
<source>ukui control center desktop message</source>
<translation>ukui </translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="138"/>
<source>wirless switch is close or no wireless device</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="142"/>
<source>start to close hotspot</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="151"/>
<source>hotpots name or device is invalid</source>
<translation></translation>
</message>
<message>
<source>can not create hotspot with password length less than eight!</source>
<translation type="vanished">!</translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="158"/>
<source>start to open hotspot </source>
<translation> </translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="489"/>
<source>Contains at least 8 characters</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="205"/>
<source>Hotspot</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="295"/>
<location filename="../mobilehotspotwidget.cpp" line="610"/>
<source>hotspot already close</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="435"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="456"/>
<source>Wi-Fi Name</source>
<translation>Wi-Fiཡི</translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="477"/>
<source>Password</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="518"/>
<source>Frequency band</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="544"/>
<source>Net card</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="639"/>
<location filename="../mobilehotspotwidget.cpp" line="647"/>
<source>hotspot already open</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>BlacklistItem</name>
<message>
<location filename="../blacklistitem.cpp" line="49"/>
<source>Remove</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BlacklistPage</name>
<message>
<location filename="../blacklistpage.cpp" line="45"/>
<source>Blacklist</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectDevListItem</name>
<message>
<location filename="../connectdevlistitem.cpp" line="49"/>
<source>drag into blacklist</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConnectdevPage</name>
<message>
<location filename="../connectdevpage.cpp" line="46"/>
<source>Connect device</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MobileHotspot</name>
<message>
<location filename="../mobilehotspot.cpp" line="35"/>
<source>MobileHotspot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspot.cpp" line="101"/>
<source>mobilehotspot</source>
<translation type="unfinished"></translation>
<extra-contents_path>/mobilehotspot/mobilehotspot</extra-contents_path>
</message>
<message>
<location filename="../mobilehotspot.cpp" line="103"/>
<source>mobilehotspot open</source>
<translation type="unfinished"></translation>
<extra-contents_path>/mobilehotspot/mobilehotspot open</extra-contents_path>
</message>
</context>
<context>
<name>MobileHotspotWidget</name>
<message>
<location filename="../mobilehotspotwidget.cpp" line="59"/>
<source>ukui control center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="62"/>
<source>ukui control center desktop message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="138"/>
<source>wirless switch is close or no wireless device</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="142"/>
<source>start to close hotspot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="151"/>
<source>hotpots name or device is invalid</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="158"/>
<source>start to open hotspot </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="489"/>
<source>Contains at least 8 characters</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="205"/>
<source>Hotspot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="295"/>
<location filename="../mobilehotspotwidget.cpp" line="610"/>
<source>hotspot already close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="435"/>
<source>Open</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="456"/>
<source>Wi-Fi Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="477"/>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="518"/>
<source>Frequency band</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="544"/>
<source>Net card</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="639"/>
<location filename="../mobilehotspotwidget.cpp" line="647"/>
<source>hotspot already open</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>BlacklistItem</name>
<message>
<location filename="../blacklistitem.cpp" line="49"/>
<source>Remove</source>
<translation></translation>
</message>
</context>
<context>
<name>BlacklistPage</name>
<message>
<location filename="../blacklistpage.cpp" line="45"/>
<source>Blacklist</source>
<translation></translation>
</message>
</context>
<context>
<name>ConnectDevListItem</name>
<message>
<location filename="../connectdevlistitem.cpp" line="49"/>
<source>drag into blacklist</source>
<translation></translation>
</message>
</context>
<context>
<name>ConnectdevPage</name>
<message>
<location filename="../connectdevpage.cpp" line="46"/>
<source>Connect device</source>
<translation></translation>
</message>
</context>
<context>
<name>MobileHotspot</name>
<message>
<location filename="../mobilehotspot.cpp" line="35"/>
<source>MobileHotspot</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspot.cpp" line="101"/>
<source>mobilehotspot</source>
<translation></translation>
<extra-contents_path>/mobilehotspot/mobilehotspot</extra-contents_path>
</message>
<message>
<location filename="../mobilehotspot.cpp" line="103"/>
<source>mobilehotspot open</source>
<translation> </translation>
<extra-contents_path>/mobilehotspot/mobilehotspot open</extra-contents_path>
</message>
</context>
<context>
<name>MobileHotspotWidget</name>
<message>
<location filename="../mobilehotspotwidget.cpp" line="59"/>
<source>ukui control center</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="62"/>
<source>ukui control center desktop message</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="138"/>
<source>wirless switch is close or no wireless device</source>
<translation>线线</translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="142"/>
<source>start to close hotspot</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="151"/>
<source>hotpots name or device is invalid</source>
<translation></translation>
</message>
<message>
<source>can not create hotspot with password length less than eight!</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="158"/>
<source>start to open hotspot </source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="489"/>
<source>Contains at least 8 characters</source>
<translation>8</translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="205"/>
<source>Hotspot</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="295"/>
<location filename="../mobilehotspotwidget.cpp" line="610"/>
<source>hotspot already close</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="435"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="456"/>
<source>Wi-Fi Name</source>
<translation>Wi-Fi名称</translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="477"/>
<source>Password</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="518"/>
<source>Frequency band</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="544"/>
<source>Net card</source>
<translation></translation>
</message>
<message>
<location filename="../mobilehotspotwidget.cpp" line="639"/>
<location filename="../mobilehotspotwidget.cpp" line="647"/>
<source>hotspot already open</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,72 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "deviceframe.h"
#define LAYOUT_MARGINS 16,0,16,0
#define FRAME_HEIGHT 58
#define RADIUS 6.0
DeviceFrame::DeviceFrame(QString devName, QWidget *parent) : QFrame(parent)
{
this->setFrameShape(QFrame::Box);
this->setFixedHeight(FRAME_HEIGHT);
QHBoxLayout *deviceLayout = new QHBoxLayout(this);
deviceLayout->setContentsMargins(LAYOUT_MARGINS);
setLayout(deviceLayout);
deviceLabel = new QLabel(this);
dropDownLabel = new DrownLabel(devName, this);
deviceSwitch = new KSwitchButton(this);
deviceSwitch->installEventFilter(this);
deviceLayout->addWidget(deviceLabel);
deviceLayout->addStretch();
deviceLayout->addWidget(dropDownLabel);
deviceLayout->addWidget(deviceSwitch);
}
bool DeviceFrame::eventFilter(QObject *w,QEvent *e)
{
if (w == deviceSwitch) {
if (e->type() == QEvent::MouseButtonPress) {
emit deviceSwitchClicked(!deviceSwitch->isChecked());
return true;
}
}
return QFrame::eventFilter(w, e);
}
void DeviceFrame::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
painter.setBrush(pal.color(QPalette::Base));
QRect rect = this->rect();
QPainterPath path;
path.addRoundedRect (rect, RADIUS, RADIUS);
QRect temp_rect(rect.left(), rect.top() + rect.height()/2, rect.width(), rect.height()/2);
path.addRect(temp_rect);
painter.drawPath(path);
QFrame::paintEvent(event);
}

View File

@ -0,0 +1,58 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef DEVICEFRAME_H
#define DEVICEFRAME_H
#include <QObject>
#include <QWidget>
#include <QPushButton>
#include <QHBoxLayout>
#include <QLabel>
#include <QTimer>
#include <QDebug>
#include "../component/DrownLabel/drownlabel.h"
#include "kwidget.h"
#include "kswitchbutton.h"
using namespace kdk;
class DeviceFrame : public QFrame
{
Q_OBJECT
public:
DeviceFrame(QString devName, QWidget *parent = nullptr);
public:
QLabel * deviceLabel = nullptr;
KSwitchButton * deviceSwitch = nullptr;
DrownLabel *dropDownLabel = nullptr;
protected:
void paintEvent(QPaintEvent *event);
bool eventFilter(QObject *w,QEvent *e);
private:
bool isDropDown = false;
int frameSize;
signals:
void deviceSwitchClicked(bool);
};
#endif // DEVICEFRAME_H

View File

@ -0,0 +1,61 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "itemframe.h"
#include <QPainter>
#include <QPalette>
#define LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_MARGINS 0,0,0,0
ItemFrame::ItemFrame(QString devName, QWidget *parent) : QFrame(parent)
{
deviceLanLayout = new QVBoxLayout(this);
deviceLanLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
lanItemFrame = new QFrame(this);
lanItemFrame->setFrameShape(QFrame::Shape::NoFrame);
lanItemLayout = new QVBoxLayout(this);
lanItemLayout->setContentsMargins(LAYOUT_MARGINS);
lanItemLayout->setSpacing(1);
addLanWidget = new AddNetBtn(false, this);
deviceLanLayout->setSpacing(1);
setLayout(deviceLanLayout);
lanItemFrame->setLayout(lanItemLayout);
deviceFrame = new DeviceFrame(devName, this);
deviceLanLayout->addWidget(deviceFrame);
deviceLanLayout->addWidget(lanItemFrame);
deviceLanLayout->addWidget(addLanWidget);
//下拉按钮
connect(deviceFrame->dropDownLabel, &DrownLabel::labelClicked, this, &ItemFrame::onDrownLabelClicked);
}
void ItemFrame::onDrownLabelClicked()
{
if (!deviceFrame->dropDownLabel->isChecked) {
lanItemFrame->show();
deviceFrame->dropDownLabel->setDropDownStatus(true);
} else {
lanItemFrame->hide();
deviceFrame->dropDownLabel->setDropDownStatus(false);
}
}

View File

@ -0,0 +1,51 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef ITEMFRAME_H
#define ITEMFRAME_H
#include <QFrame>
#include <QVBoxLayout>
#include "deviceframe.h"
#include <addbtn.h>
#include "../component/AddBtn/addnetbtn.h"
#include "lanitem.h"
class ItemFrame : public QFrame
{
Q_OBJECT
public:
ItemFrame(QString devName, QWidget *parent = nullptr);
//单设备整体layout
QVBoxLayout * deviceLanLayout = nullptr;
//单设备名称+下拉按钮Frame+d单设备开关
DeviceFrame * deviceFrame = nullptr;
//单设备列表Frame
QFrame * lanItemFrame = nullptr;
//单设备列表layout
QVBoxLayout * lanItemLayout = nullptr;
//新建有线连接
AddNetBtn * addLanWidget = nullptr;
//单设备item列表 key:uuid
QMap<QString, LanItem *> itemMap;
private slots:
void onDrownLabelClicked();
};
#endif // ITEMFRAME_H

View File

@ -0,0 +1,106 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "lanitem.h"
#define FRAME_SPEED 150
#define LIMIT_TIME 60*1000
#define TOTAL_PAGE 8
#define THEME_QT_SCHEMA "org.ukui.style"
#define MODE_QT_KEY "style-name"
LanItem::LanItem(bool isAcitve, QWidget *parent)
: QPushButton(parent),isAcitve(isAcitve)
{
this->setMinimumSize(550, 58);
this->setProperty("useButtonPalette", true);
this->setFlat(true);
QPalette pal = this->palette();
QColor color = pal.color(QPalette::Button);
color.setAlphaF(0.5);
pal.setColor(QPalette::Button, color);
this->setPalette(pal);
// setStyleSheet("QPushButton:!checked{background-color: palette(base)}");
QHBoxLayout *mLanLyt = new QHBoxLayout(this);
mLanLyt->setContentsMargins(16,0,16,0);
mLanLyt->setSpacing(16);
iconLabel = new QLabel(this);
iconLabel->setProperty("useIconHighlightEffect", 0x2);
titileLabel = new FixLabel(this);
statusLabel = new QLabel(this);
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
// statusLabel->setMinimumSize(36,36);
infoLabel = new GrayInfoButton(this);
mLanLyt->addWidget(iconLabel);
mLanLyt->addWidget(titileLabel,Qt::AlignLeft);
mLanLyt->addStretch();
mLanLyt->addWidget(statusLabel);
mLanLyt->addWidget(infoLabel);
loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));
loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic"));
loadIcons.append(QIcon::fromTheme("ukui-loading-3-symbolic"));
loadIcons.append(QIcon::fromTheme("ukui-loading-4-symbolic"));
loadIcons.append(QIcon::fromTheme("ukui-loading-5-symbolic"));
loadIcons.append(QIcon::fromTheme("ukui-loading-6-symbolic"));
loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic"));
waitTimer = new QTimer(this);
connect(waitTimer, &QTimer::timeout, this, &LanItem::updateIcon);
}
LanItem::~LanItem()
{
}
void LanItem::updateIcon()
{
if (currentIconIndex > 6) {
currentIconIndex = 0;
}
statusLabel->setPixmap(loadIcons.at(currentIconIndex).pixmap(16,16));
currentIconIndex ++;
}
void LanItem::startLoading()
{
waitTimer->start(FRAME_SPEED);
loading = true;
}
void LanItem::stopLoading(){
waitTimer->stop();
loading = false;
}
void LanItem::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
painter.setBrush(pal.color(QPalette::Base));
QRect rect = this->rect();
painter.drawRect(rect);
QPushButton::paintEvent(event);
}

View File

@ -0,0 +1,71 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef LANITEM_H
#define LANITEM_H
#include <QWidget>
#include <QPushButton>
#include <QHBoxLayout>
#include <QLabel>
#include <QVariantMap>
#include <QTimer>
#include <QGSettings>
#include <QDebug>
#include <QImage>
#include <QPainter>
#include "fixlabel.h"
//#include "infobutton.h"
#include "../component/AddBtn/grayinfobutton.h"
class LanItem : public QPushButton
{
public:
LanItem(bool isAcitve, QWidget *parent = nullptr);
~LanItem();
public:
QLabel * iconLabel = nullptr;
GrayInfoButton * infoLabel = nullptr;
FixLabel * titileLabel = nullptr;
QLabel * statusLabel = nullptr;
public:
void startLoading();
void stopLoading();
bool loading = false;
bool isAcitve = false;
QString uuid;
QString dbusPath;
protected:
void paintEvent(QPaintEvent *);
private:
QTimer *waitTimer = nullptr;
QGSettings *themeGsettings = nullptr;
QList<QIcon> loadIcons;
int currentIconIndex=0;
private slots:
void updateIcon();
};
#endif // LANITEM_H

View File

@ -0,0 +1,898 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "netconnect.h"
#include "ui_netconnect.h"
#include <QGSettings>
#include <QProcess>
#include <QTimer>
#include <QtDBus>
#include <QDir>
#include <QDebug>
#include <QtAlgorithms>
#define WIRED_TYPE 0
#define ITEMHEIGH 50
#define LAN_TYPE 0
#define CONTROL_CENTER_WIFI "org.ukui.control-center.wifi.switch"
const QString KLanSymbolic = "network-wired-connected-symbolic";
const QString NoNetSymbolic = "network-wired-disconnected-symbolic";
const QString WIRED_SWITCH = "wiredswitch";
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
#define ACTIVATING 1
#define ACTIVATED 2
#define DEACTIVATING 3
#define DEACTIVATED 4
#define NO_MARGINS 0,0,0,0
#define TOP_MARGINS 0,8,0,0
#define MAIN_LAYOUT_MARGINS 0,0,0,8
#define SPACING 8
#define ICON_SIZE 16,16
bool sortByVal(const QPair<QString, int> &l, const QPair<QString, int> &r) {
return (l.second < r.second);
}
void NetConnect::showDesktopNotify(const QString &message)
{
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
args<<(tr("ukui control center"))
<<((unsigned int) 0)
<<QString("gnome-dev-ethernet")
<<tr("ukui control center desktop message") //显示的是什么类型的信息
<<message //显示的具体信息
<<QStringList()
<<QVariantMap()
<<(int)-1;
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
}
NetConnect::NetConnect() : mFirstLoad(true) {
QTranslator* translator = new QTranslator(this);
translator->load("/usr/share/kylin-nm/netconnect/" + QLocale::system().name());
QApplication::installTranslator(translator);
pluginName = tr("WiredConnect");
pluginType = NETWORK;
}
NetConnect::~NetConnect() {
if (!mFirstLoad) {
delete ui;
ui = nullptr;
delete m_interface;
delete m_switchGsettings;
}
}
QString NetConnect::plugini18nName() {
return pluginName;
}
int NetConnect::pluginTypes() {
return pluginType;
}
QWidget *NetConnect::pluginUi() {
if (mFirstLoad) {
mFirstLoad = false;
ui = new Ui::NetConnect;
pluginWidget = new QWidget;
pluginWidget->setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(pluginWidget);
qDBusRegisterMetaType<QVector<QStringList>>();
m_interface = new QDBusInterface("com.kylin.network",
"/com/kylin/network",
"com.kylin.network",
QDBusConnection::sessionBus());
if(!m_interface->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
}
initSearchText();
initComponent();
}
return pluginWidget;
}
const QString NetConnect::name() const {
return QStringLiteral("netconnect");
}
bool NetConnect::isEnable() const
{
return true;
}
bool NetConnect::isShowOnHomePage() const
{
return false;
}
QIcon NetConnect::icon() const
{
return QIcon::fromTheme("network-wired-symbolic");
}
QString NetConnect::translationPath() const
{
return "/usr/share/kylin-nm/netconnect/%1.ts";
}
void NetConnect::initSearchText() {
//~ contents_path /netconnect/Advanced settings"
ui->detailBtn->setText(tr("Advanced settings"));
ui->titleLabel->setText(tr("Wired Network"));
//~ contents_path /netconnect/open
ui->openLabel->setText(tr("open"));
}
bool NetConnect::eventFilter(QObject *w, QEvent *e) {
if (e->type() == QEvent::Enter) {
if (w->findChild<QWidget*>())
w->findChild<QWidget*>()->setStyleSheet("QWidget{background: palette(button);border-radius:4px;}");
} else if (e->type() == QEvent::Leave) {
if (w->findChild<QWidget*>())
w->findChild<QWidget*>()->setStyleSheet("QWidget{background: palette(base);border-radius:4px;}");
}
if (w == wiredSwitch) {
if (e->type() == QMouseEvent::MouseButtonRelease) {
if (!wiredSwitch->isCheckable()) {
showDesktopNotify(tr("No ethernet device avaliable"));
} else {
m_interface->call(QStringLiteral("setWiredSwitchEnable"), !wiredSwitch->isChecked());
return true;
}
}
}
return QObject::eventFilter(w,e);
}
void NetConnect::initComponent() {
wiredSwitch = new KSwitchButton(pluginWidget);
ui->openWIifLayout->addWidget(wiredSwitch);
ui->openWIifLayout->setContentsMargins(0,0,8,0);
ui->detailLayOut->setContentsMargins(MAIN_LAYOUT_MARGINS);
ui->verticalLayout_3->setContentsMargins(NO_MARGINS);
ui->verticalLayout_3->setSpacing(8);
ui->availableLayout->setSpacing(SPACING);
ui->horizontalLayout->setContentsMargins(TOP_MARGINS);
wiredSwitch->installEventFilter(this);
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
setSwitchStatus();
connect(m_switchGsettings, &QGSettings::changed, this, [=] (const QString &key) {
if (key == WIRED_SWITCH) {
setSwitchStatus();
}
});
} else {
wiredSwitch->blockSignals(true);
wiredSwitch->setChecked(true);
wiredSwitch->blockSignals(false);
qDebug()<<"[Netconnect] org.ukui.kylin-nm.switch is not installed!";
}
getDeviceStatusMap(deviceStatusMap);
if (deviceStatusMap.isEmpty()) {
qDebug() << "[Netconnect] no device exist when init, set switch disable";
wiredSwitch->setChecked(false);
wiredSwitch->setCheckable(false);
}
initNet();
if (!wiredSwitch->isChecked() || deviceStatusMap.isEmpty() || !m_interface->isValid()) {
hideLayout(ui->availableLayout);
}
// 有线网络断开或连接时刷新可用网络列表
connect(m_interface, SIGNAL(lanActiveConnectionStateChanged(QString, QString, int)), this, SLOT(onActiveConnectionChanged(QString, QString, int)), Qt::QueuedConnection);
//有线网络新增时添加网络
connect(m_interface, SIGNAL(lanAdd(QString, QStringList)), this, SLOT(onLanAdd(QString, QStringList)), Qt::QueuedConnection);
//删除有线网络
connect(m_interface, SIGNAL(lanRemove(QString)), this, SLOT(onLanRemove(QString)), Qt::QueuedConnection);
//更新有线网络
connect(m_interface, SIGNAL(lanUpdate(QString, QStringList)), this, SLOT(updateLanInfo(QString, QStringList)),Qt::QueuedConnection);
//网卡插拔处理
connect(m_interface, SIGNAL(deviceStatusChanged()), this, SLOT(onDeviceStatusChanged()),Qt::QueuedConnection);
//网卡name处理
connect(m_interface, SIGNAL(deviceNameChanged(QString, QString, int)), this, SLOT(onDeviceNameChanged(QString, QString, int)),Qt::QueuedConnection);
connect(ui->detailBtn, &QPushButton::clicked, this, [=](bool checked) {
Q_UNUSED(checked)
runExternalApp();
});
}
//获取网卡列表
void NetConnect::getDeviceStatusMap(QMap<QString, bool> &map)
{
if (!m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call getDeviceListAndEnabled" << __LINE__;
QDBusMessage result = m_interface->call(QStringLiteral("getDeviceListAndEnabled"),0);
qDebug() << "[NetConnect]call getDeviceListAndEnabled Respond" << __LINE__;
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "[NetConnect]getWiredDeviceList error:" << result.errorMessage();
return;
}
auto dbusArg = result.arguments().at(0).value<QDBusArgument>();
dbusArg >> map;
}
//lanUpdate
void NetConnect::updateLanInfo(QString deviceName, QStringList lanInfo)
{
//she bei gui shu bian hua && you xian ming cheng bian hua
QMap<QString, ItemFrame *>::iterator iter;
for (iter = deviceFrameMap.begin(); iter != deviceFrameMap.end(); iter++) {
if (deviceName.isEmpty()) {
//变为无指定网卡,所有列表都要添加
if (!iter.value()->itemMap.contains(lanInfo.at(1))) {
qDebug() << "[NetConnect]" << lanInfo.at(0) << " change to device none, add every list";
addOneLanFrame(iter.value(), iter.key(), lanInfo);
} else {
if (iter.value()->itemMap[lanInfo.at(1)]->titileLabel->text() != lanInfo.at(0)) {
qDebug() << "[NetConnect]" << iter.key()
<< iter.value()->itemMap[lanInfo.at(1)]->titileLabel->text() << "change to" << lanInfo.at(0);
iter.value()->itemMap[lanInfo.at(1)]->titileLabel->setText(lanInfo.at(0));
}
}
} else {
if (iter.key() != deviceName) {
qDebug() << "[NetConnect]" << lanInfo.at(0) << " not belongs to " << iter.key();
removeOneLanFrame(iter.value(), deviceName, lanInfo.at(1));
} else {
if (!iter.value()->itemMap.contains(lanInfo.at(1))) {
qDebug() << "[NetConnect]" << lanInfo.at(0) << " now belongs to " << deviceName;
addOneLanFrame(iter.value(), deviceName, lanInfo);
} else {
qDebug() << "[NetConnect]" << deviceName
<< iter.value()->itemMap[lanInfo.at(1)]->titileLabel->text() << "change to" << lanInfo.at(0);
if (iter.value()->itemMap[lanInfo.at(1)]->titileLabel->text() != lanInfo.at(0)) {
iter.value()->itemMap[lanInfo.at(1)]->titileLabel->setText(lanInfo.at(0));
}
}
}
}
}
}
//总开关
void NetConnect::setSwitchStatus()
{
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
bool status = m_switchGsettings->get(WIRED_SWITCH).toBool();
wiredSwitch->blockSignals(true);
wiredSwitch->setChecked(status);
wiredSwitch->blockSignals(false);
if (!status) {
hideLayout(ui->availableLayout);
} else {
showLayout(ui->availableLayout);
}
} else {
qDebug()<<"[netconnect] org.ukui.kylin-nm.switch is not installed!";
}
}
//总体隐藏
void NetConnect::hideLayout(QVBoxLayout * layout) {
for (int i = layout->layout()->count()-1; i >= 0; --i)
{
QLayoutItem *it = layout->layout()->itemAt(i);
ItemFrame *itemFrame = qobject_cast<ItemFrame *>(it->widget());
itemFrame->hide();
}
}
//总体显示
void NetConnect::showLayout(QVBoxLayout * layout) {
for (int i = layout->layout()->count()-1; i >= 0; --i)
{
QLayoutItem *it = layout->layout()->itemAt(i);
ItemFrame *itemFrame = qobject_cast<ItemFrame *>(it->widget());
itemFrame->show();
}
}
//初始化
void NetConnect::initNet()
{
//先构建每个设备的列表头
QStringList deviceList = deviceStatusMap.keys();
for (int i = 0; i < deviceList.size(); ++i) {
addDeviceFrame(deviceList.at(i));
}
//再填充每个设备的列表
for (int i = 0; i < deviceList.size(); ++i) {
initNetListFromDevice(deviceList.at(i));
}
}
void NetConnect::runExternalApp() {
QString cmd = "nm-connection-editor";
QProcess process(this);
process.startDetached(cmd);
}
//激活
void NetConnect::activeConnect(QString ssid, QString deviceName, int type) {
qDebug() << "[NetConnect]call activateConnect" << __LINE__;
m_interface->call(QStringLiteral("activateConnect"),type, deviceName, ssid);
qDebug() << "[NetConnect]call activateConnect respond" << __LINE__;
}
//断开
void NetConnect::deActiveConnect(QString ssid, QString deviceName, int type) {
qDebug() << "[NetConnect]call deActivateConnect" << __LINE__;
m_interface->call(QStringLiteral("deActivateConnect"),type, deviceName, ssid);
qDebug() << "[NetConnect]call deActivateConnect respond" << __LINE__;
}
//初始化设备列表 网卡标号问题?
void NetConnect::initNetListFromDevice(QString deviceName)
{
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName;
if (!deviceFrameMap.contains(deviceName)) {
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " not exist";
return;
}
if (!m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call getWiredList" << __LINE__;
QDBusMessage result = m_interface->call(QStringLiteral("getWiredList"));
qDebug() << "[NetConnect]call getWiredList respond" << __LINE__;
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getWiredList error:" << result.errorMessage();
return;
}
auto dbusArg = result.arguments().at(0).value<QDBusArgument>();
QMap<QString, QVector<QStringList>> variantList;
dbusArg >> variantList;
if (variantList.size() == 0) {
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " list empty";
return;
}
QMap<QString, QVector<QStringList>>::iterator iter;
for (iter = variantList.begin(); iter != variantList.end(); iter++) {
if (deviceName == iter.key()) {
QVector<QStringList> wlanListInfo = iter.value();
//处理列表 已连接
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " acitved lan " << wlanListInfo.at(0);
addLanItem(deviceFrameMap[deviceName], deviceName, wlanListInfo.at(0), true);
//处理列表 未连接
for (int i = 1; i < wlanListInfo.length(); i++) {
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " deacitved lan " << wlanListInfo.at(i);
addLanItem(deviceFrameMap[deviceName], deviceName, wlanListInfo.at(i), false);
}
}
}
return;
}
//初始化时添加一个项 不考虑顺序
void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoList, bool isActived)
{
if (frame == nullptr) {
return;
}
if (infoList.size() == 1) {
return;
}
LanItem * lanItem = new LanItem(pluginWidget);
QString iconPath = KLanSymbolic;
if (isActived) {
lanItem->statusLabel->setText(tr("connected"));
} else {
lanItem->statusLabel->setText("");
}
QIcon searchIcon = QIcon::fromTheme(iconPath);
// if (iconPath != KLanSymbolic && iconPath != NoNetSymbolic) {
// lanItem->iconLabel->setProperty("useIconHighlightEffect", 0x10);
// }
lanItem->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
lanItem->titileLabel->setText(infoList.at(0));
lanItem->uuid = infoList.at(1);
lanItem->dbusPath = infoList.at(2);
connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open landetail page
if (!m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call showPropertyWidget" << __LINE__;
m_interface->call(QStringLiteral("showPropertyWidget"), devName, infoList.at(1));
qDebug() << "[NetConnect]call showPropertyWidget respond" << __LINE__;
});
lanItem->isAcitve = isActived;
connect(lanItem, &QPushButton::clicked, this, [=] {
if (lanItem->isAcitve || lanItem->loading) {
deActiveConnect(lanItem->uuid, devName, WIRED_TYPE);
} else {
activeConnect(lanItem->uuid, devName, WIRED_TYPE);
}
});
//记录到deviceFrame的itemMap中
deviceFrameMap[devName]->itemMap.insert(infoList.at(1), lanItem);
qDebug()<<"insert " << infoList.at(1) << " to " << devName << " list";
frame->lanItemLayout->addWidget(lanItem);
}
//增加设备
void NetConnect::addDeviceFrame(QString devName)
{
qDebug() << "[NetConnect]addDeviceFrame " << devName;
qDebug() << "[NetConnect]call getDeviceListAndEnabled" << __LINE__;
QDBusMessage result = m_interface->call(QStringLiteral("getDeviceListAndEnabled"),0);
qDebug() << "[NetConnect]call getDeviceListAndEnabled Respond" << __LINE__;
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "[NetConnect]getWiredDeviceList error:" << result.errorMessage();
return;
}
auto dbusArg = result.arguments().at(0).value<QDBusArgument>();
QMap<QString,bool> map;
dbusArg >> map;
bool enable = true;
if (map.contains(devName)) {
enable = map[devName];
}
ItemFrame *itemFrame = new ItemFrame(devName, pluginWidget);
ui->availableLayout->addWidget(itemFrame);
itemFrame->deviceFrame->deviceLabel->setText(tr("card")+/*QString("%1").arg(count)+*/""+devName);
itemFrame->deviceFrame->deviceSwitch->setChecked(enable);
if (enable) {
itemFrame->lanItemFrame->show();
itemFrame->deviceFrame->dropDownLabel->show();
} else {
itemFrame->lanItemFrame->hide();
itemFrame->deviceFrame->dropDownLabel->hide();
itemFrame->deviceFrame->dropDownLabel->setDropDownStatus(false);
}
deviceFrameMap.insert(devName, itemFrame);
qDebug() << "[NetConnect]deviceFrameMap insert" << devName;
connect(itemFrame->deviceFrame, &DeviceFrame::deviceSwitchClicked ,this, [=] (bool checked) {
qDebug() << "[NetConnect]call setDeviceEnable" << devName << checked << __LINE__;
m_interface->call(QStringLiteral("setDeviceEnable"), devName, checked);
qDebug() << "[NetConnect]call setDeviceEnable Respond" << __LINE__;
});
connect(itemFrame->deviceFrame->deviceSwitch, &KSwitchButton::stateChanged, this, [=] (bool checked) {
if (checked) {
qDebug() << "[NetConnect]set " << devName << "status" << true;
itemFrame->lanItemFrame->show();
itemFrame->deviceFrame->dropDownLabel->show();
itemFrame->deviceFrame->dropDownLabel->setDropDownStatus(true);
deviceStatusMap[devName] = true;
} else {
qDebug() << "[NetConnect]set " << devName << "status" << false;
itemFrame->lanItemFrame->hide();
itemFrame->deviceFrame->dropDownLabel->hide();
deviceStatusMap[devName] = false;
}
});
connect(itemFrame->addLanWidget, &AddNetBtn::clicked, this, [=](){
if (m_interface->isValid()) {
qDebug() << "[NetConnect]call showCreateWiredConnectWidget" << devName << __LINE__;
m_interface->call(QStringLiteral("showCreateWiredConnectWidget"), devName);
qDebug() << "[NetConnect]call setDeviceEnable Respond" << __LINE__;
}
});
}
//减少设备
void NetConnect::removeDeviceFrame(QString devName)
{
qDebug() << "[NetConnect]removeDeviceFrame " << devName;
if (deviceFrameMap.contains(devName)) {
ItemFrame *item = deviceFrameMap[devName];
if (item->lanItemFrame->layout() != NULL) {
QLayoutItem* layoutItem;
while ((layoutItem = item->lanItemFrame->layout()->takeAt(0)) != NULL) {
delete layoutItem->widget();
delete layoutItem;
layoutItem = nullptr;
}
item->itemMap.clear();
}
delete item;
item = nullptr;
deviceFrameMap.remove(devName);
qDebug() << "[NetConnect]deviceFrameMap remove" << devName;
}
}
//device add or remove=================================
void NetConnect::onDeviceStatusChanged()
{
qDebug()<<"[NetConnect]onDeviceStatusChanged";
QEventLoop eventloop;
QTimer::singleShot(300, &eventloop, SLOT(quit()));
eventloop.exec();
QStringList list;
QMap<QString, bool> map;
getDeviceStatusMap(map);
list = map.keys();
QStringList removeList;
QMap<QString, bool> addMap;
//remove的设备
for (int i = 0; i< deviceStatusMap.keys().size(); ++i) {
if (!list.contains(deviceStatusMap.keys().at(i))) {
qDebug() << "[NetConnect]onDeviceStatusChanged " << deviceStatusMap.keys().at(i) << "was removed";
removeList << deviceStatusMap.keys().at(i);
}
}
//add的设备
for (int i = 0; i< list.size(); ++i) {
if (!deviceStatusMap.keys().contains(list.at(i))) {
qDebug() << "[NetConnect]onDeviceStatusChanged " << list.at(i) << "was add, init status" << map[list.at(i)];
addMap.insert(list.at(i),map[list.at(i)]);
}
}
for (int i = 0; i < removeList.size(); ++i) {
removeDeviceFrame(removeList.at(i));
}
QStringList addList = addMap.keys();
for (int i = 0; i < addList.size(); ++i) {
qDebug() << "add a device " << addList.at(i) << "status" << map[addList.at(i)];
addDeviceFrame(addList.at(i));
initNetListFromDevice(addList.at(i));
}
deviceStatusMap = map;
if (deviceStatusMap.isEmpty()) {
wiredSwitch->setChecked(false);
wiredSwitch->setCheckable(false);
} else {
wiredSwitch->setCheckable(true);
setSwitchStatus();
}
QMap<QString, ItemFrame *>::iterator iter;
for (iter = deviceFrameMap.begin(); iter != deviceFrameMap.end(); iter++) {
if (deviceStatusMap.contains(iter.key())) {
if (iter.value()->deviceFrame->deviceSwitch->isChecked() != deviceStatusMap[iter.key()]) {
iter.value()->deviceFrame->deviceSwitch->setChecked(deviceStatusMap[iter.key()]);
}
}
}
}
void NetConnect::onDeviceNameChanged(QString oldName, QString newName, int type)
{
if (WIRED_TYPE != type || !deviceFrameMap.contains(oldName) || !deviceStatusMap.contains(oldName)) {
qDebug() << "[NetConnect]onDeviceNameChanged no such device " << oldName;
return;
}
if (deviceFrameMap.contains(newName) && deviceStatusMap.contains(newName)) {
qDebug() << "[NetConnect]onDeviceNameChanged already has device " << newName;
return;
}
qDebug() << "[NetConnect]onDeviceNameChanged " << oldName << "change to" << newName;
//shan chu chong jian
removeDeviceFrame(oldName);
removeDeviceFrame(newName);
getDeviceStatusMap(deviceStatusMap);
if (deviceStatusMap.contains(newName)) {
addDeviceFrame(newName);
initNetListFromDevice(newName);
}
}
//wifi add===============================================================
void NetConnect::onLanAdd(QString deviceName, QStringList lanInfo)
{
qDebug()<<"[NetConnect]onLanAdd "<< deviceName << " " << lanInfo;
if (!deviceName.isEmpty() && !deviceStatusMap.contains(deviceName)) {
return;
}
QMap<QString, ItemFrame *>::iterator iter;
for (iter = deviceFrameMap.begin(); iter != deviceFrameMap.end(); iter++) {
if (deviceName.isEmpty()) {
qDebug() << "[NetConnect]onLanAdd every list" << iter.key();
addOneLanFrame(iter.value(), iter.key(), lanInfo);
} else if (deviceName == iter.key()) {
qDebug() << "[NetConnect]onLanAdd "<< deviceName;
addOneLanFrame(iter.value(), deviceName, lanInfo);
break;
}
}
}
//wifi remove =============================================================
void NetConnect::onLanRemove(QString lanPath)
{
//开关已关闭 忽略
// if (!wifiSwtch->isChecked()) {
// qDebug() << "[NetConnect]recieve network remove,but wireless switch is off";
// return;
// }
qDebug()<<"[NetConnect]lan remove " << "dbus path:" << lanPath;
QMap<QString, ItemFrame *>::iterator iter;
for (iter = deviceFrameMap.begin(); iter != deviceFrameMap.end(); iter++) {
QMap<QString, LanItem *>::iterator itemIter;
for (itemIter = iter.value()->itemMap.begin(); itemIter != iter.value()->itemMap.end(); itemIter++) {
if (itemIter.value()->dbusPath == lanPath) {
qDebug()<<"[NetConnect]lan remove " << lanPath << " find in " << itemIter.value()->titileLabel->text();
QString key = itemIter.key();
iter.value()->lanItemLayout->removeWidget(itemIter.value());
delete itemIter.value();
iter.value()->itemMap.remove(key);
break;
}
}
}
}
//增加一项
void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringList infoList)
{
if (nullptr == frame) {
return;
}
if (frame->itemMap.contains(infoList.at(1))) {
qDebug() << "[NetConnect]Already exist a lan " << infoList.at(1) << " in " << deviceName;
return;
}
qDebug() << "[NetConnect]addOneLanFrame" << deviceName << infoList.at(0);
QString connName = infoList.at(0);
QString connUuid = infoList.at(1);
QString connDbusPath = infoList.at(2);
LanItem * lanItem = new LanItem(pluginWidget);
QString iconPath;
iconPath = KLanSymbolic;
lanItem->statusLabel->setText("");
QIcon searchIcon = QIcon::fromTheme(iconPath);
// if (iconPath != KLanSymbolic && iconPath != NoNetSymbolic) {
// lanItem->iconLabel->setProperty("useIconHighlightEffect", 0x10);
// }
lanItem->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
lanItem->titileLabel->setText(connName);
lanItem->uuid = connUuid;
lanItem->dbusPath = connDbusPath;
connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open landetail page
if (!m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call showPropertyWidget" << deviceName << connUuid << __LINE__;
m_interface->call(QStringLiteral("showPropertyWidget"), deviceName, connUuid);
qDebug() << "[NetConnect]call showPropertyWidget respond" << __LINE__;
});
lanItem->isAcitve = false;
connect(lanItem, &QPushButton::clicked, this, [=] {
if (lanItem->isAcitve || lanItem->loading) {
deActiveConnect(lanItem->uuid, deviceName, WIRED_TYPE);
} else {
activeConnect(lanItem->uuid, deviceName, WIRED_TYPE);
}
});
//记录到deviceFrame的itemMap中
deviceFrameMap[deviceName]->itemMap.insert(connUuid, lanItem);
int index = getInsertPos(connName, deviceName);
qDebug()<<"[NetConnect]addOneLanFrame " << connName << " to " << deviceName << " list at pos:" << index;
frame->lanItemLayout->insertWidget(index, lanItem);
}
void NetConnect::removeOneLanFrame(ItemFrame *frame, QString deviceName, QString uuid)
{
if (nullptr == frame) {
return;
}
if (!frame->itemMap.contains(uuid)) {
qDebug() << "[NetConnect]not exist a lan " << uuid << " in " << deviceName;
return;
}
qDebug()<<"[NetConnect]removeOneLanFrame " << uuid << " find in " << deviceName;
frame->lanItemLayout->removeWidget(frame->itemMap[uuid]);
delete frame->itemMap[uuid];
frame->itemMap.remove(uuid);
}
//activeconnect status change
void NetConnect::onActiveConnectionChanged(QString deviceName, QString uuid, int status)
{
if (uuid.isEmpty()) {
qDebug() << "[NetConnect]onActiveConnectionChanged but uuid is empty";
return;
}
qDebug() << "[NetConnect]onActiveConnectionChanged " << deviceName << uuid << status;
LanItem * item= nullptr;
if (deviceName.isEmpty()) {
if (status != DEACTIVATED) {
return;
}
//断开时 设备为空 说明此有线未指定设备 添加到所有列表中
QStringList infoList;
QMap<QString, ItemFrame *>::iterator iters;
for (iters = deviceFrameMap.begin(); iters != deviceFrameMap.end(); iters++) {
if (iters.value()->itemMap.contains(uuid)) {
item = iters.value()->itemMap[uuid];
infoList << item->titileLabel->text() << item->uuid << item->dbusPath;
//为断开则重新插入
int index = getInsertPos(item->titileLabel->text(), iters.key());
qDebug() << "[NetConnect]reinsert" << item->titileLabel->text() << "pos" << index << "in" << iters.key() << "because status changes to deactive";
deviceFrameMap[iters.key()]->lanItemLayout->removeWidget(item);
deviceFrameMap[iters.key()]->lanItemLayout->insertWidget(index,item);
itemActiveConnectionStatusChanged(item, status);
}
}
//添加到所有列表中
if (!infoList.isEmpty()) {
QMap<QString, ItemFrame *>::iterator iter;
for (iter = deviceFrameMap.begin(); iter != deviceFrameMap.end(); iter++) {
if (!iter.value()->itemMap.contains(uuid)) {
addOneLanFrame(iter.value(), iter.key(), infoList);
}
}
}
} else {
if (deviceFrameMap.contains(deviceName)) {
if (deviceFrameMap[deviceName]->itemMap.contains(uuid)) {
item = deviceFrameMap[deviceName]->itemMap[uuid];
if (status == ACTIVATED) {
//为已连接则放到第一个
deviceFrameMap[deviceName]->lanItemLayout->removeWidget(item);
deviceFrameMap[deviceName]->lanItemLayout->insertWidget(0,item);
} else if (status == DEACTIVATED) {
//为断开则重新插入
int index = getInsertPos(item->titileLabel->text(), deviceName);
qDebug() << "[NetConnect]reinsert" << item->titileLabel->text() << "pos" << index << "in" << deviceName << "because status changes to deactive";
deviceFrameMap[deviceName]->lanItemLayout->removeWidget(item);
deviceFrameMap[deviceName]->lanItemLayout->insertWidget(index,item);
}
itemActiveConnectionStatusChanged(item, status);
}
} else {
if (status == ACTIVATED || status == DEACTIVATED) {
//虚拟网卡处理
QMap<QString, ItemFrame *>::iterator iters;
for (iters = deviceFrameMap.begin(); iters != deviceFrameMap.end(); iters++) {
if (iters.value()->itemMap.contains(uuid)) {
removeOneLanFrame(iters.value(), iters.key(), uuid);
}
}
}
}
}
}
void NetConnect::itemActiveConnectionStatusChanged(LanItem *item, int status)
{
// QString iconPath = NoNetSymbolic;
if (status == ACTIVATING) {
item->startLoading();
} else if (status == ACTIVATED) {
item->stopLoading();
// iconPath = KLanSymbolic;
item->statusLabel->clear();
item->statusLabel->setMinimumSize(36,36);
item->statusLabel->setMaximumSize(16777215,16777215);
item->statusLabel->setText(tr("connected"));
item->isAcitve = true;
} else if (status == DEACTIVATING) {
item->startLoading();
} else {
item->stopLoading();
item->statusLabel->setMinimumSize(36,36);
item->statusLabel->setMaximumSize(16777215,16777215);
item->statusLabel->clear();
item->isAcitve = false;
}
// QIcon searchIcon = QIcon::fromTheme(iconPath);
// item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(24, 24))));
}
int NetConnect::getInsertPos(QString connName, QString deviceName)
{
qDebug() << "[NetConnect]getInsertPos" << connName << deviceName;
int index = 0;
if(!m_interface->isValid()) {
index = 0;
} else {
qDebug() << "[NetConnect]call getWiredList" << __LINE__;
QDBusMessage result = m_interface->call(QStringLiteral("getWiredList"));
qDebug() << "[NetConnect]call getWiredList respond" << __LINE__;
if(result.type() == QDBusMessage::ErrorMessage)
{
qWarning() << "getWiredList error:" << result.errorMessage();
return 0;
}
auto dbusArg = result.arguments().at(0).value<QDBusArgument>();
QMap<QString, QVector<QStringList>> variantList;
dbusArg >> variantList;
if (!variantList.contains(deviceName)) {
qDebug() << "[NetConnect] getInsertPos but " << deviceName << "not exist";
return 0;
}
for (int i = 0; i < variantList[deviceName].size(); ++i ) {
if (variantList[deviceName].at(i).at(0) == connName) {
qDebug() << "pos in kylin-nm is " << i;
index = i;
break;
}
}
if (variantList[deviceName].at(0).size() == 1) {
index--;
}
}
return index;
}

View File

@ -0,0 +1,159 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef NETCONNECT_H
#define NETCONNECT_H
#include <QObject>
#include <QtPlugin>
#include <QTranslator>
#include <QApplication>
#include <QNetworkInterface>
#include <QtNetwork/QNetworkConfigurationManager>
#include <QtNetwork/QtNetwork>
#include <QTimer>
#include <QStringList>
#include <QString>
#include <QGSettings>
#include <QListWidget>
#include <QListWidgetItem>
#include <QMap>
#include <QPropertyAnimation>
#include <QPoint>
#include <QDBusMessage>
#include <QDBusObjectPath>
#include <QDBusInterface>
#include <QDBusReply>
#include "interface.h"
#include "addbtn.h"
#include "fixlabel.h"
#include "hoverbtn.h"
#include "lanitem.h"
#include "deviceframe.h"
#include "itemframe.h"
#include "kwidget.h"
#include "kswitchbutton.h"
using namespace kdk;
enum {
DISCONNECTED,
NOINTERNET,
CONNECTED
};
namespace Ui {
class NetConnect;
}
class NetConnect : public QObject, CommonInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
Q_INTERFACES(CommonInterface)
public:
NetConnect();
~NetConnect();
QString plugini18nName() Q_DECL_OVERRIDE;
int pluginTypes() Q_DECL_OVERRIDE;
QWidget * pluginUi() Q_DECL_OVERRIDE;
const QString name() const Q_DECL_OVERRIDE;
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
QIcon icon() const Q_DECL_OVERRIDE;
bool isEnable() const Q_DECL_OVERRIDE;
QString translationPath() const Q_DECL_OVERRIDE;
private:
void initSearchText();
void initComponent();
void runExternalApp();
void showDesktopNotify(const QString &message);
//开关相关
void setSwitchStatus();
void hideLayout(QVBoxLayout * layout);
void showLayout(QVBoxLayout * layout);
int getInsertPos(QString connName, QString deviceName);
void deleteOneLan(QString ssid);
void activeConnect(QString ssid, QString deviceName, int type);
void deActiveConnect(QString ssid, QString deviceName, int type);
//获取设备列表
void getDeviceStatusMap(QMap<QString, bool> &map);
void initNet();
void initNetListFromDevice(QString deviceName);
//处理列表增加
void addLanItem(ItemFrame *frame, QString devName, QStringList infoList, bool isActived);
//增加设备
void addDeviceFrame(QString devName);
//减少设备
void removeDeviceFrame(QString devName);
//增加一项
void addOneLanFrame(ItemFrame *frame, QString devName, QStringList infoList);
//减少一项
void removeOneLanFrame(ItemFrame *frame, QString deviceName, QString uuid);
//单个lan连接状态变化
void itemActiveConnectionStatusChanged(LanItem *item, int status);
protected:
bool eventFilter(QObject *w,QEvent *e);
private:
Ui::NetConnect *ui;
QString pluginName;
int pluginType;
QWidget *pluginWidget;
QDBusInterface *m_interface = nullptr;
KSwitchButton *wiredSwitch;
bool mFirstLoad;
QGSettings *m_switchGsettings;
QMap<QString, bool> deviceStatusMap;
QMap<QString, ItemFrame *> deviceFrameMap;
private slots:
void updateLanInfo(QString deviceName, QStringList lanInfo);
void onLanAdd(QString deviceName, QStringList lanInfo);
void onLanRemove(QString dbusPath);
void onActiveConnectionChanged(QString deviceName, QString uuid, int status);
void onDeviceStatusChanged();
void onDeviceNameChanged(QString, QString, int);
};
Q_DECLARE_METATYPE(QList<QDBusObjectPath>);
#endif // NETCONNECT_H

View File

@ -0,0 +1,54 @@
QT += widgets network dbus gui core
TEMPLATE = lib
CONFIG += plugin
include(../component/drownlabel.pri)
include(../component/addbtn.pri)
TARGET = $$qtLibraryTarget(netconnect)
DESTDIR = ../..
target.path = $$[QT_INSTALL_LIBS]/ukui-control-center
trans.files = translations/*
trans.path = /usr/share/kylin-nm/netconnect/
INCLUDEPATH += \
$$PROJECT_COMPONENTSOURCE \
$$PROJECT_ROOTDIR \
/usr/include/ukcc/interface \
/usr/include/ukcc/widgets
LIBS += -L$$[QT_INSTALL_LIBS] -lgsettings-qt -lukcc
CONFIG += c++11 \
link_pkgconfig \
PKGCONFIG += gsettings-qt \
kysdk-qtwidgets \
#DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
deviceframe.cpp \
# drownlabel.cpp \
itemframe.cpp \
lanitem.cpp \
netconnect.cpp
HEADERS += \
deviceframe.h \
# drownlabel.h \
itemframe.h \
lanitem.h \
netconnect.h
FORMS += \
netconnect.ui
INSTALLS += target \
trans
TRANSLATIONS += \
translations/zh_CN.ts \
translations/tr.ts \
translations/bo.ts \
translations/bo_CN.ts

View File

@ -0,0 +1,244 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NetConnect</class>
<widget class="QWidget" name="NetConnect">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>885</width>
<height>700</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">NetConnect</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="TitleLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Wired Network</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="detailLayOut">
<property name="spacing">
<number>1</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="openWifiFrame">
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>18</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="openWIifLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="openLabel">
<property name="minimumSize">
<size>
<width>118</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>open</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>523</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>1</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="availableLayout">
<property name="spacing">
<number>1</number>
</property>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="detailBtn">
<property name="minimumSize">
<size>
<width>120</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>36</height>
</size>
</property>
<property name="text">
<string>Advanced settings</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>TitleLabel</class>
<extends>QLabel</extends>
<header>titlelabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>AddNetBtn</name>
<message>
<location filename="../addnetbtn.cpp" line="22"/>
<source>Add WiredNetork</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NetConnect</name>
<message>
<location filename="../netconnect.ui" line="50"/>
<location filename="../netconnect.cpp" line="152"/>
<source>Wired Network</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.ui" line="112"/>
<location filename="../netconnect.cpp" line="154"/>
<source>open</source>
<translation type="unfinished"></translation>
<extra-contents_path>/netconnect/open</extra-contents_path>
</message>
<message>
<location filename="../netconnect.ui" line="198"/>
<location filename="../netconnect.cpp" line="151"/>
<source>Advanced settings</source>
<translation type="unfinished"></translation>
<extra-contents_path>/netconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../netconnect.cpp" line="63"/>
<source>ukui control center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="66"/>
<source>ukui control center desktop message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="80"/>
<source>WiredConnect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="177"/>
<source>No ethernet device avaliable</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="426"/>
<location filename="../netconnect.cpp" line="833"/>
<source>connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="490"/>
<source>card</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="bo_CN">
<context>
<name>AddNetBtn</name>
<message>
<location filename="../addnetbtn.cpp" line="22"/>
<source>Add WiredNetork</source>
<translation></translation>
</message>
</context>
<context>
<name>NetConnect</name>
<message>
<location filename="../netconnect.ui" line="50"/>
<location filename="../netconnect.cpp" line="152"/>
<source>Wired Network</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.ui" line="112"/>
<location filename="../netconnect.cpp" line="154"/>
<source>open</source>
<translation></translation>
<extra-contents_path>/netconnect/open</extra-contents_path>
</message>
<message>
<location filename="../netconnect.ui" line="198"/>
<location filename="../netconnect.cpp" line="151"/>
<source>Advanced settings</source>
<translation></translation>
<extra-contents_path>/netconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../netconnect.cpp" line="63"/>
<source>ukui control center</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="66"/>
<source>ukui control center desktop message</source>
<translation>ukui </translation>
</message>
<message>
<location filename="../netconnect.cpp" line="80"/>
<source>WiredConnect</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="177"/>
<source>No ethernet device avaliable</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="426"/>
<location filename="../netconnect.cpp" line="833"/>
<source>connected</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="490"/>
<source>card</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>AddNetBtn</name>
<message>
<location filename="../addnetbtn.cpp" line="22"/>
<source>Add WiredNetork</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NetConnect</name>
<message>
<location filename="../netconnect.ui" line="50"/>
<location filename="../netconnect.cpp" line="152"/>
<source>Wired Network</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.ui" line="112"/>
<location filename="../netconnect.cpp" line="154"/>
<source>open</source>
<translation type="unfinished"></translation>
<extra-contents_path>/netconnect/open</extra-contents_path>
</message>
<message>
<location filename="../netconnect.ui" line="198"/>
<location filename="../netconnect.cpp" line="151"/>
<source>Advanced settings</source>
<translation type="unfinished"></translation>
<extra-contents_path>/netconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../netconnect.cpp" line="63"/>
<source>ukui control center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="66"/>
<source>ukui control center desktop message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="80"/>
<source>WiredConnect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="177"/>
<source>No ethernet device avaliable</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="426"/>
<location filename="../netconnect.cpp" line="833"/>
<source>connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="490"/>
<source>card</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>AddNetBtn</name>
<message>
<location filename="../addnetbtn.cpp" line="22"/>
<source>Add WiredNetork</source>
<translation>线</translation>
</message>
</context>
<context>
<name>NetConnect</name>
<message>
<location filename="../netconnect.ui" line="50"/>
<location filename="../netconnect.cpp" line="152"/>
<source>Wired Network</source>
<translation>线</translation>
</message>
<message>
<location filename="../netconnect.ui" line="112"/>
<location filename="../netconnect.cpp" line="154"/>
<source>open</source>
<translation></translation>
<extra-contents_path>/netconnect/open</extra-contents_path>
</message>
<message>
<location filename="../netconnect.ui" line="198"/>
<location filename="../netconnect.cpp" line="151"/>
<source>Advanced settings</source>
<translation></translation>
<extra-contents_path>/netconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../netconnect.cpp" line="63"/>
<source>ukui control center</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="66"/>
<source>ukui control center desktop message</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="80"/>
<source>WiredConnect</source>
<translation>线</translation>
</message>
<message>
<location filename="../netconnect.cpp" line="177"/>
<source>No ethernet device avaliable</source>
<translation>线</translation>
</message>
<message>
<location filename="../netconnect.cpp" line="426"/>
<location filename="../netconnect.cpp" line="833"/>
<source>connected</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="490"/>
<source>card</source>
<translation></translation>
</message>
</context>
</TS>

6
plugins/plugin.pro Normal file
View File

@ -0,0 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = \
netconnect \
wlanconnect \
mobilehotspot \
proxy

View File

@ -0,0 +1,138 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "applistwidget.h"
#include <QDebug>
AppListWidget::AppListWidget(QString path, QWidget *parent)
: m_path(path), QWidget(parent)
{
initUI();
initDbus();
}
AppListWidget::~AppListWidget()
{
}
/**
* @brief AppListWidget::setAppChecked
* @param flag 使
*/
void AppListWidget::setAppChecked(bool flag)
{
m_checkBox->setChecked(flag);
}
/**
* @brief AppListWidget::setAppIcon
* @param icon
*/
void AppListWidget::setAppIcon(const QPixmap &icon)
{
m_iconLabel->setAlignment(Qt::AlignCenter);
m_iconLabel->setPixmap(icon);
}
/**
* @brief AppListWidget::setAppName
* @param text
*/
void AppListWidget::setAppName(const QString &text)
{
m_nameLabel->setText(text);
}
/**
* @brief AppListWidget::onAppCheckStateChanged
* checkBox是否选中
*/
void AppListWidget::onAppCheckStateChanged()
{
if (m_checkBox->isChecked()) {
AddAppProxyConfig();
} else {
RemoveAppProxyConfig();
}
}
/**
* @brief AppListWidget::AddAppProxyConfig
*
*/
void AppListWidget::AddAppProxyConfig()
{
if(!m_dbusInterface->isValid()) {
qWarning ()<< "init AppProxy dbus error";
}
qDebug() << "call QDBusInterface addAppIntoProxy";
m_dbusInterface->call("addAppIntoProxy", m_path);
}
/**
* @brief AppListWidget::RemoveAppProxyConfig
*
*/
void AppListWidget::RemoveAppProxyConfig()
{
if(!m_dbusInterface->isValid()) {
qWarning ()<< "init AppProxy dbus error";
}
qDebug() << "call QDBusInterface delAppIntoProxy";
m_dbusInterface->call("delAppIntoProxy", m_path);
}
void AppListWidget::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
m_checkBox->setChecked(!m_checkBox->isChecked());
onAppCheckStateChanged();
}
return QWidget::mousePressEvent(event);
}
void AppListWidget::initUI()
{
QHBoxLayout *mainLayout = new QHBoxLayout(this);
mainLayout->setContentsMargins(17, 0, 17, 0);
mainLayout->setSpacing(8);
m_checkBox = new QCheckBox(this);
m_checkBox->setFixedSize(16, 16);
m_checkBox->setAttribute(Qt::WA_TransparentForMouseEvents, true); //m_checkBox不响应鼠标事件,将其传递给父窗口
m_iconLabel = new QLabel(this);
m_iconLabel->setFixedSize(24, 24);
m_nameLabel = new QLabel(this);
mainLayout->addWidget(m_checkBox);
mainLayout->addSpacing(8);
mainLayout->addWidget(m_iconLabel);
mainLayout->addWidget(m_nameLabel);
mainLayout->addStretch();
}
void AppListWidget::initDbus()
{
m_dbusInterface = new QDBusInterface("org.ukui.SettingsDaemon",
"/org/ukui/SettingsDaemon/AppProxy",
"org.ukui.SettingsDaemon.AppProxy",
QDBusConnection::sessionBus());
}

View File

@ -0,0 +1,60 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef APPLISTWIDGET_H
#define APPLISTWIDGET_H
#include <QObject>
#include <QWidget>
#include <QMouseEvent>
#include <QCheckBox>
#include <QLabel>
#include <QHBoxLayout>
#include <QDBusInterface>
#include <QDBusReply>
class AppListWidget : public QWidget
{
Q_OBJECT
public:
explicit AppListWidget(QString path, QWidget *parent = nullptr);
~AppListWidget();
void setAppChecked(bool flag);
void setAppIcon(const QPixmap &icon);
void setAppName(const QString &text);
void onAppCheckStateChanged();
void AddAppProxyConfig();
void RemoveAppProxyConfig();
protected:
void mousePressEvent(QMouseEvent *event);
private:
void initUI();
void initDbus();
QCheckBox *m_checkBox = nullptr;
QLabel *m_iconLabel = nullptr;
QLabel *m_nameLabel = nullptr;
QString m_path = nullptr;
QDBusInterface *m_dbusInterface = nullptr;
};
#endif // APPLISTWIDGET_H

32
plugins/proxy/aptinfo.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef APTINFO_H
#define APTINFO_H
#include <QHash>
#include <QVariant>
#include <QString>
#include <QDBusArgument>
struct AptInfo
{
QString arg;
QDBusVariant out;
};
QDBusArgument &operator<<(QDBusArgument &argument, const AptInfo &mystruct)
{
argument.beginStructure();
argument << mystruct.arg << mystruct.out;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, AptInfo &mystruct)
{
argument.beginStructure();
argument >> mystruct.arg >> mystruct.out;
argument.endStructure();
return argument;
}
Q_DECLARE_METATYPE(AptInfo)
#endif // APTINFO_H

View File

@ -0,0 +1,127 @@
#include "aptproxydialog.h"
#include <QDebug>
#include <QLineEdit>
#include <QSpacerItem>
#include <QLabel>
#include <QPushButton>
#include "proxy.h"
AptProxyDialog::AptProxyDialog(QWidget *parent ):
QDialog(parent)
{
initUi();
setupComponent();
initConnect();
}
AptProxyDialog::~AptProxyDialog()
{
}
void AptProxyDialog::initUi()
{
setWindowTitle(tr("Set Apt Proxy"));
this->setFixedSize(480, 200);
QVBoxLayout *mAptProxyLyt = new QVBoxLayout(this);
mAptProxyLyt->setContentsMargins(24, 24, 24, 24);
mAptProxyLyt->setSpacing(16);
QFrame *mHostFrame = new QFrame(this);
mHostFrame->setFixedSize(432, 36);
mHostFrame->setFrameShape(QFrame::NoFrame);
QHBoxLayout *mLyt_1= new QHBoxLayout(mHostFrame);
mLyt_1->setContentsMargins(0, 0, 0, 0);
mLyt_1->setSpacing(8);
FixLabel *mSetHostLabel = new FixLabel(mHostFrame);
mSetHostLabel->setFixedSize(92, 36);
mSetHostLabel->setText(tr("Server Address"));
mHostEdit = new QLineEdit(mHostFrame);
mHostEdit->setAttribute(Qt::WA_InputMethodEnabled, false); //限制中文输入法
mHostEdit->setFixedSize(332, 36);
mHostEdit->installEventFilter(this);
mLyt_1->addWidget(mSetHostLabel);
mLyt_1->addWidget(mHostEdit);
QFrame *mPortFrame = new QFrame(this);
mPortFrame->setFixedSize(432, 36);
mPortFrame->setFrameShape(QFrame::NoFrame);
QHBoxLayout *mLyt_2= new QHBoxLayout(mPortFrame);
mLyt_2->setContentsMargins(0, 0, 0, 0);
mLyt_2->setSpacing(8);
QLabel *mSetPortLabel = new QLabel(tr("Port") ,mPortFrame);
mSetPortLabel->setFixedSize(92, 36);
mPortEdit = new QLineEdit(mPortFrame);
mPortEdit->setAttribute(Qt::WA_InputMethodEnabled, false); //限制中文输入法
mPortEdit->setFixedSize(332, 36);
mPortEdit->installEventFilter(this);
mLyt_2->addWidget(mSetPortLabel);
mLyt_2->addWidget(mPortEdit);
QFrame *mChooseFrame = new QFrame(this);
mChooseFrame->setFixedWidth(432);
mChooseFrame->setFrameShape(QFrame::NoFrame);
QHBoxLayout *mLyt_3= new QHBoxLayout(mChooseFrame);
mLyt_3->setContentsMargins(0, 0, 0, 0);
mLyt_3->setSpacing(16);
mCancelBtn = new QPushButton(mChooseFrame);
mCancelBtn->setMinimumWidth(96);
mCancelBtn->setText(tr("Cancel"));
mConfirmBtn = new QPushButton(mChooseFrame);
mConfirmBtn->setMinimumWidth(96);
mConfirmBtn->setText(tr("Confirm"));
mLyt_3->addStretch();
mLyt_3->addWidget(mCancelBtn);
mLyt_3->addWidget(mConfirmBtn);
mAptProxyLyt->addWidget(mHostFrame);
mAptProxyLyt->addWidget(mPortFrame);
mAptProxyLyt->addSpacing(16);
mAptProxyLyt->addWidget(mChooseFrame);
}
void AptProxyDialog::initConnect()
{
connect(mHostEdit, &QLineEdit::textEdited, this, [=]() {
if (mHostEdit->text().isEmpty()) {
mConfirmBtn->setEnabled(false);
} else {
mConfirmBtn->setEnabled(true);
}
});
connect(mCancelBtn, &QPushButton::clicked, this, [=]() {
this->close();
});
connect(mConfirmBtn, &QPushButton::clicked, this, [=]() {
Proxy::setAptProxy(mHostEdit->text() , mPortEdit->text() , true);
this->close();
});
}
void AptProxyDialog::setupComponent()
{
QString host = Proxy::getAptProxy()["ip"].toString();
QString port = Proxy::getAptProxy()["port"].toString();;
mHostEdit->setText(host);
mPortEdit->setText(port);
if (host.isEmpty()) {
mConfirmBtn->setEnabled(false);
}
}

View File

@ -0,0 +1,38 @@
#ifndef APTPROXYDIALOG_H
#define APTPROXYDIALOG_H
#include <QObject>
#include <QWidget>
#include <QVBoxLayout>
#include <QGSettings>
#include <QLabel>
#include <QLineEdit>
#include <QDialog>
#include "fixlabel.h"
#define APT_PROXY_SCHEMA "org.ukui.control-center.apt.proxy"
#define APT_PROXY_ENABLED "enabled"
#define APT_PROXY_HOST_KEY "host"
#define APT_PROXY_PORT_KEY "port"
class AptProxyDialog : public QDialog
{
Q_OBJECT
public:
AptProxyDialog(QWidget *parent = nullptr);
~AptProxyDialog();
void initUi();
private:
QLineEdit *mHostEdit;
QLineEdit *mPortEdit;
QPushButton *mCancelBtn;
QPushButton *mConfirmBtn;
private:
void initConnect();
void setupComponent();
};
#endif // APTPROXYDIALOG_H

View File

@ -0,0 +1,31 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef CERTIFICATIONDIALOG_H
#define CERTIFICATIONDIALOG_H
#include <QDialog>
#define HTTP_PROXY_SCHEMA "org.gnome.system.proxy.http"
#define HTTP_AUTH_KEY "use-authentication"
#define HTTP_AUTH_USER_KEY "authentication-user"
#define HTTP_AUTH_PASSWD_KEY "authentication-password"
#endif // CERTIFICATIONDIALOG_H

View File

@ -0,0 +1,342 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CertificationDialog</class>
<widget class="QDialog" name="CertificationDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>246</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>246</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>246</height>
</size>
</property>
<property name="windowTitle">
<string>UserCertification</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>20</number>
</property>
<property name="leftMargin">
<number>20</number>
</property>
<property name="topMargin">
<number>25</number>
</property>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="activeHLayout" stretch="0">
<property name="spacing">
<number>10</number>
</property>
<property name="leftMargin">
<number>20</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>UserCertification</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>User:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="userLineEdit">
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>180</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Passwd:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="pwdLineEdit">
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>180</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="closePushBtn">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>80</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

1367
plugins/proxy/proxy.cpp Normal file

File diff suppressed because it is too large Load Diff

285
plugins/proxy/proxy.h Normal file
View File

@ -0,0 +1,285 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef PROXY_H
#define PROXY_H
#include <QObject>
#include <QtPlugin>
#include <QFileSystemWatcher>
#include <QDialog>
#include <QLineEdit>
#include "certificationdialog.h"
#include <QGSettings>
#include <QRadioButton>
#include <QLineEdit>
#include <QCheckBox>
#include <QTextEdit>
#include <QButtonGroup>
#include <QComboBox>
#include <QListWidget>
#include <QFormLayout>
#include <QDBusInterface>
#include <QDBusConnection>
#include <QDBusError>
#include <QDBusReply>
#include <QMessageBox>
#include <QtDBus/QDBusMetaType>
#include "interface.h"
#include "titlelabel.h"
#include "hoverwidget.h"
#include "applistwidget.h"
#include "kswitchbutton.h"
#include "kpasswordedit.h"
using namespace kdk;
/* qt会将glib里的signals成员识别为宏所以取消该宏
* signals时使Q_SIGNALS代替即可
**/
#ifdef signals
#undef signals
#endif
#include <glib.h>
#include <gio/gio.h>
struct GSData
{
QString key;
QString schema;
};
typedef enum{
NONE,
MANUAL,
AUTO
}ProxyMode;
//自定义类型使用QVariant需要使用 Q_DECLARE_METATYPE 注册
Q_DECLARE_METATYPE(ProxyMode)
Q_DECLARE_METATYPE(GSData)
namespace Ui {
class Proxy;
}
class Proxy : public QObject, CommonInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
Q_INTERFACES(CommonInterface)
public:
Proxy();
~Proxy();
QString plugini18nName() Q_DECL_OVERRIDE;
int pluginTypes() Q_DECL_OVERRIDE;
QWidget * pluginUi() Q_DECL_OVERRIDE;
void plugin_leave()Q_DECL_OVERRIDE;
const QString name() const Q_DECL_OVERRIDE;
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
QIcon icon() const Q_DECL_OVERRIDE;
bool isEnable() const Q_DECL_OVERRIDE;
public:
void initUi(QWidget *widget);
void initSearchText();
void retranslateUi();
void setupComponent();
void setupConnect();
void initProxyModeStatus();
void initAutoProxyStatus();
void initManualProxyStatus();
void initIgnoreHostStatus();
void initDbus();
void initAppProxyStatus();
void manualProxyTextChanged(QString txt);
int _getCurrentProxyMode();
void _setSensitivity();
bool getAptProxyInfo(bool status);
static void setAptProxy(QString host ,QString port ,bool status); // apt代理对应的配置文件的写入或删除
static QHash<QString, QVariant> getAptProxy();
void setAptInfo();
void reboot(); // 调用重启接口
void setFrame_Noframe(QFrame *frame);
QFrame *setLine(QFrame *frame);
bool getAppProxyState(); //获取应用代理开启状态--调用Dbus
void setAppProxyState(bool state); //设置应用代理开启状态--调用Dbus
static QStringList getAppProxyConf(); //获取应用代理配置信息--调用Dbus
void setAppProxyConf(QStringList list); //设置应用代理配置信息--调用Dbus
static QMap<QString, QStringList> getAppListProxy();
// bool checkIsChanged(QStringList info);
private:
void setAppProxyFrameUi(QWidget *widget);
void setAppListFrameUi(QWidget *widget);
void appProxyInfoPadding();
void appListPadding();
bool getipEditState(QString text);
QString pluginName;
int pluginType;
QWidget * pluginWidget;
TitleLabel *mTitleLabel;
TitleLabel *m_appProxyLabel;
TitleLabel *mAptProxyLabel;
QLabel *mUrlLabel;
QLabel *mHTTPLabel;
QLabel *mHTTPPortLabel;
QLabel *mHTTPSLabel;
QLabel *mHTTPSPortLabel;
QLabel *mFTPLabel;
QLabel *mFTPPortLabel;
QLabel *mSOCKSLabel;
QLabel *mSOCKSPortLabel;
QLabel *mIgnoreLabel;
QLabel *mAptLabel;
QLabel *mAPTHostLabel_1;
QLabel *mAPTHostLabel_2;
QLabel *mAPTPortLabel_1;
QLabel *mAPTPortLabel_2;
QLabel *mCertificationLabel;
QLabel *mUserNameLabel;
QLabel *mPwdLabel;
QLabel *m_appEnableLabel;
QLabel *m_proxyTypeLabel;
QLabel *m_ipAddressLabel;
QLabel *m_ipHintsLabel;
QLabel *m_portLabel;
QLabel *m_userNameLabel;
QLabel *m_pwdLabel;
QLabel *m_allowAppProxyLabel;
QFrame *mProxyFrame;
QFrame *mEnableFrame;
QFrame *mSelectFrame;
QFrame *mUrlFrame;
QFrame *mHTTPFrame;
QFrame *mHTTPSFrame;
QFrame *mFTPFrame;
QFrame *mSOCKSFrame;
QFrame *mIgnoreFrame;
QFrame *mCertificationFrame_1;
QFrame *m_appEnableFrame;
QFrame *m_appProxyFrame;
QFrame *m_proxyTypeFrame;
QFrame *m_ipAddressFrame;
QFrame *m_portFrame;
QFrame *m_userNameFrame;
QFrame *m_pwdFrame;
// QFrame *m_appBtnFrame;
QFrame *m_appListFrame;
QFrame *mAPTFrame;
QFrame *mAPTFrame_1;
QFrame *mAPTFrame_2;
QFrame *line_1;
QFrame *line_2;
QFrame *line_3;
QFrame *line_4;
QFrame *line_5;
QFrame *line_6;
QFrame *line_7;
QFrame *line_8;
QFrame *m_appLine1;
QFrame *m_appLine2;
QFrame *m_appLine3;
QFrame *m_appLine4;
QFrame *m_appLine5;
QRadioButton *mAutoBtn;
QRadioButton *mManualBtn;
KSwitchButton *mEnableBtn;
KSwitchButton *mAptBtn;
QPushButton *mEditBtn;
QCheckBox *mCertificationBtn;
QButtonGroup *mProxyBtnGroup;
QLineEdit *mUrlLineEdit;
QLineEdit *mHTTPLineEdit_1;
QLineEdit *mHTTPLineEdit_2;
QLineEdit *mHTTPSLineEdit_1;
QLineEdit *mHTTPSLineEdit_2;
QLineEdit *mFTPLineEdit_1;
QLineEdit *mFTPLineEdit_2;
QLineEdit *mSOCKSLineEdit_1;
QLineEdit *mSOCKSLineEdit_2;
QLineEdit *mUserNameLineEdit;
QLineEdit *mPwdLineEdit;
QLineEdit *m_ipAddressLineEdit;
QLineEdit *m_portLineEdit;
QLineEdit *m_userNameLineEdit;
KSwitchButton *m_appEnableBtn;
QComboBox *m_proxyTypeComboBox;
KPasswordEdit *m_pwdLineEdit = nullptr;
// QPushButton *m_cancelBtn;
// QPushButton *m_saveBtn;
QListWidget *m_appListWidget = nullptr;
QTextEdit *mIgnoreLineEdit;
QGSettings * proxysettings;
QGSettings * httpsettings;
QGSettings * securesettings;
QGSettings * ftpsettings;
QGSettings * sockssettings;
QGSettings * aptsettings;
QFileSystemWatcher *mfileWatch_1;
QFileSystemWatcher *mfileWatch_2;
QDBusInterface *mAptproxyDbus;
QDBusInterface *m_appProxyDbus;
bool isExistSettings = false;
bool settingsCreate;
bool mFirstLoad;
QStringList m_appProxyInfo;
QStringList m_appCheckedList;
private slots:
void setAptProxySlot(); //处理apt代理前端交互逻辑
void onappProxyEnableChanged(bool enable); //IP地址无效提示
void onipEditStateChanged(); //IP地址无效提示
void onAppProxyConfChanged(); //应用代理配置信息变化
void onAppProxyConfEditFinished();
// void onCancelBtnClicked();
// void onSaveBtnClicked();
// void setBtnEnable();
};
#endif // PROXY_H

52
plugins/proxy/proxy.pro Normal file
View File

@ -0,0 +1,52 @@
#include(../../../env.pri)
QT += widgets dbus
TEMPLATE = lib
CONFIG += plugin
TARGET = $$qtLibraryTarget(proxy)
DESTDIR = ../..
target.path = $$[QT_INSTALL_LIBS]/ukui-control-center
trans.files = translations/*
trans.path = /usr/share/kylin-nm/proxy/
INCLUDEPATH += \
$$PROJECT_COMPONENTSOURCE \
$$PROJECT_ROOTDIR \
/usr/include/ukcc/interface \
/usr/include/ukcc/widgets
LIBS += -L$$[QT_INSTALL_LIBS] -lgsettings-qt -lukcc
##加载gio库和gio-unix库用于获取和设置enum类型的gsettings
CONFIG += link_pkgconfig \
C++11
PKGCONFIG += gio-2.0 \
gio-unix-2.0 \
gsettings-qt \
kysdk-qtwidgets
#DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
applistwidget.cpp \
aptproxydialog.cpp \
proxy.cpp
HEADERS += \
applistwidget.h \
aptinfo.h \
aptproxydialog.h \
proxy.h \
certificationdialog.h
FORMS +=
INSTALLS += target \
trans
TRANSLATIONS += \
translations/zh_CN.ts \
translations/tr.ts \
translations/bo_CN.ts

Binary file not shown.

View File

@ -0,0 +1,227 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="bo_CN">
<context>
<name>AptProxyDialog</name>
<message>
<location filename="../aptproxydialog.cpp" line="24"/>
<source>Set Apt Proxy</source>
<translation>Apt </translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="41"/>
<source>Server Address</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="59"/>
<source>Port</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="80"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="84"/>
<source>Confirm</source>
<translation></translation>
</message>
</context>
<context>
<name>Proxy</name>
<message>
<location filename="../proxy.cpp" line="63"/>
<source>Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="194"/>
<source>Start using</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="207"/>
<source>Proxy mode</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="211"/>
<source>Auto</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="214"/>
<source>Manual</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="369"/>
<source>Application Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="444"/>
<source>System Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="446"/>
<source>Auto url</source>
<translation></translation>
<extra-contents_path>/Proxy/Auto url</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="448"/>
<source>Http Proxy</source>
<translation>HTTP </translation>
<extra-contents_path>/Proxy/Http Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="450"/>
<source>Https Proxy</source>
<translation>HTTPS </translation>
<extra-contents_path>/Proxy/Https Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="452"/>
<source>Ftp Proxy</source>
<translation>FTP </translation>
<extra-contents_path>/Proxy/Ftp Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="454"/>
<source>Socks Proxy</source>
<translation>SOCKS </translation>
<extra-contents_path>/Proxy/Socks Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="455"/>
<location filename="../proxy.cpp" line="456"/>
<location filename="../proxy.cpp" line="457"/>
<location filename="../proxy.cpp" line="458"/>
<location filename="../proxy.cpp" line="1047"/>
<source>Port</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="459"/>
<source>List of ignored hosts. more than one entry, please separate with english semicolon(;)</source>
<translation> (;)</translation>
</message>
<message>
<location filename="../proxy.cpp" line="462"/>
<source>Apt Proxy</source>
<translation>APT </translation>
<extra-contents_path>/Proxy/Apt Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="463"/>
<location filename="../proxy.cpp" line="984"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="464"/>
<source>Server Address : </source>
<translation> </translation>
</message>
<message>
<location filename="../proxy.cpp" line="465"/>
<source>Port : </source>
<translation> </translation>
</message>
<message>
<location filename="../proxy.cpp" line="466"/>
<source>Edit</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="564"/>
<source>The apt proxy has been turned off and needs to be restarted to take effect</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="565"/>
<location filename="../proxy.cpp" line="797"/>
<source>Reboot Later</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="566"/>
<location filename="../proxy.cpp" line="798"/>
<source>Reboot Now</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="796"/>
<source>The system needs to be restarted to set the Apt proxy, whether to reboot</source>
<translation>Aptཡི </translation>
</message>
<message>
<location filename="../proxy.cpp" line="996"/>
<source>Proxy type</source>
<translation></translation>
</message>
<message>
<source>HTTP</source>
<translation type="vanished">HTTP</translation>
</message>
<message>
<source>socks4</source>
<translation type="vanished">4</translation>
</message>
<message>
<source>socks5</source>
<translation type="vanished">5</translation>
</message>
<message>
<location filename="../proxy.cpp" line="1013"/>
<source>IP address</source>
<translation>IPས</translation>
</message>
<message>
<location filename="../proxy.cpp" line="1019"/>
<location filename="../proxy.cpp" line="1050"/>
<source>Required</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1040"/>
<source>Invalid IP Address</source>
<translation>IPས</translation>
</message>
<message>
<location filename="../proxy.cpp" line="1061"/>
<source>Username</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1064"/>
<location filename="../proxy.cpp" line="1078"/>
<source>Optional</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1074"/>
<source>Password</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1097"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1098"/>
<source>Save</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1160"/>
<source>The following applications are allowed to use this configuration:</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,215 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>AptProxyDialog</name>
<message>
<location filename="../aptproxydialog.cpp" line="24"/>
<source>Set Apt Proxy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="41"/>
<source>Server Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="59"/>
<source>Port</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="80"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="84"/>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Proxy</name>
<message>
<location filename="../proxy.cpp" line="63"/>
<source>Proxy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="194"/>
<source>Start using</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="207"/>
<source>Proxy mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="211"/>
<source>Auto</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="214"/>
<source>Manual</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="369"/>
<source>Application Proxy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="444"/>
<source>System Proxy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="446"/>
<source>Auto url</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Auto url</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="448"/>
<source>Http Proxy</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Http Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="450"/>
<source>Https Proxy</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Https Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="452"/>
<source>Ftp Proxy</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Ftp Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="454"/>
<source>Socks Proxy</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Socks Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="455"/>
<location filename="../proxy.cpp" line="456"/>
<location filename="../proxy.cpp" line="457"/>
<location filename="../proxy.cpp" line="458"/>
<location filename="../proxy.cpp" line="1047"/>
<source>Port</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="459"/>
<source>List of ignored hosts. more than one entry, please separate with english semicolon(;)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="462"/>
<source>Apt Proxy</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Apt Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="463"/>
<location filename="../proxy.cpp" line="984"/>
<source>Open</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="464"/>
<source>Server Address : </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="465"/>
<source>Port : </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="466"/>
<source>Edit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="564"/>
<source>The apt proxy has been turned off and needs to be restarted to take effect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="565"/>
<location filename="../proxy.cpp" line="797"/>
<source>Reboot Later</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="566"/>
<location filename="../proxy.cpp" line="798"/>
<source>Reboot Now</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="796"/>
<source>The system needs to be restarted to set the Apt proxy, whether to reboot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="996"/>
<source>Proxy type</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1013"/>
<source>IP address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1019"/>
<location filename="../proxy.cpp" line="1050"/>
<source>Required</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1040"/>
<source>Invalid IP Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1061"/>
<source>Username</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1064"/>
<location filename="../proxy.cpp" line="1078"/>
<source>Optional</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1074"/>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1097"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1098"/>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1160"/>
<source>The following applications are allowed to use this configuration:</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,215 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>AptProxyDialog</name>
<message>
<location filename="../aptproxydialog.cpp" line="24"/>
<source>Set Apt Proxy</source>
<translation>APT代理</translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="41"/>
<source>Server Address</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="59"/>
<source>Port</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="80"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="84"/>
<source>Confirm</source>
<translation></translation>
</message>
</context>
<context>
<name>Proxy</name>
<message>
<location filename="../proxy.cpp" line="63"/>
<source>Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="194"/>
<source>Start using</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="207"/>
<source>Proxy mode</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="211"/>
<source>Auto</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="214"/>
<source>Manual</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="369"/>
<source>Application Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="444"/>
<source>System Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="446"/>
<source>Auto url</source>
<translation>URL</translation>
<extra-contents_path>/Proxy/Auto url</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="448"/>
<source>Http Proxy</source>
<translation>HTTP代理</translation>
<extra-contents_path>/Proxy/Http Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="450"/>
<source>Https Proxy</source>
<translation>HTTPS代理</translation>
<extra-contents_path>/Proxy/Https Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="452"/>
<source>Ftp Proxy</source>
<translation>FTP代理</translation>
<extra-contents_path>/Proxy/Ftp Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="454"/>
<source>Socks Proxy</source>
<translation>SOCKS代理</translation>
<extra-contents_path>/Proxy/Socks Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="455"/>
<location filename="../proxy.cpp" line="456"/>
<location filename="../proxy.cpp" line="457"/>
<location filename="../proxy.cpp" line="458"/>
<location filename="../proxy.cpp" line="1047"/>
<source>Port</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="459"/>
<source>List of ignored hosts. more than one entry, please separate with english semicolon(;)</source>
<translation>使;</translation>
</message>
<message>
<location filename="../proxy.cpp" line="462"/>
<source>Apt Proxy</source>
<translation>APT代理</translation>
<extra-contents_path>/Proxy/Apt Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="463"/>
<location filename="../proxy.cpp" line="984"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="464"/>
<source>Server Address : </source>
<translation> </translation>
</message>
<message>
<location filename="../proxy.cpp" line="465"/>
<source>Port : </source>
<translation> </translation>
</message>
<message>
<location filename="../proxy.cpp" line="466"/>
<source>Edit</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="564"/>
<source>The apt proxy has been turned off and needs to be restarted to take effect</source>
<translation>APT代理已关闭</translation>
</message>
<message>
<location filename="../proxy.cpp" line="565"/>
<location filename="../proxy.cpp" line="797"/>
<source>Reboot Later</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="566"/>
<location filename="../proxy.cpp" line="798"/>
<source>Reboot Now</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="796"/>
<source>The system needs to be restarted to set the Apt proxy, whether to reboot</source>
<translation>APT代理需要重启系统后生效</translation>
</message>
<message>
<location filename="../proxy.cpp" line="996"/>
<source>Proxy type</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1013"/>
<source>IP address</source>
<translation>IP地址</translation>
</message>
<message>
<location filename="../proxy.cpp" line="1019"/>
<location filename="../proxy.cpp" line="1050"/>
<source>Required</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1040"/>
<source>Invalid IP Address</source>
<translation>IP地址</translation>
</message>
<message>
<location filename="../proxy.cpp" line="1061"/>
<source>Username</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1064"/>
<location filename="../proxy.cpp" line="1078"/>
<source>Optional</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1074"/>
<source>Password</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1097"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1098"/>
<source>Save</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1160"/>
<source>The following applications are allowed to use this configuration:</source>
<translation>使</translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,67 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "deviceframe.h"
#include <QPainter>
#define LAYOUT_MARGINS 18,0,8,0
#define FRAME_HEIGHT 58
#define LAYOUT_SPACING 16
#define RADIUS 6.0
DeviceFrame::DeviceFrame(QString devName, QWidget *parent) : QFrame(parent)
{
this->setFrameShape(QFrame::Box);
this->setFixedHeight(FRAME_HEIGHT);
QHBoxLayout *deviceLayout = new QHBoxLayout(this);
deviceLayout->setContentsMargins(LAYOUT_MARGINS);
setLayout(deviceLayout);
deviceLayout->setSpacing(LAYOUT_SPACING);
deviceLabel = new QLabel(this);
dropDownLabel = new DrownLabel(devName, this);
deviceLayout->addWidget(deviceLabel);
deviceLayout->addStretch();
deviceLayout->addWidget(dropDownLabel);
}
DeviceFrame::~DeviceFrame()
{
}
void DeviceFrame::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
painter.setBrush(pal.color(QPalette::Base));
QRect rect = this->rect();
QPainterPath path;
path.addRoundedRect (rect, RADIUS, RADIUS);
QRect temp_rect(rect.left(), rect.top() + rect.height()/2, rect.width(), rect.height()/2);
path.addRect(temp_rect);
painter.drawPath(path);
QFrame::paintEvent(event);
}

View File

@ -0,0 +1,49 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef DEVICEFRAME_H
#define DEVICEFRAME_H
#include <QObject>
#include <QWidget>
#include <QPushButton>
#include <QHBoxLayout>
#include <QLabel>
#include <QDebug>
#include "../component/DrownLabel/drownlabel.h"
class DeviceFrame : public QFrame
{
public:
DeviceFrame(QString devName, QWidget *parent = nullptr);
~DeviceFrame();
public:
//仅设备名称+下拉label
QLabel * deviceLabel = nullptr;
DrownLabel *dropDownLabel = nullptr;
protected:
void paintEvent(QPaintEvent *event);
private:
int frameSize;
};
#endif // DEVICEFRAME_H

View File

@ -0,0 +1,82 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "itemframe.h"
#include <QPainter>
#define LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_MARGINS 0,0,0,0
ItemFrame::ItemFrame(QString devName, QWidget *parent)
{
deviceLanLayout = new QVBoxLayout(this);
deviceLanLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
lanItemFrame = new QFrame(this);
lanItemFrame->setFrameShape(QFrame::Shape::NoFrame);
lanItemFrame->setContentsMargins(LAYOUT_MARGINS);
lanItemLayout = new QVBoxLayout(this);
lanItemLayout->setContentsMargins(LAYOUT_MARGINS);
lanItemLayout->setSpacing(1);
addWlanWidget = new AddNetBtn(true, this);
deviceLanLayout->setSpacing(1);
setLayout(deviceLanLayout);
lanItemFrame->setLayout(lanItemLayout);
deviceFrame = new DeviceFrame(devName, this);
deviceLanLayout->addWidget(deviceFrame);
deviceLanLayout->addWidget(lanItemFrame);
deviceLanLayout->addWidget(addWlanWidget);
//下拉按钮
connect(deviceFrame->dropDownLabel, &DrownLabel::labelClicked, this, &ItemFrame::onDrownLabelClicked);
}
ItemFrame::~ItemFrame()
{
}
void ItemFrame::onDrownLabelClicked()
{
if (!deviceFrame->dropDownLabel->isChecked) {
lanItemFrame->show();
deviceFrame->dropDownLabel->setDropDownStatus(true);
} else {
lanItemFrame->hide();
deviceFrame->dropDownLabel->setDropDownStatus(false);
}
}
void ItemFrame::filletStyleChange()
{
if (lanItemLayout->isEmpty()) {
return;
}
for (int i = 0; i < lanItemLayout->count(); ++i) {
QLayoutItem *it = lanItemLayout->itemAt(i);
WlanItem *itemFrame = (WlanItem*)(it->widget());
if (i != lanItemLayout->count()-1) {
itemFrame->setHalfFillet(false);
} else {
itemFrame->setHalfFillet(true);
}
}
}

View File

@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef ITEMFRAME_H
#define ITEMFRAME_H
#include <QFrame>
#include <QVBoxLayout>
#include "deviceframe.h"
#include "../component/AddBtn/addnetbtn.h"
#include "wlanitem.h"
class ItemFrame : public QFrame
{
Q_OBJECT
public:
ItemFrame(QString devName, QWidget *parent = nullptr);
~ItemFrame();
//单设备整体layout
QVBoxLayout * deviceLanLayout = nullptr;
//单设备名称+下拉按钮Frame
DeviceFrame * deviceFrame = nullptr;
//单设备列表Frame
QFrame * lanItemFrame = nullptr;
//单设备列表layout
QVBoxLayout * lanItemLayout = nullptr;
//单设备item列表
QMap<QString, WlanItem *> itemMap;
//已激活uuid
QString uuid = "";
//新建无线连接
AddNetBtn * addWlanWidget = nullptr;
void filletStyleChange();
private slots:
void onDrownLabelClicked();
};
#endif // ITEMFRAME_H

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>AddNetBtn</name>
<message>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
<source>Add Others</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="27"/>
<source>Add WiredNetork</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WlanConnect</name>
<message>
<location filename="../wlanconnect.ui" line="14"/>
<location filename="../wlanconnect.cpp" line="140"/>
<source>WlanConnect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="35"/>
<location filename="../wlanconnect.cpp" line="211"/>
<source>WLAN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="94"/>
<location filename="../wlanconnect.cpp" line="213"/>
<source>open</source>
<translation type="unfinished"></translation>
<extra-contents_path>/wlanconnect/open</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.ui" line="147"/>
<location filename="../wlanconnect.cpp" line="210"/>
<source>Advanced settings</source>
<translation type="unfinished"></translation>
<extra-contents_path>/wlanconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.cpp" line="123"/>
<source>ukui control center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="126"/>
<source>ukui control center desktop message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="228"/>
<source>No wireless network card detected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="374"/>
<location filename="../wlanconnect.cpp" line="1022"/>
<location filename="../wlanconnect.cpp" line="1084"/>
<source>connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="959"/>
<source>card</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="bo_CN">
<context>
<name>AddNetBtn</name>
<message>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="43"/>
<source>Add Others</source>
<translation></translation>
</message>
<message>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="47"/>
<source>Add WiredNetork</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WlanConnect</name>
<message>
<location filename="../wlanconnect.ui" line="14"/>
<location filename="../wlanconnect.cpp" line="140"/>
<source>WlanConnect</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="35"/>
<location filename="../wlanconnect.cpp" line="211"/>
<source>WLAN</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="94"/>
<location filename="../wlanconnect.cpp" line="213"/>
<source>open</source>
<translation></translation>
<extra-contents_path>/wlanconnect/open</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.ui" line="147"/>
<location filename="../wlanconnect.cpp" line="210"/>
<source>Advanced settings</source>
<translation></translation>
<extra-contents_path>/wlanconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.cpp" line="123"/>
<source>ukui control center</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="126"/>
<source>ukui control center desktop message</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="228"/>
<source>No wireless network card detected</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="374"/>
<location filename="../wlanconnect.cpp" line="1022"/>
<location filename="../wlanconnect.cpp" line="1084"/>
<source>connected</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="959"/>
<source>card</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>AddNetBtn</name>
<message>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
<source>Add Others</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="27"/>
<source>Add WiredNetork</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WlanConnect</name>
<message>
<location filename="../wlanconnect.ui" line="14"/>
<location filename="../wlanconnect.cpp" line="140"/>
<source>WlanConnect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="35"/>
<location filename="../wlanconnect.cpp" line="211"/>
<source>WLAN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="94"/>
<location filename="../wlanconnect.cpp" line="213"/>
<source>open</source>
<translation type="unfinished"></translation>
<extra-contents_path>/wlanconnect/open</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.ui" line="147"/>
<location filename="../wlanconnect.cpp" line="210"/>
<source>Advanced settings</source>
<translation type="unfinished"></translation>
<extra-contents_path>/wlanconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.cpp" line="123"/>
<source>ukui control center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="126"/>
<source>ukui control center desktop message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="228"/>
<source>No wireless network card detected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="374"/>
<location filename="../wlanconnect.cpp" line="1022"/>
<location filename="../wlanconnect.cpp" line="1084"/>
<source>connected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="959"/>
<source>card</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>AddNetBtn</name>
<message>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
<source>Add Others</source>
<translation></translation>
</message>
<message>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="27"/>
<source>Add WiredNetork</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WlanConnect</name>
<message>
<location filename="../wlanconnect.ui" line="14"/>
<location filename="../wlanconnect.cpp" line="140"/>
<source>WlanConnect</source>
<translation>线</translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="35"/>
<location filename="../wlanconnect.cpp" line="211"/>
<source>WLAN</source>
<translation>线</translation>
</message>
<message>
<location filename="../wlanconnect.ui" line="94"/>
<location filename="../wlanconnect.cpp" line="213"/>
<source>open</source>
<translation></translation>
<extra-contents_path>/wlanconnect/open</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.ui" line="147"/>
<location filename="../wlanconnect.cpp" line="210"/>
<source>Advanced settings</source>
<translation></translation>
<extra-contents_path>/wlanconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../wlanconnect.cpp" line="123"/>
<source>ukui control center</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="126"/>
<source>ukui control center desktop message</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="228"/>
<source>No wireless network card detected</source>
<translation>线</translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="374"/>
<location filename="../wlanconnect.cpp" line="1022"/>
<location filename="../wlanconnect.cpp" line="1084"/>
<source>connected</source>
<translation></translation>
</message>
<message>
<location filename="../wlanconnect.cpp" line="959"/>
<source>card</source>
<translation></translation>
</message>
</context>
</TS>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,195 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef WLANCONNECT_H
#define WLANCONNECT_H
#include <QObject>
#include <QtPlugin>
#include <QNetworkInterface>
#include <QtNetwork/QNetworkConfigurationManager>
#include <QtNetwork/QtNetwork>
#include <QTimer>
#include <QStringList>
#include <QString>
#include <QGSettings>
#include <QListWidget>
#include <QListWidgetItem>
#include <QMap>
#include <QDBusMessage>
#include <QDBusObjectPath>
#include <QDBusInterface>
#include <QDBusReply>
#include <interface.h>
#include "hoverbtn.h"
#include "itemframe.h"
#include "wlanitem.h"
#include "kwidget.h"
#include "kswitchbutton.h"
using namespace kdk;
namespace Ui {
class WlanConnect;
}
class WlanConnect : public QObject, CommonInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.kycc.CommonInterface")
Q_INTERFACES(CommonInterface)
public:
WlanConnect();
~WlanConnect();
QString plugini18nName() Q_DECL_OVERRIDE;
int pluginTypes() Q_DECL_OVERRIDE;
QWidget * pluginUi() Q_DECL_OVERRIDE;
const QString name() const Q_DECL_OVERRIDE;
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
QIcon icon() const Q_DECL_OVERRIDE;
bool isEnable() const Q_DECL_OVERRIDE;
QString translationPath() const Q_DECL_OVERRIDE;
private:
void initComponent();
void runExternalApp();
void initSearchText();
void showDesktopNotify(const QString &message);
//点击item 连接/断开
void activeConnect(QString netName, QString deviceName, int type);
void deActiveConnect(QString netName, QString deviceName, int type);
int sortWlanNet(QString deviceName, QString name, QString signal);
void updateIcon(WlanItem *item, QString signalStrength, QString security, QString isApConnection, int category);
void resortWifiList(ItemFrame *frame, QVector<QStringList> list);
//单wifi图标
int setSignal(QString lv);
QString wifiIcon(bool isLock, int strength, int category);
//开关相关
void hideLayout(QVBoxLayout * layout);
void showLayout(QVBoxLayout * layout);
//获取设备列表
void getDeviceList(QStringList &list);
//初始化设备wifi列表
void initNet();
void initNetListFromDevice(QString deviceName);
//处理列表 已连接
void addActiveItem(ItemFrame *frame, QString devName, QStringList infoList);
//处理列表 未连接
void addCustomItem(ItemFrame *frame, QString devName, QStringList infoList);
//增加设备
void addDeviceFrame(QString devName);
//减少设备
void removeDeviceFrame(QString devName);
//增加ap
void addOneWlanFrame(ItemFrame *frame, QString deviceName, QString name, QString signal, QString uuid, bool isLock, bool status, int type, QString isApConnection, int category);
//减少ap
void removeOneWlanFrame(ItemFrame *frame, QString deviceName, QString ssid);
//单个wifi连接状态变化
void itemActiveConnectionStatusChanged(WlanItem *item, int status);
void initSwtichState();
inline void setSwitchBtnEnable(bool state) {
if (m_wifiSwitch != nullptr) {
m_wifiSwitch->setCheckable(state);
}
}
inline bool getSwitchBtnEnable() {
if (m_wifiSwitch != nullptr) {
return m_wifiSwitch->isCheckable();
}
}
inline void setSwitchBtnState(bool state) {
if (m_wifiSwitch != nullptr) {
m_wifiSwitch->blockSignals(true);
m_wifiSwitch->setChecked(state);
m_wifiSwitch->blockSignals(false);
}
}
inline bool getSwitchBtnState() {
if (m_wifiSwitch != nullptr) {
return m_wifiSwitch->isChecked();
}
}
protected:
bool eventFilter(QObject *w,QEvent *e);
private:
Ui::WlanConnect *ui;
QString pluginName;
int pluginType;
QWidget *pluginWidget;
QDBusInterface *m_interface = nullptr;
//设备列表
QStringList deviceList;
//设备名 + 单设备frame
QMap<QString, ItemFrame *> deviceFrameMap;
//QVector<QStringList> wlanSignalList;
// DeviceWlanlistInfo deviceWlanlistInfo;
QTimer * m_scanTimer = nullptr;
// QTimer * m_updateTimer = nullptr;
private:
KSwitchButton *m_wifiSwitch;
bool m_firstLoad;
private slots:
void onNetworkAdd(QString deviceName, QStringList wlanInfo);
void onNetworkRemove(QString deviceName, QString wlannName);
void onActiveConnectionChanged(QString deviceName, QString ssid, QString uuid, int status);
void updateList();
void onDeviceStatusChanged();
void onDeviceNameChanged(QString, QString, int);
void onSwitchBtnChanged(bool);
void reScan();
};
#endif // WLANCONNECT_H

View File

@ -0,0 +1,54 @@
QT += widgets network dbus gui core
TEMPLATE = lib
CONFIG += plugin
include(../component/drownlabel.pri)
include(../component/addbtn.pri)
TARGET = $$qtLibraryTarget(wlanconnect)
DESTDIR = ../..
target.path = $$[QT_INSTALL_LIBS]/ukui-control-center
trans.files = translations/*
trans.path = /usr/share/kylin-nm/wlanconnect/
INCLUDEPATH += \
$$PROJECT_COMPONENTSOURCE \
$$PROJECT_ROOTDIR \
/usr/include/ukcc/interface \
/usr/include/ukcc/widgets
LIBS += -L$$[QT_INSTALL_LIBS] -lgsettings-qt -lukcc
CONFIG += c++11 \
link_pkgconfig \
PKGCONFIG += gsettings-qt \
kysdk-qtwidgets \
#DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
deviceframe.cpp \
# drownlabel.cpp \
itemframe.cpp \
wlanconnect.cpp \
wlanitem.cpp
HEADERS += \
deviceframe.h \
# drownlabel.h \
itemframe.h \
wlanconnect.h \
wlanitem.h
FORMS += \
wlanconnect.ui
INSTALLS += target \
trans
TRANSLATIONS += \
translations/zh_CN.ts \
translations/tr.ts \
translations/bo.ts \
translations/bo_CN.ts

Some files were not shown because too many files have changed in this diff Show More