modificado el estilo de los splitters y la toolbar de comics

This commit is contained in:
Luis Ángel San Martín
2013-05-26 18:47:37 +02:00
commit 754953cc30
485 changed files with 43643 additions and 0 deletions

46
CHANGELOG.txt Normal file
View File

@ -0,0 +1,46 @@
6.3
Mejorada la gesti<74>n de errores relacionada con las bibliotecas
A<EFBFBD>adido bot<6F>n que permite ocultar las portadas en la pantalla de importaci<63>n
A<EFBFBD>adidos t<>tulos "Bibliotecas" y "Carpetas" a la barra de navegaci<63>n
Nuevos iconos para seleccionar la carpeta ra<72>z, expandir y contraer todos.
Bot<EFBFBD>n para cambiar el puerto del servidor por el usuario.
Ahora las columnas de la lista de c<>mics pueden reordenarse
Ahora YACReaderLibrary s<>lo permite una instancia ejecutandose.
Columna le<6C>do a<>adida.
Cambiado estilo de la lista de c<>cmis
Corregidos bugs relacionados con realizar operaciones sobre c<>mics cuando no hab<61>a ninguno seleccionado en la lista de c<>mics
6.2
Nueva ventana de "bienvenida"
Nueva ventana de importar/actualizar
Nuevo control para la b<>squeda
Nueva imagen para las marcas de c<>mics le<6C>dos (s<>lo en OpenGL)
Cambiada la distribuci<63>n de algunos iconos
Cambiado el modo de eliminar la metainformaci<63>n (borrar base de datos/portadas de disco)
Ocultadas las opciones avanzadas de configuraci<63>n de YACReader Flow, accesibles ahora tras pulsar un bot<6F>n (di<64>logos de configuraci<63>n m<>s simples)
6.0.1 (No p<>blica)
Corregido bug al usar las teclas Inicio/fin
Corregido bug que al arrancar YACReaderLibrary por primera vez causaba que no se mostrasen las portadas (s<>lo bajo ciertas circunstancias)
A<EFBFBD>adidos algunos atajos de teclado a YACReaderLibrary a los ya existentes
6.0
Mejorada la velocidad de inicio gracias al uso de /LTCG como opci<63>n de compilaci<63>n
Corregido bug relacionado con OpenGL que causaba consumo excesivo de CPU en tarjetas NVidia
A<EFBFBD>adidos iconos para cada tipo de archivo soportado en YACReaderLibrary
Cambiado el icono "folder" en YACReaderLibrary
A<EFBFBD>adida barra para ajustar el ancho de p<>gina en la toolbar de YACReader
A<EFBFBD>adido widget para la information label
A<EFBFBD>adido nuevo estilo visual a goToFlow
A<EFBFBD>adidos filtros para controlar el brillo, el contraste y el valor gamma
A<EFBFBD>adidas notificaciones de portada y <20>ltima p<>gina
InformationLabel se muestra ahora en la esquina superiror derecha.
InformationLabel se muestra en 3 tama<6D>os diferentes en funci<63>n de la resoluci<63>n
Corregido bug que causaba que las marcas de c<>mic le<6C>do no se dibujasen adecuadamente.
Se recuerda si se debe mostrar o no la "label" informaci<63>n.
Corregido bug que provocaba el fallo de YACReader al pasar muy r<>pido las p<>ginas.
A<EFBFBD>adida columna "Tama<6D>o" a la lista de c<>mics en YACReaderLibrary
A<EFBFBD>adida la ordinaci<63>n "natural" de los comics que hay en directorio del c<>mic actual.
Corregido bug que causaba que se abriese el c<>mic erroneo en YACReaderLibrary.
Cambiado el modo en el que se cargan los lenguages, ahora se pueden a<>adir traducciones sin necesidad de recompilar.

674
COPYING.txt Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

22
README.txt Normal file
View File

@ -0,0 +1,22 @@
LICENSE
*******
This software has been developed by Luis <20>ngel San Mart<72>n Rodr<64>guez (luisangelsm@gmail.com) under GPL v3 license
(for more details read COPYING.txt).
CONTACT
*******
Project home page : www.yacreader.com
e-mail:
info@yacreader.com
support@yacreader.com
Social:
Facebook - http://www.facebook.com/YACReader
Twitter - https://twitter.com/yacreader
YouTube - https://www.youtube.com/user/yacreader
If you need help or have any suggestion, please, send me an e-mail.
DONATIONS
*********
YACReader is free but it needs money to still be alive, so please,
if you like YACReader, visit the home page and make a donation.

BIN
YACReader/YACReader.icns Normal file

Binary file not shown.

112
YACReader/YACReader.pro Normal file
View File

@ -0,0 +1,112 @@
# #####################################################################
# Automatically generated by qmake (2.01a) mi<EFBFBD> 8. oct 20:54:05 2008
# #####################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += . \
release
INCLUDEPATH += .
INCLUDEPATH += ../common \
../custom_widgets
win32 {
INCLUDEPATH += ../dependencies/poppler/include
LIBS += -L../dependencies/poppler/lib -lpoppler-qt4
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
}
unix:!macx{
INCLUDEPATH += /usr/include/poppler/qt4
LIBS += -L/usr/lib -lpoppler-qt4
LIBS += -lGLU
}
macx{
#INCLUDEPATH += "/Volumes/Mac OS X Lion/usr/X11/include"
INCLUDEPATH += /usr/local/include/poppler/qt4
LIBS += -L/usr/local/lib -lpoppler-qt4
}
QT += network webkit phonon opengl
CONFIG += release
CONFIG -= flat
# Input
HEADERS += comic.h \
configuration.h \
goto_dialog.h \
magnifying_glass.h \
main_window_viewer.h \
viewer.h \
goto_flow.h \
options_dialog.h \
bookmarks.h \
bookmarks_dialog.h \
render.h \
shortcuts_dialog.h \
translator.h \
goto_flow_gl.h \
goto_flow_widget.h \
page_label_widget.h \
goto_flow_toolbar.h \
goto_flow_decorationbar.h \
width_slider.h \
notifications_label_widget.h \
../common/pictureflow.h \
../common/custom_widgets.h \
../common/check_new_version.h \
../common/qnaturalsorting.h \
../common/yacreader_flow_gl.h \
../common/yacreader_global.h \
../common/onstart_flow_selection_dialog.h \
yacreader_local_client.h
SOURCES += comic.cpp \
configuration.cpp \
goto_dialog.cpp \
magnifying_glass.cpp \
main.cpp \
main_window_viewer.cpp \
viewer.cpp \
goto_flow.cpp \
options_dialog.cpp \
bookmarks.cpp \
bookmarks_dialog.cpp \
render.cpp \
shortcuts_dialog.cpp \
translator.cpp \
goto_flow_gl.cpp \
goto_flow_widget.cpp \
page_label_widget.cpp \
goto_flow_toolbar.cpp \
goto_flow_decorationbar.cpp \
width_slider.cpp \
notifications_label_widget.cpp \
../common/pictureflow.cpp \
../common/custom_widgets.cpp \
../common/check_new_version.cpp \
../common/qnaturalsorting.cpp \
../common/yacreader_flow_gl.cpp \
../common/onstart_flow_selection_dialog.cpp \
yacreader_local_client.cpp
include(../custom_widgets/custom_widgets.pri)
RESOURCES += images.qrc \
files.qrc
RC_FILE = icon.rc
macx {
ICON = YACReader.icns
}
TRANSLATIONS = yacreader_es.ts \
yacreader_fr.ts \
yacreader_ru.ts \
yacreader_pt.ts \
FORMS +=
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug

159
YACReader/bookmarks.cpp Normal file
View File

@ -0,0 +1,159 @@
#include "bookmarks.h"
#include <QFile>
#include <QDataStream>
#include <QCoreApplication>
#include <QFileInfo>
#include <QMessageBox>
#define NUM_BOOKMARKS 250
Bookmarks::Bookmarks()
:lastPageIndex(0)
{
list.load();
}
void Bookmarks::setLastPage(int index,const QImage & page)
{
lastPageIndex = index;
lastPage = page;
}
void Bookmarks::setBookmark(int index,const QImage & page)
{
if(!bookmarks.contains(index))
{
bookmarks.insert(index,page);
latestBookmarks.push_front(index);
if(latestBookmarks.count()>3)
{
bookmarks.remove(latestBookmarks.back());
latestBookmarks.pop_back();
}
}
else //udate de pixmap;
{
bookmarks[index]=page;
}
}
void Bookmarks::removeBookmark(int index)
{
bookmarks.remove(index);
}
QList<int> Bookmarks::getBookmarkPages() const
{
return bookmarks.keys();
}
QImage Bookmarks::getBookmarkPixmap(int page) const
{
return bookmarks.value(page);
}
QImage Bookmarks::getLastPagePixmap() const
{
return lastPage;
}
int Bookmarks::getLastPage() const
{
return lastPageIndex;
}
bool Bookmarks::isBookmark(int page)
{
return bookmarks.contains(page);
}
bool Bookmarks::imageLoaded(int page)
{
return !bookmarks.value(page).isNull();
}
void Bookmarks::newComic(const QString & path)
{
QFileInfo f(path);
QString comicID = f.fileName().toLower()+QString::number(f.size());
clear();
BookmarksList::Bookmark b = list.get(comicID);
comicPath=comicID;
lastPageIndex = b.lastPage;
latestBookmarks = b.bookmarks;
for(int i=0;i<latestBookmarks.count();i++)
bookmarks.insert(latestBookmarks.at(i),QImage());
added = b.added;
}
void Bookmarks::clear()
{
bookmarks.clear();
latestBookmarks.clear();
lastPageIndex=0;
lastPage = QImage();
}
void Bookmarks::save()
{
BookmarksList::Bookmark b;
b.lastPage = lastPageIndex;
b.bookmarks = getBookmarkPages();
BookmarksList::Bookmark previousBookmarks;
bool updated = ((previousBookmarks.lastPage != b.lastPage) || (previousBookmarks.bookmarks != b.bookmarks));
if(b.added.isNull() || updated)
b.added = QDateTime::currentDateTime();
list.add(comicPath,b);
list.save();
}
//-----------------------------------------------------------------------------
void BookmarksList::load()
{
QFile f(QCoreApplication::applicationDirPath()+"/bookmarks.yacr");
if(f.open(QIODevice::ReadOnly))
{
QDataStream dataS(&f);
dataS >> list;
f.close();
}
}
void BookmarksList::save()
{
QFile f(QCoreApplication::applicationDirPath()+"/bookmarks.yacr");
f.open(QIODevice::WriteOnly);
QDataStream dataS(&f);
if(list.count()>NUM_BOOKMARKS)
deleteOldest(list.count()-NUM_BOOKMARKS);
dataS << list;
f.close();
}
void BookmarksList::deleteOldest(int num)
{
QString comic;
QDateTime date(QDate(10000,1,1));//TODO MAX_DATE??
for(QMap<QString,Bookmark>::const_iterator itr=list.begin();itr!=list.end();itr++)
{
if(itr->added<date)
{
comic=itr.key();
date = itr->added;
}
}
list.remove(comic);
}
void BookmarksList::add(const QString & comicID, const Bookmark & b)
{
list.insert(comicID,b);
}
BookmarksList::Bookmark BookmarksList::get(const QString & comicID)
{
//if(list.contains(comicID)
return list.value(comicID);
}

77
YACReader/bookmarks.h Normal file
View File

@ -0,0 +1,77 @@
#ifndef BOOKMARKS_H
#define BOOKMARKS_H
#include <QObject>
#include <QMap>
#include <QImage>
#include <QString>
#include <QMap>
#include <QDateTime>
class BookmarksList
{
public:
struct Bookmark {
int lastPage;
QList<int> bookmarks;
QDateTime added;
Bookmark():lastPage(0){};
friend QDataStream & operator<< ( QDataStream & out, const Bookmark & bm )
{
out << bm.lastPage;
out << bm.bookmarks;
out << bm.added;
return out;
}
friend QDataStream & operator>> ( QDataStream & in, Bookmark & bm )
{
in >> bm.lastPage;
in >> bm.bookmarks;
in >> bm.added;
return in;
}
};
BookmarksList(){}
void load();
void save();
void add(const QString & comicID, const Bookmark & b);
Bookmark get(const QString & comicID);
protected:
QMap<QString,Bookmark> list;
void deleteOldest(int num);
};
class Bookmarks : public QObject
{
Q_OBJECT
protected:
QString comicPath;
//bookmarks setted by the user
QMap<int,QImage> bookmarks;
QList<int> latestBookmarks;
//last page readed
int lastPageIndex;
QImage lastPage;
BookmarksList list;
QDateTime added;
public:
Bookmarks();
void setLastPage(int index,const QImage & page);
void setBookmark(int index,const QImage & page);
void removeBookmark(int index);
QList<int> getBookmarkPages() const;
QImage getBookmarkPixmap(int page) const;
QImage getLastPagePixmap() const;
int getLastPage() const;
bool isBookmark(int page);
bool imageLoaded(int page);
void newComic(const QString & path);
void clear();
void save();
};
#endif // BOOKMARKS_H

View File

@ -0,0 +1,182 @@
#include "bookmarks_dialog.h"
#include <QGridLayout>
#include <QLabel>
#include <QApplication>
#include <QDesktopWidget>
#include <QFrame>
#include <QImage>
#include "bookmarks.h"
BookmarksDialog::BookmarksDialog(QWidget * parent)
:QDialog(parent,Qt::FramelessWindowHint)
{
setModal(true);
animation = new QPropertyAnimation(this,"windowOpacity");
animation->setDuration(150);
QHBoxLayout * layout = new QHBoxLayout();
//bookmarks
QGridLayout * bookmarksL = new QGridLayout();
pages.push_back(new QLabel(tr("Lastest Page")));
for(int i=0;i<3;i++)
pages.push_back(new QLabel("-"));
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
int height,width;
height = heightDesktopResolution*0.50;
width = height*0.65;
coverSize = QSize(width,height);
for(int i=0;i<4;i++)
{
QLabel * l = new QLabel();
l->setFixedSize(coverSize);
l->setScaledContents(false);
//l->setPixmap(QPixmap(":/images/notCover.png"));
l->installEventFilter(this);
images.push_back(l);
}
for(int i=0;i<3;i++)
bookmarksL->addWidget(pages.at(i+1),0,i,Qt::AlignCenter);
for(int i=0;i<3;i++)
bookmarksL->addWidget(images.at(i+1),1,i,Qt::AlignCenter);
//last page
QGridLayout * lp = new QGridLayout();
lp->addWidget(pages.at(0),0,0,Qt::AlignCenter);
lp->addWidget(images.at(0),1,0,Qt::AlignCenter);
layout->addLayout(bookmarksL);
QFrame *f = new QFrame( this );
f->setFrameStyle( QFrame::VLine | QFrame::Sunken );
layout->addWidget(f);
layout->addLayout(lp);
QHBoxLayout * buttons = new QHBoxLayout();
cancel = new QPushButton(tr("Close"));
cancel->setFlat(true);
connect(cancel,SIGNAL(clicked()),this,SLOT(hide()));
buttons->addStretch();
buttons->addWidget(cancel);
QVBoxLayout * l = new QVBoxLayout();
l->addWidget(new QLabel(tr("Click on any image to go to the bookmark")),0,Qt::AlignCenter);
l->addLayout(layout);
l->addLayout(buttons);
this->setPalette(QPalette(QColor(25,25,25)));
//this->setAutoFillBackground(true);
setLayout(l);
}
void BookmarksDialog::setBookmarks(const Bookmarks & bm)
{
lastPage = bm.getLastPage();
if (lastPage > 0)
{
QPixmap p = QPixmap::fromImage(bm.getLastPagePixmap());
if(p.isNull())
{
images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
images.at(0)->setText(tr("Loading..."));
}
else
{
images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignBottom);
images.at(0)->setPixmap(p.scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
}
}
else
{
images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
images.at(0)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
}
QList<int> l = bm.getBookmarkPages();
int s = l.count();
for(int i=0;i<s;i++)
{
pages.at(i+1)->setText(QString::number(l.at(i)+1));
QPixmap p = QPixmap::fromImage(bm.getBookmarkPixmap(l.at(i)));
if(p.isNull())
{
images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
images.at(i+1)->setText(tr("Loading..."));
}
else
{
images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignBottom);
images.at(i+1)->setPixmap(p.scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
}
}
for(int i=s;i<3;i++)
{
pages.at(i+1)->setText("-");
images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
images.at(i+1)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
}
}
bool BookmarksDialog::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::MouseButtonPress)
{
if (obj == images.at(0))
{
emit(goToPage(lastPage+1));
close();
event->accept();
}
for(int i=1;i<=3;i++)
{
if(obj == images.at(i))
{
bool b;
int page = pages.at(i)->text().toInt(&b);
if(b)
{
emit(goToPage(page));
close();
}
event->accept();
}
}
}
// pass the event on to the parent class
return QDialog::eventFilter(obj, event);
}
void BookmarksDialog::keyPressEvent(QKeyEvent * event)
{
if(event->key() == Qt::Key_M)
hide();
}
void BookmarksDialog::show()
{
QDialog::show();
disconnect(animation,SIGNAL(finished()),this,SLOT(close()));
animation->setStartValue(0);
animation->setEndValue(1);
animation->start();
}
void BookmarksDialog::hide()
{
connect(animation,SIGNAL(finished()),this,SLOT(close()));
animation->setStartValue(1);
animation->setEndValue(0);
animation->start();
}

View File

@ -0,0 +1,45 @@
#ifndef __BOOKMARKS_DIALOG_H
#define __BOOKMARKS_DIALOG_H
#include <QWidget>
#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QEvent>
#include <QKeyEvent>
#include <QPropertyAnimation>
#include "bookmarks.h"
class BookmarksDialog : public QDialog
{
Q_OBJECT
protected:
QList<QLabel *> pages;
QList<QLabel *> images;
int lastPage;
QPushButton * accept;
QPushButton * cancel;
QSize coverSize;
bool eventFilter(QObject *obj, QEvent *event);
void keyPressEvent(QKeyEvent * event);
QPropertyAnimation * animation;
public:
BookmarksDialog(QWidget * parent = 0);
public slots:
void setBookmarks(const Bookmarks & bookmarks);
void show();
void hide();
signals:
void goToPage(unsigned int page);
};
#endif // BOOKMARKS_DIALOG_H

488
YACReader/comic.cpp Normal file
View File

@ -0,0 +1,488 @@
#include "comic.h"
#include <QPixmap>
#include <QRegExp>
#include <QString>
#include <algorithm>
#include <QDir>
#include <QFileInfoList>
#include "bookmarks.h" //TODO desacoplar la dependencia con bookmarks
#include "qnaturalsorting.h"
#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp"
//-----------------------------------------------------------------------------
Comic::Comic()
:_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false)
{
setup();
}
//-----------------------------------------------------------------------------
Comic::Comic(const QString & pathFile)
:_pages(),_index(0),_path(pathFile),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false)
{
setup();
}
//-----------------------------------------------------------------------------
Comic::~Comic()
{
delete bm; //TODO safe delete
}
//-----------------------------------------------------------------------------
void Comic::setup()
{
connect(this,SIGNAL(pageChanged(int)),this,SLOT(checkIsBookmark(int)));
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(updateBookmarkImage(int)));
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(setPageLoaded(int)));
}
//-----------------------------------------------------------------------------
int Comic::nextPage()
{
if(_index<_pages.size()-1)
{
_index++;
emit pageChanged(_index);
}
else
emit isLast();
return _index;
}
//---------------------------------------------------------------------------
int Comic::previousPage()
{
if(_index>0)
{
_index--;
emit pageChanged(_index);
}
else
emit isCover();
return _index;
}
//-----------------------------------------------------------------------------
void Comic::setIndex(unsigned int index)
{
int previousIndex = _index;
if(static_cast<int>(index)<_pages.size()-1)
_index = index;
else
_index = _pages.size()-1;
if(previousIndex != _index)
emit pageChanged(_index);
}
//-----------------------------------------------------------------------------
/*QPixmap * Comic::currentPage()
{
QPixmap * p = new QPixmap();
p->loadFromData(_pages[_index]);
return p;
}
//-----------------------------------------------------------------------------
QPixmap * Comic::operator[](unsigned int index)
{
QPixmap * p = new QPixmap();
p->loadFromData(_pages[index]);
return p;
}*/
//-----------------------------------------------------------------------------
bool Comic::loaded()
{
return _loaded;
}
//-----------------------------------------------------------------------------
void Comic::loadFinished()
{
emit imagesLoaded();
}
//-----------------------------------------------------------------------------
void Comic::setBookmark()
{
QImage p;
p.loadFromData(_pages[_index]);
bm->setBookmark(_index,p);
//emit bookmarksLoaded(*bm);
emit bookmarksUpdated();
}
//-----------------------------------------------------------------------------
void Comic::removeBookmark()
{
bm->removeBookmark(_index);
//emit bookmarksLoaded(*bm);
emit bookmarksUpdated();
}
//-----------------------------------------------------------------------------
void Comic::saveBookmarks()
{
QImage p;
p.loadFromData(_pages[_index]);
bm->setLastPage(_index,p);
bm->save();
}
//-----------------------------------------------------------------------------
void Comic::checkIsBookmark(int index)
{
emit isBookmark(bm->isBookmark(index));
}
//-----------------------------------------------------------------------------
void Comic::updateBookmarkImage(int index)
{
if(bm->isBookmark(index))
{
QImage p;
p.loadFromData(_pages[index]);
bm->setBookmark(index,p);
emit bookmarksUpdated();
//emit bookmarksLoaded(*bm);
}
if(bm->getLastPage() == index)
{
QImage p;
p.loadFromData(_pages[index]);
bm->setLastPage(index,p);
emit bookmarksUpdated();
//emit bookmarksLoaded(*bm);
}
}
//-----------------------------------------------------------------------------
void Comic::setPageLoaded(int page)
{
_loadedPages[page] = true;
}
//-----------------------------------------------------------------------------
QByteArray Comic::getRawPage(int page)
{
if(page < 0 || page >= _pages.size())
return QByteArray();
return _pages[page];
}
//-----------------------------------------------------------------------------
bool Comic::pageIsLoaded(int page)
{
if(page < 0 || page >= _pages.size())
return false;
return _loadedPages[page];
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
FileComic::FileComic()
:Comic()
{
}
FileComic::FileComic(const QString & path)
:Comic(path)
{
load(path);
}
FileComic::~FileComic()
{
//Comic::~Comic();
}
bool FileComic::load(const QString & path)
{
QFileInfo fi(path);
if(fi.exists())
{
bm->newComic(path);
emit bookmarksUpdated();
//emit bookmarksLoaded(*bm);
_path = QDir::cleanPath(path);
//load files size
_7z = new QProcess();
QStringList attributes;
attributes << "l" << "-ssc-" << "-r" << _path EXTENSIONS;
connect(_7z,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(loadSizes(void)));
connect(_7z,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError)));
_7z->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes);
return true;
}
else
{
QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found"));
emit errorOpening();
return false;
}
}
//-----------------------------------------------------------------------------
void FileComic::loadSizes()
{
QRegExp rx("[0-9]{4}-[0-9]{2}-[0-9]{2}[ ]+[0-9]{2}:[0-9]{2}:[0-9]{2}[ ]+.{5}[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)");
QByteArray ba = _7z->readAllStandardOutput();
QList<QByteArray> lines = ba.split('\n');
QByteArray line;
QString name;
foreach(line,lines)
{
if(rx.indexIn(QString(line))!=-1)
{
_sizes.push_back(rx.cap(1).toInt());
name = rx.cap(3).trimmed();
_order.push_back(name);
_fileNames.push_back(name);
}
}
if(_sizes.size()==0)
{
QMessageBox::critical(NULL,tr("File error"),tr("File not found or not images in file"));
emit errorOpening();
return;
}
_pages.resize(_sizes.size());
_loadedPages = QVector<bool>(_sizes.size(),false);
emit pageChanged(0); // this indicates new comic, index=0
emit numPages(_pages.size());
_loaded = true;
_cfi=0;
qSort(_fileNames.begin(),_fileNames.end(), naturalSortLessThanCI);
int i=0;
foreach(name,_fileNames)
{
_newOrder.insert(name,i);
i++;
}
_7ze = new QProcess();
QStringList attributes;
attributes << "e" << "-ssc-" << "-so" << "-r" << _path EXTENSIONS;
connect(_7ze,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError)));
connect(_7ze,SIGNAL(readyReadStandardOutput()),this,SLOT(loadImages(void)));
connect(_7ze,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(loadFinished(void)));
_7ze->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes);
}
//-----------------------------------------------------------------------------
void FileComic::loadImages()
{
QByteArray ba = _7ze->readAllStandardOutput();
int s;
int rigthIndex;
while(ba.size()>0)
{
rigthIndex = _newOrder.value(_order[_cfi]);
s = _pages[rigthIndex].size();
_pages[rigthIndex].append(ba.left(_sizes[_cfi]-s));
ba.remove(0,_sizes[_cfi]-s);
if(_pages[rigthIndex].size()==static_cast<int>(_sizes[_cfi]))
{
emit imageLoaded(rigthIndex);
emit imageLoaded(rigthIndex,_pages[rigthIndex]);
_cfi++;
}
}
}
//-----------------------------------------------------------------------------
void FileComic::openingError(QProcess::ProcessError error)
{
switch(error)
{
case QProcess::FailedToStart:
QMessageBox::critical(NULL,tr("7z not found"),tr("7z wasn't found in your PATH."));
break;
case QProcess::Crashed:
QMessageBox::critical(NULL,tr("7z crashed"),tr("7z crashed."));
break;
case QProcess::ReadError:
QMessageBox::critical(NULL,tr("7z reading"),tr("problem reading from 7z"));
break;
case QProcess::UnknownError:
QMessageBox::critical(NULL,tr("7z problem"),tr("Unknown error 7z"));
break;
default:
//TODO
break;
}
_loaded = false;
emit errorOpening();
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
FolderComic::FolderComic()
:Comic()
{
}
FolderComic::FolderComic(const QString & path)
:Comic(path)
{
load(path);
}
FolderComic::~FolderComic()
{
}
bool FolderComic::load(const QString & path)
{
_path = path;
bm->newComic(_path);
emit bookmarksUpdated();
//emit bookmarksLoaded(*bm);
return true;
}
void FolderComic::process()
{
QDir d(_path);
QStringList l;
l EXTENSIONS;
d.setNameFilters(l);
d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
//d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
QFileInfoList list = d.entryInfoList();
qSort(list.begin(),list.end(),naturalSortLessThanCIFileInfo);
int nPages = list.size();
_pages.clear();
_pages.resize(nPages);
_loadedPages = QVector<bool>(nPages,false);
if(nPages==0)
{
//TODO emitir este mensaje en otro sitio
//QMessageBox::critical(NULL,QObject::tr("No images found"),QObject::tr("There are not images on the selected folder"));
emit errorOpening();
}
else
{
emit pageChanged(0); // this indicates new comic, index=0
emit numPages(_pages.size());
_loaded = true;
for(int i=0;i<nPages;i++)
{
QFile f(list.at(i).absoluteFilePath());
f.open(QIODevice::ReadOnly);
_pages[i]=f.readAll();
emit imageLoaded(i);
emit imageLoaded(i,_pages[i]);
}
}
emit imagesLoaded();
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
PDFComic::PDFComic()
:Comic()
{
}
PDFComic::PDFComic(const QString & path)
:Comic(path)
{
load(path);
}
PDFComic::~PDFComic()
{
}
bool PDFComic::load(const QString & path)
{
_path = path;
bm->newComic(_path);
emit bookmarksUpdated();
//emit bookmarksLoaded(*bm);
return true;
}
void PDFComic::process()
{
pdfComic = Poppler::Document::load(_path);
if (!pdfComic)
{
delete pdfComic;
pdfComic = 0;
//TODO emitir este mensaje en otro sitio
//QMessageBox::critical(NULL,QObject::tr("Bad PDF File"),QObject::tr("Invalid PDF file"));
emit errorOpening();
return;
}
//pdfComic->setRenderHint(Poppler::Document::Antialiasing, true);
pdfComic->setRenderHint(Poppler::Document::TextAntialiasing, true);
int nPages = pdfComic->numPages();
emit pageChanged(0); // this indicates new comic, index=0
emit numPages(nPages);
_loaded = true;
//QMessageBox::critical(NULL,QString("%1").arg(nPages),tr("Invalid PDF file"));
_pages.clear();
_pages.resize(nPages);
_loadedPages = QVector<bool>(nPages,false);
for(int i=0;i<nPages;i++)
{
Poppler::Page* pdfpage = pdfComic->page(i);
if (pdfpage)
{
QImage img = pdfpage->renderToImage(150,150);
delete pdfpage;
QByteArray ba;
QBuffer buf(&ba);
img.save(&buf, "jpg");
_pages[i] = ba;
emit imageLoaded(i);
emit imageLoaded(i,_pages[i]);
}
}
delete pdfComic;
emit imagesLoaded();
}
Comic * FactoryComic::newComic(const QString & path)
{
QFileInfo fi(path);
if(fi.exists())
{
if(fi.isFile())
{
if(fi.suffix().compare("pdf",Qt::CaseInsensitive) == 0)
return new PDFComic();
else
return new FileComic();
}
else
{
if(fi.isDir())
return new FolderComic();
else
return NULL;
}
}
else
return NULL;
}

142
YACReader/comic.h Normal file
View File

@ -0,0 +1,142 @@
#ifndef __COMIC_H
#define __COMIC_H
#include <QtCore>
#include <QImage>
#include <QtGui>
#include <QByteArray>
#include <QMap>
#include "bookmarks.h"
#include "poppler-qt4.h"
class Comic : public QObject
{
Q_OBJECT
protected:
//Comic pages, one QPixmap for each file.
QVector<QByteArray> _pages;
QVector<bool> _loadedPages;
QVector<uint> _sizes;
QStringList _fileNames;
QMap<QString,int> _newOrder;
QVector<QString> _order;
int _index;
QString _path;
bool _loaded;
int _cfi;
bool _isPDF;
public:
Bookmarks * bm;
//Constructors
Comic();
Comic(const QString & pathFile);
~Comic();
void setup();
//Load pages from file
virtual bool load(const QString & path) = 0;
/*void loadFromFile(const QString & pathFile);
void loadFromDir(const QString & pathDir);
void loadFromPDF(const QString & pathPDF);*/
int nextPage();
int previousPage();
void setIndex(unsigned int index);
unsigned int getIndex(){return _index;};
unsigned int numPages(){return _pages.size();}
//QPixmap * currentPage();
bool loaded();
//QPixmap * operator[](unsigned int index);
QVector<QByteArray> * getRawData(){return &_pages;};
QByteArray getRawPage(int page);
bool pageIsLoaded(int page);
public slots:
void loadFinished();
void setBookmark();
void removeBookmark();
void saveBookmarks();
void checkIsBookmark(int index);
void updateBookmarkImage(int);
void setPageLoaded(int page);
signals:
void imagesLoaded();
void imageLoaded(int index);
void imageLoaded(int index,const QByteArray & image);
void pageChanged(int index);
void numPages(unsigned int numPages);
void errorOpening();
void isBookmark(bool);
void bookmarksUpdated();
void isCover();
void isLast();
};
class FileComic : public Comic
{
Q_OBJECT
private:
QProcess * _7z;
QProcess * _7ze;
public:
FileComic();
FileComic(const QString & path);
~FileComic();
virtual bool load(const QString & path);
public slots:
void loadImages();
void loadSizes();
void openingError(QProcess::ProcessError error);
};
class FolderComic : public Comic
{
Q_OBJECT
private:
//void run();
public:
FolderComic();
FolderComic(const QString & path);
~FolderComic();
virtual bool load(const QString & path);
public slots:
void process();
};
class PDFComic : public Comic
{
Q_OBJECT
private:
//pdf
Poppler::Document * pdfComic;
//void run();
public:
PDFComic();
PDFComic(const QString & path);
~PDFComic();
virtual bool load(const QString & path);
public slots:
void process();
};
class FactoryComic
{
public:
static Comic * newComic(const QString & path);
};
#endif

218
YACReader/configuration.cpp Normal file
View File

@ -0,0 +1,218 @@
#include "configuration.h"
#include <QFile>
#include <QFile>
#include <QTextStream>
#include <QCoreApplication>
#include <QStringList>
#include <QMessageBox>
Configuration::Configuration()
{
//read configuration
//load("/YACReader.conf");
}
Configuration::Configuration(const Configuration & conf)
{
//nothing
}
void Configuration::load(QSettings * settings)
{
this->settings = settings;
//TODO set defaults
if(!settings->contains(PATH))
settings->setValue(PATH,".");
if(!settings->contains(GO_TO_FLOW_SIZE))
settings->setValue(GO_TO_FLOW_SIZE,QSize(126,200));
if(!settings->contains(MAG_GLASS_SIZE))
settings->setValue(MAG_GLASS_SIZE,QSize(350,175));
if(!settings->contains(ZOOM_LEVEL))
settings->setValue(MAG_GLASS_SIZE,QSize(350,175));
if(!settings->contains(FIT))
settings->setValue(FIT,true);
if(!settings->contains(FLOW_TYPE))
settings->setValue(FLOW_TYPE,0);
if(!settings->contains(FULLSCREEN))
settings->setValue(FULLSCREEN,false);
if(!settings->contains(FIT_TO_WIDTH_RATIO))
settings->setValue(FIT_TO_WIDTH_RATIO,1);
if(!settings->contains(Y_WINDOW_SIZE))
settings->setValue(Y_WINDOW_SIZE,QSize(0,0));
if(!settings->contains(MAXIMIZED))
settings->setValue(MAXIMIZED,false);
if(!settings->contains(DOUBLE_PAGE))
settings->setValue(DOUBLE_PAGE,false);
if(!settings->contains(ADJUST_TO_FULL_SIZE))
settings->setValue(ADJUST_TO_FULL_SIZE,false);
if(!settings->contains(BACKGROUND_COLOR))
settings->setValue(BACKGROUND_COLOR,QColor(0,0,0));
if(!settings->contains(ALWAYS_ON_TOP))
settings->setValue(ALWAYS_ON_TOP,false);
if(!settings->contains(SHOW_TOOLBARS))
settings->setValue(SHOW_TOOLBARS, true);
}
void Configuration::load(const QString & path)
{
//load default configuration
defaultPath = ".";
magnifyingGlassSize = QSize(350,175);
gotoSlideSize = QSize(126,200); //normal
//gotoSlideSize = QSize(79,125); //small
//gotoSlideSize = QSize(173,275); //big
//gotoSlideSize = QSize(220,350); //huge
zoomLevel = 0.5;
adjustToWidth = true;
flowType = Strip;
fullScreen = false;
fitToWidthRatio = 1;
windowSize = QSize(0,0);
maximized = false;
doublePage = false;
adjustToFullSize = false;
backgroundColor = QColor(0,0,0);
alwaysOnTop = false;
//load from file
QFile f(QCoreApplication::applicationDirPath()+path);
f.open(QIODevice::ReadOnly);
QTextStream txtS(&f);
QString content = txtS.readAll();
QStringList lines = content.split('\n');
QString line,name;
int i=0;
foreach(line,lines)
{
if((i%2)==0)
{
name = line.trimmed();
}
else
{
if(name==PATH)
defaultPath = line.trimmed();
else
if(name==MAG_GLASS_SIZE)
{
QStringList values = line.split(',');
magnifyingGlassSize = QSize(values[0].toInt(),values[1].toInt());
}
else
if(name==ZOOM_LEVEL)
zoomLevel = line.toFloat();
else
if(name==SLIDE_SIZE)
{
int height = line.toInt();
gotoSlideSize = QSize(static_cast<int>(height/SLIDE_ASPECT_RATIO),height);
}
else
if(name==FIT)
adjustToWidth = line.toInt();
else
if(name==FLOW_TYPE)
flowType = (FlowType)line.toInt();
else
if(name==FULLSCREEN)
fullScreen = line.toInt();
else
if(name==FIT_TO_WIDTH_RATIO)
fitToWidthRatio = line.toFloat();
else
if(name==Y_WINDOW_POS)
{
QStringList l = line.split(',');
windowPos = QPoint(l[0].toInt(),l[1].toInt());
}
else
if(name==Y_WINDOW_SIZE)
{
QStringList l = line.split(',');
windowSize = QSize(l[0].toInt(),l[1].toInt());
}
else
if(name==MAXIMIZED)
maximized = line.toInt();
else
if(name==DOUBLE_PAGE)
doublePage = line.toInt();
else
if(name==ADJUST_TO_FULL_SIZE)
adjustToFullSize = line.toInt();
else
if(name==BACKGROUND_COLOR)
{
QStringList l = line.split(',');
backgroundColor = QColor(l[0].toInt(),l[1].toInt(),l[2].toInt());
}
else
if(name==ALWAYS_ON_TOP)
alwaysOnTop = line.toInt();
}
i++;
}
}
void Configuration::save()
{
QFile f(QCoreApplication::applicationDirPath()+"/YACReader.conf");
if(!f.open(QIODevice::WriteOnly))
{
QMessageBox::critical(NULL,tr("Saving config file...."),tr("There was a problem saving YACReader configuration. Please, check if you have enough permissions in the YACReader root folder."));
}
else
{
QTextStream txtS(&f);
txtS << PATH << "\n";
txtS << defaultPath << "\n";
txtS << MAG_GLASS_SIZE << "\n";
txtS << magnifyingGlassSize.width() <<","<< magnifyingGlassSize.height() << "\n";
txtS << ZOOM_LEVEL << "\n";
txtS << zoomLevel << "\n";
txtS << SLIDE_SIZE << "\n";
txtS << gotoSlideSize.height() << "\n";
txtS << FIT << "\n";
txtS << (int)adjustToWidth << "\n";
txtS << FLOW_TYPE << "\n";
txtS << (int)flowType << "\n";
txtS << FULLSCREEN << "\n";
txtS << (int)fullScreen << "\n";
txtS << FIT_TO_WIDTH_RATIO << "\n";
txtS << fitToWidthRatio << "\n";
txtS << Y_WINDOW_POS << "\n";
txtS << windowPos.x() << "," << windowPos.y() << "\n";
txtS << Y_WINDOW_SIZE << "\n";
txtS << windowSize.width() << "," << windowSize.height() << "\n";
txtS << MAXIMIZED << "\n";
txtS << (int)maximized << "\n";
txtS << DOUBLE_PAGE << "\n";
txtS << (int)doublePage << "\n";
txtS << ADJUST_TO_FULL_SIZE << "\n";
txtS << (int) adjustToFullSize << "\n";
txtS << BACKGROUND_COLOR << "\n";
txtS << backgroundColor.red() << "," << backgroundColor.green() << "," << backgroundColor.blue() << "\n";
txtS << ALWAYS_ON_TOP << "\n";
txtS << (int)alwaysOnTop << "\n";
}
}

90
YACReader/configuration.h Normal file
View File

@ -0,0 +1,90 @@
#ifndef __CONFIGURATION_H
#define __CONFIGURATION_H
#include <QString>
#include <QSize>
#include <QObject>
#include <QPoint>
#include <QColor>
#include <QSettings>
#include "yacreader_global.h"
#define CONF_FILE_PATH "."
#define SLIDE_ASPECT_RATIO 1.585
class Configuration : public QObject
{
Q_OBJECT
private:
QSettings * settings;
QString defaultPath;
//configuration properties
QSize magnifyingGlassSize;
QSize gotoSlideSize;
float zoomLevel;
bool adjustToWidth;
bool fullScreen;
FlowType flowType;
float fitToWidthRatio;
QPoint windowPos;
QSize windowSize;
bool maximized;
bool doublePage;
bool alwaysOnTop;
bool adjustToFullSize;
QColor backgroundColor;
Configuration();
Configuration(const Configuration & conf);
void load(const QString & path = CONF_FILE_PATH);
public:
static Configuration & getConfiguration()
{
static Configuration configuration;
return configuration;
};
void load(QSettings * settings);
QString getDefaultPath() { return settings->value(PATH).toString(); };
void setDefaultPath(QString defaultPath){settings->setValue(PATH,defaultPath);};
QSize getMagnifyingGlassSize() { return settings->value(MAG_GLASS_SIZE).toSize();};
void setMagnifyingGlassSize(const QSize & mgs) { settings->setValue(MAG_GLASS_SIZE,mgs);};
QSize getGotoSlideSize() { return settings->value(GO_TO_FLOW_SIZE).toSize();};
void setGotoSlideSize(const QSize & gss) { settings->setValue(GO_TO_FLOW_SIZE,gss);};
float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat();};
void setZoomLevel(float zl) { settings->setValue(ZOOM_LEVEL,zl);};
bool getAdjustToWidth() {return settings->value(FIT).toBool();};
void setAdjustToWidth(bool atw=true) {settings->setValue(FIT,atw);};
FlowType getFlowType(){return (FlowType)settings->value(FLOW_TYPE_SW).toInt();};
void setFlowType(FlowType type){settings->setValue(FLOW_TYPE_SW,type);};
bool getFullScreen(){return settings->value(FULLSCREEN).toBool();};
void setFullScreen(bool f){settings->setValue(FULLSCREEN,f);};
float getFitToWidthRatio(){return settings->value(FIT_TO_WIDTH_RATIO).toFloat();};
void setFitToWidthRatio(float r){settings->setValue(FIT_TO_WIDTH_RATIO,r);};
QPoint getPos(){return settings->value(Y_WINDOW_POS).toPoint();};
void setPos(QPoint p){settings->setValue(Y_WINDOW_POS,p);};
QSize getSize(){return settings->value(Y_WINDOW_SIZE).toSize();};
void setSize(QSize s){settings->setValue(Y_WINDOW_SIZE,s);};
bool getMaximized(){return settings->value(MAXIMIZED).toBool();};
void setMaximized(bool b){settings->setValue(MAXIMIZED,b);};
bool getDoublePage(){return settings->value(DOUBLE_PAGE).toBool();};
void setDoublePage(bool b){settings->setValue(DOUBLE_PAGE,b);};
bool getAdjustToFullSize(){return settings->value(ADJUST_TO_FULL_SIZE).toBool();};
void setAdjustToFullSize(bool b){settings->setValue(ADJUST_TO_FULL_SIZE,b);};
QColor getBackgroundColor(){return settings->value(BACKGROUND_COLOR).value<QColor>();};
void setBackgroundColor(const QColor& color){settings->value(BACKGROUND_COLOR,color);};
bool getAlwaysOnTop(){return settings->value(ALWAYS_ON_TOP).toBool();};
void setAlwaysOnTop(bool b){ settings->setValue(ALWAYS_ON_TOP,b);};
bool getShowToolbars(){return settings->value(SHOW_TOOLBARS).toBool();};
void setShowToolbars(bool b){settings->setValue(SHOW_TOOLBARS,b);};
bool getShowInformation(){return settings->value(SHOW_INFO,false).toBool();};
void setShowInformation(bool b){settings->setValue(SHOW_INFO,b);};
void save();
};
#endif

14
YACReader/files.qrc Normal file
View File

@ -0,0 +1,14 @@
<RCC>
<qresource>
<file>../files/about.html</file>
<file>../files/helpYACReader.html</file>
<file>../files/shortcuts.html</file>
<file>../files/shortcuts2.html</file>
<file>../files/translator.html</file>
</qresource>
<qresource lang="es_ES">
<file alias="/files/about.html">../files/about_es_ES.html</file>
<file alias="/files/helpYACReader.html">../files/helpYACReader_es_ES.html</file>
</qresource>
</RCC>

75
YACReader/goto_dialog.cpp Normal file
View File

@ -0,0 +1,75 @@
#include "goto_dialog.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QIntValidator>
GoToDialog::GoToDialog(QWidget * parent)
:QDialog(parent)
{
setupUI();
}
void GoToDialog::setupUI()
{
textLabel = new QLabel(tr("Page : "));
pageNumber = new QLineEdit;
v = new QIntValidator(this);
v->setBottom(1);
pageNumber->setValidator(v);
textLabel->setBuddy(pageNumber);
textLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
accept = new QPushButton(tr("Go To"));
connect(accept,SIGNAL(clicked()),this,SLOT(goTo()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
QHBoxLayout *topLayout = new QHBoxLayout;
topLayout->addWidget(textLabel);
topLayout->addWidget(pageNumber);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(numPagesLabel = new QLabel(tr("Total pages : ")));
mainLayout->addLayout(topLayout);
mainLayout->addStretch();
mainLayout->addLayout(bottomLayout);
QHBoxLayout *imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel();
QPixmap p(":/images/goto.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setWindowTitle(tr("Go to..."));
setModal (true);
}
void GoToDialog::goTo()
{
unsigned int page = pageNumber->text().toInt();
pageNumber->clear();
if(page >= 1)
emit(goToPage(page-1));
close();
}
void GoToDialog::setNumPages(unsigned int numPages)
{
numPagesLabel->setText(tr("Total pages : ")+QString::number(numPages));
v->setTop(numPages);
}

31
YACReader/goto_dialog.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef __GOTODIALOG_H
#define __GOTODIALOG_H
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QIntValidator>
class GoToDialog : public QDialog
{
Q_OBJECT
public:
GoToDialog(QWidget * parent = 0);
private:
QLabel * numPagesLabel;
QLabel * textLabel;
QLineEdit * pageNumber;
QIntValidator * v;
QPushButton * accept;
QPushButton * cancel;
void setupUI();
public slots:
void goTo();
void setNumPages(unsigned int numPages);
signals:
void goToPage(unsigned int page);
};
#endif

324
YACReader/goto_flow.cpp Normal file
View File

@ -0,0 +1,324 @@
#include "goto_flow.h"
#include "configuration.h"
#include "comic.h"
#include <QVBoxLayout>
#include <QSize>
#include <QImage>
#include <QLabel>
#include <QPushButton>
#include <QMutex>
#include <QCoreApplication>
#include <QLineEdit>
#include <QPushButton>
#include <QPixmap>
#include <QThread>
#include <QSize>
#include <QIntValidator>
#include <QWaitCondition>
#include <QObject>
#include <QEvent>
#include <QLabel>
#include "yacreader_flow.h"
#include "goto_flow_toolbar.h"
#include "goto_flow_decorationbar.h"
/*#define WIDTH 126
#define HEIGHT 200*/
QMutex mutexGoToFlow;
GoToFlow::GoToFlow(QWidget *parent,FlowType flowType)
:GoToFlowWidget(parent),ready(false)
{
updateTimer = new QTimer;
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData()));
worker = new PageLoader;
flow = new YACReaderFlow(this,flowType);
flow->setReflectionEffect(PictureFlow::PlainReflection);
imageSize = Configuration::getConfiguration().getGotoSlideSize();
flow->setSlideSize(imageSize);
connect(flow,SIGNAL(centerIndexChanged(int)),this,SLOT(setPageNumber(int)));
connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
connect(toolBar,SIGNAL(goTo(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
connect(toolBar,SIGNAL(setCenter(unsigned int)),flow,SLOT(showSlide(unsigned int)));
mainLayout->insertWidget(1,flow);
mainLayout->setStretchFactor(flow,1);
resize(static_cast<int>(5*imageSize.width()),static_cast<int>(imageSize.height()*1.7));
//install eventFilter
//flow->installEventFilter(this);
/*edit->installEventFilter(this);
centerButton->installEventFilter(this);
goToButton->installEventFilter(this);
connect(edit,SIGNAL(returnPressed()),goToButton,SIGNAL(clicked()));*/
this->setCursor(QCursor(Qt::ArrowCursor));
}
void GoToFlow::centerSlide(int slide)
{
if(flow->centerIndex()!=slide)
{
flow->setCenterIndex(slide);
if(ready)// load images if pages are loaded.
{
//worker->reset(); //BUG FIXED : image didn't load if worker was working
preload();
}
}
}
void GoToFlow::setNumSlides(unsigned int slides)
{
// numPagesLabel->setText(tr("Total pages : ")+QString::number(slides));
// numPagesLabel->adjustSize();
imagesReady.clear();
imagesReady.fill(false,slides);
rawImages.clear();
rawImages.resize(slides);
toolBar->setTop(slides);
SlideInitializer * si = new SlideInitializer(flow,slides);
imagesLoaded.clear();
imagesLoaded.fill(false,slides);
imagesSetted.clear();
imagesSetted.fill(false,slides);
numImagesLoaded = 0;
connect(flow, SIGNAL(centerIndexChanged(int)), this, SLOT(preload()));
ready = true;
worker->reset();
si->start();
}
void GoToFlow::reset()
{
updateTimer->stop();
/*imagesLoaded.clear();
numImagesLoaded = 0;
imagesReady.clear();
rawImages.clear();*/
ready = false;
}
void GoToFlow::setImageReady(int index,const QByteArray & image)
{
rawImages[index]=image;
imagesReady[index]=true;
preload();
}
void GoToFlow::preload()
{
if(numImagesLoaded < imagesLoaded.size())
updateTimer->start(30); //TODO comprobar rendimiento, antes era 70
}
void GoToFlow::updateImageData()
{
// can't do anything, wait for the next possibility
if(worker->busy())
return;
// set image of last one
int idx = worker->index();
if( idx >= 0 && !worker->result().isNull())
{
if(!imagesSetted[idx])
{
flow->setSlide(idx, worker->result());
imagesSetted[idx] = true;
numImagesLoaded++;
rawImages[idx].clear();; //release memory
imagesLoaded[idx]=true;
}
}
// try to load only few images on the left and right side
// i.e. all visible ones plus some extra
#define COUNT 8
int indexes[2*COUNT+1];
int center = flow->centerIndex();
indexes[0] = center;
for(int j = 0; j < COUNT; j++)
{
indexes[j*2+1] = center+j+1;
indexes[j*2+2] = center-j-1;
}
for(int c = 0; c < 2*COUNT+1; c++)
{
int i = indexes[c];
if((i >= 0) && (i < flow->slideCount()))
if(!imagesLoaded[i]&&imagesReady[i])//slide(i).isNull())
{
// schedule thumbnail generation
worker->generate(i, flow->slideSize(),rawImages[i]);
return;
}
}
// no need to generate anything? stop polling...
updateTimer->stop();
}
bool GoToFlow::eventFilter(QObject *target, QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
int key = keyEvent->key();
if((key==Qt::Key_Return)||
(key==Qt::Key_Enter)||
(key==Qt::Key_Space)||
(key==Qt::Key_Left)||
(key==Qt::Key_Right)||
(key==Qt::Key_S))
this->keyPressEvent(keyEvent);
}
return QWidget::eventFilter(target, event);
}
void GoToFlow::wheelEvent(QWheelEvent * event)
{
if(event->delta()<0)
flow->showNext();
else
flow->showPrevious();
event->accept();
}
void GoToFlow::setFlowType(FlowType flowType)
{
flow->setFlowType(flowType);
}
void GoToFlow::updateSize() //TODO : fix. it doesn't work.
{
imageSize = Configuration::getConfiguration().getGotoSlideSize();
flow->setSlideSize(imageSize);
resize(static_cast<int>(5*imageSize.width()),static_cast<int>(imageSize.height()*1.7));
}
void GoToFlow::updateConfig(QSettings * settings)
{
}
//-----------------------------------------------------------------------------
//SlideInitializer
//-----------------------------------------------------------------------------
SlideInitializer::SlideInitializer(PictureFlow * flow,int slides)
:QThread(),_flow(flow),_slides(slides)
{
}
void SlideInitializer::run()
{
mutexGoToFlow.lock();
_flow->clear();
for(int i=0;i<_slides;i++)
_flow->addSlide(QImage());
_flow->setCenterIndex(0);
mutexGoToFlow.unlock();
}
//-----------------------------------------------------------------------------
//PageLoader
//-----------------------------------------------------------------------------
PageLoader::PageLoader():
QThread(), restart(false), working(false), idx(-1)
{
}
PageLoader::~PageLoader()
{
mutexGoToFlow.lock();
condition.wakeOne();
mutexGoToFlow.unlock();
wait();
}
bool PageLoader::busy() const
{
return isRunning() ? working : false;
}
void PageLoader::generate(int index, QSize size,const QByteArray & rImage)
{
mutexGoToFlow.lock();
this->idx = index;
//this->img = QImage();
this->size = size;
this->rawImage = rImage;
mutexGoToFlow.unlock();
if (!isRunning())
start();
else
{
// already running, wake up whenever ready
restart = true;
condition.wakeOne();
}
}
void PageLoader::run()
{
for(;;)
{
// copy necessary data
mutexGoToFlow.lock();
this->working = true;
//int idx = this->idx;
QImage image;
image.loadFromData(this->rawImage);
// let everyone knows it is ready
image = image.scaled(this->size,Qt::KeepAspectRatio,Qt::SmoothTransformation);
mutexGoToFlow.unlock();
mutexGoToFlow.lock();
this->working = false;
this->img = image;
mutexGoToFlow.unlock();
// put to sleep
mutexGoToFlow.lock();
if (!this->restart)
condition.wait(&mutexGoToFlow);
restart = false;
mutexGoToFlow.unlock();
}
}

105
YACReader/goto_flow.h Normal file
View File

@ -0,0 +1,105 @@
#ifndef __GOTO_FLOW_H
#define __GOTO_FLOW_H
#include "goto_flow_widget.h"
#include <QThread>
#include <QWaitCondition>
class QLineEdit;
class QPushButton;
class QPixmap;
class QThread;
class QSize;
class QIntValidator;
class QWaitCondition;
class QEvent;
class QLabel;
class Comic;
class SlideInitializer;
class PageLoader;
class YACReaderFlow;
class PictureFlow;
class GoToFlow : public GoToFlowWidget
{
Q_OBJECT
public:
GoToFlow(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
bool ready; //comic is ready for read.
bool eventFilter(QObject *target, QEvent *event);
private:
YACReaderFlow * flow;
//Comic * comic;
QSize imageSize;
QVector<bool> imagesLoaded;
QVector<bool> imagesSetted;
uint numImagesLoaded;
QVector<bool> imagesReady;
QVector<QByteArray> rawImages;
QTimer* updateTimer;
PageLoader* worker;
virtual void wheelEvent(QWheelEvent * event);
private slots:
void preload();
void updateImageData();
public slots:
void centerSlide(int slide);
void reset();
void setNumSlides(unsigned int slides);
void setImageReady(int index,const QByteArray & image);
void setFlowType(FlowType flowType);
void updateSize();
void updateConfig(QSettings * settings);
signals:
void goToPage(unsigned int page);
};
//-----------------------------------------------------------------------------
//SlideInitializer
//-----------------------------------------------------------------------------
class SlideInitializer : public QThread
{
public:
SlideInitializer(PictureFlow * flow,int slides);
private:
PictureFlow * _flow;
int _slides;
void run();
};
//-----------------------------------------------------------------------------
//PageLoader
//-----------------------------------------------------------------------------
class PageLoader : public QThread
{
public:
PageLoader();
~PageLoader();
// returns FALSE if worker is still busy and can't take the task
bool busy() const;
void generate(int index, QSize size,const QByteArray & rImage);
void reset(){idx = -1;};
int index() const { return idx; }
QImage result() const { return img; }
protected:
void run();
private:
QWaitCondition condition;
bool restart;
bool working;
int idx;
QSize size;
QImage img;
QByteArray rawImage;
};
#endif

View File

@ -0,0 +1,33 @@
#include "goto_flow_decorationbar.h"
#include <QHBoxLayout>
#include <qlabel.h>
GoToFlowDecorationBar::GoToFlowDecorationBar(QWidget * parent)
:QWidget(parent)
{
QHBoxLayout * topBar = new QHBoxLayout();
QLabel * imgTopLeft = new QLabel();
QLabel * imgTopRight = new QLabel();
QLabel * imgTopMiddle = new QLabel();
QPixmap pL(":/images/imgTopLeft.png");
QPixmap pM(":/images/imgTopMiddle.png");
QPixmap pR(":/images/imgTopRight.png");
imgTopLeft->setPixmap(pL);
imgTopRight->setPixmap(pR);
imgTopMiddle->setPixmap(pM);
imgTopMiddle->setScaledContents(true);
topBar->addWidget(imgTopLeft);
topBar->addWidget(imgTopMiddle);
topBar->addWidget(imgTopRight);
topBar->setStretchFactor(imgTopLeft,0);
topBar->setStretchFactor(imgTopMiddle,1);
topBar->setStretchFactor(imgTopRight,0);
topBar->setMargin(0);
topBar->setSpacing(0);
setLayout(topBar);
}

View File

@ -0,0 +1,13 @@
#ifndef GOTO_FLOW_DECORATIONBAR_H
#define GOTO_FLOW_DECORATIONBAR_H
#include <QWidget>
class GoToFlowDecorationBar : public QWidget
{
Q_OBJECT
public:
GoToFlowDecorationBar(QWidget * parent = 0);
};
#endif

164
YACReader/goto_flow_gl.cpp Normal file
View File

@ -0,0 +1,164 @@
#include "goto_flow_gl.h"
#include <QLineEdit>
#include <QIntValidator>
#include <QPushButton>
#include <QPushButton>
#include <QSize>
#include "configuration.h"
#include "goto_flow_toolbar.h"
#include "goto_flow_decorationbar.h"
GoToFlowGL::GoToFlowGL(QWidget* parent, FlowType flowType)
:GoToFlowWidget(parent)
{
flow = new YACReaderPageFlowGL(this);
flow->setShowMarks(false);
imageSize = Configuration::getConfiguration().getGotoSlideSize();
flow->setSlideSize(imageSize);
connect(flow,SIGNAL(centerIndexChanged(int)),this,SLOT(setPageNumber(int)));
connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
connect(toolBar,SIGNAL(goTo(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
connect(toolBar,SIGNAL(setCenter(unsigned int)),flow,SLOT(setCenterIndex(unsigned int)));
mainLayout->insertWidget(1,flow);
mainLayout->setStretchFactor(flow,1);
resize(static_cast<int>(5*imageSize.width()),static_cast<int>(imageSize.height()*1.7));
//install eventFilter
//flow->installEventFilter(this);
//edit->installEventFilter(this);
//centerButton->installEventFilter(this);
//goToButton->installEventFilter(this);
this->setCursor(QCursor(Qt::ArrowCursor));
}
bool GoToFlowGL::eventFilter(QObject *target, QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
int key = keyEvent->key();
if((key==Qt::Key_Return)||
(key==Qt::Key_Enter)||
(key==Qt::Key_Space)||
(key==Qt::Key_Left)||
(key==Qt::Key_Right)||
(key==Qt::Key_S))
this->keyPressEvent(keyEvent);
}
return QWidget::eventFilter(target, event);
}
void GoToFlowGL::reset()
{
flow->reset();
}
void GoToFlowGL::centerSlide(int slide)
{
if(flow->centerIndex()!=slide)
{
flow->setCenterIndex(slide);
}
}
void GoToFlowGL::setFlowType(FlowType flowType)
{
if(flowType == CoverFlowLike)
flow->setPreset(presetYACReaderFlowClassicConfig);
else if(flowType == Strip)
flow->setPreset(presetYACReaderFlowStripeConfig);
else if(flowType == StripOverlapped)
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
else
flow->setPreset(defaultYACReaderFlowConfig);
}
void GoToFlowGL::setNumSlides(unsigned int slides)
{
flow->populate(slides);
toolBar->setTop(slides);
}
void GoToFlowGL::setImageReady(int index,const QByteArray & imageData)
{
flow->rawImages[index] = imageData;
flow->imagesReady[index] = true;
}
void GoToFlowGL::updateSize()
{
}
void GoToFlowGL::updateConfig(QSettings * settings)
{
Performance performance = medium;
switch (settings->value(PERFORMANCE).toInt())
{
case 0:
performance = low;
break;
case 1:
performance = medium;
break;
case 2:
performance = high;
break;
case 3:
performance = ultraHigh;
break;
}
flow->setPerformance(performance);
switch (settings->value(FLOW_TYPE_GL).toInt())
{
case 0:
flow->setPreset(presetYACReaderFlowClassicConfig);
return;
case 1:
flow->setPreset(presetYACReaderFlowStripeConfig);
return;
case 2:
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
return;
case 3:
flow->setPreset(defaultYACReaderFlowConfig);
return;
case 4:
flow->setPreset(pressetYACReaderFlowDownConfig);
return;
}
//custom config
flow->setCF_RX(settings->value(X_ROTATION).toInt());
flow->setCF_Y(settings->value(Y_POSITION).toInt());
flow->setX_Distance(settings->value(COVER_DISTANCE).toInt());
flow->setCenter_Distance(settings->value(CENTRAL_DISTANCE).toInt());
flow->setCF_Z(settings->value(ZOOM_LEVEL).toInt());
flow->setY_Distance(settings->value(Y_COVER_OFFSET).toInt());
flow->setZ_Distance(settings->value(Z_COVER_OFFSET).toInt());
flow->setRotation(settings->value(COVER_ROTATION).toInt());
flow->setFadeOutDist(settings->value(FADE_OUT_DIST).toInt());
flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt());
flow->setMaxAngle(settings->value(MAX_ANGLE).toInt());
/* flow->setVisibility(settings->value("visibilityDistance").toInt());
flow->setLightStrenght(settings->value("lightStrength").toInt())*/;
}

39
YACReader/goto_flow_gl.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef __GOTO_FLOW_GL_H
#define __GOTO_FLOW_GL_H
#include "yacreader_global.h"
#include "goto_flow_widget.h"
#include "yacreader_flow_gl.h"
class QLineEdit;
class QIntValidator;
class QPushButton;
class QPushButton;
class QSize;
class GoToFlowGL : public GoToFlowWidget
{
Q_OBJECT
public:
GoToFlowGL(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
void reset();
void centerSlide(int slide);
void setFlowType(FlowType flowType);
void setNumSlides(unsigned int slides);
void setImageReady(int index,const QByteArray & image);
void updateSize();
bool eventFilter(QObject *target, QEvent *event);
void updateConfig(QSettings * settings);
signals:
void goToPage(unsigned int page);
private:
YACReaderPageFlowGL * flow;
//Comic * comic;
QSize imageSize;
};
#endif

View File

@ -0,0 +1,120 @@
#include "goto_flow_toolbar.h"
#include <QLineEdit>
#include <QIntValidator>
#include <QPushButton>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QResizeEvent>
GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
:QWidget(parent)
{
//fondo
QBoxLayout * background = new QHBoxLayout(this);
QLabel * imgBottomLeft = new QLabel(this);
QLabel * imgBottomRight = new QLabel(this);
QLabel * imgBottomMiddle = new QLabel(this);
QPixmap pBL(":/images/imgBottomLeft.png");
QPixmap pBM(":/images/imgBottomMiddle.png");
QPixmap pBR(":/images/imgBottomRight.png");
imgBottomLeft->setPixmap(pBL);
imgBottomRight->setPixmap(pBR);
imgBottomMiddle->setPixmap(pBM);
imgBottomMiddle->setScaledContents(true);
//imgTop->setStyleSheet("background-image: url(:/images/numPagesLabel.png); width: 100%; height:100%; background-repeat: none; border: none");
background->addWidget(imgBottomLeft);
background->addWidget(imgBottomMiddle);
background->addWidget(imgBottomRight);
background->setStretchFactor(imgBottomLeft,0);
background->setStretchFactor(imgBottomMiddle,1);
background->setStretchFactor(imgBottomRight,0);
background->setMargin(0);
background->setSpacing(0);
//elementos interactivos
//QVBoxLayout * mainLayout = new QVBoxLayout;
bar = new QWidget(this);
QHBoxLayout * bottom = new QHBoxLayout(bar);
bottom->addStretch();
bottom->addWidget(new QLabel(tr("Page : "),bar));
bottom->addWidget(edit = new QLineEdit(bar));
v = new QIntValidator(bar);
v->setBottom(1);
edit->setValidator(v);
edit->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
edit->setStyleSheet("background-image: url(:/images/imgEdit.png); width: 100%; height:100%; background-repeat: none; border: none; padding: 3px; color: white;");
QPixmap p(":/images/imgEdit.png");
edit->setFixedSize(54,50);
edit->setAttribute(Qt::WA_MacShowFocusRect,false);
edit->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
//edit->resize(QSize(54,50));
edit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
edit->setAutoFillBackground(false);
connect(edit,SIGNAL(returnPressed()),this,SLOT(goTo()));
QString centerButtonCSS = "QPushButton {background-image: url(:/images/imgCenterSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
"QPushButton:focus { border: none; outline: none;}"
"QPushButton:pressed {background-image: url(:/images/imgCenterSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} ";
centerButton = new QPushButton(bar);
//centerButton->setIcon(QIcon(":/images/center.png"));
centerButton->setStyleSheet(centerButtonCSS);
centerButton->setFixedSize(26,50);
centerButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
connect(centerButton,SIGNAL(clicked()),this,SLOT(centerSlide()));
bottom->addWidget(centerButton);
QString goToButtonCSS = "QPushButton {background-image: url(:/images/imgGoToSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
"QPushButton:focus { border: none; outline: none;}"
"QPushButton:pressed {background-image: url(:/images/imgGoToSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} ";
goToButton = new QPushButton(bar);
//goToButton->setIcon(QIcon(":/images/goto.png"));
goToButton->setStyleSheet(goToButtonCSS);
goToButton->setFixedSize(32,50);
goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
connect(goToButton,SIGNAL(clicked()),this,SLOT(goTo()));
bottom->addWidget(goToButton);
bottom->addStretch();
bottom->setMargin(0);
bottom->setSpacing(0);
bar->setLayout(bottom);
//mainLayout->addWidget(bar);
setLayout(background);
bar->setGeometry(QRect(0,0,400,50));
}
void GoToFlowToolBar::setPage(int pageNumber)
{
edit->setText(QString::number(pageNumber+1));
}
void GoToFlowToolBar::setTop(int numPages)
{
v->setTop(numPages);
}
void GoToFlowToolBar::resizeEvent(QResizeEvent * event)
{
bar->setGeometry(QRect(0,(event->size().height()-50)+((50-bar->height())/2),event->size().width(),50));
QWidget::resizeEvent(event);
}
void GoToFlowToolBar::goTo()
{
emit(goTo(edit->text().toInt()-1));
}
void GoToFlowToolBar::centerSlide()
{
emit(setCenter(edit->text().toInt()-1));
}

View File

@ -0,0 +1,33 @@
#ifndef GOTO_FLOW_TOOLBAR_H
#define GOTO_FLOW_TOOLBAR_H
#include <QWidget>
class QLineEdit;
class QIntValidator;
class QPushButton;
class GoToFlowToolBar : public QWidget
{
Q_OBJECT
private:
QLineEdit * edit;
QIntValidator * v;
QPushButton * centerButton;
QPushButton * goToButton;
QWidget * bar;
void resizeEvent(QResizeEvent * event);
public:
GoToFlowToolBar(QWidget * parent = 0);
public slots:
void setPage(int pageNumber);
void setTop(int numPages);
void goTo();
void centerSlide();
signals:
void setCenter(unsigned int);
void goTo(unsigned int);
};
#endif

View File

@ -0,0 +1,58 @@
#include "goto_flow_widget.h"
#include <QSettings>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QCoreApplication>
#include "goto_flow_toolbar.h"
#include "goto_flow_decorationbar.h"
GoToFlowWidget::GoToFlowWidget(QWidget * parent)
:QWidget(parent)
{
mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
topBar = new GoToFlowDecorationBar(this);
toolBar = new GoToFlowToolBar(this);
mainLayout->addWidget(topBar);
mainLayout->addWidget(toolBar);
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
setLayout(mainLayout);
}
void GoToFlowWidget::setPageNumber(int page)
{
toolBar->setPage(page);
}
void GoToFlowWidget::keyPressEvent(QKeyEvent* event)
{
switch (event->key())
{
case Qt::Key_Return: case Qt::Key_Enter:
toolBar->goTo();
toolBar->centerSlide();
break;
case Qt::Key_Space:
toolBar->centerSlide();
break;
case Qt::Key_S:
QCoreApplication::sendEvent(this->parent(),event);
break;
case Qt::Key_Left: case Qt::Key_Right:
//if(event->modifiers() == Qt::ControlModifier)
//flow->keyPressEvent(event);
//QCoreApplication::sendEvent(flow,event);
break;
}
event->accept();
}

View File

@ -0,0 +1,37 @@
#ifndef __GOTO_FLOW_WIDGET_H
#define __GOTO_FLOW_WIDGET_H
#include <QWidget>
#include <QSettings>
#include "yacreader_global.h"
class QSettings;
class GoToFlowDecorationBar;
class GoToFlowToolBar;
class QVBoxLayout;
class GoToFlowWidget : public QWidget
{
Q_OBJECT
protected:
QVBoxLayout * mainLayout;
GoToFlowDecorationBar * topBar;
GoToFlowToolBar * toolBar;
public:
GoToFlowWidget(QWidget * paret = 0);
public slots:
virtual void reset() = 0;
virtual void centerSlide(int slide) = 0;
virtual void setPageNumber(int page);
virtual void setFlowType(FlowType flowType) = 0;
virtual void setNumSlides(unsigned int slides) = 0;
virtual void setImageReady(int index,const QByteArray & image) = 0;
virtual void updateSize() = 0;
virtual void updateConfig(QSettings * settings) = 0;
protected:
void keyPressEvent(QKeyEvent* event);
};
#endif

BIN
YACReader/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

1
YACReader/icon.rc Normal file
View File

@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "icon.ico"

95
YACReader/images.qrc Normal file
View File

@ -0,0 +1,95 @@
<RCC>
<qresource>
<file>../images/open.png</file>
<file>../images/openFolder.png</file>
<file>../images/next.png</file>
<file>../images/prev.png</file>
<file>../images/icon.png</file>
<file>../images/zoom.png</file>
<file>../images/fit.png</file>
<file>../images/goto.png</file>
<file>../images/help.png</file>
<file>../images/center.png</file>
<file>../images/options.png</file>
<file>../images/comicFolder.png</file>
<file>../images/save.png</file>
<file>../images/rotateL.png</file>
<file>../images/rotateR.png</file>
<file>../images/flow1.png</file>
<file>../images/flow2.png</file>
<file>../images/flow3.png</file>
<file>../images/flow4.png</file>
<file>../images/flow5.png</file>
<file>../images/bookmark.png</file>
<file>../images/setBookmark.png</file>
<file>../images/notCover.png</file>
<file>../images/previousComic.png</file>
<file>../images/nextComic.png</file>
<file>../images/deleteLibrary.png</file>
<file>../images/properties.png</file>
<file>../images/doublePage.png</file>
<file>../images/shortcuts.png</file>
<file>../images/close.png</file>
<file>../images/up.png</file>
<file>../images/down.png</file>
<file>../images/dictionary.png</file>
<file>../images/alwaysOnTop.png</file>
<file>../images/adjustToFullSize.png</file>
<file>../images/numPagesLabel.png</file>
<file>../images/numPagesLabelMedium.png</file>
<file>../images/numPagesLabelBig.png</file>
<file>../images/imgTopLeft.png</file>
<file>../images/imgTopMiddle.png</file>
<file>../images/imgTopRight.png</file>
<file>../images/imgBottomLeft.png</file>
<file>../images/imgBottomMiddle.png</file>
<file>../images/imgBottomRight.png</file>
<file>../images/imgEdit.png</file>
<file>../images/imgCenterSlide.png</file>
<file>../images/imgGoToSlide.png</file>
<file>../images/imgCenterSlidePressed.png</file>
<file>../images/imgGoToSlidePressed.png</file>
<file>../images/sliderBackground.png</file>
<file>../images/sliderGround.png</file>
<file>../images/sliderSubPage.png</file>
<file>../images/sliderAddPage.png</file>
<file>../images/sliderHandle.png</file>
<file>../images/helpImages/open.png</file>
<file>../images/helpImages/openFolder.png</file>
<file>../images/helpImages/next.png</file>
<file>../images/helpImages/prev.png</file>
<file>../images/helpImages/icon.png</file>
<file>../images/helpImages/zoom.png</file>
<file>../images/helpImages/fit.png</file>
<file>../images/helpImages/goto.png</file>
<file>../images/helpImages/help.png</file>
<file>../images/helpImages/center.png</file>
<file>../images/helpImages/options.png</file>
<file>../images/helpImages/comicFolder.png</file>
<file>../images/helpImages/save.png</file>
<file>../images/helpImages/rotateL.png</file>
<file>../images/helpImages/rotateR.png</file>
<file>../images/helpImages/flow1.png</file>
<file>../images/helpImages/flow2.png</file>
<file>../images/helpImages/flow3.png</file>
<file>../images/helpImages/bookmark.png</file>
<file>../images/helpImages/setBookmark.png</file>
<file>../images/helpImages/notCover.png</file>
<file>../images/helpImages/previousComic.png</file>
<file>../images/helpImages/nextComic.png</file>
<file>../images/helpImages/deleteLibrary.png</file>
<file>../images/helpImages/properties.png</file>
<file>../images/helpImages/doublePage.png</file>
<file>../images/helpImages/shortcuts.png</file>
<file>../images/helpImages/keyboard.png</file>
<file>../images/helpImages/mouse.png</file>
<file>../images/helpImages/speaker.png</file>
<file>../images/defaultCover.png</file>
<file>../images/onStartFlowSelection.png</file>
<file>../images/onStartFlowSelection_es.png</file>
<file>../images/useNewFlowButton.png</file>
<file>../images/useOldFlowButton.png</file>
<file>../images/notificationsLabel.png</file>
</qresource>
</RCC>

View File

@ -0,0 +1,267 @@
#include "magnifying_glass.h"
#include "viewer.h"
MagnifyingGlass::MagnifyingGlass(int w, int h, QWidget * parent)
:QLabel(parent),zoomLevel(0.5)
{
setup(QSize(w,h));
}
MagnifyingGlass::MagnifyingGlass(const QSize & size, QWidget * parent)
:QLabel(parent),zoomLevel(0.5)
{
setup(size);
}
void MagnifyingGlass::setup(const QSize & size)
{
resize(size);
setScaledContents(true);
setMouseTracking(true);
setCursor(QCursor(QBitmap(1,1),QBitmap(1,1)));
}
void MagnifyingGlass::mouseMoveEvent(QMouseEvent * event)
{
updateImage();
}
void MagnifyingGlass::updateImage(int x, int y)
{
//image section augmented
int zoomWidth = static_cast<int>(width() * zoomLevel);
int zoomHeight = static_cast<int>(height() * zoomLevel);
Viewer * p = (Viewer *)parent();
int currentPos = p->verticalScrollBar()->sliderPosition();
const QPixmap * image = p->pixmap();
int iWidth = image->width();
int iHeight = image->height();
float wFactor = static_cast<float>(iWidth) / p->widget()->width();
float hFactor = static_cast<float>(iHeight) / p->widget()->height();
zoomWidth *= wFactor;
zoomHeight *= hFactor;
if(p->verticalScrollBar()->minimum()==p->verticalScrollBar()->maximum())
{
int xp = static_cast<int>(((x-p->widget()->pos().x())*wFactor)-zoomWidth/2);
int yp = static_cast<int>((y-p->widget()->pos().y()+currentPos)*hFactor-zoomHeight/2);
int xOffset=0;
int yOffset=0;
int zw=zoomWidth;
int zh=zoomHeight;
//int wOffset,hOffset=0;
bool outImage = false;
if(xp<0)
{
xOffset = -xp;
xp=0;
zw = zw - xOffset;
outImage = true;
}
if(yp<0)
{
yOffset = -yp;
yp=0;
zh = zh - yOffset;
outImage = true;
}
if(xp+zoomWidth >= image->width())
{
zw -= xp+zw - image->width();
outImage = true;
}
if(yp+zoomHeight >= image->height())
{
zh -= yp+zh - image->height();
outImage = true;
}
if(outImage)
{
QImage img(zoomWidth,zoomHeight,QImage::Format_RGB32);
img.fill(0);
if(zw>0&&zh>0)
{
QPainter painter(&img);
painter.drawPixmap(xOffset,yOffset,p->pixmap()->copy(xp,yp,zw,zh));
}
setPixmap(QPixmap().fromImage(img));
}
else
setPixmap(p->pixmap()->copy(xp,yp,zoomWidth,zoomHeight));
}
else
{
int xp = static_cast<int>(((x-p->widget()->pos().x())*wFactor)-zoomWidth/2);
int yp = static_cast<int>((y+currentPos)*hFactor-zoomHeight/2);
int xOffset=0;
int yOffset=0;
int zw=zoomWidth;
int zh=zoomHeight;
//int wOffset,hOffset=0;
bool outImage = false;
if(xp<0)
{
xOffset = -xp;
xp=0;
zw = zw - xOffset;
outImage = true;
}
if(yp<0)
{
yOffset = -yp;
yp=0;
zh = zh - yOffset;
outImage = true;
}
if(xp+zoomWidth >= image->width())
{
zw -= xp+zw - image->width();
outImage = true;
}
if(yp+zoomHeight >= image->height())
{
zh -= yp+zh - image->height();
outImage = true;
}
if(outImage)
{
QImage img(zoomWidth,zoomHeight,QImage::Format_RGB32);
img.fill(0);
if(zw>0&&zh>0)
{
QPainter painter(&img);
painter.drawPixmap(xOffset,yOffset,p->pixmap()->copy(xp,yp,zw,zh));
}
setPixmap(QPixmap().fromImage(img));
}
else
setPixmap(p->pixmap()->copy(xp,yp,zoomWidth,zoomHeight));
}
move(static_cast<int>(x-float(width())/2),static_cast<int>(y-float(height())/2));
}
void MagnifyingGlass::updateImage()
{
if(isVisible())
{
QPoint p = QPoint(cursor().pos().x(),cursor().pos().y());
p = this->parentWidget()->mapFromGlobal(p);
updateImage(p.x(),p.y());
}
}
void MagnifyingGlass::wheelEvent(QWheelEvent * event)
{
switch(event->modifiers())
{
//size
case Qt::NoModifier:
if(event->delta()<0)
sizeUp();
else
sizeDown();
break;
//size height
case Qt::ControlModifier:
if(event->delta()<0)
heightUp();
else
heightDown();
break;
//size width
case Qt::AltModifier:
if(event->delta()<0)
widthUp();
else
widthDown();
break;
//zoom level
case Qt::ShiftModifier:
if(event->delta()<0)
zoomIn();
else
zoomOut();
break;
}
updateImage();
event->setAccepted(true);
}
void MagnifyingGlass::zoomIn()
{
if(zoomLevel>0.2)
zoomLevel -= 0.025;
}
void MagnifyingGlass::zoomOut()
{
if(zoomLevel<0.9)
zoomLevel += 0.025;
}
void MagnifyingGlass::sizeUp()
{
Viewer * p = (Viewer *)parent();
if(width()<(p->width()*0.90))
resize(width()+30,height()+15);
}
void MagnifyingGlass::sizeDown()
{
if(width()>175)
resize(width()-30,height()-15);
}
void MagnifyingGlass::heightUp()
{
Viewer * p = (Viewer *)parent();
if(height()<(p->height()*0.90))
resize(width(),height()+15);
}
void MagnifyingGlass::heightDown()
{
if(height()>80)
resize(width(),height()-15);
}
void MagnifyingGlass::widthUp()
{
Viewer * p = (Viewer *)parent();
if(width()<(p->width()*0.90))
resize(width()+30,height());
}
void MagnifyingGlass::widthDown()
{
if(width()>175)
resize(width()-30,height());
}
void MagnifyingGlass::keyPressEvent(QKeyEvent *event)
{
bool validKey = false;
switch (event->key())
{
case Qt::Key_Plus:
sizeUp();
validKey = true;
break;
case Qt::Key_Minus:
sizeDown();
validKey = true;
break;
case Qt::Key_Underscore:
zoomOut();
validKey = true;
break;
case Qt::Key_Asterisk:
zoomIn();
validKey = true;
break;
}
updateImage();
if(validKey)
event->setAccepted(true);
}

View File

@ -0,0 +1,34 @@
#ifndef __MAGNIFYING_GLASS
#define __MAGNIFYING_GLASS
#include <QLabel>
#include <QtGui>
#include <QMouseEvent>
#include <QWidget>
class MagnifyingGlass : public QLabel
{
Q_OBJECT
private:
float zoomLevel;
void setup(const QSize & size);
void keyPressEvent(QKeyEvent * event);
public:
MagnifyingGlass(int width,int height,QWidget * parent);
MagnifyingGlass(const QSize & size, QWidget * parent);
void mouseMoveEvent(QMouseEvent * event);
public slots:
void updateImage(int x, int y);
void updateImage();
void wheelEvent(QWheelEvent * event);
void zoomIn();
void zoomOut();
void sizeUp();
void sizeDown();
void heightUp();
void heightDown();
void widthUp();
void widthDown();
};
#endif

47
YACReader/main.cpp Normal file
View File

@ -0,0 +1,47 @@
#include <QApplication>
#include <QPixmap>
#include <QLabel>
//#include <QMetaObject>
#include <QPushButton>
#include <QMainWindow>
#include <QtCore>
#include <QThread>
#include <QFile>
#include <QDataStream>
#include <QTranslator>
#include "main_window_viewer.h"
#include "configuration.h"
#if defined(WIN32) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
#define new DEBUG_NEW
#endif
int main(int argc, char * argv[])
{
#if defined(_MSC_VER) && defined(_DEBUG)
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
QApplication app(argc, argv);
QTranslator translator;
QString sufix = QLocale::system().name();
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix);
app.installTranslator(&translator);
app.setApplicationName("YACReader");
MainWindowViewer * mwv = new MainWindowViewer();
mwv->show();
int ret = app.exec();
Configuration::getConfiguration().save();
return ret;
}

View File

@ -0,0 +1,780 @@
#include "main_window_viewer.h"
#include "configuration.h"
#include "viewer.h"
#include "goto_dialog.h"
#include "custom_widgets.h"
#include "options_dialog.h"
#include "check_new_version.h"
#include "comic.h"
#include "bookmarks_dialog.h"
#include "shortcuts_dialog.h"
#include "width_slider.h"
#include "qnaturalsorting.h"
#include "help_about_dialog.h"
#include "yacreader_tool_bar_stretch.h"
#include <ctime>
#include <algorithm>
MainWindowViewer::MainWindowViewer()
:QMainWindow(),fullscreen(false),toolbars(true),alwaysOnTop(false),currentDirectory("."),currentDirectoryImgDest(".")
{
loadConfiguration();
setupUI();
}
void MainWindowViewer::loadConfiguration()
{
settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
Configuration & config = Configuration::getConfiguration();
config.load(settings);
currentDirectory = config.getDefaultPath();
fullscreen = config.getFullScreen();
}
void MainWindowViewer::setupUI()
{
setWindowIcon(QIcon(":/images/icon.png"));
setUnifiedTitleAndToolBarOnMac(true);
viewer = new Viewer(this);
connect(viewer,SIGNAL(reset()),this,SLOT(disableActions()));
setCentralWidget(viewer);
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
int height,width;
height = static_cast<int>(heightDesktopResolution*0.84);
width = static_cast<int>(height*0.70);
Configuration & conf = Configuration::getConfiguration();
QPoint p = conf.getPos();
QSize s = conf.getSize();
if(s.width()!=0)
{
move(p);
resize(s);
}
else
{
move(QPoint((widthDesktopResolution-width)/2,((heightDesktopResolution-height)-40)/2));
resize(QSize(width,height));
}
had = new HelpAboutDialog(this); //TODO load data
had->loadAboutInformation(":/files/about.html");
had->loadHelp(":/files/helpYACReader.html");
optionsDialog = new OptionsDialog(this);
connect(optionsDialog,SIGNAL(accepted()),viewer,SLOT(updateOptions()));
connect(optionsDialog,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
connect(optionsDialog, SIGNAL(optionsChanged()),this,SLOT(reloadOptions()));
connect(optionsDialog,SIGNAL(changedImageOptions()),viewer,SLOT(updateImageOptions()));
optionsDialog->restoreOptions(settings);
shortcutsDialog = new ShortcutsDialog(this);
createActions();
createToolBars();
setWindowTitle("YACReader");
if(QCoreApplication::argc()>1)
{
//TODO: new method open(QString)
QString pathFile = QCoreApplication::arguments().at(1);
currentDirectory = pathFile;
QFileInfo fi(pathFile);
getSiblingComics(fi.absolutePath(),fi.fileName());
setWindowTitle("YACReader - " + fi.fileName());
enableActions();
viewer->open(pathFile);
}
versionChecker = new HttpVersionChecker();
connect(versionChecker,SIGNAL(newVersionDetected()),
this,SLOT(newVersion()));
QTimer * tT = new QTimer;
tT->setSingleShot(true);
connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get()));
//versionChecker->get(); //TOD<4F>
tT->start(100);
viewer->setFocusPolicy(Qt::StrongFocus);
if(Configuration::getConfiguration().getAlwaysOnTop())
{
setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
}
if(fullscreen)
toFullScreen();
if(conf.getMaximized())
showMaximized();
setAcceptDrops(true);
if(Configuration::getConfiguration().getShowToolbars() && !Configuration::getConfiguration().getFullScreen())
showToolBars();
else
hideToolBars();
}
void MainWindowViewer::createActions()
{
openAction = new QAction(tr("&Open"),this);
openAction->setShortcut(tr("O"));
openAction->setIcon(QIcon(":/images/open.png"));
openAction->setToolTip(tr("Open a comic"));
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
openFolderAction = new QAction(tr("Open Folder"),this);
openFolderAction->setShortcut(tr("Ctrl+O"));
openFolderAction->setIcon(QIcon(":/images/openFolder.png"));
openFolderAction->setToolTip(tr("Open image folder"));
connect(openFolderAction, SIGNAL(triggered()), this, SLOT(openFolder()));
saveImageAction = new QAction(tr("Save"),this);
saveImageAction->setIcon(QIcon(":/images/save.png"));
saveImageAction->setToolTip(tr("Save current page"));
saveImageAction->setDisabled(true);
connect(saveImageAction,SIGNAL(triggered()),this,SLOT(saveImage()));
openPreviousComicAction = new QAction(tr("Previous Comic"),this);
openPreviousComicAction->setIcon(QIcon(":/images/previousComic.png"));
openPreviousComicAction->setShortcut(Qt::CTRL + Qt::Key_Left);
openPreviousComicAction->setToolTip(tr("Open previous comic"));
openPreviousComicAction->setDisabled(true);
connect(openPreviousComicAction,SIGNAL(triggered()),this,SLOT(openPreviousComic()));
openNextComicAction = new QAction(tr("Next Comic"),this);
openNextComicAction->setIcon(QIcon(":/images/nextComic.png"));
openNextComicAction->setShortcut(Qt::CTRL + Qt::Key_Right);
openNextComicAction->setToolTip(tr("Open next comic"));
openNextComicAction->setDisabled(true);
connect(openNextComicAction,SIGNAL(triggered()),this,SLOT(openNextComic()));
prevAction = new QAction(tr("&Previous"),this);
prevAction->setIcon(QIcon(":/images/prev.png"));
prevAction->setShortcut(Qt::Key_Left);
prevAction->setToolTip(tr("Go to previous page"));
prevAction->setDisabled(true);
connect(prevAction, SIGNAL(triggered()),viewer,SLOT(prev()));
nextAction = new QAction(tr("&Next"),this);
nextAction->setIcon(QIcon(":/images/next.png"));
nextAction->setShortcut(Qt::Key_Right);
nextAction->setToolTip(tr("Go to next page"));
nextAction->setDisabled(true);
connect(nextAction, SIGNAL(triggered()),viewer,SLOT(next()));
adjustWidth = new QAction(tr("Fit Width"),this);
adjustWidth->setShortcut(tr("A"));
adjustWidth->setIcon(QIcon(":/images/fit.png"));
adjustWidth->setCheckable(true);
adjustWidth->setDisabled(true);
adjustWidth->setChecked(Configuration::getConfiguration().getAdjustToWidth());
adjustWidth->setToolTip(tr("Fit image to ..."));
//adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
connect(adjustWidth, SIGNAL(triggered()),this,SLOT(changeFit()));
leftRotationAction = new QAction(tr("Rotate image to the left"),this);
leftRotationAction->setShortcut(tr("L"));
leftRotationAction->setIcon(QIcon(":/images/rotateL.png"));
leftRotationAction->setDisabled(true);
connect(leftRotationAction, SIGNAL(triggered()),viewer,SLOT(rotateLeft()));
rightRotationAction = new QAction(tr("Rotate image to the right"),this);
rightRotationAction->setShortcut(tr("R"));
rightRotationAction->setIcon(QIcon(":/images/rotateR.png"));
rightRotationAction->setDisabled(true);
connect(rightRotationAction, SIGNAL(triggered()),viewer,SLOT(rotateRight()));
doublePageAction = new QAction(tr("Double page mode"),this);
doublePageAction->setToolTip(tr("Switch to double page mode"));
doublePageAction->setShortcut(tr("D"));
doublePageAction->setIcon(QIcon(":/images/doublePage.png"));
doublePageAction->setDisabled(true);
doublePageAction->setCheckable(true);
doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage());
connect(doublePageAction, SIGNAL(triggered()),viewer,SLOT(doublePageSwitch()));
goToPage = new QAction(tr("Go To"),this);
goToPage->setShortcut(tr("G"));
goToPage->setIcon(QIcon(":/images/goto.png"));
goToPage->setDisabled(true);
goToPage->setToolTip(tr("Go to page ..."));
connect(goToPage, SIGNAL(triggered()),viewer,SLOT(showGoToDialog()));
optionsAction = new QAction(tr("Options"),this);
optionsAction->setShortcut(tr("C"));
optionsAction->setToolTip(tr("YACReader options"));
optionsAction->setIcon(QIcon(":/images/options.png"));
connect(optionsAction, SIGNAL(triggered()),optionsDialog,SLOT(show()));
helpAboutAction = new QAction(tr("Help"),this);
helpAboutAction->setToolTip(tr("Help, About YACReader"));
helpAboutAction->setShortcut(Qt::Key_F1);
helpAboutAction->setIcon(QIcon(":/images/help.png"));
connect(helpAboutAction, SIGNAL(triggered()),had,SLOT(show()));
showMagnifyingGlass = new QAction(tr("Magnifying glass"),this);
showMagnifyingGlass->setToolTip(tr("Switch Magnifying glass"));
showMagnifyingGlass->setShortcut(tr("Z"));
showMagnifyingGlass->setIcon(QIcon(":/images/zoom.png"));
showMagnifyingGlass->setDisabled(true);
showMagnifyingGlass->setCheckable(true);
connect(showMagnifyingGlass, SIGNAL(triggered()),viewer,SLOT(magnifyingGlassSwitch()));
setBookmark = new QAction(tr("Set bookmark"),this);
setBookmark->setToolTip(tr("Set a bookmark on the current page"));
setBookmark->setShortcut(Qt::CTRL+Qt::Key_M);
setBookmark->setIcon(QIcon(":/images/setBookmark.png"));
setBookmark->setDisabled(true);
setBookmark->setCheckable(true);
connect(setBookmark,SIGNAL(triggered (bool)),viewer,SLOT(setBookmark(bool)));
connect(viewer,SIGNAL(pageAvailable(bool)),setBookmark,SLOT(setEnabled(bool)));
connect(viewer,SIGNAL(pageIsBookmark(bool)),setBookmark,SLOT(setChecked(bool)));
showBookmarks = new QAction(tr("Show bookmarks"),this);
showBookmarks->setToolTip(tr("Show the bookmarks of the current comic"));
showBookmarks->setShortcut(tr("M"));
showBookmarks->setIcon(QIcon(":/images/bookmark.png"));
showBookmarks->setDisabled(true);
connect(showBookmarks, SIGNAL(triggered()),viewer->getBookmarksDialog(),SLOT(show()));
showShorcutsAction = new QAction(tr("Show keyboard shortcuts"), this );
showShorcutsAction->setIcon(QIcon(":/images/shortcuts.png"));
connect(showShorcutsAction, SIGNAL(triggered()),shortcutsDialog,SLOT(show()));
showInfo = new QAction(tr("Show Info"),this);
showInfo->setShortcut(tr("I"));
showInfo->setIcon(QIcon(":/images/properties.png"));
showInfo->setDisabled(true);
connect(showInfo, SIGNAL(triggered()),viewer,SLOT(informationSwitch()));
closeAction = new QAction(tr("Close"),this);
closeAction->setShortcut(Qt::Key_Escape);
closeAction->setIcon(QIcon(":/images/deleteLibrary.png"));
connect(closeAction,SIGNAL(triggered()),this,SLOT(close()));
showDictionaryAction = new QAction(tr("Show Dictionary"),this);
showDictionaryAction->setShortcut(Qt::Key_T);
showDictionaryAction->setIcon(QIcon(":/images/dictionary.png"));
showDictionaryAction->setCheckable(true);
showDictionaryAction->setDisabled(true);
connect(showDictionaryAction,SIGNAL(triggered()),viewer,SLOT(translatorSwitch()));
alwaysOnTopAction = new QAction(tr("Always on top"),this);
alwaysOnTopAction->setShortcut(Qt::Key_Q);
alwaysOnTopAction->setIcon(QIcon(":/images/alwaysOnTop.png"));
alwaysOnTopAction->setCheckable(true);
alwaysOnTopAction->setDisabled(true);
alwaysOnTopAction->setChecked(Configuration::getConfiguration().getAlwaysOnTop());
connect(alwaysOnTopAction,SIGNAL(triggered()),this,SLOT(alwaysOnTopSwitch()));
adjustToFullSizeAction = new QAction(tr("Show full size"),this);
adjustToFullSizeAction->setShortcut(Qt::Key_W);
adjustToFullSizeAction->setIcon(QIcon(":/images/adjustToFullSize.png"));
adjustToFullSizeAction->setCheckable(true);
adjustToFullSizeAction->setDisabled(true);
adjustToFullSizeAction->setChecked(Configuration::getConfiguration().getAdjustToFullSize());
connect(adjustToFullSizeAction,SIGNAL(triggered()),this,SLOT(adjustToFullSizeSwitch()));
}
void MainWindowViewer::createToolBars()
{
comicToolBar = addToolBar(tr("&File"));
QToolButton * tb = new QToolButton();
tb->addAction(openAction);
tb->addAction(openFolderAction);
tb->setPopupMode(QToolButton::MenuButtonPopup);
tb->setDefaultAction(openAction);
comicToolBar->addWidget(tb);
comicToolBar->addAction(saveImageAction);
comicToolBar->addAction(openPreviousComicAction);
comicToolBar->addAction(openNextComicAction);
comicToolBar->addSeparator();
comicToolBar->addAction(prevAction);
comicToolBar->addAction(nextAction);
comicToolBar->addAction(goToPage);
#ifndef Q_OS_MAC
comicToolBar->addSeparator();
comicToolBar->addAction(alwaysOnTopAction);
#else
alwaysOnTopAction->setEnabled(false);
#endif
comicToolBar->addSeparator();
//QWidget * widget = new QWidget();
//QToolButton * tbW = new QToolButton(widget);
//tbW->addAction(adjustWidth);
//tbW->setPopupMode(QToolButton::MenuButtonPopup);
//tbW->setDefaultAction(adjustWidth);
//QHBoxLayout *layout = new QHBoxLayout;
//layout->addWidget(tbW);
//layout->setContentsMargins(0,0,0,0);
//widget->setLayout(layout);
//widget->setContentsMargins(0,0,0,0);
//comicToolBar->addWidget(widget);
//comicToolBar->addAction(adjustWidth);
QMenu * menu = new QMenu();
sliderAction = new YACReaderSliderAction(this);
menu->setAutoFillBackground(false);
menu->setStyleSheet(" QMenu {background:transparent; border: 0px;padding: 0px; }"
);
menu->addAction(sliderAction);
QToolButton * tb2 = new QToolButton();
tb2->addAction(adjustWidth);
tb2->setMenu(menu);
connect(sliderAction,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
connect(optionsDialog,SIGNAL(fitToWidthRatioChanged(float)),sliderAction,SLOT(updateFitToWidthRatio(float)));
//tb2->addAction();
tb2->setPopupMode(QToolButton::MenuButtonPopup);
tb2->setDefaultAction(adjustWidth);
comicToolBar->addWidget(tb2);
comicToolBar->addAction(adjustToFullSizeAction);
comicToolBar->addAction(leftRotationAction);
comicToolBar->addAction(rightRotationAction);
comicToolBar->addAction(doublePageAction);
comicToolBar->addSeparator();
comicToolBar->addAction(showMagnifyingGlass);
comicToolBar->addSeparator();
comicToolBar->addAction(setBookmark);
comicToolBar->addAction(showBookmarks);
comicToolBar->addSeparator();
comicToolBar->addAction(showDictionaryAction);
comicToolBar->addWidget(new QToolBarStretch());
comicToolBar->addAction(showShorcutsAction);
comicToolBar->addAction(optionsAction);
comicToolBar->addAction(helpAboutAction);
comicToolBar->addAction(closeAction);
comicToolBar->setMovable(false);
viewer->addAction(openAction);
viewer->addAction(openFolderAction);
viewer->addAction(saveImageAction);
viewer->addAction(openPreviousComicAction);
viewer->addAction(openNextComicAction);
QAction * separator = new QAction("",this);
separator->setSeparator(true);
viewer->addAction(separator);
viewer->addAction(prevAction);
viewer->addAction(nextAction);
viewer->addAction(goToPage);
viewer->addAction(adjustWidth);
viewer->addAction(adjustToFullSizeAction);
viewer->addAction(leftRotationAction);
viewer->addAction(rightRotationAction);
viewer->addAction(doublePageAction);
separator = new QAction("",this);
separator->setSeparator(true);
viewer->addAction(separator);
viewer->addAction(setBookmark);
viewer->addAction(showBookmarks);
separator = new QAction("",this);
separator->setSeparator(true);
viewer->addAction(separator);
viewer->addAction(showDictionaryAction);
separator = new QAction("",this);
separator->setSeparator(true);
viewer->addAction(separator);
viewer->addAction(showMagnifyingGlass);
viewer->addAction(optionsAction);
viewer->addAction(helpAboutAction);
viewer->addAction(showInfo);
viewer->addAction(showShorcutsAction);
separator = new QAction("",this);
separator->setSeparator(true);
viewer->addAction(separator);
viewer->addAction(closeAction);
viewer->setContextMenuPolicy(Qt::ActionsContextMenu);
}
void MainWindowViewer::reloadOptions()
{
viewer->updateConfig(settings);
}
void MainWindowViewer::open()
{
QFileDialog openDialog;
QString pathFile = openDialog.getOpenFileName(this,tr("Open Comic"),currentDirectory,tr("Comic files") + "(*.cbr *.cbz *.rar *.zip *.tar *.pdf *.7z *.cb7 *.arj *.cbt)");
if (!pathFile.isEmpty())
{
openComicFromPath(pathFile);
}
}
void MainWindowViewer::openComicFromPath(QString pathFile)
{
currentDirectory = pathFile;
QFileInfo fi(pathFile);
getSiblingComics(fi.absolutePath(),fi.fileName());
setWindowTitle("YACReader - " + fi.fileName());
enableActions();
viewer->open(pathFile);
}
void MainWindowViewer::openFolder()
{
QFileDialog openDialog;
QString pathDir = openDialog.getExistingDirectory(this,tr("Open folder"),currentDirectory);
if (!pathDir.isEmpty())
{
openFolderFromPath(pathDir);
}
}
void MainWindowViewer::openFolderFromPath(QString pathDir)
{
currentDirectory = pathDir; //TODO ??
QFileInfo fi(pathDir);
getSiblingComics(fi.absolutePath(),fi.fileName());
setWindowTitle("YACReader - " + fi.fileName());
enableActions();
viewer->open(pathDir);
}
void MainWindowViewer::saveImage()
{
QFileDialog saveDialog;
QString pathFile = saveDialog.getSaveFileName(this,tr("Save current page"),currentDirectoryImgDest,tr("Image files (*.jpg)"));
if (!pathFile.isEmpty())
{
currentDirectoryImgDest = pathFile;
const QPixmap * p = viewer->pixmap();
if(p!=NULL)
p->save(pathFile);
}
}
void MainWindowViewer::enableActions()
{
saveImageAction->setDisabled(false);
prevAction->setDisabled(false);
nextAction->setDisabled(false);
adjustWidth->setDisabled(false);
goToPage->setDisabled(false);
alwaysOnTopAction->setDisabled(false);
leftRotationAction->setDisabled(false);
rightRotationAction->setDisabled(false);
showMagnifyingGlass->setDisabled(false);
doublePageAction->setDisabled(false);
adjustToFullSizeAction->setDisabled(false);
//setBookmark->setDisabled(false);
showBookmarks->setDisabled(false);
showInfo->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited
showDictionaryAction->setDisabled(false);
}
void MainWindowViewer::disableActions()
{
saveImageAction->setDisabled(true);
prevAction->setDisabled(true);
nextAction->setDisabled(true);
adjustWidth->setDisabled(true);
goToPage->setDisabled(true);
alwaysOnTopAction->setDisabled(true);
leftRotationAction->setDisabled(true);
rightRotationAction->setDisabled(true);
showMagnifyingGlass->setDisabled(true);
doublePageAction->setDisabled(true);
adjustToFullSizeAction->setDisabled(true);
setBookmark->setDisabled(true);
showBookmarks->setDisabled(true);
showInfo->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited
openPreviousComicAction->setDisabled(true);
openNextComicAction->setDisabled(true);
showDictionaryAction->setDisabled(true);
}
void MainWindowViewer::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Escape:
this->close();
break;
case Qt::Key_F:
toggleFullScreen();
break;
case Qt::Key_H:
toggleToolBars();
break;
case Qt::Key_O:
open();
break;
default:
QWidget::keyPressEvent(event);
break;
}
}
void MainWindowViewer::mouseDoubleClickEvent ( QMouseEvent * event )
{
toggleFullScreen();
event->accept();
}
void MainWindowViewer::toggleFullScreen()
{
fullscreen?toNormal():toFullScreen();
Configuration::getConfiguration().setFullScreen(fullscreen = !fullscreen);
}
void MainWindowViewer::toFullScreen()
{
fromMaximized = this->isMaximized();
hideToolBars();
viewer->hide();
viewer->fullscreen = true;//TODO, change by the right use of windowState();
showFullScreen();
viewer->show();
if(viewer->magnifyingGlassIsVisible())
viewer->showMagnifyingGlass();
}
void MainWindowViewer::toNormal()
{
//show all
viewer->hide();
viewer->fullscreen = false;//TODO, change by the right use of windowState();
//viewer->hideMagnifyingGlass();
if(fromMaximized)
showMaximized();
else
showNormal();
if(Configuration::getConfiguration().getShowToolbars())
showToolBars();
viewer->show();
if(viewer->magnifyingGlassIsVisible())
viewer->showMagnifyingGlass();
}
void MainWindowViewer::toggleToolBars()
{
toolbars?hideToolBars():showToolBars();
Configuration::getConfiguration().setShowToolbars(toolbars);
comicToolBar->setMovable(false);
}
void MainWindowViewer::hideToolBars()
{
//hide all
this->comicToolBar->hide();
toolbars = false;
}
void MainWindowViewer::showToolBars()
{
this->comicToolBar->show();
toolbars = true;
}
void MainWindowViewer::changeFit()
{
Configuration & conf = Configuration::getConfiguration();
conf.setAdjustToWidth(!conf.getAdjustToWidth());
viewer->updatePage();
}
void MainWindowViewer::newVersion()
{
QMessageBox msgBox;
msgBox.setText(tr("There is a new version avaliable"));
msgBox.setInformativeText(tr("Do you want to download the new version?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if(ret==QMessageBox::Yes){
QDesktopServices::openUrl(QUrl("http://www.yacreader.com"));
}
}
void MainWindowViewer::closeEvent ( QCloseEvent * event )
{
viewer->save();
Configuration & conf = Configuration::getConfiguration();
if(!fullscreen && !isMaximized())
{
conf.setPos(pos());
conf.setSize(size());
}
conf.setMaximized(isMaximized());
}
void MainWindowViewer::openPreviousComic()
{
if(!previousComicPath.isEmpty())
{
viewer->open(previousComicPath);
QFileInfo fi(previousComicPath);
getSiblingComics(fi.absolutePath(),fi.fileName());
setWindowTitle("YACReader - " + fi.fileName());
}
}
void MainWindowViewer::openNextComic()
{
if(!nextComicPath.isEmpty())
{
viewer->open(nextComicPath);
QFileInfo fi(nextComicPath);
getSiblingComics(fi.absolutePath(),fi.fileName());
setWindowTitle("YACReader - " + fi.fileName());
}
}
void MainWindowViewer::getSiblingComics(QString path,QString currentComic)
{
QDir d(path);
d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
d.setNameFilters(QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf" << "*.7z" << "*.cb7" << "*.arj" << "*.cbt");
d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
QStringList list = d.entryList();
qSort(list.begin(),list.end(),naturalSortLessThanCI);
//std::sort(list.begin(),list.end(),naturalSortLessThanCI);
int index = list.indexOf(currentComic);
if(index == -1) //comic not found
{
QFile f(QCoreApplication::applicationDirPath()+"/errorLog.txt");
if(!f.open(QIODevice::WriteOnly))
{
QMessageBox::critical(NULL,tr("Saving error log file...."),tr("There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder."));
}
else
{
QTextStream txtS(&f);
txtS << "METHOD : MainWindowViewer::getSiblingComics" << '\n';
txtS << "ERROR : current comic not found in its own path" << '\n';
txtS << path << '\n';
txtS << currentComic << '\n';
txtS << "Comic list count : " + list.count() << '\n';
foreach(QString s, list){
txtS << s << '\n';
}
f.close();
}
}
previousComicPath = nextComicPath = "";
if(index>0)
{
previousComicPath = path+"/"+list.at(index-1);
openPreviousComicAction->setDisabled(false);
}
else
openPreviousComicAction->setDisabled(true);
if(index+1<list.count())
{
nextComicPath = path+"/"+list.at(index+1);
openNextComicAction->setDisabled(false);
}
else
openNextComicAction->setDisabled(true);
}
void MainWindowViewer::dropEvent(QDropEvent *event)
{
QList<QUrl> urlList;
QString fName;
QFileInfo info;
if (event->mimeData()->hasUrls())
{
urlList = event->mimeData()->urls();
if ( urlList.size() > 0)
{
fName = urlList[0].toLocalFile(); // convert first QUrl to local path
info.setFile( fName ); // information about file
if (info.isFile())
openComicFromPath(fName); // if is file, setText
else
if(info.isDir())
openFolderFromPath(fName);
}
}
event->acceptProposedAction();
}
void MainWindowViewer::dragEnterEvent(QDragEnterEvent *event)
{
// accept just text/uri-list mime format
if (event->mimeData()->hasFormat("text/uri-list"))
{
event->acceptProposedAction();
}
}
void MainWindowViewer::alwaysOnTopSwitch()
{
if(!Configuration::getConfiguration().getAlwaysOnTop())
{
setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); //always on top
show();
}
else
{
setWindowFlags(this->windowFlags() ^ (Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint));
show();
}
Configuration::getConfiguration().setAlwaysOnTop(!Configuration::getConfiguration().getAlwaysOnTop());
}
void MainWindowViewer::adjustToFullSizeSwitch()
{
Configuration::getConfiguration().setAdjustToFullSize(!Configuration::getConfiguration().getAdjustToFullSize());
viewer->updatePage();
}

View File

@ -0,0 +1,121 @@
#ifndef __MAIN_WINDOW_VIEWER_H
#define __MAIN_WINDOW_VIEWER_H
#include <QMainWindow>
#include <QScrollArea>
#include <QToolBar>
#include <QAction>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QCloseEvent>
#include <QSettings>
class Comic;
class Viewer;
class OptionsDialog;
class HelpAboutDialog;
class HttpVersionChecker;
class ShortcutsDialog;
class YACReaderSliderAction;
class MainWindowViewer : public QMainWindow
{
Q_OBJECT
public slots:
void open();
void openFolder();
void saveImage();
void toggleToolBars();
void hideToolBars();
void showToolBars();
void changeFit();
void enableActions();
void disableActions();
void toggleFullScreen();
void toFullScreen();
void toNormal();
void loadConfiguration();
void newVersion();
void openPreviousComic();
void openNextComic();
void openComicFromPath(QString pathFile);
void openFolderFromPath(QString pathDir);
void alwaysOnTopSwitch();
void adjustToFullSizeSwitch();
void reloadOptions();
/*void viewComic();
void prev();
void next();
void updatePage();*/
private:
//!State
bool fullscreen;
bool toolbars;
bool alwaysOnTop;
bool fromMaximized;
QString currentDirectory;
QString currentDirectoryImgDest;
//!Widgets
Viewer * viewer;
//GoToDialog * goToDialog;
OptionsDialog * optionsDialog;
HelpAboutDialog * had;
ShortcutsDialog * shortcutsDialog;
//! ToolBars
QToolBar *comicToolBar;
//! Actions
QAction *openAction;
QAction *openFolderAction;
QAction *saveImageAction;
QAction *openPreviousComicAction;
QAction *openNextComicAction;
QAction *nextAction;
QAction *prevAction;
QAction *adjustWidth;
QAction *adjustHeight;
QAction *goToPage;
QAction *optionsAction;
QAction *helpAboutAction;
QAction *showMagnifyingGlass;
QAction *setBookmark;
QAction *showBookmarks;
QAction *leftRotationAction;
QAction *rightRotationAction;
QAction *showInfo;
QAction *closeAction;
QAction *doublePageAction;
QAction *showShorcutsAction;
QAction *showDictionaryAction;
QAction *alwaysOnTopAction;
QAction *adjustToFullSizeAction;
YACReaderSliderAction * sliderAction;
HttpVersionChecker * versionChecker;
QString previousComicPath;
QString nextComicPath;
//! M<>todo que inicializa el interfaz.
void setupUI();
void createActions();
void createToolBars();
void getSiblingComics(QString path,QString currentComic);
//! Manejadores de evento:
void keyPressEvent(QKeyEvent *event);
//void resizeEvent(QResizeEvent * event);
void mouseDoubleClickEvent ( QMouseEvent * event );
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
QSettings * settings;
protected:
virtual void closeEvent ( QCloseEvent * event );
public:
MainWindowViewer();
};
#endif

View File

@ -0,0 +1,83 @@
#include "notifications_label_widget.h"
#include <QLabel>
#include <QHBoxLayout>
#include <QPropertyAnimation>
#include <QGraphicsOpacityEffect>
NotificationsLabelWidget::NotificationsLabelWidget(QWidget * parent)
:QWidget(parent)
{
setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
effect = new QGraphicsOpacityEffect(this);
effect->setOpacity(1.0);
effect2= new QGraphicsOpacityEffect(this);
effect->setOpacity(1.0);
anim = new QPropertyAnimation(effect,"opacity");
anim->setDuration(500);
anim->setStartValue(1.0);
anim->setEndValue(0.0);
anim->setEasingCurve(QEasingCurve::InExpo);
anim2 = new QPropertyAnimation(effect2,"opacity");
anim2->setDuration(500);
anim2->setStartValue(1.0);
anim2->setEndValue(0.0);
anim2->setEasingCurve(QEasingCurve::InExpo);
anim2->start();
connect(anim,SIGNAL(finished()),this,SLOT(hide()));
imgLabel = new QLabel(this);
QPixmap p(":/images/notificationsLabel.png");
imgLabel->resize(p.size());
imgLabel->setPixmap(p);
imgLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
textLabel = new QLabel(this);
textLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
textLabel->setStyleSheet("QLabel { color : white; font-size:24px; }");
textLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
textLabel->setGeometry(imgLabel->geometry());
#ifndef Q_OS_MAC
imgLabel->setGraphicsEffect(effect);
textLabel->setGraphicsEffect(effect2);
#endif
resize(p.size());
updatePosition();
}
void NotificationsLabelWidget::flash()
{
updatePosition();
anim->stop();
anim2->stop();
anim->start();
anim2->start();
setVisible(true);
}
void NotificationsLabelWidget::setText(const QString & text)
{
textLabel->setText(text);
QRect geom = imgLabel->geometry();
QSize size = geom.size();
size.setHeight(size.height() - 10); //TODO remove this amazing magic number
geom.setSize(size);
textLabel->setGeometry(geom);
}
void NotificationsLabelWidget::updatePosition()
{
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
if(parent == 0)
{
return;
}
move(QPoint((parent->geometry().size().width()-this->width())/2,(parent->geometry().size().height()-this->height())/2));
}

View File

@ -0,0 +1,29 @@
#ifndef NOTIFICATIONS_LABEL_WIDGET_H
#define NOTIFICATIONS_LABEL_WIDGET_H
#include <QWidget>
class QLabel;
class QPropertyAnimation;
class QGraphicsOpacityEffect;
class NotificationsLabelWidget : public QWidget
{
Q_OBJECT
private:
QLabel * imgLabel;
QLabel * textLabel;
QPropertyAnimation * anim;
QPropertyAnimation * anim2;
QGraphicsOpacityEffect * effect;
QGraphicsOpacityEffect * effect2;
public:
NotificationsLabelWidget(QWidget * parent);
public slots:
void flash();
void setText(const QString & text);
void updatePosition();
};
#endif

View File

@ -0,0 +1,283 @@
#include "options_dialog.h"
#include "configuration.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFileDialog>
#include <QGroupBox>
#include <QRadioButton>
#include <QTabWidget>
#include <QSlider>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QColorDialog>
#include "yacreader_spin_slider_widget.h"
#include "yacreader_flow_config_widget.h"
#include "yacreader_gl_flow_config_widget.h"
OptionsDialog::OptionsDialog(QWidget * parent)
:YACReaderOptionsDialog(parent)
{
QTabWidget * tabWidget = new QTabWidget();
QVBoxLayout * layout = new QVBoxLayout(this);
QWidget * pageGeneral = new QWidget();
QWidget * pageFlow = new QWidget();
QWidget * pageImage = new QWidget();
QVBoxLayout * layoutGeneral = new QVBoxLayout();
QVBoxLayout * layoutFlow = new QVBoxLayout();
QVBoxLayout * layoutImageV = new QVBoxLayout();
QGridLayout * layoutImage = new QGridLayout();
QGroupBox *slideSizeBox = new QGroupBox(tr("\"Go to flow\" size"));
//slideSizeLabel = new QLabel(,this);
slideSize = new QSlider(this);
slideSize->setMinimum(125);
slideSize->setMaximum(350);
slideSize->setPageStep(5);
slideSize->setOrientation(Qt::Horizontal);
QHBoxLayout * slideLayout = new QHBoxLayout();
slideLayout->addWidget(slideSize);
slideSizeBox->setLayout(slideLayout);
QGroupBox *pathBox = new QGroupBox(tr("My comics path"));
QHBoxLayout * path = new QHBoxLayout();
path->addWidget(pathEdit = new QLineEdit());
path->addWidget(pathFindButton = new QPushButton(QIcon(":/images/comicFolder.png"),""));
pathBox->setLayout(path);
connect(pathFindButton,SIGNAL(clicked()),this,SLOT(findFolder()));
//fitToWidthRatioLabel = new QLabel(tr("Page width stretch"),this);
QGroupBox *fitBox = new QGroupBox(tr("Page width stretch"));
fitToWidthRatioS = new QSlider(this);
fitToWidthRatioS->setMinimum(50);
fitToWidthRatioS->setMaximum(100);
fitToWidthRatioS->setPageStep(5);
fitToWidthRatioS->setOrientation(Qt::Horizontal);
connect(fitToWidthRatioS,SIGNAL(valueChanged(int)),this,SLOT(fitToWidthRatio(int)));
QHBoxLayout * fitLayout = new QHBoxLayout;
fitLayout->addWidget(fitToWidthRatioS);
fitBox->setLayout(fitLayout);
QHBoxLayout * colorSelection = new QHBoxLayout;
backgroundColor = new QLabel();
QPalette pal = backgroundColor->palette();
pal.setColor(backgroundColor->backgroundRole(), Qt::black);
backgroundColor->setPalette(pal);
backgroundColor->setAutoFillBackground(true);
colorDialog = new QColorDialog(Qt::red,this);
connect(colorDialog,SIGNAL(colorSelected(QColor)),this,SLOT(updateColor(QColor)));
QGroupBox *colorBox = new QGroupBox(tr("Background color"));
//backgroundColor->setMinimumWidth(100);
colorSelection->addWidget(backgroundColor);
colorSelection->addWidget(selectBackgroundColorButton = new QPushButton(tr("Choose")));
colorSelection->setStretchFactor(backgroundColor,1);
colorSelection->setStretchFactor(selectBackgroundColorButton,0);
//colorSelection->addStretch();
connect(selectBackgroundColorButton, SIGNAL(clicked()), colorDialog, SLOT(show()));
colorBox->setLayout(colorSelection);
brightnessS = new YACReaderSpinSliderWidget(this,true);
brightnessS->setRange(0,100);
//brightnessS->setText(tr("Brightness"));
brightnessS->setTracking(false);
connect(brightnessS,SIGNAL(valueChanged(int)),this,SLOT(brightnessChanged(int)));
contrastS = new YACReaderSpinSliderWidget(this,true);
contrastS->setRange(0,250);
//contrastS->setText(tr("Contrast"));
contrastS->setTracking(false);
connect(contrastS,SIGNAL(valueChanged(int)),this,SLOT(contrastChanged(int)));
gammaS = new YACReaderSpinSliderWidget(this,true);
gammaS->setRange(0,250);
//gammaS->setText(tr("Gamma"));
gammaS->setTracking(false);
connect(gammaS,SIGNAL(valueChanged(int)),this,SLOT(gammaChanged(int)));
//connect(brightnessS,SIGNAL(valueChanged(int)),this,SIGNAL(changedOptions()));
QHBoxLayout * buttons = new QHBoxLayout();
buttons->addStretch();
buttons->addWidget(new QLabel(tr("Restart is needed")));
buttons->addWidget(accept);
buttons->addWidget(cancel);
layoutGeneral->addWidget(pathBox);
layoutGeneral->addWidget(slideSizeBox);
layoutGeneral->addWidget(fitBox);
layoutGeneral->addWidget(colorBox);
layoutGeneral->addStretch();
layoutFlow->addWidget(sw);
layoutFlow->addWidget(gl);
layoutFlow->addWidget(useGL);
layoutFlow->addStretch();
layoutImage->addWidget(new QLabel(tr("Brightness")),0,0);
layoutImage->addWidget(new QLabel(tr("Contrast")),1,0);
layoutImage->addWidget(new QLabel(tr("Gamma")),2,0);
layoutImage->addWidget(brightnessS,0,1);
layoutImage->addWidget(contrastS,1,1);
layoutImage->addWidget(gammaS,2,1);
QPushButton * pushButton = new QPushButton(tr("Reset"));
connect(pushButton,SIGNAL(pressed()),this,SLOT(resetImageConfig()));
layoutImage->addWidget(pushButton,3,0);
layoutImage->setColumnStretch(1,1);
QGroupBox *imageBox = new QGroupBox(tr("Image options"));
imageBox->setLayout(layoutImage);
layoutImageV->addWidget(imageBox);
layoutImageV->addStretch();
pageGeneral->setLayout(layoutGeneral);
pageFlow->setLayout(layoutFlow);
pageImage->setLayout(layoutImageV);
tabWidget->addTab(pageGeneral,tr("General"));
tabWidget->addTab(pageFlow,tr("Page Flow"));
tabWidget->addTab(pageImage,tr("Image adjustment"));
layout->addWidget(tabWidget);
layout->addLayout(buttons);
setLayout(layout);
//disable vSyncCheck
gl->vSyncCheck->hide();
//restoreOptions(); //load options
//resize(400,0);
setModal (true);
setWindowTitle(tr("Options"));
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
}
void OptionsDialog::findFolder()
{
QString s = QFileDialog::getExistingDirectory(0,tr("Comics directory"),".");
if(!s.isEmpty())
{
pathEdit->setText(s);
}
}
void OptionsDialog::saveOptions()
{
settings->setValue(GO_TO_FLOW_SIZE,QSize(static_cast<int>(slideSize->sliderPosition()/SLIDE_ASPECT_RATIO),slideSize->sliderPosition()));
if(sw->radio1->isChecked())
settings->setValue(FLOW_TYPE_SW,0);
if(sw->radio2->isChecked())
settings->setValue(FLOW_TYPE_SW,1);
if(sw->radio3->isChecked())
settings->setValue(FLOW_TYPE_SW,2);
settings->setValue(PATH,pathEdit->text());
settings->setValue(BACKGROUND_COLOR,colorDialog->currentColor());
settings->setValue(FIT_TO_WIDTH_RATIO,fitToWidthRatioS->sliderPosition()/100.0);
YACReaderOptionsDialog::saveOptions();
}
void OptionsDialog::restoreOptions(QSettings * settings)
{
YACReaderOptionsDialog::restoreOptions(settings);
slideSize->setSliderPosition(settings->value(GO_TO_FLOW_SIZE).toSize().height());
switch(settings->value(FLOW_TYPE_SW).toInt())
{
case 0:
sw->radio1->setChecked(true);
break;
case 1:
sw->radio2->setChecked(true);
break;
case 2:
sw->radio3->setChecked(true);
break;
default:
sw->radio1->setChecked(true);
break;
}
pathEdit->setText(settings->value(PATH).toString());
updateColor(settings->value(BACKGROUND_COLOR).value<QColor>());
fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
brightnessS->setValue(settings->value(BRIGHTNESS,0).toInt());
contrastS->setValue(settings->value(CONTRAST,100).toInt());
gammaS->setValue(settings->value(GAMMA,100).toInt());
}
void OptionsDialog::updateColor(const QColor & color)
{
QPalette pal = backgroundColor->palette();
pal.setColor(backgroundColor->backgroundRole(), color);
backgroundColor->setPalette(pal);
backgroundColor->setAutoFillBackground(true);
colorDialog->setCurrentColor(color);
settings->setValue(BACKGROUND_COLOR,color);
emit(changedOptions());
}
void OptionsDialog::fitToWidthRatio(int value)
{
Configuration::getConfiguration().setFitToWidthRatio(value/100.0);
emit(fitToWidthRatioChanged(value/100.0));
}
void OptionsDialog::brightnessChanged(int value)
{
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(BRIGHTNESS,value);
emit(changedImageOptions());
}
void OptionsDialog::contrastChanged(int value)
{
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(CONTRAST,value);
emit(changedImageOptions());
}
void OptionsDialog::gammaChanged(int value)
{
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(GAMMA,value);
emit(changedImageOptions());
}
void OptionsDialog::resetImageConfig()
{
brightnessS->setValue(0);
contrastS->setValue(100);
gammaS->setValue(100);
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(BRIGHTNESS,0);
settings.setValue(CONTRAST,100);
settings.setValue(GAMMA,100);
emit(changedImageOptions());
}
void OptionsDialog::show()
{
//TODO solucionar el tema de las settings, esto s<>lo deber<65>a aparecer en una <20>nica l<>nea de c<>digo
QSettings *s = new QSettings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
QDialog::show();
delete s;
}

View File

@ -0,0 +1,68 @@
#ifndef __OPTIONS_DIALOG_H
#define __OPTIONS_DIALOG_H
#include "yacreader_options_dialog.h"
class QDialog;
class QLabel;
class QLineEdit;
class QPushButton;
class QSlider;
class QPushButton;
class QRadioButton;
class QColorDialog;
class YACReaderSpinSliderWidget;
class OptionsDialog : public YACReaderOptionsDialog
{
Q_OBJECT
public:
OptionsDialog(QWidget * parent = 0);
private:
//QLabel * pathLabel;
QLineEdit * pathEdit;
QPushButton * pathFindButton;
QLabel * magGlassSizeLabel;
QLabel * zoomLevel;
//QLabel * slideSizeLabel;
QSlider * slideSize;
//QLabel * fitToWidthRatioLabel;
QSlider * fitToWidthRatioS;
QLabel * backgroundColor;
QPushButton * selectBackgroundColorButton;
QColorDialog * colorDialog;
YACReaderSpinSliderWidget * brightnessS;
YACReaderSpinSliderWidget * contrastS;
YACReaderSpinSliderWidget * gammaS;
public slots:
void saveOptions();
void restoreOptions(QSettings * settings);
void findFolder();
void updateColor(const QColor & color);
void fitToWidthRatio(int value);
void brightnessChanged(int value);
void contrastChanged(int value);
void gammaChanged(int value);
void resetImageConfig();
void show();
signals:
void changedOptions();
void changedImageOptions();
void fitToWidthRatioChanged(float ratio);
};
#endif

View File

@ -0,0 +1,116 @@
#include "page_label_widget.h"
#include <QLabel>
#include <QHBoxLayout>
#include <QPropertyAnimation>
#include <QApplication>
#include <QDesktopWidget>
PageLabelWidget::PageLabelWidget(QWidget * parent)
:QWidget(parent)
{
animation = new QPropertyAnimation(this,"pos");
animation->setDuration(150);
int verticalRes = QApplication::desktop()->screenGeometry().height();
imgLabel = new QLabel(this);
QPixmap p;
if (verticalRes <= 1024)
p.load(":/images/numPagesLabel.png");
else if (verticalRes <= 1200)
p.load(":/images/numPagesLabelMedium.png");
else
p.load(":/images/numPagesLabelBig.png");
imgLabel->resize(p.size());
imgLabel->setPixmap(p);
textLabel = new QLabel(this);
textLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
if(verticalRes <= 1024)
textLabel->setStyleSheet("QLabel { color : white; font-size:12px; padding-left:8px; }");
else if (verticalRes <= 1200)
textLabel->setStyleSheet("QLabel { color : white; font-size:16px; padding-left:8px;}");
else
textLabel->setStyleSheet("QLabel { color : white; font-size:20px; padding-left:8px; }");
//informationLabel->setAutoFillBackground(true);
//textLabel->setFont(QFont("courier new bold", 12));
//textLabel->resize(100,25);
resize(p.size());
//por defecto aparece oculto
if(parent != 0)
move(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
/*QSize size = textLabel->sizeHint();
int w = width(); // returns screen width
int h = height(); // returns screen height
int mw = size.width();
int mh = size.height();
int cw = (w-mw)/2;
int ch = 0;
textLabel->move(cw,ch);*/
}
void PageLabelWidget::show()
{
if(this->pos().y() <= 0 && animation->state()!=QPropertyAnimation::Running)
{
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
if(parent == 0)
{
return;
}
QWidget::show();
//connect(animation,SIGNAL(finished()),this,SLOT(QWidget::hide()));
animation->disconnect();
animation->setStartValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),0));
animation->start();
}
}
void PageLabelWidget::hide()
{
if(this->pos().y() >= 0 && animation->state()!=QPropertyAnimation::Running)
{
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
if(parent == 0)
{
return;
}
//connect(animation,SIGNAL(finished()),this,SLOT(setHidden()));
animation->setStartValue(QPoint((parent->geometry().size().width()-this->width()),0));
animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
animation->start();
}
}
void PageLabelWidget::setText(const QString & text)
{
textLabel->setText(text);
QRect geom = imgLabel->geometry();
QSize size = geom.size();
size.setHeight(size.height() - 10);//TODO remove this amazing magic number
geom.setSize(size);
textLabel->setGeometry(geom);
}
/*void PageLabelWidget::resizeEvent(QResizeEvent * event)
{
move(QPoint((((QWidget *) parent())->geometry().size().width()-this->width())/2,0));
}*/
void PageLabelWidget::updatePosition()
{
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
if(parent == 0)
{
return;
}
move(QPoint((parent->geometry().size().width()-this->width()),this->pos().y()));
}

View File

@ -0,0 +1,29 @@
#ifndef PAGE_LABEL_WIDGET_H
#define PAGE_LABEL_WIDGET_H
#include <QWidget>
class QLabel;
class QPropertyAnimation;
class PageLabelWidget : public QWidget
{
Q_OBJECT
private:
QLabel * imgLabel;
QLabel * textLabel;
QPropertyAnimation * animation;
//void resizeEvent(QResizeEvent * event);
public:
PageLabelWidget(QWidget * parent);
public slots:
void show();
void hide();
void setText(const QString & text);
void updatePosition();
};
#endif

954
YACReader/render.cpp Normal file
View File

@ -0,0 +1,954 @@
#include "render.h"
#include <cmath>
#include <QList>
#include <algorithm>
#include <QByteArray>
#include <QPixmap>
#include <typeinfo>
#define NL 2
#define NR 2
#include "yacreader_global.h"
template<class T>
inline const T& kClamp( const T& x, const T& low, const T& high )
{
if ( x < low ) return low;
else if ( high < x ) return high;
else return x;
}
inline
int changeBrightness( int value, int brightness )
{
return kClamp( value + brightness * 255 / 100, 0, 255 );
}
inline
int changeContrast( int value, int contrast )
{
return kClamp((( value - 127 ) * contrast / 100 ) + 127, 0, 255 );
}
inline
int changeGamma( int value, int gamma )
{
return kClamp( int( pow( value / 255.0, 100.0 / gamma ) * 255 ), 0, 255 );
}
inline
int changeUsingTable( int value, const int table[] )
{
return table[ value ];
}
template< int operation( int, int ) >
static
QImage changeImage( const QImage& image, int value )
{
QImage im = image;
im.detach();
if( im.numColors() == 0 ) /* truecolor */
{
if( im.format() != QImage::Format_RGB32 ) /* just in case */
im = im.convertToFormat( QImage::Format_RGB32 );
int table[ 256 ];
for( int i = 0;
i < 256;
++i )
table[ i ] = operation( i, value );
if( im.hasAlphaChannel() )
{
for( int y = 0;
y < im.height();
++y )
{
QRgb* line = reinterpret_cast< QRgb* >( im.scanLine( y ));
for( int x = 0;
x < im.width();
++x )
line[ x ] = qRgba( changeUsingTable( qRed( line[ x ] ), table ),
changeUsingTable( qGreen( line[ x ] ), table ),
changeUsingTable( qBlue( line[ x ] ), table ),
changeUsingTable( qAlpha( line[ x ] ), table ));
}
}
else
{
for( int y = 0;
y < im.height();
++y )
{
QRgb* line = reinterpret_cast< QRgb* >( im.scanLine( y ));
for( int x = 0;
x < im.width();
++x )
line[ x ] = qRgb( changeUsingTable( qRed( line[ x ] ), table ),
changeUsingTable( qGreen( line[ x ] ), table ),
changeUsingTable( qBlue( line[ x ] ), table ));
}
}
}
else
{
QVector<QRgb> colors = im.colorTable();
for( int i = 0;
i < im.numColors();
++i )
colors[ i ] = qRgb( operation( qRed( colors[ i ] ), value ),
operation( qGreen( colors[ i ] ), value ),
operation( qBlue( colors[ i ] ), value ));
}
return im;
}
// brightness is multiplied by 100 in order to avoid floating point numbers
QImage changeBrightness( const QImage& image, int brightness )
{
if( brightness == 0 ) // no change
return image;
return changeImage< changeBrightness >( image, brightness );
}
// contrast is multiplied by 100 in order to avoid floating point numbers
QImage changeContrast( const QImage& image, int contrast )
{
if( contrast == 100 ) // no change
return image;
return changeImage< changeContrast >( image, contrast );
}
// gamma is multiplied by 100 in order to avoid floating point numbers
QImage changeGamma( const QImage& image, int gamma )
{
if( gamma == 100 ) // no change
return image;
return changeImage< changeGamma >( image, gamma );
}
QMutex mutex;
//-----------------------------------------------------------------------------
// MeanNoiseReductionFilter
//-----------------------------------------------------------------------------
MeanNoiseReductionFilter::MeanNoiseReductionFilter(enum NeighborghoodSize ns)
:neighborghoodSize(ns)
{
}
QImage MeanNoiseReductionFilter::setFilter(const QImage & image)
{
int width = image.width();
int height = image.height();
QImage result(width,height,image.format());
int filterSize = sqrt((float)neighborghoodSize);
int bound = filterSize/2;
QRgb pix;
int r,g,b;
for(int j=bound;j<height-bound;j++){
for(int i=bound;i<width-bound;i++){
r=g=b=0;
for(int y=j-bound;y<=j+bound;y++)
{
for(int x=i-bound;x<=i+bound;x++)
{
pix = image.pixel(x,y);
r += qRed(pix);
g += qGreen(pix);
b += qBlue(pix);
}
}
result.setPixel(i,j,QColor(r/neighborghoodSize,g/neighborghoodSize,b/neighborghoodSize).rgb());
//qDebug((QString::number(redChannel.at(4))+" "+QString::number(greenChannel.at(4))+" "+QString::number(blueChannel.at(4))).toAscii());
//qDebug((QString::number(redChannel.size())+" "+QString::number(greenChannel.size())+" "+QString::number(blueChannel.size())).toAscii());
}
}
return result;
}
//-----------------------------------------------------------------------------
// MedianNoiseReductionFilter
//-----------------------------------------------------------------------------
MedianNoiseReductionFilter::MedianNoiseReductionFilter(enum NeighborghoodSize ns)
:neighborghoodSize(ns)
{
}
QImage MedianNoiseReductionFilter::setFilter(const QImage & image)
{
int width = image.width();
int height = image.height();
QImage result(width,height,image.format());
int filterSize = sqrt((float)neighborghoodSize);
int bound = filterSize/2;
QRgb pix;
QList<int> redChannel;
QList<int> greenChannel;
QList<int> blueChannel;
for(int j=bound;j<height-bound;j++){
for(int i=bound;i<width-bound;i++){
redChannel.clear();
greenChannel.clear();
blueChannel.clear();
for(int y=j-bound;y<=j+bound;y++)
{
for(int x=i-bound;x<=i+bound;x++)
{
pix = image.pixel(x,y);
redChannel.push_back(qRed(pix));
greenChannel.push_back(qGreen(pix));
blueChannel.push_back(qBlue(pix));
}
}
std::sort(redChannel.begin(),redChannel.end());
std::sort(greenChannel.begin(),greenChannel.end());
std::sort(blueChannel.begin(),blueChannel.end());
result.setPixel(i,j,QColor(redChannel.at(4),greenChannel.at(4),blueChannel.at(4)).rgb());
}
}
return result;
}
//-----------------------------------------------------------------------------
// BrightnessFilter
//-----------------------------------------------------------------------------
BrightnessFilter::BrightnessFilter(int l)
:level(l)
{
}
QImage BrightnessFilter::setFilter(const QImage & image)
{
/*int width = image.width();
int height = image.height();
QImage result(width,height,image.format());
for(int j=0;j<height;j++){
for(int i=0;i<width;i++){
result.setPixel(i,j,QColor(image.pixel(i,j)).light(level).rgb());
}
}
return result;*/
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
return changeBrightness(image,settings.value(BRIGHTNESS,0).toInt());
}
//-----------------------------------------------------------------------------
// ContrastFilter
//-----------------------------------------------------------------------------
ContrastFilter::ContrastFilter(int l)
:level(l)
{
}
QImage ContrastFilter::setFilter(const QImage & image)
{
/*int width = image.width();
int height = image.height();
QImage result(width,height,image.format());
int min,max,v;
min = 0;
max = 255;
int sum = 0;
QVector<int> hist(256,0);
for(int j=0;j<height;j++){
for(int i=0;i<width;i++){
hist[QColor(image.pixel(i,j)).lightness()]++;
sum++;
}
}
long double count = sum;
long double new_count = 0.0;
long double percentage,next_percentage;
for (int i = 0; i < 254; i++)
{
new_count += hist[i];
percentage = new_count/count;
next_percentage = (new_count+hist[i+1])/count;
if(fabs (percentage - 0.006) < fabs (next_percentage - 0.006))
{
min = i+1;
break;
}
}
new_count=0.0;
for (int i = 255; i > 1; i--)
{
new_count += hist[i];
percentage = new_count/count;
next_percentage = (new_count+hist[i-1])/count;
if(fabs (percentage - 0.006) < fabs (next_percentage - 0.006))
{
max = i-1;
break;
}
}
QColor c;
int range = max - min;
for(int j=0;j<height;j++){
for(int i=0;i<width;i++){
c = QColor(image.pixel(i,j));
result.setPixel(i,j,c.light(((c.lightness()-min)/range*1.0)*255).rgb());
}
}
return result;*/
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
return changeContrast(image,settings.value(CONTRAST,100).toInt());
}
//-----------------------------------------------------------------------------
// ContrastFilter
//-----------------------------------------------------------------------------
GammaFilter::GammaFilter(int l)
:level(l)
{
}
QImage GammaFilter::setFilter(const QImage & image)
{
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
return changeGamma(image,settings.value(GAMMA,100).toInt());
}
//-----------------------------------------------------------------------------
// PageRender
//-----------------------------------------------------------------------------
PageRender::PageRender()
:QThread()
{
}
PageRender::PageRender(int np, const QByteArray & rd, QImage * p,unsigned int d, QVector<ImageFilter *> f)
:QThread(),
numPage(np),
data(rd),
page(p),
degrees(d),
filters(f)
{
}
void PageRender::run()
{
QMutexLocker locker(&mutex);
QImage img;
img.loadFromData(data);
if(degrees > 0)
{
QMatrix m;
m.rotate(degrees);
img = img.transformed(m,Qt::SmoothTransformation);
}
for(int i=0;i<filters.size();i++)
{
img = filters[i]->setFilter(img);
}
*page = img;
emit pageReady(numPage);
}
//-----------------------------------------------------------------------------
// DoublePageRender
//-----------------------------------------------------------------------------
DoublePageRender::DoublePageRender(int np, const QByteArray & rd, const QByteArray & rd2, QImage * p,unsigned int d, QVector<ImageFilter *> f)
:PageRender(),
numPage(np),
data(rd),
data2(rd2),
page(p),
degrees(d),
filters(f)
{
}
void DoublePageRender::run()
{
//QImage result;
QMutexLocker locker(&mutex);
QImage img, img2;
if(!data.isEmpty())
img.loadFromData(data);
if(!data2.isEmpty())
img2.loadFromData(data2);
/*if(img.isNull())
img = QPixmap(img2.width(),img2.height());
if(img2.isNull())
img2 = QPixmap(img.width(),img.height());*/
int x,y;
x = img.width()+img2.width();
y = qMax(img.height(),img2.height());
QImage auxImg(x,y,QImage::Format_RGB32);
QPainter painter(&auxImg);
painter.drawImage(0,0,img);
painter.drawImage(img.width(),0,img2);
painter.end();
if(degrees > 0)
{
QMatrix m;
m.rotate(degrees);
auxImg = auxImg.transformed(m,Qt::SmoothTransformation);
}
for(int i=0;i<filters.size();i++)
{
auxImg = filters[i]->setFilter(auxImg);
}
*page = auxImg;
emit pageReady(numPage);
}
//-----------------------------------------------------------------------------
// Render
//-----------------------------------------------------------------------------
Render::Render()
:currentIndex(0),doublePage(false),comic(0),loadedComic(false),imageRotation(0),numLeftPages(NL),numRightPages(NR)
{
int size = numLeftPages+numRightPages+1;
currentPageBufferedIndex = numLeftPages;
for(int i = 0; i<size; i++)
{
buffer.push_back(new QImage());
pageRenders.push_back(0);
}
filters.push_back(new BrightnessFilter());
filters.push_back(new ContrastFilter());
filters.push_back(new GammaFilter());
}
//Este m<>todo se encarga de forzar el renderizado de las p<>ginas.
//Actualiza el buffer seg<65>n es necesario.
//si la pagina actual no est<73> renderizada, se lanza un hilo que la renderize (double or single page mode) y se emite una se<73>al que indica que se est<73> renderizando.
void Render::render()
{
updateBuffer();
if(buffer[currentPageBufferedIndex]->isNull())
{
if(pagesReady.size()>0)
{
if(doublePage)
{
if(pagesReady[currentIndex] && pagesReady[qMin(currentIndex+1,(int)comic->numPages()-1)])
if(currentIndex+1 > comic->numPages()-1)
pageRenders[currentPageBufferedIndex] = new DoublePageRender(currentIndex,comic->getRawData()->at(currentIndex),QByteArray(),buffer[currentPageBufferedIndex],imageRotation,filters);
else
pageRenders[currentPageBufferedIndex] = new DoublePageRender(currentIndex,comic->getRawData()->at(currentIndex),comic->getRawData()->at(currentIndex+1),buffer[currentPageBufferedIndex],imageRotation,filters);
else
//las p<>ginas no est<73>n listas, y se est<73>n cargando en el c<>mic
emit processingPage(); //para evitar confusiones esta se<73>al deber<65>a llamarse de otra forma
}
else
if(pagesReady[currentIndex])
pageRenders[currentPageBufferedIndex] = new PageRender(currentIndex,comic->getRawData()->at(currentIndex),buffer[currentPageBufferedIndex],imageRotation,filters);
else
//las p<>ginas no est<73>n listas, y se est<73>n cargando en el c<>mic
emit processingPage(); //para evitar confusiones esta se<73>al deber<65>a llamarse de otra forma
//si se ha creado un hilo para renderizar la p<>gina actual, se arranca
if(pageRenders[currentPageBufferedIndex]!=0)
{
//se conecta la se<73>al pageReady del hilo, con el SLOT prepareAvailablePage
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
//se emite la se<73>al de procesando, debido a que los hilos se arrancan aqu<71>
if(doublePage || filters.size()>0)
emit processingPage();
pageRenders[currentPageBufferedIndex]->start();
pageRenders[currentPageBufferedIndex]->setPriority(QThread::TimeCriticalPriority);
}
else
//en qu<71> caso ser<65>a necesario hacer esto??? //TODO: IMPORTANTE, puede que no sea necesario.
emit processingPage();
}
else
//no hay ninguna p<>gina lista para ser renderizada, es necesario esperar.
emit processingPage();
}
else
// la p<>gina actual est<73> lista
emit currentPageReady();
//se renderizan las p<>ginas restantes para llenar el buffer.
if(doublePage)
fillBufferDoublePage();
else
fillBuffer();
}
QPixmap * Render::getCurrentPage()
{
QPixmap * page = new QPixmap();
*page = page->fromImage(*buffer[currentPageBufferedIndex]);
return page;
}
void Render::setRotation(int degrees)
{
}
void Render::setComic(Comic * c)
{
if(comic !=0)
{
comic->moveToThread(QApplication::instance()->thread());
comic->disconnect();
comic->deleteLater();
}
comic = c;
}
void Render::prepareAvailablePage(int page)
{
if(currentIndex == page)
emit currentPageReady();
}
void Render::update()
{
render();
}
//-----------------------------------------------------------------------------
// Comic interface
//-----------------------------------------------------------------------------
void Render::load(const QString & path)
{
if(comic!=0)
{
comic->moveToThread(QApplication::instance()->thread());
comic->disconnect();
comic->deleteLater();
}
//comic->moveToThread(QApplication::instance()->thread());
comic = FactoryComic::newComic(path);
if(comic == NULL)//archivo no encontrado o no v<>lido
{
emit errorOpening();
reset();
return;
}
previousIndex = currentIndex = 0;
connect(comic,SIGNAL(errorOpening()),this,SIGNAL(errorOpening()));
connect(comic,SIGNAL(errorOpening()),this,SLOT(reset()));
connect(comic,SIGNAL(imageLoaded(int)),this,SIGNAL(imageLoaded(int)));
connect(comic,SIGNAL(imageLoaded(int)),this,SLOT(pageRawDataReady(int)));
//connect(comic,SIGNAL(pageChanged(int)),this,SIGNAL(pageChanged(int)));
connect(comic,SIGNAL(numPages(unsigned int)),this,SIGNAL(numPages(unsigned int)));
connect(comic,SIGNAL(numPages(unsigned int)),this,SLOT(setNumPages(unsigned int)));
connect(comic,SIGNAL(imageLoaded(int,QByteArray)),this,SIGNAL(imageLoaded(int,QByteArray)));
connect(comic,SIGNAL(isBookmark(bool)),this,SIGNAL(currentPageIsBookmark(bool)));
connect(comic,SIGNAL(isBookmark(bool)),this,SLOT(pageIsBookmark(bool)));
connect(comic,SIGNAL(bookmarksUpdated()),this,SIGNAL(bookmarksUpdated()));
connect(comic,SIGNAL(isLast()),this,SIGNAL(isLast()));
connect(comic,SIGNAL(isCover()),this,SIGNAL(isCover()));
QThread * thread = NULL;
if (typeid(*comic) != typeid(FileComic))
{
thread = new QThread();
comic->moveToThread(thread);
connect(thread, SIGNAL(started()), comic, SLOT(process()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
}
pagesReady.clear();
comic->load(path); //garantiza que se va a intentar abrir el c<>mic
if(thread != NULL)
thread->start();
invalidate();
loadedComic = true;
update();
}
void Render::reset()
{
loadedComic = false;
invalidate();
}
//si se solicita la siguiente p<>gina, se calcula cu<63>l debe ser en funci<63>n de si se lee en modo a doble p<>gina o no.
//la p<>gina s<>lo se renderiza, si realmente ha cambiado.
void Render::nextPage()
{
int nextPage; //indica cu<63>l ser<65> la pr<70>xima p<>gina
if(doublePage)
{
nextPage = currentIndex;
if(currentIndex+2<comic->numPages())
{
nextPage = currentIndex+2;
if(currentIndex != nextPage)
comic->setIndex(nextPage);
}
}
else
{
nextPage = comic->nextPage();
}
//se fuerza renderizado si la p<>gina ha cambiado
if(currentIndex != nextPage)
{
previousIndex = currentIndex;
currentIndex = nextPage;
update();
}
else
emit isLast();
}
//si se solicita la p<>gina anterior, se calcula cu<63>l debe ser en funci<63>n de si se lee en modo a doble p<>gina o no.
//la p<>gina s<>lo se renderiza, si realmente ha cambiado.
void Render::previousPage()
{
int previousPage; //indica cu<63>l ser<65> la pr<70>xima p<>gina
if(doublePage)
{
if(currentIndex == 1)
invalidate();
previousPage = qMax(currentIndex-2,0);
if(currentIndex != previousPage)
{
comic->setIndex(previousPage);
}
}
else
{
previousPage = comic->previousPage();
}
//se fuerza renderizado si la p<>gina ha cambiado
if(currentIndex != previousPage)
{
previousIndex = currentIndex;
currentIndex = previousPage;
update();
}
else
emit isCover();
}
unsigned int Render::getIndex()
{
return comic->getIndex();
}
unsigned int Render::numPages()
{
return comic->numPages();
}
bool Render::hasLoadedComic()
{
if(comic!=0)
return comic->loaded();
return false;
}
void Render::setNumPages(unsigned int numPages)
{
pagesReady.fill(false,numPages);
}
void Render::pageRawDataReady(int page)
{
pagesEmited.push_back(page);
if(pageRenders.size()>0)
{
for(int i=0;i<pagesEmited.size();i++)
{
pagesReady[pagesEmited.at(i)] = true;
if(pagesEmited.at(i) == currentIndex)
update();
if(doublePage)
{
if(pagesEmited.at(i)==currentIndex+1)
update();
if ( ((pagesEmited.at(i) < currentIndex) && (pagesEmited.at(i) > currentIndex-2*numLeftPages)) ||
((pagesEmited.at(i) > currentIndex+1) && (pagesEmited.at(i) < currentIndex+1+2*numRightPages)) )
{
fillBufferDoublePage();
}
}
else
{
if ( ((pagesEmited.at(i) < currentIndex) && (pagesEmited.at(i) > currentIndex-numLeftPages)) ||
((pagesEmited.at(i) > currentIndex) && (pagesEmited.at(i) < currentIndex+numRightPages)) )
{
fillBuffer();
}
}
}
pagesEmited.clear();
}
}
//s<>lo se renderiza la p<>gina, si ha habido un cambio de p<>gina
void Render::goTo(int index)
{
if(currentIndex != index)
{
comic->setIndex(index);
previousIndex = currentIndex;
currentIndex = index;
//si cambia la paridad de las p<>gina en modo a doble p<>gina, se rellena el buffer.
//esto solo deber<65>a orcurrir al llegar al principio o al final
if(doublePage && ((previousIndex - index) % 2)!=0)
invalidate();
update();
}
}
void Render::rotateRight()
{
imageRotation = (imageRotation+90) % 360;
reload();
}
void Render::rotateLeft()
{
if(imageRotation == 0)
imageRotation = 270;
else
imageRotation = imageRotation - 90;
reload();
}
//Actualiza el buffer, a<>adiendo las im<69>genes (vac<61>as) necesarias para su posterior renderizado y
//eliminado aquellas que ya no sean necesarias. Tambi<62>n libera los hilos (no estoy seguro de que sea responsabilidad suya)
//Calcula el n<>mero de nuevas p<>ginas que hay que buferear y si debe hacerlo por la izquierda o la derecha (seg<65>n sea el sentido de la lectura)
void Render::updateBuffer()
{
QMutexLocker locker(&mutex);
int windowSize = currentIndex - previousIndex;
if(doublePage)
{
windowSize = windowSize/2;
if(currentIndex == 0 && windowSize == 0 && previousIndex == 1)
windowSize = -1;
}
if(windowSize > 0)//add pages to right pages and remove on the left
{
windowSize = qMin(windowSize,buffer.size());
for(int i = 0; i < windowSize; i++)
{
//renders
PageRender * pr = pageRenders.front();
pageRenders.pop_front();
if(pr !=0)
{
if(pr->wait())
delete pr;
}
pageRenders.push_back(0);
//images
if(buffer.front()!=0)
delete buffer.front();
buffer.pop_front();
buffer.push_back(new QImage());
}
}
else //add pages to left pages and remove on the right
if(windowSize<0)
{
windowSize = -windowSize;
windowSize = qMin(windowSize,buffer.size());
for(int i = 0; i < windowSize; i++)
{
//renders
PageRender * pr = pageRenders.back();
pageRenders.pop_back();
if(pr !=0)
{
if(pr->wait())
delete pr;
}
pageRenders.push_front(0);
//images
buffer.push_front(new QImage());
QImage * p = buffer.back();
if(p!=0)
delete p;
buffer.pop_back();
}
}
previousIndex = currentIndex;
}
void Render::fillBuffer()
{
for(int i = 1; i <= qMax(numLeftPages,numRightPages); i++)
{
if ((currentIndex+i < comic->numPages()) &&
buffer[currentPageBufferedIndex+i]->isNull() &&
i <= numRightPages &&
pageRenders[currentPageBufferedIndex+i]==0 &&
pagesReady[currentIndex+1]) //preload next pages
{
pageRenders[currentPageBufferedIndex+i] = new PageRender(currentIndex+i,comic->getRawData()->at(currentIndex+i),buffer[currentPageBufferedIndex+i],imageRotation,filters);
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
pageRenders[currentPageBufferedIndex+i]->start();
}
if ((currentIndex-i > 0) &&
buffer[currentPageBufferedIndex-i]->isNull() &&
i <= numLeftPages &&
pageRenders[currentPageBufferedIndex-i]==0 &&
pagesReady[currentIndex-1]) //preload previous pages
{
pageRenders[currentPageBufferedIndex-i] = new PageRender(currentIndex-i,comic->getRawData()->at(currentIndex-i),buffer[currentPageBufferedIndex-i],imageRotation,filters);
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
pageRenders[currentPageBufferedIndex-i]->start();
}
}
}
void Render::fillBufferDoublePage()
{
for(int i = 1; i <= qMax(numLeftPages,numRightPages); i++)
{
if ((currentIndex+2*i < comic->numPages()) &&
buffer[currentPageBufferedIndex+i]->isNull() &&
i <= numRightPages &&
pageRenders[currentPageBufferedIndex+i]==0 &&
(pagesReady[currentIndex+2*i] && pagesReady[qMin(currentIndex+(2*i)+1,(int)comic->numPages()-1)])) //preload next pages
{
if(currentIndex+(2*i)+1 > comic->numPages()-1)
pageRenders[currentPageBufferedIndex+i] = new DoublePageRender(currentIndex+2*i,comic->getRawData()->at(currentIndex+(2*i)),QByteArray(),buffer[currentPageBufferedIndex+i],imageRotation,filters);
else
pageRenders[currentPageBufferedIndex+i] = new DoublePageRender(currentIndex+2*i,comic->getRawData()->at(currentIndex+(2*i)),comic->getRawData()->at(currentIndex+(2*i)+1),buffer[currentPageBufferedIndex+i],imageRotation,filters);
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
pageRenders[currentPageBufferedIndex+i]->start();
}
if ((currentIndex-2*i >= -1) &&
buffer[currentPageBufferedIndex-i]->isNull() &&
i <= numLeftPages &&
pageRenders[currentPageBufferedIndex-i]==0 &&
(pagesReady[qMax(currentIndex-2*i,0)] && pagesReady[qMin(currentIndex-(2*i)+1,(int)comic->numPages()-1)])) //preload previous pages
{
if(currentIndex-2*i == -1)
pageRenders[currentPageBufferedIndex-i] = new DoublePageRender(0,QByteArray(),comic->getRawData()->at(0),buffer[currentPageBufferedIndex-i],imageRotation,filters);
else
pageRenders[currentPageBufferedIndex-i] = new DoublePageRender(currentIndex-2*i,comic->getRawData()->at(currentIndex-(2*i)),comic->getRawData()->at(currentIndex-(2*i)+1),buffer[currentPageBufferedIndex-i],imageRotation,filters);
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
pageRenders[currentPageBufferedIndex-i]->start();
}
}
}
//M<>todo que debe ser llamado cada vez que la estructura del buffer se vuelve inconsistente con el modo de lectura actual.
//se terminan todos los hilos en ejecuci<63>n y se libera la memoria (de hilos e im<69>genes)
void Render::invalidate()
{
for(int i=0;i<pageRenders.size();i++)
{
if(pageRenders[i]!=0)
{
pageRenders[i]->wait();
delete pageRenders[i];
pageRenders[i] = 0;
}
}
for(int i=0;i<buffer.size();i++)
{
delete buffer[i];
buffer[i] = new QImage();
}
}
void Render::doublePageSwitch()
{
doublePage = !doublePage;
if(comic)
{
invalidate();
update();
}
}
QString Render::getCurrentPagesInformation()
{
QString s = QString::number(currentIndex+1);
if (doublePage && (currentIndex+1 < comic->numPages()))
s += "-"+QString::number(currentIndex+2);
s += "/"+QString::number(comic->numPages());
return s;
}
void Render::setBookmark()
{
comic->setBookmark();
}
void Render::removeBookmark()
{
comic->removeBookmark();
}
void Render::save()
{
comic->saveBookmarks();
}
Bookmarks * Render::getBookmarks()
{
return comic->bm;
}
void Render::reload()
{
if(comic)
{
invalidate();
update();
}
}

192
YACReader/render.h Normal file
View File

@ -0,0 +1,192 @@
#ifndef RENDER_H
#define RENDER_H
#include <QImage>
#include <QPixmap>
#include <QPainter>
#include <QThread>
#include <QByteArray>
#include <QVector>
#include "comic.h"
//-----------------------------------------------------------------------------
// FILTERS
//-----------------------------------------------------------------------------
#include <QThread>
class Comic;
class ImageFilter {
public:
ImageFilter(){};
virtual QImage setFilter(const QImage & image) = 0;
};
class MeanNoiseReductionFilter : public ImageFilter {
public:
enum NeighborghoodSize{SMALL=9, LARGE=25 };
MeanNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
virtual QImage setFilter(const QImage & image);
private:
enum NeighborghoodSize neighborghoodSize;
};
class MedianNoiseReductionFilter : public ImageFilter {
public:
enum NeighborghoodSize{SMALL=9, LARGE=25 };
MedianNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
virtual QImage setFilter(const QImage & image);
private:
enum NeighborghoodSize neighborghoodSize;
};
class BrightnessFilter : public ImageFilter {
public:
BrightnessFilter(int l=150);
virtual QImage setFilter(const QImage & image);
private:
int level;
};
class ContrastFilter : public ImageFilter {
public:
ContrastFilter(int l=150);
virtual QImage setFilter(const QImage & image);
private:
int level;
};
class GammaFilter : public ImageFilter {
public:
GammaFilter(int l=150);
virtual QImage setFilter(const QImage & image);
private:
int level;
};
//-----------------------------------------------------------------------------
// RENDER
//-----------------------------------------------------------------------------
class PageRender : public QThread
{
Q_OBJECT
public:
PageRender();
PageRender(int numPage, const QByteArray & rawData, QImage * page,unsigned int degrees=0, QVector<ImageFilter *> filters = QVector<ImageFilter *>());
int getNumPage(){return numPage;};
void setData(const QByteArray & rawData){data = rawData;};
void setPage(QImage * p){page = p;};
void setRotation(unsigned int d){degrees = d;};
void setFilters(QVector<ImageFilter *> f){filters = f;};
private:
int numPage;
QByteArray data;
QImage * page;
unsigned int degrees;
QVector<ImageFilter *> filters;
void run();
signals:
void pageReady(int);
};
//-----------------------------------------------------------------------------
// RENDER
//-----------------------------------------------------------------------------
class DoublePageRender : public PageRender
{
Q_OBJECT
public:
DoublePageRender(int firstPage, const QByteArray & firstPageData,const QByteArray & secondPageData, QImage * page,unsigned int degrees=0, QVector<ImageFilter *> filters = QVector<ImageFilter *>());
private:
int numPage;
QByteArray data;
QByteArray data2;
QImage * page;
unsigned int degrees;
QVector<ImageFilter *> filters;
void run();
signals:
void pageReady(int);
};
class Render : public QObject {
Q_OBJECT
public:
Render();
public slots:
void render();
QPixmap * getCurrentPage();
void goTo(int index);
void doublePageSwitch();
void setRotation(int degrees);
void setComic(Comic * c);
void prepareAvailablePage(int page);
void update();
void setNumPages(unsigned int numPages);
void pageRawDataReady(int page);
//--comic interface
void nextPage();
void previousPage();
void load(const QString & path);
void rotateRight();
void rotateLeft();
unsigned int getIndex();
unsigned int numPages();
bool hasLoadedComic();
void updateBuffer();
void fillBuffer();
void fillBufferDoublePage();
void invalidate();
QString getCurrentPagesInformation();
void setBookmark();
void removeBookmark();
void save();
void reset();
void reload();
Bookmarks * getBookmarks();
signals:
void currentPageReady();
void processingPage();
void imagesLoaded();
void imageLoaded(int index);
void imageLoaded(int index,const QByteArray & image);
void pageChanged(int index);
void numPages(unsigned int numPages);
void errorOpening();
void currentPageIsBookmark(bool);
void isLast();
void isCover();
void bookmarksUpdated();
private:
Comic * comic;
bool doublePage;
int previousIndex;
int currentIndex;
//QPixmap * currentPage;
int currentPageBufferedIndex;
int numLeftPages;
int numRightPages;
QList<PageRender *> pageRenders;
QList<QImage *> buffer;
void loadAll();
void updateRightPages();
void updateLeftPages();
bool loadedComic;
QList<int> pagesEmited;
QVector<bool> pagesReady;
int imageRotation;
QVector<ImageFilter *> filters;
};
#endif // RENDER_H

View File

@ -0,0 +1,67 @@
#include "shortcuts_dialog.h"
#include <QVBoxLayout>
#include <QPushButton>
#include <QTextEdit>
#include <QLabel>
#include <QPixmap>
#include <QFile>
#include <QTextStream>
#include <QTextCodec>
ShortcutsDialog::ShortcutsDialog(QWidget * parent)
:QDialog(parent)//,Qt::FramelessWindowHint)
{
setModal(true);
setWindowIcon(QIcon(":/images/shortcuts.png"));
setWindowTitle(tr("YACReader keyboard shortcuts"));
QVBoxLayout * mainLayout = new QVBoxLayout;
close = new QPushButton(tr("Close"));
connect(close,SIGNAL(clicked()),this,SLOT(close()));
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(close);
QHBoxLayout * shortcutsLayout = new QHBoxLayout;
shortcuts = new QTextEdit();
shortcuts->setFrameStyle(QFrame::NoFrame);
//"<p><b>General functions:</b><hr/><b>O</b> : Open comic<br/><b>Esc</b> : Exit</p>"
shortcuts->setReadOnly(true);
shortcutsLayout->addWidget(shortcuts);
//shortcutsLayout->addWidget(shortcuts2);
shortcutsLayout->setSpacing(0);
mainLayout->addLayout(shortcutsLayout);
mainLayout->addLayout(bottomLayout);
QHBoxLayout *imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel();
QPixmap p(":/images/shortcuts.png");
imgLabel->setPixmap(p);
QVBoxLayout * imgLayout = new QVBoxLayout;
imgLayout->addWidget(imgLabel);
imgLayout->addStretch();
imgMainLayout->addLayout(imgLayout);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setFixedSize(QSize(700,500));
QFile f(":/files/shortcuts.html");
f.open(QIODevice::ReadOnly);
QTextStream txtS(&f);
txtS.setCodec(QTextCodec::codecForName("UTF-8"));
QString content = txtS.readAll();
f.close();
shortcuts->setHtml(content);
setWindowTitle(tr("Keyboard Shortcuts"));
}

View File

@ -0,0 +1,19 @@
#ifndef SHORTCUTS_DIALOG_H
#define SHORTCUTS_DIALOG_H
#include <QDialog>
#include <QTextEdit>
#include <QPushButton>
class ShortcutsDialog : public QDialog
{
Q_OBJECT
public:
ShortcutsDialog(QWidget * parent = 0);
private:
QTextEdit * shortcuts;
QPushButton * close;
public slots:
};
#endif // SHORTCUTS_DIALOG_H

90
YACReader/translator.cpp Normal file
View File

@ -0,0 +1,90 @@
#include <QUrl>
#include <Phonon/MediaObject>
#include <Phonon/MediaSource>
#include <QPushButton>
#include <QPalette>
#include <QMouseEvent>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QWebView>
#include <QFile>
#include <QPoint>
#include <QWidget>
#include <QTextCodec>
#include "translator.h"
YACReaderTranslator::YACReaderTranslator(QWidget * parent)
:QWidget(parent)
{
this->setCursor(QCursor(Qt::ArrowCursor));
this->setAutoFillBackground(true);
this->setBackgroundRole(QPalette::Window);
QPalette p(this->palette());
p.setColor(QPalette::Window, QColor(96,96,96));
this->setPalette(p);
QVBoxLayout *layout = new QVBoxLayout(this);
QWebView * view = new QWebView();
QFile f(":/files/translator.html");
f.open(QIODevice::ReadOnly);
QTextStream txtS(&f);
txtS.setCodec(QTextCodec::codecForName("UTF-8"));
QString contentHTML = txtS.readAll();
view->setHtml(contentHTML);
view->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
connect(view->page(),SIGNAL(linkClicked(QUrl)),this,SLOT(play(QUrl)));
QHBoxLayout * buttonBar = new QHBoxLayout();
QPushButton * close = new QPushButton(QIcon(QPixmap(":/images/close.png")),"");
close->setFlat(true);
buttonBar->addStretch();
close->resize(18,18);
buttonBar->addWidget(close);
buttonBar->setMargin(0);
connect(close,SIGNAL(clicked()),this->parent(),SLOT(animateHideTranslator()));
layout->setMargin(0);
layout->setSpacing(0);
layout->addLayout(buttonBar);
layout->addWidget(view);
resize(view->size().width()/1.60,view->size().height());
music = createPlayer(MusicCategory);
show();
}
void YACReaderTranslator::play(const QUrl & url)
{
MediaSource src(url);
src.setAutoDelete(true);
music->setCurrentSource(src);
music->play();
}
YACReaderTranslator::~YACReaderTranslator()
{
delete music;
}
void YACReaderTranslator::mousePressEvent(QMouseEvent *event)
{
drag = true;
click = event->pos();
}
void YACReaderTranslator::mouseReleaseEvent(QMouseEvent *event)
{
drag = false;
}
void YACReaderTranslator::mouseMoveEvent(QMouseEvent * event)
{
if(drag)
this->move(QPoint(mapToParent(event->pos())-click));
}

32
YACReader/translator.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef __TRANSLATOR_H
#define __TRANSLATOR_H
class QUrl;
class QMouseEvent;
class QPoint;
#include<QWidget>
#include<Phonon/MediaObject>
using namespace Phonon;
class YACReaderTranslator : public QWidget
{
Q_OBJECT
public:
YACReaderTranslator(QWidget * parent = 0);
~YACReaderTranslator();
public slots:
void play(const QUrl & url);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent ( QMouseEvent * event );
bool drag;
QPoint click;
private:
MediaObject * music;
};
#endif

782
YACReader/viewer.cpp Normal file
View File

@ -0,0 +1,782 @@
#include "viewer.h"
#include "magnifying_glass.h"
#include "configuration.h"
#include "magnifying_glass.h"
#include "goto_flow.h"
#include "goto_flow_gl.h"
#include "bookmarks_dialog.h"
#include "render.h"
#include "goto_dialog.h"
#include "translator.h"
#include "onstart_flow_selection_dialog.h"
#include "page_label_widget.h"
#include "notifications_label_widget.h"
#include <QWebView>
#include <QFile>
#define STEPS 22
Viewer::Viewer(QWidget * parent)
:QScrollArea(parent),
currentPage(0),
magnifyingGlassShowed(false),
fullscreen(false),
information(false),
adjustToWidthRatio(1),
doublePage(false),
wheelStop(false),
direction(1),
restoreMagnifyingGlass(false),
drag(false)
{
translator = new YACReaderTranslator(this);
translator->hide();
translatorAnimation = new QPropertyAnimation(translator,"pos");
translatorAnimation->setDuration(150);
translatorXPos = -10000;
translator->move(-translator->width(),10);
//current comic page
content = new QLabel(this);
configureContent(tr("Press 'O' to open comic."));
//scroll area configuration
setBackgroundRole(QPalette::Dark);
setWidget(content);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFrameStyle(QFrame::NoFrame);
setAlignment(Qt::AlignCenter);
QPalette palette;
palette.setColor(backgroundRole(), Configuration::getConfiguration().getBackgroundColor());
setPalette(palette);
//---------------------------------------
mglass = new MagnifyingGlass(Configuration::getConfiguration().getMagnifyingGlassSize(),this);
mglass->hide();
content->setMouseTracking(true);
setMouseTracking(true);
showCursor();
goToDialog = new GoToDialog(this);
QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
//CONFIG GOTO_FLOW--------------------------------------------------------
if(QGLFormat::hasOpenGL() && !settings->contains(USE_OPEN_GL))
{
OnStartFlowSelectionDialog * flowSelDialog = new OnStartFlowSelectionDialog();
flowSelDialog->exec();
if(flowSelDialog->result() == QDialog::Accepted)
settings->setValue(USE_OPEN_GL,2);
else
settings->setValue(USE_OPEN_GL,0);
delete flowSelDialog;
}
if(QGLFormat::hasOpenGL() && (settings->value(USE_OPEN_GL).toBool() == true))
goToFlow = new GoToFlowGL(this,Configuration::getConfiguration().getFlowType());
else
goToFlow = new GoToFlow(this,Configuration::getConfiguration().getFlowType());
goToFlow->hide();
showGoToFlowAnimation = new QPropertyAnimation(goToFlow,"pos");
showGoToFlowAnimation->setDuration(150);
bd = new BookmarksDialog(this->parentWidget());
render = new Render();
hideCursorTimer = new QTimer();
hideCursorTimer->setSingleShot(true);
if(Configuration::getConfiguration().getDoublePage())
doublePageSwitch();
createConnections();
hideCursorTimer->start(2500);
setMouseTracking(true);
//animations
verticalScroller = new QPropertyAnimation(verticalScrollBar(), "sliderPosition");
connect(verticalScroller,SIGNAL(valueChanged (const QVariant &)),this,SIGNAL(backgroundChanges()));
notificationsLabel = new NotificationsLabelWidget(this);
notificationsLabel->hide();
informationLabel = new PageLabelWidget(this);
}
void Viewer::createConnections()
{
//magnifyingGlass (update mg after a background change
connect(this,SIGNAL(backgroundChanges()),mglass,SLOT(updateImage()));
//goToDialog
connect(goToDialog,SIGNAL(goToPage(unsigned int)),this,SLOT(goTo(unsigned int)));
//goToFlow goTo
connect(goToFlow,SIGNAL(goToPage(unsigned int)),this,SLOT(goTo(unsigned int)));
//current time
QTimer * t = new QTimer();
connect(t,SIGNAL(timeout()),this,SLOT(updateInformation()));
t->start(1000);
//hide cursor
connect(hideCursorTimer,SIGNAL(timeout()),this,SLOT(hideCursor()));
//bookmarks
connect(bd,SIGNAL(goToPage(unsigned int)),this,SLOT(goTo(unsigned int)));
//render
connect(render,SIGNAL(errorOpening()),this,SLOT(resetContent()));
connect(render,SIGNAL(errorOpening()),this,SLOT(showMessageErrorOpening()));
connect(render,SIGNAL(numPages(unsigned int)),goToFlow,SLOT(setNumSlides(unsigned int)));
connect(render,SIGNAL(numPages(unsigned int)),goToDialog,SLOT(setNumPages(unsigned int)));
connect(render,SIGNAL(imageLoaded(int,QByteArray)),goToFlow,SLOT(setImageReady(int,QByteArray)));
connect(render,SIGNAL(currentPageReady()),this,SLOT(updatePage()));
connect(render,SIGNAL(processingPage()),this,SLOT(setLoadingMessage()));
connect(render,SIGNAL(currentPageIsBookmark(bool)),this,SIGNAL(pageIsBookmark(bool)));
//connect(render,SIGNAL(bookmarksLoaded(Bookmarks)),this,SLOT(setBookmarks(Bookmarks)));
connect(render,SIGNAL(isLast()),this,SLOT(showIsLastMessage()));
connect(render,SIGNAL(isCover()),this,SLOT(showIsCoverMessage()));
connect(render,SIGNAL(bookmarksUpdated()),this,SLOT(setBookmarks()));
}
void Viewer::open(QString pathFile)
{
if(render->hasLoadedComic())
save();
//bd->setBookmarks(*bm);
goToFlow->reset();
render->load(pathFile);
//render->update();
verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
if(Configuration::getConfiguration().getShowInformation() && !information)
{
QTimer * timer = new QTimer();
connect(timer,SIGNAL(timeout()),this,SLOT(informationSwitch()));
connect(timer,SIGNAL(timeout()),timer,SLOT(deleteLater()));
timer->start();
}
informationLabel->setText("...");
setAcceptDrops(true);
}
void Viewer::showMessageErrorOpening()
{
QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found"));
}
void Viewer::next()
{
direction = 1;
render->nextPage();
updateInformation();
}
void Viewer::prev()
{
direction = -1;
render->previousPage();
updateInformation();
}
void Viewer::showGoToDialog()
{
goToDialog->show();
}
void Viewer::goTo(unsigned int page)
{
direction = 1; //in "go to" direction is always fordward
render->goTo(page);
}
void Viewer::updatePage()
{
QPixmap * previousPage = currentPage;
currentPage = render->getCurrentPage();
content->setPixmap(*currentPage);
updateContentSize();
updateVerticalScrollBar();
emit backgroundChanges();
emit(pageAvailable(true));
//TODO -> update bookmark action
setFocus(Qt::ShortcutFocusReason);
delete previousPage;
if(restoreMagnifyingGlass)
{
restoreMagnifyingGlass = false;
showMagnifyingGlass();
}
}
void Viewer::updateContentSize()
{
//there is an image to resize
if(currentPage !=0 && !currentPage->isNull())
{
if(Configuration::getConfiguration().getAdjustToFullSize())
{
content->resize(currentPage->width(),currentPage->height());
}
else
{
float aspectRatio = (float)currentPage->width()/currentPage->height();
//Fit to width
if(Configuration::getConfiguration().getAdjustToWidth())
{
adjustToWidthRatio = Configuration::getConfiguration().getFitToWidthRatio();
if(static_cast<int>(width()*adjustToWidthRatio/aspectRatio)<height())
if(static_cast<int>(height()*aspectRatio)>width())
content->resize(width(),static_cast<int>(width()/aspectRatio));
else
content->resize(static_cast<int>(height()*aspectRatio),height());
else
content->resize(width()*adjustToWidthRatio,static_cast<int>(width()*adjustToWidthRatio/aspectRatio));
}
//Fit to height or fullsize/custom size
else
{
if(static_cast<int>(height()*aspectRatio)>width()) //page width exceeds window width
content->resize(width(),static_cast<int>(width()/aspectRatio));
else
content->resize(static_cast<int>(height()*aspectRatio),height());
}
}
emit backgroundChanges();
}
content->update(); //TODO, it shouldn't be neccesary
}
void Viewer::updateVerticalScrollBar()
{
if(direction > 0)
verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
else
verticalScrollBar()->setSliderPosition(verticalScrollBar()->maximum());
}
void Viewer::scrollDown()
{
if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum())
{
next();
}
else
{
int currentPos = verticalScrollBar()->sliderPosition();
verticalScroller->setDuration(250);
verticalScroller->setStartValue(currentPos);
verticalScroller->setEndValue(nextPos);
verticalScroller->start();
emit backgroundChanges();
}
}
void Viewer::scrollUp()
{
if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum())
{
prev();
}
else
{
int currentPos = verticalScrollBar()->sliderPosition();
verticalScroller->setDuration(250);
verticalScroller->setStartValue(currentPos);
verticalScroller->setEndValue(nextPos);
verticalScroller->start();
emit backgroundChanges();
}
}
void Viewer::keyPressEvent(QKeyEvent *event)
{
if(render->hasLoadedComic())
{
if(goToFlow->isVisible() && event->key()!=Qt::Key_S)
QCoreApplication::sendEvent(goToFlow,event);
else
switch (event->key())
{
case Qt::Key_Space:
posByStep = height()/STEPS;
nextPos=verticalScrollBar()->sliderPosition()+static_cast<int>((height()*0.80));
scrollDown();
break;
case Qt::Key_B:
posByStep = height()/STEPS;
nextPos=verticalScrollBar()->sliderPosition()-static_cast<int>((height()*0.80));
scrollUp();
break;
case Qt::Key_S:
goToFlowSwitch();
break;
case Qt::Key_T:
translatorSwitch();
break;
case Qt::Key_Down:
/*if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum())
next();
else*/
QAbstractScrollArea::keyPressEvent(event);
emit backgroundChanges();
break;
case Qt::Key_Up:
/*if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum())
prev();
else*/
QAbstractScrollArea::keyPressEvent(event);
emit backgroundChanges();
break;
case Qt::Key_Home:
goTo(0);
break;
case Qt::Key_End:
goTo(this->render->numPages()-1);
break;
default:
QAbstractScrollArea::keyPressEvent(event);
break;
}
if(mglass->isVisible())
switch(event->key())
{
case Qt::Key_Plus: case Qt::Key_Minus: case Qt::Key_Underscore: case Qt::Key_Asterisk:
QCoreApplication::sendEvent(mglass,event);
}
}
}
void Viewer::wheelEvent(QWheelEvent * event)
{
if(render->hasLoadedComic())
{
if((event->delta()<0)&&(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum()))
{
if(wheelStop)
{
next();
verticalScroller->stop();
event->accept();
wheelStop = false;
return;
}
else
wheelStop = true;
}
else
{
if((event->delta()>0)&&(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum()))
{
if(wheelStop)
{
prev();
verticalScroller->stop();
event->accept();
wheelStop = false;
return;
}
else
wheelStop = true;
}
}
int deltaNotFinished = 0;
if(verticalScroller->state() == QAbstractAnimation::Running)
{
deltaNotFinished = verticalScroller->startValue().toInt() - verticalScroller->endValue().toInt();
verticalScroller->stop();
}
int currentPos = verticalScrollBar()->sliderPosition();
verticalScroller->setDuration(250);
verticalScroller->setStartValue(currentPos);
verticalScroller->setEndValue(currentPos - event->delta() - deltaNotFinished);
verticalScroller->start();
//QAbstractScrollArea::wheelEvent(event);
}
}
void Viewer::resizeEvent(QResizeEvent * event)
{
updateContentSize();
goToFlow->move(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height()));
informationLabel->updatePosition();
QScrollArea::resizeEvent(event);
}
void Viewer::mouseMoveEvent(QMouseEvent * event)
{
showCursor();
hideCursorTimer->start(2500);
if(magnifyingGlassShowed)
mglass->move(static_cast<int>(event->x()-float(mglass->width())/2),static_cast<int>(event->y()-float(mglass->height())/2));
if(render->hasLoadedComic())
{
if(showGoToFlowAnimation->state()!=QPropertyAnimation::Running)
{
if(goToFlow->isVisible())
{
animateHideGoToFlow();
//goToFlow->hide();
}
else
{
int umbral = (width()-goToFlow->width())/2;
if((event->y()>height()-15)&&(event->x()>umbral)&&(event->x()<width()-umbral))
{
animateShowGoToFlow();
hideCursorTimer->stop();
}
}
}
if(drag)
{
int currentPosY = verticalScrollBar()->sliderPosition();
int currentPosX = horizontalScrollBar()->sliderPosition();
verticalScrollBar()->setSliderPosition(currentPosY=currentPosY+(yDragOrigin-event->y()));
horizontalScrollBar()->setSliderPosition(currentPosX=currentPosX+(xDragOrigin-event->x()));
yDragOrigin = event->y();
xDragOrigin = event->x();
}
}
}
const QPixmap * Viewer::pixmap()
{
return content->pixmap();
}
void Viewer::magnifyingGlassSwitch()
{
magnifyingGlassShowed?hideMagnifyingGlass():showMagnifyingGlass();
}
void Viewer::showMagnifyingGlass()
{
if(render->hasLoadedComic())
{
QPoint p = QPoint(cursor().pos().x(),cursor().pos().y());
p = this->parentWidget()->mapFromGlobal(p);
mglass->move(static_cast<int>(p.x()-float(mglass->width())/2)
,static_cast<int>(p.y()-float(mglass->height())/2));
mglass->show();
mglass->updateImage(mglass->x()+mglass->width()/2,mglass->y()+mglass->height()/2);
magnifyingGlassShowed = true;
}
}
void Viewer::hideMagnifyingGlass()
{
mglass->hide();
magnifyingGlassShowed = false;
}
void Viewer::informationSwitch()
{
information?informationLabel->hide():informationLabel->show();
//informationLabel->move(QPoint((width()-informationLabel->width())/2,0));
information=!information;
Configuration::getConfiguration().setShowInformation(information);
//TODO it shouldn't be neccesary
informationLabel->adjustSize();
informationLabel->update();
}
void Viewer::updateInformation()
{
if(render->hasLoadedComic())
{
informationLabel->setText(render->getCurrentPagesInformation()+" - "+QTime::currentTime().toString("HH:mm"));
informationLabel->adjustSize();
informationLabel->update(); //TODO it shouldn't be neccesary
}
}
void Viewer::goToFlowSwitch()
{
goToFlow->isVisible()?animateHideGoToFlow():showGoToFlow();
}
void Viewer::translatorSwitch()
{
translator->isVisible()?animateHideTranslator():animateShowTranslator();
}
void Viewer::showGoToFlow()
{
if(render->hasLoadedComic())
{
animateShowGoToFlow();
}
}
void Viewer::animateShowGoToFlow()
{
if(goToFlow->isHidden() && showGoToFlowAnimation->state()!=QPropertyAnimation::Running)
{
disconnect(showGoToFlowAnimation,SIGNAL(finished()),goToFlow,SLOT(hide()));
connect(showGoToFlowAnimation,SIGNAL(finished()),this,SLOT(moveCursoToGoToFlow()));
showGoToFlowAnimation->setStartValue(QPoint((width()-goToFlow->width())/2,height()-10));
showGoToFlowAnimation->setEndValue(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height()));
showGoToFlowAnimation->start();
goToFlow->centerSlide(render->getIndex());
goToFlow->setPageNumber(render->getIndex());
goToFlow->show();
goToFlow->setFocus(Qt::OtherFocusReason);
}
}
void Viewer::animateHideGoToFlow()
{
if(goToFlow->isVisible() && showGoToFlowAnimation->state()!=QPropertyAnimation::Running)
{
connect(showGoToFlowAnimation,SIGNAL(finished()),goToFlow,SLOT(hide()));
disconnect(showGoToFlowAnimation,SIGNAL(finished()),this,SLOT(moveCursoToGoToFlow()));
showGoToFlowAnimation->setStartValue(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height()));
showGoToFlowAnimation->setEndValue(QPoint((width()-goToFlow->width())/2,height()));
showGoToFlowAnimation->start();
goToFlow->centerSlide(render->getIndex());
goToFlow->setPageNumber(render->getIndex());
this->setFocus(Qt::OtherFocusReason);
}
}
void Viewer::moveCursoToGoToFlow()
{
//Move cursor to goToFlow widget on show (this avoid hide when mouse is moved)
int y = goToFlow->pos().y();
int x1 = goToFlow->pos().x();
int x2 = x1 + goToFlow->width();
QPoint cursorPos = mapFromGlobal(cursor().pos());
int cursorX = cursorPos.x();
int cursorY = cursorPos.y();
if(cursorY <= y)
cursorY = y + 10;
if(cursorX <= x1)
cursorX = x1 + 10;
if(cursorX >= x2)
cursorX = x2 - 10;
cursor().setPos(mapToGlobal(QPoint(cursorX,cursorY)));
hideCursorTimer->stop();
showCursor();
}
void Viewer::rotateLeft()
{
render->rotateLeft();
}
void Viewer::rotateRight()
{
render->rotateRight();
}
//TODO
void Viewer::setBookmark(bool set)
{
render->setBookmark();
if(set) //add bookmark
{
render->setBookmark();
}
else //remove bookmark
{
render->removeBookmark();
}
}
void Viewer::save ()
{
if(render->hasLoadedComic())
render->save();
}
void Viewer::doublePageSwitch()
{
doublePage = !doublePage;
render->doublePageSwitch();
Configuration::getConfiguration().setDoublePage(doublePage);
}
void Viewer::resetContent()
{
configureContent(tr("Press 'O' to open comic."));
goToFlow->reset();
emit reset();
}
void Viewer::setLoadingMessage()
{
if(magnifyingGlassShowed)
{
hideMagnifyingGlass();
restoreMagnifyingGlass = true;
}
emit(pageAvailable(false));
configureContent(tr("Loading...please wait!"));
}
void Viewer::configureContent(QString msg)
{
content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
content->setScaledContents(true);
content->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
content->setText(msg);
content->setFont(QFont("courier new", 12));
content->adjustSize();
setFocus(Qt::ShortcutFocusReason);
//emit showingText();
}
void Viewer::hideCursor()
{
#ifdef Q_OS_MAC
setCursor(QCursor(QBitmap(1,1),QBitmap(1,1)));
#else
setCursor(Qt::BlankCursor);
#endif
}
void Viewer::showCursor()
{
if(drag)
setCursor(Qt::ClosedHandCursor);
else
setCursor(Qt::OpenHandCursor);
}
void Viewer::updateOptions()
{
goToFlow->setFlowType(Configuration::getConfiguration().getFlowType());
updateBackgroundColor(Configuration::getConfiguration().getBackgroundColor());
updateContentSize();
//goToFlow->updateSize();
}
void Viewer::updateBackgroundColor(const QColor & color)
{
QPalette palette;
palette.setColor(backgroundRole(), color);
setPalette(palette);
}
void Viewer::animateShowTranslator()
{
if(translator->isHidden() && translatorAnimation->state()!=QPropertyAnimation::Running)
{
disconnect(translatorAnimation,SIGNAL(finished()),translator,SLOT(hide()));
if(translatorXPos == -10000)
translatorXPos = (width()-translator->width())/2;
int x = qMax(0,qMin(translatorXPos,width()-translator->width()));
if(translator->pos().x()<0)
{
translatorAnimation->setStartValue(QPoint(-translator->width(),translator->pos().y()));
}
else
{
translatorAnimation->setStartValue(QPoint(width()+translator->width(),translator->pos().y()));
}
translatorAnimation->setEndValue(QPoint(x,translator->pos().y()));
translatorAnimation->start();
translator->show();
translator->setFocus(Qt::OtherFocusReason);
}
}
void Viewer::animateHideTranslator()
{
if(translator->isVisible() && translatorAnimation->state()!=QPropertyAnimation::Running)
{
connect(translatorAnimation,SIGNAL(finished()),translator,SLOT(hide()));
translatorAnimation->setStartValue(QPoint(translatorXPos = translator->pos().x(),translator->pos().y()));
if((translator->width()/2)+translator->pos().x() <= width()/2)
translatorAnimation->setEndValue(QPoint(-translator->width(),translator->pos().y()));
else
translatorAnimation->setEndValue(QPoint(width()+translator->width(),translator->pos().y()));
translatorAnimation->start();
this->setFocus(Qt::OtherFocusReason);
}
}
void Viewer::mousePressEvent ( QMouseEvent * event )
{
drag = true;
yDragOrigin = event->y();
xDragOrigin = event->x();
setCursor(Qt::ClosedHandCursor);
}
void Viewer::mouseReleaseEvent ( QMouseEvent * event )
{
drag = false;
setCursor(Qt::OpenHandCursor);
}
void Viewer::updateFitToWidthRatio(float ratio)
{
adjustToWidthRatio = ratio;
updateContentSize();
}
void Viewer::updateConfig(QSettings * settings)
{
goToFlow->updateConfig(settings);
QPalette palette;
palette.setColor(backgroundRole(), Configuration::getConfiguration().getBackgroundColor());
setPalette(palette);
}
void Viewer::updateImageOptions()
{
render->reload();
}
void Viewer::setBookmarks()
{
bd->setBookmarks(*render->getBookmarks());
}
void Viewer::showIsCoverMessage()
{
notificationsLabel->setText(tr("Cover!"));
notificationsLabel->flash();
}
void Viewer::showIsLastMessage()
{
notificationsLabel->setText(tr("Last page!"));
notificationsLabel->flash();
}

146
YACReader/viewer.h Normal file
View File

@ -0,0 +1,146 @@
#ifndef __VIEWER_H
#define __VIEWER_H
#include <QMainWindow>
#include <QScrollArea>
#include <QAction>
#include <QTimer>
#include <QLabel>
#include <QPixmap>
#include <QKeyEvent>
#include <QResizeEvent>
#include <QWheelEvent>
#include <QMouseEvent>
#include <QCloseEvent>
#include <QPropertyAnimation>
#include <QSettings>
class Comic;
class MagnifyingGlass;
class GoToFlow;
class BookmarksDialog;
class Render;
class GoToDialog;
class YACReaderTranslator;
class GoToFlowWidget;
class Bookmarks;
class PageLabelWidget;
class NotificationsLabelWidget;
class Viewer : public QScrollArea
{
Q_OBJECT
public:
bool fullscreen; //TODO, change by the right use of windowState();
public slots:
void open(QString pathFile);
void prev();
void next();
void showGoToDialog();
void goTo(unsigned int page);
void updatePage();
void updateContentSize();
void updateVerticalScrollBar();
void updateOptions();
void scrollDown();
void scrollUp();
void magnifyingGlassSwitch();
void showMagnifyingGlass();
void hideMagnifyingGlass();
void informationSwitch();
void updateInformation();
void goToFlowSwitch();
void showGoToFlow();
void moveCursoToGoToFlow();
void animateShowGoToFlow();
void animateHideGoToFlow();
void rotateLeft();
void rotateRight();
bool magnifyingGlassIsVisible() {return magnifyingGlassShowed;}
void setBookmark(bool);
void save();
void doublePageSwitch();
void resetContent();
void setLoadingMessage();
void configureContent(QString msg);
void hideCursor();
void showCursor();
void createConnections();
void translatorSwitch();
void animateShowTranslator();
void animateHideTranslator();
virtual void mousePressEvent ( QMouseEvent * event );
virtual void mouseReleaseEvent ( QMouseEvent * event );
void updateBackgroundColor(const QColor & color);
void updateFitToWidthRatio(float ratio);
void updateConfig(QSettings * settings);
void showMessageErrorOpening();
void setBookmarks();
void updateImageOptions();
void showIsCoverMessage();
void showIsLastMessage();
private:
bool information;
bool doublePage;
PageLabelWidget * informationLabel;
//QTimer * scroller;
QPropertyAnimation * verticalScroller;
int posByStep;
int nextPos;
GoToFlowWidget * goToFlow;
QPropertyAnimation * showGoToFlowAnimation;
GoToDialog * goToDialog;
//!Image properties
float adjustToWidthRatio;
//! Comic
//Comic * comic;
int index;
QPixmap *currentPage;
BookmarksDialog * bd;
bool wheelStop;
Render * render;
QTimer * hideCursorTimer;
int direction;
bool drag;
//!Widgets
QLabel *content;
YACReaderTranslator * translator;
int translatorXPos;
QPropertyAnimation * translatorAnimation;
int yDragOrigin;
int xDragOrigin;
NotificationsLabelWidget * notificationsLabel;
private:
//!Magnifying glass
MagnifyingGlass *mglass;
bool magnifyingGlassShowed;
bool restoreMagnifyingGlass;
//! Manejadores de evento:
void keyPressEvent(QKeyEvent * event);
void resizeEvent(QResizeEvent * event);
void wheelEvent(QWheelEvent * event);
void mouseMoveEvent(QMouseEvent * event);
public:
Viewer(QWidget * parent = 0);
void toggleFullScreen();
const QPixmap * pixmap();
//Comic * getComic(){return comic;}
const BookmarksDialog * getBookmarksDialog(){return bd;}
signals:
void backgroundChanges();
void pageAvailable(bool);
void pageIsBookmark(bool);
void reset();
};
#endif

View File

@ -0,0 +1,78 @@
#include "width_slider.h"
#include <QWidget>
#include <QHBoxLayout>
#include <QLabel>
#include <QSlider>
#include "configuration.h"
YACReaderSliderAction::YACReaderSliderAction (QWidget * parent)
:QWidgetAction (0) {
QWidget* pWidget = new QWidget (NULL);
QHBoxLayout* pLayout = new QHBoxLayout();
pLayout->addStretch();
percentageLabel = new QLabel ("100%");
percentageLabel->setStyleSheet("QLabel { color : white; }");
percentageLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
pLayout->addWidget (percentageLabel);
slider = new QSlider(NULL);
slider->setOrientation(Qt::Horizontal);
pLayout->addWidget (slider);
QString sliderCSS =
"QSlider::sub-page:horizontal {background-image: url(:/images/sliderSubPage.png); border: 0px; margin-left: 18px;}"
"QSlider::add-page:horizontal {background-image: url(:/images/sliderAddPage.png); border: 0px; margin-right: 25px;}"
"QSlider::handle:horizontal {image: url(:/images/sliderHandle.png); width: 31px;height:45px; }"
"QSlider::groove:horizontal {border-image:url(:/images/sliderGround.png); border-left:-2px; border-right:0;}"
;
slider->setStyleSheet(sliderCSS);
slider->setFixedSize(218,45);
QLabel* imgLabel = new QLabel(pWidget);
QPixmap p(":/images/sliderBackground.png");
imgLabel->resize(p.size());
imgLabel->setPixmap(p);
pLayout->setMargin(0);
pLayout->setSpacing(0);
pLayout->setStretchFactor(percentageLabel,1);
pLayout->setStretchFactor(slider,0);
pWidget->setLayout (pLayout);
pWidget->setAutoFillBackground(false);
pWidget->setMinimumSize(276,45);
setDefaultWidget(pWidget);
slider->setMinimum(50);
slider->setMaximum(100);
slider->setPageStep(5);
int value = Configuration::getConfiguration().getFitToWidthRatio()*100;
slider->setValue(value);
percentageLabel->setText(QString("%1 %").arg(value));
connect(slider,SIGNAL(valueChanged(int)),this,SLOT(updateText(int)));
}
void YACReaderSliderAction::updateText(int value)
{
percentageLabel->setText(QString("%1 %").arg(value));
Configuration::getConfiguration().setFitToWidthRatio(value/100.0);
emit(fitToWidthRatioChanged(value / 100.0f));
}
void YACReaderSliderAction::updateFitToWidthRatio(float v)
{
int value = v*100;
slider->setValue(value);
percentageLabel->setText(QString("%1 %").arg(value));
}

29
YACReader/width_slider.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef WIDTH_SLIDER_H
#define WIDTH_SLIDER_H
#include <QWidgetAction>
class QLabel;
class QSlider;
class YACReaderSliderAction : public QWidgetAction
{
Q_OBJECT
private:
QLabel * percentageLabel;
QSlider * slider;
public:
YACReaderSliderAction (QWidget * parent = 0);
public slots:
void updateText(int value);
void updateFitToWidthRatio(float v);
signals:
void fitToWidthRatioChanged(float value);
};
#endif

BIN
YACReader/yacreader_es.qm Normal file

Binary file not shown.

929
YACReader/yacreader_es.ts Normal file
View File

@ -0,0 +1,929 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="es_ES">
<context>
<name>BookmarksDialog</name>
<message>
<location filename="bookmarks_dialog.cpp" line="25"/>
<source>Lastest Page</source>
<translation>Última página</translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="66"/>
<source>Close</source>
<translation>Cerrar</translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="74"/>
<source>Click on any image to go to the bookmark</source>
<translation>Pulsa en cualquier imagen para ir al marcador</translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="92"/>
<location filename="bookmarks_dialog.cpp" line="116"/>
<source>Loading...</source>
<translation>Cargando...</translation>
</message>
</context>
<context>
<name>Comic</name>
<message>
<source>Not found</source>
<translation type="obsolete">No encontrado</translation>
</message>
<message>
<source>Comic not found</source>
<translation type="obsolete">Cómic no encontrado</translation>
</message>
<message>
<source>Bad PDF File</source>
<translation type="obsolete">Archivo PDF erróneo</translation>
</message>
<message>
<source>Invalid PDF file</source>
<translation type="obsolete">Archivo PDF inválido</translation>
</message>
<message>
<source>No images found</source>
<translation type="obsolete">No se han encontrado imágenes</translation>
</message>
<message>
<source>There are not images on the selected folder</source>
<translation type="obsolete">No hay imágenes en el directorio seleccionado</translation>
</message>
<message>
<source>File error</source>
<translation type="obsolete">Error en archivo</translation>
</message>
<message>
<source>File not found or not images in file</source>
<translation type="obsolete">Archivo no encontrado o no hay imágenes en él</translation>
</message>
<message>
<source>7z not found</source>
<translation type="obsolete">7z no encontrado</translation>
</message>
<message>
<source>7z wasn&apos;t found in your PATH.</source>
<translation type="obsolete">7z no se ha encontrado en el PATH.</translation>
</message>
<message>
<source>7z crashed</source>
<translation type="obsolete">7z falló</translation>
</message>
<message>
<source>7z crashed.</source>
<translation type="obsolete">7z falló.</translation>
</message>
<message>
<source>7z reading</source>
<translation type="obsolete">7z leyendo</translation>
</message>
<message>
<source>problem reading from 7z</source>
<translation type="obsolete">Problema leyendo desde 7z</translation>
</message>
<message>
<source>7z problem</source>
<translation type="obsolete">7z problema</translation>
</message>
<message>
<source>Unknown error 7z</source>
<translation type="obsolete">Error desconocido 7z</translation>
</message>
</context>
<context>
<name>Comic2</name>
<message>
<source>7z not found</source>
<translation type="obsolete">7z no encontrado</translation>
</message>
<message>
<source>7z wasn&apos;t found in your PATH.</source>
<translation type="obsolete">7z no se ha encontrado en el PATH.</translation>
</message>
<message>
<source>7z crashed</source>
<translation type="obsolete">7z falló</translation>
</message>
<message>
<source>7z crashed.</source>
<translation type="obsolete">7z falló.</translation>
</message>
<message>
<source>7z reading</source>
<translation type="obsolete">7z leyendo</translation>
</message>
<message>
<source>problem reading from 7z</source>
<translation type="obsolete">Problema leyendo desde 7z</translation>
</message>
<message>
<source>7z problem</source>
<translation type="obsolete">7z problema</translation>
</message>
<message>
<source>Unknown error 7z</source>
<translation type="obsolete">Error desconocido 7z</translation>
</message>
</context>
<context>
<name>Configuration</name>
<message>
<location filename="configuration.cpp" line="167"/>
<source>Saving config file....</source>
<translation>Guardando el archivo de configuración...</translation>
</message>
<message>
<location filename="configuration.cpp" line="167"/>
<source>There was a problem saving YACReader configuration. Please, check if you have enough permissions in the YACReader root folder.</source>
<translation>Hubo un problema al guardar la configuración de YACReader. Por favor, comprueba si tienes suficientes permisos en el directorio raíz de YACReader.</translation>
</message>
</context>
<context>
<name>FileComic</name>
<message>
<location filename="comic.cpp" line="216"/>
<source>Not found</source>
<translatorcomment>No encontrado</translatorcomment>
<translation>No encontrado</translation>
</message>
<message>
<location filename="comic.cpp" line="216"/>
<source>Comic not found</source>
<translation>Cómic no encontrado</translation>
</message>
<message>
<location filename="comic.cpp" line="243"/>
<source>File error</source>
<translation>Error en archivo</translation>
</message>
<message>
<location filename="comic.cpp" line="243"/>
<source>File not found or not images in file</source>
<translation>Archivo no encontrado o no hay imágenes en él</translation>
</message>
<message>
<location filename="comic.cpp" line="297"/>
<source>7z not found</source>
<translation>7z no encontrado</translation>
</message>
<message>
<location filename="comic.cpp" line="297"/>
<source>7z wasn&apos;t found in your PATH.</source>
<translation>7z no se ha encontrado en el PATH.</translation>
</message>
<message>
<location filename="comic.cpp" line="300"/>
<source>7z crashed</source>
<translation>7z falló</translation>
</message>
<message>
<location filename="comic.cpp" line="300"/>
<source>7z crashed.</source>
<translation>7z falló.</translation>
</message>
<message>
<location filename="comic.cpp" line="303"/>
<source>7z reading</source>
<translation>7z leyendo</translation>
</message>
<message>
<location filename="comic.cpp" line="303"/>
<source>problem reading from 7z</source>
<translation>Problema leyendo desde 7z</translation>
</message>
<message>
<location filename="comic.cpp" line="306"/>
<source>7z problem</source>
<translation>7z problema</translation>
</message>
<message>
<location filename="comic.cpp" line="306"/>
<source>Unknown error 7z</source>
<translation>Error desconocido 7z</translation>
</message>
</context>
<context>
<name>GoToDialog</name>
<message>
<location filename="goto_dialog.cpp" line="17"/>
<source>Page : </source>
<translation>Página :</translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="25"/>
<source>Go To</source>
<translation>Ir a</translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="27"/>
<source>Cancel</source>
<translation>Cancelar</translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="41"/>
<location filename="goto_dialog.cpp" line="73"/>
<source>Total pages : </source>
<translation>Páginas totales:</translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="55"/>
<source>Go to...</source>
<translation>Ir a...</translation>
</message>
</context>
<context>
<name>GoToFlow</name>
<message>
<source>Page : </source>
<translation type="obsolete">Página:</translation>
</message>
<message>
<source>Total pages : </source>
<translation type="obsolete">Page:</translation>
</message>
</context>
<context>
<name>GoToFlowGL</name>
<message>
<source>Page : </source>
<translation type="obsolete">Página :</translation>
</message>
</context>
<context>
<name>GoToFlowToolBar</name>
<message>
<location filename="goto_flow_toolbar.cpp" line="44"/>
<source>Page : </source>
<translation>Página : </translation>
</message>
</context>
<context>
<name>HelpAboutDialog</name>
<message>
<location filename="../custom_widgets/help_about_dialog.cpp" line="19"/>
<source>About</source>
<translation>Acerca de</translation>
</message>
<message>
<location filename="../custom_widgets/help_about_dialog.cpp" line="22"/>
<source>Help</source>
<translation>Ayuda</translation>
</message>
</context>
<context>
<name>MainWindowViewer</name>
<message>
<location filename="main_window_viewer.cpp" line="135"/>
<source>&amp;Open</source>
<translation>&amp;Abrir</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="136"/>
<source>O</source>
<translation>O</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="138"/>
<source>Open a comic</source>
<translation>Abrir cómic</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="141"/>
<source>Open Folder</source>
<translation>Abrir carpeta</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="142"/>
<source>Ctrl+O</source>
<translation>Ctrl+O</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="144"/>
<source>Open image folder</source>
<oldsource>Open images in a folder</oldsource>
<translation>Abrir carpeta de imágenes</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="147"/>
<source>Save</source>
<translation>Guardar</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="149"/>
<location filename="main_window_viewer.cpp" line="483"/>
<source>Save current page</source>
<translation>Guardar la página actual</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="153"/>
<source>Previous Comic</source>
<translation>Cómic anterior</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="156"/>
<source>Open previous comic</source>
<translation>Abrir cómic anterior</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="160"/>
<source>Next Comic</source>
<translation>Siguiente Cómic</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="163"/>
<source>Open next comic</source>
<translation>Abrir siguiente cómic</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="167"/>
<source>&amp;Previous</source>
<translation>A&amp;nterior</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="170"/>
<source>Go to previous page</source>
<translation>Ir a la página anterior</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="174"/>
<source>&amp;Next</source>
<translation>Siguie&amp;nte</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="177"/>
<source>Go to next page</source>
<translation>Ir a la página siguiente</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="181"/>
<source>Fit Width</source>
<translation>Ajustar anchura</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="182"/>
<source>A</source>
<translation>A</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="187"/>
<source>Fit image to ...</source>
<translation>Ajustar imagen a...</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="191"/>
<source>Rotate image to the left</source>
<translation>Rotar imagen a la izquierda</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="192"/>
<source>L</source>
<translation>L</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="197"/>
<source>Rotate image to the right</source>
<translation>Rotar imagen a la derecha</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="198"/>
<source>R</source>
<translation>R</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="203"/>
<source>Double page mode</source>
<translation>Modo a doble página</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="204"/>
<source>Switch to double page mode</source>
<translation>Cambiar a modo de doble página</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="205"/>
<source>D</source>
<translation>D</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="212"/>
<source>Go To</source>
<translation>Ir a</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="213"/>
<source>G</source>
<translation>G</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="216"/>
<source>Go to page ...</source>
<translation>Ir a página...</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="219"/>
<source>Options</source>
<translation>Opciones</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="220"/>
<source>C</source>
<translation>C</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="221"/>
<source>YACReader options</source>
<translation>Opciones de YACReader</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="226"/>
<source>Help</source>
<translation>Ayuda</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="227"/>
<source>Help, About YACReader</source>
<translation>Ayuda, Sobre YACReader</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="232"/>
<source>Magnifying glass</source>
<translation>Lupa</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="233"/>
<source>Switch Magnifying glass</source>
<translation>Lupa On/Off</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="234"/>
<source>Z</source>
<translation>Z</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="240"/>
<source>Set bookmark</source>
<translation>Añadir marcador</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="241"/>
<source>Set a bookmark on the current page</source>
<translation>Añadir un marcador en la página actual</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="250"/>
<source>Show bookmarks</source>
<translation>Mostrar marcadores</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="251"/>
<source>Show the bookmarks of the current comic</source>
<translation>Mostrar los marcadores del cómic actual</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="252"/>
<source>M</source>
<translation>M</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="257"/>
<source>Show keyboard shortcuts</source>
<translation>Mostrar atajos de teclado</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="261"/>
<source>Show Info</source>
<translation>Mostrar información</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="262"/>
<source>I</source>
<translation>I</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="267"/>
<source>Close</source>
<translation>Cerrar</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="272"/>
<source>Show Dictionary</source>
<translation>Mostrar diccionario</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="279"/>
<source>Always on top</source>
<translation>Siempre visible</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="287"/>
<source>Show full size</source>
<translation>Mostrar a tamaño original</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="298"/>
<source>&amp;File</source>
<translation>&amp;Archivo</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="435"/>
<source>Open Comic</source>
<translation>Abrir cómic</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="435"/>
<source>Comic files</source>
<translation>Archivos de cómic</translation>
</message>
<message>
<source>Comic files (*.cbr *.cbz *.rar *.zip *.pdf *.tar *.arj)</source>
<translation type="obsolete">Archivos de cómic (*.cbr *.cbz *.rar *.zip *pdf *.tar *.arj)</translation>
</message>
<message>
<source>Comic files (*.cbr *.cbz *.rar *.zip *.tar *.arj)</source>
<translation type="obsolete">Archivos de cómic (*.cbr *.cbz *.rar *.zip *.tar *.arj)</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="459"/>
<source>Open folder</source>
<translation>Abrir carpeta</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="483"/>
<source>Image files (*.jpg)</source>
<translation>Archivos de imagen (*.jpg)</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="627"/>
<source>There is a new version avaliable</source>
<translation>Hay una nueva versión disponible</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="628"/>
<source>Do you want to download the new version?</source>
<translation>¿Desea descargar la nueva versión?</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="693"/>
<source>Saving error log file....</source>
<translation>Guardando el archivo de log...</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="693"/>
<source>There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder.</source>
<translation>Hubo un problema al guardar el archivo de log de YACReader. Por favor, comprueba si tienes suficientes permisos en el directorio raíz de YACReader.</translation>
</message>
</context>
<context>
<name>OptionsDialog</name>
<message>
<location filename="options_dialog.cpp" line="35"/>
<source>&quot;Go to flow&quot; size</source>
<translation>Tamaño de &quot;Go to flow&quot;</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="46"/>
<source>My comics path</source>
<translation>Ruta a mis cómics</translation>
</message>
<message>
<source>Save</source>
<translation type="obsolete">Guardar</translation>
</message>
<message>
<source>Cancel</source>
<translation type="obsolete">Cancelar</translation>
</message>
<message>
<source>How to show pages in GoToFlow:</source>
<translation type="obsolete">¿Cómo deseas que se muestren las páginas en &quot;Go To Flow&quot;:</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="56"/>
<source>Page width stretch</source>
<translation>Ajuste en anchura de la página</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="77"/>
<source>Background color</source>
<translation>Color de fondo</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="80"/>
<source>Choose</source>
<translation>Elegir</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="108"/>
<source>Restart is needed</source>
<translation>Es necesario reiniciar</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="121"/>
<source>Brightness</source>
<translation>Brillo</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="122"/>
<source>Contrast</source>
<translation>Contraste</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="123"/>
<source>Gamma</source>
<translation>Gamma</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="127"/>
<source>Reset</source>
<translation>Reset</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="133"/>
<source>Image options</source>
<translation>Opciones de imagen</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="143"/>
<source>General</source>
<translation>General</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="144"/>
<source>Page Flow</source>
<translation>Page Flow</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="145"/>
<source>Image adjustment</source>
<translation>Ajustes de imagen</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="158"/>
<source>Options</source>
<translation>Opciones</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="165"/>
<source>Comics directory</source>
<translation>Directorio de cómics</translation>
</message>
</context>
<context>
<name>QPushButton</name>
<message>
<source>Hello world!</source>
<translation type="obsolete">Hola mundo!</translation>
</message>
</context>
<context>
<name>ShortcutsDialog</name>
<message>
<location filename="shortcuts_dialog.cpp" line="16"/>
<source>YACReader keyboard shortcuts</source>
<translation>Atajos de teclado de YACReader</translation>
</message>
<message>
<location filename="shortcuts_dialog.cpp" line="20"/>
<source>Close</source>
<translation>Cerrar</translation>
</message>
<message>
<location filename="shortcuts_dialog.cpp" line="66"/>
<source>Keyboard Shortcuts</source>
<translation>Atajos de teclado</translation>
</message>
</context>
<context>
<name>Viewer</name>
<message>
<location filename="viewer.cpp" line="43"/>
<location filename="viewer.cpp" line="634"/>
<source>Press &apos;O&apos; to open comic.</source>
<translation>Pulsa &apos;O&apos; para abrir un fichero.</translation>
</message>
<message>
<location filename="viewer.cpp" line="183"/>
<source>Not found</source>
<translation>No encontrado</translation>
</message>
<message>
<location filename="viewer.cpp" line="183"/>
<source>Comic not found</source>
<translation>Cómic no encontrado</translation>
</message>
<message>
<location filename="viewer.cpp" line="773"/>
<source>Cover!</source>
<translation>¡Portada!</translation>
</message>
<message>
<location filename="viewer.cpp" line="780"/>
<source>Last page!</source>
<translation>¡Última página!</translation>
</message>
<message>
<source>Show Info</source>
<translation type="obsolete">Mostrar información</translation>
</message>
<message>
<source>I</source>
<translation type="obsolete">I</translation>
</message>
<message>
<location filename="viewer.cpp" line="647"/>
<source>Loading...please wait!</source>
<translation>Cargando...espere, por favor!</translation>
</message>
</context>
<context>
<name>YACReaderFieldEdit</name>
<message>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="9"/>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="29"/>
<source>Click to overwrite</source>
<translation>Click para sobreescribir</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="11"/>
<source>Restore to default</source>
<translation>Restaurar valor por defecto</translation>
</message>
</context>
<context>
<name>YACReaderFieldPlainTextEdit</name>
<message>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="9"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="20"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="45"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="51"/>
<source>Click to overwrite</source>
<translation>Click para sobreescribir</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="10"/>
<source>Restore to default</source>
<translation>Restaurar valor por defecto</translation>
</message>
</context>
<context>
<name>YACReaderFlowConfigWidget</name>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="13"/>
<source>How to show covers:</source>
<translation>Cómo mostrar las portadas:</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="15"/>
<source>CoverFlow look</source>
<translation>Tipo CoverFlow</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="16"/>
<source>Stripe look</source>
<translation>Tipo tira</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="17"/>
<source>Overlapped Stripe look</source>
<translation>Tipo tira solapada</translation>
</message>
</context>
<context>
<name>YACReaderGLFlowConfigWidget</name>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="19"/>
<source>Presets:</source>
<translation>Predefinidos:</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="21"/>
<source>Classic look</source>
<translation>Tipo clásico</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="24"/>
<source>Stripe look</source>
<translation>Tipo tira</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="27"/>
<source>Overlapped Stripe look</source>
<translation>Tipo tira solapada</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="30"/>
<source>Modern look</source>
<translation>Tipo moderno</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="33"/>
<source>Roulette look</source>
<translation>Tipo ruleta</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="77"/>
<source>Show advanced settings</source>
<translation>Opciones avanzadas</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="86"/>
<source>Custom:</source>
<translation>Personalizado:</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="89"/>
<source>View angle</source>
<translation>Ángulo de vista</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="95"/>
<source>Position</source>
<translation>Posición</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="101"/>
<source>Cover gap</source>
<translation>Hueco entre portadas</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="107"/>
<source>Central gap</source>
<translation>Hueco central</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="113"/>
<source>Zoom</source>
<translation>Zoom</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="119"/>
<source>Y offset</source>
<translation>Desplazamiento en Y</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="125"/>
<source>Z offset</source>
<translation>Desplazamiento en Z </translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="131"/>
<source>Cover Angle</source>
<translation>Ángulo de las portadas</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="137"/>
<source>Visibility</source>
<translation>Visibilidad</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="143"/>
<source>Light</source>
<translation>Luz</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="149"/>
<source>Max angle</source>
<translation>Ángulo máximo</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="181"/>
<source>Low Performance</source>
<translation>Rendimiento bajo</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="183"/>
<source>High Performance</source>
<translation>Alto rendimiento</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="194"/>
<source>Use VSync (improve the image quality in fullscreen mode, worse performance)</source>
<translation>Utilizar VSync (mejora la calidad de imagen en pantalla completa, peor rendimiento)</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="202"/>
<source>Performance:</source>
<translation>Rendimiento:</translation>
</message>
</context>
<context>
<name>YACReaderOptionsDialog</name>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="21"/>
<source>Save</source>
<translation>Guardar</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="22"/>
<source>Cancel</source>
<translation>Cancelar</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="30"/>
<source>Use hardware acceleration (restart needed)</source>
<translation>Utilizar aceleración por hardware (necesario reiniciar)</translation>
</message>
</context>
</TS>

772
YACReader/yacreader_fr.ts Normal file
View File

@ -0,0 +1,772 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="fr_FR">
<context>
<name>BookmarksDialog</name>
<message>
<location filename="bookmarks_dialog.cpp" line="25"/>
<source>Lastest Page</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="66"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="74"/>
<source>Click on any image to go to the bookmark</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="92"/>
<location filename="bookmarks_dialog.cpp" line="116"/>
<source>Loading...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Configuration</name>
<message>
<location filename="configuration.cpp" line="167"/>
<source>Saving config file....</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="configuration.cpp" line="167"/>
<source>There was a problem saving YACReader configuration. Please, check if you have enough permissions in the YACReader root folder.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FileComic</name>
<message>
<location filename="comic.cpp" line="216"/>
<source>Not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="216"/>
<source>Comic not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="243"/>
<source>File error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="243"/>
<source>File not found or not images in file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="297"/>
<source>7z not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="297"/>
<source>7z wasn&apos;t found in your PATH.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="300"/>
<source>7z crashed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="300"/>
<source>7z crashed.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="303"/>
<source>7z reading</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="303"/>
<source>problem reading from 7z</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="306"/>
<source>7z problem</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="306"/>
<source>Unknown error 7z</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GoToDialog</name>
<message>
<location filename="goto_dialog.cpp" line="17"/>
<source>Page : </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="25"/>
<source>Go To</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="27"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="41"/>
<location filename="goto_dialog.cpp" line="73"/>
<source>Total pages : </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="55"/>
<source>Go to...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GoToFlowToolBar</name>
<message>
<location filename="goto_flow_toolbar.cpp" line="44"/>
<source>Page : </source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>HelpAboutDialog</name>
<message>
<location filename="../custom_widgets/help_about_dialog.cpp" line="19"/>
<source>About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/help_about_dialog.cpp" line="22"/>
<source>Help</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWindowViewer</name>
<message>
<location filename="main_window_viewer.cpp" line="135"/>
<source>&amp;Open</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="136"/>
<source>O</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="138"/>
<source>Open a comic</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="141"/>
<source>Open Folder</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="142"/>
<source>Ctrl+O</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="144"/>
<source>Open image folder</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="147"/>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="149"/>
<location filename="main_window_viewer.cpp" line="483"/>
<source>Save current page</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="153"/>
<source>Previous Comic</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="156"/>
<source>Open previous comic</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="160"/>
<source>Next Comic</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="163"/>
<source>Open next comic</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="167"/>
<source>&amp;Previous</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="170"/>
<source>Go to previous page</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="174"/>
<source>&amp;Next</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="177"/>
<source>Go to next page</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="181"/>
<source>Fit Width</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="182"/>
<source>A</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="187"/>
<source>Fit image to ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="191"/>
<source>Rotate image to the left</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="192"/>
<source>L</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="197"/>
<source>Rotate image to the right</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="198"/>
<source>R</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="203"/>
<source>Double page mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="204"/>
<source>Switch to double page mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="205"/>
<source>D</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="212"/>
<source>Go To</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="213"/>
<source>G</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="216"/>
<source>Go to page ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="219"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="220"/>
<source>C</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="221"/>
<source>YACReader options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="226"/>
<source>Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="227"/>
<source>Help, About YACReader</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="232"/>
<source>Magnifying glass</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="233"/>
<source>Switch Magnifying glass</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="234"/>
<source>Z</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="240"/>
<source>Set bookmark</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="241"/>
<source>Set a bookmark on the current page</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="250"/>
<source>Show bookmarks</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="251"/>
<source>Show the bookmarks of the current comic</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="252"/>
<source>M</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="257"/>
<source>Show keyboard shortcuts</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="261"/>
<source>Show Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="262"/>
<source>I</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="267"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="272"/>
<source>Show Dictionary</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="279"/>
<source>Always on top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="287"/>
<source>Show full size</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="298"/>
<source>&amp;File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="435"/>
<source>Open Comic</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="435"/>
<source>Comic files</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="459"/>
<source>Open folder</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="483"/>
<source>Image files (*.jpg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="627"/>
<source>There is a new version avaliable</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="628"/>
<source>Do you want to download the new version?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="693"/>
<source>Saving error log file....</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="693"/>
<source>There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>OptionsDialog</name>
<message>
<location filename="options_dialog.cpp" line="35"/>
<source>&quot;Go to flow&quot; size</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="46"/>
<source>My comics path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="56"/>
<source>Page width stretch</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="77"/>
<source>Background color</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="80"/>
<source>Choose</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="108"/>
<source>Restart is needed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="121"/>
<source>Brightness</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="122"/>
<source>Contrast</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="123"/>
<source>Gamma</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="127"/>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="133"/>
<source>Image options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="143"/>
<source>General</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="144"/>
<source>Page Flow</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="145"/>
<source>Image adjustment</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="158"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="165"/>
<source>Comics directory</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ShortcutsDialog</name>
<message>
<location filename="shortcuts_dialog.cpp" line="16"/>
<source>YACReader keyboard shortcuts</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcuts_dialog.cpp" line="20"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcuts_dialog.cpp" line="66"/>
<source>Keyboard Shortcuts</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Viewer</name>
<message>
<location filename="viewer.cpp" line="43"/>
<location filename="viewer.cpp" line="634"/>
<source>Press &apos;O&apos; to open comic.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="viewer.cpp" line="183"/>
<source>Not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="viewer.cpp" line="183"/>
<source>Comic not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="viewer.cpp" line="647"/>
<source>Loading...please wait!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="viewer.cpp" line="773"/>
<source>Cover!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="viewer.cpp" line="780"/>
<source>Last page!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YACReaderFieldEdit</name>
<message>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="9"/>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="29"/>
<source>Click to overwrite</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="11"/>
<source>Restore to default</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YACReaderFieldPlainTextEdit</name>
<message>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="9"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="20"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="45"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="51"/>
<source>Click to overwrite</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="10"/>
<source>Restore to default</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YACReaderFlowConfigWidget</name>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="13"/>
<source>How to show covers:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="15"/>
<source>CoverFlow look</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="16"/>
<source>Stripe look</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="17"/>
<source>Overlapped Stripe look</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YACReaderGLFlowConfigWidget</name>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="19"/>
<source>Presets:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="21"/>
<source>Classic look</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="24"/>
<source>Stripe look</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="27"/>
<source>Overlapped Stripe look</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="30"/>
<source>Modern look</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="33"/>
<source>Roulette look</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="77"/>
<source>Show advanced settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="86"/>
<source>Custom:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="89"/>
<source>View angle</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="95"/>
<source>Position</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="101"/>
<source>Cover gap</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="107"/>
<source>Central gap</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="113"/>
<source>Zoom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="119"/>
<source>Y offset</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="125"/>
<source>Z offset</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="131"/>
<source>Cover Angle</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="137"/>
<source>Visibility</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="143"/>
<source>Light</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="149"/>
<source>Max angle</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="181"/>
<source>Low Performance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="183"/>
<source>High Performance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="194"/>
<source>Use VSync (improve the image quality in fullscreen mode, worse performance)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="202"/>
<source>Performance:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YACReaderOptionsDialog</name>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="21"/>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="22"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="30"/>
<source>Use hardware acceleration (restart needed)</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,31 @@
#include "yacreader_local_client.h"
#include "yacreader_comic_library.h"
#include "yacreader_comic_info_library.h"
#include <QLocalSocket>
YACReaderLocalClient::YACReaderLocalClient(QObject *parent) :
QObject(parent)
{
localSocket = new QLocalSocket(this);
connect(localSocket, SIGNAL(readyRead()), this, SLOT(readMessage()));
/*connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)),
this, SLOT(displayError(QLocalSocket::LocalSocketError)));*/
}
//información de comic recibida...
void YACReaderLocalClient::readMessage()
{
}
void YACReaderLocalClient::requestComicInfo(QString library, YACReaderComicLibrary & comic)
{
}
void YACReaderLocalClient::sendComicInfo(QString library, YACReaderComicLibrary & comic)
{
}

View File

@ -0,0 +1,27 @@
#ifndef YACREADER_LOCAL_CLIENT_H
#define YACREADER_LOCAL_CLIENT_H
#include <QObject>
class QLocalSocket;
class YACReaderComicLibrary;
class YACReaderLocalClient : public QObject
{
Q_OBJECT
public:
explicit YACReaderLocalClient(QObject *parent = 0);
signals:
public slots:
void readMessage();
void requestComicInfo(QString library, YACReaderComicLibrary & comic);
void sendComicInfo(QString library, YACReaderComicLibrary & comic);
private:
QLocalSocket * localSocket;
};
#endif // YACREADER_LOCAL_CLIENT_H

862
YACReader/yacreader_pt.ts Normal file
View File

@ -0,0 +1,862 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="pt_BR">
<context>
<name>BookmarksDialog</name>
<message>
<location filename="bookmarks_dialog.cpp" line="25"/>
<source>Lastest Page</source>
<translation>Última Página</translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="66"/>
<source>Close</source>
<translation>Fechar</translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="74"/>
<source>Click on any image to go to the bookmark</source>
<translation>Clique em qualquer imagem para ir para o marcador</translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="92"/>
<location filename="bookmarks_dialog.cpp" line="116"/>
<source>Loading...</source>
<translation>Carregando...</translation>
</message>
</context>
<context>
<name>Comic</name>
<message>
<source>No images found</source>
<translation type="obsolete">Nenhuma imagem encontrada</translation>
</message>
<message>
<source>There are not images on the selected folder</source>
<translation type="obsolete">Não imagens na pasta selecionada</translation>
</message>
<message>
<source>File error</source>
<translation type="obsolete">Erro no arquivo</translation>
</message>
<message>
<source>File not found or not images in file</source>
<translation type="obsolete">Arquivo não encontrado ou nenhuma imagem no arquivo</translation>
</message>
<message>
<source>7z not found</source>
<translation type="obsolete">7z não encontrado</translation>
</message>
<message>
<source>7z wasn&apos;t found in your PATH.</source>
<translation type="obsolete">7z não foi encontrado no seu sistema (PATH).</translation>
</message>
<message>
<source>7z crashed</source>
<translation type="obsolete">7z fechou inesperadamente</translation>
</message>
<message>
<source>7z crashed.</source>
<translation type="obsolete">7z fechou inesperadamente.</translation>
</message>
<message>
<source>7z reading</source>
<translation type="obsolete">Lendo 7z</translation>
</message>
<message>
<source>problem reading from 7z</source>
<translation type="obsolete">Problema na leitura do 7z</translation>
</message>
<message>
<source>7z problem</source>
<translation type="obsolete">Problema no 7z</translation>
</message>
<message>
<source>Unknown error 7z</source>
<translation type="obsolete">Erro desconhecido no 7z</translation>
</message>
</context>
<context>
<name>Configuration</name>
<message>
<location filename="configuration.cpp" line="167"/>
<source>Saving config file....</source>
<translation>Salvando arquivo de configuração...</translation>
</message>
<message>
<location filename="configuration.cpp" line="167"/>
<source>There was a problem saving YACReader configuration. Please, check if you have enough permissions in the YACReader root folder.</source>
<translation>Houve um problema ao salvar a configuração do YACReader. Por favor, verifique se você tem permissões suficientes na pasta raiz do YACReader.</translation>
</message>
</context>
<context>
<name>FileComic</name>
<message>
<location filename="comic.cpp" line="216"/>
<source>Not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="216"/>
<source>Comic not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="comic.cpp" line="243"/>
<source>File error</source>
<translation>Erro no arquivo</translation>
</message>
<message>
<location filename="comic.cpp" line="243"/>
<source>File not found or not images in file</source>
<translation>Arquivo não encontrado ou nenhuma imagem no arquivo</translation>
</message>
<message>
<location filename="comic.cpp" line="297"/>
<source>7z not found</source>
<translation>7z não encontrado</translation>
</message>
<message>
<location filename="comic.cpp" line="297"/>
<source>7z wasn&apos;t found in your PATH.</source>
<translation>7z não foi encontrado no seu sistema (PATH).</translation>
</message>
<message>
<location filename="comic.cpp" line="300"/>
<source>7z crashed</source>
<translation>7z fechou inesperadamente</translation>
</message>
<message>
<location filename="comic.cpp" line="300"/>
<source>7z crashed.</source>
<translation>7z fechou inesperadamente.</translation>
</message>
<message>
<location filename="comic.cpp" line="303"/>
<source>7z reading</source>
<translation>Lendo 7z</translation>
</message>
<message>
<location filename="comic.cpp" line="303"/>
<source>problem reading from 7z</source>
<translation>Problema na leitura do 7z</translation>
</message>
<message>
<location filename="comic.cpp" line="306"/>
<source>7z problem</source>
<translation>Problema no 7z</translation>
</message>
<message>
<location filename="comic.cpp" line="306"/>
<source>Unknown error 7z</source>
<translation>Erro desconhecido no 7z</translation>
</message>
</context>
<context>
<name>GoToDialog</name>
<message>
<location filename="goto_dialog.cpp" line="17"/>
<source>Page : </source>
<translation>Página : </translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="25"/>
<source>Go To</source>
<translation>Ir Para</translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="27"/>
<source>Cancel</source>
<translation>Cancelar</translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="41"/>
<location filename="goto_dialog.cpp" line="73"/>
<source>Total pages : </source>
<translation>Total de páginas : </translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="55"/>
<source>Go to...</source>
<translation>Ir para...</translation>
</message>
</context>
<context>
<name>GoToFlow</name>
<message>
<source>Page : </source>
<translation type="obsolete">Página : </translation>
</message>
</context>
<context>
<name>GoToFlowToolBar</name>
<message>
<location filename="goto_flow_toolbar.cpp" line="44"/>
<source>Page : </source>
<translation>Página : </translation>
</message>
</context>
<context>
<name>HelpAboutDialog</name>
<message>
<location filename="../custom_widgets/help_about_dialog.cpp" line="19"/>
<source>About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/help_about_dialog.cpp" line="22"/>
<source>Help</source>
<translation>Ajuda</translation>
</message>
</context>
<context>
<name>MainWindowViewer</name>
<message>
<location filename="main_window_viewer.cpp" line="135"/>
<source>&amp;Open</source>
<translation>&amp;Abrir</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="136"/>
<source>O</source>
<translation>O</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="138"/>
<source>Open a comic</source>
<translation>Abrir um quadrinho</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="141"/>
<source>Open Folder</source>
<translation>Abrir Pasta</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="142"/>
<source>Ctrl+O</source>
<translation>Ctrl+O</translation>
</message>
<message>
<source>Open images in a folder</source>
<translation type="obsolete">Abrir imagens em uma pasta</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="144"/>
<source>Open image folder</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="147"/>
<source>Save</source>
<translation>Salvar</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="149"/>
<location filename="main_window_viewer.cpp" line="483"/>
<source>Save current page</source>
<translation>Salvar página atual</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="153"/>
<source>Previous Comic</source>
<translation>Quadrinho Anterior</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="156"/>
<source>Open previous comic</source>
<translation>Abrir quadrinho anterior</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="160"/>
<source>Next Comic</source>
<translation>Próximo Quadrinho</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="163"/>
<source>Open next comic</source>
<translation>Abrir próximo quadrinho</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="167"/>
<source>&amp;Previous</source>
<translation>A&amp;nterior</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="170"/>
<source>Go to previous page</source>
<translation>Ir para a página anterior</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="174"/>
<source>&amp;Next</source>
<translation>&amp;Próxima</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="177"/>
<source>Go to next page</source>
<translation>Ir para a próxima página</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="181"/>
<source>Fit Width</source>
<translation>Ajustar à Largura</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="182"/>
<source>A</source>
<translation>A</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="187"/>
<source>Fit image to ...</source>
<translation>Ajustar imagem à...</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="191"/>
<source>Rotate image to the left</source>
<translation>Girar imagem à esquerda</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="192"/>
<source>L</source>
<translation>L</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="197"/>
<source>Rotate image to the right</source>
<translation>Girar imagem à direita</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="198"/>
<source>R</source>
<translation>R</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="203"/>
<source>Double page mode</source>
<translation>Modo dupla página</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="204"/>
<source>Switch to double page mode</source>
<translation>Alternar para o modo dupla página</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="205"/>
<source>D</source>
<translation>D</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="212"/>
<source>Go To</source>
<translation>Ir Para</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="213"/>
<source>G</source>
<translation>G</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="216"/>
<source>Go to page ...</source>
<translation>Ir para a página...</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="219"/>
<source>Options</source>
<translation>Opções</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="220"/>
<source>C</source>
<translation>C</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="221"/>
<source>YACReader options</source>
<translation>Opções do YACReader</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="226"/>
<source>Help</source>
<translation>Ajuda</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="227"/>
<source>Help, About YACReader</source>
<translation>Ajuda, Sobre o YACReader</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="232"/>
<source>Magnifying glass</source>
<translation>Lupa</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="233"/>
<source>Switch Magnifying glass</source>
<translation>Alternar Lupa</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="234"/>
<source>Z</source>
<translation>Z</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="240"/>
<source>Set bookmark</source>
<translation>Definir marcador</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="241"/>
<source>Set a bookmark on the current page</source>
<translation>Definir um marcador na página atual</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="250"/>
<source>Show bookmarks</source>
<translation>Mostrar marcadores</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="251"/>
<source>Show the bookmarks of the current comic</source>
<translation>Mostrar os marcadores do quadrinho atual</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="252"/>
<source>M</source>
<translation>M</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="257"/>
<source>Show keyboard shortcuts</source>
<translation>Mostrar teclas de atalhos</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="261"/>
<source>Show Info</source>
<translation>Mostrar Informações</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="262"/>
<source>I</source>
<translation>I</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="267"/>
<source>Close</source>
<translation>Fechar</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="272"/>
<source>Show Dictionary</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="279"/>
<source>Always on top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="287"/>
<source>Show full size</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="298"/>
<source>&amp;File</source>
<translation>&amp;Arquivo</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="435"/>
<source>Open Comic</source>
<translation>Abrir Quadrinho</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="435"/>
<source>Comic files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comic files (*.cbr *.cbz *.rar *.zip *.tar *.arj)</source>
<translation type="obsolete">Arquivos de quadrinho (*.cbr *.cbz *.rar *.zip *.tar *.arj)</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="459"/>
<source>Open folder</source>
<translation>Abrir pasta</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="483"/>
<source>Image files (*.jpg)</source>
<translation>Arquivos de imagem (*.jpg)</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="627"/>
<source>There is a new version avaliable</source>
<translation> uma nova versão disponível</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="628"/>
<source>Do you want to download the new version?</source>
<translation>Você deseja baixar a nova versão?</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="693"/>
<source>Saving error log file....</source>
<translation>Salvando arquivo de registro de erro....</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="693"/>
<source>There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder.</source>
<translation>Houve um problema ao salvar o arquivo de registro de erro do YACReader. Por favor, verifique se você tem permissões suficientes na pasta raiz YACReader.</translation>
</message>
</context>
<context>
<name>OptionsDialog</name>
<message>
<location filename="options_dialog.cpp" line="35"/>
<source>&quot;Go to flow&quot; size</source>
<translation>Tamanho do &quot;Ir para cheia&quot;</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="46"/>
<source>My comics path</source>
<translation>Meu caminho de quadrinhos</translation>
</message>
<message>
<source>Save</source>
<translation type="obsolete">Salvar</translation>
</message>
<message>
<source>Cancel</source>
<translation type="obsolete">Cancelar</translation>
</message>
<message>
<source>How to show pages in GoToFlow:</source>
<translation type="obsolete">Como mostrar páginas em IrParaCheia:</translation>
</message>
<message>
<source>CoverFlow look</source>
<translation type="obsolete">Olhar capa cheia</translation>
</message>
<message>
<source>Stripe look</source>
<translation type="obsolete">Olhar lista</translation>
</message>
<message>
<source>Overlapped Stripe look</source>
<translation type="obsolete">Olhar lista sobreposta</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="56"/>
<source>Page width stretch</source>
<translation>Trecho da largura da página</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="77"/>
<source>Background color</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="80"/>
<source>Choose</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="108"/>
<source>Restart is needed</source>
<translation>Reiniciar é necessário</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="121"/>
<source>Brightness</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="122"/>
<source>Contrast</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="123"/>
<source>Gamma</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="127"/>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="133"/>
<source>Image options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="143"/>
<source>General</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="144"/>
<source>Page Flow</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="145"/>
<source>Image adjustment</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="options_dialog.cpp" line="158"/>
<source>Options</source>
<translation>Opções</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="165"/>
<source>Comics directory</source>
<translation>Diretório de quadrinhos</translation>
</message>
</context>
<context>
<name>ShortcutsDialog</name>
<message>
<location filename="shortcuts_dialog.cpp" line="16"/>
<source>YACReader keyboard shortcuts</source>
<translation>Teclas de atalhos do YACReader</translation>
</message>
<message>
<location filename="shortcuts_dialog.cpp" line="20"/>
<source>Close</source>
<translation>Fechar</translation>
</message>
<message>
<location filename="shortcuts_dialog.cpp" line="66"/>
<source>Keyboard Shortcuts</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Viewer</name>
<message>
<location filename="viewer.cpp" line="43"/>
<location filename="viewer.cpp" line="634"/>
<source>Press &apos;O&apos; to open comic.</source>
<translation>Pressione &apos;O&apos; para abrir um quadrinho.</translation>
</message>
<message>
<location filename="viewer.cpp" line="183"/>
<source>Not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="viewer.cpp" line="183"/>
<source>Comic not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="viewer.cpp" line="647"/>
<source>Loading...please wait!</source>
<translation>Carregando... por favor, aguarde!</translation>
</message>
<message>
<location filename="viewer.cpp" line="773"/>
<source>Cover!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="viewer.cpp" line="780"/>
<source>Last page!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YACReaderFieldEdit</name>
<message>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="9"/>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="29"/>
<source>Click to overwrite</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="11"/>
<source>Restore to default</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YACReaderFieldPlainTextEdit</name>
<message>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="9"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="20"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="45"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="51"/>
<source>Click to overwrite</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="10"/>
<source>Restore to default</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YACReaderFlowConfigWidget</name>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="13"/>
<source>How to show covers:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="15"/>
<source>CoverFlow look</source>
<translation>Olhar capa cheia</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="16"/>
<source>Stripe look</source>
<translation>Olhar lista</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="17"/>
<source>Overlapped Stripe look</source>
<translation>Olhar lista sobreposta</translation>
</message>
</context>
<context>
<name>YACReaderGLFlowConfigWidget</name>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="19"/>
<source>Presets:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="21"/>
<source>Classic look</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="24"/>
<source>Stripe look</source>
<translation>Olhar lista</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="27"/>
<source>Overlapped Stripe look</source>
<translation>Olhar lista sobreposta</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="30"/>
<source>Modern look</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="33"/>
<source>Roulette look</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="77"/>
<source>Show advanced settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="86"/>
<source>Custom:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="89"/>
<source>View angle</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="95"/>
<source>Position</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="101"/>
<source>Cover gap</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="107"/>
<source>Central gap</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="113"/>
<source>Zoom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="119"/>
<source>Y offset</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="125"/>
<source>Z offset</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="131"/>
<source>Cover Angle</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="137"/>
<source>Visibility</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="143"/>
<source>Light</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="149"/>
<source>Max angle</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="181"/>
<source>Low Performance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="183"/>
<source>High Performance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="194"/>
<source>Use VSync (improve the image quality in fullscreen mode, worse performance)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="202"/>
<source>Performance:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YACReaderOptionsDialog</name>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="21"/>
<source>Save</source>
<translation>Salvar</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="22"/>
<source>Cancel</source>
<translation>Cancelar</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="30"/>
<source>Use hardware acceleration (restart needed)</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

772
YACReader/yacreader_ru.ts Normal file
View File

@ -0,0 +1,772 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="ru_RU" sourcelanguage="ru">
<context>
<name>BookmarksDialog</name>
<message>
<location filename="bookmarks_dialog.cpp" line="25"/>
<source>Lastest Page</source>
<translation>Последняя Страница</translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="66"/>
<source>Close</source>
<translation>Закрыть</translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="74"/>
<source>Click on any image to go to the bookmark</source>
<translation>Нажмите на любое изображение, чтобы перейти к закладке</translation>
</message>
<message>
<location filename="bookmarks_dialog.cpp" line="92"/>
<location filename="bookmarks_dialog.cpp" line="116"/>
<source>Loading...</source>
<translation>Загрузка...</translation>
</message>
</context>
<context>
<name>Configuration</name>
<message>
<location filename="configuration.cpp" line="167"/>
<source>Saving config file....</source>
<translation>Сохраняется конфигурация...</translation>
</message>
<message>
<location filename="configuration.cpp" line="167"/>
<source>There was a problem saving YACReader configuration. Please, check if you have enough permissions in the YACReader root folder.</source>
<translation>Возникла проблема с сохранением конфигурации YACReader. Пожалуйста, проверьте есть ли у вас права доступа к корневой папке YACReader.</translation>
</message>
</context>
<context>
<name>FileComic</name>
<message>
<location filename="comic.cpp" line="216"/>
<source>Not found</source>
<translation>Не найдено</translation>
</message>
<message>
<location filename="comic.cpp" line="216"/>
<source>Comic not found</source>
<translation>Комикс не найден</translation>
</message>
<message>
<location filename="comic.cpp" line="243"/>
<source>File error</source>
<translation>Ощибка файла</translation>
</message>
<message>
<location filename="comic.cpp" line="243"/>
<source>File not found or not images in file</source>
<translation>Не найден файл или изображения </translation>
</message>
<message>
<location filename="comic.cpp" line="297"/>
<source>7z not found</source>
<translation>7z не найден</translation>
</message>
<message>
<location filename="comic.cpp" line="297"/>
<source>7z wasn&apos;t found in your PATH.</source>
<translation>7z не был найден в указанном пути.</translation>
</message>
<message>
<location filename="comic.cpp" line="300"/>
<source>7z crashed</source>
<translation>7z повреждён</translation>
</message>
<message>
<location filename="comic.cpp" line="300"/>
<source>7z crashed.</source>
<translation>7z повреждён.</translation>
</message>
<message>
<location filename="comic.cpp" line="303"/>
<source>7z reading</source>
<translation>7z просматривается</translation>
</message>
<message>
<location filename="comic.cpp" line="303"/>
<source>problem reading from 7z</source>
<translation>Проблема просмотра с 7z</translation>
</message>
<message>
<location filename="comic.cpp" line="306"/>
<source>7z problem</source>
<translation>7z проблема</translation>
</message>
<message>
<location filename="comic.cpp" line="306"/>
<source>Unknown error 7z</source>
<translation>Неизестная ошибка 7z</translation>
</message>
</context>
<context>
<name>GoToDialog</name>
<message>
<location filename="goto_dialog.cpp" line="17"/>
<source>Page : </source>
<translation>Страница:</translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="25"/>
<source>Go To</source>
<translation>Перейти к</translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="27"/>
<source>Cancel</source>
<translation>Отмена</translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="41"/>
<location filename="goto_dialog.cpp" line="73"/>
<source>Total pages : </source>
<translation>Общее количеств страниц:</translation>
</message>
<message>
<location filename="goto_dialog.cpp" line="55"/>
<source>Go to...</source>
<translation>Перейти к...</translation>
</message>
</context>
<context>
<name>GoToFlowToolBar</name>
<message>
<location filename="goto_flow_toolbar.cpp" line="44"/>
<source>Page : </source>
<translation>Страница:</translation>
</message>
</context>
<context>
<name>HelpAboutDialog</name>
<message>
<location filename="../custom_widgets/help_about_dialog.cpp" line="19"/>
<source>About</source>
<translation>О программе</translation>
</message>
<message>
<location filename="../custom_widgets/help_about_dialog.cpp" line="22"/>
<source>Help</source>
<translation>Справка</translation>
</message>
</context>
<context>
<name>MainWindowViewer</name>
<message>
<location filename="main_window_viewer.cpp" line="135"/>
<source>&amp;Open</source>
<translation>&amp;Открыть</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="136"/>
<source>O</source>
<translation>О</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="138"/>
<source>Open a comic</source>
<translation>Открыть комикс</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="141"/>
<source>Open Folder</source>
<translation>Открыть папку</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="142"/>
<source>Ctrl+O</source>
<translation>Ctrl+О</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="144"/>
<source>Open image folder</source>
<translation>Открыть папку с изображениями</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="147"/>
<source>Save</source>
<translation>Сохранить</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="149"/>
<location filename="main_window_viewer.cpp" line="483"/>
<source>Save current page</source>
<translation>Сохранить нынешнюю страницу</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="153"/>
<source>Previous Comic</source>
<translation>Предыдущий комикс</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="156"/>
<source>Open previous comic</source>
<translation>Открыть предыдуший комикс</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="160"/>
<source>Next Comic</source>
<translation>Следующий комикс</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="163"/>
<source>Open next comic</source>
<translation>Открыть следующий комикс</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="167"/>
<source>&amp;Previous</source>
<translation>&amp;Предыдущий</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="170"/>
<source>Go to previous page</source>
<translation>Перейти к предыдущей странице</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="174"/>
<source>&amp;Next</source>
<translation>&amp;Следующий</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="177"/>
<source>Go to next page</source>
<translation>Перейти к следующей странице</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="181"/>
<source>Fit Width</source>
<translation>Подогнать ширину</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="182"/>
<source>A</source>
<translation>А</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="187"/>
<source>Fit image to ...</source>
<translation>Подогнать изображение для ...</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="191"/>
<source>Rotate image to the left</source>
<translation>Повернуть изображение против часовой стрелки</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="192"/>
<source>L</source>
<translation>L</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="197"/>
<source>Rotate image to the right</source>
<translation>Повернуть изображение по часовой стрелке</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="198"/>
<source>R</source>
<translation>R</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="203"/>
<source>Double page mode</source>
<translation>Двойной режим страницы</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="204"/>
<source>Switch to double page mode</source>
<translation>Переключить на двойной режим страницы</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="205"/>
<source>D</source>
<translation>D</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="212"/>
<source>Go To</source>
<translation>Перейти к</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="213"/>
<source>G</source>
<translation>G</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="216"/>
<source>Go to page ...</source>
<translation>Перейти к странице ...</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="219"/>
<source>Options</source>
<translation>Настройки</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="220"/>
<source>C</source>
<translation>С</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="221"/>
<source>YACReader options</source>
<translation>Настройки YACReader</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="226"/>
<source>Help</source>
<translation>Справка</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="227"/>
<source>Help, About YACReader</source>
<translation>Справка по YACReader</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="232"/>
<source>Magnifying glass</source>
<translation>Увеличительное стекло</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="233"/>
<source>Switch Magnifying glass</source>
<translation>Переключиться на увеличительное стекло</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="234"/>
<source>Z</source>
<translation>Z</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="240"/>
<source>Set bookmark</source>
<translation>Установить закладку</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="241"/>
<source>Set a bookmark on the current page</source>
<translation>Установить закладку на текущей странице</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="250"/>
<source>Show bookmarks</source>
<translation>Показать закладки</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="251"/>
<source>Show the bookmarks of the current comic</source>
<translation>Показать закладки текущего комикса</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="252"/>
<source>M</source>
<translation>M</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="257"/>
<source>Show keyboard shortcuts</source>
<translation>Показать горячие клавиши</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="261"/>
<source>Show Info</source>
<translation>Показать информацию</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="262"/>
<source>I</source>
<translation>I</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="267"/>
<source>Close</source>
<translation>Закрыть</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="272"/>
<source>Show Dictionary</source>
<translation>Показать словарь</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="279"/>
<source>Always on top</source>
<translation>Всегда сверху</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="287"/>
<source>Show full size</source>
<translation>Полноэкранный режим</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="298"/>
<source>&amp;File</source>
<translation>&amp;Файл</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="435"/>
<source>Open Comic</source>
<translation>Открыть комикс</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="435"/>
<source>Comic files</source>
<translation>Файлы комикса</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="459"/>
<source>Open folder</source>
<translation>Открыть папку</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="483"/>
<source>Image files (*.jpg)</source>
<translation>Файлы изображений</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="627"/>
<source>There is a new version avaliable</source>
<translation>Доступно новое обновление</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="628"/>
<source>Do you want to download the new version?</source>
<translation>Хотите загрузить новую версию ?</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="693"/>
<source>Saving error log file....</source>
<translation>Сохранение файла с логом ошибки...</translation>
</message>
<message>
<location filename="main_window_viewer.cpp" line="693"/>
<source>There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder.</source>
<translation>Возникла проблема с сохраниением файла лога YACReader. Пожалуйста, проверьте есть ли у вас права доступа к корневой папке YACReader.</translation>
</message>
</context>
<context>
<name>OptionsDialog</name>
<message>
<location filename="options_dialog.cpp" line="35"/>
<source>&quot;Go to flow&quot; size</source>
<translation>Перейти к исходному размеру</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="46"/>
<source>My comics path</source>
<translation>Путь комикса</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="56"/>
<source>Page width stretch</source>
<translation>Растянуть страницу в ширину</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="77"/>
<source>Background color</source>
<translation>Фоновый цвет</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="80"/>
<source>Choose</source>
<translation>Выбрать</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="108"/>
<source>Restart is needed</source>
<translation>Необходима перезагрузка</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="121"/>
<source>Brightness</source>
<translation>Яркость</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="122"/>
<source>Contrast</source>
<translation>Контраст</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="123"/>
<source>Gamma</source>
<translation>Гамма</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="127"/>
<source>Reset</source>
<translation>Перезапуск</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="133"/>
<source>Image options</source>
<translation>Настройки изображения</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="143"/>
<source>General</source>
<translation>Общее</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="144"/>
<source>Page Flow</source>
<translation>Страница потока</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="145"/>
<source>Image adjustment</source>
<translation>Регулировки изображения</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="158"/>
<source>Options</source>
<translation>Настройки</translation>
</message>
<message>
<location filename="options_dialog.cpp" line="165"/>
<source>Comics directory</source>
<translation>Каталог комиксов</translation>
</message>
</context>
<context>
<name>ShortcutsDialog</name>
<message>
<location filename="shortcuts_dialog.cpp" line="16"/>
<source>YACReader keyboard shortcuts</source>
<translation>Клавиатурные комбинации YACReader</translation>
</message>
<message>
<location filename="shortcuts_dialog.cpp" line="20"/>
<source>Close</source>
<translation>Закрыть</translation>
</message>
<message>
<location filename="shortcuts_dialog.cpp" line="66"/>
<source>Keyboard Shortcuts</source>
<translation>Клавиатурные комбинации</translation>
</message>
</context>
<context>
<name>Viewer</name>
<message>
<location filename="viewer.cpp" line="43"/>
<location filename="viewer.cpp" line="634"/>
<source>Press &apos;O&apos; to open comic.</source>
<translation>Нажмите &quot;O&quot; , чтобы открыть комикс.</translation>
</message>
<message>
<location filename="viewer.cpp" line="183"/>
<source>Not found</source>
<translation>Не найдено</translation>
</message>
<message>
<location filename="viewer.cpp" line="183"/>
<source>Comic not found</source>
<translation>Комикс не найден</translation>
</message>
<message>
<location filename="viewer.cpp" line="647"/>
<source>Loading...please wait!</source>
<translation>Загрузка ... Пожалуйста подождите!</translation>
</message>
<message>
<location filename="viewer.cpp" line="773"/>
<source>Cover!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="viewer.cpp" line="780"/>
<source>Last page!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>YACReaderFieldEdit</name>
<message>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="9"/>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="29"/>
<source>Click to overwrite</source>
<translation>Нажмите, чтобы переписать</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_field_edit.cpp" line="11"/>
<source>Restore to default</source>
<translation>Вернуть начальные установки</translation>
</message>
</context>
<context>
<name>YACReaderFieldPlainTextEdit</name>
<message>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="9"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="20"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="45"/>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="51"/>
<source>Click to overwrite</source>
<translation>Нажмите, чтобы переписать</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_field_plain_text_edit.cpp" line="10"/>
<source>Restore to default</source>
<translation>Вернуть начальные установки</translation>
</message>
</context>
<context>
<name>YACReaderFlowConfigWidget</name>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="13"/>
<source>How to show covers:</source>
<translation>Как показать обложки:</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="15"/>
<source>CoverFlow look</source>
<translation>Предосмотр обложки</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="16"/>
<source>Stripe look</source>
<translation>Вид полосами</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_flow_config_widget.cpp" line="17"/>
<source>Overlapped Stripe look</source>
<translation>Вид перекрывающимися полосами</translation>
</message>
</context>
<context>
<name>YACReaderGLFlowConfigWidget</name>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="19"/>
<source>Presets:</source>
<translation>Предустановки:</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="21"/>
<source>Classic look</source>
<translation>Классический вид</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="24"/>
<source>Stripe look</source>
<translation>Вид полосами</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="27"/>
<source>Overlapped Stripe look</source>
<translation>Вид перекрывающимися полосами</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="30"/>
<source>Modern look</source>
<translation>Современный вид</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="33"/>
<source>Roulette look</source>
<translation>Вид рулеткой</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="77"/>
<source>Show advanced settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="86"/>
<source>Custom:</source>
<translation>Пользовательский:</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="89"/>
<source>View angle</source>
<translation>Угол зрения</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="95"/>
<source>Position</source>
<translation>Позиция</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="101"/>
<source>Cover gap</source>
<translation>Осветить разрыв</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="107"/>
<source>Central gap</source>
<translation>Сфокусировать разрыв</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="113"/>
<source>Zoom</source>
<translation>Масштабировать</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="119"/>
<source>Y offset</source>
<translation>Смещение по Y</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="125"/>
<source>Z offset</source>
<translation>Смещение по Z</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="131"/>
<source>Cover Angle</source>
<translation>Охватить угол</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="137"/>
<source>Visibility</source>
<translation>Прозрачность</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="143"/>
<source>Light</source>
<translation>Осветить</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="149"/>
<source>Max angle</source>
<translation>Максимальный угол</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="181"/>
<source>Low Performance</source>
<translation>Минимальная производительность</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="183"/>
<source>High Performance</source>
<translation>Максимальная производительность</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="194"/>
<source>Use VSync (improve the image quality in fullscreen mode, worse performance)</source>
<translation>Использовать VSync (повысить формат изображения в полноэкранном режиме , хуже производительность)</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_gl_flow_config_widget.cpp" line="202"/>
<source>Performance:</source>
<translation>Производительность:</translation>
</message>
</context>
<context>
<name>YACReaderOptionsDialog</name>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="21"/>
<source>Save</source>
<translation>Сохранить</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="22"/>
<source>Cancel</source>
<translation>Отмена</translation>
</message>
<message>
<location filename="../custom_widgets/yacreader_options_dialog.cpp" line="30"/>
<source>Use hardware acceleration (restart needed)</source>
<translation>Использовать аппаратное ускорение (Требуется перезагрузка)</translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,137 @@
######################################################################
# Automatically generated by qmake (2.01a) dom 12. oct 20:47:48 2008
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
INCLUDEPATH += ../common \
./server \
./db \
../YACReader \
../custom_widgets
DEFINES += SERVER_RELEASE
win32 {
INCLUDEPATH += ../dependencies/poppler/include
LIBS += -L../dependencies/poppler/lib -lpoppler-qt4
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
}
unix:!macx{
INCLUDEPATH += /usr/include/poppler/qt4
LIBS += -L/usr/lib -lpoppler-qt4
LIBS += -lGLU
}
macx{
#INCLUDEPATH += "/Volumes/Mac OS X Lion/usr/X11/include"
INCLUDEPATH += /usr/local/include/poppler/qt4
LIBS += -L/usr/local/lib -lpoppler-qt4
}
CONFIG += release
CONFIG -= flat
QT += sql network opengl
# Input
HEADERS += comic_flow.h \
create_library_dialog.h \
library_creator.h \
library_window.h \
add_library_dialog.h \
rename_library_dialog.h \
properties_dialog.h \
options_dialog.h \
export_library_dialog.h \
import_library_dialog.h \
package_manager.h \
bundle_creator.h \
export_comics_info_dialog.h \
import_comics_info_dialog.h \
server_config_dialog.h \
comic_flow_widget.h \
db_helper.h \
./db/data_base_management.h \
./db/treeitem.h \
./db/treemodel.h \
./db/tablemodel.h \
./db/tableitem.h \
./db/comic_db.h \
./db/folder.h \
./db/library_item.h \
../YACReader/comic.h \
../YACReader/bookmarks.h \
../common/pictureflow.h \
../common/custom_widgets.h \
../common/qnaturalsorting.h \
../common/yacreader_flow_gl.h \
../common/yacreader_global.h \
../common/onstart_flow_selection_dialog.h \
no_libraries_widget.h \
import_widget.h \
yacreader_local_server.h \
../common/yacreader_comic_library.h \
../common/yacreader_comic_info_library.h
SOURCES += comic_flow.cpp \
create_library_dialog.cpp \
library_creator.cpp \
library_window.cpp \
main.cpp \
add_library_dialog.cpp \
rename_library_dialog.cpp \
properties_dialog.cpp \
options_dialog.cpp \
export_library_dialog.cpp \
import_library_dialog.cpp \
package_manager.cpp \
bundle_creator.cpp \
export_comics_info_dialog.cpp \
import_comics_info_dialog.cpp \
server_config_dialog.cpp \
comic_flow_widget.cpp \
db_helper.cpp \
./db/data_base_management.cpp \
./db/treeitem.cpp \
./db/treemodel.cpp \
./db/tablemodel.cpp \
./db/tableitem.cpp \
./db/comic_db.cpp \
./db/folder.cpp \
./db/library_item.cpp \
../YACReader/comic.cpp \
../YACReader/bookmarks.cpp \
../common/pictureflow.cpp \
../common/custom_widgets.cpp \
../common/qnaturalsorting.cpp \
../common/yacreader_flow_gl.cpp \
../common/onstart_flow_selection_dialog.cpp \
no_libraries_widget.cpp \
import_widget.cpp \
yacreader_local_server.cpp \
../common/yacreader_comic_library.cpp \
../common/yacreader_comic_info_library.cpp
include(./server/server.pri)
include(../custom_widgets/custom_widgets.pri)
RESOURCES += images.qrc files.qrc
RC_FILE = icon.rc
macx {
ICON = YACReaderLibrary.icns
}
TRANSLATIONS = yacreaderlibrary_es.ts \
yacreaderlibrary_ru.ts \
yacreaderlibrary_pt.ts
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug

View File

@ -0,0 +1,125 @@
#include "add_library_dialog.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QGridLayout>
AddLibraryDialog::AddLibraryDialog(QWidget * parent)
:QDialog(parent)
{
setupUI();
}
void AddLibraryDialog::setupUI()
{
textLabel = new QLabel(tr("Comics folder : "));
path = new QLineEdit;
textLabel->setBuddy(path);
connect(path,SIGNAL(textChanged(QString)),this,SLOT(pathSetted(QString)));
nameLabel = new QLabel(tr("Library Name : "));
nameEdit = new QLineEdit;
nameLabel->setBuddy(nameEdit);
connect(nameEdit,SIGNAL(textChanged(QString)),this,SLOT(nameSetted(QString)));
accept = new QPushButton(tr("Add"));
accept->setDisabled(true);
connect(accept,SIGNAL(clicked()),this,SLOT(add()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
find = new QPushButton(QIcon(":/images/comicFolder.png"),"");
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
QGridLayout * content = new QGridLayout;
content->addWidget(nameLabel,0,0);
content->addWidget(nameEdit,0,1);
content->addWidget(textLabel,1,0);
content->addWidget(path,1,1);
content->addWidget(find,1,2);
content->setColumnStretch(2,0);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(content);
mainLayout->addStretch();
mainLayout->addLayout(bottomLayout);
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/openLibrary.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);//,0,Qt::AlignTop);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setModal(true);
setWindowTitle(tr("Add an existing library"));
}
void AddLibraryDialog::add()
{
//accept->setEnabled(false);
emit(addLibrary(QDir::cleanPath(path->text()),nameEdit->text()));
close();
}
void AddLibraryDialog::nameSetted(const QString & text)
{
if(!text.isEmpty())
{
if(!path->text().isEmpty())
{
QFileInfo fi(path->text());
if(fi.isDir())
accept->setEnabled(true);
else
accept->setEnabled(false);
}
}
else
accept->setEnabled(false);
}
void AddLibraryDialog::pathSetted(const QString & text)
{
QFileInfo fi(text);
if(fi.isDir())
{
if(!nameEdit->text().isEmpty())
accept->setEnabled(true);
}
else
accept->setEnabled(false);
}
void AddLibraryDialog::findPath()
{
QString s = QFileDialog::getExistingDirectory(0,"Comics directory",".");
if(!s.isEmpty())
{
path->setText(s);
if(!nameEdit->text().isEmpty())
accept->setEnabled(true);
}
else
accept->setEnabled(false);
}
void AddLibraryDialog::close()
{
path->clear();
nameEdit->clear();
accept->setEnabled(false);
QDialog::close();
}

View File

@ -0,0 +1,35 @@
#ifndef __ADD_LIBRARY_DIALOG_H
#define __ADD_LIBRARY_DIALOG_H
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QThread>
class AddLibraryDialog : public QDialog
{
Q_OBJECT
public:
AddLibraryDialog(QWidget * parent = 0);
private:
QLabel * nameLabel;
QLabel * textLabel;
QLineEdit * path;
QLineEdit * nameEdit;
QPushButton * find;
QPushButton * accept;
QPushButton * cancel;
void setupUI();
public slots:
void add();
void findPath();
void close();
void nameSetted(const QString & text);
void pathSetted(const QString & text);
signals:
void addLibrary(QString target, QString name);
};
#endif

View File

@ -0,0 +1,13 @@
#include "bundle_creator.h"
BundleCreator::BundleCreator(void)
:QObject()
{
}
BundleCreator::~BundleCreator(void)
{
}

View File

@ -0,0 +1,14 @@
#ifndef __BUNDLE_CREATOR_H
#define __BUNDLE_CREATOR_H
#include <QtCore>
class BundleCreator : public QObject
{
Q_OBJECT
public:
BundleCreator(void);
~BundleCreator(void);
};
#endif

View File

@ -0,0 +1,210 @@
#include "comic_flow.h"
#include "qnaturalsorting.h"
#include "yacreader_global.h"
#include <algorithm>
#include <QMutex>
#include <QImageReader>
#include <QTimer>
ComicFlow::ComicFlow(QWidget* parent,FlowType flowType)
:YACReaderFlow(parent,flowType)
{
updateTimer = new QTimer;
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData()));
worker = new ImageLoader;
connect(this, SIGNAL(centerIndexChanged(int)), this, SLOT(preload()));
setReflectionEffect(PlainReflection);
}
ComicFlow::~ComicFlow()
{
delete worker;
delete updateTimer;
}
void ComicFlow::setImagePaths(const QStringList& paths)
{
clear();
//imagePath = path;
imageFiles = paths;
imagesLoaded.clear();
imagesLoaded.fill(false,imageFiles.size());
numImagesLoaded = 0;
imagesSetted.clear();
imagesSetted.fill(false,imageFiles.size());
// populate with empty images
QImage img; //TODO remove
QString s;
for(int i = 0; i < (int)imageFiles.size(); i++)
{
addSlide(img);
s = imageFiles.at(i);
s.remove(s.size()-4,4);
if(QFileInfo(s+".r").exists())
markSlide(i);
}
setCenterIndex(0);
worker->reset();
preload();
}
void ComicFlow::preload()
{
if(numImagesLoaded < imagesLoaded.size())
updateTimer->start(30); //TODO comprobar rendimiento, originalmente era 70
}
void ComicFlow::updateImageData()
{
// can't do anything, wait for the next possibility
if(worker->busy())
return;
// set image of last one
int idx = worker->index();
if( idx >= 0 && !worker->result().isNull())
{
if(!imagesSetted[idx])
{
setSlide(idx, worker->result());
imagesSetted[idx] = true;
numImagesLoaded++;
imagesLoaded[idx]=true;
}
}
// try to load only few images on the left and right side
// i.e. all visible ones plus some extra
#define COUNT 8
int indexes[2*COUNT+1];
int center = centerIndex();
indexes[0] = center;
for(int j = 0; j < COUNT; j++)
{
indexes[j*2+1] = center+j+1;
indexes[j*2+2] = center-j-1;
}
for(int c = 0; c < 2*COUNT+1; c++)
{
int i = indexes[c];
if((i >= 0) && (i < slideCount()))
if(!imagesLoaded[i])//slide(i).isNull())
{
// schedule thumbnail generation
QString fname = imageFiles[i];
worker->generate(i, fname, slideSize());
return;
}
}
// no need to generate anything? stop polling...
updateTimer->stop();
}
void ComicFlow::keyPressEvent(QKeyEvent* event)
{
PictureFlow::keyPressEvent(event);
}
void ComicFlow::wheelEvent(QWheelEvent * event)
{
if(event->delta()<0)
showNext();
else
showPrevious();
event->accept();
}
//-----------------------------------------------------------------------------
//ImageLoader
//-----------------------------------------------------------------------------
static QImage loadImage(const QString& fileName)
{
QImage image;
bool result = image.load(fileName);
if(!result)
return QImage();
return image;
}
ImageLoader::ImageLoader():
QThread(), restart(false), working(false), idx(-1)
{
}
ImageLoader::~ImageLoader()
{
mutex.lock();
condition.wakeOne();
mutex.unlock();
wait();
}
bool ImageLoader::busy() const
{
return isRunning() ? working : false;
}
void ImageLoader::generate(int index, const QString& fileName, QSize size)
{
mutex.lock();
this->idx = index;
this->fileName = fileName;
this->size = size;
this->img = QImage();
mutex.unlock();
if (!isRunning())
start();
else
{
// already running, wake up whenever ready
restart = true;
condition.wakeOne();
}
}
void ImageLoader::run()
{
for(;;)
{
// copy necessary data
mutex.lock();
this->working = true;
QString fileName = this->fileName;
mutex.unlock();
QImage image = loadImage(fileName);
// let everyone knows it is ready
mutex.lock();
this->working = false;
this->img = image;
mutex.unlock();
// put to sleep
mutex.lock();
if (!this->restart)
condition.wait(&mutex);
restart = false;
mutex.unlock();
}
}
QImage ImageLoader::result()
{
return img;
}

View File

@ -0,0 +1,74 @@
#ifndef __COMICFLOW_H
#define __COMICFLOW_H
#include "yacreader_flow.h"
#include <QtCore>
#include <QObject>
#include <QThread>
#include <QImage>
#include <QMutex>
#include <QWaitCondition>
#include <QString>
#include <QWheelEvent>
class ImageLoader;
class ComicFlow : public YACReaderFlow
{
Q_OBJECT
public:
ComicFlow(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
virtual ~ComicFlow();
void setImagePaths(const QStringList& paths);
//bool eventFilter(QObject *target, QEvent *event);
void keyPressEvent(QKeyEvent* event);
private slots:
void preload();
void updateImageData();
private:
//QString imagePath;
QStringList imageFiles;
QVector<bool> imagesLoaded;
QVector<bool> imagesSetted;
uint numImagesLoaded;
QTimer* updateTimer;
ImageLoader* worker;
virtual void wheelEvent(QWheelEvent * event);
};
//-----------------------------------------------------------------------------
// Source code of ImageLoader class was modified from http://code.google.com/p/photoflow/
//------------------------------------------------------------------------------
class ImageLoader : public QThread
{
public:
ImageLoader();
~ImageLoader();
// returns FALSE if worker is still busy and can't take the task
bool busy() const;
void generate(int index, const QString& fileName, QSize size);
void reset(){idx = -1;};
int index() const { return idx; };
QImage result();
protected:
void run();
private:
QMutex mutex;
QWaitCondition condition;
bool restart;
bool working;
int idx;
QString fileName;
QSize size;
QImage img;
};
#endif

View File

@ -0,0 +1,326 @@
#include "comic_flow_widget.h"
ComicFlowWidget::ComicFlowWidget(QWidget * parent)
:QWidget(parent)
{
}
ComicFlowWidgetSW::ComicFlowWidgetSW(QWidget * parent)
:ComicFlowWidget(parent)
{
flow = new ComicFlow(parent);
connect(flow,SIGNAL(centerIndexChanged(int)),this,SIGNAL(centerIndexChanged(int)));
connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(selected(unsigned int)));
QVBoxLayout * l = new QVBoxLayout;
l->addWidget(flow);
setLayout(l);
//TODO eleminar "padding"
QPalette Pal(palette());
// set black background
Pal.setColor(QPalette::Background, Qt::black);
setAutoFillBackground(true);
setPalette(Pal);
}
QSize ComicFlowWidgetSW::minimumSizeHint() const
{
return flow->minimumSizeHint();
}
QSize ComicFlowWidgetSW::sizeHint() const
{
return flow->sizeHint();
}
void ComicFlowWidgetSW::setShowMarks(bool value)
{
flow->setShowMarks(value);
}
void ComicFlowWidgetSW::setMarks(QVector<bool> marks)
{
flow->setMarks(marks);
}
void ComicFlowWidgetSW::setMarkImage(QImage & image)
{
flow->setMarkImage(image);
}
void ComicFlowWidgetSW::markSlide(int index)
{
flow->markSlide(index);
}
void ComicFlowWidgetSW::unmarkSlide(int index)
{
flow->unmarkSlide(index);
}
void ComicFlowWidgetSW::setSlideSize(QSize size)
{
flow->setSlideSize(size);
}
void ComicFlowWidgetSW::clear()
{
flow->clear();
}
void ComicFlowWidgetSW::setImagePaths(QStringList paths)
{
flow->setImagePaths(paths);
}
void ComicFlowWidgetSW::setCenterIndex(int index)
{
flow->setCenterIndex(index);
}
void ComicFlowWidgetSW::showSlide(int index)
{
flow->showSlide(index);
}
int ComicFlowWidgetSW::centerIndex()
{
return flow->centerIndex();
}
void ComicFlowWidgetSW::updateMarks()
{
flow->updateMarks();
}
void ComicFlowWidgetSW::setFlowType(FlowType flowType)
{
flow->setFlowType(flowType);
}
void ComicFlowWidgetSW::render()
{
flow->render();
}
void ComicFlowWidgetSW::keyPressEvent(QKeyEvent* event)
{
flow->keyPressEvent(event);
}
void ComicFlowWidgetSW::paintEvent(QPaintEvent *event)
{
flow->paintEvent(event);
}
void ComicFlowWidgetSW::mousePressEvent(QMouseEvent* event)
{
flow->mousePressEvent(event);
}
void ComicFlowWidgetSW::resizeEvent(QResizeEvent* event)
{
flow->resizeEvent(event);
}
void ComicFlowWidgetSW::mouseDoubleClickEvent(QMouseEvent* event)
{
flow->mouseDoubleClickEvent(event);
}
void ComicFlowWidgetSW::updateConfig(QSettings * settings)
{
switch (settings->value(FLOW_TYPE_SW).toInt())
{
case 0:
flow->setFlowType(CoverFlowLike);
return;
case 1:
flow->setFlowType(Strip);
return;
case 2:
flow->setFlowType(StripOverlapped);
return;
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
///OpenGL ComicFlow
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget * parent)
:ComicFlowWidget(parent)
{
flow = new YACReaderComicFlowGL(parent);
connect(flow,SIGNAL(centerIndexChanged(int)),this,SIGNAL(centerIndexChanged(int)));
connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(selected(unsigned int)));
QVBoxLayout * l = new QVBoxLayout;
l->addWidget(flow);
l->setContentsMargins(0,0,0,0);
setLayout(l);
//TODO eleminar "padding"
QPalette Pal(palette());
// set black background
Pal.setColor(QPalette::Background, Qt::black);
setAutoFillBackground(true);
setPalette(Pal);
}
QSize ComicFlowWidgetGL::minimumSizeHint() const
{
return flow->minimumSizeHint();
}
QSize ComicFlowWidgetGL::sizeHint() const
{
return flow->sizeHint();
}
void ComicFlowWidgetGL::setShowMarks(bool value)
{
flow->setShowMarks(value);
}
void ComicFlowWidgetGL::setMarks(QVector<bool> marks)
{
flow->setMarks(marks);
}
void ComicFlowWidgetGL::setMarkImage(QImage & image)
{
flow->setMarkImage(image);
}
void ComicFlowWidgetGL::markSlide(int index)
{
flow->markSlide(index);
}
void ComicFlowWidgetGL::unmarkSlide(int index)
{
flow->unmarkSlide(index);
}
void ComicFlowWidgetGL::setSlideSize(QSize size)
{
flow->setSlideSize(size);
}
void ComicFlowWidgetGL::clear()
{
flow->clear();
}
void ComicFlowWidgetGL::setImagePaths(QStringList paths)
{
flow->setImagePaths(paths);
}
void ComicFlowWidgetGL::setCenterIndex(int index)
{
flow->setCenterIndex(index);
}
void ComicFlowWidgetGL::showSlide(int index)
{
flow->showSlide(index);
}
int ComicFlowWidgetGL::centerIndex()
{
return flow->centerIndex();
}
void ComicFlowWidgetGL::updateMarks()
{
flow->updateMarks();
}
void ComicFlowWidgetGL::setFlowType(FlowType flowType)
{
if(flowType == CoverFlowLike)
flow->setPreset(presetYACReaderFlowClassicConfig);
else if(flowType == Strip)
flow->setPreset(presetYACReaderFlowStripeConfig);
else if(flowType == StripOverlapped)
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
else
flow->setPreset(defaultYACReaderFlowConfig);
}
void ComicFlowWidgetGL::render()
{
flow->render();
}
void ComicFlowWidgetGL::keyPressEvent(QKeyEvent* event)
{
flow->keyPressEvent(event);
}
void ComicFlowWidgetGL::paintEvent(QPaintEvent *event)
{
//flow->paintEvent(event);
}
void ComicFlowWidgetGL::mousePressEvent(QMouseEvent* event)
{
flow->mousePressEvent(event);
}
void ComicFlowWidgetGL::resizeEvent(QResizeEvent* event)
{
flow->resizeGL(event->size().width(),event->size().height());
}
void ComicFlowWidgetGL::mouseDoubleClickEvent(QMouseEvent* event)
{
flow->mouseDoubleClickEvent(event);
}
void ComicFlowWidgetGL::updateConfig(QSettings * settings)
{
Performance performance = medium;
switch (settings->value(PERFORMANCE).toInt())
{
case 0:
performance = low;
break;
case 1:
performance = medium;
break;
case 2:
performance = high;
break;
case 3:
performance = ultraHigh;
break;
}
flow->setPerformance(performance);
if(!settings->contains(V_SYNC))
flow->useVSync(false);
else
flow->useVSync(settings->value(V_SYNC).toBool());
switch (settings->value(FLOW_TYPE_GL).toInt())
{
case 0:
flow->setPreset(presetYACReaderFlowClassicConfig);
return;
case 1:
flow->setPreset(presetYACReaderFlowStripeConfig);
return;
case 2:
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
return;
case 3:
flow->setPreset(defaultYACReaderFlowConfig);
return;
case 4:
flow->setPreset(pressetYACReaderFlowDownConfig);
return;
}
//custom config
flow->setCF_RX(settings->value(X_ROTATION).toInt());
flow->setCF_Y(settings->value(Y_POSITION).toInt());
flow->setX_Distance(settings->value(COVER_DISTANCE).toInt());
flow->setCenter_Distance(settings->value(CENTRAL_DISTANCE).toInt());
flow->setCF_Z(settings->value(ZOOM_LEVEL).toInt());
flow->setY_Distance(settings->value(Y_COVER_OFFSET).toInt());
flow->setZ_Distance(settings->value(Z_COVER_OFFSET).toInt());
flow->setRotation(settings->value(COVER_ROTATION).toInt());
flow->setFadeOutDist(settings->value(FADE_OUT_DIST).toInt());
flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt());
flow->setMaxAngle(settings->value(MAX_ANGLE).toInt());
/* flow->setVisibility(settings->value("visibilityDistance").toInt());
flow->setLightStrenght(settings->value("lightStrength").toInt())*/;
}
//void ComicFlowWidgetGL::setCF_RX(int value){ flow->setCF_RX(value);}
//void ComicFlowWidgetGL::setCF_RY(int value){ flow->setCF_RY(value);}
//void ComicFlowWidgetGL::setCF_RZ(int value){ flow->setCF_RZ(value);}
//void ComicFlowWidgetGL::setZoom(int zoom){ flow->setZoom(zoom);}
//void ComicFlowWidgetGL::setRotation(int angle){ flow->setRotation(angle);}
//void ComicFlowWidgetGL::setX_Distance(int distance){ flow->setX_Distance(distance);}
//void ComicFlowWidgetGL::setCenter_Distance(int distance){ flow->setCenter_Distance(distance);}
//void ComicFlowWidgetGL::setZ_Distance(int distance){ flow->setZ_Distance(distance);}
//void ComicFlowWidgetGL::setCF_Y(int value){ flow->setCF_Y(value);}
//void ComicFlowWidgetGL::setY_Distance(int value){ flow->setY_Distance(value);}
//void ComicFlowWidgetGL::setPreset(const Preset & p){ flow->setPreset(p);}

View File

@ -0,0 +1,123 @@
#ifndef __COMIC_FLOW_WIDGET_H
#define __COMIC_FLOW_WIDGET_H
#include <QWidget>
#include "pictureflow.h"
#include "comic_flow.h"
#include "yacreader_flow_gl.h"
class ComicFlowWidget : public QWidget
{
Q_OBJECT
public:
ComicFlowWidget(QWidget * paret = 0);
public slots:
virtual void setShowMarks(bool value) = 0;
virtual void setMarks(QVector<bool> marks) = 0;
virtual void setMarkImage(QImage & image) = 0;
virtual void markSlide(int index) = 0;
virtual void unmarkSlide(int index) = 0;
virtual void setSlideSize(QSize size) = 0;
virtual void clear() = 0;
virtual void setImagePaths(QStringList paths) = 0;
virtual void setCenterIndex(int index) = 0;
virtual void showSlide(int index) = 0;
virtual int centerIndex() = 0;
virtual void updateMarks() = 0;
virtual void setFlowType(FlowType flowType) = 0;
virtual void render() = 0;
virtual void updateConfig(QSettings * settings) = 0;
signals:
void centerIndexChanged(int);
void selected(unsigned int);
};
class ComicFlowWidgetSW : public ComicFlowWidget
{
Q_OBJECT
private:
ComicFlow * flow;
public:
ComicFlowWidgetSW(QWidget * parent = 0);
void setShowMarks(bool value);
void setMarks(QVector<bool> marks);
void setMarkImage(QImage & image);
void markSlide(int index);
void unmarkSlide(int index);
void setSlideSize(QSize size);
void clear();
void setImagePaths(QStringList paths);
void setCenterIndex(int index);
void showSlide(int index);
int centerIndex();
void updateMarks();
void setFlowType(FlowType flowType);
void render();
void updateConfig(QSettings * settings);
protected:
void keyPressEvent(QKeyEvent* event);
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent* event);
void resizeEvent(QResizeEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
QSize minimumSizeHint() const;
QSize sizeHint() const;
};
class ComicFlowWidgetGL : public ComicFlowWidget
{
Q_OBJECT
private:
YACReaderComicFlowGL * flow;
public:
ComicFlowWidgetGL(QWidget * parent = 0);
void setShowMarks(bool value);
void setMarks(QVector<bool> marks);
void setMarkImage(QImage & image);
void markSlide(int index);
void unmarkSlide(int index);
void setSlideSize(QSize size);
void clear();
void setImagePaths(QStringList paths);
void setCenterIndex(int index);
void showSlide(int index);
int centerIndex();
void updateMarks();
void setFlowType(FlowType flowType);
void render();
void updateConfig(QSettings * settings);
//public slots:
// void setCF_RX(int value);
// //the Y Rotation of the Coverflow
// void setCF_RY(int value);
// //the Z Rotation of the Coverflow
// void setCF_RZ(int value);
// //perspective
// void setZoom(int zoom);
// void setRotation(int angle);
// //sets the distance between the covers
// void setX_Distance(int distance);
// //sets the distance between the centered and the non centered covers
// void setCenter_Distance(int distance);
// //sets the pushback amount
// void setZ_Distance(int distance);
// void setCF_Y(int value);
// void setY_Distance(int value);
// void setPreset(const Preset & p);
protected:
void keyPressEvent(QKeyEvent* event);
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent* event);
void resizeEvent(QResizeEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
QSize minimumSizeHint() const;
QSize sizeHint() const;
};
#endif

View File

@ -0,0 +1,235 @@
#include "create_library_dialog.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QSizePolicy>
#include <QMessageBox>
CreateLibraryDialog::CreateLibraryDialog(QWidget * parent)
:QDialog(parent)
{
setupUI();
}
void CreateLibraryDialog::setupUI()
{
textLabel = new QLabel(tr("Comics folder : "));
path = new QLineEdit;
textLabel->setBuddy(path);
connect(path,SIGNAL(textChanged(QString)),this,SLOT(pathSetted(QString)));
nameLabel = new QLabel(tr("Library Name : "));
nameEdit = new QLineEdit;
nameLabel->setBuddy(nameEdit);
connect(nameEdit,SIGNAL(textChanged(QString)),this,SLOT(nameSetted(QString)));
accept = new QPushButton(tr("Create"));
accept->setDisabled(true);
connect(accept,SIGNAL(clicked()),this,SLOT(create()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SIGNAL(cancelCreate()));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
find = new QPushButton(QIcon(":/images/comicFolder.png"),"");
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
QGridLayout * content = new QGridLayout;
//QHBoxLayout *nameLayout = new QHBoxLayout;
content->addWidget(nameLabel,0,0);
content->addWidget(nameEdit,0,1);
//QHBoxLayout *libraryLayout = new QHBoxLayout;
content->addWidget(textLabel,1,0);
content->addWidget(path,1,1);
content->addWidget(find,1,2);
content->setColumnMinimumWidth(2,0); //TODO
QHBoxLayout *middleLayout = new QHBoxLayout;
progressBar = new QProgressBar(this);
progressBar->setMinimum(0);
progressBar->setMaximum(0);
progressBar->setTextVisible(false);
progressBar->hide();
currentFileLabel = new QLabel("");
currentFileLabel->setWordWrap(true);
middleLayout->addWidget(currentFileLabel);
middleLayout->addStretch();
middleLayout->setSizeConstraint(QLayout::SetMaximumSize);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addWidget(message = new QLabel(tr("Create a library could take several minutes. You can stop the process and update the library later for completing the task.")));
message->setWordWrap(true);
//message->hide();
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(content);
mainLayout->addLayout(middleLayout);
mainLayout->addStretch();
mainLayout->addWidget(progressBar);
mainLayout->addLayout(bottomLayout);
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/new.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setModal(true);
setWindowTitle(tr("Create new library"));
}
void CreateLibraryDialog::create()
{
QFileInfo f(path->text());
if(f.exists() && f.isDir() && f.isWritable())
{
progressBar->show();
message->show();
currentFileLabel->setText("Importing : \n\n\n\n\n");
this->adjustSize();
accept->setEnabled(false);
emit(createLibrary(QDir::cleanPath(path->text()),QDir::cleanPath(path->text())+"/.yacreaderlibrary",nameEdit->text()));
close();
}
else
QMessageBox::critical(NULL,tr("Path not found"),tr("The selected path does not exist or is not a valid path. Be sure that you have write access to this folder"));
}
void CreateLibraryDialog::showCurrentFile(QString file)
{
currentFileLabel->setText(tr("Importing : \n") + file);
currentFileLabel->update();
//this->adjustSize();
//is->update();
}
void CreateLibraryDialog::nameSetted(const QString & text)
{
if(!text.isEmpty())
{
if(!path->text().isEmpty())
{
QFileInfo fi(path->text());
if(fi.isDir())
accept->setEnabled(true);
else
accept->setEnabled(false);
}
}
else
accept->setEnabled(false);
}
void CreateLibraryDialog::pathSetted(const QString & text)
{
QFileInfo fi(text);
if(fi.isDir())
{
if(!nameEdit->text().isEmpty())
accept->setEnabled(true);
}
else
accept->setEnabled(false);
}
void CreateLibraryDialog::findPath()
{
QString s = QFileDialog::getExistingDirectory(0,"Comics directory",".");
if(!s.isEmpty())
{
path->setText(s);
if(!nameEdit->text().isEmpty())
accept->setEnabled(true);
}
else
accept->setEnabled(false);
}
void CreateLibraryDialog::close()
{
progressBar->hide();
path->clear();
nameEdit->clear();
currentFileLabel->setText("");
this->adjustSize();
accept->setEnabled(false);
QDialog::close();
}
void CreateLibraryDialog::setDataAndStart(QString name, QString path)
{
this->path->setText(path);
this->nameEdit->setText(name);
show();
create();
}
//-----------------------------------------------------------------------------
// UpdateLibraryDialog
//-----------------------------------------------------------------------------
UpdateLibraryDialog::UpdateLibraryDialog(QWidget * parent)
:QDialog(parent)
{
QVBoxLayout * mainLayout = new QVBoxLayout;
mainLayout->addWidget(message = new QLabel(tr("Updating....")));
mainLayout->addWidget(currentFileLabel = new QLabel("\n\n\n\n"));
currentFileLabel->setWordWrap(true);
QHBoxLayout * bottom = new QHBoxLayout;
bottom->addStretch();
bottom->addWidget(cancel = new QPushButton(tr("Cancel")));
connect(cancel,SIGNAL(clicked()),this,SIGNAL(cancelUpdate()));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
mainLayout->addStretch();
progressBar = new QProgressBar(this);
progressBar->setMinimum(0);
progressBar->setMaximum(0);
progressBar->setTextVisible(false);
mainLayout->addWidget(progressBar);
mainLayout->addLayout(bottom);
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/updateLibrary.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setModal(true);
setWindowTitle(tr("Update library"));
}
void UpdateLibraryDialog::showCurrentFile(QString file)
{
currentFileLabel->setText(file);
currentFileLabel->update();
this->update();
}
void UpdateLibraryDialog::close()
{
currentFileLabel->setText("");
this->adjustSize();
QDialog::close();
}

View File

@ -0,0 +1,58 @@
#ifndef __CREATE_LIBRARY_DIALOG_H
#define __CREATE_LIBRARY_DIALOG_H
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QThread>
#include <QProgressBar>
class CreateLibraryDialog : public QDialog
{
Q_OBJECT
public:
CreateLibraryDialog(QWidget * parent = 0);
private:
QLabel * nameLabel;
QLabel * textLabel;
QLabel * message;
QProgressBar *progressBar;
QLabel * currentFileLabel;
QLineEdit * path;
QLineEdit * nameEdit;
QPushButton * find;
QPushButton * accept;
QPushButton * cancel;
void setupUI();
public slots:
void create();
void findPath();
void showCurrentFile(QString file);
void close();
void setDataAndStart(QString name, QString paht);
void nameSetted(const QString & text);
void pathSetted(const QString & text);
signals:
void createLibrary(QString source, QString target, QString name);
void cancelCreate();
};
class UpdateLibraryDialog : public QDialog
{
Q_OBJECT
public:
UpdateLibraryDialog(QWidget * parent = 0);
private:
QLabel * message;
QLabel * currentFileLabel;
QProgressBar *progressBar;
QPushButton * cancel;
public slots:
void showCurrentFile(QString file);
void close();
signals:
void cancelUpdate();
};
#endif

View File

@ -0,0 +1,750 @@
#include "comic_db.h"
#include <QSqlQuery>
#include <QSqlRecord>
#include <QVariant>
//-----------------------------------------------------------------------------
//COMIC------------------------------------------------------------------------
//-----------------------------------------------------------------------------
ComicDB::ComicDB()
{
}
ComicDB::ComicDB(qulonglong cparentId, QString cname, QString cpath, QString chash, QSqlDatabase & database)
{
parentId = cparentId;
name = cname;
path = cpath;
if(!info.load(chash,database))
{
info.hash = chash;
info.coverPage = new int(1);
_hasCover = false;
}
else
_hasCover = true;
}
QList<LibraryItem *> ComicDB::getComicsFromParent(qulonglong parentId, QSqlDatabase & db, bool sort)
{
QList<LibraryItem *> list;
QSqlQuery selectQuery(db);
selectQuery.prepare("select c.id,c.parentId,c.fileName,c.path,ci.hash from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId");
selectQuery.bindValue(":parentId", parentId);
selectQuery.exec();
ComicDB * currentItem;
while (selectQuery.next())
{
QList<QVariant> data;
QSqlRecord record = selectQuery.record();
for(int i=0;i<record.count();i++)
data << record.value(i);
currentItem = new ComicDB();
currentItem->id = record.value("id").toULongLong();
currentItem->parentId = record.value(1).toULongLong();
currentItem->name = record.value(2).toString();
currentItem->path = record.value(3).toString();
currentItem->info.load(record.value(4).toString(),db);
int lessThan = 0;
if(list.isEmpty() || !sort)
list.append(currentItem);
else
{
ComicDB * last = static_cast<ComicDB *>(list.back());
QString nameLast = last->name;
QString nameCurrent = currentItem->name;
QList<LibraryItem *>::iterator i;
i = list.end();
i--;
while ((0 > (lessThan = nameCurrent.localeAwareCompare(nameLast))) && i != list.begin()) //se usa la misma ordenaci<63>n que en QDir
{
i--;
nameLast = (*i)->name;
}
if(lessThan>0) //si se ha encontrado un elemento menor que current, se inserta justo despu<70>s
list.insert(++i,currentItem);
else
list.insert(i,currentItem);
}
}
//selectQuery.finish();
return list;
}
bool ComicDB::load(qulonglong idc, QSqlDatabase & db)
{
QSqlQuery selectQuery(db);
selectQuery.prepare("select c.id,c.parentId,c.fileName,c.path,ci.hash from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.id = :id");
selectQuery.bindValue(":id", idc);
selectQuery.exec();
this->id = idc;
if(selectQuery.next())
{
QSqlRecord record = selectQuery.record();
//id = record.value("id").toULongLong();
parentId = record.value("parentId").toULongLong();
name = record.value("name").toString();
path = record.value("path").toString();
info.load(record.value("hash").toString(),db);
return true;
}
//selectQuery.finish();
return false;
}
qulonglong ComicDB::insert(QSqlDatabase & db)
{
//TODO cambiar por info.insert(db)
if(!info.existOnDb)
{
QSqlQuery comicInfoInsert(db);
comicInfoInsert.prepare("INSERT INTO comic_info (hash,numPages) "
"VALUES (:hash,:numPages)");
comicInfoInsert.bindValue(":hash", info.hash);
comicInfoInsert.bindValue(":numPages", *info.numPages);
comicInfoInsert.exec();
info.id =comicInfoInsert.lastInsertId().toULongLong();
_hasCover = false;
}
else
_hasCover = true;
QSqlQuery query(db);
query.prepare("INSERT INTO comic (parentId, comicInfoId, fileName, path) "
"VALUES (:parentId,:comicInfoId,:name, :path)");
query.bindValue(":parentId", parentId);
query.bindValue(":comicInfoId", info.id);
query.bindValue(":name", name);
query.bindValue(":path", path);
query.exec();
return query.lastInsertId().toULongLong();
}
void ComicDB::update(QSqlDatabase & db)
{
}
void ComicDB::removeFromDB(QSqlDatabase & db)
{
QSqlQuery query(db);
query.prepare("DELETE FROM comic WHERE id = :id");
query.bindValue(":id", id);
query.exec();
//query.finish();
}
bool ComicDB::isDir()
{
return false;
}
QString ComicDB::toTXT()
{
QString txt;
//Legacy info
txt.append(QString("comicid:%1\r\n").arg(id));
txt.append(QString("hash:%1\r\n").arg(info.hash));
txt.append(QString("path:%1\r\n").arg(path));
txt.append(QString("numpages:%1\r\n").arg(*info.numPages));
//Informaci<63>n general
if(info.coverPage != NULL)
txt.append(QString("coverPage:%1\r\n").arg(*info.coverPage));
if(info.title != NULL)
txt.append(QString("title:%1\r\n").arg(*info.title));
if(info.number != NULL)
txt.append(QString("number:%1\r\n").arg(*info.number));
if(info.isBis != NULL)
txt.append(QString("isBis:%1\r\n").arg(*info.isBis));
if(info.count != NULL)
txt.append(QString("count:%1\r\n").arg(*info.count));
if(info.volume != NULL)
txt.append(QString("volume:%1\r\n").arg(*info.volume));
if(info.storyArc != NULL)
txt.append(QString("storyArc:%1\r\n").arg(*info.storyArc));
if(info.arcNumber != NULL)
txt.append(QString("arcNumber:%1\r\n").arg(*info.arcNumber));
if(info.arcCount != NULL)
txt.append(QString("arcCount:%1\r\n").arg(*info.arcCount));
if(info.genere != NULL)
txt.append(QString("genere:%1\r\n").arg(*info.genere));
//Autores
if(info.writer != NULL)
txt.append(QString("writer:%1\r\n").arg(*info.writer));
if(info.penciller != NULL)
txt.append(QString("penciller:%1\r\n").arg(*info.penciller));
if(info.inker != NULL)
txt.append(QString("inker:%1\r\n").arg(*info.inker));
if(info.colorist != NULL)
txt.append(QString("colorist:%1\r\n").arg(*info.colorist));
if(info.letterer != NULL)
txt.append(QString("letterer:%1\r\n").arg(*info.letterer));
if(info.coverArtist != NULL)
txt.append(QString("coverArtist:%1\r\n").arg(*info.coverArtist));
//Publicaci<63>n
if(info.date != NULL)
txt.append(QString("date:%1\r\n").arg(*info.date));
if(info.publisher != NULL)
txt.append(QString("publisher:%1\r\n").arg(*info.publisher));
if(info.format != NULL)
txt.append(QString("format:%1\r\n").arg(*info.format));
if(info.color != NULL)
txt.append(QString("color:%1\r\n").arg(*info.color));
if(info.ageRating != NULL)
txt.append(QString("ageRating:%1\r\n").arg(*info.ageRating));
//Argumento
if(info.synopsis != NULL)
txt.append(QString("synopsis:%1\r\n").arg(*info.synopsis));
if(info.characters != NULL)
txt.append(QString("characters:%1\r\n").arg(*info.characters));
if(info.notes != NULL)
txt.append(QString("notes:%1\r\n").arg(*info.notes));
return txt;
}
//-----------------------------------------------------------------------------
//COMIC_INFO-------------------------------------------------------------------
//-----------------------------------------------------------------------------
ComicInfo::ComicInfo()
:existOnDb(false),
title(NULL),
coverPage(NULL),
numPages(NULL),
number(NULL),
isBis(NULL),
count(NULL),
volume(NULL),
storyArc(NULL),
arcNumber(NULL),
arcCount(NULL),
genere(NULL),
writer(NULL),
penciller(NULL),
inker(NULL),
colorist(NULL),
letterer(NULL),
coverArtist(NULL),
date(NULL),
publisher(NULL),
format(NULL),
color(NULL),
ageRating(NULL),
synopsis(NULL),
characters(NULL),
notes(NULL)
{
}
ComicInfo::ComicInfo(const ComicInfo & comicInfo)
: title(NULL),
coverPage(NULL),
numPages(NULL),
number(NULL),
isBis(NULL),
count(NULL),
volume(NULL),
storyArc(NULL),
arcNumber(NULL),
arcCount(NULL),
genere(NULL),
writer(NULL),
penciller(NULL),
inker(NULL),
colorist(NULL),
letterer(NULL),
coverArtist(NULL),
date(NULL),
publisher(NULL),
format(NULL),
color(NULL),
ageRating(NULL),
synopsis(NULL),
characters(NULL),
notes(NULL)
{
copyField(title,comicInfo.title);
copyField(coverPage,comicInfo.coverPage);
copyField(numPages,comicInfo.numPages);
copyField(number,comicInfo.number);
copyField(isBis,comicInfo.isBis);
copyField(count,comicInfo.count);
copyField(volume,comicInfo.volume);
copyField(storyArc,comicInfo.storyArc);
copyField(arcNumber,comicInfo.arcNumber);
copyField(arcCount,comicInfo.arcCount);
copyField(genere,comicInfo.genere);
copyField(writer,comicInfo.writer);
copyField(penciller,comicInfo.penciller);
copyField(inker,comicInfo.inker);
copyField(colorist,comicInfo.colorist);
copyField(letterer,comicInfo.letterer);
copyField(coverArtist,comicInfo.coverArtist);
copyField(date,comicInfo.date);
copyField(publisher,comicInfo.publisher);
copyField(format,comicInfo.format);
copyField(color,comicInfo.color);
copyField(ageRating,comicInfo.ageRating);
copyField(synopsis,comicInfo.synopsis);
copyField(characters,comicInfo.characters);
copyField(notes,comicInfo.notes);
hash = comicInfo.hash;
id = comicInfo.id;
existOnDb = comicInfo.existOnDb;
read = comicInfo.read;
edited = comicInfo.edited;
}
ComicInfo::~ComicInfo()
{
delete title;
delete coverPage;
delete numPages;
delete number;
delete isBis;
delete count;
delete volume;
delete storyArc;
delete arcNumber;
delete arcCount;
delete genere;
delete writer;
delete penciller;
delete inker;
delete colorist;
delete letterer;
delete coverArtist;
delete date;
delete publisher;
delete format;
delete color;
delete ageRating;
delete synopsis;
delete characters;
delete notes;
}
void ComicInfo::setField(const QString & name, QString * & field, QSqlRecord & record)
{
if(!record.value(name).isNull())
{
field = new QString();
*field = record.value(name).toString();
}
}
void ComicInfo::setField(const QString & name, int * & field, QSqlRecord & record)
{
if(!record.value(name).isNull())
{
field = new int;
*field = record.value(name).toInt();
}
}
void ComicInfo::setField(const QString & name, bool * & field, QSqlRecord & record)
{
if(!record.value(name).isNull())
{
field = new bool;
*field = record.value(name).toBool();
}
}
void ComicInfo::bindField(const QString & name, QString * field, QSqlQuery & query)
{
if(field != NULL)
{
query.bindValue(name,*field);
}
}
void ComicInfo::bindField(const QString & name, int * field, QSqlQuery & query)
{
if(field != NULL)
{
query.bindValue(name,*field);
}
}
void ComicInfo::bindField(const QString & name, bool * field, QSqlQuery & query)
{
if(field != NULL)
{
query.bindValue(name,*field);
}
}
void ComicInfo::setValue(QString * & field, const QString & value)
{
if(field == NULL)
field = new QString;
*field = value;
}
void ComicInfo::setValue(int * & field, int value)
{
if(field == NULL)
field = new int;
*field = value;
}
void ComicInfo::setValue(bool * & field, bool value)
{
if(field == NULL)
field = new bool;
*field = value;
}
void ComicInfo::copyField(QString * & field, const QString * value)
{
if(value != NULL)
field = new QString(*value);
}
void ComicInfo::copyField(int * & field, int * value)
{
if(value != NULL)
field = new int(*value);
}
void ComicInfo::copyField(bool * & field, bool * value)
{
if(value != NULL)
field = new bool(*value);
}
bool ComicInfo::load(QString hash, QSqlDatabase & db)
{
QSqlQuery findComicInfo(db);
findComicInfo.prepare("SELECT * FROM comic_info WHERE hash = :hash");
findComicInfo.bindValue(":hash", hash);
findComicInfo.exec();
if(findComicInfo.next())
{
this->hash = hash;
QSqlRecord record = findComicInfo.record();
hash = hash;
id = record.value("id").toULongLong();
read = record.value("read").toBool();
edited = record.value("edited").toBool();
setField("title",title,record);
setField("numPages",numPages,record);
setField("coverPage",coverPage,record);
setField("number",number,record);
setField("isBis",isBis,record);
setField("count",count,record);
setField("volume",volume,record);
setField("storyArc",storyArc,record);
setField("arcNumber",arcNumber,record);
setField("arcCount",arcCount,record);
setField("genere",genere,record);
setField("writer",writer,record);
setField("penciller",penciller,record);
setField("inker",inker,record);
setField("colorist",colorist,record);
setField("letterer",letterer,record);
setField("coverArtist",coverArtist,record);
setField("date",date,record);
setField("publisher",publisher,record);
setField("format",format,record);
setField("color",color,record);
setField("ageRating",ageRating,record);
setField("synopsis",synopsis,record);
setField("characters",characters,record);
setField("notes",notes,record);
return existOnDb = true;
}
return existOnDb = false;
}
qulonglong ComicInfo::insert(QSqlDatabase & db)
{
return 0;
}
void ComicInfo::removeFromDB(QSqlDatabase & db)
{
}
void ComicInfo::update(QSqlDatabase & db)
{
//db.open();
QSqlQuery updateComicInfo(db);
updateComicInfo.prepare("UPDATE comic_info SET "
"title = :title,"
"coverPage = :coverPage,"
"numPages = :numPages,"
"number = :number,"
"isBis = :isBis,"
"count = :count,"
"volume = :volume,"
"storyArc = :storyArc,"
"arcNumber = :arcNumber,"
"arcCount = :arcCount,"
"genere = :genere,"
"writer = :writer,"
"penciller = :penciller,"
"inker = :inker,"
"colorist = :colorist,"
"letterer = :letterer,"
"coverArtist = :coverArtist,"
"date = :date,"
"publisher = :publisher,"
"format = :format,"
"color = :color,"
"ageRating = :ageRating,"
"synopsis = :synopsis,"
"characters = :characters,"
"notes = :notes,"
"read = :read,"
"edited = :edited"
" WHERE id = :id ");
bindField(":title",title,updateComicInfo);
bindField(":coverPage",coverPage,updateComicInfo);
bindField(":numPages",numPages,updateComicInfo);
bindField(":number",number,updateComicInfo);
bindField(":isBis",isBis,updateComicInfo);
bindField(":count",count,updateComicInfo);
bindField(":volume",volume,updateComicInfo);
bindField(":storyArc",storyArc,updateComicInfo);
bindField(":arcNumber",arcNumber,updateComicInfo);
bindField(":arcCount",arcCount,updateComicInfo);
bindField(":genere",genere,updateComicInfo);
bindField(":writer",writer,updateComicInfo);
bindField(":penciller",penciller,updateComicInfo);
bindField(":inker",inker,updateComicInfo);
bindField(":colorist",colorist,updateComicInfo);
bindField(":letterer",letterer,updateComicInfo);
bindField(":coverArtist",coverArtist,updateComicInfo);
bindField(":date",date,updateComicInfo);
bindField(":publisher",publisher,updateComicInfo);
bindField(":format",format,updateComicInfo);
bindField(":color",color,updateComicInfo);
bindField(":ageRating",ageRating,updateComicInfo);
bindField(":synopsis",synopsis,updateComicInfo);
bindField(":characters",characters,updateComicInfo);
bindField(":notes",notes,updateComicInfo);
updateComicInfo.bindValue(":read", read?1:0);
updateComicInfo.bindValue(":id", id);
updateComicInfo.bindValue(":edited", edited?1:0);
updateComicInfo.exec();
//updateComicInfo.finish();
//db.close();
}
void ComicInfo::updateRead(QSqlDatabase & db)
{
QSqlQuery findComicInfo(db);
findComicInfo.prepare("UPDATE comic_info SET "
"read = :read"
" WHERE id = :id ");
findComicInfo.bindValue(":read", read?1:0);
findComicInfo.bindValue(":id", id);
findComicInfo.exec();
//findComicInfo.finish();
}
//set fields
void ComicInfo::setTitle(QString value)
{
setValue(title,value);
}
void ComicInfo::setCoverPage(int value)
{
setValue(coverPage,value);
}
void ComicInfo::setNumPages(int value)
{
setValue(numPages,value);
}
void ComicInfo::setNumber(int value)
{
setValue(number,value);
}
void ComicInfo::setIsBis(bool value)
{
setValue(isBis,value);
}
void ComicInfo::setCount(int value)
{
setValue(count,value);
}
void ComicInfo::setVolume(QString value)
{
setValue(volume,value);
}
void ComicInfo::setStoryArc(QString value)
{
setValue(storyArc,value);
}
void ComicInfo::setArcNumber(int value)
{
setValue(arcNumber,value);
}
void ComicInfo::setArcCount(int value)
{
setValue(arcCount,value);
}
void ComicInfo::setGenere(QString value)
{
setValue(genere,value);
}
void ComicInfo::setWriter(QString value)
{
setValue(writer,value);
}
void ComicInfo::setPenciller(QString value)
{
setValue(penciller,value);
}
void ComicInfo::setInker(QString value)
{
setValue(inker,value);
}
void ComicInfo::setColorist(QString value)
{
setValue(colorist,value);
}
void ComicInfo::setLetterer(QString value)
{
setValue(letterer,value);
}
void ComicInfo::setCoverArtist(QString value)
{
setValue(coverArtist,value);
}
void ComicInfo::setDate(QString value)
{
setValue(date,value);
}
void ComicInfo::setPublisher(QString value)
{
setValue(publisher,value);
}
void ComicInfo::setFormat(QString value)
{
setValue(format,value);
}
void ComicInfo::setColor(bool value)
{
setValue(color,value);
}
void ComicInfo::setAgeRating(QString value)
{
setValue(ageRating,value);
}
void ComicInfo::setSynopsis(QString value)
{
setValue(synopsis,value);
}
void ComicInfo::setCharacters(QString value)
{
setValue(characters,value);
}
void ComicInfo::setNotes(QString value)
{
setValue(notes,value);
}
QPixmap ComicInfo::getCover(const QString & basePath)
{
if(cover.isNull())
{
cover.load(basePath + "/.yacreaderlibrary/covers/" + hash + ".jpg");
}
QPixmap c;
c.convertFromImage(cover);
return c;
}

View File

@ -0,0 +1,141 @@
#ifndef __COMICDB_H
#define __COMICDB_H
#include "library_item.h"
#include <QSqlDatabase>
#include <QList>
#include <QPixmap>
#include <QImage>
class ComicInfo
{
public:
ComicInfo();
ComicInfo(const ComicInfo & comicInfo);
~ComicInfo();
bool load(QString hash, QSqlDatabase & db);
qulonglong insert(QSqlDatabase & db);
void removeFromDB(QSqlDatabase & db);
void update(QSqlDatabase & db);
void updateRead(QSqlDatabase & db);
qulonglong id;
bool read;
bool edited;
QString hash;
bool existOnDb;
QString * title;
int * coverPage;
int * numPages;
int * number;
bool * isBis;
int * count;
QString * volume;
QString * storyArc;
int * arcNumber;
int * arcCount;
QString * genere;
QString * writer;
QString * penciller;
QString * inker;
QString * colorist;
QString * letterer;
QString * coverArtist;
QString * date;
QString * publisher;
QString * format;
bool * color;
QString * ageRating;
QString * synopsis;
QString * characters;
QString * notes;
QImage cover;
void setTitle(QString value);
void setCoverPage(int value);
void setNumPages(int value);
void setNumber(int value);
void setIsBis(bool value);
void setCount(int value);
void setVolume(QString value);
void setStoryArc(QString value);
void setArcNumber(int value);
void setArcCount(int value);
void setGenere(QString value);
void setWriter(QString value);
void setPenciller(QString value);
void setInker(QString value);
void setColorist(QString value);
void setLetterer(QString value);
void setCoverArtist(QString value);
void setDate(QString value);
void setPublisher(QString value);
void setFormat(QString value);
void setColor(bool value);
void setAgeRating(QString value);
void setSynopsis(QString value);
void setCharacters(QString value);
void setNotes(QString value);
QPixmap getCover(const QString & basePath);
private:
void setField(const QString & name, QString * & field, QSqlRecord & record);
void setField(const QString & name, int * & field, QSqlRecord & record);
void setField(const QString & name, bool * & field, QSqlRecord & record);
void bindField(const QString & name, QString * field, QSqlQuery & query);
void bindField(const QString & name, int * field, QSqlQuery & query);
void bindField(const QString & name, bool * field, QSqlQuery & query);
void setValue(QString * & field, const QString & value);
void setValue(int * & field, int value);
void setValue(bool * & field, bool value);
void copyField(QString * & field, const QString * value);
void copyField(int * & field, int * value);
void copyField(bool * & field, bool * value);
};
class ComicDB : public LibraryItem
{
private:
bool _hasCover;
public:
ComicDB();
ComicDB(qulonglong cparentId, QString cname, QString cpath, QString chash, QSqlDatabase & database);
//Comic(QString fn, QString fp):name(fn),path(fp),knownParent(false), knownId(false){};
static QList<LibraryItem *> getComicsFromParent(qulonglong parentId, QSqlDatabase & db, bool sort = true);
bool isDir();
bool load(qulonglong id, QSqlDatabase & db);
qulonglong insert(QSqlDatabase & db);
void removeFromDB(QSqlDatabase & db);
void update(QSqlDatabase & db);
bool hasCover() {return _hasCover;};
QString toTXT();
ComicInfo info;
};
#endif

View File

@ -0,0 +1,591 @@
#include "data_base_management.h"
#include <QtCore>
#include "library_creator.h"
#include "check_new_version.h"
static QString fields = "title ,"
"coverPage,"
"numPages,"
"number,"
"isBis,"
"count,"
"volume,"
"storyArc,"
"arcNumber,"
"arcCount,"
"genere,"
"writer,"
"penciller,"
"inker,"
"colorist,"
"letterer,"
"coverArtist,"
"date,"
"publisher,"
"format,"
"color,"
"ageRating,"
"synopsis,"
"characters,"
"notes,"
"hash";
DataBaseManagement::DataBaseManagement()
:QObject(),dataBasesList()
{
}
/*TreeModel * DataBaseManagement::newTreeModel(QString path)
{
//la consulta se ejecuta...
QSqlQuery selectQuery(loadDatabase(path));
selectQuery.setForwardOnly(true);
selectQuery.exec("select * from folder order by parentId,name");
//selectQuery.finish();
return new TreeModel(selectQuery);
}*/
QSqlDatabase DataBaseManagement::createDatabase(QString name, QString path)
{
return createDatabase(QDir::cleanPath(path) + "/" + name + ".ydb");
}
QSqlDatabase DataBaseManagement::createDatabase(QString dest)
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE",dest);
db.setDatabaseName(dest);
if (!db.open())
qDebug() << db.lastError();
else {
qDebug() << db.tables();
}
{
QSqlQuery pragma("PRAGMA foreign_keys = ON",db);
//pragma.finish();
DataBaseManagement::createTables(db);
QSqlQuery query("INSERT INTO folder (parentId, name, path) "
"VALUES (1,'root', '/')",db);
}
//query.finish();
//db.close();
return db;
}
QSqlDatabase DataBaseManagement::loadDatabase(QString path)
{
//TODO check path
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE",path);
db.setDatabaseName(path+"/library.ydb");
if (!db.open()) {
//se devuelve una base de datos vac<61>a e inv<6E>lida
return QSqlDatabase();
}
QSqlQuery pragma("PRAGMA foreign_keys = ON",db);
//pragma.finish();
//devuelve la base de datos
return db;
}
QSqlDatabase DataBaseManagement::loadDatabaseFromFile(QString filePath)
{
//TODO check path
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE",filePath);
db.setDatabaseName(filePath);
if (!db.open()) {
//se devuelve una base de datos vac<61>a e inv<6E>lida
return QSqlDatabase();
}
{
QSqlQuery pragma("PRAGMA foreign_keys = ON",db);
}
//pragma.finish();
//devuelve la base de datos
return db;
}
bool DataBaseManagement::createTables(QSqlDatabase & database)
{
bool success = true;
//FOLDER (representa una carpeta en disco)
{
QSqlQuery queryFolder(database);
queryFolder.prepare("CREATE TABLE folder (id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, name TEXT NOT NULL, path TEXT NOT NULL, FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE)");
success = success && queryFolder.exec();
//queryFolder.finish();
//COMIC INFO (representa la informaci<63>n de un c<>mic, cada c<>mic tendr<64> un id<69>ntificador <20>nico formado por un hash sha1'de los primeros 512kb' + su tama<6D>o en bytes)
QSqlQuery queryComicInfo(database);
queryComicInfo.prepare("CREATE TABLE comic_info ("
"id INTEGER PRIMARY KEY,"
"title TEXT,"
"coverPage INTEGER DEFAULT 1,"
"numPages INTEGER,"
"number INTEGER,"
"isBis BOOLEAN,"
"count INTEGER,"
"volume TEXT,"
"storyArc TEXT,"
"arcNumber INTEGER,"
"arcCount INTEGER,"
"genere TEXT,"
"writer TEXT,"
"penciller TEXT,"
"inker TEXT,"
"colorist TEXT,"
"letterer TEXT,"
"coverArtist TEXT,"
"date TEXT," //dd/mm/yyyy --> se mostrar<61> en 3 campos diferentes
"publisher TEXT,"
"format TEXT,"
"color BOOLEAN,"
"ageRating BOOLEAN,"
"synopsis TEXT,"
"characters TEXT,"
"notes TEXT,"
"hash TEXT UNIQUE NOT NULL,"
"edited BOOLEAN DEFAULT 0,"
"read BOOLEAN DEFAULT 0)");
success = success && queryComicInfo.exec();
//queryComicInfo.finish();
//COMIC (representa un c<>mic en disco, contiene el nombre de fichero)
QSqlQuery queryComic(database);
queryComic.prepare("CREATE TABLE comic (id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, comicInfoId INTEGER NOT NULL, fileName TEXT NOT NULL, path TEXT, FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE, FOREIGN KEY(comicInfoId) REFERENCES comic_info(id))");
success = success && queryComic.exec();
//queryComic.finish();
//DB INFO
QSqlQuery queryDBInfo(database);
queryDBInfo.prepare("CREATE TABLE db_info (version TEXT NOT NULL)");
success = success && queryDBInfo.exec();
//queryDBInfo.finish();
QSqlQuery query("INSERT INTO db_info (version) "
"VALUES ('"VERSION"')",database);
//query.finish();
}
return success;
}
#include <qmessagebox.h>
void DataBaseManagement::exportComicsInfo(QString source, QString dest)
{
//QSqlDatabase sourceDB = loadDatabase(source);
QSqlDatabase destDB = loadDatabaseFromFile(dest);
//sourceDB.open();
{
QSqlQuery attach(destDB);
attach.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(dest) +"' AS dest;");
//attach.bindValue(":dest",QDir().toNativeSeparators(dest));
attach.exec();
//attach.finish();
QSqlQuery attach2(destDB);
attach2.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(source) +"' AS source;");
attach2.exec();
//attach2.finish();
//sourceDB.close();
QSqlQuery queryDBInfo(destDB);
queryDBInfo.prepare("CREATE TABLE dest.db_info (version TEXT NOT NULL)");
queryDBInfo.exec();
//queryDBInfo.finish();
/*QSqlQuery queryComicsInfo(sourceDB);
queryComicsInfo.prepare("CREATE TABLE dest.comic_info (id INTEGER PRIMARY KEY, hash TEXT NOT NULL, edited BOOLEAN DEFAULT FALSE, title TEXT, read BOOLEAN)");
queryComicsInfo.exec();*/
QSqlQuery query("INSERT INTO dest.db_info (version) "
"VALUES ('"VERSION"')",destDB);
//query.finish();
QSqlQuery exportData(destDB);
exportData.prepare("create table dest.comic_info as select " + fields +
" from source.comic_info where source.comic_info.edited = 1");
exportData.exec();
//exportData.finish();
}
//sourceDB.close();
destDB.close();
QSqlDatabase::removeDatabase(dest);
}
bool DataBaseManagement::importComicsInfo(QString source, QString dest)
{
QString error;
QString driver;
QStringList hashes;
bool b = false;
QSqlDatabase sourceDB = loadDatabaseFromFile(source);
QSqlDatabase destDB = loadDatabaseFromFile(dest);
{
QSqlQuery pragma("PRAGMA synchronous=OFF",destDB);
QSqlQuery newInfo(sourceDB);
newInfo.prepare("SELECT * FROM comic_info");
newInfo.exec();
destDB.transaction();
int cp;
while (newInfo.next()) //cada tupla deber<65> ser insertada o actualizada
{
QSqlQuery update(destDB);
update.prepare("UPDATE comic_info SET "
"title = :title,"
"coverPage = :coverPage,"
"numPages = :numPages,"
"number = :number,"
"isBis = :isBis,"
"count = :count,"
"volume = :volume,"
"storyArc = :storyArc,"
"arcNumber = :arcNumber,"
"arcCount = :arcCount,"
"genere = :genere,"
"writer = :writer,"
"penciller = :penciller,"
"inker = :inker,"
"colorist = :colorist,"
"letterer = :letterer,"
"coverArtist = :coverArtist,"
"date = :date,"
"publisher = :publisher,"
"format = :format,"
"color = :color,"
"ageRating = :ageRating,"
"synopsis = :synopsis,"
"characters = :characters,"
"notes = :notes,"
"edited = :edited"
" WHERE hash = :hash ");
QSqlQuery insert(destDB);
insert.prepare("INSERT INTO comic_info "
"(title,"
"coverPage,"
"numPages,"
"number,"
"isBis,"
"count,"
"volume,"
"storyArc,"
"arcNumber,"
"arcCount,"
"genere,"
"writer,"
"penciller,"
"inker,"
"colorist,"
"letterer,"
"coverArtist,"
"date,"
"publisher,"
"format,"
"color,"
"ageRating,"
"synopsis,"
"characters,"
"notes,"
"read,"
"edited,"
"hash)"
"VALUES (:title,"
":coverPage,"
":numPages,"
":number,"
":isBis,"
":count,"
":volume,"
":storyArc,"
":arcNumber,"
":arcCount,"
":genere,"
":writer,"
":penciller,"
":inker,"
":colorist,"
":letterer,"
":coverArtist,"
":date,"
":publisher,"
":format,"
":color,"
":ageRating,"
":synopsis,"
":characters,"
":notes,"
":read,"
":edited,"
":hash )");
QSqlRecord record = newInfo.record();
cp = record.value("coverPage").toInt();
if(cp>1)
{
QSqlQuery checkCoverPage(destDB);
checkCoverPage.prepare("SELECT coverPage FROM comic_info where hash = :hash");
checkCoverPage.bindValue(":hash",record.value("hash").toString());
checkCoverPage.exec();
bool extract = false;
if(checkCoverPage.next())
{
extract = checkCoverPage.record().value("coverPage").toInt() != cp;
}
if(extract)
hashes.append(record.value("hash").toString());
}
bindValuesFromRecord(record,update);
update.bindValue(":edited",1);
update.exec();
if(update.numRowsAffected() == 0)
{
bindValuesFromRecord(record,insert);
insert.bindValue(":edited",1);
insert.bindValue(":read",0);
insert.exec();
QString error1 = insert.lastError().databaseText();
QString error2 = insert.lastError().driverText();
//QMessageBox::critical(NULL,"db",error1);
//QMessageBox::critical(NULL,"driver",error2);
}
//update.finish();
//insert.finish();
}
}
destDB.commit();
QString hash;
foreach(hash, hashes)
{
QSqlQuery getComic(destDB);
getComic.prepare("SELECT c.path,ci.coverPage FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) where ci.hash = :hash");
getComic.bindValue(":hash",hash);
getComic.exec();
if(getComic.next())
{
QString basePath = QString(dest).remove("/.yacreaderlibrary/library.ydb");
QString path = basePath + getComic.record().value("path").toString();
int coverPage = getComic.record().value("coverPage").toInt();
ThumbnailCreator tc(path,basePath+"/.yacreaderlibrary/covers/"+hash+".jpg",coverPage);
tc.create();
}
}
destDB.close();
sourceDB.close();
QSqlDatabase::removeDatabase(source);
QSqlDatabase::removeDatabase(dest);
return b;
}
void DataBaseManagement::bindValuesFromRecord(const QSqlRecord & record, QSqlQuery & query)
{
bindString("title",record,query);
bindInt("coverPage",record,query);
bindInt("numPages",record,query);
bindInt("number",record,query);
bindInt("isBis",record,query);
bindInt("count",record,query);
bindString("volume",record,query);
bindString("storyArc",record,query);
bindInt("arcNumber",record,query);
bindInt("arcCount",record,query);
bindString("genere",record,query);
bindString("writer",record,query);
bindString("penciller",record,query);
bindString("inker",record,query);
bindString("colorist",record,query);
bindString("letterer",record,query);
bindString("coverArtist",record,query);
bindString("date",record,query);
bindString("publisher",record,query);
bindString("format",record,query);
bindInt("color",record,query);
bindString("ageRating",record,query);
bindString("synopsis",record,query);
bindString("characters",record,query);
bindString("notes",record,query);
bindString("hash",record,query);
}
void DataBaseManagement::bindString(const QString & name, const QSqlRecord & record, QSqlQuery & query)
{
if(!record.value(name).isNull())
{
query.bindValue(":"+name,record.value(name).toString());
}
}
void DataBaseManagement::bindInt(const QString & name, const QSqlRecord & record, QSqlQuery & query)
{
if(!record.value(name).isNull())
{
query.bindValue(":"+name,record.value(name).toInt());
}
}
QString DataBaseManagement::checkValidDB(const QString & fullPath)
{
QSqlDatabase db = loadDatabaseFromFile(fullPath);
QString versionString = "";
if(db.isValid() && db.isOpen())
{
QSqlQuery version(db);
version.prepare("SELECT * FROM db_info");
version.exec();
if(version.next())
versionString = version.record().value("version").toString();
}
db.close();
QSqlDatabase::removeDatabase(fullPath);
return versionString;
}
int DataBaseManagement::compareVersions(const QString & v1, const QString v2)
{
QStringList v1l = v1.split('.');
QStringList v2l = v2.split('.');
QList<int> v1il;
QList<int> v2il;
foreach(QString s, v1l)
v1il.append(s.toInt());
foreach(QString s,v2l)
v2il.append(s.toInt());
for(int i=0;i<qMin(v1il.length(),v2il.length());i++)
{
if(v1il[i]<v2il[i])
return -1;
if(v1il[i]>v2il[i])
return 1;
}
if(v1il.length() < v2il.length())
return -1;
if(v1il.length() == v2il.length())
return 0;
if(v1il.length() > v2il.length())
return 1;
return 0;
}
bool DataBaseManagement::updateToCurrentVersion(const QString & fullPath)
{
QSqlDatabase db = loadDatabaseFromFile(fullPath);
bool returnValue = false;
if(db.isValid() && db.isOpen())
{
QSqlQuery updateVersion(db);
updateVersion.prepare("UPDATE db_info SET "
"version = :version");
updateVersion.bindValue(":version",VERSION);
updateVersion.exec();
if(updateVersion.numRowsAffected() > 0)
returnValue = true;
}
db.close();
QSqlDatabase::removeDatabase(fullPath);
return returnValue;
}
//COMICS_INFO_EXPORTER
ComicsInfoExporter::ComicsInfoExporter()
:QThread()
{
}
void ComicsInfoExporter::exportComicsInfo(QSqlDatabase & source, QSqlDatabase & dest)
{
}
void ComicsInfoExporter::run()
{
}
//COMICS_INFO_IMPORTER
ComicsInfoImporter::ComicsInfoImporter()
:QThread()
{
}
void ComicsInfoImporter::importComicsInfo(QSqlDatabase & source, QSqlDatabase & dest)
{
}
void ComicsInfoImporter::run()
{
}

View File

@ -0,0 +1,59 @@
#ifndef __DATA_BASE_MANAGEMENT_H
#define __DATA_BASE_MANAGEMENT_H
#include <QtCore>
#include <QtSql>
#include <QSqlDatabase>
#include "treemodel.h"
class ComicsInfoExporter : public QThread
{
Q_OBJECT
public:
ComicsInfoExporter();
void exportComicsInfo(QSqlDatabase & source, QSqlDatabase & dest);
private:
void run();
};
class ComicsInfoImporter : public QThread
{
Q_OBJECT
public:
ComicsInfoImporter();
void importComicsInfo(QSqlDatabase & source, QSqlDatabase & dest);
private:
void run();
};
class DataBaseManagement : public QObject
{
Q_OBJECT
private:
QList<QString> dataBasesList;
static void bindString(const QString & name, const QSqlRecord & record, QSqlQuery & query);
static void bindInt(const QString & name, const QSqlRecord & record, QSqlQuery & query);
static void bindValuesFromRecord(const QSqlRecord & record, QSqlQuery & query);
public:
DataBaseManagement();
//TreeModel * newTreeModel(QString path);
//crea una base de datos y todas sus tablas
static QSqlDatabase createDatabase(QString name, QString path);
static QSqlDatabase createDatabase(QString dest);
//carga una base de datos desde la ruta path
static QSqlDatabase loadDatabase(QString path);
static QSqlDatabase loadDatabaseFromFile(QString path);
static bool createTables(QSqlDatabase & database);
static void exportComicsInfo(QString source, QString dest);
static bool importComicsInfo(QString source, QString dest);
static QString checkValidDB(const QString & fullPath); //retorna "" si la DB es inv<6E>lida <20> la versi<73>n si es v<>lida.
static int compareVersions(const QString & v1, const QString v2); //retorna <0 si v1 < v2, 0 si v1 = v2 y >0 si v1 > v2
static bool updateToCurrentVersion(const QString & path);
};
#endif

View File

@ -0,0 +1,89 @@
#include "folder.h"
#include <QSqlQuery>
#include <QSqlRecord>
#include <QVariant>
Folder::Folder(qulonglong id, QSqlDatabase & db)
{
QSqlQuery query(db);
query.prepare("SELECT * FROM folder WHERE id = :id");
query.bindValue(":id",id);
query.exec();
this->id = id;
this->parentId = 0;
if(query.next())
{
QSqlRecord record = query.record();
this->parentId = record.value("parentId").toULongLong();
this->name = record.value("name").toString();
this->path = record.value("path").toString();
}
}
qulonglong Folder::insert(QSqlDatabase & db)
{
QSqlQuery query(db);
query.prepare("INSERT INTO folder (parentId, name, path) "
"VALUES (:parentId, :name, :path)");
query.bindValue(":parentId", parentId);
query.bindValue(":name", name);
query.bindValue(":path", path);
query.exec();
return query.lastInsertId().toULongLong();
}
QList<LibraryItem *> Folder::getFoldersFromParent(qulonglong parentId, QSqlDatabase & db, bool sort)
{
QList<LibraryItem *> list;
QSqlQuery selectQuery(db); //TODO check
selectQuery.prepare("SELECT * FROM folder WHERE parentId = :parentId and id <> 1");
selectQuery.bindValue(":parentId", parentId);
selectQuery.exec();
Folder * currentItem;
while (selectQuery.next())
{
QList<QVariant> data;
QSqlRecord record = selectQuery.record();
for(int i=0;i<record.count();i++)
data << record.value(i);
//TODO sort by sort indicator and name
currentItem = new Folder(record.value("id").toULongLong(),record.value("parentId").toULongLong(),record.value("name").toString(),record.value("path").toString());
int lessThan = 0;
if(list.isEmpty() || !sort)
list.append(currentItem);
else
{
Folder * last = static_cast<Folder *>(list.back());
QString nameLast = last->name;
QString nameCurrent = currentItem->name;
QList<LibraryItem *>::iterator i;
i = list.end();
i--;
while ((0 > (lessThan = nameCurrent.localeAwareCompare(nameLast))) && i != list.begin())
{
i--;
nameLast = (*i)->name;
}
if(lessThan>0) //si se ha encontrado un elemento menor que current, se inserta justo despu<70>s
list.insert(++i,currentItem);
else
list.insert(i,currentItem);
}
}
return list;
}
void Folder::removeFromDB(QSqlDatabase & db)
{
QSqlQuery query(db);
query.prepare("DELETE FROM folder WHERE id = :id");
query.bindValue(":id", id);
query.exec();
}

View File

@ -0,0 +1,27 @@
#ifndef __FOLDER_H
#define __FOLDER_H
#include "library_item.h"
#include <QSqlDatabase>
#include <QList>
class Folder : public LibraryItem
{
public:
bool knownParent;
bool knownId;
Folder():knownParent(false), knownId(false){};
Folder(qulonglong sid, qulonglong pid,QString fn, QString fp):knownParent(true), knownId(true){id = sid; parentId = pid;name = fn; path = fp;};
Folder(QString fn, QString fp):knownParent(false), knownId(false){name = fn; path = fp;};
Folder(qulonglong id, QSqlDatabase & db);//loads a folder from db;
void setId(qulonglong sid){id = sid;knownId = true;};
void setFather(qulonglong pid){parentId = pid;knownParent = true;};
static QList<LibraryItem *> getFoldersFromParent(qulonglong parentId, QSqlDatabase & db, bool sort = true);
qulonglong insert(QSqlDatabase & db);
bool isDir(){return true;};
void removeFromDB(QSqlDatabase & db);
};
#endif

View File

View File

@ -0,0 +1,17 @@
#ifndef __LIBRARY_ITEM_H
#define __LIBRARY_ITEM_H
#include <QSqlDatabase>
class LibraryItem
{
public:
virtual bool isDir() = 0;
virtual void removeFromDB(QSqlDatabase & db) = 0;
QString name;
QString path;
qulonglong parentId;
qulonglong id;
};
#endif

View File

@ -0,0 +1,47 @@
#include <QStringList>
#include "tableitem.h"
//! [0]
TableItem::TableItem(const QList<QVariant> &data)
{
itemData = data;
}
//! [0]
//! [1]
TableItem::~TableItem()
{
}
//! [1]
//! [5]
int TableItem::columnCount() const
{
return itemData.count();
}
//! [5]
//! [6]
QVariant TableItem::data(int column) const
{
return itemData.value(column);
}
//! [6]
void TableItem::setData(int column,const QVariant & value)
{
itemData[column] = value;
}
//! [8]
int TableItem::row() const
{
return 0;
}
//! [8]

View File

@ -0,0 +1,27 @@
#ifndef TABLEITEM_H
#define TABLEITEM_H
#include <QList>
#include <QVariant>
//! [0]
class TableItem : public QObject
{
Q_OBJECT
public:
TableItem(const QList<QVariant> &data);
~TableItem();
int columnCount() const;
QVariant data(int column) const;
void setData(int column,const QVariant & value);
int row() const;
unsigned long long int id; //TODO sustituir por una clase adecuada
//Comic comic;
private:
QList<QVariant> itemData;
};
//! [0]
#endif

View File

@ -0,0 +1,442 @@
#include <QtGui>
#include <QtDebug>
#include "tableitem.h"
#include "tablemodel.h"
#include "data_base_management.h"
#include "qnaturalsorting.h"
#include "comic_db.h"
//ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read
#define NUMBER 0
#define TITLE 1
#define FILE_NAME 2
#define NUM_PAGES 3
#define ID 4
#define PARENT_ID 5
#define PATH 6
#define HASH 7
#define READ 8
#define IS_BIS 9
TableModel::TableModel(QObject *parent)
: QAbstractItemModel(parent)
{
connect(this,SIGNAL(beforeReset()),this,SIGNAL(modelAboutToBeReset()));
connect(this,SIGNAL(reset()),this,SIGNAL(modelReset()));
}
//! [0]
TableModel::TableModel( QSqlQuery &sqlquery, QObject *parent)
: QAbstractItemModel(parent)
{
setupModelData(sqlquery);
}
//! [0]
//! [1]
TableModel::~TableModel()
{
qDeleteAll(_data);
}
//! [1]
//! [2]
int TableModel::columnCount(const QModelIndex &parent) const
{
if(_data.isEmpty())
return 0;
return _data.first()->columnCount();
}
//! [2]
//! [3]
QVariant TableModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role == Qt::DecorationRole)
{
return QVariant();
}
if (role != Qt::DisplayRole)
return QVariant();
TableItem *item = static_cast<TableItem*>(index.internalPointer());
if(index.column() == HASH)
return QString::number(item->data(index.column()).toString().right(item->data(index.column()).toString().length()-40).toInt()/1024.0/1024.0,'f',2)+"Mb";
if(index.column() == READ)
return item->data(index.column()).toBool()?QVariant(tr("yes")):QVariant(tr("no"));
return item->data(index.column());
}
//! [3]
//! [4]
Qt::ItemFlags TableModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
//! [4]
//! [5]
QVariant TableModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
switch(section)//TODO obtener esto de la query
{
case 0:
return QVariant(QString("#"));
case 1:
return QVariant(QString(tr("Title")));
case 2:
return QVariant(QString(tr("File Name")));
case 3:
return QVariant(QString(tr("Pages")));
case 7:
return QVariant(QString(tr("Size")));
case 8:
return QVariant(QString(tr("Read")));
}
}
if(orientation == Qt::Vertical && role == Qt::DecorationRole)
{
QString fileName = _data.value(section)->data(FILE_NAME).toString();
QFileInfo fi(fileName);
QString ext = fi.suffix();
if (ext.compare("cbr",Qt::CaseInsensitive) == 0)
return QVariant(QIcon(":/images/comicRar.png"));
else if (ext.compare("cbz",Qt::CaseInsensitive) == 0)
return QVariant(QIcon(":/images/comicZip.png"));
else if(ext.compare("pdf",Qt::CaseInsensitive) == 0)
return QVariant(QIcon(":/images/pdf.png"));
else if (ext.compare("tar",Qt::CaseInsensitive) == 0)
return QVariant(QIcon(":/images/tar.png"));
else if(ext.compare("zip",Qt::CaseInsensitive) == 0)
return QVariant(QIcon(":/images/zip.png"));
else if(ext.compare("rar",Qt::CaseInsensitive) == 0)
return QVariant(QIcon(":/images/rar.png"));
else if (ext.compare("7z",Qt::CaseInsensitive) == 0)
return QVariant(QIcon(":/images/7z.png"));
else if (ext.compare("cb7",Qt::CaseInsensitive) == 0)
return QVariant(QIcon(":/images/comic7z.png"));
else if (ext.compare("cb7",Qt::CaseInsensitive) == 0)
return QVariant(QIcon(":/images/comicTar.png"));
}
return QVariant();
}
//! [5]
//! [6]
QModelIndex TableModel::index(int row, int column, const QModelIndex &parent)
const
{
if (!hasIndex(row, column, parent))
return QModelIndex();
return createIndex(row, column, _data.at(row));
}
//! [6]
//! [7]
QModelIndex TableModel::parent(const QModelIndex &index) const
{
return QModelIndex();
}
//! [7]
//! [8]
int TableModel::rowCount(const QModelIndex &parent) const
{
TreeItem *parentItem;
if (parent.column() > 0)
return 0;
if (!parent.isValid())
return _data.count();
return 0;
}
//! [8]
QStringList TableModel::getPaths(const QString & _source)
{
QStringList paths;
QString source = _source + "/.yacreaderlibrary/covers/";
QList<TableItem *>::ConstIterator itr;
for(itr = _data.constBegin();itr != _data.constEnd();itr++)
{
QString hash = (*itr)->data(HASH).toString();
paths << source+ hash +".jpg";
}
return paths;
}
void TableModel::setupModelData(unsigned long long int folderId,const QString & databasePath)
{
//QFile f(QCoreApplication::applicationDirPath()+"/performance.txt");
//f.open(QIODevice::Append);
beginResetModel();
//QElapsedTimer timer;
//timer.start();
qDeleteAll(_data);
_data.clear();
//QTextStream txtS(&f);
//txtS << "TABLEMODEL: Tiempo de borrado: " << timer.elapsed() << "ms\r\n";
_databasePath = databasePath;
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
{
//crear la consulta
//timer.restart();
QSqlQuery selectQuery(db); //TODO check
selectQuery.prepare("select ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read,ci.isBis from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId");
selectQuery.bindValue(":parentId", folderId);
selectQuery.exec();
//txtS << "TABLEMODEL: Tiempo de consulta: " << timer.elapsed() << "ms\r\n";
//timer.restart();
setupModelData(selectQuery);
//txtS << "TABLEMODEL: Tiempo de creaci<63>n del modelo: " << timer.elapsed() << "ms\r\n";
//selectQuery.finish();
}
db.close();
QSqlDatabase::removeDatabase(_databasePath);
endResetModel();
//f.close();
}
QString TableModel::getComicPath(QModelIndex mi)
{
if(mi.isValid())
return _data.at(mi.row())->data(PATH).toString();
return "";
}
#define NUMBER_MAX 99999999
void TableModel::setupModelData(QSqlQuery &sqlquery)
{
TableItem * currentItem;
while (sqlquery.next())
{
QList<QVariant> data;
QSqlRecord record = sqlquery.record();
for(int i=0;i<record.count();i++)
data << record.value(i);
currentItem = new TableItem(data);
bool lessThan = false;
if(_data.isEmpty())
_data.append(currentItem);
else
{
TableItem * last = _data.back();
QString nameLast = last->data(FILE_NAME).toString();
QString nameCurrent = currentItem->data(FILE_NAME).toString();
int numberLast,numberCurrent;
numberLast = numberCurrent = NUMBER_MAX; //TODO change by std limit
if(!last->data(NUMBER).isNull())
numberLast = last->data(NUMBER).toInt();
if(!currentItem->data(NUMBER).isNull())
numberCurrent = currentItem->data(NUMBER).toInt();
QList<TableItem *>::iterator i;
i = _data.end();
i--;
if(numberCurrent != NUMBER_MAX)
{
while ((lessThan =numberCurrent < numberLast) && i != _data.begin())
{
i--;
numberLast = NUMBER_MAX; //TODO change by std limit
if(!(*i)->data(NUMBER).isNull())
numberLast = (*i)->data(NUMBER).toInt();
}
}
else
{
while ((lessThan = naturalSortLessThanCI(nameCurrent,nameLast)) && i != _data.begin() && numberLast == 99999999)
{
i--;
nameLast = (*i)->data(FILE_NAME).toString();
numberLast = NUMBER_MAX; //TODO change by std limit
if(!(*i)->data(NUMBER).isNull())
numberLast = (*i)->data(NUMBER).toInt();
}
}
if(!lessThan) //si se ha encontrado un elemento menor que current, se inserta justo despu<70>s
{
if(numberCurrent != NUMBER_MAX)
{
if(numberCurrent == numberLast)
if(currentItem->data(IS_BIS).toBool())
{
_data.insert(++i,currentItem);
}
else
_data.insert(i,currentItem);
else
_data.insert(++i,currentItem);
}
else
_data.insert(++i,currentItem);
}
else
{
_data.insert(i,currentItem);
}
}
}
}
ComicDB TableModel::getComic(const QModelIndex & mi)
{
ComicDB c;
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
c.load(_data.at(mi.row())->data(ID).toULongLong(),db);
db.close();
QSqlDatabase::removeDatabase(_databasePath);
return c;
}
ComicDB TableModel::_getComic(const QModelIndex & mi)
{
ComicDB c;
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
c.load(_data.at(mi.row())->data(ID).toULongLong(),db);
db.close();
QSqlDatabase::removeDatabase(_databasePath);
return c;
}
QVector<bool> TableModel::getReadList()
{
int numComics = _data.count();
QVector<bool> readList(numComics);
for(int i=0;i<numComics;i++)
{
readList[i] = _data.value(i)->data(READ).toBool();
}
return readList;
}
QVector<bool> TableModel::setAllComicsRead(bool read)
{
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
db.transaction();
int numComics = _data.count();
QVector<bool> readList(numComics);
for(int i=0;i<numComics;i++)
{
readList[i] = read;
_data.value(i)->setData(READ,QVariant(read));
ComicDB c;
c.load(_data.value(i)->data(ID).toULongLong(),db);
c.info.read = read;
c.info.update(db);
}
db.commit();
db.close();
QSqlDatabase::removeDatabase(_databasePath);
emit dataChanged(index(0,READ),index(numComics-1,READ));
return readList;
}
QList<ComicDB> TableModel::getComics(QList<QModelIndex> list)
{
QList<ComicDB> comics;
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
db.transaction();
QList<QModelIndex>::const_iterator itr;
for(itr = list.constBegin(); itr!= list.constEnd();itr++)
{
comics.append(_getComic(*itr));
}
db.commit();
db.close();
QSqlDatabase::removeDatabase(_databasePath);
return comics;
}
QVector<bool> TableModel::setComicsRead(QList<QModelIndex> list,bool read)
{
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
db.transaction();
foreach (QModelIndex mi, list)
{
_data.value(mi.row())->setData(READ, QVariant(read));
ComicDB c;
c.load(_data.value(mi.row())->data(ID).toULongLong(),db);
c.info.read = read;
c.info.update(db);
}
db.commit();
db.close();
QSqlDatabase::removeDatabase(_databasePath);
emit dataChanged(index(list.first().row(),READ),index(list.last().row(),READ));
return getReadList();
}
qint64 TableModel::asignNumbers(QList<QModelIndex> list,int startingNumber)
{
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
db.transaction();
qint64 idFirst = _data.value(list[0].row())->data(ID).toULongLong();
int i = 0;
foreach (QModelIndex mi, list)
{
ComicDB c;
c.load(_data.value(mi.row())->data(ID).toULongLong(),db);
c.info.setNumber(startingNumber+i);
c.info.edited = true;
c.info.update(db);
i++;
}
db.commit();
db.close();
QSqlDatabase::removeDatabase(_databasePath);
//emit dataChanged(index(list.first().row(),READ),index(list.last().row(),READ));
return idFirst;
}
QModelIndex TableModel::getIndexFromId(quint64 id)
{
QList<TableItem *>::ConstIterator itr;
int i=0;
for(itr = _data.constBegin();itr != _data.constEnd();itr++)
{
if((*itr)->data(ID).toULongLong() == id)
break;
i++;
}
return index(i,0);
}

View File

@ -0,0 +1,61 @@
#ifndef TABLEMODEL_H
#define TABLEMODEL_H
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
#include <QSqlQuery>
#include <QSqlDatabase>
class ComicDB;
class TableItem;
//! [0]
class TableModel : public QAbstractItemModel
{
Q_OBJECT
public:
TableModel(QObject *parent = 0);
TableModel( QSqlQuery &sqlquery, QObject *parent = 0);
~TableModel();
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
void setupModelData(unsigned long long int parentFolder,const QString & databasePath);
//M<>todos de conveniencia
QStringList getPaths(const QString & _source);
QString getComicPath(QModelIndex mi);
ComicDB getComic(const QModelIndex & mi); //--> para la edici<63>n
QVector<bool> getReadList();
QVector<bool> setAllComicsRead(bool read);
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la informaci<63>n com<6F>n a los comics seleccionados
QModelIndex getIndexFromId(quint64 id);
//setcomicInfo(QModelIndex & mi); --> inserta en la base datos
//setComicInfoForAllComics(); --> inserta la informaci<63>n com<6F>n a todos los c<>mics de una sola vez.
//setComicInfoForSelectedComis(QList<QModelIndex> list); -->inserta la informaci<63>n com<6F>n para los comics seleccionados
QVector<bool> setComicsRead(QList<QModelIndex> list,bool read);
qint64 asignNumbers(QList<QModelIndex> list,int startingNumber);
private:
void setupModelData( QSqlQuery &sqlquery);
ComicDB _getComic(const QModelIndex & mi);
QList<TableItem *> _data;
QString _databasePath;
signals:
void beforeReset();
void reset();
};
//! [0]
#endif

View File

@ -0,0 +1,147 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
****************************************************************************/
/*
treeitem.cpp
A container for items of data supplied by the simple tree model.
*/
#include <QStringList>
#include "treeitem.h"
#include "qnaturalsorting.h"
//! [0]
TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
{
parentItem = parent;
itemData = data;
}
//! [0]
//! [1]
TreeItem::~TreeItem()
{
qDeleteAll(childItems);
}
//! [1]
//! [2]
void TreeItem::appendChild(TreeItem *item)
{
item->parentItem = this;
//TODO insertar odernado
if(childItems.isEmpty())
childItems.append(item);
else
{
TreeItem * last = childItems.back();
QString nameLast = last->data(1).toString(); //TODO usar info name si est<73> disponible, sino el nombre del fichero.....
QString nameCurrent = item->data(1).toString();
QList<TreeItem *>::iterator i;
i = childItems.end();
i--;
while (naturalSortLessThanCI(nameCurrent,nameLast) && i != childItems.begin())
{
i--;
nameLast = (*i)->data(1).toString();
}
if(!naturalSortLessThanCI(nameCurrent,nameLast)) //si se ha encontrado un elemento menor que current, se inserta justo despu<70>s
childItems.insert(++i,item);
else
childItems.insert(i,item);
}
//childItems.append(item);
}
//! [2]
//! [3]
TreeItem *TreeItem::child(int row)
{
return childItems.value(row);
}
//! [3]
//! [4]
int TreeItem::childCount() const
{
return childItems.count();
}
//! [4]
//! [5]
int TreeItem::columnCount() const
{
return itemData.count();
}
//! [5]
//! [6]
QVariant TreeItem::data(int column) const
{
return itemData.value(column);
}
//! [6]
//! [7]
TreeItem *TreeItem::parent()
{
return parentItem;
}
//! [7]
//! [8]
int TreeItem::row() const
{
if (parentItem)
return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
return 0;
}
//! [8]
QList<QVariant> TreeItem::getData() const
{
return itemData;
}

View File

@ -0,0 +1,78 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef TREEITEM_H
#define TREEITEM_H
#include <QList>
#include <QVariant>
#include <QModelIndex>
//! [0]
class TreeItem
{
public:
TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
~TreeItem();
void appendChild(TreeItem *child);
TreeItem *child(int row);
int childCount() const;
int columnCount() const;
QVariant data(int column) const;
QList<QVariant> getData() const;
int row() const;
TreeItem *parent();
TreeItem *parentItem;
unsigned long long int id;
QList<QString> comicNames;
TreeItem * originalItem;
private:
QList<TreeItem*> childItems;
QList<QVariant> itemData;
};
//! [0]
#endif

View File

@ -0,0 +1,413 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
****************************************************************************/
/*
treemodel.cpp
Provides a simple tree model to show how to create and use hierarchical
models.
*/
#include <QtGui>
#include "treeitem.h"
#include "treemodel.h"
#include "data_base_management.h"
#define ROOT 1
TreeModel::TreeModel(QObject *parent)
: QAbstractItemModel(parent),rootItem(0),rootBeforeFilter(0),filterEnabled(false),includeComics(false)
{
connect(this,SIGNAL(beforeReset()),this,SIGNAL(modelAboutToBeReset()));
connect(this,SIGNAL(reset()),this,SIGNAL(modelReset()));
}
//! [0]
TreeModel::TreeModel( QSqlQuery &sqlquery, QObject *parent)
: QAbstractItemModel(parent),rootItem(0),rootBeforeFilter(0),filterEnabled(false),includeComics(false)
{
//lo m<>s probable es que el nodo ra<72>z no necesite tener informaci<63>n
QList<QVariant> rootData;
rootData << "root"; //id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
rootItem = new TreeItem(rootData);
rootItem->id = ROOT;
rootItem->parentItem = 0;
setupModelData(sqlquery, rootItem);
//sqlquery.finish();
}
//! [0]
//! [1]
TreeModel::~TreeModel()
{
if(rootItem != 0)
delete rootItem;
}
//! [1]
//! [2]
int TreeModel::columnCount(const QModelIndex &parent) const
{
if (parent.isValid())
return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
else
return rootItem->columnCount();
}
//! [2]
//! [3]
QVariant TreeModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role == Qt::DecorationRole)
return QVariant(QIcon(":/images/folder.png"));
if (role != Qt::DisplayRole)
return QVariant();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(index.column());
}
//! [3]
//! [4]
Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
//! [4]
//! [5]
QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return rootItem->data(section);
return QVariant();
}
//! [5]
//! [6]
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent)
const
{
if (!hasIndex(row, column, parent))
return QModelIndex();
TreeItem *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<TreeItem*>(parent.internalPointer());
TreeItem *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
else
return QModelIndex();
}
//! [6]
//! [7]
QModelIndex TreeModel::parent(const QModelIndex &index) const
{
if (!index.isValid())
return QModelIndex();
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
TreeItem *parentItem = childItem->parent();
if (parentItem == rootItem)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);
}
//! [7]
QModelIndex TreeModel::indexFromItem(TreeItem * item,int column)
{
//if(item->parent() != 0)
// return index(item->row(),column,parent(indexFromItem(item->parent(),column-1)));
//else
// return index(item->row(),0,QModelIndex());
return createIndex(item->row(), column, item);
}
//! [8]
int TreeModel::rowCount(const QModelIndex &parent) const
{
TreeItem *parentItem;
if (parent.column() > 0)
return 0;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<TreeItem*>(parent.internalPointer());
return parentItem->childCount();
}
//! [8]
void TreeModel::setupModelData(QString path)
{
beginResetModel();
if(rootItem != 0)
delete rootItem; //TODO comprobar que se libera bien la memoria
filterEnabled = false;
rootItem = 0;
rootBeforeFilter = 0;
//inicializar el nodo ra<72>z
QList<QVariant> rootData;
rootData << "root"; //id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
rootItem = new TreeItem(rootData);
rootItem->id = ROOT;
rootItem->parentItem = 0;
//cargar la base de datos
_databasePath = path;
QSqlDatabase db = DataBaseManagement::loadDatabase(path);
//crear la consulta
{
QSqlQuery selectQuery("select * from folder where id <> 1 order by parentId,name",db);
setupModelData(selectQuery,rootItem);
}
//selectQuery.finish();
db.close();
QSqlDatabase::removeDatabase(path);
endResetModel();
}
void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
{
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
//el diccionario permitir<69> encontrar cualquier nodo del <20>rbol r<>pidamente, de forma que a<>adir un hijo a un padre sea O(1)
items.clear();
//se a<>ade el nodo 0
items.insert(parent->id,parent);
while (sqlquery.next()) {
QList<QVariant> data;
QSqlRecord record = sqlquery.record();
data << record.value("name").toString();
data << record.value("path").toString();
TreeItem * item = new TreeItem(data);
item->id = record.value("id").toULongLong();
//la inserci<63>n de hijos se hace de forma ordenada
items.value(record.value("parentId").toULongLong())->appendChild(item);
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
items.insert(item->id,item);
}
}
void TreeModel::setupFilteredModelData()
{
beginResetModel();
//TODO hay que liberar memoria de anteriores filtrados
//inicializar el nodo ra<72>z
if(rootBeforeFilter == 0)
rootBeforeFilter = rootItem;
else
delete rootItem;//los resultados de la b<>squeda anterior deben ser borrados
QList<QVariant> rootData;
rootData << "root"; //id 1, padre 1, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
rootItem = new TreeItem(rootData);
rootItem->id = ROOT;
rootItem->parentItem = 0;
//cargar la base de datos
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
//crear la consulta
{
QSqlQuery selectQuery(db); //TODO check
if(!includeComics)
{
selectQuery.prepare("select * from folder where id <> 1 and upper(name) like upper(:filter) order by parentId,name ");
selectQuery.bindValue(":filter", "%%"+filter+"%%");
}
else
{
selectQuery.prepare("SELECT DISTINCT f.id, f.parentId, f.name, f.path FROM folder f INNER JOIN comic c ON (f.id = c.parentId) WHERE f.id <> 1 AND ((UPPER(c.fileName) like UPPER(:filter)) OR (UPPER(f.name) like UPPER(:filter2))) ORDER BY f.parentId,f.name");
selectQuery.bindValue(":filter", "%%"+filter+"%%");
selectQuery.bindValue(":filter2", "%%"+filter+"%%");
}
selectQuery.exec();
setupFilteredModelData(selectQuery,rootItem);
}
//selectQuery.finish();
db.close();
QSqlDatabase::removeDatabase(_databasePath);
endResetModel();
}
void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent)
{
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
filteredItems.clear();
//se a<>ade el nodo 0 al modelo que representa el arbol de elementos que cumplen con el filtro
filteredItems.insert(parent->id,parent);
while (sqlquery.next()) { //se procesan todos los folders que cumplen con el filtro
//datos de la base de datos
QList<QVariant> data;
QSqlRecord record = sqlquery.record();
data << record.value("name").toString();
data << record.value("path").toString();
TreeItem * item = new TreeItem(data);
item->id = sqlquery.value(0).toULongLong();
//id del padre
quint64 parentId = record.value("parentId").toULongLong();
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
if(!filteredItems.contains(item->id))
filteredItems.insert(item->id,item);
//es necesario conocer las coordenadas de origen para poder realizar scroll autom<6F>tico en la vista
item->originalItem = items.value(item->id);
//si el padre ya existe en el modelo, el item se a<>ade como hijo
if(filteredItems.contains(parentId))
filteredItems.value(parentId)->appendChild(item);
else//si el padre a<>n no se ha a<>adido, hay que a<>adirlo a <20>l y todos los padres hasta el nodo ra<72>z
{
//comprobamos con esta variable si el <20>ltimo de los padres (antes del nodo ra<72>z) ya exist<73>a en el modelo
bool parentPreviousInserted = false;
//mientras no se alcance el nodo ra<72>z se procesan todos los padres (de abajo a arriba)
while(parentId != ROOT )
{
//el padre no estaba en el modelo filtrado, as<61> que se rescata del modelo original
TreeItem * parentItem = items.value(parentId);
//se debe crear un nuevo nodo (para no compartir los hijos con el nodo original)
TreeItem * newparentItem = new TreeItem(parentItem->getData()); //padre que se a<>adir<69> a la estructura de directorios filtrados
newparentItem->id = parentId;
newparentItem->originalItem = parentItem;
//si el modelo contiene al padre, se a<>ade el item actual como hijo
if(filteredItems.contains(parentId))
{
filteredItems.value(parentId)->appendChild(item);
parentPreviousInserted = true;
}
//sino se registra el nodo para poder encontrarlo con posterioridad y se a<>ade el item actual como hijo
else
{
newparentItem->appendChild(item);
filteredItems.insert(newparentItem->id,newparentItem);
parentPreviousInserted = false;
}
//variables de control del bucle, se avanza hacia el nodo padre
item = newparentItem;
parentId = parentItem->parentItem->id;
}
//si el nodo es hijo de 1 y no hab<61>a sido previamente insertado como hijo, se a<>ade como tal
if(!parentPreviousInserted)
filteredItems.value(ROOT)->appendChild(item);
}
}
}
QString TreeModel::getDatabase()
{
return _databasePath;
}
QString TreeModel::getFolderPath(const QModelIndex &folder)
{
return static_cast<TreeItem*>(folder.internalPointer())->data(1).toString();
}
void TreeModel::setFilter(QString filter, bool includeComics)
{
this->filter = filter;
this->includeComics = includeComics;
filterEnabled = true;
setupFilteredModelData();
}
void TreeModel::resetFilter()
{
beginResetModel();
filter = "";
includeComics = false;
//TODO hay que liberar la memoria reservada para el filtrado
//items.clear();
filteredItems.clear();
TreeItem * root = rootItem;
rootItem = rootBeforeFilter; //TODO si no se aplica el filtro previamente, esto invalidar<61>a en modelo
if(root !=0)
delete root;
rootBeforeFilter = 0;
filterEnabled = false;
endResetModel();
}

View File

@ -0,0 +1,106 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef TREEMODEL_H
#define TREEMODEL_H
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
#include <QSqlQuery>
#include <QSqlDatabase>
class TreeItem;
//! [0]
class TreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
TreeModel(QObject *parent = 0);
TreeModel( QSqlQuery &sqlquery, QObject *parent = 0);
~TreeModel();
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
QModelIndex indexFromItem(TreeItem * item, int column);
/*QModelIndex _indexFromItem(TreeItem * item, int column);
int column;*/
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
void setupModelData(QString path);
QString getDatabase();
//M<>todos de conveniencia
QString getFolderPath(const QModelIndex &folder);
void setFilter(QString filter, bool includeComics);
void resetFilter();
bool isFilterEnabled(){return filterEnabled;};
private:
void setupModelData( QSqlQuery &sqlquery, TreeItem *parent);
void setupFilteredModelData( QSqlQuery &sqlquery, TreeItem *parent);
void setupFilteredModelData();
TreeItem *rootItem; //el <20>rbol
QMap<unsigned long long int, TreeItem *> items; //relaci<63>n entre folders
TreeItem *rootBeforeFilter;
QMap<unsigned long long int, TreeItem *> filteredItems; //relaci<63>n entre folders
QString _databasePath;
bool includeComics;
QString filter;
bool filterEnabled;
signals:
void beforeReset();
void reset();
};
//! [0]
#endif

View File

@ -0,0 +1,127 @@
#include "db_helper.h"
#include <QMap>
#include <QString>
#include <QList>
#include <QDateTime>
#include <QFile>
#include <QFileInfo>
#include <QCoreApplication>
#include <QTextStream>
#include "library_item.h"
#include "comic_db.h"
#include "data_base_management.h"
#include "folder.h"
//server
//TODO optimizar, evitar que se tenga que leer en cada petición el archivo
//conservar un QDateTime stático que compruebe si libraries.yacr ha sido modificado
//libraries debe ser una variable estática
static QDateTime lastModified;
static QMap<QString,QString> libraries;
QMap<QString,QString> DBHelper::getLibraries()
{
QFileInfo fi(QCoreApplication::applicationDirPath()+"/libraries.yacr");
if(fi.lastModified() == lastModified)
return libraries;
lastModified = fi.lastModified();
libraries.clear();
QFile f(QCoreApplication::applicationDirPath()+"/libraries.yacr");
f.open(QIODevice::ReadOnly);
QTextStream txtS(&f);
QString content = txtS.readAll();
QStringList lines = content.split('\n');
QString line,name;
int i=0;
foreach(line,lines)
{
if((i%2)==0)
{
name = line;
}
else
{
//sólo se agregan las bibliotecas realmente disponibles
QSqlDatabase db = DataBaseManagement::loadDatabase(line.trimmed()+"/.yacreaderlibrary");
if(db.isValid())
libraries.insert(name.trimmed(),line.trimmed());
db.close();
}
i++;
}
f.close();
return libraries;
}
QList<LibraryItem *> DBHelper::getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId)
{
QString libraryPath = DBHelper::getLibraries().value(libraryName);
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
QList<LibraryItem *> list = Folder::getFoldersFromParent(folderId,db,false);
db.close();
QSqlDatabase::removeDatabase(libraryPath);
return list;
}
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId)
{
QString libraryPath = DBHelper::getLibraries().value(libraryName);
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
QList<LibraryItem *> list = ComicDB::getComicsFromParent(folderId,db,false);
db.close();
QSqlDatabase::removeDatabase(libraryPath);
return list;
}
qulonglong DBHelper::getParentFromComicFolderId(const QString & libraryName, qulonglong id)
{
QString libraryPath = DBHelper::getLibraries().value(libraryName);
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
Folder f(id,db);
db.close();
QSqlDatabase::removeDatabase(libraryPath);
return f.parentId;
}
ComicDB DBHelper::getComicInfo(const QString & libraryName, qulonglong id)
{
QString libraryPath = DBHelper::getLibraries().value(libraryName);
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
ComicDB comic;
comic.load(id,db);
db.close();
QSqlDatabase::removeDatabase(libraryPath);
return comic;
}
QString DBHelper::getFolderName(const QString & libraryName, qulonglong id)
{
QString libraryPath = DBHelper::getLibraries().value(libraryName);
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
QString name="";
{
QSqlQuery selectQuery(db); //TODO check
selectQuery.prepare("SELECT name FROM folder WHERE id = :id");
selectQuery.bindValue(":id", id);
selectQuery.exec();
if(selectQuery.next())
{
QSqlRecord record = selectQuery.record();
name = record.value(0).toString();
}
}
db.close();
QSqlDatabase::removeDatabase(libraryPath);
return name;
}

View File

@ -0,0 +1,22 @@
#ifndef DB_HELPER_H
#define DB_HELPER_H
class QString;
class LibraryItem;
#include "comic_db.h"
#include <QMap>
#include <QList>
class DBHelper
{
public:
//server
static QMap<QString,QString> getLibraries();
static QList<LibraryItem *> getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId);
static QList<LibraryItem *> getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId);
static qulonglong getParentFromComicFolderId(const QString & libraryName, qulonglong id);
static ComicDB getComicInfo(const QString & libraryName, qulonglong id);
static QString getFolderName(const QString & libraryName, qulonglong id);
};
#endif

View File

@ -0,0 +1,92 @@
#include "export_comics_info_dialog.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QDir>
#include <QMessageBox>
#include "data_base_management.h"
ExportComicsInfoDialog::ExportComicsInfoDialog(QWidget *parent)
: QDialog(parent)
{
textLabel = new QLabel(tr("Output file : "));
path = new QLineEdit;
textLabel->setBuddy(path);
accept = new QPushButton(tr("Create"));
accept->setDisabled(true);
connect(accept,SIGNAL(clicked()),this,SLOT(exportComicsInfo()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected()));
find = new QPushButton(QIcon(":/images/db.png"),"");
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
QHBoxLayout *libraryLayout = new QHBoxLayout;
libraryLayout->addWidget(textLabel);
libraryLayout->addWidget(path);
libraryLayout->addWidget(find);
libraryLayout->setStretchFactor(find,0); //TODO
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(libraryLayout);
mainLayout->addWidget(progress=new QLabel());
mainLayout->addStretch();
mainLayout->addLayout(bottomLayout);
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/exportComicsInfo.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setModal(true);
setWindowTitle(tr("Export comics info"));
}
ExportComicsInfoDialog::~ExportComicsInfoDialog()
{
}
void ExportComicsInfoDialog::findPath()
{
QString s = QFileDialog::getSaveFileName(this,tr("Destination database name"),".","*.ydb");
if(!s.isEmpty())
{
path->setText(s);
accept->setEnabled(true);
}
}
void ExportComicsInfoDialog::exportComicsInfo()
{
QFileInfo f(path->text());
QFileInfo fPath(f.absoluteDir().path());
if(fPath.exists() && fPath.isDir() && fPath.isWritable())
{
DataBaseManagement::exportComicsInfo(source,path->text());
close();
}
else
QMessageBox::critical(NULL,tr("Problem found while writing"),tr("The selected path for the output file does not exist or is not a valid path. Be sure that you have write access to this folder"));
}
void ExportComicsInfoDialog::close()
{
path->clear();
QDialog::close();
}

View File

@ -0,0 +1,35 @@
#ifndef EXPORT_COMICS_INFO_DIALOG_H
#define EXPORT_COMICS_INFO_DIALOG_H
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
class ExportComicsInfoDialog : public QDialog
{
Q_OBJECT
public:
ExportComicsInfoDialog(QWidget *parent = 0);
~ExportComicsInfoDialog();
QString source;
public slots:
void findPath();
void exportComicsInfo();
void close();
private:
QLabel * progress;
QLabel * textLabel;
QLineEdit * path;
QPushButton * find;
QPushButton * accept;
QPushButton * cancel;
};
#endif // EXPORT_COMICS_INFO_DIALOG_H

View File

@ -0,0 +1,104 @@
#include "export_library_dialog.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QMessageBox>
#include <QDir>
ExportLibraryDialog::ExportLibraryDialog(QWidget * parent)
:QDialog(parent),progressCount(0)
{
textLabel = new QLabel(tr("Output folder : "));
path = new QLineEdit;
textLabel->setBuddy(path);
accept = new QPushButton(tr("Create"));
accept->setDisabled(true);
connect(accept,SIGNAL(clicked()),this,SLOT(exportLibrary()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected()));
find = new QPushButton(QIcon(":/images/comicFolder.png"),"");
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
QHBoxLayout *libraryLayout = new QHBoxLayout;
libraryLayout->addWidget(textLabel);
libraryLayout->addWidget(path);
libraryLayout->addWidget(find);
libraryLayout->setStretchFactor(find,0); //TODO
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
progressBar = new QProgressBar(this);
progressBar->setMinimum(0);
progressBar->setMaximum(0);
progressBar->setTextVisible(false);
progressBar->hide();
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(libraryLayout);
mainLayout->addStretch();
mainLayout->addWidget(progressBar);
mainLayout->addLayout(bottomLayout);
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/exportLibrary.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setModal(true);
setWindowTitle(tr("Create covers package"));
t.setInterval(500);
connect(&t,SIGNAL(timeout()),this,SLOT(updateProgress()));
}
void ExportLibraryDialog::exportLibrary()
{
QFileInfo f(path->text());
if(f.exists() && f.isDir() && f.isWritable())
{
progressBar->show();
accept->setEnabled(false);
emit exportPath(QDir::cleanPath(path->text()));
t.start();
}
else
QMessageBox::critical(NULL,tr("Problem found while writing"),tr("The selected path for the output file does not exist or is not a valid path. Be sure that you have write access to this folder"));
}
void ExportLibraryDialog::findPath()
{
QString s = QFileDialog::getExistingDirectory(0,tr("Destination directory"),".");
if(!s.isEmpty())
{
path->setText(s);
accept->setEnabled(true);
}
}
void ExportLibraryDialog::close()
{
path->clear();
progressBar->hide();
accept->setEnabled(false);
t.stop();
progressCount=0;
QDialog::close();
}
void ExportLibraryDialog::run()
{
}

View File

@ -0,0 +1,36 @@
#ifndef EXPORT_LIBRARY_DIALOG_H
#define EXPORT_LIBRARY_DIALOG_H
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QString>
#include <QThread>
#include <QTimer>
#include <QProgressBar>
class ExportLibraryDialog : public QDialog
{
Q_OBJECT
public:
ExportLibraryDialog(QWidget * parent = 0);
public slots:
void exportLibrary();
void findPath();
void close();
private:
int progressCount;
QProgressBar *progressBar;
QLabel * textLabel;
QLineEdit * path;
QPushButton * find;
QPushButton * accept;
QPushButton * cancel;
void run();
QTimer t;
signals:
void exportPath(QString);
};
#endif

View File

@ -0,0 +1,12 @@
<RCC>
<qresource>
<file>../files/about.html</file>
<file>../files/helpYACReaderLibrary.html</file>
</qresource>
<qresource lang="es_ES">
<file alias="/files/about.html">../files/about_es_ES.html</file>
<file alias="/files/helpYACReaderLibrary.html">../files/helpYACReaderLibrary_es_ES.html</file>
</qresource>
</RCC>

BIN
YACReaderLibrary/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

3
YACReaderLibrary/icon.rc Normal file
View File

@ -0,0 +1,3 @@
IDI_ICON1 ICON DISCARDABLE "icon.ico"
IDI_ICON2 ICON DISCARDABLE "icon2.ico"
IDI_ICON3 ICON DISCARDABLE "icon3.ico"

BIN
YACReaderLibrary/icon2.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

BIN
YACReaderLibrary/icon3.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

View File

@ -0,0 +1,74 @@
<RCC>
<qresource prefix="/" >
<file>../images/deleteLibrary.png</file>
<file>../images/folder.png</file>
<file>../images/help.png</file>
<file>../images/icon.png</file>
<file>../images/iconLibrary.png</file>
<file>../images/new.png</file>
<file>../images/openLibrary.png</file>
<file>../images/removeLibrary.png</file>
<file>../images/updateLibrary.png</file>
<file>../images/setRoot.png</file>
<file>../images/expand.png</file>
<file>../images/colapse.png</file>
<file>../images/comicFolder.png</file>
<file>../images/notCover.png</file>
<file>../images/edit.png</file>
<file>../images/fit.png</file>
<file>../images/properties.png</file>
<file>../images/options.png</file>
<file>../images/flow1.png</file>
<file>../images/flow2.png</file>
<file>../images/flow3.png</file>
<file>../images/flow4.png</file>
<file>../images/flow5.png</file>
<file>../images/importLibrary.png</file>
<file>../images/exportLibrary.png</file>
<file>../images/open.png</file>
<file>../images/coversPackage.png</file>
<file>../images/setRead.png</file>
<file>../images/setAllRead.png</file>
<file>../images/setUnread.png</file>
<file>../images/setAllUnread.png</file>
<file>../images/showMarks.png</file>
<file>../images/importCover.png</file>
<file>../images/editComic.png</file>
<file>../images/selectAll.png</file>
<file>../images/hideComicFlow.png</file>
<file>../images/exportComicsInfo.png</file>
<file>../images/importComicsInfo.png</file>
<file>../images/db.png</file>
<file>../images/asignNumber.png</file>
<file>../images/defaultCover.png</file>
<file>../images/server.png</file>
<file>../images/iphoneConfig.png</file>
<file>../images/qrMessage.png</file>
<file>../images/onStartFlowSelection.png</file>
<file>../images/onStartFlowSelection_es.png</file>
<file>../images/useNewFlowButton.png</file>
<file>../images/useOldFlowButton.png</file>
<file>../images/zip.png</file>
<file>../images/rar.png</file>
<file>../images/tar.png</file>
<file>../images/7z.png</file>
<file>../images/pdf.png</file>
<file>../images/comicZip.png</file>
<file>../images/comicRar.png</file>
<file>../images/comicTar.png</file>
<file>../images/comic7z.png</file>
<file>../images/serverConfigBackground.png</file>
<file>../images/noLibrariesIcon.png</file>
<file>../images/noLibrariesLine.png</file>
<file>../images/importingIcon.png</file>
<file>../images/updatingIcon.png</file>
<file>../images/importTopCoversDecoration.png</file>
<file>../images/importBottomCoversDecoration.png</file>
<file>../images/glowLine.png</file>
<file>../images/clearSearch.png</file>
<file>../images/iconSearch.png</file>
<file>../images/readRibbon.png</file>
<file>../images/shownCovers.png</file>
<file>../images/hiddenCovers.png</file>
</qresource>
</RCC>

View File

@ -0,0 +1,111 @@
#include "import_comics_info_dialog.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QProgressBar>
#include "data_base_management.h"
ImportComicsInfoDialog::ImportComicsInfoDialog(QWidget *parent)
: QDialog(parent)
{
setModal(true);
setWindowTitle(tr("Import comics info"));
textLabel = new QLabel(tr("Info database location : "));
path = new QLineEdit;
textLabel->setBuddy(path);
accept = new QPushButton(tr("Import"));
accept->setDisabled(true);
connect(accept,SIGNAL(clicked()),this,SLOT(import()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
//connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected()));
find = new QPushButton(QIcon(":/images/db.png"),"");
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
QHBoxLayout *libraryLayout = new QHBoxLayout;
libraryLayout->addWidget(textLabel);
libraryLayout->addWidget(path);
libraryLayout->addWidget(find);
libraryLayout->setStretchFactor(find,0); //TODO
progressBar = new QProgressBar(this);
progressBar->setMinimum(0);
progressBar->setMaximum(0);
progressBar->setTextVisible(false);
progressBar->hide();
connect(accept,SIGNAL(progressBar()),this,SLOT(show()));
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(libraryLayout);
mainLayout->addStretch();
mainLayout->addWidget(progressBar);
mainLayout->addLayout(bottomLayout);
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/importComicsInfo.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setModal(true);
}
ImportComicsInfoDialog::~ImportComicsInfoDialog()
{
}
void ImportComicsInfoDialog::findPath()
{
QString s = QFileDialog::getOpenFileName(0,"Comics Info",".",tr("Comics info file (*.ydb)"));
if(!s.isEmpty())
{
path->setText(s);
accept->setEnabled(true);
}
}
void ImportComicsInfoDialog::import()
{
progressBar->show();
Importer * importer = new Importer();
importer->source = path->text();
importer->dest = dest;
connect(importer,SIGNAL(finished()),this,SLOT(close()));
connect(importer,SIGNAL(finished()),this,SLOT(hide()));
importer->start();
}
void ImportComicsInfoDialog::close()
{
path->clear();
progressBar->hide();
accept->setDisabled(true);
QDialog::close();
emit(finished(0));
}
void Importer::run()
{
DataBaseManagement::importComicsInfo(source,dest);
}

View File

@ -0,0 +1,52 @@
#ifndef IMPORT_COMICS_INFO_DIALOG_H
#define IMPORT_COMICS_INFO_DIALOG_H
#include <QDialog>
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QProgressBar>
#include <QThread>
class Importer : public QThread
{
public:
QString source;
QString dest;
private:
void run();
};
class ImportComicsInfoDialog : public QDialog
{
Q_OBJECT
public:
ImportComicsInfoDialog(QWidget *parent = 0);
~ImportComicsInfoDialog();
QString dest;
private:
QLabel * nameLabel;
QLabel * textLabel;
QLabel * destLabel;
QLineEdit * path;
QLineEdit * destPath;
QLineEdit * nameEdit;
QPushButton * find;
QPushButton * findDest;
QPushButton * accept;
QPushButton * cancel;
QLabel * progress;
void setupUI();
int progressCount;
QProgressBar *progressBar;
public slots:
void findPath();
void import();
void close();
};
#endif // IMPORT_COMICS_INFO_DIALOG_H

View File

@ -0,0 +1,144 @@
#include "import_library_dialog.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QGridLayout>
ImportLibraryDialog::ImportLibraryDialog(QWidget * parent)
:QDialog(parent),progressCount(0)
{
setupUI();
}
void ImportLibraryDialog::setupUI()
{
nameLabel = new QLabel(tr("Library Name : "));
nameEdit = new QLineEdit;
nameLabel->setBuddy(nameEdit);
connect(nameEdit,SIGNAL(textChanged(QString)),this,SLOT(nameEntered()));
textLabel = new QLabel(tr("Package location : "));
path = new QLineEdit;
textLabel->setBuddy(path);
destLabel = new QLabel(tr("Destination folder : "));
destPath = new QLineEdit;
textLabel->setBuddy(destPath);
accept = new QPushButton(tr("Unpack"));
accept->setDisabled(true);
connect(accept,SIGNAL(clicked()),this,SLOT(add()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
//connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected()));
find = new QPushButton(QIcon(":/images/coversPackage.png"),"");
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
findDest = new QPushButton(QIcon(":/images/open.png"),"");
connect(findDest,SIGNAL(clicked()),this,SLOT(findDestination()));
QGridLayout * content = new QGridLayout;
content->addWidget(nameLabel,0,0);
content->addWidget(nameEdit,0,1);
content->addWidget(textLabel,1,0);
content->addWidget(path,1,1);
content->addWidget(find,1,2);
content->setColumnStretch(2,0); //TODO
content->addWidget(destLabel,2,0);
content->addWidget(destPath,2,1);
content->addWidget(findDest,2,2);
//destLayout->setStretchFactor(findDest,0); //TODO
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
progressBar = new QProgressBar(this);
progressBar->setMinimum(0);
progressBar->setMaximum(0);
progressBar->setTextVisible(false);
progressBar->hide();
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(content);
//mainLayout->addWidget(progress = new QLabel());
mainLayout->addStretch();
mainLayout->addWidget(progressBar);
mainLayout->addLayout(bottomLayout);
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/importLibrary.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setModal(true);
setWindowTitle(tr("Extract a catalog"));
}
void ImportLibraryDialog::add()
{
accept->setEnabled(false);
progressBar->show();
emit(unpackCLC(QDir::cleanPath(path->text()),QDir::cleanPath(destPath->text()),nameEdit->text()));
}
void ImportLibraryDialog::findPath()
{
QString s = QFileDialog::getOpenFileName(0,"Covers Package",".",tr("Compresed library covers (*.clc)"));
if(!s.isEmpty())
{
path->setText(s);
if(!destPath->text().isEmpty() && !nameEdit->text().isEmpty())
accept->setEnabled(true);
}
}
void ImportLibraryDialog::findDestination()
{
QString s = QFileDialog::getExistingDirectory(0,"Folder",".",QFileDialog::ShowDirsOnly);
if(!s.isEmpty())
{
destPath->setText(s);
if(!path->text().isEmpty() && !nameEdit->text().isEmpty())
accept->setEnabled(true);
}
}
void ImportLibraryDialog::nameEntered()
{
if(!nameEdit->text().isEmpty())
{
if(!path->text().isEmpty() && !destPath->text().isEmpty())
accept->setEnabled(true);
}
else
accept->setEnabled(false);
}
void ImportLibraryDialog::close()
{
path->clear();
destPath->clear();
nameEdit->clear();
accept->setEnabled(false);
progressBar->hide();
QDialog::hide();
}
void ImportLibraryDialog::closeEvent ( QCloseEvent * e )
{
close();
}

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