Repository: Iktwo/QuteLauncher
Branch: master
Commit: ddd581b87a1a
Files: 67
Total size: 159.4 KB
Directory structure:
gitextract_61lu3w5h/
├── .gitignore
├── COPYING
├── README.md
├── qute-launcher.pro
└── src/
├── android/
│ ├── AndroidManifest.xml
│ ├── build.gradle
│ ├── full/
│ │ ├── AndroidManifest.xml
│ │ └── com/
│ │ └── iktwo/
│ │ └── qutelauncher/
│ │ └── QuteLauncherFlavored.kt
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── noanalytics/
│ │ └── com/
│ │ └── iktwo/
│ │ └── qutelauncher/
│ │ └── QuteLauncherFlavored.kt
│ ├── res/
│ │ ├── values/
│ │ │ ├── libs.xml
│ │ │ └── screen_data.xml
│ │ ├── values-sw600dp/
│ │ │ └── screen_data.xml
│ │ └── values-v21/
│ │ └── styles.xml
│ └── src/
│ └── com/
│ └── iktwo/
│ └── qutelauncher/
│ ├── Application.kt
│ ├── PackageChangedReceiver.kt
│ └── QuteLauncher.kt
├── deployment.pri
├── qml/
│ ├── IntroView.qml
│ ├── components/
│ │ ├── MenuItem.qml
│ │ ├── PressAndHoldMenu.qml
│ │ ├── RadioButtonStyleDefault.qml
│ │ └── qmldir
│ ├── config/
│ │ ├── Dimensions.qml
│ │ ├── Theme.qml
│ │ └── qmldir
│ ├── debug/
│ │ ├── Debug.qml
│ │ └── qmldir
│ ├── intro/
│ │ ├── IntroEnd.qml
│ │ ├── IntroMain.qml
│ │ ├── IntroScreen.qml
│ │ └── IntroSelection.qml
│ ├── main.qml
│ └── themes/
│ ├── classic/
│ │ ├── ApplicationGrid.qml
│ │ ├── ApplicationGridMenu.qml
│ │ ├── ApplicationTile.qml
│ │ ├── ExpandableItem.qml
│ │ └── ThemeMain.qml
│ └── tiles/
│ ├── ApplicationGrid.qml
│ ├── ApplicationList.qml
│ ├── ApplicationMenu.qml
│ ├── ApplicationSection.qml
│ ├── ColorPicker.qml
│ ├── Configuration.qml
│ ├── SectionNavigator.qml
│ ├── ThemeMain.qml
│ └── qmldir
├── resources.qrc
├── src/
│ ├── application.cpp
│ ├── application.h
│ ├── applicationinfo.cpp
│ ├── applicationinfo.h
│ ├── iconimageprovider.cpp
│ ├── iconimageprovider.h
│ ├── launcher.cpp
│ ├── launcher.h
│ ├── main.cpp
│ ├── packagemanager.cpp
│ ├── packagemanager.h
│ ├── screenvalues.cpp
│ ├── screenvalues.h
│ ├── system.cpp
│ └── system.h
└── src.pro
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
# Qt-es
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
qrc_*.cpp
ui_*.h
Makefile*
*-build-*
# QtCreator
*.autosave
#QtCtreator Qml
*.qmlproject.user
*.qmlproject.user.*
*~
google-services.json
.DS_STORE
.build
.gradle
.idea
gen
gradle.properties
android.iml
build-src*
src/android/gradle.properties
src/android/local.properties
================================================
FILE: COPYING
================================================
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.
================================================
FILE: README.md
================================================
# Qute Launcher

Qute Launcher is and Android Launcher written with Qt, it is in alpha state but it already supports launching applications.
Requires Qt >= 5.5
# Screenshot

