diff --git a/data/.vscode/c_cpp_properties.json b/data/.vscode/c_cpp_properties.json
new file mode 100644
index 0000000000000000000000000000000000000000..541db60d3c3243299a30db80a0b36c001074e3cf
--- /dev/null
+++ b/data/.vscode/c_cpp_properties.json
@@ -0,0 +1,26 @@
+{
+ "configurations": [
+ {
+ "name": "Linux",
+ "includePath": [
+ "${workspaceFolder}/**",
+ "/usr/local/oecore-x86_64/sysroots/cortexa9hf-neon-oe-linux-gnueabi/usr/include/**",
+ "/usr/local/oecore-x86_64/sysroots/cortexa9hf-neon-oe-linux-gnueabi/usr/include/c++/7.3.0/**",
+ "/usr/local/oecore-x86_64/sysroots/cortexa9hf-neon-oe-linux-gnueabi/usr/include/c++/7.3.0/backward/**",
+ "/usr/local/oecore-x86_64/sysroots/cortexa9hf-neon-oe-linux-gnueabi/usr/include/c++/7.3.0/arm-oe-linux-gnueabi/**",
+ "/usr/local/oecore-x86_64/sysroots/cortexa9hf-neon-oe-linux-gnueabi/usr/lib/gcc/arm-oe-linux-gnueabi/7.3.0/include/**",
+ "/usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/lib/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/7.3.0/include/**",
+ "/usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/lib/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/7.3.0/include-fixed/**"
+ ],
+ "defines": [
+ "__ARM_PCS_VFP",
+ "_MIPS_SIM"
+ ],
+ "compilerPath": "/usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-g++",
+ "cStandard": "c11",
+ "cppStandard": "c++11",
+ "intelliSenseMode": "linux-gcc-arm64"
+ }
+ ],
+ "version": 4
+}
\ No newline at end of file
diff --git a/data/.vscode/settings.json b/data/.vscode/settings.json
new file mode 100644
index 0000000000000000000000000000000000000000..c0526a9becbc36c673e995a9a15644d6951b7523
--- /dev/null
+++ b/data/.vscode/settings.json
@@ -0,0 +1,84 @@
+{
+ "files.associations": {
+ "cstdlib": "cpp",
+ "sstream": "cpp",
+ "array": "cpp",
+ "atomic": "cpp",
+ "bit": "cpp",
+ "*.tcc": "cpp",
+ "cctype": "cpp",
+ "clocale": "cpp",
+ "cmath": "cpp",
+ "cstdarg": "cpp",
+ "cstddef": "cpp",
+ "cstdint": "cpp",
+ "cstdio": "cpp",
+ "cwchar": "cpp",
+ "cwctype": "cpp",
+ "deque": "cpp",
+ "unordered_map": "cpp",
+ "vector": "cpp",
+ "exception": "cpp",
+ "algorithm": "cpp",
+ "functional": "cpp",
+ "iterator": "cpp",
+ "memory": "cpp",
+ "memory_resource": "cpp",
+ "numeric": "cpp",
+ "optional": "cpp",
+ "random": "cpp",
+ "string": "cpp",
+ "string_view": "cpp",
+ "system_error": "cpp",
+ "tuple": "cpp",
+ "type_traits": "cpp",
+ "utility": "cpp",
+ "fstream": "cpp",
+ "initializer_list": "cpp",
+ "iosfwd": "cpp",
+ "iostream": "cpp",
+ "istream": "cpp",
+ "limits": "cpp",
+ "new": "cpp",
+ "ostream": "cpp",
+ "stdexcept": "cpp",
+ "streambuf": "cpp",
+ "typeinfo": "cpp",
+ "qtquick": "cpp",
+ "qtquickdepends": "cpp",
+ "qtcore": "cpp",
+ "qtcoredepends": "cpp",
+ "qguiapplication": "cpp",
+ "qdebug": "cpp",
+ "qjsonarray": "cpp",
+ "qjsonvalue": "cpp",
+ "hash_map": "cpp",
+ "hash_set": "cpp",
+ "unordered_set": "cpp",
+ "qtplugin": "cpp",
+ "qtgui": "cpp",
+ "qprocess": "cpp",
+ "list": "cpp",
+ "cassert": "cpp",
+ "cerrno": "cpp",
+ "cfloat": "cpp",
+ "chrono": "cpp",
+ "climits": "cpp",
+ "complex": "cpp",
+ "condition_variable": "cpp",
+ "cstring": "cpp",
+ "ctime": "cpp",
+ "map": "cpp",
+ "set": "cpp",
+ "ratio": "cpp",
+ "future": "cpp",
+ "iomanip": "cpp",
+ "ios": "cpp",
+ "locale": "cpp",
+ "mutex": "cpp",
+ "queue": "cpp",
+ "thread": "cpp",
+ "cinttypes": "cpp",
+ "variant": "cpp"
+ }
+}
\ No newline at end of file
diff --git a/data/LICENSE b/data/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..f288702d2fa16d3cdf0035b15a9fcbc552cd88e7
--- /dev/null
+++ b/data/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/data/backend/common.js b/data/backend/common.js
new file mode 100644
index 0000000000000000000000000000000000000000..99653aca25555cddca1f687ff70e013ed02bb25e
--- /dev/null
+++ b/data/backend/common.js
@@ -0,0 +1,16 @@
+const config = JSON.parse(require("fs").readFileSync(__dirname + "/../config.json"));
+
+module.exports.fetchOptions = {
+ headers: {
+ "Upgrade-Insecure-Requests": "1",
+ "Sec-GPC": "1",
+ "Cookie": config.cookie,
+ },
+ method: "GET",
+ compress: true,
+ redirect: "follow",
+};
+
+module.exports.domain = config.domain;
+module.exports.listURL = config.listURL;
+module.exports.additionalBookLocation = config.additionalBookLocation;
\ No newline at end of file
diff --git a/data/backend/download.js b/data/backend/download.js
new file mode 100644
index 0000000000000000000000000000000000000000..d36e29d9d85c75777328e23f9d95b58a1b2e8541
--- /dev/null
+++ b/data/backend/download.js
@@ -0,0 +1,101 @@
+const { writeFileSync, copyFileSync, existsSync, mkdirSync, createWriteStream, constants } = require("fs");
+const { join: pathJoin, extname, basename } = require("path");
+const { v4 } = require("uuid");
+const { domain, fetchOptions, additionalBookLocation } = require("./common");
+const fetch = require("node-fetch");
+
+module.exports = function (args, socket) {
+ if (args.length < 1) {
+ socket.write("ERR: No download link\n");
+ return;
+ }
+
+ const xochitlFolder = "/home/root/.local/share/remarkable/xochitl/";
+ const downloadURL = domain + args[0];
+ console.log(downloadURL);
+
+ fetch(downloadURL, fetchOptions).then((response) => {
+ console.log("Redirected to:", response.url);
+
+ let fileName;
+ let fileExt;
+
+ const disposition = response.headers.get('content-disposition');
+ if (disposition) {
+ const nameMatch = disposition.match(/filename="(.+)"/);
+ if (nameMatch) {
+ let name = nameMatch[1].replace(" (z-lib.org)", "");
+ // Convert multi-byte chars to their true representation
+ name = Buffer.from(name, "binary").toString("utf8");
+
+ fileExt = extname(name);
+ fileName = basename(name, fileExt);
+ console.log(fileName, fileExt);
+ }
+ }
+
+ if (!fileName || !fileExt) {
+ socket.write("ERR: 2 No file\n");
+ return;
+ }
+
+ const fileLength = parseInt(response.headers.get('content-length'));
+
+ const uuid = v4();
+ const tempFilePath = "/tmp/" + uuid;
+ console.log(tempFilePath, fileLength);
+
+ const fileStream = createWriteStream(tempFilePath);
+
+ response.body.on("data", (chunk) => {
+ fileStream.write(chunk, () => {
+ socket.write("PROG:" + Math.floor(fileStream.bytesWritten / fileLength * 95).toString() + "\n");
+ if (fileStream.bytesWritten == fileLength) {
+ fileStream.close();
+ }
+ });
+ });
+
+ response.body.on("error", (error) => {
+ socket.write("ERR: 2 " + error + "\n");
+ socket.end();
+ });
+
+ fileStream.on('close', () => {
+ socket.write("DOWNLOAD DONE\n");
+
+ if (fileExt == ".epub" || fileExt == ".pdf") {
+ writeFileSync(xochitlFolder + uuid + ".metadata", JSON.stringify({
+ "deleted": false,
+ "lastModified": "1",
+ "lastOpenedPage": 0,
+ "metadatamodified": false,
+ "modified": false,
+ "parent": "",
+ "pinned": false,
+ "synced": false,
+ "type": "DocumentType",
+ "version": 1,
+ "visibleName": fileName
+ }));
+
+ copyFileSync(tempFilePath, pathJoin(xochitlFolder, uuid + fileExt), constants.COPYFILE_FICLONE);
+ socket.write("COPIED XOCHITL\n");
+ }
+
+ if (additionalBookLocation) {
+ if (!existsSync(additionalBookLocation)) {
+ mkdirSync(additionalBookLocation, { recursive: true });
+ }
+ copyFileSync(tempFilePath, pathJoin(additionalBookLocation, fileName + fileExt), constants.COPYFILE_FICLONE);
+ socket.write("COPIED LOCAL\n");
+ }
+ socket.write("PROG:100\n");
+ socket.end();
+ });
+ })
+ .catch(err => {
+ socket.write("ERR: 1 " + err + "\n");
+ socket.end();
+ });
+}
diff --git a/data/backend/info.js b/data/backend/info.js
new file mode 100644
index 0000000000000000000000000000000000000000..dc17dc76c073827e5420f2f5e072cfb017b8cb76
--- /dev/null
+++ b/data/backend/info.js
@@ -0,0 +1,56 @@
+const cheerio = require("cheerio");
+const { domain, fetchOptions } = require("./common");
+const fetch = require("node-fetch");
+
+module.exports = function (args, socket) {
+ const profile = fetch(domain + "/papi/user/dstats", fetchOptions).then(res => res.json()).then(json => {
+ if (!json) return;
+
+ return ({
+ today_download: json.dailyDownloads + "/" + json.dailyDownloadsLimit
+ });
+ })
+ .catch(err => {
+ socket.write("ERR: 1 " + err + "\n");
+ socket.end();
+ });
+
+ const history = fetch(domain + "/users/dstats.php?today", fetchOptions).then(res => res.text()).then(html => {
+ const $ = cheerio.load(html);
+ const rows = $(".dstats-row");
+ if (!rows.length) return;
+
+ return rows.get().map(row => {
+ const a = $(row).find("a");
+ if (!a) return undefined;
+
+ let url = a.attr("href");
+ let name = a.text().trim();
+ if (!url || !name) return undefined;
+
+ if (url[0] !== "/") url = "/" + url;
+
+ return ({ url, name });
+ })
+ .filter(a => a);
+ })
+ .catch(err => {
+ socket.write("ERR: 1 " + err + "\n");
+ socket.end();
+ });
+
+ Promise.all([profile, history]).then(results => {
+ if (!results || results.length < 2) return;
+
+ const final = results[0];
+ final.today_list = results[1];
+ socket.write(JSON.stringify(final));
+ socket.write("\n");
+ socket.end();
+ })
+ .catch(err => {
+ socket.write("ERR: 1 " + err + "\n");
+ socket.end();
+ })
+
+}
diff --git a/data/backend/list.js b/data/backend/list.js
new file mode 100644
index 0000000000000000000000000000000000000000..6a93f9d31edbb7a0acc919f212cf291023e732ed
--- /dev/null
+++ b/data/backend/list.js
@@ -0,0 +1,109 @@
+
+const cheerio = require("cheerio");
+const { domain, fetchOptions } = require("./common");
+const fetch = require("node-fetch");
+
+module.exports.getList = function (args, socket) {
+ let [isExact, fromYear, toYear, lang, ext, order, query, page] = args;
+
+ let listURL = [domain + "/s/?"];
+ if (isExact && isExact === "1") listURL.push("e=1");
+ if (fromYear && fromYear !== "Any") listURL.push("yearFrom=" + fromYear);
+ if (toYear && toYear !== "Any") listURL.push("yearTo=" + toYear);
+ if (lang && lang !== "Any") listURL.push("language=" + lang);
+ if (ext && ext !== "Any") listURL.push("extensiont=" + ext);
+
+ if (order) {
+ order = ({
+ "Best Match": "bestmatch",
+ "By Title (A-Z)": "titleA",
+ "By Title (Z-A)": "title",
+ "By Year": "year",
+ "File Size Asc.": "filesizeA",
+ "File Size Des.": "filesize",
+ "Most Popular": "popular",
+ "Recently added": "date",
+ })[order];
+
+ if (!order) order = "popular";
+ listURL.push("order=" + order);
+ }
+
+ if (query) listURL.push("q=" + encodeURI(query));
+
+ if (listURL.length < 2) {
+ // socket.write("[]");
+ socket.write("ERR: Not enough query parameter\n");
+ return;
+ }
+
+ if (page) listURL.push("page=" + page);
+
+ listURL = listURL.join("&");
+ fetchList(listURL, socket);
+}
+
+module.exports.getSaved = function(_, socket) {
+ fetchList(domain + "/users/saved_books.php", socket);
+}
+
+function fetchList(listURL, socket) {
+ fetch(listURL, fetchOptions).then(res => {
+ const fileLength = parseInt(res.headers.get('content-length'));
+
+ let raw = "";
+
+ res.body.on("data", (chunk) => {
+ raw += chunk;
+ socket.write("PROG:" + Math.round(res.body.bytesWritten / fileLength * 100).toString() + "\n");
+ });
+
+ res.body.on('end', () => {
+ socket.write("PROG:100\n");
+ sendResult(raw);
+ });
+
+ res.body.on("error", (err) => {
+ socket.write("ERR: 2 " + err + "\n");
+ socket.end();
+ });
+ })
+ .catch(err => {
+ socket.write("ERR: 1 " + err + "\n");
+ socket.end();
+ });
+
+ function sendResult(html) {
+ const $ = cheerio.load(html);
+
+ let totalItems = $(".totalCounter")
+ if (totalItems) {
+ totalItems = parseInt(totalItems.text().replace(/[()+]/g, ""));
+ socket.write("TOTAL:" + totalItems.toString() + "\n");
+ }
+
+ const books = $(".resItemBoxBooks").get().map(ele => {
+ const image = $(ele).find('img');
+ let imageUrl;
+ let imgSources = image.attr('data-srcset');
+ if (imgSources) {
+ imgSources = imgSources.split(", ");
+ imageUrl = imgSources[imgSources.length - 1]
+ .split(" ")[0];
+ } else {
+ imageUrl = image.attr('data-src');
+ }
+ if (!imageUrl || imageUrl[0] === "/") imageUrl = "";
+
+ return {
+ url: $(ele).find('h3 a').attr('href'),
+ img: imageUrl,
+ name: $(ele).find('h3').text().trim(),
+ author: $(ele).find('div.authors').text().trim(),
+ }
+ });
+ socket.write(JSON.stringify(books));
+ socket.write("\n");
+ socket.end();
+ }
+}
\ No newline at end of file
diff --git a/data/backend/metadata.js b/data/backend/metadata.js
new file mode 100644
index 0000000000000000000000000000000000000000..61ef3a6c564fc48513eda44f571a82deb09c2fef
--- /dev/null
+++ b/data/backend/metadata.js
@@ -0,0 +1,60 @@
+const cheerio = require("cheerio");
+const { domain, fetchOptions } = require("./common");
+const fetch = require("node-fetch");
+
+module.exports = function (args, socket) {
+ if (args.length < 1) {
+ console.log("ERR: No link");
+ return;
+ }
+
+ fetch(domain + args[0], fetchOptions).then(a => a.text()).then(html => {
+ const $ = cheerio.load(html);
+
+ const author = $(`[itemprop="author"]`)
+ .toArray()
+ .map(e => $(e).text().trim())
+ .join(", ");
+
+ let description = $("#bookDescriptionBox").html();
+
+ let detail = $(".bookDetailsBox");
+ if (detail) {
+ detail = $(detail[0]).find(".bookProperty")
+ .toArray()
+ .map(e => `${$(e).find(".property_label").text().trim()} ${$(e).find(".property_value").text().trim()}`)
+ .join(" | ");
+ }
+
+ if (description) {
+ description = detail + "
" + description.trim();
+ } else {
+ description = detail;
+ }
+
+ let dlUrl = $(".dlButton").attr("href");
+ if (dlUrl === "#") {
+ dlUrl = "";
+ }
+
+ const similars = $("#bMosaicBox .brick").get().map(a => ({
+ url: $(a).find("a").attr("href"),
+ img: $(a).find("img").attr("src"),
+ }));
+
+ socket.write(JSON.stringify({
+ name: $("h1").text().trim(),
+ author,
+ img: $(".details-book-cover").attr("href"),
+ description,
+ dlUrl,
+ similars,
+ }));
+ socket.write("\n");
+ socket.end();
+ })
+ .catch(err => {
+ socket.write("ERR: 1 " + err + "\n");
+ socket.end();
+ });
+}
diff --git a/data/backend/package-lock.json b/data/backend/package-lock.json
new file mode 100644
index 0000000000000000000000000000000000000000..0dd7c48e17dca86af55d15dbabcc52f28ec14160
--- /dev/null
+++ b/data/backend/package-lock.json
@@ -0,0 +1,136 @@
+{
+ "name": "zshelf-backend",
+ "version": "1.0.0",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "boolbase": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
+ "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
+ },
+ "cheerio": {
+ "version": "1.0.0-rc.5",
+ "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.5.tgz",
+ "integrity": "sha512-yoqps/VCaZgN4pfXtenwHROTp8NG6/Hlt4Jpz2FEP0ZJQ+ZUkVDd0hAPDNKhj3nakpfPt/CNs57yEtxD1bXQiw==",
+ "requires": {
+ "cheerio-select-tmp": "^0.1.0",
+ "dom-serializer": "~1.2.0",
+ "domhandler": "^4.0.0",
+ "entities": "~2.1.0",
+ "htmlparser2": "^6.0.0",
+ "parse5": "^6.0.0",
+ "parse5-htmlparser2-tree-adapter": "^6.0.0"
+ }
+ },
+ "cheerio-select-tmp": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/cheerio-select-tmp/-/cheerio-select-tmp-0.1.1.tgz",
+ "integrity": "sha512-YYs5JvbpU19VYJyj+F7oYrIE2BOll1/hRU7rEy/5+v9BzkSo3bK81iAeeQEMI92vRIxz677m72UmJUiVwwgjfQ==",
+ "requires": {
+ "css-select": "^3.1.2",
+ "css-what": "^4.0.0",
+ "domelementtype": "^2.1.0",
+ "domhandler": "^4.0.0",
+ "domutils": "^2.4.4"
+ }
+ },
+ "css-select": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/css-select/-/css-select-3.1.2.tgz",
+ "integrity": "sha512-qmss1EihSuBNWNNhHjxzxSfJoFBM/lERB/Q4EnsJQQC62R2evJDW481091oAdOr9uh46/0n4nrg0It5cAnj1RA==",
+ "requires": {
+ "boolbase": "^1.0.0",
+ "css-what": "^4.0.0",
+ "domhandler": "^4.0.0",
+ "domutils": "^2.4.3",
+ "nth-check": "^2.0.0"
+ }
+ },
+ "css-what": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/css-what/-/css-what-4.0.0.tgz",
+ "integrity": "sha512-teijzG7kwYfNVsUh2H/YN62xW3KK9YhXEgSlbxMlcyjPNvdKJqFx5lrwlJgoFP1ZHlB89iGDlo/JyshKeRhv5A=="
+ },
+ "dom-serializer": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.2.0.tgz",
+ "integrity": "sha512-n6kZFH/KlCrqs/1GHMOd5i2fd/beQHuehKdWvNNffbGHTr/almdhuVvTVFb3V7fglz+nC50fFusu3lY33h12pA==",
+ "requires": {
+ "domelementtype": "^2.0.1",
+ "domhandler": "^4.0.0",
+ "entities": "^2.0.0"
+ }
+ },
+ "domelementtype": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.1.0.tgz",
+ "integrity": "sha512-LsTgx/L5VpD+Q8lmsXSHW2WpA+eBlZ9HPf3erD1IoPF00/3JKHZ3BknUVA2QGDNu69ZNmyFmCWBSO45XjYKC5w=="
+ },
+ "domhandler": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.0.0.tgz",
+ "integrity": "sha512-KPTbnGQ1JeEMQyO1iYXoagsI6so/C96HZiFyByU3T6iAzpXn8EGEvct6unm1ZGoed8ByO2oirxgwxBmqKF9haA==",
+ "requires": {
+ "domelementtype": "^2.1.0"
+ }
+ },
+ "domutils": {
+ "version": "2.4.4",
+ "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.4.4.tgz",
+ "integrity": "sha512-jBC0vOsECI4OMdD0GC9mGn7NXPLb+Qt6KW1YDQzeQYRUFKmNG8lh7mO5HiELfr+lLQE7loDVI4QcAxV80HS+RA==",
+ "requires": {
+ "dom-serializer": "^1.0.1",
+ "domelementtype": "^2.0.1",
+ "domhandler": "^4.0.0"
+ }
+ },
+ "entities": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz",
+ "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w=="
+ },
+ "htmlparser2": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.0.0.tgz",
+ "integrity": "sha512-numTQtDZMoh78zJpaNdJ9MXb2cv5G3jwUoe3dMQODubZvLoGvTE/Ofp6sHvH8OGKcN/8A47pGLi/k58xHP/Tfw==",
+ "requires": {
+ "domelementtype": "^2.0.1",
+ "domhandler": "^4.0.0",
+ "domutils": "^2.4.4",
+ "entities": "^2.0.0"
+ }
+ },
+ "node-fetch": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
+ "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
+ },
+ "nth-check": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz",
+ "integrity": "sha512-i4sc/Kj8htBrAiH1viZ0TgU8Y5XqCaV/FziYK6TBczxmeKm3AEFWqqF3195yKudrarqy7Zu80Ra5dobFjn9X/Q==",
+ "requires": {
+ "boolbase": "^1.0.0"
+ }
+ },
+ "parse5": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
+ "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
+ },
+ "parse5-htmlparser2-tree-adapter": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz",
+ "integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==",
+ "requires": {
+ "parse5": "^6.0.1"
+ }
+ },
+ "uuid": {
+ "version": "8.3.2",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
+ "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
+ }
+ }
+}
diff --git a/data/backend/package.json b/data/backend/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..6e6789de99293e80d419172aa8810f586f1c2d03
--- /dev/null
+++ b/data/backend/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "zshelf-backend",
+ "version": "1.0.0",
+ "description": "",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "khanhas",
+ "license": "MIT",
+ "dependencies": {
+ "cheerio": "^1.0.0-rc.5",
+ "node-fetch": "^2.6.1",
+ "uuid": "^8.3.2"
+ }
+}
diff --git a/data/backend/server.js b/data/backend/server.js
new file mode 100644
index 0000000000000000000000000000000000000000..627a0c8a90f9682d7b9420dc26b181b966d61b13
--- /dev/null
+++ b/data/backend/server.js
@@ -0,0 +1,45 @@
+const { execSync } = require("child_process");
+const net = require("net");
+const { getList, getSaved } = require("./list");
+const getInfo = require("./info");
+const getMeta = require("./metadata");
+const download = require("./download");
+
+const socketLocation = "/tmp/zshelf_socket";
+execSync("rm -f " + socketLocation);
+
+const server = net.createServer();
+server.listen(socketLocation, () => {
+ console.log('[SERVER] Ready');
+
+ setInterval(() => {
+ // Exit when zshelf dies
+ try { execSync("pidof zshelf"); }
+ catch { process.exit(0); }
+ }, 10000);
+});
+
+server.on("connection", (client) => {
+ console.log('[SERVER] New client');
+ client.on("data", (data) => {
+ try {
+ console.log(data.toString());
+ const raw = data.toString().split("\n");
+ const cmd = raw[0];
+ const arg = raw.splice(1);
+ switch (cmd) {
+ case "LIST": getList(arg, client); break;
+ case "INFO": getInfo(arg, client); break;
+ case "META": getMeta(arg, client); break;
+ case "DOWN": download(arg, client); break;
+ case "SAVE": getSaved(arg, client); break;
+ }
+ } catch (err) {
+ client.write("ERR: 0 " + err + "\n");
+ client.end();
+ }
+ });
+});
+
+server.on("error", (err) => console.log("ERR: " + err));
+server.on("close", () => process.exit(0));
diff --git a/data/config.json b/data/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..b4e4bceae7f2fb54edb48e9bde0189a4c919a59c
--- /dev/null
+++ b/data/config.json
@@ -0,0 +1,14 @@
+{
+ "domain": "https://b-ok.global",
+ "cookie": "",
+ "additionalBookLocation": "/home/root/Books/",
+ "defaultQuery": {
+ "exactMatch": "0",
+ "fromYear": "2020",
+ "toYear": "2021",
+ "language": "English",
+ "extension": "epub",
+ "order": "Most Popular",
+ "query": ""
+ }
+}
diff --git a/data/dist.sh b/data/dist.sh
new file mode 100644
index 0000000000000000000000000000000000000000..1e81d55e9b4c9c05d8411c4dba4c6f2d44fbdf52
--- /dev/null
+++ b/data/dist.sh
@@ -0,0 +1,18 @@
+ver=${1:?Must provide version string}
+
+make -j8
+
+if test -d dist; then
+ rm -r dist
+fi
+
+mkdir dist
+mkdir dist/zshelf
+
+cp -r backend dist/zshelf
+cp zshelf dist/zshelf
+cp config.json dist/zshelf
+cp README.md dist/zshelf
+
+cd dist
+zip -r "zshelf-reMarkable-${ver}.zip" ./zshelf/
\ No newline at end of file
diff --git a/data/fonts/MaisonNeue-Bold.ttf b/data/fonts/MaisonNeue-Bold.ttf
new file mode 100644
index 0000000000000000000000000000000000000000..99c9b0fd292df5d92149c405686b89c8410c909b
Binary files /dev/null and b/data/fonts/MaisonNeue-Bold.ttf differ
diff --git a/data/fonts/MaisonNeue-Demi.ttf b/data/fonts/MaisonNeue-Demi.ttf
new file mode 100644
index 0000000000000000000000000000000000000000..216524c4220b525a0d58424e731ee6b47eeb4675
Binary files /dev/null and b/data/fonts/MaisonNeue-Demi.ttf differ
diff --git a/data/fonts/MaisonNeue-Medium.ttf b/data/fonts/MaisonNeue-Medium.ttf
new file mode 100644
index 0000000000000000000000000000000000000000..ba171b95de876381062042cc30aa4790420d3d1b
Binary files /dev/null and b/data/fonts/MaisonNeue-Medium.ttf differ
diff --git a/data/grayImage.h b/data/grayImage.h
new file mode 100644
index 0000000000000000000000000000000000000000..731fbd3cb1a275b1deaf8fce294019c214e4adda
--- /dev/null
+++ b/data/grayImage.h
@@ -0,0 +1,71 @@
+#ifndef GRAYIMAGE_H
+#define GRAYIMAGE_H
+
+#include
+#include
+#include
+#include
+#include
+
+class AsyncImageResponse : public QQuickImageResponse
+{
+public:
+ AsyncImageResponse(const QString &id, const QSize &requestedSize)
+ : m_id(id), m_requestedSize(requestedSize)
+ {
+ connect(&netManager, &QNetworkAccessManager::finished, this, [this](QNetworkReply *rep) {
+ rep->deleteLater();
+ if (rep->error() != QNetworkReply::NoError)
+ {
+ qDebug() << "[NET] ERR: " << rep->errorString();
+ emit finished();
+ return;
+ }
+
+ QByteArray bytes = rep->readAll();
+ QImage img = QImage::fromData(bytes).convertToFormat(QImage::Format_Grayscale8);
+
+ _img = QImage(img.size(), QImage::Format_ARGB32);
+ _img.fill(Qt::transparent);
+ QPainter p(&_img);
+ p.setBrush(QBrush(img));
+ p.setPen(Qt::NoPen);
+ qreal radius = 8.0;
+ if (img.width() > 200) {
+ p.setRenderHint(QPainter::Antialiasing, true);
+ radius = 16.0;
+ }
+ p.drawRoundedRect(1, 1, img.width() - 2, img.height() - 2, radius, radius);
+ p.end();
+
+ emit finished();
+ });
+
+ netManager.get(QNetworkRequest(m_id));
+ }
+
+ QQuickTextureFactory *textureFactory() const
+ {
+ return QQuickTextureFactory::textureFactoryForImage(_img);
+ }
+
+private:
+ QImage _img;
+ QString m_id;
+ QSize m_requestedSize;
+ QNetworkAccessManager netManager;
+};
+
+class GrayImageProvider : public QQuickAsyncImageProvider
+{
+public:
+ GrayImageProvider() {}
+
+ QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override
+ {
+ AsyncImageResponse *response = new AsyncImageResponse(id, requestedSize);
+ return response;
+ }
+};
+
+#endif /* GRAYIMAGE_H */
\ No newline at end of file
diff --git a/data/main.cpp b/data/main.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..988bad06c29cea3ab015fbd1b453522a0ac68369
--- /dev/null
+++ b/data/main.cpp
@@ -0,0 +1,44 @@
+#include
+#include
+#include
+#include "store.h"
+#include "quickvirtualkeyboard/register.h"
+#include "grayImage.h"
+
+Q_IMPORT_PLUGIN(QsgEpaperPlugin)
+
+int main(int argc, char *argv[])
+{
+ qputenv("QMLSCENE_DEVICE", "epaper");
+ qputenv("QT_QPA_PLATFORM", "epaper:enable_fonts");
+ qputenv("QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS", "rotate=180");
+
+ QGuiApplication app(argc, argv);
+
+ Store view;
+ qmlRegisterType();
+
+ auto context = view.rootContext();
+ context->setContextProperty("screenGeometry", app.primaryScreen()->geometry());
+ context->setContextProperty("store", &view);
+ context->setContextProperty("storeProg", QVariant(0));
+ context->setContextProperty("storeError", QVariant(""));
+ context->setContextProperty("titleVisible", QVariant(true));
+
+ QFontDatabase::addApplicationFont(":/fonts/MaisonNeue-Bold");
+ QFontDatabase::addApplicationFont(":/fonts/MaisonNeue-Demi");
+ QFontDatabase::addApplicationFont(":/fonts/MaisonNeue-Medium");
+
+ view.engine()->addImportPath(QStringLiteral(DEPLOYMENT_PATH));
+ view.engine()->addImageProvider(QLatin1String("gray"), new GrayImageProvider);
+ registerQmlTypes();
+ view.setSource(QUrl(QStringLiteral("qrc:/Main.qml")));
+
+ QObject::connect(view.engine(), &QQmlEngine::quit, &QGuiApplication::quit);
+ QObject::connect(&app, &QCoreApplication::aboutToQuit, [&view]() { delete &view; });
+
+ view.show();
+ view.open();
+
+ return app.exec();
+}
diff --git a/data/qml.qrc b/data/qml.qrc
new file mode 100644
index 0000000000000000000000000000000000000000..e0b84a8c36ccca36a63005f6b235781f419e3997
--- /dev/null
+++ b/data/qml.qrc
@@ -0,0 +1,30 @@
+
+
+ qml/Main.qml
+ qml/BookPopup.qml
+ qml/Query.qml
+ qml/Filter.qml
+ qml/FlatButton.qml
+ qml/DownloadPopup.qml
+ qml/loading.png
+ qml/search.png
+ qml/searchblack.png
+ qml/book.png
+ qml/bookmark.png
+ qml/title.svg
+ fonts/MaisonNeue-Bold.ttf
+ fonts/MaisonNeue-Demi.ttf
+ fonts/MaisonNeue-Medium.ttf
+
+ quickvirtualkeyboard/qml/Btn.qml
+ quickvirtualkeyboard/qml/BtnPreview.qml
+ quickvirtualkeyboard/qml/modes/Standard.qml
+ quickvirtualkeyboard/qml/modes/Symbols.qml
+ quickvirtualkeyboard/qml/modes/Symbols2.qml
+
+ quickvirtualkeyboard/png/shiftblack.png
+ quickvirtualkeyboard/png/shiftwhite.png
+ quickvirtualkeyboard/png/backspaceblack.png
+ quickvirtualkeyboard/png/backspacewhite.png
+
+
diff --git a/data/qml/BookPopup.qml b/data/qml/BookPopup.qml
new file mode 100644
index 0000000000000000000000000000000000000000..07d9e0759aaada588879c39aa4e924943027dd85
--- /dev/null
+++ b/data/qml/BookPopup.qml
@@ -0,0 +1,208 @@
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+import QtQuick.Layouts 1.11
+
+Popup {
+ property var model;
+ property bool isBusy;
+
+ id: bookPopup
+
+ width: 1000
+ height: 1300
+ x: (parent.width / 2) - (width / 2)
+ y: (parent.height / 2) - (height / 2) + 150
+ closePolicy: Popup.CloseOnPressOutside
+ dim: true
+ padding: 40
+
+ Overlay.modeless: Rectangle {
+ color: "#90ffffff"
+ MouseArea {
+ anchors.fill: parent
+ }
+ }
+
+ background: Rectangle {
+ border.width: 2
+ border.color: "black"
+ radius: 5
+ }
+
+ onOpened: bar.currentIndex = 0;
+
+ contentChildren: [
+ Image {
+ id: bookImage
+ fillMode: Image.PreserveAspectFit
+ smooth: true
+ source: model ? model.imgFile : ""
+ width: 400
+ height: 400 * 1.5
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: -(parent.height / 2 - height / 2)
+ ProgressBar {
+ visible: parent.progress < 1.0
+ value: parent.progress
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ bottom: parent.bottom
+ bottomMargin: 80
+ }
+ }
+ },
+ Text {
+ id: bookName
+ text: model ? model.name : ""
+ anchors {
+ left: parent.left; right: parent.right
+ top: bookImage.bottom
+ topMargin: 30
+ }
+ font.family:"Maison Neue"
+ font.styleName: "Bold"
+ font.pixelSize: 40
+ wrapMode: Text.Wrap
+ horizontalAlignment: Text.AlignHCenter
+ },
+ Text {
+ id: bookAuthor
+ text: model ? model.author : ""
+ anchors {
+ left: parent.left; right: parent.right
+ top: bookName.bottom
+ topMargin: 20
+ }
+ font.family:"Maison Neue"
+ font.styleName: "Medium"
+ font.pixelSize: 35
+ wrapMode: Text.Wrap
+ horizontalAlignment: Text.AlignHCenter
+ },
+ TabBar {
+ id: bar
+ visible: !isBusy
+ anchors {
+ left: parent.left; right: parent.right
+ top: bookAuthor.bottom
+ topMargin: 30
+ }
+ font.pixelSize: 25
+ TabButton {
+ contentItem: Label {
+ text: "Details"
+ color: bar.currentIndex == 0 ? "black" : "gray"
+ font.underline: bar.currentIndex == 0
+ horizontalAlignment: Text.AlignHCenter
+ }
+ background: Rectangle {}
+ }
+ TabButton {
+ contentItem: Label {
+ text: "Similar books"
+ color: bar.currentIndex == 1 ? "black" : "gray"
+ font.underline: bar.currentIndex == 1
+ horizontalAlignment: Text.AlignHCenter
+ }
+ background: Rectangle {}
+ }
+ },
+ StackLayout {
+ id: stack
+ anchors {
+ left: parent.left; right: parent.right
+ top: bar.bottom
+ topMargin: 30
+ bottom: parent.bottom
+ bottomMargin: 30
+ }
+ currentIndex: bar.currentIndex
+ Item {
+ Flickable {
+ anchors.fill: parent
+ contentHeight: bookDesc.height
+ clip: true
+ flickableDirection: Flickable.VerticalFlick
+ boundsBehavior: Flickable.StopAtBounds
+
+ Text {
+ id: bookDesc
+ textFormat: Text.RichText
+ text: model ? model.desc : ""
+ font.family:"EB Garamond"
+ font.styleName: "Medium"
+ font.pixelSize: 30
+ width: parent.width
+ wrapMode: Text.Wrap
+ }
+ }
+ }
+ Item {
+ GridView {
+ id: recGrid
+ anchors.fill: parent
+ boundsBehavior: Flickable.StopAtBounds
+ cellHeight: stack.height / 2
+ cellWidth: cellHeight / 1.5
+ model: bookPopup.model ? bookPopup.model.similars : []
+ flickableDirection: Flickable.HorizontalFlick
+ flow: GridView.TopToBottom
+ clip: true
+ snapMode: GridView.SnapToRow
+ flickDeceleration: 0
+ delegate: Item {
+ id: itemRoot
+ width: recGrid.cellWidth
+ height: recGrid.cellHeight
+ Image {
+ id: image
+ fillMode: Image.PreserveAspectCrop
+ source: model.modelData.imgFile || "png/book"
+ anchors.fill: itemRoot
+ anchors.margins: 10
+ Image {
+ visible: image.status === Image.Error
+ source: "png/book"
+ width: 52; height: 52
+ anchors.centerIn: parent
+ }
+ }
+ MouseArea {
+ anchors.fill: itemRoot
+ onClicked: {
+ model.modelData.getDetail(bookPopup);
+ bar.currentIndex = 0;
+ bookPopup.model = model.modelData;
+ }
+ }
+ }
+ }
+ }
+ },
+ Image {
+ z: 1
+ source: "png/loading"
+ visible: isBusy
+ width: 60
+ height: 60
+ anchors.centerIn: parent
+ }
+ ]
+
+ FlatButton {
+ id: download
+ visible: !isBusy
+ width: 300
+ x: parent.width - 220
+ y: parent.height - 5
+ bgColor: "black"
+ fgColor: "white"
+ text: !model || !model.dlUrl ? "Unavailable" : model.status
+ onTapped: {
+ if(!model || !model.dlUrl || model.status !== "Download") {
+ return
+ }
+ store.download(model);
+ }
+ }
+}
\ No newline at end of file
diff --git a/data/qml/DownloadPopup.qml b/data/qml/DownloadPopup.qml
new file mode 100644
index 0000000000000000000000000000000000000000..72403d63e47ff05691d6b5e380b9e6c84df3a72e
--- /dev/null
+++ b/data/qml/DownloadPopup.qml
@@ -0,0 +1,132 @@
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+import QtQuick.Layouts 1.11
+
+Popup {
+ id: downloadPopup
+ width: 500
+ height: store.downloadList.length ? Math.min(listView.contentHeight + 10, 1000) : 130
+ x: accountStatus.x + accountStatus.width - 500 + screenMargin
+ y: accountStatus.y + accountStatus.height + 60
+
+ leftPadding: 20; rightPadding: 20
+ topPadding: 5; bottomPadding: 5
+
+ closePolicy: Popup.CloseOnPressOutside
+ dim: true
+ Overlay.modeless: Rectangle {
+ color: "transparent"
+ MouseArea {
+ anchors.fill: parent
+ }
+ }
+ background: Rectangle {
+ anchors.fill: parent
+ color: "white"
+ border.width: 3
+ border.color: "black"
+ radius: 5
+ }
+
+ Rectangle {
+ visible: store.downloadList.length == 0
+ width: parent.width
+ height: 120
+ Text {
+ id: quote
+ text: "“ A room without books is like\na body without a soul.”"
+ font.family: "Maison Neue"
+ font.styleName: "Medium"
+ font.italic: true
+ font.pixelSize: 22
+ horizontalAlignment: Text.AlignRight
+ anchors {
+ top: parent.top
+ right: parent.right
+ topMargin: 25
+ rightMargin: 80
+ }
+ }
+ Text {
+ text: "— Cicero"
+ font.family: "Maison Neue"
+ font.styleName: "Bold"
+ font.pixelSize: 22
+ anchors.top: quote.bottom
+ anchors.topMargin: 10
+ anchors.right: quote.right
+ horizontalAlignment: Text.AlignRight
+ }
+ }
+
+ ListView {
+ id: listView
+ width: 500 - parent.padding * 2
+ anchors.fill: parent
+ model: store.downloadList
+ clip: true
+ boundsBehavior: Flickable.StopAtBounds
+ flickableDirection: Flickable.VerticalFlick
+ flickDeceleration: 0
+
+ delegate: Item {
+ id: root
+ width: parent.width
+ height: 120
+ Rectangle {
+ id: wrapper
+ width: parent.width
+ height: parent.height
+ anchors {
+ left: parent.left
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ }
+ Text {
+ id: name
+ text: model.modelData.name
+ font.family: "Maison Neue"
+ font.styleName: "Medium"
+ font.pixelSize: 22
+ width: 350
+ maximumLineCount: 2
+ wrapMode: Text.Wrap
+ anchors.verticalCenter: parent.verticalCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ Text {
+ id: downloadStatusText
+ visible: model.modelData.status === "Downloaded" ||
+ model.modelData.status.endsWith("%")
+ text: model.modelData.status === "Downloaded" ? "↓ " : model.modelData.status
+ color: "black"
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ font.family:"Maison Neue"
+ font.styleName: "Bold"
+ font.pixelSize: 30
+ }
+ Rectangle {
+ color: "gray"
+ width: parent.width
+ height: 1
+ anchors.bottom: parent.bottom
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ model.modelData.getDetail(itemInfo);
+ itemInfo.model = model.modelData;
+ downloadPopup.close();
+ itemInfo.open();
+ }
+ onPressAndHold: {
+ return;
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/data/qml/Filter.qml b/data/qml/Filter.qml
new file mode 100644
index 0000000000000000000000000000000000000000..1e585cba0324922b1fecf068f9ee7d5bc1a9e3ab
--- /dev/null
+++ b/data/qml/Filter.qml
@@ -0,0 +1,102 @@
+import QtQuick 2.5
+import QtQuick.Controls 2.4
+
+Item {
+ id: root
+ signal activated(int index);
+ property alias model: combo.model
+ property alias text: name.text
+ property alias curIndex: combo.currentIndex
+
+ function setDefault(value) {
+ const id = combo.find(value, Qt.MatchExactly);
+ if (id !== -1) combo.currentIndex = id;
+ else combo.currentIndex = 0;
+ }
+
+ function reset() {
+ combo.currentIndex = 0;
+ }
+
+ function value() {
+ return combo.currentText;
+ }
+
+ height: 100
+
+ Text {
+ id: name
+ font.pixelSize: 35
+ font.family: "Maison Neue"
+ font.styleName: "Bold"
+ }
+ ComboBox {
+ id: combo
+ anchors {
+ top: name.bottom
+ topMargin: 20
+ }
+ width: parent.width
+ height: 60
+
+ font.family: "Maison Neue"
+ font.styleName: "light"
+
+ background: Rectangle {
+ border.width: 2
+ border.color: "black"
+ color: "white"
+ radius: 2
+ }
+ contentItem: Label {
+ text: parent.currentText
+ anchors {
+ left: parent.left
+ leftMargin: 15
+ verticalCenter: parent.verticalCenter
+ verticalCenterOffset: 2
+ }
+ verticalAlignment: Text.AlignVCenter
+ color: "black"
+ }
+
+ delegate: ItemDelegate {
+ width: root.width - 25
+ contentItem: Text {
+ text: modelData
+ color: "black"
+ font.family: "Maison Neue"
+ font.styleName: "light"
+ font.bold: combo.highlightedIndex === index
+ verticalAlignment: Text.AlignVCenter
+ }
+ }
+
+ popup: Popup {
+ readonly property int columns: combo.model.length > 12 ? 2 : 1
+ y: combo.height + 20
+ width: root.width * columns
+ implicitHeight: Math.min(contentItem.contentHeight + 20, 800)
+ clip: true
+
+ contentItem: GridView {
+ id: grid
+ flow: GridView.FlowLeftToRight
+ model: combo.popup.visible ? combo.delegateModel : null
+ currentIndex: combo.highlightedIndex
+ cellWidth: root.width - 15
+ cellHeight: combo.height
+
+ ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
+ }
+
+ background: Rectangle {
+ border.color: "black"
+ border.width: 2
+ radius: 3
+ }
+ }
+
+ onActivated: parent.activated(index);
+ }
+}
\ No newline at end of file
diff --git a/data/qml/FlatButton.qml b/data/qml/FlatButton.qml
new file mode 100644
index 0000000000000000000000000000000000000000..14d53f39227009176de3df6e9b4a2874091d9b6d
--- /dev/null
+++ b/data/qml/FlatButton.qml
@@ -0,0 +1,36 @@
+import QtQuick 2.5
+import QtQuick.Controls 2.4
+
+Item {
+ signal tapped;
+ property alias bgColor: button.color
+ property alias fgColor: name.color
+ property alias text: name.text
+ property int borderWidth: 0
+
+ Rectangle {
+ id: button
+ width: parent.width
+ height: 80
+ radius: 3
+ border.color: name.color
+ border.width: borderWidth
+
+ MouseArea {
+ id: click
+ anchors.fill: parent
+ onClicked: tapped()
+ }
+ }
+
+ Text {
+ id: name
+ anchors.centerIn: button
+ anchors.verticalCenterOffset: 2
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.family: "Maison Neue"
+ font.styleName: "Bold"
+ font.pixelSize: 30
+ }
+}
\ No newline at end of file
diff --git a/data/qml/Main.qml b/data/qml/Main.qml
new file mode 100644
index 0000000000000000000000000000000000000000..f9cd32c0624413b4ee2f3a8f9f1d06a29486ead1
--- /dev/null
+++ b/data/qml/Main.qml
@@ -0,0 +1,462 @@
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+import QtQuick.Layouts 1.11
+
+Rectangle {
+ id: canvas
+ width: screenGeometry.width
+ height: screenGeometry.height
+ readonly property int screenMargin: 40
+ readonly property int columns: 4
+ readonly property int rows: 3
+ readonly property int itemPerPage: rows * columns
+ readonly property int bookWidth: (width - screenMargin * 2) / columns
+ readonly property int itemContentWidth: bookWidth - 20
+
+ Rectangle {
+ id: title
+ visible: titleVisible
+ z: 3
+ anchors.fill: parent
+ color: "white"
+ Image {
+ id: titleImg
+ source: "svg/title"
+ anchors.centerIn: parent
+ }
+ }
+
+ Rectangle {
+ id: closeApp
+ anchors.top: parent.top
+ anchors.right: parent.right
+ anchors.margins: screenMargin
+ width: 80
+ height: 80
+ radius: 40
+ z: 1
+ color: "black"
+ Text {
+ text: "x"
+ font.family: "Maison Neue"
+ font.bold: true
+ font.pixelSize:40
+ color: "white"
+ anchors.centerIn: parent
+ anchors.topMargin: 10
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+
+
+ Rectangle {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.margins: 40
+ height: 100
+
+ Rectangle {
+ width: 150
+ height: 80
+
+ Image {
+ source: "png/searchblack"
+ width: 80
+ height: 80
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: queryUI.openSearch(true);
+ }
+ }
+ Rectangle {
+ id: savedList
+ width: 60
+ height: 60
+ border.color: "black"
+ border.width: 2
+ radius: 30
+ color: "white"
+ anchors {
+ right: parent.right
+ rightMargin: 120
+ top: parent.top
+ topMargin: 10
+ }
+ Image {
+ source: "png/bookmark"
+ anchors.centerIn: parent
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: store.openSavedList(0)
+ }
+ }
+ Rectangle {
+ id: accountStatus
+ width: accountStatusText.contentWidth + 60
+ height: 60
+ visible: store.accountStatus.length > 0
+ border.color: "black"
+ border.width: 2
+ radius: 30
+ color: "white"
+ anchors {
+ right: savedList.left
+ rightMargin: 30
+ top: parent.top
+ topMargin: 10
+ }
+ Text {
+ id: accountStatusText
+ text: store.accountStatus
+ color: "black"
+ font.pixelSize: 25
+ font.family:"Maison Neue"
+ font.styleName: "Medium"
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: 2
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: downloadList.open()
+ }
+ }
+ }
+
+ GridView {
+ id: libView
+ objectName: "libView"
+ anchors.fill: parent
+ anchors.margins: screenMargin
+ anchors.topMargin: 140
+
+ boundsBehavior: Flickable.StopAtBounds
+ cellWidth: bookWidth
+ cellHeight: bookWidth * 1.5 + 30
+ model: store.books
+ flickableDirection: Flickable.HorizontalFlick
+ flow: GridView.TopToBottom
+ clip: true
+ snapMode: GridView.SnapToRow
+ flickDeceleration: 0
+ onMovementEnded: currentIndex = indexAt(contentX, 0)
+
+ delegate: Item {
+ id: root
+ width: libView.cellWidth
+ height: libView.cellHeight
+
+ Rectangle {
+ id: background
+ color: "white"
+ anchors.fill: parent
+ }
+ Text {
+ id: author
+ text: model.modelData.author
+ font.family:"Maison Neue"
+ font.styleName: "Demi"
+ font.pixelSize:25
+ width: itemContentWidth
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 50
+ anchors.horizontalCenter: parent.horizontalCenter
+ horizontalAlignment: Text.AlignHCenter
+ maximumLineCount: 1
+ wrapMode: Text.Wrap
+ }
+ Text {
+ id: name
+ text: model.modelData.name
+ font.family:"Maison Neue"
+ font.styleName: "Bold"
+ font.pixelSize:25
+ width: itemContentWidth
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: author.top
+ anchors.bottomMargin: 5
+ horizontalAlignment: Text.AlignHCenter
+ maximumLineCount: 2
+ wrapMode: Text.Wrap
+ }
+ Image {
+ id: image
+ fillMode: Image.PreserveAspectFit
+ width: 200
+ source: model.modelData.imgFile || "png/book"
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: -60
+ Image {
+ visible: image.status === Image.Error
+ source: "png/book"
+ width: 52; height: 52
+ anchors.centerIn: parent
+ }
+ }
+
+ Rectangle {
+ id: downloadStatus
+ visible: model.modelData.status === "Downloaded" ||
+ model.modelData.status.endsWith("%")
+ anchors.top: parent.top
+ anchors.right: parent.right
+ width: Math.max(40, downloadStatusText.contentWidth + 20)
+ height: 40
+ color: "black"
+
+ Text {
+ id: downloadStatusText
+ text: model.modelData.status === "Downloaded" ? "↓" : model.modelData.status
+ color: "white"
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: 2
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.family:"Maison Neue"
+ font.styleName: "Medium"
+ font.pixelSize:25
+ }
+ }
+
+ MouseArea {
+ anchors.fill: root
+ onPressed: {
+ background.color = "black"
+ name.color = "white"
+ author.color = "white"
+ }
+ onReleased: {
+ background.color = "white"
+ name.color = "black"
+ author.color = "black"
+ }
+ onCanceled: {
+ background.color = "white"
+ name.color = "black"
+ author.color = "black"
+ }
+ onClicked: {
+ model.modelData.getDetail(itemInfo);
+ itemInfo.model = model.modelData;
+ itemInfo.open();
+ }
+ onPressAndHold: {
+ return;
+ }
+ }
+ }
+ }
+
+ Row {
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.leftMargin: screenMargin
+ anchors.bottomMargin: screenMargin + 10
+ Repeater {
+ model: store.pages
+ Rectangle {
+ width: 100; height: 60
+ Rectangle {
+ id: bg
+ width: 80; height: 60
+ border.width: store.currentPage == index ? 2 : 0
+ border.color: "black"
+ radius: 30
+ color: "white"
+ }
+ Text {
+ text: modelData
+ anchors.centerIn: bg
+ anchors.verticalCenterOffset: 2
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.family: "Maison Neue"
+ font.styleName: "Medium"
+ font.pixelSize: 20
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (store.currentPage == index) {
+ return;
+ }
+ store.newQuery(index);
+ }
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ property bool isClickable: (libView.currentIndex + itemPerPage) < libView.count
+ id: goRight
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ anchors.margins: screenMargin
+ width: 80; height: 80; radius: 40
+ color: isClickable ? "black" : "gray"
+ Text {
+ text: "v"
+ font.family: "Maison Neue"
+ font.bold: true
+ font.pixelSize:40
+ color: "white"
+ anchors.centerIn: parent
+ }
+ transform: Rotation {
+ origin.x: 40;
+ origin.y: 40;
+ angle: 270
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (parent.isClickable) {
+ libView.currentIndex += itemPerPage;
+ } else {
+ return;
+ }
+
+ if (libView.currentIndex >= libView.count) {
+ libView.currentIndex = libView.count - itemPerPage + libView.count % itemPerPage;
+ }
+ libView.positionViewAtIndex(libView.currentIndex, GridView.Beginning);
+ }
+ }
+ }
+
+
+ Rectangle {
+ property bool isClickable: (libView.currentIndex - itemPerPage) >= 0 ||
+ (libView.currentIndex - rows) >= 0
+ id: goLeft
+ anchors.bottom: parent.bottom
+ anchors.right: goRight.left
+ anchors.margins: screenMargin
+ width: 80; height: 80; radius: 40
+ color: isClickable ? "black" : "gray"
+ Text {
+ text: "v"
+ font.family: "Maison Neue"
+ font.bold: true
+ font.pixelSize:40
+ color: "white"
+ anchors.centerIn: parent
+ }
+ transform: Rotation {
+ origin.x: 40;
+ origin.y: 40;
+ angle: 90
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (parent.isClickable) {
+ libView.currentIndex -= itemPerPage;
+ } else {
+ return;
+ }
+
+ if (libView.currentIndex < 0) {
+ libView.currentIndex = 0
+ }
+ libView.positionViewAtIndex(libView.currentIndex, GridView.Beginning);
+ }
+ }
+ }
+
+ BookPopup {
+ id: itemInfo
+ // anchors.fill: parent
+ }
+
+ Query {
+ id: queryUI
+ anchors.fill: parent
+ z: 2
+ storeFront: store
+ }
+
+ DownloadPopup {
+ id: downloadList
+ }
+
+ Text {
+ id: errorMessage
+ text: storeError
+ font.family: "Maison Neue"
+ font.styleName: "Medium"
+ font.pixelSize: 40
+ width: 800
+ anchors.centerIn: parent
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.Wrap
+ }
+
+ Rectangle {
+ z: 4
+ visible: store.isBusy
+ color: "white"
+ width: 400; height: 200
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: 160
+
+ Rectangle {
+ id: progBarBase
+ color: "black";
+ width: 344
+ height: 2
+ anchors.top: parent.top
+ anchors.topMargin: 60
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Rectangle {
+ color: "black";
+ width: storeProg * 344
+ height: 15
+ anchors.bottom: progBarBase.bottom
+ anchors.left: progBarBase.left
+ }
+
+ onVisibleChanged: {
+ if (!visible && queryUI.visible) {
+ queryUI.visible = false;
+ }
+ }
+
+ Rectangle {
+ id: cancleButton
+ visible: !titleVisible
+ color: "black"
+ width: 200
+ height: 70
+ radius: 3
+ anchors {
+ bottom: parent.bottom
+ bottomMargin: 30
+ horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "Cancel"
+ color: "white"
+ anchors.fill: parent
+ anchors.centerIn: parent
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.family:"Maison Neue"
+ font.styleName: "Bold"
+ font.pixelSize: 30
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: store.stopQuery()
+ }
+ }
+ }
+}
diff --git a/data/qml/Query.qml b/data/qml/Query.qml
new file mode 100644
index 0000000000000000000000000000000000000000..b69ed247d14f8ddfcfdc4a193f3b49b21aae8124
--- /dev/null
+++ b/data/qml/Query.qml
@@ -0,0 +1,355 @@
+import QtQuick 2.5
+import QtQuick.Controls 2.4
+import QtQuick.Layouts 1.0
+import QuickKeyboard 1.0
+import "modes"
+
+Item {
+ property variant storeFront;
+ property bool firstOpen: true;
+
+ id: searchUI
+ visible: false
+
+ function openSearch(open) {
+ if (open) {
+ searchUI.visible = true
+ keyboard.dispatcher.setFocusObject(textInput);
+ if (firstOpen) {
+ firstOpen = false;
+ fromYear.setDefault(storeFront.fromYear);
+ toYear.setDefault(storeFront.toYear);
+ fromYear.activated(fromYear.curIndex);
+
+ language.setDefault(storeFront.language);
+ extension.setDefault(storeFront.extension);
+ order.setDefault(storeFront.order);
+ storeFront.exactMatch == "1" && exactMatch.toggle();
+ storeFront.query.length && (textInput.text = storeFront.query);
+ }
+ } else {
+ searchUI.visible = false;
+ }
+ }
+
+ function getParams() {
+ storeFront.exactMatch = exactMatch.position;
+ storeFront.fromYear = fromYear.value();
+ storeFront.toYear = toYear.value();
+ storeFront.language = language.value();
+ storeFront.extension = extension.value();
+ storeFront.order = order.value();
+ storeFront.query = textInput.text;
+ }
+
+ function sendQuery() {
+ getParams();
+ storeFront.newQuery(0);
+ }
+
+ Rectangle {
+ id: background
+ anchors.fill: parent
+
+ MouseArea {
+ anchors.fill: parent
+ }
+ }
+
+ Rectangle {
+ id: searchBox
+ color: "black"
+ height: 110
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: parent.top
+ }
+
+ Image {
+ source: "png/search"
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.leftMargin: 40
+ width: 50
+ height: 50
+ }
+
+ TextField {
+ id: textInput
+ font.pixelSize: 35
+ color: "white"
+ font.family: "Maison Neue"
+ anchors { fill: parent; verticalCenter: parent.verticalCenter; topMargin: 10 }
+ clip: true
+ verticalAlignment: Text.AlignVCenter
+ anchors.leftMargin: 120
+ anchors.rightMargin: 40 + 150
+ placeholderText: "Search for title, author, ISBN, publisher, md5..."
+ background: Rectangle {
+ anchors.fill: parent
+ color: "black"
+ }
+ }
+
+ Rectangle {
+ visible: textInput.text.length > 0
+ color: "black"
+ border.color: "white"
+ border.width: 3
+ width: 130
+ height: 50
+ radius: 4
+ anchors {
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ rightMargin: 40
+ }
+ Text {
+ text: "Clear"
+ font.pixelSize: 25
+ color: "white"
+ font.family: "Maison Neue"
+ font.bold: true
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: 2
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: textInput.text = ""
+ }
+ }
+ }
+
+ Row {
+ anchors {
+ left: parent.left
+ leftMargin: screenMargin
+ top: searchBox.bottom
+ topMargin: 30
+ }
+ spacing: 33
+
+ Filter {
+ id: fromYear
+ model: {
+ let a = ["Any"];
+ let thisYear = (new Date).getFullYear();
+ while (thisYear >= 1800) {
+ a.push(thisYear);
+ thisYear--;
+ }
+ return a;
+ }
+ width: 150
+ text: "From"
+ onActivated: {
+ let oldIndex = toYear.curIndex;
+ toYear.model = index > 0 ? fromYear.model.slice(0, index + 1) : fromYear.model;
+ if (oldIndex <= index) {
+ toYear.curIndex = oldIndex;
+ } else {
+ toYear.curIndex = index;
+ }
+ }
+ }
+
+ Filter {
+ id: toYear
+ model: fromYear.model
+ text: "To"
+ width: 150
+ }
+
+ Filter {
+ id: language
+ model: ["Any","Afrikaans","Albanian","Arabic","Armenian","Azerbaijani","Bashkir","Belarusian","Bengali","Berber","Bulgarian","Catalan","Chinese","Crimean Tatar","Croatian","Czech","Danish","Dutch","English","Esperanto","Finnish","French","Georgian","German","Greek","Gujarati","Hebrew","Hindi","Hungarian","Icelandic","Indigenous","Indonesian","Italian","Japanese","Kannada","Kazakh","Kirghiz","Korean","Latin","Latvian","Lithuanian","Malayalam","Marathi","Mongolian","Nepali","Norwegian","Odia","Persian","Polish","Portuguese","Romanian","Russian","Sanskrit","Serbian","Sinhala","Slovak","Slovenian","Somali","Spanish","Swahili","Swedish","Tajik","Tamil","Tatar","Telugu","Turkish","Ukrainian","Urdu","Uzbek","Vietnamese"]
+ text: "Language"
+ width: 350
+ }
+
+ Filter {
+ id: extension
+ model: ["Any","pdf","epub","djvu","fb2","txt","rar","mobi","lit","doc","rtf","azw3"]
+ text: "Extension"
+ width: 200
+ }
+
+ Filter {
+ id: order
+ model: [ "Most Popular", "Best Match", "Recently added", "By Title (A-Z)", "By Title (Z-A)", "By Year", "File Size Asc.", "File Size Des." ]
+ text: "Sort by"
+ width: 350
+ }
+ }
+
+ Switch {
+ id : exactMatch
+ x: screenMargin
+ y: 280
+
+ indicator: Rectangle {
+ width: 80
+ height: 40
+ y: parent.height / 2 - height / 2
+ radius: 20
+ color: exactMatch.checked ? "black" : "white"
+ border.color: "black"
+ border.width: 1
+
+ Rectangle {
+ x: exactMatch.checked ? parent.width - width : 0
+ width: 40
+ height: 40
+ radius: 20
+ color: "white"
+ border.color: "black"
+ border.width: 1
+ }
+ }
+
+ contentItem: Text {
+ text: " Exact match"
+ font.family: "Maison Neue"
+ font.bold: true
+ font.pixelSize: 35
+ color: "black"
+ height: 40
+ verticalAlignment: Text.AlignVCenter
+ }
+ }
+
+ FlatButton {
+ id: startQuery
+ width: 200
+ bgColor: "black"
+ fgColor: "white"
+ text: "Search"
+ y: 400
+ anchors {
+ right: parent.right
+ rightMargin: 40
+ }
+ onTapped: sendQuery()
+ }
+
+ FlatButton {
+ id: setDefaultQuery
+ width: 350
+ bgColor: "white"
+ fgColor: "black"
+ text: "Set as default query"
+ borderWidth: 3
+ y: 400
+ anchors {
+ left: parent.left
+ leftMargin: 40
+ }
+ onTapped: {
+ getParams();
+ storeFront.setConfig();
+
+ setDefaultQuery.text = "✔";
+ resetButtonText.start();
+ }
+ Timer {
+ id: resetButtonText
+ interval: 3000; running: false; repeat: false
+ onTriggered: setDefaultQuery.text = "Set as default query";
+ }
+ }
+
+ FlatButton {
+ id: resetFilter
+ width: 250
+ bgColor: "white"
+ fgColor: "black"
+ text: "Reset query"
+ borderWidth: 3
+ y: 400
+ anchors {
+ left: setDefaultQuery.right
+ leftMargin: 30
+ }
+ onTapped: {
+ if (exactMatch.position == 1.0)
+ exactMatch.toggle();
+
+ fromYear.reset();
+ toYear.reset();
+ language.reset();
+ extension.reset();
+ order.reset();
+ textInput.text = "";
+ }
+ }
+
+ Keyboard {
+ id: keyboard
+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
+ height: 626
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ }
+
+ mode: standard
+
+ Standard {
+ id: standard
+ anchors.fill: parent
+ anchors.topMargin: 93
+ onSymbolsModeSwitched: keyboard.mode = symbols
+ onEnter: sendQuery()
+ }
+
+ Symbols {
+ id: symbols
+ anchors.fill: parent
+ anchors.topMargin: 93
+ onStandardModeSwitched: keyboard.mode = standard
+ onSymbolsModeSwitched: keyboard.mode = symbols2
+ onEnter: sendQuery()
+ }
+
+ Symbols2 {
+ id: symbols2
+ anchors.fill: parent
+ anchors.topMargin: 93
+ onStandardModeSwitched: keyboard.mode = standard
+ onSymbolsModeSwitched: keyboard.mode = symbols
+ onEnter: sendQuery()
+ }
+ }
+
+ Rectangle {
+ id: closeSearchUI
+ width: 80
+ height: 80
+ radius: 40
+ color: "black"
+ anchors {
+ right: parent.right
+ bottom: keyboard.top
+ margins: 40
+ }
+ Text {
+ text: "v"
+ font.family: "Maison Neue"
+ font.bold: true
+ color: "white"
+ anchors.centerIn: parent
+ font.pixelSize:40
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: openSearch(false)
+ }
+ }
+
+ Item {
+ id: keyboardOverlay
+ anchors.fill: keyboard
+ }
+}
\ No newline at end of file
diff --git a/data/qml/book.png b/data/qml/book.png
new file mode 100644
index 0000000000000000000000000000000000000000..260275fb7cc865afa2a7757cc764be1d1bb0b1e4
--- /dev/null
+++ b/data/qml/book.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e9f42d6fc10f7d89a5f885aa09e90762aa24d2a73976a8604c2b3984a056f76f
+size 1190
diff --git a/data/qml/bookmark.png b/data/qml/bookmark.png
new file mode 100644
index 0000000000000000000000000000000000000000..2ed41d9bdf0ce8a5a7cb0ce651112eb69d545cf4
--- /dev/null
+++ b/data/qml/bookmark.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bb1e88fd1d420d0ff99d4b0d5d10a0f0f485cb35400a2e8c8ab2ea70e48b6266
+size 318
diff --git a/data/qml/loading.png b/data/qml/loading.png
new file mode 100644
index 0000000000000000000000000000000000000000..7714d21eaa921e1b04e1670dac887b1580e753d8
--- /dev/null
+++ b/data/qml/loading.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:495f2034db49492d4f784d071bbebb6fb68316ab0e318dda95342e25bb1dd077
+size 7218
diff --git a/data/qml/search.png b/data/qml/search.png
new file mode 100644
index 0000000000000000000000000000000000000000..fc0674847c61961e25f121ed41888691a67d3354
--- /dev/null
+++ b/data/qml/search.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:551b3e990f60df50bed1aba92ead9bcb7dc704c6eb12f64c1e0f5118c087cbc4
+size 1226
diff --git a/data/qml/searchblack.png b/data/qml/searchblack.png
new file mode 100644
index 0000000000000000000000000000000000000000..8ead07deea3e6c956082a2210ddf2d81e7a3ab55
--- /dev/null
+++ b/data/qml/searchblack.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c13783eb6513ce73a1ebae37bd881c19611fdf0f94ff65a0024d0f20612bed69
+size 1364
diff --git a/data/qml/title.svg b/data/qml/title.svg
new file mode 100644
index 0000000000000000000000000000000000000000..bd8ac94c8c7a97195d42b0defddb0e4e63378992
--- /dev/null
+++ b/data/qml/title.svg
@@ -0,0 +1,13 @@
+
diff --git a/data/quickvirtualkeyboard/AUTHORS b/data/quickvirtualkeyboard/AUTHORS
new file mode 100644
index 0000000000000000000000000000000000000000..d01cb8558690dfda10e11429587d2730f4c8855d
--- /dev/null
+++ b/data/quickvirtualkeyboard/AUTHORS
@@ -0,0 +1 @@
+Miroslav Bendík
diff --git a/data/quickvirtualkeyboard/ButtonItem.cpp b/data/quickvirtualkeyboard/ButtonItem.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6b63ff5e34e251b107101f69ef180fda1b52d486
--- /dev/null
+++ b/data/quickvirtualkeyboard/ButtonItem.cpp
@@ -0,0 +1,100 @@
+#include "ButtonItem.h"
+
+namespace QuickKeyboard
+{
+
+ButtonItem::ButtonItem(QQuickItem *parent):
+ QQuickItem(parent),
+ m_active(false),
+ m_mouseDown(false),
+ m_modifier(false),
+ m_col(0),
+ m_row(0),
+ m_colSpan(1),
+ m_rowSpan(1),
+ m_currentSymbolIndex(-1)
+{
+ connect(this, SIGNAL(symbolsChanged(const QStringList &)), SLOT(onSymbolsChanged()));
+ connect(this, SIGNAL(triggered()), SLOT(onTriggered()));
+ connect(this, SIGNAL(released()), SLOT(onReleased()));
+}
+
+ButtonItem::~ButtonItem()
+{
+}
+
+void ButtonItem::setActive(bool active)
+{
+ if (m_active == active) {
+ return;
+ }
+
+ m_active = active;
+ emit activeChanged(active);
+ emit pressedChanged(m_active || m_mouseDown);
+ setCurrentSymbolIndex(0);
+}
+
+void ButtonItem::setMouseDown(bool mouseDown)
+{
+ if (m_mouseDown == mouseDown) {
+ return;
+ }
+
+ m_mouseDown = mouseDown;
+ emit mouseDownChanged(mouseDown);
+ emit pressedChanged(m_active || m_mouseDown);
+ setCurrentSymbolIndex(0);
+}
+
+void ButtonItem::setCurrentSymbolIndex(int currentSymbolIndex)
+{
+ if (m_symbols.length() == 0) {
+ currentSymbolIndex = -1;
+ }
+ if (currentSymbolIndex == -1 && m_symbols.length() > 0) {
+ currentSymbolIndex = 0;
+ }
+
+ if (currentSymbolIndex == m_currentSymbolIndex) {
+ return;
+ }
+
+ m_currentSymbolIndex = currentSymbolIndex;
+ emit currentSymbolIndexChanged(currentSymbolIndex);
+}
+
+void ButtonItem::onSymbolsChanged()
+{
+ if (m_symbols.length() == 0) {
+ setCurrentSymbolIndex(-1);
+ }
+ else {
+ if (m_currentSymbolIndex < 0 || m_currentSymbolIndex >= m_symbols.length()) {
+ setCurrentSymbolIndex(0);
+ }
+ }
+}
+
+void ButtonItem::onTriggered()
+{
+ if (m_currentSymbolIndex < 0 || m_currentSymbolIndex >= m_symbols.length()) {
+ return;
+ }
+
+ emit symbolTriggered(m_symbols[m_currentSymbolIndex]);
+}
+
+void ButtonItem::onReleased()
+{
+ bool active = m_active;
+ if (m_modifier) {
+ setActive(!active);
+ }
+ if (isStandard() || active) {
+ emit triggered();
+ }
+}
+
+} /* QuickKeyboard */
+
diff --git a/data/quickvirtualkeyboard/ButtonItem.h b/data/quickvirtualkeyboard/ButtonItem.h
new file mode 100644
index 0000000000000000000000000000000000000000..848ae1931118d0c578b4e5766d3b95d36d024c53
--- /dev/null
+++ b/data/quickvirtualkeyboard/ButtonItem.h
@@ -0,0 +1,81 @@
+#ifndef BUTTONITEM_H_VNF1QLCU
+#define BUTTONITEM_H_VNF1QLCU
+
+#include
+#include
+
+namespace QuickKeyboard
+{
+
+class ButtonItem: public QQuickItem
+{
+Q_OBJECT
+Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged DESIGNABLE false)
+Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged DESIGNABLE false)
+Q_PROPERTY(bool mouseDown READ isMouseDown WRITE setMouseDown NOTIFY mouseDownChanged DESIGNABLE false)
+Q_PROPERTY(bool modifier MEMBER m_modifier READ isModifier NOTIFY modifierChanged DESIGNABLE false)
+Q_PROPERTY(QString label MEMBER m_label READ label NOTIFY labelChanged)
+Q_PROPERTY(QStringList symbols MEMBER m_symbols READ symbols NOTIFY symbolsChanged)
+Q_PROPERTY(int currentSymbolIndex MEMBER m_currentSymbolIndex WRITE setCurrentSymbolIndex NOTIFY currentSymbolIndexChanged)
+
+// position
+Q_PROPERTY(int col MEMBER m_col NOTIFY colChanged)
+Q_PROPERTY(int row MEMBER m_row NOTIFY rowChanged)
+Q_PROPERTY(int colSpan MEMBER m_colSpan NOTIFY colSpanChanged)
+Q_PROPERTY(int rowSpan MEMBER m_rowSpan NOTIFY rowSpanChanged)
+public:
+ explicit ButtonItem(QQuickItem *parent = 0);
+ ~ButtonItem();
+
+ bool isPressed() const { return m_active || m_mouseDown; };
+ bool isActive() const { return m_active; };
+ bool isMouseDown() const { return m_mouseDown; };
+ bool isModifier() const { return m_modifier; };
+ bool isStandard() const { return !m_modifier; };
+ QString label() const { return m_label; };
+ QStringList symbols() const { return m_symbols; };
+
+ void setActive(bool active);
+ void setMouseDown(bool mouseDown);
+ void setCurrentSymbolIndex(int currentSymbolIndex);
+
+signals:
+ void pressedChanged(bool is_pressed);
+ void activeChanged(bool is_active);
+ void mouseDownChanged(bool mouseDown);
+ void modifierChanged(bool is_modifier);
+ void labelChanged(const QString &label);
+ void symbolsChanged(const QStringList &symbols);
+
+ void colChanged(int col);
+ void rowChanged(int row);
+ void colSpanChanged(int colSpan);
+ void rowSpanChanged(int rowSpan);
+
+ void currentSymbolIndexChanged(int index);
+ void triggered();
+ void released();
+ void symbolTriggered(const QString &symbol);
+
+private slots:
+ void onSymbolsChanged();
+ void onTriggered();
+ void onReleased();
+
+private:
+ bool m_active;
+ bool m_mouseDown;
+ bool m_modifier;
+ QString m_label;
+ QStringList m_symbols;
+ int m_col;
+ int m_row;
+ int m_colSpan;
+ int m_rowSpan;
+ int m_currentSymbolIndex;
+}; /* ----- end of class ButtonItem ----- */
+
+} /* QuickKeyboard */
+
+#endif /* end of include guard: BUTTONITEM_H_VNF1QLCU */
+
diff --git a/data/quickvirtualkeyboard/COPYING b/data/quickvirtualkeyboard/COPYING
new file mode 100644
index 0000000000000000000000000000000000000000..a2f83301f5e38f7f3cc51064739c8ddca2eae311
--- /dev/null
+++ b/data/quickvirtualkeyboard/COPYING
@@ -0,0 +1,27 @@
+Copyright (c) 2014, Miroslav Bendík and various contributors (see AUTHORS)
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those
+of the authors and should not be interpreted as representing official policies,
+either expressed or implied, of the FreeBSD Project.
+
diff --git a/data/quickvirtualkeyboard/Dispatcher.cpp b/data/quickvirtualkeyboard/Dispatcher.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b7ab2bece5d7ff838aa97ada3dc9a4752c5c4bef
--- /dev/null
+++ b/data/quickvirtualkeyboard/Dispatcher.cpp
@@ -0,0 +1,69 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include "Dispatcher.h"
+
+namespace QuickKeyboard
+{
+
+Dispatcher::Dispatcher(QObject *parent):
+ QObject(parent),
+ m_focusObject(0),
+ m_sendReturnKey(false)
+{
+}
+
+Dispatcher::~Dispatcher()
+{
+}
+
+QObject *Dispatcher::focusObject() const
+{
+ return m_focusObject;
+}
+
+void Dispatcher::setFocusObject(QObject *focusObject)
+{
+ m_focusObject = focusObject;
+}
+
+void Dispatcher::sendSymbol(const QString &symbol)
+{
+ if (!m_focusObject) {
+ return;
+ }
+
+ QInputMethodEvent ev;
+ if (symbol == QString("\x7f")) { // backspace
+ ev.setCommitString("", -1, 1);
+ }
+ else if (m_sendReturnKey && symbol == QString("\n")) {
+ QWindow *window = 0;
+
+ QQuickItem *quickItem = qobject_cast(m_focusObject);
+ if (quickItem) {
+ window = quickItem->window();
+ }
+
+ if (window) {
+ QKeyEvent *press = new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
+ QGuiApplication::postEvent(window, press);
+ QKeyEvent *release = new QKeyEvent(QKeyEvent::KeyRelease, Qt::Key_Return, Qt::NoModifier);
+ QGuiApplication::postEvent(window, release);
+ return;
+ }
+ else {
+ ev.setCommitString(symbol);
+ }
+ }
+ else {
+ ev.setCommitString(symbol);
+ }
+ QCoreApplication::sendEvent(m_focusObject, &ev);
+}
+
+} /* QuickKeyboard */
+
diff --git a/data/quickvirtualkeyboard/Dispatcher.h b/data/quickvirtualkeyboard/Dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..f4f35a5acab1a75575180a57cd80a62e88effe10
--- /dev/null
+++ b/data/quickvirtualkeyboard/Dispatcher.h
@@ -0,0 +1,30 @@
+#ifndef DISPATCHER_H_4JJ7SBUO
+#define DISPATCHER_H_4JJ7SBUO
+
+#include
+
+namespace QuickKeyboard
+{
+
+class Dispatcher: public QObject
+{
+Q_OBJECT
+Q_PROPERTY(bool sendReturnKey MEMBER m_sendReturnKey)
+public:
+ explicit Dispatcher(QObject *parent = 0);
+ ~Dispatcher();
+ QObject *focusObject() const;
+
+public slots:
+ void setFocusObject(QObject *focusObject);
+ virtual void sendSymbol(const QString &symbol);
+
+private:
+ QObject *m_focusObject;
+ bool m_sendReturnKey;
+}; /* ----- end of class Dispatcher ----- */
+
+} /* QuickKeyboard */
+
+#endif /* end of include guard: DISPATCHER_H_4JJ7SBUO */
+
diff --git a/data/quickvirtualkeyboard/GridLayoutItem.cpp b/data/quickvirtualkeyboard/GridLayoutItem.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f3fb5fb64f8d98d71e62d3a0c523e8f47e9ff0c9
--- /dev/null
+++ b/data/quickvirtualkeyboard/GridLayoutItem.cpp
@@ -0,0 +1,275 @@
+#include
+#include
+#include "ButtonItem.h"
+#include "ModeItem.h"
+#include "GridLayoutItem.h"
+
+namespace QuickKeyboard
+{
+
+GridLayoutItemAttached::GridLayoutItemAttached(QObject *parent):
+ QObject(parent),
+ m_col(0),
+ m_row(0),
+ m_colSpan(1),
+ m_rowSpan(1)
+{
+}
+
+GridLayoutItemAttached::~GridLayoutItemAttached()
+{
+}
+
+GridLayoutItem *GridLayoutItemAttached::layout() const
+{
+ QObject *predecessor = parent();
+ ModeItem *mode = 0;
+ while (predecessor != 0) {
+ predecessor = predecessor->parent();
+ mode = qobject_cast(predecessor);
+ if (mode) {
+ return qobject_cast(mode->layout());
+ }
+ }
+ return 0;
+}
+
+GridLayoutItem::GridLayoutItem(QQuickItem *parent):
+ LayoutItem(parent),
+ m_autoSize(true)
+{
+ setFlag(QQuickItem::ItemHasContents);
+ setAcceptedMouseButtons(Qt::LeftButton);
+ setZ(1);
+ m_touchPositions << QPointF();
+}
+
+GridLayoutItem::~GridLayoutItem()
+{
+}
+
+void GridLayoutItem::addButton(ButtonItem *button)
+{
+ LayoutItem::addButton(button);
+ connect(button, SIGNAL(triggered()), this, SLOT(synchronizeMouseDownPoints()));
+}
+
+void GridLayoutItem::clearButtons()
+{
+ for (const ButtonItem *button : buttons()) {
+ QObject *layoutAttached = qmlAttachedPropertiesObject(button);
+ if (layoutAttached) {
+ disconnect(button, SIGNAL(triggered()), this, SLOT(synchronizeMouseDownPoints()));
+ }
+ }
+ LayoutItem::clearButtons();
+}
+
+void GridLayoutItem::setRowLength(QList rows)
+{
+ m_autoSize = false;
+ m_rowLengths = rows;
+}
+
+GridLayoutItemAttached *GridLayoutItem::qmlAttachedProperties(QObject *object)
+{
+ return new GridLayoutItemAttached(object);
+}
+
+void GridLayoutItem::redirectEventsToItem(QQuickItem *item)
+{
+ if (!item) {
+ return;
+ }
+
+ if (!m_touchPositions[0].isNull()) {
+ ungrabMouse();
+ QMouseEvent pressEvent(QMouseEvent::MouseButtonPress, QPointF(0, 0), Qt::LeftButton, Qt::LeftButton, 0);
+ QCoreApplication::sendEvent(item, &pressEvent);
+ item->grabMouse();
+ }
+ if (!m_touchPoints.isEmpty()) {
+ ungrabTouchPoints();
+
+ QVector ids;
+ for (const QTouchEvent::TouchPoint &point : m_touchPoints) {
+ ids << point.id();
+ }
+
+ QTouchEvent touchEvent(
+ QEvent::TouchBegin,
+ (QTouchDevice *)QTouchDevice::devices().first(),
+ Qt::NoModifier,
+ Qt::TouchPointPressed,
+ m_touchPoints
+ );
+
+ QCoreApplication::sendEvent(item, &touchEvent);
+ item->grabTouchPoints(ids);
+ }
+
+ m_touchPositions.clear();
+ m_touchPositions << QPointF();
+ m_touchPoints.clear();
+}
+
+void GridLayoutItem::triggerOnPosition(const QPointF &point)
+{
+ for (ButtonItem *button : buttons()) {
+ if (checkButtonAtPoint(button, point)) {
+ emit button->released();
+ }
+ }
+}
+
+void GridLayoutItem::setMousePosition(const QPointF &position)
+{
+ m_touchPositions[0] = position;
+ synchronizeMouseDownPoints();
+}
+
+void GridLayoutItem::setTouchPositions(const QList &positions)
+{
+ m_touchPositions = QList() << m_touchPositions[0];
+ m_touchPositions += positions;
+ synchronizeMouseDownPoints();
+}
+
+bool GridLayoutItem::checkMouseDown(const ButtonItem *button) const
+{
+ for (const QPointF &point : m_touchPositions) {
+ if (!point.isNull()) {
+ if (checkButtonAtPoint(button, point)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+inline bool GridLayoutItem::checkButtonAtPoint(const ButtonItem *button, const QPointF &point)
+{
+ QPointF mapped = point - QPointF(button->x(), button->y());
+ if (mapped.x() >= 0.0f && mapped.y() >= 0.0f && mapped.x() < button->width() && mapped.y() < button->height()) {
+ return true;
+ }
+ return false;
+}
+
+void GridLayoutItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ LayoutItem::geometryChanged(newGeometry, oldGeometry);
+ int width = property("width").toInt();
+ int height = property("height").toInt();
+
+ if (!width || !height) return;
+
+ hCenter = width / 2;
+ vCenter = height / 2;
+ recalculatePositions();
+}
+
+void GridLayoutItem::touchEvent(QTouchEvent *event)
+{
+ QVector points;
+ m_touchPoints = event->touchPoints();
+ points.reserve(m_touchPoints.length());
+ for (const QTouchEvent::TouchPoint &point : m_touchPoints) {
+ points << point.pos();
+ }
+ setTouchPositions(points.toList());
+
+ QVector pointsAfterRelease;
+ pointsAfterRelease.reserve(m_touchPoints.length());
+
+ for (const QTouchEvent::TouchPoint &point : m_touchPoints) {
+ if (point.state() == Qt::TouchPointReleased) {
+ pointsAfterRelease << QPointF();
+ triggerOnPosition(point.pos());
+ }
+ else {
+ pointsAfterRelease << point.pos().toPoint();
+ }
+ }
+
+ if (points != pointsAfterRelease) {
+ setTouchPositions(pointsAfterRelease.toList());
+ }
+}
+
+void GridLayoutItem::mouseMoveEvent(QMouseEvent *event)
+{
+ QPointF scenePos = QPointF(event->x(), event->y());
+ setMousePosition(scenePos);
+}
+
+void GridLayoutItem::mousePressEvent(QMouseEvent *event)
+{
+ QPointF scenePos = QPointF(event->x(), event->y());
+ setMousePosition(scenePos);
+}
+
+void GridLayoutItem::mouseReleaseEvent(QMouseEvent *event)
+{
+ QPointF scenePos = QPointF(event->x(), event->y());
+ triggerOnPosition(scenePos);
+ setMousePosition(QPointF());
+}
+
+int GridLayoutItem::layoutProperty(const ButtonItem *button, const char *property, int fallback)
+{
+ QObject *layoutAttached = qmlAttachedPropertiesObject(button);
+ if (!layoutAttached) {
+ return fallback;
+ }
+ return layoutAttached->property(property).toInt();
+}
+
+void GridLayoutItem::recalculatePositions()
+{
+ int w = 52;
+ int h = 52;
+ int gap = 5;
+
+ QList offsets = m_rowLengths;
+ for (int i = 0; i < offsets.size(); i++) {
+ if (offsets[i] == 0) continue;
+
+ offsets[i] = (1404 - (offsets[i] * w + (offsets[i] - 2) * gap )) / 2;
+ }
+
+ for (ButtonItem *button : buttons()) {
+ QObject *layoutAttached = qmlAttachedPropertiesObject(button);
+ if (!layoutAttached) {
+ continue;
+ }
+
+ int left = layoutAttached->property("col").toInt();
+ int top = layoutAttached->property("row").toInt();
+ int width = layoutAttached->property("colSpan").toInt() * w;
+ int height = layoutAttached->property("rowSpan").toInt() * h;
+
+ int x = left * (w + gap);
+ int y = top * (h + gap);
+
+ x += offsets[top];
+
+ button->setProperty("x", x);
+ button->setProperty("y", y);
+ button->setProperty("width", width);
+ button->setProperty("height", height);
+ }
+}
+
+void GridLayoutItem::synchronizeMouseDownPoints()
+{
+ for (auto button : buttons()) {
+ bool pointMouseDown = checkMouseDown(button);
+ if (button->isMouseDown() != pointMouseDown) {
+ button->setMouseDown(pointMouseDown);
+ }
+ }
+}
+
+} /* QuickKeyboard */
+
diff --git a/data/quickvirtualkeyboard/GridLayoutItem.h b/data/quickvirtualkeyboard/GridLayoutItem.h
new file mode 100644
index 0000000000000000000000000000000000000000..429fa03bd85bc4ca0f6af488b5d2905ad5b08051
--- /dev/null
+++ b/data/quickvirtualkeyboard/GridLayoutItem.h
@@ -0,0 +1,102 @@
+#ifndef GRIDLAYOUTITEM_H_KEQWS1DN
+#define GRIDLAYOUTITEM_H_KEQWS1DN
+
+
+#include
+#include "LayoutItem.h"
+
+namespace QuickKeyboard
+{
+
+class GridLayoutItem;
+
+class GridLayoutItemAttached: public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int col MEMBER m_col NOTIFY colChanged)
+Q_PROPERTY(int row MEMBER m_row NOTIFY rowChanged)
+Q_PROPERTY(int colSpan MEMBER m_colSpan NOTIFY colSpanChanged)
+Q_PROPERTY(int rowSpan MEMBER m_rowSpan NOTIFY rowSpanChanged)
+Q_PROPERTY(QuickKeyboard::GridLayoutItem *layout READ layout)
+public:
+ explicit GridLayoutItemAttached(QObject *parent = 0);
+ ~GridLayoutItemAttached();
+ GridLayoutItem *layout() const;
+
+signals:
+ void colChanged(int col);
+ void rowChanged(int row);
+ void colSpanChanged(int colSpan);
+ void rowSpanChanged(int rowSpan);
+
+private:
+ int m_col;
+ int m_row;
+ int m_colSpan;
+ int m_rowSpan;
+}; /* ----- end of class GridLayoutItemAttached ----- */
+
+
+class GridLayoutItem: public LayoutItem
+{
+Q_OBJECT
+Q_PROPERTY(QList rowLengths MEMBER m_rowLengths WRITE setRowLength NOTIFY rowLengthChanged)
+public:
+ explicit GridLayoutItem(QQuickItem *parent = 0);
+ ~GridLayoutItem();
+
+ void addButton(ButtonItem *button);
+ void clearButtons();
+
+ void setRowLength(QList rows);
+
+ static GridLayoutItemAttached *qmlAttachedProperties(QObject *object);
+
+public slots:
+ void redirectEventsToItem(QQuickItem *item);
+
+private:
+ void triggerOnPosition(const QPointF &point);
+
+ void setMousePosition(const QPointF &position);
+ void setTouchPositions(const QList &positions);
+
+ bool checkMouseDown(const ButtonItem *button) const;
+
+ static bool checkButtonAtPoint(const ButtonItem *button, const QPointF &point);
+
+signals:
+ void colsChanged(int cols);
+ void rowsChanged(int rows);
+ void rowLengthChanged(QList lengths);
+
+protected:
+ virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
+ virtual void touchEvent(QTouchEvent *event);
+ virtual void mouseMoveEvent(QMouseEvent *event);
+ virtual void mousePressEvent(QMouseEvent *event);
+ virtual void mouseReleaseEvent(QMouseEvent *event);
+
+private:
+ static int layoutProperty(const ButtonItem *button, const char *property, int fallback);
+
+private slots:
+ void recalculatePositions();
+ void synchronizeMouseDownPoints();
+
+private:
+ bool m_autoSize;
+ QList m_rowLengths;
+ int hCenter;
+ int vCenter;
+
+ QList m_touchPositions;
+ QList m_touchPoints;
+}; /* ----- end of class GridLayoutItem ----- */
+
+} /* QuickKeyboard */
+
+QML_DECLARE_TYPEINFO(QuickKeyboard::GridLayoutItem, QML_HAS_ATTACHED_PROPERTIES)
+
+#endif /* end of include guard: GRIDLAYOUTITEM_H_KEQWS1DN */
+
diff --git a/data/quickvirtualkeyboard/KeyboardItem.cpp b/data/quickvirtualkeyboard/KeyboardItem.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..234584cd565b45468c7cab54b3d3afb1e41752cb
--- /dev/null
+++ b/data/quickvirtualkeyboard/KeyboardItem.cpp
@@ -0,0 +1,54 @@
+#include "Dispatcher.h"
+#include "ModeItem.h"
+#include "KeyboardItem.h"
+
+namespace QuickKeyboard
+{
+
+KeyboardItem::KeyboardItem(QQuickItem *parent):
+ QQuickItem(parent),
+ m_mode(0),
+ m_dispatcher(new Dispatcher(this))
+{
+ setObjectName("QuickKeyboard");
+}
+
+KeyboardItem::~KeyboardItem()
+{
+}
+
+void KeyboardItem::setMode(ModeItem *mode)
+{
+ if (m_mode == mode) {
+ return;
+ }
+
+ if (m_mode) {
+ m_mode->setVisible(false);
+ disconnect(m_mode, SIGNAL(symbolTriggered(const QString &)), this, SLOT(onSymbolTriggered(const QString &)));
+ }
+
+ m_mode = mode;
+ if (mode) {
+ mode->setVisible(true);
+ connect(mode, SIGNAL(symbolTriggered(const QString &)), this, SLOT(onSymbolTriggered(const QString &)));
+ }
+ emit modeChanged(m_mode);
+}
+
+Dispatcher *KeyboardItem::dispatcher() const
+{
+ return m_dispatcher;
+}
+
+void KeyboardItem::onSymbolTriggered(const QString &symbol)
+{
+ if (!m_dispatcher) {
+ return;
+ }
+
+ m_dispatcher->sendSymbol(symbol);
+}
+
+} /* QuickKeyboard */
+
diff --git a/data/quickvirtualkeyboard/KeyboardItem.h b/data/quickvirtualkeyboard/KeyboardItem.h
new file mode 100644
index 0000000000000000000000000000000000000000..33243e91836e20f04e6b467ed3a2cd16e3d86e57
--- /dev/null
+++ b/data/quickvirtualkeyboard/KeyboardItem.h
@@ -0,0 +1,39 @@
+#ifndef KEYBOARDITEM_H_PT4SCIAV
+#define KEYBOARDITEM_H_PT4SCIAV
+
+#include
+#include
+
+namespace QuickKeyboard
+{
+
+class ModeItem;
+class Dispatcher;
+
+class KeyboardItem: public QQuickItem
+{
+Q_OBJECT
+Q_PROPERTY(QuickKeyboard::ModeItem* mode MEMBER m_mode WRITE setMode NOTIFY modeChanged DESIGNABLE false)
+Q_PROPERTY(QuickKeyboard::Dispatcher* dispatcher READ dispatcher MEMBER m_dispatcher)
+public:
+ explicit KeyboardItem(QQuickItem *parent = 0);
+ ~KeyboardItem();
+
+ void setMode(ModeItem *mode);
+ Dispatcher *dispatcher() const;
+
+signals:
+ void modeChanged(ModeItem *mode);
+
+private slots:
+ void onSymbolTriggered(const QString &symbol);
+
+private:
+ ModeItem *m_mode;
+ Dispatcher *m_dispatcher;
+}; /* ----- end of class KeyboardItem ----- */
+
+} /* QuickKeyboard */
+
+#endif /* end of include guard: KEYBOARDITEM_H_PT4SCIAV */
+
diff --git a/data/quickvirtualkeyboard/LayoutItem.cpp b/data/quickvirtualkeyboard/LayoutItem.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4c1d5b850b08bdb839c98d1869a4e1b4c46a873f
--- /dev/null
+++ b/data/quickvirtualkeyboard/LayoutItem.cpp
@@ -0,0 +1,32 @@
+#include "ButtonItem.h"
+#include "LayoutItem.h"
+
+namespace QuickKeyboard
+{
+
+LayoutItem::LayoutItem(QQuickItem *parent):
+ QQuickItem(parent)
+{
+}
+
+LayoutItem::~LayoutItem()
+{
+}
+
+void LayoutItem::addButton(ButtonItem *button)
+{
+ m_buttons.append(button);
+}
+
+void LayoutItem::clearButtons()
+{
+ m_buttons.clear();
+}
+
+const QList &LayoutItem::buttons() const
+{
+ return m_buttons;
+}
+
+} /* QuickKeyboard */
+
diff --git a/data/quickvirtualkeyboard/LayoutItem.h b/data/quickvirtualkeyboard/LayoutItem.h
new file mode 100644
index 0000000000000000000000000000000000000000..2eba83a7a938f19ada2483a1bf2eabcb56da0cf0
--- /dev/null
+++ b/data/quickvirtualkeyboard/LayoutItem.h
@@ -0,0 +1,32 @@
+#ifndef LAYOUTITEM_H_ZHXO0UI7
+#define LAYOUTITEM_H_ZHXO0UI7
+
+#include
+#include
+
+namespace QuickKeyboard
+{
+
+class ButtonItem;
+
+class LayoutItem: public QQuickItem
+{
+Q_OBJECT
+public:
+ explicit LayoutItem(QQuickItem *parent = 0);
+ ~LayoutItem();
+
+ virtual void addButton(ButtonItem *button);
+ virtual void clearButtons();
+
+protected:
+ const QList &buttons() const;
+
+private:
+ QList m_buttons;
+}; /* ----- end of class LayoutItem ----- */
+
+} /* QuickKeyboard */
+
+#endif /* end of include guard: LAYOUTITEM_H_ZHXO0UI7 */
+
diff --git a/data/quickvirtualkeyboard/ModeItem.cpp b/data/quickvirtualkeyboard/ModeItem.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ec4138338656d950863fd77934be05d1a149f6ee
--- /dev/null
+++ b/data/quickvirtualkeyboard/ModeItem.cpp
@@ -0,0 +1,115 @@
+#include
+#include "ButtonItem.h"
+#include "GridLayoutItem.h"
+#include "ModeItem.h"
+
+namespace QuickKeyboard
+{
+
+ModeItem::ModeItem(QQuickItem *parent):
+ QQuickItem(parent),
+ m_layout(0)
+{
+ setVisible(false);
+ setLayout(new GridLayoutItem());
+}
+
+ModeItem::~ModeItem()
+{
+}
+
+LayoutItem *ModeItem::layout() const
+{
+ return m_layout;
+}
+
+void ModeItem::setLayout(LayoutItem *layout)
+{
+ if (m_layout == layout) {
+ return;
+ }
+
+ if (m_layout) {
+ m_layout->setParentItem(0);
+ delete m_layout;
+ }
+
+ if (layout) {
+ layout->setParentItem(this);
+ for (ButtonItem *button : m_buttons) {
+ m_layout->addButton(button);
+ }
+ layout->property("anchors").value()->setProperty("fill", QVariant::fromValue(this));
+ }
+ m_layout = layout;
+}
+
+QQmlListProperty ModeItem::buttons()
+{
+ return QQmlListProperty(
+ this,
+ &m_buttons,
+ &ModeItem::buttons_append,
+ &ModeItem::buttons_count,
+ &ModeItem::buttons_at,
+ &ModeItem::buttons_clear
+ );
+}
+
+void ModeItem::buttons_append(QQmlListProperty *property, ButtonItem *button)
+{
+ ModeItem *that = static_cast(property->object);
+ button->setParentItem(that);
+ that->m_buttons.append(button);
+ if (that->m_layout) {
+ that->m_layout->addButton(button);
+ }
+ QObject::connect(button, SIGNAL(symbolTriggered(const QString &)), that, SIGNAL(symbolTriggered(const QString &)));
+ QObject::connect(button, SIGNAL(triggered()), that, SLOT(setModifiersInactive()));
+}
+
+int ModeItem::buttons_count(QQmlListProperty *property)
+{
+ ModeItem *that = static_cast(property->object);
+ return that->m_buttons.count();
+}
+
+ButtonItem *ModeItem::buttons_at(QQmlListProperty *property, int idx)
+{
+ ModeItem *that = static_cast(property->object);
+ return that->m_buttons.value(idx, 0);
+}
+
+void ModeItem::buttons_clear(QQmlListProperty *property)
+{
+ ModeItem *that = static_cast(property->object);
+ if (that->m_layout) {
+ that->m_layout->clearButtons();
+ }
+ for (ButtonItem *button : that->m_buttons) {
+ QObject::disconnect(button, SIGNAL(symbolTriggered(const QString &)), that, SIGNAL(symbolTriggered(const QString &)));
+ QObject::disconnect(button, SIGNAL(triggered()), that, SLOT(setModifiersInactive()));
+ button->setParentItem(0);
+ }
+ that->m_buttons.clear();
+}
+
+void ModeItem::itemChange(ItemChange change, const ItemChangeData &value)
+{
+ QQuickItem::itemChange(change, value);
+ if (change == QQuickItem::ItemVisibleHasChanged && !isVisible()) {
+ setModifiersInactive();
+ }
+}
+
+void ModeItem::setModifiersInactive()
+{
+ for (ButtonItem *button : m_buttons) {
+ if (button->isModifier()) {
+ button->setActive(false);
+ }
+ }
+}
+
+} /* QuickKeyboard */
+
diff --git a/data/quickvirtualkeyboard/ModeItem.h b/data/quickvirtualkeyboard/ModeItem.h
new file mode 100644
index 0000000000000000000000000000000000000000..519d9e211083d34bce55b6eb1c5d001ab415d202
--- /dev/null
+++ b/data/quickvirtualkeyboard/ModeItem.h
@@ -0,0 +1,56 @@
+#ifndef MODEITEM_H_6ZH81LSX
+#define MODEITEM_H_6ZH81LSX
+
+#include
+#include
+
+namespace QuickKeyboard
+{
+
+class ButtonItem;
+class LayoutItem;
+
+class ModeItem: public QQuickItem
+{
+Q_OBJECT
+Q_PROPERTY(QuickKeyboard::LayoutItem* layout READ layout WRITE setLayout NOTIFY layoutChanged)
+Q_PROPERTY(QQmlListProperty buttons READ buttons DESIGNABLE false)
+Q_CLASSINFO("DefaultProperty", "buttons")
+public:
+ explicit ModeItem(QQuickItem *parent = 0);
+ ~ModeItem();
+
+ // layout property
+ LayoutItem *layout() const;
+ void setLayout(LayoutItem *layout);
+
+ // buttons property
+ QQmlListProperty buttons();
+ static void buttons_append(QQmlListProperty *property, ButtonItem *mode);
+ static int buttons_count(QQmlListProperty *property);
+ static ButtonItem *buttons_at(QQmlListProperty *property, int idx);
+ static void buttons_clear(QQmlListProperty *property);
+
+signals:
+ void layoutChanged(LayoutItem *layout);
+ void colsChanged(int cols);
+ void rowsChanged(int rows);
+ void symbolTriggered(const QString &symbol);
+
+protected:
+ virtual void itemChange(ItemChange change, const ItemChangeData &value);
+
+private slots:
+ void setModifiersInactive();
+
+private:
+ LayoutItem *m_layout;
+ QList m_buttons;
+ int m_cols;
+ int m_rows;
+}; /* ----- end of class ModeItem ----- */
+
+} /* QuickKeyboard */
+
+#endif /* end of include guard: MODEITEM_H_6ZH81LSX */
+
diff --git a/data/quickvirtualkeyboard/components.pri b/data/quickvirtualkeyboard/components.pri
new file mode 100644
index 0000000000000000000000000000000000000000..00924b5c14e7b6ce73fb50a1332d432687707e7c
--- /dev/null
+++ b/data/quickvirtualkeyboard/components.pri
@@ -0,0 +1,15 @@
+HEADERS += \
+ $$PWD/ButtonItem.h \
+ $$PWD/Dispatcher.h \
+ $$PWD/GridLayoutItem.h \
+ $$PWD/KeyboardItem.h \
+ $$PWD/LayoutItem.h \
+ $$PWD/ModeItem.h \
+ $$PWD/register.h
+SOURCES += \
+ $$PWD/ButtonItem.cpp \
+ $$PWD/Dispatcher.cpp \
+ $$PWD/GridLayoutItem.cpp \
+ $$PWD/KeyboardItem.cpp \
+ $$PWD/LayoutItem.cpp \
+ $$PWD/ModeItem.cpp
diff --git a/data/quickvirtualkeyboard/png/backspaceblack.png b/data/quickvirtualkeyboard/png/backspaceblack.png
new file mode 100644
index 0000000000000000000000000000000000000000..8a2ff2f110efd5ad730aed02e6a765284b1105dc
--- /dev/null
+++ b/data/quickvirtualkeyboard/png/backspaceblack.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5acd0142b4b30c5760737b5cd900aeececbdce23c075d29c093e31f955ae1cb0
+size 3032
diff --git a/data/quickvirtualkeyboard/png/backspacewhite.png b/data/quickvirtualkeyboard/png/backspacewhite.png
new file mode 100644
index 0000000000000000000000000000000000000000..0130d76c630c76e0ab0ee2f9039fd897d937b4af
--- /dev/null
+++ b/data/quickvirtualkeyboard/png/backspacewhite.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8a51b6b2435691e404fb47ffeea990807a590ffffcc1b6116e2c6140aa2d5ad2
+size 3005
diff --git a/data/quickvirtualkeyboard/png/shiftblack.png b/data/quickvirtualkeyboard/png/shiftblack.png
new file mode 100644
index 0000000000000000000000000000000000000000..bc51fc8ade322c39f32fc16ffe418d7ddfb58d2e
--- /dev/null
+++ b/data/quickvirtualkeyboard/png/shiftblack.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a0e02a31f64d0a35dccdb82a4f3285716714d1178e18713eeae534ef46c50c31
+size 2952
diff --git a/data/quickvirtualkeyboard/png/shiftwhite.png b/data/quickvirtualkeyboard/png/shiftwhite.png
new file mode 100644
index 0000000000000000000000000000000000000000..054917f5e66d3e43534329911c57dca1a63577f8
--- /dev/null
+++ b/data/quickvirtualkeyboard/png/shiftwhite.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0ad7d25d3a7d937db55e851e6392866093f1535ed3ebbcd2685d5fa94d5a87bf
+size 2963
diff --git a/data/quickvirtualkeyboard/qml/Btn.qml b/data/quickvirtualkeyboard/qml/Btn.qml
new file mode 100644
index 0000000000000000000000000000000000000000..817acc25f01f440416739b418ac3a399d5419d5c
--- /dev/null
+++ b/data/quickvirtualkeyboard/qml/Btn.qml
@@ -0,0 +1,109 @@
+import QtQuick 2.11
+import QuickKeyboard 1.0
+import QtQuick.Shapes 1.11
+
+Button {
+ id: btn
+ property string icon
+ property int row
+ property int col
+ property Item buttonPreview
+ property bool hasPreview: false
+ property bool hasBorder: false
+ property bool forceFlip: false
+ property bool smallFont: false
+ GridLayout.row: row
+ GridLayout.col: col
+ GridLayout.colSpan: 2
+ GridLayout.rowSpan: 2
+ readonly property string fromColor: forceFlip ? "white" : "black"
+ readonly property string toColor: forceFlip ? "black" : "white"
+
+ Rectangle {
+ id: background
+ anchors.fill: parent
+ // color: mouseDown || active ? toColor : fromColor
+ color: fromColor
+ border.width: hasBorder ? 4 : 0
+ radius: hasBorder ? 2 : 0
+ border.color: "white"
+ }
+
+ Text {
+ id: keyName
+ text: label
+ color: toColor
+ anchors {
+ verticalCenter: parent.verticalCenter
+ left: parent.left
+ right: parent.right
+ leftMargin: 5
+ rightMargin: 5
+ }
+ font.pixelSize: smallFont ? 26 : 32
+ font.family: "Maison Neue"
+ font.styleName: "Bold"
+ maximumLineCount: 1
+ horizontalAlignment: Text.AlignHCenter
+ }
+
+ Image {
+ id: iconImg
+ source: icon ? (icon + toColor) : ""
+ fillMode: Image.PreserveAspectFit
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+
+ }
+
+ Component {
+ id: buttonPreviewComponent
+ BtnPreview {hasPreview: btn.hasPreview}
+ }
+
+ Timer {
+ id: createPreviewTimer
+ interval: 500
+
+ onTriggered: {
+ if (buttonPreview !== null) {
+ buttonPreview.destroy();
+ buttonPreview = null;
+ }
+ buttonPreview = buttonPreviewComponent.createObject(keyboardOverlay, {"btn": btn, "keyboard": keyboard});
+ }
+ }
+
+ function lowState() {
+ background.color = fromColor;
+ keyName.color = toColor;
+ iconImg.source = icon ? (icon + toColor) : "";
+ }
+
+ function highState() {
+ background.color = toColor;
+ keyName.color = fromColor;
+ iconImg.source = icon ? (icon + fromColor) : "";
+ }
+
+ onMouseDownChanged: {
+ if (modifier) return;
+
+ if (mouseDown) {
+ highState();
+ createPreviewTimer.restart();
+ } else {
+ lowState();
+ createPreviewTimer.stop();
+ if (buttonPreview !== null) {
+ buttonPreview.destroy();
+ buttonPreview = null;
+ }
+ }
+ }
+
+ onActiveChanged: {
+ if (active) highState();
+ else lowState();
+ }
+}
diff --git a/data/quickvirtualkeyboard/qml/BtnPreview.qml b/data/quickvirtualkeyboard/qml/BtnPreview.qml
new file mode 100644
index 0000000000000000000000000000000000000000..d648611e11b199227f62c01425cf9b3ef1f3e232
--- /dev/null
+++ b/data/quickvirtualkeyboard/qml/BtnPreview.qml
@@ -0,0 +1,122 @@
+import QtQuick 2.2
+import QuickKeyboard 1.0
+
+Item {
+ id: preview
+
+ property bool hasPreview: false
+
+ property Item keyboard
+ property Item btn
+
+ property int backgroundBorder: 3
+ property int padding: 10
+
+ property int centeredX: -width / 2 + btn.width / 2 + btn.x
+ property int minX: - backgroundBorder
+ property int maxX: btn.parent.width - width + backgroundBorder
+ property bool initTouch: true
+
+ x: Math.max(Math.min(centeredX, maxX), minX)
+ y: btn.y - height
+ width: buttonContent.width + backgroundBorder * 2
+ height: buttonContent.height + backgroundBorder * 2
+ visible: symbolsItems.count > 0
+
+ Rectangle {
+ id: shadow
+ x: 10
+ y: 5
+ width: background.width - 20
+ height: background.height
+ color: "darkgray"
+ radius: 4
+ }
+
+ Rectangle {
+ id: background
+ anchors.fill: parent
+ color: "white"
+ border.color: "black"
+ border.width: backgroundBorder
+ radius: 4
+ }
+
+ Component {
+ id: textPreview
+
+ Rectangle {
+ property bool active: (index == currentSymbolIndex)
+ color: active ? "black" : "transparent"
+ width: 70
+ height: 160
+
+ Text {
+ id: labelPreview
+ anchors.fill: parent
+ text: modelData
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: active ? "white" : "black"
+ font.family: "Noto Sans"
+ font.pixelSize: 50
+ font.weight: Font.Bold
+
+ }
+ }
+ }
+
+ Item {
+ id: buttonContent
+ x: backgroundBorder
+ y: backgroundBorder
+ height: 160
+ width: chars.width
+ Row {
+ id: chars
+ Repeater {
+ id: symbolsItems
+ model: 0
+ delegate: textPreview
+ }
+ }
+
+ MultiPointTouchArea {
+ id: buttonsArea
+ anchors.fill: parent
+ onPressed: {
+ symbolsItems.visible = true
+ symbolsItems.model = symbols
+ }
+ onReleased: {
+ if (touchPoints.length == 1) {
+ btn.triggered();
+ }
+ }
+ onTouchUpdated: {
+ if (touchPoints.length > 0) {
+ if (initTouch) {
+ initTouch = false;
+ currentSymbolIndex = Math.floor(symbolsItems.count / 2)
+ return;
+ }
+ var touchPoint = touchPoints[0];
+ var underMouseIndex = Math.floor(touchPoint.x * symbolsItems.count / chars.width);
+ if (underMouseIndex < 0) {
+ underMouseIndex = 0;
+ }
+ if (underMouseIndex >= symbolsItems.count) {
+ underMouseIndex = symbolsItems.count - 1;
+ }
+ currentSymbolIndex = underMouseIndex;
+ }
+ }
+ }
+ }
+
+ Timer {
+ interval: 500
+ running: mouseDown && symbols.length > 1
+ onTriggered: btn.GridLayout.layout.redirectEventsToItem(buttonsArea)
+ }
+}
diff --git a/data/quickvirtualkeyboard/qml/keyboard.qml b/data/quickvirtualkeyboard/qml/keyboard.qml
new file mode 100644
index 0000000000000000000000000000000000000000..17a8483f20b4e01080cc2d06ad117353794a9f2d
--- /dev/null
+++ b/data/quickvirtualkeyboard/qml/keyboard.qml
@@ -0,0 +1,72 @@
+import QtQuick 2.0
+import QuickKeyboard 1.0
+import "modes"
+
+// import QtGraphicalEffects 1.0
+
+Item {
+ id: main
+ width: 1404; height: 1872
+
+ Rectangle {
+ color: "black"
+ height: 100
+ // border { left: 9; top: 9; right: 9; bottom: 9 }
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: parent.top
+ }
+
+ TextEdit {
+ id: textInput
+ font.pixelSize: 40
+ color: "white"
+ anchors { fill: parent; verticalCenter: parent.verticalCenter; }
+ clip: true
+ }
+ }
+
+ Keyboard {
+ id: keyboard
+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
+ height: 626
+ Component.onCompleted: keyboard.dispatcher.setFocusObject(textInput)
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ // border { left: 1; top: 12; right: 1; bottom: 1 }
+ }
+
+ mode: standard
+
+ Standard {
+ id: standard
+ anchors.fill: parent
+ anchors.topMargin: 93
+ onSymbolsModeSwitched: keyboard.mode = symbols
+ }
+
+ Symbols {
+ id: symbols
+ anchors.fill: parent
+ anchors.topMargin: 93
+ onStandardModeSwitched: keyboard.mode = standard
+ onSymbolsModeSwitched: keyboard.mode = symbols2
+ }
+
+ Symbols2 {
+ id: symbols2
+ anchors.fill: parent
+ anchors.topMargin: 93
+ onStandardModeSwitched: keyboard.mode = standard
+ onSymbolsModeSwitched: keyboard.mode = symbols
+ }
+ }
+
+ Item {
+ id: keyboardOverlay
+ anchors.fill: keyboard
+ }
+}
diff --git a/data/quickvirtualkeyboard/qml/modes/Standard.qml b/data/quickvirtualkeyboard/qml/modes/Standard.qml
new file mode 100644
index 0000000000000000000000000000000000000000..38ea764a88bcc67e8175d52ec3a3e75826b49d02
--- /dev/null
+++ b/data/quickvirtualkeyboard/qml/modes/Standard.qml
@@ -0,0 +1,151 @@
+import QtQuick 2.0
+import QuickKeyboard 1.0
+import ".."
+
+Mode {
+ signal symbolsModeSwitched
+ signal enter
+
+ property variant btn_q:
+ shift.pressed ?
+ ["Q", "Ω"] :
+ ["q", "\\"]
+ property variant btn_w:
+ shift.pressed ?
+ acute.pressed ? ["Ẃ"] : ["W", "Ŵ", "Ẁ", "Ẇ", "Ẃ", "Ẅ", "Ł"] :
+ acute.pressed ? ["ẃ"] : ["w", "ŵ", "ẘ", "ẁ", "ẇ", "ẃ", "ẅ", "|"]
+ property variant btn_e:
+ shift.pressed ?
+ acute.pressed ? ["É"] : (caron.pressed ? ["Ě"] : ["E", "Ẽ", "Ě", "Ê", "Ĕ", "Ę", "È", "Ė", "É", "Ë", "Ȩ"]) :
+ acute.pressed ? ["é"] : (caron.pressed ? ["ě"] : ["e", "ě", "ê", "ĕ", "ę", "è", "ė", "é", "ë", "ȩ", "€"])
+ property variant btn_r:
+ shift.pressed ?
+ acute.pressed ? ["Ŕ"] : (caron.pressed ? ["Ř"] : ["R", "Ř", "Ṙ", "Ŕ", "Ŗ", "®"]) :
+ acute.pressed ? ["ŕ"] : (caron.pressed ? ["ř"] : ["r", "ř", "ṙ", "ŕ", "ŗ", "¶"])
+ property variant btn_t:
+ shift.pressed ?
+ caron.pressed ? ["Ť"] : ["T", "Ť", "Ṫ", "Ţ", "Ŧ"] :
+ caron.pressed ? ["ť"] : ["t", "ť", "ṫ", "ẗ", "ţ", "ŧ"]
+ property variant btn_y:
+ shift.pressed ?
+ acute.pressed ? ["Ý"] : ["Y", "Ỹ", "Ŷ", "Ỳ", "Ẏ", "Ý", "Ÿ", "¥"] :
+ acute.pressed ? ["ý"] : ["y", "ỹ", "ŷ", "ẙ", "ỳ", "ẏ", "ý", "ÿ", "←"]
+ property variant btn_u:
+ shift.pressed ?
+ acute.pressed ? ["Ú"] : (caron.pressed ? ["Ǔ"] : ["U", "Ũ", "Ǔ", "Û", "Ŭ", "Ů", "Ų", "Ù", "Ú", "Ű", "Ü", "Ǚ", "Ǜ", "Ǘ", "↑"]) :
+ acute.pressed ? ["ú"] : (caron.pressed ? ["ǔ"] : ["u", "ũ", "ǔ", "û", "ŭ", "ů", "ų", "ù", "ú", "ű", "ü", "ǚ", "ǜ", "ǘ", "↓"])
+ property variant btn_i:
+ shift.pressed ?
+ acute.pressed ? ["Í"] : (caron.pressed ? ["Ǐ"] : ["I", "Ĩ", "Ǐ", "Î", "Ĭ", "Į", "Ì", "İ", "Í", "Ï", "ı"]) :
+ acute.pressed ? ["í"] : (caron.pressed ? ["ǐ"] : ["i", "ĩ", "ǐ", "î", "ĭ", "į", "ì", "ı", "í", "ï", "→"])
+ property variant btn_o:
+ shift.pressed ?
+ acute.pressed ? ["Ó"] : (caron.pressed ? ["Ǒ"] : ["O", "Õ", "Ǒ", "Ô", "Ŏ", "Ǫ", "Ò", "Ȯ", "Ó", "Ő", "Ö", "Ø"]) :
+ acute.pressed ? ["ó"] : (caron.pressed ? ["ǒ"] : ["o", "õ", "ǒ", "ô", "ŏ", "ǫ", "ò", "ȯ", "ó", "ő", "ö", "ø"])
+ property variant btn_p:
+ shift.pressed ?
+ acute.pressed ? ["Ṕ"] : ["P", "Ṗ", "Ṕ", "Þ"] :
+ acute.pressed ? ["ṕ"] : ["p", "ṗ", "ṕ", "þ"]
+ property variant btn_a:
+ shift.pressed ?
+ acute.pressed ? ["Á"] : (caron.pressed ? ["Ǎ"] : ["A", "Ã", "Ǎ", "Â", "Ă", "Å", "Ą", "À", "Ȧ", "Á", "Ä", "Æ"]) :
+ acute.pressed ? ["á"] : (caron.pressed ? ["ǎ"] : ["a", "ã", "ǎ", "â", "ă", "å", "ą", "à", "ȧ", "á", "ä", "~"])
+ property variant btn_s:
+ shift.pressed ?
+ acute.pressed ? ["Ś"] : (caron.pressed ? ["Š"] : ["S", "Š", "Ŝ", "Ṡ", "Ś", "Ş", "§"]) :
+ acute.pressed ? ["ś"] : (caron.pressed ? ["š"] : ["s", "š", "ŝ", "ṡ", "ś", "ş", "đ"])
+ property variant btn_d:
+ shift.pressed ?
+ caron.pressed ? ["Ď"] : ["D", "Ď", "Ḋ", "Ḑ", "Đ"] :
+ caron.pressed ? ["ď"] : ["d", "ď", "ḋ", "ḑ", "đ"]
+ property variant btn_f:
+ shift.pressed ?
+ ["F", "Ḟ", "ª"] : ["f", "ḟ", "["]
+ property variant btn_g:
+ shift.pressed ?
+ acute.pressed ? ["Ǵ"] : (caron.pressed ? ["Ǧ"] : ["G", "Ǧ", "Ĝ", "Ğ", "Ġ", "Ǵ", "Ģ", "Ŋ"]) :
+ acute.pressed ? ["ǵ"] : (caron.pressed ? ["ǧ"] : ["g", "ǧ", "ĝ", "ğ", "ġ", "ǵ", "ģ", "]"])
+ property variant btn_h:
+ shift.pressed ?
+ caron.pressed ? ["Ȟ"] : ["H", "Ȟ", "Ĥ", "Ḣ", "Ḧ", "Ḩ", "Ħ"] :
+ caron.pressed ? ["ȟ"] : ["h", "ȟ", "ĥ", "ḣ", "ḧ", "ḩ", "`"]
+ property variant btn_j:
+ shift.pressed ?
+ ["J", "Ĵ", "J́", "'"] :
+ caron.pressed ? ["ǰ"] : ["j", "ǰ", "ĵ", "ȷ", " ̛"]
+ property variant btn_k:
+ shift.pressed ?
+ acute.pressed ? ["Ḱ"] : (caron.pressed ? ["Ǩ"] : ["K", "Ǩ", "Ḱ", "Ķ", "&"]) :
+ acute.pressed ? ["ḱ"] : (caron.pressed ? ["ǩ"] : ["k", "ǩ", "ḱ", "ķ", "ł"])
+ property variant btn_l:
+ shift.pressed ?
+ acute.pressed ? ["Ĺ"] : (caron.pressed ? ["Ľ"] : ["L", "Ľ", "Ŀ", "Ĺ", "Ļ", "Ł"]) :
+ acute.pressed ? ["ĺ"] : (caron.pressed ? ["ľ"] : ["l", "ľ", "ŀ", "ĺ", "ļ", "Ł"])
+ property variant btn_z:
+ shift.pressed ?
+ acute.pressed ? ["Ź"] : (caron.pressed ? ["Ž"] : ["Z", "Ž", "Ẑ", "Ż", "Ź", "<"]) :
+ acute.pressed ? ["ź"] : (caron.pressed ? ["ž"] : ["z", "ž", "ẑ", "ż", "ź", "°"])
+ property variant btn_x:
+ shift.pressed ?
+ ["X", "Ẋ", "Ẍ", ">"] : ["x", "ẋ", "ẍ", "#"]
+ property variant btn_c:
+ shift.pressed ?
+ acute.pressed ? ["Ć"] : (caron.pressed ? ["Č"] : ["C", "Č", "Ĉ", "Ċ", "Ć", "Ç", "©"]) :
+ acute.pressed ? ["ć"] : (caron.pressed ? ["č"] : ["c", "č", "ĉ", "ċ", "ć", "ç", "&"])
+ property variant btn_v:
+ shift.pressed ?
+ ["V", "Ṽ", "‘"] : ["v", "ṽ", "@"]
+ property variant btn_b:
+ shift.pressed ?
+ ["B", "Ḃ", "’"] : ["b", "ḃ", "{"]
+ property variant btn_n:
+ shift.pressed ?
+ acute.pressed ? ["Ń"] : (caron.pressed ? ["Ň"] : ["N", "Ñ", "Ň", "Ǹ", "Ṅ", "Ń", "Ņ"]) :
+ acute.pressed ? ["ń"] : (caron.pressed ? ["ň"] : ["n", "ñ", "ň", "ǹ", "ṅ", "ń", "ņ", "}"])
+ property variant btn_m:
+ shift.pressed ?
+ acute.pressed ? ["Ḿ"] : ["M", "Ṁ", "Ḿ", "º"] :
+ acute.pressed ? ["ḿ"] : ["m", "ṁ", "ḿ", "^"]
+ property variant btn_dot:
+ shift.pressed ?
+ [",", ".", ":", ";", "!", "?"] : [".", ",", ":", ";", "!", "?"]
+
+ layout: GridLayout{ rowLengths : [20, 0, 18, 0, 22, 0, 0, 24] }
+
+ Btn { col: 0; row: 0; label: shift.pressed ? "Q" : "q"; symbols: btn_q }
+ Btn { col: 2; row: 0; label: shift.pressed ? "W" : "w"; symbols: btn_w }
+ Btn { col: 4; row: 0; label: shift.pressed ? "E" : "e"; symbols: btn_e }
+ Btn { col: 6; row: 0; label: shift.pressed ? "R" : "r"; symbols: btn_r }
+ Btn { col: 8; row: 0; label: shift.pressed ? "T" : "t"; symbols: btn_t }
+ Btn { col: 10; row: 0; label: shift.pressed ? "Y" : "y"; symbols: btn_y }
+ Btn { col: 12; row: 0; label: shift.pressed ? "U" : "u"; symbols: btn_u }
+ Btn { col: 14; row: 0; label: shift.pressed ? "I" : "i"; symbols: btn_i }
+ Btn { col: 16; row: 0; label: shift.pressed ? "O" : "o"; symbols: btn_o }
+ Btn { col: 18; row: 0; label: shift.pressed ? "P" : "p"; symbols: btn_p }
+
+ Btn { col: 0; row: 2; label: shift.pressed ? "A" : "a"; symbols: btn_a }
+ Btn { col: 2; row: 2; label: shift.pressed ? "S" : "s"; symbols: btn_s }
+ Btn { col: 4; row: 2; label: shift.pressed ? "D" : "d"; symbols: btn_d }
+ Btn { col: 6; row: 2; label: shift.pressed ? "F" : "f"; symbols: btn_f }
+ Btn { col: 8; row: 2; label: shift.pressed ? "G" : "g"; symbols: btn_g }
+ Btn { col: 10; row: 2; label: shift.pressed ? "H" : "h"; symbols: btn_h }
+ Btn { col: 12; row: 2; label: shift.pressed ? "J" : "j"; symbols: btn_j }
+ Btn { col: 14; row: 2; label: shift.pressed ? "K" : "k"; symbols: btn_k }
+ Btn { col: 16; row: 2; label: shift.pressed ? "L" : "l"; symbols: btn_l }
+
+ Btn { col: 0; row: 4; GridLayout.colSpan: 4; icon: "png/shift"; id: shift; modifier: true; hasPreview: false }
+ Btn { col: 4; row: 4; label: shift.pressed ? "Z" : "z"; symbols: btn_z }
+ Btn { col: 6; row: 4; label: shift.pressed ? "X" : "x"; symbols: btn_x }
+ Btn { col: 8; row: 4; label: shift.pressed ? "C" : "c"; symbols: btn_c }
+ Btn { col: 10; row: 4; label: shift.pressed ? "V" : "v"; symbols: btn_v }
+ Btn { col: 12; row: 4; label: shift.pressed ? "B" : "b"; symbols: btn_b }
+ Btn { col: 14; row: 4; label: shift.pressed ? "N" : "n"; symbols: btn_n }
+ Btn { col: 16; row: 4; label: shift.pressed ? "M" : "m"; symbols: btn_m }
+ Btn { col: 18; row: 4; GridLayout.colSpan: 4; icon: "png/backspace"; hasPreview: false; symbols: ["\x7f"] }
+
+ Btn { col: 0; row: 7; GridLayout.colSpan: 4; label: "123"; onTriggered: symbolsModeSwitched(); hasPreview: false; smallFont: true }
+ Btn { col: 4; row: 7; label: "´"; id: acute; modifier: true; hasPreview: false; onActiveChanged: if (active) caron.active = false }
+ Btn { col: 6; row: 7; GridLayout.colSpan: 11; label: "space"; hasPreview: false; symbols: " "; hasBorder: true; smallFont: true }
+ Btn { col: 18; row: 7; label: "ˇ"; id: caron; modifier: true; hasPreview: false; onActiveChanged: if (active) acute.active = false }
+ Btn { col: 20; row: 7; GridLayout.colSpan: 4; label: "enter"; onTriggered: enter(); hasPreview: false; forceFlip: true; smallFont: true }
+}
diff --git a/data/quickvirtualkeyboard/qml/modes/Symbols.qml b/data/quickvirtualkeyboard/qml/modes/Symbols.qml
new file mode 100644
index 0000000000000000000000000000000000000000..b3470e8d454bad5a0d83b73bd49966a4a87cd081
--- /dev/null
+++ b/data/quickvirtualkeyboard/qml/modes/Symbols.qml
@@ -0,0 +1,47 @@
+import QtQuick 2.0
+import QuickKeyboard 1.0
+import ".."
+
+Mode {
+ signal standardModeSwitched
+ signal symbolsModeSwitched
+ signal enter
+
+ layout: GridLayout{ rowLengths : [20, 0, 18, 0, 22, 0, 0, 24] }
+
+ Btn { col: 0; row: 0; label: "1"; symbols: ["1"] }
+ Btn { col: 2; row: 0; label: "2"; symbols: ["2"] }
+ Btn { col: 4; row: 0; label: "3"; symbols: ["3"] }
+ Btn { col: 6; row: 0; label: "4"; symbols: ["4"] }
+ Btn { col: 8; row: 0; label: "5"; symbols: ["5"] }
+ Btn { col: 10; row: 0; label: "6"; symbols: ["6"] }
+ Btn { col: 12; row: 0; label: "7"; symbols: ["7"] }
+ Btn { col: 14; row: 0; label: "8"; symbols: ["8"] }
+ Btn { col: 16; row: 0; label: "9"; symbols: ["9"] }
+ Btn { col: 18; row: 0; label: "0"; symbols: ["0"] }
+
+ Btn { col: 0; row: 2; label: "-"; symbols: ["-"] }
+ Btn { col: 2; row: 2; label: "/"; symbols: ["/"] }
+ Btn { col: 4; row: 2; label: ":"; symbols: [":"] }
+ Btn { col: 6; row: 2; label: ";"; symbols: [";"] }
+ Btn { col: 8; row: 2; label: "("; symbols: ["("] }
+ Btn { col: 10; row: 2; label: ")"; symbols: [")"] }
+ Btn { col: 12; row: 2; label: "€"; symbols: ["€"] }
+ Btn { col: 14; row: 2; label: "&"; symbols: ["&"] }
+ Btn { col: 16; row: 2; label: "@"; symbols: ["@"] }
+
+ Btn { col: 0; row: 4; GridLayout.colSpan: 4; label: "#<"; hasPreview: false; onTriggered: symbolsModeSwitched(); }
+ Btn { col: 4; row: 4; label: "\""; symbols: ["\""] }
+ Btn { col: 6; row: 4; label: "'"; symbols: ["'"] }
+ Btn { col: 8; row: 4; label: "."; symbols: ["."] }
+ Btn { col: 10; row: 4; label: ","; symbols: [","] }
+ Btn { col: 12; row: 4; label: "?"; symbols: ["?"] }
+ Btn { col: 14; row: 4; label: "!"; symbols: ["!"] }
+ Btn { col: 16; row: 4; label: "*"; symbols: ["*"] }
+ Btn { col: 18; row: 4; label: "%"; symbols: ["%"] }
+ Btn { col: 18; row: 4; GridLayout.colSpan: 4; icon: "png/backspace"; hasPreview: false; symbols: ["\x7f"] }
+
+ Btn { col: 0; row: 7; GridLayout.colSpan: 4; label: "ABC"; onTriggered: standardModeSwitched(); hasPreview: false; smallFont: true }
+ Btn { col: 6; row: 7; GridLayout.colSpan: 11; label: "space"; hasPreview: false; symbols: " "; hasBorder: true; smallFont: true }
+ Btn { col: 20; row: 7; GridLayout.colSpan: 4; label: "enter"; hasPreview: false; onTriggered: enter(); forceFlip: true; smallFont: true }
+}
diff --git a/data/quickvirtualkeyboard/qml/modes/Symbols2.qml b/data/quickvirtualkeyboard/qml/modes/Symbols2.qml
new file mode 100644
index 0000000000000000000000000000000000000000..e44db9b27e14ecd9816d4f8a029bcf9b408e68a7
--- /dev/null
+++ b/data/quickvirtualkeyboard/qml/modes/Symbols2.qml
@@ -0,0 +1,47 @@
+import QtQuick 2.0
+import QuickKeyboard 1.0
+import ".."
+
+Mode {
+ signal standardModeSwitched
+ signal symbolsModeSwitched
+ signal enter
+
+ layout: GridLayout{ rowLengths : [20, 0, 18, 0, 24, 0, 0, 24] }
+
+ Btn { col: 0; row: 0; label: "~"; symbols: ["~"] }
+ Btn { col: 2; row: 0; label: "$"; symbols: ["$"] }
+ Btn { col: 4; row: 0; label: "£"; symbols: ["£"] }
+ Btn { col: 6; row: 0; label: "¥"; symbols: ["¥"] }
+ Btn { col: 8; row: 0; label: "§"; symbols: ["§"] }
+ Btn { col: 10; row: 0; label: "&"; symbols: ["&"] }
+ Btn { col: 12; row: 0; label: "@"; symbols: ["@"] }
+ Btn { col: 14; row: 0; label: "©"; symbols: ["©"] }
+ Btn { col: 16; row: 0; label: "®"; symbols: ["®"] }
+ Btn { col: 18; row: 0; label: "°"; symbols: ["°"] }
+
+ Btn { col: 0; row: 2; label: "="; symbols: ["="] }
+ Btn { col: 2; row: 2; label: "#"; symbols: ["#"] }
+ Btn { col: 4; row: 2; label: "|"; symbols: ["|"] }
+ Btn { col: 6; row: 2; label: "_"; symbols: ["_"] }
+ Btn { col: 8; row: 2; label: "+"; symbols: ["+"] }
+ Btn { col: 10; row: 2; label: "-"; symbols: ["-"] }
+ Btn { col: 12; row: 2; label: "/"; symbols: ["/"] }
+ Btn { col: 14; row: 2; label: "*"; symbols: ["*"] }
+ Btn { col: 16; row: 2; label: "%"; symbols: ["%"] }
+
+ Btn { col: 0; row: 4; GridLayout.colSpan: 4; label: "12"; hasPreview: false; onTriggered: symbolsModeSwitched(); }
+ Btn { col: 4; row: 4; label: "("; symbols: ["("] }
+ Btn { col: 6; row: 4; label: ")"; symbols: [")"] }
+ Btn { col: 8; row: 4; label: "["; symbols: ["["] }
+ Btn { col: 10; row: 4; label: "]"; symbols: ["]"] }
+ Btn { col: 12; row: 4; label: "{"; symbols: ["{"] }
+ Btn { col: 14; row: 4; label: "}"; symbols: ["}"] }
+ Btn { col: 16; row: 4; label: "<"; symbols: ["<"] }
+ Btn { col: 18; row: 4; label: ">"; symbols: [">"] }
+ Btn { col: 20; row: 4; GridLayout.colSpan: 4; icon: "png/backspace"; hasPreview: false; symbols: ["\x7f"] }
+
+ Btn { col: 0; row: 7; GridLayout.colSpan: 4; label: "ABC"; onTriggered: standardModeSwitched(); hasPreview: false; smallFont: true }
+ Btn { col: 6; row: 7; GridLayout.colSpan: 11; label: "space"; hasPreview: false; symbols: " "; hasBorder: true; smallFont: true }
+ Btn { col: 20; row: 7; GridLayout.colSpan: 4; label: "enter"; hasPreview: false; onTriggered: enter(); forceFlip: true; smallFont: true }
+}
diff --git a/data/quickvirtualkeyboard/register.h b/data/quickvirtualkeyboard/register.h
new file mode 100644
index 0000000000000000000000000000000000000000..81ec7955b4d39dd3f5c86a61e5f6e722457309de
--- /dev/null
+++ b/data/quickvirtualkeyboard/register.h
@@ -0,0 +1,18 @@
+#include
+#include "KeyboardItem.h"
+#include "Dispatcher.h"
+#include "ModeItem.h"
+#include "ButtonItem.h"
+#include "GridLayoutItem.h"
+
+
+inline void registerQmlTypes()
+{
+ qmlRegisterType("QuickKeyboard", 1, 0, "Keyboard");
+ qmlRegisterType("QuickKeyboard", 1, 0, "Mode");
+ qmlRegisterType("QuickKeyboard", 1, 0, "Button");
+ qmlRegisterType("QuickKeyboard", 1, 0, "Dispatcher");
+ qmlRegisterType();
+ qmlRegisterType();
+ qmlRegisterType("QuickKeyboard", 1, 0, "GridLayout");
+}
diff --git a/data/store.cpp b/data/store.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..517983b46806e63d208a3d8518ade1972dd5afab
--- /dev/null
+++ b/data/store.cpp
@@ -0,0 +1,428 @@
+#include "store.h"
+
+bool initialInfo = true;
+Worker *infoThread = nullptr;
+
+Store::Store() : rootView(rootObject()), context(rootContext())
+{
+ worker = new Worker({}, true);
+ // Start server
+ worker->checkServer();
+ context->setContextProperty("storeProg", QVariant(0.2));
+
+ connect(worker, &Worker::updateStatus, this, [this](QString stat) {
+ qDebug() << "LOG: " << stat;
+ if (stat.startsWith("TOTAL:"))
+ {
+ // Hacky trick to force redrawing Repeater
+ QStringList pagesList;
+ setProperty("pages", QVariant::fromValue(pagesList));
+
+ int totalItems = stat.mid(6).trimmed().toInt();
+ if (totalItems < 50)
+ return;
+
+ for (int i = 50; i < totalItems; i += 50)
+ pagesList.push_back(QString::number(i));
+
+ pagesList.push_back(QString::number(totalItems));
+ setProperty("pages", QVariant::fromValue(pagesList));
+ }
+ });
+ connect(worker, &Worker::updateProgress, this, [this](int prog) {
+ context->setContextProperty("storeProg", QVariant(0.2 + prog / 100.0 * 0.7));
+ });
+ connect(worker, &Worker::socketClosed, this, [this]() {
+ context->setContextProperty("titleVisible", QVariant(false));
+ setProperty("isBusy", false);
+ if (initialInfo && infoThread != nullptr) {
+ infoThread->work();
+ initialInfo = false;
+ }
+ });
+ connect(worker, &Worker::readAll, this, [this](QByteArray bytes) {
+ if (booksParent != nullptr) {
+ delete booksParent;
+ booksParent = nullptr;
+ }
+
+ _books.clear();
+ emit booksChanged();
+
+ context->setContextProperty("storeProg", QVariant(0.95));
+ QJsonParseError jsonError;
+ QJsonDocument document = QJsonDocument::fromJson(bytes, &jsonError);
+ if (jsonError.error != QJsonParseError::NoError)
+ {
+ qDebug() << "fromJson failed: " << jsonError.errorString();
+ context->setContextProperty("storeError", bytes);
+ return;
+ }
+
+ if (!document.isArray())
+ {
+ context->setContextProperty("storeError", QVariant("ERR: Server response malformed"));
+ return;
+ }
+
+ // QList booksList;
+ QJsonArray list = document.array();
+ if (list.size() == 0)
+ {
+ context->setContextProperty("storeError", QVariant("No result found"));
+ return;
+ }
+
+ booksParent = new QObject();
+
+ for (auto book : list)
+ {
+ if (!book.isObject())
+ continue;
+
+ QJsonObject bookObj = book.toObject();
+ Book *item = new Book(booksParent);
+ item->_name = bookObj.value("name").toString();
+ item->_author = bookObj.value("author").toString();
+ item->_imgFile = bookObj.value("img").toString();
+ if (item->_imgFile.size() > 0) {
+ item->_imgFile.prepend("image://gray/");
+ }
+ item->_url = bookObj.value("url").toString();
+
+ _books.push_back(item);
+ }
+
+ emit booksChanged();
+ context->setContextProperty("storeProg", QVariant(1));
+ context->setContextProperty("storeError", QVariant(""));
+ });
+}
+
+Store::~Store()
+{
+ if (worker != nullptr)
+ delete worker;
+
+ if (infoThread != nullptr)
+ delete infoThread;
+
+ if (serverProc != nullptr)
+ delete serverProc;
+}
+
+void Store::open()
+{
+ if (!loadConfig())
+ qDebug() << "config.json malformed";
+
+ newQuery(0);
+
+ if (_cookieAvailable)
+ {
+ infoThread = new Worker({"INFO"}, true);
+ connect(infoThread, &Worker::readAll, this, [this](QByteArray bytes) {
+ QJsonParseError jsonError;
+ QJsonDocument document = QJsonDocument::fromJson(bytes, &jsonError);
+ if (jsonError.error != QJsonParseError::NoError)
+ {
+ qDebug() << "fromJson failed: " << jsonError.errorString();
+ qDebug() << "ERR: " << bytes;
+ return;
+ }
+ if (!document.isObject())
+ return;
+
+ QJsonObject jsonObj = document.object();
+ QString downloads = jsonObj.value("today_download").toString("");
+ if (downloads.length() > 0)
+ {
+ auto counts = downloads.split("/");
+ downloads.prepend("↓ ");
+ if (counts[0] == counts[1])
+ {
+ downloads.prepend("⚠️ ");
+ }
+ this->setProperty("accountStatus", downloads);
+ }
+
+ QJsonValue historyList = jsonObj.value("today_list");
+ if (!historyList.isArray())
+ return;
+ QJsonArray downloadedBooks = historyList.toArray();
+ for (auto book : downloadedBooks)
+ {
+ auto bookObj = book.toObject();
+ QString url = bookObj.value("url").toString();
+
+ bool found = false;
+ for (auto seen : _downloadList)
+ {
+ if (url == seen->property("url"))
+ {
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ continue;
+ Book *item = new Book(nullptr);
+ item->_url = url;
+ item->_name = bookObj.value("name").toString();
+ _downloadList.push_back(item);
+ }
+ emit downloadListChanged();
+ });
+ }
+ else
+ {
+ setProperty("accountStatus", "⚠️ Cookie is not configured");
+ }
+}
+
+void Store::newQuery(int page = 0)
+{
+ _currentPage = page;
+ QStringList args = {
+ "LIST",
+ _exactMatch,
+ _fromYear,
+ _toYear,
+ _language,
+ _extension,
+ _order,
+ _query,
+ QString::number(page + 1)
+ };
+
+ stopQuery();
+ setProperty("isBusy", true);
+ worker->args = args;
+ context->setContextProperty("storeProg", QVariant(0.2));
+ worker->work();
+}
+
+void Store::openSavedList(int page = 0)
+{
+ _currentPage = page;
+ QStringList args = {
+ "SAVE",
+ QString::number(page + 1)
+ };
+
+ stopQuery();
+ setProperty("isBusy", true);
+ worker->args = args;
+ context->setContextProperty("storeProg", QVariant(0.2));
+ worker->work();
+}
+
+void Store::stopQuery()
+{
+ if (worker->isRunning())
+ worker->terminate();
+ setProperty("isBusy", false);
+}
+
+bool Store::loadConfig()
+{
+ QFile file(QCoreApplication::applicationDirPath() + "/config.json");
+
+ if (!file.open(QIODevice::ReadOnly))
+ return false;
+
+ QByteArray bytes = file.readAll();
+ file.close();
+
+ QJsonParseError jsonError;
+ QJsonDocument document = QJsonDocument::fromJson(bytes, &jsonError);
+ if (jsonError.error != QJsonParseError::NoError)
+ {
+ qDebug() << "fromJson failed: " << jsonError.errorString();
+ return false;
+ }
+ if (!document.isObject())
+ return false;
+
+ QJsonObject jsonObj = document.object();
+
+ _cookieAvailable = jsonObj.value("cookie").toString("").length() > 0;
+
+ QJsonValue defaultQueryValue = jsonObj.value("defaultQuery");
+ if (!defaultQueryValue.isObject())
+ return false;
+
+ QJsonObject defaultQueryObj = defaultQueryValue.toObject();
+
+ _exactMatch = defaultQueryObj.value("exactMatch").toString("");
+ _fromYear = defaultQueryObj.value("fromYear").toString("");
+ _toYear = defaultQueryObj.value("toYear").toString("");
+ _language = defaultQueryObj.value("language").toString("");
+ _extension = defaultQueryObj.value("extension").toString("");
+ _order = defaultQueryObj.value("order").toString("");
+ _query = defaultQueryObj.value("query").toString("");
+
+ return true;
+}
+
+bool Store::setConfig()
+{
+ QFile file(QCoreApplication::applicationDirPath() + "/config.json");
+
+ if (!file.open(QIODevice::ReadOnly))
+ {
+ qDebug() << "Can't open config.json in read-only";
+ return false;
+ }
+
+ QByteArray bytes = file.readAll();
+ file.close();
+
+ QJsonParseError jsonError;
+ QJsonDocument document = QJsonDocument::fromJson(bytes, &jsonError);
+ if (jsonError.error != QJsonParseError::NoError)
+ {
+ qDebug() << "fromJson failed: " << jsonError.errorString();
+ return false;
+ }
+ if (!document.isObject())
+ {
+ qDebug() << "config.json malformed";
+ return false;
+ }
+
+ QJsonObject jsonObj = document.object();
+
+ QJsonObject defaultQuery;
+
+ defaultQuery.insert("exactMatch", _exactMatch);
+ defaultQuery.insert("fromYear", _fromYear);
+ defaultQuery.insert("toYear", _toYear);
+ defaultQuery.insert("language", _language);
+ defaultQuery.insert("extension", _extension);
+ defaultQuery.insert("order", _order);
+ defaultQuery.insert("query", _query);
+
+ jsonObj.remove("defaultQuery");
+ jsonObj.insert("defaultQuery", defaultQuery);
+
+ file.remove();
+ if (!file.open(QIODevice::WriteOnly))
+ {
+ qDebug() << "Can't open config.json in write-only";
+ return false;
+ }
+
+ QByteArray writeBytes = QJsonDocument(jsonObj).toJson(QJsonDocument::Indented);
+
+ QTextStream iStream(&file);
+ iStream.setCodec("utf-8");
+ iStream << writeBytes;
+ file.close();
+
+ return true;
+}
+
+void Store::download(Book* book)
+{
+ if (book->worker == nullptr) {
+ book->worker = new Worker({"DOWN", book->_dlUrl});
+ connect(book->worker, &Worker::updateProgress, book, &Book::updateProgress);
+ connect(book->worker, &Worker::updateStatus, book, [book](QString stat) {
+ qDebug() << "LOG: " << stat;
+ if (stat.startsWith("ERR:"))
+ {
+ book->setProperty("status", QVariant(stat.trimmed()));
+ book->worker->terminate();
+ delete book->worker;
+ }
+ });
+ connect(book->worker, &Worker::socketClosed, book, [book]() {
+ if (infoThread != nullptr && !infoThread->isRunning())
+ {
+ infoThread->work();
+ }
+ });
+ }
+
+ book->setParent(nullptr);
+ _downloadList.prepend(book);
+ emit downloadListChanged();
+
+ book->setProperty("status", QVariant("Downloading"));
+ book->worker->work();
+}
+
+Book::~Book() {
+ if (worker != nullptr) {
+ delete worker;
+ }
+}
+
+void Book::getDetail(QObject* popup)
+{
+ if (_metadownloaded)
+ {
+ return;
+ }
+
+ Worker *metaWorker = new Worker({"META", _url}, true);
+ connect(metaWorker, &Worker::readAll, this, [this, metaWorker, popup](QByteArray bytes) {
+ QJsonParseError jsonError;
+ QJsonDocument document = QJsonDocument::fromJson(bytes, &jsonError);
+ if (jsonError.error != QJsonParseError::NoError)
+ {
+ qDebug() << "fromJson failed: " << jsonError.errorString();
+ setProperty("desc", bytes);
+ return;
+ }
+ if (!document.isObject())
+ {
+ return;
+ }
+ QJsonObject detail = document.object();
+ setProperty("name", detail.value("name").toString());
+ setProperty("author", detail.value("author").toString());
+ setProperty("dlUrl", detail.value("dlUrl").toString());
+ setProperty("desc", detail.value("description").toString());
+ auto imgFile = detail.value("img").toString();
+ if (imgFile.size() > 0)
+ {
+ imgFile.prepend("image://gray/");
+ }
+ setProperty("imgFile", imgFile);
+
+ QJsonArray similarsArray = detail.value("similars").toArray();
+ QList recList;
+ for (auto recom : similarsArray)
+ {
+ QJsonObject bookObj = recom.toObject();
+ Book *item = new Book(this);
+ item->setProperty("imgFile", bookObj.value("img").toString());
+ item->setProperty("url", bookObj.value("url").toString());
+ recList.push_back(item);
+ }
+ setProperty("similars", QVariant::fromValue(recList));
+
+ setProperty("status", "Download");
+ _metadownloaded = true;
+ popup->setProperty("isBusy", false);
+
+ qDebug() << "Meta downloaded";
+ delete metaWorker;
+ });
+
+ qDebug() << "Meta downloading";
+ popup->setProperty("isBusy", true);
+ metaWorker->work();
+}
+
+void Book::updateProgress(int prog)
+{
+ if (prog == 100)
+ {
+ setProperty("status", QVariant("Downloaded"));
+ return;
+ }
+ setProperty("status", QVariant(QString::number(prog) + "%"));
+}
\ No newline at end of file
diff --git a/data/store.h b/data/store.h
new file mode 100644
index 0000000000000000000000000000000000000000..2c88a3f5a57a32af7342a03c8781291dfcc2ef20
--- /dev/null
+++ b/data/store.h
@@ -0,0 +1,119 @@
+#ifndef STORE_H
+#define STORE_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "worker.h"
+
+class Book : public QObject
+{
+ Q_OBJECT
+
+public:
+ Book(QObject* parent) : QObject(parent) {};
+ ~Book();
+
+ Q_PROPERTY(QString imgFile MEMBER _imgFile NOTIFY imgFileChanged)
+ Q_PROPERTY(QString name MEMBER _name NOTIFY nameChanged)
+ Q_PROPERTY(QString author MEMBER _author NOTIFY authorChanged)
+ Q_PROPERTY(QString url MEMBER _url NOTIFY urlChanged)
+ Q_PROPERTY(QString desc MEMBER _desc NOTIFY descChanged)
+ Q_PROPERTY(QString dlUrl MEMBER _dlUrl NOTIFY dlUrlChanged)
+ Q_PROPERTY(QString status MEMBER _status NOTIFY statusChanged)
+ Q_PROPERTY(QList similars MEMBER _similars NOTIFY similarsChanged)
+
+ Q_INVOKABLE void getDetail(QObject *popup);
+
+ void updateProgress(int prog);
+
+signals:
+ void imgFileChanged(QString);
+ void nameChanged(QString);
+ void authorChanged(QString);
+ void urlChanged(QString);
+ void descChanged(QString);
+ void dlUrlChanged(QString);
+ void statusChanged(QString);
+ void similarsChanged(QList);
+
+public:
+ Worker *worker = nullptr;
+ QString _imgFile;
+ QString _name;
+ QString _author;
+ QString _url;
+ QString _desc;
+ QString _dlUrl;
+ QString _status;
+ QList _similars;
+ bool _metadownloaded = false;
+};
+
+class Store : public QQuickView
+{
+ Q_OBJECT
+public:
+ Q_PROPERTY(QList books MEMBER _books NOTIFY booksChanged)
+ Q_PROPERTY(QList downloadList MEMBER _downloadList NOTIFY downloadListChanged)
+ Q_PROPERTY(bool isBusy MEMBER _isBusy NOTIFY isBusyChanged)
+ Q_PROPERTY(QString exactMatch MEMBER _exactMatch)
+ Q_PROPERTY(QString fromYear MEMBER _fromYear)
+ Q_PROPERTY(QString toYear MEMBER _toYear)
+ Q_PROPERTY(QString language MEMBER _language)
+ Q_PROPERTY(QString extension MEMBER _extension)
+ Q_PROPERTY(QString order MEMBER _order)
+ Q_PROPERTY(QString query MEMBER _query)
+ Q_PROPERTY(QString accountStatus MEMBER _accountStatus NOTIFY accountStatusChanged)
+ Q_PROPERTY(QStringList pages MEMBER _pages NOTIFY pagesChanged)
+ Q_PROPERTY(int currentPage MEMBER _currentPage NOTIFY currentPageChanged)
+
+ Store();
+ ~Store();
+ bool loadConfig();
+ void open();
+
+public slots:
+ Q_INVOKABLE void newQuery(int page);
+ Q_INVOKABLE void openSavedList(int page);
+ Q_INVOKABLE void stopQuery();
+ Q_INVOKABLE bool setConfig();
+ Q_INVOKABLE void download(Book*);
+
+signals:
+ void booksChanged();
+ void downloadListChanged();
+ void isBusyChanged();
+ void accountStatusChanged();
+ void pagesChanged();
+ void currentPageChanged();
+
+private:
+ QQuickItem *rootView;
+ QQmlContext *context;
+ QQuickItem *storeView;
+ QList _books;
+ QList _downloadList;
+ QObject *booksParent = nullptr;
+ bool _isBusy;
+ Worker *worker = nullptr;
+ QString _exactMatch = "0";
+ QString _fromYear = "2021";
+ QString _toYear = "2021";
+ QString _language = "English";
+ QString _extension = "epub";
+ QString _order = "Most Popular";
+ QString _query = "";
+ QString _accountStatus;
+
+ bool _cookieAvailable;
+ QStringList _pages = { "10", "20", "30"};
+ int _currentPage = 0;
+};
+
+#endif /* STORE_H */
\ No newline at end of file
diff --git a/data/worker.h b/data/worker.h
new file mode 100644
index 0000000000000000000000000000000000000000..4483ba52f11ee1f64fa3bbdc8527d2a6bc7659b3
--- /dev/null
+++ b/data/worker.h
@@ -0,0 +1,92 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+
+static QProcess *serverProc = nullptr;
+
+class Worker : public QThread
+{
+ Q_OBJECT
+public:
+ Worker(QStringList args, bool isReadAll = false) : args(args), isReadAll(isReadAll) {}
+
+ QStringList args;
+ bool isReadAll;
+ QString socketPath = "/tmp/zshelf_socket";
+
+ static void createServer() {
+ serverProc = new QProcess;
+ serverProc->start("/opt/bin/node", {QGuiApplication::applicationDirPath() + "/backend/server.js"}, QIODevice::ReadOnly);
+ serverProc->waitForStarted();
+ serverProc->waitForReadyRead();
+ }
+
+ static void checkServer() {
+ if (serverProc == nullptr) createServer();
+
+ if (serverProc->state() == QProcess::NotRunning)
+ {
+ qDebug() << "[SERVER] Not running " << serverProc->state() << serverProc->error();
+ delete serverProc;
+ createServer();
+ }
+ qDebug() << "[SERVER] " << serverProc->state();
+ }
+
+ void work() {
+ checkServer();
+ start();
+ }
+
+ void run() override
+ {
+ QLocalSocket sock;
+ sock.connectToServer(socketPath, QIODevice::ReadWrite);
+ sock.waitForConnected();
+ qDebug() << "[SOCKET]" << args[0] << "Connected";
+ for (auto arg : args) {
+ sock.write(arg.toStdString().c_str());
+ sock.write("\n", 1);
+ }
+ sock.waitForBytesWritten();
+ QByteArray bytes;
+ while (sock.waitForReadyRead() || sock.canReadLine())
+ {
+ QByteArray line = sock.readLine();
+
+ if (line.startsWith("PROG:"))
+ {
+ emit updateProgress(line.mid(5).trimmed().toInt());
+ continue;
+ }
+ else if (line.startsWith("TOTAL:"))
+ {
+ emit updateStatus(line);
+ continue;
+ }
+
+ if (isReadAll)
+ bytes.push_back(line);
+ else
+ emit updateStatus(line);
+
+ if (line.startsWith("ERR:")) break;
+ }
+
+ if (isReadAll)
+ emit readAll(bytes);
+
+ sock.close();
+ emit socketClosed();
+ qDebug() << "[SOCKET]" << args[0] << "Closed";
+ };
+signals:
+ void updateProgress(int result);
+ void updateStatus(QString str);
+ void readAll(QByteArray bytes);
+ void socketClosed();
+};
\ No newline at end of file
diff --git a/data/zshelf.pro b/data/zshelf.pro
new file mode 100644
index 0000000000000000000000000000000000000000..62d17d21249ff7f0c50be50475b6e9ccc5181bec
--- /dev/null
+++ b/data/zshelf.pro
@@ -0,0 +1,51 @@
+TEMPLATE = app
+QT += quick network
+CONFIG += c++11
+LIBS += -lqsgepaper
+
+TARGET = zshelf
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES = main.cpp \
+ store.cpp
+
+HEADERS = \
+ worker.h \
+ store.h \
+ grayImage.h
+
+RESOURCES += qml.qrc
+
+include(quickvirtualkeyboard/components.pri)
+
+DEPLOYMENT_PATH = /usr/share/$$TARGET
+DEFINES += DEPLOYMENT_PATH=\\\"$$DEPLOYMENT_PATH\\\"
+DEFINES += QML_FOLDER=\\\"qml\\\"
+
+# Installs /etc/draft and /lib/systemd/system/draft.service.
+configFile.files=config.json
+configFile.path =/etc/zshelf
+INSTALLS += configFile
+
+backend.files = backend
+backend.path=/etc/zshelf
+INSTALLS += backend
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+target.path = /usr/bin
+INSTALLS += target
+
+MOC_DIR = mocs
+OBJECTS_DIR = objs
\ No newline at end of file