Import Upstream version 1.1.0.1.0034
|
@ -0,0 +1,6 @@
|
||||||
|
ukui-notification-daemon authors
|
||||||
|
------------------
|
||||||
|
|
||||||
|
liushanwen <liushanwen@Kylinos.cn>
|
||||||
|
|
||||||
|
|
|
@ -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>.
|
|
@ -0,0 +1,20 @@
|
||||||
|
<schemalist gettext-domain="ukui-time-shutdown">
|
||||||
|
<schema id="org.ukui.time-shutdwon.settings" path="/org/ukui/time-shotdown/settings/">
|
||||||
|
<key name="shutdowntime" type="s">
|
||||||
|
<default>""</default>
|
||||||
|
<summary>shutdown-time</summary>
|
||||||
|
<description>the shutdown time set by program</description>
|
||||||
|
</key>
|
||||||
|
<key name="shutdownfrequency" type="s">
|
||||||
|
<default>""</default>
|
||||||
|
<summary>shutdown frequency</summary>
|
||||||
|
<description>the shutdown frequency set by program</description>
|
||||||
|
</key>
|
||||||
|
<key name="timeshutdown" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>shutdown frequency</summary>
|
||||||
|
<description>the shutdown frequency set by program</description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
</schemalist>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=Clock
|
||||||
|
Name[zh_CN]=定时关机
|
||||||
|
Name[tr_TR]=time-shutdown
|
||||||
|
GenericName=Kylin time shutdown
|
||||||
|
GenericName[zh_CN]=定时关机
|
||||||
|
GenericName[tr_TR]=
|
||||||
|
Comment=Ukui time shutdown
|
||||||
|
Comment[zh_CN]= =定时关机
|
||||||
|
Comment[tr_TR]=Ukui Çalar Saat
|
||||||
|
Keywords=guide;
|
||||||
|
Exec=/usr/bin/time-shutdown
|
||||||
|
Icon=kylin-alarm-clock
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
NoDisplay=false
|
||||||
|
Categories=System;Utility;
|
||||||
|
StartupNotify=false
|
||||||
|
|
After Width: | Height: | Size: 340 B |
After Width: | Height: | Size: 327 B |
After Width: | Height: | Size: 239 B |
After Width: | Height: | Size: 230 B |
After Width: | Height: | Size: 231 B |
After Width: | Height: | Size: 145 B |
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 24.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
width="19px" height="19px" viewBox="0 0 19 19" style="enable-background:new 0 0 19 19;" xml:space="preserve">
|
||||||
|
<style type="text/css">
|
||||||
|
.st0{opacity:0.75;fill:#FFFFFF;}
|
||||||
|
</style>
|
||||||
|
<rect x="12" y="8" class="st0" width="6" height="1"/>
|
||||||
|
<rect y="9" class="st0" width="3" height="1"/>
|
||||||
|
<rect x="8" y="17" transform="matrix(6.123234e-17 -1 1 6.123234e-17 -8 27)" class="st0" width="3" height="1"/>
|
||||||
|
<rect x="9" y="0" class="st0" width="1" height="9"/>
|
||||||
|
<rect x="5" y="2" class="st0" width="1" height="1"/>
|
||||||
|
<rect x="2" y="5" class="st0" width="1" height="1"/>
|
||||||
|
<rect x="5" y="16" class="st0" width="1" height="1"/>
|
||||||
|
<rect x="2" y="13" class="st0" width="1" height="1"/>
|
||||||
|
<rect x="16" y="13" transform="matrix(-1.346052e-10 -1 1 -1.346052e-10 3 30)" class="st0" width="1" height="1"/>
|
||||||
|
<rect x="13" y="16" transform="matrix(-1.346052e-10 -1 1 -1.346052e-10 -3 30)" class="st0" width="1" height="1"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,12 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>image/close_light.png</file>
|
||||||
|
<file>image/close2.png</file>
|
||||||
|
<file>image/close3.png</file>
|
||||||
|
<file>image/mini_light.png</file>
|
||||||
|
<file>image/mini2.png</file>
|
||||||
|
<file>image/mini3.png</file>
|
||||||
|
<file>image/time_shutdown.svg</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
.\" Man Page for kylin-clock
|
||||||
|
.TH UKUI-SHUTDOWN-TIMER 1 "2021-08-04" "UKUI Desktop Environment"
|
||||||
|
.\" Please adjust this date when revising the manpage.
|
||||||
|
.\"
|
||||||
|
.SH "NAME"
|
||||||
|
\fBukui-shutdown-timer\fR \- shutdown app in UKUI Desktop Environment
|
||||||
|
.SH "SYNOPSIS"
|
||||||
|
.B ukui-shutdown-timer [OPTIONS]
|
||||||
|
.SH "DESCRIPTION"
|
||||||
|
A shutdown app in UKUI Desktop Environment
|
||||||
|
.SH "OPTIONS"
|
||||||
|
.TP
|
||||||
|
\fB\-v, \-\-version\fR
|
||||||
|
Output version information and exit.
|
||||||
|
.SH "BUGS"
|
||||||
|
.SS Should you encounter any bugs, they may be reported at:
|
||||||
|
http://gitlab2.kylin.com/kylin-desktop/ukui-time-shutdown/-/issues
|
||||||
|
.SH "AUTHORS"
|
||||||
|
.SS This Manual Page has been written for the UKUI Desktop Environment by:
|
||||||
|
liuliang <liuliang@kylinos.cn> (2020)
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
.SS Further information may also be available at: http://wiki.ukui-desktop.org/docs
|
|
@ -0,0 +1,183 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "comboxwidget.h"
|
||||||
|
#include <QPainterPath>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
comBoxWidget::comBoxWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
this->setFixedSize(312, 34);
|
||||||
|
this->setProperty("isWindowButton", 0x1);
|
||||||
|
initMemberVariable();
|
||||||
|
initLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void comBoxWidget::initMemberVariable()
|
||||||
|
{
|
||||||
|
m_pLabel_1 = new QLabel();
|
||||||
|
m_pLabel_1->setAlignment(Qt::AlignVCenter);
|
||||||
|
m_pLabel_1->setText(QObject::tr("Shutdown")); //需要改一下
|
||||||
|
|
||||||
|
m_pLabel_2 = new QLabel();
|
||||||
|
m_pLabel_2->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
m_pLabel_2->setFixedWidth(165);
|
||||||
|
m_pLabel_3 = new QLabel();
|
||||||
|
QIcon labelIcon = QIcon::fromTheme("ukui-down.symbolic");
|
||||||
|
m_pLabel_3->setPixmap(labelIcon.pixmap(QSize(16, 16)));
|
||||||
|
m_pLabel_3->setProperty("useIconHighlightEffect", 0x2);
|
||||||
|
m_pHcomBoxWidgetLayout = new QHBoxLayout();
|
||||||
|
m_pHcomBoxWidgetLayout->setSpacing(0);
|
||||||
|
m_pHcomBoxWidgetLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
this->setContentsMargins(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void comBoxWidget::initLayout()
|
||||||
|
{
|
||||||
|
m_pHcomBoxWidgetLayout->addItem(new QSpacerItem(16, 1));
|
||||||
|
m_pHcomBoxWidgetLayout->addWidget(m_pLabel_1, Qt::AlignVCenter);
|
||||||
|
m_pHcomBoxWidgetLayout->addItem(new QSpacerItem(14, 10));
|
||||||
|
m_pHcomBoxWidgetLayout->addWidget(m_pLabel_2, Qt::AlignVCenter);
|
||||||
|
m_pHcomBoxWidgetLayout->addItem(new QSpacerItem(14, 30, QSizePolicy::Fixed));
|
||||||
|
m_pHcomBoxWidgetLayout->addWidget(m_pLabel_3, Qt::AlignVCenter);
|
||||||
|
this->setLayout(m_pHcomBoxWidgetLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取关机频率栏的文字显示
|
||||||
|
void comBoxWidget::setLabelWeekSelect(QString text)
|
||||||
|
{
|
||||||
|
m_sStroyLabel_2_Text = text;
|
||||||
|
this->m_pLabel_2->setText(SetFormatBody(m_sStroyLabel_2_Text, this->m_pLabel_2));
|
||||||
|
}
|
||||||
|
|
||||||
|
void comBoxWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
emit comBoxWidgetClicked();
|
||||||
|
QWidget::mouseReleaseEvent(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 设置...字样 */
|
||||||
|
QString comBoxWidget::SetFormatBody(QString text, QLabel *label)
|
||||||
|
{
|
||||||
|
QFontMetrics fontMetrics(label->font());
|
||||||
|
int LableWidth = label->width();
|
||||||
|
int fontSize = fontMetrics.width(text);
|
||||||
|
QString formatBody = text;
|
||||||
|
if(fontSize > (LableWidth - 10)) {
|
||||||
|
QStringList list = formatBody.split("\n");
|
||||||
|
if (list.size() >= 2) {
|
||||||
|
//当有几行时,只需要截取第一行就行,在第一行后面加...
|
||||||
|
// 判断第一行是否是空行
|
||||||
|
formatBody = judgeBlankLine(list);
|
||||||
|
formatBody = formatBody + "aa";
|
||||||
|
int oneFontSize = fontMetrics.width(formatBody);
|
||||||
|
if (oneFontSize > (LableWidth - 10)) {
|
||||||
|
formatBody = fontMetrics.elidedText(formatBody, Qt::ElideRight, LableWidth - 10);
|
||||||
|
return formatBody;
|
||||||
|
} else {
|
||||||
|
if (!substringSposition(formatBody, list)) {
|
||||||
|
int oneFontSize = fontMetrics.width(formatBody);
|
||||||
|
formatBody = fontMetrics.elidedText(formatBody, Qt::ElideRight, oneFontSize - 1);
|
||||||
|
return formatBody;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//说明只存在一行,在最后面加...就行
|
||||||
|
formatBody = fontMetrics.elidedText(formatBody, Qt::ElideRight, LableWidth - 10);
|
||||||
|
return formatBody;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QStringList list = formatBody.split("\n");
|
||||||
|
if (list.size() >= 2) {
|
||||||
|
//取得当前的有字符串的子串
|
||||||
|
formatBody = judgeBlankLine(list);
|
||||||
|
formatBody = formatBody + "aa";
|
||||||
|
if (!substringSposition(formatBody, list)) {
|
||||||
|
int oneFontSize = fontMetrics.width(formatBody);
|
||||||
|
formatBody = fontMetrics.elidedText(formatBody, Qt::ElideRight, oneFontSize - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return formatBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 去除掉空行,显示有字体的行 */
|
||||||
|
QString comBoxWidget::judgeBlankLine(QStringList list)
|
||||||
|
{
|
||||||
|
int tmp = list.count();
|
||||||
|
for (int i = 0; i < tmp; i++) {
|
||||||
|
QString dest = list.at(i);
|
||||||
|
dest = dest.trimmed();
|
||||||
|
if (dest.size() != 0) {
|
||||||
|
return list.at(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list.at(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 判断当前子串位置,后面是否还有子串 */
|
||||||
|
bool comBoxWidget::substringSposition(QString formatBody, QStringList list)
|
||||||
|
{
|
||||||
|
int tmp = list.count();
|
||||||
|
for (int i = 0; i < tmp; i++) {
|
||||||
|
QString dest = list.at(i);
|
||||||
|
if (dest == formatBody && i == tmp - 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void comBoxWidget::leaveEvent(QEvent *e)
|
||||||
|
{
|
||||||
|
Q_UNUSED(e);
|
||||||
|
m_mouseEnter = false;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void comBoxWidget::enterEvent(QEvent *e)
|
||||||
|
{
|
||||||
|
Q_UNUSED(e);
|
||||||
|
m_mouseEnter = true;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void comBoxWidget::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QStyleOption opt;
|
||||||
|
opt.init(this);
|
||||||
|
QPainter p(this);
|
||||||
|
QPainterPath path;
|
||||||
|
opt.rect.adjust(0,0,0,0);
|
||||||
|
if (m_mouseEnter && this->isEnabled()) {
|
||||||
|
p.setBrush(opt.palette.color(QPalette::Midlight));
|
||||||
|
} else {
|
||||||
|
p.setBrush(opt.palette.color(QPalette::Button));
|
||||||
|
}
|
||||||
|
p.setOpacity(1);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.drawRoundedRect(opt.rect, 6, 6);
|
||||||
|
p.setRenderHint(QPainter::Antialiasing); //反锯齿
|
||||||
|
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMBOXWIDGET_H
|
||||||
|
#define COMBOXWIDGET_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QGSettings>
|
||||||
|
|
||||||
|
class comBoxWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit comBoxWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
void initMemberVariable();
|
||||||
|
void initLayout();
|
||||||
|
void setLabelWeekSelect(QString text);
|
||||||
|
QString SetFormatBody(QString text, QLabel *label);
|
||||||
|
QString judgeBlankLine(QStringList list);
|
||||||
|
bool substringSposition(QString formatBody, QStringList list);
|
||||||
|
QLabel *m_pLabel_1 = nullptr;
|
||||||
|
QLabel *m_pLabel_2 = nullptr;
|
||||||
|
QLabel *m_pLabel_3 = nullptr;
|
||||||
|
QHBoxLayout *m_pHcomBoxWidgetLayout = nullptr;
|
||||||
|
QString m_sStroyLabel_2_Text;
|
||||||
|
bool m_mouseEnter = false;
|
||||||
|
protected:
|
||||||
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
void leaveEvent(QEvent *e);
|
||||||
|
void enterEvent(QEvent *e);
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
signals:
|
||||||
|
void comBoxWidgetClicked();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COMBOXWIDGET_H
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "confirmareawidget.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
confirmAreaWidget::confirmAreaWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
initMemberVariable();
|
||||||
|
initLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 初始化成员变量 */
|
||||||
|
void confirmAreaWidget::initMemberVariable()
|
||||||
|
{
|
||||||
|
m_pCancelButton = new QPushButton(QObject::tr("Cancel"));
|
||||||
|
m_pCancelButton->setProperty("isWindowButton", 0x1);
|
||||||
|
m_pCancelButton->setProperty("useIconHighlightEffect", 0x2);
|
||||||
|
m_pCancelButton->setFixedHeight(34);
|
||||||
|
m_pConfirmButton = new QPushButton(QObject::tr("Confirm"));
|
||||||
|
m_pConfirmButton->setProperty("isImportant", 0x1);
|
||||||
|
m_pConfirmButton->setFixedHeight(34);
|
||||||
|
|
||||||
|
m_pconfirmAreaWidgetHLayout = new QHBoxLayout();
|
||||||
|
m_pconfirmAreaWidgetHLayout->setSpacing(0);
|
||||||
|
m_pconfirmAreaWidgetHLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
this->setContentsMargins(0, 0, 0, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void confirmAreaWidget::initLayout()
|
||||||
|
{
|
||||||
|
m_pconfirmAreaWidgetHLayout->addItem(new QSpacerItem(98, 10, QSizePolicy::Expanding));
|
||||||
|
m_pconfirmAreaWidgetHLayout->addWidget(m_pCancelButton);
|
||||||
|
m_pconfirmAreaWidgetHLayout->addItem(new QSpacerItem(16, 10, QSizePolicy::Fixed));
|
||||||
|
m_pconfirmAreaWidgetHLayout->addWidget(m_pConfirmButton);
|
||||||
|
m_pconfirmAreaWidgetHLayout->addItem(new QSpacerItem(98, 10, QSizePolicy::Expanding));
|
||||||
|
this->setLayout(m_pconfirmAreaWidgetHLayout);
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIRMAREAWIDGET_H
|
||||||
|
#define CONFIRMAREAWIDGET_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVariant>
|
||||||
|
class confirmAreaWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit confirmAreaWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
QPushButton *m_pCancelButton;
|
||||||
|
QPushButton *m_pConfirmButton;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initMemberVariable();
|
||||||
|
void initLayout();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHBoxLayout *m_pconfirmAreaWidgetHLayout;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONFIRMAREAWIDGET_H
|
|
@ -0,0 +1,244 @@
|
||||||
|
#include "dropdownmenu.h"
|
||||||
|
#include <QWidgetAction>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QGSettings>
|
||||||
|
|
||||||
|
MenuItem::MenuItem(QString week, int id, QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
m_id = id;
|
||||||
|
m_pweekLabel = new QLabel();
|
||||||
|
m_pweekLabel->setText(week);
|
||||||
|
m_pselectedLabelIcon = new QLabel();
|
||||||
|
m_pselectedLabelIcon->setFixedSize(16, 16);
|
||||||
|
QIcon labelIcon = QIcon::fromTheme("object-select-symbolic");
|
||||||
|
m_pselectedLabelIcon->setPixmap(labelIcon.pixmap(QSize(16, 16)));
|
||||||
|
m_pselectedLabelIcon->setProperty("useIconHighlightEffect", 0x8);
|
||||||
|
m_pHWeekLayout = new QHBoxLayout();
|
||||||
|
m_pHWeekLayout->setContentsMargins(17, 0, 0, 0);
|
||||||
|
m_pHWeekLayout->addWidget(m_pselectedLabelIcon);
|
||||||
|
m_pHWeekLayout->addWidget(m_pweekLabel);
|
||||||
|
QSizePolicy policy = m_pselectedLabelIcon->sizePolicy();
|
||||||
|
policy.setRetainSizeWhenHidden(true);
|
||||||
|
m_pselectedLabelIcon->setSizePolicy(policy);
|
||||||
|
m_pselectedLabelIcon->setVisible(false);
|
||||||
|
this->setLayout(m_pHWeekLayout);
|
||||||
|
this->setFixedSize(306, 35);
|
||||||
|
}
|
||||||
|
|
||||||
|
//显示或取消勾选标志
|
||||||
|
void MenuItem::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
if (!this->m_pselectedLabelIcon->isVisible()) {
|
||||||
|
m_pselectedLabelIcon->setVisible(true);
|
||||||
|
emit showLabelIcon(m_id);
|
||||||
|
} else {
|
||||||
|
m_pselectedLabelIcon->setVisible(false);
|
||||||
|
emit hideLabelIcon(m_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QWidget::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuItem::enterEvent(QEvent *e)
|
||||||
|
{
|
||||||
|
Q_UNUSED(e);
|
||||||
|
m_mouseEnter = true;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuItem::leaveEvent(QEvent *e)
|
||||||
|
{
|
||||||
|
Q_UNUSED(e);
|
||||||
|
m_mouseEnter = false;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuItem::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QStyleOption opt;
|
||||||
|
opt.init(this);
|
||||||
|
QPainter p(this);
|
||||||
|
opt.rect.adjust(0,0,0,0);
|
||||||
|
if (m_mouseEnter) {
|
||||||
|
QPalette palette;
|
||||||
|
palette.setColor(QPalette::Active, QPalette::WindowText,Qt::white);
|
||||||
|
m_pweekLabel->setPalette(palette);
|
||||||
|
p.setBrush(opt.palette.color(QPalette::Link));
|
||||||
|
} else {
|
||||||
|
if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())){
|
||||||
|
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
|
||||||
|
if (gsetting.keys().contains("styleName")){
|
||||||
|
QPalette palette;
|
||||||
|
if (gsetting.get("styleName").toString() == "ukui-default") {
|
||||||
|
palette.setColor(QPalette::Active, QPalette::WindowText,Qt::black);
|
||||||
|
} else {
|
||||||
|
palette.setColor(QPalette::Active, QPalette::WindowText,Qt::white);
|
||||||
|
}
|
||||||
|
m_pweekLabel->setPalette(palette);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.setBrush(opt.palette.color(QPalette::ToolTipBase));
|
||||||
|
}
|
||||||
|
p.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
|
p.setOpacity(1);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.drawRoundedRect(opt.rect, 6, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
DropDownMenu::DropDownMenu()
|
||||||
|
{
|
||||||
|
initWeekDateList();
|
||||||
|
initAllDateWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 初始化链表, 将所有的选项保存到链表中 */
|
||||||
|
void DropDownMenu::initWeekDateList()
|
||||||
|
{
|
||||||
|
m_pWeekDateList.append(QObject::tr("never"));
|
||||||
|
m_pWeekDateList.append(QObject::tr("Only this shutdown"));
|
||||||
|
m_pWeekDateList.append(QObject::tr("Everyday"));
|
||||||
|
m_pWeekDateList.append(QObject::tr("Mon"));
|
||||||
|
m_pWeekDateList.append(QObject::tr("Tue"));
|
||||||
|
m_pWeekDateList.append(QObject::tr("Wed"));
|
||||||
|
m_pWeekDateList.append(QObject::tr("Thu"));
|
||||||
|
m_pWeekDateList.append(QObject::tr("Fri"));
|
||||||
|
m_pWeekDateList.append(QObject::tr("Sat"));
|
||||||
|
m_pWeekDateList.append(QObject::tr("Sun"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropDownMenu::initAllDateWidget()
|
||||||
|
{
|
||||||
|
this->setFixedWidth(324);
|
||||||
|
m_selectWeek.clear();
|
||||||
|
for (int i = 0; i < m_pWeekDateList.count(); i++) {
|
||||||
|
MenuItem *item = new MenuItem(m_pWeekDateList[i], i, this);
|
||||||
|
connect(item, SIGNAL(showLabelIcon(int)), this, SLOT(handleShowLabelSlot(int)));
|
||||||
|
connect(item, SIGNAL(hideLabelIcon(int)), this, SLOT(handleHideLabelSlot(int)));
|
||||||
|
QWidgetAction *action = new QWidgetAction(this);
|
||||||
|
action->setDefaultWidget(item);
|
||||||
|
this->addAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropDownMenu::initLabelStatus(QList<int> selectWeek)
|
||||||
|
{
|
||||||
|
m_selectWeek.clear();
|
||||||
|
for(int i = 0; i < selectWeek.count(); i++) {
|
||||||
|
QWidgetAction *wAction = dynamic_cast<QWidgetAction *>(this->actions().at(selectWeek[i]));
|
||||||
|
MenuItem *item = dynamic_cast<MenuItem *>(wAction->defaultWidget());
|
||||||
|
item->m_pselectedLabelIcon->setVisible(true);
|
||||||
|
m_selectWeek.append(selectWeek[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//返回列表选中的组合
|
||||||
|
QString DropDownMenu::getChosenList(QList<int> selectList)
|
||||||
|
{
|
||||||
|
QString chooseList = m_pWeekDateList[selectList[0]];
|
||||||
|
for (int i = 1; i < selectList.count(); i++) {
|
||||||
|
chooseList += " " + m_pWeekDateList[selectList[i]];
|
||||||
|
}
|
||||||
|
return chooseList;
|
||||||
|
}
|
||||||
|
|
||||||
|
//从gsetting中获取选取星期值
|
||||||
|
QList<int> DropDownMenu::getWeekDateList(QString indexString)
|
||||||
|
{
|
||||||
|
QStringList indexList = indexString.split(" ");
|
||||||
|
QList<int> selectWeek;
|
||||||
|
selectWeek.clear();
|
||||||
|
for (int i = 0; i < indexList.count(); i++) {
|
||||||
|
selectWeek.append(indexList.at(i).toInt());
|
||||||
|
}
|
||||||
|
return selectWeek;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropDownMenu::handleShowLabelSlot(int id)
|
||||||
|
{
|
||||||
|
if (id <= 2) {
|
||||||
|
m_selectWeek.clear();
|
||||||
|
for (int i = 0; i < this->actions().count(); ++i) {
|
||||||
|
if (i == id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QWidgetAction *wAction = dynamic_cast<QWidgetAction *>(this->actions().at(i));
|
||||||
|
MenuItem *item = dynamic_cast<MenuItem *>(wAction->defaultWidget());
|
||||||
|
item->m_pselectedLabelIcon->setVisible(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i <= 2; i++) {
|
||||||
|
QWidgetAction *wAction = dynamic_cast<QWidgetAction *>(this->actions().at(i));
|
||||||
|
MenuItem *item = dynamic_cast<MenuItem *>(wAction->defaultWidget());
|
||||||
|
item->m_pselectedLabelIcon->setVisible(false);
|
||||||
|
m_selectWeek.removeAll(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_selectWeek.append(id);
|
||||||
|
qSort(m_selectWeek.begin(), m_selectWeek.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropDownMenu::handleHideLabelSlot(int id)
|
||||||
|
{
|
||||||
|
m_selectWeek.removeAll(id);
|
||||||
|
m_selectWeek.removeAll(0);
|
||||||
|
if (m_selectWeek.isEmpty()) {
|
||||||
|
m_selectWeek.append(0);
|
||||||
|
QWidgetAction *wAction = dynamic_cast<QWidgetAction *>(this->actions().at(0));
|
||||||
|
MenuItem *item = dynamic_cast<MenuItem *>(wAction->defaultWidget());
|
||||||
|
item->m_pselectedLabelIcon->setVisible(true);
|
||||||
|
this->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList DropDownMenu::getWeekStringList()
|
||||||
|
{
|
||||||
|
QStringList weekStringList;
|
||||||
|
for (int i = 0; i < m_selectWeek.size(); ++i) {
|
||||||
|
weekStringList.append(QString().number(m_selectWeek.at(i)));
|
||||||
|
}
|
||||||
|
return weekStringList;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropDownMenu::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
QAction *action = this->actionAt(event->pos());
|
||||||
|
if (action) {
|
||||||
|
for (int i = 0; i < this->actions().count(); i++) {
|
||||||
|
if (this->actions().at(i) == action) {
|
||||||
|
if (i <= 2 && event->button() == Qt::LeftButton) {
|
||||||
|
QMenu::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QMenu::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropDownMenu::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())){
|
||||||
|
QGSettings gsetting(QString("org.ukui.style").toLocal8Bit());
|
||||||
|
if (gsetting.keys().contains("styleName")){
|
||||||
|
if (gsetting.get("styleName").toString() == "ukui-dark") {
|
||||||
|
QStyleOption opt;
|
||||||
|
opt.init(this);
|
||||||
|
QPainter p(this);
|
||||||
|
opt.rect.adjust(0,0,0,0);
|
||||||
|
p.setBrush(opt.palette.color(QPalette::ToolTipBase));
|
||||||
|
p.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
|
p.setOpacity(1);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.drawRoundedRect(opt.rect, 6, 6);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QMenu::paintEvent(event);
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
#ifndef DROPDOWNMENU_H
|
||||||
|
#define DROPDOWNMENU_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
class MenuItem : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MenuItem(QString week, int id, QWidget *parent = nullptr);
|
||||||
|
QLabel *m_pweekLabel;
|
||||||
|
QLabel *m_pselectedLabelIcon;
|
||||||
|
QHBoxLayout *m_pHWeekLayout;
|
||||||
|
bool m_mouseEnter = false;
|
||||||
|
int m_id = 0;
|
||||||
|
protected:
|
||||||
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
void enterEvent(QEvent *e);
|
||||||
|
void leaveEvent(QEvent *e);
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
Q_SIGNALS:
|
||||||
|
void showLabelIcon(int id);
|
||||||
|
void hideLabelIcon(int id);
|
||||||
|
};
|
||||||
|
|
||||||
|
class DropDownMenu : public QMenu
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
DropDownMenu();
|
||||||
|
void initWeekDateList();
|
||||||
|
void initAllDateWidget();
|
||||||
|
void initLabelStatus(QList<int> selectWeek);
|
||||||
|
QStringList getWeekStringList();
|
||||||
|
QString getChosenList(QList<int> selectList);
|
||||||
|
QList<int> getWeekDateList(QString indexString);
|
||||||
|
protected:
|
||||||
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
public Q_SLOTS:
|
||||||
|
void handleShowLabelSlot(int id);
|
||||||
|
void handleHideLabelSlot(int id);
|
||||||
|
private:
|
||||||
|
QStringList m_pWeekDateList;
|
||||||
|
QList<int> m_selectWeek;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DROPDOWNMENU_H
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "widget.h"
|
||||||
|
#include "qtsingleapplication.h"
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <syslog.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
int getScreenWidth() {
|
||||||
|
Display *disp = XOpenDisplay(NULL);
|
||||||
|
Screen *scrn = DefaultScreenOfDisplay(disp);
|
||||||
|
if (NULL == scrn) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int width = scrn->width;
|
||||||
|
|
||||||
|
if (NULL != disp) {
|
||||||
|
XCloseDisplay(disp);
|
||||||
|
}
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||||
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QString id = QString("time-shutdown-" + QLatin1String(getenv("DISPLAY")));
|
||||||
|
QtSingleApplication a(id, argc, argv);
|
||||||
|
QGuiApplication::setFallbackSessionManagementEnabled(true);
|
||||||
|
QGuiApplication::setQuitOnLastWindowClosed(false);
|
||||||
|
if (a.isRunning()) {
|
||||||
|
a.sendMessage(nullptr);
|
||||||
|
qDebug() << QObject::tr("time-shutdown is already running!");
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} else {
|
||||||
|
Widget w;
|
||||||
|
w.show();
|
||||||
|
QObject::connect(&a, SIGNAL(messageReceived(const QString&)), &w, SLOT(bootOptionsFilter(const QString&)));
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "monitortimethread.h"
|
||||||
|
|
||||||
|
monitorTimeThread::monitorTimeThread()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MONITORTIMETHREAD_H
|
||||||
|
#define MONITORTIMETHREAD_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
class monitorTimeThread : public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
monitorTimeThread();
|
||||||
|
// void run(); //线程入口函数(工作线程的主函数)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MONITORTIMETHREAD_H
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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 3, 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef PLUGINSTOOLBUTTON_H
|
||||||
|
#define PLUGINSTOOLBUTTON_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QToolButton>
|
||||||
|
class PluginsToolButton : public QToolButton
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit PluginsToolButton(QWidget *parent = nullptr);
|
||||||
|
enum SidebarButtonStatus{NORMAL, HOVER, PRESS};
|
||||||
|
SidebarButtonStatus status;
|
||||||
|
protected:
|
||||||
|
void enterEvent(QEvent *e); //鼠标进入事件
|
||||||
|
void leaveEvent(QEvent *e); //鼠标离开事件
|
||||||
|
void mousePressEvent(QMouseEvent *e); //按钮点击事件
|
||||||
|
void paintEvent(QPaintEvent *e);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PLUGINSTOOLBUTTON_H
|
|
@ -0,0 +1,204 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Solutions component.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** You may use this file under the terms of the BSD license as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||||
|
** of its contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "qtlocalpeer.h"
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
#include <QLibrary>
|
||||||
|
#include <qt_windows.h>
|
||||||
|
typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*);
|
||||||
|
static PProcessIdToSessionId pProcessIdToSessionId = 0;
|
||||||
|
#endif
|
||||||
|
#if defined(Q_OS_UNIX)
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace QtLP_Private {
|
||||||
|
#include "qtlockedfile.cpp"
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
#include "qtlockedfile_win.cpp"
|
||||||
|
#else
|
||||||
|
#include "qtlockedfile_unix.cpp"
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* QtLocalPeer::ack = "ack";
|
||||||
|
|
||||||
|
QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
|
||||||
|
: QObject(parent), id(appId)
|
||||||
|
{
|
||||||
|
QString prefix = id;
|
||||||
|
if (id.isEmpty()) {
|
||||||
|
id = QCoreApplication::applicationFilePath();
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
id = id.toLower();
|
||||||
|
#endif
|
||||||
|
prefix = id.section(QLatin1Char('/'), -1);
|
||||||
|
}
|
||||||
|
prefix.remove(QRegExp("[^a-zA-Z]"));
|
||||||
|
prefix.truncate(6);
|
||||||
|
|
||||||
|
QByteArray idc = id.toUtf8();
|
||||||
|
quint16 idNum = qChecksum(idc.constData(), idc.size());
|
||||||
|
socketName = QLatin1String("qtsingleapp-") + prefix
|
||||||
|
+ QLatin1Char('-') + QString::number(idNum, 16);
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
if (!pProcessIdToSessionId) {
|
||||||
|
QLibrary lib("kernel32");
|
||||||
|
pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId");
|
||||||
|
}
|
||||||
|
if (pProcessIdToSessionId) {
|
||||||
|
DWORD sessionId = 0;
|
||||||
|
pProcessIdToSessionId(GetCurrentProcessId(), &sessionId);
|
||||||
|
socketName += QLatin1Char('-') + QString::number(sessionId, 16);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
socketName += QLatin1Char('-') + QString::number(::getuid(), 16);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
server = new QLocalServer(this);
|
||||||
|
QString lockName = QDir(QDir::tempPath()).absolutePath()
|
||||||
|
+ QLatin1Char('/') + socketName
|
||||||
|
+ QLatin1String("-lockfile");
|
||||||
|
lockFile.setFileName(lockName);
|
||||||
|
lockFile.open(QIODevice::ReadWrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool QtLocalPeer::isClient()
|
||||||
|
{
|
||||||
|
if (lockFile.isLocked())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
bool res = server->listen(socketName);
|
||||||
|
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
|
||||||
|
// ### Workaround
|
||||||
|
if (!res && server->serverError() == QAbstractSocket::AddressInUseError) {
|
||||||
|
QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName);
|
||||||
|
res = server->listen(socketName);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (!res)
|
||||||
|
qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
|
||||||
|
QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool QtLocalPeer::sendMessage(const QString &message, int timeout)
|
||||||
|
{
|
||||||
|
if (!isClient())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QLocalSocket socket;
|
||||||
|
bool connOk = false;
|
||||||
|
for(int i = 0; i < 2; i++) {
|
||||||
|
// Try twice, in case the other instance is just starting up
|
||||||
|
socket.connectToServer(socketName);
|
||||||
|
connOk = socket.waitForConnected(timeout/2);
|
||||||
|
if (connOk || i)
|
||||||
|
break;
|
||||||
|
int ms = 250;
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
Sleep(DWORD(ms));
|
||||||
|
#else
|
||||||
|
struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
|
||||||
|
nanosleep(&ts, NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (!connOk)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QByteArray uMsg(message.toUtf8());
|
||||||
|
QDataStream ds(&socket);
|
||||||
|
ds.writeBytes(uMsg.constData(), uMsg.size());
|
||||||
|
bool res = socket.waitForBytesWritten(timeout);
|
||||||
|
if (res) {
|
||||||
|
res &= socket.waitForReadyRead(timeout); // wait for ack
|
||||||
|
if (res)
|
||||||
|
res &= (socket.read(qstrlen(ack)) == ack);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QtLocalPeer::receiveConnection()
|
||||||
|
{
|
||||||
|
QLocalSocket* socket = server->nextPendingConnection();
|
||||||
|
if (!socket)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (socket->bytesAvailable() < (int)sizeof(quint32))
|
||||||
|
socket->waitForReadyRead();
|
||||||
|
QDataStream ds(socket);
|
||||||
|
QByteArray uMsg;
|
||||||
|
quint32 remaining;
|
||||||
|
ds >> remaining;
|
||||||
|
uMsg.resize(remaining);
|
||||||
|
int got = 0;
|
||||||
|
char* uMsgBuf = uMsg.data();
|
||||||
|
do {
|
||||||
|
got = ds.readRawData(uMsgBuf, remaining);
|
||||||
|
remaining -= got;
|
||||||
|
uMsgBuf += got;
|
||||||
|
} while (remaining && got >= 0 && socket->waitForReadyRead(2000));
|
||||||
|
if (got < 0) {
|
||||||
|
qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData());
|
||||||
|
delete socket;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QString message(QString::fromUtf8(uMsg));
|
||||||
|
socket->write(ack, qstrlen(ack));
|
||||||
|
socket->waitForBytesWritten(1000);
|
||||||
|
socket->waitForDisconnected(1000); // make sure client reads ack
|
||||||
|
delete socket;
|
||||||
|
emit messageReceived(message); //### (might take a long time to return)
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Solutions component.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** You may use this file under the terms of the BSD license as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||||
|
** of its contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QTLOCALPEER_H
|
||||||
|
#define QTLOCALPEER_H
|
||||||
|
|
||||||
|
#include <QLocalServer>
|
||||||
|
#include <QLocalSocket>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include "qtlockedfile.h"
|
||||||
|
|
||||||
|
class QtLocalPeer : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
|
||||||
|
bool isClient();
|
||||||
|
bool sendMessage(const QString &message, int timeout);
|
||||||
|
QString applicationId() const
|
||||||
|
{ return id; }
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void messageReceived(const QString &message);
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
void receiveConnection();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString id;
|
||||||
|
QString socketName;
|
||||||
|
QLocalServer* server;
|
||||||
|
QtLP_Private::QtLockedFile lockFile;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const char* ack;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QTLOCALPEER_H
|
|
@ -0,0 +1,193 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Solutions component.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** You may use this file under the terms of the BSD license as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||||
|
** of its contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "qtlockedfile.h"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class QtLockedFile
|
||||||
|
|
||||||
|
\brief The QtLockedFile class extends QFile with advisory locking
|
||||||
|
functions.
|
||||||
|
|
||||||
|
A file may be locked in read or write mode. Multiple instances of
|
||||||
|
\e QtLockedFile, created in multiple processes running on the same
|
||||||
|
machine, may have a file locked in read mode. Exactly one instance
|
||||||
|
may have it locked in write mode. A read and a write lock cannot
|
||||||
|
exist simultaneously on the same file.
|
||||||
|
|
||||||
|
The file locks are advisory. This means that nothing prevents
|
||||||
|
another process from manipulating a locked file using QFile or
|
||||||
|
file system functions offered by the OS. Serialization is only
|
||||||
|
guaranteed if all processes that access the file use
|
||||||
|
QLockedFile. Also, while holding a lock on a file, a process
|
||||||
|
must not open the same file again (through any API), or locks
|
||||||
|
can be unexpectedly lost.
|
||||||
|
|
||||||
|
The lock provided by an instance of \e QtLockedFile is released
|
||||||
|
whenever the program terminates. This is true even when the
|
||||||
|
program crashes and no destructors are called.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \enum QtLockedFile::LockMode
|
||||||
|
|
||||||
|
This enum describes the available lock modes.
|
||||||
|
|
||||||
|
\value ReadLock A read lock.
|
||||||
|
\value WriteLock A write lock.
|
||||||
|
\value NoLock Neither a read lock nor a write lock.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructs an unlocked \e QtLockedFile object. This constructor
|
||||||
|
behaves in the same way as \e QFile::QFile().
|
||||||
|
|
||||||
|
\sa QFile::QFile()
|
||||||
|
*/
|
||||||
|
QtLockedFile::QtLockedFile()
|
||||||
|
: QFile()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
wmutex = 0;
|
||||||
|
rmutex = 0;
|
||||||
|
#endif
|
||||||
|
m_lock_mode = NoLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructs an unlocked QtLockedFile object with file \a name. This
|
||||||
|
constructor behaves in the same way as \e QFile::QFile(const
|
||||||
|
QString&).
|
||||||
|
|
||||||
|
\sa QFile::QFile()
|
||||||
|
*/
|
||||||
|
QtLockedFile::QtLockedFile(const QString &name)
|
||||||
|
: QFile(name)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
wmutex = 0;
|
||||||
|
rmutex = 0;
|
||||||
|
#endif
|
||||||
|
m_lock_mode = NoLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Opens the file in OpenMode \a mode.
|
||||||
|
|
||||||
|
This is identical to QFile::open(), with the one exception that the
|
||||||
|
Truncate mode flag is disallowed. Truncation would conflict with the
|
||||||
|
advisory file locking, since the file would be modified before the
|
||||||
|
write lock is obtained. If truncation is required, use resize(0)
|
||||||
|
after obtaining the write lock.
|
||||||
|
|
||||||
|
Returns true if successful; otherwise false.
|
||||||
|
|
||||||
|
\sa QFile::open(), QFile::resize()
|
||||||
|
*/
|
||||||
|
bool QtLockedFile::open(OpenMode mode)
|
||||||
|
{
|
||||||
|
if (mode & QIODevice::Truncate) {
|
||||||
|
qWarning("QtLockedFile::open(): Truncate mode not allowed.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return QFile::open(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns \e true if this object has a in read or write lock;
|
||||||
|
otherwise returns \e false.
|
||||||
|
|
||||||
|
\sa lockMode()
|
||||||
|
*/
|
||||||
|
bool QtLockedFile::isLocked() const
|
||||||
|
{
|
||||||
|
return m_lock_mode != NoLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the type of lock currently held by this object, or \e
|
||||||
|
QtLockedFile::NoLock.
|
||||||
|
|
||||||
|
\sa isLocked()
|
||||||
|
*/
|
||||||
|
QtLockedFile::LockMode QtLockedFile::lockMode() const
|
||||||
|
{
|
||||||
|
return m_lock_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn bool QtLockedFile::lock(LockMode mode, bool block = true)
|
||||||
|
|
||||||
|
Obtains a lock of type \a mode. The file must be opened before it
|
||||||
|
can be locked.
|
||||||
|
|
||||||
|
If \a block is true, this function will block until the lock is
|
||||||
|
acquired. If \a block is false, this function returns \e false
|
||||||
|
immediately if the lock cannot be acquired.
|
||||||
|
|
||||||
|
If this object already has a lock of type \a mode, this function
|
||||||
|
returns \e true immediately. If this object has a lock of a
|
||||||
|
different type than \a mode, the lock is first released and then a
|
||||||
|
new lock is obtained.
|
||||||
|
|
||||||
|
This function returns \e true if, after it executes, the file is
|
||||||
|
locked by this object, and \e false otherwise.
|
||||||
|
|
||||||
|
\sa unlock(), isLocked(), lockMode()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn bool QtLockedFile::unlock()
|
||||||
|
|
||||||
|
Releases a lock.
|
||||||
|
|
||||||
|
If the object has no lock, this function returns immediately.
|
||||||
|
|
||||||
|
This function returns \e true if, after it executes, the file is
|
||||||
|
not locked by this object, and \e false otherwise.
|
||||||
|
|
||||||
|
\sa lock(), isLocked(), lockMode()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QtLockedFile::~QtLockedFile()
|
||||||
|
|
||||||
|
Destroys the \e QtLockedFile object. If any locks were held, they
|
||||||
|
are released.
|
||||||
|
*/
|
|
@ -0,0 +1,97 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Solutions component.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** You may use this file under the terms of the BSD license as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||||
|
** of its contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QTLOCKEDFILE_H
|
||||||
|
#define QTLOCKEDFILE_H
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <QVector>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT)
|
||||||
|
# define QT_QTLOCKEDFILE_EXPORT
|
||||||
|
# elif defined(QT_QTLOCKEDFILE_IMPORT)
|
||||||
|
# if defined(QT_QTLOCKEDFILE_EXPORT)
|
||||||
|
# undef QT_QTLOCKEDFILE_EXPORT
|
||||||
|
# endif
|
||||||
|
# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport)
|
||||||
|
# elif defined(QT_QTLOCKEDFILE_EXPORT)
|
||||||
|
# undef QT_QTLOCKEDFILE_EXPORT
|
||||||
|
# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define QT_QTLOCKEDFILE_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace QtLP_Private {
|
||||||
|
|
||||||
|
class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum LockMode { NoLock = 0, ReadLock, WriteLock };
|
||||||
|
|
||||||
|
QtLockedFile();
|
||||||
|
QtLockedFile(const QString &name);
|
||||||
|
~QtLockedFile();
|
||||||
|
|
||||||
|
bool open(OpenMode mode);
|
||||||
|
|
||||||
|
bool lock(LockMode mode, bool block = true);
|
||||||
|
bool unlock();
|
||||||
|
bool isLocked() const;
|
||||||
|
LockMode lockMode() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
Qt::HANDLE wmutex;
|
||||||
|
Qt::HANDLE rmutex;
|
||||||
|
QVector<Qt::HANDLE> rmutexes;
|
||||||
|
QString mutexname;
|
||||||
|
|
||||||
|
Qt::HANDLE getMutexHandle(int idx, bool doCreate);
|
||||||
|
bool waitMutex(Qt::HANDLE mutex, bool doBlock);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
LockMode m_lock_mode;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,115 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Solutions component.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** You may use this file under the terms of the BSD license as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||||
|
** of its contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include "qtlockedfile.h"
|
||||||
|
|
||||||
|
bool QtLockedFile::lock(LockMode mode, bool block)
|
||||||
|
{
|
||||||
|
if (!isOpen()) {
|
||||||
|
qWarning("QtLockedFile::lock(): file is not opened");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == NoLock)
|
||||||
|
return unlock();
|
||||||
|
|
||||||
|
if (mode == m_lock_mode)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (m_lock_mode != NoLock)
|
||||||
|
unlock();
|
||||||
|
|
||||||
|
struct flock fl;
|
||||||
|
fl.l_whence = SEEK_SET;
|
||||||
|
fl.l_start = 0;
|
||||||
|
fl.l_len = 0;
|
||||||
|
fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK;
|
||||||
|
int cmd = block ? F_SETLKW : F_SETLK;
|
||||||
|
int ret = fcntl(handle(), cmd, &fl);
|
||||||
|
|
||||||
|
if (ret == -1) {
|
||||||
|
if (errno != EINTR && errno != EAGAIN)
|
||||||
|
qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
m_lock_mode = mode;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool QtLockedFile::unlock()
|
||||||
|
{
|
||||||
|
if (!isOpen()) {
|
||||||
|
qWarning("QtLockedFile::unlock(): file is not opened");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLocked())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
struct flock fl;
|
||||||
|
fl.l_whence = SEEK_SET;
|
||||||
|
fl.l_start = 0;
|
||||||
|
fl.l_len = 0;
|
||||||
|
fl.l_type = F_UNLCK;
|
||||||
|
int ret = fcntl(handle(), F_SETLKW, &fl);
|
||||||
|
|
||||||
|
if (ret == -1) {
|
||||||
|
qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_lock_mode = NoLock;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QtLockedFile::~QtLockedFile()
|
||||||
|
{
|
||||||
|
if (isOpen())
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,347 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Solutions component.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** You may use this file under the terms of the BSD license as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||||
|
** of its contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "qtsingleapplication.h"
|
||||||
|
#include "qtlocalpeer.h"
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class QtSingleApplication qtsingleapplication.h
|
||||||
|
\brief The QtSingleApplication class provides an API to detect and
|
||||||
|
communicate with running instances of an application.
|
||||||
|
|
||||||
|
This class allows you to create applications where only one
|
||||||
|
instance should be running at a time. I.e., if the user tries to
|
||||||
|
launch another instance, the already running instance will be
|
||||||
|
activated instead. Another usecase is a client-server system,
|
||||||
|
where the first started instance will assume the role of server,
|
||||||
|
and the later instances will act as clients of that server.
|
||||||
|
|
||||||
|
By default, the full path of the executable file is used to
|
||||||
|
determine whether two processes are instances of the same
|
||||||
|
application. You can also provide an explicit identifier string
|
||||||
|
that will be compared instead.
|
||||||
|
|
||||||
|
The application should create the QtSingleApplication object early
|
||||||
|
in the startup phase, and call isRunning() to find out if another
|
||||||
|
instance of this application is already running. If isRunning()
|
||||||
|
returns false, it means that no other instance is running, and
|
||||||
|
this instance has assumed the role as the running instance. In
|
||||||
|
this case, the application should continue with the initialization
|
||||||
|
of the application user interface before entering the event loop
|
||||||
|
with exec(), as normal.
|
||||||
|
|
||||||
|
The messageReceived() signal will be emitted when the running
|
||||||
|
application receives messages from another instance of the same
|
||||||
|
application. When a message is received it might be helpful to the
|
||||||
|
user to raise the application so that it becomes visible. To
|
||||||
|
facilitate this, QtSingleApplication provides the
|
||||||
|
setActivationWindow() function and the activateWindow() slot.
|
||||||
|
|
||||||
|
If isRunning() returns true, another instance is already
|
||||||
|
running. It may be alerted to the fact that another instance has
|
||||||
|
started by using the sendMessage() function. Also data such as
|
||||||
|
startup parameters (e.g. the name of the file the user wanted this
|
||||||
|
new instance to open) can be passed to the running instance with
|
||||||
|
this function. Then, the application should terminate (or enter
|
||||||
|
client mode).
|
||||||
|
|
||||||
|
If isRunning() returns true, but sendMessage() fails, that is an
|
||||||
|
indication that the running instance is frozen.
|
||||||
|
|
||||||
|
Here's an example that shows how to convert an existing
|
||||||
|
application to use QtSingleApplication. It is very simple and does
|
||||||
|
not make use of all QtSingleApplication's functionality (see the
|
||||||
|
examples for that).
|
||||||
|
|
||||||
|
\code
|
||||||
|
// Original
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
MyMainWidget mmw;
|
||||||
|
mmw.show();
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Single instance
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
QtSingleApplication app(argc, argv);
|
||||||
|
|
||||||
|
if (app.isRunning())
|
||||||
|
return !app.sendMessage(someDataString);
|
||||||
|
|
||||||
|
MyMainWidget mmw;
|
||||||
|
app.setActivationWindow(&mmw);
|
||||||
|
mmw.show();
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
Once this QtSingleApplication instance is destroyed (normally when
|
||||||
|
the process exits or crashes), when the user next attempts to run the
|
||||||
|
application this instance will not, of course, be encountered. The
|
||||||
|
next instance to call isRunning() or sendMessage() will assume the
|
||||||
|
role as the new running instance.
|
||||||
|
|
||||||
|
For console (non-GUI) applications, QtSingleCoreApplication may be
|
||||||
|
used instead of this class, to avoid the dependency on the QtGui
|
||||||
|
library.
|
||||||
|
|
||||||
|
\sa QtSingleCoreApplication
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void QtSingleApplication::sysInit(const QString &appId)
|
||||||
|
{
|
||||||
|
actWin = 0;
|
||||||
|
peer = new QtLocalPeer(this, appId);
|
||||||
|
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Creates a QtSingleApplication object. The application identifier
|
||||||
|
will be QCoreApplication::applicationFilePath(). \a argc, \a
|
||||||
|
argv, and \a GUIenabled are passed on to the QAppliation constructor.
|
||||||
|
|
||||||
|
If you are creating a console application (i.e. setting \a
|
||||||
|
GUIenabled to false), you may consider using
|
||||||
|
QtSingleCoreApplication instead.
|
||||||
|
*/
|
||||||
|
|
||||||
|
QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled)
|
||||||
|
: QApplication(argc, argv, GUIenabled)
|
||||||
|
{
|
||||||
|
sysInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Creates a QtSingleApplication object with the application
|
||||||
|
identifier \a appId. \a argc and \a argv are passed on to the
|
||||||
|
QAppliation constructor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv)
|
||||||
|
: QApplication(argc, argv)
|
||||||
|
{
|
||||||
|
sysInit(appId);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < 0x050000
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Creates a QtSingleApplication object. The application identifier
|
||||||
|
will be QCoreApplication::applicationFilePath(). \a argc, \a
|
||||||
|
argv, and \a type are passed on to the QAppliation constructor.
|
||||||
|
*/
|
||||||
|
QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type)
|
||||||
|
: QApplication(argc, argv, type)
|
||||||
|
{
|
||||||
|
sysInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# if defined(Q_WS_X11)
|
||||||
|
/*!
|
||||||
|
Special constructor for X11, ref. the documentation of
|
||||||
|
QApplication's corresponding constructor. The application identifier
|
||||||
|
will be QCoreApplication::applicationFilePath(). \a dpy, \a visual,
|
||||||
|
and \a cmap are passed on to the QApplication constructor.
|
||||||
|
*/
|
||||||
|
QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap)
|
||||||
|
: QApplication(dpy, visual, cmap)
|
||||||
|
{
|
||||||
|
sysInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Special constructor for X11, ref. the documentation of
|
||||||
|
QApplication's corresponding constructor. The application identifier
|
||||||
|
will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a
|
||||||
|
argv, \a visual, and \a cmap are passed on to the QApplication
|
||||||
|
constructor.
|
||||||
|
*/
|
||||||
|
QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
|
||||||
|
: QApplication(dpy, argc, argv, visual, cmap)
|
||||||
|
{
|
||||||
|
sysInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Special constructor for X11, ref. the documentation of
|
||||||
|
QApplication's corresponding constructor. The application identifier
|
||||||
|
will be \a appId. \a dpy, \a argc, \a
|
||||||
|
argv, \a visual, and \a cmap are passed on to the QApplication
|
||||||
|
constructor.
|
||||||
|
*/
|
||||||
|
QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
|
||||||
|
: QApplication(dpy, argc, argv, visual, cmap)
|
||||||
|
{
|
||||||
|
sysInit(appId);
|
||||||
|
}
|
||||||
|
# endif // Q_WS_X11
|
||||||
|
#endif // QT_VERSION < 0x050000
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns true if another instance of this application is running;
|
||||||
|
otherwise false.
|
||||||
|
|
||||||
|
This function does not find instances of this application that are
|
||||||
|
being run by a different user (on Windows: that are running in
|
||||||
|
another session).
|
||||||
|
|
||||||
|
\sa sendMessage()
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool QtSingleApplication::isRunning()
|
||||||
|
{
|
||||||
|
return peer->isClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Tries to send the text \a message to the currently running
|
||||||
|
instance. The QtSingleApplication object in the running instance
|
||||||
|
will emit the messageReceived() signal when it receives the
|
||||||
|
message.
|
||||||
|
|
||||||
|
This function returns true if the message has been sent to, and
|
||||||
|
processed by, the current instance. If there is no instance
|
||||||
|
currently running, or if the running instance fails to process the
|
||||||
|
message within \a timeout milliseconds, this function return false.
|
||||||
|
|
||||||
|
\sa isRunning(), messageReceived()
|
||||||
|
*/
|
||||||
|
bool QtSingleApplication::sendMessage(const QString &message, int timeout)
|
||||||
|
{
|
||||||
|
return peer->sendMessage(message, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the application identifier. Two processes with the same
|
||||||
|
identifier will be regarded as instances of the same application.
|
||||||
|
*/
|
||||||
|
QString QtSingleApplication::id() const
|
||||||
|
{
|
||||||
|
return peer->applicationId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Sets the activation window of this application to \a aw. The
|
||||||
|
activation window is the widget that will be activated by
|
||||||
|
activateWindow(). This is typically the application's main window.
|
||||||
|
|
||||||
|
If \a activateOnMessage is true (the default), the window will be
|
||||||
|
activated automatically every time a message is received, just prior
|
||||||
|
to the messageReceived() signal being emitted.
|
||||||
|
|
||||||
|
\sa activateWindow(), messageReceived()
|
||||||
|
*/
|
||||||
|
|
||||||
|
void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
|
||||||
|
{
|
||||||
|
actWin = aw;
|
||||||
|
if (activateOnMessage)
|
||||||
|
connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
|
||||||
|
else
|
||||||
|
disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the applications activation window if one has been set by
|
||||||
|
calling setActivationWindow(), otherwise returns 0.
|
||||||
|
|
||||||
|
\sa setActivationWindow()
|
||||||
|
*/
|
||||||
|
QWidget* QtSingleApplication::activationWindow() const
|
||||||
|
{
|
||||||
|
return actWin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
De-minimizes, raises, and activates this application's activation window.
|
||||||
|
This function does nothing if no activation window has been set.
|
||||||
|
|
||||||
|
This is a convenience function to show the user that this
|
||||||
|
application instance has been activated when he has tried to start
|
||||||
|
another instance.
|
||||||
|
|
||||||
|
This function should typically be called in response to the
|
||||||
|
messageReceived() signal. By default, that will happen
|
||||||
|
automatically, if an activation window has been set.
|
||||||
|
|
||||||
|
\sa setActivationWindow(), messageReceived(), initialize()
|
||||||
|
*/
|
||||||
|
void QtSingleApplication::activateWindow()
|
||||||
|
{
|
||||||
|
if (actWin) {
|
||||||
|
actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
|
||||||
|
actWin->raise();
|
||||||
|
actWin->activateWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QtSingleApplication::messageReceived(const QString& message)
|
||||||
|
|
||||||
|
This signal is emitted when the current instance receives a \a
|
||||||
|
message from another instance of this application.
|
||||||
|
|
||||||
|
\sa sendMessage(), setActivationWindow(), activateWindow()
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QtSingleApplication::initialize(bool dummy = true)
|
||||||
|
|
||||||
|
\obsolete
|
||||||
|
*/
|
|
@ -0,0 +1,105 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Solutions component.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** You may use this file under the terms of the BSD license as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||||
|
** of its contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QTSINGLEAPPLICATION_H
|
||||||
|
#define QTSINGLEAPPLICATION_H
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
class QtLocalPeer;
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT)
|
||||||
|
# define QT_QTSINGLEAPPLICATION_EXPORT
|
||||||
|
# elif defined(QT_QTSINGLEAPPLICATION_IMPORT)
|
||||||
|
# if defined(QT_QTSINGLEAPPLICATION_EXPORT)
|
||||||
|
# undef QT_QTSINGLEAPPLICATION_EXPORT
|
||||||
|
# endif
|
||||||
|
# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport)
|
||||||
|
# elif defined(QT_QTSINGLEAPPLICATION_EXPORT)
|
||||||
|
# undef QT_QTSINGLEAPPLICATION_EXPORT
|
||||||
|
# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define QT_QTSINGLEAPPLICATION_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtSingleApplication(int &argc, char **argv, bool GUIenabled = true);
|
||||||
|
QtSingleApplication(const QString &id, int &argc, char **argv);
|
||||||
|
#if QT_VERSION < 0x050000
|
||||||
|
QtSingleApplication(int &argc, char **argv, Type type);
|
||||||
|
# if defined(Q_WS_X11)
|
||||||
|
QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
|
||||||
|
QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
|
||||||
|
QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
|
||||||
|
# endif // Q_WS_X11
|
||||||
|
#endif // QT_VERSION < 0x050000
|
||||||
|
|
||||||
|
bool isRunning();
|
||||||
|
QString id() const;
|
||||||
|
|
||||||
|
void setActivationWindow(QWidget* aw, bool activateOnMessage = true);
|
||||||
|
QWidget* activationWindow() const;
|
||||||
|
|
||||||
|
// Obsolete:
|
||||||
|
void initialize(bool dummy = true)
|
||||||
|
{ isRunning(); Q_UNUSED(dummy) }
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
bool sendMessage(const QString &message, int timeout = 5000);
|
||||||
|
void activateWindow();
|
||||||
|
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void messageReceived(const QString &message);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void sysInit(const QString &appId = QString());
|
||||||
|
QtLocalPeer *peer;
|
||||||
|
QWidget *actWin;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QTSINGLEAPPLICATION_H
|
|
@ -0,0 +1,24 @@
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/comboxwidget.cpp \
|
||||||
|
$$PWD/confirmareawidget.cpp \
|
||||||
|
$$PWD/dropdownmenu.cpp \
|
||||||
|
$$PWD/monitortimethread.cpp \
|
||||||
|
$$PWD/timeshowwidget.cpp \
|
||||||
|
$$PWD/widget.cpp \
|
||||||
|
$$PWD/verticalscroll60.cpp \
|
||||||
|
$$PWD/qtsingleapplication.cpp \
|
||||||
|
$$PWD/qtlocalpeer.cpp \
|
||||||
|
$$PWD/qtlockedfile.cpp \
|
||||||
|
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/comboxwidget.h \
|
||||||
|
$$PWD/confirmareawidget.h \
|
||||||
|
$$PWD/dropdownmenu.h \
|
||||||
|
$$PWD/monitortimethread.h \
|
||||||
|
$$PWD/timeshowwidget.h \
|
||||||
|
$$PWD/widget.h \
|
||||||
|
$$PWD/verticalscroll60.h \
|
||||||
|
$$PWD/qtsingleapplication.h \
|
||||||
|
$$PWD/qtlocalpeer.h \
|
||||||
|
$$PWD/qtlockedfile.h \
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "timeshowwidget.h"
|
||||||
|
#include <QPainterPath>
|
||||||
|
|
||||||
|
BlankShadowWidget::BlankShadowWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
this->setFixedSize(312, 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlankShadowWidget::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QStyleOption opt;
|
||||||
|
opt.init(this);
|
||||||
|
QPainter p(this);
|
||||||
|
QPainterPath path;
|
||||||
|
opt.rect.adjust(0,0,0,0);
|
||||||
|
p.setBrush(opt.palette.color(QPalette::Button));
|
||||||
|
p.setOpacity(0.5);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.drawRoundedRect(opt.rect, 6, 6);
|
||||||
|
p.setRenderHint(QPainter::Antialiasing); //反锯齿
|
||||||
|
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
|
||||||
|
}
|
||||||
|
|
||||||
|
timeShowWidget::timeShowWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
initMemberVariable();
|
||||||
|
setLabelFont();
|
||||||
|
initLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void timeShowWidget::initMemberVariable()
|
||||||
|
{
|
||||||
|
this->setContentsMargins(0, 0, 0, 0);
|
||||||
|
this->setFixedWidth(372);
|
||||||
|
this->setFixedHeight(155);
|
||||||
|
m_pHourLabel = new QLabel(QObject::tr("hours"), this);
|
||||||
|
m_pHourLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
m_pHourLabel->setFixedWidth(100);
|
||||||
|
// m_pHourLabel->setMaximumWidth(100);
|
||||||
|
m_pHourLabel->setFixedHeight(30);
|
||||||
|
|
||||||
|
m_pMinuteLabel = new QLabel(QObject::tr("minute"), this);
|
||||||
|
m_pMinuteLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
m_pMinuteLabel->setFixedWidth(100);
|
||||||
|
// m_pMinuteLabel->setMaximumWidth(100);
|
||||||
|
m_pMinuteLabel->setFixedHeight(30);
|
||||||
|
|
||||||
|
m_pSeparatedLabel = new QLabel(":", this);
|
||||||
|
m_pSeparatedLabel->setFixedSize(8, 45);
|
||||||
|
|
||||||
|
m_pHourRollWidget = new VerticalScroll_60(23, this);
|
||||||
|
m_pMinuteRollWidget = new VerticalScroll_60(59, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void timeShowWidget::initLayout()
|
||||||
|
{
|
||||||
|
//此种指定坐标写法,不采用布局,不够规范,也会有一些问题。后续有时间会重新规划布局统一调整写法。
|
||||||
|
m_pHourLabel->move(86, 0);
|
||||||
|
m_pMinuteLabel->move(191, 0);
|
||||||
|
m_pHourRollWidget->move(117, 10);
|
||||||
|
m_pSeparatedLabel->move(182, 60);
|
||||||
|
m_pMinuteRollWidget->move(222, 10);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void timeShowWidget::setLabelFont()
|
||||||
|
{
|
||||||
|
QFont font = m_pHourLabel->font();
|
||||||
|
font.setPixelSize(14);
|
||||||
|
// m_pHourLabel->setFont(font);
|
||||||
|
|
||||||
|
font = m_pMinuteLabel->font();
|
||||||
|
font.setPixelSize(14);
|
||||||
|
// m_pHourLabel->setFont(font);
|
||||||
|
|
||||||
|
font = m_pSeparatedLabel->font();
|
||||||
|
font.setPixelSize(30);
|
||||||
|
m_pSeparatedLabel->setFont(font);
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef TIMESHOWWIDGET_H
|
||||||
|
#define TIMESHOWWIDGET_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QApplication>
|
||||||
|
#include "verticalscroll60.h"
|
||||||
|
|
||||||
|
/* 含有底色无控件的窗体类,中间选中条目底色 */
|
||||||
|
class BlankShadowWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BlankShadowWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 显示中间部分的widget */
|
||||||
|
class timeShowWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit timeShowWidget(QWidget *parent = nullptr);
|
||||||
|
VerticalScroll_60 *m_pHourRollWidget;
|
||||||
|
VerticalScroll_60 *m_pMinuteRollWidget;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initMemberVariable();
|
||||||
|
void initLayout();
|
||||||
|
void setLabelFont();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLabel *m_pHourLabel;
|
||||||
|
QLabel *m_pMinuteLabel;
|
||||||
|
QLabel *m_pSeparatedLabel;
|
||||||
|
signals:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TIMESHOWWIDGET_H
|
|
@ -0,0 +1,284 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "verticalscroll60.h"
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
VerticalScroll_60::VerticalScroll_60(int m_maxRange, QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
m_minRange(0), //最小值默认为0 // The minimum value defaults to 0
|
||||||
|
m_maxRange(m_maxRange), //最大值默认60 // Max default 24
|
||||||
|
m_currentValue(0), //当前值默认0 // Current value defaults to 0
|
||||||
|
isDragging(false),
|
||||||
|
m_deviation(0), //默认偏移量为0 // The default offset is 0
|
||||||
|
m_numSize(4),
|
||||||
|
interval(1), //间隔默认1 // Interval default 1
|
||||||
|
devide(4) //默认分成4格 // Divided into 4 grids by default
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
homingAni = new QPropertyAnimation(this, "deviation");
|
||||||
|
homingAni->setDuration(300);
|
||||||
|
homingAni->setEasingCurve(QEasingCurve::OutQuad);
|
||||||
|
}
|
||||||
|
|
||||||
|
VerticalScroll_60::~VerticalScroll_60()
|
||||||
|
{
|
||||||
|
delete homingAni;
|
||||||
|
qDebug()<<"-------VerticalScroll_60---------";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 设置范围 set range
|
||||||
|
* int min 最小值
|
||||||
|
* int max 最大值
|
||||||
|
*/
|
||||||
|
void VerticalScroll_60::setRange(int min, int max)
|
||||||
|
{
|
||||||
|
m_minRange = min;
|
||||||
|
m_maxRange = max;
|
||||||
|
if (m_currentValue < min)
|
||||||
|
m_currentValue = min;
|
||||||
|
|
||||||
|
if (m_currentValue > max)
|
||||||
|
m_currentValue = max;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取当前值
|
||||||
|
//Get current value
|
||||||
|
int VerticalScroll_60::readValue()
|
||||||
|
{
|
||||||
|
return m_currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerticalScroll_60::mousePressEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
qDebug()<<"mouse pressed on vertical scroll";
|
||||||
|
homingAni->stop();
|
||||||
|
isDragging = true;
|
||||||
|
m_mouseSrcPos = e->pos().y();
|
||||||
|
QWidget::mousePressEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerticalScroll_60::mouseMoveEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
if (isDragging) {
|
||||||
|
if( m_currentValue == m_minRange && e->pos().y() >= m_mouseSrcPos ) {
|
||||||
|
m_currentValue = m_maxRange;
|
||||||
|
} else if( m_currentValue == m_maxRange && e->pos().y() <= m_mouseSrcPos ) {
|
||||||
|
m_currentValue = m_minRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_deviation = e->pos().y() - m_mouseSrcPos;
|
||||||
|
//若移动速度过快,则进行限制
|
||||||
|
// If the movement speed is too fast, limit it
|
||||||
|
if (m_deviation > (height() - 1) / devide) {
|
||||||
|
m_deviation = (height() - 1) / devide;
|
||||||
|
} else if (m_deviation < -(height() - 1) / devide) {
|
||||||
|
m_deviation = -(height() - 1) / devide;
|
||||||
|
}
|
||||||
|
emit deviationChange((int)m_deviation / ((height() - 1) / devide));
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerticalScroll_60::mouseReleaseEvent(QMouseEvent *)
|
||||||
|
{
|
||||||
|
if (isDragging) {
|
||||||
|
isDragging = false;
|
||||||
|
homing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerticalScroll_60::wheelEvent(QWheelEvent *event)
|
||||||
|
{
|
||||||
|
if (event->delta() > 0) {
|
||||||
|
if(m_currentValue <= m_minRange)
|
||||||
|
m_currentValue = m_maxRange;
|
||||||
|
else
|
||||||
|
m_currentValue -= 1;
|
||||||
|
} else {
|
||||||
|
if (m_currentValue >= m_maxRange)
|
||||||
|
m_currentValue = m_minRange;
|
||||||
|
else
|
||||||
|
m_currentValue += 1;
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerticalScroll_60::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
int Height = height() - 1;
|
||||||
|
|
||||||
|
if ( m_deviation >= Height / devide && m_currentValue > m_minRange ) {
|
||||||
|
m_mouseSrcPos += Height / devide;
|
||||||
|
m_deviation -= Height / devide;
|
||||||
|
m_currentValue -= interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_deviation <= -Height / devide && m_currentValue < m_maxRange ) {
|
||||||
|
m_mouseSrcPos -= Height / devide;
|
||||||
|
m_deviation += Height / devide;
|
||||||
|
m_currentValue += interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
//middle number 中间数
|
||||||
|
paintNum(painter, m_currentValue, m_deviation);
|
||||||
|
|
||||||
|
// Numbers on both sides 两侧数字
|
||||||
|
if (m_currentValue != m_minRange) {
|
||||||
|
paintNum(painter, m_currentValue - interval, m_deviation - Height / devide);
|
||||||
|
} else {
|
||||||
|
paintNum(painter, m_maxRange, m_deviation - Height / devide);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_currentValue != m_maxRange) {
|
||||||
|
paintNum(painter, m_currentValue + interval, m_deviation + Height / devide);
|
||||||
|
} else {
|
||||||
|
paintNum(painter, m_minRange, m_deviation + Height / devide);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=2; i <= devide/2; ++i) { //有BUG
|
||||||
|
if (m_currentValue - interval * i >= m_minRange)
|
||||||
|
paintNum(painter, m_currentValue - interval * i, m_deviation - Height / devide * i);
|
||||||
|
if (m_currentValue + interval * i <= m_maxRange)
|
||||||
|
paintNum(painter, m_currentValue + interval * i, m_deviation + Height / devide * i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 根据偏移量描绘数字
|
||||||
|
* Drawing numbers
|
||||||
|
* int num 需要显示的数字
|
||||||
|
* int deviation 数字相对中间的偏移量
|
||||||
|
*/
|
||||||
|
void VerticalScroll_60::paintNum(QPainter &painter, int num, int deviation)
|
||||||
|
{
|
||||||
|
int Width = width() - 1;
|
||||||
|
int Height = height() - 1;
|
||||||
|
int size = (Height - qAbs(deviation)) / m_numSize; // The larger the offset, the smaller the number 偏移量越大,数字越小
|
||||||
|
|
||||||
|
int transparency = 255 - 255 * qAbs(deviation) / Height;
|
||||||
|
|
||||||
|
int height = Height / devide;
|
||||||
|
|
||||||
|
int y = Height / 2 + deviation - height / 2;
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(size);
|
||||||
|
painter.setFont(font);
|
||||||
|
if (deviation <= 5 && deviation >= -5) {
|
||||||
|
transparency = 255;
|
||||||
|
} else {
|
||||||
|
transparency = 30;
|
||||||
|
if (m_bSelectColor) {
|
||||||
|
transparency = 255 * 0.23 - 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QColor color;
|
||||||
|
color = qApp->palette().color(QPalette::PlaceholderText);
|
||||||
|
color.setAlphaF(transparency/100.0);
|
||||||
|
painter.setPen(color);
|
||||||
|
if ( y >= 0 && y + height < Height) {
|
||||||
|
painter.drawText(QRectF(0, y, Width, height),
|
||||||
|
Qt::AlignCenter,
|
||||||
|
change_NUM_to_str(num));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//单位变双位
|
||||||
|
// Unit to double
|
||||||
|
QString VerticalScroll_60::change_NUM_to_str(int alarmHour)
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
if (alarmHour < 10) {
|
||||||
|
QString hours_str = QString::number(alarmHour);
|
||||||
|
str = "0" + hours_str;
|
||||||
|
} else {
|
||||||
|
str = QString::number(alarmHour);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 使选中的数字回到屏幕中间
|
||||||
|
* Bring the selected number back to the middle of the screen
|
||||||
|
*/
|
||||||
|
void VerticalScroll_60::homing()
|
||||||
|
{
|
||||||
|
if (m_deviation > height() / 10) {
|
||||||
|
homingAni->setStartValue( ( height() - 1 ) / 8 - m_deviation);
|
||||||
|
homingAni->setEndValue(0);
|
||||||
|
m_currentValue -= interval;
|
||||||
|
} else if (m_deviation > -height() / 10) {
|
||||||
|
homingAni->setStartValue(m_deviation);
|
||||||
|
homingAni->setEndValue(0);
|
||||||
|
} else if (m_deviation < -height() / 10) {
|
||||||
|
homingAni->setStartValue(-(height() - 1) / 8 - m_deviation);
|
||||||
|
homingAni->setEndValue(0);
|
||||||
|
m_currentValue += interval;
|
||||||
|
}
|
||||||
|
emit currentValueChanged(m_currentValue);
|
||||||
|
homingAni->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
int VerticalScroll_60::readDeviation()
|
||||||
|
{
|
||||||
|
return m_deviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerticalScroll_60::setDeviation(int n)
|
||||||
|
{
|
||||||
|
m_deviation = n;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerticalScroll_60::setupUi(QWidget *VerticalScroll_60)
|
||||||
|
{
|
||||||
|
if (VerticalScroll_60->objectName().isEmpty())
|
||||||
|
VerticalScroll_60->setObjectName(QString::fromUtf8("VerticalScroll_60"));
|
||||||
|
VerticalScroll_60->resize(40, 144);
|
||||||
|
|
||||||
|
retranslateUi(VerticalScroll_60);
|
||||||
|
|
||||||
|
QMetaObject::connectSlotsByName(VerticalScroll_60);
|
||||||
|
} // setupUi
|
||||||
|
|
||||||
|
void VerticalScroll_60::retranslateUi(QWidget *VerticalScroll_60)
|
||||||
|
{
|
||||||
|
VerticalScroll_60->setWindowTitle(QApplication::translate("VerticalScroll_60", "VerticalScroll_60", nullptr));
|
||||||
|
} // retranslateUi
|
||||||
|
|
||||||
|
void VerticalScroll_60::setColor(bool selectColor)
|
||||||
|
{
|
||||||
|
m_bSelectColor = selectColor;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerticalScroll_60::setCurrentValue(int value)
|
||||||
|
{
|
||||||
|
m_currentValue = value;
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VERTICALSCROLL60_H
|
||||||
|
#define VERTICALSCROLL60_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPropertyAnimation>
|
||||||
|
#include <QPainter>
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
|
class VerticalScroll_60;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class VerticalScroll_60 : public QWidget
|
||||||
|
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int deviation READ readDeviation WRITE setDeviation )
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit VerticalScroll_60(int m_maxRange, QWidget *parent = 0);
|
||||||
|
|
||||||
|
~VerticalScroll_60();
|
||||||
|
|
||||||
|
// set range 设置范围
|
||||||
|
void setRange(int min, int max);
|
||||||
|
|
||||||
|
// Get current value 获取当前值
|
||||||
|
int readValue();
|
||||||
|
|
||||||
|
//Currently selected value 当前选中的值
|
||||||
|
int m_currentValue;
|
||||||
|
|
||||||
|
void setupUi(QWidget *VerticalScroll_60);
|
||||||
|
|
||||||
|
void retranslateUi(QWidget *VerticalScroll_60);
|
||||||
|
|
||||||
|
void setColor(bool selectColor);
|
||||||
|
|
||||||
|
void setCurrentValue(int value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
|
||||||
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
|
|
||||||
|
void mouseReleaseEvent(QMouseEvent *);
|
||||||
|
|
||||||
|
void wheelEvent(QWheelEvent *);
|
||||||
|
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
|
// Drawing numbers 描绘数字
|
||||||
|
void paintNum(QPainter &painter, int num, int deviation);
|
||||||
|
|
||||||
|
//Bring the selected number back to the middle of the screen 使选中的数字回到屏幕中间
|
||||||
|
void homing();
|
||||||
|
|
||||||
|
// Mouse movement offset, default is 0 鼠标移动偏移量,默认为0
|
||||||
|
int readDeviation();
|
||||||
|
|
||||||
|
// Set offset 设置偏移量
|
||||||
|
void setDeviation(int n);
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void currentValueChanged(int value);
|
||||||
|
|
||||||
|
void deviationChange(int deviation);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
Ui::VerticalScroll_60 *ui;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_minRange; //最小值 // minimum value
|
||||||
|
int m_maxRange; //最大值 // Maximum
|
||||||
|
|
||||||
|
bool isDragging; //鼠标是否按下 // Muse down
|
||||||
|
int m_deviation; //偏移量,记录鼠标按下后移动的垂直距离 // Offset, record the vertical distance after mouse is pressed
|
||||||
|
int m_mouseSrcPos;
|
||||||
|
int m_numSize;
|
||||||
|
bool m_bSelectColor = false;
|
||||||
|
QPropertyAnimation *homingAni;
|
||||||
|
const int interval; //间隔大小 // Interval size
|
||||||
|
const int devide; //分隔数量 // Number of partitions
|
||||||
|
QString change_NUM_to_str(int alarmHour);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VERTICALSCROLL60_H
|
|
@ -0,0 +1,685 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "widget.h"
|
||||||
|
#include <QPainterPath>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
|
/* widget主类 */
|
||||||
|
Widget::Widget(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
// 国际化
|
||||||
|
initTranslation();
|
||||||
|
|
||||||
|
// 初始化成员变量
|
||||||
|
initMemberVariable();
|
||||||
|
|
||||||
|
// 初始化界面布局
|
||||||
|
initLayout();
|
||||||
|
|
||||||
|
// 初始化所有成员变量的信号槽
|
||||||
|
initSignalSlots();
|
||||||
|
|
||||||
|
// 初始化gsetting值
|
||||||
|
initGsetting();
|
||||||
|
|
||||||
|
// 根据版本设置gsetting值
|
||||||
|
getTimeShutdownVersion();
|
||||||
|
|
||||||
|
// 创建当前动作
|
||||||
|
createActions();
|
||||||
|
|
||||||
|
// 初始化当前的托盘栏图标
|
||||||
|
createTrayIcon();
|
||||||
|
|
||||||
|
setIcon(QIcon::fromTheme("kylin-alarm-clock", QIcon("://image/time_shutdown.svg")));
|
||||||
|
|
||||||
|
// 获取保存在gsetting中的定时关机设置状态
|
||||||
|
getTimedShutdownState();
|
||||||
|
|
||||||
|
// 获取当前关机频率
|
||||||
|
getComBoxShutdownFrequency();
|
||||||
|
|
||||||
|
// 获取保存在gsetting中的设置的时间
|
||||||
|
getShutDownTime();
|
||||||
|
|
||||||
|
// 初始化定时关机显示界面
|
||||||
|
initTimeShutdownWidget();
|
||||||
|
|
||||||
|
// 初始化下拉框状态
|
||||||
|
initDropDownBoxLabelStatus();
|
||||||
|
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
this->setWindowState(Qt::WindowNoState);
|
||||||
|
this->setWindowIcon(QIcon::fromTheme("kylin-alarm-clock", QIcon("://image/time_shutdown.svg")));
|
||||||
|
QDesktopWidget *pDesk = QApplication::desktop();
|
||||||
|
move((pDesk->width() - this->width()) / 2, (pDesk->height() - this->height()) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget::~Widget()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::initTranslation()
|
||||||
|
{
|
||||||
|
m_ptranslator = new QTranslator;
|
||||||
|
QTranslator *translator_qt = new QTranslator;
|
||||||
|
//获取系统语言环境 选择翻译文件
|
||||||
|
if (m_ptranslator->load(QLocale(), QLatin1String("time-shutdown"), QLatin1String("_"), QLatin1String("/usr/share/ukui-time-shutdown/")))
|
||||||
|
QApplication::installTranslator(m_ptranslator);
|
||||||
|
else
|
||||||
|
qDebug() << "cannot load translator ukui-time-shutdown" << QLocale::system().name() << ".qm!";
|
||||||
|
|
||||||
|
if (translator_qt->load("/usr/share/qt5/translations/qt_"+QLocale::system().name()))
|
||||||
|
QApplication::installTranslator(translator_qt);
|
||||||
|
else
|
||||||
|
qDebug() << "cannot load translator ukui-time-shutdown" << QLocale::system().name() << ".qm!";
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::initMemberVariable()
|
||||||
|
{
|
||||||
|
this->setContentsMargins(0, 0, 0, 0);
|
||||||
|
this->setFixedSize(372, 339);
|
||||||
|
this->setWindowTitle(QObject::tr("time-shutdown"));
|
||||||
|
|
||||||
|
m_pVMainLayout = new QVBoxLayout();
|
||||||
|
m_pVMainLayout->setSpacing(0);
|
||||||
|
m_pVMainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
// 提示关机时间Label
|
||||||
|
//固定大小字体,代码或许可以简写
|
||||||
|
m_pTimeRemainLabel = new QLabel();
|
||||||
|
QFont font = m_pTimeRemainLabel->font();
|
||||||
|
font.setPixelSize(12);
|
||||||
|
m_pTimeRemainLabel->setFont(font);
|
||||||
|
m_pTimeRemainLabel->setAlignment(Qt::AlignHCenter);
|
||||||
|
m_pTimeRemainLabel->setFixedHeight(18);
|
||||||
|
|
||||||
|
/* 监听主题变化,修改提示关机时间Label字体颜色 */
|
||||||
|
initRemainLableFnotGsetting();
|
||||||
|
|
||||||
|
m_traslate = QObject::tr("next shutdown");
|
||||||
|
m_traslateHours = QObject::tr("hour");
|
||||||
|
m_traslateMinute = QObject::tr("minute");
|
||||||
|
|
||||||
|
// 初始化定时器
|
||||||
|
m_pMonitorTime = new QTimer();
|
||||||
|
|
||||||
|
// 初始化透明窗口,存在问题
|
||||||
|
m_pTransparentWidget = new QWidget();
|
||||||
|
m_pTransparentWidget->move(116, 82);
|
||||||
|
m_pTransparentWidget->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
m_pTransparentWidget->setFixedSize(380, 155);
|
||||||
|
|
||||||
|
m_pComBoxWidget = new comBoxWidget(this); //关机频率显示栏
|
||||||
|
m_pDropDownBox = new DropDownMenu();
|
||||||
|
m_pConfirmAreaWidget = new confirmAreaWidget(); //取消,确认显示区
|
||||||
|
m_pTimeShowWidget = new timeShowWidget(); //时间显示区
|
||||||
|
m_pBlankShadowWidget = new BlankShadowWidget(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::initLayout()
|
||||||
|
{
|
||||||
|
m_pBlankShadowWidget->move(30, 145);
|
||||||
|
m_pComBoxWidget->move(30, 22);
|
||||||
|
|
||||||
|
m_pVMainLayout->addItem(new QSpacerItem(10, 81));
|
||||||
|
m_pVMainLayout->addWidget(m_pTimeShowWidget);
|
||||||
|
m_pVMainLayout->addItem(new QSpacerItem(10, 16));
|
||||||
|
m_pVMainLayout->addWidget(m_pTimeRemainLabel);
|
||||||
|
m_pVMainLayout->addItem(new QSpacerItem(10, 24));
|
||||||
|
m_pVMainLayout->addWidget(m_pConfirmAreaWidget);
|
||||||
|
m_pVMainLayout->addItem(new QSpacerItem(10, 32, QSizePolicy::Fixed));
|
||||||
|
this->setLayout(m_pVMainLayout);
|
||||||
|
m_pTransparentWidget->setParent(this);
|
||||||
|
m_pDropDownBox->setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::initSignalSlots()
|
||||||
|
{
|
||||||
|
connect(m_pComBoxWidget, &comBoxWidget::comBoxWidgetClicked, this, &Widget::dropDownBoxShowHideSlots); // 下拉框点击槽函数
|
||||||
|
connect(m_pDropDownBox, &DropDownMenu::aboutToHide, this, &Widget::updatedropDownBoxSelectSlots); // ListWidget条目点击槽函数
|
||||||
|
connect(m_pMonitorTime, &QTimer::timeout, this, &Widget::threadSlots); // 定时器
|
||||||
|
connect(m_pConfirmAreaWidget->m_pConfirmButton, &QPushButton::clicked, this, &Widget::confirmButtonSlots); // 确认按钮槽函数
|
||||||
|
connect(m_pConfirmAreaWidget->m_pCancelButton, &QPushButton::clicked, this, &Widget::canceButtonSlots); // 取消按钮槽函数
|
||||||
|
}
|
||||||
|
|
||||||
|
//初始化下拉框选项选中状态
|
||||||
|
void Widget::initDropDownBoxLabelStatus()
|
||||||
|
{
|
||||||
|
m_pDropDownBox->initLabelStatus(m_WeekSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::initGsetting()
|
||||||
|
{
|
||||||
|
/* 链接time-shutdown的dgsetting接口 */
|
||||||
|
if(QGSettings::isSchemaInstalled(UKUITIMESHUTDOWN))
|
||||||
|
m_pTimeShutdown = new QGSettings(UKUITIMESHUTDOWN);
|
||||||
|
if (m_pTimeShutdown != nullptr) {
|
||||||
|
qDebug() << "当前的gsetting的key值" << m_pTimeShutdown->keys();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 监听主题变化,修改提示关机时间Label字体颜色 */
|
||||||
|
void Widget::initRemainLableFnotGsetting()
|
||||||
|
{
|
||||||
|
const QByteArray id(ORG_UKUI_STYLE);
|
||||||
|
if (QGSettings::isSchemaInstalled(id)) {
|
||||||
|
m_pGsettingFont = new QGSettings(id);
|
||||||
|
if (m_pGsettingFont) {
|
||||||
|
connect(m_pGsettingFont, &QGSettings::changed, this, [=](QString keyName) {
|
||||||
|
if (keyName == "styleName") {
|
||||||
|
m_pDropDownBox->repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::createActions()
|
||||||
|
{
|
||||||
|
minimizeAction = new QAction(tr("Mi&nimize"), this);
|
||||||
|
connect(minimizeAction, &QAction::triggered, this, &QWidget::hide);
|
||||||
|
|
||||||
|
restoreAction = new QAction(tr("&Restore"), this);
|
||||||
|
connect(restoreAction, &QAction::triggered, this, &QWidget::showNormal);
|
||||||
|
|
||||||
|
quitAction = new QAction(tr("&Quit"), this);
|
||||||
|
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::createTrayIcon()
|
||||||
|
{
|
||||||
|
trayIconMenu = new QMenu(this);
|
||||||
|
trayIconMenu->addAction(minimizeAction);
|
||||||
|
trayIconMenu->addAction(restoreAction);
|
||||||
|
trayIconMenu->addSeparator();
|
||||||
|
trayIconMenu->addAction(quitAction);
|
||||||
|
|
||||||
|
trayIcon = new QSystemTrayIcon(this);
|
||||||
|
trayIcon->setContextMenu(trayIconMenu);
|
||||||
|
trayIcon->setToolTip(QObject::tr("time-shutdown"));
|
||||||
|
connect(trayIcon, &QSystemTrayIcon::activated, this, &Widget::iconActivated);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::setIcon(QIcon icon)
|
||||||
|
{
|
||||||
|
trayIcon->setIcon(icon);
|
||||||
|
trayIcon->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取关机频率字符串 */
|
||||||
|
void Widget::getComBoxShutdownFrequency()
|
||||||
|
{
|
||||||
|
if (m_timeShotdown && m_pTimeShutdown != nullptr) {
|
||||||
|
QStringList keyList = m_pTimeShutdown->keys();
|
||||||
|
if (keyList.contains("shutdownfrequency")) {
|
||||||
|
m_selectIndexGsetting = m_pTimeShutdown->get("shutdownfrequency").toString();
|
||||||
|
m_WeekSelect = m_pDropDownBox->getWeekDateList(m_selectIndexGsetting);
|
||||||
|
}
|
||||||
|
if (determineShutdownTime()) { //有BUG
|
||||||
|
m_timeShotdown = false;
|
||||||
|
setTimeShutdownValue(false);
|
||||||
|
m_pConfirmAreaWidget->m_pCancelButton->setEnabled(false);
|
||||||
|
m_WeekSelect.clear();
|
||||||
|
m_WeekSelect.append(NEVER_SHUTDON);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
disconnect(m_pComBoxWidget, &comBoxWidget::comBoxWidgetClicked, this, &Widget::dropDownBoxShowHideSlots);
|
||||||
|
} else {
|
||||||
|
m_WeekSelect.clear();
|
||||||
|
m_WeekSelect.append(NEVER_SHUTDON);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取关机时间 */
|
||||||
|
void Widget::getShutDownTime()
|
||||||
|
{
|
||||||
|
if (m_timeShotdown && m_pTimeShutdown != nullptr) {
|
||||||
|
QStringList keyList = m_pTimeShutdown->keys();
|
||||||
|
if (keyList.contains("shutdowntime")) {
|
||||||
|
m_pShowDownTime = m_pTimeShutdown->get("shutdowntime").toString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_pShowDownTime.clear();
|
||||||
|
QTime time = QTime::currentTime();
|
||||||
|
int timeH = time.hour();
|
||||||
|
int timeM = time.minute();
|
||||||
|
m_hours = timeH;
|
||||||
|
m_minute = timeM;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QStringList timeList = m_pShowDownTime.split(":");
|
||||||
|
qDebug() << "timeList---->" << timeList.count();
|
||||||
|
if (timeList.count() > 1) {
|
||||||
|
m_hours = QString(timeList.at(0)).toInt();
|
||||||
|
m_minute = QString(timeList.at(1)).toInt();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取定时关机状态 */
|
||||||
|
bool Widget::getTimedShutdownState()
|
||||||
|
{
|
||||||
|
if (m_pTimeShutdown != nullptr) {
|
||||||
|
QStringList keyList = m_pTimeShutdown->keys();
|
||||||
|
if (keyList.contains("timeshutdown")) {
|
||||||
|
m_timeShotdown = m_pTimeShutdown->get("timeshutdown").toBool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!m_timeShotdown) {
|
||||||
|
m_pConfirmAreaWidget->m_pCancelButton->setEnabled(false);
|
||||||
|
}
|
||||||
|
return m_timeShotdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 初始化当前的启动界面 */
|
||||||
|
void Widget::initTimeShutdownWidget()
|
||||||
|
{
|
||||||
|
// 设置保存在gsetting中已设置好的时:分
|
||||||
|
m_pTimeShowWidget->m_pHourRollWidget->setCurrentValue(m_hours);
|
||||||
|
m_pTimeShowWidget->m_pMinuteRollWidget->setCurrentValue(m_minute);
|
||||||
|
m_pComBoxWidget->setLabelWeekSelect(m_pDropDownBox->getChosenList(m_WeekSelect));
|
||||||
|
|
||||||
|
if (m_timeShotdown) {
|
||||||
|
m_pMonitorTime->start(1000); // 开始轮训,每秒轮训一次
|
||||||
|
m_pTimeShowWidget->m_pHourRollWidget->setColor(false); // 修改时间界面透明度
|
||||||
|
m_pTimeShowWidget->m_pMinuteRollWidget->setColor(false);
|
||||||
|
m_pTimeShowWidget->m_pHourRollWidget->update();
|
||||||
|
m_pTimeShowWidget->m_pMinuteRollWidget->update();
|
||||||
|
m_pTransparentWidget->setVisible(true); // 置时间调试界面为不可滚动
|
||||||
|
m_pBlankShadowWidget->setVisible(true);
|
||||||
|
m_pShowDownTime = QStringLiteral("%1:%2").arg(m_hours).arg(m_minute);
|
||||||
|
m_pConfirmAreaWidget->m_pConfirmButton->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
m_pMonitorTime->stop();
|
||||||
|
m_pTimeShowWidget->m_pHourRollWidget->setColor(true);
|
||||||
|
m_pTimeShowWidget->m_pMinuteRollWidget->setColor(true);
|
||||||
|
m_pTimeShowWidget->m_pHourRollWidget->update();
|
||||||
|
m_pTimeShowWidget->m_pMinuteRollWidget->update();
|
||||||
|
m_pTransparentWidget->setVisible(false);
|
||||||
|
m_pBlankShadowWidget->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 设置定时关机时状态 */
|
||||||
|
void Widget::setTimeShutdownValue(bool value)
|
||||||
|
{
|
||||||
|
m_pTimeShutdown->set("timeshutdown", value);
|
||||||
|
m_timeShotdown = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 设置定时关机时间 */
|
||||||
|
void Widget::setShutDownTimeValue(QString value)
|
||||||
|
{
|
||||||
|
m_pTimeShutdown->set("shutdowntime", value);
|
||||||
|
m_pShowDownTime = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 设置定时关机频率 */
|
||||||
|
void Widget::setFrequencyValue(QString value)
|
||||||
|
{
|
||||||
|
m_pTimeShutdown->set("shutdownfrequency", value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::setWeekSelectShutdownFrequency()
|
||||||
|
{
|
||||||
|
if (m_WeekSelect[0] == NEVER_SHUTDON) {
|
||||||
|
setTimeShutdownValue(false);
|
||||||
|
} else if (m_WeekSelect[0] == ONLY_ONCE) {
|
||||||
|
setTimeShutdownValue(false);//存在问题,需要复查
|
||||||
|
canceButtonSlots();
|
||||||
|
} else {
|
||||||
|
setTimeShutdownValue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::setShutdownFrequency(QList<int> list)
|
||||||
|
{
|
||||||
|
if (list[0] == NEVER_SHUTDON) {
|
||||||
|
setTimeShutdownValue(false);
|
||||||
|
} else {
|
||||||
|
setTimeShutdownValue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::setNextShutDownTime()
|
||||||
|
{
|
||||||
|
QString shutDownTime;
|
||||||
|
if (m_WeekSelect[0] == NEVER_SHUTDON) {
|
||||||
|
m_pTimeRemainLabel->setVisible(false);
|
||||||
|
} else {
|
||||||
|
if (!m_pTimeRemainLabel->isVisible()) {
|
||||||
|
m_pTimeRemainLabel->setVisible(true);
|
||||||
|
}
|
||||||
|
shutDownTime = getCalculateShutDownTime(m_WeekSelect);
|
||||||
|
}
|
||||||
|
qDebug() << shutDownTime;
|
||||||
|
QStringList timeList = shutDownTime.split(":");
|
||||||
|
m_pTimeRemainLabel->setText(QStringLiteral("%1%2%3%4%5").arg(m_traslate).arg(timeList.at(0)).arg(m_traslateHours).arg(timeList.at(1)).arg(m_traslateMinute));
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取当前系统时间的星期所对应的选项,返回int型数字?
|
||||||
|
int Widget::getCurrentShutDownNum()
|
||||||
|
{
|
||||||
|
QDate date = QDateTime::currentDateTime().date();
|
||||||
|
return date.dayOfWeek() + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算下一次需要关机的星期
|
||||||
|
int Widget::caculateNextShutDownNum(int currentTmp, QList<int> weekSelect)
|
||||||
|
{
|
||||||
|
if(weekSelect[0] == EVERYDAY) {
|
||||||
|
weekSelect.clear();
|
||||||
|
if (currentTmp == SUNDAY) {
|
||||||
|
weekSelect.append(MONDAY);
|
||||||
|
weekSelect.append(SUNDAY);
|
||||||
|
} else {
|
||||||
|
weekSelect.append(currentTmp);
|
||||||
|
weekSelect.append(currentTmp + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime time = QTime::currentTime();
|
||||||
|
int timeHours = time.hour();
|
||||||
|
int minite = time.minute();
|
||||||
|
for (int i = 0; i < weekSelect.count(); i++) {
|
||||||
|
if ((weekSelect[i] == currentTmp
|
||||||
|
&& ((timeHours == m_pTimeShowWidget->m_pHourRollWidget->readValue()
|
||||||
|
&& minite <= m_pTimeShowWidget->m_pMinuteRollWidget->readValue())
|
||||||
|
|| timeHours < m_pTimeShowWidget->m_pHourRollWidget->readValue()))
|
||||||
|
|| weekSelect[i] > currentTmp) {
|
||||||
|
return weekSelect[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return weekSelect[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算出距离下次关机所需时间
|
||||||
|
QString Widget::getCalculateShutDownTime(QList<int> weekSelect)
|
||||||
|
{
|
||||||
|
m_currentTmp = getCurrentShutDownNum();
|
||||||
|
if (weekSelect[0] == ONLY_ONCE) {
|
||||||
|
m_nextCurrenttmp = m_currentTmp;
|
||||||
|
} else {
|
||||||
|
m_nextCurrenttmp = caculateNextShutDownNum(m_currentTmp, weekSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime time = QTime::currentTime();
|
||||||
|
int timeMinute = time.minute();
|
||||||
|
int timeHours = time.hour();
|
||||||
|
int hour, minute = 0;
|
||||||
|
qDebug() << "当前关机序号" << m_currentTmp << "下一次关机序号" << m_nextCurrenttmp;
|
||||||
|
|
||||||
|
if (m_nextCurrenttmp > m_currentTmp) {
|
||||||
|
hour = 24 * (m_nextCurrenttmp - m_currentTmp)- (timeHours - m_pTimeShowWidget->m_pHourRollWidget->readValue());
|
||||||
|
} else if (m_nextCurrenttmp < m_currentTmp) {
|
||||||
|
hour = 24 * (7 - (m_currentTmp - m_nextCurrenttmp)) - (timeHours - m_pTimeShowWidget->m_pHourRollWidget->readValue());
|
||||||
|
// 今天之前
|
||||||
|
} else if (m_nextCurrenttmp == m_currentTmp &&
|
||||||
|
timeHours > m_pTimeShowWidget->m_pHourRollWidget->readValue()) {
|
||||||
|
hour = 24 * (7 - (m_currentTmp - m_nextCurrenttmp)) -
|
||||||
|
(timeHours - m_pTimeShowWidget->m_pHourRollWidget->readValue());
|
||||||
|
} else if (m_nextCurrenttmp == m_currentTmp &&
|
||||||
|
timeHours <= m_pTimeShowWidget->m_pHourRollWidget->readValue()) {
|
||||||
|
hour = m_pTimeShowWidget->m_pHourRollWidget->readValue() - timeHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeMinute > m_pTimeShowWidget->m_pMinuteRollWidget->readValue()) {
|
||||||
|
minute = 60 - (timeMinute - m_pTimeShowWidget->m_pMinuteRollWidget->readValue());
|
||||||
|
hour = hour - 1;
|
||||||
|
} else {
|
||||||
|
minute = m_pTimeShowWidget->m_pMinuteRollWidget->readValue() - timeMinute;
|
||||||
|
}
|
||||||
|
return QStringLiteral("%1:%2").arg(hour).arg(minute);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_OSX
|
||||||
|
if (!event->spontaneous() || !isVisible()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (trayIcon->isVisible()) {
|
||||||
|
hide();
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
QWidget::closeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QStyleOption opt;
|
||||||
|
opt.init(this);
|
||||||
|
QPainter p(this);
|
||||||
|
QPainterPath path;
|
||||||
|
opt.rect.adjust(0,0,0,0);
|
||||||
|
|
||||||
|
p.setBrush(opt.palette.color(QPalette::Base));
|
||||||
|
p.setOpacity(1);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.setRenderHint(QPainter::Antialiasing); //反锯齿
|
||||||
|
p.drawRoundedRect(opt.rect, 0, 0);
|
||||||
|
path.addRoundedRect(opt.rect, 0, 0);
|
||||||
|
QRegion Region(path.toFillPolygon().toPolygon());
|
||||||
|
setProperty("blurRegion", Region);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::dropDownBoxShowHideSlots()
|
||||||
|
{
|
||||||
|
if (!m_pDropDownBox->isVisible()) {
|
||||||
|
m_pDropDownBox->exec(this->mapToGlobal(QPoint(24, 0)));
|
||||||
|
} else {
|
||||||
|
m_pDropDownBox->hide();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::updatedropDownBoxSelectSlots()
|
||||||
|
{
|
||||||
|
m_WeekSelect.clear();
|
||||||
|
m_selectIndexGsetting.clear();
|
||||||
|
QStringList WeekStringList = m_pDropDownBox->getWeekStringList();
|
||||||
|
qDebug() << "21321312312" << WeekStringList;
|
||||||
|
for (int i = 0; i < WeekStringList.count(); i++) {
|
||||||
|
if (i == 0)
|
||||||
|
m_selectIndexGsetting = WeekStringList.at(i);
|
||||||
|
else
|
||||||
|
m_selectIndexGsetting = m_selectIndexGsetting + " " + WeekStringList.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_selectIndexGsetting == "") {
|
||||||
|
m_selectIndexGsetting = QString().number(0);
|
||||||
|
}
|
||||||
|
m_WeekSelect = m_pDropDownBox->getWeekDateList(m_selectIndexGsetting);
|
||||||
|
m_pComBoxWidget->setLabelWeekSelect(m_pDropDownBox->getChosenList(m_WeekSelect));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::confirmButtonSlots()
|
||||||
|
{
|
||||||
|
setShutdownFrequency(m_WeekSelect);
|
||||||
|
if (m_WeekSelect[0] == NEVER_SHUTDON) {
|
||||||
|
QMessageBox::warning(NULL, tr("warning"), tr("no set shutdown"), QMessageBox::Ok );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (determineShutdownTime()) {
|
||||||
|
QMessageBox::warning(NULL, tr("warning"), \
|
||||||
|
tr("The shutdown time is shorter than the current time"), \
|
||||||
|
QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_timeShotdown = getTimedShutdownState();
|
||||||
|
if (!m_timeShotdown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_pMonitorTime->start(1000); // 开始轮训,每秒轮训一次
|
||||||
|
m_pTimeShowWidget->m_pHourRollWidget->setColor(false); // 修改时间界面透明度
|
||||||
|
m_pTimeShowWidget->m_pMinuteRollWidget->setColor(false);
|
||||||
|
m_pTimeShowWidget->m_pHourRollWidget->update();
|
||||||
|
m_pTimeShowWidget->m_pMinuteRollWidget->update();
|
||||||
|
m_pTransparentWidget->setVisible(true); // 置时间调试界面为不可滚动
|
||||||
|
m_pBlankShadowWidget->setVisible(true);
|
||||||
|
// 设置关机频率
|
||||||
|
setTimeShutdownValue(true);
|
||||||
|
setShutDownTimeValue(m_pShowDownTime);
|
||||||
|
setFrequencyValue(m_selectIndexGsetting);
|
||||||
|
m_pConfirmAreaWidget->m_pConfirmButton->setEnabled(false);
|
||||||
|
m_pConfirmAreaWidget->m_pCancelButton->setEnabled(true);
|
||||||
|
m_pTimeRemainLabel->setVisible(true);
|
||||||
|
m_pComBoxWidget->setEnabled(false);
|
||||||
|
// 断开点击Combox展示下拉框的 信号 槽
|
||||||
|
disconnect(m_pComBoxWidget, &comBoxWidget::comBoxWidgetClicked, this, &Widget::dropDownBoxShowHideSlots);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::canceButtonSlots()
|
||||||
|
{
|
||||||
|
m_pMonitorTime->stop(); // 开始轮训,每秒轮训一次
|
||||||
|
m_pTimeShowWidget->m_pHourRollWidget->setColor(true); // 修改时间界面透明度
|
||||||
|
m_pTimeShowWidget->m_pMinuteRollWidget->setColor(true);
|
||||||
|
m_pTimeShowWidget->m_pHourRollWidget->update();
|
||||||
|
m_pTimeShowWidget->m_pMinuteRollWidget->update();
|
||||||
|
m_pTransparentWidget->setVisible(false); // 置时间调试界面为可滚动
|
||||||
|
m_pBlankShadowWidget->setVisible(false);
|
||||||
|
setShutDownTimeValue(m_pShowDownTime);
|
||||||
|
setFrequencyValue(m_selectIndexGsetting);
|
||||||
|
setTimeShutdownValue(false);
|
||||||
|
m_pConfirmAreaWidget->m_pConfirmButton->setEnabled(true);
|
||||||
|
m_pTimeRemainLabel->setVisible(false);
|
||||||
|
// 重新连接点击Combox展示下拉框的 信号 槽
|
||||||
|
m_pComBoxWidget->setEnabled(true);
|
||||||
|
connect(m_pComBoxWidget, &comBoxWidget::comBoxWidgetClicked, this, &Widget::dropDownBoxShowHideSlots);
|
||||||
|
m_pConfirmAreaWidget->m_pCancelButton->setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//只要时间变化就执行此槽函数,获取倒计时状态。
|
||||||
|
void Widget::threadSlots()
|
||||||
|
{
|
||||||
|
QTime time = QTime::currentTime();
|
||||||
|
int timeS = time.second();
|
||||||
|
QTime current_time = QTime::currentTime();
|
||||||
|
int currentHours = current_time.hour();
|
||||||
|
int currentMinute = current_time.minute();
|
||||||
|
QString s_currentTime = QStringLiteral("%1:%2").arg(currentHours).arg(currentMinute);
|
||||||
|
m_timeShotdown = getTimedShutdownState();
|
||||||
|
|
||||||
|
if (m_timeShotdown && m_currentTmp == m_nextCurrenttmp && s_currentTime == m_pShowDownTime && timeS == 0) {
|
||||||
|
qDebug() << "-------------------------------------->进入关机状态";
|
||||||
|
setWeekSelectShutdownFrequency();
|
||||||
|
setNextShutDownTime();
|
||||||
|
QStringList argvList;
|
||||||
|
argvList.clear();
|
||||||
|
argvList.append("--shutdown");
|
||||||
|
QProcess p(0);
|
||||||
|
p.startDetached("ukui-session-tools", argvList);
|
||||||
|
p.waitForStarted();
|
||||||
|
}
|
||||||
|
setNextShutDownTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::iconActivated(QSystemTrayIcon::ActivationReason reason)
|
||||||
|
{
|
||||||
|
switch (reason) {
|
||||||
|
case QSystemTrayIcon::Trigger:
|
||||||
|
if (m_bShowFlag) {
|
||||||
|
this->show();
|
||||||
|
m_bShowFlag = false;
|
||||||
|
} else {
|
||||||
|
this->hide();
|
||||||
|
m_bShowFlag = true;
|
||||||
|
}
|
||||||
|
case QSystemTrayIcon::Context:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::bootOptionsFilter(const QString&)
|
||||||
|
{
|
||||||
|
this->show();
|
||||||
|
this->raise();
|
||||||
|
this->activateWindow();
|
||||||
|
m_bShowFlag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Widget::getTimeShutdownVersion()
|
||||||
|
{
|
||||||
|
QString tagsFilePath = QDir::homePath() + "/" + "tagfile.txt";
|
||||||
|
if (QFile::exists(tagsFilePath)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QProcess process(0);
|
||||||
|
QStringList cmdList;
|
||||||
|
cmdList.clear();
|
||||||
|
cmdList.append("-l");
|
||||||
|
cmdList.append("time-shutdown");
|
||||||
|
process.start("dpkg", cmdList);
|
||||||
|
process.waitForFinished(-1);
|
||||||
|
QString outputString = process.readAllStandardOutput();
|
||||||
|
QStringList outList = outputString.split("\n");
|
||||||
|
QString versionString = outList.at(outList.count() - 2);
|
||||||
|
QStringList versionStringList = versionString.split(" ");
|
||||||
|
versionStringList.removeAll("");
|
||||||
|
if (versionStringList.at(1) == "time-shutdown" &&
|
||||||
|
(QString::compare(versionStringList.at(2), "1.1.0-1-0030") <= 0)) {
|
||||||
|
m_pTimeShutdown->set("shutdowntime", "");
|
||||||
|
m_pTimeShutdown->set("shutdownfrequency", "");
|
||||||
|
m_pTimeShutdown->set("timeshutdown", false);
|
||||||
|
QFile file(tagsFilePath);
|
||||||
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断仅一次关机时是否可执行关机操作
|
||||||
|
bool Widget::determineShutdownTime()
|
||||||
|
{
|
||||||
|
QTime current_time = QTime::currentTime();
|
||||||
|
int currentHours = current_time.hour();
|
||||||
|
int currentMinute = current_time.minute();
|
||||||
|
m_pShowDownTime.clear();
|
||||||
|
m_hours = m_pTimeShowWidget->m_pHourRollWidget->readValue();
|
||||||
|
m_minute = m_pTimeShowWidget->m_pMinuteRollWidget->readValue();
|
||||||
|
m_pShowDownTime = QStringLiteral("%1:%2").arg(m_hours).arg(m_minute);
|
||||||
|
qDebug() << m_hours << m_minute << "currentHours:" << currentHours << "currentMinute:" << currentMinute;
|
||||||
|
|
||||||
|
if (m_WeekSelect[0] == ONLY_ONCE) {
|
||||||
|
if (m_hours < currentHours || (currentHours == m_hours && m_minute <= currentMinute)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
|
@ -0,0 +1,167 @@
|
||||||
|
/*
|
||||||
|
* Ukui-shutdown-timer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: liushanwen <liushanwen@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WIDGET_H
|
||||||
|
#define WIDGET_H
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QStringLiteral>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QGSettings>
|
||||||
|
#include <QTranslator>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QDir>
|
||||||
|
#include "confirmareawidget.h"
|
||||||
|
#include "timeshowwidget.h"
|
||||||
|
#include "comboxwidget.h"
|
||||||
|
#include "dropdownmenu.h"
|
||||||
|
|
||||||
|
#define UKUITIMESHUTDOWN "org.ukui.time-shutdwon.settings"
|
||||||
|
#define ORG_UKUI_STYLE "org.ukui.style"
|
||||||
|
#define SETTAGSFILE "/home/kylin/.config/ukui/tagfile.txt"
|
||||||
|
/* app主类 */
|
||||||
|
class Widget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
Widget(QWidget *parent = nullptr);
|
||||||
|
~Widget();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initTranslation();
|
||||||
|
void initMemberVariable();
|
||||||
|
void initLayout();
|
||||||
|
|
||||||
|
void initSignalSlots();
|
||||||
|
void initDropDownBoxLabelStatus();
|
||||||
|
|
||||||
|
// 初始化托盘图标
|
||||||
|
void createActions();
|
||||||
|
void createTrayIcon();
|
||||||
|
void setIcon(QIcon icon);
|
||||||
|
|
||||||
|
// getstting初始化、值获取、设置getsetting值
|
||||||
|
void initGsetting();
|
||||||
|
void initRemainLableFnotGsetting();
|
||||||
|
void getComBoxShutdownFrequency();
|
||||||
|
void getShutDownTime();
|
||||||
|
bool getTimedShutdownState();
|
||||||
|
void initTimeShutdownWidget();
|
||||||
|
void setTimeShutdownValue(bool value);
|
||||||
|
void setShutDownTimeValue(QString value);
|
||||||
|
void setFrequencyValue(QString value);
|
||||||
|
|
||||||
|
// 根据关机频率来选择是否能进行定时关机
|
||||||
|
void setWeekSelectShutdownFrequency();
|
||||||
|
void setShutdownFrequency(QList<int> list);
|
||||||
|
|
||||||
|
// 设置距离下一次关机时间
|
||||||
|
void setNextShutDownTime();
|
||||||
|
int getCurrentShutDownNum();
|
||||||
|
int caculateNextShutDownNum(int currentTmp, QList<int> weekSelect);
|
||||||
|
//计算下次关机所需时间
|
||||||
|
QString getCalculateShutDownTime(QList<int> weekSelect);
|
||||||
|
QString getTimeShutdownVersion();
|
||||||
|
bool determineShutdownTime();
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum SelectSection{
|
||||||
|
NEVER_SHUTDON = 0,
|
||||||
|
ONLY_ONCE = 1,
|
||||||
|
EVERYDAY = 2,
|
||||||
|
MONDAY = 3,
|
||||||
|
SUNDAY = 9
|
||||||
|
};
|
||||||
|
|
||||||
|
QVBoxLayout *m_pVMainLayout = nullptr;
|
||||||
|
QLabel *m_pTimeRemainLabel = nullptr;
|
||||||
|
QList<int> m_WeekSelect;
|
||||||
|
QString m_selectIndexGsetting = nullptr;
|
||||||
|
QString m_pShowDownTime;
|
||||||
|
QTimer *m_pMonitorTime = nullptr;
|
||||||
|
QWidget *m_pTransparentWidget = nullptr;
|
||||||
|
QGSettings *m_pTimeShutdown = nullptr;
|
||||||
|
QGSettings *m_pGsettingFont = nullptr;
|
||||||
|
QString m_traslate;
|
||||||
|
QString m_traslateHours;
|
||||||
|
QString m_traslateMinute;
|
||||||
|
QTranslator *m_ptranslator;
|
||||||
|
|
||||||
|
/* 托盘栏图标 */
|
||||||
|
QAction *minimizeAction;
|
||||||
|
QAction *maximizeAction;
|
||||||
|
QAction *restoreAction;
|
||||||
|
QAction *quitAction;
|
||||||
|
|
||||||
|
QSystemTrayIcon *trayIcon;
|
||||||
|
QMenu *trayIconMenu;
|
||||||
|
|
||||||
|
int m_hours; // 时
|
||||||
|
int m_minute; // 分钟
|
||||||
|
int m_currentTmp = -1;
|
||||||
|
int m_nextCurrenttmp = -2;
|
||||||
|
bool m_timeShotdown = false;
|
||||||
|
bool m_bShowFlag = false;
|
||||||
|
|
||||||
|
DropDownMenu *m_pDropDownBox = nullptr;
|
||||||
|
comBoxWidget *m_pComBoxWidget = nullptr;
|
||||||
|
confirmAreaWidget *m_pConfirmAreaWidget = nullptr;
|
||||||
|
timeShowWidget *m_pTimeShowWidget = nullptr;
|
||||||
|
BlankShadowWidget *m_pBlankShadowWidget = nullptr;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void dropDownBoxShowHideSlots();
|
||||||
|
void updatedropDownBoxSelectSlots();
|
||||||
|
void confirmButtonSlots();
|
||||||
|
void canceButtonSlots();
|
||||||
|
void threadSlots();
|
||||||
|
void iconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||||
|
void bootOptionsFilter(const QString&);
|
||||||
|
signals:
|
||||||
|
void hideDropDownBox();
|
||||||
|
};
|
||||||
|
#endif // WIDGET_H
|
|
@ -0,0 +1,52 @@
|
||||||
|
QT += core gui network
|
||||||
|
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
TARGET = time-shutdown
|
||||||
|
CONFIG += c++11 link_pkgconfig
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
include(src/src.pri)
|
||||||
|
PKGCONFIG += gsettings-qt
|
||||||
|
|
||||||
|
# The following define makes your compiler emit warnings if you use
|
||||||
|
# any Qt feature that has been marked deprecated (the exact warnings
|
||||||
|
# depend on your compiler). Please consult the documentation of the
|
||||||
|
# deprecated API in order to know how to port your code away from it.
|
||||||
|
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
LIBS += -lX11 -lgio-2.0 -lgobject-2.0 -lglib-2.0
|
||||||
|
|
||||||
|
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||||
|
# In order to do so, uncomment the following line.
|
||||||
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
|
isEmpty(PREFIX){
|
||||||
|
PREFIX = /usr
|
||||||
|
}
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
src/main.cpp \
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
images.qrc
|
||||||
|
|
||||||
|
TRANSLATIONS += translations/time-shutdown_zh_CN.ts
|
||||||
|
|
||||||
|
translation.files += translations/*.qm
|
||||||
|
translation.path = /usr/share/ukui-time-shutdown/
|
||||||
|
|
||||||
|
schemes.files += data/org.ukui.time.shutdown.settings.gschema.xml
|
||||||
|
schemes.path = /usr/share/glib-2.0/schemas/
|
||||||
|
|
||||||
|
#desktopfile.files = data/ukui-time-shotdown.desktop
|
||||||
|
#desktopfile.path = /usr/share/applications/
|
||||||
|
|
||||||
|
target.path = /usr/bin/
|
||||||
|
|
||||||
|
INSTALLS += target schemes translation
|
||||||
|
# Default rules for deployment.
|
||||||
|
|
|
@ -0,0 +1,314 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE QtCreatorProject>
|
||||||
|
<!-- Written by QtCreator 4.11.0, 2022-03-29T10:17:47. -->
|
||||||
|
<qtcreator>
|
||||||
|
<data>
|
||||||
|
<variable>EnvironmentId</variable>
|
||||||
|
<value type="QByteArray">{3a2694dc-8289-4b15-bc5f-e55bc7498498}</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||||
|
<value type="QString" key="language">Cpp</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||||
|
<value type="QString" key="language">QmlJS</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||||
|
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||||
|
<valuemap type="QVariantMap"/>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{44430689-3f94-4588-864b-d63f38f99a4d}</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ztz/桌面/shutdown--timerEX/build-time-shutdown-unknown-Debug</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
|
||||||
|
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ztz/桌面/shutdown--timerEX/build-time-shutdown-unknown-Release</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
|
||||||
|
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ztz/桌面/shutdown--timerEX/build-time-shutdown-unknown-Profile</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
|
||||||
|
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||||
|
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
|
||||||
|
<value type="QString">cpu-cycles</value>
|
||||||
|
</valuelist>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
|
||||||
|
<value type="int" key="Analyzer.Perf.Frequency">250</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
|
||||||
|
<value type="QString">-e</value>
|
||||||
|
<value type="QString">cpu-cycles</value>
|
||||||
|
<value type="QString">--call-graph</value>
|
||||||
|
<value type="QString">dwarf,4096</value>
|
||||||
|
<value type="QString">-F</value>
|
||||||
|
<value type="QString">250</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||||
|
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||||
|
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||||
|
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||||
|
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||||
|
<value type="int">0</value>
|
||||||
|
<value type="int">1</value>
|
||||||
|
<value type="int">2</value>
|
||||||
|
<value type="int">3</value>
|
||||||
|
<value type="int">4</value>
|
||||||
|
<value type="int">5</value>
|
||||||
|
<value type="int">6</value>
|
||||||
|
<value type="int">7</value>
|
||||||
|
<value type="int">8</value>
|
||||||
|
<value type="int">9</value>
|
||||||
|
<value type="int">10</value>
|
||||||
|
<value type="int">11</value>
|
||||||
|
<value type="int">12</value>
|
||||||
|
<value type="int">13</value>
|
||||||
|
<value type="int">14</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/桌面/shutdown--timerEX/ukui-shutdown-timer/time-shutdown.pro</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/ztz/桌面/shutdown--timerEX/ukui-shutdown-timer/time-shutdown.pro</value>
|
||||||
|
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
||||||
|
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/ztz/桌面/shutdown--timerEX/build-time-shutdown-unknown-Debug</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
|
<value type="int">1</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||||
|
<value type="int">22</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>Version</variable>
|
||||||
|
<value type="int">22</value>
|
||||||
|
</data>
|
||||||
|
</qtcreator>
|
|
@ -0,0 +1,128 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="tr_TR">
|
||||||
|
<context>
|
||||||
|
<name>QObject</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/comboxwidget.cpp" line="19"/>
|
||||||
|
<source>Shutdown</source>
|
||||||
|
<translation>Bilgisayarı Kapat</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/confirmareawidget.cpp" line="14"/>
|
||||||
|
<source>Cancel</source>
|
||||||
|
<translation>İptal</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/confirmareawidget.cpp" line="17"/>
|
||||||
|
<source>Confirm</source>
|
||||||
|
<translation>Onayla</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="66"/>
|
||||||
|
<source>never</source>
|
||||||
|
<translation>Asla</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="67"/>
|
||||||
|
<source>Only this shutdown</source>
|
||||||
|
<translation>Sadece bu kapatma</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="68"/>
|
||||||
|
<source>Everyday</source>
|
||||||
|
<translation>Her gün</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="69"/>
|
||||||
|
<source>Mon</source>
|
||||||
|
<translation>Pzt</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="70"/>
|
||||||
|
<source>Tue</source>
|
||||||
|
<translation>Sal</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="71"/>
|
||||||
|
<source>Wed</source>
|
||||||
|
<translation>Çar</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="72"/>
|
||||||
|
<source>Thu</source>
|
||||||
|
<translation>Per</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="73"/>
|
||||||
|
<source>Fri</source>
|
||||||
|
<translation>Cum</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="74"/>
|
||||||
|
<source>Sat</source>
|
||||||
|
<translation>Cts</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="75"/>
|
||||||
|
<source>Sun</source>
|
||||||
|
<translation>Paz</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/timeshowwidget.cpp" line="39"/>
|
||||||
|
<source>hours</source>
|
||||||
|
<translation>Saat</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/timeshowwidget.cpp" line="43"/>
|
||||||
|
<location filename="../src/widget.cpp" line="149"/>
|
||||||
|
<source>minute</source>
|
||||||
|
<translation>Dakika</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="24"/>
|
||||||
|
<source>time-shutdown</source>
|
||||||
|
<translation>Kapatma zamanı</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="147"/>
|
||||||
|
<source>next shutdown</source>
|
||||||
|
<translation>Sonraki kapatma</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="148"/>
|
||||||
|
<source>hour</source>
|
||||||
|
<translation>Saat</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>minutes</source>
|
||||||
|
<translation type="vanished">Dakika</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>VerticalScroll_60</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/verticalscroll60.cpp" line="243"/>
|
||||||
|
<source>VerticalScroll_60</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>Widget</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="237"/>
|
||||||
|
<source>Mi&nimize</source>
|
||||||
|
<translation>Aşağı İndir</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="240"/>
|
||||||
|
<source>&Restore</source>
|
||||||
|
<translation>Onar</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="243"/>
|
||||||
|
<source>&Quit</source>
|
||||||
|
<translation>Çıkış</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
|
@ -0,0 +1,157 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="en_US">
|
||||||
|
<context>
|
||||||
|
<name>QObject</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/comboxwidget.cpp" line="39"/>
|
||||||
|
<source>Shutdown</source>
|
||||||
|
<translation>关机频率</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/confirmareawidget.cpp" line="34"/>
|
||||||
|
<source>Cancel</source>
|
||||||
|
<translation>取消</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/confirmareawidget.cpp" line="38"/>
|
||||||
|
<source>Confirm</source>
|
||||||
|
<translation>确认</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="97"/>
|
||||||
|
<location filename="../src/widget.cpp" line="628"/>
|
||||||
|
<source>never</source>
|
||||||
|
<translation>从不</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="98"/>
|
||||||
|
<location filename="../src/widget.cpp" line="640"/>
|
||||||
|
<source>Only this shutdown</source>
|
||||||
|
<translation>仅本次关机</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="99"/>
|
||||||
|
<source>Everyday</source>
|
||||||
|
<translation>每天</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="100"/>
|
||||||
|
<source>Mon</source>
|
||||||
|
<translation>周一</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="101"/>
|
||||||
|
<source>Tue</source>
|
||||||
|
<translation>周二</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="102"/>
|
||||||
|
<source>Wed</source>
|
||||||
|
<translation>周三</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="103"/>
|
||||||
|
<source>Thu</source>
|
||||||
|
<translation>周四</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="104"/>
|
||||||
|
<source>Fri</source>
|
||||||
|
<translation>周五</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="105"/>
|
||||||
|
<source>Sat</source>
|
||||||
|
<translation>周六</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dropdownbox.cpp" line="106"/>
|
||||||
|
<source>Sun</source>
|
||||||
|
<translation>周日</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/timeshowwidget.cpp" line="60"/>
|
||||||
|
<source>hours</source>
|
||||||
|
<translation>时</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/timeshowwidget.cpp" line="63"/>
|
||||||
|
<location filename="../src/widget.cpp" line="122"/>
|
||||||
|
<source>minute</source>
|
||||||
|
<translation>分</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="100"/>
|
||||||
|
<location filename="../src/widget.cpp" line="238"/>
|
||||||
|
<source>time-shutdown</source>
|
||||||
|
<translation>定时关机</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="120"/>
|
||||||
|
<source>next shutdown</source>
|
||||||
|
<translation>距离下一次关机时间</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="121"/>
|
||||||
|
<source>hour</source>
|
||||||
|
<translation>小时</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>minutes</source>
|
||||||
|
<translation type="vanished">分钟</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/main.cpp" line="61"/>
|
||||||
|
<source>time-shutdown is already running!</source>
|
||||||
|
<translation type="unfinished">定时关机已经运行</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>VerticalScroll_60</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/verticalscroll60.cpp" line="268"/>
|
||||||
|
<source>VerticalScroll_60</source>
|
||||||
|
<translation></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>Widget</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="218"/>
|
||||||
|
<source>Mi&nimize</source>
|
||||||
|
<translation>最小化</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="221"/>
|
||||||
|
<source>&Restore</source>
|
||||||
|
<translation>打开</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="224"/>
|
||||||
|
<source>&Quit</source>
|
||||||
|
<translation>退出</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="645"/>
|
||||||
|
<source>The shutdown time is shorter than the current time</source>
|
||||||
|
<translation>关机时间小于当前时间</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="685"/>
|
||||||
|
<source>never</source>
|
||||||
|
<translation>从不</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="630"/>
|
||||||
|
<location filename="../src/widget.cpp" line="644"/>
|
||||||
|
<source>warning</source>
|
||||||
|
<translation>警告</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/widget.cpp" line="630"/>
|
||||||
|
<source>no set shutdown</source>
|
||||||
|
<translation>未设置关机频率</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
|
@ -0,0 +1,117 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="bo_CN">
|
||||||
|
<context>
|
||||||
|
<name>QObject</name>
|
||||||
|
<message>
|
||||||
|
<source>Fri</source>
|
||||||
|
<translation>གཟའ་པ་སངས།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Mon</source>
|
||||||
|
<translation>Mono</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Sat</source>
|
||||||
|
<translation>གཟའ་སྤེན་པ།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Sun</source>
|
||||||
|
<translation> ཉིན།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Thu</source>
|
||||||
|
<translation>གཟའ་ཕུར་བུ།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Tue</source>
|
||||||
|
<translation>གཟའ་མིག་དམར།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Wed</source>
|
||||||
|
<translation>གཟའ་ལྷག་པ།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>hour</source>
|
||||||
|
<translation>དུས་ཚོད།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Only this shutdown</source>
|
||||||
|
<translation>སྒོ་གཏན་ཐེངས་འདི་ཁོ་ན།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>hours</source>
|
||||||
|
<translation>དུས་ཚོད།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>never</source>
|
||||||
|
<translation>གཏན་མིན།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Cancel</source>
|
||||||
|
<translation>མེད་པར་བཟོ་བ</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>time-shutdown</source>
|
||||||
|
<translation>དུས་བཅད་སྒོ་གཏན།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>minute</source>
|
||||||
|
<translation>སྐར་མ།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Confirm</source>
|
||||||
|
<translation>གཏན་འཁེལ།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>time-shutdown is already running!</source>
|
||||||
|
<translation>དུས་བཅད་སྒོ་གཏན་མགོ་བརྩམས་ཟིན།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>next shutdown</source>
|
||||||
|
<translation>ཐེངས་རྗེས་མའི་དུས་བཅད་སྒོ་གཏན་བར་གྱི་དུས་ཚོད།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Everyday</source>
|
||||||
|
<translation>ཉིན་རེ་རེ།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Shutdown</source>
|
||||||
|
<translation>ཁ་རྒྱག</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>Widget</name>
|
||||||
|
<message>
|
||||||
|
<source>&Quit</source>
|
||||||
|
<translation>ཕྱིར་འབུད།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>never</source>
|
||||||
|
<translation>གཏན་མིན།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>no set shutdown</source>
|
||||||
|
<translation>སྒོ་གཏན་ཕྱོད་ལ་སྒྲིག་འགོད་བྱས་མེད།</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>&Restore</source>
|
||||||
|
<translation>ཕྱིར་ལོག</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Mi&nimize</source>
|
||||||
|
<translation>ཆེས་ཆུང་པ་ཅན།(&N)</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>warning</source>
|
||||||
|
<translation>ཉེན་བརྡ</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>VerticalScroll_60</name>
|
||||||
|
<message>
|
||||||
|
<source>VerticalScroll_60</source>
|
||||||
|
<translation/>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|