# Features
* Application icon retrieval.
* Detect app installation or removal.
# TODO
* Add wallpaper picker.
* Add support for themes.
* Add intro screen to configure theme.
* Add home screens and favorites bar.
* Support icon themes.
* Investigate if it is possible to integrate widgets.
# Analytics
This project uses Firebase Analytics to collect usage data.
# How to compile
In order to build this project you need to use Gradle. There are no Qt/QML dependencies. If you have Qt >= 5.5 for Android open the project with QtCreator or follow this instructions if you don't want to use QtCreator http://doc.qt.io/qt-5/deployment-android.html passing --gradle to the androiddeployqt tool.
================================================
FILE: qute-launcher.pro
================================================
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += \
src
OTHER_FILES += \
README.md
================================================
FILE: src/android/AndroidManifest.xml
================================================
================================================
FILE: src/android/build.gradle
================================================
buildscript {
ext {
kotlin_version = '1.3.0'
gradle_version = '3.3.1'
}
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:$gradle_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61"
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
/**
* Uncomment the following lines and remove minsdk from manifest to sync inside IntelliJ:
*
* String androidBuildToolsVersion = "28.0.3"
* String androidCompileSdkVersion = "28"
* String qt5AndroidDir = ""
*/
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion
defaultConfig {
applicationId "com.iktwo.qutelauncher"
targetSdkVersion 28
}
String APK_NAME = "qutelauncher"
productFlavors {
full {
dimension "analytics"
}
noanalytics {
dimension "analytics"
}
}
flavorDimensions "analytics"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
full {
java.srcDirs = ['full']
manifest.srcFile 'full/AndroidManifest.xml'
}
noanalytics {
java.srcDirs = ['noanalytics']
}
}
lintOptions {
abortOnError false
}
afterEvaluate {
assembleRelease.doLast {
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
output.outputFileName = [APK_NAME, variant.productFlavors[0].name, variant.buildType.name].join("_") + ".apk"
}
variant.assemble.doLast {
variant.outputs.all { output ->
String apk_name = [APK_NAME, variant.productFlavors[0].name, variant.buildType.name].join("_") + ".apk"
if (variant.productFlavors[0].name == "full") {
copy {
from output.outputFile
into file(buildDir.getPath() + "/outputs/apk/")
rename { String fileName ->
fileName.replace(apk_name, "android-build-" + variant.buildType.name + ".apk")
}
}
}
}
}
}
}
================================================
FILE: src/android/full/AndroidManifest.xml
================================================
================================================
FILE: src/android/full/com/iktwo/qutelauncher/QuteLauncherFlavored.kt
================================================
package com.iktwo.qutelauncher
import android.os.Bundle
class QuteLauncherFlavored : QuteLauncher() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
================================================
FILE: src/android/gradle/wrapper/gradle-wrapper.properties
================================================
#Thu Feb 28 21:51:51 PST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
================================================
FILE: src/android/gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: src/android/gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: src/android/noanalytics/com/iktwo/qutelauncher/QuteLauncherFlavored.kt
================================================
package com.iktwo.qutelauncher
class QuteLauncherFlavored : QuteLauncher()
================================================
FILE: src/android/res/values/libs.xml
================================================
- https://download.qt.io/ministro/android/qt5/qt-5.6
================================================
FILE: src/android/res/values/screen_data.xml
================================================
false
================================================
FILE: src/android/res/values-sw600dp/screen_data.xml
================================================
true
================================================
FILE: src/android/res/values-v21/styles.xml
================================================
================================================
FILE: src/android/src/com/iktwo/qutelauncher/Application.kt
================================================
package com.iktwo.qutelauncher
class Application(var name: String, var packageName: String) : Comparable {
override fun compareTo(application: Application): Int {
return this.name.toUpperCase().compareTo(application.name.toUpperCase())
}
}
================================================
FILE: src/android/src/com/iktwo/qutelauncher/PackageChangedReceiver.kt
================================================
package com.iktwo.qutelauncher
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
class PackageChangedReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val packageName = intent.data!!.schemeSpecificPart
if (packageName == null || packageName.isEmpty()) {
return
}
val action = intent.action
if (action == "android.intent.action.PACKAGE_ADDED") {
if (QuteLauncher.isApplaunchable(packageName))
jpackageAdded(QuteLauncher.getApplicationLabel(packageName), packageName, internalQtObject)
} else if (action == "android.intent.action.PACKAGE_REMOVED") {
jpackageRemoved(packageName, internalQtObject)
}
}
companion object {
@JvmStatic
var internalQtObject: Long = 0
@JvmStatic
fun setQtObject(qtObject2: Long) {
internalQtObject = qtObject2
}
@JvmStatic
private external fun jpackageAdded(label: String, packageName: String, qtObject: Long)
@JvmStatic
private external fun jpackageRemoved(packageName: String, qtObject: Long)
}
}
================================================
FILE: src/android/src/com/iktwo/qutelauncher/QuteLauncher.kt
================================================
package com.iktwo.qutelauncher
import android.app.ActivityManager
import android.app.WallpaperManager
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.drawable.AdaptiveIconDrawable
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable
import android.net.ConnectivityManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import java.io.ByteArrayOutputStream
open class QuteLauncher : org.qtproject.qt5.android.bindings.QtActivity() {
init {
instance = this
}
override fun onCreate(savedInstanceState: Bundle?) {
this.QT_ANDROID_DEFAULT_THEME = "AppTheme"
super.onCreate(savedInstanceState)
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
}
override fun onStart() {
super.onStart()
instance = this
val activityManager = instance!!.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
mIconDpi = activityManager.launcherLargeIconDensity
mPm = instance!!.getPackageManager() as PackageManager
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
jnewIntent(qtObject)
}
companion object {
private val TAG = "QuteLauncher"
private var cm: ConnectivityManager? = null
var instance: QuteLauncher? = null
private set
private val wm: WallpaperManager? = null
private var mIconDpi: Int = 0
private var mPm: PackageManager? = null
private var qtObject: Long = 0
fun connectionType(): String {
cm = instance!!.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
val netInfo = cm!!.activeNetworkInfo
return netInfo.typeName
}
fun isApplaunchable(packageName: String): Boolean {
return mPm!!.getLaunchIntentForPackage(packageName) != null
}
val dpi: Int
get() {
val dm = instance!!.getResources().getDisplayMetrics()
return dm.densityDpi
}
@JvmStatic
fun applications(): Array {
val intent = Intent(Intent.ACTION_MAIN, null)
intent.addCategory(Intent.CATEGORY_LAUNCHER)
val availableActivities = mPm!!.queryIntentActivities(intent, 0)
val applications = mutableListOf()
for (i in availableActivities.indices) {
applications.add(Application(availableActivities[i].loadLabel(mPm).toString(), availableActivities[i].activityInfo.packageName))
}
for (i in applications.indices) {
if (applications[i].name.isNotEmpty() && (Character.isSpaceChar(applications[i].name[0]) || Character.isWhitespace(applications[i].name[0]))) {
val charToReplace = applications[i].name[0]
applications[i].name = applications[i].name.replace(charToReplace, ' ').trim { it <= ' ' }
applications[i].name = applications[i].name.trim { it <= ' ' }
}
}
applications.sort()
return applications.toTypedArray()
}
@JvmStatic
fun launchApplication(packageName: String) {
val intent = mPm!!.getLaunchIntentForPackage(packageName)
if (intent != null) {
instance!!.startActivity(intent)
}
}
@JvmStatic
fun getApplicationIcon(packageName: String): ByteArray {
var icon: Drawable?
try {
val app = mPm!!.getApplicationInfo(packageName, 0)
val resources = mPm!!.getResourcesForApplication(app)
val resolveInfo = mPm!!.resolveActivity(mPm!!.getLaunchIntentForPackage(packageName), 0)
icon = resources.getDrawableForDensity(resolveInfo.activityInfo.iconResource, mIconDpi)
} catch (e: Exception) {
Log.e(TAG, "exception getApplicationIcon for $packageName", e)
icon = null
}
if (icon == null)
icon = defaultApplicationIcon
val stream = ByteArrayOutputStream()
var bitmap: Bitmap? = null
if (icon is BitmapDrawable) {
bitmap = icon.bitmap
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (icon is AdaptiveIconDrawable) {
val arrayOfDrawables = arrayOf(icon.background, icon.foreground)
val layerDrawable = LayerDrawable(arrayOfDrawables)
bitmap = Bitmap.createBitmap(layerDrawable.intrinsicWidth, layerDrawable.intrinsicHeight, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
layerDrawable.setBounds(0, 0, canvas.width, canvas.height)
layerDrawable.draw(canvas)
} else {
bitmap = (defaultApplicationIcon as BitmapDrawable).bitmap
}
} else {
bitmap = (defaultApplicationIcon as BitmapDrawable).bitmap
}
}
bitmap?.compress(Bitmap.CompressFormat.PNG, 100, stream)
return stream.toByteArray()
}
val defaultApplicationIcon: Drawable
get() = instance!!.getResources().getDrawable(android.R.mipmap.sym_def_app_icon)
@JvmStatic
fun getApplicationLabel(packageName: String): String {
try {
val app = mPm!!.getApplicationInfo(packageName, 0)
val resources = mPm!!.getResourcesForApplication(app)
val resolveInfo = mPm!!.resolveActivity(mPm!!.getLaunchIntentForPackage(packageName), 0)
return resolveInfo.loadLabel(mPm).toString()
} catch (e: Exception) {
Log.e(TAG, "getApplicationLabel for $packageName", e)
return ""
}
}
fun pickWallpaper() {
val intent = Intent(Intent.ACTION_SET_WALLPAPER)
instance!!.startActivity(Intent.createChooser(intent, "Select Wallpaper"))
}
fun openApplicationInfo(packageName: String) {
val intent = Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.data = Uri.parse("package:$packageName")
instance!!.startActivity(intent)
}
fun setQtObject(qtObject: Long) {
QuteLauncher.qtObject = qtObject
}
@JvmStatic
private external fun jnewIntent(qtObject: Long)
}
}
================================================
FILE: src/deployment.pri
================================================
android-no-sdk {
target.path = /data/user/qt
export(target.path)
INSTALLS += target
} else:android {
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:unix {
isEmpty(target.path) {
qnx {
target.path = /tmp/$${TARGET}/bin
} else {
target.path = /opt/$${TARGET}/bin
}
export(target.path)
}
INSTALLS += target
}
export(INSTALLS)
================================================
FILE: src/qml/IntroView.qml
================================================
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2
import com.iktwo.qutelauncher 1.0 as QL
FocusScope {
id: root
property alias currentIndex: listView.currentIndex
property alias model: listView.model
property alias progress: animationController.progress
property alias enabled: listView.enabled
property alias delegate: listView.delegate
property alias view: listView
property alias buttonsContainerHeight: buttonsContainer.height
property alias rectangleDividerHeight: rectangleDivider.height
property alias dragging: listView.dragging
property int navbarMargin
property int statusbarMargin
readonly property double xPosition: (listView.contentX / listView.width)
readonly property bool movingLeft: listView.movingLeft
signal done
onXPositionChanged: {
if (currentIndex < 0)
return
var result = 0
if (listView.movingLeft)
result = (1 - (xPosition - Math.floor(xPosition))).toFixed(2)
else
result = (xPosition - Math.floor(xPosition)).toFixed(2)
if (listView.movingLeft) {
if (xPosition > 0 && currentIndex > 0 && xPosition < currentIndex) {
propertyAnimationBackground.to = model.get(Math.max(currentIndex - 1, 0)).backgroundColor
propertyAnimationBackground.from = model.get(currentIndex).backgroundColor
} else {
propertyAnimationBackground.to = model.get(currentIndex).backgroundColor
propertyAnimationBackground.from = model.get(Math.min(listView.count - 1, currentIndex + 1)).backgroundColor
}
} else {
if (xPosition < (model.count - 1) && currentIndex < (model.count - 1) && currentIndex < xPosition) {
propertyAnimationBackground.to = model.get(Math.min(listView.count - 1, currentIndex + 1)).backgroundColor
propertyAnimationBackground.from = model.get(currentIndex).backgroundColor
} else {
propertyAnimationBackground.to = model.get(currentIndex).backgroundColor
propertyAnimationBackground.from = model.get(Math.max(currentIndex - 1, 0)).backgroundColor
}
}
if (result == 0) {
rectangleBackground.color = model.get(currentIndex).backgroundColor
propertyAnimationBackground.from = model.get(currentIndex).backgroundColor
} else if (xPosition > 0 && xPosition < (model.count - 1)) {
progress = result
} else if (xPosition < 0) {
progress = 0
rectangleBackground.color = model.get(currentIndex).backgroundColor
}
}
Rectangle {
id: rectangleBackground
anchors.fill: parent
ColorAnimation on color { duration: 325 }
}
ListView {
id: listView
property double previousX
property bool movingLeft
anchors {
top: parent.top
bottom: buttonsContainer.top
left: parent.left
right: parent.right
}
model: model
orientation: ListView.Horizontal
snapMode: ListView.SnapToItem
boundsBehavior: Flickable.StopAtBounds
onContentXChanged: {
if (previousX > contentX)
movingLeft = true
else
movingLeft = false
previousX = contentX
}
highlightRangeMode: ListView.StrictlyEnforceRange
preferredHighlightBegin: 0
preferredHighlightEnd: width
cacheBuffer: width * 3
maximumFlickVelocity: width * 2
delegate: Item {
property int parentIndex: listView.currentIndex
height: ListView.view.height
width: ListView.view.width
onParentIndexChanged: {
if (parentIndex === index + 1) {
loader.item.next()
}
}
Loader {
id: loader
anchors {
fill: parent
topMargin: statusbarMargin
bottomMargin: navbarMargin
}
source: "intro/" + model.name
}
Connections {
target: loader.item
ignoreUnknownSignals: true
onDone: root.done()
}
}
}
Item {
id: buttonsContainer
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom; bottomMargin: root.navbarMargin
}
height: 56 * QL.ScreenValues.dp
Rectangle {
id: rectangleDivider
anchors {
left: parent.left
right: parent.right
}
height: 1 * QL.ScreenValues.dp
color: "#44ffffff"
}
Row {
anchors.centerIn: parent
spacing: 8 * QL.ScreenValues.dp
Repeater {
model: root.model.count
Item {
height: 16 * QL.ScreenValues.dp
width: height
Rectangle {
id: rectangleIndicator
property bool active: index === listView.currentIndex
anchors.centerIn: parent
height: 10 * QL.ScreenValues.dp
width: height
radius: height
opacity: active ? 1 : 0.6
state: "inactive"
states: [
State {
name: "active"
when: rectangleIndicator.active
PropertyChanges {
target: rectangleIndicator
height: 16 * QL.ScreenValues.dp
width: 16 * QL.ScreenValues.dp
}
},
State {
name: "inactive"
when: !rectangleIndicator.active
PropertyChanges {
target: rectangleIndicator
height: 10 * QL.ScreenValues.dp
width: 10 * QL.ScreenValues.dp
}
}
]
transitions: [
Transition {
from: "active"
to: "inactive"
reversible: true
ParallelAnimation {
NumberAnimation {
property: "height"
duration: 175
easing.type: Easing.OutQuad
}
NumberAnimation {
property: "width"
duration: 175
easing.type: Easing.OutQuad
}
}
}
]
}
}
}
}
}
AnimationController {
id: animationController
animation: ParallelAnimation {
PropertyAnimation {
id: propertyAnimationBackground
target: rectangleBackground
property: "color"
from: model.count > 0 ? model.get(0).backgroundColor : "#000000"
to: model.count > 0 ? model.get(1).backgroundColor : "#000000"
onFromChanged: animationController.reload()
onToChanged: animationController.reload()
}
}
}
}
================================================
FILE: src/qml/components/MenuItem.qml
================================================
import QtQuick 2.2
import QtQuick.Controls 1.1
Item {
id: root
property alias text: textElement.text
signal clicked()
width: parent.width
height: applicationWindow.height / 7
Label {
id: textElement
anchors {
fill: parent
leftMargin: root.width * 0.02
rightMargin: root.width * 0.02
topMargin: root.height * 0.06
bottomMargin: root.height * 0.06
}
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
font {
pointSize: 22
}
transform: Rotation { origin.x: 0; origin.y: textElement.height / 2; axis { x: 0; y: 1; z: 0 } angle: mouseArea.pressed ? -10 : 0 }
scale: mouseArea.pressed ? 0.98 : 1
color: root.enabled ? "black" : "#8d8d8d"
}
MouseArea {
id: mouseArea
anchors.fill: parent
enabled: root.enabled
onClicked: {
root.clicked()
try {
root.parent.close()
} catch (e) {
console.log("MenuItem is meant to be used inside a PressAndHoldMenu")
}
}
}
}
================================================
FILE: src/qml/components/PressAndHoldMenu.qml
================================================
import QtQuick 2.2
Item {
id: root
property int expandedWidth: width
property int expandedHeight: 300
property int menuXPosition: width / 2
property int menuYPosition: height / 2
property int screenHeight
default property alias content: container.children
signal closed
signal canceled
function open(xPosition, yPosition) {
/// TODO: add some y offset so it's not oppened under the finger
if (yPosition === undefined) {
yPosition = screenHeight / 2
}
if (xPosition === undefined) {
xPosition = 0
}
if (xPosition < width * 0.15)
menuXPosition = width * 0.15
else if (xPosition > width * 0.85)
menuXPosition = width * 0.85
else
menuXPosition = xPosition
menuYPosition = yPosition
if (yPosition + expandedHeight > height * 0.93) {
background.state = "openedUp"
} else {
background.state = "openedDown"
}
}
function close() {
background.state = "closed"
}
function cancel() {
background.state = "closed"
root.canceled()
}
anchors.fill: parent
Rectangle {
anchors.fill: parent
color: "black"
opacity: background.state != "closed" ? 0.2 : 0
}
MouseArea {
anchors.fill: parent
enabled: background.state != "closed"
onClicked: root.cancel()
}
Rectangle {
id: background
y: menuYPosition
Column {
id: container
function close() {
root.close()
}
anchors.fill: parent
clip: true
}
state: "closed"
states: [
State {
name: "openedDown"
PropertyChanges { target: background; width: root.expandedWidth; height: root.expandedHeight; x: 0 }
},
State {
name: "closed"
PropertyChanges { target: background; width: 0; height: 0; x: root.menuXPosition }
},
State {
name: "openedUp"
PropertyChanges { target: background; width: root.expandedWidth; height: root.expandedHeight; x: 0; y: menuYPosition - expandedHeight }
}
]
transitions: [
Transition {
from: "closed"
to: "openedDown"
SequentialAnimation {
ScriptAction {
script: background.height = 10
}
NumberAnimation { properties: "x, width"; duration: 300; easing.type: Easing.InOutQuad }
NumberAnimation { properties: "height"; duration: 300; easing.type: Easing.InOutQuad }
}
},
Transition {
from: "closed"
to: "openedUp"
SequentialAnimation {
ScriptAction {
script: {
background.height = 10
}
}
NumberAnimation { properties: "x, width"; duration: 300; easing.type: Easing.InOutQuad }
ParallelAnimation {
NumberAnimation { properties: "y"; duration: 300; easing.type: Easing.InOutQuad }
NumberAnimation { properties: "height"; duration: 300; easing.type: Easing.InOutQuad }
}
}
}
]
}
}
================================================
FILE: src/qml/components/RadioButtonStyleDefault.qml
================================================
import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import com.iktwo.qutelauncher 1.0 as QL
RadioButtonStyle {
label: Label {
text: control.text
color: "#ffffff"
}
indicator: Rectangle {
implicitWidth: QL.ScreenValues.dp * 16
implicitHeight: QL.ScreenValues.dp * 16
radius: QL.ScreenValues.dp * 9
border {
color: control.activeFocus ? "darkblue" : "gray"
width: QL.ScreenValues.dp * 1
}
Rectangle {
anchors {
fill: parent
margins: QL.ScreenValues.dp * 4
}
visible: control.checked
color: "#555"
radius: QL.ScreenValues.dp * 9
}
}
}
================================================
FILE: src/qml/components/qmldir
================================================
MenuItem 1.0 MenuItem.qml
RadioButtonStyleDefault 1.0 RadioButtonStyleDefault.qml
PressAndHoldMenu 1.0 PressAndHoldMenu.qml
================================================
FILE: src/qml/config/Dimensions.qml
================================================
pragma Singleton
import QtQuick 2.0
import com.iktwo.qutelauncher 1.0 as QL
Item {
property int barsShadowSize: 85 * QL.ScreenValues.dp
}
================================================
FILE: src/qml/config/Theme.qml
================================================
pragma Singleton
import QtQuick 2.0
import Qt.labs.settings 1.0
Item {
id: root
property color colorGridContainer: "#f5f5f5"
property color colorApplicationWindow: "#00000000"
property bool portrait: false
property bool tablet: false
property int columns: getColumns(portrait)
property int rows: getRows(portrait)
property string theme: "classic"
function getColumns(portrait) {
if (portrait) {
if (tablet) {
return 5
} else {
return 4
}
} else {
if (tablet) {
return 6
} else {
return 4
}
}
}
function getRows(portrait) {
if (portrait) {
return 6
} else {
if (tablet) {
return 5
} else {
return 4
}
}
}
Settings {
property alias theme: root.theme
}
}
================================================
FILE: src/qml/config/qmldir
================================================
singleton Dimensions 1.0 Dimensions.qml
singleton Theme 1.0 Theme.qml
================================================
FILE: src/qml/debug/Debug.qml
================================================
import QtQuick 2.0
import QtQuick.Controls 1.4
import com.iktwo.qutelauncher 1.0 as QL
/*!
\qmltype Debug
\brief Element that displays debug data.
*/
Item {
id: root
property string jsonStyle: ""
property var debugData
function _replacer(match, pIndent, pKey, pVal, pEnd) {
var key = '
'
var val = ''
var str = ''
var r = pIndent || ''
if (pKey)
r = r + key + pKey.replace(/[": ]/g, '') + ': '
if (pVal)
r = r + (pVal[0] === '"' ? str : val) + pVal + ''
return r + (pEnd || '')
}
function prettyPrint(obj) {
var jsonLine = /^( *)("[\w]+": )?("[^"]*"|[\w.+-]*)?([,[{])?$/mg
var jsonString = JSON.stringify(obj, null, 2)
if (!jsonString)
return
return jsonString
.replace(/&/g, '&').replace(/\\"/g, '"')
.replace(//g, '>')
.replace(jsonLine, root._replacer)
.replace("}", "
}")
}
anchors.fill: parent
Rectangle {
anchors.fill: parent
color: "#000000"
opacity: 0.2
}
Label {
anchors {
fill: parent
margins: Math.min(root.height, root.width) * 0.02
}
opacity: 0.8
color: "#95a5a6"
textFormat: Text.RichText
wrapMode: Text.Wrap
font.pointSize: 22
text: jsonStyle + prettyPrint(root.debugData)
}
}
================================================
FILE: src/qml/debug/qmldir
================================================
Debug 1.0 Debug.qml
================================================
FILE: src/qml/intro/IntroEnd.qml
================================================
import QtQuick 2.6
import QtQuick.Controls 1.4
import com.iktwo.qutelauncher 1.0 as QL
IntroScreen {
id: root
Button {
anchors.centerIn: parent
text: qsTr("DONE")
onClicked: root.done()
}
}
================================================
FILE: src/qml/intro/IntroMain.qml
================================================
import QtQuick 2.6
import QtQuick.Controls 1.4
import com.iktwo.qutelauncher 1.0 as QL
IntroScreen {
Column {
anchors {
fill: parent
margins: 8 * QL.ScreenValues.dp
}
Label {
anchors {
left: parent.left
right: parent.right
}
text: qsTr("QuteLauncher")
color: "#ffffff"
horizontalAlignment: Text.AlignHCenter
font.pointSize: 22
}
Item {
height: 16 * QL.ScreenValues.dp
}
Label {
anchors {
left: parent.left
right: parent.right
}
text: "**PLACEHOLDER** Customizable open source Android launcher. Get the source code and contribute at https://iktwo.github.io/QuteLauncher/"
color: "#ffffff"
horizontalAlignment: Text.AlignJustify
wrapMode: Text.Wrap
font.pointSize: 16
}
Item {
height: 24 * QL.ScreenValues.dp
}
Image {
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(parent.width, parent.height) * 0.34
height: width
source: "qrc:/images/icon"
}
}
}
================================================
FILE: src/qml/intro/IntroScreen.qml
================================================
import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import Qt.labs.settings 1.0
import com.iktwo.qutelauncher 1.0 as QL
import components 1.0 as C
FocusScope {
signal done
signal next
}
================================================
FILE: src/qml/intro/IntroSelection.qml
================================================
import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import Qt.labs.settings 1.0
import com.iktwo.qutelauncher 1.0 as QL
import components 1.0 as C
import config 1.0 as Config
IntroScreen {
Column {
anchors.centerIn: parent
Repeater {
id: repeater
model: ["Classic", "Tiles"]
RadioButton {
text: modelData
checked: index === 0
style: C.RadioButtonStyleDefault { }
exclusiveGroup: exclusiveGroupTheme
}
}
}
Settings {
id: settings
property string theme: repeater.model[0].toLowerCase()
}
ExclusiveGroup {
id: exclusiveGroupTheme
}
onNext: Config.Theme.theme = exclusiveGroupTheme.current.text.toLowerCase()
}
================================================
FILE: src/qml/main.qml
================================================
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Window 2.2
import Qt.labs.settings 1.0
import com.iktwo.qutelauncher 1.0 as QL
import config 1.0 as Config
import debug 1.0 as D
ApplicationWindow {
id: applicationWindow
property bool isWindowActive: Qt.application.state === Qt.ApplicationActive
property int dpi: Screen.pixelDensity * 25.4
property variant favoritesData: ([])
property var resolutions: [
{"height": 480, "width": 320}, // HVGA
{"height": 640, "width": 480}, // VGA
{"height": 800, "width": 480}, // WVGA
{"height": 800, "width": 600}, // SVGA
{"height": 640, "width": 360}, // nHD
{"height": 960, "width": 540} // qHD
]
property int currentResolution: 3
property bool activeScreen: Qt.application.state === Qt.ApplicationActive
function updatePortraitMode() {
if (height >= width)
Config.Theme.portrait = true
else
Config.Theme.portrait = true
}
color: Config.Theme.colorApplicationWindow
width: resolutions[currentResolution].width
height: resolutions[currentResolution].height
visible: true
onWidthChanged: updatePortraitMode()
onHeightChanged: updatePortraitMode()
onActiveScreenChanged: {
if (activeScreen)
QL.ScreenValues.updateScreenValues()
}
onFavoritesDataChanged: {
listModelFavorites.clear()
for (var i = 0; i < favoritesData.length; ++i) {
listModelFavorites.append(favoritesData)
}
}
Component.onCompleted: {
Config.Theme.tablet = QL.ScreenValues.isTablet
}
Timer {
interval: 550
running: true
onTriggered: {
QL.Launcher.registerMethods()
QL.PackageManager.registerBroadcast()
}
}
Loader {
id: loaderMainTheme
anchors.fill: parent
source: "themes/" + Config.Theme.theme + "/ThemeMain.qml"
Keys.onBackPressed: {
event.accepted = true
if (loaderMainTheme.item && loaderMainTheme.item.opened) {
QL.Launcher.minimize()
}
}
Keys.onEscapePressed: {
if (loaderMainTheme.item && loaderMainTheme.item.opened) {
QL.Launcher.minimize()
}
}
}
Loader {
id: loader
function unload() {
sourceComponent = null
loaderMainTheme.focus = true
}
anchors.fill: parent
sourceComponent: !QL.ApplicationInfo.hasShownInitialDialog ? introView : undefined
focus: true
// TODO: Remove this once the intro is ready
Component.onCompleted: {
unload()
}
Component {
id: introView
IntroView {
anchors.fill: parent
statusbarMargin: QL.ScreenValues.statusBarHeight
navbarMargin: QL.ScreenValues.navBarVisible ? QL.ScreenValues.navigationBarHeight : 0
model: ListModel {
ListElement { name: "IntroMain.qml"; backgroundColor: "#424242" }
ListElement { name: "IntroSelection.qml"; backgroundColor: "#2c3e50" }
ListElement { name: "IntroEnd.qml"; backgroundColor: "#424242" }
}
onDone: {
QL.ApplicationInfo.hasShownInitialDialog = true
loader.unload()
}
}
}
}
Image {
anchors {
left: parent.left
right: parent.right
top: parent.top
}
height: QL.ScreenValues.statusBarHeight
fillMode: Image.Tile
source: "qrc:/images/shadow"
}
Image {
id: borderImageNavBar
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
height: QL.ScreenValues.navBarVisible ? QL.ScreenValues.navigationBarHeight : 0
fillMode: Image.Tile
source: QL.ScreenValues.navBarVisible ? "qrc:/images/shadow_navigationbar" : ""
}
Connections {
target: QL.PackageManager
onAddedApplicationToGrid: {
var favs = favoritesData
favs.push({'name': name, 'packageName': packageName})
favoritesData = favs
}
}
Settings {
property alias favorites: applicationWindow.favoritesData
}
ListModel {
id: listModelFavorites
}
// D.Debug {
// debugData: {
// 'sdkInt': QL.System.sdkInt,
// 'height': applicationWindow.height,
// 'width': applicationWindow.width,
// 'dp': QL.ScreenValues.dp.toFixed(2),
// 'dpi': QL.ScreenValues.dpi.toFixed(2),
// 'density': QL.ScreenValues.density.toFixed(2),
// 'isTablet': QL.ScreenValues.isTablet,
// 'navBarVisible': QL.ScreenValues.navBarVisible
// }
// }
}
================================================
FILE: src/qml/themes/classic/ApplicationGrid.qml
================================================
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.3
import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0
import com.iktwo.qutelauncher 1.0 as QL
import config 1.0 as Config
ScrollView {
id: root
property alias model: gridView.model
signal pressAndHold(var model, int x, int y)
anchors.fill: parent
style: ScrollViewStyle {
transientScrollBars: false
scrollBarBackground: Rectangle {
implicitWidth: 5 * QL.ScreenValues.dp
color: "#d9d9d9"
}
handle: Rectangle {
implicitWidth: 5 * QL.ScreenValues.dp
color: "#129688"
}
corner: Item { }
decrementControl: Item { }
incrementControl: Item { }
}
flickableItem.focus: true
flickableItem.interactive: true
GridView {
id: gridView
property int highlightedItem
maximumFlickVelocity: height * 5
header: Item {
width: parent.width
height: 20 * QL.ScreenValues.dp
}
add: Transition {
NumberAnimation { properties: "opacity"; from: 0; to: 1; duration: 450 }
NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 500 }
}
displaced: Transition {
NumberAnimation { property: "opacity"; to: 1.0 }
NumberAnimation { property: "scale"; to: 1.0 }
}
clip: true
interactive: visible
cellHeight: height / Config.Theme.getColumns()
cellWidth: width / Config.Theme.getRows()
delegate: ApplicationTile {
id: applicationTile
height: GridView.view.cellHeight
width: GridView.view.cellWidth
source: "image://icon/" + model.packageName
text: model.name
onClicked: QL.PackageManager.launchApplication(model.packageName)
onPressAndHold: root.pressAndHold(model, x, y)
}
onHeightChanged: {
if (height !== 0)
cacheBuffer = Math.max(1080, height * 5)
}
}
}
================================================
FILE: src/qml/themes/classic/ApplicationGridMenu.qml
================================================
import QtQuick 2.2
import com.iktwo.qutelauncher 1.0 as QL
import components 1.0 as C
C.PressAndHoldMenu {
property string packageName
property string name
expandedHeight: menuItem.height * 2
C.MenuItem {
id: menuItem
text: qsTr("Info")
onClicked: QL.PackageManager.openApplicationInfo(packageName)
}
C.MenuItem {
/// TODO: consume the click even if not enabled
/// TODO: verify this
// enabled: QL.PackageManager.packages.indexOf(packageName) === -1
text: qsTr("Add to grid")
onClicked: QL.PackageManager.addApplicationToGrid(name, packageName)
}
}
================================================
FILE: src/qml/themes/classic/ApplicationTile.qml
================================================
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2
import com.iktwo.qutelauncher 1.0
Item {
id: root
property alias text: label.text
property alias source: image.source
property var dragTarget
property var _originalParent
property var _newParent
signal pressAndHold(var model, int x, int y)
signal clicked
Drag.active: mouseArea.drag.active
Drag.hotSpot.x: width / 2
Drag.hotSpot.y: height / 2
width: 80
height: 80
Component.onCompleted: {
_originalParent = parent
_newParent = _originalParent
}
ColumnLayout {
anchors {
top: parent.top
left: parent.left
right: parent.right
}
Image {
id: image
Layout.alignment: Layout.Center
asynchronous: true
Layout.preferredHeight: Math.round(48 * ScreenValues.dp)
Layout.preferredWidth: Math.round(48 * ScreenValues.dp)
fillMode: Image.PreserveAspectFit
}
Label {
id: label
Layout.alignment: Layout.Center
Layout.preferredWidth: parent.width * 0.90
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.NoWrap
maximumLineCount: 1
font.pixelSize: 12 * ScreenValues.dp
color: "#666666"
}
}
MouseArea {
id: mouseArea
property var originalParent
anchors.fill: parent
drag.target: root.dragTarget
onClicked: root.clicked()
onPressAndHold: {
var mappedItem = mapToItem(loaderMainTheme, mouse.x, mouse.y)
root.pressAndHold(model, mappedItem.x, mappedItem.y)
}
onReleased: root._newParent = (root.Drag.target !== null ? root.Drag.target : root._originalParent)
states: [
State {
name: "dragging"
when: mouseArea.drag.active
ParentChange { target: root; parent: root._originalParent }
AnchorChanges {
target: root
anchors {
verticalCenter: undefined
horizontalCenter: undefined
left: undefined
right: undefined
top: undefined
bottom: undefined
}
}
},
State {
name: "notDragging"
when: !mouseArea.drag.active
ParentChange { target: root; parent: root._newParent }
AnchorChanges {
target: root
anchors {
verticalCenter: parent !== root._originalParent ? parent.verticalCenter : undefined
horizontalCenter: parent !== root._originalParent ? parent.horizontalCenter : undefined
left: undefined
right: undefined
top: undefined
bottom: undefined
}
}
}
]
}
}
================================================
FILE: src/qml/themes/classic/ExpandableItem.qml
================================================
import QtQuick 2.5
import com.iktwo.qutelauncher 1.0
import config 1.0 as Config
Item {
default property alias content: itemContainer.data
property alias color: rectangleMinizedIndicator.color
property alias busy: transition.running
property int minimizedHeight: Math.round(48 * ScreenValues.dp)
property int minimizedWidth: Math.round(48 * ScreenValues.dp)
property int targetWidth: Math.round(parent.width - (getSideMargin() * ScreenValues.dp))
property int targetHeight: Math.round(parent.height - 8 * ScreenValues.dp)
property point minimizedPoint: Qt.point(Math.round(parent.width / 2), Math.round(parent.height - rectangleMinizedIndicator.height - (4 * ScreenValues.dp)))
property point centerPoint: Qt.point(Math.round(parent.width / 2), Math.round(parent.height / 2))
property point targetPoint: Qt.point(Math.round(centerPoint.x - (targetWidth / 2)), Math.round(6 * ScreenValues.dp))
readonly property bool isOpened: stateGroup.state === "opened"
function close() {
stateGroup.state = "closed"
}
function open() {
stateGroup.state = "opened"
}
function getSideMargin() {
if (applicationWindow.isScreenPortrait) {
if (ScreenValues.isTablet)
return -1 /// TODO: find right value
else
return 16
} else {
if (ScreenValues.isTablet)
return 138
else
return -1 /// TODO: find right value
}
}
Rectangle {
id: rectangleMinizedIndicator
color: Config.Theme.colorGridContainer
width: minimizedWidth
height: minimizedHeight
x: minimizedPoint.x
y: minimizedPoint.y
}
StateGroup {
id: stateGroup
state: "closed"
states: [
State {
name: "closed"
PropertyChanges {
target: rectangleMinizedIndicator
height: minimizedHeight; width: minimizedWidth
x: Math.round(minimizedPoint.x - (minimizedWidth / 2)); y: minimizedPoint.y
radius: Math.round(minimizedWidth / 2)
}
PropertyChanges {
target: itemContainer
opacity: 0
}
},
State {
name: "opened"
PropertyChanges {
target: rectangleMinizedIndicator
height: targetHeight; width: targetWidth
x: targetPoint.x; y: targetPoint.y
radius: Math.round(2 * ScreenValues.dp)
}
PropertyChanges {
target: itemContainer
opacity: 1
}
}
]
transitions: [
Transition {
id: transition
from: "closed"
to: "opened"
reversible: true
ParallelAnimation {
PropertyAnimation { property: "y"; duration: 275; easing.type: Easing.InOutCubic }
SequentialAnimation {
PauseAnimation { duration: 50 }
ParallelAnimation {
PropertyAnimation { target: rectangleMinizedIndicator; properties: "height, width"; easing.type: Easing.InOutCubic; duration: 250 }
PropertyAnimation { target: rectangleMinizedIndicator; property: "radius"; easing.type: Easing.InOutCubic; duration: 250 }
PropertyAnimation { target: rectangleMinizedIndicator; property: "x"; easing.type: Easing.InOutCubic; duration: 250 }
SequentialAnimation {
PauseAnimation { duration: 150 }
PropertyAnimation { target: itemContainer; property: "opacity"; easing.type: Easing.InOutCubic}
}
}
}
}
}
]
}
Item {
id: itemContainer
anchors {
right: rectangleMinizedIndicator.right; rightMargin: -ScreenValues.dp
verticalCenter: rectangleMinizedIndicator.verticalCenter
}
width: targetWidth
height: targetHeight
}
MouseArea {
anchors.fill: parent
enabled: stateGroup.state === "closed"
}
MouseArea {
anchors.fill: rectangleMinizedIndicator
enabled: stateGroup.state === "closed"
onClicked: open()
}
}
================================================
FILE: src/qml/themes/classic/ThemeMain.qml
================================================
import QtQuick 2.0
import com.iktwo.qutelauncher 1.0 as QL
import config 1.0 as Config
FocusScope {
id: root
property int navbarMargin: QL.ScreenValues.navBarVisible ? QL.ScreenValues.navigationBarHeight : 0
property int statusbarMargin: QL.ScreenValues.statusBarHeight
property bool opened: explandableItem.isOpened
focus: true
Keys.onUpPressed: {
if (Qt.platform.os !== "android")
explandableItem.open()
event.accepted = false
}
Keys.onDownPressed: {
if (Qt.platform.os !== "android")
explandableItem.close()
event.accepted = false
}
MouseArea {
anchors.fill: parent
enabled: !explandableItem.isOpened
onPressAndHold: QL.Launcher.pickWallpaper()
}
GridView {
id: gridView
anchors.fill: parent
property int highlightedItem
maximumFlickVelocity: height * 5
header: Item {
width: parent.width
height: 20 * QL.ScreenValues.dp
}
add: Transition {
NumberAnimation { properties: "opacity"; from: 0; to: 1; duration: 450 }
NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 500 }
}
displaced: Transition {
NumberAnimation { property: "opacity"; to: 1.0 }
NumberAnimation { property: "scale"; to: 1.0 }
}
clip: true
interactive: visible
visible: false
cellHeight: height / Config.Theme.getColumns()
cellWidth: width / Config.Theme.getRows()
model: listModelFavorites
delegate: ApplicationTile {
id: applicationTile
height: GridView.view.cellHeight
width: GridView.view.cellWidth
source: "image://icon/" + model.packageName
text: model.name
onClicked: QL.PackageManager.launchApplication(model.packageName)
onPressAndHold: root.pressAndHold(model, x, y)
}
onHeightChanged: {
if (height !== 0)
cacheBuffer = Math.max(1080, height * 5)
}
}
Item {
anchors {
top: parent.top; topMargin: QL.ScreenValues.statusBarHeight
bottom: parent.bottom; bottomMargin: root.navbarMargin
left: parent.left
right: parent.right
}
ExpandableItem {
id: explandableItem
anchors.fill: parent
ApplicationGrid {
model: QL.PackageManager
anchors.fill: parent
onPressAndHold: {
/// TODO: implement this
// applicationTile.source = "image://icon/" + model.packageName
// applicationTile.text = model.name
applicationGridMenu.packageName = model.packageName
applicationGridMenu.name = model.name
applicationGridMenu.open(x, y)
}
}
}
}
MouseArea {
anchors.fill: parent
enabled: explandableItem.busy
}
GridView {
/// TODO: verify in landscape mode
anchors {
top: parent.top; topMargin: QL.ScreenValues.statusBarHeight
left: parent.left
right: parent.right
}
height: 4 * (80 * QL.ScreenValues.dp)
model: 16
enabled: false
interactive: false
cellHeight: height / 4
cellWidth: width / 4
delegate: DropArea {
width: GridView.view.cellWidth
height: GridView.view.cellHeight
}
}
Row {
id: rowFavorites
anchors {
bottom: parent.bottom; bottomMargin: root.navbarMargin
}
height: 80 * QL.ScreenValues.dp
Repeater {
model: 5
DropArea {
width: 80 * QL.ScreenValues.dp
height: 80 * QL.ScreenValues.dp
}
}
}
Connections {
target: QL.Launcher
onNewIntentReceived: explandableItem.close()
onMinimized: explandableItem.close()
}
ApplicationGridMenu {
id: applicationGridMenu
screenHeight: root.height
onClosed: explandableItem.close()
}
}
================================================
FILE: src/qml/themes/tiles/ApplicationGrid.qml
================================================
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtGraphicalEffects 1.0
import com.iktwo.qutelauncher 1.0 as QL
GridView {
id: root
property bool editMode: false
property int highlightedItem
maximumFlickVelocity: height * 2.5
cacheBuffer: height * 5
add: Transition {
NumberAnimation { properties: "opacity"; from: 0; to: 1; duration: 450 }
NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 500 }
}
displaced: Transition {
NumberAnimation { property: "opacity"; to: 1.0 }
NumberAnimation { property: "scale"; to: 1.0 }
}
visible: false
interactive: visible
cellHeight: height / 5
cellWidth: width / 4
onCountChanged: {
if (count == 0)
editMode = false
}
delegate: Item {
id: itemDelegate
height: GridView.view.cellHeight
width: GridView.view.cellWidth
Item {
id: container
anchors {
fill: parent
margins: dpi * 0.04
}
scale: editMode && index == highlightedItem ? 1.2 : 1
Label {
anchors {
left: parent.left; leftMargin: dpi * 0.02
right: parent.right; rightMargin: dpi * 0.02
bottom: parent.bottom; bottomMargin: dpi * 0.03
}
text: model.name
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.NoWrap
maximumLineCount: 2
font {
pointSize: 14
}
color: "white"
}
Image {
id: icon
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top; topMargin: parent.height * 0.2
}
antialiasing: true
height: parent.height * 0.6
width: parent.width * 0.6
asynchronous: true
fillMode: Image.PreserveAspectFit
source: "image://icon/" + model.packageName
}
}
MouseArea {
anchors.fill: parent
onClicked: {
if (editMode) {
if (highlightedItem == index) {
editMode = false
} else {
highlightedItem = index
}
} else {
QL.PackageManager.launchApplication(model.packageName)
}
}
onPressAndHold: {
highlightedItem = index
editMode = true
}
}
MouseArea {
id: test
anchors {
top: parent.top
right: parent.right
}
height: closeButton.height * 1.2
width: closeButton.width * 1.2
enabled: editMode && index == highlightedItem
onClicked: {
/// TODO: verify this
//gridModel.removeApplication(model.packageName)
if (root.count > highlightedItem)
highlightedItem -= 1
}
}
Rectangle {
id: closeButton
anchors {
right: parent.right; rightMargin: - width / 3
top: parent.top; topMargin: - height / 3
}
enabled: editMode && index == highlightedItem
visible: enabled
width: parent.width / 4
height: width
radius: height / 2
clip: true
color: "black"
border {
color: "white"
width: closeButton.width * 0.15
}
Rectangle {
rotation: 45
width: parent.width * 0.9
height: width * 0.1
anchors.centerIn: parent
smooth: true
antialiasing: true
}
Rectangle {
rotation: -45
width: parent.width * 0.9
height: width * 0.1
anchors.centerIn: parent
smooth: true
antialiasing: true
}
}
}
}
================================================
FILE: src/qml/themes/tiles/ApplicationList.qml
================================================
import QtQuick 2.2
import QtQuick.Layouts 1.1
import com.iktwo.qutelauncher 1.0 as QL
import "."
Item {
id: root
property alias model: listView.model
property int delegateHeight: dpi * 0.40
signal showColorPicker
function goToIndex(index) {
listView.positionViewAtIndex(index, ListView.Beginning)
/// Add delegateHeight to move past the section
listView.contentY += delegateHeight
}
anchors.fill: parent
ListView {
id: listView
anchors {
top: listHeader.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
cacheBuffer: height >= 0 ? (height * 9) : root.height
maximumFlickVelocity: root.height * 2.5
section {
property: "category"
criteria: ViewSection.FirstCharacter
delegate: ApplicationSection {
text: section
onClicked: sectionNavigator.open()
}
}
delegate: Item {
height: delegateHeight
width: root.width
Rectangle {
anchors {
fill: icon
margins: -parent.height * 0.05
}
color: Configuration.color
}
Image {
id: icon
anchors {
left: parent.left; leftMargin: 20
verticalCenter: parent.verticalCenter
//horizontalCenter: parent.horizontalCenter
//top: parent.top; topMargin: parent.height * 0.2
}
antialiasing: true
height: parent.height * 0.75
width: height
asynchronous: true
fillMode: Image.PreserveAspectFit
source: "image://icon/" + model.packageName
}
Text {
anchors {
verticalCenter: icon.verticalCenter
left: icon.right; leftMargin: dpi * 0.06
right: parent.right
}
text: model.name
elide: Text.ElideRight
color: "white"
}
MouseArea {
anchors.fill: parent
onClicked: packageManager.launchApplication(model.packageName)
onPressAndHold: {
var mappedItem = mapToItem(root, mouse.x, mouse.y)
menu.packageName = model.packageName
menu.name = model.name
menu.open(mouse.x, mappedItem.y)
}
}
}
}
Rectangle {
id: listHeader
anchors {
top: parent.top
left: parent.left
right: parent.right
}
height: delegateHeight
color: "black"
visible: listView.contentY > delegateHeight
ApplicationSection {
text: listView.currentSection
onClicked: sectionNavigator.open()
}
}
Item {
id: btnMenu
anchors {
top: parent.top
right: parent.right
}
width: 48 * QL.ScreenValues.dp
height: 48 * QL.ScreenValues.dp
clip: true
scale: mouseArea.pressed ? 0.97 : 1
Image {
anchors.fill: parent
antialiasing: true
/// TODO: verify this
source: "qrc:/images/menu"
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: root.showColorPicker()
}
}
}
================================================
FILE: src/qml/themes/tiles/ApplicationMenu.qml
================================================
import QtQuick 2.2
import com.iktwo.qutelauncher 1.0 as QL
import components 1.0 as C
C.PressAndHoldMenu {
property string packageName
property string name
expandedHeight: menuItem.height * 2
C.MenuItem {
id: menuItem
text: qsTr("Info")
onClicked: QL.PackageManager.openApplicationInfo(packageName)
}
C.MenuItem {
/// TODO: consume the click even if not enabled
/// TODO: verify this
// enabled: QL.PackageManager.packages.indexOf(packageName) === -1
text: qsTr("Add to grid")
onClicked: QL.PackageManager.addApplicationToGrid(name, packageName)
}
}
================================================
FILE: src/qml/themes/tiles/ApplicationSection.qml
================================================
import QtQuick 2.2
import "."
Item {
id: root
property alias text: textElement.text
signal clicked()
width: height
height: delegateHeight
Rectangle {
anchors {
left: parent.left
leftMargin: 20
verticalCenter: parent.verticalCenter
}
border.color: Configuration.color
border.width: parent.height * 0.01
color: "transparent"
width: parent.height * 0.8
height: width
Text {
id: textElement
anchors.centerIn: parent
color: Configuration.color
font {
pointSize: 24
bold: true
}
}
}
MouseArea {
anchors.fill: parent
onClicked: root.clicked()
}
}
================================================
FILE: src/qml/themes/tiles/ColorPicker.qml
================================================
import QtQuick 2.6
Item {
id: root
property color color
signal selectedColor()
function open() {
focus = true
visible = true
}
function close() {
visible = false
/// TODO: verify this
// backKeyHandler.forceActiveFocus()
}
anchors.fill: parent
visible: false
Keys.onBackPressed: close()
Rectangle {
id: container
property var colors: [
"#a4c400", "#60a917", "#008a00",
"#00aba9", "#1ba1e2", "#0050ef",
"#6a00ff", "#aa00ff", "#f472d0",
"#d80073", "#a20025", "#e51400",
"#fa6800", "#f0a30a", "#e3c800",
"#825a2c", "#6d8764", "#647687",
"#76608a", "#87794e"
]
anchors.fill: parent
color: "black"
GridView {
anchors.centerIn: parent
width: parent.width * 0.9
height: parent.height * 0.9
cellHeight: height / 5
cellWidth: width / 4
model: container.colors.length
delegate: Item {
height: GridView.view.cellHeight
width: GridView.view.cellWidth
Rectangle {
id: itemColor
anchors.centerIn: parent
width: parent.width * 0.9
height: parent.height * 0.9
color: container.colors[index]
}
MouseArea {
anchors.fill: parent
onClicked: {
root.color = itemColor.color
selectedColor()
close()
}
}
}
}
}
}
================================================
FILE: src/qml/themes/tiles/Configuration.qml
================================================
pragma Singleton
import QtQuick 2.0
import Qt.labs.settings 1.0
Item {
id: root
property bool dark: true
property color color: "green"
Settings {
property alias dark: root.dark
property alias color: root.color
}
}
================================================
FILE: src/qml/themes/tiles/SectionNavigator.qml
================================================
import QtQuick 2.6
import com.iktwo.qutelauncher 1.0 as QL
import "."
Item {
id: root
property var sections: [
"#", "A", "B", "C", "D", "E", "F", "G",
"H", "I", "J", "K", "L", "M", "N", "O",
"P", "Q", "R", "S", "T", "U", "V", "W",
"X", "Y", "Z", "%"
]
property bool animationRunning: false
signal goToSection(int sectionIndex)
signal closed()
signal opened()
function open() {
visible = true
focus = true
opened()
}
function close() {
/// TODO: verify this
// backKeyHandler.forceActiveFocus()
closed()
}
anchors.fill: parent
visible: false
Keys.onBackPressed: close()
MouseArea {
anchors.fill: parent
enabled: parent.visible
}
Rectangle {
anchors.fill: parent
color: "black"
opacity: 0.6
}
GridView {
id: view
anchors {
fill: parent
rightMargin: parent.width * 0.025
leftMargin: parent.width * 0.025
topMargin: parent.width * 0.02
bottomMargin: parent.width * 0.02
}
model: root.sections.length
cellWidth: width / 4
cellHeight: height / 7
interactive: false
delegate: Item {
property bool sectionExists: QL.PackageManager.sections.indexOf(root.sections[index]) !== -1
height: view.cellHeight
width: view.cellWidth
Flipable {
id: flipable
property bool flipped: !root.visible
Connections {
target: root
onClosed: flipable.flipped = true
onOpened: flipable.flipped = false
}
anchors.fill: parent
front: Rectangle {
anchors {
fill: parent
rightMargin: parent.width * 0.06
leftMargin: parent.width * 0.06
topMargin: parent.width * 0.06
bottomMargin: parent.width * 0.06
}
color: sectionExists ? Configuration.color : "black"
clip: true
Text {
anchors {
left: parent.left; leftMargin: 15
bottom: parent.bottom; bottomMargin: 15
}
color: "white"
font {
pointSize: 22
bold: true
}
text: root.sections[index]
}
}
transform: Rotation {
id: rotation
origin.x: flipable.width/2
origin.y: flipable.height/2
axis.x: 1; axis.y: 0; axis.z: 0
angle: 0
}
states: State {
name: "back"
when: flipable.flipped
PropertyChanges { target: rotation; angle: 180 }
}
transitions: Transition {
ParallelAnimation {
alwaysRunToEnd: true
NumberAnimation { target: rotation; property: "angle"; duration: 450; easing.type: Easing.InOutQuad }
SequentialAnimation {
ScriptAction {
script: root.animationRunning = true
}
PauseAnimation { duration: 300 }
ScriptAction {
script: {
if (flipable.flipped)
root.visible = false
root.animationRunning = false
}
}
}
}
}
}
MouseArea {
anchors.fill: parent
enabled: sectionExists && !root.animationRunning
onClicked: {
root.goToSection(QL.PackageManager.indexOfSection(root.sections[index]))
close()
}
}
}
}
}
================================================
FILE: src/qml/themes/tiles/ThemeMain.qml
================================================
import QtQuick 2.6
import com.iktwo.qutelauncher 1.0 as QL
import "."
Item {
id: root
property int navbarMargin: QL.ScreenValues.navBarVisible ? QL.ScreenValues.navigationBarHeight : 0
property int statusbarMargin: QL.ScreenValues.statusBarHeight
/// TODO: adapt this to tiles theme
property bool opened: false
Flickable {
anchors.fill: parent
contentWidth: width * 2
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.HorizontalFlick
maximumFlickVelocity: applicationWindow.width * 3
pressDelay: 50
flickDeceleration: 5000
/// TODO: check if this is ok
interactive: !applicationGrid.editMode
// property bool enableAnimation: true
Behavior on contentX { SmoothedAnimation { duration: 150 } }
// onMovementStarted: {
// }
onMovementEnded: {
if (contentX >= width / 2)
contentX = width
else
contentX = 0
//console.log("CONTENT X:", contentX)
}
Item {
anchors {
top: parent.top
bottom: parent.bottom
}
width: applicationWindow.width * 2
Rectangle {
anchors.fill: parent
color: "black"
opacity: 0.3
visible: applicationGrid.editMode
}
ApplicationGrid {
id: applicationGrid
anchors {
top: parent.top; topMargin: parent.height * 0.025
bottom: parent.bottom; bottomMargin: parent.height * 0.025
left: parent.left; leftMargin: (parent.width / 2 ) * 0.025
}
model: QL.PackageManager
width: (parent.width / 2 ) * 0.95
}
Rectangle {
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
}
width: parent.width / 2
color: "black"
ApplicationList {
id: applicationList
model: QL.PackageManager
onShowColorPicker: colorPicker.open()
}
}
}
}
ApplicationMenu {
id: menu
}
SectionNavigator {
id: sectionNavigator
onGoToSection: applicationList.goToIndex(sectionIndex)
}
ColorPicker {
id: colorPicker
/// TODO: handle back key
onSelectedColor: Configuration.color = color
}
Connections {
target: QL.Launcher
onNewIntentReceived: explandableItem.close()
onMinimized: explandableItem.close()
}
}
================================================
FILE: src/qml/themes/tiles/qmldir
================================================
singleton Configuration 1.0 Configuration.qml
================================================
FILE: src/resources.qrc
================================================
qml/main.qml
qml/IntroView.qml
qml/config/qmldir
qml/config/Theme.qml
qml/config/Dimensions.qml
qml/debug/Debug.qml
qml/debug/qmldir
qml/intro/IntroMain.qml
qml/intro/IntroEnd.qml
qml/themes/classic/ThemeMain.qml
qml/themes/classic/ApplicationGrid.qml
qml/themes/classic/ExpandableItem.qml
qml/themes/classic/ApplicationTile.qml
qml/themes/tiles/ThemeMain.qml
qml/themes/tiles/ApplicationGrid.qml
qml/themes/tiles/ApplicationList.qml
qml/themes/tiles/ApplicationMenu.qml
qml/themes/tiles/ColorPicker.qml
qml/themes/tiles/SectionNavigator.qml
qml/themes/tiles/ApplicationSection.qml
qml/themes/tiles/Configuration.qml
qml/themes/tiles/qmldir
qml/components/PressAndHoldMenu.qml
qml/components/qmldir
qml/themes/classic/ApplicationGridMenu.qml
qml/components/MenuItem.qml
qml/intro/IntroSelection.qml
qml/components/RadioButtonStyleDefault.qml
qml/intro/IntroScreen.qml
resources/images/test.png
resources/images/shadow.png
resources/images/shadow_navigationbar.png
resources/images/icon.svg
================================================
FILE: src/src/application.cpp
================================================
#include "application.h"
#include
Application::Application(QObject *parent) :
QObject(parent)
{
}
Application::Application(const QString &name, const QString &packageName, QObject *parent) :
QObject(parent),
mName(name),
mPackageName(packageName)
{
setCategory();
}
QString Application::name() const
{
return mName;
}
void Application::setName(const QString &name)
{
if (mName == name)
return;
mName = name;
emit nameChanged();
setCategory();
}
QString Application::packageName() const
{
return mPackageName;
}
void Application::setPackageName(const QString &packageName)
{
if (mPackageName == packageName)
return;
mPackageName = packageName;
emit packageNameChanged();
}
QString Application::category() const
{
return mCategory;
}
void Application::setCategory()
{
QString name = mName.simplified();
name.replace(QRegExp("[ÁÀÂÃÄ]"), "A");
name.replace(QRegExp("[áàâãä]"), "a");
name.replace(QRegExp("[ÉÈÊẼË]"), "E");
name.replace(QRegExp("[éèêẽë]"), "e");
name.replace(QRegExp("[ÍÌÎĨÏ]"), "I");
name.replace(QRegExp("[íìîĩï]"), "i");
name.replace(QRegExp("[ÓÒÔÕÖ]"), "O");
name.replace(QRegExp("[óòôõö]"), "o");
name.replace(QRegExp("[ÚÙÛŨÜ]"), "U");
name.replace(QRegExp("[úùûũü]"), "u");
name.replace(QRegExp("[Ç]"), "C");
name.replace(QRegExp("[ç]"), "c");
if (name.simplified().isEmpty())
mCategory = " ";
else if (name.at(0).isDigit())
mCategory = "#";
else if (name.at(0) <= 'z')
mCategory = name.at(0).toUpper();
else
mCategory = "%";
emit categoryChanged();
}
================================================
FILE: src/src/application.h
================================================
#ifndef APPLICATION_H
#define APPLICATION_H
#include
class Application : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString packageName READ packageName NOTIFY packageNameChanged)
Q_PROPERTY(QString category READ category NOTIFY categoryChanged)
public:
explicit Application(QObject *parent = 0);
Application(const QString &name, const QString &packageName, QObject *parent = 0);
QString name() const;
void setName(const QString &name);
QString packageName() const;
void setPackageName(const QString &packageName);
QString category() const;
void setCategory();
signals:
void nameChanged();
void packageNameChanged();
void categoryChanged();
private:
QString mName;
QString mPackageName;
QString mCategory;
};
#endif // APPLICATION_H
================================================
FILE: src/src/applicationinfo.cpp
================================================
#include "applicationinfo.h"
#include
#include
#ifdef Q_OS_ANDROID
#include
#include
#endif
ApplicationInfo::ApplicationInfo(QObject *parent) :
QObject(parent),
m_timesLaunched(0),
m_hasShownInitialDialog(false)
{
QSettings settings;
m_timesLaunched = settings.value("timesLaunched", 0).toInt();
m_hasShownInitialDialog = settings.value("hasShownInitialDialog", false).toBool();
m_firstTimeLaunched = settings.value("firstTimeLaunched", QDate::fromString("20000101", "yyyyMMdd")).toDate();
if (m_firstTimeLaunched.toString("yyyyMMdd") == "20000101")
setFirstTimeLaunched(QDate::currentDate());
m_OSVersion = getOSVersion();
setTimesLaunched(m_timesLaunched + 1);
}
int ApplicationInfo::timesLaunched() const
{
return m_timesLaunched;
}
void ApplicationInfo::setTimesLaunched(int timesLaunched)
{
if (m_timesLaunched == timesLaunched)
return;
m_timesLaunched = timesLaunched;
QSettings settings;
settings.setValue("timesLaunched", m_timesLaunched);
emit timesLaunchedChanged();
}
QDate ApplicationInfo::firstTimeLaunched() const
{
return m_firstTimeLaunched;
}
void ApplicationInfo::setFirstTimeLaunched(const QDate &firstTimeLaunched)
{
if (m_firstTimeLaunched == firstTimeLaunched)
return;
m_firstTimeLaunched = firstTimeLaunched;
QSettings settings;
settings.setValue("firstTimeLaunched", m_firstTimeLaunched);
emit firstTimeLaunchedChanged();
}
bool ApplicationInfo::hasShownInitialDialog() const
{
return m_hasShownInitialDialog;
}
void ApplicationInfo::setHasShownInitialDialog(bool hasShownInitialDialog)
{
if (m_hasShownInitialDialog == hasShownInitialDialog)
return;
m_hasShownInitialDialog = hasShownInitialDialog;
QSettings settings;
settings.setValue("hasShownInitialDialog", m_hasShownInitialDialog);
emit hasShownInitialDialogChanged();
}
int ApplicationInfo::OSVersion() const
{
return m_OSVersion;
}
void ApplicationInfo::setOSVersion(int version)
{
if (m_OSVersion == version)
return;
m_OSVersion = version;
emit OSVersionChanged();
}
int ApplicationInfo::getOSVersion()
{
#ifdef Q_OS_ANDROID
jint version = QAndroidJniObject::getStaticField("android.os.Build$VERSION", "SDK_INT");
return version;
#else
return -1;
#endif
}
================================================
FILE: src/src/applicationinfo.h
================================================
#ifndef APPLICATIONINFO_H
#define APPLICATIONINFO_H
#include
#include
class ApplicationInfo : public QObject
{
Q_OBJECT
Q_PROPERTY(int timesLaunched READ timesLaunched NOTIFY timesLaunchedChanged)
Q_PROPERTY(QDate firstTimeLaunched READ firstTimeLaunched NOTIFY firstTimeLaunchedChanged)
Q_PROPERTY(bool hasShownInitialDialog READ hasShownInitialDialog WRITE setHasShownInitialDialog NOTIFY hasShownInitialDialogChanged)
Q_PROPERTY(int OSVersion READ OSVersion WRITE setOSVersion NOTIFY OSVersionChanged)
public:
ApplicationInfo(QObject *parent = 0);
int timesLaunched() const;
void setTimesLaunched(int timesLaunched);
QDate firstTimeLaunched() const;
void setFirstTimeLaunched(const QDate &firstTimeLaunched);
bool hasShownInitialDialog() const;
void setHasShownInitialDialog(bool hasShownInitialDialog);
int OSVersion() const;
void setOSVersion(int version);
signals:
void timesLaunchedChanged();
void firstTimeLaunchedChanged();
void hasShownInitialDialogChanged();
void OSVersionChanged();
private:
int m_timesLaunched;
QDate m_firstTimeLaunched;
bool m_hasShownInitialDialog;
int m_OSVersion;
int getOSVersion();
};
#endif // APPLICATIONINFO_H
================================================
FILE: src/src/iconimageprovider.cpp
================================================
#include "iconimageprovider.h"
#ifdef Q_OS_ANDROID
#include
#include
#endif
#include
IconImageProvider::IconImageProvider() :
QQuickImageProvider(QQuickImageProvider::Image)
{
}
QImage IconImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
Q_UNUSED(size);
Q_UNUSED(requestedSize);
QImage image;
#ifdef Q_OS_ANDROID
QAndroidJniObject appIcon = QAndroidJniObject::callStaticObjectMethod("com/iktwo/qutelauncher/QuteLauncher",
"getApplicationIcon",
"(Ljava/lang/String;)[B",
QAndroidJniObject::fromString(id).object());
QAndroidJniEnvironment env;
jbyteArray iconDataArray = appIcon.object();
if (!iconDataArray) {
qDebug() << Q_FUNC_INFO << "No icon data";
return image;
}
jsize iconSize = env->GetArrayLength(iconDataArray);
if (iconSize > 0) {
jboolean jfalse = false;
jbyte *icon = env->GetByteArrayElements(iconDataArray, &jfalse);
image = QImage::fromData((uchar*) icon, iconSize,"PNG");
env->ReleaseByteArrayElements(iconDataArray, icon, JNI_ABORT);
}
return image;
#else
Q_UNUSED(id)
return QImage("://images/test","PNG");
#endif
}
================================================
FILE: src/src/iconimageprovider.h
================================================
#ifndef ICONIMAGEPROVIDER_H
#define ICONIMAGEPROVIDER_H
#include
class IconImageProvider : public QQuickImageProvider
{
public:
explicit IconImageProvider();
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize);
};
#endif // ICONIMAGEPROVIDER_H
================================================
FILE: src/src/launcher.cpp
================================================
#include "launcher.h"
#ifdef Q_OS_ANDROID
#include
static void newIntent(JNIEnv *env, jobject thiz, jlong qtObject)
{
Q_UNUSED(env)
Q_UNUSED(thiz)
reinterpret_cast(qtObject)->emitNewIntent();
}
#endif
Launcher::Launcher(QObject *parent) : QObject(parent)
{
#ifdef Q_OS_ANDROID
mActivity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");
#endif
}
void Launcher::pickWallpaper()
{
#ifdef Q_OS_ANDROID
QAndroidJniObject::callStaticMethod("com/iktwo/qutelauncher/QuteLauncher",
"pickWallpaper",
"()V");
#endif
}
void Launcher::emitNewIntent()
{
emit newIntentReceived();
}
void Launcher::registerMethods()
{
registerNativeMethods();
}
void Launcher::minimize()
{
emit minimized();
}
void Launcher::registerNativeMethods()
{
#ifdef Q_OS_ANDROID
JNINativeMethod methods[] {{"jnewIntent", "(J)V", reinterpret_cast(newIntent)}};
QAndroidJniObject::callStaticMethod("com/iktwo/qutelauncher/QuteLauncherFlavored",
"setQtObject", "(J)V",
"(J)V", reinterpret_cast(this));
QAndroidJniEnvironment env;
jclass objectClass = env->GetObjectClass(mActivity.object());
if (env->ExceptionCheck())
env->ExceptionClear();
env->RegisterNatives(objectClass, methods, sizeof(methods) / sizeof(methods[0]));
if (env->ExceptionCheck())
env->ExceptionClear();
env->DeleteLocalRef(objectClass);
if (env->ExceptionCheck())
env->ExceptionClear();
#endif
}
================================================
FILE: src/src/launcher.h
================================================
#ifndef LAUNCHER_H
#define LAUNCHER_H
#include
#ifdef Q_OS_ANDROID
#include
#endif
class Launcher : public QObject
{
Q_OBJECT
public:
explicit Launcher(QObject *parent = 0);
Q_INVOKABLE void pickWallpaper();
Q_INVOKABLE void emitNewIntent();
Q_INVOKABLE void registerMethods();
Q_INVOKABLE void minimize();
signals:
void newIntentReceived();
void minimized();
private:
void registerNativeMethods();
#ifdef Q_OS_ANDROID
QAndroidJniObject mActivity;
#endif
};
#endif // LAUNCHER_H
================================================
FILE: src/src/main.cpp
================================================
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "applicationinfo.h"
#include "iconimageprovider.h"
#include "launcher.h"
#include "packagemanager.h"
#include "screenvalues.h"
#include "system.h"
static QObject *package_manager_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new PackageManager();
}
static QObject *screen_values_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new ScreenValues();
}
static QObject *launcher_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new Launcher();
}
static QObject *system_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new System();
}
static QObject *application_info_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new ApplicationInfo();
}
int main(int argc, char *argv[])
{
QScopedPointer app(new QApplication(argc, argv));
QCoreApplication::setOrganizationName("Iktwo Corp.");
QCoreApplication::setOrganizationDomain("iktwo.com");
QCoreApplication::setApplicationName("QuteLauncher");
QQmlApplicationEngine engine;
QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
qmlRegisterSingletonType("com.iktwo.qutelauncher", 1, 0, "PackageManager", package_manager_provider);
qmlRegisterSingletonType("com.iktwo.qutelauncher", 1, 0, "ApplicationInfo", application_info_provider);
qmlRegisterSingletonType("com.iktwo.qutelauncher", 1, 0, "ScreenValues", screen_values_provider);
qmlRegisterSingletonType("com.iktwo.qutelauncher", 1, 0, "System", system_provider);
qmlRegisterSingletonType("com.iktwo.qutelauncher", 1, 0, "Launcher", launcher_provider);
engine.addImageProvider(QLatin1String("icon"), new IconImageProvider());
engine.addImportPath("qrc:/qml/qml");
engine.load(QUrl("qrc:/qml/qml/main.qml"));
return app->exec();
}
================================================
FILE: src/src/packagemanager.cpp
================================================
#include "packagemanager.h"
#include "application.h"
#include
#include
#include
#ifdef Q_OS_ANDROID
#include
static void packageAdded(JNIEnv *env, jobject thiz, jstring label, jstring packageName, jlong qtObject)
{
Q_UNUSED(env)
Q_UNUSED(thiz)
reinterpret_cast(qtObject)->emitAddApplication(PackageManager::jstringToQString(label).simplified(), PackageManager::jstringToQString(packageName));
}
static void packageRemoved(JNIEnv *env, jobject thiz, jstring packageName, jlong qtObject)
{
Q_UNUSED(env)
Q_UNUSED(thiz)
reinterpret_cast(qtObject)->emitRemoveApplication(PackageManager::jstringToQString(packageName));
}
#endif
PackageManager::PackageManager(QObject *parent) :
QAbstractListModel(parent)
{
#ifdef Q_OS_ANDROID
mAndroidActivity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");
mIntentFilter = QAndroidJniObject("android/content/IntentFilter");
mBroadcastReceiver = QAndroidJniObject("com/iktwo/qutelauncher/PackageChangedReceiver");
#endif
connect(this, SIGNAL(newApplicationDetected(QString, QString)), this, SLOT(addApplication(QString, QString)));
connect(this, SIGNAL(removedApplication(QString)), this, SLOT(removeApplication(QString)));
}
int PackageManager::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return mApplications.count();
}
QVariant PackageManager::data(const QModelIndex &index, int role) const
{
if (index.row() < 0 || index.row() >= mApplications.count())
return QVariant();
switch (role) {
case NameRole:
return qobject_cast(mApplications.at(index.row()))->name();
break;
case PackageNameRole:
return qobject_cast(mApplications.at(index.row()))->packageName();
break;
case CategoryRole:
return qobject_cast(mApplications.at(index.row()))->category();
break;
}
return QVariant();
}
#ifdef Q_OS_ANDROID
void PackageManager::registerNativeMethods() {
JNINativeMethod methods[] {{"jpackageRemoved", "(Ljava/lang/String;J)V", reinterpret_cast(packageRemoved)},
{"jpackageAdded", "(Ljava/lang/String;Ljava/lang/String;J)V", reinterpret_cast(packageAdded)}};
QAndroidJniObject::callStaticMethod("com/iktwo/qutelauncher/PackageChangedReceiver",
"setQtObject", "(J)V",
"(J)V", reinterpret_cast(this));
QAndroidJniEnvironment env;
jclass objectClass = env->GetObjectClass(mBroadcastReceiver.object());
if (env->ExceptionCheck())
env->ExceptionClear();
env->RegisterNatives(objectClass, methods, sizeof(methods) / sizeof(methods[0]));
if (env->ExceptionCheck())
env->ExceptionClear();
env->DeleteLocalRef(objectClass);
if (env->ExceptionCheck())
env->ExceptionClear();
}
#endif
void PackageManager::launchApplication(const QString &application)
{
#ifdef Q_OS_ANDROID
QAndroidJniObject::callStaticMethod("com/iktwo/qutelauncher/QuteLauncher",
"launchApplication",
"(Ljava/lang/String;)V",
QAndroidJniObject::fromString(application).object());
#else
Q_UNUSED(application)
#endif
}
QHash PackageManager::roleNames() const
{
QHash roles;
roles[NameRole] = "name";
roles[PackageNameRole] = "packageName";
roles[CategoryRole] = "category";
return roles;
}
QString GetRandomString()
{
const QString possibleCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
const int randomStringLength = 8; // assuming you want random strings of 12 characters
QString randomString;
for(int i=0; i < randomStringLength; ++i)
{
int index = qrand() % possibleCharacters.length();
QChar nextChar = possibleCharacters.at(index);
randomString.append(nextChar);
}
return randomString;
}
void PackageManager::retrievePackages()
{
beginResetModel();
#ifdef Q_OS_ANDROID
QAndroidJniObject connectionType = QAndroidJniObject::callStaticObjectMethod("com/iktwo/qutelauncher/QuteLauncher",
"applications",
"()[Lcom/iktwo/qutelauncher/Application;");
jobjectArray array = connectionType.object();
QAndroidJniEnvironment env;
jsize size = env->GetArrayLength(array);
for (int i = 0; i < size; ++i) {
QAndroidJniObject obj = env->GetObjectArrayElement(array, i);
QString name = jstringToQString((obj.callObjectMethod("getName")).object());
QString packageName = jstringToQString((obj.callObjectMethod("getPackageName")).object());
qDebug() << "name:" << name << " packageName:" << packageName;
if (packageName == "com.google.android.launcher")
continue;
mApplications.append(new Application(name.simplified(), packageName));
}
#else
mApplications.append(new Application("Aero", "com.aero"));
mApplications.append(new Application("Andale", "com.andale"));
mApplications.append(new Application("Andate", "com.andate"));
mApplications.append(new Application("Basurto", "com.basurto"));
mApplications.append(new Application("Bueno", "com.bueno"));
mApplications.append(new Application("Casa", "com.casa"));
mApplications.append(new Application("Cosa", "com.cosa"));
mApplications.append(new Application("Crosa", "com.crosa"));
mApplications.append(new Application("Indie", "com.indie"));
mApplications.append(new Application("Indira", "com.indira"));
mApplications.append(new Application("Indigo", "com.indigo"));
mApplications.append(new Application("Juice", "com.juice"));
mApplications.append(new Application("Kato", "com.kato"));
mApplications.append(new Application("Keee", "com.keee"));
mApplications.append(new Application("Kila", "com.kila"));
mApplications.append(new Application("Kilo", "com.kilo"));
mApplications.append(new Application("Kudo", "com.kudo"));
mApplications.append(new Application("Kuelo", "com.kuelo"));
mApplications.append(new Application("Kuzz", "com.kuzz"));
mApplications.append(new Application("Locos", "com.locos"));
mApplications.append(new Application("Lucas", "com.lucas"));
mApplications.append(new Application("Many", "com.many"));
mApplications.append(new Application("Mano", "com.mano"));
mApplications.append(new Application("Mezcla", "com.mezcla"));
mApplications.append(new Application("Nooooo", "com.nooooo"));
mApplications.append(new Application("Niurka", "com.niurka"));
mApplications.append(new Application("Nunca", "com.nunca"));
mApplications.append(new Application("Tatoo", "com.tatoo"));
mApplications.append(new Application("Tito", "com.tito"));
mApplications.append(new Application("Toto", "com.toto"));
mApplications.append(new Application("Tuto", "com.tuto"));
mApplications.append(new Application("Radio", "com.radio"));
mApplications.append(new Application("Rojo", "com.rojo"));
mApplications.append(new Application("Very long name here", "com.very"));
mApplications.append(new Application("Zahm", "com.zahm"));
mApplications.append(new Application("Zooom", "com.zooom"));
#endif
QSettings settings;
int packagesSize = settings.beginReadArray("packages");
settings.endArray();
QStringList defaultApps;
#ifdef Q_OS_ANDROID
if (packagesSize == 0) {
defaultApps << "com.android.dialer";
defaultApps << "com.android.contacts";
defaultApps << "com.android.chrome";
defaultApps << "com.google.android.GoogleCamera";
defaultApps << "com.google.android.music";
defaultApps << "com.google.android.youtube";
defaultApps << "com.google.android.talk";
defaultApps << "com.google.android.gallery3d";
defaultApps << "com.facebook.katana";
defaultApps << "com.whatsapp";
defaultApps << "com.google.android.gm";
defaultApps << "com.android.deskclock";
defaultApps << "com.google.android.keep";
defaultApps << "com.google.android.calendar";
defaultApps << "com.google.android.apps.maps";
defaultApps << "com.google.earth";
defaultApps << "com.cyanogenmod.filemanager";
defaultApps << "com.android.providers.downloads.ui";
defaultApps << "com.android.vending";
defaultApps << "com.android.settings";
}
#else
if (packagesSize == 0) {
defaultApps << "com.aero";
defaultApps << "com.andate";
defaultApps << "com.basurto";
}
#endif
if (packagesSize == 0) {
foreach (QString app, defaultApps) {
foreach (QObject *applicationObject, mApplications) {
Application *application = qobject_cast(applicationObject);
if (app == application->packageName()) {
emit addedApplicationToGrid(application->name(), application->packageName());
break;
}
}
}
}
/// TODO: add code to clean this before retrieving packages, change this foreach with a for
/// This assumes mApplications is ordered, and it should be..
int i = 0;
foreach (QObject *object, mApplications) {
Application *application = qobject_cast(object);
if (!mSections.contains(application->category())) {
mSections.append(application->category());
mSectionsPositions.append(i);
}
++i;
}
// qDebug() << "mApplications:" << mApplications;
endResetModel();
emit sectionsChanged();
}
void PackageManager::registerBroadcast()
{
retrievePackages();
#ifdef Q_OS_ANDROID
qDebug() << Q_FUNC_INFO << "registering broadcast";
QAndroidJniObject addActionString = QAndroidJniObject::fromString("android.intent.action.PACKAGE_ADDED");
QAndroidJniObject removeActionString = QAndroidJniObject::fromString("android.intent.action.PACKAGE_REMOVED");
QAndroidJniObject dataSchemeString = QAndroidJniObject::fromString("package");
mIntentFilter.callMethod("addAction", "(Ljava/lang/String;)V", addActionString.object());
mIntentFilter.callMethod("addAction", "(Ljava/lang/String;)V", removeActionString.object());
mIntentFilter.callMethod("addDataScheme", "(Ljava/lang/String;)V", dataSchemeString.object());
mAndroidActivity.callObjectMethod("registerReceiver",
"(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;",
mBroadcastReceiver.object(), mIntentFilter.object());
registerNativeMethods();
#endif
}
int PackageManager::indexOfSection(const QString §ion)
{
return mSectionsPositions.at(mSections.indexOf(section));
}
void PackageManager::openApplicationInfo(const QString &packageName)
{
#ifdef Q_OS_ANDROID
QAndroidJniObject::callStaticObjectMethod("com/iktwo/qutelauncher/QuteLauncher",
"openApplicationInfo",
"(Ljava/lang/String;)V",
QAndroidJniObject::fromString(packageName).object());
#else
Q_UNUSED(packageName)
#endif
}
void PackageManager::addApplicationToGrid(const QString &name, const QString &packageName)
{
emit addedApplicationToGrid(name, packageName);
}
void PackageManager::testJNICall()
{
#ifdef Q_OS_ANDROID
qDebug() << "GEtting instance";
QAndroidJniObject packageManager = QAndroidJniObject::callStaticObjectMethod("com/iktwo/qutelauncher/QuteLauncher",
"getInstance",
"()Lcom/iktwo/qutelauncher/QuteLauncher;");
packageManager.callMethod("selectWidget");
qDebug() << "PM:" << packageManager.toString();
#endif
}
QStringList PackageManager::sections() const
{
return mSections;
}
#ifdef Q_OS_ANDROID
QString PackageManager::jstringToQString(jstring string)
{
QAndroidJniEnvironment env;
jboolean jfalse = false;
return QString(env->GetStringUTFChars(string, &jfalse));
}
#endif
void PackageManager::addApplication(const QString &name, const QString &packageName)
{
int i;
for (i = 0; i < mApplications.length(); ++i) {
Application *application = qobject_cast(mApplications.at(i));
if (name.compare(application->name()) < 0)
break;
}
qDebug() << Q_FUNC_INFO << "NAME:" << name << " PACKAGE:" << packageName;
beginInsertRows(QModelIndex(), i, i);
Application *application = new Application(name, packageName);
mApplications.insert(i, application);
endInsertRows();
if (!mSections.contains(application->category())) {
mSections.append(application->category());
mSectionsPositions.append(i);
}
}
void PackageManager::removeApplication(const QString &packageName)
{
qDebug() << Q_FUNC_INFO << packageName;
int i = 0;
foreach (QObject *object, mApplications) {
Application *app = qobject_cast(object);
if (app->packageName() == packageName) {
beginRemoveRows(QModelIndex(), i, i);
delete mApplications.takeAt(i);
endRemoveRows();
i--;
}
i++;
}
mSections.clear();
mSectionsPositions.clear();
i = 0;
foreach (QObject *object, mApplications) {
Application *application = qobject_cast(object);
if (!mSections.contains(application->category())) {
mSections.append(application->category());
mSectionsPositions.append(i);
}
++i;
}
sectionsChanged();
}
void PackageManager::emitAddApplication(const QString &name, const QString &packageName)
{
emit newApplicationDetected(name, packageName);
}
void PackageManager::emitRemoveApplication(const QString &packageName)
{
emit removedApplication(packageName);
}
================================================
FILE: src/src/packagemanager.h
================================================
#ifndef PACKAGEMANAGER_H
#define PACKAGEMANAGER_H
#include
#ifdef Q_OS_ANDROID
#include
#endif
class PackageManager : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QStringList sections READ sections NOTIFY sectionsChanged)
public:
explicit PackageManager(QObject *parent = 0);
enum Roles {
NameRole = Qt::UserRole +1,
PackageNameRole,
CategoryRole
};
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
Q_INVOKABLE void launchApplication(const QString &application);
Q_INVOKABLE void registerBroadcast();
Q_INVOKABLE int indexOfSection(const QString §ion);
Q_INVOKABLE void openApplicationInfo(const QString &packageName);
Q_INVOKABLE void addApplicationToGrid(const QString &name, const QString &packageName);
Q_INVOKABLE void testJNICall();
#ifdef Q_OS_ANDROID
static QString jstringToQString(jstring string);
#endif
Q_INVOKABLE void emitAddApplication(const QString &name, const QString &packageName);
Q_INVOKABLE void emitRemoveApplication(const QString &packageName);
QStringList sections() const;
public slots:
void retrievePackages();
void addApplication(const QString &name, const QString &packageName);
void removeApplication(const QString &packageName);
protected:
QHash roleNames() const;
signals:
void newApplicationDetected(const QString &name, const QString &packageName);
void addedApplicationToGrid(const QString &name, const QString &packageName);
void removedApplication(const QString &packageName);
void sectionsChanged();
private:
QObjectList mApplications;
QMap mApps;
QStringList mSections;
QList mSectionsPositions;
void registerNativeMethods();
//void sortApplications();
#ifdef Q_OS_ANDROID
QAndroidJniObject mAndroidActivity;
QAndroidJniObject mIntentFilter;
QAndroidJniObject mBroadcastReceiver;
#endif
};
#endif // PACKAGEMANAGER_H
================================================
FILE: src/src/screenvalues.cpp
================================================
#include "screenvalues.h"
#include
#include
#ifdef Q_OS_ANDROID
#include
#include
#endif
#include
ScreenValues::ScreenValues(QObject *parent) :
QObject(parent),
m_dpi(0),
m_isTablet(false)
{
m_dpi = retrieveDpi();
m_density = retrieveDensity();
m_dp = (float) m_dpi / 160;
setStatusBarHeight(getResourceSize("status_bar_height"));
setNavigationBarHeight(getResourceSize("navigation_bar_height"));
setNavigationBarHeightLandscape(getResourceSize("navigation_bar_height_landscape"));
updateScreenValues();
m_isTablet = retrieveIsTablet();
}
void ScreenValues::updateScreenValues()
{
#ifdef Q_OS_ANDROID
if (m_system.sdkInt() >= 19) {
QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative",
"activity",
"()Landroid/app/Activity;");
QAndroidJniObject wm = activity.callObjectMethod("getWindowManager", "()Landroid/view/WindowManager;");
QAndroidJniObject display = wm.callObjectMethod("getDefaultDisplay", "()Landroid/view/Display;");
QAndroidJniObject realSize = QAndroidJniObject("android/graphics/Point");
display.callMethod("getRealSize", "(Landroid/graphics/Point;)V", realSize.object());
QAndroidJniObject displayFrame = QAndroidJniObject("android/graphics/Rect");
QAndroidJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
QAndroidJniObject view = window.callObjectMethod("getDecorView", "()Landroid/view/View;");
QAndroidJniObject rootView = view.callObjectMethod("getRootView", "()Landroid/view/View;");
rootView.callMethod("getWindowVisibleDisplayFrame", "(Landroid/graphics/Rect;)V", displayFrame.object());
if (((int) realSize.getField("y") - (int) displayFrame.callMethod("height")) - m_statusBarHeight == 0)
setNavBarVisible(false);
else
setNavBarVisible(true);
}
#endif
}
int ScreenValues::dpi() const
{
return m_dpi;
}
void ScreenValues::setDpi(int dpi)
{
if (m_dpi == dpi)
return;
m_dpi = dpi;
emit dpiChanged();
setDp((float) m_dpi / 160);
}
float ScreenValues::dp() const
{
return m_dp;
}
void ScreenValues::setDp(float dp)
{
if (m_dp == dp)
return;
m_dp = dp;
emit dpChanged();
}
bool ScreenValues::isTablet() const
{
return m_isTablet;
}
void ScreenValues::setIsTablet(bool isTablet)
{
if (m_isTablet == isTablet)
return;
m_isTablet = isTablet;
emit isTabletChanged();
}
bool ScreenValues::navBarVisible() const
{
return m_navBarVisible;
}
float ScreenValues::density() const
{
return m_density;
}
void ScreenValues::setDensity(float density)
{
if (m_density == density)
return;
m_density = density;
emit densityChanged(density);
}
int ScreenValues::statusBarHeight() const
{
return m_statusBarHeight;
}
int ScreenValues::navigationBarHeight() const
{
return m_navigationBarHeight;
}
int ScreenValues::navigationBarHeightLandscape() const
{
return m_navigationBarHeightLandscape;
}
void ScreenValues::setStatusBarHeight(int statusBarHeight)
{
if (m_statusBarHeight == statusBarHeight)
return;
m_statusBarHeight = statusBarHeight;
emit statusBarHeightChanged();
}
void ScreenValues::setNavigationBarHeight(int navigationBarHeight)
{
if (m_navigationBarHeight == navigationBarHeight)
return;
m_navigationBarHeight = navigationBarHeight;
emit navigationBarHeightChanged();
}
void ScreenValues::setNavigationBarHeightLandscape(int navigationBarHeightLandscape)
{
if (m_navigationBarHeightLandscape == navigationBarHeightLandscape)
return;
m_navigationBarHeightLandscape = navigationBarHeightLandscape;
emit navigationBarHeightLandscapeChanged();
}
void ScreenValues::setNavBarVisible(bool visible)
{
if (m_navBarVisible == visible)
return;
m_navBarVisible = visible;
emit navBarVisibleChanged();
}
bool ScreenValues::retrieveIsTablet()
{
#ifdef Q_OS_ANDROID
QAndroidJniEnvironment env;
env->PushLocalFrame(9);
QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative",
"activity",
"()Landroid/app/Activity;");
QAndroidJniObject resources = activity.callObjectMethod("getResources",
"()Landroid/content/res/Resources;");
QAndroidJniObject configuration = resources.callObjectMethod("getConfiguration",
"()Landroid/content/res/Configuration;");
jint smallestScreenWidthDp = configuration.getField("smallestScreenWidthDp");
return smallestScreenWidthDp >= 600;
#else
return false;
#endif
}
int ScreenValues::retrieveDpi()
{
#ifdef Q_OS_ANDROID
QAndroidJniEnvironment env;
env->PushLocalFrame(9);
QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative",
"activity",
"()Landroid/app/Activity;");
jclass activityClass = env->GetObjectClass(activity.object());
jmethodID mIDGetResources = env->GetMethodID(activityClass,
"getResources",
"()Landroid/content/res/Resources;");
jobject resources = env->CallObjectMethod(activity.object(), mIDGetResources);
jclass resourcesClass = env->GetObjectClass(resources);
jmethodID mIDGetDisplayMetrics = env->GetMethodID(resourcesClass,
"getDisplayMetrics",
"()Landroid/util/DisplayMetrics;");
jobject displayMetrics = env->CallObjectMethod(resources, mIDGetDisplayMetrics);
jclass displayMetricsClass = env->GetObjectClass(displayMetrics);
jfieldID fIDDensityDpi = env->GetFieldID(displayMetricsClass, "densityDpi", "I");
jint densityDpi = env->GetIntField(displayMetrics, fIDDensityDpi);
int result = (int)densityDpi;
env->PopLocalFrame(NULL);
return result;
#else
return QGuiApplication::primaryScreen()->physicalDotsPerInch();
#endif
}
float ScreenValues::retrieveDensity()
{
#ifdef Q_OS_ANDROID
QAndroidJniEnvironment env;
env->PushLocalFrame(9);
QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative",
"activity",
"()Landroid/app/Activity;");
jclass activityClass = env->GetObjectClass(activity.object());
jmethodID mIDGetResources = env->GetMethodID(activityClass,
"getResources",
"()Landroid/content/res/Resources;");
jobject resources = env->CallObjectMethod(activity.object(), mIDGetResources);
jclass resourcesClass = env->GetObjectClass(resources);
jmethodID mIDGetDisplayMetrics = env->GetMethodID(resourcesClass,
"getDisplayMetrics",
"()Landroid/util/DisplayMetrics;");
jobject displayMetrics = env->CallObjectMethod(resources, mIDGetDisplayMetrics);
jclass displayMetricsClass = env->GetObjectClass(displayMetrics);
jfieldID fIDDensityDpi = env->GetFieldID(displayMetricsClass, "density", "F");
jfloat densityDpi = env->GetFloatField(displayMetrics, fIDDensityDpi);
float result = (float)densityDpi;
env->PopLocalFrame(NULL);
return result;
#else
return QGuiApplication::primaryScreen()->physicalDotsPerInch();
#endif
}
int ScreenValues::getResourceSize(const QString &resource)
{
#ifdef Q_OS_ANDROID
QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative",
"activity",
"()Landroid/app/Activity;");
QAndroidJniObject resources = activity.callObjectMethod("getResources", "()Landroid/content/res/Resources;");
QAndroidJniObject jName = QAndroidJniObject::fromString(resource);
QAndroidJniObject jDefType = QAndroidJniObject::fromString("dimen");
QAndroidJniObject jDefPackage = QAndroidJniObject::fromString("android");
jint identifier = resources.callMethod("getIdentifier",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
jName.object(),
jDefType.object(),
jDefPackage.object());
jint size = resources.callMethod("getDimensionPixelSize",
"(I)I", identifier);
return size;
#else
return 0;
#endif
}
================================================
FILE: src/src/screenvalues.h
================================================
#ifndef SCREENVALUES_H
#define SCREENVALUES_H
#include
#include "system.h"
class ScreenValues : public QObject
{
Q_OBJECT
Q_PROPERTY(int statusBarHeight READ statusBarHeight NOTIFY statusBarHeightChanged)
Q_PROPERTY(int navigationBarHeight READ navigationBarHeight NOTIFY navigationBarHeightChanged)
Q_PROPERTY(int navigationBarHeightLandscape READ navigationBarHeightLandscape NOTIFY navigationBarHeightLandscapeChanged)
Q_PROPERTY(int dpi READ dpi WRITE setDpi NOTIFY dpiChanged)
Q_PROPERTY(float dp READ dp WRITE setDp NOTIFY dpChanged)
Q_PROPERTY(float density READ density NOTIFY densityChanged)
Q_PROPERTY(bool isTablet READ isTablet NOTIFY isTabletChanged)
Q_PROPERTY(bool navBarVisible READ navBarVisible NOTIFY navBarVisibleChanged)
public:
explicit ScreenValues(QObject *parent = 0);
Q_INVOKABLE void updateScreenValues();
float dp() const;
void setDp(float dp);
float density() const;
void setDensity(float density);
int dpi() const;
void setDpi(int dpi);
int statusBarHeight() const;
int navigationBarHeight() const;
int navigationBarHeightLandscape() const;
bool isTablet() const;
void setIsTablet(bool isTablet);
bool navBarVisible() const;
signals:
void dpChanged();
void dpiChanged();
void statusBarHeightChanged();
void navigationBarHeightChanged();
void navigationBarHeightLandscapeChanged();
void isTabletChanged();
void navBarVisibleChanged();
void densityChanged(float density);
private:
System m_system;
float m_dp;
float m_density;
int m_dpi;
int m_statusBarHeight;
int m_navigationBarHeight;
int m_navigationBarHeightLandscape;
bool m_isTablet;
bool m_navBarVisible;
float retrieveDensity();
int retrieveDpi();
int getResourceSize(const QString &resource);
bool retrieveIsTablet();
void setStatusBarHeight(int statusBarHeight);
void setNavigationBarHeight(int navigationBarHeight);
void setNavigationBarHeightLandscape(int navigationBarHeightLandscape);
void setNavBarVisible(bool visible);
};
#endif // SCREENVALUES_H
================================================
FILE: src/src/system.cpp
================================================
#include "system.h"
#ifdef Q_OS_ANDROID
#include
#endif
System::System(QObject *parent) : QObject(parent)
{
setSdkInt(getSdkInt());
}
int System::sdkInt() const
{
return m_sdkInt;
}
void System::setSdkInt(int sdkInt)
{
if (m_sdkInt == sdkInt)
return;
m_sdkInt = sdkInt;
emit sdkIntChanged(sdkInt);
}
int System::getSdkInt()
{
#ifdef Q_OS_ANDROID
return m_sdkInt = QAndroidJniObject::getStaticField("android/os/Build$VERSION", "SDK_INT");
#else
return 0;
#endif
}
================================================
FILE: src/src/system.h
================================================
#ifndef SYSTEM_H
#define SYSTEM_H
#include
class System : public QObject
{
Q_OBJECT
Q_PROPERTY(int sdkInt READ sdkInt NOTIFY sdkIntChanged)
public:
explicit System(QObject *parent = 0);
int sdkInt() const;
signals:
void sdkIntChanged(int sdkInt);
private slots:
void setSdkInt(int sdkInt);
private:
int m_sdkInt;
int getSdkInt();
};
#endif // SYSTEM_H
================================================
FILE: src/src.pro
================================================
TEMPLATE = app
TARGET = qute-launcher
QT += qml quick widgets svg network
android {
QT += androidextras
OTHER_FILES += \
android/src/com/iktwo/qutelauncher/*.java \
android/src/org/qtproject/qt5/android/bindings/*.java \
android/res/values-v21/* \
android/res/values-v19/* \
android/res/values/* \
android/AndroidManifest.xml
}
QML_IMPORT_PATH = $$PWD/qml
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
HEADERS += $$files($$PWD/src/*.h)
SOURCES += $$files($$PWD/src/*.cpp)
RESOURCES += resources.qrc
include(deployment.pri)
DISTFILES += \
android/gradle/wrapper/gradle-wrapper.jar \
android/gradlew \
android/res/values/libs.xml \
android/build.gradle \
android/gradle/wrapper/gradle-wrapper.properties \
android/gradlew.bat