commit 519f2abbc7ba14c3196bdadde3c5361d47ef2bf3 Author: 李 翔 Date: Thu Dec 21 11:51:56 2017 +0800 fork youker-assistant(commit:764) diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..69b0344 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Ubuntu Kylin Team diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5bb9a95 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +youker-assistant +================ + +Attention +========= +It supports unity and mate for Ubuntu/Ubuntu Kylin. + +Depends +======= +debhelper (>= 9),python-dev,python-lxml,python-piston-mini-client,python-xdg,libqt4-dev,pkg-config,python (>= 2.6.6-3~),libglib2.0-dev,libgtop2-dev + +Launchpad +======= +https://launchpad.net/youker-assistant + +Internationalization +======= +lupdate youker-assistant.pro +linguist youker-assistant_zh_CN.ts +lrelease youker-assistant.pro + +Python Internationalization +======= +xgettext -k_ -o youker-assistant.pot cpuinfo.py +youker-assistant.pot:修改charset为utf-8 +cp youker-assistant.pot youker-assistant.po +msgfmt -o youker-assistant.mo youker-assistant.po +(sudo cp youker-assistant.mo /usr/share/locale/zh_CN/LC_MESSAGES/) + + + + +FT Version: +1)changelog like this: +youker-assistant (2.0.7kord) juniper; urgency=low + +2)youker-assistant.dekstop + +3)debian/source/format +replace quilt with native + + +DEBUG: +gdb python +set args start_sessiondbus.py +run diff --git a/backends/backends.pro b/backends/backends.pro new file mode 100644 index 0000000..1dffd1a --- /dev/null +++ b/backends/backends.pro @@ -0,0 +1,18 @@ +TEMPLATE = aux + +inst1.files += ../backends/youker-assistant-daemon/src/ +inst1.path = /usr/lib/python2.7/dist-packages/youker-assistant-daemon/ +inst2.files += ../backends/youker-assistant-daemon/data/beautify/autostart/ +inst2.path = /var/lib/youker-assistant-daemon/ +inst3.files += ../backends/youker-assistant-daemon/data/beautify/plymouth/ +inst3.path = /var/lib/youker-assistant-daemon/ +inst4.files += ../backends/youker-assistant-daemon/data/beautify/sound-theme/ +inst4.path = /var/lib/youker-assistant-daemon/ +inst5.files += ../backends/youker-assistant-daemon/data/ubuntukylin-default-settings.ini +inst5.path = /var/lib/youker-assistant-daemon/ + +INSTALLS += inst1 \ + inst2 \ + inst3 \ + inst4 \ + inst5 diff --git a/backends/youker-assistant-daemon/data/beautify/autostart/libcanberra-login-sound.desktop b/backends/youker-assistant-daemon/data/beautify/autostart/libcanberra-login-sound.desktop new file mode 100644 index 0000000..0dad37c --- /dev/null +++ b/backends/youker-assistant-daemon/data/beautify/autostart/libcanberra-login-sound.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Type=Application +Name=GNOME Login Sound +Comment=Plays a sound whenever you log in +Exec=/usr/bin/canberra-gtk-play --id="desktop-login" --description="GNOME Login" +OnlyShowIn=GNOME;Unity; +AutostartCondition=GSettings org.gnome.desktop.sound event-sounds +X-GNOME-Autostart-Phase=Application +X-GNOME-Provides=login-sound +X-GNOME-Autostart-enabled=true +NoDisplay=false diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/defaults/default.plymouth b/backends/youker-assistant-daemon/data/beautify/plymouth/defaults/default.plymouth new file mode 100644 index 0000000..0eb4716 --- /dev/null +++ b/backends/youker-assistant-daemon/data/beautify/plymouth/defaults/default.plymouth @@ -0,0 +1,6 @@ +[Plymouth Theme] +Name=ubuntukylin Logo +Description=A theme that features a blank background with a logo. +ModuleName=script + +[script] diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/defaults/only_background.script b/backends/youker-assistant-daemon/data/beautify/plymouth/defaults/only_background.script new file mode 100644 index 0000000..15ca345 --- /dev/null +++ b/backends/youker-assistant-daemon/data/beautify/plymouth/defaults/only_background.script @@ -0,0 +1,44 @@ +# ubuntukylin-logo.script - boot splash plugin +# +# Copyright (C) 2009 Canonical Ltd. +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, 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. + +logo.image = Image("customBG.png"); + +logo.screen_x = Window.GetWidth(); +logo.screen_y = Window.GetHeight(); +logo.image_x = logo.image.GetWidth(); +logo.image_y = logo.image.GetHeight(); + +logo.scale_factor_x = Window.GetWidth() / logo.image.GetWidth(); +logo.scale_factor_y = Window.GetHeight() / logo.image.GetHeight(); + +if(logo.scale_factor_x >= 1 && logo.scale_factor_y >= 1){ + logo.scale_factor = 1; +} +else{ + if(logo.scale_factor_x > logo.scale_factor_y){ + logo.scale_factor = logo.scale_factor_y; + } + else{ + logo.scale_factor = logo.scale_factor_x; + } +} + +logo.scaled_image = logo.image.Scale(logo.image.GetWidth() * logo.scale_factor, + logo.image.GetHeight() * logo.scale_factor); + +logo.sprite = Sprite(logo.scaled_image); + +logo.sprite.SetX(Window.GetWidth() / 2 - logo.scaled_image.GetWidth () / 2); +logo.sprite.SetY(Window.GetHeight() / 2 - logo.scaled_image.GetHeight() / 2); +logo.sprite.SetZ(-10000); diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/existing/README b/backends/youker-assistant-daemon/data/beautify/plymouth/existing/README new file mode 100644 index 0000000..fdf08e1 --- /dev/null +++ b/backends/youker-assistant-daemon/data/beautify/plymouth/existing/README @@ -0,0 +1 @@ +This directory is used to store the current system can be used in boot animation diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all1_1.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all1_1.png new file mode 100644 index 0000000..f0acaf9 Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all1_1.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all1_2.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all1_2.png new file mode 100644 index 0000000..c2c8c0d Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all1_2.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all_1.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all_1.png new file mode 100644 index 0000000..f412f02 Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all_1.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all_2.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all_2.png new file mode 100644 index 0000000..bbae031 Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/all_2.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/left_1.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/left_1.png new file mode 100644 index 0000000..e33dcc7 Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/left_1.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/left_2.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/left_2.png new file mode 100644 index 0000000..bf641b2 Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/left_2.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/text.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/text.png new file mode 100644 index 0000000..4b99e31 Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/text.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/ubuntukylin-logo.plymouth b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/ubuntukylin-logo.plymouth new file mode 100644 index 0000000..e480b55 --- /dev/null +++ b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/ubuntukylin-logo.plymouth @@ -0,0 +1,8 @@ +[Plymouth Theme] +Name=My Theme +Description=This theme is a template to build on +ModuleName=script + +[script] +ImageDir=/lib/plymouth/themes/ubuntukylin-logo +ScriptFile=/lib/plymouth/themes/ubuntukylin-logo/ubuntukylin-logo.script diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/ubuntukylin-logo.script b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/ubuntukylin-logo.script new file mode 100644 index 0000000..43dbfb3 --- /dev/null +++ b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/ubuntukylin-logo.script @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2014 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Zhang Chao zhangchao@ubuntukylin.com + * + * 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; version 3. + * + * 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 . + */ +//背景 + +Window.SetBackgroundTopColor (0, 0, 0); +Window.SetBackgroundBottomColor (0, 0, 0); +// +left_1_image = Image("left_1.png"); +resized_left_1_image = left_1_image.Scale(Window.GetWidth(), Window.GetWidth()*left_1_image.GetHeight()/left_1_image.GetWidth()); +left_1_sprite = Sprite(); +left_1_sprite.SetImage(resized_left_1_image); +left_1_sprite.SetX(0); +left_1_sprite.SetY(Window.GetHeight() / 2 - resized_left_1_image.GetHeight() / 2); +left_1_sprite.SetZ(98); +left_1_sprite.SetOpacity(0); + +left_2_image = Image("left_2.png"); +resized_left_2_image = left_2_image.Scale(Window.GetWidth(), Window.GetWidth()*left_2_image.GetHeight()/left_2_image.GetWidth()); +left_2_sprite = Sprite(); +left_2_sprite.SetImage(resized_left_2_image); +left_2_sprite.SetX(0); +left_2_sprite.SetY(Window.GetHeight() / 2 - resized_left_2_image.GetHeight() / 2); +left_2_sprite.SetZ(98); +left_2_sprite.SetOpacity(1); + +xx_h=resized_left_1_image.GetHeight()-50; +xx_y=Window.GetHeight() / 2 - xx_h / 2; + +xx_w=resized_left_1_image.GetWidth()-200; +xx_x=Window.GetWidth() / 2 - xx_w / 2; + +all_1_image = Image("all_1.png"); +resized_all_1_image = all_1_image.Scale(Window.GetWidth(), Window.GetWidth()*all_1_image.GetHeight()/all_1_image.GetWidth()); +all_1_sprite = Sprite(); +all_1_sprite.SetImage(resized_all_1_image); +all_1_sprite.SetX(0); +all_1_sprite.SetY(Window.GetHeight() / 2 - resized_all_1_image.GetHeight() / 2); +all_1_sprite.SetZ(102); +all_1_sprite.SetOpacity(0); + +all_2_image = Image("all_2.png"); +resized_all_2_image = all_2_image.Scale(Window.GetWidth(), Window.GetWidth()*all_2_image.GetHeight()/all_2_image.GetWidth()); +all_2_sprite = Sprite(); +all_2_sprite.SetImage(resized_all_2_image); +all_2_sprite.SetX(0); +all_2_sprite.SetY(Window.GetHeight() / 2 - resized_all_2_image.GetHeight() / 2); +all_2_sprite.SetZ(103); +all_2_sprite.SetOpacity(0); + +all1_1_image = Image("all1_1.png"); +resized_all1_1_image = all1_1_image.Scale(Window.GetWidth(), Window.GetWidth()*all1_1_image.GetHeight()/all1_1_image.GetWidth()); +all1_1_sprite = Sprite(); +all1_1_sprite.SetImage(resized_all1_1_image); +all1_1_sprite.SetX(0); +all1_1_sprite.SetY(Window.GetHeight() / 2 - resized_all1_1_image.GetHeight() / 2); +all1_1_sprite.SetZ(101); +all1_1_sprite.SetOpacity(0); + +all1_2_image = Image("all1_2.png"); +resized_all1_2_image = all1_2_image.Scale(Window.GetWidth(), Window.GetWidth()*all1_2_image.GetHeight()/all1_2_image.GetWidth()); +all1_2_sprite = Sprite(); +all1_2_sprite.SetImage(resized_all1_2_image); +all1_2_sprite.SetX(0); +all1_2_sprite.SetY(Window.GetHeight() / 2 - resized_all1_2_image.GetHeight() / 2); +all1_2_sprite.SetZ(100); +all1_2_sprite.SetOpacity(0); +//文字 +text_image = Image("text.png"); +resized_text_image = text_image.Scale(Window.GetWidth(), Window.GetWidth()*text_image.GetHeight()/text_image.GetWidth()); +text_sprite = Sprite(); +text_sprite.SetImage(resized_text_image); +text_sprite.SetX(0); +text_sprite.SetY(Window.GetHeight() / 2 - resized_text_image.GetHeight() / 2); +text_sprite.SetZ(106); +text_sprite.SetOpacity(0); + + +xx_image = Image("xx.png"); +xx1_image = Image("xx1.png"); +xx2_image = Image("xx2.png"); +xx3_image = Image("xx3.png"); +xxnum=15; +for(i=0;i 50){ + all1_1_Opacity=(progress-50)%314; + all1_1_sprite.SetOpacity(Math.Sin(all1_1_Opacity/100)); + } + if(progress > 127){ + all1_2_Opacity=progress%78; + all1_2_sprite.SetOpacity(Math.Sin(all1_2_Opacity/25)); + } + if(progress > 78){ + all_1_Opacity=(progress-78)%157; + all_1_sprite.SetOpacity(Math.Sin(all_1_Opacity/50)); + } + if(progress > 157){ + all_2_Opacity=progress%157; + all_2_sprite.SetOpacity(Math.Sin(all_2_Opacity/50)); + } + + + + + if(star_progress < 800){ + if(star_progress%40==0){ + xx_sprite[star_progress/40].SetX(Math.Int(Math.Random(10)*xx_w+xx_x)); + xx_sprite[star_progress/40].SetY(Math.Int(Math.Random(10)*xx_h+xx_y)); + xx1_sprite[star_progress/40].SetX(Math.Int(Math.Random(10)*Window.GetWidth())); + xx1_sprite[star_progress/40].SetY(Math.Int(Math.Random(10)*Window.GetHeight())); + xx2_sprite[star_progress/40].SetX(Math.Int(Math.Random(10)*Window.GetWidth())); + xx2_sprite[star_progress/40].SetY(Math.Int(Math.Random(10)*Window.GetHeight())); + xx3_sprite[star_progress/40].SetX(Math.Int(Math.Random(10)*Window.GetWidth())); + xx3_sprite[star_progress/40].SetY(Math.Int(Math.Random(10)*Window.GetHeight())); + } + xx_sprite[Math.Int(star_progress/40)].SetOpacity((progress%40)/40); + xx1_sprite[Math.Int(star_progress/40)].SetOpacity((progress%40)/40); + xx2_sprite[Math.Int(star_progress/40)].SetOpacity((progress%40)/40); + xx3_sprite[Math.Int(star_progress/40)].SetOpacity((progress%40)/40); + }else{ + if(star_progress%80 < 40){ + xx_sprite[Math.Int(star_progress/80)% 20].SetOpacity(1-(progress%80)/40); + xx1_sprite[Math.Int(star_progress/80)% 20].SetOpacity(1-(progress%80)/40); + xx2_sprite[Math.Int(star_progress/80)% 20].SetOpacity(1-(progress%80)/40); + xx3_sprite[Math.Int(star_progress/80)% 20].SetOpacity(1-(progress%80)/40); + }else{ + if(star_progress%80==40){ + xx_sprite[Math.Int(star_progress/80)% 20].SetX(Math.Int(Math.Random(10)*xx_w+xx_x)); + xx_sprite[Math.Int(star_progress/80)% 20].SetY(Math.Int(Math.Random(10)*xx_h+xx_y)); + xx1_sprite[Math.Int(star_progress/80)% 20].SetX(Math.Int(Math.Random(10)*Window.GetWidth())); + xx1_sprite[Math.Int(star_progress/80)% 20].SetY(Math.Int(Math.Random(10)*Window.GetHeight())); + xx2_sprite[Math.Int(star_progress/80)% 20].SetX(Math.Int(Math.Random(10)*Window.GetWidth())); + xx2_sprite[Math.Int(star_progress/80)% 20].SetY(Math.Int(Math.Random(10)*Window.GetHeight())); + xx3_sprite[Math.Int(star_progress/80)% 20].SetX(Math.Int(Math.Random(10)*Window.GetWidth())); + xx3_sprite[Math.Int(star_progress/80)% 20].SetY(Math.Int(Math.Random(10)*Window.GetHeight())); + } + xx_sprite[Math.Int(star_progress/80)% 20].SetOpacity((progress%80)/40); + xx1_sprite[Math.Int(star_progress/80)% 20].SetOpacity((progress%80)/40); + xx2_sprite[Math.Int(star_progress/80)% 20].SetOpacity((progress%80)/40); + xx3_sprite[Math.Int(star_progress/80)% 20].SetOpacity((progress%80)/40); + } + } + progress+=2; +star_progress+=20; + + } + + +Plymouth.SetRefreshFunction (refresh_callback); + + + +#----------------------------------------- Progress Bar -------------------------------- + + +fun progress_callback (duration, progress) + { + + } + +Plymouth.SetBootProgressFunction(progress_callback); + +#----------------------------------------- Quit -------------------------------- + +fun quit_callback () +{ +} + +Plymouth.SetQuitFunction(quit_callback); + + diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx.png new file mode 100644 index 0000000..7fd4fab Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx1.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx1.png new file mode 100644 index 0000000..d347406 Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx1.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx2.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx2.png new file mode 100644 index 0000000..68db954 Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx2.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx3.png b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx3.png new file mode 100644 index 0000000..bca1f79 Binary files /dev/null and b/backends/youker-assistant-daemon/data/beautify/plymouth/ubuntukylin-logo/xx3.png differ diff --git a/backends/youker-assistant-daemon/data/beautify/sound-theme/README b/backends/youker-assistant-daemon/data/beautify/sound-theme/README new file mode 100644 index 0000000..912904f --- /dev/null +++ b/backends/youker-assistant-daemon/data/beautify/sound-theme/README @@ -0,0 +1 @@ +This directory is used to back up the system sound theme diff --git a/backends/youker-assistant-daemon/data/ubuntukylin-default-settings.ini b/backends/youker-assistant-daemon/data/ubuntukylin-default-settings.ini new file mode 100644 index 0000000..b094b26 --- /dev/null +++ b/backends/youker-assistant-daemon/data/ubuntukylin-default-settings.ini @@ -0,0 +1,71 @@ +[font] +font-name=Ubuntu 11 +font=Ubuntu 11 +monospace-font-name=Ubuntu Mono 13 +document-font-name=Sans 11 +titlebar-font=Ubuntu Bold 11 +text-scaling-factor=1 +hinting=slight +antialiasing=rgba + +[icon] +icon-theme=ubuntukylin-icon-theme +show-desktop-icons=1 +home-icon-visible=1 +network-icon-visible=0 +trash-icon-visible=1 +volumes-visible=1 + +[cinnamon-icon] +show-desktop-icons=1 +computer-icon-visible=1 +home-icon-visible=1 +network-icon-visible=0 +trash-icon-visible=0 +volumes-visible=1 + +[file] +always-use-location-entry=0 +automount=1 +automount-open=1 +autorun-never=0 +thumbnail-size=64 +maximum-age=180 +maximum-size=512 + +[unity] +icon-size=48 +launcher-hide-mode=0 +launcher-opacity=0.2 +backlight-mode=only run app +dash-blur-experimental=2 +panel-opacity=0.2 + +[mouse] +cursor-theme=DMZ-White +cursor-size=24 + +[touchpad] +touchpad-enabled=1 +horiz-scroll-enabled=1 +scrollbar-mode=overlay-auto +scroll-method=two-finger-scrolling + +[window] +button-layout=close-minimize-maximize: +menus-have-icons=0 +mouse-wheel-action=none +action-double-click-titlebar=toggle-maximize +action-middle-click-titlebar=lower +action-right-click-titlebar=menu + +[datetime] +time-format=locale-default +show-seconds=0 +show-day=0 +show-date=0 + +[power] +icon-policy=present +show-percentage=0 +show-time=0 diff --git a/backends/youker-assistant-daemon/dbus/com.ubuntukylin.session.service b/backends/youker-assistant-daemon/dbus/com.ubuntukylin.session.service new file mode 100644 index 0000000..3a75bfb --- /dev/null +++ b/backends/youker-assistant-daemon/dbus/com.ubuntukylin.session.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=com.ubuntukylin.session +Exec=/usr/bin/youker-assistant-session.py diff --git a/backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.conf b/backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.conf new file mode 100644 index 0000000..8257c06 --- /dev/null +++ b/backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.conf @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.policy b/backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.policy new file mode 100644 index 0000000..b286710 --- /dev/null +++ b/backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.policy @@ -0,0 +1,25 @@ + + + + + Youker Assistant + http://ubuntukylin.com + youker-assistant + + + <_description> + system level settings + + <_message> + To Change the settings, you need to authenticate. + + + auth_admin + auth_admin + auth_admin + + + + diff --git a/backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.service b/backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.service new file mode 100644 index 0000000..f90fb23 --- /dev/null +++ b/backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.service @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=com.ubuntukylin.youker +Exec=/usr/bin/youker-assistant-backend.py +User=root diff --git a/backends/youker-assistant-daemon/src/appcollections/__init__.py b/backends/youker-assistant-daemon/src/appcollections/__init__.py new file mode 100644 index 0000000..013e4b7 --- /dev/null +++ b/backends/youker-assistant-daemon/src/appcollections/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/backends/youker-assistant-daemon/src/appcollections/monitorball/__init__.py b/backends/youker-assistant-daemon/src/appcollections/monitorball/__init__.py new file mode 100644 index 0000000..013e4b7 --- /dev/null +++ b/backends/youker-assistant-daemon/src/appcollections/monitorball/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/backends/youker-assistant-daemon/src/appcollections/monitorball/monitor_ball.py b/backends/youker-assistant-daemon/src/appcollections/monitorball/monitor_ball.py new file mode 100644 index 0000000..a8a3f79 --- /dev/null +++ b/backends/youker-assistant-daemon/src/appcollections/monitorball/monitor_ball.py @@ -0,0 +1,130 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import psutil +import time +import subprocess + +class MonitorBall: + + # clean up memory + def cleanup_memory(self): + '''force changed to disk, update the super block''' + pone = subprocess.Popen(["sync"], shell=True) + pone.wait() + + '''drop pagecache, dentries and inodes to free the memory''' + ptwo = subprocess.Popen(["echo 3 > /proc/sys/vm/drop_caches"], shell=True) + ptwo.wait() + + # get cpu percent + def get_cpu_percent(self, percpu = False): + return psutil.cpu_percent(0.1, percpu) + + # get total memory + cache + def get_total_cmemory(self, symbol = "m"): + mem = psutil.phymem_usage() + value = mem.total + return self.bytes2human(value, symbol) + + # get used memory + cache + def get_used_cmemory(self, symbol = "m"): + mem = psutil.phymem_usage() + value = mem.used + return self.bytes2human(value, symbol) + + # get free memory + cache + def get_free_cmemory(self, symbol = "m"): + mem = psutil.phymem_usage() + value = mem.free + return self.bytes2human(value, symbol) + + # get total memory + def get_total_memory(self, symbol = "m"): + baseData = psutil.virtual_memory() + value = baseData.total + return self.bytes2human(value, symbol) + + # get used memory + def get_used_memory(self, symbol = "m"): + baseData = psutil.virtual_memory() + value = baseData.total - baseData.available + return self.bytes2human(value, symbol) + + # get free memory + def get_free_memory(self, symbol = "m"): + baseData = psutil.virtual_memory() + value = baseData.available + return self.bytes2human(value, symbol) + + # get memory used percent + def get_memory_percent(self): + baseData = psutil.virtual_memory() + return baseData.percent + + # get network total flow, return (up, down) + def get_network_flow_total(self, symbol = "k"): + network = psutil.network_io_counters() + sent = network.bytes_sent + recv = network.bytes_recv + + if(symbol == "b"): + return (sent, recv) + elif(symbol == "k"): + k_up = float(sent) / 1024 + ups = str(k_up) + ups = ups[0:ups.find(".") + 2] + + k_down = float(recv) / 1024 + downs = str(k_down) + downs = downs[0:downs.find(".") + 2] + + return (ups, downs) + else: + return None + + # byte to human by symbol + def bytes2human(self, value, symbol): + if symbol == "k": + value = value / 1024 + elif symbol == "m": + value = value / 1024 / 1024 + elif symbol == "g": + valuef = float(value) / 1024 / 1024 / 1024 + values = str(valuef) + value = values[0:values.find(".") + 2] + else: + pass + return str(value) + +if __name__ == "__main__": + mmm = MonitorBall() + # print mmm.get_network_flow_total() + # print mmm.get_network_flow_total("b") + # mmm.cleanup_memory() + # print mmm.get_cpu_percent() + # print mmm.get_cpu_percent(True) + # print mmm.get_cpu_percent() + # print mmm.get_free_memory("m") + # print mmm.get_used_memory("g") + # print mmm.get_total_memory("g") + # mmm.ttestt() + print mmm.get_memory_percent() + print mmm.get_total_memory() + print mmm.get_used_memory() + print mmm.get_free_memory() diff --git a/backends/youker-assistant-daemon/src/autostartmanage/__init__.py b/backends/youker-assistant-daemon/src/autostartmanage/__init__.py new file mode 100644 index 0000000..4265cc3 --- /dev/null +++ b/backends/youker-assistant-daemon/src/autostartmanage/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/env python diff --git a/backends/youker-assistant-daemon/src/autostartmanage/autostartmanage.py b/backends/youker-assistant-daemon/src/autostartmanage/autostartmanage.py new file mode 100644 index 0000000..f5f7e51 --- /dev/null +++ b/backends/youker-assistant-daemon/src/autostartmanage/autostartmanage.py @@ -0,0 +1,378 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + + +import os +import ConfigParser +import copy +import shutil +from pprint import pprint +import locale + +SECTION = 'Desktop Entry' +OPTION_H = 'Hidden' +OPTION_N = 'NoDisplay' +OPTION_O = 'OnlyShowIn' +OPTION_NOT = 'NotShowIn' +OPTION_X = 'X-GNOME-Autostart-enabled' + +class MyConfigParser(ConfigParser.ConfigParser): + + def __inin__(self, defaults=None): + ConfigParser.ConfigParser.__init__(self, defaults=None) + + def optionxform(self, optionstr): + return optionstr + +class Desktop_Autostart_Manage(): + + def __init__(self): + self.dic = {} + + def function(self, filename): + #config = ConfigParser.ConfigParser() + config = MyConfigParser() + config.read(filename) + + #flag = '' + current_desktop_env = self.get_desktop_env() + all_sections = config.sections() + + if SECTION in all_sections: + all_options = config.options(SECTION) + #pprint(all_options) + if OPTION_H in all_options and config.getboolean(SECTION, OPTION_H): + self.dic.setdefault(OPTION_H, []).append(filename) + #else: + #temp_h = '-' + OPTION_H + #self.dic.setdefault(temp_h, []).append(filename) + else: + if OPTION_N in all_options and config.getboolean(SECTION, OPTION_N): + self.dic.setdefault(OPTION_N, []).append(filename) + else: + #OPTION_O in all_options or OPTION_NOT in all_options or OPTION_X in all_options: + if (OPTION_O in all_options and current_desktop_env not in config.get(SECTION, OPTION_O)) or (OPTION_NOT in all_options and current_desktop_env in config.get(SECTION, OPTION_NOT)): + self.dic.setdefault('*showin', []).append(filename) + elif OPTION_X in all_options and not config.getboolean(SECTION, OPTION_X): + self.dic.setdefault('notautostart', []).append(filename) + else: + self.dic.setdefault('autostart', []).append(filename) + + #return flag + + def get_desktop_env(self): + desktop_name = os.getenv('XDG_CURRENT_DESKTOP') + if desktop_name is None: + desktop_name = os.getenv('XDG_SESSION_DESKTOP') + return desktop_name + + def _walk_dir(self, sdir): + scan_files = [] + for root, dirs, files in os.walk(sdir): + for name in files: + absolute_path = os.path.join(root, name) + if absolute_path.endswith('desktop'): + scan_files.append(absolute_path) + return scan_files + + def get_autostart_dirs(self): + dirs = [] + dirs_home = '' + dirs_dirs = '' + + dirs_home = os.getenv('XDG_CONFIG_HOME') + #pprint(dirs_dirs) + if dirs_home: + temp1 = [j for j in dirs_home.split(":") if os.path.exists(j)] + dirs.extend(temp1) + + dirs_dirs = os.getenv('XDG_CONFIG_DIRS') + #pprint(dirs_dirs) + if dirs_dirs: + temp2 = [i for i in dirs_dirs.split(":") if os.path.exists(i)] + dirs.extend(temp2) + + return dirs + + def check_dic(self, filename): + name = filename.split("/")[-1] + if name in [s.split("/")[-1] for s in self.dic.get(OPTION_H, ['']) if s]: + return True + else: + return False + + + + def init_dic(self): + dirs = self.get_autostart_dirs() + + for one in dirs: + x = self._walk_dir(one) + for value in x: + if self.check_dic(value): + continue + self.function(value) + #pprint(self.dic) + + def function_home(self, filename): + #config = ConfigParser.ConfigParser() + config = MyConfigParser() + config.read(filename) + + current_desktop_env = self.get_desktop_env() + all_sections = config.sections() + if SECTION in all_sections: + flag = '' + all_options = config.options(SECTION) + + if OPTION_H in all_options and config.getboolean(SECTION, OPTION_H): + flag = OPTION_H + else: + if OPTION_N in all_options and config.getboolean(SECTION, OPTION_N): + flag = OPTION_N + else: + if (OPTION_O in all_options and current_desktop_env not in config.get(SECTION, OPTION_O)) or (OPTION_NOT in all_options and current_desktop_env in config.get(SECTION, OPTION_NOT)): + flag = '*showin' + elif OPTION_X in all_options and not config.getboolean(SECTION, OPTION_X): + flag = 'notautostart' + else: + flag = 'autostart' + return flag + + def get_final_status(self): + self.init_dic() + + autostart_home_dir = os.path.expanduser('~/.config/autostart/') + + if os.path.exists(autostart_home_dir): + home_desktop_files = self._walk_dir(autostart_home_dir) + else: + home_desktop_files = [] + if home_desktop_files: + for single in home_desktop_files: + status = self.function_home(single) + #pprint(status) + if status == OPTION_H or status == OPTION_N: + autostart_1_list = self.dic.get('autostart', []) + if autostart_1_list: + new_autostart_list = [d for d in autostart_1_list if not d.count(single.split("/")[-1])] + self.dic['autostart'] = new_autostart_list + notautostart_1_list = self.dic.get('notautostart', []) + if notautostart_1_list: + #backup_list = copy.deepcopy(notautostart_list) + new_notautostart_list = filter(lambda x: not x.count(single.split("/")[-1]), notautostart_1_list) + self.dic['notautostart'] = new_notautostart_list + self.dic.setdefault(OPTION_H, []).append(single) + + if status == 'autostart': + autostart_2_list = self.dic.get('autostart', []) + if autostart_2_list: + new_autostart_2_list = [d for d in autostart_2_list if not d.count(single.split("/")[-1])] + self.dic['autostart'] = new_autostart_2_list + notautostart_2_list = self.dic.get('notautostart', []) + if notautostart_2_list: + #backup_list = copy.deepcopy(notautostart_list) + new_notautostart_2_list = filter(lambda x: not x.count(single.split("/")[-1]), notautostart_2_list) + self.dic['notautostart'] = new_notautostart_2_list + self.dic.setdefault('autostart', []).append(single) + + if status == 'notautostart': + autostart_3_list = self.dic.get('autostart', []) + if autostart_3_list: + new_autostart_3_list = [d for d in autostart_3_list if not d.count(single.split("/")[-1])] + self.dic['autostart'] = new_autostart_3_list + notautostart_3_list = self.dic.get('notautostart', []) + if notautostart_3_list: + #backup_list = copy.deepcopy(notautostart_list) + new_notautostart_3_list = filter(lambda x: not x.count(single.split("/")[-1]), notautostart_3_list) + self.dic['notautostart'] = new_notautostart_3_list + self.dic.setdefault('notautostart', []).append(single) + + else: + pass + + #pprint(self.dic) + + def change_single_status(self, filename): + #dirs = self.get_autostart_dirs() + status = '' + new_status = '' + hdir = os.path.expanduser('~/.config/autostart/') + mdir = '/usr/share/upstart/xdg/autostart/' + ldir = '/etc/xdg/autostart/' + + hfilename = hdir + filename + mfilename = mdir + filename + lfilename = ldir + filename + + if os.path.exists(mfilename): + #pprint(mfilename) + status = self.function_home(mfilename) + #pprint(status) + + if os.path.exists(lfilename): + if not status: + status = self.function_home(lfilename) + else: + pass + #pprint(status) + if os.path.exists(hfilename): + new_status = self.function_home(hfilename) + #pprint(new_status) + if status == new_status: + #change + if new_status == 'autostart': + #pprint("change false") + self.change_option_x(hfilename, 'false') + elif new_status == 'notautostart': + #pprint("change true") + self.change_option_x(hfilename, 'true') + else: + #remove + #pprint("remove") + os.remove(hfilename) + + else: + #touch + if not os.path.exists(hdir): + os.makedirs(hdir) + #pprint("copy") + shutil.copy(lfilename, hfilename) + if status == 'autostart': + #pprint("change false") + self.change_option_x(hfilename, 'false') + elif status == 'notautostart': + self.change_option_x(hfilename, 'true') + + + def change_option_x(self, name, value): + #cf = ConfigParser.ConfigParser() + cf = MyConfigParser() + cf.read(name) + + s = cf.sections() + o = cf.options(SECTION) + if SECTION in s: + #if OPTION_X in o: + #if cf.getboolean(SECTION, OPTION_X): + #cf.set(SECTION, OPTION_X, 'false') + #else: + #cf.set(SECTION, OPTION_X, 'true') + #else: + cf.set(SECTION, OPTION_X, value) + cf.write(open(name, "w")) + + def get_desktop_info(self, filepath, locale_language): + cf = MyConfigParser() + cf.read(filepath) + + info = [] + iconpath1 = '/usr/share/icons/hicolor/24x24/apps/' + iconpath2 = '/usr/share/pixmaps/' + s = cf.sections() + o = cf.options(SECTION) + info.append('Path:' + filepath) + + # + if SECTION in s: + if locale_language == "zh_CN": + if 'Name[zh_CN]' in o: + info.append('Name:' + cf.get(SECTION, 'Name[zh_CN]')) + else: + info.append('Name:' + cf.get(SECTION, 'Name')) + + if 'Comment[zh_CN]' in o: + info.append('Comment:' + cf.get(SECTION, 'Comment[zh_CN]')) + elif 'Comment' in o: + info.append('Comment:' + cf.get(SECTION, 'Comment')) + else: + info.append('Comment:') + else: + info.append('Name:' + cf.get(SECTION, 'Name')) + if 'Comment' in o: + info.append('Comment:' + cf.get(SECTION, 'Comment')) + else: + info.append('Comment:') + + if 'Icon' in o: + tempicon = cf.get(SECTION, 'Icon') + if not tempicon.endswith('.png') and not tempicon.endswith('.jpg'): + tempicon = tempicon + '.png' + if os.path.exists(iconpath2 + tempicon): + info.append('Icon:' + iconpath2 + tempicon) + elif os.path.exists(iconpath1 + tempicon): + info.append('Icon:' + iconpath1 + tempicon) + else: + info.append('Icon:/usr/share/pixmaps/autostart-default.png') + else: + info.append('Icon:/usr/share/pixmaps/autostart-default.png') + + return info + + +def interface_get_status(fobj): + locale_language = locale.getdefaultlocale()[0] + try: + obj = Desktop_Autostart_Manage() + obj.get_final_status() + up = obj.dic.get("autostart", []) + if up: + for upvalue in up: + up_list = obj.get_desktop_info(upvalue, locale_language) + up_list.append('Status:' + 'true') + fobj.autostartmanage_data_signal(up_list) + + down = obj.dic.get("notautostart", []) + if down: + for downvalue in down: + down_list = obj.get_desktop_info(downvalue, locale_language) + down_list.append('Status:' + 'false') + fobj.autostartmanage_data_signal(down_list) + + except Exception, e: + fobj.autostartmanage_error_signal(str(e)) + else: + fobj.autostartmanage_status_signal("complete") + +def interface_get_single_status(fobj, path): + obj = Desktop_Autostart_Manage() + status = obj.function_home(path) + if status == "autostart": + return True + elif status == "notautostart": + return False + else: + return False + +def interface_change_status(fobj, filename): + try: + obj = Desktop_Autostart_Manage() + obj.change_single_status(filename) + except Exception, e: + fobj.autostartmanage_error_signal(str(e)) +# else: +# fobj.autostartmanage_status_signal("complete") + +if __name__ == "__main__": + obj = Desktop_Autostart_Manage() + #obj.main() + #obj.function_home('/home/ice/.config/autostart/ubuntu-kylin-software-center-autostart.desktop') + #obj.get_final_status() + #obj.change_single_status('ubuntu-kylin-software-center-autostart.desktop') + #interface_get_status() + #interface_change_status() diff --git a/backends/youker-assistant-daemon/src/beautify/__init__.py b/backends/youker-assistant-daemon/src/beautify/__init__.py new file mode 100644 index 0000000..013e4b7 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/backends/youker-assistant-daemon/src/beautify/ccm/Conflicts.py b/backends/youker-assistant-daemon/src/beautify/ccm/Conflicts.py new file mode 100644 index 0000000..9569b94 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/ccm/Conflicts.py @@ -0,0 +1,518 @@ +# -*- coding: UTF-8 -*- + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Authors: Quinn Storm (quinn@beryl-project.org) +# Patrick Niklaus (marex@opencompositing.org) +# Guillaume Seguin (guillaume@segu.in) +# Christopher Williams (christopherw@verizon.net) +# Copyright (C) 2007 Quinn Storm + +from gi.repository import Gtk + +from Constants import * +from Utils import * + +import locale +import gettext +locale.setlocale(locale.LC_ALL, "") +gettext.bindtextdomain("ccsm", DataDir + "/locale") +gettext.textdomain("ccsm") +_ = gettext.gettext + +class Conflict: + def __init__(self, autoResolve): + self.AutoResolve = autoResolve + + # buttons = (text, type/icon, response_id) + def Ask(self, message, buttons, custom_widgets=None): + if self.AutoResolve: + return Gtk.ResponseType.YES + + dialog = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL, type=Gtk.MessageType.WARNING) + + for text, icon, response in buttons: + button = Gtk.Button(text) + button.set_image(Gtk.Image.new_from_stock(icon, Gtk.IconSize.BUTTON)) + dialog.add_action_widget(button, response) + + if custom_widgets != None: + for widget in custom_widgets: + dialog.vbox.pack_start(widget, False, False) + + dialog.set_markup(message) + dialog.show_all() + answer = dialog.run() + dialog.destroy() + + return answer + +class ActionConflict (Conflict): + + ActionTypes = set(('Bell', 'Button', 'Edge', 'Key')) + + def __init__ (self, setting, settings, autoResolve): + + def ExcludeInternal (settings): + for setting in settings: + if not setting.Info[0]: + yield setting + + Conflict.__init__(self, autoResolve) + self.Conflicts = [] + self.Name = "" + self.Setting = setting + + if settings is None: + settings = [] + + self.Settings = settings + + # if the action is internal, include all global actions plus internal + # actions from the same plugin. If it is global, include all actions. + + if not settings: + for n in self.Setting.Plugin.Context.Plugins: + plugin = self.Setting.Plugin.Context.Plugins[n] + if plugin.Enabled: + pluginActions = GetSettings(plugin, types=self.ActionTypes) + + if len(setting.Info) and setting.Info[0] and plugin is not setting.Plugin: + settings.extend(ExcludeInternal(pluginActions)) + else: + settings.extend(pluginActions) + + def Resolve (self, updater = None): + if len (self.Conflicts): + for setting in self.Conflicts: + answer = self.AskUser (self.Setting, setting) + if answer == Gtk.ResponseType.YES: + setting.Value = 'Disabled' + if updater: + updater.UpdateSetting (setting) + if answer == Gtk.ResponseType.NO: + return False + + return True + + def AskUser (self, setting, conflict): + msg = _("The new value for the %(binding)s binding for the action %(action)s "\ + "in plugin %(plugin)s conflicts with the action %(action_conflict)s of the %(plugin_conflict)s plugin.\n"\ + "Do you wish to disable %(action_conflict)s in the %(plugin_conflict)s plugin?") + + msg_dict = {'binding': self.Name, + 'action': setting.ShortDesc, + 'plugin': setting.Plugin.ShortDesc, + 'action_conflict': conflict.ShortDesc, + 'plugin_conflict': conflict.Plugin.ShortDesc} + + msg = msg % protect_markup_dict (msg_dict) + + yesButton = (_("Disable %(action_conflict)s") % msg_dict, Gtk.STOCK_YES, Gtk.ResponseType.YES) + noButton = (_("Don't set %(action)s") % msg_dict, Gtk.STOCK_NO, Gtk.ResponseType.NO) + ignoreButton = (_("Set %(action)s anyway") % msg_dict, Gtk.STOCK_STOP, Gtk.ResponseType.REJECT) + + return self.Ask (msg, (ignoreButton, noButton, yesButton)) + +class KeyConflict(ActionConflict): + def __init__(self, setting, newValue, settings=None, autoResolve=False, ignoreOld=False): + ActionConflict.__init__(self, setting, settings, autoResolve) + self.Name = _("key") + + if not newValue: + return + + newValue = newValue.lower () + oldValue = self.Setting.Value.lower () + badValues = ["disabled", "none"] + if not ignoreOld: + badValues.append (oldValue) + if newValue in badValues: + return + + for s in self.Settings: + if s is setting: + continue + if s.Type == 'Key': + if s.Value.lower() == newValue: + self.Conflicts.append (s) + +class ButtonConflict(ActionConflict): + def __init__(self, setting, newValue, settings=None, autoResolve=False, ignoreOld=False): + ActionConflict.__init__(self, setting, settings, autoResolve) + self.Name = _("button") + + if not newValue: + return + + newValue = newValue.lower () + oldValue = self.Setting.Value.lower () + badValues = ["disabled", "none"] + if not ignoreOld: + badValues.append (oldValue) + if newValue in badValues: + return + + for s in self.Settings: + if s is setting: + continue + if s.Type == 'Button': + if s.Value.lower() == newValue: + self.Conflicts.append (s) + +class EdgeConflict(ActionConflict): + def __init__(self, setting, newValue, settings=None, autoResolve=False, ignoreOld=False): + ActionConflict.__init__(self, setting, settings, autoResolve) + self.Name = _("edge") + + if not newValue: + return + + newEdges = set(newValue.split("|")) + + if not ignoreOld: + oldEdges = set(self.Setting.Value.split("|")) + diff = newEdges - oldEdges + if diff: + newEdges = diff # no need to check edges that were already set + else: + return + + for s in self.Settings: + if s is setting: + continue + elif s.Type == 'Edge': + settingEdges = set(s.Value.split("|")) + union = newEdges & settingEdges + if union: + for edge in union: + self.Conflicts.append ((s, edge)) + break + + def Resolve (self, updater = None): + if len (self.Conflicts): + for setting, edge in self.Conflicts: + answer = self.AskUser (self.Setting, setting) + if answer == Gtk.ResponseType.YES: + value = setting.Value.split ("|") + value.remove (edge) + setting.Value = "|".join (value) + if updater: + updater.UpdateSetting (setting) + if answer == Gtk.ResponseType.NO: + return False + + return True + +# Not used for plugin dependencies (which are handled by ccs) but own feature checking e.g. image support +class FeatureRequirement(Conflict): + def __init__(self, context, feature, autoResolve=False): + Conflict.__init__(self, autoResolve) + self.Requirements = [] + self.Context = context + self.Feature = feature + + self.Found = False + for plugin in context.Plugins.values(): + if feature in plugin.Features: + self.Found = True + if not plugin.Enabled: + self.Requirements.append(plugin) + + def Resolve(self): + if len(self.Requirements) == 0 and self.Found: + return True + elif not self.Found: + answer = self.ErrorAskUser() + if answer == Gtk.ResponseType.YES: + return True + else: + return False + + for plugin in self.Requirements: + answer = self.AskUser(plugin) + if answer == Gtk.ResponseType.YES: + plugin.Enabled = True + self.Context.Write() + return True + + def ErrorAskUser(self): + msg = _("You are trying to use the feature %(feature)s which is not provided by any plugin.\n"\ + "Do you wish to use this feature anyway?") + + msg_dict = {'feature': self.Feature} + + msg = msg % protect_markup_dict (msg_dict) + + yesButton = (_("Use %(feature)s") % msg_dict, Gtk.STOCK_YES, Gtk.ResponseType.YES) + noButton = (_("Don't use %(feature)s") % msg_dict, Gtk.STOCK_NO, Gtk.ResponseType.NO) + + answer = self.Ask(msg, (noButton, yesButton)) + + return answer + + def AskUser(self, plugin): + msg = _("You are trying to use the feature %(feature)s which is provided by %(plugin)s.\n"\ + "This plugin is currently disabled.\n"\ + "Do you wish to enable %(plugin)s so the feature is available?") + + msg_dict = {'feature': self.Feature, + 'plugin': plugin.ShortDesc} + + msg = msg % protect_markup_dict (msg_dict) + + yesButton = (_("Enable %(plugin)s") % msg_dict, Gtk.STOCK_YES, Gtk.ResponseType.YES) + noButton = (_("Don't enable %(feature)s") % msg_dict, Gtk.STOCK_NO, Gtk.ResponseType.NO) + + answer = self.Ask(msg, (noButton, yesButton)) + + return answer + +class PluginConflict(Conflict): + def __init__(self, plugin, conflicts, autoResolve=False): + Conflict.__init__(self, autoResolve) + self.Conflicts = conflicts + self.Plugin = plugin + + def Resolve(self): + for conflict in self.Conflicts: + if conflict[0] == 'ConflictFeature': + answer = self.AskUser(self.Plugin, conflict) + if answer == Gtk.ResponseType.YES: + disableConflicts = conflict[2][0].DisableConflicts + con = PluginConflict(conflict[2][0], disableConflicts, + self.AutoResolve) + if con.Resolve(): + conflict[2][0].Enabled = False + else: + return False + else: + return False + + elif conflict[0] == 'ConflictPlugin': + answer = self.AskUser(self.Plugin, conflict) + if answer == Gtk.ResponseType.YES: + disableConflicts = conflict[2][0].DisableConflicts + con = PluginConflict(conflict[2][0], disableConflicts, + self.AutoResolve) + if con.Resolve(): + conflict[2][0].Enabled = False + else: + return False + else: + return False + + elif conflict[0] == 'RequiresFeature': + answer, choice = self.AskUser(self.Plugin, conflict) + if answer == Gtk.ResponseType.YES: + for plg in conflict[2]: + if plg.ShortDesc == choice: + enableConflicts = plg.EnableConflicts + con = PluginConflict(plg, enableConflicts, + self.AutoResolve) + if con.Resolve(): + plg.Enabled = True + else: + return False + break + else: + return False + + elif conflict[0] == 'RequiresPlugin': + answer = self.AskUser(self.Plugin, conflict) + if answer == Gtk.ResponseType.YES: + enableConflicts = conflict[2][0].EnableConflicts + con = PluginConflict(conflict[2][0], enableConflicts, + self.AutoResolve) + if con.Resolve(): + conflict[2][0].Enabled = True + else: + return False + else: + return False + + elif conflict[0] == 'FeatureNeeded': + answer = self.AskUser(self.Plugin, conflict) + if answer == Gtk.ResponseType.YES: + for plg in conflict[2]: + disableConflicts = plg.DisableConflicts + con = PluginConflict(plg, disableConflicts, + self.AutoResolve) + if con.Resolve(): + plg.Enabled = False + else: + return False + else: + return False + + elif conflict[0] == 'PluginNeeded': + answer = self.AskUser(self.Plugin, conflict) + if answer == Gtk.ResponseType.YES: + for plg in conflict[2]: + disableConflicts = plg.DisableConflicts + con = PluginConflict(plg, disableConflicts, + self.AutoResolve) + if con.Resolve(): + plg.Enabled = False + else: + return False + else: + return False + + # Only when enabling a plugin + types = [] + actionConflicts = [] + if not self.Plugin.Enabled and not self.AutoResolve: + for setting in GetSettings(self.Plugin): + conflict = None + if setting.Type == 'Key': + conflict = KeyConflict(setting, setting.Value, ignoreOld=True) + elif setting.Type == 'Button': + conflict = ButtonConflict(setting, setting.Value, ignoreOld=True) + elif setting.Type == 'Edge': + conflict = EdgeConflict(setting, setting.Value, ignoreOld=True) + + # Conflicts were found + if conflict and conflict.Conflicts: + name = conflict.Name + if name not in types: + types.append(name) + actionConflicts.append(conflict) + + if actionConflicts: + answer = self.AskUser(self.Plugin, ('ConflictAction', types)) + if answer == Gtk.ResponseType.YES: + for conflict in actionConflicts: + conflict.Resolve() + + return True + + def AskUser(self, plugin, conflict): + msg = "" + okMsg = "" + cancelMsg = "" + widgets = [] + + # CCSM custom conflict + if conflict[0] == 'ConflictAction': + msg = _("Some %(bindings)s bindings of Plugin %(plugin)s " \ + "conflict with other plugins. Do you want to resolve " \ + "these conflicts?") + + types = conflict[1] + bindings = ", ".join(types[:-1]) + if len(types) > 1: + bindings = "%s and %s" % (bindings, types[-1]) + + msg_dict = {'plugin': plugin.ShortDesc, + 'bindings': bindings} + + msg = msg % protect_markup_dict (msg_dict) + + okMsg = _("Resolve conflicts") % msg_dict + cancelMsg = _("Ignore conflicts") % msg_dict + + elif conflict[0] == 'ConflictFeature': + msg = _("Plugin %(plugin_conflict)s provides feature " \ + "%(feature)s which is also provided by " \ + "%(plugin)s") + + msg_dict = {'plugin_conflict': conflict[2][0].ShortDesc, + 'feature': conflict[1], + 'plugin': plugin.ShortDesc} + + msg = msg % protect_markup_dict (msg_dict) + + okMsg = _("Disable %(plugin_conflict)s") % msg_dict + cancelMsg = _("Don't enable %(plugin)s") % msg_dict + + elif conflict[0] == 'ConflictPlugin': + msg = _("Plugin %(plugin_conflict)s conflicts with " \ + "%(plugin)s.") + msg = msg % protect_markup_dict (msg_dict) + + okMsg = _("Disable %(plugin_conflict)s") % msg_dict + cancelMsg = _("Don't enable %(plugin)s") % msg_dict + + elif conflict[0] == 'RequiresFeature': + pluginList = ', '.join("\"%s\"" % plugin.ShortDesc for plugin in conflict[2]) + msg = _("%(plugin)s requires feature %(feature)s " \ + "which is provided by the following " \ + "plugins:\n%(plugin_list)s") + + msg_dict = {'plugin': plugin.ShortDesc, + 'feature': conflict[1], + 'plugin_list': pluginList} + + msg = msg % protect_markup_dict (msg_dict) + + cmb = Gtk.ComboBoxText() + for plugin in conflict[2]: + cmb.append_text(plugin.ShortDesc) + cmb.set_active(0) + widgets.append(cmb) + + okMsg = _("Enable these plugins") + cancelMsg = _("Don't enable %(plugin)s") % msg_dict + + elif conflict[0] == 'RequiresPlugin': + msg = _("%(plugin)s requires the plugin %(require)s.") + + msg_dict = {'plugin': plugin.ShortDesc, + 'require': conflict[2][0].ShortDesc} + + msg = msg % protect_markup_dict (msg_dict) + + okMsg = _("Enable %(require)s") % msg_dict + cancelMsg = _("Don't enable %(plugin)s") % msg_dict + + elif conflict[0] == 'FeatureNeeded': + pluginList = ', '.join("\"%s\"" % plugin.ShortDesc for plugin in conflict[2]) + msg = _("%(plugin)s provides the feature " \ + "%(feature)s which is required by the plugins " \ + "%(plugin_list)s.") + + msg_dict = {'plugin': plugin.ShortDesc, + 'feature': conflict[1], + 'plugin_list': pluginList} + + msg = msg % protect_markup_dict (msg_dict) + + okMsg = _("Disable these plugins") + cancelMsg = _("Don't disable %(plugin)s") % msg_dict + + elif conflict[0] == 'PluginNeeded': + pluginList = ', '.join("\"%s\"" % plugin.ShortDesc for plugin in conflict[2]) + msg = _("%(plugin)s is required by the plugins " \ + "%(plugin_list)s.") + + msg_dict = {'plugin': plugin.ShortDesc, + 'plugin_list': pluginList} + + msg = msg % protect_markup_dict (msg_dict) + + okMsg = _("Disable these plugins") + cancelMsg = _("Don't disable %(plugin)s") % msg_dict + + okButton = (okMsg, Gtk.STOCK_OK, Gtk.ResponseType.YES) + cancelButton = (cancelMsg, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) + + answer = self.Ask(msg, (cancelButton, okButton), widgets) + if conflict[0] == 'RequiresFeature': + choice = widgets[0].get_active_text() + return answer, choice + + return answer + e diff --git a/backends/youker-assistant-daemon/src/beautify/ccm/Constants.py b/backends/youker-assistant-daemon/src/beautify/ccm/Constants.py new file mode 100644 index 0000000..f4e546a --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/ccm/Constants.py @@ -0,0 +1,96 @@ +# -*- coding: UTF-8 -*- + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Authors: Quinn Storm (quinn@beryl-project.org) +# Patrick Niklaus (marex@opencompositing.org) +# Guillaume Seguin (guillaume@segu.in) +# Christopher Williams (christopherw@verizon.net) +# Copyright (C) 2007 Quinn Storm + +from gi.repository import Gtk, Gdk + +# Current Screen +# +CurrentScreenNum = Gdk.Display.get_default().get_n_screens() + +# Settings Table +# +TableDef = Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND +TableX = 4 +TableY = 2 + +# Action Constants +# +KeyModifier = ["Shift", "Control", "Mod1", "Mod2", "Mod3", "Mod4", + "Mod5", "Alt", "Meta", "Super", "Hyper", "ModeSwitch"] +Edges = ["Left", "Right", "Top", "Bottom", + "TopLeft", "TopRight", "BottomLeft", "BottomRight"] + +# Label Styles +# +HeaderMarkup = "%s" + +# Image Types +# +ImageNone = 0 +ImagePlugin = 1 +ImageCategory = 2 +ImageThemed = 3 +ImageStock = 4 + +# Filter Levels +# +FilterName = 1 << 0 +FilterLongDesc = 1 << 1 +FilterValue = 1 << 2 # Settings Only +FilterCategory = 1 << 3 # Plugins Only +FilterAll = FilterName | FilterLongDesc | FilterValue | FilterCategory + +# Paths +# +DataDir = "/usr/share" +IconDir = DataDir+"/ccsm/icons" +PixmapDir = DataDir+"/ccsm/images" + +# Version +# +Version = "0.9.4" + + +# Translation +# +import locale +import gettext +locale.setlocale(locale.LC_ALL, "") +gettext.bindtextdomain("ccsm", DataDir + "/locale") +gettext.textdomain("ccsm") +_ = gettext.gettext + +# Category Transaltion Table +# Just to get them into gettext +# +CategoryTranslation = { +"General": _("General"), +"Accessibility": _("Accessibility"), +"Desktop": _("Desktop"), +"Extras": _("Extras"), +"Window Management": _("Window Management"), +"Effects": _("Effects"), +"Image Loading": _("Image Loading"), +"Utility": _("Utility"), +"All": _("All"), +"Uncategorized": _("Uncategorized") +} diff --git a/backends/youker-assistant-daemon/src/beautify/ccm/Utils.py b/backends/youker-assistant-daemon/src/beautify/ccm/Utils.py new file mode 100644 index 0000000..18cf482 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/ccm/Utils.py @@ -0,0 +1,415 @@ +# -*- coding: UTF-8 -*- + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Authors: Quinn Storm (quinn@beryl-project.org) +# Patrick Niklaus (marex@opencompositing.org) +# Guillaume Seguin (guillaume@segu.in) +# Christopher Williams (christopherw@verizon.net) +# Copyright (C) 2007 Quinn Storm + +import os +import weakref + +from gi.repository import GObject, Gtk, Gdk, Pango + +from Constants import * +from cgi import escape as protect_pango_markup +import operator +import itertools + +import locale +import gettext +locale.setlocale(locale.LC_ALL, "") +gettext.bindtextdomain("ccsm", DataDir + "/locale") +gettext.textdomain("ccsm") +_ = gettext.gettext + +IconTheme = Gtk.IconTheme.get_default() +#TODO +#if not IconDir in IconTheme.get_search_path(): +# IconTheme.prepend_search_path(IconDir) + +def gtk_process_events (): + while Gtk.events_pending (): + Gtk.main_iteration () + +def getScreens(): + screens = [] + display = Gdk.Display.get_default() + nScreens = display.get_n_screens() + for i in range(nScreens): + screens.append(i) + return screens + +def getDefaultScreen(): + display = Gdk.Display.get_default() + return display.get_default_screen().get_number() + +def protect_markup_dict (dict_): + return dict((k, protect_pango_markup (v)) for (k, v) in dict_.items()) + +class Image (Gtk.Image): + + def __init__ (self, name = None, type = ImageNone, size = 32, + useMissingImage = False): + GObject.GObject.__init__ (self) + + if not name: + return + + if useMissingImage: + self.set_from_stock (Gtk.STOCK_MISSING_IMAGE, + Gtk.IconSize.LARGE_TOOLBAR) + return + + try: + if type in (ImagePlugin, ImageCategory, ImageThemed): + pixbuf = None + + if type == ImagePlugin: + name = "plugin-" + name + try: + pixbuf = IconTheme.load_icon (name, size, 0) + except GObject.GError: + pixbuf = IconTheme.load_icon ("plugin-unknown", size, 0) + + elif type == ImageCategory: + name = "plugins-" + name + try: + pixbuf = IconTheme.load_icon (name, size, 0) + except GObject.GError: + pixbuf = IconTheme.load_icon ("plugins-unknown", size, 0) + + else: + pixbuf = IconTheme.load_icon (name, size, 0) + + self.set_from_pixbuf (pixbuf) + + elif type == ImageStock: + self.set_from_stock (name, size) + except GObject.GError as e: + self.set_from_stock (Gtk.STOCK_MISSING_IMAGE, Gtk.IconSize.BUTTON) + +class ActionImage (Gtk.Alignment): + + map = { + "keyboard" : "input-keyboard", + "button" : "input-mouse", + "edges" : "video-display", + "bell" : "audio-x-generic" + } + + def __init__ (self, action): + GObject.GObject.__init__ (self, 0, 0.5) + self.set_padding (0, 0, 0, 10) + if action in self.map: action = self.map[action] + self.add (Image (name = action, type = ImageThemed, size = 22)) + +class SizedButton (Gtk.Button): + + minWidth = -1 + minHeight = -1 + + def __init__ (self, minWidth = -1, minHeight = -1): + super (SizedButton, self).__init__ () + self.minWidth = minWidth + self.minHeight = minHeight + self.connect ("size-request", self.adjust_size) + + def adjust_size (self, widget, requisition): + width, height = requisition.width, requisition.height + newWidth = max (width, self.minWidth) + newHeight = max (height, self.minHeight) + self.set_size_request (newWidth, newHeight) + +class PrettyButton (Gtk.Button): + __gsignals__ = { + 'draw': 'override', + } + + _old_toplevel = None + + def __init__ (self): + super (PrettyButton, self).__init__ () + self.states = { + "focus" : False, + "pointer" : False + } + self.set_size_request (200, -1) + self.set_relief (Gtk.ReliefStyle.NONE) + self.connect ("focus-in-event", self.update_state_in, "focus") + self.connect ("focus-out-event", self.update_state_out, "focus") + self.connect ("hierarchy-changed", self.hierarchy_changed) + + def hierarchy_changed (self, widget, old_toplevel): + if old_toplevel == self._old_toplevel: + return + + if not old_toplevel and self.state != Gtk.StateType.NORMAL: + self.set_state(Gtk.StateType.PRELIGHT) + self.set_state(Gtk.StateType.NORMAL) + + self._old_toplevel = old_toplevel + + + def update_state_in (self, *args): + state = args[-1] + self.set_state (Gtk.StateType.PRELIGHT) + self.states[state] = True + + def update_state_out (self, *args): + state = args[-1] + self.states[state] = False + if True in self.states.values (): + self.set_state (Gtk.StateType.PRELIGHT) + else: + self.set_state (Gtk.StateType.NORMAL) + + def do_expose_event (self, event): + has_focus = self.flags () & Gtk.HAS_FOCUS + if has_focus: + self.unset_flags (Gtk.HAS_FOCUS) + + ret = super (PrettyButton, self).do_expose_event (self, event) + + if has_focus: + self.set_flags (Gtk.HAS_FOCUS) + + return ret + +class Label(Gtk.Label): + def __init__(self, value = "", wrap = 160): + GObject.GObject.__init__(self, value) + self.props.xalign = 0 + self.props.wrap_mode = Pango.WrapMode.WORD + self.set_line_wrap(True) + self.set_size_request(wrap, -1) + +class NotFoundBox(Gtk.Alignment): + def __init__(self, value=""): + GObject.GObject.__init__(self, 0.5, 0.5, 0.0, 0.0) + + box = Gtk.HBox() + self.Warning = Gtk.Label() + self.Markup = _("No matches found. \n\n Your filter \"%s\" does not match any items.") + value = protect_pango_markup(value) + self.Warning.set_markup(self.Markup % value) + image = Image("face-surprise", ImageThemed, 48) + + box.pack_start(image, False, False, 0) + box.pack_start(self.Warning, True, True, 15) + self.add(box) + + def update(self, value): + value = protect_pango_markup(value) + self.Warning.set_markup(self.Markup % value) + +class IdleSettingsParser: + def __init__(self, context, main): + def FilterPlugin (p): + return not p.Initialized and p.Enabled + + self.Context = context + self.Main = main + self.PluginList = [p for p in self.Context.Plugins.items() if FilterPlugin(p[1])] + nCategories = len (main.MainPage.RightWidget._boxes) + self.CategoryLoadIconsList = list(range(3, nCategories)) # Skip the first 3 + print('Loading icons...') + + GObject.timeout_add (150, self.Wait) + + def Wait(self): + if not self.PluginList: + return False + + if len (self.CategoryLoadIconsList) == 0: # If we're done loading icons + GObject.idle_add (self.ParseSettings) + else: + GObject.idle_add (self.LoadCategoryIcons) + + return False + + def ParseSettings(self): + name, plugin = self.PluginList[0] + + if not plugin.Initialized: + plugin.Update () + self.Main.RefreshPage(plugin) + + self.PluginList.remove (self.PluginList[0]) + + GObject.timeout_add (200, self.Wait) + + return False + + def LoadCategoryIcons(self): + from ccm.Widgets import PluginButton + + catIndex = self.CategoryLoadIconsList[0] + pluginWindow = self.Main.MainPage.RightWidget + categoryBox = pluginWindow._boxes[catIndex] + for (pluginIndex, plugin) in \ + enumerate (categoryBox.get_unfiltered_plugins()): + categoryBox._buttons[pluginIndex] = PluginButton (plugin) + categoryBox.rebuild_table (categoryBox._current_cols, True) + pluginWindow.connect_buttons (categoryBox) + + self.CategoryLoadIconsList.remove (self.CategoryLoadIconsList[0]) + + GObject.timeout_add (150, self.Wait) + + return False + +# Updates all registered setting when they where changed through CompizConfig +class Updater: + + def __init__ (self): + self.VisibleSettings = {} + self.Plugins = [] + self.Block = 0 + + def SetContext (self, context): + self.Context = context + + GObject.timeout_add (2000, self.Update) + + def Append (self, widget): + reference = weakref.ref(widget) + setting = widget.Setting + self.VisibleSettings.setdefault((setting.Plugin.Name, setting.Name), []).append(reference) + + def AppendPlugin (self, plugin): + self.Plugins.append (plugin) + + def Remove (self, widget): + setting = widget.Setting + l = self.VisibleSettings.get((setting.Plugin.Name, setting.Name)) + if not l: + return + for i, ref in enumerate(list(l)): + if ref() is widget: + l.remove(ref) + break + + def UpdatePlugins(self): + for plugin in self.Plugins: + plugin.Read() + + def UpdateSetting (self, setting): + widgets = self.VisibleSettings.get((setting.Plugin.Name, setting.Name)) + if not widgets: + return + for reference in widgets: + widget = reference() + if widget is not None: + widget.Read() + + def Update (self): + if self.Block > 0: + return True + + if self.Context.ProcessEvents(): + changed = self.Context.ChangedSettings + if [s for s in changed if s.Plugin.Name == "core" and s.Name == "active_plugins"]: + self.UpdatePlugins() + + for setting in list(changed): + widgets = self.VisibleSettings.get((setting.Plugin.Name, setting.Name)) + if widgets: + for reference in widgets: + widget = reference() + if widget is not None: + widget.Read() + if widget.List: + widget.ListWidget.Read() + changed.remove(setting) + + self.Context.ChangedSettings = changed + + return True + +GlobalUpdater = Updater () + +class PluginSetting: + + def __init__ (self, plugin, widget, handler): + self.Widget = widget + self.Plugin = plugin + self.Handler = handler + GlobalUpdater.AppendPlugin (self) + + def Read (self): + widget = self.Widget + widget.handler_block(self.Handler) + widget.set_active (self.Plugin.Enabled) + widget.set_sensitive (self.Plugin.Context.AutoSort) + widget.handler_unblock(self.Handler) + +class PureVirtualError(Exception): + pass + +def SettingKeyFunc(value): + return value.Plugin.Ranking[value.Name] + +def CategoryKeyFunc(category): + if 'General' == category: + return '' + else: + return category or 'zzzzzzzz' + +def GroupIndexKeyFunc(item): + return item[1][0] + +FirstItemKeyFunc = operator.itemgetter(0) + +EnumSettingKeyFunc = operator.itemgetter(1) + +PluginKeyFunc = operator.attrgetter('ShortDesc') + +def HasOnlyType (settings, stype): + return settings and not [s for s in settings if s.Type != stype] + +def GetSettings(group, types=None): + + def TypeFilter (settings, types): + for setting in settings: + if setting.Type in types: + yield setting + + if types: + screen = TypeFilter(iter(group.Screen.values()), types) + else: + screen = iter(group.Screen.values()) + + return screen + +# Support python 2.4 +try: + any + all +except NameError: + def any(iterable): + for element in iterable: + if element: + return True + return False + + def all(iterable): + for element in iterable: + if not element: + return False + return True + diff --git a/backends/youker-assistant-daemon/src/beautify/ccm/__init__.py b/backends/youker-assistant-daemon/src/beautify/ccm/__init__.py new file mode 100644 index 0000000..55d4ba6 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/ccm/__init__.py @@ -0,0 +1,3 @@ +from Conflicts import * +from Constants import * +from Utils import * diff --git a/backends/youker-assistant-daemon/src/beautify/cloudconfig.py b/backends/youker-assistant-daemon/src/beautify/cloudconfig.py new file mode 100644 index 0000000..a0c2ff1 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/cloudconfig.py @@ -0,0 +1,598 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import ConfigParser +import os, sys +import threading +import gsettings +from shutil import copy + +class CloudConfig(threading.Thread): + def __init__(self, sysdaemon): + self.sysdaemon = sysdaemon + self.conf = ConfigParser.ConfigParser() + self.home = os.path.expandvars('$HOME') + self.youker_path = './' + self.kuaipan_path = '' + + # write profiles + def write_conf(self, section, conf_id, conf_schema, conf_path, conf_key, conf_type): + value = gsettings.get(conf_schema, conf_path, conf_key, conf_type) + if (conf_id in section): + self.conf.set(conf_id, 'value', str(value)) + else: + self.conf.add_section(conf_id) + self.conf.set(conf_id, 'schema', conf_schema) + self.conf.set(conf_id, 'path', conf_path) + self.conf.set(conf_id, 'key', conf_key) + self.conf.set(conf_id, 'type', conf_type) + self.conf.set(conf_id, 'value', str(value)) + + # Save system configuration + def save_configuration_to_local_file(self, file_name): + pass +# self.conf.read(file_name) +# sections = self.conf.sections() + +# # 桌面图标显示控制----------------------------- +# self.write_conf(sections, 'show_desktop_icons', +# 'org.gnome.desktop.background', +# None, 'show-desktop-icons', 'boolean') +# self.write_conf(sections, 'show_homefolder', +# 'org.gnome.nautilus.desktop', +# None, 'home-icon-visible', 'boolean') +# self.write_conf(sections, 'show_network', +# 'org.gnome.nautilus.desktop', +# None, 'network-icon-visible', 'boolean') +# self.write_conf(sections, 'show_trash', +# 'org.gnome.nautilus.desktop', +# None, 'trash-icon-visible', 'boolean') +# self.write_conf(sections, 'show_devices', +# 'org.gnome.nautilus.desktop', +# None, 'volumes-visible', 'boolean') + +# # 启动器设置---------------------------------- +# self.write_conf(sections, 'launcher_autohide', +# 'org.compiz.unityshell', +# '/org/compiz/profiles/unity/plugins/unityshell/', +# 'launcher-hide-mode', 'int') +# self.write_conf(sections, 'launcher_icon_size', +# 'org.compiz.unityshell', +# '/org/compiz/profiles/unity/plugins/unityshell/', +# 'icon-size', 'int') + +# # 触摸板设置----------------------------------- +## self.write_conf(sections, 'touchpad_enable', +## 'org.gnome.settings-daemon.peripherals.touchpad', +## None, 'touchpad-enabled', 'boolean') +## self.write_conf(sections, 'touch_horizontal_scrolling', +## 'org.gnome.settings-daemon.peripherals.touchpad', +## None, 'horiz-scroll-enabled', 'boolean') +## self.write_conf(sections, 'type_scroll_bar', +## 'com.canonical.desktop.interface', +## None, 'scrollbar-mode', 'string') +## self.write_conf(sections, 'touchpad_scrolling_mode', +## 'org.gnome.settings-daemon.peripherals.touchpad', +## None, 'scroll-method', 'string') + +# # 字体设置------------------------------------- +# self.write_conf(sections, 'default_font', +# 'org.gnome.desktop.interface', +# None, 'font-name', 'string') +# self.write_conf(sections, 'desktop_font', +# 'org.gnome.nautilus.desktop', +# None, 'font', 'string') +# self.write_conf(sections, 'document_font', +# 'org.gnome.desktop.interface', +# None, 'document-font-name', 'string') +# self.write_conf(sections, 'monospace_font', +# 'org.gnome.desktop.interface', +# None, 'monospace-font-name', 'string') +# self.write_conf(sections, 'window_title_font', +# 'org.gnome.desktop.wm.preferences', +# None, 'titlebar-font', 'string') +# self.write_conf(sections, 'font_zoom', +# 'org.gnome.desktop.interface', +# None, 'text-scaling-factor', 'double') +# self.write_conf(sections, 'font_hinting', +# 'org.gnome.settings-daemon.plugins.xsettings', +# None, 'hinting', 'string') +# self.write_conf(sections, 'font_antialiasing', +# 'org.gnome.settings-daemon.plugins.xsettings', +# None, 'antialiasing', 'string') + +# # 主题设置------------------------------------- +# #self.write_conf(sections, 'gtk_theme', +# # 'org.gnome.desktop.interface', +# # None, 'gtk-theme', 'string') +## self.write_conf(sections, 'window_theme', +## 'org.gnome.desktop.wm.preferences', +## None, 'theme', 'string') +# self.write_conf(sections, 'icon_theme', +# 'org.gnome.desktop.interface', +# None, 'icon-theme', 'string') + +# # 窗口设置-------------------------------------- +# self.write_conf(sections, 'window_button', +# 'org.gnome.desktop.wm.preferences', +# None, 'button-layout', 'string') +# self.write_conf(sections, 'menus_have_icons', +# 'org.gnome.desktop.interface', +# None, 'menus-have-icons', 'boolean') +# self.write_conf(sections, 'titlebar_wheel', +# 'org.compiz.gwd', +# None, 'mouse-wheel-action', 'string') +# self.write_conf(sections, 'titlebar_double', +# 'org.gnome.desktop.wm.preferences', +# None, 'action-double-click-titlebar', 'string') +# self.write_conf(sections, 'titlebar_middle', +# 'org.gnome.desktop.wm.preferences', +# None, 'action-middle-click-titlebar', 'string') +# self.write_conf(sections, 'titlebar_right', +# 'org.gnome.desktop.wm.preferences', +# None, 'action-right-click-titlebar', 'string') + +# # 文件管理器----------------------------------- +# self.write_conf(sections, 'location_replace_pathbar', +# 'org.gnome.nautilus.preferences', +# None, 'always-use-location-entry', 'boolean') +# self.write_conf(sections, 'auto_mount_media', +# 'org.gnome.desktop.media-handling', +# None, 'automount', 'boolean') +# self.write_conf(sections, 'auto_open_folder', +# 'org.gnome.desktop.media-handling', +# None, 'automount-open', 'boolean') +# self.write_conf(sections, 'prompt_autorun_programs', +# 'org.gnome.desktop.media-handling', +# None, 'autorun-never', 'boolean') +# self.write_conf(sections, 'thumbnail_icon_size', +# 'org.gnome.nautilus.icon-view', +# None, 'thumbnail-size', 'int') +# self.write_conf(sections, 'thumbnail_cache_time', +# 'org.gnome.desktop.thumbnail-cache', +# None, 'maximum-age', 'int') +# self.write_conf(sections, 'thumbnail_cache_size', +# 'org.gnome.desktop.thumbnail-cache', +# None, 'maximum-size', 'int') + +# fd = open(file_name, 'w') +# self.conf.write(fd) +# fd.close() + + # system settings + def setconf(self, conf_id): + conf_schema = self.conf.get(conf_id, 'schema') + conf_path = self.conf.get(conf_id, 'path') + if conf_path == 'None': + conf_path = None + conf_key = self.conf.get(conf_id, 'key') + conf_type = self.conf.get(conf_id, 'type') + if conf_type == 'boolean' : + conf_value = self.conf.getboolean(conf_id, 'value') + elif conf_type == 'int' : + conf_value = self.conf.getint(conf_id, 'value') + elif conf_type == 'double' or conf_type == 'float' : + conf_value = self.conf.getfloat(conf_id, 'value') + else : + conf_value = self.conf.get(conf_id, 'value') + #gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + + if conf_id == 'window_button': + value = gsettings.get('org.gnome.desktop.wm.preferences', + None, 'button-layout', 'string') + left_list = ['close,minimize,maximize:', 'close,maximize,minimize:'] + right_list = [':minimize,maximize,close', ':maximize,minimize,close'] + if value in left_list and conf_value in right_list: + gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + self.sysdaemon.download_cloud_conf_signal('window_button') + elif value in right_list and conf_value in left_list: + gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + self.sysdaemon.download_cloud_conf_signal('window_button') + else: + value = gsettings.get(conf_schema, conf_path, conf_key, conf_type) + if value != conf_value: + gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + self.sysdaemon.download_cloud_conf_signal(conf_id) + + #----------------desktop icon settings---------------- + #if conf_id == 'show_desktop_icons': + # value = gsettings.get('org.gnome.desktop.background', + # None, 'show-desktop-icons', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('show_desktop_icons') + #elif conf_id == 'show_homefolder': + # value = gsettings.get('org.gnome.nautilus.desktop', + # None, 'home-icon-visible', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('show_homefolder') + #elif conf_id == 'show_network': + # value = gsettings.get('org.gnome.nautilus.desktop', + # None, 'network-icon-visible', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('show_network') + #elif conf_id == 'show_trash': + # value = gsettings.get('org.gnome.nautilus.desktop', + # None, 'trash-icon-visible', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('show_trash') + #elif conf_id == 'show_devices': + # value = gsettings.get('org.gnome.nautilus.desktop', + # None, 'volumes-visible', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('show_devices') + + #----------------launcher settings---------------- + #elif conf_id == 'launcher_autohide': + # value = gsettings.get('org.compiz.unityshell', + # '/org/compiz/profiles/unity/plugins/unityshell/', + # 'launcher-hide-mode', 'int') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('launcher_autohide') + #elif conf_id == 'launcher_icon_size': + # value = gsettings.get('org.compiz.unityshell', + # '/org/compiz/profiles/unity/plugins/unityshell/', + # 'icon-size', 'int') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('launcher_icon_size') + + #----------------touchpad settings---------------- + #elif conf_id == 'touchpad_enable': + # value = gsettings.get('org.gnome.settings-daemon.peripherals.touchpad', + # None, 'touchpad-enabled', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('touchpad_enable') + #elif conf_id == 'touch_horizontal_scrolling': + # value = gsettings.get('org.gnome.settings-daemon.peripherals.touchpad', + # None, 'horiz-scroll-enabled', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('touch_horizontal_scrolling') + #elif conf_id == 'type_scroll_bar': + # value = gsettings.get('com.canonical.desktop.interface', + # None, 'scrollbar-mode', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('type_scroll_bar') + #elif conf_id == 'touchpad_scrolling_mode': + # value = gsettings.get('org.gnome.settings-daemon.peripherals.touchpad', + # None, 'scroll-method', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('touchpad_scrolling_mode') + + #----------------font settings---------------- + #elif conf_id == 'default_font': + # value = gsettings.get('org.gnome.desktop.interface', + # None, 'font-name', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('default_font') + #elif conf_id == 'desktop_font': + # value = gsettings.get('org.gnome.nautilus.desktop', + # None, 'font', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('desktop_font') + #elif conf_id == 'document_font': + # value = gsettings.get('org.gnome.desktop.interface', + # None, 'document-font-name', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('document_font') + #elif conf_id == 'monospace_font': + # value = gsettings.get('org.gnome.desktop.interface', + # None, 'monospace-font-name', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('monospace_font') + #elif conf_id == 'window_title_font': + # value = gsettings.get('org.gnome.desktop.wm.preferences', + # None, 'titlebar-font', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('window_title_font') + #elif conf_id == 'font_zoom': + # value = gsettings.get('org.gnome.desktop.interface', + # None, 'text-scaling-factor', 'double') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('font_zoom') + #elif conf_id == 'font_hinting': + # value = gsettings.get('org.gnome.settings-daemon.plugins.xsettings', + # None, 'hinting', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('font_hinting') + #elif conf_id == 'font_antialiasing': + # value = gsettings.get('org.gnome.settings-daemon.plugins.xsettings', + # None, 'antialiasing', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('font_antialiasing') + + + #----------------theme settings---------------- + #elif conf_id == 'gtk_theme': + # value = gsettings.get('org.gnome.desktop.interface', + # None, 'gtk-theme', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('gtk_theme') + #elif conf_id == 'window_theme': + # value = gsettings.get('org.gnome.desktop.wm.preferences', + # None, 'theme', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('window_theme') + #elif conf_id == 'icon_theme': + # value = gsettings.get('org.gnome.desktop.interface', + # None, 'icon-theme', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('icon_theme') + + #----------------window settings---------------- + #elif conf_id == 'window_button': + # value = gsettings.get('org.gnome.desktop.wm.preferences', + # None, 'button-layout', 'string') + # left_list = ['close,minimize,maximize:', 'close,maximize,minimize:'] + # right_list = [':minimize,maximize,close', ':maximize,minimize,close'] + # if value in left_list and conf_value in right_list: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('window_button') + # elif value in right_list and conf_value in left_list: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('window_button') + #elif conf_id == 'menus_have_icons': + # value = gsettings.get('org.gnome.desktop.interface', + # None, 'menus-have-icons', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('menus_have_icons') + #elif conf_id == 'titlebar_wheel': + # value = gsettings.get('org.compiz.gwd', + # None, 'mouse-wheel-action', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('titlebar_wheel') + #elif conf_id == 'titlebar_double': + # value = gsettings.get('org.gnome.desktop.wm.preferences', + # None, 'action-double-click-titlebar', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('titlebar_double') + #elif conf_id == 'titlebar_middle': + # value = gsettings.get('org.gnome.desktop.wm.preferences', + # None, 'action-middle-click-titlebar', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('titlebar_middle') + #elif conf_id == 'titlebar_right': + # value = gsettings.get('org.gnome.desktop.wm.preferences', + # None, 'action-right-click-titlebar', 'string') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('titlebar_right') + + #----------------file manager---------------- + #elif conf_id == 'location_replace_pathbar': + # value = gsettings.get('org.gnome.nautilus.preferences', + # None, 'always-use-location-entry', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('location_replace_pathbar') + #elif conf_id == 'auto_mount_media': + # value = gsettings.get('org.gnome.desktop.media-handling', + # None, 'automount', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('auto_mount_media') + #elif conf_id == 'auto_open_folder': + # value = gsettings.get('org.gnome.desktop.media-handling', + # None, 'automount-open', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('auto_open_folder') + #elif conf_id == 'prompt_autorun_programs': + # value = gsettings.get('org.gnome.desktop.media-handling', + # None, 'autorun-never', 'boolean') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('prompt_autorun_programs') + #elif conf_id == 'thumbnail_icon_size': + # value = gsettings.get('org.gnome.nautilus.icon-view', + # None, 'thumbnail-size', 'int') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('thumbnail_icon_size') + #elif conf_id == 'thumbnail_cache_time': + # value = gsettings.get('org.gnome.desktop.thumbnail-cache', + # None, 'maximum-age', 'int') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('thumbnail_cache_time') + #elif conf_id == 'thumbnail_cache_size': + # value = gsettings.get('org.gnome.desktop.thumbnail-cache', + # None, 'maximum-size', 'int') + # if value != conf_value: + # gsettings.set(conf_schema, conf_path, conf_key, conf_type, conf_value) + # self.sysdaemon.download_cloud_conf_signal('thumbnail_cache_size') + + # desktop icon settings + #if conf_id == 'show_desktop_icons': + # self.sysdaemon.download_cloud_conf_signal('show_desktop_icons') + #elif conf_id == 'show_homefolder': + # self.sysdaemon.download_cloud_conf_signal('show_homefolder') + #elif conf_id == 'show_network': + # self.sysdaemon.download_cloud_conf_signal('show_network') + #elif conf_id == 'show_trash': + # self.sysdaemon.download_cloud_conf_signal('show_trash') + #elif conf_id == 'show_devices': + # self.sysdaemon.download_cloud_conf_signal('show_devices') + + # launcher settings + #elif conf_id == 'launcher_autohide': + # self.sysdaemon.download_cloud_conf_signal('launcher_autohide') + #elif conf_id == 'launcher_icon_size': + # self.sysdaemon.download_cloud_conf_signal('launcher_icon_size') + + # touchpad settings + #elif conf_id == 'touchpad_enable': + # self.sysdaemon.download_cloud_conf_signal('touchpad_enable') + #elif conf_id == 'touch_horizontal_scrolling': + # self.sysdaemon.download_cloud_conf_signal('touch_horizontal_scrolling') + #elif conf_id == 'type_scroll_bar': + # self.sysdaemon.download_cloud_conf_signal('type_scroll_bar') + #elif conf_id == 'touchpad_scrolling_mode': + # self.sysdaemon.download_cloud_conf_signal('touchpad_scrolling_mode') + + # font settings + #elif conf_id == 'default_font': + # self.sysdaemon.download_cloud_conf_signal('default_font') + #elif conf_id == 'desktop_font': + # self.sysdaemon.download_cloud_conf_signal('desktop_font') + #elif conf_id == 'document_font': + # self.sysdaemon.download_cloud_conf_signal('document_font') + #elif conf_id == 'monospace_font': + # self.sysdaemon.download_cloud_conf_signal('monospace_font') + #elif conf_id == 'window_title_font': + # self.sysdaemon.download_cloud_conf_signal('window_title_font') + #elif conf_id == 'font_zoom': + # self.sysdaemon.download_cloud_conf_signal('font_zoom') + #elif conf_id == 'font_hinting': + # self.sysdaemon.download_cloud_conf_signal('font_hinting') + #elif conf_id == 'font_antialiasing': + # self.sysdaemon.download_cloud_conf_signal('font_antialiasing') + + # theme settings + #elif conf_id == 'gtk_theme': + # self.sysdaemon.download_cloud_conf_signal('gtk_theme') + #elif conf_id == 'window_theme': + # self.sysdaemon.download_cloud_conf_signal('window_theme') + #elif conf_id == 'icon_theme': + # self.sysdaemon.download_cloud_conf_signal('icon_theme') + + # window settings + #elif conf_id == 'window_button': + # self.sysdaemon.download_cloud_conf_signal('window_button') + #elif conf_id == 'menus_have_icons': + # self.sysdaemon.download_cloud_conf_signal('menus_have_icons') + #elif conf_id == 'titlebar_wheel': + # self.sysdaemon.download_cloud_conf_signal('titlebar_wheel') + #elif conf_id == 'titlebar_double': + # self.sysdaemon.download_cloud_conf_signal('titlebar_double') + #elif conf_id == 'titlebar_middle': + # self.sysdaemon.download_cloud_conf_signal('titlebar_middle') + #elif conf_id == 'titlebar_right': + # self.sysdaemon.download_cloud_conf_signal('titlebar_right') + + # file manager + #elif conf_id == 'location_replace_pathbar': + # self.sysdaemon.download_cloud_conf_signal('location_replace_pathbar') + #elif conf_id == 'auto_mount_media': + # self.sysdaemon.download_cloud_conf_signal('auto_mount_media') + #elif conf_id == 'auto_open_folder': + # self.sysdaemon.download_cloud_conf_signal('auto_open_folder') + #elif conf_id == 'prompt_autorun_programs': + # self.sysdaemon.download_cloud_conf_signal('prompt_autorun_programs') + #elif conf_id == 'thumbnail_icon_size': + # self.sysdaemon.download_cloud_conf_signal('thumbnail_icon_size') + #elif conf_id == 'thumbnail_cache_time': + # self.sysdaemon.download_cloud_conf_signal('thumbnail_cache_time') + #elif conf_id == 'thumbnail_cache_size': + # self.sysdaemon.download_cloud_conf_signal('thumbnail_cache_size') + + + # Restore the system configuration + def use_cloud_configuration(self, file_name): + print file_name + self.conf.read(file_name) + sections = self.conf.sections() + for conf_id in sections: + self.setconf(conf_id) + return True + + # Get kuaipan directory address + def get_kuaipan_path(self): + kpconf = ConfigParser.ConfigParser() + kpconf.read(self.home + '/.config/ubuntukylin/kuaipan4uk.conf') + return kpconf.get('client-info', 'Root') + + # Determine whether kuaipan process starts + def kuaipan_run(self): + ps = os.popen('pgrep kuaipan4uk') + kuaipan_ps = ps.read() + ps.close() + return kuaipan_ps + + # Configuration file upload + def real_upload_kysoft_cloud_conf(self): + if not self.kuaipan_run(): + # 快盘没有启动或没有安装,提示用户安装并启动快盘才能上传 + self.sysdaemon.upload_cloud_conf_signal('upload_norun') + return + self.kuaipan_path = self.get_kuaipan_path() + '/[Ubuntu Kylin Sync]' + if not os.path.isdir(self.kuaipan_path): + os.makedirs(self.kuaipan_path) + self.kuaipan_path = self.kuaipan_path + '/youker-assistant' + if not os.path.isdir(self.kuaipan_path): + os.makedirs(self.kuaipan_path) + self.youker_path = self.home + '/.config/ubuntukylin/youker-assistant/' + youker_abs_path = self.youker_path + 'youker-settings-cloud.conf' + self.save_configuration_to_local_file(youker_abs_path) + copy(youker_abs_path, self.kuaipan_path) + self.sysdaemon.upload_cloud_conf_signal('upload_ok') + + # Configuration file download + def real_download_kysoft_cloud_conf(self): + if not self.kuaipan_run(): + # 快盘没有启动或没有安装,提示用户安装并启动快盘才能下载 + self.sysdaemon.download_cloud_conf_signal('download_norun') + return + self.youker_path = self.home + '/.config/ubuntukylin/youker-assistant/' + youker_abs_path = self.youker_path + 'youker-settings-cloud.conf' + if not os.path.exists(youker_abs_path): + os.mknod(youker_abs_path) + cloud_abs_path = self.get_kuaipan_path() + '/[Ubuntu Kylin Sync]/youker-assistant/youker-settings-cloud.conf' + if not os.path.isfile(cloud_abs_path): + # 云端没有备份的配置文件 + self.sysdaemon.download_cloud_conf_signal('download_notconf') + return + copy(cloud_abs_path, self.youker_path) + self.use_cloud_configuration(youker_abs_path) + self.sysdaemon.download_cloud_conf_signal('download_ok') + + def upload_kysoft_cloud_conf(self): + threading.Thread(target=self.real_upload_kysoft_cloud_conf, name='UpLoad').start() + + def download_kysoft_cloud_conf(self): + threading.Thread(target=self.real_download_kysoft_cloud_conf, name='DownLoad').start() + +if __name__ == '__main__': + pass + #cc = CloudConfig(None) + #cc.upload_kysoft_cloud_conf() + #cc.download_kysoft_cloud_conf() + diff --git a/backends/youker-assistant-daemon/src/beautify/common.py b/backends/youker-assistant-daemon/src/beautify/common.py new file mode 100644 index 0000000..f073810 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/common.py @@ -0,0 +1,185 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (C) 2007-2011 Tualatrix Chou +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +import glob +import logging +import ConfigParser + +from lxml import etree + +log = logging.getLogger('CommonSetting') + +class RawConfigSetting(object): + '''Just pass the file path''' + def __init__(self, path, type=type): + self._type = type + + self._path = path + + self.init_configparser() + + def _type_convert_set(self, value): + if type(value) == bool: + if value == True: + value = 'true' + elif value == False: + value = 'false' + + # This is a hard code str type, so return '"xxx"' instead of 'xxx' + if self._type == str: + value = "'%s'" % value + + return value + + def _type_convert_get(self, value): + if value == 'false': + value = False + elif value == 'true': + value = True + + # This is a hard code str type, so return '"xxx"' instead of 'xxx' + if self._type == str or type(value) == str: + if (value.startswith('"') and value.endswith('"')) or \ + (value.startswith("'") and value.endswith("'")): + value = eval(value) + + return value + + def init_configparser(self): + self._configparser = ConfigParser.ConfigParser() + self._configparser.read(self._path) + + def sections(self): + return self._configparser.sections() + + def options(self, section): + return self._configparser.options(section) + + def set_value(self, section, option, value): + value = self._type_convert_set(value) + + if not self._configparser.has_section(section): + self._configparser.add_section(section) + + self._configparser.set(section, option, value) + with open(self._path, 'wb') as configfile: + self._configparser.write(configfile) + + self.init_configparser() + + def get_value(self, section, option): + if self._type: + if self._type == int: + getfunc = getattr(self._configparser, 'getint') + elif self._type == float: + getfunc = getattr(self._configparser, 'getfloat') + elif self._type == bool: + getfunc = getattr(self._configparser, 'getboolean') + else: + getfunc = getattr(self._configparser, 'get') + + value = getfunc(section, option) + else: + log.debug("No type message, so use the generic get") + value = self._configparser.get(section, option) + + value = self._type_convert_get(value) + + return value + +class Schema(object): + cached_schema = {} + cached_schema_tree = {} + cached_override = {} + + @classmethod + def load_override(cls): + log.debug("\tLoading override") + for override in glob.glob('/usr/share/glib-2.0/schemas/*.gschema.override'): + try: + cs = RawConfigSetting(override) + for section in cs.sections(): + cls.cached_override[section] = {} + for option in cs.options(section): + cls.cached_override[section][option] = cs.get_value(section, option) + except Exception, e: + log.error('Error while parsing override file: %s' % override) + + @classmethod + def load_schema(cls, schema_id, key): + log.debug("Loading schema value for: %s/%s" % (schema_id, key)) + if not cls.cached_override: + cls.load_override() + + if schema_id in cls.cached_override and \ + key in cls.cached_override[schema_id]: + return cls.cached_override[schema_id][key] + + if schema_id in cls.cached_schema and \ + key in cls.cached_schema[schema_id]: + return cls.cached_schema[schema_id][key] + + schema_defaults = {} + + for schema_path in glob.glob('/usr/share/glib-2.0/schemas/*'): + if not schema_path.endswith('.gschema.xml') and not schema_path.endswith('.enums.xml'): + #TODO deal with enums + continue + + if schema_path in cls.cached_schema_tree: + tree = cls.cached_schema_tree[schema_path] + else: + tree = etree.parse(open(schema_path)) + + for schema_node in tree.findall('schema'): + if schema_node.attrib.get('id') == schema_id: + for key_node in schema_node.findall('key'): + if key_node.findall('default'): + schema_defaults[key_node.attrib['name']] = cls.parse_value(key_node) + else: + continue + + cls.cached_schema[schema_id] = schema_defaults + if key in schema_defaults: + return schema_defaults[key] + else: + return None + + @classmethod + def parse_value(cls, key_node): + log.debug("Try to get type for value: %s" % key_node.items()) + value = key_node.find('default').text + + #TODO enum type + if key_node.attrib.get('type'): + type = key_node.attrib['type'] + + if type == 'b': + if value == 'true': + return True + else: + return False + elif type == 'i': + return int(value) + elif type == 'd': + return float(value) + elif type == 'as': + return eval(value) + + return eval(value) diff --git a/backends/youker-assistant-daemon/src/beautify/compizsettings.py b/backends/youker-assistant-daemon/src/beautify/compizsettings.py new file mode 100644 index 0000000..ba89dd5 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/compizsettings.py @@ -0,0 +1,110 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright (C) 2007-2011 Tualatrix Chou +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +import logging + +import ccm +import compizconfig + +log = logging.getLogger('CompizSetting') + +class CompizPlugin: + context = compizconfig.Context() + + def __init__(self, name): + self._plugin = self.context.Plugins[name] + + @classmethod + def set_plugin_active(cls, name, active): + try: + plugin = cls.context.Plugins[name] + plugin.Enabled = int(active) + cls.context.Write() + except: + pass + + @classmethod + def get_plugin_active(cls, name): + try: + plugin = cls.context.Plugins[name] + return bool(plugin.Enabled) + except: + return False + + def set_enabled(self, bool): + self._plugin.Enabled = int(bool) + self.save() + + def get_enabled(self): + return self._plugin.Enabled + + def save(self): + self.context.Write() + + def resolve_conflict(self): + conflicts = self.get_enabled() and self._plugin.DisableConflicts or \ + self._plugin.EnableConflicts + conflict = ccm.PluginConflict(self._plugin, conflicts) + return conflict.Resolve() + + @classmethod + def is_available(cls, name, setting): + return cls.context.Plugins.has_key(name) and \ + cls.context.Plugins[name].Screen.has_key(setting) + + def create_setting(self, key, target): + settings = self._plugin.Screen + + if type(settings) == list: + return settings[0][key] + else: + return settings[key] + + +class CompizSetting(object): + def __init__(self, key, target=''): + plugin_name, setting_name = key.split('.') + self.key = key + self._plugin = CompizPlugin(plugin_name) + + if not self._plugin.get_enabled(): + self._plugin.set_enabled(True) + + self._setting = self._plugin.create_setting(setting_name, target) + + def set_value(self, value): + self._setting.Value = value + self._plugin.save() + + def get_value(self): + return self._setting.Value + + def is_default_and_enabled(self): + return self._setting.Value == self._setting.DefaultValue and \ + self._plugin.get_enabled() + + def reset(self): + self._setting.Reset() + self._plugin.save() + + def resolve_conflict(self): + return self._plugin.resolve_conflict() + + def get_schema_value(self): + return self._setting.DefaultValue diff --git a/backends/youker-assistant-daemon/src/beautify/desktop.py b/backends/youker-assistant-daemon/src/beautify/desktop.py new file mode 100644 index 0000000..d17579c --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/desktop.py @@ -0,0 +1,251 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import gsettings + +class Desktop: + desktop = None + + def __init__(self): + self.desktop = os.getenv('XDG_CURRENT_DESKTOP') + if self.desktop is None: + self.desktop = os.getenv('XDG_SESSION_DESKTOP') + + # ---------------desktopicon--------------- + # -----------------默认值----------------- + # Get Default Value + def get_default_schema_value(self, schema, key): + return gsettings.get_schema_value(schema, key) + + # Set Default Value + def set_default_schema_value(self, schema, key, type): + default_value = self.get_default_schema_value(schema, key) + if default_value is not None: + return gsettings.set(schema, None, key, type, default_value) + else: + raise NotImplemented + # ---------------------------------- + + + # show desktop icons, True/False + def set_show_desktop_icons(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.background', + None, + 'show-desktop-icons', + 'boolean', flag) + else: + return gsettings.set('org.gnome.desktop.background', + None, + 'show-desktop-icons', + 'boolean', flag) + + # get is show desktop icons + def get_show_desktop_icons(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.background', + None, 'show-desktop-icons', 'boolean') + else: + return gsettings.get('org.gnome.desktop.background', + None, 'show-desktop-icons', 'boolean') + + def set_show_computer(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.caja.desktop', + None, + 'computer-icon-visible', + 'boolean', flag) + + def get_show_computer(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.caja.desktop', + None, 'computer-icon-visible', 'boolean') + + # show home folder + def set_show_homefolder(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.caja.desktop', + None, + 'home-icon-visible', + 'boolean', flag) + else: + return gsettings.set('org.gnome.nautilus.desktop', + None, + 'home-icon-visible', + 'boolean', flag) + + # get show homefolder + def get_show_homefolder(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.caja.desktop', + None, 'home-icon-visible', 'boolean') + else: + return gsettings.get('org.gnome.nautilus.desktop', + None, 'home-icon-visible', 'boolean') + + # show network + def set_show_network(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.caja.desktop', + None, + 'network-icon-visible', + 'boolean', flag) + else: + return gsettings.set('org.gnome.nautilus.desktop', + None, + 'network-icon-visible', + 'boolean', flag) + + # get show network + def get_show_network(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.caja.desktop', + None, 'network-icon-visible', 'boolean') + else: + return gsettings.get('org.gnome.nautilus.desktop', + None, 'network-icon-visible', 'boolean') + + # show trash + def set_show_trash(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.caja.desktop', + None, + 'trash-icon-visible', + 'boolean', flag) + else: + return gsettings.set('org.gnome.nautilus.desktop', + None, + 'trash-icon-visible', + 'boolean', flag) + + # get show trash + def get_show_trash(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.caja.desktop', + None, 'trash-icon-visible', 'boolean') + else: + return gsettings.get('org.gnome.nautilus.desktop', + None, 'trash-icon-visible', 'boolean') + + # show devices + def set_show_devices(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.caja.desktop', + None, + 'volumes-visible', + 'boolean', flag) + else: + return gsettings.set('org.gnome.nautilus.desktop', + None, + 'volumes-visible', + 'boolean', flag) + + # get show devices + def get_show_devices(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.caja.desktop', + None, 'volumes-visible', 'boolean') + else: + return gsettings.get('org.gnome.nautilus.desktop', + None, 'volumes-visible', 'boolean') + + + #-------------------------cinnamon-------------------------------- + # show desktop icons, True/False + def set_show_cinnamon_desktop_icons(self, flag): + return gsettings.set('org.nemo.desktop', + None, + 'show-desktop-icons', + 'boolean', flag) + + # get is show desktop icons + def get_show_cinnamon_desktop_icons(self): + return gsettings.get('org.nemo.desktop', + None, 'show-desktop-icons', 'boolean') + + def set_show_cinnamon_computer(self, flag): + return gsettings.set('org.nemo.desktop', + None, + 'computer-icon-visible', + 'boolean', flag) + + def get_show_cinnamon_computer(self): + return gsettings.get('org.nemo.desktop', + None, 'computer-icon-visible', 'boolean') + + # show home folder + def set_show_cinnamon_homefolder(self, flag): + return gsettings.set('org.nemo.desktop', + None, + 'home-icon-visible', + 'boolean', flag) + + # get show homefolder + def get_show_cinnamon_homefolder(self): + return gsettings.get('org.nemo.desktop', + None, 'home-icon-visible', 'boolean') + + # show network + def set_show_cinnamon_network(self, flag): + return gsettings.set('org.nemo.desktop', + None, + 'network-icon-visible', + 'boolean', flag) + + # get show network + def get_show_cinnamon_network(self): + return gsettings.get('org.nemo.desktop', + None, 'network-icon-visible', 'boolean') + + # show trash + def set_show_cinnamon_trash(self, flag): + return gsettings.set('org.nemo.desktop', + None, + 'trash-icon-visible', + 'boolean', flag) + + # get show trash + def get_show_cinnamon_trash(self): + return gsettings.get('org.nemo.desktop', + None, 'trash-icon-visible', 'boolean') + + # show devices + def set_show_cinnamon_devices(self, flag): + return gsettings.set('org.nemo.desktop', + None, + 'volumes-visible', + 'boolean', flag) + + # get show devices + def get_show_cinnamon_devices(self): + return gsettings.get('org.nemo.desktop', + None, 'volumes-visible', 'boolean') + +# if __name__ == '__main__': +# ddd = Desktop() + # print ddd.get_show_desktop_icons() + # print ddd.get_show_homefolder() + # print ddd.get_show_network() + # print ddd.get_show_trash() + # print ddd.get_show_devices() + # ddd.set_show_desktop_icons(True) + # ddd.set_show_homefolder(True) + # ddd.set_show_network(True) + # ddd.set_show_trash(True) + # ddd.set_show_devices(True) diff --git a/backends/youker-assistant-daemon/src/beautify/filemanager.py b/backends/youker-assistant-daemon/src/beautify/filemanager.py new file mode 100644 index 0000000..cf31600 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/filemanager.py @@ -0,0 +1,267 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# +# Author: Kobe Lee +# Maintainer: Ubuntu Kylin +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import gsettings + +class FileManager: + + desktop = None + + def __init__(self): + self.desktop = os.getenv('XDG_CURRENT_DESKTOP') + if self.desktop is None: + self.desktop = os.getenv('XDG_SESSION_DESKTOP') + + # -----------------默认值----------------- + # Get Default Value + def get_default_schema_value(self, schema, key): + return gsettings.get_schema_value(schema, key) + + # Set Default Value + def set_default_schema_value(self, schema, key, type): + default_value = self.get_default_schema_value(schema, key) + if default_value is not None: + return gsettings.set(schema, None, key, type, default_value) + else: + raise NotImplemented + + # -----------------使用路径输入框取代路径栏----------------- + # Get: Use the location entry instead of the pathbar + def get_location_replace_pathbar(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.caja.preferences', + None, 'always-use-location-entry', 'boolean') + else: + return gsettings.get('org.gnome.nautilus.preferences', + None, 'always-use-location-entry', 'boolean') + + # Set: Use the location entry instead of the pathbar + def set_location_replace_pathbar(self, flag): + #gstheme = gsettings.get_schema('org.gnome.desktop.sound') + #gstheme.set_string('theme-name',theme) + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.caja.preferences', + None, + 'always-use-location-entry', + 'boolean', flag) + else: + return gsettings.set('org.gnome.nautilus.preferences', + None, + 'always-use-location-entry', + 'boolean', flag) + + # -----------------自动挂载媒体----------------- + # Get: Automatically mount media + def get_auto_mount_media(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.media-handling', + None, 'automount', 'boolean') + else: + return gsettings.get('org.gnome.desktop.media-handling', + None, 'automount', 'boolean') + + # Set: Automatically mount media + def set_auto_mount_media(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.media-handling', + None, + 'automount', + 'boolean', flag) + else: + return gsettings.set('org.gnome.desktop.media-handling', + None, + 'automount', + 'boolean', flag) + + # -----------------自动打开文件夹----------------- + # Get: Automatically open a folder + def get_auto_open_folder(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.media-handling', + None, 'automount-open', 'boolean') + else: + return gsettings.get('org.gnome.desktop.media-handling', + None, 'automount-open', 'boolean') + + # Set: Automatically open a folder + def set_auto_open_folder(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.media-handling', + None, + 'automount-open', + 'boolean', flag) + else: + return gsettings.set('org.gnome.desktop.media-handling', + None, + 'automount-open', + 'boolean', flag) + + # -----------------提示自动运行的程序----------------- + # Get: Prompt or autorun/autostart programs + def get_prompt_autorun_programs(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.media-handling', + None, 'autorun-never', 'boolean') + else: + return gsettings.get('org.gnome.desktop.media-handling', + None, 'autorun-never', 'boolean') + + # Set: Prompt or autorun/autostart programs + def set_prompt_autorun_programs(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.media-handling', + None, + 'autorun-never', + 'boolean', flag) + else: + return gsettings.set('org.gnome.desktop.media-handling', + None, + 'autorun-never', + 'boolean', flag) + + # -----------------缩略图图标尺寸(像素) min=16, max=512, step=16, default=64----------------- + # Get: Thumbnail icon size (pixels) + def get_thumbnail_icon_size(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.caja.icon-view', + None, 'thumbnail-size', 'int') + else: + return gsettings.get('org.gnome.nautilus.icon-view', + None, 'thumbnail-size', 'int') + + # Set: Thumbnail icon size (pixels) + def set_thumbnail_icon_size(self, size): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.caja.icon-view', + None, + 'thumbnail-size', + 'int', size) + else: + return gsettings.set('org.gnome.nautilus.icon-view', + None, + 'thumbnail-size', + 'int', size) + + # -----------------缩略图缓存时间(天数) min=-1, max=180, step=1, default=180----------------- + # Get: Thumbnail cache time (days) + def get_thumbnail_cache_time(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.thumbnail-cache', + None, 'maximum-age', 'int') + else: + return gsettings.get('org.gnome.desktop.thumbnail-cache', + None, 'maximum-age', 'int') + + # Set: Thumbnail cache time (days) + def set_thumbnail_cache_time(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.thumbnail-cache', + None, + 'maximum-age', + 'int', value) + else: + return gsettings.set('org.gnome.desktop.thumbnail-cache', + None, + 'maximum-age', + 'int', value) + + # -----------------最大缩略图缓存尺寸(MB) min=-1, max=512, step=1, default=512----------------- + # Get: Maximum thumbnail cache size (MB) + def get_thumbnail_cache_size(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.thumbnail-cache', + None, 'maximum-size', 'int') + else: + return gsettings.get('org.gnome.desktop.thumbnail-cache', + None, 'maximum-size', 'int') + + # Set: Maximum thumbnail cache size (MB) + def set_thumbnail_cache_size(self, size): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.thumbnail-cache', + None, + 'maximum-size', + 'int', size) + else: + return gsettings.set('org.gnome.desktop.thumbnail-cache', + None, + 'maximum-size', + 'int', size) + +if __name__ == '__main__': + pass +# fm = FileManager() + #value = fm.get_location_replace_pathbar() + #if(value): + # print "yes" + # fm.set_location_replace_pathbar(False) + #else: + # print "False" + # fm.set_location_replace_pathbar(True) + + #value = fm.get_auto_mount_media() + #if(value): + # fm.set_auto_mount_media(False) + #else: + # fm.set_auto_mount_media(True) + + #value = fm.get_auto_open_folder() + #if(value): + # fm.set_auto_open_folder(False) + #else: + # fm.set_auto_open_folder(True) + + #value = fm.get_prompt_autorun_programs() + #if(value): + # fm.set_prompt_autorun_programs(False) + #else: + # fm.set_prompt_autorun_programs(True) + + #value = fm.get_thumbnail_icon_size() + #if(value == 64): + # fm.set_thumbnail_icon_size(48) + #else: + # fm.set_thumbnail_icon_size(64) + + #value = fm.get_thumbnail_cache_time() + #if(value == 180): + # fm.set_thumbnail_cache_time(120) + #else: + # fm.set_thumbnail_cache_time(180) + + #value = fm.get_thumbnail_cache_size() + #aa = fm.test() + #print aa + #if(value == 512): + # fm.set_thumbnail_cache_size(500) + #else: + # fm.set_thumbnail_cache_size(512) + +# aa = fm.get_default_schema_value('org.gnome.desktop.media-handling', 'automount') +# print aa +# #aa = fm.get_default_schema_value('org.gnome.desktop.media-handling', 'automount') +# #print aa +# #fm.set_default_schema_value('org.gnome.desktop.media-handling', 'automount', 'boolean') + +# bb = fm.get_default_schema_value('org.gnome.nautilus.desktop', 'font') +# print bb diff --git a/backends/youker-assistant-daemon/src/beautify/geditmanager.py b/backends/youker-assistant-daemon/src/beautify/geditmanager.py new file mode 100644 index 0000000..a4b0cc1 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/geditmanager.py @@ -0,0 +1,92 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# +# Author: Kobe Lee +# Maintainer: Ubuntu Kylin +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +from settings import Settings +import types + +class GeditManager: + def __init__(self): + self.default = None + self.settings = Settings("org.gnome.gedit.preferences.encodings") + + # -----------------默认值----------------- + # Get Default Value + def get_default_schema_value(self, schema, key): + return self.settings.get_schema_value(schema, key) + + # Set Default Value + def set_default_schema_value(self, schema, key, type): + default_value = self.get_default_schema_value(schema, key) + if default_value is not None: + return self.settings.set_value(key, type, default_value) + else: + raise NotImplemented + + # 在Gedit中自动检测简体中文编码 + # on=['GB18030', 'UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16'] + # off=['UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16'] + # default = off + # Get: Auto detect text encoding for Simplified Chinese in Gedit + def get_detect_chinese_encoding(self): + return self.settings.get_value("auto-detected", types.ListType) + + # Set: Auto detect text encoding for Simplified Chinese in Gedit + def set_detect_chinese_encoding(self, flag): + list_on = ['GB18030', 'UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16'] + list_off = ['UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16'] + if(flag): + self.settings.set_value("auto-detected", types.ListType, list_off) + else: + self.settings.set_value("auto-detected", types.ListType, list_on) + + + # Get Default Value: Auto detect text encoding for Simplified Chinese in Gedit + #def get_default_detect_chinese_encoding(self): + # self.default = self.settings.get_schema_value("auto-detected") + + # Set Default Value: Auto detect text encoding for Simplified Chinese in Gedit + #def set_default_detect_chinese_encoding(self): + # if self.default is not None: + # self.settings.set_value("auto-detected", types.ListType, self.default) + + +if __name__ == '__main__': + gm = GeditManager() + #aa = gm.get_detect_chinese_encoding() + #print aa + #list_on = ['GB18030', 'UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16'] + #list_off = ['UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16'] + #if aa == list_off: + # gm.set_detect_chinese_encoding(False) + #else: + # gm.set_detect_chinese_encoding(True) + + + #gm.get_default_detect_chinese_encoding() + #print "default->" + #print gm.default + #gm.set_default_detect_chinese_encoding() + + #aa = gm.get_default_schema_value("org.gnome.gedit.preferences.encodings", "auto-detected") + #print aa + gm.set_default_schema_value("org.gnome.gedit.preferences.encodings", "auto-detected", types.ListType) diff --git a/backends/youker-assistant-daemon/src/beautify/gsettings.py b/backends/youker-assistant-daemon/src/beautify/gsettings.py new file mode 100644 index 0000000..33d4d48 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/gsettings.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +from gi.repository import Gio as gio +from common import Schema +import logging + +logger=logging.getLogger('youker-assistant-daemon') + +def get(schema, path, key, type): + try: + gs = gio.Settings(schema, path) + return gs.__getattribute__('get_' + type)(key) + except: + logger.debug("gsettings.get: can't find value for %s" % gs) + return None + +def set(schema, path, key, type, value): + try: + gs = gio.Settings(schema, path) + gs.__getattribute__('set_' + type)(key, value) + return True + except: + logger.debug("gsettings.set: can't find value for %s" % gs) + return False + +def get_schema(schema): + return gio.Settings(schema) + +# added by kobe: access default schema value +def get_schema_value(schema, key): + schema_default = Schema.load_schema(schema, key) + if schema_default is not None: + return schema_default + else: + raise NotImplemented diff --git a/backends/youker-assistant-daemon/src/beautify/others.py b/backends/youker-assistant-daemon/src/beautify/others.py new file mode 100644 index 0000000..e339636 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/others.py @@ -0,0 +1,155 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import re +import shutil +import Image +# from _pyio import open + +class Others: + + # custom plymouth bg by plymouthName + def custom_plymouth_bg(self, plymouthName): + plymouthName = plymouthName.encode('utf-8') + existingDir = '/var/lib/youker-assistant-daemon/plymouth/existing/' + linkFileDir = '/lib/plymouth/themes/default.plymouth' + + # replace the config file + shutil.copy(existingDir + plymouthName + '/default.plymouth', linkFileDir) + + # add new custom plymouth + def add_new_plymouth(self, customBG, plymouthName): + # if plymouthName exist return false + existingPlymouth = self.get_existing_plymouth_list() + customBG = customBG.encode('utf-8') + plymouthName = plymouthName.encode('utf-8') + plymouthName + if(plymouthName in existingPlymouth): + return False + else: + existingDir = '/var/lib/youker-assistant-daemon/plymouth/existing/' + customScript = '/var/lib/youker-assistant-daemon/plymouth/defaults/only_background.script' + defaultplymouthfile = '/var/lib/youker-assistant-daemon/plymouth/defaults/default.plymouth' + + # add new plymouth conf dir + os.mkdir(existingDir + plymouthName) + shutil.copy(defaultplymouthfile, existingDir + plymouthName + '/default.plymouth') + # modify config file + fileHandle = open(existingDir + plymouthName + '/default.plymouth', 'a') + fileHandle.write('ImageDir=/lib/plymouth/themes/' + plymouthName + '\n') + fileHandle.write('ScriptFile=/lib/plymouth/themes/' + plymouthName + '/youker.script') + fileHandle.close() + + # add new system plymouth dir + os.mkdir('/lib/plymouth/themes/' + plymouthName) + shutil.copy(customScript, '/lib/plymouth/themes/' + plymouthName + '/youker.script') + #shutil.copy(customBG, '/lib/plymouth/themes/' + plymouthName + '/customBG.png') + Image.open(customBG).save('/lib/plymouth/themes/' + plymouthName + '/customBG.png') + + return True + + # get existing plymouth list + def get_existing_plymouth_list(self): + result = [] + edir = ('/var/lib/youker-assistant-daemon/plymouth/existing') + if os.path.isdir(edir): + for f in os.listdir(edir): + if os.path.isdir(os.path.join(edir, f)): + result.append(f) + result.sort() + return result + + # check and save current plymouth when init + def plymouth_init_check(self): + existingDir = '/var/lib/youker-assistant-daemon/plymouth/existing/' + linkFileDir = '/lib/plymouth/themes/default.plymouth' + + # add 0619 + if(os.path.exists('/lib/plymouth/themes/ubuntukylin-logo') == False): + shutil.copytree('/var/lib/youker-assistant-daemon/plymouth/ubuntukylin-logo/', '/lib/plymouth/themes/ubuntukylin-logo') + + # locate the current plymouth theme dir + linkFile = open(linkFileDir) + fullString = linkFile.read() + linkFile.close() + index = fullString.find('ScriptFile=') + theLine = fullString[index:] + # cut 'ScriptFile=' & '\n' + scriptFile = theLine[theLine.find('/'):theLine.find('\n')] +# scriptFile = theLine[theLine.find('/'):] + scriptDir = scriptFile[0:scriptFile.rfind('/')] + scriptName = scriptFile[scriptFile.rfind('/') + 1:] + plymouthName = scriptDir[scriptDir.rfind('/') + 1:] + + # check and save current pl linkFile.close()ymouth + if(os.path.exists(existingDir + plymouthName) == False): + os.mkdir(existingDir + plymouthName) + shutil.copy(scriptFile, existingDir + plymouthName + '/' + scriptName) + shutil.copy(linkFileDir, existingDir + plymouthName + '/default.plymouth') + + def get_image_path(self,name): + name = name.encode('utf-8') +# if not os.path.exists('/lib/plymouth/themes/' + name + '/customBG.png') : + if not os.path.exists('/lib/plymouth/themes/' + name + '/' + name + '.script') : + if not os.path.exists('/lib/plymouth/themes/' + name + '/youker.script') : + if not os.path.exists('/lib/plymouth/themes/' + name + '/customBG.png') : + return "False" + else: + return "True" + else: + return "True" + else : + return "True" +# path = '/lib/plymouth/themes/' + name + '/customBG.png' +# return path + + def delete_plymouth(self,plymouthName): + plymouthName = plymouthName.encode('utf-8') + fd = open('/lib/plymouth/themes/default.plymouth','r') + animation = fd.read() + fd.close() + used = animation[animation.index('themes/')+len('themes/'):] + used = used[:used.index('\n')] + if used == plymouthName : + return 'use' + elif plymouthName == 'ubuntukylin-logo': + return 'sys' + else : + shutil.rmtree('/var/lib/youker-assistant-daemon/plymouth/existing/' + plymouthName) + shutil.rmtree('/lib/plymouth/themes/' + plymouthName) + return 'ok' +# plymouthName = plymouthName.encode('utf-8') +# fd = open('/lib/plymouth/themes/default.plymouth','r') +# animation = fd.read() +# fd.close() +# used = animation[animation.index('themes/')+len('themes/'):] +# used = used[:used.index('\n')] +# if used == plymouthName : +# return False +# else : +# shutil.rmtree('/var/lib/youker-assistant-daemon/plymouth/existing/' + plymouthName) +# shutil.rmtree('/lib/plymouth/themes/' + plymouthName) +# return True + +if __name__ == '__main__': + ooo = Others() +# print ooo.get_existing_plymouth_list() +# ooo.add_new_plymouth('/home/shine/heihei.png', 'hoho') +# ooo.custom_plymouth_bg('hoho') +# ooo.plymouth_init_check() diff --git a/backends/youker-assistant-daemon/src/beautify/settings.py b/backends/youker-assistant-daemon/src/beautify/settings.py new file mode 100644 index 0000000..a83999b --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/settings.py @@ -0,0 +1,115 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# +# Author: Kobe Lee +# Maintainer: Ubuntu Kylin +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + + +from gi.repository import Gio as gio +import os, sys +import types +from common import Schema + +#http://lazka.github.io/pgi-docs/api/Gio_2.0/classes/Settings.html + +class Settings: + #db = None + #BASE_KEY = "org.gnome.gedit.preferences.encodings" + def __init__(self, schema): + self.db = gio.Settings.new(schema) + + #def open_settings_db(self): + # try: + # self.db = gio.Settings.new(self.BASE_KEY) + # except Exception as e: + # print e + + def get_value(self, key, type): + try: + setting_type = type + get_func = { + types.IntType: self.db.get_int, + types.StringType: self.db.get_string, + types.BooleanType: self.db.get_boolean, + types.ListType: self.db.get_strv, + types.DictType: self.db.get_string, + types.NoneType: self.db.get_value, + }[setting_type] + return get_func(key) + except Exception as e: + print e + return None + + def set_value(self, key, type, value): + try: + setting_type = type + set_func = { + types.IntType: self.db.set_int, + types.StringType: self.db.set_string, + types.BooleanType: self.db.set_boolean, + types.ListType: self.db.set_strv, + types.DictType: self.db.set_string, + types.NoneType: self.db.set_value, + }[setting_type] + set_func(key, value) + except Exception as e: + print e + + def get_schema_value(self, schema, key): + schema_default = Schema.load_schema(schema, key) + if schema_default is not None: + return schema_default + else: + raise NotImplemented + + # kobe: test notify func +# def connect_notify(self): +# #def connect_notify(self, func, data=None): +## gs = gio.Settings("org.gnome.nautilus.desktop", None) +# self.db.connect("changed::home-icon-visible", self.kobe_test) + +# def kobe_test(self, settings, key): +# print "notify test success----------------------------" + +if __name__ == '__main__': + #list_on = ['GB18030', 'UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16'] + #list_off = ['UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16'] + settings = Settings("org.gnome.gedit.preferences.encodings") + ##settings.open_settings_db() + #value = settings.get_value("auto-detected", types.ListType) + #print type(value)# + #print value + #if value == list_off: + # settings.set_value("auto-detected", types.ListType, list_on) + #else: + # settings.set_value("auto-detected", types.ListType, list_off) + + #settings = Settings("org.gnome.nautilus.preferences") + #value = settings.get_value("always-use-location-entry", types.BooleanType) + #settings = Settings("org.gnome.desktop.media-handling") + #value = settings.get_value("automount", types.BooleanType) + #print type(value)# + #print value + + default_value = settings.get_schema_value("org.gnome.gedit.preferences.encodings", "auto-detected") + print "default_value->" + print default_value + + + diff --git a/backends/youker-assistant-daemon/src/beautify/sound.py b/backends/youker-assistant-daemon/src/beautify/sound.py new file mode 100644 index 0000000..e80eb8c --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/sound.py @@ -0,0 +1,222 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import shutil +import gsettings +import utils + +class Sound: + homedir = '' + desktop = None + + def __init__(self): + self.homedir = utils.get_home_dir() + self.desktop = os.getenv('XDG_CURRENT_DESKTOP') + if self.desktop is None: + self.desktop = os.getenv('XDG_SESSION_DESKTOP') + + # sometimes need set homedir manual fe:the backend run by root dbus + def set_homedir(self, homedir): + self.homedir = homedir + + # -----------------默认值----------------- + # Get Default Value + def get_default_schema_value(self, schema, key): + return gsettings.get_schema_value(schema, key) + + # Set Default Value + def set_default_schema_value(self, schema, key, type): + default_value = self.get_default_schema_value(schema, key) + if default_value is not None: + return gsettings.set(schema, None, key, type, default_value) + else: + raise NotImplemented + # ---------------------------------- + def set_input_feedback_sounds_enable(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.sound', + None, + 'input-feedback-sounds', + 'boolean', flag) + else: + return gsettings.set('org.gnome.desktop.sound', + None, + 'input-feedback-sounds', + 'boolean', flag) + + def get_input_feedback_sounds_enable(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.sound', + None, 'input-feedback-sounds', 'boolean') + else: + return gsettings.get('org.gnome.desktop.sound', + None, 'input-feedback-sounds', 'boolean') + + def set_sound_event_enable(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.sound', + None, + 'event-sounds', + 'boolean', flag) + else: + return gsettings.set('org.gnome.desktop.sound', + None, + 'event-sounds', + 'boolean', flag) + + def get_sound_event_enable(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.sound', + None, 'event-sounds', 'boolean') + else: + return gsettings.get('org.gnome.desktop.sound', + None, 'event-sounds', 'boolean') + + # enable the login music + def set_login_music_enable(self, flag): + configdir = self.homedir + '/.config/autostart' + desktopfile = '/var/lib/youker-assistant-daemon/autostart/libcanberra-login-sound.desktop' + targetfile = configdir + '/libcanberra-login-sound.desktop' + + if flag: + if os.path.exists(configdir): + pass + else: + os.makedirs(configdir) + shutil.copy(desktopfile, targetfile) + else: + if os.path.exists(targetfile): + os.remove(targetfile) + else: + pass + + # get enable the login music. need fix text check in 'libcanberra-login-sound.desktop' + def get_login_music_enable(self): + targetfile = self.homedir + '/.config/autostart/libcanberra-login-sound.desktop' + + if os.path.exists(targetfile): + return True + else: + return False + + # get sound themes & check and bak sounds + def get_sound_themes(self): + bakDir = '/var/lib/youker-assistant-daemon/sound-theme/' + dirs = ('/usr/share/sounds', os.path.join(self.homedir, ".sounds")) + filters = ('index.theme', '') + valid = utils.check_dirs(dirs, filters, True) + valid.sort() + + # check and bak sounds + for st in valid: + if(os.path.exists(bakDir + st) == False): + if(os.path.exists('/usr/share/sounds/' + st)): + shutil.copytree('/usr/share/sounds/' + st, bakDir + st) + else: + shutil.copytree(self.homedir + '.sounds/' + st, bakDir + st) + + return valid + + # get current sound theme + def get_sound_theme(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.sound', + None, 'theme-name', 'string') + else: + return gsettings.get('org.gnome.desktop.sound', + None, 'theme-name', 'string') + + # set sound theme + def set_sound_theme(self, theme): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gstheme = gsettings.get_schema('org.mate.sound') + gstheme.set_string('theme-name',theme) + else: + gstheme = gsettings.get_schema('org.gnome.desktop.sound') + gstheme.set_string('theme-name',theme) + + # get sounds in current theme + def get_sounds(self): + results = [] + currentTheme = self.get_sound_theme() + if(os.path.exists(os.path.join(self.homedir, ".sounds") + currentTheme)): + soundDir = os.path.join(self.homedir, ".sounds") + currentTheme + elif(os.path.exists('/usr/share/sounds/' + currentTheme)): + soundDir = '/usr/share/sounds/' + currentTheme + else: + return results + + for sound in os.listdir(soundDir + '/stereo'): + # pass the link file + if(os.path.islink(soundDir + '/stereo/' + sound) == False): + results.append(soundDir + '/stereo/' + sound) + results.sort() + return results + + # replace sound file + def replace_sound_file(self, newSoundFile, targetSoundFile): + newSoundFile = newSoundFile.encode('utf-8') + targetSoundFile = targetSoundFile.encode('utf-8') + currentTheme = self.get_sound_theme() + if(os.path.exists(os.path.join(self.homedir, ".sounds") + currentTheme)): + soundDir = os.path.join(self.homedir, ".sounds") + currentTheme + elif(os.path.exists('/usr/share/sounds/' + currentTheme)): + soundDir = '/usr/share/sounds/' + currentTheme + else: + pass + + shutil.copy(newSoundFile, soundDir + '/stereo/' + targetSoundFile) + + # restore sound file + def restore_sound_file(self, targetSoundFile): + targetSoundFile = targetSoundFile.encode('utf-8') + bakDir = '/var/lib/youker-assistant-daemon/sound-theme/' + currentTheme = self.get_sound_theme() + if(os.path.exists(os.path.join(self.homedir, ".sounds") + currentTheme)): + soundDir = os.path.join(self.homedir, ".sounds") + currentTheme + elif(os.path.exists('/usr/share/sounds/' + currentTheme)): + soundDir = '/usr/share/sounds/' + currentTheme + else: + pass + + shutil.copy(bakDir + currentTheme + '/stereo/' + targetSoundFile, soundDir + '/stereo/' + targetSoundFile) + + # restore all sound file in current sound theme + def restore_all_sound_file(self, soundTheme): + bakSoundThemeDir = '/var/lib/youker-assistant-daemon/sound-theme/' + soundTheme + if(os.path.exists(os.path.join(self.homedir, ".sounds") + soundTheme)): + soundDir = os.path.join(self.homedir, ".sounds") + soundTheme + elif(os.path.exists('/usr/share/sounds/' + soundTheme)): + soundDir = '/usr/share/sounds/' + soundTheme + else: + pass + + for soundFile in os.listdir(bakSoundThemeDir + '/stereo'): + shutil.copy(bakSoundThemeDir + '/stereo/' + soundFile, soundDir + '/stereo/' + soundFile) + +if __name__ == '__main__': + sss = Sound() +# print sss.get_sound_themes() +# sss.restore_all_sound_file('ubuntu') +# print sss.get_login_music_enable() +# sss.set_login_music_enable(False) +# print sss.get_sound_themes() +# print sss.get_sound_theme() + print sss.get_sounds() +# sss.set_sound_theme('freedesktop') diff --git a/backends/youker-assistant-daemon/src/beautify/system.py b/backends/youker-assistant-daemon/src/beautify/system.py new file mode 100644 index 0000000..a529169 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/system.py @@ -0,0 +1,633 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import gsettings +import platform +from gi.repository import Gio as gio + +class System(): + + desktop = None + touchpad_remove = False + + def __init__(self, sysdaemon): + self.sysdaemon = sysdaemon + self.desktop = os.getenv('XDG_CURRENT_DESKTOP') + if self.desktop is None: + self.desktop = os.getenv('XDG_SESSION_DESKTOP') + release_info = platform.platform() + # 20160119 + if "org.gnome.settings-daemon.peripherals.touchpad" in gio.Settings.list_schemas(): + self.touchpad_remove = False + else: + self.touchpad_remove = True +# if "15.10-wily" in release_info: +# self.touchpad_remove = True + + # -----------------默认值----------------- + # Get Default Value + def get_default_schema_value(self, schema, key): + return gsettings.get_schema_value(schema, key) + + # Set Default Value + def set_default_schema_value(self, schema, key, type): + #fp = open("/tmp/default.txt", "w") + #print >> fp, "--------------" + #fp.close() + default_value = self.get_default_schema_value(schema, key) + if default_value is not None: + gsettings.set(schema, None, key, type, default_value) + if schema == "org.gnome.desktop.wm.preferences" and key == "button-layout": + if default_value == 'close,maximize,minimize:' or default_value == 'close,minimize,maximize:': + self.sysdaemon.change_titlebar_position('left') + elif default_value == ':minimize,maximize,close': + self.sysdaemon.change_titlebar_position('right') + else: + raise NotImplemented + + # ---------------scrollbars--------------- + + # set scrollbars mode overlay + def set_scrollbars_mode_overlay(self): + return gsettings.set('com.canonical.desktop.interface', + None, + 'scrollbar-mode', + 'string', 'overlay-auto') + + # set scrollbars mode legacy + def set_scrollbars_mode_legacy(self): + return gsettings.set('com.canonical.desktop.interface', + None, + 'scrollbar-mode', + 'string', 'normal') + + # get scrollbars mode + def get_scrollbars_mode(self): + return gsettings.get('com.canonical.desktop.interface', + None, 'scrollbar-mode', 'string') + + # ---------------touchpad--------------- + + # enable/disable the touchpad + def set_touchpad_enable(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.peripherals-touchpad', + None, + 'touchpad-enabled', + 'boolean', flag) + else: + # kobe1510 + if self.touchpad_remove: + return False + else: + return gsettings.set('org.gnome.settings-daemon.peripherals.touchpad', + None, + 'touchpad-enabled', + 'boolean', flag) + + # get is touchpad enable + def get_touchpad_enable(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.peripherals-touchpad', + None, 'touchpad-enabled', 'boolean') + else: + # kobe1510 + if self.touchpad_remove: + return False + else: + return gsettings.get('org.gnome.settings-daemon.peripherals.touchpad', + None, 'touchpad-enabled', 'boolean') + + def set_touchscrolling_mode_disabled(self): + # kobe1510 + if self.touchpad_remove: + return gsettings.set('org.gnome.desktop.peripherals.touchpad', + None, + 'scroll-method', + 'string', 'disabled') + else: + return gsettings.set('org.gnome.settings-daemon.peripherals.touchpad', + None, + 'scroll-method', + 'string', 'disabled') + + # set touch scrolling mode edge + def set_touchscrolling_mode_edge(self): + # kobe1510 + if self.touchpad_remove: + return gsettings.set('org.gnome.desktop.peripherals.touchpad', + None, + 'scroll-method', + 'string', 'edge-scrolling') + else: + return gsettings.set('org.gnome.settings-daemon.peripherals.touchpad', + None, + 'scroll-method', + 'string', 'edge-scrolling') + + # set touch scrolling mode two-finger + def set_touchscrolling_mode_twofinger(self): + # kobe1510 + if self.touchpad_remove: + return gsettings.set('org.gnome.desktop.peripherals.touchpad', + None, + 'scroll-method', + 'string', 'two-finger-scrolling') + else: + return gsettings.set('org.gnome.settings-daemon.peripherals.touchpad', + None, + 'scroll-method', + 'string', 'two-finger-scrolling') + + # get touchpad scrolling mode + def get_touchscrolling_mode(self): + # kobe1510 + if self.touchpad_remove: + return gsettings.get('org.gnome.desktop.peripherals.touchpad', + None, 'scroll-method', 'string') + else: + return gsettings.get('org.gnome.settings-daemon.peripherals.touchpad', + None, 'scroll-method', 'string') + + #----------------------------mate-------------------------- + #选择触摸板滚动模式。支持的值有:0 - 禁止,1 - 边界滚动,2 - 双指滚动 + def set_mate_touchscrolling_mode(self, value): + return gsettings.set('org.mate.peripherals-touchpad', + None, + 'scroll-method', + 'int', value) + + def get_mate_touchscrolling_mode(self): + return gsettings.get('org.mate.peripherals-touchpad', + None, 'scroll-method', 'int') + + # set touch scrolling use horizontal True/False + def set_touchscrolling_use_horizontal(self, flag): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.peripherals-touchpad', + None, + 'horiz-scroll-enabled', + 'boolean', flag) + else: + # kobe1510 + if self.touchpad_remove: + return False + else: + return gsettings.set('org.gnome.settings-daemon.peripherals.touchpad', + None, + 'horiz-scroll-enabled', + 'boolean', flag) + + # get is touch scrolling use horizontal + def get_touchscrolling_use_horizontal(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.peripherals-touchpad', + None, 'horiz-scroll-enabled', 'boolean') + else: + # kobe1510 + if self.touchpad_remove: + return False + else: + return gsettings.get('org.gnome.settings-daemon.peripherals.touchpad', + None, 'horiz-scroll-enabled', 'boolean') + + # ---------------window--------------- + + # set window button alignment left + def set_window_button_align_left(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + value = gsettings.get('org.gnome.desktop.wm.preferences', + None, 'button-layout', 'string') + if "menu" in value: + gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'button-layout', + 'string', 'close,maximize,minimize:menu') + else: + gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'button-layout', + 'string', 'close,maximize,minimize') + else: + gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'button-layout', + 'string', 'close,maximize,minimize:') + self.sysdaemon.change_titlebar_position("left") + #return gsettings.set('org.gnome.desktop.wm.preferences', + # None, + # 'button-layout', + # 'string', 'close,maximize,minimize:')#close,minimize,maximize: + + # set window button alignment right + def set_window_button_align_right(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + value = gsettings.get('org.gnome.desktop.wm.preferences', + None, 'button-layout', 'string') + if "menu" in value: + gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'button-layout', + 'string', 'menu:minimize,maximize,close') + else: + gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'button-layout', + 'string', ':minimize,maximize,close') + else: + gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'button-layout', + 'string', ':minimize,maximize,close') + self.sysdaemon.change_titlebar_position("right") + #return gsettings.set('org.gnome.desktop.wm.preferences', + # None, + # 'button-layout', + # 'string', ':minimize,maximize,close') + + # get window button alignment + def get_window_button_align(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + value = gsettings.get('org.gnome.desktop.wm.preferences', + None, 'button-layout', 'string') + if value == 'close,maximize,minimize:menu' or value == 'close,minimize,maximize:menu' or value == 'close,minimize,maximize:' or value == 'close,maximize,minimize:': + return 'left' + elif value == 'menu:minimize,maximize,close' or value == 'menu:maximize,minimize,close' or value == ':minimize,maximize,close' or value == ':maximize,minimize,close': + return 'right' + else: + value = gsettings.get('org.gnome.desktop.wm.preferences', + None, 'button-layout', 'string') + if value == 'close,maximize,minimize:' or value == 'close,minimize,maximize:': + return 'left' + elif value == ':minimize,maximize,close' or value == ':maximize,minimize,close': + return 'right' + #elif value == 'close,minimize,maximize:': + # return 'default' + else: + return 'custom' + + # set right click menus have icons 菜单带图标 是否可在菜单项旁显示图标。 + def set_menus_have_icons(self, flag): + return gsettings.set('org.gnome.desktop.interface', + None, + 'menus-have-icons', + 'boolean', flag) + + # get is right click menus have icons + def get_menus_have_icons(self): + return gsettings.get('org.gnome.desktop.interface', + None, 'menus-have-icons', 'boolean') + + #-----------------------窗口控制按钮位置---------------------- + # get window button + #def get_window_button(self): + # return ['close,minimize,maximize:', ':minimize,maximize,close'] #左边/右边 + + # get current window button + #def get_current_window_button(self): + # return gsettings.get('org.gnome.desktop.wm.preferences', + # None, 'button-layout', 'string') + + # set window button + #def set_window_button(self, value): + # return gsettings.set('org.gnome.desktop.wm.preferences', + # None, + # 'button-layout', + # 'string', value) + + #-----------------------标题栏鼠标滚轮动作--------------------- + # get titlebar wheel + def get_titlebar_wheel(self): + return ['none', 'shade'] + + # get current titlebar wheel + def get_current_titlebar_wheel(self): + return gsettings.get('org.compiz.gwd', + None, 'mouse-wheel-action', 'string') + + # set titlebar wheel + def set_titlebar_wheel(self, value): + return gsettings.set('org.compiz.gwd', + None, + 'mouse-wheel-action', + 'string', value) + + #-------------------------标题栏双击动作------------------------- +# “toggle-shade”卷起/展开窗口,“toggle-maximize”最大化/还原窗口, +#“toggle-maximize-horizontally”及“toggle-maximize-vertically”横向及纵向最大化/还原窗口, +#“minimize”最小化窗口,“shade”卷起窗口, +#“menu”显示窗口菜单,“lower”将窗口降低到所有窗口之下,还有“none”什么也不做。 + # get titlebar double + def get_titlebar_options(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return ['none', 'toggle_maximize', 'toggle_maximize_horizontally', 'toggle_maximize_vertically', 'minimize', 'toggle_shade', 'lower', 'menu', 'last'] + else: + return ['none', 'toggle-maximize', 'toggle-maximize-horizontally', 'toggle-maximize-vertically', 'minimize', 'toggle-shade', 'lower', 'menu', 'last'] + + # get current titlebar double + def get_current_titlebar_double(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.gnome.desktop.wm.preferences', + None, 'action-double-click-titlebar', 'string') + else: + return gsettings.get('org.gnome.desktop.wm.preferences', + None, 'action-double-click-titlebar', 'string') + + # set titlebar double + def set_titlebar_double(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'action-double-click-titlebar', + 'string', value) + else: + return gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'action-double-click-titlebar', + 'string', value) + + #-------------------------标题栏中键动作------------------------- + # get titlebar middle + def get_titlebar_middle(self): + return ['none', 'toggle-maximize', 'toggle-maximize-horizontally', 'toggle-maximize-vertically', 'minimize', 'toggle-shade', 'lower', 'menu', 'last'] + + # get current titlebar middle + def get_current_titlebar_middle(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.gnome.desktop.wm.preferences', + None, 'action-middle-click-titlebar', 'string') + else: + return gsettings.get('org.gnome.desktop.wm.preferences', + None, 'action-middle-click-titlebar', 'string') + + # set titlebar middle + def set_titlebar_middle(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'action-middle-click-titlebar', + 'string', value) + else: + return gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'action-middle-click-titlebar', + 'string', value) + + #-------------------------标题栏右键动作------------------------- + # get titlebar right + def get_titlebar_right(self): + return ['none', 'toggle-maximize', 'toggle-maximize-horizontally', 'toggle-maximize-vertically', 'minimize', 'toggle-shade', 'lower', 'menu', 'last'] + + # get current titlebar right + def get_current_titlebar_right(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.gnome.desktop.wm.preferences', + None, 'action-right-click-titlebar', 'string') + else: + return gsettings.get('org.gnome.desktop.wm.preferences', + None, 'action-right-click-titlebar', 'string') + + # set titlebar right + def set_titlebar_right(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'action-right-click-titlebar', + 'string', value) + else: + return gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'action-right-click-titlebar', + 'string', value) + + def get_current_idle_delay(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.session', + None, 'idle-delay', 'int') + else: + return gsettings.get('org.gnome.desktop.session', + None, 'idle-delay', 'uint') + + def set_current_idle_delay(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gsettings.set('org.mate.session', + None, + 'idle-delay', + 'int', value) + else: + gsettings.set('org.gnome.desktop.session', + None, + 'idle-delay', + 'uint', value) + + def get_lock_enabled(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.screensaver', + None, 'lock-enabled', 'boolean') + else: + return gsettings.get('org.gnome.desktop.screensaver', + None, 'lock-enabled', 'boolean') + + def set_lock_enabled(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gsettings.set('org.mate.screensaver', + None, + 'lock-enabled', + 'boolean', value) + else: + gsettings.set('org.gnome.desktop.screensaver', + None, + 'lock-enabled', + 'boolean', value) + + def get_current_lock_delay(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.screensaver', + None, 'lock-delay', 'int') + else: + return gsettings.get('org.gnome.desktop.screensaver', + None, 'lock-delay', 'uint') + + def set_current_lock_delay(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gsettings.set('org.mate.screensaver', + None, + 'lock-delay', + 'int', value) + else: + gsettings.set('org.gnome.desktop.screensaver', + None, + 'lock-delay', + 'uint', value) + + def get_current_critical_low(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.power-manager', + None, 'action-critical-battery', 'string') + else: + return gsettings.get('org.gnome.settings-daemon.plugins.power', + None, 'critical-battery-action', 'string') + + def set_current_critical_low(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gsettings.set('org.mate.power-manager', + None, + 'action-critical-battery', + 'string', value) + else: + gsettings.set('org.gnome.settings-daemon.plugins.power', + None, + 'critical-battery-action', + 'string', value) + + def get_current_lid_battery(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.power-manager', + None, 'button-lid-battery', 'string') + else: + return gsettings.get('org.gnome.settings-daemon.plugins.power', + None, 'lid-close-battery-action', 'string') + + def set_current_lid_battery(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gsettings.set('org.mate.power-manager', + None, + 'button-lid-battery', + 'string', value) + else: + gsettings.set('org.gnome.settings-daemon.plugins.power', + None, + 'lid-close-battery-action', + 'string', value) + + def get_current_lid_ac(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.power-manager', + None, 'button-lid-ac', 'string') + else: + return gsettings.get('org.gnome.settings-daemon.plugins.power', + None, 'lid-close-ac-action', 'string') + + def set_current_lid_ac(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gsettings.set('org.mate.power-manager', + None, + 'button-lid-ac', + 'string', value) + else: + gsettings.set('org.gnome.settings-daemon.plugins.power', + None, + 'lid-close-ac-action', + 'string', value) + + #---------------------------------------------------------------------- + def get_current_sleep_timeout_display_battery(self): + return gsettings.get('org.mate.power-manager', + None, 'sleep-display-battery', 'int') + + def set_current_sleep_timeout_display_battery(self, value): + gsettings.set('org.mate.power-manager', + None, + 'sleep-display-battery', + 'int', value) + + def get_current_sleep_timeout_display_ac(self): + return gsettings.get('org.mate.power-manager', + None, 'sleep-display-ac', 'int') + + def set_current_sleep_timeout_display_ac(self, value): + gsettings.set('org.mate.power-manager', + None, + 'sleep-display-ac', + 'int', value) + #---------------------------------------------------------------------- + + def get_current_sleep_timeout_battery(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.power-manager', + None, 'sleep-computer-battery', 'int') + else: + return gsettings.get('org.gnome.settings-daemon.plugins.power', + None, 'sleep-inactive-battery-timeout', 'int') + + def set_current_sleep_timeout_battery(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gsettings.set('org.mate.power-manager', + None, + 'sleep-computer-battery', + 'int', value) + else: + gsettings.set('org.gnome.settings-daemon.plugins.power', + None, + 'sleep-inactive-battery-timeout', + 'int', value) + + def get_current_sleep_timeout_ac(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.power-manager', + None, 'sleep-computer-ac', 'int') + else: + return gsettings.get('org.gnome.settings-daemon.plugins.power', + None, 'sleep-inactive-ac-timeout', 'int') + + def set_current_sleep_timeout_ac(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gsettings.set('org.mate.power-manager', + None, + 'sleep-computer-ac', + 'int', value) + else: + gsettings.set('org.gnome.settings-daemon.plugins.power', + None, + 'sleep-inactive-ac-timeout', + 'int', value) + +if __name__ == '__main__': + gsettings.set('org.compiz.gwd',None,'mouse-wheel-action', 'string', 'shade') +# sss = System(None) +# print sss.set_titlebar_wheel('shade') + + #aa = sss.get_default_schema_value('org.gnome.settings-daemon.peripherals.touchpad', 'touchpad-enabled') + #print aa#True + #sss.set_default_schema_value('org.gnome.settings-daemon.peripherals.touchpad', 'touchpad-enabled', 'boolean') + #bb = sss.get_default_schema_value('com.canonical.desktop.interface', 'scrollbar-mode') + #print bb#overlay-auto + #sss.set_default_schema_value('com.canonical.desktop.interface', 'scrollbar-mode', 'string') + #cc = sss.get_default_schema_value('org.gnome.settings-daemon.peripherals.touchpad', 'scroll-method') + #print cc#two-finger-scrolling + #sss.set_default_schema_value('org.gnome.settings-daemon.peripherals.touchpad', 'scroll-method', 'string') +# dd = sss.get_default_schema_value('org.gnome.settings-daemon.peripherals.touchpad', 'horiz-scroll-enabled') +# print dd#True + #sss.set_default_schema_value('org.gnome.settings-daemon.peripherals.touchpad', 'horiz-scroll-enabled', 'boolean') + + #print sss.get_scrollbars_mode() + #print sss.get_touchpad_enable() + #print sss.get_touchscrolling_mode() + #print sss.get_touchscrolling_use_horizontal() + #print sss.get_window_button_align() + #print sss.get_menus_have_icons() +# sss.set_menus_have_icons(True) +# sss.set_touchpad_enable(True) + #sss.set_scrollbars_mode_overlay() + # sss.set_scrollbars_mode_legacy() + # sss.set_touchscrolling_mode_edge() + #sss.set_touchscrolling_mode_twofinger() + #sss.set_touchscrolling_use_horizontal(True) + # sss.set_window_button_align_left() + # sss.set_window_button_align_right() diff --git a/backends/youker-assistant-daemon/src/beautify/theme.py b/backends/youker-assistant-daemon/src/beautify/theme.py new file mode 100644 index 0000000..1b56ffb --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/theme.py @@ -0,0 +1,446 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import gsettings +import utils + +class Theme: + homedir = '' + desktop = None + + def __init__(self): + self.homedir = utils.get_home_dir() + self.desktop = os.getenv('XDG_CURRENT_DESKTOP') + if self.desktop is None: + self.desktop = os.getenv('XDG_SESSION_DESKTOP') + + # ---------------themes--------------- + def set_ubuntukylin_default_setting(self, schema, title, key, type, default_value): + if title == 'unity': + return gsettings.set(schema, '/org/compiz/profiles/unity/plugins/unityshell/', key, type, default_value) + else: + return gsettings.set(schema, None, key, type, default_value) + + # -----------------默认值----------------- + # Get Default Value + def get_default_schema_value(self, schema, key): + default_value = gsettings.get_schema_value(schema, key) + if self.desktop != "mate" and self.desktop != "MATE": + if (default_value in (None, '') and schema == 'org.gnome.nautilus.desktop' and key == 'font'): + default_value = 'Ubuntu 11' + return default_value + + # Set Default Value + def set_default_schema_value(self, schema, key, type): + default_value = self.get_default_schema_value(schema, key) + if (default_value in (None, '') and schema == 'org.gnome.nautilus.desktop' and key == 'font'): + default_value = 'Ubuntu 11' + if default_value is not None: + return gsettings.set(schema, None, key, type, default_value) + else: + raise NotImplemented + # ---------------------------------- + + # get themes + def get_themes(self): + dirs = ('/usr/share/themes', os.path.join(self.homedir, ".themes")) + filters = ('gtk-2.0', 'gtk-3.0', 'metacity-1') + valid = utils.check_dirs(dirs, filters, True) + valid.sort() + return valid + + # get current theme + def get_theme(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.interface', + None, 'gtk-theme', 'string') + else: + return gsettings.get('org.gnome.desktop.interface', + None, 'gtk-theme', 'string') + + # set GTK theme and window theme + def set_theme(self, theme): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gstheme = gsettings.get_schema('org.mate.interface') + gstheme.set_string('gtk-theme',theme) + else: + gstheme = gsettings.get_schema('org.gnome.desktop.interface') + gstheme.set_string('gtk-theme',theme) + _gstheme = gsettings.get_schema('org.gnome.desktop.wm.preferences') + _gstheme.set_string('theme',theme) + + #------------------------窗口主题设置 + # get window theme + def get_window_themes(self): + dirs = ('/usr/share/themes', os.path.join(self.homedir, ".themes")) + filters = ['metacity-1'] + valid = utils.check_dirs(dirs, filters, True) + valid.sort() + return valid + + # get current window theme + def get_current_window_theme(self): + return gsettings.get('org.gnome.desktop.wm.preferences', + None, 'theme', 'string') + + # set window theme + def set_window_theme(self, theme): + return gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'theme', + 'string', theme) + + + + # get icon themes + def get_icon_themes(self): + dirs = ('/usr/share/icons', os.path.join(self.homedir, ".icons")) + + '''filters: if use only one filter string, + the 'for' block in check_dirs() will split the filter string to single chars...''' + filters = ('cursors', '#') + valid = utils.check_dirs(dirs, filters, False) + valid.sort() + return valid + + # get current icon theme + def get_icon_theme(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.interface', + None, 'icon-theme', 'string') + else: + return gsettings.get('org.gnome.desktop.interface', + None, 'icon-theme', 'string') + + # set icon theme + def set_icon_theme(self, theme): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gstheme = gsettings.get_schema('org.mate.interface') + gstheme.set_string('icon-theme',theme) + else: + gstheme = gsettings.get_schema('org.gnome.desktop.interface') + gstheme.set_string('icon-theme',theme) + + # get cursor themes + def get_cursor_themes(self): + dirs = ('/usr/share/icons', os.path.join(self.homedir, ".icons")) + + '''filters: if use only one filter string, + the 'for' block in check_dirs() will split the filter string to single chars...''' + filters = ('cursors', '') + valid = utils.check_dirs(dirs, filters, True) + valid.sort() + return valid + + # get current cursor theme + def get_cursor_theme(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.peripherals-mouse', + None, 'cursor-theme', 'string') + else: + return gsettings.get('org.gnome.desktop.interface', + None, 'cursor-theme', 'string') + + # set cursor theme + def set_cursor_theme(self, theme): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gstheme = gsettings.get_schema('org.mate.peripherals-mouse') + gstheme.set_string('cursor-theme', theme) + else: + gstheme = gsettings.get_schema('org.gnome.desktop.interface') + gstheme.set_string('cursor-theme', theme) + + def set_cursor_theme_with_root(self, theme): + try : + fd = open('/usr/share/icons/default/index.theme','w') + fd.write('[Icon Theme]\n') + fd.write('Inherits=' + theme + '\n') + fd.close() + return True + except Exception,e : + return False + + # get cursor size + def get_cursor_size(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.peripherals-mouse', + None, 'cursor-size', 'int') + else: + return gsettings.get('org.gnome.desktop.interface', + None, 'cursor-size', 'int') + + # set cursor size + def set_cursor_size(self, size): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + gstheme = gsettings.get_schema('org.mate.peripherals-mouse') + gstheme.set_int('cursor-size', size) + else: + gstheme = gsettings.get_schema('org.gnome.desktop.interface') + gstheme.set_int('cursor-size', size) + + + + # ---------------fonts--------------- + + # get font + def get_font(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.interface', + None, 'font-name', 'string') + else: + return gsettings.get('org.gnome.desktop.interface', + None, 'font-name', 'string') + + # set font + def set_font(self, font): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.interface', + None, + 'font-name', + 'string', font) + else: + return gsettings.set('org.gnome.desktop.interface', + None, + 'font-name', + 'string', font) + + # get desktop font + def get_desktop_font(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.caja.desktop', + None, 'font', 'string') + else: + return gsettings.get('org.gnome.nautilus.desktop', + None, 'font', 'string') + + # set desktop font + def set_desktop_font(self, font): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.caja.desktop', + None, + 'font', + 'string', font) + else: + return gsettings.set('org.gnome.nautilus.desktop', + None, + 'font', + 'string', font) + + # get document font + def get_document_font(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.interface', + None, 'document-font-name', 'string') + else: + return gsettings.get('org.gnome.desktop.interface', + None, 'document-font-name', 'string') + + # set document font + def set_document_font(self, font): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.interface', + None, + 'document-font-name', + 'string', font) + else: + return gsettings.set('org.gnome.desktop.interface', + None, + 'document-font-name', + 'string', font) + + # get monospace font + def get_monospace_font(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.interface', + None, 'monospace-font-name', 'string') + else: + return gsettings.get('org.gnome.desktop.interface', + None, 'monospace-font-name', 'string') + + # set monospace font (use this func to change document font in ubuntu) + def set_monospace_font(self, font): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.interface', + None, + 'monospace-font-name', + 'string', font) + else: + return gsettings.set('org.gnome.desktop.interface', + None, + 'monospace-font-name', + 'string', font) + + # get window title font + def get_window_title_font(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.gnome.desktop.wm.preferences', + None, 'titlebar-font', 'string') + else: + return gsettings.get('org.gnome.desktop.wm.preferences', + None, 'titlebar-font', 'string') + + # set window title font + def set_window_title_font(self, font): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'titlebar-font', + 'string', font) + else: + return gsettings.set('org.gnome.desktop.wm.preferences', + None, + 'titlebar-font', + 'string', font) + + # get font zoom + def get_font_zoom(self): + return gsettings.get('org.gnome.desktop.interface', + None, 'text-scaling-factor', 'double') + + # set font zoom + def set_font_zoom(self, zoom): + return gsettings.set('org.gnome.desktop.interface', + None, + 'text-scaling-factor', + 'double', zoom) + + # -------------------------平滑性---------------------------------- + # get all hinting value. none:'No hinting',slight:'Basic',medium:'Moderate',full:'Maximum' + def get_all_hinting(self): + return ['none', 'slight', 'medium', 'full'] + + # get current hinting + def get_hinting(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.font-rendering', + None, + 'hinting', + 'string') + else: + return gsettings.get('org.gnome.settings-daemon.plugins.xsettings', + None, + 'hinting', + 'string') + + # set hinting + def set_hinting(self, value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.font-rendering', + None, + 'hinting', + 'string', value) + else: + return gsettings.set('org.gnome.settings-daemon.plugins.xsettings', + None, + 'hinting', + 'string', value) + + # -------------------------反锯齿---------------------------------- + # get all antialiasing value. none:'No antialiasing', grayscale:'Standard grayscale antialiasing',rgba:'Subpixel antialiasing (LCD screens only)' + def get_all_antialiasing(self): + return ['none', 'grayscale', 'rgba'] + + # get current antialiasing + def get_antialiasing(self): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.get('org.mate.font-rendering', + None, + 'antialiasing', + 'string') + else: + return gsettings.get('org.gnome.settings-daemon.plugins.xsettings', + None, + 'antialiasing', + 'string') + + # set antialiasing + def set_antialiasing(self,value): + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + return gsettings.set('org.mate.font-rendering', + None, + 'antialiasing', + 'string', value) + else: + return gsettings.set('org.gnome.settings-daemon.plugins.xsettings', + None, + 'antialiasing', + 'string', value) + +if __name__ == '__main__': + ttt = Theme() + # print ttt.get_window_theme() + # print ttt.get_current_window_theme() + # print ttt.set_window_theme('Crux') + # print ttt.get_current_hinting() + # print ttt.get_current_antialiasing() + # print ttt.set_hinting('none') + # print ttt.set_antialiasing('none') + # print ttt.get_font() + # print ttt.set_font('Ubuntu 14') + # print ttt.get_font_zoom() + # ttt.set_font_zoom(1.0) + #ttt.set_monospace_font('Ubuntu Mono 13') + #print ttt.get_monospace_font() + + #aa = ttt.get_default_schema_value('org.gnome.nautilus.desktop', 'font') + #print aa + #ttt.set_default_schema_value('org.gnome.nautilus.desktop', 'font', 'string') + #aa = ttt.get_default_schema_value('org.gnome.settings-daemon.plugins.xsettings', 'hinting') + #print aa + #ttt.set_default_schema_value('org.gnome.settings-daemon.plugins.xsettings', 'hinting', 'string') + #bb = ttt.get_default_schema_value('org.gnome.settings-daemon.plugins.xsettings', 'antialiasing') + #print bb + + aa = ttt.get_default_schema_value('org.gnome.desktop.interface', 'cursor-size') + print aa + bb = ttt.get_cursor_size() + print bb + ttt.set_default_schema_value('org.gnome.desktop.interface', 'cursor-size', 'int') + + #aa = ttt.get_default_schema_value('org.gnome.desktop.interface', 'font-name') + #print aa + # ttt.set_default_schema_value('org.gnome.desktop.interface', 'font-name', 'string') + # print ttt.get_theme() + # print ttt.get_icon_theme() + # print ttt.get_cursor_theme() + # print ttt.get_cursor_size() + # ttt.set_font('Ubuntu 11') +# print ttt.get_document_font() +# ttt.set_document_font('Sans 15') + # ttt.set_window_title_font('Ubuntu Bold 11') + # print ttt.get_font() + # ttt.set_desktop_font('Ubuntu 11') + # print ttt.get_desktop_font() + # print ttt.get_document_font() + # print ttt.get_window_title_font() + # themes = ttt.get_themes() + # print themes + # print ttt.get_theme() + # ttt.set_theme('ubuntukylin-theme') + # ttt.set_theme('Radiance') + # ttt.set_theme('Ambiance') + # ttt.set_theme('HighContrast') + # iconthemes = ttt.get_icon_themes() + # print iconthemes + # ttt.set_icon_theme('ubuntukylin-icon-theme') + # cursorthemes = ttt.get_cursor_themes() + # print cursorthemes + # print ttt.get_cursor_theme() + # ttt.set_cursor_theme(cursorthemes[1]) + # ttt.set_cursor_size(24) diff --git a/backends/youker-assistant-daemon/src/beautify/unity.py b/backends/youker-assistant-daemon/src/beautify/unity.py new file mode 100644 index 0000000..9cbf6df --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/unity.py @@ -0,0 +1,451 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import gsettings +from compizsettings import CompizSetting + +class Unity: + '''if compiz: key is icon_size; else if gsettins: key is icon-size''' + desktop = None + + def __init__(self): + self.desktop = os.getenv('XDG_CURRENT_DESKTOP') + if self.desktop is None: + self.desktop = os.getenv('XDG_SESSION_DESKTOP') + # self.setting = CompizSetting("%s.%s" % (name, key)) + + # ---------------launcher--------------- + # -----------------默认值----------------- + # Get Default Value + def get_default_schema_value(self, name, key): + compizsetting = CompizSetting("%s.%s" % (name, key)) + return compizsetting.get_schema_value() + + # Set Default Value min=32, max=64, step=16, key="unityshell.icon_size" + #def set_default_schema_value(self, key, name, type, value): + def set_default_schema_value(self, key, type, value): + #default_value = self.get_default_schema_value(name, key) + #if default_value is not None: + return gsettings.set('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + key, type, value) + #else: + # raise NotImplemented + + # launcher auto hide mode, True/False + def set_launcher_autohide(self, flag): + return gsettings.set('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'launcher-hide-mode', + 'int', flag) + + # get launcher auto hide mode + def get_launcher_autohide(self): + try: + value = gsettings.get('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'launcher-hide-mode', 'int') + if value == 0: + return False + elif value == 1: + return True + else: + return None + except Exception, e: + return False + + # launcher icon size 32-64 + def set_launcher_icon_size(self, size): + return gsettings.set('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'icon-size', + 'int', size) + + # get launcher icon size + def get_launcher_icon_size(self): + try: + return gsettings.get('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'icon-size', 'int') + except Exception, e: + return 0 + + # launcher 'show desktop' icon True/False + def set_launcher_have_showdesktopicon(self, flag): + launcher = gsettings.get_schema('com.canonical.Unity.Launcher') + icons = launcher.get_strv('favorites') + desktop = 'unity://desktop-icon' + if flag == True: + if desktop not in icons: + icons.append(desktop) + launcher.set_strv('favorites', icons) + else: + if desktop in icons: + icons.remove(desktop) + launcher.set_strv('favorites', icons) + + # get is launcher have 'show desktop' icon + def get_launcher_have_showdesktopicon(self): + launcher = gsettings.get_schema('com.canonical.Unity.Launcher') + icons = launcher.get_strv('favorites') + desktop = 'unity://desktop-icon' + if desktop in icons: + return True + else: + return False + + def get_default_launcher_have_showdesktopicon(self): + return self.get_launcher_have_showdesktopicon() + + def set_default_launcher_have_showdesktopicon(self): + self.set_launcher_have_showdesktopicon(True) + + + + #add by kobe + # 透明度 + def get_launcher_transparency(self): + try: + return gsettings.get('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'launcher-opacity', 'double') + except Exception, e: + return 0.0 + + # 'min' : 0.2, # TODO : Check these min max. Most prolly wrong. + # 'max' : 1.0, # But fine since they are ignored anyway. + # 'ticks' : [(0.666, Gtk.PositionType.BOTTOM, None)] + def set_launcher_transparency(self, opacity): + return gsettings.set('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'launcher-opacity', + 'double', opacity) + + # 图标背景 + def get_all_launcher_icon_colourings(self): +# return ['0:0', '1:1', '2:2', '3:3', '4:4'] + return ['all programs', 'only run app', 'no coloring', 'edge coloring', 'each workspace alternating coloring'] + + def get_launcher_icon_colouring(self): + try: + return gsettings.get('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'backlight-mode', 'int') + except Exception, e: + return 0 + + # 'map' : {0:0,1:1,2:2,3:3,4:4} 0:所有程序,1:仅打开的应用程序,2:不着色,3:边缘着色,4:每个工作区交替着色 + def set_launcher_icon_colouring(self, colouring): + return gsettings.set('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'backlight-mode', + 'int', colouring) + + def get_all_launcher_position(self): + return ['Left', 'Bottom'] + + def get_current_launcher_position(self): + return gsettings.get('com.canonical.Unity.Launcher', + None, + 'launcher-position', + 'string') + + def set_launcher_position(self, position): + return gsettings.set('com.canonical.Unity.Launcher', + None, + 'launcher-position', + 'string', position) + + #Dash背景模糊类型 + def get_dash_blur_experimental(self): + try: + return gsettings.get('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'dash-blur-experimental', 'int') + except Exception, e: + return 0 + + # 活动模糊smart: 2 静态模糊static:1 非模糊0 + def set_dash_blur_experimental(self, blur): + return gsettings.set('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'dash-blur-experimental', + 'int', blur) + + #面板菜单透明度 + def get_panel_transparency(self): + try: + return gsettings.get('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'panel-opacity', 'double') + except Exception, e: + return 0.0 + + # 'min' : 0.2, # TODO : Check these min max. Most prolly wrong. + # 'max' : 8.0, # But fine since they are ignored anyway. + # 'ticks' : [(0.666, Gtk.PositionType.BOTTOM, None)] + def set_panel_transparency(self, opacity): + return gsettings.set('org.compiz.unityshell', + '/org/compiz/profiles/unity/plugins/unityshell/', + 'panel-opacity', + 'double', opacity) + + #日期时间格式 + def get_all_time_format(self): + return ['locale-default', '12-hour' , '24-hour', 'custom'] + + def get_time_format(self): +# if self.desktop == "mate": +# return gsettings.get('org.mate.panel', +# '/org/mate/panel/objects/clock/prefs/', +# 'format', +# 'string') +# else: + return gsettings.get('com.canonical.indicator.datetime', + None, + 'time-format', + 'string') + + def set_time_format(self, format): +# if self.desktop == "mate": +# return gsettings.set('org.mate.panel', +# '/org/mate/panel/objects/clock/prefs/', +# 'format', +# 'string', format) +# else: + return gsettings.set('com.canonical.indicator.datetime', + None, + 'time-format', + 'string', format) + # 秒 + def get_show_seconds(self): + return gsettings.get('com.canonical.indicator.datetime', + None, + 'show-seconds', + 'boolean') + + def set_show_seconds(self, flag): + return gsettings.set('com.canonical.indicator.datetime', + None, + 'show-seconds', + 'boolean', flag) + + #星期 + def get_show_week(self): + return gsettings.get('com.canonical.indicator.datetime', + None, + 'show-day', + 'boolean') + + def set_show_week(self, flag): + return gsettings.set('com.canonical.indicator.datetime', + None, + 'show-day', + 'boolean', flag) + + #日期 + def get_show_date(self): + return gsettings.get('com.canonical.indicator.datetime', + None, + 'show-date', + 'boolean') + + def set_show_date(self, flag): + return gsettings.set('com.canonical.indicator.datetime', + None, + 'show-date', + 'boolean', flag) + + # 电源 + # present:电源总是可见 charge:当机器充电/放电时可见 never:总是不可见 + def get_all_power_icon_policy(self): + return ['present', 'charge', 'never'] + + def get_power_icon_policy(self): + return gsettings.get('com.canonical.indicator.power', + None, + 'icon-policy', + 'string') + + def set_power_icon_policy(self, flag): + return gsettings.set('com.canonical.indicator.power', + None, + 'icon-policy', + 'string', flag) + + #电源时间 + def get_show_power_time(self): + return gsettings.get('com.canonical.indicator.power', + None, + 'show-time', + 'boolean') + + def set_show_power_time(self, flag): + return gsettings.set('com.canonical.indicator.power', + None, + 'show-time', + 'boolean', flag) + + #电源百分比 + def get_show_power_percentage(self): + return gsettings.get('com.canonical.indicator.power', + None, + 'show-percentage', + 'boolean') + + def set_show_power_percentage(self, flag): + return gsettings.set('com.canonical.indicator.power', + None, + 'show-percentage', + 'boolean', flag) + + #-----------------mate---------------------------- + def set_mate_panel_icon_size(self, position, size): + if position == "top": + return gsettings.set('org.mate.panel.toplevel', + '/org/mate/panel/toplevels/top/', + 'size', + 'int', size) + elif position == "bottom": + return gsettings.set('org.mate.panel.toplevel', + '/org/mate/panel/toplevels/bottom/', + 'size', + 'int', size) + else: + return False + + # get launcher icon size + def get_mate_panel_icon_size(self, position): + if position == "top": + return gsettings.get('org.mate.panel.toplevel', + '/org/mate/panel/toplevels/top/', + 'size', 'int') + elif position == "bottom": + return gsettings.get('org.mate.panel.toplevel', + '/org/mate/panel/toplevels/bottom/', + 'size', 'int') + else: + return False + + def set_mate_panel_autohide(self, position, flag): + if position == "top": + return gsettings.set('org.mate.panel.toplevel', + '/org/mate/panel/toplevels/top/', + 'auto-hide', + 'boolean', flag) + elif position == "bottom": + return gsettings.set('org.mate.panel.toplevel', + '/org/mate/panel/toplevels/bottom/', + 'auto-hide', + 'boolean', flag) + else: + return False + + def get_mate_panel_autohide(self, position): + if position == "top": + return gsettings.get('org.mate.panel.toplevel', + '/org/mate/panel/toplevels/top/', + 'auto-hide', 'boolean') + elif position == "bottom": + return gsettings.get('org.mate.panel.toplevel', + '/org/mate/panel/toplevels/bottom/', + 'auto-hide', 'boolean') + else: + return False + + def get_show_apps(self): + return gsettings.get('org.mate.panel.menubar', + None, + 'show-applications', + 'boolean') + + def set_show_apps(self, flag): + return gsettings.set('org.mate.panel.menubar', + None, + 'show-applications', + 'boolean', flag) + + def get_show_desktop(self): + return gsettings.get('org.mate.panel.menubar', + None, + 'show-desktop', + 'boolean') + + def set_show_desktop(self, flag): + return gsettings.set('org.mate.panel.menubar', + None, + 'show-desktop', + 'boolean', flag) + + def get_show_icon(self): + return gsettings.get('org.mate.panel.menubar', + None, + 'show-icon', + 'boolean') + + def set_show_icon(self, flag): + return gsettings.set('org.mate.panel.menubar', + None, + 'show-icon', + 'boolean', flag) + + def get_show_places(self): + return gsettings.get('org.mate.panel.menubar', + None, + 'show-places', + 'boolean') + + def set_show_places(self, flag): + return gsettings.set('org.mate.panel.menubar', + None, + 'show-places', + 'boolean', flag) + +if __name__ == '__main__': + uuu = Unity() +# print uuu.get_launcher_icon_colouring() +# print uuu.set_launcher_icon_colouring(1) + print uuu.get_time_format() +# bb = uuu.get_default_schema_value("unityshell", "icon_size") +# aa = uuu.get_default_schema_value("unityshell", "launcher_hide_mode") + #aa = uuu.get_default_schema_value('org.gnome.desktop.media-handling', 'automount') + #uuu = Unity("unityshell", "icon_size") + #aa = uuu.get_launcher_icon_size_test() + #print "bb->" + #print bb + #print "aa->" + #print aa + #uuu.set_default_schema_value('icon-size', 'int', bb) +# cc = uuu.get_default_launcher_have_showdesktopicon() +# print cc + + #uuu.set_default_schema_value('launcher-hide-mode', 'int', aa) + + #bb = uuu.get_default_launcher_icon_size() + #print "bb->" + #print bb + #print(type(bb)) + #uuu.reset_default_launcher_icon_size(bb) + #uuu.set_launcher_icon_size(48) + # print uuu.get_launcher_icon_size() + # print uuu.get_launcher_have_showdesktopicon() + # uuu.set_launcher_autohide(0) + # print uuu.get_launcher_autohide() + # uuu.set_launcher_have_showdesktopicon(True) + # uuu.set_launcher_icon_size(48) diff --git a/backends/youker-assistant-daemon/src/beautify/utils.py b/backends/youker-assistant-daemon/src/beautify/utils.py new file mode 100644 index 0000000..e4a8756 --- /dev/null +++ b/backends/youker-assistant-daemon/src/beautify/utils.py @@ -0,0 +1,57 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os + +# get ~ dir +def get_home_dir(): + return os.path.expanduser('~') + +# check dirs with given filters and filtertype +def check_dirs(dirs, filters, filtertype): + result = [] + try: + for onedir in dirs: + if os.path.isdir(onedir): + for f in os.listdir(onedir): + if use_filters(os.path.join(onedir, f), filters, filtertype): + result.append(f) + except: + pass + return result + +# check the fpathdir with filters filtertype: True == include, False == exlude +def use_filters(fpath, filters, filtertype): + # not a directory + if os.path.isdir(fpath) == False: + return False + + if filtertype: + for onefilter in filters: + if os.path.exists(os.path.join(fpath, onefilter)): + continue + else: + return False + return True + else: + for onefilter in filters: + if os.path.exists(os.path.join(fpath, onefilter)): + return False + else: + continue + return True \ No newline at end of file diff --git a/backends/youker-assistant-daemon/src/camera/__init__.py b/backends/youker-assistant-daemon/src/camera/__init__.py new file mode 100644 index 0000000..013e4b7 --- /dev/null +++ b/backends/youker-assistant-daemon/src/camera/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/backends/youker-assistant-daemon/src/camera/capture.py b/backends/youker-assistant-daemon/src/camera/capture.py new file mode 100644 index 0000000..dd38a6a --- /dev/null +++ b/backends/youker-assistant-daemon/src/camera/capture.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# Author: Kobe Lee +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE +#sudo apt-get install python-pygame +import os, sys +import time +import pygame +import pygame.camera +from pygame.locals import * +import threading + +def get_local_format_time(): + ''' + year-month-day hour:minute:second + 2014-05-07 13:51:30 + ''' + local_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + return local_date + +#class Capture(object): +class Capture(threading.Thread): + def __init__(self): + threading.Thread.__init__(self) + pygame.init() + pygame.camera.init() + + def judge_camera(self): + clist = pygame.camera.list_cameras()#['/dev/video0'] + if not clist: + return False +# raise ValueError("Sorry, no cameras detected.") + else: + return True + + def call_camera(self): + threading.Thread(target=self.call_camera_real, name='Capture').start() + + def call_camera_real(self): + self.size = (640,480) + self.clist = pygame.camera.list_cameras()#['/dev/video0'] + self.display = pygame.display.set_mode(self.size, 0) + self.snapshot = pygame.surface.Surface(self.size, 0, self.display) + self.cam = pygame.camera.Camera(self.clist[0], self.size,"RGB") + self.cam.start() + going = True + timevalue = "00-00-00" + while going: + events = pygame.event.get() + for e in events: + if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE): + self.cam.stop() + pic_name = get_local_format_time() + '.png' + print pic_name + going = False + if self.cam.query_image(): + self.snapshot = self.cam.get_image(self.snapshot) + self.display.blit(self.snapshot, (0,0)) + pygame.display.flip() + pic_path = os.path.expanduser('~') + '/' + pic_name + #pic_path = os.path.join('/home/trusty', pic_name) + #os.path.expanduser('~') + #pic_name = '/home/trusty/' + timevalue + '.png' + pygame.image.save(self.snapshot, pic_path) + pygame.quit() + #exit(0) + +#if __name__ == '__main__': +# mycam=Capture() +# if mycam.judge_camera(): +# mycam.call_camera() + diff --git a/backends/youker-assistant-daemon/src/cleaner/__init__.py b/backends/youker-assistant-daemon/src/cleaner/__init__.py new file mode 100644 index 0000000..46ad232 --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/__init__.py @@ -0,0 +1,1059 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import sys +import apt +import apt_pkg +import shutil +import commands +import threading +import ctypes +from apt.progress.base import InstallProgress +import time +import historyclean +import cookiesclean +import searchsame +import diskanalyse +import osslim +import common +import cacheclean +import oldkernel +import systemhistory +import dashhistory +import softwareconfigfile + +HOMEDIR = '' + +def get_user_homedir(homedir): + global HOMEDIR + HOMEDIR = homedir + +def return_homedir_sysdaemon(): + global HOMEDIR + return HOMEDIR + +# clean up by one key +class OneKeyClean(): + def __init__(self): + self.objunneed = CleanTheUnneed() + self.objcache = CleanTheCache() + + def get_onekey_crufts(self, sesdaemon, mode_list): + homedir = common.return_homedir_sesdaemon() + crufts_dic = {} + total_dic = {} + flag_dic = {'history': False, 'cookies': False, 'cache': False} + for mode in mode_list: + flag_dic['%s' % mode] = True + time.sleep(1) + if flag_dic['history']: + historysize = 0 + objhg = historyclean.HistoryClean(homedir) + filepathf = "%s/.mozilla/firefox/%s/places.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + if os.path.exists(filepathf): + tempf_list = objhg.scan_firefox_history_records(filepathf) + for onef in tempf_list: + sesdaemon.display_scan_process(onef[1]) + #sesdaemon.display_scan_process_msg(onef[1]) + historysize += onef[2] + filepathc = "%s/.config/chromium/Default/History" % homedir + if os.path.exists(filepathc): + run = common.process_pid("chromium-browser") + if not run: + tempc_list = objhg.scan_chromium_history_records(filepathc) + for onec in tempc_list: + sesdaemon.display_scan_process(onec[1]) + #sesdaemon.display_scan_process_msg(onec[1]) + historysize += onec[2] + total_dic['history'] = str(historysize) + sesdaemon.total_data_transmit('h', total_dic['history']) + time.sleep(1) + if flag_dic['cookies']: + cookiessize = 0 + objcg = cookiesclean.CookiesClean(homedir) + filepathff = "%s/.mozilla/firefox/%s/cookies.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + if os.path.exists(filepathff): + pamf = [filepathff, 'moz_cookies', 'baseDomain'] + tempff_list = objcg.scan_cookies_records(pamf[0], pamf[1], pamf[2]) + for oneff in tempff_list: + sesdaemon.display_scan_process(oneff[0]) + #sesdaemon.display_scan_process_msg(oneff[0]) + cookiessize += oneff[1] + filepathcc = "%s/.config/chromium/Default/Cookies" % homedir + if os.path.exists(filepathcc): + pamc = [filepathcc, 'cookies', 'host_key'] + tempcc_list = objcg.scan_cookies_records(pamc[0], pamc[1], pamc[2]) + for onecc in tempcc_list: + sesdaemon.display_scan_process(onecc[0]) + #sesdaemon.display_scan_process_msg(onecc[0]) + cookiessize += onecc[1] + total_dic['cookies'] = str(cookiessize) + sesdaemon.total_data_transmit('k', total_dic['cookies']) + time.sleep(1) + if flag_dic['cache']: + cachesize = 0 + objcache = cacheclean.CacheClean() + apt_path = "/var/cache/apt/archives" + temp_apt_list = objcache.scan_apt_cache(apt_path) + for oneapt in temp_apt_list: + sesdaemon.display_scan_process(oneapt) + #sesdaemon.display_scan_process_msg(oneapt) + cachesize += os.path.getsize(oneapt) + swcenterpath = '%s/.cache/software-center' % homedir + temp_swcenter_list = objcache.public_scan_cache(swcenterpath) + for oneswcenter in temp_swcenter_list: + sesdaemon.display_scan_process(oneswcenter) + #sesdaemon.display_scan_process_msg(oneswcenter) + if os.path.isdir(oneswcenter): + cachesize += common.get_dir_size(oneswcenter) + else: + cachesize += os.path.getsize(oneswcenter) + total_dic['cache'] = common.confirm_filesize_unit(cachesize) + sesdaemon.total_data_transmit('c', total_dic['cache']) + + def clean_all_onekey_crufts(self, sysdaemon, mode_list): + homedir = return_homedir_sysdaemon() + flag_dic = {'history': False, 'cookies': False, 'cache': False} + for mode in mode_list: + flag_dic['%s' % mode] = True + #if flag_dic['cache']: + time.sleep(1) + if mode_list[0] in '1': + try: + objclean = FunctionOfClean() + objcache = cacheclean.CacheClean() + apt_path = "/var/cache/apt/archives" + temp_apt_list = objcache.scan_apt_cache(apt_path) + for cachea in temp_apt_list: + sysdaemon.status_for_quick_clean('apt', cachea) + objclean.clean_the_file(cachea) + sysdaemon.status_for_quick_clean('apt', 'end') + + swcenterpath = '%s/.cache/software-center' % homedir + temp_swcenter_list = objcache.public_scan_cache(swcenterpath) + for caches in temp_swcenter_list: + sysdaemon.status_for_quick_clean('software_center', caches) + objclean.clean_the_file(caches) + sysdaemon.status_for_quick_clean('software_center', 'end') + except Exception, e: + sysdaemon.clean_error_onekey('ce') + else: + sysdaemon.clean_complete_onekey('c') + #if flag_dic['history']: + time.sleep(1) + if mode_list[1] in '1': + try: + sysdaemon.status_for_quick_clean('firefoxhistory', 'start') + objca = historyclean.HistoryClean(homedir) + filepathf = "%s/.mozilla/firefox/%s/places.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + objca.clean_firefox_all_records(filepathf) + sysdaemon.status_for_quick_clean('firefoxhistory', 'end') + + run = common.process_pid("chromium-browser") + if not run: + sysdaemon.status_for_quick_clean('chromiumhistory', 'start') + filepathc = "%s/.config/chromium/Default/History" % homedir + objca.clean_chromium_all_records(filepathc) + sysdaemon.status_for_quick_clean('chromiumhistory', 'end') + except Exception, e: + sysdaemon.clean_error_onekey('he') + else: + sysdaemon.clean_complete_onekey('h') + + #if flag_dic['cookies']: + time.sleep(1) + if mode_list[2] in '1': + try: + objcc = cookiesclean.CookiesClean(homedir) + sysdaemon.status_for_quick_clean('firefoxcookies', 'start') + filepathfc = "%s/.mozilla/firefox/%s/cookies.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + pamfc = [filepathfc, 'moz_cookies', 'baseDomain'] + objcc.clean_all_records(pamfc[0], pamfc[1], pamfc[2]) + sysdaemon.status_for_quick_clean('firefoxcookies', 'end') + + sysdaemon.status_for_quick_clean('chromiumcookies', 'start') + filepathcc = "%s/.config/chromium/Default/Cookies" % homedir + pamcc = [filepathcc, 'cookies', 'host_key'] + objcc.clean_all_records(pamcc[0], pamcc[1], pamcc[2]) + sysdaemon.status_for_quick_clean('chromiumcookies', 'end') + except Exception, e: + sysdaemon.clean_error_onekey('ke') + else: + sysdaemon.clean_complete_onekey('k') + sysdaemon.clean_complete_onekey('o') + +# the functions of search the same files +class SearchTheSame(): + def __init__(self): + self.objs = searchsame.SearchSame() + + def get_scan_result(self, path): + self.path = path + self.objs.search_by_style(self.path) + samefile_list = self.objs.adjust_the_dic() + return samefile_list + +# the functions of manage the large files +class ManageTheLarge(): + def __init__(self): + self.objl = diskanalyse.DiskAnalyse() + +# def get_large_files(self, size, path, sesdaemon): +# objlg = diskanalyse.DiskAnalyse() +# finalsize = size * 1024 * 1024 +# largefile_list = objlg.hundred_large_files(finalsize, path) +# for one in largefile_list: +# sesdaemon.data_transmit_by_large(common.confirm_filesize_unit(one[0]), one[1]) +# sesdaemon.large_transmit_complete() + + def get_scan_result(self, size, path): + self.path = path + finalsize = size * 1024 * 1024 + #self.objl.hundred_large_files(finalsize, self.path) + #self.objl.type_of_file() + largefile_dic = self.objl.adjust_the_list(finalsize, self.path) + return largefile_dic + +# the functions of clean the browser history +class CleanTheHistory(): + def __init__(self): + pass + + #def new_get_history_crufts(self, flag, sesdaemon): + # homedir = common.return_homedir_sesdaemon() + # objhg = historyclean.HistoryClean(homedir) + # crufts_list = [] + # cache = common.get_cache_list() + + # if flag in "firefox": + # if cache['firefox'].is_installed: + # filepathf = "%s/.mozilla/firefox/%s/places.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + # if not common.process_pid("firefox"): + # if os.path.exists(filepathf): + # temp_list = objhg.scan_firefox_history_records(filepathf) + # sesdaemon.data_transmit_by_history(sum([sin[2] for sin in temp_list])) + # else: + # sesdaemon.browser_status_by_history('fruning') + # else: + # sesdaemon.history_transmit_complete('funinstall') + # if flag in "chromium": + # if cache['chromium'].is_installed: + # filepathc = "%s/.config/chromium/Default/History" % homedir + # if not common.process_pid("chromium-browser"): + # if os.path.exists(filepathc): + # temp_list = objhg.scan_chromium_history_records(filepathc) + # sesdaemon.data_transmit_by_history(sum([sin[2] for sin in temp_list])) + # else: + # sesdaemon.browser_status_by_history('cruning') + # else: + # sesdaemon.history_transmit_complete('cuninstall') + + def get_history_crufts(self, flag): + homedir = common.return_homedir_sesdaemon() + objhg = historyclean.HistoryClean(homedir) + crufts_list = [] + cache = common.get_cache_list() + + if flag in "firefox": + filepathf = "%s/.mozilla/firefox/%s/places.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + if cache['firefox'].is_installed: + if os.path.exists(filepathf): + temp_list = objhg.scan_firefox_history_records(filepathf) + crufts_list = ["%s<2_2>%s<2_2>%s" % (str(each[0]), each[1], str(each[2])) for each in temp_list] + else: + return 'No' + if flag in "chromium": + filepathc = "%s/.config/chromium/Default/History" % homedir + if cache['chromium-browser'].is_installed: + if os.path.exists(filepathc): + run = common.process_pid("chromium-browser") + if not run: + temp_list = objhg.scan_chromium_history_records(filepathc) + crufts_list = ["%s<2_2>%s<2_2>%s" % (str(each[0]), each[1], str(each[2])) for each in temp_list] + else: + return 'True' + else: + return 'No' + return crufts_list + + def clean_all_history_crufts(self, flag): + homedir = return_homedir_sysdaemon() + objca = historyclean.HistoryClean(homedir) + running = False + + if flag in "firefox": + filepathf = "%s/.mozilla/firefox/%s/places.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + objca.clean_firefox_all_records(filepathf) + if flag in "chromium": + run = common.process_pid("chromium-browser") + if not run: + filepathc = "%s/.config/chromium/Default/History" % homedir + objca.clean_chromium_all_records(filepathc) + else: + running = True + return running + +# the function of clean the system history +class CleanSystemHistory(): + def get_scan_result(self, homedir = ''): + objhg = systemhistory.SystemHistory() + url = objhg.scan_the_xml(homedir) + return url + + def clean_the_cruftlist(self): + global HOMEDIR + objhc = systemhistory.SystemHistory() + objhc.clean_the_xml(HOMEDIR) + + +# the function of clean the dash history +class CleanDashHistory(): + def get_scan_result(self, homedir = ''): + objhg = dashhistory.DashHistory(homedir) + num = objhg.scan_the_records() + return num + + def clean_the_cruftlist(self): + global HOMEDIR + objhc = dashhistory.DashHistory(HOMEDIR) + objhc.clean_the_records() + +# the function of clean the cookies +class CleanTheCookies(): + def __init__(self, daemon_obj): + self.daemon_obj = daemon_obj + + def get_cookie_crufts(self, flag, sesdaemon): + homedir = common.return_homedir_sesdaemon() + objcg = cookiesclean.CookiesClean(homedir) + cache = common.get_cache_list() + crufts_list = [] + + if flag in "firefox": + if cache["firefox"].is_installed: + filepathf = "%s/.mozilla/firefox/%s/cookies.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + if os.path.exists(filepathf): + pamf = [filepathf, 'moz_cookies', 'baseDomain'] + temp_firefox_list = objcg.scan_cookies_records(pamf[0], pamf[1], pamf[2]) + for one in temp_firefox_list: + sesdaemon.data_transmit_by_cookies("firefox", one[0], str(one[-1])) + sesdaemon.cookies_transmit_complete('firefox') + else: + sesdaemon.cookies_transmit_complete('funinstall') + + if flag in "chromium": + if cache["chromium-browser"].is_installed: + filepathc = "%s/.config/chromium/Default/Cookies" % homedir + if os.path.exists(filepathc): + pamc = [filepathc, 'cookies', 'host_key'] + temp_chromium_list = objcg.scan_cookies_records(pamc[0], pamc[1], pamc[2]) + for one in temp_chromium_list: + sesdaemon.data_transmit_by_cookies("chromium", one[0], str(one[-1])) + sesdaemon.cookies_transmit_complete('chromium') + else: + sesdaemon.cookies_transmit_complete('cuninstall') + + def get_cookies_crufts(self, flag): + homedir = common.return_homedir_sesdaemon() + objcg = cookiesclean.CookiesClean(homedir) + crufts_list = [] + + if flag in "firefox": + filepathf = common.analytical_profiles_file(homedir) + "cookies.sqlite" + if os.path.exists(filepathf): + pamf = [filepathf, 'moz_cookies', 'baseDomain'] + temp_list = objcg.scan_cookies_records(pamf[0], pamf[1], pamf[2]) + crufts_list = ["%s<2_2>%s" % (eachone[0], str(eachone[-1])) for eachone in temp_list] + else: + crufts_list.append('None') + return crufts_list + if flag in "chromium": + filepathc = "%s/.config/chromium/Default/Cookies" % homedir + if os.path.exists(filepathc): + pamc = [filepathc, 'cookies', 'host_key'] + temp_list = objcg.scan_cookies_records(pamc[0], pamc[1], pamc[2]) + crufts_list = ["%s<2_2>%s" % (eachone[0], str(eachone[-1])) for eachone in temp_list] + else: + crufts_list.append('None') + return crufts_list + + return crufts_list + + def clean_one_cookies_cruft(self, flag, domain): + homedir = return_homedir_sysdaemon() + objcc = cookiesclean.CookiesClean(homedir) + + if flag in "firefox": + filepathf = "%s/.mozilla/firefox/%s/cookies.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + pamf = [filepathf, 'moz_cookies', 'baseDomain', domain] + objcc.clean_cookies_record(pamf[0], pamf[1], pamf[2], pamf[3]) + if flag in "chromium": + filepathc = "%s/.config/chromium/Default/Cookies" % homedir + pamc = [filepathc, 'cookies', 'host_key', domain] + objcc.clean_cookies_record(pamc[0], pamc[1], pamc[2], pamc[3]) + + def clean_all_cookies_crufts(self, flag): + homedir = return_homedir_sysdaemon() + objcc = cookiesclean.CookiesClean(homedir) + + if flag in "firefox": + filepathf = "%s/.mozilla/firefox/%s/cookies.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + pamf = [filepathf, 'moz_cookies', 'baseDomain'] + objcc.clean_all_records(pamf[0], pamf[1], pamf[2]) + if flag in "chromium": + filepathc = "%s/.config/chromium/Default/Cookies" % homedir + pamc = [filepathc, 'cookies', 'host_key'] + objcc.clean_all_records(pamc[0], pamc[1], pamc[2]) + +# the function of scan the unneedpackages +class CleanTheUnneed(): + def __init__(self): + self.objc = osslim.OsSlim() + + def get_scan_result(self): + namesummarysize = self.objc.get_spare_packages() + return namesummarysize + +# the function of clean old kernel +class CleanTheOldkernel(): + def __init__(self): + pass + + def get_oldkernel_crufts(self): + objc = oldkernel.OldKernel() + pkgobj_list = objc.scan_oldkernel_packages() + crufts_list = ["%s<2_2>%s" % (pkg.name, pkg.installed.summary, common.confirm_filesize_unit(pkg.installed.installed_size))for pkg in pkgobj_list] + return crufts_list + +# the function of clean spare packages +class CleanTheSpare(): + def __init__(self): + pass + + def get_all_package_crufts(self, mode_list, sesdaemon): + if 'unneed' in mode_list: + upkg_obj = osslim.OsSlim() + temp_unneed_list = upkg_obj.scan_spare_packages() + for upkg in temp_unneed_list: + sesdaemon.data_transmit_by_package('unneed', upkg.name, upkg.installed.summary, common.confirm_filesize_unit(upkg.installed.installed_size)) + + if 'oldkernel' in mode_list: + opkg_obj = oldkernel.OldKernel() + temp_oldkernel_list = opkg_obj.scan_oldkernel_packages() + for opkg in temp_oldkernel_list: + sesdaemon.data_transmit_by_package('oldkernel', opkg.name, opkg.installed.summary, common.confirm_filesize_unit(opkg.installed.installed_size)) + + if 'configfile' in mode_list: + spkg_obj = softwareconfigfile.SoftwareConfigfile() + temp_configfile_list = spkg_obj.scan_configfile_packages() + for spkg in temp_configfile_list: + sesdaemon.data_transmit_by_package('configfile', spkg.name, '', '') + sesdaemon.package_transmit_complete() + +# the function of scan the cache +class CleanTheCache(): + def __init__(self): + self.objc = cacheclean.CacheClean() + + def get_all_cache_crufts(self, mode_list, flag, sesdaemon): + homedir = common.return_homedir_sesdaemon() + + if 'apt' in mode_list: + aptpath = "/var/cache/apt/archives" + temp_apt_list = self.objc.scan_apt_cache(aptpath) + for one in temp_apt_list: + sesdaemon.data_transmit_by_cache('apt', one, 'False', '%s' % common.confirm_filesize_unit(os.path.getsize(one))) + + if 'software-center' in mode_list: + softwarecenterpath = "%s/.cache/software-center" % homedir + temp_softwarecenter_list = self.objc.public_scan_cache(softwarecenterpath) + for one in temp_softwarecenter_list: + if os.path.isdir(one): + sesdaemon.data_transmit_by_cache('software-center', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one))) + else: + sesdaemon.data_transmit_by_cache('software-center', one, 'False', common.confirm_filesize_unit(os.path.getsize(one))) + + if 'thumbnails' in mode_list: + thumbnailspath = "%s/.cache/thumbnails" % homedir + temp_thumbnails_list = self.objc.public_scan_cache(thumbnailspath) + for one in temp_thumbnails_list: + if os.path.isdir(one): + sesdaemon.data_transmit_by_cache('thumbnails', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one))) + else: + sesdaemon.data_transmit_by_cache('thumbnails', one, 'False',common.confirm_filesize_unit(os.path.getsize(one))) + if 'firefox' in mode_list: + firefoxpath = "%s/.cache/mozilla/firefox/%s" % (homedir, common.analytical_profiles_file(homedir)) + #sesdaemon.path_transmit_by_cache('firefox', firefoxpath) + temp_firefox_list = self.objc.firefox_scan_cache(firefoxpath) + for one in temp_firefox_list: + if os.path.isdir(one): + sesdaemon.data_transmit_by_cache('firefox', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one))) + else: + sedaemon.data_transmit_by_cache('firefox', one, 'False', common.confirm_filesize_unit(os.path.getsize(one))) + if 'chromium' in mode_list: + chromiumpath = "%s/.cache/chromium/Default" % homedir + #sesdaemon.path_transmit_by_cache('chromium', chromiumpath) + temp_chromium_list = self.objc.public_scan_cache(chromiumpath) + for one in temp_chromium_list: + if os.path.isdir(one): + sesdaemon.data_transmit_by_cache('chromium', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one))) + else: + sesdaemon.data_transmit_by_cache('chromium', one, 'False',common.confirm_filesize_unit(os.path.getsize(one))) + + sesdaemon.cache_transmit_complete(flag) + +# the function of clean cruft files and cruft packages +#class FunctionOfClean(threading.Thread): +class FunctionOfClean(): + def __init__(self): + #threading.Thread.__init__(self) + #self.msgdaemon = msgdaemon + pass + + def clean_the_file(self, cruft): + tmp = cruft.encode("UTF-8") + #sysdaemon.data_of_remove_file(tmp) + if tmp: + if os.path.isdir(tmp): + shutil.rmtree(tmp) + else: + os.remove(tmp) + + #def clean_the_file(self, cruftlist): + # threading.Thread(target=self.clean_the_file_thread, args=(cruftlist,), name='CleanFile').start() + + def clean_the_package(self, cruftlist, sysdaemon): + if cruftlist: + cache = common.get_cache_list() + cache.open() + for cruft in cruftlist: + pkg = cache[cruft] + if pkg.is_installed: + pkg.mark_delete() + else: + pkg.mark_delete(purge=True) + iprogress = MyInstallProgress(sysdaemon) + cache.commit(None, iprogress) + + def purge_the_package(self, cruftlist, sysdaemon): + if cruftlist: + cache = common.get_cache_list() + cache.open() + for cruft in cruftlist: + pkg = cache[cruft] + pkg.mark_delete(purge=True) + iprogress = MyInstallProgress(sysdaemon) + cache.commit(None, iprogress) + + #def clean_the_package(self, cruftlist): + # threading.Thread(target=self.clean_the_package_thread, args=(cruftlist,), name='CleanPackage').start() + +class MyInstallProgress(InstallProgress): + def __init__(self, sysdaemon): + InstallProgress.__init__(self) + self.sysdaemon = sysdaemon + + def status_change(self, pkg, percent, status): + self.sysdaemon.status_remove_packages("apt_pulse", "percent: %s, status: %s" % (str(int(percent)), status)) + + def error(self, errorstr): + pass + + def finish_update(self): + self.sysdaemon.status_remove_packages("apt_stop", "") + + def start_update(self): + self.sysdaemon.status_remove_packages("apt_start", "") + +def cancel_mainpage_function(target_tid, exception): + pass + #found = False + #target_tid = 0 + #for tid, tobj in threading._active.items(): + # if tobj is thread_obj: + # found = True + # target_tid = tid + # break + #if not found: + # raise ValueError("Invalid thread object") +# res = ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(target_tid), ctypes.py_object(exception)) + +# if res = 0: +# raise ValueError("Invalid thread ID") +# elif res > 1: +# ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(target_tid), None) +# raise SystemError("PyThreadState_SetAsyncExc failed") + +def get_threadid(thread_obj): + found = False + target_tid = 0 + for tid, tobj in threading._active.items(): + if tobj is thread_obj: + found = True + target_tid = tid + break + if not found: + raise ValueError("Invalid thread object") + return target_tid + + +class MainPage(): + def __init__(self): + pass + + def get_cache(self, sesdaemon): + flag = False + totalsize = 0 + homedir = '' + cache_obj = cacheclean.CacheClean() + if sesdaemon: + homedir = common.return_homedir_sesdaemon() + else: + homedir = return_homedir_sysdaemon() + + self.cache_dic = {'apt':[], 'softwarecenter':[], 'thumbnail':[]} + aptpath = "/var/cache/apt/archives" + temp_apt_list = cache_obj.scan_apt_cache(aptpath) + if sesdaemon: + for one in temp_apt_list: + self.cache_dic['apt'].append(one) + totalsize += common.get_size(one) + sesdaemon.check_scan_garbage_process(one) + else: + for one in temp_apt_list: + self.cache_dic['apt'].append(one) + softwarecenterpath = "%s/.cache/software-center" % homedir + temp_softwarecenter_list = cache_obj.public_scan_cache(softwarecenterpath) + if sesdaemon: + for one in temp_softwarecenter_list: + self.cache_dic['softwarecenter'].append(one) + totalsize += common.get_size(one) + sesdaemon.check_scan_garbage_process(one) + else: + for one in temp_softwarecenter_list: + self.cache_dic['softwarecenter'].append(one) + thumbnailspath = "%s/.cache/thumbnails" % homedir + try: + temp_thumbnails_list = cache_obj.public_scan_cache(thumbnailspath) + except Exception, e: + print e + if sesdaemon: + for one in temp_thumbnails_list: + self.cache_dic['thumbnail'].append(one) + totalsize += common.get_size(one) + sesdaemon.check_scan_garbage_process(one) + else: + for one in temp_thumbnails_list: + self.cache_dic['thumbnail'].append(one) + if sesdaemon: + for key in self.cache_dic.keys(): + if self.cache_dic[key]: + flag = True + break + if flag: + sesdaemon.scan_complete('True') + else: + sesdaemon.scan_complete('False') + size_str = common.confirm_filesize_unit(totalsize) + sesdaemon.check_scan_complete(size_str) + else: + pass + + def clean_cache(self, sysdaemon): + totalsize = 0 + self.get_cache(None) + for key in self.cache_dic.keys(): + for f in self.cache_dic[key]: + totalsize += common.get_size(f) + if os.path.isdir(f): + sysdaemon.info_for_mainpage_clean(f) + shutil.rmtree(f) + else: + sysdaemon.info_for_mainpage_clean(f) + os.remove(f) + size_str = common.confirm_filesize_unit(totalsize) + sysdaemon.mainpage_clean(size_str) +#----------------------------NEW YOUKER-------------------- + +#---------------------SubPage--------------------- + +def append_cacheinfo_to_list(belong, path): + info = [] + info.append('Belong:%s' % belong) + info.append('Path:%s' % path) + if os.path.isdir(path): + info.append('Type:directory') + info.append('Size:%s' % common.confirm_filesize_unit(common.get_dir_size(path))) + else: + info.append('Type:file') + info.append('Size:%s' % common.confirm_filesize_unit(os.path.getsize(path))) + + return info + +def interface_get_subpage_session(session, mode_dic): + homedir = common.return_homedir_sesdaemon() + + cache = mode_dic.get('Cache', []) + if cache: + cache_obj = cacheclean.CacheClean() + if 'apt' in cache: + aptpath = "/var/cache/apt/archives" + apt_list = cache_obj.scan_apt_cache(aptpath) + for value in apt_list: + info = append_cacheinfo_to_list('Cache.apt', value) + + session.subpage_data_signal(info) + #else: + #info = [] + #info.append('Belong:Cache.apt') + #info.append('') + #session.subpage_data_signal(info) + + if 'software-center' in cache: + swcenterpath = "%s/.cache/software-center" % homedir + swcenter_list = cache_obj.public_scan_cache(swcenterpath) + for value in swcenter_list: + info = append_cacheinfo_to_list('Cache.software-center', value) + session.subpage_data_signal(info) + #else: + #info = [] + #info.append('Belong:Cache-apt') + #info.append('') + #session.subpage_data_signal(info) + + if 'thumbnails' in cache: + thumbnailspath = "%s/.cache/thumbnails" % homedir + thumbnails_list = cache_obj.public_scan_cache(thumbnailspath) + for value in thumbnails_list: + info = append_cacheinfo_to_list('Cache.thumbnails', value) + session.subpage_data_signal(info) + #else: + #info = [] + #info.append('Belong:Cache.thumbnails') + #info.append('') + #session.subpage_data_signal(info) + + + if 'firefox' in cache: + firefoxpath = "%s/.cache/mozilla/firefox/%s" % (homedir, common.analytical_profiles_file(homedir)) + firefox_cache_list = cache_obj.firefox_scan_cache(firefoxpath) + for value in firefox_cache_list: + info = append_cacheinfo_to_list('Cache.firefox', value) + session.subpage_data_signal(info) + #else: + #info = [] + #info.append('Belong:Cache.firefox') + #info.append('') + #session.subpage_data_signal(info) + + if 'chromium' in cache: + chromiumpath = "%s/.cache/chromium/Default" % homedir + chromium_cache_list = cache_obj.public_scan_cache(chromiumpath) + for value in chromium_cache_list: + info = append_cacheinfo_to_list('Cache.chromium', value) + session.subpage_data_signal(info) + #else: + #info = [] + #info.append('Belong:Cache.chromium') + #info.append('') + #session.subpage_data_signal(info) + + session.subpage_status_signal('Complete:Cache') + + cookies = mode_dic.get('Cookies', []) + if cookies: + cache = common.get_cache_list() + cookies_obj = cookiesclean.CookiesClean(homedir) + + + if 'firefox' in cookies: + if cache['firefox'].is_installed: + ffcpath = "%s/.mozilla/firefox/%s/cookies.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + if os.path.exists(ffcpath): + ffcpam = [ffcpath, 'moz_cookies', 'baseDomain'] + firefox_cookies_list = cookies_obj.scan_cookies_records(ffcpam[0], ffcpam[1], ffcpam[2]) + + for value in firefox_cookies_list: + info = [] + info.append('Belong:Cookies.firefox') + info.append('Content:%s' % value[0]) + info.append('Count:%s' % str(value[-1])) + session.subpage_data_signal(info) + + else: + info = [] + info.append('Belong:Cookies.firefox') + info.append('') + session.subpage_data_signal(info) + else: + session.subpage_error_signal('Uninstalled:Firefox') + + + if 'chromium' in cookies: + try: + pkg = cache['chromium-browser'] + except KeyError: + pass + else: + if pkg.is_installed: + chcpath = "%s/.config/chromium/Default/Cookies" % homedir + if os.path.exists(chcpath): + chcpam = [chcpath, 'cookies', 'host_key'] + chromium_cookies_list = cookies_obj.scan_cookies_records(chcpam[0], chcpam[1], chcpam[2]) + for value in chromium_cookies_list: + info = [] + info.append('Belong:Cookies.chromium') + info.append('Content:%s' % value[0]) + info.append('Count:%s' % str(value[-1])) + session.subpage_data_signal(info) + else: + info = [] + info.append('Belong:Cookies.chromium') + info.append('') + session.subpage_data_signal(info) + else: + session.subpage_error_signal('Uninstalled:Chromium') + session.subpage_status_signal('Complete:Cookies') + + + history = mode_dic.get('History', []) + if history: + cache = common.get_cache_list() + brohistory_obj = historyclean.HistoryClean(homedir) + + if 'firefox' in history: + if cache['firefox'].is_installed: + ffhpath = "%s/.mozilla/firefox/%s/places.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + if os.path.exists(ffhpath): + firefox_history_list = brohistory_obj.scan_firefox_history_records(ffhpath) + #for single in firefox_history_list: + # info = [] + # info.append('Belong:History.firefox') + # info.append('Id:%s' % str(single[0])) + # info.append('Url:%s' % single[1]) + # info.append('Count:%s' % str(single[2])) + # session.subpage_data_signal(info) + info = [] + info.append('Belong:History.firefox') + info.append('Count:%s' % str(len(firefox_history_list))) + session.subpage_data_signal(info) + else: + info = [] + info.append('Belong:History.firefox') + info.append('') + session.subpage_data_signal(info) + + else: + session.subpage_error_signal('Uninstalled:Firefox') + + if 'chromium' in history: + chhpath = "%s/.config/chromium/Default/History" % homedir + try: + pkg = cache['chromium-browser'] + except KeyError: + pass + else: + if pkg.is_installed: + run = common.process_pid("chromium-browser") + if not run: + chromium_history_list = brohistory_obj.scan_chromium_history_records(chhpath) + #for single in chromium_history_list: + # info = [] + # info.append('Belong:History.chromium') + # info.append('Id:%s' % str(single[0])) + # info.append('Url:%s' % single[1]) + # info.append('Count:%s' % str(single[2])) + # session.subpage_data_signal(info) + info = [] + info.append('Belong:History.chromium') + info.append('Count:%s' % str(len(chromium_history_list))) + session.subpage_data_signal(info) + else: + session.subpage_error_signal('Working:Chromium') + else: + session.subpage_error_signal('Uninstalled:Chromium') + if 'bash' in history: + path = os.path.join(homedir, ".bash_history") + size = 0 + if os.path.exists(path): + size = common.confirm_filesize_unit(os.path.getsize(path)) + info = [] + info.append('Belong:History.bash') + info.append('Size:%s' % str(size)) + info.append('Path:%s' % path) + session.subpage_data_signal(info) + else: + pass + + + if 'X11' in history: + x11_list = [os.path.join(homedir, x) for x in os.listdir(homedir) if x.startswith(".xsession-errors")] + for value in x11_list: + info = append_cacheinfo_to_list('History.X11', value) + session.subpage_data_signal(info) + + if 'system' in history: + syshistory_obj = systemhistory.SystemHistory() + url_list = syshistory_obj.scan_the_xml(homedir) + #for value in url_list: + # info = [] + # info.append('Belong:History.system') + #info.append('Count:%s' % len(url_list)) + # info.append('Href:%s' % value) + # session.subpage_data_signal(info) + info = [] + info.append('Belong:History.system') + info.append('Count:%s' % str(len(url_list))) + session.subpage_data_signal(info) + session.subpage_status_signal('Complete:History') + + packages = mode_dic.get('Packages', []) + if packages: + if 'unneed' in packages: + unneed_obj = osslim.OsSlim() + + unneed_packages_list = unneed_obj.get_unneed_packages() + for value in unneed_packages_list: + info = value.split(";") + info.insert(0, 'Belong:Packages.unneed') + session.subpage_data_signal(info) + + if 'oldkernel' in packages: + oldkernel_obj = oldkernel.OldKernel() + + oldkernel_list = oldkernel_obj.get_oldkernel_packages() + for value in oldkernel_list: + info = value.split(";") + info.insert(0, 'Belong:Packages.oldkernel') + session.subpage_data_signal(info) + + if 'configfile' in packages: + configfile_obj = softwareconfigfile.SoftwareConfigfile() + + configfile_list = configfile_obj.get_configfile_packages() + for value in configfile_list: + info = value.split(";") + info.insert(0, 'Belong:Packages.configfile') + session.subpage_data_signal(info) + session.subpage_status_signal('Complete:Packages') + session.subpage_status_signal('Complete:All') + + +def interface_remove_file_system(system, fp): + filepath = fp.encode("UTF-8") + if os.path.exists(fp): + info = [] + if os.path.isdir(filepath): + info.append('Path:%s' % filepath) + info.append('Size:%s' % common.confirm_filesize_unit(common.get_dir_size(filepath))) + shutil.rmtree(filepath) + system.subpage_data_signal(info) + else: + info.append('Path:%s' % filepath) + info.append('Size:%s' % common.confirm_filesize_unit(os.path.getsize(filepath))) + os.remove(filepath) + system.subpage_data_signal(info) + else: + system.subpage_error_signal('Non-existent:%s' % filepath) + +def interface_remove_firefox_history_system(system): + homedir = return_homedir_sysdaemon() + firefox_history_obj = historyclean.HistoryClean(homedir) + + ffhpath = "%s/.mozilla/firefox/%s/places.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + firefox_history_obj.clean_firefox_all_records(ffhpath) + + system.subpage_status_signal('Complete:History.firefox', 'history') + +def interface_remove_system_history_system(system): + homedir = return_homedir_sysdaemon() + system_history_obj = systemhistory.SystemHistory() + system_history_obj.clean_the_xml(homedir) + system.subpage_status_signal('Complete:History.system', 'history') + +def interface_remove_chromium_history_system(system): + homedir = return_homedir_sysdaemon() + chromium_history_obj = historyclean.HistoryClean(homedir) + + run = common.process_pid("chromium-browser") + if not run: + chhpath = "%s/.config/chromium/Default/History" % homedir + chromium_history_obj.clean_chromium_all_records(chhpath) + system.subpage_status_signal('Complete:History.chromium', 'history') + else: + system.subpage_error_signal('Working:Chromium') + +def interface_remove_firefox_cookies_system(system, domain): + homedir = return_homedir_sysdaemon() + firefox_cookies_obj = cookiesclean.CookiesClean(homedir) + #print(domain) + + ffcpath = "%s/.mozilla/firefox/%s/cookies.sqlite" % (homedir, common.analytical_profiles_file(homedir)) + ffcpam = [ffcpath, 'moz_cookies', 'baseDomain', domain] + firefox_cookies_obj.clean_cookies_record(ffcpam[0], ffcpam[1], ffcpam[2], ffcpam[3]) + system.subpage_status_signal('Complete:Cookies.firefox', domain) + +def interface_remove_chromium_cookies_system(system, domain): + homedir = return_homedir_sysdaemon() + chromium_cookies_obj = cookiesclean.CookiesClean(homedir) + + chcpath = "%s/.config/chromium/Default/Cookies" % homedir + chcpam = [chcpath, 'cookies', 'host_key', domain] + chromium_cookies_obj.clean_cookies_record(chcpam[0], chcpam[1], chcpam[2], chcpam[3]) + system.subpage_status_signal('Complete:Cookies.chromium', domain) + + +def interface_remove_package_system(system, packagename): + if packagename: + cache = common.get_cache_list() + cache.open() + try: + pkg = cache[packagename] + except KeyError: + system.subpage_error_signal('Non-existent:%s' % packagename) + if pkg.is_installed: + pkg.mark_delete() + else: + pkg.mark_delete(purge=True) + iprogress = NewInstallProgress(system) + cache.commit(None, iprogress) + +class NewInstallProgress(InstallProgress): + def __init__(self, system): + InstallProgress.__init__(self) + self.system = system + + def status_change(self, pkg, percent, status): + #self.system.status_remove_packages("apt_pulse", "percent: %s, status: %s" % (str(int(percent)), status)) + info = [] + info.append('Pkg:%s' % pkg) + info.append('Percent:%s' % str(int(percent))) + info.append('Status:%s' % status) + self.system.subpage_data_signal(info) + #self.system.subpage_status_signal(info, 'apt') + + def error(self, errorstr): + pass + + def finish_update(self): + #self.system.status_remove_packages("apt_stop", "") + self.system.subpage_status_signal('Complete:', 'apt') + + def start_update(self): + #self.system.status_remove_packages("apt_start", "") + self.system.subpage_status_signal('Start:', 'apt') diff --git a/backends/youker-assistant-daemon/src/cleaner/cacheclean.py b/backends/youker-assistant-daemon/src/cleaner/cacheclean.py new file mode 100644 index 0000000..e30adca --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/cacheclean.py @@ -0,0 +1,56 @@ +import os +from common import get_dir_size +from common import confirm_filesize_unit + + +class CacheClean(): + def __init__(self): + pass + + def get_apt_cache(self): + apt_cache = '/var/cache/apt/archives' + #aptcachelist = map(lambda filename: '%s/%s<2_2>%s' % (apt_cache, filename, str(os.path.getsize('%s/%s' % (apt_cache, filename)))), filter(lambda filestr: filestr.endswith('deb'), os.listdir(apt_cache))) + aptcachelist = ['%s/%s<2_2>%s' % (apt_cache,filename, confirm_filesize_unit(os.path.getsize('%s/%s' % (apt_cache, filename)))) for filename in os.listdir(apt_cache) if filename.endswith('deb')] + return aptcachelist + + def scan_apt_cache(self, path): + aptcache_list = [] + if os.path.exists(path): + aptcache_list = ['%s/%s' % (path, filename) for filename in os.listdir(path) if filename.endswith('deb')] + + return aptcache_list + + def public_scan_cache(self, path): + publiccache_list = [] + if os.path.exists(path): + publiccache_list = ['%s/%s' % (path, filename) for filename in os.listdir(path)] + + return publiccache_list + + def firefox_scan_cache(self, path): + firefoxcache_list = [] + if os.path.exists(path): + firefoxcache_list = ['%s/%s' % (path, filename) for filename in os.listdir(path) if filename in 'Cache'] + return firefoxcache_list + + def get_softwarecenter_cache(self, homedir): + centercachelist = [] + if homedir: + softwarecenter_cache = '%s/.cache/software-center/' % homedir + else: + softwarecenter_cache = os.path.expanduser('~/.cache/software-center/') + full_path = softwarecenter_cache + if os.path.exists(full_path): + for one in os.listdir(full_path): + tmp_path = full_path + one + if os.path.isdir(tmp_path): + size = get_dir_size(tmp_path) + centercachelist.append('%s<2_2>%s' % (tmp_path, confirm_filesize_unit(size))) + else: + centercachelist.append('%s<2_2>%s' % (tmp_path, confirm_filesize_unit(os.path.getsize(tmp_path)))) + return centercachelist + +if __name__ == "__main__": + obja = CacheClean() + obja.get_apt_cache() + obja.get_softwarecenter_cache() diff --git a/backends/youker-assistant-daemon/src/cleaner/common.py b/backends/youker-assistant-daemon/src/cleaner/common.py new file mode 100644 index 0000000..fda7733 --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/common.py @@ -0,0 +1,159 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import ConfigParser +import apt +import apt_pkg +import psutil +import re + +HOMEDIR = '' + +def confirm_filesize_unit(size): + unit_list = ['B', 'KB', 'MB', 'GB', 'TB'] + flag = 0 + while True: + if size > 512: + size /= 1024.0 + flag += 1 + else: break + tmp = "%.2f" % size + finalsize = tmp + ' ' + unit_list[flag] + return finalsize + +def get_dir_size(path): + size = 0L + for root, dirs, files in os.walk(path): + size += sum([os.path.getsize(os.path.join(root, name)) for name in files]) + return size + +def process_pid(pname): + pid = None + processinfo = psutil.process_iter() + for one in processinfo: + one_str = str(one) + patt = re.compile(pname, re.I) + if patt.search(one_str): + pid = int(one_str.split('pid=')[1].split(',')[0]) + return pid + +def get_cache_list(): + cache = None + #apt_pkg.InitConfig() + #apt_pkg.InitSystem() + apt_pkg.init_config() + apt_pkg.init_system() + cache = apt.Cache() + return cache + +#def get_homedir_sysdaemon(homedir): +# global HOMEDIR +# HOMEDIR = homedir + +def return_homedir_sysdaemon(): + global HOMEDIR + return HOMEDIR + +def return_homedir_sesdaemon(): + return os.path.expanduser('~') + +def analytical_profiles_file(homedir): + count = 0 + tmp_pro_section = [] + flag_pro_section = '' + finalpath = '' + + app_path = '%s/.mozilla/firefox' % homedir + profiles_path = '%s/profiles.ini' % app_path + if os.path.exists(profiles_path): + cfg = ConfigParser.ConfigParser() + cfg.read(profiles_path) + complete_section = cfg.sections() + for section in complete_section: + if section.startswith('Profile'): + tmp_pro_section.append(section) + complete_option = cfg.options(section) + try: + cfg.getint(section, 'Default') == 1 + except Exception, e: + pass + else: + flag_pro_section = section + count += 1 + if cfg.getint('General', 'StartWithLastProfile'): + if count == 1: + if cfg.getint(tmp_pro_section[0], 'IsRelative') == 0: + finalpath = cfg.get(tmp_pro_section[0], 'Path').split('/')[-1] + else: + finalpath = cfg.get(tmp_pro_section[0], 'Path') + elif count > 1 : + if cfg.getint(flag_pro_section, 'IsRelative') == 0: + finalpath = cfg.get(flag_pro_section, 'Path').split('/')[-1] + else: + finalpath = cfg.get(flag_pro_section, 'Path') + else: + pass + else: + pass + return finalpath + +def get_mozilla_path(homedir): + count = 0 + tmp_pro_section = [] + if homedir: + app_path = '%s/.mozilla/firefox' % homedir + else: + app_path = os.path.expanduser('~/.mozilla/firefox') + flag_pro_section = '' + finalpath = '' + + profiles_path = '%s/profiles.ini' % app_path + if os.path.exists(profiles_path): + cfg = ConfigParser.ConfigParser() + cfg.read(profiles_path) + complete_section = cfg.sections() + for section in complete_section: + if section.startswith('Profile'): + tmp_pro_section.append(section) + complete_option = cfg.options(section) + try: + cfg.getint(section, 'Default') == 1 + except Exception, e: + pass + else: + flag_pro_section = section + count += 1 + if cfg.getint('General', 'StartWithLastProfile'): + if count == 1: + if cfg.getint(tmp_pro_section[0], 'IsRelative') == 0: + finalpath = cfg.get(tmp_pro_section[0], 'Path') + else: + finalpath = os.path.expanduser('%s/%s/' % (app_path, cfg.get(tmp_pro_section[0], 'Path'))) + elif count > 1 : + if cfg.getint(flag_pro_section, 'IsRelative') == 0: + finalpath = cfg.get(flag_pro_section, 'Path') + else: + finalpath = os.path.expanduser('%s/%s/' % (app_path, cfg.get(flag_pro_section, 'Path'))) + else: + raise Exception('profile.ini has error!') + else: + pass + return finalpath + +if __name__ == '__main__': + print analytical_profiles_file('/home/aya') diff --git a/backends/youker-assistant-daemon/src/cleaner/cookiesclean.py b/backends/youker-assistant-daemon/src/cleaner/cookiesclean.py new file mode 100644 index 0000000..0dd1556 --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/cookiesclean.py @@ -0,0 +1,102 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os.path +import sqlite3 + +from common import get_mozilla_path + + +class CookiesClean(): + def __init__(self, homedir): + self.filename = 'cookies.sqlite' + self.path = get_mozilla_path(homedir) + + def scan_the_records(self): + save = [] + if os.path.exists(self.path): + scan_browser_conn = sqlite3.connect(self.path + self.filename) + scan_browser_cur = scan_browser_conn.cursor() + sql_select = 'SELECT baseDomain, count(*) FROM moz_cookies GROUP BY baseDomain' + scan_browser_cur.execute(sql_select) + for eachvisit in scan_browser_cur.fetchall(): + tmp = list(eachvisit) + tmp[-1] = str(tmp[-1]) + tmp_str = '<2_2>'.join(tmp) + save.append(tmp_str) + scan_browser_cur.close() + scan_browser_conn.close() + return save + + def scan_cookies_records(self, filepath, tablename, keyname): + result = [] + if os.path.exists(filepath): + scan_browser_conn = sqlite3.connect(filepath) + scan_browser_cur = scan_browser_conn.cursor() + sql_select = 'SELECT %s, count(*) FROM %s GROUP BY %s' % (keyname, tablename, keyname) + scan_browser_cur.execute(sql_select) + result = scan_browser_cur.fetchall() + scan_browser_cur.close() + scan_browser_conn.close() + #result = ["%s<2_2>%s" % (eachone[0], str(eachone[-1])) for eachone in allvisit] + return result + + def clean_cookies_record(self, filepath, tablename, keyname, domain): + if os.path.exists(filepath): + clean_browser_conn = sqlite3.connect(filepath) + clean_browser_cur = clean_browser_conn.cursor() + #sql_exist = "SELECT * FROM %s WHERE %s='%s'" % (tablename, keyname, domain) + #clean_browser_cur.execute(sql_exist) + #if clean_browser_cur.fetchone(): + sql_delete = "DELETE FROM %s WHERE %s='%s'" % (tablename, keyname, domain) + clean_browser_cur.execute(sql_delete) + clean_browser_conn.commit() + clean_browser_cur.close() + clean_browser_conn.close() + + def clean_all_records(self, filename, tablename, keyname): + if os.path.exists(filename): + clean_browser_conn = sqlite3.connect(filename) + clean_browser_cur = clean_browser_conn.cursor() + sql_delete = "DELETE FROM %s" % tablename + clean_browser_cur.execute(sql_delete) + clean_browser_conn.commit() + clean_browser_cur.close() + clean_browser_conn.close() + + + def clean_the_records(self, domain): + if os.path.exists(self.path): + clean_browser_conn = sqlite3.connect(self.path + self.filename) + clean_browser_cur = clean_browser_conn.cursor() + sql_exist = "SELECT * FROM moz_cookies WHERE baseDomain='%s'" % domain + clean_browser_cur.execute(sql_exist) + if clean_browser_cur.fetchone(): + sql_delete = "DELETE FROM moz_cookies WHERE baseDomain='%s'" % domain + clean_browser_cur.execute(sql_delete) + clean_browser_conn.commit() + clean_browser_cur.close() + clean_browser_conn.close() + return True + else: + return False + +if __name__ == "__main__": + objc = CookiesClean() + objc.scan_the_records() + #objc.clean_the_records(['1188.com']) + del objc diff --git a/backends/youker-assistant-daemon/src/cleaner/dashhistory.py b/backends/youker-assistant-daemon/src/cleaner/dashhistory.py new file mode 100644 index 0000000..08fd8bd --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/dashhistory.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import commands +import sqlite3 + + +class DashHistory(): + def __init__(self, homedir): + self.full_path = '' + if homedir: + path = '%s/.local/share/zeitgeist/' % homedir + else: + path = os.path.expanduser('~/.local/share/zeitgeist/') + self.full_path = path + 'activity.sqlite' + if not os.path.exists(self.full_path): + raise Exception("Dashhistory: path did not exist") + + def scan_the_records(self): + self.browser_conn = sqlite3.connect(self.full_path) + self.browser_cur = self.browser_conn.cursor() + + sql_select = "SELECT COUNT(*) FROM event_view" + self.browser_cur.execute(sql_select) + number = self.browser_cur.fetchone()[0] + + self.browser_cur.close() + self.browser_conn.close() + return number + + def clean_the_records(self): + tmp_path = self.full_path + user = tmp_path.split('/')[2] + os.remove(tmp_path) + cmd = "su - %s -c 'zeitgeist-daemon --replace & >& /dev/null'" % user + (status, output) = commands.getstatusoutput(cmd) + return + + diff --git a/backends/youker-assistant-daemon/src/cleaner/diskanalyse.py b/backends/youker-assistant-daemon/src/cleaner/diskanalyse.py new file mode 100644 index 0000000..c76a649 --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/diskanalyse.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import os.path + +import common + +class DiskAnalyse(): + def __init__(self): + pass + + def hundred_large_files(self, size, path): + mypath = path + final_list = [] + if os.path.exists(mypath): + for rootpath, dirnames, filenames in os.walk(mypath): + for filename in filenames: + flag = True + filepath = os.path.join(rootpath, filename) + if os.path.islink(filepath): + continue + filelist = [os.path.getsize(filepath), filepath] + if not final_list and filelist[0] >= size: + final_list.append(filelist) + flag = False + else: + for index, values in enumerate(final_list): + if filelist > values: + final_list.insert(index, filelist) + flag = False + break + if flag and filelist[0] >= size : + final_list.append(filelist) + else: + pass + return final_list + + def adjust_the_list(self, size, path): + final_str = [] + tmp_list = self.hundred_large_files(size, path) + if tmp_list: + for tmp in tmp_list: + tmp[0] = common.confirm_filesize_unit(tmp[0]) + final_str.append('<2_2>'.join(tmp)) + return final_str + + +if __name__ == '__main__': + obj = DiskAnalyse() + obj.hundred_large_files() + obj.type_of_file() diff --git a/backends/youker-assistant-daemon/src/cleaner/historyclean.py b/backends/youker-assistant-daemon/src/cleaner/historyclean.py new file mode 100644 index 0000000..4071b53 --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/historyclean.py @@ -0,0 +1,143 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os.path +import sqlite3 +from common import process_pid +from common import get_mozilla_path + + +class HistoryClean(): + def __init__(self, homedir): + self.filename = 'places.sqlite' + self.path = get_mozilla_path(homedir) + + def scan_the_records(self): + save = [] + if os.path.exists(self.path): + scan_browser_conn = sqlite3.connect(self.path + self.filename) + scan_browser_cur = scan_browser_conn.cursor() + sql_select = "SELECT moz_historyvisits.place_id, moz_places.url, moz_places.title, count(*) FROM moz_historyvisits, moz_places WHERE moz_historyvisits.place_id=moz_places.id GROUP BY moz_historyvisits.place_id" + scan_browser_cur.execute(sql_select) + for eachvisit in scan_browser_cur.fetchall(): + + tmp = list(eachvisit) + tmp[0], tmp[-1] = str(tmp[0]), str(tmp[-1]) + if not isinstance(tmp[2], unicode): + tmp[2] = str(tmp[2]) + tmp_str = '<2_2>'.join(tmp) + save.append(tmp_str) + scan_browser_cur.close() + scan_browser_conn.close() + return save + + def scan_firefox_history_records(self, filepath): + result = [] + if os.path.exists(filepath): + scan_browser_conn = sqlite3.connect(filepath) + scan_browser_cur = scan_browser_conn.cursor() + sql_select = "SELECT moz_historyvisits.place_id, moz_places.url, count(*) FROM moz_historyvisits, moz_places WHERE moz_historyvisits.place_id=moz_places.id GROUP BY moz_historyvisits.place_id" + scan_browser_cur.execute(sql_select) + result = scan_browser_cur.fetchall() + #result = ["%s<2_2>%s<2_2>%s" % (str(each[0]), each[1], str(each[2])) for each in allvisit] + scan_browser_cur.close() + scan_browser_conn.close() + return result + + def scan_chromium_history_records(self, filepath): + result = [] + if os.path.exists(filepath): + scan_chromium_conn = sqlite3.connect(filepath) + scan_chromium_cur = scan_chromium_conn.cursor() + sql_select = "SELECT visits.url, urls.url, count(*) FROM visits, urls WHERE visits.url=urls.id GROUP BY visits.url" + scan_chromium_cur.execute(sql_select) + result = scan_chromium_cur.fetchall() + #result = ["%s<2_2>%s<2_2>%s" % (str(each[0]), each[1], str(each[2])) for each in allvisit] + scan_chromium_cur.close() + scan_chromium_conn.close() + + return result + + def clean_firefox_all_records(self, filepath): + if os.path.exists(filepath): + clean_browser_conn = sqlite3.connect(filepath) + clean_browser_cur = clean_browser_conn.cursor() + sql_deletehistory = 'DELETE FROM moz_historyvisits' + clean_browser_cur.execute(sql_deletehistory) + clean_browser_conn.commit() + + sql_selectplace = 'SELECT place_id FROM moz_annos UNION SELECT fk FROM moz_bookmarks UNION SELECT place_id FROM moz_inputhistory' + clean_browser_cur.execute(sql_selectplace) + delete_place_id = clean_browser_cur.fetchall() + delete_place_id_str = ','.join([ str(one[0]) for one in delete_place_id if one[0]]) + sql_deleteplace = 'DELETE FROM moz_places WHERE id NOT IN (%s)' % delete_place_id_str + clean_browser_cur.execute(sql_deleteplace) + clean_browser_conn.commit() + + sql_selectfavicons = 'SELECT favicon_id FROM moz_places' + clean_browser_cur.execute(sql_selectfavicons) + delete_favicon_id = clean_browser_cur.fetchall() + delete_favicon_id_str = ','.join([ str(one[0]) for one in delete_favicon_id if one[0]]) + sql_deletefavicons = 'DELETE FROM moz_favicons WHERE id NOT in (%s)' % delete_favicon_id_str + clean_browser_cur.execute(sql_deletefavicons) + clean_browser_conn.commit() + + clean_browser_cur.close() + clean_browser_conn.close() + + def clean_chromium_all_records(self, filepath): + if os.path.exists(filepath): + clean_chromium_conn = sqlite3.connect(filepath) + clean_chromium_cur = clean_chromium_conn.cursor() + tables = ['visits', 'urls', 'keyword_search_terms', 'segment_usage', 'segments'] + for tn in tables: + sql_delete = 'DELETE FROM %s' % tn + clean_chromium_cur.execute(sql_delete) + clean_chromium_conn.commit() + + clean_chromium_cur.close() + clean_chromium_conn.close() + + def clean_the_records(self, history): + int_history = int(history) + sql_exist = 'SELECT * FROM moz_historyvisits WHERE place_id=%s' % int_history + self.browser_cur.execute(sql_exist) + if self.browser_cur.fetchone(): + sql_delete = 'DELETE FROM moz_historyvisits WHERE place_id=%s ' % int_history + self.browser_cur.execute(sql_delete) + #self.browser_cur.execute('DELETE FROM moz_places WHERE visit_count=0') + self.browser_conn.commit() + return True + else: + return False + + def clean_all_records(self): + if os.path.exists(self.path): + clean_browser_conn = sqlite3.connect(self.path + self.filename) + clean_browser_cur = clean_browser_conn.cursor() + sql_deleteall = 'DELETE FROM moz_historyvisits' + clean_browser_cur.execute(sql_deleteall) + #self.browser_cur.execute('DELETE FROM moz_places WHERE visit_count=0') + clean_browser_conn.commit() + clean_browser_cur.close() + clean_browser_conn.close() + +if __name__ == "__main__": + objc = HistoryClean() + objc.scan_the_records() + #objc.clean_the_records(['36']) + del objc diff --git a/backends/youker-assistant-daemon/src/cleaner/oldkernel.py b/backends/youker-assistant-daemon/src/cleaner/oldkernel.py new file mode 100644 index 0000000..b194eff --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/oldkernel.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +#import apt +import apt_pkg +import re + +import common + +class OldKernel(): + def __init__(self): + #cache = None + self.flag = '(\w+-)*[.\d]+-\d+[\D]*' + + def scan_oldkernel_packages(self): + #pkgs = self.cache.packages + cache = common.get_cache_list() + final_oldkernel_list = [] + current_version = '-'.join(os.uname()[2].split('-')[:2]) + if cache: + for pkg in cache: + if pkg.is_installed and pkg.name.startswith('linux'): + if re.match(self.flag, pkg.name): + #version = pkg.installedVersion[:-3] + version = pkg.installed.version + if apt_pkg.version_compare(version, current_version) < 0: + #tmp_oldkernel_list = [pkg.name, common.confirm_filesize_unit(pkg.installedSize)] + #final_oldkernel_list.append('<2_2>'.join(tmp_oldkernel_list)) + final_oldkernel_list.append(pkg) + return final_oldkernel_list + + def get_oldkernel_packages(self): + #pkgs = self.cache.packages + cache = common.get_cache_list() + oldkernel_list = [] + current_version = '-'.join(os.uname()[2].split('-')[:2]) + if cache: + for pkg in cache: + if pkg.is_installed and pkg.name.startswith('linux'): + if re.match(self.flag, pkg.name): + #version = pkg.installedVersion[:-3] + version = pkg.installed.version + if apt_pkg.version_compare(version, current_version) < 0: + #tmp_oldkernel_list = [pkg.name, common.confirm_filesize_unit(pkg.installedSize)] + #final_oldkernel_list.append('<2_2>'.join(tmp_oldkernel_list)) + oldkernel_list.append('Name:' + pkg.name + ';' + 'Summary:' + pkg.installed.summary + ';' + 'Size:' + common.confirm_filesize_unit(pkg.installed.installed_size)) + + return oldkernel_list +if __name__ == "__main__": + objo = OldKernel() + #objo.get_the_kernel() + aaa = objo.get_old_kernel() + print aaa + diff --git a/backends/youker-assistant-daemon/src/cleaner/osslim.py b/backends/youker-assistant-daemon/src/cleaner/osslim.py new file mode 100644 index 0000000..2644477 --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/osslim.py @@ -0,0 +1,45 @@ +import sys +import apt +import apt_pkg +from apt.progress.base import InstallProgress + +import common + +class OsSlim(): + def __init__(self): + pass + + def get_unneed_packages(self): + cache = common.get_cache_list() + unneed_packages_list = [] + if cache: + for pkg in cache: + if pkg.is_auto_removable and not pkg.name.startswith('linux'): + unneed_packages_list.append('Name:' + pkg.name + ';' + 'Summary:' + pkg.installed.summary + ';' + 'Size:' + common.confirm_filesize_unit(pkg.installed.installed_size)) + return unneed_packages_list + + def get_spare_packages(self): + cache = common.get_cache_list() + spare_packages_list = [] + if cache: + for pkg in cache: + if pkg.is_auto_removable and not pkg.name.startswith('linux'): + #if pkg.is_installed and pkg.name.startswith('linux-headers'): + tmp_packages_list = [pkg.name, pkg.installed.summary, common.confirm_filesize_unit(pkg.installed.installed_size)] + spare_packages_list.append('<2_2>'.join(tmp_packages_list)) + return spare_packages_list + + def scan_spare_packages(self): + cache = common.get_cache_list() + final_spare_list = [] + if cache: + for pkg in cache: + if pkg.is_auto_removable and not pkg.name.startswith('linux'): + final_spare_list.append(pkg) + return final_spare_list + + +if __name__ == '__main__': + obj = OsSlim() + obj.get_spare_packages() + #obj.clean_spare_packages() diff --git a/backends/youker-assistant-daemon/src/cleaner/searchsame.py b/backends/youker-assistant-daemon/src/cleaner/searchsame.py new file mode 100644 index 0000000..c365e4e --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/searchsame.py @@ -0,0 +1,100 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import os.path +import fnmatch +import filecmp +import hashlib + +class SearchSame(): + def __init__(self): + self.style = ['.gz', '.bz2'] + self.style_dic = {} + self.tmp_style_dic = {} + + def search_by_style(self, spath): + if not os.path.exists(spath): + raise Exception('no such path!') + else: + if not spath.endswith('/'): + spath += '/' + for name in os.listdir(spath): + tmp = spath + name + if os.path.islink(tmp): + continue + elif os.path.isdir(tmp): + self.search_by_style(tmp) + else: + front, behind = os.path.splitext(tmp) + if behind in self.style: + addf, addb = os.path.splitext(front) + if addb == '.tar': + behind = addb + behind + self.tmp_style_dic.setdefault(behind, []).append(tmp) + + def search_by_size(self): + self.style_dic = self.reduce_the_dic(self.tmp_style_dic) + size_dic = {} + for k in self.style_dic.keys(): + for abc in self.style_dic[k]: + filesize = os.path.getsize(abc) + size_dic.setdefault(filesize, []).append(abc) + return self.reduce_the_dic(size_dic) + + def search_by_cmp(self): + final_dic = {} + size_dic = self.search_by_size() + for k in size_dic.keys(): + for content in size_dic[k]: + sha1sumva = self.get_file_hash(content) + final_dic.setdefault(sha1sumva, []).append(content) + return self.reduce_the_dic(final_dic) + + + def get_file_hash(self, filepath): + with open(filepath, 'rb') as f: + sha1obj = hashlib.sha1() + sha1obj.update(f.read()) + hashvalue = sha1obj.hexdigest() + return hashvalue + + def adjust_the_dic(self): + final_list = [] + final_dic = self.search_by_cmp() + for key in final_dic.keys(): + tmp_str = "<2_2>".join(final_dic[key]) + final_list.append(tmp_str) + # init + self.style_dic = {} + self.tmp_style_dic = {} + return final_list + + def reduce_the_dic(self, tmp_dic): + for key in tmp_dic.keys(): + if len(tmp_dic[key]) < 2: + del tmp_dic[key] + return tmp_dic + +if __name__ == '__main__': + path = '/home/kylin/ubuntu-tweak' + obj = SearchSame() + obj.search_by_style(path) + #obj.search_by_size() + #obj.search_by_cmp() + obj.adjust_the_dic() + #obj.get_file_hash('/home/aya/test.py') diff --git a/backends/youker-assistant-daemon/src/cleaner/softwareconfigfile.py b/backends/youker-assistant-daemon/src/cleaner/softwareconfigfile.py new file mode 100644 index 0000000..1aa0909 --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/softwareconfigfile.py @@ -0,0 +1,50 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import commands + +import common + +class SoftwareConfigfile(): + def __init__(self): + pass + + def scan_configfile_packages(self): + cache = common.get_cache_list() + final_softwareconfigfile_list = [] + + status, output = commands.getstatusoutput('dpkg -l') + result = [(line.split()[1]).split(':')[0] for line in output.split('\n') if line.startswith('rc')] + for one in result: + final_softwareconfigfile_list.append(cache[one]) + return final_softwareconfigfile_list + def get_configfile_packages(self): + cache = common.get_cache_list() + softwareconfigfile_list = [] + + status, output = commands.getstatusoutput('dpkg -l') + result = [(line.split()[1]).split(':')[0] for line in output.split('\n') if line.startswith('rc')] + for one in result: + pkg = cache[one] + softwareconfigfile_list.append('Name:' + pkg.name + ';' + 'Summary:' + ';' + 'Size:') + return softwareconfigfile_list + + +if __name__ == '__main__': + obj = SoftwareConfigfile() + a = obj.scan_configfile_packages() + print a diff --git a/backends/youker-assistant-daemon/src/cleaner/systemhistory.py b/backends/youker-assistant-daemon/src/cleaner/systemhistory.py new file mode 100644 index 0000000..016a614 --- /dev/null +++ b/backends/youker-assistant-daemon/src/cleaner/systemhistory.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +from xml.etree import ElementTree + +class SystemHistory(): + def __init__(self): + pass + + def scan_the_xml(self, homedir): + if homedir: + xml_path = '%s/.local/share/' % homedir + else: + xml_path = os.path.expanduser('~/.local/share/') + + full_path = xml_path + 'recently-used.xbel' + + hreflist = [] + if os.path.exists(full_path): + tree = ElementTree.parse(full_path) + nodes = tree.findall("bookmark") + for node in nodes: + hreflist.append(node.get('href')) + + return hreflist + + def clean_the_xml(self, homedir): + xml_path = '%s/.local/share/' % homedir + full_path = xml_path + 'recently-used.xbel' + + if os.path.exists(full_path): + tree = ElementTree.parse(full_path) + root = tree.getroot() + root .clear() + + tree.write(full_path, encoding="UTF-8", xml_declaration=None, default_namespace=None, method="xml") diff --git a/backends/youker-assistant-daemon/src/detailinfo/__init__.py b/backends/youker-assistant-daemon/src/detailinfo/__init__.py new file mode 100644 index 0000000..013e4b7 --- /dev/null +++ b/backends/youker-assistant-daemon/src/detailinfo/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/backends/youker-assistant-daemon/src/detailinfo/cpuinfo.py b/backends/youker-assistant-daemon/src/detailinfo/cpuinfo.py new file mode 100644 index 0000000..75f61c3 --- /dev/null +++ b/backends/youker-assistant-daemon/src/detailinfo/cpuinfo.py @@ -0,0 +1,1925 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + + +import sys +import os +import re +import uuid +import socket +import fcntl +import struct +import math +import binascii +import platform +import commands +import random +from pprint import pprint + +from gi.repository import GLib#20161228 +import locale +import gettext +##from gettext import gettext as _ +##from gettext import ngettext as __ +#locale.setlocale(locale.LC_ALL, "") +#gettext.bindtextdomain("youker-assistant", "/usr/share/locale") +#gettext.textdomain("youker-assistant") +#_ = gettext.gettext + +CPU_CURRENT_FREQ = "" +CPU_MAX_FREQ = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" +MEMORY = "/sys/phytium1500a_info" + +KILOBYTE_FACTOR = 1000.0 +MEGABYTE_FACTOR = (1000.0 * 1000.0) +GIGABYTE_FACTOR = (1000.0 * 1000.0 * 1000.0) +TERABYTE_FACTOR = (1000.0 * 1000.0 * 1000.0 * 1000.0) + +def get_human_read_capacity_size(size): + size_str = "" + displayed_size = 0.0 + unit = "KB" + + if size < MEGABYTE_FACTOR: + displayed_size = float(size/KILOBYTE_FACTOR) + unit = "KB" + elif size < GIGABYTE_FACTOR: + displayed_size = float(size/MEGABYTE_FACTOR) + unit = "MB" + elif size < TERABYTE_FACTOR: + displayed_size = float(size/GIGABYTE_FACTOR) + unit = "GB" + else: + displayed_size = float(size/TERABYTE_FACTOR) + unit = "TB" + #print "displayed_size=", round(displayed_size) + #round 不是简单的四舍五入,而是ROUND_HALF_EVEN的策略 + #ceil 取大于或者等于x的最小整数 + #floor 取小于或者等于x的最大整数 + #print round(2.5)#3.0 + #print math.ceil(2.5)#3.0 + #print math.floor(2.5)#2.0 + #print round(2.3)#2.0 + #print math.ceil(2.3)#3.0 + #print math.floor(2.3)#2.0 + str_list = [str(int(round(displayed_size))), unit] + size_str = " ".join(str_list) + return size_str + +def get_interface_mac(interface): + DEVICE_NAME_LEN = 15 + MAC_START = 18 + MAC_END = 24 + try: + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', interface[:DEVICE_NAME_LEN])) + return ''.join(['%02x:' % ord(char) for char in info[MAC_START:MAC_END]])[:-1] + except Exception as e: + return "unknown" + +def get_interface_ip(interface): + DEVICE_NAME_LEN = 15 + IP_START = 20 + IP_END = 24 + if interface == "unknown": + return "unknown" + try: + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + info = fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', interface[:DEVICE_NAME_LEN])) + return ''.join(['%s.' % ord(char) for char in info[IP_START:IP_END]])[:-1] + except Exception as e: + return "unknown" + #try: + # sk = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + # ip = socket.inet_ntoa(fcntl.ioctl( + # sk.fileno(), + # 0x8915, # SIOCGIFADDR + # struct.pack('256s', netItem[:15]) + # )[20:24]) + # return ip + #except Exception as e: + # return "unknown" + +def get_interface_driver(interface): + if interface == "unknown": + return "unknown" + cmd = "ethtool -i %s |grep 'driver:'" % interface + fp = os.popen(cmd) + msg = fp.read().strip('\n') + fp.close() + if msg: + tmp = re.findall('driver: (.*)', msg) + if tmp[0] in [None, '']: + return "unknown" + else: + return tmp[0] + else: + return "unknown" + +class DetailInfo: +#Computer: +# ComVendor 制造商 +# ComProduct 电脑型号 +# ComVersion 电脑版本 +# ComSerial 序列号 +# node 主机名 +# uptime 持续运行时间 +# system 操作系统类型 +# platform 操作系统 +# architecture 系统位数 +# release 内核版本 +# machine 内核架构 + +#CPU: +# CpuVersion 处理器版本 +# CpuVendor 制造商 +# CpuSlot 插槽 +# CpuSerial 序列号 +# CpuCapacity 最大主频 +# CpuSize 当前主频 +# CpuClock 前端总线 +# cpu_cores cpu内核数 +# cpu_siblings cpu线程数 +# clflush_size 一级缓存 +# cache_size 二级缓存 + +#Board and BIOS: +# BoaProduct 主板型号 +# BoaVendor 主板产商 +# BoaSerial 序列号 +# BioVendor BIOS产商 +# BioVersion BIOS版本 +# BioRelease 发布日期 + +#Memory: +# Memnum 内存条个数 +# MemInfo 内存条信息 +# MemWidth 数据宽度 +# MemSlot 插槽号 +# MemProduct 内存型号 +# MemVendor 制造商 +# MemSerial 序列号 +# MemSize 内存大小 + +#Monitor: +# Mon_product 显示器型号 +# Mon_vendor 显示器制造商 +# Mon_year 生产日期_年 +# Mon_week 生产日期_周 +# Mon_size 可视面积 +# Mon_in 屏幕尺寸 +# Mon_maxmode 最大分辨率 +# Mon_gamma 伽马值 +# Mon_output 当前接口 +# Mon_support 支持接口 +# Mon_chip 当前显卡 +# Vga_num 显卡数 +# Vga_product 显卡型号 +# Vga_vendor 显卡产商 +# Vga_businfo 显卡总线地址 +# Vga_Drive 显卡驱动 + +#Disk : +# disknum 硬盘个数 +# DiskProduct 硬盘型号 +# DiskVendor 硬盘厂商 +# DiskCapacity 硬盘容量 +# DiskName 设备名称 +# DiskFw 固件版本 +# DiskSerial 序列号 + +#Network : +# NetProduct 网卡型号 +# NetVendor 制造商 +# NetBusinfo 总线地址 +# NetLogicalname 设备名称 +# NetSerial MAC地址 +# NetCapacity 最大带宽 +# NetIp IP地址 +# NetLink 连接状态 +# NetDrive 网卡驱动 +# WlanProduct 无线网卡型号 +# WlanVendor 无线制造商 +# WlanBusinfo 总线地址 +# WlanLogicalname 设备名称 +# WlanSerial MAC地址 +# WlanIp 无线IP地址 +# WlanDrive 无线网卡驱动 + +#multimedia : +# MulNum 多媒体个数 +# MulProduct 产品型号 +# MulVendor 制造商 +# MulBusinfo 总线地址 +# MulDrive 驱动 + +#dvd : +# Dvdnum 光驱个数 +# DvdProduct 光驱型号 +# DvdVendor 制造商 +# DvdName 设备名称 +# DvdFw 固件版本 +# DvdSerial 序列号 + +#usb : +# Usbnum usb使用个数 +# UsbVendor 制造商 +# UsbProduct 产品型号 +# UsbBusinfo 总线地址 +# UsbID 设备ID +# bcdUsb 固件版本 +# UsbMaxpower 最大电流 + + def __init__(self): + self.lshwstr = '' + self.machine = platform.machine() + self.osname = self.read_os_name() +# print platform.platform() +# print platform.version() +# print platform.architecture() +# print platform.node() +# print platform.processor() +# print platform.uname() + + def ctoascii(self,buf): + ch = str(buf) + asci = binascii.b2a_hex(ch) + asci = int(asci,16) + return asci + + def strip(self, s): + if(len(s) == 0): + return s + while len(s) > 0 and self.ctoascii(s[0]) <= 32: + s = s[1: ] + k = len(s) + while len(s) > 0 and self.ctoascii(s[k-1]) <= 32: + s = s[ :k-1] + k = len(s) + i = 0 + while i < len(s): + if s[i] < 32: + s = s[ :i] + s[i+1: ] + i -= 1 + i += 1 + return s + + def uptimeinfo(self): + with open('/proc/uptime') as f: + for line in f: + string = line.split('.')[0] + seconds = int(string) + minutes = seconds / 60 + upminutes = str(minutes) + return upminutes + + def read_os_name(self): + platValue = platform.platform() + if os.path.exists("/etc/ubuntukylin-release"): + with open("/etc/ubuntukylin-release", "r") as fsys: + for line in fsys: + if line.startswith("DISTRIB_DESCRIPTION"): + tmp = line + break + # kobe: remove '"' and '\n' + front = tmp.split('=')[1].replace('"', '').replace('\n', '') + platValue = front + elif os.path.exists("/etc/os-release"): + with open("/etc/os-release", "r") as fsys: + for line in fsys: + if line.startswith("NAME"): + tmp = line + break + # kobe: remove '"' and '\n' + front = tmp.split('=')[1].replace('"', '').replace('\n', '') + platValue = front + + if front == "Kylin" or front == "YHKylin": + with open("/etc/lsb-release", "r") as fp: + for line in fp: + if line.startswith("DISTRIB_VERSION_TYPE"): + tmp = line + # kobe: remove '"' and '\n' + id = tmp.split('=')[1].replace('"', '').replace('\n', '') + if id == "community": + platValue = "YHKylin community" + break + else: + community = "" + id = "" + with open("/etc/lsb-release", "r") as fp: + for line in fp: + if line.startswith("DISTRIB_ID"):#if line.startswith("DISTRIB_DESCRIPTION"): + tmp = line + # kobe: remove '"' and '\n' + id = tmp.split('=')[1].replace('"', '').replace('\n', '') + elif line.startswith("DISTRIB_VERSION_TYPE"): + tmp = line + # kobe: remove '"' and '\n' + community = tmp.split('=')[1].replace('"', '').replace('\n', '') +# break + platValue = id + if id == "Kylin" or id == "YHKylin": + if community == "community": + platValue = "YHKylin community" + return platValue + + def get_os_name(self): + return self.osname + + def get_url(self,v,p): + vendors = { +#CPU产商 + "INTEL":["Intel"], + "AMD":["AMD"], + "VIMICRO":["Vimicro"], +#显卡产商 + "ATI":["ATI"], + "1002":["ATI"], + "SIS":["SIS"], + "1039":["SIS"], + "NVIDIA":["Nvidia"], + "VIA":["VIA"], + "XFX":["XFX"], + "SUPERGRAPHIC":["Supergraphic"], +#显示器产商 + "AUO":["AUO"], + "AOC":["AOC"], + "PHILIPS":["Philips"], + "PHL":["Philips"], + "LEN":["Lenovo"], + "SEC":["SAMSUNG"], +#电脑品牌 + "HASEE":["Hasee"], + "FOUNDER":["Founder"], + "TONGFANG":["Tongfang"], + "TSINGHUA":["Tongfang"], + "ACER":["Acer"], + "LENOVO":["Lenovo"], + "ASUSTEK":["ASUS"], + "NEC":["NEC"], + "HP":["HP"], + "HEWLETT-PACKARD":["HP"], + "SAMSUNG":["SAMSUNG"], + "TOSHIBA":["TOSHIBA"], + "APPLE":["Apple"], + "DELL":["DELL"], + "FUJITSU":["FUJITSU"], + "PANASONIC":["Panasonic"], + "SONY":["SONY"], + "IBM":["IBM"], +#虚拟机 + "INNOTEK":["VirtualBox"], + "VBOX":["VirtualBox"], + "VIRTUALBOX":["VirtualBox"], +#网卡产商 + "3COM":["3COM"], + "D-LINK":["D-LINK"], + "RALINK":["Ralink"], + "ATHEROS":["Atheros"], + "MARVELL":["Marvell"], + "BROADCOM":["Broadcom"], +#硬盘产商 + "EXCELSTOR":["Excelstor"], + "HITACHI":["Hitachi"], + "MAXTOR":["Maxtor"], + "WESTERN":["Western Digital"], + "LITEON":["Liteon"], + "SEAGATE":["Seagate"], + "QUANTUM":["Quantum"], +#光驱产商 + "PLDS":["PLDS"], + "PBDS":["PLDS"], + "HL-DT-ST":["LG"], + "OPTIARC":["SONY"], + "TSSTCORP":["TSSTcorp"], + "PIONEER":["Pioneer"], + "MATSHITA":["Panasonic"], +#声卡产商 + "REALTEK":["Realtek"], + "CREATIVE":["Creative"], +#摄像头 + "SONIX":["Sonix"], + "ETRON":["Etron"], + "AVEO":["Aveo"], + "SYNTEK":["Syntek"], + "EMPIA":["Empia"], + "CHICONY":["Chicony"], + "OMNIVISION":["OmniVision"], +#鼠标产商 + "LOGITECH":["Logitech"], + "SUNPLUS":["Sunplus"], + "PRIMAX":["Primax"], + "PIXART":["Pixart"], + "TRUST":["Trust"], + "1BCF":["Rapoo"], + "AVAGO":["Avago"], + "MICROSOFT":["Microsoft"], +#键盘产商 + "RAPOO":["Rapoo"], +#主板产商 + "GIGABYTE":["Gigabyte"], + "BIOSTAR":["Biostar"], + "COLORFUL":["Colorful"], + "YESTON":["Yeston"], +#指纹识别 + "UPEK":["Authentec"], + "AUTHENTEC":["Authentec"], +#闪存产商 + "KINGSTON":["Kingston"], + "KINGMAX":["Kingmax"], + "KINGBOX":["Kingbox"], + "HYNIX":["Hynix"], + "HYUNDAI":["Hynix"], + "MICRON":["Micron"], + "06C1":["Asint"], + "ADATA":["ADATA"], + "ZTE":["ZTE"], + "EAGET":["Eaget"], + "TEXAS":["Texas Instruments"], + "MOTOROLA":["Motorola"], +#电源产商 + "SMP":["SMP"], + "SIMPLO":["SMP"], +#BIOS产商 + "AMERICAN":["AMI"], + "AWARD":["Phoenix"], + "PHOENIX":["Phoenix"] + } + tmp = v.split(" ")[0] + tmp = re.findall("([a-zA-Z0-9-]+)", tmp) + if tmp : + url = vendors.get(tmp[0].upper()) + if url: + return url[0] + else : + k = p.split(" ")[0] + url = vendors.get(k.upper()) + if url: + return url[0] + else: + tmp = p.split(" ")[0] + url = vendors.get(tmp.upper()) + if url: + return url[0] + tmp = re.findall("ATI", v) + if tmp : + url = vendors.get(tmp[0].upper()) + if url: + return url[0] + tmp = re.findall("SIS", v) + if tmp : + url = vendors.get(tmp[0].upper()) + if url: + return url[0] + tmp = re.findall("Intel", v) + if tmp : + url = vendors.get(tmp[0].upper()) + if url: + return url[0] + tmp = re.findall("ATI", p) + if tmp : + url = vendors.get(tmp[0].upper()) + if url: + return url[0] + tmp = re.findall("SIS", p) + if tmp : + url = vendors.get(tmp[0].upper()) + if url: + return url[0] + tmp = re.findall("Intel", p) + if tmp : + url = vendors.get(tmp[0].upper()) + if url: + return url[0] + return v + + def get_computer(self): + #Computer + Com = {} + hw = os.popen("dmidecode -t system") + computer = hw.read() + hw.close() + ComVendor,ComProduct,ComVersion,ComSerial = '','','','' + if computer : + tmp = re.findall("Product Name: (.*)",computer) + if tmp : + ComProduct = tmp[0] + tmp = re.findall("Manufacturer: (.*)",computer) + if tmp : + ComVendor = tmp[0] + tmp = re.findall("Version: (.*)",computer) + if tmp : + ComVersion = tmp[0] + tmp = re.findall("Serial Number: (.*)",computer) + if tmp : + ComSerial = tmp[0] + ComVendor = self.get_url(ComVendor,ComProduct) + Com['ComProduct'],Com['ComVendor'],Com['ComVersion'],Com['ComSerial'] = self.strip(ComProduct),self.strip(ComVendor),self.strip(ComVersion),self.strip(ComSerial) + with open('/proc/uptime') as f: + for line in f: + string = line.split('.')[0] + seconds = int(string) + minutes = seconds / 60 + uptime = str(minutes) + +# platValue = platform.platform() +# if os.path.exists("/etc/ubuntukylin-release"): +# with open("/etc/ubuntukylin-release", "r") as fsys: +# for line in fsys: +# if line.startswith("DISTRIB_DESCRIPTION"): +# tmp = line +# break +# # kobe: remove '"' and '\n' +# front = tmp.split('=')[1].replace('"', '').replace('\n', '') +# platValue = front +## if front.startswith("UbuntuKylin") or front.startswith("Ubuntu Kylin"): +## platValue = platValue.replace('Ubuntu', 'Ubuntu Kylin') +# elif os.path.exists("/etc/os-release"): +# with open("/etc/os-release", "r") as fsys: +# for line in fsys: +# if line.startswith("NAME"): +# tmp = line +# break +# # kobe: remove '"' and '\n' +# front = tmp.split('=')[1].replace('"', '').replace('\n', '') +# platValue = front +## if front.startswith("UbuntuKylin") or front.startswith("Ubuntu Kylin"): +## platValue = platValue.replace('Ubuntu', 'Ubuntu Kylin') +# else: +# with open("/etc/lsb-release", "r") as fp: +# for line in fp: +# if line.startswith("DISTRIB_DESCRIPTION"): +# tmp = line +# break +# # kobe: remove '"' and '\n' +# id = tmp.split('=')[1].replace('"', '').replace('\n', '') +# platValue = id +# if "Ubuntu" in platValue: +# platValue = platValue.replace('Ubuntu', id) + + +# if not os.path.exists("/etc/ubuntukylin-release"): +# if "Ubuntu" in platValue and "Kylin" not in platValue: +# with open("/etc/lsb-release", "r") as fsys: +# for line in fsys: +# if line.startswith("DISTRIB_DESCRIPTION"): +# tmp = line +# break +# # kobe: remove '"' and '\n' +# front = tmp.split('=')[1].replace('"', '').replace('\n', '') +# if front.startswith("UbuntuKylin") or front.startswith("Ubuntu Kylin"): +# platValue = platValue.replace('Ubuntu', 'Ubuntu Kylin') +# else: +# with open("/etc/ubuntukylin-release", "r") as fp: +# for line in fp: +# if line.startswith("DISTRIB_ID"): +# tmp = line +# break +# # kobe: remove '"' and '\n' +# id = tmp.split('=')[1].replace('"', '').replace('\n', '') +# if "Ubuntu" in platValue: +# platValue = platValue.replace('Ubuntu', id) + +# Com['platform'] = platValue +# Com['platform'] = self.osname + Com['osname'] = self.osname + + #Com['node'], Com['uptime'], Com['system'], Com['platform'],Com['architecture'], Com['release'], Com['machine'] = platform.node(),uptime,platform.system(),platform.platform(),platform.architecture()[0],platform.release(),platform.machine() + Com['node'], Com['uptime'], Com['system'], Com['architecture'], Com['release'], Com['machine'] = platform.node(),uptime,platform.system(),platform.architecture()[0],platform.release(),platform.machine() + return Com + + def get_cpu(self): + # CPU + Cpu = {} + if self.machine == "aarch64": + if os.path.exists(CPU_MAX_FREQ): + fp = open(CPU_MAX_FREQ, "r") + info = fp.read() + fp.close() + tmp = float(info.strip()) / (1000 * 1000) + freq = str("%.1f" % tmp) + #processor + Cpu['CpuVersion'] = "1500a v1.0 64bit" + Cpu['CpuVendor'] = "phytium"#(飞腾) + Cpu['CpuCapacity'] = "%s GHz" % freq + #Cpu['cpu_cores'] = "4 cores"#4 核 + if os.path.exists('/proc/cpuinfo'): + fp = open('/proc/cpuinfo', "r") + info = fp.read() + fp.close() + cnt = info.count("processor") +# Cpu['cpu_cores'] = _("%d cores") % cnt + Cpu['cpu_cores'] = cnt + with open('/proc/cpuinfo') as f: + for line in f: + if line.strip(): + if line.rstrip('\n').startswith('model name'): + modelName = line.rstrip('\n').split(':')[1].strip().strip('\n') + if "phytium" in modelName: +# Cpu['CpuVersion'] = _("%s v1.0") % modelName + Cpu['CpuVersion'] = "%s v1.0" % modelName + Cpu['CpuVendor'] = "phytium"#(飞腾) + else: + Cpu['CpuVersion'] = modelName + break + #Cpu['cpu_siblings'] = "4 thread/core"#4 线程/核 + #Cpu['clflush_size'] = "32 KB" + #Cpu['cache_size'] = "2 MB" + else: + #处理器版本 + Cpu['CpuVersion'] = "1500a v1.0" + #制造商 phytium + Cpu['CpuVendor'] = "phytium"#(飞腾) + #插槽 + #Cpu['CpuSlot'] = "插槽" + #序列号 + #Cpu['CpuSerial'] = "序列号" + #最大主频 + Cpu['CpuCapacity'] = "1800 MHz" + #当前主频 + #Cpu['CpuSize']= "当前主频" + #前端总线 + #Cpu['CpuClock'] = "前端总线" + #内核数 + Cpu['cpu_cores'] = "4 "#4 核 + #线程数 + #Cpu['cpu_siblings'] = "4 thread/core"#4 线程/核 + #一级缓存 + #Cpu['clflush_size'] = "32 KB" + #二级缓存 + #Cpu['cache_size'] = "2 MB" + else: + hw = os.popen("dmidecode -t processor") + cpuin = hw.read() + hw.close() + CpuVersion,CpuVendor,CpuSlot,CpuSerial,CpuCapacity,CpuSize,CpuClock,cpu_cores,cpu_siblings,clflush_size,cache_size = '','','','','','','','','','','' + if cpuin : + tmp = re.findall("Version: (.*)",cpuin) + if tmp : + CpuVersion = tmp[0] + tmp = re.findall("Manufacturer: (.*)",cpuin) + if tmp : + CpuVendor = tmp[0] + tmp = re.findall("Socket Designation: (.*)",cpuin) + if tmp : + CpuSlot = tmp[0] + tmp = re.findall("Serial Number: (.*)",cpuin) + if tmp : + CpuSerial = tmp[0] + tmp = re.findall("Max Speed: (.*)",cpuin) + if tmp : + CpuCapacity = tmp[0] + tmp = re.findall("Current Speed: (.*)",cpuin) + if tmp : + CpuSize = tmp[0] + tmp = re.findall("External Clock: (.*)",cpuin) + if tmp : + CpuClock = tmp[0] + CpuVendor = self.get_url(CpuVendor,CpuVersion) + Cpu['CpuVersion'],Cpu['CpuVendor'],Cpu['CpuSlot'],Cpu['CpuSerial'],Cpu['CpuCapacity'],Cpu['CpuSize'],Cpu['CpuClock'] = self.strip(CpuVersion),self.strip(CpuVendor),self.strip(CpuSlot),self.strip(CpuSerial),self.strip(CpuCapacity),self.strip(CpuSize),self.strip(CpuClock) + with open('/proc/cpuinfo') as f: + for line in f: + if line.strip(): + if line.rstrip('\n').startswith('vendor_id'): + vendor = line.rstrip('\n').split(':')[1] + elif line.rstrip('\n').startswith('cpu cores'): + cpu_cores = line.rstrip('\n').split(':')[1] + elif line.rstrip('\n').startswith('siblings'): + cpu_siblings = line.rstrip('\n').split(':')[1] + elif line.rstrip('\n').startswith('clflush size'): + clflush_size = line.rstrip('\n').split(':')[1] + clflush_size = filter(str.isdigit,clflush_size) + elif line.rstrip('\n').startswith('cache size'): + cache_size = line.rstrip('\n').split(':')[1] + cache_size = filter(str.isdigit,cache_size) + Cpu['cpu_cores'],Cpu['cpu_siblings'],Cpu['clflush_size'],Cpu['cache_size'] = cpu_cores,cpu_siblings,clflush_size,cache_size + return Cpu + + def get_board(self): + #Board and BIOS + Boa = {} + hw = os.popen("dmidecode -t baseboard") + board = hw.read() + hw.close() + BoaProduct,BoaVendor,BoaSerial,BioVendor,BioVersion,BioRelease = '','','','','','' + if board : + tmp = re.findall("Product Name: (.*)",board) + if tmp : + BoaProduct = tmp[0] + tmp = re.findall("Manufacturer: (.*)",board) + if tmp : + BoaVendor = tmp[0] + tmp = re.findall("Serial Number: (.*)",board) + if tmp : + BoaSerial = tmp[0] + hw = os.popen("dmidecode -t bios") + bios = hw.read() + hw.close() + if bios : + tmp = re.findall("Vendor: (.*)",bios) + if tmp: + BioVendor = tmp[0] + tmp = re.findall("Version: (.*)",bios) + if tmp: + BioVersion = tmp[0] + tmp = re.findall("Release Date: (.*)",bios) + if tmp: + BioRelease = tmp[0] + BoaVendor = self.get_url(BoaVendor,BoaProduct) + BioVendor = self.get_url(BioVendor,BioVersion) + Boa['BoaProduct'],Boa['BoaVendor'],Boa['BoaSerial'],Boa['BioVendor'],Boa['BioVersion'],Boa['BioRelease'] = self.strip(BoaProduct),self.strip(BoaVendor),self.strip(BoaSerial),self.strip(BioVendor),self.strip(BioVersion),self.strip(BioRelease) + return Boa + + def get_memory(self): + #Memory Device + Mem = {} + if self.machine == "aarch64": + if os.path.exists(MEMORY): + memnum = 0 + all_exists = [] + total = [ f for f in os.listdir(MEMORY) if f.startswith("memory")] + + for p in total: + exists = os.path.join(MEMORY, p) + if os.stat(exists).st_size: + # memnum += 1 + all_exists.append(exists) + + # Mem["Memnum"] = str(memnum) + for i in all_exists: + fp = open(i, "r") + info = fp.read() + fp.close + # dic = dict([tuple(x.split(":")) for x in info.split("\n") if x]) + dic = dict([tuple(x.split(":")) for x in info.split("\n") if x and ":" in x]) + if dic in(None, {}): + continue + else: + memnum += 1 + #if Mem.get("MemInfo") == None: + # Mem["MemInfo"] = "DDR3 " + dic["Speed"] + #else: + # Mem["MemInfo"] += "<1_1>" + "DDR3 " + dic["Speed"] + ###add by hebing at 2017.01.23 for 206 + if Mem.get("MemInfo") == None: + Mem["MemInfo"] = "DDR3 " + else: + Mem["MemInfo"] += "<1_1>" + "DDR3 " + + if dic["Bank Locator"]: + median = str(dic["Bank Locator"]) + else: + median = '$' + if Mem.get("MemSlot") == None: + Mem["MemSlot"] = median + else: + Mem["MemSlot"] += "<1_1>" + median + + if dic["Size"]: + median = str(dic["Size"]) + else: + median = '$' + if Mem.get("MemSize") == None: + Mem["MemSize"] = median + else: + Mem["MemSize"] += "<1_1>" + median + + if dic["Manufacturer ID"]: + median = str(dic["Manufacturer ID"].upper()) + else: + median = '$' + if Mem.get("MemVendor") == None: + Mem["MemVendor"] = median + else: + Mem["MemVendor"] += "<1_1>" + median + + if Mem.get("MemWidth") == None: + Mem["MemWidth"] = "64bit" + else: + Mem["MemWidth"] += "<1_1>" + "64bit" + Mem["Memnum"] = str(memnum) + if Mem in (None, '', '[]', {}) or Mem["Memnum"] == '0':#20161228 + Mem["Memnum"] = "1" + Mem["MemWidth"] = "64bit" + Mem["MemInfo"] = "DDR3" + fp = open("/proc/meminfo", "r") + info = fp.read() + fp.close() + dic = dict([tuple(x.split(":")) for x in info.split("\n") if x]) + MemTotal = dic["MemTotal"].strip().split(' ')[0] + Mem["MemSize"] = GLib.format_size_for_display(int(MemTotal) * 1024) + else: + MemInfo,MemWidth,Memnum,MemSlot,MemProduct,MemVendor,MemSerial,MemSize,BioVendor = "","","","","","",'','','' + hw = os.popen("dmidecode -t memory") + memory = hw.read() + hw.close() + num = 0 + q = re.findall('Memory Device\n',memory) + if q : + memory = memory[memory.index("Memory Device\n")+len("Memory Device\n"):] + else : + memory = '' + if memory : + mark = re.findall("Data Width: (.*)",memory) + if mark : + for k in mark : + if not k == 'Unknown': + num += 1 + if MemWidth : + MemWidth += "<1_1>" + k + else : + MemWidth = k + Memnum = str(num) + tmp = re.findall("Bank Locator: (.*)",memory) + i = 0 + if tmp : + for k in mark : + i += 1 + if not k == 'Unknown': + if MemSlot : + MemSlot +="<1_1>"+ tmp[i-1] + else : + MemSlot = tmp[i-1] + tmp = re.findall("Part Number: (.*)",memory) + i = 0 + if tmp : + for k in mark : + i += 1 + if not k == 'Unknown': + if MemProduct : + MemProduct += "<1_1>" + tmp[i-1] + else : + MemProduct = tmp[i-1] + tmp = re.findall("Manufacturer: (.*)",memory) + i = 0 + if tmp : + for k in mark : + i += 1 + if not k == 'Unknown': + if MemVendor : + MemVendor += "<1_1>" + tmp[i-1] + else : + MemVendor = tmp[i-1] + tmp = re.findall("Serial Number: (.*)",memory) + i = 0 + if tmp : + for k in mark : + i += 1 + if not k == 'Unknown': + if MemSerial : + MemSerial += "<1_1>" + tmp[i-1] + else : + MemSerial = tmp[i-1] + tmp = re.findall("Size: (.*)",memory) + i = 0 + if tmp : + for k in mark : + i += 1 + if not k == 'Unknown': + if MemSize : + MemSize += "<1_1>" + tmp[i-1] + else : + MemSize = tmp[i-1] + tmp0 = self.strip(re.findall("Form Factor: (.*)",memory)) + tmp1 = self.strip(re.findall("Type: (.*)",memory)) + tmp2 = self.strip(re.findall("Type Detail: (.*)",memory)) + tmp3 = self.strip(re.findall("Speed: (.*)",memory)) + i = 0 + if tmp0 and tmp1 and tmp2 and tmp3 : + for k in mark : + i += 1 + if not k == 'Unknown': + if MemInfo : + MemInfo += "<1_1>" + tmp0[i-1] + ' ' + tmp1[i-1] + ' ' + tmp2[i-1] + ' ' + tmp3[i-1] + else : + MemInfo = tmp0[i-1] + ' ' + tmp1[i-1] + ' ' + tmp2[i-1] + ' ' + tmp3[i-1] + Mem["MemInfo"],Mem["MemWidth"],Mem["MemSlot"],Mem["MemProduct"],Mem["MemVendor"],Mem["MemSerial"],Mem["MemSize"],Mem["Memnum"] = MemInfo,self.strip(MemWidth),self.strip(MemSlot),self.strip(MemProduct),self.strip(MemVendor),self.strip(MemSerial),self.strip(MemSize),self.strip(Memnum) + return Mem + ## 2017.07.27 add by hebing + def get_monitor(self): + ret_output, ret_vendor, ret_product, ret_year, ret_week, \ + ret_size, ret_in, ret_gamma, ret_maxmode = "", "", "", "", "", "", "", "", "" + Vga_product,Vga_vendor,Vga_businfo,Vga_Drive = "", "", "", "" + Vga_num = 0 + with open("/var/log/Xorg.0.log", "r") as fp: + info = fp.read() + value = re.findall("EDID for output (.*)", info) + for monitor in value: + ret = {} + p = re.compile(r'Output %s connected' % monitor) + for m in p.finditer(info): # p.finditer(info) 返回一个迭代对象,通常只会循环一次 + Vga_num += 1 + print(monitor) + #print info.split("EDID for output %s" % monitor)[1].split("EDID for output")[0] + #ret.setdefault("Mon_output", monitor) + ret_output += (monitor + "<1_1>") + localinfo = info.split("EDID for output %s" % monitor)[1].split("EDID for output")[0] + + result = re.findall('Monitor name: \s*(\w*)\s*(\w*)', localinfo) + result_bak = re.findall("Manufacturer:\s*(\w*)\s*Model:\s*(\w*)", localinfo) + #ret.setdefault("Mon_vendor", result[0][0]) + #ret.setdefault("Mon_product", " ".join(result[0])) + if result: ### 笔记本没有Monitor name + ret_vendor += (result[0][0] + "<1_1>") + ret_product += (" ".join(result[0]) + "<1_1>") + else: + ret_vendor += (result_bak[0][0] + "<1_1>") + ret_product += (" ".join(result_bak[0]) + "<1_1>") + + result = re.findall("Year:\s*(\w*)\s*Week:\s*(\w*)", localinfo) + #ret.setdefault("Mon_year", result[0][0]) + #ret.setdefault("Mon_week", result[0][1]) + ret_year += (result[0][0] + "<1_1>") + ret_week += (result[0][1] + "<1_1>") + + result = re.findall("Image Size: \s*(\w*) x (\w*)", localinfo) + x = float(result[0][0])/10; y = float(result[0][1])/10; d = math.sqrt(x**2 + y**2)/2.54 + #ret.setdefault("Mon_size", (str(x) + " X " + str(y) + " cm")) + #ret.setdefault("Mon_in", str("%.1f" %d)) + ret_size += ((str(x) + " X " + str(y) + " cm") + "<1_1>") + ret_in += (str("%.1f" %d) + "<1_1>") + + result = re.findall("Gamma: (\S*)", localinfo) + #ret.setdefault("Mon_gamma", result[0]) + ret_gamma += (result[0] + "<1_1>") + + h = re.findall("h_active: (\d*)", localinfo); v = re.findall("v_active: (\d*)", localinfo) + #ret.setdefault("Mon_maxmode", h[0] + "X" + v[0]) + ret_maxmode += ((h[0] + "X" + v[0]) + "<1_1>") + + Vga_businfo += "<1_1>"; Vga_product += "<1_1>"; Vga_vendor += "<1_1>"; Vga_Drive += "<1_1>" + + status, output = commands.getstatusoutput('lspci -vvv') + if not status: + for local in output.split("\n\n"): + if "VGA compatible controller: " in local: + Vga_num += 1 + ret_output += ""; ret_vendor += ""; ret_product += ""; ret_year += ""; ret_week += "" + ret_size += ""; ret_in += ""; ret_gamma += ""; ret_maxmode += "" + + Vga_businfo += "pci@0000:" + local.split(" ")[0] + + for line in local.split("\n"): + if "VGA compatible controller: " in line: + print line + Vga_product += line.split(":")[2][:-30] + Vga_vendor += self.get_url("", line.split(":")[2]) + if "Kernel driver in use: " in line: + Vga_Drive += line.split(":")[1] + elif "Kernel driver in use: " not in local: + Vga_Drive += "" + + ret["Mon_output"], ret["Mon_vendor"], ret["Mon_product"], ret["Mon_year"], ret["Mon_week"], ret["Mon_size"], ret["Mon_in"] = \ + ret_output, ret_vendor, ret_product, ret_year, ret_week, ret_size, ret_in + ret["Mon_gamma"], ret["Mon_maxmode"] = ret_gamma, ret_maxmode + ret["Vga_num"], ret['Vga_businfo'],ret['Vga_product'],ret['Vga_vendor'],ret['Vga_Drive'] = self.strip(str(Vga_num)), self.strip(Vga_businfo),self.strip(Vga_product),self.strip(Vga_vendor),self.strip(Vga_Drive) + return ret + + def get_monitor_obsolete(self): + #Monitor +# ret = {'Mon_chip': 'CAICOS', +# 'Mon_gamma': '2.20', +# 'Mon_in': '24.1', +# 'Mon_maxmode': '1920x1200', +# 'Mon_output': 'HDMI-0', +# 'Mon_product': 'DELL U2413', +# 'Mon_size': '51.8cm x 32.4cm', +# 'Mon_support': "['HDMI-0', 'VGA-0']", +# 'Mon_vendor': 'DELL', +# 'Mon_week': '13', +# 'Mon_year': '2015', +# 'Vga_Drive': 'radeon', +# 'Vga_businfo': 'pci@0000:02:00.0', +# 'Vga_num': '1', +# 'Vga_product': 'Advanced Micro Devices, Inc. [AMD/ATI] Caicos XT [Radeon HD 7470/8470 / R5 235/310 OEM] (prog-if 00 [VGA controller])', +# 'Vga_vendor': 'ATI'} +# return ret + ret = {} + with open('/var/log/Xorg.0.log','r') as fp: + info = fp.read() + tmp = re.findall('Monitor name: \s*(\w*)\s*(\w*)', info) + if tmp: + if tmp[0][1]: + ret["Mon_vendor"] = tmp[0][0] + ret["Mon_product"] = tmp[0][0] + " " + tmp[0][1] + else:ret["Mon_product"] = tmp[0][0] + + tmp = re.findall("Manufacturer:\s*(\w*)\s*Model:\s*(\w*)", info) + if tmp: + if not ret.get("Mon_product"): + ret["Mon_product"] = tmp[0][0] + " " + tmp[0][1] + if not ret.get("Mon_vendor"): + ret["Mon_vendor"] = tmp[0][0] + + tmp = re.findall("Year:\s*(\w*)\s*Week:\s*(\w*)", info) + if tmp: + ret["Mon_year"] = tmp[0][0] + ret["Mon_week"] = tmp[0][1] + tmp = re.findall("Image Size: \s*(\w*) x (\w*)", info) + if tmp: + x = float(tmp[0][0])/10 + y = float(tmp[0][1])/10 + d = math.sqrt(x**2 + y**2)/2.54 + + ret["Mon_size"] = str(x) + "cm" + " x " + str(y) + "cm" + ret["Mon_in"] = "%.1f" %d + + tmp = re.findall("Gamma: (\S*)", info) + if tmp: + ret["Mon_gamma"] = tmp[0] + + h = re.findall("h_active: (\d*)", info) + v = re.findall("v_active: (\d*)", info) + if h and v: + ret["Mon_maxmode"] = h[0] + "x" + v[0] + + tmp = re.findall("EDID for output (.*)", info) + if tmp: + ret["Mon_support"] = str(tmp) + + tmp = re.findall("Output (.*).* connected", info) + if tmp: + ret["Mon_output"] = tmp[0] + + tmp = re.findall("Integrated Graphics Chipset: (.*)", info) + if tmp: + ret["Mon_chip"] = tmp[0] + + tmp = re.findall("Chipset: \"(.*)\"", info) + if tmp: + if not ret.get("Mon_chip"): + ret["Mon_chip"] = tmp[0] + n = os.popen('lspci -vvv') + vga = n.read() + n.close() + Vga_num = 0 + Vga_product,Vga_vendor,Vga_businfo,Vga_Drive = '','','','' + if vga : + while re.findall('VGA compatible controller: ',vga) : + tmp = vga[vga.index('VGA compatible controller: ') - 8:] + vga = tmp[30:] + if tmp[:8]: + median = 'pci@0000:' + tmp[:8] + else: + median = '$' + if Vga_businfo: + Vga_businfo += "<1_1>" + median + else: + Vga_businfo = median + + pro = re.findall('VGA compatible controller: (.*)',tmp) + if pro: + median = pro[0] + median_2 = self.get_url('',pro[0]) + else: + median = '$' + median_2 = '$' + if Vga_product: + Vga_product += "<1_1>" + median + Vga_vendor += "<1_1>" + median_2 + else: + Vga_product = median + Vga_vendor = median_2 + + Vga_num += 1 + tmp = re.findall('Kernel driver in use: (.*)',tmp) + if tmp: + median = tmp[0] + else: + median = '$' + if Vga_Drive: + Vga_Drive += "<1_1>" + median + else : + Vga_Drive = median + + if (ret.get('Mon_vendor')): + if (ret.get('Mon_product')): + ret['Mon_vendor'] = self.get_url(ret['Mon_vendor'],ret['Mon_product']) + else : + ret['Mon_vendor'] = self.get_url(ret['Mon_vendor'],'') + ret['Vga_num'],ret['Vga_businfo'],ret['Vga_product'],ret['Vga_vendor'],ret['Vga_Drive'] = self.strip(str(Vga_num)),self.strip(Vga_businfo),self.strip(Vga_product),self.strip(Vga_vendor),self.strip(Vga_Drive) + return ret + + def get_disk_obsolete(self): + dis={} + disknum = 0 + disk_manufacturers = [ + "^ST.+", "Seagate", + "^D...-.+", "IBM", + "^IBM.+", "IBM", + "^HITACHI.+", "Hitachi", + "^IC.+", "Hitachi", + "^HTS.+", "Hitachi", + "^FUJITSU.+", "Fujitsu", + "^MP.+", "Fujitsu", + "^TOSHIBA.+", "Toshiba", + "^MK.+", "Toshiba", + "^MAXTOR.+", "Maxtor", + "^Pioneer.+", "Pioneer", + "^PHILIPS.+", "Philips", + "^QUANTUM.+", "Quantum", + "FIREBALL.+", "Quantum", + "^WDC.+", "Western Digital", + "WD.+", "Western Digital", + ] + DiskProduct,DiskVendor,DiskCapacity,DiskName,DiskFw,DiskSerial = '','','','','','' + n = os.popen("ls /dev/sd?") + line = n.read() + n.close() + n = os.popen("ls /dev/hd?") + line += n.read() + n.close() + if line : + line = line.split('\n') + for k in line : + if k : + st = os.popen("hdparm -i %s" % k) + strin = st.read() + st.close() + tmp = re.findall("Model=(.*), F",strin) + if not tmp and DiskProduct: + continue + if tmp: + median = tmp[0] + else: + median = '$' + if DiskProduct : + DiskProduct += "<1_1>" + median + else: + DiskProduct = median + i = 0 + tm = '' + while i < len(disk_manufacturers): + ven = re.compile(disk_manufacturers[i],re.I) + tm = ven.findall(tmp[0]) + if tm: + break; + i += 2 + if tm: + median = disk_manufacturers[i+1] + else: + median = '$' + if DiskVendor : + DiskVendor += "<1_1>" + median + else: + DiskVendor += median + + tmp = re.findall("FwRev=(.*), ",strin) + if tmp : + median = tmp[0] + else: + median = '$' + if DiskFw : + DiskFw += "<1_1>" + median + else: + DiskFw = median + + tmp = re.findall("SerialNo=(.*)",strin) + if tmp : + median = tmp[0] + else: + median = '$' + if DiskSerial : + DiskSerial += "<1_1>" + median + else : + DiskSerial = median + + ds = os.popen("fdisk -l %s" % k) + d = ds.read() + ds.close() + tmp = re.findall("%s: (.*)," % k,d) + if tmp: + median = tmp[0] + else: + median = '$' + ### add by hebing at 2017.01.20 + ### NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT + disklist = [] + status, output = commands.getstatusoutput("lsblk -ab") + for line in output.split("\n"): + value = line.split() + if value[1] == "8:0" and value[5] == "disk": + disklist.append(int(value[3])) + if not status: + median = str(sum(disklist) / 1000 / 1000 / 1000) + "G" + else: + median = '$' + if DiskCapacity : + DiskCapacity += "<1_1>" + median + else : + DiskCapacity = median + disknum += 1 + if DiskName : + DiskName += "<1_1>" + k + else : + DiskName = k + + dis['DiskNum'],dis['DiskProduct'],dis['DiskVendor'],dis['DiskCapacity'],dis['DiskName'],dis['DiskFw'],dis['DiskSerial'] = self.strip(str(disknum)),self.strip(DiskProduct),self.strip(DiskVendor),self.strip(DiskCapacity),self.strip(DiskName),self.strip(DiskFw),self.strip(DiskSerial) + return dis + + # writed by hb at 20170517 + def get_disk(self): + dis = {} + disk_manufacturers = { + "ST": "Seagate", + "IBM": "IBM", + "HITACHI": "Hitachi", + "IC": "Hitachi", + "HTS": "Hitachi", + "FUJITSU": "Fujitsu", + "MP": "Fujitsu", + "TOSHIBA": "Toshiba", + "MK": "Toshiba", + "MAXTOR": "Maxtor", + "Pioneer": "Pioneer", + "PHILIPS": "Philips", + "QUANTUM": "Quantum", + "FIREBALL": "Quantum", + "WDC": "Western Digital", + } + DiskProduct,DiskVendor,DiskCapacity,DiskName,DiskFw,DiskSerial = '','','','','','' + diskdict = {} + disknum = 0 + statusfirst, output = commands.getstatusoutput("lsblk -b") + + for line in output.split("\n"): + value = line.split() + if value[1].startswith("8:") and value[5] == "disk": + disknum += 1 + HDSize = get_human_read_capacity_size(int(value[3])) + DiskCapacity += ((HDSize if not statusfirst else "$") + "<1_1>") +# DiskCapacity += ( ((str(int(value[3]) / 10**9) + "G") if not statusfirst else "$") + "<1_1>") + + infodict = {} + status, output = commands.getstatusoutput("hdparm -i %s" % ("/dev/" + value[0])) + + pprint(status) + if not status: + singleinfolist = [ tmp.strip() for tmp in output.split("\n") if tmp] + pprint(output) + for mid in singleinfolist[1].split(","): + needinfo = mid.split("=") + infodict.setdefault(needinfo[0].strip(), needinfo[1]) + for key, va in disk_manufacturers.items(): + if infodict.get("Model", "$").startswith(key): + infodict.setdefault("Vendor", va) + break + + pprint(infodict) + DiskProduct += (infodict.get("Model", "$") + "<1_1>") + DiskVendor += (infodict.get("Vendor", "$") + "<1_1>") + DiskFw += (infodict.get("FwRev", "$") + "<1_1>") + DiskSerial += (infodict.get("SerialNo", "$") + "<1_1>") + else: + pprint(output) + DiskProduct += ( "$" + "<1_1>") + DiskVendor += ("$" + "<1_1>") + DiskFw += ("$" + "<1_1>") + DiskSerial += ("$" + "<1_1>") + DiskName += (("/dev/" + value[0]) + "<1_1>") + pprint(DiskProduct) + pprint(DiskVendor) + pprint(DiskFw) + pprint(DiskSerial) + pprint(DiskName) + pprint(DiskCapacity) + dis['DiskNum'],dis['DiskProduct'],dis['DiskVendor'],dis['DiskCapacity'],dis['DiskName'],dis['DiskFw'],dis['DiskSerial'] = str(disknum),DiskProduct.rstrip("<1_1>"),DiskVendor.rstrip("<1_1>"),DiskCapacity.rstrip("<1_1>"),DiskName.rstrip("<1_1>"),DiskFw.rstrip("<1_1>"),DiskSerial.rstrip("<1_1>") + return dis + + + + # writed by kobe 20170318 + def get_network_obsolete(self): +# net = {'NetNum': 2, 'NetSerial': '00:23:81:21:e4:0b', 'NetProduct': '82574L Gigabit Network Connection', 'NetLogicalname': 'enp1s0', 'NetDrive': 'e1000e', 'NetIp': 'unknown', 'NetType': 'Ethernet interface', 'NetVendor': 'Intel Corporation', 'NetBusinfo': 'pci@0000:01:00.0'} +# return net + net = {} + NetNum = 0 + NetType,NetProduct,NetVendor,NetDrive,NetBusinfo,NetLogicalname,NetSerial,NetIp = '','','','','','','','' +# fp=os.popen("ifconfig -s|grep -v Iface|grep -v lo|awk '{print $1}' | wc -l"); +# NetNum = int(fp.read().strip('\n')) +# net['NetNum'] = NetNum +# fp.close() + try: + fp = os.popen("lshw -C network"); + lines = fp.readlines() + fp.close() + if lines: + for line in lines: + if ":" in line: + line = line.strip() + if "description:" in line: + tmp = re.findall('description: (.*)', line) + NetNum += 1 + if tmp[0] in [None, '']: + if NetType: + NetType += "<1_1>" + "unknown" + else: + NetType = "unknown" + else: + if NetType: + NetType += "<1_1>" + tmp[0] + else: + NetType = tmp[0] + elif "product:" in line: + tmp = re.findall('product: (.*)', line) + if tmp[0] in [None, '']: + if NetProduct: + NetProduct += "<1_1>" + "unknown" + else: + NetProduct = "unknown" + else: + if NetProduct: + NetProduct += "<1_1>" + tmp[0] + else: + NetProduct = tmp[0] + elif "vendor:" in line: + tmp = re.findall('vendor: (.*)', line) + if tmp[0] in [None, '']: + if NetVendor: + NetVendor += "<1_1>" + "unknown" + else: + NetVendor = "unknown" + else: + if NetVendor: + NetVendor += "<1_1>" + tmp[0] + else: + NetVendor = tmp[0] + elif "bus info:" in line: + tmp = re.findall('bus info: (.*)', line) + if tmp[0] in [None, '']: + if NetBusinfo: + NetBusinfo += "<1_1>" + "unknown" + else: + NetBusinfo = "unknown" + else: + if NetBusinfo: + NetBusinfo += "<1_1>" + tmp[0] + else: + NetBusinfo = tmp[0] + elif "serial:" in line: + tmp = re.findall('serial: (.*)', line) + if tmp[0] in [None, '']: + if NetSerial: + NetSerial += "<1_1>" + "unknown" + else: + NetSerial = "unknown" + else: + if NetSerial: + NetSerial += "<1_1>" + tmp[0] + else: + NetSerial = tmp[0] + elif "logical name:" in line: + tmp = re.findall('logical name: (.*)', line) + if tmp[0] in [None, '']: + if NetLogicalname: + NetLogicalname += "<1_1>" + "unknown" + else: + NetLogicalname = "unknown" + if NetIp: + NetIp += "<1_1>" + "unknown" + else: + NetIp = "unknown" + if NetDrive: + NetDrive += "<1_1>" + "unknown" + else: + NetDrive = "unknown" +# if NetType: +# NetType += "<1_1>unknown" +# else: +# NetType = "unknown" + else: + if NetLogicalname: + NetLogicalname += "<1_1>" + tmp[0] + else: + NetLogicalname = tmp[0] +# if tmp[0].startswith('veth') or tmp[0].startswith('virbr'): +# if NetType: +# NetType += "<1_1>VNIC" +# else: +# NetType = "VNIC" +# else: +# if NetType: +# NetType += "<1_1>unknown" +# else: +# NetType = "unknown" + ip = get_interface_ip(tmp[0]) + if ip in [None, '']: + if NetIp: + NetIp += "<1_1>" + "unknown" + else: + NetIp = "unknown" + else: + if NetIp: + NetIp += "<1_1>" + ip + else: + NetIp = ip + driver = get_interface_driver(tmp[0])#enp0s25 wlp3s0 + if driver in [None, '']: + if NetDrive: + NetDrive += "<1_1>" + "unknown" + else: + NetDrive = "unknown" + else: + if NetDrive: + NetDrive += "<1_1>" + driver + else: + NetDrive = driver + +# for line in lines: +# if ":" in line: +# line = line.strip() +# if "description:" in line: +# tmp = re.findall('description: (.*)', line) +# if tmp[0] in [None, '']: +# if NetType: +# NetType += "<1_1>" + "unknown" +# else: +# NetType = "unknown" +# else: +# if NetType: +# NetType += "<1_1>" + tmp[0] +# else: +# NetType = tmp[0] + net['NetNum'] = NetNum + net['NetType'],net['NetProduct'],net['NetVendor'],net['NetBusinfo'],net['NetLogicalname'],net['NetSerial'],net['NetIp'],net['NetDrive'] = NetType.rstrip("<1_1>"), NetProduct.rstrip("<1_1>"),NetVendor.rstrip("<1_1>"),NetBusinfo.rstrip("<1_1>"),NetLogicalname.rstrip("<1_1>"),NetSeriali.rstrip("<1_1>"),NetIp.rstrip("<1_1>"), NetDrive.rstrip("<1_1>") + return net + except Exception as e: + return net +# print NetType +# print NetProduct +# print NetVendor +# print NetBusinfo +# print NetSerial +# print NetLogicalname +# print NetIp +# print NetDrive + + #write by hb at 20170516 for 20x_server + def get_network(self): + net = {} + netflag = "" + NetType,NetProduct,NetVendor,NetDriver,NetBusinfo,NetLogicalname,NetSerial,NetIp = '','','','','','','','' + + try: + #fp = open("/home/ice/networkinfo") + #allinfo = fp.read() + #fp.close() + + fp = os.popen("lshw -C network"); + allinfo = fp.read() + infolist = allinfo.split("*-network")[1:] + + for singleinfo in infolist: + infodict = {} + singleinfolist = [ tmp.strip() for tmp in singleinfo.split("\n") ] + netflag = singleinfolist[0] + for info in singleinfolist[1:]: + if info: + tmp = info.split(": ") + pprint(tmp) + infodict.setdefault(tmp[0], tmp[1]) + pprint(infodict) + + NetType += ( infodict.get("description", "unknown") + "<1_1>" ) + + NetProduct += ( infodict.get("product", "unknown") + "<1_1>" ) + + NetVendor += ( infodict.get("vendor", "unknown") + "<1_1>") + + NetBusinfo += ( infodict.get("bus info", "unknown") + "<1_1>" ) + + NetSerial += ( infodict.get("serial", "unknown") + "<1_1>") + + NetLogicalname += ( infodict.get("logical name", "unknown") + "<1_1>") + NetIp += ( get_interface_ip(infodict.get("logical name", "unknown")) + "<1_1>") + NetDriver += (get_interface_driver(infodict.get("logical name", "unknown")) + "<1_1>") + + net['NetNum'] = len(infolist) + net['NetType'],net['NetProduct'],net['NetVendor'],net['NetBusinfo'],net['NetLogicalname'],net['NetSerial'],net['NetIp'],net['NetDrive'] = NetType.rstrip("<1_1>"), NetProduct.rstrip("<1_1>"),NetVendor.rstrip("<1_1>"),NetBusinfo.rstrip("<1_1>"),NetLogicalname.rstrip("<1_1>"),NetSerial.rstrip("<1_1>"),NetIp.rstrip("<1_1>"), NetDriver.rstrip("<1_1>") + except Exception as e: + pass + return net + + + #kobe:测试发现服务器上有个网卡名为:lxcbr0,其通过lspci -vvv找不到对应的信息 + def get_network_test(self): + net = {} + NetNum = 0 + #NetList = [] + NetProduct,NetVendor,NetDrive,NetBusinfo,NetLogicalname,NetSerial,NetIp,NetLink,NetCapacity,Subsystem = '','','','','','','','','','' + fp=os.popen("ifconfig -s|grep -v Iface|grep -v lo|awk '{print $1}'") + interface = fp.readlines() + fp.close() + ip_dic={} + for name in interface: + name = name.strip() + if name is not "lo":#20161228 + mac = get_interface_mac(name) + if NetSerial: + NetSerial += "<1_1>" + mac + else: + NetSerial = mac + ip = get_interface_ip(name) + if NetIp: + NetIp += "<1_1>" + ip + else: + NetIp = ip + NetNum += 1 + #NetList.append(name) + if NetLogicalname: + NetLogicalname += "<1_1>" + name + else: + NetLogicalname = name + + n = os.popen('lspci -vvv') + network = n.read() + n.close() + bus = re.findall('Ethernet controller: ', network) + if bus: + #tmp =network network[network.index('Ethernet controller: ')-8:] + #network = network[network.index('Ethernet controller: ')+len('Ethernet controller: '):] + #addr = network.index('Ethernet controller: ') + #network = network[:network.index('Ethernet controller: ')-1] + #print network + while bus: + st = network[:network.index('Ethernet controller: ')-1] + tmp = network[st.rindex('\n')+1:network.index('Ethernet controller: ')-1] + if tmp: + if NetBusinfo: + NetBusinfo += "<1_1>" + 'pci@0000:' + tmp + else: + NetBusinfo = 'pci@0000:' + tmp + network = network[network.index('Ethernet controller: '):] + tmp = network[network.index('Ethernet controller: ')+len('Ethernet controller: '):network.index('\n')] + if tmp: + if NetVendor: + NetVendor += "<1_1>" + self.get_url('', tmp) + else: + NetVendor = self.get_url('', tmp) + if NetProduct: + NetProduct += "<1_1>" + tmp + else: + NetProduct = tmp + network = network[network.index('Ethernet controller: ')+len('Ethernet controller: '):] + idx = network[network.index('Subsystem: '):] + tmp = idx[idx.index('Subsystem: ')+len('Subsystem: '):idx.index('\n')] + if tmp: + if Subsystem: + Subsystem += "<1_1>" + tmp + else: + Subsystem = tmp + idx = network[network.index('Kernel driver in use: '):] + tmp = idx[idx.index('Kernel driver in use: ')+len('Kernel driver in use: '):idx.index('\n')] + if tmp: + if NetDrive: + NetDrive += "<1_1>" + tmp + else: + NetDrive = tmp + bus = re.findall('Ethernet controller: ', network) + #if network : + # if re.findall('Ethernet controller: ',network): + # tmp = network[network.index('Ethernet controller: ')-8:] + # NetBusinfo = 'pci@0000:' + tmp[:8] + # pro = re.findall('Ethernet controller: (.*)',tmp) + # NetProduct = pro[0] + # NetVendor = self.get_url('',pro[0]) + # tmp = re.findall('Kernel driver in use: (.*)',tmp) + # NetDrive = tmp[0] + #n = os.popen('ifconfig eth') + #network = n.read() + #n.close() + #if network : + # NetLogicalname = network[:4] + # tmp = re.findall("\w\w:\w\w:\w\w:\w\w:\w\w:\w\w",network) + # if tmp: + # NetSerial = tmp[0] + # tmp = re.findall("inet(.*)",network) + # if tmp: + # ip = tmp[0][tmp[0].index(':')+len(':'): ] + # ip = ip[: ip.index(' ')] + # NetIp = ip + # modify by kobe(LP: #1310882 ) + # -------------------get eth interface and ip address------------------- + #fp=os.popen("ifconfig -s|grep -v Iface|grep -v lo|awk '{print $1}'") + #interface=fp.readlines() + #fp.close() + #print interface + #ip_dic={} + #devName = '' + #for name in interface: + # name=name.strip() + # if devName: + # devName += "<1_1>" + name + # else: + # devName = name + # # remove 'wlan' + # #if name.startswith('eth'): + # if name is not "lo":#20161228 + #print NetList + #for netItem in NetList: + # try: + # sk = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + # ipaddr=socket.inet_ntoa(fcntl.ioctl( + # sk.fileno(), + # 0x8915, # SIOCGIFADDR + # struct.pack('256s', netItem[:15]) + # )[20:24]) + # ip_dic[netItem]=ipaddr + # except Exception as e: + # print e + #print ip_dic + #if len(ip_dic) == 0: + # #NetLogicalname = 'N/A' + # NetIp = 'N/A' + #else: + # #NetLogicalname = ip_dic.keys()[0] + # NetIp = ip_dic.values()[0] + # -------------------get mac address------------------- + #mac_addr = uuid.UUID(int = uuid.getnode()).hex[-12:] + #NetSerial = ":".join([mac_addr[e:e+2] for e in range(0,11,2)]) + try: + n = os.popen('mii-tool -v') + network = n.read() + n.close() + if network : + tmp = re.findall("basic status: (.*)",network) + if tmp: + NetLink = tmp[0] + tmp = re.findall('capabilities: (\d*)',network) + if tmp: + NetCapacity = tmp[0] + except Exception, e: + print e + WlanProduct,WlanVendor,WlanBusinfo,WlanLogicalname,WlanSerial,WlanIp,WlanDrive = '','','','','','','' + n = os.popen('lspci -vvv') + wlan = n.read() + n.close() + if wlan : + if re.findall('Network controller: ',wlan): + tmp = wlan[wlan.index('Network controller: ') - 8:] + WlanBusinfo = 'pci@0000:' + tmp[:8] + pro = re.findall('Network controller: (.*)',tmp) + WlanProduct = pro[0] + WlanVendor = self.get_url('',pro[0]) + tmp = re.findall('Kernel driver in use: (.*)',tmp) + WlanDrive = tmp[0] + n = os.popen('ifconfig wlan') + wlan = n.read() + n.close() + if wlan: + WlanLogicalname = wlan[:5] + tmp = re.findall("\w\w:\w\w:\w\w:\w\w:\w\w:\w\w",wlan) + if tmp: + WlanSerial = tmp[0] + tmp = re.findall("inet(.*)",wlan) + if tmp: + ip = tmp[0][tmp[0].index(':')+len(':'):] + ip = ip[: ip.index(' ')] + WlanIp = ip + net['NetNum'] = NetNum + net['NetProduct'],net['NetVendor'],net['NetBusinfo'],net['NetLogicalname'],net['NetSerial'],net['NetIp'],net['NetLink'],net['NetCapacity'],net['NetDrive'],net['WlanProduct'],net['WlanVendor'],net['WlanBusinfo'],net['WlanLogicalname'],net['WlanSerial'],net['WlanIp'],net['WlanDrive'] = self.strip(NetProduct),self.strip(NetVendor),self.strip(NetBusinfo),self.strip(NetLogicalname),self.strip(NetSerial),self.strip(NetIp),self.strip(NetLink),self.strip(NetCapacity),self.strip(NetDrive),self.strip(WlanProduct),self.strip(WlanVendor),self.strip(WlanBusinfo),self.strip(WlanLogicalname),self.strip(WlanSerial),self.strip(WlanIp),self.strip(WlanDrive) + return net + + def get_multimedia(self): + Mul = {} + MulNum = 0 + MulProduct,MulVendor,MulBusinfo,MulDrive = '','','','' + n = os.popen('lspci -vvv') + multimedia = n.read() + n.close() + if multimedia: + if re.findall('Audio device:',multimedia): + tmp = multimedia[multimedia.index('Audio device:')- 8:] + multimedia = tmp[30:] + if MulBusinfo: + MulBusinfo += "<1_1>"+ 'pci@0000:' + tmp[ :8] + else : + MulBusinfo = 'pci@0000:' + tmp[ :8] + if MulProduct: + pro = re.findall('Audio device: (.*)',tmp) + MulProduct += "<1_1>" + pro[0] + MulVendor += "<1_1>" + self.get_url('',self.strip(pro[0])) + else : + pro = re.findall('Audio device: (.*)',tmp) + MulProduct = pro[0] + MulVendor = self.get_url('',self.strip(pro[0])) + MulNum += 1 + tmp = re.findall('Kernel driver in use: (.*)',tmp) + if MulDrive: + MulDrive += "<1_1>" + tmp[0] + else : + MulDrive = tmp[0] + elif re.findall('Multimedia audio controller:',multimedia) : + tmp = multimedia[multimedia.index('Multimedia audio controller:')- 8:] + multimedia = tmp[30:] + if MulBusinfo: + MulBusinfo += "<1_1>"+ 'pci@0000:' + tmp[ :8] + else : + MulBusinfo = 'pci@0000:' + tmp[ :8] + if MulProduct: + pro = re.findall('Multimedia audio controller: (.*)',tmp) + MulProduct += "<1_1>" + pro[0] + MulVendor += "<1_1>" + self.get_url('',self.strip(pro[0])) + else : + pro = re.findall('Multimedia audio controller: (.*)',tmp) + MulProduct = pro[0] + MulVendor = self.get_url('',self.strip(pro[0])) + MulNum += 1 + tmp = re.findall('Kernel driver in use: (.*)',tmp) + if MulDrive: + MulDrive += "<1_1>" + tmp[0] + else : + MulDrive = tmp[0] + Mul['MulNum'],Mul['MulProduct'],Mul['MulVendor'],Mul['MulBusinfo'],Mul['MulDrive'] = self.strip(str(MulNum)),self.strip(MulProduct),self.strip(MulVendor),self.strip(MulBusinfo),self.strip(MulDrive) + return Mul + + def get_dvd(self): + dvd = {} + Dvdnum = 0 + DvdProduct,DvdVendor,DvdName,DvdFw,DvdSerial = '','','','','' + n = os.popen("hdparm -i /dev/cdrom") + cdrom = n.read() + n.close() + if cdrom: + tmp = re.findall("Model=(.*), F",cdrom) + if tmp: + DvdProduct = tmp[0] + DvdVendor = self.get_url('',self.strip(DvdProduct)) + if not DvdVendor : + pro = DvdProduct[:DvdProduct.index('DVD')] + DvdVendor = self.get_url('',self.strip(pro)) + if not DvdVendor : + pro = DvdProduct[:DvdProduct.index('CD')] + DvdVendor = self.get_url('',self.strip(pro)) + tmp = re.findall("FwRev=(.*), ",cdrom) + if tmp : + DvdFw = tmp[0] + tmp = re.findall("SerialNo=(.*)",cdrom) + if tmp : + DvdSerial = tmp[0] + DvdName = '/dev/cdrom' + Dvdnum += 1 + dvd['Dvdnum'],dvd['DvdProduct'],dvd['DvdVendor'],dvd['DvdName'],dvd['DvdFw'],dvd['DvdSerial'] = self.strip(str(Dvdnum)),self.strip(DvdProduct),self.strip(DvdVendor),self.strip(DvdName),self.strip(DvdFw),self.strip(DvdSerial) + return dvd + + def get_usb(self): + usb = {} + Usbnum = 0 + UsbVendor, UsbBusinfo, UsbID, UsbProduct, bcdUsb, UsbMaxpower = '','','','','','' + n = os.popen("lsusb -v") + usbinfo = n.read() + n.close() + bus = re.findall('Bus 0',usbinfo) + if bus: + usbinfo = usbinfo[usbinfo.index('Bus 0')+len('Bus 0'):] + while bus: + usbstr = usbinfo[:usbinfo.index('Device Status:')] + flag = usbstr[usbstr.index('\n')-8:usbstr.index('\n')] + if not flag == 'root hub' : + if UsbBusinfo: + UsbBusinfo += "<1_1>" + 'Bus 0'+usbstr[:2] + else : + UsbBusinfo = 'Bus 0'+usbstr[:2] + + tmp = re.findall('idVendor(.*)',usbstr) + vendor = tmp[0].lstrip() + if UsbVendor: + UsbVendor += "<1_1>" + vendor[7:] + else : + UsbVendor = vendor[7:] + + tmp = re.findall('idProduct(.*)',usbstr) + product = tmp[0].lstrip() + if UsbProduct: + UsbProduct += "<1_1>" + product[7:] + else : + UsbProduct = product[7:] + + if UsbID: + UsbID += "<1_1>" + vendor[2:6] + ':' + product[2:6] + else : + UsbID = vendor[2:6] + ':' + product[2:6] + + tmp = re.findall('bcdUSB(.*)',usbstr) + if bcdUsb: + bcdUsb += "<1_1>" + tmp[0].lstrip() + else : + bcdUsb = tmp[0].lstrip() + + tmp = re.findall('MaxPower(.*)',usbstr) + if UsbMaxpower: + UsbMaxpower += "<1_1>" + tmp[0].lstrip() + else : + UsbMaxpower = tmp[0].lstrip() + Usbnum += 1 + bus = re.findall('Bus 0',usbinfo) + if bus : + usbinfo = usbinfo[usbinfo.index('Bus 0')+len('Bus 0'):] + usb['Usbnum'],usb['UsbVendor'],usb['UsbProduct'],usb['UsbBusinfo'],usb['UsbID'],usb['bcdUsb'],usb['UsbMaxpower'] = self.strip(str(Usbnum)),self.strip(UsbVendor),self.strip(UsbProduct),self.strip(UsbBusinfo),self.strip(UsbID),self.strip(bcdUsb),self.strip(UsbMaxpower) + return usb + + def judge_sensors_exists(self): + if os.path.exists("/usr/bin/sensors"): + r = os.popen("/usr/bin/sensors") + text = r.read() + r.close() + if "w83795g-i2c-1-2c" in text or "w83795adg-i2c-1-2c" in text: + return True + else: + return False + return False + + def get_sensors(self): +# origin = {"IN0": "0.75V", #"内存参考电压" +# "IN2": "1.0V", #"SATA控制器电压" +# "IN3": "1.5V", #"内存电压", +# "IN5": "1.8V", #"CPU管脚电压", +# "IN6": "1.25 V", #"桥片电压", +# "TR1": "1.65 V", #"ATX_3V3", +# "TR2": "1.67 V", #"ATX_5V", +# "TR3": "1.0 V", #"ATX_12V", +# "TR4": "1.0 V", #"CPU核电压", +# "TR5": "", #"CPU温度", +# "TR6": "", #"主板温度" +# "FANIN1": "" #"CPU风扇转速" +# } + origin = {"IN0": "", #"内存参考电压" + "IN2": "", #"SATA控制器电压" + "IN3": "", #"内存电压", + "IN5": "", #"CPU管脚电压", + "IN6": "", #"桥片电压", + "TR1": "", #"ATX_3V3", + "TR2": "", #"ATX_5V", + "TR3": "", #"ATX_12V", + "TR4": "", #"CPU核电压", + "TR5": "", #"CPU温度", + "TR6": "", #"主板温度" + "FANIN1": "" #"CPU风扇转速" + } + + opposite = {"IN0": "in0", + "IN2": "in2", + "IN3": "in3", + "IN5": "in5", + "IN6": "in6", + "TR1": "in17", + "TR2": "in18", + "TR3": "in19", + "TR4": "in20", + "TR5": "temp5", + "TR6": "temp6", + "FANIN1": "fan1" + } + + product = {"in17": 2, + "in18": 3, + "in19": 12, + } + + status, output = commands.getstatusoutput("sensors") + for line in output.split("\n"): + for key in opposite.items(): + if line.split(":")[0] == key[1]: + if key[1] in ["in17", "in18", "in19"]: + value = (line.split(":")[1]).split("(")[0].strip() + origin[key[0]] = value[0:1] + str(float(value[1:-1]) * product[key[1]]) + " V" + break + if key[1] in ["temp5", "temp6"]: + origin[key[0]] = ((line.split(":")[1]).split("(")[0].strip())[0:5] + u"℃ " + break + origin[key[0]] = (line.split(":")[1]).split("(")[0].strip() + break + return origin + +if __name__ == "__main__": + pass + #cc = DetailInfo() + #cc.ctoascii('a') + #cc.strip('a') + #cc.get_url('a','a') + #cc.get_computer() + #cc.get_cpu() + #cc.get_board() + #cc.get_memory() + #cc.get_monitor() + #cc.get_disk() + #cc.get_network() + #cc.get_multimedia() + #cc.get_dvd() + #cc.get_usb() + #pprint(cc.get_sensors()) diff --git a/backends/youker-assistant-daemon/src/policykit/__init__.py b/backends/youker-assistant-daemon/src/policykit/__init__.py new file mode 100644 index 0000000..9c6ed8d --- /dev/null +++ b/backends/youker-assistant-daemon/src/policykit/__init__.py @@ -0,0 +1 @@ +UK_ACTION_YOUKER = 'com.ubuntukylin.youker.action' diff --git a/backends/youker-assistant-daemon/src/policykit/dbusproxy.py b/backends/youker-assistant-daemon/src/policykit/dbusproxy.py new file mode 100644 index 0000000..eaa176b --- /dev/null +++ b/backends/youker-assistant-daemon/src/policykit/dbusproxy.py @@ -0,0 +1,71 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2007-2011 Tualatrix Chou +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import dbus +import dbus.service +import logging +log = logging.getLogger("DbusProxy") + +INTERFACE = 'com.ubuntukylin.youker' +UKPATH = '/' +SHOWED = False + +def show_message(*args): + from dialogs import ErrorDialog + title = 'Daemon start failed' + message = ('Youker Assisant systemdaemon didn\'t start correctly.\n' + 'If you want to help developers debugging, try to run "sudo /usr/lib/python2.7/dist-packages/youker-assistant-daemon/src/start_systemdbus.py" in a terminal.') + ErrorDialog(title=title, message=message).launch() + +def nothing(*args): + return None + +class DbusProxy: + try: + __system_bus = dbus.SystemBus() + __object = __system_bus.get_object(INTERFACE, UKPATH) + except Exception, e: + __object = None + + def __getattr__(self, name): + global SHOWED + try: + return self.__object.get_dbus_method(name, dbus_interface=self.INTERFACE) + except Exception, e: + #log.error(e) + if not SHOWED: + SHOWED = True + return show_message + else: + return nothing + + def get_object(self): + return self.__object + +class AccessDeniedException(dbus.DBusException): + '''This exception is raised when some operation is not permitted.''' + + _dbus_error_name = 'com.ubuntukylin.youker.AccessDeniedException' + +def init_dbus(dbus_iface=INTERFACE, dbus_path=UKPATH): + '''init dbus''' + proxy = DbusProxy() + return proxy + +if __name__ == '__main__': + print init_dbus() diff --git a/backends/youker-assistant-daemon/src/policykit/dialogs.py b/backends/youker-assistant-daemon/src/policykit/dialogs.py new file mode 100644 index 0000000..be1c294 --- /dev/null +++ b/backends/youker-assistant-daemon/src/policykit/dialogs.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# Copyright (C) 2007-2011 Tualatrix Chou +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import thread + +from gi.repository import GObject, Gtk, Gdk + +class BaseDialog(Gtk.MessageDialog): + def __init__(self, **kwargs): + title = kwargs.pop('title', '') + message = kwargs.pop('message', '') + + GObject.GObject.__init__(self, **kwargs) + + if title: + self.set_title(title) + + if message: + self.set_content(message) + + def set_title(self, title): + self.set_markup('%s' % title) + + def set_content(self, message): + if self.get_property('text'): + self.format_secondary_markup(message) + else: + self.set_markup(message) + + def launch(self): + self.run() + self.destroy() + + def add_option_button(self, button): + '''Add an option button to the left. It will not grab the default response.''' + vbox = self.get_content_area() + hbuttonbox = vbox.get_children()[-1] + + hbox = Gtk.HBox(spacing=12) + vbox.pack_start(hbox, False, False, 0) + vbox.remove(hbuttonbox) + + new_hbuttonbox = Gtk.HButtonBox() + new_hbuttonbox.set_layout(Gtk.ButtonBoxStyle.START) + new_hbuttonbox.pack_start(button, True, True, 0) + + hbox.pack_start(new_hbuttonbox, True, True, 0) + hbox.pack_start(hbuttonbox, True, True, 0) + + hbuttonbox.get_children()[-1].grab_focus() + + vbox.show_all() + + +class ErrorDialog(BaseDialog): + def __init__(self, title='', message='', parent=None, + type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK): + BaseDialog.__init__(self, title=title, message=message, + parent=parent, message_type=type, buttons=buttons) diff --git a/backends/youker-assistant-daemon/src/sessiondbus/__init__.py b/backends/youker-assistant-daemon/src/sessiondbus/__init__.py new file mode 100644 index 0000000..013e4b7 --- /dev/null +++ b/backends/youker-assistant-daemon/src/sessiondbus/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/backends/youker-assistant-daemon/src/sessiondbus/common.py b/backends/youker-assistant-daemon/src/sessiondbus/common.py new file mode 100644 index 0000000..8fb34df --- /dev/null +++ b/backends/youker-assistant-daemon/src/sessiondbus/common.py @@ -0,0 +1,153 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# +# Author: Kobe Lee +# Maintainer: Ubuntu Kylin +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os, sys +import urllib2 +import platform +import re +import subprocess +import commands + +BOOL_TYPE = 1 +INT_TYPE = 2 +DOUBLE_TYPE = 3 +STRING_TYPE = 4 + +str_agent = [] +LEN_AGENT = 10 + +str_agent.append('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; Media Center PC 6.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C)') + +str_agent.append('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; msn OptimizedIE8;ZHCN)') + +str_agent.append('Mozilla/5.0 (X11; Linux x86_64; rv:2.2a1pre) Gecko/20110324 Firefox/4.2a1pre') + +str_agent.append('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.0b8pre) Gecko/20101213 Firefox/4.0b8pre') + +str_agent.append('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; Alexa Toolbar)') + +str_agent.append('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.53 Safari/534.30') + +str_agent.append('Mozilla/5.0 (X11; U;Linux i686; zh-CN;rv:1.2.3.4) Gecko/') + +str_agent.append('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; Alexa Toolbar; SE 2.X MetaSr 1.0)') + +str_agent.append('Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.4 (KHTML, like Gecko) Maxthon/3.0.6.27 Safari/532.4') + +str_agent.append('Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/34.0.1847.116 Chrome/34.0.1847.116 Safari/537.36') + +ubuntukylin_distrowatch = 'http://distrowatch.com/table.php?distribution=ubuntukylin' +distrowatch = 'http://distrowatch.com/' + +def get_distro_info(): + ufpath = '/etc/ubuntukylin-release' + if(os.path.exists(ufpath) and os.path.isfile(ufpath)): + uf = open(ufpath) + lines = uf.readlines() + rtn = [] + for line in lines: + kv = line.split('=') + if (kv[0] == 'DISTRIB_ID'): + v = kv[1] + rtn.append(v[:-1]) + if (kv[0] == 'DISTRIB_RELEASE'): + v = kv[1] + rtn.append(v[:-1]) + uf.close() + return rtn + else: + dist = platform.dist() + distname = dist[0] + distversion = dist[1] + return [distname, distversion] + +#def get_machine_id(): +# fpath = '/var/lib/dbus/machine-id' +# if(os.path.exists(fpath) and os.path.isfile(fpath)): +# f = open(fpath, 'r') +# id = f.read() +# f.close() +# id = id.replace('\n','') +# if(id == ''): +# return 'unknown' +# else: +# return id +# else: +# return 'unknown' + +def get_ip_again(): + ret = '' + url = "http://members.3322.org/dyndns/getip" + try: + fp = urllib2.urlopen(url, timeout=5) + souce = fp.read() + if not isinstance(souce, str): + souce = str(souce) + fp.close() + ret = souce.replace('\n', '') + except: + print >> sys.stderr, 'get_ip failed!' + return ret + +def get_ip(): + ret = '' + url = "http://iframe.ip138.com/ic.asp" + try: + fp = urllib2.urlopen(url, timeout=5) + souce = fp.read().decode("GB2312") + fp.close() + ret = re.findall("
(.*)
", souce)[0].encode("UTF-8") + except: + ret = get_ip_again() + return ret + + +def get_run_command(pkgname): + fd = os.popen('find /usr/share/applications/ -name "%s.desktop" | xargs grep "Exec"' %pkgname) + exc = fd.read() + fd.close() + command = [''] + # 截取运行指令部分 + if exc: + command = re.findall('Exec=(.*)',exc) + # 有些软件Exec后面会有%U %f等,进行过滤 + if re.findall(' ',command[0]): + command = re.findall('(.*) ',command[0]) + #split the command to prevent the error: "OSError: [Errno 2] 没有那个文件或目录" + fullcmd = command[0] + if fullcmd: + fullcmd = command[0].split() + return fullcmd + +def run_app(pkgname): + cmd = get_run_command(pkgname) + p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) + +def get_output(cmd): + '''status =0 : success''' + status, output = commands.getstatusoutput(cmd) + if status: raise + return output + +if __name__ == '__main__': + ip = get_ip() + print ip diff --git a/backends/youker-assistant-daemon/src/sessiondbus/daemon.py b/backends/youker-assistant-daemon/src/sessiondbus/daemon.py new file mode 100644 index 0000000..c16132a --- /dev/null +++ b/backends/youker-assistant-daemon/src/sessiondbus/daemon.py @@ -0,0 +1,2220 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import sys +reload(sys) +sys.setdefaultencoding('utf8') +import os +import glob +import fcntl +import shutil +import logging +import tempfile +import subprocess +import commands +import re +from subprocess import PIPE +import apt +import apt_pkg +import dbus +import dbus.service +import dbus.mainloop.glib +import time +import threading +import platform +import cleaner +from autostartmanage import autostartmanage +#import pywapi +import urllib2, urllib +from urllib import urlencode +from xml.dom.minidom import parseString +import re +import json +import locale +import aptsources.sourceslist + +import datetime +HOME = os.path.expandvars('$HOME') + +#import mechanize +#import cookielib +#import random +#from BeautifulSoup import BeautifulSoup + + +from beautify.desktop import Desktop +from beautify.unity import Unity +from beautify.theme import Theme +from beautify.system import System +from beautify.sound import Sound +from beautify.filemanager import FileManager +#from beautify.cloudconfig import CloudConfig +from sysinfo import Sysinfo +#from camera.capture import Capture +#from weather.weatherinfo import WeatherInfo +#from weather.yahoo import YahooWeather +from common import * +#from unzip import unzip_resource +#from piston_mini_client import APIError +import httplib2 +#from weather.piston import WeatherPistonAPI +#MySever = ("http://service.ubuntukylin.com:8001/weather/api/1.0/") +#WeatherPistonAPI.default_service_root = MySever + +#from piston_remoter import PingBackPistonAPI +#PingBackSever = ("http://servicPingBackPistonAPIe.ubuntukylin.com:8001/youker-assistant/") +#PingBackPistonAPI.default_service_root = PingBackSever +#PINGBACK_SERVER = "http://service.ubuntukylin.com:8001/youker-assistant/" + +#from piston_remoter import ServerPingBackAPI +#WEATHER_SERVER = "http://service.ubuntukylin.com:8001/weather/" + +#from appcollections.monitorball.monitor_ball import MonitorBall + +from sso.ubuntusso import get_ubuntu_sso_backend + +log = logging.getLogger('SessionDaemon') +#from slider.wizard import Wizard + +INTERFACE = "com.ubuntukylin.session" +UKPATH = "/" +POWER_PATH = "/sys/class/power_supply" +BATTERY_PATH = "/sys/class/power_supply/BAT0" +BAT_FILE = "/sys/class/power_supply/BAT0/uevent" + +from gi.repository import Gio as gio +from common import (BOOL_TYPE, INT_TYPE, DOUBLE_TYPE, STRING_TYPE) + +#Depends:gir1.2-gconf-2.0 +#from gi.repository import GConf +#import gconf +#TOPKEY = "/org/mate/panel/toplevels/top/size" +#BOTTOMKEY = "/org/mate/panel/toplevels/bottom/size" + +class SessionDaemon(dbus.service.Object): + def __init__ (self, mainloop): + #self.wizardconf = Wizard() +# self.ip_addr = None + self.distrowatch = [] + self.ubuntukylin_dict = dict() +# self.cloudconf = CloudConfig(self) + self.sysconf = Sysinfo() + self.desktopconf = Desktop() + self.unityconf = Unity() + self.themeconf = Theme() + self.systemconf = System(self) + self.soundconf = Sound() +# self.ballconf = MonitorBall() + self.fileconf = FileManager() +# self.yahooconf = YahooWeather(self) +# self.server = WeatherPistonAPI(service_root=MySever) +# self.premoter = PingBackPistonAPI(service_root=PINGBACK_SERVER) +# self.weatherping = ServerPingBackAPI(service_root=WEATHER_SERVER) +# self.daemonsame = cleaner.SearchTheSame() +# self.daemonlarge = cleaner.ManageTheLarge() +# self.daemonunneed = cleaner.CleanTheUnneed() +# self.daemonoldkernel = cleaner.CleanTheOldkernel() +# self.daemoncache = cleaner.CleanTheCache() +# self.init_mechanize() +# # sso - Robert +# self.sso = get_ubuntu_sso_backend() +# self.sso.connect("whoami", self.slot_whoami_done) +# self.sso.connect("logout", self.slot_logout_successful) +# self.sso.connect("fail",self.slot_login_fail) + self.token = "" + self.user = "" + self.display_name = "" + self.preferred_email = "" + + self.desktop = os.getenv('XDG_CURRENT_DESKTOP') + if self.desktop is None: + self.desktop = os.getenv('XDG_SESSION_DESKTOP') + + # gtk theme + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.interface_settings = gio.Settings.new("org.mate.interface") + else: + self.interface_settings = gio.Settings.new("org.gnome.desktop.interface") + self.interface_settings.connect("changed::gtk-theme", self.gio_settings_monitor, STRING_TYPE) + + # icon + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": +# self.interface_settings = gio.Settings.new("org.mate.interface") + self.interface_settings.connect("changed::icon-theme", self.gio_settings_monitor, STRING_TYPE) + self.background_settings = gio.Settings.new("org.mate.background") + self.background_settings.connect("changed::show-desktop-icons", self.gio_settings_monitor, BOOL_TYPE) + self.desktop_settings = gio.Settings.new("org.mate.caja.desktop") + for key in ("computer-icon-visible", "home-icon-visible", "network-icon-visible", "trash-icon-visible", "volumes-visible"): + self.desktop_settings.connect("changed::%s" % key, self.gio_settings_monitor, BOOL_TYPE) + else: +# self.interface_settings = gio.Settings.new("org.gnome.desktop.interface") + self.interface_settings.connect("changed::icon-theme", self.gio_settings_monitor, STRING_TYPE) + self.background_settings = gio.Settings.new("org.gnome.desktop.background") + self.background_settings.connect("changed::show-desktop-icons", self.gio_settings_monitor, BOOL_TYPE) + self.desktop_settings = gio.Settings.new("org.gnome.nautilus.desktop") + for key in ("home-icon-visible", "network-icon-visible", "trash-icon-visible", "volumes-visible"): + self.desktop_settings.connect("changed::%s" % key, self.gio_settings_monitor, BOOL_TYPE) + + # mouse + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.mouse_settings = gio.Settings.new("org.mate.peripherals-mouse") + self.mouse_settings.connect("changed::cursor-theme", self.gio_settings_monitor, STRING_TYPE) + self.mouse_settings.connect("changed::cursor-size", self.gio_settings_monitor, INT_TYPE) + else: + self.interface_settings.connect("changed::cursor-theme", self.gio_settings_monitor, STRING_TYPE) + self.interface_settings.connect("changed::cursor-size", self.gio_settings_monitor, INT_TYPE) + + # voice + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.sound_settings = gio.Settings.new("org.mate.sound") + else: + self.sound_settings = gio.Settings.new("org.gnome.desktop.sound") + self.sound_settings.connect("changed::theme-name", self.gio_settings_monitor, STRING_TYPE) + self.sound_settings.connect("changed::event-sounds", self.gio_settings_monitor, BOOL_TYPE) + self.sound_settings.connect("changed::input-feedback-sounds", self.gio_settings_monitor, BOOL_TYPE) + + if self.desktop == "Unity": + #unity launcher position + self.unity_launcher_position = gio.Settings.new("com.canonical.Unity.Launcher") + self.unity_launcher_position.connect("changed::launcher-position", self.gio_settings_monitor, STRING_TYPE) + #unity launcher + self.unity_settings = gio.Settings("org.compiz.unityshell", "/org/compiz/profiles/unity/plugins/unityshell/") + self.unity_settings.connect("changed::icon-size", self.gio_settings_monitor, INT_TYPE) + self.unity_settings.connect("changed::launcher-hide-mode", self.gio_settings_monitor, INT_TYPE) + self.unity_settings.connect("changed::launcher-opacity", self.gio_settings_monitor, DOUBLE_TYPE) + self.unity_settings.connect("changed::backlight-mode", self.gio_settings_monitor, INT_TYPE) + #panel + self.datetime_settings = gio.Settings.new("com.canonical.indicator.datetime") + self.datetime_settings.connect("changed::show-seconds", self.gio_settings_monitor, BOOL_TYPE) + self.datetime_settings.connect("changed::show-day", self.gio_settings_monitor, BOOL_TYPE) + self.datetime_settings.connect("changed::show-date", self.gio_settings_monitor, BOOL_TYPE) + #power + self.power_settings = gio.Settings.new("com.canonical.indicator.power") + self.power_settings.connect("changed::icon-policy", self.gio_settings_monitor, STRING_TYPE) + self.power_settings.connect("changed::show-time", self.gio_settings_monitor, BOOL_TYPE) + self.power_settings.connect("changed::show-percentage", self.gio_settings_monitor, BOOL_TYPE) + + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.toplevels_settings = gio.Settings("org.mate.panel.toplevel", "/org/mate/panel/toplevels/top/") + self.toplevels_settings.connect("changed::size", self.gio_settings_monitor_diff, INT_TYPE, "top") + self.toplevels_settings.connect("changed::auto-hide", self.gio_settings_monitor_diff, BOOL_TYPE, "top") + self.bottomlevels_settings = gio.Settings("org.mate.panel.toplevel", "/org/mate/panel/toplevels/bottom/") + self.bottomlevels_settings.connect("changed::size", self.gio_settings_monitor_diff, INT_TYPE, "bottom") + self.bottomlevels_settings.connect("changed::auto-hide", self.gio_settings_monitor_diff, BOOL_TYPE, "bottom") + + # kobe: test GConf notify +## kobekey = "/apps/metacity/general/titlebar_font" +## aa = '/'.join(kobekey.split('/')[0: -1])#/apps/metacity/general +# self.client = GConf.Client.get_default() +## self.client.add_dir('/'.join(TOPKEY.split('/')[0: -1]), GConf.ClientPreloadType.PRELOAD_NONE) +# self.client.add_dir("/org/mate/panel/toplevels/top", GConf.ClientPreloadType.PRELOAD_NONE) +# self.client.notify_add(TOPKEY, self.gio_settings_monitor_diff)#, "top" +## self.client = gconf.client_get_default() +## self.client.add_dir('/'.join(TOPKEY.split('/')[0: -1]), gconf.CLIENT_PRELOAD_NONE) +## self.client.notify_add(TOPKEY, self.gio_settings_monitor_diff, "top") + +# gc = GConf.Client.get_default() +# print gc.get_int('/org/mate/panel/toplevels/top/size') +# gc.set_int('/org/mate/panel/toplevels/top/size', 1) +# print gc.get_int('/org/mate/panel/toplevels/top/size') + + # menubar + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.menubar_settings = gio.Settings.new("org.mate.panel.menubar") + self.menubar_settings.connect("changed::show-applications", self.gio_settings_monitor, BOOL_TYPE) + self.menubar_settings.connect("changed::show-desktop", self.gio_settings_monitor, BOOL_TYPE) + self.menubar_settings.connect("changed::show-icon", self.gio_settings_monitor, BOOL_TYPE) + self.menubar_settings.connect("changed::show-places", self.gio_settings_monitor, BOOL_TYPE) + + # window + self.interface_settings.connect("changed::menus-have-icons", self.gio_settings_monitor, BOOL_TYPE) + if self.desktop == "Unity": + self.gwd_settings = gio.Settings.new("org.compiz.gwd") + self.gwd_settings.connect("changed::mouse-wheel-action", self.gio_settings_monitor, STRING_TYPE) + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.titlebar_settings = gio.Settings.new("org.gnome.desktop.wm.preferences") + else: + self.titlebar_settings = gio.Settings.new("org.gnome.desktop.wm.preferences") + self.titlebar_settings.connect("changed::button-layout", self.gio_settings_monitor, STRING_TYPE) + self.titlebar_settings.connect("changed::action-double-click-titlebar", self.gio_settings_monitor, STRING_TYPE) + self.titlebar_settings.connect("changed::action-middle-click-titlebar", self.gio_settings_monitor, STRING_TYPE) + self.titlebar_settings.connect("changed::action-right-click-titlebar", self.gio_settings_monitor, STRING_TYPE) + + #font + self.interface_settings.connect("changed::font-name", self.gio_settings_monitor, STRING_TYPE) + self.desktop_settings.connect("changed::font", self.gio_settings_monitor, STRING_TYPE) + self.interface_settings.connect("changed::monospace-font-name", self.gio_settings_monitor, STRING_TYPE) + self.interface_settings.connect("changed::document-font-name", self.gio_settings_monitor, STRING_TYPE) + self.titlebar_settings.connect("changed::titlebar-font", self.gio_settings_monitor, STRING_TYPE) + self.interface_settings.connect("changed::text-scaling-factor", self.gio_settings_monitor, DOUBLE_TYPE) + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.font_settings = gio.Settings.new("org.mate.font-rendering") + else: + self.font_settings = gio.Settings.new("org.gnome.settings-daemon.plugins.xsettings") + self.font_settings.connect("changed::hinting", self.gio_settings_monitor, STRING_TYPE) + self.font_settings.connect("changed::antialiasing", self.gio_settings_monitor, STRING_TYPE) + + # touchpad + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.touchpad_settings = gio.Settings.new("org.mate.peripherals-touchpad") + self.touchpad_settings.connect("changed::scroll-method", self.gio_settings_monitor, INT_TYPE) + self.touchpad_settings.connect("changed::touchpad-enabled", self.gio_settings_monitor, BOOL_TYPE) + self.touchpad_settings.connect("changed::horiz-scroll-enabled", self.gio_settings_monitor, BOOL_TYPE) + else: + # 20160119 + if "org.gnome.settings-daemon.peripherals.touchpad" in gio.Settings.list_schemas(): + self.touchpad_settings = gio.Settings.new("org.gnome.settings-daemon.peripherals.touchpad") + self.touchpad_settings.connect("changed::scroll-method", self.gio_settings_monitor, STRING_TYPE) + self.touchpad_settings.connect("changed::touchpad-enabled", self.gio_settings_monitor, BOOL_TYPE) + self.touchpad_settings.connect("changed::horiz-scroll-enabled", self.gio_settings_monitor, BOOL_TYPE) +# release_info = platform.platform() +# if "15.10-wily" not in release_info: +# self.touchpad_settings = gio.Settings.new("org.gnome.settings-daemon.peripherals.touchpad") +# self.touchpad_settings.connect("changed::scroll-method", self.gio_settings_monitor, STRING_TYPE) +# self.touchpad_settings.connect("changed::touchpad-enabled", self.gio_settings_monitor, BOOL_TYPE) +# self.touchpad_settings.connect("changed::horiz-scroll-enabled", self.gio_settings_monitor, BOOL_TYPE) + if self.desktop == "Unity": + self.canonical_interface_settings = gio.Settings.new("com.canonical.desktop.interface") + self.canonical_interface_settings.connect("changed::scrollbar-mode", self.gio_settings_monitor, STRING_TYPE) + + #file manager + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.filemanager_settings = gio.Settings.new("org.mate.caja.preferences") + else: + self.filemanager_settings = gio.Settings.new("org.gnome.nautilus.preferences") + self.filemanager_settings.connect("changed::always-use-location-entry", self.gio_settings_monitor, BOOL_TYPE) + + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.mediahanding_settings = gio.Settings.new("org.mate.media-handling") + else: + self.mediahanding_settings = gio.Settings.new("org.gnome.desktop.media-handling") + self.mediahanding_settings.connect("changed::automount", self.gio_settings_monitor, BOOL_TYPE) + self.mediahanding_settings.connect("changed::automount-open", self.gio_settings_monitor, BOOL_TYPE) + self.mediahanding_settings.connect("changed::autorun-never", self.gio_settings_monitor, BOOL_TYPE) + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.iconview_settings = gio.Settings.new("org.mate.caja.icon-view") + else: + self.iconview_settings = gio.Settings.new("org.gnome.nautilus.icon-view") + self.iconview_settings.connect("changed::thumbnail-size", self.gio_settings_monitor, INT_TYPE) + if self.desktop == "mate" or self.desktop == "MATE" or self.desktop == "ukui" or self.desktop == "UKUI": + self.thumbnail_settings = gio.Settings.new("org.mate.thumbnail-cache") + else: + self.thumbnail_settings = gio.Settings.new("org.gnome.desktop.thumbnail-cache") + self.thumbnail_settings.connect("changed::maximum-age", self.gio_settings_monitor, INT_TYPE) + self.thumbnail_settings.connect("changed::maximum-size", self.gio_settings_monitor, INT_TYPE) + + bus_name = dbus.service.BusName(INTERFACE, bus=dbus.SessionBus()) + dbus.service.Object.__init__(self, bus_name, UKPATH) + self.mainloop = mainloop + +# def gio_settings_monitor_diff(self, client, cnxn_id, entry, params): +# pass + def gio_settings_monitor_diff(self, settings, key, type, diff): + if diff == "top": + if type == BOOL_TYPE and key == "auto-hide": + value = settings.get_boolean(key) + self.notify_boolean("auto-hide-top", value) + elif type == INT_TYPE and key == "size": + value = settings.get_int(key) + self.notify_int("size-top", value) + elif diff == "bottom": + if type == BOOL_TYPE and key == "auto-hide": + value = settings.get_boolean(key) + self.notify_boolean("auto-hide-bottom", value) + elif type == INT_TYPE and key == "size": + value = settings.get_int(key) + self.notify_int("size-bottom", value) + + def gio_settings_monitor(self, settings, key, type): +# value = settings.get_boolean("home-icon-visible")#get_int get_string get_string + if type == BOOL_TYPE: + value = settings.get_boolean(key) + self.notify_boolean(key, value) + elif type == INT_TYPE: + value = settings.get_int(key) + self.notify_int(key, value) + elif type == DOUBLE_TYPE: + value = settings.get_double(key) + self.notify_double(key, value) + elif type == STRING_TYPE: + value = settings.get_string(key) + self.notify_string(key, value) + + @dbus.service.signal(INTERFACE, signature='sb') + def notify_boolean(self, key, value): + pass + + @dbus.service.signal(INTERFACE, signature='si') + def notify_int(self, key, value): + pass + + @dbus.service.signal(INTERFACE, signature='sd') + def notify_double(self, key, value): + pass + + @dbus.service.signal(INTERFACE, signature='ss') + def notify_string(self, key, value): + pass + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_os_release(self): + return platform.platform() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def currently_installed_version(self): + apt_list = [] + cache = apt.Cache() + pkg = cache['youker-assistant'] + installed_version = pkg.installed.version +# print installed_version + if ":" in installed_version: + info = installed_version.split(":") + apt_list.append(info.at(1)) + else: + apt_list.append(installed_version) +# print pkg.installed.version#1:2.0.3-0~704~ubuntu15.04.1 + if len(pkg.versions) == 2: +# print pkg.versions[0].version, pkg.versions[1].version + if pkg.versions[0].version == pkg.versions[1].version: + apt_list.append(pkg.versions[0].version) + apt_list.append(pkg.versions[1].version) + apt_list.append("0") + else: + tmp_installed = '' + tmp_unstalled = '' + if pkg.installed.version == pkg.versions[0].version: + if ":" in pkg.versions[0].version: + tmp_installed = pkg.versions[0].version.split(":").at(1) + else: + tmp_installed = pkg.versions[0].version + if ":" in pkg.versions[1].version: + tmp_unstalled = pkg.versions[1].version.split(":").at(1) + else: + tmp_unstalled = pkg.versions[1].version + if tmp_installed < tmp_unstalled: + apt_list.append(tmp_installed) + apt_list.append(tmp_unstalled) + apt_list.append("1") + elif pkg.installed.version == pkg.versions[1].version: + if ":" in pkg.versions[1].version: + tmp_installed = pkg.versions[1].version.split(":").at(1) + else: + tmp_installed = pkg.versions[1].version + if ":" in pkg.versions[0].version: + tmp_unstalled = pkg.versions[0].version.split(":").at(1) + else: + tmp_unstalled = pkg.versions[0].version + if tmp_installed < tmp_unstalled: + apt_list.append(tmp_installed) + apt_list.append(tmp_unstalled) + apt_list.append("1") + return apt_list + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def run_selected_app(self, pkgname): + run_app(pkgname) + + #---------------------------------conserve energy------------------------------------ + @dbus.service.method(INTERFACE, in_signature='d', out_signature='') + def adjust_screen_gamma(self, gamma): + cmd = "xgamma -gamma " + str(gamma) + print cmd + os.system(cmd) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='d') + def get_screen_gamma(self): +# p = os.popen("xgamma") + status, output = commands.getstatusoutput("xgamma") + gamma_list = output.split(" ") + gamma = gamma_list[len(gamma_list) - 1] + return float(gamma) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_idle_delay_list(self): + return ['60', '120', '180', '300', '600', '1800', '3600', '0'] + + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_current_idle_delay(self): + return self.systemconf.get_current_idle_delay() + + @dbus.service.method(INTERFACE, in_signature='i', out_signature='') + def set_current_idle_delay(self, value): + self.systemconf.set_current_idle_delay(value) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_lock_enabled(self): + return self.systemconf.get_lock_enabled() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='') + def set_lock_enabled(self, value): + self.systemconf.set_lock_enabled(value) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_lock_delay_list(self): + return ['30', '60', '120', '180', '300', '600', '1800', '3600', '0'] + + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_current_lock_delay(self): + return self.systemconf.get_current_lock_delay() + + @dbus.service.method(INTERFACE, in_signature='i', out_signature='') + def set_current_lock_delay(self, value): + self.systemconf.set_current_lock_delay(value) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_sleep_timeout_list(self): + return ['300', '600', '1200', '1800', '3600', '7200', '0'] + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_current_critical_low(self): + return self.systemconf.get_current_critical_low() + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_current_critical_low(self, value): + self.systemconf.set_current_critical_low(value) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_current_lid_battery(self): + return self.systemconf.get_current_lid_battery() + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_current_lid_battery(self, value): + self.systemconf.set_current_lid_battery(value) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_current_lid_ac(self): + return self.systemconf.get_current_lid_ac() + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_current_lid_ac(self, value): + self.systemconf.set_current_lid_ac(value) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_current_sleep_timeout_display_battery(self): + return self.systemconf.get_current_sleep_timeout_display_battery() + + @dbus.service.method(INTERFACE, in_signature='i', out_signature='') + def set_current_sleep_timeout_display_battery(self, value): + self.systemconf.set_current_sleep_timeout_display_battery(value) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_current_sleep_timeout_display_ac(self): + return self.systemconf.get_current_sleep_timeout_display_ac() + + @dbus.service.method(INTERFACE, in_signature='i', out_signature='') + def set_current_sleep_timeout_display_ac(self, value): + self.systemconf.set_current_sleep_timeout_display_ac(value) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_current_sleep_timeout_battery(self): + return self.systemconf.get_current_sleep_timeout_battery() + + @dbus.service.method(INTERFACE, in_signature='i', out_signature='') + def set_current_sleep_timeout_battery(self, value): + self.systemconf.set_current_sleep_timeout_battery(value) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_current_sleep_timeout_ac(self): + return self.systemconf.get_current_sleep_timeout_ac() + + @dbus.service.method(INTERFACE, in_signature='i', out_signature='') + def set_current_sleep_timeout_ac(self, value): + self.systemconf.set_current_sleep_timeout_ac(value) + + + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def check_user(self): + try: + self.sso = get_ubuntu_sso_backend() + self.sso.connect("whoami", self.slot_whoami_done) + self.sso.connect("logout", self.slot_logout_successful) + self.sso.connect("fail",self.slot_login_fail) + # try backend login + self.sso.find_oauth_token() + except ImportError: + print('Initial ubuntu-kylin-sso-client failed, seem it is not installed.') + except Exception, e: + print('Check user failed.') + print e + + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def slot_do_login_account(self): + try: + self.sso.set_show_register(False) + self.sso.get_oauth_token() + except ImportError: + print('Initial ubuntu-kylin-sso-client failed, seem it is not installed.') + except Exception, e: + print('User login failed.') + print e + + # user register + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def slot_do_register(self): + try: + self.sso.set_show_register(True) + self.sso.get_oauth_token() + + except ImportError: + print('Initial ubuntu-kylin-sso-client failed, seem it is not installed.') + except Exception, e: + print('User register failed.') + print e + + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def slot_do_logout(self): + try: + self.sso.clear_token() + + except ImportError: + print('Initial ubuntu-kylin-sso-client failed, seem it is not installed.') + except Exception, e: + print('User logout failed.') + print e + + #update user login status + def slot_whoami_done(self, sso, result): + self.user = result["username"] + self.display_name = result["displayname"] + self.preferred_email = result["preferred_email"] + print 'Login success, username: %s' % self.display_name + self.youkerid_whoami_signal(self.display_name, self.preferred_email) + + def slot_logout_successful(self, sso): + if self.token: + print 'User %s has been logout' % self.display_name + self.token = '' + self.user = '' + self.display_name = '' + self.preferred_email = '' + else: + print 'No user has been login' + self.youkerid_logout_signal() + + def slot_login_fail(self, sso): + print 'Login or logout failed' + self.youkerid_login_fail_signal() + + @dbus.service.signal(INTERFACE, signature='ss') + def youkerid_whoami_signal(self, display_name, preferred_email): + pass + + @dbus.service.signal(INTERFACE, signature='') + def youkerid_logout_signal(self): + pass + + @dbus.service.signal(INTERFACE, signature='') + def youkerid_login_fail_signal(self): + pass + + + + # a dbus method which open folder by kobe + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def open_folder(self, path): + root_path = os.path.expanduser(path) + #if not os.path.isdir(root_path): + # path = os.path.dirname(path) + if os.path.isdir(root_path): + os.system("xdg-open '%s' &" % root_path) + +# def real_get_ip_address(self): +# self.ip_addr = get_ip() +# if self.ip_addr not in (False, None, {}, '', '[]', "['']"): +# self.access_weather('ip_addr', 'kobe') + +# @dbus.service.signal(INTERFACE, signature='b') +# def unzip_signal(self, result): +# pass + +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') +# def unzip_resource_uk_real(self, path): +# value = unzip_resource(path) +# self.unzip_signal(value) + +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='') +# def unzip_resource_uk(self, path): +# t = threading.Thread(target = self.unzip_resource_uk_real, args=(path,)) +# t.start() + + #-----------------------------distrowatch rank----------------------------- + def copy_distrowatch_default_conf(self): + distrowatch_path = HOME + '/.config/ubuntukylin/youker-assistant/distrowatch.conf' + distrowatch_path_uk = HOME + '/.config/ubuntukylin' + distrowatch_path_youker = HOME + '/.config/ubuntukylin/youker-assistant' + if not os.path.isdir(distrowatch_path_uk): + os.makedirs(distrowatch_path_uk) + if not os.path.isdir(distrowatch_path_youker): + os.makedirs(distrowatch_path_youker) + if not os.path.exists(distrowatch_path): + if not os.path.exists(distrowatch_path): + os.mknod(distrowatch_path) + srcFile = '/var/lib/youker-assistant-daemon/distrowatch.conf' + if not os.path.exists(srcFile): + print "error with distrowatch file" + return + else: + open(distrowatch_path, "wb").write(open(srcFile, "rb").read()) + +# def init_mechanize(self): +# #copy distrowatch default file +# self.copy_distrowatch_default_conf() +# # Browser +# self.br = mechanize.Browser() +# # Cookie Jar +# cj = cookielib.LWPCookieJar() +# self.br.set_cookiejar(cj) + +# # Browser options +# self.br.set_handle_equiv(True) +## self.br.set_handle_gzip(True) +# #self.br.set_handle_gzip(False) +# self.br.set_handle_redirect(True) +# self.br.set_handle_referer(True) +# self.br.set_handle_robots(False) +# self.br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) +# index = random.randint(0, LEN_AGENT-1) +# # br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Ubuntu/3.0.1-1.fc9 Firefox/3.0.1'), ('Accept-Language', 'zh-CN,zh;q=0.8,en;q=0.6')] +# self.br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Ubuntu/3.0.1-1.fc9 Firefox/3.0.1')] + +# @dbus.service.signal(INTERFACE, signature='b') +# def distrowatch_ubuntukylin_signal(self, uk_flag): +# pass + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') +# def real_get_ubuntukylin_distrowatch_info(self): +# self.ubuntukylin_dict.clear() +# try: +# r = self.br.open(ubuntukylin_distrowatch) +# html = r.read() +# soup = BeautifulSoup(html) +# except Exception as e: +# self.distrowatch_ubuntukylin_signal(False) +# return +# contents = soup.findAll(name="td", attrs={"class":"TablesTitle"}) +# p = re.compile('<[^>]+>') +## ubuntukylin_dict = dict() +# try: +# result = p.sub(" ", str(contents)) +# aa = result.split('\n') +# # print len(aa) +# for i in range(0, len(aa)): +# if 'Last Update:' in aa[i]: +# start_pos = str(aa[i]).find("Last Update:") +# self.ubuntukylin_dict['lastupdate'] = str(aa[i])[(start_pos+13):].rstrip() +# elif 'OS Type:' in aa[i] and 'Based on:' in aa[i] and 'Origin:' in aa[i]: +# pos1 = str(aa[i]).find("OS Type:") +# pos2 = str(aa[i]).find("Based on:") +# pos3 = str(aa[i]).find("Origin:") +# self.ubuntukylin_dict['ostype'] = str(aa[i])[(pos1+8):pos2].replace(' ', '') +# self.ubuntukylin_dict['basedon'] = str(aa[i])[(pos2+9):pos3].replace(' ', '') +# self.ubuntukylin_dict['origin'] = str(aa[i])[(pos3+7):].replace(' ', '') +# elif 'Architecture:' in aa[i] and 'Desktop:' in aa[i] and 'Category:' in aa[i] and 'Status:' in aa[i] and 'Popularity:' in aa[i] and 'hits per day' in aa[i]: +# pos1 = str(aa[i]).find("Architecture:") +# pos2 = str(aa[i]).find("Desktop:") +# pos3 = str(aa[i]).find("Category:") +# pos4 = str(aa[i]).find("Status:") +# pos5 = str(aa[i]).find("Popularity:") +# pos6 = str(aa[i]).find("hits per day") +# self.ubuntukylin_dict['architecture'] = str(aa[i])[(pos1+13):pos2].replace(' ', '') +# self.ubuntukylin_dict['desktop'] = str(aa[i])[(pos2+8):pos3].replace(' ', '') +# self.ubuntukylin_dict['category'] = str(aa[i])[(pos3+9):pos4].replace(' ', '') +# self.ubuntukylin_dict['status'] = str(aa[i])[(pos4+7):pos5].replace(' ', '') +# self.ubuntukylin_dict['popularity'] = str(aa[i])[(pos5+11):pos6].replace(' ', '') +# elif i==6: +# self.ubuntukylin_dict['description'] = aa[i] +# except Exception, e: +# print 'exception->', e +# self.distrowatch_ubuntukylin_signal(True) +## return ubuntukylin_dict + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') +# def show_ubuntukylin_distrowatch_info(self): +# return self.ubuntukylin_dict + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='') +# def get_ubuntukylin_distrowatch_info(self): +# t = threading.Thread(target = self.real_get_ubuntukylin_distrowatch_info) +# t.start() + +# @dbus.service.signal(INTERFACE, signature='s') +# def distrowatch_all_signal(self, update_rate): +# pass + +# def real_get_distrowatch_url(self): +# self.distrowatch = [] +# update_rate = 'Last 6 months' +# rank_list = [] +# os_list = [] +# today_hit_list = [] +# img_list = [] +# yestoday_hit_list = [] +# try: +# r = self.br.open(distrowatch) +# html = r.read() +# soup = BeautifulSoup(html) +# except Exception as e: +# self.distrowatch_all_signal("") +# return +# p = re.compile('<[^>]+>') +# spiderContents = soup.findAll(name="option", attrs={"selected":"selected"}) +# if len(spiderContents) > 1: +# try: +# result = p.sub("", str(spiderContents[1])) +# update_rate = result +# except Exception, e: +# pass +# else: +# try: +# result = p.sub("", str(spiderContents[0])) +# update_rate = result +# except Exception, e: +# pass +# spiderContents_rank = soup.findAll(name="th", attrs={"class":"phr1"}) +# spiderContents_os = soup.findAll(name="td", attrs={"class":"phr2"}) +# spiderContents_hit = soup.findAll(name="td", attrs={"class":"phr3"}) +# for i in range(0, len(spiderContents_rank)): +# # print spiderContents_rank[i]#96 +# try: +# result = p.sub("", str(spiderContents_rank[i])) +# rank_list.append(result) +# # bb = spiderContents[i].findAll('img', id = 'src') +# # print pa.sub("", str(spiderContents[i])) +# # print bb#[=] +# except Exception, e: +# rank_list.append('') +# try: +# result = p.sub("", str(spiderContents_os[i])) +# os_list.append(result) +# except Exception, e: +# os_list[i].append('') +# try: +# result = p.sub("", str(spiderContents_hit[i])) +# today_hit_list.append(result) +# except Exception, e: +# today_hit_list.append('') +# #156= +# start_pos = str(spiderContents_hit[i]).find("src=") +# end_pos = str(spiderContents_hit[i]).find("alt=") +# img_path = '' +# img_path = str(spiderContents_hit[i])[start_pos+5:end_pos] +# img_path = img_path.replace('\"', '').replace(' ', '') +# yestoday_hit_last_pos = str(spiderContents_hit[i]).find('Yesterday:',start_pos) +# yestoday_hit_str = str(spiderContents_hit[i])[yestoday_hit_last_pos+10:] +# yestoday_hit_num = 0 +# yestoday_hit_num = int(filter(str.isdigit, yestoday_hit_str)) +# img_list.append(img_path) +# yestoday_hit_list.append(str(yestoday_hit_num)) +# for i in range(0, len(rank_list)): +# line = "%s+%s+%s+%s+%s+%s" % (rank_list[i], os_list[i], os_list[i].replace(' ', '').replace('-', '').lower(), today_hit_list[i], img_list[i], yestoday_hit_list[i]) +# self.distrowatch.append(line) +## print self.distrowatch +# self.distrowatch_all_signal(update_rate) + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='') +# def get_distrowatch_url(self): +# t = threading.Thread(target = self.real_get_distrowatch_url) +# t.start() + + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='as') +# def get_distrowatch_info(self): +# return self.distrowatch + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='') +# def get_ip_address(self): +# t = threading.Thread(target = self.real_get_ip_address) +# t.start() + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='s') +# def show_ip_address(self): +# return self.ip_addr + + # True: has camera, False: no camera +# @dbus.service.method(INTERFACE, in_signature='', out_signature='b') +# def judge_camera(self): +# if not hasattr(self, 'capturemode'): +# self.capturemode = Capture() +# return self.capturemode.judge_camera() + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='') +# def call_camera(self): +# self.capturemode.call_camera() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def judge_power_is_exists(self): + if os.path.isdir(POWER_PATH): + if len(os.listdir(POWER_PATH)) == 0: + return False + else: + if os.path.isdir(BATTERY_PATH): + return True + else: + return False + else: + return False + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def read_battery_info(self): + bat_dict = {} + if not os.path.exists(BAT_FILE): + bat_dict['error'] = 'unknown' + else: + try: + fp = open(BAT_FILE) + allLines = fp.readlines() + fp.close() + for eachline in allLines: + eachline = eachline.strip('\n') + if '=' in eachline: + tmp_list = eachline.split('=') + bat_dict[tmp_list[0]] = tmp_list[1] + except Exception, e: + bat_dict['error'] = 'unknown' + return bat_dict + + # a dbus method which download and use kuaipan cloud conf by kobe +# @dbus.service.method(INTERFACE, in_signature='', out_signature='') +# def download_kysoft_cloud_conf(self): +# self.cloudconf.download_kysoft_cloud_conf() + + # a dbus method which upload conf to kuaipan cloud by kobe +# @dbus.service.method(INTERFACE, in_signature='', out_signature='') +# def upload_kysoft_cloud_conf(self): +# self.cloudconf.upload_kysoft_cloud_conf() + + # a dbus signal which download and use kuaipan cloud conf by kobe + @dbus.service.signal(INTERFACE, signature='s') + def download_cloud_conf_signal(self, download): + pass + + # a dbus signal which upload conf to kuaipan cloud by kobe + @dbus.service.signal(INTERFACE, signature='s') + def upload_cloud_conf_signal(self, upload): + pass + + # a dbus signal which tell widget to change titlebar postion by kobe + @dbus.service.signal(INTERFACE, signature='s') + def change_titlebar_position(self, position): + pass + + #@dbus.service.method(INTERFACE, in_signature='', out_signature='') + #def display_slide_show(self): + # self.wizardconf.show_slider() + + @dbus.service.method(INTERFACE, in_signature='as', out_signature='') + def onekey_scan_function(self, mode_list): + onekeyfunc_obj = cleaner.OneKeyClean() + onekeyfunc_obj.get_onekey_crufts(self, mode_list) + self.scan_complete_msg('onekey') + +# @dbus.service.method(INTERFACE, in_signature='as', out_signature='') +# def mainpage_scan_function(self): +# mainfunc_obj = cleaner.MainPage() +# t = threading.Thread(target = mainfunc_obj.get_cache, args=(self,)) +# target_tid = mainfunc_obj.get_threadid(t) +# self.trans_thread_infor(target_tid) +# t.join() +# self.scan_complete_msg('onekey') + +# @dbus.service.method(INTERFACE, in_signature='i', out_signature='') +# def cancel_mainpage_scan(self, target_tid): +# mainfunc_obj = cleaner.MainPage() +# mainfunc_obj.cancel_mainpage_function(target_tid, SystemExit) + +# @dbus.service.signal(INTERFACE, signature='as') +# def get_largefile_list(self, filelist): +# pass + +# def tell_widget_largefile_list(self, filelist): +# self.get_largefile_list(filelist) + +# @dbus.service.signal(INTERFACE, signature='si') +# def get_history_number(self, flag, num): +# pass + +# def tell_widget_history_number(self, flag, num): +# self.get_history_number(flag, num) + +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='i') +# def scan_history_records(self, flag): +# historyfunc_obj = cleaner.CleanTheHistory() +# crufts = historyfunc_obj.get_history_crufts(flag) +# figure = None +# if isinstance(crufts, list): +# figure = sum([int(one.split('<2_2>')[-1]) for one in crufts]) +# elif crufts in 'True': +# figure = -99 +# elif crufts in 'No': +# figure = -1 +# #return figure +# self.tell_widget_history_number(flag, figure) + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='i') +# def scan_system_history(self): +# daemonsystem = cleaner.CleanSystemHistory() +# url = daemonsystem.get_scan_result() +# #self.scan_complete_msg('system') +# #return len(url) +# self.tell_widget_history_number("system", len(url)) + + #@dbus.service.method(INTERFACE, in_signature='', out_signature='i') + #def scan_dash_history(self): + # daemondash = cleaner.CleanDashHistory() + # num = daemondash.get_scan_result() + # return num + + # the function of search the same file below path + ### input-'path' output-['filea<2_2>filea','fileb<2_2>fileb'....] + #@dbus.service.method(INTERFACE, in_signature='s', out_signature='as') + #def scan_of_same(self, path): + # tmp_list = self.daemonsame.get_scan_result(path) + # self.scan_complete_msg('same') + # return tmp_list + + # the function of sort the hundred files below path betown big to small + ### input-'path' output-['size<2_2>biggestfile<2_2>filestyle', 'size...] + #@dbus.service.method(INTERFACE, in_signature='is', out_signature='as') + #def scan_of_large(self, size, path): + # tmp_list = self.daemonlarge.get_scan_result(size, path) + # self.scan_complete_msg('large') + # return tmp_list + +# def real_scan_large_files(self, size, path): +# filelist = self.daemonlarge.get_scan_result(size, path) +# # start to send the over signal to UI +# self.get_largefile_list(filelist) + +# @dbus.service.method(INTERFACE, in_signature='is', out_signature='') +# def scan_of_large(self, size, path): +# t = threading.Thread(target = self.real_scan_large_files, args=(size, path)) +# t.start() + + # the function of clean the cookies records +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='') +# def cookies_scan_function(self, flag): +# cookiesfunc_obj = cleaner.CleanTheCookies(self) +# t = threading.Thread(target = cookiesfunc_obj.get_cookie_crufts, args = (flag, self)) +# t.start() +# #cookiesfunc_obj.get_cookie_crufts(flag, self) + +# @dbus.service.method(INTERFACE, in_signature='as', out_signature='') +# def package_scan_function(self, mode_list): +# packagefunc_obj = cleaner.CleanTheSpare() +# t = threading.Thread(target = packagefunc_obj.get_all_package_crufts, args = (mode_list, self)) +# t.start() + +# @dbus.service.method(INTERFACE, in_signature='ass', out_signature='') +# def cache_scan_function(self, mode_list, flag): +# cachefunc_obj = cleaner.CleanTheCache() +# t = threading.Thread(target = cachefunc_obj.get_all_cache_crufts, args = (mode_list, flag, self)) +# t.start() + + # a dbus signal which means access weather by kobe +# @dbus.service.signal(INTERFACE, signature='ss') +# def access_weather(self, key, msg): +# pass + + # a dbus signal which means scan complete by kobe + @dbus.service.signal(INTERFACE, signature='s') + def scan_complete(self, msg): + pass + + @dbus.service.signal(INTERFACE, signature='ssss') + def data_transmit_by_cache(self, flag0, path, flag1, size): + pass + + @dbus.service.signal(INTERFACE, signature='i') + def trans_thread_infor(self, target_tid): + pass + + @dbus.service.signal(INTERFACE, signature='ssss') + def data_transmit_by_package(self, flag, name, summary, size): + pass + + @dbus.service.signal(INTERFACE, signature='sss') + def data_transmit_by_cookies(self, flag, domain, num): + pass + + #@dbus.service.signal(INTERFACE, signature='i') + #def data_transmit_by_history(self, num): + # pass + + #@dbus.service.signal(INTERFACE, signature='s') + #def browser_status_by_history(self, status): + # pass + +# @dbus.service.signal(INTERFACE, signature='ss') +# def data_transmit_by_large(self, size, filepath): +# pass + + @dbus.service.signal(INTERFACE, signature='s') + def cache_transmit_complete(self, flag): + pass + + @dbus.service.signal(INTERFACE, signature='') + def package_transmit_complete(self): + pass + + @dbus.service.signal(INTERFACE, signature='s') + def cookies_transmit_complete(self, msg): + pass + + #@dbus.service.signal(INTERFACE, signature='s') + #def history_transmit_complete(self, msg): + # pass + + @dbus.service.signal(INTERFACE, signature='') + def large_transmit_complete(self): + pass + + @dbus.service.signal(INTERFACE, signature='ss') + def total_data_transmit(self, flag, msg): + pass + + @dbus.service.signal(INTERFACE, signature='s') + def display_scan_process(self, msg): + pass + + def scan_complete_msg(self, para): + self.scan_complete(para) + + def trans_thread_infor_msg(self, para): + self.trans_thread_infor(para) + + def display_scan_process_msg(self, para): + self.display_scan_process(para) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def exit(self): + self.mainloop.quit() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_session_daemon(self): + return "SessionDaemon" + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_system_message(self): + return self.sysconf.get_sys_msg() + + # -------------------------beautify start here------------------------- + + # -------------------------desktop------------------------- + +# @dbus.service.method(INTERFACE, in_signature='ss', out_signature='b') +# def get_default_desktop_bool(self, schema, key): +# return self.desktopconf.get_default_schema_value(schema, key) + +# @dbus.service.method(INTERFACE, in_signature='sss', out_signature='') +# def set_default_desktop(self, schema, key, type): +# self.desktopconf.set_default_schema_value(schema, key, type) + + #--------------unity-------------------- + # show desktop icons + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_desktop_icons(self, flag): + return self.desktopconf.set_show_desktop_icons(flag) + + # get show desktop icons + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_desktop_icons(self): + return self.desktopconf.get_show_desktop_icons() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_computer(self, flag): + return self.desktopconf.set_show_computer(flag) + + # get show homefolder + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_computer(self): + return self.desktopconf.get_show_computer() + + # show home folder + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_homefolder(self, flag): + return self.desktopconf.set_show_homefolder(flag) + + # get show homefolder + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_homefolder(self): + return self.desktopconf.get_show_homefolder() + + # show network + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_network(self, flag): + return self.desktopconf.set_show_network(flag) + + # get show network + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_network(self): + return self.desktopconf.get_show_network() + + # show trash + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_trash(self, flag): + return self.desktopconf.set_show_trash(flag) + + # get show trash + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_trash(self): + return self.desktopconf.get_show_trash() + + # show devices + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_devices(self, flag): + return self.desktopconf.set_show_devices(flag) + + # get show devices + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_devices(self): + return self.desktopconf.get_show_devices() + + #--------------cinnamon-------------------- + # show desktop icons + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_cinnamon_desktop_icons(self, flag): + return self.desktopconf.set_show_cinnamon_desktop_icons(flag) + + # get show desktop icons + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_cinnamon_desktop_icons(self): + return self.desktopconf.get_show_cinnamon_desktop_icons() + + # show computer + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_cinnamon_computer(self, flag): + return self.desktopconf.set_show_cinnamon_computer(flag) + + # get show computer + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_cinnamon_computer(self): + return self.desktopconf.get_show_cinnamon_computer() + + # show home folder + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_cinnamon_homefolder(self, flag): + return self.desktopconf.set_show_cinnamon_homefolder(flag) + + # get show homefolder + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_cinnamon_homefolder(self): + return self.desktopconf.get_show_cinnamon_homefolder() + + # show network + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_cinnamon_network(self, flag): + return self.desktopconf.set_show_cinnamon_network(flag) + + # get show network + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_cinnamon_network(self): + return self.desktopconf.get_show_cinnamon_network() + + # show trash + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_cinnamon_trash(self, flag): + return self.desktopconf.set_show_cinnamon_trash(flag) + + # get show trash + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_cinnamon_trash(self): + return self.desktopconf.get_show_cinnamon_trash() + + # show devices + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_cinnamon_devices(self, flag): + return self.desktopconf.set_show_cinnamon_devices(flag) + + # get show devices + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_cinnamon_devices(self): + return self.desktopconf.get_show_cinnamon_devices() + + # -------------------------unity------------------------- + +# @dbus.service.method(INTERFACE, in_signature='ss', out_signature='i') +# def get_default_unity(self, name, key): +# return self.unityconf.get_default_schema_value(name, key) + +# @dbus.service.method(INTERFACE, in_signature='ssi', out_signature='') +# def set_default_unity(self, key, type, value): +# self.unityconf.set_default_schema_value(key, type, value) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def set_default_launcher_have_showdesktopicon(self): + self.unityconf.set_default_launcher_have_showdesktopicon() + + # set launcher auto hide mode + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_launcher_autohide(self, flag): + return self.unityconf.set_launcher_autohide(flag) + + # get launcher auto hide mode + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_launcher_autohide(self): + return self.unityconf.get_launcher_autohide() + + # launcher icon size 32-64 + @dbus.service.method(INTERFACE, in_signature='i', out_signature='b') + def set_launcher_icon_size(self, size): + return self.unityconf.set_launcher_icon_size(size) + + # get launcher icon size + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_launcher_icon_size(self): + return self.unityconf.get_launcher_icon_size() + + # set launcher 'show desktop' icon + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_launcher_have_showdesktopicon(self, flag): + return self.unityconf.set_launcher_have_showdesktopicon(flag) + + # get is launcher have 'show desktop' icon + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_launcher_have_showdesktopicon(self): + return self.unityconf.get_launcher_have_showdesktopicon() + + + + + #add by kobe for v1.1.0 + # 透明度 + @dbus.service.method(INTERFACE, in_signature='', out_signature='d') + def get_launcher_transparency(self): + return self.unityconf.get_launcher_transparency() + + @dbus.service.method(INTERFACE, in_signature='d', out_signature='b') + def set_launcher_transparency(self, opacity): + return self.unityconf.set_launcher_transparency(opacity) + + #图标背景 + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_all_launcher_icon_colourings(self): + return self.unityconf.get_all_launcher_icon_colourings() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_launcher_icon_colouring(self): + return self.unityconf.get_launcher_icon_colouring() + + @dbus.service.method(INTERFACE, in_signature='i', out_signature='b') + def set_launcher_icon_colouring(self, colouring): + return self.unityconf.set_launcher_icon_colouring(colouring) + + + + #Launcher position + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_all_launcher_position(self): + return self.unityconf.get_all_launcher_position() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_current_launcher_position(self): + return self.unityconf.get_current_launcher_position() + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_launcher_position(self, position): + return self.unityconf.set_launcher_position(position) + + # Dash背景模糊类型 + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_dash_blur_experimental(self): + return self.unityconf.get_dash_blur_experimental() + + @dbus.service.method(INTERFACE, in_signature='i', out_signature='b') + def set_dash_blur_experimental(self, blur): + return self.unityconf.set_dash_blur_experimental(blur) + + #面板菜单透明度 + @dbus.service.method(INTERFACE, in_signature='', out_signature='d') + def get_panel_transparency(self): + return self.unityconf.get_panel_transparency() + + @dbus.service.method(INTERFACE, in_signature='d', out_signature='b') + def set_panel_transparency(self, opacity): + return self.unityconf.set_panel_transparency(opacity) + + + #日期时间格式 + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_all_time_format(self): + return self.unityconf.get_all_time_format() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_time_format(self): + return self.unityconf.get_time_format() + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_time_format(self, format): + return self.unityconf.set_time_format(format) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_seconds(self): + return self.unityconf.get_show_seconds() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_seconds(self, flag): + return self.unityconf.set_show_seconds(flag) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_week(self): + return self.unityconf.get_show_week() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_week(self, flag): + return self.unityconf.set_show_week(flag) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_date(self): + return self.unityconf.get_show_date() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_date(self, flag): + return self.unityconf.set_show_date(flag) + + # 电源 + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_all_power_icon_policy(self): + return self.unityconf.get_all_power_icon_policy() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_power_icon_policy(self): + return self.unityconf.get_power_icon_policy() + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_power_icon_policy(self, flag): + return self.unityconf.set_power_icon_policy(flag) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_power_time(self): + return self.unityconf.get_show_power_time() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_power_time(self, flag): + return self.unityconf.set_show_power_time(flag) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_power_percentage(self): + return self.unityconf.get_show_power_percentage() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_power_percentage(self, flag): + return self.unityconf.set_show_power_percentage(flag) + + #-------------------------mate------------------------- + @dbus.service.method(INTERFACE, in_signature='sb', out_signature='b') + def set_mate_panel_autohide(self, position, flag): + return self.unityconf.set_mate_panel_autohide(position, flag) + + # get launcher auto hide mode + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def get_mate_panel_autohide(self, position): + return self.unityconf.get_mate_panel_autohide(position) + + @dbus.service.method(INTERFACE, in_signature='si', out_signature='b') + def set_mate_panel_icon_size(self, position, size): + return self.unityconf.set_mate_panel_icon_size(position, size) + + # get launcher icon size + @dbus.service.method(INTERFACE, in_signature='s', out_signature='i') + def get_mate_panel_icon_size(self, position): + return self.unityconf.get_mate_panel_icon_size(position) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_apps(self): + return self.unityconf.get_show_apps() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_apps(self, flag): + return self.unityconf.set_show_apps(flag) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_desktop(self): + return self.unityconf.get_show_desktop() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_desktop(self, flag): + return self.unityconf.set_show_desktop(flag) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_icon(self): + return self.unityconf.get_show_icon() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_icon(self, flag): + return self.unityconf.set_show_icon(flag) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_show_places(self): + return self.unityconf.get_show_places() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_show_places(self, flag): + return self.unityconf.set_show_places(flag) + + # -------------------------theme------------------------- + + @dbus.service.method(INTERFACE, in_signature='ss', out_signature='s') + def get_default_font_string(self, schema, key): + return self.themeconf.get_default_schema_value(schema, key) + +# @dbus.service.method(INTERFACE, in_signature='ss', out_signature='d') +# def get_default_font_double(self, schema, key): +# return self.themeconf.get_default_schema_value(schema, key) + + @dbus.service.method(INTERFACE, in_signature='sss', out_signature='b') + def set_default_font(self, schema, key, type): + return self.themeconf.set_default_schema_value(schema, key, type) + + # get themes + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_themes(self): + return self.themeconf.get_themes() + + # get current theme + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_theme(self): + return self.themeconf.get_theme() + + # set GTK theme and window theme + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_theme(self, theme): + self.themeconf.set_theme(theme) + + +#---------------------------------------------------------------------------------------------------------- + @dbus.service.method(INTERFACE, in_signature='sssss', out_signature='') + def set_ubuntukylin_default_setting_str(self, schema, title, key, type,value): + self.themeconf.set_ubuntukylin_default_setting(schema, title, key, type,value) + + @dbus.service.method(INTERFACE, in_signature='ssssd', out_signature='') + def set_ubuntukylin_default_setting_double(self, schema, title, key, type,value): + self.themeconf.set_ubuntukylin_default_setting(schema, title, key, type,value) + + @dbus.service.method(INTERFACE, in_signature='ssssi', out_signature='') + def set_ubuntukylin_default_setting_int(self, schema, title, key, type,value): + self.themeconf.set_ubuntukylin_default_setting(schema, title, key, type,value) + + @dbus.service.method(INTERFACE, in_signature='ssssb', out_signature='') + def set_ubuntukylin_default_setting_bool(self, schema, title, key, type,value): + self.themeconf.set_ubuntukylin_default_setting(schema, title, key, type,value) +#---------------------------------------------------------------------------------------------------------- + + + # ----------------window theme---------------- + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_window_themes(self): + return self.themeconf.get_window_themes() + + # get current window theme + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_current_window_theme(self): + return self.themeconf.get_current_window_theme() + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_window_theme(self, theme): + self.themeconf.set_window_theme(theme) + + # get icon themes + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_icon_themes(self): + return self.themeconf.get_icon_themes() + + # get current icon theme + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_icon_theme(self): + return self.themeconf.get_icon_theme() + + # set icon theme + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_icon_theme(self, theme): + self.themeconf.set_icon_theme(theme) + + # get cursor themes + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_cursor_themes(self): + return self.themeconf.get_cursor_themes() + + # get current cursor theme + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_cursor_theme(self): + return self.themeconf.get_cursor_theme() + + # set cursor theme + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_cursor_theme(self, theme): + self.themeconf.set_cursor_theme(theme) + + # get cursor size + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_cursor_size(self): + return self.themeconf.get_cursor_size() + + # set cursor size + @dbus.service.method(INTERFACE, in_signature='i', out_signature='') + def set_cursor_size(self, size): + self.themeconf.set_cursor_size(size) + + # -------------------------fonts------------------------- + + # get font + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_font(self): + return self.themeconf.get_font() + + # set font + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_font(self, font): + return self.themeconf.set_font(font) + + # get desktop font + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_desktop_font(self): + return self.themeconf.get_desktop_font() + + # set desktop font + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_desktop_font(self, font): + return self.themeconf.set_desktop_font(font) + + # get document font + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_document_font(self): + return self.themeconf.get_document_font() + + # set document font + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_document_font(self, font): + return self.themeconf.set_document_font(font) + + # get monospace font + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_monospace_font(self): + return self.themeconf.get_monospace_font() + + # set monospace font (use this func to change document font in ubuntu) + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_monospace_font(self, font): + return self.themeconf.set_monospace_font(font) + + # get window title font + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_window_title_font(self): + return self.themeconf.get_window_title_font() + + # set window title font + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_window_title_font(self, font): + return self.themeconf.set_window_title_font(font) + + # get font zoom + @dbus.service.method(INTERFACE, in_signature='', out_signature='d') + def get_font_zoom(self): + return self.themeconf.get_font_zoom() + + # set font zoom + @dbus.service.method(INTERFACE, in_signature='d', out_signature='b') + def set_font_zoom(self, zoom): + return self.themeconf.set_font_zoom(zoom) + + # get smooth style list + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_smooth_style_list(self): + return self.themeconf.get_all_hinting() + + # get smooth style + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_smooth_style(self): + return self.themeconf.get_hinting() + + # set smooth style + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_smooth_style(self, value): + return self.themeconf.set_hinting(value) + + # get antialiasing style list + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_antialiasing_style_list(self): + return self.themeconf.get_all_antialiasing() + + # get antialiasing style + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_antialiasing_style(self): + return self.themeconf.get_antialiasing() + + # set antialiasing style + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_antialiasing_style(self, value): + return self.themeconf.set_antialiasing(value) + + + # -------------------------scrollbars------------------------- +# @dbus.service.method(INTERFACE, in_signature='ss', out_signature='s') +# def get_default_system_sring(self, schema, key): +# return self.systemconf.get_default_schema_value(schema, key) + +# @dbus.service.method(INTERFACE, in_signature='ss', out_signature='b') +# def get_default_system_bool(self, schema, key): +# return self.systemconf.get_default_schema_value(schema, key) + +# @dbus.service.method(INTERFACE, in_signature='sss', out_signature='') +# def set_default_system(self, schema, key, type): +# self.systemconf.set_default_schema_value(schema, key, type) + + # set scrollbars mode overlay + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def set_scrollbars_mode_overlay(self): + return self.systemconf.set_scrollbars_mode_overlay() + + # set scrollbars mode legacy + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def set_scrollbars_mode_legacy(self): + return self.systemconf.set_scrollbars_mode_legacy() + + # get scrollbars mode + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_scrollbars_mode(self): + return self.systemconf.get_scrollbars_mode() + + # -------------------------touchpad------------------------- + + # enable/disable the touchpad + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_touchpad_enable(self, flag): + return self.systemconf.set_touchpad_enable(flag) + + # get is touchpad enable + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_touchpad_enable(self): + return self.systemconf.get_touchpad_enable() + + # set touch scrolling use horizontal + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_touchscrolling_use_horizontal(self, flag): + return self.systemconf.set_touchscrolling_use_horizontal(flag) + + # get is touch scrolling use horizontal + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_touchscrolling_use_horizontal(self): + return self.systemconf.get_touchscrolling_use_horizontal() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def set_touchscrolling_mode_disabled(self): + return self.systemconf.set_touchscrolling_mode_disabled() + + # set touch scrolling mode edge + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def set_touchscrolling_mode_edge(self): + return self.systemconf.set_touchscrolling_mode_edge() + + # set touch scrolling mode two-finger + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def set_touchscrolling_mode_twofinger(self): + return self.systemconf.set_touchscrolling_mode_twofinger() + + # get touchpad scrolling mode + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_touchscrolling_mode(self): + return self.systemconf.get_touchscrolling_mode() + + @dbus.service.method(INTERFACE, in_signature='i', out_signature='b') + def set_mate_touchscrolling_mode(self, value): + return self.systemconf.set_mate_touchscrolling_mode(value) + + # get is touch scrolling use horizontal + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_mate_touchscrolling_mode(self): + return self.systemconf.get_mate_touchscrolling_mode() + + # -------------------------window------------------------- + + # set window button alignment left + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def set_window_button_align_left(self): + self.systemconf.set_window_button_align_left() + + # set window button alignment right + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def set_window_button_align_right(self): + self.systemconf.set_window_button_align_right() + + # get window button alignment + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_window_button_align(self): + return self.systemconf.get_window_button_align() + + # set right click menus have icons + @dbus.service.method(INTERFACE, in_signature='b', out_signature='b') + def set_menus_have_icons(self, flag): + return self.systemconf.set_menus_have_icons(flag) + + # get is right click menus have icons + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_menus_have_icons(self): + return self.systemconf.get_menus_have_icons() + + # get titlebar wheel action + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_titlebar_wheel(self): + return self.systemconf.get_titlebar_wheel() + + # get current titlebar wheel + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_current_titlebar_wheel(self): + return self.systemconf.get_current_titlebar_wheel() + + # set titlebar wheel + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_titlebar_wheel(self, value): + self.systemconf.set_titlebar_wheel(value) + + # get titlebar double + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_titlebar_options(self): + return self.systemconf.get_titlebar_options() + + # get current titlebar double + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_current_titlebar_double(self): + return self.systemconf.get_current_titlebar_double() + + # set titlebar double + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_titlebar_double(self, value): + self.systemconf.set_titlebar_double(value) + + # get titlebar middle + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_titlebar_middle(self): + return self.systemconf.get_titlebar_middle() + + # get current titlebar middle + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_current_titlebar_middle(self): + return self.systemconf.get_current_titlebar_middle() + + # set titlebar middle + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_titlebar_middle(self, value): + self.systemconf.set_titlebar_middle(value) + + # get titlebar right + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_titlebar_right(self): + return self.systemconf.get_titlebar_right() + + # get current titlebar right + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_current_titlebar_right(self): + return self.systemconf.get_current_titlebar_right() + + # set titlebar right + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_titlebar_right(self, value): + self.systemconf.set_titlebar_right(value) + + # -------------------------sound------------------------- + + @dbus.service.method(INTERFACE, in_signature='ss', out_signature='s') + def get_default_sound_string(self, schema, key): + return self.soundconf.get_default_schema_value(schema, key) + +# @dbus.service.method(INTERFACE, in_signature='sss', out_signature='') +# def set_default_sound(self, schema, key, type): +# self.soundconf.set_default_schema_value(schema, key, type) + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='') + def set_input_feedback_sounds_enable(self, flag): + self.soundconf.set_input_feedback_sounds_enable(flag) + + # get enable the login music + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_input_feedback_sounds_enable(self): + return self.soundconf.get_input_feedback_sounds_enable() + + @dbus.service.method(INTERFACE, in_signature='b', out_signature='') + def set_sound_event_enable(self, flag): + self.soundconf.set_sound_event_enable(flag) + + # get enable the login music + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_sound_event_enable(self): + return self.soundconf.get_sound_event_enable() + + # set enable the login music + @dbus.service.method(INTERFACE, in_signature='b', out_signature='') + def set_login_music_enable(self, flag): + self.soundconf.set_login_music_enable(flag) + + # get enable the login music + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_login_music_enable(self): + return self.soundconf.get_login_music_enable() + + # get current sound theme + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_sound_theme(self): + return self.soundconf.get_sound_theme() + + # set sound theme + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_sound_theme(self, theme): + self.soundconf.set_sound_theme(theme) + + + # -------------------------filemanager------------------------- + @dbus.service.method(INTERFACE, in_signature='ss', out_signature='b') + def get_default_filemanager_bool(self, schema, key): + return self.fileconf.get_default_schema_value(schema, key) + + @dbus.service.method(INTERFACE, in_signature='ss', out_signature='i') + def get_default_filemanager_int(self, schema, key): + return self.fileconf.get_default_schema_value(schema, key) + +# @dbus.service.method(INTERFACE, in_signature='sss', out_signature='') +# def set_default_filemanager(self, schema, key, type): +# self.fileconf.set_default_schema_value(schema, key, type) + + # Set: Use the location entry instead of the pathbar + @dbus.service.method(INTERFACE, in_signature='b', out_signature='') + def set_location_replace_pathbar(self, flag): + self.fileconf.set_location_replace_pathbar(flag) + + # Get: Use the location entry instead of the pathbar + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_location_replace_pathbar(self): + return self.fileconf.get_location_replace_pathbar() + + # Set: Automatically mount media + @dbus.service.method(INTERFACE, in_signature='b', out_signature='') + def set_auto_mount_media(self, flag): + self.fileconf.set_auto_mount_media(flag) + + # Get: Automatically mount media + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_auto_mount_media(self): + return self.fileconf.get_auto_mount_media() + + # Set: Automatically open a folder + @dbus.service.method(INTERFACE, in_signature='b', out_signature='') + def set_auto_open_folder(self, flag): + self.fileconf.set_auto_open_folder(flag) + + # Get: Automatically open a folder + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_auto_open_folder(self): + return self.fileconf.get_auto_open_folder() + + # Set: Prompt or autorun/autostart programs + @dbus.service.method(INTERFACE, in_signature='b', out_signature='') + def set_prompt_autorun_programs(self, flag): + self.fileconf.set_prompt_autorun_programs(flag) + + # Get: Prompt or autorun/autostart programs + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def get_prompt_autorun_programs(self): + return self.fileconf.get_prompt_autorun_programs() + + # Set: Thumbnail icon size (pixels) + @dbus.service.method(INTERFACE, in_signature='i', out_signature='') + def set_thumbnail_icon_size(self, size): + self.fileconf.set_thumbnail_icon_size(size) + + # Get: Thumbnail icon size (pixels) + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_thumbnail_icon_size(self): + return self.fileconf.get_thumbnail_icon_size() + + # Set: Thumbnail cache time (days) + @dbus.service.method(INTERFACE, in_signature='i', out_signature='') + def set_thumbnail_cache_time(self, size): + self.fileconf.set_thumbnail_cache_time(size) + + # Get: Thumbnail cache time (days) + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_thumbnail_cache_time(self): + return self.fileconf.get_thumbnail_cache_time() + + # Set: Maximum thumbnail cache size (MB) + @dbus.service.method(INTERFACE, in_signature='i', out_signature='') + def set_thumbnail_cache_size(self, size): + self.fileconf.set_thumbnail_cache_size(size) + + # Get: Maximum thumbnail cache size (MB) + @dbus.service.method(INTERFACE, in_signature='', out_signature='i') + def get_thumbnail_cache_size(self): + return self.fileconf.get_thumbnail_cache_size() + + # ---start---------------------autostartmanage------------------- + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def get_current_autostart_status(self): + autostartmanage.interface_get_status(self) + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def get_current_single_autostart_status(self, path): + return autostartmanage.interface_get_single_status(self, path) + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def change_autostart_status(self, filename): + autostartmanage.interface_change_status(self, filename) + + @dbus.service.signal(INTERFACE, signature='as') + def autostartmanage_data_signal(self, info): + pass + @dbus.service.signal(INTERFACE, signature='s') + def autostartmanage_status_signal(self, status): + pass + @dbus.service.signal(INTERFACE, signature='s') + def autostartmanage_error_signal(self, error): + pass + # ---end---------------------autostartmanage-------------------- + + #----START-------------------New-Youker------------------------- + @dbus.service.method(INTERFACE, in_signature='a{sv}', out_signature='') + def get_scan_result(self, mode_dic): + cleaner.interface_get_subpage_session(self, mode_dic) + + @dbus.service.signal(INTERFACE, signature='as') + def subpage_data_signal(self, info): + pass + + @dbus.service.signal(INTERFACE, signature='s') + def subpage_status_signal(self, status): + pass + + @dbus.service.signal(INTERFACE, signature='s') + def subpage_error_signal(self, error): + pass + #----END---------------------New-Youker------------------------- + + @dbus.service.signal(INTERFACE, signature='b') + def check_source_list_signal(self, result): + pass + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def start_check_source_useable(self): + source_urllist = [] + bad_source_urllist = [] + good_source_urllist = [] + source = aptsources.sourceslist.SourcesList() + for item in source.list: + if item.str()[0:4] == "deb " and item.str()[0:9] != "deb cdrom": + #print type(item.str()[4:].split()),item.str()[4:].split() + source_list = item.str()[4:].split() + if source_list[0].endswith("/") is True: + str = source_list[0] + "dists" + else: + str = source_list[0] + "/dists" + source_list[0] = str + if len(source_list)>3: + urlend = source_list[2:] + for item in urlend: + urlbegin = source_list[0:2] + urlbegin.append(item) + source_urllist.append(urlbegin) + else: + source_urllist.append(source_list) + for urllist in source_urllist: + source_url = '/'.join(urllist) + try: + response = urllib2.urlopen(source_url,timeout=5) + good_source_urllist.append(source_url) + except Exception, e: + print e + bad_source_urllist.append(source_url) + if good_source_urllist == []: + self.check_source_list_signal(False) + else: + self.check_source_list_signal(True) + + # -------------------------monitorball------------------------- +# # get cpu percent +# @dbus.service.method(INTERFACE, in_signature='', out_signature='d') +# def get_cpu_percent(self): +# return self.ballconf.get_cpu_percent() + +# # get total memory +# @dbus.service.method(INTERFACE, in_signature='', out_signature='s') +# def get_total_memory(self): +# return self.ballconf.get_total_memory() + +# # get used memory +# @dbus.service.method(INTERFACE, in_signature='', out_signature='s') +# def get_used_memory(self): +# return self.ballconf.get_used_memory() + +# # get free memory +# @dbus.service.method(INTERFACE, in_signature='', out_signature='s') +# def get_free_memory(self): +# return self.ballconf.get_free_memory() + +# # get network flow total, return (up, down) +# @dbus.service.method(INTERFACE, in_signature='', out_signature='as') +# def get_network_flow_total(self): +# return self.ballconf.get_network_flow_total() + + # -------------------------weather------------------------- + # get weather information of six days +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='') +# def get_forecast_weahter(self, cityId): +# self.weatherconf.getWeatherForecast(cityId) + + # get real forecast weather information of six days +# @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') +# def get_forecast_dict(self): +# return self.weatherconf.get_forecast_dict() + + # is Unity or Cinnamon or others + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def access_current_desktop(self): + '''env |grep XDG_CURRENT_DESKTOP''' + desktop = None + try: + desktop = os.getenv('XDG_CURRENT_DESKTOP') + if desktop is None: + desktop = os.getenv('XDG_SESSION_DESKTOP') + except Exception as e: + pass + return desktop + + # is x86 or aarch64 + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def access_current_machine(self): + return platform.machine() + +# # is Unity or not +# @dbus.service.method(INTERFACE, in_signature='', out_signature='s') +# def judge_desktop_is_unity(self): +# '''env |grep XDG_CURRENT_DESKTOP''' +# desktop = '' +# try: +# desktop = os.getenv('XDG_CURRENT_DESKTOP') +# except Exception as e: +# pass +# return desktop + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='s') +# def judge_desktop_is_cinnamon(self): +# '''env |grep XDG_CURRENT_DESKTOP''' +# desktop = ''#X-Cinnamon +# try: +# desktop = os.getenv('XDG_CURRENT_DESKTOP') +# except Exception as e: +# pass +# return desktop + + + # -------------------------pingback------------------------- + def get_last_time(self): + time_text = None + usrPath = os.path.join(HOME, '.config/ubuntukylin/youker-assistant/pingback.time') + if os.path.exists(usrPath): + fp = open(usrPath) + try: + time_text = fp.read( ).replace('\n', '') + finally: + fp.close() + return time_text + + def set_last_time(self, time_text): + abs_path = os.path.join(HOME, '.config/ubuntukylin/youker-assistant') + if not os.path.isdir(abs_path): + os.makedirs(abs_path) + usrPath = os.path.join(abs_path, 'pingback.time') + fp = open(usrPath, 'w') + fp.write(time_text) + fp.close() + +# @dbus.service.signal(INTERFACE, signature='b') +# def weather_server_pingback_signal(self, result): +# pass + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='b') +# def access_server_pingback_real(self): +# pingback = self.weatherping.access_server_pingback() +# self.weather_server_pingback_signal(pingback) +## return pingback + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='') +# def access_server_pingback(self): +# t = threading.Thread(target = self.access_server_pingback_real) +# t.start() + +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') +# def submit_uk_pingback(self, cityname): +# last_time = self.get_last_time() +# now_time = datetime.datetime.now() +# if last_time in (None, ''): +# version_youker_assistant = get_uk_version() +# distro, version_os = get_distro_info() +# try: +# pingback = self.premoter.submit_pingback_main(distro, version_os, version_youker_assistant, cityname) +# except Exception as e: +# print 'pingback failed...' +# print e +# if pingback: +# self. set_last_time(now_time.strftime('%Y-%m-%d'))#'%Y-%m-%d %H:%M:%S' +# return pingback +# else: +# last_time = datetime.datetime.strptime(last_time, '%Y-%m-%d') +# now_time = now_time.strftime('%Y-%m-%d') +# now_time = datetime.datetime.strptime(now_time, '%Y-%m-%d') +## myseconds = (now_time - last_time).seconds +# delta = now_time - last_time#两个日期相隔的天数 +# if (delta.days > 0): +# version_youker_assistant = get_uk_version() +# distro, version_os = get_distro_info() +# try: +# pingback = self.premoter.submit_pingback_main(distro, version_os, version_youker_assistant, cityname) +# except Exception as e: +# print 'pingback failed...' +# print e +# if pingback: +# self. set_last_time(now_time.strftime('%Y-%m-%d')) +# return pingback +# else: +# return False + +# def real_get_current_weather(self, cityId): +# self.weather_data = self.server.get_cma_observe_weather(cityId) +# if self.weather_data not in (False, None, {}, '', '[]', "['']"): +# self.access_weather('weather', 'kobe') + + # get current day's weather +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='') +# def get_current_weather(self, cityId): +# t = threading.Thread(target = self.real_get_current_weather, args = (cityId,)) +# t.setDaemon(True) +# t.start() +# self.weatherconf.getCurrentWeather(cityId) + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') +# def get_current_weather_dict(self): +# return self.weather_data +# return self.weatherconf.get_current_weather_dict() + + # get current day's weather from yahoo 0.3.3 +# @dbus.service.method(INTERFACE, in_signature='ass', out_signature='') +# def get_current_yahoo_weather(self, latlon, cityId): +# self.yahooconf.getYahooCurrentWeather(latlon, cityId) + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') +# def get_current_yahoo_weather_dict(self): +# return self.yahooconf.get_current_yahoo_weather_dict() + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') +# def get_yahoo_forecast_dict(self): +# return self.yahooconf.get_yahoo_forecast_dict() diff --git a/backends/youker-assistant-daemon/src/sessiondbus/piston_remoter.py b/backends/youker-assistant-daemon/src/sessiondbus/piston_remoter.py new file mode 100644 index 0000000..a6f0270 --- /dev/null +++ b/backends/youker-assistant-daemon/src/sessiondbus/piston_remoter.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# Author: Kobe Lee +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +"""This module provides the RatingsAndReviewsAPI class for talking to the +ratings and reviews API, plus a few helper classes. +""" + +import os, sys +reload(sys) +sys.setdefaultencoding('utf8') +from urllib import quote_plus +from piston_mini_client import ( + PistonAPI, + PistonResponseObject, + PistonSerializable, + returns, + returns_json, + returns_list_of, + ) +from piston_mini_client.validators import validate_pattern, validate +#from piston_mini_client import APIError +import httplib2 + +# These are factored out as constants for if you need to work against a +# server that doesn't support both schemes (like http-only dev servers) +PUBLIC_API_SCHEME = 'http' +AUTHENTICATED_API_SCHEME = 'https' + + +class PingbackmainRequest(PistonSerializable): + _atts = ('distro', 'version_os', 'version_youker_assistant', 'city') + + +class PingBackPistonAPI(PistonAPI): + """A client for talking to the reviews and ratings API. + + If you pass no arguments into the constructor it will try to connect to + localhost:8000 so you probably want to at least pass in the + ``service_root`` constructor argument. + """ + default_content_type = 'application/x-www-form-urlencoded' + + @returns_json + def submit_pingback_main(self, distro, version_os, version_youker_assistant, city): + postdata = PingbackmainRequest() + postdata.distro = distro + postdata.version_os = version_os + postdata.version_youker_assistant = version_youker_assistant + postdata.city = city + return self._post('pingbackmain/', data=postdata, scheme=PUBLIC_API_SCHEME, content_type='application/json') + +class ServerPingBackAPI(PistonAPI): + default_content_type = 'application/x-www-form-urlencoded' + + @returns_json + def access_server_pingback(self): + return self._get('pingnetwork/', scheme=PUBLIC_API_SCHEME) diff --git a/backends/youker-assistant-daemon/src/sessiondbus/unzip.py b/backends/youker-assistant-daemon/src/sessiondbus/unzip.py new file mode 100644 index 0000000..c8bb620 --- /dev/null +++ b/backends/youker-assistant-daemon/src/sessiondbus/unzip.py @@ -0,0 +1,66 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# +# Author: Kobe Lee +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import sys +import subprocess +import shutil + +# unzip -o test.zip -d /tmp/ + +HOME_PATH = os.path.expandvars('$HOME') + +def generate_tmp_path(name): + assert(isinstance(name, str)) +# dest_path = HOME_PATH + "/.config/ubuntukylin/youker-assistant/" + dest_path = HOME_PATH + "/.cache/youker-assistant/" + folder_path = dest_path + name + if os.path.exists(folder_path): + shutil.rmtree(folder_path) + return dest_path + +def unzip_resource(package_file): + unziped_dir = generate_tmp_path("uk-img") + if unziped_dir[len(unziped_dir)-1] != "/": + unziped_dir = unziped_dir + "/" + subprocess.call(["unzip", package_file, "-d", unziped_dir]) + dest_dir = unziped_dir + "uk-img/" + if not os.path.exists(dest_dir): + print("unzip '%s' to '%s' failed" % (package_file , unziped_dir)) + return False + else: + print "unzip ok...." + return True +# unziped_dir = unziped_dir + WS360_CHROME_PKGNAME +# version = get_package_ver_from_manifest(unziped_dir) +# if version == "0.0": +# return False +# extension_filedir = "/home/trusty/360-deb/" +# shutil.copytree(unziped_dir, extension_filedir) +# shutil.rmtree(unziped_dir) +# return True + +#unzip_resource("/home/trusty/uk-img.zip") + + + + + + diff --git a/backends/youker-assistant-daemon/src/single.py b/backends/youker-assistant-daemon/src/single.py new file mode 100644 index 0000000..ac4c7e9 --- /dev/null +++ b/backends/youker-assistant-daemon/src/single.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import os, sys, shutil, tempfile +import commands + +# ensure that single instance of applet is running for each user +class SingleInstance(object): + + #Initialize, specifying a path to store pids + def __init__(self,pidPath): + + self.pidPath = pidPath + if os.path.exists(pidPath): + # Make sure it is not a "stale" pidFile + pid = open(pidPath, 'r').read().strip() + # Check list of running pids, if not running it is stale so overwrite + pidRunning = commands.getoutput('ls -1 /proc | grep ^%s$' % pid) + self.lasterror = True if pidRunning else False + else: + self.lasterror = False + + if not self.lasterror: + # Create a temp file, copy it to pidPath and remove temporary file + (fp, temp_path) = tempfile.mkstemp() + try: + os.fdopen(fp, "w+b").write(str(os.getpid())) + shutil.copy(temp_path, pidPath) + os.unlink(temp_path) + except Exception as e: + print str(e) + + def is_already_running(self): + return self.lasterror + + def __del__(self): + if not self.lasterror: + os.unlink(self.pidPath) diff --git a/backends/youker-assistant-daemon/src/slider/__init__.py b/backends/youker-assistant-daemon/src/slider/__init__.py new file mode 100644 index 0000000..013e4b7 --- /dev/null +++ b/backends/youker-assistant-daemon/src/slider/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/backends/youker-assistant-daemon/src/slider/wizard.py b/backends/youker-assistant-daemon/src/slider/wizard.py new file mode 100644 index 0000000..764f63f --- /dev/null +++ b/backends/youker-assistant-daemon/src/slider/wizard.py @@ -0,0 +1,252 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# +# Author: Kobe Lee +# Maintainer: Ubuntu Kylin +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os +import gtk +import gobject +import math +import locale +#samples:https://developer.gnome.org/pygtk/stable/class-gdkwindow.html + +class TimeController(gobject.GObject): + __gsignals__ = { + 'update': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_FLOAT,)), + 'completed': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), + } + + def __init__(self, timeout): + gobject.GObject.__init__(self) + self.timeout = timeout + self.container = [] + + def start(self): + tmp = (self.timeout / 1000.0) * 30.0 + while len(self.container) <= tmp: + curve = lambda x: math.sin(math.pi / 2 * x) + self.container.append(curve(len(self.container) * (1.0 / tmp))) + self.container.reverse() + gobject.timeout_add(int(self.timeout / tmp), self.update) + + def update(self): + self.emit('update', self.container.pop()) + if len(self.container) == 0: + self.emit('completed') + return False + return True + +class WizardEventBox(gtk.EventBox): + __gsignals__ = { 'close': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),} + def __init__(self, slider_icons=None, pointer_icons=None, button_icons=None): + gtk.EventBox.__init__(self) + self.set_visible_window(False) + self.add_events(gtk.gdk.BUTTON_PRESS_MASK |gtk.gdk.POINTER_MOTION_MASK) + # 显示图片事件 + self.connect("expose-event", self.on_expose_event) + # 鼠标点击滑动点的事件 + self.connect("motion-notify-event", self.on_motion_notify) + # 鼠标事件 + self.connect("button-press-event", self.on_button_press) + # 幻灯片图片 + self.slider_pics = map(gtk.gdk.pixbuf_new_from_file, slider_icons) + # 幻灯片总数 + self.icon_num = len(slider_icons) + # 滑动圆点图片设置 + self.pointer_pic, self.pointer_pic_active = map(gtk.gdk.pixbuf_new_from_file, pointer_icons) + # 开始按钮图片设置 + self.btn_pic, self.btn_pic_press = map(gtk.gdk.pixbuf_new_from_file, button_icons) + button_size = 55 + self.pointer_dict = {} + self.index = 0 + self.dsc_index = None + slider_pixbuf = self.slider_pics[0] + self.slider_width = slider_pixbuf.get_width() + self.slider_height = slider_pixbuf.get_height() + self.set_size_request(self.slider_width, self.slider_height) + self.pointer_width = self.pointer_pic.get_width() + self.pointer_height = self.pointer_pic.get_height() + pointer_width = self.pointer_width * self.icon_num + 10 * (self.icon_num - 1) + self.pointer_sx = (self.slider_width - pointer_width) / 2 + self.pointer_y = self.slider_height -40 + # 开始按钮区域 + self.btn_rect = gtk.gdk.Rectangle((self.slider_width - self.btn_pic.get_width()) / 2, self.slider_height - self.btn_pic.get_height() - button_size, self.btn_pic.get_width(), self.btn_pic.get_height()) + self.alpha = 1.0 + self.active_x = 0 + self.dsc_x = None + self.slider_y = 0 + self.showing = False + self.show_index = None + gobject.timeout_add(2000, lambda : self.start_slider(1000)) + + def draw_pixbuf(self, cr, pixbuf, x=0, y=0, alpha=1.0): + if pixbuf != None: + cr.set_source_pixbuf(pixbuf, x, y) + cr.paint_with_alpha(alpha) + + def on_expose_event(self, widget, event): + # samples:http://zetcode.com/gui/pygtk/drawing/ + cr = widget.window.cairo_create() + rect = widget.allocation + cr.save() + self.draw_pixbuf(cr, self.slider_pics[self.index], rect.x + self.active_x, + rect.x + self.slider_y, self.alpha) + if self.dsc_index != None and self.dsc_x != None: + self.draw_pixbuf(cr, self.slider_pics[self.dsc_index], rect.x + self.dsc_x, + rect.y + self.slider_y, self.dsc_alpha) + cr.restore() + dot_start_x = rect.x + self.pointer_sx + for i in range(self.icon_num): + if self.dsc_index == None: + if self.index == i: + dot_pixbuf = self.pointer_pic_active + else: + dot_pixbuf = self.pointer_pic + else: + if self.dsc_index == i: + dot_pixbuf = self.pointer_pic_active + else: + dot_pixbuf = self.pointer_pic + pointer_rect = gtk.gdk.Rectangle( + dot_start_x, rect.y + self.pointer_y, + self.pointer_width, self.pointer_height) + self.pointer_dict[i] = pointer_rect + self.draw_pixbuf(cr, dot_pixbuf, dot_start_x, rect.y + self.pointer_y) + offset = self.pointer_width + 10 + dot_start_x += offset + if self.dsc_index == self.icon_num - 1: + if self.button_hover_flag: + pixbuf = self.btn_pic_press + else: + pixbuf = self.btn_pic + self.draw_pixbuf(cr, pixbuf, rect.x + self.btn_rect.x, rect.y + self.btn_rect.y) + return True + + def on_motion_notify(self, widget, event): + self.show_index = None + for index, rect in self.pointer_dict.items(): + if rect.x <= event.x <= rect.x + rect.width and rect.y <= event.y <= rect.y + rect.height: + self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2)) + self.show_index = index + break + else: + self.show_index = None + self.window.set_cursor(None) + x, y, w, h = self.btn_rect + if (event.x >= x and event.x <= x + w and event.y >= y and event.y <= y + h): + self.button_hover_flag = True + else: + self.button_hover_flag = False + self.queue_draw() + + def on_button_press(self, widget, event): + # 当前不是空时,重新播放 + if self.show_index != None: + self.start_slider(1000, self.show_index) + # 点击“开始”按钮,关闭启动界面 + x, y, w, h = self.btn_rect + if (event.x >= x and event.x <= x + w and event.y >= y and event.y <= y + h): + self.emit("close") + + def start_slider(self, animation_time, dsc_index=None, direction="left"): + if dsc_index is None: + if self.index >= self.icon_num - 1: + return False + dsc_index = 0 + else: + dsc_index = self.index + 1 + else: + if dsc_index < self.index: + direction = "right" + + if not self.showing: + self.showing = True + self.dsc_index = dsc_index + self.timecontroller = TimeController(animation_time) + self.timecontroller.connect("update", lambda source, status: self.update_slider(source, status, direction)) + self.timecontroller.connect("completed", lambda source: self.complete_slider(source, dsc_index)) + self.timecontroller.start() + return True + + def update_slider(self, source, status, direction): + self.alpha = 1.0 - status + self.dsc_alpha = status + if direction == "right": + self.active_x = self.slider_width * status + self.dsc_x = 0 + else: + self.active_x = 0 - (self.slider_width * status) + self.dsc_x = 0 + self.queue_draw() + + def complete_slider(self, source, index): + self.index = index + self.alpha = 1.0 + self.dsc_alpha = 0.0 + self.showing = False + self.active_x = 0 + self.dsc_x = None + self.queue_draw() + +class Wizard(gtk.Window): + def __init__(self): + gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) + self.set_decorated(False)#去掉默认标题栏 + self.set_position(gtk.WIN_POS_CENTER) + self.set_resizable(False) + self.window_align = gtk.Alignment() + self.window_box = gtk.VBox() + # 图片与边框的距离 + self.window_align.set(0.0, 0.0, 1.0, 1.0) + self.window_align.set_padding(2, 2, 2, 2) + self.add(self.window_align) + self.window_align.add(self.window_box) + wizard_dir = "/usr/share/youker-assistant/qml/img/zh_CN/wizard" + wizard_root_dir = "/usr/share/youker-assistant/qml/img/icons" + slider_icons = (os.path.join(wizard_dir, "%d.png" % i) for i in range(3)) + pointer_icons = (os.path.join(wizard_root_dir, "dot_normal.png"), os.path.join(wizard_root_dir, "dot_active.png")) + button_icons = (os.path.join(wizard_dir, "start_normal.png"), os.path.join(wizard_dir, "start_press.png")) + self.event_box = WizardEventBox(slider_icons, pointer_icons, button_icons) + self.event_box.connect("close", lambda widget: self.destroy()) + self.connect("destroy", self.destroy_wizard) + self.window_box.add(self.event_box) + # 鼠标拖动界面 + self.move_window_event(self.event_box) + + def destroy_wizard(self, widget): + print 'Youker-Assistant slide show is over!' + #widget.destory() + + def is_left_button(self, event): + return event.button == 1 + + def move_window(self, event, widget):#kobe + if self.is_left_button(event): + widget.set_can_focus(True) + widget.grab_focus() + self.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time) + return False + + def move_window_event(self, widget): + widget.connect("button-press-event", lambda w, e: self.move_window(e, w)) + + def show_slider(self): + self.show_all() + gtk.main() diff --git a/backends/youker-assistant-daemon/src/softwarecenter/__init__.py b/backends/youker-assistant-daemon/src/softwarecenter/__init__.py new file mode 100644 index 0000000..013e4b7 --- /dev/null +++ b/backends/youker-assistant-daemon/src/softwarecenter/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/backends/youker-assistant-daemon/src/softwarecenter/apt_daemon.py b/backends/youker-assistant-daemon/src/softwarecenter/apt_daemon.py new file mode 100644 index 0000000..e373672 --- /dev/null +++ b/backends/youker-assistant-daemon/src/softwarecenter/apt_daemon.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE + +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import apt + +class AptDaemon(): + def __init__(self): + self.ca = apt.Cache() + self.ca.open() + +if __name__ == "__main__": + pass diff --git a/backends/youker-assistant-daemon/src/sso/__init__.py b/backends/youker-assistant-daemon/src/sso/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backends/youker-assistant-daemon/src/sso/enums.py b/backends/youker-assistant-daemon/src/sso/enums.py new file mode 100644 index 0000000..e0627d7 --- /dev/null +++ b/backends/youker-assistant-daemon/src/sso/enums.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE + +# Copyright (C) 2014 National University of Defense Technology(NUDT) & Kylin Ltd + +# Author: +# Robert + +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + +import os +import errno +from xdg import BaseDirectory as xdg + +def safe_makedirs(dir_path): + """ This function can be used in place of a straight os.makedirs to + handle the possibility of a race condition when more than one + process may potentially be creating the same directory, it will + not fail if two processes try to create the same dir at the same + time + """ + # avoid throwing an OSError, see for example LP: #743003 + if not os.path.exists(dir_path): + try: + os.makedirs(dir_path) + except OSError as e: + if e.errno == errno.EEXIST: + # it seems that another process has already created this + # directory in the meantime, that's ok + pass + else: + # the error is due to something else, so we want to raise it + raise + +# ported from ubuntu-software-center to support Ubuntu-kylin-SSO +UBUNTU_KYLIN_SSO_SERVICE = 'https://login.ubuntukylin.com/api/1.0' +SOFTWARE_CENTER_NAME_KEYRING = "Youker ID" +SOFTWARE_CENTER_SSO_DESCRIPTION = '注册或登录优客账号。' +datadir = './sso/utils/' +PISTON_GENERIC_HELPER = "piston_generic_helper.py" +YOUKER_ASSISTANT_CACHE_DIR = os.path.join(xdg.xdg_cache_home, "youker-assistant") +safe_makedirs(YOUKER_ASSISTANT_CACHE_DIR) \ No newline at end of file diff --git a/backends/youker-assistant-daemon/src/sso/login.py b/backends/youker-assistant-daemon/src/sso/login.py new file mode 100644 index 0000000..bb79275 --- /dev/null +++ b/backends/youker-assistant-daemon/src/sso/login.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (C) 2010 Canonical +# +# Authors: +# Michael Vogt +# +# 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; version 3. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +from gi.repository import GObject + +import logging +# import os + +LOG = logging.getLogger(__name__) + + +class LoginBackend(GObject.GObject): + + NEW_ACCOUNT_URL = None + FORGOT_PASSWORD_URL = None + + __gsignals__ = { + "login-successful": (GObject.SIGNAL_RUN_LAST, + GObject.TYPE_NONE, + (GObject.TYPE_PYOBJECT,), + ), + "login-failed": (GObject.SIGNAL_RUN_LAST, + GObject.TYPE_NONE, + (), + ), + "login-canceled": (GObject.SIGNAL_RUN_LAST, + GObject.TYPE_NONE, + (), + ), + "need-username-password": (GObject.SIGNAL_RUN_LAST, + GObject.TYPE_NONE, + (), + ), + "logout-successful": (GObject.SIGNAL_RUN_LAST, + GObject.TYPE_NONE, + (), + ), + } + + def login(self): + raise NotImplemented + + def login_or_register(self): + raise NotImplemented + + def find_credentials(self): + raise NotImplemented + + def cancel_login(self): + self.emit("login-canceled") + + def logout(self): + raise NotImplemented + + +def get_login_backend(window_id, appname, help_text): + """ + factory that returns an SSO loader singleton + """ + # if "SOFTWARE_CENTER_FAKE_REVIEW_API" in os.environ: + # from backend.login_impl.login_fake import ( + # LoginBackendDbusSSOFake) + # sso_class = LoginBackendDbusSSOFake(window_id, appname, help_text) + # LOG.warn('Using fake login SSO functionality. Only meant for ' + # 'testing purposes') + # else: + from sso.login_impl.login_sso import ( + LoginBackendDbusSSO) + sso_class = LoginBackendDbusSSO(window_id, appname, help_text) + return sso_class + + +#if __name__ == "__main__": +# logging.basicConfig(level=logging.DEBUG) + +# from models.enums import SOFTWARE_CENTER_NAME_KEYRING +# login = get_login_backend(0, SOFTWARE_CENTER_NAME_KEYRING, "login-text") +# login.login() + +# from gi.repository import Gtk +# Gtk.main() diff --git a/backends/youker-assistant-daemon/src/sso/login_impl/__init__.py b/backends/youker-assistant-daemon/src/sso/login_impl/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backends/youker-assistant-daemon/src/sso/login_impl/login_sso.py b/backends/youker-assistant-daemon/src/sso/login_impl/login_sso.py new file mode 100644 index 0000000..9dd2ca0 --- /dev/null +++ b/backends/youker-assistant-daemon/src/sso/login_impl/login_sso.py @@ -0,0 +1,145 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (C) 2010 Canonical +# +# Authors: +# Michael Vogt +# Robert +# +# 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; version 3. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +import dbus +import logging + +from dbus.mainloop.glib import DBusGMainLoop +DBusGMainLoop(set_as_default=True) + +from ubuntu_kylin_sso import ( + DBUS_BUS_NAME, + DBUS_CREDENTIALS_IFACE, + DBUS_CREDENTIALS_PATH, +) + +from sso.login import LoginBackend + +from sso.enums import SOFTWARE_CENTER_NAME_KEYRING + +LOG = logging.getLogger(__name__) + +def utf8(s): + """ + Takes a string or unicode object and returns a utf-8 encoded + string, errors are ignored + """ + if s is None: + return None + if isinstance(s, unicode): + return s.encode("utf-8", "ignore") + return unicode(s, "utf8", "ignore").encode("utf8") + +class LoginBackendDbusSSO(LoginBackend): + + def __init__(self, window_id, appname, help_text): + super(LoginBackendDbusSSO, self).__init__() + if not appname: + self.appname = SOFTWARE_CENTER_NAME_KEYRING + else: + self.appname = appname + self.help_text = help_text + self.bus = dbus.SessionBus() + obj = self.bus.get_object(bus_name=DBUS_BUS_NAME, + object_path=DBUS_CREDENTIALS_PATH, + follow_name_owner_changes=True) + self.proxy = dbus.Interface(object=obj, + dbus_interface=DBUS_CREDENTIALS_IFACE) + self.proxy.connect_to_signal("CredentialsFound", + self._on_credentials_found) + self.proxy.connect_to_signal("CredentialsNotFound", + self._on_credentials_not_found) + self.proxy.connect_to_signal("CredentialsError", + self._on_credentials_error) + self.proxy.connect_to_signal("AuthorizationDenied", + self._on_authorization_denied) + self.proxy.connect_to_signal("CredentialsCleared", + self._on_credential_cleared) + self._window_id = window_id + self._credentials = None + + def _get_params(self): + p = {} + if self.help_text: + p['help_text'] = utf8(self.help_text) + if self._window_id: + p['window_id'] = self._window_id + return p + + def find_credentials(self): + LOG.debug("find_credentials()") + self._credentials = None + self.proxy.find_credentials(self.appname, self._get_params()) + + def login(self): + LOG.debug("login()") + self._credentials = None + self.proxy.login(self.appname, self._get_params()) + + def login_or_register(self): + LOG.debug("login_or_register()") + self._credentials = None + # print "login_sso::login_or_register:", self.appname, self._get_params() + self.proxy.register(self.appname, self._get_params()) + + def logout(self): + LOG.debug("login_or_register()") + self._credentials = None + self.proxy.clear_credentials(self.appname, {}) + + def _on_credentials_not_found(self, app_name): + LOG.debug("_on_credentials_not_found for '%s'" % app_name) + if app_name != self.appname: + return + self.emit("login-failed") + + def _on_credentials_found(self, app_name, credentials): + LOG.debug("_on_credentials_found for '%s'" % app_name) + if app_name != self.appname: + return + # only emit signal here once, otherwise it may happen that a + # different process that triggers the on the dbus triggers + # another signal emission here! + if self._credentials != credentials: + self.emit("login-successful", credentials) + self._credentials = credentials + + def _on_credentials_error(self, app_name, error, detailed_error=""): + LOG.error("_on_credentials_error for %s: %s (%s)" % ( + app_name, error, detailed_error)) + if app_name != self.appname: + return + # FIXME: do something useful with the error + self.emit("login-failed") + + def _on_authorization_denied(self, app_name): + LOG.info("_on_authorization_denied: %s" % app_name) + if app_name != self.appname: + return + self.cancel_login() + self.emit("login-canceled") + + def _on_credential_cleared(self, app_name): + LOG.info("_on_credential_cleared: %s" % app_name) + if app_name != self.appname: + return + self.emit("logout-successful") diff --git a/backends/youker-assistant-daemon/src/sso/piston/__init__.py b/backends/youker-assistant-daemon/src/sso/piston/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backends/youker-assistant-daemon/src/sso/piston/ubuntusso_pristine.py b/backends/youker-assistant-daemon/src/sso/piston/ubuntusso_pristine.py new file mode 100644 index 0000000..3ebcbf9 --- /dev/null +++ b/backends/youker-assistant-daemon/src/sso/piston/ubuntusso_pristine.py @@ -0,0 +1,23 @@ +from piston_mini_client import PistonAPI, returns_json +from piston_mini_client.validators import oauth_protected + +# These are factored out as constants for if you need to work against a +# server that doesn't support both schemes (like http-only dev servers) +PUBLIC_API_SCHEME = 'http' +AUTHENTICATED_API_SCHEME = 'https' + + +# this is only here because: +# a) ubuntu-sso-client does not support verifying if the credentials +# are still valid +# b) the restful client interface is not really needed because we just +# need this one single call +class UbuntuSsoAPI(PistonAPI): + default_service_root = 'http://localhost:8000/api/2.0' + + @oauth_protected + @returns_json + def whoami(self, id=None): + # return self._get('accounts?ws.op=me', + # scheme=AUTHENTICATED_API_SCHEME) + return self._get('accounts?ws.op=me') diff --git a/backends/youker-assistant-daemon/src/sso/ubuntusso.py b/backends/youker-assistant-daemon/src/sso/ubuntusso.py new file mode 100644 index 0000000..fb5d8dd --- /dev/null +++ b/backends/youker-assistant-daemon/src/sso/ubuntusso.py @@ -0,0 +1,275 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (C) 2010 Canonical +# +# Authors: +# Michael Vogt +# Robert +# +# 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; version 3. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +from gi.repository import GObject, GLib +from gettext import gettext as _ + +import logging +# import os + +import piston_mini_client.auth +import piston_mini_client.failhandlers + +# mostly for testing +#from fake_review_settings import FakeReviewSettings, network_delay +#from spawn_helper import SpawnHelper + +from login import get_login_backend + +from piston.ubuntusso_pristine import ( + UbuntuSsoAPI as PristineUbuntuSsoAPI, +) +# patch default_service_root to the one we use +from enums import UBUNTU_KYLIN_SSO_SERVICE +# *Don't* append /api/1.0, as it's already included in UBUNTU_SSO_SERVICE +PristineUbuntuSsoAPI.default_service_root = UBUNTU_KYLIN_SSO_SERVICE + +from enums import ( + SOFTWARE_CENTER_NAME_KEYRING, + SOFTWARE_CENTER_SSO_DESCRIPTION, +) +import dbus + +LOG = logging.getLogger(__name__) + + +class UbuntuSSO(GObject.GObject): + """ Ubuntu SSO interface using the oauth token from the keyring + + The methods that work synchronously are suffixed with _sync() + """ + __gsignals__ = { + "whoami": (GObject.SIGNAL_RUN_LAST, + GObject.TYPE_NONE, + (GObject.TYPE_PYOBJECT,), + ), + "logout": (GObject.SIGNAL_RUN_LAST, + GObject.TYPE_NONE, + (), + ), + "fail": (GObject.SIGNAL_RUN_LAST, + GObject.TYPE_NONE, + (), + ), + "error": (GObject.SIGNAL_RUN_LAST, + GObject.TYPE_NONE, + (GObject.TYPE_PYOBJECT,), + ), + } + + def __init__(self, xid=0): + GObject.GObject.__init__(self) + self.oauth = None + self.xid = xid + self.show_register = True + self.sso = get_login_backend( + self.xid, + SOFTWARE_CENTER_NAME_KEYRING, + _(SOFTWARE_CENTER_SSO_DESCRIPTION)) + self.sso.connect("login-successful", self._dbus_maybe_login_successful) + self.sso.connect("login-failed", self._fail) + self.sso.connect("login-canceled", self._fail) + self.sso.connect("logout-successful", self._logout_successful) + + def set_show_register(self, show): + self.show_register = not not show + + def whoami(self, token): + auth = piston_mini_client.auth.OAuthAuthorizer( + token["token"], token["token_secret"], + token["consumer_key"], token["consumer_secret"]) + api = PristineUbuntuSsoAPI(auth=auth) + try: + res = api.whoami() + except piston_mini_client.failhandlers.APIError as e: + print "api.whoami failed with APIError: '%s'" % e + LOG.exception("api.whoami failed with APIError: '%s'" % e) + if len(res) == 0: + self.emit("error") + self.oauth = None + else: + self.emit("whoami", res) + + def _dbus_maybe_login_successful(self, sso_backend, oauth_result): +# LOG.debug("_login_successful") + # print("ubuntusso::_login_successful oauth_result: %s" % oauth_result) + self.oauth = oauth_result + self.whoami(self.oauth) + # self.loop.quit() + +# def verify_token(self, token): +# """ Verify that the token is valid +# +# Note that this may raise httplib2 exceptions if the server +# is not reachable +# """ +# # LOG.debug("verify_token") +# auth = piston_mini_client.auth.OAuthAuthorizer( +# token["token"], token["token_secret"], +# token["consumer_key"], token["consumer_secret"]) +# api = PristineUbuntuSsoAPI(auth=auth) +# try: +# res = api.whoami() +# except piston_mini_client.failhandlers.APIError as e: +# print "api.whoami failed with APIError: '%s'" % e +# LOG.exception("api.whoami failed with APIError: '%s'" % e) +# return False +# return len(res) > 0 + + def clear_token(self): + # clear_token_from_ubuntu_sso_sync(SOFTWARE_CENTER_NAME_KEYRING) + # sso = self. _get_login_backend_and_connect() + self.sso.logout() + # GLib.timeout_add_seconds(2, self.loop.quit()) + # self.loop.run() + # return True + + # def _get_login_backend_and_connect(self): + # sso = get_login_backend( + # self.xid, + # SOFTWARE_CENTER_NAME_KEYRING, + # _(SOFTWARE_CENTER_SSO_DESCRIPTION)) + # sso.connect("login-successful", self._dbus_maybe_login_successful) + # sso.connect("login-failed", self._fail) + # sso.connect("login-canceled", self._fail) + # sso.connect("logout-successful", self._logout_successful) + # return sso + + def _fail(self, sso_backend): + self.emit("fail") + + def _logout_successful(self, sso_backend): + self.oauth = None + self.emit("logout") + + def find_oauth_token(self): + self.oauth = None + # sso = self. _get_login_backend_and_connect() + self.sso.find_credentials() + # self.loop.run() + # return self.oauth + + def get_oauth_token(self): + self.oauth = None + # sso = self. _get_login_backend_and_connect() + if self.show_register: + self.sso.login_or_register() + else: + self.sso.login() + # self.loop.run() + # return self.oauth + + # def get_oauth_token_and_verify(self, no_relogin=False): + # token = self.oauth + # # check if the token is valid and reset it if not + # if token: + # # verify token will return false if there is a API error, + # # but there may be httplib2 errors if there is no network, + # # so ignore them + # try: + # if not self.verify_token(token): + # attempt_relogin = not no_relogin + # if attempt_relogin: + # self.clear_token() + # # re-trigger login once + # token = self.get_oauth_token() + # else: + # return None + # except Exception as e: + # print "token could not be verified (network problem?): %s" % e + # LOG.warn( + # "token could not be verified (network problem?): %s" % e) + # return token + # + # def find_oauth_token_and_verify(self): + # token = self.find_oauth_token() + # # check if the token is valid and reset it if not + # if token: + # # verify token will return false if there is a API error, + # # but there may be httplib2 errors if there is no network, + # # so ignore them + # try: + # self.verify_token(token) + # except Exception as e: + # print "token could not be verified (network problem?): %s" % e + # LOG.warn( + # "token could not be verified (network problem?): %s" % e) + # return token + + +def get_ubuntu_sso_backend(): #get_ubuntu_sso_backend(xid): + """ + factory that returns an ubuntu sso loader singleton + """ + # if "SOFTWARE_CENTER_FAKE_REVIEW_API" in os.environ: + # ubuntu_sso_class = UbuntuSSOAPIFake() + # LOG.warn('Using fake Ubuntu SSO API. Only meant for testing purposes') + # else: + ubuntu_sso_class = UbuntuSSO() #UbuntuSSO(xid) + return ubuntu_sso_class + + +# # test code +# def _login_success(lp, token): +# print "success", lp, token +# +# +# def _login_failed(lp): +# print "fail", lp +# +# +# def _login_need_user_and_password(sso): +# import sys +# sys.stdout.write("user: ") +# sys.stdout.flush() +# user = sys.stdin.readline().strip() +# sys.stdout.write("pass: ") +# sys.stdout.flush() +# password = sys.stdin.readline().strip() +# sso.login(user, password) +# +# +# # interactive test code +# if __name__ == "__main__": +# def _whoami(sso, result): +# print "res: ", result +# Gtk.main_quit() +# +# def _error(sso, result): +# print "err: ", result +# Gtk.main_quit() +# +# def _dbus_maybe_login_successful(ssologin, oauth_result): +# print "got token, verify it now" +# sso = UbuntuSSO() +# sso.connect("whoami", _whoami) +# sso.connect("error", _error) +# sso.whoami() +# +# from gi.repository import Gtk +# # logging.basicConfig(level=logging.DEBUG) +# # softwarecenter.paths.datadir = "./data" +# +# backend = get_login_backend("", "appname", "help_text") +# backend.connect("login-successful", _dbus_maybe_login_successful) +# backend.login_or_register() +# Gtk.main() diff --git a/backends/youker-assistant-daemon/src/start_sessiondbus.py b/backends/youker-assistant-daemon/src/start_sessiondbus.py new file mode 100755 index 0000000..5103fef --- /dev/null +++ b/backends/youker-assistant-daemon/src/start_sessiondbus.py @@ -0,0 +1,40 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2007-2011 Tualatrix Chou +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os, sys +import dbus +import signal +import dbus.mainloop.glib +from gi.repository import GObject +from single import SingleInstance +#import gobject + +if __name__ == '__main__': + myapp = SingleInstance("/tmp/youker-assistant-sessiondbus-%d.pid" % os.getuid()) + if myapp.is_already_running(): + print "Another instance of this sessiondbus is already running" + sys.exit("Another instance of this sessiondbus is already running") + from sessiondbus.daemon import SessionDaemon + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + GObject.threads_init() + mainloop = GObject.MainLoop() + #gobject.threads_init() + #mainloop = gobject.MainLoop() + signal.signal(signal.SIGINT, lambda : mainloop.quit()) + SessionDaemon(mainloop) + mainloop.run() diff --git a/backends/youker-assistant-daemon/src/start_systemdbus.py b/backends/youker-assistant-daemon/src/start_systemdbus.py new file mode 100755 index 0000000..65df9a2 --- /dev/null +++ b/backends/youker-assistant-daemon/src/start_systemdbus.py @@ -0,0 +1,44 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import os, sys +import signal +import dbus +import dbus.mainloop.glib +from gi.repository import GObject +from single import SingleInstance +#import gobject + +if __name__ == '__main__': + myapp = SingleInstance("/tmp/youker-assistant-systemdbus-%d.pid" % os.getuid()) + if myapp.is_already_running(): + print "Another instance of this systemdbus is already running" + sys.exit("Another instance of this systemdbus is already running") + os.environ["TERM"] = "xterm" + os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin" + os.environ["DEBIAN_FRONTEND"] = "noninteractive" + if os.path.exists("/var/lib/apt/lists/lock"): + os.remove("/var/lib/apt/lists/lock") + from systemdbus.daemon import Daemon + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + GObject.threads_init() + mainloop = GObject.MainLoop() + #gobject.threads_init() + #mainloop = gobject.MainLoop() + signal.signal(signal.SIGINT, lambda : mainloop.quit()) + Daemon(dbus.SystemBus(), mainloop) + mainloop.run() diff --git a/backends/youker-assistant-daemon/src/sysinfo/__init__.py b/backends/youker-assistant-daemon/src/sysinfo/__init__.py new file mode 100644 index 0000000..5791acc --- /dev/null +++ b/backends/youker-assistant-daemon/src/sysinfo/__init__.py @@ -0,0 +1,259 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import sys +import os +from gi.repository import GLib +import platform +import math +import apt + +NO_UPDATE_WARNING_DAYS = 7 +FILEPATH = "/etc/lsb-release" +RELEASEPATH = "/etc/ubuntukylin-release" + +KILOBYTE_FACTOR = 1000.0 +MEGABYTE_FACTOR = (1000.0 * 1000.0) +GIGABYTE_FACTOR = (1000.0 * 1000.0 * 1000.0) +TERABYTE_FACTOR = (1000.0 * 1000.0 * 1000.0 * 1000.0) + +def get_human_read_capacity_size(size): + size_str = "" + displayed_size = 0.0 + unit = "KB" + + if size < MEGABYTE_FACTOR: + displayed_size = float(size/KILOBYTE_FACTOR) + unit = "KB" + elif size < GIGABYTE_FACTOR: + displayed_size = float(size/MEGABYTE_FACTOR) + unit = "MB" + elif size < TERABYTE_FACTOR: + displayed_size = float(size/GIGABYTE_FACTOR) + unit = "GB" + else: + displayed_size = float(size/TERABYTE_FACTOR) + unit = "TB" + #print "displayed_size=", round(displayed_size) + #round 不是简单的四舍五入,而是ROUND_HALF_EVEN的策略 + #ceil 取大于或者等于x的最小整数 + #floor 取小于或者等于x的最大整数 + #print round(2.5)#3.0 + #print math.ceil(2.5)#3.0 + #print math.floor(2.5)#2.0 + #print round(2.3)#2.0 + #print math.ceil(2.3)#3.0 + #print math.floor(2.3)#2.0 + str_list = [str(int(round(displayed_size))), unit] + size_str = " ".join(str_list) + return size_str + + +class Sysinfo: + CACHE_FLAG = '' + CACHE_PACKAGES = '' + CACHE_SIZE = '' + CPU = '' + RAM = '' + HOSTNAME = '' + PLATFORM = '' + DISTRO = '' + DESKTOP_FULLNAME = '' + UPDATE_TIME = '' + CURRENT_USER = '' + HOME_DIRECTORY = '' + SHELL = '' + LANGUAGE = '' + + def __init__(self): + self.CACHE_FLAG = 'a' + self.CACHE_PACKAGES = 'b' + self.CACHE_SIZE = 'c' + self.CPU = 'd' + self.RAM = 'e' + self.HOSTNAME = 'f' + self.PLATFORM = 'g' + self.DISTRO = 'h' + self.DESKTOP_FULLNAME = 'i' + self.UPDATE_TIME = 'j' + self.CURRENT_USER = 'k' + self.HOME_DIRECTORY = 'l' + self.SHELL = 'm' + self.LANGUAGE = 'n' + + def get_sys_msg(self): + CLIPS_DICT = {} + CLIPS_DICT['currrent_user'], CLIPS_DICT['home_path'], CLIPS_DICT['terminal'], CLIPS_DICT['language'] = self.get_userinfo() + CLIPS_DICT['distribution'] = self.get_distro() + CLIPS_DICT['desktopenvironment'] = self.get_desktop() + CLIPS_DICT['hostname'], CLIPS_DICT['machine'] = self.get_systeminfo() + CLIPS_DICT['cpu'], CLIPS_DICT['ram'] = self.get_hardwareinfo() + return CLIPS_DICT + + def get_userinfo(self): + dict = {} + dict['username'] = GLib.get_user_name() + dict['homedir'] = GLib.get_home_dir() + dict['terminal'] = GLib.getenv('SHELL') + dict['lang'] = GLib.getenv('LANG') + return dict['username'], dict['homedir'],dict['terminal'],dict['lang'] + + def get_distro(self): + '''It should be: DISTRIB_DESCRIPTION="UbuntuKylin 13.10''' + #FILEPATH RELEASEPATH + distro = "" + if os.path.exists(RELEASEPATH): + with open(RELEASEPATH, "r") as fsys: + for line in fsys: + if line.startswith("DISTRIB_DESCRIPTION"): + tmp = line + break + # kobe: remove '"' and '\n' + front = tmp.split('=')[1].replace('"', '').replace('\n', '') #(LP: #1240862) + distro = front + '-' + platform.dist()[2] + elif os.path.exists("/etc/os-release"): + with open("/etc/os-release", "r") as fsys: + for line in fsys: + if line.startswith("PRETTY_NAME"): + tmp = line + break + distro = tmp.split('=')[1].replace('"', '').replace('\n', '') + else: + a = platform.dist()[0] + b = platform.dist()[1] + c = platform.dist()[2] + distro = '-'.join((a,b,c)) +# if not os.path.exists(RELEASEPATH): +# with open(FILEPATH, "r") as fsys: +# for line in fsys: +# if line.startswith("DISTRIB_DESCRIPTION"): +# tmp = line +# break +# # kobe: remove '"' and '\n' +# front = tmp.split('=')[1].replace('"', '').replace('\n', '') #(LP: #1240862) +# if front.startswith("UbuntuKylin") or front.startswith("Ubuntu Kylin"): +# distro = front + '-' + platform.dist()[2] +# else: +# a = platform.dist()[0] +# b = platform.dist()[1] +# c = platform.dist()[2] +# distro = '-'.join((a,b,c)) +# else: +# with open(RELEASEPATH, "r") as fp: +# for line in fp: +# if line.startswith("DISTRIB_ID"): +# tmp1 = line +# elif line.startswith("DISTRIB_RELEASE"): +# tmp2 = line +# elif line.startswith("DISTRIB_CODENAME"): +# tmp3 = line +# # kobe: remove '"' and '\n' +# id = tmp1.split('=')[1].replace('"', '').replace('\n', '') +# release = tmp2.split('=')[1].replace('"', '').replace('\n', '') +# codename = tmp3.split('=')[1].replace('"', '').replace('\n', '') +# distro = '-'.join((id, release, codename)) + return distro + + def get_desktop(self): + apt_cache = apt.Cache() + try: + package = apt_cache["kylin-menu"] + except: + package = None + if package is not None and package.is_installed: + return "UKUI" + desktop_dict = {'ubuntu': 'Unity', + 'ubuntu-2d': 'Unity 2D', + 'gnome': 'GNOME Shell', + 'gnome-classic': 'GNOME Classic', + 'gnome-shell': 'GNOME Shell', + 'gnome-fallback': 'GNOME Fallback', + 'pantheon': 'elementary OS (Luna)', + 'Lubutu': 'LXDE', + } + try: + desktop_name = os.getenv('XDG_CURRENT_DESKTOP') + if desktop_name is None: + desktop_name = os.getenv('XDG_SESSION_DESKTOP') + if desktop_name is None: + desktop_name = "N/A" + return desktop_name + except Exception as e: + print e + desktop = os.getenv('DESKTOP_SESSION') + if desktop in desktop_dict: + return desktop_dict[desktop] + else: + if desktop: + return 'Unknown (%s)' % desktop + else: + return 'Unknown' + + + def get_systeminfo(self): + return platform.node() , platform.processor() + + def get_hardwareinfo(self): + model_name = 'N/A' +# MemTotal2 = '' + MemSize = None + # CPU + with open('/proc/cpuinfo') as f: + for line in f: + if line.strip(): + if line.rstrip('\n').startswith('model name'): + model_name = line.rstrip('\n').split(':')[1] + break + elif line.rstrip('\n').startswith('Hardware'): + model_name = line.rstrip('\n').split(':')[1].strip() + break + # Memory +# with open('/proc/meminfo') as f: +# for line in f: +# if line.strip(): +# if line.rstrip('\n').startswith('MemTotal'): +# MemTotal = line.rstrip('\n').split(':')[1].strip() +# MemTotal1 = MemTotal.split(' ')[0] +# #MemTotal2 = GLib.format_size_for_display(int(MemTotal1) * 1024) +# MemTotal2 = str(round(float(MemTotal1) / (1000 ** 2), 1)) + "G" +# break + + with open('/proc/meminfo') as f: + for line in f: + if line.strip(): + if line.rstrip('\n').startswith('MemTotal'): + MemTotal = line.rstrip('\n').split(':')[1].strip() + MemTmp = MemTotal.split(' ')[0] + #print "MemTmp=",MemTmp + #MemTmp = 1000204886#8156252#7889972 + MemSize = get_human_read_capacity_size(int(MemTmp)*1000) + break + if MemSize is None: + MemSize = "N/A" + return model_name,str(MemSize) +# return model_name,MemTotal2 + + def get_codename(self): + codename = platform.dist()[2] + return codename + +if __name__ == '__main__': + c = Sysinfo() + print(c.get_sys_msg()) + import getpass + print(getpass.getuser()) diff --git a/backends/youker-assistant-daemon/src/systemdbus/__init__.py b/backends/youker-assistant-daemon/src/systemdbus/__init__.py new file mode 100644 index 0000000..013e4b7 --- /dev/null +++ b/backends/youker-assistant-daemon/src/systemdbus/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/backends/youker-assistant-daemon/src/systemdbus/apt_handler.py b/backends/youker-assistant-daemon/src/systemdbus/apt_handler.py new file mode 100644 index 0000000..d51440f --- /dev/null +++ b/backends/youker-assistant-daemon/src/systemdbus/apt_handler.py @@ -0,0 +1,328 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import apt +import apt.progress.base as apb +from apt.debfile import DebPackage +from apt.cache import FetchFailedException + +import locale + +# application actions +class AppActions: + INSTALLDEPS = "install_deps" + INSTALLDEBFILE = "install_debfile" + INSTALL = "install" + REMOVE = "remove" + UPGRADE = "upgrade" + CANCEL = "cancel" + APPLY = "apply_changes" + PURCHASE = "purchase" + UPDATE = "update" + UPDATE_FIRST = "update_first" + ADD_SOURCE = "add_source" + REMOVE_SOURCE = "remove_source" + GET_SOURCES = "get_sources" + + +class FetchProcess(apb.AcquireProgress): + + def __init__(self, dbus_service, appname, action): + apb.AcquireProgress.__init__(self) + self.dbus_service = dbus_service + self.appname = appname + self.action = action + + def done(self, item): +# kwarg = {"download_appname":self.appname, +# "download_percent":str(self.percent), +# "action":str(self.action), +# } + kwarg = [] + kwarg.append(self.appname) + kwarg.append(str(self.percent)) + kwarg.append(str(self.action)) + + self.dbus_service.youker_fetch_signal("down_done", kwarg) + + def fail(self, item): +# kwarg = {"download_appname":self.appname, +# "download_percent":str(self.percent), +# "action":str(self.action), +# } + kwarg = [] + kwarg.append(self.appname) + kwarg.append(str(self.percent)) + kwarg.append(str(self.action)) + self.dbus_service.youker_fetch_signal("down_fail", kwarg) + + def fetch(self, item): +# kwarg = {"download_appname":self.appname, +# "download_percent":str(self.percent), +# "action":str(self.action), +# } + kwarg = [] + kwarg.append(self.appname) + kwarg.append(str(self.percent)) + kwarg.append(str(self.action)) + self.dbus_service.youker_fetch_signal("down_fetch", kwarg) + + def ims_hit(self, item): + print 'ims_hit' + pass + + def media_change(self, media, drive): + print 'media_change' + pass + + def pulse(self, owner): + + if self.action == AppActions.UPDATE or self.action == AppActions.UPDATE_FIRST: + if self.total_items!= 0: + percent = float(self.current_items * 100.0 / self.total_items) + if percent > self.percent: + self.percent = percent + else: + if self.total_bytes != 0: + self.percent = float(self.current_bytes * 100.0 / self.total_bytes) + +# kwarg = {"download_appname":self.appname, +# "download_percent":str(self.percent), +# "download_bytes":str(self.current_bytes), +# "total_bytes":str(self.total_bytes), +# "download_items":str(self.current_items), +# "total_items":str(self.total_items), +# "action":str(self.action), +# } + kwarg = [] + kwarg.append(self.appname) + kwarg.append(str(self.percent)) + kwarg.append(str(self.action)) + kwarg.append(self.current_bytes) + kwarg.append(str(self.total_bytes)) + kwarg.append(str(self.current_items)) + kwarg.append(str(self.total_items)) + self.dbus_service.youker_fetch_signal("down_pulse", kwarg) + + # cancel the operation + if self.dbus_service.check_cancel_worker_item(self.appname) is True: + print "download_cancel" + self.dbus_service.youker_fetch_signal("down_cancel", kwarg) + return False + + def start(self): + # Reset all our values. + self.current_bytes = 0.0 + self.current_cps = 0.0 + self.current_items = 0 + self.elapsed_time = 0 + self.fetched_bytes = 0.0 + self.last_bytes = 0.0 + self.total_bytes = 0.0 + self.total_items = 0 + self.percent = 0 + +# kwarg = {"download_appname":self.appname, +# "download_percent":str(self.percent), +# "action":str(self.action), +# } + kwarg = [] + kwarg.append(self.appname) + kwarg.append(str(self.percent)) + kwarg.append(str(self.action)) + self.dbus_service.youker_fetch_signal("down_start", kwarg) + + def stop(self): +# kwarg = {"download_appname":self.appname, +# "download_percent":str(200), +# "action":str(self.action), +# } + kwarg = [] + kwarg.append(self.appname) + kwarg.append(str(200)) + kwarg.append(str(self.action)) + self.dbus_service.youker_fetch_signal("down_stop", kwarg) + + +class AptProcess(apb.InstallProgress): + '''Apt progress''' + def __init__(self, dbus_service, appname, action): + apb.InstallProgress.__init__(self) + self.dbus_service = dbus_service + self.appname = appname + self.percent = 0 + self.action = action + + def conffile(self, current, new): + pass + + def error(self, pkg, errormsg): +# kwarg = {"apt_appname":str(pkg), +# "apt_percent":str(self.percent), +# "action":str(self.action), +# } + kwarg = [] + kwarg.append(str(pkg)) + kwarg.append(str(self.percent)) + kwarg.append(str(self.action)) + self.dbus_service.youker_apt_signal("apt_error", kwarg) + + def start_update(self): +# kwarg = {"apt_appname":self.appname, +# "apt_percent":str(self.percent), +# "action":str(self.action), +# } + kwarg = [] + kwarg.append(self.appname) + kwarg.append(str(self.percent)) + kwarg.append(str(self.action)) + self.dbus_service.youker_apt_signal("apt_start", kwarg) + + def finish_update(self): +# kwarg = {"apt_appname":self.appname, +# "apt_percent":str(200), +# "action":str(self.action), +# } + kwarg = [] + kwarg.append(self.appname) + kwarg.append(str(200)) + kwarg.append(str(self.action)) + self.dbus_service.youker_apt_signal("apt_finish", kwarg) + + def status_change(self, pkg, percent, status): +# kwarg = {"apt_appname":str(pkg), +# "apt_percent":str(percent), +# "action":str(self.action), +# "status":str(status), +# } + kwarg = [] + kwarg.append(str(pkg)) + kwarg.append(str(percent)) + kwarg.append(str(self.action)) + kwarg.append(str(status)) + self.dbus_service.youker_apt_signal("apt_pulse", kwarg) + +class AptHandler(): + + def __init__(self, dbus_service): + self.dbus_service = dbus_service + locale.setlocale(locale.LC_ALL, "zh_CN.UTF-8") + self.cache = apt.Cache() + self.cache.open() + + # get package by pkgName + def get_pkg_by_name(self, pkgName): + try: + return self.cache[pkgName] + except KeyError: + raise WorkitemError(1, "Package %s is not available" % pkgName) + # except Exception, e: + # print e + # return "ERROR" + + # install deps + def install_deps(self, path, kwargs=None): + debfile = DebPackage(path) + pkgName = debfile._sections["Package"] + debfile.check() + deps = debfile.missing_deps + + if(len(deps) > 0): + self.cache.open() + for pkgn in deps: + pkg = self.get_pkg_by_name(pkgn) + pkg.mark_install() + + try: + self.cache.commit(FetchProcess(self.dbus_service, pkgName, AppActions.INSTALLDEPS), AptProcess(self.dbus_service, pkgName, AppActions.INSTALLDEPS)) + except Exception, e: + print e + print "install err" + + # install package + def install(self, pkgName, kwargs=None): + print "real install->", pkgName + self.cache.open() + pkg = self.get_pkg_by_name(pkgName) + print pkg.installed.version#1.2.0-0ubuntu1 + print len(pkg.versions)#2 + print pkg.versions[0].version#1.3.1-0ubuntu1 + print pkg.versions[1].version#1.2.0-0ubuntu1 +# if pkg.is_installed: +# raise WorkitemError(7, "Package %s is installed" % pkgName) + pkg.mark_install() + + try: + self.cache.commit(FetchProcess(self.dbus_service, pkgName, AppActions.INSTALL), AptProcess(self.dbus_service, pkgName, AppActions.INSTALL)) + except apt.cache.FetchFailedException as error: + raise WorkitemError(2, str(error)) + except apt.cache.LockFailedException: + raise WorkitemError(3, "package manager is running.") + except Exception as e: + raise WorkitemError(0, "unknown error") + # except Exception, e: + # print e + # print "install err" + + # update packages + def upgrade(self, pkgNames, kwargs=None): + self.cache.open() + + for pkgName in pkgNames: + pkg = self.get_pkg_by_name(pkgName) + pkg.mark_upgrade() + + try: + self.cache.commit(FetchProcess(self.dbus_service, "#upgrade", AppActions.UPGRADE), AptProcess(self.dbus_service, "#upgrade", AppActions.UPGRADE)) + except apt.cache.FetchFailedException as error: + raise WorkitemError(2, str(error)) + except apt.cache.LockFailedException: + raise WorkitemError(3, "package manager is running.") + except Exception as e: + raise WorkitemError(0, "unknown error") + # except Exception, e: + # print e + # print "update err" + + def upone(self, pkgName, kwargs=None): + self.cache.open() + pkg = self.get_pkg_by_name(pkgName) + pkg.mark_install() + + try: + self.cache.commit(FetchProcess(self.dbus_service, pkgName, AppActions.INSTALL), AptProcess(self.dbus_service, pkgName, AppActions.INSTALL)) + except apt.cache.FetchFailedException as error: + raise WorkitemError(2, str(error)) + except apt.cache.LockFailedException: + raise WorkitemError(3, "package manager is running.") + except Exception as e: + raise WorkitemError(0, "unknown error") + + # apt-get update + def update(self, kwargs=None): + quiet = False + if kwargs is not None: + quiet = int(kwargs["quiet"]) + + try: + if quiet == True: + print "quiet=True" + self.cache.update() + else: + print "quiet=False" + self.cache.update(fetch_progress=FetchProcess(self.dbus_service, "#update", AppActions.UPDATE)) + except Exception, e: + print e + print "update except" + + +class WorkitemError(Exception): + + def __init__(self, errornum, details = ""): + self.errornum = errornum + self.details = details + + +if __name__ == "__main__": + ad = AptHandler(None) + ad.upgrade(['khelpcenter4']) diff --git a/backends/youker-assistant-daemon/src/systemdbus/daemon.py b/backends/youker-assistant-daemon/src/systemdbus/daemon.py new file mode 100644 index 0000000..20a6420 --- /dev/null +++ b/backends/youker-assistant-daemon/src/systemdbus/daemon.py @@ -0,0 +1,810 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +### BEGIN LICENSE +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 . +### END LICENSE + +import sys +import os +import signal +import glob +import fcntl +import shutil +import logging +import tempfile +import subprocess +import re +import dbus +import dbus.service +import dbus.mainloop.glib +from gi.repository import GObject +#import apt +#import aptsources.sourceslist +#import apt_pkg +import threading +import thread +from server import PolicyKitService +from policykit import UK_ACTION_YOUKER +import time +import cleaner +from detailinfo.cpuinfo import DetailInfo +from beautify.sound import Sound +from beautify.others import Others +#from appcollections.monitorball.monitor_ball import MonitorBall +#from softwarecenter.apt_daemon import AptDaemon +from beautify.theme import Theme +log = logging.getLogger('Daemon') + + +INTERFACE = 'com.ubuntukylin.youker' +UKPATH = '/' + +#------------------------------------apt start---------------------------- +from apt_handler import AppActions, AptHandler, WorkitemError +#class WorkItem: +# def __init__(self, pkgname, action, kwargs): +# self.pkgname = pkgname +# self.action = action +# self.kwargs = kwargs + +#class WorkThread(threading.Thread): +# def __init__(self, dbusDaemon): +# threading.Thread.__init__(self) +# self.dbusDaemon = dbusDaemon +# print "$$$$$$$$$$$$$$ ", type(self.dbusDaemon) + +# def run(self): +# while(True): +# if len(self.dbusDaemon.worklist) == 0: +# time.sleep(0.2) +# continue + +# self.dbusDaemon.mutex.acquire() +# item = self.dbusDaemon.worklist.pop(0) #get first item and remove it from list +# self.dbusDaemon.mutex.release() + +# try: +# func = getattr(self.dbusDaemon.aptHandler, item.action) +# if func is None: +# print "Error action: ", item + +# res = func(item.pkgname,item.kwargs) +# if res is False: +# print "Action exec failed..." +# except WorkitemError as e: +# kwarg = {"apt_appname": item.pkgname, +# "apt_percent": str(-e.errornum), +# "action": str(item.action), +# } +# self.dbusDaemon.youker_apt_signal("apt_error", kwarg) + +# time.sleep(0.3) +#------------------------------------apt end---------------------------- + +class Daemon(PolicyKitService): + def __init__ (self, bus, mainloop): + self.infoconf = DetailInfo() + self.otherconf = Others() + self.soundconf = Sound() +# self.ballconf = MonitorBall() + self.themeconf = Theme() +# self.daemonsame = cleaner.SearchTheSame() +# self.daemonlarge = cleaner.ManageTheLarge() +# self.daemonunneed = cleaner.CleanTheUnneed() +# self.daemonclean = cleaner.FunctionOfClean() + self.daemononekey = cleaner.OneKeyClean() +# self.daemoncache = cleaner.CleanTheCache() +# self.daemonApt = AptDaemon() + #self.daemonApt = AptDaemon(self) + + #--------------apt start---------------- + self.aptHandler = AptHandler(self) +# self.worklist = [] +# self.mutex = threading.RLock() +# self.worker_thread = WorkThread(self) +# self.worker_thread.setDaemon(True) +# self.worker_thread.start() + #--------------apt end---------------- + + bus_name = dbus.service.BusName(INTERFACE, bus=bus) + PolicyKitService.__init__(self, bus_name, UKPATH) + self.mainloop = mainloop + + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def exit(self): + self.mainloop.quit() + + #--------------apt start---------------- +# def add_worker_item(self, item): +# print "####add_worker_item:", item +# self.mutex.acquire() +# self.worklist.append(item) +# self.mutex.release() + + # package download status signal + '''parm mean + type: + start:start download + stop:all work is finish + done:all items download finished + fail:download failed + fetch:one item download finished + pulse:download status, this msg given a string like dict + msg: + a message of type, sometimes is None + ''' + @dbus.service.signal(INTERFACE, signature='sas') + def youker_fetch_signal(self, type, msg): + pass + + # package install/update/remove signal + '''parm mean + type: + start:start work + stop:work finish + error:got a error + pulse:work status, this msg given a string like dict + msg: + a message of type, sometimes is None + ''' + @dbus.service.signal(INTERFACE, signature='sas') + def youker_apt_signal(self, type, msg): + pass + + def start_install_uk(self, pkgName): + self.aptHandler.install(pkgName) + + # install package sa:youker_fetch_signal() and youker_apt_signal() + #sudo apt-get install youker-assistant=1.3.1-0ubuntu1 + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b', sender_keyword='sender') + def install(self, pkgName, sender=None): + print "####install: ",pkgName +# item = WorkItem(pkgName, AppActions.INSTALL, None) +# self.add_worker_item(item) +# self.aptHandler.install(pkgName) + thread.start_new_thread(self.start_install_uk, (pkgName,)) + print "####install return" + return True + + def start_update_source_list(self): + self.aptHandler.update() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b', sender_keyword='sender') + def update(self, sender=None): + thread.start_new_thread(self.start_update_source_list, ()) +# self.aptHandler.update() + return True + +# @dbus.service.method(INTERFACE, in_signature='as', out_signature='b', sender_keyword='sender') +# def upgrade(self, pkgNames, sender=None): +# print "####upgrade: ", pkgNames +# item = WorkItem(pkgNames, AppActions.UPGRADE, None) +# self.add_worker_item(item) +# # self.aptHandler.upgrade_pkg(pkgName) +# print "####upgrade return" +# return True + #--------------apt end---------------- + + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_homedir(self, homedir): + self.soundconf.set_homedir(homedir) + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def adjust_cpufreq_scaling_governer(self, value): + cpufreq_file = "/etc/init.d/cpufrequtils" + oldvalue = '' + if os.path.exists(cpufreq_file): + fp = open(cpufreq_file, "rw+") + line = fp.readline() + while line: + if line.startswith("GOVERNOR="): + if value not in line: + oldvalue = line.split("=")[1].replace('"', '').replace('\n', '') + break + line = fp.readline() + fp.close() + if oldvalue not in ['', None] and value not in ['', None]: + cmd = "sed -i 's/%s/%s/g' %s" % (oldvalue, value, cpufreq_file) + os.system(cmd) + os.system('service cpufrequtils restart') + else: + fpath = os.path.expanduser("/sys/devices/system/cpu/") + for line in os.listdir(fpath): + line = line.strip('\n') + #pattern = re.compile(r'cpu.*[0-9]$') + pattern = re.compile(r'cpu.*\d\Z') + m = pattern.match(line) + if m: + filepath = "/sys/devices/system/cpu/%s/cpufreq/scaling_governor" % line + if os.path.exists(filepath): + cmd = 'echo %s > %s' % (value, filepath) + os.system(cmd) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_cpufreq_scaling_governer_list(self): + cmd = "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors" + fp = os.popen(cmd) + msg = fp.read().strip('\n') + fp.close() + cpulist = [] + if msg not in ['', None]: + cpulist = msg.split(' ') + return cpulist + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_current_cpufreq_scaling_governer(self): + cmd = "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" + fp = os.popen(cmd) + msg = fp.read().strip('\n') + fp.close() + return msg + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def copy_file(self, filename): + des_path = '/var/lib/youker-assistant-daemon/custom' + filename = filename.encode('utf-8') + if not os.path.exists(des_path): + os.makedirs(des_path) + try: + shutil.copy(filename, des_path) + return True + except os.error: + pass + return False + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def delete_file(self, filename): + filename = filename.encode('utf-8') +# output = open("/tmp/default.txt", 'w+') +# output.write(filename) +# output.close() +# fp = open("/tmp/default.txt", "w") +# print >> fp, "--------------" +# print >> fp, filename +# print >> fp, "------22222222--------" +# fp.close() +# if os.path.exists(filename): + if os.path.isfile(filename): + try: + os.remove(filename) + return True + except os.error: + pass + return False + + # set cursor theme + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b') + def set_cursor_theme_with_root(self, theme): + return self.themeconf.set_cursor_theme_with_root(theme) + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='b', sender_keyword='sender') + def kill_root_process(self, pid, sender=None): + status = self._check_permission(sender, UK_ACTION_YOUKER) + if not status: + return False + cmd = 'kill -9 %s' % pid + subprocess.Popen(cmd, shell=True, close_fds=True)#加上close_fds=True,避免子进程一直存在 + return True + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def kill_uk_process(self): + cmd = 'killall youker-assistant' + subprocess.Popen(cmd, shell=True, close_fds=True)#加上close_fds=True,避免子进程一直存在 + return True + + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def set_user_homedir(self, homedir): + cleaner.get_user_homedir(homedir) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_system_daemon(self): + return "SystemDaemon" + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_computer_info(self): + return self.infoconf.get_computer() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_os_name(self): + return self.infoconf.get_os_name() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_cpu_info(self): + return self.infoconf.get_cpu() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_board_info(self): + return self.infoconf.get_board() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_memory_info(self): + return self.infoconf.get_memory() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_harddisk_info(self): + return self.infoconf.get_disk() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_networkcard_info(self): + return self.infoconf.get_network() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_monitor_info(self): + return self.infoconf.get_monitor() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_cdrom_info(self): + return self.infoconf.get_dvd() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_audiocard_info(self): + return self.infoconf.get_multimedia() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='s') + def get_time_value(self): + return self.infoconf.uptimeinfo() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='a{sv}') + def get_sensor_info(self): + return self.infoconf.get_sensors() + + @dbus.service.method(INTERFACE, in_signature='', out_signature='b') + def judge_sensors_exists_hb(self): + return self.infoconf.judge_sensors_exists() + + + # -------------------------sound------------------------- + # get sound themes + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_sound_themes(self): + return self.soundconf.get_sound_themes() + + # get sound files in current sound theme + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_sounds(self): + return self.soundconf.get_sounds() + + # replace a sound file + @dbus.service.method(INTERFACE, in_signature='ss', out_signature='') + def replace_sound_file(self, newSoundFile, targetSoundFile): + self.soundconf.replace_sound_file(newSoundFile, targetSoundFile) + + # restore a sound file + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def restore_sound_file(self, targetSoundFile): + self.soundconf.restore_sound_file(targetSoundFile) + + # restore all sound file in current sound theme + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def restore_all_sound_file(self, soundTheme): + self.soundconf.restore_all_sound_file(soundTheme) + + # -------------------------others------------------------- + + # custom plymouth bg by plymouthName + @dbus.service.method(INTERFACE, in_signature='s', out_signature='') + def custom_plymouth_bg(self, plymouthName): + self.otherconf.custom_plymouth_bg(plymouthName) + + # add new custom plymouth + @dbus.service.method(INTERFACE, in_signature='ss', out_signature='') + def add_new_plymouth(self, customBG, plymouthName): + self.otherconf.add_new_plymouth(customBG, plymouthName) + + # get existing plymouth list + @dbus.service.method(INTERFACE, in_signature='', out_signature='as') + def get_existing_plymouth_list(self): + return self.otherconf.get_existing_plymouth_list() + + # check and save current plymouth when init + @dbus.service.method(INTERFACE, in_signature='', out_signature='') + def plymouth_init_check(self): + self.otherconf.plymouth_init_check() + + # get image path + @dbus.service.method(INTERFACE, in_signature='s', out_signature='s') + def get_image_path(self,name): + return self.otherconf.get_image_path(name) + + # Delete the boot animation from the list + @dbus.service.method(INTERFACE, in_signature='s', out_signature='s') + def delete_plymouth(self,plymouthName): + return self.otherconf.delete_plymouth(plymouthName) + + # -------------------------monitorball------------------------- + # clean up memory +# @dbus.service.method(INTERFACE, in_signature='', out_signature='') +# def cleanup_memory(self): +# self.ballconf.cleanup_memory() + # -------------------------monitorball end------------------------- + + @dbus.service.signal(INTERFACE, signature='s') + def clean_complete_onekey(self, msg): + pass + + @dbus.service.signal(INTERFACE, signature='s') + def clean_error_onekey(self, msg): + pass + + @dbus.service.signal(INTERFACE, signature='ss') + def status_for_quick_clean(self, flag, status): + pass + + # a dbus method which means clean complete + @dbus.service.signal(INTERFACE, signature='s') + def clean_complete(self, msg): + pass + + # a dbus method which means quit clean by clicking the policykit's quit button + @dbus.service.signal(INTERFACE, signature='b') + def quit_clean(self, status): + pass + + # a dbus method which means clean single complete + @dbus.service.signal(INTERFACE, signature='s') + def clean_single_complete(self, msg): + pass + + # a dbus method which means an error occurred + @dbus.service.signal(INTERFACE, signature='s') + def clean_error(self, msg): + pass + + # a dbus method which means an single error occurred + @dbus.service.signal(INTERFACE, signature='s') + def clean_single_error(self, msg): + pass + + @dbus.service.method(INTERFACE, in_signature='as', out_signature='', sender_keyword='sender') + def onekey_clean_crufts_function(self, mode_list, sender=None): + status = self._check_permission(sender, UK_ACTION_YOUKER) + if not status: + self.revoke_clean_onekey('yes') + return + else: + self.revoke_clean_onekey('no') + daemononekey = cleaner.OneKeyClean() + try: + t = threading.Thread(target = daemononekey.clean_all_onekey_crufts, args = (self, mode_list)) + t.start() + #daemononekey.clean_all_onekey_crufts(self, mode_list) + except Exception, e: + self.clean_error_msg('onekey') + else: + self.clean_complete_msg('onekey') + +# @dbus.service.method(INTERFACE, in_signature='as', out_signature='', sender_keyword='sender') +# def onekey_clean_crufts_function_by_threading(self, mode_list, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.revoke_clean_onekey('yes') +# return +# else: +# self.revoke_clean_onekey('no') +# daemononekey = cleaner.OneKeyClean() +# try: +# t = threading.Thread(target = daemononekey.clean_all_onekey_crufts, args = (self, mode_list)) +# #daemononekey.clean_all_onekey_crufts(self, mode_list) +# except Exception, e: +# self.clean_error_msg('onekey') +# else: +# self.clean_complete_msg('onekey') + +# return t + + def onekey_clean_cancel_function(self, t): + daemononekey.cancel_onekey_clean(t, SystemExit) + +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender') +# def history_clean_records_function(self, flag, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.clean_complete_msg('') +# return +# daemonhistory = cleaner.CleanTheHistory() +# try: +# running = daemonhistory.clean_all_history_crufts(flag) +# except Exception, e: +# self.clean_error_msg(flag) +# else: +# self.clean_complete_msg(flag) + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='', sender_keyword='sender') +# def clean_system_history(self, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.clean_complete_msg('') +# return +# daemonsystem = cleaner.CleanSystemHistory() +# try: +# daemonsystem.clean_the_cruftlist() +# except Exception, e: +# self.clean_error_msg('system') +# else: +# self.clean_complete_msg('system') + + #@dbus.service.method(INTERFACE, in_signature='', out_signature='', sender_keyword='sender') + #def clean_dash_history(self, sender=None): + # status = self._check_permission(sender, UK_ACTION_YOUKER) + # if not status: + # self.clean_complete_msg('') + # return + # daemondash = cleaner.CleanDashHistory() + # try: + # daemondash.clean_the_cruftlist() + # except Exception, e: + # self.clean_error_msg('dash') + # else: + # self.clean_complete_msg('dash') + +# @dbus.service.method(INTERFACE, in_signature = 'as', out_signature = '', sender_keyword = 'sender') +# def cookies_clean_record_function(self, flag, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.clean_single_complete_msg('') +# return +# daemoncookies = cleaner.CleanTheCookies(None) +# try: +# daemoncookies.clean_one_cookies_cruft(flag[0], flag[1]) +# except Exception, e: +# self.clean_single_error_msg('cookies') +# else: +# self.clean_single_complete_msg('cookies') + +# @dbus.service.method(INTERFACE, in_signature = 's', out_signature = '', sender_keyword = 'sender') +# def cookies_clean_records_function(self, flag, sender = None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.quit_clean_work(flag) +# return +# daemoncookies = cleaner.CleanTheCookies(None) +# try: +# daemoncookies.clean_all_cookies_crufts(flag) +# except Exception, e: +# self.clean_error_msg(flag) +# else: +# self.clean_complete_msg(flag) + + # the function of clean files + ### input-['filepath', 'file...] output-'' +# @dbus.service.method(INTERFACE, in_signature='ass', out_signature='', sender_keyword='sender') +# def clean_file_cruft(self, cruft_list, flagstr, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.clean_complete_msg('') +# return +# try: +# for cruft in cruft_list: +# self.daemonclean.clean_the_file(cruft) +# except Exception, e: +# self.clean_error_msg(flagstr) +# else: +# self.clean_complete_msg(flagstr) + + #def dbusstring_to_string(self, string): + # tmp_string = str(string) + # patt = "u'[\S]+'" + # tmp_list = re.findall(patt, tmp_string) + # return [ok.split("'")[1] for ok in tmp_list] + + def clean_complete_msg(self, para): + self.clean_complete(para) + +# def quit_clean_work(self, para): +# self.quit_clean(para) +# def quit_clean_work(self, status): +# self.quit_clean(status) + + def clean_single_complete_msg(self, para): + self.clean_single_complete(para) + + def clean_error_msg(self, para): + self.clean_error(para) + + def clean_single_error_msg(self, para): + self.clean_single_error(para) + + def revoke_clean_onekey(self, para): + self.clean_complete_onekey(para) + + # a dbus method which means clean complete +# @dbus.service.signal(INTERFACE, signature='s') +# def finish_clean(self, msg): +# pass + + @dbus.service.signal(INTERFACE, signature='ss') + def status_remove_packages(self, type, msg): + pass + + # a dbus method which means an error occurred +# @dbus.service.signal(INTERFACE, signature='s') +# def sudo_clean_error(self, msg): +# pass + + # the function of clean packages + ### input-['packagename', 'pack...] output-'' +# @dbus.service.method(INTERFACE, in_signature='ass', out_signature='', sender_keyword='sender') +# def clean_package_cruft(self, cruftlist, flag, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.finish_clean_msg('') +# return +# try: +# self.daemonclean.clean_the_package(cruftlist, self) +# except Exception, e: +# self.sudo_clean_error_msg(flag) +# else: +# self.finish_clean_msg(flag) + +# def finish_clean_msg(self, para): +# self.finish_clean(para) + +# def sudo_clean_error_msg(self, para): +# self.sudo_clean_error(para) + +#-----START-----------NEW-YOUKER--------------------------- +# + +# @dbus.service.method(INTERFACE, in_signature='a{sv}', out_signature='', sender_keyword='sender') +# def remove_select_items(self, mode_dic, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.quit_clean(False) +## self.quit_clean_work() +# return +# else: +# self.quit_clean(True) + def start_clean_all(self, mode_dic): + filecache = mode_dic.get('file', []) + if filecache: + for tmpName in filecache: + cleaner.interface_remove_file_system(self, tmpName) + + packagecache = mode_dic.get('package', []) + if packagecache: + for pkgName in packagecache: + cleaner.interface_remove_package_system(self, pkgName) + + bashhistory = mode_dic.get('bash-history', []) + if bashhistory: + for tmpName in bashhistory: + cleaner.interface_remove_file_system(self, tmpName) + + x11history = mode_dic.get('x11-history', []) + if x11history: + for tmpName in x11history: + cleaner.interface_remove_file_system(self, tmpName) + + firefoxhistory = mode_dic.get('firefox-history', []) + if firefoxhistory: + cleaner.interface_remove_firefox_history_system(self) + + chromiumhistory = mode_dic.get('chromium-history', []) + if chromiumhistory: + cleaner.interface_remove_chromium_history_system(self) + + systemhistory = mode_dic.get('system-history', []) + if systemhistory: + cleaner.interface_remove_system_history_system(self) + + firefoxcookies = mode_dic.get('firefox-cookie', []) + if firefoxcookies: + for domain in firefoxcookies: + cleaner.interface_remove_firefox_cookies_system(self, domain) + + chromiumcookies = mode_dic.get('chromium-cookie', []) + if chromiumcookies: + for domain in chromiumcookies: + cleaner.interface_remove_chromium_cookies_system(self, domain) + + self.subpage_status_signal('Complete:All', "finish") + + @dbus.service.method(INTERFACE, in_signature='a{sv}', out_signature='', sender_keyword='sender') + def remove_select_items(self, mode_dic, sender=None): + status = self._check_permission(sender, UK_ACTION_YOUKER) + if not status: + self.quit_clean(False) + return + else: + self.quit_clean(True) + thread.start_new_thread(self.start_clean_all, (mode_dic,)) +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender') +# def remove_file(self, fp): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.revoke_clean_onekey('yes') +# return +# else: +# self.revoke_clean_onekey('no') +# cleaner.interface_remove_file_system(self, fp) + +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender') +# def remove_package(self, pkgname, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.revoke_clean_onekey('yes') +# return +# else: +# self.revoke_clean_onekey('no') +# cleaner.interface_remove_package_system(self, pkgname) + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='', sender_keyword='sender') +# def remove_firefox_history(self, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.revoke_clean_onekey('yes') +# return +# else: +# self.revoke_clean_onekey('no') +# cleaner.interface_remove_firefox_history_system(self) + +# @dbus.service.method(INTERFACE, in_signature='', out_signature='', sender_keyword='sender') +# def remove_chromium_history(self, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.revoke_clean_onekey('yes') +# return +# else: +# self.revoke_clean_onekey('no') +# cleaner.interface_remove_chromium_history_system(self) + +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender') +# def remove_firefox_cookies(self, domain, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.revoke_clean_onekey('yes') +# return +# else: +# self.revoke_clean_onekey('no') +# cleaner.interface_remove_firefox_cookies_system(self, domain) + +# @dbus.service.method(INTERFACE, in_signature='s', out_signature='', sender_keyword='sender') +# def remove_chromium_cookies(self, domain, sender=None): +# status = self._check_permission(sender, UK_ACTION_YOUKER) +# if not status: +# self.revoke_clean_onekey('yes') +# return +# else: +# self.revoke_clean_onekey('no') +# cleaner.interface_remove_chromium_cookies_system(self, domain) + + @dbus.service.signal(INTERFACE, signature='as') + def subpage_data_signal(self, msg): + pass + + @dbus.service.signal(INTERFACE, signature='ss') + def subpage_status_signal(self, msg, domain): + pass + + @dbus.service.signal(INTERFACE, signature='s') + def subpage_error_signal(self, msg): + pass +#-----END------------NEW-YOUKER--------------------------- + +if __name__ == '__main__': + os.environ["TERM"] = "xterm" + os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin" + os.environ["DEBIAN_FRONTEND"] = "noninteractive" + if os.path.exists("/var/lib/apt/lists/lock"): + os.remove("/var/lib/apt/lists/lock") + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + #gobject.threads_init() + #mainloop = gobject.MainLoop() + GObject.threads_init() + mainloop = GObject.MainLoop() + signal.signal(signal.SIGINT, lambda : mainloop.quit()) + Daemon(dbus.SystemBus(), mainloop) + mainloop.run() diff --git a/backends/youker-assistant-daemon/src/systemdbus/server.py b/backends/youker-assistant-daemon/src/systemdbus/server.py new file mode 100644 index 0000000..07f0b1d --- /dev/null +++ b/backends/youker-assistant-daemon/src/systemdbus/server.py @@ -0,0 +1,26 @@ +# This class is modified from gnome-lirc-properties project +# the original file is gnome_lirc_properties/backend.py +# GPL v2+ +# Copyright (C) 2008 Fluendo Embedded S.L. +# Copyright (C) 2010 TualatriX +# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd + +import dbus.service + +class AccessDeniedException(dbus.DBusException): + '''This exception is raised when some operation is not permitted.''' + + _dbus_error_name = 'com.ubuntukylin.youker.AccessDeniedException' + + +class PolicyKitService(dbus.service.Object): + '''A D-BUS service that uses PolicyKit for authorization.''' + + def _check_permission(self, sender, action): + if not sender: raise ValueError('sender == None') + kit = dbus.SystemBus().get_object('org.freedesktop.PolicyKit1', '/org/freedesktop/PolicyKit1/Authority') + kit = dbus.Interface(kit, 'org.freedesktop.PolicyKit1.Authority') + (granted, _, details) = kit.CheckAuthorization( + ('system-bus-name', {'name': sender}), + action, {}, dbus.UInt32(1), '', timeout=600) + return granted diff --git a/cleaner/cacheactionwidget.cpp b/cleaner/cacheactionwidget.cpp new file mode 100644 index 0000000..d5352ea --- /dev/null +++ b/cleaner/cacheactionwidget.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cacheactionwidget.h" +#include "mainwindow.h" +#include + +CacheActionWidget::CacheActionWidget(QWidget *parent) + : QWidget(parent) +{ + this->setFixedSize(900, 150); + this->setAutoFillBackground(true); + this->setObjectName("transparentWidget"); + + img_label = new QLabel(); + title_label = new QLabel(); + description_label = new QLabel(); + + img_label->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小 + QPixmap label_pixmap("://res/cache.png"); + img_label->setPixmap(label_pixmap); + img_label->setFixedSize(label_pixmap.size()); + + title_label->setObjectName("whiteLabel"); + description_label->setWordWrap(true);//QLabel自动换行 + description_label->setObjectName("tipLabel"); + + QVBoxLayout *layout1 = new QVBoxLayout(); + layout1->addStretch(); + layout1->addWidget(title_label); + layout1->addWidget(description_label); + layout1->addStretch(); + layout1->setSpacing(15); + layout1->setMargin(0); + layout1->setContentsMargins(0, 0, 0, 0); + + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->addWidget(img_label, 0, Qt::AlignVCenter); + layout2->addLayout(layout1); + layout2->setSpacing(20); + layout2->setMargin(0); + layout2->setContentsMargins(20, 20, 0, 0); + + setLayout(layout2); + + this->setLanguage(); +} + +CacheActionWidget::~CacheActionWidget() +{ + if(img_label != NULL) { + delete img_label; + img_label = NULL; + } + if(title_label != NULL) { + delete title_label; + title_label = NULL; + } + if(description_label != NULL) { + delete description_label; + description_label = NULL; + } +} + +void CacheActionWidget::setLanguage() +{ + title_label->setText(tr("Cleaning up the system cache")); + description_label->setText(tr("Deep cleaning up the system cache, to save disk space")); +} diff --git a/cleaner/cacheactionwidget.h b/cleaner/cacheactionwidget.h new file mode 100644 index 0000000..002494a --- /dev/null +++ b/cleaner/cacheactionwidget.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CACHEACTIONWIDGET_H +#define CACHEACTIONWIDGET_H + +#include +class MainWindow; +class QLabel; + +class CacheActionWidget : public QWidget +{ + Q_OBJECT +public: + explicit CacheActionWidget(QWidget *parent = 0); + ~CacheActionWidget(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void setLanguage(); + +private: + QLabel *img_label; + QLabel *title_label; + QLabel *description_label; + MainWindow *p_mainwindow; +}; + +#endif // CACHEACTIONWIDGET_H + + + + diff --git a/cleaner/cleanerdetailwidget-org.cpp b/cleaner/cleanerdetailwidget-org.cpp new file mode 100644 index 0000000..08547ca --- /dev/null +++ b/cleaner/cleanerdetailwidget-org.cpp @@ -0,0 +1,1117 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleanerdetailwidget.h" +#include "ui_cleanerdetailwidget.h" +#include "../mainui/mainwindow.h" +#include "../component/cleansubgroup.h" +#include +#include + +CleanerDetailWidget::CleanerDetailWidget(QWidget *parent, SessionDispatcher *seroxy, SystemDispatcher *syproxy, MainWindow *window, Toolkits *kits, QString skin) + : QWidget(parent), sessionproxy(seroxy), systemproxy(syproxy), parentWindow(window), toolKits(kits),cur_skin(skin), + ui(new Ui::CleanerDetailWidget) +{ + ui->setupUi(this); +// this->setStyleSheet("QWidget{border: none}"); + this->setObjectName("transparentWidget"); + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + this->setFixedSize(900, 403); + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); +// this->setObjectName("transparentWidget"); +// this->setAutoFillBackground(true); +// QPalette palette; +// palette.setBrush(QPalette::Window, QBrush(Qt::white)); +// this->setPalette(palette); + + ui->scrollArea->setFixedSize(900, 403); + ui->scrollArea->setAutoFillBackground(true); + ui->scrollArea->setBackgroundRole(QPalette::Light); + + subCount = 0; + scanResult = false; + ui->label->hide(); + + grid_layout = new QGridLayout(); +// rowIndex = columnIndex = 0; + + cache_apt_items = NULL; + cache_apt_btn = NULL; + cache_software_items = NULL; + cache_software_btn = NULL; + cache_thumbnails_items = NULL; + cache_thumbnails_btn = NULL; + cache_firefox_items = NULL; + cache_firefox_btn = NULL; + cache_chromium_items = NULL; + cache_chromium_btn = NULL; + + package_unneed_items = NULL; + package_unneed_btn = NULL; + package_oldkernel_items = NULL; + package_oldkernel_btn = NULL; + package_configfile_items = NULL; + package_configfile_btn = NULL; + + cookies_firefox_items = NULL; + cookies_firefox_btn = NULL; + cookies_chromium_items = NULL; + cookies_chromium_btn = NULL; + + trace_firefox_btn = NULL; + trace_chromium_btn = NULL; + trace_system_btn = NULL; + trace_bash_btn = NULL; + trace_x11_btn = NULL; + trace_x11_items = NULL; + + ui->scrollAreaWidgetContents->setLayout(grid_layout); + this->setLanguage(); +} + +CleanerDetailWidget::~CleanerDetailWidget() +{ + if(cache_apt_items != NULL) + { + delete cache_apt_items; + cache_apt_items = NULL; + } + if(cache_software_items != NULL) + { + delete cache_software_items; + cache_software_items = NULL; + } + if(cache_thumbnails_items != NULL) + { + delete cache_thumbnails_items; + cache_thumbnails_items = NULL; + } + if(cache_firefox_items != NULL) + { + delete cache_firefox_items; + cache_firefox_items = NULL; + } + if(cache_chromium_items != NULL) + { + delete cache_chromium_items; + cache_chromium_items = NULL; + } + if(package_unneed_items != NULL) + { + delete package_unneed_items; + package_unneed_items = NULL; + } + if(package_oldkernel_items != NULL) + { + delete package_oldkernel_items; + package_oldkernel_items = NULL; + } + if(package_configfile_items != NULL) + { + delete package_configfile_items; + package_configfile_items = NULL; + } + if(cookies_firefox_items != NULL) + { + delete cookies_firefox_items; + cookies_firefox_items = NULL; + } + if(cookies_chromium_items != NULL) + { + delete cookies_chromium_items; + cookies_chromium_items = NULL; + } + if(trace_x11_items != NULL) + { + delete trace_x11_items; + trace_x11_items = NULL; + } + if(grid_layout != NULL) + { + delete grid_layout; + grid_layout = NULL; + } + delete ui; +} + +void CleanerDetailWidget::CleanUIAndData() +{ + if(!ui->label->isHidden()) + ui->label->hide(); + scanResult = false; + subCount = 0; +// rowIndex = columnIndex = 0; + cache_apt_list.clear(); + cache_software_list.clear(); + cache_thumbnails_list.clear(); + cache_firefox_list.clear(); + cache_chromium_list.clear(); + package_unneed_list.clear(); + package_oldkernel_list.clear(); + package_configfile_list.clear(); + cookies_firefox_list.clear(); + cookies_chromium_list.clear(); + trace_firefox_count.clear(); + trace_chromium_count.clear(); + trace_system_count.clear(); + trace_bash_size.clear(); + trace_bash_path.clear(); + trace_x11_list.clear(); + + //clear ui + while(grid_layout != NULL && grid_layout->count() > 0) + { + QWidget* widget = grid_layout->itemAt(0)->widget(); + grid_layout->removeWidget(widget); + delete widget; + } +} + +void CleanerDetailWidget::showReciveData(const QStringList &data) +{ + //----------------------------------------------------------------Cache--------------------------- + if(data.at(0) == "Belong:Cache.apt" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_apt_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.software-center" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_software_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.thumbnails" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_thumbnails_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.firefox" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_firefox_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.chromium" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_chromium_list.append(data.at(1).split(":").at(1)); + } + } + //----------------------------------------------------------------Package--------------------------- + else if(data.at(0) == "Belong:Packages.unneed" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + package_unneed_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Packages.oldkernel" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + package_oldkernel_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Packages.configfile" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + package_configfile_list.append(data.at(1).split(":").at(1)); + } + } + + //----------------------------------------------------------------Cookies--------------------------- + else if(data.at(0) == "Belong:Cookies.firefox" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":") && !data.at(1).split(":").at(1).isEmpty()) + { + if (scanResult == false) + scanResult = true; + cookies_firefox_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cookies.chromium" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":") && !data.at(1).split(":").at(1).isEmpty()) + { + if (scanResult == false) + scanResult = true; + cookies_chromium_list.append(data.at(1).split(":").at(1)); + } + } + + //----------------------------------------------------------------History Trace--------------------------- + else if(data.at(0) == "Belong:History.firefox" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if(data.at(1).split(":").at(1).toInt() != 0) { + if (scanResult == false) + scanResult = true; + trace_firefox_count = data.at(1).split(":").at(1); + } + } + } + else if(data.at(0) == "Belong:History.chromium" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if(data.at(1).split(":").at(1).toInt() != 0) { + if (scanResult == false) + scanResult = true; + trace_chromium_count = data.at(1).split(":").at(1); + } + } + } + else if(data.at(0) == "Belong:History.system" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if(data.at(1).split(":").at(1).toInt() != 0) { + if (scanResult == false) + scanResult = true; + trace_system_count = data.at(1).split(":").at(1); + } + } + } + else if(data.at(0) == "Belong:History.bash" && !data.at(1).isEmpty() && !data.at(2).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + trace_bash_size= data.at(1).split(":").at(1); + trace_bash_path= data.at(2).split(":").at(1); + } +// qDebug() << "bash------------"; +// qDebug() << data.at(1);//"Size:55.67 KB" +// qDebug() << data.at(2);/"Path:/home/kobe/.bash_history" + } + else if(data.at(0) == "Belong:History.X11")// && !data.at(1).isEmpty() && !data.at(2).isEmpty() + { +// qDebug() << "x11------------"; +// qDebug() << data.at(1);//Path:/home/kobe/.xsession-errors +// qDebug() << data.at(2);//Type:file +// qDebug() << data.at(3);//Size:0.98 KB + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + trace_x11_list.append(data.at(1).split(":").at(1)); + } + } +} + +void CleanerDetailWidget::showReciveStatus(const QString &status) +{ + if(status == "Complete:Cache") + { + if(cache_apt_list.length() > 0) + { + cache_apt_items = new CleanListWidget(cache_apt_list, this->cur_skin, tr("Apt Cache Clean Items")); +// cache_apt_btn = new CommonCheckBox(0, "://res/cache"); + cache_apt_btn = new CleanSubGroup(0, "://res/janitor/apt"); + cache_apt_btn->setFocusPolicy(Qt::NoFocus); +// cache_apt_btn->setFixedSize(160, 130); +// cache_apt_btn->setFixedSize(160, 200); + cache_apt_btn->setStatusTip("cache-apt"); + cache_apt_btn->setLabelText(tr("Apt Cache count:"), cache_apt_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_apt_items, SIGNAL(notifyMainCheckBox(int)), cache_apt_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,显示自定义页面 + connect(cache_apt_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_apt_btn, SIGNAL(spreadStatus(int)), cache_apt_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(cache_apt_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_apt_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_apt_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cache_software_list.length() > 0) + { + cache_software_items = new CleanListWidget(cache_software_list, this->cur_skin, tr("Software Cache Clean Items")); +// cache_software_btn = new CommonCheckBox(0, "://res/cache"); + cache_software_btn = new CleanSubGroup(0, "://res/janitor/software"); + cache_software_btn->setFocusPolicy(Qt::NoFocus); +// cache_software_btn->setFixedSize(160, 130); +// cache_software_btn->setFixedSize(160, 200); + cache_software_btn->setStatusTip("cache-software"); + cache_software_btn->setLabelText(tr("Software Cache count:"), cache_software_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_software_items, SIGNAL(notifyMainCheckBox(int)), cache_software_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_software_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_software_btn, SIGNAL(spreadStatus(int)), cache_software_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(cache_software_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_software_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_software_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cache_thumbnails_list.length() > 0) + { + cache_thumbnails_items = new CleanListWidget(cache_thumbnails_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// cache_thumbnails_btn = new CommonCheckBox(0, "://res/cache"); + cache_thumbnails_btn = new CleanSubGroup(0, "://res/janitor/thumbnails"); + cache_thumbnails_btn->setFocusPolicy(Qt::NoFocus); +// cache_thumbnails_btn->setFixedSize(160, 130); +// cache_thumbnails_btn->setFixedSize(160, 200); + cache_thumbnails_btn->setStatusTip("cache-thumbnails"); + cache_thumbnails_btn->setLabelText(tr("Thumbnails Cache Count:"), cache_thumbnails_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_thumbnails_items, SIGNAL(notifyMainCheckBox(int)), cache_thumbnails_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_thumbnails_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_thumbnails_btn, SIGNAL(spreadStatus(int)), cache_thumbnails_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(cache_thumbnails_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_thumbnails_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_thumbnails_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + + + if(cache_firefox_list.length() > 0) + { + cache_firefox_items = new CleanListWidget(cache_firefox_list, this->cur_skin, tr("Software Cache Clean Items")); +// cache_firefox_btn = new CommonCheckBox(0, "://res/cache"); + cache_firefox_btn = new CleanSubGroup(0, "://res/janitor/firefox"); + cache_firefox_btn->setFocusPolicy(Qt::NoFocus); +// cache_firefox_btn->setFixedSize(160, 130); + cache_firefox_btn->setStatusTip("cache-firefox"); + cache_firefox_btn->setLabelText(tr("Firefox Cache Count:"), cache_firefox_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_firefox_items, SIGNAL(notifyMainCheckBox(int)), cache_firefox_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_firefox_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_firefox_btn, SIGNAL(spreadStatus(int)), cache_firefox_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(cache_firefox_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cache_chromium_list.length() > 0) + { + cache_chromium_items = new CleanListWidget(cache_chromium_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// cache_chromium_btn = new CommonCheckBox(0, "://res/cache"); + cache_chromium_btn = new CleanSubGroup(0, "://res/janitor/chromium"); + cache_chromium_btn->setFocusPolicy(Qt::NoFocus); +// cache_chromium_btn->setFixedSize(160, 130); + cache_chromium_btn->setStatusTip("cache-chromium"); + cache_chromium_btn->setLabelText(tr("Chromium Cache Count:"), cache_chromium_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_chromium_items, SIGNAL(notifyMainCheckBox(int)), cache_chromium_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_chromium_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_chromium_btn, SIGNAL(spreadStatus(int)), cache_chromium_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(cache_chromium_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + else if(status == "Complete:Cookies") + { +// doing_label->setText(tr("Cookies Scan OK......")); + if(cookies_firefox_list.length() > 0) + { + cookies_firefox_items = new CleanListWidget(cookies_firefox_list, this->cur_skin, tr("Firefox Cookies Clean Items")); +// cookies_firefox_btn = new CommonCheckBox(0, "://res/cookie"); + cookies_firefox_btn = new CleanSubGroup(0, "://res/janitor/firefox"); + cookies_firefox_btn->setFocusPolicy(Qt::NoFocus); +// cookies_firefox_btn->setFixedSize(160, 130); + cookies_firefox_btn->setStatusTip("cookes-firefox"); + cookies_firefox_btn->setLabelText(tr("Firefox Cookies Count:"), cookies_firefox_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cookies_firefox_items, SIGNAL(notifyMainCheckBox(int)), cookies_firefox_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_firefox_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_firefox_btn, SIGNAL(spreadStatus(int)), cookies_firefox_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(cookies_firefox_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cookies_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cookies_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cookies_chromium_list.length() > 0) + { + cookies_chromium_items = new CleanListWidget(cookies_chromium_list, this->cur_skin, tr("Chromium Cookies Clean Items")); +// cookies_chromium_btn = new CommonCheckBox(0, "://res/cache"); + cookies_chromium_btn = new CleanSubGroup(0, "://res/janitor/chromium"); + cookies_chromium_btn->setFocusPolicy(Qt::NoFocus); +// cookies_chromium_btn->setFixedSize(160, 130); + cookies_chromium_btn->setStatusTip("cookes-chromium"); + cookies_chromium_btn->setLabelText(tr("Chromium Cookies Count:"), cookies_chromium_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cookies_chromium_items, SIGNAL(notifyMainCheckBox(int)), cookies_chromium_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_chromium_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_chromium_btn, SIGNAL(spreadStatus(int)), cookies_chromium_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(cookies_chromium_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cookies_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cookies_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + else if(status == "Complete:History") + { +// doing_label->setText(tr("History Scan OK")); + if(trace_firefox_count.length() > 0) + { +// trace_firefox_btn = new CommonCheckBox(0, "://res/cache"); + trace_firefox_btn = new CleanSubGroup(0, "://res/janitor/firefox"); + trace_firefox_btn->setFocusPolicy(Qt::NoFocus); +// trace_firefox_btn->setFixedSize(160, 130); + trace_firefox_btn->hideCustomButton(); + trace_firefox_btn->setStatusTip("history-firefox"); + trace_firefox_btn->setLabelText(tr("Firefox History Count:"), trace_firefox_count.toInt()); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(trace_firefox_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(trace_chromium_count.length() > 0) + { + trace_chromium_btn = new CleanSubGroup(0, "://res/janitor/chromium"); + trace_chromium_btn->setFocusPolicy(Qt::NoFocus); + trace_chromium_btn->hideCustomButton(); + trace_chromium_btn->setStatusTip("history-chromium"); + trace_chromium_btn->setLabelText(tr("Chromium History Count:"), trace_chromium_count.toInt()); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(trace_chromium_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + + if(trace_system_count.length() > 0) + { + trace_system_btn = new CleanSubGroup(0, "://res/janitor/trace"); + trace_system_btn->setFocusPolicy(Qt::NoFocus); + trace_system_btn->hideCustomButton(); + trace_system_btn->setStatusTip("history-system"); + trace_system_btn->setLabelText(tr("System History Count:"), trace_system_count.toInt()); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(trace_system_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_system_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_system_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + //kobe + if(!trace_bash_path.isEmpty()) + { + trace_bash_btn = new CleanSubGroup(0, "://res/janitor/trace"); + trace_bash_btn->setFocusPolicy(Qt::NoFocus); + trace_bash_btn->hideCustomButton(); + trace_bash_btn->setStatusTip("history-bash"); + trace_bash_btn->setLabelStringText(tr("Command history size:"), trace_bash_size); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(trace_bash_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_bash_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_bash_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + + if(trace_x11_list.length() > 0) + { + trace_x11_items = new CleanListWidget(trace_x11_list, this->cur_skin, tr("Debug log Items")); + trace_x11_btn = new CleanSubGroup(0, "://res/janitor/debug"); + trace_x11_btn->setFocusPolicy(Qt::NoFocus); + trace_x11_btn->setStatusTip("x11-history"); + trace_x11_btn->setLabelText(tr("Debug log:"), trace_x11_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(trace_x11_items, SIGNAL(notifyMainCheckBox(int)), trace_x11_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(trace_x11_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(trace_x11_btn, SIGNAL(spreadStatus(int)), trace_x11_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(trace_x11_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_x11_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_x11_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + else if(status == "Complete:Packages") + { +// doing_label->setText(tr("Packages Scan OK")); + if(package_unneed_list.length() > 0) + { + package_unneed_items = new CleanListWidget(package_unneed_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// package_unneed_btn = new CommonCheckBox(0, "://res/cache"); + package_unneed_btn = new CleanSubGroup(0, "://res/janitor/package"); + package_unneed_btn->setFocusPolicy(Qt::NoFocus); +// package_unneed_btn->setFixedSize(160, 130); + package_unneed_btn->setStatusTip("package-unneed"); + package_unneed_btn->setLabelText(tr("Package Unneed Count:"),package_unneed_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_unneed_items, SIGNAL(notifyMainCheckBox(int)), package_unneed_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_unneed_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_unneed_btn, SIGNAL(spreadStatus(int)), package_unneed_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(package_unneed_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(package_unneed_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(package_unneed_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(package_oldkernel_list.length() > 0) + { + package_oldkernel_items = new CleanListWidget(package_oldkernel_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// package_oldkernel_btn = new CommonCheckBox(0, "://res/cache"); + package_oldkernel_btn = new CleanSubGroup(0, "://res/janitor/package"); + package_oldkernel_btn->setFocusPolicy(Qt::NoFocus); +// package_oldkernel_btn->setFixedSize(160, 130); + package_oldkernel_btn->setStatusTip("package-oldkernel"); + package_oldkernel_btn->setLabelText(tr("Package oldkernel Count:"), package_oldkernel_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_oldkernel_items, SIGNAL(notifyMainCheckBox(int)), package_oldkernel_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_oldkernel_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_oldkernel_btn, SIGNAL(spreadStatus(int)), package_oldkernel_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(package_oldkernel_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(package_oldkernel_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(package_oldkernel_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(package_configfile_list.length() > 0) + { + package_configfile_items = new CleanListWidget(package_configfile_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// package_configfile_btn = new CommonCheckBox(0, "://res/cache"); + package_configfile_btn = new CleanSubGroup(0, "://res/janitor/package"); + package_configfile_btn->setFocusPolicy(Qt::NoFocus); +// package_configfile_btn->setFixedSize(160, 130); + package_configfile_btn->setStatusTip("package-configfile"); + package_configfile_btn->setLabelText(tr("Package configfile Count:"),package_configfile_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_configfile_items, SIGNAL(notifyMainCheckBox(int)), package_configfile_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_configfile_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_configfile_btn, SIGNAL(spreadStatus(int)), package_configfile_items, SLOT(resetSubCheckbox(int))); + if(grid_layout == NULL) + { + grid_layout = new QGridLayout(); + } + grid_layout->addWidget(package_configfile_btn, subCount/5, subCount%5); + subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(package_configfile_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(package_configfile_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + else if(status == "Complete:All") + { + if(!scanResult) + ui->label->show(); + emit this->sendScanOverStatus(scanResult); + } +} + +void CleanerDetailWidget::showCustomPage() +{ + QObject *object = QObject::sender(); +// CommonCheckBox *checkbox = qobject_cast(object); + CleanSubGroup *checkbox = qobject_cast(object); + QString object_name = checkbox->statusTip(); + if(object_name == "cache-apt") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_apt_items->move(w_x, w_y); + cache_apt_items->exec(); + } + else if(object_name == "cache-software") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_software_items->move(w_x, w_y); + cache_software_items->exec(); + } + else if(object_name == "cache-thumbnails") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_thumbnails_items->move(w_x, w_y); + cache_thumbnails_items->exec(); + } + else if(object_name == "cache-firefox") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_firefox_items->move(w_x, w_y); + cache_firefox_items->exec(); + } + else if(object_name == "cache-chromium") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_chromium_items->move(w_x, w_y); + cache_chromium_items->exec(); + } + else if(object_name == "cookes-firefox") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cookies_firefox_items->move(w_x, w_y); + cookies_firefox_items->exec(); + } + else if(object_name == "cookes-chromium") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cookies_chromium_items->move(w_x, w_y); + cookies_chromium_items->exec(); + } + else if(object_name == "package-unneed") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + package_unneed_items->move(w_x, w_y); + package_unneed_items->exec(); + } + else if(object_name == "package-oldkernel") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + package_oldkernel_items->move(w_x, w_y); + package_oldkernel_items->exec(); + } + else if(object_name == "package-configfile") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + package_configfile_items->move(w_x, w_y); + package_configfile_items->exec(); + } + else if(object_name == "x11-history") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + trace_x11_items->move(w_x, w_y); + trace_x11_items->exec(); + } +// else if(object_name == "history-firefox" || object_name == "history-chromium" || object_name == "history-system"|| object_name == "history-bash" ) { +// } +} + +void CleanerDetailWidget::setLanguage() +{ + ui->label->setText(tr("No garbage ")); +// title_label->setText(tr("Cleaning up the system cache")); +// description_label->setText(tr("Deep cleaning up the system cache, to save disk space")); +} + +void CleanerDetailWidget::resetCurrentSkin(QString skin) +{ + this->cur_skin = skin; + + //can remove this code + if(cache_apt_items != NULL) + cache_apt_items->resetTitleSkin(skin); + if(cache_software_items != NULL) + cache_software_items->resetTitleSkin(skin); + if(cache_thumbnails_items != NULL) + cache_thumbnails_items->resetTitleSkin(skin); + if(cache_firefox_items != NULL) + cache_firefox_items->resetTitleSkin(skin); + if(cache_chromium_items != NULL) + cache_chromium_items->resetTitleSkin(skin); + if(cookies_firefox_items != NULL) + cookies_firefox_items->resetTitleSkin(skin); + if(cookies_chromium_items != NULL) + cookies_chromium_items->resetTitleSkin(skin); + if(package_unneed_items != NULL) + package_unneed_items->resetTitleSkin(skin); + if(package_oldkernel_items != NULL) + package_oldkernel_items->resetTitleSkin(skin); + if(package_configfile_items != NULL) + package_configfile_items->resetTitleSkin(skin); + if(trace_x11_items != NULL) + trace_x11_items->resetTitleSkin(skin); +} + +void CleanerDetailWidget::receiveCleanSignal() +{ + this->getAllSelectedItems(); + if(argsData.empty()) + { + toolKits->alertMSG(parentWindow->geometry().topLeft().x(), parentWindow->geometry().topLeft().y(), tr("Clean args is empty!")); + } + else + { +// qDebug() << "args is.........." << argsData; + systemproxy->set_user_homedir_qt(); + systemproxy->cleanAllSelectItems(argsData); + } +} + +//void CleanerDetailWidget::receivePolicyKitSignal(bool status) +//{ +// //status = true:ok +// //status = false:cacel +// if(status)//ok +// { +// emit this->showActionAnimaiton(); +// } +//} + +void CleanerDetailWidget::getAllSelectedItems() +{ + argsData.clear(); + QStringList fileTmp; + QStringList packageTmp; + QStringList firefoxcookieTmp; + QStringList chromiumcookieTmp; + QStringList traceTmp; + + if(cache_apt_btn != NULL && cache_apt_btn->getCheckBoxStatus() != 0) + { + QStringList tmp = cache_apt_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_software_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_thumbnails_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_firefox_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_chromium_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_unneed_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_oldkernel_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_configfile_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cookies_firefox_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cookies_chromium_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + argsData.insert("firefox-history", QStringList() << trace_firefox_count); + } + if(trace_chromium_btn != NULL && trace_chromium_btn->getCheckBoxStatus() != 0) + { + argsData.insert("chromium-history", QStringList() << trace_chromium_count); + } + if(trace_system_btn != NULL && trace_system_btn->getCheckBoxStatus() != 0) + { + argsData.insert("system-history", QStringList() << trace_system_count); + } + //kobe + if(trace_bash_btn != NULL && trace_bash_btn->getCheckBoxStatus() != 0) + { + argsData.insert("bash-history", QStringList() << trace_bash_path); + } + if(trace_x11_btn != NULL && trace_x11_btn->getCheckBoxStatus() != 0) + { + QStringList tmp = trace_x11_items->getSelectedItems(); + for(int i = 0; i 0) + argsData.insert("file", fileTmp); + if(packageTmp.length() > 0) + argsData.insert("package", packageTmp); + if(firefoxcookieTmp.length() > 0) + argsData.insert("firefox-cookie", firefoxcookieTmp); + if(chromiumcookieTmp.length() > 0) + argsData.insert("chromium-cookie", chromiumcookieTmp); + if(traceTmp.length() > 0) + argsData.insert("x11-history", traceTmp); +} diff --git a/cleaner/cleanerdetailwidget-org.h b/cleaner/cleanerdetailwidget-org.h new file mode 100644 index 0000000..e0474f8 --- /dev/null +++ b/cleaner/cleanerdetailwidget-org.h @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERDETAILWIDGET_H +#define CLEANERDETAILWIDGET_H + +#include +#include "cleaneritems.h" +#include "cleanlistwidget.h" + +class QLabel; +class QBoxLayout; +class QHBoxLayout; +class QGridLayout; +class SessionDispatcher; +class SystemDispatcher; +class Toolkits; +class MainWindow; +class CleanSubGroup; + + +namespace Ui { +class CleanerDetailWidget; +} + +class CleanerDetailWidget : public QWidget +{ + Q_OBJECT + +public: + explicit CleanerDetailWidget(QWidget *parent = 0, SessionDispatcher *seroxy = 0, SystemDispatcher *syproxy = 0, MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png"); + ~CleanerDetailWidget(); + void setUIData(); + void setLanguage(); + void initConnect(); + void getAllSelectedItems(); + void resetCurrentSkin(QString skin); + +public slots: + void showCustomPage(); + void showReciveData(const QStringList &data); + void receiveCleanSignal(); + void showReciveStatus(const QString &status); + void CleanUIAndData(); +// void receivePolicyKitSignal(bool status); + +signals: + void notifyMainCheckBox(int status); +// void showActionAnimaiton(); + void sendScanOverStatus(bool status); + +private: + void initTitleBar(); + +private: + Ui::CleanerDetailWidget *ui; + MainWindow *parentWindow; + SessionDispatcher *sessionproxy; + SystemDispatcher *systemproxy; + Toolkits *toolKits; + QMap argsData; + CleanListWidget *cache_apt_items ; + CleanSubGroup *cache_apt_btn; + CleanListWidget *cache_software_items ; + CleanSubGroup *cache_software_btn; + CleanListWidget *cache_thumbnails_items ; + CleanSubGroup *cache_thumbnails_btn; + CleanListWidget *cache_firefox_items ; + CleanSubGroup *cache_firefox_btn; + CleanListWidget *cache_chromium_items ; + CleanSubGroup *cache_chromium_btn; + + CleanListWidget *package_unneed_items ; + CleanSubGroup *package_unneed_btn; + CleanListWidget *package_oldkernel_items ; + CleanSubGroup *package_oldkernel_btn; + CleanListWidget *package_configfile_items ; + CleanSubGroup *package_configfile_btn; + + CleanListWidget *cookies_firefox_items ; + CleanSubGroup *cookies_firefox_btn; + CleanListWidget *cookies_chromium_items ; + CleanSubGroup *cookies_chromium_btn; + + CleanSubGroup *trace_firefox_btn; + CleanSubGroup *trace_chromium_btn; + CleanSubGroup *trace_system_btn; + CleanSubGroup *trace_bash_btn; + CleanListWidget *trace_x11_items ; + CleanSubGroup *trace_x11_btn; + + QStringList cache_apt_list; + QStringList cache_software_list; + QStringList cache_thumbnails_list; + QStringList cache_firefox_list; + QStringList cache_chromium_list; + QStringList package_unneed_list; + QStringList package_oldkernel_list; + QStringList package_configfile_list; + QStringList cookies_firefox_list; + QStringList cookies_chromium_list; + QString trace_firefox_count; + QString trace_chromium_count; + QString trace_system_count; + QString trace_bash_size; + QString trace_bash_path; + QStringList trace_x11_list; + + QGridLayout *grid_layout; +// int rowIndex; +// int columnIndex; + int subCount; + bool scanResult; + QString cur_skin; +}; + +#endif // CLEANERDETAILWIDGET_H diff --git a/cleaner/cleanerdetailwidget-test.cpp b/cleaner/cleanerdetailwidget-test.cpp new file mode 100644 index 0000000..036490e --- /dev/null +++ b/cleaner/cleanerdetailwidget-test.cpp @@ -0,0 +1,1247 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleanerdetailwidget.h" +#include "ui_cleanerdetailwidget.h" +#include "../mainui/mainwindow.h" +#include "../component/cleansubgroup.h" +#include +#include +#include "../component/cardwidget.h" + +CleanerDetailWidget::CleanerDetailWidget(QWidget *parent, SessionDispatcher *seroxy, SystemDispatcher *syproxy, MainWindow *window, Toolkits *kits, QString skin) + : QWidget(parent), sessionproxy(seroxy), systemproxy(syproxy), parentWindow(window), toolKits(kits),cur_skin(skin) +// ui(new Ui::CleanerDetailWidget) +{ +// ui->setupUi(this); +// this->setStyleSheet("QWidget{border: none}"); +// this->setObjectName("transparentWidget"); +// this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + this->setFixedSize(900, 403); + this->setStyleSheet("QWidget{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); + setWindowFlags(Qt::FramelessWindowHint); + +// this->setAutoFillBackground(true); +// QPalette palette; +// palette.setBrush(QPalette::Window, QBrush(Qt::white)); +// this->setPalette(palette); +// this->setObjectName("transparentWidget"); +// this->setAutoFillBackground(true); +// QPalette palette; +// palette.setBrush(QPalette::Window, QBrush(Qt::white)); +// this->setPalette(palette); + +// ui->scrollArea->setFixedSize(900, 403); +// ui->scrollArea->setAutoFillBackground(true); +// ui->scrollArea->setBackgroundRole(QPalette::Light); + + subCount = 0; + scanResult = false; +// ui->label->hide(); + +// grid_layout = new QGridLayout(); +// rowIndex = columnIndex = 0; + + cache_apt_items = NULL; + cache_apt_btn = NULL; + cache_software_items = NULL; + cache_software_btn = NULL; + cache_thumbnails_items = NULL; + cache_thumbnails_btn = NULL; + cache_firefox_items = NULL; + cache_firefox_btn = NULL; + cache_chromium_items = NULL; + cache_chromium_btn = NULL; + + package_unneed_items = NULL; + package_unneed_btn = NULL; + package_oldkernel_items = NULL; + package_oldkernel_btn = NULL; + package_configfile_items = NULL; + package_configfile_btn = NULL; + + cookies_firefox_items = NULL; + cookies_firefox_btn = NULL; + cookies_chromium_items = NULL; + cookies_chromium_btn = NULL; + + trace_firefox_btn = NULL; + trace_chromium_btn = NULL; + trace_system_btn = NULL; + trace_bash_btn = NULL; + trace_x11_btn = NULL; + trace_x11_items = NULL; + +// ui->scrollAreaWidgetContents->setLayout(grid_layout); + this->setLanguage(); + + skin_widget = new QWidget(this); + skin_widget->setGeometry(QRect(0, 0, 900, 403)); +// custom_list_widget = new CardWidget(160, 110, 5, this->skin_widget); + custom_list_widget = new CardWidget(130, 87, 10, this->skin_widget); + custom_list_widget->setGeometry(QRect(0, 0, 900, 403)); + custom_list_widget->calculate_data(); + custom_card_list.clear(); +// custom_list_widget->show(); +// this->setStyleSheet("QWidget{background:white;}"); +} + +CleanerDetailWidget::~CleanerDetailWidget() +{ + if(cache_apt_items != NULL) + { + delete cache_apt_items; + cache_apt_items = NULL; + } + if(cache_software_items != NULL) + { + delete cache_software_items; + cache_software_items = NULL; + } + if(cache_thumbnails_items != NULL) + { + delete cache_thumbnails_items; + cache_thumbnails_items = NULL; + } + if(cache_firefox_items != NULL) + { + delete cache_firefox_items; + cache_firefox_items = NULL; + } + if(cache_chromium_items != NULL) + { + delete cache_chromium_items; + cache_chromium_items = NULL; + } + if(package_unneed_items != NULL) + { + delete package_unneed_items; + package_unneed_items = NULL; + } + if(package_oldkernel_items != NULL) + { + delete package_oldkernel_items; + package_oldkernel_items = NULL; + } + if(package_configfile_items != NULL) + { + delete package_configfile_items; + package_configfile_items = NULL; + } + if(cookies_firefox_items != NULL) + { + delete cookies_firefox_items; + cookies_firefox_items = NULL; + } + if(cookies_chromium_items != NULL) + { + delete cookies_chromium_items; + cookies_chromium_items = NULL; + } + if(trace_x11_items != NULL) + { + delete trace_x11_items; + trace_x11_items = NULL; + } +// if(grid_layout != NULL) +// { +// delete grid_layout; +// grid_layout = NULL; +// } +// delete ui; +} + +void CleanerDetailWidget::CleanUIAndData() +{ + qDebug() << "CleanUIAndData-------------"; + custom_card_list.clear(); + custom_list_widget->clear_card(); + + +// if(!ui->label->isHidden()) +// ui->label->hide(); + scanResult = false; + subCount = 0; +// rowIndex = columnIndex = 0; + cache_apt_list.clear(); + cache_software_list.clear(); + cache_thumbnails_list.clear(); + cache_firefox_list.clear(); + cache_chromium_list.clear(); + package_unneed_list.clear(); + package_oldkernel_list.clear(); + package_configfile_list.clear(); + cookies_firefox_list.clear(); + cookies_chromium_list.clear(); + trace_firefox_count.clear(); + trace_chromium_count.clear(); + trace_system_count.clear(); + trace_bash_size.clear(); + trace_bash_path.clear(); + trace_x11_list.clear(); + + //clear ui +// while(grid_layout != NULL && grid_layout->count() > 0) +// { +// QWidget* widget = grid_layout->itemAt(0)->widget(); +// grid_layout->removeWidget(widget); +// delete widget; +// } +} + +void CleanerDetailWidget::showReciveData(const QStringList &data) +{ + //----------------------------------------------------------------Cache--------------------------- + if(data.at(0) == "Belong:Cache.apt" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_apt_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.software-center" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_software_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.thumbnails" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_thumbnails_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.firefox" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_firefox_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.chromium" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_chromium_list.append(data.at(1).split(":").at(1)); + } + } + //----------------------------------------------------------------Package--------------------------- + else if(data.at(0) == "Belong:Packages.unneed" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + package_unneed_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Packages.oldkernel" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + package_oldkernel_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Packages.configfile" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + package_configfile_list.append(data.at(1).split(":").at(1)); + } + } + + //----------------------------------------------------------------Cookies--------------------------- + else if(data.at(0) == "Belong:Cookies.firefox" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":") && !data.at(1).split(":").at(1).isEmpty()) + { + if (scanResult == false) + scanResult = true; + cookies_firefox_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cookies.chromium" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":") && !data.at(1).split(":").at(1).isEmpty()) + { + if (scanResult == false) + scanResult = true; + cookies_chromium_list.append(data.at(1).split(":").at(1)); + } + } + + //----------------------------------------------------------------History Trace--------------------------- + else if(data.at(0) == "Belong:History.firefox" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if(data.at(1).split(":").at(1).toInt() != 0) { + if (scanResult == false) + scanResult = true; + trace_firefox_count = data.at(1).split(":").at(1); + } + } + } + else if(data.at(0) == "Belong:History.chromium" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if(data.at(1).split(":").at(1).toInt() != 0) { + if (scanResult == false) + scanResult = true; + trace_chromium_count = data.at(1).split(":").at(1); + } + } + } + else if(data.at(0) == "Belong:History.system" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if(data.at(1).split(":").at(1).toInt() != 0) { + if (scanResult == false) + scanResult = true; + trace_system_count = data.at(1).split(":").at(1); + } + } + } + else if(data.at(0) == "Belong:History.bash" && !data.at(1).isEmpty() && !data.at(2).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + trace_bash_size= data.at(1).split(":").at(1); + trace_bash_path= data.at(2).split(":").at(1); + } +// qDebug() << "bash------------"; +// qDebug() << data.at(1);//"Size:55.67 KB" +// qDebug() << data.at(2);/"Path:/home/kobe/.bash_history" + } + else if(data.at(0) == "Belong:History.X11")// && !data.at(1).isEmpty() && !data.at(2).isEmpty() + { +// qDebug() << "x11------------"; +// qDebug() << data.at(1);//Path:/home/kobe/.xsession-errors +// qDebug() << data.at(2);//Type:file +// qDebug() << data.at(3);//Size:0.98 KB + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + trace_x11_list.append(data.at(1).split(":").at(1)); + } + } +} + +void CleanerDetailWidget::showReciveStatus(const QString &status) +{ + if(status == "Complete:Cache") + { + if(cache_apt_list.length() > 0) + { + cache_apt_items = new CleanListWidget(cache_apt_list, this->cur_skin, tr("Apt Cache Clean Items")); +// cache_apt_btn = new CommonCheckBox(0, "://res/cache"); + cache_apt_btn = new CleanSubGroup(0, "://res/janitor/apt"); + cache_apt_btn->setFocusPolicy(Qt::NoFocus); +// cache_apt_btn->setFixedSize(160, 130); +// cache_apt_btn->setFixedSize(160, 200); + cache_apt_btn->setStatusTip("cache-apt"); + cache_apt_btn->setLabelText(tr("Apt Cache count:"), cache_apt_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_apt_items, SIGNAL(notifyMainCheckBox(int)), cache_apt_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,显示自定义页面 + connect(cache_apt_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_apt_btn, SIGNAL(spreadStatus(int)), cache_apt_items, SLOT(resetSubCheckbox(int))); + +// custom_card_list.append(cache_apt_btn); +// custom_list_widget->add_card(cache_apt_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + qDebug() << "cache_apt_btn added......"; + +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cache_apt_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_apt_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_apt_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cache_software_list.length() > 0) + { + cache_software_items = new CleanListWidget(cache_software_list, this->cur_skin, tr("Software Cache Clean Items")); +// cache_software_btn = new CommonCheckBox(0, "://res/cache"); + cache_software_btn = new CleanSubGroup(0, "://res/janitor/software"); + cache_software_btn->setFocusPolicy(Qt::NoFocus); +// cache_software_btn->setFixedSize(160, 130); +// cache_software_btn->setFixedSize(160, 200); + cache_software_btn->setStatusTip("cache-software"); + cache_software_btn->setLabelText(tr("Software Cache count:"), cache_software_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_software_items, SIGNAL(notifyMainCheckBox(int)), cache_software_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_software_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_software_btn, SIGNAL(spreadStatus(int)), cache_software_items, SLOT(resetSubCheckbox(int))); + +// custom_card_list.append(cache_software_btn); +// custom_list_widget->add_card(cache_software_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + qDebug() << "cache_software_btn added......"; + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cache_software_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_software_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_software_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cache_thumbnails_list.length() > 0) + { + cache_thumbnails_items = new CleanListWidget(cache_thumbnails_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// cache_thumbnails_btn = new CommonCheckBox(0, "://res/cache"); + cache_thumbnails_btn = new CleanSubGroup(0, "://res/janitor/thumbnails"); + cache_thumbnails_btn->setFocusPolicy(Qt::NoFocus); +// cache_thumbnails_btn->setFixedSize(160, 130); +// cache_thumbnails_btn->setFixedSize(160, 200); + cache_thumbnails_btn->setStatusTip("cache-thumbnails"); + cache_thumbnails_btn->setLabelText(tr("Thumbnails Cache Count:"), cache_thumbnails_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_thumbnails_items, SIGNAL(notifyMainCheckBox(int)), cache_thumbnails_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_thumbnails_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_thumbnails_btn, SIGNAL(spreadStatus(int)), cache_thumbnails_items, SLOT(resetSubCheckbox(int))); + + +// CleanSubGroup *testbtn = new CleanSubGroup(0, "://res/janitor/thumbnails"); +// testbtn->setFocusPolicy(Qt::NoFocus); +// testbtn->setStatusTip("cache-thumbnails"); +// testbtn->setLabelText(tr("Thumbnails Cache Count:"), cache_thumbnails_list.length()); +// custom_card_list.append(testbtn); +// custom_list_widget->add_card(testbtn); + +// custom_card_list.append(cache_thumbnails_btn); +// custom_list_widget->add_card(cache_thumbnails_btn); + +// ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); +// custom_card_list.append(card); +// custom_list_widget->add_card(card); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + qDebug() << "cache_thumbnails_btn added......"; + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cache_thumbnails_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_thumbnails_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_thumbnails_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + + + if(cache_firefox_list.length() > 0) + { + cache_firefox_items = new CleanListWidget(cache_firefox_list, this->cur_skin, tr("Software Cache Clean Items")); +// cache_firefox_btn = new CommonCheckBox(0, "://res/cache"); + cache_firefox_btn = new CleanSubGroup(0, "://res/janitor/firefox"); + cache_firefox_btn->setFocusPolicy(Qt::NoFocus); +// cache_firefox_btn->setFixedSize(160, 130); + cache_firefox_btn->setStatusTip("cache-firefox"); + cache_firefox_btn->setLabelText(tr("Firefox Cache Count:"), cache_firefox_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_firefox_items, SIGNAL(notifyMainCheckBox(int)), cache_firefox_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_firefox_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_firefox_btn, SIGNAL(spreadStatus(int)), cache_firefox_items, SLOT(resetSubCheckbox(int))); + +// custom_card_list.append(cache_firefox_btn); +// custom_list_widget->add_card(cache_firefox_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + qDebug() << "cache_firefox_btn added......"; + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cache_firefox_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cache_chromium_list.length() > 0) + { + cache_chromium_items = new CleanListWidget(cache_chromium_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// cache_chromium_btn = new CommonCheckBox(0, "://res/cache"); + cache_chromium_btn = new CleanSubGroup(0, "://res/janitor/chromium"); + cache_chromium_btn->setFocusPolicy(Qt::NoFocus); +// cache_chromium_btn->setFixedSize(160, 130); + cache_chromium_btn->setStatusTip("cache-chromium"); + cache_chromium_btn->setLabelText(tr("Chromium Cache Count:"), cache_chromium_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_chromium_items, SIGNAL(notifyMainCheckBox(int)), cache_chromium_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_chromium_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_chromium_btn, SIGNAL(spreadStatus(int)), cache_chromium_items, SLOT(resetSubCheckbox(int))); + + +// custom_card_list.append(cache_chromium_btn); +// custom_list_widget->add_card(cache_chromium_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + qDebug() << "cache_chromium_btn added......"; + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cache_chromium_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + else if(status == "Complete:Cookies") + { +// doing_label->setText(tr("Cookies Scan OK......")); + if(cookies_firefox_list.length() > 0) + { + cookies_firefox_items = new CleanListWidget(cookies_firefox_list, this->cur_skin, tr("Firefox Cookies Clean Items")); +// cookies_firefox_btn = new CommonCheckBox(0, "://res/cookie"); + cookies_firefox_btn = new CleanSubGroup(0, "://res/janitor/firefox"); + cookies_firefox_btn->setFocusPolicy(Qt::NoFocus); +// cookies_firefox_btn->setFixedSize(160, 130); + cookies_firefox_btn->setStatusTip("cookes-firefox"); + cookies_firefox_btn->setLabelText(tr("Firefox Cookies Count:"), cookies_firefox_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cookies_firefox_items, SIGNAL(notifyMainCheckBox(int)), cookies_firefox_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_firefox_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_firefox_btn, SIGNAL(spreadStatus(int)), cookies_firefox_items, SLOT(resetSubCheckbox(int))); + +// custom_card_list.append(cookies_firefox_btn); +// custom_list_widget->add_card(cookies_firefox_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cookies_firefox_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cookies_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cookies_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cookies_chromium_list.length() > 0) + { + cookies_chromium_items = new CleanListWidget(cookies_chromium_list, this->cur_skin, tr("Chromium Cookies Clean Items")); +// cookies_chromium_btn = new CommonCheckBox(0, "://res/cache"); + cookies_chromium_btn = new CleanSubGroup(0, "://res/janitor/chromium"); + cookies_chromium_btn->setFocusPolicy(Qt::NoFocus); +// cookies_chromium_btn->setFixedSize(160, 130); + cookies_chromium_btn->setStatusTip("cookes-chromium"); + cookies_chromium_btn->setLabelText(tr("Chromium Cookies Count:"), cookies_chromium_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cookies_chromium_items, SIGNAL(notifyMainCheckBox(int)), cookies_chromium_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_chromium_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_chromium_btn, SIGNAL(spreadStatus(int)), cookies_chromium_items, SLOT(resetSubCheckbox(int))); + +// custom_card_list.append(cookies_chromium_btn); +// custom_list_widget->add_card(cookies_chromium_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cookies_chromium_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cookies_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cookies_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + else if(status == "Complete:History") + { +// doing_label->setText(tr("History Scan OK")); + if(trace_firefox_count.length() > 0) + { +// trace_firefox_btn = new CommonCheckBox(0, "://res/cache"); + trace_firefox_btn = new CleanSubGroup(0, "://res/janitor/firefox"); + trace_firefox_btn->setFocusPolicy(Qt::NoFocus); +// trace_firefox_btn->setFixedSize(160, 130); + trace_firefox_btn->hideCustomButton(); + trace_firefox_btn->setStatusTip("history-firefox"); + trace_firefox_btn->setLabelText(tr("Firefox History Count:"), trace_firefox_count.toInt()); +// custom_card_list.append(trace_firefox_btn); +// custom_list_widget->add_card(trace_firefox_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(trace_firefox_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(trace_chromium_count.length() > 0) + { + trace_chromium_btn = new CleanSubGroup(0, "://res/janitor/chromium"); + trace_chromium_btn->setFocusPolicy(Qt::NoFocus); + trace_chromium_btn->hideCustomButton(); + trace_chromium_btn->setStatusTip("history-chromium"); + trace_chromium_btn->setLabelText(tr("Chromium History Count:"), trace_chromium_count.toInt()); + +// custom_card_list.append(trace_chromium_btn); +// custom_list_widget->add_card(trace_chromium_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(trace_chromium_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + + if(trace_system_count.length() > 0) + { + trace_system_btn = new CleanSubGroup(0, "://res/janitor/trace"); + trace_system_btn->setFocusPolicy(Qt::NoFocus); + trace_system_btn->hideCustomButton(); + trace_system_btn->setStatusTip("history-system"); + trace_system_btn->setLabelText(tr("System History Count:"), trace_system_count.toInt()); + +// custom_card_list.append(trace_system_btn); +// custom_list_widget->add_card(trace_system_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(trace_system_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_system_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_system_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + //kobe + if(!trace_bash_path.isEmpty()) + { + trace_bash_btn = new CleanSubGroup(0, "://res/janitor/trace"); + trace_bash_btn->setFocusPolicy(Qt::NoFocus); + trace_bash_btn->hideCustomButton(); + trace_bash_btn->setStatusTip("history-bash"); + trace_bash_btn->setLabelStringText(tr("Command history size:"), trace_bash_size); + +// custom_card_list.append(trace_bash_btn); +// custom_list_widget->add_card(trace_bash_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(trace_bash_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_bash_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_bash_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + + if(trace_x11_list.length() > 0) + { + trace_x11_items = new CleanListWidget(trace_x11_list, this->cur_skin, tr("Debug log Items")); + trace_x11_btn = new CleanSubGroup(0, "://res/janitor/debug"); + trace_x11_btn->setFocusPolicy(Qt::NoFocus); + trace_x11_btn->setStatusTip("x11-history"); + trace_x11_btn->setLabelText(tr("Debug log:"), trace_x11_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(trace_x11_items, SIGNAL(notifyMainCheckBox(int)), trace_x11_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(trace_x11_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(trace_x11_btn, SIGNAL(spreadStatus(int)), trace_x11_items, SLOT(resetSubCheckbox(int))); + +// custom_card_list.append(trace_x11_btn); +// custom_list_widget->add_card(trace_x11_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(trace_x11_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_x11_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_x11_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + else if(status == "Complete:Packages") + { +// doing_label->setText(tr("Packages Scan OK")); + if(package_unneed_list.length() > 0) + { + package_unneed_items = new CleanListWidget(package_unneed_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// package_unneed_btn = new CommonCheckBox(0, "://res/cache"); + package_unneed_btn = new CleanSubGroup(0, "://res/janitor/package"); + package_unneed_btn->setFocusPolicy(Qt::NoFocus); +// package_unneed_btn->setFixedSize(160, 130); + package_unneed_btn->setStatusTip("package-unneed"); + package_unneed_btn->setLabelText(tr("Package Unneed Count:"),package_unneed_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_unneed_items, SIGNAL(notifyMainCheckBox(int)), package_unneed_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_unneed_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_unneed_btn, SIGNAL(spreadStatus(int)), package_unneed_items, SLOT(resetSubCheckbox(int))); + + +// custom_card_list.append(package_unneed_btn); +// custom_list_widget->add_card(package_unneed_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(package_unneed_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(package_unneed_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(package_unneed_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(package_oldkernel_list.length() > 0) + { + package_oldkernel_items = new CleanListWidget(package_oldkernel_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// package_oldkernel_btn = new CommonCheckBox(0, "://res/cache"); + package_oldkernel_btn = new CleanSubGroup(0, "://res/janitor/package"); + package_oldkernel_btn->setFocusPolicy(Qt::NoFocus); +// package_oldkernel_btn->setFixedSize(160, 130); + package_oldkernel_btn->setStatusTip("package-oldkernel"); + package_oldkernel_btn->setLabelText(tr("Package oldkernel Count:"), package_oldkernel_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_oldkernel_items, SIGNAL(notifyMainCheckBox(int)), package_oldkernel_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_oldkernel_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_oldkernel_btn, SIGNAL(spreadStatus(int)), package_oldkernel_items, SLOT(resetSubCheckbox(int))); + +// custom_card_list.append(package_oldkernel_btn); +// custom_list_widget->add_card(package_oldkernel_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(package_oldkernel_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(package_oldkernel_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(package_oldkernel_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(package_configfile_list.length() > 0) + { + package_configfile_items = new CleanListWidget(package_configfile_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// package_configfile_btn = new CommonCheckBox(0, "://res/cache"); + package_configfile_btn = new CleanSubGroup(0, "://res/janitor/package"); + package_configfile_btn->setFocusPolicy(Qt::NoFocus); +// package_configfile_btn->setFixedSize(160, 130); + package_configfile_btn->setStatusTip("package-configfile"); + package_configfile_btn->setLabelText(tr("Package configfile Count:"),package_configfile_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_configfile_items, SIGNAL(notifyMainCheckBox(int)), package_configfile_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_configfile_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_configfile_btn, SIGNAL(spreadStatus(int)), package_configfile_items, SLOT(resetSubCheckbox(int))); + +// custom_card_list.append(package_configfile_btn); +// custom_list_widget->add_card(package_configfile_btn); + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(package_configfile_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(package_configfile_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(package_configfile_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + else if(status == "Complete:All") + { +// if(!scanResult) +// ui->label->show(); + emit this->sendScanOverStatus(scanResult); +// custom_list_widget->raise(); + } +} + +void CleanerDetailWidget::showCustomPage() +{ + QObject *object = QObject::sender(); +// CommonCheckBox *checkbox = qobject_cast(object); + CleanSubGroup *checkbox = qobject_cast(object); + QString object_name = checkbox->statusTip(); + if(object_name == "cache-apt") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_apt_items->move(w_x, w_y); + cache_apt_items->exec(); + } + else if(object_name == "cache-software") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_software_items->move(w_x, w_y); + cache_software_items->exec(); + } + else if(object_name == "cache-thumbnails") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_thumbnails_items->move(w_x, w_y); + cache_thumbnails_items->exec(); + } + else if(object_name == "cache-firefox") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_firefox_items->move(w_x, w_y); + cache_firefox_items->exec(); + } + else if(object_name == "cache-chromium") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_chromium_items->move(w_x, w_y); + cache_chromium_items->exec(); + } + else if(object_name == "cookes-firefox") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cookies_firefox_items->move(w_x, w_y); + cookies_firefox_items->exec(); + } + else if(object_name == "cookes-chromium") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cookies_chromium_items->move(w_x, w_y); + cookies_chromium_items->exec(); + } + else if(object_name == "package-unneed") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + package_unneed_items->move(w_x, w_y); + package_unneed_items->exec(); + } + else if(object_name == "package-oldkernel") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + package_oldkernel_items->move(w_x, w_y); + package_oldkernel_items->exec(); + } + else if(object_name == "package-configfile") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + package_configfile_items->move(w_x, w_y); + package_configfile_items->exec(); + } + else if(object_name == "x11-history") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + trace_x11_items->move(w_x, w_y); + trace_x11_items->exec(); + } +// else if(object_name == "history-firefox" || object_name == "history-chromium" || object_name == "history-system"|| object_name == "history-bash" ) { +// } +} + +void CleanerDetailWidget::setLanguage() +{ +// ui->label->setText(tr("No garbage ")); +// title_label->setText(tr("Cleaning up the system cache")); +// description_label->setText(tr("Deep cleaning up the system cache, to save disk space")); +} + +void CleanerDetailWidget::resetCurrentSkin(QString skin) +{ + this->cur_skin = skin; + + //can remove this code + if(cache_apt_items != NULL) + cache_apt_items->resetTitleSkin(skin); + if(cache_software_items != NULL) + cache_software_items->resetTitleSkin(skin); + if(cache_thumbnails_items != NULL) + cache_thumbnails_items->resetTitleSkin(skin); + if(cache_firefox_items != NULL) + cache_firefox_items->resetTitleSkin(skin); + if(cache_chromium_items != NULL) + cache_chromium_items->resetTitleSkin(skin); + if(cookies_firefox_items != NULL) + cookies_firefox_items->resetTitleSkin(skin); + if(cookies_chromium_items != NULL) + cookies_chromium_items->resetTitleSkin(skin); + if(package_unneed_items != NULL) + package_unneed_items->resetTitleSkin(skin); + if(package_oldkernel_items != NULL) + package_oldkernel_items->resetTitleSkin(skin); + if(package_configfile_items != NULL) + package_configfile_items->resetTitleSkin(skin); + if(trace_x11_items != NULL) + trace_x11_items->resetTitleSkin(skin); +} + +void CleanerDetailWidget::receiveCleanSignal() +{ + this->getAllSelectedItems(); + if(argsData.empty()) + { + toolKits->alertMSG(parentWindow->geometry().topLeft().x(), parentWindow->geometry().topLeft().y(), tr("Clean args is empty!")); + } + else + { +// qDebug() << "args is.........." << argsData; + systemproxy->set_user_homedir_qt(); + systemproxy->cleanAllSelectItems(argsData); + } +} + +//void CleanerDetailWidget::receivePolicyKitSignal(bool status) +//{ +// //status = true:ok +// //status = false:cacel +// if(status)//ok +// { +// emit this->showActionAnimaiton(); +// } +//} + +void CleanerDetailWidget::getAllSelectedItems() +{ + argsData.clear(); + QStringList fileTmp; + QStringList packageTmp; + QStringList firefoxcookieTmp; + QStringList chromiumcookieTmp; + QStringList traceTmp; + + if(cache_apt_btn != NULL && cache_apt_btn->getCheckBoxStatus() != 0) + { + QStringList tmp = cache_apt_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_software_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_thumbnails_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_firefox_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_chromium_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_unneed_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_oldkernel_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_configfile_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cookies_firefox_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cookies_chromium_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + argsData.insert("firefox-history", QStringList() << trace_firefox_count); + } + if(trace_chromium_btn != NULL && trace_chromium_btn->getCheckBoxStatus() != 0) + { + argsData.insert("chromium-history", QStringList() << trace_chromium_count); + } + if(trace_system_btn != NULL && trace_system_btn->getCheckBoxStatus() != 0) + { + argsData.insert("system-history", QStringList() << trace_system_count); + } + //kobe + if(trace_bash_btn != NULL && trace_bash_btn->getCheckBoxStatus() != 0) + { + argsData.insert("bash-history", QStringList() << trace_bash_path); + } + if(trace_x11_btn != NULL && trace_x11_btn->getCheckBoxStatus() != 0) + { + QStringList tmp = trace_x11_items->getSelectedItems(); + for(int i = 0; i 0) + argsData.insert("file", fileTmp); + if(packageTmp.length() > 0) + argsData.insert("package", packageTmp); + if(firefoxcookieTmp.length() > 0) + argsData.insert("firefox-cookie", firefoxcookieTmp); + if(chromiumcookieTmp.length() > 0) + argsData.insert("chromium-cookie", chromiumcookieTmp); + if(traceTmp.length() > 0) + argsData.insert("x11-history", traceTmp); +} diff --git a/cleaner/cleanerdetailwidget-test.h b/cleaner/cleanerdetailwidget-test.h new file mode 100644 index 0000000..e7f74ab --- /dev/null +++ b/cleaner/cleanerdetailwidget-test.h @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERDETAILWIDGET_H +#define CLEANERDETAILWIDGET_H + +#include +#include "cleaneritems.h" +#include "cleanlistwidget.h" + +class QLabel; +class QBoxLayout; +class QHBoxLayout; +class QGridLayout; +class SessionDispatcher; +class SystemDispatcher; +class Toolkits; +class MainWindow; +class CleanSubGroup; + +//1110 +class CardWidget; +class ItemCard; + +//namespace Ui { +//class CleanerDetailWidget; +//} + +class CleanerDetailWidget : public QWidget +{ + Q_OBJECT + +public: + explicit CleanerDetailWidget(QWidget *parent = 0, SessionDispatcher *seroxy = 0, SystemDispatcher *syproxy = 0, MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png"); + ~CleanerDetailWidget(); + void setUIData(); + void setLanguage(); + void initConnect(); + void getAllSelectedItems(); + void resetCurrentSkin(QString skin); + +public slots: + void showCustomPage(); + void showReciveData(const QStringList &data); + void receiveCleanSignal(); + void showReciveStatus(const QString &status); + void CleanUIAndData(); +// void receivePolicyKitSignal(bool status); + +signals: + void notifyMainCheckBox(int status); +// void showActionAnimaiton(); + void sendScanOverStatus(bool status); + +private: + void initTitleBar(); + +private: +// Ui::CleanerDetailWidget *ui; + MainWindow *parentWindow; + SessionDispatcher *sessionproxy; + SystemDispatcher *systemproxy; + Toolkits *toolKits; + QMap argsData; + CleanListWidget *cache_apt_items ; + CleanSubGroup *cache_apt_btn; + CleanListWidget *cache_software_items ; + CleanSubGroup *cache_software_btn; + CleanListWidget *cache_thumbnails_items ; + CleanSubGroup *cache_thumbnails_btn; + CleanListWidget *cache_firefox_items ; + CleanSubGroup *cache_firefox_btn; + CleanListWidget *cache_chromium_items ; + CleanSubGroup *cache_chromium_btn; + + CleanListWidget *package_unneed_items ; + CleanSubGroup *package_unneed_btn; + CleanListWidget *package_oldkernel_items ; + CleanSubGroup *package_oldkernel_btn; + CleanListWidget *package_configfile_items ; + CleanSubGroup *package_configfile_btn; + + CleanListWidget *cookies_firefox_items ; + CleanSubGroup *cookies_firefox_btn; + CleanListWidget *cookies_chromium_items ; + CleanSubGroup *cookies_chromium_btn; + + CleanSubGroup *trace_firefox_btn; + CleanSubGroup *trace_chromium_btn; + CleanSubGroup *trace_system_btn; + CleanSubGroup *trace_bash_btn; + CleanListWidget *trace_x11_items ; + CleanSubGroup *trace_x11_btn; + + QStringList cache_apt_list; + QStringList cache_software_list; + QStringList cache_thumbnails_list; + QStringList cache_firefox_list; + QStringList cache_chromium_list; + QStringList package_unneed_list; + QStringList package_oldkernel_list; + QStringList package_configfile_list; + QStringList cookies_firefox_list; + QStringList cookies_chromium_list; + QString trace_firefox_count; + QString trace_chromium_count; + QString trace_system_count; + QString trace_bash_size; + QString trace_bash_path; + QStringList trace_x11_list; + +// QGridLayout *grid_layout; +// int rowIndex; +// int columnIndex; + int subCount; + bool scanResult; + QString cur_skin; + + + //1110 + CardWidget *custom_list_widget; +// QList custom_card_list; + QList custom_card_list; + QWidget *skin_widget; +}; + +#endif // CLEANERDETAILWIDGET_H diff --git a/cleaner/cleanerdetailwidget.cpp b/cleaner/cleanerdetailwidget.cpp new file mode 100644 index 0000000..d025850 --- /dev/null +++ b/cleaner/cleanerdetailwidget.cpp @@ -0,0 +1,1293 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleanerdetailwidget.h" +#include "ui_cleanerdetailwidget.h" +#include "../mainui/mainwindow.h" +#include "../component/cleansubgroup.h" +#include +#include + +CleanerDetailWidget::CleanerDetailWidget(QWidget *parent, SessionDispatcher *seroxy, SystemDispatcher *syproxy, MainWindow *window, Toolkits *kits, QString skin) + : QWidget(parent), sessionproxy(seroxy), systemproxy(syproxy), parentWindow(window), toolKits(kits),cur_skin(skin), + ui(new Ui::CleanerDetailWidget) +{ + ui->setupUi(this); +// this->setStyleSheet("QWidget{border: none}"); + this->setFixedSize(900, 403); + this->setObjectName("transparentWidget"); + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + + /*this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette);*/ +// this->setObjectName("transparentWidget"); +// this->setAutoFillBackground(true); +// QPalette palette; +// palette.setBrush(QPalette::Window, QBrush(Qt::white)); +// this->setPalette(palette); + + this->number_per_row = -1; + this->itemwidth = 160; + this->itemheight = 110; + this->cardspace = 10; + + ui->scrollAreaWidgetContents->setGeometry(0, 0, this->width(), this->height()); + ui->scrollArea->setFixedSize(900, 403); + ui->scrollArea->setAutoFillBackground(true); + ui->scrollArea->setBackgroundRole(QPalette::Light); + + subCount = 0; + scanResult = false; + ui->label->hide(); + +// grid_layout = new QGridLayout(); +// rowIndex = columnIndex = 0; + + cache_apt_items = NULL; + cache_apt_btn = NULL; + cache_software_items = NULL; + cache_software_btn = NULL; + cache_thumbnails_items = NULL; + cache_thumbnails_btn = NULL; + cache_firefox_items = NULL; + cache_firefox_btn = NULL; + cache_chromium_items = NULL; + cache_chromium_btn = NULL; + +// package_unneed_items = NULL; +// package_unneed_btn = NULL; +// package_oldkernel_items = NULL; +// package_oldkernel_btn = NULL; +// package_configfile_items = NULL; +// package_configfile_btn = NULL; + + cookies_firefox_items = NULL; + cookies_firefox_btn = NULL; + cookies_chromium_items = NULL; + cookies_chromium_btn = NULL; + + trace_firefox_btn = NULL; + trace_chromium_btn = NULL; + trace_system_btn = NULL; + trace_bash_btn = NULL; + trace_x11_btn = NULL; + trace_x11_items = NULL; + +// ui->scrollAreaWidgetContents->setLayout(grid_layout); + this->number_per_row = (this->width() + this->cardspace - 60) / (this->itemwidth + this->cardspace); + this->setLanguage(); +} + +CleanerDetailWidget::~CleanerDetailWidget() +{ + if(cache_apt_items != NULL) + { + delete cache_apt_items; + cache_apt_items = NULL; + } + if(cache_software_items != NULL) + { + delete cache_software_items; + cache_software_items = NULL; + } + if(cache_thumbnails_items != NULL) + { + delete cache_thumbnails_items; + cache_thumbnails_items = NULL; + } + if(cache_firefox_items != NULL) + { + delete cache_firefox_items; + cache_firefox_items = NULL; + } + if(cache_chromium_items != NULL) + { + delete cache_chromium_items; + cache_chromium_items = NULL; + } + /*if(package_unneed_items != NULL) + { + delete package_unneed_items; + package_unneed_items = NULL; + } + if(package_oldkernel_items != NULL) + { + delete package_oldkernel_items; + package_oldkernel_items = NULL; + } + if(package_configfile_items != NULL) + { + delete package_configfile_items; + package_configfile_items = NULL; + }*/ + if(cookies_firefox_items != NULL) + { + delete cookies_firefox_items; + cookies_firefox_items = NULL; + } + if(cookies_chromium_items != NULL) + { + delete cookies_chromium_items; + cookies_chromium_items = NULL; + } + if(trace_x11_items != NULL) + { + delete trace_x11_items; + trace_x11_items = NULL; + } +// if(grid_layout != NULL) +// { +// delete grid_layout; +// grid_layout = NULL; +// } + delete ui; +} + +void CleanerDetailWidget::CleanUIAndData() +{ + if(!ui->label->isHidden()) + ui->label->hide(); + scanResult = false; + subCount = 0; +// rowIndex = columnIndex = 0; + cache_apt_list.clear(); + cache_software_list.clear(); + cache_thumbnails_list.clear(); + cache_firefox_list.clear(); + cache_chromium_list.clear(); + /*package_unneed_list.clear(); + package_oldkernel_list.clear(); + package_configfile_list.clear();*/ + cookies_firefox_list.clear(); + cookies_chromium_list.clear(); + trace_firefox_count.clear(); + trace_chromium_count.clear(); + trace_system_count.clear(); + trace_bash_size.clear(); + trace_bash_path.clear(); + trace_x11_list.clear(); + + //clear ui +// foreach (QObject *child, ui->scrollAreaWidgetContents->children()) { +// QWidget *widget = static_cast(child); +// widget->deleteLater(); +// } + for(int i=0; iscrollAreaWidgetContents->setGeometry(0, 0, this->width(), this->height()); + this->subCount = 0; +// while(grid_layout != NULL && grid_layout->count() > 0) +// { +// QWidget* widget = grid_layout->itemAt(0)->widget(); +// grid_layout->removeWidget(widget); +// delete widget; +// } +} + +void CleanerDetailWidget::showReciveData(const QStringList &data) +{ + //----------------------------------------------------------------Cache--------------------------- + if(data.at(0) == "Belong:Cache.apt" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_apt_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.software-center" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_software_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.thumbnails" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_thumbnails_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.firefox" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_firefox_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cache.chromium" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + cache_chromium_list.append(data.at(1).split(":").at(1)); + } + } + //----------------------------------------------------------------Package--------------------------- + /*else if(data.at(0) == "Belong:Packages.unneed" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + package_unneed_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Packages.oldkernel" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + package_oldkernel_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Packages.configfile" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + package_configfile_list.append(data.at(1).split(":").at(1)); + } + }*/ + + //----------------------------------------------------------------Cookies--------------------------- + else if(data.at(0) == "Belong:Cookies.firefox" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":") && !data.at(1).split(":").at(1).isEmpty()) + { + if (scanResult == false) + scanResult = true; + cookies_firefox_list.append(data.at(1).split(":").at(1)); + } + } + else if(data.at(0) == "Belong:Cookies.chromium" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":") && !data.at(1).split(":").at(1).isEmpty()) + { + if (scanResult == false) + scanResult = true; + cookies_chromium_list.append(data.at(1).split(":").at(1)); + } + } + + //----------------------------------------------------------------History Trace--------------------------- + else if(data.at(0) == "Belong:History.firefox" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if(data.at(1).split(":").at(1).toInt() != 0) { + if (scanResult == false) + scanResult = true; + trace_firefox_count = data.at(1).split(":").at(1); + } + } + } + else if(data.at(0) == "Belong:History.chromium" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if(data.at(1).split(":").at(1).toInt() != 0) { + if (scanResult == false) + scanResult = true; + trace_chromium_count = data.at(1).split(":").at(1); + } + } + } + else if(data.at(0) == "Belong:History.system" && !data.at(1).isEmpty()) + { + if(data.at(1).contains(":")) + { + if(data.at(1).split(":").at(1).toInt() != 0) { + if (scanResult == false) + scanResult = true; + trace_system_count = data.at(1).split(":").at(1); + } + } + } + else if(data.at(0) == "Belong:History.bash" && !data.at(1).isEmpty() && !data.at(2).isEmpty()) + { + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + trace_bash_size= data.at(1).split(":").at(1); + trace_bash_path= data.at(2).split(":").at(1); + } +// qDebug() << "bash------------"; +// qDebug() << data.at(1);//"Size:55.67 KB" +// qDebug() << data.at(2);/"Path:/home/kobe/.bash_history" + } + else if(data.at(0) == "Belong:History.X11")// && !data.at(1).isEmpty() && !data.at(2).isEmpty() + { +// qDebug() << "x11------------"; +// qDebug() << data.at(1);//Path:/home/kobe/.xsession-errors +// qDebug() << data.at(2);//Type:file +// qDebug() << data.at(3);//Size:0.98 KB + if(data.at(1).contains(":")) + { + if (scanResult == false) + scanResult = true; + trace_x11_list.append(data.at(1).split(":").at(1)); + } + } +} + +void CleanerDetailWidget::showReciveStatus(const QString &status) +{ + if(status == "Complete:Cache") + { + if(cache_apt_list.length() > 0) + { + cache_apt_items = new CleanListWidget(cache_apt_list, this->cur_skin, tr("Apt Cache Clean Items")); +// cache_apt_btn = new CommonCheckBox(0, "://res/cache"); + cache_apt_btn = new CleanSubGroup(this, "://res/janitor/apt"); + cache_apt_btn->setFocusPolicy(Qt::NoFocus); +// cache_apt_btn->setFixedSize(160, 130); +// cache_apt_btn->setFixedSize(160, 200); + cache_apt_btn->setStatusTip("cache-apt"); + cache_apt_btn->setLabelText(tr("Apt Cache count:"), cache_apt_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_apt_items, SIGNAL(notifyMainCheckBox(int)), cache_apt_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,显示自定义页面 + connect(cache_apt_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_apt_btn, SIGNAL(spreadStatus(int)), cache_apt_items, SLOT(resetSubCheckbox(int))); +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cache_apt_btn, subCount/5, subCount%5); + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + cache_apt_btn->move(x, y); + cache_apt_btn->show(); + cardlist.append(cache_apt_btn); + subCount += 1; + + +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_apt_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_apt_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cache_software_list.length() > 0) + { + cache_software_items = new CleanListWidget(cache_software_list, this->cur_skin, tr("Software Cache Clean Items")); +// cache_software_btn = new CommonCheckBox(0, "://res/cache"); + cache_software_btn = new CleanSubGroup(this, "://res/janitor/software"); + cache_software_btn->setFocusPolicy(Qt::NoFocus); +// cache_software_btn->setFixedSize(160, 130); +// cache_software_btn->setFixedSize(160, 200); + cache_software_btn->setStatusTip("cache-software"); + cache_software_btn->setLabelText(tr("Software Cache count:"), cache_software_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_software_items, SIGNAL(notifyMainCheckBox(int)), cache_software_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_software_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_software_btn, SIGNAL(spreadStatus(int)), cache_software_items, SLOT(resetSubCheckbox(int))); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + cache_software_btn->move(x, y); + cache_software_btn->show(); + cardlist.append(cache_software_btn); + subCount += 1; + + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cache_software_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_software_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_software_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cache_thumbnails_list.length() > 0) + { + cache_thumbnails_items = new CleanListWidget(cache_thumbnails_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// cache_thumbnails_btn = new CommonCheckBox(0, "://res/cache"); + cache_thumbnails_btn = new CleanSubGroup(this, "://res/janitor/thumbnails"); + cache_thumbnails_btn->setFocusPolicy(Qt::NoFocus); +// cache_thumbnails_btn->setFixedSize(160, 130); +// cache_thumbnails_btn->setFixedSize(160, 200); + cache_thumbnails_btn->setStatusTip("cache-thumbnails"); + cache_thumbnails_btn->setLabelText(tr("Thumbnails Cache Count:"), cache_thumbnails_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_thumbnails_items, SIGNAL(notifyMainCheckBox(int)), cache_thumbnails_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_thumbnails_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_thumbnails_btn, SIGNAL(spreadStatus(int)), cache_thumbnails_items, SLOT(resetSubCheckbox(int))); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + cache_thumbnails_btn->move(x, y); + cache_thumbnails_btn->show(); + cardlist.append(cache_thumbnails_btn); + subCount += 1; + + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cache_thumbnails_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_thumbnails_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_thumbnails_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + + + if(cache_firefox_list.length() > 0) + { + cache_firefox_items = new CleanListWidget(cache_firefox_list, this->cur_skin, tr("Software Cache Clean Items")); +// cache_firefox_btn = new CommonCheckBox(0, "://res/cache"); + cache_firefox_btn = new CleanSubGroup(this, "://res/janitor/firefox"); + cache_firefox_btn->setFocusPolicy(Qt::NoFocus); +// cache_firefox_btn->setFixedSize(160, 130); + cache_firefox_btn->setStatusTip("cache-firefox"); + cache_firefox_btn->setLabelText(tr("Firefox Cache Count:"), cache_firefox_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_firefox_items, SIGNAL(notifyMainCheckBox(int)), cache_firefox_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_firefox_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_firefox_btn, SIGNAL(spreadStatus(int)), cache_firefox_items, SLOT(resetSubCheckbox(int))); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + cache_firefox_btn->move(x, y); + cache_firefox_btn->show(); + cardlist.append(cache_firefox_btn); + subCount += 1; + // if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cache_firefox_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cache_chromium_list.length() > 0) + { + cache_chromium_items = new CleanListWidget(cache_chromium_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// cache_chromium_btn = new CommonCheckBox(0, "://res/cache"); + cache_chromium_btn = new CleanSubGroup(this, "://res/janitor/chromium"); + cache_chromium_btn->setFocusPolicy(Qt::NoFocus); +// cache_chromium_btn->setFixedSize(160, 130); + cache_chromium_btn->setStatusTip("cache-chromium"); + cache_chromium_btn->setLabelText(tr("Chromium Cache Count:"), cache_chromium_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_chromium_items, SIGNAL(notifyMainCheckBox(int)), cache_chromium_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_chromium_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cache_chromium_btn, SIGNAL(spreadStatus(int)), cache_chromium_items, SLOT(resetSubCheckbox(int))); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + cache_chromium_btn->move(x, y); + cache_chromium_btn->show(); + cardlist.append(cache_chromium_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cache_chromium_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cache_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cache_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + else if(status == "Complete:Cookies") + { +// doing_label->setText(tr("Cookies Scan OK......")); + if(cookies_firefox_list.length() > 0) + { + cookies_firefox_items = new CleanListWidget(cookies_firefox_list, this->cur_skin, tr("Firefox Cookies Clean Items")); +// cookies_firefox_btn = new CommonCheckBox(0, "://res/cookie"); + cookies_firefox_btn = new CleanSubGroup(this, "://res/janitor/firefox"); + cookies_firefox_btn->setFocusPolicy(Qt::NoFocus); +// cookies_firefox_btn->setFixedSize(160, 130); + cookies_firefox_btn->setStatusTip("cookes-firefox"); + cookies_firefox_btn->setLabelText(tr("Firefox Cookies Count:"), cookies_firefox_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cookies_firefox_items, SIGNAL(notifyMainCheckBox(int)), cookies_firefox_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_firefox_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_firefox_btn, SIGNAL(spreadStatus(int)), cookies_firefox_items, SLOT(resetSubCheckbox(int))); + + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + cookies_firefox_btn->move(x, y); + cookies_firefox_btn->show(); + cardlist.append(cookies_firefox_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cookies_firefox_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cookies_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cookies_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(cookies_chromium_list.length() > 0) + { + cookies_chromium_items = new CleanListWidget(cookies_chromium_list, this->cur_skin, tr("Chromium Cookies Clean Items")); +// cookies_chromium_btn = new CommonCheckBox(0, "://res/cache"); + cookies_chromium_btn = new CleanSubGroup(this, "://res/janitor/chromium"); + cookies_chromium_btn->setFocusPolicy(Qt::NoFocus); +// cookies_chromium_btn->setFixedSize(160, 130); + cookies_chromium_btn->setStatusTip("cookes-chromium"); + cookies_chromium_btn->setLabelText(tr("Chromium Cookies Count:"), cookies_chromium_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cookies_chromium_items, SIGNAL(notifyMainCheckBox(int)), cookies_chromium_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_chromium_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(cookies_chromium_btn, SIGNAL(spreadStatus(int)), cookies_chromium_items, SLOT(resetSubCheckbox(int))); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + cookies_chromium_btn->move(x, y); + cookies_chromium_btn->show(); + cardlist.append(cookies_chromium_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(cookies_chromium_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(cookies_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(cookies_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + else if(status == "Complete:History") + { +// doing_label->setText(tr("History Scan OK")); + if(trace_firefox_count.length() > 0) + { +// trace_firefox_btn = new CommonCheckBox(0, "://res/cache"); + trace_firefox_btn = new CleanSubGroup(this, "://res/janitor/firefox"); + trace_firefox_btn->setFocusPolicy(Qt::NoFocus); +// trace_firefox_btn->setFixedSize(160, 130); + trace_firefox_btn->hideCustomButton(); + trace_firefox_btn->setStatusTip("history-firefox"); + trace_firefox_btn->setLabelText(tr("Firefox History Count:"), trace_firefox_count.toInt()); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + trace_firefox_btn->move(x, y); + trace_firefox_btn->show(); + cardlist.append(trace_firefox_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(trace_firefox_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_firefox_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(trace_chromium_count.length() > 0) + { + trace_chromium_btn = new CleanSubGroup(this, "://res/janitor/chromium"); + trace_chromium_btn->setFocusPolicy(Qt::NoFocus); + trace_chromium_btn->hideCustomButton(); + trace_chromium_btn->setStatusTip("history-chromium"); + trace_chromium_btn->setLabelText(tr("Chromium History Count:"), trace_chromium_count.toInt()); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + trace_chromium_btn->move(x, y); + trace_chromium_btn->show(); + cardlist.append(trace_chromium_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(trace_chromium_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_chromium_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + + if(trace_system_count.length() > 0) + { + trace_system_btn = new CleanSubGroup(this, "://res/janitor/trace"); + trace_system_btn->setFocusPolicy(Qt::NoFocus); + trace_system_btn->hideCustomButton(); + trace_system_btn->setStatusTip("history-system"); + trace_system_btn->setLabelText(tr("System History Count:"), trace_system_count.toInt()); + + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + trace_system_btn->move(x, y); + trace_system_btn->show(); + cardlist.append(trace_system_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(trace_system_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_system_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_system_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + //kobe + if(!trace_bash_path.isEmpty()) + { + trace_bash_btn = new CleanSubGroup(this, "://res/janitor/trace"); + trace_bash_btn->setFocusPolicy(Qt::NoFocus); + trace_bash_btn->hideCustomButton(); + trace_bash_btn->setStatusTip("history-bash"); + trace_bash_btn->setLabelStringText(tr("Command history size:"), trace_bash_size); + + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + trace_bash_btn->move(x, y); + trace_bash_btn->show(); + cardlist.append(trace_bash_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(trace_bash_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_bash_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_bash_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + + if(trace_x11_list.length() > 0) + { + trace_x11_items = new CleanListWidget(trace_x11_list, this->cur_skin, tr("Debug log Items")); + trace_x11_btn = new CleanSubGroup(this, "://res/janitor/debug"); + trace_x11_btn->setFocusPolicy(Qt::NoFocus); + trace_x11_btn->setStatusTip("x11-history"); + trace_x11_btn->setLabelText(tr("Debug log:"), trace_x11_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(trace_x11_items, SIGNAL(notifyMainCheckBox(int)), trace_x11_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(trace_x11_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(trace_x11_btn, SIGNAL(spreadStatus(int)), trace_x11_items, SLOT(resetSubCheckbox(int))); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + trace_x11_btn->move(x, y); + trace_x11_btn->show(); + cardlist.append(trace_x11_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(trace_x11_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(trace_x11_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(trace_x11_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + } + /*else if(status == "Complete:Packages") + { +// doing_label->setText(tr("Packages Scan OK")); + if(package_unneed_list.length() > 0) + { + package_unneed_items = new CleanListWidget(package_unneed_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// package_unneed_btn = new CommonCheckBox(0, "://res/cache"); + package_unneed_btn = new CleanSubGroup(this, "://res/janitor/package"); + package_unneed_btn->setFocusPolicy(Qt::NoFocus); +// package_unneed_btn->setFixedSize(160, 130); + package_unneed_btn->setStatusTip("package-unneed"); + package_unneed_btn->setLabelText(tr("Package Unneed Count:"),package_unneed_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_unneed_items, SIGNAL(notifyMainCheckBox(int)), package_unneed_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_unneed_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_unneed_btn, SIGNAL(spreadStatus(int)), package_unneed_items, SLOT(resetSubCheckbox(int))); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + package_unneed_btn->move(x, y); + package_unneed_btn->show(); + cardlist.append(package_unneed_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(package_unneed_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(package_unneed_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(package_unneed_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(package_oldkernel_list.length() > 0) + { + package_oldkernel_items = new CleanListWidget(package_oldkernel_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// package_oldkernel_btn = new CommonCheckBox(0, "://res/cache"); + package_oldkernel_btn = new CleanSubGroup(this, "://res/janitor/package"); + package_oldkernel_btn->setFocusPolicy(Qt::NoFocus); +// package_oldkernel_btn->setFixedSize(160, 130); + package_oldkernel_btn->setStatusTip("package-oldkernel"); + package_oldkernel_btn->setLabelText(tr("Package oldkernel Count:"), package_oldkernel_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_oldkernel_items, SIGNAL(notifyMainCheckBox(int)), package_oldkernel_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_oldkernel_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_oldkernel_btn, SIGNAL(spreadStatus(int)), package_oldkernel_items, SLOT(resetSubCheckbox(int))); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + package_oldkernel_btn->move(x, y); + package_oldkernel_btn->show(); + cardlist.append(package_oldkernel_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(package_oldkernel_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(package_oldkernel_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(package_oldkernel_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + if(package_configfile_list.length() > 0) + { + package_configfile_items = new CleanListWidget(package_configfile_list, this->cur_skin, tr("Thumbnails Cache Clean Items")); +// package_configfile_btn = new CommonCheckBox(0, "://res/cache"); + package_configfile_btn = new CleanSubGroup(this, "://res/janitor/package"); + package_configfile_btn->setFocusPolicy(Qt::NoFocus); +// package_configfile_btn->setFixedSize(160, 130); + package_configfile_btn->setStatusTip("package-configfile"); + package_configfile_btn->setLabelText(tr("Package configfile Count:"),package_configfile_list.length()); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_configfile_items, SIGNAL(notifyMainCheckBox(int)), package_configfile_btn, SLOT(resetMainStatus(int))); + //点击自定义按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_configfile_btn, SIGNAL(customButtonClicked()), this, SLOT(showCustomPage())); + //点击总按钮后,根据总按钮的状态去改变子checkbox的状态 + connect(package_configfile_btn, SIGNAL(spreadStatus(int)), package_configfile_items, SLOT(resetSubCheckbox(int))); + + int x = int(this->subCount % this->number_per_row) * (this->itemwidth + this->cardspace) + 30; + int y = int(this->subCount / this->number_per_row) * (this->itemheight + this->cardspace) + 30; + int nowHeight = y + this->itemheight; + if(nowHeight >= ui->scrollAreaWidgetContents->height()) + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->width(), nowHeight); + package_configfile_btn->move(x, y); + package_configfile_btn->show(); + cardlist.append(package_configfile_btn); + subCount += 1; +// if(grid_layout == NULL) +// { +// grid_layout = new QGridLayout(); +// } +// grid_layout->addWidget(package_configfile_btn, subCount/5, subCount%5); +// subCount += 1; +// if(columnIndex < 5) +// { +// grid_layout->addWidget(package_configfile_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } +// else { +// rowIndex += 1; +// columnIndex = 0; +// grid_layout->addWidget(package_configfile_btn, rowIndex, columnIndex); +// columnIndex += 1; +// } + } + }*/ + else if(status == "Complete:All") + { + if(!scanResult) + ui->label->show(); + emit this->sendScanOverStatus(scanResult); + } +} + +void CleanerDetailWidget::showCustomPage() +{ + QObject *object = QObject::sender(); +// CommonCheckBox *checkbox = qobject_cast(object); + CleanSubGroup *checkbox = qobject_cast(object); + QString object_name = checkbox->statusTip(); + if(object_name == "cache-apt") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_apt_items->move(w_x, w_y); + cache_apt_items->exec(); + } + else if(object_name == "cache-software") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_software_items->move(w_x, w_y); + cache_software_items->exec(); + } + else if(object_name == "cache-thumbnails") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_thumbnails_items->move(w_x, w_y); + cache_thumbnails_items->exec(); + } + else if(object_name == "cache-firefox") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_firefox_items->move(w_x, w_y); + cache_firefox_items->exec(); + } + else if(object_name == "cache-chromium") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_chromium_items->move(w_x, w_y); + cache_chromium_items->exec(); + } + else if(object_name == "cookes-firefox") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cookies_firefox_items->move(w_x, w_y); + cookies_firefox_items->exec(); + } + else if(object_name == "cookes-chromium") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cookies_chromium_items->move(w_x, w_y); + cookies_chromium_items->exec(); + } + /*else if(object_name == "package-unneed") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + package_unneed_items->move(w_x, w_y); + package_unneed_items->exec(); + } + else if(object_name == "package-oldkernel") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + package_oldkernel_items->move(w_x, w_y); + package_oldkernel_items->exec(); + } + else if(object_name == "package-configfile") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + package_configfile_items->move(w_x, w_y); + package_configfile_items->exec(); + }*/ + else if(object_name == "x11-history") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + trace_x11_items->move(w_x, w_y); + trace_x11_items->exec(); + } +// else if(object_name == "history-firefox" || object_name == "history-chromium" || object_name == "history-system"|| object_name == "history-bash" ) { +// } +} + +void CleanerDetailWidget::setLanguage() +{ + ui->label->setText(tr("No garbage ")); +// title_label->setText(tr("Cleaning up the system cache")); +// description_label->setText(tr("Deep cleaning up the system cache, to save disk space")); +} + +void CleanerDetailWidget::resetCurrentSkin(QString skin) +{ + this->cur_skin = skin; + + //can remove this code + if(cache_apt_items != NULL) + cache_apt_items->resetTitleSkin(skin); + if(cache_software_items != NULL) + cache_software_items->resetTitleSkin(skin); + if(cache_thumbnails_items != NULL) + cache_thumbnails_items->resetTitleSkin(skin); + if(cache_firefox_items != NULL) + cache_firefox_items->resetTitleSkin(skin); + if(cache_chromium_items != NULL) + cache_chromium_items->resetTitleSkin(skin); + if(cookies_firefox_items != NULL) + cookies_firefox_items->resetTitleSkin(skin); + if(cookies_chromium_items != NULL) + cookies_chromium_items->resetTitleSkin(skin); + /*if(package_unneed_items != NULL) + package_unneed_items->resetTitleSkin(skin); + if(package_oldkernel_items != NULL) + package_oldkernel_items->resetTitleSkin(skin); + if(package_configfile_items != NULL) + package_configfile_items->resetTitleSkin(skin);*/ + if(trace_x11_items != NULL) + trace_x11_items->resetTitleSkin(skin); +} + +void CleanerDetailWidget::receiveCleanSignal() +{ + this->getAllSelectedItems(); + if(argsData.empty()) + { + toolKits->alertMSG(parentWindow->geometry().topLeft().x(), parentWindow->geometry().topLeft().y(), tr("Clean args is empty!")); + } + else + { +// qDebug() << "args is.........." << argsData; + systemproxy->set_user_homedir_qt(); + systemproxy->cleanAllSelectItems(argsData); + } +} + +//void CleanerDetailWidget::receivePolicyKitSignal(bool status) +//{ +// //status = true:ok +// //status = false:cacel +// if(status)//ok +// { +// emit this->showActionAnimaiton(); +// } +//} + +void CleanerDetailWidget::getAllSelectedItems() +{ + argsData.clear(); + QStringList fileTmp; +// QStringList packageTmp; + QStringList firefoxcookieTmp; + QStringList chromiumcookieTmp; + QStringList traceTmp; + + if(cache_apt_btn != NULL && cache_apt_btn->getCheckBoxStatus() != 0) + { + QStringList tmp = cache_apt_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_software_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_thumbnails_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_firefox_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cache_chromium_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_unneed_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_oldkernel_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_configfile_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cookies_firefox_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cookies_chromium_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + argsData.insert("firefox-history", QStringList() << trace_firefox_count); + } + if(trace_chromium_btn != NULL && trace_chromium_btn->getCheckBoxStatus() != 0) + { + argsData.insert("chromium-history", QStringList() << trace_chromium_count); + } + if(trace_system_btn != NULL && trace_system_btn->getCheckBoxStatus() != 0) + { + argsData.insert("system-history", QStringList() << trace_system_count); + } + //kobe + if(trace_bash_btn != NULL && trace_bash_btn->getCheckBoxStatus() != 0) + { + argsData.insert("bash-history", QStringList() << trace_bash_path); + } + if(trace_x11_btn != NULL && trace_x11_btn->getCheckBoxStatus() != 0) + { + QStringList tmp = trace_x11_items->getSelectedItems(); + for(int i = 0; i 0) + argsData.insert("file", fileTmp); +// if(packageTmp.length() > 0) +// argsData.insert("package", packageTmp); + if(firefoxcookieTmp.length() > 0) + argsData.insert("firefox-cookie", firefoxcookieTmp); + if(chromiumcookieTmp.length() > 0) + argsData.insert("chromium-cookie", chromiumcookieTmp); + if(traceTmp.length() > 0) + argsData.insert("x11-history", traceTmp); +} diff --git a/cleaner/cleanerdetailwidget.h b/cleaner/cleanerdetailwidget.h new file mode 100644 index 0000000..1016953 --- /dev/null +++ b/cleaner/cleanerdetailwidget.h @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERDETAILWIDGET_H +#define CLEANERDETAILWIDGET_H + +#include +#include "cleaneritems.h" +#include "cleanlistwidget.h" + +class QLabel; +class QBoxLayout; +class QHBoxLayout; +class QGridLayout; +class SessionDispatcher; +class SystemDispatcher; +class Toolkits; +class MainWindow; +class CleanSubGroup; + + +namespace Ui { +class CleanerDetailWidget; +} + +class CleanerDetailWidget : public QWidget +{ + Q_OBJECT + +public: + explicit CleanerDetailWidget(QWidget *parent = 0, SessionDispatcher *seroxy = 0, SystemDispatcher *syproxy = 0, MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png"); + ~CleanerDetailWidget(); + void setUIData(); + void setLanguage(); + void initConnect(); + void getAllSelectedItems(); + void resetCurrentSkin(QString skin); + +public slots: + void showCustomPage(); + void showReciveData(const QStringList &data); + void receiveCleanSignal(); + void showReciveStatus(const QString &status); + void CleanUIAndData(); +// void receivePolicyKitSignal(bool status); + +signals: + void notifyMainCheckBox(int status); +// void showActionAnimaiton(); + void sendScanOverStatus(bool status); + +private: + void initTitleBar(); + +private: + Ui::CleanerDetailWidget *ui; + MainWindow *parentWindow; + SessionDispatcher *sessionproxy; + SystemDispatcher *systemproxy; + Toolkits *toolKits; + QMap argsData; + CleanListWidget *cache_apt_items ; + CleanSubGroup *cache_apt_btn; + CleanListWidget *cache_software_items ; + CleanSubGroup *cache_software_btn; + CleanListWidget *cache_thumbnails_items ; + CleanSubGroup *cache_thumbnails_btn; + CleanListWidget *cache_firefox_items ; + CleanSubGroup *cache_firefox_btn; + CleanListWidget *cache_chromium_items ; + CleanSubGroup *cache_chromium_btn; + + /*CleanListWidget *package_unneed_items ; + CleanSubGroup *package_unneed_btn; + CleanListWidget *package_oldkernel_items ; + CleanSubGroup *package_oldkernel_btn; + CleanListWidget *package_configfile_items ; + CleanSubGroup *package_configfile_btn;*/ + + CleanListWidget *cookies_firefox_items ; + CleanSubGroup *cookies_firefox_btn; + CleanListWidget *cookies_chromium_items ; + CleanSubGroup *cookies_chromium_btn; + + CleanSubGroup *trace_firefox_btn; + CleanSubGroup *trace_chromium_btn; + CleanSubGroup *trace_system_btn; + CleanSubGroup *trace_bash_btn; + CleanListWidget *trace_x11_items ; + CleanSubGroup *trace_x11_btn; + + QStringList cache_apt_list; + QStringList cache_software_list; + QStringList cache_thumbnails_list; + QStringList cache_firefox_list; + QStringList cache_chromium_list; + /*QStringList package_unneed_list; + QStringList package_oldkernel_list; + QStringList package_configfile_list;*/ + QStringList cookies_firefox_list; + QStringList cookies_chromium_list; + QString trace_firefox_count; + QString trace_chromium_count; + QString trace_system_count; + QString trace_bash_size; + QString trace_bash_path; + QStringList trace_x11_list; + + QGridLayout *grid_layout; +// int rowIndex; +// int columnIndex; + int subCount; + bool scanResult; + QString cur_skin; + + int number_per_row; + int itemwidth; + int itemheight; + int cardspace; + QList cardlist; +// QList page_list; +}; + +#endif // CLEANERDETAILWIDGET_H diff --git a/cleaner/cleanerdetailwidget.ui b/cleaner/cleanerdetailwidget.ui new file mode 100644 index 0000000..27672b7 --- /dev/null +++ b/cleaner/cleanerdetailwidget.ui @@ -0,0 +1,64 @@ + + + CleanerDetailWidget + + + + 0 + 0 + 900 + 403 + + + + Form + + + 1.000000000000000 + + + + + 0 + 0 + 900 + 403 + + + + true + + + true + + + + + 0 + 0 + 898 + 401 + + + + + + 10 + 160 + 881 + 20 + + + + + + + Qt::AlignCenter + + + + + + + + diff --git a/cleaner/cleaneritems-new.cpp b/cleaner/cleaneritems-new.cpp new file mode 100644 index 0000000..804c358 --- /dev/null +++ b/cleaner/cleaneritems-new.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleaneritems.h" +#include "mainwindow.h" +#include + +//CleanerItems::CleanerItems(QStringList &arglist, QStringList &statuslist, int height, const QString title_text, QWidget *parent) +// : QWidget(parent),titleName(title_text)/*, widgetHeight(height)*/ + +CleanerItems::CleanerItems(QStringList &arglist, QStringList &statuslist, QString skin, int height, const QString title_text, QWidget *parent) + :QWidget(parent),titleName(title_text) +{ + setWindowFlags(Qt::FramelessWindowHint); + this->setFixedSize(900, 403); +// this->setObjectName("transparentWidget"); +// this->setWindowFlags(Qt::FramelessWindowHint); + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + QVBoxLayout *button_layout = new QVBoxLayout; + int count = arglist.count(); + // QSignalMapper *signal_mapper = new QSignalMapper(this); + for(int i=0; isetFocusPolicy(Qt::NoFocus); + checkbox->setCheckState(Qt::Checked); + checkbox->setStatusTip(statuslist.at(i)); + checkbox_list.append(checkbox); +// connect(checkbox, SIGNAL(clicked()), signal_mapper, SLOT(map())); + connect(checkbox, SIGNAL(clicked()), this, SLOT(scanAllSubCheckbox())); +// signal_mapper->setMapping(checkbox, QString::number(i, 10)); + button_layout->addWidget(checkbox); + } + button_layout->setSpacing(15); + button_layout->setMargin(0); + button_layout->setContentsMargins(0, 10, 0, 0); +// connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchPageIndex(QString))); +// setLayout(button_layout); + + okBtn = new QPushButton(); + okBtn->setFixedSize(91, 25); + okBtn->setObjectName("blackButton"); + okBtn->setFocusPolicy(Qt::NoFocus); + QHBoxLayout *btn_layout = new QHBoxLayout(); + btn_layout->addStretch(); + btn_layout->addWidget(okBtn); + btn_layout->setMargin(0); + btn_layout->setContentsMargins(0, 0, 15, 10); + + group_box = new QGroupBox(); + group_box->setStyleSheet("QGroupBox{border: 1px solid #e0e0e0;border-radius: 2px;margin-top: 15px;font-size:14px;}QGroupBox:title{subcontrol-origin: margin;subcontrol-position: top left;padding: 6px 3px;color: #00609a;font-family: 方正黑体_GBK;font-weight:bold;}"); + group_box->setTitle(titleName); + QFont group_box_font = group_box->font(); + group_box_font.setBold(true); + group_box->setFont(group_box_font); + group_box->setFixedWidth(380); + group_box->setLayout(button_layout); + group_box->setContentsMargins(10, 10, 10, 10); + + QHBoxLayout *group_layout = new QHBoxLayout(); + group_layout->addWidget(group_box); + group_layout->setMargin(0); + group_layout->setContentsMargins(10, 10, 10, 0); + + QVBoxLayout *main_layout = new QVBoxLayout(); +// main_layout->addWidget(title_bar); + main_layout->addLayout(group_layout); +// main_layout->addWidget(group_box); + main_layout->addStretch(); + main_layout->addLayout(btn_layout); + main_layout->setSpacing(0); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + setLayout(main_layout); + + this->initConnect(); + this->setLanguage(); +} + +CleanerItems::~CleanerItems() +{ + +} + +void CleanerItems::initConnect() +{ +// connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); + connect(okBtn,SIGNAL(clicked()), this, SLOT(onCloseButtonClicked())); +} + +void CleanerItems::onCloseButtonClicked() +{ + emit this->sendoksignal(); + this->close(); +} + +//void CleanerItems::initTitleBar(QString skin) +//{ +// title_bar->setTitleWidth(410); +// title_bar->setTitleName(titleName); +//// title_bar->setTitleBackgound(":/background/res/skin/1.png"); +// title_bar->setTitleBackgound(skin); +//} + +//void CleanerItems::resetTitleSkin(QString skin) +//{ +// title_bar->resetBackground(skin); +//} + +int CleanerItems::getItemCount() +{ + return checkbox_list.count(); +} + +QStringList CleanerItems::getSelectedItems() +{ + QStringList text_list; + int count = checkbox_list.count(); + for(int i=0; iisChecked()) { +// text_list.append(checkbox->text()); + text_list.append(checkbox->statusTip()); + } + } + return text_list; +} + +void CleanerItems::setLanguage() +{ + okBtn->setText(tr("OK")); +} + +void CleanerItems::scanAllSubCheckbox() { + int count = checkbox_list.count(); + int m = 0; + for(int i=0; iisChecked()) { + m +=1; + } + } + if (m == 0) { + emit this->notifyMainCheckBox(0); + } + else if (m == count) { + emit this->notifyMainCheckBox(2); + } + else { + emit this->notifyMainCheckBox(1); + } +} + +void CleanerItems::resetSubCheckbox(int status) { + if(status == 0) { + for(int i=0; isetChecked(false); + } + } + else if(status == 2) { + for(int i=0; isetChecked(true); + } + } +} diff --git a/cleaner/cleaneritems-new.h b/cleaner/cleaneritems-new.h new file mode 100644 index 0000000..dc9acf4 --- /dev/null +++ b/cleaner/cleaneritems-new.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERITEMS_H +#define CLEANERITEMS_H + +#include +#include + +class MainWindow; +class QCheckBox; +class QGroupBox; + +class CleanerItems : public QWidget +{ + Q_OBJECT +public: + explicit CleanerItems(QStringList &arglist, QStringList &statuslist, QString skin = ":/background/res/skin/1.png", int height = 0, const QString title_text = "UbuntuKylin", QWidget *parent = 0); + ~CleanerItems(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void setLanguage(); + void initConnect(); + int getItemCount(); + QStringList getSelectedItems(); + +public slots: + void resetSubCheckbox(int status); + void scanAllSubCheckbox(); + void onCloseButtonClicked(); + +signals: + void notifyMainCheckBox(int status); + void sendoksignal(); + +private: + QList checkbox_list; + MainWindow *p_mainwindow; + QString titleName; + QPushButton *okBtn; + QGroupBox *group_box; +}; + +#endif // CLEANERITEMS_H + + + + diff --git a/cleaner/cleaneritems-org.cpp b/cleaner/cleaneritems-org.cpp new file mode 100644 index 0000000..7621aa8 --- /dev/null +++ b/cleaner/cleaneritems-org.cpp @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleaneritems.h" +#include "mainwindow.h" +#include + +//CleanerItems::CleanerItems(QStringList &arglist, QStringList &statuslist, int height, const QString title_text, QWidget *parent) +// : QWidget(parent),titleName(title_text)/*, widgetHeight(height)*/ + +CleanerItems::CleanerItems(QStringList &arglist, QStringList &statuslist, QString skin, int height, const QString title_text, QDialog *parent) + :QDialog(parent),titleName(title_text) +{ + setWindowFlags(Qt::FramelessWindowHint); + this->setStyleSheet("QDialog{border: 1px solid gray;border-radius:2px}");//设定边框宽度以及颜色 + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + + this->setFixedSize(410, height); +// this->setObjectName("transparentWidget"); +// this->setWindowFlags(Qt::FramelessWindowHint); + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + title_bar = new KylinTitleBar(); + initTitleBar(skin); + + QVBoxLayout *button_layout = new QVBoxLayout; + int count = arglist.count(); + // QSignalMapper *signal_mapper = new QSignalMapper(this); + for(int i=0; isetFocusPolicy(Qt::NoFocus); + checkbox->setCheckState(Qt::Checked); + checkbox->setStatusTip(statuslist.at(i)); + checkbox_list.append(checkbox); +// connect(checkbox, SIGNAL(clicked()), signal_mapper, SLOT(map())); + connect(checkbox, SIGNAL(clicked()), this, SLOT(scanAllSubCheckbox())); +// signal_mapper->setMapping(checkbox, QString::number(i, 10)); + button_layout->addWidget(checkbox); + } + button_layout->setSpacing(15); + button_layout->setMargin(0); + button_layout->setContentsMargins(0, 10, 0, 0); +// connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchPageIndex(QString))); +// setLayout(button_layout); + + okBtn = new QPushButton(); + okBtn->setFixedSize(91, 25); + okBtn->setObjectName("blackButton"); + okBtn->setFocusPolicy(Qt::NoFocus); + QHBoxLayout *btn_layout = new QHBoxLayout(); + btn_layout->addStretch(); + btn_layout->addWidget(okBtn); + btn_layout->setMargin(0); + btn_layout->setContentsMargins(0, 0, 15, 10); + + group_box = new QGroupBox(); + group_box->setStyleSheet("QGroupBox{border: 1px solid #e0e0e0;border-radius: 2px;margin-top: 15px;font-size:14px;}QGroupBox:title{subcontrol-origin: margin;subcontrol-position: top left;padding: 6px 3px;color: #00609a;font-family: 方正黑体_GBK;font-weight:bold;}"); + group_box->setTitle(titleName); + QFont group_box_font = group_box->font(); + group_box_font.setBold(true); + group_box->setFont(group_box_font); + group_box->setFixedWidth(380); + group_box->setLayout(button_layout); + group_box->setContentsMargins(10, 10, 10, 10); + + QHBoxLayout *group_layout = new QHBoxLayout(); + group_layout->addWidget(group_box); + group_layout->setMargin(0); + group_layout->setContentsMargins(10, 10, 10, 0); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(title_bar); + main_layout->addLayout(group_layout); +// main_layout->addWidget(group_box); + main_layout->addStretch(); + main_layout->addLayout(btn_layout); + main_layout->setSpacing(0); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + setLayout(main_layout); + + this->initConnect(); + this->setLanguage(); +} + +CleanerItems::~CleanerItems() +{ + +} + +void CleanerItems::initConnect() +{ + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); + connect(okBtn,SIGNAL(clicked()), this, SLOT(onCloseButtonClicked())); +} + +void CleanerItems::onCloseButtonClicked() +{ + this->close(); +} + +void CleanerItems::initTitleBar(QString skin) +{ + title_bar->setTitleWidth(410); + title_bar->setTitleName(titleName); +// title_bar->setTitleBackgound(":/background/res/skin/1.png"); + title_bar->setTitleBackgound(skin); +} + +void CleanerItems::resetTitleSkin(QString skin) +{ + title_bar->resetBackground(skin); +} + +int CleanerItems::getItemCount() +{ + return checkbox_list.count(); +} + +QStringList CleanerItems::getSelectedItems() +{ + QStringList text_list; + int count = checkbox_list.count(); + for(int i=0; iisChecked()) { +// text_list.append(checkbox->text()); + text_list.append(checkbox->statusTip()); + } + } + return text_list; +} + +void CleanerItems::setLanguage() +{ + okBtn->setText(tr("OK")); +} + +void CleanerItems::scanAllSubCheckbox() { + int count = checkbox_list.count(); + int m = 0; + for(int i=0; iisChecked()) { + m +=1; + } + } + if (m == 0) { + emit this->notifyMainCheckBox(0); + } + else if (m == count) { + emit this->notifyMainCheckBox(2); + } + else { + emit this->notifyMainCheckBox(1); + } +} + +void CleanerItems::resetSubCheckbox(int status) { + if(status == 0) { + for(int i=0; isetChecked(false); + } + } + else if(status == 2) { + for(int i=0; isetChecked(true); + } + } +} diff --git a/cleaner/cleaneritems-org.h b/cleaner/cleaneritems-org.h new file mode 100644 index 0000000..70b3e0a --- /dev/null +++ b/cleaner/cleaneritems-org.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERITEMS_H +#define CLEANERITEMS_H + +#include +#include +#include "../component/kylintitlebar.h" + +class MainWindow; +class QCheckBox; +class QGroupBox; + +//class CleanerItems : public QWidget +class CleanerItems : public QDialog +{ + Q_OBJECT +public: +// explicit CleanerItems(QStringList &arglist, QStringList &statuslist, int height = 0, const QString title_text = "UbuntuKylin", QWidget *parent = 0); + explicit CleanerItems(QStringList &arglist, QStringList &statuslist, QString skin = ":/background/res/skin/1.png", int height = 0, const QString title_text = "UbuntuKylin", QDialog *parent = 0); + ~CleanerItems(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void setLanguage(); + void initConnect(); + int getItemCount(); + QStringList getSelectedItems(); + void resetTitleSkin(QString skin); + +public slots: + void resetSubCheckbox(int status); + void scanAllSubCheckbox(); + void onCloseButtonClicked(); + +private: + void initTitleBar(QString skin); + +signals: + void notifyMainCheckBox(int status); + +private: + QList checkbox_list; + MainWindow *p_mainwindow; + KylinTitleBar *title_bar; + QString titleName; + QPushButton *okBtn; + QGroupBox *group_box; + QString cur_skin; +}; + +#endif // CLEANERITEMS_H + + + + diff --git a/cleaner/cleaneritems.cpp b/cleaner/cleaneritems.cpp new file mode 100644 index 0000000..4957d3b --- /dev/null +++ b/cleaner/cleaneritems.cpp @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleaneritems.h" +#include "mainwindow.h" +#include + +//CleanerItems::CleanerItems(QStringList &arglist, QStringList &statuslist, int height, const QString title_text, QWidget *parent) +// : QWidget(parent),titleName(title_text)/*, widgetHeight(height)*/ + +CleanerItems::CleanerItems(QStringList &arglist, QStringList &statuslist, QString skin, int height, const QString title_text, QDialog *parent) + :QDialog(parent),titleName(title_text) +{ + setWindowFlags(Qt::FramelessWindowHint); + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + + this->setFixedSize(410, height); +// this->setObjectName("transparentWidget"); +// this->setWindowFlags(Qt::FramelessWindowHint); + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + title_bar = new KylinTitleBar(); + initTitleBar(skin); + + QVBoxLayout *button_layout = new QVBoxLayout; + int count = arglist.count(); + // QSignalMapper *signal_mapper = new QSignalMapper(this); + for(int i=0; isetFocusPolicy(Qt::NoFocus); + checkbox->setCheckState(Qt::Checked); + checkbox->setStatusTip(statuslist.at(i)); + checkbox_list.append(checkbox); +// connect(checkbox, SIGNAL(clicked()), signal_mapper, SLOT(map())); + connect(checkbox, SIGNAL(clicked()), this, SLOT(scanAllSubCheckbox())); +// signal_mapper->setMapping(checkbox, QString::number(i, 10)); + button_layout->addWidget(checkbox); + } + button_layout->setSpacing(15); + button_layout->setMargin(0); + button_layout->setContentsMargins(0, 10, 0, 0); +// connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchPageIndex(QString))); +// setLayout(button_layout); + + okBtn = new QPushButton(); + okBtn->setFixedSize(91, 25); + okBtn->setObjectName("blackButton"); + okBtn->setFocusPolicy(Qt::NoFocus); + QHBoxLayout *btn_layout = new QHBoxLayout(); + btn_layout->addStretch(); + btn_layout->addWidget(okBtn); + btn_layout->setMargin(0); + btn_layout->setContentsMargins(0, 0, 15, 10); + + group_box = new QGroupBox(); + group_box->setStyleSheet("QGroupBox{border: 1px solid #e0e0e0;border-radius: 2px;margin-top: 15px;font-size:14px;}QGroupBox:title{subcontrol-origin: margin;subcontrol-position: top left;padding: 6px 3px;color: #00609a;font-family: 方正黑体_GBK;font-weight:bold;}"); + group_box->setTitle(titleName); + QFont group_box_font = group_box->font(); + group_box_font.setBold(true); + group_box->setFont(group_box_font); + group_box->setFixedWidth(380); + group_box->setLayout(button_layout); + group_box->setContentsMargins(10, 10, 10, 10); + + QHBoxLayout *group_layout = new QHBoxLayout(); + group_layout->addWidget(group_box); + group_layout->setMargin(0); + group_layout->setContentsMargins(10, 10, 10, 0); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(title_bar); + main_layout->addLayout(group_layout); +// main_layout->addWidget(group_box); + main_layout->addStretch(); + main_layout->addLayout(btn_layout); + main_layout->setSpacing(0); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + setLayout(main_layout); + + this->initConnect(); + this->setLanguage(); +} + +CleanerItems::~CleanerItems() +{ + for(int i=0; iclose(); +} + +void CleanerItems::initTitleBar(QString skin) +{ + title_bar->setTitleWidth(410); + title_bar->setTitleName(titleName); +// title_bar->setTitleBackgound(":/background/res/skin/1.png"); + title_bar->setTitleBackgound(skin); +} + +void CleanerItems::resetTitleSkin(QString skin) +{ + title_bar->resetBackground(skin); +} + +int CleanerItems::getItemCount() +{ + return checkbox_list.count(); +} + +QStringList CleanerItems::getSelectedItems() +{ + QStringList text_list; + int count = checkbox_list.count(); + for(int i=0; iisChecked()) { +// text_list.append(checkbox->text()); + text_list.append(checkbox->statusTip()); + } + } + return text_list; +} + +void CleanerItems::setLanguage() +{ + okBtn->setText(tr("OK")); +} + +void CleanerItems::scanAllSubCheckbox() { + int count = checkbox_list.count(); + int m = 0; + for(int i=0; iisChecked()) { + m +=1; + } + } + if (m == 0) { + emit this->notifyMainCheckBox(0); + } + else if (m == count) { + emit this->notifyMainCheckBox(2); + } + else { + emit this->notifyMainCheckBox(1); + } +} + +void CleanerItems::resetSubCheckbox(int status) { + if(status == 0) { + for(int i=0; isetChecked(false); + } + } + else if(status == 2) { + for(int i=0; isetChecked(true); + } + } +} diff --git a/cleaner/cleaneritems.h b/cleaner/cleaneritems.h new file mode 100644 index 0000000..6f24f02 --- /dev/null +++ b/cleaner/cleaneritems.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERITEMS_H +#define CLEANERITEMS_H + +#include +#include +#include "../component/kylintitlebar.h" + +class MainWindow; +class QCheckBox; +class QGroupBox; + +//class CleanerItems : public QWidget +class CleanerItems : public QDialog +{ + Q_OBJECT +public: +// explicit CleanerItems(QStringList &arglist, QStringList &statuslist, int height = 0, const QString title_text = "UbuntuKylin", QWidget *parent = 0); + explicit CleanerItems(QStringList &arglist, QStringList &statuslist, QString skin = ":/background/res/skin/1.png", int height = 0, const QString title_text = "UbuntuKylin", QDialog *parent = 0); + ~CleanerItems(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void setLanguage(); + void initConnect(); + int getItemCount(); + QStringList getSelectedItems(); + void resetTitleSkin(QString skin); + +public slots: + void resetSubCheckbox(int status); + void scanAllSubCheckbox(); + void onCloseButtonClicked(); + +private: + void initTitleBar(QString skin); + +signals: + void notifyMainCheckBox(int status); + +private: + QList checkbox_list; + MainWindow *p_mainwindow; + KylinTitleBar *title_bar; + QString titleName; + QPushButton *okBtn; + QGroupBox *group_box; +}; + +#endif // CLEANERITEMS_H + + + + diff --git a/cleaner/cleanermainwidget-new.cpp b/cleaner/cleanermainwidget-new.cpp new file mode 100644 index 0000000..954fe24 --- /dev/null +++ b/cleaner/cleanermainwidget-new.cpp @@ -0,0 +1,406 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleanermainwidget.h" +#include +#include "../mainui/mainwindow.h" +#include "../component/cleangroup.h" +#include +#include + +CleanerMainWidget::CleanerMainWidget(QWidget *parent, SessionDispatcher *seroxy, MainWindow *window, Toolkits *kits, QString skin) + : QWidget(parent), sessionproxy(seroxy), parentWindow(window), toolKits(kits) +{ + this->setFixedSize(900, 403); + this->setObjectName("transparentWidget"); + + scanWidgets = new QStackedWidget(this); +// scanWidgets->setGeometry(rect()); +// scanWidgets->lower(); + scanWidgets->setGeometry(QRect(900, 0, 900, 403)); +// this->setAutoFillBackground(true); +// QPalette palette; +// palette.setBrush(QPalette::Window, QBrush(Qt::white)); +// this->setPalette(palette); + + baseWidget = new QWidget(this); + baseWidget->setGeometry(rect()); +// baseWidget->setAutoFillBackground(true); +// QPalette palette; +// palette.setBrush(QPalette::Window, QBrush(Qt::blue)); +// baseWidget->setPalette(palette); + + + tip_label = new QLabel(baseWidget); + tip_label->setObjectName("tipLabel"); + tip_label->setGeometry(QRect(30, 10, 800, 30)); + QStringList cache_list, status_list; + cache_list << tr("Cleanup Package Cache") << tr("Cleanup Software Center Cache") << tr("Cleanup Thumbnails Cache") << tr("Cleanup FireFox Cache") << tr("Cleanup Chromium Cache"); + status_list << "apt" << "software-center" << "thumbnails" << "firefox" << "chromium"; + cache_items = new CleanerItems(cache_list, status_list, skin, 280, tr("Cache Items")); + connect(cache_items, SIGNAL(sendoksignal()), this, SLOT(showCleanMainPage())); + cache_btn = new CleanGroup(baseWidget, "://res/cache"); + cache_btn->setGeometry(QRect(10, 50, 260, 150)); + cache_btn->setStatusTip("cache"); + cache_btn->setLabelText(tr("System Cache"), tr("Cleanup cache of system, software-center, thumbnails and browser"));//系统缓存垃圾 清除包、软件中心、缩略图和浏览器缓存 + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_items, SIGNAL(notifyMainCheckBox(int)), cache_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(cache_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + + QStringList package_list; + package_list << tr("Uninstall unnecessary procedures") << tr("Uninstall old kernel packages") << tr("Cleanup software configfile"); + status_list.clear(); + status_list << "unneed" << "oldkernel" << "configfile"; + package_items = new CleanerItems(package_list, status_list, skin, 200, tr("Package Items")); + connect(package_items, SIGNAL(sendoksignal()), this, SLOT(showCleanMainPage())); + package_btn = new CleanGroup(baseWidget, "://res/cache"); + package_btn->setGeometry(QRect(310, 50, 260, 150)); + package_btn->setLabelText(tr("Packages and configfile"), tr("Cleaning up the software that installed by other software bundled, old kernel packages and configfile, to improve system performance"));//包垃圾 清除不必要的程序、旧内核包、配置文件 + package_btn->setStatusTip("package"); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_items, SIGNAL(notifyMainCheckBox(int)), package_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(package_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + + QStringList cookies_list; + cookies_list << tr("Cleanup the Cookies saving in Firefox") << tr("Cleanup the Cookies saving in Chromium"); + status_list.clear(); + status_list << "firefox" << "chromium"; + cookies_items = new CleanerItems(cookies_list, status_list, skin, 170, tr("Cookies Items")); + connect(cookies_items, SIGNAL(sendoksignal()), this, SLOT(showCleanMainPage())); + cookies_btn = new CleanGroup(baseWidget, "://res/cache"); + cookies_btn->setGeometry(QRect(610, 50, 260, 150)); + cookies_btn->setLabelText(tr("Cookies"), tr("Clean up user login information, support Firefox and Chromium browser"));//清除上网、游戏、购物等记录 + cookies_btn->setStatusTip("cookies"); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cookies_items, SIGNAL(notifyMainCheckBox(int)), cookies_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(cookies_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + + QStringList trace_list; + trace_list << tr("Clean up the Firefox Internet records") << tr("Clean up the Chromium Internet records") << tr("Clean up the recently opened documents records") << tr("Delete the command history") << tr("Delete the debug logs"); + status_list.clear(); + status_list << "firefox" << "chromium" << "system" << "bash" << "X11"; + trace_items = new CleanerItems(trace_list, status_list, skin, 280, tr("Trace Items")); + connect(trace_items, SIGNAL(sendoksignal()), this, SLOT(showCleanMainPage())); + trace_btn = new CleanGroup(baseWidget, "://res/cache"); + trace_btn->setGeometry(QRect(10, 240, 260, 150)); + trace_btn->setLabelText(tr("History trace"), tr("Cleaning the internet and opened documents recently records"));//使用痕迹 清除浏览器和系统使用痕迹 + trace_btn->setStatusTip("trace"); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(trace_items, SIGNAL(notifyMainCheckBox(int)), trace_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(trace_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + +// QHBoxLayout *tip_layout = new QHBoxLayout(); +// tip_layout->addWidget(tip_label); +// tip_layout->addStretch(); +// tip_layout->setMargin(0); +// tip_layout->setContentsMargins(38,20,72,0); + +// QHBoxLayout *layout1 = new QHBoxLayout; +// layout1->addWidget(cache_btn); +// layout1->addWidget(package_btn); +// layout1->addWidget(cookies_btn); +// layout1->setMargin(0); +// layout1->setContentsMargins(0,0,0,0); + +// QHBoxLayout *layout2 = new QHBoxLayout; +// layout2->addWidget(trace_btn); +// layout2->addStretch(); +// layout1->setMargin(0); +// layout2->setContentsMargins(20,0,0,0); + +// QVBoxLayout *layoutbox = new QVBoxLayout; +// layoutbox->addLayout(layout1); +// layoutbox->addLayout(layout2); +// layoutbox->setSpacing(20); +// layoutbox->setMargin(0); +// layoutbox->setContentsMargins(0,0,0,0); + +// QVBoxLayout *main_layout = new QVBoxLayout; +// main_layout->addLayout(tip_layout); +// main_layout->addLayout(layoutbox); +// main_layout->addStretch(); +// main_layout->setSpacing(30); +// main_layout->setMargin(0); +// main_layout->setContentsMargins(0,0,0,0); + +// setLayout(main_layout); + this->setLanguage(); + + + scanWidgets->addWidget(cache_items); + scanWidgets->addWidget(package_items); + scanWidgets->addWidget(cookies_items); + scanWidgets->addWidget(trace_items); + + this->initAnimation(); +} + +CleanerMainWidget::~CleanerMainWidget() +{ + +} + +void CleanerMainWidget::initAnimation() +{ + QPropertyAnimation *m_upMainAnimation = new QPropertyAnimation(baseWidget, "pos"); + m_upMainAnimation->setDuration(200); + m_upMainAnimation->setStartValue(QPoint(0, 0)); + m_upMainAnimation->setEndValue(QPoint(-900, 0)); + + QPropertyAnimation *m_downMainAnimation = new QPropertyAnimation(scanWidgets, "pos"); + m_downMainAnimation->setDuration(200); + m_downMainAnimation->setStartValue(QPoint(900, 0)); + m_downMainAnimation->setEndValue(QPoint(0, 0)); + +// QPropertyAnimation *m_toTrans = new QPropertyAnimation(m_grayWidget, "opacity"); +// m_toTrans->setDuration(200); +// m_toTrans->setStartValue(1); +// m_toTrans->setEndValue(0); + + m_upGroup = new QParallelAnimationGroup; + m_upGroup->addAnimation(m_upMainAnimation); + m_upGroup->addAnimation(m_downMainAnimation); +// m_upGroup->addAnimation(m_toTrans); + + QPropertyAnimation *m_upGarAnimation = new QPropertyAnimation(baseWidget, "pos"); + m_upGarAnimation->setDuration(200); + m_upGarAnimation->setStartValue(QPoint(-900, 0)); + m_upGarAnimation->setEndValue(QPoint(0, 0)); + + QPropertyAnimation *m_downGarAnimation = new QPropertyAnimation(scanWidgets, "pos"); + m_downGarAnimation->setDuration(200); + m_downGarAnimation->setStartValue(QPoint(0, 0)); + m_downGarAnimation->setEndValue(QPoint(900, 0)); + +// QPropertyAnimation *m_toGray = new QPropertyAnimation(m_grayWidget, "opacity"); +// m_toGray->setDuration(200); +// m_toGray->setStartValue(0); +// m_toGray->setEndValue(1); + + m_downGroup = new QParallelAnimationGroup; + m_downGroup->addAnimation(m_upGarAnimation); + m_downGroup->addAnimation(m_downGarAnimation); +// m_downGroup->addAnimation(m_toGray); + + connect(m_upGroup, SIGNAL(finished()), SLOT(onUpGroupFinished())); +} + +void CleanerMainWidget::setLanguage() +{ + tip_label->setText(tr("Please select the items you want to clean")); +} + +void CleanerMainWidget::resetCurrentSkin(QString skin) +{ +// if(cache_items != NULL) +// cache_items->resetTitleSkin(skin); +// if(trace_items != NULL) +// trace_items->resetTitleSkin(skin); +// if(package_items != NULL) +// package_items->resetTitleSkin(skin); +// if(cookies_items != NULL) +// cookies_items->resetTitleSkin(skin); +} + +void CleanerMainWidget::showCleanMainPage() +{ + m_downGroup->start(); + qDebug() << "back to main....."; +} + +void CleanerMainWidget::onUpGroupFinished() +{ + scanWidgets->currentWidget()->show(); +} + +void CleanerMainWidget::receiveScanSignal() +{ + this->getAllScanSelectedItems(); + if(argsMap.empty()) + { + toolKits->alertMSG(parentWindow->geometry().topLeft().x(), parentWindow->geometry().topLeft().y(), tr("Scan args is empty!")); + } + else + { + qDebug() << "args is.........." << argsMap; +// emit this->showActionAnimaiton(); +// sessionproxy->scanSystemCleanerItems(argsMap); + } +} + +void CleanerMainWidget::getAllScanSelectedItems() +{ + argsMap.clear(); + QStringList cacheTmp; + QStringList packageTmp; + QStringList cookieTmp; + QStringList historyTmp; + + if(cache_btn != NULL && cache_btn->getCheckBoxStatus() != 0) + { + QStringList tmp = cache_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cookies_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = trace_items->getSelectedItems(); + for(int i = 0; i 0) + argsMap.insert("Cache", cacheTmp); + if(packageTmp.length() > 0) + argsMap.insert("Packages", packageTmp); + if(cookieTmp.length() > 0) + argsMap.insert("Cookies", cookieTmp); + if(historyTmp.length() > 0) + argsMap.insert("History", historyTmp); +} + +void CleanerMainWidget::onButtonClicked() +{ + QObject *object = QObject::sender(); +// KylinCheckBox *checkbox = qobject_cast(object); + CleanGroup *checkbox = qobject_cast(object); + QString object_name = checkbox->statusTip(); + if(object_name == "cache") + { + scanWidgets->setCurrentWidget(cache_items); + m_upGroup->start(); +// if(cache_items->isHidden()) { +// int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); +// int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); +// cache_items->move(w_x, w_y); +// cache_items->show(); +// } +// else +// { +// cache_items->hide(); +// } +// if(!package_items->isHidden()) { +// package_items->hide(); +// } +// if(!cookies_items->isHidden()) { +// cookies_items->hide(); +// } +// if(!trace_items->isHidden()) { +// trace_items->hide(); +// } + } + else if(object_name == "package") + { + scanWidgets->setCurrentWidget(package_items); + m_upGroup->start(); +// if(package_items->isHidden()) { +// int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); +// int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (200 / 2); +// package_items->move(w_x, w_y); +// package_items->show(); +// } +// else +// { +// package_items->hide(); +// } +// if(!cache_items->isHidden()) { +// cache_items->hide(); +// } +// if(!cookies_items->isHidden()) { +// cookies_items->hide(); +// } +// if(!trace_items->isHidden()) { +// trace_items->hide(); +// } + } + if(object_name == "cookies") + { + scanWidgets->setCurrentWidget(cookies_items); + m_upGroup->start(); +// if(cookies_items->isHidden()) { +// int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); +// int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (170 / 2); +// cookies_items->move(w_x, w_y); +// cookies_items->show(); +// } +// else +// { +// cookies_items->hide(); +// } +// if(!cache_items->isHidden()) { +// cache_items->hide(); +// } +// if(!package_items->isHidden()) { +// package_items->hide(); +// } +// if(!trace_items->isHidden()) { +// trace_items->hide(); +// } + } + if(object_name == "trace") + { + scanWidgets->setCurrentWidget(trace_items); + m_upGroup->start(); +// if(trace_items->isHidden()) { +// int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); +// int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (200 / 2); +// trace_items->move(w_x, w_y); +// trace_items->show(); +// } +// else +// { +// trace_items->hide(); +// } +// if(!cache_items->isHidden()) { +// cache_items->hide(); +// } +// if(!package_items->isHidden()) { +// package_items->hide(); +// } +// if(!cookies_items->isHidden()) { +// cookies_items->hide(); +// } + } +} diff --git a/cleaner/cleanermainwidget-new.h b/cleaner/cleanermainwidget-new.h new file mode 100644 index 0000000..ea94999 --- /dev/null +++ b/cleaner/cleanermainwidget-new.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERMAINWIDGET_H +#define CLEANERMAINWIDGET_H + +#include +#include +#include +#include +#include "cleaneritems.h" + +class MainWindow; +class CleanGroup; +class SessionDispatcher; +class Toolkits; +class QParallelAnimationGroup; + +class CleanerMainWidget : public QWidget +{ + Q_OBJECT +public: + explicit CleanerMainWidget(QWidget *parent = 0, SessionDispatcher *seroxy = 0, MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png"); + ~CleanerMainWidget(); + void setLanguage(); + void getAllScanSelectedItems(); + void resetCurrentSkin(QString skin); + void initAnimation(); + +public slots: + void onButtonClicked(); + void receiveScanSignal(); + void showCleanMainPage(); + void onUpGroupFinished(); + +signals: + void showActionAnimaiton(); + +private: + MainWindow *parentWindow; + QLabel *tip_label; + QWidget *baseWidget; + CleanGroup *cache_btn; + CleanerItems *cache_items; + CleanGroup *package_btn; + CleanerItems *package_items; + CleanGroup *cookies_btn; + CleanerItems *cookies_items; + CleanGroup *trace_btn; + CleanerItems *trace_items; + + QMap argsMap; + SessionDispatcher *sessionproxy; + Toolkits *toolKits; + QStackedWidget *scanWidgets; + QParallelAnimationGroup *m_upGroup; + QParallelAnimationGroup *m_downGroup; +}; + +#endif // CLEANERMAINWIDGET_H + + + + diff --git a/cleaner/cleanermainwidget-org.cpp b/cleaner/cleanermainwidget-org.cpp new file mode 100644 index 0000000..374c901 --- /dev/null +++ b/cleaner/cleanermainwidget-org.cpp @@ -0,0 +1,341 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleanermainwidget.h" +#include +#include "../mainui/mainwindow.h" +#include "../component/cleangroup.h" + +CleanerMainWidget::CleanerMainWidget(QWidget *parent, SessionDispatcher *seroxy, MainWindow *window, Toolkits *kits, QString skin) + : QWidget(parent), sessionproxy(seroxy), parentWindow(window), toolKits(kits) +{ + this->setFixedSize(900, 403); + this->setObjectName("transparentWidget"); +// this->setAutoFillBackground(true); +// QPalette palette; +// palette.setBrush(QPalette::Window, QBrush(Qt::white)); +// this->setPalette(palette); + + tip_label = new QLabel(); + tip_label->setObjectName("tipLabel"); + QStringList cache_list, status_list; + cache_list << tr("Cleanup Package Cache") << tr("Cleanup Software Center Cache") << tr("Cleanup Thumbnails Cache") << tr("Cleanup FireFox Cache") << tr("Cleanup Chromium Cache"); + status_list << "apt" << "software-center" << "thumbnails" << "firefox" << "chromium"; + cache_items = new CleanerItems(cache_list, status_list, skin, 280, tr("Cache Items")); +// cache_btn = new KylinCheckBox(0, "://res/cache.png"); + cache_btn = new CleanGroup(0, "://res/cache"); +// cache_btn->setFixedSize(260, 130); + cache_btn->setStatusTip("cache"); + cache_btn->setLabelText(tr("System Cache"), tr("Cleanup cache of system, software-center, thumbnails and browser"));//系统缓存垃圾 清除包、软件中心、缩略图和浏览器缓存 + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_items, SIGNAL(notifyMainCheckBox(int)), cache_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(cache_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + + QStringList package_list; + package_list << tr("Uninstall unnecessary procedures") << tr("Uninstall old kernel packages") << tr("Cleanup software configfile"); + status_list.clear(); + status_list << "unneed" << "oldkernel" << "configfile"; + package_items = new CleanerItems(package_list, status_list, skin, 200, tr("Package Items")); +// package_btn = new KylinCheckBox(0, "://res/package.png"); + package_btn = new CleanGroup(0, "://res/cache"); +// package_btn->setFixedSize(260, 130); + package_btn->setLabelText(tr("Packages and configfile"), tr("Cleaning up the software that installed by other software bundled, old kernel packages and configfile, to improve system performance"));//包垃圾 清除不必要的程序、旧内核包、配置文件 + package_btn->setStatusTip("package"); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_items, SIGNAL(notifyMainCheckBox(int)), package_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(package_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + + QStringList cookies_list; + cookies_list << tr("Cleanup the Cookies saving in Firefox") << tr("Cleanup the Cookies saving in Chromium"); + status_list.clear(); + status_list << "firefox" << "chromium"; + cookies_items = new CleanerItems(cookies_list, status_list, skin, 170, tr("Cookies Items")); +// cookies_btn = new KylinCheckBox(0, "://res/cookie.png"); + cookies_btn = new CleanGroup(0, "://res/cache"); +// cookies_btn->setFixedSize(260, 130); + cookies_btn->setLabelText(tr("Cookies"), tr("Clean up user login information, support Firefox and Chromium browser"));//清除上网、游戏、购物等记录 + cookies_btn->setStatusTip("cookies"); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cookies_items, SIGNAL(notifyMainCheckBox(int)), cookies_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(cookies_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + + ////Debug logs调试日志 command history 命令历史记录 + QStringList trace_list; + trace_list << tr("Clean up the Firefox Internet records") << tr("Clean up the Chromium Internet records") << tr("Clean up the recently opened documents records") << tr("Delete the command history") << tr("Delete the debug logs"); + status_list.clear(); + status_list << "firefox" << "chromium" << "system" << "bash" << "X11"; + trace_items = new CleanerItems(trace_list, status_list, skin, 280, tr("Trace Items")); +// trace_btn = new KylinCheckBox(0, "://res/trace.png"); + trace_btn = new CleanGroup(0, "://res/cache"); +// trace_btn->setFixedSize(260, 130); + trace_btn->setLabelText(tr("History trace"), tr("Cleaning the internet and opened documents recently records"));//使用痕迹 清除浏览器和系统使用痕迹 + trace_btn->setStatusTip("trace"); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(trace_items, SIGNAL(notifyMainCheckBox(int)), trace_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(trace_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + +// main_checkbox = new QCheckBox("main");//三态复选框 +// main_checkbox->setObjectName("mainCheckBox"); +// main_checkbox->setTristate(true); +// main_checkbox->setEnabled(true); +// main_checkbox->setCheckState(Qt::Unchecked); +// connect(main_checkbox, SIGNAL(clicked()), this, SLOT(reset_sub_checkboxes())); + + QHBoxLayout *tip_layout = new QHBoxLayout(); + tip_layout->addWidget(tip_label); + tip_layout->addStretch(); +// tip_layout->addWidget(main_checkbox); +// tip_layout->setSpacing(50); + tip_layout->setMargin(0); + tip_layout->setContentsMargins(38,20,72,0); + + QHBoxLayout *layout1 = new QHBoxLayout; + layout1->addWidget(cache_btn); + layout1->addWidget(package_btn); + layout1->addWidget(cookies_btn); + layout1->setMargin(0); + layout1->setContentsMargins(0,0,0,0); + + QHBoxLayout *layout2 = new QHBoxLayout; +// layout2->addWidget(browser_btn); + layout2->addWidget(trace_btn); + layout2->addStretch(); + layout1->setMargin(0); + layout2->setContentsMargins(20,0,0,0); + + QVBoxLayout *layoutbox = new QVBoxLayout; + layoutbox->addLayout(layout1); + layoutbox->addLayout(layout2); + layoutbox->setSpacing(20); + layoutbox->setMargin(0); + layoutbox->setContentsMargins(0,0,0,0); + + QVBoxLayout *main_layout = new QVBoxLayout; + main_layout->addLayout(tip_layout); + main_layout->addLayout(layoutbox); + main_layout->addStretch(); + main_layout->setSpacing(30); + main_layout->setMargin(0); + main_layout->setContentsMargins(0,0,0,0); + + setLayout(main_layout); + this->setLanguage(); + +// main_checkbox = new QCheckBox(); +// main_checkbox->setFocusPolicy(Qt::NoFocus); +// main_checkbox->setObjectName("mainCheckBox"); +// main_checkbox->setTristate(true); +// main_checkbox->setEnabled(true); +// main_checkbox->setCheckState(Qt::Checked); +// cache_items = NULL; +// scanWidgets = new QStackedWidget(this); +// scanWidgets->setGeometry(rect()); +// scanWidgets->lower(); +} + +CleanerMainWidget::~CleanerMainWidget() +{ + +} + +void CleanerMainWidget::setLanguage() +{ + tip_label->setText(tr("Please select the items you want to clean")); +// main_checkbox->setText(tr("All")); +} + +void CleanerMainWidget::resetCurrentSkin(QString skin) +{ + if(cache_items != NULL) + cache_items->resetTitleSkin(skin); + if(trace_items != NULL) + trace_items->resetTitleSkin(skin); + if(package_items != NULL) + package_items->resetTitleSkin(skin); + if(cookies_items != NULL) + cookies_items->resetTitleSkin(skin); +} + +void CleanerMainWidget::receiveScanSignal() +{ + this->getAllScanSelectedItems(); + if(argsMap.empty()) + { + toolKits->alertMSG(parentWindow->geometry().topLeft().x(), parentWindow->geometry().topLeft().y(), tr("Scan args is empty!")); + } + else + { +// qDebug() << "args is.........." << argsMap; + emit this->showActionAnimaiton(); + sessionproxy->scanSystemCleanerItems(argsMap); + } +} + +void CleanerMainWidget::getAllScanSelectedItems() +{ + argsMap.clear(); + QStringList cacheTmp; + QStringList packageTmp; + QStringList cookieTmp; + QStringList historyTmp; + + if(cache_btn != NULL && cache_btn->getCheckBoxStatus() != 0) + { + QStringList tmp = cache_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = package_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cookies_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = trace_items->getSelectedItems(); + for(int i = 0; i 0) + argsMap.insert("Cache", cacheTmp); + if(packageTmp.length() > 0) + argsMap.insert("Packages", packageTmp); + if(cookieTmp.length() > 0) + argsMap.insert("Cookies", cookieTmp); + if(historyTmp.length() > 0) + argsMap.insert("History", historyTmp); +} + +void CleanerMainWidget::onButtonClicked() +{ + QObject *object = QObject::sender(); +// KylinCheckBox *checkbox = qobject_cast(object); + CleanGroup *checkbox = qobject_cast(object); + QString object_name = checkbox->statusTip(); + if(object_name == "cache") + { + if(cache_items->isHidden()) { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_items->move(w_x, w_y); + cache_items->show(); + } + else + { + cache_items->hide(); + } + if(!package_items->isHidden()) { + package_items->hide(); + } + if(!cookies_items->isHidden()) { + cookies_items->hide(); + } + if(!trace_items->isHidden()) { + trace_items->hide(); + } + } + else if(object_name == "package") + { + if(package_items->isHidden()) { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (200 / 2); + package_items->move(w_x, w_y); + package_items->show(); + } + else + { + package_items->hide(); + } + if(!cache_items->isHidden()) { + cache_items->hide(); + } + if(!cookies_items->isHidden()) { + cookies_items->hide(); + } + if(!trace_items->isHidden()) { + trace_items->hide(); + } + } + if(object_name == "cookies") + { + if(cookies_items->isHidden()) { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (170 / 2); + cookies_items->move(w_x, w_y); + cookies_items->show(); + } + else + { + cookies_items->hide(); + } + if(!cache_items->isHidden()) { + cache_items->hide(); + } + if(!package_items->isHidden()) { + package_items->hide(); + } + if(!trace_items->isHidden()) { + trace_items->hide(); + } + } + if(object_name == "trace") + { + if(trace_items->isHidden()) { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (200 / 2); + trace_items->move(w_x, w_y); + trace_items->show(); + } + else + { + trace_items->hide(); + } + if(!cache_items->isHidden()) { + cache_items->hide(); + } + if(!package_items->isHidden()) { + package_items->hide(); + } + if(!cookies_items->isHidden()) { + cookies_items->hide(); + } + } +} diff --git a/cleaner/cleanermainwidget-org.h b/cleaner/cleanermainwidget-org.h new file mode 100644 index 0000000..ce913b5 --- /dev/null +++ b/cleaner/cleanermainwidget-org.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERMAINWIDGET_H +#define CLEANERMAINWIDGET_H + +#include +#include +#include "cleaneritems.h" + +class MainWindow; +class CleanGroup; +class SessionDispatcher; +class Toolkits; + +class CleanerMainWidget : public QWidget +{ + Q_OBJECT +public: + explicit CleanerMainWidget(QWidget *parent = 0, SessionDispatcher *seroxy = 0, MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png"); + ~CleanerMainWidget(); + void setLanguage(); + void getAllScanSelectedItems(); + void resetCurrentSkin(QString skin); + +public slots: + void onButtonClicked(); + void receiveScanSignal(); + +signals: + void showActionAnimaiton(); + +private: + MainWindow *parentWindow; + QLabel *tip_label; + + CleanGroup *cache_btn; + CleanerItems *cache_items; + CleanGroup *package_btn; + CleanerItems *package_items; + CleanGroup *cookies_btn; + CleanerItems *cookies_items; + CleanGroup *trace_btn; + CleanerItems *trace_items; + + QMap argsMap; + SessionDispatcher *sessionproxy; + Toolkits *toolKits; +// QStackedWidget *scanWidgets; +}; + +#endif // CLEANERMAINWIDGET_H + + + + diff --git a/cleaner/cleanermainwidget.cpp b/cleaner/cleanermainwidget.cpp new file mode 100644 index 0000000..04b87bc --- /dev/null +++ b/cleaner/cleanermainwidget.cpp @@ -0,0 +1,250 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleanermainwidget.h" +#include +#include "../mainui/mainwindow.h" +#include "../component/cleangroup.h" + +CleanerMainWidget::CleanerMainWidget(QWidget *parent, SessionDispatcher *seroxy, MainWindow *window, Toolkits *kits, QString skin) + : QWidget(parent), sessionproxy(seroxy), parentWindow(window), toolKits(kits) +{ + this->setFixedSize(900, 403); + this->setObjectName("transparentWidget"); +// this->setAutoFillBackground(true); +// QPalette palette; +// palette.setBrush(QPalette::Window, QBrush(Qt::white)); +// this->setPalette(palette); + + tip_label = new QLabel(this); + tip_label->setGeometry(QRect(30, 10, 800, 30)); + tip_label->setObjectName("tipLabel"); + QStringList cache_list, status_list; + cache_list << tr("Cleanup Package Cache") << tr("Cleanup Software Center Cache") << tr("Cleanup Thumbnails Cache") << tr("Cleanup FireFox Cache") << tr("Cleanup Chromium Cache"); + status_list << "apt" << "software-center" << "thumbnails" << "firefox" << "chromium"; + cache_items = new CleanerItems(cache_list, status_list, skin, 280, tr("Cache Items")); +// cache_btn = new KylinCheckBox(0, "://res/cache.png"); + cache_btn = new CleanGroup(this, "://res/cache"); + cache_btn->setFocusPolicy(Qt::NoFocus); +// cache_btn->setGeometry(QRect(10, 50, 260, 150)); + cache_btn->setGeometry(QRect(10, 150, 260, 150)); +// cache_btn->setFixedSize(260, 130); + cache_btn->setStatusTip("cache"); + cache_btn->setLabelText(tr("System Cache"), tr("Cleanup cache of system, software-center, thumbnails and browser"));//系统缓存垃圾 清除包、软件中心、缩略图和浏览器缓存 + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cache_items, SIGNAL(notifyMainCheckBox(int)), cache_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(cache_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + + //20160711 + /*QStringList package_list; + package_list << tr("Uninstall unnecessary procedures") << tr("Uninstall old kernel packages") << tr("Cleanup software configfile"); + status_list.clear(); + status_list << "unneed" << "oldkernel" << "configfile"; + package_items = new CleanerItems(package_list, status_list, skin, 200, tr("Package Items")); +// package_btn = new KylinCheckBox(0, "://res/package.png"); + package_btn = new CleanGroup(this, "://res/package"); + package_btn->setFocusPolicy(Qt::NoFocus); + package_btn->setGeometry(QRect(320, 50, 260, 150)); +// package_btn->setFixedSize(260, 130); + package_btn->setLabelText(tr("Packages and configfile"), tr("Cleaning up the software that installed by other software bundled, old kernel packages and configfile, to improve system performance"));//包垃圾 清除不必要的程序、旧内核包、配置文件 + package_btn->setStatusTip("package"); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(package_items, SIGNAL(notifyMainCheckBox(int)), package_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(package_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked()));*/ + + QStringList cookies_list; + cookies_list << tr("Cleanup the Cookies saving in Firefox") << tr("Cleanup the Cookies saving in Chromium"); + status_list.clear(); + status_list << "firefox" << "chromium"; + cookies_items = new CleanerItems(cookies_list, status_list, skin, 170, tr("Cookies Items")); +// cookies_btn = new KylinCheckBox(0, "://res/cookie.png"); + cookies_btn = new CleanGroup(this, "://res/cookie"); + cookies_btn->setFocusPolicy(Qt::NoFocus); + cookies_btn->setGeometry(QRect(320, 150, 260, 150)); +// cookies_btn->setGeometry(QRect(630, 50, 260, 150)); +// cookies_btn->setFixedSize(260, 130); + cookies_btn->setLabelText(tr("Cookies"), tr("Clean up user login information, support Firefox and Chromium browser"));//清除上网、游戏、购物等记录 + cookies_btn->setStatusTip("cookies"); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(cookies_items, SIGNAL(notifyMainCheckBox(int)), cookies_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(cookies_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + + QStringList trace_list; + trace_list << tr("Clean up the Firefox Internet records") << tr("Clean up the Chromium Internet records") << tr("Clean up the recently opened documents records") << tr("Delete the command history") << tr("Delete the debug logs"); + status_list.clear(); + status_list << "firefox" << "chromium" << "system" << "bash" << "X11"; + trace_items = new CleanerItems(trace_list, status_list, skin, 280, tr("Trace Items")); +// trace_btn = new KylinCheckBox(0, "://res/trace.png"); + trace_btn = new CleanGroup(this, "://res/trace"); + trace_btn->setFocusPolicy(Qt::NoFocus); +// trace_btn->setGeometry(QRect(10, 240, 260, 150)); + trace_btn->setGeometry(QRect(630, 150, 260, 150)); +// trace_btn->setFixedSize(260, 130); + trace_btn->setLabelText(tr("History trace"), tr("Cleaning the internet and opened documents recently records"));//使用痕迹 清除浏览器和系统使用痕迹 + trace_btn->setStatusTip("trace"); + //子checkbox的状态被改变时,重新设置总按钮的状态 + connect(trace_items, SIGNAL(notifyMainCheckBox(int)), trace_btn, SLOT(resetMainStatus(int))); + //点击按钮后,显示子页面 + connect(trace_btn, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + this->setLanguage(); +} + +CleanerMainWidget::~CleanerMainWidget() +{ + if(cache_items != NULL) { + delete cache_items; + cache_items = NULL; + } +// if(package_items != NULL) { +// delete package_items; +// package_items = NULL; +// } + if(cookies_items != NULL) { + delete cookies_items; + cookies_items = NULL; + } + if(trace_items != NULL) { + delete trace_items; + trace_items = NULL; + } +} + +void CleanerMainWidget::setLanguage() +{ + tip_label->setText(tr("Please select the items you want to clean")); +} + +void CleanerMainWidget::resetCurrentSkin(QString skin) +{ + if(cache_items != NULL) + cache_items->resetTitleSkin(skin); + if(trace_items != NULL) + trace_items->resetTitleSkin(skin); +// if(package_items != NULL) +// package_items->resetTitleSkin(skin); + if(cookies_items != NULL) + cookies_items->resetTitleSkin(skin); +} + +void CleanerMainWidget::receiveScanSignal() +{ + this->getAllScanSelectedItems(); + if(argsMap.empty()) + { + toolKits->alertMSG(parentWindow->geometry().topLeft().x(), parentWindow->geometry().topLeft().y(), tr("Scan args is empty!")); + } + else + { +// qDebug() << "args is.........." << argsMap; + emit this->showActionAnimaiton(); + sessionproxy->scanSystemCleanerItems(argsMap); + } +} + +void CleanerMainWidget::getAllScanSelectedItems() +{ + argsMap.clear(); + QStringList cacheTmp; +// QStringList packageTmp; + QStringList cookieTmp; + QStringList historyTmp; + + if(cache_btn != NULL && cache_btn->getCheckBoxStatus() != 0) + { + QStringList tmp = cache_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) +// { +// QStringList tmp = package_items->getSelectedItems(); +// for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = cookies_items->getSelectedItems(); + for(int i = 0; igetCheckBoxStatus() != 0) + { + QStringList tmp = trace_items->getSelectedItems(); + for(int i = 0; i 0) + argsMap.insert("Cache", cacheTmp); +// if(packageTmp.length() > 0) +// argsMap.insert("Packages", packageTmp); + if(cookieTmp.length() > 0) + argsMap.insert("Cookies", cookieTmp); + if(historyTmp.length() > 0) + argsMap.insert("History", historyTmp); +} + +void CleanerMainWidget::onButtonClicked() +{ + QObject *object = QObject::sender(); +// KylinCheckBox *checkbox = qobject_cast(object); + CleanGroup *checkbox = qobject_cast(object); + QString object_name = checkbox->statusTip(); + if(object_name == "cache") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + cache_items->move(w_x, w_y); + cache_items->exec(); + } +// if(object_name == "package") +// { +// int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); +// int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (200 / 2); +// package_items->move(w_x, w_y); +// package_items->exec(); +// } + if(object_name == "cookies") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (170 / 2); + cookies_items->move(w_x, w_y); + cookies_items->exec(); + } + if(object_name == "trace") + { + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); + trace_items->move(w_x, w_y); + trace_items->exec(); + } +} diff --git a/cleaner/cleanermainwidget.h b/cleaner/cleanermainwidget.h new file mode 100644 index 0000000..9815421 --- /dev/null +++ b/cleaner/cleanermainwidget.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERMAINWIDGET_H +#define CLEANERMAINWIDGET_H + +#include +#include +#include "cleaneritems.h" + +class MainWindow; +class CleanGroup; +class SessionDispatcher; +class Toolkits; + +class CleanerMainWidget : public QWidget +{ + Q_OBJECT +public: + explicit CleanerMainWidget(QWidget *parent = 0, SessionDispatcher *seroxy = 0, MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png"); + ~CleanerMainWidget(); + void setLanguage(); + void getAllScanSelectedItems(); + void resetCurrentSkin(QString skin); + +public slots: + void onButtonClicked(); + void receiveScanSignal(); + +signals: + void showActionAnimaiton(); + +private: + MainWindow *parentWindow; + QLabel *tip_label; + + CleanGroup *cache_btn; + CleanerItems *cache_items; +// CleanGroup *package_btn; +// CleanerItems *package_items; + CleanGroup *cookies_btn; + CleanerItems *cookies_items; + CleanGroup *trace_btn; + CleanerItems *trace_items; + + QMap argsMap; + SessionDispatcher *sessionproxy; + Toolkits *toolKits; +}; + +#endif // CLEANERMAINWIDGET_H + + + + diff --git a/cleaner/cleanlistwidget.cpp b/cleaner/cleanlistwidget.cpp new file mode 100644 index 0000000..16323f4 --- /dev/null +++ b/cleaner/cleanlistwidget.cpp @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleanlistwidget.h" +#include "ui_cleanlistwidget.h" +#include +#include +#include "../component/utils.h" +#include + +//CleanListWidget::CleanListWidget(QStringList &arglist, const QString title_text, QWidget *parent) : +// QWidget(parent),titleName(title_text), +CleanListWidget::CleanListWidget(QStringList &arglist, QString skin, const QString title_text, QDialog *parent) : + QDialog(parent),titleName(title_text), + ui(new Ui::CleanListWidget) +{ + ui->setupUi(this); + this->setFixedSize(560, 398); + setWindowFlags(Qt::FramelessWindowHint); + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + tip_label = new QLabel(); + num_label = new QLabel(); + + ui->widget_1->setAutoFillBackground(true); + QPalette palette; + palette.setColor(QPalette::Background, QColor(233,238,241));//#e9eef1 + ui->widget_1->setPalette(palette); + + ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + ui->scrollArea->setStyleSheet("QScrollArea{border: none}"); + ui->scrollArea->setAutoFillBackground(true); + ui->scrollArea->setBackgroundRole(QPalette::Light);//QPalette::Dark +// palette.setBrush(QPalette::Window, QBrush(Qt::white)); +// ui->scrollArea->setPalette(palette); + + tip_label->setText(tr("Clean Items:")); + + QHBoxLayout *tip_layout = new QHBoxLayout(); + tip_layout->addWidget(tip_label); + tip_layout->addWidget(num_label); + tip_layout->addStretch(); + tip_layout->setSpacing(0); + tip_layout->setMargin(0); + tip_layout->setContentsMargins(10, 0, 0, 0); + ui->widget_1->setLayout(tip_layout); + + title_bar = new KylinTitleBar(this); + title_bar->move(0,0); + title_bar->show(); + initTitleBar(skin); + ui->scrollArea->setFixedSize(556,331); + + + QVBoxLayout *button_layout = new QVBoxLayout; + int count = arglist.count(); + num_label->setText(QString::number(count)); + for(int i=0; isetFocusPolicy(Qt::NoFocus); + checkbox->setCheckState(Qt::Checked); + checkbox_list.append(checkbox); + connect(checkbox, SIGNAL(clicked()), this, SLOT(scanAllSubCheckbox())); + button_layout->addWidget(checkbox); + } + button_layout->setSpacing(5); + button_layout->setMargin(0); + button_layout->setContentsMargins(0, 0, 0, 0); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(button_layout); + layout->addStretch(); + layout->setSpacing(0); + layout->setMargin(0); + layout->setContentsMargins(10, 0, 10, 10); + ui->scrollAreaWidgetContents->setLayout(layout); + ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + this->setLanguage(); + this->initConnect(); +} + +CleanListWidget::~CleanListWidget() +{ + if(tip_label != NULL) { + delete tip_label; + tip_label = NULL; + } + if(num_label != NULL) { + delete num_label; + num_label = NULL; + } + if(title_bar != NULL) { + delete title_bar; + title_bar = NULL; + } + for(int i=0; iisChecked()) { + text_list.append(checkbox->text()); + } + } + return text_list; +} + +void CleanListWidget::scanAllSubCheckbox() { + int count = checkbox_list.count(); + int m = 0; + for(int i=0; iisChecked()) { + m +=1; + } + } + num_label->setText(QString::number(m)); + if (m == 0) { + emit this->notifyMainCheckBox(0); + } + else if (m == count) { + emit this->notifyMainCheckBox(2); + } + else { + emit this->notifyMainCheckBox(1); + } +} + +void CleanListWidget::resetSubCheckbox(int status) { + if(status == 0) { + for(int i=0; isetChecked(false); + } + num_label->setText("0"); + } + else if(status == 2) { + for(int i=0; isetChecked(true); + } + int count = checkbox_list.count(); + num_label->setText(QString::number(count)); + } +} + +void CleanListWidget::setLanguage() +{ + +} + +void CleanListWidget::initConnect() +{ + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); +} + +void CleanListWidget::initTitleBar(QString skin) +{ + title_bar->setTitleWidth(560); + title_bar->setTitleName(titleName); +// title_bar->setTitleBackgound(":/background/res/skin/1.png"); + title_bar->setTitleBackgound(skin); +} + +void CleanListWidget::resetTitleSkin(QString skin) +{ + title_bar->resetBackground(skin); +} + + +void CleanListWidget::onCloseButtonClicked() +{ + this->close(); +} diff --git a/cleaner/cleanlistwidget.h b/cleaner/cleanlistwidget.h new file mode 100644 index 0000000..e5a0fe6 --- /dev/null +++ b/cleaner/cleanlistwidget.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANLISTWIDGET_H +#define CLEANLISTWIDGET_H + +#include +#include +#include "../component/kylintitlebar.h" + +class SessionDispatcher; +class QCheckBox; + +namespace Ui { +class CleanListWidget; +} + +class CleanListWidget : public QDialog +{ + Q_OBJECT + +public: +// explicit CleanListWidget(QStringList &arglist, const QString title_text = "UbuntuKylin", QWidget *parent = 0/*, SessionDispatcher *proxy = 0*/); + explicit CleanListWidget(QStringList &arglist, QString skin = ":/background/res/skin/1.png", const QString title_text = "UbuntuKylin", QDialog *parent = 0/*, SessionDispatcher *proxy = 0*/); + ~CleanListWidget(); + void setLanguage(); + void initConnect(); + QStringList getSelectedItems(); + void resetTitleSkin(QString skin); + +public slots: + void resetSubCheckbox(int status); + void scanAllSubCheckbox(); + void onCloseButtonClicked(); + +signals: + void notifyMainCheckBox(int status); + +private: + void initTitleBar(QString skin); + +private: + Ui::CleanListWidget *ui; + QList checkbox_list; + KylinTitleBar *title_bar; + QString titleName; + QLabel *tip_label; + QLabel *num_label; +}; + +#endif // CLEANLISTWIDGET_H diff --git a/cleaner/cleanlistwidget.ui b/cleaner/cleanlistwidget.ui new file mode 100644 index 0000000..a483a41 --- /dev/null +++ b/cleaner/cleanlistwidget.ui @@ -0,0 +1,52 @@ + + + CleanListWidget + + + + 0 + 0 + 560 + 398 + + + + Dialog + + + + + 0 + 65 + 560 + 331 + + + + true + + + + + 0 + 0 + 558 + 329 + + + + + + + + 0 + 32 + 560 + 33 + + + + + + + diff --git a/component/agentlistitem.cpp b/component/agentlistitem.cpp new file mode 100644 index 0000000..def171f --- /dev/null +++ b/component/agentlistitem.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "agentlistitem.h" +#include +#include + +AgentListItem::AgentListItem(QWidget *parent) : + QWidget(parent) +{ + this->setWindowFlags(Qt::FramelessWindowHint); + mouse_press = false; + label = new QLabel(); + delede_button = new QPushButton(); + delede_button->setFocusPolicy(Qt::NoFocus); + delede_button->setObjectName("transparentButton"); + + QPixmap pixmap("://res/delete.png"); + delede_button->setIcon(pixmap); + delede_button->setIconSize(pixmap.size()); + connect(delede_button, SIGNAL(clicked()), this, SLOT(onDeleteButtonClicked())); + + QHBoxLayout *layout = new QHBoxLayout(); + layout->addWidget(label); + layout->addStretch(); + layout->addWidget(delede_button); +// layout->setContentsMargins(5, 5, 5, 5); + layout->setSpacing(5); + layout->setMargin(0); + setLayout(layout); +} + +AgentListItem::~AgentListItem() +{ + if(label != NULL) + { + delete label; + label = NULL; + } + if(delede_button != NULL) + { + delete delede_button; + delede_button = NULL; + } +} + +void AgentListItem::setCurrentItemName(QString name) +{ + label->setText(name); +} + +QString AgentListItem::getCurrentItemName() +{ + QString name = label->text(); + return name; +} + +void AgentListItem::onDeleteButtonClicked() +{ + QString name = label->text(); + emit removeItem(name); +} + +void AgentListItem::mousePressEvent(QMouseEvent *event) +{ + if(event->button() == Qt::LeftButton) + { + mouse_press = true; + } +} + +void AgentListItem::mouseReleaseEvent(QMouseEvent *event) +{ + if(mouse_press) + { + emit showItemName(label->text()); + mouse_press = false; + } +} diff --git a/component/agentlistitem.h b/component/agentlistitem.h new file mode 100644 index 0000000..562c1ed --- /dev/null +++ b/component/agentlistitem.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AGENTLISTITEM_H +#define AGENTLISTITEM_H + +#include +#include +#include + +class AgentListItem : public QWidget +{ + Q_OBJECT +public: + explicit AgentListItem(QWidget *parent = 0); + ~AgentListItem(); + void setCurrentItemName(QString name); + QString getCurrentItemName(); + +protected: + void mouseReleaseEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); + +signals: + void showItemName(QString name); + void removeItem(QString name); + +public slots: + void onDeleteButtonClicked(); + +private: + bool mouse_press; + QLabel *label; + QPushButton *delede_button; + +}; + + +#endif // AGENTLISTITEM_H diff --git a/component/alertdialog.cpp b/component/alertdialog.cpp new file mode 100644 index 0000000..feb8ebd --- /dev/null +++ b/component/alertdialog.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "alertdialog.h" +#include "ui_alertdialog.h" + +AlertDialog::AlertDialog(QWidget *parent) : + QWidget(parent), + ui(new Ui::AlertDialog) +{ + ui->setupUi(this); + this->setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_TranslucentBackground); + connect(ui->alertBG,SIGNAL(clicked()),this,SLOT(hide())); + ui->alertBG->setStyleSheet("QPushButton{background-image:url('://res/alert.png');border:0px;padding-top:-10px;}"); + ui->alertBG->setFocusPolicy(Qt::NoFocus); +// this->hide(); +} + +AlertDialog::~AlertDialog() +{ + delete ui; +} + +void AlertDialog::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + QStyleOption opt; + opt.init(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); +} + +void AlertDialog::setMSG(QString msg) +{ + ui->alertBG->setText(msg); +} diff --git a/component/alertdialog.h b/component/alertdialog.h new file mode 100644 index 0000000..cbcce32 --- /dev/null +++ b/component/alertdialog.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef ALERTDIALOG_H +#define ALERTDIALOG_H + +#include +#include + +namespace Ui { +class AlertDialog; +} + +class AlertDialog : public QWidget +{ + Q_OBJECT + +public: + explicit AlertDialog(QWidget *parent = 0); + ~AlertDialog(); + void paintEvent(QPaintEvent *); + void setMSG(QString); +private: + Ui::AlertDialog *ui; +}; + +#endif // ALERTDIALOG_H diff --git a/component/alertdialog.ui b/component/alertdialog.ui new file mode 100644 index 0000000..24a16e0 --- /dev/null +++ b/component/alertdialog.ui @@ -0,0 +1,32 @@ + + + AlertDialog + + + + 0 + 0 + 200 + 75 + + + + Form + + + + + 0 + 0 + 200 + 75 + + + + + + + + + + diff --git a/component/autogroup.cpp b/component/autogroup.cpp new file mode 100644 index 0000000..82a28d9 --- /dev/null +++ b/component/autogroup.cpp @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "autogroup.h" +#include "utils.h" +#include + +AutoGroup::AutoGroup(QWidget *parent) : + QWidget(parent) +{ + this->resize(560, 50); + splitlabel = new QLabel(); +// splitlabel->setGeometry(QRect(0, this->height(), this->width(), 1)); + splitlabel->setFixedHeight(1); + splitlabel->setStyleSheet("QLabel{background:#e0e0e0;}"); + + logo_label = new QLabel(); + name_label = new QLabel(); + comment_label = new QLabel(); + switcher = new KylinSwitcher(); + connect(switcher, SIGNAL(clicked()), this, SIGNAL(autoStatusChange())); + + QVBoxLayout *v_layout = new QVBoxLayout(); + v_layout->addStretch(); + v_layout->addWidget(name_label); + v_layout->addWidget(comment_label); + v_layout->addStretch(); + v_layout->setSpacing(5); + v_layout->setMargin(0); + v_layout->setContentsMargins(0,0,0,0); + QHBoxLayout *h_layout = new QHBoxLayout(); + h_layout->addWidget(logo_label); + h_layout->addLayout(v_layout); + h_layout->addStretch(); + h_layout->addWidget(switcher); + h_layout->setSpacing(10); + h_layout->setMargin(0);//设置总的外围边框 + h_layout->setContentsMargins(0,0,0,0); + + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addStretch(); + layout->addLayout(h_layout); + layout->addWidget(splitlabel); + layout->addStretch(); +// layout->setSpacing(5); + layout->setMargin(0); + layout->setContentsMargins(0,0,0,0); + + setLayout(layout); +} + +AutoGroup::~AutoGroup() +{ + if(logo_label != NULL) + { + delete logo_label; + logo_label = NULL; + } + if(name_label != NULL) + { + delete name_label; + name_label = NULL; + } + if(comment_label != NULL) + { + delete comment_label; + comment_label = NULL; + } + if(switcher != NULL) + { + delete switcher; + switcher = NULL; + } + if(splitlabel != NULL) + { + delete splitlabel; + splitlabel = NULL; + } +} +void AutoGroup::initData(QMap data) +{ + dekstopFile = data.value("Path"); + logo_label->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小 + if(data.value("Icon").isEmpty()) + { + QPixmap label_pixmap("://res/ubuntukylin.png"); + logo_label->setPixmap(label_pixmap); + } + else + { + QPixmap label_pixmap(data.value("Icon")); + logo_label->setPixmap(label_pixmap); + } +// logo_label->setFixedSize(label_pixmap.size()); + logo_label->setFixedSize(40, 40); + name_label->setText(data.value("Name")); + if(data.value("Comment").isEmpty()) + { + comment_label->setText(data.value("NONE")); + } + else + { + comment_label->setText(data.value("Comment")); + } + + if(data.value("Status") == "true") + switcher->switchedOn = true; + else + switcher->switchedOn = false; +} + +bool AutoGroup::getSwitcherStatus() +{ + if(switcher->switchedOn == true) + return true; + else + return false; +} diff --git a/component/autogroup.h b/component/autogroup.h new file mode 100644 index 0000000..ea722e5 --- /dev/null +++ b/component/autogroup.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AUTOGROUP_H +#define AUTOGROUP_H + +#include +#include +#include +#include +#include "kylinswitcher.h" + +class AutoGroup : public QWidget +{ + Q_OBJECT +public: + explicit AutoGroup(QWidget *parent = 0); + ~AutoGroup(); + void initData(QMap data); + QString dekstopFile; + bool getSwitcherStatus(); + +signals: + void autoStatusChange(); + +private: + QLabel *logo_label; + QLabel *name_label; + QLabel *comment_label; + KylinSwitcher *switcher; + QLabel *splitlabel; +}; + +#endif // AUTOGROUP_H diff --git a/component/basewidget.cpp b/component/basewidget.cpp new file mode 100644 index 0000000..498ca9c --- /dev/null +++ b/component/basewidget.cpp @@ -0,0 +1,37 @@ +#include "basewidget.h" +#include +#include + +BaseWidget::BaseWidget(QWidget *parent) : + QWidget(parent) +{ + this->initUI(); + this->initConnect(); +} + +void BaseWidget::initUI() +{ + m_vLayout = new QVBoxLayout; +} + +void BaseWidget::initConnect() +{ +} + +void BaseWidget::insertWidget(QWidget *widget) +{ + m_vLayout->addWidget(widget); + m_vLayout->setContentsMargins(0, 0, 0, 0); + m_vLayout->setSpacing(0); + + this->setLayout(m_vLayout); +} + +void BaseWidget::insertLayout(QLayout *layout) +{ + m_vLayout->addLayout(layout); + m_vLayout->setContentsMargins(0, 0, 0, 0); + m_vLayout->setSpacing(0); + + this->setLayout(m_vLayout); +} diff --git a/component/basewidget.h b/component/basewidget.h new file mode 100644 index 0000000..2946f61 --- /dev/null +++ b/component/basewidget.h @@ -0,0 +1,25 @@ +#ifndef BASEWIDGET_H +#define BASEWIDGET_H + +#include +class QVBoxLayout; + +class BaseWidget : public QWidget +{ + Q_OBJECT +public: + explicit BaseWidget(QWidget *parent = 0); + void insertWidget(QWidget *widget); + void insertLayout(QLayout *layout); + void initUI(); + void initConnect(); + +signals: + +public slots: + +private: + QVBoxLayout *m_vLayout; +}; + +#endif // BASEWIDGET_H diff --git a/component/cardwidget.cpp b/component/cardwidget.cpp new file mode 100644 index 0000000..36419cb --- /dev/null +++ b/component/cardwidget.cpp @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cardwidget.h" +#include +#include "../component/utils.h" + +CardWidget::CardWidget(int cardwidth, int cardheight, int space, QWidget *parent) : + QWidget(parent) +{ + cardcount = 0; + number_per_row = -1; + this->itemwidth = cardwidth; + this->itemheight = cardheight; + this->cardspace = space; + + scrollArea = new QScrollArea(this); + scrollArea->setStyleSheet("QScrollArea{border: none;background-color: #ffffff;}"); + cardPanel = new QWidget(); + cardPanel->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + this->scrollArea->setWidget(this->cardPanel); + this->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + this->scrollArea->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{margin:0px 0px 0px 0px;background-color:rgb(255,255,255,100);border:0px;width:6px;}\ + QScrollBar::sub-line:vertical{subcontrol-origin:margin;border:1px solid red;height:13px}\ + QScrollBar::up-arrow:vertical{subcontrol-origin:margin;background-color:blue;height:13px}\ + QScrollBar::sub-page:vertical{background-color:#EEEDF0;}\ + QScrollBar::handle:vertical{background-color:#D1D0D2;width:6px;} QScrollBar::handle:vertical:hover{background-color:#14ACF5;width:6px;} QScrollBar::handle:vertical:pressed{background-color:#0B95D7;width:6px;}\ + QScrollBar::add-page:vertical{background-color:#EEEDF0;}\ + QScrollBar::down-arrow:vertical{background-color:yellow;}\ + QScrollBar::add-line:vertical{subcontrol-origin:margin;border:1px solid green;height:13px}"); + +// QVBoxLayout *v_layout = new QVBoxLayout(); +// v_layout->addWidget(scrollArea); +// v_layout->setSpacing(0);//设置间隔 +// v_layout->setMargin(0);//设置总的外围边框 +// v_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(v_layout); +} + +CardWidget::~CardWidget() { + if(cardPanel != NULL) { + delete cardPanel; + cardPanel = NULL; + } +} + +void CardWidget::calculate_data() +{ +// this->scrollArea->setGeometry(-1, -1, this->width() + 2, this->height() + 2); + this->scrollArea->setGeometry(0, 0, this->width(), this->height()); + this->cardPanel->setGeometry(0, 0, this->width(), this->height()); + this->number_per_row = (this->width() + this->cardspace) / (this->itemwidth + this->cardspace); +} + +void CardWidget::add_card(QWidget *card) +{ + int x = int(this->cardcount % this->number_per_row) * (this->itemwidth + this->cardspace); + int y = int(this->cardcount / this->number_per_row) * (this->itemheight + this->cardspace); + + int nowHeight = y + this->itemheight; + if(nowHeight >= this->cardPanel->height()) + this->cardPanel->resize(this->cardPanel->width(), nowHeight); + card->move(x, y); + this->cardcount += 1; +} + +void CardWidget::clear_card() +{ + foreach (QObject *child, this->cardPanel->children()) { + QWidget *widget = static_cast(child); + widget->deleteLater(); + } + this->cardPanel->setGeometry(0, 0, this->width(), this->height()); + this->cardcount = 0; +} diff --git a/component/cardwidget.h b/component/cardwidget.h new file mode 100644 index 0000000..74d5aab --- /dev/null +++ b/component/cardwidget.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CARDWIDGET_H +#define CARDWIDGET_H + +#include +#include +#include +#include + + +class CardWidget : public QWidget +{ + Q_OBJECT +public: + explicit CardWidget(int cardwidth = 0, int cardheight = 0, int space = 0, QWidget *parent = 0); + ~CardWidget(); + void calculate_data(); + void add_card(QWidget *card); + void clear_card(); + QWidget *cardPanel; + +private: + int cardcount; + int number_per_row; + int itemwidth; + int itemheight; + int cardspace; + QScrollArea *scrollArea; +}; + +#endif // CARDWIDGET_H diff --git a/component/cleanbutton.cpp b/component/cleanbutton.cpp new file mode 100644 index 0000000..31f4d34 --- /dev/null +++ b/component/cleanbutton.cpp @@ -0,0 +1,165 @@ +/* Authors: +* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com +* +* 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; version 3. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#include "cleanbutton.h" +#include +#include +#include + +CleanButton::CleanButton(QWidget *parent) : + QWidget(parent) +{ + hoverPixmap.load("://res/shadow_hover"); + grayhoverPixmap.load("://res/shadow_gray_hover"); + this->setFixedSize(hoverPixmap.size()); + QPixmap pixMap("://res/checkbox-two.png"); + int width = pixMap.width(); + int height = pixMap.height();//20 + int num = 6;//6*20=120 + for(int i=0; i != num; i++) + { + checkboxList.append(pixMap.copy(i*(width/num), 0, width/num, height)); + } + //设置checkbox的显示位置:x(62), y(53) + checkboxRect.setX(60); + checkboxRect.setY(53); + checkboxRect.setSize(checkboxList.at(0).size()); +} + +void CleanButton::setIconPath(const QString &icon) +{ + checkPixmap.load(icon + "_check"); + uncheckPixmap.load(icon + "_uncheck"); +} + +void CleanButton::setCleanButtonStatus(BUTTONSTATUS status) +{ + buttonStatus = status; + update(); +} + +void CleanButton::setCheckboxStatus(int status) +{ + tristateStatus = status; + setCleanButtonStatus(BUTTON_LEAVE); +} + +void CleanButton::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + switch (buttonStatus) { + case BUTTON_LEAVE: + if(tristateStatus == 2) + { + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(2)); + } + else if(tristateStatus == 1) + { + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(4)); + } + else if(tristateStatus == 0) + { + painter.drawPixmap(rect(), uncheckPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(0)); + } + break; + case BUTTON_ENTER: + if(tristateStatus == 2) + { + painter.drawPixmap(rect(), hoverPixmap); + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(2)); + } + else if(tristateStatus == 1) + { + painter.drawPixmap(rect(), hoverPixmap); + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(4)); + } + else if(tristateStatus == 0) + { + painter.drawPixmap(rect(), grayhoverPixmap); + painter.drawPixmap(rect(), uncheckPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(0)); + } + break; + case BUTTON_PRESSED: + if(tristateStatus == 2) + { + painter.drawPixmap(rect(), hoverPixmap); + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(2)); + } + else if(tristateStatus == 1) + { + painter.drawPixmap(rect(), hoverPixmap); + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(4)); + } + else if(tristateStatus == 0) + { + painter.drawPixmap(rect(), grayhoverPixmap); + painter.drawPixmap(rect(), uncheckPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(0)); + } + break; + default: + break; + } +} + +void CleanButton::enterEvent(QEvent *) +{ + setCleanButtonStatus(BUTTON_ENTER); +} + +void CleanButton::leaveEvent(QEvent *) +{ + setCleanButtonStatus(BUTTON_LEAVE); +} + +void CleanButton::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + setCleanButtonStatus(BUTTON_PRESSED); + } + else + { + event->ignore(); + } +} + +void CleanButton::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + if(rect().contains(event->pos())) + { + setCleanButtonStatus(BUTTON_ENTER); + emit this->clicked(); + }else + { + setCleanButtonStatus(BUTTON_LEAVE); + } + } + else + { + event->ignore(); + } +} diff --git a/component/cleanbutton.h b/component/cleanbutton.h new file mode 100644 index 0000000..c54a63b --- /dev/null +++ b/component/cleanbutton.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANBUTTON_H +#define CLEANBUTTON_H + +#include +#include "utils.h" + +class CleanButton : public QWidget +{ + Q_OBJECT +public: + explicit CleanButton(QWidget *parent = 0); + void setIconPath(const QString &icon); + void setCleanButtonStatus(BUTTONSTATUS status); + void setCheckboxStatus(int status); + +signals: + void clicked(); + +protected: + void paintEvent(QPaintEvent *); + void enterEvent(QEvent *); + void leaveEvent(QEvent *); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +private: + int tristateStatus; + QPixmap hoverPixmap; + QPixmap grayhoverPixmap; + QPixmap checkPixmap; + QPixmap uncheckPixmap; + QList checkboxList; + BUTTONSTATUS buttonStatus; + QRect checkboxRect; +}; + +#endif // CLEANBUTTON_H diff --git a/component/cleangroup.cpp b/component/cleangroup.cpp new file mode 100644 index 0000000..7ba7e15 --- /dev/null +++ b/component/cleangroup.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleangroup.h" +#include "cleanbutton.h" +#include +#include +#include + +CleanGroup::CleanGroup(QWidget *parent, const QString &picture) : + QWidget(parent), tristateStatus(2) +{ + this->setAttribute(Qt::WA_TranslucentBackground); + this->setFixedSize(260, 150); + this->setFocusPolicy(Qt::NoFocus); + img_btn = new CleanButton(); +// img_btn->setAttribute(Qt::WA_TransparentForMouseEvents);//屏蔽鼠标事件 + connect(img_btn, SIGNAL(clicked()),this, SIGNAL(clicked())); + img_btn->setIconPath(picture); + img_btn->setCheckboxStatus(tristateStatus);//全选状态 + img_btn->setFocusPolicy(Qt::NoFocus); + + name_label = new QLabel(); + description_label = new QLabel(); + name_label->setObjectName("middleblackLabel"); + name_label->setAlignment(Qt::AlignCenter); + description_label->setAlignment(Qt::AlignCenter); + description_label->setObjectName("smallgrayLabel"); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(img_btn, 0, Qt::AlignHCenter); + main_layout->addWidget(name_label, 0, Qt::AlignHCenter); + main_layout->addWidget(description_label, 0, Qt::AlignHCenter); + main_layout->setSpacing(5); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + + this->setLayout(main_layout); +} + +CleanGroup::~CleanGroup() +{ + if(img_btn != NULL) + { + delete img_btn; + img_btn = NULL; + } + if(name_label != NULL) + { + delete name_label; + name_label = NULL; + } + if(description_label != NULL) + { + delete description_label; + description_label = NULL; + } +} + +void CleanGroup::setLabelText(const QString &name, const QString &desc) +{ + QFont ft; + QFontMetrics fm(ft); + QString elided_text = fm.elidedText(name, Qt::ElideRight, 260); + name_label->setText(elided_text); + elided_text = fm.elidedText(desc, Qt::ElideRight, 260); + description_label->setText(elided_text); + if(elided_text.endsWith("…")) + description_label->setToolTip(desc); +} + +//sub item's change to make it work +void CleanGroup::resetMainStatus(int status) +{ + tristateStatus = status; + if(status == 0) { + img_btn->setCheckboxStatus(0); + } + else if(status == 1) { + img_btn->setCheckboxStatus(1); + } + else if(status == 2) { + img_btn->setCheckboxStatus(2); + } +} + +int CleanGroup::getCheckBoxStatus() +{ + return tristateStatus; +} diff --git a/component/cleangroup.h b/component/cleangroup.h new file mode 100644 index 0000000..7069b0a --- /dev/null +++ b/component/cleangroup.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANGROUP_H +#define CLEANGROUP_H + +#include +class QLabel; +class CleanButton; + +class CleanGroup : public QWidget +{ + Q_OBJECT +public: + explicit CleanGroup(QWidget *parent = 0, const QString &picture= ""); + ~CleanGroup(); + void setLabelText(const QString &name, const QString &desc); + int getCheckBoxStatus(); + +public slots: + void resetMainStatus(int status); + +signals: + void clicked(); + +private: + CleanButton *img_btn; + QLabel *name_label; + QLabel *description_label; + int tristateStatus; +}; + +#endif // CLEANGROUP_H diff --git a/component/cleansubbutton.cpp b/component/cleansubbutton.cpp new file mode 100644 index 0000000..63756be --- /dev/null +++ b/component/cleansubbutton.cpp @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleansubbutton.h" +#include +#include +#include + +CleanSubButton::CleanSubButton(QWidget *parent) : + QWidget(parent) +{ +// hoverPixmap.load("://res/shadow_hover"); +// grayhoverPixmap.load("://res/shadow_gray_hover"); +// this->setFixedSize(hoverPixmap.size()); + this->setFixedSize(48, 48); + QPixmap pixMap("://res/checkbox-tristate.png"); + int width = pixMap.width(); + int height = pixMap.height(); + int num = 9;//9*12=108 + for(int i=0; i != num; i++) + { + checkboxList.append(pixMap.copy(i*(width/num), 0, width/num, height)); + } + //设置checkbox的显示位置:x(36), y(34) + checkboxRect.setX(36); + checkboxRect.setY(34); + checkboxRect.setSize(checkboxList.at(0).size()); +} + +void CleanSubButton::setIconPath(const QString &icon) +{ + checkPixmap.load(icon + "_check"); +// midcheckPixmap.load(icon + "_midcheck"); + uncheckPixmap.load(icon + "_uncheck"); +} + +void CleanSubButton::setCleanButtonStatus(BUTTONSTATUS status) +{ + buttonStatus = status; + update(); +} + +void CleanSubButton::setCheckboxStatus(int status) +{ + tristateStatus = status; + setCleanButtonStatus(BUTTON_LEAVE); +} + +void CleanSubButton::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + switch (buttonStatus) { + case BUTTON_LEAVE: + if(tristateStatus == 2) + { + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(3)); + } + else if(tristateStatus == 1) + { + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(6)); + } + else if(tristateStatus == 0) + { + painter.drawPixmap(rect(), uncheckPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(0)); + } + break; + case BUTTON_ENTER: + if(tristateStatus == 2) + { +// painter.drawPixmap(rect(), hoverPixmap); + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(4)); + } + else if(tristateStatus == 1) + { +// painter.drawPixmap(rect(), hoverPixmap); + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(7)); + } + else if(tristateStatus == 0) + { +// painter.drawPixmap(rect(), grayhoverPixmap); + painter.drawPixmap(rect(), uncheckPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(1)); + } + break; + case BUTTON_PRESSED: + if(tristateStatus == 2) + { +// painter.drawPixmap(rect(), hoverPixmap); + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(4)); + } + else if(tristateStatus == 1) + { +// painter.drawPixmap(rect(), hoverPixmap); + painter.drawPixmap(rect(), checkPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(7)); + } + else if(tristateStatus == 0) + { +// painter.drawPixmap(rect(), grayhoverPixmap); + painter.drawPixmap(rect(), uncheckPixmap); + painter.drawPixmap(checkboxRect, checkboxList.at(1)); + } + break; + default: + break; + } +} + +void CleanSubButton::enterEvent(QEvent *) +{ + setCleanButtonStatus(BUTTON_ENTER); +} + +void CleanSubButton::leaveEvent(QEvent *) +{ + setCleanButtonStatus(BUTTON_LEAVE); +} + +void CleanSubButton::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + setCleanButtonStatus(BUTTON_PRESSED); + } + else + { + event->ignore(); + } +} + +void CleanSubButton::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + if(rect().contains(event->pos())) + { + setCleanButtonStatus(BUTTON_ENTER); + emit this->clicked(); + }else + { + setCleanButtonStatus(BUTTON_LEAVE); + } + } + else + { + event->ignore(); + } +} diff --git a/component/cleansubbutton.h b/component/cleansubbutton.h new file mode 100644 index 0000000..cb719ff --- /dev/null +++ b/component/cleansubbutton.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANSUBBUTTON_H +#define CLEANSUBBUTTON_H + +#include +#include "utils.h" + +class CleanSubButton : public QWidget +{ + Q_OBJECT +public: + explicit CleanSubButton(QWidget *parent = 0); + void setIconPath(const QString &icon); + void setCleanButtonStatus(BUTTONSTATUS status); + void setCheckboxStatus(int status); + +signals: + void clicked(); + +protected: + void paintEvent(QPaintEvent *); + void enterEvent(QEvent *); + void leaveEvent(QEvent *); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +private: + int tristateStatus; +// QPixmap hoverPixmap; +// QPixmap grayhoverPixmap; + QPixmap checkPixmap; +// QPixmap midcheckPixmap; + QPixmap uncheckPixmap; + QList checkboxList; + BUTTONSTATUS buttonStatus; + QRect checkboxRect; +}; + +#endif // CLEANSUBBUTTON_H diff --git a/component/cleansubgroup.cpp b/component/cleansubgroup.cpp new file mode 100644 index 0000000..fcde530 --- /dev/null +++ b/component/cleansubgroup.cpp @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleansubgroup.h" +#include "cleansubbutton.h" +#include +#include +#include +#include + +CleanSubGroup::CleanSubGroup(QWidget *parent, const QString &picture) : + QWidget(parent), tristateStatus(2) +{ + this->setStyleSheet("QWidget{background:transparent;}"); +// this->setAttribute(Qt::WA_TranslucentBackground); + this->setFixedSize(160, 110); + this->setFocusPolicy(Qt::NoFocus); + img_btn = new CleanSubButton(); +// img_btn->setAttribute(Qt::WA_TransparentForMouseEvents);//屏蔽鼠标事件 + img_btn->setIconPath(picture); + img_btn->setCheckboxStatus(tristateStatus);//全选状态 + img_btn->setFocusPolicy(Qt::NoFocus); + + name_label = new QLabel(); + description_label = new QLabel(); + name_label->setObjectName("smallgrayLabel"); + name_label->setAlignment(Qt::AlignCenter); + description_label->setAlignment(Qt::AlignCenter); + description_label->setObjectName("smallgrayLabel"); + + custom_btn = new QPushButton(); + custom_btn->setFocusPolicy(Qt::NoFocus); + custom_btn->setObjectName("checkButton"); + custom_btn->setCursor(Qt::PointingHandCursor); + custom_btn->setFixedSize(91, 25); + custom_btn->setText(tr("Custom")); + +// QVBoxLayout *main_layout = new QVBoxLayout(); +// main_layout->addWidget(img_btn, 0, Qt::AlignHCenter); +// main_layout->addWidget(name_label, 0, Qt::AlignHCenter); +// main_layout->addWidget(description_label, 0, Qt::AlignHCenter); +// main_layout->setSpacing(5); +// main_layout->setMargin(0); +// main_layout->setContentsMargins(0, 0, 0, 0); + + QHBoxLayout *h_layout = new QHBoxLayout(); + h_layout->addStretch(); + h_layout->addWidget(name_label); + h_layout->addWidget(description_label); + h_layout->addStretch(); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(img_btn, 0, Qt::AlignHCenter); + main_layout->addLayout(h_layout); + main_layout->addWidget(custom_btn,0, Qt::AlignHCenter); + main_layout->setSpacing(5); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + this->setLayout(main_layout); + + this->initConnect(); +} + +CleanSubGroup::~CleanSubGroup() +{ + if(img_btn != NULL) + { + delete img_btn; + img_btn = NULL; + } + if(name_label != NULL) + { + delete name_label; + name_label = NULL; + } + if(description_label != NULL) + { + delete description_label; + description_label = NULL; + } + if(custom_btn != NULL) + { + delete custom_btn; + custom_btn = NULL; + } +} + +void CleanSubGroup::initConnect() +{ + connect(img_btn, SIGNAL(clicked()), this, SLOT(onZoneClicked())); + connect(custom_btn, SIGNAL(clicked()), this, SIGNAL(customButtonClicked())); +} + +void CleanSubGroup::setLabelText(const QString &title, int count) +{ + QFont ft; + QFontMetrics fm(ft); + QString elided_text = fm.elidedText(title, Qt::ElideRight, 80); + name_label->setText(elided_text); + description_label->setText(QString::number(count)); + if(elided_text.endsWith("…")) + name_label->setToolTip(title + QString::number(count)); +} + +void CleanSubGroup::setLabelStringText(const QString &title, QString size) +{ + QFont ft; + QFontMetrics fm(ft); + QString elided_text = fm.elidedText(title, Qt::ElideRight, 80); + name_label->setText(elided_text); + description_label->setText(size); + if(elided_text.endsWith("…")) + name_label->setToolTip(title + size); +} + +void CleanSubGroup::hideCustomButton() +{ + custom_btn->hide(); +} + +void CleanSubGroup::onZoneClicked() +{ + if(tristateStatus == 0) { + tristateStatus = 2; + img_btn->setCheckboxStatus(2); + emit this->spreadStatus(2); + } + else if(tristateStatus == 1) { + tristateStatus = 2; + img_btn->setCheckboxStatus(2); + emit this->spreadStatus(2); + } + else if(tristateStatus == 2) { + tristateStatus = 0; + img_btn->setCheckboxStatus(0); + emit this->spreadStatus(0); + } +} + +//sub item's change to make it work +void CleanSubGroup::resetMainStatus(int status) +{ + tristateStatus = status; + if(status == 0) { + img_btn->setCheckboxStatus(0); + } + else if(status == 1) { + img_btn->setCheckboxStatus(1); + } + else if(status == 2) { + img_btn->setCheckboxStatus(2); + } +} + +int CleanSubGroup::getCheckBoxStatus() +{ + return tristateStatus; +} diff --git a/component/cleansubgroup.h b/component/cleansubgroup.h new file mode 100644 index 0000000..7a2e431 --- /dev/null +++ b/component/cleansubgroup.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANSUBGROUP_H +#define CLEANSUBGROUP_H + +#include +class QLabel; +class QPushButton; +class CleanSubButton; + +class CleanSubGroup : public QWidget +{ + Q_OBJECT +public: + explicit CleanSubGroup(QWidget *parent = 0, const QString &picture= ""); + ~CleanSubGroup(); + void setLabelText(const QString &title, int count); + void setLabelStringText(const QString &title, QString size); + int getCheckBoxStatus(); + void initConnect(); + void hideCustomButton(); + +public slots: + void onZoneClicked(); + void resetMainStatus(int status); + +signals: + void clicked(); + void customButtonClicked(); + void spreadStatus(int status); + +private: + CleanSubButton *img_btn; + QLabel *name_label; + QLabel *description_label; + QPushButton *custom_btn; + int tristateStatus; +}; + +#endif // CLEANSUBGROUP_H diff --git a/component/commoncheckbox.cpp b/component/commoncheckbox.cpp new file mode 100644 index 0000000..6be14c0 --- /dev/null +++ b/component/commoncheckbox.cpp @@ -0,0 +1,201 @@ +#include "commoncheckbox.h" +//#include "../component/kylintoolbutton.h" +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +CommonCheckBox::CommonCheckBox(QWidget *parent, const QString &picture) + : QWidget(parent) +{ +// qDebug() << "init main....."; +// this->setFixedSize(260, 90); + //set white background color + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + img_btn = new QPushButton(); + img_btn->setFocusPolicy(Qt::NoFocus); + checkbox = new QCheckBox(this); + checkbox->setObjectName("mainCheckBox"); + checkbox->setTristate(true); + checkbox->setEnabled(true); + checkbox->setCheckState(Qt::Checked); + + name_label = new QLabel(); +// name_label->setObjectName("middleblackLabel"); + name_label->setObjectName("smallgrayLabel"); + name_label->setAlignment(Qt::AlignCenter); +// name_label->setText(tr("Records Count:")); + description_label = new QLabel(); + description_label->setAlignment(Qt::AlignCenter); + description_label->setObjectName("smallgrayLabel"); + + + custom_btn = new QPushButton(); + custom_btn->setFocusPolicy(Qt::NoFocus); + custom_btn->setObjectName("checkButton"); + custom_btn->setCursor(Qt::PointingHandCursor); + custom_btn->setFixedSize(91, 25); + custom_btn->setText(tr("Custom")); +// custom_btn->setObjectName("blackButton"); + + +// img_btn->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小 +// QPixmap label_pixmap("://res/camera-uk.png"); +// img_btn->setPixmap(label_pixmap); +// img_btn->setFixedSize(label_pixmap.size()); + img_btn->setFocusPolicy(Qt::NoFocus); +// QPixmap pixmap("://res/camera-uk.png"); + QPixmap pixmap(picture); + img_btn->setIcon(pixmap); + img_btn->setIconSize(pixmap.size()); +// img_btn->setIconSize(QSize(72, 72)); + img_btn->setObjectName("transparentButton"); + +// checkbox->setAutoFillBackground(true); + checkbox->show(); +// checkbox->move(151-checkbox->width(), 0); + checkbox->move(100, 60); + + QHBoxLayout *h_layout = new QHBoxLayout(); + h_layout->addStretch(); + h_layout->addWidget(name_label); + h_layout->addWidget(description_label); + h_layout->addStretch(); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(img_btn); + main_layout->addLayout(h_layout); +// main_layout->addWidget(name_label); +// main_layout->addWidget(description_label); + main_layout->addWidget(custom_btn,0, Qt::AlignHCenter); + main_layout->setSpacing(5); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + + setLayout(main_layout); + this->initConnect(); + + +// suggest_label->setObjectName("whiteLabel"); +// result_label->setWordWrap(true);//QLabel自动换行 +// result_label->setObjectName("tipLabel"); + +// scan_button->setFixedSize(204, 65); +// scan_button->setFocusPolicy(Qt::NoFocus); +// QPixmap pixmap("://res/scan.png"); +// scan_button->setIcon(pixmap); +// scan_button->setIconSize(pixmap.size()); +// scan_button->setObjectName("greenButton"); +//// QFont scan_font = scan_button->font(); +//// scan_font.setPointSize(16); +//// scan_button->setFont(scan_font); +// back_button->setFocusPolicy(Qt::NoFocus); +// back_button->setFixedSize(50, 30); +// back_button->setObjectName("underlineButton"); + +// //set underline +// // QFont font = back_button->font(); +// // font.setUnderline(true); +// // back_button->setFont(font); + +// //set scan button text color +//// QPalette palette; +//// palette.setColor(QPalette::ButtonText, QColor(255,17,135)); +//// scan_button->setPalette(palette); +} + +CommonCheckBox::~CommonCheckBox() +{ + +} + +int CommonCheckBox::getCheckBoxStatus() +{ + if(checkbox->checkState() == 0) { + return 0; + } + else if(checkbox->checkState() == 1) { + return 1; + } + else if(checkbox->checkState() == 2) { + return 2; + } + else { + return 0; + } +} + +void CommonCheckBox::onZoneClicked() +{ + if(checkbox->checkState() == 0) { + checkbox->setCheckState(Qt::Checked); + emit this->spreadStatus(2); + } + else if(checkbox->checkState() == 1) { + checkbox->setCheckState(Qt::Checked); + emit this->spreadStatus(2); + } + else if(checkbox->checkState() == 2) { + checkbox->setCheckState(Qt::Unchecked); + emit this->spreadStatus(0); + } +} + +//sub item's change to make it work +void CommonCheckBox::resetMainStatus(int status) +{ + if(status == 0) { + checkbox->setCheckState(Qt::Unchecked); + } + else if(status == 1) { + checkbox->setCheckState(Qt::PartiallyChecked); + } + else if(status == 2) { + checkbox->setCheckState(Qt::Checked); + } +} + +void CommonCheckBox::initConnect() +{ + connect(img_btn, SIGNAL(clicked()), this, SLOT(onZoneClicked())); + connect(custom_btn, SIGNAL(clicked()), this, SIGNAL(customButtonClicked())); +// connect(img_btn, SIGNAL(clicked()), this, SIGNAL(customButtonClicked())); +} + +void CommonCheckBox::setLabelText(const QString &title, int count) +{ +// QFont font(name_label->font()); +// QFontMetrics fm(font); +// name_label->setText(fm.elidedText(name), Qt::ElideRight, name_label->width()); +// description_label->setText(fm.elidedText(tip), Qt::ElideRight, description_label->width()); + + QFont ft; + QFontMetrics fm(ft); + QString elided_text = fm.elidedText(title, Qt::ElideRight, 100); + name_label->setText(elided_text); + description_label->setText(QString::number(count)); +// elided_text = fm.elidedText(tip, Qt::ElideRight, 260); +// description_label->setText(elided_text); +} diff --git a/component/commoncheckbox.h b/component/commoncheckbox.h new file mode 100644 index 0000000..b82f42d --- /dev/null +++ b/component/commoncheckbox.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef COMMONCHECKBOX_H +#define COMMONCHECKBOX_H + +#include +#include +#include +#include +//#include +//#include +//#include +//#include +//#include "../component/kylinbutton.h" +//#include "../component/kylintoolbutton.h" +//#include "../component/systembutton.h" +//#include "../component/loadinglabel.h" + +//class MainWindow; + +class CommonCheckBox : public QWidget +{ + Q_OBJECT +public: + explicit CommonCheckBox(QWidget *parent = 0, const QString &picture= ""); + ~CommonCheckBox(); +// void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void initConnect(); + void setLabelText(const QString &title, int count); + int getCheckBoxStatus(); + +public slots: + void onZoneClicked(); + void resetMainStatus(int status); + +signals: + void customButtonClicked(); + void spreadStatus(int status); + +private: + QPushButton *img_btn; + QCheckBox *checkbox; + QLabel *name_label; + QLabel *description_label; + QPushButton *custom_btn; + +// MainWindow *p_mainwindow; +}; + +#endif // COMMONCHECKBOX_H diff --git a/component/commontoolbutton.cpp b/component/commontoolbutton.cpp new file mode 100644 index 0000000..17b73d2 --- /dev/null +++ b/component/commontoolbutton.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "commontoolbutton.h" + +CommonToolButton::CommonToolButton(const QString &pic_name, const QString &text, QWidget *parent) + :QToolButton(parent) +{ + setDown(false); + setFocusPolicy(Qt::NoFocus); + + this->setText(text); + +// QPalette text_palette = palette(); +// text_palette.setColor(QPalette::ButtonText, QColor(230, 230, 230)); +// setPalette(text_palette); + + setToolButtonStyle( Qt::ToolButtonTextUnderIcon); + setPopupMode(QToolButton::InstantPopup); + + QPixmap pixmap(pic_name); + normal_icon = QIcon(pic_name); + + setIcon(pixmap); + setIconSize(pixmap.size()); + +// setFixedSize(pixmap.width(), pixmap.height() + 10); + setAutoRaise(true); + this->setObjectName("commonToolButton"); + mouse_over = false; + mouse_press = false; +} + +CommonToolButton::~CommonToolButton() +{ + +} + +void CommonToolButton::enterEvent(QEvent *event) +{ + if(isEnabled()) + { + mouse_over = true; + } +} + +void CommonToolButton::leaveEvent(QEvent *event) +{ + if(isEnabled()) + { + mouse_over = false; + } +} + +void CommonToolButton::mousePressEvent(QMouseEvent *event) +{ + if(isEnabled() && event->button() == Qt::LeftButton) + { + emit clicked(); + } + QToolButton::mousePressEvent(event); +} + +void CommonToolButton::setMousePress(bool is_press) +{ + this->mouse_press = is_press; + update(); +} + +void CommonToolButton::paintEvent(QPaintEvent *event) +{ + if(this->mouse_over) + { + this->setIcon(QIcon(press_icon)); + } + else + { + if(this->mouse_press) + { + this->setIcon(QIcon(hover_icon)); + } + else + { + this->setIcon(QIcon(normal_icon)); + } + } + + QToolButton::paintEvent(event); +} diff --git a/component/commontoolbutton.h b/component/commontoolbutton.h new file mode 100644 index 0000000..b8edb81 --- /dev/null +++ b/component/commontoolbutton.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef COMMONOOlBUTTON_H +#define COMMONOOlBUTTON_H + +#include +#include + +class CommonToolButton : public QToolButton +{ + +public: + explicit CommonToolButton(const QString &pic_name, const QString &text , QWidget *parent = 0); + ~CommonToolButton(); + void setMousePress(bool is_press); + +protected: + void enterEvent(QEvent *event); + void leaveEvent(QEvent *event); + void mousePressEvent(QMouseEvent *event); + void paintEvent(QPaintEvent *event); + +public: + bool mouse_over; //鼠标是否移过 + bool mouse_press; //鼠标是否按下 + QIcon normal_icon; + QIcon hover_icon; + QIcon press_icon; +}; + +#endif //COMMONOOlBUTTON_H diff --git a/component/commonwidget.cpp b/component/commonwidget.cpp new file mode 100644 index 0000000..a0cb2ba --- /dev/null +++ b/component/commonwidget.cpp @@ -0,0 +1,12 @@ +#include "commonwidget.h" + +CommonWidget::CommonWidget(QWidget *parent) : + QWidget(parent) +{ + this->setFixedSize(110, 110); + this->setWindowFlags(Qt::FramelessWindowHint); + this->setAutoFillBackground(true); + QPalette palette; + palette.setColor(QPalette::Background, QColor(233,238,241));//#e9eef1 + this->setPalette(palette); +} diff --git a/component/commonwidget.h b/component/commonwidget.h new file mode 100644 index 0000000..c2205c5 --- /dev/null +++ b/component/commonwidget.h @@ -0,0 +1,18 @@ +#ifndef COMMONWIDGET_H +#define COMMONWIDGET_H + +#include + +class CommonWidget : public QWidget +{ + Q_OBJECT +public: + explicit CommonWidget(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // COMMONWIDGET_H diff --git a/component/itemcard.cpp b/component/itemcard.cpp new file mode 100644 index 0000000..41b192c --- /dev/null +++ b/component/itemcard.cpp @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "itemcard.h" +#include "ui_itemcard.h" +#include +#include + +ItemCard::ItemCard(QString title, bool flag, QWidget *parent) : + QWidget(parent), + ui(new Ui::ItemCard) +{ + ui->setupUi(this); + ui->deleteWidget->hide(); + ui->coverWidget->lower(); + ui->coverWidget->hide(); + dislayDelBtn = false; +// switchTimer = new QTimer(); +// connect(switchTimer, SIGNAL(timeout()), this, SLOT(slotSwitchAnimationStep())); + + //delay show animation + showDelay = false; + +// py = 87;//67 + if(flag) + iconDir = "/var/lib/youker-assistant-daemon/custom/"; + else + iconDir = "/var/lib/youker-assistant-daemon/default/"; + +// delayTimer = new QTimer(this); +// connect(delayTimer, SIGNAL(timeout()), this, SLOT(slotShowDelayAnimation())); + +// ui->deleteWidget->setAutoFillBackground(true); +// QPalette palette = ui->deleteWidget->palette(); +//// palette.setColor(QPalette::Background, QColor(100,100,100,50)); +// palette.setBrush(QPalette::Window, QBrush(Qt::red)); +//// palette.setBrush(QPalette::Base, QBrush(QColor(255,0,0,0))); +// ui->deleteWidget->setPalette(palette); + +// ui->deleteWidget->setStyleSheet("QWidget{background:transparent url(:/background/res/skin/1.png);icon-size:20px 5px}"); + ui->baseWidget->setStyleSheet("QWidget{background:transparent;}"); + ui->deleteWidget->setStyleSheet("QWidget{background:transparent url(://res/conceal.png);}"); + ui->coverWidget->setStyleSheet("QWidget{background:transparent url(://res/skin-cover.png);}"); + +// QPixmap pix = QPixmap("://res/menu-big-hover.png","0",Qt::AvoidDither|Qt::ThresholdDither|Qt::ThresholdAlphaDither); +// ui->baseWidget->setMask(pix.mask()); + + ui->deleteBtn->setFocusPolicy(Qt::NoFocus); + ui->deleteBtn->setCursor(Qt::PointingHandCursor); + ui->deleteBtn->setStyleSheet("QPushButton{background-image:url('://res/remove.png');border:0px;}"); +// ui->deleteBtn->setStyleSheet("QPushButton{background-image:url('://res/remove.png');border:0px;}QPushButton:hover{background:url('://res/cache_logo.png');}QPushButton:pressed{background:url('://res/cache_logo.png');}"); + connect(ui->deleteBtn, SIGNAL(clicked()), this, SLOT(onDeleteBtnClicked())); + if(title == "://res/create.png") { + iconpath = title; + ui->name->hide(); + this->setCursor(Qt::PointingHandCursor); + } + else { + iconpath = iconDir.append(title); + } +// ui->icon->setStyleSheet("QLabel{background-image:url('" + iconpath + "')}"); + ui->icon->installEventFilter(this); +// QPixmap pixmap; +// pixmap.copy(QRect(0,0,212,100)).save(iconpath); +// ui->icon->setPixmap(pixmap); + QPixmap pixmap(iconpath); + pixmap.copy(QRect(0,0,130,68)); + ui->icon->setPixmap(pixmap); + + ui->name->setStyleSheet("QLabel{background: transparent; font-size:13px;color:#666666;}"); + ui->name->setText(title.replace(".png", "").replace(".jpg", "")); + +// ui->using_label->setStyleSheet("QLabel{background: transparent;}"); + ui->using_label->setStyleSheet("QLabel{background-image:url('://res/choose.png')}"); +// ui->using_label->setAutoFillBackground(true); +// palette.setBrush(QPalette::Background, QBrush(QPixmap("://res/clothes.png"))); +// ui->using_label->setPalette(palette); + ui->using_label->hide(); +} + +ItemCard::~ItemCard() { +// if (switchTimer != NULL) { +// disconnect(switchTimer,SIGNAL(timeout()),this,SLOT(slotSwitchAnimationStep())); +// if(switchTimer->isActive()) { +// switchTimer->stop(); +// } +// delete switchTimer; +// switchTimer = NULL; +// } +// if (delayTimer != NULL) { +// disconnect(delayTimer,SIGNAL(timeout()),this,SLOT(slotShowDelayAnimation())); +// if(delayTimer->isActive()) { +// delayTimer->stop(); +// } +// delete delayTimer; +// delayTimer = NULL; +// } + delete ui; +} + +void ItemCard::resetdislayDelBtnValue(bool flag) +{ + if(flag) + this->dislayDelBtn = true; + else + this->dislayDelBtn = false; +} + +void ItemCard::onDeleteBtnClicked() +{ + emit this->sendDelteSignal(iconpath); +} + +void ItemCard::showUsingLogo(bool flag) +{ + if(flag) + ui->using_label->show(); + else + ui->using_label->hide(); +} + +QString ItemCard::getCardName() +{ + return this->iconpath; +} + +void ItemCard::enterEvent(QEvent *) +{ + emit this->sendEnterBackground(iconpath); + if(this->iconpath != "://res/create.png") + ui->coverWidget->show(); + if (this->dislayDelBtn) { + ui->deleteWidget->show(); +// this->delayTimer->start(300); + } +} + +void ItemCard::leaveEvent(QEvent *) +{ + emit this->sendLeaveBackground(); + if(this->iconpath != "://res/create.png") + ui->coverWidget->hide(); + if (this->dislayDelBtn) + ui->deleteWidget->hide(); +// if (this->delayTimer->isActive()) +// this->delayTimer->stop(); +// if (this->showDelay && this->dislayDelBtn) { +// this->showDelay = false; +// this->switchDirection = "down"; +// this->switchAnimation(); +// } +} + +void ItemCard::slotShowDelayAnimation() +{ +// if(this->delayTimer->isActive()) +// this->delayTimer->stop(); +// this->switchDirection = "up"; +// this->switchAnimation(); +// this->showDelay = true; +} + +void ItemCard::switchAnimation() +{ +// if(this->switchDirection == "up") +// { +// this->py = 87;//67 +// if(this->switchTimer->isActive()) +// this->switchTimer->stop(); +// this->switchTimer->start(30); +// } +// else +// { +// this->py = 48;//49 +// if(this->switchTimer->isActive()) +// this->switchTimer->stop(); +// this->switchTimer->start(30); +// } +} + +void ItemCard::slotSwitchAnimationStep() +{ +// if(this->switchDirection == "up") +// { +//// if(this->py < 0) +//// { +//// this->py += 3; +//// ui->deleteWidget->move(0, this->py); +//// } +//// else +//// { +//// if(this->switchTimer->isActive()) +//// this->switchTimer->stop(); +//// ui->deleteWidget->move(0, 0); +//// } +// if(this->py > 48)//49 +// { +// this->py -= 3; +// ui->deleteWidget->move(0, this->py); +// } +// else +// { +// if(this->switchTimer->isActive()) +// this->switchTimer->stop(); +// ui->deleteWidget->move(0, 48);// 49 +// } +// } +// else +// { +//// if(this->py <= 48 && this->py > -18)// if(this->py >= 49 && this->py < 67) +//// { +//// this->py -= 3; +//// ui->deleteWidget->move(0, this->py); +//// } +//// else +//// { +//// this->switchTimer->stop(); +//// ui->deleteWidget->move(0, -18);//67 +//// } +// if(this->py >= 48 && this->py < 87)// if(this->py >= 49 && this->py < 67) +// { +// this->py += 3; +// ui->deleteWidget->move(0, this->py); +// } +// else +// { +// this->switchTimer->stop(); +// ui->deleteWidget->move(0, 87);//67 +// } +// } +} + +bool ItemCard::eventFilter(QObject *obj, QEvent *event) +{ + if(obj == ui->icon){ + if(event->type() == QEvent::MouseButtonRelease){ + if (this->iconpath == "://res/create.png") + emit this->sendAddSignal(); + else + emit this->sendBackgroundName(iconpath); + } + } + return QObject::eventFilter(obj, event); +} diff --git a/component/itemcard.h b/component/itemcard.h new file mode 100644 index 0000000..d2941a1 --- /dev/null +++ b/component/itemcard.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef ITEMCARD_H +#define ITEMCARD_H + +#include +#include +#include +#include +#include +#include + +namespace Ui { +class ItemCard; +} + +class ItemCard : public QWidget +{ + Q_OBJECT + +public: + explicit ItemCard(QString title = "", bool flag = false, QWidget *parent = 0);//true:custom; false:system + ~ItemCard(); + void switchAnimation(); + void showUsingLogo(bool flag); + void resetdislayDelBtnValue(bool flag); + QString getCardName(); + +public slots: + void slotShowDelayAnimation(); + void slotSwitchAnimationStep(); + void onDeleteBtnClicked(); + +signals: + void sendBackgroundName(QString name); + void sendEnterBackground(QString name); + void sendLeaveBackground(); + void sendDelteSignal(QString name); + void sendAddSignal(); + +protected: + void enterEvent(QEvent *); + void leaveEvent(QEvent *); + bool eventFilter(QObject *obj, QEvent *event); + +private: + Ui::ItemCard *ui; +// QTimer *switchTimer; +// QTimer *delayTimer; + bool showDelay; + QString switchDirection; + int py; + QString iconDir; + QString iconpath; + bool dislayDelBtn; +}; + +#endif // ITEMCARD_H diff --git a/component/itemcard.ui b/component/itemcard.ui new file mode 100644 index 0000000..a3a3673 --- /dev/null +++ b/component/itemcard.ui @@ -0,0 +1,104 @@ + + + ItemCard + + + + 0 + 0 + 132 + 87 + + + + Form + + + + + 1 + 1 + 130 + 67 + + + + + + 0 + 0 + 130 + 67 + + + + + + + + + + 104 + 5 + 22 + 22 + + + + + + + + + + + 1 + 50 + 130 + 18 + + + + + + 3 + 2 + 16 + 14 + + + + + + + + + + + 5 + 67 + 122 + 20 + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 0 + 0 + 132 + 69 + + + + + + + diff --git a/component/kobemenu.cpp b/component/kobemenu.cpp new file mode 100644 index 0000000..b22e6fd --- /dev/null +++ b/component/kobemenu.cpp @@ -0,0 +1,65 @@ +#include "kobemenu.h" +#include "../mainui/mainwindow.h" +#include + +KobeMenu::KobeMenu(QWidget *parent) : + QWidget(parent) +{ + this->createActions(); + this->setLanguage(); +} + +void KobeMenu::createActions() +{ + help_action = new QToolButton(this); + features_action = new QToolButton(this); + feedback_action = new QToolButton(this); + setting_action = new QToolButton(this); + about_action = new QToolButton(this); + help_action->setIcon(QIcon(":/tool/res/menu/help.png")); + help_action->setIconSize(QPixmap(":/tool/res/menu/help.png").size()); + features_action->setIcon(QIcon(":/tool/res/menu/features.png")); + features_action->setIconSize(QPixmap(":/tool/res/menu/features.png").size()); + feedback_action->setIcon(QIcon(":/tool/res/menu/feedback.png")); + feedback_action->setIconSize( QPixmap(":/tool/res/menu/feedback.png").size()); + setting_action->setIcon(QIcon(":/tool/res/menu/setup.png")); + setting_action->setIconSize( QPixmap(":/tool/res/menu/setup.png").size()); + about_action->setIcon(QIcon(":/tool/res/menu/about.png")); + about_action->setIconSize( QPixmap(":/tool/res/menu/about.png").size()); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addWidget(help_action/*, 0, Qt::AlignTop*/); + layout->addWidget(features_action); + layout->addWidget(feedback_action); + layout->addWidget(setting_action); + layout->addWidget(about_action/*, 0, Qt::AlignBottom*/); + + layout->setMargin(0); + layout->setSpacing(5); + layout->setContentsMargins(5, 5, 5, 5); + + this->setLayout(layout); +} + +void KobeMenu::setLanguage() { + help_action->setText(tr("Forum Help")); + features_action->setText(tr("Features")); + feedback_action->setText(tr("Feedback")); + setting_action->setText(tr("Set up")); + about_action->setText(tr("About us")); +} + +void KobeMenu::initConnect() +{ + connect(help_action, SIGNAL(clicked()), this, SLOT(forumHelp())); + connect(help_action, SIGNAL(clicked()), p_mainwindow, SLOT(newFeatures())); + connect(help_action, SIGNAL(clicked()), p_mainwindow, SLOT(questionFeedback())); + connect(help_action, SIGNAL(clicked()), p_mainwindow, SLOT(setupConfigure())); + connect(help_action, SIGNAL(clicked()), p_mainwindow, SLOT(aboutUs())); +} + +void KobeMenu::forumHelp() +{ + QUrl url(QString("http://www.ubuntukylin.com/ukylin/forum.php")); + QDesktopServices::openUrl(url); +} diff --git a/component/kobemenu.h b/component/kobemenu.h new file mode 100644 index 0000000..0f96104 --- /dev/null +++ b/component/kobemenu.h @@ -0,0 +1,36 @@ +#ifndef KOBEMENU_H +#define KOBEMENU_H + +#include +#include +#include +#include + +class MainWindow; + +class KobeMenu : public QWidget +{ + Q_OBJECT +public: + explicit KobeMenu(QWidget *parent = 0); + void setLanguage(); + void initConnect(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + +private: + void createActions(); + +public slots: + void forumHelp(); + +private: + QToolButton *help_action; + QToolButton *features_action; + QToolButton *feedback_action; + QToolButton *setting_action; + QToolButton *about_action; + MainWindow *p_mainwindow; + +}; + +#endif // KOBEMENU_H diff --git a/component/kylinaction.cpp b/component/kylinaction.cpp new file mode 100644 index 0000000..56c561e --- /dev/null +++ b/component/kylinaction.cpp @@ -0,0 +1,43 @@ +#include "kylinaction.h" + +//KylinAction::KylinAction(const QString &text, QObject *parent) : QAction(text, parent) +//{ + +//} + +KylinAction::KylinAction(const QIcon &icon, const QString &text, QObject *parent) + : QAction(icon, text, parent) +{ + +} + +KylinAction::~KylinAction() +{ + +} + +void KylinAction::setSkinPath(const QString skinPath) +{ + this->mSkinPath = skinPath; +} + +const QString KylinAction::getSkinPath() +{ + return this->mSkinPath; +} + +void KylinAction::setRealName(const QString realName) +{ + this->mRealName = realName; +} + +const QString KylinAction::getRealName() +{ + return this->mRealName; +} + + +void KylinAction::hover() +{ + +} diff --git a/component/kylinaction.h b/component/kylinaction.h new file mode 100644 index 0000000..1476467 --- /dev/null +++ b/component/kylinaction.h @@ -0,0 +1,40 @@ +#ifndef __KYLINACTION_H__ +#define __KYLINACTION_H__ + +#include +//#include "qimpanelagent.h" + +//typedef enum SkinClass +//{ +// FCITX, +// SOGOU +//} SkinClass; + +class KylinAction : public QAction +{ + Q_OBJECT + +public: +// MyAction(const QString &text, QObject *parent); + KylinAction(const QIcon &icon, const QString &text, QObject *parent); + virtual ~KylinAction(); + +public: +// void setProp(const KimpanelProperty &prop); +// const KimpanelProperty& getProp(); + void setSkinPath(const QString skinPath); + const QString getSkinPath(); +// void setSkinClass(const SkinClass skinClass); +// SkinClass getSkinClass(); + void setRealName(const QString realName); + const QString getRealName(); +private: +// KimpanelProperty mProp; + QString mSkinPath; +// SkinClass mSkinClass; + QString mRealName; +public slots: + void hover(); +}; + +#endif // __KYLINACTION_H__ diff --git a/component/kylinbutton.cpp b/component/kylinbutton.cpp new file mode 100644 index 0000000..3b2fd09 --- /dev/null +++ b/component/kylinbutton.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylinbutton.h" + +KylinButton::KylinButton(QWidget *parent) + :QPushButton(parent) +{ + status = NORMAL; + mouse_press = false; +} + +KylinButton::~KylinButton() +{ + +} + +void KylinButton::setPicName(QString pic_name) +{ + this->pic_name = pic_name; + setFixedSize(QPixmap(pic_name).size()); +} + +void KylinButton::enterEvent(QEvent *) +{ + status = ENTER; + update(); +} + +void KylinButton::mousePressEvent(QMouseEvent *event) +{ + if(event->button() == Qt::LeftButton) + { + mouse_press = true; + status = PRESS; + update(); + } +} + +void KylinButton::mouseReleaseEvent(QMouseEvent *event) +{ + if(mouse_press && this->rect().contains(event->pos())) + { + mouse_press = false; + status = ENTER; + update(); + emit clicked(); + } +} + +void KylinButton::leaveEvent(QEvent *) +{ + status = NORMAL; + update(); +} + +void KylinButton::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + QPixmap pixmap; + switch(status) + { + case NORMAL: + { + pixmap.load(pic_name); + break; + } + case ENTER: + { + pixmap.load(pic_name + QString("_hover")); + break; + } + case PRESS: + { + pixmap.load(pic_name + QString("_pressed")); + break; + } + case NOSTATUS: + { + pixmap.load(pic_name); + break; + } + default: + pixmap.load(pic_name); + } + + painter.drawPixmap(rect(), pixmap); +} diff --git a/component/kylinbutton.h b/component/kylinbutton.h new file mode 100644 index 0000000..960865e --- /dev/null +++ b/component/kylinbutton.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINBUTTON_H +#define KYLINBUTTON_H + +#include +#include +#include + +class KylinButton : public QPushButton +{ + Q_OBJECT + +public: + explicit KylinButton(QWidget *parent = 0); + ~KylinButton(); + void setPicName(QString pic_name); + +protected: + void enterEvent(QEvent *); + void leaveEvent(QEvent *); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void paintEvent(QPaintEvent *); + +private: + //枚举按钮的几种状态 + enum ButtonStatus{NORMAL, ENTER, PRESS, NOSTATUS}; + ButtonStatus status; + QString pic_name; + + int btn_width; //按钮宽度 + int btn_height; //按钮高度 + bool mouse_press; //按钮左键是否按下 +}; + +#endif //KYLINBUTTON_H + diff --git a/component/kylincheckbox.cpp b/component/kylincheckbox.cpp new file mode 100644 index 0000000..314d46c --- /dev/null +++ b/component/kylincheckbox.cpp @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylincheckbox.h" +//#include "../component/kylintoolbutton.h" +//#include "mainwindow.h" +#include +#include +#include + +KylinCheckBox::KylinCheckBox(QWidget *parent, const QString &picture) + : QWidget(parent) +{ +// qDebug() << "init main....."; +// this->setFixedSize(260, 90); + //set white background color + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + img_btn = new QPushButton(); + img_btn->setFocusPolicy(Qt::NoFocus); + checkbox = new QCheckBox(this); + checkbox->setObjectName("mainCheckBox"); + checkbox->setTristate(true); + checkbox->setEnabled(true); + checkbox->setCheckState(Qt::Checked); + + name_label = new QLabel(); + name_label->setObjectName("middleblackLabel"); + name_label->setAlignment(Qt::AlignCenter); + description_label = new QLabel(); + description_label->setAlignment(Qt::AlignCenter); + description_label->setObjectName("smallgrayLabel"); + + + + +// custom_btn = new QPushButton(); +// custom_btn->setFocusPolicy(Qt::NoFocus); +// custom_btn->setObjectName("checkButton"); +// custom_btn->setCursor(Qt::PointingHandCursor); + +// img_btn->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小 +// QPixmap label_pixmap("://res/camera-uk.png"); +// img_btn->setPixmap(label_pixmap); +// img_btn->setFixedSize(label_pixmap.size()); + img_btn->setFocusPolicy(Qt::NoFocus); +// QPixmap pixmap("://res/camera-uk.png"); + QPixmap pixmap(picture); + img_btn->setIcon(pixmap); + img_btn->setIconSize(pixmap.size()); +// img_btn->setIconSize(QSize(72, 72)); + img_btn->setObjectName("transparentButton"); + +// checkbox->setAutoFillBackground(true); + checkbox->show(); +// checkbox->move(151-checkbox->width(), 0); + checkbox->move(152, 60); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(img_btn); + main_layout->addWidget(name_label); + main_layout->addWidget(description_label); +// main_layout->addWidget(custom_btn); + main_layout->setSpacing(5); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + + setLayout(main_layout); + this->initConnect(); + + +// suggest_label->setObjectName("whiteLabel"); +// result_label->setWordWrap(true);//QLabel自动换行 +// result_label->setObjectName("tipLabel"); + +// scan_button->setFixedSize(204, 65); +// scan_button->setFocusPolicy(Qt::NoFocus); +// QPixmap pixmap("://res/scan.png"); +// scan_button->setIcon(pixmap); +// scan_button->setIconSize(pixmap.size()); +// scan_button->setObjectName("greenButton"); +//// QFont scan_font = scan_button->font(); +//// scan_font.setPointSize(16); +//// scan_button->setFont(scan_font); +// back_button->setFocusPolicy(Qt::NoFocus); +// back_button->setFixedSize(50, 30); +// back_button->setObjectName("underlineButton"); + +// //set underline +// // QFont font = back_button->font(); +// // font.setUnderline(true); +// // back_button->setFont(font); + +// //set scan button text color +//// QPalette palette; +//// palette.setColor(QPalette::ButtonText, QColor(255,17,135)); +//// scan_button->setPalette(palette); +} + +KylinCheckBox::~KylinCheckBox() +{ + +} + +void KylinCheckBox::onZoneClicked() +{ + if(checkbox->checkState() == 0) { + checkbox->setCheckState(Qt::Checked); + emit this->spreadStatus(2); + } + else if(checkbox->checkState() == 1) { + checkbox->setCheckState(Qt::Checked); + emit this->spreadStatus(2); + } + else if(checkbox->checkState() == 2) { + checkbox->setCheckState(Qt::Unchecked); + emit this->spreadStatus(0); + } +} + +//sub item's change to make it work +void KylinCheckBox::resetMainStatus(int status) +{ + if(status == 0) { + checkbox->setCheckState(Qt::Unchecked); + } + else if(status == 1) { + checkbox->setCheckState(Qt::PartiallyChecked); + } + else if(status == 2) { + checkbox->setCheckState(Qt::Checked); + } +} + +void KylinCheckBox::initConnect() +{ +// connect(img_btn, SIGNAL(clicked()), this, SLOT(onZoneClicked())); +// connect(custom_btn, SIGNAL(clicked()), this, SIGNAL(customButtonClicked())); + connect(img_btn, SIGNAL(clicked()), this, SIGNAL(customButtonClicked())); +} + +void KylinCheckBox::setLabelText(const QString &name, const QString &tip) +{ +// QFont font(name_label->font()); +// QFontMetrics fm(font); +// name_label->setText(fm.elidedText(name), Qt::ElideRight, name_label->width()); +// description_label->setText(fm.elidedText(tip), Qt::ElideRight, description_label->width()); + + + QFont ft; + QFontMetrics fm(ft); + QString elided_text = fm.elidedText(name, Qt::ElideRight, 260); + name_label->setText(elided_text); + elided_text = fm.elidedText(tip, Qt::ElideRight, 260); + description_label->setText(elided_text); +} diff --git a/component/kylincheckbox.h b/component/kylincheckbox.h new file mode 100644 index 0000000..72483c8 --- /dev/null +++ b/component/kylincheckbox.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINCHECKBOX_H +#define KYLINCHECKBOX_H + +#include +#include +#include +#include +//#include +//#include +//#include +//#include +//#include "../component/kylinbutton.h" +//#include "../component/kylintoolbutton.h" +//#include "../component/systembutton.h" +//#include "../component/loadinglabel.h" + +//class MainWindow; + +class KylinCheckBox : public QWidget +{ + Q_OBJECT +public: + explicit KylinCheckBox(QWidget *parent = 0, const QString &picture= ""); + ~KylinCheckBox(); +// void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void initConnect(); + void setLabelText(const QString &name, const QString &tip); + +public slots: + void onZoneClicked(); + void resetMainStatus(int status); + +signals: + void customButtonClicked(); + void spreadStatus(int status); + +private: + QPushButton *img_btn; + QCheckBox *checkbox; + QLabel *name_label; + QLabel *description_label; +// QPushButton *custom_btn; + +// MainWindow *p_mainwindow; +}; + +#endif // KYLINCHECKBOX_H diff --git a/component/kylineditbutton.cpp b/component/kylineditbutton.cpp new file mode 100644 index 0000000..804f09a --- /dev/null +++ b/component/kylineditbutton.cpp @@ -0,0 +1,23 @@ +#include "kylineditbutton.h" +#include +#include + +KylinEditButton::KylinEditButton(QLineEdit *edit) + : QPushButton(edit) +{ + QSize size = QSize(40, edit->sizeHint().height()); +// setMinimumSize(size); +// setMaximumSize(size); + this->setFocusPolicy(Qt::NoFocus); + this->setFlat(true); + this->setIcon(QIcon("://res/folder.png")); + this->setIconSize(QSize(16, 16)); + this->setCursor(QCursor(Qt::PointingHandCursor)); + + QHBoxLayout *layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->addStretch(); + layout->addWidget(this); + edit->setLayout(layout); + edit->setTextMargins(0, 1, size.width(), 1); +} diff --git a/component/kylineditbutton.h b/component/kylineditbutton.h new file mode 100644 index 0000000..48227be --- /dev/null +++ b/component/kylineditbutton.h @@ -0,0 +1,14 @@ +#ifndef KYLINEDITBUTTON_H +#define KYLINEDITBUTTON_H + +#include +class QLineEdit; + +class KylinEditButton : public QPushButton +{ + Q_OBJECT +public: + KylinEditButton(QLineEdit *edit); +}; + +#endif // KYLINEDITBUTTON_H diff --git a/component/kylinfontdialog.cpp b/component/kylinfontdialog.cpp new file mode 100644 index 0000000..92b1418 --- /dev/null +++ b/component/kylinfontdialog.cpp @@ -0,0 +1,475 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylinfontdialog.h" +#include +#include +#include +#include +#include +#include +#include +#include + +KylinFontDialog::KylinFontDialog(/*QSettings *mSettings, QString flag, */QString cur_font, QString skin, QWidget *parent) : + QDialog(parent) +{ + this->setFixedSize(600, 500); + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + this->setAttribute(Qt::WA_DeleteOnClose); + this->setWindowFlags(Qt::FramelessWindowHint); + this->setAutoFillBackground(true); + + title_bar = new KylinTitleBar(); + initTitleBar(skin); + + cur_tip_label = new QLabel(); + cur_font_label = new QLabel(); + font_label = new QLabel(); + style_label = new QLabel(); + size_label = new QLabel(); + font_edit = new QLineEdit(); + style_edit = new QLineEdit(); + size_edit = new QLineEdit(); + font_view = new QListView(); + style_view = new QListView(); + size_view = new QListView(); + sample_label = new QLabel(); + sample_edit = new QLineEdit(); + ok_btn = new QPushButton(); + cacel_btn = new QPushButton(); + ok_btn->setFixedSize(91, 25); + ok_btn->setObjectName("blackButton"); + ok_btn->setFocusPolicy(Qt::NoFocus); + cacel_btn->setFixedSize(91, 25); + cacel_btn->setObjectName("blackButton"); + cacel_btn->setFocusPolicy(Qt::NoFocus); + font_edit->setStyleSheet("QLineEdit{border:1px solid #bebebe;}"); + style_edit->setStyleSheet("QLineEdit{border:1px solid #bebebe;}"); + size_edit->setStyleSheet("QLineEdit{border:1px solid #bebebe;}"); + sample_edit->setStyleSheet("QLineEdit{border:1px solid #bebebe;}"); + + style_label->setFixedWidth(140); + style_edit->setFixedWidth(140); + style_view->setFixedWidth(140); + size_label->setFixedWidth(60); + size_edit->setFixedWidth(60); + size_view->setFixedWidth(60); + + font_edit->setReadOnly(true); + font_edit->setFocusProxy(font_view); + font_label->setBuddy(font_view); + style_edit->setReadOnly(true); + style_edit->setFocusProxy(style_view); + style_label->setBuddy(style_view); + size_edit->setReadOnly(true); + size_edit->setFocusProxy(size_view); + size_label->setBuddy(size_view); + sample_edit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored)); + sample_edit->setAlignment(Qt::AlignCenter); + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->addWidget(cur_tip_label); + layout1->addWidget(cur_font_label); + layout1->addStretch(); + layout1->setSpacing(5); + layout1->setMargin(0); + layout1->setContentsMargins(10, 0, 0, 0); + + QVBoxLayout *layout2 = new QVBoxLayout(); + layout2->addWidget(font_label); + layout2->addWidget(font_edit); + layout2->addWidget(font_view); + + QVBoxLayout *layout3 = new QVBoxLayout(); + layout3->addWidget(style_label); + layout3->addWidget(style_edit); + layout3->addWidget(style_view); + + QVBoxLayout *layout4 = new QVBoxLayout(); + layout4->addWidget(size_label); + layout4->addWidget(size_edit); + layout4->addWidget(size_view); + + QHBoxLayout *layout5 = new QHBoxLayout(); + layout5->addLayout(layout2); + layout5->addLayout(layout3); + layout5->addLayout(layout4); + layout5->setSpacing(10); + layout5->setMargin(0); + layout5->setContentsMargins(10, 0, 10, 0); + + QVBoxLayout *layout6 = new QVBoxLayout(); + layout6->addWidget(cacel_btn); + layout6->addWidget(ok_btn); + + QHBoxLayout *layout7 = new QHBoxLayout(); + layout7->addWidget(sample_edit); +// layout7->addStretch(); + layout7->addLayout(layout6); + + QVBoxLayout *layout8 = new QVBoxLayout(); + layout8->addWidget(sample_label); + layout8->addLayout(layout7); + layout8->setSpacing(5); + layout8->setMargin(0); + layout8->setContentsMargins(10, 0, 10, 10); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(title_bar); + main_layout->addLayout(layout1); + main_layout->addLayout(layout5); + main_layout->addLayout(layout8); + main_layout->setSpacing(5); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + setLayout(main_layout); + cur_font_label->setText(cur_font); + + familymodel = new QStringListModel; + stylemodel = new QStringListModel; + sizemodel = new QStringListModel; + + this->initDialog();//初始化字体对话框 + this->setLanguage(); + this->initConnect(); +} + +KylinFontDialog::~KylinFontDialog() +{ + if (familymodel != NULL) { + delete familymodel; + familymodel = NULL; + } + if (stylemodel != NULL) { + delete stylemodel; + stylemodel = NULL; + } + if (sizemodel != NULL) { + delete sizemodel; + sizemodel = NULL; + } + if (title_bar != NULL) { + delete title_bar; + title_bar = NULL; + } + if (cur_tip_label != NULL) { + delete cur_tip_label; + cur_tip_label = NULL; + } + if (cur_font_label != NULL) { + delete cur_font_label; + cur_font_label = NULL; + } + if (font_label != NULL) { + delete font_label; + font_label = NULL; + } + if (style_label != NULL) { + delete style_label; + style_label = NULL; + } + if (size_label != NULL) { + delete size_label; + size_label = NULL; + } + if (font_edit != NULL) { + delete font_edit; + font_edit = NULL; + } + if (style_edit != NULL) { + delete style_edit; + style_edit = NULL; + } + if (size_edit != NULL) { + delete size_edit; + size_edit = NULL; + } + if (font_view != NULL) { + delete font_view; + font_view = NULL; + } + if (style_view != NULL) { + delete style_view; + style_view = NULL; + } + if (size_view != NULL) { + delete size_view; + size_view = NULL; + } + if (sample_label != NULL) { + delete sample_label; + sample_label = NULL; + } + if (sample_edit != NULL) { + delete sample_edit; + sample_edit = NULL; + } + if (ok_btn != NULL) { + delete ok_btn; + ok_btn = NULL; + } + if (cacel_btn != NULL) { + delete cacel_btn; + cacel_btn = NULL; + } +} + +void KylinFontDialog::setLanguage() +{ + cur_tip_label->setText(tr("Current Font") + ":"); + font_label->setText(tr("Font")); + style_label->setText(tr("Style")); + size_label->setText(tr("Size")); + sample_label->setText(tr("View")); + ok_btn->setText(tr("OK")); + cacel_btn->setText(tr("Cancel")); +} + +void KylinFontDialog::initConnect() +{ +// connect(title_bar, SIGNAL(showMinDialog()), this, SLOT(onMinButtonClicked())); + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCacelButtonClicked())); + connect(font_view, SIGNAL(clicked(QModelIndex)), this, SLOT(updateAll(QModelIndex))); + connect(style_view, SIGNAL(clicked(QModelIndex)), this, SLOT(updateStyleandSize(QModelIndex))); + connect(size_view, SIGNAL(clicked(QModelIndex)), this, SLOT(updateSize(QModelIndex))); + connect(cacel_btn, SIGNAL(clicked()), this, SLOT(onCacelButtonClicked())); + connect(ok_btn, SIGNAL(clicked()), this, SLOT(onOKButtonClicked())); +} + +void KylinFontDialog::onCacelButtonClicked() +{ + this->close(); +} + +void KylinFontDialog::onOKButtonClicked() { + if(font_edit->text().isEmpty()) { + //提示 您还没有更换字体,请选择字体进行更换! + QMessageBox::warning(NULL, + tr("Tips"), + tr("You haven't change the font, please choose the font!"), + QMessageBox::Ok); + } + else { + selectedFont = font_edit->text().append(" ").append(style_edit->text().append(" ").append(size_edit->text())); + emit this->rebackCurrentFont(selectedFont); + this->accept(); + } +} + +void KylinFontDialog::initTitleBar(QString skin) +{ + title_bar->setTitleWidth(600); + title_bar->setTitleName(tr("Font Dialog")); +// title_bar->setTitleBackgound(":/background/res/skin/1.png"); + title_bar->setTitleBackgound(skin); +} + +void KylinFontDialog::initDialog() { + //列出所有字体的名字 + QStringList familyNames = fdb.families(); + familymodel->setStringList(familyNames); + font_view->setModel(familymodel); + QModelIndex index; + index = familymodel->index(0); + font_view->setCurrentIndex(index); + + //列出系统对应的所有风格 + QStringList familystyles = fdb.styles(font_view->currentIndex().data().toString()); + stylemodel->setStringList(familystyles); + style_view->setModel(stylemodel); + index = stylemodel->index(0); + style_view->setCurrentIndex(index); + + //列出所有字体及其风格对应的所有大小 + QList sizes = fdb.pointSizes(font_view->currentIndex().data().toString(), style_view->currentIndex().data().toString()); + QStringList str_sizes; + for(QList::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) { + str_sizes.append(QString::number(*it)); + } + sizemodel->setStringList(str_sizes); + size_view->setModel(sizemodel); + //默认的字体大小显示为11 + bool flag = false; + int row = -1; + for(QStringList::Iterator m = str_sizes.begin(); m != str_sizes.end(); ++m) { + row++; + QString size = *m; + if("11" == size) {//默认字体大小存在列表中 + index = sizemodel->index(row); + size_view->setCurrentIndex(index); + flag = true; + break; + } + } + if(flag == false) {//11不存在列表中,此时让光标定位在第一个大小上面 + index = sizemodel->index(0); + size_view->setCurrentIndex(index); + } +} + +void KylinFontDialog::updateSampleFont() { + QFont font(fdb.font(font_edit->text(), style_edit->text(), size_edit->text().toInt())); + if (font != sample_edit->font()) { + sample_edit->setFont(font); + } +} + +void KylinFontDialog::updateAll(QModelIndex index) { + font_edit->setText(index.data().toString()); + QModelIndex styleindex = stylemodel->index(0); + + //更新stylemodel + QStringList familystyles = fdb.styles(font_edit->text()); + stylemodel->setStringList(familystyles); + style_view->setModel(stylemodel); + //设置光标默认值 + style_view->setCurrentIndex(styleindex); + style_edit->setText(style_view->currentIndex().data().toString()); + + //列出所有字体及其风格对应的所有大小 + //更新sizemodel + bool sizeFlag = false; + int num = 0; + QList sizes = fdb.pointSizes(font_edit->text(), style_edit->text()); + QStringList str_sizes; + int row = -1; + for(QList::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) { + row++; + str_sizes.append(QString::number(*it)); + if(*it == 11) { + sizeFlag = true; + num = row; + } + } + sizemodel->setStringList(str_sizes); + size_view->setModel(sizemodel); + QModelIndex sizeindex; + //更新时如果大小列表中存在11,则大小的默认值设为11 + if(sizeFlag == false) { + sizeindex = sizemodel->index(0); + size_view->setCurrentIndex(sizeindex); + size_edit->setText(size_view->currentIndex().data().toString()); + } + else { + sizeFlag = false; + sizeindex = sizemodel->index(num); + size_view->setCurrentIndex(sizeindex); + size_edit->setText(size_view->currentIndex().data().toString()); + } + QString curStr = font_edit->text().append(" ").append(style_edit->text().append(" ").append(size_edit->text())); + cur_font_label->setText(curStr); + sample_edit->setText("Ubuntu Kylin:做最有中国味的操作系统!"); + updateSampleFont(); +} + +void KylinFontDialog::updateStyleandSize(QModelIndex index) { + style_edit->setText(index.data().toString()); + + //列出所有字体及其风格对应的所有大小 + //更新sizemodel + bool sizeFlag = false; + int num = 0; + QList sizes = fdb.pointSizes(font_edit->text(), style_edit->text()); + QStringList str_sizes; + int row = -1; + for(QList::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) { + row++; + str_sizes.append(QString::number(*it)); + if(*it == 11) { + sizeFlag = true; + num = row; + } + } + sizemodel->setStringList(str_sizes); + size_view->setModel(sizemodel); + //更新时如果大小列表中存在11,则大小的默认值设为11 + QModelIndex sizeindex; + if(sizeFlag == false) { + sizeindex = sizemodel->index(0); + size_view->setCurrentIndex(sizeindex); + size_edit->setText(size_view->currentIndex().data().toString()); + } + else { + sizeFlag = false; + sizeindex = sizemodel->index(num); + size_view->setCurrentIndex(sizeindex); + size_edit->setText(size_view->currentIndex().data().toString()); + } + + QString curfont = font_edit->text(); + if(!curfont.isEmpty()) { + QString curStr = font_edit->text().append(" ").append(style_edit->text().append(" ").append(size_edit->text())); + cur_font_label->setText(curStr); + updateSampleFont(); + } +} + +void KylinFontDialog::updateSize(QModelIndex index) { + size_edit->setText(index.data().toString()); + QString curfont = font_edit->text(); + if(!curfont.isEmpty()) { + QString curStr = font_edit->text().append(" ").append(style_edit->text().append(" ").append(size_edit->text())); + cur_font_label->setText(curStr); + updateSampleFont(); + } +} + +void KylinFontDialog::resetTitleSkin(QString skin) +{ + title_bar->resetBackground(skin); +} + +bool KylinFontDialog::eventFilter(QObject *obj, QEvent *event) { + if(obj == ok_btn ||obj == cacel_btn) + { + if(event->type() == QEvent::MouseButtonPress) + { + QMouseEvent *me = (QMouseEvent *)event; + dragPos = me->globalPos() - frameGeometry().topLeft(); + }else if(event->type() == QEvent::MouseButtonRelease) + { + setWindowOpacity(1); + } + } + return QObject::eventFilter(obj, event); +} + +void KylinFontDialog::mousePressEvent(QMouseEvent *event) { + if (event->button() == Qt::LeftButton) { + dragPos = event->globalPos() - frameGeometry().topLeft(); + event->accept(); + } +} + +void KylinFontDialog::mouseMoveEvent(QMouseEvent *event) { + if (event->buttons() & Qt::LeftButton ) { + move(event->globalPos() - dragPos); + setWindowOpacity(1);//0.5 + } + event->accept(); +} + +void KylinFontDialog::mouseReleaseEvent(QMouseEvent *event) { + if (event->button() == Qt::LeftButton) { + setWindowOpacity(1); + } + event->accept(); +} diff --git a/component/kylinfontdialog.h b/component/kylinfontdialog.h new file mode 100644 index 0000000..5a22664 --- /dev/null +++ b/component/kylinfontdialog.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINFONTDIALOG_H +#define KYLINFONTDIALOG_H + +#include +#include +#include +#include +#include "kylintitlebar.h" +#include + +class QSettings; +//namespace Ui { +//class KylinFontDialog; +//} + +class KylinFontDialog : public QDialog +{ + Q_OBJECT + +public: + explicit KylinFontDialog(/*QSettings *mSettings = 0, QString flag = "", */QString cur_font = "", QString skin = ":/background/res/skin/1.png", QWidget *parent = 0); + ~KylinFontDialog(); + void initDialog(); + void setLanguage(); + void initConnect(); + void initTitleBar(QString skin); + void updateSampleFont(); + void resetTitleSkin(QString skin); + +public slots: + void onCacelButtonClicked(); +// void onMinButtonClicked(); + void onOKButtonClicked(); + +signals: + void rebackCurrentFont(QString cur_font); + +protected slots: + void updateAll(QModelIndex index); + void updateStyleandSize(QModelIndex index); + void updateSize(QModelIndex index); + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + bool eventFilter(QObject *obj, QEvent *event); + +private: +// Ui::KylinFontDialog *ui; +// QSettings *pSettings; + QFontDatabase fdb; +// QString fontFlag;//字体标记 + QStringListModel *familymodel; + QStringListModel *stylemodel; + QStringListModel *sizemodel; + QPoint dragPos; + QString selectedFont; + KylinTitleBar *title_bar; + + QLabel *cur_tip_label; + QLabel *cur_font_label; + QLabel *font_label; + QLabel *style_label; + QLabel *size_label; + QLineEdit *font_edit; + QLineEdit *style_edit; + QLineEdit *size_edit; + QListView *font_view; + QListView *style_view; + QListView *size_view; + QLabel *sample_label; + QLineEdit *sample_edit; + QPushButton *ok_btn; + QPushButton *cacel_btn; +}; + +#endif // KYLINFONTDIALOG_H diff --git a/component/kylinfontdialog.ui b/component/kylinfontdialog.ui new file mode 100644 index 0000000..4380c2a --- /dev/null +++ b/component/kylinfontdialog.ui @@ -0,0 +1,216 @@ + + + KylinFontDialog + + + + 0 + 0 + 512 + 390 + + + + Dialog + + + + + 0 + 0 + 512 + 30 + + + + + + + 0 + 30 + 512 + 359 + + + + + + 126 + 10 + 371 + 20 + + + + <html><head/><body><p><br/></p></body></html> + + + + + + 444 + 59 + 51 + 27 + + + + + + + 14 + 9 + 111 + 20 + + + + <html><head/><body><p><span style=" font-weight:600;">Current Font:</span></p></body></html> + + + + + + 250 + 39 + 71 + 17 + + + + Style + + + + + + 444 + 39 + 91 + 17 + + + + Size + + + + + + 16 + 59 + 211 + 27 + + + + + + + 16 + 39 + 71 + 17 + + + + Font + + + + + + 250 + 59 + 171 + 27 + + + + + + + 445 + 90 + 51 + 161 + + + + + + + 17 + 90 + 211 + 161 + + + + + + + 251 + 90 + 171 + 161 + + + + + + + 426 + 320 + 70 + 28 + + + + OK + + + + + + 426 + 280 + 70 + 28 + + + + Cancel + + + + + + 20 + 260 + 81 + 17 + + + + View + + + + + + 20 + 280 + 391 + 71 + + + + + + + + + + + diff --git a/component/kylinlistmodel.cpp b/component/kylinlistmodel.cpp new file mode 100644 index 0000000..2a44458 --- /dev/null +++ b/component/kylinlistmodel.cpp @@ -0,0 +1,133 @@ +#include "kylinlistmodel.h" +#include + +KylinListModel::KylinListModel() +{ +} + +KylinListModel::~KylinListModel() +{ +} + +QModelIndex KylinListModel::index ( int row, + int column, + const QModelIndex & parent) const +{ + if (row >= 0 && row < rowCount() && column >= 0 && column < columnCount()) + { + QStandardItem* item = m_data.at(row); +// item->setSizeHint(QSize(80,130)); + return createIndex (row, column, (void *)(item)); + } + return QModelIndex(); +} + +int KylinListModel::rowCount ( const QModelIndex & parent ) const +{ + return m_data.count(); +} + +int KylinListModel::columnCount ( const QModelIndex & parent ) const +{ + return m_title.count(); +} +bool KylinListModel::insertRows ( int row, int count, const QModelIndex & parent) +{ + beginInsertRows(QModelIndex(), row, row + count - 1); + for (int i = 0; i < count; ++i) + { + QStandardItem *item = new QStandardItem(); +// item->setSizeHint(QSize(80,130)); +// item->setFont(QFont("微软雅黑",10,1)); +// QPixmap pix("://res/box-hover.png"); +// QBrush brush(pix); +// item->setBackground(brush); + m_data.insert (row,item); + } + endInsertRows(); + return true; +} + +bool KylinListModel::insertColumns ( int column, int count, const QModelIndex & ) +{ + return true; +} + +bool KylinListModel::removeRows ( int row, int count, const QModelIndex & parent ) +{ + return true; +} + +bool KylinListModel::removeColumns ( int column, int count, const QModelIndex & parent ) +{ + return true; +} + +QVariant KylinListModel::data ( const QModelIndex & index, int role ) const +{ + if (!index.isValid()) + { + return QVariant(); + } + if (role == Qt::DisplayRole) + { + QStandardItem* item = m_data.at(index.row()); +// item->setSizeHint(QSize(80,130)); + return QVariant(item->text()); + + } + if (role == Qt::DecorationRole) + { + QStandardItem* item = m_data.at(index.row()); +// item->setSizeHint(QSize(80,130)); + return QVariant(item->icon()); + } + + if (role == Qt::WhatsThisRole) + { + QStandardItem* item = m_data.at(index.row()); +// item->setSizeHint(QSize(80,130)); + return item->toolTip(); + } + return QVariant(); +} + +bool KylinListModel::setData ( const QModelIndex & index, + const QVariant & value, + int role) +{ + + if (index.isValid() && role == Qt::EditRole) + { + QStandardItem* item = m_data.at(index.row()); +// item->setSizeHint(QSize(80,130)); + item->setText(value.toString()); + emit dataChanged(index, index); + return true; + } + if (role == Qt::DecorationRole) + { + QStandardItem* item = m_data.at(index.row()); +// item->setSizeHint(QSize(80,130)); + item->setIcon(value.value()); + return true; + } + if (role == Qt::WhatsThisRole) + { + QStandardItem* item = m_data.at(index.row()); +// item->setSizeHint(QSize(80,130)); + item->setToolTip(value.toString()); + return true; + } + return false; +} + +QVariant KylinListModel::headerData(int section, Qt::Orientation orientation ,int role) const +{ + + if (role == Qt::DisplayRole && orientation == Qt::Horizontal) + { + return m_title.at(0); + } + return QVariant(); +} diff --git a/component/kylinlistmodel.h b/component/kylinlistmodel.h new file mode 100644 index 0000000..7a29ca0 --- /dev/null +++ b/component/kylinlistmodel.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include +#include +class KylinListModel : public QAbstractListModel +{ +public: + KylinListModel(); + ~KylinListModel(); + virtual QModelIndex index (int row, int column = 0, const QModelIndex & parent = QModelIndex()) const; + QVariant data (const QModelIndex & index, int role = Qt::DisplayRole ) const; + virtual bool setData (const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); + int rowCount (const QModelIndex & parent = QModelIndex() ) const; + int columnCount (const QModelIndex & parent = QModelIndex() ) const; + bool insertRows (int row, int count, const QModelIndex & parent = QModelIndex()); + bool insertColumns (int column, int count, const QModelIndex & parent = QModelIndex()); + bool removeRows (int row, int count, const QModelIndex & parent = QModelIndex() ); + bool removeColumns (int column, int count, const QModelIndex & parent = QModelIndex()); + QVariant headerData(int section,Qt::Orientation,int role) const; + void setTitle(QStringList title) { m_title = title;} + void setGuid(QString guid) { m_guid_list.append(guid);} + QString getGuid(int index) { return m_guid_list.at(index);} + +private: + QList m_data; + QStringList m_title; + QStringList m_guid_list; +}; diff --git a/component/kylinlistview.cpp b/component/kylinlistview.cpp new file mode 100644 index 0000000..cb497a4 --- /dev/null +++ b/component/kylinlistview.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylinlistview.h" +#include +#include +#include + +KylinListView::KylinListView(QWidget *parent) + : QListView(parent) +{ +} + +KylinListView::~KylinListView() +{ + +} + +bool KylinListView::viewportEvent(QEvent *pEvent) +{ + bool bRes = QAbstractItemView::viewportEvent(pEvent); + QEvent::Type enumType = pEvent->type(); + switch (enumType) + { + case QEvent::HoverEnter: + { + qDebug() << "hover enter......"; + } + break; + case QEvent::HoverLeave: + { + qDebug() << "hover leave......"; + } + break; + case QEvent::HoverMove: + { + qDebug() << "hover move......"; + } + break; + default: + break; + } + return QAbstractItemView::viewportEvent(pEvent); +} diff --git a/component/kylinlistview.h b/component/kylinlistview.h new file mode 100644 index 0000000..590fd00 --- /dev/null +++ b/component/kylinlistview.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINLISTVIEW_H +#define KYLINLISTVIEW_H + +#include + +class KylinListView : public QListView +{ + Q_OBJECT +public: + KylinListView(QWidget *parent); + ~KylinListView(); + +protected: + virtual bool viewportEvent(QEvent *pEvent); + +private: + +}; + +#endif // KYLINLISTVIEW_H diff --git a/component/kylinlistwidget.cpp b/component/kylinlistwidget.cpp new file mode 100644 index 0000000..089b0f8 --- /dev/null +++ b/component/kylinlistwidget.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include "kylinlistwidget.h" +#include "kylinlistwidgetitem.h" +#include "mainwindow.h" + +KylinListWidget::KylinListWidget(QWidget *parent) + :QListWidget(parent) +{ + connect(this, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(onItemClicked(QListWidgetItem*))); +} + +KylinListWidget::~KylinListWidget() +{ +} + +void KylinListWidget::onItemClicked(QListWidgetItem *item) +{ + KylinListWidgetItem* listitem = static_cast(item); + emit this->sendBackgroundName(listitem->getSkinName()); + mainwindow->changeSkin(listitem->getSkinName()); +} + +void KylinListWidget::leaveEvent (QEvent *event) +{ + mainwindow->reViewTheOrgSkin(); +} + +void KylinListWidget::mouseMoveEvent(QMouseEvent *event) +{ + QPoint point = event->pos(); + KylinListWidgetItem *item = (KylinListWidgetItem*)itemAt(point); + if (item) + { + item->paintPointSkin(); + } + event->ignore(); +} diff --git a/component/kylinlistwidget.h b/component/kylinlistwidget.h new file mode 100644 index 0000000..7ff5068 --- /dev/null +++ b/component/kylinlistwidget.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINLISTWIDGET_H +#define KYLINLISTWIDGET_H + +#include +class MainWindow; + +class KylinListWidget : public QListWidget +{ + Q_OBJECT +public: + KylinListWidget(QWidget *parent = 0); + ~KylinListWidget(); + void setMainWindow(MainWindow* window) { mainwindow = window;} + +public slots: + void onItemClicked(QListWidgetItem *item); + +signals: + void sendBackgroundName(QString name); + +protected: + virtual void leaveEvent (QEvent *event); + virtual void mouseMoveEvent(QMouseEvent *event); + +private: + MainWindow *mainwindow; +}; + +#endif // KYLINLISTWIDGET_H diff --git a/component/kylinlistwidgetitem.cpp b/component/kylinlistwidgetitem.cpp new file mode 100644 index 0000000..fa38692 --- /dev/null +++ b/component/kylinlistwidgetitem.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylinlistwidgetitem.h" +#include "mainwindow.h" + +KylinListWidgetItem::KylinListWidgetItem(const QIcon &icon, const QString &text, QListWidget *view, int type) + :QListWidgetItem(icon,text,view,type) +{ + mainwindow = NULL; +} + +KylinListWidgetItem::~KylinListWidgetItem() +{ +} + +void KylinListWidgetItem::paintPointSkin() +{ + mainwindow->reViewThePointSkin(point_skin); +} diff --git a/component/kylinlistwidgetitem.h b/component/kylinlistwidgetitem.h new file mode 100644 index 0000000..25487a0 --- /dev/null +++ b/component/kylinlistwidgetitem.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * 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 . + */ + +#pragma once + +#include +class MainWindow; + +class KylinListWidgetItem :public QListWidgetItem +{ +public: + KylinListWidgetItem(const QIcon &icon, const QString &text, QListWidget *view = 0, int type = Type); + ~KylinListWidgetItem(); + void paintPointSkin(); + void setMainWindow(MainWindow *window) { mainwindow = window; } + void setSkinName(QString picture) {point_skin = picture;} + QString getSkinName() {return point_skin;} + +private: + MainWindow *mainwindow; + QString point_skin; +}; diff --git a/component/kylinmenu.cpp b/component/kylinmenu.cpp new file mode 100644 index 0000000..5130b43 --- /dev/null +++ b/component/kylinmenu.cpp @@ -0,0 +1,261 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylinmenu.h" +#include "../mainui/mainwindow.h" +#include +#include + +KylinMenu::KylinMenu(QWidget *widget) + : QMenu(widget) +{ + this->createActions(); + this->setLanguage(); +} + +KylinMenu::~KylinMenu() +{ + if(check_label != NULL) + { + delete check_label; + check_label = NULL; + } + if(help_label != NULL) + { + delete help_label; + help_label = NULL; + } + if(feedback_label != NULL) + { + delete feedback_label; + feedback_label = NULL; + } + if(about_label != NULL) + { + delete about_label; + about_label = NULL; + } + if(check_button != NULL) + { + delete check_button; + check_button = NULL; + } + if(help_button != NULL) + { + delete help_button; + help_button = NULL; + } + if(feedback_button != NULL) + { + delete feedback_button; + feedback_button = NULL; + } + if(about_button != NULL) + { + delete about_button; + about_button = NULL; + } + if(check_widget != NULL) + { + delete check_widget; + check_widget = NULL; + } + if(help_widget != NULL) + { + delete help_widget; + help_widget = NULL; + } + if(feedback_widget != NULL) + { + delete feedback_widget; + feedback_widget = NULL; + } + if(about_widget != NULL) + { + delete about_widget; + about_widget = NULL; + } +} + +void KylinMenu::createActions() +{ +// help_action = new QAction(this); +//// features_action = new QAction(this); +// feedback_action = new QAction(this); +//// setting_action = new QAction(this); +// about_action = new QAction(this); + check_widget = new QWidget(); + help_widget = new QWidget(); + feedback_widget = new QWidget(); + about_widget = new QWidget(); + check_widget_action = new QWidgetAction(this); + help_widget_action = new QWidgetAction(this); + feedback_widget_action = new QWidgetAction(this); + about_widget_action = new QWidgetAction(this); + check_label = new QLabel(); + help_label = new QLabel(); + feedback_label = new QLabel(); + about_label = new QLabel(); + check_button = new QPushButton(); + help_button = new QPushButton(); + feedback_button = new QPushButton(); + about_button = new QPushButton(); + check_button->setStyleSheet("QPushButton{background:transparent;text-align:left;font-family: 方正黑体_GBK;font-size:14px;color:#666666;}QPushButton:hover{color:#0396DC;}"); + help_button->setStyleSheet("QPushButton{background:transparent;text-align:left;font-family: 方正黑体_GBK;font-size:14px;color:#666666;}QPushButton:hover{color:#0396DC;}"); + feedback_button->setStyleSheet("QPushButton{background:transparent;text-align:left;font-family: 方正黑体_GBK;font-size:14px;color:#666666;}QPushButton:hover{color:#0396DC;}"); + about_button->setStyleSheet("QPushButton{background:transparent;text-align:left;font-family: 方正黑体_GBK;font-size:14px;color:#666666;}QPushButton:hover{color:#0396DC;}"); + + QPixmap check_pixmap(":/tool/res/menu/upgrade.png"); + check_label->setPixmap(check_pixmap); + check_label->setFixedSize(check_pixmap.size()); + check_button->setFocusPolicy(Qt::NoFocus); + check_button->setObjectName("transparentButton"); + + QPixmap help_pixmap(":/tool/res/menu/help.png"); + help_label->setPixmap(help_pixmap); + help_label->setFixedSize(help_pixmap.size()); +// help_button->setIcon(help_pixmap); +// help_button->setIconSize(help_pixmap.size()); + help_button->setFocusPolicy(Qt::NoFocus); + help_button->setObjectName("transparentButton"); + + QPixmap feedback_pixmap(":/tool/res/menu/feedback.png"); + feedback_label->setPixmap(feedback_pixmap); + feedback_label->setFixedSize(feedback_pixmap.size()); + feedback_button->setFocusPolicy(Qt::NoFocus); + feedback_button->setObjectName("transparentButton"); + + QPixmap about_pixmap(":/tool/res/menu/about.png"); + about_label->setPixmap(about_pixmap); + about_label->setFixedSize(about_pixmap.size()); + about_button->setFocusPolicy(Qt::NoFocus); + about_button->setObjectName("transparentButton"); + + QHBoxLayout *check_layout = new QHBoxLayout(); + check_layout->addWidget(check_label); + check_layout->addWidget(check_button); + check_layout->setSpacing(10); + check_layout->setContentsMargins(20, 0, 20, 0); + check_widget->setLayout(check_layout); + check_widget_action->setDefaultWidget(check_widget); + + QHBoxLayout *help_layout = new QHBoxLayout(); + help_layout->addWidget(help_label); + help_layout->addWidget(help_button); + help_layout->setSpacing(10); + help_layout->setContentsMargins(20, 0, 20, 0); + help_widget->setLayout(help_layout); + help_widget_action->setDefaultWidget(help_widget); + + QHBoxLayout *feedback_layout = new QHBoxLayout(); + feedback_layout->addWidget(feedback_label); + feedback_layout->addWidget(feedback_button); + feedback_layout->setSpacing(10); + feedback_layout->setContentsMargins(20, 0, 20, 0); + feedback_widget->setLayout(feedback_layout); + feedback_widget_action->setDefaultWidget(feedback_widget); + + QHBoxLayout *about_layout = new QHBoxLayout(); + about_layout->addWidget(about_label); + about_layout->addWidget(about_button); + about_layout->setSpacing(10); + about_layout->setContentsMargins(20, 0, 20, 0); + about_widget->setLayout(about_layout); + about_widget_action->setDefaultWidget(about_widget); + +// this->addAction(check_widget_action); + if (GlobalData::globalarch == "x86_64") + { + this->addAction(help_widget_action); + this->addAction(feedback_widget_action); + this->addSeparator(); + } + + this->addAction(about_widget_action); + +// this->addAction(help_action); +//// this->addAction(features_action); +// this->addAction(feedback_action); +//// this->addAction(setting_action); +// this->addSeparator(); +// this->addAction(about_action); +// this->addSeparator(); +// this->addAction(play_widget_action); +} + +void KylinMenu::setLanguage() { +// help_action->setText(tr("Forum Help")); +//// features_action->setText(tr("Features")); +// feedback_action->setText(tr("Feedback")); +//// setting_action->setText(tr("Set up")); +// about_action->setText(tr("About us")); +// help_action->setIcon(QIcon("://res/icon.png")); +// help_action->setToolTip(tr("Help")); + check_button->setText(tr("Check and update")); + help_button->setText(tr("Forum Help")); + feedback_button->setText(tr("Feedback")); + about_button->setText(tr("About us")); +} + +void KylinMenu::initConnect() +{ +// connect(help_action, SIGNAL(triggered()), this, SLOT(forumHelp())); +//// connect(features_action, SIGNAL(triggered()), p_mainwindow, SLOT(newFeatures())); +// connect(feedback_action, SIGNAL(triggered()), this, SLOT(questionFeedback())); +//// connect(setting_action, SIGNAL(triggered()), p_mainwindow, SLOT(setupConfigure())); +// connect(about_action, SIGNAL(triggered()), p_mainwindow, SLOT(aboutUs())); + connect(check_button, SIGNAL(clicked()), p_mainwindow, SLOT(openUpgradePage())); + connect(help_button, SIGNAL(clicked()), this, SLOT(forumHelp())); + connect(feedback_button, SIGNAL(clicked()), this, SLOT(questionFeedback())); + connect(about_button, SIGNAL(clicked()), p_mainwindow, SLOT(aboutUs())); +} + +void KylinMenu::forumHelp() +{ + this->close(); + QUrl url(QString("http://www.ubuntukylin.com/ukylin/forum.php")); + QDesktopServices::openUrl(url); +} + +void KylinMenu::questionFeedback() +{ + this->close(); + QUrl url(QString("https://bugs.launchpad.net/youker-assistant")); + QDesktopServices::openUrl(url); +} + +//bool KylinMenu::event(QEvent* e) +//{ +// switch(e->type()) +// { +// case QEvent::ToolTip: +// //show action tooltip instead of widget tooltip +// { +// QHelpEvent *he = dynamic_cast(e); +// QAction *act = actionAt(he->pos()); +// if(act) +// { +// QToolTip::showText(he->globalPos(), act->toolTip(), this); +// return true; +// } +// } +// break; +// } +// QMenu::event(e); +//} diff --git a/component/kylinmenu.h b/component/kylinmenu.h new file mode 100644 index 0000000..b1c923d --- /dev/null +++ b/component/kylinmenu.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINMENU_H +#define KYLINMENU_H + +#include +#include +#include +#include +#include +#include + +class MainWindow; + +class KylinMenu : public QMenu +{ + Q_OBJECT + +public: + explicit KylinMenu(QWidget *parent = 0); + ~KylinMenu(); + void setLanguage(); + void initConnect(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + +//protected: +// virtual bool event(QEvent* e); + +private: + void createActions(); + +public slots: + void forumHelp(); + void questionFeedback(); + +private: +// QAction *help_action; +//// QAction *features_action; +// QAction *feedback_action; +//// QAction *setting_action; +// QAction *about_action; + MainWindow *p_mainwindow; + QWidget *check_widget; + QWidget *help_widget; + QWidget *feedback_widget; + QWidget *about_widget; + QWidgetAction *check_widget_action; + QWidgetAction *help_widget_action; + QWidgetAction *feedback_widget_action; + QWidgetAction *about_widget_action; + QLabel *check_label; + QLabel *help_label; + QLabel *feedback_label; + QLabel *about_label; + QPushButton *check_button; + QPushButton *help_button; + QPushButton *feedback_button; + QPushButton *about_button; +}; + +#endif // KYLINMENU_H diff --git a/component/kylinscrollarea.cpp b/component/kylinscrollarea.cpp new file mode 100644 index 0000000..22fccfa --- /dev/null +++ b/component/kylinscrollarea.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylinscrollarea.h" +#include +#include "autogroup.h" + + +KylinScrollArea::KylinScrollArea(QWidget *parent/*, int width, int height, int spacing*/) : + QWidget(parent) +{ + cardcount = 0; + number_per_row = -1; + this->setWindowFlags(Qt::FramelessWindowHint); + itemwidth = 400;//width; + itemheight = 50;//height; + cardspacing = 6;//spacing; + scroll_area = new QScrollArea(this); + cardPanel = new QWidget(); + scroll_area->setWidget(cardPanel); + scroll_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scroll_area->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); +} + +void KylinScrollArea::calculate_data() +{ + scroll_area->setGeometry(-1, -1, this->width() + 2, this->height() + 2); + cardPanel->setGeometry(0, 0, this->width(), this->height()); + number_per_row = (this->width() + this->cardspacing) / (this->itemwidth + this->cardspacing); +} + +void KylinScrollArea::add_card(AutoGroup *card) +{ + int x = int(cardcount % number_per_row) * (itemwidth + cardspacing); + int y = int(cardcount / number_per_row) * (itemheight + cardspacing); + + int nowHeight = y + itemheight; + if(nowHeight >= cardPanel->height()) + cardPanel->resize(cardPanel->width(), nowHeight); + + card->move(x, y); + cardcount = cardcount + 1; +} diff --git a/component/kylinscrollarea.h b/component/kylinscrollarea.h new file mode 100644 index 0000000..1a13e88 --- /dev/null +++ b/component/kylinscrollarea.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINSCROLLAREA_H +#define KYLINSCROLLAREA_H + +#include +#include +#include +#include + +class AutoGroup; + +class KylinScrollArea : public QWidget +{ + Q_OBJECT +public: + explicit KylinScrollArea(QWidget *parent = 0/*, int width = 0, int height = 0, int spacing = 0*/); + void calculate_data(); + void add_card(AutoGroup *card); + QWidget *cardPanel; + +private: + QScrollArea *scroll_area; + int cardcount; + int number_per_row; + int itemwidth; + int itemheight; + int cardspacing; +}; + +#endif // KYLINSCROLLAREA_H diff --git a/component/kylinswitcher.cpp b/component/kylinswitcher.cpp new file mode 100644 index 0000000..837b87a --- /dev/null +++ b/component/kylinswitcher.cpp @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylinswitcher.h" +#include + +KylinSwitcher::KylinSwitcher(QWidget *parent) : + QWidget(parent) +{ + setWindowFlags(Qt::FramelessWindowHint); + switchedOn = false; + mouse_press = false; + pixmap_on.load("://res/switch-on.png"); + pixmap_off.load("://res/switch-off.png"); + this->setFixedSize(pixmap_on.width(), pixmap_on.height()); + this->setCursor(Qt::PointingHandCursor); +} + +void KylinSwitcher::mousePressEvent(QMouseEvent *event) +{ + if(event->button() == Qt::LeftButton) + { + mouse_press = true; + } +} + +void KylinSwitcher::mouseReleaseEvent(QMouseEvent *event) +{ + if (mouse_press && this->rect().contains(event->pos())) { + mouse_press = false; + switchedOn = !switchedOn; + emit clicked(); + } + update(); +} + +//void KylinSwitcher::enterEvent(QEvent *) +//{ +// if(this->isEnabled()) { +// update(); +// } +//} + +void KylinSwitcher::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.drawPixmap(QPoint(0,0), pixmap_on); + QPoint off_point; + if (switchedOn) + { + off_point = rect().topRight(); + } + else + { + off_point = QPoint(this->width() - pixmap_off.width(), this->rect().top()); + } + painter.drawPixmap(off_point, pixmap_off); + + if(switchedOn) + { + QRect rectON; +// rectON.setTopLeft(rect().topLeft()); + rectON.setTopLeft(QPoint(rect().topLeft().x() + 10, rect().topLeft().y())); + rectON.setBottomRight(QPoint(pixmap_off.width(), pixmap_off.height())); + this->setStyleSheet("QWidget{color:#ffffff;font-size:12px;}"); + painter.drawText(rectON, Qt::AlignLeft | Qt::AlignVCenter, tr("ON")); + } + else + { + QRect rectOFF; + rectOFF.setTopLeft(rect().topLeft()); +// rectOFF.setBottomRight(QPoint(pixmap_off.width(), pixmap_off.height())); + rectOFF.setBottomRight(QPoint(pixmap_off.width() - 10, pixmap_off.height())); + this->setStyleSheet("QWidget{color:#7c8487;font-size:12px;}"); + painter.drawText(rectOFF, Qt::AlignRight|Qt::AlignVCenter, tr("OFF")); + } +} diff --git a/component/kylinswitcher.h b/component/kylinswitcher.h new file mode 100644 index 0000000..e261cd3 --- /dev/null +++ b/component/kylinswitcher.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINSWITCHER_H +#define KYLINSWITCHER_H + +#include +#include +#include + +class KylinSwitcher : public QWidget +{ + Q_OBJECT +public: + explicit KylinSwitcher(QWidget *parent = 0); + bool switchedOn; +// void setSwitchStatus(bool flag) {switchedOn = flag;} + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void paintEvent(QPaintEvent *); +// void enterEvent(QEvent *); + +signals: + void clicked(); + +public slots: + +private: + QPixmap pixmap_on; + QPixmap pixmap_off; + bool mouse_press; +}; + +#endif // KYLINSWITCHER_H diff --git a/component/kylintitlebar.cpp b/component/kylintitlebar.cpp new file mode 100644 index 0000000..147ae5e --- /dev/null +++ b/component/kylintitlebar.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylintitlebar.h" +#include +#include + +KylinTitleBar::KylinTitleBar(QWidget *parent) : + QWidget(parent) +{ + this->setWindowFlags(Qt::FramelessWindowHint); + this->setFixedHeight(32); + this->setAutoFillBackground(true); + +// min_btn = new SystemButton(); + close_btn = new SystemButton(this); + close_btn->setFocusPolicy(Qt::NoFocus); +// min_btn->loadPixmap(":/sys/res/sysBtn/min_button.png"); + close_btn->loadPixmap(":/sys/res/sysBtn/close_button.png"); + + title_label = new QLabel(this); + title_label->setAlignment(Qt::AlignCenter); + title_label->setStyleSheet("QLabel{color:#ffffff;font-family: 方正黑体_GBK;font-size: 14px;text-align: center;font-weight:bold;}"); +// logo_label = new QLabel(); +// logo_label->setFixedSize(22, 22); +// logo_label->setFrameShape(QFrame::NoFrame); +// logo_label->setAutoFillBackground(true); +// logo_label->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小 +// QPixmap label_pixmap("://res/icon.png"); +// logo_label->setPixmap(label_pixmap); + +// logo_label->setFixedSize(label_pixmap.size()); +// QPalette palette; +// palette.setBrush(QPalette::Background, QBrush(QPixmap("://res/logo.png"))); +// logo_label->setPalette(palette); + +// QHBoxLayout *label_layout = new QHBoxLayout(); +// label_layout->addWidget(logo_label, 0, Qt::AlignVCenter); +// label_layout->addWidget(title_label, 0, Qt::AlignVCenter); +// label_layout->setSpacing(5); +// label_layout->setMargin(0); +// label_layout->setContentsMargins(2, 2, 0, 0); + +// QHBoxLayout *btn_layout = new QHBoxLayout(); +// btn_layout->addWidget(min_btn, 0, Qt::AlignTop); +// btn_layout->addWidget(close_btn, 0, Qt::AlignVCenter); +// QHBoxLayout *main_layout = new QHBoxLayout(); +// main_layout->addWidget(close_btn, 0, Qt::AlignVCenter); +// main_layout->addLayout(btn_layout); +// main_layout->addStretch(); +// main_layout->addWidget(title_label, 0, Qt::AlignVCenter); +// main_layout->addStretch(); +// main_layout->addWidget(logo_label, 0, Qt::AlignVCenter); +// main_layout->addLayout(label_layout); + +// main_layout->setSpacing(0); +// main_layout->setMargin(0); +// main_layout->setContentsMargins(0, 0, 2, 0); +// setLayout(main_layout); + +// connect(min_btn, SIGNAL(clicked()), this, SIGNAL(showMinDialog())); + connect(close_btn, SIGNAL(clicked()), this, SIGNAL(closeDialog())); +} + +KylinTitleBar::~KylinTitleBar(void) +{ + if(title_label != NULL) + { + delete title_label; + title_label = NULL; + } + if(close_btn != NULL) + { + delete close_btn; + close_btn = NULL; + } +} + +void KylinTitleBar::resetBackground(QString name) +{ + backgroud_image = name; + QPalette palette_widget; + palette_widget.setBrush(QPalette::Background, QBrush(QPixmap(backgroud_image))); + setPalette(palette_widget); +} + +//20161228 +void KylinTitleBar::setTitleWidth(int width) +{ + title_width = width; + +#ifdef __aarch64__ + close_btn->move(title_width - 36, 0); +#else + close_btn->move(0, 0); +#endif +} + +void KylinTitleBar::resizeEvent(QResizeEvent *event) +{ + //width + this->setFixedWidth(title_width); + + //backgrond + QPalette palette_widget; + palette_widget.setBrush(QPalette::Background, QBrush(QPixmap(backgroud_image))); + setPalette(palette_widget); + + //title and font + title_label->setText(title_content); + title_label->setGeometry(QRect(40, 0, title_width- 80, 32)); +// title_label->setGeometry(QRect(40, 0, 40, 32)); +// QPalette objPalette = palette(); +// objPalette.setColor(QPalette::WindowText, Qt::white); +// title_label->setPalette(objPalette); +// QFont &objFont = const_cast(font()); +// objFont.setWeight(QFont::Bold); +// title_label->setFont(objFont); +} + +void KylinTitleBar::mousePressEvent ( QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + if(event->y() < 5 || event->x() < 5 || rect().width() - event->x() < 5) { + event->ignore(); + return; + } + press_point = event->globalPos(); + left_btn_pressed = true; + } + event->ignore(); +} + +void KylinTitleBar::mouseMoveEvent ( QMouseEvent *event) +{ + if(left_btn_pressed) { + move_point = event->globalPos(); + QWidget *pMainWindow = (qobject_cast(parent())); + pMainWindow->move(pMainWindow->pos() + move_point - press_point); + press_point = move_point; + } + event->ignore(); +} + +void KylinTitleBar::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + left_btn_pressed = false; + } + event->ignore(); +} diff --git a/component/kylintitlebar.h b/component/kylintitlebar.h new file mode 100644 index 0000000..54f9900 --- /dev/null +++ b/component/kylintitlebar.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINTITLEBAR_H +#define KYLINTITLEBAR_H + +#include +#include +#include +#include +#include "systembutton.h" + +class KylinTitleBar : public QWidget +{ + Q_OBJECT +public: + explicit KylinTitleBar(QWidget *parent = 0); + virtual ~KylinTitleBar(); + void setTitleWidth(int width);// { title_width = width;}20161228 + void setTitleName(QString title) { title_content = title;} + void setTitleBackgound(QString img) { backgroud_image = img;} + void resetBackground(QString name); + +protected: + virtual void resizeEvent (QResizeEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +signals: +// void showMinDialog(); + void closeDialog(); + +private: + QPoint press_point; + QPoint move_point; + bool left_btn_pressed; +// QLabel *logo_label; + QLabel *title_label; + int title_width; + QString title_content; + QString backgroud_image; +// SystemButton *min_btn; + SystemButton *close_btn; +}; + +#endif // KYLINTITLEBAR_H diff --git a/component/kylintoolbutton.cpp b/component/kylintoolbutton.cpp new file mode 100644 index 0000000..1603324 --- /dev/null +++ b/component/kylintoolbutton.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylintoolbutton.h" +#include + +KylinToolButton::KylinToolButton(const QString &pic_name, const QString &text, QWidget *parent) + :QToolButton(parent) +{ + setDown(false); + setFocusPolicy(Qt::NoFocus); + + this->setText(text); + +// QPalette text_palette = palette(); +// text_palette.setColor(QPalette::ButtonText, QColor(230, 230, 230)); +// setPalette(text_palette); + +// QFont &text_font = const_cast(font()); +// text_font.setWeight(QFont::Bold); + + setToolButtonStyle(Qt::ToolButtonTextBesideIcon); +// setToolButtonStyle( Qt::ToolButtonTextUnderIcon); + setPopupMode(QToolButton::InstantPopup); + + QPixmap pixmap(pic_name); + normal_icon = QIcon(pic_name); + hover_icon = QIcon(pic_name + "-hover"); + press_icon = QIcon(pic_name + "-press"); + setIcon(pixmap); + setIconSize(pixmap.size()); + +// setFixedSize(pixmap.width(), pixmap.height() + 10); + setAutoRaise(true); + this->setObjectName("transparentToolButton"); + mouse_over = false; + mouse_press = false; + pressed = false; +} + +KylinToolButton::~KylinToolButton() +{ + +} + +void KylinToolButton::enterEvent(QEvent *event) +{ + if(isEnabled()) + { + mouse_over = true; + this->setMouseHover(); + } +} + +void KylinToolButton::leaveEvent(QEvent *event) +{ + if(isEnabled()) + { + mouse_over = false; + this->setMouseHover(); + } +} + +void KylinToolButton::mousePressEvent(QMouseEvent *event) +{ + if(isEnabled() && event->button() == Qt::LeftButton) + { + //kobe: don't emit, it will emit by click it self. +// emit clicked(); + } + QToolButton::mousePressEvent(event); +} + +void KylinToolButton::setMouseHover() +{ + if(this->mouse_over) + { + this->setIcon(QIcon(hover_icon)); + } + else { + if(pressed) + this->setIcon(QIcon(press_icon)); + else + this->setIcon(QIcon(normal_icon)); + } +} + +void KylinToolButton::setMousePress(bool is_press) +{ + this->mouse_press = is_press; + + if(this->mouse_press) + { + this->setIcon(QIcon(press_icon)); + pressed = true; + } + else + { + this->setIcon(QIcon(normal_icon)); + pressed = false; + } + +// if(this->mouse_over) +// { +// this->setIcon(QIcon(hover_icon)); +// } +// else +// { +// if(this->mouse_press) +// { +// this->setIcon(QIcon(press_icon)); +// } +// else +// { +// this->setIcon(QIcon(normal_icon)); +// } +// } +} diff --git a/component/kylintoolbutton.h b/component/kylintoolbutton.h new file mode 100644 index 0000000..bd9cafb --- /dev/null +++ b/component/kylintoolbutton.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINTOOlBUTTON_H +#define KYLINTOOlBUTTON_H + +#include +#include +#include + +class KylinToolButton : public QToolButton +{ + +public: + explicit KylinToolButton(const QString &pic_name, const QString &text , QWidget *parent = 0); + ~KylinToolButton(); + void setMousePress(bool is_press); + void setMouseHover(); + bool pressed; + +protected: + void enterEvent(QEvent *event); + void leaveEvent(QEvent *event); + void mousePressEvent(QMouseEvent *event); + +public: + bool mouse_over; //鼠标是否移过 + bool mouse_press; //鼠标是否按下 + QIcon normal_icon; + QIcon hover_icon; + QIcon press_icon; +}; + +#endif //KYLINTOOlBUTTON_H diff --git a/component/labelgroup.cpp b/component/labelgroup.cpp new file mode 100644 index 0000000..cb2ec44 --- /dev/null +++ b/component/labelgroup.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "labelgroup.h" +#include "utils.h" +#include + +LabelGroup::LabelGroup(QWidget *parent) : + QWidget(parent) +{ + this->resize(ITEMWIDTH, ITEMHEIGHT); + //边框 +// this->setStyleSheet("border:1px solid black;"); + + //背景 +// this->setAutoFillBackground(true); +// QPalette palette; +//// palette.setColor(QPalette::Background, QColor(192,253,123)); +// palette.setBrush(QPalette::Background, QBrush(QPixmap(":/background/res/bg/6.png"))); +// this->setPalette(palette); + + + h_layout = new QHBoxLayout(); + key_info = new QLabel(); + value_info = new QLabel(); + key_info->setFixedSize(180, ITEMHEIGHT); + value_info->setFixedHeight(ITEMHEIGHT); + + QFont font = key_info->font(); + font.setPointSize(14); + key_info->setFont(font); + key_info->setObjectName("titleLabel"); + value_info->setFont(font); + value_info->setObjectName("grayLabel"); + + h_layout->addWidget(key_info); + h_layout->addWidget(value_info); + + h_layout->setMargin(0);//设置总的外围边框 + setLayout(h_layout); +} + +//void LabelGroup::pushMap(QString key, QString value) +//{ +// this->name[key] = value; +//} + +void LabelGroup::setLanguage(QString key, QString value) +{ + key_info->setText(tr("%1:").arg(key)); + value_info->setText(tr("%1").arg(value)); +} diff --git a/component/labelgroup.h b/component/labelgroup.h new file mode 100644 index 0000000..c24a9ad --- /dev/null +++ b/component/labelgroup.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LABELGROUP_H +#define LABELGROUP_H + +#include +#include +#include +#include + +class LabelGroup : public QWidget +{ + Q_OBJECT +public: + explicit LabelGroup(QWidget *parent = 0); + void setLanguage(QString key, QString value); +// void pushMap(QString key, QString value); + +signals: + +public slots: + +private: + QHBoxLayout *h_layout; + QLabel *key_info; + QLabel *value_info; +// QMap name; +}; + +#endif // LABELGROUP_H diff --git a/component/loadinglabel.cpp b/component/loadinglabel.cpp new file mode 100644 index 0000000..3667bc2 --- /dev/null +++ b/component/loadinglabel.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "loadinglabel.h" +#include +#include +#include + +LoadingLabel::LoadingLabel(QWidget *parent, QString flag) : + QLabel(parent), category(flag) +{ + if(category == "firstkey") { + page_count = 18; + this->setFixedSize(150, 150); + } + else if(category == "clean") { + page_count = 18; + this->setFixedSize(96, 96); + } + else if(category == "upgrading") { + page_count = 32; + this->setFixedSize(182, 181); + } + else if(category == "working") { + page_count = 36; + this->setFixedSize(182, 181); + } + this->setWindowFlags(Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_TranslucentBackground, true); + currentpage = 0; + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(changeAnimationStep())); + + this->loadAllPictures(); + this->raise(); + + //init animation + QPixmap cur_pix = png_vector.at(0); + this->setPixmap(cur_pix); + setMask(QBitmap(cur_pix.mask())); +} + +LoadingLabel::~LoadingLabel() +{ + if (timer != NULL) { + disconnect(timer,SIGNAL(timeout()),this,SLOT(changeAnimationStep())); + if(timer->isActive()) { + timer->stop(); + } + delete timer; + timer = NULL; + } +} + +void LoadingLabel::changeAnimationStep() +{ + + if(currentpage == this->page_count) + { + currentpage = 0; + } +// qDebug() << currentpage; + QPixmap cur_pix = png_vector.at(currentpage); + this->setPixmap(cur_pix); + setMask(QBitmap(cur_pix.mask())); + currentpage += 1; +} + +void LoadingLabel::loadAllPictures() +{ + QString path; + if(category == "firstkey") { + path = ":/movie/res/loading/"; + } + else if(category == "clean") { + path = ":/movie/res/loading/small/"; + } + else if(category == "upgrading") { + path = ":/movie/res/upgrading/"; + } + else if(category == "working") { + path = ":/movie/res/working/"; + } + for(int i =1; i <= this->page_count; i++) + { + QPixmap img = QPixmap(path + QString::number(i, 10) + ".png"); + png_vector.append(img); + } +} + +void LoadingLabel::startLoading() +{ + currentpage = 0; + if(category == "upgrading" || category == "working") + timer->start(50); + else + timer->start(60); +} + +void LoadingLabel::stopLoading() +{ + timer->stop(); +} diff --git a/component/loadinglabel.h b/component/loadinglabel.h new file mode 100644 index 0000000..7c516c1 --- /dev/null +++ b/component/loadinglabel.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LOADINLABEL_H +#define LOADINLABEL_H + +#include +#include +#include +#include + +class LoadingLabel : public QLabel +{ + Q_OBJECT +public: + explicit LoadingLabel(QWidget *parent = 0, QString flag = "");//flag=ture:big picture;flag=false:small picture + ~LoadingLabel(); + void loadAllPictures(); + void startLoading(); + void stopLoading(); + +public slots: + void changeAnimationStep(); + +private: + QTimer *timer; + QVector png_vector; + int currentpage; + int page_count; + QString category; +}; + +#endif // LOADINLABEL_H diff --git a/component/normalcard.cpp b/component/normalcard.cpp new file mode 100644 index 0000000..9f020ac --- /dev/null +++ b/component/normalcard.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "normalcard.h" +#include "ui_normalcard.h" +#include + +NormalCard::NormalCard(QString title, QWidget *parent) : + QWidget(parent), + ui(new Ui::NormalCard) +{ + ui->setupUi(this); +// ui->raiseWidget->setStyleSheet("QWidget{background:transparent url(:/background/res/skin/1.png);icon-size:20px 5px}"); + ui->raiseWidget->setStyleSheet("QWidget{background:transparent url(://res/theme-cover.png);}"); + ui->baseWidget->setStyleSheet("QWidget{background:transparent;}"); + this->icon_name = title; + iconpath=QString(":/gtk/res/theme/" + title + ".png"); + QPixmap pixmap(iconpath); + if(pixmap.isNull()) + { + pixmap = QPixmap(":/gtk/res/theme/disappear.png"); + } + pixmap.copy(QRect(0,0,119,119)); + ui->icon->setPixmap(pixmap); +// ui->icon->setStyleSheet("QLabel{background-image:url('" + iconpath + "')}"); + ui->icon->installEventFilter(this); + ui->raiseWidget->installEventFilter(this); + ui->name->setStyleSheet("QLabel{background: transparent;color:#666666;方正黑体_GBK;font-size: 14px;text-align: center;}"); + ui->name->setText(title); + ui->using_label->setStyleSheet("QLabel{background-image:url('://res/choose.png')}"); + ui->using_label->hide(); +} + +NormalCard::~NormalCard() { + delete ui; +} + +void NormalCard::showUsingLogo(bool flag) +{ + if(flag) { + ui->using_label->show(); + ui->raiseWidget->hide(); + } + else { + ui->using_label->hide(); + ui->raiseWidget->show(); + } +} + +void NormalCard::enterEvent(QEvent *) +{ + +} + +void NormalCard::leaveEvent(QEvent *) +{ + +} + +bool NormalCard::eventFilter(QObject *obj, QEvent *event) +{ + if(obj == ui->icon || obj == ui->raiseWidget){ + if(event->type() == QEvent::MouseButtonRelease){ + emit this->sendSelectThemeName(this->icon_name); + } + } + return QObject::eventFilter(obj, event); +} diff --git a/component/normalcard.h b/component/normalcard.h new file mode 100644 index 0000000..ff99f38 --- /dev/null +++ b/component/normalcard.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef NORMALCARD_H +#define NORMALCARD_H + +#include +#include +#include +#include +#include +#include + +namespace Ui { +class NormalCard; +} + +class NormalCard : public QWidget +{ + Q_OBJECT + +public: + explicit NormalCard(QString title = "", QWidget *parent = 0); + ~NormalCard(); +// void switchAnimation(); + void showUsingLogo(bool flag); + +public slots: +// void slotShowDelayAnimation(); +// void slotSwitchAnimationStep(); +// void onDeleteBtnClicked(); + +signals: + void sendSelectThemeName(QString name); +// void sendEnterBackground(QString name); +// void sendLeaveBackground(); +// void sendDelteSignal(QString name); + +protected: + void enterEvent(QEvent *); + void leaveEvent(QEvent *); + bool eventFilter(QObject *obj, QEvent *event); + +private: + Ui::NormalCard *ui; +// QTimer *switchTimer; +// QTimer *delayTimer; +// bool showDelay; +// QString switchDirection; +// int py; +// QString iconDir; + QString icon_name; + QString iconpath; +}; + +#endif // NORMALCARD_H diff --git a/component/normalcard.ui b/component/normalcard.ui new file mode 100644 index 0000000..5eaf11d --- /dev/null +++ b/component/normalcard.ui @@ -0,0 +1,81 @@ + + + NormalCard + + + + 0 + 0 + 119 + 139 + + + + Form + + + + + 0 + 0 + 119 + 119 + + + + + + 0 + 0 + 119 + 119 + + + + + + + + + + 92 + 92 + 22 + 22 + + + + + + + + + + + 0 + 0 + 119 + 119 + + + + + + + 0 + 119 + 119 + 20 + + + + + + + Qt::AlignCenter + + + + + + diff --git a/component/normalwidget.cpp b/component/normalwidget.cpp new file mode 100644 index 0000000..0fe7fcf --- /dev/null +++ b/component/normalwidget.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "normalwidget.h" +#include +#include "../component/utils.h" + +NormalWidget::NormalWidget(int cardwidth, int cardheight, int space, QWidget *parent) : + QWidget(parent) +{ + cardcount = 0; + number_per_row = -1; + this->itemwidth = cardwidth; + this->itemheight = cardheight; + this->cardspace = space; + + scrollArea = new QScrollArea(this); + scrollArea->setStyleSheet("QScrollArea{border: none;background-color: #ffffff;}"); + cardPanel = new QWidget(); + cardPanel->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + this->scrollArea->setWidget(this->cardPanel); + this->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + this->scrollArea->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{margin:0px 0px 0px 0px;background-color:rgb(255,255,255,100);border:0px;width:6px;}\ + QScrollBar::sub-line:vertical{subcontrol-origin:margin;border:1px solid red;height:13px}\ + QScrollBar::up-arrow:vertical{subcontrol-origin:margin;background-color:blue;height:13px}\ + QScrollBar::sub-page:vertical{background-color:#EEEDF0;}\ + QScrollBar::handle:vertical{background-color:#D1D0D2;width:6px;} QScrollBar::handle:vertical:hover{background-color:#14ACF5;width:6px;} QScrollBar::handle:vertical:pressed{background-color:#0B95D7;width:6px;}\ + QScrollBar::add-page:vertical{background-color:#EEEDF0;}\ + QScrollBar::down-arrow:vertical{background-color:yellow;}\ + QScrollBar::add-line:vertical{subcontrol-origin:margin;border:1px solid green;height:13px}"); + +// QVBoxLayout *v_layout = new QVBoxLayout(); +// v_layout->addWidget(scrollArea); +// v_layout->setSpacing(0);//设置间隔 +// v_layout->setMargin(0);//设置总的外围边框 +// v_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(v_layout); +} + +NormalWidget::~NormalWidget() { + if(cardPanel != NULL) { + delete cardPanel; + cardPanel = NULL; + } +} + +void NormalWidget::calculate_data() +{ + this->scrollArea->setGeometry(-1, -1, this->width() + 2, this->height() + 2); + this->cardPanel->setGeometry(0, 0, this->width(), this->height()); + this->number_per_row = (this->width() + this->cardspace) / (this->itemwidth + this->cardspace); +} + +void NormalWidget::add_card(QWidget *card) +{ + int x = int(this->cardcount % this->number_per_row) * (this->itemwidth + this->cardspace); + int y = int(this->cardcount / this->number_per_row) * (this->itemheight + this->cardspace); + + int nowHeight = y + this->itemheight; +// qDebug() << "nowHeight-> " << nowHeight; + if(nowHeight >= this->cardPanel->height()) + this->cardPanel->resize(this->cardPanel->width(), nowHeight); + card->move(x, y); + this->cardcount += 1; +} diff --git a/component/normalwidget.h b/component/normalwidget.h new file mode 100644 index 0000000..254f6ee --- /dev/null +++ b/component/normalwidget.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef NORMALWIDGET_H +#define NORMALWIDGET_H + +#include +#include +#include +#include + + +class NormalWidget : public QWidget +{ + Q_OBJECT +public: + explicit NormalWidget(int cardwidth = 0, int cardheight = 0, int space = 0, QWidget *parent = 0); + ~NormalWidget(); + void calculate_data(); + void add_card(QWidget *card); + QWidget *cardPanel; + +private: + int cardcount; + int number_per_row; + int itemwidth; + int itemheight; + int cardspace; + QScrollArea *scrollArea; +}; + +#endif // NORMALWIDGET_H diff --git a/component/plugininterface.h b/component/plugininterface.h new file mode 100644 index 0000000..f92b6cd --- /dev/null +++ b/component/plugininterface.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PLUGININTERFACE_H +#define PLUGININTERFACE_H + +#include +#include + +class PluginInterface +{ +public: + virtual ~PluginInterface() {} + virtual QString getGuid() = 0; + virtual QString getName() = 0; + virtual QString getDescribe() = 0; + virtual QString getPicture() = 0; + virtual void doAction() = 0; +}; + +//Q_DECLARE_INTERFACE定义在在qobject.h中,用来告诉Qt meta-object system 这个接口名称 +Q_DECLARE_INTERFACE(PluginInterface, "com.ubuntukylin.Plugin.PluginInterface ") + +#endif // PLUGININTERFACE_H + diff --git a/component/quibo.cpp b/component/quibo.cpp new file mode 100644 index 0000000..51d214b --- /dev/null +++ b/component/quibo.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "quibo.h" +#include "ui_quibo.h" + +QUIBO::QUIBO(QWidget *parent) : + QWidget(parent), + ui(new Ui::QUIBO) +{ + ui->setupUi(this); + + this->colors = new QStringList(); + this->colors->append("blue"); + this->colors->append("purple"); + this->colors->append("green"); + this->colors->append("orange"); + this->colors->append("red"); + this->colors->append("black"); + this->colors->append("white"); + this->cindex = 1; + + ui->bg->setStyleSheet("QLabel{background-color:" + this->colors->at(0) + ";}"); + + this->show(); + this->setWindowState(Qt::WindowActive); + this->setWindowState(Qt::WindowFullScreen); +} + +QUIBO::~QUIBO() { + if(colors != NULL) { + delete colors; + colors = NULL; + } + delete ui; +} + +void QUIBO::mouseReleaseEvent(QMouseEvent *me) { + if(me->button() == Qt::LeftButton){ + this->changeColor(); + }else if(me->button() == Qt::RightButton){ + this->close(); + }else{ + } +} + +void QUIBO::myshow() { +} + +void QUIBO::changeColor() { + if(this->cindex >= 7){ + this->close(); + }else{ + ui->bg->setStyleSheet("QLabel{background-color:" + this->colors->at(this->cindex) + ";}"); + this->cindex ++; + } +} diff --git a/component/quibo.h b/component/quibo.h new file mode 100644 index 0000000..3cd81c5 --- /dev/null +++ b/component/quibo.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef QUIBO_H +#define QUIBO_H + +#include +#include +#include +#include +#include + +namespace Ui { +class QUIBO; +} + +class QUIBO : public QWidget +{ + Q_OBJECT + +public: + explicit QUIBO(QWidget *parent = 0); + ~QUIBO(); + + void myshow(); +private: + Ui::QUIBO *ui; + + int cindex; + QStringList *colors; + void mouseReleaseEvent(QMouseEvent *me); + void changeColor(); +}; + +#endif // QUIBO_H diff --git a/component/quibo.ui b/component/quibo.ui new file mode 100644 index 0000000..0b5cb80 --- /dev/null +++ b/component/quibo.ui @@ -0,0 +1,32 @@ + + + QUIBO + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + 0 + 0 + 5000 + 5000 + + + + + + + + + + diff --git a/component/scrollwidget.cpp b/component/scrollwidget.cpp new file mode 100644 index 0000000..3990d81 --- /dev/null +++ b/component/scrollwidget.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "scrollwidget.h" +#include "../info/computerpage.h" +#include +#include "../component/utils.h" + +ScrollWidget::ScrollWidget(QWidget *parent) : + QWidget(parent) +{ +// this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + this->setWindowFlags(Qt::FramelessWindowHint); + widget_count = 0; + zone_height = 403; + scroll_area = new QScrollArea(); + zone = new QWidget(); + + //set white background color + zone->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + zone->setPalette(palette); + + scroll_area->setGeometry(-1, -1, 750+2, 403); + zone->setGeometry(0,0,750,403); + zone->setWindowFlags(Qt::FramelessWindowHint); + scroll_area->setWidget(zone); + scroll_area->horizontalScrollBar()->hide(); +// scroll_area->setBackgroundRole(QPalette::Dark); + scroll_area->setAlignment(Qt::AlignLeft); + scroll_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scroll_area->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + QVBoxLayout *v_layout = new QVBoxLayout(); + v_layout->addWidget(scroll_area); + v_layout->setSpacing(0);//设置间隔 + v_layout->setMargin(0);//设置总的外围边框 +// v_layout->setContentsMargins(5, 5, 5, 5); + + setLayout(v_layout); +} + +ScrollWidget::~ScrollWidget() { + if(zone != NULL) { + delete zone; + zone = NULL; + } + if(scroll_area != NULL) { + delete scroll_area; + scroll_area = NULL; + } +} + +void ScrollWidget::addScrollWidget(ComputerPage *widget) +{ + if (widget_count == 0) { + widget->move(0,0); +// if(widget->page_height > zone->height()) { +// zone_height = widget->page_height; +// this->zone->resize(750, zone_height); +// } +// else { +// this->zone->resize(750, 403-3); +// } + zone_height = widget->page_height; + this->zone->resize(750, zone_height); + } + else { + int y = zone_height/* + PAGESPACE*/; + zone_height += widget->page_height/* + PAGESPACE*/; + if(zone_height > zone->height()) { + this->zone->resize(750, zone_height); + } + widget->move(0, y); + } + widget_count ++; +} + +void ScrollWidget::resetWidget() +{ + widget_count = 0; + zone_height = 403; +} diff --git a/component/scrollwidget.h b/component/scrollwidget.h new file mode 100644 index 0000000..dff6203 --- /dev/null +++ b/component/scrollwidget.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SCROLLWIDGET_H +#define SCROLLWIDGET_H + +#include +#include +#include +#include + +class ComputerPage; + +class ScrollWidget : public QWidget +{ + Q_OBJECT +public: + explicit ScrollWidget(QWidget *parent = 0); + ~ScrollWidget(); + void addScrollWidget(ComputerPage *widget); + QWidget *zone; + void resetWidget(); + +private: + QScrollArea *scroll_area; + int widget_count; + int zone_height; +}; + +#endif // SCROLLWIDGET_H diff --git a/component/settingaction.cpp b/component/settingaction.cpp new file mode 100644 index 0000000..e233947 --- /dev/null +++ b/component/settingaction.cpp @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "settingaction.h" + +SettingAction::SettingAction(QString cur_desktop, QWidget *parent) + : QWidget(parent), desktop(cur_desktop) +{ + this->setFixedSize(900, 150); + this->setAutoFillBackground(true); + this->setObjectName("transparentWidget"); + + back_btn = new QPushButton(); + back_btn->setCursor(Qt::PointingHandCursor); + back_btn->setFixedSize(91,39); + back_btn->setFocusPolicy(Qt::NoFocus); + QPixmap pixmap("://res/back-arrow.png"); + back_btn->setIcon(pixmap); + back_btn->setIconSize(pixmap.size()); + back_btn->setObjectName("backgroundButton"); + connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + img_label = new QLabel(); + title_label = new QLabel(); +// description_label = new QLabel(); + + img_label->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小 + QPixmap label_pixmap("://res/systemset.png"); + img_label->setPixmap(label_pixmap); + img_label->setFixedSize(label_pixmap.size()); + + title_label->setObjectName("whiteLabel"); + title_label->setFixedWidth(650); + title_label->setWordWrap(true);//QLabel自动换行 +// description_label->setWordWrap(true);//QLabel自动换行 +// description_label->setObjectName("tipLabel"); + + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->addWidget(img_label, 0, Qt::AlignVCenter); + layout1->addWidget(title_label, 0, Qt::AlignVCenter); + layout1->setSpacing(20); + layout1->setMargin(0); +// layout1->setContentsMargins(20, 20, 0, 0); + layout1->setContentsMargins(0, 0, 0, 0); + + +// QVBoxLayout *layout1 = new QVBoxLayout(); +// layout1->addStretch(); +// layout1->addWidget(title_label); +//// layout1->addWidget(description_label); +// layout1->addStretch(); +// layout1->setSpacing(15); +// layout1->setMargin(0); +// layout1->setContentsMargins(0, 0, 0, 0); + + QVBoxLayout *layout2 = new QVBoxLayout(); + layout2->addWidget(back_btn); + layout2->addStretch(); + layout2->setMargin(0); + layout2->setContentsMargins(0, 0, 0, 0); + + QHBoxLayout *main_layout = new QHBoxLayout(); +// main_layout->addWidget(img_label, 0, Qt::AlignVCenter); + main_layout->addLayout(layout1); + main_layout->addStretch(); + main_layout->addLayout(layout2); +// main_layout->addWidget(back_btn, 0, Qt::AlignVCenter); + main_layout->setSpacing(20); + main_layout->setMargin(0); + main_layout->setContentsMargins(20, 20, 0, 0); + + setLayout(main_layout); + +} + +SettingAction::~SettingAction() +{ + if(back_btn != NULL) { + delete back_btn; + back_btn = NULL; + } + if(img_label != NULL) { + delete img_label; + img_label = NULL; + } + if(title_label != NULL) { + delete title_label; + title_label = NULL; + } +} + +void SettingAction::setLanguage(int index) +{ + back_btn->setText(tr("Back")); + switch (index) { + case 1: + title_label->setText(tr("Choose the theme what you want")); +// description_label->setText(tr("Choose the theme what you want.")); + break; + case 2: + title_label->setText(tr("Set the desktop icon theme and the visibility of desktop icons")); +// description_label->setText(tr("Set the desktop icon theme and the visibility of desktop icons.")); + break; + case 3: + title_label->setText(tr("Replace the theme and size of the mouse pointer, and theme change need to restart system")); +// description_label->setText(tr("Replace the theme and size of the mouse pointer, then click the 'OK' button to confirm. Also, theme change need to restart system.")); + break; + case 4: + title_label->setText(tr("Set the sound theme you want")); +// description_label->setText(tr("Set the sound theme you want.")); + break; +// case 5: +// title_label->setText(tr("Click the \"Custom Picture\" button to select the picture you want to add, click the picture you want to set and push the \"OK\" button to complete")); +//// description_label->setText(tr("Click the \"Custom Picture\" button to select the picture you want to add, click the picture you want to set and push the \"OK\" button to complete.")); +// break; + case 5: + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "ukui" || this->desktop == "UKUI") + title_label->setText(tr("Setting the panel mode of auto hide and icon size")); + else + title_label->setText(tr("Setting the Launcher display mode, Icon size")); +// description_label->setText(tr("Setting the Launcher display mode, Icon size.")); + break; + case 6: + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "ukui" || this->desktop == "UKUI") + title_label->setText(tr("Manage display of the start menu")); + else + title_label->setText(tr("Manage Dash and Panel menu settings")); +// description_label->setText(tr("Manage Dash and Panel menu settings.")); + break; + case 7: + title_label->setText(tr("Window Manager settings")); +// description_label->setText(tr("Window Manager settings.")); + break; + case 8: + title_label->setText(tr("According to personal preferences to set the system default font, click the 'Restore' button, can be restored to the state before the font settings")); +// description_label->setText(tr("According to personal preferences to set the system default font, click the 'Restore' button, can be restored to the state before the font settings.")); + break; + case 9: + title_label->setText(tr("Setting the relevant properties of your touchpad,make the operation more convenient")); +// description_label->setText(tr("Setting the relevant properties of your touchpad,make the operation more convenient.")); + break; + case 10: + title_label->setText(tr("Monitor Check")); +// description_label->setText(tr("Monitor Check.")); + break; + case 11: + title_label->setText(tr("Save energy to let the computer longer standby time")); + break; + case 12: + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "ukui" || this->desktop == "UKUI") + title_label->setText(tr("Manage the Caja file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked")); + else + title_label->setText(tr("Manage the Nautilus file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked")); +// description_label->setText(tr("Manage the Nautilus file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked.")); + break; + default: + break; + } +} diff --git a/component/settingaction.h b/component/settingaction.h new file mode 100644 index 0000000..fc30a04 --- /dev/null +++ b/component/settingaction.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SETTINGACTION_H +#define SETTINGACTION_H + +#include +#include +#include +#include +#include +#include +#include +#include "../component/kylinbutton.h" +#include "../component/systembutton.h" + +class SettingAction : public QWidget +{ + Q_OBJECT +public: + explicit SettingAction(QString cur_dekstop = "", QWidget *parent = 0); + ~SettingAction(); +// void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void setLanguage(int index); + +signals: + void showSettingMainWidget(); + +private: + QPushButton *back_btn; + QLabel *img_label; + QLabel *title_label; +// QLabel *description_label; +// MainWindow *p_mainwindow; + QString desktop; +}; + +#endif // SETTINGACTION_H diff --git a/component/systembutton.cpp b/component/systembutton.cpp new file mode 100644 index 0000000..1dddce1 --- /dev/null +++ b/component/systembutton.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "systembutton.h" +#include + +SystemButton::SystemButton(QWidget *parent) : + QPushButton(parent) +{ + status = NORMAL; + mouse_press = false; +} + + +void SystemButton::loadPixmap(QString pic_name) +{ + pixmap = QPixmap(pic_name); + btn_width = pixmap.width()/3; + btn_height = pixmap.height(); + this->setFixedSize(btn_width, btn_height); +} + +void SystemButton::enterEvent(QEvent *) +{ + status = ENTER; + update(); +} + +void SystemButton::mousePressEvent(QMouseEvent *event) +{ + if(event->button() == Qt::LeftButton) + { + mouse_press = true; + status = PRESS; + update(); + } +} + +void SystemButton::mouseReleaseEvent(QMouseEvent *event) +{ + if(mouse_press && this->rect().contains(event->pos())) + { + mouse_press = false; + status = ENTER; + update(); + emit clicked(); + } +} + +void SystemButton::leaveEvent(QEvent *) +{ + status = NORMAL; + update(); +} + +void SystemButton::paintEvent(QPaintEvent *) +{ + QPainter painter; + painter.begin(this); + painter.drawPixmap(this->rect(), pixmap.copy(btn_width * status, 0, btn_width, btn_height)); + painter.end(); +} diff --git a/component/systembutton.h b/component/systembutton.h new file mode 100644 index 0000000..86074c3 --- /dev/null +++ b/component/systembutton.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SYSTEMBUTTON_H +#define SYSTEMBUTTON_H + +#include +#include +#include + +class SystemButton : public QPushButton +{ + Q_OBJECT +public: + explicit SystemButton(QWidget *parent = 0); + void loadPixmap(QString pic_name); + + + +protected: + void enterEvent(QEvent *); + void leaveEvent(QEvent *); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void paintEvent(QPaintEvent *); + +signals: + +public slots: + +private: + QPixmap pixmap; + enum ButtonStatus{NORMAL, ENTER, PRESS}; + ButtonStatus status; + bool mouse_press; //按钮左键是否按下 + int btn_width; + int btn_height; +}; + +#endif // SYSTEMBUTTON_H diff --git a/component/systemtray.cpp b/component/systemtray.cpp new file mode 100644 index 0000000..53a0852 --- /dev/null +++ b/component/systemtray.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "systemtray.h" + +SystemTray::SystemTray(QWidget *parent) + : QSystemTrayIcon(parent) +{ + this->initTrayActions(); + this->setLanguage(); +} + +SystemTray::~SystemTray() +{ +} + +void SystemTray::setLanguage() +{ + this->setToolTip(tr("Youker Assistant")); + action_open->setText(tr("open")); + action_open->setIcon(QIcon("://res/icon.png")); + action_logout->setText(tr("logout")); +} + +void SystemTray::initTrayActions() +{ + this->setIcon(QIcon("://res/icon.png")); + tray_menu = new QMenu(); +// tray_menu->setObjectName("mainmenu"); + action_open = new QAction(this); + action_logout = new QAction(this); + + tray_menu->setFixedWidth(250); + + connect(action_open, SIGNAL(triggered()), this, SIGNAL(showWidget())); + connect(action_logout, SIGNAL(triggered()), qApp, SLOT(quit())); + + this->setContextMenu(tray_menu); + + tray_menu->addAction(action_open); + tray_menu->addSeparator(); + tray_menu->addAction(action_logout); +} diff --git a/component/systemtray.h b/component/systemtray.h new file mode 100644 index 0000000..027d240 --- /dev/null +++ b/component/systemtray.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SYSTEMTRAY_H +#define SYSTEMTRAY_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class SystemTray : public QSystemTrayIcon +{ + Q_OBJECT + +public: + explicit SystemTray(QWidget *parent = 0); + ~SystemTray(); + void setLanguage(); + +signals: + void showWidget(); + +private: + void initTrayActions(); + +private: + QMenu *tray_menu; + QAction *action_open; + QAction *action_logout; +}; + +#endif // SYSTEMTRAY_H diff --git a/component/threadpool.cpp b/component/threadpool.cpp new file mode 100644 index 0000000..b4ee0b5 --- /dev/null +++ b/component/threadpool.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2013 ~ 2017 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "threadpool.h" +#include + +ThreadPool::ThreadPool(QObject *parent) : QObject(parent) +{ + +} + +ThreadPool::~ThreadPool() +{ + exitAllThreads(); +} + +ThreadPool *ThreadPool::Instance() +{ + static ThreadPool threadPool; + return &threadPool; +} + +QThread *ThreadPool::createNewThread() +{ + QThread *thread = new QThread; + thread_pool.push_back(thread); + return thread; +} + +void ThreadPool::exitAllThreads() +{ + foreach (QThread *thread, thread_pool) { + thread->quit(); + thread->wait(2000); + } +} diff --git a/component/threadpool.h b/component/threadpool.h new file mode 100644 index 0000000..6b56de6 --- /dev/null +++ b/component/threadpool.h @@ -0,0 +1,39 @@ +#ifndef THREADPOOL_H +#define THREADPOOL_H +/* + * Copyright (C) 2013 ~ 2017 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +class ThreadPool : public QObject +{ + Q_OBJECT +public: + explicit ThreadPool(QObject *parent = 0); + ~ThreadPool(); + + static ThreadPool *Instance(); + QThread *createNewThread(); + void exitAllThreads(); + +private: + QList thread_pool; +}; + +#endif // THREADPOOL_H diff --git a/component/tipdialog.cpp b/component/tipdialog.cpp new file mode 100644 index 0000000..d49d658 --- /dev/null +++ b/component/tipdialog.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "tipdialog.h" +#include "mainwindow.h" +#include +#include + +TipDialog::TipDialog(QWidget *parent, QString msg) + :QDialog(parent), message(msg) +{ + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); + this->setFixedSize(410, 180); + setWindowFlags(Qt::FramelessWindowHint); + + title_bar = new KylinTitleBar(); + initTitleBar(); + msg_label = new QLabel(); + msg_label->setWordWrap(true);//QLabel自动换行 + msg_label->setFixedWidth(380); + msg_label->setText(message); + okBtn = new QPushButton(); + okBtn->setFixedSize(91, 25); + okBtn->setObjectName("blackButton"); + okBtn->setFocusPolicy(Qt::NoFocus); + + QHBoxLayout *h_layout = new QHBoxLayout(); + h_layout->addStretch(); + h_layout->addWidget(okBtn); + h_layout->setMargin(0); + h_layout->setContentsMargins(0,0,0,0); + + QVBoxLayout *v_layout = new QVBoxLayout(); + v_layout->addWidget(msg_label); + v_layout->addLayout(h_layout); + v_layout->setSpacing(40); + v_layout->setMargin(0); + v_layout->setContentsMargins(10, 40, 10, 0); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(title_bar); + main_layout->addLayout(v_layout); + main_layout->addStretch(); + main_layout->setSpacing(0); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + setLayout(main_layout); + this->setLanguage(); + this->initConnect(); +} + +TipDialog::~TipDialog() +{ + if(title_bar != NULL) { + delete title_bar; + title_bar = NULL; + } + if(msg_label != NULL) { + delete msg_label; + msg_label = NULL; + } + if(okBtn != NULL) { + delete okBtn; + okBtn = NULL; + } +} + +void TipDialog::setLanguage() +{ + okBtn->setText(tr("OK")); +} + + +void TipDialog::onOKButtonClicked() +{ + this->close(); +} + +void TipDialog::initConnect() +{ + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); + connect(okBtn,SIGNAL(clicked()), this, SLOT(onOKButtonClicked())); +} + +void TipDialog::onCloseButtonClicked() +{ + this->close(); +} + +void TipDialog::initTitleBar() +{ + title_bar->setTitleWidth(410); + title_bar->setTitleName(tr("Tip Dialog")); + title_bar->setTitleBackgound(":/background/res/skin/1.png"); +} diff --git a/component/tipdialog.h b/component/tipdialog.h new file mode 100644 index 0000000..2f628c8 --- /dev/null +++ b/component/tipdialog.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef TIPDIALOG_H +#define TIPDIALOG_H + +#include + +#include "../component/kylinlistwidget.h" +#include "../component/kylintitlebar.h" + +class SessionDispatcher; +class MainWindow; + +class TipDialog :public QDialog +{ + Q_OBJECT +public: + TipDialog(QWidget *parent = 0, QString msg = ""); + ~TipDialog(); + void setParentWindow(MainWindow *From) { mainwindow = From;} + void setLanguage(); + void initConnect(); + +public slots: + void onCloseButtonClicked(); + void onOKButtonClicked(); + +private: + void initTitleBar(); + +private: + MainWindow *mainwindow; + KylinTitleBar *title_bar; + QLabel *msg_label; + QPushButton *okBtn; + QString message; +}; + +#endif // TIPDIALOG_H diff --git a/component/toolbutton.cpp b/component/toolbutton.cpp new file mode 100644 index 0000000..3b196be --- /dev/null +++ b/component/toolbutton.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "toolbutton.h" +#include +#include +#include +#include +#include +#include + +ToolButton::ToolButton(QWidget *parent, bool whiteflag) : + QWidget(parent) +{ + this->setWindowFlags(Qt::FramelessWindowHint); + this->setAutoFillBackground(true); + this->setCursor(Qt::PointingHandCursor); + this->setFixedSize(90, 90); + this->setFocusPolicy(Qt::NoFocus); + QPalette palette; + palette.setColor(this->backgroundRole(), QColor(255,255,255));//#ffffff + this->setPalette(palette); + iconLabel = new QLabel; + textLabel = new QLabel; + if(whiteflag) + textLabel->setObjectName("backgroundWhiteLabel"); + else + textLabel->setObjectName("backgroundLabel"); + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(iconLabel, 0, Qt::AlignCenter); + layout->addWidget(textLabel, 0, Qt::AlignHCenter); + layout->setContentsMargins(0, 10, 0, 10); + this->setLayout(layout); +} + +ToolButton::~ToolButton() +{ + if(iconLabel != NULL) { + delete iconLabel; + iconLabel = NULL; + } + if(textLabel != NULL) { + delete textLabel; + textLabel = NULL; + } +} + +void ToolButton::setIcon(const QString &icon) +{ + QPixmap pixmap(icon); + iconLabel->setPixmap(pixmap); + iconLabel->setFixedSize(pixmap.size()); +} + +void ToolButton::setText(const QString &text) +{ + QFont ft; + QFontMetrics fm(ft); + QString elided_text = fm.elidedText(text, Qt::ElideRight, 90); + textLabel->setText(elided_text); + textLabel->adjustSize(); + if(elided_text.endsWith("…")) + this->setToolTip(text); +} + +void ToolButton::setToolButtonStatus(BUTTONSTATUS status) +{ + QPalette palette; + switch (status) { + case BUTTON_ENTER: + palette.setColor(this->backgroundRole(), QColor(233,238,241));//#e9eef1 + this->setPalette(palette); + break; + case BUTTON_LEAVE: + palette.setColor(this->backgroundRole(), QColor(255,255,255));//#ffffff + this->setPalette(palette); + break; + case BUTTON_PRESSED: + palette.setColor(this->backgroundRole(), QColor(233,238,241));//#e9eef1 + this->setPalette(palette); + break; + default: + break; + } +// QPalette palette; +//// palette.setBrush(this->backgroundRole(),QBrush(Qt::green)); +//// palette.setBrush(QPalette::Window, QBrush(Qt::white)); +//// palette.setColor(QPalette::Background, QColor(233,238,241));//#e9eef1 +// palette.setColor(this->backgroundRole(), QColor(233,238,241));//#e9eef1 +// this->setPalette(palette); +} + +void ToolButton::enterEvent(QEvent *) +{ + setToolButtonStatus(BUTTON_ENTER); +} + +void ToolButton::leaveEvent(QEvent *) +{ + setToolButtonStatus(BUTTON_LEAVE); +} + +void ToolButton::mousePressEvent(QMouseEvent *e) +{ + if (e->button() == Qt::LeftButton) + { + ToolButton(BUTTON_PRESSED); + } + else + { + e->ignore(); + } +} + +void ToolButton::mouseReleaseEvent(QMouseEvent *e) +{ + if(e->button() == Qt::LeftButton) + { + if(rect().contains(e->pos())) + { + if(this->isEnabled()) { + emit clicked(); + } + setToolButtonStatus(BUTTON_ENTER); + e->accept(); + }else{ + setToolButtonStatus(BUTTON_LEAVE); + e->ignore(); + } + } + else + { + e->ignore(); + } +} diff --git a/component/toolbutton.h b/component/toolbutton.h new file mode 100644 index 0000000..0e6875e --- /dev/null +++ b/component/toolbutton.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef TOOLBUTTON_H +#define TOOLBUTTON_H + +#include +#include "utils.h" + +class QLabel; + +class ToolButton : public QWidget +{ + Q_OBJECT +public: + explicit ToolButton(QWidget *parent = 0, bool whiteflag = false); + ~ToolButton(); + void setIcon(const QString &icon); + void setText(const QString &text); + void setToolButtonStatus(BUTTONSTATUS status); + +protected: + void enterEvent(QEvent *); + void leaveEvent(QEvent *); + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + +signals: + void clicked(); + +private: + QLabel *iconLabel; + QLabel *textLabel; +}; + +#endif // TOOLBUTTON_H diff --git a/component/toolkits.cpp b/component/toolkits.cpp new file mode 100644 index 0000000..b78b4ce --- /dev/null +++ b/component/toolkits.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "toolkits.h" + +Toolkits::Toolkits(QObject *parent, int width, int height) : + QObject(parent), parent_width(width), parent_height(height) +{ + this->alert_width = 200; + this->alert_height = 75; + + alertBG = new AlertDialog(); + this->alertTimer = new QTimer(this); + connect(alertTimer, SIGNAL(timeout()), this, SLOT(updateAlert())); + this->alertDelayTimer = new QTimer(this); + connect(alertDelayTimer, SIGNAL(timeout()), this, SLOT(hideAlert())); + this->alertGOE = new QGraphicsOpacityEffect(); + this->alertBG->setGraphicsEffect(alertGOE); + this->ao = 0.0; + this->alertBG->hide(); +} + +Toolkits::~Toolkits() +{ + if(alertGOE != NULL) { + delete alertGOE; + alertGOE = NULL; + } + if(alertBG != NULL) { + delete alertBG; + alertBG = NULL; + } + if (alertTimer != NULL) { + disconnect(alertTimer,SIGNAL(timeout()),this,SLOT(updateAlert())); + if(alertTimer->isActive()) { + alertTimer->stop(); + } + delete alertTimer; + alertTimer = NULL; + } + if (alertDelayTimer != NULL) { + disconnect(alertDelayTimer,SIGNAL(timeout()),this,SLOT(hideAlert())); + if(alertDelayTimer->isActive()) { + alertDelayTimer->stop(); + } + delete alertDelayTimer; + alertDelayTimer = NULL; + } +} + +//启动alert提示 +void Toolkits::alertMSG(int x, int y, const QString &alertText) { + this->alert_x = x + (this->parent_width / 2) - (this->alert_width / 2); + this->alert_y = y + (this->parent_height /2) - (this->alert_height / 2); + + this->ay = this->alert_y; + this->ao = 0.0; + this->alertBG->move(this->alert_x, this->alert_y); + this->alertGOE->setOpacity(this->ao); + this->alertBG->setMSG(alertText); + this->alertBG->show(); + this->alertTimer->start(15); +} +//alert提示框的步处理 +void Toolkits::updateAlert() { + if(this->ao < 0.90){ + this->ao += 0.02; + this->alertGOE->setOpacity(this->ao); + } + if(this->ay <= (this->alert_y - 150)){ + this->alertTimer->stop(); + //5秒后自动关闭alert提示框 + this->alertDelayTimer->start(1000); + }else{ + this->ay -= 3; + this->alertBG->move(this->alert_x,this->ay); + } +} +//隐藏alert提示框 +void Toolkits::hideAlert() { + this->alertBG->hide(); + this->alertDelayTimer->stop(); +} diff --git a/component/toolkits.h b/component/toolkits.h new file mode 100644 index 0000000..632d186 --- /dev/null +++ b/component/toolkits.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef TOOLKITS_H +#define TOOLKITS_H + +#include +#include +#include +#include "alertdialog.h" + +class Toolkits : public QObject +{ + Q_OBJECT +public: + explicit Toolkits(QObject *parent = 0, int width = 0, int height = 0); + ~Toolkits(); + //启动alert提示 + Q_INVOKABLE void alertMSG(int x, int y, const QString &alertText); +private: + int parent_width; + int parent_height; + int alert_width; + int alert_height; + //本次alert的x坐标 + int alert_x; + //保额次alert的y坐标 + int alert_y; + + //alert message提示框 + AlertDialog *alertBG; + //alert提示框timer + QTimer *alertTimer; + //alert提示框隐藏timer + QTimer *alertDelayTimer; + //alert提示框GOE + QGraphicsOpacityEffect *alertGOE; + //alert提示框透明度 + float ao; + //alert提示框y坐标 + int ay; +private slots: + //alert提示步处理 + void updateAlert(); + //隐藏alert提示框 + void hideAlert(); +}; + +#endif // TOOLKITS_H diff --git a/component/utils.h b/component/utils.h new file mode 100644 index 0000000..3a83abd --- /dev/null +++ b/component/utils.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef UTILS_H +#define UTILS_H + +#include + +#define ITEMHEIGHT 30 +#define ITEMHSPACE 10 +#define ITEMVSPACE 5 +#define PAGESPACE 20 +#define ITEMWIDTH 650 + +#define VERSION "2.4.1" + +const QString YOUKER_COMPANY_SETTING = "ubuntukylin/youker-assistant"; +const QString YOUKER_SETTING_FILE_NAME_SETTING = "youker-assistant"; + +typedef enum{ + YOUKER_EN, + YOUKER_ZH_CN, + YOUKER_ES, +} LANGUAGE; + +typedef enum{ + CACHE, + PACAKAGE, + COOKIES, + BROWSER, + TRACE, + BIGFILE, +} CLEANERTAB; + +struct AutoData +{ + QString appPath; + QString appName; + QString appComment; + QString iconName; + QString appStatus; +}; + +typedef enum{ + BUTTON_ENTER, + BUTTON_LEAVE, + BUTTON_PRESSED, + BUTTON_DISABLE, + BUTTON_FIRST, + BUTTON_SCALED, +}BUTTONSTATUS; + +typedef enum{ + HOMEPAGE, + CLEANPAGE, + INFOPAGE, + SETTINGPAGE, + BOXPAGE, +}PAGESTATUS; + +#endif // UTILS_H diff --git a/component/workthread.h b/component/workthread.h new file mode 100644 index 0000000..c6af651 --- /dev/null +++ b/component/workthread.h @@ -0,0 +1,33 @@ +#include +#include +#include "../dbusproxy/youkersystemdbus.h" + +class WorkerThread : public QThread +{ + Q_OBJECT + +public: + explicit WorkerThread(QObject *parent = 0) + : QThread(parent) + { +// qDebug() << "Worker Thread : " << QThread::currentThreadId(); + } + void initInterface(SystemDispatcher *systemiface) { + iface = systemiface; + } + +protected: +// virtual void run() Q_DECL_OVERRIDE { + void run() + { +// qDebug() << "Worker Run Thread : " << QThread::currentThreadId(); + QMap wire_info_map; + wire_info_map = iface->get_networkcard_info_qt(); + emit resultReady(wire_info_map); + } +signals: + void resultReady(QMap value); + +private: + SystemDispatcher *iface; +}; diff --git a/dbusproxy/youkersessiondbus.cpp b/dbusproxy/youkersessiondbus.cpp new file mode 100644 index 0000000..272a129 --- /dev/null +++ b/dbusproxy/youkersessiondbus.cpp @@ -0,0 +1,1365 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "youkersessiondbus.h" +#include + +SessionDispatcher::SessionDispatcher(QObject *parent) + : QObject(parent) +{ + sessioniface = new QDBusInterface("com.ubuntukylin.session", + "/", + "com.ubuntukylin.session", + QDBusConnection::sessionBus()); + +// QObject::connect(sessioniface, SIGNAL(autostartmanage_data_signal(QVariantMap)), this, SLOT(handlerAutoManageData(QVariantMap))); + QObject::connect(sessioniface, SIGNAL(autostartmanage_data_signal(QStringList)), this, SLOT(handlerAutoManageData(QStringList))); + QObject::connect(sessioniface, SIGNAL(autostartmanage_status_signal(QString)), this, SLOT(handlerAutoManageStatus(QString))); + QObject::connect(sessioniface, SIGNAL(autostartmanage_error_signal(QString)), this, SLOT(handlerAutoManageError(QString))); + + QObject::connect(sessioniface, SIGNAL(subpage_data_signal(QStringList)), this, SLOT(handlerScanCleanerData(QStringList))); + QObject::connect(sessioniface, SIGNAL(subpage_status_signal(QString)), this, SLOT(handlerScanCleanerStatus(QString))); + QObject::connect(sessioniface, SIGNAL(subpage_error_signal(QString)), this, SLOT(handlerScanCleanerError(QString))); + +// thread = new KThread(this); + + + //kobe + check_thread = new KThread(this); + scan_thread = new KThread(this); + onekey_scan_thread = new KThread(this); + + QObject::connect(sessioniface, SIGNAL(display_scan_process(QString)), this, SLOT(handler_scan_process(QString))); + QObject::connect(sessioniface, SIGNAL(scan_complete(QString)), this, SLOT(handler_scan_complete(QString))); + QObject::connect(sessioniface, SIGNAL(total_data_transmit(QString, QString)), this, SLOT(handler_total_data_transmit(QString,QString))); + QObject::connect(sessioniface, SIGNAL(youkerid_whoami_signal(QString, QString)), this, SLOT(handlerYoukerID(QString, QString))); + QObject::connect(sessioniface, SIGNAL(youkerid_logout_signal()), this, SLOT(handlerLogoutSuccess())); + QObject::connect(sessioniface, SIGNAL(youkerid_login_fail_signal()), this, SLOT(handlerLoginFail())); + + + QObject::connect(sessioniface, SIGNAL(notify_boolean(QString, bool)), this, SLOT(handler_notify_boolean(QString, bool))); + QObject::connect(sessioniface, SIGNAL(notify_int(QString, int)), this, SLOT(handler_notify_int(QString, int))); + QObject::connect(sessioniface, SIGNAL(notify_double(QString, double)), this, SLOT(handler_notify_double(QString, double))); + QObject::connect(sessioniface, SIGNAL(notify_string(QString, QString)), this, SLOT(handler_notify_string(QString, QString))); + + QObject::connect(sessioniface, SIGNAL(check_source_list_signal(bool)), this, SIGNAL(receive_source_list_signal(bool))); +} + +SessionDispatcher::~SessionDispatcher() { + check_thread->terminate(); + check_thread->wait(); + if(check_thread != NULL) { + delete check_thread; + check_thread = NULL; + } + scan_thread->terminate(); + scan_thread->wait(); + if(scan_thread != NULL) { + delete scan_thread; + scan_thread = NULL; + } + onekey_scan_thread->terminate(); + onekey_scan_thread->wait(); + if(onekey_scan_thread != NULL) { + delete onekey_scan_thread; + onekey_scan_thread = NULL; + } + + +// thread->terminate(); +// thread->wait(); +// if(thread != NULL) { +// delete thread; +// thread = NULL; +// } + this->exit_qt(); + if (sessioniface != NULL) { + delete sessioniface; + sessioniface = NULL; + } +} + +//dbus服务退出 +void SessionDispatcher::exit_qt() { + sessioniface->call("exit"); +} + +QString SessionDispatcher::get_os_release_qt() +{ + QDBusReply reply = sessioniface->call("get_os_release"); + return reply.value(); +} + +QStringList SessionDispatcher::checkNewVersion() +{ + QDBusReply reply = sessioniface->call("currently_installed_version"); + return reply.value(); +} + +bool SessionDispatcher::start_check_source_useable_qt() +{ +// QDBusReply reply = sessioniface->call("start_check_source_useable"); +// return reply.value(); + if (check_thread->isRunning()) { + qDebug() << "check_thread is running......"; + } + else { + QMap data; + QStringList tmplist; + check_thread->initValues(data, tmplist, sessioniface, "start_check_source_useable"); + check_thread->start(); +// qDebug() << "check_thread is ready to run......"; + } +} + +void SessionDispatcher::runApp(QString pkgname) +{ + sessioniface->call("run_selected_app", pkgname); +} + +void SessionDispatcher::handlerAutoManageData(QStringList data) +//void SessionDispatcher::handlerAutoManageData(const QVariantMap &data) +{ + emit this->tellAutoModel(data); +} + +void SessionDispatcher::handlerAutoManageStatus(QString status) +{ + emit this->showAutoModel(); +} + +void SessionDispatcher::handlerAutoManageError(QString status) +{ + +} + +void SessionDispatcher::getAutoStartAppStatus() +{ + sessioniface->call("get_current_autostart_status"); +} + +bool SessionDispatcher::getSingleAutoStartStatus(QString abs_path) +{ + QDBusReply reply = sessioniface->call("get_current_single_autostart_status", abs_path); + return reply.value(); +} + + +void SessionDispatcher::changeAutoStartAppStatus(QString appName) +{ + sessioniface->call("change_autostart_status", appName); +} + +void SessionDispatcher::handlerScanCleanerData(QStringList data) +{ + emit this->tellCleanerDetailData(data); +} + +void SessionDispatcher::handlerScanCleanerStatus(QString status) +{ + emit this->tellCleanerDetailStatus(status); +} + +void SessionDispatcher::handlerScanCleanerError(QString status) +{ + emit this->tellCleanerDetailError(status); +} + +//bool SessionDispatcher::judge_camera_qt() { +// QDBusReply reply = sessioniface->call("judge_camera"); +// return reply.value(); +//} + +//void SessionDispatcher::call_camera_qt() { +// sessioniface->call("call_camera"); +//// if (thread->isRunning()) { +//// qDebug() << "camera_thread is running......"; +//// } +//// else { +//// qDebug() << "camera_thread is ready to run......"; +//// QStringList tmp; +//// QMap data; +//// thread->initValues(data, tmp, sessioniface, "call_camera"); +//// thread->start(); +//// } +//} + +bool SessionDispatcher::judge_power_is_exists_qt() { + QDBusReply reply = sessioniface->call("judge_power_is_exists"); + return reply.value(); +} + +QMap SessionDispatcher::read_battery_info_qt() +{ + QMap value; + QDBusReply > reply = sessioniface->call("read_battery_info"); + if (reply.isValid()) { + value = reply.value(); + if (value.contains("POWER_SUPPLY_VOLTAGE_NOW")) { + value["POWER_SUPPLY_VOLTAGE_NOW"] = QString::number(value["POWER_SUPPLY_VOLTAGE_NOW"].toDouble()/1000000, 'f', 1) + "V"; + } + if (value.contains("POWER_SUPPLY_ENERGY_FULL_DESIGN")) { + value["POWER_SUPPLY_ENERGY_FULL_DESIGN"] = QString::number(value["POWER_SUPPLY_ENERGY_FULL_DESIGN"].toDouble()/1000000, 'f', 1) + "Wh"; + } + if (value.contains("POWER_SUPPLY_ENERGY_FULL")) { + value["POWER_SUPPLY_ENERGY_FULL"] = QString::number(value["POWER_SUPPLY_ENERGY_FULL"].toDouble()/1000000, 'f', 1) + "Wh"; + } + if (value.contains("POWER_SUPPLY_ENERGY_NOW")) { + value["POWER_SUPPLY_ENERGY_NOW"] = QString::number(value["POWER_SUPPLY_ENERGY_NOW"].toDouble()/1000000, 'f', 1) + "Wh"; + } + return value; + } + else { + qDebug() << "get battery_message failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +void SessionDispatcher::open_folder_qt(QString path) { + sessioniface->call("open_folder", path); +} + +void SessionDispatcher::check_user_qt() { + sessioniface->call("check_user"); +} + +//弹出登录框 +void SessionDispatcher::popup_login_dialog() { + //add ubuntukylin sso + sessioniface->call("slot_do_login_account"); +} + +void SessionDispatcher::popup_register_dialog() { + //add ubuntukylin sso + sessioniface->call("slot_do_register"); +} + +//退出登录 +void SessionDispatcher::logout_ubuntukylin_account() { + //add ubuntukylin sso + sessioniface->call("slot_do_logout"); +} + +void SessionDispatcher::handlerYoukerID(QString displayName, QString emailAddress) { + emit this->ssoSuccessSignal(displayName, emailAddress); +} + +void SessionDispatcher::handlerLogoutSuccess() { + emit this->ssoLoginLogoutSignal(true); +} + +void SessionDispatcher::handlerLoginFail() { + emit this->ssoLoginLogoutSignal(false); +} + +void SessionDispatcher::handler_scan_complete(QString msg) { + emit finishScanWork(msg); +} + +void SessionDispatcher::handler_scan_process(QString msg) { + emit isScanning(msg); +} + +void SessionDispatcher::handler_total_data_transmit(QString flag, QString msg) { + emit tellScanResult(flag, msg); +} + +//QString SessionDispatcher::get_locale_version() { +// QString locale = QLocale::system().name(); +// return locale; +//} + +void SessionDispatcher::onekey_scan_function_qt(QStringList selectedList) { +// QMap data; +// thread->initValues(data, selectedList, sessioniface, "onekey_scan_function"); +// thread->start(); + + if (scan_thread->isRunning()) { + qDebug() << "onekey_scan_thread is running......"; + } + else { +// qDebug() << "onekey_scan_thread is ready to run......"; + QMap data; + onekey_scan_thread->initValues(data, selectedList, sessioniface, "onekey_scan_function"); + onekey_scan_thread->start(); + } +} + +void SessionDispatcher::scanSystemCleanerItems(QMap data) +{ +// QStringList tmp; +// thread->initValues(data, tmp, sessioniface, "get_scan_result"); +// thread->start(); + if (scan_thread->isRunning()) { + qDebug() << "scan_thread is running......"; + } + else { +// if (scan_thread == NULL) +// qDebug() << "scan_thread is null, ready to run......"; +// else +// qDebug() << "scan_thread is not null, ready to run......"; + QStringList tmp; + scan_thread->initValues(data, tmp, sessioniface, "get_scan_result"); + scan_thread->start(); +// QElapsedTimer et; +// et.start(); +// while(et.elapsed()<300) +// QCoreApplication::processEvents(); + } +} + +QString SessionDispatcher::getHomePath() { + QString homepath = QDir::homePath(); + return homepath; +} + +//QString SessionDispatcher::get_session_daemon_qt() { +// QDBusReply reply = sessioniface->call("get_session_daemon"); +// return reply.value(); +//} + +QMap SessionDispatcher::get_system_message_qt() +{ + QMap value; + QDBusReply > reply = sessioniface->call("get_system_message"); + if (reply.isValid()) { + value = reply.value(); + return value; +// systemInfo.clear(); +// systemInfo = value; + //把当前登录的用户名存放到QSetting配置文件中,方便任务管理器使用 +// mSettings->beginGroup("user"); +// mSettings->setValue("currentName", systemInfo["currrent_user"].toString()); +// mSettings->endGroup(); +// mSettings->sync(); + } + else { + qDebug() << "get pc_message failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +/*-----------------------------desktop of beauty-----------------------------*/ +bool SessionDispatcher::set_show_desktop_icons_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_desktop_icons", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_desktop_icons_qt() { + QDBusReply reply = sessioniface->call("get_show_desktop_icons"); + return reply.value(); +} + +bool SessionDispatcher::set_show_computer_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_computer", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_computer_qt() { + QDBusReply reply = sessioniface->call("get_show_computer"); + return reply.value(); +} + +bool SessionDispatcher::set_show_homefolder_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_homefolder", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_homefolder_qt() { + QDBusReply reply = sessioniface->call("get_show_homefolder"); + return reply.value(); +} + +bool SessionDispatcher::set_show_network_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_network", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_network_qt() { + QDBusReply reply = sessioniface->call("get_show_network"); + return reply.value(); +} + +bool SessionDispatcher::set_show_trash_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_trash", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_trash_qt() { + QDBusReply reply = sessioniface->call("get_show_trash"); + return reply.value(); +} + +bool SessionDispatcher::set_show_devices_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_devices", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_devices_qt() { + QDBusReply reply = sessioniface->call("get_show_devices"); + return reply.value(); +} + +//bool SessionDispatcher::get_show_cinnamon_desktop_icons_qt() { +// QDBusReply reply = sessioniface->call("get_show_cinnamon_desktop_icons"); +// return reply.value(); +//} + +//bool SessionDispatcher::set_show_cinnamon_desktop_icons_qt(bool flag) { +// QDBusReply reply = sessioniface->call("set_show_cinnamon_desktop_icons", flag); +// return reply.value(); +//} + +//bool SessionDispatcher::get_show_cinnamon_computer_qt() { +// QDBusReply reply = sessioniface->call("get_show_cinnamon_computer"); +// return reply.value(); +//} + +//bool SessionDispatcher::set_show_cinnamon_computer_qt(bool flag) { +// QDBusReply reply = sessioniface->call("set_show_cinnamon_computer", flag); +// return reply.value(); +//} + +//bool SessionDispatcher::get_show_cinnamon_homefolder_qt() { +// QDBusReply reply = sessioniface->call("get_show_cinnamon_homefolder"); +// return reply.value(); +//} + +//bool SessionDispatcher::set_show_cinnamon_homefolder_qt(bool flag) { +// QDBusReply reply = sessioniface->call("set_show_cinnamon_homefolder", flag); +// return reply.value(); +//} + +//bool SessionDispatcher::get_show_cinnamon_network_qt() { +// QDBusReply reply = sessioniface->call("get_show_cinnamon_network"); +// return reply.value(); +//} + +//bool SessionDispatcher::set_show_cinnamon_network_qt(bool flag) { +// QDBusReply reply = sessioniface->call("set_show_cinnamon_network", flag); +// return reply.value(); +//} + +//bool SessionDispatcher::get_show_cinnamon_trash_qt() { +// QDBusReply reply = sessioniface->call("get_show_cinnamon_trash"); +// return reply.value(); +//} + +//bool SessionDispatcher::set_show_cinnamon_trash_qt(bool flag) { +// QDBusReply reply = sessioniface->call("set_show_cinnamon_trash", flag); +// return reply.value(); +//} + +//bool SessionDispatcher::get_show_cinnamon_devices_qt() { +// QDBusReply reply = sessioniface->call("get_show_cinnamon_devices"); +// return reply.value(); +//} +//bool SessionDispatcher::set_show_cinnamon_devices_qt(bool flag) { +// QDBusReply reply = sessioniface->call("set_show_cinnamon_devices", flag); +// return reply.value(); +//} + +/*-----------------------------unity of beauty-----------------------------*/ +//void SessionDispatcher::set_default_launcher_have_showdesktopicon_qt() { +// sessioniface->call("set_default_launcher_have_showdesktopicon"); +//} + +bool SessionDispatcher::set_launcher_autohide_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_launcher_autohide", flag); + return reply.value(); +} + +bool SessionDispatcher::get_launcher_autohide_qt() { + QDBusReply reply = sessioniface->call("get_launcher_autohide"); + return reply.value(); +} + +bool SessionDispatcher::set_launcher_icon_size_qt(int num) { + QDBusReply reply = sessioniface->call("set_launcher_icon_size", num); + return reply.value(); +} + +int SessionDispatcher::get_launcher_icon_size_qt() { + QDBusReply reply = sessioniface->call("get_launcher_icon_size"); + return reply.value(); +} +bool SessionDispatcher::set_launcher_have_showdesktopicon_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_launcher_have_showdesktopicon", flag); + return reply.value(); +} + +bool SessionDispatcher::get_launcher_have_showdesktopicon_qt() { + QDBusReply reply = sessioniface->call("get_launcher_have_showdesktopicon"); + return reply.value(); +} + +//-----------------------------------------------mate---------------------------------------------- +bool SessionDispatcher::set_mate_panel_autohide_qt(QString positon, bool flag) +{ + QDBusReply reply = sessioniface->call("set_mate_panel_autohide", positon, flag); + return reply.value(); +} + +bool SessionDispatcher::get_mate_panel_autohide_qt(QString positon) +{ + QDBusReply reply = sessioniface->call("get_mate_panel_autohide", positon); + return reply.value(); +} + +bool SessionDispatcher::set_mate_panel_icon_size_qt(QString positon, int num) +{ + QDBusReply reply = sessioniface->call("set_mate_panel_icon_size", positon, num); + return reply.value(); +} + +int SessionDispatcher::get_mate_panel_icon_size_qt(QString positon) +{ + QDBusReply reply = sessioniface->call("get_mate_panel_icon_size", positon); + return reply.value(); +} + +//透明度 +double SessionDispatcher::get_launcher_transparency_qt() { + QDBusReply reply = sessioniface->call("get_launcher_transparency"); + return reply.value(); +} + +bool SessionDispatcher::set_launcher_transparency_qt(double opacity) { + QDBusReply reply = sessioniface->call("set_launcher_transparency", opacity); + return reply.value(); +} + +//图标背景 +QStringList SessionDispatcher::get_all_launcher_icon_colourings_qt() { + QDBusReply reply = sessioniface->call("get_all_launcher_icon_colourings"); + return reply.value(); +} + +int SessionDispatcher::get_launcher_icon_colouring_qt() { + QDBusReply reply = sessioniface->call("get_launcher_icon_colouring"); + return reply.value(); +} + +bool SessionDispatcher::set_launcher_icon_colouring_qt(int colouring) { + QDBusReply reply = sessioniface->call("set_launcher_icon_colouring", colouring); + return reply.value(); +} + +//Dash背景模糊类型 +int SessionDispatcher::get_dash_blur_experimental_qt() { + QDBusReply reply = sessioniface->call("get_dash_blur_experimental"); + return reply.value(); +} + +bool SessionDispatcher::set_dash_blur_experimental_qt(int blur) { + QDBusReply reply = sessioniface->call("set_dash_blur_experimental", blur); + return reply.value(); +} + +//面板菜单透明度 +double SessionDispatcher::get_panel_transparency_qt() { + QDBusReply reply = sessioniface->call("get_panel_transparency"); + return reply.value(); +} + +bool SessionDispatcher::set_panel_transparency_qt(double opacity) { + QDBusReply reply = sessioniface->call("set_panel_transparency", opacity); + return reply.value(); +} + +//日期时间格式 +QStringList SessionDispatcher::get_all_time_format_qt() { + QDBusReply reply = sessioniface->call("get_all_time_format"); + return reply.value(); +} + +QString SessionDispatcher::get_time_format_qt() { + QDBusReply reply = sessioniface->call("get_time_format"); + return reply.value(); +} + +bool SessionDispatcher::set_time_format_qt(QString format) { + QDBusReply reply = sessioniface->call("set_time_format", format); + return reply.value(); +} + +bool SessionDispatcher::get_show_seconds_qt() { + QDBusReply reply = sessioniface->call("get_show_seconds"); + return reply.value(); +} + +bool SessionDispatcher::set_show_seconds_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_seconds", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_week_qt() { + QDBusReply reply = sessioniface->call("get_show_week"); + return reply.value(); +} + +bool SessionDispatcher::set_show_week_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_week", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_date_qt() { + QDBusReply reply = sessioniface->call("get_show_date"); + return reply.value(); +} + +bool SessionDispatcher::set_show_date_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_date", flag); + return reply.value(); +} + +//电源 +QStringList SessionDispatcher::get_all_power_icon_policy_qt() { + QDBusReply reply = sessioniface->call("get_all_power_icon_policy"); + return reply.value(); +} + +QString SessionDispatcher::get_power_icon_policy_qt() { + QDBusReply reply = sessioniface->call("get_power_icon_policy"); + return reply.value(); +} + +bool SessionDispatcher::set_power_icon_policy_qt(QString format) { + QDBusReply reply = sessioniface->call("set_power_icon_policy", format); + return reply.value(); +} + +bool SessionDispatcher::get_show_power_time_qt() { + QDBusReply reply = sessioniface->call("get_show_power_time"); + return reply.value(); +} + +bool SessionDispatcher::set_show_power_time_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_power_time", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_power_percentage_qt() { + QDBusReply reply = sessioniface->call("get_show_power_percentage"); + return reply.value(); +} + +bool SessionDispatcher::set_show_power_percentage_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_power_percentage", flag); + return reply.value(); +} + +//--------------------------mate-------------------- +bool SessionDispatcher::get_show_apps_qt() { + QDBusReply reply = sessioniface->call("get_show_apps"); + return reply.value(); +} + +bool SessionDispatcher::set_show_apps_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_apps", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_desktop_qt() { + QDBusReply reply = sessioniface->call("get_show_desktop"); + return reply.value(); +} + +bool SessionDispatcher::set_show_desktop_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_desktop", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_icon_qt() { + QDBusReply reply = sessioniface->call("get_show_icon"); + return reply.value(); +} + +bool SessionDispatcher::set_show_icon_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_icon", flag); + return reply.value(); +} + +bool SessionDispatcher::get_show_places_qt() { + QDBusReply reply = sessioniface->call("get_show_places"); + return reply.value(); +} + +bool SessionDispatcher::set_show_places_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_show_places", flag); + return reply.value(); +} + + +/*-----------------------------theme of beauty-----------------------------*/ +QStringList SessionDispatcher::get_themes_qt() { + QDBusReply reply = sessioniface->call("get_themes"); + return reply.value(); +} + +QString SessionDispatcher::get_theme_qt() { + QDBusReply reply = sessioniface->call("get_theme"); + return reply.value(); +} + +void SessionDispatcher::set_theme_qt(QString theme) { + sessioniface->call("set_theme", theme); +} + +QStringList SessionDispatcher::get_icon_themes_qt() { + QDBusReply reply = sessioniface->call("get_icon_themes"); + return reply.value(); +} + +QString SessionDispatcher::get_icon_theme_qt() { + QDBusReply reply = sessioniface->call("get_icon_theme"); + return reply.value(); +} + +void SessionDispatcher::set_icon_theme_qt(QString theme) { + sessioniface->call("set_icon_theme", theme); +} + +QStringList SessionDispatcher::get_cursor_themes_qt() { + QDBusReply reply = sessioniface->call("get_cursor_themes"); + return reply.value(); +} + +QString SessionDispatcher::get_cursor_theme_qt() { + QDBusReply reply = sessioniface->call("get_cursor_theme"); + return reply.value(); +} + +void SessionDispatcher::set_cursor_theme_qt(QString theme) { + sessioniface->call("set_cursor_theme", theme); +} + +int SessionDispatcher::get_cursor_size_qt() { + QDBusReply reply = sessioniface->call("get_cursor_size"); + return reply.value(); +} +void SessionDispatcher::set_cursor_size_qt(int size) { + sessioniface->call("set_cursor_size", size); +} + +//window theme +//QStringList SessionDispatcher::get_window_themes_qt() { +// QDBusReply reply = sessioniface->call("get_window_themes"); +// return reply.value(); +//} + +//QString SessionDispatcher::get_current_window_theme_qt() { +// QDBusReply reply = sessioniface->call("get_current_window_theme"); +// return reply.value(); +//} + +//void SessionDispatcher::set_window_theme_qt(QString theme) { +// sessioniface->call("set_window_theme", theme); +//} + +QString SessionDispatcher::get_default_font_string_qt(QString schema, QString key) +{ + QDBusReply reply = sessioniface->call("get_default_font_string", schema, key); + return reply.value(); +} + +bool SessionDispatcher::set_default_font_string_qt(QString schema, QString key, QString type) +{ + QDBusReply reply = sessioniface->call("set_default_font", schema, key, type); + return reply.value(); +} + +QString SessionDispatcher::get_font_qt() { + QDBusReply reply = sessioniface->call("get_font"); + return reply.value(); +} + +//bool SessionDispatcher::set_font_qt_default(QString font) { +// QDBusReply reply = sessioniface->call("set_font", font); +// return reply.value(); +//} + +bool SessionDispatcher::set_font_qt(QString font) { + QDBusReply reply = sessioniface->call("set_font", font); + return reply.value(); +} + +QString SessionDispatcher::get_desktop_font_qt() { + QDBusReply reply = sessioniface->call("get_desktop_font"); + return reply.value(); +} + +bool SessionDispatcher::set_desktop_font_qt(QString font) { + QDBusReply reply = sessioniface->call("set_desktop_font", font); + return reply.value(); +} + +bool SessionDispatcher::set_desktop_font_qt_default() { + QDBusReply reply = sessioniface->call("set_desktop_font", "Ubuntu 11"); + return reply.value(); +} + +QString SessionDispatcher::get_document_font_qt() { + QDBusReply reply = sessioniface->call("get_document_font"); + return reply.value(); +} + +//bool SessionDispatcher::set_document_font_qt_default(QString font) { +// QDBusReply reply = sessioniface->call("set_document_font", font); +// return reply.value(); +//} + +bool SessionDispatcher::set_document_font_qt(QString font) { + QDBusReply reply = sessioniface->call("set_document_font", font); + return reply.value(); +} + +QString SessionDispatcher::get_monospace_font_qt() { + QDBusReply reply = sessioniface->call("get_monospace_font"); + return reply.value(); +} + +//bool SessionDispatcher::set_monospace_font_qt_default(QString font) { +// QDBusReply reply = sessioniface->call("set_monospace_font", font); +// return reply.value(); +//} + +bool SessionDispatcher::set_monospace_font_qt(QString font) { + QDBusReply reply = sessioniface->call("set_monospace_font", font); + return reply.value(); +} + +QString SessionDispatcher::get_window_title_font_qt() { + QDBusReply reply = sessioniface->call("get_window_title_font"); + return reply.value(); +} + +//bool SessionDispatcher::set_window_title_font_qt_default(QString font) { +// QDBusReply reply = sessioniface->call("set_window_title_font", font); +// return reply.value(); +//} + +bool SessionDispatcher::set_window_title_font_qt(QString font) { + QDBusReply reply = sessioniface->call("set_window_title_font", font); + return reply.value(); +} + +double SessionDispatcher::get_font_zoom_qt() { + QDBusReply reply = sessioniface->call("get_font_zoom"); + return reply.value(); +} + +bool SessionDispatcher::set_font_zoom_qt(double zoom) { + QDBusReply reply = sessioniface->call("set_font_zoom", zoom); + return reply.value(); +} + +QStringList SessionDispatcher::get_smooth_style_list_qt() { + QDBusReply reply = sessioniface->call("get_smooth_style_list"); + return reply.value(); +} + +QString SessionDispatcher::get_smooth_style_qt() { + QDBusReply reply = sessioniface->call("get_smooth_style"); + return reply.value(); +} + +bool SessionDispatcher::set_smooth_style_qt(QString style) { + QDBusReply reply = sessioniface->call("set_smooth_style", style); + return reply.value(); +} + +QStringList SessionDispatcher::get_antialiasing_style_list_qt() { + QDBusReply reply = sessioniface->call("get_antialiasing_style_list"); + return reply.value(); +} + +QString SessionDispatcher::get_antialiasing_style_qt() { + QDBusReply reply = sessioniface->call("get_antialiasing_style"); + return reply.value(); +} + +bool SessionDispatcher::set_antialiasing_style_qt(QString style) { + QDBusReply reply = sessioniface->call("set_antialiasing_style", style); + return reply.value(); +} + +/*-----------------------------scrollbars of beauty-----------------------------*/ +bool SessionDispatcher::set_scrollbars_mode_overlay_qt() { + QDBusReply reply = sessioniface->call("set_scrollbars_mode_overlay"); + return reply.value(); +} + +bool SessionDispatcher::set_scrollbars_mode_legacy_qt() { + QDBusReply reply = sessioniface->call("set_scrollbars_mode_legacy"); + return reply.value(); +} + +QString SessionDispatcher::get_scrollbars_mode_qt() { + QDBusReply reply = sessioniface->call("get_scrollbars_mode"); + return reply.value(); +} + +/*-----------------------------touchpad of beauty-----------------------------*/ +bool SessionDispatcher::set_touchpad_enable_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_touchpad_enable", flag); + return reply.value(); +} + +bool SessionDispatcher::get_touchpad_enable_qt() { + QDBusReply reply = sessioniface->call("get_touchpad_enable"); + return reply.value(); +} + +bool SessionDispatcher::set_touchscrolling_mode_disabled_qt() { + QDBusReply reply = sessioniface->call("set_touchscrolling_mode_disabled"); + return reply.value(); +} + +bool SessionDispatcher::set_touchscrolling_mode_edge_qt() { + QDBusReply reply = sessioniface->call("set_touchscrolling_mode_edge"); + return reply.value(); +} + +bool SessionDispatcher::set_touchscrolling_mode_twofinger_qt() { + QDBusReply reply = sessioniface->call("set_touchscrolling_mode_twofinger"); + return reply.value(); +} + +QString SessionDispatcher::get_touchscrolling_mode_qt() { + QDBusReply reply = sessioniface->call("get_touchscrolling_mode"); + return reply.value(); +} + +bool SessionDispatcher::set_touchscrolling_use_horizontal_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_touchscrolling_use_horizontal", flag); + return reply.value(); +} + +bool SessionDispatcher::get_touchscrolling_use_horizontal_qt() { + QDBusReply reply = sessioniface->call("get_touchscrolling_use_horizontal"); + return reply.value(); +} + +int SessionDispatcher::get_mate_touchscrolling_mode_qt() +{ + QDBusReply reply = sessioniface->call("get_mate_touchscrolling_mode"); + return reply.value(); +} + +bool SessionDispatcher::set_mate_touchscrolling_mode_qt(int value) +{ + QDBusReply reply = sessioniface->call("set_mate_touchscrolling_mode", value); + return reply.value(); +} + +/*-----------------------------window of beauty-----------------------------*/ +void SessionDispatcher::set_window_button_align_left_qt() { + sessioniface->call("set_window_button_align_left"); +} + +void SessionDispatcher::set_window_button_align_right_qt() { + sessioniface->call("set_window_button_align_right"); +} + +QString SessionDispatcher::get_window_button_align_qt() { + QDBusReply reply = sessioniface->call("get_window_button_align"); + return reply.value(); +} + +bool SessionDispatcher::set_menus_have_icons_qt(bool flag) { + QDBusReply reply = sessioniface->call("set_menus_have_icons", flag); + return reply.value(); +} + +bool SessionDispatcher::get_menus_have_icons_qt() { + QDBusReply reply = sessioniface->call("get_menus_have_icons"); + return reply.value(); +} + +QStringList SessionDispatcher::get_titlebar_wheel_qt() { + QDBusReply reply = sessioniface->call("get_titlebar_wheel"); + return reply.value(); +} + +QString SessionDispatcher::get_current_titlebar_wheel_qt() { + QDBusReply reply = sessioniface->call("get_current_titlebar_wheel"); + return reply.value(); +} + +void SessionDispatcher::set_titlebar_wheel_qt(QString value) { + sessioniface->call("set_titlebar_wheel", value); +} + +QStringList SessionDispatcher::get_titlebar_options_qt() { + QDBusReply reply = sessioniface->call("get_titlebar_options"); + return reply.value(); +} + +QString SessionDispatcher::get_current_titlebar_double_qt() { + QDBusReply reply = sessioniface->call("get_current_titlebar_double"); + return reply.value(); +} + +void SessionDispatcher::set_titlebar_double_qt(QString value) { + sessioniface->call("set_titlebar_double", value); +} + +//QStringList SessionDispatcher::get_titlebar_middle_qt() { +// QDBusReply reply = sessioniface->call("get_titlebar_middle"); +// return reply.value(); +//} + +QString SessionDispatcher::get_current_titlebar_middle_qt() { + QDBusReply reply = sessioniface->call("get_current_titlebar_middle"); + return reply.value(); +} + +void SessionDispatcher::set_titlebar_middle_qt(QString value) { + sessioniface->call("set_titlebar_middle", value); +} + +//QStringList SessionDispatcher::get_titlebar_right_qt() { +// QDBusReply reply = sessioniface->call("get_titlebar_right"); +// return reply.value(); +//} + +QString SessionDispatcher::get_current_titlebar_right_qt() { + QDBusReply reply = sessioniface->call("get_current_titlebar_right"); + return reply.value(); +} + +void SessionDispatcher::set_titlebar_right_qt(QString value) { + sessioniface->call("set_titlebar_right", value); +} + +/*-----------------------------sound of beauty-----------------------------*/ +bool SessionDispatcher::get_sound_event_enable_qt() { + QDBusReply reply = sessioniface->call("get_sound_event_enable"); + return reply.value(); +} + +void SessionDispatcher::set_sound_event_enable_qt(bool flag) { + sessioniface->call("set_sound_event_enable", flag); +} + +bool SessionDispatcher::get_input_feedback_sounds_enable_qt() { + QDBusReply reply = sessioniface->call("get_input_feedback_sounds_enable"); + return reply.value(); +} + +void SessionDispatcher::set_input_feedback_sounds_enable_qt(bool flag) { + sessioniface->call("set_input_feedback_sounds_enable", flag); +} + +void SessionDispatcher::set_login_music_enable_qt(bool flag) { + sessioniface->call("set_login_music_enable", flag); +} + +bool SessionDispatcher::get_login_music_enable_qt() { + QDBusReply reply = sessioniface->call("get_login_music_enable"); + return reply.value(); +} + +QString SessionDispatcher::get_sound_theme_qt() { + QDBusReply reply = sessioniface->call("get_sound_theme"); + return reply.value(); +} + +void SessionDispatcher::set_sound_theme_qt(QString theme) { + sessioniface->call("set_sound_theme", theme); +} + +void SessionDispatcher::set_location_replace_pathbar_qt(bool flag) { + sessioniface->call("set_location_replace_pathbar", flag); +} + +bool SessionDispatcher::get_location_replace_pathbar_qt() { + QDBusReply reply = sessioniface->call("get_location_replace_pathbar"); + return reply.value(); +} + +void SessionDispatcher::set_auto_mount_media_qt(bool flag) { + sessioniface->call("set_auto_mount_media", flag); +} + +bool SessionDispatcher::get_auto_mount_media_qt() { + QDBusReply reply = sessioniface->call("get_auto_mount_media"); + return reply.value(); +} + +void SessionDispatcher::set_auto_open_folder_qt(bool flag) { + sessioniface->call("set_auto_open_folder", flag); +} + +bool SessionDispatcher::get_auto_open_folder_qt() { + QDBusReply reply = sessioniface->call("get_auto_open_folder"); + return reply.value(); +} + +void SessionDispatcher::set_prompt_autorun_programs_qt(bool flag) { + sessioniface->call("set_prompt_autorun_programs", flag); +} + +bool SessionDispatcher::get_prompt_autorun_programs_qt() { + QDBusReply reply = sessioniface->call("get_prompt_autorun_programs"); + return reply.value(); +} + +void SessionDispatcher::set_thumbnail_icon_size_qt(int size) { + sessioniface->call("set_thumbnail_icon_size", size); +} + +int SessionDispatcher::get_thumbnail_icon_size_qt() { + QDBusReply reply = sessioniface->call("get_thumbnail_icon_size"); + return reply.value(); +} + +void SessionDispatcher::set_thumbnail_cache_time_qt(int value) { + sessioniface->call("set_thumbnail_cache_time", value); +} + +int SessionDispatcher::get_thumbnail_cache_time_qt() { + QDBusReply reply = sessioniface->call("get_thumbnail_cache_time"); + return reply.value(); +} + +void SessionDispatcher::set_thumbnail_cache_size_qt(int size) { + sessioniface->call("set_thumbnail_cache_size", size); +} + +int SessionDispatcher::get_thumbnail_cache_size_qt() { + QDBusReply reply = sessioniface->call("get_thumbnail_cache_size"); + return reply.value(); +} + +QString SessionDispatcher::access_current_desktop_qt() { + QDBusReply reply = sessioniface->call("access_current_desktop"); + return reply.value(); +} + +QString SessionDispatcher::access_current_machine_qt() { + QDBusReply reply = sessioniface->call("access_current_machine"); + return reply.value(); +} + +//QString SessionDispatcher::judge_desktop_is_unity_qt() { +// QDBusReply reply = sessioniface->call("judge_desktop_is_unity"); +// return reply.value(); +//} + +//QString SessionDispatcher::judge_desktop_is_cinnamon_qt() { +// QDBusReply reply = sessioniface->call("judge_desktop_is_cinnamon"); +// return reply.value(); +//} +void SessionDispatcher::adjust_screen_gamma_qt(double gamma) +{ + sessioniface->call("adjust_screen_gamma", gamma); +} + +double SessionDispatcher::get_screen_gamma_qt() +{ + QDBusReply reply = sessioniface->call("get_screen_gamma"); + return reply.value(); +} + +QStringList SessionDispatcher::get_idle_delay_list_qt() +{ + QDBusReply reply = sessioniface->call("get_idle_delay_list"); + return reply.value(); +} + +QString SessionDispatcher::get_current_idle_delay_qt() +{ + QDBusReply reply = sessioniface->call("get_current_idle_delay"); + return QString::number(reply.value()); +} + +void SessionDispatcher::set_current_idle_delay_qt(int value) +{ + sessioniface->call("set_current_idle_delay", value); +} + +bool SessionDispatcher::get_lock_enabled_qt() +{ + QDBusReply reply = sessioniface->call("get_lock_enabled"); + return reply.value(); +} + +void SessionDispatcher::set_lock_enabled_qt(bool value) +{ + sessioniface->call("set_lock_enabled", value); +} + +QStringList SessionDispatcher::get_lock_delay_list_qt() +{ + QDBusReply reply = sessioniface->call("get_lock_delay_list"); + return reply.value(); +} + +QString SessionDispatcher::get_current_lock_delay_qt() +{ + QDBusReply reply = sessioniface->call("get_current_lock_delay"); + return QString::number(reply.value()); +} + +void SessionDispatcher::set_current_lock_delay_qt(int value) +{ + sessioniface->call("set_current_lock_delay", value); +} + +QStringList SessionDispatcher::get_sleep_timeout_list_qt() +{ + QDBusReply reply = sessioniface->call("get_sleep_timeout_list"); + return reply.value(); +} + +QString SessionDispatcher::get_current_critical_low_qt() +{ + QDBusReply reply = sessioniface->call("get_current_critical_low"); + return reply.value(); +} + +void SessionDispatcher::set_current_critical_low_qt(QString value) +{ + sessioniface->call("set_current_critical_low", value); +} + + +QString SessionDispatcher::get_current_lid_battery_qt() +{ + QDBusReply reply = sessioniface->call("get_current_lid_battery"); + return reply.value(); +} + +void SessionDispatcher::set_current_lid_battery_qt(QString value) +{ + sessioniface->call("set_current_lid_battery", value); +} + + +QString SessionDispatcher::get_current_lid_ac_qt() +{ + QDBusReply reply = sessioniface->call("get_current_lid_ac"); + return reply.value(); +} + +void SessionDispatcher::set_current_lid_ac_qt(QString value) +{ + sessioniface->call("set_current_lid_ac", value); +} + + +QString SessionDispatcher::get_current_sleep_timeout_display_battery_qt() +{ + QDBusReply reply = sessioniface->call("get_current_sleep_timeout_display_battery"); + return QString::number(reply.value()); +} + +void SessionDispatcher::set_current_sleep_timeout_display_battery_qt(int value) +{ + sessioniface->call("set_current_sleep_timeout_display_battery", value); +} + +QString SessionDispatcher::get_current_sleep_timeout_display_ac_qt() +{ + QDBusReply reply = sessioniface->call("get_current_sleep_timeout_display_ac"); + return QString::number(reply.value()); +} + +void SessionDispatcher::set_current_sleep_timeout_display_ac_qt(int value) +{ + sessioniface->call("set_current_sleep_timeout_display_ac", value); +} + + +QString SessionDispatcher::get_current_sleep_timeout_battery_qt() +{ + QDBusReply reply = sessioniface->call("get_current_sleep_timeout_battery"); + return QString::number(reply.value()); +} + +void SessionDispatcher::set_current_sleep_timeout_battery_qt(int value) +{ + sessioniface->call("set_current_sleep_timeout_battery", value); +} + +QString SessionDispatcher::get_current_sleep_timeout_ac_qt() +{ + QDBusReply reply = sessioniface->call("get_current_sleep_timeout_ac"); + return QString::number(reply.value()); +} + +void SessionDispatcher::set_current_sleep_timeout_ac_qt(int value) +{ + sessioniface->call("set_current_sleep_timeout_ac", value); +} + +QString SessionDispatcher::get_current_launcher_position_qt() +{ + QDBusReply reply = sessioniface->call("get_current_launcher_position"); + return reply.value(); +} + +QStringList SessionDispatcher::get_all_launcher_position_qt() +{ + QDBusReply reply = sessioniface->call("get_all_launcher_position"); + return reply.value(); +} + +bool SessionDispatcher::set_launcher_position_qt(QString position) +{ + QDBusReply reply = sessioniface->call("set_launcher_position", position); + return reply.value(); +} + +// notify changes +void SessionDispatcher::handler_notify_boolean(QString key, bool value) +{ +// if (key == "home-icon-visible") +// { +// qDebug() << "home-icon-visible->" << value; +// } +// qDebug() << key; +// qDebug() << value; + emit bool_value_notify(key, value); +} + +void SessionDispatcher::handler_notify_int(QString key, int value) +{ + emit int_value_notify(key, value); +} + +void SessionDispatcher::handler_notify_double(QString key, double value) +{ + emit double_value_notify(key, value); +} + +void SessionDispatcher::handler_notify_string(QString key, QString value) +{ +// if (key == "gtk-theme") +// { +// } + emit string_value_notify(key, value); +} + diff --git a/dbusproxy/youkersessiondbus.h b/dbusproxy/youkersessiondbus.h new file mode 100644 index 0000000..32434dd --- /dev/null +++ b/dbusproxy/youkersessiondbus.h @@ -0,0 +1,360 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SESSIONDISPATCHER_H +#define SESSIONDISPATCHER_H + +#include +#include +#include +#include +#include "kthread.h" + +class SessionDispatcher : public QObject +{ + Q_OBJECT +public: + explicit SessionDispatcher(QObject *parent = 0); + ~SessionDispatcher(); + void getAutoStartAppStatus(); + bool getSingleAutoStartStatus(QString abs_path); + void changeAutoStartAppStatus(QString appName); + QStringList checkNewVersion(); + void runApp(QString pkgname); + void scanSystemCleanerItems(QMap data); + void check_user_qt(); + //打开文件夹 + void open_folder_qt(QString path); +// bool judge_camera_qt(); +// void call_camera_qt(); + QMap batteryInfo; + bool judge_power_is_exists_qt(); + QMap read_battery_info_qt(); + + QString get_os_release_qt(); + + //弹出登录框 + void popup_login_dialog(); + void popup_register_dialog(); + //退出登录 + void logout_ubuntukylin_account(); + + //得到SessionDbus的验证值,可以通过其判断该服务是否正在运行 +// QString get_session_daemon_qt(); + + //退出sessiondubs服务 + void exit_qt(); + //得到安装操作系统的语言版本 +// QString get_locale_version(); +// //得到当前登录用户的主目录 + QString getHomePath(); + + //----get system message + //存放当前系统和桌面信息 + QMap systemInfo; + //得到当前系统和桌面信息 + QMap get_system_message_qt(); + +// void set_default_launcher_have_showdesktopicon_qt(); + +// /*-------------------desktop of beauty-------------------*/ + bool set_show_desktop_icons_qt(bool flag); + bool get_show_desktop_icons_qt(); + bool set_show_computer_qt(bool flag); + bool get_show_computer_qt(); + bool set_show_homefolder_qt(bool flag); + bool get_show_homefolder_qt(); + bool set_show_network_qt(bool flag); + bool get_show_network_qt(); + bool set_show_trash_qt(bool flag); + bool get_show_trash_qt(); + bool set_show_devices_qt(bool flag); + bool get_show_devices_qt(); + + bool start_check_source_useable_qt(); +// Q_INVOKABLE bool get_show_cinnamon_desktop_icons_qt(); +// Q_INVOKABLE bool set_show_cinnamon_desktop_icons_qt(bool flag); +// Q_INVOKABLE bool get_show_cinnamon_computer_qt(); +// Q_INVOKABLE bool set_show_cinnamon_computer_qt(bool flag); +// Q_INVOKABLE bool get_show_cinnamon_homefolder_qt(); +// Q_INVOKABLE bool set_show_cinnamon_homefolder_qt(bool flag); +// Q_INVOKABLE bool get_show_cinnamon_network_qt(); +// Q_INVOKABLE bool set_show_cinnamon_network_qt(bool flag); +// Q_INVOKABLE bool get_show_cinnamon_trash_qt(); +// Q_INVOKABLE bool set_show_cinnamon_trash_qt(bool flag); +// Q_INVOKABLE bool get_show_cinnamon_devices_qt(); +// Q_INVOKABLE bool set_show_cinnamon_devices_qt(bool flag); + + /*-------------------unity of beauty-------------------*/ + bool set_launcher_autohide_qt(bool flag); + bool get_launcher_autohide_qt(); + bool set_launcher_icon_size_qt(int num); + int get_launcher_icon_size_qt(); + bool set_launcher_have_showdesktopicon_qt(bool flag); + bool get_launcher_have_showdesktopicon_qt(); + //-----------------mate of beauty--------------------*/ + bool set_mate_panel_autohide_qt(QString positon, bool flag); + bool get_mate_panel_autohide_qt(QString positon); + bool set_mate_panel_icon_size_qt(QString positon, int num); + int get_mate_panel_icon_size_qt(QString positon); + + //透明度 + double get_launcher_transparency_qt(); + bool set_launcher_transparency_qt(double opacity); + //图标背景 + QStringList get_all_launcher_icon_colourings_qt(); + int get_launcher_icon_colouring_qt(); + bool set_launcher_icon_colouring_qt(int colouring); + //Launcher position + QString get_current_launcher_position_qt(); + QStringList get_all_launcher_position_qt(); + bool set_launcher_position_qt(QString position); + //Dash背景模糊类型 + int get_dash_blur_experimental_qt(); + bool set_dash_blur_experimental_qt(int blur); + //面板菜单透明度 + double get_panel_transparency_qt(); + bool set_panel_transparency_qt(double opacity); + //日期时间格式 + QStringList get_all_time_format_qt(); + QString get_time_format_qt(); + bool set_time_format_qt(QString format); + bool get_show_seconds_qt(); + bool set_show_seconds_qt(bool flag); + bool get_show_week_qt(); + bool set_show_week_qt(bool flag); + bool get_show_date_qt(); + bool set_show_date_qt(bool flag); + //电源 + QStringList get_all_power_icon_policy_qt(); + QString get_power_icon_policy_qt(); + bool set_power_icon_policy_qt(QString flag); + bool get_show_power_time_qt(); + bool set_show_power_time_qt(bool flag); + bool get_show_power_percentage_qt(); + bool set_show_power_percentage_qt(bool flag); + + + bool get_show_apps_qt(); + bool set_show_apps_qt(bool flag); + bool get_show_desktop_qt(); + bool set_show_desktop_qt(bool flag); + bool get_show_icon_qt(); + bool set_show_icon_qt(bool flag); + bool get_show_places_qt(); + bool set_show_places_qt(bool flag); + + /*-------------------theme of beauty-------------------*/ + QStringList get_themes_qt(); + QString get_theme_qt(); + void set_theme_qt(QString theme); + QStringList get_icon_themes_qt(); + QString get_icon_theme_qt(); + void set_icon_theme_qt(QString theme); + QStringList get_cursor_themes_qt(); + QString get_cursor_theme_qt(); + void set_cursor_theme_qt(QString theme); + int get_cursor_size_qt(); + void set_cursor_size_qt(int size); + //window theme +// QStringList get_window_themes_qt(); +// QString get_current_window_theme_qt(); +// void set_window_theme_qt(QString theme); + +// /*-------------------fonts of beauty-------------------*/ + QString get_default_font_string_qt(QString schema, QString key); + bool set_default_font_string_qt(QString schema, QString key, QString type); + + QString get_font_qt(); +// Q_INVOKABLE bool set_font_qt_default(QString font); + bool set_font_qt(QString font); + QString get_desktop_font_qt(); + bool set_desktop_font_qt_default();//when is null ,we set a default value + bool set_desktop_font_qt(QString font); + QString get_document_font_qt(); +// Q_INVOKABLE bool set_document_font_qt_default(QString font); + bool set_document_font_qt(QString font); + QString get_monospace_font_qt(); +// Q_INVOKABLE bool set_monospace_font_qt_default(QString font); + bool set_monospace_font_qt(QString font); + QString get_window_title_font_qt(); +// Q_INVOKABLE bool set_window_title_font_qt_default(QString font); + bool set_window_title_font_qt(QString font); + double get_font_zoom_qt(); + bool set_font_zoom_qt(double zoom); + + QStringList get_smooth_style_list_qt(); + QString get_smooth_style_qt(); + bool set_smooth_style_qt(QString style); + QStringList get_antialiasing_style_list_qt(); + QString get_antialiasing_style_qt(); + bool set_antialiasing_style_qt(QString style); + + /*-------------------scrollbars of beauty-------------------*/ + bool set_scrollbars_mode_overlay_qt(); + bool set_scrollbars_mode_legacy_qt(); + QString get_scrollbars_mode_qt(); + + /*-------------------touchpad of beauty-------------------*/ + bool set_touchpad_enable_qt(bool flag); + bool get_touchpad_enable_qt(); + bool set_touchscrolling_mode_disabled_qt(); + bool set_touchscrolling_mode_edge_qt(); + bool set_touchscrolling_mode_twofinger_qt(); + QString get_touchscrolling_mode_qt(); + bool set_touchscrolling_use_horizontal_qt(bool flag); + bool get_touchscrolling_use_horizontal_qt(); + + int get_mate_touchscrolling_mode_qt(); + bool set_mate_touchscrolling_mode_qt(int value); + + /*-------------------window of beauty-------------------*/ + void set_window_button_align_left_qt(); + void set_window_button_align_right_qt(); + QString get_window_button_align_qt(); + bool set_menus_have_icons_qt(bool flag); + bool get_menus_have_icons_qt(); + QStringList get_titlebar_wheel_qt(); + QString get_current_titlebar_wheel_qt(); + void set_titlebar_wheel_qt(QString value); + QStringList get_titlebar_options_qt(); + QString get_current_titlebar_double_qt(); + void set_titlebar_double_qt(QString value); +// QStringList get_titlebar_middle_qt(); + QString get_current_titlebar_middle_qt(); + void set_titlebar_middle_qt(QString value); +// QStringList get_titlebar_right_qt(); + QString get_current_titlebar_right_qt(); + void set_titlebar_right_qt(QString value); + + /*-------------------sound of beauty-------------------*/ + void set_sound_event_enable_qt(bool flag); + bool get_sound_event_enable_qt(); + void set_input_feedback_sounds_enable_qt(bool flag); + bool get_input_feedback_sounds_enable_qt(); + void set_login_music_enable_qt(bool flag); + bool get_login_music_enable_qt(); + QString get_sound_theme_qt(); + void set_sound_theme_qt(QString theme); + + /*-------------------filemanager of beauty-------------------*/ + void set_location_replace_pathbar_qt(bool flag); + bool get_location_replace_pathbar_qt(); + void set_auto_mount_media_qt(bool flag); + bool get_auto_mount_media_qt(); + void set_auto_open_folder_qt(bool flag); + bool get_auto_open_folder_qt(); + void set_prompt_autorun_programs_qt(bool flag); + bool get_prompt_autorun_programs_qt(); + void set_thumbnail_icon_size_qt(int size); + int get_thumbnail_icon_size_qt(); + void set_thumbnail_cache_time_qt(int value); + int get_thumbnail_cache_time_qt(); + void set_thumbnail_cache_size_qt(int size); + int get_thumbnail_cache_size_qt(); + QString access_current_desktop_qt(); + QString access_current_machine_qt(); +// Q_INVOKABLE QString judge_desktop_is_unity_qt(); +// Q_INVOKABLE QString judge_desktop_is_cinnamon_qt(); + //一键清理扫描 + void onekey_scan_function_qt(QStringList selectedList); + + //-------------------conserve energe---------------- + void adjust_screen_gamma_qt(double gamma); + double get_screen_gamma_qt(); + QStringList get_idle_delay_list_qt(); + QString get_current_idle_delay_qt(); + void set_current_idle_delay_qt(int value); + bool get_lock_enabled_qt(); + void set_lock_enabled_qt(bool value); + QStringList get_lock_delay_list_qt(); + QString get_current_lock_delay_qt(); + void set_current_lock_delay_qt(int value); + + QStringList get_sleep_timeout_list_qt(); + QString get_current_critical_low_qt(); + void set_current_critical_low_qt(QString value); + QString get_current_lid_battery_qt(); + void set_current_lid_battery_qt(QString value); + QString get_current_lid_ac_qt(); + void set_current_lid_ac_qt(QString value); + QString get_current_sleep_timeout_display_battery_qt(); + void set_current_sleep_timeout_display_battery_qt(int value); + QString get_current_sleep_timeout_display_ac_qt(); + void set_current_sleep_timeout_display_ac_qt(int value); + QString get_current_sleep_timeout_battery_qt(); + void set_current_sleep_timeout_battery_qt(int value); + QString get_current_sleep_timeout_ac_qt(); + void set_current_sleep_timeout_ac_qt(int value); + + +signals: + void tellAutoModel(const QStringList &data); + void showAutoModel(); + void finishScanWork(QString msg); + void isScanning(QString msg); + void tellCleanerDetailData(const QStringList &data); + void tellCleanerDetailStatus(const QString &status); + void tellCleanerDetailError(const QString &status); + void tellScanResult(QString flag, QString msg); + void ssoSuccessSignal(QString displayName, QString emailAddress); + void ssoLoginLogoutSignal(bool loginFlag); + + void bool_value_notify(QString key, bool value); + void int_value_notify(QString key, int value); + void double_value_notify(QString key, double value); + void string_value_notify(QString key, QString value); + + void receive_source_list_signal(bool result); + +public slots: + void handlerAutoManageData(QStringList data); +// void handlerAutoManageData(const QVariantMap &data); + + void handlerAutoManageStatus(QString status); + void handlerAutoManageError(QString status); + + void handlerScanCleanerData(QStringList data); + void handlerScanCleanerStatus(QString status); + void handlerScanCleanerError(QString status); + + //扫描完成槽函数 + void handler_scan_complete(QString msg); + //扫描过程的函数 + void handler_scan_process(QString msg); + //扫描的总数 + void handler_total_data_transmit(QString flag, QString msg); + void handlerYoukerID(QString displayName, QString emailAddress); + void handlerLogoutSuccess(); + void handlerLoginFail(); + + // notify changes + void handler_notify_boolean(QString key, bool value); + void handler_notify_int(QString key, int value); + void handler_notify_double(QString key, double value); + void handler_notify_string(QString key, QString value); + +private: + QDBusInterface *sessioniface; + KThread *check_thread; + KThread *scan_thread; + KThread *onekey_scan_thread; +}; + +#endif // SESSIONDISPATCHER_H diff --git a/dbusproxy/youkersystemdbus.cpp b/dbusproxy/youkersystemdbus.cpp new file mode 100644 index 0000000..2832fd2 --- /dev/null +++ b/dbusproxy/youkersystemdbus.cpp @@ -0,0 +1,509 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "youkersystemdbus.h" +#include +#include + +SystemDispatcher::SystemDispatcher(QObject *parent) + : QObject(parent) +{ + systemiface = NULL; + thread = new KThread(this); + + //kobe + clean_thread = new KThread(this); +} + +SystemDispatcher::~SystemDispatcher() { + thread->terminate(); + thread->wait(); + if(thread != NULL) { + delete thread; + thread = NULL; + } + + clean_thread->terminate(); + clean_thread->wait(); + if(clean_thread != NULL) { + delete clean_thread; + clean_thread = NULL; + } + + + this->exit_qt(); + if (systemiface != NULL) { + delete systemiface; + systemiface = NULL; + } +} + +void SystemDispatcher::initData() +{ + systemiface = new QDBusInterface("com.ubuntukylin.youker", + "/", + "com.ubuntukylin.youker", + QDBusConnection::systemBus()); + + QObject::connect(systemiface,SIGNAL(quit_clean(bool)),this,SLOT(handler_interrupt_clean(bool))); + QObject::connect(systemiface,SIGNAL(clean_complete_onekey(QString)),this,SLOT(handler_clear_rubbish_main_onekey(QString))); + QObject::connect(systemiface,SIGNAL(clean_error_onekey(QString)),this,SLOT(handler_clear_rubbish_main_error(QString))); + QObject::connect(systemiface,SIGNAL(status_for_quick_clean(QString,QString)),this,SLOT(handler_status_for_quick_clean(QString,QString))); + + QObject::connect(systemiface,SIGNAL(subpage_data_signal(QStringList)),this,SLOT(handlerCleanerSubPageDataSignal(QStringList))); + QObject::connect(systemiface,SIGNAL(subpage_status_signal(QString, QString)),this,SLOT(handlerCleanerSubPageStatusSignal(QString, QString))); + QObject::connect(systemiface,SIGNAL(subpage_error_signal(QString)),this,SLOT(handlerCleanerSubPageErrorSignal(QString))); + + + QObject::connect(systemiface,SIGNAL(youker_fetch_signal(QString, QStringList)),this,SIGNAL(get_fetch_signal(QString, QStringList))); + QObject::connect(systemiface,SIGNAL(youker_apt_signal(QString, QStringList)),this,SIGNAL(get_apt_signal(QString, QStringList))); +// QObject::connect(systemiface,SIGNAL(youker_fetch_signal(QString, QStringList)),this,SLOT(handlerFetchSignal(QString, QStringList))); +// QObject::connect(systemiface,SIGNAL(youker_apt_signal(QString, QStringList)),this,SLOT(handlerAptSignal(QString, QStringList))); + emit this->dbusInitFinished(); +} + +//void SystemDispatcher::handlerFetchSignal(QString msg_type, QStringList msg) +//{ +// qDebug() << "fecth----->" << msg_type; +// qDebug() << msg; +//} + +//void SystemDispatcher::handlerAptSignal(QString msg_type, QStringList msg) +//{ +// qDebug() << "apt----->" << msg_type; +// qDebug() << msg; +//} + +void SystemDispatcher::adjust_cpufreq_scaling_governer_qt(QString value) +{ + systemiface->call("adjust_cpufreq_scaling_governer", value); +} + +QStringList SystemDispatcher::get_cpufreq_scaling_governer_list_qt() +{ + QDBusReply reply = systemiface->call("get_cpufreq_scaling_governer_list"); + return reply.value(); +} + +QString SystemDispatcher::get_current_cpufreq_scaling_governer_qt() +{ + QDBusReply reply = systemiface->call("get_current_cpufreq_scaling_governer"); + return reply.value(); +} + +//void SystemDispatcher::handlerCleanerSubPageDataSignal(QStringList data) +//{ +// emit this->tellCleanerMainData(data); +//} + + +bool SystemDispatcher::update_myself() +{ + QStringList tmp; + QMap data; + QEventLoop q; + KThread *apt_thread = new KThread(this); +// connect(apt_thread, SIGNAL(finished()), apt_thread, SLOT(deleteLater())); + apt_thread->initValues(data, tmp, systemiface, "install"); + apt_thread->start(); + q.exec(); + if(apt_thread->isFinished()){ + q.quit(); + } + return true; +// QDBusReply reply = systemiface->call("install", "youker-assistant"); +// return reply.value(); +} + +bool SystemDispatcher::update_source() +{ + QStringList tmp; + QMap data; + QEventLoop q; + KThread *source_thread = new KThread(this); +// connect(source_thread, SIGNAL(finished()), source_thread, SLOT(deleteLater())); + source_thread->initValues(data, tmp, systemiface, "update"); + source_thread->start(); + q.exec(); + if(source_thread->isFinished()){ + q.quit(); + } + return true; +} + +bool SystemDispatcher::copy_file_qt(QString filename) +{ + QDBusReply reply = systemiface->call("copy_file", filename); + return reply.value(); +} + +bool SystemDispatcher::delete_file_qt(QString filename) +{ + QDBusReply reply = systemiface->call("delete_file", filename); + return reply.value(); +} + +void SystemDispatcher::cleanAllSelectItems(QMap selectMap) +{ + if (clean_thread->isRunning()) { + qDebug() << "clean_thread is running......"; + } + else { +// if(clean_thread == NULL) { +// qDebug() << "clean_thread is null, ready to run......"; +// } +// else +// qDebug() << "clean_thread is not null, ready to run......"; + QStringList tmp; + QEventLoop q; + clean_thread->initValues(selectMap, tmp, systemiface, "remove_select_items"); + clean_thread->start(); + q.exec(); + if(clean_thread->isFinished()){ + q.quit(); + } + } +// QElapsedTimer et; +// et.start(); +// while(et.elapsed()<300) +// QCoreApplication::processEvents(); +} + +//void SystemDispatcher::kill_root_process_qt(QString pid) { +// systemiface->call("kill_root_process", pid); +//} + +bool SystemDispatcher::kill_uk_process_qt() { + QDBusReply reply = systemiface->call("kill_uk_process"); + return reply.value(); +} + +bool SystemDispatcher::set_cursor_theme_with_root_qt(QString theme) { + QDBusReply reply = systemiface->call("set_cursor_theme_with_root", theme); + return reply.value(); +} + +QString SystemDispatcher::get_os_name_qt() +{ + QDBusReply reply = systemiface->call("get_os_name"); + return reply.value(); +} + +QMap SystemDispatcher::get_computer_info_qt() +{ + QMap value; + QDBusReply > reply = systemiface->call("get_computer_info"); + if (reply.isValid()) { + value = reply.value(); + return value; + } + else { + qDebug() << "get computer info failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +bool SystemDispatcher::judge_sensors_exists_qt() { + QDBusReply reply = systemiface->call("judge_sensors_exists_hb"); + return reply.value(); +} + +QMap SystemDispatcher::get_sensor_info_qt() +{ + /*QMap value; + value.insert("IN0", "0.75V"); + value.insert("IN2", "1.0V"); + value.insert("IN3", "1.5V"); + value.insert("IN5", "1.8V"); + value.insert("IN6", "2.5V/2"); + value.insert("TR1", "3.3V/2"); + value.insert("TR2", "5V/3"); + value.insert("TR3", "12V/12"); + value.insert("TR4", "1.0V"); + value.insert("TR5", "45℃"); + value.insert("TR6", "50℃"); + value.insert("FANIN1", "1800"); + return value;*/ + QMap value; + QDBusReply > reply = systemiface->call("get_sensor_info"); + if (reply.isValid()) { + value = reply.value(); + return value; + } + else { +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +QMap SystemDispatcher::get_cpu_info_qt() +{ + QMap value; + QDBusReply > reply = systemiface->call("get_cpu_info"); + if (reply.isValid()) { + value = reply.value(); + return value; + } + else { + qDebug() << "get cpu info failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +QMap SystemDispatcher::get_memory_info_qt() +{ + QMap value; + QDBusReply > reply = systemiface->call("get_memory_info"); + if (reply.isValid()) { + value = reply.value(); + return value; + } + else { + qDebug() << "get memory info failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +QMap SystemDispatcher::get_board_info_qt() +{ + QMap value; + QDBusReply > reply = systemiface->call("get_board_info"); + if (reply.isValid()) { + value = reply.value(); + return value; + } + else { + qDebug() << "get board info failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +QMap SystemDispatcher::get_harddisk_info_qt() +{ + QMap value; + QDBusReply > reply = systemiface->call("get_harddisk_info"); + if (reply.isValid()) { + value = reply.value(); + return value; + } + else { + qDebug() << "get harddisk info failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +QMap SystemDispatcher::get_networkcard_info_qt() +{ + QMap value; + QDBusReply > reply = systemiface->call("get_networkcard_info"); + if (reply.isValid()) { + value = reply.value(); + return value; + } + else { + qDebug() << "get networkcard info failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +QMap SystemDispatcher::get_monitor_info_qt() +{ + QMap value; + QDBusReply > reply = systemiface->call("get_monitor_info"); + if (reply.isValid()) { + value = reply.value(); + return value; + } + else { + qDebug() << "get monitor info failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +QMap SystemDispatcher::get_cdrom_info_qt() +{ + QMap value; + QDBusReply > reply = systemiface->call("get_cdrom_info"); + if (reply.isValid()) { + value = reply.value(); + return value; + } + else { + qDebug() << "get cdrom info failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +QMap SystemDispatcher::get_audiocard_info_qt() +{ + QMap value; + QDBusReply > reply = systemiface->call("get_audiocard_info"); + if (reply.isValid()) { + value = reply.value(); + return value; + } + else { + qDebug() << "get audiocard info failed!"; +// QMap value; +// value.insert("kylinkobe", "kylinkobe"); + return value; + } +} + +QString SystemDispatcher::get_time_value_qt() { + QDBusReply reply = systemiface->call("get_time_value"); + return reply.value(); +} + +void SystemDispatcher::exit_qt() { + systemiface->call("exit"); +} + +QString SystemDispatcher::get_system_daemon_qt() { + QDBusReply reply = systemiface->call("get_system_daemon"); + return reply.value(); +} + +//void SystemDispatcher::set_homedir_qt() { +// QString homedir = QDir::homePath(); +// systemiface->call("set_homedir", homedir); +//} + +void SystemDispatcher::set_user_homedir_qt() { + QString homedir = QDir::homePath(); + systemiface->call("set_user_homedir", homedir); +} + +void SystemDispatcher::handler_interrupt_clean(bool status) { + emit policykitCleanSignal(status); +} + +void SystemDispatcher::handler_clear_rubbish_main_onekey(QString msg) { + emit finishCleanWorkMain(msg); +} + +void SystemDispatcher::handler_clear_rubbish_main_error(QString msg) { + emit finishCleanWorkMainError(msg); +} + +void SystemDispatcher::handler_status_for_quick_clean(QString type, QString status) { + emit quickCleanProcess(type, status); +} + +//-----------------------sound------------------------ +QStringList SystemDispatcher::get_sound_themes_qt() { + QDBusReply reply = systemiface->call("get_sound_themes"); + return reply.value(); +} + +void SystemDispatcher::handlerCleanerSubPageDataSignal(QStringList data) +{ + emit this->tellCleanerMainData(data); +} + +void SystemDispatcher::handlerCleanerSubPageStatusSignal(QString status, QString domain) +{ + if(status == "Complete:All" && domain == "finish") + { + emit sendCleanOverSignal(); + } + else { + emit this->tellCleanerMainStatus(status, domain); + } +} + +void SystemDispatcher::handlerCleanerSubPageErrorSignal(QString status) +{ + emit sendCleanErrorSignal(status); +} + +//QStringList SystemDispatcher::get_sounds_qt() { +// QDBusReply reply = systemiface->call("get_sounds"); +// return reply.value(); +//} + +//void SystemDispatcher::replace_sound_file_qt(QString origfile, QString targetfile) { +// systemiface->call("replace_sound_file", origfile, targetfile); +//} +//void SystemDispatcher::restore_sound_file_qt(QString targetfile) { +// systemiface->call("restore_sound_file", targetfile); +//} + +//void SystemDispatcher::restore_all_sound_file_qt(QString soundtheme) { +// systemiface->call("restore_all_sound_file", soundtheme); +//} + +//-----------------------others------------------------ +void SystemDispatcher::custom_plymouth_bg_qt(QString plymouthName) { + systemiface->call("custom_plymouth_bg", plymouthName); +} + +void SystemDispatcher::add_new_plymouth_qt(QString customBG, QString plymouthName) { + systemiface->call("add_new_plymouth", customBG, plymouthName); +} + +QStringList SystemDispatcher::get_existing_plymouth_list_qt() { + QDBusReply reply = systemiface->call("get_existing_plymouth_list"); + return reply.value(); +} + +void SystemDispatcher::plymouth_init_check_qt() { + systemiface->call("plymouth_init_check"); +} + +QString SystemDispatcher::get_image_path_qt(QString name) { + QDBusReply reply = systemiface->call("get_image_path", name); + return reply.value(); +} + +QString SystemDispatcher::delete_plymouth_qt(QString plymouthName) { + QDBusReply reply = systemiface->call("delete_plymouth", plymouthName); + return reply.value(); +} + +void SystemDispatcher::clean_by_main_one_key_qt() { + if (thread->isRunning()) { + qDebug() << "onekey_clean_thread is running......"; + } + else { +// qDebug() << "onekey_clean_thread is ready to run......"; + QStringList argList; + argList << "1" << "1" << "1"; + QMap data; + thread->initValues(data, argList, systemiface, "onekey_clean_crufts_function"); + thread->start(); + } +} diff --git a/dbusproxy/youkersystemdbus.h b/dbusproxy/youkersystemdbus.h new file mode 100644 index 0000000..c5b0ebf --- /dev/null +++ b/dbusproxy/youkersystemdbus.h @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef YOUKERSYSTEMDBUS_H +#define YOUKERSYSTEMDBUS_H + +#include +#include +#include +#include "kthread.h" + +class SystemDispatcher : public QObject +{ + Q_OBJECT +public: + explicit SystemDispatcher(QObject *parent = 0); + ~SystemDispatcher(); + //退出systemdbus服务 + void exit_qt(); + + void adjust_cpufreq_scaling_governer_qt(QString value); + QStringList get_cpufreq_scaling_governer_list_qt(); + QString get_current_cpufreq_scaling_governer_qt(); + + void cleanAllSelectItems(QMap selectMap); + bool kill_uk_process_qt(); + //杀掉root用户的进程 +// void kill_root_process_qt(QString pid); + //得到SystemDbus的验证值,可以通过其判断该服务是否正在运行 + QString get_system_daemon_qt(); + //为系统设置来设置登录系统的普通用户的用户目录 +// void set_homedir_qt(); + //为系统清理来设置登录系统的普通用户的用户目录 + void set_user_homedir_qt(); + //首页一键清理 + void clean_by_main_one_key_qt(); + bool copy_file_qt(QString filename); + bool delete_file_qt(QString filename); + bool update_myself(); + bool update_source(); + + //-----------------------sound------------------------ + QStringList get_sound_themes_qt(); +// Q_INVOKABLE QStringList get_sounds_qt(); +// Q_INVOKABLE void replace_sound_file_qt(QString origfile, QString targetfile); +// Q_INVOKABLE void restore_sound_file_qt(QString targetfile); +// Q_INVOKABLE void restore_all_sound_file_qt(QString soundtheme); + bool set_cursor_theme_with_root_qt(QString theme); + + //-----------------------others------------------------ + void custom_plymouth_bg_qt(QString plymouthName); + void add_new_plymouth_qt(QString customBG, QString plymouthName); + QStringList get_existing_plymouth_list_qt(); + void plymouth_init_check_qt(); + QString get_image_path_qt(QString name); + QString delete_plymouth_qt(QString plymouthName); + + //得到当前系统和桌面的详细信息 + QString get_os_name_qt(); + bool judge_sensors_exists_qt(); + QMap get_computer_info_qt(); + QMap get_sensor_info_qt(); + QMap get_cpu_info_qt(); + QMap get_memory_info_qt(); + QMap get_board_info_qt(); + QMap get_harddisk_info_qt(); + QMap get_networkcard_info_qt(); + QMap get_monitor_info_qt(); + QMap get_cdrom_info_qt(); + QMap get_audiocard_info_qt(); + QString get_time_value_qt(); + +signals: + void tellCleanerMainData(const QStringList &data); + void tellCleanerMainStatus(const QString &status, const QString &domain); + void sendCleanOverSignal(); + void sendCleanErrorSignal(const QString &status); + void policykitCleanSignal(bool status); + void finishCleanWorkMain(QString msg); + void finishCleanWorkMainError(QString msg); + void quickCleanProcess(QString type, QString status); + + //apt + void get_fetch_signal(QString msg_type, QStringList msg); + void get_apt_signal(QString msg_type, QStringList msg); + + void dbusInitFinished(); + +public slots: + void handler_interrupt_clean(bool status); + void handler_clear_rubbish_main_onekey(QString msg); + void handler_clear_rubbish_main_error(QString msg); + void handler_status_for_quick_clean(QString type, QString status); + void handlerCleanerSubPageDataSignal(QStringList data); + void handlerCleanerSubPageStatusSignal(QString status, QString domain); + void handlerCleanerSubPageErrorSignal(QString status); + + //apt +// void handlerFetchSignal(QString msg_type, QStringList msg); +// void handlerAptSignal(QString msg_type, QStringList msg); + + void initData(); + +private: + QDBusInterface *systemiface; + KThread *thread; + KThread *clean_thread; +}; + +#endif // YOUKERSYSTEMDBUS_H diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..ff46703 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,493 @@ +youker-assistant (2.4.2-0ubuntu4) artful; urgency=low + + [hebing] + * change judge of dynamic load sysinfo + + -- hebing Tue, 05 Dec 2017 09:21:22 +0800 + +youker-assistant (2.4.1-0ubuntu4) artful; urgency=low + + [hebing] + * rm debug info in cdrowwidget.cpp + * add info output in terminal if started repeated + + -- hebing Tue, 14 Nov 2017 11:03:25 +0800 + +youker-assistant (2.4.0-0ubuntu4) artful; urgency=low + + [hebing] + * change cpu info from 4 cores cores to 4 + * add call for changeinfopage when click memoryinfo page + * add a picture in skin + * coded bootanimation in main.cpp + + -- hebing Fri, 10 Nov 2017 17:01:56 +0800 + +youker-assistant (2.3.0-0ubuntu4) artful; urgency=low + + [hebing] + * adjust onclick method in common tool beause camera deleted + * add comment for desktop file + * add i18n for "Open File" + + -- hebing Thu, 09 Nov 2017 09:15:54 +0800 + +youker-assistant (2.2.13-0ubuntu4) artful; urgency=low + + [hebing] + * change youker-assistant to kylin-assistant in desktop file + * increase the size of common tool from 120 to 240 + + -- hebing Tue, 31 Oct 2017 10:46:31 +0800 + +youker-assistant (2.2.12-0ubuntu4) artful; urgency=low + + [hebing] + * generate kylin-assistant for 1710 + + [Mattia Rizzolo] + * Fix build with OpenCV 3.1. + + -- hebing Tue, 19 Sep 2017 14:26:17 +0800 + +youker-assistant (2.2.12-0ubuntu2) zesty; urgency=low + + [ hebing ] + * change the system infomation UI Dynamic loading + + [ lixiang ] + * Add a module to calculate capacity of memory and hd. + + -- lixiang Tue, 19 Sep 2017 14:26:17 +0800 + +youker-assistant (2.2.11-0ubuntu2) zesty; urgency=low + + [ Mathieu Trudel-Lapierre ] + * debian/control: limit dmidecode Depends to x86 and ARM. (LP: #1679788) + + -- hebing Thu, 07 Sep 2017 10:15:59 +0800 + +youker-assistant (2.2.11-0ubuntu1) zesty; urgency=low + + [ hebing ] + * change name from youker to kylin + * change the length of label on command history clean + * recode the code of add skin + * recode the function of get information of display device + * voluation "UKUI" for desktop env + * add icon for autostart manager + + [ lixiang ] + * Add threadpool. + + -- hebing Fri, 01 Sep 2017 09:04:11 +0800 + +youker-assistant (2.2.10-0ubuntu1) zesty; urgency=low + + [ hebing ] + * invisable the mainwindow's title for UKUI + * rewrite the function of get_disk and get_network + + -- hebing Fri, 23 Jun 2017 14:04:48 +0800 + +youker-assistant (2.2.9-0ubuntu1) zesty; urgency=low + + [ hebing ] + * add systemdbus method judge_sensors_exists_hb + * fix bug the text of vga_product is too long + + -- hebing Wed, 19 Apr 2017 14:41:56 +0800 + +youker-assistant (2.2.8-0ubuntu1) zesty; urgency=low + + * Access information of network cards with QThread. + * Refresh the hardware information when the page is switched. + * Free memory when hardware information page is switched. + + -- lixiang Fri, 07 Apr 2017 16:40:29 +0800 + +youker-assistant (2.2.7-0ubuntu2) zesty; urgency=low + + [ lixiang ] + * Set Cpu FM mode. + * Only support x86 and ARM. + + [ Mathieu Trudel-Lapierre ] + * debian/control: limit dmidecode Depends to x86 and ARM. (LP: #1679788) + + -- lixiang Thu, 30 Mar 2017 10:37:12 +0800 + +youker-assistant (2.2.7-0ubuntu1) zesty; urgency=low + + * Call cheese. + * Free some list struct. + * Modify os release information. + * Resolved lintian warning. + + -- lixiang Thu, 23 Mar 2017 10:17:31 +0800 + +youker-assistant (2.2.6-0ubuntu1) zesty; urgency=low + + * Set launcher position. + * Multi screen display normal. + * Display virtual network card info. + * Display right network info. + + -- lixiang Mon, 20 Mar 2017 11:32:41 +0800 + +youker-assistant (2.2.4-0ubuntu1) zesty; urgency=low + + * Fixed the ℃ display. + * Fixed some bug about information. + + -- lixiang Fri, 17 Mar 2017 15:09:41 +0800 + +youker-assistant (2.1.9-0ubuntu1) xenial; urgency=low + + * change get_sensor because the kernel update + + -- hebing Tue, 14 Feb 2017 14:30:58 +0800 + +youker-assistant (2.1.8-0ubuntu1) xenial; urgency=low + + * integrate sensors's ui and backend. + * Support multiple network card display. + + -- hebing Wed, 08 Feb 2017 13:49:27 +0800 + +youker-assistant (2.1.5-0ubuntu1) xenial; urgency=low + + * Hardware sensor information for arm64. + * change disk capacity from 1024 to 1000. + + -- lixiang Sun, 22 Jan 2017 23:49:39 +0800 + +youker-assistant (2.1.4-0ubuntu1) xenial; urgency=low + + * Translation for arm64. + * Repair the bug about graphics. + + -- lixiang Wed, 18 Jan 2017 15:35:07 +0800 + +youker-assistant (2.1.2-0ubuntu1) xenial; urgency=low + + * Fixed ip address, memory info and hdinfo. + * Adjust the close button position accord to desktop environment. + + -- Kobe Lee (kylinkobe) Wed, 28 Dec 2016 12:03:36 +0800 + +youker-assistant (2.0.9-0ubuntu1) xenial; urgency=low + + * Add depends. + * Modify cpuinfo.py. + + -- Kobe Lee (kylinkobe) Wed, 12 Oct 2016 23:12:34 +0800 + +youker-assistant (2.0.8-0ubuntu1) xenial; urgency=low + + * Deal with org.gnome.settings-daemon.peripherals.touchpad. + * Replace psutil.get_process_list with psutil.process_iter. + * Optimized scan display interface. + * Remove processmanager. + * Modified control file for python 2.7. + * Add depends for python 2.7. + + -- Kobe Lee (kylinkobe) Wed, 27 Apr 2016 09:49:25 +0800 + +youker-assistant (2.0.5) wily; urgency=low + + * Distinguish system structure. + * Modify translations(LP: #1480175). + * Wily replaces org.gnome.settings-daemon.peripherals.touchpad with org.gnome.desktop.peripherals.touchpad. + * Fixed session dbus daemon(LP: #1475090). + * Set fixed size for main window. + * Make scan result showed more uniform. + + -- Kobe Lee (kylinkobe) Fri, 04 Dec 2015 15:59:29 +0800 + +youker-assistant (2.0.3) wily; urgency=low + + * Access FT Arm settings and information. + * Deal with situation when the scanning garbage is empty. + * Display hardware manufacturer logo. + * Add Gio.Settings notify for Unity and Mate settings. + * Make interface switching more smoothly. + * Adjust the layout of interface. + * Beautify skin center, menu, info module and setting module. + * Rewrite skin center, aboutdialog and animation. + * Add upgrade function. + * Delete debug logs and command history. + * Rewrite camera module and replace pygame with opencv. + * Make dash blur experimental normal(LP: #1430118). + * Modify custom skin filter(LP: #1475074). + * Modify cleanerdetailwidget. + + -- Kobe Lee (kylinkobe) Thu, 16 Jul 2015 13:34:35 +0800 + +youker-assistant (2.0.2) vivid; urgency=low + + * Add mate-desktop-environment settings. + * Deal with system information for mate. + * Add restore button for font. + * Modify system info display model. + * Add energy conserving model. + * Fixed battery information(LP: #1430128). + + -- Kobe Lee (kylinkobe) Wed, 15 Apr 2015 13:11:15 +0800 + +youker-assistant (2.0.1) vivid; urgency=low + + * Achieve low CPU occupancy rate. + * Improve UI. + * Fixed some bug. + * Deal with system information access exception. + * Deal with autostart Apps. + + -- Kobe Lee (kylinkobe) Mon, 23 Mar 2015 21:36:55 +0800 + +youker-assistant (2.0.0) vivid; urgency=low + + * New UI. + * Fixed FileDialog and LoginDialog. + + -- Kobe Lee (kylinkobe) Fri, 20 Feb 2015 22:16:28 +0800 + +youker-assistant (1.3.3-0ubuntu1) vivid; urgency=low + + * Modify control and desktop file. + * Display animation when cleaning up garbage. + * Solve some problems about sso when network abnormal. + * Add 3 OS rankings. + + -- Kobe Lee (kylinkobe) Sun, 04 Jan 2015 17:03:17 +0800 + +youker-assistant (1.3.2-0ubuntu1) vivid; urgency=low + + * Make it work normally when fisrt start(LP: #1373294). + * Make icons on panel normally(LP: #1380938). + * Make main page normally when double clicked the link Btn and the back Btn(LP: #1387927). + * Shred big file normally(LP: #1373302). + + -- Kobe Lee (kylinkobe) Tue, 30 Dec 2014 10:21:27 +0800 + +youker-assistant (1.3.1-0ubuntu1) utopic; urgency=low + + * Add cinnamon desktop settings. + * Add Ubuntu Kylin SSO. + * Connect Server with thread. + * Make File Shredder work properly(LP: #1381382). + + -- Kobe Lee (kylinkobe) Fri, 17 Oct 2014 10:42:04 +0800 + +youker-assistant (1.3.0-0ubuntu1) utopic; urgency=low + + * Support multiple languages. + * Remove copyrighted images and download images from http server. + * Add file shreder. + + -- Kobe Lee (kylinkobe) Mon, 22 Sep 2014 11:07:11 +0800 + + +youker-assistant (1.2.0-0ubuntu1) utopic; urgency=low + + * Add IP Address and pid file. + * Adjust the widget of system settings and change the background color. + * Display the slidershow according to different users. + * Modify debian/postinst and debian/postrm. + * Display the current font style when clicked the change button. + * Add pingback function. + * Modify Driver info page(LP: #1267374) and FileManager Page(LP: #1358999). + * Add judgment of the Desktop and DistroWatch ranking. + * Make launcher transparency setting do work(LP: #1358672). + * Find large files with thread(LP: #1358992). + + -- Kobe Lee (kylinkobe) Thu, 28 Aug 2014 12:28:56 +0800 + +youker-assistant (1.1.0-0ubuntu1) trusty; urgency=low + + * Perfect for parameter when checkbox checked. + * Get the correct version information of OS. + * Do system scan with thread. + * Use Python Socket and UUID to get LAN port, IP address and MAC address(LP: #1310882). + * Add slider show and battery information. + * Solved the interface flicker problem when it move(LP: #1304980). + * Add some settings about Dash, Panel and Launcher. + * Use camera to take pictures. + * Modify moving zone of the main widget, file cleaner, cpu ratio and the monitor ball. + * Modify weather model. + + -- Kobe Lee (kylinkobe) Mon, 07 Jul 2014 22:43:31 +0800 + +youker-assistant (1.0.1-0ubuntu1) trusty; urgency=low + + * Modify display mode of weather forecast and system settings. + * Add file manager and font style settings. + * Improve system settings and restoring default settings. + * Cache user account (not password). + * Change the position of window control buttons. + * Add configuration for Kysoft KuaiPan cloud client. + * Add the instruction of Youker Assistant. + * Open related folders when scanning items got double-clicked. + * Notify users when operating the Kingsoft disk cloud configuration. + * Modify Dbus starting method. + + -- Kobe Lee (kylinkobe) Thu, 20 Mar 2014 10:14:56 +0800 + +youker-assistant (1.0.0-0ubuntu1) trusty; urgency=low + + * Access Yahoo weather info. + * Add Class LoginDialog and HttpAuth to login with Ubuntu Kylin forum account. + * Cleanup browser cache, thumbnail cache and software configfile. + * Completed global mouse theme. + * Modify the icon on PolicyKit Dialog. + * Adjust the display format of network traffic on the monitor ball. + * Add ToolTip.qml. + * Achieve the function about login with forum account. + * Add FileManager.qml, filemanager.py, common.py, geditmanager.py and settings.py. + * Reset default config value with Gio Settings and compizconfig. + * Remove software recommand. + + -- Kobe Lee (kylinkobe) Fri, 21 Feb 2014 16:36:44 +0800 + +youker-assistant (0.3.2-0ubuntu1) trusty; urgency=low + + * Refersh process list automatically and position the originally selected process(LP: #1261802). + * Adjust the structure of QML project. + * Add CD-ROM, Audio Card and WLan information. + * Kill root process. + * Add Device driver basic information. + * Use new translation content. + * Display the preview picture when click the name on the BootAnimation page. + * Rename dbus and add backends/youker-assistant-daemon/install.sh. + * Use policykit for all place that requires authentication(LP: #1261799). + * Add GnuPG keys of the UbuntuKylin archive: ubuntukylin-archive-keyring.gpg. + * Replace some icons. + + -- Kobe Lee (kylinkobe) Fri, 10 Jan 2014 12:30:30 +0800 + +youker-assistant (0.3.1-0ubuntu1) trusty; urgency=low + + * Overide the Font Dialog with KFontDialog Class. + * Add detailed information of Network Card, HardDisk and Graphics Card. + * Add Separator.qml. + * Change Logo and add InfoGroup.js. + * Access weather data with python threading. + * Change /usr/share/youker-assistant-daemon to /var/lib/youker-assistant-daemon. + * Change UbuntuKylin to Ubuntu Kylin. + * Modify calculation method of system memory allocation(LP: #1242579). + * Refresh net speed every second to resolve the wrong displaying net flow(LP: #1237891). + * Modify LargestFile.qml and One Key cleaner. + + -- Kobe Lee (kylinkobe) Tue, 17 Dec 2013 15:12:07 +0800 + +youker-assistant (0.2.4-0ubuntu1) saucy; urgency=low + + * Optimize button events of AuthDialog(LP: #1256183). + * Fixed Dialog's movement and hazing when click a button(LP: #1255550). + * Change some pictures of computer's detailed information. + * All system configuration saved with QSetting. + + -- Kobe Lee (kylinkobe) Thu, 05 Dec 2013 14:26:53 +0800 + +youker-assistant (0.2.3-0ubuntu1) saucy; urgency=low + + * Add processmanager. + * Add Google Chromium Cookies cleaner. + * Change Chinese to English add add translation. + * Adjust components space after it added translation. + * Solve the segmentation fault when users cancel the previous Fcitx configuration(LP: #1252595). + * Save and restore the default system configuration with QSetting. + * Clear Cookies of Chromium(LP: #1224871). + * Solve wrong status of history cleaning(LP: #1253852). + * Popup a dialog to add Ubuntu Kylin sourcelist or not. + * Display detailed information of Computer. + * Display contents when one key scanning. + * Add debian/postrm file to remove a folder when it is uninstalled. + + -- Kobe Lee (kylinkobe) Thu, 28 Nov 2013 21:01:35 +0800 + +youker-assistant (0.2.2-0ubuntu1) saucy; urgency=low + + * Change skin and add weather forecast information. + * Get correct system information(LP: #1240862). + * Get software list and software information dynamically. + * Start sudodbus server at the same time to scan package cruft(LP: #1242498). + * Change the progressbar from Qt to QML. + * Use qtsingleapplication by F.J Kong (kroodylove). + * Solve the SIGSEGV crash when the program exit(LP: #1235073). + * Add Splash screen. + + -- Kobe Lee (kylinkobe) Fri, 01 Nov 2013 10:24:05 +0800 + +youker-assistant (0.2.1-0ubuntu1) saucy; urgency=low + + * Modify the mouse events of MonitorBall. + * Add reset button for clear pages. + * Add policykit for apt clear in sudodbus. + * Fixed the bug about software status and add masklayer. + * Rewrite the code of system information. + * Add some signals and slots. + * Fixed the bug about Software signals(LP: #1226389). + * Modify KThread and add base.py. + * Fixed the bug about the black widget when operate software(LP: #1231408). + + -- Kobe Lee (kylinkobe) Thu, 26 Sep 2013 20:08:11 +0800 + +youker-assistant (0.2.0-0ubuntu1) saucy; urgency=low + + * Modify the MonitorBall from QML to QT. + * Add recommendation about top software. + * Add a module and clean trace about file opened. + * Add progressbar to display operation status and progress. + * Make it can only start a single program. + * Modify all status of clean module. + + -- Kobe Lee (kylinkobe) Fri, 13 Sep 2013 16:57:13 +0800 + +youker-assistant (0.1.6-0ubuntu1) saucy; urgency=low + + * Modify Class SystemDispatcher and SessionDispatcher. + * Add watch file into debian folder. + * Resolve status of onekey button(LP: #1216236 ). + * Add monitorball code into systemdbus daemon. + * Optimize the status button. + + -- Kobe Lee (kylinkobe) Mon, 02 Sep 2013 17:17:45 +0800 + +youker-assistant (0.1.5-0ubuntu1) saucy; urgency=low + + * 0.1-Release. + * Add policykit. + * Make bootimage success. + + -- Kobe Lee (kylinkobe) Thu, 22 Aug 2013 11:25:15 +0800 + +youker-assistant (0.1.4-0ubuntu1) raring; urgency=low + + * Remove libstyleplugin.so and add our components. + * Merge youker-assistant and youker-assistant-daemon into one project. + * Finish the method of get password. + * Modify the start method of systemdbus. + * Add Timer to prompt information. + + -- Kobe Lee (kylinkobe) Fri, 09 Aug 2013 16:41:16 +0800 + +youker-assistant (0.1.3-0ubuntu1) raring; urgency=low + + * Finish the basic beauty of Clear pages and Set pages. + + -- Kobe Lee (kylinkobe) Thu, 01 Aug 2013 18:33:08 +0800 + +youker-assistant (0.1.2-0ubuntu1) raring; urgency=low + + * Modify some systemset pages. + * systemdbus and sessiondbus start when the program run. + * Modify Rubbish Clear functions. + + -- Kobe Lee (kylinkobe) Fri, 26 Jul 2013 18:23:15 +0800 + +youker-assistant (0.1.1-0ubuntu1) raring; urgency=low + + * Initial release. + + -- Kobe Lee (kylinkobe) Tue, 02 Jul 2013 08:57:14 +0800 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..544c33f --- /dev/null +++ b/debian/control @@ -0,0 +1,50 @@ +Source: youker-assistant +Section: misc +Priority: optional +Maintainer: Ubuntu Kylin Team +Build-Depends: debhelper (>= 9), + python-dev, + python-lxml, + python-piston-mini-client, + python-xdg, + libqt4-dev, + pkg-config, + python (>= 2.6.6-3~), + libglib2.0-dev, + libgtop2-dev +Standards-Version: 3.9.8 +Homepage: https://launchpad.net/youker-assistant +Vcs-Browser: https://code.launchpad.net/~ubuntukylin-members/youker-assistant/trunk +Vcs-Bzr: lp:youker-assistant + +Package: youker-assistant +Architecture: amd64 arm64 armhf i386 +Depends: python-dbus, + python-psutil, + python-lxml, + python-xdg, + python-apt, + python-pil, + python-imaging, + python-piston-mini-client, + python-compizconfig, + hdparm, + lm-sensors, + ethtool, + lshw, + dmidecode [amd64 arm64 armhf i386], + cpufrequtils, + pciutils, + ${misc:Depends}, + ${python:Depends}, + ${shlibs:Depends}, +Description: Integrated tool to aid in routine system maintenance tasks + Youker Assistant is a tool designed to help Ubuntu and Ubuntu Kylin + desktop users manage and maintain many aspects of their working + environment conveniently in a single application, providing a consistent + user experience. + . + Features currently included: + * Detecting and displaying general system information + * Unity and Mate user interface customization + * System garbage cleaning diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..ffae215 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,77 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: youker-assistant +Upstream-Contact: Ubuntu Kylin Team +Source: https://launchpad.net/youker-assistant + +Files: * +Copyright: 2013-2014, National University of Defense Technology(NUDT) & Kylin Ltd. +License: GPL-3 + +Files: backends/youker-assistant-daemon/src/policykit/* +Copyright: Copyright (C) 2007-2011 Tualatrix Chou + Copyright (C) 2013-2014 National University of Defense Technology(NUDT) & Kylin Ltd. +License: GPL-3 + +Files: backends/youker-assistant-daemon/src/systemdbus/server.py +Copyright: Copyright (C) 2008 Fluendo Embedded S.L. + Copyright (C) 2010 TualatriX + Copyright (C) 2013-2014 National University of Defense Technology(NUDT) & Kylin Ltd. +License: GPL-2+ + +Files: backends/youker-assistant-daemon/src/beautify/common.py backends/youker-assistant-daemon/src/beautify/compizsettings.py +Copyright: Copyright (C) 2007-2011 Tualatrix Chou +License: GPL-2+ + +Files: backends/youker-assistant-daemon/src/beautify/ccm/* +Copyright: Copyright (C) 2007 Quinn Storm +License: GPL-2+ + +Files: qtsingleapplication/* +Copyright: 2013 Digia Plc and/or its subsidiary(-ies) +License: BSD-3-clause + +License: GPL-2+ + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + . + On Debian and Ubuntu systems, a copy of the GNU General Public License version + 2 may be found in the file /usr/share/common-licenses/GPL-2. + +License: GPL-3 + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License version 3 as + published by the Free Software Foundation. + . + 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. + . + On Debian/Ubuntu systems, the full text of the GPL v3 can be found in + `/usr/share/common-licenses/GPL-3' + +License: BSD-3-clause + 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 the organization 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 HOLDER 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. diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..c0120f7 --- /dev/null +++ b/debian/install @@ -0,0 +1,4 @@ +backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.service /usr/share/dbus-1/system-services/ +backends/youker-assistant-daemon/dbus/com.ubuntukylin.session.service /usr/share/dbus-1/services/ +backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.policy /usr/share/polkit-1/actions/ +backends/youker-assistant-daemon/dbus/com.ubuntukylin.youker.conf /etc/dbus-1/system.d/ diff --git a/debian/links b/debian/links new file mode 100644 index 0000000..690f23d --- /dev/null +++ b/debian/links @@ -0,0 +1,2 @@ +/usr/lib/python2.7/dist-packages/youker-assistant-daemon/src/start_systemdbus.py /usr/bin/youker-assistant-backend.py +/usr/lib/python2.7/dist-packages/youker-assistant-daemon/src/start_sessiondbus.py /usr/bin/youker-assistant-session.py diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..75db016 --- /dev/null +++ b/debian/rules @@ -0,0 +1,13 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +override_dh_auto_configure: + QT_SELECT=qt4 dh_auto_configure \ + -- "QMAKE_CXXFLAGS=$(CFLAGS)" \ + youker-assistant.pro + +%: + dh $@ --with python2 --fail-missing --parallel diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..daaa3a1 --- /dev/null +++ b/debian/watch @@ -0,0 +1,2 @@ +version=3 +https://launchpad.net/youker-assistant/+download https://launchpad.net/youker-assistant/.*/youker-assistant-(.*)\.tar\.gz diff --git a/debian/youker-assistant.manpages b/debian/youker-assistant.manpages new file mode 100644 index 0000000..b85872f --- /dev/null +++ b/debian/youker-assistant.manpages @@ -0,0 +1,3 @@ +man/youker-assistant.1 +man/youkersession.1 +man/youkersystem.1 diff --git a/info/audiowidget.cpp b/info/audiowidget.cpp new file mode 100644 index 0000000..010f89a --- /dev/null +++ b/info/audiowidget.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "audiowidget.h" +#include "computerpage.h" + +AudioWidget::AudioWidget(QWidget *parent, SystemDispatcher *proxy) : + QWidget(parent), + systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403/* - 10*/); + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403/* - 10*/); + dataOK = false; +} + +AudioWidget::~AudioWidget() +{ + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void AudioWidget::clear_page_list() +{ + for(int i=0; iresetWidget(); +} + +bool AudioWidget::getStatus() +{ + return this->dataOK; +} + +bool AudioWidget::displaySwitch() +{ + audio_info_map.clear(); + audio_info_map = systemproxy->get_audiocard_info_qt(); + if (audio_info_map.empty() || audio_info_map.count() <= 0) + { + return false; + } + else + { + return true; + } +} + +void AudioWidget::initData() +{ + this->clear_page_list(); +// audio_info_map.clear(); + audio_info_map = systemproxy->get_audiocard_info_qt();//?硬盘,显卡,声卡,内存界面需要重新调用?为何其他界面不需要重新调用 + + QMap::iterator iter = audio_info_map.find("MulNum"); + qDebug() << iter.value().toInt(); + int mulNum = 0; + if (iter == audio_info_map.end()) + { + mulNum = 0; + } + + else + { + mulNum = iter.value().toInt(); + } + if(mulNum == 0) + { + } + else + { + if(mulNum == 1) + { + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Audio Info")); + page_list.append(page); + audio_info_map.remove("MulNum"); + QMap tmpMap; + QMap::iterator it; + for ( it = audio_info_map.begin(); it != audio_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(tmpMap, audio_info_map.value("MulVendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + else if(mulNum > 1) + { + for(int i=0;izone, tr("Audio Info %1").arg(i+1)); + page_list.append(page); + tmp_info_map.clear(); + QMap::iterator itbegin = audio_info_map.begin(); + QMap::iterator itend = audio_info_map.end(); + for (;itbegin != itend; ++itbegin) + { + if(itbegin.key() != "MulNum" && itbegin.value().toString().contains("<1_1>")) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + tmp_info_map.insert(itbegin.key(), result); + } + } + } + page->setMap(tmp_info_map, tmp_info_map.value("MulVendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + } + } + +/*QMap::iterator iter = audio_info_map.find("MulNum"); +int mulNum = 0; +if (iter == audio_info_map.end()) +{ + mulNum = 0; +} +else{ + mulNum = iter.value().toInt(); +} +if(audio_info_map.count() == 1 && audio_info_map.contains("kylinkobe")) +{ +} +else { + if(mulNum == 1) + { + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Audio Info")); + audio_info_map.remove("MulNum"); + QMap tmpMap; + QMap::iterator it; + for ( it = audio_info_map.begin(); it != audio_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(tmpMap, audio_info_map.value("MulVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + else if(mulNum > 1) + { + for(int i=0;izone, tr("Audio Info %1").arg(i+1)); + tmp_info_map.clear(); + QMap::iterator itbegin = audio_info_map.begin(); + QMap::iterator itend = audio_info_map.end(); + for (;itbegin != itend; ++itbegin) + { + if(itbegin.key() != "MulNum" && itbegin.value().toString().contains("<1_1>")) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + tmp_info_map.insert(itbegin.key(), result); + } + } + } + page->setMap(tmp_info_map, tmp_info_map.value("MulVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + } +}*/ +// dataOK = true; +} diff --git a/info/audiowidget.h b/info/audiowidget.h new file mode 100644 index 0000000..ae3d6d8 --- /dev/null +++ b/info/audiowidget.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AUDIOWIDGET_H +#define AUDIOWIDGET_H + +#include +#include +#include +#include "../component/scrollwidget.h" + +class SystemDispatcher; + +class AudioWidget : public QWidget +{ + Q_OBJECT +public: + explicit AudioWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0); + ~AudioWidget(); + void initData(); + bool getStatus(); + void clear_page_list(); + bool displaySwitch(); + +signals: + +public slots: + +private: + ScrollWidget *scroll_widget; + QMap audio_info_map; + QMap tmp_info_map; + SystemDispatcher *systemproxy; + bool dataOK; + QList page_list; +}; + +#endif // AUDIOWIDGET_H diff --git a/info/batterywidget.cpp b/info/batterywidget.cpp new file mode 100644 index 0000000..b360921 --- /dev/null +++ b/info/batterywidget.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "batterywidget.h" + +BatteryWidget::BatteryWidget(QWidget *parent, SessionDispatcher *proxy) : + QWidget(parent), + sessionproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + page = NULL; + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); + dataOK = false; +} + +BatteryWidget::~BatteryWidget() +{ + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void BatteryWidget::clear_page_list() +{ + if (page != NULL) { + delete page; + page = NULL; + } + if (scroll_widget) + scroll_widget->resetWidget(); +} + +bool BatteryWidget::getStatus() +{ + return this->dataOK; +} + +void BatteryWidget::initData() +{ + this->clear_page_list(); + QMap tmpMap = sessionproxy->read_battery_info_qt(); + if (tmpMap.isEmpty() || tmpMap.count() <= 0) { + page = NULL; + } + else { + QMap::iterator it; //遍历map + QStringList powerlist; + powerlist << "POWER_SUPPLY_NAME" << "POWER_SUPPLY_MANUFACTURER" << "POWER_SUPPLY_MODEL_NAME" << "POWER_SUPPLY_TECHNOLOGY" << "POWER_SUPPLY_VOLTAGE_NOW" << "POWER_SUPPLY_ENERGY_FULL_DESIGN" << "POWER_SUPPLY_ENERGY_FULL" << "POWER_SUPPLY_ENERGY_NOW" << "POWER_SUPPLY_SERIAL_NUMBER"; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { + QList::Iterator itstart = powerlist.begin(), itend = powerlist.end(); + for(;itstart !=itend;itstart++) + { + if(*itstart == it.key()) + { + if (it.key() == "POWER_SUPPLY_SERIAL_NUMBER") + { + if (it.value().toString().replace(" " ,"").length() > 0) + battery_info_map.insert(it.key(), it.value()); + } + else { + if (it.value().toString().length() > 0) + battery_info_map.insert(it.key(), it.value()); + } + break; + } + } + } + if(battery_info_map.isEmpty() || battery_info_map.count() <= 0) { + page = NULL; + } + else { + page = new ComputerPage(scroll_widget->zone, tr("Battery Info")); + page->setMap(battery_info_map, battery_info_map.value("POWER_SUPPLY_MANUFACTURER").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + } + /*QMap::iterator it; //遍历map + QStringList powerlist; + powerlist << "POWER_SUPPLY_NAME" << "POWER_SUPPLY_MANUFACTURER" << "POWER_SUPPLY_MODEL_NAME" << "POWER_SUPPLY_TECHNOLOGY" << "POWER_SUPPLY_VOLTAGE_NOW" << "POWER_SUPPLY_ENERGY_FULL_DESIGN" << "POWER_SUPPLY_ENERGY_FULL" << "POWER_SUPPLY_ENERGY_NOW" << "POWER_SUPPLY_SERIAL_NUMBER"; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { + QList::Iterator itstart = powerlist.begin(), itend = powerlist.end(); + for(;itstart !=itend;itstart++) + { + if(*itstart == it.key()) + { + if (it.key() == "POWER_SUPPLY_SERIAL_NUMBER") + { + if (it.value().toString().replace(" " ,"").length() > 0) + battery_info_map.insert(it.key(), it.value()); + } + else { + if (it.value().toString().length() > 0) + battery_info_map.insert(it.key(), it.value()); + } + break; + } + } +// if(it.key() != "POWER_SUPPLY_CAPACITY" && it.key() != "POWER_SUPPLY_CYCLE_COUNT" && it.key() != "POWER_SUPPLY_POWER_NOW" && it.key() != "POWER_SUPPLY_PRESENT" && it.key() != "POWER_SUPPLY_STATUS" && it.key() != "POWER_SUPPLY_VOLTAGE_MIN_DESIGN" ) +// { +// if (it.value().toString().length() > 0) +// battery_info_map.insert(it.key(), it.value()); +// } + } + if(battery_info_map.count() == 1 && battery_info_map.contains("kylinkobe")) { + page = NULL; + } + else { + page = new ComputerPage(scroll_widget->zone, tr("Battery Info")); + page->setMap(battery_info_map, battery_info_map.value("POWER_SUPPLY_MANUFACTURER").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + }*/ +// dataOK = true; +} + diff --git a/info/batterywidget.h b/info/batterywidget.h new file mode 100644 index 0000000..6d36bb9 --- /dev/null +++ b/info/batterywidget.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BATTERYWIDGET_H +#define BATTERYWIDGET_H + +#include +#include "computerpage.h" +#include "../component/scrollwidget.h" +#include + +class QVariant; +class SessionDispatcher; + +class BatteryWidget : public QWidget +{ + Q_OBJECT +public: + explicit BatteryWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0); + ~BatteryWidget(); + void initData(); + bool getStatus(); + void clear_page_list(); + +signals: + +public slots: + +private: + ScrollWidget *scroll_widget; + ComputerPage *page; + QMap battery_info_map; + SessionDispatcher *sessionproxy; + bool dataOK; +}; + +#endif // BATTERYWIDGET_H diff --git a/info/boardwidget.cpp b/info/boardwidget.cpp new file mode 100644 index 0000000..7924890 --- /dev/null +++ b/info/boardwidget.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "boardwidget.h" + +BoardWidget::BoardWidget(QWidget *parent, SystemDispatcher *proxy) : + QWidget(parent), + systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + page = NULL; + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); + dataOK = false; +} + +BoardWidget::~BoardWidget() +{ + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void BoardWidget::clear_page_list() +{ + if (page != NULL) { + delete page; + page = NULL; + } + if (scroll_widget) + scroll_widget->resetWidget(); +} + +bool BoardWidget::displaySwitch() +{ + QMap tmpMap = systemproxy->get_board_info_qt(); +// if (tmpMap.isEmpty() || tmpMap.count() <= 0) +// { +// return false; +// } +// else +// { +// QMap::iterator it; +// for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) +// { +// if (it.value().toString().length() > 0) +// { +// board_info_map.insert(it.key(), it.value()); +// } +// } +// return true; +// } + + QMap::iterator it; + bool sflag = false; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) + { + if (it.value().toString().length() > 0) + { + board_info_map.insert(it.key(), it.value()); + sflag = true; + } + } + if (sflag) + return true; + else + return false; +} + +bool BoardWidget::getStatus() +{ + return this->dataOK; +} + +void BoardWidget::initData() +{ + this->clear_page_list(); + + page = new ComputerPage(scroll_widget->zone, tr("Board Info")); + page->setMap(board_info_map, board_info_map.value("BoaVendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + /*QMap::iterator it; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { + if (it.value().toString().length() > 0) { + board_info_map.insert(it.key(), it.value()); + } + } + if(board_info_map.count() == 1 && board_info_map.contains("kylinkobe")) + { + page = NULL; + } + else { + page = new ComputerPage(scroll_widget->zone, tr("Board Info")); + page->setMap(board_info_map, board_info_map.value("BoaVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + }*/ +// dataOK = true; +} diff --git a/info/boardwidget.h b/info/boardwidget.h new file mode 100644 index 0000000..2e402b6 --- /dev/null +++ b/info/boardwidget.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BOARDWIDGET_H +#define BOARDWIDGET_H + +#include +#include "computerpage.h" +#include "../component/scrollwidget.h" +#include + +class QVariant; +class SystemDispatcher; + +class BoardWidget : public QWidget +{ + Q_OBJECT +public: + explicit BoardWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0); + ~BoardWidget(); + void initData(); + bool getStatus(); + void clear_page_list(); + bool displaySwitch(); + +signals: + +public slots: + +private: + ScrollWidget *scroll_widget; + ComputerPage *page; + QMap board_info_map; + SystemDispatcher *systemproxy; + bool dataOK; +}; + +#endif // BOARDWIDGET_H diff --git a/info/cdrowwidget.cpp b/info/cdrowwidget.cpp new file mode 100644 index 0000000..a22999d --- /dev/null +++ b/info/cdrowwidget.cpp @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cdrowwidget.h" +#include "computerpage.h" + +CDRowWidget::CDRowWidget(QWidget *parent, SystemDispatcher *proxy) : + QWidget(parent), + systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); + dataOK = false; +} + +CDRowWidget::~CDRowWidget() +{ + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void CDRowWidget::clear_page_list() +{ + for(int i=0; iresetWidget(); +} + +bool CDRowWidget::getStatus() +{ + return this->dataOK; +} + +void CDRowWidget::initData() +{ + this->clear_page_list(); + cdrom_info_map.clear(); + cdrom_info_map = systemproxy->get_cdrom_info_qt(); + int cdNum = 0; + if (cdrom_info_map.isEmpty() || cdrom_info_map.count() <= 0) { + cdNum = 0; + } + else { + QMap::iterator iter = cdrom_info_map.find("Dvdnum"); + if (iter == cdrom_info_map.end()) { + cdNum = 0; + } + else { + cdNum = iter.value().toInt(); + if(cdNum == 1) + { + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("CDROM Info")); + page_list.append(page); + cdrom_info_map.remove("Dvdnum"); + QMap tmpMap; + QMap::iterator it; + for ( it = cdrom_info_map.begin(); it != cdrom_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(tmpMap, cdrom_info_map.value("DvdVendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + else if(cdNum > 1) + { + for(int i=0;izone, tr("CDROM Info %1").arg(i+1)); + page_list.append(page); + tmp_info_map.clear(); + QMap::iterator itbegin = cdrom_info_map.begin(); + QMap::iterator itend = cdrom_info_map.end(); + for (;itbegin != itend; ++itbegin) + { + if(itbegin.key() != "Dvdnum" && itbegin.value().toString().contains("<1_1>")) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + tmp_info_map.insert(itbegin.key(), result); + } + } + } + page->setMap(tmp_info_map, tmp_info_map.value("DvdVendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + } + } + } + /*if(cdrom_info_map.count() == 1 && cdrom_info_map.contains("kylinkobe")) + { + } + else { + if(cdNum == 1) + { + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("CDROM Info")); + cdrom_info_map.remove("Dvdnum"); + QMap tmpMap; + QMap::iterator it; + for ( it = cdrom_info_map.begin(); it != cdrom_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(tmpMap, cdrom_info_map.value("DvdVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + else if(cdNum > 1) + { + for(int i=0;izone, tr("CDROM Info %1").arg(i+1)); + tmp_info_map.clear(); + QMap::iterator itbegin = cdrom_info_map.begin(); + QMap::iterator itend = cdrom_info_map.end(); + for (;itbegin != itend; ++itbegin) + { + if(itbegin.key() != "Dvdnum" && itbegin.value().toString().contains("<1_1>")) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + tmp_info_map.insert(itbegin.key(), result); + } + } + } + page->setMap(tmp_info_map, tmp_info_map.value("DvdVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + } + }*/ +// dataOK = true; +} diff --git a/info/cdrowwidget.h b/info/cdrowwidget.h new file mode 100644 index 0000000..8683f9e --- /dev/null +++ b/info/cdrowwidget.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CDROWWIDGET_H +#define CDROWWIDGET_H + +#include +#include "../component/scrollwidget.h" +#include +#include + +class SystemDispatcher; + +class CDRowWidget : public QWidget +{ + Q_OBJECT +public: + explicit CDRowWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0); + ~CDRowWidget(); + void initData(); + bool getStatus(); + void clear_page_list(); + +signals: + +public slots: + +private: + ScrollWidget *scroll_widget; + QMap cdrom_info_map; + QMap tmp_info_map; + SystemDispatcher *systemproxy; + bool dataOK; + QList page_list; +}; + +#endif // CDROWWIDGET_H diff --git a/info/computerpage.cpp b/info/computerpage.cpp new file mode 100644 index 0000000..08f29ec --- /dev/null +++ b/info/computerpage.cpp @@ -0,0 +1,905 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "computerpage.h" +#include "../component/utils.h" +#include +#include +#include +#include +#include +#include +#include + +ComputerPage::ComputerPage(QWidget *parent, QString title/*, QString manufacturer*/) : + QWidget(parent), title_context(title)/*, vendor(manufacturer)*/ +{ +// this->setWindowFlags(Qt::FramelessWindowHint); + sensor = false; + page_height = 0; + title_label = NULL; + time_label = NULL; + logo_label = NULL; + group_box = NULL; + form_layout = NULL; + ondemand_radio = NULL; + powersave_radio = NULL; + performance_radio = NULL; + layout = NULL; + + in0_label = NULL; + in2_label = NULL; + in3_label = NULL; + in5_label = NULL; + in6_label = NULL; + tr1_label = NULL; + tr2_label = NULL; + tr3_label = NULL; + tr4_label = NULL; + tr5_label = NULL; + tr6_label = NULL; + fanin1_label = NULL; +} + +ComputerPage::~ComputerPage() +{ + for(int i=0; isetTitle(tr("%1").arg(title_context)); +} + +void ComputerPage::initUI(bool cpu) +{ + group_box = new QGroupBox(); + group_box->setStyleSheet("QGroupBox{border: 1px solid #e0e0e0;border-radius: 2px;margin-top: 15px;font-size:14px;}QGroupBox:title{subcontrol-origin: margin;subcontrol-position: top left;padding: 6px 3px;color: #00609a;font-family: 方正黑体_GBK;font-weight:bold;}"); + + QFont group_box_font = group_box->font(); + group_box_font.setBold(true); + group_box->setFont(group_box_font); + group_box->setFixedWidth(720); + + form_layout = new QFormLayout(); +// form_layout->setSizeConstraint(QLayout::SetFixedSize);//frame will fixed with content's width + form_layout->setSpacing(ITEMVSPACE); + form_layout->setHorizontalSpacing(ITEMHSPACE); + form_layout->setRowWrapPolicy(QFormLayout::DontWrapRows); + form_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); + QMap::iterator it; //遍历map + if (sensor) { + in0_label = new QLabel(); + in2_label = new QLabel(); + in3_label = new QLabel(); + in5_label = new QLabel(); + in6_label = new QLabel(); + tr1_label = new QLabel(); + tr2_label = new QLabel(); + tr3_label = new QLabel(); + tr4_label = new QLabel(); + tr5_label = new QLabel(); + tr6_label = new QLabel(); + fanin1_label = new QLabel(); + in0_label->setFixedHeight(ITEMHEIGHT); + in2_label->setFixedHeight(ITEMHEIGHT); + in3_label->setFixedHeight(ITEMHEIGHT); + in5_label->setFixedHeight(ITEMHEIGHT); + in6_label->setFixedHeight(ITEMHEIGHT); + tr1_label->setFixedHeight(ITEMHEIGHT); + tr2_label->setFixedHeight(ITEMHEIGHT); + tr3_label->setFixedHeight(ITEMHEIGHT); + tr4_label->setFixedHeight(ITEMHEIGHT); + tr5_label->setFixedHeight(ITEMHEIGHT); + tr6_label->setFixedHeight(ITEMHEIGHT); + fanin1_label->setFixedHeight(ITEMHEIGHT); + for (it = info_map.begin(); it != info_map.end(); ++it ) { + if(it.key() == "IN0") { + in0_label->setText(it.value().toString()); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), in0_label); + page_height += in0_label->height(); + } + else if(it.key() == "IN2") { + in2_label->setText(it.value().toString()); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), in2_label); + page_height += in2_label->height(); + } + else if(it.key() == "IN3") { + in3_label->setText(it.value().toString()); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), in3_label); + page_height += in3_label->height(); + } + else if(it.key() == "IN5") { + in5_label->setText(it.value().toString()); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), in5_label); + page_height += in5_label->height(); + } + else if(it.key() == "IN6") { + in6_label->setText(it.value().toString()); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), in6_label); + page_height += in6_label->height(); + } + else if(it.key() == "TR1") { + tr1_label->setText(it.value().toString()); + form_layout->addRow("ATX_3V3", tr1_label); + page_height += tr1_label->height(); + } + else if(it.key() == "TR2") { + tr2_label->setText(it.value().toString()); + form_layout->addRow("ATX_5V", tr2_label); + page_height += tr2_label->height(); + } + else if(it.key() == "TR3") { + tr3_label->setText(it.value().toString()); + form_layout->addRow("ATX_12V", tr3_label); + page_height += tr3_label->height(); + } + else if(it.key() == "TR4") { + tr4_label->setText(it.value().toString()); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), tr4_label); + page_height += tr4_label->height(); + } + else if(it.key() == "TR5") { + tr5_label->setText(it.value().toString()); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), tr5_label); + page_height += tr5_label->height(); + } + else if(it.key() == "TR6") { + tr6_label->setText(it.value().toString()); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), tr6_label); + page_height += tr6_label->height(); + } + else if(it.key() == "FANIN1") { + fanin1_label->setText(it.value().toString()); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), fanin1_label); + page_height += fanin1_label->height(); + } + page_height += ITEMVSPACE; + } + } + else { + for (it = info_map.begin(); it != info_map.end(); ++it ) { + if(it.key() == "uptime") + { + time_label = new QLabel(); + int time_value = it.value().toInt(); + int hour_value = time_value/60; + int minutes_value =time_value%60; + if(hour_value < 1) + { + time_label->setText(QString::number(minutes_value) + tr(" Minutes"));//分钟 + } + else + { + time_label->setText(QString::number(hour_value) + tr(" Hours ") + QString::number(minutes_value) + tr(" Minutes"));//小时 分钟 + } + time_label->setFixedHeight(ITEMHEIGHT); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), time_label); + page_height += time_label->height(); + } + else { + QString valueStr = it.value().toString().trimmed(); + if (QString::compare(valueStr, "UNKOWN", Qt::CaseInsensitive) == 0 || QString::compare(valueStr, "UNKNOWN", Qt::CaseInsensitive) == 0) {//for arm memory + //do nothing + } + else if (it.key().length() > 0 && valueStr.length() > 0) {//20161228 + QLabel *label = new QLabel(); + label_list.append(label); + if (it.key() == "cpu_cores") { + label->setText(tr("%1 ").arg(valueStr)); + } + else if (it.key() == "CpuVersion" && valueStr.contains("v1.0")) { + label->setText(tr("%1 64bit").arg(valueStr)); + } + else { + if (QString::compare(valueStr, "1500a v1.0 64 bits", Qt::CaseInsensitive) == 0)//2017 + label->setText(tr("%1").arg(this->translatorSwitch(valueStr))); + else if (QString::compare(valueStr, "phytium", Qt::CaseInsensitive) == 0)//2017 + label->setText(tr("%1").arg(this->translatorSwitch(valueStr))); + else if (QString::compare(valueStr, "4 cores", Qt::CaseInsensitive) == 0)//2017 + label->setText(tr("%1").arg(this->translatorSwitch(valueStr))); + else if (QString::compare(valueStr, "4 thread/core", Qt::CaseInsensitive) == 0)//2017 + label->setText(tr("%1").arg(this->translatorSwitch(valueStr))); + else if (QString::compare(valueStr, "32bit", Qt::CaseInsensitive) == 0)//2017 + label->setText(tr("%1").arg(this->translatorSwitch(valueStr))); + else if (QString::compare(valueStr, "64bit", Qt::CaseInsensitive) == 0)//2017 + label->setText(tr("%1").arg(this->translatorSwitch(valueStr))); + else if (QString::compare(valueStr, "Ethernet interface", Qt::CaseInsensitive) == 0) { + label->setText(tr("%1").arg(this->translatorSwitch(valueStr))); + } + else if (QString::compare(valueStr, "Wireless interface", Qt::CaseInsensitive) == 0) { + label->setText(tr("%1").arg(this->translatorSwitch(valueStr))); + } + else if (QString::compare(valueStr, "YHKylin community", Qt::CaseInsensitive) == 0) { + label->setText(tr("%1").arg(this->translatorSwitch(valueStr))); + } + else + { + QFont ft; + QFontMetrics fm(ft); + QString elided_text = fm.elidedText(tr("%1").arg(valueStr), Qt::ElideRight, 400); + label->setText(elided_text); + if(elided_text.endsWith("…")) + label->setToolTip(tr("%1").arg(valueStr)); +// label->setText(tr("%1").arg(valueStr)); + } + } + label->setFixedHeight(ITEMHEIGHT); + form_layout->addRow(tr("%1").arg(this->translatorSwitch(it.key())), label); + page_height += label->height(); + } + } + page_height += ITEMVSPACE; + } + } + + + if (cpu) { + if (systemProxy) { + QStringList cpulist = systemProxy->get_cpufreq_scaling_governer_list_qt(); + if (cpulist.length() > 0) { + ondemand_radio = new QRadioButton(); + ondemand_radio->setFocusPolicy(Qt::NoFocus); + ondemand_radio->setFixedHeight(ITEMHEIGHT); + ondemand_radio->setText(tr("Ondemand")); + ondemand_radio->setObjectName("ondemandradio"); + ondemand_radio->setChecked(false); + ondemand_radio->hide(); + powersave_radio = new QRadioButton(); + powersave_radio->setFixedHeight(ITEMHEIGHT); + powersave_radio->setFocusPolicy(Qt::NoFocus); + powersave_radio->setText(tr("Powersave")); + powersave_radio->setObjectName("powersaveradio"); + powersave_radio->setChecked(false); + powersave_radio->hide(); + performance_radio = new QRadioButton(); + performance_radio->setFixedHeight(ITEMHEIGHT); + performance_radio->setFocusPolicy(Qt::NoFocus); + performance_radio->setText(tr("Performance")); + performance_radio->setObjectName("performanceradio"); + performance_radio->setChecked(false); + performance_radio->hide(); + connect(ondemand_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + connect(powersave_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + connect(performance_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + layout = new QHBoxLayout(); + layout->setSpacing(10); + layout->addWidget(ondemand_radio); + layout->addWidget(powersave_radio); + layout->addWidget(performance_radio); + layout->addStretch(); + + QString cur_cpu = systemProxy->get_current_cpufreq_scaling_governer_qt(); + QList::Iterator it = cpulist.begin(), itend = cpulist.end(); + bool showed = false; + for(;it != itend; it++) + { + if(*it == "ondemand") { + if (cur_cpu == *it) { + ondemand_radio->setChecked(true); + powersave_radio->setChecked(false); + performance_radio->setChecked(false); + } + ondemand_radio->show(); + showed = true; + } + else if(*it == "powersave") { + if (cur_cpu == *it) { + powersave_radio->setChecked(true); + ondemand_radio->setChecked(false); + performance_radio->setChecked(false); + } + powersave_radio->show(); + showed = true; + } + else if(*it == "performance") { + if (cur_cpu == *it) { + performance_radio->setChecked(true); + ondemand_radio->setChecked(false); + powersave_radio->setChecked(false); + } + performance_radio->show(); + showed = true; + } + } + if (showed) { + form_layout->addRow(tr("CPU FM mode"), layout); + page_height += ITEMHEIGHT; + } + } + } + } + + page_height += ITEMVSPACE*2;//every groupbox has tow separate line + page_height += 30; + page_height += ITEMHSPACE;//ContentsMargin's height + info_map.clear(); //清空map + + group_box->setLayout(form_layout); + QVBoxLayout *layout = new QVBoxLayout(); + layout->addWidget(group_box); + layout->setMargin(0); + layout->setContentsMargins(ITEMHSPACE, ITEMHSPACE, 0, 0); + setLayout(layout); + + if(!vendor.isEmpty()) + { + logo_label = new QLabel(this); + logo_label->setAutoFillBackground(true); + logo_label->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小 + QPixmap label_pixmap(":/vendor/res/manufacturer/" + vendor + ".jpg"); + if (label_pixmap.isNull()) + { +// label_pixmap = QPixmap(":/vendor/res/manufacturer/UBUNTUKYLIN.jpg"); + label_pixmap = QPixmap(""); + } + logo_label->setPixmap(label_pixmap); + logo_label->setFixedSize(label_pixmap.size()); + logo_label->setGeometry(QRect(720 - logo_label->width(), 40, logo_label->width(), logo_label->height())); + logo_label->setMask(label_pixmap.mask()); +// QImage image(":/vendor/res/manufacturer/UBUNTUKYLIN.jpg"); +// if (!image.isNull()) { +// image = image.scaled(logo_label->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); +// logo_label->setPixmap(QPixmap::fromImage(image)); +// } +// logo_label->setGeometry(QRect(720 - logo_label->width(), 40, logo_label->width(), logo_label->height())); + } + + this->setLanguage(); +} + +void ComputerPage::setRadioButtonRowStatus() +{ + QObject *obj = sender(); //返回发出信号的对象,用QObject类型接收 + QRadioButton* pbtn = qobject_cast(obj); + QString obj_name = pbtn->objectName(); + if(obj_name == "ondemandradio") { + systemProxy->adjust_cpufreq_scaling_governer_qt("ondemand"); + } + else if(obj_name == "powersaveradio") { + systemProxy->adjust_cpufreq_scaling_governer_qt("powersave"); + } + else if(obj_name == "performanceradio") { + systemProxy->adjust_cpufreq_scaling_governer_qt("performance"); + } +} + + +void ComputerPage::resetTimeValue(QString value) +{ + time_label->setText(value); +} + +void ComputerPage::resetSensor(QMap sensormap) +{ + if (sensor) { + QMap::iterator it; //遍历map + for (it = sensormap.begin(); it != sensormap.end(); ++it ) { + if(it.key() == "IN0") { + if (in0_label) + in0_label->setText(it.value().toString()); + } + else if(it.key() == "IN2") { + if (in2_label) + in2_label->setText(it.value().toString()); + } + else if(it.key() == "IN3") { + if (in3_label) + in3_label->setText(it.value().toString()); + } + else if(it.key() == "IN5") { + if (in5_label) + in5_label->setText(it.value().toString()); + } + else if(it.key() == "IN6") { + if (in6_label) + in6_label->setText(it.value().toString()); + } + else if(it.key() == "TR1") { + if (tr1_label) + tr1_label->setText(it.value().toString()); + } + else if(it.key() == "TR2") { + if (tr2_label) + tr2_label->setText(it.value().toString()); + } + else if(it.key() == "TR3") { + if (tr3_label) + tr3_label->setText(it.value().toString()); + } + else if(it.key() == "TR4") { + if (tr4_label) + tr4_label->setText(it.value().toString()); + } + else if(it.key() == "TR5") { + if (tr5_label) + tr5_label->setText(it.value().toString()); + } + else if(it.key() == "TR6") { + if (tr6_label) + tr6_label->setText(it.value().toString()); + } + else if(it.key() == "FANIN1") { + if (fanin1_label) + fanin1_label->setText(it.value().toString()); + } + } + } +} + +QString ComputerPage::translatorSwitch(QString orgStr) +{ + if(orgStr == "MulProduct")//声卡型号 + return tr("Audio Model"); + else if(orgStr == "MulVendor")//制造商 + return tr("Vendor"); + else if(orgStr == "MulBusinfo")//总线地址 + return tr("Bus Address"); + else if(orgStr == "MulDrive")//声卡驱动 + return tr("Audio Driver"); + + else if(orgStr == "POWER_SUPPLY_NAME")//设备名 + return tr("Device Name"); + else if(orgStr == "POWER_SUPPLY_MANUFACTURER")//发行商 + return tr("Manufacturer"); +// else if(orgStr == "POWER_SUPPLY_CAPACITY")// +// return tr("POWER_SUPPLY_CAPACITY"); +// else if(orgStr == "POWER_SUPPLY_CYCLE_COUNT")// +// return tr("POWER_SUPPLY_CYCLE_COUNT"); +// else if(orgStr == "POWER_SUPPLY_POWER_NOW")// +// return tr("POWER_SUPPLY_POWER_NOW"); +// else if(orgStr == "POWER_SUPPLY_PRESENT")// +// return tr("POWER_SUPPLY_PRESENT"); +// else if(orgStr == "POWER_SUPPLY_STATUS")// +// return tr("POWER_SUPPLY_STATUS"); +// else if(orgStr == "POWER_SUPPLY_VOLTAGE_MIN_DESIGN")// +// return tr("POWER_SUPPLY_VOLTAGE_MIN_DESIGN"); + // POWER_SUPPLY_CAPACITY_LEVEL + // POWER_SUPPLY_CHARGE_FULL + // POWER_SUPPLY_CHARGE_FULL_DESIGN + // POWER_SUPPLY_CHARGE_NOW + // POWER_SUPPLY_CURRENT_NOW + // POWER_SUPPLY_PROP_STATUS + // POWER_SUPPLY_PROP_CHARGE_TYPE + // POWER_SUPPLY_PROP_HEALTH + // POWER_SUPPLY_PROP_PRESENT, + // POWER_SUPPLY_PROP_TECHNOLOGY, + // POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, + // POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, + // POWER_SUPPLY_PROP_VOLTAGE_NOW, + // POWER_SUPPLY_PROP_CAPACITY, + // POWER_SUPPLY_PROP_CURRENT_NOW, + // POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, + // POWER_SUPPLY_PROP_TEMP, + // POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL + // POWER_SUPPLY_ATTR + // POWER_SUPPLY_CURRENT_MAX + // SEQNUM + // POWER_SUPPLY_CHARGING_ENABLED + // POWER_SUPPLY_CHARGE_TYPE + // POWER_SUPPLY_HEALTH + // POWER_SUPPLY_VOLTAGE_MAX_DESIGN + // POWER_SUPPLY_TEMP + // POWER_SUPPLY_SYSTEM_TEMP_LEVEL + else if(orgStr == "POWER_SUPPLY_MODEL_NAME")//型号 + return tr("Model"); + else if(orgStr == "POWER_SUPPLY_TECHNOLOGY")//技术 + return tr("Technology"); + else if(orgStr == "POWER_SUPPLY_VOLTAGE_NOW")//电压 + return tr("Voltage"); + else if(orgStr == "POWER_SUPPLY_ENERGY_FULL_DESIGN")//能量(设计) + return tr("Energy Designed"); + else if(orgStr == "POWER_SUPPLY_ENERGY_FULL")//满时能量 + return tr("Energy Full"); + else if(orgStr == "POWER_SUPPLY_ENERGY_NOW")//能量 + return tr("Energy Now"); + else if(orgStr == "POWER_SUPPLY_SERIAL_NUMBER")//序列号 + return tr("Serial Number"); + + else if(orgStr == "BoaVendor")//主板型号 + return tr("Motherboard Model"); + else if(orgStr == "BoaProduct")//主板产商 + return tr("Motherboard Vendor"); + else if(orgStr == "BoaSerial")//序列号 + return tr("Serial Number"); + else if(orgStr == "BioVendor")//BIOS产商 + return tr("BIOS Vendor"); + else if(orgStr == "BioVersion")//BIOS版本 + return tr("BIOS Version"); + else if(orgStr == "BioRelease")//发布日期 + return tr("Release Date"); + + else if(orgStr == "DvdProduct")//光驱型号 + return tr("CD-ROM Model"); + else if(orgStr == "DvdVendor")//制造商 + return tr("Vendor"); + else if(orgStr == "DvdName")//设备名称 + return tr("Device Name"); + else if(orgStr == "DvdFw")//固件版本 + return tr("Firmware Version"); + else if(orgStr == "DvdSerial")//序列号 + return tr("Serial Number"); + + + + else if(orgStr == "CpuVersion")//处理器: + return tr("CPU"); + else if(orgStr == "CpuVendor")//制造商: + return tr("Vendor"); + else if(orgStr == "CpuSerial")//序列号: + return tr("Serial Number"); + else if(orgStr == "CpuSlot")//插座/插槽: + return tr("Socket/Slot"); + else if(orgStr == "CpuCapacity")//最大主频: + return tr("Maximum Frequency"); + else if(orgStr == "CpuSize")//当前主频: + return tr("Current Frequency"); + else if(orgStr == "CpuClock")//前端总线: + return tr("FSB"); + else if(orgStr == "cpu_cores")//核心数目: + return tr("Core Number"); + else if(orgStr == "cpu_siblings")//线程 + return tr("Thread"); + else if(orgStr == "clflush_size")//一级缓存: + return tr("L1 Cache"); + else if(orgStr == "cache_size")//二级缓存: + return tr("L2 Cache"); + + +// else if(orgStr == "1500a v1.0 64 bits")//1500a v1.0 64位 +// return tr("1500a v1.0 64 bits"); + else if(orgStr == "phytium")//飞腾 + return tr("phytium"); + else if(orgStr == "4 cores")//4核 + return tr("4 cores"); + else if(orgStr == "4 thread/core")//4线程/核 + return tr("4 thread/core"); + + + else if(orgStr == "desktopenvironment")//桌面环境 + return tr("Desktop Environment"); + else if(orgStr == "cpu") + return tr("CPU"); + else if(orgStr == "hostname") + return tr("Host Name"); + else if(orgStr == "ram") + return tr("Memery Capacity"); + else if(orgStr == "terminal") + return tr("Terminal"); + else if(orgStr == "distribution")//发行版 + return tr("Distribution"); + else if(orgStr == "language")//语言 + return tr("Language"); + else if(orgStr == "currrent_user")//当前用户 + return tr("User"); + else if(orgStr == "home_path")//用户主目录 + return tr("Home Folder"); + + else if(orgStr == "Host bridge")//主桥 + return tr("Host bridge"); + else if(orgStr == "VGA compatible controller")//VGA兼容控制器 + return tr("VGA Model"); + else if(orgStr == "USB controller")//USB控制器 + return tr("USB Model"); + else if(orgStr == "Communication controller")//通信控制器 + return tr("Communication Model"); + else if(orgStr == "Ethernet controller")//以太网控制器 + return tr("Ethernet Model"); + else if(orgStr == "Audio device")//音频设备 + return tr("Audio Model"); + else if(orgStr == "PCI bridge")//PCI桥 + return tr("PCI bridge"); + else if(orgStr == "ISA bridge")//ISA桥 + return tr("ISA bridge"); + else if(orgStr == "SATA controller")//SATA控制器 + return tr("SATA Model"); + else if(orgStr == "SMBus")//系统管理总线 + return tr("SMBus"); + else if(orgStr == "System peripheral")//系统外围 + return tr("System peripheral"); + else if(orgStr == "driver in use")//使用的驱动 + return tr("Driver in use"); + else if(orgStr == "existing drivers")//可选的驱动 + return tr("existing drivers"); + else if(orgStr == "IDE interface")//IDE接口 + return tr("IDE interface"); + else if(orgStr == "Signal processing controller")//信号处理控制器 + return tr("SP controller"); + else if(orgStr == "Network controller")//网络控制器 + return tr("Network controller"); + else if(orgStr == "Multimedia audio controller")//多媒体音频控制器 + return tr("Multimedia audio controller"); + + + else if(orgStr == "DiskProduct")//硬盘型号: + return tr("HDD Model"); + else if(orgStr == "DiskVendor")//硬盘厂商: + return tr("HDD Vendor"); + else if(orgStr == "DiskCapacity")//硬盘容量: + return tr("HDD Capacity"); + else if(orgStr == "DiskName")//设备名称: + return tr("Device Name"); + else if(orgStr == "DiskFw")//固件版本: + return tr("Firmware Version"); + else if(orgStr == "DiskSerial")//序列号: + return tr("Serial Number"); + + else if(orgStr == "MemSlot")//插槽号: + return tr("Slot Number"); + else if(orgStr == "MemProduct")//内存型号: + return tr("Memory Model"); + else if(orgStr == "MemVendor")//制造商: + return tr("Vendor"); + else if(orgStr == "MemSerial")//序列号: + return tr("Serial Number"); + else if(orgStr == "MemSize")//内存大小: + return tr("Memory Size"); + else if(orgStr == "MemWidth")//数据宽度: + return tr("Data Width"); + else if(orgStr == "MemInfo")//内存条信息: + return tr("Memory Info"); + + else if(orgStr == "Vga_product")//显卡型号: + return tr("Graphics Card Model"); + else if(orgStr == "Mon_chip")//当前显卡: + return tr("Current Graphics Card"); + else if(orgStr == "Vga_vendor")//显卡制造商: + return tr("Graphics Card Vendor"); + else if(orgStr == "Vga_Drive")//显卡驱动: + return tr("Graphics Driver"); + else if(orgStr == "Vga_businfo")//显卡总线地址: + return tr("Bus Address"); + else if(orgStr == "Mon_gamma")//伽马值 + return tr("Gamma"); + else if(orgStr == "Mon_in")//屏幕尺寸(英寸) + return tr("Screen Size(inch)"); + else if(orgStr == "Mon_maxmode")//最大分辨率 + return tr("Max Resolution"); + else if(orgStr == "Mon_output")//当前接口 + return tr("Current Interface"); + else if(orgStr == "Mon_product")//显示器型号: + return tr("Monitor Model"); + else if(orgStr == "Mon_size")//可视面积 + return tr("Visual Area"); + else if(orgStr == "Mon_support")//支持接口 + return tr("Support Interface"); + else if(orgStr == "Mon_vendor")//显示器制造商 + return tr("Monitor Manufacturers"); + else if(orgStr == "Mon_week")//生产日期_周 + return tr("Date of production/Week"); + else if(orgStr == "Mon_year")//生产日期_年 + return tr("Date of production/Year"); + + + else if(orgStr == "NetVendor")//制造商: + return tr("Vendor"); + else if(orgStr == "NetProduct")//网卡型号: + return tr("NIC Model"); + else if(orgStr == "NetDrive")//有线网卡驱动: + return tr("NIC Driver"); + else if(orgStr == "NetBusinfo")//总线地址: + return tr("Bus Address"); + else if(orgStr == "NetLogicalname")//设备名称: + return tr("Device Name"); + else if(orgStr == "NetIp")//IP地址: + return tr("IP Address"); + else if(orgStr == "NetSerial")//MAC地址: + return tr("Mac Address"); + else if(orgStr == "NetLink")//连接状态: + return tr("Connection Status"); + else if(orgStr == "NetCapacity")//最大带宽: + return tr("Max Bandwidth"); + else if(orgStr == "WlanVendor")//制造商: + return tr("Vendor"); + else if(orgStr == "WlanDrive")//无线网卡驱动: + return tr("WLan NIC Driver"); + else if(orgStr == "WlanProduct")//网卡型号: + return tr("WLan NIC Model"); + else if(orgStr == "WlanBusinfo")//总线地址: + return tr("Bus Address"); + else if(orgStr == "WlanLogicalname")//设备名称: + return tr("Device Name:"); + else if(orgStr == "WlanSerial")//序列号: + return tr("Serial Number"); + else if(orgStr == "WlanIp")//IP地址: + return tr("IP Address"); + else if (orgStr == "VNIC") { + return tr("VNIC"); + } + else if (orgStr == "NetType") { + return tr("NetType"); + } + else if (orgStr == "Ethernet interface") { + return tr("Ethernet interface"); + } + else if (orgStr == "Wireless interface") { + return tr("Wireless interface"); + } + + else if(orgStr == "ComVendor")//制造商: + return tr("Vendor"); + else if(orgStr == "ComProduct")//电脑型号: + return tr("Model"); + else if(orgStr == "ComVersion")//电脑版本: + return tr("Version"); + else if(orgStr == "ComSerial")//序列号: + return tr("Serial Number"); + else if(orgStr == "node")//主机名: + return tr("Hostname"); + else if(orgStr == "uptime")//持续运行时间: + return tr("Running Time"); + else if(orgStr == "system")//操作系统类型: + return tr("OS Types"); + else if(orgStr == "osname")//操作系统版本: + return tr("OS Version"); + else if(orgStr == "architecture")//系统位数: + return tr("Kernel Bit"); + else if(orgStr == "release")//内核版本: + return tr("Kernel Version"); + else if(orgStr == "machine")//内核架构: + return tr("Kernel Arch"); + else if (orgStr == "32bit") + return tr("32bit"); + else if (orgStr == "64bit" || orgStr == "64 bits") + return tr("64bit"); + else if (orgStr == "YHKylin community") + return tr("YHKylin community"); + + else if(orgStr == "IN0")//内存参考电压 + return tr("Memory reference voltage"); + else if(orgStr == "IN2")//SATA控制器电压 + return tr("SATA controller voltage"); + else if(orgStr == "IN3")//内存电压 + return tr("Memory voltage"); + else if(orgStr == "IN5")//CPU管脚电压 + return tr("CPU pin voltage"); + else if(orgStr == "IN6")//桥片电压 + return tr("Bridge voltage"); + else if(orgStr == "TR4")//CPU核电压 + return tr("CPU core voltage"); + else if(orgStr == "TR5")//CPU温度 + return tr("CPU temperature"); + else if(orgStr == "TR6")//主板温度 + return tr("Motherboard temperature"); + else if(orgStr == "FANIN1")//CPU风扇转速 + return tr("CPU fan speed"); + else + return orgStr; +} + +//void ComputerPage::resizeEvent(QResizeEvent *event) +//{ +// //获取当前窗口高度 +//// this->resize(700, page_height); +//// page_height = height(); +// QWidget::resizeEvent(event); +//} + + diff --git a/info/computerpage.h b/info/computerpage.h new file mode 100644 index 0000000..cbe1e1a --- /dev/null +++ b/info/computerpage.h @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef COMPUTERPAGE_H +#define COMPUTERPAGE_H + +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" +#include "../dbusproxy/youkersystemdbus.h" + +class QLabel; +class QComboBox; +class QRadioButton; +class QGroupBox; +class QFormLayout; +class QHBoxLayout; + +class ComputerPage : public QWidget +{ + Q_OBJECT +public: + explicit ComputerPage(QWidget *parent = 0, QString title = "computer"/*, QString manufacturer = "UbuntuKylin"*/); + ~ComputerPage(); + void setLanguage(); + int page_height; + void initUI(bool cpu); + void setMap(QMap tmp, const QString &manufacturer) { + info_map = tmp; + vendor = manufacturer; + } + void setsensor(bool flag) { + sensor = flag; + } + void setSystemDbusProxy(SystemDispatcher* dispatcher) { systemProxy = dispatcher;} + QString translatorSwitch(QString orgStr); + void resetTimeValue(QString value); + void resetSensor(QMap sensormap); + +public slots: + void setRadioButtonRowStatus(); + +private: + QString title_context; + QLabel *title_label; + QString vendor; +// void resizeEvent(QResizeEvent *); + QMap info_map; + QLabel *logo_label; + QLabel *time_label; + QGroupBox *group_box; + QFormLayout *form_layout; + bool sensor; + QRadioButton *ondemand_radio; + QRadioButton *powersave_radio; + QRadioButton *performance_radio; + SystemDispatcher *systemProxy; + QHBoxLayout *layout; + + QLabel *in0_label; + QLabel *in2_label; + QLabel *in3_label; + QLabel *in5_label; + QLabel *in6_label; + QLabel *tr1_label; + QLabel *tr2_label; + QLabel *tr3_label; + QLabel *tr4_label; + QLabel *tr5_label; + QLabel *tr6_label; + QLabel *fanin1_label; + QList label_list; + /* + else if(orgStr == "IN0")//内存参考电压 + return tr("Memory reference voltage"); + else if(orgStr == "IN2")//SATA控制器电压 + return tr("SATA controller voltage"); + else if(orgStr == "IN3")//内存电压 + return tr("Memory voltage"); + else if(orgStr == "IN5")//CPU管脚电压 + return tr("CPU pin voltage"); + else if(orgStr == "IN6")//桥片电压 + return tr("Bridge voltage"); + else if(orgStr == "TR4")//CPU核电压 + return tr("CPU core voltage"); + else if(orgStr == "TR5")//CPU温度 + return tr("CPU temperature"); + else if(orgStr == "TR6")//主板温度 + return tr("Motherboard temperature"); + else if(orgStr == "FANIN1")//CPU风扇转速 + return tr("CPU fan speed"); +// ATX_3V3 TR1 +// ATX_5V TR2 +// ATX_12V TR3*/ +}; + +#endif // COMPUTERPAGE_H diff --git a/info/cpuwidget.cpp b/info/cpuwidget.cpp new file mode 100644 index 0000000..8d71a97 --- /dev/null +++ b/info/cpuwidget.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cpuwidget.h" + +CpuWidget::CpuWidget(QWidget *parent, SystemDispatcher *proxy) : + QWidget(parent), + systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + page = NULL; + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403 - 3); + dataOK = false; +// timer = new QTimer(this); +// connect(timer, SIGNAL(timeout()), this, SLOT(updateCpuTemp())); +} + +CpuWidget::~CpuWidget() +{ +// disconnect(timer,SIGNAL(timeout()),this,SLOT(updateCpuTemp())); +// if(timer->isActive()) { +// timer->stop(); +// } +// if (timer != NULL) { +// delete timer; +// timer = NULL; +// } + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void CpuWidget::clear_page_list() +{ + if (page != NULL) { + delete page; + page = NULL; + } + if (scroll_widget) + scroll_widget->resetWidget(); +} + +bool CpuWidget::displaySwitch() +{ + QMap tmpMap = systemproxy->get_cpu_info_qt(); +// if (tmpMap.isEmpty() || tmpMap.count() <= 0) { +// return false; +// } +// else +// { +// QMap::iterator it; +// for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { +// if (it.value().toString().length() > 0) { +// cpu_info_map.insert(it.key(), it.value()); +// } +// } +// return true; +// } + QMap::iterator it; + bool sflag = false; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) + { + if (it.value().toString().length() > 0) + { + cpu_info_map.insert(it.key(), it.value()); + sflag = true; + } + } + if (sflag) + return true; + else + return false; + +} + +bool CpuWidget::getStatus() +{ + return this->dataOK; +} + +void CpuWidget::initData() +{ + this->clear_page_list(); + + page = new ComputerPage(scroll_widget->zone, tr("CPU Info")); + page->setSystemDbusProxy(systemproxy); + page->setMap(cpu_info_map, cpu_info_map.value("CpuVendor").toString().toUpper()); + page->initUI(true); + scroll_widget->addScrollWidget(page); + /*QMap::iterator it; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { + if (it.value().toString().length() > 0) { + cpu_info_map.insert(it.key(), it.value()); + } + } + if(cpu_info_map.count() == 1 && cpu_info_map.contains("kylinkobe")) + { + page = NULL; + } + else { + page = new ComputerPage(scroll_widget->zone, tr("CPU Info")); + page->setMap(cpu_info_map, cpu_info_map.value("CpuVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + }*/ +// dataOK = true; +} + +//void CpuWidget::updateCpuTemp() +//{ +//} diff --git a/info/cpuwidget.h b/info/cpuwidget.h new file mode 100644 index 0000000..190e782 --- /dev/null +++ b/info/cpuwidget.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CPUWIDGET_H +#define CPUWIDGET_H + +#include +#include "computerpage.h" +#include "../component/scrollwidget.h" +#include +//#include + +class QVariant; +class SystemDispatcher; + +class CpuWidget : public QWidget +{ + Q_OBJECT +public: + explicit CpuWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0); + ~CpuWidget(); + void initData(); + bool getStatus(); + void clear_page_list(); + bool displaySwitch(); + +signals: + +public slots: +// void updateCpuTemp(); + +private: + ScrollWidget *scroll_widget; + ComputerPage *page; + QMap cpu_info_map; + SystemDispatcher *systemproxy; + bool dataOK; +// QTimer *timer; +}; + +#endif // CPUWIDGET_H diff --git a/info/desktopwidget.cpp b/info/desktopwidget.cpp new file mode 100644 index 0000000..b1df72d --- /dev/null +++ b/info/desktopwidget.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "desktopwidget.h" + +DesktopWidget::DesktopWidget(QWidget *parent, SessionDispatcher *proxy) : + QWidget(parent), + sessionProxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + dataOK = false; + page = NULL; + setFixedSize(750, 403); + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); +} + +DesktopWidget::~DesktopWidget() +{ + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void DesktopWidget::clear_page_list() +{ + if (page != NULL) { + delete page; + page = NULL; + } + if (scroll_widget) + scroll_widget->resetWidget(); +} + +bool DesktopWidget::displaySwitch() +{ + QMap tmpMap = sessionProxy->get_system_message_qt(); +// if (tmpMap.isEmpty() || tmpMap.count() <= 0) +// { +// return false; +// } +// else +// { +// QMap::iterator it; +// for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { +// if (it.value().toString().length() > 0) { +// desktop_info_map.insert(it.key(), it.value()); +// } +// } +// return true; +// } + QMap::iterator it; + bool sflag = false; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) + { + if (it.value().toString().length() > 0) + { + desktop_info_map.insert(it.key(), it.value()); + sflag = true; + } + } + if (sflag) + return true; + else + return false; +} + +bool DesktopWidget::getStatus() +{ + return this->dataOK; +} + + +void DesktopWidget::initData() +{ + this->clear_page_list(); + + page = new ComputerPage(scroll_widget->zone, tr("Desktop Info")); + page->setMap(desktop_info_map, ""); + page->initUI(false); + scroll_widget->addScrollWidget(page); + /*QMap::iterator it; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { + if (it.value().toString().length() > 0) { + desktop_info_map.insert(it.key(), it.value()); + } + } + if(desktop_info_map.count() == 1 && desktop_info_map.contains("kylinkobe")) + { + page = NULL; + } + else { + page = new ComputerPage(scroll_widget->zone, tr("Desktop Info")); + page->setMap(desktop_info_map, "UBUNTUKYLIN"); + page->initUI(); + scroll_widget->addScrollWidget(page); + }*/ +// dataOK = true; +} diff --git a/info/desktopwidget.h b/info/desktopwidget.h new file mode 100644 index 0000000..a8c133d --- /dev/null +++ b/info/desktopwidget.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DESKTOPWIDGET_H +#define DESKTOPWIDGET_H + +#include +#include "computerpage.h" +#include "../component/scrollwidget.h" +#include + +class QVariant; +class SessionDispatcher; + +class DesktopWidget : public QWidget +{ + Q_OBJECT +public: + explicit DesktopWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0); + ~DesktopWidget(); + void initData(); + bool getStatus(); + void clear_page_list(); + bool displaySwitch(); + +signals: + +public slots: + +private: + ScrollWidget *scroll_widget; + ComputerPage *page; + QMap desktop_info_map; + SessionDispatcher *sessionProxy; + bool dataOK; +}; + +#endif // DESKTOPWIDGET_H diff --git a/info/devicemanager.cpp b/info/devicemanager.cpp new file mode 100644 index 0000000..a8f1aed --- /dev/null +++ b/info/devicemanager.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "devicemanager.h" + +DeviceManager::DeviceManager(QObject *parent) : + QObject(parent) +{ +} + +QStringList DeviceManager::getDeviceMsg(){ + QString cmd = "lspci -k"; + + QProcess *p = new QProcess(); + p->start(cmd); + p->waitForFinished(); + + QStringList tmpList; + while(p->canReadLine()){ + QString str = p->readLine(); + str = str.left(str.length() - 1); + tmpList.append(str); + } + + QString tmps; + QStringList deviceMsgList; + for (int i = 0;i < tmpList.size();i ++) { + QString str = tmpList.at(i); + if(str.startsWith("\t") == false){ + if(tmps != ""){ + deviceMsgList.append(tmps); + } + tmps = str.mid(str.indexOf(" ")); + }else{ + QStringList tmparr = str.split(":"); + if(tmparr.at(0).indexOf("Kernel driver in use") != -1){ + tmps += ";"; + tmps += "driver in use:"; //"使用中的驱动:" + tmps += tmparr.at(1); + } + if(tmparr.at(0).indexOf("Kernel modules") != -1){ + tmps += ";"; + tmps += "existing drivers:"; //"可选择的驱动:" + tmps += tmparr.at(1); + } + } + } + return deviceMsgList; +} diff --git a/info/devicemanager.h b/info/devicemanager.h new file mode 100644 index 0000000..f50ef2a --- /dev/null +++ b/info/devicemanager.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DEVICEMANAGER_H +#define DEVICEMANAGER_H + +#include +#include +#include +#include +#include + +class DeviceManager : public QObject +{ + Q_OBJECT +public: + explicit DeviceManager(QObject *parent = 0); + + //得到硬件设备及其驱动信息 + Q_INVOKABLE QStringList getDeviceMsg(); + +signals: + +public slots: + +}; + +#endif // DEVICEMANAGER_H diff --git a/info/driverwidget.cpp b/info/driverwidget.cpp new file mode 100644 index 0000000..df2b5c9 --- /dev/null +++ b/info/driverwidget.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "driverwidget.h" +#include "devicemanager.h" +#include + +DriverWidget::DriverWidget(QWidget *parent/*, SystemDispatcher *proxy*/) : + QWidget(parent) +// systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); + this->initData(); + if(driver_info_map.count() != 0) + { + page = new ComputerPage(scroll_widget->zone, tr("Driver Info")); + page->setMap(driver_info_map,""); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + else { + page = NULL; + } +} + +DriverWidget::~DriverWidget() +{ + if (page != NULL) { + delete page; + page = NULL; + } + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void DriverWidget::initData() +{ + DeviceManager manager; + QStringList list = manager.getDeviceMsg(); + for (int i=0 ; i < list.length() ; i++) { + QStringList splitlist = list.at(i).split(";"); + if(splitlist.length() == 1) { + QStringList name = splitlist.at(0).split(":"); + driver_info_map.insert(name.at(0).trimmed(), name.at(1)); +// driver_info_map.insert("deviceName", name.at(0)); +// driver_info_map.insert("deviceNameText", name.at(1)); + } + else if(splitlist.length() == 2) { + QStringList name1 = splitlist.at(0).split(":"); + QStringList name2 = splitlist.at(1).split(":"); + driver_info_map.insert(name1.at(0).trimmed(), name1.at(1)); + driver_info_map.insert(name2.at(0).trimmed(), name2.at(1)); +// driver_info_map.insert("deviceName", name1.at(0)); +// driver_info_map.insert("deviceNameText", name1.at(1)); +// driver_info_map.insert("inUseName", name2.at(0)); +// driver_info_map.insert("inUseNameText", name2.at(1)); + } + else if(splitlist.length() == 3) { + QStringList name3 = splitlist[0].split(":"); + QStringList name4 = splitlist[1].split(":"); + QStringList name5 = splitlist[2].split(":"); + driver_info_map.insert(name3.at(0).trimmed(), name3.at(1)); + driver_info_map.insert(name4.at(0).trimmed(), name4.at(1)); + driver_info_map.insert(name5.at(0).trimmed(), name5.at(1)); +// driver_info_map.insert("deviceName", name3.at(0)); +// driver_info_map.insert("deviceNameText", name3.at(1)); +// driver_info_map.insert("inUseName", name4.at(0)); +// driver_info_map.insert("inUseNameText", name4.at(1)); +// driver_info_map.insert("existName", name5.at(0)); +// driver_info_map.insert("existNameText", name5.at(1)); + } + } +} diff --git a/info/driverwidget.h b/info/driverwidget.h new file mode 100644 index 0000000..0dc4800 --- /dev/null +++ b/info/driverwidget.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DRIVERWIDGET_H +#define DRIVERWIDGET_H + +#include +#include "computerpage.h" +#include "../component/scrollwidget.h" +#include +class QVariant; + +class DriverWidget : public QWidget +{ + Q_OBJECT +public: + explicit DriverWidget(QWidget *parent = 0/*, SystemDispatcher *proxy = 0*/); + ~DriverWidget(); + void initData(); + +signals: + +public slots: + +private: + ScrollWidget *scroll_widget; + ComputerPage *page; + QMap driver_info_map; +}; + +#endif // DRIVERWIDGET_H diff --git a/info/hdwidget.cpp b/info/hdwidget.cpp new file mode 100644 index 0000000..6e1f5a3 --- /dev/null +++ b/info/hdwidget.cpp @@ -0,0 +1,193 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "hdwidget.h" +#include "computerpage.h" + +HDWidget::HDWidget(QWidget *parent, SystemDispatcher *proxy) : + QWidget(parent), + systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); + dataOK = false; +} + +HDWidget::~HDWidget() +{ + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void HDWidget::clear_page_list() +{ + for(int i=0; iresetWidget(); +} + +bool HDWidget::displaySwitch() +{ + hd_info_map.clear(); + hd_info_map = systemproxy->get_harddisk_info_qt(); + if (hd_info_map.isEmpty() || hd_info_map.count() <= 0) + { + return false; + } + else + { + return true; + } +} + +bool HDWidget::getStatus() +{ + return this->dataOK; +} + +void HDWidget::initData() +{ + this->clear_page_list(); + + + //0711 +// hd_info_map.insert("DiskCapacity", "465.8 GiB, 500107862016 bytes<1_1>14.9 GiB, 16013942784 bytes"); +// hd_info_map.insert("DiskFw", "0002LIM1<1_1>U21B001"); +// hd_info_map.insert("DiskName", "/dev/sda<1_1>/dev/sdb"); +// hd_info_map.insert("DiskNum", "2"); +// hd_info_map.insert("DiskProduct", "ST500LM021-1KJ152<1_1>SanDisk SSD U110 16GB"); +// hd_info_map.insert("DiskSerial", "W6227R7B<1_1>144116411501"); +// hd_info_map.insert("DiskVendor", "Seagate<1_1>Seagate"); + + hd_info_map = systemproxy->get_harddisk_info_qt(); //?硬盘,显卡,声卡,内存界面需要重新调用?为何其他界面不需要重新调用 + QMap::iterator iter = hd_info_map.find("DiskNum"); + int diskNum = 0; + if (iter == hd_info_map.end()) { + diskNum = 0; + } + else{ + diskNum = iter.value().toInt(); + } + if(diskNum == 0) { + } + else { + if(diskNum == 1) { + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("HardWare Info")); + page_list.append(page); + hd_info_map.remove("DiskNum"); + QMap tmpMap; + QMap::iterator it; + for ( it = hd_info_map.begin(); it != hd_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + if (QString::compare(it.value().toString(), "$", Qt::CaseInsensitive) != 0)//20161228 + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(tmpMap, hd_info_map.value("DiskVendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + else if(diskNum > 1) { + for(int i=0;izone, tr("HardWare Info %1").arg(i+1)); + page_list.append(page); + tmp_info_map.clear(); + QMap::iterator itbegin = hd_info_map.begin(); + QMap::iterator itend = hd_info_map.end(); + for (;itbegin != itend; ++itbegin) { + if(itbegin.key() != "DiskNum" && itbegin.value().toString().contains("<1_1>")) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + if (QString::compare(result, "$", Qt::CaseInsensitive) != 0)//20161228 + tmp_info_map.insert(itbegin.key(), result); + } + } + } + page->setMap(tmp_info_map, tmp_info_map.value("DiskVendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + } + } + /*QMap::iterator iter = hd_info_map.find("DiskNum"); + int diskNum = 0; + if (iter == hd_info_map.end()) + { + diskNum = 0; + } + else{ + diskNum = iter.value().toInt(); + } + if(hd_info_map.count() == 1 && hd_info_map.contains("kylinkobe")) + { + } + else { + if(diskNum == 1) + { + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("HardWare Info")); + hd_info_map.remove("DiskNum"); + QMap tmpMap; + QMap::iterator it; + for ( it = hd_info_map.begin(); it != hd_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + if (QString::compare(it.value().toString(), "$", Qt::CaseInsensitive) != 0)//20161228 + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(tmpMap, hd_info_map.value("DiskVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + else if(diskNum > 1) + { + for(int i=0;izone, tr("HardWare Info %1").arg(i+1)); + tmp_info_map.clear(); + QMap::iterator itbegin = hd_info_map.begin(); + QMap::iterator itend = hd_info_map.end(); + for (;itbegin != itend; ++itbegin) + { + if(itbegin.key() != "DiskNum" && itbegin.value().toString().contains("<1_1>")) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + if (QString::compare(result, "$", Qt::CaseInsensitive) != 0)//20161228 + tmp_info_map.insert(itbegin.key(), result); + } + } + } + page->setMap(tmp_info_map, tmp_info_map.value("DiskVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + } + }*/ +// dataOK = true; +} diff --git a/info/hdwidget.h b/info/hdwidget.h new file mode 100644 index 0000000..c940e03 --- /dev/null +++ b/info/hdwidget.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef HDWIDGET_H +#define HDWIDGET_H + +#include +#include "../component/scrollwidget.h" +#include +#include + +class SystemDispatcher; + +class HDWidget : public QWidget +{ + Q_OBJECT +public: + explicit HDWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0); + ~HDWidget(); + void initData(); + bool getStatus(); + void clear_page_list(); + bool displaySwitch(); + +signals: + +public slots: + +private: + ScrollWidget *scroll_widget; + QMap hd_info_map; + QMap tmp_info_map; + SystemDispatcher *systemproxy; + bool dataOK; + QList page_list; +}; + +#endif // HDWIDGET_H diff --git a/info/memorywidget.cpp b/info/memorywidget.cpp new file mode 100644 index 0000000..95eeed7 --- /dev/null +++ b/info/memorywidget.cpp @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "memorywidget.h" +#include "computerpage.h" +#include "../dbusproxy/youkersystemdbus.h" +#include + +MemoryWidget::MemoryWidget(QWidget *parent, SystemDispatcher *proxy) : + QWidget(parent), + systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); + dataOK = false; +} + +MemoryWidget::~MemoryWidget() +{ + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void MemoryWidget::clear_page_list() +{ + for(int i=0; iresetWidget(); +} + +bool MemoryWidget::displaySwitch() +{ + memory_info_map.clear(); + memory_info_map = systemproxy->get_memory_info_qt(); + if (memory_info_map.isEmpty() || memory_info_map.count() <= 0) + { + return false; + } + else + { + return true; + } +} + +bool MemoryWidget::getStatus() +{ + return this->dataOK; +} + +void MemoryWidget::initData() +{ + this->clear_page_list(); + memory_info_map = systemproxy->get_memory_info_qt();//?硬盘,显卡,声卡,内存界面需要重新调用?为何其他界面不需要重新调用 + QMap::iterator iter = memory_info_map.find("Memnum"); + int memoryNum = 0; + if (iter == memory_info_map.end()) { + memoryNum = 0; + } + else{ + memoryNum = iter.value().toInt(); + } + if(memoryNum == 0) { + } + else { + if(memoryNum == 1) { + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Memory Info")); + page_list.append(page); + memory_info_map.remove("Memnum"); + QMap tmpMap; + QMap::iterator it; + for ( it = memory_info_map.begin(); it != memory_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(tmpMap, "UBUNTUKYLIN"); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + else if(memoryNum > 1) { + for(int i=0;izone, tr("Memory Info %1").arg(i+1)); + page_list.append(page); + tmp_info_map.clear(); + QMap::iterator itbegin = memory_info_map.begin(); + QMap::iterator itend = memory_info_map.end(); + for (;itbegin != itend; ++itbegin) { + if(itbegin.key() != "Memnum" && itbegin.value().toString().contains("<1_1>")) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + tmp_info_map.insert(itbegin.key(), result); + } + } + } + page->setMap(tmp_info_map, tmp_info_map.value("MemVendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + } + } + + /*QMap::iterator iter = memory_info_map.find("Memnum"); + int memoryNum = 0; + if (iter == memory_info_map.end()) + { + memoryNum = 0; + } + else{ + memoryNum = iter.value().toInt(); + } + if(memory_info_map.count() == 1 && memory_info_map.contains("kylinkobe")) + { + } + else { + if(memoryNum == 1) + { + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Memory Info")); + memory_info_map.remove("Memnum"); + QMap tmpMap; + QMap::iterator it; + for ( it = memory_info_map.begin(); it != memory_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(tmpMap, "UBUNTUKYLIN"); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + else if(memoryNum > 1) + { + for(int i=0;izone, tr("Memory Info %1").arg(i+1)); + tmp_info_map.clear(); + QMap::iterator itbegin = memory_info_map.begin(); + QMap::iterator itend = memory_info_map.end(); + for (;itbegin != itend; ++itbegin) + { + if(itbegin.key() != "Memnum" && itbegin.value().toString().contains("<1_1>")) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + tmp_info_map.insert(itbegin.key(), result); + } + } + } + page->setMap(tmp_info_map, tmp_info_map.value("MemVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + } + }*/ +// dataOK = true; +} diff --git a/info/memorywidget.h b/info/memorywidget.h new file mode 100644 index 0000000..3375057 --- /dev/null +++ b/info/memorywidget.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef MEMORYWIDGET_H +#define MEMORYWIDGET_H + +#include +#include "../component/scrollwidget.h" +#include +#include + +class SystemDispatcher; + +class MemoryWidget : public QWidget +{ + Q_OBJECT +public: + explicit MemoryWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0); + ~MemoryWidget(); + void initData(); + bool getStatus(); + void clear_page_list(); + bool displaySwitch(); + +signals: + +public slots: + +private: + ScrollWidget *scroll_widget; + QMap memory_info_map; + QMap tmp_info_map; + SystemDispatcher *systemproxy; + bool dataOK; + QList page_list; +}; + +#endif // MEMORYWIDGET_H diff --git a/info/monitorwidget.cpp b/info/monitorwidget.cpp new file mode 100644 index 0000000..9f1d808 --- /dev/null +++ b/info/monitorwidget.cpp @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "monitorwidget.h" +#include "computerpage.h" + +MonitorWidget::MonitorWidget(QWidget *parent, SystemDispatcher *proxy) : + QWidget(parent), + systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); + dataOK = false; +} + +MonitorWidget::~MonitorWidget() +{ + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void MonitorWidget::clear_page_list() +{ + for(int i=0; iresetWidget(); +} + +bool MonitorWidget::displaySwitch() +{ + monitor_info_map.clear(); + monitor_info_map = systemproxy->get_monitor_info_qt(); + if (monitor_info_map.isEmpty() || monitor_info_map.count() <= 0) + { + return false; + } + else + { + return true; + } +} + +bool MonitorWidget::getStatus() +{ + return this->dataOK; +} + +void MonitorWidget::initData() +{ + this->clear_page_list(); + + + //0711 +// monitor_info_map.insert("Mon_chip", "Intel(R) HD Graphics 4400"); +// monitor_info_map.insert("Vga_Drive", "i915<1_1>nouveau"); +// monitor_info_map.insert("Vga_businfo", "pci@0000:00:02.0 <1_1>pci@0000:04:00.0"); +// monitor_info_map.insert("Vga_num", "2"); +// monitor_info_map.insert("Vga_product", "Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 09) (prog-if 00 [VGA controller])<1_1>NVIDIA Corporation GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] (rev a1) (prog-if 00 [VGA controller]"); +// monitor_info_map.insert("Vga_vendor", "Intel<1_1>Nvidia"); + monitor_info_map = systemproxy->get_monitor_info_qt();//?硬盘,显卡,声卡,内存界面需要重新调用?为何其他界面不需要重新调用 + QMap::iterator iter = monitor_info_map.find("Vga_num"); + int vgaNum = 0; + if (iter == monitor_info_map.end()) { + vgaNum = 0; + } + else { + vgaNum = iter.value().toInt(); + } + if(vgaNum == 0) { + } + else { + if(vgaNum == 1) { + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Monitor Info")); + page_list.append(page); + monitor_info_map.remove("Vga_num"); + QMap tmpMap; + QMap::iterator it; + for ( it = monitor_info_map.begin(); it != monitor_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(tmpMap, monitor_info_map.value("Vga_vendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + else if(vgaNum > 1) { + for(int i=0;izone, tr("Monitor Info %1").arg(i+1)); + page_list.append(page); + tmp_info_map.clear(); + QMap::iterator itbegin = monitor_info_map.begin(); + QMap::iterator itend = monitor_info_map.end(); + for (;itbegin != itend; ++itbegin) { + if(itbegin.key() != "Vga_num" && itbegin.value().toString().contains("<1_1>")) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + tmp_info_map.insert(itbegin.key(), result); + } + } + } + page->setMap(tmp_info_map, tmp_info_map.value("Vga_vendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + } + } + + /*QMap::iterator iter = monitor_info_map.find("Vga_num"); + int vgaNum = 0; + if (iter == monitor_info_map.end()) + { + vgaNum = 0; + } + else{ + vgaNum = iter.value().toInt(); + } + if(monitor_info_map.count() == 1 && monitor_info_map.contains("kylinkobe")) + { + } + else { + if(vgaNum == 1) + { + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("Monitor Info")); + monitor_info_map.remove("Vga_num"); + QMap tmpMap; + QMap::iterator it; + for ( it = monitor_info_map.begin(); it != monitor_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(tmpMap, monitor_info_map.value("Vga_vendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + else if(vgaNum > 1) + { + for(int i=0;izone, tr("Monitor Info %1").arg(i+1)); + tmp_info_map.clear(); + QMap::iterator itbegin = monitor_info_map.begin(); + QMap::iterator itend = monitor_info_map.end(); + for (;itbegin != itend; ++itbegin) + { + if(itbegin.key() != "Vga_num" && itbegin.value().toString().contains("<1_1>")) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + tmp_info_map.insert(itbegin.key(), result); + } + } + } + page->setMap(tmp_info_map, tmp_info_map.value("Vga_vendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + } + }*/ +// dataOK = true; +} diff --git a/info/monitorwidget.h b/info/monitorwidget.h new file mode 100644 index 0000000..83422e7 --- /dev/null +++ b/info/monitorwidget.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef MONITORWIDGET_H +#define MONITORWIDGET_H + +#include +#include "../component/scrollwidget.h" +#include +#include + +class SystemDispatcher; + +class MonitorWidget : public QWidget +{ + Q_OBJECT +public: + explicit MonitorWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0); + ~MonitorWidget(); + void initData(); + bool getStatus(); + void clear_page_list(); + + bool displaySwitch(); + +signals: + +public slots: + +private: + ScrollWidget *scroll_widget; + QMap monitor_info_map; + QMap tmp_info_map; + SystemDispatcher *systemproxy; + bool dataOK; + QList page_list; +}; + +#endif // MONITORWIDGET_H diff --git a/info/nicwidget.cpp b/info/nicwidget.cpp new file mode 100644 index 0000000..296d43d --- /dev/null +++ b/info/nicwidget.cpp @@ -0,0 +1,505 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "nicwidget.h" +#include + +NicWidget::NicWidget(QWidget *parent, SystemDispatcher *proxy) : + QWidget(parent), + systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); + dataOK = false; +} + +NicWidget::~NicWidget() +{ + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + +void NicWidget::clear_page_list() +{ + for(int i=0; iresetWidget(); +} + +bool NicWidget::getStatus() +{ + return this->dataOK; +} + +void NicWidget::slot_network_info(QMap info) +{ +// qDebug() << "slot_network_info=" << info; + this->clear_page_list(); + wire_info_map.clear(); + wire_info_map = info; + if (wire_info_map.isEmpty() || wire_info_map.count() <= 1) {//may be wire_info_map only contains NetNum + + } + else { + QMap::iterator iter = wire_info_map.find("NetNum"); + int netNum = 0; + if (iter == wire_info_map.end()) { + netNum = 0; + } + else{ + netNum = iter.value().toInt(); + } + wire_info_map.remove("NetNum"); +// qDebug() << netNum; + if(netNum == 0) { + } + else { + if(netNum == 1) { + if (wire_info_map.contains("NetLogicalname")) { + QMap::iterator iter = wire_info_map.find("NetLogicalname"); + QString netcard = iter.value().toString(); + if (netcard.startsWith("veth") || netcard.startsWith("virbr")) { + wire_info_map["NetType"] = "VNIC"; + } + } + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info")); + page_list.append(page); + QMap tmpMap; + QMap::iterator it; + for ( it = wire_info_map.begin(); it != wire_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + tmpMap.insert(it.key(), it.value()); + } + } + if (wire_info_map.value("NetVendor").toString().toUpper().contains("INTEL")) { + page->setMap(tmpMap, "INTEL"); + } + else if (wire_info_map.value("NetVendor").toString().toUpper().contains("REALTEK")) { + page->setMap(tmpMap, "REALTEK"); + } + else { + page->setMap(tmpMap, ""); + } + page->initUI(false); + scroll_widget->addScrollWidget(page); + page->show(); + } + else if(netNum > 1) { + for(int i=0;izone, tr("NIC Info %1").arg(i+1)); + page_list.append(page); + tmp_info_map.clear(); + QMap::iterator itbegin = wire_info_map.begin(); + QMap::iterator itend = wire_info_map.end(); + for (;itbegin != itend; ++itbegin) { + if(itbegin.value().toString().contains("<1_1>")) { + QStringList tmplist = itbegin.value().toString().split("<1_1>"); + if (tmplist.length() >= i) { + QString result = tmplist.at(i); + if (result.length() > 0) + tmp_info_map.insert(itbegin.key(), result); + } + } + } + if (tmp_info_map.contains("NetLogicalname")) { + if (tmp_info_map.value("NetLogicalname").toString().startsWith("veth") || tmp_info_map.value("NetLogicalname").toString().startsWith("virbr")) { + tmp_info_map["NetType"] = QVariant("VNIC"); + } + } +// qDebug() << "tmp_info_map=" << tmp_info_map; + if (tmp_info_map.value("NetVendor").toString().toUpper().contains("INTEL")) { + page->setMap(tmp_info_map, "INTEL"); + } + else if (tmp_info_map.value("NetVendor").toString().toUpper().contains("REALTEK")) { + page->setMap(tmp_info_map, "REALTEK"); + } + else { + page->setMap(tmp_info_map, ""); + } + page->initUI(false); + scroll_widget->addScrollWidget(page); + page->show(); + } + } + } + } +// dataOK = true; +} + +void NicWidget::initData() +{ + /*wire_info_map.clear(); + wire_info_map = systemproxy->get_networkcard_info_qt(); + if (wire_info_map.isEmpty() || wire_info_map.count() <= 1) {//may be wire_info_map only contains NetNum + + } + else { + QMap::iterator iter = wire_info_map.find("NetNum"); + int netNum = 0; + if (iter == wire_info_map.end()) { + netNum = 0; + } + else{ + netNum = iter.value().toInt(); + } + wire_info_map.remove("NetNum"); + if(netNum == 0) { + } + else { + if(netNum == 1) { + if (wire_info_map.contains("NetLogicalname")) { + QMap::iterator iter = wire_info_map.find("NetLogicalname"); + QString netcard = iter.value().toString(); + if (netcard.startsWith("veth") || netcard.startsWith("virbr")) { + wire_info_map["NetType"] = "VNIC"; + } + } + ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info")); + QMap tmpMap; + QMap::iterator it; + for ( it = wire_info_map.begin(); it != wire_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + tmpMap.insert(it.key(), it.value()); + } + } + if (wire_info_map.value("NetVendor").toString().toUpper().contains("INTEL")) { + page->setMap(tmpMap, "INTEL"); + } + else if (wire_info_map.value("NetVendor").toString().toUpper().contains("REALTEK")) { + page->setMap(tmpMap, "REALTEK"); + } + else { + page->setMap(tmpMap, ""); + } + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + else if(netNum > 1) { + for(int i=0;izone, tr("NIC Info %1").arg(i+1)); + tmp_info_map.clear(); + QMap::iterator itbegin = wire_info_map.begin(); + QMap::iterator itend = wire_info_map.end(); + for (;itbegin != itend; ++itbegin) { + if(itbegin.value().toString().contains("<1_1>")) { + QStringList tmplist = itbegin.value().toString().split("<1_1>"); + if (tmplist.length() >= i) { + QString result = tmplist.at(i); + if (result.length() > 0) + tmp_info_map.insert(itbegin.key(), result); + } + } + } + if (tmp_info_map.contains("NetLogicalname")) { + if (tmp_info_map.value("NetLogicalname").toString().startsWith("veth") || tmp_info_map.value("NetLogicalname").toString().startsWith("virbr")) { + tmp_info_map["NetType"] = QVariant("VNIC"); + } + } + if (tmp_info_map.value("NetVendor").toString().toUpper().contains("INTEL")) { + page->setMap(tmp_info_map, "INTEL"); + } + else if (tmp_info_map.value("NetVendor").toString().toUpper().contains("REALTEK")) { + page->setMap(tmp_info_map, "REALTEK"); + } + else { + page->setMap(tmp_info_map, ""); + } + page->initUI(false); + scroll_widget->addScrollWidget(page); + } + } + } + } + dataOK = true;*/ + + + + + + /*QMap tmpMap = systemproxy->get_networkcard_info_qt(); + if (tmpMap.isEmpty() || tmpMap.count() <= 0) { + page2 = NULL; + } + else { + QMap::iterator it;//遍历map + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { + if(it.key().startsWith("Wlan")) { + if (it.value().toString().length() > 0) { + wireless_info_map.insert(it.key(), it.value()); + } + } + else { + if (it.value().toString().length() > 0) { + wire_info_map.insert(it.key(), it.value()); + } + } + } + QMap::iterator iter = tmpMap.find("NetNum"); + int netNum = 0; + if (iter == tmpMap.end()) { + netNum = 0; + } + else { + netNum = iter.value().toInt(); + } + if(wire_info_map.isEmpty() || wire_info_map.count() <= 0) { + } + else { + if(netNum == 1) { + ComputerPage *page = NULL; + if (wire_info_map.contains("NetLogicalname")) { + QMap::iterator iter = wire_info_map.find("NetLogicalname"); + QString netcard = iter.value().toString(); + if (netcard.startsWith("veth") || netcard.startsWith("virbr")) { + page = new ComputerPage(scroll_widget->zone, tr("Vir NIC Info")); + } + else { + page = new ComputerPage(scroll_widget->zone, tr("NIC Info")); + } + } + else { + page = new ComputerPage(scroll_widget->zone, tr("NIC Info")); + } +// ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info")); + wire_info_map.remove("NetNum"); + QMap tmpMap; + QMap::iterator it; + for ( it = wire_info_map.begin(); it != wire_info_map.end(); ++it ) { + if (it.value().toString().length() > 0) { + if (QString::compare(it.value().toString(), "$", Qt::CaseInsensitive) != 0)//20161228 + tmpMap.insert(it.key(), it.value()); + } + } + page->setMap(wire_info_map, wire_info_map.value("NetVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + else if(netNum > 1) { + int vir = 0; + int nic = 0; + bool pageInit = false; + for(int i=0;i::iterator itbegin = wire_info_map.begin(); + QMap::iterator itend = wire_info_map.end(); + for (;itbegin != itend; ++itbegin) { + if(itbegin.key() != "NetNum" && itbegin.value().toString().contains("<1_1>")) { + int len = itbegin.value().toString().split("<1_1>").length(); + if (len > i) { + QString result = itbegin.value().toString().split("<1_1>").at(i); + if (result.length() > 0) { + if (QString::compare(result, "$", Qt::CaseInsensitive) != 0) { + tmp_info_map.insert(itbegin.key(), result); + if (itbegin.key() == "NetLogicalname") { + if (result.startsWith("veth") || result.startsWith("virbr")) { + if (!pageInit) { + vir ++; + page = new ComputerPage(scroll_widget->zone, tr("Vir NIC Info %1").arg(vir)); + } + } + else { + if (!pageInit) { + nic ++; + page = new ComputerPage(scroll_widget->zone, tr("NIC Info %1").arg(nic)); + } + } + pageInit = true; + } + } + } + } + else { + tmp_info_map.insert(itbegin.key(), "unknown"); + } + } + } +// ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info %1").arg(i+1)); + page->setMap(tmp_info_map, tmp_info_map.value("NetVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + } + } + } + + if (wireless_info_map.isEmpty() || wireless_info_map.count() == 0) { + page2 = NULL; + } + else { + page2 = new ComputerPage(scroll_widget->zone, tr("WireLess NIC Info")); + page2->setMap(wireless_info_map, wireless_info_map.value("WlanVendor").toString().toUpper()); + page2->initUI(); + scroll_widget->addScrollWidget(page2); + } + }*/ +// QMap::iterator it;//遍历map +// for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { +// if(it.key().startsWith("Wlan")) +// { +// if (it.value().toString().length() > 0) { +// wireless_info_map.insert(it.key(), it.value()); +// } +// } +// else +// { +// if (it.value().toString().length() > 0) { +// wire_info_map.insert(it.key(), it.value()); +// } +// } +// } + +// QMap::iterator iter = tmpMap.find("NetNum"); +// int netNum = 0; +// if (iter == tmpMap.end()) +// { +// netNum = 0; +// } +// else { +// netNum = iter.value().toInt(); +// } +// if(wire_info_map.count() == 1 && wire_info_map.contains("kylinkobe")) +// { +// } +// else { +// if(netNum == 1) +// { +// ComputerPage *page = new ComputerPage(scroll_widget->zone, tr("NIC Info")); +// wire_info_map.remove("NetNum"); +// QMap tmpMap; +// QMap::iterator it; +// for ( it = wire_info_map.begin(); it != wire_info_map.end(); ++it ) { +// if (it.value().toString().length() > 0) { +// if (QString::compare(it.value().toString(), "$", Qt::CaseInsensitive) != 0)//20161228 +// tmpMap.insert(it.key(), it.value()); +// } +// } +// page->setMap(wire_info_map, wire_info_map.value("NetVendor").toString().toUpper()); +// page->initUI(); +// scroll_widget->addScrollWidget(page); +// } +// else if(netNum > 1) +// { +// for(int i=0;izone, tr("NIC Info %1").arg(i+1)); +// tmp_info_map.clear(); +// QMap::iterator itbegin = wire_info_map.begin(); +// QMap::iterator itend = wire_info_map.end(); +// for (;itbegin != itend; ++itbegin) +// { +// if(itbegin.key() != "NetNum" && itbegin.value().toString().contains("<1_1>")) { +// int len = itbegin.value().toString().split("<1_1>").length(); +// if (len > i) { +// QString result = itbegin.value().toString().split("<1_1>").at(i); +// if (result.length() > 0) { +// if (QString::compare(result, "$", Qt::CaseInsensitive) != 0)//20161228 +// tmp_info_map.insert(itbegin.key(), result); +// } +// } +// else { +// tmp_info_map.insert(itbegin.key(), "unknown"); +// } +// } +// } +// page->setMap(tmp_info_map, tmp_info_map.value("NetVendor").toString().toUpper()); +// page->initUI(); +// scroll_widget->addScrollWidget(page); +// } +// } +// } + +// if((wireless_info_map.count() == 0) || (wireless_info_map.count() == 1 && wireless_info_map.contains("kylinkobe"))) +// { +// page2 = NULL; +// } +// else { +// page2 = new ComputerPage(scroll_widget->zone, tr("WireLess NIC Info")); +// page2->setMap(wireless_info_map, wireless_info_map.value("WlanVendor").toString().toUpper()); +// page2->initUI(); +// scroll_widget->addScrollWidget(page2); +// } +// dataOK = true; + + + + + + + + + + + + + + + + + + + +// QMap::iterator it; //遍历map +// for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { +// if(it.key().startsWith("Wlan")) +// { +// if (it.value().toString().length() > 0) { +// wireless_info_map.insert(it.key(), it.value()); +// } +// } +// else +// { +// if (it.value().toString().length() > 0) { +// wire_info_map.insert(it.key(), it.value()); +// } +// } +// } +// if((wire_info_map.count() == 0) || (wire_info_map.count() == 1 && wire_info_map.contains("kylinkobe"))) +// { +// page = NULL; +// } +// else { +// page = new ComputerPage(scroll_widget->zone, tr("NIC Info")); +// page->setMap(wire_info_map, wire_info_map.value("NetVendor").toString().toUpper()); +// page->initUI(); +// scroll_widget->addScrollWidget(page); +// } +// if((wireless_info_map.count() == 0) || (wireless_info_map.count() == 1 && wireless_info_map.contains("kylinkobe"))) +// { +// page2 = NULL; +// } +// else { +// page2 = new ComputerPage(scroll_widget->zone, tr("WireLess NIC Info")); +// page2->setMap(wireless_info_map, wireless_info_map.value("WlanVendor").toString().toUpper()); +// page2->initUI(); +// scroll_widget->addScrollWidget(page2); +// } +// dataOK = true; +} diff --git a/info/nicwidget.h b/info/nicwidget.h new file mode 100644 index 0000000..6249356 --- /dev/null +++ b/info/nicwidget.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef NICWIDGET_H +#define NICWIDGET_H + +#include +#include "computerpage.h" +#include "../component/scrollwidget.h" +#include + +class QVariant; +class SystemDispatcher; + +class NicWidget : public QWidget +{ + Q_OBJECT +public: + explicit NicWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0); + ~NicWidget(); + void initData(); + bool getStatus(); + void clear_page_list(); + +signals: + +public slots: + void slot_network_info(QMap info); + +private: + ScrollWidget *scroll_widget; +// ComputerPage *page; +// ComputerPage *page2; + QMap wire_info_map; +// QMap wireless_info_map; + QMap tmp_info_map; + SystemDispatcher *systemproxy; + bool dataOK; + QList page_list; +}; + +#endif // NICWIDGET_H diff --git a/info/sensorwidget.cpp b/info/sensorwidget.cpp new file mode 100644 index 0000000..7207cc7 --- /dev/null +++ b/info/sensorwidget.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sensorwidget.h" +#include "computerpage.h" + +SensorWieget::SensorWieget(QWidget *parent, SystemDispatcher *proxy) : + QWidget(parent), + systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + page = NULL; + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeValue())); + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); + this->initData(); +} + +SensorWieget::~SensorWieget() +{ + if (timer != NULL) { + disconnect(timer,SIGNAL(timeout()),this,SLOT(updateTimeValue())); + if(timer->isActive()) { + timer->stop(); + } + delete timer; + timer = NULL; + } + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + + +void SensorWieget::clear_page_list() +{ + if (page != NULL) { + delete page; + page = NULL; + } + if (scroll_widget) + scroll_widget->resetWidget(); +} + +void SensorWieget::updateTimeValue() +{ + QMap tmpMap = systemproxy->get_sensor_info_qt(); + if (tmpMap.isEmpty() || tmpMap.count() <= 0) { + + } + else { + sensor_info_map.clear(); + QMap::iterator it; + for (it = tmpMap.begin(); it != tmpMap.end(); ++it) { + if (it.value().toString().length() > 0) { + sensor_info_map.insert(it.key(), it.value()); + } + } + if (!sensor_info_map.isEmpty() && sensor_info_map.count() > 0) { + page->resetSensor(sensor_info_map); + } + } +} + +void SensorWieget::initData() +{ + QMap tmpMap = systemproxy->get_sensor_info_qt(); + if (tmpMap.isEmpty() || tmpMap.count() <= 0) { + page = NULL; + } + else { + QMap::iterator it; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { + if (it.value().toString().length() > 0) { + sensor_info_map.insert(it.key(), it.value()); + } + } + if (sensor_info_map.isEmpty() || sensor_info_map.count() <= 0) { + page = NULL; + } + else { + page = new ComputerPage(scroll_widget->zone, tr("Hardware sensor information")); + page->setMap(sensor_info_map, ""); + page->setsensor(true); + page->initUI(false); + scroll_widget->addScrollWidget(page); + timer->start(1000*4); + } + } + /*QMap::iterator it; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { + if (it.value().toString().length() > 0) { + sensor_info_map.insert(it.key(), it.value()); + } + } + if(sensor_info_map.count() == 0) + { + page = NULL; + } + else { + page = new ComputerPage(scroll_widget->zone, tr("Hardware sensor information")); + page->setMap(sensor_info_map, ""); + page->setsensor(true); + page->initUI(); + scroll_widget->addScrollWidget(page); + timer->start(1000*4); + }*/ +} diff --git a/info/sensorwidget.h b/info/sensorwidget.h new file mode 100644 index 0000000..911ce92 --- /dev/null +++ b/info/sensorwidget.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SENSORWIDGET_H +#define SENSORWIDGET_H + +#include +#include "../component/scrollwidget.h" +#include +#include +#include + +class SystemDispatcher; + +class SensorWieget : public QWidget +{ + Q_OBJECT +public: + explicit SensorWieget(QWidget *parent = 0, SystemDispatcher *proxy = 0); + ~SensorWieget(); + void initData(); + void clear_page_list(); + +signals: + +public slots: + void updateTimeValue(); + +private: + ScrollWidget *scroll_widget; + QMap sensor_info_map; + ComputerPage *page; + SystemDispatcher *systemproxy; + QTimer *timer; +}; + +#endif // SENSORWIDGET_H diff --git a/info/systemwidget.cpp b/info/systemwidget.cpp new file mode 100644 index 0000000..b9fb3c8 --- /dev/null +++ b/info/systemwidget.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "systemwidget.h" +#include +#include +#include + +SystemWidget::SystemWidget(QWidget *parent, SystemDispatcher *proxy) : + QWidget(parent), + systemproxy(proxy) +{ + this->setStyleSheet("QWidget{border: none;background-color: #ffffff;}"); + setFixedSize(750, 403); + page = NULL; + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeValue())); + scroll_widget = new ScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 403); + this->initData(); +} + +SystemWidget::~SystemWidget() +{ + if (timer != NULL) { + disconnect(timer,SIGNAL(timeout()),this,SLOT(updateTimeValue())); + if(timer->isActive()) { + timer->stop(); + } + delete timer; + timer = NULL; + } + this->clear_page_list(); + if (scroll_widget != NULL) { + delete scroll_widget; + scroll_widget = NULL; + } +} + + +void SystemWidget::clear_page_list() +{ + if (page != NULL) { + delete page; + page = NULL; + } + if (scroll_widget) + scroll_widget->resetWidget(); +} + +void SystemWidget::updateTimeValue() +{ + QString result; + int time_value = systemproxy->get_time_value_qt().toInt(); + int hour_value = time_value/60; + int minutes_value =time_value%60; + if(hour_value < 1) + { + result = QString::number(minutes_value) + tr(" Minutes");//分钟 + } + else + { + result = QString::number(hour_value) + tr(" Hours ") + QString::number(minutes_value) + tr(" Minutes");//小时 分钟 + } + page->resetTimeValue(result); +} + + +bool SystemWidget::displaySwitch() +{ + return true; //系统信息的首页,一直为真 +} + +void SystemWidget::initData() +{ + this->clear_page_list(); + QMap tmpMap = systemproxy->get_computer_info_qt(); + if (tmpMap.isEmpty() || tmpMap.count() <= 0) { + page = NULL; + } + else { + QMap::iterator it; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { + if (it.value().toString().length() > 0) { + sys_info_map.insert(it.key(), it.value()); + } + } + if(sys_info_map.isEmpty() || sys_info_map.count() <= 0) { + page = NULL; + } + else { + page = new ComputerPage(scroll_widget->zone, tr("Computer Base Info")); + page->setMap(sys_info_map, sys_info_map.value("ComVendor").toString().toUpper()); + page->initUI(false); + scroll_widget->addScrollWidget(page); + timer->start(1000*4); + } + } + /*QMap::iterator it; + for ( it = tmpMap.begin(); it != tmpMap.end(); ++it ) { + if (it.value().toString().length() > 0) { + sys_info_map.insert(it.key(), it.value()); + } + } + if(sys_info_map.count() == 1 && sys_info_map.contains("kylinkobe")) + { + page = NULL; + } + else { + page = new ComputerPage(scroll_widget->zone, tr("Computer Base Info")); + page->setMap(sys_info_map, sys_info_map.value("ComVendor").toString().toUpper()); + page->initUI(); + scroll_widget->addScrollWidget(page); + timer->start(1000*4); + }*/ +} diff --git a/info/systemwidget.h b/info/systemwidget.h new file mode 100644 index 0000000..2deaea6 --- /dev/null +++ b/info/systemwidget.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SYSTEMWIDGET_H +#define SYSTEMWIDGET_H + +#include +#include "computerpage.h" +#include "../component/scrollwidget.h" +#include +#include + +class QVariant; +class SystemDispatcher; + +class SystemWidget : public QWidget +{ + Q_OBJECT +public: + explicit SystemWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0); + ~SystemWidget(); + void initData(); + void clear_page_list(); + bool displaySwitch(); + +signals: + +public slots: + void updateTimeValue(); + +private: + ScrollWidget *scroll_widget; + ComputerPage *page; + QMap sys_info_map; + SystemDispatcher *systemproxy; + QTimer *timer; +}; + +#endif // SYSTEMWIDGET_H diff --git a/mainui/aboutdialog-org.cpp b/mainui/aboutdialog-org.cpp new file mode 100644 index 0000000..abe2a59 --- /dev/null +++ b/mainui/aboutdialog-org.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "QDesktopWidget" + +#include "aboutdialog.h" +#include "ui_aboutdialog.h" +#include + +AboutDialog::AboutDialog(QWidget *parent, const QString &version) : + QDialog(parent), + ui(new Ui::AboutDialog) +{ + ui->setupUi(this); + this->setStyleSheet("QDialog{border: 1px solid gray;border-radius:2px}"); + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + ui->tabWidget->setStyleSheet("QTabWidget{border:1px solid #bebebe;}"); + ui->textEdit->setStyleSheet("QLineEdit{border:1px solid #bebebe;}"); + ui->textEdit_2->setStyleSheet("QLineEdit{border:1px solid #bebebe;}"); + ui->versionlabel->setText(version); + this->setWindowFlags(Qt::WindowStaysOnTopHint); + move((QApplication::desktop()->width() - this->width())/2, (QApplication::desktop()->height() - this->height())/2); + ui->tabWidget->setCurrentIndex(0); + connect(ui->homeBtn, SIGNAL(linkActivated(QString)), this, SLOT(openUrl(QString))); +} + +AboutDialog::~AboutDialog() +{ + delete ui; +} + +void AboutDialog::on_closeBtn_clicked() +{ +// QDialog::accept(); + this->hide(); +} + +void AboutDialog::openUrl(QString url) +{ + QDesktopServices::openUrl(QUrl(url)); +} diff --git a/mainui/aboutdialog-org.h b/mainui/aboutdialog-org.h new file mode 100644 index 0000000..9284aa6 --- /dev/null +++ b/mainui/aboutdialog-org.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include + +namespace Ui { +class AboutDialog; +} + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = 0, const QString &version=""); + ~AboutDialog(); + +private slots: + void on_closeBtn_clicked(); + void openUrl(QString url); + +private: + Ui::AboutDialog *ui; +}; + +#endif // ABOUTDIALOG_H diff --git a/mainui/aboutdialog-org.ui b/mainui/aboutdialog-org.ui new file mode 100644 index 0000000..5043a6c --- /dev/null +++ b/mainui/aboutdialog-org.ui @@ -0,0 +1,209 @@ + + + AboutDialog + + + + 0 + 0 + 400 + 320 + + + + + 400 + 320 + + + + + 400 + 320 + + + + About + + + + + 2 + 0 + 396 + 271 + + + + 1 + + + + About + + + + + 10 + 1 + 64 + 64 + + + + + + + :/res/youker-assistant.png + + + + + + 77 + 17 + 241 + 20 + + + + Youker Assistant + + + Qt::AlignCenter + + + + + + 292 + 42 + 101 + 17 + + + + + + + Qt::AlignCenter + + + + + + 18 + 76 + 361 + 151 + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:11pt;"> Youker Assistant is a powerful system supporting software which is developed by Ubuntu Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information , system customization, task manager, monitoring ball, and some other functions. </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:11pt;"> The software is still under development. Please visit www.ubuntukylin.com for more information. Welcome everyone to join with us. youker-assistant Homepage: https://launchpad.net/youker-assistant.</span></p></body></html> + + + + + + Contributor + + + + + 18 + 76 + 361 + 151 + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt;">Maintainer</span><span style=" font-family:'Droid Sans Fallback'; font-size:11pt;">:</span></p> +<p style=" margin-top:11px; margin-bottom:11px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt;">Ubuntu Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</span></p></body></html> + + + + + + 10 + 1 + 64 + 64 + + + + + + + :/res/youker-assistant.png + + + + + + 77 + 17 + 241 + 20 + + + + Youker Assistant + + + Qt::AlignCenter + + + + + + 292 + 42 + 101 + 17 + + + + <a href=https://launchpad.net/youker-assistant>home page</a> + + + Qt::AlignCenter + + + + + + + + 291 + 281 + 81 + 30 + + + + Close + + + + + + + + + + diff --git a/mainui/aboutdialog.cpp b/mainui/aboutdialog.cpp new file mode 100644 index 0000000..4d41dac --- /dev/null +++ b/mainui/aboutdialog.cpp @@ -0,0 +1,258 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "QDesktopWidget" + +#include "aboutdialog.h" +#include +#include +#include +#include "../component/utils.h" + +AboutDialog::AboutDialog(QWidget *parent, /*const QString &version, */QString skin, QString arch, QString os): + QDialog(parent) +{ + this->setWindowFlags(Qt::FramelessWindowHint); +// this->setWindowFlags(Qt::WindowStaysOnTopHint); + this->setFixedSize(442, 326); + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); + this->setWindowTitle(tr("About us")); + + aboutGroup = NULL; + contributorGroup = NULL; + + baseWidget = new QWidget(this); + baseWidget->setGeometry(QRect(0, 0, 442, 82)); +// baseWidget->setStyleSheet("QWidget{background:transparent url(://res/menu-big-hover.png);}"); + baseWidget->setAutoFillBackground(true); +// QPixmap label_pixmap(skin); +// logo_label->setPixmap(label_pixmap); +// logo_label->setFixedSize(label_pixmap.size()); + +// QPixmap label_pixmap(skin); +// qDebug() << label_pixmap.size(); + + QPalette palette; + palette.setBrush(QPalette::Background, QBrush(QPixmap(skin))); + baseWidget->setPalette(palette); + + close_btn = new SystemButton(baseWidget); + close_btn->setFocusPolicy(Qt::NoFocus); + close_btn->loadPixmap(":/sys/res/sysBtn/close_button.png"); + + iconLabel = new QLabel(baseWidget); + //iconLabel->setGeometry(QRect(380, 20, 44, 44)); + iconLabel->setGeometry(QRect(360, 36, 44, 44));//20161228 + nameLabel = new QLabel(baseWidget); + nameLabel->setGeometry(QRect(71, 0, 300, 30)); +// linkLabel = new QLabel(); +// iconLabel->setStyleSheet("QLabel{background-image:url(':/res/youker-assistant.png')}"); + + QImage image(":/res/youker-assistant.png"); + image = image.scaled(QSize(44, 44), Qt::KeepAspectRatio, Qt::SmoothTransformation); + iconLabel->setPixmap(QPixmap::fromImage(image)); + + nameLabel->setStyleSheet("QLabel{color:#ffffff;font-family: 方正黑体_GBK;font-size: 12px;text-align: center;font-weight:bold;}"); + nameLabel->setAlignment(Qt::AlignCenter); +// if (arch == "aarch64" || os == "Kylin" || os == "YHKylin") {//20161228 +// close_btn->move(442-36, 0); +// nameLabel->setText(tr("Kylin Assisant") + " " + VERSION); +// } +// else { +// close_btn->move(0, 0); +// nameLabel->setText(tr("Youker Assisant") + " " + VERSION); +// } + + close_btn->move(442-36, 0); + nameLabel->setText(tr("Kylin Assistant") + " " + VERSION); + +// linkLabel->setAlignment(Qt::AlignRight); +// linkLabel->setText(QString::fromLocal8Bit(" home page")); + + aboutBtn = new QPushButton(baseWidget); + aboutBtn->setText(tr("About")); + aboutBtn->setGeometry(QRect(10, 50, 60, 24)); + contributorBtn = new QPushButton(baseWidget); + contributorBtn->setText(tr("Contributor")); + contributorBtn->setGeometry(QRect(75, 50, 60, 24)); + + indicator = new QLabel(baseWidget); + indicator->setStyleSheet("QLabel{background-image:url('://res/underline.png');background-position:center;}"); + indicator->setGeometry(QRect(10, 75, 60, 2)); +// aboutIndicator = new QLabel(baseWidget); +// aboutIndicator->setGeometry(QRect(10, 75, 60, 2)); +// contributorIndicator = new QLabel(baseWidget); +// contributorIndicator->setGeometry(QRect(75, 75, 60, 2)); +// aboutIndicator->setStyleSheet("QLabel{background-image:url('://res/underline.png');background-position:center;}"); +// contributorIndicator->setStyleSheet("QLabel{background-image:url('://res/underline.png');background-position:center;}"); +// contributorIndicator->hide(); + +// aboutEdit = new QTextEdit(this); + aboutEdit = new QTextBrowser(this); + aboutEdit->setOpenLinks(true); + aboutEdit->setOpenExternalLinks(true); + contributorEdit = new QTextEdit(this); + aboutEdit->setGeometry(QRect(17, 92, 408, 200)); + contributorEdit->setGeometry(QRect(17, 92, 408, 200)); + aboutEdit->setReadOnly(true); + contributorEdit->setReadOnly(true); +// if (arch == "aarch64" || os == "Kylin" || os == "YHKylin") { +// contributorEdit->setText(tr("Maintainer:\nKylin Team ")); +// aboutEdit->append(tr(" Kylin Assistant is a powerful system supporting software which is developed by Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, task manager, and some other functions.")); +// aboutEdit->append(tr(" The software is still under development. Please visit ") + QString::fromLocal8Bit("www.ubuntukylin.com") + tr(" for more information. Welcome everyone to join with us. kylin-assistant Homepage: ")); +// } +// else { +// contributorEdit->setText(tr("Maintainer:\nUbuntu Kylin Team ")); +// aboutEdit->append(tr(" Youker Assistant is a powerful system supporting software which is developed by Ubuntu Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, system customization, task manager, and some other functions.")); +// aboutEdit->append(tr(" The software is still under development. Please visit ") + QString::fromLocal8Bit("www.ubuntukylin.com") + tr(" for more information. Welcome everyone to join with us. youker-assistant Homepage: ")); +// } + + contributorEdit->setText(tr("Maintainer:\nKylin Team ")); + aboutEdit->append(tr(" Kylin Assistant is a powerful system supporting software which is developed by Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, task manager, and some other functions.")); + aboutEdit->append(tr(" The software is still under development. Please visit ") + QString::fromLocal8Bit("www.ubuntukylin.com") + tr(" for more information. Welcome everyone to join with us. kylin-assistant Homepage: ")); + + aboutEdit->append(QString::fromLocal8Bit("https://launchpad.net/youker-assistant")); + + contributorEdit->hide(); + + aboutBtn->setFocusPolicy(Qt::NoFocus); + aboutBtn->setObjectName("transparentButton"); + contributorBtn->setFocusPolicy(Qt::NoFocus); + contributorBtn->setObjectName("transparentButton"); + aboutBtn->setStyleSheet("QPushButton{background:transparent;text-align:center;font-family: 方正黑体_GBK;font-size:14px;color:#ffffff;}");//QPushButton:hover{color:#666666;} + contributorBtn->setStyleSheet("QPushButton{background:transparent;text-align:center;font-family: 方正黑体_GBK;font-size:14px;color:#ffffff;}");//QPushButton:hover{color:#666666;} +// aboutEdit->setStyleSheet("QLineEdit{border:1px solid #bebebe;}"); +// contributorEdit->setStyleSheet("QLineEdit{border:1px solid #bebebe;}"); + aboutEdit->setStyleSheet("QTextBrowser{border:none;font-family: 方正黑体_GBK;font-size:14px;}"); + contributorEdit->setStyleSheet("QTextEdit{border:none;font-family: 方正黑体_GBK;font-size:14px;}"); + okBtn = new QPushButton(this); + okBtn->setGeometry(QRect(334, 295, 90, 25)); + okBtn->setObjectName("blackButton"); + okBtn->setFocusPolicy(Qt::NoFocus); + okBtn->setText(tr("Close")); + this->initAnimation(); + this->initConnect(); +} + +AboutDialog::~AboutDialog() +{ + if(aboutGroup != NULL) + { + delete aboutGroup; + aboutGroup = NULL; + } + if(contributorGroup != NULL) + { + delete contributorGroup; + contributorGroup = NULL; + } +} + +void AboutDialog::initAnimation() +{ + QRect mainAcitonRect(10, 75, 60, 2); + QRect origAcitonRect(75, 75, 60, 2); + + QPropertyAnimation *aboutAnimation = new QPropertyAnimation(indicator, "geometry"); + aboutAnimation->setDuration(300); + aboutAnimation->setStartValue(origAcitonRect); + aboutAnimation->setEndValue(mainAcitonRect); + + aboutGroup = new QParallelAnimationGroup(this); + aboutGroup->addAnimation(aboutAnimation); + + QPropertyAnimation *contributorAnimation = new QPropertyAnimation(indicator, "geometry"); + contributorAnimation->setDuration(300); + contributorAnimation->setStartValue(mainAcitonRect); + contributorAnimation->setEndValue(origAcitonRect); + + contributorGroup = new QParallelAnimationGroup(this); + contributorGroup->addAnimation(contributorAnimation); +} + +void AboutDialog::initConnect() +{ + connect(aboutBtn, SIGNAL(clicked()), this, SLOT(onAboutBtnClicked())); + connect(contributorBtn, SIGNAL(clicked()), this, SLOT(onContributorBtnClicked())); + connect(close_btn, SIGNAL(clicked()), this, SLOT(onCloseBtnClicked())); + connect(okBtn, SIGNAL(clicked()), this, SLOT(onCloseBtnClicked())); +// connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseBtnClicked())); +// connect(linkLabel,SIGNAL(linkActivated(QString)),this,SLOT(openUrl(QString))); +} + +void AboutDialog::onAboutBtnClicked() +{ + aboutGroup->start(); + aboutEdit->show(); +// aboutIndicator->show(); + contributorEdit->hide(); +// contributorIndicator->hide(); +} + +void AboutDialog::onContributorBtnClicked() +{ + contributorGroup->start(); + contributorEdit->show(); +// contributorIndicator->show(); + aboutEdit->hide(); +// aboutIndicator->hide(); +} + +void AboutDialog::resetTitleSkin(QString skin) +{ +// title_bar->resetBackground(skin); + QPalette palette; + palette.setBrush(QPalette::Background, QBrush(QPixmap(skin))); + baseWidget->setPalette(palette); +} + +void AboutDialog::onCloseBtnClicked() +{ + this->close(); +} + +void AboutDialog::openUrl(QString url) +{ + QDesktopServices::openUrl(QUrl(url)); +} + +void AboutDialog::mousePressEvent(QMouseEvent *event) +{ + if(event->button() == Qt::LeftButton) + { + mouse_press = true; + drag_pos = event->globalPos() - this->frameGeometry().topLeft(); + event->accept(); + } +} + +void AboutDialog::mouseReleaseEvent(QMouseEvent *) +{ + mouse_press = false; +} + +void AboutDialog::mouseMoveEvent(QMouseEvent *event) +{ + if(mouse_press) + { + QPoint move_pos = event->globalPos(); + move(move_pos - drag_pos); + event->accept(); + } +} diff --git a/mainui/aboutdialog.h b/mainui/aboutdialog.h new file mode 100644 index 0000000..f14b132 --- /dev/null +++ b/mainui/aboutdialog.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include +#include "../component/kylintitlebar.h" +#include +#include +#include "../component/systembutton.h" + +class QParallelAnimationGroup; + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = 0, /*const QString &version="", */QString skin = ":/background/res/skin/1.png", QString arch = "", QString os = ""); + ~AboutDialog(); + void initConnect(); + void resetTitleSkin(QString skin); + void initAnimation(); + +public slots: + void onCloseBtnClicked(); + void openUrl(QString url); + void onAboutBtnClicked(); + void onContributorBtnClicked(); + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + +private: +// KylinTitleBar *title_bar; + QPoint drag_pos; //移动的距离 + bool mouse_press; //按下鼠标左键 + QWidget *baseWidget; + SystemButton *close_btn; + QPushButton *aboutBtn; + QPushButton *contributorBtn; + QLabel *indicator; +// QLabel *aboutIndicator; +// QLabel *contributorIndicator; +// QTextEdit *aboutEdit; + QTextBrowser *aboutEdit; + QTextEdit *contributorEdit; + QLabel *iconLabel; + QLabel *nameLabel; + QPushButton *okBtn; +// QLabel *versionLabel; +// QLabel *linkLabel; + QParallelAnimationGroup *aboutGroup; + QParallelAnimationGroup *contributorGroup; +}; + +#endif // ABOUTDIALOG_H diff --git a/mainui/aboutdialog.ui b/mainui/aboutdialog.ui new file mode 100644 index 0000000..5043a6c --- /dev/null +++ b/mainui/aboutdialog.ui @@ -0,0 +1,209 @@ + + + AboutDialog + + + + 0 + 0 + 400 + 320 + + + + + 400 + 320 + + + + + 400 + 320 + + + + About + + + + + 2 + 0 + 396 + 271 + + + + 1 + + + + About + + + + + 10 + 1 + 64 + 64 + + + + + + + :/res/youker-assistant.png + + + + + + 77 + 17 + 241 + 20 + + + + Youker Assistant + + + Qt::AlignCenter + + + + + + 292 + 42 + 101 + 17 + + + + + + + Qt::AlignCenter + + + + + + 18 + 76 + 361 + 151 + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:11pt;"> Youker Assistant is a powerful system supporting software which is developed by Ubuntu Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information , system customization, task manager, monitoring ball, and some other functions. </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:11pt;"> The software is still under development. Please visit www.ubuntukylin.com for more information. Welcome everyone to join with us. youker-assistant Homepage: https://launchpad.net/youker-assistant.</span></p></body></html> + + + + + + Contributor + + + + + 18 + 76 + 361 + 151 + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt;">Maintainer</span><span style=" font-family:'Droid Sans Fallback'; font-size:11pt;">:</span></p> +<p style=" margin-top:11px; margin-bottom:11px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt;">Ubuntu Kylin Team &lt;ubuntukylin-members@list.launchpad.net&gt;</span></p></body></html> + + + + + + 10 + 1 + 64 + 64 + + + + + + + :/res/youker-assistant.png + + + + + + 77 + 17 + 241 + 20 + + + + Youker Assistant + + + Qt::AlignCenter + + + + + + 292 + 42 + 101 + 17 + + + + <a href=https://launchpad.net/youker-assistant>home page</a> + + + Qt::AlignCenter + + + + + + + + 291 + 281 + 81 + 30 + + + + Close + + + + + + + + + + diff --git a/mainui/actionwidget.cpp b/mainui/actionwidget.cpp new file mode 100644 index 0000000..2d948d3 --- /dev/null +++ b/mainui/actionwidget.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "actionwidget.h" + +ActionWidget::ActionWidget(QWidget *parent) + : QWidget(parent) +{ + this->setFixedSize(900, 227); +// this->setGeometry(0, 0, 900, 227); + this->setAutoFillBackground(true); +} + +ActionWidget::~ActionWidget() +{ + +} diff --git a/mainui/actionwidget.h b/mainui/actionwidget.h new file mode 100644 index 0000000..d3573fc --- /dev/null +++ b/mainui/actionwidget.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef ACTIONWIDGET_H +#define ACTIONWIDGET_H + +#include + +class ActionWidget : public QWidget +{ + Q_OBJECT +public: + explicit ActionWidget(QWidget *parent = 0); + ~ActionWidget(); +}; + +#endif // ACTIONWIDGET_H diff --git a/mainui/autostart.cpp b/mainui/autostart.cpp new file mode 100644 index 0000000..b527148 --- /dev/null +++ b/mainui/autostart.cpp @@ -0,0 +1,152 @@ +#include "autostart.h" +#include "../component/kylinlistwidgetitem.h" +//#include "mainwindow.h" +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" +#include "../component/utils.h" + + +AutoStart::AutoStart(QWidget *parent, SessionDispatcher *proxy) + :QDialog(parent), + sessionproxy(proxy) +{ + this->setFixedSize(750, 300); + setWindowFlags(Qt::FramelessWindowHint); + title_bar = NULL; + + scroll_widget = new TestScrollWidget(this); + scroll_widget->setGeometry(0, 0, 750, 300); + + this->setLanguage(); + this->initConnect(); +} + +AutoStart::~AutoStart() +{ +} + +void AutoStart::initData() +{ + sessionproxy->getAutoStartAppStatus(); +} + + +void AutoStart::readyReciveData(const QStringList &data) +{ + data_list.append(data); +} + +void AutoStart::readyShowUI() +{ + QVBoxLayout *v_layout = new QVBoxLayout(); + QSignalMapper *signal_mapper = new QSignalMapper(this); + for(int i =0; i tmpMap; + QStringList tmp_list = data_list.at(i); + for(int j=0;jzone); + auto_group->initData(tmpMap); +// qDebug() << tmpMap; + scroll_widget->addScrollWidget(auto_group); + +// AutoGroup *auto_group = new AutoGroup(); +// auto_group->initData(tmpMap); + connect(auto_group, SIGNAL(autoStatusChange()), signal_mapper, SLOT(map())); + signal_mapper->setMapping(auto_group, tmpMap.value("Path")); + v_layout->addWidget(auto_group, 0, Qt::AlignBottom); + } + connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(setCurrentItemAutoStatus(QString))); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addWidget(title_bar); + layout->addLayout(v_layout); +// layout->addWidget(scroll_widget); + layout->setSpacing(0); + layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); + setLayout(layout); +} + +//void AutoStart::readyShowUI() +//{ +//// qDebug() << data_list.length(); +// QVBoxLayout *v_layout = new QVBoxLayout(); +// QSignalMapper *signal_mapper = new QSignalMapper(this); +// for(int i =0; i tmpMap; +// QStringList tmp_list = data_list.at(i); +// for(int j=0;jinitData(tmpMap); +//// auto_list.append(auto_group); +// connect(auto_group, SIGNAL(autoStatusChange()), signal_mapper, SLOT(map())); +//// signal_mapper->setMapping(auto_group, QString::number(i, 10)); +//// signal_mapper->setMapping(auto_group, auto_group->name_label->text()); +// signal_mapper->setMapping(auto_group, tmpMap.value("Path")); +// v_layout->addWidget(auto_group, 0, Qt::AlignBottom); +// } +// connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(setCurrentItemAutoStatus(QString))); + +// QVBoxLayout *layout = new QVBoxLayout(); +// layout->addWidget(title_bar); +// layout->addLayout(v_layout); +//// layout->addWidget(list_widget); +// layout->setSpacing(0); +// layout->setMargin(0); +// layout->setContentsMargins(0, 0, 0, 0); +// setLayout(layout); +//// panel->setLayout(layout); +//// scrollArea->show(); +//// QHBoxLayout *main_layout = new QHBoxLayout(); +//// main_layout->addWidget(scrollArea); +//// setLayout(main_layout); +//} + +void AutoStart::setCurrentItemAutoStatus(QString dekstopName) +{ + int start_pos = dekstopName.lastIndexOf("/") + 1; + int end_pos = dekstopName.length(); + QString name = dekstopName.mid(start_pos, end_pos-start_pos); + qDebug() << "change status->" << name; + sessionproxy->changeAutoStartAppStatus(name); +} + +void AutoStart::setLanguage() +{ + +} + +void AutoStart::initConnect() +{ + connect(title_bar, SIGNAL(showMinDialog()), this, SLOT(onMinButtonClicked())); + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); +} + +void AutoStart::onCloseButtonClicked() +{ + this->close(); +} + +void AutoStart::onMinButtonClicked() +{ + this->hide(); +} + +void AutoStart::initTitleBar() +{ + title_bar->setTitleWidth(500); + title_bar->setTitleName(tr("Boot Manager")); + title_bar->setTitleBackgound(":/background/res/skin/1.png"); +} diff --git a/mainui/autostart.h b/mainui/autostart.h new file mode 100644 index 0000000..6431fbb --- /dev/null +++ b/mainui/autostart.h @@ -0,0 +1,52 @@ +#ifndef AUTOSTART_H +#define AUTOSTART_H + +#include + +#include "../component/kylinlistwidget.h" +#include "../component/kylintitlebar.h" +#include "../component/autogroup.h" +//class KylinTitleBar; +//#include +//#include "../component/kylinscrollarea.h" + +#include "../component/testscrollwidget.h" + +class MainWindow; +class SessionDispatcher; +class AutoStart :public QDialog +{ + Q_OBJECT +public: + AutoStart(QWidget *parent = 0, SessionDispatcher *proxy = 0); + ~AutoStart(); +// void setParentWindow(MainWindow *From) { mainwindow = From;} + void setLanguage(); + void initConnect(); + void initData(); + +public slots: + void onCloseButtonClicked(); + void onMinButtonClicked(); + void setCurrentItemAutoStatus(QString dekstopName); + void readyReciveData(const QStringList &data); + void readyShowUI(); + +private: + void initTitleBar(); + +private: + SessionDispatcher *sessionproxy; +// MainWindow *mainwindow; + KylinTitleBar *title_bar; +// QWidget *bottom_widget; +// KylinListWidget *list_widget; +// QList auto_list; + QList data_list; +// QScrollArea *scrollArea; +// QWidget *panel; +// KylinScrollArea *scroll_widget; + TestScrollWidget *scroll_widget; +}; + +#endif // AUTOSTART_H diff --git a/mainui/autostartwidget.cpp b/mainui/autostartwidget.cpp new file mode 100644 index 0000000..70409db --- /dev/null +++ b/mainui/autostartwidget.cpp @@ -0,0 +1,269 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "autostartwidget.h" +#include "ui_autostartwidget.h" +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" +#include "../component/utils.h" + +//AutoStartWidget::AutoStartWidget(QWidget *parent, SessionDispatcher *proxy) : +// QWidget(parent),sessionproxy(proxy), +AutoStartWidget::AutoStartWidget(QDialog *parent, SessionDispatcher *proxy, QString skin) : + QDialog(parent),sessionproxy(proxy), + ui(new Ui::AutoStartWidget) +{ + ui->setupUi(this); + this->setFixedSize(560, 398); + setWindowFlags(Qt::FramelessWindowHint); + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + this->setWindowTitle(tr("Boot Manager")); + tip_label = new QLabel(); + num_label = new QLabel(); + on_label = new QLabel(); + on_num_label = new QLabel(); + off_label = new QLabel(); + off_num_label = new QLabel(); + name_label = new QLabel(); + status_label = new QLabel(); + + ui->widget_1->setAutoFillBackground(true); + ui->widget_2->setAutoFillBackground(true); + QPalette palette; + palette.setColor(QPalette::Background, QColor(233,238,241));//#e9eef1 + ui->widget_1->setPalette(palette); + palette.setColor(QPalette::Background, QColor(255,255,255));//#ffffff + ui->widget_2->setPalette(palette); + + tip_label->setText(tr("AutoStart Items:")); + name_label->setText(tr("App")); + status_label->setText(tr("Status")); + + on_label->setText(tr("ON Items:")); + off_label->setText(tr("OFF Items:")); + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->addWidget(tip_label); + layout1->addWidget(num_label); + layout1->setSpacing(0); + layout1->setMargin(0); + + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->addWidget(on_label); + layout2->addWidget(on_num_label); + layout2->setSpacing(0); + layout2->setMargin(0); + + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->addWidget(off_label); + layout3->addWidget(off_num_label); + layout3->setSpacing(0); + layout3->setMargin(0); + + QHBoxLayout *tip_layout = new QHBoxLayout(); + tip_layout->addLayout(layout1); + tip_layout->addStretch(); + tip_layout->addLayout(layout2); + tip_layout->addStretch(); + tip_layout->addLayout(layout3); + tip_layout->setSpacing(0); + tip_layout->setMargin(0); + tip_layout->setContentsMargins(10, 0, 10, 1); + ui->widget_1->setLayout(tip_layout); + +// QHBoxLayout *tip_layout = new QHBoxLayout(); +// tip_layout->addWidget(tip_label); +// tip_layout->addWidget(num_label); +// tip_layout->addStretch(); +// tip_layout->setSpacing(0); +// tip_layout->setMargin(0); +// tip_layout->setContentsMargins(20, 0, 0, 0); +// ui->widget_1->setLayout(tip_layout); + + QHBoxLayout *status_layout = new QHBoxLayout(); + status_layout->addWidget(name_label); + status_layout->addStretch(); + status_layout->addWidget(status_label); + status_layout->setSpacing(0); + status_layout->setMargin(0); + status_layout->setContentsMargins(10, 0, 10, 0); + ui->widget_2->setLayout(status_layout); + + title_bar = new KylinTitleBar(this); + title_bar->move(0,0); + title_bar->show(); + initTitleBar(skin); + ui->scrollArea->setStyleSheet("QScrollArea{border: none}"); + ui->scrollArea->setFixedSize(556,300); + ui->scrollArea->setAutoFillBackground(true); + ui->scrollArea->setBackgroundRole(QPalette::Light); + this->initConnect(); +} + +AutoStartWidget::~AutoStartWidget() +{ +// KylinTitleBar *title_bar; + if(tip_label != NULL) { + delete tip_label; + tip_label = NULL; + } + if(num_label != NULL) { + delete num_label; + num_label = NULL; + } + if(on_label != NULL) { + delete on_label; + on_label = NULL; + } + if(on_num_label != NULL) { + delete on_num_label; + on_num_label = NULL; + } + if(off_label != NULL) { + delete off_label; + off_label = NULL; + } + if(off_num_label != NULL) { + delete off_num_label; + off_num_label = NULL; + } + if(name_label != NULL) { + delete name_label; + name_label = NULL; + } + if(status_label != NULL) { + delete status_label; + status_label = NULL; + } + for(int i=0; igetAutoStartAppStatus(); +} + + +void AutoStartWidget::readyReciveData(const QStringList &data) +{ + data_list.append(data); +} + +void AutoStartWidget::readyShowUI() +{ + int rowIndex = 0; + QVBoxLayout *v_layout = new QVBoxLayout(); +// QGridLayout *v_layout = new QGridLayout(); + QSignalMapper *signal_mapper = new QSignalMapper(this); + onNum = offNum = 0; + num_label->setText(QString::number(data_list.length())); + for(int i =0; i tmpMap; + QStringList tmp_list = data_list.at(i); + for(int j=0;jsetFixedHeight(50); + auto_group->initData(tmpMap); + if(tmpMap.value("Status") == "true") + onNum += 1; + else if(tmpMap.value("Status") == "false") + offNum += 1; + connect(auto_group, SIGNAL(autoStatusChange()), signal_mapper, SLOT(map())); + signal_mapper->setMapping(auto_group, tmpMap.value("Path")); + v_layout->addWidget(auto_group, 0, Qt::AlignBottom); +// v_layout->addWidget(auto_group, rowIndex, 0); + rowIndex += 1; + switcher_list.append(auto_group); + } + v_layout->addStretch(); + connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(setCurrentItemAutoStatus(QString))); + on_num_label->setText(QString::number(onNum)); + off_num_label->setText(QString::number(offNum)); + +// QVBoxLayout *layout = new QVBoxLayout(); +// layout->addLayout(v_layout); +// layout->setSpacing(0); +// layout->setMargin(0); +// layout->setContentsMargins(10, 0, 10, 10); + ui->scrollAreaWidgetContents->setLayout(v_layout); +} + +void AutoStartWidget::scanAllSwitcher() { + int count = switcher_list.count(); + onNum = offNum = 0; + for(int i=0; igetSwitcherStatus()) + { + onNum +=1; + } + else { + offNum += 1; + } + } + on_num_label->setText(QString::number(onNum)); + off_num_label->setText(QString::number(offNum)); +} + +void AutoStartWidget::setCurrentItemAutoStatus(QString dekstopName) +{ + int start_pos = dekstopName.lastIndexOf("/") + 1; + int end_pos = dekstopName.length(); + QString name = dekstopName.mid(start_pos, end_pos-start_pos); + sessionproxy->changeAutoStartAppStatus(name); + this->scanAllSwitcher(); +} + +void AutoStartWidget::initConnect() +{ + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); +} + +void AutoStartWidget::initTitleBar(QString skin) +{ + title_bar->setTitleWidth(560); + title_bar->setTitleName(tr("Boot Manager")); +// title_bar->setTitleBackgound(":/background/res/skin/1.png"); + title_bar->setTitleBackgound(skin); +} + +void AutoStartWidget::resetTitleSkin(QString skin) +{ + title_bar->resetBackground(skin); +} + +void AutoStartWidget::onCloseButtonClicked() +{ + this->close(); +} diff --git a/mainui/autostartwidget.h b/mainui/autostartwidget.h new file mode 100644 index 0000000..31622cc --- /dev/null +++ b/mainui/autostartwidget.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AUTOSTARTWIDGET_H +#define AUTOSTARTWIDGET_H + +#include +#include +#include "../component/kylinlistwidget.h" +#include "../component/kylintitlebar.h" +#include "../component/autogroup.h" + +class SessionDispatcher; + +namespace Ui { +class AutoStartWidget; +} + +class AutoStartWidget : public QDialog//QWidget +{ + Q_OBJECT + +public: +// explicit AutoStartWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0); + explicit AutoStartWidget(QDialog *parent = 0, SessionDispatcher *proxy = 0, QString skin = ":/background/res/skin/1.png"); + ~AutoStartWidget(); + void initConnect(); + void initData(); + void scanAllSwitcher(); + void resetTitleSkin(QString skin); + +public slots: + void onCloseButtonClicked(); +// void onMinButtonClicked(); + void setCurrentItemAutoStatus(QString dekstopName); + void readyReciveData(const QStringList &data); + void readyShowUI(); + +private: + void initTitleBar(QString skin); + +private: + Ui::AutoStartWidget *ui; + SessionDispatcher *sessionproxy; + QList data_list; + QList switcher_list; + KylinTitleBar *title_bar; + QLabel *tip_label; + QLabel *num_label; + QLabel *on_label; + QLabel *on_num_label; + QLabel *off_label; + QLabel *off_num_label; + QLabel *name_label; + QLabel *status_label; + int onNum; + int offNum; +}; + +#endif // AUTOSTARTWIDGET_H diff --git a/mainui/autostartwidget.ui b/mainui/autostartwidget.ui new file mode 100644 index 0000000..df5de02 --- /dev/null +++ b/mainui/autostartwidget.ui @@ -0,0 +1,62 @@ + + + AutoStartWidget + + + + 0 + 0 + 560 + 398 + + + + Dialog + + + + + 0 + 32 + 560 + 33 + + + + + + + 0 + 65 + 560 + 31 + + + + + + + 0 + 96 + 560 + 300 + + + + true + + + + + 0 + 0 + 558 + 298 + + + + + + + + diff --git a/mainui/boxactionwidget.cpp b/mainui/boxactionwidget.cpp new file mode 100644 index 0000000..66fe89c --- /dev/null +++ b/mainui/boxactionwidget.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "boxactionwidget.h" +#include "mainwindow.h" +#include + +BoxActionWidget::BoxActionWidget(QWidget *parent) + : QWidget(parent) +{ + this->setFixedSize(900, 150); + this->setAutoFillBackground(true); + this->setObjectName("transparentWidget"); + + img_label = new QLabel(); + title_label = new QLabel(); + more_btn = new QPushButton(); + + img_label->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小 + QPixmap label_pixmap("://res/toolkits.png"); + img_label->setPixmap(label_pixmap); + img_label->setFixedSize(label_pixmap.size()); + title_label->setObjectName("whiteLabel"); + title_label->setWordWrap(true);//QLabel自动换行 + more_btn->setFocusPolicy(Qt::NoFocus); +// more_btn->setObjectName("transparentButton"); + more_btn->setObjectName("whiteButton"); + more_btn->hide(); +// title_label->setFixedWidth(400); + title_label->setMinimumWidth(500); + title_label->setMaximumWidth(600); + + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->addWidget(img_label); + layout1->addWidget(title_label); + layout1->addWidget(more_btn); + layout1->addStretch(); + layout1->setSpacing(15); + layout1->setContentsMargins(20, 20, 0, 0); + setLayout(layout1); + + this->setLanguage(); +} + +BoxActionWidget::~BoxActionWidget() +{ + if(img_label != NULL) { + delete img_label; + img_label = NULL; + } + if(title_label != NULL) { + delete title_label; + title_label = NULL; + } + if(more_btn != NULL) { + delete more_btn; + more_btn = NULL; + } +} + + +void BoxActionWidget::setLanguage() +{ + title_label->setText(tr("Provide a practical and lightweight tool, create fast and convenient experience for you"));//提供轻巧实用工具,为您打造快捷方便的体验 + more_btn->setText(tr("More App")); +} diff --git a/mainui/boxactionwidget.h b/mainui/boxactionwidget.h new file mode 100644 index 0000000..20f6803 --- /dev/null +++ b/mainui/boxactionwidget.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BOXACTIONWIDGET_H +#define BOXACTIONWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include "../component/kylinbutton.h" +#include "../component/systembutton.h" + +class MainWindow; + +class BoxActionWidget : public QWidget +{ + Q_OBJECT +public: + explicit BoxActionWidget(QWidget *parent = 0); + ~BoxActionWidget(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void setLanguage(); + +private: + QLabel *img_label; + QLabel *title_label; + QPushButton *more_btn; + MainWindow *p_mainwindow; +}; + +#endif // BOXACTIONWIDGET_H diff --git a/mainui/boxwidget.cpp b/mainui/boxwidget.cpp new file mode 100644 index 0000000..b63abb4 --- /dev/null +++ b/mainui/boxwidget.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "boxwidget.h" +#include +#include "../component/plugininterface.h" +#include "pluginmanager.h" +#include +#include "../dbusproxy/youkersessiondbus.h" + +BoxWidget::BoxWidget(QWidget *parent, QString arch, QString os, QString path) : + QWidget(parent), osarch(arch), osname(os), plugin_path(path) +{ + this->setFixedSize(900, 403); + this->setStyleSheet("QWidget{border: none;}"); + //set white background color + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + list_view = new QListView(this); +// list_view = new KylinListView(this); + list_view->setFocusPolicy(Qt::NoFocus); + list_view->setAutoFillBackground(true); + list_view->setIconSize(QSize(48, 48)); + list_view->setResizeMode(QListView::Adjust); + list_view->setModel(&pluginModel); + list_view->setViewMode(QListView::IconMode); +// list_view->setMovement(QListView::Static); + list_view->setSpacing(26); +// list_view->setLineWidth(110); + + this->loadPlugins(); + this->initPluginWidget(); + connect(list_view,SIGNAL(clicked(const QModelIndex&)),this,SLOT(OnClickListView(const QModelIndex &))); + + +// stacked_widget = new QStackedWidget(this);//stacked_widget will delete when InfoWidget delete +// stacked_widget->setFocusPolicy(Qt::NoFocus); +// stacked_widget->setAutoFillBackground(true); +// stacked_widget->addWidget(list_view); +// stacked_widget->addWidget(test_widget); + + QGridLayout *layout = new QGridLayout(); + layout->addWidget(list_view,0,0); + layout->setSpacing(0); + layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); + setLayout(layout); +} + +BoxWidget::~BoxWidget() +{ +} + +void BoxWidget::displayBoxHomePage() { +// stacked_widget->setCurrentIndex(0); +} + +void BoxWidget::displayBoxSubPage(QString plugin_id) { +// QObject *object = QObject::sender(); +// QPushButton *btn = qobject_cast(object); +// QString object_name = btn->statusTip(); +// if (object_name == "theme") { +// stacked_widget->setCurrentIndex(1); +// } +} + +void BoxWidget::loadPlugins() +{ + PluginManager::Instance()->loadPlugin(plugin_path); +} + +void BoxWidget::initPluginWidget() +{ + QStringList title; + title << tr(""); + pluginModel.setTitle(title); +// pluginModel.insertRows(0,1,QModelIndex()); +// QModelIndex qindex = pluginModel.index(0,0,QModelIndex()); +// pluginModel.setData(qindex,tr(" ")); + pluginModel.insertRows(0,1,QModelIndex()); + QModelIndex qindex = pluginModel.index(0,0,QModelIndex()); + +// if(this->osarch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin") { +// //set text +// pluginModel.setData(qindex, tr("Kylin Software Center")); +// //set tooltip +// pluginModel.setData(qindex, tr("Kylin Software Center"),Qt::WhatsThisRole); +// } +// else { +// //set text +// pluginModel.setData(qindex, tr("UbuntuKylin Software Center")); +// //set tooltip +// pluginModel.setData(qindex, tr("UbuntuKylin Software Center"),Qt::WhatsThisRole); +// } + + //set text + pluginModel.setData(qindex, tr("Kylin Software Center")); + //set tooltip + pluginModel.setData(qindex, tr("Kylin Software Center"),Qt::WhatsThisRole); + + //set icon + pluginModel.setData(qindex,QIcon(QPixmap("://res/ubuntukylin-software-center.png")),Qt::DecorationRole); + + QStringList icon_list; + //icon_list<<"://res/boot"<<"://res/camera"; + icon_list<<"://res/boot"; + QStringList text_list; + //text_list << tr("Boot Manager") << tr("Camera"); + text_list << tr("Boot Manager"); + for (int index = 0;index < 1;++index) + { + pluginModel.insertRows(index + 1,1,QModelIndex()); + qindex = pluginModel.index(index + 1,0,QModelIndex()); + pluginModel.setData(qindex, text_list.at(index)); + //set icon + pluginModel.setData(qindex,QIcon(QPixmap(icon_list.at(index))),Qt::DecorationRole); + //set tooltip + pluginModel.setData(qindex, text_list.at(index),Qt::WhatsThisRole); + } + + int count = PluginManager::Instance()->count(); + for (int i = 0;i < count;++i) + { + PluginInterface* ICommon = PluginManager::Instance()->getInterfaceByindex(i); + QString picture = ICommon->getPicture(); + QString pacture_path = QString(":/model/res/plugin/%1").arg(picture); + pluginModel.setGuid(ICommon->getGuid()); +// pluginModel.insertRows(i + 1,1,QModelIndex()); +// qindex = pluginModel.index(i + 1,0,QModelIndex()); + pluginModel.insertRows(i + 2,1,QModelIndex()); + qindex = pluginModel.index(i + 2,0,QModelIndex()); + pluginModel.setData(qindex,ICommon->getName()); + pluginModel.setData(qindex,QIcon(QPixmap(pacture_path)),Qt::DecorationRole); + pluginModel.setData(qindex,ICommon->getName(),Qt::WhatsThisRole); + } +} + +void BoxWidget::OnClickListView(const QModelIndex & index) +{ + if(index.row() == 0) + { + if(this->osarch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin") + sessionProxy->runApp("kylin-software-center"); + else + sessionProxy->runApp("ubuntu-kylin-software-center"); + } + else if(index.row() == 1) { + emit this->sendSubIndex(0); + } + else if(index.row() == -1) { + if(this->osarch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin") + sessionProxy->runApp("cheese"); + else + emit this->sendSubIndex(1); + } + else + { +// QString guid = pluginModel.getGuid(index.row() - 1); + QString guid = pluginModel.getGuid(index.row() - 2); + PluginInterface* interface = PluginManager::Instance()->getInterfaceByGuid(guid); + interface->doAction(); + } +} diff --git a/mainui/boxwidget.h b/mainui/boxwidget.h new file mode 100644 index 0000000..62f49fe --- /dev/null +++ b/mainui/boxwidget.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BOXWIDGET_H +#define BOXWIDGET_H + +#include +#include +#include +#include +#include +#include "../component/kylinlistmodel.h" +//#include "../component/kylinlistview.h" + +class SessionDispatcher; + +class BoxWidget : public QWidget +{ + Q_OBJECT +public: + explicit BoxWidget(QWidget *parent = 0, QString arch = "", QString os = "", QString path = ""); + ~BoxWidget(); + void loadPlugins(); + void initPluginWidget(); + void setSessionDbusProxy(SessionDispatcher *dispatcher) { sessionProxy = dispatcher;} + +signals: + void sendSubIndex(int index); + +public slots: + void OnClickListView(const QModelIndex & index); + void displayBoxHomePage(); + void displayBoxSubPage(QString plugin_id); + +private: + QListView *list_view; +// KylinListView *list_view; + KylinListModel pluginModel; + QString osname; + QString osarch; + QString plugin_path; + SessionDispatcher *sessionProxy; +}; + +#endif // BOXWIDGET_H diff --git a/mainui/cameramanager-org.cpp b/mainui/cameramanager-org.cpp new file mode 100644 index 0000000..830a67f --- /dev/null +++ b/mainui/cameramanager-org.cpp @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +//#include "cameramanager.h" +#include "mainwindow.h" +#include +#include +#include "../dbusproxy/youkersessiondbus.h" + +CameraManager::CameraManager(QWidget *parent, SessionDispatcher *proxy, QString skin) +:QDialog(parent),sessionproxy(proxy) +{ + this->setStyleSheet("QDialog{border: 1px solid gray;border-radius:2px}"); + this->setFixedSize(500, 271); + this->setWindowFlags(Qt::FramelessWindowHint); + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + title_bar = new KylinTitleBar(); + initTitleBar(skin); + msg_label = new QLabel(); + msg_label->setWordWrap(true);//QLabel自动换行 + msg_label->setFixedWidth(480); + + palette.setColor(QPalette::WindowText,Qt::red); + msg_label->setPalette(palette); + + msg_label->hide(); + tip_label = new QLabel(); + tip_label->setWordWrap(true);//QLabel自动换行 + tip_label->setFixedWidth(480); + description_label = new QLabel(); + description_label->setWordWrap(true);//QLabel自动换行 + description_label->setFixedWidth(480); + + okBtn = new QPushButton(); + viewBtn = new QPushButton(); + okBtn->setFixedSize(91, 25); + okBtn->setObjectName("blackButton"); + okBtn->setFocusPolicy(Qt::NoFocus); + viewBtn->setFixedSize(91, 25); + viewBtn->setObjectName("blackButton"); + viewBtn->setFocusPolicy(Qt::NoFocus); + + QHBoxLayout *h_layout = new QHBoxLayout(); + h_layout->addStretch(); + h_layout->addWidget(okBtn); + h_layout->addWidget(viewBtn); + h_layout->addStretch(); + h_layout->setSpacing(50); + h_layout->setMargin(0); + h_layout->setContentsMargins(0,0,0,0); + + QVBoxLayout *v_layout = new QVBoxLayout(); + v_layout->addWidget(msg_label); + v_layout->addWidget(tip_label); + v_layout->addWidget(description_label); + v_layout->addLayout(h_layout); + v_layout->setSpacing(30); + v_layout->setMargin(0); + v_layout->setContentsMargins(10, 40, 10, 0); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(title_bar); + main_layout->addLayout(v_layout); + main_layout->addStretch(); + main_layout->setSpacing(0); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + setLayout(main_layout); + this->setLanguage(); + this->initConnect(); +} + +CameraManager::~CameraManager() +{ + if(title_bar != NULL) { + delete title_bar; + title_bar = NULL; + } + if(msg_label != NULL) { + delete msg_label; + msg_label = NULL; + } + if(tip_label != NULL) { + delete tip_label; + tip_label = NULL; + } + if(description_label != NULL) { + delete description_label; + description_label = NULL; + } + if(okBtn != NULL) { + delete okBtn; + okBtn = NULL; + } + if(viewBtn != NULL) { + delete viewBtn; + viewBtn = NULL; + } +} + +void CameraManager::setLanguage() +{ + msg_label->setText(tr("NO found camara")); + tip_label->setText(tr("An application to take pictures with the device camera.")); + description_label->setText(tr("Press the [ESC] button to take picture and turn the camera off , the photo saved in home directory by default.")); + okBtn->setText(tr("Open camera")); + viewBtn->setText(tr("View Photos")); +} + +void CameraManager::setOKButtonEnable(bool enable) +{ + if(enable) + { + msg_label->hide(); + okBtn->setEnabled(true); + } + else + { + msg_label->show(); + okBtn->setEnabled(false); + } +} + +void CameraManager::onOKButtonClicked() +{ + sessionproxy->call_camera_qt(); +} + +void CameraManager::onViewButtonClicked() +{ + sessionproxy->open_folder_qt(sessionproxy->getHomePath()); +} + +void CameraManager::initConnect() +{ + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); + connect(okBtn,SIGNAL(clicked()), this, SLOT(onOKButtonClicked())); + connect(viewBtn,SIGNAL(clicked()), this, SLOT(onViewButtonClicked())); +} + +void CameraManager::onCloseButtonClicked() +{ + this->close(); +} + +void CameraManager::initTitleBar(QString skin) +{ + title_bar->setTitleWidth(500); + title_bar->setTitleName(tr("Camera Manager")); +// title_bar->setTitleBackgound(":/background/res/skin/1.png"); + title_bar->setTitleBackgound(skin); +} + +void CameraManager::resetTitleSkin(QString skin) +{ + title_bar->resetBackground(skin); +} diff --git a/mainui/cameramanager-org.h b/mainui/cameramanager-org.h new file mode 100644 index 0000000..40752d3 --- /dev/null +++ b/mainui/cameramanager-org.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CAMERAMANAGER_H +#define CAMERAMANAGER_H + +#include + +#include "../component/kylinlistwidget.h" +#include "../component/kylintitlebar.h" + +class SessionDispatcher; +class MainWindow; +class CameraManager :public QDialog +{ + Q_OBJECT +public: + CameraManager(QWidget *parent = 0, SessionDispatcher *proxy = 0, QString skin = ":/background/res/skin/1.png"); + ~CameraManager(); + void setParentWindow(MainWindow *From) { mainwindow = From;} +// void initBackgroundList(); + void setLanguage(); + void initConnect(); + void setOKButtonEnable(bool enable); + void resetTitleSkin(QString skin); + +public slots: + void onCloseButtonClicked(); + void onOKButtonClicked(); + void onViewButtonClicked(); + +private: + void initTitleBar(QString skin); + +private: + MainWindow *mainwindow; + SessionDispatcher *sessionproxy; + KylinTitleBar *title_bar; + QLabel *msg_label; + QLabel *tip_label; + QLabel *description_label; + QPushButton *okBtn; + QPushButton *viewBtn; +}; + +#endif // CAMERAMANAGER_H diff --git a/mainui/cameramanager.cpp b/mainui/cameramanager.cpp new file mode 100644 index 0000000..09f835a --- /dev/null +++ b/mainui/cameramanager.cpp @@ -0,0 +1,328 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cameramanager.h" +#include "mainwindow.h" +#include +#include +#include "../dbusproxy/youkersessiondbus.h" +#include "../component/toolbutton.h" + +//#include +#include +#include + +CameraManager::CameraManager(QWidget *parent, SessionDispatcher *proxy, QString skin) +:QDialog(parent),sessionproxy(proxy) +{ + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:2px}"); + this->setFixedSize(622, 480); + this->setWindowFlags(Qt::FramelessWindowHint); + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + timer = NULL; + imag = NULL; + cam = NULL; + frame = NULL; + + title_bar = new KylinTitleBar(this); + initTitleBar(skin); + + camera_label = new QLabel(this); + camera_label->setGeometry(QRect(0,32,622,340)); + camera_label->hide(); + baseWidget = new QWidget(this); + baseWidget->setStyleSheet("QWidget{border: none;background-color: #a6b6c1;}");//background:transparent; + baseWidget->setGeometry(QRect(0,372,622,108)); + catch_label = new QLabel(baseWidget); + catch_label->setStyleSheet("QLabel{border: 1px solid white;}"); + catch_label->setGeometry(QRect(10,11,145,86)); + QImage image("://res/camera-default.png"); + if (!image.isNull()) { + catch_label->setPixmap(QPixmap::fromImage(image).scaled(145, 86, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + } + + disable_icon = new QLabel(baseWidget); + disable_icon->setGeometry(QRect(263,7,93,93)); + disable_icon->setStyleSheet("QLabel{background-image:url(':/res/catch-disable.png')}"); + disable_icon->hide(); + + okBtn = new QPushButton(baseWidget); + okBtn->setGeometry(QRect(263,7,93,93)); + okBtn->hide(); + okBtn->setCursor(Qt::PointingHandCursor); + okBtn->setFocusPolicy(Qt::NoFocus); + okBtn->setIconSize(QSize(93, 93)); + okBtn->setFlat(true); + okBtn->setStyleSheet("QPushButton{background:transparent;background-image:url('://res/catch.png');}QPushButton:hover{background:url('://res/catch-hover.png');}"); + viewBtn = new ToolButton(baseWidget, true); + viewBtn->setFocusPolicy(Qt::NoFocus); + viewBtn->setCursor(Qt::PointingHandCursor); + viewBtn->setIcon("://res/view.png"); + viewBtn->setText(tr("View Photos")); + viewBtn->setGeometry(QRect(500,16,50,60)); + + error_icon = new QLabel(this); + error_icon->setGeometry(QRect(0,32,622,340)); + error_icon->setStyleSheet("QLabel{background-image:url('://res/camera-error.png')}"); + error_label = new QLabel(this); + error_label->setGeometry(QRect(10, 280, 600, 20)); + error_label->setWordWrap(true); + error_label->setStyleSheet("QLabel{color:#90a5b1;font-family: 方正黑体_GBK;font-size: 14px;text-align: center;}"); + error_label->setAlignment(Qt::AlignCenter); + error_label->setText(tr("The camera is out of question, Refresh to call it out ~")); + + this->initCamera(); + this->initConnect(); + +} + +//CameraManager::~CameraManager() +//{ +// if (timer != NULL) { +// disconnect(timer,SIGNAL(timeout()),this,SLOT(readFarme())); +// if(timer->isActive()) +// timer->stop(); +// delete timer; +// timer = NULL; +// } +// if (imag != NULL) { +// delete imag; +// imag = NULL; +// } +// if (cam != NULL) { +// delete cam; +// cam = NULL; +// } +//} + +void CameraManager::initCamera() +{ + timer = new QTimer(this); + imag = new QImage(); + int number = this->countCamaras();//获取摄像头的个数 +// qDebug() << "camara number:" << number; +// if (cam != NULL) +// return; + if(number < 1) { + this->setOKButtonEnable(false); + return; + } + else { + this->setOKButtonEnable(true); + } + //0表示内置摄像头 1表示外界摄像头 + cam = cvCreateCameraCapture(0);//打开摄像头,从摄像头中获取视频 +// assert(NULL != cam); + if(cam == NULL) { + this->setOKButtonEnable(false); + return; + } + cvSetCaptureProperty(cam, CV_CAP_PROP_FPS, 30);//帧率(只对摄像头有效) + //default :640*480 +// cvSetCaptureProperty(cam, CV_CAP_PROP_FRAME_WIDTH, 1280);//视频流的帧宽度(只对摄像头有效) +// cvSetCaptureProperty(cam, CV_CAP_PROP_FRAME_HEIGHT, 720);//视频流的帧高度(只对摄像头有效) + timer->start(33);// 开始计时,超时则发出timeout()信号 +} + +QString CameraManager::getCurrentDateTime() { + QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间 + QString str = time.toString("yyyy-MM-dd hh:mm:ss dddd"); //设置显示格式 + return str; +} + +QString CameraManager::getHomePath() { + QString homepath = QDir::homePath(); + return homepath; +} + +int CameraManager::countCamaras() { + cv::VideoCapture temp_camera; + int maxTested = 10; + for (int i = 0; i < maxTested; i++) { +// try { +// cv::VideoCapture temp_camera(i); +// } +// catch(cv::Exception& e) { +// qDebug() << e.what(); +// } + cv::VideoCapture temp_camera(i); + bool res = (!temp_camera.isOpened()); + temp_camera.release(); + if (res) + { + return i; + } + } + return maxTested; +} + +void CameraManager::setOKButtonEnable(bool enable) +{ + if(enable) + { + error_icon->hide(); + error_label->hide(); + disable_icon->hide(); + camera_label->show(); + okBtn->show(); +// okBtn->setEnabled(true); + } + else + { + camera_label->hide(); +// okBtn->setEnabled(false); + okBtn->hide(); + error_icon->show(); + error_label->show(); + disable_icon->show(); + } +} + +void CameraManager::onOKButtonClicked() +{ + frame = cvQueryFrame(cam); +// QImage image = QImage((const uchar*)frame->imageData, frame->width, frame->height, QImage::Format_RGB888).rgbSwapped(); + QImage image = QImage((const uchar*)frame->imageData, frame->width, frame->height, QImage::Format_RGB888).rgbSwapped(); + catch_label->setPixmap(QPixmap::fromImage(image).scaled(145, 86, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + IplImage* outImage = cvCreateImage(cvGetSize(frame),frame->depth,frame->nChannels); + cvCopy(frame,outImage,NULL); + // outImage = this->DoPyrDown(outImage);//图片缩放 + QString outImageName = this->getHomePath() + "/" + this->getCurrentDateTime() + ".jpg"; + char* ch; + QByteArray ba = outImageName.toUtf8(); + ch=ba.data(); + cvSaveImage(ch,outImage); + cvReleaseImage(&outImage); +} + +void CameraManager::readFarme() +{ + frame = cvQueryFrame(cam); + if(!frame) + return; + QImage image = QImage((const uchar*)frame->imageData, frame->width, frame->height, QImage::Format_RGB888).rgbSwapped(); + camera_label->setPixmap(QPixmap::fromImage(image)); +} + + +// 实现将拍下来的图片缩放一倍 +IplImage* CameraManager::DoPyrDown(IplImage* image, int filter = IPL_GAUSSIAN_5x5) +//IplImage* CameraManager::DoPyrDown(IplImage* image, int filter = CV_GAUSSIAN_5x5) +{ + CvSize size = cvSize(image->width / 2,image->height / 2); + IplImage* outImage = cvCreateImage(size,image->depth,image->nChannels); + cvPyrDown(image,outImage); + cvReleaseImage(&image); + return outImage; +} + +void CameraManager::onViewButtonClicked() +{ +// sessionproxy->open_folder_qt(sessionproxy->getHomePath()); + QDesktopServices::openUrl(QUrl(QString("file:%1").arg(this->getHomePath()), QUrl::TolerantMode)); +} + +void CameraManager::initConnect() +{ + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); + connect(okBtn,SIGNAL(clicked()), this, SLOT(onOKButtonClicked())); + connect(viewBtn, SIGNAL(clicked()), this, SLOT(onViewButtonClicked())); + connect(error_label,SIGNAL(linkActivated(QString)),this,SLOT(refreshCamera())); + connect(timer, SIGNAL(timeout()), this, SLOT(readFarme())); // 时间到,读取当前摄像头信息 +} + +void CameraManager::refreshCamera() +{ + int number = this->countCamaras();//获取摄像头的个数 + if(number < 1) { + this->setOKButtonEnable(false); + return; + } + else { + this->setOKButtonEnable(true); + } + //0表示内置摄像头 1表示外界摄像头 + cam = cvCreateCameraCapture(0);//打开摄像头,从摄像头中获取视频 + if(cam == NULL) { + this->setOKButtonEnable(false); + return; + } + cvSetCaptureProperty(cam, CV_CAP_PROP_FPS, 30);//帧率(只对摄像头有效) + if(timer != NULL) { + if(timer->isActive()) + timer->stop(); + timer->start(33);// 开始计时,超时则发出timeout()信号 + } +} + +void CameraManager::onCloseButtonClicked() +{ + cvReleaseCapture(&cam); + if (timer != NULL) { + disconnect(timer,SIGNAL(timeout()),this,SLOT(readFarme())); + if(timer->isActive()) + timer->stop(); + delete timer; + timer = NULL; + } + if (imag != NULL) { + delete imag; + imag = NULL; + } + if (cam != NULL) { + delete cam; + cam = NULL; + } + this->close(); +} + +void CameraManager::initTitleBar(QString skin) +{ + title_bar->setTitleWidth(622); + title_bar->setTitleName(tr("Camera")); + title_bar->setTitleBackgound(skin); +} + +void CameraManager::resetTitleSkin(QString skin) +{ + title_bar->resetBackground(skin); +} + +//void CameraManager::keyPressEvent(QKeyEvent *k) +//{ +// if (k->key() == Qt::Key_Escape) { +// qDebug() << "prssss. esc....."; +// if (cam != NULL) { +// qDebug() << "cam not null"; +// this->onCloseButtonClicked(); +// } +// else +// qDebug() << "cam null"; +// } +// else if (k->key() == Qt::Key_Enter || k->key() == Qt::Key_Return) +// { +// qDebug() << "prssss. enter....."; +// if (cam != NULL) +// this->onPicButtonClicked(); +// } +//} diff --git a/mainui/cameramanager.h b/mainui/cameramanager.h new file mode 100644 index 0000000..6bffa34 --- /dev/null +++ b/mainui/cameramanager.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CAMERAMANAGER_H +#define CAMERAMANAGER_H +//sudo apt-get install libcv-dev libopencv-highgui-dev libopencv-dev libhighgui-dev +#include +#include "../component/kylintitlebar.h" +#include +#include // 设置采集数据的间隔时间 +#include //包含opencv库头文件 +#include +//#include //1710opencv库 +//#include +//#include +#include +#include +#include +#include +#include + +class SessionDispatcher; +class MainWindow; +class ToolButton; + +class CameraManager :public QDialog +{ + Q_OBJECT +public: + CameraManager(QWidget *parent = 0, SessionDispatcher *proxy = 0, QString skin = ":/background/res/skin/1.png"); +// ~CameraManager(); + void setParentWindow(MainWindow *From) { mainwindow = From;} + void initConnect(); + void setOKButtonEnable(bool enable); + void resetTitleSkin(QString skin); + void initCamera(); + IplImage* DoPyrDown(IplImage* image, int filter); + QString getCurrentDateTime(); + QString getHomePath(); + int countCamaras(); + +public slots: + void readFarme();//读取当前帧信息 + void onCloseButtonClicked(); + void onOKButtonClicked(); + void onViewButtonClicked(); + void refreshCamera(); + +//protected: +// void keyPressEvent( QKeyEvent *k ); + +private: + void initTitleBar(QString skin); + +private: + MainWindow *mainwindow; + SessionDispatcher *sessionproxy; + QTimer *timer; + QImage *imag; + CvCapture *cam;// 视频获取结构, 用来作为视频获取函数的一个参数 + IplImage *frame;//申请IplImage类型指针,就是申请内存空间来存放每一帧图像 + KylinTitleBar *title_bar; + QLabel *camera_label; + QWidget *baseWidget; + QLabel *catch_label; + QLabel *disable_icon; + QPushButton *okBtn; + ToolButton *viewBtn; + QLabel *error_icon; + QLabel *error_label; +}; + +#endif // CAMERAMANAGER_H diff --git a/mainui/cleaneractionwidget.cpp b/mainui/cleaneractionwidget.cpp new file mode 100644 index 0000000..54f6cd9 --- /dev/null +++ b/mainui/cleaneractionwidget.cpp @@ -0,0 +1,393 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleaneractionwidget.h" +#include +#include "../dbusproxy/youkersessiondbus.h" +#include "../dbusproxy/youkersystemdbus.h" + +CleanerActionWidget::CleanerActionWidget(QWidget *parent) + : QWidget(parent) +{ + this->setFixedSize(900, 150); + + this->setAutoFillBackground(true); + this->setObjectName("transparentWidget"); +// cache_page = new CacheActionWidget(this); +// statked_widget = new QStackedWidget(this); +//// QPalette palette; +//// palette.setBrush(QPalette::Window, QBrush(Qt::white)); +//// statked_widget->setPalette(palette); +//// statked_widget->setAutoFillBackground(true); +// statked_widget->addWidget(cache_page); +// QVBoxLayout *layout1 = new QVBoxLayout(); +// layout1->addWidget(statked_widget); +// layout1->setMargin(0); +// layout1->setContentsMargins(0, 0, 0, 0); +// setLayout(layout1); + + suggest_label = new QLabel(); +// result_label = new QLabel(); + doing_label = new QLabel(); + scan_button = new QPushButton(this); + clean_button = new QPushButton(this); + back_button = new QPushButton(this); + back_button->setObjectName("backButton"); + back_button->hide(); + + loading_label = new LoadingLabel(this, "clean"); + loading_label->show(); + + suggest_label->setObjectName("whiteLabel"); + suggest_label->setWordWrap(true);//QLabel自动换行 + suggest_label->setFixedWidth(550); +// result_label->setWordWrap(true);//QLabel自动换行 +// result_label->setObjectName("tipLabel"); + doing_label->setFixedWidth(550); + doing_label->setWordWrap(true);//QLabel自动换行 + doing_label->setObjectName("whiteLabel"); + doing_label->hide(); + +// scan_button->setFixedSize(182, 58); + scan_button->setGeometry(QRect(680, 50, 182, 58)); + scan_button->setFocusPolicy(Qt::NoFocus); + scan_button->setObjectName("greenButton"); + scan_button->show(); +// clean_button->setFixedSize(182, 58); + clean_button->setGeometry(QRect(680, 50, 182, 58)); + clean_button->setFocusPolicy(Qt::NoFocus); + clean_button->setObjectName("greenButton"); + clean_button->hide(); + + back_button->setFocusPolicy(Qt::NoFocus); +// back_button->setFixedSize(50, 30); + back_button->setGeometry(QRect(820, 110, 50, 30)); + back_button->setObjectName("underlineButton"); + back_button->hide(); + + //set underline + // QFont font = back_button->font(); + // font.setUnderline(true); + // back_button->setFont(font); + + //set scan button text color +// QPalette palette; +// palette.setColor(QPalette::ButtonText, QColor(255,17,135)); +// scan_button->setPalette(palette); + + QVBoxLayout *layout1 = new QVBoxLayout(); + layout1->addStretch(); + layout1->addWidget(suggest_label, 0 , Qt::AlignVCenter); +// layout1->addWidget(result_label); + layout1->addWidget(doing_label, 0 , Qt::AlignVCenter); + layout1->addStretch(); + layout1->setSpacing(0); + layout1->setContentsMargins(0, 0, 0, 0); + + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->addWidget(loading_label, 0, Qt::AlignVCenter); + layout2->addLayout(layout1); + layout2->setSpacing(20); + layout2->setMargin(0); + layout2->setContentsMargins(0, 0, 0, 0); + +// QVBoxLayout *layout3 = new QVBoxLayout(); +// layout3->addStretch(); +// layout3->addWidget(scan_button, 0, Qt::AlignRight); +// layout3->addWidget(clean_button, 0, Qt::AlignRight); +// layout3->addWidget(back_button, 0, Qt::AlignRight); +// layout3->addStretch(); +// layout3->setSpacing(10); +// layout3->setContentsMargins(0, 20, 0, 0); + + + + QHBoxLayout *main_layout = new QHBoxLayout(); + main_layout->addLayout(layout2); + main_layout->addStretch(); +// main_layout->addLayout(layout3); + main_layout->setSpacing(0); + main_layout->setMargin(0); + main_layout->setContentsMargins(13, 20, 44, 0); + + setLayout(main_layout); + + this->initConnect(); + this->setLanguage(); +} + +CleanerActionWidget::~CleanerActionWidget() +{ + if(suggest_label != NULL) { + delete suggest_label; + suggest_label = NULL; + } + if(doing_label != NULL) { + delete doing_label; + doing_label = NULL; + } +} + +void CleanerActionWidget::initConnect() +{ + connect(scan_button, SIGNAL(clicked()), this, SLOT(onStartButtonClicked())); + connect(clean_button, SIGNAL(clicked()), this, SLOT(onCleanButtonClicked())); + connect(back_button, SIGNAL(clicked()), this, SLOT(onBackButtonClicked())); +} + +void CleanerActionWidget::setLanguage() +{ + suggest_label->setText(tr("Regular cleaning, let your computer remains the relaxed state"));//经常清理,让电脑保持最轻松的状态 +// result_label->setText(tr("上次检测时间为2014-07-07 16:40:35 星期一,清理了4.84KB垃圾。")); + scan_button->setText(tr("Start Scan"));//开始扫描 + clean_button->setText(tr("Start Cleanup"));//开始清理 + back_button->setText(tr("Back")); + doing_label->setText(tr("Scaning......"));//正在扫描...... +} + +void CleanerActionWidget::showCleanOverStatus() +{ + loading_label->stopLoading(); + scan_button->show(); + scan_button->setEnabled(true); + clean_button->hide(); + clean_button->setEnabled(true); + back_button->hide(); + doing_label->setText(tr("Clean OK")); +} + +void CleanerActionWidget::showCleanerData(const QStringList &data) +{ + if(data.length() == 2) + { + doing_label->setText(tr("Cleaning: ") + data.at(0).split(":").at(1)); + } + else if(data.length() == 3) + { + doing_label->setText(data.at(0).split(":").at(1) + tr(", Percent is: ") + data.at(1).split(":").at(1) + tr("%, Status is: ") + data.at(2).split(":").at(1)); + } +} + +void CleanerActionWidget::showCleanerStatus(const QString &status, const QString &domain) +{ + if(status == "Complete:History.firefox" && domain == "history") + { + doing_label->setText(tr("Clean Firefox history......")); + } + else if(status == "Complete:History.chromium" && domain == "history") + { + doing_label->setText(tr("Clean Chromium history......")); + } + else if(status == "Complete:History.system" && domain == "history") + { + doing_label->setText(tr("Clean system history......")); + } + + else if(status == "Complete:" && domain == "apt") + { + doing_label->setText(tr("Clean apt......")); + } + else if(status == "Start:" && domain == "apt") + { + doing_label->setText(tr("Start clean apt......")); + } + + else if(status == "Complete:Cookies.firefox") + { + doing_label->setText(tr("Clean Firefox Cookie:") + domain); + } + else if(status == "Complete:Cookies.chromium") + { + doing_label->setText(tr("Clean Chromium Cookie:") + domain); + } +} + +void CleanerActionWidget::showCleanerError(const QString &status) +{ + if(status.contains("Non-existent:")) + { + if(status.split(":").at(1).length() > 0) + doing_label->setText(status.split(":").at(1) + tr(" does not exist")); + } + else if(status.contains("Working:Chromium")) + { + doing_label->setText(tr("Chromium Browser is running......")); + } +} + +void CleanerActionWidget::showCleanReciveStatus(const QString &status) +{ + if(status == "Complete:Cache") + { + doing_label->setText(tr("Cache Scan OK")); + } + else if(status == "Complete:Cookies") + { + doing_label->setText(tr("Cookies Scan OK")); + } + else if(status == "Complete:") + { + doing_label->setText(tr("History Scan OK")); + } + else if(status == "Complete:Packages") + { + doing_label->setText(tr("Packages Scan OK")); + } + else if(status == "Complete:All") + { +// doing_label->setText(tr("Scaning......")); +// doing_label->hide(); +// loading_label->stopLoading(); +// scan_button->hide(); +// scan_button->setEnabled(true); +// clean_button->show(); +// clean_button->setEnabled(true); +// suggest_label->show(); +// back_button->show(); + } +} + +void CleanerActionWidget::accordScanOverStatusToChange(bool status) +{ + if (status) { + doing_label->setText(tr("Scaning......")); + doing_label->hide(); + loading_label->stopLoading(); + scan_button->hide(); + scan_button->setEnabled(true); + clean_button->show(); + clean_button->setEnabled(true); + suggest_label->show(); + back_button->show(); + } + else { + doing_label->setText(tr("Scaning......")); + doing_label->hide(); + loading_label->stopLoading(); + scan_button->hide(); + scan_button->setEnabled(true); + clean_button->hide(); + clean_button->setEnabled(true); + suggest_label->show(); + back_button->show(); + } +} + +void CleanerActionWidget::showCleanReciveError(const QString &status) +{ + doing_label->setText(tr("Error: ") + status); + if(status == "Uninstalled:Firefox") + { + doing_label->setText(tr("Firefox Browser does not be installed")); + } + else if(status == "Uninstalled:Chromium") + { + doing_label->setText(tr("Chromium Browser does not be installed")); + } + else if(status == "Working:Chromium") + { + doing_label->setText(tr("Chromium Browser is running")); + } + else + { + if(status.contains("Non-existent:")) + doing_label->setText(status.split(":").at(1) + tr(" does not exist")); + } +} + +void CleanerActionWidget::displayAnimation() +{ + scan_button->setEnabled(false); + loading_label->startLoading(); + suggest_label->hide(); + doing_label->show(); + emit this->showDetailData(); +} + +//void CleanerActionWidget::displayCleanAnimation() +//{ +// clean_button->show(); +// clean_button->setEnabled(false); +// loading_label->startLoading(); +// suggest_label->hide(); +// doing_label->setText(tr("Ready to Cleanup......"));//准备清理...... +// doing_label->show(); +//} + +void CleanerActionWidget::receivePolicyKitSignal(bool status) +{ + /*display Clean Animation + status = true:ok + status = false:cacel + */ + if(status)//ok + { + clean_button->show(); + clean_button->setEnabled(false); + back_button->hide();//0713 + scan_button->hide(); + loading_label->startLoading(); + suggest_label->hide(); + doing_label->setText(tr("Ready to Cleanup......"));//准备清理...... + doing_label->show(); + } + else { + clean_button->show(); + back_button->show(); + } +} + + +void CleanerActionWidget::onStartButtonClicked() +{ + doing_label->setText(tr("Scaning......")); + emit this->sendScanSignal(); +} + +void CleanerActionWidget::onCleanButtonClicked() +{ + clean_button->hide(); + back_button->hide(); + emit this->sendCleanSignal(); +} + +void CleanerActionWidget::displayOrgPage() +{ + doing_label->hide(); + back_button->hide(); +// loading_label->stopLoading(); + scan_button->show(); + scan_button->setEnabled(true); + clean_button->hide(); + suggest_label->show(); +} + +void CleanerActionWidget::onBackButtonClicked() +{ + doing_label->hide(); + back_button->hide(); + loading_label->stopLoading(); + scan_button->show(); + scan_button->setEnabled(true); + clean_button->hide(); +// back_button->hide(); + suggest_label->show(); +// result_label->show(); + emit this->showMainData(); +} diff --git a/mainui/cleaneractionwidget.h b/mainui/cleaneractionwidget.h new file mode 100644 index 0000000..6cd08ec --- /dev/null +++ b/mainui/cleaneractionwidget.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERACTIONWIDGET_H +#define CLEANERACTIONWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include "../component/kylinbutton.h" +#include "../component/systembutton.h" +#include "../component/loadinglabel.h" + +class SessionDispatcher; +class SystemDispatcher; + +class CleanerActionWidget : public QWidget +{ + Q_OBJECT +public: + explicit CleanerActionWidget(QWidget *parent = 0); + ~CleanerActionWidget(); + void setSessionDbusProxy(SessionDispatcher* dispatcher) { sessionProxy = dispatcher;} + void setSystemDbusProxy(SystemDispatcher* dispatcher) { systemProxy = dispatcher;} + void initConnect(); + void setLanguage(); + +public slots: + void onStartButtonClicked(); + void onCleanButtonClicked(); + void onBackButtonClicked(); + void showCleanReciveStatus(const QString &status); + void showCleanReciveError(const QString &status); + void showCleanOverStatus(); + void showCleanerData(const QStringList &data); + void showCleanerStatus(const QString &status, const QString &domain); + void showCleanerError(const QString &status); + void displayOrgPage(); + void displayAnimation(); +// void displayCleanAnimation(); + void receivePolicyKitSignal(bool status); + void accordScanOverStatusToChange(bool status); + +signals: + void showDetailData(); + void showMainData(); + void sendCleanSignal(); + void sendScanSignal(); + +private: + bool is_move; + LoadingLabel *loading_label; + QLabel *suggest_label; + QLabel *doing_label; + QPushButton *scan_button; + QPushButton *clean_button; + QPushButton *back_button; + + SystemDispatcher *systemProxy; + SessionDispatcher *sessionProxy; +}; + +#endif // CLEANERACTIONWIDGET_H diff --git a/mainui/cleanerwidget.cpp b/mainui/cleanerwidget.cpp new file mode 100644 index 0000000..67b2322 --- /dev/null +++ b/mainui/cleanerwidget.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cleanerwidget.h" +#include +#include +#include "../component/utils.h" +#include "../dbusproxy/youkersessiondbus.h" + +CleanerWidget::CleanerWidget(QWidget *parent) : + QWidget(parent) +{ + this->setFixedSize(900, 403); + this->setWindowFlags(Qt::FramelessWindowHint | Qt::Widget); + //set white background color + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + statked_widget = new QStackedWidget(this); + p_mainwindow = NULL; + systemProxy = NULL; + sessionProxy = NULL; + main_widget = NULL; + detail_widget = NULL; +} + +CleanerWidget::~CleanerWidget() +{ + +} + +void CleanerWidget::initUI(QString skin) +{ + main_widget = new CleanerMainWidget(this, sessionProxy, p_mainwindow, toolKits, skin); + detail_widget = new CleanerDetailWidget(this, sessionProxy, systemProxy, p_mainwindow, toolKits ,skin); + connect(this, SIGNAL(transCleanSignal()), detail_widget, SLOT(receiveCleanSignal())); + + connect(this, SIGNAL(transScanSignal()), main_widget, SLOT(receiveScanSignal())); + connect(main_widget, SIGNAL(showActionAnimaiton()), this, SIGNAL(tranActionAnimaitonSignal())); +// connect(detail_widget, SIGNAL(showActionAnimaiton()), this, SIGNAL(tranCleanActionAnimaitonSignal())); + connect(detail_widget, SIGNAL(sendScanOverStatus(bool)), this, SIGNAL(tranScanOverSignal(bool))); + + connect(this, SIGNAL(clearDetailPage()), detail_widget, SLOT(CleanUIAndData())); + connect(sessionProxy, SIGNAL(tellCleanerDetailData(QStringList)), detail_widget, SLOT(showReciveData(QStringList))); + connect(sessionProxy, SIGNAL(tellCleanerDetailStatus(QString)), detail_widget, SLOT(showReciveStatus(QString))); + statked_widget->addWidget(main_widget); + statked_widget->addWidget(detail_widget); + QVBoxLayout *layout1 = new QVBoxLayout(); + layout1->addWidget(statked_widget); + layout1->setSpacing(0); + layout1->setMargin(0); + layout1->setContentsMargins(0, 0, 0, 0); + + setLayout(layout1); +} + +void CleanerWidget::resetSkin(QString skin) +{ + if(main_widget != NULL) + main_widget->resetCurrentSkin(skin); + if(detail_widget != NULL) + detail_widget->resetCurrentSkin(skin); +} + +void CleanerWidget::displayDetailPage() +{ + statked_widget->setCurrentIndex(1); +} + +void CleanerWidget::displayMainPage() +{ + statked_widget->setCurrentIndex(0); + emit this->clearDetailPage(); +} diff --git a/mainui/cleanerwidget.h b/mainui/cleanerwidget.h new file mode 100644 index 0000000..dde051d --- /dev/null +++ b/mainui/cleanerwidget.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CLEANERWIDGET_H +#define CLEANERWIDGET_H + +#include +#include "../cleaner/cleanermainwidget.h" +#include "../cleaner/cleanerdetailwidget.h" +#include + +class SessionDispatcher; +class SystemDispatcher; +class Toolkits; +class MainWindow; + +class CleanerWidget : public QWidget +{ + Q_OBJECT + +public: + explicit CleanerWidget(QWidget *parent = 0); + ~CleanerWidget(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void setSessionDbusProxy(SessionDispatcher* dispatcher) { sessionProxy = dispatcher;} + void setSystemDbusProxy(SystemDispatcher* dispatcher) { systemProxy = dispatcher;} + void setToolKits(Toolkits* kits) { toolKits = kits;} + void initUI(QString skin); + void resetSkin(QString skin); + +public slots: + void displayDetailPage(); + void displayMainPage(); + +signals: + void transCleanSignal(); + void transScanSignal(); + void clearDetailPage(); + void tranActionAnimaitonSignal(); +// void tranCleanActionAnimaitonSignal(); + void tranScanOverSignal(bool status); + +private: + QStackedWidget *statked_widget; + CleanerMainWidget *main_widget; + CleanerDetailWidget *detail_widget; + MainWindow *p_mainwindow; + SystemDispatcher *systemProxy; + SessionDispatcher *sessionProxy; + Toolkits *toolKits; +}; + +#endif // CLEANERWIDGET_H diff --git a/mainui/contentwidget.cpp b/mainui/contentwidget.cpp new file mode 100644 index 0000000..9bd010e --- /dev/null +++ b/mainui/contentwidget.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "contentwidget.h" +#include + +ContentWidget::ContentWidget(QWidget *parent) + : QWidget(parent) +{ +// this->resize(900, 326); + this->setFixedSize(900, 326); +// this->setGeometry(0, 274, 900, 326); + +} + +ContentWidget::~ContentWidget() +{ +} diff --git a/mainui/contentwidget.h b/mainui/contentwidget.h new file mode 100644 index 0000000..76496f1 --- /dev/null +++ b/mainui/contentwidget.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CONTENTWIDGET_H +#define CONTENTWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class ContentWidget : public QWidget +{ + Q_OBJECT + +public: + explicit ContentWidget(QWidget *parent = 0); + ~ContentWidget(); + void setLanguage(); + +private: +protected: + +public slots: + +signals: + +private: + + +}; + +#endif // CONTENTWIDGET_H diff --git a/mainui/homeactionwidget.cpp b/mainui/homeactionwidget.cpp new file mode 100644 index 0000000..c2daf02 --- /dev/null +++ b/mainui/homeactionwidget.cpp @@ -0,0 +1,496 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "homeactionwidget.h" +#include "mainwindow.h" +#include +#include + +HomeActionWidget::HomeActionWidget(QWidget *parent, QSettings *mSettings) + : QWidget(parent), pSettings(mSettings) +{ +// this->resize(900, 227); + this->setFixedSize(900, 227); +// setWindowOpacity(0.6); + is_move = false; + this->setAutoFillBackground(true); + this->setObjectName("transparentWidget"); + scanFinishTime = ""; + + suggest_label = new QLabel(); + scan_result_label = new QLabel(); + result_label = new QLabel(); + doing_label = new QLabel(); + scan_button = new QPushButton(this); + clean_button = new QPushButton(this); + back_button = new QPushButton(this); + + loading_label = new LoadingLabel(this, "firstkey"); + loading_label->show(); +// movie_label->setScaledContents(true);//设置movie_label自动缩放,显示图像大小自动调整为Qlabel大小 +// QPixmap label_pixmap(""); +// movie_label->setPixmap(label_pixmap); +// movie_label->setFixedSize(label_pixmap.size()); + + suggest_label->setObjectName("whiteLabel"); + suggest_label->setWordWrap(true);//QLabel自动换行 + suggest_label->setFixedWidth(460); + scan_result_label->setObjectName("whiteLabel"); + scan_result_label->setWordWrap(true);//QLabel自动换行 + scan_result_label->setFixedWidth(460); + scan_result_label->hide(); + result_label->setWordWrap(true);//QLabel自动换行 + result_label->setObjectName("smallWhiteLabel"); + result_label->setFixedWidth(460); + doing_label->setWordWrap(true);//QLabel自动换行 + doing_label->setObjectName("whiteLabel"); + doing_label->hide(); + doing_label->setFixedWidth(460); + +// scan_button->setFixedSize(204, 65); + scan_button->setGeometry(QRect(680, 100, 204, 65)); + scan_button->setFocusPolicy(Qt::NoFocus); + QPixmap pixmap("://res/scan.png"); + scan_button->setIcon(pixmap); + scan_button->setIconSize(pixmap.size()); + scan_button->setObjectName("greenButton"); + scan_button->setEnabled(false); + scan_button->show(); +// QFont scan_font = scan_button->font(); +// scan_font.setPointSize(16); +// scan_button->setFont(scan_font); +// clean_button->setFixedSize(204, 65); + clean_button->setGeometry(QRect(680, 100, 204, 65)); + clean_button->setFocusPolicy(Qt::NoFocus); + clean_button->setObjectName("greenButton"); + clean_button->hide(); + + back_button->setFocusPolicy(Qt::NoFocus); +// back_button->setFixedSize(50, 30); + back_button->setGeometry(QRect(840, 170, 50, 30)); + back_button->setObjectName("backButton"); + back_button->setObjectName("underlineButton"); + back_button->hide(); + + //set underline + // QFont font = back_button->font(); + // font.setUnderline(true); + // back_button->setFont(font); + + //set scan button text color +// QPalette palette; +// palette.setColor(QPalette::ButtonText, QColor(255,17,135)); +// scan_button->setPalette(palette); + + QVBoxLayout *layout1 = new QVBoxLayout(); + layout1->addStretch(); + layout1->addWidget(suggest_label); + layout1->addWidget(scan_result_label); + layout1->addWidget(doing_label); + layout1->addWidget(result_label); + layout1->addStretch(); + layout1->setSpacing(15); + layout1->setContentsMargins(0, 20, 0, 0); + + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->addWidget(loading_label, 0, Qt::AlignHCenter); + layout2->addLayout(layout1); + layout2->setSpacing(20); + layout2->setContentsMargins(0, 0, 0, 0); + +// QVBoxLayout *layout3 = new QVBoxLayout(); +// layout3->addStretch(); +// layout3->addWidget(scan_button, 0, Qt::AlignRight); +// layout3->addWidget(clean_button, 0, Qt::AlignRight); +// layout3->addWidget(back_button, 0, Qt::AlignRight); +// layout3->addStretch(); +// layout3->setSpacing(10); +// layout3->setContentsMargins(0, 20, 0, 0); + + QHBoxLayout *main_layout = new QHBoxLayout(); + main_layout->addLayout(layout2); + main_layout->addStretch(); +// main_layout->addLayout(layout3); + main_layout->setSpacing(0); + main_layout->setMargin(0); + main_layout->setContentsMargins(10, 30, 44, 0); + + setLayout(main_layout); + + + workFlag = this->getOneKeyFlag(); + if(workFlag.length() > 0) + { + if(workFlag == "1") + { + //clean + dateStr = this->getFixCleanDate(); + result_label->setText(tr("The lastest cleanup time is ") + dateStr); + } + else if(workFlag == "0") + { + //scan + dateStr = this->getSafeScanDate(); + result_label->setText(tr("The lastest scan time is ") + dateStr); + } + } + else { + result_label->setText(tr("You have not implemented the one key scan and clean-up operation.")); + } + + this->initConnect(); + this->setLanguage(); +} + +HomeActionWidget::~HomeActionWidget() +{ + if(suggest_label != NULL) { + delete suggest_label; + suggest_label = NULL; + } + if(scan_result_label != NULL) { + delete scan_result_label; + scan_result_label = NULL; + } + if(result_label != NULL) { + delete result_label; + result_label = NULL; + } + if(doing_label != NULL) { + delete doing_label; + doing_label = NULL; + } +} + +void HomeActionWidget::initConnect() +{ + connect(scan_button, SIGNAL(clicked()), this, SLOT(onStartButtonClicked())); + connect(clean_button, SIGNAL(clicked()), this, SLOT(onCleanButtonClicked())); + connect(back_button, SIGNAL(clicked()), this, SLOT(onEndButtonClicked())); +} + +void HomeActionWidget::setLanguage() +{ + suggest_label->setText(tr("Quick clean up system trash, saving disk space and improving the system efficiency!"));//一键清理系统垃圾,帮您节省磁盘空间,让系统运行更加有效率! + scan_button->setText(tr("Start Scan"));//开始扫描 + clean_button->setText(tr("Start Cleanup"));//开始清理 + back_button->setText(tr("Back")); + doing_label->setText(tr("Scanning......"));//正在扫描...... + scan_result_label->setText(tr("Scan Over")); +} + +void HomeActionWidget::enableSanButton() +{ + scan_button->setEnabled(true); +} + +void HomeActionWidget::getScanResult(QString msg) +{ + doing_label->setText(tr("Scanning:") + msg);//正在扫描: +} + +void HomeActionWidget::finishScanResult(QString msg) +{ + if(msg == "onekey") { +// doing_label->setText(tr("Scan Over"));//扫描完成 + doing_label->hide(); + scan_result_label->show(); + result_label->show(); + QString msg; + if (trace.toInt() > 0) + { + if (cookies.toInt() > 0) { + if (garbage == "0.00 B") + { + msg = trace + tr(" history trace; ") + cookies + tr(" browser cookies.") ; + } + else + { + msg = trace + tr(" history trace; ") + cookies + tr(" browser cookies; ") + garbage + tr(" garbage.") ; + } + } + else + { + if (garbage == "0.00 B") + { + msg = trace + tr(" history trace.") ; + } + else + { + msg = trace + tr(" history trace; ") + garbage + tr(" garbage.") ; + } + } + } + else + { + if (cookies.toInt() > 0) + { + if (garbage == "0.00 B") + { + msg = cookies + tr(" browser cookies.") ; + } + else + { + msg = cookies + tr(" browser cookies; ") + garbage + tr(" garbage.") ; + } + } + else + { + if (garbage == "0.00 B") + { + msg = ""; + } + else + { + msg = garbage + tr(" garbage.") ; + } + } + } + if (msg.isEmpty()) { + result_label->setText(tr("No garbage.")); + scan_button->setEnabled(true); + clean_button->hide(); + } + else + { + result_label->setText(msg); + clean_button->show(); + clean_button->setEnabled(true); + } + scanFinishTime = this->getCurrentDateTime(); +// result_label->setText(tr("The lastest scan time is ") + this->getCurrentDateTime()); + this->writeSafeScanDate(); + scan_button->hide(); + back_button->show(); + loading_label->stopLoading(); + } +} + +void HomeActionWidget::getScanAllResult(QString flag, QString msg){ + if(flag == "h") { + trace = msg; + } + else if(flag == "k") { + cookies = msg; + } + else if(flag == "c") { + garbage = msg; + } +} + +void HomeActionWidget::getCleanResult(QString msg/*, QString flag*/) +{ +// if(flag == "onekey") { + if (msg == "yes") {//在弹出输入密码验证时,点击了取消按钮 + loading_label->stopLoading(); + clean_button->show(); + clean_button->setEnabled(true); + back_button->show(); + } + else if (msg == "no") {//在弹出输入密码验证时,输入密码,验证通过,此时让动态图片开始显示 + //show dynamic image + clean_button->show(); + clean_button->setEnabled(false); + back_button->hide(); + doing_label->setText(tr("Cleaning......"));//正在清理...... + loading_label->startLoading(); + } + else if (msg == "c") { + doing_label->setText(tr("Garbage Cleanup OK......")); + } + else if (msg == "h") { + doing_label->setText(tr("History Cleanup OK......")); + } + else if (msg == "k") { + doing_label->setText(tr("Cookies Cleanup OK......")); + } + else if (msg == "o") { + this->writeFixCleanDate(); + //清理完毕后显示清理总数 + result_label->setText(tr("The lastest cleanup time is ") + this->getCurrentDateTime()); + doing_label->setText(tr("Cleanup Cookies:") +cookies + tr("; Garbage:") + garbage + tr("; Historical records:") +trace ); + trace.clear(); + cookies.clear(); + garbage.clear(); + loading_label->stopLoading(); + scan_button->show(); + scan_button->setEnabled(true); + clean_button->hide(); + clean_button->setEnabled(true); + back_button->hide(); + } +// } +} + +void HomeActionWidget::finishCleanError(QString msg) +{ + if (msg == "ce") { + qDebug() << "GarbageException---------"; + } + else if (msg == "he") { + qDebug() << "HistoryException---------"; + } + else if (msg == "ke") { + qDebug() << "CookiesException---------"; + } +} + +void HomeActionWidget::getCleaningMessage(QString type, QString status) +{ + if(type == "firefoxhistory") { + if(status == "start") { + doing_label->setText(tr("Cleaning up history trace of Firefox..."));//正在清理Firefox的历史痕迹... + } + else if(status == "end") { + doing_label->setText(tr("Firefox history trace had been cleared!"));//Firefox的历史痕迹已清理完毕! + } + } + else if(type == "chromiumhistory") { + if(status == "start") { + doing_label->setText(tr("Cleaning up history trace of Chromium..."));//正在清理Chromium的历史痕迹... + } + else if(status == "end") { + doing_label->setText(tr("Chromium history trace had been cleared!"));//Chromium的历史痕迹已清理完毕! + } + } + else if(type == "firefoxcookies") { + if(status == "start") { + doing_label->setText(tr("Cleaning up Cookies of Firefox..."));//正在清理Firefox的Cookies... + } + else if(status == "end") { + doing_label->setText(tr("Firefox Cookies had been cleared!"));//Firefox的Cookies已清理完毕! + } + } + else if(type == "chromiumcookies") { + if(status == "start") { + doing_label->setText(tr("Cleaning up Cookies of Chromium..."));//正在清理Chromium的Cookies... + } + else if(status == "end") { + doing_label->setText(tr("Chromium Cookies had been cleared!"));//Chromium的Cookies已清理完毕! + } + } + else if(type == "apt") { + if(status == "end") { + doing_label->setText(tr("Apt cache had been cleared!"));//Apt缓存已清理完毕! + } + else { + doing_label->setText(tr("Cleaning up Apt cache: ") + status);//正在清理Apt缓存: + } + } + else if(type == "software_center") { + if(status == "end") { + doing_label->setText(tr("Software Center cache had been cleared!"));//软件中心缓存已清理完毕! + } + else { + doing_label->setText(tr("Cleaning up Software Center cache: ") + status);//正在清理软件中心缓存: + } + } +} + +void HomeActionWidget::onStartButtonClicked() +{ + doing_label->setText(tr("Scanning......"));//正在扫描...... + scan_button->setEnabled(false); + loading_label->startLoading(); + suggest_label->hide(); + scan_result_label->hide(); + result_label->hide(); + doing_label->show(); + QStringList args; + args << "cache" << "history" << "cookies"; + sessionProxy->onekey_scan_function_qt(args); +} + +void HomeActionWidget::onCleanButtonClicked() +{ + clean_button->hide(); + back_button->hide(); + loading_label->startLoading(); + suggest_label->hide(); + scan_result_label->hide(); + result_label->hide(); + doing_label->setText(tr("Ready to Cleanup......"));//准备清理...... + doing_label->show(); + systemProxy->set_user_homedir_qt(); + systemProxy->clean_by_main_one_key_qt(); +} + +void HomeActionWidget::onEndButtonClicked() +{ + result_label->setText(tr("The lastest scan time is ") + scanFinishTime); + loading_label->stopLoading(); + scan_button->show(); + scan_button->setEnabled(true); + clean_button->hide(); + back_button->hide(); + suggest_label->show(); + scan_result_label->hide(); + result_label->show(); + doing_label->hide(); +} + +void HomeActionWidget::writeFixCleanDate() { + QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间 + QString str = time.toString("yyyy-MM-dd hh:mm:ss dddd"); //设置显示格式 + pSettings->beginGroup("OneKeyClean"); + pSettings->setValue("CleanDate", str); + pSettings->setValue("Flag", "1"); + pSettings->endGroup(); + pSettings->sync(); +} + +QString HomeActionWidget::getFixCleanDate() { + pSettings->beginGroup("OneKeyClean"); + QString value = pSettings->value("CleanDate").toString(); + pSettings->endGroup(); + pSettings->sync(); + return value; +} + +QString HomeActionWidget::getCurrentDateTime() { + QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间 + QString str = time.toString("yyyy-MM-dd hh:mm:ss dddd"); //设置显示格式 + return str; +} + +void HomeActionWidget::writeSafeScanDate() { + QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间 + QString str = time.toString("yyyy-MM-dd hh:mm:ss dddd"); //设置显示格式 + pSettings->beginGroup("OneKeyClean"); + pSettings->setValue("ScanDate", str); + pSettings->setValue("Flag", "0"); + pSettings->endGroup(); + pSettings->sync(); +} + +QString HomeActionWidget::getSafeScanDate() { + pSettings->beginGroup("OneKeyClean"); + QString value = pSettings->value("ScanDate").toString(); + pSettings->endGroup(); + pSettings->sync(); + return value; +} + +QString HomeActionWidget::getOneKeyFlag() { + pSettings->beginGroup("OneKeyClean"); + QString value = pSettings->value("Flag").toString(); + pSettings->endGroup(); + pSettings->sync(); + return value; +} diff --git a/mainui/homeactionwidget.h b/mainui/homeactionwidget.h new file mode 100644 index 0000000..ab80a24 --- /dev/null +++ b/mainui/homeactionwidget.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef HOMEACTIONWIDGET_H +#define HOMEACTIONWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include "../component/kylinbutton.h" +#include "../component/systembutton.h" +#include "../component/loadinglabel.h" + +class MainWindow; +class SessionDispatcher; +class SystemDispatcher; + +class HomeActionWidget : public QWidget +{ + Q_OBJECT +public: + explicit HomeActionWidget(QWidget *parent = 0, QSettings *mSettings = 0); + ~HomeActionWidget(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void setSessionDbusProxy(SessionDispatcher* dispatcher) { sessionProxy = dispatcher;} + void setSystemDbusProxy(SystemDispatcher* dispatcher) { systemProxy = dispatcher;} + void initConnect(); + void setLanguage(); + void writeFixCleanDate(); + QString getFixCleanDate(); + QString getCurrentDateTime(); + void writeSafeScanDate(); + QString getSafeScanDate(); + QString getOneKeyFlag(); + + void enableSanButton(); + +public slots: + void onStartButtonClicked(); + void onCleanButtonClicked(); + void onEndButtonClicked(); + void getScanResult(QString msg); + void finishScanResult(QString msg); + void getScanAllResult(QString flag, QString msg); + void getCleanResult(QString msg/*, QString flag*/); + void finishCleanError(QString msg); + void getCleaningMessage(QString type, QString status); + +private: + QPoint press_point;//鼠标按下去的点 + bool is_move; + LoadingLabel *loading_label; + QLabel *suggest_label; + QLabel *scan_result_label; + QLabel *result_label; + QLabel *doing_label; + QPushButton *scan_button; + QPushButton *clean_button; + QPushButton *back_button; + + MainWindow *p_mainwindow; + SystemDispatcher *systemProxy; + SessionDispatcher *sessionProxy; + QString trace; + QString cookies; + QString garbage; + QSettings *pSettings; + QString dateStr; + QString workFlag; + QString scanFinishTime; +}; + +#endif // HOMEACTIONWIDGET_H diff --git a/mainui/homepage.cpp b/mainui/homepage.cpp new file mode 100644 index 0000000..8cc75b6 --- /dev/null +++ b/mainui/homepage.cpp @@ -0,0 +1,410 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "homepage.h" +#include +#include +#include "mainwindow.h" +#include "../component/toolbutton.h" +#include "../component/utils.h" + +HomePage::HomePage(QWidget *parent, QString arch, QString os/*, const QString &version*/) : + QWidget(parent), osarch(arch), osname(os) +{ + this->setFixedSize(900, 326); + + //set white background color + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + +//// QPixmap label_pixmap(""); +//// movie_label->setPixmap(label_pixmap); +//// movie_label->setFixedSize(label_pixmap.size()); + +// scan_button->setFocusPolicy(Qt::NoFocus); +// QPixmap pixmap("://res/scan.png"); +// scan_button->setIcon(pixmap); +// scan_button->setIconSize(pixmap.size()); + current_version = VERSION; + version_logo = new QLabel(); + version_title = new QLabel(); + version_tip = new QLabel(); + check_btn = new QPushButton(); + check_btn->hide(); +// version_label = new QLabel(); + box_logo = new QLabel(); + box_title = new QPushButton(); + box_title->setFixedWidth(240); + box_title->setCursor(Qt::PointingHandCursor); + box_title->setFocusPolicy(Qt::NoFocus); + box_title->setStyleSheet("QPushButton{background:transparent;text-align:left;font-family: 方正黑体_GBK;font-size:24px;color:#000000;}QPushButton:hover{color:#3f96e4;}"); +// box_title->installEventFilter(this); + box_tip = new QLabel(); +// more_text_btn = new QPushButton(); +// more_btn = new QPushButton(); + +// auto_start = NULL; +// camera_manager = NULL; + +// more_text_btn->setObjectName("checkButton"); +// more_text_btn->setCursor(Qt::PointingHandCursor); +// more_text_btn->setCursor(Qt::OpenHandCursor); +// more_text_btn->setFocusPolicy(Qt::NoFocus); +// QFont font = more_text_btn->font(); +// font.setUnderline(true); +// more_text_btn->setFont(font); + + check_btn->setObjectName("checkButton"); + check_btn->setCursor(Qt::PointingHandCursor); + check_btn->setFocusPolicy(Qt::NoFocus); +// version_label->setObjectName("smallgrayLabel"); + version_title->setObjectName("bigblackLabel"); +// box_title->setObjectName("bigblackLabel"); + version_tip->setAlignment(Qt::AlignLeft); + version_tip->setObjectName("smallgrayLabel"); + version_tip->setFixedWidth(380); + box_tip->setAlignment(Qt::AlignLeft); + box_tip->setObjectName("smallgrayLabel"); + version_tip->setWordWrap(true);//QLabel自动换行 + box_tip->setWordWrap(true);//QLabel自动换行 + box_tip->setFixedWidth(380); +// more_btn->setObjectName("transparentButton"); +// more_btn->setCursor(Qt::PointingHandCursor); + + version_logo->setFixedSize(65, 65); + version_logo->setPixmap(QPixmap("://res/version.png")); + box_logo->setFixedSize(65, 65); + box_logo->setPixmap(QPixmap("://res/box.png")); + + + + this->setLanguage(); +} + +HomePage::~HomePage() +{ + if(version_logo != NULL) { + delete version_logo; + version_logo = NULL; + } + if(version_title != NULL) { + delete version_title; + version_title = NULL; + } + if(version_tip != NULL) { + delete version_tip; + version_tip = NULL; + } + if(check_btn != NULL) { + delete check_btn; + check_btn = NULL; + } + if(box_logo != NULL) { + delete box_logo; + box_logo = NULL; + } + if(box_title != NULL) { + delete box_title; + box_title = NULL; + } + if(box_tip != NULL) { + delete box_tip; + box_tip = NULL; + } + for(int i=0; iaddWidget(version_title); + layout1->addWidget(check_btn); +// layout1->addWidget(version_label); + layout1->addStretch(); + layout1->setMargin(0); + layout1->setSpacing(5); + layout1->setContentsMargins(0,0,0,0); + QVBoxLayout *layout2 = new QVBoxLayout(); + layout2->addStretch(); + layout2->addLayout(layout1); + layout2->addWidget(version_tip); + layout2->addStretch(); + layout2->setMargin(0); + layout2->setSpacing(5); + layout2->setContentsMargins(0,0,0,0); + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->addWidget(version_logo/* ,0, Qt::AlignVCenter*/); + layout3->addLayout(layout2); + layout3->addStretch(); + layout3->setMargin(0); + layout3->setSpacing(5); + layout3->setContentsMargins(0,0,0,0); + + QVBoxLayout *layout4 = new QVBoxLayout(); + layout4->addStretch(); + layout4->addWidget(box_title); + layout4->addWidget(box_tip); + layout4->addStretch(); + layout4->setMargin(0); + layout4->setSpacing(5); + layout4->setContentsMargins(0,0,0,0); + + + + + QStringList icon_list; +// icon_list<<"://res/ubuntukylin-software-center"<<"://res/boot"<<"://res/camera"; + icon_list<<"://res/boot" << "://res/more.png"; + QStringList text_list; +// text_list<< tr("Youker Softeware Center") << tr("Boot Manager") << tr("Camera"); + text_list << tr("Boot Manager") << tr("More"); + QHBoxLayout *button_layout = new QHBoxLayout(); + QSignalMapper *signal_mapper = new QSignalMapper(this); + for(int i=0; isetFocusPolicy(Qt::NoFocus); + tool_button->setIcon(icon_list.at(i)); + tool_button->setText(text_list.at(i)); + connect(tool_button, SIGNAL(clicked()), signal_mapper, SLOT(map())); + signal_mapper->setMapping(tool_button, QString::number(i, 10)); + button_layout->addWidget(tool_button); + item_list.append(tool_button); + + } + connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchPageIndex(QString))); + + +// more_btn->setFocusPolicy(Qt::NoFocus); +// QPixmap pixmap("://res/more.png"); +// more_btn->setIcon(pixmap); +// more_btn->setIconSize(pixmap.size()); + +// QVBoxLayout *more_layout = new QVBoxLayout(); +//// more_layout->addStretch(); +// more_layout->addWidget(more_btn); +// more_layout->addWidget(more_text_btn); +//// more_layout->addStretch(); +// more_layout->setSpacing(0); +// more_layout->setMargin(0); +// more_layout->setContentsMargins(0, 8, 0, 0); + +// button_layout->addStretch(); +// button_layout->addLayout(more_layout); +//// button_layout->addWidget(more_btn, 0, Qt::AlignTop); +// button_layout->setSpacing(20); +// button_layout->setMargin(0); +// button_layout->setContentsMargins(0, 0, 0, 0); + + QHBoxLayout *layout5 = new QHBoxLayout(); + layout5->addWidget(box_logo); + layout5->addLayout(layout4); + layout5->addStretch(); + layout5->addLayout(button_layout); + layout5->setMargin(0); + layout5->setSpacing(5); + layout5->setContentsMargins(0,0,0,0); + + + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addLayout(layout3); + main_layout->addLayout(layout5); + main_layout->setMargin(0); + main_layout->setSpacing(50); + main_layout->setContentsMargins(60,50,60,80); + + this->setLayout(main_layout); +} + +void HomePage::initConnect() +{ + connect(this, SIGNAL(moreSignal()), p_mainwindow, SIGNAL(chanegBoxToolStatus())); +// connect(more_btn, SIGNAL(clicked()), p_mainwindow, SLOT(showBoxWidget())); +// connect(more_btn, SIGNAL(clicked()), p_mainwindow, SIGNAL(chanegBoxToolStatus())); +// connect(more_text_btn, SIGNAL(clicked()), p_mainwindow, SLOT(showBoxWidget())); +// connect(more_text_btn, SIGNAL(clicked()), p_mainwindow, SIGNAL(chanegBoxToolStatus())); +// connect(check_btn, SIGNAL(clicked()), this, SLOT(checkLastestVersion())); + connect(check_btn, SIGNAL(clicked()), this, SLOT(onCheckBtnClicked())); + connect(this, SIGNAL(sendSignal()), p_mainwindow, SIGNAL(chanegBoxToolStatus())); + connect(box_title, SIGNAL(clicked()), this, SIGNAL(sendSignal())); +} + +void HomePage::setLanguage() +{ + version_title->setText(tr("Current Version Number") + " " + current_version); + version_tip->setText(tr("Update to the lastest version, make it work better")); + check_btn->setText(tr("updating on the backend")); + box_title->setText(tr("Common toolbox")); + box_tip->setText(tr("Fast and practical, making the system more personalized")); +// more_text_btn->setText(tr("More")); +// more_btn->setToolTip(tr("More")); +} + +void HomePage::initBoxTool() +{ + +} + +void HomePage::onCheckBtnClicked() +{ + emit this->sendOpenUpgrade(); + check_btn->hide(); +} + +void HomePage::displayBackedBtn(bool flag) +{ + if(flag) + check_btn->setText(tr("Upgrade is complete")); + else + check_btn->setText(tr("Updating on the backend")); + check_btn->show(); +} + +void HomePage::hideBackedBtn() +{ + check_btn->hide(); +} + +//void HomePage::checkLastestVersion() +//{ +// QStringList version_list = sessionProxy->checkNewVersion(); +// if(version_list.length() == 1) { +// version_label->setText(version_list.at(0)); +// } +// if(version_list.length() == 4) { +// version_label->setText(version_list.at(2)); +// if(version_list.at(3) == "1") { +// qDebug() << "Neet to UPdate......"; +// p_mainwindow->openUpgradePage(version_list); +//// systemProxy->update_myself(); +// } +// else { +// qDebug() << "Unneccesary to UPdate......"; +// p_mainwindow->openUpgradePage(version_list); +// } +// } +// else { +// version_label->setText(""); +// } +//} + +void HomePage::switchPageIndex(QString index) +{ +// bool ok; +// int current_index = index.toInt(&ok, 10); + + if(index == "0") + emit this->sendSubIndex(0); + else if(index == "-1") + if(this->osarch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin") + sessionProxy->runApp("cheese"); + else + emit this->sendSubIndex(1); + else if(index == "1") { +// p_mainwindow->showBoxWidget(); + emit this->moreSignal(); + } + +// if(index == "0") +// { +// if(auto_start == NULL) { +// auto_start = new AutoStartWidget(0, sessionProxy); +// connect(sessionProxy, SIGNAL(tellAutoModel(QStringList)), auto_start, SLOT(readyReciveData(QStringList))); +// connect(sessionProxy, SIGNAL(showAutoModel()), auto_start, SLOT(readyShowUI())); +// auto_start->initData(); +// int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (560 / 2); +// int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (398 / 2); +// auto_start->move(w_x, w_y); +// auto_start->show(); +// auto_start->raise(); +// } +// else { +// int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (560 / 2); +// int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (398 / 2); +// auto_start->move(w_x, w_y); +// auto_start->show(); +// auto_start->raise(); +// } +// } + +// else if(index == "1") +// { +// if(camera_manager == NULL) { +// camera_manager = new CameraManager(0, sessionProxy); +// if(sessionProxy->judge_camera_qt()) +// { +// camera_manager->setOKButtonEnable(true); +// } +// else{ +// camera_manager->setOKButtonEnable(false); +// } +// int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (524 / 2); +// int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (277 / 2); +// camera_manager->move(w_x, w_y); +// camera_manager->exec(); +//// camera_manager->show(); +//// camera_manager->raise(); +// } +// else { +// int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (524 / 2); +// int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (277 / 2); +// camera_manager->move(w_x, w_y); +// camera_manager->show(); +// camera_manager->raise(); +// } +// } +} + +//bool HomePage::eventFilter(QObject *obj, QEvent *event) +//{ +// if(obj == box_title){ +// if(event->type() == QEvent::MouseButtonRelease){ +// emit this->sendSignal(); +//// p_mainwindow->showBoxWidget(); +// } +//// if(event->type() == QEvent::Enter){ +//// ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn_hover.png")); +//// }else if(event->type() == QEvent::Leave){ +//// ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn.png")); +//// }else if(event->type() == QEvent::MouseButtonPress){ +//// ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn_hover.png")); +//// }else if(event->type() == QEvent::MouseButtonRelease){ +//// QMouseEvent *me = (QMouseEvent *)event; +//// QLabel *lb = (QLabel *)obj; +//// if(me->x() > 0 && me->x() < lb->width() && me->y() > 0 && me->y() < lb->height()){ +//// this->close(); +//// this->destroy(); +//// }else{ +//// ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn.png")); +//// } +//// } else { +//// return QObject::eventFilter(obj, event); +//// } +// } +// return QObject::eventFilter(obj, event); +//} diff --git a/mainui/homepage.h b/mainui/homepage.h new file mode 100644 index 0000000..78d333d --- /dev/null +++ b/mainui/homepage.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef HOMEPAGE_H +#define HOMEPAGE_H + +#include +#include +#include +#include +#include + +class MainWindow; +class SessionDispatcher; +class SystemDispatcher; +class ToolButton; +//#include "autostartwidget.h" +//#include "cameramanager.h" + +class HomePage : public QWidget +{ + Q_OBJECT +public: + explicit HomePage(QWidget *parent = 0, QString arch = "", QString os = ""/*, const QString &version = ""*/); + ~HomePage(); + void setLanguage(); + void initBoxTool(); + void initConnect(); + void setSessionDbusProxy(SessionDispatcher *dispatcher) { sessionProxy = dispatcher;} + void setSystemDbusProxy(SystemDispatcher *dispatcher) { systemProxy = dispatcher;} + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void initUI(); + +//protected: +// bool eventFilter(QObject *obj, QEvent *event); + +public slots: + void switchPageIndex(QString index); +// void checkLastestVersion(); + void displayBackedBtn(bool flag); + void onCheckBtnClicked(); + void hideBackedBtn(); + +signals: + void sendSubIndex(int index); + void sendSignal(); + void moreSignal(); + void sendOpenUpgrade(); + +private: + QLabel *version_logo; + QLabel *version_title; + QLabel *version_tip; + QPushButton *check_btn; +// QLabel *version_label; + QLabel *box_logo; + QPushButton *box_title; + QLabel *box_tip; +// QPushButton *more_text_btn; +// QPushButton *more_btn; + SessionDispatcher *sessionProxy; + SystemDispatcher *systemProxy; + MainWindow *p_mainwindow; +// AutoStartWidget *auto_start; +// CameraManager *camera_manager; + QString current_version; + QString osname; + QString osarch; + QList item_list; +}; + +#endif // HOMEPAGE_H diff --git a/mainui/img.qrc b/mainui/img.qrc new file mode 100644 index 0000000..8679f0e --- /dev/null +++ b/mainui/img.qrc @@ -0,0 +1,549 @@ + + + res/logo.png + res/menu_hover.png + res/arrowhead.png + res/title.png + res/scan.png + res/left-tab-default.png + res/left-tab-hover.png + res/ubuntukylin.png + res/off.png + res/on.png + res/switch-closed-dangerous.png + res/switch-closed-dangerous-hover.png + res/switch-closed-normal.png + res/switch-closed-normal-hover.png + res/switch-opend.png + res/switch-opend-hover.png + res/switch-shade.png + res/dot.png + res/book.png + res/bootanimation.png + res/box.png + res/broadcast.png + res/camera.png + res/camera-uk.png + res/dynamic.png + res/folder.png + res/folder_hover.png + res/font.png + res/iconbeauty.png + res/ip.png + res/listen-pen.png + res/mouse.png + res/move.gif + res/next.png + res/others.png + res/pic.png + res/play.png + res/play_hover.png + res/power.png + res/previewzone.png + res/processmanager.png + res/revoke.png + res/revoke_hover.png + res/shredder.png + res/systemset.png + res/systemsound.png + res/themeset.png + res/tool-hover.png + res/touchpad.png + res/unity.png + res/apt-min.png + res/box-hover.png + res/browser.png + res/brush.png + res/button-hover.png + res/cache.png + res/chrome.png + res/chromium.png + res/configfile.png + res/cookies.png + res/cookies-bg.png + res/deb-min.png + res/firefox.png + res/green.png + res/highlight.png + res/history.png + res/history-max.png + res/hover-enter.png + res/hover-press.png + res/kernel.png + res/menu-big-hover.png + res/menu_press.png + res/program.png + res/red.png + res/searchfile.png + res/software-min.png + res/systemtrace.png + res/thumbnails.png + res/yellow.png + res/using.png + res/alert.png + res/icon.png + res/logo-hover.png + res/boot.png + res/more.png + res/toolkits.png + res/ubuntukylin-software-center.png + res/version.png + res/checkbox.png + res/checkbox_mid.png + res/checkbox_seclect.png + res/screen.png + res/bigfile.png + res/checkbox-hover.png + res/checkbox-press.png + res/closeBtn.png + res/closeBtn_hover.png + res/cookie.png + res/menu.png + res/minBtn.png + res/minBtn_hover.png + res/package.png + res/trace.png + res/checkbox-checked.png + res/checkbox-disable-checked.png + res/checkbox-disable-unchecked.png + res/checkbox-unchecked.png + res/custom.png + res/desktop.png + res/other.png + res/radiobutton-disable.png + res/radiobutton-select.png + res/radiobutton-unselect.png + res/system.png + res/arrow-hover.png + res/arrow-normal.png + res/back-arrow.png + res/btn-ground.png + res/switch-off.png + res/switch-on.png + res/youker-assistant.png + res/delete.png + res/picture.png + res/systeminfo.png + res/checkbox-tristate.png + res/checkbox-two.png + res/radiobutton.png + res/cache_check.png + res/cache_uncheck.png + res/shadow_gray_hover.png + res/shadow_hover.png + res/bigfile_check.png + res/bigfile_uncheck.png + res/browser_check.png + res/browser_uncheck.png + res/cookie_check.png + res/cookie_uncheck.png + res/package_check.png + res/package_uncheck.png + res/trace_check.png + res/trace_uncheck.png + res/bigfile_logo.png + res/bigfile_logo_gray.png + res/browser_logo.png + res/browser_logo_gray.png + res/cache_logo.png + res/cache_logo_gray.png + res/cookie_logo.png + res/cookie_logo_gray.png + res/disappear.png + res/package_logo.png + res/package_logo_gray.png + res/trace_logo.png + res/trace_logo_gray.png + res/background.jpg + res/clothes.png + res/indicator.png + res/underline.png + res/choose.png + res/conceal.png + res/remove.png + res/skin-cover.png + res/theme-cover.png + res/create.png + res/no-net.png + res/retry-hover.png + res/retry-press.png + res/retry.png + res/upgrade-normal.png + res/upgrade-ok.png + res/hook.png + res/janitor/apt_check.png + res/janitor/apt_uncheck.png + res/janitor/chromium_check.png + res/janitor/chromium_uncheck.png + res/janitor/debug_check.png + res/janitor/debug_uncheck.png + res/janitor/firefox_check.png + res/janitor/firefox_uncheck.png + res/janitor/package_check.png + res/janitor/package_uncheck.png + res/janitor/software_check.png + res/janitor/software_uncheck.png + res/janitor/thumbnails_check.png + res/janitor/thumbnails_uncheck.png + res/janitor/trace_check.png + res/janitor/trace_uncheck.png + res/catch.png + res/catch-hover.png + res/view.png + res/camera-default.png + res/camera-error.png + res/catch-disable.png + + + res/sysBtn/close_button.png + res/sysBtn/main_menu.png + res/sysBtn/min_button.png + res/sysBtn/skin_button.png + + + res/qss/youker-assistant.qss + + + translation/youker-assistant_de.qm + translation/youker-assistant_es.qm + translation/youker-assistant_fr.qm + translation/youker-assistant_ru.qm + translation/youker-assistant_zh_CN.qm + + + res/hardware/audio.png + res/hardware/battery.png + res/hardware/board.png + res/hardware/cdrom.png + res/hardware/computer.png + res/hardware/cpu.png + res/hardware/drive.png + res/hardware/harddisk.png + res/hardware/memory.png + res/hardware/monitor.png + res/hardware/network.png + res/hardware/unity.png + res/hardware/sensor.png + + + res/manufacturer/3COM.jpg + res/manufacturer/ABIT.jpg + res/manufacturer/ACER.jpg + res/manufacturer/ADATA.jpg + res/manufacturer/A-DATA.jpg + res/manufacturer/AEXEA.jpg + res/manufacturer/ALI.jpg + res/manufacturer/AMD.jpg + res/manufacturer/AMI.jpg + res/manufacturer/AOC.jpg + res/manufacturer/AOPEN.jpg + res/manufacturer/APACER.jpg + res/manufacturer/APPLE.jpg + res/manufacturer/ASINT.jpg + res/manufacturer/ASROCK.jpg + res/manufacturer/ASUS.jpg + res/manufacturer/ASZ.jpg + res/manufacturer/ATHEROS.jpg + res/manufacturer/ATI.jpg + res/manufacturer/AUO.jpg + res/manufacturer/AUTHENTEC.jpg + res/manufacturer/AVAGO.jpg + res/manufacturer/AVEO.jpg + res/manufacturer/B&DATA.jpg + res/manufacturer/BENQ.jpg + res/manufacturer/BIOSTAR.jpg + res/manufacturer/B-LINK.jpg + res/manufacturer/BROADCOM.jpg + res/manufacturer/CANON.jpg + res/manufacturer/CHAINTECH.jpg + res/manufacturer/CHICONY.jpg + res/manufacturer/CISCO.jpg + res/manufacturer/COLORFUL.jpg + res/manufacturer/COMEON.jpg + res/manufacturer/CORSAIR.jpg + res/manufacturer/CREATIVE.jpg + res/manufacturer/DELL.jpg + res/manufacturer/DFI.jpg + res/manufacturer/D-LINK.jpg + res/manufacturer/DTK.jpg + res/manufacturer/EAGET.jpg + res/manufacturer/EAST.jpg + res/manufacturer/ECS.jpg + res/manufacturer/ELEPHANT.jpg + res/manufacturer/ELIXIR.jpg + res/manufacturer/ELSA.jpg + res/manufacturer/EMPIA.jpg + res/manufacturer/E-MU.jpg + res/manufacturer/ENLON.jpg + res/manufacturer/ENNYAH.jpg + res/manufacturer/ETRON.jpg + res/manufacturer/EXCELSTOR.jpg + res/manufacturer/FIC.jpg + res/manufacturer/FOUNDER.jpg + res/manufacturer/FUJITSU.jpg + res/manufacturer/G.SKILL.jpg + res/manufacturer/GAINWARO.jpg + res/manufacturer/GALAXY.jpg + res/manufacturer/GAMEN.jpg + res/manufacturer/GEIL.jpg + res/manufacturer/GIGABYTE.jpg + res/manufacturer/GREAT WALL.jpg + res/manufacturer/HASEE.jpg + res/manufacturer/HITACHI.jpg + res/manufacturer/HOMKEY.jpg + res/manufacturer/HP.jpg + res/manufacturer/HYNIX.jpg + res/manufacturer/HYUNDAI.jpg + res/manufacturer/IBM.jpg + res/manufacturer/INNOVISION.jpg + res/manufacturer/INTEL.jpg + res/manufacturer/IOMEGA.jpg + res/manufacturer/JETWAY.jpg + res/manufacturer/J&W.jpg + res/manufacturer/KINGBOX.jpg + res/manufacturer/KINGFAST.jpg + res/manufacturer/KINGMAX.jpg + res/manufacturer/KINGSPEC.jpg + res/manufacturer/KINGSTEK.jpg + res/manufacturer/KINGSTON.jpg + res/manufacturer/KINGTIGER.jpg + res/manufacturer/LEADTEK.jpg + res/manufacturer/LENOVO.jpg + res/manufacturer/LG.jpg + res/manufacturer/LINKSYS.jpg + res/manufacturer/LITEON.jpg + res/manufacturer/LITTLE TIGER.jpg + res/manufacturer/LOGITECH.jpg + res/manufacturer/MACY.jpg + res/manufacturer/MAGIC-PRO.jpg + res/manufacturer/MARVELL.jpg + res/manufacturer/MATROX.jpg + res/manufacturer/M_AUDIO.jpg + res/manufacturer/MAXSUN.jpg + res/manufacturer/MAXTOR.jpg + res/manufacturer/MAYA.jpg + res/manufacturer/MEGASTAR.jpg + res/manufacturer/MICRON.jpg + res/manufacturer/MICROSOFT.jpg + res/manufacturer/MMC.jpg + res/manufacturer/M-ONE.jpg + res/manufacturer/MOTOROLA.jpg + res/manufacturer/MSI.jpg + res/manufacturer/MUSILAND .jpg + res/manufacturer/NEC.jpg + res/manufacturer/NETGEAR.jpg + res/manufacturer/NOKIA.jpg + res/manufacturer/NVIDIA.jpg + res/manufacturer/OCZ.jpg + res/manufacturer/OMEGA.jpg + res/manufacturer/OMNIVISION.jpg + res/manufacturer/OMRON.jpg + res/manufacturer/ONDA.jpg + res/manufacturer/ONKYO.jpg + res/manufacturer/PANASONIC.jpg + res/manufacturer/PHILIPS.jpg + res/manufacturer/PHOENIX.jpg + res/manufacturer/PINE.jpg + res/manufacturer/PIONEER.jpg + res/manufacturer/PIXART.jpg + res/manufacturer/PLDS.jpg + res/manufacturer/POWERCOLOR.jpg + res/manufacturer/PRIMAX.jpg + res/manufacturer/QDI.jpg + res/manufacturer/QIMONDA.jpg + res/manufacturer/QUANTUM.jpg + res/manufacturer/RALINK.jpg + res/manufacturer/RAPOO.jpg + res/manufacturer/RAZER.jpg + res/manufacturer/REALTEK.jpg + res/manufacturer/SAMSUNG.jpg + res/manufacturer/SANYO.jpg + res/manufacturer/SAPPHIRE.jpg + res/manufacturer/SEAGATE.jpg + res/manufacturer/SHARK.jpg + res/manufacturer/SIEMENS.jpg + res/manufacturer/SIS.jpg + res/manufacturer/SMP.jpg + res/manufacturer/SONIX.jpg + res/manufacturer/SONY.jpg + res/manufacturer/SOYO.jpg + res/manufacturer/SPARK.jpg + res/manufacturer/SUNPLUS.jpg + res/manufacturer/SUPERGRAPHIC.jpg + res/manufacturer/SUPOX.jpg + res/manufacturer/SYMBOL.jpg + res/manufacturer/SYNTEK.jpg + res/manufacturer/TAIYANFA.jpg + res/manufacturer/TDK.jpg + res/manufacturer/TEKRAM.jpg + res/manufacturer/TERRATEC.jpg + res/manufacturer/TEXAS.jpg + res/manufacturer/TONGFANG.jpg + res/manufacturer/TOSHIBA.jpg + res/manufacturer/TOYOTA.jpg + res/manufacturer/TP-LINK.jpg + res/manufacturer/TRANSMETA.jpg + res/manufacturer/TRUST.jpg + res/manufacturer/TSSTCORP.jpg + res/manufacturer/T&W.jpg + res/manufacturer/TYAN.jpg + res/manufacturer/UMC.jpg + res/manufacturer/UNIKA.jpg + res/manufacturer/VIA.jpg + res/manufacturer/VIMICRO.jpg + res/manufacturer/VIRTUALBOX.jpg + res/manufacturer/WDC.jpg + res/manufacturer/WINBOND.jpg + res/manufacturer/XFX.jpg + res/manufacturer/YESTON.jpg + res/manufacturer/ZOTAC.jpg + res/manufacturer/ZTE.jpg + res/manufacturer/UBUNTUKYLIN.jpg + + + res/skin/1.png + res/skin/2.png + res/skin/3.png + res/skin/4.png + + + res/menu/cleanup.png + res/menu/cleanup-hover.png + res/menu/feature.png + res/menu/feature-hover.png + res/menu/home.png + res/menu/home-hover.png + res/menu/sysinfo.png + res/menu/sysinfo-hover.png + res/menu/toolkits.png + res/menu/toolkits-hover.png + res/menu/about.png + res/menu/features.png + res/menu/feedback.png + res/menu/help.png + res/menu/setup.png + res/menu/cleanup-press.png + res/menu/feature-press.png + res/menu/home-press.png + res/menu/sysinfo-press.png + res/menu/toolkits-press.png + res/menu/upgrade.png + + + res/loading/1.png + res/loading/2.png + res/loading/3.png + res/loading/4.png + res/loading/5.png + res/loading/6.png + res/loading/7.png + res/loading/8.png + res/loading/9.png + res/loading/10.png + res/loading/11.png + res/loading/12.png + res/loading/13.png + res/loading/14.png + res/loading/15.png + res/loading/16.png + res/loading/17.png + res/loading/18.png + res/loading/small/10.png + res/loading/small/11.png + res/loading/small/12.png + res/loading/small/13.png + res/loading/small/14.png + res/loading/small/15.png + res/loading/small/16.png + res/loading/small/17.png + res/loading/small/18.png + res/loading/small/1.png + res/loading/small/2.png + res/loading/small/3.png + res/loading/small/4.png + res/loading/small/5.png + res/loading/small/6.png + res/loading/small/7.png + res/loading/small/8.png + res/loading/small/9.png + res/upgrading/10.png + res/upgrading/11.png + res/upgrading/12.png + res/upgrading/13.png + res/upgrading/14.png + res/upgrading/15.png + res/upgrading/16.png + res/upgrading/17.png + res/upgrading/18.png + res/upgrading/19.png + res/upgrading/20.png + res/upgrading/21.png + res/upgrading/22.png + res/upgrading/23.png + res/upgrading/24.png + res/upgrading/25.png + res/upgrading/26.png + res/upgrading/27.png + res/upgrading/28.png + res/upgrading/29.png + res/upgrading/30.png + res/upgrading/31.png + res/upgrading/32.png + res/working/10.png + res/working/11.png + res/working/12.png + res/working/13.png + res/working/14.png + res/working/15.png + res/working/16.png + res/working/17.png + res/working/18.png + res/working/19.png + res/working/20.png + res/working/21.png + res/working/22.png + res/working/23.png + res/working/24.png + res/working/25.png + res/working/26.png + res/working/27.png + res/working/28.png + res/working/29.png + res/working/30.png + res/working/31.png + res/working/32.png + res/working/33.png + res/working/34.png + res/working/35.png + res/working/36.png + res/upgrading/1.png + res/upgrading/2.png + res/upgrading/3.png + res/upgrading/4.png + res/upgrading/5.png + res/upgrading/6.png + res/upgrading/7.png + res/upgrading/8.png + res/upgrading/9.png + res/working/1.png + res/working/2.png + res/working/3.png + res/working/4.png + res/working/5.png + res/working/6.png + res/working/7.png + res/working/8.png + res/working/9.png + + + res/theme/Ambiance.png + res/theme/disappear.png + res/theme/HighContrast.png + res/theme/Radiance.png + res/theme/ubuntukylin-theme.png + + + res/plugin/processmanager.png + res/plugin/shredder.png + + diff --git a/mainui/infoactionwidget.cpp b/mainui/infoactionwidget.cpp new file mode 100644 index 0000000..ccd9d28 --- /dev/null +++ b/mainui/infoactionwidget.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "infoactionwidget.h" +#include "mainwindow.h" + +InfoActionWidget::InfoActionWidget(QWidget *parent) + : QWidget(parent) +{ + this->setFixedSize(900, 150); + this->setAutoFillBackground(true); + this->setObjectName("transparentWidget"); + + img_label = new QLabel(); + suggest_label = new QLabel(); + + img_label->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小 + QPixmap label_pixmap("://res/systeminfo.png"); + img_label->setPixmap(label_pixmap); + img_label->setFixedSize(label_pixmap.size()); + + suggest_label->setObjectName("whiteLabel"); + suggest_label->setWordWrap(true);//QLabel自动换行 + + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->addWidget(img_label, 0, Qt::AlignVCenter); + layout2->addWidget(suggest_label, 0, Qt::AlignVCenter); + layout2->setSpacing(20); + layout2->setMargin(0); + layout2->setContentsMargins(20, 20, 0, 0); + + setLayout(layout2); + + this->setLanguage(); +} + +InfoActionWidget::~InfoActionWidget() +{ + if(img_label != NULL) { + delete img_label; + img_label = NULL; + } + if(suggest_label != NULL) { + delete suggest_label; + suggest_label = NULL; + } +} + + +void InfoActionWidget::setLanguage() +{ + suggest_label->setText(tr("Understand hardware information, provide more convenient channel to obtain hardware information"));//了解电脑硬件详细信息,为用户提供更加方便的获取硬件信息渠道 +} diff --git a/mainui/infoactionwidget.h b/mainui/infoactionwidget.h new file mode 100644 index 0000000..5d67613 --- /dev/null +++ b/mainui/infoactionwidget.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef INFOACTIONWIDGET_H +#define INFOACTIONWIDGET_H + +#include +#include +#include +#include + +class InfoActionWidget : public QWidget +{ + Q_OBJECT +public: + explicit InfoActionWidget(QWidget *parent = 0); + ~InfoActionWidget(); + void setLanguage(); + +private: + QLabel *img_label; + QLabel *suggest_label; +// QLabel *result_label; +}; + +#endif // INFOACTIONWIDGET_H diff --git a/mainui/infowidget.cpp b/mainui/infowidget.cpp new file mode 100644 index 0000000..4fca6c5 --- /dev/null +++ b/mainui/infowidget.cpp @@ -0,0 +1,385 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "infowidget.h" +#include +//#include + +InfoWidget::InfoWidget(QString machine, QWidget *parent) : + QWidget(parent), arch(machine) +{ + this->setFixedSize(900, 403); + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + splitter = new QSplitter(this); + splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + splitter->setOrientation(Qt::Horizontal); + splitter->setHandleWidth(1); + + category_widget = new QListWidget(this); + category_widget->setFixedSize(150, 403); + category_widget->setFocusPolicy(Qt::NoFocus); + category_widget->setObjectName("infoList"); + + category_widget->setIconSize(QSize(16, 16));//设置QListWidget中的单元项的图片大小 + category_widget->setResizeMode(QListView::Adjust); + category_widget->setViewMode(QListView::ListMode); //设置QListWidget的显示模式 + category_widget->setMovement(QListView::Static);//设置QListWidget中的单元项不可被拖动 +// category_widget->setSpacing(1);//设置QListWidget中的单元项的间距 + + stacked_widget = new QStackedWidget(this);//stacked_widget will delete when InfoWidget delete +// stacked_widget->setStyleSheet("QStackedWidget{border: none;}"); + stacked_widget->setFocusPolicy(Qt::NoFocus); + stacked_widget->setAutoFillBackground(true); + +// arch = ""; + + system_widget = NULL; + desktop_widget = NULL; + sensor_widget = NULL; + cpu_widget = NULL; + memory_widget = NULL; + board_widget = NULL; + hd_widget = NULL; + nic_widget = NULL; + monitor_widget = NULL; + audio_widget = NULL; + cdrom_widget = NULL; + battery_widget = NULL; + driver_widget = NULL; + + connect(category_widget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(changeInfoPage(QListWidgetItem*))); + + + connect(&m_workerThread, SIGNAL(resultReady(QMap)), this, SLOT(handleResults(QMap))); +// connect(&m_workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater())); + connect(&m_workerThread, SIGNAL(finished()), this, SLOT(threadFinish())); + +} + +InfoWidget::~InfoWidget() +{ + m_workerThread.quit(); + m_workerThread.deleteLater(); +} + +void InfoWidget::initUI(bool has_battery, bool has_sensor) +{ + system_widget = new SystemWidget(this, systemProxy); + desktop_widget = new DesktopWidget(this, sessionProxy); + cpu_widget = new CpuWidget(this, systemProxy); + memory_widget = new MemoryWidget(this, systemProxy); + board_widget = new BoardWidget(this, systemProxy); + hd_widget = new HDWidget(this, systemProxy); + nic_widget = new NicWidget(this, systemProxy); + connect(this, SIGNAL(emit_network_info(QMap)), nic_widget, SLOT(slot_network_info(QMap))); + monitor_widget = new MonitorWidget(this, systemProxy); + audio_widget = new AudioWidget(this, systemProxy); + serverOrDesktop = sessionProxy->get_os_release_qt(); + + int dvdNum = 0; + QMap tmpMap = systemProxy->get_cdrom_info_qt(); + if (tmpMap.isEmpty()) { + dvdNum = 0; + } + else { + QMap::iterator iter = tmpMap.find("Dvdnum"); + if (iter == tmpMap.end()) + { + dvdNum = 0; + } + else{ + dvdNum = iter.value().toInt(); + } + } + if(dvdNum != 0) + { + cdrom_widget = new CDRowWidget(this, systemProxy); + } +// bool power = sessionProxy->judge_power_is_exists_qt(); +// if(power) + if(has_battery) + { + battery_widget = new BatteryWidget(this, sessionProxy); + } + driver_widget = new DriverWidget(this/*, systemProxy*/); + + if (has_sensor) { + sensor_widget = new SensorWieget(this, systemProxy); + } + +// QProcess *p = new QProcess(); +// p->start("uname -p"); +// bool result = p->waitForFinished(); +// if (result) { +// if (p->canReadLine()){ +// arch = p->readLine(); +// arch = arch.left(arch.length() - 1); +// } +// } + + + if (system_widget->displaySwitch()) + { + type_list << tr("Computer"); + icon_list << "computer"; + } + + if (desktop_widget->displaySwitch()) + { + type_list << tr("Desktop"); + icon_list << "unity"; + } + + if (cpu_widget->displaySwitch()) + { + type_list << tr("CPU"); + icon_list << "cpu"; + } + + if (memory_widget->displaySwitch()) + { + type_list << tr("Memory"); + icon_list << "memory"; + } + + if (board_widget->displaySwitch()) + { + type_list << tr("Motherboard"); + icon_list << "board"; + } + + if (hd_widget->displaySwitch()) + { + type_list << tr("HD"); + icon_list << "harddisk"; + } + + if (true) //网络模块获取速度慢,使用的多线程,避免初始化界面阶段获取数据 + { + type_list << tr("NIC"); + icon_list << "network"; + } + + if (monitor_widget->displaySwitch()) + { + type_list << tr("VGA"); + icon_list << "monitor"; + } + + if (audio_widget->displaySwitch()) + { + type_list << tr("Audio"); + icon_list << "audio"; + } + if (dvdNum > 0) + { + type_list << tr("CD-ROM"); + icon_list << "cdrom"; + } + if (has_battery) + { + type_list << tr("Battery"); + icon_list << "battery"; + } + if (has_sensor) + { + type_list << tr("Sensor"); + icon_list << "sensor"; + } + if (true) //驱动必然有 + { + type_list << tr("Device Driver"); + icon_list << "drive"; + } + + + for(int i = 0;i < type_list.length();i ++) { +// if (i == 1 && arch == "aarch64") +// { +// // FT arm can not access board +// } +// else if (i == 11 && arch == "aarch64" && serverOrDesktop.contains("server")) { +// //arm server no sensor +// } + QIcon icon; + icon.addFile(":/hd/res/hardware/" + icon_list.at(i), QSize(), QIcon::Normal, QIcon::Off); + QListWidgetItem *item = new QListWidgetItem(type_list.at(i), category_widget); + // item->setSizeHint(QSize(120,31)); //设置单元项的宽度和高度 + item->setSizeHint(QSize(120,36)); //设置单元项的宽度和高度 + item->setStatusTip(icon_list.at(i)); + item->setIcon(icon); + } + category_widget->setCurrentRow(0); + current_tip = category_widget->currentItem()->statusTip(); + + stacked_widget->addWidget(system_widget); + stacked_widget->addWidget(desktop_widget); + stacked_widget->addWidget(cpu_widget); + stacked_widget->addWidget(memory_widget); + stacked_widget->addWidget(board_widget); + stacked_widget->addWidget(hd_widget); + stacked_widget->addWidget(nic_widget); + stacked_widget->addWidget(monitor_widget); + stacked_widget->addWidget(audio_widget); + + if(dvdNum != 0) + { + stacked_widget->addWidget(cdrom_widget); + } +// if(power) + if(has_battery) + { + stacked_widget->addWidget(battery_widget); + } +// if (arch == "aarch64" && !serverOrDesktop.contains("server")) {//20170206 + if (has_sensor) { + stacked_widget->addWidget(sensor_widget); + } + stacked_widget->addWidget(driver_widget); + +// device_content = new QWidget(); +// QScrollArea scroll_area1; +// scroll_area1.setWidget(device_content); +// //设置背景色的方法。 +// scroll_area1.viewport()->setBackgroundRole(QPalette::Light); +// scroll_area1.viewport()->setAutoFillBackground(true); +// scroll_area1.show(); + +// logo_view = new QWidget(); +// logo_view->setFixedWidth(150); +// QScrollArea scroll_area2; +// scroll_area2.setWidget(logo_view); +// scroll_area2.show(); + + QVBoxLayout *center_layout = new QVBoxLayout(); + center_layout->addWidget(stacked_widget); + center_layout->setSpacing(0); + center_layout->setMargin(0); + center_layout->setContentsMargins(0, 0, 0, 0); + splitter->addWidget(category_widget); + splitter->addWidget(stacked_widget); + + for(int i = 0; icount();i++) + { + QSplitterHandle *handle = splitter->handle(i); + handle->setEnabled(false); + } + + QHBoxLayout *main_layout = new QHBoxLayout(); + main_layout->addWidget(splitter); + main_layout->setSpacing(0); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + this->setLayout(main_layout); + + m_workerThread.initInterface(systemProxy); +} + +// 开启线程 +void InfoWidget::startThread() +{ +// WorkerThread *workerThread = new WorkerThread(this); +// connect(workerThread, SIGNAL(resultReady(QMap)), this, SLOT(handleResults(QMap))); +// // 线程结束后,自动销毁 +// connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater())); +// workerThread->start(); + + if (!m_workerThread.isRunning()) + m_workerThread.start(); +} + +void InfoWidget::handleResults(QMap value) +{ +// qDebug() << "Handle Thread : " << QThread::currentThreadId();// << " value=" << value; + emit this->emit_network_info(value); +} + +void InfoWidget::threadFinish() +{ +// qDebug() << "threadFinish"; +} + +void InfoWidget::changeInfoPage(QListWidgetItem *item) { + if (item->statusTip() != this->current_tip) { + if (item->statusTip() == "computer") { + stacked_widget->setCurrentWidget(system_widget); + } + else if (item->statusTip() == "unity") { +// if(!desktop_widget->getStatus()) + desktop_widget->initData(); + stacked_widget->setCurrentWidget(desktop_widget); + } + else if (item->statusTip() == "cpu") { +// if(!cpu_widget->getStatus()) + cpu_widget->initData(); + stacked_widget->setCurrentWidget(cpu_widget); + } + else if (item->statusTip() == "memory") { +// if(!memory_widget->getStatus()) + memory_widget->initData(); + stacked_widget->setCurrentWidget(memory_widget); + } + else if (item->statusTip() == "board") { +// if(!board_widget->getStatus()) + board_widget->initData(); + stacked_widget->setCurrentWidget(board_widget); + } + else if (item->statusTip() == "harddisk") { +// if(!hd_widget->getStatus()) + hd_widget->initData(); + stacked_widget->setCurrentWidget(hd_widget); + } + else if (item->statusTip() == "network") { +// nic_widget->initData(); + this->startThread(); + stacked_widget->setCurrentWidget(nic_widget); + } + else if (item->statusTip() == "monitor") { +// if(!monitor_widget->getStatus()) + monitor_widget->initData(); + stacked_widget->setCurrentWidget(monitor_widget); + } + else if (item->statusTip() == "audio") { +// if(!audio_widget->getStatus()) + audio_widget->initData(); + stacked_widget->setCurrentWidget(audio_widget); + } + else if (item->statusTip() == "cdrom") { +// if(!cdrom_widget->getStatus()) + cdrom_widget->initData(); + stacked_widget->setCurrentWidget(cdrom_widget); + } + else if (item->statusTip() == "battery") { +// if(!battery_widget->getStatus()) + battery_widget->initData(); + stacked_widget->setCurrentWidget(battery_widget); + } + else if (item->statusTip() == "sensor") { + stacked_widget->setCurrentWidget(sensor_widget); + } + else if (item->statusTip() == "drive") { + stacked_widget->setCurrentWidget(driver_widget); + } + this->current_tip = item->statusTip(); + } +} diff --git a/mainui/infowidget.h b/mainui/infowidget.h new file mode 100644 index 0000000..42958bf --- /dev/null +++ b/mainui/infowidget.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef INFOWIDGET_H +#define INFOWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include "infotype.h" +#include "../info/systemwidget.h" +#include "../info/desktopwidget.h" +#include "../info/cpuwidget.h" +#include "../info/memorywidget.h" +#include "../info/boardwidget.h" +#include "../info/hdwidget.h" +#include "../info/nicwidget.h" +#include "../info/monitorwidget.h" +#include "../info/audiowidget.h" +#include "../info/cdrowwidget.h" +#include "../info/batterywidget.h" +#include "../info/driverwidget.h" +#include "../info/sensorwidget.h" +#include +//#include "../dbusproxy/youkersystemdbus.h" +class SessionDispatcher; +class SystemDispatcher; + +#include "../component/workthread.h" + +class InfoWidget : public QWidget +{ + Q_OBJECT +public: + explicit InfoWidget(QString machine = "", QWidget *parent = 0); + ~InfoWidget(); + void setSessionDbusProxy(SessionDispatcher *dispatcher) { sessionProxy = dispatcher;} + void setSystemDbusProxy(SystemDispatcher *dispatcher) { systemProxy = dispatcher;} + void initUI(bool has_battery, bool has_sensor); + + + void startThread(); + +public slots: + void changeInfoPage(QListWidgetItem* item); + void handleResults(QMap value); + void threadFinish(); + +signals: + void emit_network_info(QMap info); + +private: + QSplitter *splitter; + QListWidget *category_widget; + QStringList type_list; + QStringList icon_list; + QStackedWidget *stacked_widget; + SystemWidget *system_widget; + DesktopWidget *desktop_widget; + CpuWidget *cpu_widget; + MemoryWidget *memory_widget; + BoardWidget *board_widget; + HDWidget *hd_widget; + NicWidget *nic_widget; + MonitorWidget *monitor_widget; + AudioWidget *audio_widget; + CDRowWidget *cdrom_widget; + BatteryWidget *battery_widget; + DriverWidget *driver_widget; + SensorWieget *sensor_widget; + QString current_tip; +// QList *categoryList; + QString serverOrDesktop; + QString arch; +// QWidget *device_content; +// QWidget *logo_view; +// SystemDispatcher systemproxy; + SessionDispatcher *sessionProxy; + SystemDispatcher *systemProxy; + + WorkerThread m_workerThread; +}; + +#endif // INFOWIDGET_H diff --git a/mainui/kthread.cpp b/mainui/kthread.cpp new file mode 100644 index 0000000..bcbe8b0 --- /dev/null +++ b/mainui/kthread.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include "kthread.h" + +//Thread::Thread(QString message, QObject *parent) : +// stopped(false) +// , QThread(parent) +// , message(message) +//{ +//} + +//Thread *thread = new Thread(name, this); + + +KThread::KThread(QObject *parent):QThread(parent) +{ + +} + +void KThread::initValues(QMap data, QStringList &arglist, QDBusInterface *systemiface, QString method) { + iface = systemiface; + mapData = data; + methodName = method; + list = arglist; +} + +KThread::~KThread() { + stop(); +} + +void KThread::run() { + //清理 + if(methodName == "onekey_clean_crufts_function") { + iface->call("onekey_clean_crufts_function", list); + } + //扫描 + else if(methodName == "onekey_scan_function") { + iface->call("onekey_scan_function", list); + } + else if(methodName == "get_scan_result") { + iface->call("get_scan_result", mapData); + } + else if(methodName == "remove_select_items") { + iface->call("remove_select_items", mapData); + } + else if(methodName == "call_camera") { + iface->call("call_camera"); + } + else if(methodName == "install") { + iface->call("install", "youker-assistant"); + } + else if(methodName == "update") { + iface->call("update"); + } + else if(methodName == "start_check_source_useable") { + iface->call("start_check_source_useable"); + } + //sso +// else if(methodName == "slot_do_login_account") { +// iface->call("slot_do_login_account"); +// } +// else if(methodName == "check_user") { +// iface->call("check_user"); +// } +// else if(methodName == "shredFile") { +// QDBusReply reply = iface->call("shredFile", fileFlag); +// emit msgSignal(reply.value()); +// } +} +void KThread::stop() { + wait(); +} diff --git a/mainui/kthread.h b/mainui/kthread.h new file mode 100644 index 0000000..626c0fb --- /dev/null +++ b/mainui/kthread.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KTHREAD_H +#define KTHREAD_H + +#include +#include +#include +#include + +#include +#include +#include +#include + +class KThread : public QThread +{ + Q_OBJECT +public: + explicit KThread(QObject *parent); +// explicit KThread(QStringList &arglist, QDBusInterface *systemiface=0,/* QObject *parent = 0, */QString method="", QString flag="", int size=0); + ~KThread(); + void stop(); + void initValues(QMap data, QStringList &arglist, QDBusInterface *systemiface=0,QString method=""); +//signals: +// void msgSignal(const int result);//用于向主线程传递 +protected: + void run(); +private: + //Dbus接口 + QDBusInterface *iface; + QMap mapData; + QStringList list; + QString methodName; +// QString fileFlag; +}; +#endif // KTHREAD_H diff --git a/mainui/kylinthread.cpp b/mainui/kylinthread.cpp new file mode 100644 index 0000000..4bc09cf --- /dev/null +++ b/mainui/kylinthread.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "kylinthread.h" + +#include "cleanerwidget.h" + +KylinThread::KylinThread() +{ +} + +KylinThread::~KylinThread() +{ +} + + +void KylinThread::run () +{ + return; +} diff --git a/mainui/kylinthread.h b/mainui/kylinthread.h new file mode 100644 index 0000000..8803130 --- /dev/null +++ b/mainui/kylinthread.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KYLINTHREAD_H +#define KYLINTHREAD_H + +#include +class CleanerWidget; + +class KylinThread : public QThread +{ + Q_OBJECT +public: + KylinThread(); + ~KylinThread(); + virtual void run(); + void setCleanerWidget(CleanerWidget* widget) { parent_widget = widget; } + +private: + CleanerWidget *parent_widget; +}; + +#endif // KYLINTHREAD_H diff --git a/mainui/loginwidget.cpp b/mainui/loginwidget.cpp new file mode 100644 index 0000000..20d12b8 --- /dev/null +++ b/mainui/loginwidget.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "loginwidget.h" +#include "mainwindow.h" +#include +#include + +LoginWidget::LoginWidget(QWidget *parent) + : QWidget(parent) +{ + this->setFixedSize(300, 72); + logo_label = new QPushButton(); + logo_label->setObjectName("whiteButton"); + logo_label->setCursor(Qt::PointingHandCursor); +// logo_label->setCursor(Qt::ArrowCursor); +// logo_label->setCursor(Qt::SizeHorCursor); + logo_label->setFocusPolicy(Qt::NoFocus); + login_button = new QPushButton(); + login_button->setObjectName("loginButton"); + login_button->setCursor(Qt::PointingHandCursor); + login_button->setFocusPolicy(Qt::NoFocus); + login_button->setFixedSize(44, 44); +// login_button->setIcon(QIcon("://res/logo.png")); + login_button->setIconSize(QSize(44, 44)); + login_button->setFlat(true); + + user_label = new QLabel(); + user_label->hide(); + user_label->setStyleSheet("QLabel{color:#ffffff;font-family: 方正黑体_GBK;font-size: 12px;text-align: right;}"); + user_label->adjustSize(); + + logout_btn = new QPushButton(); + logout_btn->setObjectName("whiteButton"); + logout_btn->setCursor(Qt::PointingHandCursor); + logout_btn->setFocusPolicy(Qt::NoFocus); + logout_btn->hide(); + + QHBoxLayout *layout = new QHBoxLayout(); + layout->addStretch(); + layout->addWidget(logo_label, 0, Qt::AlignVCenter); + layout->addWidget(login_button, 0, Qt::AlignVCenter); + layout->addWidget(user_label, 0, Qt::AlignVCenter); + layout->addWidget(logout_btn, 0, Qt::AlignVCenter); + layout->setSpacing(11); + layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); + + setLayout(layout); + + is_move = false; + this->initConnect(); + this->setLauguage(); +} + +LoginWidget::~LoginWidget() +{ + if(login_button != NULL) + { + delete login_button; + login_button = NULL; + } + if(logo_label != NULL) + { + delete logo_label; + logo_label = NULL; + } + if(user_label != NULL) + { + delete user_label; + user_label = NULL; + } + if(logout_btn != NULL) + { + delete logout_btn; + logout_btn = NULL; + } +} + +void LoginWidget::initConnect() +{ + connect(logo_label, SIGNAL(clicked()), this, SLOT(onLoginButtonClicked())); + connect(login_button, SIGNAL(clicked()), this, SLOT(onLoginButtonClicked())); + connect(logout_btn, SIGNAL(clicked()), this, SLOT(onLogoutButtonClicked())); +} + +void LoginWidget::showLoginInfo(QString name, QString email) +{ + logo_label->hide(); + login_button->hide(); + user_label->show(); +// user_label->setText(name + "<" + email + ">"); + QString alltext= QString("%1 <%2>").arg(name).arg(email); + QFont ft; + QFontMetrics fm(ft); + QString elided_text = fm.elidedText(alltext, Qt::ElideRight, 260); + user_label->setText(elided_text); + if(elided_text.endsWith("…")) + user_label->setToolTip(alltext); + logout_btn->show(); +} + +void LoginWidget::showLoginAndLogoutStatus(bool status) +{ + if(status) + {//logout success + logo_label->show(); + login_button->show(); + logout_btn->hide(); + user_label->setText(""); + user_label->hide(); + } + else + {//login failed + qDebug() << "login failed"; + } +} + +void LoginWidget::setLauguage() +{ +// logo_label->setText(tr("Login Youker Account")); +// logout_btn->setText(tr("Logout")); + logo_label->setText(tr("Login Kylin Account")); + logout_btn->setText(tr("Logout")); +} + +void LoginWidget::onLoginButtonClicked() +{ + sessionProxy->popup_login_dialog(); +} + +void LoginWidget::onLogoutButtonClicked() +{ + sessionProxy->logout_ubuntukylin_account(); +} diff --git a/mainui/loginwidget.h b/mainui/loginwidget.h new file mode 100644 index 0000000..4848139 --- /dev/null +++ b/mainui/loginwidget.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LOGINWIDGET_H +#define LOGINWIDGET_H + +#include + +#include "../component/kylinbutton.h" +#include "../component/systembutton.h" + +class SessionDispatcher; +class QLabel; + +class LoginWidget : public QWidget +{ + Q_OBJECT +public: + explicit LoginWidget(QWidget *parent = 0); + ~LoginWidget(); + void setSessionDbusProxy(SessionDispatcher* dispatcher) { sessionProxy = dispatcher;} + void setLauguage(); + void initConnect(); + +public slots: + void onLoginButtonClicked(); + void onLogoutButtonClicked(); + void showLoginInfo(QString name, QString email); + void showLoginAndLogoutStatus(bool status); + +private: + QPoint press_point;//鼠标按下去的点 + bool is_move; + QPushButton *login_button; + QPushButton *logo_label; + QLabel *user_label; + QPushButton *logout_btn; + SessionDispatcher *sessionProxy; +}; + +#endif // LOGINWIDGET_H diff --git a/mainui/main.cpp b/mainui/main.cpp new file mode 100644 index 0000000..a75e4f2 --- /dev/null +++ b/mainui/main.cpp @@ -0,0 +1,295 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "mainwindow.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define BUFF_SIZE (512) +char filePath[BUFF_SIZE] = {0}; + +#define LOCKFILE "/tmp/youker-assistant-%d.pid" +#define LOCKMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) + +int make_pid_file() { + char buf[16]; + struct flock fl; + snprintf(filePath, BUFF_SIZE, LOCKFILE, getuid()); + + int fd = open(filePath, O_RDWR|O_CREAT, LOCKMODE); + if (fd < 0) { + printf("Can not open %s: %s.\n", filePath, strerror(errno)); + return -1; + } + + fl.l_type = F_WRLCK; + fl.l_start = 0; + fl.l_whence = SEEK_SET; + fl.l_len = 0; + + if (fcntl(fd, F_SETLK, &fl) < 0) { + printf("Can not lock %s: %s.\n", filePath, strerror(errno)); + close(fd); + return -1; + } + + ftruncate(fd, 0); + sprintf(buf, "%d\n", getpid()); + write(fd, buf, strlen(buf)); + close(fd); + return 0; +} + +// Helper function to return display orientation as a string. +/*QString Orientation(Qt::ScreenOrientation orientation) +{ + switch (orientation) { + case Qt::PrimaryOrientation : return "Primary"; + case Qt::LandscapeOrientation : return "Landscape"; + case Qt::PortraitOrientation : return "Portrait"; + case Qt::InvertedLandscapeOrientation : return "Inverted landscape"; + case Qt::InvertedPortraitOrientation : return "Inverted portrait"; + default : return "Unknown"; + } +}*/ + +/*int main(int argc, char *argv) +{ + QGuiApplication a(argc, &argv); + + qDebug() << "Number of screens:" << QGuiApplication::screens().size(); + + qDebug() << "Primary screen:" << QGuiApplication::primaryScreen()->name(); + + foreach (QScreen *screen, QGuiApplication::screens()) { + qDebug() << "Information for screen:" << screen->name(); + qDebug() << " Available geometry:" << screen->availableGeometry().x() << screen->availableGeometry().y() << screen->availableGeometry().width() << "x" << screen->availableGeometry().height(); + qDebug() << " Available size:" << screen->availableSize().width() << "x" << screen->availableSize().height(); + qDebug() << " Available virtual geometry:" << screen->availableVirtualGeometry().x() << screen->availableVirtualGeometry().y() << screen->availableVirtualGeometry().width() << "x" << screen->availableVirtualGeometry().height(); + qDebug() << " Available virtual size:" << screen->availableVirtualSize().width() << "x" << screen->availableVirtualSize().height(); + qDebug() << " Depth:" << screen->depth() << "bits"; + qDebug() << " Geometry:" << screen->geometry().x() << screen->geometry().y() << screen->geometry().width() << "x" << screen->geometry().height(); + qDebug() << " Logical DPI:" << screen->logicalDotsPerInch(); + qDebug() << " Logical DPI X:" << screen->logicalDotsPerInchX(); + qDebug() << " Logical DPI Y:" << screen->logicalDotsPerInchY(); + qDebug() << " Orientation:" << Orientation(screen->orientation()); + qDebug() << " Physical DPI:" << screen->physicalDotsPerInch(); + qDebug() << " Physical DPI X:" << screen->physicalDotsPerInchX(); + qDebug() << " Physical DPI Y:" << screen->physicalDotsPerInchY(); + qDebug() << " Physical size:" << screen->physicalSize().width() << "x" << screen->physicalSize().height() << "mm"; + qDebug() << " Primary orientation:" << Orientation(screen->primaryOrientation()); + qDebug() << " Refresh rate:" << screen->refreshRate() << "Hz"; + qDebug() << " Size:" << screen->size().width() << "x" << screen->size().height(); + qDebug() << " Virtual geometry:" << screen->virtualGeometry().x() << screen->virtualGeometry().y() << screen->virtualGeometry().width() << "x" << screen->virtualGeometry().height(); + qDebug() << " Virtual size:" << screen->virtualSize().width() << "x" << screen->virtualSize().height(); + } +}*/ + + + + + +int main(int argc, char *argv[]) +{ +// QApplication app(argc, argv); + //单程序运行处理 + QtSingleApplication app(argc, argv); + if (app.isRunning()) + { + qDebug() << QObject::tr("kylin-assistant had already running!"); + return 0; + } + + QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); + QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale()); + QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + + if (make_pid_file()) { + exit(1); + } + + QString arch = ""; + +#ifdef __x86_64__ + arch = "x86_64"; +#elif __i386__ + arch = "i386"; +#elif __aarch64__ + arch = "aarch64"; +#endif + + QString locale = QLocale::system().name(); + QTranslator translator; + if(locale == "zh_CN" || locale == "es" || locale == "fr" || locale == "de" || locale == "ru") {//中文 西班牙语 法语 德语 俄语 + if(!translator.load("youker-assistant_" + locale + ".qm", + ":/qmfile/translation/")) + qDebug() << "Load translation file:"<< "youker-assistant_" + locale + ".qm" << " failed!"; + else + app.installTranslator(&translator); + } + + //加载Qt对话框默认的国际化 + QTranslator qtTranslator; + qtTranslator.load("qt_" + locale, + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + app.installTranslator(&qtTranslator); + + QFile qss(":/qssfile/res/qss/youker-assistant.qss"); + qss.open(QFile::ReadOnly); + qApp->setStyleSheet(qss.readAll()); + qss.close(); + + QDesktopWidget *desktop = QApplication::desktop(); +// qDebug() << desktop->primaryScreen();//获取主屏幕的索引序号 + int sCount = desktop->screenCount();//获取当前显示器的个数 +// qDebug() << sCount; + //如果有两个显示,则N=2,qt默认的计算机主机的index = 0,外接显示器的index = 1; +// mdlg.setGeometry(desktop->screenGeometry(1));//QDialog 有个成员函数叫setGeometry,只需要将dialog对象的Geometry设置为index为1的显示器即可,默认为0.如果要显示的dialog的对象为mdlg,则 +// mdlg.show(); + + //启动图片 + QPixmap pixmap("://res/skin/x.png"); + QSplashScreen screen(pixmap); + screen.show(); + screen.showMessage("START...", Qt::AlignCenter, Qt::white); + + MainWindow w(arch, sCount); + +#if 0 + //延时 + int delayTime = 3; + QElapsedTimer timer; + timer.start(); + while (timer.elapsed() < (delayTime * 1000)) { + app.processEvents(); + } + screen.finish(&w); +#endif + + w.setTranslator(&translator); + + + +// if (sCount > 1) { +// w.setGeometry(desktop->screenGeometry(1)); +// } +// w.display(sCount); + + return app.exec(); +} + + +/* +测试多屏(只测了横屏,没测试纵屏): 根据当前屏幕数量n,生成n个窗口,每个窗口都占据了一个屏幕 +#include "mainwindow.h" + +#include + +#include + +#include + +#include + + + +typedef struct{ + +int screen_no; + +QRect rect; + +}SCREEN; + +SCREEN g_screens[10]; + + + +int main(int argc, char *argv[]) + +{ + +QApplication app(argc, argv); + +QDesktopWidget *desktop = QApplication::desktop(); + + +int screen_count = desktop->screenCount(); + + +int prim_screen = desktop->primaryScreen(); + +char warning[100], *idx=warning; + +for(int i=0; iscreenGeometry(prim_screen + i); + +sprintf(idx, "screen%d w[%d], h[%d] ",i, g_screens[i].rect.width(),g_screens[i].rect.height() ); + +idx += strlen(idx); + +} + +sprintf(idx, "total width[%d] , total height[%d] \n", desktop->width(), desktop->height() ); + +QMessageBox::warning(NULL, "screen", warning, QMessageBox::Ok); + + +MainWindow wnd[5]; + +for(int i=0; i < screen_count; i++){ + +wnd[i].resize(g_screens[i].rect.width(),g_screens[i].rect.height()); + +if(i == 0) + +wnd[i].move(0,0); + +else + +wnd[i].move(i* g_screens[i-1].rect.width(),0); + +char str[50]; + +sprintf(str,"this is screen %d",i); + +wnd[i].show(); + +} + +return app.exec(); + +} + * */ diff --git a/mainui/mainui.pro b/mainui/mainui.pro new file mode 100644 index 0000000..d61b037 --- /dev/null +++ b/mainui/mainui.pro @@ -0,0 +1,267 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-01-21T08:48:08 +# +#------------------------------------------------- + +QT += core gui dbus + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = youker-assistant +DESTDIR = ../ +TEMPLATE = app +CONFIG += qt \ + warn_on \ + release \ + link_pkgconfig +INCLUDEPATH += . + +include(../qtsingleapplication/src/qtsingleapplication.pri) + +QMAKE_CFLAGS_DEBUG = -g + +#指定uic命令将.ui文件转化成ui_*.h文件的存放的目录 +UI_DIR += $$PWD/../tmp/ + +#指定rcc命令将.qrc文件转换成qrc_*.h文件的存放目录 +RCC_DIR += $$PWD/../tmp/ + +#指定moc命令将含Q_OBJECT的头文件转换成标准.h文件的存放目录 +MOC_DIR += $$PWD/../tmp/ + +#指定目标文件(obj)的存放目录 +#OBJECTS_DIR += $$PWD/../tmp/ + +CONFIG(debug,debug|release){ + message(debug) + + DEFINES += _DEBUG + +# DESTDIR = $$PWD/../bin/Debug + OBJECTS_DIR = $$PWD/../obj/Debug +} + +CONFIG(release,debug|release){ + message(release) + +# DESTDIR = $$PWD/../bin/Release + OBJECTS_DIR = $$PWD/../obj/Release + + QMAKE_CFLAGS += -Os -s + QMAKE_CXXFLAGS += -Os -s +} + +inst1.files += res/youker-assistant.png +inst1.path = /usr/share/pixmaps +inst2.files += ../youker-assistant.desktop +inst2.path = /usr/share/applications +inst3.files += res/default/ +inst3.path = /var/lib/youker-assistant-daemon/ +inst4.files += res/custom/ +inst4.path = /var/lib/youker-assistant-daemon/ +inst5.files += res/autostart-default.png +inst5.path = /usr/share/pixmaps +target.source += $$TARGET +target.path = /usr/bin +INSTALLS += inst1 \ + inst2 \ + inst3 \ + inst4 \ + inst5 \ + target + +SOURCES += main.cpp\ + mainwindow.cpp \ + titlewidget.cpp \ + loginwidget.cpp \ + actionwidget.cpp \ + homeactionwidget.cpp \ + infoactionwidget.cpp \ + cleaneractionwidget.cpp \ + settingactionwidget.cpp \ + boxactionwidget.cpp \ + toolwidget.cpp \ + contentwidget.cpp \ + infowidget.cpp \ + cleanerwidget.cpp \ + settingwidget.cpp \ + boxwidget.cpp \ + pluginmanager.cpp \ + ../component/kylinlistmodel.cpp \ + ../component/kylinbutton.cpp \ + ../component/kylinmenu.cpp \ + ../component/kylintoolbutton.cpp \ + ../component/kylinswitcher.cpp \ + ../component/systembutton.cpp \ + ../component/kylintitlebar.cpp \ + ../component/threadpool.cpp \ + homepage.cpp \ + ../info/systemwidget.cpp \ + ../info/desktopwidget.cpp \ + ../info/cpuwidget.cpp \ + ../info/memorywidget.cpp \ + ../info/boardwidget.cpp \ + ../info/hdwidget.cpp \ + ../info/nicwidget.cpp \ + ../info/monitorwidget.cpp \ + ../info/audiowidget.cpp \ + ../info/cdrowwidget.cpp \ + ../info/batterywidget.cpp \ + ../info/driverwidget.cpp \ + ../info/sensorwidget.cpp \ + ../info/computerpage.cpp \ + ../setting/themewidget.cpp \ + ../setting/iconwidget.cpp \ + ../setting/mousewidget.cpp \ + ../setting/voicewidget.cpp \ +# ../setting/animationwidget.cpp \ + ../setting/launcherwidget.cpp \ + ../setting/panelwidget.cpp \ + ../setting/windowwidget.cpp \ + ../setting/fontwidget.cpp \ + ../setting/touchpadwidget.cpp \ +# ../setting/deadpixelwidget.cpp \ + ../setting/conservewidget.cpp \ + ../setting/nautiluswidget.cpp \ + ../component/scrollwidget.cpp \ + ../component/agentlistitem.cpp \ + ../component/quibo.cpp \ + ../component/kylinfontdialog.cpp \ + skincenter.cpp \ + ../component/kylinlistwidgetitem.cpp \ + ../component/kylinlistwidget.cpp \ + ../component/loadinglabel.cpp \ + ../component/alertdialog.cpp \ + ../component/toolkits.cpp \ + ../cleaner/cacheactionwidget.cpp \ + ../cleaner/cleanerdetailwidget.cpp \ + ../cleaner/cleanermainwidget.cpp \ + ../cleaner/cleaneritems.cpp \ + ../dbusproxy/youkersystemdbus.cpp \ + ../dbusproxy/youkersessiondbus.cpp \ + ../info/devicemanager.cpp \ + ../component/settingaction.cpp \ + autostartwidget.cpp \ + ../component/autogroup.cpp \ + kthread.cpp \ + aboutdialog.cpp \ + ../cleaner/cleanlistwidget.cpp \ + ../component/tipdialog.cpp \ + ../component/toolbutton.cpp \ + ../component/cleangroup.cpp \ + ../component/cleanbutton.cpp \ + ../component/cleansubgroup.cpp \ + ../component/cleansubbutton.cpp \ + ../component/cardwidget.cpp \ + ../component/itemcard.cpp \ + upgradedialog.cpp \ + ../component/normalwidget.cpp \ + ../component/normalcard.cpp \ + shadowwidget.cpp \ + ../component/basewidget.cpp + +HEADERS += mainwindow.h \ + titlewidget.h \ + actionwidget.h \ + homeactionwidget.h \ + infoactionwidget.h \ + cleaneractionwidget.h \ + settingactionwidget.h \ + boxactionwidget.h \ + toolwidget.h \ + loginwidget.h \ + contentwidget.h \ + infowidget.h \ + cleanerwidget.h \ + settingwidget.h \ + boxwidget.h \ + pluginmanager.h \ + ../component/workthread.h \ + ../component/plugininterface.h \ + ../component/kylinlistmodel.h \ + ../component/utils.h \ + ../component/kylinbutton.h \ + ../component/kylinmenu.h \ + ../component/kylintoolbutton.h \ + ../component/kylinswitcher.h \ + ../component/systembutton.h \ + ../component/kylintitlebar.h \ + ../component/threadpool.h \ + homepage.h \ + ../info/systemwidget.h \ + ../info/desktopwidget.h \ + ../info/cpuwidget.h \ + ../info/memorywidget.h \ + ../info/boardwidget.h \ + ../info/hdwidget.h \ + ../info/nicwidget.h \ + ../info/monitorwidget.h \ + ../info/audiowidget.h \ + ../info/cdrowwidget.h \ + ../info/batterywidget.h \ + ../info/driverwidget.h \ + ../info/sensorwidget.h \ + ../info/computerpage.h \ + ../setting/themewidget.h \ + ../setting/iconwidget.h \ + ../setting/mousewidget.h \ + ../setting/voicewidget.h \ +# ../setting/animationwidget.h \ + ../setting/launcherwidget.h \ + ../setting/panelwidget.h \ + ../setting/windowwidget.h \ + ../setting/fontwidget.h \ + ../setting/touchpadwidget.h \ +# ../setting/deadpixelwidget.h \ + ../setting/conservewidget.h \ + ../setting/nautiluswidget.h \ + ../component/scrollwidget.h \ + ../component/agentlistitem.h \ + ../component/quibo.h \ + ../component/kylinfontdialog.h \ + skincenter.h \ + ../component/kylinlistwidgetitem.h \ + ../component/kylinlistwidget.h \ + ../component/loadinglabel.h \ + ../component/alertdialog.h \ + ../component/toolkits.h \ + ../cleaner/cacheactionwidget.h \ + ../cleaner/cleanerdetailwidget.h \ + ../cleaner/cleanermainwidget.h \ + ../cleaner/cleaneritems.h \ + ../dbusproxy/youkersystemdbus.h \ + ../dbusproxy/youkersessiondbus.h \ + ../info/devicemanager.h \ + ../component/settingaction.h \ + autostartwidget.h \ + ../component/autogroup.h \ + kthread.h \ + aboutdialog.h \ + ../cleaner/cleanlistwidget.h \ + ../component/tipdialog.h \ + ../component/toolbutton.h \ + ../component/cleangroup.h \ + ../component/cleanbutton.h \ + ../component/cleansubgroup.h \ + ../component/cleansubbutton.h \ + ../component/cardwidget.h \ + ../component/itemcard.h \ + upgradedialog.h \ + ../component/normalwidget.h \ + ../component/normalcard.h \ + shadowwidget.h \ + ../component/basewidget.h + +FORMS += \ + ../component/quibo.ui \ + ../component/alertdialog.ui \ + autostartwidget.ui \ +# aboutdialog.ui \ + ../cleaner/cleanlistwidget.ui \ + ../cleaner/cleanerdetailwidget.ui \ + ../component/itemcard.ui \ + ../component/normalcard.ui + +RESOURCES += \ + img.qrc diff --git a/mainui/mainwindow.cpp b/mainui/mainwindow.cpp new file mode 100644 index 0000000..b93b856 --- /dev/null +++ b/mainui/mainwindow.cpp @@ -0,0 +1,1349 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "mainwindow.h" +#include +#include +#include +#include "shadowwidget.h" +//#include "cameramanager.h" +#include "../component/threadpool.h" + +QString GlobalData::globalarch = ""; // add by hebing, just for transmit var + +MainWindow::MainWindow(QString cur_arch, int d_count, QWidget *parent) : + QDialog(parent), arch(cur_arch), display_count(d_count)/*skin_center(parent),*/ +{ + + GlobalData::globalarch = this->arch; + + this->osName = accessOSName(); +// char *dsk; +// dsk = getenv("XDG_CURRENT_DESKTOP"); + + + this->desktop = qgetenv("XDG_CURRENT_DESKTOP"); + if(this->desktop.isEmpty()) + this->desktop = qgetenv("XDG_SESSION_DESKTOP"); +// qDebug() << this->desktop; +// qDebug() << QString::compare(this->desktop, "mate", Qt::CaseInsensitive/*Qt::CaseInsensitive*/); + +// this->osName = "Kylin"; +// if (this->arch == "aarch64" || this->osName == "Kylin" || this->osName == "YHKylin") { + if (this->desktop == "MATE" || this->desktop == "mate" || this->desktop == "UKUI" || this->desktop == "ukui") { + this->isTopLevel(); + this->resize(900, 600); + this->setAutoFillBackground(true); + this->setWindowFlags(Qt::FramelessWindowHint | Qt::Widget); + this->setWindowTitle(tr("Kylin Assistant")); + } + else { + this->setFixedSize(900, 600); + this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint); + this->setWindowTitle(tr("Youker Assistant")); + } + +// this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint); +//// this->setAttribute(Qt::WA_TranslucentBackground, true); + + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + this->setWindowOpacity(1); +// this->setWindowFlags(Qt::FramelessWindowHint | Qt::Widget); +// this->setAttribute(Qt::WA_TranslucentBackground); +// this->setStyleSheet("QMainWindow{border: 1px solid gray;border-radius:2px}"); + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); +// version = "V2.2.0"; + status = HOMEPAGE; + statusFlag = false; + + sessioninterface = NULL; + systeminterface = NULL; + + mSettings = new QSettings(YOUKER_COMPANY_SETTING, YOUKER_SETTING_FILE_NAME_SETTING); + mSettings->setIniCodec("UTF-8"); + + + //judge has skin or not in /var/lib/youker-assistant-daemon/default/ + mSettings->beginGroup("Background"); + last_skin_path = mSettings->value("Path").toString(); + if(last_skin_path.isEmpty()) { + last_skin_path = ":/background/res/skin/1.png"; + mSettings->setValue("Path", last_skin_path); + } + else { + QStringList skinlist = this->filterSkin(); + QList::Iterator it = skinlist.begin(), itend = skinlist.end(); + bool flag = false; + for(;it != itend; it++) + { + if(*it == last_skin_path) { + flag = true; + break; + } + } + if (flag == false) { + last_skin_path = skinlist.at(0); + mSettings->setValue("Path", last_skin_path); + } + } + + mSettings->endGroup(); + mSettings->sync(); + main_skin_pixmap.load(last_skin_path); + + skin_center = NULL; + + home_page = NULL; + info_widget = NULL; + cleaner_widget = NULL; + setting_widget = NULL; + box_widget = NULL; + aboutDlg = NULL; + + auto_start = NULL; + upgrade_dialog = NULL; +// camera_manager = NULL; + + spreadGroup = NULL; + gatherGroup = NULL; + + home_action_widget = NULL; + info_action_widget = NULL; + cleaner_action_widget = NULL; + setting_action_widget = NULL; + box_action_widget = NULL; + + toolKits = new Toolkits(0, this->width(), this->height()); + + + shadow_widget = new ShadowWidget(this); + shadow_widget->setGeometry(rect()); +// shadow_widget->setColor(QColor(Qt::gray)); + shadow_widget->setColor(QColor("#e9eef0")); + + default_action_widget = new ActionWidget(this); + default_action_widget->setGeometry(QRect(0, 0, 900, 227)); + default_action_widget->setFixedHeight(227); + other_action_widget = new ActionWidget(this); + other_action_widget->setGeometry(QRect(0, -150, 900, 150)); + other_action_widget->setFixedHeight(150); + topStack = new QStackedWidget(other_action_widget); + topStack->setGeometry(other_action_widget->rect()); + + //设置在最底层,方便title_widget的显示 +// default_action_widget->lower(); + QPalette palette_back; + palette_back.setBrush(QPalette::Background, QBrush(QPixmap(last_skin_path))); + default_action_widget->setPalette(palette_back); + other_action_widget->setPalette(palette_back); + + tool_widget = new ToolWidget(this, this->arch, this->osName); + tool_widget->setGeometry(QRect(0, 227, 900, 47)); + tool_widget->setParentWindow(this); + connect(this, SIGNAL(chanegBoxToolStatus()), tool_widget, SLOT(showBoxTool())); + tool_widget->initConnect(); + + title_widget = new TitleWidget(this, this->arch, this->osName); + if (this->arch == "aarch64" || this->osName == "Kylin" || this->osName == "YHKylin") + title_widget->move(756, 0); + else { + title_widget->move(0, 0); + } + connect(title_widget, SIGNAL(closeApp()), this, SLOT(closeYoukerAssistant())); + title_widget->setParentWindow(this); + title_widget->initConnect(); + +// + login_widget = new LoginWidget(this); + if (this->arch == "aarch64" || this->osName == "Kylin" || this->osName == "YHKylin") + login_widget->hide(); + else { + login_widget->move(585, 0);//900 - login_widget(220) - right_align(15) = 665 + } + + default_content_widget = new ContentWidget(this); + default_content_widget->setGeometry(QRect(0, 274, 900, 326)); + default_content_widget->setFixedHeight(326); + other_content_widget = new ContentWidget(this); + other_content_widget->setGeometry(QRect(0, 600, 900, 403)); + other_content_widget->setFixedHeight(403); + bottomStack = new QStackedWidget(other_content_widget); + bottomStack->setGeometry(other_content_widget->rect()); +// top_grid_layout = NULL; +// bottom_grid_layout = NULL; + + main_menu = new KylinMenu(this); + main_menu->setParentWindow(this); + main_menu->initConnect(); + + this->initHomePage(); + this->initAnimation(); + + this->hide(); + this->startDbusDaemon(); +} + +MainWindow::~MainWindow() +{ + if (home_page != NULL) + { + delete home_page; + home_page = NULL; + } + if (info_widget != NULL) + { + delete info_widget; + info_widget = NULL; + } + if (cleaner_widget != NULL) + { + delete cleaner_widget; + cleaner_widget = NULL; + } + if (setting_widget != NULL) + { + delete setting_widget; + setting_widget = NULL; + } + if (box_widget != NULL) + { + delete box_widget; + box_widget = NULL; + } + if (setting_action_widget != NULL) + { + delete setting_action_widget; + setting_action_widget = NULL; + } +// if (sessioninterface != NULL) +// { +// delete sessioninterface; +// sessioninterface = NULL; +// } +// if (systeminterface != NULL) +// { +// delete systeminterface; +// systeminterface = NULL; +// } + if (sessioninterface) { + sessioninterface->deleteLater(); + } + if (systeminterface) { + systeminterface->deleteLater(); + } + ThreadPool::Instance()->deleteLater(); + if (aboutDlg != NULL) + { + delete aboutDlg; + aboutDlg = NULL; + } + if (toolKits != NULL) + { + delete toolKits; + toolKits = NULL; + } + if (mSettings != NULL) + { + mSettings->sync(); + delete mSettings; + mSettings = NULL; + } + + if(auto_start != NULL) + { + delete auto_start; + auto_start = NULL; + } +// if(camera_manager != NULL) +// { +// delete camera_manager; +// camera_manager = NULL; +// } + if(skin_center != NULL) + { + delete skin_center; + skin_center = NULL; + } + if(upgrade_dialog != NULL) + { + delete upgrade_dialog; + upgrade_dialog = NULL; + } +} + +QString MainWindow::accessOSName() +{ + + QString osname = ""; + QString tmp = ""; + + QFile osfile("/etc/os-release"); + if(osfile.exists()) { + if(!osfile.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "Can't open os-release!" << endl; + } + else { + while(!osfile.atEnd()) { + QByteArray line = osfile.readLine(); + QString str(line); + if (str.startsWith("NAME")) { + tmp = str; + break; + } + } + osfile.close(); + } + } + if(tmp.length() > 0 && tmp.contains("=")) { + osname = QString(tmp.split("=").at(1)).replace("\"", "").replace("\n","").trimmed(); + } + if(osname.length() > 0) { + return osname; + } + + osname = ""; + tmp = ""; + QFile ukfile("/etc/ubuntukylin-release"); + if(ukfile.exists()) { + if(!ukfile.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "Can't open ubuntukylin-release!" << endl; + } + else { + while(!ukfile.atEnd()) { + QByteArray line = ukfile.readLine(); + QString str(line); + if (str.startsWith("DISTRIB_DESCRIPTION")) { + tmp = str; + break; + } + } + ukfile.close(); + } + } + if(tmp.length() > 0 && tmp.contains("=")) { + osname = QString(tmp.split("=").at(1)).replace("\"", "").replace("\n","").trimmed(); + } + if(osname.length() > 0) { + return osname; + } + + osname = ""; + tmp = ""; + QFile lsbfile("/etc/lsb-release"); + if(lsbfile.exists()) { + if(!lsbfile.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "Can't open lsb-release!" << endl; + } + else { + while(!lsbfile.atEnd()) { + QByteArray line = lsbfile.readLine(); + QString str(line); + if (str.startsWith("DISTRIB_DESCRIPTION")) { + tmp = str; + break; + } + } + lsbfile.close(); + } + } + if(tmp.length() > 0 && tmp.contains("=")) { + osname = QString(tmp.split("=").at(1)).replace("\"", "").replace("\n","").trimmed(); + } + if(osname.length() > 0) { + return osname; + } + + return "Ubuntu Kylin"; +} + +bool MainWindow::deleteFile(QString filename) +{ + bool result = systeminterface->delete_file_qt(filename); + return result; +} + +bool MainWindow::CopyFile(QString filename) +{ + bool result = systeminterface->copy_file_qt(filename); + return result; +} + +QStringList MainWindow::filterSkin() +{ + QStringList skinlist; + QString path = "/var/lib/youker-assistant-daemon/default/"; + QString path2 = "/var/lib/youker-assistant-daemon/custom/"; + QDir picdir(path); + picdir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + picdir.setSorting(QDir::Size | QDir::Reversed); + QDir picdir2(path2); + picdir2.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + picdir2.setSorting(QDir::Size | QDir::Reversed); + QStringList filters; + filters << "*.jpg" << "*.png"; + picdir.setNameFilters(filters); + picdir2.setNameFilters(filters); + QFileInfoList list = picdir.entryInfoList(); + QFileInfoList list2 = picdir2.entryInfoList(); + if(list.size() < 1 && list2.size() < 1) { + skinlist << ":/background/res/skin/1.png" << ":/background/res/skin/2.png" << ":/background/res/skin/3.png" << ":/background/res/skin/4.png"; +// return ":/background/res/skin/1.png"; + } + else if(list.size() > 0 && list2.size() > 0) { + for (int j = 0; j < list.size(); ++j) { + QFileInfo fileInfo = list.at(j); + skinlist << path + fileInfo.fileName(); + } + for (int k = 0; k < list2.size(); ++k) { + QFileInfo fileInfo = list2.at(k); + skinlist << path2 + fileInfo.fileName(); + } + skinlist << ":/background/res/skin/1.png" << ":/background/res/skin/2.png" << ":/background/res/skin/3.png" << ":/background/res/skin/4.png"; + } + else { + if(list.size() > 0) { + for (int j = 0; j < list.size(); ++j) { + QFileInfo fileInfo = list.at(j); + skinlist << path + fileInfo.fileName(); + } + skinlist << ":/background/res/skin/1.png" << ":/background/res/skin/2.png" << ":/background/res/skin/3.png" << ":/background/res/skin/4.png"; + } + else if(list2.size() > 0) { + for (int m = 0; m < list2.size(); ++m) { + QFileInfo fileInfo = list2.at(m); + skinlist << path2 + fileInfo.fileName(); + } + skinlist << ":/background/res/skin/1.png" << ":/background/res/skin/2.png" << ":/background/res/skin/3.png" << ":/background/res/skin/4.png"; + } +// QFileInfo fileInfo = list.at(0); +// return path + fileInfo.fileName(); + } + return skinlist; +} + +void MainWindow::initAnimation() +{ + QPoint origPoint(0, 227); + QPoint needPoint(0, 150); + QPoint origPoint1(0, 0); + QPoint needPoint1(0, -227); + QPoint origPoint2(0, -150); + QPoint needPoint2(0, 0); + + QPoint origPoint3(0, 274); + QPoint needPoint3(0, 600); + QPoint origPoint4(0, 600); + QPoint needPoint4(0, 197); + + QPropertyAnimation *mainActionAnimation = new QPropertyAnimation(default_action_widget, "pos"); + mainActionAnimation->setDuration(500); + mainActionAnimation->setStartValue(origPoint1); + mainActionAnimation->setEndValue(needPoint1); + + QPropertyAnimation *mainActionAnimation2 = new QPropertyAnimation(other_action_widget, "pos"); + mainActionAnimation2->setDuration(500); + mainActionAnimation2->setStartValue(origPoint2); + mainActionAnimation2->setEndValue(needPoint2); + + QPropertyAnimation *mainToolAnimation = new QPropertyAnimation(tool_widget, "pos"); + mainToolAnimation->setDuration(500); + mainToolAnimation->setStartValue(origPoint); + mainToolAnimation->setEndValue(needPoint); + + QPropertyAnimation *mainContentAnimation = new QPropertyAnimation(default_content_widget, "pos"); + mainContentAnimation->setDuration(500); + mainContentAnimation->setStartValue(origPoint3); + mainContentAnimation->setEndValue(needPoint3); + + QPropertyAnimation *mainContentAnimation2 = new QPropertyAnimation(other_content_widget, "pos"); + mainContentAnimation2->setDuration(500); + mainContentAnimation2->setStartValue(origPoint4); + mainContentAnimation2->setEndValue(needPoint4); + + QPropertyAnimation *m_toTrans = new QPropertyAnimation(shadow_widget, "opacity"); + m_toTrans->setDuration(200); + m_toTrans->setStartValue(1); + m_toTrans->setEndValue(0); + + spreadGroup = new QParallelAnimationGroup(this); + spreadGroup->addAnimation(mainActionAnimation); + spreadGroup->addAnimation(mainActionAnimation2); + spreadGroup->addAnimation(mainToolAnimation); + spreadGroup->addAnimation(mainContentAnimation); + spreadGroup->addAnimation(mainContentAnimation2); + spreadGroup->addAnimation(m_toTrans); + + QPropertyAnimation *mainActionBackAnimation2 = new QPropertyAnimation(other_action_widget, "pos"); + mainActionBackAnimation2->setDuration(500); + mainActionBackAnimation2->setStartValue(needPoint2); + mainActionBackAnimation2->setEndValue(origPoint2); + + QPropertyAnimation *mainActionBackAnimation = new QPropertyAnimation(default_action_widget, "pos"); + mainActionBackAnimation->setDuration(500); + mainActionBackAnimation->setStartValue(needPoint1); + mainActionBackAnimation->setEndValue(origPoint1); + + QPropertyAnimation *mainToolBackAnimation = new QPropertyAnimation(tool_widget, "pos"); + mainToolBackAnimation->setDuration(500); + mainToolBackAnimation->setStartValue(needPoint); + mainToolBackAnimation->setEndValue(origPoint); + + + QPropertyAnimation *mainContentBackAnimation = new QPropertyAnimation(default_content_widget, "pos"); + mainContentBackAnimation->setDuration(500); + mainContentBackAnimation->setStartValue(needPoint3); + mainContentBackAnimation->setEndValue(origPoint3); + + QPropertyAnimation *mainContentBackAnimation2 = new QPropertyAnimation(other_content_widget, "pos"); + mainContentBackAnimation2->setDuration(500); + mainContentBackAnimation2->setStartValue(needPoint4); + mainContentBackAnimation2->setEndValue(origPoint4); + + QPropertyAnimation *m_toGray = new QPropertyAnimation(shadow_widget, "opacity"); + m_toGray->setDuration(200); + m_toGray->setStartValue(0); + m_toGray->setEndValue(1); + + gatherGroup = new QParallelAnimationGroup(this); + gatherGroup->addAnimation(mainActionBackAnimation); + gatherGroup->addAnimation(mainActionBackAnimation2); + gatherGroup->addAnimation(mainToolBackAnimation); + gatherGroup->addAnimation(mainContentBackAnimation); + gatherGroup->addAnimation(mainContentBackAnimation2); + gatherGroup->addAnimation(m_toGray); + + connect(spreadGroup, SIGNAL(finished()), this, SLOT(upAnimFinished())); + connect(gatherGroup, SIGNAL(finished()), this, SLOT(closeAnimFinished())); +} + +void MainWindow::upAnimFinished() +{ + tool_widget->show(); + shadow_widget->hide(); + if(title_widget->isHidden()) + title_widget->show(); + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin") + { + if(status == BOXPAGE && login_widget->isHidden()) { + login_widget->show(); + } + else { + login_widget->hide(); + } + } +} + +void MainWindow::closeAnimFinished() +{ + tool_widget->show(); + if(title_widget->isHidden()) + title_widget->show(); + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin" && login_widget->isHidden()) + { + login_widget->show(); + } + shadow_widget->hide(); +} + +void MainWindow::setTranslator(QTranslator* translator) +{ + this->translator = translator; +} + +void MainWindow::changeLanguage(LANGUAGE language) +{ + if(current_language == language) + { + return; + } + current_language = language; + + switch(language) + { + case YOUKER_EN: + translator->load(QString(":/qmfile/res/qm/youker-assistant_es.qm")); + break; + + case YOUKER_ZH_CN: + translator->load(QString(":/qmfile/res/qm/youker-assistant_zh_CN.qm")); + break; + + case YOUKER_ES: + translator->load(QString(":/qmfile/res/qm/youker-assistant_es.qm")); + break; + + default: + translator->load(QString(":/qmfile/res/qm/youker-assistant_zh_CN.qm")); + } + +// title_widget->translateLanguage(); +// kill_mummy_widget->translateLanguage(); +// main_menu->translateActions(); +// character_widget->translateLanguage(); +// login_dialog->translateLanguage(); +// register_widget->translateLanguage(); +// character_widget->translateLanguage(); +// about_us_dialog->translateLanguage(); +// setting_dialog->translateLanguage(); +// skin_widget->translateLanguage(); +// system_tray->translateLanguage(); +} + +void MainWindow::displayMainWindow(/*int count*/) +{ + this->battery = sessioninterface->judge_power_is_exists_qt(); + this->sensor = systeminterface->judge_sensors_exists_qt(); + login_widget->setSessionDbusProxy(sessioninterface); + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin") + sessioninterface->check_user_qt(); + connect(sessioninterface, SIGNAL(ssoSuccessSignal(QString, QString)), login_widget, SLOT(showLoginInfo(QString,QString))); + connect(sessioninterface, SIGNAL(ssoLoginLogoutSignal(bool)), login_widget, SLOT(showLoginAndLogoutStatus(bool))); + home_action_widget->setSessionDbusProxy(sessioninterface); + home_action_widget->setSystemDbusProxy(systeminterface); + home_action_widget->enableSanButton(); + connect(sessioninterface, SIGNAL(isScanning(QString)), home_action_widget, SLOT(getScanResult(QString))); + connect(sessioninterface, SIGNAL(finishScanWork(QString)), home_action_widget, SLOT(finishScanResult(QString))); + connect(sessioninterface, SIGNAL(tellScanResult(QString,QString)) ,home_action_widget, SLOT(getScanAllResult(QString,QString))); + connect(systeminterface, SIGNAL(finishCleanWorkMain(QString/*, QString*/)), home_action_widget, SLOT(getCleanResult(QString/*, QString*/))); + connect(systeminterface, SIGNAL(finishCleanWorkMainError(QString)), home_action_widget, SLOT(finishCleanError(QString))); + connect(systeminterface, SIGNAL(quickCleanProcess(QString,QString)), home_action_widget, SLOT(getCleaningMessage(QString,QString))); + home_page->setSessionDbusProxy(sessioninterface); + home_page->setSystemDbusProxy(systeminterface); + this->initOtherPages(); + +// if (this->isHidden()) { + int windowWidth, windowHeight = 0; + if (this->display_count < 2) { + windowWidth = QApplication::desktop()->width(); + windowHeight = QApplication::desktop()->height(); + this->move((windowWidth - this->width()) / 2,(windowHeight - this->height()) / 2); + } + else { + /*this->setGeometry(QApplication::desktop()->screenGeometry(1)); + int a_width = 0; + for (int i=0;iscreenGeometry(i).width();//QRect QApplication::desktop->screenGeometry(1);根据当前的屏幕序号获取屏幕宽高等属性 + } + windowWidth = QApplication::desktop()->width() - a_width;//QApplication::desktop()->width();获取虚拟屏幕全宽,注意这个比较猛,是获取的总宽度,对于横向扩展屏来说,也就是 屏幕1+ 屏幕2 + ... 的宽度 + windowHeight = QApplication::desktop()->screenGeometry(1).height(); + qDebug() << windowWidth;//3286 1024 1920 1366 + qDebug() << windowHeight;//1080 768 1080 768 + qDebug() << this->width();//900 + qDebug() << this->height();//600 + this->move((windowWidth - this->width()) / 2,(windowHeight - this->height()) / 2);*/ + windowWidth = QApplication::desktop()->screenGeometry(0).width(); + windowHeight = QApplication::desktop()->screenGeometry(0).height(); + this->move((windowWidth - this->width()) / 2,(windowHeight - this->height()) / 2); + } + + this->show(); + this->raise(); +// QTimer::singleShot(100, this, SLOT(startDbusDaemon())); +// } +// else { +// this->hide(); +// } +} + +inline bool isRunningInstalled() { + static bool installed = (QCoreApplication::applicationDirPath() == + QDir(("/usr/bin")).canonicalPath()); + return installed; +} + +inline QString getAppDirectory() { + if (isRunningInstalled()) { + return QString("/var/lib/youker-assistant-daemon/"); + } else { + return QString(QCoreApplication::applicationDirPath()); + } +} + +void MainWindow::startDbusDaemon() +{ + sessioninterface = new SessionDispatcher; + systeminterface = new SystemDispatcher; + QThread *sessionThread = ThreadPool::Instance()->createNewThread(); + sessioninterface->moveToThread(sessionThread); + sessionThread->start(); + QThread *systemThread = ThreadPool::Instance()->createNewThread(); + systeminterface->moveToThread(systemThread); + connect(systemThread, SIGNAL(started()), systeminterface, SLOT(initData())); + +// connect(systeminterface, &SystemDispatcher::dbusInitFinished, this, [=] {dlg.close();this->displayMainWindow(); +// }); + connect(systeminterface, SIGNAL(dbusInitFinished()), this, SLOT(displayMainWindow()));//数据获取完毕后,告诉界面去更新数据后显示界面 + systemThread->start(); + + + /*sessioninterface = new SessionDispatcher(this); + systeminterface = new SystemDispatcher(this); +// this->desktop = sessioninterface->access_current_desktop_qt(); +// this->osName = systeminterface->get_os_name_qt(); +// this->machine = sessioninterface->access_current_machine_qt();//x86_64 + this->battery = sessioninterface->judge_power_is_exists_qt(); + this->sensor = systeminterface->judge_sensors_exists_qt(); + login_widget->setSessionDbusProxy(sessioninterface); + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin") + sessioninterface->check_user_qt(); + connect(sessioninterface, SIGNAL(ssoSuccessSignal(QString, QString)), login_widget, SLOT(showLoginInfo(QString,QString))); + connect(sessioninterface, SIGNAL(ssoLoginLogoutSignal(bool)), login_widget, SLOT(showLoginAndLogoutStatus(bool))); + home_action_widget->setSessionDbusProxy(sessioninterface); + home_action_widget->setSystemDbusProxy(systeminterface); + home_action_widget->enableSanButton(); + connect(sessioninterface, SIGNAL(isScanning(QString)), home_action_widget, SLOT(getScanResult(QString))); + connect(sessioninterface, SIGNAL(finishScanWork(QString)), home_action_widget, SLOT(finishScanResult(QString))); + connect(sessioninterface, SIGNAL(tellScanResult(QString,QString)) ,home_action_widget, SLOT(getScanAllResult(QString,QString))); + connect(systeminterface, SIGNAL(finishCleanWorkMain(QString)), home_action_widget, SLOT(getCleanResult(QString))); + connect(systeminterface, SIGNAL(finishCleanWorkMainError(QString)), home_action_widget, SLOT(finishCleanError(QString))); + connect(systeminterface, SIGNAL(quickCleanProcess(QString,QString)), home_action_widget, SLOT(getCleaningMessage(QString,QString))); + home_page->setSessionDbusProxy(sessioninterface); + home_page->setSystemDbusProxy(systeminterface); + this->initOtherPages();*/ +} + +void MainWindow::initOtherPages() +{ + if(cleaner_action_widget == NULL) + cleaner_action_widget = new CleanerActionWidget(this); + topStack->addWidget(cleaner_action_widget); + if(info_action_widget == NULL) + info_action_widget = new InfoActionWidget(this); + topStack->addWidget(info_action_widget); + if(setting_action_widget == NULL) + setting_action_widget = new SettingActionWidget(); + topStack->addWidget(setting_action_widget); + if(box_action_widget == NULL) + box_action_widget = new BoxActionWidget(this); + topStack->addWidget(box_action_widget); + + if(cleaner_widget == NULL) + cleaner_widget = new CleanerWidget(); + cleaner_widget->setSessionDbusProxy(sessioninterface); + cleaner_widget->setSystemDbusProxy(systeminterface); + cleaner_widget->setToolKits(toolKits); + cleaner_widget->setParentWindow(this); + cleaner_widget->initUI(last_skin_path); + connect(cleaner_action_widget, SIGNAL(showDetailData()),cleaner_widget, SLOT(displayDetailPage())); + connect(cleaner_action_widget, SIGNAL(showMainData()),cleaner_widget, SLOT(displayMainPage())); + connect(cleaner_action_widget, SIGNAL(sendCleanSignal()),cleaner_widget, SIGNAL(transCleanSignal())); + connect(systeminterface, SIGNAL(sendCleanOverSignal()), cleaner_widget, SLOT(displayMainPage())); + connect(systeminterface, SIGNAL(sendCleanOverSignal()), cleaner_action_widget, SLOT(displayOrgPage())); + //kobe + connect(systeminterface, SIGNAL(policykitCleanSignal(bool)), cleaner_action_widget, SLOT(receivePolicyKitSignal(bool))); + connect(systeminterface, SIGNAL(sendCleanOverSignal()), cleaner_action_widget, SLOT(showCleanOverStatus())); + connect(systeminterface, SIGNAL(tellCleanerMainData(QStringList)), cleaner_action_widget, SLOT(showCleanerData(QStringList))); + connect(systeminterface, SIGNAL(tellCleanerMainStatus(QString, QString)), cleaner_action_widget, SLOT(showCleanerStatus(QString, QString))); + connect(systeminterface, SIGNAL(sendCleanErrorSignal(QString)), cleaner_action_widget, SLOT(showCleanerError(QString))); + connect(sessioninterface, SIGNAL(tellCleanerDetailStatus(QString)), cleaner_action_widget, SLOT(showCleanReciveStatus(QString))); + connect(sessioninterface, SIGNAL(tellCleanerDetailError(QString)), cleaner_action_widget, SLOT(showCleanReciveError(QString))); + + + connect(cleaner_action_widget, SIGNAL(sendScanSignal()),cleaner_widget, SIGNAL(transScanSignal())); + connect(cleaner_widget, SIGNAL(tranActionAnimaitonSignal()),cleaner_action_widget, SLOT(displayAnimation())); + connect(cleaner_widget, SIGNAL(tranScanOverSignal(bool)),cleaner_action_widget, SLOT(accordScanOverStatusToChange(bool))); + bottomStack->addWidget(cleaner_widget); + + if(info_widget == NULL) + info_widget = new InfoWidget(this->arch); + info_widget->setSessionDbusProxy(sessioninterface); + info_widget->setSystemDbusProxy(systeminterface); + info_widget->initUI(this->battery, this->sensor); + bottomStack->addWidget(info_widget); + + if(setting_widget == NULL) + setting_widget = new SettingWidget(this->desktop, this->battery); + setting_widget->setParentWindow(this); + setting_widget->setSessionDbusProxy(sessioninterface); + setting_widget->setSystemDbusProxy(systeminterface); + setting_widget->initUI(last_skin_path); + connect(setting_widget, SIGNAL(changeActionPage(int)), setting_action_widget, SLOT(displayActionSubPage(int))); + connect(setting_action_widget, SIGNAL(notifyContentPageToMain()), setting_widget, SLOT(displaySettingHomePage())); + bottomStack->addWidget(setting_widget); + + if(box_widget == NULL) + box_widget = new BoxWidget(this, this->arch, this->osName, getAppDirectory()); + box_widget->setSessionDbusProxy(sessioninterface); + connect(box_widget, SIGNAL(sendSubIndex(int)), this, SLOT(displaySubPage(int))); + bottomStack->addWidget(box_widget); +} + +int MainWindow::getCurrentBackgroundIndex() +{ + int index = 1; + mSettings->beginGroup("Background"); + QString cur_skin_path = mSettings->value("Path").toString(); + if(!cur_skin_path.isEmpty()) { + int start_pos = cur_skin_path.lastIndexOf("/") + 1; + int end_pos = cur_skin_path.length(); + index = cur_skin_path.mid(start_pos, end_pos-start_pos).replace(".png", "").toInt(); + } + mSettings->endGroup(); + mSettings->sync(); + return index; +} + +QString MainWindow::getCurrentBackgroundName() +{ + QString cur_skin_path; + mSettings->beginGroup("Background"); + cur_skin_path = mSettings->value("Path").toString(); + if(!cur_skin_path.isEmpty()) { + int start_pos = cur_skin_path.lastIndexOf("/") + 1; + int end_pos = cur_skin_path.length(); + cur_skin_path = cur_skin_path.mid(start_pos, end_pos-start_pos); + } + mSettings->endGroup(); + mSettings->sync(); + return cur_skin_path; +} + +QString MainWindow::getCurrentBackgroundAbsName() +{ + QString cur_skin_path; + mSettings->beginGroup("Background"); + cur_skin_path = mSettings->value("Path").toString(); + mSettings->endGroup(); + mSettings->sync(); + return cur_skin_path; +} + +void MainWindow::restoreSkin() +{ + if (main_skin_pixmap.isDetached()) + { + main_skin_pixmap.detach(); + } + main_skin_pixmap.load(last_skin_path); + QPalette palette_back; + palette_back.setBrush(QPalette::Background, main_skin_pixmap); + default_action_widget->setPalette(palette_back); + other_action_widget->setPalette(palette_back); +} + + +void MainWindow::changeSkin(QString pciture) +{ + if (main_skin_pixmap.isDetached()) + { + main_skin_pixmap.detach(); + } + last_skin_path = pciture; + main_skin_pixmap.load(pciture); + QPalette palette; + palette.setBrush(QPalette::Background, main_skin_pixmap); + default_action_widget->setPalette(palette); + other_action_widget->setPalette(palette); + + mSettings->beginGroup("Background"); + mSettings->setValue("Path", pciture); + mSettings->endGroup(); + mSettings->sync(); + + if(auto_start != NULL) { + auto_start->resetTitleSkin(last_skin_path); + } +// if(camera_manager != NULL) { +// camera_manager->resetTitleSkin(last_skin_path); +// } + if(setting_widget != NULL) { + setting_widget->resetSkin(last_skin_path); + } + if(cleaner_widget != NULL) { + cleaner_widget->resetSkin(last_skin_path); + } + if(aboutDlg != NULL) { + aboutDlg->resetTitleSkin(last_skin_path); + } + if(upgrade_dialog != NULL) { + upgrade_dialog->resetTitleSkin(last_skin_path); + } +} + +void MainWindow::reViewThePointSkin(QString pciture) +{ + if (review_skin_pixmap.isDetached()) + { + review_skin_pixmap.detach(); + } + review_skin_pixmap.load(pciture); + QPalette palette_back; + palette_back.setBrush(QPalette::Background, review_skin_pixmap); + default_action_widget->setPalette(palette_back); + other_action_widget->setPalette(palette_back); +} + +void MainWindow::reViewTheOrgSkin() +{ + if (review_skin_pixmap.isDetached()) + { + review_skin_pixmap.detach(); + } + review_skin_pixmap.load(last_skin_path); + QPalette palette_back; + palette_back.setBrush(QPalette::Background, review_skin_pixmap); + default_action_widget->setPalette(palette_back); + other_action_widget->setPalette(palette_back); +} + +void MainWindow::showMainMenu() { + if (this->arch == "aarch64" || this->osName == "Kylin" || this->osName == "YHKylin") + { + QPoint p = rect().topRight(); + p.setX(p.x() - 180); + p.setY(p.y() + 22); + main_menu->exec(this->mapToGlobal(p)); + } + else + { + QPoint p = rect().topLeft(); + p.setX(p.x() + 107);//104 + p.setY(p.y() + 22); + main_menu->exec(this->mapToGlobal(p)); + } + +// //向上弹出menu +// QPoint pos; +// pos.setX(0); +// pos.setY(-main_menu->sizeHint().height()); +// main_menu->exec(title_widget->mapToGlobal(pos)); +} + +void MainWindow::closeYoukerAssistant() { +// qApp->exit(); + QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity"); + animation->setDuration(500); + animation->setStartValue(1); + animation->setEndValue(0); + animation->start(); + connect(animation, SIGNAL(finished()), this, SLOT(close())); +} + +void MainWindow::closeEvent(QCloseEvent *) +{ +// QApplication::quit(); + qApp->exit(); +} + +void MainWindow::setCurrentPageIndex(int index) +{ + if(index == 0) + { + if (this->arch == "aarch64" || this->osName == "Kylin" || this->osName == "YHKylin") + login_widget->hide(); + if (status != HOMEPAGE) { + statusFlag = true; + shadow_widget->show(); + tool_widget->hide(); + if(title_widget->isVisible()) + title_widget->hide(); + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin" && login_widget->isVisible()) + { + login_widget->hide(); + } + gatherGroup->start(); + status = HOMEPAGE; + } + else + statusFlag = false; + } + else if(index == 1) + { + if (this->arch == "aarch64" || this->osName == "Kylin" || this->osName == "YHKylin") + login_widget->hide(); + if (status == HOMEPAGE) { + statusFlag = true; + } + else { + statusFlag = false; + } + if (status != CLEANPAGE && statusFlag) { + shadow_widget->show(); + tool_widget->hide(); + if(title_widget->isVisible()) + title_widget->hide(); + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin" && login_widget->isVisible()) { + login_widget->hide(); + } +// topStack->setCurrentIndex(0); +// bottomStack->setCurrentIndex(0); + topStack->setCurrentWidget(cleaner_action_widget); + bottomStack->setCurrentWidget(cleaner_widget); + spreadGroup->start(); + status = CLEANPAGE; + } + else { + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin" && login_widget->isVisible()) { + login_widget->hide(); + } +// topStack->setCurrentIndex(0); +// bottomStack->setCurrentIndex(0); + topStack->setCurrentWidget(cleaner_action_widget); + bottomStack->setCurrentWidget(cleaner_widget); + } + } + else if(index == 2) + { + if (this->arch == "aarch64" || this->osName == "Kylin" || this->osName == "YHKylin" ) + login_widget->hide(); + if (status == HOMEPAGE) { + statusFlag = true; + } + else { + statusFlag = false; + } + if (status != INFOPAGE && statusFlag) { + shadow_widget->show(); + tool_widget->hide(); + if(title_widget->isVisible()) + title_widget->hide(); + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin" && login_widget->isVisible()) { + login_widget->hide(); + } +// topStack->setCurrentIndex(1); +// bottomStack->setCurrentIndex(1); + topStack->setCurrentWidget(info_action_widget); + bottomStack->setCurrentWidget(info_widget); + spreadGroup->start(); + status = INFOPAGE; + } + else { + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin" && login_widget->isVisible()) { + login_widget->hide(); + } +// topStack->setCurrentIndex(1); +// bottomStack->setCurrentIndex(1); + topStack->setCurrentWidget(info_action_widget); + bottomStack->setCurrentWidget(info_widget); + } + } + else if(index == 3) + { + if (status == HOMEPAGE) + statusFlag = true; + else + statusFlag = false; + if (this->arch == "aarch64" || this->osName == "Kylin" || this->osName == "YHKylin" ) + { + login_widget->hide(); + if (status != BOXPAGE && statusFlag) { + shadow_widget->show(); + tool_widget->hide(); + if(title_widget->isVisible()) + title_widget->hide(); + // topStack->setCurrentIndex(3); + // bottomStack->setCurrentIndex(3); + topStack->setCurrentWidget(box_action_widget); + bottomStack->setCurrentWidget(box_widget); + spreadGroup->start(); + status = BOXPAGE; + } + else { + // topStack->setCurrentIndex(3); + // bottomStack->setCurrentIndex(3); + topStack->setCurrentWidget(box_action_widget); + bottomStack->setCurrentWidget(box_widget); + } + } + else + { + if (status != SETTINGPAGE && statusFlag) { + shadow_widget->show(); + tool_widget->hide(); + if(title_widget->isVisible()) + title_widget->hide(); + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin" && login_widget->isVisible()) { + login_widget->hide(); + } + // topStack->setCurrentIndex(2); + // bottomStack->setCurrentIndex(2); + topStack->setCurrentWidget(setting_action_widget); + bottomStack->setCurrentWidget(setting_widget); + spreadGroup->start(); + status = SETTINGPAGE; + } + else { + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin" && login_widget->isVisible()) { + login_widget->hide(); + } + // topStack->setCurrentIndex(2); + // bottomStack->setCurrentIndex(2); + topStack->setCurrentWidget(setting_action_widget); + bottomStack->setCurrentWidget(setting_widget); + } + } + } + else if(index == 4) + { + if (this->arch != "aarch64" && this->osName != "Kylin" && this->osName != "YHKylin") + { + if (status == HOMEPAGE) + statusFlag = true; + else + statusFlag = false; + if (status != BOXPAGE && statusFlag) { + shadow_widget->show(); + tool_widget->hide(); + if(title_widget->isVisible()) + title_widget->hide(); + if (login_widget->isVisible()) { + login_widget->hide(); + } + // topStack->setCurrentIndex(3); + // bottomStack->setCurrentIndex(3); + topStack->setCurrentWidget(box_action_widget); + bottomStack->setCurrentWidget(box_widget); + spreadGroup->start(); + status = BOXPAGE; + } + else { + if (login_widget->isHidden()) { + login_widget->show(); + } + // topStack->setCurrentIndex(3); + // bottomStack->setCurrentIndex(3); + topStack->setCurrentWidget(box_action_widget); + bottomStack->setCurrentWidget(box_widget); + } + } + } +} + +void MainWindow::initHomePage() +{ + if(home_action_widget == NULL) + { +// if(top_grid_layout == NULL ) + QGridLayout *home_top_grid_layout = new QGridLayout(); +// home_action_widget = new HomeActionWidget(this, mSettings); + home_action_widget = new HomeActionWidget(0, mSettings); + home_top_grid_layout->addWidget(home_action_widget,0,0); + default_action_widget->setLayout(home_top_grid_layout); + home_top_grid_layout->setSpacing(0); + home_top_grid_layout->setContentsMargins(0, 0, 0, 0); + } + + if(home_page == NULL) + { +// if( bottom_grid_layout == NULL ) + QGridLayout *home_bottom_grid_layout = new QGridLayout(); +// home_page = new HomePage(0/*, version*/); + home_page = new HomePage(this, this->arch, this->osName/*, version*/); + connect(home_page, SIGNAL(sendSubIndex(int)), this, SLOT(displaySubPage(int))); + home_page->setParentWindow(this); + home_page->initUI(); + home_page->initConnect(); + + home_bottom_grid_layout->addWidget(home_page,0,0); + default_content_widget->setLayout(home_bottom_grid_layout); + home_bottom_grid_layout->setSpacing(0); + home_bottom_grid_layout->setContentsMargins(0, 0, 0, 0); + } +} + +void MainWindow::openSkinCenter() { + if(skin_center == NULL) { + skin_center = new SkinCenter(0, last_skin_path, this->arch, this->osName);//20161228 + skin_center->setParentWindow(this); + skin_center->initSysBackgroundList(); + int w_x = this->frameGeometry().topLeft().x() + (900 / 2) - (442 / 2); + int w_y = this->frameGeometry().topLeft().y() + (600 /2) - (340 / 2); + skin_center->move(w_x, w_y); + skin_center->show(); + skin_center->raise(); + } + else { + int w_x = this->frameGeometry().topLeft().x() + (900 / 2) - (442 / 2); + int w_y = this->frameGeometry().topLeft().y() + (600 /2) - (326 / 2); + skin_center->move(w_x, w_y); + skin_center->show(); + skin_center->raise(); + } +} + +void MainWindow::openUpgradePage(/*QStringList version_list*/) +{ + int w_x = this->frameGeometry().topLeft().x() + (900 / 2) - (334 / 2); + int w_y = this->frameGeometry().topLeft().y() + (600 /2) - (470 / 2); + if(upgrade_dialog == NULL) + { +// upgrade_dialog = new UpgradeDialog(0, version_list.at(2), last_skin_path); + upgrade_dialog = new UpgradeDialog(0, /*this->version, */last_skin_path, this->arch, this->osName);//20161228 + upgrade_dialog->setSystemDbusProxy(systeminterface); + upgrade_dialog->setSessionDbusProxy(sessioninterface); + connect(home_page, SIGNAL(sendOpenUpgrade()), this, SLOT(openUpgradePageAgain())); + connect(upgrade_dialog, SIGNAL(showBackendBtnSignal(bool)), home_page, SLOT(displayBackedBtn(bool))); + connect(upgrade_dialog,SIGNAL(close_signal()), this, SLOT(closeYoukerAssistant())); + connect(systeminterface,SIGNAL(get_fetch_signal(QString, QStringList)),upgrade_dialog,SLOT(receiveFetchSignal(QString, QStringList))); + connect(systeminterface,SIGNAL(get_apt_signal(QString, QStringList)),upgrade_dialog,SLOT(receiveAptSignal(QString, QStringList))); + connect(sessioninterface,SIGNAL(receive_source_list_signal(bool)),upgrade_dialog,SLOT(receiveCheckResultSignal(bool))); + upgrade_dialog->move(w_x, w_y); + upgrade_dialog->show(); + upgrade_dialog->raise(); + upgrade_dialog->startAccessData(); + } + else { +// upgrade_dialog->resetVersionNumber(version_list); + upgrade_dialog->move(w_x, w_y); + upgrade_dialog->show(); + upgrade_dialog->raise(); + home_page->hideBackedBtn(); +// upgrade_dialog->startAccessData(); + } +} + +void MainWindow::openUpgradePageAgain() +{ + int w_x = this->frameGeometry().topLeft().x() + (900 / 2) - (334 / 2); + int w_y = this->frameGeometry().topLeft().y() + (600 /2) - (470 / 2); + upgrade_dialog->move(w_x, w_y); + upgrade_dialog->show(); + upgrade_dialog->raise(); +} + +void MainWindow::displaySubPage(int index) +{ + if(index == 0) + { + if(auto_start == NULL) { + auto_start = new AutoStartWidget(0, sessioninterface, last_skin_path); + connect(sessioninterface, SIGNAL(tellAutoModel(QStringList)), auto_start, SLOT(readyReciveData(QStringList))); + connect(sessioninterface, SIGNAL(showAutoModel()), auto_start, SLOT(readyShowUI())); + auto_start->initData(); + int w_x = this->frameGeometry().topLeft().x() + (900 / 2) - (560 / 2); + int w_y = this->frameGeometry().topLeft().y() + (600 /2) - (398 / 2); + auto_start->move(w_x, w_y); + auto_start->show(); + auto_start->raise(); + } + else { + int w_x = this->frameGeometry().topLeft().x() + (900 / 2) - (560 / 2); + int w_y = this->frameGeometry().topLeft().y() + (600 /2) - (398 / 2); + auto_start->move(w_x, w_y); + auto_start->show(); + auto_start->raise(); + } + } + + else if(index == 1) + { + //CameraManager *camera_manager = new CameraManager(0, sessioninterface, last_skin_path); + //int w_x = this->frameGeometry().topLeft().x() + (900 / 2) - (622 / 2); + //int w_y = this->frameGeometry().topLeft().y() + (600 /2) - (480 / 2); + //camera_manager->move(w_x, w_y); + //camera_manager->exec(); +// if(camera_manager == NULL) { +// camera_manager = new CameraManager(0, sessioninterface, last_skin_path); +// int w_x = this->frameGeometry().topLeft().x() + (900 / 2) - (622 / 2); +// int w_y = this->frameGeometry().topLeft().y() + (600 /2) - (480 / 2); +// camera_manager->move(w_x, w_y); +// camera_manager->exec(); +// } +// else { +// int w_x = this->frameGeometry().topLeft().x() + (900 / 2) - (622 / 2); +// int w_y = this->frameGeometry().topLeft().y() + (600 /2) - (480 / 2); +// camera_manager->move(w_x, w_y); +// camera_manager->exec(); +// } + } +} + +void MainWindow::newFeatures() +{ + +} + +void MainWindow::setupConfigure() +{ + +} + +void MainWindow::aboutUs() +{ + int w_x = this->frameGeometry().topLeft().x() + (900 / 2) - (442 / 2); + int w_y = this->frameGeometry().topLeft().y() + (600 /2) - (326 / 2); + if(aboutDlg == NULL) + { + aboutDlg = new AboutDialog(0, /*version, */last_skin_path, this->arch, this->osName); + aboutDlg->move(w_x, w_y); + aboutDlg->show(); + aboutDlg->raise(); + } + else { + aboutDlg->move(w_x, w_y); + aboutDlg->show(); + aboutDlg->raise(); + } +} + + +void MainWindow::mousePressEvent(QMouseEvent *event) +{ +// if(event->button() == Qt::LeftButton) +// { +// mouse_press = true; +// drag_pos = event->globalPos() - this->frameGeometry().topLeft(); +// event->accept(); +// } + if(event->button() == Qt::LeftButton) + { + mouse_press = true; + drag_pos = event->globalPos() - pos(); + } +} + +void MainWindow::mouseReleaseEvent(QMouseEvent *) +{ + mouse_press = false; + setWindowOpacity(1); +} + +void MainWindow::mouseMoveEvent(QMouseEvent *event) +{ + if(mouse_press) + { + QPoint move_pos = event->globalPos(); + move(move_pos - drag_pos); + setWindowOpacity(0.9); +// event->accept(); + } +} + +//void MainWindow::paintEvent(QPaintEvent *event) +//{ +// QPainterPath path; +// path.setFillRule(Qt::WindingFill); +// path.addRect(10, 10, this->width()-20, this->height()-20); + +// QPainter painter(this); +// painter.setRenderHint(QPainter::Antialiasing, true); +// painter.fillPath(path, QBrush(Qt::white)); + +// QColor color(0, 0, 0, 50); +// for(int i=0; i<10; i++) +// { +// QPainterPath path; +// path.setFillRule(Qt::WindingFill); +// path.addRect(10-i, 10-i, this->width()-(10-i)*2, this->height()-(10-i)*2); +// color.setAlpha(150 - qSqrt(i)*50); +// painter.setPen(color); +// painter.drawPath(path); +// } +//} diff --git a/mainui/mainwindow.h b/mainui/mainwindow.h new file mode 100644 index 0000000..5825586 --- /dev/null +++ b/mainui/mainwindow.h @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include + +#include "titlewidget.h" +#include "actionwidget.h" +#include "toolwidget.h" +#include "loginwidget.h" +#include "contentwidget.h" +#include "homepage.h" +#include "infowidget.h" +#include "settingwidget.h" +#include "cleanerwidget.h" +#include "boxwidget.h" +#include "skincenter.h" +#include "../component/kylinmenu.h" +#include "../component/utils.h" +#include "../component/toolkits.h" +#include "homeactionwidget.h" +#include "infoactionwidget.h" +#include "cleaneractionwidget.h" +#include "settingactionwidget.h" +#include "boxactionwidget.h" +#include "aboutdialog.h" +#include "upgradedialog.h" + +class QParallelAnimationGroup; +class SessionDispatcher; +class SystemDispatcher; +class ShadowWidget; +#include "autostartwidget.h" +//#include "cameramanager.h" + +class MainWindow : public QDialog +{ + Q_OBJECT + +public: + explicit MainWindow(QString cur_arch = "", int d_count = 0, QWidget *parent = 0); + ~MainWindow(); + void setTranslator(QTranslator* translator); + void initConnect(); + void initHomePage(); + void initOtherPages(); + void reViewThePointSkin(QString pciture); + void reViewTheOrgSkin(); + void changeSkin(QString pciture); + void restoreSkin(); + void initAnimation(); + int getCurrentBackgroundIndex(); + QString getCurrentBackgroundName(); + QString getCurrentBackgroundAbsName(); + QStringList filterSkin(); + bool deleteFile(QString filename); + bool CopyFile(QString filename); + QString accessOSName(); + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void closeEvent(QCloseEvent *); +// virtual void paintEvent(QPaintEvent *event); + +public slots: + void openSkinCenter(); + void openUpgradePage(/*QStringList version_list*/); + void openUpgradePageAgain(); + void showMainMenu(); + void closeYoukerAssistant(); + void setCurrentPageIndex(int index); + void changeLanguage(LANGUAGE language); + void newFeatures(); + void setupConfigure(); + void aboutUs(); + void startDbusDaemon(); + void displaySubPage(int index); + void upAnimFinished(); + void closeAnimFinished(); + + void displayMainWindow(/*int display*/); + +signals: + void chanegBoxToolStatus(); + +private: + QStackedWidget *topStack; + QStackedWidget *bottomStack; +// QGridLayout *top_grid_layout; +// QGridLayout *bottom_grid_layout; + TitleWidget *title_widget; + ActionWidget *default_action_widget; + ActionWidget *other_action_widget; + ToolWidget *tool_widget; + LoginWidget *login_widget; + ContentWidget *default_content_widget; + ContentWidget *other_content_widget; + HomePage *home_page; + InfoWidget *info_widget; + CleanerWidget *cleaner_widget; + SettingWidget *setting_widget; + BoxWidget *box_widget; + HomeActionWidget *home_action_widget; + InfoActionWidget *info_action_widget; + CleanerActionWidget *cleaner_action_widget; + SettingActionWidget *setting_action_widget; + BoxActionWidget *box_action_widget; + SkinCenter *skin_center; + KylinMenu *main_menu; +// QString version; + QPoint drag_pos; //移动的距离 + bool mouse_press; //按下鼠标左键 + QTranslator* translator; //翻译器 + LANGUAGE current_language; //当前语言 + QPixmap main_skin_pixmap; + QString last_skin_path; + QPixmap review_skin_pixmap; + SystemDispatcher *systeminterface; + SessionDispatcher *sessioninterface; + Toolkits *toolKits; + AboutDialog *aboutDlg; + QSettings *mSettings; + QString desktop; +// QString machine; + QString osName; + QString arch; + bool battery; + bool sensor; + QParallelAnimationGroup *spreadGroup; + QParallelAnimationGroup *gatherGroup; + PAGESTATUS status; + bool statusFlag; + AutoStartWidget *auto_start; +// CameraManager *camera_manager; + UpgradeDialog *upgrade_dialog; +// QStringList skinlist; + ShadowWidget *shadow_widget; + int display_count; +}; + +class GlobalData // define by hebing,just for transmit var +{ + +public: + static QString globalarch; +}; + +#endif // MAINWINDOW_H diff --git a/mainui/mainwindow.ui b/mainui/mainwindow.ui new file mode 100644 index 0000000..f05a577 --- /dev/null +++ b/mainui/mainwindow.ui @@ -0,0 +1,28 @@ + + + MainWindow + + + + 0 + 0 + 900 + 600 + + + + false + + + MainWindow + + + + false + + + + + + + diff --git a/mainui/pluginmanager.cpp b/mainui/pluginmanager.cpp new file mode 100644 index 0000000..abc8364 --- /dev/null +++ b/mainui/pluginmanager.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "pluginmanager.h" +#include "../component/plugininterface.h" +#include +#include + +PluginManager::PluginManager(void) +{ + +} + +PluginManager::~PluginManager(void) +{ +} + +PluginManager* PluginManager::Instance() +{ + static PluginManager PluginMgr; + return &PluginMgr; +} + +bool PluginManager::loadPlugin(QString plugin_path) +{ + QDir pluginsDir(plugin_path + "/libs"); + foreach (QString fileName, pluginsDir.entryList(QStringList("*.so"),QDir::Files)) { + QPluginLoader *pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName)); + QObject *plugin = pluginLoader->instance(); + if (plugin) {//测试插件是否有效:使用 qobject_cast()测试插件是否给出了相应接口并进行类型转换,转换成接口对象指针. + PluginInterface* interface = qobject_cast(plugin); + if (interface) { + QString guid = interface->getGuid(); + plugin_map.insert(guid, pluginLoader); + } + } + else { + delete pluginLoader; + } + } + return true; +} + +bool PluginManager::unloadPlugin(QString plugin_guid) +{ + QMap::iterator iter = plugin_map.find(plugin_guid); + if (iter == plugin_map.end()) + { + return false; + } + iter.value()->unload(); + plugin_map.erase(iter); + return true; +} diff --git a/mainui/pluginmanager.h b/mainui/pluginmanager.h new file mode 100644 index 0000000..82a0691 --- /dev/null +++ b/mainui/pluginmanager.h @@ -0,0 +1,62 @@ +#include +#include + +class PluginManager +{ +private: + PluginManager(); + ~PluginManager(); + +public: + static PluginManager* Instance(); + bool loadPlugin(QString plugin_path); + bool unloadPlugin(QString plugin_guid); + + template + T* getPlugin(QString plugin_guid) + { + QMap::iterator iter = plugin_map.find(plugin_guid); + if (iter == plugin_map.end()) + { + return NULL; + } + return iter.value(); + } + + int count() {return plugin_map.count();} + + template + T* getPluginByindex(int index) + { + QMap::iterator iter = plugin_map.begin(); + for (int i = 0;i < index; ++i) + { + ++iter; + } + return iter.value(); + } + + template + T* getInterfaceByindex(int index) + { + QPluginLoader* plugin_loader = getPluginByindex(index); + QObject *plugin = plugin_loader->instance(); + return qobject_cast(plugin); + } + + template + T* getInterfaceByGuid(QString guid) + { + QMap::iterator iter = plugin_map.find(guid); + if (iter == plugin_map.end()) + { + return NULL; + } + QPluginLoader* plugin_loader = iter.value(); + QObject *plugin = plugin_loader->instance(); + return qobject_cast(plugin); + } + +private: + QMap plugin_map; +}; diff --git a/mainui/res/alert.png b/mainui/res/alert.png new file mode 100755 index 0000000..8a36017 Binary files /dev/null and b/mainui/res/alert.png differ diff --git a/mainui/res/apt-min.png b/mainui/res/apt-min.png new file mode 100644 index 0000000..b8c47a0 Binary files /dev/null and b/mainui/res/apt-min.png differ diff --git a/mainui/res/arrow-hover.png b/mainui/res/arrow-hover.png new file mode 100644 index 0000000..1c6391d Binary files /dev/null and b/mainui/res/arrow-hover.png differ diff --git a/mainui/res/arrow-normal.png b/mainui/res/arrow-normal.png new file mode 100644 index 0000000..cefd4f4 Binary files /dev/null and b/mainui/res/arrow-normal.png differ diff --git a/mainui/res/arrowhead.png b/mainui/res/arrowhead.png new file mode 100644 index 0000000..cbfbb7c Binary files /dev/null and b/mainui/res/arrowhead.png differ diff --git a/mainui/res/autostart-default.png b/mainui/res/autostart-default.png new file mode 100644 index 0000000..6c75b36 Binary files /dev/null and b/mainui/res/autostart-default.png differ diff --git a/mainui/res/back-arrow.png b/mainui/res/back-arrow.png new file mode 100644 index 0000000..e9bdc37 Binary files /dev/null and b/mainui/res/back-arrow.png differ diff --git a/mainui/res/background.jpg b/mainui/res/background.jpg new file mode 100644 index 0000000..b210131 Binary files /dev/null and b/mainui/res/background.jpg differ diff --git a/mainui/res/bigfile.png b/mainui/res/bigfile.png new file mode 100644 index 0000000..708df62 Binary files /dev/null and b/mainui/res/bigfile.png differ diff --git a/mainui/res/bigfile_check.png b/mainui/res/bigfile_check.png new file mode 100644 index 0000000..1581283 Binary files /dev/null and b/mainui/res/bigfile_check.png differ diff --git a/mainui/res/bigfile_logo.png b/mainui/res/bigfile_logo.png new file mode 100644 index 0000000..4a18946 Binary files /dev/null and b/mainui/res/bigfile_logo.png differ diff --git a/mainui/res/bigfile_logo_gray.png b/mainui/res/bigfile_logo_gray.png new file mode 100644 index 0000000..ed25eef Binary files /dev/null and b/mainui/res/bigfile_logo_gray.png differ diff --git a/mainui/res/bigfile_uncheck.png b/mainui/res/bigfile_uncheck.png new file mode 100644 index 0000000..de97b48 Binary files /dev/null and b/mainui/res/bigfile_uncheck.png differ diff --git a/mainui/res/book.png b/mainui/res/book.png new file mode 100644 index 0000000..34d322b Binary files /dev/null and b/mainui/res/book.png differ diff --git a/mainui/res/boot.png b/mainui/res/boot.png new file mode 100644 index 0000000..e84397f Binary files /dev/null and b/mainui/res/boot.png differ diff --git a/mainui/res/bootanimation.png b/mainui/res/bootanimation.png new file mode 100644 index 0000000..9baa5c2 Binary files /dev/null and b/mainui/res/bootanimation.png differ diff --git a/mainui/res/box-hover.png b/mainui/res/box-hover.png new file mode 100644 index 0000000..20db0d0 Binary files /dev/null and b/mainui/res/box-hover.png differ diff --git a/mainui/res/box.png b/mainui/res/box.png new file mode 100644 index 0000000..b6328f5 Binary files /dev/null and b/mainui/res/box.png differ diff --git a/mainui/res/broadcast.png b/mainui/res/broadcast.png new file mode 100644 index 0000000..94a6b8f Binary files /dev/null and b/mainui/res/broadcast.png differ diff --git a/mainui/res/browser.png b/mainui/res/browser.png new file mode 100644 index 0000000..a09ecc4 Binary files /dev/null and b/mainui/res/browser.png differ diff --git a/mainui/res/browser_check.png b/mainui/res/browser_check.png new file mode 100644 index 0000000..a980e1d Binary files /dev/null and b/mainui/res/browser_check.png differ diff --git a/mainui/res/browser_logo.png b/mainui/res/browser_logo.png new file mode 100644 index 0000000..0d910e6 Binary files /dev/null and b/mainui/res/browser_logo.png differ diff --git a/mainui/res/browser_logo_gray.png b/mainui/res/browser_logo_gray.png new file mode 100644 index 0000000..c864ce6 Binary files /dev/null and b/mainui/res/browser_logo_gray.png differ diff --git a/mainui/res/browser_uncheck.png b/mainui/res/browser_uncheck.png new file mode 100644 index 0000000..450b544 Binary files /dev/null and b/mainui/res/browser_uncheck.png differ diff --git a/mainui/res/brush.png b/mainui/res/brush.png new file mode 100644 index 0000000..55ffa52 Binary files /dev/null and b/mainui/res/brush.png differ diff --git a/mainui/res/btn-ground.png b/mainui/res/btn-ground.png new file mode 100644 index 0000000..9634038 Binary files /dev/null and b/mainui/res/btn-ground.png differ diff --git a/mainui/res/button-hover.png b/mainui/res/button-hover.png new file mode 100644 index 0000000..eaf2c94 Binary files /dev/null and b/mainui/res/button-hover.png differ diff --git a/mainui/res/cache.png b/mainui/res/cache.png new file mode 100644 index 0000000..291912c Binary files /dev/null and b/mainui/res/cache.png differ diff --git a/mainui/res/cache_check.png b/mainui/res/cache_check.png new file mode 100644 index 0000000..0a5e055 Binary files /dev/null and b/mainui/res/cache_check.png differ diff --git a/mainui/res/cache_logo.png b/mainui/res/cache_logo.png new file mode 100644 index 0000000..92f07dc Binary files /dev/null and b/mainui/res/cache_logo.png differ diff --git a/mainui/res/cache_logo_gray.png b/mainui/res/cache_logo_gray.png new file mode 100644 index 0000000..563346f Binary files /dev/null and b/mainui/res/cache_logo_gray.png differ diff --git a/mainui/res/cache_uncheck.png b/mainui/res/cache_uncheck.png new file mode 100644 index 0000000..acc0e52 Binary files /dev/null and b/mainui/res/cache_uncheck.png differ diff --git a/mainui/res/camera-default.png b/mainui/res/camera-default.png new file mode 100644 index 0000000..c9c2e28 Binary files /dev/null and b/mainui/res/camera-default.png differ diff --git a/mainui/res/camera-error.png b/mainui/res/camera-error.png new file mode 100644 index 0000000..a7cba18 Binary files /dev/null and b/mainui/res/camera-error.png differ diff --git a/mainui/res/camera-uk.png b/mainui/res/camera-uk.png new file mode 100644 index 0000000..c47ea84 Binary files /dev/null and b/mainui/res/camera-uk.png differ diff --git a/mainui/res/camera.png b/mainui/res/camera.png new file mode 100644 index 0000000..3302efb Binary files /dev/null and b/mainui/res/camera.png differ diff --git a/mainui/res/catch-disable.png b/mainui/res/catch-disable.png new file mode 100644 index 0000000..8451e9b Binary files /dev/null and b/mainui/res/catch-disable.png differ diff --git a/mainui/res/catch-hover.png b/mainui/res/catch-hover.png new file mode 100644 index 0000000..8700116 Binary files /dev/null and b/mainui/res/catch-hover.png differ diff --git a/mainui/res/catch.png b/mainui/res/catch.png new file mode 100644 index 0000000..7d59805 Binary files /dev/null and b/mainui/res/catch.png differ diff --git a/mainui/res/checkbox-checked.png b/mainui/res/checkbox-checked.png new file mode 100644 index 0000000..2e6a006 Binary files /dev/null and b/mainui/res/checkbox-checked.png differ diff --git a/mainui/res/checkbox-disable-checked.png b/mainui/res/checkbox-disable-checked.png new file mode 100644 index 0000000..a53fab5 Binary files /dev/null and b/mainui/res/checkbox-disable-checked.png differ diff --git a/mainui/res/checkbox-disable-unchecked.png b/mainui/res/checkbox-disable-unchecked.png new file mode 100644 index 0000000..34e61c4 Binary files /dev/null and b/mainui/res/checkbox-disable-unchecked.png differ diff --git a/mainui/res/checkbox-hover.png b/mainui/res/checkbox-hover.png new file mode 100644 index 0000000..63238d3 Binary files /dev/null and b/mainui/res/checkbox-hover.png differ diff --git a/mainui/res/checkbox-press.png b/mainui/res/checkbox-press.png new file mode 100644 index 0000000..256b015 Binary files /dev/null and b/mainui/res/checkbox-press.png differ diff --git a/mainui/res/checkbox-tristate.png b/mainui/res/checkbox-tristate.png new file mode 100644 index 0000000..49adce0 Binary files /dev/null and b/mainui/res/checkbox-tristate.png differ diff --git a/mainui/res/checkbox-two.png b/mainui/res/checkbox-two.png new file mode 100644 index 0000000..1207917 Binary files /dev/null and b/mainui/res/checkbox-two.png differ diff --git a/mainui/res/checkbox-unchecked.png b/mainui/res/checkbox-unchecked.png new file mode 100644 index 0000000..3e0d8fe Binary files /dev/null and b/mainui/res/checkbox-unchecked.png differ diff --git a/mainui/res/checkbox.png b/mainui/res/checkbox.png new file mode 100644 index 0000000..a59ba67 Binary files /dev/null and b/mainui/res/checkbox.png differ diff --git a/mainui/res/checkbox_mid.png b/mainui/res/checkbox_mid.png new file mode 100644 index 0000000..d5c7322 Binary files /dev/null and b/mainui/res/checkbox_mid.png differ diff --git a/mainui/res/checkbox_seclect.png b/mainui/res/checkbox_seclect.png new file mode 100644 index 0000000..b283bb2 Binary files /dev/null and b/mainui/res/checkbox_seclect.png differ diff --git a/mainui/res/choose.png b/mainui/res/choose.png new file mode 100644 index 0000000..973606c Binary files /dev/null and b/mainui/res/choose.png differ diff --git a/mainui/res/chrome.png b/mainui/res/chrome.png new file mode 100644 index 0000000..9b4ae58 Binary files /dev/null and b/mainui/res/chrome.png differ diff --git a/mainui/res/chromium.png b/mainui/res/chromium.png new file mode 100644 index 0000000..5b559e7 Binary files /dev/null and b/mainui/res/chromium.png differ diff --git a/mainui/res/closeBtn.png b/mainui/res/closeBtn.png new file mode 100644 index 0000000..102342a Binary files /dev/null and b/mainui/res/closeBtn.png differ diff --git a/mainui/res/closeBtn_hover.png b/mainui/res/closeBtn_hover.png new file mode 100644 index 0000000..3307341 Binary files /dev/null and b/mainui/res/closeBtn_hover.png differ diff --git a/mainui/res/clothes.png b/mainui/res/clothes.png new file mode 100644 index 0000000..a318650 Binary files /dev/null and b/mainui/res/clothes.png differ diff --git a/mainui/res/conceal.png b/mainui/res/conceal.png new file mode 100644 index 0000000..5dd1498 Binary files /dev/null and b/mainui/res/conceal.png differ diff --git a/mainui/res/configfile.png b/mainui/res/configfile.png new file mode 100644 index 0000000..a1054fe Binary files /dev/null and b/mainui/res/configfile.png differ diff --git a/mainui/res/cookie.png b/mainui/res/cookie.png new file mode 100644 index 0000000..06df6d5 Binary files /dev/null and b/mainui/res/cookie.png differ diff --git a/mainui/res/cookie_check.png b/mainui/res/cookie_check.png new file mode 100644 index 0000000..8dd4015 Binary files /dev/null and b/mainui/res/cookie_check.png differ diff --git a/mainui/res/cookie_logo.png b/mainui/res/cookie_logo.png new file mode 100644 index 0000000..ed0f10e Binary files /dev/null and b/mainui/res/cookie_logo.png differ diff --git a/mainui/res/cookie_logo_gray.png b/mainui/res/cookie_logo_gray.png new file mode 100644 index 0000000..798d333 Binary files /dev/null and b/mainui/res/cookie_logo_gray.png differ diff --git a/mainui/res/cookie_uncheck.png b/mainui/res/cookie_uncheck.png new file mode 100644 index 0000000..ff7cd15 Binary files /dev/null and b/mainui/res/cookie_uncheck.png differ diff --git a/mainui/res/cookies-bg.png b/mainui/res/cookies-bg.png new file mode 100644 index 0000000..c73209b Binary files /dev/null and b/mainui/res/cookies-bg.png differ diff --git a/mainui/res/cookies.png b/mainui/res/cookies.png new file mode 100644 index 0000000..9edf5b8 Binary files /dev/null and b/mainui/res/cookies.png differ diff --git a/mainui/res/create.png b/mainui/res/create.png new file mode 100644 index 0000000..05d5ad1 Binary files /dev/null and b/mainui/res/create.png differ diff --git a/mainui/res/custom.png b/mainui/res/custom.png new file mode 100644 index 0000000..b6c717a Binary files /dev/null and b/mainui/res/custom.png differ diff --git a/mainui/res/deb-min.png b/mainui/res/deb-min.png new file mode 100644 index 0000000..6241d63 Binary files /dev/null and b/mainui/res/deb-min.png differ diff --git a/mainui/res/default/光影.png b/mainui/res/default/光影.png new file mode 100644 index 0000000..7e9c1f5 Binary files /dev/null and b/mainui/res/default/光影.png differ diff --git a/mainui/res/default/夜半星辉.png b/mainui/res/default/夜半星辉.png new file mode 100644 index 0000000..e1ac417 Binary files /dev/null and b/mainui/res/default/夜半星辉.png differ diff --git a/mainui/res/default/落日余晖.png b/mainui/res/default/落日余晖.png new file mode 100644 index 0000000..13f77f6 Binary files /dev/null and b/mainui/res/default/落日余晖.png differ diff --git a/mainui/res/default/蓝色点阵.png b/mainui/res/default/蓝色点阵.png new file mode 100644 index 0000000..909c1e7 Binary files /dev/null and b/mainui/res/default/蓝色点阵.png differ diff --git a/mainui/res/default/路.png b/mainui/res/default/路.png new file mode 100644 index 0000000..be926c2 Binary files /dev/null and b/mainui/res/default/路.png differ diff --git a/mainui/res/default/魅力紫色.png b/mainui/res/default/魅力紫色.png new file mode 100644 index 0000000..750482f Binary files /dev/null and b/mainui/res/default/魅力紫色.png differ diff --git a/mainui/res/delete.png b/mainui/res/delete.png new file mode 100644 index 0000000..f376912 Binary files /dev/null and b/mainui/res/delete.png differ diff --git a/mainui/res/desktop.png b/mainui/res/desktop.png new file mode 100644 index 0000000..050571e Binary files /dev/null and b/mainui/res/desktop.png differ diff --git a/mainui/res/disappear.png b/mainui/res/disappear.png new file mode 100644 index 0000000..bb50804 Binary files /dev/null and b/mainui/res/disappear.png differ diff --git a/mainui/res/dot.png b/mainui/res/dot.png new file mode 100644 index 0000000..6eced2f Binary files /dev/null and b/mainui/res/dot.png differ diff --git a/mainui/res/dynamic.png b/mainui/res/dynamic.png new file mode 100644 index 0000000..3ef2270 Binary files /dev/null and b/mainui/res/dynamic.png differ diff --git a/mainui/res/firefox.png b/mainui/res/firefox.png new file mode 100644 index 0000000..00815a9 Binary files /dev/null and b/mainui/res/firefox.png differ diff --git a/mainui/res/folder.png b/mainui/res/folder.png new file mode 100644 index 0000000..2be76ce Binary files /dev/null and b/mainui/res/folder.png differ diff --git a/mainui/res/folder_hover.png b/mainui/res/folder_hover.png new file mode 100644 index 0000000..08ddbf9 Binary files /dev/null and b/mainui/res/folder_hover.png differ diff --git a/mainui/res/font.png b/mainui/res/font.png new file mode 100644 index 0000000..b67ac1a Binary files /dev/null and b/mainui/res/font.png differ diff --git a/mainui/res/green.png b/mainui/res/green.png new file mode 100644 index 0000000..7810452 Binary files /dev/null and b/mainui/res/green.png differ diff --git a/mainui/res/hardware/audio.png b/mainui/res/hardware/audio.png new file mode 100644 index 0000000..b26bce1 Binary files /dev/null and b/mainui/res/hardware/audio.png differ diff --git a/mainui/res/hardware/battery.png b/mainui/res/hardware/battery.png new file mode 100644 index 0000000..b5f7b9e Binary files /dev/null and b/mainui/res/hardware/battery.png differ diff --git a/mainui/res/hardware/board.png b/mainui/res/hardware/board.png new file mode 100644 index 0000000..1f3002c Binary files /dev/null and b/mainui/res/hardware/board.png differ diff --git a/mainui/res/hardware/cdrom.png b/mainui/res/hardware/cdrom.png new file mode 100644 index 0000000..3b9d764 Binary files /dev/null and b/mainui/res/hardware/cdrom.png differ diff --git a/mainui/res/hardware/computer.png b/mainui/res/hardware/computer.png new file mode 100644 index 0000000..e79ec03 Binary files /dev/null and b/mainui/res/hardware/computer.png differ diff --git a/mainui/res/hardware/cpu.png b/mainui/res/hardware/cpu.png new file mode 100644 index 0000000..d314188 Binary files /dev/null and b/mainui/res/hardware/cpu.png differ diff --git a/mainui/res/hardware/drive.png b/mainui/res/hardware/drive.png new file mode 100644 index 0000000..9094ceb Binary files /dev/null and b/mainui/res/hardware/drive.png differ diff --git a/mainui/res/hardware/harddisk.png b/mainui/res/hardware/harddisk.png new file mode 100644 index 0000000..479c160 Binary files /dev/null and b/mainui/res/hardware/harddisk.png differ diff --git a/mainui/res/hardware/memory.png b/mainui/res/hardware/memory.png new file mode 100644 index 0000000..976ce1a Binary files /dev/null and b/mainui/res/hardware/memory.png differ diff --git a/mainui/res/hardware/monitor.png b/mainui/res/hardware/monitor.png new file mode 100644 index 0000000..09ae6e2 Binary files /dev/null and b/mainui/res/hardware/monitor.png differ diff --git a/mainui/res/hardware/network.png b/mainui/res/hardware/network.png new file mode 100644 index 0000000..36aa071 Binary files /dev/null and b/mainui/res/hardware/network.png differ diff --git a/mainui/res/hardware/sensor.png b/mainui/res/hardware/sensor.png new file mode 100644 index 0000000..c49e09b Binary files /dev/null and b/mainui/res/hardware/sensor.png differ diff --git a/mainui/res/hardware/unity.png b/mainui/res/hardware/unity.png new file mode 100644 index 0000000..99e1a3a Binary files /dev/null and b/mainui/res/hardware/unity.png differ diff --git a/mainui/res/highlight.png b/mainui/res/highlight.png new file mode 100644 index 0000000..c858968 Binary files /dev/null and b/mainui/res/highlight.png differ diff --git a/mainui/res/history-max.png b/mainui/res/history-max.png new file mode 100644 index 0000000..7d8243c Binary files /dev/null and b/mainui/res/history-max.png differ diff --git a/mainui/res/history.png b/mainui/res/history.png new file mode 100644 index 0000000..f4cf926 Binary files /dev/null and b/mainui/res/history.png differ diff --git a/mainui/res/hook.png b/mainui/res/hook.png new file mode 100644 index 0000000..80e1b13 Binary files /dev/null and b/mainui/res/hook.png differ diff --git a/mainui/res/hover-enter.png b/mainui/res/hover-enter.png new file mode 100644 index 0000000..058d932 Binary files /dev/null and b/mainui/res/hover-enter.png differ diff --git a/mainui/res/hover-press.png b/mainui/res/hover-press.png new file mode 100644 index 0000000..f5fd97a Binary files /dev/null and b/mainui/res/hover-press.png differ diff --git a/mainui/res/icon.png b/mainui/res/icon.png new file mode 100644 index 0000000..8fd19b7 Binary files /dev/null and b/mainui/res/icon.png differ diff --git a/mainui/res/iconbeauty.png b/mainui/res/iconbeauty.png new file mode 100644 index 0000000..f7ed89e Binary files /dev/null and b/mainui/res/iconbeauty.png differ diff --git a/mainui/res/indicator.png b/mainui/res/indicator.png new file mode 100644 index 0000000..1874772 Binary files /dev/null and b/mainui/res/indicator.png differ diff --git a/mainui/res/ip.png b/mainui/res/ip.png new file mode 100644 index 0000000..89a74ba Binary files /dev/null and b/mainui/res/ip.png differ diff --git a/mainui/res/janitor/apt_check.png b/mainui/res/janitor/apt_check.png new file mode 100644 index 0000000..bd526a3 Binary files /dev/null and b/mainui/res/janitor/apt_check.png differ diff --git a/mainui/res/janitor/apt_uncheck.png b/mainui/res/janitor/apt_uncheck.png new file mode 100644 index 0000000..b8d3ff5 Binary files /dev/null and b/mainui/res/janitor/apt_uncheck.png differ diff --git a/mainui/res/janitor/chromium_check.png b/mainui/res/janitor/chromium_check.png new file mode 100644 index 0000000..359526b Binary files /dev/null and b/mainui/res/janitor/chromium_check.png differ diff --git a/mainui/res/janitor/chromium_uncheck.png b/mainui/res/janitor/chromium_uncheck.png new file mode 100644 index 0000000..7ec1888 Binary files /dev/null and b/mainui/res/janitor/chromium_uncheck.png differ diff --git a/mainui/res/janitor/debug_check.png b/mainui/res/janitor/debug_check.png new file mode 100644 index 0000000..e2ec247 Binary files /dev/null and b/mainui/res/janitor/debug_check.png differ diff --git a/mainui/res/janitor/debug_uncheck.png b/mainui/res/janitor/debug_uncheck.png new file mode 100644 index 0000000..e3f22ca Binary files /dev/null and b/mainui/res/janitor/debug_uncheck.png differ diff --git a/mainui/res/janitor/firefox_check.png b/mainui/res/janitor/firefox_check.png new file mode 100644 index 0000000..90b01c9 Binary files /dev/null and b/mainui/res/janitor/firefox_check.png differ diff --git a/mainui/res/janitor/firefox_uncheck.png b/mainui/res/janitor/firefox_uncheck.png new file mode 100644 index 0000000..a748e5a Binary files /dev/null and b/mainui/res/janitor/firefox_uncheck.png differ diff --git a/mainui/res/janitor/package_check.png b/mainui/res/janitor/package_check.png new file mode 100644 index 0000000..5dbb12c Binary files /dev/null and b/mainui/res/janitor/package_check.png differ diff --git a/mainui/res/janitor/package_uncheck.png b/mainui/res/janitor/package_uncheck.png new file mode 100644 index 0000000..9303906 Binary files /dev/null and b/mainui/res/janitor/package_uncheck.png differ diff --git a/mainui/res/janitor/software_check.png b/mainui/res/janitor/software_check.png new file mode 100644 index 0000000..1a772fa Binary files /dev/null and b/mainui/res/janitor/software_check.png differ diff --git a/mainui/res/janitor/software_uncheck.png b/mainui/res/janitor/software_uncheck.png new file mode 100644 index 0000000..666f803 Binary files /dev/null and b/mainui/res/janitor/software_uncheck.png differ diff --git a/mainui/res/janitor/thumbnails_check.png b/mainui/res/janitor/thumbnails_check.png new file mode 100644 index 0000000..f55e08f Binary files /dev/null and b/mainui/res/janitor/thumbnails_check.png differ diff --git a/mainui/res/janitor/thumbnails_uncheck.png b/mainui/res/janitor/thumbnails_uncheck.png new file mode 100644 index 0000000..69b5970 Binary files /dev/null and b/mainui/res/janitor/thumbnails_uncheck.png differ diff --git a/mainui/res/janitor/trace_check.png b/mainui/res/janitor/trace_check.png new file mode 100644 index 0000000..dc80123 Binary files /dev/null and b/mainui/res/janitor/trace_check.png differ diff --git a/mainui/res/janitor/trace_uncheck.png b/mainui/res/janitor/trace_uncheck.png new file mode 100644 index 0000000..d26a43f Binary files /dev/null and b/mainui/res/janitor/trace_uncheck.png differ diff --git a/mainui/res/kernel.png b/mainui/res/kernel.png new file mode 100644 index 0000000..ca258d9 Binary files /dev/null and b/mainui/res/kernel.png differ diff --git a/mainui/res/left-tab-default.png b/mainui/res/left-tab-default.png new file mode 100644 index 0000000..6b1245b Binary files /dev/null and b/mainui/res/left-tab-default.png differ diff --git a/mainui/res/left-tab-hover.png b/mainui/res/left-tab-hover.png new file mode 100644 index 0000000..da6859e Binary files /dev/null and b/mainui/res/left-tab-hover.png differ diff --git a/mainui/res/listen-pen.png b/mainui/res/listen-pen.png new file mode 100644 index 0000000..1ad25e2 Binary files /dev/null and b/mainui/res/listen-pen.png differ diff --git a/mainui/res/loading/1.png b/mainui/res/loading/1.png new file mode 100644 index 0000000..f50d19c Binary files /dev/null and b/mainui/res/loading/1.png differ diff --git a/mainui/res/loading/10.png b/mainui/res/loading/10.png new file mode 100644 index 0000000..4580cf7 Binary files /dev/null and b/mainui/res/loading/10.png differ diff --git a/mainui/res/loading/11.png b/mainui/res/loading/11.png new file mode 100644 index 0000000..7f7510a Binary files /dev/null and b/mainui/res/loading/11.png differ diff --git a/mainui/res/loading/12.png b/mainui/res/loading/12.png new file mode 100644 index 0000000..7c49286 Binary files /dev/null and b/mainui/res/loading/12.png differ diff --git a/mainui/res/loading/13.png b/mainui/res/loading/13.png new file mode 100644 index 0000000..47d57ef Binary files /dev/null and b/mainui/res/loading/13.png differ diff --git a/mainui/res/loading/14.png b/mainui/res/loading/14.png new file mode 100644 index 0000000..15cad56 Binary files /dev/null and b/mainui/res/loading/14.png differ diff --git a/mainui/res/loading/15.png b/mainui/res/loading/15.png new file mode 100644 index 0000000..8d69394 Binary files /dev/null and b/mainui/res/loading/15.png differ diff --git a/mainui/res/loading/16.png b/mainui/res/loading/16.png new file mode 100644 index 0000000..b93b0cb Binary files /dev/null and b/mainui/res/loading/16.png differ diff --git a/mainui/res/loading/17.png b/mainui/res/loading/17.png new file mode 100644 index 0000000..183055b Binary files /dev/null and b/mainui/res/loading/17.png differ diff --git a/mainui/res/loading/18.png b/mainui/res/loading/18.png new file mode 100644 index 0000000..748dbe8 Binary files /dev/null and b/mainui/res/loading/18.png differ diff --git a/mainui/res/loading/2.png b/mainui/res/loading/2.png new file mode 100644 index 0000000..6703d92 Binary files /dev/null and b/mainui/res/loading/2.png differ diff --git a/mainui/res/loading/3.png b/mainui/res/loading/3.png new file mode 100644 index 0000000..f968bfd Binary files /dev/null and b/mainui/res/loading/3.png differ diff --git a/mainui/res/loading/4.png b/mainui/res/loading/4.png new file mode 100644 index 0000000..87fd030 Binary files /dev/null and b/mainui/res/loading/4.png differ diff --git a/mainui/res/loading/5.png b/mainui/res/loading/5.png new file mode 100644 index 0000000..41d7576 Binary files /dev/null and b/mainui/res/loading/5.png differ diff --git a/mainui/res/loading/6.png b/mainui/res/loading/6.png new file mode 100644 index 0000000..b25af90 Binary files /dev/null and b/mainui/res/loading/6.png differ diff --git a/mainui/res/loading/7.png b/mainui/res/loading/7.png new file mode 100644 index 0000000..71d277f Binary files /dev/null and b/mainui/res/loading/7.png differ diff --git a/mainui/res/loading/8.png b/mainui/res/loading/8.png new file mode 100644 index 0000000..c572039 Binary files /dev/null and b/mainui/res/loading/8.png differ diff --git a/mainui/res/loading/9.png b/mainui/res/loading/9.png new file mode 100644 index 0000000..43f52c6 Binary files /dev/null and b/mainui/res/loading/9.png differ diff --git a/mainui/res/loading/small/1.png b/mainui/res/loading/small/1.png new file mode 100644 index 0000000..ea0222b Binary files /dev/null and b/mainui/res/loading/small/1.png differ diff --git a/mainui/res/loading/small/10.png b/mainui/res/loading/small/10.png new file mode 100644 index 0000000..ad6834c Binary files /dev/null and b/mainui/res/loading/small/10.png differ diff --git a/mainui/res/loading/small/11.png b/mainui/res/loading/small/11.png new file mode 100644 index 0000000..3311c8a Binary files /dev/null and b/mainui/res/loading/small/11.png differ diff --git a/mainui/res/loading/small/12.png b/mainui/res/loading/small/12.png new file mode 100644 index 0000000..a997356 Binary files /dev/null and b/mainui/res/loading/small/12.png differ diff --git a/mainui/res/loading/small/13.png b/mainui/res/loading/small/13.png new file mode 100644 index 0000000..a5c4c71 Binary files /dev/null and b/mainui/res/loading/small/13.png differ diff --git a/mainui/res/loading/small/14.png b/mainui/res/loading/small/14.png new file mode 100644 index 0000000..6d1a0ff Binary files /dev/null and b/mainui/res/loading/small/14.png differ diff --git a/mainui/res/loading/small/15.png b/mainui/res/loading/small/15.png new file mode 100644 index 0000000..1962004 Binary files /dev/null and b/mainui/res/loading/small/15.png differ diff --git a/mainui/res/loading/small/16.png b/mainui/res/loading/small/16.png new file mode 100644 index 0000000..4c1f2bb Binary files /dev/null and b/mainui/res/loading/small/16.png differ diff --git a/mainui/res/loading/small/17.png b/mainui/res/loading/small/17.png new file mode 100644 index 0000000..6682f75 Binary files /dev/null and b/mainui/res/loading/small/17.png differ diff --git a/mainui/res/loading/small/18.png b/mainui/res/loading/small/18.png new file mode 100644 index 0000000..7af8ecb Binary files /dev/null and b/mainui/res/loading/small/18.png differ diff --git a/mainui/res/loading/small/2.png b/mainui/res/loading/small/2.png new file mode 100644 index 0000000..fd7b3ee Binary files /dev/null and b/mainui/res/loading/small/2.png differ diff --git a/mainui/res/loading/small/3.png b/mainui/res/loading/small/3.png new file mode 100644 index 0000000..6439adb Binary files /dev/null and b/mainui/res/loading/small/3.png differ diff --git a/mainui/res/loading/small/4.png b/mainui/res/loading/small/4.png new file mode 100644 index 0000000..e634934 Binary files /dev/null and b/mainui/res/loading/small/4.png differ diff --git a/mainui/res/loading/small/5.png b/mainui/res/loading/small/5.png new file mode 100644 index 0000000..dd1b3da Binary files /dev/null and b/mainui/res/loading/small/5.png differ diff --git a/mainui/res/loading/small/6.png b/mainui/res/loading/small/6.png new file mode 100644 index 0000000..8fcf0f7 Binary files /dev/null and b/mainui/res/loading/small/6.png differ diff --git a/mainui/res/loading/small/7.png b/mainui/res/loading/small/7.png new file mode 100644 index 0000000..1ac2f87 Binary files /dev/null and b/mainui/res/loading/small/7.png differ diff --git a/mainui/res/loading/small/8.png b/mainui/res/loading/small/8.png new file mode 100644 index 0000000..eee91b4 Binary files /dev/null and b/mainui/res/loading/small/8.png differ diff --git a/mainui/res/loading/small/9.png b/mainui/res/loading/small/9.png new file mode 100644 index 0000000..0ff5dbd Binary files /dev/null and b/mainui/res/loading/small/9.png differ diff --git a/mainui/res/logo-hover.png b/mainui/res/logo-hover.png new file mode 100644 index 0000000..21af488 Binary files /dev/null and b/mainui/res/logo-hover.png differ diff --git a/mainui/res/logo.png b/mainui/res/logo.png new file mode 100644 index 0000000..66f6dba Binary files /dev/null and b/mainui/res/logo.png differ diff --git a/mainui/res/manufacturer/3COM.jpg b/mainui/res/manufacturer/3COM.jpg new file mode 100644 index 0000000..06079ac Binary files /dev/null and b/mainui/res/manufacturer/3COM.jpg differ diff --git a/mainui/res/manufacturer/A-DATA.jpg b/mainui/res/manufacturer/A-DATA.jpg new file mode 100644 index 0000000..fac05e8 Binary files /dev/null and b/mainui/res/manufacturer/A-DATA.jpg differ diff --git a/mainui/res/manufacturer/ABIT.jpg b/mainui/res/manufacturer/ABIT.jpg new file mode 100644 index 0000000..4fc13f6 Binary files /dev/null and b/mainui/res/manufacturer/ABIT.jpg differ diff --git a/mainui/res/manufacturer/ACER.jpg b/mainui/res/manufacturer/ACER.jpg new file mode 100644 index 0000000..6ad0622 Binary files /dev/null and b/mainui/res/manufacturer/ACER.jpg differ diff --git a/mainui/res/manufacturer/ADATA.jpg b/mainui/res/manufacturer/ADATA.jpg new file mode 100644 index 0000000..c9e3f2a Binary files /dev/null and b/mainui/res/manufacturer/ADATA.jpg differ diff --git a/mainui/res/manufacturer/AEXEA.jpg b/mainui/res/manufacturer/AEXEA.jpg new file mode 100644 index 0000000..0444777 Binary files /dev/null and b/mainui/res/manufacturer/AEXEA.jpg differ diff --git a/mainui/res/manufacturer/ALI.jpg b/mainui/res/manufacturer/ALI.jpg new file mode 100644 index 0000000..0b901f1 Binary files /dev/null and b/mainui/res/manufacturer/ALI.jpg differ diff --git a/mainui/res/manufacturer/AMD.jpg b/mainui/res/manufacturer/AMD.jpg new file mode 100644 index 0000000..2cb3303 Binary files /dev/null and b/mainui/res/manufacturer/AMD.jpg differ diff --git a/mainui/res/manufacturer/AMI.jpg b/mainui/res/manufacturer/AMI.jpg new file mode 100644 index 0000000..52383b1 Binary files /dev/null and b/mainui/res/manufacturer/AMI.jpg differ diff --git a/mainui/res/manufacturer/AOC.jpg b/mainui/res/manufacturer/AOC.jpg new file mode 100644 index 0000000..12153a6 Binary files /dev/null and b/mainui/res/manufacturer/AOC.jpg differ diff --git a/mainui/res/manufacturer/AOPEN.jpg b/mainui/res/manufacturer/AOPEN.jpg new file mode 100644 index 0000000..f504765 Binary files /dev/null and b/mainui/res/manufacturer/AOPEN.jpg differ diff --git a/mainui/res/manufacturer/APACER.jpg b/mainui/res/manufacturer/APACER.jpg new file mode 100644 index 0000000..00e13f3 Binary files /dev/null and b/mainui/res/manufacturer/APACER.jpg differ diff --git a/mainui/res/manufacturer/APPLE.jpg b/mainui/res/manufacturer/APPLE.jpg new file mode 100644 index 0000000..5c31ff9 Binary files /dev/null and b/mainui/res/manufacturer/APPLE.jpg differ diff --git a/mainui/res/manufacturer/ASINT.jpg b/mainui/res/manufacturer/ASINT.jpg new file mode 100644 index 0000000..f47efd4 Binary files /dev/null and b/mainui/res/manufacturer/ASINT.jpg differ diff --git a/mainui/res/manufacturer/ASROCK.jpg b/mainui/res/manufacturer/ASROCK.jpg new file mode 100644 index 0000000..b7b68ff Binary files /dev/null and b/mainui/res/manufacturer/ASROCK.jpg differ diff --git a/mainui/res/manufacturer/ASUS.jpg b/mainui/res/manufacturer/ASUS.jpg new file mode 100644 index 0000000..9f7d7a1 Binary files /dev/null and b/mainui/res/manufacturer/ASUS.jpg differ diff --git a/mainui/res/manufacturer/ASZ.jpg b/mainui/res/manufacturer/ASZ.jpg new file mode 100644 index 0000000..c4b1f38 Binary files /dev/null and b/mainui/res/manufacturer/ASZ.jpg differ diff --git a/mainui/res/manufacturer/ATHEROS.jpg b/mainui/res/manufacturer/ATHEROS.jpg new file mode 100644 index 0000000..874c3ac Binary files /dev/null and b/mainui/res/manufacturer/ATHEROS.jpg differ diff --git a/mainui/res/manufacturer/ATI.jpg b/mainui/res/manufacturer/ATI.jpg new file mode 100644 index 0000000..fc2ff89 Binary files /dev/null and b/mainui/res/manufacturer/ATI.jpg differ diff --git a/mainui/res/manufacturer/AUO.jpg b/mainui/res/manufacturer/AUO.jpg new file mode 100644 index 0000000..f8253c6 Binary files /dev/null and b/mainui/res/manufacturer/AUO.jpg differ diff --git a/mainui/res/manufacturer/AUTHENTEC.jpg b/mainui/res/manufacturer/AUTHENTEC.jpg new file mode 100644 index 0000000..9230c37 Binary files /dev/null and b/mainui/res/manufacturer/AUTHENTEC.jpg differ diff --git a/mainui/res/manufacturer/AVAGO.jpg b/mainui/res/manufacturer/AVAGO.jpg new file mode 100644 index 0000000..e5849fe Binary files /dev/null and b/mainui/res/manufacturer/AVAGO.jpg differ diff --git a/mainui/res/manufacturer/AVEO.jpg b/mainui/res/manufacturer/AVEO.jpg new file mode 100644 index 0000000..2ce123f Binary files /dev/null and b/mainui/res/manufacturer/AVEO.jpg differ diff --git a/mainui/res/manufacturer/B&DATA.jpg b/mainui/res/manufacturer/B&DATA.jpg new file mode 100644 index 0000000..b74be79 Binary files /dev/null and b/mainui/res/manufacturer/B&DATA.jpg differ diff --git a/mainui/res/manufacturer/B-LINK.jpg b/mainui/res/manufacturer/B-LINK.jpg new file mode 100644 index 0000000..642e301 Binary files /dev/null and b/mainui/res/manufacturer/B-LINK.jpg differ diff --git a/mainui/res/manufacturer/BENQ.jpg b/mainui/res/manufacturer/BENQ.jpg new file mode 100644 index 0000000..e762047 Binary files /dev/null and b/mainui/res/manufacturer/BENQ.jpg differ diff --git a/mainui/res/manufacturer/BIOSTAR.jpg b/mainui/res/manufacturer/BIOSTAR.jpg new file mode 100644 index 0000000..9926ac2 Binary files /dev/null and b/mainui/res/manufacturer/BIOSTAR.jpg differ diff --git a/mainui/res/manufacturer/BROADCOM.jpg b/mainui/res/manufacturer/BROADCOM.jpg new file mode 100644 index 0000000..b5bc160 Binary files /dev/null and b/mainui/res/manufacturer/BROADCOM.jpg differ diff --git a/mainui/res/manufacturer/CANON.jpg b/mainui/res/manufacturer/CANON.jpg new file mode 100644 index 0000000..95daebd Binary files /dev/null and b/mainui/res/manufacturer/CANON.jpg differ diff --git a/mainui/res/manufacturer/CHAINTECH.jpg b/mainui/res/manufacturer/CHAINTECH.jpg new file mode 100644 index 0000000..577f661 Binary files /dev/null and b/mainui/res/manufacturer/CHAINTECH.jpg differ diff --git a/mainui/res/manufacturer/CHICONY.jpg b/mainui/res/manufacturer/CHICONY.jpg new file mode 100644 index 0000000..ec31360 Binary files /dev/null and b/mainui/res/manufacturer/CHICONY.jpg differ diff --git a/mainui/res/manufacturer/CISCO.jpg b/mainui/res/manufacturer/CISCO.jpg new file mode 100644 index 0000000..91cd410 Binary files /dev/null and b/mainui/res/manufacturer/CISCO.jpg differ diff --git a/mainui/res/manufacturer/COLORFUL.jpg b/mainui/res/manufacturer/COLORFUL.jpg new file mode 100644 index 0000000..50d9f79 Binary files /dev/null and b/mainui/res/manufacturer/COLORFUL.jpg differ diff --git a/mainui/res/manufacturer/COMEON.jpg b/mainui/res/manufacturer/COMEON.jpg new file mode 100644 index 0000000..87b905f Binary files /dev/null and b/mainui/res/manufacturer/COMEON.jpg differ diff --git a/mainui/res/manufacturer/CORSAIR.jpg b/mainui/res/manufacturer/CORSAIR.jpg new file mode 100644 index 0000000..d4aa0f6 Binary files /dev/null and b/mainui/res/manufacturer/CORSAIR.jpg differ diff --git a/mainui/res/manufacturer/CREATIVE.jpg b/mainui/res/manufacturer/CREATIVE.jpg new file mode 100644 index 0000000..e410aa5 Binary files /dev/null and b/mainui/res/manufacturer/CREATIVE.jpg differ diff --git a/mainui/res/manufacturer/D-LINK.jpg b/mainui/res/manufacturer/D-LINK.jpg new file mode 100644 index 0000000..b55888b Binary files /dev/null and b/mainui/res/manufacturer/D-LINK.jpg differ diff --git a/mainui/res/manufacturer/DELL.jpg b/mainui/res/manufacturer/DELL.jpg new file mode 100644 index 0000000..6fcfd52 Binary files /dev/null and b/mainui/res/manufacturer/DELL.jpg differ diff --git a/mainui/res/manufacturer/DFI.jpg b/mainui/res/manufacturer/DFI.jpg new file mode 100644 index 0000000..8bafe96 Binary files /dev/null and b/mainui/res/manufacturer/DFI.jpg differ diff --git a/mainui/res/manufacturer/DTK.jpg b/mainui/res/manufacturer/DTK.jpg new file mode 100644 index 0000000..e7a881e Binary files /dev/null and b/mainui/res/manufacturer/DTK.jpg differ diff --git a/mainui/res/manufacturer/E-MU.jpg b/mainui/res/manufacturer/E-MU.jpg new file mode 100644 index 0000000..fe9da00 Binary files /dev/null and b/mainui/res/manufacturer/E-MU.jpg differ diff --git a/mainui/res/manufacturer/EAGET.jpg b/mainui/res/manufacturer/EAGET.jpg new file mode 100644 index 0000000..822ac3b Binary files /dev/null and b/mainui/res/manufacturer/EAGET.jpg differ diff --git a/mainui/res/manufacturer/EAST.jpg b/mainui/res/manufacturer/EAST.jpg new file mode 100644 index 0000000..227ef71 Binary files /dev/null and b/mainui/res/manufacturer/EAST.jpg differ diff --git a/mainui/res/manufacturer/ECS.jpg b/mainui/res/manufacturer/ECS.jpg new file mode 100644 index 0000000..cd25b08 Binary files /dev/null and b/mainui/res/manufacturer/ECS.jpg differ diff --git a/mainui/res/manufacturer/ELEPHANT.jpg b/mainui/res/manufacturer/ELEPHANT.jpg new file mode 100644 index 0000000..d5afe5a Binary files /dev/null and b/mainui/res/manufacturer/ELEPHANT.jpg differ diff --git a/mainui/res/manufacturer/ELIXIR.jpg b/mainui/res/manufacturer/ELIXIR.jpg new file mode 100644 index 0000000..79d4ff7 Binary files /dev/null and b/mainui/res/manufacturer/ELIXIR.jpg differ diff --git a/mainui/res/manufacturer/ELSA.jpg b/mainui/res/manufacturer/ELSA.jpg new file mode 100644 index 0000000..1b75d75 Binary files /dev/null and b/mainui/res/manufacturer/ELSA.jpg differ diff --git a/mainui/res/manufacturer/EMPIA.jpg b/mainui/res/manufacturer/EMPIA.jpg new file mode 100644 index 0000000..62491c9 Binary files /dev/null and b/mainui/res/manufacturer/EMPIA.jpg differ diff --git a/mainui/res/manufacturer/ENLON.jpg b/mainui/res/manufacturer/ENLON.jpg new file mode 100644 index 0000000..77a52f6 Binary files /dev/null and b/mainui/res/manufacturer/ENLON.jpg differ diff --git a/mainui/res/manufacturer/ENNYAH.jpg b/mainui/res/manufacturer/ENNYAH.jpg new file mode 100644 index 0000000..7808df4 Binary files /dev/null and b/mainui/res/manufacturer/ENNYAH.jpg differ diff --git a/mainui/res/manufacturer/ETRON.jpg b/mainui/res/manufacturer/ETRON.jpg new file mode 100644 index 0000000..7992d02 Binary files /dev/null and b/mainui/res/manufacturer/ETRON.jpg differ diff --git a/mainui/res/manufacturer/EXCELSTOR.jpg b/mainui/res/manufacturer/EXCELSTOR.jpg new file mode 100644 index 0000000..9bd1954 Binary files /dev/null and b/mainui/res/manufacturer/EXCELSTOR.jpg differ diff --git a/mainui/res/manufacturer/FIC.jpg b/mainui/res/manufacturer/FIC.jpg new file mode 100644 index 0000000..b409522 Binary files /dev/null and b/mainui/res/manufacturer/FIC.jpg differ diff --git a/mainui/res/manufacturer/FOUNDER.jpg b/mainui/res/manufacturer/FOUNDER.jpg new file mode 100644 index 0000000..ec49e86 Binary files /dev/null and b/mainui/res/manufacturer/FOUNDER.jpg differ diff --git a/mainui/res/manufacturer/FUJITSU.jpg b/mainui/res/manufacturer/FUJITSU.jpg new file mode 100644 index 0000000..3eac444 Binary files /dev/null and b/mainui/res/manufacturer/FUJITSU.jpg differ diff --git a/mainui/res/manufacturer/G.SKILL.jpg b/mainui/res/manufacturer/G.SKILL.jpg new file mode 100644 index 0000000..0fa6ccd Binary files /dev/null and b/mainui/res/manufacturer/G.SKILL.jpg differ diff --git a/mainui/res/manufacturer/GAINWARO.jpg b/mainui/res/manufacturer/GAINWARO.jpg new file mode 100644 index 0000000..bd34601 Binary files /dev/null and b/mainui/res/manufacturer/GAINWARO.jpg differ diff --git a/mainui/res/manufacturer/GALAXY.jpg b/mainui/res/manufacturer/GALAXY.jpg new file mode 100644 index 0000000..53f44f6 Binary files /dev/null and b/mainui/res/manufacturer/GALAXY.jpg differ diff --git a/mainui/res/manufacturer/GAMEN.jpg b/mainui/res/manufacturer/GAMEN.jpg new file mode 100644 index 0000000..ab054b1 Binary files /dev/null and b/mainui/res/manufacturer/GAMEN.jpg differ diff --git a/mainui/res/manufacturer/GEIL.jpg b/mainui/res/manufacturer/GEIL.jpg new file mode 100644 index 0000000..2b08c76 Binary files /dev/null and b/mainui/res/manufacturer/GEIL.jpg differ diff --git a/mainui/res/manufacturer/GIGABYTE.jpg b/mainui/res/manufacturer/GIGABYTE.jpg new file mode 100644 index 0000000..3d6c147 Binary files /dev/null and b/mainui/res/manufacturer/GIGABYTE.jpg differ diff --git a/mainui/res/manufacturer/GREAT WALL.jpg b/mainui/res/manufacturer/GREAT WALL.jpg new file mode 100644 index 0000000..649d189 Binary files /dev/null and b/mainui/res/manufacturer/GREAT WALL.jpg differ diff --git a/mainui/res/manufacturer/HASEE.jpg b/mainui/res/manufacturer/HASEE.jpg new file mode 100644 index 0000000..fadfbaf Binary files /dev/null and b/mainui/res/manufacturer/HASEE.jpg differ diff --git a/mainui/res/manufacturer/HITACHI.jpg b/mainui/res/manufacturer/HITACHI.jpg new file mode 100644 index 0000000..06bc639 Binary files /dev/null and b/mainui/res/manufacturer/HITACHI.jpg differ diff --git a/mainui/res/manufacturer/HOMKEY.jpg b/mainui/res/manufacturer/HOMKEY.jpg new file mode 100644 index 0000000..d7b5857 Binary files /dev/null and b/mainui/res/manufacturer/HOMKEY.jpg differ diff --git a/mainui/res/manufacturer/HP.jpg b/mainui/res/manufacturer/HP.jpg new file mode 100644 index 0000000..3b14fc4 Binary files /dev/null and b/mainui/res/manufacturer/HP.jpg differ diff --git a/mainui/res/manufacturer/HYNIX.jpg b/mainui/res/manufacturer/HYNIX.jpg new file mode 100644 index 0000000..d74c2ca Binary files /dev/null and b/mainui/res/manufacturer/HYNIX.jpg differ diff --git a/mainui/res/manufacturer/HYUNDAI.jpg b/mainui/res/manufacturer/HYUNDAI.jpg new file mode 100644 index 0000000..270ab0a Binary files /dev/null and b/mainui/res/manufacturer/HYUNDAI.jpg differ diff --git a/mainui/res/manufacturer/IBM.jpg b/mainui/res/manufacturer/IBM.jpg new file mode 100644 index 0000000..03e65ee Binary files /dev/null and b/mainui/res/manufacturer/IBM.jpg differ diff --git a/mainui/res/manufacturer/INNOVISION.jpg b/mainui/res/manufacturer/INNOVISION.jpg new file mode 100644 index 0000000..94ce4ae Binary files /dev/null and b/mainui/res/manufacturer/INNOVISION.jpg differ diff --git a/mainui/res/manufacturer/INTEL.jpg b/mainui/res/manufacturer/INTEL.jpg new file mode 100644 index 0000000..eff6ac6 Binary files /dev/null and b/mainui/res/manufacturer/INTEL.jpg differ diff --git a/mainui/res/manufacturer/IOMEGA.jpg b/mainui/res/manufacturer/IOMEGA.jpg new file mode 100644 index 0000000..ac79355 Binary files /dev/null and b/mainui/res/manufacturer/IOMEGA.jpg differ diff --git a/mainui/res/manufacturer/J&W.jpg b/mainui/res/manufacturer/J&W.jpg new file mode 100644 index 0000000..226fa7f Binary files /dev/null and b/mainui/res/manufacturer/J&W.jpg differ diff --git a/mainui/res/manufacturer/JETWAY.jpg b/mainui/res/manufacturer/JETWAY.jpg new file mode 100644 index 0000000..fc18d29 Binary files /dev/null and b/mainui/res/manufacturer/JETWAY.jpg differ diff --git a/mainui/res/manufacturer/KINGBOX.jpg b/mainui/res/manufacturer/KINGBOX.jpg new file mode 100644 index 0000000..940250f Binary files /dev/null and b/mainui/res/manufacturer/KINGBOX.jpg differ diff --git a/mainui/res/manufacturer/KINGFAST.jpg b/mainui/res/manufacturer/KINGFAST.jpg new file mode 100644 index 0000000..8993d3f Binary files /dev/null and b/mainui/res/manufacturer/KINGFAST.jpg differ diff --git a/mainui/res/manufacturer/KINGMAX.jpg b/mainui/res/manufacturer/KINGMAX.jpg new file mode 100644 index 0000000..d37e053 Binary files /dev/null and b/mainui/res/manufacturer/KINGMAX.jpg differ diff --git a/mainui/res/manufacturer/KINGSPEC.jpg b/mainui/res/manufacturer/KINGSPEC.jpg new file mode 100644 index 0000000..92ee68e Binary files /dev/null and b/mainui/res/manufacturer/KINGSPEC.jpg differ diff --git a/mainui/res/manufacturer/KINGSTEK.jpg b/mainui/res/manufacturer/KINGSTEK.jpg new file mode 100644 index 0000000..d85b6db Binary files /dev/null and b/mainui/res/manufacturer/KINGSTEK.jpg differ diff --git a/mainui/res/manufacturer/KINGSTON.jpg b/mainui/res/manufacturer/KINGSTON.jpg new file mode 100644 index 0000000..41a0b22 Binary files /dev/null and b/mainui/res/manufacturer/KINGSTON.jpg differ diff --git a/mainui/res/manufacturer/KINGTIGER.jpg b/mainui/res/manufacturer/KINGTIGER.jpg new file mode 100644 index 0000000..56f450f Binary files /dev/null and b/mainui/res/manufacturer/KINGTIGER.jpg differ diff --git a/mainui/res/manufacturer/LEADTEK.jpg b/mainui/res/manufacturer/LEADTEK.jpg new file mode 100644 index 0000000..590a537 Binary files /dev/null and b/mainui/res/manufacturer/LEADTEK.jpg differ diff --git a/mainui/res/manufacturer/LENOVO.jpg b/mainui/res/manufacturer/LENOVO.jpg new file mode 100644 index 0000000..8f27658 Binary files /dev/null and b/mainui/res/manufacturer/LENOVO.jpg differ diff --git a/mainui/res/manufacturer/LG.jpg b/mainui/res/manufacturer/LG.jpg new file mode 100644 index 0000000..48a5f08 Binary files /dev/null and b/mainui/res/manufacturer/LG.jpg differ diff --git a/mainui/res/manufacturer/LINKSYS.jpg b/mainui/res/manufacturer/LINKSYS.jpg new file mode 100644 index 0000000..c3989ef Binary files /dev/null and b/mainui/res/manufacturer/LINKSYS.jpg differ diff --git a/mainui/res/manufacturer/LITEON.jpg b/mainui/res/manufacturer/LITEON.jpg new file mode 100644 index 0000000..36b7a43 Binary files /dev/null and b/mainui/res/manufacturer/LITEON.jpg differ diff --git a/mainui/res/manufacturer/LITTLE TIGER.jpg b/mainui/res/manufacturer/LITTLE TIGER.jpg new file mode 100644 index 0000000..1dbf0ae Binary files /dev/null and b/mainui/res/manufacturer/LITTLE TIGER.jpg differ diff --git a/mainui/res/manufacturer/LOGITECH.jpg b/mainui/res/manufacturer/LOGITECH.jpg new file mode 100644 index 0000000..94526f4 Binary files /dev/null and b/mainui/res/manufacturer/LOGITECH.jpg differ diff --git a/mainui/res/manufacturer/M-ONE.jpg b/mainui/res/manufacturer/M-ONE.jpg new file mode 100644 index 0000000..d92d2c4 Binary files /dev/null and b/mainui/res/manufacturer/M-ONE.jpg differ diff --git a/mainui/res/manufacturer/MACY.jpg b/mainui/res/manufacturer/MACY.jpg new file mode 100644 index 0000000..24a85cc Binary files /dev/null and b/mainui/res/manufacturer/MACY.jpg differ diff --git a/mainui/res/manufacturer/MAGIC-PRO.jpg b/mainui/res/manufacturer/MAGIC-PRO.jpg new file mode 100644 index 0000000..b50ec3b Binary files /dev/null and b/mainui/res/manufacturer/MAGIC-PRO.jpg differ diff --git a/mainui/res/manufacturer/MARVELL.jpg b/mainui/res/manufacturer/MARVELL.jpg new file mode 100644 index 0000000..d285bff Binary files /dev/null and b/mainui/res/manufacturer/MARVELL.jpg differ diff --git a/mainui/res/manufacturer/MATROX.jpg b/mainui/res/manufacturer/MATROX.jpg new file mode 100644 index 0000000..1d07cd0 Binary files /dev/null and b/mainui/res/manufacturer/MATROX.jpg differ diff --git a/mainui/res/manufacturer/MAXSUN.jpg b/mainui/res/manufacturer/MAXSUN.jpg new file mode 100644 index 0000000..75f66ce Binary files /dev/null and b/mainui/res/manufacturer/MAXSUN.jpg differ diff --git a/mainui/res/manufacturer/MAXTOR.jpg b/mainui/res/manufacturer/MAXTOR.jpg new file mode 100644 index 0000000..6e03dc1 Binary files /dev/null and b/mainui/res/manufacturer/MAXTOR.jpg differ diff --git a/mainui/res/manufacturer/MAYA.jpg b/mainui/res/manufacturer/MAYA.jpg new file mode 100644 index 0000000..1897053 Binary files /dev/null and b/mainui/res/manufacturer/MAYA.jpg differ diff --git a/mainui/res/manufacturer/MEGASTAR.jpg b/mainui/res/manufacturer/MEGASTAR.jpg new file mode 100644 index 0000000..f852e43 Binary files /dev/null and b/mainui/res/manufacturer/MEGASTAR.jpg differ diff --git a/mainui/res/manufacturer/MICRON.jpg b/mainui/res/manufacturer/MICRON.jpg new file mode 100644 index 0000000..caa9d34 Binary files /dev/null and b/mainui/res/manufacturer/MICRON.jpg differ diff --git a/mainui/res/manufacturer/MICROSOFT.jpg b/mainui/res/manufacturer/MICROSOFT.jpg new file mode 100644 index 0000000..aec024f Binary files /dev/null and b/mainui/res/manufacturer/MICROSOFT.jpg differ diff --git a/mainui/res/manufacturer/MMC.jpg b/mainui/res/manufacturer/MMC.jpg new file mode 100644 index 0000000..4f87c1c Binary files /dev/null and b/mainui/res/manufacturer/MMC.jpg differ diff --git a/mainui/res/manufacturer/MOTOROLA.jpg b/mainui/res/manufacturer/MOTOROLA.jpg new file mode 100644 index 0000000..82cd1f8 Binary files /dev/null and b/mainui/res/manufacturer/MOTOROLA.jpg differ diff --git a/mainui/res/manufacturer/MSI.jpg b/mainui/res/manufacturer/MSI.jpg new file mode 100644 index 0000000..428dad8 Binary files /dev/null and b/mainui/res/manufacturer/MSI.jpg differ diff --git a/mainui/res/manufacturer/MUSILAND .jpg b/mainui/res/manufacturer/MUSILAND .jpg new file mode 100644 index 0000000..d23f761 Binary files /dev/null and b/mainui/res/manufacturer/MUSILAND .jpg differ diff --git a/mainui/res/manufacturer/M_AUDIO.jpg b/mainui/res/manufacturer/M_AUDIO.jpg new file mode 100644 index 0000000..9778902 Binary files /dev/null and b/mainui/res/manufacturer/M_AUDIO.jpg differ diff --git a/mainui/res/manufacturer/NEC.jpg b/mainui/res/manufacturer/NEC.jpg new file mode 100644 index 0000000..7b59168 Binary files /dev/null and b/mainui/res/manufacturer/NEC.jpg differ diff --git a/mainui/res/manufacturer/NETGEAR.jpg b/mainui/res/manufacturer/NETGEAR.jpg new file mode 100644 index 0000000..c740c0e Binary files /dev/null and b/mainui/res/manufacturer/NETGEAR.jpg differ diff --git a/mainui/res/manufacturer/NOKIA.jpg b/mainui/res/manufacturer/NOKIA.jpg new file mode 100644 index 0000000..40d3073 Binary files /dev/null and b/mainui/res/manufacturer/NOKIA.jpg differ diff --git a/mainui/res/manufacturer/NVIDIA.jpg b/mainui/res/manufacturer/NVIDIA.jpg new file mode 100644 index 0000000..901db6f Binary files /dev/null and b/mainui/res/manufacturer/NVIDIA.jpg differ diff --git a/mainui/res/manufacturer/OCZ.jpg b/mainui/res/manufacturer/OCZ.jpg new file mode 100644 index 0000000..08b2db7 Binary files /dev/null and b/mainui/res/manufacturer/OCZ.jpg differ diff --git a/mainui/res/manufacturer/OMEGA.jpg b/mainui/res/manufacturer/OMEGA.jpg new file mode 100644 index 0000000..05f70f2 Binary files /dev/null and b/mainui/res/manufacturer/OMEGA.jpg differ diff --git a/mainui/res/manufacturer/OMNIVISION.jpg b/mainui/res/manufacturer/OMNIVISION.jpg new file mode 100644 index 0000000..b305e28 Binary files /dev/null and b/mainui/res/manufacturer/OMNIVISION.jpg differ diff --git a/mainui/res/manufacturer/OMRON.jpg b/mainui/res/manufacturer/OMRON.jpg new file mode 100644 index 0000000..c84c3d0 Binary files /dev/null and b/mainui/res/manufacturer/OMRON.jpg differ diff --git a/mainui/res/manufacturer/ONDA.jpg b/mainui/res/manufacturer/ONDA.jpg new file mode 100644 index 0000000..e70ba04 Binary files /dev/null and b/mainui/res/manufacturer/ONDA.jpg differ diff --git a/mainui/res/manufacturer/ONKYO.jpg b/mainui/res/manufacturer/ONKYO.jpg new file mode 100644 index 0000000..78ea32b Binary files /dev/null and b/mainui/res/manufacturer/ONKYO.jpg differ diff --git a/mainui/res/manufacturer/PANASONIC.jpg b/mainui/res/manufacturer/PANASONIC.jpg new file mode 100644 index 0000000..2622eec Binary files /dev/null and b/mainui/res/manufacturer/PANASONIC.jpg differ diff --git a/mainui/res/manufacturer/PHILIPS.jpg b/mainui/res/manufacturer/PHILIPS.jpg new file mode 100644 index 0000000..355427b Binary files /dev/null and b/mainui/res/manufacturer/PHILIPS.jpg differ diff --git a/mainui/res/manufacturer/PHOENIX.jpg b/mainui/res/manufacturer/PHOENIX.jpg new file mode 100644 index 0000000..ac77463 Binary files /dev/null and b/mainui/res/manufacturer/PHOENIX.jpg differ diff --git a/mainui/res/manufacturer/PINE.jpg b/mainui/res/manufacturer/PINE.jpg new file mode 100644 index 0000000..e11664a Binary files /dev/null and b/mainui/res/manufacturer/PINE.jpg differ diff --git a/mainui/res/manufacturer/PIONEER.jpg b/mainui/res/manufacturer/PIONEER.jpg new file mode 100644 index 0000000..9525fe1 Binary files /dev/null and b/mainui/res/manufacturer/PIONEER.jpg differ diff --git a/mainui/res/manufacturer/PIXART.jpg b/mainui/res/manufacturer/PIXART.jpg new file mode 100644 index 0000000..d295da7 Binary files /dev/null and b/mainui/res/manufacturer/PIXART.jpg differ diff --git a/mainui/res/manufacturer/PLDS.jpg b/mainui/res/manufacturer/PLDS.jpg new file mode 100644 index 0000000..b2695c0 Binary files /dev/null and b/mainui/res/manufacturer/PLDS.jpg differ diff --git a/mainui/res/manufacturer/POWERCOLOR.jpg b/mainui/res/manufacturer/POWERCOLOR.jpg new file mode 100644 index 0000000..f59d052 Binary files /dev/null and b/mainui/res/manufacturer/POWERCOLOR.jpg differ diff --git a/mainui/res/manufacturer/PRIMAX.jpg b/mainui/res/manufacturer/PRIMAX.jpg new file mode 100644 index 0000000..4003519 Binary files /dev/null and b/mainui/res/manufacturer/PRIMAX.jpg differ diff --git a/mainui/res/manufacturer/QDI.jpg b/mainui/res/manufacturer/QDI.jpg new file mode 100644 index 0000000..a930ec1 Binary files /dev/null and b/mainui/res/manufacturer/QDI.jpg differ diff --git a/mainui/res/manufacturer/QIMONDA.jpg b/mainui/res/manufacturer/QIMONDA.jpg new file mode 100644 index 0000000..7bf5361 Binary files /dev/null and b/mainui/res/manufacturer/QIMONDA.jpg differ diff --git a/mainui/res/manufacturer/QUANTUM.jpg b/mainui/res/manufacturer/QUANTUM.jpg new file mode 100644 index 0000000..ae78c3a Binary files /dev/null and b/mainui/res/manufacturer/QUANTUM.jpg differ diff --git a/mainui/res/manufacturer/RALINK.jpg b/mainui/res/manufacturer/RALINK.jpg new file mode 100644 index 0000000..fee4ba7 Binary files /dev/null and b/mainui/res/manufacturer/RALINK.jpg differ diff --git a/mainui/res/manufacturer/RAPOO.jpg b/mainui/res/manufacturer/RAPOO.jpg new file mode 100644 index 0000000..46c9389 Binary files /dev/null and b/mainui/res/manufacturer/RAPOO.jpg differ diff --git a/mainui/res/manufacturer/RAZER.jpg b/mainui/res/manufacturer/RAZER.jpg new file mode 100644 index 0000000..e866b49 Binary files /dev/null and b/mainui/res/manufacturer/RAZER.jpg differ diff --git a/mainui/res/manufacturer/REALTEK.jpg b/mainui/res/manufacturer/REALTEK.jpg new file mode 100644 index 0000000..099974a Binary files /dev/null and b/mainui/res/manufacturer/REALTEK.jpg differ diff --git a/mainui/res/manufacturer/SAMSUNG.jpg b/mainui/res/manufacturer/SAMSUNG.jpg new file mode 100644 index 0000000..560f63b Binary files /dev/null and b/mainui/res/manufacturer/SAMSUNG.jpg differ diff --git a/mainui/res/manufacturer/SANYO.jpg b/mainui/res/manufacturer/SANYO.jpg new file mode 100644 index 0000000..a88423c Binary files /dev/null and b/mainui/res/manufacturer/SANYO.jpg differ diff --git a/mainui/res/manufacturer/SAPPHIRE.jpg b/mainui/res/manufacturer/SAPPHIRE.jpg new file mode 100644 index 0000000..b2d8656 Binary files /dev/null and b/mainui/res/manufacturer/SAPPHIRE.jpg differ diff --git a/mainui/res/manufacturer/SEAGATE.jpg b/mainui/res/manufacturer/SEAGATE.jpg new file mode 100644 index 0000000..6b6c1a8 Binary files /dev/null and b/mainui/res/manufacturer/SEAGATE.jpg differ diff --git a/mainui/res/manufacturer/SHARK.jpg b/mainui/res/manufacturer/SHARK.jpg new file mode 100644 index 0000000..ba2e788 Binary files /dev/null and b/mainui/res/manufacturer/SHARK.jpg differ diff --git a/mainui/res/manufacturer/SIEMENS.jpg b/mainui/res/manufacturer/SIEMENS.jpg new file mode 100644 index 0000000..e9c2cc6 Binary files /dev/null and b/mainui/res/manufacturer/SIEMENS.jpg differ diff --git a/mainui/res/manufacturer/SIS.jpg b/mainui/res/manufacturer/SIS.jpg new file mode 100644 index 0000000..2585c54 Binary files /dev/null and b/mainui/res/manufacturer/SIS.jpg differ diff --git a/mainui/res/manufacturer/SMP.jpg b/mainui/res/manufacturer/SMP.jpg new file mode 100644 index 0000000..e3c4e84 Binary files /dev/null and b/mainui/res/manufacturer/SMP.jpg differ diff --git a/mainui/res/manufacturer/SONIX.jpg b/mainui/res/manufacturer/SONIX.jpg new file mode 100644 index 0000000..42c6900 Binary files /dev/null and b/mainui/res/manufacturer/SONIX.jpg differ diff --git a/mainui/res/manufacturer/SONY.jpg b/mainui/res/manufacturer/SONY.jpg new file mode 100644 index 0000000..7bb4246 Binary files /dev/null and b/mainui/res/manufacturer/SONY.jpg differ diff --git a/mainui/res/manufacturer/SOYO.jpg b/mainui/res/manufacturer/SOYO.jpg new file mode 100644 index 0000000..c52ea46 Binary files /dev/null and b/mainui/res/manufacturer/SOYO.jpg differ diff --git a/mainui/res/manufacturer/SPARK.jpg b/mainui/res/manufacturer/SPARK.jpg new file mode 100644 index 0000000..f21119b Binary files /dev/null and b/mainui/res/manufacturer/SPARK.jpg differ diff --git a/mainui/res/manufacturer/SUNPLUS.jpg b/mainui/res/manufacturer/SUNPLUS.jpg new file mode 100644 index 0000000..220f56f Binary files /dev/null and b/mainui/res/manufacturer/SUNPLUS.jpg differ diff --git a/mainui/res/manufacturer/SUPERGRAPHIC.jpg b/mainui/res/manufacturer/SUPERGRAPHIC.jpg new file mode 100644 index 0000000..913e042 Binary files /dev/null and b/mainui/res/manufacturer/SUPERGRAPHIC.jpg differ diff --git a/mainui/res/manufacturer/SUPOX.jpg b/mainui/res/manufacturer/SUPOX.jpg new file mode 100644 index 0000000..db9b684 Binary files /dev/null and b/mainui/res/manufacturer/SUPOX.jpg differ diff --git a/mainui/res/manufacturer/SYMBOL.jpg b/mainui/res/manufacturer/SYMBOL.jpg new file mode 100644 index 0000000..f7f6393 Binary files /dev/null and b/mainui/res/manufacturer/SYMBOL.jpg differ diff --git a/mainui/res/manufacturer/SYNTEK.jpg b/mainui/res/manufacturer/SYNTEK.jpg new file mode 100644 index 0000000..4970af1 Binary files /dev/null and b/mainui/res/manufacturer/SYNTEK.jpg differ diff --git a/mainui/res/manufacturer/T&W.jpg b/mainui/res/manufacturer/T&W.jpg new file mode 100644 index 0000000..37ffa58 Binary files /dev/null and b/mainui/res/manufacturer/T&W.jpg differ diff --git a/mainui/res/manufacturer/TAIYANFA.jpg b/mainui/res/manufacturer/TAIYANFA.jpg new file mode 100644 index 0000000..64de4a2 Binary files /dev/null and b/mainui/res/manufacturer/TAIYANFA.jpg differ diff --git a/mainui/res/manufacturer/TDK.jpg b/mainui/res/manufacturer/TDK.jpg new file mode 100644 index 0000000..b02090b Binary files /dev/null and b/mainui/res/manufacturer/TDK.jpg differ diff --git a/mainui/res/manufacturer/TEKRAM.jpg b/mainui/res/manufacturer/TEKRAM.jpg new file mode 100644 index 0000000..d19b05e Binary files /dev/null and b/mainui/res/manufacturer/TEKRAM.jpg differ diff --git a/mainui/res/manufacturer/TERRATEC.jpg b/mainui/res/manufacturer/TERRATEC.jpg new file mode 100644 index 0000000..7349697 Binary files /dev/null and b/mainui/res/manufacturer/TERRATEC.jpg differ diff --git a/mainui/res/manufacturer/TEXAS.jpg b/mainui/res/manufacturer/TEXAS.jpg new file mode 100644 index 0000000..3f3e349 Binary files /dev/null and b/mainui/res/manufacturer/TEXAS.jpg differ diff --git a/mainui/res/manufacturer/TONGFANG.jpg b/mainui/res/manufacturer/TONGFANG.jpg new file mode 100644 index 0000000..1492e18 Binary files /dev/null and b/mainui/res/manufacturer/TONGFANG.jpg differ diff --git a/mainui/res/manufacturer/TOSHIBA.jpg b/mainui/res/manufacturer/TOSHIBA.jpg new file mode 100644 index 0000000..e0884d0 Binary files /dev/null and b/mainui/res/manufacturer/TOSHIBA.jpg differ diff --git a/mainui/res/manufacturer/TOYOTA.jpg b/mainui/res/manufacturer/TOYOTA.jpg new file mode 100644 index 0000000..3856e29 Binary files /dev/null and b/mainui/res/manufacturer/TOYOTA.jpg differ diff --git a/mainui/res/manufacturer/TP-LINK.jpg b/mainui/res/manufacturer/TP-LINK.jpg new file mode 100644 index 0000000..5a73f08 Binary files /dev/null and b/mainui/res/manufacturer/TP-LINK.jpg differ diff --git a/mainui/res/manufacturer/TRANSMETA.jpg b/mainui/res/manufacturer/TRANSMETA.jpg new file mode 100644 index 0000000..a8a1745 Binary files /dev/null and b/mainui/res/manufacturer/TRANSMETA.jpg differ diff --git a/mainui/res/manufacturer/TRUST.jpg b/mainui/res/manufacturer/TRUST.jpg new file mode 100644 index 0000000..acb679c Binary files /dev/null and b/mainui/res/manufacturer/TRUST.jpg differ diff --git a/mainui/res/manufacturer/TSSTCORP.jpg b/mainui/res/manufacturer/TSSTCORP.jpg new file mode 100644 index 0000000..c37b2ba Binary files /dev/null and b/mainui/res/manufacturer/TSSTCORP.jpg differ diff --git a/mainui/res/manufacturer/TYAN.jpg b/mainui/res/manufacturer/TYAN.jpg new file mode 100644 index 0000000..55af9f1 Binary files /dev/null and b/mainui/res/manufacturer/TYAN.jpg differ diff --git a/mainui/res/manufacturer/UBUNTUKYLIN.jpg b/mainui/res/manufacturer/UBUNTUKYLIN.jpg new file mode 100644 index 0000000..4a1f841 Binary files /dev/null and b/mainui/res/manufacturer/UBUNTUKYLIN.jpg differ diff --git a/mainui/res/manufacturer/UMC.jpg b/mainui/res/manufacturer/UMC.jpg new file mode 100644 index 0000000..8eb0c52 Binary files /dev/null and b/mainui/res/manufacturer/UMC.jpg differ diff --git a/mainui/res/manufacturer/UNIKA.jpg b/mainui/res/manufacturer/UNIKA.jpg new file mode 100644 index 0000000..b1a2cad Binary files /dev/null and b/mainui/res/manufacturer/UNIKA.jpg differ diff --git a/mainui/res/manufacturer/VIA.jpg b/mainui/res/manufacturer/VIA.jpg new file mode 100644 index 0000000..c7a62be Binary files /dev/null and b/mainui/res/manufacturer/VIA.jpg differ diff --git a/mainui/res/manufacturer/VIMICRO.jpg b/mainui/res/manufacturer/VIMICRO.jpg new file mode 100644 index 0000000..74118dc Binary files /dev/null and b/mainui/res/manufacturer/VIMICRO.jpg differ diff --git a/mainui/res/manufacturer/VIRTUALBOX.jpg b/mainui/res/manufacturer/VIRTUALBOX.jpg new file mode 100644 index 0000000..7cf89d0 Binary files /dev/null and b/mainui/res/manufacturer/VIRTUALBOX.jpg differ diff --git a/mainui/res/manufacturer/WDC.jpg b/mainui/res/manufacturer/WDC.jpg new file mode 100644 index 0000000..a44a6cb Binary files /dev/null and b/mainui/res/manufacturer/WDC.jpg differ diff --git a/mainui/res/manufacturer/WINBOND.jpg b/mainui/res/manufacturer/WINBOND.jpg new file mode 100644 index 0000000..8e30d9d Binary files /dev/null and b/mainui/res/manufacturer/WINBOND.jpg differ diff --git a/mainui/res/manufacturer/XFX.jpg b/mainui/res/manufacturer/XFX.jpg new file mode 100644 index 0000000..61ac8c5 Binary files /dev/null and b/mainui/res/manufacturer/XFX.jpg differ diff --git a/mainui/res/manufacturer/YESTON.jpg b/mainui/res/manufacturer/YESTON.jpg new file mode 100644 index 0000000..c579f88 Binary files /dev/null and b/mainui/res/manufacturer/YESTON.jpg differ diff --git a/mainui/res/manufacturer/ZOTAC.jpg b/mainui/res/manufacturer/ZOTAC.jpg new file mode 100644 index 0000000..50b6b69 Binary files /dev/null and b/mainui/res/manufacturer/ZOTAC.jpg differ diff --git a/mainui/res/manufacturer/ZTE.jpg b/mainui/res/manufacturer/ZTE.jpg new file mode 100644 index 0000000..a964965 Binary files /dev/null and b/mainui/res/manufacturer/ZTE.jpg differ diff --git a/mainui/res/menu-big-hover.png b/mainui/res/menu-big-hover.png new file mode 100644 index 0000000..bd6b4ab Binary files /dev/null and b/mainui/res/menu-big-hover.png differ diff --git a/mainui/res/menu.png b/mainui/res/menu.png new file mode 100644 index 0000000..d5574c5 Binary files /dev/null and b/mainui/res/menu.png differ diff --git a/mainui/res/menu/about.png b/mainui/res/menu/about.png new file mode 100644 index 0000000..b2d4ab4 Binary files /dev/null and b/mainui/res/menu/about.png differ diff --git a/mainui/res/menu/cleanup-hover.png b/mainui/res/menu/cleanup-hover.png new file mode 100644 index 0000000..dbc26e9 Binary files /dev/null and b/mainui/res/menu/cleanup-hover.png differ diff --git a/mainui/res/menu/cleanup-press.png b/mainui/res/menu/cleanup-press.png new file mode 100644 index 0000000..5ce93c1 Binary files /dev/null and b/mainui/res/menu/cleanup-press.png differ diff --git a/mainui/res/menu/cleanup.png b/mainui/res/menu/cleanup.png new file mode 100644 index 0000000..47f1b5c Binary files /dev/null and b/mainui/res/menu/cleanup.png differ diff --git a/mainui/res/menu/feature-hover.png b/mainui/res/menu/feature-hover.png new file mode 100644 index 0000000..3b7bca6 Binary files /dev/null and b/mainui/res/menu/feature-hover.png differ diff --git a/mainui/res/menu/feature-press.png b/mainui/res/menu/feature-press.png new file mode 100644 index 0000000..5e7e94e Binary files /dev/null and b/mainui/res/menu/feature-press.png differ diff --git a/mainui/res/menu/feature.png b/mainui/res/menu/feature.png new file mode 100644 index 0000000..beced96 Binary files /dev/null and b/mainui/res/menu/feature.png differ diff --git a/mainui/res/menu/features.png b/mainui/res/menu/features.png new file mode 100644 index 0000000..5600c1b Binary files /dev/null and b/mainui/res/menu/features.png differ diff --git a/mainui/res/menu/feedback.png b/mainui/res/menu/feedback.png new file mode 100644 index 0000000..96778ca Binary files /dev/null and b/mainui/res/menu/feedback.png differ diff --git a/mainui/res/menu/help.png b/mainui/res/menu/help.png new file mode 100644 index 0000000..bb297bb Binary files /dev/null and b/mainui/res/menu/help.png differ diff --git a/mainui/res/menu/home-hover.png b/mainui/res/menu/home-hover.png new file mode 100644 index 0000000..1baf4ff Binary files /dev/null and b/mainui/res/menu/home-hover.png differ diff --git a/mainui/res/menu/home-press.png b/mainui/res/menu/home-press.png new file mode 100644 index 0000000..603eb43 Binary files /dev/null and b/mainui/res/menu/home-press.png differ diff --git a/mainui/res/menu/home.png b/mainui/res/menu/home.png new file mode 100644 index 0000000..96fc221 Binary files /dev/null and b/mainui/res/menu/home.png differ diff --git a/mainui/res/menu/setup.png b/mainui/res/menu/setup.png new file mode 100644 index 0000000..a8dbe7d Binary files /dev/null and b/mainui/res/menu/setup.png differ diff --git a/mainui/res/menu/sysinfo-hover.png b/mainui/res/menu/sysinfo-hover.png new file mode 100644 index 0000000..8f74c90 Binary files /dev/null and b/mainui/res/menu/sysinfo-hover.png differ diff --git a/mainui/res/menu/sysinfo-press.png b/mainui/res/menu/sysinfo-press.png new file mode 100644 index 0000000..8766f9c Binary files /dev/null and b/mainui/res/menu/sysinfo-press.png differ diff --git a/mainui/res/menu/sysinfo.png b/mainui/res/menu/sysinfo.png new file mode 100644 index 0000000..5eac2a8 Binary files /dev/null and b/mainui/res/menu/sysinfo.png differ diff --git a/mainui/res/menu/toolkits-hover.png b/mainui/res/menu/toolkits-hover.png new file mode 100644 index 0000000..7c9a786 Binary files /dev/null and b/mainui/res/menu/toolkits-hover.png differ diff --git a/mainui/res/menu/toolkits-press.png b/mainui/res/menu/toolkits-press.png new file mode 100644 index 0000000..38a11cf Binary files /dev/null and b/mainui/res/menu/toolkits-press.png differ diff --git a/mainui/res/menu/toolkits.png b/mainui/res/menu/toolkits.png new file mode 100644 index 0000000..6581494 Binary files /dev/null and b/mainui/res/menu/toolkits.png differ diff --git a/mainui/res/menu/upgrade.png b/mainui/res/menu/upgrade.png new file mode 100644 index 0000000..bd338d1 Binary files /dev/null and b/mainui/res/menu/upgrade.png differ diff --git a/mainui/res/menu_hover.png b/mainui/res/menu_hover.png new file mode 100644 index 0000000..e065d61 Binary files /dev/null and b/mainui/res/menu_hover.png differ diff --git a/mainui/res/menu_press.png b/mainui/res/menu_press.png new file mode 100644 index 0000000..17172ee Binary files /dev/null and b/mainui/res/menu_press.png differ diff --git a/mainui/res/minBtn.png b/mainui/res/minBtn.png new file mode 100644 index 0000000..62167af Binary files /dev/null and b/mainui/res/minBtn.png differ diff --git a/mainui/res/minBtn_hover.png b/mainui/res/minBtn_hover.png new file mode 100644 index 0000000..385524c Binary files /dev/null and b/mainui/res/minBtn_hover.png differ diff --git a/mainui/res/more.png b/mainui/res/more.png new file mode 100644 index 0000000..76c337d Binary files /dev/null and b/mainui/res/more.png differ diff --git a/mainui/res/mouse.png b/mainui/res/mouse.png new file mode 100644 index 0000000..6bde996 Binary files /dev/null and b/mainui/res/mouse.png differ diff --git a/mainui/res/move.gif b/mainui/res/move.gif new file mode 100644 index 0000000..d6f31cb Binary files /dev/null and b/mainui/res/move.gif differ diff --git a/mainui/res/next.png b/mainui/res/next.png new file mode 100644 index 0000000..a2ba6b1 Binary files /dev/null and b/mainui/res/next.png differ diff --git a/mainui/res/no-net.png b/mainui/res/no-net.png new file mode 100644 index 0000000..dc62d18 Binary files /dev/null and b/mainui/res/no-net.png differ diff --git a/mainui/res/off.png b/mainui/res/off.png new file mode 100644 index 0000000..72a049f Binary files /dev/null and b/mainui/res/off.png differ diff --git a/mainui/res/on.png b/mainui/res/on.png new file mode 100644 index 0000000..251ec36 Binary files /dev/null and b/mainui/res/on.png differ diff --git a/mainui/res/other.png b/mainui/res/other.png new file mode 100644 index 0000000..253c9b6 Binary files /dev/null and b/mainui/res/other.png differ diff --git a/mainui/res/others.png b/mainui/res/others.png new file mode 100644 index 0000000..c2c86d0 Binary files /dev/null and b/mainui/res/others.png differ diff --git a/mainui/res/package.png b/mainui/res/package.png new file mode 100644 index 0000000..6d73f30 Binary files /dev/null and b/mainui/res/package.png differ diff --git a/mainui/res/package_check.png b/mainui/res/package_check.png new file mode 100644 index 0000000..f2ccd5c Binary files /dev/null and b/mainui/res/package_check.png differ diff --git a/mainui/res/package_logo.png b/mainui/res/package_logo.png new file mode 100644 index 0000000..8f14a27 Binary files /dev/null and b/mainui/res/package_logo.png differ diff --git a/mainui/res/package_logo_gray.png b/mainui/res/package_logo_gray.png new file mode 100644 index 0000000..71d9f68 Binary files /dev/null and b/mainui/res/package_logo_gray.png differ diff --git a/mainui/res/package_uncheck.png b/mainui/res/package_uncheck.png new file mode 100644 index 0000000..f54ffc2 Binary files /dev/null and b/mainui/res/package_uncheck.png differ diff --git a/mainui/res/pic.png b/mainui/res/pic.png new file mode 100644 index 0000000..ffdeb0d Binary files /dev/null and b/mainui/res/pic.png differ diff --git a/mainui/res/picture.png b/mainui/res/picture.png new file mode 100644 index 0000000..528c0ea Binary files /dev/null and b/mainui/res/picture.png differ diff --git a/mainui/res/play.png b/mainui/res/play.png new file mode 100644 index 0000000..4b0a87e Binary files /dev/null and b/mainui/res/play.png differ diff --git a/mainui/res/play_hover.png b/mainui/res/play_hover.png new file mode 100644 index 0000000..bed075d Binary files /dev/null and b/mainui/res/play_hover.png differ diff --git a/mainui/res/plugin/processmanager.png b/mainui/res/plugin/processmanager.png new file mode 100644 index 0000000..275f72f Binary files /dev/null and b/mainui/res/plugin/processmanager.png differ diff --git a/mainui/res/plugin/shredder.png b/mainui/res/plugin/shredder.png new file mode 100644 index 0000000..e8bdf21 Binary files /dev/null and b/mainui/res/plugin/shredder.png differ diff --git a/mainui/res/power.png b/mainui/res/power.png new file mode 100644 index 0000000..db538f3 Binary files /dev/null and b/mainui/res/power.png differ diff --git a/mainui/res/previewzone.png b/mainui/res/previewzone.png new file mode 100644 index 0000000..e0c020f Binary files /dev/null and b/mainui/res/previewzone.png differ diff --git a/mainui/res/processmanager.png b/mainui/res/processmanager.png new file mode 100644 index 0000000..275f72f Binary files /dev/null and b/mainui/res/processmanager.png differ diff --git a/mainui/res/program.png b/mainui/res/program.png new file mode 100644 index 0000000..266bc34 Binary files /dev/null and b/mainui/res/program.png differ diff --git a/mainui/res/qss/youker-assistant.qss b/mainui/res/qss/youker-assistant.qss new file mode 100644 index 0000000..25d09c7 --- /dev/null +++ b/mainui/res/qss/youker-assistant.qss @@ -0,0 +1,694 @@ +QSplitter::handle{ + background:lightgray; +} + +QLabel{ + color:#000000; + font-family: "方正黑体_GBK"; + font-size: 14px; + text-align: left; +} + +QLabel#grayLabel{ + color:gray; +} + +QLabel#titleLabel{ + color:black; +} + +QLabel#whiteLabel{ + color:#ffffff; + font-family: "方正黑体_GBK"; + font-size: 20px; + text-align: left; +} + +QLabel#smallWhiteLabel{ + color:#ffffff; + font-family: "方正黑体_GBK"; + font-size: 14px; + text-align: left; +} + +QLabel#tipLabel{ + color:#000000; + font-family: "方正黑体_GBK"; + font-size: 18px; + text-align: left; +} + +QLabel#bigblackLabel{ + color:#000000; + font-family: "方正黑体_GBK"; + font-size: 24px; + text-align: left; +} + +QLabel#middleblackLabel{ + color:#000000; + font-family: "方正黑体_GBK"; + font-size: 18px; + text-align: center; +} + +QLabel#smallgrayLabel{ + color:#b2b2b2; + font-family: "方正黑体_GBK"; + font-size: 14px; +} + +QLabel#tipLabel{ + color:#b2b2b2; + font-family: "方正黑体_GBK"; + font-size: 14; + text-align: left; +} + +QLabel#backgroundWhiteLabel{ + color:#ffffff; + font-family: "方正黑体_GBK"; + font-size: 14px; +} + +QLabel#backgroundLabel{ + color:#b2b2b2; + font-family: "方正黑体_GBK"; + font-size: 14px; +} + +QLabel#backgroundLabel::hover{ + color:#b2b2b2; + font-family: "方正黑体_GBK"; + font-size: 14px; +} + +QLabel#backgroundLabel::pressed{ + color:#b2b2b2; + font-family: "方正黑体_GBK"; + font-size: 14px; +} + +/*QStackedWidget{ + border:none; + background-color: cornsilk; + selection-color: #0a214c; + selection-background-color: #C19A6B; + font-family: "方正黑体_GBK"; + color: #000; +}*/ + +QWidget#transparentWidget { + /*border: none;*/ + background-color: transparent; +} + +/*QPushButton{ + background:transparent; + color:#000000; + font-family: "方正黑体_GBK"; + font-size: 8px; + text-align: center; +}*/ + +QPushButton#transparentButton{ + background:transparent; +} + +QPushButton#settingButton{ + /*color:rgb(0, 120, 230);*/ + color:#00609a; + background:transparent; + text-align: left; +} + +QPushButton#settingButton:hover{ + /*color:rgb(50, 150, 255);*/ + color:#3f96e4; +} + +QPushButton#settingButton:pressed{ + /*color:rgb(50, 150, 255);*/ + color:#3f96e4; +} + +QPushButton#backgroundButton{ + color:#ffffff; + border:none; + background:url(://res/btn-ground.png); +} + +QPushButton#blackButton{ + font-size:12px; + background:#ffffff; + border:1px solid #bebebe; + color:#000000; +} + +QPushButton#blackButton:hover{ + background-color:#ffffff; + border:1px solid #3f96e4; + color:#000000; +} + +QPushButton#blackButton:pressed{ + background-color:#ffffff; + border:1px solid #3f96e4; + color:#000000; +} + +QPushButton#underlineButton{ + background:transparent; + text-decoration:underline; + color:#cfd8dc; + font-family: "方正黑体_GBK"; + font-size: 14px; + text-align: center; +} + +QPushButton#underlineButton:hover{ + color:#ffffff; + text-decoration:underline; +} + +QPushButton#whiteButton{ + color:#ffffff; + font-family: "方正黑体_GBK"; + font-size: 16px; + text-align: center; + background:transparent; +} + +QPushButton#checkButton{ + color:#3f96e4; + font-family: "方正黑体_GBK"; + font-size: 14px; + text-align: center; + background:transparent; +} + +QPushButton#checkButton:hover{ + color:#4fc3f7; + font-family: "方正黑体_GBK"; + font-size: 14px; + text-align: center; + background:transparent; +} + +QPushButton#checkButton:pressed{ + color:#4fc3f7; + font-family: "方正黑体_GBK"; + font-size: 14px; + text-align: center; + background:transparent; +} + +QPushButton#greenButton{ + background:#52c832; + font-size:30px; + color:#ffffff; + border-radius:1px; +} + +QPushButton#greenButton:hover{ + background:#68d94a; +} + +QPushButton#greenButton:pressed{ + background:#40b222; +} + +QPushButton#backButton{ + font-size:14px; + color:#cfd8dc; +} + +QPushButton#backButton:hover{ + background:#ffffff; +} + +QPushButton#backButton:pressed{ + background:#ffffff; +} + +QPushButton#bottomButton{ + color:rgb(0, 120, 230); + background:transparent; +} + +QPushButton#bottomButton:hover{ + color:rgb(50, 150, 255); +} + +QPushButton#bottomButton:pressed{ + color:rgb(50, 150, 255); +} + +QPushButton#loginButton{ + background-image: url(://res/logo.png); + border: none; +} + +QPushButton#loginButton:hover{ + background-image: url(://res/logo-hover.png); +} + +QPushButton#loginButton:pressed{ + background-image: url(://res/logo-hover.png); +} + +QToolButton#commonToolButton{ + background-color:#ffffff; + border:none; + color:#b2b2b2; + font-family: "方正黑体_GBK"; + font-size: 14px; + text-align: center; +} + +QToolButton#commonToolButton::hover{ + background-color:#e9eef1; + color:#b2b2b2; + font-family: "方正黑体_GBK"; + font-size: 14px; + text-align: center; +} + +QToolButton#commonToolButton::pressed{ + background-color:#e9eef1; + color:#b2b2b2; + font-family: "方正黑体_GBK"; + font-size: 14px; + text-align: center; +} + +QToolButton#transparentToolButton{ + background:transparent; + border:none; + color:#00609a; + font-family: "方正黑体_GBK"; + font-size: 18px; + text-align: left; +} + +QToolButton#transparentToolButton::hover{ + color:#3f96e4; + font-family: "方正黑体_GBK"; + font-size: 18px; + text-align: left; +} + +QToolButton#transparentToolButton::pressed{ + color:#3f96e4; + font-family: "方正黑体_GBK"; + font-size: 18px; + text-align: left; +} + +/*-------------------QComboBox-------------------*/ +QComboBox{ + border:1px solid #32435E; + width: 150px; + height: 24px; +} + +QComboBox::hover{ + background-color:#a6d7ff; + border-color:#5D8B9E; +} + +QComboBox QAbstractItemView::item{ + height:24px; +} + +QComboBox::down-arrow{ + image:url(://res/arrow-normal.png); +} + +QComboBox::drop-down { + border:0px; + background-color:#64b5f6; +} + +/*QComboBox { + border: 1px solid #32435E; + border-radius: 1px; + padding: 1px 18px 1px 3px; + min-width: 150px; +}*/ +/*非编辑状态下,鼠标移到控件上的背景色和边框色*/ +/*QComboBox::hover{ + background-color:#a6d7ff; + border-color:#5D8B9E; +}*/ +/*QComboBox:editable { + background: #14ACF5; +}*/ + +/*非编辑状态下默认底色和编辑状态下鼠标移到非选中项的底色*/ +/*QComboBox:!editable, QComboBox::drop-down:editable { + background: #14ACF5; +}*/ + +/* QComboBox gets the "on" state when the popup is open */ +/*编辑状态下鼠标移到被勾选项时的底色*/ +/*QComboBox:!editable:on, QComboBox::drop-down:editable:on { + background:gray; +}*/ +/* shift the text when the popup opens */ +/*QComboBox:on { + padding-top: 3px; + padding-left: 4px; +}*/ + +/*右侧箭头图标的处理*/ +/*QComboBox::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + width: 15px; + border-left-width: 1px;*/ + /*border-left-color: #64b5f6;*//*箭头左侧分割线颜色*/ + /*border-left-style: solid; *//* just a single line */ + /*border-top-right-radius: 1px; *//* same radius as the QComboBox */ + /*border-bottom-right-radius: 1px; +}*/ + +/*QComboBox::down-arrow { + image: url(://res/arrow-normal.png); +}*/ +/* shift the arrow when popup is open */ +/*QComboBox::down-arrow:on { + top: 1px; + left: 1px; +}*/ + +/*QComboBox QAbstractItemView { + border: 1px solid #ffffff; + selection-background-color: #9B9B9B; + background: #e9eef0; +}*/ + +/*-------------------QScrollBar-------------------*/ +QScrollBar:vertical{ + margin:0px 0px 0px 0px; + background-color:rgb(255,255,255,100); + border:0px; + width:6px; +} + +QScrollBar::sub-line:vertical{ + subcontrol-origin:margin; + border:1px solid red; + height:13px; +} + +QScrollBar::up-arrow:vertical{ + subcontrol-origin:margin; + background-color:blue; + height:13px; +} + +QScrollBar::sub-page:vertical{ + background-color:#EEEDF0; +} + +QScrollBar::handle:vertical{ + background-color:#D1D0D2; + width:6px; +} + +QScrollBar::handle:vertical:hover{ + background-color:#14ACF5; + width:6px; +} + +QScrollBar::handle:vertical:pressed{ + background-color:#0B95D7; + width:6px; +} + +QScrollBar::add-page:vertical{ + background-color:#EEEDF0; +} + +QScrollBar::down-arrow:vertical{ + background-color:yellow; +} + +QScrollBar::add-line:vertical{ + subcontrol-origin:margin; + border:1px solid green; + height:13px; +} + +/*QListView{ + border:none; +}*/ + +QListView { + show-decoration-selected: 1; +} + +QListView::item:alternate { + background: #ffffff; +} + +/*QListView::item:selected { + border: 1px solid #3f96e4; +}*/ + +QListView::item:selected:!active { + /*background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #ABAFE5, stop: 1 #8588B2);*/ + background:#e9eef1; +} + +QListView::item:selected:active { + /*background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #6a6ea9, stop: 1 #888dd9);*/ + background:#3f96e4; +} + +QListView::item:hover { + /*background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #FAFBFE, stop: 1 #DCDEF1);*/ + background:#e9eef0; +} + +/*QListView::item:hover { + background-color: wheat; +}*/ + + +/*-------------------QListWidget-------------------*/ +QListWidget{ + border:none; +} + +QListWidget#animationListWidget{ + border: 1px solid #32435E; +} +QListWidget#animationListWidget::item:selected { + border:none; + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #6A848C, stop: 1.0 #0F9EAF); + padding:0px; + margin:0px; +} + +QListWidget#infoList{ + border:1px solid #e0e0e0;/*#d5e3ec*/ + border-radius:4px; +} + +QListWidget#infoList::item{ + height:31px; + padding-left:27px; + margin-top:-1px; + border:1px solid #d5e3ec; + background:#ffffff; + color:#000000; + font-family: "方正黑体_GBK"; + font-size: 12px; +} + +QListWidget#infoList::item:hover{ + background:#e9eef0; + color:#000000; + font-family: "方正黑体_GBK"; + font-size: 12px; + border:none; + margin:0px; +} + +QListWidget#infoList::item:selected { + border:none; + background:#3f96e4; + color:#ffffff; + font-family: "方正黑体_GBK"; + font-size: 12px; + margin:0px; +} + +QListWidget#infoList::item:selected:!active { + border-width: 0px ; +} +QListWidget#infoList::item:selected:active { + border-width: 1px; +} + +/*-------------------QTabWidget-------------------*/ +QTabWidget::tab-bar{ + alignment:center; +} +QTabBar::tab{ + left: 0px; + top: 0px; + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3); + border: 1px solid #C4C4C3; + border-bottom-color: #C2C7CB; + border-top-left-radius: 2px; + border-top-right-radius: 2px; + min-width: 137px; + min-height: 4ex; + padding: 1px; +} + +QTabBar::tab:selected, QTabBar::tab:hover{ + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #fafafa, stop: 0.4 #f4f4f4,stop: 0.5 #e7e7e7, stop: 1.0 #fafafa); +} + +QTabBar::tab:selected{ + border-color: #9B9B9B; + border-bottom-color: white; +} + +QTabBar::tab:first:selected{ + margin-left: 0; +} + +QTabBar::tab:last:selected{ + margin-right: 0; +} + +QTabBar::tab:only-one { + margin: 0; +} + +/*-------------------QGroupBox-------------------*/ +/*QGroupBox { + border: 1px solid #e0e0e0; + border-radius: 2px; + margin-top: 15px; + } + + QGroupBox::title { + subcontrol-origin: margin; + subcontrol-position: top left; + padding: 6px 3px; + color: #00609a; + font-weight:bold; + }*/ + +/*-------------------QMenu-------------------*/ +QMenu { + background-color: white; + border: 1px solid gray; + color: #4f4f4f; + padding: 1px; +} + +QMenu::item { + padding: 2px 80px 2px 20px; + border: 1px solid transparent; +} + +QMenu::item:disabled { + color: #4f4f4f; +} + +QMenu::item:selected { + border-color: gray; + background: white; +} + +QMenu::icon:checked { + +} + +QMenu::separator { + height: 1px; + background: #e0e0e0;/*#222222*/ + margin-left: 10px; + margin-right: 10px; + margin-top: 1px; + margin-bottom: 1px; +} + +QMenu::indicator { + width: 65px; + height: 13px; +} + +/*-------------------QRadioButton-------------------*/ +QRadioButton { + spacing: 5px; + font-size: 14px; + color:#000000; + font-family: "方正黑体_GBK"; +} + +QRadioButton::indicator { + width: 12px; + height: 12px +} + +QRadioButton::indicator:checked { + image: url(://res/radiobutton-select.png); +} + +QRadioButton::indicator:disabled { + image: url(://res/radiobutton-disable.png); +} + +QRadioButton::indicator:unchecked { + image: url(://res/radiobutton-unselect.png); +} + +QRadioButton::indicator:unchecked:hover { + image: url(://res/radiobutton-unselect.png); +} + +/*-------------------QCheckBox-------------------*/ +QCheckBox{ + spacing:5px; +} + +QCheckBox::indicator { + width:20px; + height:20px; +} + +QCheckBox::indicator:unchecked{ + image: url(://res/checkbox-unchecked.png); +} + +QCheckBox::indicator:unchecked:hover { + image: url(://res/checkbox-unchecked.png); +} + +QCheckBox::indicator:unchecked:pressed { + image: url(://res/checkbox-unchecked.png); +} + +QCheckBox::indicator:checked{ + image: url(://res/checkbox-checked.png); +} + +QCheckBox::indicator:checked:hover { + image: url(://res/checkbox-checked.png); +} + +QCheckBox::indicator:checked:pressed { + image: url(://res/checkbox-checked.png); +} diff --git a/mainui/res/radiobutton-disable.png b/mainui/res/radiobutton-disable.png new file mode 100644 index 0000000..d9074aa Binary files /dev/null and b/mainui/res/radiobutton-disable.png differ diff --git a/mainui/res/radiobutton-select.png b/mainui/res/radiobutton-select.png new file mode 100644 index 0000000..b15ed1f Binary files /dev/null and b/mainui/res/radiobutton-select.png differ diff --git a/mainui/res/radiobutton-unselect.png b/mainui/res/radiobutton-unselect.png new file mode 100644 index 0000000..24415f1 Binary files /dev/null and b/mainui/res/radiobutton-unselect.png differ diff --git a/mainui/res/radiobutton.png b/mainui/res/radiobutton.png new file mode 100644 index 0000000..da6a05d Binary files /dev/null and b/mainui/res/radiobutton.png differ diff --git a/mainui/res/red.png b/mainui/res/red.png new file mode 100644 index 0000000..a792e6e Binary files /dev/null and b/mainui/res/red.png differ diff --git a/mainui/res/remove.png b/mainui/res/remove.png new file mode 100644 index 0000000..1b29537 Binary files /dev/null and b/mainui/res/remove.png differ diff --git a/mainui/res/retry-hover.png b/mainui/res/retry-hover.png new file mode 100644 index 0000000..8f66b6f Binary files /dev/null and b/mainui/res/retry-hover.png differ diff --git a/mainui/res/retry-press.png b/mainui/res/retry-press.png new file mode 100644 index 0000000..1c889a5 Binary files /dev/null and b/mainui/res/retry-press.png differ diff --git a/mainui/res/retry.png b/mainui/res/retry.png new file mode 100644 index 0000000..b854e14 Binary files /dev/null and b/mainui/res/retry.png differ diff --git a/mainui/res/revoke.png b/mainui/res/revoke.png new file mode 100644 index 0000000..77c4e47 Binary files /dev/null and b/mainui/res/revoke.png differ diff --git a/mainui/res/revoke_hover.png b/mainui/res/revoke_hover.png new file mode 100644 index 0000000..9a4f4c8 Binary files /dev/null and b/mainui/res/revoke_hover.png differ diff --git a/mainui/res/scan.png b/mainui/res/scan.png new file mode 100644 index 0000000..7098cba Binary files /dev/null and b/mainui/res/scan.png differ diff --git a/mainui/res/screen.png b/mainui/res/screen.png new file mode 100644 index 0000000..f06be17 Binary files /dev/null and b/mainui/res/screen.png differ diff --git a/mainui/res/searchfile.png b/mainui/res/searchfile.png new file mode 100644 index 0000000..f3b9c03 Binary files /dev/null and b/mainui/res/searchfile.png differ diff --git a/mainui/res/shadow_gray_hover.png b/mainui/res/shadow_gray_hover.png new file mode 100644 index 0000000..c75769f Binary files /dev/null and b/mainui/res/shadow_gray_hover.png differ diff --git a/mainui/res/shadow_hover.png b/mainui/res/shadow_hover.png new file mode 100644 index 0000000..c8a1d64 Binary files /dev/null and b/mainui/res/shadow_hover.png differ diff --git a/mainui/res/shredder.png b/mainui/res/shredder.png new file mode 100644 index 0000000..2fe2125 Binary files /dev/null and b/mainui/res/shredder.png differ diff --git a/mainui/res/skin-cover.png b/mainui/res/skin-cover.png new file mode 100644 index 0000000..f8c9897 Binary files /dev/null and b/mainui/res/skin-cover.png differ diff --git a/mainui/res/skin/1.png b/mainui/res/skin/1.png new file mode 100644 index 0000000..909c1e7 Binary files /dev/null and b/mainui/res/skin/1.png differ diff --git a/mainui/res/skin/2.png b/mainui/res/skin/2.png new file mode 100644 index 0000000..8984625 Binary files /dev/null and b/mainui/res/skin/2.png differ diff --git a/mainui/res/skin/3.png b/mainui/res/skin/3.png new file mode 100644 index 0000000..7e9c1f5 Binary files /dev/null and b/mainui/res/skin/3.png differ diff --git a/mainui/res/skin/4.png b/mainui/res/skin/4.png new file mode 100644 index 0000000..750482f Binary files /dev/null and b/mainui/res/skin/4.png differ diff --git a/mainui/res/skin/5.png b/mainui/res/skin/5.png new file mode 100755 index 0000000..c8c1912 Binary files /dev/null and b/mainui/res/skin/5.png differ diff --git a/mainui/res/software-min.png b/mainui/res/software-min.png new file mode 100644 index 0000000..655bde1 Binary files /dev/null and b/mainui/res/software-min.png differ diff --git a/mainui/res/switch-closed-dangerous-hover.png b/mainui/res/switch-closed-dangerous-hover.png new file mode 100644 index 0000000..15d6cc6 Binary files /dev/null and b/mainui/res/switch-closed-dangerous-hover.png differ diff --git a/mainui/res/switch-closed-dangerous.png b/mainui/res/switch-closed-dangerous.png new file mode 100644 index 0000000..2d542a4 Binary files /dev/null and b/mainui/res/switch-closed-dangerous.png differ diff --git a/mainui/res/switch-closed-normal-hover.png b/mainui/res/switch-closed-normal-hover.png new file mode 100644 index 0000000..ccb773a Binary files /dev/null and b/mainui/res/switch-closed-normal-hover.png differ diff --git a/mainui/res/switch-closed-normal.png b/mainui/res/switch-closed-normal.png new file mode 100644 index 0000000..54df36c Binary files /dev/null and b/mainui/res/switch-closed-normal.png differ diff --git a/mainui/res/switch-off.png b/mainui/res/switch-off.png new file mode 100644 index 0000000..4fbec05 Binary files /dev/null and b/mainui/res/switch-off.png differ diff --git a/mainui/res/switch-on.png b/mainui/res/switch-on.png new file mode 100644 index 0000000..40112fb Binary files /dev/null and b/mainui/res/switch-on.png differ diff --git a/mainui/res/switch-opend-hover.png b/mainui/res/switch-opend-hover.png new file mode 100644 index 0000000..aa7c1db Binary files /dev/null and b/mainui/res/switch-opend-hover.png differ diff --git a/mainui/res/switch-opend.png b/mainui/res/switch-opend.png new file mode 100644 index 0000000..d1a137d Binary files /dev/null and b/mainui/res/switch-opend.png differ diff --git a/mainui/res/switch-shade.png b/mainui/res/switch-shade.png new file mode 100644 index 0000000..c19921f Binary files /dev/null and b/mainui/res/switch-shade.png differ diff --git a/mainui/res/sysBtn/close_button.png b/mainui/res/sysBtn/close_button.png new file mode 100644 index 0000000..c81f991 Binary files /dev/null and b/mainui/res/sysBtn/close_button.png differ diff --git a/mainui/res/sysBtn/main_menu.png b/mainui/res/sysBtn/main_menu.png new file mode 100644 index 0000000..4be245e Binary files /dev/null and b/mainui/res/sysBtn/main_menu.png differ diff --git a/mainui/res/sysBtn/min_button.png b/mainui/res/sysBtn/min_button.png new file mode 100644 index 0000000..f43e260 Binary files /dev/null and b/mainui/res/sysBtn/min_button.png differ diff --git a/mainui/res/sysBtn/skin_button.png b/mainui/res/sysBtn/skin_button.png new file mode 100644 index 0000000..1e8b50b Binary files /dev/null and b/mainui/res/sysBtn/skin_button.png differ diff --git a/mainui/res/system.png b/mainui/res/system.png new file mode 100644 index 0000000..5d3d64a Binary files /dev/null and b/mainui/res/system.png differ diff --git a/mainui/res/systeminfo.png b/mainui/res/systeminfo.png new file mode 100644 index 0000000..f87a36a Binary files /dev/null and b/mainui/res/systeminfo.png differ diff --git a/mainui/res/systemset.png b/mainui/res/systemset.png new file mode 100644 index 0000000..c5ae438 Binary files /dev/null and b/mainui/res/systemset.png differ diff --git a/mainui/res/systemsound.png b/mainui/res/systemsound.png new file mode 100644 index 0000000..678f4d6 Binary files /dev/null and b/mainui/res/systemsound.png differ diff --git a/mainui/res/systemtrace.png b/mainui/res/systemtrace.png new file mode 100644 index 0000000..8a5ed7a Binary files /dev/null and b/mainui/res/systemtrace.png differ diff --git a/mainui/res/theme-cover.png b/mainui/res/theme-cover.png new file mode 100644 index 0000000..70d42ff Binary files /dev/null and b/mainui/res/theme-cover.png differ diff --git a/mainui/res/theme/Ambiance.png b/mainui/res/theme/Ambiance.png new file mode 100644 index 0000000..dbe64df Binary files /dev/null and b/mainui/res/theme/Ambiance.png differ diff --git a/mainui/res/theme/HighContrast.png b/mainui/res/theme/HighContrast.png new file mode 100644 index 0000000..0a7de9a Binary files /dev/null and b/mainui/res/theme/HighContrast.png differ diff --git a/mainui/res/theme/Radiance.png b/mainui/res/theme/Radiance.png new file mode 100644 index 0000000..1cedbb7 Binary files /dev/null and b/mainui/res/theme/Radiance.png differ diff --git a/mainui/res/theme/disappear.png b/mainui/res/theme/disappear.png new file mode 100644 index 0000000..bb50804 Binary files /dev/null and b/mainui/res/theme/disappear.png differ diff --git a/mainui/res/theme/ubuntukylin-theme.png b/mainui/res/theme/ubuntukylin-theme.png new file mode 100644 index 0000000..a0ed2c5 Binary files /dev/null and b/mainui/res/theme/ubuntukylin-theme.png differ diff --git a/mainui/res/themeset.png b/mainui/res/themeset.png new file mode 100644 index 0000000..7c3616f Binary files /dev/null and b/mainui/res/themeset.png differ diff --git a/mainui/res/thumbnails.png b/mainui/res/thumbnails.png new file mode 100644 index 0000000..3279a71 Binary files /dev/null and b/mainui/res/thumbnails.png differ diff --git a/mainui/res/title.png b/mainui/res/title.png new file mode 100644 index 0000000..4532d81 Binary files /dev/null and b/mainui/res/title.png differ diff --git a/mainui/res/tool-hover.png b/mainui/res/tool-hover.png new file mode 100644 index 0000000..7bdbe45 Binary files /dev/null and b/mainui/res/tool-hover.png differ diff --git a/mainui/res/toolkits.png b/mainui/res/toolkits.png new file mode 100644 index 0000000..208296c Binary files /dev/null and b/mainui/res/toolkits.png differ diff --git a/mainui/res/touchpad.png b/mainui/res/touchpad.png new file mode 100644 index 0000000..4d90b30 Binary files /dev/null and b/mainui/res/touchpad.png differ diff --git a/mainui/res/trace.png b/mainui/res/trace.png new file mode 100644 index 0000000..f1fafb7 Binary files /dev/null and b/mainui/res/trace.png differ diff --git a/mainui/res/trace_check.png b/mainui/res/trace_check.png new file mode 100644 index 0000000..9731dec Binary files /dev/null and b/mainui/res/trace_check.png differ diff --git a/mainui/res/trace_logo.png b/mainui/res/trace_logo.png new file mode 100644 index 0000000..6e5702f Binary files /dev/null and b/mainui/res/trace_logo.png differ diff --git a/mainui/res/trace_logo_gray.png b/mainui/res/trace_logo_gray.png new file mode 100644 index 0000000..f74122e Binary files /dev/null and b/mainui/res/trace_logo_gray.png differ diff --git a/mainui/res/trace_uncheck.png b/mainui/res/trace_uncheck.png new file mode 100644 index 0000000..b0e9f76 Binary files /dev/null and b/mainui/res/trace_uncheck.png differ diff --git a/mainui/res/ubuntukylin-software-center.png b/mainui/res/ubuntukylin-software-center.png new file mode 100644 index 0000000..736a850 Binary files /dev/null and b/mainui/res/ubuntukylin-software-center.png differ diff --git a/mainui/res/ubuntukylin.png b/mainui/res/ubuntukylin.png new file mode 100644 index 0000000..debea0d Binary files /dev/null and b/mainui/res/ubuntukylin.png differ diff --git a/mainui/res/underline.png b/mainui/res/underline.png new file mode 100644 index 0000000..c6b8024 Binary files /dev/null and b/mainui/res/underline.png differ diff --git a/mainui/res/unity.png b/mainui/res/unity.png new file mode 100644 index 0000000..cb7b768 Binary files /dev/null and b/mainui/res/unity.png differ diff --git a/mainui/res/upgrade-normal.png b/mainui/res/upgrade-normal.png new file mode 100644 index 0000000..de90aff Binary files /dev/null and b/mainui/res/upgrade-normal.png differ diff --git a/mainui/res/upgrade-ok.png b/mainui/res/upgrade-ok.png new file mode 100644 index 0000000..d6ec797 Binary files /dev/null and b/mainui/res/upgrade-ok.png differ diff --git a/mainui/res/upgrading/1.png b/mainui/res/upgrading/1.png new file mode 100644 index 0000000..ff1d438 Binary files /dev/null and b/mainui/res/upgrading/1.png differ diff --git a/mainui/res/upgrading/10.png b/mainui/res/upgrading/10.png new file mode 100644 index 0000000..b6f4e0f Binary files /dev/null and b/mainui/res/upgrading/10.png differ diff --git a/mainui/res/upgrading/11.png b/mainui/res/upgrading/11.png new file mode 100644 index 0000000..bf739f2 Binary files /dev/null and b/mainui/res/upgrading/11.png differ diff --git a/mainui/res/upgrading/12.png b/mainui/res/upgrading/12.png new file mode 100644 index 0000000..667ed62 Binary files /dev/null and b/mainui/res/upgrading/12.png differ diff --git a/mainui/res/upgrading/13.png b/mainui/res/upgrading/13.png new file mode 100644 index 0000000..446561b Binary files /dev/null and b/mainui/res/upgrading/13.png differ diff --git a/mainui/res/upgrading/14.png b/mainui/res/upgrading/14.png new file mode 100644 index 0000000..c9dca57 Binary files /dev/null and b/mainui/res/upgrading/14.png differ diff --git a/mainui/res/upgrading/15.png b/mainui/res/upgrading/15.png new file mode 100644 index 0000000..4f0227b Binary files /dev/null and b/mainui/res/upgrading/15.png differ diff --git a/mainui/res/upgrading/16.png b/mainui/res/upgrading/16.png new file mode 100644 index 0000000..7cedd49 Binary files /dev/null and b/mainui/res/upgrading/16.png differ diff --git a/mainui/res/upgrading/17.png b/mainui/res/upgrading/17.png new file mode 100644 index 0000000..10906bd Binary files /dev/null and b/mainui/res/upgrading/17.png differ diff --git a/mainui/res/upgrading/18.png b/mainui/res/upgrading/18.png new file mode 100644 index 0000000..eaf635d Binary files /dev/null and b/mainui/res/upgrading/18.png differ diff --git a/mainui/res/upgrading/19.png b/mainui/res/upgrading/19.png new file mode 100644 index 0000000..85619bf Binary files /dev/null and b/mainui/res/upgrading/19.png differ diff --git a/mainui/res/upgrading/2.png b/mainui/res/upgrading/2.png new file mode 100644 index 0000000..0806cdb Binary files /dev/null and b/mainui/res/upgrading/2.png differ diff --git a/mainui/res/upgrading/20.png b/mainui/res/upgrading/20.png new file mode 100644 index 0000000..66328a2 Binary files /dev/null and b/mainui/res/upgrading/20.png differ diff --git a/mainui/res/upgrading/21.png b/mainui/res/upgrading/21.png new file mode 100644 index 0000000..a736ded Binary files /dev/null and b/mainui/res/upgrading/21.png differ diff --git a/mainui/res/upgrading/22.png b/mainui/res/upgrading/22.png new file mode 100644 index 0000000..e1ed321 Binary files /dev/null and b/mainui/res/upgrading/22.png differ diff --git a/mainui/res/upgrading/23.png b/mainui/res/upgrading/23.png new file mode 100644 index 0000000..45fb115 Binary files /dev/null and b/mainui/res/upgrading/23.png differ diff --git a/mainui/res/upgrading/24.png b/mainui/res/upgrading/24.png new file mode 100644 index 0000000..9881594 Binary files /dev/null and b/mainui/res/upgrading/24.png differ diff --git a/mainui/res/upgrading/25.png b/mainui/res/upgrading/25.png new file mode 100644 index 0000000..199a7c3 Binary files /dev/null and b/mainui/res/upgrading/25.png differ diff --git a/mainui/res/upgrading/26.png b/mainui/res/upgrading/26.png new file mode 100644 index 0000000..ae79404 Binary files /dev/null and b/mainui/res/upgrading/26.png differ diff --git a/mainui/res/upgrading/27.png b/mainui/res/upgrading/27.png new file mode 100644 index 0000000..a8734cd Binary files /dev/null and b/mainui/res/upgrading/27.png differ diff --git a/mainui/res/upgrading/28.png b/mainui/res/upgrading/28.png new file mode 100644 index 0000000..18c8617 Binary files /dev/null and b/mainui/res/upgrading/28.png differ diff --git a/mainui/res/upgrading/29.png b/mainui/res/upgrading/29.png new file mode 100644 index 0000000..9637d30 Binary files /dev/null and b/mainui/res/upgrading/29.png differ diff --git a/mainui/res/upgrading/3.png b/mainui/res/upgrading/3.png new file mode 100644 index 0000000..8db953e Binary files /dev/null and b/mainui/res/upgrading/3.png differ diff --git a/mainui/res/upgrading/30.png b/mainui/res/upgrading/30.png new file mode 100644 index 0000000..b2edd92 Binary files /dev/null and b/mainui/res/upgrading/30.png differ diff --git a/mainui/res/upgrading/31.png b/mainui/res/upgrading/31.png new file mode 100644 index 0000000..2e79501 Binary files /dev/null and b/mainui/res/upgrading/31.png differ diff --git a/mainui/res/upgrading/32.png b/mainui/res/upgrading/32.png new file mode 100644 index 0000000..aa87946 Binary files /dev/null and b/mainui/res/upgrading/32.png differ diff --git a/mainui/res/upgrading/4.png b/mainui/res/upgrading/4.png new file mode 100644 index 0000000..afb50cb Binary files /dev/null and b/mainui/res/upgrading/4.png differ diff --git a/mainui/res/upgrading/5.png b/mainui/res/upgrading/5.png new file mode 100644 index 0000000..3994008 Binary files /dev/null and b/mainui/res/upgrading/5.png differ diff --git a/mainui/res/upgrading/6.png b/mainui/res/upgrading/6.png new file mode 100644 index 0000000..0f47a77 Binary files /dev/null and b/mainui/res/upgrading/6.png differ diff --git a/mainui/res/upgrading/7.png b/mainui/res/upgrading/7.png new file mode 100644 index 0000000..7b6a591 Binary files /dev/null and b/mainui/res/upgrading/7.png differ diff --git a/mainui/res/upgrading/8.png b/mainui/res/upgrading/8.png new file mode 100644 index 0000000..c3c3882 Binary files /dev/null and b/mainui/res/upgrading/8.png differ diff --git a/mainui/res/upgrading/9.png b/mainui/res/upgrading/9.png new file mode 100644 index 0000000..101e19a Binary files /dev/null and b/mainui/res/upgrading/9.png differ diff --git a/mainui/res/using.png b/mainui/res/using.png new file mode 100644 index 0000000..2426329 Binary files /dev/null and b/mainui/res/using.png differ diff --git a/mainui/res/version.png b/mainui/res/version.png new file mode 100644 index 0000000..4983400 Binary files /dev/null and b/mainui/res/version.png differ diff --git a/mainui/res/view.png b/mainui/res/view.png new file mode 100644 index 0000000..7c29a5e Binary files /dev/null and b/mainui/res/view.png differ diff --git a/mainui/res/working/1.png b/mainui/res/working/1.png new file mode 100644 index 0000000..089031a Binary files /dev/null and b/mainui/res/working/1.png differ diff --git a/mainui/res/working/10.png b/mainui/res/working/10.png new file mode 100644 index 0000000..bfe54fe Binary files /dev/null and b/mainui/res/working/10.png differ diff --git a/mainui/res/working/11.png b/mainui/res/working/11.png new file mode 100644 index 0000000..7b6856d Binary files /dev/null and b/mainui/res/working/11.png differ diff --git a/mainui/res/working/12.png b/mainui/res/working/12.png new file mode 100644 index 0000000..d2d57ab Binary files /dev/null and b/mainui/res/working/12.png differ diff --git a/mainui/res/working/13.png b/mainui/res/working/13.png new file mode 100644 index 0000000..77d4312 Binary files /dev/null and b/mainui/res/working/13.png differ diff --git a/mainui/res/working/14.png b/mainui/res/working/14.png new file mode 100644 index 0000000..d9b1d5a Binary files /dev/null and b/mainui/res/working/14.png differ diff --git a/mainui/res/working/15.png b/mainui/res/working/15.png new file mode 100644 index 0000000..4256536 Binary files /dev/null and b/mainui/res/working/15.png differ diff --git a/mainui/res/working/16.png b/mainui/res/working/16.png new file mode 100644 index 0000000..d491552 Binary files /dev/null and b/mainui/res/working/16.png differ diff --git a/mainui/res/working/17.png b/mainui/res/working/17.png new file mode 100644 index 0000000..9e19308 Binary files /dev/null and b/mainui/res/working/17.png differ diff --git a/mainui/res/working/18.png b/mainui/res/working/18.png new file mode 100644 index 0000000..6752540 Binary files /dev/null and b/mainui/res/working/18.png differ diff --git a/mainui/res/working/19.png b/mainui/res/working/19.png new file mode 100644 index 0000000..3dc42cc Binary files /dev/null and b/mainui/res/working/19.png differ diff --git a/mainui/res/working/2.png b/mainui/res/working/2.png new file mode 100644 index 0000000..56e4d24 Binary files /dev/null and b/mainui/res/working/2.png differ diff --git a/mainui/res/working/20.png b/mainui/res/working/20.png new file mode 100644 index 0000000..fe7f845 Binary files /dev/null and b/mainui/res/working/20.png differ diff --git a/mainui/res/working/21.png b/mainui/res/working/21.png new file mode 100644 index 0000000..05e154a Binary files /dev/null and b/mainui/res/working/21.png differ diff --git a/mainui/res/working/22.png b/mainui/res/working/22.png new file mode 100644 index 0000000..9cffda2 Binary files /dev/null and b/mainui/res/working/22.png differ diff --git a/mainui/res/working/23.png b/mainui/res/working/23.png new file mode 100644 index 0000000..4be6ca9 Binary files /dev/null and b/mainui/res/working/23.png differ diff --git a/mainui/res/working/24.png b/mainui/res/working/24.png new file mode 100644 index 0000000..7e91443 Binary files /dev/null and b/mainui/res/working/24.png differ diff --git a/mainui/res/working/25.png b/mainui/res/working/25.png new file mode 100644 index 0000000..dbb98f8 Binary files /dev/null and b/mainui/res/working/25.png differ diff --git a/mainui/res/working/26.png b/mainui/res/working/26.png new file mode 100644 index 0000000..8152e47 Binary files /dev/null and b/mainui/res/working/26.png differ diff --git a/mainui/res/working/27.png b/mainui/res/working/27.png new file mode 100644 index 0000000..f1410e2 Binary files /dev/null and b/mainui/res/working/27.png differ diff --git a/mainui/res/working/28.png b/mainui/res/working/28.png new file mode 100644 index 0000000..77b6c44 Binary files /dev/null and b/mainui/res/working/28.png differ diff --git a/mainui/res/working/29.png b/mainui/res/working/29.png new file mode 100644 index 0000000..97948ed Binary files /dev/null and b/mainui/res/working/29.png differ diff --git a/mainui/res/working/3.png b/mainui/res/working/3.png new file mode 100644 index 0000000..43f83b8 Binary files /dev/null and b/mainui/res/working/3.png differ diff --git a/mainui/res/working/30.png b/mainui/res/working/30.png new file mode 100644 index 0000000..21c4fb4 Binary files /dev/null and b/mainui/res/working/30.png differ diff --git a/mainui/res/working/31.png b/mainui/res/working/31.png new file mode 100644 index 0000000..bf34336 Binary files /dev/null and b/mainui/res/working/31.png differ diff --git a/mainui/res/working/32.png b/mainui/res/working/32.png new file mode 100644 index 0000000..2fb9d94 Binary files /dev/null and b/mainui/res/working/32.png differ diff --git a/mainui/res/working/33.png b/mainui/res/working/33.png new file mode 100644 index 0000000..deb9d57 Binary files /dev/null and b/mainui/res/working/33.png differ diff --git a/mainui/res/working/34.png b/mainui/res/working/34.png new file mode 100644 index 0000000..2e1ae63 Binary files /dev/null and b/mainui/res/working/34.png differ diff --git a/mainui/res/working/35.png b/mainui/res/working/35.png new file mode 100644 index 0000000..0a05dc0 Binary files /dev/null and b/mainui/res/working/35.png differ diff --git a/mainui/res/working/36.png b/mainui/res/working/36.png new file mode 100644 index 0000000..b328dd9 Binary files /dev/null and b/mainui/res/working/36.png differ diff --git a/mainui/res/working/4.png b/mainui/res/working/4.png new file mode 100644 index 0000000..4b72244 Binary files /dev/null and b/mainui/res/working/4.png differ diff --git a/mainui/res/working/5.png b/mainui/res/working/5.png new file mode 100644 index 0000000..c752062 Binary files /dev/null and b/mainui/res/working/5.png differ diff --git a/mainui/res/working/6.png b/mainui/res/working/6.png new file mode 100644 index 0000000..3445123 Binary files /dev/null and b/mainui/res/working/6.png differ diff --git a/mainui/res/working/7.png b/mainui/res/working/7.png new file mode 100644 index 0000000..b80f7b9 Binary files /dev/null and b/mainui/res/working/7.png differ diff --git a/mainui/res/working/8.png b/mainui/res/working/8.png new file mode 100644 index 0000000..7e572c4 Binary files /dev/null and b/mainui/res/working/8.png differ diff --git a/mainui/res/working/9.png b/mainui/res/working/9.png new file mode 100644 index 0000000..3c320c8 Binary files /dev/null and b/mainui/res/working/9.png differ diff --git a/mainui/res/yellow.png b/mainui/res/yellow.png new file mode 100644 index 0000000..6fd001a Binary files /dev/null and b/mainui/res/yellow.png differ diff --git a/mainui/res/youker-assistant.png b/mainui/res/youker-assistant.png new file mode 100644 index 0000000..4d4724c Binary files /dev/null and b/mainui/res/youker-assistant.png differ diff --git a/mainui/settingactionwidget.cpp b/mainui/settingactionwidget.cpp new file mode 100644 index 0000000..0b8d2c7 --- /dev/null +++ b/mainui/settingactionwidget.cpp @@ -0,0 +1,275 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "settingactionwidget.h" +#include "mainwindow.h" + +SettingActionWidget::SettingActionWidget(QString cur_desktop, QWidget *parent) + : QWidget(parent), desktop(cur_desktop) +{ + this->setFixedSize(900, 150); + this->setAutoFillBackground(true); + this->setObjectName("transparentWidget"); + + img_label = new QLabel(); + title_label = new QLabel(); +// description_label = new QLabel(); + main_acion = new QWidget(); + img_label->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小 + QPixmap label_pixmap("://res/systemset.png"); + img_label->setPixmap(label_pixmap); + img_label->setFixedSize(label_pixmap.size()); + + title_label->setObjectName("whiteLabel"); +// description_label->setWordWrap(true);//QLabel自动换行 +// description_label->setObjectName("tipLabel"); + +// QVBoxLayout *layout1 = new QVBoxLayout(); +// layout1->addStretch(); +// layout1->addWidget(title_label); +// layout1->addWidget(description_label); +// layout1->addStretch(); +// layout1->setSpacing(15); +// layout1->setMargin(0); +// layout1->setContentsMargins(0, 0, 0, 0); + + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->addWidget(img_label, 0, Qt::AlignVCenter); + layout2->addWidget(title_label, 0, Qt::AlignVCenter); +// layout2->addLayout(layout1); + layout2->setSpacing(20); + layout2->setMargin(0); + layout2->setContentsMargins(20, 20, 0, 0); + + main_acion->setLayout(layout2); + + stacked_widget = new QStackedWidget(this);//stacked_widget will delete when SettingWidget delete + theme_action = new SettingAction(desktop); + theme_action->setLanguage(1); + + icon_action = new SettingAction(desktop); + icon_action->setLanguage(2); + mouse_action = new SettingAction(desktop); + mouse_action->setLanguage(3); + voice_action = new SettingAction(desktop); + voice_action->setLanguage(4); +// animation_action = new SettingAction(desktop); +// animation_action->setLanguage(5); + launcher_action = new SettingAction(desktop); + launcher_action->setLanguage(5); + panel_action = new SettingAction(desktop); + panel_action->setLanguage(6); + window_action = new SettingAction(desktop); + window_action->setLanguage(7); + font_action = new SettingAction(desktop); + font_action->setLanguage(8); + touchpad_action = new SettingAction(desktop); + touchpad_action->setLanguage(9); + deadpixel_action = new SettingAction(desktop); + deadpixel_action->setLanguage(10); + conserve_aciton = new SettingAction(desktop); + conserve_aciton->setLanguage(11); + nautilus_action = new SettingAction(desktop); + nautilus_action->setLanguage(12); + stacked_widget->addWidget(main_acion); + stacked_widget->addWidget(theme_action); + stacked_widget->addWidget(icon_action); + stacked_widget->addWidget(mouse_action); + stacked_widget->addWidget(voice_action); +// stacked_widget->addWidget(animation_action); + stacked_widget->addWidget(launcher_action); + stacked_widget->addWidget(panel_action); + stacked_widget->addWidget(window_action); + stacked_widget->addWidget(font_action); + stacked_widget->addWidget(touchpad_action); + stacked_widget->addWidget(deadpixel_action); + stacked_widget->addWidget(conserve_aciton); + stacked_widget->addWidget(nautilus_action); + + + + QHBoxLayout *main_layout = new QHBoxLayout(); + main_layout->addWidget(stacked_widget); + main_layout->setSpacing(0); + main_layout->setContentsMargins(0, 0, 0, 0); + + this->setLayout(main_layout); + this->initConnect(); + this->setLanguage(); +} + +SettingActionWidget::~SettingActionWidget() +{ + if(img_label != NULL) + { + delete img_label; + img_label = NULL; + } + if(title_label != NULL) + { + delete title_label; + title_label = NULL; + } + if(main_acion != NULL) + { + delete main_acion; + main_acion = NULL; + } + if(theme_action != NULL) + { + delete theme_action; + theme_action = NULL; + } + if(icon_action != NULL) + { + delete icon_action; + icon_action = NULL; + } + if(mouse_action != NULL) + { + delete mouse_action; + mouse_action = NULL; + } + if(voice_action != NULL) + { + delete voice_action; + voice_action = NULL; + } + if(launcher_action != NULL) + { + delete launcher_action; + launcher_action = NULL; + } + if(panel_action != NULL) + { + delete panel_action; + panel_action = NULL; + } + if(window_action != NULL) + { + delete window_action; + window_action = NULL; + } + if(font_action != NULL) + { + delete font_action; + font_action = NULL; + } + if(touchpad_action != NULL) + { + delete touchpad_action; + touchpad_action = NULL; + } + if(deadpixel_action != NULL) + { + delete deadpixel_action; + deadpixel_action = NULL; + } + + if(conserve_aciton != NULL) + { + delete conserve_aciton; + conserve_aciton = NULL; + } + if(nautilus_action != NULL) + { + delete nautilus_action; + nautilus_action = NULL; + } +} + +void SettingActionWidget::initConnect() +{ + connect(theme_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(icon_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(mouse_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(voice_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); +// connect(animation_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(launcher_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(panel_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(window_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(font_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(touchpad_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(deadpixel_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(conserve_aciton, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); + connect(nautilus_action, SIGNAL(showSettingMainWidget()), this, SLOT(displayActionMainPage())); +} + + +void SettingActionWidget::setLanguage() +{ + title_label->setText(tr("You can perform a full range of customized systems based on personal preferences"));//您可以根据个人喜好对系统进行全方位的定制 +// description_label->setText(tr("您可以根据个人喜好对系统进行全方位的定制")); +} + +void SettingActionWidget::displayActionSubPage(int index) +{ + stacked_widget->setCurrentIndex(index); +} + +void SettingActionWidget::displayActionMainPage() { + stacked_widget->setCurrentIndex(0); + emit this->notifyContentPageToMain(); +// QObject *object = QObject::sender(); +// QAction *action = qobject_cast(object); +// QString object_name = action->objectName(); +// int index = object_name.toInt(); + + + +// QObject *object = QObject::sender(); +// QPushButton *btn = qobject_cast(object); +// QString object_name = btn->statusTip(); +// if (object_name == "theme") { +// stacked_widget->setCurrentIndex(1); +// } +// else if (object_name == "icon") { +// stacked_widget->setCurrentIndex(2); +// } +// else if (object_name == "mouse") { +// stacked_widget->setCurrentIndex(3); +// } +// else if (object_name == "voice") { +// stacked_widget->setCurrentIndex(4); +// } +// else if (object_name == "animation") { +// stacked_widget->setCurrentIndex(5); +// } +// else if (object_name == "launcher") { +// stacked_widget->setCurrentIndex(6); +// } +// else if (object_name == "panel") { +// stacked_widget->setCurrentIndex(7); +// } +// else if (object_name == "window") { +// stacked_widget->setCurrentIndex(8); +// } +// else if (object_name == "font") { +// stacked_widget->setCurrentIndex(9); +// } +// else if (object_name == "touchpad") { +// stacked_widget->setCurrentIndex(10); +// } +// else if (object_name == "deadpixel") { +// stacked_widget->setCurrentIndex(11); +// } +// else if (object_name == "nautilus") { +// stacked_widget->setCurrentIndex(12); +// } +} diff --git a/mainui/settingactionwidget.h b/mainui/settingactionwidget.h new file mode 100644 index 0000000..acd4604 --- /dev/null +++ b/mainui/settingactionwidget.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SETTINGACTIONWIDGET_H +#define SETTINGACTIONWIDGET_H + +#include +#include "../component/kylinbutton.h" +#include "../component/systembutton.h" +#include "../component/settingaction.h" + +class MainWindow; +class QStackedWidget; + +class SettingActionWidget : public QWidget +{ + Q_OBJECT +public: + explicit SettingActionWidget(QString cur_desktop = "", QWidget *parent = 0); + ~SettingActionWidget(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void setLanguage(); + void initConnect(); + +public slots: + void displayActionMainPage(); + void displayActionSubPage(int index); + +signals: + void notifyContentPageToMain(); + +private: + QLabel *img_label; + QLabel *title_label; + QStackedWidget *stacked_widget; + QWidget *main_acion; + SettingAction *theme_action; + SettingAction *icon_action; + SettingAction *mouse_action; + SettingAction *voice_action; +// SettingAction *animation_action; + SettingAction *launcher_action; + SettingAction *panel_action; + SettingAction *window_action; + SettingAction *font_action; + SettingAction *touchpad_action; + SettingAction *deadpixel_action; + SettingAction *conserve_aciton; + SettingAction *nautilus_action; + + MainWindow *p_mainwindow; + QString desktop; +}; + +#endif // SETTINGACTIONWIDGET_H diff --git a/mainui/settingwidget.cpp b/mainui/settingwidget.cpp new file mode 100644 index 0000000..51221de --- /dev/null +++ b/mainui/settingwidget.cpp @@ -0,0 +1,835 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "settingwidget.h" +#include +//#include "../component/deadpixeldialog.h" +//#include "../dbusproxy/youkersessiondbus.h" +//#include "mainwindow.h" + +SettingWidget::SettingWidget(QString cur_desktop, bool has_battery, QWidget *parent) : + QWidget(parent), desktop(cur_desktop), battery(has_battery) +{ + this->setFixedSize(900, 403); + //set white background color + this->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Window, QBrush(Qt::white)); + this->setPalette(palette); + + this->qtui = NULL; + +// this->mainwindow_width = 850; +// this->mainwindow_height = 600; + + stacked_widget = new QStackedWidget(this);//stacked_widget will delete when SettingWidget delete + theme_widget = NULL; + icon_widget = NULL; + mouse_widget = NULL; + voice_widget = NULL; +// animation_widget = NULL; + launcher_widget = NULL; + panel_widget = NULL; + window_widget = NULL; + font_widget = NULL; + touchpad_widget = NULL; +// deadpixel_widget = NULL; + conserve_widget = NULL; + nautilus_widget = NULL; + + h_splitter = new QSplitter(this); + h_splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + h_splitter->setOrientation(Qt::Horizontal); + h_splitter->setHandleWidth(1); + + this->initIndividuationWidget(); + this->initDesktopWidget(); + this->initFontWidget(); + this->initOptionWidget(); + this->initOtherWidget(); + + individuation_widget->setFixedSize(170, 426); + dekstop_widget->setFixedSize(170, 426); + fonts_widget->setFixedSize(170, 426); + option_widget->setFixedSize(170, 426); + h_splitter->addWidget(individuation_widget); + h_splitter->addWidget(dekstop_widget); + h_splitter->addWidget(fonts_widget); + h_splitter->addWidget(option_widget); + h_splitter->addWidget(other_widget); + + for(int i = 0; icount();i++) + { + QSplitterHandle *handle = h_splitter->handle(i); + handle->setEnabled(false); + } + +// for(int i = 0; icount();i++) +// { +// QSplitterHandle *handle = v_splitter->handle(i); +// handle->setEnabled(false); +// } + +// QHBoxLayout *main_layout = new QHBoxLayout(); +// main_layout->addWidget(v_splitter); +// main_layout->setSpacing(0); +// main_layout->setContentsMargins(0, 0, 0, 0); + + +// connect(theme_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(icon_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(mouse_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(voice_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(animation_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(launcher_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(panel_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(window_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(font_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(touchpad_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(deadpixel_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +// connect(nautilus_widget, SIGNAL(showSettingMainWidget()), this, SLOT(displaySettingHomePage())); +} + +SettingWidget::~SettingWidget() +{ + + if(individuation_icon != NULL) + { + delete individuation_icon; + individuation_icon = NULL; + } + if(individuation_title != NULL) + { + delete individuation_title; + individuation_title = NULL; + } + if(dekstop_icon != NULL) + { + delete dekstop_icon; + dekstop_icon = NULL; + } + if(dekstop_title != NULL) + { + delete dekstop_title; + dekstop_title = NULL; + } + + + + if(font_icon != NULL) + { + delete font_icon; + font_icon = NULL; + } + if(font_title != NULL) + { + delete font_title; + font_title = NULL; + } + if(option_icon != NULL) + { + delete option_icon; + option_icon = NULL; + } + if(option_title != NULL) + { + delete option_title; + option_title = NULL; + } + if(other_icon != NULL) + { + delete other_icon; + other_icon = NULL; + } + if(other_title != NULL) + { + delete other_title; + other_title = NULL; + } + if(dot1 != NULL) + { + delete dot1; + dot1 = NULL; + } + if(dot2 != NULL) + { + delete dot2; + dot2 = NULL; + } + if(dot3 != NULL) + { + delete dot3; + dot3 = NULL; + } + if(dot4 != NULL) + { + delete dot4; + dot4 = NULL; + } + if(dot6 != NULL) + { + delete dot6; + dot6 = NULL; + } + if(dot7 != NULL) + { + delete dot7; + dot7 = NULL; + } + if(dot8 != NULL) + { + delete dot8; + dot8 = NULL; + } + if(dot9 != NULL) + { + delete dot9; + dot9 = NULL; + } + if(dot10 != NULL) + { + delete dot10; + dot10 = NULL; + } + if(dot11 != NULL) + { + delete dot11; + dot11 = NULL; + } + if(dot12 != NULL) + { + delete dot12; + dot12 = NULL; + } + if(dot13 != NULL) + { + delete dot13; + dot13 = NULL; + } + if(theme_button != NULL) + { + delete theme_button; + theme_button = NULL; + } + if(icon_button != NULL) + { + delete icon_button; + icon_button = NULL; + } + if(mouse_button != NULL) + { + delete mouse_button; + mouse_button = NULL; + } + if(voice_button != NULL) + { + delete voice_button; + voice_button = NULL; + } + if(launcher_button != NULL) + { + delete launcher_button; + launcher_button = NULL; + } + if(panel_button != NULL) + { + delete panel_button; + panel_button = NULL; + } + if(window_button != NULL) + { + delete window_button; + window_button = NULL; + } + if(font_button != NULL) + { + delete font_button; + font_button = NULL; + } + if(touch_button != NULL) + { + delete touch_button; + touch_button = NULL; + } + if(pixel_button != NULL) + { + delete pixel_button; + pixel_button = NULL; + } + if(conserve_button != NULL) + { + delete conserve_button; + conserve_button = NULL; + } + if(nautilus_button != NULL) + { + delete nautilus_button; + nautilus_button = NULL; + } + if(qtui != NULL) + { + delete qtui; + qtui = NULL; + } +} + +void SettingWidget::initUI(QString skin) +{ + theme_widget = new ThemeWidget(this, sessionProxy); + icon_widget = new IconWidget(this, sessionProxy, desktop); + mouse_widget = new MouseWidget(this, sessionProxy, systemProxy, desktop); + voice_widget = new VoiceWidget(this, sessionProxy, systemProxy, desktop); +// animation_widget = new AnimationWidget(this, systemProxy, p_mainwindow); + launcher_widget = new LauncherWidget(this, sessionProxy, desktop); + panel_widget = new PanelWidget(this, sessionProxy, desktop, battery); + window_widget = new WindowWidget(this, sessionProxy, desktop); + font_widget = new FontWidget(this, sessionProxy, p_mainwindow, desktop, skin); + touchpad_widget = new TouchpadWidget(this, sessionProxy, desktop); +// deadpixel_widget = new DeadpixelWidget(this); + conserve_widget = new ConserveWidget(this, sessionProxy, desktop, battery); + nautilus_widget = new NautilusWidget(this, sessionProxy); + stacked_widget->addWidget(h_splitter); + stacked_widget->addWidget(theme_widget); + stacked_widget->addWidget(icon_widget); + stacked_widget->addWidget(mouse_widget); + stacked_widget->addWidget(voice_widget); +// stacked_widget->addWidget(animation_widget); + stacked_widget->addWidget(launcher_widget); + stacked_widget->addWidget(panel_widget); + stacked_widget->addWidget(window_widget); + stacked_widget->addWidget(font_widget); + stacked_widget->addWidget(touchpad_widget); +// stacked_widget->addWidget(deadpixel_widget); + stacked_widget->addWidget(conserve_widget); + stacked_widget->addWidget(nautilus_widget); + + QHBoxLayout *main_layout = new QHBoxLayout(); + main_layout->addWidget(stacked_widget); + main_layout->setSpacing(0); + main_layout->setContentsMargins(0, 0, 0, 0); + + this->setLayout(main_layout); + +// connect(sessionProxy, SIGNAL(bool_value_notify(QString, bool)), this, SLOT(slot_notify_boolean(QString, bool))); +} + +//void SettingWidget::slot_notify_boolean(QString key, bool value) +//{ +//} +void SettingWidget::resetSkin(QString skin) +{ + if(font_widget != NULL) + font_widget->resetCurrentSkin(skin); +} + +void SettingWidget::initIndividuationWidget() { + individuation_widget = new QWidget(this); + individuation_icon = new QLabel(); + individuation_title = new QLabel(); + dot1 = new QLabel(); + theme_button = new QPushButton(); + dot2 = new QLabel(); + icon_button = new QPushButton(); + dot3 = new QLabel(); + mouse_button = new QPushButton(); + dot4 = new QLabel(); + voice_button = new QPushButton(); +// dot5 = new QLabel(); +// animation_button = new QPushButton(); + + theme_button->setFocusPolicy(Qt::NoFocus); + theme_button->setObjectName("settingButton"); + icon_button->setFocusPolicy(Qt::NoFocus); + icon_button->setObjectName("settingButton"); + mouse_button->setFocusPolicy(Qt::NoFocus); + mouse_button->setObjectName("settingButton"); + voice_button->setFocusPolicy(Qt::NoFocus); + voice_button->setObjectName("settingButton"); +// animation_button->setFocusPolicy(Qt::NoFocus); +// animation_button->setObjectName("settingButton"); + + QHBoxLayout *title_layout = new QHBoxLayout(); + title_layout->addWidget(individuation_icon); + title_layout->addWidget(individuation_title); + title_layout->addStretch(); + title_layout->setSpacing(10); + title_layout->setContentsMargins(20, 20, 0, 0); + title_layout->setAlignment(individuation_icon, Qt::AlignVCenter); + title_layout->setAlignment(individuation_title, Qt::AlignVCenter); + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->addWidget(dot1); + layout1->addWidget(theme_button); + layout1->addStretch(); + layout1->setSpacing(5); + layout1->setContentsMargins(29, 10, 0, 0); + layout1->setAlignment(dot1, Qt::AlignVCenter); + layout1->setAlignment(theme_button, Qt::AlignVCenter); + + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->addWidget(dot2); + layout2->addWidget(icon_button); + layout2->addStretch(); + layout2->setSpacing(5); + layout2->setContentsMargins(29, 0, 0, 0); + layout2->setAlignment(dot2, Qt::AlignVCenter); + layout2->setAlignment(icon_button, Qt::AlignVCenter); + + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->addWidget(dot3); + layout3->addWidget(mouse_button); + layout3->addStretch(); + layout3->setSpacing(5); + layout3->setContentsMargins(29, 0, 0, 0); + layout3->setAlignment(dot3, Qt::AlignVCenter); + layout3->setAlignment(mouse_button, Qt::AlignVCenter); + + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->addWidget(dot4); + layout4->addWidget(voice_button); + layout4->addStretch(); + layout4->setSpacing(5); + layout4->setContentsMargins(29, 0, 0, 0); + layout4->setAlignment(dot4, Qt::AlignVCenter); + layout4->setAlignment(voice_button, Qt::AlignVCenter); + +// QHBoxLayout *layout5 = new QHBoxLayout(); +// layout5->addWidget(dot5); +// layout5->addWidget(animation_button); +// layout5->addStretch(); +// layout5->setSpacing(5); +// layout5->setContentsMargins(29, 0, 0, 0); +// layout5->setAlignment(dot5, Qt::AlignVCenter); +// layout5->setAlignment(animation_button, Qt::AlignVCenter); + + QVBoxLayout *v_layout = new QVBoxLayout(); + v_layout->addLayout(title_layout); + v_layout->addLayout(layout1); + v_layout->addLayout(layout2); + v_layout->addLayout(layout3); + v_layout->addLayout(layout4); +// v_layout->addLayout(layout5); + v_layout->addStretch(); + v_layout->setSpacing(10); + v_layout->setContentsMargins(0, 0, 0, 0); + + individuation_widget->setLayout(v_layout); + + + individuation_icon->setPixmap(QPixmap("://res/custom.png")); + individuation_title->setText(tr("Personalize"));//个性化 + dot1->setPixmap(QPixmap("://res/dot.png")); + dot2->setPixmap(QPixmap("://res/dot.png")); + dot3->setPixmap(QPixmap("://res/dot.png")); + dot4->setPixmap(QPixmap("://res/dot.png")); +// dot5->setPixmap(QPixmap(":/res//dot.png")); + theme_button->setStatusTip("theme"); + icon_button->setStatusTip("icon"); + mouse_button->setStatusTip("mouse"); + voice_button->setStatusTip("voice"); +// animation_button->setStatusTip("animation"); + theme_button->setText(tr("ThemeSetting"));//主题设置 + icon_button->setText(tr("IconSetting"));//图标配置 + mouse_button->setText(tr("MousePointer"));//鼠标指针 + voice_button->setText(tr("SoundEffect"));//声音效果 +// animation_button->setText(tr("BootAnimation"));//开机动画 + + connect(theme_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); + connect(icon_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); + connect(mouse_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); + connect(voice_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); +// connect(animation_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); +} + +void SettingWidget::initDesktopWidget() { + dekstop_widget = new QWidget(this); + dekstop_icon = new QLabel(); + dekstop_title = new QLabel(); + dot6 = new QLabel(); + launcher_button = new QPushButton(); + dot7 = new QLabel(); + panel_button = new QPushButton(); + dot8 = new QLabel(); + window_button = new QPushButton(); + + launcher_button->setFocusPolicy(Qt::NoFocus); + launcher_button->setObjectName("settingButton"); + panel_button->setFocusPolicy(Qt::NoFocus); + panel_button->setObjectName("settingButton"); + window_button->setFocusPolicy(Qt::NoFocus); + window_button->setObjectName("settingButton"); + + QHBoxLayout *title_layout = new QHBoxLayout(); + title_layout->addWidget(dekstop_icon); + title_layout->addWidget(dekstop_title); + title_layout->addStretch(); + title_layout->setSpacing(10); + title_layout->setContentsMargins(20, 20, 0, 0); + title_layout->setAlignment(dekstop_icon, Qt::AlignVCenter); + title_layout->setAlignment(dekstop_title, Qt::AlignVCenter); + + QHBoxLayout *layout6 = new QHBoxLayout(); + layout6->addWidget(dot6); + layout6->addWidget(launcher_button); + layout6->addStretch(); + layout6->setSpacing(5); + layout6->setContentsMargins(29, 10, 0, 0); + layout6->setAlignment(dot6, Qt::AlignVCenter); + layout6->setAlignment(launcher_button, Qt::AlignVCenter); + + QHBoxLayout *layout7 = new QHBoxLayout(); + layout7->addWidget(dot7); + layout7->addWidget(panel_button); + layout7->addStretch(); + layout7->setSpacing(5); + layout7->setContentsMargins(29, 0, 0, 0); + layout7->setAlignment(dot7, Qt::AlignVCenter); + layout7->setAlignment(panel_button, Qt::AlignVCenter); + + QHBoxLayout *layout8 = new QHBoxLayout(); + layout8->addWidget(dot8); + layout8->addWidget(window_button); + layout8->addStretch(); + layout8->setMargin(0); + layout8->setSpacing(5); + layout8->setContentsMargins(29, 0, 0, 0); + layout8->setAlignment(dot8, Qt::AlignVCenter); + layout8->setAlignment(window_button, Qt::AlignVCenter); + + QVBoxLayout *v_layout = new QVBoxLayout(); + v_layout->addLayout(title_layout); + v_layout->addLayout(layout6); + v_layout->addLayout(layout7); + v_layout->addLayout(layout8); + v_layout->addStretch(); + v_layout->setSpacing(10); + v_layout->setContentsMargins(0, 0, 0, 0); + + dekstop_widget->setLayout(v_layout); + + dekstop_icon->setPixmap(QPixmap("://res/desktop.png")); + dekstop_title->setText(tr("Desktop"));//桌面 + dot6->setPixmap(QPixmap("://res/dot.png")); + dot7->setPixmap(QPixmap("://res/dot.png")); + dot8->setPixmap(QPixmap("://res/dot.png")); + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "ukui" || this->desktop == "UKUI") { + launcher_button->setText(tr("Panel"));//面板 + panel_button->setText(tr("StartMenu"));//启动菜单 + } + else { + launcher_button->setText(tr("Custom Launcher"));//自定义启动器 + panel_button->setText(tr("Dash & Panel"));//搜索和面板 + } + window_button->setText(tr("Window"));//窗口 + launcher_button->setStatusTip("launcher"); + panel_button->setStatusTip("panel"); + window_button->setStatusTip("window"); + + connect(launcher_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); + connect(panel_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); + connect(window_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); +} + +void SettingWidget::initFontWidget() { + fonts_widget = new QWidget(this); + font_icon = new QLabel(); + font_title = new QLabel(); + dot9 = new QLabel(); + font_button = new QPushButton(); + + font_button->setFocusPolicy(Qt::NoFocus); + font_button->setObjectName("settingButton"); + + QHBoxLayout *title_layout = new QHBoxLayout(); + title_layout->addWidget(font_icon); + title_layout->addWidget(font_title); + title_layout->addStretch(); + title_layout->setSpacing(10); + title_layout->setContentsMargins(20, 20, 0, 0); + title_layout->setAlignment(font_icon, Qt::AlignVCenter); + title_layout->setAlignment(font_title, Qt::AlignVCenter); + + QHBoxLayout *layout9 = new QHBoxLayout(); + layout9->addWidget(dot9); + layout9->addWidget(font_button); + layout9->addStretch(); + layout9->setSpacing(5); + layout9->setContentsMargins(29, 10, 0, 0); + layout9->setAlignment(dot9, Qt::AlignVCenter); + layout9->setAlignment(font_button, Qt::AlignVCenter); + + QVBoxLayout *v_layout = new QVBoxLayout(); + v_layout->addLayout(title_layout); + v_layout->addLayout(layout9); + v_layout->addStretch(); + v_layout->setSpacing(10); + v_layout->setContentsMargins(0, 0, 0, 0); + + fonts_widget->setLayout(v_layout); + + font_icon->setPixmap(QPixmap("://res/font.png")); + font_title->setText(tr("Font")); + dot9->setPixmap(QPixmap("://res/dot.png")); + font_button->setText(tr("FontSetting"));//字体设置 + font_button->setStatusTip("font"); + + connect(font_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); +} + +void SettingWidget::initOptionWidget() { + option_widget = new QWidget(this); + option_icon = new QLabel(); + option_title = new QLabel(); + dot10 = new QLabel(); + touch_button = new QPushButton(); + dot11 = new QLabel(); + pixel_button = new QPushButton(); + dot12 = new QLabel(); + conserve_button = new QPushButton(); + + touch_button->setFocusPolicy(Qt::NoFocus); + touch_button->setObjectName("settingButton"); + pixel_button->setFocusPolicy(Qt::NoFocus); + pixel_button->setObjectName("settingButton"); + conserve_button->setFocusPolicy(Qt::NoFocus); + conserve_button->setObjectName("settingButton"); + + QHBoxLayout *title_layout = new QHBoxLayout(); + title_layout->addWidget(option_icon); + title_layout->addWidget(option_title); + title_layout->addStretch(); + title_layout->setSpacing(10); + title_layout->setContentsMargins(20, 20, 0, 0); + title_layout->setAlignment(option_icon, Qt::AlignVCenter); + title_layout->setAlignment(option_title, Qt::AlignVCenter); + + QHBoxLayout *layout10 = new QHBoxLayout(); + layout10->addWidget(dot10); + layout10->addWidget(touch_button); + layout10->addStretch(); + layout10->setSpacing(5); + layout10->setContentsMargins(29, 10, 0, 0); + layout10->setAlignment(dot10, Qt::AlignVCenter); + layout10->setAlignment(touch_button, Qt::AlignVCenter); + + QHBoxLayout *layout11 = new QHBoxLayout(); + layout11->addWidget(dot11); + layout11->addWidget(pixel_button); + layout11->addStretch(); + layout11->setSpacing(5); + layout11->setContentsMargins(29, 0, 0, 0); + layout11->setAlignment(dot11, Qt::AlignVCenter); + layout11->setAlignment(pixel_button, Qt::AlignVCenter); + + QHBoxLayout *layout12 = new QHBoxLayout(); + layout12->addWidget(dot12); + layout12->addWidget(conserve_button); + layout12->addStretch(); + layout12->setSpacing(5); + layout12->setContentsMargins(29, 0, 0, 0); + layout12->setAlignment(dot12, Qt::AlignVCenter); + layout12->setAlignment(conserve_button, Qt::AlignVCenter); + + QVBoxLayout *v_layout = new QVBoxLayout(); + v_layout->addLayout(title_layout); + v_layout->addLayout(layout10); + v_layout->addLayout(layout11); + v_layout->addLayout(layout12); + v_layout->addStretch(); + v_layout->setSpacing(10); + v_layout->setContentsMargins(0, 0, 0, 0); + + option_widget->setLayout(v_layout); + + option_icon->setPixmap(QPixmap("://res/system.png")); + option_title->setText(tr("Sys options"));//系统选项 + dot10->setPixmap(QPixmap("://res/dot.png")); + dot11->setPixmap(QPixmap("://res/dot.png")); + dot12->setPixmap(QPixmap("://res/dot.png")); + touch_button->setText(tr("Touchpad"));//触摸板设置 + pixel_button->setText(tr("Dead pixel check"));//坏点检测 + conserve_button->setText(tr("Energy saving")); + touch_button->setStatusTip("touchpad"); + pixel_button->setStatusTip("deadpixel"); + conserve_button->setStatusTip("conserve"); + + connect(touch_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); +// connect(pixel_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); + connect(pixel_button, SIGNAL(clicked()), this, SLOT(startMonitorCheck())); + connect(conserve_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); +// connect(pixel_button, SIGNAL(clicked()), this, SLOT(showCheckscreenDialog())); +} + +void SettingWidget::initOtherWidget() { + other_widget = new QWidget(this); + other_icon = new QLabel(); + other_title = new QLabel(); + dot13 = new QLabel(); + nautilus_button = new QPushButton(); + + nautilus_button->setFocusPolicy(Qt::NoFocus); + nautilus_button->setObjectName("settingButton"); +// nautilus_button->setStyleSheet("QPushButton{color:rgb(0, 120, 230);background:transparent;}QPushButton:hover{color:rgb(50, 150, 255);}QPushButton:pressed{color:rgb(50, 150, 255);}"); + + QHBoxLayout *title_layout = new QHBoxLayout(); + title_layout->addWidget(other_icon); + title_layout->addWidget(other_title); + title_layout->addStretch(); + title_layout->setSpacing(10); + title_layout->setContentsMargins(20, 20, 0, 0); + title_layout->setAlignment(other_icon, Qt::AlignVCenter); + title_layout->setAlignment(other_title, Qt::AlignVCenter); + + QHBoxLayout *layout13 = new QHBoxLayout(); + layout13->addWidget(dot13); + layout13->addWidget(nautilus_button); + layout13->addStretch(); + layout13->setSpacing(5); + layout13->setContentsMargins(29, 0, 0, 0); + layout13->setAlignment(dot13, Qt::AlignVCenter); + layout13->setAlignment(nautilus_button, Qt::AlignVCenter); + + QVBoxLayout *v_layout = new QVBoxLayout(); + v_layout->addLayout(title_layout); + v_layout->addLayout(layout13); + v_layout->addStretch(); + v_layout->setSpacing(10); + v_layout->setContentsMargins(0, 0, 0, 0); + + other_widget->setLayout(v_layout); + + other_icon->setPixmap(QPixmap("://res/other.png")); + other_title->setText(tr("Others"));//杂项 + dot13->setPixmap(QPixmap("://res/dot.png")); + nautilus_button->setText(tr("File manager"));//文件管理器 + nautilus_button->setStatusTip("nautilus"); + + connect(nautilus_button, SIGNAL(clicked()), this, SLOT(displaySettingSubPage())); +} + +void SettingWidget::startMonitorCheck() { + if (this->qtui) + { + delete this->qtui; + this->qtui = NULL; + } + this->qtui = new QUIBO(); +} + +void SettingWidget::displaySettingHomePage() { + stacked_widget->setCurrentIndex(0); +} + +void SettingWidget::displaySettingSubPage() { +// QObject *object = QObject::sender(); +// QAction *action = qobject_cast(object); +// QString object_name = action->objectName(); +// int index = object_name.toInt(); + QObject *object = QObject::sender(); + QPushButton *btn = qobject_cast(object); + QString object_name = btn->statusTip(); + if (object_name == "theme") { + emit changeActionPage(1); + if(!theme_widget->getStatus()) + theme_widget->initData(); +// stacked_widget->setCurrentIndex(1); + stacked_widget->setCurrentWidget(theme_widget); + } + else if (object_name == "icon") { + emit changeActionPage(2); + if(!icon_widget->getStatus()) + icon_widget->initData(); +// stacked_widget->setCurrentIndex(2); + stacked_widget->setCurrentWidget(icon_widget); + } + else if (object_name == "mouse") { + emit changeActionPage(3); + if(!mouse_widget->getStatus()) + mouse_widget->initData(); +// stacked_widget->setCurrentIndex(3); + stacked_widget->setCurrentWidget(mouse_widget); + } + else if (object_name == "voice") { + emit changeActionPage(4); + if(!voice_widget->getStatus()) + voice_widget->initData(); +// stacked_widget->setCurrentIndex(4); + stacked_widget->setCurrentWidget(voice_widget); + } +// else if (object_name == "animation") { +// emit changeActionPage(5); +// if(!animation_widget->getStatus()) +// animation_widget->initData(); +// stacked_widget->setCurrentIndex(5); +// } + + else if (object_name == "launcher") { + emit changeActionPage(5); + if(!launcher_widget->getStatus()) + launcher_widget->initData(); +// stacked_widget->setCurrentIndex(5); + stacked_widget->setCurrentWidget(launcher_widget); + } + else if (object_name == "panel") { + emit changeActionPage(6); + if(!panel_widget->getStatus()) + panel_widget->initData(); +// stacked_widget->setCurrentIndex(6); + stacked_widget->setCurrentWidget(panel_widget); + } + else if (object_name == "window") { + emit changeActionPage(7); + if(!window_widget->getStatus()) + window_widget->initData(); +// stacked_widget->setCurrentIndex(7); + stacked_widget->setCurrentWidget(window_widget); + } + else if (object_name == "font") { + emit changeActionPage(8); + if(!font_widget->getStatus()) + font_widget->initData(); +// stacked_widget->setCurrentIndex(8); + stacked_widget->setCurrentWidget(font_widget); + } + else if (object_name == "touchpad") { + emit changeActionPage(9); + if(!touchpad_widget->getStatus()) + touchpad_widget->initData(); +// stacked_widget->setCurrentIndex(9); + stacked_widget->setCurrentWidget(touchpad_widget); + } +// else if (object_name == "deadpixel") { +// emit changeActionPage(10); +// stacked_widget->setCurrentIndex(10); +// } + else if (object_name == "conserve") { + emit changeActionPage(11); + if(!conserve_widget->getStatus()) + conserve_widget->initData(); +// stacked_widget->setCurrentIndex(11); + stacked_widget->setCurrentWidget(conserve_widget); + } + else if (object_name == "nautilus") { + emit changeActionPage(12); + if(!nautilus_widget->getStatus()) + nautilus_widget->initData(); +// stacked_widget->setCurrentIndex(12); + stacked_widget->setCurrentWidget(nautilus_widget); + } +} diff --git a/mainui/settingwidget.h b/mainui/settingwidget.h new file mode 100644 index 0000000..facea8d --- /dev/null +++ b/mainui/settingwidget.h @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SETTINGWIDGET_H +#define SETTINGWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../setting/themewidget.h" +#include "../setting/iconwidget.h" +#include "../setting/mousewidget.h" +#include "../setting/voicewidget.h" +//#include "../setting/animationwidget.h" +#include "../setting/launcherwidget.h" +#include "../setting/panelwidget.h" +#include "../setting/windowwidget.h" +#include "../setting/fontwidget.h" +#include "../setting/touchpadwidget.h" +//#include "../setting/deadpixelwidget.h" +#include "../setting/conservewidget.h" +#include "../setting/nautiluswidget.h" +#include "../component/quibo.h" + +class SessionDispatcher; +class SystemDispatcher; +class MainWindow; + +class SettingWidget : public QWidget +{ + Q_OBJECT +public: + explicit SettingWidget(QString cur_desktop = "", bool has_battery = false, QWidget *parent = 0); + ~SettingWidget(); + void initIndividuationWidget(); + void initDesktopWidget(); + void initFontWidget(); + void initOptionWidget(); + void initOtherWidget(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void setSessionDbusProxy(SessionDispatcher *dispatcher) { sessionProxy = dispatcher;} + void setSystemDbusProxy(SystemDispatcher *dispatcher) { systemProxy = dispatcher;} + void initUI(QString skin); + void resetSkin(QString skin); + + +signals: + void changeActionPage(int index); + +public slots: + void displaySettingHomePage(); + void displaySettingSubPage(); +// void slot_notify_boolean(QString key, bool value); + void startMonitorCheck(); + +private: + MainWindow *p_mainwindow; + SessionDispatcher *sessionProxy; + SystemDispatcher *systemProxy; + QString desktop; + bool battery; + QUIBO *qtui; + QStackedWidget *stacked_widget; + ThemeWidget *theme_widget; + IconWidget *icon_widget; + MouseWidget *mouse_widget; + VoiceWidget *voice_widget; +// AnimationWidget *animation_widget; + LauncherWidget *launcher_widget; + PanelWidget *panel_widget; + WindowWidget *window_widget; + FontWidget *font_widget; + TouchpadWidget *touchpad_widget; +// DeadpixelWidget *deadpixel_widget; + ConserveWidget *conserve_widget; + NautilusWidget *nautilus_widget; + QSplitter *h_splitter; + QWidget *individuation_widget; + QLabel *individuation_icon; + QLabel *individuation_title; + QLabel *dot1; + QPushButton *theme_button; + QLabel *dot2; + QPushButton *icon_button; + QLabel *dot3; + QPushButton *mouse_button; + QLabel *dot4; + QPushButton *voice_button; +// QLabel *dot5; +// QPushButton *animation_button; + + QWidget *dekstop_widget; + QLabel *dekstop_icon; + QLabel *dekstop_title; + QLabel *dot6; + QPushButton *launcher_button; + QLabel *dot7; + QPushButton *panel_button; + QLabel *dot8; + QPushButton *window_button; + + QWidget *fonts_widget; + QLabel *font_icon; + QLabel *font_title; + QLabel *dot9; + QPushButton *font_button; + + QWidget *option_widget; + QLabel *option_icon; + QLabel *option_title; + QLabel *dot10; + QPushButton *touch_button; + QLabel *dot11; + QPushButton *pixel_button; + QLabel *dot12; + QPushButton *conserve_button; + + QWidget *other_widget; + QLabel *other_icon; + QLabel *other_title; + QLabel *dot13; + QPushButton *nautilus_button; +}; + +#endif // SETTINGWIDGET_H diff --git a/mainui/shadowwidget.cpp b/mainui/shadowwidget.cpp new file mode 100644 index 0000000..7c256a6 --- /dev/null +++ b/mainui/shadowwidget.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "shadowwidget.h" +#include + +ShadowWidget::ShadowWidget(QWidget *parent) : + QWidget(parent) +{ + widget_opacity = 1; +} + +void ShadowWidget::setOpacity(qreal opacity) +{ + widget_opacity = opacity; + update(); +} + +void ShadowWidget::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.setOpacity(widget_opacity); + painter.setBrush(widget_color); + painter.setPen(Qt::NoPen); + painter.drawRect(rect()); +} diff --git a/mainui/shadowwidget.h b/mainui/shadowwidget.h new file mode 100644 index 0000000..98ed172 --- /dev/null +++ b/mainui/shadowwidget.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SHADOWWIDGET_H +#define SHADOWWIDGET_H + +#include + +class ShadowWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) +public: + explicit ShadowWidget(QWidget *parent = 0); + void setOpacity(qreal opacity); + qreal opacity() + { + return widget_opacity; + } + void setColor(QColor color) + { + widget_color = color; + } + +protected: + void paintEvent(QPaintEvent *); + +private: + qreal widget_opacity; + QColor widget_color; +}; + +#endif // SHADOWWIDGET_H diff --git a/mainui/skincenter-org.cpp b/mainui/skincenter-org.cpp new file mode 100644 index 0000000..b1c41c0 --- /dev/null +++ b/mainui/skincenter-org.cpp @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "skincenter.h" +#include "mainwindow.h" +#include +#include + +SkinCenter::SkinCenter(QWidget *parent/*, Qt::WindowFlags f*/) + :QDialog(parent) +{ + this->setFixedSize(500, 271); + this->setStyleSheet("QDialog{border: 1px solid gray;border-radius:2px}"); + setWindowFlags(Qt::FramelessWindowHint); + title_bar = new KylinTitleBar(); + list_widget = new KylinListWidget(); + connect(list_widget, SIGNAL(sendBackgroundName(QString)), this, SLOT(changeSkinCenterBackground(QString))); + list_widget->setMouseTracking(true);//hover need it + list_widget->setAutoFillBackground(false); + + using_label = new QLabel(list_widget); + using_label->setFixedSize(17, 26); + using_label->setAutoFillBackground(true); + QPalette palette; +// palette.setBrush(using_label->backgroundRole(), QBrush(QPixmap("://res/clothes.png"))); + palette.setBrush(QPalette::Background, QBrush(QPixmap("://res/clothes.png"))); + using_label->setPalette(palette); + using_label->show(); + +// QHBoxLayout *list_layout = new QHBoxLayout(); +// list_layout->addWidget(list_widget); +// list_layout->setSpacing(0); +// list_layout->setMargin(0); +// list_layout->setContentsMargins(1, 0, 1, 1); + +// QVBoxLayout *layout = new QVBoxLayout(); +// layout->addWidget(title_bar); +//// layout->addWidget(list_widget); +// layout->addLayout(list_layout); +// layout->setSpacing(0); +// layout->setMargin(0); +// layout->setContentsMargins(0, 0, 0, 0); +// setLayout(layout); + + + QGridLayout *grid_layout = new QGridLayout(); + grid_layout->addWidget(list_widget); + QVBoxLayout *layout = new QVBoxLayout(); + layout->addWidget(title_bar); + layout->addLayout(grid_layout); + layout->setSpacing(0); + layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); + setLayout(layout); + + +// delayTimer = QTimer(); + + this->setLanguage(); + this->initConnect(); +} + +SkinCenter::~SkinCenter() +{ +// disconnect(delayTimer,SIGNAL(timeout()),this,SLOT(changeAnimationStep())); +// if(delayTimer->isActive()) { +// delayTimer->stop(); +// } +// if (delayTimer != NULL) { +// delete delayTimer; +// delayTimer = NULL; +// } +} + +void SkinCenter::setLanguage() +{ + +} + +void SkinCenter::initConnect() +{ + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); +// connect(delayTimer, SIGNAL(timeout()), this, SLOT(changeAnimationStep())); +} + +void SkinCenter::onCloseButtonClicked() +{ + this->close(); +} + +void SkinCenter::changeSkinCenterBackground(QString pciture) +{ + int index = 1; + last_skin_path = pciture; + title_bar->resetBackground(last_skin_path); + int start_pos = pciture.lastIndexOf("/") + 1; + int end_pos = pciture.length(); + index = pciture.mid(start_pos, end_pos-start_pos).replace(".png", "").toInt(); + qDebug() << index; + QListWidgetItem *cur_item = list_widget->item(index - 1); + this->initUsingLogo(cur_item); +} + +void SkinCenter::initBackgroundList() +{ + list_widget->setIconSize(QSize(150, 100)); + list_widget->setResizeMode(QListView::Adjust); + list_widget->setViewMode(QListView::IconMode); + list_widget->setMovement(QListView::Static); + list_widget->setSpacing(9); + list_widget->setMainWindow(mainwindow); + + list_widget->setFocusPolicy(Qt::NoFocus); + + for(int index = 0; index < 4; ++index) + { + QString iconPath = QString(":/background/res/skin/%1.png").arg(index + 1); + QPixmap pixMap(iconPath); + KylinListWidgetItem *item = new KylinListWidgetItem(QIcon(pixMap.scaled(QSize(150,100))), ""); + item->setMainWindow(mainwindow); + item->setSkinName(iconPath); + item->setSizeHint(QSize(150,100)); + list_widget->insertItem(index, item); + } + +// qDebug() << mainwindow->getCurrentBackgroundIndex(); +// QListWidgetItem *cur_item = list_widget->item(mainwindow->getCurrentBackgroundIndex() - 1); +// this->initUsingLogo(cur_item); +} + +void SkinCenter::initTitleBar(const QString &path) +{ + title_bar->setTitleWidth(500); + title_bar->setTitleName(tr("Skin Center")); + last_skin_path = path; + title_bar->setTitleBackgound(last_skin_path); +} + +void SkinCenter::setLogo() +{ + qDebug() << mainwindow->getCurrentBackgroundIndex(); + QListWidgetItem *cur_item = list_widget->item(mainwindow->getCurrentBackgroundIndex() - 1); + this->initUsingLogo(cur_item); +} + + +void SkinCenter::initUsingLogo(QListWidgetItem *init_item) { +// int nRowIndex = list_widget->row(init_item); + QRect rect = list_widget->visualItemRect(init_item); + QPoint p = rect.topLeft(); + using_label->move(p.x(), p.y()); + qDebug() << p.x(); + qDebug() << p.y(); + qDebug() <<"----------------"; +// QPoint p = rect.bottomRight(); +// using_label->move(p.x()-20, p.y()-40); + //reset current item status +// QListWidgetItem *pre_item = list_widget->item(current_index); +// pre_item->setTextColor(QColor(0, 0, 255, 127)); +// current_index = nRowIndex; +// init_item->setTextColor(QColor("4f4f4f")); +} + +//void MainWindow::reViewThePointSkin(QString pciture) +//{ +// if (review_skin_pixmap.isDetached()) +// { +// review_skin_pixmap.detach(); +// } + +// review_skin_pixmap.load(pciture); +// QPalette palette_back; +// palette_back.setBrush(QPalette::Background, review_skin_pixmap); +// action_widget->setPalette(palette_back); +//} + +//void SkinCenter::enterEvent (QEvent *) +//{ +// delayTimer->start(300); +//} + +//void SkinCenter::leaveEvent (QEvent *) +//{ +// if(delayTimer->isActive()) +// delayTimer->stop(); +//} + +void SkinCenter::closeEvent(QCloseEvent *event) +{ + title_bar->setTitleBackgound(last_skin_path); + mainwindow->restoreSkin(); +} diff --git a/mainui/skincenter-org.h b/mainui/skincenter-org.h new file mode 100644 index 0000000..2632b56 --- /dev/null +++ b/mainui/skincenter-org.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SKINCENTER_H +#define SKINCENTER_H + +#include +//#include + +#include "../component/kylinlistwidget.h" +#include "../component/kylintitlebar.h" +#include "../component/kylinlistwidgetitem.h" + +class MainWindow; + +class SkinCenter :public QDialog +{ + Q_OBJECT +public: + SkinCenter(QWidget *parent = 0/*, Qt::WindowFlags f = 0*/); + ~SkinCenter(); + void setParentWindow(MainWindow *From) { mainwindow = From;} + void initBackgroundList(); + void setLanguage(); + void initConnect(); + void initTitleBar(const QString &path); + void initUsingLogo(QListWidgetItem *init_item); + void setLogo(); + +public slots: + void onCloseButtonClicked(); + void changeSkinCenterBackground(QString pciture); + +protected: +// virtual void enterEvent (QEvent *); +// virtual void leaveEvent (QEvent *); + void closeEvent(QCloseEvent *event); + +private: + MainWindow *mainwindow; + KylinTitleBar *title_bar; + KylinListWidget *list_widget; + QString last_skin_path; + QLabel *using_label; +// QTimer *delayTimer; +// QString titlebar_pic; +}; + +#endif // SKINCENTER_H diff --git a/mainui/skincenter.cpp b/mainui/skincenter.cpp new file mode 100644 index 0000000..ea68af5 --- /dev/null +++ b/mainui/skincenter.cpp @@ -0,0 +1,709 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "skincenter.h" +#include "mainwindow.h" +#include +#include +#include +#include + +//20161228 +SkinCenter::SkinCenter(QWidget *parent, QString skin, QString arch, QString os) + :QDialog(parent) +{ + this->setFixedSize(442, 340); + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); +// this->setStyleSheet("QDialog{border: 1px solid gray;border-radius:2px}"); +// this->setStyleSheet("QDialog{border: none;background-color: #ffffff;}"); + setWindowFlags(Qt::FramelessWindowHint); +// title_bar = new KylinTitleBar(this); + this->setWindowTitle(tr("Skin Setting")); + + last_skin_path = skin; + aboutGroup = NULL; + contributorGroup = NULL; +// mouse_enter = false; + + baseWidget = new QWidget(this); + baseWidget->setGeometry(QRect(0, 0, 442, 82)); + baseWidget->setAutoFillBackground(true); + + QPalette palette; + palette.setBrush(QPalette::Background, QBrush(QPixmap(skin))); + baseWidget->setPalette(palette); + + close_btn = new SystemButton(baseWidget); + close_btn->setFocusPolicy(Qt::NoFocus); + close_btn->loadPixmap(":/sys/res/sysBtn/close_button.png"); + if (arch == "aarch64" || os == "Kylin" || os == "YHKylin") {//20161228 + close_btn->move(442-36, 0); + } + else { + close_btn->move(0, 0); + } + + label = new QLabel(baseWidget); + label->setGeometry(QRect(71, 0, 300, 30)); + label->setStyleSheet("QLabel{color:#ffffff;font-family: 方正黑体_GBK;font-size: 12px;text-align: center;font-weight:bold;}"); + label->setAlignment(Qt::AlignCenter); + label->setText(tr("Skin Setting")); + + skin_widget = new QWidget(this); +// skin_widget->setGeometry(QRect(6, 92, 430, 230)); + skin_widget->setGeometry(QRect(15, 93, 420, 240)); + list_widget = NULL; + + custom_list_widget = NULL; + + + sysBtn = new QPushButton(baseWidget); + sysBtn->setText(tr("Default")); + sysBtn->setGeometry(QRect(10, 50, 60, 24)); + customBtn = new QPushButton(baseWidget); + customBtn->setText(tr("Custom")); + customBtn->setGeometry(QRect(75, 50, 60, 24)); + indicator = new QLabel(baseWidget); + indicator->setStyleSheet("QLabel{background-image:url('://res/underline.png');background-position:center;}"); + indicator->setGeometry(QRect(10, 75, 60, 2)); + sysBtn->setFocusPolicy(Qt::NoFocus); + sysBtn->setObjectName("transparentButton"); + customBtn->setFocusPolicy(Qt::NoFocus); + customBtn->setObjectName("transparentButton"); + sysBtn->setStyleSheet("QPushButton{background:transparent;text-align:center;font-family: 方正黑体_GBK;font-size:14px;color:#ffffff;}");//QPushButton:hover{color:#666666;} + customBtn->setStyleSheet("QPushButton{background:transparent;text-align:center;font-family: 方正黑体_GBK;font-size:14px;color:#ffffff;}");//QPushButton:hover{color:#666666;} + +// QVBoxLayout *layout = new QVBoxLayout(); +// layout->addWidget(title_bar); +// layout->addWidget(skin_widget); +// layout->setSpacing(10); +// layout->setMargin(0); +// layout->setContentsMargins(0, 0, 0, 0); +// setLayout(layout); + +// list_widget = new KylinListWidget(); +// connect(list_widget, SIGNAL(sendBackgroundName(QString)), this, SLOT(changeSkinCenterBackground(QString))); +// list_widget->setMouseTracking(true);//hover need it +// list_widget->setAutoFillBackground(false); + +// using_label = new QLabel(list_widget); +// using_label->setFixedSize(17, 26); +// using_label->setAutoFillBackground(true); +// QPalette palette; +//// palette.setBrush(using_label->backgroundRole(), QBrush(QPixmap("://res/clothes.png"))); +// palette.setBrush(QPalette::Background, QBrush(QPixmap("://res/clothes.png"))); +// using_label->setPalette(palette); +// using_label->show(); + +//// QHBoxLayout *list_layout = new QHBoxLayout(); +//// list_layout->addWidget(list_widget); +//// list_layout->setSpacing(0); +//// list_layout->setMargin(0); +//// list_layout->setContentsMargins(1, 0, 1, 1); + +//// QVBoxLayout *layout = new QVBoxLayout(); +//// layout->addWidget(title_bar); +////// layout->addWidget(list_widget); +//// layout->addLayout(list_layout); +//// layout->setSpacing(0); +//// layout->setMargin(0); +//// layout->setContentsMargins(0, 0, 0, 0); +//// setLayout(layout); + + +// QGridLayout *grid_layout = new QGridLayout(); +// grid_layout->addWidget(list_widget); +// QVBoxLayout *layout = new QVBoxLayout(); +// layout->addWidget(title_bar); +// layout->addLayout(grid_layout); +// layout->setSpacing(0); +// layout->setMargin(0); +// layout->setContentsMargins(0, 0, 0, 0); +// setLayout(layout); + + +//// delayTimer = QTimer(); + +// this->setLanguage(); + this->initAnimation(); + this->initConnect(); +} + +SkinCenter::~SkinCenter() +{ + if(aboutGroup != NULL) + { + delete aboutGroup; + aboutGroup = NULL; + } + if(contributorGroup != NULL) + { + delete contributorGroup; + contributorGroup = NULL; + } + for(int i=0; iisActive()) { +// delayTimer->stop(); +// } +// if (delayTimer != NULL) { +// delete delayTimer; +// delayTimer = NULL; +// } +} + +//void SkinCenter::setLanguage() +//{ + +//} + +void SkinCenter::initAnimation() +{ + QRect mainAcitonRect(10, 75, 60, 2); + QRect origAcitonRect(75, 75, 60, 2); + + QPropertyAnimation *aboutAnimation = new QPropertyAnimation(indicator, "geometry"); + aboutAnimation->setDuration(300); + aboutAnimation->setStartValue(origAcitonRect); + aboutAnimation->setEndValue(mainAcitonRect); + + aboutGroup = new QParallelAnimationGroup(this); + aboutGroup->addAnimation(aboutAnimation); + + QPropertyAnimation *contributorAnimation = new QPropertyAnimation(indicator, "geometry"); + contributorAnimation->setDuration(300); + contributorAnimation->setStartValue(mainAcitonRect); + contributorAnimation->setEndValue(origAcitonRect); + + contributorGroup = new QParallelAnimationGroup(this); + contributorGroup->addAnimation(contributorAnimation); +} + +void SkinCenter::initConnect() +{ +// connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); + connect(close_btn, SIGNAL(clicked()), this, SLOT(onCloseButtonClicked())); + connect(sysBtn,SIGNAL(clicked()), this, SLOT(showSystem())); + connect(customBtn,SIGNAL(clicked()), this, SLOT(showCustom())); +// connect(delayTimer, SIGNAL(timeout()), this, SLOT(changeAnimationStep())); +} + +void SkinCenter::showSystem() +{ + aboutGroup->start(); + if(list_widget != NULL) + list_widget->show(); + if(custom_list_widget != NULL) + custom_list_widget->hide(); +} + +void SkinCenter::showCustom() +{ + contributorGroup->start(); + if(custom_list_widget != NULL) + custom_list_widget->show(); + if(list_widget != NULL) + list_widget->hide(); +} + +void SkinCenter::onCloseButtonClicked() +{ + this->close(); +} + +void SkinCenter::changeSkinCenterBackground(QString pciture) +{ +// int index = 1; + last_skin_path = pciture; + QPalette palette; + palette.setBrush(QPalette::Background, QBrush(QPixmap(last_skin_path))); + baseWidget->setPalette(palette); + +// title_bar->resetBackground(last_skin_path); +// int start_pos = pciture.lastIndexOf("/") + 1; +// int end_pos = pciture.length(); +// index = pciture.mid(start_pos, end_pos-start_pos).replace(".png", "").toInt(); +// qDebug() << index; +// QListWidgetItem *cur_item = list_widget->item(index - 1); +// this->initUsingLogo(cur_item); + + + mainwindow->changeSkin(pciture); +} + +void SkinCenter::changeEnterBackground(QString pciture) +{ + mainwindow->reViewThePointSkin(pciture); +// title_bar->resetBackground(pciture); + QPalette palette; + palette.setBrush(QPalette::Background, QBrush(QPixmap(pciture))); + baseWidget->setPalette(palette); +} + +void SkinCenter::changeLeaveBackground() +{ + mainwindow->reViewTheOrgSkin(); +// title_bar->resetBackground(last_skin_path); + QPalette palette; + palette.setBrush(QPalette::Background, QBrush(QPixmap(last_skin_path))); + baseWidget->setPalette(palette); +} + +void SkinCenter::deleteBackground(QString picture) +{ + bool result = mainwindow->deleteFile(picture); + if (result) + { +// list_widget->clear_card(); + custom_list_widget->clear_card(); + this->reloadBackgroundList(); + QString conf_skin = mainwindow->getCurrentBackgroundAbsName(); + if (conf_skin == picture) + this->changeSkinCenterBackground(":/background/res/skin/1.png"); + } +} + +void SkinCenter::initSysBackgroundList() +{ +// self.winListWidget = CardWidget(427, 88, 6, self.ui.winpageWidget) +// self.winListWidget.setGeometry(0, 50, 860 + 6 + (20 - 6) / 2, 516) +// self.winListWidget.calculate_data() +// list_widget = new CardWidget(200, 88, 6, this->skin_widget); + list_widget = new CardWidget(130, 87, 10, this->skin_widget); + list_widget->setGeometry(QRect(0, 0, 420, 240)); + list_widget->calculate_data(); + QDir picdir("/var/lib/youker-assistant-daemon/default"); + picdir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + picdir.setSorting(QDir::Size | QDir::Reversed); + QStringList filters; + filters << "*.jpg" << "*.png"; + picdir.setNameFilters(filters); + QFileInfoList list = picdir.entryInfoList(); + QString cur_skin = mainwindow->getCurrentBackgroundName(); + card_list.clear(); +// qDebug() << "getCurrentBackgroundName->" << mainwindow->getCurrentBackgroundName(); + QSignalMapper *signal_mapper = new QSignalMapper(this); + for (int j = 0; j < list.size(); ++j) { + QFileInfo fileInfo = list.at(j); +// qDebug() << fileInfo.fileName(); + ItemCard *card = new ItemCard(fileInfo.fileName(), false, list_widget->cardPanel); +// card->resetdislayDelBtnValue(true);//test + card_list.append(card); + if(cur_skin == fileInfo.fileName()) + card->showUsingLogo(true); + list_widget->add_card(card); + connect(card, SIGNAL(sendBackgroundName(QString)), signal_mapper, SLOT(map())); + signal_mapper->setMapping(card, QString::number(j, 10)); + connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchUsingLogo(QString))); + connect(card, SIGNAL(sendBackgroundName(QString)), this, SLOT(changeSkinCenterBackground(QString))); + connect(card, SIGNAL(sendEnterBackground(QString)), this, SLOT(changeEnterBackground(QString))); + connect(card, SIGNAL(sendLeaveBackground()), this, SLOT(changeLeaveBackground())); +// connect(card, SIGNAL(sendDelteSignal(QString)), this, SLOT(deleteBackground(QString))); + } + + + + +// custom_list_widget = new CardWidget(212, 100, 20, this->skin_widget); + custom_list_widget = new CardWidget(130, 87, 10, this->skin_widget); + custom_list_widget->hide(); +// custom_list_widget->setGeometry(QRect(30, 0, 500, 239)); + custom_list_widget->setGeometry(QRect(0, 0, 420, 240)); + custom_list_widget->calculate_data(); + QDir customdir("/var/lib/youker-assistant-daemon/custom"); + customdir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + customdir.setSorting(QDir::Size | QDir::Reversed); + customdir.setNameFilters(filters); + QFileInfoList custom_list = customdir.entryInfoList(); + QString cur_custom_skin = mainwindow->getCurrentBackgroundName(); + custom_card_list.clear(); +// qDebug() << "getCurrentBackgroundName->" << mainwindow->getCurrentBackgroundName(); + QSignalMapper *custom_mapper = new QSignalMapper(this); + for (int j = 0; j < custom_list.size(); ++j) { + QFileInfo fileInfo = custom_list.at(j); + ItemCard *card = new ItemCard(fileInfo.fileName(), true, custom_list_widget->cardPanel); + card->resetdislayDelBtnValue(true); + custom_card_list.append(card); + if(cur_custom_skin == fileInfo.fileName()) + card->showUsingLogo(true); + custom_list_widget->add_card(card); + connect(card, SIGNAL(sendBackgroundName(QString)), custom_mapper, SLOT(map())); + custom_mapper->setMapping(card, QString::number(j, 10)); + connect(custom_mapper, SIGNAL(mapped(QString)), this, SLOT(switchCusteomUsingLogo(QString))); + connect(card, SIGNAL(sendBackgroundName(QString)), this, SLOT(changeSkinCenterBackground(QString))); + connect(card, SIGNAL(sendEnterBackground(QString)), this, SLOT(changeEnterBackground(QString))); + connect(card, SIGNAL(sendLeaveBackground()), this, SLOT(changeLeaveBackground())); + connect(card, SIGNAL(sendDelteSignal(QString)), this, SLOT(deleteBackground(QString))); + } + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + custom_card_list.append(card); + custom_list_widget->add_card(card); + connect(card, SIGNAL(sendAddSignal()), this, SLOT(addCustomBackground())); +// list_widget->setIconSize(QSize(150, 100)); +// list_widget->setResizeMode(QListView::Adjust); +// list_widget->setViewMode(QListView::IconMode); +// list_widget->setMovement(QListView::Static); +// list_widget->setSpacing(9); +// list_widget->setMainWindow(mainwindow); + +// list_widget->setFocusPolicy(Qt::NoFocus); + +// for(int index = 0; index < 4; ++index) +// { +// QString iconPath = QString(":/background/res/skin/%1.png").arg(index + 1); +// QPixmap pixMap(iconPath); +// KylinListWidgetItem *item = new KylinListWidgetItem(QIcon(pixMap.scaled(QSize(150,100))), ""); +// item->setMainWindow(mainwindow); +// item->setSkinName(iconPath); +// item->setSizeHint(QSize(150,100)); +// list_widget->insertItem(index, item); +// } + +//// qDebug() << mainwindow->getCurrentBackgroundIndex(); +//// QListWidgetItem *cur_item = list_widget->item(mainwindow->getCurrentBackgroundIndex() - 1); +//// this->initUsingLogo(cur_item); +} + +void SkinCenter::reloadBackgroundList() +{ +// list_widget->setGeometry(QRect(0,2, 500, 230)); +// list_widget->calculate_data(); + custom_list_widget->setGeometry(QRect(0,2, 500, 230)); + custom_list_widget->calculate_data(); + +// QDir picdir("/var/lib/youker-assistant-daemon/default"); + QDir picdir("/var/lib/youker-assistant-daemon/custom"); + picdir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + picdir.setSorting(QDir::Size | QDir::Reversed); + QStringList filters; + filters << "*.jpg" << "*.png"; + picdir.setNameFilters(filters); + QFileInfoList list = picdir.entryInfoList(); + QString cur_skin = mainwindow->getCurrentBackgroundName(); +// card_list.clear(); + //no need to call this code, because it have called custom_list_widget->clear_card(); +// for(int i=0; icardPanel); + ItemCard *card = new ItemCard(fileInfo.fileName(), true, custom_list_widget->cardPanel); + card->resetdislayDelBtnValue(true); + card->show(); +// card_list.append(card); + custom_card_list.append(card); + if(cur_skin == fileInfo.fileName()) + card->showUsingLogo(true); +// list_widget->add_card(card); + custom_list_widget->add_card(card); + connect(card, SIGNAL(sendBackgroundName(QString)), signal_mapper, SLOT(map())); + signal_mapper->setMapping(card, QString::number(j, 10)); +// connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchUsingLogo(QString))); + connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchCusteomUsingLogo(QString))); + connect(card, SIGNAL(sendBackgroundName(QString)), this, SLOT(changeSkinCenterBackground(QString))); + connect(card, SIGNAL(sendEnterBackground(QString)), this, SLOT(changeEnterBackground(QString))); + connect(card, SIGNAL(sendLeaveBackground()), this, SLOT(changeLeaveBackground())); + connect(card, SIGNAL(sendDelteSignal(QString)), this, SLOT(deleteBackground(QString))); + } + ItemCard *card = new ItemCard("://res/create.png", true, custom_list_widget->cardPanel); + card->show(); + custom_card_list.append(card); + custom_list_widget->add_card(card); + connect(card, SIGNAL(sendAddSignal()), this, SLOT(addCustomBackground())); +} + +void SkinCenter::addCustomBackground() +{ + //QStringList fileNameList; + //QString fileName; + //QFileDialog* fd = new QFileDialog(this); + //fd->resize(500, 471); +// // fd->setFilter("Allfile(*.*);;png(*.png);;jpg(*.jpg)"); + //fd->setNameFilter(tr("Image Files(*.jpg *.png)")); + //fd->setViewMode(QFileDialog::List); + //if (fd->exec() == QDialog::Accepted) + //{ + // fileNameList = fd->selectedFiles(); + // fileName = fileNameList[0]; +// // qDebug() << "select pic name ->" << fileName; + // bool result = mainwindow->CopyFile(fileName); + // if(result == true) { + // custom_list_widget->clear_card(); + // this->reloadBackgroundList(); + // int start_pos = fileName.lastIndexOf("/") + 1; + // int end_pos = fileName.length(); + // QString icon_name = "/var/lib/youker-assistant-daemon/custom/"; + // QString abs_name = icon_name.append(fileName.mid(start_pos, end_pos-start_pos)); +// // qDebug() << "abs_name->" << abs_name; + // this->changeSkinCenterBackground(abs_name); + + // //change custom using logo + // for(int i=0; igetCardName(); + // if(card->getCardName() == abs_name) + // { + // card->showUsingLogo(true); + // } + // else + // { + // card->showUsingLogo(false); + // } + // } + + // //change system using logo + // for(int i=0; ishowUsingLogo(false); + // } + // } + //} + //else + // fd->close(); + + QStringList fileNameList; + QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), ".", + tr("Files(*.png *.jpg)")); + if (fileName.length() == 0) + { +// QMessageBox::information(NULL, tr("Path"), tr("You didn't select any files.")); + } + else + { + bool result = mainwindow->CopyFile(fileName); + if(result == true) + { + custom_list_widget->clear_card(); + this->reloadBackgroundList(); + int start_pos = fileName.lastIndexOf("/") + 1; + int end_pos = fileName.length(); + QString icon_name = "/var/lib/youker-assistant-daemon/custom/"; + QString abs_name = icon_name.append(fileName.mid(start_pos, end_pos-start_pos)); + this->changeSkinCenterBackground(abs_name); + + for(int i=0; igetCardName(); + if(card->getCardName() == abs_name) + { + card->showUsingLogo(true); + } + else + { + card->showUsingLogo(false); + } + } + + //change system using logo + for(int i=0; ishowUsingLogo(false); + } + } +// QMessageBox::information(NULL, tr("Path"), tr("You select ") + fileName); + } +} + +void SkinCenter::switchUsingLogo(QString index) +{ + bool ok; + int current_index = index.toInt(&ok, 10); +// qDebug () << "current_index->" << current_index; + for(int i=0; ishowUsingLogo(true); + } + else + { + card->showUsingLogo(false); + } + } + //change custom using logo + for(int i=0; ishowUsingLogo(false); + } +} + +void SkinCenter::switchCusteomUsingLogo(QString index) +{ + bool ok; + int current_index = index.toInt(&ok, 10); + for(int i=0; ishowUsingLogo(true); + } + else + { + card->showUsingLogo(false); + } + } + //change ystem using logo + for(int i=0; ishowUsingLogo(false); + } +} + +//void SkinCenter::initTitleBar(const QString &path) +//{ +// title_bar->setTitleWidth(500); +// title_bar->setTitleName(tr("Skin Center")); +// last_skin_path = path; +// title_bar->setTitleBackgound(last_skin_path); +//} + +//void SkinCenter::setLogo() +//{ +// qDebug() << mainwindow->getCurrentBackgroundIndex(); +// QListWidgetItem *cur_item = list_widget->item(mainwindow->getCurrentBackgroundIndex() - 1); +// this->initUsingLogo(cur_item); +//} + + +//void SkinCenter::initUsingLogo(QListWidgetItem *init_item) { +//// int nRowIndex = list_widget->row(init_item); +// QRect rect = list_widget->visualItemRect(init_item); +// QPoint p = rect.topLeft(); +// using_label->move(p.x(), p.y()); +// qDebug() << p.x(); +// qDebug() << p.y(); +// qDebug() <<"----------------"; +//// QPoint p = rect.bottomRight(); +//// using_label->move(p.x()-20, p.y()-40); +// //reset current item status +//// QListWidgetItem *pre_item = list_widget->item(current_index); +//// pre_item->setTextColor(QColor(0, 0, 255, 127)); +//// current_index = nRowIndex; +//// init_item->setTextColor(QColor("4f4f4f")); +//} + +////void MainWindow::reViewThePointSkin(QString pciture) +////{ +//// if (review_skin_pixmap.isDetached()) +//// { +//// review_skin_pixmap.detach(); +//// } + +//// review_skin_pixmap.load(pciture); +//// QPalette palette_back; +//// palette_back.setBrush(QPalette::Background, review_skin_pixmap); +//// action_widget->setPalette(palette_back); +////} + +////void SkinCenter::enterEvent (QEvent *) +////{ +//// delayTimer->start(300); +////} + +////void SkinCenter::leaveEvent (QEvent *) +////{ +//// if(delayTimer->isActive()) +//// delayTimer->stop(); +////} + +//void SkinCenter::paintEvent(QPaintEvent *) +//{ +// if(mouse_enter) +// { +// //绘制边框 +// QPainter painter(this); +// QPen pen(QColor("red")); +// painter.setPen(pen); +// painter.drawRoundRect(0,0,this->width()-1, this->height()-1, 5, 5); +// } +//} + +//void SkinCenter::enterEvent(QEvent *) +//{ +// mouse_enter = true; +// update(); +//} + +//void SkinCenter::leaveEvent(QEvent *) +//{ +// mouse_enter = false; +// update(); +//} + +void SkinCenter::mousePressEvent(QMouseEvent *event) +{ + if(event->button() == Qt::LeftButton) + { + mouse_press = true; + drag_pos = event->globalPos() - this->frameGeometry().topLeft(); + event->accept(); + } +} + +void SkinCenter::mouseReleaseEvent(QMouseEvent *) +{ + mouse_press = false; +} + +void SkinCenter::mouseMoveEvent(QMouseEvent *event) +{ + if(mouse_press) + { + QPoint move_pos = event->globalPos(); + move(move_pos - drag_pos); + event->accept(); + } +} + +void SkinCenter::closeEvent(QCloseEvent *event) +{ +// title_bar->setTitleBackgound(last_skin_path); + QPalette palette; + palette.setBrush(QPalette::Background, QBrush(QPixmap(last_skin_path))); + baseWidget->setPalette(palette); + mainwindow->restoreSkin(); +} diff --git a/mainui/skincenter.h b/mainui/skincenter.h new file mode 100644 index 0000000..577dc96 --- /dev/null +++ b/mainui/skincenter.h @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SKINCENTER_H +#define SKINCENTER_H + +#include +//#include + +#include "../component/kylinlistwidget.h" +#include "../component/kylintitlebar.h" +#include "../component/kylinlistwidgetitem.h" + +#include "../component/cardwidget.h" +#include "../component/itemcard.h" + +class MainWindow; +class QParallelAnimationGroup; +//class SystemDispatcher; +//#include "../dbusproxy/youkersystemdbus.h" + +class SkinCenter :public QDialog +{ + Q_OBJECT +public: + SkinCenter(QWidget *parent = 0, QString skin = ":/background/res/skin/1.png", QString arch = "", QString os = "");//20161228 + ~SkinCenter(); + void setParentWindow(MainWindow *From) { mainwindow = From;} +// void setSystemDbusProxy(SystemDispatcher* dispatcher) { systemProxy = dispatcher;} + void initSysBackgroundList(); + void reloadBackgroundList(); +// void setLanguage(); + void initConnect(); + void initTitleBar(const QString &path); +// void initUsingLogo(QListWidgetItem *init_item); +// void setLogo(); + void initAnimation(); + +public slots: + void onCloseButtonClicked(); + void changeSkinCenterBackground(QString pciture); + void changeEnterBackground(QString pciture); + void changeLeaveBackground(); + void deleteBackground(QString picture); + void switchUsingLogo(QString index); + void switchCusteomUsingLogo(QString index); + void showSystem(); + void showCustom(); + void addCustomBackground(); + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); +//// virtual void enterEvent (QEvent *); +//// virtual void leaveEvent (QEvent *); + void closeEvent(QCloseEvent *event); +// void paintEvent(QPaintEvent *event); +// void enterEvent(QEvent *event); +// void leaveEvent(QEvent *event); + +private: + MainWindow *mainwindow; + QPoint drag_pos; //移动的距离 +// bool mouse_enter; + bool mouse_press; //按下鼠标左键 + QWidget *baseWidget; + SystemButton *close_btn; + QLabel *indicator; + QLabel *label; +// KylinTitleBar *title_bar; + QWidget *skin_widget; +// KylinListWidget *list_widget; + QString last_skin_path; +// QLabel *using_label; +// QTimer *delayTimer; +// QString titlebar_pic; + QPushButton *sysBtn; + QPushButton *customBtn; + + CardWidget *list_widget; +// SystemDispatcher *systemProxy; + QList card_list; + + CardWidget *custom_list_widget; + QList custom_card_list; + + QParallelAnimationGroup *aboutGroup; + QParallelAnimationGroup *contributorGroup; +}; + +#endif // SKINCENTER_H diff --git a/mainui/titlewidget.cpp b/mainui/titlewidget.cpp new file mode 100644 index 0000000..66f2090 --- /dev/null +++ b/mainui/titlewidget.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "titlewidget.h" +#include "mainwindow.h" + +TitleWidget::TitleWidget(QWidget *parent, QString arch, QString os) + : QWidget(parent) +{ + this->setFixedSize(900, 36); + min_button = new SystemButton(); + close_button = new SystemButton(); + skin_button = new SystemButton(); + main_menu_button = new SystemButton(); + min_button->loadPixmap(":/sys/res/sysBtn/min_button.png"); + close_button->loadPixmap(":/sys/res/sysBtn/close_button.png"); + skin_button->loadPixmap(":/sys/res/sysBtn/skin_button.png"); + main_menu_button->loadPixmap(":/sys/res/sysBtn/main_menu.png"); + min_button->setFocusPolicy(Qt::NoFocus); + close_button->setFocusPolicy(Qt::NoFocus); + skin_button->setFocusPolicy(Qt::NoFocus); + main_menu_button->setFocusPolicy(Qt::NoFocus); + + QHBoxLayout *title_layout = new QHBoxLayout(); + if(arch == "aarch64" || os == "Kylin" || os == "YHKylin") + { + title_layout->addWidget(main_menu_button, 0, Qt::AlignTop); + title_layout->addWidget(skin_button, 0, Qt::AlignTop); + title_layout->addWidget(min_button, 0, Qt::AlignTop); + title_layout->addWidget(close_button, 0, Qt::AlignTop); + } + else + { + title_layout->addWidget(close_button, 0, Qt::AlignTop); + title_layout->addWidget(min_button, 0, Qt::AlignTop); + title_layout->addWidget(skin_button, 0, Qt::AlignTop); + title_layout->addWidget(main_menu_button, 0, Qt::AlignTop); + } + + title_layout->addStretch(); + title_layout->setSpacing(0); + title_layout->setContentsMargins(0, 0, 5, 0); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addLayout(title_layout); + main_layout->setSpacing(0); + main_layout->setContentsMargins(0, 0, 0, 0); + + setLayout(main_layout); + + is_move = false; +} + +TitleWidget::~TitleWidget() +{ + if(min_button != NULL) + { + delete min_button; + min_button = NULL; + } + if(close_button != NULL) + { + delete close_button; + close_button = NULL; + } + if(skin_button != NULL) + { + delete skin_button; + skin_button = NULL; + } + if(main_menu_button != NULL) + { + delete main_menu_button; + main_menu_button = NULL; + } +} + +void TitleWidget::initConnect() { + connect(min_button, SIGNAL(clicked()), p_mainwindow, SLOT(showMinimized())); + connect(close_button, SIGNAL(clicked()), this, SIGNAL(closeApp())); + connect(skin_button, SIGNAL(clicked()), p_mainwindow, SLOT(openSkinCenter())); + connect(main_menu_button, SIGNAL(clicked()), p_mainwindow, SLOT(showMainMenu())); +} diff --git a/mainui/titlewidget.h b/mainui/titlewidget.h new file mode 100644 index 0000000..310fab0 --- /dev/null +++ b/mainui/titlewidget.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef TITLEWIDGET_H +#define TITLEWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include "../component/kylinbutton.h" +#include "../component/systembutton.h" + +class MainWindow; + +class TitleWidget : public QWidget +{ + Q_OBJECT +public: + explicit TitleWidget(QWidget *parent = 0, QString arch = "", QString os = ""); + ~TitleWidget(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void initConnect(); + +signals: + void closeApp(); + +private: + QPoint press_point;//鼠标按下去的点 + bool is_move; + SystemButton *min_button; + SystemButton *close_button; + SystemButton *skin_button; + SystemButton *main_menu_button; + + MainWindow *p_mainwindow; +}; + +#endif // TITLEWIDGET_H diff --git a/mainui/toolkits.cpp b/mainui/toolkits.cpp new file mode 100644 index 0000000..9c1eb4a --- /dev/null +++ b/mainui/toolkits.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "toolkits.h" + +extern QPoint widgetPosition; + +Toolkits::Toolkits(QObject *parent) : + QObject(parent) +{ + this->mainwindow_width = 850; + this->mainwindow_height = 600; + this->alert_width = 200; + this->alert_height = 75; + + alertBG = new AlertDialog(); + this->alertTimer = new QTimer(this); +// connect(alertTimer, SIGNAL(timeout()), this, SLOT(updateAlert())); +// this->alertDelayTimer = new QTimer(this); +// connect(alertDelayTimer, SIGNAL(timeout()), this, SLOT(hideAlert())); + this->alertGOE = new QGraphicsOpacityEffect(); + this->alertBG->setGraphicsEffect(alertGOE); + this->ao = 0.0; + this->alertBG->hide(); +} + +//启动alert提示 +void Toolkits::alertMSG(const QString &alertText) { + this->alert_x = widgetPosition.x() + (mainwindow_width / 2) - (this->alert_width / 2); + this->alert_y = widgetPosition.y() + (mainwindow_height /2) - (this->alert_height / 2); + + this->ay = this->alert_y; + this->ao = 0.0; + this->alertBG->move(this->alert_x, this->alert_y); + this->alertGOE->setOpacity(this->ao); + this->alertBG->setMSG(alertText); + this->alertBG->show(); +// this->alertTimer->start(15); +} +//alert提示框的步处理 +void Toolkits::updateAlert() { +// if(this->ao < 0.90){ +// this->ao += 0.02; +// this->alertGOE->setOpacity(this->ao); +// } +// if(this->ay <= (this->alert_y - 150)){ +// this->alertTimer->stop(); +// //5秒后自动关闭alert提示框 +// this->alertDelayTimer->start(1000); +// }else{ +// this->ay -= 3; +// this->alertBG->move(this->alert_x,this->ay); +// } +} +//隐藏alert提示框 +void Toolkits::hideAlert() { + this->alertBG->hide(); +// this->alertDelayTimer->stop(); +} diff --git a/mainui/toolkits.h b/mainui/toolkits.h new file mode 100644 index 0000000..2736024 --- /dev/null +++ b/mainui/toolkits.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef TOOLKITS_H +#define TOOLKITS_H + +#include +#include +#include +#include "alertdialog.h" + +class Toolkits : public QObject +{ + Q_OBJECT +public: + explicit Toolkits(QObject *parent = 0); + //启动alert提示 + Q_INVOKABLE void alertMSG(const QString &alertText); +private: + int mainwindow_width; + int mainwindow_height; + int alert_width; + int alert_height; + //本次alert的x坐标 + int alert_x; + //保额次alert的y坐标 + int alert_y; + + //alert message提示框 + AlertDialog *alertBG; + //alert提示框timer + QTimer *alertTimer; + //alert提示框隐藏timer + QTimer *alertDelayTimer; + //alert提示框GOE + QGraphicsOpacityEffect *alertGOE; + //alert提示框透明度 + float ao; + //alert提示框y坐标 + int ay; +private slots: + //alert提示步处理 + void updateAlert(); + //隐藏alert提示框 + void hideAlert(); +}; + +#endif // TOOLKITS_H diff --git a/mainui/toolwidget.cpp b/mainui/toolwidget.cpp new file mode 100644 index 0000000..ea22da4 --- /dev/null +++ b/mainui/toolwidget.cpp @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "toolwidget.h" +#include "../component/kylintoolbutton.h" +#include "mainwindow.h" +//#include +#include +//#include + +ToolWidget::ToolWidget(QWidget *parent, QString arch, QString os) + : QWidget(parent), cur_arch(arch), osname(os) +{ + this->setFixedSize(900, 47); +// this->setGeometry(0, 227, 900, 47); + this->setAutoFillBackground(true); + QPalette palette; + palette.setColor(QPalette::Background, QColor(233,238,241));//#e9eef1 + this->setPalette(palette); + + QStringList icon_list; + QStringList text_list; + if(this->cur_arch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin") + { + icon_list<<":/tool/res/menu/home"<<":/tool/res/menu/cleanup"<<":/tool/res/menu/sysinfo"<<":/tool/res/menu/toolkits"; + text_list<< tr("KylinHome") << tr("Cleanup") << tr("Sysinfo") << tr("Toolkits"); + } + else { + icon_list<<":/tool/res/menu/home"<<":/tool/res/menu/cleanup"<<":/tool/res/menu/sysinfo"<<":/tool/res/menu/feature"<<":/tool/res/menu/toolkits"; + text_list<< tr("Home") << tr("Cleanup") << tr("Sysinfo") << tr("Feature") << tr("Toolkits"); + } + + QHBoxLayout *button_layout = new QHBoxLayout(); + + QSignalMapper *signal_mapper = new QSignalMapper(this); + for(int i=0; isetFixedSize(180, 47); + button_list.append(tool_button); + connect(tool_button, SIGNAL(clicked()), signal_mapper, SLOT(map())); + signal_mapper->setMapping(tool_button, QString::number(i, 10)); + button_layout->addWidget(tool_button, 0, Qt::AlignBottom); + } + this->switchSelectedPageIndex(0); + connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchSelectedPageIndex(QString))); + + button_layout->addStretch(); + button_layout->setSpacing(8); + button_layout->setMargin(0); + button_layout->setContentsMargins(15, 0, 15, 0); + + setLayout(button_layout); + is_move = false; +// this->initAnimation(); +} + +ToolWidget::~ToolWidget() +{ + for(int i=0; isetMousePress(true); + } + else + { + tool_button->setMousePress(false); + } + } + emit turnCurrentPage(current_index); +} + +void ToolWidget::showBoxTool() +{ + if(this->cur_arch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin") + { + this->switchSelectedPageIndex("3"); + } + else + { + this->switchSelectedPageIndex("4"); + } +} + + +//void ToolWidget::initAnimation() +//{ +// QPoint home_origPoint(0, 227); +// QPoint home_needPoint(0, 274); +// QPoint clean_origPoint(180, 197); +// QPoint clean_needPoint(180, 150); +// QPoint info_origPoint(360, 197); +// QPoint info_needPoint(360, 150); +// QPoint setting_origPoint(480, 197); +// QPoint setting_needPoint(480, 150); +// QPoint box_origPoint(720, 197); +// QPoint box_needPoint(720, 150); + +// QPropertyAnimation *homeToolAnimation = new QPropertyAnimation(button_list.at(0), "pos"); +// homeToolAnimation->setDuration(200); +// homeToolAnimation->setStartValue(home_origPoint); +// homeToolAnimation->setEndValue(home_needPoint); + +// QPropertyAnimation *cleanToolAnimation = new QPropertyAnimation(button_list.at(1), "pos"); +// cleanToolAnimation->setDuration(200); +// cleanToolAnimation->setStartValue(clean_origPoint); +// cleanToolAnimation->setEndValue(clean_needPoint); + +// QPropertyAnimation *infoToolAnimation = new QPropertyAnimation(button_list.at(2), "pos"); +// infoToolAnimation->setDuration(200); +// infoToolAnimation->setStartValue(info_origPoint); +// infoToolAnimation->setEndValue(info_needPoint); + +// QPropertyAnimation *settingToolAnimation = new QPropertyAnimation(button_list.at(3), "pos"); +// settingToolAnimation->setDuration(200); +// settingToolAnimation->setStartValue(setting_needPoint); +// settingToolAnimation->setEndValue(setting_origPoint); + +// QPropertyAnimation *boxToolAnimation = new QPropertyAnimation(button_list.at(4), "pos"); +// boxToolAnimation->setDuration(200); +// boxToolAnimation->setStartValue(box_origPoint); +// boxToolAnimation->setEndValue(box_needPoint); + +// openGroup = new QParallelAnimationGroup(this); +// openGroup->addAnimation(setting_origPoint); +// openGroup->addAnimation(boxToolAnimation); + +// QPropertyAnimation *settingbackToolAnimation = new QPropertyAnimation(button_list.at(3), "pos"); +// settingbackToolAnimation->setDuration(200); +// settingbackToolAnimation->setStartValue(setting_origPoint); +// settingbackToolAnimation->setEndValue(setting_needPoint); + +// QPropertyAnimation *boxbackToolAnimation = new QPropertyAnimation(button_list.at(4), "pos"); +// boxbackToolAnimation->setDuration(200); +// boxbackToolAnimation->setStartValue(box_needPoint); +// boxbackToolAnimation->setEndValue(box_origPoint); + +// closeGroup = new QParallelAnimationGroup(this); +// closeGroup->addAnimation(settingbackToolAnimation); +// closeGroup->addAnimation(boxbackToolAnimation); +//} diff --git a/mainui/toolwidget.h b/mainui/toolwidget.h new file mode 100644 index 0000000..d11e995 --- /dev/null +++ b/mainui/toolwidget.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef TOOLWIDGET_H +#define TOOLWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include "../component/kylinbutton.h" +#include "../component/kylintoolbutton.h" + +class MainWindow; +//class QParallelAnimationGroup; + +class ToolWidget : public QWidget +{ + Q_OBJECT +public: + explicit ToolWidget(QWidget *parent = 0, QString arch = "", QString os = ""); + ~ToolWidget(); + void setParentWindow(MainWindow* window) { p_mainwindow = window;} + void initConnect(); +// void initAnimation(); + +signals: + void turnCurrentPage(int index); + +public slots: + void switchSelectedPageIndex(QString index); + void showBoxTool(); + +private: + QPoint press_point;//鼠标按下去的点 + bool is_move; + QList button_list; + MainWindow *p_mainwindow; + QString cur_arch; + QString osname; +// QParallelAnimationGroup *openGroup; +// QParallelAnimationGroup *closeGroup; +}; + +#endif // TOOLWIDGET_H diff --git a/mainui/translation/youker-assistant_de.qm b/mainui/translation/youker-assistant_de.qm new file mode 100644 index 0000000..9dad8df Binary files /dev/null and b/mainui/translation/youker-assistant_de.qm differ diff --git a/mainui/translation/youker-assistant_de.ts b/mainui/translation/youker-assistant_de.ts new file mode 100644 index 0000000..3687c7c --- /dev/null +++ b/mainui/translation/youker-assistant_de.ts @@ -0,0 +1,2863 @@ + + + + + AboutDialog + + + Youker Assisant + + + + + About + + + + + for more information. Welcome everyone to join with us. youker-assistant Homepage: + + + + + + The software is still under development. Please visit + + + + + Kylin Assisant + + + + + Maintainer: +Kylin Team <ubuntukylin-members@list.launchpad.net> + + + + + Kylin Assistant is a powerful system supporting software which is developed by Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, task manager, and some other functions. + + + + + for more information. Welcome everyone to join with us. kylin-assistant Homepage: + + + + + Maintainer: +Ubuntu Kylin Team <ubuntukylin-members@list.launchpad.net> + + + + + Contributor + + + + + Youker Assistant is a powerful system supporting software which is developed by Ubuntu Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, system customization, task manager, and some other functions. + + + + + Close + + + + + AlertDialog + + + Form + + + + + AudioWidget + + + Audio Info + + + + + Audio Info %1 + + + + + AutoStartWidget + + + AutoStart Items: + + + + + App + + + + + Status + + + + + ON Items: + + + + + OFF Items: + + + + + Boot Manager + + + + + Dialog + + + + + BatteryWidget + + + Battery Info + + + + + BoardWidget + + + Board Info + + + + + BoxActionWidget + + + Provide a practical and lightweight tool, create fast and convenient experience for you + + + + + More App + + + + + BoxWidget + + + + Kylin Software Center + + + + + + UbuntuKylin Software Center + + + + + Boot Manager + + + + + Camera + + + + + CDRowWidget + + + CDROM Info + + + + + CDROM Info %1 + + + + + CacheActionWidget + + + Cleaning up the system cache + + + + + Deep cleaning up the system cache, to save disk space + + + + + CameraManager + + + View Photos + + + + + The camera is out of question, <a style='color: #3f96e4;' href = http://www.ubuntukylin.com> Refresh</a> to call it out ~ + + + + + Camera + + + + + CleanListWidget + + + Clean Items: + + + + + Dialog + + + + + CleanSubGroup + + + Custom + + + + + CleanerActionWidget + + + Regular cleaning, let your computer remains the relaxed state + + + + + Start Scan + + + + + Start Cleanup + + + + + Back + + + + + + + + Scaning...... + + + + + Clean OK + + + + + Cleaning: + + + + + , Percent is: + + + + + %, Status is: + + + + + Clean Firefox history...... + + + + + Clean Chromium history...... + + + + + Clean system history...... + + + + + Clean apt...... + + + + + Start clean apt...... + + + + + Clean Firefox Cookie: + + + + + Clean Chromium Cookie: + + + + + + does not exist + + + + + Chromium Browser is running...... + + + + + Cache Scan OK + + + + + Cookies Scan OK + + + + + History Scan OK + + + + + Firefox Browser does not be installed + + + + + Chromium Browser does not be installed + + + + + Chromium Browser is running + + + + + Error: + + + + + Packages Scan OK + + + + + Ready to Cleanup...... + + + + + CleanerDetailWidget + + + Form + + + + + Apt Cache Clean Items + + + + + Apt Cache count: + + + + + + Software Cache Clean Items + + + + + Software Cache count: + + + + + + Thumbnails Cache Clean Items + + + + + Thumbnails Cache Count: + + + + + Firefox Cache Count: + + + + + Chromium Cache Count: + + + + + Firefox Cookies Clean Items + + + + + Firefox Cookies Count: + + + + + Chromium Cookies Clean Items + + + + + Chromium Cookies Count: + + + + + Firefox History Count: + + + + + Chromium History Count: + + + + + System History Count: + + + + + Command history size: + + + + + Debug log Items + + + + + Debug log: + + + + + No garbage + + + + + Clean args is empty! + + + + + CleanerItems + + + OK + + + + + CleanerMainWidget + + + Cleanup Package Cache + + + + + Cleanup Software Center Cache + + + + + Cleanup Thumbnails Cache + + + + + Cleanup FireFox Cache + + + + + Cleanup Chromium Cache + + + + + Cache Items + + + + + System Cache + + + + + Cleanup cache of system, software-center, thumbnails and browser + + + + + Cleanup the Cookies saving in Firefox + + + + + Cleanup the Cookies saving in Chromium + + + + + Cookies Items + + + + + Cookies + + + + + Clean up user login information, support Firefox and Chromium browser + + + + + Clean up the Firefox Internet records + + + + + Clean up the Chromium Internet records + + + + + Clean up the recently opened documents records + + + + + Delete the command history + + + + + Delete the debug logs + + + + + Trace Items + + + + + History trace + + + + + Cleaning the internet and opened documents recently records + + + + + Please select the items you want to clean + + + + + Scan args is empty! + + + + + ComputerPage + + + + + + + + + + + + + + + + + + + + + + + + %1 + + + + + + Minutes + + + + + Hours + + + + + %1 cores + + + + + %1 64bit + + + + + Ondemand + + + + + Powersave + + + + + Performance + + + + + CPU FM mode + + + + + + Audio Model + + + + + + + + + + + Vendor + + + + + + + + Bus Address + + + + + Audio Driver + + + + + + + + Device Name + + + + + Manufacturer + + + + + + Model + + + + + Technology + + + + + Voltage + + + + + Energy Designed + + + + + Energy Full + + + + + Energy Now + + + + + + + + + + + + Serial Number + + + + + Motherboard Model + + + + + Motherboard Vendor + + + + + BIOS Vendor + + + + + BIOS Version + + + + + Release Date + + + + + CD-ROM Model + + + + + + Firmware Version + + + + + + CPU + + + + + Socket/Slot + + + + + Maximum Frequency + + + + + Current Frequency + + + + + FSB + + + + + Core Number + + + + + Thread + + + + + L1 Cache + + + + + L2 Cache + + + + + phytium + + + + + 4 cores + + + + + 4 thread/core + + + + + Desktop Environment + + + + + Host Name + + + + + Memery Capacity + + + + + Terminal + + + + + Distribution + + + + + Language + + + + + User + + + + + Home Folder + + + + + Host bridge + + + + + VGA Model + + + + + USB Model + + + + + Communication Model + + + + + Ethernet Model + + + + + PCI bridge + + + + + ISA bridge + + + + + SATA Model + + + + + SMBus + + + + + System peripheral + + + + + Driver in use + + + + + existing drivers + + + + + IDE interface + + + + + SP controller + + + + + Network controller + + + + + Multimedia audio controller + + + + + HDD Model + + + + + HDD Vendor + + + + + HDD Capacity + + + + + Slot Number + + + + + Memory Model + + + + + Memory Size + + + + + Data Width + + + + + Memory Info + + + + + Graphics Card Model + + + + + Current Graphics Card + + + + + Graphics Card Vendor + + + + + Graphics Driver + + + + + Gamma + + + + + Screen Size(inch) + + + + + Max Resolution + + + + + Current Interface + + + + + Monitor Model + + + + + Visual Area + + + + + Support Interface + + + + + Monitor Manufacturers + + + + + Date of production/Week + + + + + Date of production/Year + + + + + NIC Model + + + + + NIC Driver + + + + + + IP Address + + + + + Mac Address + + + + + Connection Status + + + + + Max Bandwidth + + + + + WLan NIC Driver + + + + + WLan NIC Model + + + + + Device Name: + + + + + VNIC + + + + + NetType + + + + + Ethernet interface + + + + + Wireless interface + + + + + Version + + + + + Hostname + + + + + Running Time + + + + + OS Types + + + + + OS Version + + + + + Kernel Bit + + + + + Kernel Version + + + + + Kernel Arch + + + + + 32bit + + + + + 64bit + + + + + YHKylin community + + + + + Memory reference voltage + + + + + SATA controller voltage + + + + + Memory voltage + + + + + CPU pin voltage + + + + + Bridge voltage + + + + + CPU core voltage + + + + + CPU temperature + + + + + Motherboard temperature + + + + + CPU fan speed + + + + + ConserveWidget + + + Adjust gamma + + + + + Adjust brightness + + + + + Time before session is considered idle + + + + + Lock screen + + + + + Lock delay + + + + + Battery critical low action + + + + + Laptop lid close action on battery + + + + + Laptop lid close action on AC + + + + + Sleep timeout PC when on battery + + + + + Sleep timeout PC when on AC + + + + + Sleep timeout display when on battery + + + + + Sleep timeout display when on AC + + + + + + + suspend + + + + + shutdown + + + + + + nothing + + + + + + 1 minute + + + + + + 2 minutes + + + + + + 3 minutes + + + + + + + + + + 5 minutes + + + + + + + + + + 10 minutes + + + + + + + + + + Half an hour + + + + + + + + + + 1 hour + + + + + + + + + never + + + + + 30 seconds + + + + + Turn off the screen + + + + + + + + 20 minutes + + + + + + + + 2 hours + + + + + CpuWidget + + + CPU Info + + + + + DesktopWidget + + + Desktop Info + + + + + DriverWidget + + + Driver Info + + + + + FontWidget + + + + + + + Click here to change font + + + + + Default Font + + + + + Desktop Font + + + + + Monospace Font + + + + + Document Font + + + + + Titlebar Font + + + + + Global Font Scaling + + + + + Hinting + + + + + Antialiasing + + + + + + + + + Restore + + + + + HDWidget + + + HardWare Info + + + + + HardWare Info %1 + + + + + HomeActionWidget + + + + The lastest cleanup time is + + + + + + The lastest scan time is + + + + + You have not implemented the one key scan and clean-up operation. + + + + + Quick clean up system trash, saving disk space and improving the system efficiency! + + + + + Start Scan + + + + + Start Cleanup + + + + + Back + + + + + + Scanning...... + + + + + Scanning: + + + + + Scan Over + + + + + + + history trace; + + + + + + browser cookies. + + + + + + browser cookies; + + + + + + + + garbage. + + + + + history trace. + + + + + No garbage. + + + + + Cleaning...... + + + + + Garbage Cleanup OK...... + + + + + History Cleanup OK...... + + + + + Cookies Cleanup OK...... + + + + + Cleanup Cookies: + + + + + ; Garbage: + + + + + ; Historical records: + + + + + Cleaning up history trace of Firefox... + + + + + Firefox history trace had been cleared! + + + + + Cleaning up history trace of Chromium... + + + + + Chromium history trace had been cleared! + + + + + Cleaning up Cookies of Firefox... + + + + + Firefox Cookies had been cleared! + + + + + Cleaning up Cookies of Chromium... + + + + + Chromium Cookies had been cleared! + + + + + Apt cache had been cleared! + + + + + Cleaning up Apt cache: + + + + + Software Center cache had been cleared! + + + + + Cleaning up Software Center cache: + + + + + Ready to Cleanup...... + + + + + HomePage + + + Boot Manager + + + + + Camera + + + + + Current Version Number + + + + + Update to the lastest version, make it work better + + + + + updating on the backend + + + + + Common toolbox + + + + + Fast and practical, making the system more personalized + + + + + Upgrade is complete + + + + + Updating on the backend + + + + + More + + + + + IconWidget + + + Icon theme + + + + + Computer + + + + + Home Folder + + + + + Network + + + + + Trash + + + + + Mounted Volumes + + + + + InfoActionWidget + + + Understand hardware information, provide more convenient channel to obtain hardware information + + + + + InfoWidget + + + Computer + + + + + Desktop + + + + + CPU + + + + + Memory + + + + + Motherboard + + + + + HD + + + + + NIC + + + + + VGA + + + + + Audio + + + + + CD-ROM + + + + + Battery + + + + + Device Driver + + + + + Sensor + + + + + ItemCard + + + Form + + + + + KylinFontDialog + + + Current Font + + + + + Font + + + + + Style + + + + + Size + + + + + View + + + + + OK + + + + + Cancel + + + + + Tips + + + + + You haven't change the font, please choose the font! + + + + + Font Dialog + + + + + KylinMenu + + + Check and update + + + + + Forum Help + + + + + Feedback + + + + + About us + + + + + KylinSwitcher + + + ON + + + + + OFF + + + + + LauncherWidget + + + Launcher icon size + + + + + Launcher hide mode + + + + + Display desktop icon + + + + + Launcher Transparency + + + + + Icon Background + + + + + Top panel icon size + + + + + Top panel auto hide + + + + + Bottom panel icon size + + + + + Bottom panel auto hide + + + + + Launcher position + + + + + LoginWidget + + + Login Youker Account + + + + + Logout + + + + + MainWindow + + + Kylin Assistant + + + + + Youker Assistant + + + + + MemoryWidget + + + Memory Info + + + + + Memory Info %1 + + + + + MonitorWidget + + + Monitor Info + + + + + Monitor Info %1 + + + + + MouseWidget + + + Mouse Pointer Theme + + + + + Cursor Pointer Size + + + + + Small Size + + + + + Big Size + + + + + NautilusWidget + + + Display entry location + + + + + Automatically mount media + + + + + Automatically open a folder + + + + + Prompt autorun programs + + + + + Thumbnail icon size (pixels) + + + + + Thumbnail cache time (days) + + + + + Maximum thumbnail cache size (MB) + + + + + NicWidget + + + NIC Info + + + + + NIC Info %1 + + + + + NormalCard + + + Form + + + + + PanelWidget + + + Dash background blur type + + + + + Panel Transparency + + + + + Date & time format + + + + + Display seconds + + + + + Display week + + + + + Display the date + + + + + Display battery icon + + + + + Display battery percentage + + + + + Display battery remaining time + + + + + Smart blur + + + + + Static blur + + + + + Clear + + + + + Show applications + + + + + Show system + + + + + Show places + + + + + Show icon + + + + + QUIBO + + + Form + + + + + SensorWieget + + + Hardware sensor information + + + + + SettingAction + + + Back + + + + + Choose the theme what you want + + + + + Set the desktop icon theme and the visibility of desktop icons + + + + + Set the sound theme you want + + + + + Replace the theme and size of the mouse pointer, and theme change need to restart system + + + + + Setting the panel mode of auto hide and icon size + + + + + Setting the Launcher display mode, Icon size + + + + + Manage display of the start menu + + + + + Manage Dash and Panel menu settings + + + + + Window Manager settings + + + + + According to personal preferences to set the system default font, click the 'Restore' button, can be restored to the state before the font settings + + + + + Setting the relevant properties of your touchpad,make the operation more convenient + + + + + Monitor Check + + + + + Save energy to let the computer longer standby time + + + + + Manage the Caja file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked + + + + + Manage the Nautilus file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked + + + + + SettingActionWidget + + + You can perform a full range of customized systems based on personal preferences + + + + + SettingWidget + + + Personalize + + + + + ThemeSetting + + + + + IconSetting + + + + + MousePointer + + + + + SoundEffect + + + + + Desktop + + + + + Panel + + + + + StartMenu + + + + + Custom Launcher + + + + + Dash & Panel + + + + + Window + + + + + Font + + + + + FontSetting + + + + + Sys options + + + + + Touchpad + + + + + Dead pixel check + + + + + Energy saving + + + + + Others + + + + + File manager + + + + + ShredDialog + + + + Shred Manager + + + + + + + No select any file which need to be shredded + + + + + Shred File + + + + + Deselect + + + + + Allfile(*) + + + + + Select file! + + + + + Shred successfully! + + + + + Shred failed! + + + + + ShredManager + + + Shred Manager + + + + + Delete files makes it unable to recover + + + + + SkinCenter + + + Skin Setting + + + + + Default + + + + + Custom + + + + + Image Files(*.jpg *.png) + + + + + SystemWidget + + + Computer Base Info + + + + + + Minutes + + + + + Hours + + + + + ThemeWidget + + + Please choose theme which you need + + + + + TipDialog + + + OK + + + + + Tip Dialog + + + + + ToolWidget + + + Home + + + + + + Cleanup + + + + + + Sysinfo + + + + + KylinHome + + + + + Feature + + + + + + Toolkits + + + + + TouchpadWidget + + + Enable touchpad + + + + + Enable horizontal scrolling + + + + + Scrollbar type + + + + + Touchpad scrolling mode + + + + + Features Type + + + + + Standard Type + + + + + Disabled + + + + + Edge Scrolling + + + + + Two-finger Scrolling + + + + + UpgradeDialog + + + check and update + + + + + + Current verison: + + + + + Official version + + + + + An error occurred! + + + + + Network or local sources anomaly + + + + + you can visit the<a style='color: #3f96e4;' href = http://www.ubuntukylin.com> UK official website</a> to download the lastest deb package + + + + + Retry + + + + + Finish + + + + + Upgrade + + + + + + Start to update the local sources + + + + + Start to download + + + + + Updating local sources... + + + + + Youker Assistant is the latest version + + + + + Start to install + + + + + Download completely + + + + + Local sources updated + + + + + Found a new version + + + + + New version: + + + + + + Not found + + + + + + Testing network and local sources... + + + + + Upgrading the main program... + + + + + Start to upgrade the main program + + + + + VoiceWidget + + + Sound theme + + + + + Login tone + + + + + Event sounds + + + + + Input feedback sounds + + + + + WindowWidget + + + Arrangement of buttons on the titlebar + + + + + Menu with icons + + + + + Titlebar mouse wheel action + + + + + Titlebar double-click action + + + + + Titlebar middle-click action + + + + + Titlebar right-click action + + + + + Left + + + + + Right + + + + diff --git a/mainui/translation/youker-assistant_es.qm b/mainui/translation/youker-assistant_es.qm new file mode 100644 index 0000000..9dad8df Binary files /dev/null and b/mainui/translation/youker-assistant_es.qm differ diff --git a/mainui/translation/youker-assistant_es.ts b/mainui/translation/youker-assistant_es.ts new file mode 100644 index 0000000..413204d --- /dev/null +++ b/mainui/translation/youker-assistant_es.ts @@ -0,0 +1,2863 @@ + + + + + AboutDialog + + + Youker Assisant + + + + + About + + + + + for more information. Welcome everyone to join with us. youker-assistant Homepage: + + + + + + The software is still under development. Please visit + + + + + Kylin Assisant + + + + + Maintainer: +Kylin Team <ubuntukylin-members@list.launchpad.net> + + + + + Kylin Assistant is a powerful system supporting software which is developed by Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, task manager, and some other functions. + + + + + for more information. Welcome everyone to join with us. kylin-assistant Homepage: + + + + + Maintainer: +Ubuntu Kylin Team <ubuntukylin-members@list.launchpad.net> + + + + + Contributor + + + + + Youker Assistant is a powerful system supporting software which is developed by Ubuntu Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, system customization, task manager, and some other functions. + + + + + Close + + + + + AlertDialog + + + Form + + + + + AudioWidget + + + Audio Info + + + + + Audio Info %1 + + + + + AutoStartWidget + + + AutoStart Items: + + + + + App + + + + + Status + + + + + ON Items: + + + + + OFF Items: + + + + + Boot Manager + + + + + Dialog + + + + + BatteryWidget + + + Battery Info + + + + + BoardWidget + + + Board Info + + + + + BoxActionWidget + + + Provide a practical and lightweight tool, create fast and convenient experience for you + + + + + More App + + + + + BoxWidget + + + + Kylin Software Center + + + + + + UbuntuKylin Software Center + + + + + Boot Manager + + + + + Camera + + + + + CDRowWidget + + + CDROM Info + + + + + CDROM Info %1 + + + + + CacheActionWidget + + + Cleaning up the system cache + + + + + Deep cleaning up the system cache, to save disk space + + + + + CameraManager + + + View Photos + + + + + The camera is out of question, <a style='color: #3f96e4;' href = http://www.ubuntukylin.com> Refresh</a> to call it out ~ + + + + + Camera + + + + + CleanListWidget + + + Clean Items: + + + + + Dialog + + + + + CleanSubGroup + + + Custom + + + + + CleanerActionWidget + + + Regular cleaning, let your computer remains the relaxed state + + + + + Start Scan + + + + + Start Cleanup + + + + + Back + + + + + + + + Scaning...... + + + + + Clean OK + + + + + Cleaning: + + + + + , Percent is: + + + + + %, Status is: + + + + + Clean Firefox history...... + + + + + Clean Chromium history...... + + + + + Clean system history...... + + + + + Clean apt...... + + + + + Start clean apt...... + + + + + Clean Firefox Cookie: + + + + + Clean Chromium Cookie: + + + + + + does not exist + + + + + Chromium Browser is running...... + + + + + Cache Scan OK + + + + + Cookies Scan OK + + + + + History Scan OK + + + + + Firefox Browser does not be installed + + + + + Chromium Browser does not be installed + + + + + Chromium Browser is running + + + + + Error: + + + + + Packages Scan OK + + + + + Ready to Cleanup...... + + + + + CleanerDetailWidget + + + Form + + + + + Apt Cache Clean Items + + + + + Apt Cache count: + + + + + + Software Cache Clean Items + + + + + Software Cache count: + + + + + + Thumbnails Cache Clean Items + + + + + Thumbnails Cache Count: + + + + + Firefox Cache Count: + + + + + Chromium Cache Count: + + + + + Firefox Cookies Clean Items + + + + + Firefox Cookies Count: + + + + + Chromium Cookies Clean Items + + + + + Chromium Cookies Count: + + + + + Firefox History Count: + + + + + Chromium History Count: + + + + + System History Count: + + + + + Command history size: + + + + + Debug log Items + + + + + Debug log: + + + + + No garbage + + + + + Clean args is empty! + + + + + CleanerItems + + + OK + + + + + CleanerMainWidget + + + Cleanup Package Cache + + + + + Cleanup Software Center Cache + + + + + Cleanup Thumbnails Cache + + + + + Cleanup FireFox Cache + + + + + Cleanup Chromium Cache + + + + + Cache Items + + + + + System Cache + + + + + Cleanup cache of system, software-center, thumbnails and browser + + + + + Cleanup the Cookies saving in Firefox + + + + + Cleanup the Cookies saving in Chromium + + + + + Cookies Items + + + + + Cookies + + + + + Clean up user login information, support Firefox and Chromium browser + + + + + Clean up the Firefox Internet records + + + + + Clean up the Chromium Internet records + + + + + Clean up the recently opened documents records + + + + + Delete the command history + + + + + Delete the debug logs + + + + + Trace Items + + + + + History trace + + + + + Cleaning the internet and opened documents recently records + + + + + Please select the items you want to clean + + + + + Scan args is empty! + + + + + ComputerPage + + + + + + + + + + + + + + + + + + + + + + + + %1 + + + + + + Minutes + + + + + Hours + + + + + %1 cores + + + + + %1 64bit + + + + + Ondemand + + + + + Powersave + + + + + Performance + + + + + CPU FM mode + + + + + + Audio Model + + + + + + + + + + + Vendor + + + + + + + + Bus Address + + + + + Audio Driver + + + + + + + + Device Name + + + + + Manufacturer + + + + + + Model + + + + + Technology + + + + + Voltage + + + + + Energy Designed + + + + + Energy Full + + + + + Energy Now + + + + + + + + + + + + Serial Number + + + + + Motherboard Model + + + + + Motherboard Vendor + + + + + BIOS Vendor + + + + + BIOS Version + + + + + Release Date + + + + + CD-ROM Model + + + + + + Firmware Version + + + + + + CPU + + + + + Socket/Slot + + + + + Maximum Frequency + + + + + Current Frequency + + + + + FSB + + + + + Core Number + + + + + Thread + + + + + L1 Cache + + + + + L2 Cache + + + + + phytium + + + + + 4 cores + + + + + 4 thread/core + + + + + Desktop Environment + + + + + Host Name + + + + + Memery Capacity + + + + + Terminal + + + + + Distribution + + + + + Language + + + + + User + + + + + Home Folder + + + + + Host bridge + + + + + VGA Model + + + + + USB Model + + + + + Communication Model + + + + + Ethernet Model + + + + + PCI bridge + + + + + ISA bridge + + + + + SATA Model + + + + + SMBus + + + + + System peripheral + + + + + Driver in use + + + + + existing drivers + + + + + IDE interface + + + + + SP controller + + + + + Network controller + + + + + Multimedia audio controller + + + + + HDD Model + + + + + HDD Vendor + + + + + HDD Capacity + + + + + Slot Number + + + + + Memory Model + + + + + Memory Size + + + + + Data Width + + + + + Memory Info + + + + + Graphics Card Model + + + + + Current Graphics Card + + + + + Graphics Card Vendor + + + + + Graphics Driver + + + + + Gamma + + + + + Screen Size(inch) + + + + + Max Resolution + + + + + Current Interface + + + + + Monitor Model + + + + + Visual Area + + + + + Support Interface + + + + + Monitor Manufacturers + + + + + Date of production/Week + + + + + Date of production/Year + + + + + NIC Model + + + + + NIC Driver + + + + + + IP Address + + + + + Mac Address + + + + + Connection Status + + + + + Max Bandwidth + + + + + WLan NIC Driver + + + + + WLan NIC Model + + + + + Device Name: + + + + + VNIC + + + + + NetType + + + + + Ethernet interface + + + + + Wireless interface + + + + + Version + + + + + Hostname + + + + + Running Time + + + + + OS Types + + + + + OS Version + + + + + Kernel Bit + + + + + Kernel Version + + + + + Kernel Arch + + + + + 32bit + + + + + 64bit + + + + + YHKylin community + + + + + Memory reference voltage + + + + + SATA controller voltage + + + + + Memory voltage + + + + + CPU pin voltage + + + + + Bridge voltage + + + + + CPU core voltage + + + + + CPU temperature + + + + + Motherboard temperature + + + + + CPU fan speed + + + + + ConserveWidget + + + Adjust gamma + + + + + Adjust brightness + + + + + Time before session is considered idle + + + + + Lock screen + + + + + Lock delay + + + + + Battery critical low action + + + + + Laptop lid close action on battery + + + + + Laptop lid close action on AC + + + + + Sleep timeout PC when on battery + + + + + Sleep timeout PC when on AC + + + + + Sleep timeout display when on battery + + + + + Sleep timeout display when on AC + + + + + + + suspend + + + + + shutdown + + + + + + nothing + + + + + + 1 minute + + + + + + 2 minutes + + + + + + 3 minutes + + + + + + + + + + 5 minutes + + + + + + + + + + 10 minutes + + + + + + + + + + Half an hour + + + + + + + + + + 1 hour + + + + + + + + + never + + + + + 30 seconds + + + + + Turn off the screen + + + + + + + + 20 minutes + + + + + + + + 2 hours + + + + + CpuWidget + + + CPU Info + + + + + DesktopWidget + + + Desktop Info + + + + + DriverWidget + + + Driver Info + + + + + FontWidget + + + + + + + Click here to change font + + + + + Default Font + + + + + Desktop Font + + + + + Monospace Font + + + + + Document Font + + + + + Titlebar Font + + + + + Global Font Scaling + + + + + Hinting + + + + + Antialiasing + + + + + + + + + Restore + + + + + HDWidget + + + HardWare Info + + + + + HardWare Info %1 + + + + + HomeActionWidget + + + + The lastest cleanup time is + + + + + + The lastest scan time is + + + + + You have not implemented the one key scan and clean-up operation. + + + + + Quick clean up system trash, saving disk space and improving the system efficiency! + + + + + Start Scan + + + + + Start Cleanup + + + + + Back + + + + + + Scanning...... + + + + + Scanning: + + + + + Scan Over + + + + + + + history trace; + + + + + + browser cookies. + + + + + + browser cookies; + + + + + + + + garbage. + + + + + history trace. + + + + + No garbage. + + + + + Cleaning...... + + + + + Garbage Cleanup OK...... + + + + + History Cleanup OK...... + + + + + Cookies Cleanup OK...... + + + + + Cleanup Cookies: + + + + + ; Garbage: + + + + + ; Historical records: + + + + + Cleaning up history trace of Firefox... + + + + + Firefox history trace had been cleared! + + + + + Cleaning up history trace of Chromium... + + + + + Chromium history trace had been cleared! + + + + + Cleaning up Cookies of Firefox... + + + + + Firefox Cookies had been cleared! + + + + + Cleaning up Cookies of Chromium... + + + + + Chromium Cookies had been cleared! + + + + + Apt cache had been cleared! + + + + + Cleaning up Apt cache: + + + + + Software Center cache had been cleared! + + + + + Cleaning up Software Center cache: + + + + + Ready to Cleanup...... + + + + + HomePage + + + Boot Manager + + + + + Camera + + + + + Current Version Number + + + + + Update to the lastest version, make it work better + + + + + updating on the backend + + + + + Common toolbox + + + + + Fast and practical, making the system more personalized + + + + + Upgrade is complete + + + + + Updating on the backend + + + + + More + + + + + IconWidget + + + Icon theme + + + + + Computer + + + + + Home Folder + + + + + Network + + + + + Trash + + + + + Mounted Volumes + + + + + InfoActionWidget + + + Understand hardware information, provide more convenient channel to obtain hardware information + + + + + InfoWidget + + + Computer + + + + + Desktop + + + + + CPU + + + + + Memory + + + + + Motherboard + + + + + HD + + + + + NIC + + + + + VGA + + + + + Audio + + + + + CD-ROM + + + + + Battery + + + + + Device Driver + + + + + Sensor + + + + + ItemCard + + + Form + + + + + KylinFontDialog + + + Current Font + + + + + Font + + + + + Style + + + + + Size + + + + + View + + + + + OK + + + + + Cancel + + + + + Tips + + + + + You haven't change the font, please choose the font! + + + + + Font Dialog + + + + + KylinMenu + + + Check and update + + + + + Forum Help + + + + + Feedback + + + + + About us + + + + + KylinSwitcher + + + ON + + + + + OFF + + + + + LauncherWidget + + + Launcher icon size + + + + + Launcher hide mode + + + + + Display desktop icon + + + + + Launcher Transparency + + + + + Icon Background + + + + + Top panel icon size + + + + + Top panel auto hide + + + + + Bottom panel icon size + + + + + Bottom panel auto hide + + + + + Launcher position + + + + + LoginWidget + + + Login Youker Account + + + + + Logout + + + + + MainWindow + + + Kylin Assistant + + + + + Youker Assistant + + + + + MemoryWidget + + + Memory Info + + + + + Memory Info %1 + + + + + MonitorWidget + + + Monitor Info + + + + + Monitor Info %1 + + + + + MouseWidget + + + Mouse Pointer Theme + + + + + Cursor Pointer Size + + + + + Small Size + + + + + Big Size + + + + + NautilusWidget + + + Display entry location + + + + + Automatically mount media + + + + + Automatically open a folder + + + + + Prompt autorun programs + + + + + Thumbnail icon size (pixels) + + + + + Thumbnail cache time (days) + + + + + Maximum thumbnail cache size (MB) + + + + + NicWidget + + + NIC Info + + + + + NIC Info %1 + + + + + NormalCard + + + Form + + + + + PanelWidget + + + Dash background blur type + + + + + Panel Transparency + + + + + Date & time format + + + + + Display seconds + + + + + Display week + + + + + Display the date + + + + + Display battery icon + + + + + Display battery percentage + + + + + Display battery remaining time + + + + + Smart blur + + + + + Static blur + + + + + Clear + + + + + Show applications + + + + + Show system + + + + + Show places + + + + + Show icon + + + + + QUIBO + + + Form + + + + + SensorWieget + + + Hardware sensor information + + + + + SettingAction + + + Back + + + + + Choose the theme what you want + + + + + Set the desktop icon theme and the visibility of desktop icons + + + + + Set the sound theme you want + + + + + Replace the theme and size of the mouse pointer, and theme change need to restart system + + + + + Setting the panel mode of auto hide and icon size + + + + + Setting the Launcher display mode, Icon size + + + + + Manage display of the start menu + + + + + Manage Dash and Panel menu settings + + + + + Window Manager settings + + + + + According to personal preferences to set the system default font, click the 'Restore' button, can be restored to the state before the font settings + + + + + Setting the relevant properties of your touchpad,make the operation more convenient + + + + + Monitor Check + + + + + Save energy to let the computer longer standby time + + + + + Manage the Caja file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked + + + + + Manage the Nautilus file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked + + + + + SettingActionWidget + + + You can perform a full range of customized systems based on personal preferences + + + + + SettingWidget + + + Personalize + + + + + ThemeSetting + + + + + IconSetting + + + + + MousePointer + + + + + SoundEffect + + + + + Desktop + + + + + Panel + + + + + StartMenu + + + + + Custom Launcher + + + + + Dash & Panel + + + + + Window + + + + + Font + + + + + FontSetting + + + + + Sys options + + + + + Touchpad + + + + + Dead pixel check + + + + + Energy saving + + + + + Others + + + + + File manager + + + + + ShredDialog + + + + Shred Manager + + + + + + + No select any file which need to be shredded + + + + + Shred File + + + + + Deselect + + + + + Allfile(*) + + + + + Select file! + + + + + Shred successfully! + + + + + Shred failed! + + + + + ShredManager + + + Shred Manager + + + + + Delete files makes it unable to recover + + + + + SkinCenter + + + Skin Setting + + + + + Default + + + + + Custom + + + + + Image Files(*.jpg *.png) + + + + + SystemWidget + + + Computer Base Info + + + + + + Minutes + + + + + Hours + + + + + ThemeWidget + + + Please choose theme which you need + + + + + TipDialog + + + OK + + + + + Tip Dialog + + + + + ToolWidget + + + Home + + + + + + Cleanup + + + + + + Sysinfo + + + + + KylinHome + + + + + Feature + + + + + + Toolkits + + + + + TouchpadWidget + + + Enable touchpad + + + + + Enable horizontal scrolling + + + + + Scrollbar type + + + + + Touchpad scrolling mode + + + + + Features Type + + + + + Standard Type + + + + + Disabled + + + + + Edge Scrolling + + + + + Two-finger Scrolling + + + + + UpgradeDialog + + + check and update + + + + + + Current verison: + + + + + Official version + + + + + An error occurred! + + + + + Network or local sources anomaly + + + + + you can visit the<a style='color: #3f96e4;' href = http://www.ubuntukylin.com> UK official website</a> to download the lastest deb package + + + + + Retry + + + + + Finish + + + + + Upgrade + + + + + + Start to update the local sources + + + + + Start to download + + + + + Updating local sources... + + + + + Youker Assistant is the latest version + + + + + Start to install + + + + + Download completely + + + + + Local sources updated + + + + + Found a new version + + + + + New version: + + + + + + Not found + + + + + + Testing network and local sources... + + + + + Upgrading the main program... + + + + + Start to upgrade the main program + + + + + VoiceWidget + + + Sound theme + + + + + Login tone + + + + + Event sounds + + + + + Input feedback sounds + + + + + WindowWidget + + + Arrangement of buttons on the titlebar + + + + + Menu with icons + + + + + Titlebar mouse wheel action + + + + + Titlebar double-click action + + + + + Titlebar middle-click action + + + + + Titlebar right-click action + + + + + Left + + + + + Right + + + + diff --git a/mainui/translation/youker-assistant_fr.qm b/mainui/translation/youker-assistant_fr.qm new file mode 100644 index 0000000..c02994c Binary files /dev/null and b/mainui/translation/youker-assistant_fr.qm differ diff --git a/mainui/translation/youker-assistant_fr.ts b/mainui/translation/youker-assistant_fr.ts new file mode 100644 index 0000000..ff9dd30 --- /dev/null +++ b/mainui/translation/youker-assistant_fr.ts @@ -0,0 +1,2863 @@ + + + + + AboutDialog + + + Youker Assisant + + + + + About + + + + + for more information. Welcome everyone to join with us. youker-assistant Homepage: + + + + + + The software is still under development. Please visit + + + + + Kylin Assisant + + + + + Maintainer: +Kylin Team <ubuntukylin-members@list.launchpad.net> + + + + + Kylin Assistant is a powerful system supporting software which is developed by Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, task manager, and some other functions. + + + + + for more information. Welcome everyone to join with us. kylin-assistant Homepage: + + + + + Maintainer: +Ubuntu Kylin Team <ubuntukylin-members@list.launchpad.net> + + + + + Contributor + + + + + Youker Assistant is a powerful system supporting software which is developed by Ubuntu Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, system customization, task manager, and some other functions. + + + + + Close + + + + + AlertDialog + + + Form + + + + + AudioWidget + + + Audio Info + + + + + Audio Info %1 + + + + + AutoStartWidget + + + AutoStart Items: + + + + + App + + + + + Status + + + + + ON Items: + + + + + OFF Items: + + + + + Boot Manager + + + + + Dialog + + + + + BatteryWidget + + + Battery Info + + + + + BoardWidget + + + Board Info + + + + + BoxActionWidget + + + Provide a practical and lightweight tool, create fast and convenient experience for you + + + + + More App + + + + + BoxWidget + + + + Kylin Software Center + + + + + + UbuntuKylin Software Center + + + + + Boot Manager + + + + + Camera + + + + + CDRowWidget + + + CDROM Info + + + + + CDROM Info %1 + + + + + CacheActionWidget + + + Cleaning up the system cache + + + + + Deep cleaning up the system cache, to save disk space + + + + + CameraManager + + + View Photos + + + + + The camera is out of question, <a style='color: #3f96e4;' href = http://www.ubuntukylin.com> Refresh</a> to call it out ~ + + + + + Camera + + + + + CleanListWidget + + + Clean Items: + + + + + Dialog + + + + + CleanSubGroup + + + Custom + + + + + CleanerActionWidget + + + Regular cleaning, let your computer remains the relaxed state + + + + + Start Scan + + + + + Start Cleanup + + + + + Back + + + + + + + + Scaning...... + + + + + Clean OK + + + + + Cleaning: + + + + + , Percent is: + + + + + %, Status is: + + + + + Clean Firefox history...... + + + + + Clean Chromium history...... + + + + + Clean system history...... + + + + + Clean apt...... + + + + + Start clean apt...... + + + + + Clean Firefox Cookie: + + + + + Clean Chromium Cookie: + + + + + + does not exist + + + + + Chromium Browser is running...... + + + + + Cache Scan OK + + + + + Cookies Scan OK + + + + + History Scan OK + + + + + Firefox Browser does not be installed + + + + + Chromium Browser does not be installed + + + + + Chromium Browser is running + + + + + Error: + + + + + Packages Scan OK + + + + + Ready to Cleanup...... + + + + + CleanerDetailWidget + + + Form + + + + + Apt Cache Clean Items + + + + + Apt Cache count: + + + + + + Software Cache Clean Items + + + + + Software Cache count: + + + + + + Thumbnails Cache Clean Items + + + + + Thumbnails Cache Count: + + + + + Firefox Cache Count: + + + + + Chromium Cache Count: + + + + + Firefox Cookies Clean Items + + + + + Firefox Cookies Count: + + + + + Chromium Cookies Clean Items + + + + + Chromium Cookies Count: + + + + + Firefox History Count: + + + + + Chromium History Count: + + + + + System History Count: + + + + + Command history size: + + + + + Debug log Items + + + + + Debug log: + + + + + No garbage + + + + + Clean args is empty! + + + + + CleanerItems + + + OK + + + + + CleanerMainWidget + + + Cleanup Package Cache + + + + + Cleanup Software Center Cache + + + + + Cleanup Thumbnails Cache + + + + + Cleanup FireFox Cache + + + + + Cleanup Chromium Cache + + + + + Cache Items + + + + + System Cache + + + + + Cleanup cache of system, software-center, thumbnails and browser + + + + + Cleanup the Cookies saving in Firefox + + + + + Cleanup the Cookies saving in Chromium + + + + + Cookies Items + + + + + Cookies + + + + + Clean up user login information, support Firefox and Chromium browser + + + + + Clean up the Firefox Internet records + + + + + Clean up the Chromium Internet records + + + + + Clean up the recently opened documents records + + + + + Delete the command history + + + + + Delete the debug logs + + + + + Trace Items + + + + + History trace + + + + + Cleaning the internet and opened documents recently records + + + + + Please select the items you want to clean + + + + + Scan args is empty! + + + + + ComputerPage + + + + + + + + + + + + + + + + + + + + + + + + %1 + + + + + + Minutes + + + + + Hours + + + + + %1 cores + + + + + %1 64bit + + + + + Ondemand + + + + + Powersave + + + + + Performance + + + + + CPU FM mode + + + + + + Audio Model + + + + + + + + + + + Vendor + + + + + + + + Bus Address + + + + + Audio Driver + + + + + + + + Device Name + + + + + Manufacturer + + + + + + Model + + + + + Technology + + + + + Voltage + + + + + Energy Designed + + + + + Energy Full + + + + + Energy Now + + + + + + + + + + + + Serial Number + + + + + Motherboard Model + + + + + Motherboard Vendor + + + + + BIOS Vendor + + + + + BIOS Version + + + + + Release Date + + + + + CD-ROM Model + + + + + + Firmware Version + + + + + + CPU + + + + + Socket/Slot + + + + + Maximum Frequency + + + + + Current Frequency + + + + + FSB + + + + + Core Number + + + + + Thread + + + + + L1 Cache + + + + + L2 Cache + + + + + phytium + + + + + 4 cores + + + + + 4 thread/core + + + + + Desktop Environment + + + + + Host Name + + + + + Memery Capacity + + + + + Terminal + + + + + Distribution + + + + + Language + + + + + User + + + + + Home Folder + + + + + Host bridge + + + + + VGA Model + + + + + USB Model + + + + + Communication Model + + + + + Ethernet Model + + + + + PCI bridge + + + + + ISA bridge + + + + + SATA Model + + + + + SMBus + + + + + System peripheral + + + + + Driver in use + + + + + existing drivers + + + + + IDE interface + + + + + SP controller + + + + + Network controller + + + + + Multimedia audio controller + + + + + HDD Model + + + + + HDD Vendor + + + + + HDD Capacity + + + + + Slot Number + + + + + Memory Model + + + + + Memory Size + + + + + Data Width + + + + + Memory Info + + + + + Graphics Card Model + + + + + Current Graphics Card + + + + + Graphics Card Vendor + + + + + Graphics Driver + + + + + Gamma + + + + + Screen Size(inch) + + + + + Max Resolution + + + + + Current Interface + + + + + Monitor Model + + + + + Visual Area + + + + + Support Interface + + + + + Monitor Manufacturers + + + + + Date of production/Week + + + + + Date of production/Year + + + + + NIC Model + + + + + NIC Driver + + + + + + IP Address + + + + + Mac Address + + + + + Connection Status + + + + + Max Bandwidth + + + + + WLan NIC Driver + + + + + WLan NIC Model + + + + + Device Name: + + + + + VNIC + + + + + NetType + + + + + Ethernet interface + + + + + Wireless interface + + + + + Version + + + + + Hostname + + + + + Running Time + + + + + OS Types + + + + + OS Version + + + + + Kernel Bit + + + + + Kernel Version + + + + + Kernel Arch + + + + + 32bit + + + + + 64bit + + + + + YHKylin community + + + + + Memory reference voltage + + + + + SATA controller voltage + + + + + Memory voltage + + + + + CPU pin voltage + + + + + Bridge voltage + + + + + CPU core voltage + + + + + CPU temperature + + + + + Motherboard temperature + + + + + CPU fan speed + + + + + ConserveWidget + + + Adjust gamma + + + + + Adjust brightness + + + + + Time before session is considered idle + + + + + Lock screen + + + + + Lock delay + + + + + Battery critical low action + + + + + Laptop lid close action on battery + + + + + Laptop lid close action on AC + + + + + Sleep timeout PC when on battery + + + + + Sleep timeout PC when on AC + + + + + Sleep timeout display when on battery + + + + + Sleep timeout display when on AC + + + + + + + suspend + + + + + shutdown + + + + + + nothing + + + + + + 1 minute + + + + + + 2 minutes + + + + + + 3 minutes + + + + + + + + + + 5 minutes + + + + + + + + + + 10 minutes + + + + + + + + + + Half an hour + + + + + + + + + + 1 hour + + + + + + + + + never + + + + + 30 seconds + + + + + Turn off the screen + + + + + + + + 20 minutes + + + + + + + + 2 hours + + + + + CpuWidget + + + CPU Info + + + + + DesktopWidget + + + Desktop Info + + + + + DriverWidget + + + Driver Info + + + + + FontWidget + + + + + + + Click here to change font + + + + + Default Font + + + + + Desktop Font + + + + + Monospace Font + + + + + Document Font + + + + + Titlebar Font + + + + + Global Font Scaling + + + + + Hinting + + + + + Antialiasing + + + + + + + + + Restore + + + + + HDWidget + + + HardWare Info + + + + + HardWare Info %1 + + + + + HomeActionWidget + + + + The lastest cleanup time is + + + + + + The lastest scan time is + + + + + You have not implemented the one key scan and clean-up operation. + + + + + Quick clean up system trash, saving disk space and improving the system efficiency! + + + + + Start Scan + + + + + Start Cleanup + + + + + Back + + + + + + Scanning...... + + + + + Scanning: + + + + + Scan Over + + + + + + + history trace; + + + + + + browser cookies. + + + + + + browser cookies; + + + + + + + + garbage. + + + + + history trace. + + + + + No garbage. + + + + + Cleaning...... + + + + + Garbage Cleanup OK...... + + + + + History Cleanup OK...... + + + + + Cookies Cleanup OK...... + + + + + Cleanup Cookies: + + + + + ; Garbage: + + + + + ; Historical records: + + + + + Cleaning up history trace of Firefox... + + + + + Firefox history trace had been cleared! + + + + + Cleaning up history trace of Chromium... + + + + + Chromium history trace had been cleared! + + + + + Cleaning up Cookies of Firefox... + + + + + Firefox Cookies had been cleared! + + + + + Cleaning up Cookies of Chromium... + + + + + Chromium Cookies had been cleared! + + + + + Apt cache had been cleared! + + + + + Cleaning up Apt cache: + + + + + Software Center cache had been cleared! + + + + + Cleaning up Software Center cache: + + + + + Ready to Cleanup...... + + + + + HomePage + + + Boot Manager + + + + + Camera + + + + + Current Version Number + + + + + Update to the lastest version, make it work better + + + + + updating on the backend + + + + + Common toolbox + + + + + Fast and practical, making the system more personalized + + + + + Upgrade is complete + + + + + Updating on the backend + + + + + More + + + + + IconWidget + + + Icon theme + + + + + Computer + + + + + Home Folder + + + + + Network + + + + + Trash + + + + + Mounted Volumes + + + + + InfoActionWidget + + + Understand hardware information, provide more convenient channel to obtain hardware information + + + + + InfoWidget + + + Computer + + + + + Desktop + + + + + CPU + + + + + Memory + + + + + Motherboard + + + + + HD + + + + + NIC + + + + + VGA + + + + + Audio + + + + + CD-ROM + + + + + Battery + + + + + Device Driver + + + + + Sensor + + + + + ItemCard + + + Form + + + + + KylinFontDialog + + + Current Font + + + + + Font + + + + + Style + + + + + Size + + + + + View + + + + + OK + + + + + Cancel + + + + + Tips + + + + + You haven't change the font, please choose the font! + + + + + Font Dialog + + + + + KylinMenu + + + Check and update + + + + + Forum Help + + + + + Feedback + + + + + About us + + + + + KylinSwitcher + + + ON + + + + + OFF + + + + + LauncherWidget + + + Launcher icon size + + + + + Launcher hide mode + + + + + Display desktop icon + + + + + Launcher Transparency + + + + + Icon Background + + + + + Top panel icon size + + + + + Top panel auto hide + + + + + Bottom panel icon size + + + + + Bottom panel auto hide + + + + + Launcher position + + + + + LoginWidget + + + Login Youker Account + + + + + Logout + + + + + MainWindow + + + Kylin Assistant + + + + + Youker Assistant + + + + + MemoryWidget + + + Memory Info + + + + + Memory Info %1 + + + + + MonitorWidget + + + Monitor Info + + + + + Monitor Info %1 + + + + + MouseWidget + + + Mouse Pointer Theme + + + + + Cursor Pointer Size + + + + + Small Size + + + + + Big Size + + + + + NautilusWidget + + + Display entry location + + + + + Automatically mount media + + + + + Automatically open a folder + + + + + Prompt autorun programs + + + + + Thumbnail icon size (pixels) + + + + + Thumbnail cache time (days) + + + + + Maximum thumbnail cache size (MB) + + + + + NicWidget + + + NIC Info + + + + + NIC Info %1 + + + + + NormalCard + + + Form + + + + + PanelWidget + + + Dash background blur type + + + + + Panel Transparency + + + + + Date & time format + + + + + Display seconds + + + + + Display week + + + + + Display the date + + + + + Display battery icon + + + + + Display battery percentage + + + + + Display battery remaining time + + + + + Smart blur + + + + + Static blur + + + + + Clear + + + + + Show applications + + + + + Show system + + + + + Show places + + + + + Show icon + + + + + QUIBO + + + Form + + + + + SensorWieget + + + Hardware sensor information + + + + + SettingAction + + + Back + + + + + Choose the theme what you want + + + + + Set the desktop icon theme and the visibility of desktop icons + + + + + Set the sound theme you want + + + + + Replace the theme and size of the mouse pointer, and theme change need to restart system + + + + + Setting the panel mode of auto hide and icon size + + + + + Setting the Launcher display mode, Icon size + + + + + Manage display of the start menu + + + + + Manage Dash and Panel menu settings + + + + + Window Manager settings + + + + + According to personal preferences to set the system default font, click the 'Restore' button, can be restored to the state before the font settings + + + + + Setting the relevant properties of your touchpad,make the operation more convenient + + + + + Monitor Check + + + + + Save energy to let the computer longer standby time + + + + + Manage the Caja file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked + + + + + Manage the Nautilus file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked + + + + + SettingActionWidget + + + You can perform a full range of customized systems based on personal preferences + + + + + SettingWidget + + + Personalize + + + + + ThemeSetting + + + + + IconSetting + + + + + MousePointer + + + + + SoundEffect + + + + + Desktop + + + + + Panel + + + + + StartMenu + + + + + Custom Launcher + + + + + Dash & Panel + + + + + Window + + + + + Font + + + + + FontSetting + + + + + Sys options + + + + + Touchpad + + + + + Dead pixel check + + + + + Energy saving + + + + + Others + + + + + File manager + + + + + ShredDialog + + + + Shred Manager + + + + + + + No select any file which need to be shredded + + + + + Shred File + + + + + Deselect + + + + + Allfile(*) + + + + + Select file! + + + + + Shred successfully! + + + + + Shred failed! + + + + + ShredManager + + + Shred Manager + + + + + Delete files makes it unable to recover + + + + + SkinCenter + + + Skin Setting + + + + + Default + + + + + Custom + + + + + Image Files(*.jpg *.png) + + + + + SystemWidget + + + Computer Base Info + + + + + + Minutes + + + + + Hours + + + + + ThemeWidget + + + Please choose theme which you need + + + + + TipDialog + + + OK + + + + + Tip Dialog + + + + + ToolWidget + + + Home + + + + + + Cleanup + + + + + + Sysinfo + + + + + KylinHome + + + + + Feature + + + + + + Toolkits + + + + + TouchpadWidget + + + Enable touchpad + + + + + Enable horizontal scrolling + + + + + Scrollbar type + + + + + Touchpad scrolling mode + + + + + Features Type + + + + + Standard Type + + + + + Disabled + + + + + Edge Scrolling + + + + + Two-finger Scrolling + + + + + UpgradeDialog + + + check and update + + + + + + Current verison: + + + + + Official version + + + + + An error occurred! + + + + + Network or local sources anomaly + + + + + you can visit the<a style='color: #3f96e4;' href = http://www.ubuntukylin.com> UK official website</a> to download the lastest deb package + + + + + Retry + + + + + Finish + + + + + Upgrade + + + + + + Start to update the local sources + + + + + Start to download + + + + + Updating local sources... + + + + + Youker Assistant is the latest version + + + + + Start to install + + + + + Download completely + + + + + Local sources updated + + + + + Found a new version + + + + + New version: + + + + + + Not found + + + + + + Testing network and local sources... + + + + + Upgrading the main program... + + + + + Start to upgrade the main program + + + + + VoiceWidget + + + Sound theme + + + + + Login tone + + + + + Event sounds + + + + + Input feedback sounds + + + + + WindowWidget + + + Arrangement of buttons on the titlebar + + + + + Menu with icons + + + + + Titlebar mouse wheel action + + + + + Titlebar double-click action + + + + + Titlebar middle-click action + + + + + Titlebar right-click action + + + + + Left + + + + + Right + + + + diff --git a/mainui/translation/youker-assistant_ru.qm b/mainui/translation/youker-assistant_ru.qm new file mode 100644 index 0000000..7431612 Binary files /dev/null and b/mainui/translation/youker-assistant_ru.qm differ diff --git a/mainui/translation/youker-assistant_ru.ts b/mainui/translation/youker-assistant_ru.ts new file mode 100644 index 0000000..d8eed44 --- /dev/null +++ b/mainui/translation/youker-assistant_ru.ts @@ -0,0 +1,2863 @@ + + + + + AboutDialog + + + Youker Assisant + + + + + About + + + + + for more information. Welcome everyone to join with us. youker-assistant Homepage: + + + + + + The software is still under development. Please visit + + + + + Kylin Assisant + + + + + Maintainer: +Kylin Team <ubuntukylin-members@list.launchpad.net> + + + + + Kylin Assistant is a powerful system supporting software which is developed by Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, task manager, and some other functions. + + + + + for more information. Welcome everyone to join with us. kylin-assistant Homepage: + + + + + Maintainer: +Ubuntu Kylin Team <ubuntukylin-members@list.launchpad.net> + + + + + Contributor + + + + + Youker Assistant is a powerful system supporting software which is developed by Ubuntu Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, system customization, task manager, and some other functions. + + + + + Close + + + + + AlertDialog + + + Form + + + + + AudioWidget + + + Audio Info + + + + + Audio Info %1 + + + + + AutoStartWidget + + + AutoStart Items: + + + + + App + + + + + Status + + + + + ON Items: + + + + + OFF Items: + + + + + Boot Manager + + + + + Dialog + + + + + BatteryWidget + + + Battery Info + + + + + BoardWidget + + + Board Info + + + + + BoxActionWidget + + + Provide a practical and lightweight tool, create fast and convenient experience for you + + + + + More App + + + + + BoxWidget + + + + Kylin Software Center + + + + + + UbuntuKylin Software Center + + + + + Boot Manager + + + + + Camera + + + + + CDRowWidget + + + CDROM Info + + + + + CDROM Info %1 + + + + + CacheActionWidget + + + Cleaning up the system cache + + + + + Deep cleaning up the system cache, to save disk space + + + + + CameraManager + + + View Photos + + + + + The camera is out of question, <a style='color: #3f96e4;' href = http://www.ubuntukylin.com> Refresh</a> to call it out ~ + + + + + Camera + + + + + CleanListWidget + + + Clean Items: + + + + + Dialog + + + + + CleanSubGroup + + + Custom + + + + + CleanerActionWidget + + + Regular cleaning, let your computer remains the relaxed state + + + + + Start Scan + + + + + Start Cleanup + + + + + Back + + + + + + + + Scaning...... + + + + + Clean OK + + + + + Cleaning: + + + + + , Percent is: + + + + + %, Status is: + + + + + Clean Firefox history...... + + + + + Clean Chromium history...... + + + + + Clean system history...... + + + + + Clean apt...... + + + + + Start clean apt...... + + + + + Clean Firefox Cookie: + + + + + Clean Chromium Cookie: + + + + + + does not exist + + + + + Chromium Browser is running...... + + + + + Cache Scan OK + + + + + Cookies Scan OK + + + + + History Scan OK + + + + + Firefox Browser does not be installed + + + + + Chromium Browser does not be installed + + + + + Chromium Browser is running + + + + + Error: + + + + + Packages Scan OK + + + + + Ready to Cleanup...... + + + + + CleanerDetailWidget + + + Form + + + + + Apt Cache Clean Items + + + + + Apt Cache count: + + + + + + Software Cache Clean Items + + + + + Software Cache count: + + + + + + Thumbnails Cache Clean Items + + + + + Thumbnails Cache Count: + + + + + Firefox Cache Count: + + + + + Chromium Cache Count: + + + + + Firefox Cookies Clean Items + + + + + Firefox Cookies Count: + + + + + Chromium Cookies Clean Items + + + + + Chromium Cookies Count: + + + + + Firefox History Count: + + + + + Chromium History Count: + + + + + System History Count: + + + + + Command history size: + + + + + Debug log Items + + + + + Debug log: + + + + + No garbage + + + + + Clean args is empty! + + + + + CleanerItems + + + OK + + + + + CleanerMainWidget + + + Cleanup Package Cache + + + + + Cleanup Software Center Cache + + + + + Cleanup Thumbnails Cache + + + + + Cleanup FireFox Cache + + + + + Cleanup Chromium Cache + + + + + Cache Items + + + + + System Cache + + + + + Cleanup cache of system, software-center, thumbnails and browser + + + + + Cleanup the Cookies saving in Firefox + + + + + Cleanup the Cookies saving in Chromium + + + + + Cookies Items + + + + + Cookies + + + + + Clean up user login information, support Firefox and Chromium browser + + + + + Clean up the Firefox Internet records + + + + + Clean up the Chromium Internet records + + + + + Clean up the recently opened documents records + + + + + Delete the command history + + + + + Delete the debug logs + + + + + Trace Items + + + + + History trace + + + + + Cleaning the internet and opened documents recently records + + + + + Please select the items you want to clean + + + + + Scan args is empty! + + + + + ComputerPage + + + + + + + + + + + + + + + + + + + + + + + + %1 + + + + + + Minutes + + + + + Hours + + + + + %1 cores + + + + + %1 64bit + + + + + Ondemand + + + + + Powersave + + + + + Performance + + + + + CPU FM mode + + + + + + Audio Model + + + + + + + + + + + Vendor + + + + + + + + Bus Address + + + + + Audio Driver + + + + + + + + Device Name + + + + + Manufacturer + + + + + + Model + + + + + Technology + + + + + Voltage + + + + + Energy Designed + + + + + Energy Full + + + + + Energy Now + + + + + + + + + + + + Serial Number + + + + + Motherboard Model + + + + + Motherboard Vendor + + + + + BIOS Vendor + + + + + BIOS Version + + + + + Release Date + + + + + CD-ROM Model + + + + + + Firmware Version + + + + + + CPU + + + + + Socket/Slot + + + + + Maximum Frequency + + + + + Current Frequency + + + + + FSB + + + + + Core Number + + + + + Thread + + + + + L1 Cache + + + + + L2 Cache + + + + + phytium + + + + + 4 cores + + + + + 4 thread/core + + + + + Desktop Environment + + + + + Host Name + + + + + Memery Capacity + + + + + Terminal + + + + + Distribution + + + + + Language + + + + + User + + + + + Home Folder + + + + + Host bridge + + + + + VGA Model + + + + + USB Model + + + + + Communication Model + + + + + Ethernet Model + + + + + PCI bridge + + + + + ISA bridge + + + + + SATA Model + + + + + SMBus + + + + + System peripheral + + + + + Driver in use + + + + + existing drivers + + + + + IDE interface + + + + + SP controller + + + + + Network controller + + + + + Multimedia audio controller + + + + + HDD Model + + + + + HDD Vendor + + + + + HDD Capacity + + + + + Slot Number + + + + + Memory Model + + + + + Memory Size + + + + + Data Width + + + + + Memory Info + + + + + Graphics Card Model + + + + + Current Graphics Card + + + + + Graphics Card Vendor + + + + + Graphics Driver + + + + + Gamma + + + + + Screen Size(inch) + + + + + Max Resolution + + + + + Current Interface + + + + + Monitor Model + + + + + Visual Area + + + + + Support Interface + + + + + Monitor Manufacturers + + + + + Date of production/Week + + + + + Date of production/Year + + + + + NIC Model + + + + + NIC Driver + + + + + + IP Address + + + + + Mac Address + + + + + Connection Status + + + + + Max Bandwidth + + + + + WLan NIC Driver + + + + + WLan NIC Model + + + + + Device Name: + + + + + VNIC + + + + + NetType + + + + + Ethernet interface + + + + + Wireless interface + + + + + Version + + + + + Hostname + + + + + Running Time + + + + + OS Types + + + + + OS Version + + + + + Kernel Bit + + + + + Kernel Version + + + + + Kernel Arch + + + + + 32bit + + + + + 64bit + + + + + YHKylin community + + + + + Memory reference voltage + + + + + SATA controller voltage + + + + + Memory voltage + + + + + CPU pin voltage + + + + + Bridge voltage + + + + + CPU core voltage + + + + + CPU temperature + + + + + Motherboard temperature + + + + + CPU fan speed + + + + + ConserveWidget + + + Adjust gamma + + + + + Adjust brightness + + + + + Time before session is considered idle + + + + + Lock screen + + + + + Lock delay + + + + + Battery critical low action + + + + + Laptop lid close action on battery + + + + + Laptop lid close action on AC + + + + + Sleep timeout PC when on battery + + + + + Sleep timeout PC when on AC + + + + + Sleep timeout display when on battery + + + + + Sleep timeout display when on AC + + + + + + + suspend + + + + + shutdown + + + + + + nothing + + + + + + 1 minute + + + + + + 2 minutes + + + + + + 3 minutes + + + + + + + + + + 5 minutes + + + + + + + + + + 10 minutes + + + + + + + + + + Half an hour + + + + + + + + + + 1 hour + + + + + + + + + never + + + + + 30 seconds + + + + + Turn off the screen + + + + + + + + 20 minutes + + + + + + + + 2 hours + + + + + CpuWidget + + + CPU Info + + + + + DesktopWidget + + + Desktop Info + + + + + DriverWidget + + + Driver Info + + + + + FontWidget + + + + + + + Click here to change font + + + + + Default Font + + + + + Desktop Font + + + + + Monospace Font + + + + + Document Font + + + + + Titlebar Font + + + + + Global Font Scaling + + + + + Hinting + + + + + Antialiasing + + + + + + + + + Restore + + + + + HDWidget + + + HardWare Info + + + + + HardWare Info %1 + + + + + HomeActionWidget + + + + The lastest cleanup time is + + + + + + The lastest scan time is + + + + + You have not implemented the one key scan and clean-up operation. + + + + + Quick clean up system trash, saving disk space and improving the system efficiency! + + + + + Start Scan + + + + + Start Cleanup + + + + + Back + + + + + + Scanning...... + + + + + Scanning: + + + + + Scan Over + + + + + + + history trace; + + + + + + browser cookies. + + + + + + browser cookies; + + + + + + + + garbage. + + + + + history trace. + + + + + No garbage. + + + + + Cleaning...... + + + + + Garbage Cleanup OK...... + + + + + History Cleanup OK...... + + + + + Cookies Cleanup OK...... + + + + + Cleanup Cookies: + + + + + ; Garbage: + + + + + ; Historical records: + + + + + Cleaning up history trace of Firefox... + + + + + Firefox history trace had been cleared! + + + + + Cleaning up history trace of Chromium... + + + + + Chromium history trace had been cleared! + + + + + Cleaning up Cookies of Firefox... + + + + + Firefox Cookies had been cleared! + + + + + Cleaning up Cookies of Chromium... + + + + + Chromium Cookies had been cleared! + + + + + Apt cache had been cleared! + + + + + Cleaning up Apt cache: + + + + + Software Center cache had been cleared! + + + + + Cleaning up Software Center cache: + + + + + Ready to Cleanup...... + + + + + HomePage + + + Boot Manager + + + + + Camera + + + + + Current Version Number + + + + + Update to the lastest version, make it work better + + + + + updating on the backend + + + + + Common toolbox + + + + + Fast and practical, making the system more personalized + + + + + Upgrade is complete + + + + + Updating on the backend + + + + + More + + + + + IconWidget + + + Icon theme + + + + + Computer + + + + + Home Folder + + + + + Network + + + + + Trash + + + + + Mounted Volumes + + + + + InfoActionWidget + + + Understand hardware information, provide more convenient channel to obtain hardware information + + + + + InfoWidget + + + Computer + + + + + Desktop + + + + + CPU + + + + + Memory + + + + + Motherboard + + + + + HD + + + + + NIC + + + + + VGA + + + + + Audio + + + + + CD-ROM + + + + + Battery + + + + + Device Driver + + + + + Sensor + + + + + ItemCard + + + Form + + + + + KylinFontDialog + + + Current Font + + + + + Font + + + + + Style + + + + + Size + + + + + View + + + + + OK + + + + + Cancel + + + + + Tips + + + + + You haven't change the font, please choose the font! + + + + + Font Dialog + + + + + KylinMenu + + + Check and update + + + + + Forum Help + + + + + Feedback + + + + + About us + + + + + KylinSwitcher + + + ON + + + + + OFF + + + + + LauncherWidget + + + Launcher icon size + + + + + Launcher hide mode + + + + + Display desktop icon + + + + + Launcher Transparency + + + + + Icon Background + + + + + Top panel icon size + + + + + Top panel auto hide + + + + + Bottom panel icon size + + + + + Bottom panel auto hide + + + + + Launcher position + + + + + LoginWidget + + + Login Youker Account + + + + + Logout + + + + + MainWindow + + + Kylin Assistant + + + + + Youker Assistant + + + + + MemoryWidget + + + Memory Info + + + + + Memory Info %1 + + + + + MonitorWidget + + + Monitor Info + + + + + Monitor Info %1 + + + + + MouseWidget + + + Mouse Pointer Theme + + + + + Cursor Pointer Size + + + + + Small Size + + + + + Big Size + + + + + NautilusWidget + + + Display entry location + + + + + Automatically mount media + + + + + Automatically open a folder + + + + + Prompt autorun programs + + + + + Thumbnail icon size (pixels) + + + + + Thumbnail cache time (days) + + + + + Maximum thumbnail cache size (MB) + + + + + NicWidget + + + NIC Info + + + + + NIC Info %1 + + + + + NormalCard + + + Form + + + + + PanelWidget + + + Dash background blur type + + + + + Panel Transparency + + + + + Date & time format + + + + + Display seconds + + + + + Display week + + + + + Display the date + + + + + Display battery icon + + + + + Display battery percentage + + + + + Display battery remaining time + + + + + Smart blur + + + + + Static blur + + + + + Clear + + + + + Show applications + + + + + Show system + + + + + Show places + + + + + Show icon + + + + + QUIBO + + + Form + + + + + SensorWieget + + + Hardware sensor information + + + + + SettingAction + + + Back + + + + + Choose the theme what you want + + + + + Set the desktop icon theme and the visibility of desktop icons + + + + + Set the sound theme you want + + + + + Replace the theme and size of the mouse pointer, and theme change need to restart system + + + + + Setting the panel mode of auto hide and icon size + + + + + Setting the Launcher display mode, Icon size + + + + + Manage display of the start menu + + + + + Manage Dash and Panel menu settings + + + + + Window Manager settings + + + + + According to personal preferences to set the system default font, click the 'Restore' button, can be restored to the state before the font settings + + + + + Setting the relevant properties of your touchpad,make the operation more convenient + + + + + Monitor Check + + + + + Save energy to let the computer longer standby time + + + + + Manage the Caja file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked + + + + + Manage the Nautilus file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked + + + + + SettingActionWidget + + + You can perform a full range of customized systems based on personal preferences + + + + + SettingWidget + + + Personalize + + + + + ThemeSetting + + + + + IconSetting + + + + + MousePointer + + + + + SoundEffect + + + + + Desktop + + + + + Panel + + + + + StartMenu + + + + + Custom Launcher + + + + + Dash & Panel + + + + + Window + + + + + Font + + + + + FontSetting + + + + + Sys options + + + + + Touchpad + + + + + Dead pixel check + + + + + Energy saving + + + + + Others + + + + + File manager + + + + + ShredDialog + + + + Shred Manager + + + + + + + No select any file which need to be shredded + + + + + Shred File + + + + + Deselect + + + + + Allfile(*) + + + + + Select file! + + + + + Shred successfully! + + + + + Shred failed! + + + + + ShredManager + + + Shred Manager + + + + + Delete files makes it unable to recover + + + + + SkinCenter + + + Skin Setting + + + + + Default + + + + + Custom + + + + + Image Files(*.jpg *.png) + + + + + SystemWidget + + + Computer Base Info + + + + + + Minutes + + + + + Hours + + + + + ThemeWidget + + + Please choose theme which you need + + + + + TipDialog + + + OK + + + + + Tip Dialog + + + + + ToolWidget + + + Home + + + + + + Cleanup + + + + + + Sysinfo + + + + + KylinHome + + + + + Feature + + + + + + Toolkits + + + + + TouchpadWidget + + + Enable touchpad + + + + + Enable horizontal scrolling + + + + + Scrollbar type + + + + + Touchpad scrolling mode + + + + + Features Type + + + + + Standard Type + + + + + Disabled + + + + + Edge Scrolling + + + + + Two-finger Scrolling + + + + + UpgradeDialog + + + check and update + + + + + + Current verison: + + + + + Official version + + + + + An error occurred! + + + + + Network or local sources anomaly + + + + + you can visit the<a style='color: #3f96e4;' href = http://www.ubuntukylin.com> UK official website</a> to download the lastest deb package + + + + + Retry + + + + + Finish + + + + + Upgrade + + + + + + Start to update the local sources + + + + + Start to download + + + + + Updating local sources... + + + + + Youker Assistant is the latest version + + + + + Start to install + + + + + Download completely + + + + + Local sources updated + + + + + Found a new version + + + + + New version: + + + + + + Not found + + + + + + Testing network and local sources... + + + + + Upgrading the main program... + + + + + Start to upgrade the main program + + + + + VoiceWidget + + + Sound theme + + + + + Login tone + + + + + Event sounds + + + + + Input feedback sounds + + + + + WindowWidget + + + Arrangement of buttons on the titlebar + + + + + Menu with icons + + + + + Titlebar mouse wheel action + + + + + Titlebar double-click action + + + + + Titlebar middle-click action + + + + + Titlebar right-click action + + + + + Left + + + + + Right + + + + diff --git a/mainui/translation/youker-assistant_zh_CN.qm b/mainui/translation/youker-assistant_zh_CN.qm new file mode 100644 index 0000000..f4d59dc Binary files /dev/null and b/mainui/translation/youker-assistant_zh_CN.qm differ diff --git a/mainui/translation/youker-assistant_zh_CN.ts b/mainui/translation/youker-assistant_zh_CN.ts new file mode 100644 index 0000000..336b2a2 --- /dev/null +++ b/mainui/translation/youker-assistant_zh_CN.ts @@ -0,0 +1,2860 @@ + + + + + AboutDialog + + + About us + 关于我们 + + + + Kylin Assistant + 麒麟助手 + + + + About + 关于本软件 + 关于 + + + + Maintainer: +Kylin Team <ubuntukylin-members@list.launchpad.net> + 维护者: +麒麟团队 <ubuntukylin-members@list.launchpad.net> + + + + Kylin Assistant is a powerful system supporting software which is developed by Kylin team. Mainly for the naive user, it can help users manage the system. At present, It provides system junk scanning and cleaning, viewing the system hardware and software information, task manager, and some other functions. + 麒麟助手是由麒麟团队开发的一款功能强大的系统辅助软件。主要面向初级用户,能够帮助用户对系统进行管理。目前已具备了系统垃圾扫描与清理、系统软硬件信息查看、系统全方位定制、任务管理器等功能。 + + + + for more information. Welcome everyone to join with us. kylin-assistant Homepage: + 了解软件的最新进展并反馈问题,欢迎广大用户和爱好者一起参与。麒麟助手主页: + + + + The software is still under development. Please visit + 各项功能还在不断完善,更多功能也将陆续开发,敬请关注 Ubuntu Kylin 官网 + + + + Contributor + 贡献者 + + + + Close + 关闭 + 关闭 + + + + AlertDialog + + + Form + + + + + AudioWidget + + + Audio Info + 声卡信息 + + + + Audio Info %1 + 声卡信息%1 + + + + AutoStartWidget + + + AutoStart Items: + 自启动选项: + + + + App + 应用程序 + + + + Status + 状态 + + + + ON Items: + 已开启数目: + + + + OFF Items: + 已关闭数目: + + + + + Boot Manager + 启动项管理 + + + + Dialog + + + + + BatteryWidget + + + Battery Info + 电池信息 + + + + BoardWidget + + + Board Info + 主板信息 + + + + BoxActionWidget + + + Provide a practical and lightweight tool, create fast and convenient experience for you + 提供轻巧使用工具,为您打造快捷方便的体验 + + + + More App + 更多应用 + + + + BoxWidget + + + + Kylin Software Center + 麒麟软件中心 + + + + Boot Manager + 启动项管理 + + + Camera + 摄像头 + + + + CDRowWidget + + + CDROM Info + 光驱信息 + + + + CDROM Info %1 + 光驱信息 %1 + + + + CacheActionWidget + + + Cleaning up the system cache + 清理系统缓存 + + + + Deep cleaning up the system cache, to save disk space + 深度清理系统缓存,节省磁盘空间 + + + + CameraManager + + View Photos + 浏览照片 + + + The camera is out of question, <a style='color: #3f96e4;' href = http://www.ubuntukylin.com> Refresh</a> to call it out ~ + 摄像头出问题了, <a style='color: #3f96e4;' href = http://www.ubuntukylin.com> 刷新</a> 去召唤它~ + + + Camera + 摄像头 + + + + CleanListWidget + + + Clean Items: + 清理项: + + + + Dialog + + + + + CleanSubGroup + + + Custom + 自定义 + + + + CleanerActionWidget + + + Regular cleaning, let your computer remains the relaxed state + 经常清理,让电脑保持最轻松的状态 + + + + Start Scan + 开始扫描 + + + + Start Cleanup + 开始清理 + + + + Back + 返回 + + + + + + + Scaning...... + 正在扫描..... + + + + Clean OK + 清理完毕 + + + + Cleaning: + 正在清理: + + + + , Percent is: + ,进度为: + + + + %, Status is: + %,状态为: + + + + Clean Firefox history...... + 清理Firefox浏览器历史记录...... + + + + Clean Chromium history...... + 清理Chromium浏览器历史记录...... + + + + Clean system history...... + 清理系统历史痕迹...... + + + + Clean apt...... + 清理Apt...... + + + + Start clean apt...... + 开始清理Apt...... + + + + Clean Firefox Cookie: + 清理Firefox浏览器Cookie: + + + + Clean Chromium Cookie: + 清理Chromium浏览器Cookie: + + + + + does not exist + 不存在 + + + + Chromium Browser is running...... + Chromium浏览器正在运行中...... + + + + Cache Scan OK + 缓存扫描完成 + + + + Cookies Scan OK + Cookies扫描完成 + + + + History Scan OK + 历史记录扫描完成 + + + + Packages Scan OK + 包扫描完成 + + + + Firefox Browser does not be installed + 没有安装Firefox浏览器 + + + + Chromium Browser does not be installed + 没有安装Chromium浏览器 + + + + Chromium Browser is running + Chromium浏览器正在运行中 + + + + Error: + 错误: + + + + Ready to Cleanup...... + 准备清理...... + + + + CleanerDetailWidget + + + Apt Cache Clean Items + Apt缓存清理项 + + + + Apt Cache count: + Apt缓存总数: + + + + + Software Cache Clean Items + 软件中心缓存清理项 + + + + Software Cache count: + 软件中心缓存总数: + + + + + Thumbnails Cache Clean Items + 缩略图缓存清理项 + + + + Thumbnails Cache Count: + 缩略图缓存总数: + + + + Firefox Cache Count: + Firefox浏览器缓存总数: + + + + Chromium Cache Count: + Chromium浏览器缓存总数: + + + + Firefox Cookies Clean Items + Firefox Cookies 清理项 + + + + Firefox Cookies Count: + Firefox Cookies总数: + + + + Chromium Cookies Clean Items + Chromium Cookies 清理项 + + + + Chromium Cookies Count: + Chromium Cookies总数: + + + + Firefox History Count: + Firefox 历史记录总数: + + + + Chromium History Count: + Chromium历史记录总数: + + + + System History Count: + 系统历史痕迹总数: + + + + Command history size: + 命令历史记录大小: + + + + Debug log Items + 调试日志项 + + + + Debug log: + 调试日志: + + + + No garbage + 没有扫描到垃圾 + + + + Clean args is empty! + 清理参数为空! + + + + Form + + + + + + CleanerItems + + + OK + 确定 + + + + CleanerMainWidget + + + Cleanup Package Cache + 清理包缓存 + + + + Cleanup Software Center Cache + 清理软件中心缓存 + + + + Cleanup Thumbnails Cache + 清理缩略图缓存 + + + + Cleanup FireFox Cache + 清理火狐浏览器缓存 + + + + Cleanup Chromium Cache + 清理chromium缓存 + + + + Cache Items + 缓存选项 + + + + System Cache + 系统缓存 + + + + Cleanup cache of system, software-center, thumbnails and browser + 清除包、缩略图和浏览器缓存等 + + + + Cleanup the Cookies saving in Firefox + 清理火狐浏览器的Cookies + + + + Cleanup the Cookies saving in Chromium + 清理Chromium浏览器的Cookies + + + + Cookies Items + Cookies选项 + + + + Cookies + Cookies + + + + Clean up user login information, support Firefox and Chromium browser + 清除上网、游戏、购物等记录 + + + + Clean up the Firefox Internet records + 清理火狐访问记录 + + + + Clean up the Chromium Internet records + 清理Chromium访问记录 + + + + Clean up the recently opened documents records + 清理最近打开的文件记录 + + + + Delete the command history + 删除命令历史记录 + + + + Delete the debug logs + 删除调试日志 + + + + Trace Items + 访问痕迹选项 + + + + History trace + 历史痕迹 + + + + Cleaning the internet and opened documents recently records + 清除浏览器和系统使用痕迹 + + + + Please select the items you want to clean + 请选择您想清理的选项 + + + + Scan args is empty! + 扫描参数为空! + + + + ComputerPage + + + + + + + + + + + + + + + + + + + + + + + + + %1 + + + + + + Minutes + 分钟 + + + + Hours + 小时 + + + %1 cores + %1 核 + + + + + Audio Model + 声卡型号 + + + + + + + + + + Vendor + 制造商 + + + + + + + Bus Address + 总线地址 + + + + Audio Driver + 声卡驱动 + + + + + + + Device Name + 设备名 + + + + Manufacturer + 发行商 + + + + + Model + 型号 + + + + Technology + 技术 + + + + Voltage + 电压 + + + + Energy Designed + 能量(设计) + + + + Energy Full + 满时能量 + + + + Energy Now + 能量 + + + + + + + + + + + Serial Number + 序列号 + + + + Motherboard Model + 主板型号 + + + + Motherboard Vendor + 主板产商 + + + + BIOS Vendor + BIOS产商 + + + + BIOS Version + BIOS版本 + + + + Release Date + 发布日期 + + + + CD-ROM Model + 光驱型号 + + + + + Firmware Version + 固件版本 + + + + + CPU + 处理器 + + + + Socket/Slot + 插座/插槽 + + + + Maximum Frequency + 最大主频 + + + + Current Frequency + 当前主频 + + + + FSB + 前端总线 + + + + Core Number + 核心数目 + + + + Thread + 线程 + + + + L1 Cache + 1级缓存 + + + + L2 Cache + 2级缓存 + + + + phytium + 飞腾 + + + + 4 cores + 4核 + + + + 4 thread/core + 4线程/核 + + + + Desktop Environment + 桌面环境 + + + + Host Name + 主机名 + + + + Memery Capacity + 内存容量 + + + + Terminal + 用户命令解释器 + + + + 32bit + 32位 + + + + 64bit + 64位 + + + + YHKylin community + 银河麒麟社区版 + + + + Memory reference voltage + 内存参考电压 + + + + SATA controller voltage + SATA控制器电压 + + + + Memory voltage + 内存电压 + + + + CPU pin voltage + CPU管脚电压 + + + + Bridge voltage + 桥片电压 + + + + CPU core voltage + CPU核电压 + + + + CPU temperature + CPU温度 + + + + Motherboard temperature + 主板温度 + + + + CPU fan speed + CPU风扇转速 + + + + %1 64bit + %1 64位 + + + + %1 + %1 + + + + Ondemand + 自动调频 + + + + Powersave + 省电模式 + + + + Performance + 性能模式 + + + + CPU FM mode + CPU调频模式 + + + + Distribution + 发行版 + + + + Language + 语言 + + + + User + 用户 + + + + Home Folder + 用户主目录 + + + + Host bridge + 主桥 + + + + VGA Model + VGA兼容控制器 + + + + USB Model + USB控制器 + + + + Communication Model + 通信控制器 + + + + Ethernet Model + 以太网控制器 + + + + PCI bridge + PCI桥 + + + + ISA bridge + ISA桥 + + + + SATA Model + SATA控制器 + + + + SMBus + 系统管理总线 + + + + System peripheral + 系统外围 + + + + Driver in use + 使用的驱动 + + + + existing drivers + 可选的驱动 + + + + IDE interface + IDE接口 + + + + SP controller + 信号处理控制器 + + + + Network controller + 网络控制器 + + + + Multimedia audio controller + 多媒体音频控制器 + + + + HDD Model + 硬盘型号 + + + + HDD Vendor + 硬盘厂商 + + + + HDD Capacity + 硬盘容量 + + + + Slot Number + 插槽号 + + + + Memory Model + 内存型号 + + + + Memory Size + 内存大小 + + + + Data Width + 数据宽度 + + + + Memory Info + 内存条信息 + + + + Graphics Card Model + 显卡型号 + + + + Current Graphics Card + 当前显卡 + + + + Graphics Card Vendor + 显卡制造商 + + + + Graphics Driver + 显卡驱动 + + + + Gamma + 伽马值 + + + + Screen Size(inch) + 屏幕尺寸(英寸) + + + + Max Resolution + 最大分辨率 + + + + Current Interface + 当前接口 + + + + Monitor Model + 显示器型号 + + + + Visual Area + 可视面积 + + + + Support Interface + 支持接口 + + + + Monitor Manufacturers + 显示器制造商 + + + + Date of production/Week + 生产日期/周 + + + + Date of production/Year + 生产日期/年 + + + + NIC Model + 网卡型号 + + + + NIC Driver + 网卡驱动 + + + + + IP Address + IP地址 + + + + Mac Address + MAC地址 + + + + Connection Status + 连接状态 + + + + Max Bandwidth + 最大带宽 + + + + WLan NIC Driver + 无线网卡驱动 + + + + WLan NIC Model + 网卡型号 + + + + Device Name: + 设备名称: + + + + VNIC + 虚拟网卡 + + + + NetType + 网卡类型 + + + + Ethernet interface + 以太网接口 + + + + Wireless interface + 无线网接口 + + + + Version + 电脑版本 + + + + Hostname + 主机名 + + + + Running Time + 持续运行时间 + + + + OS Types + 操作系统类型 + + + + OS Version + 操作系统版本 + + + + Kernel Bit + 系统位数 + + + + Kernel Version + 内核版本 + + + + Kernel Arch + 内核架构 + + + + ConserveWidget + + + Adjust gamma + 调整伽马值 + + + + Adjust brightness + 调整屏幕亮度 + + + + Time before session is considered idle + 在此时间范围内无操作则关闭屏幕 + + + + Lock screen + 锁定屏幕 + + + + Lock delay + 锁定延时 + + + + Battery critical low action + 电池严重不足时 + + + + Laptop lid close action on battery + 使用电池合上盖子时 + + + + Laptop lid close action on AC + 使用电源合上盖子时 + + + + Sleep timeout PC when on battery + 使用电池,空闲此时间后电脑转入睡眠 + + + + Sleep timeout PC when on AC + 使用电源,空闲此时间后电脑转入睡眠 + + + + Sleep timeout display when on battery + 使用电池,空闲此时间后屏幕转入睡眠 + + + + Sleep timeout display when on AC + 使用电源,空闲此时间后屏幕转入睡眠 + + + + + + suspend + 挂起 + + + + shutdown + 电源关闭 + + + + + nothing + 不处理 + + + + + 1 minute + 1 分钟 + + + + + 2 minutes + 2 分钟 + + + + + 3 minutes + 3 分钟 + + + + + + + + + 5 minutes + 5 分钟 + + + + + + + + + 10 minutes + 10 分钟 + + + + + + + + + Half an hour + 半小时 + + + + + + + + + 1 hour + 1 小时 + + + + + + + + never + 从不 + + + + 30 seconds + 30 秒 + + + + Turn off the screen + 关闭屏幕 + + + + + + + 20 minutes + 20 分钟 + + + + + + + 2 hours + 2 小时 + + + + CpuWidget + + + CPU Info + 处理器信息 + + + + DesktopWidget + + + Desktop Info + 桌面环境信息 + + + + DriverWidget + + + Driver Info + 驱动信息 + + + + FontWidget + + + + + + + Click here to change font + 点击此处更换字体 + + + + Default Font + 默认字体 + + + + Desktop Font + 桌面字体 + + + + Monospace Font + 等宽字体 + + + + Document Font + 文档字体 + + + + Titlebar Font + 标题栏字体 + + + + Global Font Scaling + 全局字体缩放 + + + + Hinting + 平滑 + + + + Antialiasing + 反锯齿 + + + + + + + + Restore + 恢复默认 + + + + HDWidget + + + HardWare Info + 硬盘信息 + + + + HardWare Info %1 + 硬盘信息 %1 + + + + HomeActionWidget + + + + The lastest cleanup time is + 上一次清理时间是 + + + + + The lastest scan time is + 上一次扫描时间是 + + + + You have not implemented the one key scan and clean-up operation. + 您还没有执行过一键扫描和一键清理操作。 + + + + Quick clean up system trash, saving disk space and improving the system efficiency! + 一键清理系统垃圾,帮您节省磁盘空间,让系统运行更加有效率! + + + + Start Scan + 开始扫描 + + + + Start Cleanup + 开始清理 + + + + Back + 返回 + + + + + Scanning...... + 正在扫描..... + + + + Scanning: + 正在扫描: + + + + Scan Over + 扫描完成 + + + + + + history trace; + 条历史痕迹; + + + + + browser cookies. + 条浏览器Cookies。 + + + + + browser cookies; + 条浏览器Cookies; + + + + + + + garbage. + 垃圾。 + + + + history trace. + 条历史痕迹。 + + + + No garbage. + 没有扫描到垃圾。 + + + + Cleaning...... + 正在清理....... + + + + Garbage Cleanup OK...... + 垃圾清理完成...... + + + + History Cleanup OK...... + 历史记录清理完成...... + + + + Cookies Cleanup OK...... + Cookies清理完成...... + + + + Cleanup Cookies: + 清理了Cookies: + + + + ; Garbage: + ;垃圾: + + + + ; Historical records: + ;历史记录: + + + + Cleaning up history trace of Firefox... + 正在清理Firefox浏览器的历史痕迹...... + + + + Firefox history trace had been cleared! + Firefox浏览器历史痕迹清理完成! + + + + Cleaning up history trace of Chromium... + 正在清理Chromium浏览器的历史痕迹...... + + + + Chromium history trace had been cleared! + Chromium浏览器的历史痕迹清理完成! + + + + Cleaning up Cookies of Firefox... + 正在清理Firefox浏览器的Cookies...... + + + + Firefox Cookies had been cleared! + Firefox浏览器的Cookies清理完成! + + + + Cleaning up Cookies of Chromium... + 正在清理Chromium浏览器的Cookies...... + + + + Chromium Cookies had been cleared! + Chromium浏览器的Cookies清理完成! + + + + Apt cache had been cleared! + Apt缓存清理完成! + + + + Cleaning up Apt cache: + 正在清理Apt缓存: + + + + Software Center cache had been cleared! + 软件中心缓存清理完成! + + + + Cleaning up Software Center cache: + 正在清理软件中心缓存: + + + + Ready to Cleanup...... + 准备清理...... + + + + HomePage + + + Boot Manager + 启动项管理 + + + Camera + 摄像头 + + + + Current Version Number + 当前版本号 + + + + Update to the lastest version, make it work better + 更新至最新版本,使软件更好用 + + + + updating on the backend + 正在后台升级 + + + + Upgrade is complete + 升级完成 + + + + Updating on the backend + 正在后台升级 + + + + Common toolbox + 工具箱 + + + + Fast and practical, making the system more personalized + 更快更好,让系统更具个性化 + + + + More + 更多 + + + + IconWidget + + + Icon theme + 图标主题 + + + + Computer + 计算机 + + + + Home Folder + 用户主目录 + + + + Network + 网络 + + + + Trash + 回收站 + + + + Mounted Volumes + 挂载卷 + + + + InfoActionWidget + + + Understand hardware information, provide more convenient channel to obtain hardware information + 了解电脑硬件详细信息,为用户提供更加方便的获取硬件信息渠道 + + + + InfoWidget + + + Computer + 电脑概述 + + + + Desktop + 桌面环境 + + + + CPU + 处理器 + + + + Memory + 内存 + + + + Motherboard + 主板 + + + + HD + 硬盘 + + + + NIC + 网卡 + + + + VGA + 显卡 + + + + Audio + 声卡 + + + + CD-ROM + 光驱 + + + + Battery + 电池 + + + + Device Driver + 设备驱动 + + + + Sensor + 硬件传感 + + + + ItemCard + + + Form + + + + + + KylinFontDialog + + + Current Font + 当前字体 + + + + Font + 字体 + + + + Style + 风格 + + + + Size + 大小 + + + + View + 视图 + + + + OK + 确定 + + + + Cancel + 取消 + + + + Tips + 提示 + + + + You haven't change the font, please choose the font! + 您没有更改字体,请选择需要更改的字体! + + + + Font Dialog + 字体对话框 + + + + KylinMenu + + + Check and update + 检查更新 + + + + Forum Help + 论坛求助 + + + + Feedback + 问题反馈 + + + + About us + 关于我们 + + + + KylinSwitcher + + + ON + 已开启 + + + + OFF + 已关闭 + + + + LauncherWidget + + + Launcher icon size + 启动器图标尺寸 + + + + Launcher hide mode + 启动器自动隐藏 + + + + Display desktop icon + 显示桌面图标 + + + + Launcher Transparency + 启动器透明度 + + + + Icon Background + 图标背景 + + + + Top panel icon size + 顶部面板图标大小 + + + + Top panel auto hide + 顶部面板自动隐藏 + + + + Bottom panel icon size + 底部面板图标大小 + + + + Bottom panel auto hide + 底部面板自动隐藏 + + + + Launcher position + 启动器位置 + + + + LoginWidget + + + Login Kylin Account + 登录麒麟帐号 + + + + Logout + 注销 + + + + MainWindow + + + Kylin Assistant + 麒麟助手 + + + + Youker Assistant + 优客助手 + + + + MemoryWidget + + + Memory Info + 内存条信息 + + + + Memory Info %1 + 内存信息 %1 + + + + MonitorWidget + + + Monitor Info + 显示器和显卡信息 + + + + Monitor Info %1 + 显示器和显卡信息 %1 + + + + MouseWidget + + + Mouse Pointer Theme + 鼠标指针主题 + + + + Cursor Pointer Size + 光标指针大小 + + + + Small Size + 小号 + + + + Big Size + 大号 + + + + NautilusWidget + + + Display entry location + 路径输入框取代路径栏 + + + + Automatically mount media + 自动挂载媒体 + + + + Automatically open a folder + 自动打开文件夹 + + + + Prompt autorun programs + 提示自动运行的程序 + + + + Thumbnail icon size (pixels) + 缩略图图标尺寸(像素) + + + + Thumbnail cache time (days) + 缩略图缓存时间(天数) + + + + Maximum thumbnail cache size (MB) + 最大缩略图缓存尺寸(MB) + + + + NicWidget + + + NIC Info + 网卡信息 + + + + NIC Info %1 + 网卡信息 %1 + + + + NormalCard + + + Form + + + + + PanelWidget + + + Dash background blur type + 搜索框背景模糊类型 + + + + Panel Transparency + 面板透明度 + + + + Date & time format + 日期时间格式 + + + + Display seconds + 显示秒数 + + + + Display week + 显示星期 + + + + Display the date + 显示日期 + + + + Display battery icon + 显示电池图标 + + + + Display battery percentage + 显示电池百分比 + + + + Display battery remaining time + 显示电池电量时间 + + + + Smart blur + 活动模糊 + + + + Static blur + 静态模糊 + + + + Clear + 非模糊 + + + + Show applications + 显示应用程序 + + + + Show system + 显示系统 + + + + Show places + 显示位置 + + + + Show icon + 显示图标 + + + + QObject + + + kylin-assistant had already running! + 麒麟助手运行中 + + + + QUIBO + + + Form + + + + + SensorWieget + + + Hardware sensor information + 硬件传感检测信息 + + + + SettingAction + + + Back + 返回 + + + + Choose the theme what you want + 选择您需要的主题 + + + + Set the desktop icon theme and the visibility of desktop icons + 设置桌面图标主题和桌面图标的可见性 + + + + Set the sound theme you want + 设置您需要的声音主题 + + + + Replace the theme and size of the mouse pointer, and theme change need to restart system + 更换鼠标指针主题和大小,主题更改需要重启系统才能生效 + + + + Setting the panel mode of auto hide and icon size + 设置面板自动隐藏模式和面板图标大小 + + + + Setting the Launcher display mode, Icon size + 设置启动器的显示模式、图标尺寸 + + + + Manage display of the start menu + 管理启动菜单的显示 + + + + Manage Dash and Panel menu settings + 管理Dash搜索和面板菜单的设置 + + + + Window Manager settings + 窗口管理器设置 + + + + According to personal preferences to set the system default font, click the 'Restore' button, can be restored to the state before the font settings + 根据个人喜好设置系统默认字体,单击"恢复默认"按钮,可以将对应的字体恢复到设置前状态 + + + + Setting the relevant properties of your touchpad,make the operation more convenient + 通过调整您触摸板的相关设置,使操作更加便捷 + + + + Monitor Check + 坏点检测 + + + + Save energy to let the computer longer standby time + 节省电量,让电脑待机时间更长 + + + + Manage the Caja file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked + 管理Caja文件管理器。注意:如果缩略图缓存时间或尺寸被设置为-1,缩略图将不会被清理 + + + + Manage the Nautilus file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked + 管理Nautilus文件管理器。注意:如果缩略图缓存时间或尺寸被设置为-1,缩略图将不会被清理 + + + + SettingActionWidget + + + You can perform a full range of customized systems based on personal preferences + 您可以根据个人喜好对系统进行全方位的定制 + + + + SettingWidget + + + Personalize + 个性化 + + + + ThemeSetting + 主题设置 + + + + IconSetting + 图标设置 + + + + MousePointer + 鼠标设置 + + + + SoundEffect + 声音效果 + + + + Desktop + 桌面 + + + + Panel + 面板 + + + + StartMenu + 启动菜单 + + + + Custom Launcher + 自定义启动器 + + + + Dash & Panel + 搜索和面板 + + + + Window + 窗口 + + + + Font + 字体 + + + + FontSetting + 字体设置 + + + + Sys options + 系统选项 + + + + Touchpad + 触摸板 + + + + Dead pixel check + 坏点检测 + + + + Energy saving + 省电设置 + + + + Others + 其他 + + + + File manager + 文件管理器 + + + + ShredDialog + + + + Shred Manager + 文件粉碎机 + + + + + + No select any file which need to be shredded + 没有选择需要粉碎的文件 + + + + Shred File + 粉碎文件 + + + + Deselect + 取消粉碎 + + + + Allfile(*) + 所有文件(*) + + + + Select file! + 选择文件! + + + + Shred successfully! + 粉碎成功! + + + + Shred failed! + 粉碎失败! + + + + ShredManager + + + Shred Manager + 文件粉碎机 + + + + Delete files makes it unable to recover + 彻底删除文件使其无法恢复 + + + + SkinCenter + + + + Skin Setting + 皮肤设置 + + + + Default + 默认皮肤 + + + + Custom + 自定义 + + + + Open File + 打开文件 + + + + Files(*.png *.jpg) + 文件(*.png *.jpg) + + + + SystemWidget + + + Computer Base Info + 电脑概述 + + + + + Minutes + 分钟 + + + + Hours + 小时 + + + + ThemeWidget + + + Please choose theme which you need + 选择您需要的主题 + + + + TipDialog + + + OK + 确定 + + + + Tip Dialog + 提示框 + + + + ToolWidget + + + Home + 麒麟首页 + + + + + Cleanup + 系统清理 + + + + + Sysinfo + 系统信息 + + + + KylinHome + 麒麟首页 + + + + Feature + 系统美化 + + + + + Toolkits + 功能大全 + + + + TouchpadWidget + + + Enable touchpad + 启用/禁用触摸板 + + + + Enable horizontal scrolling + 触摸板横向滚动 + + + + Scrollbar type + 滚动条类型 + + + + Touchpad scrolling mode + 触摸板滚动模式 + + + + Features Type + 特色类型 + + + + Standard Type + 标准类型 + + + + Disabled + 禁用 + + + + Edge Scrolling + 边界滚动 + + + + Two-finger Scrolling + 双指滚动 + + + + UpgradeDialog + + + check and update + 检查更新 + + + + + Current verison: + 当前版本: + + + + Official version + 正式版 + + + + An error occurred! + 出错了!无法升级 + + + + Network or local sources anomaly + 网络或源地址连接失败,升级未成功 + + + + + Testing network and local sources... + 正在检查网络和本地源... + + + + Retry + 重试 + + + + Finish + 完成 + + + + Upgrade + 升级 + + + + + Start to update the local sources + 开始更新本地源 + + + + Start to download + 开始下载 + + + + Updating local sources... + 正在更新本地源... + + + + Kylin Assistant is the latest version + 麒麟助手已经是最新的版本 + + + + Start to install + 开始安装 + + + + Download completely + 下载完成 + + + + Local sources updated + 源更新完毕 + + + + Found a new version + 发现新版本 + + + + New version: + 新版本号: + + + + you can visit the<a style='color: #3f96e4;' href = http://www.ubuntukylin.com> UK official website</a> to download the lastest deb package + 您可以访问 <a style='color: #3f96e4;' href = http://www.ubuntukylin.com> UK 官网</a> 下载最新的deb包 + + + + + Not found + 没有发现新版本 + + + + Upgrading the main program... + 正在升级主程序... + + + + Start to upgrade the main program + 开始升级主程序 + + + + VoiceWidget + + + Sound theme + 声音主题 + + + + Login tone + 登录提示音 + + + + Event sounds + 事件声音 + + + + Input feedback sounds + 输入反馈声音 + + + + WindowWidget + + + Arrangement of buttons on the titlebar + 标题栏按钮布局 + + + + Menu with icons + 菜单项旁显示图标 + + + + Titlebar mouse wheel action + 标题栏鼠标滚轮动作 + + + + Titlebar double-click action + 标题栏双击动作 + + + + Titlebar middle-click action + 标题栏中键动作 + + + + Titlebar right-click action + 标题栏右键动作 + + + + Left + 左边 + + + + Right + 右边 + + + diff --git a/mainui/upgradedialog.cpp b/mainui/upgradedialog.cpp new file mode 100644 index 0000000..c2a75f8 --- /dev/null +++ b/mainui/upgradedialog.cpp @@ -0,0 +1,505 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "QDesktopWidget" + +#include "upgradedialog.h" +#include "../component/loadinglabel.h" +#include "../component/utils.h" +#include +#include +//20161228 +UpgradeDialog::UpgradeDialog(QWidget *parent, /*const QString &version, */QString skin, QString arch, QString os) : + QDialog(parent) +{ + this->setWindowFlags(Qt::FramelessWindowHint |Qt::WindowStaysOnTopHint); + this->setFixedSize(334, 470); + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); + + isBusy = false; + upgradeOver = false; +// cur_version = version; + cur_version = VERSION; + + baseWidget = new QWidget(this); + baseWidget->setGeometry(QRect(0, 0, 334, 191)); + baseWidget->setAutoFillBackground(true); + QPalette palette; + palette.setBrush(QPalette::Background, QBrush(QPixmap(skin))); + baseWidget->setPalette(palette); + + close_btn = new SystemButton(baseWidget); + close_btn->setFocusPolicy(Qt::NoFocus); + close_btn->loadPixmap(":/sys/res/sysBtn/close_button.png"); + if (arch == "aarch64" || os == "Kylin"|| os == "YHKylin") {//20161228 + close_btn->move(334-36, 0); + } + else { + close_btn->move(0, 0); + } + + nameLabel = new QLabel(baseWidget); + nameLabel->setGeometry(QRect(37, 0, 260, 30)); + nameLabel->setStyleSheet("QLabel{color:#ffffff;font-family: 方正黑体_GBK;font-size: 12px;text-align: center;font-weight:bold;}"); + nameLabel->setAlignment(Qt::AlignCenter); + nameLabel->setText(tr("check and update")); + +// msg_label = new QLabel(baseWidget); +// msg_label->setGeometry(QRect(10, 40, 324, 20)); +// msg_label->setStyleSheet("QLabel{color:#FF0000;font-family: 方正黑体_GBK;font-size: 14px;text-align: center;}"); +// msg_label->setAlignment(Qt::AlignCenter); +// msg_label->setText(tr("Is working, please wait a moment.")); +// msg_label->hide(); + + net_icon_label = new QLabel(this); + net_icon_label->setGeometry(QRect(76, 64, 182, 181)); + net_icon_label->setStyleSheet("QLabel{background-image:url(':/res/no-net.png')}"); + net_icon_label->hide(); + + normal_icon_label = new QLabel(this); + normal_icon_label->setGeometry(QRect(76, 64, 182, 181)); + normal_icon_label->setStyleSheet("QLabel{background-image:url(':/res/upgrade-normal.png');color:#ffffff;font-family: 方正黑体_GBK;font-size: 22px;text-align: center;}"); + normal_icon_label->setAlignment(Qt::AlignCenter); + normal_icon_label->hide(); + + ok_icon_label = new QLabel(this); + ok_icon_label->setGeometry(QRect(76, 64, 182, 181)); + ok_icon_label->setStyleSheet("QLabel{background-image:url(':/res/upgrade-ok.png')}"); + ok_icon_label->hide(); + + work_loading_label = new LoadingLabel(this, "working"); + work_loading_label->setGeometry(QRect(76, 64, 182, 181)); + work_loading_label->show(); + + upgrade_loading_label = new LoadingLabel(this, "upgrading"); + upgrade_loading_label->setGeometry(QRect(76, 64, 182, 181)); + upgrade_loading_label->hide(); + +// movie_label = new QLabel(this); +// movie_label->setGeometry(QRect(76, 91, 182, 181)); +// movie = new QMovie("://res/move.gif"); +// movie_label->setMovie(movie); +// timer = new QTimer(this); + + version_label = new QLabel(this); + version_label->setObjectName("smallgrayLabel"); + version_label->setGeometry(QRect(10, 440, 324, 20)); + version_label->setText(tr("Current verison:") + VERSION); + doing_label = new QLabel(this); + doing_label->setWordWrap(true);//QLabel自动换行 + doing_label->setStyleSheet("QLabel{color:#000000;font-family: 方正黑体_GBK;font-size: 22px;text-align: center;}"); + doing_label->setAlignment(Qt::AlignCenter); + doing_label->setGeometry(QRect(10, 264, 324, 30)); + + error_label = new QLabel(this); + error_label->setGeometry(QRect(10, 264, 324, 30)); + error_label->setWordWrap(true);//QLabel自动换行 + error_label->setStyleSheet("QLabel{color:#000000;font-family: 方正黑体_GBK;font-size: 22px;text-align: center;}"); + error_label->setAlignment(Qt::AlignCenter); + error_label->hide(); + tip_label = new QLabel(this); + tip_label->setGeometry(QRect(10, 294, 324, 30)); + tip_label->setWordWrap(true);//QLabel自动换行 + tip_label->setStyleSheet("QLabel{color:#999999;font-family: 方正黑体_GBK;font-size: 12px;text-align: center;}"); + tip_label->setAlignment(Qt::AlignCenter); + tip_label->hide(); + + visit_label = new QLabel(this); + visit_label->setGeometry(QRect(10, 294, 324, 30)); + visit_label->setWordWrap(true);//QLabel自动换行 + visit_label->setStyleSheet("QLabel{color:#999999;font-family: 方正黑体_GBK;font-size: 12px;text-align: center;}"); + visit_label->setAlignment(Qt::AlignCenter); +// visit_label->hide(); + + new_widget = new QWidget(this); + new_widget->setGeometry(QRect(17, 264, 300, 80)); + new_widget->setStyleSheet("QWidget{background:transparent; border:1px solid #3f96e4;}"); + new_widget->hide(); + official_label = new QLabel(new_widget); + official_label->setWordWrap(true);//QLabel自动换行 + official_label->setStyleSheet("QLabel{border:none;color:#000000;font-family: 方正黑体_GBK;font-size: 13px;text-align: center;}");//background: transparent; + official_label->setAlignment(Qt::AlignCenter); + official_label->setGeometry(QRect(0, 15, 60, 30)); + official_label->setText(tr("Official version")); + hook_label = new QLabel(new_widget); +// hook_label->setGeometry(QRect(18, 32, 23, 16)); + hook_label->setGeometry(QRect(18, 50, 23, 16)); + hook_label->setStyleSheet("QLabel{background: transparent;border:none;background-image:url(':/res/hook.png')}"); + + vline = new QLabel(new_widget); + vline->setGeometry(QRect(60, 0, 1, 80)); + vline->setStyleSheet("QLabel{background-color:#3f96e4;}"); +// new_label = new QLabel(this); + new_label = new QLabel(new_widget); + new_label->setWordWrap(true);//QLabel自动换行 + new_label->setStyleSheet("QLabel{border:none;color:#000000;font-family: 方正黑体_GBK;font-size: 16px;text-align: left;}");//background: transparent; + new_label->setGeometry(QRect(70, 10, 220, 30)); + new_label->setText(tr("New version:")); +// new_label->setGeometry(QRect(10, 264, 324, 20)); +// new_label->hide(); + new_num_label = new QLabel(new_widget); + new_num_label->setWordWrap(true);//QLabel自动换行 +// new_num_label->setObjectName("smallgrayLabel"); + new_num_label->setStyleSheet("QLabel{border:none;color:#000000;font-family: 方正黑体_GBK;font-size: 16px;text-align: left;}");//background: transparent; + new_num_label->setGeometry(QRect(70, 40, 220, 30)); + + error_label->setText(tr("An error occurred!")); + tip_label->setText(tr("Network or local sources anomaly")); + doing_label->setText(tr("Testing network and local sources...")); +// visit_label->setText(tr("you can visit ") + QString::fromLocal8Bit(" UK official website ") + tr("to download the lastest deb package")); +// visit_label->setText(tr("you can visit ") + tr(" UK official website ") + tr("to download the lastest deb package")); + visit_label->setText(tr("you can visit the UK official website to download the lastest deb package")); + retryBtn = new QPushButton(this); + retryBtn->setFocusPolicy(Qt::NoFocus); + retryBtn->setStyleSheet("QPushButton{background-image:url('://res/retry.png');border:0px;color:#ffffff;font-family: 方正黑体_GBK;font-size: 30px;}QPushButton:hover{background:url('://res/retry-hover.png');}QPushButton:pressed{background:url('://res/retry-press.png');}"); + retryBtn->hide(); + retryBtn->setText(tr("Retry")); + retryBtn->setGeometry(QRect(74, 350, 186, 56)); + + progressbar = new QProgressBar(this); + progressbar->setValue(0); + progressbar->setGeometry(QRect(30, 340, 284, 30)); + progressbar->hide(); + progressbar->setStyleSheet("QProgressBar{background-color:#ffffff;border:1px solid #aaaaaa;border-radius:0px;color:#666666;font-family: 方正黑体_GBK;text-align:center;}" + "QProgressBar:chunk{background-color:#b1dcff;}"); + okBtn = new QPushButton(this); + okBtn->setFocusPolicy(Qt::NoFocus); + okBtn->setStyleSheet("QPushButton{background-image:url('://res/retry.png');border:0px;color:#ffffff;font-family: 方正黑体_GBK;font-size: 30px;}QPushButton:hover{background:url('://res/retry-hover.png');}QPushButton:pressed{background:url('://res/retry-press.png');}"); + okBtn->hide(); + okBtn->setText(tr("Finish")); + okBtn->setGeometry(QRect(74, 350, 186, 56)); + + upgradeBtn = new QPushButton(this); + upgradeBtn->setFocusPolicy(Qt::NoFocus); + upgradeBtn->setGeometry(QRect(234, 437, 91, 25)); + upgradeBtn->setObjectName("blackButton"); + upgradeBtn->setText(tr("Upgrade")); + upgradeBtn->hide(); + + splitlabel = new QLabel(this); + splitlabel->setGeometry(QRect(0, 430, 334, 1)); + splitlabel->setFixedHeight(1); + splitlabel->setStyleSheet("QLabel{background:#e0e0e0;}"); + this->initConnect(); +} + +UpgradeDialog::~UpgradeDialog() +{ +// if(movie != NULL) { +// delete movie; +// movie = NULL; +// } +// if (timer != NULL) { +// disconnect(timer,SIGNAL(timeout()),this,SLOT(slotDisappearTip())); +// if(timer->isActive()) { +// timer->stop(); +// } +// delete timer; +// timer = NULL; +// } +} + +void UpgradeDialog::initConnect() +{ + connect(close_btn, SIGNAL(clicked()), this, SLOT(onCloseBtnClicked())); + connect(retryBtn, SIGNAL(clicked()), this, SLOT(onRetryBtnClicked())); + connect(upgradeBtn, SIGNAL(clicked()), this, SLOT(onUpgradeBtnClicked())); + connect(okBtn, SIGNAL(clicked()), this, SIGNAL(close_signal())); +// connect(timer, SIGNAL(timeout()), this, SLOT(slotDisappearTip())); + connect(visit_label,SIGNAL(linkActivated(QString)),this,SLOT(openUrl(QString))); +} + +//void UpgradeDialog::slotDisappearTip() +//{ +// msg_label->hide(); +//} + +void UpgradeDialog::openUrl(QString url) +{ + QDesktopServices::openUrl(QUrl(url)); +} + +void UpgradeDialog::startAccessData() +{ + QTimer::singleShot(100, this, SLOT(checkLastestVersion())); +} + +void UpgradeDialog::showErrorComponents() +{ + error_label->show(); + tip_label->show(); + retryBtn->show(); + doing_label->hide(); + visit_label->hide(); +} + +void UpgradeDialog::showUpdateSourceComponents() +{ + doing_label->setText(tr("Start to update the local sources")); + visit_label->show(); + progressbar->setValue(0); + progressbar->show(); +} + +void UpgradeDialog::checkLastestVersion() +{ + //check source list valid or not + this->isBusy = true; + work_loading_label->startLoading(); +// movie->start(); + sessionProxy->start_check_source_useable_qt(); +} + +void UpgradeDialog::onRetryBtnClicked() +{ + this->isBusy = true; + net_icon_label->hide(); + error_label->hide(); + tip_label->hide(); + retryBtn->hide(); + work_loading_label->show(); + work_loading_label->startLoading(); + doing_label->setText(tr("Testing network and local sources...")); + doing_label->show(); + visit_label->show(); +// movie_label->show(); +// movie->start(); + sessionProxy->start_check_source_useable_qt(); +} + +void UpgradeDialog::receiveCheckResultSignal(bool result) +{ + if(result == false) { + this->isBusy = false; + work_loading_label->stopLoading(); + work_loading_label->hide(); +// movie->stop(); +// movie_label->hide(); + net_icon_label->show(); + this->showErrorComponents(); + } + else { + this->isBusy = true; + this->showUpdateSourceComponents(); + systemProxy->update_source(); + + //test by kobe +// progressbar->hide(); +// visit_label->hide(); +// work_loading_label->stopLoading(); +// work_loading_label->hide(); +// normal_icon_label->show(); +// doing_label->setText(tr("Local sources updated")); +// QStringList version_list = sessionProxy->checkNewVersion(); +// qDebug() << version_list;//("1.2.0-0ubuntu1", "1.2.0-0ubuntu1", "1.3.1-0ubuntu1", "1") +// if(version_list.length() == 4) { +// if(version_list.at(3) == "1") { +// normal_icon_label->setText(tr("Found a new version")); +// new_widget->show(); +// this->cur_version = version_list.at(2); +// new_num_label->setText(this->cur_version); +// upgradeBtn->show(); +// doing_label->hide(); +// } +// else { +// normal_icon_label->setText(tr("Not found")); +// } +// } + } +} + +void UpgradeDialog::receiveFetchSignal(QString msg_type, QStringList msg) +{ + if(msg_type == "down_start") + { + if( msg.length() == 3 && msg.at(0) == "youker-assistant" && msg.at(2) == "install") { + if(msg.at(1) == "0") { + doing_label->setText(tr("Start to download")); + } + } + else if( msg.length() == 3 && msg.at(0) == "#update" && msg.at(1) == "0" && msg.at(2) == "update") { + doing_label->setText(tr("Start to update the local sources")); + } + } + else if(msg_type == "down_stop") + { + if( msg.length() == 3 && msg.at(0) == "youker-assistant" && msg.at(2) == "install") { + if(msg.at(1) == "0") { + doing_label->setText(tr("Download completely")); + } + } + else if( msg.length() == 3 && msg.at(0) == "#update" && msg.at(1) == "200" && msg.at(2) == "update") { + progressbar->hide(); + visit_label->hide(); +// movie->stop(); +// movie_label->hide(); + work_loading_label->stopLoading(); + work_loading_label->hide(); + normal_icon_label->show(); + doing_label->setText(tr("Local sources updated")); + QStringList version_list = sessionProxy->checkNewVersion(); +// qDebug() << version_list << "=====" << version_list.length();//("1.2.0-0ubuntu1", "1.2.0-0ubuntu1", "1.3.1-0ubuntu1", "1") + if(version_list.length() == 1) { +// version_label->setText(version_list.at(0)); + normal_icon_label->setText(tr("Not found")); + } + else if(version_list.length() == 4) { + // version_label->setText(version_list.at(2)); + if(version_list.at(3) == "1") { + normal_icon_label->setText(tr("Found a new version")); +// new_label->show(); + new_widget->show(); + this->cur_version = version_list.at(2); + new_num_label->setText(this->cur_version); + upgradeBtn->show(); + doing_label->hide(); + } + else { + normal_icon_label->setText(tr("Not found")); + } + } + this->isBusy = false; + } + } + else if(msg_type == "down_fetch" || msg_type == "down_done") { + if(msg.length() == 3 && msg.at(0) == "#update" && msg.at(2) == "update") { + doing_label->setText(tr("Updating local sources...") + QString::number(int(msg.at(1).toDouble())) + "%"); + progressbar->setValue(msg.at(1).toFloat()); + } + } +} + +void UpgradeDialog::receiveAptSignal(QString msg_type, QStringList msg) +{ + if(msg_type == "apt_finish") + { + if( msg.length() == 3 && msg.at(0) == "youker-assistant" && msg.at(1) == "200" && msg.at(2) == "install") { + this->isBusy = false; + this->upgradeOver = true; + ok_icon_label->show(); + okBtn->show(); + doing_label->setText(tr("Kylin Assistant is the latest version")); + version_label->setText(tr("Current verison:") + this->cur_version); + upgrade_loading_label->stopLoading(); + upgrade_loading_label->hide(); + progressbar->setValue(100); + progressbar->hide(); + emit this->showBackendBtnSignal(true); +// visit_label->hide(); + } + } + else if(msg_type == "apt_start") + { + if( msg.length() == 3 && msg.at(0) == "youker-assistant" && msg.at(1) == "0" && msg.at(2) == "install") { + doing_label->setText(tr("Start to install")); + progressbar->setValue(0); + } + } + else if(msg_type == "apt_pulse") + { + if( msg.length() == 4){ + //installing + doing_label->setText(tr("Upgrading the main program...") + QString::number(int(msg.at(1).toDouble())) + "%"); + progressbar->setValue(msg.at(1).toFloat()); + } + } + else { + qDebug() << "apt->" << msg_type; + qDebug() << msg; + } +} + +void UpgradeDialog::resetTitleSkin(QString skin) +{ + QPalette palette; + palette.setBrush(QPalette::Background, QBrush(QPixmap(skin))); + baseWidget->setPalette(palette); +} + +void UpgradeDialog::resetVersionNumber(QStringList version_list) +{ + qDebug() << "new version->" << version_list; +} + +void UpgradeDialog::onCloseBtnClicked() +{ +// if (timer->isActive()) +// timer->stop(); + if(this->isBusy) { + emit this->showBackendBtnSignal(false); + } + else if(this->upgradeOver) { + emit this->close_signal(); + } + this->close(); +// if(this->isBusy) { +// msg_label->show(); +// timer->start(3000); +// } +// else { +// if (timer->isActive()) +// timer->stop(); +// this->close(); +// } +} + +void UpgradeDialog::onUpgradeBtnClicked() +{ + this->isBusy = true; +// new_label->hide(); + new_widget->hide(); + upgradeBtn->hide(); + normal_icon_label->hide(); + upgrade_loading_label->show(); + upgrade_loading_label->startLoading(); + doing_label->show(); + doing_label->setText(tr("Start to upgrade the main program")); + visit_label->show(); + progressbar->setValue(0); + progressbar->show(); +// net_icon_label->hide(); +// movie_label->show(); +// movie->start(); + systemProxy->update_myself(); +} + +void UpgradeDialog::mousePressEvent(QMouseEvent *event) +{ + if(event->button() == Qt::LeftButton) + { + mouse_press = true; + drag_pos = event->globalPos() - this->frameGeometry().topLeft(); + event->accept(); + } +} + +void UpgradeDialog::mouseReleaseEvent(QMouseEvent *) +{ + mouse_press = false; +} + +void UpgradeDialog::mouseMoveEvent(QMouseEvent *event) +{ + if(mouse_press) + { + QPoint move_pos = event->globalPos(); + move(move_pos - drag_pos); + event->accept(); + } +} diff --git a/mainui/upgradedialog.h b/mainui/upgradedialog.h new file mode 100644 index 0000000..925b761 --- /dev/null +++ b/mainui/upgradedialog.h @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef UPGRADEDIALOG_H +#define UPGRADEDIALOG_H + +#include +#include "../component/kylintitlebar.h" +#include +#include +#include "../dbusproxy/youkersystemdbus.h" +#include "../dbusproxy/youkersessiondbus.h" + +//class QMovie; +//class QTimer; +class LoadingLabel; + +class UpgradeDialog : public QDialog +{ + Q_OBJECT + +public: + explicit UpgradeDialog(QWidget *parent = 0, /*const QString &version="", */QString skin = ":/background/res/skin/1.png", QString arch = "", QString os = "");//20161228 + ~UpgradeDialog(); + void initConnect(); + void resetTitleSkin(QString skin); + void switchPage(bool flag); + void setSystemDbusProxy(SystemDispatcher *dispatcher) { systemProxy = dispatcher;} + void setSessionDbusProxy(SessionDispatcher *dispatcher) { sessionProxy = dispatcher;} + void resetVersionNumber(QStringList version_list); + void startAccessData(); + void showErrorComponents(); + void showUpdateSourceComponents(); + +public slots: + void onCloseBtnClicked(); + void onUpgradeBtnClicked(); + void receiveFetchSignal(QString msg_type, QStringList msg); + void receiveAptSignal(QString msg_type, QStringList msg); + void checkLastestVersion(); + void receiveCheckResultSignal(bool result); + void onRetryBtnClicked(); +// void slotDisappearTip(); + void openUrl(QString url); + +signals: + void close_signal(); + void showBackendBtnSignal(bool flag); + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + +private: + QPoint drag_pos; //移动的距离 + bool mouse_press; //按下鼠标左键 + QWidget *baseWidget; + SystemButton *close_btn; + QProgressBar *progressbar; + QLabel *visit_label; + QLabel *net_icon_label; + QLabel *normal_icon_label; + QLabel *ok_icon_label; + LoadingLabel *work_loading_label; + LoadingLabel *upgrade_loading_label; + QLabel *nameLabel; + QLabel *doing_label; + QLabel *error_label; + QLabel *tip_label; + QLabel *splitlabel; + QLabel *version_label; + QWidget *new_widget; + QLabel *hook_label; + QLabel *official_label; + QLabel *vline; + QLabel *new_label; + QLabel *new_num_label; + QPushButton *retryBtn; + QPushButton *upgradeBtn; + QPushButton *okBtn; + SystemDispatcher *systemProxy; + SessionDispatcher *sessionProxy; + bool isBusy; + bool upgradeOver; +// QMovie *movie; +// QLabel *movie_label; +// QTimer *timer; +// QLabel *msg_label; + QString cur_version; +}; + +#endif // UPGRADEDIALOG_H diff --git a/man/youker-assistant.1 b/man/youker-assistant.1 new file mode 100644 index 0000000..fbff8b0 --- /dev/null +++ b/man/youker-assistant.1 @@ -0,0 +1,19 @@ +.\" Hey, EMACS: -*- nroff -*- +.TH YOUKER-ASSISTANT 1 "19 AUG 2013" +.\" Please adjust this date whenever revising the manpage. +.SH NAME +youker-assistant \- launch youker-assistant frontends +.SH SYNOPSIS +.B youker-assistant +.SH DESCRIPTION +.B youker-assistant +It is used to launch frontends. +.PP +.SH SEE ALSO +.BR youker-assistant (1), +.br +.SH AUTHOR +youker-assistant was written by Kobe . +.PP +This manual page was written by shijing . + diff --git a/man/youkersession.1 b/man/youkersession.1 new file mode 100644 index 0000000..de286a3 --- /dev/null +++ b/man/youkersession.1 @@ -0,0 +1,19 @@ +.\" Hey, EMACS: -*- nroff -*- +.TH YOUKER-SESSION 1 "19 AUG 2013" +.\" Please adjust this date whenever revising the manpage. +.SH NAME +youker-session \- launch backends +.SH SYNOPSIS +.B youker-session +.SH DESCRIPTION +.B youker-session +It is used to launch backends. +.PP +.SH SEE ALSO +.BR youker-session (1), +.br +.SH AUTHOR +youker-session was written by Kobe . +.PP +This manual page was written by shijing . + diff --git a/man/youkersystem.1 b/man/youkersystem.1 new file mode 100644 index 0000000..4e38c0b --- /dev/null +++ b/man/youkersystem.1 @@ -0,0 +1,19 @@ +.\" Hey, EMACS: -*- nroff -*- +.TH YOUKER-SYSTEM 1 "19 AUG 2013" +.\" Please adjust this date whenever revising the manpage. +.SH NAME +youker-system \- launch backends +.SH SYNOPSIS +.B youker-system +.SH DESCRIPTION +.B youker-system +It is used to launch backends. Need to use root privilige. +.PP +.SH SEE ALSO +.BR youker-system (1), +.br +.SH AUTHOR +youker-system was written by Kobe . +.PP +This manual page was written by shijing . + diff --git a/po/python/youker-assistant.mo b/po/python/youker-assistant.mo new file mode 100644 index 0000000..b6adab6 Binary files /dev/null and b/po/python/youker-assistant.mo differ diff --git a/po/python/youker-assistant.po b/po/python/youker-assistant.po new file mode 100644 index 0000000..b64ae30 --- /dev/null +++ b/po/python/youker-assistant.po @@ -0,0 +1,28 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-08 02:56+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: cpuinfo.py:553 +#, python-format +msgid "%d cores" +msgstr "%d 核" + +#: cpuinfo.py:560 +#, python-format +msgid "%s v1.0 64 bits" +msgstr "%s v1.0 64 位" diff --git a/po/python/youker-assistant.pot b/po/python/youker-assistant.pot new file mode 100644 index 0000000..011a63e --- /dev/null +++ b/po/python/youker-assistant.pot @@ -0,0 +1,28 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-08 02:56+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: cpuinfo.py:553 +#, python-format +msgid "%d cores" +msgstr "" + +#: cpuinfo.py:560 +#, python-format +msgid "%s v1.0 64 bits" +msgstr "" diff --git a/po/youker-assistant.pot b/po/youker-assistant.pot new file mode 100644 index 0000000..822b5ee --- /dev/null +++ b/po/youker-assistant.pot @@ -0,0 +1,2134 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Language: es_ES\n" +"X-Source-Language: C\n" +"X-Qt-Contexts: true\n" + +#: ../aboutdialog.ui:26 ../aboutdialog.ui:42 +msgctxt "AboutDialog|" +msgid "About" +msgstr "" + +#: ../aboutdialog.ui:70 ../aboutdialog.ui:165 +msgctxt "AboutDialog|" +msgid "Youker Assistant" +msgstr "" + +#: ../aboutdialog.ui:105 +msgctxt "AboutDialog|" +msgid "" +"\n" +"\n" +"

Youker Assistant is a powerful system " +"supporting software which is developed by Ubuntu Kylin team. Mainly for the " +"naive user, it can help users manage the system. At present, It provides " +"system junk scanning and cleaning, viewing the system hardware and software " +"information , system customization, task manager, monitoring ball, and some " +"other functions.

\n" +"

The software is still under development. " +"Please visit www.ubuntukylin.com for more information. Welcome everyone to " +"join with us. youker-assistant Homepage: " +"https://launchpad.net/youker-assistant.

" +msgstr "" + +#: ../aboutdialog.ui:116 +msgctxt "AboutDialog|" +msgid "Contributor" +msgstr "" + +#: ../aboutdialog.ui:131 +msgctxt "AboutDialog|" +msgid "" +"\n" +"\n" +"

Maintainer:

\n" +"

Ubuntu Kylin Team " +"<ubuntukylin-members@list.launchpad.net>

" +msgstr "" + +#: ../aboutdialog.ui:181 +msgctxt "AboutDialog|" +msgid "home page" +msgstr "" + +#: ../aboutdialog.ui:199 +msgctxt "AboutDialog|" +msgid "Close" +msgstr "" + +#: ../../component/alertdialog.ui:14 +msgctxt "AlertDialog|" +msgid "Form" +msgstr "" + +#: ../../setting/animationwidget.cpp:191 +msgctxt "AnimationWidget|" +msgid "Please select a picture as boot animation" +msgstr "" + +#: ../../setting/animationwidget.cpp:192 +msgctxt "AnimationWidget|" +msgid "Custom Picture" +msgstr "" + +#: ../../setting/animationwidget.cpp:193 +msgctxt "AnimationWidget|" +msgid "Optional BootAnimation" +msgstr "" + +#: ../../setting/animationwidget.cpp:194 +msgctxt "AnimationWidget|" +msgid "OK" +msgstr "" + +#: ../../setting/animationwidget.cpp:255 +msgctxt "AnimationWidget|" +msgid "Image Files (*.png *.jpg *.gif)" +msgstr "" + +#: ../../setting/animationwidget.cpp:305 +msgctxt "AnimationWidget|" +msgid "Deleted successfully!" +msgstr "" + +#: ../../setting/animationwidget.cpp:314 +msgctxt "AnimationWidget|" +msgid "This is the using animation!" +msgstr "" + +#: ../../setting/animationwidget.cpp:324 +msgctxt "AnimationWidget|" +msgid "This is the default animation!" +msgstr "" + +#: ../../setting/animationwidget.cpp:334 +msgctxt "AnimationWidget|" +msgid "An unknown error occurred!" +msgstr "" + +#: ../../info/audiowidget.cpp:37 +msgctxt "AudioWidget|" +msgid "Audio Info" +msgstr "" + +#: ../../info/audiowidget.cpp:47 +#, qt-format +msgctxt "AudioWidget|" +msgid "Audio Info %1" +msgstr "" + +#: ../autostartwidget.ui:14 +msgctxt "AutoStartWidget|" +msgid "Form" +msgstr "" + +#: ../autostartwidget.cpp:52 +msgctxt "AutoStartWidget|" +msgid "AutoStart Items:" +msgstr "" + +#: ../autostartwidget.cpp:53 +msgctxt "AutoStartWidget|" +msgid "App" +msgstr "" + +#: ../autostartwidget.cpp:54 +msgctxt "AutoStartWidget|" +msgid "Status" +msgstr "" + +#: ../autostartwidget.cpp:56 +msgctxt "AutoStartWidget|" +msgid "ON Items:" +msgstr "" + +#: ../autostartwidget.cpp:57 +msgctxt "AutoStartWidget|" +msgid "OFF Items:" +msgstr "" + +#: ../autostartwidget.cpp:208 +msgctxt "AutoStartWidget|" +msgid "Auto Start" +msgstr "" + +#: ../../info/batterywidget.cpp:32 +msgctxt "BatteryWidget|" +msgid "Battery Info" +msgstr "" + +#: ../../info/boardwidget.cpp:29 +msgctxt "BoardWidget|" +msgid "Board Info" +msgstr "" + +#: ../boxactionwidget.cpp:70 +msgctxt "BoxActionWidget|" +msgid "" +"Provide a practical and lightweight tool, create fast and convenient " +"experience for you" +msgstr "" + +#: ../boxactionwidget.cpp:71 +msgctxt "BoxActionWidget|" +msgid "More App" +msgstr "" + +#: ../boxwidget.cpp:98 ../boxwidget.cpp:102 +msgctxt "BoxWidget|" +msgid "UbuntuKylin Software Center" +msgstr "" + +#: ../../info/cdrowwidget.cpp:30 +msgctxt "CDRowWidget|" +msgid "CDROM Info" +msgstr "" + +#: ../../cleaner/cacheactionwidget.cpp:72 +msgctxt "CacheActionWidget|" +msgid "Cleaning up the system cache" +msgstr "" + +#: ../../cleaner/cacheactionwidget.cpp:73 +msgctxt "CacheActionWidget|" +msgid "Deep cleaning up the system cache, to save disk space" +msgstr "" + +#: ../cameramanager.cpp:98 +msgctxt "CameraManager|" +msgid "NO found camara" +msgstr "" + +#: ../cameramanager.cpp:99 +msgctxt "CameraManager|" +msgid "An application to take pictures with the device camera." +msgstr "" + +#: ../cameramanager.cpp:100 +msgctxt "CameraManager|" +msgid "" +"Press the [ESC] button to take picture and turn the camera off , the photo " +"saved in home directory by default." +msgstr "" + +#: ../cameramanager.cpp:101 +msgctxt "CameraManager|" +msgid "Open camera" +msgstr "" + +#: ../cameramanager.cpp:102 +msgctxt "CameraManager|" +msgid "View Photos" +msgstr "" + +#: ../cameramanager.cpp:144 +msgctxt "CameraManager|" +msgid "Camera Manager" +msgstr "" + +#: ../../cleaner/cleanlistwidget.ui:14 +msgctxt "CleanListWidget|" +msgid "Form" +msgstr "" + +#: ../../cleaner/cleanlistwidget.cpp:45 +msgctxt "CleanListWidget|" +msgid "Clean Items:" +msgstr "" + +#: ../../component/cleansubgroup.cpp:51 +msgctxt "CleanSubGroup|" +msgid "Custom" +msgstr "" + +#: ../cleaneractionwidget.cpp:142 +msgctxt "CleanerActionWidget|" +msgid "Regular cleaning, let your computer remains the relaxed state" +msgstr "" + +#: ../cleaneractionwidget.cpp:144 +msgctxt "CleanerActionWidget|" +msgid "Start Scan" +msgstr "" + +#: ../cleaneractionwidget.cpp:145 +msgctxt "CleanerActionWidget|" +msgid "Start Cleanup" +msgstr "" + +#: ../cleaneractionwidget.cpp:146 +msgctxt "CleanerActionWidget|" +msgid "Back" +msgstr "" + +#: ../cleaneractionwidget.cpp:147 ../cleaneractionwidget.cpp:239 +msgctxt "CleanerActionWidget|" +msgid "Scaning......" +msgstr "" + +#: ../cleaneractionwidget.cpp:157 +msgctxt "CleanerActionWidget|" +msgid "Clean OK......" +msgstr "" + +#: ../cleaneractionwidget.cpp:164 +msgctxt "CleanerActionWidget|" +msgid "Cleaning: " +msgstr "" + +#: ../cleaneractionwidget.cpp:168 +msgctxt "CleanerActionWidget|" +msgid ", Percent is: " +msgstr "" + +#: ../cleaneractionwidget.cpp:168 +msgctxt "CleanerActionWidget|" +msgid "%, Status is: " +msgstr "" + +#: ../cleaneractionwidget.cpp:176 +msgctxt "CleanerActionWidget|" +msgid "Clean Firefox history......" +msgstr "" + +#: ../cleaneractionwidget.cpp:180 +msgctxt "CleanerActionWidget|" +msgid "Clean Chromium history......" +msgstr "" + +#: ../cleaneractionwidget.cpp:184 +msgctxt "CleanerActionWidget|" +msgid "Clean system history......" +msgstr "" + +#: ../cleaneractionwidget.cpp:189 +msgctxt "CleanerActionWidget|" +msgid "Clean apt......" +msgstr "" + +#: ../cleaneractionwidget.cpp:193 +msgctxt "CleanerActionWidget|" +msgid "Start clean apt......" +msgstr "" + +#: ../cleaneractionwidget.cpp:198 +msgctxt "CleanerActionWidget|" +msgid "Clean Firefox Cookie:" +msgstr "" + +#: ../cleaneractionwidget.cpp:202 +msgctxt "CleanerActionWidget|" +msgid "Clean Chromium Cookie:" +msgstr "" + +#: ../cleaneractionwidget.cpp:211 ../cleaneractionwidget.cpp:269 +msgctxt "CleanerActionWidget|" +msgid " does not exist" +msgstr "" + +#: ../cleaneractionwidget.cpp:215 ../cleaneractionwidget.cpp:264 +msgctxt "CleanerActionWidget|" +msgid "Chromium Browser is running......" +msgstr "" + +#: ../cleaneractionwidget.cpp:223 +msgctxt "CleanerActionWidget|" +msgid "Cache Scan OK......" +msgstr "" + +#: ../cleaneractionwidget.cpp:227 +msgctxt "CleanerActionWidget|" +msgid "Cookies Scan OK......" +msgstr "" + +#: ../cleaneractionwidget.cpp:231 +msgctxt "CleanerActionWidget|" +msgid "History Scan OK......" +msgstr "" + +#: ../cleaneractionwidget.cpp:235 +msgctxt "CleanerActionWidget|" +msgid "Packages Scan OK......" +msgstr "" + +#: ../cleaneractionwidget.cpp:253 +msgctxt "CleanerActionWidget|" +msgid "Error: " +msgstr "" + +#: ../cleaneractionwidget.cpp:256 +msgctxt "CleanerActionWidget|" +msgid "Firefox Browser does not be installed......" +msgstr "" + +#: ../cleaneractionwidget.cpp:260 +msgctxt "CleanerActionWidget|" +msgid "Chromium Browser does not be installed......" +msgstr "" + +#: ../cleaneractionwidget.cpp:288 +msgctxt "CleanerActionWidget|" +msgid "Ready to Cleanup......" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.ui:14 +msgctxt "CleanerDetailWidget|" +msgid "Form" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:228 +msgctxt "CleanerDetailWidget|" +msgid "Apt Cache Clean Items" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:234 +msgctxt "CleanerDetailWidget|" +msgid "Apt Cache count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:274 +#: ../../cleaner/cleanerdetailwidget.cpp:368 +msgctxt "CleanerDetailWidget|" +msgid "Software Cache Clean Items" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:280 +msgctxt "CleanerDetailWidget|" +msgid "Software Cache count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:320 +#: ../../cleaner/cleanerdetailwidget.cpp:413 +#: ../../cleaner/cleanerdetailwidget.cpp:463 +#: ../../cleaner/cleanerdetailwidget.cpp:510 +#: ../../cleaner/cleanerdetailwidget.cpp:643 +#: ../../cleaner/cleanerdetailwidget.cpp:689 +#: ../../cleaner/cleanerdetailwidget.cpp:735 +msgctxt "CleanerDetailWidget|" +msgid "Thumbnails Cache Clean Items" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:326 +msgctxt "CleanerDetailWidget|" +msgid "Thumbnails Cache Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:373 +msgctxt "CleanerDetailWidget|" +msgid "Firefox Cache Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:418 +msgctxt "CleanerDetailWidget|" +msgid "Chromium Cache Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:468 +msgctxt "CleanerDetailWidget|" +msgid "Firefox Cookies Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:515 +msgctxt "CleanerDetailWidget|" +msgid "Chromium Cookies Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:566 +msgctxt "CleanerDetailWidget|" +msgid "Firefox History Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:603 +msgctxt "CleanerDetailWidget|" +msgid "Chromium History Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:623 +msgctxt "CleanerDetailWidget|" +msgid "System History Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:648 +msgctxt "CleanerDetailWidget|" +msgid "Package Unneed Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:694 +msgctxt "CleanerDetailWidget|" +msgid "Package oldkernel Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:740 +msgctxt "CleanerDetailWidget|" +msgid "Package configfile Count:" +msgstr "" + +#: ../../cleaner/cleanerdetailwidget.cpp:1268 +msgctxt "CleanerDetailWidget|" +msgid "Clean args is empty!" +msgstr "" + +#: ../../cleaner/cleaneritems.cpp:143 +msgctxt "CleanerItems|" +msgid "OK" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:38 +msgctxt "CleanerMainWidget|" +msgid "Cleanup Package Cache" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:38 +msgctxt "CleanerMainWidget|" +msgid "Cleanup Software Center Cache" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:38 +msgctxt "CleanerMainWidget|" +msgid "Cleanup Thumbnails Cache" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:38 +msgctxt "CleanerMainWidget|" +msgid "Cleanup FireFox Cache" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:38 +msgctxt "CleanerMainWidget|" +msgid "Cleanup Chromium Cache" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:40 +msgctxt "CleanerMainWidget|" +msgid "Cache Items" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:45 +msgctxt "CleanerMainWidget|" +msgid "System Cache" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:45 +msgctxt "CleanerMainWidget|" +msgid "Cleanup cache of system, software-center, thumbnails and browser" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:52 +msgctxt "CleanerMainWidget|" +msgid "Uninstall unnecessary procedures" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:52 +msgctxt "CleanerMainWidget|" +msgid "Uninstall old kernel packages" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:52 +msgctxt "CleanerMainWidget|" +msgid "Cleanup software configfile" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:55 +msgctxt "CleanerMainWidget|" +msgid "Package Items" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:59 +msgctxt "CleanerMainWidget|" +msgid "Packages and configfile" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:59 +msgctxt "CleanerMainWidget|" +msgid "" +"Cleaning up the software that installed by other software bundled, old " +"kernel packages and configfile, to improve system performance" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:67 +msgctxt "CleanerMainWidget|" +msgid "Cleanup the Cookies saving in Firefox" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:67 +msgctxt "CleanerMainWidget|" +msgid "Cleanup the Cookies saving in Chromium" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:70 +msgctxt "CleanerMainWidget|" +msgid "Cookies Items" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:74 +msgctxt "CleanerMainWidget|" +msgid "Cookies" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:74 +msgctxt "CleanerMainWidget|" +msgid "Clean up user login information, support Firefox and Chromium browser" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:82 +msgctxt "CleanerMainWidget|" +msgid "Clean up the Firefox Internet records" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:82 +msgctxt "CleanerMainWidget|" +msgid "Clean up the Chromium Internet records" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:82 +msgctxt "CleanerMainWidget|" +msgid "Clean up the recently opened documents records" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:85 +msgctxt "CleanerMainWidget|" +msgid "Trace Items" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:89 +msgctxt "CleanerMainWidget|" +msgid "History trace" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:89 +msgctxt "CleanerMainWidget|" +msgid "Cleaning the internet and opened documents recently records" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:159 +msgctxt "CleanerMainWidget|" +msgid "Please select the items you want to clean" +msgstr "" + +#: ../../cleaner/cleanermainwidget.cpp:168 +msgctxt "CleanerMainWidget|" +msgid "Scan args is empty!" +msgstr "" + +#: ../../info/computerpage.cpp:55 ../../info/computerpage.cpp:104 +#: ../../info/computerpage.cpp:109 ../../info/computerpage.cpp:111 +#, qt-format +msgctxt "ComputerPage|" +msgid "%1" +msgstr "" + +#: ../../info/computerpage.cpp:97 ../../info/computerpage.cpp:101 +msgctxt "ComputerPage|" +msgid " Minutes" +msgstr "" + +#: ../../info/computerpage.cpp:101 +msgctxt "ComputerPage|" +msgid " Hours " +msgstr "" + +#: ../../info/computerpage.cpp:136 ../../info/computerpage.cpp:256 +msgctxt "ComputerPage|" +msgid "Audio Model" +msgstr "" + +#: ../../info/computerpage.cpp:138 ../../info/computerpage.cpp:191 +#: ../../info/computerpage.cpp:204 ../../info/computerpage.cpp:299 +#: ../../info/computerpage.cpp:324 ../../info/computerpage.cpp:340 +#: ../../info/computerpage.cpp:355 +msgctxt "ComputerPage|" +msgid "Vendor" +msgstr "" + +#: ../../info/computerpage.cpp:140 ../../info/computerpage.cpp:318 +#: ../../info/computerpage.cpp:328 ../../info/computerpage.cpp:346 +msgctxt "ComputerPage|" +msgid "Bus Address" +msgstr "" + +#: ../../info/computerpage.cpp:142 +msgctxt "ComputerPage|" +msgid "Audio Driver" +msgstr "" + +#: ../../info/computerpage.cpp:145 ../../info/computerpage.cpp:193 +#: ../../info/computerpage.cpp:288 ../../info/computerpage.cpp:330 +msgctxt "ComputerPage|" +msgid "Device Name" +msgstr "" + +#: ../../info/computerpage.cpp:147 +msgctxt "ComputerPage|" +msgid "Manufacturer" +msgstr "" + +#: ../../info/computerpage.cpp:161 ../../info/computerpage.cpp:357 +msgctxt "ComputerPage|" +msgid "Model" +msgstr "" + +#: ../../info/computerpage.cpp:163 +msgctxt "ComputerPage|" +msgid "Technology" +msgstr "" + +#: ../../info/computerpage.cpp:165 +msgctxt "ComputerPage|" +msgid "Voltage" +msgstr "" + +#: ../../info/computerpage.cpp:167 +msgctxt "ComputerPage|" +msgid "Energy Designed" +msgstr "" + +#: ../../info/computerpage.cpp:169 +msgctxt "ComputerPage|" +msgid "Energy Full" +msgstr "" + +#: ../../info/computerpage.cpp:171 +msgctxt "ComputerPage|" +msgid "Energy Now" +msgstr "" + +#: ../../info/computerpage.cpp:173 ../../info/computerpage.cpp:180 +#: ../../info/computerpage.cpp:197 ../../info/computerpage.cpp:206 +#: ../../info/computerpage.cpp:292 ../../info/computerpage.cpp:301 +#: ../../info/computerpage.cpp:350 ../../info/computerpage.cpp:361 +msgctxt "ComputerPage|" +msgid "Serial Number" +msgstr "" + +#: ../../info/computerpage.cpp:176 +msgctxt "ComputerPage|" +msgid "Motherboard Model" +msgstr "" + +#: ../../info/computerpage.cpp:178 +msgctxt "ComputerPage|" +msgid "Motherboard Vendor" +msgstr "" + +#: ../../info/computerpage.cpp:182 +msgctxt "ComputerPage|" +msgid "BIOS Vendor" +msgstr "" + +#: ../../info/computerpage.cpp:184 +msgctxt "ComputerPage|" +msgid "BIOS Version" +msgstr "" + +#: ../../info/computerpage.cpp:186 +msgctxt "ComputerPage|" +msgid "Release Date" +msgstr "" + +#: ../../info/computerpage.cpp:189 +msgctxt "ComputerPage|" +msgid "CD-ROM Model" +msgstr "" + +#: ../../info/computerpage.cpp:195 ../../info/computerpage.cpp:290 +msgctxt "ComputerPage|" +msgid "Firmware Version" +msgstr "" + +#: ../../info/computerpage.cpp:202 ../../info/computerpage.cpp:228 +msgctxt "ComputerPage|" +msgid "CPU" +msgstr "" + +#: ../../info/computerpage.cpp:208 +msgctxt "ComputerPage|" +msgid "Socket/Slot" +msgstr "" + +#: ../../info/computerpage.cpp:210 +msgctxt "ComputerPage|" +msgid "Maximum Frequency" +msgstr "" + +#: ../../info/computerpage.cpp:212 +msgctxt "ComputerPage|" +msgid "Current Frequency" +msgstr "" + +#: ../../info/computerpage.cpp:214 +msgctxt "ComputerPage|" +msgid "FSB" +msgstr "" + +#: ../../info/computerpage.cpp:216 +msgctxt "ComputerPage|" +msgid "Core Number" +msgstr "" + +#: ../../info/computerpage.cpp:218 +msgctxt "ComputerPage|" +msgid "Thread" +msgstr "" + +#: ../../info/computerpage.cpp:220 +msgctxt "ComputerPage|" +msgid "L1 Cache" +msgstr "" + +#: ../../info/computerpage.cpp:222 +msgctxt "ComputerPage|" +msgid "L2 Cache" +msgstr "" + +#: ../../info/computerpage.cpp:222 +msgctxt "ComputerPage|" +msgid "1500a v1.0 64 bits" +msgstr "" + +#: ../../info/computerpage.cpp:222 +msgctxt "ComputerPage|" +msgid "phytium" +msgstr "" + +#: ../../info/computerpage.cpp:222 +msgctxt "ComputerPage|" +msgid "4 cores" +msgstr "" + +#: ../../info/computerpage.cpp:222 +msgctxt "ComputerPage|" +msgid "4 thread/core" +msgstr "" + +#: ../../info/computerpage.cpp:226 +msgctxt "ComputerPage|" +msgid "Desktop Environment" +msgstr "" + +#: ../../info/computerpage.cpp:230 +msgctxt "ComputerPage|" +msgid "Host Name" +msgstr "" + +#: ../../info/computerpage.cpp:232 +msgctxt "ComputerPage|" +msgid "Memery Capacity" +msgstr "" + +#: ../../info/computerpage.cpp:234 +msgctxt "ComputerPage|" +msgid "Shell" +msgstr "" + +#: ../../info/computerpage.cpp:236 +msgctxt "ComputerPage|" +msgid "Distribution" +msgstr "" + +#: ../../info/computerpage.cpp:238 +msgctxt "ComputerPage|" +msgid "Language" +msgstr "" + +#: ../../info/computerpage.cpp:240 +msgctxt "ComputerPage|" +msgid "User" +msgstr "" + +#: ../../info/computerpage.cpp:242 +msgctxt "ComputerPage|" +msgid "Home Folder" +msgstr "" + +#: ../../info/computerpage.cpp:246 +msgctxt "ComputerPage|" +msgid "Host bridge" +msgstr "" + +#: ../../info/computerpage.cpp:248 +msgctxt "ComputerPage|" +msgid "VGA Model" +msgstr "" + +#: ../../info/computerpage.cpp:250 +msgctxt "ComputerPage|" +msgid "USB Model" +msgstr "" + +#: ../../info/computerpage.cpp:252 +msgctxt "ComputerPage|" +msgid "Communication Model" +msgstr "" + +#: ../../info/computerpage.cpp:254 +msgctxt "ComputerPage|" +msgid "Ethernet Model" +msgstr "" + +#: ../../info/computerpage.cpp:258 +msgctxt "ComputerPage|" +msgid "PCI bridge" +msgstr "" + +#: ../../info/computerpage.cpp:260 +msgctxt "ComputerPage|" +msgid "ISA bridge" +msgstr "" + +#: ../../info/computerpage.cpp:262 +msgctxt "ComputerPage|" +msgid "SATA Model" +msgstr "" + +#: ../../info/computerpage.cpp:264 +msgctxt "ComputerPage|" +msgid "SMBus" +msgstr "" + +#: ../../info/computerpage.cpp:266 +msgctxt "ComputerPage|" +msgid "System peripheral" +msgstr "" + +#: ../../info/computerpage.cpp:268 +msgctxt "ComputerPage|" +msgid "Driver in use" +msgstr "" + +#: ../../info/computerpage.cpp:270 +msgctxt "ComputerPage|" +msgid "existing drivers" +msgstr "" + +#: ../../info/computerpage.cpp:272 +msgctxt "ComputerPage|" +msgid "IDE interface" +msgstr "" + +#: ../../info/computerpage.cpp:274 +msgctxt "ComputerPage|" +msgid "SP controller" +msgstr "" + +#: ../../info/computerpage.cpp:276 +msgctxt "ComputerPage|" +msgid "Network controller" +msgstr "" + +#: ../../info/computerpage.cpp:278 +msgctxt "ComputerPage|" +msgid "Multimedia audio controller" +msgstr "" + +#: ../../info/computerpage.cpp:282 +msgctxt "ComputerPage|" +msgid "HDD Model" +msgstr "" + +#: ../../info/computerpage.cpp:284 +msgctxt "ComputerPage|" +msgid "HDD Vendor" +msgstr "" + +#: ../../info/computerpage.cpp:286 +msgctxt "ComputerPage|" +msgid "HDD Capacity" +msgstr "" + +#: ../../info/computerpage.cpp:295 +msgctxt "ComputerPage|" +msgid "Slot Number" +msgstr "" + +#: ../../info/computerpage.cpp:297 +msgctxt "ComputerPage|" +msgid "Memory Model" +msgstr "" + +#: ../../info/computerpage.cpp:303 +msgctxt "ComputerPage|" +msgid "Memory Size" +msgstr "" + +#: ../../info/computerpage.cpp:305 +msgctxt "ComputerPage|" +msgid "Data Width" +msgstr "" + +#: ../../info/computerpage.cpp:307 +msgctxt "ComputerPage|" +msgid "Memory Info" +msgstr "" + +#: ../../info/computerpage.cpp:310 +msgctxt "ComputerPage|" +msgid "Graphics Card Model" +msgstr "" + +#: ../../info/computerpage.cpp:312 +msgctxt "ComputerPage|" +msgid "Current Graphics Card" +msgstr "" + +#: ../../info/computerpage.cpp:314 +msgctxt "ComputerPage|" +msgid "Graphics Card Vendor" +msgstr "" + +#: ../../info/computerpage.cpp:316 +msgctxt "ComputerPage|" +msgid "Graphics Driver" +msgstr "" + +#: ../../info/computerpage.cpp:322 +msgctxt "ComputerPage|" +msgid "NIC Model" +msgstr "" + +#: ../../info/computerpage.cpp:326 +msgctxt "ComputerPage|" +msgid "NIC Driver" +msgstr "" + +#: ../../info/computerpage.cpp:332 ../../info/computerpage.cpp:352 +msgctxt "ComputerPage|" +msgid "IP Address" +msgstr "" + +#: ../../info/computerpage.cpp:334 +msgctxt "ComputerPage|" +msgid "Mac Address" +msgstr "" + +#: ../../info/computerpage.cpp:336 +msgctxt "ComputerPage|" +msgid "Connection Status" +msgstr "" + +#: ../../info/computerpage.cpp:338 +msgctxt "ComputerPage|" +msgid "Max Bandwidth" +msgstr "" + +#: ../../info/computerpage.cpp:342 +msgctxt "ComputerPage|" +msgid "WLan NIC Driver" +msgstr "" + +#: ../../info/computerpage.cpp:344 +msgctxt "ComputerPage|" +msgid "WLan NIC Model" +msgstr "" + +#: ../../info/computerpage.cpp:348 +msgctxt "ComputerPage|" +msgid "Device Name:" +msgstr "" + +#: ../../info/computerpage.cpp:359 +msgctxt "ComputerPage|" +msgid "Version" +msgstr "" + +#: ../../info/computerpage.cpp:363 +msgctxt "ComputerPage|" +msgid "Hostname" +msgstr "" + +#: ../../info/computerpage.cpp:365 +msgctxt "ComputerPage|" +msgid "Running Time" +msgstr "" + +#: ../../info/computerpage.cpp:367 +msgctxt "ComputerPage|" +msgid "OS Types" +msgstr "" + +#: ../../info/computerpage.cpp:369 +msgctxt "ComputerPage|" +msgid "OS Version" +msgstr "" + +#: ../../info/computerpage.cpp:371 +msgctxt "ComputerPage|" +msgid "Kernel Bit" +msgstr "" + +#: ../../info/computerpage.cpp:373 +msgctxt "ComputerPage|" +msgid "Kernel Version" +msgstr "" + +#: ../../info/computerpage.cpp:375 +msgctxt "ComputerPage|" +msgid "Kernel Arch" +msgstr "" + +#: ../../info/cpuwidget.cpp:30 +msgctxt "CpuWidget|" +msgid "CPU Info" +msgstr "" + +#: ../../setting/deadpixelwidget.cpp:75 +msgctxt "DeadpixelWidget|" +msgid "" +"Left-click to change the color, right-click to exit from this detection." +msgstr "" + +#: ../../setting/deadpixelwidget.cpp:76 +msgctxt "DeadpixelWidget|" +msgid "OK" +msgstr "" + +#: ../../info/desktopwidget.cpp:30 +msgctxt "DesktopWidget|" +msgid "Desktop Info" +msgstr "" + +#: ../../info/driverwidget.cpp:32 +msgctxt "DriverWidget|" +msgid "Driver Info" +msgstr "" + +#: ../../setting/fontwidget.cpp:63 ../../setting/fontwidget.cpp:64 +#: ../../setting/fontwidget.cpp:65 ../../setting/fontwidget.cpp:66 +#: ../../setting/fontwidget.cpp:67 +msgctxt "FontWidget|" +msgid "Click here to change font" +msgstr "" + +#: ../../setting/fontwidget.cpp:166 +msgctxt "FontWidget|" +msgid "Default Font" +msgstr "" + +#: ../../setting/fontwidget.cpp:167 +msgctxt "FontWidget|" +msgid "Desktop Font" +msgstr "" + +#: ../../setting/fontwidget.cpp:168 +msgctxt "FontWidget|" +msgid "Monospace Font" +msgstr "" + +#: ../../setting/fontwidget.cpp:169 +msgctxt "FontWidget|" +msgid "Document Font" +msgstr "" + +#: ../../setting/fontwidget.cpp:170 +msgctxt "FontWidget|" +msgid "Titlebar Font" +msgstr "" + +#: ../../setting/fontwidget.cpp:171 +msgctxt "FontWidget|" +msgid "Global Font Scaling" +msgstr "" + +#: ../../setting/fontwidget.cpp:172 +msgctxt "FontWidget|" +msgid "Hinting" +msgstr "" + +#: ../../setting/fontwidget.cpp:173 +msgctxt "FontWidget|" +msgid "Antialiasing" +msgstr "" + +#: ../../info/hdwidget.cpp:35 +msgctxt "HDWidget|" +msgid "HardWare Info" +msgstr "" + +#: ../../info/hdwidget.cpp:45 +#, qt-format +msgctxt "HDWidget|" +msgid "HardWare Info %1" +msgstr "" + +#: ../homeactionwidget.cpp:132 ../homeactionwidget.cpp:231 +msgctxt "HomeActionWidget|" +msgid "The lastest cleanup time is " +msgstr "" + +#: ../homeactionwidget.cpp:138 ../homeactionwidget.cpp:184 +msgctxt "HomeActionWidget|" +msgid "The lastest scan time is " +msgstr "" + +#: ../homeactionwidget.cpp:142 +msgctxt "HomeActionWidget|" +msgid "You have not implemented the one key scan and clean-up operation." +msgstr "" + +#: ../homeactionwidget.cpp:163 +msgctxt "HomeActionWidget|" +msgid "" +"Quick clean up system trash, saving disk space and improving the system " +"efficiency!" +msgstr "" + +#: ../homeactionwidget.cpp:164 +msgctxt "HomeActionWidget|" +msgid "Start Scan" +msgstr "" + +#: ../homeactionwidget.cpp:165 +msgctxt "HomeActionWidget|" +msgid "Start Cleanup" +msgstr "" + +#: ../homeactionwidget.cpp:166 +msgctxt "HomeActionWidget|" +msgid "Back" +msgstr "" + +#: ../homeactionwidget.cpp:167 +msgctxt "HomeActionWidget|" +msgid "Scanning......" +msgstr "" + +#: ../homeactionwidget.cpp:177 +msgctxt "HomeActionWidget|" +msgid "Scanning:" +msgstr "" + +#: ../homeactionwidget.cpp:183 +msgctxt "HomeActionWidget|" +msgid "Scan Over" +msgstr "" + +#: ../homeactionwidget.cpp:215 +msgctxt "HomeActionWidget|" +msgid "Cleaning......" +msgstr "" + +#: ../homeactionwidget.cpp:220 +msgctxt "HomeActionWidget|" +msgid "Garbage Cleanup OK......" +msgstr "" + +#: ../homeactionwidget.cpp:223 +msgctxt "HomeActionWidget|" +msgid "History Cleanup OK......" +msgstr "" + +#: ../homeactionwidget.cpp:226 +msgctxt "HomeActionWidget|" +msgid "Cookies Cleanup OK......" +msgstr "" + +#: ../homeactionwidget.cpp:232 +msgctxt "HomeActionWidget|" +msgid "Cleanup Cookies:" +msgstr "" + +#: ../homeactionwidget.cpp:232 +msgctxt "HomeActionWidget|" +msgid "; Garbage:" +msgstr "" + +#: ../homeactionwidget.cpp:232 +msgctxt "HomeActionWidget|" +msgid "; Historical records:" +msgstr "" + +#: ../homeactionwidget.cpp:262 +msgctxt "HomeActionWidget|" +msgid "Cleaning up history trace of Firefox..." +msgstr "" + +#: ../homeactionwidget.cpp:265 +msgctxt "HomeActionWidget|" +msgid "Firefox history trace had been cleared!" +msgstr "" + +#: ../homeactionwidget.cpp:270 +msgctxt "HomeActionWidget|" +msgid "Cleaning up history trace of Chromium..." +msgstr "" + +#: ../homeactionwidget.cpp:273 +msgctxt "HomeActionWidget|" +msgid "Chromium history trace had been cleared!" +msgstr "" + +#: ../homeactionwidget.cpp:278 +msgctxt "HomeActionWidget|" +msgid "Cleaning up Cookies of Firefox..." +msgstr "" + +#: ../homeactionwidget.cpp:281 +msgctxt "HomeActionWidget|" +msgid "Firefox Cookies had been cleared!" +msgstr "" + +#: ../homeactionwidget.cpp:286 +msgctxt "HomeActionWidget|" +msgid "Cleaning up Cookies of Chromium..." +msgstr "" + +#: ../homeactionwidget.cpp:289 +msgctxt "HomeActionWidget|" +msgid "Chromium Cookies had been cleared!" +msgstr "" + +#: ../homeactionwidget.cpp:294 +msgctxt "HomeActionWidget|" +msgid "Apt cache had been cleared!" +msgstr "" + +#: ../homeactionwidget.cpp:297 +msgctxt "HomeActionWidget|" +msgid "Cleaning up Apt cache: " +msgstr "" + +#: ../homeactionwidget.cpp:302 +msgctxt "HomeActionWidget|" +msgid "Software Center cache had been cleared!" +msgstr "" + +#: ../homeactionwidget.cpp:305 +msgctxt "HomeActionWidget|" +msgid "Cleaning up Software Center cache: " +msgstr "" + +#: ../homeactionwidget.cpp:329 +msgctxt "HomeActionWidget|" +msgid "Ready to Cleanup......" +msgstr "" + +#: ../homepage.cpp:152 +msgctxt "HomePage|" +msgid "Boot Manager" +msgstr "" + +#: ../homepage.cpp:152 +msgctxt "HomePage|" +msgid "Camera" +msgstr "" + +#: ../homepage.cpp:220 +msgctxt "HomePage|" +msgid "Current Version Number" +msgstr "" + +#: ../homepage.cpp:221 +msgctxt "HomePage|" +msgid "Update to the lastest version, make it work better" +msgstr "" + +#: ../homepage.cpp:222 +msgctxt "HomePage|" +msgid "Check new version" +msgstr "" + +#: ../homepage.cpp:223 +msgctxt "HomePage|" +msgid "Common toolbox" +msgstr "" + +#: ../homepage.cpp:224 +msgctxt "HomePage|" +msgid "Fast and practical, making the system more personalized" +msgstr "" + +#: ../homepage.cpp:225 ../homepage.cpp:226 +msgctxt "HomePage|" +msgid "More" +msgstr "" + +#: ../../setting/iconwidget.cpp:182 +msgctxt "IconWidget|" +msgid "Icon theme" +msgstr "" + +#: ../../setting/iconwidget.cpp:183 +msgctxt "IconWidget|" +msgid "Show Desktop Icons" +msgstr "" + +#: ../../setting/iconwidget.cpp:184 +msgctxt "IconWidget|" +msgid "Home Folder" +msgstr "" + +#: ../../setting/iconwidget.cpp:185 +msgctxt "IconWidget|" +msgid "Network" +msgstr "" + +#: ../../setting/iconwidget.cpp:186 +msgctxt "IconWidget|" +msgid "Trash" +msgstr "" + +#: ../../setting/iconwidget.cpp:187 +msgctxt "IconWidget|" +msgid "Mounted Volumes" +msgstr "" + +#: ../infoactionwidget.cpp:61 +msgctxt "InfoActionWidget|" +msgid "" +"Understand hardware information, provide more convenient channel to obtain " +"hardware information" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Computer" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Desktop" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "CPU" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Memory" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Motherboard" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "HD" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "NIC" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "VGA" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Audio" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "CD-ROM" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Battery" +msgstr "" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Device Driver" +msgstr "" + +#: ../../component/kylinfontdialog.cpp:176 +msgctxt "KylinFontDialog|" +msgid "Current Font" +msgstr "" + +#: ../../component/kylinfontdialog.cpp:177 +msgctxt "KylinFontDialog|" +msgid "Font" +msgstr "" + +#: ../../component/kylinfontdialog.cpp:178 +msgctxt "KylinFontDialog|" +msgid "Style" +msgstr "" + +#: ../../component/kylinfontdialog.cpp:179 +msgctxt "KylinFontDialog|" +msgid "Size" +msgstr "" + +#: ../../component/kylinfontdialog.cpp:180 +msgctxt "KylinFontDialog|" +msgid "View" +msgstr "" + +#: ../../component/kylinfontdialog.cpp:181 +msgctxt "KylinFontDialog|" +msgid "OK" +msgstr "" + +#: ../../component/kylinfontdialog.cpp:182 +msgctxt "KylinFontDialog|" +msgid "Cancel" +msgstr "" + +#: ../../component/kylinfontdialog.cpp:211 +msgctxt "KylinFontDialog|" +msgid "Tips" +msgstr "" + +#: ../../component/kylinfontdialog.cpp:212 +msgctxt "KylinFontDialog|" +msgid "You haven't change the font, please choose the font!" +msgstr "" + +#: ../../component/kylinfontdialog.cpp:225 +msgctxt "KylinFontDialog|" +msgid "Font Dialog" +msgstr "" + +#: ../../component/kylinmenu.cpp:48 +msgctxt "KylinMenu|" +msgid "Forum Help" +msgstr "" + +#: ../../component/kylinmenu.cpp:50 +msgctxt "KylinMenu|" +msgid "Feedback" +msgstr "" + +#: ../../component/kylinmenu.cpp:52 +msgctxt "KylinMenu|" +msgid "About us" +msgstr "" + +#: ../../component/kylinmenu.cpp:54 +msgctxt "KylinMenu|" +msgid "Help" +msgstr "" + +#: ../../component/kylinswitcher.cpp:82 +msgctxt "KylinSwitcher|" +msgid "ON" +msgstr "" + +#: ../../component/kylinswitcher.cpp:91 +msgctxt "KylinSwitcher|" +msgid "OFF" +msgstr "" + +#: ../../setting/launcherwidget.cpp:133 +msgctxt "LauncherWidget|" +msgid "Launcher icon size" +msgstr "" + +#: ../../setting/launcherwidget.cpp:134 +msgctxt "LauncherWidget|" +msgid "Launcher hide mode" +msgstr "" + +#: ../../setting/launcherwidget.cpp:135 +msgctxt "LauncherWidget|" +msgid "Display desktop icon" +msgstr "" + +#: ../../setting/launcherwidget.cpp:136 +msgctxt "LauncherWidget|" +msgid "Launcher Transparency" +msgstr "" + +#: ../../setting/launcherwidget.cpp:137 +msgctxt "LauncherWidget|" +msgid "Icon Background" +msgstr "" + +#: ../loginwidget.cpp:106 +msgctxt "LoginWidget|" +msgid "Login Youker Account" +msgstr "" + +#: ../loginwidget.cpp:107 +msgctxt "LoginWidget|" +msgid "Logout" +msgstr "" + +#: ../mainwindow.ui:17 +msgctxt "MainWindow|" +msgid "MainWindow" +msgstr "" + +#: ../../info/memorywidget.cpp:36 +msgctxt "MemoryWidget|" +msgid "Memory Info" +msgstr "" + +#: ../../info/memorywidget.cpp:46 +#, qt-format +msgctxt "MemoryWidget|" +msgid "Memory Info %1" +msgstr "" + +#: ../../info/monitorwidget.cpp:35 +msgctxt "MonitorWidget|" +msgid "Monitor Info" +msgstr "" + +#: ../../info/monitorwidget.cpp:45 +#, qt-format +msgctxt "MonitorWidget|" +msgid "Monitor Info %1" +msgstr "" + +#: ../../setting/mousewidget.cpp:100 +msgctxt "MouseWidget|" +msgid "Mouse Pointer Theme" +msgstr "" + +#: ../../setting/mousewidget.cpp:101 +msgctxt "MouseWidget|" +msgid "Cursor Pointer Size" +msgstr "" + +#: ../../setting/mousewidget.cpp:102 +msgctxt "MouseWidget|" +msgid "Small Size" +msgstr "" + +#: ../../setting/mousewidget.cpp:103 +msgctxt "MouseWidget|" +msgid "Big Size" +msgstr "" + +#: ../../setting/nautiluswidget.cpp:179 +msgctxt "NautilusWidget|" +msgid "Display entry location" +msgstr "" + +#: ../../setting/nautiluswidget.cpp:180 +msgctxt "NautilusWidget|" +msgid "Automatically mount media" +msgstr "" + +#: ../../setting/nautiluswidget.cpp:181 +msgctxt "NautilusWidget|" +msgid "Automatically open a folder" +msgstr "" + +#: ../../setting/nautiluswidget.cpp:182 +msgctxt "NautilusWidget|" +msgid "Prompt autorun programs" +msgstr "" + +#: ../../setting/nautiluswidget.cpp:183 +msgctxt "NautilusWidget|" +msgid "Thumbnail icon size (pixels)" +msgstr "" + +#: ../../setting/nautiluswidget.cpp:184 +msgctxt "NautilusWidget|" +msgid "Thumbnail cache time (days)" +msgstr "" + +#: ../../setting/nautiluswidget.cpp:185 +msgctxt "NautilusWidget|" +msgid "Maximum thumbnail cache size (MB)" +msgstr "" + +#: ../../info/nicwidget.cpp:30 +msgctxt "NicWidget|" +msgid "NIC Info" +msgstr "" + +#: ../../info/nicwidget.cpp:34 +msgctxt "NicWidget|" +msgid "WireLess NIC Info" +msgstr "" + +#: ../../setting/panelwidget.cpp:181 +msgctxt "PanelWidget|" +msgid "Dash background blur type" +msgstr "" + +#: ../../setting/panelwidget.cpp:182 +msgctxt "PanelWidget|" +msgid "Panel Transparency" +msgstr "" + +#: ../../setting/panelwidget.cpp:183 +msgctxt "PanelWidget|" +msgid "Date & time format" +msgstr "" + +#: ../../setting/panelwidget.cpp:184 +msgctxt "PanelWidget|" +msgid "Display seconds" +msgstr "" + +#: ../../setting/panelwidget.cpp:185 +msgctxt "PanelWidget|" +msgid "Display week" +msgstr "" + +#: ../../setting/panelwidget.cpp:186 +msgctxt "PanelWidget|" +msgid "Display the date" +msgstr "" + +#: ../../setting/panelwidget.cpp:187 +msgctxt "PanelWidget|" +msgid "Display battery icon" +msgstr "" + +#: ../../setting/panelwidget.cpp:188 +msgctxt "PanelWidget|" +msgid "Display battery percentage" +msgstr "" + +#: ../../setting/panelwidget.cpp:189 +msgctxt "PanelWidget|" +msgid "Display battery remaining time" +msgstr "" + +#: ../../setting/panelwidget.cpp:191 +msgctxt "PanelWidget|" +msgid "Smart blur" +msgstr "" + +#: ../../setting/panelwidget.cpp:192 +msgctxt "PanelWidget|" +msgid "Static blur" +msgstr "" + +#: ../../setting/panelwidget.cpp:193 +msgctxt "PanelWidget|" +msgid "Clear" +msgstr "" + +#: ../../processmanager/processdialog.cpp:91 +#: ../../processmanager/processdialog.cpp:125 +msgctxt "ProcessDialog|" +msgid "Process Manager" +msgstr "" + +#: ../../processmanager/processdialog.cpp:92 +msgctxt "ProcessDialog|" +msgid "Help you learn more about the program running on the system." +msgstr "" + +#: ../../processmanager/processdialog.cpp:93 +msgctxt "ProcessDialog|" +msgid "Kill Process" +msgstr "" + +#: ../../processmanager/processdialog.cpp:253 +msgctxt "ProcessDialog|" +msgid "kill process success" +msgstr "" + +#: ../../processmanager/processdialog.cpp:256 +msgctxt "ProcessDialog|" +msgid "kill process failed" +msgstr "" + +#: ../../processmanager/processmanager.cpp:40 +msgctxt "ProcessManager|" +msgid "Process Manager" +msgstr "" + +#: ../../processmanager/processmanager.cpp:45 +msgctxt "ProcessManager|" +msgid "Help user to kill process" +msgstr "" + +#: ../../component/quibo.ui:14 +msgctxt "QUIBO|" +msgid "Form" +msgstr "" + +#: ../../component/settingaction.cpp:99 +msgctxt "SettingAction|" +msgid "Back" +msgstr "" + +#: ../../component/settingaction.cpp:102 +msgctxt "SettingAction|" +msgid "Choose the theme what you want" +msgstr "" + +#: ../../component/settingaction.cpp:106 +msgctxt "SettingAction|" +msgid "Set the desktop icon theme and the visibility of desktop icons" +msgstr "" + +#: ../../component/settingaction.cpp:110 +msgctxt "SettingAction|" +msgid "" +"Replace the theme and size of the mouse pointer, and theme change need to " +"restart system." +msgstr "" + +#: ../../component/settingaction.cpp:114 +msgctxt "SettingAction|" +msgid "Set the sound theme you want" +msgstr "" + +#: ../../component/settingaction.cpp:118 +msgctxt "SettingAction|" +msgid "" +"Click the \"Custom Picture\" button to select the picture you want to add, " +"click the picture you want to set and push the \"OK\" button to complete" +msgstr "" + +#: ../../component/settingaction.cpp:122 +msgctxt "SettingAction|" +msgid "Setting the Launcher display mode, Icon size." +msgstr "" + +#: ../../component/settingaction.cpp:126 +msgctxt "SettingAction|" +msgid "Manage Dash and Panel menu settings" +msgstr "" + +#: ../../component/settingaction.cpp:130 +msgctxt "SettingAction|" +msgid "Window Manager settings" +msgstr "" + +#: ../../component/settingaction.cpp:134 +msgctxt "SettingAction|" +msgid "" +"According to personal preferences to set the system default font, click the " +"'Restore' button, can be restored to the state before the font settings" +msgstr "" + +#: ../../component/settingaction.cpp:138 +msgctxt "SettingAction|" +msgid "" +"Setting the relevant properties of your touchpad,make the operation more " +"convenient" +msgstr "" + +#: ../../component/settingaction.cpp:142 +msgctxt "SettingAction|" +msgid "Monitor Check" +msgstr "" + +#: ../../component/settingaction.cpp:146 +msgctxt "SettingAction|" +msgid "" +"Manage the Nautilus file manager. Tips: if the thumbnail's cache time or " +"size is set to -1, it will not be checked." +msgstr "" + +#: ../settingactionwidget.cpp:142 +msgctxt "SettingActionWidget|" +msgid "" +"You can perform a full range of customized systems based on personal " +"preferences" +msgstr "" + +#: ../settingwidget.cpp:247 +msgctxt "SettingWidget|" +msgid "Personalize" +msgstr "" + +#: ../settingwidget.cpp:258 +msgctxt "SettingWidget|" +msgid "ThemeSetting" +msgstr "" + +#: ../settingwidget.cpp:259 +msgctxt "SettingWidget|" +msgid "IconSetting" +msgstr "" + +#: ../settingwidget.cpp:260 +msgctxt "SettingWidget|" +msgid "MousePointer" +msgstr "" + +#: ../settingwidget.cpp:261 +msgctxt "SettingWidget|" +msgid "SoundEffect" +msgstr "" + +#: ../settingwidget.cpp:262 +msgctxt "SettingWidget|" +msgid "BootAnimation" +msgstr "" + +#: ../settingwidget.cpp:338 +msgctxt "SettingWidget|" +msgid "Desktop" +msgstr "" + +#: ../settingwidget.cpp:342 +msgctxt "SettingWidget|" +msgid "Custom Launcher" +msgstr "" + +#: ../settingwidget.cpp:343 +msgctxt "SettingWidget|" +msgid "Dash & Panel" +msgstr "" + +#: ../settingwidget.cpp:344 +msgctxt "SettingWidget|" +msgid "Window" +msgstr "" + +#: ../settingwidget.cpp:392 +msgctxt "SettingWidget|" +msgid "Font" +msgstr "" + +#: ../settingwidget.cpp:394 +msgctxt "SettingWidget|" +msgid "FontSetting" +msgstr "" + +#: ../settingwidget.cpp:452 +msgctxt "SettingWidget|" +msgid "Sys options" +msgstr "" + +#: ../settingwidget.cpp:455 +msgctxt "SettingWidget|" +msgid "Touchpad" +msgstr "" + +#: ../settingwidget.cpp:456 +msgctxt "SettingWidget|" +msgid "Dead pixel check" +msgstr "" + +#: ../settingwidget.cpp:504 +msgctxt "SettingWidget|" +msgid "Others" +msgstr "" + +#: ../settingwidget.cpp:506 +msgctxt "SettingWidget|" +msgid "File manager" +msgstr "" + +#: ../../shredmanager/shreddialog.cpp:100 ../../shredmanager/shreddialog.cpp:129 +msgctxt "ShredDialog|" +msgid "Shred Manager" +msgstr "" + +#: ../../shredmanager/shreddialog.cpp:101 +#: ../../shredmanager/shreddialog.cpp:174 ../../shredmanager/shreddialog.cpp:186 +msgctxt "ShredDialog|" +msgid "No select any file which need to be shredded" +msgstr "" + +#: ../../shredmanager/shreddialog.cpp:102 +msgctxt "ShredDialog|" +msgid "Shred File" +msgstr "" + +#: ../../shredmanager/shreddialog.cpp:103 +msgctxt "ShredDialog|" +msgid "Deselect" +msgstr "" + +#: ../../shredmanager/shreddialog.cpp:145 +msgctxt "ShredDialog|" +msgid "Allfile(*)" +msgstr "" + +#: ../../shredmanager/shreddialog.cpp:162 +msgctxt "ShredDialog|" +msgid "Select file!" +msgstr "" + +#: ../../shredmanager/shreddialog.cpp:173 +msgctxt "ShredDialog|" +msgid "Shred successfully!" +msgstr "" + +#: ../../shredmanager/shreddialog.cpp:179 +msgctxt "ShredDialog|" +msgid "Shred failed!" +msgstr "" + +#: ../../shredmanager/shredmanager.cpp:40 +msgctxt "ShredManager|" +msgid "Shred Manager" +msgstr "" + +#: ../../shredmanager/shredmanager.cpp:45 +msgctxt "ShredManager|" +msgid "Delete files makes it unable to recover" +msgstr "" + +#: ../skincenter.cpp:107 +msgctxt "SkinCenter|" +msgid "Skin Center" +msgstr "" + +#: ../../info/systemwidget.cpp:36 +msgctxt "SystemWidget|" +msgid "Computer Base Info" +msgstr "" + +#: ../../info/systemwidget.cpp:63 ../../info/systemwidget.cpp:67 +msgctxt "SystemWidget|" +msgid " Minutes" +msgstr "" + +#: ../../info/systemwidget.cpp:67 +msgctxt "SystemWidget|" +msgid " Hours " +msgstr "" + +#: ../../setting/themewidget.cpp:67 +#, qt-format +msgctxt "ThemeWidget|" +msgid "%1" +msgstr "" + +#: ../../component/tipdialog.cpp:74 +msgctxt "TipDialog|" +msgid "OK" +msgstr "" + +#: ../../component/tipdialog.cpp:97 +msgctxt "TipDialog|" +msgid "Tip Dialog" +msgstr "" + +#: ../toolwidget.cpp:38 +msgctxt "ToolWidget|" +msgid "Home" +msgstr "" + +#: ../toolwidget.cpp:38 +msgctxt "ToolWidget|" +msgid "Cleanup" +msgstr "" + +#: ../toolwidget.cpp:38 +msgctxt "ToolWidget|" +msgid "Sysinfo" +msgstr "" + +#: ../toolwidget.cpp:38 +msgctxt "ToolWidget|" +msgid "Feature" +msgstr "" + +#: ../toolwidget.cpp:38 +msgctxt "ToolWidget|" +msgid "Toolkits" +msgstr "" + +#: ../../setting/touchpadwidget.cpp:126 +msgctxt "TouchpadWidget|" +msgid "Enable touchpad" +msgstr "" + +#: ../../setting/touchpadwidget.cpp:127 +msgctxt "TouchpadWidget|" +msgid "Enable horizontal scrolling" +msgstr "" + +#: ../../setting/touchpadwidget.cpp:128 +msgctxt "TouchpadWidget|" +msgid "Scrollbar type" +msgstr "" + +#: ../../setting/touchpadwidget.cpp:129 +msgctxt "TouchpadWidget|" +msgid "Panel layout" +msgstr "" + +#: ../../setting/touchpadwidget.cpp:130 +msgctxt "TouchpadWidget|" +msgid "Features Type" +msgstr "" + +#: ../../setting/touchpadwidget.cpp:131 +msgctxt "TouchpadWidget|" +msgid "Standard Type" +msgstr "" + +#: ../../setting/touchpadwidget.cpp:132 +msgctxt "TouchpadWidget|" +msgid "Edge Scrolling" +msgstr "" + +#: ../../setting/touchpadwidget.cpp:133 +msgctxt "TouchpadWidget|" +msgid "Two-finger Scrolling" +msgstr "" + +#: ../../setting/voicewidget.cpp:99 +msgctxt "VoiceWidget|" +msgid "Sound theme" +msgstr "" + +#: ../../setting/voicewidget.cpp:100 +msgctxt "VoiceWidget|" +msgid "Login tone" +msgstr "" + +#: ../../setting/voicewidget.cpp:101 +msgctxt "VoiceWidget|" +msgid "Event sounds" +msgstr "" + +#: ../../setting/voicewidget.cpp:102 +msgctxt "VoiceWidget|" +msgid "Input feedback sounds" +msgstr "" + +#: ../../setting/windowwidget.cpp:115 +msgctxt "WindowWidget|" +msgid "Menu with icons" +msgstr "" + +#: ../../setting/windowwidget.cpp:116 +msgctxt "WindowWidget|" +msgid "Titlebar mouse wheel action" +msgstr "" + +#: ../../setting/windowwidget.cpp:117 +msgctxt "WindowWidget|" +msgid "Titlebar double-click action" +msgstr "" + +#: ../../setting/windowwidget.cpp:118 +msgctxt "WindowWidget|" +msgid "Titlebar middle-click action" +msgstr "" + +#: ../../setting/windowwidget.cpp:119 +msgctxt "WindowWidget|" +msgid "Titlebar right-click action" +msgstr "" diff --git a/po/zh_CN.po b/po/zh_CN.po new file mode 100644 index 0000000..8a871da --- /dev/null +++ b/po/zh_CN.po @@ -0,0 +1,2294 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Language: zh_CN\n" +"X-Source-Language: C\n" +"X-Qt-Contexts: true\n" + +# 关于本软件 +#: ../aboutdialog.ui:26 ../aboutdialog.ui:42 +msgctxt "AboutDialog|" +msgid "About" +msgstr "关于" + +# 优客助手 +#: ../aboutdialog.ui:70 ../aboutdialog.ui:165 +msgctxt "AboutDialog|" +msgid "Youker Assistant" +msgstr "优客助手" + +#: ../aboutdialog.ui:105 +msgctxt "AboutDialog|" +msgid "" +"\n" +"\n" +"

Youker Assistant is a powerful system " +"supporting software which is developed by Ubuntu Kylin team. Mainly for the " +"naive user, it can help users manage the system. At present, It provides " +"system junk scanning and cleaning, viewing the system hardware and software " +"information , system customization, task manager, monitoring ball, and some " +"other functions.

\n" +"

The software is still under development. " +"Please visit www.ubuntukylin.com for more information. Welcome everyone to " +"join with us. youker-assistant Homepage: " +"https://launchpad.net/youker-assistant.

" +msgstr "" +"\n" +"\n" +"

优客助手是由Ubuntu " +"Kylin团队开发的一款功能强大的系统辅助软件。主要面向初级用户,能够帮助用户对系统进行管理。目前已具备了系统垃圾扫描与清理、系统软硬件信息查看、系统全方位定制、任务管理器以及监控球等功能。 " +"

\n" +"

各项功能还在不断完善,更多功能也将陆续开发,敬请关注 Ubuntu Kylin 官网 " +"www.ubuntukylin.com " +"了解软件的最新进展并反馈问题,欢迎广大优客一起参与。优客助手主页:https://launchpad.net/youker-assistant " +"。

" + +#: ../aboutdialog.ui:116 +msgctxt "AboutDialog|" +msgid "Contributor" +msgstr "贡献者" + +#: ../aboutdialog.ui:131 +msgctxt "AboutDialog|" +msgid "" +"\n" +"\n" +"

Maintainer:

\n" +"

Ubuntu Kylin Team " +"<ubuntukylin-members@list.launchpad.net>

" +msgstr "" +"\n" +"\n" +"

维护者

\n" +"

Ubuntu Kylin Team " +"<ubuntukylin-members@list.launchpad.net>

" + +#: ../aboutdialog.ui:181 +msgctxt "AboutDialog|" +msgid "home page" +msgstr "主页" + +# 关闭 +#: ../aboutdialog.ui:199 +msgctxt "AboutDialog|" +msgid "Close" +msgstr "关闭" + +#: ../../component/alertdialog.ui:14 +msgctxt "AlertDialog|" +msgid "Form" +msgstr "" + +#: ../../setting/animationwidget.cpp:191 +msgctxt "AnimationWidget|" +msgid "Please select a picture as boot animation" +msgstr "请选择一个图片作为开机动画" + +#: ../../setting/animationwidget.cpp:192 +msgctxt "AnimationWidget|" +msgid "Custom Picture" +msgstr "自定义图片" + +#: ../../setting/animationwidget.cpp:193 +msgctxt "AnimationWidget|" +msgid "Optional BootAnimation" +msgstr "可选启动动画" + +#: ../../setting/animationwidget.cpp:194 +msgctxt "AnimationWidget|" +msgid "OK" +msgstr "确定" + +#: ../../setting/animationwidget.cpp:255 +msgctxt "AnimationWidget|" +msgid "Image Files (*.png *.jpg *.gif)" +msgstr "图片文件(*.png *.jpg *.gif)" + +#: ../../setting/animationwidget.cpp:305 +msgctxt "AnimationWidget|" +msgid "Deleted successfully!" +msgstr "删除成功!" + +#: ../../setting/animationwidget.cpp:314 +msgctxt "AnimationWidget|" +msgid "This is the using animation!" +msgstr "该动画为当前使用动画!" + +#: ../../setting/animationwidget.cpp:324 +msgctxt "AnimationWidget|" +msgid "This is the default animation!" +msgstr "该动画为系统默认动画!" + +#: ../../setting/animationwidget.cpp:334 +msgctxt "AnimationWidget|" +msgid "An unknown error occurred!" +msgstr "发生未知错误!" + +#: ../../info/audiowidget.cpp:37 +msgctxt "AudioWidget|" +msgid "Audio Info" +msgstr "声卡信息" + +#: ../../info/audiowidget.cpp:47 +#, qt-format +msgctxt "AudioWidget|" +msgid "Audio Info %1" +msgstr "声卡信息%1" + +# 框 +#: ../autostartwidget.ui:14 +msgctxt "AutoStartWidget|" +msgid "Form" +msgstr "" + +#: ../autostartwidget.cpp:52 +msgctxt "AutoStartWidget|" +msgid "AutoStart Items:" +msgstr "自启动选项:" + +#~ msgctxt "AutoStartWidget|" +#~ msgid "5" +#~ msgstr "5" + +#: ../autostartwidget.cpp:53 +msgctxt "AutoStartWidget|" +msgid "App" +msgstr "应用程序" + +#: ../autostartwidget.cpp:54 +msgctxt "AutoStartWidget|" +msgid "Status" +msgstr "状态" + +#: ../autostartwidget.cpp:56 +msgctxt "AutoStartWidget|" +msgid "ON Items:" +msgstr "已开启数目:" + +#: ../autostartwidget.cpp:57 +msgctxt "AutoStartWidget|" +msgid "OFF Items:" +msgstr "已关闭数目:" + +#: ../autostartwidget.cpp:208 +msgctxt "AutoStartWidget|" +msgid "Auto Start" +msgstr "自启动" + +#: ../../info/batterywidget.cpp:32 +msgctxt "BatteryWidget|" +msgid "Battery Info" +msgstr "电池信息" + +#: ../../info/boardwidget.cpp:29 +msgctxt "BoardWidget|" +msgid "Board Info" +msgstr "主板信息" + +#: ../boxactionwidget.cpp:70 +msgctxt "BoxActionWidget|" +msgid "" +"Provide a practical and lightweight tool, create fast and convenient " +"experience for you" +msgstr "提供轻巧使用工具,为您打造快捷方便的体验" + +#: ../boxactionwidget.cpp:71 +msgctxt "BoxActionWidget|" +msgid "More App" +msgstr "更多应用" + +#: ../boxwidget.cpp:98 ../boxwidget.cpp:102 +msgctxt "BoxWidget|" +msgid "UbuntuKylin Software Center" +msgstr "优客软件中心" + +#~ msgctxt "BrowserTab|" +#~ msgid "windows系统垃圾文件" +#~ msgstr "windows系统垃圾文件" + +#~ msgctxt "BrowserTab|" +#~ msgid "浏览器缓存目录" +#~ msgstr "浏览器缓存目录" + +#~ msgctxt "BrowserTab|" +#~ msgid "视频播放缓存目录" +#~ msgstr "视频播放缓存目录" + +#~ msgctxt "BrowserTab|" +#~ msgid "Deep cleaning up the browser cache" +#~ msgstr "深度清理浏览器缓存" + +#~ msgctxt "BrowserTab|" +#~ msgid "Deep cleaning up the browser cache, to save disk space" +#~ msgstr "深度清理浏览器缓存,节省磁盘空间" + +#~ msgctxt "BrowserTab|" +#~ msgid "Start scanning" +#~ msgstr "开始扫描" + +#~ msgctxt "BrowserTab|" +#~ msgid "Begin cleanup" +#~ msgstr "开始清理" + +#: ../../info/cdrowwidget.cpp:30 +msgctxt "CDRowWidget|" +msgid "CDROM Info" +msgstr "光驱信息" + +#: ../../cleaner/cacheactionwidget.cpp:72 +msgctxt "CacheActionWidget|" +msgid "Cleaning up the system cache" +msgstr "清理系统缓存" + +#: ../../cleaner/cacheactionwidget.cpp:73 +msgctxt "CacheActionWidget|" +msgid "Deep cleaning up the system cache, to save disk space" +msgstr "深度清理系统缓存,节省磁盘空间" + +#~ msgctxt "CacheTab|" +#~ msgid "windows系统垃圾文件" +#~ msgstr "windows系统垃圾文件" + +#~ msgctxt "CacheTab|" +#~ msgid "浏览器缓存目录" +#~ msgstr "浏览器缓存目录" + +#~ msgctxt "CacheTab|" +#~ msgid "视频播放缓存目录" +#~ msgstr "视频播放缓存目录" + +#~ msgctxt "CacheTab|" +#~ msgid "Cleaning up the system cache" +#~ msgstr "清理系统缓存" + +#~ msgctxt "CacheTab|" +#~ msgid "Deep cleaning up the system cache, to save disk space" +#~ msgstr "深度清理系统缓存,节省磁盘空间" + +#~ msgctxt "CacheTab|" +#~ msgid "Start scanning" +#~ msgstr "开始扫描" + +#~ msgctxt "CacheTab|" +#~ msgid "Begin cleanup" +#~ msgstr "开始清理" + +#: ../cameramanager.cpp:98 +msgctxt "CameraManager|" +msgid "NO found camara" +msgstr "未发现摄像头" + +#: ../cameramanager.cpp:99 +msgctxt "CameraManager|" +msgid "An application to take pictures with the device camera." +msgstr "一个使用摄像头拍照的应用。" + +#: ../cameramanager.cpp:100 +msgctxt "CameraManager|" +msgid "" +"Press the [ESC] button to take picture and turn the camera off , the photo " +"saved in home directory by default." +msgstr "按[退出]键拍照并关闭摄像头,照片默认保存在家目录下。" + +#: ../cameramanager.cpp:101 +msgctxt "CameraManager|" +msgid "Open camera" +msgstr "打开摄像头" + +#: ../cameramanager.cpp:102 +msgctxt "CameraManager|" +msgid "View Photos" +msgstr "浏览照片" + +#: ../cameramanager.cpp:144 +msgctxt "CameraManager|" +msgid "Camera Manager" +msgstr "摄像头管理" + +# 框 +#: ../../cleaner/cleanlistwidget.ui:14 +msgctxt "CleanListWidget|" +msgid "Form" +msgstr "" + +#: ../../cleaner/cleanlistwidget.cpp:45 +msgctxt "CleanListWidget|" +msgid "Clean Items:" +msgstr "清理项:" + +#: ../../component/cleansubgroup.cpp:51 +msgctxt "CleanSubGroup|" +msgid "Custom" +msgstr "自定义" + +#: ../cleaneractionwidget.cpp:142 +msgctxt "CleanerActionWidget|" +msgid "Regular cleaning, let your computer remains the relaxed state" +msgstr "经常清理,让电脑保持最轻松的状态" + +#: ../cleaneractionwidget.cpp:144 +msgctxt "CleanerActionWidget|" +msgid "Start Scan" +msgstr "开始扫描" + +#: ../cleaneractionwidget.cpp:145 +msgctxt "CleanerActionWidget|" +msgid "Start Cleanup" +msgstr "开始清理" + +#: ../cleaneractionwidget.cpp:146 +msgctxt "CleanerActionWidget|" +msgid "Back" +msgstr "返回" + +#: ../cleaneractionwidget.cpp:147 ../cleaneractionwidget.cpp:239 +msgctxt "CleanerActionWidget|" +msgid "Scaning......" +msgstr "正在扫描....." + +#: ../cleaneractionwidget.cpp:157 +msgctxt "CleanerActionWidget|" +msgid "Clean OK......" +msgstr "清理完毕......" + +#: ../cleaneractionwidget.cpp:164 +msgctxt "CleanerActionWidget|" +msgid "Cleaning: " +msgstr "正在清理:" + +#: ../cleaneractionwidget.cpp:168 +msgctxt "CleanerActionWidget|" +msgid ", Percent is: " +msgstr ",进度为:" + +#: ../cleaneractionwidget.cpp:168 +msgctxt "CleanerActionWidget|" +msgid "%, Status is: " +msgstr "%,状态为:" + +#: ../cleaneractionwidget.cpp:176 +msgctxt "CleanerActionWidget|" +msgid "Clean Firefox history......" +msgstr "清理Firefox浏览器历史记录......" + +#: ../cleaneractionwidget.cpp:180 +msgctxt "CleanerActionWidget|" +msgid "Clean Chromium history......" +msgstr "清理Chromium浏览器历史记录......" + +#: ../cleaneractionwidget.cpp:184 +msgctxt "CleanerActionWidget|" +msgid "Clean system history......" +msgstr "清理系统历史痕迹......" + +#: ../cleaneractionwidget.cpp:189 +msgctxt "CleanerActionWidget|" +msgid "Clean apt......" +msgstr "清理Apt......" + +#: ../cleaneractionwidget.cpp:193 +msgctxt "CleanerActionWidget|" +msgid "Start clean apt......" +msgstr "开始清理Apt......" + +#: ../cleaneractionwidget.cpp:198 +msgctxt "CleanerActionWidget|" +msgid "Clean Firefox Cookie:" +msgstr "清理Firefox浏览器Cookie:" + +#: ../cleaneractionwidget.cpp:202 +msgctxt "CleanerActionWidget|" +msgid "Clean Chromium Cookie:" +msgstr "清理Chromium浏览器Cookie:" + +#: ../cleaneractionwidget.cpp:211 ../cleaneractionwidget.cpp:269 +msgctxt "CleanerActionWidget|" +msgid " does not exist" +msgstr "不存在" + +#: ../cleaneractionwidget.cpp:215 ../cleaneractionwidget.cpp:264 +msgctxt "CleanerActionWidget|" +msgid "Chromium Browser is running......" +msgstr "Chromium浏览器正在运行中......" + +#: ../cleaneractionwidget.cpp:223 +msgctxt "CleanerActionWidget|" +msgid "Cache Scan OK......" +msgstr "缓存扫描完成....." + +#: ../cleaneractionwidget.cpp:227 +msgctxt "CleanerActionWidget|" +msgid "Cookies Scan OK......" +msgstr "Cookies扫描完成....." + +#: ../cleaneractionwidget.cpp:231 +msgctxt "CleanerActionWidget|" +msgid "History Scan OK......" +msgstr "历史记录扫描完成....." + +#: ../cleaneractionwidget.cpp:235 +msgctxt "CleanerActionWidget|" +msgid "Packages Scan OK......" +msgstr "包扫描完成......" + +#: ../cleaneractionwidget.cpp:253 +msgctxt "CleanerActionWidget|" +msgid "Error: " +msgstr "错误:" + +#: ../cleaneractionwidget.cpp:256 +msgctxt "CleanerActionWidget|" +msgid "Firefox Browser does not be installed......" +msgstr "没有安装Firefox浏览器......" + +#: ../cleaneractionwidget.cpp:260 +msgctxt "CleanerActionWidget|" +msgid "Chromium Browser does not be installed......" +msgstr "没有安装Chromium浏览器......" + +#: ../cleaneractionwidget.cpp:288 +msgctxt "CleanerActionWidget|" +msgid "Ready to Cleanup......" +msgstr "准备清理......" + +#: ../../cleaner/cleanerdetailwidget.cpp:228 +msgctxt "CleanerDetailWidget|" +msgid "Apt Cache Clean Items" +msgstr "Apt缓存清理项" + +#: ../../cleaner/cleanerdetailwidget.cpp:234 +msgctxt "CleanerDetailWidget|" +msgid "Apt Cache count:" +msgstr "Apt缓存总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:274 +#: ../../cleaner/cleanerdetailwidget.cpp:368 +msgctxt "CleanerDetailWidget|" +msgid "Software Cache Clean Items" +msgstr "软件中心缓存清理项" + +#: ../../cleaner/cleanerdetailwidget.cpp:280 +msgctxt "CleanerDetailWidget|" +msgid "Software Cache count:" +msgstr "软件中心缓存总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:320 +#: ../../cleaner/cleanerdetailwidget.cpp:413 +#: ../../cleaner/cleanerdetailwidget.cpp:463 +#: ../../cleaner/cleanerdetailwidget.cpp:510 +#: ../../cleaner/cleanerdetailwidget.cpp:643 +#: ../../cleaner/cleanerdetailwidget.cpp:689 +#: ../../cleaner/cleanerdetailwidget.cpp:735 +msgctxt "CleanerDetailWidget|" +msgid "Thumbnails Cache Clean Items" +msgstr "缩略图缓存清理项" + +#: ../../cleaner/cleanerdetailwidget.cpp:326 +msgctxt "CleanerDetailWidget|" +msgid "Thumbnails Cache Count:" +msgstr "缩略图缓存总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:373 +msgctxt "CleanerDetailWidget|" +msgid "Firefox Cache Count:" +msgstr "Firefox浏览器缓存总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:418 +msgctxt "CleanerDetailWidget|" +msgid "Chromium Cache Count:" +msgstr "Chromium浏览器缓存总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:468 +msgctxt "CleanerDetailWidget|" +msgid "Firefox Cookies Count:" +msgstr "Firefox Cookies总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:515 +msgctxt "CleanerDetailWidget|" +msgid "Chromium Cookies Count:" +msgstr "Chromium Cookies总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:566 +msgctxt "CleanerDetailWidget|" +msgid "Firefox History Count:" +msgstr "Firefox 历史记录总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:603 +msgctxt "CleanerDetailWidget|" +msgid "Chromium History Count:" +msgstr "Chromium历史记录总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:623 +msgctxt "CleanerDetailWidget|" +msgid "System History Count:" +msgstr "系统历史痕迹总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:648 +msgctxt "CleanerDetailWidget|" +msgid "Package Unneed Count:" +msgstr "不需要的包总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:694 +msgctxt "CleanerDetailWidget|" +msgid "Package oldkernel Count:" +msgstr "旧内核包总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:740 +msgctxt "CleanerDetailWidget|" +msgid "Package configfile Count:" +msgstr "包配置文件总数:" + +#: ../../cleaner/cleanerdetailwidget.cpp:1268 +msgctxt "CleanerDetailWidget|" +msgid "Clean args is empty!" +msgstr "清理参数为空!" + +# 框 +#: ../../cleaner/cleanerdetailwidget.ui:14 +msgctxt "CleanerDetailWidget|" +msgid "Form" +msgstr "" + +#: ../../cleaner/cleaneritems.cpp:143 +msgctxt "CleanerItems|" +msgid "OK" +msgstr "确定" + +#: ../../cleaner/cleanermainwidget.cpp:38 +msgctxt "CleanerMainWidget|" +msgid "Cleanup Package Cache" +msgstr "清理包缓存" + +#: ../../cleaner/cleanermainwidget.cpp:38 +msgctxt "CleanerMainWidget|" +msgid "Cleanup Software Center Cache" +msgstr "清理软件中心缓存" + +#: ../../cleaner/cleanermainwidget.cpp:38 +msgctxt "CleanerMainWidget|" +msgid "Cleanup Thumbnails Cache" +msgstr "清理缩略图缓存" + +#: ../../cleaner/cleanermainwidget.cpp:38 +msgctxt "CleanerMainWidget|" +msgid "Cleanup FireFox Cache" +msgstr "清理火狐浏览器缓存" + +#: ../../cleaner/cleanermainwidget.cpp:38 +msgctxt "CleanerMainWidget|" +msgid "Cleanup Chromium Cache" +msgstr "清理chromium缓存" + +#: ../../cleaner/cleanermainwidget.cpp:40 +msgctxt "CleanerMainWidget|" +msgid "Cache Items" +msgstr "缓存选项" + +#: ../../cleaner/cleanermainwidget.cpp:45 +msgctxt "CleanerMainWidget|" +msgid "System Cache" +msgstr "系统缓存" + +#: ../../cleaner/cleanermainwidget.cpp:45 +msgctxt "CleanerMainWidget|" +msgid "Cleanup cache of system, software-center, thumbnails and browser" +msgstr "清除包、软件中心、缩略图和浏览器缓存" + +#: ../../cleaner/cleanermainwidget.cpp:52 +msgctxt "CleanerMainWidget|" +msgid "Uninstall unnecessary procedures" +msgstr "卸载不必要的程序" + +#: ../../cleaner/cleanermainwidget.cpp:52 +msgctxt "CleanerMainWidget|" +msgid "Uninstall old kernel packages" +msgstr "卸载旧版本内核" + +#: ../../cleaner/cleanermainwidget.cpp:52 +msgctxt "CleanerMainWidget|" +msgid "Cleanup software configfile" +msgstr "清理软件残余配置文件" + +#: ../../cleaner/cleanermainwidget.cpp:55 +msgctxt "CleanerMainWidget|" +msgid "Package Items" +msgstr "包选项" + +#: ../../cleaner/cleanermainwidget.cpp:59 +msgctxt "CleanerMainWidget|" +msgid "Packages and configfile" +msgstr "包垃圾和残余配置文件" + +#: ../../cleaner/cleanermainwidget.cpp:59 +msgctxt "CleanerMainWidget|" +msgid "" +"Cleaning up the software that installed by other software bundled, old " +"kernel packages and configfile, to improve system performance" +msgstr "清除不必要的程序、旧内核包、配置文件,提升系统性能" + +#: ../../cleaner/cleanermainwidget.cpp:67 +msgctxt "CleanerMainWidget|" +msgid "Cleanup the Cookies saving in Firefox" +msgstr "清理火狐浏览器的Cookies" + +#: ../../cleaner/cleanermainwidget.cpp:67 +msgctxt "CleanerMainWidget|" +msgid "Cleanup the Cookies saving in Chromium" +msgstr "清理Chromium浏览器的Cookies" + +#: ../../cleaner/cleanermainwidget.cpp:70 +msgctxt "CleanerMainWidget|" +msgid "Cookies Items" +msgstr "Cookies选项" + +#: ../../cleaner/cleanermainwidget.cpp:74 +msgctxt "CleanerMainWidget|" +msgid "Cookies" +msgstr "Cookies" + +#: ../../cleaner/cleanermainwidget.cpp:74 +msgctxt "CleanerMainWidget|" +msgid "Clean up user login information, support Firefox and Chromium browser" +msgstr "清除上网、游戏、购物等记录" + +#: ../../cleaner/cleanermainwidget.cpp:82 +msgctxt "CleanerMainWidget|" +msgid "Clean up the Firefox Internet records" +msgstr "清理火狐访问记录" + +#: ../../cleaner/cleanermainwidget.cpp:82 +msgctxt "CleanerMainWidget|" +msgid "Clean up the Chromium Internet records" +msgstr "清理Chromium访问记录" + +#: ../../cleaner/cleanermainwidget.cpp:82 +msgctxt "CleanerMainWidget|" +msgid "Clean up the recently opened documents records" +msgstr "清理最近打开的文件记录" + +#: ../../cleaner/cleanermainwidget.cpp:85 +msgctxt "CleanerMainWidget|" +msgid "Trace Items" +msgstr "访问痕迹选项" + +#: ../../cleaner/cleanermainwidget.cpp:89 +msgctxt "CleanerMainWidget|" +msgid "History trace" +msgstr "历史痕迹" + +#: ../../cleaner/cleanermainwidget.cpp:89 +msgctxt "CleanerMainWidget|" +msgid "Cleaning the internet and opened documents recently records" +msgstr "清除浏览器和系统使用痕迹" + +#: ../../cleaner/cleanermainwidget.cpp:159 +msgctxt "CleanerMainWidget|" +msgid "Please select the items you want to clean" +msgstr "请选择您想清理的选项" + +#: ../../cleaner/cleanermainwidget.cpp:168 +msgctxt "CleanerMainWidget|" +msgid "Scan args is empty!" +msgstr "扫描参数为空!" + +#~ msgctxt "CommonCheckBox|" +#~ msgid "Custom" +#~ msgstr "自定义" + +#: ../../info/computerpage.cpp:55 ../../info/computerpage.cpp:104 +#: ../../info/computerpage.cpp:109 ../../info/computerpage.cpp:111 +#, qt-format +msgctxt "ComputerPage|" +msgid "%1" +msgstr "" + +#: ../../info/computerpage.cpp:97 ../../info/computerpage.cpp:101 +msgctxt "ComputerPage|" +msgid " Minutes" +msgstr " 分钟" + +#: ../../info/computerpage.cpp:101 +msgctxt "ComputerPage|" +msgid " Hours " +msgstr " 小时" + +#: ../../info/computerpage.cpp:136 ../../info/computerpage.cpp:256 +msgctxt "ComputerPage|" +msgid "Audio Model" +msgstr "声卡型号" + +#: ../../info/computerpage.cpp:138 ../../info/computerpage.cpp:191 +#: ../../info/computerpage.cpp:204 ../../info/computerpage.cpp:299 +#: ../../info/computerpage.cpp:324 ../../info/computerpage.cpp:340 +#: ../../info/computerpage.cpp:355 +msgctxt "ComputerPage|" +msgid "Vendor" +msgstr "制造商" + +#: ../../info/computerpage.cpp:140 ../../info/computerpage.cpp:318 +#: ../../info/computerpage.cpp:328 ../../info/computerpage.cpp:346 +msgctxt "ComputerPage|" +msgid "Bus Address" +msgstr "总线地址" + +#: ../../info/computerpage.cpp:142 +msgctxt "ComputerPage|" +msgid "Audio Driver" +msgstr "声卡驱动" + +#: ../../info/computerpage.cpp:145 ../../info/computerpage.cpp:193 +#: ../../info/computerpage.cpp:288 ../../info/computerpage.cpp:330 +msgctxt "ComputerPage|" +msgid "Device Name" +msgstr "设备名" + +#: ../../info/computerpage.cpp:147 +msgctxt "ComputerPage|" +msgid "Manufacturer" +msgstr "发行商" + +#: ../../info/computerpage.cpp:161 ../../info/computerpage.cpp:357 +msgctxt "ComputerPage|" +msgid "Model" +msgstr "型号" + +#: ../../info/computerpage.cpp:163 +msgctxt "ComputerPage|" +msgid "Technology" +msgstr "技术" + +#: ../../info/computerpage.cpp:165 +msgctxt "ComputerPage|" +msgid "Voltage" +msgstr "电压" + +#: ../../info/computerpage.cpp:167 +msgctxt "ComputerPage|" +msgid "Energy Designed" +msgstr "能量(设计)" + +#: ../../info/computerpage.cpp:169 +msgctxt "ComputerPage|" +msgid "Energy Full" +msgstr "满时能量" + +#: ../../info/computerpage.cpp:171 +msgctxt "ComputerPage|" +msgid "Energy Now" +msgstr "能量" + +#: ../../info/computerpage.cpp:173 ../../info/computerpage.cpp:180 +#: ../../info/computerpage.cpp:197 ../../info/computerpage.cpp:206 +#: ../../info/computerpage.cpp:292 ../../info/computerpage.cpp:301 +#: ../../info/computerpage.cpp:350 ../../info/computerpage.cpp:361 +msgctxt "ComputerPage|" +msgid "Serial Number" +msgstr "序列号" + +#: ../../info/computerpage.cpp:176 +msgctxt "ComputerPage|" +msgid "Motherboard Model" +msgstr "主板型号" + +#: ../../info/computerpage.cpp:178 +msgctxt "ComputerPage|" +msgid "Motherboard Vendor" +msgstr "主板产商" + +#: ../../info/computerpage.cpp:182 +msgctxt "ComputerPage|" +msgid "BIOS Vendor" +msgstr "BIOS产商" + +#: ../../info/computerpage.cpp:184 +msgctxt "ComputerPage|" +msgid "BIOS Version" +msgstr "BIOS版本" + +#: ../../info/computerpage.cpp:186 +msgctxt "ComputerPage|" +msgid "Release Date" +msgstr "发布日期" + +#: ../../info/computerpage.cpp:189 +msgctxt "ComputerPage|" +msgid "CD-ROM Model" +msgstr "光驱型号" + +#: ../../info/computerpage.cpp:195 ../../info/computerpage.cpp:290 +msgctxt "ComputerPage|" +msgid "Firmware Version" +msgstr "固件版本" + +#: ../../info/computerpage.cpp:202 ../../info/computerpage.cpp:228 +msgctxt "ComputerPage|" +msgid "CPU" +msgstr "处理器" + +#: ../../info/computerpage.cpp:208 +msgctxt "ComputerPage|" +msgid "Socket/Slot" +msgstr "插座/插槽" + +#: ../../info/computerpage.cpp:210 +msgctxt "ComputerPage|" +msgid "Maximum Frequency" +msgstr "最大主频" + +#: ../../info/computerpage.cpp:212 +msgctxt "ComputerPage|" +msgid "Current Frequency" +msgstr "当前主频" + +#: ../../info/computerpage.cpp:214 +msgctxt "ComputerPage|" +msgid "FSB" +msgstr "前端总线" + +#: ../../info/computerpage.cpp:216 +msgctxt "ComputerPage|" +msgid "Core Number" +msgstr "核心数目" + +#: ../../info/computerpage.cpp:218 +msgctxt "ComputerPage|" +msgid "Thread" +msgstr "线程" + +#: ../../info/computerpage.cpp:220 +msgctxt "ComputerPage|" +msgid "L1 Cache" +msgstr "1级缓存" + +#: ../../info/computerpage.cpp:222 +msgctxt "ComputerPage|" +msgid "L2 Cache" +msgstr "2级缓存" + +#: ../../info/computerpage.cpp:222 +msgctxt "ComputerPage|" +msgid "1500a v1.0 64 bits" +msgstr "1500a v1.0 64位" + +#: ../../info/computerpage.cpp:222 +msgctxt "ComputerPage|" +msgid "phytium" +msgstr "飞腾" + +#: ../../info/computerpage.cpp:222 +msgctxt "ComputerPage|" +msgid "4 cores" +msgstr "4核" + +#: ../../info/computerpage.cpp:222 +msgctxt "ComputerPage|" +msgid "4 thread/core" +msgstr "4线程/核" + +#: ../../info/computerpage.cpp:226 +msgctxt "ComputerPage|" +msgid "Desktop Environment" +msgstr "桌面环境" + +#: ../../info/computerpage.cpp:230 +msgctxt "ComputerPage|" +msgid "Host Name" +msgstr "主机名" + +#: ../../info/computerpage.cpp:232 +msgctxt "ComputerPage|" +msgid "Memery Capacity" +msgstr "内存容量" + +#: ../../info/computerpage.cpp:234 +msgctxt "ComputerPage|" +msgid "Shell" +msgstr "Shell终端" + +#: ../../info/computerpage.cpp:236 +msgctxt "ComputerPage|" +msgid "Distribution" +msgstr "发行版" + +#: ../../info/computerpage.cpp:238 +msgctxt "ComputerPage|" +msgid "Language" +msgstr "语言" + +#: ../../info/computerpage.cpp:240 +msgctxt "ComputerPage|" +msgid "User" +msgstr "用户" + +#: ../../info/computerpage.cpp:242 +msgctxt "ComputerPage|" +msgid "Home Folder" +msgstr "用户主目录" + +#: ../../info/computerpage.cpp:246 +msgctxt "ComputerPage|" +msgid "Host bridge" +msgstr "主桥" + +#: ../../info/computerpage.cpp:248 +msgctxt "ComputerPage|" +msgid "VGA Model" +msgstr "VGA兼容控制器" + +#: ../../info/computerpage.cpp:250 +msgctxt "ComputerPage|" +msgid "USB Model" +msgstr "USB控制器" + +#: ../../info/computerpage.cpp:252 +msgctxt "ComputerPage|" +msgid "Communication Model" +msgstr "通信控制器" + +#: ../../info/computerpage.cpp:254 +msgctxt "ComputerPage|" +msgid "Ethernet Model" +msgstr "以太网控制器" + +#: ../../info/computerpage.cpp:258 +msgctxt "ComputerPage|" +msgid "PCI bridge" +msgstr "PCI桥" + +#: ../../info/computerpage.cpp:260 +msgctxt "ComputerPage|" +msgid "ISA bridge" +msgstr "ISA桥" + +#: ../../info/computerpage.cpp:262 +msgctxt "ComputerPage|" +msgid "SATA Model" +msgstr "SATA控制器" + +#: ../../info/computerpage.cpp:264 +msgctxt "ComputerPage|" +msgid "SMBus" +msgstr "系统管理总线" + +#: ../../info/computerpage.cpp:266 +msgctxt "ComputerPage|" +msgid "System peripheral" +msgstr "系统外围" + +#: ../../info/computerpage.cpp:268 +msgctxt "ComputerPage|" +msgid "Driver in use" +msgstr "使用的驱动" + +#: ../../info/computerpage.cpp:270 +msgctxt "ComputerPage|" +msgid "existing drivers" +msgstr "可选的驱动" + +#: ../../info/computerpage.cpp:272 +msgctxt "ComputerPage|" +msgid "IDE interface" +msgstr "IDE接口" + +#: ../../info/computerpage.cpp:274 +msgctxt "ComputerPage|" +msgid "SP controller" +msgstr "信号处理控制器" + +#: ../../info/computerpage.cpp:276 +msgctxt "ComputerPage|" +msgid "Network controller" +msgstr "网络控制器" + +#: ../../info/computerpage.cpp:278 +msgctxt "ComputerPage|" +msgid "Multimedia audio controller" +msgstr "多媒体音频控制器" + +#: ../../info/computerpage.cpp:282 +msgctxt "ComputerPage|" +msgid "HDD Model" +msgstr "硬盘型号" + +#: ../../info/computerpage.cpp:284 +msgctxt "ComputerPage|" +msgid "HDD Vendor" +msgstr "硬盘厂商" + +#: ../../info/computerpage.cpp:286 +msgctxt "ComputerPage|" +msgid "HDD Capacity" +msgstr "硬盘容量" + +#: ../../info/computerpage.cpp:295 +msgctxt "ComputerPage|" +msgid "Slot Number" +msgstr "插槽号" + +#: ../../info/computerpage.cpp:297 +msgctxt "ComputerPage|" +msgid "Memory Model" +msgstr "内存型号" + +#: ../../info/computerpage.cpp:303 +msgctxt "ComputerPage|" +msgid "Memory Size" +msgstr "内存大小" + +#: ../../info/computerpage.cpp:305 +msgctxt "ComputerPage|" +msgid "Data Width" +msgstr "数据宽度" + +#: ../../info/computerpage.cpp:307 +msgctxt "ComputerPage|" +msgid "Memory Info" +msgstr "内存条信息" + +#: ../../info/computerpage.cpp:310 +msgctxt "ComputerPage|" +msgid "Graphics Card Model" +msgstr "显卡型号" + +#: ../../info/computerpage.cpp:312 +msgctxt "ComputerPage|" +msgid "Current Graphics Card" +msgstr "当前显卡" + +#: ../../info/computerpage.cpp:314 +msgctxt "ComputerPage|" +msgid "Graphics Card Vendor" +msgstr "显卡制造商" + +#: ../../info/computerpage.cpp:316 +msgctxt "ComputerPage|" +msgid "Graphics Driver" +msgstr "显卡驱动" + +#: ../../info/computerpage.cpp:322 +msgctxt "ComputerPage|" +msgid "NIC Model" +msgstr "有线网卡型号" + +#: ../../info/computerpage.cpp:326 +msgctxt "ComputerPage|" +msgid "NIC Driver" +msgstr "有线网卡驱动" + +#: ../../info/computerpage.cpp:332 ../../info/computerpage.cpp:352 +msgctxt "ComputerPage|" +msgid "IP Address" +msgstr "IP地址" + +#: ../../info/computerpage.cpp:334 +msgctxt "ComputerPage|" +msgid "Mac Address" +msgstr "MAC地址" + +#: ../../info/computerpage.cpp:336 +msgctxt "ComputerPage|" +msgid "Connection Status" +msgstr "连接状态" + +#: ../../info/computerpage.cpp:338 +msgctxt "ComputerPage|" +msgid "Max Bandwidth" +msgstr "最大带宽" + +#: ../../info/computerpage.cpp:342 +msgctxt "ComputerPage|" +msgid "WLan NIC Driver" +msgstr "无线网卡驱动" + +#: ../../info/computerpage.cpp:344 +msgctxt "ComputerPage|" +msgid "WLan NIC Model" +msgstr "网卡型号" + +#: ../../info/computerpage.cpp:348 +msgctxt "ComputerPage|" +msgid "Device Name:" +msgstr "设备名称:" + +#: ../../info/computerpage.cpp:359 +msgctxt "ComputerPage|" +msgid "Version" +msgstr "电脑版本" + +#: ../../info/computerpage.cpp:363 +msgctxt "ComputerPage|" +msgid "Hostname" +msgstr "主机名" + +#: ../../info/computerpage.cpp:365 +msgctxt "ComputerPage|" +msgid "Running Time" +msgstr "持续运行时间" + +#: ../../info/computerpage.cpp:367 +msgctxt "ComputerPage|" +msgid "OS Types" +msgstr "操作系统类型" + +#: ../../info/computerpage.cpp:369 +msgctxt "ComputerPage|" +msgid "OS Version" +msgstr "操作系统版本" + +#: ../../info/computerpage.cpp:371 +msgctxt "ComputerPage|" +msgid "Kernel Bit" +msgstr "系统位数" + +#: ../../info/computerpage.cpp:373 +msgctxt "ComputerPage|" +msgid "Kernel Version" +msgstr "内核版本" + +#: ../../info/computerpage.cpp:375 +msgctxt "ComputerPage|" +msgid "Kernel Arch" +msgstr "内核架构" + +#: ../../info/cpuwidget.cpp:30 +msgctxt "CpuWidget|" +msgid "CPU Info" +msgstr "处理器信息" + +#: ../../setting/deadpixelwidget.cpp:75 +msgctxt "DeadpixelWidget|" +msgid "" +"Left-click to change the color, right-click to exit from this detection." +msgstr "鼠标左键点击更改颜色,右键点击推出坏点检测。" + +#: ../../setting/deadpixelwidget.cpp:76 +msgctxt "DeadpixelWidget|" +msgid "OK" +msgstr "确定" + +#: ../../info/desktopwidget.cpp:30 +msgctxt "DesktopWidget|" +msgid "Desktop Info" +msgstr "桌面环境信息" + +#: ../../info/driverwidget.cpp:32 +msgctxt "DriverWidget|" +msgid "Driver Info" +msgstr "驱动信息" + +#: ../../setting/fontwidget.cpp:63 ../../setting/fontwidget.cpp:64 +#: ../../setting/fontwidget.cpp:65 ../../setting/fontwidget.cpp:66 +#: ../../setting/fontwidget.cpp:67 +msgctxt "FontWidget|" +msgid "Click here to change font" +msgstr "点击此处更换字体" + +#: ../../setting/fontwidget.cpp:166 +msgctxt "FontWidget|" +msgid "Default Font" +msgstr "默认字体" + +#: ../../setting/fontwidget.cpp:167 +msgctxt "FontWidget|" +msgid "Desktop Font" +msgstr "桌面字体" + +#: ../../setting/fontwidget.cpp:168 +msgctxt "FontWidget|" +msgid "Monospace Font" +msgstr "等宽字体" + +#: ../../setting/fontwidget.cpp:169 +msgctxt "FontWidget|" +msgid "Document Font" +msgstr "文档字体" + +#: ../../setting/fontwidget.cpp:170 +msgctxt "FontWidget|" +msgid "Titlebar Font" +msgstr "标题栏字体" + +#: ../../setting/fontwidget.cpp:171 +msgctxt "FontWidget|" +msgid "Global Font Scaling" +msgstr "全局字体缩放" + +#: ../../setting/fontwidget.cpp:172 +msgctxt "FontWidget|" +msgid "Hinting" +msgstr "平滑" + +#: ../../setting/fontwidget.cpp:173 +msgctxt "FontWidget|" +msgid "Antialiasing" +msgstr "反锯齿" + +#: ../../info/hdwidget.cpp:35 +msgctxt "HDWidget|" +msgid "HardWare Info" +msgstr "硬盘信息" + +# 硬盘信息 %1 +#: ../../info/hdwidget.cpp:45 +#, qt-format +msgctxt "HDWidget|" +msgid "HardWare Info %1" +msgstr "" + +#: ../homeactionwidget.cpp:132 ../homeactionwidget.cpp:231 +msgctxt "HomeActionWidget|" +msgid "The lastest cleanup time is " +msgstr "上一次清理时间是" + +#: ../homeactionwidget.cpp:138 ../homeactionwidget.cpp:184 +msgctxt "HomeActionWidget|" +msgid "The lastest scan time is " +msgstr "上一次扫描时间是" + +#: ../homeactionwidget.cpp:142 +msgctxt "HomeActionWidget|" +msgid "You have not implemented the one key scan and clean-up operation." +msgstr "您还没有执行过一键扫描和一键清理操作。" + +#: ../homeactionwidget.cpp:163 +msgctxt "HomeActionWidget|" +msgid "" +"Quick clean up system trash, saving disk space and improving the system " +"efficiency!" +msgstr "一键清理系统垃圾,帮您节省磁盘空间,让系统运行更加有效率!" + +#: ../homeactionwidget.cpp:164 +msgctxt "HomeActionWidget|" +msgid "Start Scan" +msgstr "开始扫描" + +#: ../homeactionwidget.cpp:165 +msgctxt "HomeActionWidget|" +msgid "Start Cleanup" +msgstr "开始清理" + +#: ../homeactionwidget.cpp:166 +msgctxt "HomeActionWidget|" +msgid "Back" +msgstr "返回" + +#: ../homeactionwidget.cpp:167 +msgctxt "HomeActionWidget|" +msgid "Scanning......" +msgstr "正在扫描....." + +#: ../homeactionwidget.cpp:177 +msgctxt "HomeActionWidget|" +msgid "Scanning:" +msgstr "正在扫描:" + +#: ../homeactionwidget.cpp:183 +msgctxt "HomeActionWidget|" +msgid "Scan Over" +msgstr "扫描完成" + +#: ../homeactionwidget.cpp:215 +msgctxt "HomeActionWidget|" +msgid "Cleaning......" +msgstr "正在清理......." + +#: ../homeactionwidget.cpp:220 +msgctxt "HomeActionWidget|" +msgid "Garbage Cleanup OK......" +msgstr "垃圾清理完成......" + +#: ../homeactionwidget.cpp:223 +msgctxt "HomeActionWidget|" +msgid "History Cleanup OK......" +msgstr "历史记录清理完成......" + +#: ../homeactionwidget.cpp:226 +msgctxt "HomeActionWidget|" +msgid "Cookies Cleanup OK......" +msgstr "Cookies清理完成......" + +#: ../homeactionwidget.cpp:232 +msgctxt "HomeActionWidget|" +msgid "Cleanup Cookies:" +msgstr "清理了Cookies:" + +#: ../homeactionwidget.cpp:232 +msgctxt "HomeActionWidget|" +msgid "; Garbage:" +msgstr ";垃圾:" + +#: ../homeactionwidget.cpp:232 +msgctxt "HomeActionWidget|" +msgid "; Historical records:" +msgstr ";历史记录:" + +#: ../homeactionwidget.cpp:262 +msgctxt "HomeActionWidget|" +msgid "Cleaning up history trace of Firefox..." +msgstr "正在清理Firefox浏览器的历史痕迹......" + +#: ../homeactionwidget.cpp:265 +msgctxt "HomeActionWidget|" +msgid "Firefox history trace had been cleared!" +msgstr "Firefox浏览器历史痕迹清理完成!" + +#: ../homeactionwidget.cpp:270 +msgctxt "HomeActionWidget|" +msgid "Cleaning up history trace of Chromium..." +msgstr "正在清理Chromium浏览器的历史痕迹......" + +#: ../homeactionwidget.cpp:273 +msgctxt "HomeActionWidget|" +msgid "Chromium history trace had been cleared!" +msgstr "Chromium浏览器的历史痕迹清理完成!" + +#: ../homeactionwidget.cpp:278 +msgctxt "HomeActionWidget|" +msgid "Cleaning up Cookies of Firefox..." +msgstr "正在清理Firefox浏览器的Cookies......" + +#: ../homeactionwidget.cpp:281 +msgctxt "HomeActionWidget|" +msgid "Firefox Cookies had been cleared!" +msgstr "Firefox浏览器的Cookies清理完成!" + +#: ../homeactionwidget.cpp:286 +msgctxt "HomeActionWidget|" +msgid "Cleaning up Cookies of Chromium..." +msgstr "正在清理Chromium浏览器的Cookies......" + +#: ../homeactionwidget.cpp:289 +msgctxt "HomeActionWidget|" +msgid "Chromium Cookies had been cleared!" +msgstr "Chromium浏览器的Cookies清理完成!" + +#: ../homeactionwidget.cpp:294 +msgctxt "HomeActionWidget|" +msgid "Apt cache had been cleared!" +msgstr "Apt缓存清理完成!" + +#: ../homeactionwidget.cpp:297 +msgctxt "HomeActionWidget|" +msgid "Cleaning up Apt cache: " +msgstr "正在清理Apt缓存:" + +#: ../homeactionwidget.cpp:302 +msgctxt "HomeActionWidget|" +msgid "Software Center cache had been cleared!" +msgstr "软件中心缓存清理完成!" + +#: ../homeactionwidget.cpp:305 +msgctxt "HomeActionWidget|" +msgid "Cleaning up Software Center cache: " +msgstr "正在清理软件中心缓存:" + +#: ../homeactionwidget.cpp:329 +msgctxt "HomeActionWidget|" +msgid "Ready to Cleanup......" +msgstr "准备清理......" + +#: ../homepage.cpp:152 +msgctxt "HomePage|" +msgid "Boot Manager" +msgstr "开机启动项管理" + +#: ../homepage.cpp:152 +msgctxt "HomePage|" +msgid "Camera" +msgstr "摄像头" + +#: ../homepage.cpp:220 +msgctxt "HomePage|" +msgid "Current Version Number" +msgstr "当前版本号" + +#: ../homepage.cpp:221 +msgctxt "HomePage|" +msgid "Update to the lastest version, make it work better" +msgstr "更新至最新版本,使软件更好用" + +#: ../homepage.cpp:222 +msgctxt "HomePage|" +msgid "Check new version" +msgstr "检查最新版本" + +#: ../homepage.cpp:223 +msgctxt "HomePage|" +msgid "Common toolbox" +msgstr "工具箱" + +#: ../homepage.cpp:224 +msgctxt "HomePage|" +msgid "Fast and practical, making the system more personalized" +msgstr "更快更好,让系统更具个性化" + +#: ../homepage.cpp:225 ../homepage.cpp:226 +msgctxt "HomePage|" +msgid "More" +msgstr "更多" + +#: ../../setting/iconwidget.cpp:182 +msgctxt "IconWidget|" +msgid "Icon theme" +msgstr "图标主题" + +#: ../../setting/iconwidget.cpp:183 +msgctxt "IconWidget|" +msgid "Show Desktop Icons" +msgstr "显示桌面图标" + +#: ../../setting/iconwidget.cpp:184 +msgctxt "IconWidget|" +msgid "Home Folder" +msgstr "用户主目录" + +#: ../../setting/iconwidget.cpp:185 +msgctxt "IconWidget|" +msgid "Network" +msgstr "网络" + +#: ../../setting/iconwidget.cpp:186 +msgctxt "IconWidget|" +msgid "Trash" +msgstr "回收站" + +#: ../../setting/iconwidget.cpp:187 +msgctxt "IconWidget|" +msgid "Mounted Volumes" +msgstr "挂载卷" + +#: ../infoactionwidget.cpp:61 +msgctxt "InfoActionWidget|" +msgid "" +"Understand hardware information, provide more convenient channel to obtain " +"hardware information" +msgstr "了解电脑硬件详细信息,为用户提供更加方便的获取硬件信息渠道" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Computer" +msgstr "电脑概述" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Desktop" +msgstr "桌面环境" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "CPU" +msgstr "处理器" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Memory" +msgstr "内存" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Motherboard" +msgstr "主板" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "HD" +msgstr "硬盘" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "NIC" +msgstr "网卡" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "VGA" +msgstr "显卡" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Audio" +msgstr "声卡" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "CD-ROM" +msgstr "光驱" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Battery" +msgstr "电池" + +#: ../infowidget.cpp:36 +msgctxt "InfoWidget|" +msgid "Device Driver" +msgstr "设备驱动" + +#: ../../component/kylinfontdialog.cpp:176 +msgctxt "KylinFontDialog|" +msgid "Current Font" +msgstr "当前字体" + +#: ../../component/kylinfontdialog.cpp:177 +msgctxt "KylinFontDialog|" +msgid "Font" +msgstr "字体" + +#: ../../component/kylinfontdialog.cpp:178 +msgctxt "KylinFontDialog|" +msgid "Style" +msgstr "风格" + +#: ../../component/kylinfontdialog.cpp:179 +msgctxt "KylinFontDialog|" +msgid "Size" +msgstr "大小" + +#: ../../component/kylinfontdialog.cpp:180 +msgctxt "KylinFontDialog|" +msgid "View" +msgstr "视图" + +#: ../../component/kylinfontdialog.cpp:181 +msgctxt "KylinFontDialog|" +msgid "OK" +msgstr "确定" + +#: ../../component/kylinfontdialog.cpp:182 +msgctxt "KylinFontDialog|" +msgid "Cancel" +msgstr "取消" + +#: ../../component/kylinfontdialog.cpp:211 +msgctxt "KylinFontDialog|" +msgid "Tips" +msgstr "提示" + +#: ../../component/kylinfontdialog.cpp:212 +msgctxt "KylinFontDialog|" +msgid "You haven't change the font, please choose the font!" +msgstr "您没有更改字体,请选择需要更改的字体!" + +#: ../../component/kylinfontdialog.cpp:225 +msgctxt "KylinFontDialog|" +msgid "Font Dialog" +msgstr "字体对话框" + +#: ../../component/kylinmenu.cpp:48 +msgctxt "KylinMenu|" +msgid "Forum Help" +msgstr "论坛求助" + +#: ../../component/kylinmenu.cpp:50 +msgctxt "KylinMenu|" +msgid "Feedback" +msgstr "问题反馈" + +#: ../../component/kylinmenu.cpp:52 +msgctxt "KylinMenu|" +msgid "About us" +msgstr "关于我们" + +#: ../../component/kylinmenu.cpp:54 +msgctxt "KylinMenu|" +msgid "Help" +msgstr "帮助" + +#: ../../component/kylinswitcher.cpp:82 +msgctxt "KylinSwitcher|" +msgid "ON" +msgstr "已开启" + +#: ../../component/kylinswitcher.cpp:91 +msgctxt "KylinSwitcher|" +msgid "OFF" +msgstr "已关闭" + +#: ../../setting/launcherwidget.cpp:133 +msgctxt "LauncherWidget|" +msgid "Launcher icon size" +msgstr "启动器图标尺寸" + +#: ../../setting/launcherwidget.cpp:134 +msgctxt "LauncherWidget|" +msgid "Launcher hide mode" +msgstr "启动器自动隐藏" + +#: ../../setting/launcherwidget.cpp:135 +msgctxt "LauncherWidget|" +msgid "Display desktop icon" +msgstr "显示桌面图标" + +#: ../../setting/launcherwidget.cpp:136 +msgctxt "LauncherWidget|" +msgid "Launcher Transparency" +msgstr "启动器透明度" + +#: ../../setting/launcherwidget.cpp:137 +msgctxt "LauncherWidget|" +msgid "Icon Background" +msgstr "图标背景" + +#: ../loginwidget.cpp:106 +msgctxt "LoginWidget|" +msgid "Login Youker Account" +msgstr "登录优客帐号" + +#: ../loginwidget.cpp:107 +msgctxt "LoginWidget|" +msgid "Logout" +msgstr "注销" + +# 主界面 +#: ../mainwindow.ui:17 +msgctxt "MainWindow|" +msgid "MainWindow" +msgstr "" + +#: ../../info/memorywidget.cpp:36 +msgctxt "MemoryWidget|" +msgid "Memory Info" +msgstr "内存条信息" + +#: ../../info/memorywidget.cpp:46 +#, qt-format +msgctxt "MemoryWidget|" +msgid "Memory Info %1" +msgstr "内存信息 %1" + +#: ../../info/monitorwidget.cpp:35 +msgctxt "MonitorWidget|" +msgid "Monitor Info" +msgstr "显示器和显卡信息" + +#: ../../info/monitorwidget.cpp:45 +#, qt-format +msgctxt "MonitorWidget|" +msgid "Monitor Info %1" +msgstr "显示器和显卡信息 %1" + +#: ../../setting/mousewidget.cpp:100 +msgctxt "MouseWidget|" +msgid "Mouse Pointer Theme" +msgstr "鼠标指针主题" + +#: ../../setting/mousewidget.cpp:101 +msgctxt "MouseWidget|" +msgid "Cursor Pointer Size" +msgstr "光标指针大小" + +#: ../../setting/mousewidget.cpp:102 +msgctxt "MouseWidget|" +msgid "Small Size" +msgstr "小号" + +#: ../../setting/mousewidget.cpp:103 +msgctxt "MouseWidget|" +msgid "Big Size" +msgstr "大号" + +#: ../../setting/nautiluswidget.cpp:179 +msgctxt "NautilusWidget|" +msgid "Display entry location" +msgstr "路径输入框取代路径栏" + +#: ../../setting/nautiluswidget.cpp:180 +msgctxt "NautilusWidget|" +msgid "Automatically mount media" +msgstr "自动挂载媒体" + +#: ../../setting/nautiluswidget.cpp:181 +msgctxt "NautilusWidget|" +msgid "Automatically open a folder" +msgstr "自动打开文件夹" + +#: ../../setting/nautiluswidget.cpp:182 +msgctxt "NautilusWidget|" +msgid "Prompt autorun programs" +msgstr "提示自动运行的程序" + +#: ../../setting/nautiluswidget.cpp:183 +msgctxt "NautilusWidget|" +msgid "Thumbnail icon size (pixels)" +msgstr "缩略图图标尺寸(像素)" + +#: ../../setting/nautiluswidget.cpp:184 +msgctxt "NautilusWidget|" +msgid "Thumbnail cache time (days)" +msgstr "缩略图缓存时间(天数)" + +#: ../../setting/nautiluswidget.cpp:185 +msgctxt "NautilusWidget|" +msgid "Maximum thumbnail cache size (MB)" +msgstr "最大缩略图缓存尺寸(MB)" + +#: ../../info/nicwidget.cpp:30 +msgctxt "NicWidget|" +msgid "NIC Info" +msgstr "有线网卡信息" + +#: ../../info/nicwidget.cpp:34 +msgctxt "NicWidget|" +msgid "WireLess NIC Info" +msgstr "无线网卡信息" + +#: ../../setting/panelwidget.cpp:181 +msgctxt "PanelWidget|" +msgid "Dash background blur type" +msgstr "搜索框背景模糊类型" + +#: ../../setting/panelwidget.cpp:182 +msgctxt "PanelWidget|" +msgid "Panel Transparency" +msgstr "面板透明度" + +#: ../../setting/panelwidget.cpp:183 +msgctxt "PanelWidget|" +msgid "Date & time format" +msgstr "日期时间格式" + +#: ../../setting/panelwidget.cpp:184 +msgctxt "PanelWidget|" +msgid "Display seconds" +msgstr "显示秒数" + +#: ../../setting/panelwidget.cpp:185 +msgctxt "PanelWidget|" +msgid "Display week" +msgstr "显示星期" + +#: ../../setting/panelwidget.cpp:186 +msgctxt "PanelWidget|" +msgid "Display the date" +msgstr "显示日期" + +#: ../../setting/panelwidget.cpp:187 +msgctxt "PanelWidget|" +msgid "Display battery icon" +msgstr "显示电池图标" + +#: ../../setting/panelwidget.cpp:188 +msgctxt "PanelWidget|" +msgid "Display battery percentage" +msgstr "显示电池百分比" + +#: ../../setting/panelwidget.cpp:189 +msgctxt "PanelWidget|" +msgid "Display battery remaining time" +msgstr "显示电池电量时间" + +#: ../../setting/panelwidget.cpp:191 +msgctxt "PanelWidget|" +msgid "Smart blur" +msgstr "活动模糊" + +#: ../../setting/panelwidget.cpp:192 +msgctxt "PanelWidget|" +msgid "Static blur" +msgstr "静态模糊" + +#: ../../setting/panelwidget.cpp:193 +msgctxt "PanelWidget|" +msgid "Clear" +msgstr "非模糊" + +#: ../../processmanager/processdialog.cpp:91 +#: ../../processmanager/processdialog.cpp:125 +msgctxt "ProcessDialog|" +msgid "Process Manager" +msgstr "进程管理器" + +#: ../../processmanager/processdialog.cpp:92 +msgctxt "ProcessDialog|" +msgid "Help you learn more about the program running on the system." +msgstr "帮助您了解和管理系统上运行的进程。" + +#: ../../processmanager/processdialog.cpp:93 +msgctxt "ProcessDialog|" +msgid "Kill Process" +msgstr "杀进程" + +#: ../../processmanager/processdialog.cpp:253 +msgctxt "ProcessDialog|" +msgid "kill process success" +msgstr "杀进程成功" + +#: ../../processmanager/processdialog.cpp:256 +msgctxt "ProcessDialog|" +msgid "kill process failed" +msgstr "杀进程失败" + +#: ../../processmanager/processmanager.cpp:40 +msgctxt "ProcessManager|" +msgid "Process Manager" +msgstr "进程管理器" + +# 帮助用户杀进程 +#: ../../processmanager/processmanager.cpp:45 +msgctxt "ProcessManager|" +msgid "Help user to kill process" +msgstr "" + +#: ../../component/quibo.ui:14 +msgctxt "QUIBO|" +msgid "Form" +msgstr "" + +#~ msgctxt "SessionDispatcher|" +#~ msgid "Select file" +#~ msgstr "选择文件" + +#~ msgctxt "SessionDispatcher|" +#~ msgid "All Files(*)" +#~ msgstr "所有文件(*)" + +#: ../../component/settingaction.cpp:99 +msgctxt "SettingAction|" +msgid "Back" +msgstr "返回" + +#: ../../component/settingaction.cpp:102 +msgctxt "SettingAction|" +msgid "Choose the theme what you want" +msgstr "选择您需要的主题" + +#: ../../component/settingaction.cpp:106 +msgctxt "SettingAction|" +msgid "Set the desktop icon theme and the visibility of desktop icons" +msgstr "设置桌面图标主题和桌面图标的可见性" + +#~ msgctxt "SettingAction|" +#~ msgid "" +#~ "Replace the theme and size of the mouse pointer, then click the 'OK' " +#~ "button to confirm. Also, theme change need to restart system." +#~ msgstr "更换鼠标指针主题和大小,更改设置后点击"确定"按钮进行确认。主题更改需要重新系统才能生效。" + +#~ msgctxt "SettingAction|" +#~ msgid "" +#~ "Replace the theme and size of the mouse pointer. Also, theme change need " +#~ "to restart system." +#~ msgstr "更换鼠标指针主题和大小。主题更改需要重新系统才能生效。" + +#: ../../component/settingaction.cpp:110 +msgctxt "SettingAction|" +msgid "" +"Replace the theme and size of the mouse pointer, and theme change need to " +"restart system." +msgstr "更换鼠标指针主题和大小,主题更改需要重新系统才能生效。" + +#: ../../component/settingaction.cpp:114 +msgctxt "SettingAction|" +msgid "Set the sound theme you want" +msgstr "设置您需要的声音主题" + +#: ../../component/settingaction.cpp:118 +msgctxt "SettingAction|" +msgid "" +"Click the \"Custom Picture\" button to select the picture you want to add, " +"click the picture you want to set and push the \"OK\" button to complete" +msgstr "单击"自定义图片"按钮选择需要添加的图片,选中列表中要设置的图片名称,单击"确定"按钮完成设置" + +#: ../../component/settingaction.cpp:122 +msgctxt "SettingAction|" +msgid "Setting the Launcher display mode, Icon size." +msgstr "设置启动器的显示模式、图标尺寸。" + +#: ../../component/settingaction.cpp:126 +msgctxt "SettingAction|" +msgid "Manage Dash and Panel menu settings" +msgstr "管理Dash搜索和面板菜单的设置" + +#: ../../component/settingaction.cpp:130 +msgctxt "SettingAction|" +msgid "Window Manager settings" +msgstr "窗口管理器设置" + +#: ../../component/settingaction.cpp:134 +msgctxt "SettingAction|" +msgid "" +"According to personal preferences to set the system default font, click the " +"'Restore' button, can be restored to the state before the font settings" +msgstr "根据个人喜好设置系统默认字体,单击"恢复默认"按钮,可以将对应的字体恢复到设置前状态" + +#: ../../component/settingaction.cpp:138 +msgctxt "SettingAction|" +msgid "" +"Setting the relevant properties of your touchpad,make the operation more " +"convenient" +msgstr "通过调整您触摸板的相关设置,使操作更加便捷" + +#: ../../component/settingaction.cpp:142 +msgctxt "SettingAction|" +msgid "Monitor Check" +msgstr "坏点检测" + +#: ../../component/settingaction.cpp:146 +msgctxt "SettingAction|" +msgid "" +"Manage the Nautilus file manager. Tips: if the thumbnail's cache time or " +"size is set to -1, it will not be checked." +msgstr "管理Nautilus文件管理器。注意:如果缩略图缓存时间或尺寸被设置为-1,缩略图将不会被清理。" + +#: ../settingactionwidget.cpp:142 +msgctxt "SettingActionWidget|" +msgid "" +"You can perform a full range of customized systems based on personal " +"preferences" +msgstr "您可以根据个人喜好对系统进行全方位的定制" + +#: ../settingwidget.cpp:247 +msgctxt "SettingWidget|" +msgid "Personalize" +msgstr "个性化" + +#: ../settingwidget.cpp:258 +msgctxt "SettingWidget|" +msgid "ThemeSetting" +msgstr "主题设置" + +#: ../settingwidget.cpp:259 +msgctxt "SettingWidget|" +msgid "IconSetting" +msgstr "图标设置" + +#: ../settingwidget.cpp:260 +msgctxt "SettingWidget|" +msgid "MousePointer" +msgstr "鼠标设置" + +#: ../settingwidget.cpp:261 +msgctxt "SettingWidget|" +msgid "SoundEffect" +msgstr "声音效果" + +#: ../settingwidget.cpp:262 +msgctxt "SettingWidget|" +msgid "BootAnimation" +msgstr "开机动画" + +#: ../settingwidget.cpp:338 +msgctxt "SettingWidget|" +msgid "Desktop" +msgstr "桌面" + +#: ../settingwidget.cpp:342 +msgctxt "SettingWidget|" +msgid "Custom Launcher" +msgstr "自定义启动器" + +#: ../settingwidget.cpp:343 +msgctxt "SettingWidget|" +msgid "Dash & Panel" +msgstr "搜索和面板" + +#: ../settingwidget.cpp:344 +msgctxt "SettingWidget|" +msgid "Window" +msgstr "窗口" + +#: ../settingwidget.cpp:392 +msgctxt "SettingWidget|" +msgid "Font" +msgstr "字体" + +#: ../settingwidget.cpp:394 +msgctxt "SettingWidget|" +msgid "FontSetting" +msgstr "字体设置" + +#: ../settingwidget.cpp:452 +msgctxt "SettingWidget|" +msgid "Sys options" +msgstr "系统选项" + +#: ../settingwidget.cpp:455 +msgctxt "SettingWidget|" +msgid "Touchpad" +msgstr "触摸板" + +#: ../settingwidget.cpp:456 +msgctxt "SettingWidget|" +msgid "Dead pixel check" +msgstr "坏点检测" + +#: ../settingwidget.cpp:504 +msgctxt "SettingWidget|" +msgid "Others" +msgstr "其他" + +#: ../settingwidget.cpp:506 +msgctxt "SettingWidget|" +msgid "File manager" +msgstr "文件管理器" + +#: ../../shredmanager/shreddialog.cpp:100 ../../shredmanager/shreddialog.cpp:129 +msgctxt "ShredDialog|" +msgid "Shred Manager" +msgstr "文件粉碎机" + +#: ../../shredmanager/shreddialog.cpp:101 +#: ../../shredmanager/shreddialog.cpp:174 ../../shredmanager/shreddialog.cpp:186 +msgctxt "ShredDialog|" +msgid "No select any file which need to be shredded" +msgstr "没有选择需要粉碎的文件" + +#: ../../shredmanager/shreddialog.cpp:102 +msgctxt "ShredDialog|" +msgid "Shred File" +msgstr "粉碎文件" + +#: ../../shredmanager/shreddialog.cpp:103 +msgctxt "ShredDialog|" +msgid "Deselect" +msgstr "取消粉碎" + +#: ../../shredmanager/shreddialog.cpp:145 +msgctxt "ShredDialog|" +msgid "Allfile(*)" +msgstr "所有文件(*)" + +#: ../../shredmanager/shreddialog.cpp:162 +msgctxt "ShredDialog|" +msgid "Select file!" +msgstr "选择文件!" + +#~ msgctxt "ShredDialog|" +#~ msgid "Select file" +#~ msgstr "选择文件" + +#~ msgctxt "ShredDialog|" +#~ msgid "All Files(*)" +#~ msgstr "所有文件(*)" + +#: ../../shredmanager/shreddialog.cpp:173 +msgctxt "ShredDialog|" +msgid "Shred successfully!" +msgstr "粉碎成功!" + +#: ../../shredmanager/shreddialog.cpp:179 +msgctxt "ShredDialog|" +msgid "Shred failed!" +msgstr "粉碎失败!" + +#: ../../shredmanager/shredmanager.cpp:40 +msgctxt "ShredManager|" +msgid "Shred Manager" +msgstr "文件粉碎机" + +#: ../../shredmanager/shredmanager.cpp:45 +msgctxt "ShredManager|" +msgid "Delete files makes it unable to recover" +msgstr "彻底删除文件使其无法恢复" + +#: ../skincenter.cpp:107 +msgctxt "SkinCenter|" +msgid "Skin Center" +msgstr "皮肤中心" + +#~ msgctxt "SystemDispatcher|" +#~ msgid "Select the boot animation" +#~ msgstr "选择开机动画" + +#~ msgctxt "SystemDispatcher|" +#~ msgid "Image Files (*.png *.jpg *.gif)" +#~ msgstr "图片文件(*.png *.jpg *.gif)" + +#~ msgctxt "SystemDispatcher|" +#~ msgid "Select music" +#~ msgstr "选择音乐文件" + +#~ msgctxt "SystemDispatcher|" +#~ msgid "Audio Files (*.ogg *.wav *.mp3 *.wma)" +#~ msgstr "音频文件(*.ogg *.wav *.mp3 *.wma)" + +#~ msgctxt "SystemTray|" +#~ msgid "Youker Assistant" +#~ msgstr "优客助手" + +#~ msgctxt "SystemTray|" +#~ msgid "open" +#~ msgstr "打开" + +#~ msgctxt "SystemTray|" +#~ msgid "logout" +#~ msgstr "退出" + +#: ../../info/systemwidget.cpp:36 +msgctxt "SystemWidget|" +msgid "Computer Base Info" +msgstr "电脑概述" + +#: ../../info/systemwidget.cpp:63 ../../info/systemwidget.cpp:67 +msgctxt "SystemWidget|" +msgid " Minutes" +msgstr " 分钟" + +#: ../../info/systemwidget.cpp:67 +msgctxt "SystemWidget|" +msgid " Hours " +msgstr " 小时" + +#: ../../setting/themewidget.cpp:67 +#, qt-format +msgctxt "ThemeWidget|" +msgid "%1" +msgstr "" + +#: ../../component/tipdialog.cpp:74 +msgctxt "TipDialog|" +msgid "OK" +msgstr "确定" + +#: ../../component/tipdialog.cpp:97 +msgctxt "TipDialog|" +msgid "Tip Dialog" +msgstr "提示框" + +#: ../toolwidget.cpp:38 +msgctxt "ToolWidget|" +msgid "Home" +msgstr "优客首页" + +#: ../toolwidget.cpp:38 +msgctxt "ToolWidget|" +msgid "Cleanup" +msgstr "系统清理" + +#: ../toolwidget.cpp:38 +msgctxt "ToolWidget|" +msgid "Sysinfo" +msgstr "系统信息" + +#: ../toolwidget.cpp:38 +msgctxt "ToolWidget|" +msgid "Feature" +msgstr "系统美化" + +#: ../toolwidget.cpp:38 +msgctxt "ToolWidget|" +msgid "Toolkits" +msgstr "功能大全" + +#: ../../setting/touchpadwidget.cpp:126 +msgctxt "TouchpadWidget|" +msgid "Enable touchpad" +msgstr "启用/禁用触摸板" + +#: ../../setting/touchpadwidget.cpp:127 +msgctxt "TouchpadWidget|" +msgid "Enable horizontal scrolling" +msgstr "触摸板横向滚动" + +#: ../../setting/touchpadwidget.cpp:128 +msgctxt "TouchpadWidget|" +msgid "Scrollbar type" +msgstr "滚动条类型" + +#: ../../setting/touchpadwidget.cpp:129 +msgctxt "TouchpadWidget|" +msgid "Panel layout" +msgstr "触摸板滚动触发方式" + +#: ../../setting/touchpadwidget.cpp:130 +msgctxt "TouchpadWidget|" +msgid "Features Type" +msgstr "特色类型" + +#: ../../setting/touchpadwidget.cpp:131 +msgctxt "TouchpadWidget|" +msgid "Standard Type" +msgstr "标准类型" + +#: ../../setting/touchpadwidget.cpp:132 +msgctxt "TouchpadWidget|" +msgid "Edge Scrolling" +msgstr "边缘触发" + +#: ../../setting/touchpadwidget.cpp:133 +msgctxt "TouchpadWidget|" +msgid "Two-finger Scrolling" +msgstr "双指触发" + +#: ../../setting/voicewidget.cpp:99 +msgctxt "VoiceWidget|" +msgid "Sound theme" +msgstr "事件声音" + +#: ../../setting/voicewidget.cpp:100 +msgctxt "VoiceWidget|" +msgid "Login tone" +msgstr "登录提示音" + +#: ../../setting/voicewidget.cpp:101 +msgctxt "VoiceWidget|" +msgid "Event sounds" +msgstr "声音主题" + +#: ../../setting/voicewidget.cpp:102 +msgctxt "VoiceWidget|" +msgid "Input feedback sounds" +msgstr "输入反馈声音" + +#: ../../setting/windowwidget.cpp:115 +msgctxt "WindowWidget|" +msgid "Menu with icons" +msgstr "菜单项旁显示图标" + +#: ../../setting/windowwidget.cpp:116 +msgctxt "WindowWidget|" +msgid "Titlebar mouse wheel action" +msgstr "标题栏鼠标滚轮动作" + +#: ../../setting/windowwidget.cpp:117 +msgctxt "WindowWidget|" +msgid "Titlebar double-click action" +msgstr "标题栏双击动作" + +#: ../../setting/windowwidget.cpp:118 +msgctxt "WindowWidget|" +msgid "Titlebar middle-click action" +msgstr "标题栏中键动作" + +#: ../../setting/windowwidget.cpp:119 +msgctxt "WindowWidget|" +msgid "Titlebar right-click action" +msgstr "标题栏右键动作" diff --git a/processmanager/filelist.cc b/processmanager/filelist.cc new file mode 100644 index 0000000..21067cc --- /dev/null +++ b/processmanager/filelist.cc @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "filelist.h" +#include +void filelist_init(GPtrArray **filelist) +{ + *filelist = g_ptr_array_new_full(100, free); + (*filelist)->len = 0; +} + +int filelist_append(GPtrArray *filelist, char * value) +{ + g_ptr_array_add(filelist, (void*)value); + return 0; +} + +int filelist_length(GPtrArray *filelist) +{ + if( !filelist ){ + printf("it's NULL\n"); + return 0; + } + if(filelist->pdata == NULL) + return 0; + return filelist->len; +} + +char * filelist_index(GPtrArray *filelist, int index) +{ + return (char*)g_ptr_array_index(filelist, index); +} + +void filelist_destroy(GPtrArray *filelist) +{ + + g_ptr_array_free(filelist, TRUE); +} diff --git a/processmanager/filelist.h b/processmanager/filelist.h new file mode 100644 index 0000000..c6ba875 --- /dev/null +++ b/processmanager/filelist.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __FILELIST_H__ +#define __FILELIST_H__ + +#include +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +void filelist_init(GPtrArray**); +int filelist_append(GPtrArray*, char * value); +int filelist_length(GPtrArray*); +char * filelist_index(GPtrArray *filelist, int index); +void filelist_destroy(GPtrArray *filelist); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/processmanager/procapp.h b/processmanager/procapp.h new file mode 100644 index 0000000..86614e3 --- /dev/null +++ b/processmanager/procapp.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PROCAPP_H +#define PROCAPP_H + +#include +#include +#include + +using std::string; + +class ProcApp { +public: + GPtrArray * filelist; + guint64 cpu_total_time; + guint64 cpu_total_time_last; + gint num_cpus; +}; + +#endif // PROCAPP_H diff --git a/processmanager/processdialog.cpp b/processmanager/processdialog.cpp new file mode 100644 index 0000000..c12a698 --- /dev/null +++ b/processmanager/processdialog.cpp @@ -0,0 +1,335 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include "processmanager.h" +#include +#include +#include +#include + +//pkg-config --cflags libgtop-2.0 +//pkg-config --libs glib-2.0 libgtop-2.0 + +ProcessDialog::ProcessDialog(ProcessManager *plugin, QDialog *parent) +:QDialog(parent) +{ + setWindowFlags(Qt::FramelessWindowHint); + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + title_bar = new KylinTitleBar(); + + proSettings = new QSettings(YOUKER_COMPANY_SETTING, YOUKER_SETTING_FILE_NAME_SETTING); + proSettings->setIniCodec("UTF-8"); + + initTitleBar(); + + this->setFixedSize(850, 476); + process_plugin = plugin; + + toolkits = new Toolkits(0, this->width(), this->height()); + tip_label = new QLabel(); + kill_btn = new QPushButton(); + kill_btn->setFixedSize(91, 25); + kill_btn->setObjectName("blackButton"); + kill_btn->setFocusPolicy(Qt::NoFocus); + tableWidget = new QTableWidget(); + tableWidget->setStyleSheet("QTableWidget{border: none}"); + + QHBoxLayout *h_layout = new QHBoxLayout(); + h_layout->addWidget(tip_label); + h_layout->addStretch(); + h_layout->addWidget(kill_btn); + h_layout->setMargin(0); + h_layout->setContentsMargins(10, 2, 10, 0); + + QVBoxLayout *v_layout = new QVBoxLayout(); + v_layout->addWidget(tableWidget); + v_layout->setContentsMargins(10, 0, 10, 10); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(title_bar); + main_layout->addLayout(h_layout); + main_layout->addLayout(v_layout); + main_layout->setSpacing(20); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + setLayout(main_layout); + + app = new ProcApp(); + selected_pid = ""; + this->refresh_prolist(); + timer=new QTimer(this); + timer->start(3000); + + this->setLanguage(); + this->initConnect(); +} + +ProcessDialog::~ProcessDialog() +{ + if (app) { + delete app; + } + disconnect(timer,SIGNAL(timeout()),this,SLOT(refresh_prolist())); + if(timer->isActive()) { + timer->stop(); + } + if (proSettings != NULL) + { + proSettings->sync(); + delete proSettings; + proSettings = NULL; + } +} + +void ProcessDialog::setLanguage() +{ + this->setWindowTitle(tr("Process Manager")); + tip_label->setText(tr("Help you learn more about the program running on the system.")); + kill_btn->setText(tr("Kill Process")); +} + +void ProcessDialog::initConnect() +{ + connect(timer,SIGNAL(timeout()),this,SLOT(refresh_prolist())); + connect(tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(handlercellClicked(int,int))); + connect(kill_btn, SIGNAL(clicked()), this, SLOT(killSelectedProcess())); +// connect(title_bar, SIGNAL(showMinDialog()), this, SLOT(onMinButtonClicked())); + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); +} + +void ProcessDialog::onCloseButtonClicked() +{ + this->close(); +} + +//void ProcessDialog::onMinButtonClicked() +//{ +// this->showMinimized(); +//// this->hide(); +//} + +void ProcessDialog::closeEvent(QCloseEvent *event) +{ + event->accept(); +// emit SignalClose(); +} + +QString ProcessDialog::getCurrrentSkinName() +{ + proSettings->beginGroup("Background"); + QString skin = proSettings->value("Path").toString(); + if(skin.isEmpty()) { + skin = ":/background/res/skin/1.png"; + } + else { + QStringList skinlist; + QString path = "/var/lib/youker-assistant-daemon/default/"; + QDir picdir(path); + picdir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + picdir.setSorting(QDir::Size | QDir::Reversed); + QStringList filters; + filters << "*.jpg" << "*.png"; + picdir.setNameFilters(filters); + QFileInfoList list = picdir.entryInfoList(); + if(list.size() < 1) { + skinlist << ":/background/res/skin/1.png" << ":/background/res/skin/2.png" << ":/background/res/skin/3.png" << ":/background/res/skin/4.png"; + } + else { + for (int j = 0; j < list.size(); ++j) { + QFileInfo fileInfo = list.at(j); + skinlist << path + fileInfo.fileName(); + } + skinlist << ":/background/res/skin/1.png" << ":/background/res/skin/2.png" << ":/background/res/skin/3.png" << ":/background/res/skin/4.png"; + } + + QList::Iterator it = skinlist.begin(), itend = skinlist.end(); + bool flag = false; + for(;it != itend; it++) + { + if(*it == skin) { + flag = true; + break; + } + } + if (flag == false) { + skin = skinlist.at(0); + } + } + proSettings->endGroup(); + proSettings->sync(); + return skin; +} + +void ProcessDialog::initTitleBar() +{ + QString skin = this->getCurrrentSkinName(); + title_bar->setTitleWidth(850); + title_bar->setTitleName(tr("Process Manager")); +// title_bar->setTitleBackgound(":/background/res/skin/1.png"); + title_bar->setTitleBackgound(skin); +} + +void ProcessDialog::resetSkin() +{ + QString skin = this->getCurrrentSkinName(); + title_bar->resetBackground(skin); +} + +void ProcessDialog::showProList() { + tableWidget->clearContents();//只清除表中数据,不清除表头内容 + tableWidget->setRowCount(0);//连行也清除掉 + + int num = filelist_length(app->filelist); +// printf("num=%s\n",g_strdup_printf("%d", num)); + + tableWidget->setColumnCount(COLUMN_NUM); + tableWidget->setRowCount(num); + tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); + tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); + tableWidget->verticalHeader()->setVisible(false); + tableWidget->setMouseTracking(true); + tableWidget->setSelectionMode(QTableWidget::SingleSelection); + tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + tableWidget->horizontalHeader()->setHighlightSections(false); + tableWidget->setShowGrid(false); + QStringList headers; +// headers << "命令行" << "用户" << "ID" << "优先级" << "状态" << "% 内存" << "% CPU" << "CPU时间" << "开始于";//<< "等候频道"; + headers << tr("Command Line") << tr("User") << tr("ID") << tr("Priority") << tr("Status") << tr("% Memory") << tr("% CPU") << tr("CPU Time") << tr("Started");//<< "Waiting Channel"; + tableWidget->setHorizontalHeaderLabels(headers); + QTableWidgetItem *columnHeaderItem0 = tableWidget->horizontalHeaderItem(0); //获得水平方向表头的Item对象 + QTableWidgetItem *columnHeaderItem1 = tableWidget->horizontalHeaderItem(1); + QTableWidgetItem *columnHeaderItem2 = tableWidget->horizontalHeaderItem(2); + QTableWidgetItem *columnHeaderItem3 = tableWidget->horizontalHeaderItem(3); + QTableWidgetItem *columnHeaderItem4 = tableWidget->horizontalHeaderItem(4); + QTableWidgetItem *columnHeaderItem5 = tableWidget->horizontalHeaderItem(5); + QTableWidgetItem *columnHeaderItem6 = tableWidget->horizontalHeaderItem(6); + QTableWidgetItem *columnHeaderItem7 = tableWidget->horizontalHeaderItem(7); + QTableWidgetItem *columnHeaderItem8 = tableWidget->horizontalHeaderItem(8); + columnHeaderItem0->setFont(QFont("Helvetica")); //设置字体 + columnHeaderItem0->setBackgroundColor(QColor(0,60,10)); //设置单元格背景颜色 + columnHeaderItem0->setTextColor(QColor(200,111,30)); //设置文字颜色 + columnHeaderItem1->setFont(QFont("Helvetica")); + columnHeaderItem1->setBackgroundColor(QColor(0,60,10)); + columnHeaderItem1->setTextColor(QColor(200,111,30)); + columnHeaderItem2->setFont(QFont("Helvetica")); + columnHeaderItem2->setBackgroundColor(QColor(0,60,10)); + columnHeaderItem2->setTextColor(QColor(200,111,30)); + columnHeaderItem3->setFont(QFont("Helvetica")); + columnHeaderItem3->setBackgroundColor(QColor(0,60,10)); + columnHeaderItem3->setTextColor(QColor(200,111,30)); + columnHeaderItem4->setFont(QFont("Helvetica")); + columnHeaderItem4->setBackgroundColor(QColor(0,60,10)); + columnHeaderItem4->setTextColor(QColor(200,111,30)); + columnHeaderItem5->setFont(QFont("Helvetica")); + columnHeaderItem5->setBackgroundColor(QColor(0,60,10)); + columnHeaderItem5->setTextColor(QColor(200,111,30)); + columnHeaderItem6->setFont(QFont("Helvetica")); + columnHeaderItem6->setBackgroundColor(QColor(0,60,10)); + columnHeaderItem6->setTextColor(QColor(200,111,30)); + columnHeaderItem7->setFont(QFont("Helvetica")); + columnHeaderItem7->setBackgroundColor(QColor(0,60,10)); + columnHeaderItem7->setTextColor(QColor(200,111,30)); + columnHeaderItem8->setFont(QFont("Helvetica")); + columnHeaderItem8->setBackgroundColor(QColor(0,60,10)); + columnHeaderItem8->setTextColor(QColor(200,111,30)); + + //表头设置 + tableWidget->horizontalHeader()->setClickable(false); + tableWidget->horizontalHeader()->resizeSection(0,150); + tableWidget->horizontalHeader()->resizeSection(1,80); + tableWidget->horizontalHeader()->resizeSection(2,50); + tableWidget->horizontalHeader()->resizeSection(3,80); + tableWidget->horizontalHeader()->resizeSection(4,80); + tableWidget->horizontalHeader()->resizeSection(5,60); + tableWidget->horizontalHeader()->resizeSection(6,80); + tableWidget->horizontalHeader()->resizeSection(7,80); + tableWidget->horizontalHeader()->setFixedHeight(25); + tableWidget->horizontalHeader()->setStretchLastSection(true); + + int index = 0; + char * checkpath = NULL; + for( ; indexfilelist, index); + QString pro_line = QString::fromLocal8Bit(checkpath); + QStringList tmp = pro_line.split(";"); + if(tmp.length() == COLUMN_NUM) { + if(selected_pid == tmp[2]) { +// tableWidget->selectRow(index);//set current selected row + tableWidget->setCurrentCell(index, QItemSelectionModel::Select); + } + if(index == 0 && selected_pid == "") { + tableWidget->selectRow(0);//set current selected row + selected_pid = tmp[2]; + } + for(int i=0;isetItem(index, i, new QTableWidgetItem(tmp[i])); + } + else { + QTableWidgetItem *newItem = new QTableWidgetItem(tmp[i]); + newItem->setTextAlignment(Qt::AlignCenter); + tableWidget->setItem(index,i,newItem); + } + } + } + } + + tableWidget->setFocus(Qt::MouseFocusReason); + filelist_destroy(app->filelist); + app->filelist=NULL; +} + +void ProcessDialog::refresh_prolist() { + list_whose_proc_info(app); + this->showProList(); +} + +void ProcessDialog::handlercellClicked(int row, int column) { + QListitems=tableWidget->selectedItems(); + QTableWidgetItem*item=items.at(2); + QString name=item->text();//获取内容 + selected_pid = name; +} + +void ProcessDialog::killSelectedProcess(){ + QString pid; + QListitems = tableWidget->selectedItems(); + QTableWidgetItem* item = items.at(2); + pid = item->text(); + QProcess *p = new QProcess(); + p->start("kill -9 " + pid); + bool result = p->waitForFinished(); + if (result) { + toolkits->alertMSG(this->frameGeometry().topLeft().x(), this->frameGeometry().topLeft().y(), tr("kill process success")); + } + else { + toolkits->alertMSG(this->frameGeometry().topLeft().x(), this->frameGeometry().topLeft().y(), tr("kill process failed")); + } +// int count=items.count(); +// for(int i=0;irow(items.at(i));//获取选中的行 +// QTableWidgetItem* item = items.at(i); +// QString name=item->text();//获取内容 +// } +} diff --git a/processmanager/processdialog.h b/processmanager/processdialog.h new file mode 100644 index 0000000..9022ac7 --- /dev/null +++ b/processmanager/processdialog.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "procman.h" +#include "procapp.h" +#include "filelist.h" +#include "../component/utils.h" +#include "../component/toolkits.h" +#include "../component/kylintitlebar.h" + +#include +#define COLUMN_NUM 9 + +class ProcessManager; + +class ProcessDialog : public QDialog +{ + Q_OBJECT +public: + ProcessDialog(ProcessManager *plugin, QDialog *parent = 0); + ~ProcessDialog(); + void setLanguage(); + void initConnect(); + void initTitleBar(); + void showProList(); + QString getCurrrentSkinName(); + void resetSkin(); + ProcApp *app; + +protected: + void closeEvent(QCloseEvent *event); + +private slots: + void refresh_prolist(); + void handlercellClicked(int row, int column); + void killSelectedProcess(); + void onCloseButtonClicked(); +// void onMinButtonClicked(); + +private: + ProcessManager *process_plugin; + QLabel *tip_label; + QPushButton *kill_btn; + QTableWidget *tableWidget; + QString selected_pid; + QTimer *timer; + Toolkits *toolkits; + KylinTitleBar *title_bar; + QSettings *proSettings; +}; diff --git a/processmanager/processdialog.ui b/processmanager/processdialog.ui new file mode 100644 index 0000000..19a2607 --- /dev/null +++ b/processmanager/processdialog.ui @@ -0,0 +1,25 @@ + + + ProcessDialog + + + + 0 + 0 + 745 + 435 + + + + + + + false + + + + + + + + diff --git a/processmanager/processmanager.cpp b/processmanager/processmanager.cpp new file mode 100644 index 0000000..cf662e8 --- /dev/null +++ b/processmanager/processmanager.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "processmanager.h" +#include + +ProcessManager::ProcessManager(QObject *parent) +:QObject(parent), process_dialog(this) +{ + +} + +ProcessManager::~ProcessManager() +{ +} + +QString ProcessManager::getGuid() +{ + return "UBUNTU-KYLIN-PROCESS"; +} + + QString ProcessManager::getName() +{ + return tr("Process Manager"); +} + +QString ProcessManager::getDescribe() +{ + return tr("Help user to kill process");//方便用户杀掉进程 +} + +QString ProcessManager::getPicture() +{ + return "processmanager.png"; +} + +void ProcessManager::doAction() +{ + int windowWidth = QApplication::desktop()->width(); + int windowHeight = QApplication::desktop()->height(); + process_dialog.resetSkin(); + process_dialog.move((windowWidth - 850) / 2,(windowHeight - 476) / 2); + process_dialog.show(); + process_dialog.raise(); +} + +Q_EXPORT_PLUGIN2(ProcessManager, ProcessManager) diff --git a/processmanager/processmanager.h b/processmanager/processmanager.h new file mode 100644 index 0000000..cc666a3 --- /dev/null +++ b/processmanager/processmanager.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include "../component/plugininterface.h" +#include "processdialog.h" + +//插件入口 +class ProcessManager : public QObject , PluginInterface +{ + Q_OBJECT + Q_INTERFACES(PluginInterface) + +public: + ProcessManager(QObject* parent = 0); + virtual ~ProcessManager(); + +public slots: + +public: + virtual QString getGuid(); + virtual QString getName(); + virtual QString getDescribe(); + virtual QString getPicture(); + virtual void doAction(); + +private: + ProcessDialog process_dialog; +}; diff --git a/processmanager/processmanager.pro b/processmanager/processmanager.pro new file mode 100644 index 0000000..5b72a41 --- /dev/null +++ b/processmanager/processmanager.pro @@ -0,0 +1,61 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-01-26T09:16:38 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = processmanager +TEMPLATE = lib +CONFIG += plugin +INCLUDEPATH += ../processmanager +DESTDIR = ../libs +CONFIG += link_pkgconfig +PKGCONFIG += libgtop-2.0 + +UI_DIR += $$PWD/../tmp/processmanager/ + +RCC_DIR += $$PWD/../tmp/processmanager/ + +MOC_DIR += $$PWD/../tmp/processmanager/ + +OBJECTS_DIR = $$PWD/../obj/processmanager + + +target.source += $$TARGET +target.path = /var/lib/youker-assistant-daemon/libs/ +INSTALLS +=target + +HEADERS += \ + ../component/plugininterface.h \ + processmanager.h \ + processdialog.h \ + procman.h \ + procapp.h \ + util.h \ + filelist.h \ + ../component/alertdialog.h \ + ../component/toolkits.h \ + ../component/utils.h \ + ../component/kylintitlebar.h \ + ../component/systembutton.h + +SOURCES += \ + processmanager.cpp \ + processdialog.cpp \ + procman.cpp \ + util.cpp \ + filelist.cc \ + ../component/alertdialog.cpp \ + ../component/toolkits.cpp \ + ../component/kylintitlebar.cpp \ + ../component/systembutton.cpp + +FORMS += \ + ../component/alertdialog.ui + +RESOURCES += \ + ../mainui/img.qrc diff --git a/processmanager/procman.cpp b/processmanager/procman.cpp new file mode 100644 index 0000000..1a0fc42 --- /dev/null +++ b/processmanager/procman.cpp @@ -0,0 +1,249 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "procman.h" +#include "util.h" +#include "filelist.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using std::string; + +ProcessInfo::UserMap ProcessInfo::users; +ProcessInfo::List ProcessInfo::all; +std::map ProcessInfo::cpu_times; + +ProcessInfo::ProcessInfo(pid_t pid) + : tooltip(NULL), + name(NULL), + arguments(NULL), + status(0), + pid(pid), + uid(-1) +{ + ProcessInfo * const info = this; + glibtop_proc_state procstate; + glibtop_proc_time proctime; + glibtop_proc_args procargs; + gchar** arguments; + + glibtop_get_proc_state (&procstate, pid); + glibtop_get_proc_time (&proctime, pid); + arguments = glibtop_get_proc_argv (&procargs, pid, 0); + + std::string tooltip = make_string(g_strjoinv(" ", arguments)); + if (tooltip.empty()) + tooltip = procstate.cmd; + info->tooltip = g_markup_escape_text(tooltip.c_str(), -1); + info->arguments = g_strescape(tooltip.c_str(), "\\\""); + g_strfreev(arguments); + + guint64 cpu_time = proctime.rtime; + std::map::iterator it(ProcessInfo::cpu_times.find(pid)); + if (it != ProcessInfo::cpu_times.end()) + { + if (proctime.rtime >= it->second) + cpu_time = it->second; + } + info->cpu_time = cpu_time; + info->start_time = proctime.start_time; + + glibtop_init(); +} + +ProcessInfo::~ProcessInfo() +{ + glibtop_close(); + g_free(this->name); + g_free(this->tooltip); + g_free(this->arguments); +} + +ProcessInfo* ProcessInfo::find(pid_t pid) +{ + Iterator it(ProcessInfo::all.find(pid)); + return (it == ProcessInfo::all.end() ? NULL : it->second); +} + +std::string ProcessInfo::lookup_user(guint uid) +{ + typedef std::pair Pair; + ProcessInfo::UserMap::value_type hint(uid, ""); + Pair p(ProcessInfo::users.insert(hint)); + if (p.second) { + struct passwd* pwd; + pwd = getpwuid(uid); + + if (pwd && pwd->pw_name) + p.first->second = pwd->pw_name; + else { + char username[16]; + g_sprintf(username, "%u", uid); + p.first->second = username; + } + } + return p.first->second; +} + +void ProcessInfo::set_user(guint uid) +{ + if (G_LIKELY(this->uid == uid)) + return; + this->uid = uid; + this->user = lookup_user(uid); +} + +static void update_info (ProcApp *app, ProcessInfo *info) +{ + glibtop_proc_state procstate; + glibtop_proc_uid procuid; + glibtop_proc_time proctime; + glibtop_proc_args procargs; + gchar** arguments; + float memrate; + glibtop_mem memory; + glibtop_proc_mem procmem; + glibtop_get_mem(&memory); + glibtop_get_proc_mem(&procmem,info->pid); + memrate = 100*(procmem.resident) /((memory.total)*1.0); + info->mem = memrate; + + glibtop_get_proc_state (&procstate, info->pid); + info->status = procstate.state; + + glibtop_get_proc_uid (&procuid, info->pid); + glibtop_get_proc_time (&proctime, info->pid); + + arguments = glibtop_get_proc_argv (&procargs, info->pid, 0); + std::string tooltip = make_string(g_strjoinv(" ", arguments)); + if (tooltip.empty()) + tooltip = procstate.cmd; + g_strfreev(arguments); + info->name = procstate.cmd; + info->set_user(procstate.uid); + + guint64 difference = proctime.rtime - info->cpu_time; + if (difference > 0) + info->status = GLIBTOP_PROCESS_RUNNING; + info->pcpu = difference * 100 / app->cpu_total_time; + info->pcpu = MIN(info->pcpu, 100); + + ProcessInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime; + info->nice = procuid.nice; + + gchar* str_command = g_strdup_printf("%s", g_strdup_printf("%s", info->arguments)); + gchar* str_user = g_strdup_printf("%s", info->user.c_str()); + gchar* str_pid = g_strdup_printf("%s", g_strdup_printf("%d", info->pid)); + gchar* str_priority = g_strdup_printf("%s", g_strdup_printf("%s", get_nice_level(info->nice))); + gchar* str_status = g_strdup_printf("%s", g_strdup(format_process_state(info->status))); + gchar* str_mem = g_strdup_printf("%s",g_strdup_printf("%0.1f%%", info->mem)); + gchar* str_pcpu = g_strdup_printf("%s",g_strdup_printf("%d%%", info->pcpu)); + gchar* str_cputime = g_strdup_printf("%s",g_strdup_printf(ngettext("%lld second", "%lld seconds", info->cpu_time/HZ), (unsigned long long)info->cpu_time/HZ)); + gchar* str_starttime = g_strdup_printf("%s",g_strdup_printf("%s", ctime((const time_t*)(&info->start_time)))); + str_starttime[strlen(str_starttime)-1] = 0; + int info_size = 1024; +// int info_size = strlen(str_name) + strlen(str_user) + strlen(str_uid) + strlen(str_status) + strlen(str_mem) + strlen(str_pcpu) + strlen(str_cputime) + strlen(str_starttime) + strlen(str_nice) + strlen(str_priority) + strlen(str_pid) + strlen(str_command) + strlen(str_wchan) + 1; + char *pro_info; + pro_info = (char*)calloc( info_size, sizeof(char)); + memset( pro_info, 0, info_size ); + if(!pro_info){ + perror("calloc"); + } + snprintf( pro_info, info_size, "%s;%s;%s;%s;%s;%s;%s;%s;%s", str_command, str_user, str_pid, str_priority, str_status, str_mem, str_pcpu, str_cputime, str_starttime); + filelist_append(app->filelist, pro_info); +} + +static void refresh_whose_processes_list (ProcApp *app, const pid_t* pid_list, const guint n) +{ + guint i; + for(i = 0; i < n; ++i) { + ProcessInfo *info = ProcessInfo::find(pid_list[i]); + if (!info) { + info = new ProcessInfo(pid_list[i]); + ProcessInfo::all[info->pid] = info; + } + update_info (app, info); + } +} + +void list_whose_proc_info(ProcApp *app) { +// glibtop_init(); + + pid_t* pid_list; + glibtop_proclist proclist; + glibtop_cpu cpu; + gint which, arg; + gint i; + gint whose_process; + whose_process = 1; + + filelist_init(&app->filelist); + + app->num_cpus = 0; + i=0; + while (i < GLIBTOP_NCPU && cpu.xcpu_total[i] != 0) { + app->num_cpus ++; + i++; + } + if (app->num_cpus == 0) { + app->num_cpus = 1; + } + + switch (whose_process) { + case 0://all processes + which = GLIBTOP_KERN_PROC_ALL; + arg = 0; + break; + case 2://active processes + which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE; + arg = 0; + break; + default: + which = GLIBTOP_KERN_PROC_UID; + arg = getuid (); + break; + } + + pid_list = glibtop_get_proclist (&proclist, which, arg); + glibtop_get_cpu (&cpu); + app->cpu_total_time = MAX(cpu.total - app->cpu_total_time_last, 1); + app->cpu_total_time_last = cpu.total; + refresh_whose_processes_list (app, pid_list, proclist.number); + + g_free (pid_list); +// glibtop_close(); +} diff --git a/processmanager/procman.h b/processmanager/procman.h new file mode 100644 index 0000000..e5304dc --- /dev/null +++ b/processmanager/procman.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "procapp.h" + +#define HZ 100 + +void list_whose_proc_info(ProcApp *app); diff --git a/processmanager/util.cpp b/processmanager/util.cpp new file mode 100644 index 0000000..f9cce64 --- /dev/null +++ b/processmanager/util.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include "util.h" + +const char* format_process_state(guint state) +{ + const char *status; + + switch (state) + { + case GLIBTOP_PROCESS_RUNNING: + status = _("Running"); + break; + + case GLIBTOP_PROCESS_STOPPED: + status = _("Stopped"); + break; + + case GLIBTOP_PROCESS_ZOMBIE: + status = _("Zombie"); + break; + + case GLIBTOP_PROCESS_UNINTERRUPTIBLE: + status = _("Uninterruptible"); + break; + + default: + status = _("Sleeping"); + break; + } + + return status; +} + +const gchar* get_nice_level (gint nice) +{ + if (nice < -7) + return _("Very High"); + else if (nice < -2) + return _("High"); + else if (nice < 3) + return _("Normal"); + else if (nice < 7) + return _("Low"); + else + return _("Very Low"); +} diff --git a/processmanager/util.h b/processmanager/util.h new file mode 100644 index 0000000..8c50bec --- /dev/null +++ b/processmanager/util.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +using std::string; + +inline string make_string(char *c_str) +{ + if (!c_str) { + return string(); + } + string s(c_str); + g_free(c_str); + return s; +} + +const char* format_process_state(guint state); +const gchar* get_nice_level (gint nice); + +class ProcessInfo +{ + ProcessInfo& operator=(const ProcessInfo&); + ProcessInfo(const ProcessInfo&); + typedef std::map UserMap; + static UserMap users; + + public: + ProcessInfo(pid_t pid); + ~ProcessInfo(); + typedef std::map List; + typedef List::iterator Iterator; + static ProcessInfo* find(pid_t pid); + static Iterator begin() { return ProcessInfo::all.begin(); } + static Iterator end() { return ProcessInfo::all.end(); } + static List all; + + void set_user(guint uid); + std::string lookup_user(guint uid); + std::string user; + float mem; + gulong start_time; + guint64 cpu_time; + guint status; + guint pcpu; + gint nice; + gchar *tooltip; + gchar *name; + gchar *arguments; + const guint pid; + guint uid; + static std::map cpu_times; +}; diff --git a/qtsingleapplication/README.TXT b/qtsingleapplication/README.TXT new file mode 100644 index 0000000..06abb09 --- /dev/null +++ b/qtsingleapplication/README.TXT @@ -0,0 +1,33 @@ +Qt Solutions Component: Single Application + +The QtSingleApplication component provides support for +applications that can be only started once per user. + + + +Version history: + +2.0: - Version 1.3 ported to Qt 4. + +2.1: - Fix compilation problem on Mac. + +2.2: - Really fix the Mac compilation problem. + - Mac: fix crash due to wrong object releasing. + - Mac: Fix memory leak. + +2.3: - Windows: Force creation of internal widget to make it work + with Qt 4.2. + +2.4: - Fix the system for automatic window raising on message + reception. NOTE: minor API change. + +2.5: - Mac: Fix isRunning() to work and report correctly. + +2.6: - - initialize() is now obsolete, no longer necessary to call + it + - - Fixed race condition where multiple instances migth be started + - - QtSingleCoreApplication variant provided for non-GUI (console) + usage + - Complete reimplementation. Visible changes: + - LGPL release. + diff --git a/qtsingleapplication/common.pri b/qtsingleapplication/common.pri new file mode 100644 index 0000000..bae2717 --- /dev/null +++ b/qtsingleapplication/common.pri @@ -0,0 +1,6 @@ +exists(config.pri):infile(config.pri, SOLUTIONS_LIBRARY, yes): CONFIG += qtsingleapplication-uselib +TEMPLATE += fakelib +QTSINGLEAPPLICATION_LIBNAME = $$qtLibraryTarget(QtSolutions_SingleApplication-head) +TEMPLATE -= fakelib +QTSINGLEAPPLICATION_LIBDIR = $$PWD/lib +unix:qtsingleapplication-uselib:!qtsingleapplication-buildlib:QMAKE_RPATHDIR += $$QTSINGLEAPPLICATION_LIBDIR diff --git a/qtsingleapplication/src/QtLockedFile b/qtsingleapplication/src/QtLockedFile new file mode 100644 index 0000000..16b48ba --- /dev/null +++ b/qtsingleapplication/src/QtLockedFile @@ -0,0 +1 @@ +#include "qtlockedfile.h" diff --git a/qtsingleapplication/src/QtSingleApplication b/qtsingleapplication/src/QtSingleApplication new file mode 100644 index 0000000..d111bf7 --- /dev/null +++ b/qtsingleapplication/src/QtSingleApplication @@ -0,0 +1 @@ +#include "qtsingleapplication.h" diff --git a/qtsingleapplication/src/qtlocalpeer.cpp b/qtsingleapplication/src/qtlocalpeer.cpp new file mode 100644 index 0000000..332b064 --- /dev/null +++ b/qtsingleapplication/src/qtlocalpeer.cpp @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** 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 +#include + +#if defined(Q_OS_WIN) +#include +#include +typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); +static PProcessIdToSessionId pProcessIdToSessionId = 0; +#endif +#if defined(Q_OS_UNIX) +#include +#include +#include +#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) +} diff --git a/qtsingleapplication/src/qtlocalpeer.h b/qtsingleapplication/src/qtlocalpeer.h new file mode 100644 index 0000000..1b533b1 --- /dev/null +++ b/qtsingleapplication/src/qtlocalpeer.h @@ -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 +#include +#include + +#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 diff --git a/qtsingleapplication/src/qtlockedfile.cpp b/qtsingleapplication/src/qtlockedfile.cpp new file mode 100644 index 0000000..c142a86 --- /dev/null +++ b/qtsingleapplication/src/qtlockedfile.cpp @@ -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 + aquired. If \a block is false, this function returns \e false + immediately if the lock cannot be aquired. + + 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. +*/ diff --git a/qtsingleapplication/src/qtlockedfile.h b/qtsingleapplication/src/qtlockedfile.h new file mode 100644 index 0000000..84c18e5 --- /dev/null +++ b/qtsingleapplication/src/qtlockedfile.h @@ -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 +#ifdef Q_OS_WIN +#include +#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 rmutexes; + QString mutexname; + + Qt::HANDLE getMutexHandle(int idx, bool doCreate); + bool waitMutex(Qt::HANDLE mutex, bool doBlock); + +#endif + LockMode m_lock_mode; +}; +} +#endif diff --git a/qtsingleapplication/src/qtlockedfile_unix.cpp b/qtsingleapplication/src/qtlockedfile_unix.cpp new file mode 100644 index 0000000..976c1b9 --- /dev/null +++ b/qtsingleapplication/src/qtlockedfile_unix.cpp @@ -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 +#include +#include +#include + +#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(); +} + diff --git a/qtsingleapplication/src/qtlockedfile_win.cpp b/qtsingleapplication/src/qtlockedfile_win.cpp new file mode 100644 index 0000000..5e21262 --- /dev/null +++ b/qtsingleapplication/src/qtlockedfile_win.cpp @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** 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" +#include +#include + +#define MUTEX_PREFIX "QtLockedFile mutex " +// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS +#define MAX_READERS MAXIMUM_WAIT_OBJECTS + +#if QT_VERSION >= 0x050000 +#define QT_WA(unicode, ansi) unicode +#endif + +Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) +{ + if (mutexname.isEmpty()) { + QFileInfo fi(*this); + mutexname = QString::fromLatin1(MUTEX_PREFIX) + + fi.absoluteFilePath().toLower(); + } + QString mname(mutexname); + if (idx >= 0) + mname += QString::number(idx); + + Qt::HANDLE mutex; + if (doCreate) { + QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, + { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); + if (!mutex) { + qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); + return 0; + } + } + else { + QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, + { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); + if (!mutex) { + if (GetLastError() != ERROR_FILE_NOT_FOUND) + qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); + return 0; + } + } + return mutex; +} + +bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock) +{ + Q_ASSERT(mutex); + DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0); + switch (res) { + case WAIT_OBJECT_0: + case WAIT_ABANDONED: + return true; + break; + case WAIT_TIMEOUT: + break; + default: + qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); + } + return false; +} + + + +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(); + + if (!wmutex && !(wmutex = getMutexHandle(-1, true))) + return false; + + if (!waitMutex(wmutex, block)) + return false; + + if (mode == ReadLock) { + int idx = 0; + for (; idx < MAX_READERS; idx++) { + rmutex = getMutexHandle(idx, false); + if (!rmutex || waitMutex(rmutex, false)) + break; + CloseHandle(rmutex); + } + bool ok = true; + if (idx >= MAX_READERS) { + qWarning("QtLockedFile::lock(): too many readers"); + rmutex = 0; + ok = false; + } + else if (!rmutex) { + rmutex = getMutexHandle(idx, true); + if (!rmutex || !waitMutex(rmutex, false)) + ok = false; + } + if (!ok && rmutex) { + CloseHandle(rmutex); + rmutex = 0; + } + ReleaseMutex(wmutex); + if (!ok) + return false; + } + else { + Q_ASSERT(rmutexes.isEmpty()); + for (int i = 0; i < MAX_READERS; i++) { + Qt::HANDLE mutex = getMutexHandle(i, false); + if (mutex) + rmutexes.append(mutex); + } + if (rmutexes.size()) { + DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(), + TRUE, block ? INFINITE : 0); + if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) { + if (res != WAIT_TIMEOUT) + qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed"); + m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky + unlock(); + 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; + + if (m_lock_mode == ReadLock) { + ReleaseMutex(rmutex); + CloseHandle(rmutex); + rmutex = 0; + } + else { + foreach(Qt::HANDLE mutex, rmutexes) { + ReleaseMutex(mutex); + CloseHandle(mutex); + } + rmutexes.clear(); + ReleaseMutex(wmutex); + } + + m_lock_mode = QtLockedFile::NoLock; + return true; +} + +QtLockedFile::~QtLockedFile() +{ + if (isOpen()) + unlock(); + if (wmutex) + CloseHandle(wmutex); +} diff --git a/qtsingleapplication/src/qtsingleapplication.cpp b/qtsingleapplication/src/qtsingleapplication.cpp new file mode 100644 index 0000000..d0fb15d --- /dev/null +++ b/qtsingleapplication/src/qtsingleapplication.cpp @@ -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 + + +/*! + \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 +*/ diff --git a/qtsingleapplication/src/qtsingleapplication.h b/qtsingleapplication/src/qtsingleapplication.h new file mode 100644 index 0000000..049406f --- /dev/null +++ b/qtsingleapplication/src/qtsingleapplication.h @@ -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 + +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 diff --git a/qtsingleapplication/src/qtsingleapplication.pri b/qtsingleapplication/src/qtsingleapplication.pri new file mode 100644 index 0000000..6f2bced --- /dev/null +++ b/qtsingleapplication/src/qtsingleapplication.pri @@ -0,0 +1,17 @@ +include(../common.pri) +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD +QT *= network +greaterThan(QT_MAJOR_VERSION, 4): QT *= widgets + +qtsingleapplication-uselib:!qtsingleapplication-buildlib { + LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME +} else { + SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp + HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h +} + +win32 { + contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT + else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT +} diff --git a/qtsingleapplication/src/qtsinglecoreapplication.cpp b/qtsingleapplication/src/qtsinglecoreapplication.cpp new file mode 100644 index 0000000..5634537 --- /dev/null +++ b/qtsingleapplication/src/qtsinglecoreapplication.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** 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 "qtsinglecoreapplication.h" +#include "qtlocalpeer.h" + +/*! + \class QtSingleCoreApplication qtsinglecoreapplication.h + \brief A variant of the QtSingleApplication class for non-GUI applications. + + This class is a variant of QtSingleApplication suited for use in + console (non-GUI) applications. It is an extension of + QCoreApplication (instead of QApplication). It does not require + the QtGui library. + + The API and usage is identical to QtSingleApplication, except that + functions relating to the "activation window" are not present, for + obvious reasons. Please refer to the QtSingleApplication + documentation for explanation of the usage. + + A QtSingleCoreApplication instance can communicate to a + QtSingleApplication instance if they share the same application + id. Hence, this class can be used to create a light-weight + command-line tool that sends commands to a GUI application. + + \sa QtSingleApplication +*/ + +/*! + Creates a QtSingleCoreApplication object. The application identifier + will be QCoreApplication::applicationFilePath(). \a argc and \a + argv are passed on to the QCoreAppliation constructor. +*/ + +QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) + : QCoreApplication(argc, argv) +{ + peer = new QtLocalPeer(this); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + Creates a QtSingleCoreApplication object with the application + identifier \a appId. \a argc and \a argv are passed on to the + QCoreAppliation constructor. +*/ +QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv) + : QCoreApplication(argc, argv) +{ + peer = new QtLocalPeer(this, appId); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + 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 QtSingleCoreApplication::isRunning() +{ + return peer->isClient(); +} + + +/*! + Tries to send the text \a message to the currently running + instance. The QtSingleCoreApplication 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 QtSingleCoreApplication::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 QtSingleCoreApplication::id() const +{ + return peer->applicationId(); +} + + +/*! + \fn void QtSingleCoreApplication::messageReceived(const QString& message) + + This signal is emitted when the current instance receives a \a + message from another instance of this application. + + \sa sendMessage() +*/ diff --git a/qtsingleapplication/src/qtsinglecoreapplication.h b/qtsingleapplication/src/qtsinglecoreapplication.h new file mode 100644 index 0000000..b87fffe --- /dev/null +++ b/qtsingleapplication/src/qtsinglecoreapplication.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 QTSINGLECOREAPPLICATION_H +#define QTSINGLECOREAPPLICATION_H + +#include + +class QtLocalPeer; + +class QtSingleCoreApplication : public QCoreApplication +{ + Q_OBJECT + +public: + QtSingleCoreApplication(int &argc, char **argv); + QtSingleCoreApplication(const QString &id, int &argc, char **argv); + + bool isRunning(); + QString id() const; + +public Q_SLOTS: + bool sendMessage(const QString &message, int timeout = 5000); + + +Q_SIGNALS: + void messageReceived(const QString &message); + + +private: + QtLocalPeer* peer; +}; + +#endif // QTSINGLECOREAPPLICATION_H diff --git a/qtsingleapplication/src/qtsinglecoreapplication.pri b/qtsingleapplication/src/qtsinglecoreapplication.pri new file mode 100644 index 0000000..d2d6cc3 --- /dev/null +++ b/qtsingleapplication/src/qtsinglecoreapplication.pri @@ -0,0 +1,10 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD +HEADERS += $$PWD/qtsinglecoreapplication.h $$PWD/qtlocalpeer.h +SOURCES += $$PWD/qtsinglecoreapplication.cpp $$PWD/qtlocalpeer.cpp + +QT *= network + +win32:contains(TEMPLATE, lib):contains(CONFIG, shared) { + DEFINES += QT_QTSINGLECOREAPPLICATION_EXPORT=__declspec(dllexport) +} diff --git a/setting/animationwidget.cpp b/setting/animationwidget.cpp new file mode 100644 index 0000000..812e66e --- /dev/null +++ b/setting/animationwidget.cpp @@ -0,0 +1,365 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "animationwidget.h" +#include +#include "../component/agentlistitem.h" +#include "../dbusproxy/youkersystemdbus.h" +#include "../mainui/mainwindow.h" +#include +#include +#include "../component/tipdialog.h" + +AnimationWidget::AnimationWidget(QWidget *parent, SystemDispatcher *proxy, MainWindow *window) : + QWidget(parent), + systemproxy(proxy), parentWindow(window) +{ + dataOK = false; + title_label = new QLabel(); + left_widget = new QWidget(); + left_widget->setFixedWidth(240); + right_widget = new QWidget(); + right_widget->setFixedWidth(500); + +// title_label = new QLabel(); +// title_label->setFixedHeight(20); +// description_label = new QLabel(); +// description_label->setFixedHeight(20); +// back_btn = new QPushButton(); + +// QVBoxLayout *v_layout = new QVBoxLayout(); +// v_layout->addWidget(title_label); +// v_layout->addWidget(description_label); +// v_layout->setMargin(0); +// v_layout->setSpacing(1); + +// QHBoxLayout *h_layout = new QHBoxLayout(); +// h_layout->addWidget(back_btn); +// h_layout->addLayout(v_layout); +// h_layout->addStretch(); +// top_widget->setLayout(h_layout); +// top_widget->setFixedSize(900,60); +// h_layout->setSpacing(20); +// h_layout->setContentsMargins(20, 0, 0, 0); + + custom_btn = new QPushButton(); + custom_btn->setFixedSize(120, 32); + custom_btn->setObjectName("blackButton"); + custom_btn->setFocusPolicy(Qt::NoFocus); + ok_btn = new QPushButton(); + ok_btn->setFixedSize(91, 25); + ok_btn->setObjectName("blackButton"); + ok_btn->setFocusPolicy(Qt::NoFocus); + + view_widget = new QWidget(); + view_widget->setFixedSize(205, 190); + view_widget->setWindowFlags(Qt::FramelessWindowHint); + view_widget->setAutoFillBackground(true); + QPalette palette; +// palette.setColor(QPalette::Background, QColor(192,253,123)); + palette.setBrush(QPalette::Background, QBrush(QPixmap("://res/previewzone.png"))); + view_widget->setPalette(palette); + + show_widget = new QWidget(); + show_widget->setFixedSize(172, 115); +// show_widget->setWindowFlags(Qt::FramelessWindowHint); +// show_widget->setAutoFillBackground(true); +// show_widget->setObjectName("transparentWidget"); + + QVBoxLayout *layout0 = new QVBoxLayout(); + layout0->addWidget(show_widget); + layout0->addStretch(); + layout0->setMargin(0); + layout0->setSpacing(0); + view_widget->setLayout(layout0); + view_widget->setContentsMargins(16, 16, 16, 0); + + tip_label = new QLabel(); + list_widget = new QListWidget(); + list_widget->setObjectName("animationListWidget"); + +// QStringList names; +// for (int i = 1; i <= 30; ++i) +// names.append(tr("app %1").arg(i)); +// list_widget->insertItems(0, names); + list_widget->setIconSize(QSize(16, 16)); + list_widget->setResizeMode(QListView::Adjust); +// list_widget->setViewMode(QListView::IconMode); + list_widget->setMovement(QListView::Static); + list_widget->setSpacing(5); + + QHBoxLayout *layout = new QHBoxLayout(); + layout->addWidget(title_label); + layout->addStretch(); + layout->setMargin(0); + layout->setContentsMargins(20, 20, 0, 0); + + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->addStretch(); + layout1->addWidget(view_widget, Qt::AlignHCenter); + layout1->addStretch(); + + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->addStretch(); + layout2->addWidget(custom_btn, Qt::AlignHCenter); + layout2->addStretch(); + + QVBoxLayout *layout3 = new QVBoxLayout(); + layout3->addLayout(layout1); + layout3->addLayout(layout2); + layout3->addStretch(); + layout3->setAlignment(Qt::AlignHCenter); + layout3->setSpacing(20); + left_widget->setLayout(layout3); + + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->addStretch(); + layout4->addWidget(ok_btn); + + QVBoxLayout *layout5 = new QVBoxLayout(); + layout5->addWidget(tip_label); + layout5->addWidget(list_widget); + layout5->addLayout(layout4); + right_widget->setLayout(layout5); + +// QHBoxLayout *layout6 = new QHBoxLayout(); +// layout6->addWidget(left_widget); +// layout6->addWidget(right_widget); +// bottom_widget->setLayout(layout6); +// bottom_widget->setFixedWidth(850); + + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + + QHBoxLayout *widget_layout = new QHBoxLayout(); +// main_layout->addWidget(splitter); + widget_layout->addWidget(left_widget); + widget_layout->addWidget(right_widget); + widget_layout->setSpacing(60); + widget_layout->setMargin(0); + widget_layout->setContentsMargins(0, 0, 0, 0); + + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addLayout(layout); + main_layout->addLayout(widget_layout); + main_layout->setSpacing(30); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + + setLayout(main_layout); +// this->initData(); + this->setLanguage(); +} + +AnimationWidget::~AnimationWidget() +{ +// if(title_label != NULL) +// { +// delete title_label; +// title_label = NULL; +// } +// if(back_btn != NULL) +// { +// delete back_btn; +// back_btn = NULL; +// } +} + +void AnimationWidget::setLanguage() { +// title_label->setText(tr("Boot animation settings")); +// description_label->setText(tr("Click the \"Custom Picture\" button to select the picture you want to add, click the picture you want to set and push the \"OK\" button to complete.")); +// back_btn->setText(tr("Back")); + title_label->setText(tr("Please select a picture as boot animation")); + custom_btn->setText(tr("Custom Picture")); + tip_label->setText(tr("Optional BootAnimation")); + ok_btn->setText(tr("OK")); +} + +void AnimationWidget::initConnect() { +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + connect(custom_btn, SIGNAL(clicked()), this, SLOT(selectCustomAnimation())); + connect(ok_btn, SIGNAL(clicked()), this, SLOT(setCustomAnimation())); +} + +bool AnimationWidget::getStatus() +{ + return this->dataOK; +} + +void AnimationWidget::initData() +{ + + +// bootimagepage.selectedimage = plymouth_list[0]; + + systemproxy->plymouth_init_check_qt(); + QStringList valid_list; + QStringList plymouth_list = systemproxy->get_existing_plymouth_list_qt(); + for(int i=0; i < plymouth_list.length(); i++) { + if(systemproxy->get_image_path_qt(plymouth_list[i]) != "False"){ +// mainModel.append({"itemTitle": plymouth_list[i]}); + valid_list.append(plymouth_list[i]); + } + } + + for(int nIndex = 0;nIndex < valid_list.length();++nIndex) + { + QString strPath=QString("://res/picture.png"); + QPixmap objPixmap(strPath); +// //生成QListWidgetItem对象(注意:其Icon图像进行了伸缩[16*16])---scaled函数 +// QListWidgetItem *pItem = new QListWidgetItem(QIcon(objPixmap.scaled(QSize(16,16))), tr("animal picture %1").arg(nIndex)); +// //设置单元项的宽度和高度 +// pItem->setSizeHint(QSize(130,20)); +// pItem->setBackgroundColor(QColor(0, 0, 255, 127)); +// pItem->setTextColor(QColor(0, 0, 255, 127)); +// list_widget->insertItem(nIndex, pItem); + + AgentListItem *account_item = new AgentListItem(); + account_item->setCurrentItemName(QString(valid_list[nIndex])); + connect(account_item, SIGNAL(showItemName(QString)), this, SLOT(displayCurrentItemInfo(QString))); + connect(account_item, SIGNAL(removeItem(QString)), this, SLOT(deleteSelectedAnimation(QString))); + QListWidgetItem *item = new QListWidgetItem(list_widget); +// item->setSizeHint(QSize(130,20)); +// item->setBackgroundColor(QColor(0, 0, 255, 127)); + item->setIcon(QIcon(objPixmap.scaled(QSize(16,16)))); + list_widget->setItemWidget(item, account_item); + } +// connect(list_widget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(onItemClicked(QListWidgetItem*))); + dataOK = true; + this->initConnect(); +} + +void AnimationWidget::selectCustomAnimation() +{ + show_widget->setWindowFlags(Qt::FramelessWindowHint); + show_widget->setAutoFillBackground(true); +// show_widget->setObjectName("transparentWidget"); + + QStringList fileNameList; + QString abs_path; + QFileDialog* fd = new QFileDialog(this); + fd->resize(500, 471); + fd->setFilter(tr("Image Files (*.png *.jpg *.gif)")); + fd->setViewMode(QFileDialog::List);//设置浏览模式,有 列表(list) 模式和 详细信息(detail)两种方式 + if (fd->exec() == QDialog::Accepted) + { + fileNameList = fd->selectedFiles(); + abs_path = fileNameList[0]; + int start_pos = abs_path.lastIndexOf("/") + 1; + int end_pos = abs_path.length(); + QString pic_name = abs_path.mid(start_pos, end_pos-start_pos); + this->selected_animation = pic_name; + QPalette palette; + // palette.setBrush(QPalette::Background, QBrush(QPixmap("://res/ubuntukylin.png").scaled(180, 170, Qt::KeepAspectRatio))); + palette.setBrush(QPalette::Background, QBrush(QPixmap(abs_path).scaled(172, 115, Qt::KeepAspectRatio))); + show_widget->setPalette(palette); + systemproxy->add_new_plymouth_qt(abs_path, pic_name); + //update date + list_widget->clear(); + this->initData(); + } + else + fd->close(); +} + +void AnimationWidget::setCustomAnimation() +{ +// QList::const_iterator i=list_widget.begin(); +// qDebug() << (*i)->text(); + systemproxy->custom_plymouth_bg_qt(this->selected_animation); +} + +void AnimationWidget::deleteSelectedAnimation(QString name) +{ + QString result = systemproxy->delete_plymouth_qt(name); + if (result == "ok") { +// toolkits.alertMSG(qsTr("Deleted successfully!"));//删除成功! +// qDebug() << "Deleted successfully!"; + + int list_count = list_widget->count(); + for(int i=0; i < list_count; i++) + { + QListWidgetItem *item = list_widget->item(i); + AgentListItem *account_item = (AgentListItem *)(list_widget->itemWidget(item)); + QString cur_name = account_item->getCurrentItemName(); + if(name == cur_name) + { + list_widget->takeItem(i); + delete item; + break; + } + } + TipDialog *dialog = new TipDialog(0, tr("Deleted successfully!")); + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (180 / 2); + dialog->move(w_x, w_y); + dialog->show(); + dialog->raise(); + } + else if (result == "use") { +// qDebug() << "This is the using animation!"; + TipDialog *dialog = new TipDialog(0, tr("This is the using animation!")); + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (180 / 2); + dialog->move(w_x, w_y); + dialog->show(); + dialog->raise(); +// toolkits.alertMSG(qsTr("This is the using animation!"));//该动画为当前使用动画! + } + else if (result == "sys") { + qDebug() << "This is the default animation!"; + TipDialog *dialog = new TipDialog(0, tr("This is the default animation!")); + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (180 / 2); + dialog->move(w_x, w_y); + dialog->show(); + dialog->raise(); +// toolkits.alertMSG(qsTr("This is the default animation!"));//该动画为系统默认动画! + } + else { +// qDebug() << "An unknown error occurred!"; + TipDialog *dialog = new TipDialog(0, tr("An unknown error occurred!")); + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (410 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (180 / 2); + dialog->move(w_x, w_y); + dialog->show(); + dialog->raise(); +// toolkits.alertMSG(qsTr("An unknown error occurred!"));//发生未知错误! + } +} + +void AnimationWidget::displayCurrentItemInfo(QString info) +{ + this->selected_animation = info; + int list_count = list_widget->count(); + for(int i=0; i < list_count; i++) + { + QListWidgetItem *item = list_widget->item(i); + AgentListItem *account_item = (AgentListItem *)(list_widget->itemWidget(item)); + QString cur_name = account_item->getCurrentItemName(); + if(info == cur_name) + { + list_widget->setCurrentItem(item); + break; + } + } +} diff --git a/setting/animationwidget.h b/setting/animationwidget.h new file mode 100644 index 0000000..618e917 --- /dev/null +++ b/setting/animationwidget.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef ANIMATIONWIDGET_H +#define ANIMATIONWIDGET_H + +#include +#include + +class SystemDispatcher; +class MainWindow; +class QLabel; +class QPushButton; + +class AnimationWidget : public QWidget +{ + Q_OBJECT +public: + explicit AnimationWidget(QWidget *parent = 0, SystemDispatcher *proxy = 0, MainWindow *window = 0); + ~AnimationWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + +public slots: + void selectCustomAnimation(); + void setCustomAnimation(); + void deleteSelectedAnimation(QString name); + void displayCurrentItemInfo(QString info); + +private: + SystemDispatcher *systemproxy; + bool dataOK; + MainWindow *parentWindow; + QWidget * left_widget; + QWidget * right_widget; + + QLabel *title_label; + QPushButton *custom_btn; + QPushButton *ok_btn; + QWidget *view_widget; + QWidget *show_widget; + QLabel *tip_label; + + QListWidget *list_widget; + QString selected_animation; +}; + +#endif // ANIMATIONWIDGET_H diff --git a/setting/conservewidget.cpp b/setting/conservewidget.cpp new file mode 100644 index 0000000..925daca --- /dev/null +++ b/setting/conservewidget.cpp @@ -0,0 +1,879 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "conservewidget.h" +#include +#include +#include +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" +#include + +ConserveWidget::ConserveWidget(QWidget *parent, SessionDispatcher *proxy, QString cur_desktop, bool has_battery) : + QWidget(parent),desktop(cur_desktop), + sessionproxy(proxy) +{ + iface = NULL; + dataOK = false; + gamma_label = new QLabel(); + gamma_slider = new QDoubleSpinBox(); + gamma_slider->setButtonSymbols(QAbstractSpinBox::PlusMinus); + gamma_slider->setSingleStep(0.1); + gamma_slider->setMinimum(0.1); + gamma_slider->setMaximum(1.0); + + brightness_label = new QLabel(); + brightness_value_label = new QLabel(); + brightness_slider = new QSlider(Qt::Horizontal); + brightness_slider->setFocusPolicy(Qt::NoFocus); + brightness_slider->setRange(1, 100); + brightness_slider->setSingleStep(1); + + idle_delay_label = new QLabel(); + idle_delay_combo = new QComboBox(); + lock_enabled_label = new QLabel(); + lock_enabled_switch = new KylinSwitcher(); + lock_delay_label = new QLabel(); + lock_delay_combo = new QComboBox(); + + + critical_low_label = new QLabel(); + suspend_low_radio = new QRadioButton(); + shutdown_radio = new QRadioButton(); + QButtonGroup *btnGroup1 = new QButtonGroup(); + btnGroup1->addButton(suspend_low_radio); + btnGroup1->addButton(shutdown_radio); + suspend_low_radio->setFocusPolicy(Qt::NoFocus); + suspend_low_radio->setObjectName("suspend_low_radio"); + shutdown_radio->setFocusPolicy(Qt::NoFocus); + shutdown_radio->setObjectName("shutdown_radio"); + laptop_lid_battery_label = new QLabel(); + suspend_lid_battery_radio = new QRadioButton(); + nothing_battery_radio = new QRadioButton(); + QButtonGroup *btnGroup2 = new QButtonGroup(); + btnGroup2->addButton(suspend_lid_battery_radio); + btnGroup2->addButton(nothing_battery_radio); + suspend_lid_battery_radio->setFocusPolicy(Qt::NoFocus); + suspend_lid_battery_radio->setObjectName("suspend_lid_battery_radio"); + nothing_battery_radio->setFocusPolicy(Qt::NoFocus); + nothing_battery_radio->setObjectName("nothing_battery_radio"); + laptop_lid_ac_label = new QLabel(); + suspend_lid_ac_radio = new QRadioButton(); + nothing_ac_radio = new QRadioButton(); + QButtonGroup *btnGroup3 = new QButtonGroup(); + btnGroup3->addButton(suspend_lid_ac_radio); + btnGroup3->addButton(nothing_ac_radio); + suspend_lid_ac_radio->setFocusPolicy(Qt::NoFocus); + suspend_lid_ac_radio->setObjectName("suspend_lid_ac_radio"); + nothing_ac_radio->setFocusPolicy(Qt::NoFocus); + nothing_ac_radio->setObjectName("nothing_ac_radio"); + sleep_battery_label = new QLabel(); + sleep_battery_combo = new QComboBox(); + sleep_ac_label = new QLabel(); + sleep_ac_combo = new QComboBox(); + sleep_battery_display_label = new QLabel(); + sleep_battery_display_combo = new QComboBox(); + sleep_ac_display_label = new QLabel(); + sleep_ac_display_combo = new QComboBox(); + + + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + brightness_label->hide(); + brightness_value_label->hide(); + brightness_slider->hide(); + } + else { + sleep_battery_display_label->hide(); + sleep_battery_display_combo->hide(); + sleep_ac_display_label->hide(); + sleep_ac_display_combo->hide(); + } + +// if(!sessionproxy->judge_power_is_exists_qt()) + if(has_battery == false) + { + critical_low_label->hide(); + suspend_low_radio->hide(); + shutdown_radio->hide(); + laptop_lid_battery_label->hide(); + suspend_lid_battery_radio->hide(); + nothing_battery_radio->hide(); + sleep_battery_label->hide(); + sleep_battery_combo->hide(); + laptop_lid_ac_label->hide(); + suspend_lid_ac_radio->hide(); + nothing_ac_radio->hide(); + sleep_battery_display_label->hide(); + sleep_battery_display_combo->hide(); + } + + gamma_label->setFixedWidth(260); + brightness_label->setFixedWidth(260); + idle_delay_label->setFixedWidth(260); + lock_enabled_label->setFixedWidth(260); + lock_delay_label->setFixedWidth(260); + critical_low_label->setFixedWidth(260); + laptop_lid_battery_label->setFixedWidth(260); + laptop_lid_ac_label->setFixedWidth(260); + sleep_battery_label->setFixedWidth(260); + sleep_ac_label->setFixedWidth(260); + sleep_battery_display_label->setFixedWidth(260); + sleep_ac_display_label->setFixedWidth(260); + + QHBoxLayout *layout0 = new QHBoxLayout(); + layout0->setSpacing(10); + layout0->addWidget(gamma_label); + layout0->addWidget(gamma_slider); + layout0->addStretch(); + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->setSpacing(10); + layout1->addWidget(brightness_label); + layout1->addWidget(brightness_slider); + layout1->addWidget(brightness_value_label); + layout1->addStretch(); + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->setSpacing(10); + layout2->addWidget(idle_delay_label); + layout2->addWidget(idle_delay_combo); + layout2->addStretch(); + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->setSpacing(10); + layout3->addWidget(lock_enabled_label); + layout3->addWidget(lock_enabled_switch); + layout3->addStretch(); + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->setSpacing(10); + layout4->addWidget(lock_delay_label); + layout4->addWidget(lock_delay_combo); + layout4->addStretch(); + QHBoxLayout *layout5 = new QHBoxLayout(); + layout5->setSpacing(10); + layout5->addWidget(critical_low_label); + layout5->addWidget(suspend_low_radio); + layout5->addWidget(shutdown_radio); +// layout5->addWidget(btnGroup); + layout5->addStretch(); + QHBoxLayout *layout6 = new QHBoxLayout(); + layout6->setSpacing(10); + layout6->addWidget(laptop_lid_battery_label); + layout6->addWidget(suspend_lid_battery_radio); + layout6->addWidget(nothing_battery_radio); + layout6->addStretch(); + QHBoxLayout *layout7 = new QHBoxLayout(); + layout7->setSpacing(10); + layout7->addWidget(laptop_lid_ac_label); + layout7->addWidget(suspend_lid_ac_radio); + layout7->addWidget(nothing_ac_radio); + layout7->addStretch(); + QHBoxLayout *layout8 = new QHBoxLayout(); + layout8->setSpacing(10); + layout8->addWidget(sleep_battery_label); + layout8->addWidget(sleep_battery_combo); + layout8->addStretch(); + QHBoxLayout *layout9 = new QHBoxLayout(); + layout9->setSpacing(10); + layout9->addWidget(sleep_ac_label); + layout9->addWidget(sleep_ac_combo); + layout9->addStretch(); + QHBoxLayout *layout10 = new QHBoxLayout(); + layout10->setSpacing(10); + layout10->addWidget(sleep_battery_display_label); + layout10->addWidget(sleep_battery_display_combo); + layout10->addStretch(); + QHBoxLayout *layout11 = new QHBoxLayout(); + layout11->setSpacing(10); + layout11->addWidget(sleep_ac_display_label); + layout11->addWidget(sleep_ac_display_combo); + layout11->addStretch(); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(layout0); + layout->addLayout(layout1); + layout->addLayout(layout2); + layout->addLayout(layout3); + layout->addLayout(layout4); + layout->addLayout(layout5); + layout->addLayout(layout6); + layout->addLayout(layout7); + layout->addLayout(layout8); + layout->addLayout(layout9); + layout->addLayout(layout10); + layout->addLayout(layout11); + layout->addStretch(); + setLayout(layout); + layout->setSpacing(10); + layout->setContentsMargins(20, 20, 0, 0); + +// this->initData(); + this->setLanguage(); +} + +ConserveWidget::~ConserveWidget() +{ + if (iface != NULL) { + delete iface; + iface = NULL; + } + if (gamma_label != NULL) { + delete gamma_label; + gamma_label = NULL; + } + if (gamma_slider != NULL) { + delete gamma_slider; + gamma_slider = NULL; + } + if (brightness_label != NULL) { + delete brightness_label; + brightness_label = NULL; + } + if (brightness_value_label != NULL) { + delete brightness_value_label; + brightness_value_label = NULL; + } + if (brightness_slider != NULL) { + delete brightness_slider; + brightness_slider = NULL; + } + if (idle_delay_label != NULL) { + delete idle_delay_label; + idle_delay_label = NULL; + } + if (idle_delay_combo != NULL) { + delete idle_delay_combo; + idle_delay_combo = NULL; + } + if (lock_enabled_label != NULL) { + delete lock_enabled_label; + lock_enabled_label = NULL; + } + if (lock_enabled_switch != NULL) { + delete lock_enabled_switch; + lock_enabled_switch = NULL; + } + if (lock_delay_label != NULL) { + delete lock_delay_label; + lock_delay_label = NULL; + } + if (lock_delay_combo != NULL) { + delete lock_delay_combo; + lock_delay_combo = NULL; + } + if (critical_low_label != NULL) { + delete critical_low_label; + critical_low_label = NULL; + } + if (suspend_low_radio != NULL) { + delete suspend_low_radio; + suspend_low_radio = NULL; + } + if (shutdown_radio != NULL) { + delete shutdown_radio; + shutdown_radio = NULL; + } + if (laptop_lid_battery_label != NULL) { + delete laptop_lid_battery_label; + laptop_lid_battery_label = NULL; + } + if (suspend_lid_battery_radio != NULL) { + delete suspend_lid_battery_radio; + suspend_lid_battery_radio = NULL; + } + if (nothing_battery_radio != NULL) { + delete nothing_battery_radio; + nothing_battery_radio = NULL; + } + if (laptop_lid_ac_label != NULL) { + delete laptop_lid_ac_label; + laptop_lid_ac_label = NULL; + } + if (suspend_lid_ac_radio != NULL) { + delete suspend_lid_ac_radio; + suspend_lid_ac_radio = NULL; + } + if (nothing_ac_radio != NULL) { + delete nothing_ac_radio; + nothing_ac_radio = NULL; + } + if (sleep_battery_label != NULL) { + delete sleep_battery_label; + sleep_battery_label = NULL; + } + if (sleep_battery_combo != NULL) { + delete sleep_battery_combo; + sleep_battery_combo = NULL; + } + if (sleep_ac_label != NULL) { + delete sleep_ac_label; + sleep_ac_label = NULL; + } + if (sleep_ac_combo != NULL) { + delete sleep_ac_combo; + sleep_ac_combo = NULL; + } + if (sleep_battery_display_label != NULL) { + delete sleep_battery_display_label; + sleep_battery_display_label = NULL; + } + if (sleep_battery_display_combo != NULL) { + delete sleep_battery_display_combo; + sleep_battery_display_combo = NULL; + } + if (sleep_ac_display_label != NULL) { + delete sleep_ac_display_label; + sleep_ac_display_label = NULL; + } + if (sleep_ac_display_combo != NULL) { + delete sleep_ac_display_combo; + sleep_ac_display_combo = NULL; + } +} + +void ConserveWidget::setLanguage() { + gamma_label->setText(tr("Adjust gamma") + ":"); + brightness_label->setText(tr("Adjust brightness") + ":"); + idle_delay_label->setText(tr("Time before session is considered idle") + ":");//在一定时间范围内无操作则关闭屏幕 + lock_enabled_label->setText(tr("Lock screen") + ":");//锁定屏幕 + lock_delay_label->setText(tr("Lock delay") + ":");//锁屏延时 + critical_low_label->setText(tr("Battery critical low action") + ":");//电池严重不足时 + laptop_lid_battery_label->setText(tr("Laptop lid close action on battery") + ":");//合上盖子时 + laptop_lid_ac_label->setText(tr("Laptop lid close action on AC") + ":");//合上盖子时 + sleep_battery_label->setText(tr("Sleep timeout PC when on battery") + ":");//使用电池,空闲此时间后电脑转入睡眠 + sleep_ac_label->setText(tr("Sleep timeout PC when on AC") + ":");//使用电源,空闲此时间后电脑转入睡眠 + sleep_battery_display_label->setText(tr("Sleep timeout display when on battery") + ":");//使用电池,空闲此时间后屏幕转入睡眠 + sleep_ac_display_label->setText(tr("Sleep timeout display when on AC") + ":");//使用电源,空闲此时间后屏幕转入睡眠 + suspend_low_radio->setText(tr("suspend"));//休眠 + shutdown_radio->setText(tr("shutdown"));//电源关闭 + suspend_lid_battery_radio->setText(tr("suspend"));//挂起 + nothing_battery_radio->setText(tr("nothing"));//不处理 + suspend_lid_ac_radio->setText(tr("suspend"));//挂起 + nothing_ac_radio->setText(tr("nothing"));//不处理 +} + +bool ConserveWidget::getStatus() +{ + return this->dataOK; +} + +void ConserveWidget::initData() +{ + iface = new QDBusInterface("org.gnome.SettingsDaemon", + "/org/gnome/SettingsDaemon/Power", + "org.gnome.SettingsDaemon.Power.Screen", + QDBusConnection::sessionBus()); + gamma_slider->setValue(sessionproxy->get_screen_gamma_qt()); + + QStringList aclist = sessionproxy->get_sleep_timeout_list_qt(); + bool inHere = false; + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + sleep_timeout_display_battery = sessionproxy->get_current_sleep_timeout_display_battery_qt(); + QStringList huname_display_battery_list; + huname_display_battery_list << tr("5 minutes") << tr("10 minutes") << tr("20 minutes") << tr("Half an hour") << tr("1 hour") << tr("2 hours") << tr("never"); + QList::Iterator it5 = aclist.begin(), itend5 = aclist.end(); + int initIndex5 = 0; + inHere = false; + for(;it5 != itend5; it5++,initIndex5++) + { + if(*it5 == sleep_timeout_display_battery) { + inHere = true; + break; + } + } + if (inHere == false) { + huname_display_battery_list << sleep_timeout_display_battery; + initIndex5 = huname_display_battery_list.length() - 1; + } + sleep_battery_display_combo->clear(); + sleep_battery_display_combo->clearEditText(); + sleep_battery_display_combo->addItems(huname_display_battery_list); + sleep_battery_display_combo->setCurrentIndex(initIndex5); + + sleep_timeout_display_ac = sessionproxy->get_current_sleep_timeout_display_ac_qt(); + QStringList huname_display_ac_list; + huname_display_ac_list << tr("5 minutes") << tr("10 minutes") << tr("20 minutes") << tr("Half an hour") << tr("1 hour") << tr("2 hours") << tr("never"); + QList::Iterator it6 = aclist.begin(), itend6 = aclist.end(); + int initIndex6 = 0; + inHere = false; + for(;it6 != itend6; it6++,initIndex6++) + { + if(*it6 == sleep_timeout_display_ac) { + inHere = true; + break; + } + } + if (inHere == false) { + huname_display_ac_list << sleep_timeout_display_ac; + initIndex6 = huname_display_ac_list.length() - 1; + } + sleep_ac_display_combo->clear(); + sleep_ac_display_combo->clearEditText(); + sleep_ac_display_combo->addItems(huname_display_ac_list); + sleep_ac_display_combo->setCurrentIndex(initIndex6); + } + else { + QDBusReply reply = iface->call("GetPercentage"); + if (reply.isValid()) { + brightness_slider->setValue(reply.value()); + brightness_value_label->setText(QString::number(brightness_slider->value())); + } + else + { + brightness_label->hide(); + brightness_value_label->hide(); + brightness_slider->hide(); + } + } + + current_idle_delay = sessionproxy->get_current_idle_delay_qt(); + QStringList idledelaylist = sessionproxy->get_idle_delay_list_qt(); + QStringList huname_idle_list; + huname_idle_list << tr("1 minute") << tr("2 minutes") << tr("3 minutes") << tr("5 minutes") << tr("10 minutes") << tr("Half an hour") << tr("1 hour") << tr("never"); + QList::Iterator it1 = idledelaylist.begin(), itend1 = idledelaylist.end(); + int initIndex1 = 0; + + for(;it1 != itend1; it1++,initIndex1++) + { + if(*it1 == current_idle_delay) { + inHere = true; + break; + } + } + if (inHere == false) { + huname_idle_list << current_idle_delay; + initIndex1 = huname_idle_list.length() - 1; + } + idle_delay_combo->clear(); + idle_delay_combo->clearEditText(); + idle_delay_combo->addItems(huname_idle_list); + idle_delay_combo->setCurrentIndex(initIndex1); + + lock_enabled_switch->switchedOn = sessionproxy->get_lock_enabled_qt(); + if(lock_enabled_switch->switchedOn) + { + lock_delay_combo->setDisabled(false); + } + else { + lock_delay_combo->setDisabled(true); + } + + current_lock_delay = sessionproxy->get_current_lock_delay_qt(); + QStringList lockdelaylist = sessionproxy->get_lock_delay_list_qt(); + QStringList huname_lock_list; + huname_lock_list << tr("30 seconds") << tr("1 minute") << tr("2 minutes") << tr("3 minutes") << tr("5 minutes") << tr("10 minutes") << tr("Half an hour") << tr("1 hour") << tr("Turn off the screen"); + QList::Iterator it2 = lockdelaylist.begin(), itend2 = lockdelaylist.end(); + int initIndex2 = 0; + inHere = false; + for(;it2 != itend2; it2++,initIndex2++) + { + if(*it2 == current_lock_delay) { + inHere = true; + break; + } + } + if (inHere == false) { + huname_lock_list << current_lock_delay; + initIndex2 = huname_lock_list.length() - 1; + } + lock_delay_combo->clear(); + lock_delay_combo->clearEditText(); + lock_delay_combo->addItems(huname_lock_list); + lock_delay_combo->setCurrentIndex(initIndex2); + + QString critical_low = sessionproxy->get_current_critical_low_qt(); + if(critical_low == "suspend" ) { + suspend_low_radio->setChecked(true); + shutdown_radio->setChecked(false); + } + else if(critical_low == "shutdown") { + shutdown_radio->setChecked(true); + suspend_low_radio->setChecked(false); + } + QString laptop_battery = sessionproxy->get_current_lid_battery_qt(); + if(laptop_battery == "suspend") { + suspend_lid_battery_radio->setChecked(true); + nothing_battery_radio->setChecked(false); + } + else if(laptop_battery == "nothing") { + nothing_battery_radio->setChecked(true); + suspend_lid_battery_radio->setChecked(false); + } + QString laptop_ac = sessionproxy->get_current_lid_ac_qt(); + if(laptop_ac == "suspend") { + suspend_lid_ac_radio->setChecked(true); + nothing_ac_radio->setChecked(false); + } + else if(laptop_ac == "nothing") { + nothing_ac_radio->setChecked(true); + suspend_lid_ac_radio->setChecked(false); + } + + sleep_timeout_battery = sessionproxy->get_current_sleep_timeout_battery_qt(); + QStringList batterylist = sessionproxy->get_sleep_timeout_list_qt(); + QStringList huname_battery_list; + huname_battery_list << tr("5 minutes") << tr("10 minutes") << tr("20 minutes") << tr("Half an hour") << tr("1 hour") << tr("2 hours") << tr("never"); + QList::Iterator it3 = batterylist.begin(), itend3 = batterylist.end(); + int initIndex3 = 0; + inHere = false; + for(;it3 != itend3; it3++,initIndex3++) + { + if(*it3 == sleep_timeout_battery) { + inHere = true; + break; + } + } + if (inHere == false) { + huname_battery_list << sleep_timeout_battery; + initIndex3 = huname_battery_list.length() - 1; + } + sleep_battery_combo->clear(); + sleep_battery_combo->clearEditText(); + sleep_battery_combo->addItems(huname_battery_list); + sleep_battery_combo->setCurrentIndex(initIndex3); + + sleep_timeout_ac = sessionproxy->get_current_sleep_timeout_ac_qt(); + QStringList huname_ac_list; + huname_ac_list << tr("5 minutes") << tr("10 minutes") << tr("20 minutes") << tr("Half an hour") << tr("1 hour") << tr("2 hours") << tr("never"); + QList::Iterator it4 = aclist.begin(), itend4 = aclist.end(); + int initIndex4 = 0; + inHere = false; + for(;it4 != itend4; it4++,initIndex4++) + { + if(*it4 == sleep_timeout_ac) { + inHere = true; + break; + } + } + if (inHere == false) { + huname_ac_list << sleep_timeout_ac; + initIndex4 = huname_ac_list.length() - 1; + } + sleep_ac_combo->clear(); + sleep_ac_combo->clearEditText(); + sleep_ac_combo->addItems(huname_ac_list); + sleep_ac_combo->setCurrentIndex(initIndex4); + + dataOK = true; + this->initConnect(); +} + +void ConserveWidget::initConnect() { + connect(gamma_slider, SIGNAL(valueChanged(double)), this, SLOT(setScreenGammaValue(double))); + connect(brightness_slider, SIGNAL(valueChanged(int)), this, SLOT(setBrightnessValue(int))); +// connect(idle_delay_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setIdleDelay(QString))); + connect(idle_delay_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setIdleDelay(int))); + connect(lock_enabled_switch, SIGNAL(clicked()), this, SLOT(setLockEnabled())); +// connect(lock_delay_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setLockDelay(QString))); + connect(lock_delay_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setLockDelay(int))); + connect(suspend_low_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + connect(shutdown_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + connect(suspend_lid_battery_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + connect(nothing_battery_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + connect(suspend_lid_ac_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + connect(nothing_ac_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + connect(sleep_battery_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setSleepTimeoutBattery(int))); + connect(sleep_ac_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setSleepTimeoutAC(int))); + connect(sleep_battery_display_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setSleepTimeoutDisplayBattery(int))); + connect(sleep_ac_display_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setSleepTimeoutDisplayAC(int))); +} + +void ConserveWidget::setScreenGammaValue(double value) +{ + sessionproxy->adjust_screen_gamma_qt(value); +} + +void ConserveWidget::setBrightnessValue(int value) +{ + brightness_value_label->setText(QString::number(value)); + iface->call("setPercentage", value); +} + +//void ConserveWidget::setIdleDelay(QString value) +void ConserveWidget::setIdleDelay(int index) +{ + if (index == 0) + { + sessionproxy->set_current_idle_delay_qt(60); + } + else if (index == 1) + { + sessionproxy->set_current_idle_delay_qt(120); + } + else if (index == 2) + { + sessionproxy->set_current_idle_delay_qt(180); + } + else if (index == 3) + { + sessionproxy->set_current_idle_delay_qt(300); + } + else if (index == 4) + { + sessionproxy->set_current_idle_delay_qt(600); + } + else if (index == 5) + { + sessionproxy->set_current_idle_delay_qt(1800); + } + else if (index == 6) + { + sessionproxy->set_current_idle_delay_qt(3600); + } + else if (index == 7) + { + sessionproxy->set_current_idle_delay_qt(0); + } + else if (index == 8) + { + sessionproxy->set_current_idle_delay_qt(current_idle_delay.toInt()); + } +// sessionproxy->set_current_idle_delay_qt(value.toInt()); +} + +void ConserveWidget::setLockEnabled() +{ + sessionproxy->set_lock_enabled_qt(lock_enabled_switch->switchedOn); + if (lock_enabled_switch->switchedOn) { + lock_delay_combo->setDisabled(false); + } + else { + lock_delay_combo->setDisabled(true); + } +} + +//void ConserveWidget::setLockDelay(QString value) +void ConserveWidget::setLockDelay(int index) +{ + if (index == 0) + { + sessionproxy->set_current_lock_delay_qt(30); + } + else if (index == 1) + { + sessionproxy->set_current_lock_delay_qt(60); + } + else if (index == 2) + { + sessionproxy->set_current_lock_delay_qt(120); + } + else if (index == 3) + { + sessionproxy->set_current_lock_delay_qt(180); + } + else if (index == 4) + { + sessionproxy->set_current_lock_delay_qt(300); + } + else if (index == 5) + { + sessionproxy->set_current_lock_delay_qt(600); + } + else if (index == 6) + { + sessionproxy->set_current_lock_delay_qt(1800); + } + else if (index == 7) + { + sessionproxy->set_current_lock_delay_qt(3600); + } + else if (index == 8) + { + sessionproxy->set_current_lock_delay_qt(0); + } + else if (index == 9) + { + sessionproxy->set_current_lock_delay_qt(current_lock_delay.toInt()); + } +// sessionproxy->set_current_lock_delay_qt(value.toInt()); +} + +void ConserveWidget::setRadioButtonRowStatus() +{ + QObject *obj = sender(); //返回发出信号的对象,用QObject类型接收 + QRadioButton* pbtn = qobject_cast(obj); + QString obj_name = pbtn->objectName(); + if(obj_name == "suspend_low_radio") + { + sessionproxy->set_current_critical_low_qt("suspend"); + } + else if(obj_name == "shutdown_radio") + { + sessionproxy->set_current_critical_low_qt("shutdown"); + } + else if(obj_name == "suspend_lid_battery_radio") + { + sessionproxy->set_current_lid_battery_qt("suspend"); + } + else if(obj_name == "nothing_battery_radio") + { + sessionproxy->set_current_lid_battery_qt("nothing"); + } + else if(obj_name == "suspend_lid_ac_radio") + { + sessionproxy->set_current_lid_ac_qt("suspend"); + } + else if(obj_name == "nothing_ac_radio") + { + sessionproxy->set_current_lid_ac_qt("nothing"); + } +} + +void ConserveWidget::setSleepTimeoutBattery(int index) +{ + if (index == 0) + { + sessionproxy->set_current_sleep_timeout_battery_qt(300); + } + else if (index == 1) + { + sessionproxy->set_current_sleep_timeout_battery_qt(600); + } + else if (index == 2) + { + sessionproxy->set_current_sleep_timeout_battery_qt(1200); + } + else if (index == 3) + { + sessionproxy->set_current_sleep_timeout_battery_qt(1800); + } + else if (index == 4) + { + sessionproxy->set_current_sleep_timeout_battery_qt(3600); + } + else if (index == 5) + { + sessionproxy->set_current_sleep_timeout_battery_qt(7200); + } + else if (index == 6) + { + sessionproxy->set_current_sleep_timeout_battery_qt(0); + } + else if (index == 7) + { + sessionproxy->set_current_sleep_timeout_battery_qt(sleep_timeout_battery.toInt()); + } +} + +void ConserveWidget::setSleepTimeoutAC(int index) +{ + if (index == 0) + { + sessionproxy->set_current_sleep_timeout_ac_qt(300); + } + else if (index == 1) + { + sessionproxy->set_current_sleep_timeout_ac_qt(600); + } + else if (index == 2) + { + sessionproxy->set_current_sleep_timeout_ac_qt(1200); + } + else if (index == 3) + { + sessionproxy->set_current_sleep_timeout_ac_qt(1800); + } + else if (index == 4) + { + sessionproxy->set_current_sleep_timeout_ac_qt(3600); + } + else if (index == 5) + { + sessionproxy->set_current_sleep_timeout_ac_qt(7200); + } + else if (index == 6) + { + sessionproxy->set_current_sleep_timeout_ac_qt(0); + } + else if (index == 7) + { + sessionproxy->set_current_sleep_timeout_ac_qt(sleep_timeout_ac.toInt()); + } +} + +void ConserveWidget::setSleepTimeoutDisplayBattery(int index) +{ + if (index == 0) + { + sessionproxy->set_current_sleep_timeout_display_battery_qt(300); + } + else if (index == 1) + { + sessionproxy->set_current_sleep_timeout_display_battery_qt(600); + } + else if (index == 2) + { + sessionproxy->set_current_sleep_timeout_display_battery_qt(1200); + } + else if (index == 3) + { + sessionproxy->set_current_sleep_timeout_display_battery_qt(1800); + } + else if (index == 4) + { + sessionproxy->set_current_sleep_timeout_display_battery_qt(3600); + } + else if (index == 5) + { + sessionproxy->set_current_sleep_timeout_display_battery_qt(7200); + } + else if (index == 6) + { + sessionproxy->set_current_sleep_timeout_display_battery_qt(0); + } + else if (index == 7) + { + sessionproxy->set_current_sleep_timeout_display_battery_qt(sleep_timeout_battery.toInt()); + } +} + +void ConserveWidget::setSleepTimeoutDisplayAC(int index) +{ + if (index == 0) + { + sessionproxy->set_current_sleep_timeout_display_ac_qt(300); + } + else if (index == 1) + { + sessionproxy->set_current_sleep_timeout_display_ac_qt(600); + } + else if (index == 2) + { + sessionproxy->set_current_sleep_timeout_display_ac_qt(1200); + } + else if (index == 3) + { + sessionproxy->set_current_sleep_timeout_display_ac_qt(1800); + } + else if (index == 4) + { + sessionproxy->set_current_sleep_timeout_display_ac_qt(3600); + } + else if (index == 5) + { + sessionproxy->set_current_sleep_timeout_display_ac_qt(7200); + } + else if (index == 6) + { + sessionproxy->set_current_sleep_timeout_display_ac_qt(0); + } + else if (index == 7) + { + sessionproxy->set_current_sleep_timeout_display_ac_qt(sleep_timeout_battery.toInt()); + } +} diff --git a/setting/conservewidget.h b/setting/conservewidget.h new file mode 100644 index 0000000..8c3b669 --- /dev/null +++ b/setting/conservewidget.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CONSERVEWIDGET_H +#define CONSERVEWIDGET_H + +#include +#include "../component/kylinswitcher.h" + +#include +#include +#include + +class QLabel; +class QComboBox; +class QDoubleSpinBox; +class QSlider; +class QRadioButton; + +class SessionDispatcher; + +class ConserveWidget : public QWidget +{ + Q_OBJECT +public: + explicit ConserveWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0, QString cur_desktop = "", bool has_battery = false); + ~ConserveWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + +public slots: + void setScreenGammaValue(double value); + void setBrightnessValue(int value); +// void setIdleDelay(QString value); + void setIdleDelay(int index); + void setLockEnabled(); +// void setLockDelay(QString value); + void setLockDelay(int index); + void setRadioButtonRowStatus(); + void setSleepTimeoutBattery(int index); + void setSleepTimeoutAC(int index); + void setSleepTimeoutDisplayBattery(int index); + void setSleepTimeoutDisplayAC(int index); + +private: + QDBusInterface *iface; + SessionDispatcher *sessionproxy; + QString desktop; + bool dataOK; + QString current_idle_delay; + QString current_lock_delay; + QString sleep_timeout_battery; + QString sleep_timeout_ac; + QString sleep_timeout_display_battery; + QString sleep_timeout_display_ac; + QLabel *gamma_label; + QDoubleSpinBox *gamma_slider; + QLabel *brightness_label; + QLabel *brightness_value_label; + QSlider *brightness_slider; + QLabel *idle_delay_label; + QComboBox *idle_delay_combo; + QLabel *lock_enabled_label; + KylinSwitcher *lock_enabled_switch; + QLabel *lock_delay_label; + QComboBox *lock_delay_combo; + QLabel *critical_low_label; + QRadioButton *suspend_low_radio; + QRadioButton *shutdown_radio; + QLabel *laptop_lid_battery_label; + QRadioButton *suspend_lid_battery_radio; + QRadioButton *nothing_battery_radio; + QLabel *laptop_lid_ac_label; + QRadioButton *suspend_lid_ac_radio; + QRadioButton *nothing_ac_radio; + QLabel *sleep_battery_label; + QComboBox *sleep_battery_combo; + QLabel *sleep_ac_label; + QComboBox *sleep_ac_combo; + + QLabel *sleep_battery_display_label; + QComboBox *sleep_battery_display_combo; + QLabel *sleep_ac_display_label; + QComboBox *sleep_ac_display_combo; +}; + +#endif // CONSERVEWIDGET_H diff --git a/setting/deadpixelwidget.cpp b/setting/deadpixelwidget.cpp new file mode 100644 index 0000000..5499481 --- /dev/null +++ b/setting/deadpixelwidget.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "deadpixelwidget.h" +#include +#include +#include + +DeadpixelWidget::DeadpixelWidget(QWidget *parent) : + QWidget(parent) +{ + this->qtui = NULL; + tip_label = new QLabel(); + tip_label->setWordWrap(true);//QLabel自动换行 + tip_label->setFixedWidth(500); + ok_btn = new QPushButton(); + ok_btn->setFixedSize(91, 25); + ok_btn->setObjectName("blackButton"); + ok_btn->setFocusPolicy(Qt::NoFocus); +// QVBoxLayout *layout = new QVBoxLayout(); +// layout->addStretch(); +// layout->addWidget(tip_label); +// layout->addWidget(ok_btn); +// layout->addStretch(); +// bottom_widget->setLayout(layout); + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + + QHBoxLayout *main_layout = new QHBoxLayout(this); +// main_layout->addWidget(splitter); + main_layout->addStretch(); + main_layout->addWidget(tip_label); + main_layout->addWidget(ok_btn); + main_layout->addStretch(); + main_layout->setSpacing(0); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + setLayout(main_layout); + + this->setLanguage(); + this->initConnect(); +} + +DeadpixelWidget::~DeadpixelWidget() +{ + if(qtui != NULL) + { + delete qtui; + qtui = NULL; + } +} + +void DeadpixelWidget::setLanguage() +{ +// title_label->setText(tr("Monitor Check")); +// description_label->setText(tr("Monitor Check.")); +// back_btn->setText(tr("Back")); + tip_label->setText(tr("Left-click to change the color, right-click to exit from this detection.")); + ok_btn->setText(tr("OK")); +} + +void DeadpixelWidget::initConnect() +{ +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + connect(ok_btn, SIGNAL(clicked()), this, SLOT(startMonitorCheck())); +} + +void DeadpixelWidget::startMonitorCheck() { + if (this->qtui) + { + delete this->qtui; + this->qtui = NULL; + } + this->qtui = new QUIBO(); +} diff --git a/setting/deadpixelwidget.h b/setting/deadpixelwidget.h new file mode 100644 index 0000000..30a2cb1 --- /dev/null +++ b/setting/deadpixelwidget.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DEADPIXELWIDGET_H +#define DEADPIXELWIDGET_H + +#include +#include "../component/quibo.h" + +class QLabel; +class QPushButton; + +class DeadpixelWidget : public QWidget +{ + Q_OBJECT +public: + explicit DeadpixelWidget(QWidget *parent = 0); + ~DeadpixelWidget(); + void setLanguage(); + void initConnect(); + +public slots: + void startMonitorCheck(); + +private: + QUIBO *qtui; + QLabel *tip_label; + QPushButton *ok_btn; +}; + +#endif // DEADPIXELWIDGET_H diff --git a/setting/fontwidget.cpp b/setting/fontwidget.cpp new file mode 100644 index 0000000..4a82350 --- /dev/null +++ b/setting/fontwidget.cpp @@ -0,0 +1,598 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "fontwidget.h" +#include +#include "../component/kylinfontdialog.h" +#include "../dbusproxy/youkersessiondbus.h" +#include "../mainui/mainwindow.h" + +FontWidget::FontWidget(QWidget *parent, SessionDispatcher *proxy, MainWindow *window, QString cur_desktop, QString skin) : + QWidget(parent), + sessionproxy(proxy), + parentWindow(window), + desktop(cur_desktop), + cur_skin(skin) +{ + dataOK = false; + default_font_label = new QLabel(); + desktop_font_label = new QLabel(); + monospace_font_label = new QLabel(); + document_font_label = new QLabel(); + titlebar_font_label = new QLabel(); + scaling_label = new QLabel(); + hinting_label = new QLabel(); + antialiasing_label = new QLabel(); + + default_font_btn = new QPushButton(); + desktop_font_btn = new QPushButton(); + monospace_font_btn = new QPushButton(); + document_font_btn = new QPushButton(); + titlebar_font_btn = new QPushButton(); + scaling_slider = new QDoubleSpinBox(); + scaling_slider->setButtonSymbols(QAbstractSpinBox::PlusMinus); + scaling_slider->setSingleStep(0.1); + scaling_slider->setMinimum(0.5); + scaling_slider->setMaximum(3.0); + hinting_combo = new QComboBox(); + antialiasing_combo = new QComboBox(); + + restore_default_font_btn = new QPushButton(); + restore_desktop_font_btn = new QPushButton(); + restore_monospace_font_btn = new QPushButton(); + restore_document_font_btn = new QPushButton(); + restore_titlebar_font_btn = new QPushButton(); + restore_default_font_btn->setFixedSize(91, 25); + restore_desktop_font_btn->setFixedSize(91, 25); + restore_monospace_font_btn->setFixedSize(91, 25); + restore_document_font_btn->setFixedSize(91, 25); + restore_titlebar_font_btn->setFixedSize(91, 25); + restore_default_font_btn->setObjectName("blackButton"); + restore_desktop_font_btn->setObjectName("blackButton"); + restore_monospace_font_btn->setObjectName("blackButton"); + restore_document_font_btn->setObjectName("blackButton"); + restore_titlebar_font_btn->setObjectName("blackButton"); + restore_default_font_btn->setFocusPolicy(Qt::NoFocus); + restore_desktop_font_btn->setFocusPolicy(Qt::NoFocus); + restore_monospace_font_btn->setFocusPolicy(Qt::NoFocus); + restore_document_font_btn->setFocusPolicy(Qt::NoFocus); + restore_titlebar_font_btn->setFocusPolicy(Qt::NoFocus); + + default_font_btn->setObjectName("transparentButton"); + desktop_font_btn->setObjectName("transparentButton"); + monospace_font_btn->setObjectName("transparentButton"); + document_font_btn->setObjectName("transparentButton"); + titlebar_font_btn->setObjectName("transparentButton"); + default_font_btn->setFocusPolicy(Qt::NoFocus); + desktop_font_btn->setFocusPolicy(Qt::NoFocus); + monospace_font_btn->setFocusPolicy(Qt::NoFocus); + document_font_btn->setFocusPolicy(Qt::NoFocus); + titlebar_font_btn->setFocusPolicy(Qt::NoFocus); + default_font_btn->setToolTip(tr("Click here to change font")); + desktop_font_btn->setToolTip(tr("Click here to change font")); + monospace_font_btn->setToolTip(tr("Click here to change font")); + document_font_btn->setToolTip(tr("Click here to change font")); + titlebar_font_btn->setToolTip(tr("Click here to change font")); + + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + scaling_label->hide(); + scaling_slider->hide(); + } + + default_font_label->setFixedWidth(150); + desktop_font_label->setFixedWidth(150); + monospace_font_label->setFixedWidth(150); + document_font_label->setFixedWidth(150); + titlebar_font_label->setFixedWidth(150); + scaling_label->setFixedWidth(150); + hinting_label->setFixedWidth(150); + antialiasing_label->setFixedWidth(150); + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->setSpacing(10); + layout1->addWidget(default_font_label); + layout1->addWidget(default_font_btn); + layout1->addStretch(); + layout1->addWidget(restore_default_font_btn); + layout1->setContentsMargins(0, 0, 200, 0); + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->setSpacing(10); + layout2->addWidget(desktop_font_label); + layout2->addWidget(desktop_font_btn); + layout2->addStretch(); + layout2->addWidget(restore_desktop_font_btn); + layout2->setContentsMargins(0, 0, 200, 0); + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->setSpacing(10); + layout3->addWidget(monospace_font_label); + layout3->addWidget(monospace_font_btn); + layout3->addStretch(); + layout3->addWidget(restore_monospace_font_btn); + layout3->setContentsMargins(0, 0, 200, 0); + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->setSpacing(10); + layout4->addWidget(document_font_label); + layout4->addWidget(document_font_btn); + layout4->addStretch(); + layout4->addWidget(restore_document_font_btn); + layout4->setContentsMargins(0, 0, 200, 0); + QHBoxLayout *layout5 = new QHBoxLayout(); + layout5->setSpacing(10); + layout5->addWidget(titlebar_font_label); + layout5->addWidget(titlebar_font_btn); + layout5->addStretch(); + layout5->addWidget(restore_titlebar_font_btn); + layout5->setContentsMargins(0, 0, 200, 0); + QHBoxLayout *layout6 = new QHBoxLayout(); + layout6->setSpacing(10); + layout6->addWidget(scaling_label); + layout6->addWidget(scaling_slider); + layout6->addStretch(); + QHBoxLayout *layout7 = new QHBoxLayout(); + layout7->setSpacing(10); + layout7->addWidget(hinting_label); + layout7->addWidget(hinting_combo); + layout7->addStretch(); + QHBoxLayout *layout8 = new QHBoxLayout(); + layout8->setSpacing(10); + layout8->addWidget(antialiasing_label); + layout8->addWidget(antialiasing_combo); + layout8->addStretch(); + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(layout1); + layout->addLayout(layout2); + layout->addLayout(layout3); + layout->addLayout(layout4); + layout->addLayout(layout5); + layout->addLayout(layout6); + layout->addLayout(layout7); + layout->addLayout(layout8); + layout->addStretch(); +// bottom_widget->setLayout(layout); + setLayout(layout); + layout->setSpacing(10); + layout->setContentsMargins(20, 20, 20, 0); + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + +// QHBoxLayout *main_layout = new QHBoxLayout; +// main_layout->addStretch(); +// main_layout->addWidget(splitter); +// main_layout->setSpacing(0); +// main_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(main_layout); +// this->initData(); + this->setLanguage(); +} + +FontWidget::~FontWidget() +{ + if (default_font_label != NULL) { + delete default_font_label; + default_font_label = NULL; + } + if (desktop_font_label != NULL) { + delete desktop_font_label; + desktop_font_label = NULL; + } + if (monospace_font_label != NULL) { + delete monospace_font_label; + monospace_font_label = NULL; + } + if (document_font_label != NULL) { + delete document_font_label; + document_font_label = NULL; + } + if (titlebar_font_label != NULL) { + delete titlebar_font_label; + titlebar_font_label = NULL; + } + if (scaling_label != NULL) { + delete scaling_label; + scaling_label = NULL; + } + if (hinting_label != NULL) { + delete hinting_label; + hinting_label = NULL; + } + if (antialiasing_label != NULL) { + delete antialiasing_label; + antialiasing_label = NULL; + } + if (default_font_btn != NULL) { + delete default_font_btn; + default_font_btn = NULL; + } + if (desktop_font_btn != NULL) { + delete desktop_font_btn; + desktop_font_btn = NULL; + } + if (monospace_font_btn != NULL) { + delete monospace_font_btn; + monospace_font_btn = NULL; + } + if (document_font_btn != NULL) { + delete document_font_btn; + document_font_btn = NULL; + } + if (titlebar_font_btn != NULL) { + delete titlebar_font_btn; + titlebar_font_btn = NULL; + } + if (scaling_slider != NULL) { + delete scaling_slider; + scaling_slider = NULL; + } + if (hinting_combo != NULL) { + delete hinting_combo; + hinting_combo = NULL; + } + if (antialiasing_combo != NULL) { + delete antialiasing_combo; + antialiasing_combo = NULL; + } + if (restore_default_font_btn != NULL) { + delete restore_default_font_btn; + restore_default_font_btn = NULL; + } + if (restore_desktop_font_btn != NULL) { + delete restore_desktop_font_btn; + restore_desktop_font_btn = NULL; + } + if (restore_monospace_font_btn != NULL) { + delete restore_monospace_font_btn; + restore_monospace_font_btn = NULL; + } + if (restore_document_font_btn != NULL) { + delete restore_document_font_btn; + restore_document_font_btn = NULL; + } + if (restore_titlebar_font_btn != NULL) { + delete restore_titlebar_font_btn; + restore_titlebar_font_btn = NULL; + } +} + +void FontWidget::setLanguage() { +// title_label->setText(tr("Default font settings")); +// description_label->setText(tr("According to personal preferences to set the system default font, click the 'Restore' button, can be restored to the state before the font settings.")); +// back_btn->setText(tr("Back")); + default_font_label->setText(tr("Default Font") + ":"); + desktop_font_label->setText(tr("Desktop Font") + ":"); + monospace_font_label->setText(tr("Monospace Font") + ":"); + document_font_label->setText(tr("Document Font") + ":"); + titlebar_font_label->setText(tr("Titlebar Font") + ":"); + scaling_label->setText(tr("Global Font Scaling") + ":"); + hinting_label->setText(tr("Hinting") + ":"); + antialiasing_label->setText(tr("Antialiasing") + ":"); + restore_default_font_btn->setText(tr("Restore")); + restore_desktop_font_btn->setText(tr("Restore")); + restore_monospace_font_btn->setText(tr("Restore")); + restore_document_font_btn->setText(tr("Restore")); + restore_titlebar_font_btn->setText(tr("Restore")); +} + +bool FontWidget::getStatus() +{ + return this->dataOK; +} + +void FontWidget::initData() +{ + current_font = sessionproxy->get_font_qt(); + desktop_font = sessionproxy->get_desktop_font_qt(); + if(desktop_font.isEmpty()) + { +// sessionproxy->set_desktop_font_qt_default(); + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") + sessionproxy->set_desktop_font_qt("Sans 10"); + else + sessionproxy->set_desktop_font_qt("Ubuntu 11"); + } + desktop_font = sessionproxy->get_desktop_font_qt(); + monospace_font = sessionproxy->get_monospace_font_qt(); + document_font = sessionproxy->get_document_font_qt(); + titlebar_font = sessionproxy->get_window_title_font_qt(); + default_font_btn->setText(current_font); + desktop_font_btn->setText(desktop_font); + monospace_font_btn->setText(monospace_font); + document_font_btn->setText(document_font); + titlebar_font_btn->setText(titlebar_font); + + if (this->desktop != "mate" || this->desktop == "MATE") { + scaling_slider->setValue(sessionproxy->get_font_zoom_qt()); + } + + QString current_smooth = sessionproxy->get_smooth_style_qt(); + /*QStringList */smoothlist = sessionproxy->get_smooth_style_list_qt(); + hinting_combo->clear(); + hinting_combo->clearEditText(); + hinting_combo->addItems(smoothlist); + QList::Iterator it = smoothlist.begin(), itend = smoothlist.end(); + int initIndex = 0; + for(;it != itend; it++,initIndex++) + { + if(*it == current_smooth) + break; + } + hinting_combo->setCurrentIndex(initIndex); + + QString current_antialiasing = sessionproxy->get_antialiasing_style_qt(); + /*QStringList */antialiasinglist = sessionproxy->get_antialiasing_style_list_qt(); + antialiasing_combo->clear(); + antialiasing_combo->clearEditText(); + antialiasing_combo->addItems(antialiasinglist); + QList::Iterator ite = antialiasinglist.begin(), iteend = antialiasinglist.end(); + int index = 0; + for(;ite != iteend; ite++,index++) + { + if(*ite == current_antialiasing) + break; + } + antialiasing_combo->setCurrentIndex(index); + dataOK = true; + this->initConnect(); +} + +void FontWidget::initConnect() { +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + connect(default_font_btn, SIGNAL(clicked()), this, SLOT(setDefaultFont())); + connect(desktop_font_btn, SIGNAL(clicked()), this, SLOT(setDesktopFont())); + connect(monospace_font_btn, SIGNAL(clicked()), this, SLOT(setMonospaceFont())); + connect(document_font_btn, SIGNAL(clicked()), this, SLOT(setDocumentFont())); + connect(titlebar_font_btn, SIGNAL(clicked()), this, SLOT(setTitlebarFont())); + connect(scaling_slider, SIGNAL(valueChanged(double)), this, SLOT(setScalingValue(double))); + connect(hinting_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setFontHinting(QString))); + connect(antialiasing_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setFontAntialiasing(QString))); + connect(restore_default_font_btn, SIGNAL(clicked()), this, SLOT(restore_default_font())); + connect(restore_desktop_font_btn, SIGNAL(clicked()), this, SLOT(restore_desktop_font())); + connect(restore_monospace_font_btn, SIGNAL(clicked()), this, SLOT(restore_monospace_font())); + connect(restore_document_font_btn, SIGNAL(clicked()), this, SLOT(restore_document_font())); + connect(restore_titlebar_font_btn, SIGNAL(clicked()), this, SLOT(restore_titlebar_font())); + + connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(fontwidget_notify_string(QString, QString))); + connect(sessionproxy, SIGNAL(double_value_notify(QString, double)), this, SLOT(fontwidget_notify_double(QString, double))); +} + +void FontWidget::fontwidget_notify_string(QString key, QString value) +{ + if (key == "font-name") { + default_font_btn->setText(value); + } + else if (key == "font") { + desktop_font_btn->setText(value); + } + else if (key == "monospace-font-name") { + monospace_font_btn->setText(value); + } + else if (key == "document-font-name") { + document_font_btn->setText(value); + } + else if (key == "titlebar-font") { + titlebar_font_btn->setText(value); + } + else if (key == "hinting") { + QList::Iterator it = smoothlist.begin(), itend = smoothlist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if (exist) { + exist = false; + hinting_combo->setCurrentIndex(index); + } + else + hinting_combo->setCurrentIndex(-1); + } + else if (key == "antialiasing") { + QList::Iterator it = antialiasinglist.begin(), itend = antialiasinglist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if (exist) { + exist = false; + antialiasing_combo->setCurrentIndex(index); + } + else + antialiasing_combo->setCurrentIndex(-1); + } +} + +void FontWidget::fontwidget_notify_double(QString key, double value) +{ + if (key == "text-scaling-factor") { + scaling_slider->setValue(value); + } +} + + +void FontWidget::setDefaultFont() { +// KylinFontDialog *fontDialog = new KylinFontDialog(mSettings, flag, current_font, 0); + KylinFontDialog *fontDialog = new KylinFontDialog(current_font, this->cur_skin, 0); + connect(fontDialog, SIGNAL(rebackCurrentFont(QString)), this, SLOT(resetDefaultFont(QString))); + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (600 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (500 / 2); + fontDialog->move(w_x, w_y); + fontDialog->exec(); +} + +void FontWidget::resetDefaultFont(QString cur_font) +{ + this->current_font = cur_font; + sessionproxy->set_font_qt(cur_font); + default_font_btn->setText(cur_font); +} + +void FontWidget::setDesktopFont() { + KylinFontDialog *fontDialog = new KylinFontDialog(desktop_font, this->cur_skin, 0); + connect(fontDialog, SIGNAL(rebackCurrentFont(QString)), this, SLOT(resetDesktopFont(QString))); + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (600 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (500 / 2); + fontDialog->move(w_x, w_y); + fontDialog->exec(); +} + +void FontWidget::resetDesktopFont(QString cur_font) +{ + this->desktop_font = cur_font; + sessionproxy->set_desktop_font_qt(cur_font); + desktop_font_btn->setText(cur_font); +} + +void FontWidget::resetCurrentSkin(QString skin) +{ + this->cur_skin = skin; +} + +void FontWidget::setMonospaceFont() { + KylinFontDialog *fontDialog = new KylinFontDialog(monospace_font, this->cur_skin, 0); + connect(fontDialog, SIGNAL(rebackCurrentFont(QString)), this, SLOT(resetMonospaceFont(QString))); + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (600 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (500 / 2); + fontDialog->move(w_x, w_y); + fontDialog->exec(); +} + +void FontWidget::resetMonospaceFont(QString cur_font) +{ + this->monospace_font = cur_font; + sessionproxy->set_monospace_font_qt(cur_font); + monospace_font_btn->setText(cur_font); +} + +void FontWidget::setDocumentFont() { + KylinFontDialog *fontDialog = new KylinFontDialog(document_font, this->cur_skin, 0); + connect(fontDialog, SIGNAL(rebackCurrentFont(QString)), this, SLOT(resetDocumentFont(QString))); + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (600 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (500 / 2); + fontDialog->move(w_x, w_y); + fontDialog->exec(); +} + +void FontWidget::resetDocumentFont(QString cur_font) +{ + this->document_font = cur_font; + sessionproxy->set_document_font_qt(cur_font); + document_font_btn->setText(cur_font); +} + +void FontWidget::setTitlebarFont() { + KylinFontDialog *fontDialog = new KylinFontDialog(titlebar_font, this->cur_skin, 0); + connect(fontDialog, SIGNAL(rebackCurrentFont(QString)), this, SLOT(resetTitlebarFont(QString))); + int w_x = parentWindow->frameGeometry().topLeft().x() + (900 / 2) - (600 / 2); + int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (500 / 2); + fontDialog->move(w_x, w_y); + fontDialog->exec(); +} + +void FontWidget::resetTitlebarFont(QString cur_font) +{ + this->titlebar_font = cur_font; + sessionproxy->set_window_title_font_qt(cur_font); + titlebar_font_btn->setText(cur_font); +} + +void FontWidget::setScalingValue(double value) +{ + sessionproxy->set_font_zoom_qt(value); +} + +void FontWidget::setFontHinting(QString selected) +{ + sessionproxy->set_smooth_style_qt(selected); +} + +void FontWidget::setFontAntialiasing(QString selected) +{ + sessionproxy->set_antialiasing_style_qt(selected); +} + +void FontWidget::restore_default_font() +{ + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + sessionproxy->set_default_font_string_qt("org.mate.interface", "font-name", "string"); + default_font_btn->setText(sessionproxy->get_default_font_string_qt("org.mate.interface", "font-name")); + } + else { + sessionproxy->set_default_font_string_qt("org.gnome.desktop.interface", "font-name", "string"); + default_font_btn->setText(sessionproxy->get_default_font_string_qt("org.gnome.desktop.interface", "font-name")); + } +} + +void FontWidget::restore_desktop_font() +{ + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + sessionproxy->set_default_font_string_qt("org.mate.caja.desktop", "font", "string"); + desktop_font_btn->setText(sessionproxy->get_default_font_string_qt("org.mate.caja.desktop", "font")); + } + else { + sessionproxy->set_default_font_string_qt("org.gnome.nautilus.desktop", "font", "string"); + desktop_font_btn->setText(sessionproxy->get_default_font_string_qt("org.gnome.nautilus.desktop", "font")); + } +} + +void FontWidget::restore_monospace_font() +{ + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + sessionproxy->set_default_font_string_qt("org.mate.interface", "monospace-font-name", "string"); + monospace_font_btn->setText(sessionproxy->get_default_font_string_qt("org.mate.interface", "monospace-font-name")); + } + else { + sessionproxy->set_default_font_string_qt("org.gnome.desktop.interface", "monospace-font-name", "string"); + monospace_font_btn->setText(sessionproxy->get_default_font_string_qt("org.gnome.desktop.interface", "monospace-font-name")); + } +} + +void FontWidget::restore_document_font() +{ + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + sessionproxy->set_default_font_string_qt("org.mate.interface", "document-font-name", "string"); + document_font_btn->setText(sessionproxy->get_default_font_string_qt("org.mate.interface", "document-font-name")); + } + else { + sessionproxy->set_default_font_string_qt("org.gnome.desktop.interface", "document-font-name", "string"); + document_font_btn->setText(sessionproxy->get_default_font_string_qt("org.gnome.desktop.interface", "document-font-name")); + } +} + +void FontWidget::restore_titlebar_font() +{ + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + sessionproxy->set_default_font_string_qt("org.gnome.desktop.wm.preferences", "titlebar-font", "string"); + titlebar_font_btn->setText(sessionproxy->get_default_font_string_qt("org.gnome.desktop.wm.preferences", "titlebar-font")); + } + else { + sessionproxy->set_default_font_string_qt("org.gnome.desktop.wm.preferences", "titlebar-font", "string"); + titlebar_font_btn->setText(sessionproxy->get_default_font_string_qt("org.gnome.desktop.wm.preferences", "titlebar-font")); + } +} diff --git a/setting/fontwidget.h b/setting/fontwidget.h new file mode 100644 index 0000000..5ae67f1 --- /dev/null +++ b/setting/fontwidget.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef FONTWIDGET_H +#define FONTWIDGET_H + +#include + +class SessionDispatcher; +class MainWindow; +class QLabel; +class QPushButton; +class QComboBox; +class QDoubleSpinBox; + +class FontWidget : public QWidget +{ + Q_OBJECT +public: + explicit FontWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0, MainWindow *window = 0, QString cur_desktop = "", QString skin = ":/background/res/skin/1.png"); + ~FontWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + void resetCurrentSkin(QString skin); + +public slots: + void setDefaultFont(); + void setDesktopFont(); + void setMonospaceFont(); + void setDocumentFont(); + void setTitlebarFont(); + void setScalingValue(double value); + void setFontHinting(QString selected); + void setFontAntialiasing(QString selected); + void resetDefaultFont(QString cur_font); + void resetDesktopFont(QString cur_font); + void resetMonospaceFont(QString cur_font); + void resetDocumentFont(QString cur_font); + void resetTitlebarFont(QString cur_font); + void restore_default_font(); + void restore_desktop_font(); + void restore_monospace_font(); + void restore_document_font(); + void restore_titlebar_font(); + + void fontwidget_notify_string(QString key, QString value); + void fontwidget_notify_double(QString key, double value); + +private: + SessionDispatcher *sessionproxy; + bool dataOK; + QStringList smoothlist; + QStringList antialiasinglist; + MainWindow *parentWindow; + QLabel *default_font_label; + QLabel *desktop_font_label; + QLabel *monospace_font_label; + QLabel *document_font_label; + QLabel *titlebar_font_label; + QLabel *scaling_label; + QLabel *hinting_label; + QLabel *antialiasing_label; + QPushButton *default_font_btn; + QPushButton *desktop_font_btn; + QPushButton *monospace_font_btn; + QPushButton *document_font_btn; + QPushButton *titlebar_font_btn; + QDoubleSpinBox *scaling_slider; + QComboBox *hinting_combo; + QComboBox *antialiasing_combo; + + QPushButton *restore_default_font_btn; + QPushButton *restore_desktop_font_btn; + QPushButton *restore_monospace_font_btn; + QPushButton *restore_document_font_btn; + QPushButton *restore_titlebar_font_btn; + + QString current_font; + QString desktop_font; + QString monospace_font; + QString document_font; + QString titlebar_font; + QString desktop; + QString cur_skin; +}; + +#endif // FONTWIDGET_H diff --git a/setting/iconwidget.cpp b/setting/iconwidget.cpp new file mode 100644 index 0000000..1b9ad70 --- /dev/null +++ b/setting/iconwidget.cpp @@ -0,0 +1,348 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "iconwidget.h" +#include "../dbusproxy/youkersessiondbus.h" +#include +#include +#include +#include + +IconWidget::IconWidget(QWidget *parent, SessionDispatcher *proxy, QString cur_desktop) : + QWidget(parent),desktop(cur_desktop), + sessionproxy(proxy) +{ + dataOK = false; + theme_label = new QLabel(); +// show_label = new QLabel(); + computer_label = new QLabel(); + + folder_label = new QLabel(); + network_label = new QLabel(); + recycle_label = new QLabel(); + disk_label = new QLabel(); + theme_combo = new QComboBox(); +// show_switcher = new KylinSwitcher(); + computer_switcher = new KylinSwitcher(); + folder_switcher = new KylinSwitcher(); + network_switcher = new KylinSwitcher(); + recycle_switcher = new KylinSwitcher(); + disk_switcher = new KylinSwitcher(); + + if (this->desktop != "mate" && this->desktop != "MATE") + { + computer_label->hide(); + computer_switcher->hide(); + } + + theme_label->setFixedWidth(150); +// show_label->setFixedWidth(150); + computer_label->setFixedWidth(150); + folder_label->setFixedWidth(150); + network_label->setFixedWidth(150); + recycle_label->setFixedWidth(150); + disk_label->setFixedWidth(150); + + +// switcher = new KylinSwitcher(); +// connect(switcher, SIGNAL(clicked()), this, SLOT(changeSwitcherStatus())); + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->setSpacing(10); + layout1->addWidget(theme_label); + layout1->addWidget(theme_combo); + layout1->addStretch(); +// QHBoxLayout *layout2 = new QHBoxLayout(); +// layout2->setSpacing(10); +// layout2->addWidget(show_label); +// layout2->addWidget(show_switcher); +// layout2->addStretch(); + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->setSpacing(10); + layout3->addWidget(computer_label); + layout3->addWidget(computer_switcher); + layout3->addStretch(); + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->setSpacing(10); + layout4->addWidget(folder_label); + layout4->addWidget(folder_switcher); + layout4->addStretch(); + QHBoxLayout *layout5 = new QHBoxLayout(); + layout5->setSpacing(10); + layout5->addWidget(network_label); + layout5->addWidget(network_switcher); + layout5->addStretch(); + QHBoxLayout *layout6 = new QHBoxLayout(); + layout6->setSpacing(10); + layout6->addWidget(recycle_label); + layout6->addWidget(recycle_switcher); + layout6->addStretch(); + QHBoxLayout *layout7 = new QHBoxLayout(); + layout7->setSpacing(10); + layout7->addWidget(disk_label); + layout7->addWidget(disk_switcher); + layout7->addStretch(); + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(layout1); +// layout->addLayout(layout2); + layout->addLayout(layout3); + layout->addLayout(layout4); + layout->addLayout(layout5); + layout->addLayout(layout6); + layout->addLayout(layout7); + layout->addStretch(); + setLayout(layout); + layout->setSpacing(10); + layout->setContentsMargins(20, 20, 0, 0); +// QGridLayout *grid_layout = new QGridLayout; +// grid_layout->addWidget(theme_label, 0, 0/* ,1, 1*/); +// grid_layout->addWidget(theme_combo, 0, 1/* ,1, 1*/); +// grid_layout->addWidget(folder_label, 1, 0/* ,1, 1*/); +// grid_layout->addWidget(show_switcher, 1, 1/* ,1, 1*/); +// grid_layout->addWidget(show_label, 2, 0 /*,1, 1*/); +// grid_layout->addWidget(folder_switcher, 2, 1/* ,1, 1*/); +// grid_layout->addWidget(network_label, 3, 0 /*,1, 1*/); +// grid_layout->addWidget(network_switcher, 3, 1 /*,1, 1*/); +// grid_layout->addWidget(recycle_label, 4, 0 /*,1, 1*/); +// grid_layout->addWidget(recycle_switcher, 4, 1/* ,1, 1*/); +// grid_layout->addWidget(disk_label, 5, 0/* ,1, 1*/); +// grid_layout->addWidget(disk_switcher, 5, 1/* ,1, 1*/); +// grid_layout->setColumnStretch(0,1); +// grid_layout->setColumnStretch(1,3); +// bottom_widget->setLayout(grid_layout); + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + +// for(int i = 0; icount();i++) +// { +// QSplitterHandle *handle = splitter->handle(i); +// handle->setEnabled(false); +// } + + + +// QHBoxLayout *main_layout = new QHBoxLayout; +// main_layout->addStretch(); +// main_layout->addWidget(splitter); +// main_layout->setSpacing(0); +// main_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(main_layout); +// this->initData(); + this->setLanguage(); +} + +IconWidget::~IconWidget() +{ + if (theme_label != NULL) { + delete theme_label; + theme_label = NULL; + } + if (computer_label != NULL) { + delete computer_label; + computer_label = NULL; + } + if (folder_label != NULL) { + delete folder_label; + folder_label = NULL; + } + if (network_label != NULL) { + delete network_label; + network_label = NULL; + } + if (recycle_label != NULL) { + delete recycle_label; + recycle_label = NULL; + } + if (disk_label != NULL) { + delete disk_label; + disk_label = NULL; + } + if (theme_combo != NULL) { + delete theme_combo; + theme_combo = NULL; + } + if (computer_switcher != NULL) { + delete computer_switcher; + computer_switcher = NULL; + } + if (folder_switcher != NULL) { + delete folder_switcher; + folder_switcher = NULL; + } + if (network_switcher != NULL) { + delete network_switcher; + network_switcher = NULL; + } + if (recycle_switcher != NULL) { + delete recycle_switcher; + recycle_switcher = NULL; + } + if (disk_switcher != NULL) { + delete disk_switcher; + disk_switcher = NULL; + } +} + +void IconWidget::changeSwitcherStatus() { + +} + +void IconWidget::setLanguage() { +// title_label->setText(tr("Desktop Icons")); +// description_label->setText(tr("Set the desktop icon theme and the visibility of desktop icons.")); +// back_btn->setText(tr("Back")); + theme_label->setText(tr("Icon theme") + ":"); +// show_label->setText(tr("Show Desktop Icons") + ":"); + computer_label->setText(tr("Computer") + ":"); + folder_label->setText(tr("Home Folder") + ":"); + network_label->setText(tr("Network") + ":"); + recycle_label->setText(tr("Trash") + ":"); + disk_label->setText(tr("Mounted Volumes") + ":"); +} + +bool IconWidget::getStatus() +{ + return this->dataOK; +} + +void IconWidget::initData() +{ + QString current_icon_theme = sessionproxy->get_icon_theme_qt(); + /*QStringList */iconlist = sessionproxy->get_icon_themes_qt(); + theme_combo->clear(); + theme_combo->clearEditText(); + theme_combo->addItems(iconlist); + + QList::Iterator it = iconlist.begin(), itend = iconlist.end(); + int initIndex = 0; + for(;it != itend; it++,initIndex++) + { + if(*it == current_icon_theme) + break; + } + theme_combo->setCurrentIndex(initIndex); + +// show_switcher->setSwitchStatus(sessionproxy->get_show_desktop_icons_qt()); +// folder_switcher->setSwitchStatus(sessionproxy->get_show_homefolder_qt()); +// network_switcher->setSwitchStatus(sessionproxy->get_show_network_qt()); +// recycle_switcher->setSwitchStatus(sessionproxy->get_show_trash_qt()); +// disk_switcher->setSwitchStatus(sessionproxy->get_show_devices_qt()); +// show_switcher->switchedOn = sessionproxy->get_show_desktop_icons_qt(); + + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") + { + computer_switcher->switchedOn = sessionproxy->get_show_computer_qt(); + } + + folder_switcher->switchedOn = sessionproxy->get_show_homefolder_qt(); + network_switcher->switchedOn = sessionproxy->get_show_network_qt(); + recycle_switcher->switchedOn = sessionproxy->get_show_trash_qt(); + disk_switcher->switchedOn = sessionproxy->get_show_devices_qt(); + dataOK = true; + this->initConnect(); +} + +void IconWidget::initConnect() { +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); +// connect(theme_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setIconTheme())); + connect(theme_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setIconTheme(QString))); +// connect(show_switcher, SIGNAL(clicked()), this, SLOT(setShowDesktopIcons())); + connect(computer_switcher, SIGNAL(clicked()), this, SLOT(setComputerIcon())); + connect(folder_switcher, SIGNAL(clicked()), this, SLOT(setFolderIcon())); + connect(network_switcher, SIGNAL(clicked()), this, SLOT(setNetworkIcon())); + connect(recycle_switcher, SIGNAL(clicked()), this, SLOT(setRecycleBinIcon())); + connect(disk_switcher, SIGNAL(clicked()), this, SLOT(setDiskIcon())); + + connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(iconwidget_notify_string(QString, QString))); + connect(sessionproxy, SIGNAL(bool_value_notify(QString, bool)), this, SLOT(iconwidget_notify_boolean(QString, bool))); +} + +void IconWidget::iconwidget_notify_string(QString key, QString value) +{ + if (key == "icon-theme") { + QList::Iterator it = iconlist.begin(), itend = iconlist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if (exist) { + exist = false; + theme_combo->setCurrentIndex(index); + } + else + theme_combo->setCurrentIndex(-1); + } +} + +void IconWidget::iconwidget_notify_boolean(QString key, bool value) +{ +// if (key == "show-desktop-icons") { +// show_switcher->switchedOn = value; +// } + if (key == "computer-icon-visible") { + computer_switcher->switchedOn = value; + } + else if (key == "home-icon-visible") + { + folder_switcher->switchedOn = value; + } + else if (key == "network-icon-visible") { + network_switcher->switchedOn = value; + } + else if (key == "trash-icon-visible") { + recycle_switcher->switchedOn = value; + } + else if (key == "volumes-visible") { + disk_switcher->switchedOn = value; + } +} + +void IconWidget::setIconTheme(QString selectTheme) { + sessionproxy->set_icon_theme_qt(selectTheme); +} + +//void IconWidget::setShowDesktopIcons() { +// sessionproxy->set_show_desktop_icons_qt(show_switcher->switchedOn); +//} + +void IconWidget::setComputerIcon() { + sessionproxy->set_show_computer_qt(computer_switcher->switchedOn); +} + +void IconWidget::setFolderIcon() { + sessionproxy->set_show_homefolder_qt(folder_switcher->switchedOn); +} + +void IconWidget::setNetworkIcon() { + sessionproxy->set_show_network_qt(network_switcher->switchedOn); +} + +void IconWidget::setRecycleBinIcon() { + sessionproxy->set_show_trash_qt(recycle_switcher->switchedOn); +} + +void IconWidget::setDiskIcon() { + sessionproxy->set_show_devices_qt(disk_switcher->switchedOn); +} diff --git a/setting/iconwidget.h b/setting/iconwidget.h new file mode 100644 index 0000000..cea5e9b --- /dev/null +++ b/setting/iconwidget.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef ICONWIDGET_H +#define ICONWIDGET_H + +#include +#include "../component/kylinswitcher.h" + +class SessionDispatcher; +class QLabel; +class QPushButton; +class QHBoxLayout; +class QComboBox; + +class IconWidget : public QWidget +{ + Q_OBJECT +public: + explicit IconWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0, QString cur_desktop = ""); + ~IconWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + +public slots: + void changeSwitcherStatus(); + void setIconTheme(QString selectTheme); +// void setShowDesktopIcons(); + void setComputerIcon(); + void setFolderIcon(); + void setNetworkIcon(); + void setRecycleBinIcon(); + void setDiskIcon(); + +public slots: + void iconwidget_notify_string(QString key, QString value); + void iconwidget_notify_boolean(QString key, bool value); + +private: + SessionDispatcher *sessionproxy; + bool dataOK; + QString desktop; + QStringList iconlist; + QLabel *theme_label; +// QLabel *show_label; + QLabel *computer_label; + QLabel *folder_label; + QLabel *network_label; + QLabel *recycle_label; + QLabel *disk_label; + QComboBox *theme_combo; +// KylinSwitcher *show_switcher; + KylinSwitcher *computer_switcher; + KylinSwitcher *folder_switcher; + KylinSwitcher *network_switcher; + KylinSwitcher *recycle_switcher; + KylinSwitcher *disk_switcher; +}; + +#endif // ICONWIDGET_H diff --git a/setting/launcherwidget.cpp b/setting/launcherwidget.cpp new file mode 100644 index 0000000..7a0c63b --- /dev/null +++ b/setting/launcherwidget.cpp @@ -0,0 +1,570 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "launcherwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" + +LauncherWidget::LauncherWidget(QWidget *parent, SessionDispatcher *proxy, QString cur_desktop) : + QWidget(parent),desktop(cur_desktop), + sessionproxy(proxy) +{ + dataOK = false; + size_label = new QLabel(); + size_value_label = new QLabel(); + hide_label = new QLabel(); + icon_label = new QLabel(); + transparency_label = new QLabel(); + background_label = new QLabel(); + size_top_label = new QLabel(); + hide_top_label = new QLabel(); + size_top_value_label = new QLabel(); + size_bottom_label = new QLabel(); + hide_bottom_label = new QLabel(); + size_bottom_value_label = new QLabel(); + position_label = new QLabel(); + +// QLabel *size_top_label; +// QLabel *hide_top_label; +// QLabel *size_bottom_label; +// QLabel *hide_bottom_label; + + size_slider = new QSlider(Qt::Horizontal); +// size_slider->setTickPosition(QSlider::TicksRight); + size_slider->setFocusPolicy(Qt::NoFocus); + size_slider->setRange(32, 64); + size_slider->setSingleStep(1); +// size_slider->setMinimum(1); +// size_slider->setMaximum(10); + + hide_switcher = new KylinSwitcher(); + icon_switcher = new KylinSwitcher(); + transparency_slider = new QDoubleSpinBox(); + transparency_slider->setButtonSymbols(QAbstractSpinBox::PlusMinus); + transparency_slider->setSingleStep(0.1); + transparency_slider->setMinimum(0.0); + transparency_slider->setMaximum(1.0); + backgound_combo = new QComboBox(); + + size_top_slider = new QSlider(Qt::Horizontal); + size_top_slider->setFocusPolicy(Qt::NoFocus); + size_top_slider->setRange(24, 180); + size_top_slider->setSingleStep(1); + size_bottom_slider = new QSlider(Qt::Horizontal); + size_bottom_slider->setFocusPolicy(Qt::NoFocus); + size_bottom_slider->setRange(24, 180); + size_bottom_slider->setSingleStep(1); + hide_top_switcher = new KylinSwitcher(); + hide_bottom_switcher = new KylinSwitcher(); + + position_combo = new QComboBox(); + +// QSlider *size_top_slider; +// QSlider *size_bottom_slider; +// KylinSwitcher *hide_top_switcher; +// KylinSwitcher *icon_bottom_switcher; + + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + size_label->hide(); + size_value_label->hide(); + hide_label->hide(); + icon_label->hide(); + transparency_label->hide(); + background_label->hide(); + position_label->hide(); + size_slider->hide(); + hide_switcher->hide(); + icon_switcher->hide(); + transparency_slider->hide();; + backgound_combo->hide(); + position_combo->hide(); + } + else + { + size_top_label->hide(); + hide_top_label->hide(); + size_top_value_label->hide(); + size_bottom_label->hide(); + hide_bottom_label->hide(); + size_bottom_value_label->hide(); + size_top_slider->hide(); + size_bottom_slider->hide(); + hide_top_switcher->hide(); + hide_bottom_switcher->hide(); + } + + size_label->setFixedWidth(180); + hide_label->setFixedWidth(180); + icon_label->setFixedWidth(180); + transparency_label->setFixedWidth(180); + background_label->setFixedWidth(180); + size_top_label->setFixedWidth(180); + hide_top_label->setFixedWidth(180); + size_bottom_label->setFixedWidth(180); + hide_bottom_label->setFixedWidth(180); + position_label->setFixedWidth(180); + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->setSpacing(10); + layout1->addWidget(size_label); + layout1->addWidget(size_slider); + layout1->addWidget(size_value_label); + layout1->addStretch(); + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->setSpacing(10); + layout2->addWidget(hide_label); + layout2->addWidget(hide_switcher); + layout2->addStretch(); + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->setSpacing(10); + layout3->addWidget(icon_label); + layout3->addWidget(icon_switcher); + layout3->addStretch(); + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->setSpacing(10); + layout4->addWidget(transparency_label); + layout4->addWidget(transparency_slider); + layout4->addStretch(); + QHBoxLayout *layout5 = new QHBoxLayout(); + layout5->setSpacing(10); + layout5->addWidget(background_label); + layout5->addWidget(backgound_combo); + layout5->addStretch(); + + QHBoxLayout *layout6 = new QHBoxLayout(); + layout6->setSpacing(10); + layout6->addWidget(size_top_label); + layout6->addWidget(size_top_slider); + layout6->addWidget(size_top_value_label); + layout6->addStretch(); + QHBoxLayout *layout7 = new QHBoxLayout(); + layout7->setSpacing(10); + layout7->addWidget(hide_top_label); + layout7->addWidget(hide_top_switcher); + layout7->addStretch(); + QHBoxLayout *layout8 = new QHBoxLayout(); + layout8->setSpacing(10); + layout8->addWidget(size_bottom_label); + layout8->addWidget(size_bottom_slider); + layout8->addWidget(size_bottom_value_label); + layout8->addStretch(); + QHBoxLayout *layout9 = new QHBoxLayout(); + layout9->setSpacing(10); + layout9->addWidget(hide_bottom_label); + layout9->addWidget(hide_bottom_switcher); + layout9->addStretch(); + QHBoxLayout *layout10 = new QHBoxLayout(); + layout10->setSpacing(10); + layout10->addWidget(position_label); + layout10->addWidget(position_combo); + layout10->addStretch(); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(layout1); + layout->addLayout(layout2); + layout->addLayout(layout10); + layout->addLayout(layout3); + layout->addLayout(layout4); + layout->addLayout(layout5); + layout->addLayout(layout6); + layout->addLayout(layout7); + layout->addLayout(layout8); + layout->addLayout(layout9); + layout->addStretch(); + setLayout(layout); + layout->setSpacing(10); + layout->setContentsMargins(20, 20, 0, 0); + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + +// QHBoxLayout *main_layout = new QHBoxLayout; +// main_layout->addStretch(); +// main_layout->addWidget(splitter); +// main_layout->setSpacing(0); +// main_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(main_layout); +// this->initData(); + this->setLanguage(); +} + +LauncherWidget::~LauncherWidget() +{ + if (size_label != NULL) { + delete size_label; + size_label = NULL; + } + if (size_value_label != NULL) { + delete size_value_label; + size_value_label = NULL; + } + if (hide_label != NULL) { + delete hide_label; + hide_label = NULL; + } + if (icon_label != NULL) { + delete icon_label; + icon_label = NULL; + } + if (transparency_label != NULL) { + delete transparency_label; + transparency_label = NULL; + } + if (background_label != NULL) { + delete background_label; + background_label = NULL; + } + if (size_top_label != NULL) { + delete size_top_label; + size_top_label = NULL; + } + if (hide_top_label != NULL) { + delete hide_top_label; + hide_top_label = NULL; + } + if (position_label != NULL) { + delete position_label; + position_label = NULL; + } + if (size_top_value_label != NULL) { + delete size_top_value_label; + size_top_value_label = NULL; + } + if (size_bottom_label != NULL) { + delete size_bottom_label; + size_bottom_label = NULL; + } + if (hide_bottom_label != NULL) { + delete hide_bottom_label; + hide_bottom_label = NULL; + } + if (size_bottom_value_label != NULL) { + delete size_bottom_value_label; + size_bottom_value_label = NULL; + } + if (size_slider != NULL) { + delete size_slider; + size_slider = NULL; + } + if (hide_switcher != NULL) { + delete hide_switcher; + hide_switcher = NULL; + } + if (icon_switcher != NULL) { + delete icon_switcher; + icon_switcher = NULL; + } + if (transparency_slider != NULL) { + delete transparency_slider; + transparency_slider = NULL; + } + if (backgound_combo != NULL) { + delete backgound_combo; + backgound_combo = NULL; + } + if (size_top_slider != NULL) { + delete size_top_slider; + size_top_slider = NULL; + } + if (size_bottom_slider != NULL) { + delete size_bottom_slider; + size_bottom_slider = NULL; + } + if (hide_top_switcher != NULL) { + delete hide_top_switcher; + hide_top_switcher = NULL; + } + if (hide_bottom_switcher != NULL) { + delete hide_bottom_switcher; + hide_bottom_switcher = NULL; + } + if (position_combo != NULL) { + delete position_combo; + position_combo = NULL; + } + +} + +void LauncherWidget::setLanguage() { +// title_label->setText(tr("Launcher settings")); +// description_label->setText(tr("Setting the Launcher display mode, Icon size.")); +// back_btn->setText(tr("Back")); + size_label->setText(tr("Launcher icon size") + ":"); + hide_label->setText(tr("Launcher hide mode") + ":"); + icon_label->setText(tr("Display desktop icon") + ":"); + transparency_label->setText(tr("Launcher Transparency") + ":"); + background_label->setText(tr("Icon Background") + ":"); + size_top_label->setText(tr("Top panel icon size") + ":"); + hide_top_label->setText(tr("Top panel auto hide") + ":"); + size_bottom_label->setText(tr("Bottom panel icon size") + ":"); + hide_bottom_label->setText(tr("Bottom panel auto hide") + ":"); + position_label->setText(tr("Launcher position") + ":"); +} + +bool LauncherWidget::getStatus() +{ + return this->dataOK; +} + +void LauncherWidget::initData() +{ + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + size_top_slider->setValue(sessionproxy->get_mate_panel_icon_size_qt("top")); + size_top_value_label->setText(QString::number(size_top_slider->value())); + size_bottom_slider->setValue(sessionproxy->get_mate_panel_icon_size_qt("bottom")); + size_bottom_value_label->setText(QString::number(size_bottom_slider->value())); + hide_top_switcher->switchedOn = sessionproxy->get_mate_panel_autohide_qt("top"); + hide_bottom_switcher->switchedOn = sessionproxy->get_mate_panel_autohide_qt("bottom"); + } + else + { + size_slider->setValue(sessionproxy->get_launcher_icon_size_qt()); + size_value_label->setText(QString::number(size_slider->value())); + hide_switcher->switchedOn = sessionproxy->get_launcher_autohide_qt(); + icon_switcher->switchedOn = sessionproxy->get_launcher_have_showdesktopicon_qt(); + transparency_slider->setValue(sessionproxy->get_launcher_transparency_qt()); + int cur_index = sessionproxy->get_launcher_icon_colouring_qt(); + QString current_icon_colouring = ""; + if (cur_index == 0) { + current_icon_colouring = "all programs"; + } + else if (cur_index == 1) { + current_icon_colouring = "only run app"; + } + else if (cur_index == 2) { + current_icon_colouring = "no coloring"; + } + else if (cur_index == 3) { + current_icon_colouring = "edge coloring"; + } + else if (cur_index == 4) { + current_icon_colouring = "each workspace alternating coloring"; + } + /*QStringList */colourlist = sessionproxy->get_all_launcher_icon_colourings_qt(); + backgound_combo->clear(); + backgound_combo->clearEditText(); + backgound_combo->addItems(colourlist); + QList::Iterator it = colourlist.begin(), itend = colourlist.end(); + int initIndex = 0; + for(;it != itend; it++,initIndex++) + { + if(*it == current_icon_colouring) + break; + } + backgound_combo->setCurrentIndex(initIndex); + + QString current_position = sessionproxy->get_current_launcher_position_qt(); + positionlist = sessionproxy->get_all_launcher_position_qt(); + position_combo->clear(); + position_combo->clearEditText(); + position_combo->addItems(positionlist); + QList::Iterator it2 = positionlist.begin(), itend2 = positionlist.end(); + initIndex = 0; + for(;it2 != itend2; it2++,initIndex++) + { + if(*it2 == current_position) + break; + } + position_combo->setCurrentIndex(initIndex); + } + + dataOK = true; + this->initConnect(); +} + +void LauncherWidget::initConnect() { +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + connect(size_slider, SIGNAL(valueChanged(int)), this, SLOT(setIconSizeValue(int))); + connect(hide_switcher, SIGNAL(clicked()), this, SLOT(setAutoHide())); + connect(icon_switcher, SIGNAL(clicked()), this, SLOT(setDisplayDesktopIcon())); + connect(transparency_slider, SIGNAL(valueChanged(double)), this, SLOT(setTransparencyValue(double))); + connect(backgound_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setIconColouring(QString))); + connect(position_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setLauncherPosition(QString))); + + connect(size_top_slider, SIGNAL(valueChanged(int)), this, SLOT(setTopIconSizeValue(int))); + connect(size_bottom_slider, SIGNAL(valueChanged(int)), this, SLOT(setBottomIconSizeValue(int))); + connect(hide_top_switcher, SIGNAL(clicked()), this, SLOT(setTopAutoHide())); + connect(hide_bottom_switcher, SIGNAL(clicked()), this, SLOT(setBottomAutoHide())); + + connect(sessionproxy, SIGNAL(bool_value_notify(QString, bool)), this, SLOT(launcherwidget_notify_bool(QString, bool))); + connect(sessionproxy, SIGNAL(double_value_notify(QString, double)), this, SLOT(launcherwidget_notify_double(QString, double))); + connect(sessionproxy, SIGNAL(int_value_notify(QString, int)), this, SLOT(launcherwidget_notify_int(QString, int))); + connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(launcherwidget_notify_string(QString, QString))); +} + +void LauncherWidget::launcherwidget_notify_double(QString key, double value) +{ + if (key == "launcher-opacity") { + transparency_slider->setValue(value); + } +} + +void LauncherWidget::launcherwidget_notify_bool(QString key, bool value) +{ + if (key == "auto-hide-top") { + hide_top_switcher->switchedOn = value; + } + else if (key == "auto-hide-bottom") { + hide_bottom_switcher->switchedOn = value; + } +} + +void LauncherWidget::launcherwidget_notify_int(QString key, int value) +{ + if (key == "icon-size") { + size_slider->setValue(value); + size_value_label->setText(QString::number(value)); + } + else if (key == "launcher-hide-mode") { + if (value == 0) + hide_switcher->switchedOn = false; + else if (value == 1) + hide_switcher->switchedOn = true; + } + else if (key == "backlight-mode") { + QString current_icon_colouring = ""; + if (value == 0) { + current_icon_colouring = "all programs"; + } + else if (value == 1) { + current_icon_colouring = "only run app"; + } + else if (value == 2) { + current_icon_colouring = "no coloring"; + } + else if (value == 3) { + current_icon_colouring = "edge coloring"; + } + else if (value == 4) { + current_icon_colouring = "each workspace alternating coloring"; + } + QList::Iterator it = colourlist.begin(), itend = colourlist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == current_icon_colouring) { + exist = true; + break; + } + } + if (exist) { + exist = false; + backgound_combo->setCurrentIndex(index); + } + else + backgound_combo->setCurrentIndex(-1); + } + else if (key == "size-top") { + size_top_slider->setValue(value); + size_top_value_label->setText(QString::number(value)); + } + else if (key == "size-bottom") { + size_bottom_slider->setValue(value); + size_bottom_value_label->setText(QString::number(value)); + } +} + +void LauncherWidget::launcherwidget_notify_string(QString key, QString value) +{ + if (key == "launcher-position") { + QList::Iterator it = positionlist.begin(), itend = positionlist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if (exist) { + exist = false; + position_combo->setCurrentIndex(index); + } + else + position_combo->setCurrentIndex(-1); + } +} + +void LauncherWidget::setIconSizeValue(int value) { + size_value_label->setText(QString::number(value)); + sessionproxy->set_launcher_icon_size_qt(value); +} + +void LauncherWidget::setTransparencyValue(double value) +{ + sessionproxy->set_launcher_transparency_qt(value); +} + +void LauncherWidget::setIconColouring(QString selectColour) { + if (selectColour == "all programs") { + sessionproxy->set_launcher_icon_colouring_qt(0); + } + else if (selectColour == "only run app") { + sessionproxy->set_launcher_icon_colouring_qt(1); + } + else if (selectColour == "no coloring") { + sessionproxy->set_launcher_icon_colouring_qt(2); + } + else if (selectColour == "edge coloring") { + sessionproxy->set_launcher_icon_colouring_qt(3); + } + else if (selectColour == "each workspace alternating coloring") { + sessionproxy->set_launcher_icon_colouring_qt(4); + } +} + +void LauncherWidget::setAutoHide() { + sessionproxy->set_launcher_autohide_qt(hide_switcher->switchedOn); +} + +void LauncherWidget::setDisplayDesktopIcon() { + sessionproxy->set_launcher_have_showdesktopicon_qt(icon_switcher->switchedOn); +} + +void LauncherWidget::setTopIconSizeValue(int value){ + size_top_value_label->setText(QString::number(value)); + sessionproxy->set_mate_panel_icon_size_qt("top", value); +} + +void LauncherWidget::setBottomIconSizeValue(int value){ + size_bottom_value_label->setText(QString::number(value)); + sessionproxy->set_mate_panel_icon_size_qt("bottom", value); +} + +void LauncherWidget::setTopAutoHide() { + sessionproxy->set_mate_panel_autohide_qt("top", hide_top_switcher->switchedOn); +} + +void LauncherWidget::setBottomAutoHide() { + sessionproxy->set_mate_panel_autohide_qt("bottom", hide_bottom_switcher->switchedOn); +} + +void LauncherWidget::setLauncherPosition(QString position) { + sessionproxy->set_launcher_position_qt(position); +} diff --git a/setting/launcherwidget.h b/setting/launcherwidget.h new file mode 100644 index 0000000..0fce04d --- /dev/null +++ b/setting/launcherwidget.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LAUNCHERWIDGET_H +#define LAUNCHERWIDGET_H + +#include +#include "../component/kylinswitcher.h" + +class SessionDispatcher; +class QLabel; +class QPushButton; +class QComboBox; +class QSlider; +class QDoubleSpinBox; + +class LauncherWidget : public QWidget +{ + Q_OBJECT +public: + explicit LauncherWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0, QString cur_desktop = ""); + ~LauncherWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + +public slots: + void setIconColouring(QString selectColour); + void setAutoHide(); + void setDisplayDesktopIcon(); + void setIconSizeValue(int value); + void setTransparencyValue(double value); + void setTopIconSizeValue(int value); + void setBottomIconSizeValue(int value); + void setTopAutoHide(); + void setBottomAutoHide(); + void setLauncherPosition(QString position); + + void launcherwidget_notify_double(QString key, double value); + void launcherwidget_notify_bool(QString key, bool value); + void launcherwidget_notify_int(QString key, int value); + void launcherwidget_notify_string(QString key, QString value); + +private: + SessionDispatcher *sessionproxy; + bool dataOK; + QString desktop; + QStringList colourlist; + QStringList positionlist; + QLabel *size_label; + QLabel *size_value_label; + QLabel *hide_label; + QLabel *icon_label; + QLabel *transparency_label; + QLabel *background_label; + QLabel *size_top_label; + QLabel *hide_top_label; + QLabel *size_top_value_label; + QLabel *size_bottom_label; + QLabel *hide_bottom_label; + QLabel *size_bottom_value_label; + QLabel *position_label; + QSlider *size_slider; + KylinSwitcher *hide_switcher; + KylinSwitcher *icon_switcher; + QDoubleSpinBox *transparency_slider; + QComboBox *backgound_combo; + QSlider *size_top_slider; + QSlider *size_bottom_slider; + KylinSwitcher *hide_top_switcher; + KylinSwitcher *hide_bottom_switcher; + QComboBox *position_combo; +}; + +#endif // LAUNCHERWIDGET_H diff --git a/setting/mousewidget.cpp b/setting/mousewidget.cpp new file mode 100644 index 0000000..e5a8ca0 --- /dev/null +++ b/setting/mousewidget.cpp @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "mousewidget.h" +#include +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" +#include "../dbusproxy/youkersystemdbus.h" + +MouseWidget::MouseWidget(QWidget *parent, SessionDispatcher *proxy , SystemDispatcher *sproxy, QString cur_desktop) : + QWidget(parent), + sessionproxy(proxy), + systemproxy(sproxy), + desktop(cur_desktop) +{ + dataOK = false; + theme_label = new QLabel(); + size_label = new QLabel(); + theme_combo = new QComboBox(); + small_size = new QRadioButton(); + small_size->setFocusPolicy(Qt::NoFocus); +// small_size->setChecked(true); + small_size->setObjectName("smallradio"); + big_size = new QRadioButton(); + big_size->setFocusPolicy(Qt::NoFocus); +// big_size->setChecked(false); + big_size->setObjectName("bigradio"); + + theme_label->setFixedWidth(150); + size_label->setFixedWidth(150); + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->setSpacing(10); + layout1->addWidget(theme_label); + layout1->addWidget(theme_combo); + layout1->addStretch(); + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->setSpacing(10); + layout2->addWidget(size_label); + layout2->addWidget(small_size); + layout2->addWidget(big_size); + layout2->addStretch(); + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(layout1); + layout->addLayout(layout2); + layout->addStretch(); + setLayout(layout); + layout->setSpacing(10); + layout->setContentsMargins(20, 20, 0, 0); + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + + +// QHBoxLayout *main_layout = new QHBoxLayout; +// main_layout->addStretch(); +// main_layout->addWidget(splitter); +// main_layout->setSpacing(0); +// main_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(main_layout); +// this->initData(); + this->setLanguage(); +} + +MouseWidget::~MouseWidget() +{ + if (theme_label != NULL) { + delete theme_label; + theme_label = NULL; + } + if (size_label != NULL) { + delete size_label; + size_label = NULL; + } + if (theme_combo != NULL) { + delete theme_combo; + theme_combo = NULL; + } + if (small_size != NULL) { + delete small_size; + small_size = NULL; + } + if (big_size != NULL) { + delete big_size; + big_size = NULL; + } +} + +void MouseWidget::setLanguage() { +// title_label->setText(tr("Mouse Settings")); +// description_label->setText(tr("Replace the theme and size of the mouse pointer, then click the 'OK' button to confirm. Also, theme change need to restart system.")); +// back_btn->setText(tr("Back")); + theme_label->setText(tr("Mouse Pointer Theme") + ":"); + size_label->setText(tr("Cursor Pointer Size") + ":"); + small_size->setText(tr("Small Size")); + big_size->setText(tr("Big Size")); +} + +bool MouseWidget::getStatus() +{ + return this->dataOK; +} + +void MouseWidget::initData() +{ + //在mate下,默认值为空 + QString current_cursor_theme = sessionproxy->get_cursor_theme_qt(); + /*QStringList */cursorlist = sessionproxy->get_cursor_themes_qt(); + theme_combo->clear(); + theme_combo->clearEditText(); + theme_combo->addItems(cursorlist); + QList::Iterator it = cursorlist.begin(), itend = cursorlist.end(); + int initIndex = 0; + for(;it != itend; it++,initIndex++) + { + if(*it == current_cursor_theme) + break; + } + theme_combo->setCurrentIndex(initIndex); + int default_value = sessionproxy->get_cursor_size_qt(); + if(default_value < 48) { + small_size->setChecked(true); + big_size->setChecked(false); + } + else { + big_size->setChecked(true); + small_size->setChecked(false); + } +// if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") +// { +// if(default_value == 18 || default_value == 24) { +// small_size->setChecked(true); +// big_size->setChecked(false); +// } +// else if(default_value == 48) { +// big_size->setChecked(true); +// small_size->setChecked(false); +// } +// } +// else +// { +// if(default_value == 24) { +// small_size->setChecked(true); +// big_size->setChecked(false); +// } +// else if(default_value == 48) { +// big_size->setChecked(true); +// small_size->setChecked(false); +// } +// } + dataOK = true; + this->initConnect(); +} + +void MouseWidget::initConnect() { +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + connect(theme_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setMouseCursorTheme(QString))); + connect(small_size, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/))); + connect(big_size, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/))); + + connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(mousewidget_notify_string(QString, QString))); + connect(sessionproxy, SIGNAL(int_value_notify(QString, int)), this, SLOT(mousewidget_notify_int(QString, int))); +} + +void MouseWidget::mousewidget_notify_string(QString key, QString value) +{ + if (key == "cursor-theme") { + QList::Iterator it = cursorlist.begin(), itend = cursorlist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) + { + exist = true; + break; + } + } + if (exist) { + exist = false; + theme_combo->setCurrentIndex(index); + } + else + theme_combo->setCurrentIndex(-1); + } +} + +void MouseWidget::mousewidget_notify_int(QString key, int value) +{ + if (key == "cursor-size") { + if(value < 48) { + small_size->setChecked(true); + big_size->setChecked(false); + } + else { + big_size->setChecked(true); + small_size->setChecked(false); + } + } +} + +void MouseWidget::setMouseCursorTheme(QString selectTheme) +{ + sessionproxy->set_cursor_theme_qt(selectTheme); + systemproxy->set_cursor_theme_with_root_qt(selectTheme); +} + +void MouseWidget::setRadioButtonRowStatus(/*bool status*/) +{ + QObject *obj = sender(); //返回发出信号的对象,用QObject类型接收 + QRadioButton* pbtn = qobject_cast(obj); + QString obj_name = pbtn->objectName(); + if(obj_name == "smallradio") + { + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") + sessionproxy->set_cursor_size_qt(18); + else + sessionproxy->set_cursor_size_qt(24); + } + else if(obj_name == "bigradio") + { + sessionproxy->set_cursor_size_qt(48); + } +} diff --git a/setting/mousewidget.h b/setting/mousewidget.h new file mode 100644 index 0000000..8e2174b --- /dev/null +++ b/setting/mousewidget.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef MOUSEWIDGET_H +#define MOUSEWIDGET_H + +#include +#include + +class SessionDispatcher; +class SystemDispatcher; +class QLabel; +class QPushButton; +class QComboBox; +class QRadioButton; + +class MouseWidget : public QWidget +{ + Q_OBJECT +public: + explicit MouseWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0, SystemDispatcher *sproxy = 0, QString cur_desktop = ""); + ~MouseWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + +//signals: +// void showSettingMainWidget(); + +public slots: + void setMouseCursorTheme(QString selectTheme); + void setRadioButtonRowStatus(/*bool status*/); + + void mousewidget_notify_string(QString key, QString value); + void mousewidget_notify_int(QString key, int value); + +private: + SessionDispatcher *sessionproxy; + SystemDispatcher *systemproxy; + bool dataOK; + QStringList cursorlist; + QLabel *theme_label; + QLabel *size_label; + QComboBox *theme_combo; + QRadioButton *small_size; + QRadioButton *big_size; + QString desktop; +}; + +#endif // MOUSEWIDGET_H diff --git a/setting/nautiluswidget.cpp b/setting/nautiluswidget.cpp new file mode 100644 index 0000000..bf77249 --- /dev/null +++ b/setting/nautiluswidget.cpp @@ -0,0 +1,349 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "nautiluswidget.h" +#include +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" + +NautilusWidget::NautilusWidget(QWidget *parent, SessionDispatcher *proxy) : + QWidget(parent), + sessionproxy(proxy) +{ + dataOK = false; + location_label = new QLabel(); + mount_media_label = new QLabel(); + open_folder_label = new QLabel(); + autorun_program_label = new QLabel(); + icon_size_label = new QLabel(); + cache_time_label = new QLabel(); + cache_size_label = new QLabel(); + size_value_label = new QLabel(); + time_value_label = new QLabel(); + cache_value_label = new QLabel(); + location_switcher = new KylinSwitcher(); + mount_media_switcher = new KylinSwitcher(); + open_folder_switcher = new KylinSwitcher(); + autorun_program_switcher = new KylinSwitcher(); + icon_size_slider = new QSlider(Qt::Horizontal); + icon_size_slider->setRange(16, 512); + icon_size_slider->setSingleStep(1); +// icon_size_slider->setTickPosition(QSlider::TicksRight); + icon_size_slider->setFocusPolicy(Qt::NoFocus); +// icon_size_slider->setMinimum(1); +// icon_size_slider->setMaximum(10); +// icon_size_slider->setValue(2); + + cache_time_slider = new QSlider(Qt::Horizontal); + cache_time_slider->setRange(-1, 180); + cache_time_slider->setSingleStep(1); +// cache_time_slider->setTickPosition(QSlider::TicksRight); + cache_time_slider->setFocusPolicy(Qt::NoFocus); +// cache_time_slider->setValue(2); + + cache_size_slider = new QSlider(Qt::Horizontal); + cache_size_slider->setRange(-1, 512); + cache_size_slider->setSingleStep(1); +// cache_size_slider->setTickPosition(QSlider::TicksRight); + cache_size_slider->setFocusPolicy(Qt::NoFocus); +// cache_size_slider->setValue(2); + + location_label->setFixedWidth(245); + mount_media_label->setFixedWidth(245); + open_folder_label->setFixedWidth(245); + autorun_program_label->setFixedWidth(245); + icon_size_label->setFixedWidth(245); + cache_time_label->setFixedWidth(245); + cache_size_label->setFixedWidth(245); + + + +// QFormLayout *form_layout = new QFormLayout(); +// form_layout->setSpacing(10); +// form_layout->setHorizontalSpacing(5); +// form_layout->setRowWrapPolicy(QFormLayout::DontWrapRows); +// form_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); +// form_layout->addRow(QString(tr("Display entry location") + ":"), location_switcher); +// form_layout->addRow(QString(tr("Automatically mount media") + ":"), mount_media_switcher); +// form_layout->addRow(QString(tr("Automatically open a folder") + ":"), open_folder_switcher); +// form_layout->addRow(QString(tr("Prompt autorun programs") + ":"), autorun_program_switcher); +// form_layout->addRow(QString(tr("Thumbnail icon size (pixels)") + ":"), icon_size_slider); +// form_layout->addRow(QString(tr("Thumbnail cache time (days)") + ":"), cache_time_slider); +// form_layout->addRow(QString(tr("Maximum thumbnail cache size (MB)") + ":"), cache_size_slider); + + + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->setSpacing(10); + layout1->addWidget(location_label); + layout1->addWidget(location_switcher); + layout1->addStretch(); + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->setSpacing(10); + layout2->addWidget(mount_media_label); + layout2->addWidget(mount_media_switcher); + layout2->addStretch(); + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->setSpacing(10); + layout3->addWidget(open_folder_label); + layout3->addWidget(open_folder_switcher); + layout3->addStretch(); + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->setSpacing(10); + layout4->addWidget(autorun_program_label); + layout4->addWidget(autorun_program_switcher); + layout4->addStretch(); + QHBoxLayout *layout5 = new QHBoxLayout(); + layout5->setSpacing(10); + layout5->addWidget(icon_size_label); + layout5->addWidget(icon_size_slider); + layout5->addWidget(size_value_label); + layout5->addStretch(); + QHBoxLayout *layout6 = new QHBoxLayout(); + layout6->setSpacing(10); + layout6->addWidget(cache_time_label); + layout6->addWidget(cache_time_slider); + layout6->addWidget(time_value_label); + layout6->addStretch(); + QHBoxLayout *layout7 = new QHBoxLayout(); + layout7->setSpacing(10); + layout7->addWidget(cache_size_label); + layout7->addWidget(cache_size_slider); + layout7->addWidget(cache_value_label); + layout7->addStretch(); + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(layout1); + layout->addLayout(layout2); + layout->addLayout(layout3); + layout->addLayout(layout4); + layout->addLayout(layout5); + layout->addLayout(layout6); + layout->addLayout(layout7); + layout->addStretch(); + setLayout(layout); + layout->setSpacing(10); + layout->setContentsMargins(20, 20, 0, 0); + + +// setLayout(form_layout); + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + +// QHBoxLayout *main_layout = new QHBoxLayout; +// main_layout->addStretch(); +// main_layout->addWidget(splitter); +// main_layout->setSpacing(0); +// main_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(main_layout); +// this->initData(); + this->setLanguage(); +} + +NautilusWidget::~NautilusWidget() +{ + if (location_label != NULL) { + delete location_label; + location_label = NULL; + } + if (mount_media_label != NULL) { + delete mount_media_label; + mount_media_label = NULL; + } + if (open_folder_label != NULL) { + delete open_folder_label; + open_folder_label = NULL; + } + if (autorun_program_label != NULL) { + delete autorun_program_label; + autorun_program_label = NULL; + } + if (icon_size_label != NULL) { + delete icon_size_label; + icon_size_label = NULL; + } + if (size_value_label != NULL) { + delete size_value_label; + size_value_label = NULL; + } + if (cache_time_label != NULL) { + delete cache_time_label; + cache_time_label = NULL; + } + if (time_value_label != NULL) { + delete time_value_label; + time_value_label = NULL; + } + if (cache_size_label != NULL) { + delete cache_size_label; + cache_size_label = NULL; + } + if (cache_value_label != NULL) { + delete cache_value_label; + cache_value_label = NULL; + } + if (location_switcher != NULL) { + delete location_switcher; + location_switcher = NULL; + } + if (mount_media_switcher != NULL) { + delete mount_media_switcher; + mount_media_switcher = NULL; + } + if (open_folder_switcher != NULL) { + delete open_folder_switcher; + open_folder_switcher = NULL; + } + if (autorun_program_switcher != NULL) { + delete autorun_program_switcher; + autorun_program_switcher = NULL; + } + if (icon_size_slider != NULL) { + delete icon_size_slider; + icon_size_slider = NULL; + } + if (cache_time_slider != NULL) { + delete cache_time_slider; + cache_time_slider = NULL; + } + if (cache_size_slider != NULL) { + delete cache_size_slider; + cache_size_slider = NULL; + } +} + +void NautilusWidget::setLanguage() { +// title_label->setText(tr("File Manager")); +// description_label->setText(tr("Manage the Nautilus file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked.")); +// back_btn->setText(tr("Back")); + location_label->setText(tr("Display entry location") + ":"); + mount_media_label->setText(tr("Automatically mount media") + ":"); + open_folder_label->setText(tr("Automatically open a folder") + ":"); + autorun_program_label->setText(tr("Prompt autorun programs") + ":"); + icon_size_label->setText(tr("Thumbnail icon size (pixels)") + ":"); + cache_time_label->setText(tr("Thumbnail cache time (days)") + ":"); + cache_size_label->setText(tr("Maximum thumbnail cache size (MB)") + ":"); +} + +bool NautilusWidget::getStatus() +{ + return this->dataOK; +} + +void NautilusWidget::initData() +{ + location_switcher->switchedOn = sessionproxy->get_location_replace_pathbar_qt(); + mount_media_switcher->switchedOn = sessionproxy->get_auto_mount_media_qt(); + open_folder_switcher->switchedOn = sessionproxy->get_auto_open_folder_qt(); + autorun_program_switcher->switchedOn = sessionproxy->get_prompt_autorun_programs_qt(); + icon_size_slider->setValue(sessionproxy->get_thumbnail_icon_size_qt()); + cache_time_slider->setValue(sessionproxy->get_thumbnail_cache_time_qt()); + cache_size_slider->setValue(sessionproxy->get_thumbnail_cache_size_qt()); + size_value_label->setText(QString::number(icon_size_slider->value())); + time_value_label->setText(QString::number(cache_time_slider->value())); + cache_value_label->setText(QString::number(cache_size_slider->value())); + dataOK = true; + this->initConnect(); +} + +void NautilusWidget::initConnect() { +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + connect(location_switcher, SIGNAL(clicked()), this, SLOT(setLocation())); + connect(mount_media_switcher, SIGNAL(clicked()), this, SLOT(setMountMedia())); + connect(open_folder_switcher, SIGNAL(clicked()), this, SLOT(setOpenFolder())); + connect(autorun_program_switcher, SIGNAL(clicked()), this, SLOT(setAutorunProgram())); + connect(icon_size_slider, SIGNAL(valueChanged(int)), this, SLOT(setIconSizeValue(int))); + connect(cache_time_slider, SIGNAL(valueChanged(int)), this, SLOT(setCacheTimeValue(int))); + connect(cache_size_slider, SIGNAL(valueChanged(int)), this, SLOT(setCacheSizeValue(int))); + + connect(sessionproxy, SIGNAL(bool_value_notify(QString, bool)), this, SLOT(nautiluswidget_notify_bool(QString, bool))); + connect(sessionproxy, SIGNAL(int_value_notify(QString, int)), this, SLOT(nautiluswidget_notify_int(QString, int))); +} + +void NautilusWidget::nautiluswidget_notify_bool(QString key, bool value) +{ + if (key == "always-use-location-entry") { + location_switcher->switchedOn = value; + } + else if (key == "automount") { + mount_media_switcher->switchedOn = value; + } + else if (key == "automount-open") { + open_folder_switcher->switchedOn = value; + } + else if (key == "autorun-never") { + autorun_program_switcher->switchedOn = value; + } +} + +void NautilusWidget::nautiluswidget_notify_int(QString key, int value) +{ + if (key == "thumbnail-size") { + icon_size_slider->setValue(value); + size_value_label->setText(QString::number(value)); + } + else if (key == "maximum-age") { + cache_time_slider->setValue(value); + time_value_label->setText(QString::number(value)); + } + else if (key == "maximum-size") { + cache_size_slider->setValue(value); + cache_value_label->setText(QString::number(value)); + } +} + +void NautilusWidget::setLocation() +{ + sessionproxy->set_location_replace_pathbar_qt(location_switcher->switchedOn); +} + +void NautilusWidget::setMountMedia() +{ + sessionproxy->set_auto_mount_media_qt(mount_media_switcher->switchedOn); +} + +void NautilusWidget::setOpenFolder() +{ + sessionproxy->set_auto_open_folder_qt(open_folder_switcher->switchedOn); +} + +void NautilusWidget::setAutorunProgram() +{ + sessionproxy->set_prompt_autorun_programs_qt(autorun_program_switcher->switchedOn); +} + +void NautilusWidget::setIconSizeValue(int value) +{ + size_value_label->setText(QString::number(value)); + sessionproxy->set_thumbnail_icon_size_qt(value); +} + +void NautilusWidget::setCacheTimeValue(int value) +{ + time_value_label->setText(QString::number(value)); + sessionproxy->set_thumbnail_cache_time_qt(value); +} + +void NautilusWidget::setCacheSizeValue(int value) +{ + cache_value_label->setText(QString::number(value)); + sessionproxy->set_thumbnail_cache_size_qt(value); +} diff --git a/setting/nautiluswidget.h b/setting/nautiluswidget.h new file mode 100644 index 0000000..7733788 --- /dev/null +++ b/setting/nautiluswidget.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef NAUTILUSWIDGET_H +#define NAUTILUSWIDGET_H + +#include +#include "../component/kylinswitcher.h" + +class SessionDispatcher; +class QLabel; +class QPushButton; +class QSlider; + +class NautilusWidget : public QWidget +{ + Q_OBJECT +public: + explicit NautilusWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0); + ~NautilusWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + +public slots: + void setLocation(); + void setMountMedia(); + void setOpenFolder(); + void setAutorunProgram(); + void setIconSizeValue(int value); + void setCacheTimeValue(int value); + void setCacheSizeValue(int value); + + void nautiluswidget_notify_bool(QString key, bool value); + void nautiluswidget_notify_int(QString key, int value); + +private: + SessionDispatcher *sessionproxy; + bool dataOK; + QLabel *location_label; + QLabel *mount_media_label; + QLabel *open_folder_label; + QLabel *autorun_program_label; + QLabel *icon_size_label; + QLabel *size_value_label; + QLabel *cache_time_label; + QLabel *time_value_label; + QLabel *cache_size_label; + QLabel *cache_value_label; + KylinSwitcher *location_switcher; + KylinSwitcher *mount_media_switcher; + KylinSwitcher *open_folder_switcher; + KylinSwitcher *autorun_program_switcher; + QSlider *icon_size_slider; + QSlider *cache_time_slider; + QSlider *cache_size_slider; +}; + +#endif // NAUTILUSWIDGET_H diff --git a/setting/panelwidget.cpp b/setting/panelwidget.cpp new file mode 100644 index 0000000..8f94a4c --- /dev/null +++ b/setting/panelwidget.cpp @@ -0,0 +1,594 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "panelwidget.h" +#include +#include +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" + +PanelWidget::PanelWidget(QWidget *parent, SessionDispatcher *proxy, QString cur_desktop, bool has_battery) : + QWidget(parent),desktop(cur_desktop), + sessionproxy(proxy) +{ + dataOK = false; + blur_label = new QLabel(); + transparency_label = new QLabel(); + date_format_label = new QLabel(); + second_label = new QLabel(); + week_label = new QLabel(); + date_label = new QLabel(); + battery_icon_label = new QLabel(); + battery_percentage_label = new QLabel(); + battery_time_label = new QLabel(); + show_app_label = new QLabel(); + show_desktop_label = new QLabel(); + show_icon_label = new QLabel(); + show_places_label = new QLabel(); + + smart_radio = new QRadioButton(); + smart_radio->setFocusPolicy(Qt::NoFocus); + smart_radio->setChecked(true); + smart_radio->setObjectName("smart_radio"); + static_radio = new QRadioButton(); + static_radio->setFocusPolicy(Qt::NoFocus); + static_radio->setChecked(false); + static_radio->setObjectName("static_radio"); + clear_radio = new QRadioButton(); + clear_radio->setFocusPolicy(Qt::NoFocus); + clear_radio->setChecked(false); + clear_radio->setObjectName("clear_radio"); + QHBoxLayout *radio_layout = new QHBoxLayout(); + radio_layout->setSpacing(10); + radio_layout->addWidget(smart_radio); + radio_layout->addWidget(static_radio); + radio_layout->addWidget(clear_radio); + radio_layout->addStretch(); + + transparency_slider = new QDoubleSpinBox(); + transparency_slider->setButtonSymbols(QAbstractSpinBox::PlusMinus); + transparency_slider->setSingleStep(0.1); + transparency_slider->setMinimum(0.2); + transparency_slider->setMaximum(8.0); + + date_combo = new QComboBox(); + second_switcher = new KylinSwitcher(); + week_switcher = new KylinSwitcher(); + date_switcher = new KylinSwitcher(); + battery_combo = new QComboBox(); + battery_percentage_switcher = new KylinSwitcher(); + battery_time_switcher = new KylinSwitcher(); + app_switcher = new KylinSwitcher(); + desktop_switcher = new KylinSwitcher(); + icon_switcher = new KylinSwitcher(); + places_switcher = new KylinSwitcher(); + + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + blur_label->hide(); + transparency_label->hide(); + date_format_label->hide(); + second_label->hide(); + week_label->hide(); + date_label->hide(); + battery_icon_label->hide(); + battery_percentage_label->hide(); + battery_time_label->hide(); + smart_radio->hide(); + static_radio->hide(); + clear_radio->hide(); + transparency_slider->hide(); + date_combo->hide(); + second_switcher->hide(); + week_switcher->hide(); + date_switcher->hide(); + battery_combo->hide(); + battery_percentage_switcher->hide(); + battery_time_switcher->hide(); + } + else { + show_app_label->hide(); + show_desktop_label->hide(); + show_icon_label->hide(); + show_places_label->hide(); + app_switcher->hide(); + desktop_switcher->hide(); + icon_switcher->hide(); + places_switcher->hide(); + } + + blur_label->setFixedWidth(220); + transparency_label->setFixedWidth(220); + date_format_label->setFixedWidth(220); + second_label->setFixedWidth(220); + week_label->setFixedWidth(220); + date_label->setFixedWidth(220); + battery_icon_label->setFixedWidth(220); + battery_percentage_label->setFixedWidth(220); + battery_time_label->setFixedWidth(220); + show_app_label->setFixedWidth(220); + show_desktop_label->setFixedWidth(220); + show_icon_label->setFixedWidth(220); + show_places_label->setFixedWidth(220); + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->setSpacing(10); + layout1->addWidget(blur_label); + layout1->addLayout(radio_layout); + layout1->addStretch(); + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->setSpacing(10); + layout2->addWidget(transparency_label); + layout2->addWidget(transparency_slider); + layout2->addStretch(); + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->setSpacing(10); + layout3->addWidget(date_format_label); + layout3->addWidget(date_combo); + layout3->addStretch(); + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->setSpacing(10); + layout4->addWidget(second_label); + layout4->addWidget(second_switcher); + layout4->addStretch(); + QHBoxLayout *layout5 = new QHBoxLayout(); + layout5->setSpacing(10); + layout5->addWidget(week_label); + layout5->addWidget(week_switcher); + layout5->addStretch(); + QHBoxLayout *layout6 = new QHBoxLayout(); + layout6->setSpacing(10); + layout6->addWidget(date_label); + layout6->addWidget(date_switcher); + layout6->addStretch(); + QHBoxLayout *layout7 = new QHBoxLayout(); + layout7->setSpacing(10); + layout7->addWidget(battery_icon_label); + layout7->addWidget(battery_combo); + layout7->addStretch(); + QHBoxLayout *layout8 = new QHBoxLayout(); + layout8->setSpacing(10); + layout8->addWidget(battery_percentage_label); + layout8->addWidget(battery_percentage_switcher); + layout8->addStretch(); + QHBoxLayout *layout9 = new QHBoxLayout(); + layout9->setSpacing(10); + layout9->addWidget(battery_time_label); + layout9->addWidget(battery_time_switcher); + layout9->addStretch(); + QHBoxLayout *layout10 = new QHBoxLayout(); + layout10->setSpacing(10); + layout10->addWidget(show_app_label); + layout10->addWidget(app_switcher); + layout10->addStretch(); + QHBoxLayout *layout11 = new QHBoxLayout(); + layout11->setSpacing(10); + layout11->addWidget(show_desktop_label); + layout11->addWidget(desktop_switcher); + layout11->addStretch(); + QHBoxLayout *layout12 = new QHBoxLayout(); + layout12->setSpacing(10); + layout12->addWidget(show_icon_label); + layout12->addWidget(icon_switcher); + layout12->addStretch(); + QHBoxLayout *layout13 = new QHBoxLayout(); + layout13->setSpacing(10); + layout13->addWidget(show_places_label); + layout13->addWidget(places_switcher); + layout13->addStretch(); + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(layout1); + layout->addLayout(layout2); + layout->addLayout(layout3); + layout->addLayout(layout4); + layout->addLayout(layout5); + layout->addLayout(layout6); +// if(sessionproxy->judge_power_is_exists_qt()) + if(has_battery) + { + layout->addLayout(layout7); + layout->addLayout(layout8); + layout->addLayout(layout9); + } + layout->addLayout(layout10); + layout->addLayout(layout11); + layout->addLayout(layout12); + layout->addLayout(layout13); + layout->addStretch(); + setLayout(layout); + layout->setSpacing(10); + layout->setContentsMargins(20, 20, 0, 0); + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + +// QHBoxLayout *main_layout = new QHBoxLayout; +// main_layout->addStretch(); +// main_layout->addWidget(splitter); +// main_layout->setSpacing(0); +// main_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(main_layout); +// this->initData(); + this->setLanguage(); +} + +PanelWidget::~PanelWidget() +{ + if (blur_label != NULL) { + delete blur_label; + blur_label = NULL; + } + if (transparency_label != NULL) { + delete transparency_label; + transparency_label = NULL; + } + if (date_format_label != NULL) { + delete date_format_label; + date_format_label = NULL; + } + if (second_label != NULL) { + delete second_label; + second_label = NULL; + } + if (week_label != NULL) { + delete week_label; + week_label = NULL; + } + if (date_label != NULL) { + delete date_label; + date_label = NULL; + } + if (battery_icon_label != NULL) { + delete battery_icon_label; + battery_icon_label = NULL; + } + if (battery_percentage_label != NULL) { + delete battery_percentage_label; + battery_percentage_label = NULL; + } + if (battery_time_label != NULL) { + delete battery_time_label; + battery_time_label = NULL; + } + if (show_app_label != NULL) { + delete show_app_label; + show_app_label = NULL; + } + if (show_desktop_label != NULL) { + delete show_desktop_label; + show_desktop_label = NULL; + } + if (show_icon_label != NULL) { + delete show_icon_label; + show_icon_label = NULL; + } + if (show_places_label != NULL) { + delete show_places_label; + show_places_label = NULL; + } + if (smart_radio != NULL) { + delete smart_radio; + smart_radio = NULL; + } + if (static_radio != NULL) { + delete static_radio; + static_radio = NULL; + } + if (clear_radio != NULL) { + delete clear_radio; + clear_radio = NULL; + } + if (transparency_slider != NULL) { + delete transparency_slider; + transparency_slider = NULL; + } + if (date_combo != NULL) { + delete date_combo; + date_combo = NULL; + } + if (second_switcher != NULL) { + delete second_switcher; + second_switcher = NULL; + } + if (week_switcher != NULL) { + delete week_switcher; + week_switcher = NULL; + } + if (date_switcher != NULL) { + delete date_switcher; + date_switcher = NULL; + } + if (battery_combo != NULL) { + delete battery_combo; + battery_combo = NULL; + } + if (battery_percentage_switcher != NULL) { + delete battery_percentage_switcher; + battery_percentage_switcher = NULL; + } + if (battery_time_switcher != NULL) { + delete battery_time_switcher; + battery_time_switcher = NULL; + } + if (app_switcher != NULL) { + delete app_switcher; + app_switcher = NULL; + } + if (desktop_switcher != NULL) { + delete desktop_switcher; + desktop_switcher = NULL; + } + if (icon_switcher != NULL) { + delete icon_switcher; + icon_switcher = NULL; + } + if (places_switcher != NULL) { + delete places_switcher; + places_switcher = NULL; + } +} + +void PanelWidget::setLanguage() { +// title_label->setText(tr("Dash & Panel")); +// description_label->setText(tr("Manage Dash and Panel menu settings.")); +// back_btn->setText(tr("Back")); + blur_label->setText(tr("Dash background blur type") + ":"); + transparency_label->setText(tr("Panel Transparency") + ":"); + date_format_label->setText(tr("Date & time format") + ":"); + second_label->setText(tr("Display seconds") + ":"); + week_label->setText(tr("Display week") + ":"); + date_label->setText(tr("Display the date") + ":"); + battery_icon_label->setText(tr("Display battery icon") + ":"); + battery_percentage_label->setText(tr("Display battery percentage") + ":"); + battery_time_label->setText(tr("Display battery remaining time") + ":"); + + smart_radio->setText(tr("Smart blur")); + static_radio->setText(tr("Static blur")); + clear_radio->setText(tr("Clear")); + + show_app_label->setText(tr("Show applications") + ":"); + show_desktop_label->setText(tr("Show system") + ":");//Show desktop + show_icon_label->setText(tr("Show icon") + ":"); + show_places_label->setText(tr("Show places") + ":"); +} + +bool PanelWidget::getStatus() +{ + return this->dataOK; +} + +void PanelWidget::initData() +{ + if(this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + app_switcher->switchedOn = sessionproxy->get_show_apps_qt(); + desktop_switcher->switchedOn = sessionproxy->get_show_desktop_qt(); + icon_switcher->switchedOn = sessionproxy->get_show_icon_qt(); + places_switcher->switchedOn = sessionproxy->get_show_places_qt(); + } + else {//unity + int default_value = sessionproxy->get_dash_blur_experimental_qt(); + if(default_value == 2) { + smart_radio->setChecked(true); + static_radio->setChecked(false); + clear_radio->setChecked(false); + } + else if(default_value == 1) { + static_radio->setChecked(true); + smart_radio->setChecked(false); + clear_radio->setChecked(false); + } + else if(default_value == 0) { + clear_radio->setChecked(true); + static_radio->setChecked(false); + smart_radio->setChecked(false); + } + transparency_slider->setValue(sessionproxy->get_panel_transparency_qt()); + QString cur_format = sessionproxy->get_time_format_qt(); + QStringList timelist = sessionproxy->get_all_time_format_qt(); + date_combo->clear(); + date_combo->clearEditText(); + date_combo->addItems(timelist); + QList::Iterator it = timelist.begin(), itend = timelist.end(); + int initIndex = 0; + for(;it != itend; it++,initIndex++) + { + if(*it == cur_format) + break; + } + date_combo->setCurrentIndex(initIndex); + + second_switcher->switchedOn = sessionproxy->get_show_seconds_qt(); + week_switcher->switchedOn = sessionproxy->get_show_week_qt(); + date_switcher->switchedOn = sessionproxy->get_show_date_qt(); + + QString cur_power = sessionproxy->get_power_icon_policy_qt(); + /*QStringList */powerlist = sessionproxy->get_all_power_icon_policy_qt(); + battery_combo->clear(); + battery_combo->clearEditText(); + battery_combo->addItems(powerlist); + QList::Iterator ite = powerlist.begin(), iteend = powerlist.end(); + int index = 0; + for(;ite != iteend; ite++,index++) + { + if(*ite == cur_power) + break; + } + battery_combo->setCurrentIndex(index); + + battery_percentage_switcher->switchedOn = sessionproxy->get_show_power_percentage_qt(); + battery_time_switcher->switchedOn = sessionproxy->get_show_power_time_qt(); + } + + dataOK = true; + this->initConnect(); +} + +void PanelWidget::initConnect() { +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + connect(smart_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/))); + connect(static_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/))); + connect(clear_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/))); + connect(transparency_slider, SIGNAL(valueChanged(double)), this, SLOT(setTransparencyValue(double))); + connect(date_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setDateFormat(QString))); + connect(second_switcher, SIGNAL(clicked()), this, SLOT(setDisplaySeconds())); + connect(week_switcher, SIGNAL(clicked()), this, SLOT(setDisplayWeek())); + connect(date_switcher, SIGNAL(clicked()), this, SLOT(setDisplayDate())); + connect(battery_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setShowBatteryIcon(QString))); + connect(battery_percentage_switcher, SIGNAL(clicked()), this, SLOT(setDisplayBatteryPercentage())); + connect(battery_time_switcher, SIGNAL(clicked()), this, SLOT(setDisplayBatteryTime())); + connect(app_switcher, SIGNAL(clicked()), this, SLOT(showApplications())); + connect(desktop_switcher, SIGNAL(clicked()), this, SLOT(showDesktop())); + connect(icon_switcher, SIGNAL(clicked()), this, SLOT(showIcon())); + connect(places_switcher, SIGNAL(clicked()), this, SLOT(showPlaces())); + + connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(panelwidget_notify_string(QString, QString))); + connect(sessionproxy, SIGNAL(bool_value_notify(QString, bool)), this, SLOT(panelwidget_notify_bool(QString, bool))); +} + +void PanelWidget::panelwidget_notify_string(QString key, QString value) +{ + if (key == "icon-policy") { + QList::Iterator it = powerlist.begin(), itend = powerlist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if (exist) { + exist = false; + battery_combo->setCurrentIndex(index); + } + else + battery_combo->setCurrentIndex(-1); + } +} + +void PanelWidget::panelwidget_notify_bool(QString key, bool value) +{ + if (key == "show-seconds") { + second_switcher->switchedOn = value; + } + else if (key == "show-day") { + week_switcher->switchedOn = value; + } + else if (key == "show-date") { + date_switcher->switchedOn = value; + } + else if (key == "show-time") { + battery_time_switcher->switchedOn = value; + } + else if (key == "show-percentage") { + battery_percentage_switcher->switchedOn = value; + } + else if (key == "show-applications") { + app_switcher->switchedOn = value; + } + else if (key == "show-desktop") { + desktop_switcher->switchedOn = value; + } + else if (key == "show-icon") { + icon_switcher->switchedOn = value; + } + else if (key == "show-places") { + places_switcher->switchedOn = value; + } +} + +void PanelWidget::setTransparencyValue(double value) +{ + sessionproxy->set_panel_transparency_qt(value); +} + +void PanelWidget::setDateFormat(QString selected) { + sessionproxy->set_time_format_qt(selected); +} + +void PanelWidget::setShowBatteryIcon(QString selected) { + sessionproxy->set_power_icon_policy_qt(selected); +} + +void PanelWidget::setRadioButtonRowStatus(/*bool status*/) +{ + QObject *obj = sender(); //返回发出信号的对象,用QObject类型接收 + QRadioButton* pbtn = qobject_cast(obj); + QString obj_name = pbtn->objectName(); + if(obj_name == "smart_radio") + { + sessionproxy->set_dash_blur_experimental_qt(2); + } + else if(obj_name == "static_radio") + { + sessionproxy->set_dash_blur_experimental_qt(1); + } + else if(obj_name == "clear_radio") + { + sessionproxy->set_dash_blur_experimental_qt(0); + } +} + +void PanelWidget::setDisplaySeconds() +{ + sessionproxy->set_show_seconds_qt(second_switcher->switchedOn); +} + +void PanelWidget::setDisplayWeek() +{ + sessionproxy->set_show_week_qt(week_switcher->switchedOn); +} + +void PanelWidget::setDisplayDate() +{ + sessionproxy->set_show_date_qt(date_switcher->switchedOn); +} + +void PanelWidget::setDisplayBatteryPercentage() +{ + sessionproxy->set_show_power_percentage_qt(battery_percentage_switcher->switchedOn); +} + +void PanelWidget::setDisplayBatteryTime() +{ + sessionproxy->set_show_power_time_qt(battery_time_switcher->switchedOn); +} + +void PanelWidget::showApplications() +{ + sessionproxy->set_show_apps_qt(app_switcher->switchedOn); +} + +void PanelWidget::showDesktop() +{ + sessionproxy->set_show_desktop_qt(desktop_switcher->switchedOn); +} + +void PanelWidget::showIcon() +{ + sessionproxy->set_show_icon_qt(icon_switcher->switchedOn); +} + +void PanelWidget::showPlaces() +{ + sessionproxy->set_show_places_qt(places_switcher->switchedOn); +} diff --git a/setting/panelwidget.h b/setting/panelwidget.h new file mode 100644 index 0000000..78ba0a1 --- /dev/null +++ b/setting/panelwidget.h @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PANELWIDGET_H +#define PANELWIDGET_H + +#include +#include "../component/kylinswitcher.h" + +class SessionDispatcher; +class QLabel; +class QPushButton; +class QComboBox; +class QSlider; +class QDoubleSpinBox; +class QRadioButton; + +class PanelWidget : public QWidget +{ + Q_OBJECT +public: + explicit PanelWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0, QString cur_desktop = "", bool has_battery = false); + ~PanelWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + +//signals: +// void showSettingMainWidget(); + +public slots: + void setDateFormat(QString selected); + void setShowBatteryIcon(QString selected); + void setTransparencyValue(double value); + void setRadioButtonRowStatus(/*bool status*/); + void setDisplaySeconds(); + void setDisplayWeek(); + void setDisplayDate(); + void setDisplayBatteryPercentage(); + void setDisplayBatteryTime(); + void showApplications(); + void showDesktop(); + void showIcon(); + void showPlaces(); + + void panelwidget_notify_string(QString key, QString value); + void panelwidget_notify_bool(QString key, bool value); + +private: + SessionDispatcher *sessionproxy; + bool dataOK; + QString desktop; + QStringList powerlist; + QLabel *blur_label; + QLabel *transparency_label; + QLabel *date_format_label; + QLabel *second_label; + QLabel *week_label; + QLabel *date_label; + QLabel *battery_icon_label; + QLabel *battery_percentage_label; + QLabel *battery_time_label; + QLabel *show_app_label; + QLabel *show_desktop_label; + QLabel *show_icon_label; + QLabel *show_places_label; + QRadioButton *smart_radio; + QRadioButton *static_radio; + QRadioButton *clear_radio; + QDoubleSpinBox *transparency_slider; + QComboBox *date_combo; + KylinSwitcher *second_switcher; + KylinSwitcher *week_switcher; + KylinSwitcher *date_switcher; + QComboBox *battery_combo; + KylinSwitcher *battery_percentage_switcher; + KylinSwitcher *battery_time_switcher; + KylinSwitcher *app_switcher; + KylinSwitcher *desktop_switcher; + KylinSwitcher *icon_switcher; + KylinSwitcher *places_switcher; +}; + +#endif // PANELWIDGET_H diff --git a/setting/switchmenu.cpp b/setting/switchmenu.cpp new file mode 100644 index 0000000..28a6e12 --- /dev/null +++ b/setting/switchmenu.cpp @@ -0,0 +1,92 @@ +#include "switchmenu.h" + +#include +#include +#include + +SwitchMenu::SwitchMenu(QWidget *parent) : + QWidget(parent) +{ +// setWindowFlags(Qt::FramelessWindowHint); + + m_bOn = false; + + m_bLBtnDown = false; + + m_pixmapBk.load(":/background/res/on.png"); + m_pixmapFore.load(":/background/res/off.png"); + + setGeometry(0, 0, m_pixmapBk.width(), m_pixmapBk.height()); +} + +void SwitchMenu::paintEvent(QPaintEvent *) +{ + qDebug() << "1111111111"; + QPainter painter(this); + + painter.drawPixmap(QPoint(0,0), m_pixmapBk); + + QPoint ptFore; + if (m_bOn) { + ptFore = rect().topLeft(); + } else { + ptFore = QPoint(this->width() - m_pixmapFore.width(), + this->rect().top()); + } + painter.drawPixmap(ptFore, m_pixmapFore); + + QRect rcOn; + rcOn.setTopLeft(rect().topLeft()); + rcOn.setBottomRight(QPoint(m_pixmapFore.width(), m_pixmapFore.height())); + painter.drawText(rcOn, Qt::AlignCenter, "ON"); + + QRect rcOff; + rcOff.setTopLeft(QPoint(rect().width() - m_pixmapFore.width(), rect().top())); + rcOff.setBottomRight(rect().bottomRight()); + painter.drawText(rcOff, Qt::AlignCenter, "Off"); +} + +void SwitchMenu::mousePressEvent(QMouseEvent *) +{ + qDebug() << "333333333"; + m_bLBtnDown = true; +} + +void SwitchMenu::mouseReleaseEvent(QMouseEvent *e) +{ + qDebug() << "222222222"; + if (m_bLBtnDown) { + m_bOn = !m_bOn; + + m_bLBtnDown = false; + } + + update(); +} + +void SwitchMenu::leaveEvent(QEvent *) +{ +// status = NORMAL; + update(); +} + +void SwitchMenu::enterEvent(QEvent *) +{ +// status = ENTER; + update(); +} + + + + + + + + +//void SystemButton::paintEvent(QPaintEvent *) +//{ +// QPainter painter; +// painter.begin(this); +// painter.drawPixmap(this->rect(), pixmap.copy(btn_width * status, 0, btn_width, btn_height)); +// painter.end(); +//} diff --git a/setting/switchmenu.h b/setting/switchmenu.h new file mode 100644 index 0000000..86f2994 --- /dev/null +++ b/setting/switchmenu.h @@ -0,0 +1,34 @@ +#ifndef SWITCHMENU_H +#define SWITCHMENU_H + +#include + +class SwitchMenu : public QWidget +{ + Q_OBJECT +public: + explicit SwitchMenu(QWidget *parent = 0); + +protected: +// /*virtual */void paintEvent(QPaintEvent *); +// virtual void mousePressEvent(QMouseEvent *); +// virtual void mouseReleaseEvent(QMouseEvent *); +protected: + void enterEvent(QEvent *); + void leaveEvent(QEvent *); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void paintEvent(QPaintEvent *); + +signals: + +public slots: + +private: + QPixmap m_pixmapBk; + QPixmap m_pixmapFore; + bool m_bOn; + bool m_bLBtnDown; +}; + +#endif // SWITCHMENU_H diff --git a/setting/themewidget-org.cpp b/setting/themewidget-org.cpp new file mode 100644 index 0000000..670c5b3 --- /dev/null +++ b/setting/themewidget-org.cpp @@ -0,0 +1,209 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "themewidget.h" +#include +#include +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" + +ThemeWidget::ThemeWidget(QWidget *parent, SessionDispatcher *proxy) : + QWidget(parent), + sessionproxy(proxy) +{ + //创建QListWidget部件 + list_widget = new QListWidget(this); + list_widget->setFocusPolicy(Qt::NoFocus); + //设置QListWidget中的单元项的图片大小 + list_widget->setIconSize(QSize(106, 106)); + list_widget->setResizeMode(QListView::Adjust); + //设置QListWidget的显示模式 + list_widget->setViewMode(QListView::IconMode); + //设置QListWidget中的单元项不可被拖动 + list_widget->setMovement(QListView::Static); + //设置QListWidget中的单元项的间距 + list_widget->setSpacing(26); +// QPalette palette1; +// palette1.setBrush(QPalette::Normal, QPalette::Highlight, Qt::black); +// palette1.setBrush(QPalette::Inactive, QPalette::Highlight, Qt::black); +// list_widget->setPalette(palette1); + + dataOK = false; + current_index = 0; + initIndex = 0; + + using_label = new QLabel(list_widget); + using_label->setFixedSize(20, 20); + using_label->setAutoFillBackground(true); + QPalette palette; +// palette.setBrush(using_label->backgroundRole(), QBrush(QPixmap("://res/using.png"))); + palette.setBrush(QPalette::Background, QBrush(QPixmap("://res/checkbox-press.png"))); + using_label->setPalette(palette); + using_label->show(); +// using_label->move(26, 26); + + // QHBoxLayout *layout = new QHBoxLayout(); + // layout->addWidget(list_widget); + // setLayout(layout); + QGridLayout *layout = new QGridLayout(); + layout->addWidget(list_widget); + setLayout(layout); +} + +bool ThemeWidget::getStatus() +{ + return this->dataOK; +} + +void ThemeWidget::initData() { + QString current_theme = sessionproxy->get_theme_qt(); + /*QStringList */syslist = sessionproxy->get_themes_qt(); + QList::Iterator it = syslist.begin(), itend = syslist.end(); + initIndex = 0; + for(;it != itend; it++,initIndex++) + { + if(*it == current_theme) + break; + } + + for(int i = 0; isetSizeHint(QSize(130,130)); +// pItem->setFlags(Qt::ItemIsSelectable); +// pItem->setBackgroundColor(QColor(0, 0, 255, 127)); +// pItem->setTextColor(QColor(0, 0, 255, 127));//0629 + list_widget->insertItem(i, pItem); + +// QListWidgetItem *pItem = new QListWidgetItem(QIcon(pixmap.scaled(QSize(106,106))), tr("%1").arg(syslist[i]), list_widget); +// QWidget *wContainer = new QWidget(list_widget); +//// wContainer->setStyleSheet("QWidget{background:transparent url(://res/menu-big-hover.png);}"); +// wContainer->resize(130, 130); +// QLabel *label = new QLabel(); +// label->setStyleSheet("QLabel{background-image:url('://res/menu-big-hover.png')}"); +// QHBoxLayout *hLayout = new QHBoxLayout(wContainer); +// hLayout->addWidget(label); +// list_widget->setItemWidget(pItem,wContainer); + } + + //set using logo + QListWidgetItem *cur_item = list_widget->item(initIndex); + this->initCurrentTheme(cur_item); + dataOK = true; + this->initConnect(); +} + +ThemeWidget::~ThemeWidget() +{ +} + +void ThemeWidget::initConnect() { + connect(list_widget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(onItemClicked(QListWidgetItem*))); + connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(themewidget_notify_string(QString, QString))); +} + +void ThemeWidget::themewidget_notify_string(QString key, QString value) +{ + if (key == "gtk-theme") + { + QList::Iterator it = syslist.begin(), itend = syslist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if(exist) + { + exist = false; + QListWidgetItem *cur_item = list_widget->item(index); + this->initCurrentTheme(cur_item); + } + } +} + +void ThemeWidget::initCurrentTheme(QListWidgetItem *init_item) +{ + int nRowIndex = list_widget->row(init_item); + QRect rect = list_widget->visualItemRect(init_item); +// QPoint p = rect.topLeft(); +// using_label->move(p.x(), p.y()); + QPoint p = rect.bottomRight(); + using_label->move(p.x()-20, p.y()-40); +// using_label->move(p.x(), p.y()); + //reset current item status + QListWidgetItem *pre_item = list_widget->item(current_index); +// pre_item->setTextColor(QColor(0, 0, 255, 127));//0629 + pre_item->setTextColor(QColor("4f4f4f")); + current_index = nRowIndex; + init_item->setTextColor(QColor("4f4f4f")); +} + +void ThemeWidget::onItemClicked(QListWidgetItem *selected_item) +{ + if(!selected_item) + { + return; + } + sessionproxy->set_theme_qt(selected_item->text()); + + int nRowIndex = list_widget->row(selected_item); + QRect rect = list_widget->visualItemRect(selected_item); +// QPoint p = rect.topLeft(); + QPoint p = rect.bottomRight(); + using_label->move(p.x()-20, p.y()-40); +// p.setX(p.x() + 58); +// p.setY(p.y() + 29); +// using_label->move(p.x(), p.y()); + + //reset current item status + QListWidgetItem *pre_item = list_widget->item(current_index); +// pre_item->setTextColor(QColor(0, 0, 255, 127)); + pre_item->setTextColor(QColor("4f4f4f")); + pre_item->setBackground(Qt::white); + + current_index = nRowIndex; +// item->setBackgroundColor(QColor(0, 0, 255, 127)); + selected_item->setTextColor(QColor("4f4f4f")); +// selected_item->setSizeHint(QSize(130,130)); +} + +void ThemeWidget::paintEvent(QPaintEvent *) +{ + //kobe: if the scrollbar move, the using_label should move the the select item + QListWidgetItem *select_item = list_widget->item(current_index); + QRect rect = list_widget->visualItemRect(select_item); +// QPoint p = rect.topLeft(); +// using_label->move(p.x(), p.y()); + QPoint p = rect.bottomRight(); + using_label->move(p.x()-20, p.y()-40); +} diff --git a/setting/themewidget-org.h b/setting/themewidget-org.h new file mode 100644 index 0000000..5ba8e5b --- /dev/null +++ b/setting/themewidget-org.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef THEMEWIDGET_H +#define THEMEWIDGET_H + +#include + +class SessionDispatcher; +class QLabel; +class QPushButton; +class QListWidget; +class QListWidgetItem; + +class ThemeWidget : public QWidget +{ + Q_OBJECT +public: + explicit ThemeWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0); + ~ThemeWidget(); + void initConnect(); + void initCurrentTheme(QListWidgetItem *init_item); + void initData(); + bool getStatus(); + +protected: + void paintEvent(QPaintEvent *); + +public slots: + void onItemClicked(QListWidgetItem *selected_item); + void themewidget_notify_string(QString key, QString value); + +private: + QListWidget *list_widget; + int current_index; + QLabel *using_label; + SessionDispatcher *sessionproxy; + bool dataOK; + int initIndex; + QStringList syslist; +}; + +#endif // THEMEWIDGET_H diff --git a/setting/themewidget.cpp b/setting/themewidget.cpp new file mode 100644 index 0000000..3a2d3ac --- /dev/null +++ b/setting/themewidget.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "themewidget.h" +#include +#include +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" + +ThemeWidget::ThemeWidget(QWidget *parent, SessionDispatcher *proxy) : + QWidget(parent), + sessionproxy(proxy) +{ + label = new QLabel(this); + label->setObjectName("tipLabel"); + label->setGeometry(QRect(30, 15, 860, 20)); + label->setText(tr("Please choose theme which you need")); + list_widget = NULL; + dataOK = false; +} + +bool ThemeWidget::getStatus() +{ + return this->dataOK; +} + +void ThemeWidget::initData() { +// list_widget = new NormalWidget(150, 150, 20, this); + list_widget = new NormalWidget(119, 139, 20, this); + list_widget->setGeometry(QRect(30, 55, 860, 330)); + list_widget->calculate_data(); + + QString current_theme = sessionproxy->get_theme_qt(); + /*QStringList */syslist = sessionproxy->get_themes_qt(); + card_list.clear(); + QSignalMapper *signal_mapper = new QSignalMapper(this); + for(int i = 0; icardPanel); + card_list.append(card); + if(current_theme == syslist[i]) { + card->showUsingLogo(true); + } + list_widget->add_card(card); + connect(card, SIGNAL(sendSelectThemeName(QString)), signal_mapper, SLOT(map())); + signal_mapper->setMapping(card, QString::number(i, 10)); + connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchUsingLogo(QString))); + connect(card, SIGNAL(sendSelectThemeName(QString)), this, SLOT(changeTheme(QString))); + } + dataOK = true; + this->initConnect(); +} + +ThemeWidget::~ThemeWidget() +{ + for(int i=0; ishowUsingLogo(true); + } + else + { + card->showUsingLogo(false); + } + } +} + +void ThemeWidget::changeTheme(QString name) +{ + sessionproxy->set_theme_qt(name); +} + + +void ThemeWidget::themewidget_notify_string(QString key, QString value) +{ + if (key == "gtk-theme") + { + QList::Iterator it = syslist.begin(), itend = syslist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if(exist) + { + exist = false; + this->switchUsingLogo(QString::number(index, 10)); + } + } +} diff --git a/setting/themewidget.h b/setting/themewidget.h new file mode 100644 index 0000000..c4d2af3 --- /dev/null +++ b/setting/themewidget.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef THEMEWIDGET_H +#define THEMEWIDGET_H + +#include +#include "../component/normalwidget.h" +#include "../component/normalcard.h" + +class SessionDispatcher; +class QLabel; +class QPushButton; +class QListWidget; +class QListWidgetItem; + +class ThemeWidget : public QWidget +{ + Q_OBJECT +public: + explicit ThemeWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0); + ~ThemeWidget(); + void initConnect(); + void initData(); + bool getStatus(); + +public slots: + void themewidget_notify_string(QString key, QString value); + void switchUsingLogo(QString index); + void changeTheme(QString name); + +private: + SessionDispatcher *sessionproxy; + bool dataOK; + QStringList syslist; + NormalWidget *list_widget; + QList card_list; + QLabel *label; +}; + +#endif // THEMEWIDGET_H diff --git a/setting/touchpadwidget.cpp b/setting/touchpadwidget.cpp new file mode 100644 index 0000000..ebf9b68 --- /dev/null +++ b/setting/touchpadwidget.cpp @@ -0,0 +1,390 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "touchpadwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" + +TouchpadWidget::TouchpadWidget(QWidget *parent, SessionDispatcher *proxy, QString cur_desktop) : + QWidget(parent), + sessionproxy(proxy), + desktop(cur_desktop) +{ + dataOK = false; + touchpad_label = new QLabel(); + horizontal_scrolling_label = new QLabel(); + scrollbar_type_label = new QLabel(); + scrolling_mode_label = new QLabel(); + touchpad_switcher = new KylinSwitcher(); + horizontal_scrolling_switcher = new KylinSwitcher(); + features_radio = new QRadioButton(); + features_radio->setFocusPolicy(Qt::NoFocus); +// features_radio->setChecked(true); + features_radio->setObjectName("features_radio"); + standard_radio = new QRadioButton(); + standard_radio->setFocusPolicy(Qt::NoFocus); +// standard_radio->setChecked(false); + standard_radio->setObjectName("standard_radio"); + QButtonGroup *btnGroup1 = new QButtonGroup(); + btnGroup1->addButton(features_radio); + btnGroup1->addButton(standard_radio); + + disable_radio = new QRadioButton(); + disable_radio->setFocusPolicy(Qt::NoFocus); + disable_radio->setObjectName("disable_radio"); + edge_radio = new QRadioButton(); + edge_radio->setFocusPolicy(Qt::NoFocus); +// edge_radio->setChecked(true); + edge_radio->setObjectName("edge_radio"); + two_finger_radio = new QRadioButton(); + two_finger_radio->setFocusPolicy(Qt::NoFocus); +// two_finger_radio->setChecked(false); + two_finger_radio->setObjectName("two_finger_radio"); + QButtonGroup *btnGroup2 = new QButtonGroup(); + btnGroup2->addButton(disable_radio); + btnGroup2->addButton(edge_radio); + btnGroup2->addButton(two_finger_radio); + + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + scrollbar_type_label->hide(); + features_radio->hide(); + standard_radio->hide(); + } + + touchpad_label->setFixedWidth(180); + horizontal_scrolling_label->setFixedWidth(180); + scrollbar_type_label->setFixedWidth(180); + scrolling_mode_label->setFixedWidth(180); + + //kobe1510 + this->release = sessionproxy->get_os_release_qt(); + if(this->release.endsWith("15.10-wily")) { + touchpad_label->hide(); + touchpad_switcher->hide(); + horizontal_scrolling_label->hide(); + horizontal_scrolling_switcher->hide(); + scrollbar_type_label->hide(); + features_radio->hide(); + standard_radio->hide(); + } + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->setSpacing(10); + layout1->addWidget(touchpad_label); + layout1->addWidget(touchpad_switcher); + layout1->addStretch(); + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->setSpacing(10); + layout2->addWidget(horizontal_scrolling_label); + layout2->addWidget(horizontal_scrolling_switcher); + layout2->addStretch(); + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->setSpacing(10); + layout3->addWidget(scrollbar_type_label); + layout3->addWidget(features_radio); + layout3->addWidget(standard_radio); + layout3->addStretch(); + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->setSpacing(10); + layout4->addWidget(scrolling_mode_label); + layout4->addWidget(disable_radio); + layout4->addWidget(edge_radio); + layout4->addWidget(two_finger_radio); + layout4->addStretch(); + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(layout1); + layout->addLayout(layout2); + layout->addLayout(layout3); + layout->addLayout(layout4); + layout->addStretch(); + setLayout(layout); + layout->setSpacing(10); + layout->setContentsMargins(20, 20, 0, 0); + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + + +// QHBoxLayout *main_layout = new QHBoxLayout; +// main_layout->addStretch(); +// main_layout->addWidget(splitter); +// main_layout->setSpacing(0); +// main_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(main_layout); +// this->initData(); + this->setLanguage(); +} + +TouchpadWidget::~TouchpadWidget() +{ + if (touchpad_label != NULL) { + delete touchpad_label; + touchpad_label = NULL; + } + if (horizontal_scrolling_label != NULL) { + delete horizontal_scrolling_label; + horizontal_scrolling_label = NULL; + } + if (scrollbar_type_label != NULL) { + delete scrollbar_type_label; + scrollbar_type_label = NULL; + } + if (scrolling_mode_label != NULL) { + delete scrolling_mode_label; + scrolling_mode_label = NULL; + } + if (touchpad_switcher != NULL) { + delete touchpad_switcher; + touchpad_switcher = NULL; + } + if (horizontal_scrolling_switcher != NULL) { + delete horizontal_scrolling_switcher; + horizontal_scrolling_switcher = NULL; + } + if (features_radio != NULL) { + delete features_radio; + features_radio = NULL; + } + if (standard_radio != NULL) { + delete standard_radio; + standard_radio = NULL; + } + if (disable_radio != NULL) { + delete disable_radio; + disable_radio = NULL; + } + if (edge_radio != NULL) { + delete edge_radio; + edge_radio = NULL; + } + if (two_finger_radio != NULL) { + delete two_finger_radio; + two_finger_radio = NULL; + } +} + +void TouchpadWidget::setLanguage() { +// title_label->setText(tr("Touchpad settings")); +// description_label->setText(tr("Setting the relevant properties of your touchpad,make the operation more convenient.")); +// back_btn->setText(tr("Back")); + touchpad_label->setText(tr("Enable touchpad") + ":"); + horizontal_scrolling_label->setText(tr("Enable horizontal scrolling") + ":"); + scrollbar_type_label->setText(tr("Scrollbar type") + ":"); + scrolling_mode_label->setText(tr("Touchpad scrolling mode") + ":");//触摸板滚动模式 + features_radio->setText(tr("Features Type")); + standard_radio->setText(tr("Standard Type")); + disable_radio->setText(tr("Disabled"));//禁用 + edge_radio->setText(tr("Edge Scrolling"));//边界滚动 + two_finger_radio->setText(tr("Two-finger Scrolling"));//双指滚动 +} + +bool TouchpadWidget::getStatus() +{ + return this->dataOK; +} + +void TouchpadWidget::initData() +{ + //kobe1510 + if(!this->release.endsWith("15.10-wily")) { + touchpad_switcher->switchedOn = sessionproxy->get_touchpad_enable_qt(); + horizontal_scrolling_switcher->switchedOn = sessionproxy->get_touchscrolling_use_horizontal_qt(); + QString mode_value = sessionproxy->get_scrollbars_mode_qt(); + if(mode_value == "overlay-auto") { + features_radio->setChecked(true); + standard_radio->setChecked(false); + } + else if(mode_value == "normal") { + standard_radio->setChecked(true); + features_radio->setChecked(false); + } + } + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") + { + int scroll_value = sessionproxy->get_mate_touchscrolling_mode_qt(); + if(scroll_value == 0) { + disable_radio->setChecked(true); + edge_radio->setChecked(false); + two_finger_radio->setChecked(false); + } + else if(scroll_value == 1) { + edge_radio->setChecked(true); + disable_radio->setChecked(false); + two_finger_radio->setChecked(false); + } + else if(scroll_value == 2) { + two_finger_radio->setChecked(true); + disable_radio->setChecked(false); + edge_radio->setChecked(false); + } + } + else + { + QString scroll_value = sessionproxy->get_touchscrolling_mode_qt(); + if(scroll_value == "disabled") { + disable_radio->setChecked(true); + edge_radio->setChecked(false); + two_finger_radio->setChecked(false); + } + else if(scroll_value == "edge-scrolling") { + edge_radio->setChecked(true); + disable_radio->setChecked(false); + two_finger_radio->setChecked(false); + } + else if(scroll_value == "two-finger-scrolling") { + two_finger_radio->setChecked(true); + disable_radio->setChecked(false); + edge_radio->setChecked(false); + } + } + dataOK = true; + this->initConnect(); +} + +void TouchpadWidget::initConnect() { +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + connect(touchpad_switcher, SIGNAL(clicked()), this, SLOT(setTouchpad())); + connect(horizontal_scrolling_switcher, SIGNAL(clicked()), this, SLOT(setHorizontalScrolling())); + connect(features_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/))); + connect(standard_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/))); + connect(disable_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/))); + connect(edge_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/))); + connect(two_finger_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/))); + + connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(touchpadwidget_notify_string(QString, QString))); + connect(sessionproxy, SIGNAL(bool_value_notify(QString, bool)), this, SLOT(touchpadwidget_notify_bool(QString, bool))); + connect(sessionproxy, SIGNAL(int_value_notify(QString, int)), this, SLOT(touchpadwidget_notify_int(QString, int))); +} + +void TouchpadWidget::touchpadwidget_notify_string(QString key, QString value) +{ + if (key == "scroll-method") { + if(value == "disabled") { + disable_radio->setChecked(true); + edge_radio->setChecked(false); + two_finger_radio->setChecked(false); + } + else if(value == "edge-scrolling") { + edge_radio->setChecked(true); + disable_radio->setChecked(false); + two_finger_radio->setChecked(false); + } + else if(value == "two-finger-scrolling") { + two_finger_radio->setChecked(true); + disable_radio->setChecked(false); + edge_radio->setChecked(false); + } + } + else if (key == "scrollbar-mode") { + if(value == "overlay-auto") { + features_radio->setChecked(true); + standard_radio->setChecked(false); + } + else if(value == "normal") { + standard_radio->setChecked(true); + features_radio->setChecked(false); + } + } +} + +void TouchpadWidget::touchpadwidget_notify_bool(QString key, bool value) +{ + if (key == "touchpad-enabled") { + touchpad_switcher->switchedOn = value; + } + else if (key == "horiz-scroll-enabled") { + horizontal_scrolling_switcher->switchedOn = value; + } +} + +void TouchpadWidget::touchpadwidget_notify_int(QString key, int value) +{ + if (key == "scroll-method") { + if(value == 0) { + disable_radio->setChecked(true); + edge_radio->setChecked(false); + two_finger_radio->setChecked(false); + } + else if(value == 1) { + edge_radio->setChecked(true); + disable_radio->setChecked(false); + two_finger_radio->setChecked(false); + } + else if(value == 2) { + two_finger_radio->setChecked(true); + disable_radio->setChecked(false); + edge_radio->setChecked(false); + } + } +} + +void TouchpadWidget::setTouchpad() +{ + sessionproxy->set_touchpad_enable_qt(touchpad_switcher->switchedOn); +} + +void TouchpadWidget::setHorizontalScrolling() +{ + sessionproxy->set_touchscrolling_use_horizontal_qt(horizontal_scrolling_switcher->switchedOn); +} + +void TouchpadWidget::setRadioButtonRowStatus(/*bool status*/) +{ + QObject *obj = sender(); //返回发出信号的对象,用QObject类型接收 + QRadioButton* pbtn = qobject_cast(obj); + QString obj_name = pbtn->objectName(); + if(obj_name == "features_radio") + { + sessionproxy->set_scrollbars_mode_overlay_qt(); + } + else if(obj_name == "standard_radio") + { + sessionproxy->set_scrollbars_mode_legacy_qt(); + } + else if(obj_name == "disable_radio") + { + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") + sessionproxy->set_mate_touchscrolling_mode_qt(0); + else { + sessionproxy->set_touchscrolling_mode_disabled_qt(); + } + } + else if(obj_name == "edge_radio") + { + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") + sessionproxy->set_mate_touchscrolling_mode_qt(1); + else { + sessionproxy->set_touchscrolling_mode_edge_qt(); + } + } + else if(obj_name == "two_finger_radio") + { + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") + sessionproxy->set_mate_touchscrolling_mode_qt(2); + else { + sessionproxy->set_touchscrolling_mode_twofinger_qt(); + } + } +} diff --git a/setting/touchpadwidget.h b/setting/touchpadwidget.h new file mode 100644 index 0000000..1494a12 --- /dev/null +++ b/setting/touchpadwidget.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef TOUCHPADWIDGET_H +#define TOUCHPADWIDGET_H + +#include +#include "../component/kylinswitcher.h" + +class SessionDispatcher; +class QLabel; +class QPushButton; +class QRadioButton; + +class TouchpadWidget : public QWidget +{ + Q_OBJECT +public: + explicit TouchpadWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0, QString cur_desktop = ""); + ~TouchpadWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + +public slots: + void setRadioButtonRowStatus(/*bool status*/); + void setTouchpad(); + void setHorizontalScrolling(); + + void touchpadwidget_notify_string(QString key, QString value); + void touchpadwidget_notify_bool(QString key, bool value); + void touchpadwidget_notify_int(QString key, int value); + +private: + SessionDispatcher *sessionproxy; + bool dataOK; + QLabel *touchpad_label; + QLabel *horizontal_scrolling_label; + QLabel *scrollbar_type_label; + QLabel *scrolling_mode_label; + KylinSwitcher *touchpad_switcher; + KylinSwitcher *horizontal_scrolling_switcher; + QRadioButton *features_radio; + QRadioButton *standard_radio; + QRadioButton *disable_radio; + QRadioButton *edge_radio; + QRadioButton *two_finger_radio; + QString desktop; + QString release; +}; + +#endif // TOUCHPADWIDGET_H diff --git a/setting/voicewidget.cpp b/setting/voicewidget.cpp new file mode 100644 index 0000000..b9c4acb --- /dev/null +++ b/setting/voicewidget.cpp @@ -0,0 +1,234 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "voicewidget.h" +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" +#include "../dbusproxy/youkersystemdbus.h" + +VoiceWidget::VoiceWidget(QWidget *parent, SessionDispatcher *proxy , SystemDispatcher *sproxy, QString cur_desktop) : + QWidget(parent),desktop(cur_desktop), + sessionproxy(proxy), + systemproxy(sproxy) +{ + dataOK = false; + theme_label = new QLabel(); + tip_label = new QLabel(); + event_label = new QLabel(); + feedback_label = new QLabel(); + theme_combo = new QComboBox(); + tip_switcher = new KylinSwitcher(); + event_switcher = new KylinSwitcher(); + feedback_switcher = new KylinSwitcher(); + + theme_label->setFixedWidth(180); + tip_label->setFixedWidth(180); + event_label->setFixedWidth(180); + feedback_label->setFixedWidth(180); + + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") + { + tip_label->hide(); + tip_switcher->hide(); + } + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->setSpacing(10); + layout1->addWidget(theme_label); + layout1->addWidget(theme_combo); + layout1->addStretch(); + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->setSpacing(10); + layout2->addWidget(tip_label); + layout2->addWidget(tip_switcher); + layout2->addStretch(); + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->setSpacing(10); + layout3->addWidget(event_label); + layout3->addWidget(event_switcher); + layout3->addStretch(); + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->setSpacing(10); + layout4->addWidget(feedback_label); + layout4->addWidget(feedback_switcher); + layout4->addStretch(); + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(layout1); + layout->addLayout(layout2); + layout->addLayout(layout3); + layout->addLayout(layout4); + layout->addStretch(); + setLayout(layout); + layout->setSpacing(10); + layout->setContentsMargins(20, 20, 0, 0); + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + +// QHBoxLayout *main_layout = new QHBoxLayout; +// main_layout->addStretch(); +// main_layout->addWidget(splitter); +// main_layout->setSpacing(0); +// main_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(main_layout); +// this->initData(); + this->setLanguage(); +} + +VoiceWidget::~VoiceWidget() +{ + if (theme_label != NULL) { + delete theme_label; + theme_label = NULL; + } + if (tip_label != NULL) { + delete tip_label; + tip_label = NULL; + } + if (event_label != NULL) { + delete event_label; + event_label = NULL; + } + if (feedback_label != NULL) { + delete feedback_label; + feedback_label = NULL; + } + if (theme_combo != NULL) { + delete theme_combo; + theme_combo = NULL; + } + if (tip_switcher != NULL) { + delete tip_switcher; + tip_switcher = NULL; + } + if (event_switcher != NULL) { + delete event_switcher; + event_switcher = NULL; + } + if (feedback_switcher != NULL) { + delete feedback_switcher; + feedback_switcher = NULL; + } +} + +void VoiceWidget::setLanguage() { +// title_label->setText(tr("Sound effect")); +// description_label->setText(tr("Set the sound theme you want.")); +// back_btn->setText(tr("Back")); + theme_label->setText(tr("Sound theme") + ":"); + tip_label->setText(tr("Login tone") + ":"); + event_label->setText(tr("Event sounds") + ":"); + feedback_label->setText(tr("Input feedback sounds") + ":"); + +} + +bool VoiceWidget::getStatus() +{ + return this->dataOK; +} + +void VoiceWidget::initData() +{ + QString current_sound = sessionproxy->get_sound_theme_qt(); + /*QStringList */soundlist = systemproxy->get_sound_themes_qt(); + theme_combo->clear(); + theme_combo->clearEditText(); + theme_combo->addItems(soundlist); + + QList::Iterator it = soundlist.begin(), itend = soundlist.end(); + int initIndex = 0; + for(;it != itend; it++,initIndex++) + { + if(*it == current_sound) + break; + } + theme_combo->setCurrentIndex(initIndex); + + if (desktop != "mate" && desktop != "MATE") + { + tip_switcher->switchedOn = sessionproxy->get_login_music_enable_qt(); + } + + event_switcher->switchedOn = sessionproxy->get_sound_event_enable_qt(); + feedback_switcher->switchedOn = sessionproxy->get_input_feedback_sounds_enable_qt(); + dataOK = true; + this->initConnect(); +} + +void VoiceWidget::initConnect() { +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + connect(theme_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setVoiceTheme(QString))); + connect(tip_switcher, SIGNAL(clicked()), this, SLOT(setLoginTipVoice())); + connect(event_switcher, SIGNAL(clicked()), this, SLOT(setEventVoice())); + connect(feedback_switcher, SIGNAL(clicked()), this, SLOT(setInputFeedbackVoice())); + + connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(voicewidget_notify_string(QString, QString))); + connect(sessionproxy, SIGNAL(bool_value_notify(QString, bool)), this, SLOT(voicewidget_notify_bool(QString, bool))); +} + +void VoiceWidget::voicewidget_notify_string(QString key, QString value) +{ + if (key == "theme-name") { + QList::Iterator it = soundlist.begin(), itend = soundlist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if (exist) { + exist = false; + theme_combo->setCurrentIndex(index); + } + else + theme_combo->setCurrentIndex(-1); + } +} + +void VoiceWidget::voicewidget_notify_bool(QString key, bool value) +{ + if (key == "event-sounds") { + event_switcher->switchedOn = value; + } + else if (key == "input-feedback-sounds") { + feedback_switcher->switchedOn = value; + } +} + +void VoiceWidget::setVoiceTheme(QString selectTheme) { + sessionproxy->set_sound_theme_qt(selectTheme); +} + +void VoiceWidget::setLoginTipVoice() { + sessionproxy->set_login_music_enable_qt(tip_switcher->switchedOn); +} + +void VoiceWidget::setEventVoice() { + sessionproxy->set_sound_event_enable_qt(event_switcher->switchedOn); +} + +void VoiceWidget::setInputFeedbackVoice() { + sessionproxy->set_input_feedback_sounds_enable_qt(feedback_switcher->switchedOn); +} diff --git a/setting/voicewidget.h b/setting/voicewidget.h new file mode 100644 index 0000000..b27a27c --- /dev/null +++ b/setting/voicewidget.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef VOICEWIDGET_H +#define VOICEWIDGET_H + +#include +#include "../component/kylinswitcher.h" + +class SessionDispatcher; +class SystemDispatcher; +class QLabel; +class QPushButton; +class QComboBox; + +class VoiceWidget : public QWidget +{ + Q_OBJECT +public: + explicit VoiceWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0, SystemDispatcher *sproxy = 0, QString cur_desktop = ""); + ~VoiceWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + +public slots: + void setVoiceTheme(QString selectTheme); + void setLoginTipVoice(); + void setEventVoice(); + void setInputFeedbackVoice(); + void voicewidget_notify_string(QString key, QString value); + void voicewidget_notify_bool(QString key, bool value); + +private: + SessionDispatcher *sessionproxy; + SystemDispatcher *systemproxy; + bool dataOK; + QString desktop; + QStringList soundlist; + QLabel *theme_label; + QLabel *tip_label; + QLabel *event_label; + QLabel *feedback_label; + QComboBox *theme_combo; + KylinSwitcher *tip_switcher; + KylinSwitcher *event_switcher; + KylinSwitcher *feedback_switcher; +}; + +#endif // VOICEWIDGET_H diff --git a/setting/windowwidget.cpp b/setting/windowwidget.cpp new file mode 100644 index 0000000..97a5757 --- /dev/null +++ b/setting/windowwidget.cpp @@ -0,0 +1,434 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "windowwidget.h" +#include +#include +#include +#include +#include "../dbusproxy/youkersessiondbus.h" +#include + +WindowWidget::WindowWidget(QWidget *parent, SessionDispatcher *proxy, QString cur_desktop) : + QWidget(parent),desktop(cur_desktop), + sessionproxy(proxy) +{ + dataOK = false; + icon_label = new QLabel(); + wheel_label = new QLabel(); + double_click_label = new QLabel(); + middle_click_label = new QLabel(); + right_click_label = new QLabel(); + icon_switcher = new KylinSwitcher(); + wheel_combo = new QComboBox(); + double_click_combo = new QComboBox(); + middle_click_combo = new QComboBox(); + right_click_combo = new QComboBox(); + position_label = new QLabel(); + left_radio = new QRadioButton(); + right_radio = new QRadioButton(); + left_radio->setFocusPolicy(Qt::NoFocus); + left_radio->setObjectName("leftradio"); + right_radio->setFocusPolicy(Qt::NoFocus); + right_radio->setObjectName("rightradio"); + + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + icon_label->hide(); + icon_switcher->hide(); + } + else { + position_label->hide(); + left_radio->hide(); + right_radio->hide(); + } + + position_label->setFixedWidth(220); + icon_label->setFixedWidth(220); + wheel_label->setFixedWidth(220); + double_click_label->setFixedWidth(220); + middle_click_label->setFixedWidth(220); + right_click_label->setFixedWidth(220); + + QHBoxLayout *layout0 = new QHBoxLayout(); + layout0->setSpacing(10); + layout0->addWidget(position_label); + layout0->addWidget(left_radio); + layout0->addWidget(right_radio); + layout0->addStretch(); + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->setSpacing(10); + layout1->addWidget(icon_label); + layout1->addWidget(icon_switcher); + layout1->addStretch(); + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->setSpacing(10); + layout2->addWidget(wheel_label); + layout2->addWidget(wheel_combo); + layout2->addStretch(); + QHBoxLayout *layout3 = new QHBoxLayout(); + layout3->setSpacing(10); + layout3->addWidget(double_click_label); + layout3->addWidget(double_click_combo); + layout3->addStretch(); + QHBoxLayout *layout4 = new QHBoxLayout(); + layout4->setSpacing(10); + layout4->addWidget(middle_click_label); + layout4->addWidget(middle_click_combo); + layout4->addStretch(); + QHBoxLayout *layout5 = new QHBoxLayout(); + layout5->setSpacing(10); + layout5->addWidget(right_click_label); + layout5->addWidget(right_click_combo); + layout5->addStretch(); + QVBoxLayout *layout = new QVBoxLayout(); + layout->addLayout(layout0); + layout->addLayout(layout1); + layout->addLayout(layout2); + layout->addLayout(layout3); + layout->addLayout(layout4); + layout->addLayout(layout5); + layout->addStretch(); + setLayout(layout); + layout->setSpacing(10); + layout->setContentsMargins(20, 20, 0, 0); + +// splitter->addWidget(top_widget); +// splitter->addWidget(bottom_widget); + +// QHBoxLayout *main_layout = new QHBoxLayout; +// main_layout->addStretch(); +// main_layout->addWidget(splitter); +// main_layout->setSpacing(0); +// main_layout->setContentsMargins(0, 0, 0, 0); +// setLayout(main_layout); +// this->initData(); + this->setLanguage(); +} + +WindowWidget::~WindowWidget() +{ + if (icon_label != NULL) { + delete icon_label; + icon_label = NULL; + } + if (wheel_label != NULL) { + delete wheel_label; + wheel_label = NULL; + } + if (double_click_label != NULL) { + delete double_click_label; + double_click_label = NULL; + } + if (middle_click_label != NULL) { + delete middle_click_label; + middle_click_label = NULL; + } + if (right_click_label != NULL) { + delete right_click_label; + right_click_label = NULL; + } + if (icon_switcher != NULL) { + delete icon_switcher; + icon_switcher = NULL; + } + if (wheel_combo != NULL) { + delete wheel_combo; + wheel_combo = NULL; + } + if (double_click_combo != NULL) { + delete double_click_combo; + double_click_combo = NULL; + } + if (middle_click_combo != NULL) { + delete middle_click_combo; + middle_click_combo = NULL; + } + if (right_click_combo != NULL) { + delete right_click_combo; + right_click_combo = NULL; + } + if (position_label != NULL) { + delete position_label; + position_label = NULL; + } + if (left_radio != NULL) { + delete left_radio; + left_radio = NULL; + } + if (right_radio != NULL) { + delete right_radio; + right_radio = NULL; + } +} + +void WindowWidget::setLanguage() { +// title_label->setText(tr("Window")); +// description_label->setText(tr("Window Manager settings.")); +// back_btn->setText(tr("Back")); + position_label->setText(tr("Arrangement of buttons on the titlebar") + ":");//标题栏按钮布局 + icon_label->setText(tr("Menu with icons") + ":"); + wheel_label->setText(tr("Titlebar mouse wheel action") + ":"); + double_click_label->setText(tr("Titlebar double-click action") + ":"); + middle_click_label->setText(tr("Titlebar middle-click action") + ":"); + right_click_label->setText(tr("Titlebar right-click action") + ":"); + left_radio->setText(tr("Left")); + right_radio->setText(tr("Right")); +} + +bool WindowWidget::getStatus() +{ + return this->dataOK; +} + +void WindowWidget::initData() +{ + if (this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") { + QString current_value = sessionproxy->get_window_button_align_qt(); + if(current_value == "left") { + left_radio->setChecked(true); + right_radio->setChecked(false); + } + else if(current_value == "right") { + right_radio->setChecked(true); + left_radio->setChecked(false); + } + } + else { + icon_switcher->switchedOn = sessionproxy->get_menus_have_icons_qt(); + } + + QString current_wheel_type = sessionproxy->get_current_titlebar_wheel_qt(); + //FT arm has no org.compiz.gwd.mouse-wheel-action, so is empty + if (current_wheel_type.isEmpty()) + { + wheel_label->hide(); + wheel_combo->hide(); + } + + /*QStringList */wheellist = sessionproxy->get_titlebar_wheel_qt(); + wheel_combo->clear(); + wheel_combo->clearEditText(); + wheel_combo->addItems(wheellist); + QList::Iterator it1 = wheellist.begin(), itend1 = wheellist.end(); + int initIndex1 = 0; + for(;it1 != itend1; it1++,initIndex1++) + { + if(*it1 == current_wheel_type) + break; + } + wheel_combo->setCurrentIndex(initIndex1); + + QString current_double_type = sessionproxy->get_current_titlebar_double_qt(); + /*QStringList */titlebar_options = sessionproxy->get_titlebar_options_qt(); + double_click_combo->clear(); + double_click_combo->clearEditText(); + double_click_combo->addItems(titlebar_options); + QList::Iterator it2 = titlebar_options.begin(), itend2 = titlebar_options.end(); + int initIndex2 = 0; + for(;it2 != itend2; it2++,initIndex2++) + { + if(*it2 == current_double_type) + break; + } + double_click_combo->setCurrentIndex(initIndex2); + + QString current_middle_type = sessionproxy->get_current_titlebar_middle_qt(); +// QStringList middlelist = sessionproxy->get_titlebar_middle_qt(); + middle_click_combo->clear(); + middle_click_combo->clearEditText(); + middle_click_combo->addItems(titlebar_options); + QList::Iterator it3 = titlebar_options.begin(), itend3 = titlebar_options.end(); + int initIndex3 = 0; + for(;it3 != itend3; it3++,initIndex3++) + { + if(*it3 == current_middle_type) + break; + } + middle_click_combo->setCurrentIndex(initIndex3); + + QString current_right_type = sessionproxy->get_current_titlebar_right_qt(); +// QStringList rightlist = sessionproxy->get_titlebar_right_qt(); + right_click_combo->clear(); + right_click_combo->clearEditText(); + right_click_combo->addItems(titlebar_options); + QList::Iterator it4 = titlebar_options.begin(), itend4 = titlebar_options.end(); + int initIndex4 = 0; + for(;it4 != itend4; it4++,initIndex4++) + { + if(*it4 == current_right_type) + break; + } + right_click_combo->setCurrentIndex(initIndex4); + dataOK = true; + this->initConnect(); +} + +void WindowWidget::initConnect() { +// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget())); + connect(left_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + connect(right_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus())); + connect(icon_switcher, SIGNAL(clicked()), this, SLOT(setMenuIcon())); + connect(wheel_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setMouseWheel(QString))); + connect(double_click_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setMouseDoubleClick(QString))); + connect(middle_click_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setMouseMiddleClick(QString))); + connect(right_click_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setMouseRightClick(QString))); + + connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(windowwidget_notify_string(QString, QString))); + connect(sessionproxy, SIGNAL(bool_value_notify(QString, bool)), this, SLOT(windowwidget_notify_bool(QString, bool))); +} + +void WindowWidget::windowwidget_notify_string(QString key, QString value) +{ + if (key == "button-layout") { + if (value == "close,maximize,minimize:menu" || value == "close,minimize,maximize:menu" || value == "close,minimize,maximize:" || value == "close,maximize,minimize:") + { + left_radio->setChecked(true); + right_radio->setChecked(false); + } + else if (value == "menu:minimize,maximize,close" || value == "menu:maximize,minimize,close" || value == ":minimize,maximize,close" || value == ":maximize,minimize,close") + { + right_radio->setChecked(true); + left_radio->setChecked(false); + } + } + else if (key == "mouse-wheel-action") { + QList::Iterator it = wheellist.begin(), itend = wheellist.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if (exist) { + exist = false; + wheel_combo->setCurrentIndex(index); + } + else + wheel_combo->setCurrentIndex(-1); + } + else if (key == "action-double-click-titlebar") { + QList::Iterator it = titlebar_options.begin(), itend = titlebar_options.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if (exist) { + exist = false; + double_click_combo->setCurrentIndex(index); + } + else + double_click_combo->setCurrentIndex(-1); + } + else if (key == "action-middle-click-titlebar") { + QList::Iterator it = titlebar_options.begin(), itend = titlebar_options.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if (exist) { + exist = false; + middle_click_combo->setCurrentIndex(index); + } + else + middle_click_combo->setCurrentIndex(-1); + } + else if (key == "action-right-click-titlebar") { + QList::Iterator it = titlebar_options.begin(), itend = titlebar_options.end(); + int index = -1; + bool exist = false; + for(;it != itend; it++) + { + ++index; + if(*it == value) { + exist = true; + break; + } + } + if (exist) { + exist = false; + right_click_combo->setCurrentIndex(index); + } + else + right_click_combo->setCurrentIndex(-1); + } +} + +void WindowWidget::windowwidget_notify_bool(QString key, bool value) +{ + if (key == "menus-have-icons") { + icon_switcher->switchedOn = value; + } +} + +void WindowWidget::setMenuIcon() +{ + sessionproxy->set_menus_have_icons_qt(icon_switcher->switchedOn); + +} + +void WindowWidget::setMouseWheel(QString selected) +{ + sessionproxy->set_titlebar_wheel_qt(selected); +} + +void WindowWidget::setMouseDoubleClick(QString selected) +{ + sessionproxy->set_titlebar_double_qt(selected); +} + +void WindowWidget::setMouseMiddleClick(QString selected) +{ + sessionproxy->set_titlebar_middle_qt(selected); +} + +void WindowWidget::setMouseRightClick(QString selected) +{ + sessionproxy->set_titlebar_right_qt(selected); +} + +void WindowWidget::setRadioButtonRowStatus() +{ + QObject *obj = sender(); //返回发出信号的对象,用QObject类型接收 + QRadioButton* pbtn = qobject_cast(obj); + QString obj_name = pbtn->objectName(); + if(obj_name == "leftradio") + { + sessionproxy->set_window_button_align_left_qt(); + } + else if(obj_name == "rightradio") + { + sessionproxy->set_window_button_align_right_qt(); + } +} diff --git a/setting/windowwidget.h b/setting/windowwidget.h new file mode 100644 index 0000000..eaed3af --- /dev/null +++ b/setting/windowwidget.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef WINDOWWIDGET_H +#define WINDOWWIDGET_H + +#include +#include "../component/kylinswitcher.h" + +class QLabel; +class QPushButton; +class QComboBox; +class QRadioButton; + +class SessionDispatcher; + +class WindowWidget : public QWidget +{ + Q_OBJECT +public: + explicit WindowWidget(QWidget *parent = 0, SessionDispatcher *proxy = 0, QString cur_desktop = ""); + ~WindowWidget(); + void setLanguage(); + void initConnect(); + void initData(); + bool getStatus(); + +public slots: + void setMenuIcon(); + void setMouseWheel(QString selected); + void setMouseDoubleClick(QString selected); + void setMouseMiddleClick(QString selected); + void setMouseRightClick(QString selected); + void setRadioButtonRowStatus(); + + void windowwidget_notify_string(QString key, QString value); + void windowwidget_notify_bool(QString key, bool value); + +private: + SessionDispatcher *sessionproxy; + bool dataOK; + QString desktop; + QStringList wheellist; + QStringList titlebar_options; + QLabel *icon_label; + QLabel *wheel_label; + QLabel *double_click_label; + QLabel *middle_click_label; + QLabel *right_click_label; + KylinSwitcher *icon_switcher; + QComboBox *wheel_combo; + QComboBox *double_click_combo; + QComboBox *middle_click_combo; + QComboBox *right_click_combo; + QLabel *position_label; + QRadioButton *left_radio; + QRadioButton *right_radio; +}; + +#endif // WINDOWWIDGET_H diff --git a/shredmanager/filewipe.cpp b/shredmanager/filewipe.cpp new file mode 100644 index 0000000..397cc17 --- /dev/null +++ b/shredmanager/filewipe.cpp @@ -0,0 +1,450 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "filewipe.h" + +#ifdef STAT_MACROS_BROKEN +/* just in case, so we don't unlink a directory, + we don't currently handle broken stat macros */ +# define unlink(x) remove(x) +#endif + +#ifndef HAVE_UNLINK +# define unlink(x) remove(x) +#endif + +/* these should be safe for darwin */ +#ifndef PATH_MAX +# define PATH_MAX 1023 +#endif +#ifndef NAME_MAX +# define NAME_MAX 255 +#endif + +#ifndef O_NOFOLLOW +# define O_NOFOLLOW 0 +#endif + +#ifndef O_DSYNC +# define O_DSYNC O_SYNC +#endif + +#if defined HAVE_FSYNC || defined HAVE_FDATASYNC +# define SYNC 0 +#else +# ifdef O_DSYNC +# define SYNC O_DSYNC +# else +# define SYNC O_SYNC +# endif +#endif + +#include + +/* exit codes */ +#define SUCCESS 0 +#define FAILED -1 +#define NOT_SUPPORT_TYPE -2 +#define PATH_NAME_TOO_LONG -3 +#define STAT_FAILED -4 +#define WIPE_WRITE_FAILED -5 + +static int verbose = 0; + +#ifndef __DEBUG +#define fprintf(e, fmt...) +#endif + +struct file_info +{ + char path_name[PATH_MAX+1]; + + int fd; + struct stat st; + + char *buf; + size_t buf_size; +}; + +int do_close(const char name[], const int fd) +{ + if (close(fd)) + { + fprintf(stderr, "\r close failed for '%s': %s\n", name, strerror(errno)); + return FAILED; + } + return SUCCESS; +} + +int do_write(const char name[], const int fd, char *buf, size_t count) +{ + int ret; + ssize_t c; + size_t written; + + if (count == 0) + abort(); + + ret = 0; + written = 0; + + while (written < count) + { + c = write(fd, buf, count - written); + + if (c == 0) + abort(); + + if (c > 0) + { + written += c; + buf += c; + } + else + { + if (errno == ENOSPC) + { + --count; + ret = ENOSPC; + } + else if (errno == EAGAIN || errno == EINTR) + continue; + else + { + fprintf(stderr, "\r write failed to '%s': %s\n", name, strerror(errno)); + return FAILED; + } + } + } + + return ret; +} + +int sync_data(const char name[], const int fd) +{ + if (fd == -1) + //abort(); + return FAILED; + +#if !defined (HAVE_FSYNC) || !defined (HAVE_FDATASYNC) + /* + the file will still get written out + file.h will make the file be opened with a sync flag + */ + return SUCCESS; +#endif + +#ifdef HAVE_FDATASYNC + if (fdatasync(fd)) +#endif +#ifdef HAVE_FSYNC + if (fsync(fd)) +#endif + { + fprintf(stderr, "\r cannot synchronize '%s': %s\n", name, strerror(errno)); +#ifdef HAVE_FCNTL + if (fcntl(fd, F_SETFL, O_SYNC) == -1) + { + fprintf(stderr, "\r cannot set synchronis writes '%s': %s\n", name, strerror(errno)); + return FAILED; + } +#endif + } + + return SUCCESS; +} + +int write_pass(struct file_info *info) +{ + off_t i; + +#ifdef HAVE_BZERO + bzero(info->buf, info->buf_size); +#endif + memset(info->buf, 0, info->buf_size); + + for (i = 0; i < info->st.st_size; i += info->buf_size) + { + if (do_write(info->path_name, info->fd, info->buf, info->buf_size)) + return WIPE_WRITE_FAILED; + } + + return sync_data(info->path_name, info->fd); +} + +int zero_data(struct file_info *info) +{ + info->buf_size = 1024*1024;//512 + if ((info->buf = (char *)malloc(info->buf_size)) == NULL) + { + fprintf(stderr, "\r cannot allocate %ld bytes for '%s': %s\n", + (long int)info->buf_size, info->path_name, strerror(errno)); + return FAILED; + } + + if (write_pass(info)) { + free(info->buf); + return FAILED; + } + + free(info->buf); + return SUCCESS; +} + +int wipe_data(struct file_info *info) +{ + if (info->st.st_size == 0) + { + if (verbose) + { + fprintf(stderr, "\r zero length, skipping '%s'\n", info->path_name); + } + /* no need to write anything */ + return SUCCESS; + } + + return zero_data(info); +} + +char rand_safe_char(void) +{ + int i; + + struct timeval tpstart; + gettimeofday(&tpstart,NULL); + srand(tpstart.tv_usec); + + const char nameset[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_+=%@#."; + i = (int) ((float) (sizeof(nameset) - 1.0) * rand() / (RAND_MAX+1.0)); + return nameset[i]; +} + + +void rename_str(char str[], const size_t len) +{ + int i; + + i=0; + while (i <= ((int)len-2)) + str[i++] = rand_safe_char(); + + str[len-1] = 0; +} + +int dir_sync(char dir_name[]) +{ + int dfd; + DIR *dir; + + if ((dir = opendir(dir_name)) == NULL) + { + fprintf(stderr, "\r cannot open directory '%s': %s\n", dir_name, strerror(errno)); + return FAILED; + } + + if ((dfd = dirfd(dir)) < 0) + { + fprintf(stderr, "\r dirfd() failed for '%s': %s\n", dir_name, strerror(errno)); + return FAILED; + } + + sync_data(dir_name, dfd); + + if (closedir(dir)) + { + fprintf(stderr, "\r closedir failed for '%s': %s\n", dir_name, strerror(errno)); + return FAILED; + } + + return SUCCESS; +} + +int rename_file(struct file_info *info) +{ + int i; + size_t len, file_len, path_len; + char base_name[PATH_MAX+1]; + char *base, dest_name[PATH_MAX+1]; + + memset(dest_name, 0, sizeof(dest_name)); + strcpy(dest_name, info->path_name); + + base = strrchr(dest_name, '/'); + + if (base == NULL || base >= (dest_name + sizeof(dest_name))) + base = dest_name; + else + ++base; + + *base = 0x00; + memset(base_name, 0, sizeof(base_name)); + strcpy(base_name, dest_name); + + path_len = strnlen(dest_name, sizeof(dest_name)); + file_len = PATH_MAX - path_len; + + i = 0; + len = 2; + while (!i && len <= file_len) + { + rename_str(base, len++); + i = access(dest_name, F_OK); + } + + if (rename(info->path_name, dest_name) == 0) + { + memset(info->path_name, 0, sizeof(info->path_name)); + strncpy(info->path_name, dest_name, strnlen(dest_name, sizeof(dest_name))); + } + else + { + fprintf(stderr, "\r cannot rename '%s': %s\n", info->path_name, strerror(errno)); + return FAILED; + } + + if (dir_sync(base_name)) + return FAILED; + + return SUCCESS; +} + +int destroy_file(struct file_info *info) +{ + if ((info->fd = open(info->path_name, O_WRONLY | O_NOFOLLOW | SYNC)) < 0) + { + fprintf(stderr, "\r cannot open '%s': %s\n", info->path_name, strerror(errno)); + return FAILED; + } + + if (wipe_data(info) == FAILED) + { + do_close(info->path_name, info->fd); + fprintf(stderr, "\r failed to wipe '%s'\n", info->path_name); + return FAILED; + } + + if (ftruncate(info->fd, 0)) + { + do_close(info->path_name, info->fd); + fprintf(stderr, "\r cannot truncate '%s': %s\n", info->path_name, strerror(errno)); + return FAILED; + } + + do_close(info->path_name, info->fd); + + //Do not care about the return value; + rename_file(info); + + if (unlink(info->path_name)) + { + fprintf(stderr, "\r cannot unlink '%s': %s\n", info->path_name, strerror(errno)); + return FAILED; + } + + return SUCCESS; +} + +int do_file(const char *name) +{ + struct file_info info; + + if (strlen(name) > PATH_MAX) + return PATH_NAME_TOO_LONG; + + memset(info.path_name, 0, sizeof(info.path_name)); + strcpy(info.path_name, name); + + if (lstat(name, &info.st)) + { + fprintf(stderr, "\r cannot stat '%s': %s\n", name, strerror(errno)); + return FAILED; + } + + switch (info.st.st_mode & S_IFMT) + { + /* regular file */ + case S_IFREG: + return destroy_file(&info); + break; + /* block device */ + case S_IFBLK: + //destroy_blkdev(f); + return NOT_SUPPORT_TYPE; + break; + /* char dev */ + case S_IFCHR: + //destroy_file(f); + return NOT_SUPPORT_TYPE; + break; + /* directory */ + case S_IFDIR: + //drill_down(name); + return NOT_SUPPORT_TYPE; + break; + + /* fifo */ + case S_IFIFO: + /* socket */ + case S_IFSOCK: + /* sym link */ + case S_IFLNK: + if (unlink(name)) + { + if (verbose) + { + fprintf(stderr, "\r cannot remove '%s': %s\n", name, strerror(errno)); + } + } + break; + + default: + //abort(); + return NOT_SUPPORT_TYPE; + } + + return NOT_SUPPORT_TYPE; +} + +//#ifdef __DEBUG +//int main(int argc, char **argv) +//{ + /* +// char pwd_path[PATH_MAX+1]; +// memset(pwd_path, 0, sizeof(pwd_path)): +// int count = readlink("/proc/self/exe", pwd_path, PATH_MAX); +// if ( count < 0 || count >= PATH_MAX) +// { +// return -1; +// } +// */ + +// return do_file(argv[1]); +//} +//#endif diff --git a/shredmanager/filewipe.h b/shredmanager/filewipe.h new file mode 100644 index 0000000..34c737b --- /dev/null +++ b/shredmanager/filewipe.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __MAIN_H__ +#define __MAIN_H__ + +//The parameter name should be an absolute path +int do_file(const char *name); + +#endif // __MAIN_H__ diff --git a/shredmanager/shreddialog.cpp b/shredmanager/shreddialog.cpp new file mode 100644 index 0000000..3142954 --- /dev/null +++ b/shredmanager/shreddialog.cpp @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include "shredmanager.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "filewipe.h" + +ShredDialog::ShredDialog(ShredManager *plugin, QDialog *parent) + :QDialog(parent) +{ + setWindowFlags(Qt::FramelessWindowHint); + this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}"); + this->setWindowIcon(QIcon(":/res/youker-assistant.png")); + this->setFixedSize(500, 471); + process_plugin = plugin; + + shredSettings = new QSettings(YOUKER_COMPANY_SETTING, YOUKER_SETTING_FILE_NAME_SETTING); + shredSettings->setIniCodec("UTF-8"); + + title_bar = new KylinTitleBar(); + initTitleBar(); + + toolkits = new Toolkits(0, this->width(), this->height()); + + select_edit = new QLineEdit(); + select_edit->setStyleSheet("QLineEdit{border:1px solid #bebebe;}"); + select_edit->setFixedWidth(400); + select_edit->setReadOnly(true); + select_btn = new KylinEditButton(select_edit); + shred_btn = new QPushButton(); + cacel_btn = new QPushButton(); + shred_btn->setFixedSize(91, 25); + shred_btn->setObjectName("blackButton"); + shred_btn->setFocusPolicy(Qt::NoFocus); + cacel_btn->setFixedSize(91, 25); + cacel_btn->setObjectName("blackButton"); + cacel_btn->setFocusPolicy(Qt::NoFocus); + + QHBoxLayout *layout1 = new QHBoxLayout(); + layout1->addStretch(); + layout1->addWidget(select_edit); + layout1->addStretch(); + + QHBoxLayout *layout2 = new QHBoxLayout(); + layout2->addStretch(); + layout2->addWidget(shred_btn); + layout2->addWidget(cacel_btn); + layout2->addStretch(); + layout2->setMargin(0); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addStretch(); + layout->addLayout(layout1); + layout->addLayout(layout2); + layout->addStretch(); + layout->setSpacing(10); + + QVBoxLayout *main_layout = new QVBoxLayout(); + main_layout->addWidget(title_bar); + main_layout->addLayout(layout); + main_layout->setSpacing(20); + main_layout->setMargin(0); + main_layout->setContentsMargins(0, 0, 0, 0); + setLayout(main_layout); + + this->setLanguage(); + this->initConnect(); +} + +ShredDialog::~ShredDialog() +{ + if (shredSettings != NULL) + { + shredSettings->sync(); + delete shredSettings; + shredSettings = NULL; + } +} + +void ShredDialog::setLanguage() +{ + this->setWindowTitle(tr("Shred Manager")); + select_edit->setText(tr("No select any file which need to be shredded")); + shred_btn->setText(tr("Shred File")); + cacel_btn->setText(tr("Deselect")); +} + +void ShredDialog::initConnect() +{ + connect(select_btn, SIGNAL(clicked()), this, SLOT(onSelectButtonClicked())); + connect(shred_btn, SIGNAL(clicked()), this, SLOT(onShredButtonClicked())); + connect(cacel_btn, SIGNAL(clicked()), this, SLOT(onCacelButtonClicked())); +// connect(title_bar, SIGNAL(showMinDialog()), this, SLOT(onMinButtonClicked())); + connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked())); +} + +void ShredDialog::onCloseButtonClicked() +{ + this->close(); +} + +//void ShredDialog::onMinButtonClicked() +//{ +// this->showMinimized(); +//// this->hide(); +//} + +QString ShredDialog::getCurrrentSkinName() +{ + shredSettings->beginGroup("Background"); + QString skin = shredSettings->value("Path").toString(); + if(skin.isEmpty()) { + skin = ":/background/res/skin/1.png"; + } + else { + QStringList skinlist; + QString path = "/var/lib/youker-assistant-daemon/default/"; + QDir picdir(path); + picdir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + picdir.setSorting(QDir::Size | QDir::Reversed); + QStringList filters; + filters << "*.jpg" << "*.png"; + picdir.setNameFilters(filters); + QFileInfoList list = picdir.entryInfoList(); + if(list.size() < 1) { + skinlist << ":/background/res/skin/1.png" << ":/background/res/skin/2.png" << ":/background/res/skin/3.png" << ":/background/res/skin/4.png"; + } + else { + for (int j = 0; j < list.size(); ++j) { + QFileInfo fileInfo = list.at(j); + skinlist << path + fileInfo.fileName(); + } + skinlist << ":/background/res/skin/1.png" << ":/background/res/skin/2.png" << ":/background/res/skin/3.png" << ":/background/res/skin/4.png"; + } + + QList::Iterator it = skinlist.begin(), itend = skinlist.end(); + bool flag = false; + for(;it != itend; it++) + { + if(*it == skin) { + flag = true; + break; + } + } + if (flag == false) { + skin = skinlist.at(0); + } + } + shredSettings->endGroup(); + shredSettings->sync(); + return skin; +} + +void ShredDialog::initTitleBar() +{ + QString skin = this->getCurrrentSkinName(); + title_bar->setTitleWidth(500); + title_bar->setTitleName(tr("Shred Manager")); +// title_bar->setTitleBackgound(":/background/res/skin/1.png"); + title_bar->setTitleBackgound(skin); +} + +void ShredDialog::resetSkin() +{ + QString skin = this->getCurrrentSkinName(); + title_bar->resetBackground(skin); +} + +//void ShredDialog::onSelecteComboActivated(int index) +//{ +//} + +void ShredDialog::onSelectButtonClicked() +{ +// QString fileName=QFileDialog::getOpenFileName(0, tr("Select file"), QDir::homePath(), tr("All Files(*)")); + + QStringList fileNameList; + QString fileName; + QFileDialog* fd = new QFileDialog(this); +// fd->setStyleSheet("QFileDialog{background-color:blue;}"); + fd->resize(500, 471); + fd->setFilter(tr("Allfile(*)")); +// fd->setFilter( "Allfile(*.*);;mp3file(*.mp3);;wmafile(*.wma);;wavefile(*.wav)"); + fd->setViewMode(QFileDialog::List);//设置浏览模式,有 列表(list) 模式和 详细信息(detail)两种方式 + if (fd->exec() == QDialog::Accepted) + { + fileNameList = fd->selectedFiles(); + fileName = fileNameList[0]; + select_edit->setText(fileName); + } + else + fd->close(); +} + +void ShredDialog::onShredButtonClicked() +{ + if(select_edit->text().length() == 0 || !select_edit->text().contains("/")) + { + toolkits->alertMSG(this->frameGeometry().topLeft().x(), this->frameGeometry().topLeft().y(), tr("Select file!")); + } + else + { + char* ch; + QByteArray ba = select_edit->text().toUtf8(); + ch=ba.data(); + int result = do_file(ch); + if (result == 0) + { + //success + toolkits->alertMSG(this->frameGeometry().topLeft().x(), this->frameGeometry().topLeft().y(), tr("Shred successfully!")); + select_edit->setText(tr("No select any file which need to be shredded")); + } + else + { + //failed + toolkits->alertMSG(this->frameGeometry().topLeft().x(), this->frameGeometry().topLeft().y(), tr("Shred failed!")); + } + } +} + +void ShredDialog::onCacelButtonClicked() +{ + select_edit->setText(tr("No select any file which need to be shredded")); +} + +void ShredDialog::closeEvent(QCloseEvent *event) +{ + event->accept(); +// emit SignalClose(); +} diff --git a/shredmanager/shreddialog.h b/shredmanager/shreddialog.h new file mode 100644 index 0000000..a0bc38b --- /dev/null +++ b/shredmanager/shreddialog.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include "../component/kylineditbutton.h" +#include "../component/kylintitlebar.h" +#include "../component/toolkits.h" +#include "../component/utils.h" + +class QLabel; +class QPushButton; +class QLineEdit; +class QComboBox; +class ShredManager; + +class ShredDialog : public QDialog +{ + Q_OBJECT +public: + ShredDialog(ShredManager *plugin, QDialog *parent = 0); + ~ShredDialog(); + void setLanguage(); + void initConnect(); + void initTitleBar(); + QString getCurrrentSkinName(); + void resetSkin(); + +protected: + void closeEvent(QCloseEvent *event); + +public slots: + void onSelectButtonClicked(); + void onShredButtonClicked(); + void onCacelButtonClicked(); +// void onSelecteComboActivated(int index); + void onCloseButtonClicked(); +// void onMinButtonClicked(); + +private: + ShredManager *process_plugin; + KylinTitleBar *title_bar; + KylinEditButton *select_btn; + QLineEdit *select_edit; + QPushButton *shred_btn; + QPushButton *cacel_btn; + Toolkits *toolkits; + QSettings *shredSettings; +}; diff --git a/shredmanager/shreddialog.ui b/shredmanager/shreddialog.ui new file mode 100644 index 0000000..9e3de64 --- /dev/null +++ b/shredmanager/shreddialog.ui @@ -0,0 +1,25 @@ + + + ShredDialog + + + + 0 + 0 + 745 + 435 + + + + + + + false + + + + + + + + diff --git a/shredmanager/shredmanager.cpp b/shredmanager/shredmanager.cpp new file mode 100644 index 0000000..6775e1d --- /dev/null +++ b/shredmanager/shredmanager.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "shredmanager.h" + +ShredManager::ShredManager(QObject *parent) +:QObject(parent), shred_dialog(this) +{ + +} + +ShredManager::~ShredManager() +{ + +} + +QString ShredManager::getGuid() +{ + return "UBUNTU-KYLIN-SHRED"; +} + + QString ShredManager::getName() +{ + return tr("Shred Manager"); +} + +QString ShredManager::getDescribe() +{ + return tr("Delete files makes it unable to recover");//彻底删除文件使其无法恢复 +} + +QString ShredManager::getPicture() +{ + return "shredder.png"; +} + +void ShredManager::doAction() +{ + int windowWidth = QApplication::desktop()->width(); + int windowHeight = QApplication::desktop()->height(); + shred_dialog.resetSkin(); + shred_dialog.move((windowWidth - 500) / 2,(windowHeight - 471) / 2); + shred_dialog.show(); + shred_dialog.raise(); +} + +Q_EXPORT_PLUGIN2(ShredManager, ShredManager) diff --git a/shredmanager/shredmanager.h b/shredmanager/shredmanager.h new file mode 100644 index 0000000..6aaacf0 --- /dev/null +++ b/shredmanager/shredmanager.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd. + * + * Authors: + * Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com + * + * 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; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include "../component/plugininterface.h" +#include "shreddialog.h" + +//插件入口 +class ShredManager : public QObject , PluginInterface +{ + Q_OBJECT + Q_INTERFACES(PluginInterface) + +public: + ShredManager(QObject* parent = 0); + virtual ~ShredManager(); + +public slots: + +public: + virtual QString getGuid(); + virtual QString getName(); + virtual QString getDescribe(); + virtual QString getPicture(); + virtual void doAction(); + +private: + ShredDialog shred_dialog; +}; diff --git a/shredmanager/shredmanager.pro b/shredmanager/shredmanager.pro new file mode 100644 index 0000000..ca20dac --- /dev/null +++ b/shredmanager/shredmanager.pro @@ -0,0 +1,56 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-01-26T09:16:38 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = shredmanager +TEMPLATE = lib +CONFIG += plugin +INCLUDEPATH += ../shredmanager +DESTDIR = ../libs + +UI_DIR += $$PWD/../tmp/shredmanager/ + +RCC_DIR += $$PWD/../tmp/shredmanager/ + +MOC_DIR += $$PWD/../tmp/shredmanager/ + +OBJECTS_DIR = $$PWD/../obj/shredmanager + +target.source += $$TARGET +target.path = /var/lib/youker-assistant-daemon/libs/ +INSTALLS +=target + +HEADERS += \ + filewipe.h \ + ../component/plugininterface.h \ + shredmanager.h \ + shreddialog.h \ + ../component/toolkits.h \ + ../component/alertdialog.h \ + ../component/utils.h \ + ../component/toolkits.h \ + ../component/kylintitlebar.h \ + ../component/systembutton.h \ + ../component/kylineditbutton.h + +SOURCES += \ + filewipe.cpp \ + shredmanager.cpp \ + shreddialog.cpp \ + ../component/alertdialog.cpp \ + ../component/toolkits.cpp \ + ../component/kylintitlebar.cpp \ + ../component/systembutton.cpp \ + ../component/kylineditbutton.cpp + +FORMS += \ + ../component/alertdialog.ui + +RESOURCES += \ + ../mainui/img.qrc diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..408d0f2 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,30 @@ +name: youker-assistant +version: '2.4.2' +summary: Integrated tool to aid in routine system maintenance tasks +description: | + Youker Assistant is a tool designed to help Ubuntu and Ubuntu Kylin + desktop users manage and maintain many aspects of their working + environment conveniently in a single application, providing a consistent + user experience. + + Features currently included: + * Detecting and displaying general system information + * Unity and Mate user interface customization + * System garbage cleaning + +grade: devel # must be 'stable' to release into candidate/stable channels +confinement: devmode # use 'strict' once you have the right plugs and slots + +apps: + youker-assistant: + command: desktop-launch youker-assistant + desktop: usr/share/applications/youker-assistant.desktop + plugs: [home, unity7, desktop, desktop-legacy] + +parts: + youker-assistant: + plugin: qmake + qt-version: qt4 + source: . + build-packages: [g++, libqt4-dev, libglib2.0-dev] + after: [desktop-qt4] diff --git a/youker-assistant.desktop b/youker-assistant.desktop new file mode 100644 index 0000000..7fd6d17 --- /dev/null +++ b/youker-assistant.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=kylin-assistant +Name[zh_CN]=麒麟助手 +Comment=System Auxiliar Tools +Comment[zh_CN]=系统辅助工具 +Keywords=Settings;Cleaning;Customization +Exec=/usr/bin/youker-assistant %u +Icon=youker-assistant.png +StartupNotify=true +Terminal=false +Type=Application +Categories=GNOME;GTK;System;Viewer; diff --git a/youker-assistant.pro b/youker-assistant.pro new file mode 100644 index 0000000..73c2116 --- /dev/null +++ b/youker-assistant.pro @@ -0,0 +1,13 @@ +TEMPLATE = subdirs +SUBDIRS = \ + mainui \ + shredmanager \ +# processmanager \ + backends + +TRANSLATIONS += \ + mainui/translation/youker-assistant_zh_CN.ts \ + mainui/translation/youker-assistant_es.ts \ + mainui/translation/youker-assistant_de.ts \ + mainui/translation/youker-assistant_fr.ts \ + mainui/translation/youker-assistant_ru.ts