Compare commits
372 commits
Author | SHA1 | Date | |
---|---|---|---|
|
38975d1f64 | ||
|
53f458d71a | ||
|
f138f0b89d | ||
|
1d71f3477a | ||
|
2d0d61f3e5 | ||
|
1905cec933 | ||
|
912bc36dad | ||
|
317a864ff6 | ||
|
d473d23d55 | ||
|
29c5bbf62b | ||
|
e4038db1b0 | ||
|
fce00048ef | ||
|
62bcecccbe | ||
|
d3bc294f0a | ||
|
5d5e86dc6b | ||
|
3045244c71 | ||
|
3aad66c714 | ||
|
31bfd08fae | ||
|
6f4d602456 | ||
|
3d8ade0bef | ||
|
7a144471e3 | ||
|
5433d81764 | ||
|
a51061df7c | ||
|
741bdd7724 | ||
|
f9b740c94b | ||
|
371c06b430 | ||
|
38d5a95982 | ||
|
ac84fe079e | ||
|
53ca370f92 | ||
|
3abd1e103f | ||
|
8712ee6eea | ||
|
9287da53aa | ||
|
6a06fa5ffd | ||
|
b7aeb097a3 | ||
|
b70be18897 | ||
|
15cae28413 | ||
|
5f71f2dd64 | ||
|
51c90e6443 | ||
|
d037600d0f | ||
|
d094db4d89 | ||
|
515d3944e7 | ||
|
31cdaf0939 | ||
|
2cd0bb2812 | ||
|
445cc19b10 | ||
|
56395707fa | ||
|
aaae57b113 | ||
|
da923e3a32 | ||
|
071c39b6f3 | ||
|
04830863ab | ||
|
95ef563230 | ||
|
8ea54769c5 | ||
|
f6ec27b423 | ||
|
0874122bda | ||
|
813e1edb6a | ||
|
c30e7d3548 | ||
|
fb40a89858 | ||
|
64a7b0120f | ||
|
8c6344eef8 | ||
|
9ff8775fab | ||
|
6c7e09fdb5 | ||
|
1e6be94965 | ||
|
342a1a82f0 | ||
|
58619bd63a | ||
|
a7d181a867 | ||
|
18f0c66dba | ||
|
ab96dc547f | ||
|
6ba065b4b1 | ||
|
ba2a826b56 | ||
|
21b3819a86 | ||
|
08b66ed711 | ||
|
ff2eae04cf | ||
|
b4aaa85a2d | ||
|
f30f40683e | ||
|
f84d05e514 | ||
|
dd19333c81 | ||
|
b1cd524b4c | ||
|
0dd09a2707 | ||
|
6e2ded84e2 | ||
|
5799985c92 | ||
|
cecc038a6d | ||
|
993eb75cf7 | ||
|
ea39f0285b | ||
|
438628598f | ||
|
09ceb4f0ec | ||
|
e16bfbe7c6 | ||
|
ef3b53abdb | ||
|
bb6fa7926d | ||
|
40da0790e2 | ||
|
0312a367f4 | ||
|
71b2986a37 | ||
|
3be30e58e6 | ||
|
444cf09ae0 | ||
|
0efd96c072 | ||
|
d8267db9fe | ||
|
4537f32005 | ||
|
9ba3f2daf1 | ||
|
4f06a8e85e | ||
|
595a253693 | ||
|
23fe3741f9 | ||
|
8ae48b83e6 | ||
|
afb8d65ea8 | ||
|
390e5dd16d | ||
|
40e7f32846 | ||
|
263090a518 | ||
|
3bcba3b8d7 | ||
|
8843275fde | ||
|
8b4c2f373b | ||
|
2ab6a7d979 | ||
|
0684e677ec | ||
|
6c4e48d69c | ||
|
47cde78edc | ||
|
cd90064f9a | ||
|
9da439e463 | ||
|
6095694d92 | ||
|
4c0a7ed9fd | ||
|
02be96f090 | ||
|
d6db1ff5e2 | ||
|
c93d4a019f | ||
|
71dd1452bc | ||
|
4e5967e36d | ||
|
6ee912680e | ||
|
b6288ca1ee | ||
|
d20c115747 | ||
|
47149e0cd7 | ||
|
a78e2c4449 | ||
|
47fb9c8555 | ||
|
9b6fd90ed2 | ||
|
0da1783c51 | ||
|
cd62f76fc2 | ||
|
96d7fd8772 | ||
|
171dd994c8 | ||
|
76b219dc7c | ||
|
1e93735a4e | ||
|
70206916e4 | ||
|
79e7175f87 | ||
|
77457ad61b | ||
|
7b7fe049a5 | ||
|
1af7acf4fe | ||
|
d0d9e4970f | ||
|
87f9837ac7 | ||
|
69e862f360 | ||
|
b29458fe9f | ||
|
c4519e3faf | ||
|
fa93e20331 | ||
|
5f4b588846 | ||
|
0f0c764d64 | ||
|
a5c93cd422 | ||
|
308fb431b5 | ||
|
aa1dbea32c | ||
|
148de86d87 | ||
|
3892535abc | ||
|
c00ddf0ed0 | ||
|
f0eba7b5cd | ||
|
2d521dcbae | ||
|
7e528ca2bd | ||
|
4336dd6d7b | ||
|
6b11d16bfc | ||
|
81c85f3a51 | ||
|
8cad5d9ae9 | ||
|
7a5e409997 | ||
|
76e579532a | ||
|
e918b8784a | ||
|
497f860aaf | ||
|
fce3974d51 | ||
|
b5e6042f28 | ||
|
2dde092c52 | ||
|
32d3cc6587 | ||
|
0ab3d5486d | ||
|
b93568ad18 | ||
|
0ef25112a5 | ||
|
1a48bf80b3 | ||
|
29b6779f35 | ||
|
737caf9af0 | ||
|
0092b9031b | ||
|
8deca1fd52 | ||
|
f9a64b203e | ||
|
33388dd4fb | ||
|
a4168ef74f | ||
|
ebdfa9e4ee | ||
|
b5b15236f8 | ||
|
6eb71b7ae6 | ||
|
dd5cf63368 | ||
|
83ec5d8040 | ||
|
ee4428c3f3 | ||
|
a330bdce18 | ||
|
a7f169c42a | ||
|
03c51db3e5 | ||
|
e559ef1470 | ||
|
d7fd6a3064 | ||
|
83513fdeb2 | ||
|
bcbed53113 | ||
|
1b87e7a29f | ||
|
c4b8fd0b74 | ||
|
c0fdb31483 | ||
|
68b7afff5e | ||
|
47a032a84d | ||
|
b98cc0e47a | ||
|
ec6224f777 | ||
|
6d444c9aa6 | ||
|
b551fad9ee | ||
|
45da184f53 | ||
|
be390c450c | ||
|
1f947096f3 | ||
|
2f1e1bf7a5 | ||
|
5dcd6cf54f | ||
|
55f6971e6a | ||
|
deaf63eb82 | ||
|
b566dc723c | ||
|
197c54671a | ||
|
b5ea29b372 | ||
|
ab81e701fa | ||
|
6ef84580f3 | ||
|
d9c14241bf | ||
|
01e7e02bcd | ||
|
cb6f836282 | ||
|
137eb965bf | ||
|
c8bf17553b | ||
|
ea803a2727 | ||
|
79653dc244 | ||
|
0f7b776899 | ||
|
598107bcb0 | ||
|
04bf472ff8 | ||
|
4e8692c431 | ||
|
76fdbb987f | ||
|
22b6ec1c63 | ||
|
5125c48654 | ||
|
e6d9a80e1c | ||
|
8c18418f26 | ||
|
07a1e35f58 | ||
|
dd907e3550 | ||
|
acf4dd9ac7 | ||
|
c5217bb9de | ||
|
0e78e74100 | ||
|
8ad40f78a2 | ||
|
0bd35d647c | ||
|
15a13d9648 | ||
|
a41fbe067f | ||
|
5aa2afcc63 | ||
|
0666beccd2 | ||
|
8aef95b143 | ||
|
7db4f21f4e | ||
|
d7ff8e39be | ||
|
cdd850b7ab | ||
|
bacfbccc58 | ||
|
126940f8ea | ||
|
580bbdfdbb | ||
|
93705c7a60 | ||
|
94c5a36414 | ||
|
d6be727318 | ||
|
8e5f3007f3 | ||
|
946ead4698 | ||
|
1b62c663c8 | ||
|
0346a9cc13 | ||
|
9231d9e081 | ||
|
cc1f3ef2cf | ||
|
59c51a99eb | ||
|
3e4e8399d3 | ||
|
bc3c43874d | ||
|
c932d54da1 | ||
|
0a5ba8006c | ||
|
0fe054b3db | ||
|
8fad10a2d1 | ||
|
576f6a616f | ||
|
80d5783620 | ||
|
9246d385b0 | ||
|
0f890337d3 | ||
|
0371b4ca94 | ||
|
af7763848a | ||
|
45b3d11655 | ||
|
9bf1a11cb5 | ||
|
74a4544401 | ||
|
02b0d62688 | ||
|
905745714c | ||
|
f36488c1b7 | ||
|
e0eb980220 | ||
|
0087596a69 | ||
|
0010cd593a | ||
|
43373d159e | ||
|
d16562900f | ||
|
9efbb6d6f0 | ||
|
22c823563b | ||
|
b569aede6b | ||
|
d6ef26b64e | ||
|
86b580c15f | ||
|
e5b105a3c6 | ||
|
86501b45d9 | ||
|
2297853024 | ||
|
86b57b0521 | ||
|
61eaad3fb3 | ||
|
2d766345fe | ||
|
c745d6121b | ||
|
276b9d2759 | ||
|
40b1be8aab | ||
|
234e11c256 | ||
|
12db0ac4ad | ||
|
34e09abd50 | ||
|
3564b083e8 | ||
|
588e3b00c5 | ||
|
f7790e2ed3 | ||
|
187fd4226e | ||
|
1ef3d590fc | ||
|
061a66caae | ||
|
12dc15c122 | ||
|
4fbfd0d5a2 | ||
|
3d08d137e2 | ||
|
5fa287c8aa | ||
|
cac90e2fbb | ||
|
731db2dd1e | ||
|
dab0e0ebf4 | ||
|
027620277a | ||
|
01b2828838 | ||
|
bb1d1fbf27 | ||
|
7913a6c306 | ||
|
657cd37269 | ||
|
7d8ca4ac4d | ||
|
6ac268e7c7 | ||
|
3a3d6a333d | ||
|
ae3e98b2b5 | ||
|
3f50416972 | ||
|
bbddca04b3 | ||
|
ccbe726d91 | ||
|
ac25c5a0f8 | ||
|
6e22c4ad76 | ||
|
77628cf944 | ||
|
f69d67ce6e | ||
|
f00de6cbb4 | ||
|
a1cd44990b | ||
|
ec0f7848b9 | ||
|
ef1fc4b742 | ||
|
5c6a2a824c | ||
|
73ab236c5e | ||
|
460213ffa8 | ||
|
6d84ac5975 | ||
|
724cfb6eee | ||
|
2131cd4c5f | ||
|
75cb01961b | ||
|
9e25c1d314 | ||
|
dbde0d7dd1 | ||
|
a5422ae486 | ||
|
9648f3ea03 | ||
|
03653e13e6 | ||
|
2604c65466 | ||
|
0ff8b6e2e2 | ||
|
c270ac5a93 | ||
|
ded0d4a2cb | ||
|
0da94cc3b3 | ||
|
dc89381374 | ||
|
1438f8ca0c | ||
|
44a89a5d51 | ||
|
4d76999df6 | ||
|
4d0eeb35c2 | ||
|
cdcc7dc520 | ||
|
1d1c71f596 | ||
|
976fefc9c5 | ||
|
9acc87a5e9 | ||
|
0e9e6cc8bb | ||
|
57e72940f6 | ||
|
e04418dd94 | ||
|
ee52b1de2d | ||
|
a5f5e41493 | ||
|
f6d6b51b9f | ||
|
741d10120a | ||
|
e82232d61e | ||
|
73e37e8f7c | ||
|
602308f731 | ||
|
3e53e6ffcd | ||
|
94e833d32a | ||
|
099860c777 | ||
|
1f9e7d991a | ||
|
bc26edae1d | ||
|
d9007b7525 | ||
|
cb0c0e0e3d |
84 changed files with 43768 additions and 3246 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -41,7 +41,3 @@ target_wrapper.*
|
|||
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# Automatically generated
|
||||
|
||||
seaprint_version.h
|
||||
|
|
674
LICENSE
Normal file
674
LICENSE
Normal file
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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
|
||||
<https://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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
101
README.md
101
README.md
|
@ -3,4 +3,103 @@ Network printing for Sailfish OS
|
|||
|
||||
![SeaPrint icon](icons/172x172/harbour-seaprint.png)
|
||||
|
||||
Print PDFs and images over IPP (Internet Printing Protocol). Most, but not all, IPP-capable printers are supported. For printing PDFs, SeaPrint relies on the printer either supporting PDF natively, or the optional dependency `poppler-utils` to convert to Postscript, PWG-raster or URF-raster. Images can be printed on printers accepting JPEG, PNG and GIF as well as PWG-raster or URF-raster.
|
||||
Print PDFs and images over IPP (Internet Printing Protocol).
|
||||
|
||||
Most, but not all, IPP-capable printers are supported.
|
||||
|
||||
A minority of printers support only PCL and/or their own proprietary formats, these are not supported.
|
||||
|
||||
## Format support
|
||||
|
||||
For PDFs, your printer needs to support one of the following formats:
|
||||
* PDF
|
||||
* Postscript
|
||||
* PWG-raster
|
||||
* URF-raster
|
||||
|
||||
For Postscript, your printer needs to support Postscript natively. (SeaPrint just sends it as-is)
|
||||
|
||||
For Plaintext, SeaPrint can render it to PDF internally and then the requirements follow those of PDF.
|
||||
You can also send Plaintext to supporting printers and leave the rendering up to the printer (SeaPrint will strip leading and trailing Form Feed characters and ensure CR+LF newlines, but not do any reflow or similar). Since rendering will differ between printers, this has lowest priority for automatic format selection.
|
||||
|
||||
For printing "Office" files, like .doc(x) and odt, you need to install
|
||||
`calligraconverter` (from the `calligra` package in Sailfish OS 4.2 onwards).
|
||||
Then the printer support follows that of PDF.
|
||||
|
||||
For images, your printer needs to support one of the following formats:
|
||||
* PNG
|
||||
* JPEG
|
||||
* PWG-raster
|
||||
* URF-raster
|
||||
* PDF
|
||||
* Postscript
|
||||
|
||||
When printing images the result may depend on how they are transferred.
|
||||
If a document-oriented format like PDF/Postscript/PWG/URF is used SeaPrint does scale-and-rotate to fit, otherwise (when transferred as PNG or JPEG) that is left up to the printer. Only when printing images *as images* can the scaling setting be used.
|
||||
|
||||
For printing JPEG images, transferring them as JPEG has highest priority.
|
||||
JPEGs are then (losslessly) re-encoded to the baseline encoding profile to work with all printers (since SeaPrint 1.1).
|
||||
For other image formats JPEG has lowest priority as transfer format since it is lossy.
|
||||
|
||||
![Format flowchart](doc/pipeline.svg)
|
||||
|
||||
Flowchart made with [GoAT](https://github.com/blampe/goat).
|
||||
|
||||
pdf2printable, ppm2pwg and baselinify were made especially for SeaPrint and can be found [here](https://github.com/attah/ppm2pwg).
|
||||
|
||||
Printers with any of these IPP certifications and derivative standards should likely be supported:
|
||||
|
||||
* IPP Everywhere
|
||||
* AirPrint
|
||||
* Mopria
|
||||
* WiFi Direct
|
||||
|
||||
(obviously SeaPrint is unaffiliated and uncertified)
|
||||
|
||||
## Dealing with misbehaving printers
|
||||
|
||||
SeaPrint, in contrast to other printing clients, is not concerned with dealing with the idiosyncrasies of individual printers.
|
||||
If some manufacturer can't make a reasonably well-behaved printer that's on them, not something for SeaPrint to cover for.
|
||||
|
||||
There is however a possibility for you, the user, to override certain attributes (to fix names, claimed format support etc.) in the IPP data structure.
|
||||
|
||||
To see what your printer sent, aka "the debug info", tap it 5 times rapidly without any document selected. The format is a SeaPrint-specific JSON equivalent representation of the IPP binary data.
|
||||
|
||||
Create the file `/home/$USER/.config/net.attah/seaprint/overrides`. (NB: New location for 1.0, and may move again)
|
||||
|
||||
This file should contain a JSON structure, with the outermost key(s) being "what attribute to match on" (uuid recommended if available), the next level is "if this value matches". Everything beneath that is what to inject/replace into the printer's attributes (see debug info above).
|
||||
|
||||
Example:
|
||||
```JSON
|
||||
{
|
||||
"printer-uuid": {
|
||||
"urn:uuid:xxx-yyy-zzz-111-1234567890": {
|
||||
"printer-name": {
|
||||
"tag": 54,
|
||||
"value": "A better name"
|
||||
},
|
||||
"document-format-supported": {
|
||||
"tag": 73,
|
||||
"value": [
|
||||
"application/octet-stream", "application/pdf"
|
||||
]
|
||||
},
|
||||
"some-other-attribute-name": {
|
||||
"tag": 42,
|
||||
"value": "some-value"
|
||||
}
|
||||
},
|
||||
"urn:uuid:other-printer-uuid": {
|
||||
...
|
||||
}
|
||||
},
|
||||
"other-attribute-to-match-other-printer-on": {
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Dealing with printers using other protocols
|
||||
SeaPrint only supports IPP, not port 9100 pjl/pcl raw, lpd/lpr or anything else.
|
||||
|
||||
Just use a PAPPL or CUPS as an intermediary. A shared printer there is IPP by definition.
|
||||
|
|
27
doc/pipeline.goat
Normal file
27
doc/pipeline.goat
Normal file
|
@ -0,0 +1,27 @@
|
|||
Normal flow:
|
||||
.---------------.
|
||||
PDF -------------------------------------------->| +----------------------> PDF 1.5
|
||||
.-----------------. | |
|
||||
Plaintext ---->| QTextDocument +------------------>| pdf2printable +----------------------> Postscript 2
|
||||
'-----------------' | |
|
||||
DOC/PPT .-------------------. | (Poppler+Cairo) | .---------.
|
||||
ODT/ODP ---->| Calligraconverter +---------------->| | | |
|
||||
| (optional) | | +---->| +----> PWG-Raster
|
||||
'-------------------' .--------. | | | ppm2pwg |
|
||||
Images --------------------------->| +---->| | | +----> URF-Raster
|
||||
| | '---------------' | |
|
||||
| QImage +---------------------------->| |
|
||||
.--------------. | | '---------'
|
||||
SVG ---->| QSvgRenderer +---->| +----------------------------------------------> PNG, JPEG,
|
||||
'--------------' '--------' Reverse BMP
|
||||
|
||||
If target format is the same:
|
||||
|
||||
Postscript --------------------------------------------------------------------------------------> Postscript
|
||||
.-----------------------.
|
||||
Plaintext ---->| ensure CR+LF newlines +------------------------------------------------------> Plaintext
|
||||
'-----------------------'
|
||||
PNG --------------------------------------------------------------------------------------> PNG
|
||||
.------------.
|
||||
JPEG ---->| baselinify +-----------------------------------------------------------------> JPEG
|
||||
'------------' (Baseline profile)
|
444
doc/pipeline.svg
Normal file
444
doc/pipeline.svg
Normal file
|
@ -0,0 +1,444 @@
|
|||
<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='441' width='976' font-family='Menlo,Lucida Console,monospace'>
|
||||
<style type="text/css">
|
||||
svg {
|
||||
color: #000000;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
svg {
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<g transform='translate(8,16)'>
|
||||
<path d='M 496,16 L 608,16' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 120,32 L 472,32' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 624,32 L 808,32' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,48 L 304,48' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 120,64 L 152,64' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 320,64 L 472,64' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 624,64 L 808,64' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,80 L 304,80' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,96 L 320,96' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 688,96 L 752,96' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 120,112 L 152,112' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 336,112 L 472,112' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 624,128 L 664,128' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 768,128 L 808,128' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,144 L 320,144' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 360,144 L 416,144' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 120,160 L 336,160' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 432,160 L 472,160' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 768,160 L 808,160' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 496,176 L 608,176' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 432,192 L 664,192' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,208 L 280,208' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 688,208 L 752,208' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 120,224 L 152,224' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 296,224 L 336,224' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 432,224 L 808,224' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,240 L 280,240' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 360,240 L 416,240' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 120,304 L 808,304' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,320 L 352,320' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 120,336 L 152,336' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 368,336 L 808,336' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,352 L 352,352' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 120,368 L 808,368' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,384 L 264,384' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 120,400 L 152,400' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 280,400 L 808,400' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,416 L 264,416' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 160,112 L 160,128' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 336,112 L 336,128' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 344,160 L 344,224' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 432,160 L 432,192' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 432,192 L 432,224' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 480,32 L 480,160' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 624,32 L 624,64' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 624,64 L 624,128' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 624,128 L 624,160' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 672,112 L 672,192' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 768,112 L 768,128' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 768,128 L 768,160' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 768,160 L 768,192' fill='none' stroke='currentColor'></path>
|
||||
<polygon points='160.000000,64.000000 148.000000,58.400002 148.000000,69.599998' fill='currentColor' transform='rotate(0.000000, 152.000000, 64.000000)'></polygon>
|
||||
<polygon points='160.000000,112.000000 148.000000,106.400002 148.000000,117.599998' fill='currentColor' transform='rotate(0.000000, 152.000000, 112.000000)'></polygon>
|
||||
<polygon points='160.000000,224.000000 148.000000,218.399994 148.000000,229.600006' fill='currentColor' transform='rotate(0.000000, 152.000000, 224.000000)'></polygon>
|
||||
<polygon points='160.000000,336.000000 148.000000,330.399994 148.000000,341.600006' fill='currentColor' transform='rotate(0.000000, 152.000000, 336.000000)'></polygon>
|
||||
<polygon points='160.000000,400.000000 148.000000,394.399994 148.000000,405.600006' fill='currentColor' transform='rotate(0.000000, 152.000000, 400.000000)'></polygon>
|
||||
<polygon points='344.000000,160.000000 332.000000,154.399994 332.000000,165.600006' fill='currentColor' transform='rotate(0.000000, 336.000000, 160.000000)'></polygon>
|
||||
<polygon points='344.000000,224.000000 332.000000,218.399994 332.000000,229.600006' fill='currentColor' transform='rotate(0.000000, 336.000000, 224.000000)'></polygon>
|
||||
<polygon points='480.000000,32.000000 468.000000,26.400000 468.000000,37.599998' fill='currentColor' transform='rotate(0.000000, 472.000000, 32.000000)'></polygon>
|
||||
<polygon points='480.000000,64.000000 468.000000,58.400002 468.000000,69.599998' fill='currentColor' transform='rotate(0.000000, 472.000000, 64.000000)'></polygon>
|
||||
<polygon points='480.000000,112.000000 468.000000,106.400002 468.000000,117.599998' fill='currentColor' transform='rotate(0.000000, 472.000000, 112.000000)'></polygon>
|
||||
<polygon points='480.000000,160.000000 468.000000,154.399994 468.000000,165.600006' fill='currentColor' transform='rotate(0.000000, 472.000000, 160.000000)'></polygon>
|
||||
<polygon points='672.000000,128.000000 660.000000,122.400002 660.000000,133.600006' fill='currentColor' transform='rotate(0.000000, 664.000000, 128.000000)'></polygon>
|
||||
<polygon points='672.000000,192.000000 660.000000,186.399994 660.000000,197.600006' fill='currentColor' transform='rotate(0.000000, 664.000000, 192.000000)'></polygon>
|
||||
<polygon points='816.000000,32.000000 804.000000,26.400000 804.000000,37.599998' fill='currentColor' transform='rotate(0.000000, 808.000000, 32.000000)'></polygon>
|
||||
<polygon points='816.000000,64.000000 804.000000,58.400002 804.000000,69.599998' fill='currentColor' transform='rotate(0.000000, 808.000000, 64.000000)'></polygon>
|
||||
<polygon points='816.000000,128.000000 804.000000,122.400002 804.000000,133.600006' fill='currentColor' transform='rotate(0.000000, 808.000000, 128.000000)'></polygon>
|
||||
<polygon points='816.000000,160.000000 804.000000,154.399994 804.000000,165.600006' fill='currentColor' transform='rotate(0.000000, 808.000000, 160.000000)'></polygon>
|
||||
<polygon points='816.000000,224.000000 804.000000,218.399994 804.000000,229.600006' fill='currentColor' transform='rotate(0.000000, 808.000000, 224.000000)'></polygon>
|
||||
<polygon points='816.000000,304.000000 804.000000,298.399994 804.000000,309.600006' fill='currentColor' transform='rotate(0.000000, 808.000000, 304.000000)'></polygon>
|
||||
<polygon points='816.000000,336.000000 804.000000,330.399994 804.000000,341.600006' fill='currentColor' transform='rotate(0.000000, 808.000000, 336.000000)'></polygon>
|
||||
<polygon points='816.000000,368.000000 804.000000,362.399994 804.000000,373.600006' fill='currentColor' transform='rotate(0.000000, 808.000000, 368.000000)'></polygon>
|
||||
<polygon points='816.000000,400.000000 804.000000,394.399994 804.000000,405.600006' fill='currentColor' transform='rotate(0.000000, 808.000000, 400.000000)'></polygon>
|
||||
<path d='M 496,16 A 16,16 0 0,0 480,32' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 608,16 A 16,16 0 0,1 624,32' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,48 A 16,16 0 0,0 160,64' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 304,48 A 16,16 0 0,1 320,64' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 160,64 A 16,16 0 0,0 176,80' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 320,64 A 16,16 0 0,1 304,80' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,96 A 16,16 0 0,0 160,112' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 320,96 A 16,16 0 0,1 336,112' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 688,96 A 16,16 0 0,0 672,112' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 752,96 A 16,16 0 0,1 768,112' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 160,128 A 16,16 0 0,0 176,144' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 336,128 A 16,16 0 0,1 320,144' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 360,144 A 16,16 0 0,0 344,160' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 416,144 A 16,16 0 0,1 432,160' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 480,160 A 16,16 0 0,0 496,176' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 624,160 A 16,16 0 0,1 608,176' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,208 A 16,16 0 0,0 160,224' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 280,208 A 16,16 0 0,1 296,224' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 672,192 A 16,16 0 0,0 688,208' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 768,192 A 16,16 0 0,1 752,208' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 160,224 A 16,16 0 0,0 176,240' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 296,224 A 16,16 0 0,1 280,240' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 344,224 A 16,16 0 0,0 360,240' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 432,224 A 16,16 0 0,1 416,240' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,320 A 16,16 0 0,0 160,336' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 352,320 A 16,16 0 0,1 368,336' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 160,336 A 16,16 0 0,0 176,352' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 368,336 A 16,16 0 0,1 352,352' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 176,384 A 16,16 0 0,0 160,400' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 264,384 A 16,16 0 0,1 280,400' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 160,400 A 16,16 0 0,0 176,416' fill='none' stroke='currentColor'></path>
|
||||
<path d='M 280,400 A 16,16 0 0,1 264,416' fill='none' stroke='currentColor'></path>
|
||||
<style>
|
||||
text {
|
||||
text-anchor: middle;
|
||||
font-family: "Menlo","Lucida Console","monospace";
|
||||
fill: currentColor;
|
||||
font-size: 1em;
|
||||
}
|
||||
</style>
|
||||
<text x='16' y='4'>N</text>
|
||||
<text x='24' y='4'>o</text>
|
||||
<text x='32' y='4'>r</text>
|
||||
<text x='40' y='4'>m</text>
|
||||
<text x='48' y='4'>a</text>
|
||||
<text x='56' y='4'>l</text>
|
||||
<text x='72' y='4'>f</text>
|
||||
<text x='80' y='4'>l</text>
|
||||
<text x='88' y='4'>o</text>
|
||||
<text x='96' y='4'>w</text>
|
||||
<text x='104' y='4'>:</text>
|
||||
<text x='32' y='36'>P</text>
|
||||
<text x='40' y='36'>D</text>
|
||||
<text x='48' y='36'>F</text>
|
||||
<text x='824' y='36'>P</text>
|
||||
<text x='832' y='36'>D</text>
|
||||
<text x='840' y='36'>F</text>
|
||||
<text x='856' y='36'>1</text>
|
||||
<text x='864' y='36'>.</text>
|
||||
<text x='872' y='36'>5</text>
|
||||
<text x='32' y='68'>P</text>
|
||||
<text x='40' y='68'>l</text>
|
||||
<text x='48' y='68'>a</text>
|
||||
<text x='56' y='68'>i</text>
|
||||
<text x='64' y='68'>n</text>
|
||||
<text x='72' y='68'>t</text>
|
||||
<text x='80' y='68'>e</text>
|
||||
<text x='88' y='68'>x</text>
|
||||
<text x='96' y='68'>t</text>
|
||||
<text x='192' y='68'>Q</text>
|
||||
<text x='200' y='68'>T</text>
|
||||
<text x='208' y='68'>e</text>
|
||||
<text x='216' y='68'>x</text>
|
||||
<text x='224' y='68'>t</text>
|
||||
<text x='232' y='68'>D</text>
|
||||
<text x='240' y='68'>o</text>
|
||||
<text x='248' y='68'>c</text>
|
||||
<text x='256' y='68'>u</text>
|
||||
<text x='264' y='68'>m</text>
|
||||
<text x='272' y='68'>e</text>
|
||||
<text x='280' y='68'>n</text>
|
||||
<text x='288' y='68'>t</text>
|
||||
<text x='504' y='68'>p</text>
|
||||
<text x='512' y='68'>d</text>
|
||||
<text x='520' y='68'>f</text>
|
||||
<text x='528' y='68'>2</text>
|
||||
<text x='536' y='68'>p</text>
|
||||
<text x='544' y='68'>r</text>
|
||||
<text x='552' y='68'>i</text>
|
||||
<text x='560' y='68'>n</text>
|
||||
<text x='568' y='68'>t</text>
|
||||
<text x='576' y='68'>a</text>
|
||||
<text x='584' y='68'>b</text>
|
||||
<text x='592' y='68'>l</text>
|
||||
<text x='600' y='68'>e</text>
|
||||
<text x='824' y='68'>P</text>
|
||||
<text x='832' y='68'>o</text>
|
||||
<text x='840' y='68'>s</text>
|
||||
<text x='848' y='68'>t</text>
|
||||
<text x='856' y='68'>s</text>
|
||||
<text x='864' y='68'>c</text>
|
||||
<text x='872' y='68'>r</text>
|
||||
<text x='880' y='68'>i</text>
|
||||
<text x='888' y='68'>p</text>
|
||||
<text x='896' y='68'>t</text>
|
||||
<text x='912' y='68'>2</text>
|
||||
<text x='32' y='100'>D</text>
|
||||
<text x='40' y='100'>O</text>
|
||||
<text x='48' y='100'>C</text>
|
||||
<text x='56' y='100'>/</text>
|
||||
<text x='64' y='100'>P</text>
|
||||
<text x='72' y='100'>P</text>
|
||||
<text x='80' y='100'>T</text>
|
||||
<text x='496' y='100'>(</text>
|
||||
<text x='504' y='100'>P</text>
|
||||
<text x='512' y='100'>o</text>
|
||||
<text x='520' y='100'>p</text>
|
||||
<text x='528' y='100'>p</text>
|
||||
<text x='536' y='100'>l</text>
|
||||
<text x='544' y='100'>e</text>
|
||||
<text x='552' y='100'>r</text>
|
||||
<text x='560' y='100'>+</text>
|
||||
<text x='568' y='100'>C</text>
|
||||
<text x='576' y='100'>a</text>
|
||||
<text x='584' y='100'>i</text>
|
||||
<text x='592' y='100'>r</text>
|
||||
<text x='600' y='100'>o</text>
|
||||
<text x='608' y='100'>)</text>
|
||||
<text x='32' y='116'>O</text>
|
||||
<text x='40' y='116'>D</text>
|
||||
<text x='48' y='116'>T</text>
|
||||
<text x='56' y='116'>/</text>
|
||||
<text x='64' y='116'>O</text>
|
||||
<text x='72' y='116'>D</text>
|
||||
<text x='80' y='116'>P</text>
|
||||
<text x='184' y='116'>C</text>
|
||||
<text x='192' y='116'>a</text>
|
||||
<text x='200' y='116'>l</text>
|
||||
<text x='208' y='116'>l</text>
|
||||
<text x='216' y='116'>i</text>
|
||||
<text x='224' y='116'>g</text>
|
||||
<text x='232' y='116'>r</text>
|
||||
<text x='240' y='116'>a</text>
|
||||
<text x='248' y='116'>c</text>
|
||||
<text x='256' y='116'>o</text>
|
||||
<text x='264' y='116'>n</text>
|
||||
<text x='272' y='116'>v</text>
|
||||
<text x='280' y='116'>e</text>
|
||||
<text x='288' y='116'>r</text>
|
||||
<text x='296' y='116'>t</text>
|
||||
<text x='304' y='116'>e</text>
|
||||
<text x='312' y='116'>r</text>
|
||||
<text x='208' y='132'>(</text>
|
||||
<text x='216' y='132'>o</text>
|
||||
<text x='224' y='132'>p</text>
|
||||
<text x='232' y='132'>t</text>
|
||||
<text x='240' y='132'>i</text>
|
||||
<text x='248' y='132'>o</text>
|
||||
<text x='256' y='132'>n</text>
|
||||
<text x='264' y='132'>a</text>
|
||||
<text x='272' y='132'>l</text>
|
||||
<text x='280' y='132'>)</text>
|
||||
<text x='824' y='132'>P</text>
|
||||
<text x='832' y='132'>W</text>
|
||||
<text x='840' y='132'>G</text>
|
||||
<text x='848' y='132'>-</text>
|
||||
<text x='856' y='132'>R</text>
|
||||
<text x='864' y='132'>a</text>
|
||||
<text x='872' y='132'>s</text>
|
||||
<text x='880' y='132'>t</text>
|
||||
<text x='888' y='132'>e</text>
|
||||
<text x='896' y='132'>r</text>
|
||||
<text x='696' y='148'>p</text>
|
||||
<text x='704' y='148'>p</text>
|
||||
<text x='712' y='148'>m</text>
|
||||
<text x='720' y='148'>2</text>
|
||||
<text x='728' y='148'>p</text>
|
||||
<text x='736' y='148'>w</text>
|
||||
<text x='744' y='148'>g</text>
|
||||
<text x='32' y='164'>I</text>
|
||||
<text x='40' y='164'>m</text>
|
||||
<text x='48' y='164'>a</text>
|
||||
<text x='56' y='164'>g</text>
|
||||
<text x='64' y='164'>e</text>
|
||||
<text x='72' y='164'>s</text>
|
||||
<text x='824' y='164'>U</text>
|
||||
<text x='832' y='164'>R</text>
|
||||
<text x='840' y='164'>F</text>
|
||||
<text x='848' y='164'>-</text>
|
||||
<text x='856' y='164'>R</text>
|
||||
<text x='864' y='164'>a</text>
|
||||
<text x='872' y='164'>s</text>
|
||||
<text x='880' y='164'>t</text>
|
||||
<text x='888' y='164'>e</text>
|
||||
<text x='896' y='164'>r</text>
|
||||
<text x='368' y='196'>Q</text>
|
||||
<text x='376' y='196'>I</text>
|
||||
<text x='384' y='196'>m</text>
|
||||
<text x='392' y='196'>a</text>
|
||||
<text x='400' y='196'>g</text>
|
||||
<text x='408' y='196'>e</text>
|
||||
<text x='32' y='228'>S</text>
|
||||
<text x='40' y='228'>V</text>
|
||||
<text x='48' y='228'>G</text>
|
||||
<text x='184' y='228'>Q</text>
|
||||
<text x='192' y='228'>S</text>
|
||||
<text x='200' y='228'>v</text>
|
||||
<text x='208' y='228'>g</text>
|
||||
<text x='216' y='228'>R</text>
|
||||
<text x='224' y='228'>e</text>
|
||||
<text x='232' y='228'>n</text>
|
||||
<text x='240' y='228'>d</text>
|
||||
<text x='248' y='228'>e</text>
|
||||
<text x='256' y='228'>r</text>
|
||||
<text x='264' y='228'>e</text>
|
||||
<text x='272' y='228'>r</text>
|
||||
<text x='824' y='228'>P</text>
|
||||
<text x='832' y='228'>N</text>
|
||||
<text x='840' y='228'>G</text>
|
||||
<text x='848' y='228'>,</text>
|
||||
<text x='864' y='228'>J</text>
|
||||
<text x='872' y='228'>P</text>
|
||||
<text x='880' y='228'>E</text>
|
||||
<text x='888' y='228'>G</text>
|
||||
<text x='896' y='228'>,</text>
|
||||
<text x='824' y='244'>R</text>
|
||||
<text x='832' y='244'>e</text>
|
||||
<text x='840' y='244'>v</text>
|
||||
<text x='848' y='244'>e</text>
|
||||
<text x='856' y='244'>r</text>
|
||||
<text x='864' y='244'>s</text>
|
||||
<text x='872' y='244'>e</text>
|
||||
<text x='888' y='244'>B</text>
|
||||
<text x='896' y='244'>M</text>
|
||||
<text x='904' y='244'>P</text>
|
||||
<text x='16' y='276'>I</text>
|
||||
<text x='24' y='276'>f</text>
|
||||
<text x='40' y='276'>t</text>
|
||||
<text x='48' y='276'>a</text>
|
||||
<text x='56' y='276'>r</text>
|
||||
<text x='64' y='276'>g</text>
|
||||
<text x='72' y='276'>e</text>
|
||||
<text x='80' y='276'>t</text>
|
||||
<text x='96' y='276'>f</text>
|
||||
<text x='104' y='276'>o</text>
|
||||
<text x='112' y='276'>r</text>
|
||||
<text x='120' y='276'>m</text>
|
||||
<text x='128' y='276'>a</text>
|
||||
<text x='136' y='276'>t</text>
|
||||
<text x='152' y='276'>i</text>
|
||||
<text x='160' y='276'>s</text>
|
||||
<text x='176' y='276'>t</text>
|
||||
<text x='184' y='276'>h</text>
|
||||
<text x='192' y='276'>e</text>
|
||||
<text x='208' y='276'>s</text>
|
||||
<text x='216' y='276'>a</text>
|
||||
<text x='224' y='276'>m</text>
|
||||
<text x='232' y='276'>e</text>
|
||||
<text x='240' y='276'>:</text>
|
||||
<text x='32' y='308'>P</text>
|
||||
<text x='40' y='308'>o</text>
|
||||
<text x='48' y='308'>s</text>
|
||||
<text x='56' y='308'>t</text>
|
||||
<text x='64' y='308'>s</text>
|
||||
<text x='72' y='308'>c</text>
|
||||
<text x='80' y='308'>r</text>
|
||||
<text x='88' y='308'>i</text>
|
||||
<text x='96' y='308'>p</text>
|
||||
<text x='104' y='308'>t</text>
|
||||
<text x='824' y='308'>P</text>
|
||||
<text x='832' y='308'>o</text>
|
||||
<text x='840' y='308'>s</text>
|
||||
<text x='848' y='308'>t</text>
|
||||
<text x='856' y='308'>s</text>
|
||||
<text x='864' y='308'>c</text>
|
||||
<text x='872' y='308'>r</text>
|
||||
<text x='880' y='308'>i</text>
|
||||
<text x='888' y='308'>p</text>
|
||||
<text x='896' y='308'>t</text>
|
||||
<text x='32' y='340'>P</text>
|
||||
<text x='40' y='340'>l</text>
|
||||
<text x='48' y='340'>a</text>
|
||||
<text x='56' y='340'>i</text>
|
||||
<text x='64' y='340'>n</text>
|
||||
<text x='72' y='340'>t</text>
|
||||
<text x='80' y='340'>e</text>
|
||||
<text x='88' y='340'>x</text>
|
||||
<text x='96' y='340'>t</text>
|
||||
<text x='184' y='340'>e</text>
|
||||
<text x='192' y='340'>n</text>
|
||||
<text x='200' y='340'>s</text>
|
||||
<text x='208' y='340'>u</text>
|
||||
<text x='216' y='340'>r</text>
|
||||
<text x='224' y='340'>e</text>
|
||||
<text x='240' y='340'>C</text>
|
||||
<text x='248' y='340'>R</text>
|
||||
<text x='256' y='340'>+</text>
|
||||
<text x='264' y='340'>L</text>
|
||||
<text x='272' y='340'>F</text>
|
||||
<text x='288' y='340'>n</text>
|
||||
<text x='296' y='340'>e</text>
|
||||
<text x='304' y='340'>w</text>
|
||||
<text x='312' y='340'>l</text>
|
||||
<text x='320' y='340'>i</text>
|
||||
<text x='328' y='340'>n</text>
|
||||
<text x='336' y='340'>e</text>
|
||||
<text x='344' y='340'>s</text>
|
||||
<text x='824' y='340'>P</text>
|
||||
<text x='832' y='340'>l</text>
|
||||
<text x='840' y='340'>a</text>
|
||||
<text x='848' y='340'>i</text>
|
||||
<text x='856' y='340'>n</text>
|
||||
<text x='864' y='340'>t</text>
|
||||
<text x='872' y='340'>e</text>
|
||||
<text x='880' y='340'>x</text>
|
||||
<text x='888' y='340'>t</text>
|
||||
<text x='32' y='372'>P</text>
|
||||
<text x='40' y='372'>N</text>
|
||||
<text x='48' y='372'>G</text>
|
||||
<text x='824' y='372'>P</text>
|
||||
<text x='832' y='372'>N</text>
|
||||
<text x='840' y='372'>G</text>
|
||||
<text x='32' y='404'>J</text>
|
||||
<text x='40' y='404'>P</text>
|
||||
<text x='48' y='404'>E</text>
|
||||
<text x='56' y='404'>G</text>
|
||||
<text x='184' y='404'>b</text>
|
||||
<text x='192' y='404'>a</text>
|
||||
<text x='200' y='404'>s</text>
|
||||
<text x='208' y='404'>e</text>
|
||||
<text x='216' y='404'>l</text>
|
||||
<text x='224' y='404'>i</text>
|
||||
<text x='232' y='404'>n</text>
|
||||
<text x='240' y='404'>i</text>
|
||||
<text x='248' y='404'>f</text>
|
||||
<text x='256' y='404'>y</text>
|
||||
<text x='824' y='404'>J</text>
|
||||
<text x='832' y='404'>P</text>
|
||||
<text x='840' y='404'>E</text>
|
||||
<text x='848' y='404'>G</text>
|
||||
<text x='824' y='420'>(</text>
|
||||
<text x='832' y='420'>B</text>
|
||||
<text x='840' y='420'>a</text>
|
||||
<text x='848' y='420'>s</text>
|
||||
<text x='856' y='420'>e</text>
|
||||
<text x='864' y='420'>l</text>
|
||||
<text x='872' y='420'>i</text>
|
||||
<text x='880' y='420'>n</text>
|
||||
<text x='888' y='420'>e</text>
|
||||
<text x='904' y='420'>p</text>
|
||||
<text x='912' y='420'>r</text>
|
||||
<text x='920' y='420'>o</text>
|
||||
<text x='928' y='420'>f</text>
|
||||
<text x='936' y='420'>i</text>
|
||||
<text x='944' y='420'>l</text>
|
||||
<text x='952' y='420'>e</text>
|
||||
<text x='960' y='420'>)</text>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 20 KiB |
|
@ -1,11 +1,12 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
X-Nemo-Application-Type=silica-qt5
|
||||
Icon=harbour-seaprint
|
||||
X-Nemo-Application-Type=silica-qt5
|
||||
Exec=harbour-seaprint
|
||||
X-DBusActivatable=true
|
||||
Name=SeaPrint
|
||||
# translation example:
|
||||
# your app name in German locale (de)
|
||||
#
|
||||
# Remember to comment out the following line, if you do not want to use
|
||||
# a different app name in German locale (de).
|
||||
[X-Sailjail]
|
||||
Permissions=Internet;Pictures;Documents;Downloads;RemovableMedia;MediaIndexing;Compatibility
|
||||
OrganizationName=net.attah
|
||||
ApplicationName=seaprint
|
||||
ExecDBus=harbour-seaprint --prestart
|
||||
|
|
|
@ -12,40 +12,59 @@
|
|||
# The name of your application
|
||||
TARGET = harbour-seaprint
|
||||
|
||||
CONFIG += sailfishapp
|
||||
i18n.path = /usr/share/harbour-seaprint/translations
|
||||
i18n.files = translations/harbour-seaprint-de.qm \
|
||||
translations/harbour-seaprint-zh_CN.qm \
|
||||
translations/harbour-seaprint-fr.qm \
|
||||
translations/harbour-seaprint-es.qm \
|
||||
translations/harbour-seaprint-nl.qm \
|
||||
translations/harbour-seaprint-pl.qm
|
||||
|
||||
# Write version file
|
||||
VERSION_H = \
|
||||
"$${LITERAL_HASH}ifndef SEAPRINT_VERSION" \
|
||||
"$${LITERAL_HASH} define SEAPRINT_VERSION \"$$VERSION\"" \
|
||||
"$${LITERAL_HASH}endif"
|
||||
write_file($$$$OUT_PWD/seaprint_version.h, VERSION_H)
|
||||
INSTALLS += i18n
|
||||
|
||||
# automatic generation of the translation .qm files from .ts files
|
||||
system(lrelease $$PWD/translations/*.ts)
|
||||
|
||||
CONFIG += sailfishapp
|
||||
QT += svg dbus
|
||||
PKGCONFIG += mlite5 libcurl glib-2.0
|
||||
INCLUDEPATH += $$system(pkg-config --cflags-only-I poppler-glib | sed 's/-I//g')
|
||||
LIBS += -lcurl -lglib-2.0 -lgobject-2.0 -ldl
|
||||
DEFINES += MADNESS=1
|
||||
DEFINES += PDF_CREATOR='\\"SeaPrint\ $$VERSION\\"'
|
||||
DEFINES += SEAPRINT_VERSION='\\"$$VERSION\\"'
|
||||
|
||||
SOURCES += src/harbour-seaprint.cpp \
|
||||
src/dbusadaptorbase.cpp \
|
||||
src/freedesktopdbusadaptor.cpp \
|
||||
src/rangelistchecker.cpp \
|
||||
src/convertchecker.cpp \
|
||||
src/convertworker.cpp \
|
||||
src/curlrequester.cpp \
|
||||
src/imageitem.cpp \
|
||||
src/ippdiscovery.cpp \
|
||||
src/ippmsg.cpp \
|
||||
src/ippprinter.cpp \
|
||||
src/mimer.cpp \
|
||||
ppm2pwg/printparameters.cpp \
|
||||
ppm2pwg/ppm2pwg.cpp \
|
||||
ppm2pwg/bytestream/bytestream.cpp
|
||||
ppm2pwg/pdf2printable.cpp \
|
||||
ppm2pwg/baselinify.cpp \
|
||||
ppm2pwg/bytestream/bytestream.cpp \
|
||||
src/overrider.cpp \
|
||||
src/printerworker.cpp \
|
||||
src/seaprintdbusadaptor.cpp \
|
||||
src/settings.cpp
|
||||
|
||||
DISTFILES += qml/harbour-seaprint.qml \
|
||||
qml/components/LargeChoiceDialog.qml \
|
||||
qml/cover/CoverPage.qml \
|
||||
qml/components/*.qml \
|
||||
qml/components/*qml \
|
||||
qml/pages/*.qml \
|
||||
qml/pages/*.js \
|
||||
qml/pages/*svg \
|
||||
qml/pages/BusyPage.qml \
|
||||
qml/pages/DebugPage.qml \
|
||||
qml/pages/NagScreen.qml \
|
||||
qml/pages/SettingsPage.qml \
|
||||
qml/pages/*png \
|
||||
rpm/harbour-seaprint.changes.in \
|
||||
rpm/harbour-seaprint.changes.run.in \
|
||||
rpm/harbour-seaprint.spec \
|
||||
rpm/harbour-seaprint.yaml \
|
||||
translations/*.ts \
|
||||
harbour-seaprint.desktop
|
||||
|
||||
|
@ -62,20 +81,38 @@ CONFIG += sailfishapp_i18n
|
|||
TRANSLATIONS += translations/harbour-seaprint-de.ts \
|
||||
translations/harbour-seaprint-zh_CN.ts \
|
||||
translations/harbour-seaprint-fr.ts \
|
||||
translations/harbour-seaprint-es.ts
|
||||
translations/harbour-seaprint-es.ts \
|
||||
translations/harbour-seaprint-nl.ts \
|
||||
translations/harbour-seaprint-pl.ts
|
||||
|
||||
HEADERS += \
|
||||
src/dbusadaptorbase.h \
|
||||
src/freedesktopdbusadaptor.h \
|
||||
src/rangelistchecker.h \
|
||||
src/convertchecker.h \
|
||||
src/convertworker.h \
|
||||
src/curlrequester.h \
|
||||
src/imageitem.h \
|
||||
src/ippdiscovery.h \
|
||||
src/ippmsg.h \
|
||||
src/ippprinter.h \
|
||||
src/mimer.h \
|
||||
ppm2pwg/pwg_pghdr_codable.h \
|
||||
ppm2pwg/urf_pghdr_codable.h \
|
||||
ppm2pwg/ppm2pwg.h \
|
||||
ppm2pwg/pdf2printable.h \
|
||||
ppm2pwg/baselinify.h \
|
||||
ppm2pwg/madness.h \
|
||||
ppm2pwg/printparameters.h \
|
||||
ppm2pwg/PwgPgHdr.h \
|
||||
ppm2pwg/PwgPgHdr.codable \
|
||||
ppm2pwg/UrfPgHdr.h \
|
||||
ppm2pwg/UrfPgHdr.codable \
|
||||
ppm2pwg/bytestream/bytestream.h \
|
||||
ppm2pwg/bytestream/codable.h \
|
||||
src/papersizes.h
|
||||
ppm2pwg/argget.h \
|
||||
src/overrider.h \
|
||||
src/papersizes.h \
|
||||
src/printerworker.h \
|
||||
src/seaprintdbusadaptor.h \
|
||||
src/settings.h
|
||||
|
||||
INCLUDEPATH += ppm2pwg \
|
||||
ppm2pwg/bytestream
|
||||
|
|
2
ppm2pwg
2
ppm2pwg
|
@ -1 +1 @@
|
|||
Subproject commit f411bb1421bec6f6f1af80053749ea28a9a9a6ae
|
||||
Subproject commit acc32f3769c3b18bd6b94c55b882c7b7b778854c
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Label {
|
||||
|
|
48
qml/components/BarButton.qml
Normal file
48
qml/components/BarButton.qml
Normal file
|
@ -0,0 +1,48 @@
|
|||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
BackgroundItem {
|
||||
id: barButton
|
||||
|
||||
property alias text: label.text
|
||||
property bool active: false
|
||||
highlightedColor: Theme.rgba(Theme.highlightBackgroundFromColor(Theme.highlightBackgroundColor, Theme.colorScheme), Theme.highlightBackgroundOpacity)
|
||||
|
||||
onClicked:
|
||||
{
|
||||
active = !active
|
||||
}
|
||||
|
||||
function _color(alpha) {
|
||||
alpha = alpha*0.25
|
||||
return Theme.rgba(Theme.highlightBackgroundColor, alpha)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
x: -1
|
||||
anchors.fill: parent
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.0; color: _color(1) }
|
||||
GradientStop { position: 0.2; color: _color(0.6) }
|
||||
GradientStop { position: 0.8; color: _color(0.4) }
|
||||
GradientStop { position: 1.0; color: "transparent" }
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
id: label
|
||||
leftPadding: Theme.paddingLarge*2
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: barButton.highlighted ? Theme.highlightColor : Theme.primaryColor
|
||||
}
|
||||
|
||||
Image {
|
||||
id: image
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.paddingMedium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
source: active ? "image://theme/icon-m-down" : "image://theme/icon-m-right"
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +1,49 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import seaprint.convertchecker 1.0
|
||||
import "../pages/utils.js" as Utils
|
||||
|
||||
Setting {
|
||||
property var choices
|
||||
property string mime_type
|
||||
property var choices: parent.getChoices(name)
|
||||
property var preferred_choices: []
|
||||
property string preferred_choice_suffix: ""
|
||||
|
||||
property var limited_choices: Utils.limitChoices(name, choices, mime_type, ConvertChecker)
|
||||
property var actual_choices: Utils.fixupChoices(name, choices, parent.selectedFileType, parent.printer)
|
||||
|
||||
property int num_large_choices: 8
|
||||
|
||||
ValueButton {
|
||||
enabled: valid
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
label: prettyName
|
||||
value: Utils.ippName(name, choice ? choice : default_choice)
|
||||
onClicked: parent.clicked()
|
||||
}
|
||||
displayValue: Utils.ippName(name, choice != undefined ? choice : default_choice, strings)
|
||||
|
||||
onClicked: {
|
||||
if(limited_choices.length>num_large_choices)
|
||||
if(hasMenu)
|
||||
{
|
||||
menu.open(this)
|
||||
}
|
||||
else if(actual_choices.length != 0)
|
||||
{
|
||||
var dialog = pageStack.push("LargeChoiceDialog.qml",
|
||||
{name:name, choice: choice ? choice : default_choice, choices: limited_choices})
|
||||
{name:name, choice: choice != undefined ? choice : default_choice, choices: actual_choices,
|
||||
preferred_choices: preferred_choices, preferred_choice_suffix: preferred_choice_suffix,
|
||||
strings: strings})
|
||||
dialog.accepted.connect(function() {
|
||||
choice = dialog.choice
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
property var menu: ContextMenu {
|
||||
id: menu
|
||||
enabled: valid && limited_choices.length <= num_large_choices
|
||||
menu: ContextMenu {
|
||||
Repeater {
|
||||
model: limited_choices
|
||||
model: actual_choices.length>num_large_choices ? 0 : actual_choices
|
||||
MenuItem {
|
||||
text: Utils.ippName(name, limited_choices[index])
|
||||
text: Utils.ippName(name, actual_choices[index], strings)
|
||||
+ (Utils.has(preferred_choices, actual_choices[index]) ? " "+preferred_choice_suffix : "")
|
||||
onClicked:
|
||||
{
|
||||
choice = limited_choices[index];
|
||||
choice = actual_choices[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
hasMenu: actual_choices.length != 0 && (actual_choices.length <= num_large_choices)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
MouseArea {
|
||||
|
|
86
qml/components/CylinderGraph.qml
Normal file
86
qml/components/CylinderGraph.qml
Normal file
|
@ -0,0 +1,86 @@
|
|||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Item {
|
||||
id: cylinderGraph
|
||||
property string color
|
||||
property real value
|
||||
width: Theme.itemSizeSmall/2
|
||||
height: Theme.itemSizeSmall
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Rectangle {
|
||||
id: effect
|
||||
z: 1
|
||||
anchors.centerIn: parent
|
||||
|
||||
width: Theme.itemSizeExtraSmall
|
||||
height: Theme.itemSizeExtraSmall/3
|
||||
rotation: 270
|
||||
transformOrigin: Item.Center
|
||||
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.0; color: "#40888888"}
|
||||
GradientStop { position: 0.1; color: "#20FFFFFF"}
|
||||
GradientStop { position: 0.2; color: "#00000000"}
|
||||
GradientStop { position: 0.6; color: "#00000000"}
|
||||
GradientStop { position: 0.8; color: "#20FFFFFF"}
|
||||
GradientStop { position: 1.0; color: "#40888888"}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
id: fill
|
||||
width: Theme.itemSizeExtraSmall*parent.value
|
||||
height: (Theme.itemSizeExtraSmall/3)
|
||||
rotation: 270
|
||||
transformOrigin: Item.Center
|
||||
|
||||
gradient: Gradient {
|
||||
id: gradient
|
||||
}
|
||||
|
||||
Component
|
||||
{
|
||||
id: stopComponent
|
||||
GradientStop {}
|
||||
}
|
||||
|
||||
function splitColors(color) {
|
||||
if(color.indexOf("#") != 0)
|
||||
{
|
||||
return ["black"];
|
||||
}
|
||||
var colors = [];
|
||||
var parts = color.split("#");
|
||||
for(var i = 1; i < parts.length; i++)
|
||||
{
|
||||
colors.push("#"+parts[i])
|
||||
}
|
||||
return colors;
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
var colors = splitColors(cylinderGraph.color);
|
||||
var stops = [];
|
||||
|
||||
stops.push(stopComponent.createObject(fill, {"position": 0.0, "color": "#00000000"}));
|
||||
stops.push(stopComponent.createObject(fill, {"position": 0.1, "color": colors[0]}));
|
||||
|
||||
for(var i = 0; i < colors.length; i++)
|
||||
{
|
||||
var pos = 0.1+(i+0.5)*(0.8/colors.length);
|
||||
stops.push(stopComponent.createObject(fill, {"position": pos, "color": colors[i]}));
|
||||
}
|
||||
|
||||
stops.push(stopComponent.createObject(fill, {"position": 0.9, "color": colors[colors.length-1]}));
|
||||
stops.push(stopComponent.createObject(fill, {"position": 1.0, "color": "#00000000"}));
|
||||
|
||||
gradient.stops = stops;
|
||||
|
||||
}
|
||||
|
||||
anchors.horizontalCenter: effect.horizontalCenter
|
||||
anchors.bottom: effect.bottom
|
||||
anchors.bottomMargin: -1*(effect.width-width)/2
|
||||
}
|
||||
}
|
42
qml/components/DependentOn.qml
Normal file
42
qml/components/DependentOn.qml
Normal file
|
@ -0,0 +1,42 @@
|
|||
import QtQuick 2.6
|
||||
|
||||
Item {
|
||||
property alias target: targetConnection.target
|
||||
property var values
|
||||
property var overlap: []
|
||||
|
||||
Component.onCompleted:
|
||||
{
|
||||
for(var i in values)
|
||||
{
|
||||
if(target.actual_choices.indexOf(values[i]) != -1)
|
||||
{
|
||||
overlap.push(values[i])
|
||||
}
|
||||
}
|
||||
parent.valid = parent.valid && overlap.length != 0
|
||||
}
|
||||
|
||||
Connections {
|
||||
id: targetConnection
|
||||
onChoiceChanged:
|
||||
{
|
||||
if(parent.choice != undefined && overlap.indexOf(target.choice) == -1)
|
||||
{
|
||||
parent.reset()
|
||||
parent.highlight()
|
||||
}
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: parent
|
||||
onChoiceChanged:
|
||||
{
|
||||
if(parent.choice != undefined && overlap.indexOf(targetConnection.target.choice) == -1)
|
||||
{
|
||||
targetConnection.target.choice = overlap[0]
|
||||
targetConnection.target.highlight()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
35
qml/components/DocumentFilter.notqml
Normal file
35
qml/components/DocumentFilter.notqml
Normal file
|
@ -0,0 +1,35 @@
|
|||
import QtDocGallery 5.0
|
||||
|
||||
GalleryFilterUnion {
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".pdf"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".ps"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".txt"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".PDF"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".PS"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".TXT"
|
||||
}
|
||||
|
||||
}
|
104
qml/components/DocumentFilterOffice.notqml
Normal file
104
qml/components/DocumentFilterOffice.notqml
Normal file
|
@ -0,0 +1,104 @@
|
|||
import QtDocGallery 5.0
|
||||
|
||||
GalleryFilterUnion {
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".pdf"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".ps"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".txt"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".PDF"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".PS"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".TXT"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".odt"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".doc"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".docx"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".rtf"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".ODT"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".DOC"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".DOCX"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".RTF"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".ppt"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".pptx"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".odp"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".PPT"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".PPTX"
|
||||
}
|
||||
|
||||
GalleryEndsWithFilter {
|
||||
property: "fileName"
|
||||
value: ".ODP"
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Dialog {
|
||||
|
@ -11,12 +11,6 @@ Dialog {
|
|||
property string title
|
||||
canAccept: valueField.acceptableInput
|
||||
|
||||
Component.onCompleted:
|
||||
{
|
||||
|
||||
console.log("adasdsa", title)
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
|
||||
|
@ -26,10 +20,9 @@ Dialog {
|
|||
id: valueField
|
||||
validator: IntValidator{bottom: min; top: max;}
|
||||
width: parent.width
|
||||
placeholderText: ""+min+"-"+max
|
||||
placeholderText: ""+min+"-"+(max == 65535 ? "..." : max)
|
||||
label: title
|
||||
focus: true
|
||||
labelVisible: true
|
||||
inputMethodHints: Qt.ImhDigitsOnly
|
||||
|
||||
}
|
||||
|
|
|
@ -1,33 +1,51 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Setting {
|
||||
property int minimum_high: 0
|
||||
property int low: _valid ? parent.printer.attrs[name+"-supported"].value.low : (minimum_high != 0) ? 1 : 0
|
||||
property int high: _valid ? ensure_minimum(parent.printer.attrs[name+"-supported"].value.high) : minimum_high
|
||||
|
||||
property int low
|
||||
property int high
|
||||
|
||||
ValueButton {
|
||||
enabled: valid
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
label: prettyName
|
||||
value: choice ? choice : default_choice
|
||||
onClicked: parent.clicked()
|
||||
function ensure_minimum(orig)
|
||||
{
|
||||
if(orig < minimum_high)
|
||||
{
|
||||
return minimum_high;
|
||||
}
|
||||
else
|
||||
{
|
||||
return orig;
|
||||
}
|
||||
}
|
||||
|
||||
property var menu: ContextMenu {
|
||||
id: menu
|
||||
enabled: valid
|
||||
property bool suppressChange: false
|
||||
|
||||
displayValue: choice != undefined ? choice : default_choice
|
||||
|
||||
onChoiceChanged: {
|
||||
if(choice == undefined)
|
||||
{
|
||||
suppressChange = true;
|
||||
slider.value = slider.minimumValue;
|
||||
suppressChange = false;
|
||||
}
|
||||
}
|
||||
|
||||
menu: ContextMenu {
|
||||
MenuItem {
|
||||
Slider
|
||||
{
|
||||
id: slider
|
||||
minimumValue: low
|
||||
maximumValue: high < 100 ? high : 100
|
||||
maximumValue: high < 50 ? high : 50
|
||||
width: parent.width
|
||||
stepSize: 1
|
||||
value: choice ? choice : default_choice
|
||||
onValueChanged:
|
||||
{
|
||||
choice = value;
|
||||
if(!suppressChange)
|
||||
{
|
||||
choice = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
IconButton
|
||||
|
@ -35,7 +53,7 @@ Setting {
|
|||
anchors.right: parent.right
|
||||
icon.source: "image://theme/icon-s-edit"
|
||||
onClicked: {var dialog = pageStack.push(Qt.resolvedUrl("IntegerInputDialog.qml"),
|
||||
{value: choice, title: prettyName,
|
||||
{title: prettyName,
|
||||
min: low, max: high});
|
||||
dialog.accepted.connect(function() {
|
||||
choice = dialog.value;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import "../pages/utils.js" as Utils
|
||||
|
||||
|
@ -10,6 +10,9 @@ Dialog {
|
|||
property string choice
|
||||
property string new_choice: choice
|
||||
property var choices
|
||||
property var preferred_choices
|
||||
property string preferred_choice_suffix
|
||||
property var strings
|
||||
canAccept: false
|
||||
|
||||
SilicaListView
|
||||
|
@ -28,7 +31,8 @@ Dialog {
|
|||
x: Theme.paddingLarge
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
highlighted: choices[index]==new_choice
|
||||
text: Utils.ippName(name, choices[index])
|
||||
text: Utils.ippName(name, choices[index], strings)
|
||||
+ (Utils.has(preferred_choices, choices[index]) ? " "+preferred_choice_suffix : "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import seaprint.convertchecker 1.0
|
||||
import seaprint.ippmsg 1.0
|
||||
import "../pages/utils.js" as Utils
|
||||
|
||||
Setting {
|
||||
property var printer
|
||||
|
||||
Component.onCompleted: {
|
||||
if((printer.attrs["media-left-margin-supported"].value.indexOf(0) != -1) &&
|
||||
(printer.attrs["media-right-margin-supported"].value.indexOf(0) != -1) &&
|
||||
(printer.attrs["media-top-margin-supported"].value.indexOf(0) != -1) &&
|
||||
(printer.attrs["media-bottom-margin-supported"].value.indexOf(0) != -1))
|
||||
{
|
||||
valid = true
|
||||
}
|
||||
}
|
||||
|
||||
ValueButton {
|
||||
enabled: valid
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
label: prettyName
|
||||
value: choice ? qsTr("true") : qsTr("false")
|
||||
onClicked: parent.clicked()
|
||||
}
|
||||
|
||||
property var menu: ContextMenu {
|
||||
id: menu
|
||||
enabled: true
|
||||
MenuItem {
|
||||
text: qsTr("true")
|
||||
onClicked:
|
||||
{
|
||||
choice = {"media-left-margin": {"tag": IppMsg.Integer, "value": 0},
|
||||
"media-right-margin": {"tag": IppMsg.Integer, "value": 0},
|
||||
"media-top-margin": {"tag": IppMsg.Integer, "value": 0},
|
||||
"media-bottom-margin": {"tag": IppMsg.Integer, "value": 0}}
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("false")
|
||||
onClicked:
|
||||
{
|
||||
choice = undefined
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
30
qml/components/RangeListInputDialog.qml
Normal file
30
qml/components/RangeListInputDialog.qml
Normal file
|
@ -0,0 +1,30 @@
|
|||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import seaprint.rangelistchecker 1.0
|
||||
|
||||
Dialog {
|
||||
id: dialog
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
property string title
|
||||
property var value
|
||||
canAccept: valueField.acceptableInput
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
|
||||
DialogHeader { }
|
||||
|
||||
TextField {
|
||||
id: valueField
|
||||
acceptableInput: Object.keys(value).length !== 0
|
||||
width: parent.width
|
||||
placeholderText: "1,2,17-42"
|
||||
label: title
|
||||
focus: true
|
||||
labelVisible: true
|
||||
onTextChanged: { dialog.value = RangeListChecker.parse(text) }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +1,99 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Setting {
|
||||
|
||||
property int high
|
||||
property int choice_low: 1
|
||||
property int choice_high: 0
|
||||
property bool acceptRangeList: false
|
||||
|
||||
property bool suppressChange: false
|
||||
|
||||
function update_choice() {
|
||||
choice = new Object({low: choice_low, high: choice_high});
|
||||
}
|
||||
|
||||
onChoice_highChanged: {
|
||||
if(choice_high < choice_low)
|
||||
if (choice_high == 0)
|
||||
{
|
||||
low_slider.value = choice_high > 0 ? choice_high : 1;
|
||||
choice = undefined;
|
||||
}
|
||||
else
|
||||
{
|
||||
choice = new Object({low: choice_low, high: choice_high});
|
||||
}
|
||||
}
|
||||
|
||||
onChoice_highChanged: {
|
||||
if(!suppressChange)
|
||||
{
|
||||
if(choice_high < choice_low)
|
||||
{
|
||||
low_slider.value = choice_high > 0 ? choice_high : 1;
|
||||
}
|
||||
update_choice()
|
||||
}
|
||||
}
|
||||
onChoice_lowChanged: {
|
||||
if(choice_low > choice_high)
|
||||
{
|
||||
high_slider.value = choice_low
|
||||
}
|
||||
else
|
||||
if(!suppressChange)
|
||||
{
|
||||
if(choice_low > choice_high)
|
||||
{
|
||||
high_slider.value = choice_low
|
||||
}
|
||||
update_choice()
|
||||
}
|
||||
}
|
||||
|
||||
ValueButton {
|
||||
enabled: valid
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
label: prettyName
|
||||
value: choice_high==0 ? qsTr("all") : ""+choice_low+" - "+choice_high
|
||||
onClicked: parent.clicked()
|
||||
onChoiceChanged: {
|
||||
if(choice == undefined || choice.constructor.name !== "Object")
|
||||
{
|
||||
suppressChange = true;
|
||||
low_slider.value = low_slider.minimumValue;
|
||||
high_slider.value = high_slider.minimumValue;
|
||||
suppressChange = false;
|
||||
}
|
||||
}
|
||||
|
||||
property var menu: ContextMenu {
|
||||
id: menu
|
||||
enabled: valid
|
||||
displayValue: prettify(choice)
|
||||
|
||||
function prettify(choice)
|
||||
{
|
||||
if(choice == undefined)
|
||||
{
|
||||
return qsTr("all");
|
||||
}
|
||||
else if(choice.constructor.name === "Object")
|
||||
{
|
||||
return (""+choice.low+" - "+choice.high)
|
||||
}
|
||||
else
|
||||
{
|
||||
var ret = "";
|
||||
for(var i = 0; i < choice.length; i++)
|
||||
{
|
||||
if(i!=0)
|
||||
{
|
||||
ret = ret+","
|
||||
}
|
||||
if(choice[i].low == choice[i].high)
|
||||
{
|
||||
ret=ret+choice[i].low
|
||||
}
|
||||
else
|
||||
{
|
||||
ret=ret+choice[i].low+"-"+choice[i].high
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
menu: ContextMenu {
|
||||
MenuItem {
|
||||
Slider
|
||||
{
|
||||
id: low_slider
|
||||
minimumValue: 1
|
||||
maximumValue: high > 100 ? 100 : high
|
||||
maximumValue: high > 50 ? 50 : high
|
||||
width: parent.width
|
||||
stepSize: 1
|
||||
value: choice_low
|
||||
onValueChanged:
|
||||
{
|
||||
choice_low = value;
|
||||
|
@ -64,7 +104,7 @@ Setting {
|
|||
anchors.right: parent.right
|
||||
icon.source: "image://theme/icon-s-edit"
|
||||
onClicked: {var dialog = pageStack.push(Qt.resolvedUrl("IntegerInputDialog.qml"),
|
||||
{value: choice, title: prettyName,
|
||||
{title: prettyName + " (" + qsTr("Low") + ")",
|
||||
min: 1, max: high});
|
||||
dialog.accepted.connect(function() {
|
||||
choice_low = dialog.value;
|
||||
|
@ -79,10 +119,9 @@ Setting {
|
|||
{
|
||||
id: high_slider
|
||||
minimumValue: 0
|
||||
maximumValue: high > 100 ? 100 : high
|
||||
maximumValue: high > 50 ? 50 : high
|
||||
width: parent.width
|
||||
stepSize: 1
|
||||
value: choice_high
|
||||
onValueChanged:
|
||||
{
|
||||
choice_high = value;
|
||||
|
@ -93,7 +132,7 @@ Setting {
|
|||
anchors.right: parent.right
|
||||
icon.source: "image://theme/icon-s-edit"
|
||||
onClicked: {var dialog = pageStack.push(Qt.resolvedUrl("IntegerInputDialog.qml"),
|
||||
{value: choice, title: prettyName,
|
||||
{title: prettyName + " (" + qsTr("High") + ")",
|
||||
min: 1, max: high});
|
||||
dialog.accepted.connect(function() {
|
||||
choice_high = dialog.value;
|
||||
|
@ -103,6 +142,17 @@ Setting {
|
|||
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
visible: acceptRangeList
|
||||
text: qsTr("Advanced")
|
||||
onClicked: {var dialog = pageStack.push(Qt.resolvedUrl("RangeListInputDialog.qml"),
|
||||
{title: prettyName});
|
||||
dialog.accepted.connect(function() {
|
||||
choice = dialog.value;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,21 +1,87 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Item {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
height: button.height + (menu != undefined ? menu.height : 0) + resetMenu.height
|
||||
width: parent.width
|
||||
|
||||
property string name
|
||||
property string prettyName
|
||||
property int tag
|
||||
property bool valid: false
|
||||
property string subkey: ""
|
||||
property bool _valid: parent.isValid(name)
|
||||
property bool valid: _valid
|
||||
|
||||
property var choice
|
||||
property var default_choice
|
||||
property var default_choice: parent.getDefaultChoice(name)
|
||||
|
||||
property var strings: parent.printer.strings
|
||||
|
||||
Component.onCompleted: parent.setInitialChoice(this)
|
||||
|
||||
onChoiceChanged: parent.choiceMade(this)
|
||||
|
||||
signal clicked()
|
||||
signal choiceMade(int tag, var choice)
|
||||
onChoiceChanged: choiceMade(tag, choice)
|
||||
onClicked: {
|
||||
if (hasMenu)
|
||||
{
|
||||
menu.open(this)
|
||||
}
|
||||
}
|
||||
|
||||
signal pressAndHold()
|
||||
onPressAndHold: {
|
||||
resetMenu.open(this)
|
||||
}
|
||||
|
||||
property alias displayValue: button.value
|
||||
|
||||
ValueButton {
|
||||
id: button
|
||||
enabled: valid
|
||||
label: prettyName
|
||||
onClicked: parent.clicked()
|
||||
onPressAndHold: parent.pressAndHold()
|
||||
valueColor: choice != undefined ? Theme.highlightColor : Theme.secondaryHighlightColor
|
||||
}
|
||||
|
||||
property var menu
|
||||
property bool hasMenu: true
|
||||
|
||||
function reset()
|
||||
{
|
||||
choice = undefined
|
||||
}
|
||||
|
||||
ContextMenu {
|
||||
id: resetMenu
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("Reset")
|
||||
onClicked: reset()
|
||||
}
|
||||
}
|
||||
|
||||
function highlight()
|
||||
{
|
||||
highlightAnimation.start()
|
||||
}
|
||||
|
||||
NumberAnimation
|
||||
{
|
||||
id: highlightAnimation
|
||||
target: fillRectangle
|
||||
property: "opacity"
|
||||
from: 0.5
|
||||
to: 0
|
||||
duration: 1000
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: fillRectangle
|
||||
anchors.fill: parent
|
||||
color: Theme.highlightBackgroundColor
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
}
|
||||
|
|
89
qml/components/SettingsColumn.qml
Normal file
89
qml/components/SettingsColumn.qml
Normal file
|
@ -0,0 +1,89 @@
|
|||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import seaprint.mimer 1.0
|
||||
import seaprint.ippprinter 1.0
|
||||
import seaprint.ippmsg 1.0
|
||||
|
||||
Column {
|
||||
id: settingsColumn
|
||||
|
||||
property var printer
|
||||
property var jobParams
|
||||
property string selectedFile
|
||||
property string selectedFileType: Mimer.get_type(selectedFile)
|
||||
|
||||
function isValid(name) {
|
||||
return printer.attrs.hasOwnProperty(name+"-supported");
|
||||
}
|
||||
function setInitialChoice(setting) {
|
||||
if(setting.valid)
|
||||
{
|
||||
if(setting.subkey == "")
|
||||
{
|
||||
if(jobParams.hasOwnProperty(setting.name))
|
||||
{
|
||||
setting.choice = jobParams[setting.name].value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(jobParams.hasOwnProperty(setting.subkey) &&jobParams[setting.subkey].value.hasOwnProperty(setting.name))
|
||||
{
|
||||
setting.choice = jobParams[setting.subkey].value[setting.name].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Clear jobParams of invalid settings
|
||||
delete jobParams[setting.name];
|
||||
}
|
||||
|
||||
}
|
||||
function getChoices(name) {
|
||||
return isValid(name) ? printer.attrs[name+"-supported"].value : [];
|
||||
}
|
||||
function getDefaultChoice(name) {
|
||||
return printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : undefined;
|
||||
}
|
||||
function choiceMade(setting)
|
||||
{
|
||||
if(setting.subkey == "")
|
||||
{
|
||||
if(setting.choice != undefined)
|
||||
{
|
||||
jobParams[setting.name] = {tag: setting.tag, value: setting.choice};
|
||||
}
|
||||
else
|
||||
{
|
||||
delete jobParams[setting.name];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var tmpObj = Object();
|
||||
if(jobParams.hasOwnProperty(setting.subkey))
|
||||
{
|
||||
tmpObj = jobParams[setting.subkey].value;
|
||||
}
|
||||
|
||||
if(setting.choice != undefined)
|
||||
{
|
||||
tmpObj[setting.name] = {tag: setting.tag, value: setting.choice};
|
||||
}
|
||||
else
|
||||
{
|
||||
delete tmpObj[setting.name];
|
||||
}
|
||||
|
||||
if(Object.keys(tmpObj).length != 0)
|
||||
{
|
||||
jobParams[setting.subkey] = {tag: IppMsg.BeginCollection, value: tmpObj};
|
||||
}
|
||||
else
|
||||
{
|
||||
delete jobParams[setting.subkey];
|
||||
}
|
||||
}
|
||||
// console.log(JSON.stringify(jobParams));
|
||||
}
|
||||
}
|
50
qml/components/SupplyItem.qml
Normal file
50
qml/components/SupplyItem.qml
Normal file
|
@ -0,0 +1,50 @@
|
|||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import "../components"
|
||||
|
||||
Row
|
||||
{
|
||||
id: item
|
||||
property var color: "white"
|
||||
property int level: 100
|
||||
property int high_level: 100
|
||||
property int low_level: 10
|
||||
property string name: ""
|
||||
property string type: ""
|
||||
property real value_fraction: level/(high_level == 0 ? 100 : high_level)
|
||||
|
||||
spacing: Theme.paddingMedium
|
||||
bottomPadding: Theme.paddingMedium
|
||||
|
||||
CylinderGraph
|
||||
{
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: parent.color
|
||||
value: value_fraction
|
||||
}
|
||||
Label
|
||||
{
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: Theme.itemSizeExtraSmall
|
||||
text: ""+Math.round(100*value_fraction)+"%"
|
||||
color: level <= low_level ? "red" : Theme.highlightColor
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
}
|
||||
Column
|
||||
{
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
Label
|
||||
{
|
||||
text: name != "" ? name : qsTr("Unnamed supply")
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: type != "" ? type : qsTr("Unknown type")
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
color: Theme.secondaryColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Nemo.DBus 2.0
|
||||
|
||||
|
||||
|
@ -20,12 +20,10 @@ Item {
|
|||
Component.onCompleted: go()
|
||||
|
||||
function servicesChanged() {
|
||||
console.log("services changed");
|
||||
go();
|
||||
}
|
||||
|
||||
function go() {
|
||||
console.log("go!")
|
||||
call("GetServices", undefined,
|
||||
function(result) {
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
|
|
|
@ -1,18 +1,31 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
CoverBackground {
|
||||
Icon {
|
||||
anchors.centerIn: parent
|
||||
height: parent.width * 0.9
|
||||
width: parent.width * 0.9
|
||||
opacity: 0.33
|
||||
source: "../pages/icon-seaprint-nobg-bw.svg"
|
||||
height: parent.width
|
||||
width: parent.width
|
||||
sourceSize.height: height
|
||||
sourceSize.width: width
|
||||
opacity: 0.4
|
||||
source: "../pages/icon-seaprint-nobg-bw.png"
|
||||
}
|
||||
|
||||
Label {
|
||||
id: label
|
||||
anchors.centerIn: parent
|
||||
text: qsTr("SeaPrint")
|
||||
Column {
|
||||
width: parent.width
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
Label {
|
||||
id: msgLabel
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: appWin.busyMessage != "" ? appWin.busyMessage : qsTr("SeaPrint")
|
||||
}
|
||||
Label {
|
||||
id: progressLabel
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: appWin.progress
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,59 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import QtQuick.LocalStorage 2.0
|
||||
import Nemo.Notifications 1.0
|
||||
import Nemo.Configuration 1.0
|
||||
import seaprint.mimer 1.0
|
||||
import seaprint.settings 1.0
|
||||
|
||||
import "pages"
|
||||
import "components"
|
||||
|
||||
ApplicationWindow
|
||||
{
|
||||
initialPage: Component { FirstPage { selectedFile: Qt.application.arguments[1] ? Qt.application.arguments[1] : "" } }
|
||||
id: appWin
|
||||
|
||||
property Page _mainPage
|
||||
|
||||
property bool expectCalligra: true
|
||||
|
||||
|
||||
function openFile(file) {
|
||||
selectedFile = file
|
||||
selectedFileType = Mimer.get_type(selectedFile);
|
||||
if(selectedFileType == "")
|
||||
{
|
||||
selectedFile = ""
|
||||
notifier.notify(qsTr("Unsupported document format"))
|
||||
}
|
||||
if(pageStack.currentPage.busyPage)
|
||||
{
|
||||
notifier.notify(qsTr("New file selected"))
|
||||
}
|
||||
else
|
||||
{
|
||||
pageStack.pop(appWin._mainPage, PageStackAction.Immediate)
|
||||
}
|
||||
}
|
||||
|
||||
property string selectedFile: ""
|
||||
property string selectedFileType
|
||||
|
||||
initialPage: Component {
|
||||
FirstPage {
|
||||
Component.onCompleted: appWin._mainPage = this
|
||||
}
|
||||
}
|
||||
cover: Qt.resolvedUrl("cover/CoverPage.qml")
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
property string busyMessage: ""
|
||||
property string progress: ""
|
||||
|
||||
WifiChecker {
|
||||
id: wifi
|
||||
}
|
||||
|
||||
Item {
|
||||
id: db
|
||||
property var db_conn
|
||||
|
@ -19,7 +62,7 @@ ApplicationWindow
|
|||
db_conn = LocalStorage.openDatabaseSync("SeaprintDB", "1.0", "Seaprint storage", 100000)
|
||||
db_conn.transaction(function (tx) {
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS Favourites (ssid STRING, url STRING)');
|
||||
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS JobSettings (uuid STRING, type STRING, data STRING)');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -36,11 +79,9 @@ ApplicationWindow
|
|||
db_conn.transaction(function (tx) {
|
||||
var res = tx.executeSql('SELECT * FROM Favourites WHERE ssid=?', [ssid]);
|
||||
for (var i = 0; i < res.rows.length; i++) {
|
||||
console.log(res.rows.item(i).url)
|
||||
favs.push(res.rows.item(i).url);
|
||||
}
|
||||
});
|
||||
console.log(ssid, favs);
|
||||
return favs
|
||||
}
|
||||
|
||||
|
@ -60,6 +101,54 @@ ApplicationWindow
|
|||
tx.executeSql('DELETE FROM Favourites WHERE ssid=? AND url=?', [ssid, url] );
|
||||
});
|
||||
}
|
||||
|
||||
function simplifyType(mimetype) {
|
||||
if(mimetype == Mimer.SVG)
|
||||
{
|
||||
return {simple: "svg", translatable: qsTr("SVGs")};
|
||||
}
|
||||
else if(Mimer.isImage(mimetype))
|
||||
{
|
||||
return {simple: "image", translatable: qsTr("images")};
|
||||
}
|
||||
else if(mimetype == Mimer.Plaintext)
|
||||
{
|
||||
return {simple: "plaintext", translatable: qsTr("plaintext")};
|
||||
}
|
||||
else
|
||||
{
|
||||
return {simple: "document", translatable: qsTr("documents")};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function setJobSettings(uuid, mimetype, settings) {
|
||||
var type = simplifyType(mimetype).simple;
|
||||
db_conn.transaction(function (tx) {
|
||||
tx.executeSql('DELETE FROM JobSettings WHERE uuid=? AND type=?', [uuid, type] );
|
||||
tx.executeSql('INSERT INTO JobSettings VALUES(?, ?, ?)', [uuid, type, settings] );
|
||||
});
|
||||
}
|
||||
|
||||
function getJobSettings(uuid, mimetype) {
|
||||
var type = simplifyType(mimetype).simple;
|
||||
var settings = "{}";
|
||||
db_conn.transaction(function (tx) {
|
||||
var res = tx.executeSql('SELECT * FROM JobSettings WHERE uuid=? AND type=?', [uuid, type]);
|
||||
if (res.rows.length)
|
||||
{
|
||||
settings = res.rows.item(0).data
|
||||
}
|
||||
});
|
||||
return settings
|
||||
}
|
||||
|
||||
function removeJobSettings(uuid, mimetype) {
|
||||
var type = simplifyType(mimetype).simple;
|
||||
db_conn.transaction(function (tx) {
|
||||
tx.executeSql('DELETE FROM JobSettings WHERE uuid=? AND type=?', [uuid, type] );
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Notification {
|
||||
|
@ -68,7 +157,6 @@ ApplicationWindow
|
|||
expireTimeout: 4000
|
||||
|
||||
function notify(data) {
|
||||
console.log("notifyMessage", data)
|
||||
body = data
|
||||
previewBody = data
|
||||
publish()
|
||||
|
@ -80,7 +168,7 @@ ApplicationWindow
|
|||
id: nagScreenSetting
|
||||
key: "/apps/harbour-seaprint/settings/nag-screen"
|
||||
defaultValue: 0
|
||||
property int expectedValue: 1
|
||||
property int expectedValue: expectCalligra ? 2 : 1
|
||||
}
|
||||
|
||||
ConfigurationValue
|
||||
|
@ -92,32 +180,24 @@ ApplicationWindow
|
|||
|
||||
ConfigurationValue
|
||||
{
|
||||
id: alwaysConvertSetting
|
||||
key: "/apps/harbour-seaprint/settings/always-convert"
|
||||
defaultValue: false
|
||||
id: ignoreSslErrorsSetting
|
||||
key: SeaPrintSettings.ignoreSslErrorsPath
|
||||
defaultValue: SeaPrintSettings.ignoreSslErrorsDefault
|
||||
}
|
||||
|
||||
ConfigurationValue
|
||||
{
|
||||
id: forceIncluDeDocumentFormatSetting
|
||||
key: "/apps/harbour-seaprint/settings/force-include-document-format"
|
||||
defaultValue: false
|
||||
id: debugLogSetting
|
||||
key: SeaPrintSettings.debugLogPath
|
||||
defaultValue: SeaPrintSettings.debugLogDefault
|
||||
}
|
||||
|
||||
ConfigurationValue
|
||||
{
|
||||
id: removeRedundantConvertAttrsSetting
|
||||
key: "/apps/harbour-seaprint/settings/remove-redundant-convert-attributes"
|
||||
defaultValue: true
|
||||
id: allowExternalConnectionsSetting
|
||||
key: SeaPrintSettings.allowExternalConnectionsPath
|
||||
defaultValue: SeaPrintSettings.allowExternalConnectionsDefault
|
||||
}
|
||||
|
||||
ConfigurationValue
|
||||
{
|
||||
id: alwaysUseMediaColSetting
|
||||
key: "/apps/harbour-seaprint/settings/always-use-media-col"
|
||||
defaultValue: false
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import seaprint.convertchecker 1.0
|
||||
import "../components"
|
||||
|
@ -62,7 +62,7 @@ Page {
|
|||
AboutLabel {
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.primaryColor
|
||||
text: "© 2019-2020 Anton Thomasson"
|
||||
text: "© 2019-2023 Anton Thomasson et al."
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,15 +80,17 @@ Page {
|
|||
}
|
||||
|
||||
SectionHeader { text: qsTr("General contributions") }
|
||||
|
||||
AboutLabel {
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
text: qsTr("Code and Testing - Rudi Timmermans")
|
||||
text: "karry\n"+
|
||||
"piggz\n"+
|
||||
"Rudi Timmermans"
|
||||
}
|
||||
|
||||
SectionHeader { text: qsTr("Special thanks to") }
|
||||
AboutLabel {
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
text: qsTr("Testing and Design Suggestions - piggz")
|
||||
text: "dcaliste"
|
||||
}
|
||||
|
||||
SectionHeader { text: qsTr("Translations") }
|
||||
|
@ -96,16 +98,18 @@ Page {
|
|||
AboutLabel {
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
text: qsTr("Chinese")+" - dashinfantry\n"+
|
||||
qsTr("French")+" - ensag-dev, Quentí\n"+
|
||||
qsTr("Spanish")+" - carmenfdezb\n"+
|
||||
qsTr("Polish")+" - atlochowski"
|
||||
qsTr("Dutch")+" - JSEHV, Rudi Timmermans\n"+
|
||||
qsTr("French")+" - ensag-dev, pherjung, phklrz, Quentí\n"+
|
||||
qsTr("German")+" - black-sheep-dev, cnlpete, wheelseal\n"+
|
||||
qsTr("Polish")+" - atlochowski, karolkurek\n"+
|
||||
qsTr("Spanish")+" - carmenfdezb, JSEHV"
|
||||
}
|
||||
|
||||
SectionHeader { text: qsTr("Optional dependencies") }
|
||||
|
||||
AboutLabel {
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
text: "poppler-utils - "+(ConvertChecker.pdf ? qsTr("Installed") : qsTr("Not installed"))
|
||||
text: "calligraconverter - "+(ConvertChecker.calligra ? qsTr("Installed") : qsTr("Not installed"))
|
||||
}
|
||||
|
||||
SectionHeader { text: qsTr("Donations") }
|
||||
|
@ -137,7 +141,7 @@ Page {
|
|||
AboutLabel {
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.primaryColor
|
||||
text: qsTr("SeaPrint licencing is still TBD, but will be some flavor of open.")
|
||||
text: qsTr("SeaPrint is free software released under the GNU General Public License (GPL), version 3 or later.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import seaprint.ippprinter 1.0
|
||||
import "utils.js" as Utils
|
||||
|
||||
Dialog {
|
||||
id: dialog
|
||||
|
@ -9,9 +10,38 @@ Dialog {
|
|||
property string value
|
||||
property string ssid
|
||||
property var printerName: false
|
||||
canAccept: printerName != false
|
||||
canAccept: Object.keys(printer.attrs).length != 0
|
||||
|
||||
Connections {
|
||||
target: wifi
|
||||
onConnectedChanged: {
|
||||
if(!wifi.connected) {
|
||||
dialog.reject()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
valueField.forceActiveFocus()
|
||||
}
|
||||
|
||||
IppPrinter {
|
||||
id: printer
|
||||
url: valueField.text
|
||||
onAttrsChanged: {
|
||||
if(printer.attrs.hasOwnProperty("printer-name")) {
|
||||
printerName = Utils.unknownForEmptyString(printer.attrs["printer-name"].value)
|
||||
}
|
||||
else
|
||||
{
|
||||
printerName = qsTr("Unknown")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: col
|
||||
width: parent.width
|
||||
|
||||
DialogHeader {
|
||||
|
@ -22,7 +52,7 @@ Dialog {
|
|||
id: valueField
|
||||
width: parent.width
|
||||
placeholderText: "192.168.1.1/ipp/print"
|
||||
|
||||
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase
|
||||
label: title
|
||||
}
|
||||
Row {
|
||||
|
@ -31,12 +61,12 @@ Dialog {
|
|||
|
||||
Label {
|
||||
id: wifi_label
|
||||
text: qsTr("On WiFI:")
|
||||
text: qsTr("On WiFi:")
|
||||
}
|
||||
Label {
|
||||
id: ssid_label
|
||||
color: Theme.secondaryColor
|
||||
text: ssid
|
||||
text: wifi.ssid
|
||||
}
|
||||
}
|
||||
Row {
|
||||
|
@ -45,27 +75,88 @@ Dialog {
|
|||
|
||||
Label {
|
||||
id: found_label
|
||||
text: printerName != false ? qsTr("Found:") : qsTr("No printer found")
|
||||
text: canAccept ? qsTr("Found:") : qsTr("No printer found")
|
||||
}
|
||||
Label {
|
||||
id: printer_label
|
||||
color: Theme.secondaryColor
|
||||
text: printerName ? printerName : ""
|
||||
text: canAccept ? printerName : ""
|
||||
}
|
||||
}
|
||||
IppPrinter {
|
||||
id: printer
|
||||
url: valueField.text
|
||||
onAttrsChanged: {
|
||||
if(printer.attrs["printer-name"]) {
|
||||
printerName = printer.attrs["printer-name"].value == "" ? qsTr("Unknown") : printer.attrs["printer-name"].value
|
||||
}
|
||||
else
|
||||
{
|
||||
printerName = false
|
||||
}
|
||||
|
||||
Item {
|
||||
width: 1
|
||||
height: 2*Theme.paddingLarge
|
||||
}
|
||||
|
||||
Row {
|
||||
visible: valueField.text.indexOf(":9100") != -1
|
||||
x: Theme.paddingLarge
|
||||
|
||||
width: parent.width-2*Theme.paddingLarge
|
||||
spacing: Theme.paddingMedium
|
||||
|
||||
Icon {
|
||||
id: warningIcon
|
||||
source: "image://theme/icon-m-warning"
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Label {
|
||||
width: parent.width-warningIcon.width-Theme.paddingMedium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: Theme.highlightColor
|
||||
wrapMode: Text.WordWrap
|
||||
text: qsTr("Port 9100 is not used for IPP.")
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
id: suffixWarning
|
||||
visible: canAccept && !printer.correctSuffix
|
||||
x: Theme.paddingLarge
|
||||
|
||||
width: parent.width-2*Theme.paddingLarge
|
||||
spacing: Theme.paddingMedium
|
||||
|
||||
Icon {
|
||||
id: warningIcon2
|
||||
source: "image://theme/icon-m-warning"
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Label {
|
||||
width: parent.width-warningIcon2.width-Theme.paddingMedium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: Theme.highlightColor
|
||||
wrapMode: Text.WordWrap
|
||||
text: qsTr("The uri suffix is not in the printer's supported list.")+" "+
|
||||
qsTr("It might not accept print jobs on this address.")+" "+
|
||||
qsTr("Consider using a suffix like \"/ipp/print\".")
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: 1
|
||||
height: 2*Theme.paddingLarge
|
||||
}
|
||||
|
||||
Label
|
||||
{
|
||||
x: Theme.paddingLarge
|
||||
visible: suffixWarning.visible && printer.suffixes.length != 0
|
||||
text: qsTr("The printer/server lists these suffixes:")
|
||||
}
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: suffixWarning.visible ? printer.suffixes : 0
|
||||
Label
|
||||
{
|
||||
x: Theme.paddingLarge
|
||||
text: printer.suffixes[index]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,6 +164,7 @@ Dialog {
|
|||
onDone: {
|
||||
if (result == DialogResult.Accepted) {
|
||||
value = valueField.text
|
||||
ssid = wifi.ssid
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import "utils.js" as Utils
|
||||
|
||||
Page {
|
||||
property bool busyPage: true
|
||||
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
Component.onCompleted: {
|
||||
appWin.busyMessage = printer.busyMessage
|
||||
}
|
||||
|
||||
property var printer
|
||||
backNavigation: false
|
||||
Connections {
|
||||
|
@ -28,10 +34,22 @@ Page {
|
|||
notifier.notify(qsTr("Print failed: ") + msg)
|
||||
}
|
||||
}
|
||||
onBusyMessageChanged: {
|
||||
appWin.busyMessage = printer.busyMessage
|
||||
}
|
||||
|
||||
onProgressChanged: {
|
||||
appWin.progress = printer.progress
|
||||
}
|
||||
}
|
||||
|
||||
BusyLabel {
|
||||
text: printer.busyMessage+"\n"+printer.progress;
|
||||
running: true
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
appWin.busyMessage = ""
|
||||
appWin.progress = ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import "utils.js" as Utils
|
||||
|
||||
Page {
|
||||
|
||||
|
@ -17,7 +18,7 @@ Page {
|
|||
|
||||
PageHeader {
|
||||
id: header
|
||||
title: printer.attrs["printer-name"].value
|
||||
title: Utils.unknownForEmptyString(printer.attrs["printer-name"].value)
|
||||
}
|
||||
|
||||
TextArea {
|
||||
|
|
171
qml/pages/DetailsPage.qml
Normal file
171
qml/pages/DetailsPage.qml
Normal file
|
@ -0,0 +1,171 @@
|
|||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import "utils.js" as Utils
|
||||
import "../components"
|
||||
|
||||
Page {
|
||||
allowedOrientations: Orientation.All
|
||||
property var printer
|
||||
|
||||
SilicaFlickable {
|
||||
id: detailsFlickable
|
||||
anchors.fill: parent
|
||||
contentHeight: col.height
|
||||
|
||||
PullDownMenu {
|
||||
visible: identifyLabel.visible
|
||||
|
||||
MenuItem {
|
||||
id: identifyLabel
|
||||
text: qsTr("Identify printer")
|
||||
visible: printer.attrs.hasOwnProperty("identify-actions-supported")
|
||||
onClicked: printer.identify()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Column {
|
||||
id: col
|
||||
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: Math.min(Screen.width, detailsFlickable.width)-2*Theme.paddingLarge
|
||||
PageHeader {
|
||||
title: qsTr("Details")
|
||||
description: Utils.unknownForEmptyString(printer.attrs["printer-name"].value)
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// location?
|
||||
// message from operator?
|
||||
// organization /-unit
|
||||
// supply info uri?
|
||||
// identify button?
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("Make and model")
|
||||
}
|
||||
|
||||
Label {
|
||||
text: Utils.unknownForEmptyString(printer.attrs["printer-make-and-model"].value)
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("Location")
|
||||
visible: Utils.existsAndNotEmpty("printer-location", printer)
|
||||
}
|
||||
|
||||
Label {
|
||||
text: printer.attrs["printer-location"].value
|
||||
visible: Utils.existsAndNotEmpty("printer-location", printer)
|
||||
}
|
||||
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("Printer status")
|
||||
}
|
||||
|
||||
Label {
|
||||
text: Utils.ippName("printer-state", printer.attrs["printer-state"].value)
|
||||
}
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: printer.attrs["printer-state-reasons"].value
|
||||
Label {
|
||||
text: Utils.ippName("printer-state-reasons", printer.attrs["printer-state-reasons"].value[index])
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: printer.attrs["printer-state-message"].value
|
||||
visible: printer.attrs.hasOwnProperty("printer-state-message")
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("Supply status")
|
||||
visible: printer.attrs.hasOwnProperty("marker-colors")
|
||||
}
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: printer.attrs["marker-colors"].value.length
|
||||
|
||||
SupplyItem
|
||||
{
|
||||
color: printer.attrs["marker-colors"].value[index]
|
||||
level: printer.attrs["marker-levels"].value[index]
|
||||
high_level: printer.attrs["marker-high-levels"].value[index]
|
||||
low_level: printer.attrs["marker-low-levels"].value[index]
|
||||
name: printer.attrs["marker-names"].value[index]
|
||||
type: printer.attrs["marker-types"].value[index]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("IPP versions")
|
||||
visible: printer.attrs.hasOwnProperty("ipp-versions-supported")
|
||||
}
|
||||
|
||||
|
||||
Label
|
||||
{
|
||||
text: printer.attrs["ipp-versions-supported"].value.join(" ")
|
||||
visible: printer.attrs.hasOwnProperty("ipp-versions-supported")
|
||||
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("IPP features")
|
||||
visible: printer.attrs.hasOwnProperty("ipp-features-supported")
|
||||
}
|
||||
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: printer.attrs["ipp-features-supported"].value.length
|
||||
Label
|
||||
{
|
||||
text: printer.attrs["ipp-features-supported"].value[index]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("Firmware")
|
||||
visible: printer.attrs.hasOwnProperty("marker-colors")
|
||||
}
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: printer.attrs["printer-firmware-name"].value.length
|
||||
Label
|
||||
{
|
||||
text: printer.attrs["printer-firmware-name"].value[index]+": "
|
||||
+ printer.attrs["printer-firmware-string-version"].value[index]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("Performance")
|
||||
visible: printer.attrs.hasOwnProperty("pages-per-minute") || printer.attrs.hasOwnProperty("pages-per-minute-color")
|
||||
}
|
||||
|
||||
Label
|
||||
{
|
||||
text: ""+printer.attrs["pages-per-minute"].value+" "+qsTr("pages/min")
|
||||
visible: printer.attrs.hasOwnProperty("pages-per-minute")
|
||||
|
||||
}
|
||||
|
||||
Label
|
||||
{
|
||||
text: ""+printer.attrs["pages-per-minute-color"].value+" "+qsTr("pages/min (color)")
|
||||
visible: printer.attrs.hasOwnProperty("pages-per-minute-color")
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +1,32 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import Sailfish.Pickers 1.0
|
||||
import seaprint.ippdiscovery 1.0
|
||||
import seaprint.convertchecker 1.0
|
||||
import seaprint.ippprinter 1.0
|
||||
import seaprint.imageitem 1.0
|
||||
import seaprint.mimer 1.0
|
||||
import "utils.js" as Utils
|
||||
import "../components"
|
||||
import Nemo.DBus 2.0
|
||||
|
||||
Page {
|
||||
id: page
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
property string selectedFile: ""
|
||||
property string selectedFileType
|
||||
|
||||
WifiChecker {
|
||||
id: wifi
|
||||
Connections {
|
||||
target: wifi
|
||||
onConnectedChanged: {
|
||||
console.log("conn", connected, ssid)
|
||||
if(connected) {
|
||||
var favourites = db.getFavourites(ssid);
|
||||
console.log(favourites);
|
||||
if(wifi.connected) {
|
||||
var favourites = db.getFavourites(wifi.ssid);
|
||||
IppDiscovery.favourites = favourites;
|
||||
}
|
||||
else {
|
||||
IppDiscovery.favourites = []
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
property bool initialSSIDchange: true
|
||||
|
||||
onSsidChanged: {
|
||||
console.log("ssid changed", ssid);
|
||||
if(!initialSSIDchange)
|
||||
{
|
||||
IppDiscovery.reset();
|
||||
|
@ -43,16 +35,28 @@ Page {
|
|||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Not on WiFi")
|
||||
color: Theme.highlightColor
|
||||
anchors.centerIn: parent
|
||||
visible: !wifi.connected
|
||||
}
|
||||
|
||||
property bool initialized: false
|
||||
onVisibleChanged: {
|
||||
if (visible)
|
||||
{
|
||||
if(initialized)
|
||||
page.refreshed()
|
||||
initialized = true
|
||||
}
|
||||
}
|
||||
|
||||
signal refreshed()
|
||||
signal noFileSelected()
|
||||
|
||||
Component.onCompleted: {
|
||||
IppDiscovery.discover();
|
||||
if(selectedFile != "")
|
||||
{
|
||||
var type = Mimer.get_type(selectedFile);
|
||||
console.log(type);
|
||||
selectedFileType = type;
|
||||
}
|
||||
}
|
||||
|
||||
property bool nagged: false
|
||||
|
@ -60,8 +64,7 @@ Page {
|
|||
onStatusChanged: {
|
||||
if(status==PageStatus.Active && !nagged && nagScreenSetting.value != nagScreenSetting.expectedValue)
|
||||
{
|
||||
console.log("Can convert from PDF:", ConvertChecker.pdf)
|
||||
if(!ConvertChecker.pdf)
|
||||
if(expectCalligra && !ConvertChecker.calligra)
|
||||
{
|
||||
nagged=true
|
||||
pageStack.push(Qt.resolvedUrl("NagScreen.qml"))
|
||||
|
@ -71,7 +74,10 @@ Page {
|
|||
|
||||
// To enable PullDownMenu, place our content in a SilicaFlickable
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
anchors.top: parent.top
|
||||
width: parent.width
|
||||
anchors.bottom: fileDock.top
|
||||
clip: true
|
||||
|
||||
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
|
||||
PullDownMenu {
|
||||
|
@ -87,12 +93,10 @@ Page {
|
|||
text: qsTr("Add by URL")
|
||||
enabled: wifi.connected
|
||||
onClicked: {
|
||||
var dialog = pageStack.push(Qt.resolvedUrl("AddPrinterDialog.qml"),
|
||||
{ssid: wifi.ssid, title: qsTr("URL")});
|
||||
var dialog = pageStack.push(Qt.resolvedUrl("AddPrinterDialog.qml"));
|
||||
dialog.accepted.connect(function() {
|
||||
console.log("add", wifi.ssid, dialog.value);
|
||||
db.addFavourite(wifi.ssid, dialog.value);
|
||||
IppDiscovery.favourites = db.getFavourites(wifi.ssid);
|
||||
IppDiscovery.favourites = db.getFavourites(dialog.ssid);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -106,8 +110,8 @@ Page {
|
|||
}
|
||||
|
||||
SilicaListView {
|
||||
anchors.fill: parent
|
||||
id: listView
|
||||
anchors.fill: parent
|
||||
model: IppDiscovery
|
||||
spacing: Theme.paddingSmall
|
||||
|
||||
|
@ -122,10 +126,16 @@ Page {
|
|||
id: delegate
|
||||
contentItem.height: visible ? Math.max(column.implicitHeight, Theme.itemSizeLarge+2*Theme.paddingMedium) : 0
|
||||
|
||||
visible: false
|
||||
IppPrinter {
|
||||
id: printer
|
||||
url: model.display
|
||||
}
|
||||
|
||||
property string name: printer.attrs["printer-name"].value != "" ? printer.attrs["printer-name"].value : qsTr("Unknown")
|
||||
property bool canPrint: Utils.supported_formats(printer, ConvertChecker, considerAdditionalFormatsSetting.value).mimetypes.indexOf(selectedFileType) != -1
|
||||
visible: Object.keys(printer.attrs).length !== 0
|
||||
|
||||
property string name: Utils.unknownForEmptyString(printer.attrs["printer-name"].value)
|
||||
property var supported_formats: Utils.supported_formats(printer, considerAdditionalFormatsSetting.value)
|
||||
property bool canPrint: supported_formats.mimetypes.indexOf(appWin.selectedFileType) != -1
|
||||
|
||||
Connections {
|
||||
target: printer
|
||||
|
@ -143,7 +153,6 @@ Page {
|
|||
Connections {
|
||||
target: page
|
||||
onRefreshed: {
|
||||
console.log("onRefreshed")
|
||||
printer.refresh()
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +170,19 @@ Page {
|
|||
|
||||
property int debugCount: 0
|
||||
|
||||
function maybeGetParams()
|
||||
{
|
||||
if(printer.attrs.hasOwnProperty("printer-uuid"))
|
||||
{
|
||||
return JSON.parse(db.getJobSettings(printer.attrs["printer-uuid"].value, appWin.selectedFileType));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Object();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onClicked: {
|
||||
|
||||
if(++debugCount == 5)
|
||||
|
@ -169,24 +191,21 @@ Page {
|
|||
return;
|
||||
}
|
||||
debugCountReset.restart();
|
||||
if(!canPrint)
|
||||
return;
|
||||
if(selectedFile != "")
|
||||
if(appWin.selectedFile == "")
|
||||
{
|
||||
pageStack.push(Qt.resolvedUrl("PrinterPage.qml"), {printer: printer, selectedFile: selectedFile})
|
||||
noFileSelected();
|
||||
}
|
||||
else if(!canPrint)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
notifier.notify(qsTr("No file selected"))
|
||||
pageStack.push(Qt.resolvedUrl("PrinterPage.qml"), {printer: printer, selectedFile: appWin.selectedFile, jobParams: maybeGetParams()})
|
||||
}
|
||||
}
|
||||
|
||||
IppPrinter {
|
||||
id: printer
|
||||
url: model.display
|
||||
}
|
||||
|
||||
Image {
|
||||
ImageItem {
|
||||
id: icon
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
|
@ -195,11 +214,25 @@ Page {
|
|||
|
||||
height: Theme.itemSizeLarge
|
||||
width: Theme.itemSizeLarge
|
||||
source: printer.attrs["printer-icons"] ? "image://ippdiscovery/"+Utils.selectIcon(printer.attrs["printer-icons"].value)
|
||||
: "icon-seaprint-nobg.svg"
|
||||
// Some printers serve their icons over https with invalid certs...
|
||||
onStatusChanged: if (status == Image.Error) source = "icon-seaprint-nobg.svg"
|
||||
image: printer.icon
|
||||
|
||||
Image {
|
||||
id: placeholder
|
||||
anchors.fill: parent
|
||||
sourceSize.height: height
|
||||
sourceSize.width: width
|
||||
|
||||
visible: !parent.valid
|
||||
source: "icon-seaprint-nobg.svg"
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: warningIcon
|
||||
source: "image://theme/icon-lock-warning"
|
||||
anchors.bottom: icon.bottom
|
||||
anchors.right: icon.right
|
||||
visible: Utils.isWaringState(printer)
|
||||
}
|
||||
|
||||
Column {
|
||||
|
@ -209,20 +242,21 @@ Page {
|
|||
|
||||
Label {
|
||||
id: name_label
|
||||
color: canPrint || selectedFile == "" ? Theme.primaryColor : Theme.secondaryColor
|
||||
color: canPrint || appWin.selectedFile == "" ? Theme.primaryColor : Theme.secondaryColor
|
||||
text: name
|
||||
}
|
||||
|
||||
Label {
|
||||
id: mm_label
|
||||
color: canPrint || selectedFile == "" ? Theme.primaryColor : Theme.secondaryColor
|
||||
color: canPrint || appWin.selectedFile == "" ? Theme.primaryColor : Theme.secondaryColor
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
text: printer.attrs["printer-make-and-model"].value
|
||||
text: Utils.unknownForEmptyString(printer.attrs["printer-make-and-model"].value)
|
||||
+ (Utils.existsAndNotEmpty("printer-location", printer) ? " • "+printer.attrs["printer-location"].value : "")
|
||||
}
|
||||
|
||||
Label {
|
||||
id: uri_label
|
||||
color: canPrint || selectedFile == "" ? Theme.highlightColor : Theme.secondaryColor
|
||||
color: canPrint || appWin.selectedFile == "" ? Theme.highlightColor : Theme.secondaryColor
|
||||
font.pixelSize: Theme.fontSizeTiny
|
||||
text: printer.url
|
||||
}
|
||||
|
@ -231,16 +265,61 @@ Page {
|
|||
spacing: Theme.paddingMedium
|
||||
Label {
|
||||
id: format_unsupported_label
|
||||
visible: format_label.text == ""
|
||||
visible: !supported_formats.pdf && !supported_formats.postscript && !supported_formats.plaintext
|
||||
&& !supported_formats.office && !supported_formats.images
|
||||
color: "red"
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
text: qsTr("No compatible formats supported")
|
||||
}
|
||||
Label {
|
||||
id: format_label
|
||||
color: selectedFile == "" ? Theme.secondaryColor : canPrint ? Theme.primaryColor : "red"
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
text: Utils.supported_formats(printer, ConvertChecker, considerAdditionalFormatsSetting.value).supported
|
||||
|
||||
HighlightImage {
|
||||
height: Theme.itemSizeExtraSmall/2
|
||||
width: Theme.itemSizeExtraSmall/2
|
||||
visible: supported_formats.pdf
|
||||
highlightColor: "red"
|
||||
highlighted: !(appWin.selectedFile == "" || canPrint)
|
||||
source: "image://theme/icon-m-file-pdf"
|
||||
}
|
||||
HighlightImage {
|
||||
height: Theme.itemSizeExtraSmall/2
|
||||
width: Theme.itemSizeExtraSmall/2
|
||||
visible: supported_formats.postscript
|
||||
highlightColor: "red"
|
||||
highlighted: !(appWin.selectedFile == "" || canPrint)
|
||||
source: "image://theme/icon-m-file-other"
|
||||
|
||||
}
|
||||
HighlightImage {
|
||||
height: Theme.itemSizeExtraSmall/2
|
||||
width: Theme.itemSizeExtraSmall/2
|
||||
visible: supported_formats.plaintext
|
||||
highlightColor: "red"
|
||||
highlighted: !(appWin.selectedFile == "" || canPrint)
|
||||
source: "image://theme/icon-m-file-document"
|
||||
}
|
||||
HighlightImage {
|
||||
height: Theme.itemSizeExtraSmall/2
|
||||
width: Theme.itemSizeExtraSmall/2
|
||||
visible: supported_formats.office
|
||||
highlightColor: "red"
|
||||
highlighted: !(appWin.selectedFile == "" || canPrint)
|
||||
source: "image://theme/icon-m-file-formatted"
|
||||
}
|
||||
HighlightImage {
|
||||
height: Theme.itemSizeExtraSmall/2
|
||||
width: Theme.itemSizeExtraSmall/2
|
||||
visible: supported_formats.office
|
||||
highlightColor: "red"
|
||||
highlighted: !(appWin.selectedFile == "" || canPrint)
|
||||
source: "image://theme/icon-m-file-presentation"
|
||||
}
|
||||
HighlightImage {
|
||||
height: Theme.itemSizeExtraSmall/2
|
||||
width: Theme.itemSizeExtraSmall/2
|
||||
visible: supported_formats.images
|
||||
highlightColor: "red"
|
||||
highlighted: !(appWin.selectedFile == "" || canPrint)
|
||||
source: "image://theme/icon-m-file-image"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,75 +334,122 @@ Page {
|
|||
text: qsTr("View jobs")
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("JobsPage.qml"), {printer: printer})
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Printer details")
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("DetailsPage.qml"), {printer: printer})
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Remove printer")
|
||||
visible: db.isFavourite(wifi.ssid, model.display)
|
||||
onClicked: {
|
||||
removeRemorse.execute(delegate, qsTr("Removing printer"),
|
||||
function() {db.removeFavourite(wifi.ssid, model.display);
|
||||
IppDiscovery.favourites = db.getFavourites()})
|
||||
IppDiscovery.favourites = db.getFavourites(wifi.ssid)})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
onCountChanged: {
|
||||
console.log("count", count)
|
||||
}
|
||||
}
|
||||
}
|
||||
DockedPanel {
|
||||
Rectangle {
|
||||
id: fileDock
|
||||
open: true
|
||||
height: fileLabel.height+folderButton.height+3*Theme.paddingLarge
|
||||
height: panelColumn.implicitHeight
|
||||
width: parent.width
|
||||
dock: Dock.Bottom
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
Label {
|
||||
id: fileLabel
|
||||
width: parent.width-2*Theme.paddingLarge
|
||||
|
||||
anchors {
|
||||
top: parent.top
|
||||
topMargin: Theme.paddingLarge
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
horizontalAlignment: contentWidth > width ? Text.AlignRight : Text.AlignHCenter
|
||||
truncationMode: TruncationMode.Fade
|
||||
text: selectedFile != "" ? selectedFile : qsTr("No file selected")
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.15) }
|
||||
GradientStop { position: 1.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.3) }
|
||||
}
|
||||
|
||||
|
||||
Row {
|
||||
Column {
|
||||
id: panelColumn
|
||||
width: parent.width
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: Theme.paddingLarge
|
||||
IconButton {
|
||||
id: folderButton
|
||||
icon.source: "image://theme/icon-m-file-folder"
|
||||
width: parent.width/2
|
||||
onClicked: pageStack.push(filePickerPage)
|
||||
spacing: Theme.paddingLarge
|
||||
topPadding: page.isPortrait && !warningRow.visible ? 2*Theme.paddingLarge : Theme.paddingLarge
|
||||
bottomPadding: page.isPortrait ? 2*Theme.paddingLarge : Theme.paddingLarge
|
||||
|
||||
Row {
|
||||
id: warningRow
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: Mimer.isOffice(appWin.selectedFileType)
|
||||
|
||||
HighlightImage {
|
||||
source: "image://theme/icon-s-warning"
|
||||
highlighted: true
|
||||
highlightColor: Theme.highlightColor
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: qsTr("This format may not render correctly")
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
color: Theme.highlightColor
|
||||
}
|
||||
}
|
||||
IconButton {
|
||||
icon.source: "image://theme/icon-m-file-image"
|
||||
width: parent.width/2
|
||||
onClicked: pageStack.push(imagePickerPage)
|
||||
|
||||
Label {
|
||||
id: fileLabel
|
||||
width: parent.width
|
||||
leftPadding: Theme.paddingLarge
|
||||
rightPadding: Theme.paddingLarge
|
||||
|
||||
horizontalAlignment: contentWidth > width ? Text.AlignRight : Text.AlignHCenter
|
||||
truncationMode: TruncationMode.Fade
|
||||
text: appWin.selectedFile != "" ? appWin.selectedFile : qsTr("No file selected")
|
||||
|
||||
SequentialAnimation {
|
||||
id: noFileSelectedAnimation
|
||||
loops: 3
|
||||
|
||||
ColorAnimation {target: fileLabel; property: "color"; from: Theme.primaryColor; to: Theme.highlightColor; duration: 200 }
|
||||
ColorAnimation {target: fileLabel; property: "color"; from: Theme.highlightColor; to: Theme.primaryColor; duration: 200 }
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: page
|
||||
onNoFileSelected: {
|
||||
noFileSelectedAnimation.start()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
IconButton {
|
||||
id: folderButton
|
||||
icon.source: "image://theme/icon-m-file-document"
|
||||
width: parent.width/2
|
||||
onClicked: pageStack.push(documentPickerPage)
|
||||
}
|
||||
IconButton {
|
||||
id: imageButton
|
||||
icon.source: "image://theme/icon-m-file-image"
|
||||
width: parent.width/2
|
||||
onClicked: pageStack.push(imagePickerPage)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Component {
|
||||
id: filePickerPage
|
||||
FilePickerPage {
|
||||
id: documentPickerPage
|
||||
DocumentPickerPage {
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
Component.onCompleted: {
|
||||
var thingy = Qt.createComponent(ConvertChecker.calligra ? "../components/DocumentFilterOffice.notqml" : "../components/DocumentFilter.notqml");
|
||||
if (thingy.status == Component.Ready) {
|
||||
_contentModel.contentFilter = thingy.createObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
title: qsTr("Choose file")
|
||||
showSystemFiles: false
|
||||
nameFilters: ["*.pdf", "*.jpg", "*.jpeg", "*.ps"]
|
||||
|
||||
onSelectedContentPropertiesChanged: {
|
||||
page.selectedFile = selectedContentProperties.filePath
|
||||
page.selectedFileType = Mimer.get_type(selectedContentProperties.filePath)
|
||||
appWin.openFile(selectedContentProperties.filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -333,8 +459,7 @@ Page {
|
|||
allowedOrientations: Orientation.All
|
||||
|
||||
onSelectedContentPropertiesChanged: {
|
||||
page.selectedFile = selectedContentProperties.filePath
|
||||
page.selectedFileType = Mimer.get_type(selectedContentProperties.filePath)
|
||||
appWin.openFile(selectedContentProperties.filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import "utils.js" as Utils
|
||||
|
||||
|
@ -10,7 +10,6 @@ Page {
|
|||
|
||||
Component.onCompleted: {
|
||||
printer.getJobs()
|
||||
console.log(JSON.stringify(printer.jobs))
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
@ -37,7 +36,6 @@ Page {
|
|||
MenuItem {
|
||||
text: qsTr("Refresh")
|
||||
onClicked: {
|
||||
console.log(JSON.stringify(printer.jobs))
|
||||
printer.getJobs();
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +49,7 @@ Page {
|
|||
|
||||
header: PageHeader {
|
||||
id: pageHeader
|
||||
title: printer.attrs["printer-name"].value
|
||||
title: Utils.unknownForEmptyString(printer.attrs["printer-name"].value)
|
||||
description: printer.jobs.length==1 ? printer.jobs.length+" "+qsTr("job") : printer.jobs.length+" "+qsTr("jobs")
|
||||
}
|
||||
|
||||
|
@ -64,7 +62,6 @@ Page {
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: Theme.highlightColor
|
||||
text: printer.jobs[index]["job-id"].value
|
||||
Component.onCompleted: console.log(JSON.stringify(printer.jobs))
|
||||
}
|
||||
|
||||
Column {
|
||||
|
@ -73,7 +70,6 @@ Page {
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
Label {
|
||||
text: printer.jobs[index]["job-name"] ? printer.jobs[index]["job-name"].value : qsTr("Untitled job")
|
||||
Component.onCompleted: console.log(JSON.stringify(printer.jobs))
|
||||
}
|
||||
Label {
|
||||
font.pixelSize: Theme.fontSizeTiny
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import seaprint.convertchecker 1.0
|
||||
|
||||
import "../components"
|
||||
|
||||
Page {
|
||||
allowedOrientations: Orientation.All
|
||||
backNavigation: false
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: col.implicitHeight
|
||||
|
||||
Column {
|
||||
id:col
|
||||
y: Theme.paddingLarge
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width - 2*Theme.paddingLarge
|
||||
|
@ -14,17 +22,18 @@ Page {
|
|||
Label {
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
font.bold: true
|
||||
|
||||
text: qsTr("Optional dependencies are not installed!")
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: appWin.expectCalligra
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
|
||||
text: qsTr("In order to print PDF files with printers that do not support PDF natively,"
|
||||
+" you need the package \"poppler-utils\"."
|
||||
+" This enables SeaPrint to convert to formats that are more likely to be accepted.")
|
||||
text: qsTr("In order to print \"office\" documents like odt and doc(x) you need "+
|
||||
"\"calligraconverter\" from the \"calligra\" package (version 3.2.1+, Sailfish OS 4.2).")
|
||||
}
|
||||
|
||||
Label {
|
||||
|
@ -52,21 +61,33 @@ Page {
|
|||
}
|
||||
|
||||
Label {
|
||||
visible: appWin.expectCalligra
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
|
||||
text: qsTr("Install poppler-utils:")
|
||||
text: qsTr("Install Calligra:") + " " + (ConvertChecker.calligra ? qsTr("(done)") : "")
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: appWin.expectCalligra
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
font.family: "monospace"
|
||||
|
||||
text: "pkcon install poppler-utils"
|
||||
text: "pkcon install calligra"
|
||||
Clipper {}
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: appWin.expectCalligra
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
|
||||
text: qsTr("If you are still seeing this message despite installing Calligra, that can be because of SailJail "+
|
||||
"in Sailfish OS 4.x before the compatibility permission in 4.4. " +
|
||||
"You can either upgrade to 4.4 or edit out the SailJail section in /usr/share/applications/harbour-seaprint.desktop")
|
||||
}
|
||||
|
||||
Item{
|
||||
width: parent.width
|
||||
height: Theme.itemSizeMedium
|
||||
|
@ -86,6 +107,12 @@ Page {
|
|||
pageStack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
Item{
|
||||
width: parent.width
|
||||
height: Theme.itemSizeMedium
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,161 +1,230 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
import seaprint.mimer 1.0
|
||||
import seaprint.ippmsg 1.0
|
||||
import seaprint.convertchecker 1.0
|
||||
import "utils.js" as Utils
|
||||
import "../components"
|
||||
|
||||
Page {
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
id: page
|
||||
property var printer
|
||||
property var jobParams: new Object();
|
||||
property string selectedFile
|
||||
property alias printer: settingsColumn.printer
|
||||
property alias jobParams: settingsColumn.jobParams
|
||||
property alias selectedFile: settingsColumn.selectedFile
|
||||
property alias selectedFileType: settingsColumn.selectedFileType
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log(JSON.stringify(printer.attrs))
|
||||
Connections {
|
||||
target: wifi
|
||||
onConnectedChanged: {
|
||||
if(!wifi.connected) {
|
||||
pageStack.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: printer
|
||||
onAttrsChanged: {
|
||||
if(Object.keys(printer.attrs).length === 0) {
|
||||
pageStack.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// To enable PullDownMenu, place our content in a SilicaFlickable
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
anchors.fill: parent
|
||||
contentHeight: settingsColumn.height
|
||||
|
||||
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Print")
|
||||
onClicked: {
|
||||
console.log(JSON.stringify(jobParams))
|
||||
pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer},
|
||||
PageStackAction.Immediate)
|
||||
printer.print(jobParams, page.selectedFile,
|
||||
alwaysConvertSetting.value,
|
||||
removeRedundantConvertAttrsSetting.value,
|
||||
alwaysUseMediaColSetting.value)
|
||||
}
|
||||
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
|
||||
PullDownMenu {
|
||||
|
||||
MenuLabel {
|
||||
text: qsTr("Default settings for %1 on this printer").arg(db.simplifyType(selectedFileType).translatable)
|
||||
visible: printer.attrs.hasOwnProperty("printer-uuid")
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("Reset default settings")
|
||||
visible: printer.attrs.hasOwnProperty("printer-uuid")
|
||||
onClicked: {
|
||||
db.removeJobSettings(printer.attrs["printer-uuid"].value, selectedFileType);
|
||||
pageStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
ListModel {
|
||||
id:mod
|
||||
ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: IppMsg.Enum}
|
||||
ListElement {name: "media"; prettyName: qsTr("Print media"); tag: IppMsg.Keyword}
|
||||
ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: IppMsg.Integer}
|
||||
ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: IppMsg.IntegerRange}
|
||||
ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: IppMsg.Enum}
|
||||
// ListElement {name: "orientation-requested"; prettyName: qsTr("Orientation"); tag: IppMsg.Enum}
|
||||
ListElement {name: "print-quality"; prettyName: qsTr("Quality"); tag: IppMsg.Enum}
|
||||
ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: IppMsg.Resolution}
|
||||
ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: IppMsg.MimeMediaType}
|
||||
ListElement {name: "media-source"; prettyName: qsTr("Media source"); tag: IppMsg.Keyword}
|
||||
ListElement {name: "media-col"; prettyName: qsTr("Zero margins"); tag: IppMsg.BeginCollection}
|
||||
MenuItem {
|
||||
text: qsTr("Save as default settings")
|
||||
visible: printer.attrs.hasOwnProperty("printer-uuid")
|
||||
onClicked: {
|
||||
var tmp = jobParams;
|
||||
// Varies between documents, would be confusing to save
|
||||
delete tmp["page-ranges"];
|
||||
db.setJobSettings(printer.attrs["printer-uuid"].value, selectedFileType, JSON.stringify(tmp))
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("Print")
|
||||
onClicked: {
|
||||
pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer},
|
||||
PageStackAction.Immediate)
|
||||
printer.print(jobParams, page.selectedFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SilicaListView {
|
||||
id: listView
|
||||
model: mod
|
||||
clip: true
|
||||
VerticalScrollDecorator {}
|
||||
|
||||
anchors.fill: parent
|
||||
SettingsColumn {
|
||||
id: settingsColumn
|
||||
width: parent.width
|
||||
header: PageHeader {
|
||||
|
||||
PageHeader {
|
||||
id: pageHeader
|
||||
title: printer.attrs["printer-name"].value
|
||||
description: selectedFile
|
||||
|
||||
title: Utils.unknownForEmptyString(printer.attrs["printer-name"].value)
|
||||
description: Utils.basename(selectedFile)
|
||||
}
|
||||
|
||||
|
||||
|
||||
delegate: ListItem {
|
||||
id: delegate
|
||||
property alias loaderItem: loader.item
|
||||
|
||||
openMenuOnPressAndHold: false
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
anchors.fill: parent
|
||||
|
||||
onLoaded: {
|
||||
delegate.visible = true
|
||||
if(loaderItem.menu.enabled)
|
||||
{
|
||||
menu = loaderItem.menu
|
||||
loaderItem.clicked.connect(openMenu)
|
||||
}
|
||||
loaderItem.choiceMade.connect(function(tag, choice) {
|
||||
console.log("choice changed", tag, JSON.stringify(choice))
|
||||
if(choice != undefined)
|
||||
{
|
||||
jobParams[name] = {tag: tag, value: choice};
|
||||
}
|
||||
else
|
||||
{
|
||||
jobParams[name] = undefined
|
||||
}
|
||||
console.log(JSON.stringify(jobParams));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
switch(tag) {
|
||||
case IppMsg.Integer:
|
||||
var valid = printer.attrs.hasOwnProperty(name+"-supported")
|
||||
loader.setSource("../components/IntegerSetting.qml",
|
||||
{name: name,
|
||||
prettyName: prettyName,
|
||||
tag: tag,
|
||||
valid: valid,
|
||||
low: valid ? printer.attrs[name+"-supported"].value.low : 0,
|
||||
high: valid ? printer.attrs[name+"-supported"].value.high : 0,
|
||||
default_choice: printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : undefined
|
||||
})
|
||||
break
|
||||
case IppMsg.IntegerRange:
|
||||
var valid = printer.attrs.hasOwnProperty(name+"-supported") &&
|
||||
name=="page-ranges" && Mimer.get_type(selectedFile) == "application/pdf";
|
||||
var pdfpages = ConvertChecker.pdfPages(selectedFile);
|
||||
loader.setSource("../components/RangeSetting.qml",
|
||||
{name: name,
|
||||
prettyName: prettyName,
|
||||
tag: tag,
|
||||
valid: valid,
|
||||
high: name=="page-ranges" ? (pdfpages == 0 ? 65535 : pdfpages) : 0
|
||||
})
|
||||
break
|
||||
case IppMsg.Resolution:
|
||||
case IppMsg.Enum:
|
||||
case IppMsg.Keyword:
|
||||
case IppMsg.MimeMediaType:
|
||||
var valid = printer.attrs.hasOwnProperty(name+"-supported")
|
||||
loader.setSource("../components/ChoiceSetting.qml",
|
||||
{name: name,
|
||||
prettyName: prettyName,
|
||||
tag: tag,
|
||||
valid: valid,
|
||||
choices: valid ? printer.attrs[name+"-supported"].value : [],
|
||||
default_choice: printer.attrs.hasOwnProperty(name+"-default") ? printer.attrs[name+"-default"].value : "",
|
||||
mime_type: Mimer.get_type(selectedFile)
|
||||
})
|
||||
break
|
||||
case IppMsg.BeginCollection:
|
||||
loader.setSource("../components/MediaColSetting.qml",
|
||||
{name: name,
|
||||
prettyName: prettyName,
|
||||
tag: tag,
|
||||
valid: false,
|
||||
printer: printer
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
ChoiceSetting {
|
||||
tag: IppMsg.Keyword
|
||||
name: "sides"
|
||||
prettyName: qsTr("Sides")
|
||||
}
|
||||
ChoiceSetting {
|
||||
tag: IppMsg.Keyword
|
||||
name: "media"
|
||||
prettyName: qsTr("Print media")
|
||||
preferred_choices: printer.attrs.hasOwnProperty("media-ready") ? printer.attrs["media-ready"].value : []
|
||||
preferred_choice_suffix: qsTr("(loaded)")
|
||||
}
|
||||
IntegerSetting {
|
||||
tag: IppMsg.Integer
|
||||
name: "copies"
|
||||
prettyName: qsTr("Copies")
|
||||
valid: _valid || Utils.supports_raster(printer)
|
||||
minimum_high: 99
|
||||
}
|
||||
ChoiceSetting {
|
||||
tag: IppMsg.Keyword
|
||||
name: "multiple-document-handling"
|
||||
prettyName: qsTr("Collated copies")
|
||||
}
|
||||
RangeSetting {
|
||||
tag: IppMsg.IntegerRange
|
||||
name: "page-ranges"
|
||||
prettyName: qsTr("Page range")
|
||||
valid: (selectedFileType == Mimer.PDF || Mimer.isOffice(selectedFileType) || (_valid && selectedFileType == Mimer.Postscript))
|
||||
|
||||
property var pdfpages: ConvertChecker.pdfPages(selectedFile)
|
||||
high: pdfpages == 0 ? 65535 : pdfpages
|
||||
acceptRangeList: true
|
||||
}
|
||||
ChoiceSetting {
|
||||
tag: IppMsg.Integer
|
||||
name: "number-up"
|
||||
prettyName: qsTr("Pages per page")
|
||||
valid: _valid && !Mimer.isImage(selectedFileType)
|
||||
DependentOn {
|
||||
target: transferFormatSetting
|
||||
values: [Mimer.PDF, Mimer.Postscript]
|
||||
}
|
||||
}
|
||||
ChoiceSetting {
|
||||
tag: IppMsg.Keyword
|
||||
name: "print-color-mode"
|
||||
prettyName: qsTr("Color mode")
|
||||
}
|
||||
ChoiceSetting {
|
||||
tag: IppMsg.Enum
|
||||
name: "print-quality"
|
||||
prettyName: qsTr("Quality")
|
||||
}
|
||||
ChoiceSetting {
|
||||
tag: IppMsg.Resolution
|
||||
name: "printer-resolution"
|
||||
prettyName: qsTr("Resolution")
|
||||
}
|
||||
ChoiceSetting {
|
||||
tag: IppMsg.Keyword
|
||||
name: "print-scaling"
|
||||
prettyName: qsTr("Scaling")
|
||||
valid: _valid && Mimer.isImage(selectedFileType) && selectedFileType != Mimer.SVG
|
||||
DependentOn {
|
||||
target: transferFormatSetting
|
||||
values: [Mimer.JPEG, Mimer.PNG]
|
||||
}
|
||||
}
|
||||
ChoiceSetting {
|
||||
id: transferFormatSetting
|
||||
tag: IppMsg.MimeMediaType
|
||||
name: "document-format"
|
||||
prettyName: qsTr("Transfer format")
|
||||
}
|
||||
|
||||
BarButton {
|
||||
id: mediaButton
|
||||
text: qsTr("Media handling")
|
||||
}
|
||||
ChoiceSetting {
|
||||
visible: mediaButton.active
|
||||
tag: IppMsg.Keyword
|
||||
name: "media-type"
|
||||
subkey: "media-col"
|
||||
prettyName: qsTr("Media type")
|
||||
}
|
||||
ChoiceSetting {
|
||||
visible: mediaButton.active
|
||||
tag: IppMsg.Keyword
|
||||
name: "media-source"
|
||||
subkey: "media-col"
|
||||
prettyName: qsTr("Media source")
|
||||
}
|
||||
ChoiceSetting {
|
||||
visible: mediaButton.active
|
||||
tag: IppMsg.Keyword
|
||||
name: "output-bin"
|
||||
prettyName: qsTr("Output bin")
|
||||
}
|
||||
|
||||
BarButton {
|
||||
id: marginsButton
|
||||
text: qsTr("Margins")
|
||||
}
|
||||
ChoiceSetting {
|
||||
visible: marginsButton.active
|
||||
tag: IppMsg.Integer
|
||||
name: "media-top-margin"
|
||||
subkey: "media-col"
|
||||
prettyName: qsTr("Top")
|
||||
valid: _valid && Mimer.isImage(selectedFileType)
|
||||
}
|
||||
ChoiceSetting {
|
||||
visible: marginsButton.active
|
||||
tag: IppMsg.Integer
|
||||
name: "media-bottom-margin"
|
||||
subkey: "media-col"
|
||||
prettyName: qsTr("Bottom")
|
||||
valid: _valid && Mimer.isImage(selectedFileType)
|
||||
}
|
||||
ChoiceSetting {
|
||||
visible: marginsButton.active
|
||||
tag: IppMsg.Integer
|
||||
name: "media-left-margin"
|
||||
subkey: "media-col"
|
||||
prettyName: qsTr("Left")
|
||||
valid: _valid && Mimer.isImage(selectedFileType)
|
||||
}
|
||||
ChoiceSetting {
|
||||
visible: marginsButton.active
|
||||
tag: IppMsg.Integer
|
||||
name: "media-right-margin"
|
||||
subkey: "media-col"
|
||||
prettyName: qsTr("Right")
|
||||
valid: _valid && Mimer.isImage(selectedFileType)
|
||||
}
|
||||
VerticalScrollDecorator {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Page {
|
||||
|
@ -45,32 +45,31 @@ Page {
|
|||
}
|
||||
|
||||
TextSwitch {
|
||||
text: qsTr("Always convert to raster format")
|
||||
description: qsTr("Force conversion to PWG/URF raster format. This is mainly intended for testing.")
|
||||
checked: alwaysConvertSetting.value
|
||||
text: qsTr("Ignore SSL errors")
|
||||
description: qsTr("In order to work with self-signed certificates of printers and CUPS instances, SSL errors needs to be ignored.")
|
||||
checked: ignoreSslErrorsSetting.value
|
||||
onCheckedChanged: {
|
||||
alwaysConvertSetting.value = checked
|
||||
ignoreSslErrorsSetting.value = checked
|
||||
}
|
||||
}
|
||||
|
||||
TextSwitch {
|
||||
text: qsTr("Remove redundant attributes")
|
||||
description: qsTr("Remove redundant IPP attributes, if they are also conveyed in the transfer format. Some printers reject the job even if the settings are consistent.")
|
||||
checked: removeRedundantConvertAttrsSetting.value
|
||||
text: qsTr("Enable debug log")
|
||||
description: qsTr("Print debug log messages to console (if launched from there) or journal if launched normally. Takes effect on app (re-)start.")
|
||||
checked: debugLogSetting.value
|
||||
onCheckedChanged: {
|
||||
removeRedundantConvertAttrsSetting.value = checked
|
||||
debugLogSetting.value = checked
|
||||
}
|
||||
}
|
||||
|
||||
TextSwitch {
|
||||
text: qsTr("Always use media-col")
|
||||
description: qsTr("Use the attribute media-col instead of media for paper sizes. I.e. do parametric selection of print media rather than by name. If you use zero print margins, parametric selection will be used regardless of this setting.")
|
||||
checked: alwaysUseMediaColSetting.value
|
||||
text: qsTr("Allow external connections")
|
||||
description: qsTr("Allow SeaPrint to fetch recources like icons and option name dictionaries from addresses that are not the printer itself. Some printer makers store icons on their website as opposed to locally on the printer.")
|
||||
checked: allowExternalConnectionsSetting.value
|
||||
onCheckedChanged: {
|
||||
alwaysUseMediaColSetting.value = checked
|
||||
allowExternalConnectionsSetting.value = checked
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
BIN
qml/pages/icon-seaprint-nobg-bw.png
Normal file
BIN
qml/pages/icon-seaprint-nobg-bw.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
|
@ -12,11 +12,11 @@
|
|||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 86 86"
|
||||
style="enable-background:new 0 0 86 86;"
|
||||
viewBox="0 0 344 344"
|
||||
style="enable-background:new 0 0 344 344;"
|
||||
xml:space="preserve"
|
||||
id="svg82"
|
||||
sodipodi:docname="icon-seaprint-nobg-bw.svg"
|
||||
sodipodi:docname="icon-seaprint-nobg.svg"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)"><metadata
|
||||
id="metadata88"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
|
@ -26,26 +26,7 @@
|
|||
inkscape:label="Greyscale"
|
||||
id="filter1011"><feColorMatrix
|
||||
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.26 0.21 0.69 -0.26 0 "
|
||||
id="feColorMatrix1009" /></filter></defs><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1408"
|
||||
inkscape:window-height="1167"
|
||||
id="namedview84"
|
||||
showgrid="false"
|
||||
inkscape:zoom="2.744186"
|
||||
inkscape:cx="43"
|
||||
inkscape:cy="43"
|
||||
inkscape:window-x="1962"
|
||||
inkscape:window-y="599"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg82" />
|
||||
id="feColorMatrix1009" /></filter></defs>
|
||||
<style
|
||||
type="text/css"
|
||||
id="style2">
|
||||
|
@ -63,6 +44,8 @@
|
|||
.st11{fill:url(#SVGID_10_);}
|
||||
</style>
|
||||
|
||||
<g transform="scale(4)">
|
||||
|
||||
<g
|
||||
id="Слой_3"
|
||||
class="st1">
|
||||
|
@ -272,4 +255,5 @@
|
|||
d="M65,59.2H21c-1.1,0-2-0.9-2-2V-2.6c0-1.1,0.9-2,2-2h44c1.1,0,2,0.9,2,2v59.9C67,58.3,66.1,59.2,65,59.2z"
|
||||
id="path79" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 5.7 KiB |
|
@ -21,26 +21,7 @@
|
|||
id="metadata88"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs86" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1408"
|
||||
inkscape:window-height="1167"
|
||||
id="namedview84"
|
||||
showgrid="false"
|
||||
inkscape:zoom="2.744186"
|
||||
inkscape:cx="43"
|
||||
inkscape:cy="43"
|
||||
inkscape:window-x="1899"
|
||||
inkscape:window-y="502"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg82" />
|
||||
id="defs86" />
|
||||
<style
|
||||
type="text/css"
|
||||
id="style2">
|
||||
|
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.4 KiB |
1148
qml/pages/strings.js
Normal file
1148
qml/pages/strings.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,10 @@
|
|||
function supported_formats(printer, ConvertChecker, considerAdditionalFormats)
|
||||
.pragma library
|
||||
.import seaprint.mimer 1.0 as Mimer
|
||||
.import seaprint.convertchecker 1.0 as ConvertChecker
|
||||
.import "strings.js" as Strings
|
||||
|
||||
// TODO move to IppPrinter?
|
||||
function supported_formats(printer, considerAdditionalFormats)
|
||||
{
|
||||
var formats = printer.attrs["document-format-supported"].value;
|
||||
if(considerAdditionalFormats)
|
||||
|
@ -6,34 +12,65 @@ function supported_formats(printer, ConvertChecker, considerAdditionalFormats)
|
|||
formats=formats+printer.additionalDocumentFormats;
|
||||
}
|
||||
|
||||
var raster = (has(formats, "image/pwg-raster") || has(formats, "image/urf"));
|
||||
var raster = (has(formats, Mimer.Mimer.PWG) || has(formats, Mimer.Mimer.URF));
|
||||
|
||||
var mimetypes = [];
|
||||
var supported = [];
|
||||
if(has(formats, "application/pdf") ||
|
||||
(ConvertChecker.pdf && ( has(formats, "application/postscript") || raster )))
|
||||
{
|
||||
mimetypes.push("application/pdf");
|
||||
supported.push("PDF");
|
||||
}
|
||||
if(has(formats, "application/postscript"))
|
||||
{
|
||||
mimetypes.push("application/postscript");
|
||||
supported.push("Postscript");
|
||||
}
|
||||
var pdf = false;
|
||||
var postscript = false;
|
||||
var office = false;
|
||||
var images = false;
|
||||
var plaintext = false;
|
||||
|
||||
if (raster || has(formats, "image/jpeg"))
|
||||
{
|
||||
mimetypes.push("image/jpeg");
|
||||
supported.push("JPEG");
|
||||
}
|
||||
if(raster || has(formats, "image/png"))
|
||||
{
|
||||
mimetypes.push("image/png");
|
||||
supported.push("PNG");
|
||||
}
|
||||
if(has(formats, Mimer.Mimer.PDF) ||
|
||||
(has(formats, Mimer.Mimer.Postscript) || raster ))
|
||||
{
|
||||
pdf = true;
|
||||
mimetypes.push(Mimer.Mimer.PDF);
|
||||
}
|
||||
|
||||
return {supported: supported.join(" "), mimetypes: mimetypes};
|
||||
if(has(formats, Mimer.Mimer.Postscript))
|
||||
{
|
||||
postscript = true;
|
||||
mimetypes.push(Mimer.Mimer.Postscript);
|
||||
}
|
||||
|
||||
if(pdf || has(formats, Mimer.Mimer.Plaintext))
|
||||
{
|
||||
plaintext = true;
|
||||
mimetypes.push(Mimer.Mimer.Plaintext);
|
||||
}
|
||||
|
||||
if((ConvertChecker.ConvertChecker.calligra) && pdf)
|
||||
{
|
||||
office = true;
|
||||
mimetypes = mimetypes.concat(Mimer.Mimer.OfficeFormats);
|
||||
}
|
||||
|
||||
if(pdf || has(formats, Mimer.Mimer.JPEG) || has(formats, Mimer.Mimer.PNG) || has(formats, Mimer.Mimer.RBMP))
|
||||
{
|
||||
images = true;
|
||||
mimetypes.push(Mimer.Mimer.JPEG);
|
||||
mimetypes.push(Mimer.Mimer.PNG);
|
||||
mimetypes.push(Mimer.Mimer.TIFF);
|
||||
mimetypes.push(Mimer.Mimer.GIF);
|
||||
}
|
||||
|
||||
if(pdf)
|
||||
{
|
||||
mimetypes.push(Mimer.Mimer.SVG);
|
||||
}
|
||||
|
||||
return {pdf: pdf, postscript: postscript, plaintext: plaintext, office: office, images: images, mimetypes: mimetypes};
|
||||
}
|
||||
|
||||
function supports_raster(printer)
|
||||
{
|
||||
var formats = printer.attrs["document-format-supported"].value;
|
||||
if(considerAdditionalFormats)
|
||||
{
|
||||
formats=formats+printer.additionalDocumentFormats;
|
||||
}
|
||||
return (has(formats, Mimer.Mimer.PWG) || has(formats, Mimer.Mimer.URF));
|
||||
}
|
||||
|
||||
function has(arrayish, what)
|
||||
|
@ -41,8 +78,13 @@ function has(arrayish, what)
|
|||
return arrayish.indexOf(what) != -1;
|
||||
}
|
||||
|
||||
function ippName(name, value)
|
||||
function ippName(name, value, printerStrings)
|
||||
{
|
||||
if(value==undefined)
|
||||
{
|
||||
return ""
|
||||
}
|
||||
|
||||
switch(name) {
|
||||
case "job-state":
|
||||
switch(value) {
|
||||
|
@ -63,6 +105,17 @@ function ippName(name, value)
|
|||
default:
|
||||
return qsTr("unknown state ")+value
|
||||
}
|
||||
case "printer-state":
|
||||
switch(value) {
|
||||
case 3:
|
||||
return qsTr("Idle");
|
||||
case 4:
|
||||
return qsTr("Processing");
|
||||
case 5:
|
||||
return qsTr("Stopped");
|
||||
default:
|
||||
return qsTr("Unknown State ")+value
|
||||
}
|
||||
case "print-quality":
|
||||
switch(value) {
|
||||
case 3:
|
||||
|
@ -96,9 +149,43 @@ function ippName(name, value)
|
|||
}
|
||||
return ""+value.x+"x"+value.y+units;
|
||||
case "media":
|
||||
if(media.hasOwnProperty(value))
|
||||
if(Strings.media.hasOwnProperty(value))
|
||||
{
|
||||
return media[value];
|
||||
return Strings.media[value];
|
||||
}
|
||||
else
|
||||
{
|
||||
return value;
|
||||
}
|
||||
case "media-type":
|
||||
if(Strings.mediaType.hasOwnProperty(value))
|
||||
{
|
||||
return Strings.mediaType[value];
|
||||
}
|
||||
else if(printerStrings != undefined && printerStrings.hasOwnProperty("media-type."+value))
|
||||
{
|
||||
return printerStrings["media-type."+value];
|
||||
}
|
||||
else
|
||||
{
|
||||
return value;
|
||||
}
|
||||
case "printer-state-reasons":
|
||||
if(Strings.printerStateReasons.hasOwnProperty(value))
|
||||
{
|
||||
return Strings.printerStateReasons[value];
|
||||
}
|
||||
else if (endsWith("-report", value))
|
||||
{
|
||||
return ippName(name, value.substr(0, value.length-"-report".length))+" (" + qsTr("Report") + ")"
|
||||
}
|
||||
else if (endsWith("-warning", value))
|
||||
{
|
||||
return ippName(name, value.substr(0, value.length-"-warning".length))+" (" + qsTr("Warning") + ")"
|
||||
}
|
||||
else if (endsWith("-error", value))
|
||||
{
|
||||
return ippName(name, value.substr(0, value.length-"-error".length))+" (" + qsTr("Error") + ")"
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -115,6 +202,20 @@ function ippName(name, value)
|
|||
default:
|
||||
return value
|
||||
}
|
||||
case "multiple-document-handling":
|
||||
switch(value) {
|
||||
case "single-document":
|
||||
return qsTr("single document");
|
||||
case "separate-documents-uncollated-copies":
|
||||
return qsTr("uncollated");
|
||||
case "separate-documents-collated-copies":
|
||||
return qsTr("collated");
|
||||
case "single-document-new-sheet":
|
||||
return qsTr("single document (new sheet)");
|
||||
default:
|
||||
return value
|
||||
}
|
||||
|
||||
case "print-color-mode":
|
||||
switch(value) {
|
||||
case "auto":
|
||||
|
@ -136,45 +237,92 @@ function ippName(name, value)
|
|||
default:
|
||||
return value
|
||||
}
|
||||
case "document-format":
|
||||
case "print-scaling":
|
||||
switch(value) {
|
||||
case "application/octet-stream":
|
||||
return qsTr("auto-sense");
|
||||
case "application/pdf":
|
||||
return qsTr("PDF");
|
||||
case "application/postscript":
|
||||
return qsTr("Postscript");
|
||||
case "image/pwg-raster":
|
||||
return qsTr("PWG-raster");
|
||||
case "image/urf":
|
||||
return qsTr("URF-raster");
|
||||
case "image/png":
|
||||
return qsTr("PNG");
|
||||
case "image/jpeg":
|
||||
return qsTr("JPEG");
|
||||
case "image/gif":
|
||||
return qsTr("GIF");
|
||||
case "auto":
|
||||
return qsTr("auto");
|
||||
case "auto-fit":
|
||||
return qsTr("auto (fit)");
|
||||
case "fill":
|
||||
return qsTr("fill");
|
||||
case "fit":
|
||||
return qsTr("fit");
|
||||
case "none":
|
||||
return qsTr("none");
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
|
||||
case "document-format":
|
||||
switch(value) {
|
||||
case Mimer.Mimer.OctetStream:
|
||||
return qsTr("auto-sense");
|
||||
case Mimer.Mimer.PDF:
|
||||
return qsTr("PDF");
|
||||
case Mimer.Mimer.Postscript:
|
||||
return qsTr("Postscript");
|
||||
case Mimer.Mimer.Plaintext:
|
||||
return qsTr("Plaintext");
|
||||
case Mimer.Mimer.PWG:
|
||||
return qsTr("PWG-raster");
|
||||
case Mimer.Mimer.URF:
|
||||
return qsTr("URF-raster");
|
||||
case Mimer.Mimer.PNG:
|
||||
return qsTr("PNG");
|
||||
case Mimer.Mimer.JPEG:
|
||||
return qsTr("JPEG");
|
||||
case Mimer.Mimer.GIF:
|
||||
return qsTr("GIF");
|
||||
case Mimer.Mimer.SVG:
|
||||
return qsTr("SVG");
|
||||
case Mimer.Mimer.RBMP:
|
||||
return qsTr("Reverse BMP");
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
case "media-top-margin":
|
||||
case "media-bottom-margin":
|
||||
case "media-left-margin":
|
||||
case "media-right-margin":
|
||||
return ""+(value/100)+"mm"
|
||||
case "media-source":
|
||||
if(value.indexOf("tray-")==0)
|
||||
{
|
||||
return qsTr("tray")+" "+value.split("-")[1];
|
||||
}
|
||||
else if(value.indexOf("roll-")==0)
|
||||
{
|
||||
return qsTr("roll")+" "+value.split("-")[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(value) {
|
||||
case "by-pass-tray":
|
||||
return qsTr("by-pass tray");
|
||||
case "alternate":
|
||||
return qsTr("alternate");
|
||||
case "alternate-roll":
|
||||
return qsTr("alternate-roll");
|
||||
case "auto":
|
||||
return qsTr("automatic");
|
||||
case "bottom":
|
||||
return qsTr("bottom");
|
||||
case "by-pass-tray":
|
||||
return qsTr("by-pass tray");
|
||||
case "center":
|
||||
return qsTr("center");
|
||||
case "disc":
|
||||
return qsTr("disc");
|
||||
case "envelope":
|
||||
return qsTr("envelope");
|
||||
case "hagaki":
|
||||
return qsTr("hagaki");
|
||||
case "large-capacity":
|
||||
return qsTr("large capacity");
|
||||
case "left":
|
||||
return qsTr("left");
|
||||
case "main":
|
||||
return qsTr("main");
|
||||
case "main-roll":
|
||||
return qsTr("main roll");
|
||||
case "manual":
|
||||
return qsTr("manual");
|
||||
case "middle":
|
||||
|
@ -193,6 +341,52 @@ function ippName(name, value)
|
|||
return value;
|
||||
}
|
||||
}
|
||||
case "output-bin":
|
||||
if(value.indexOf("tray-")==0)
|
||||
{
|
||||
return qsTr("tray")+" "+value.split("-")[1];
|
||||
}
|
||||
else if(value.indexOf("stacker-")==0)
|
||||
{
|
||||
return qsTr("stacker")+" "+value.split("-")[1];
|
||||
}
|
||||
else if(value.indexOf("mailbox-")==0)
|
||||
{
|
||||
return qsTr("mailbox")+" "+value.split("-")[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(value) {
|
||||
case "auto":
|
||||
return qsTr("automatic");
|
||||
case "top":
|
||||
return qsTr("top");
|
||||
case "middle":
|
||||
return qsTr("middle");
|
||||
case "bottom":
|
||||
return qsTr("bottom");
|
||||
case "side":
|
||||
return qsTr("side");
|
||||
case "left":
|
||||
return qsTr("left");
|
||||
case "right":
|
||||
return qsTr("right");
|
||||
case "center":
|
||||
return qsTr("center");
|
||||
case "rear":
|
||||
return qsTr("rear");
|
||||
case "face-up":
|
||||
return qsTr("face-up");
|
||||
case "face-down":
|
||||
return qsTr("face-down");
|
||||
case "large-capacity":
|
||||
return qsTr("large capacity");
|
||||
case "my-mailbox":
|
||||
return qsTr("my mailbox");
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@ -202,21 +396,41 @@ function endsWith(ending, string)
|
|||
return string.lastIndexOf(ending) == (string.length - ending.length);
|
||||
}
|
||||
|
||||
var pdfTargets = [Mimer.Mimer.OctetStream, Mimer.Mimer.PDF, Mimer.Mimer.Postscript, Mimer.Mimer.PWG, Mimer.Mimer.URF];
|
||||
|
||||
|
||||
function canConvertPdfTo(type)
|
||||
{
|
||||
var targets = ["application/octet-stream", "application/pdf", "application/postscript", "image/pwg-raster", "image/urf"];
|
||||
return has(pdfTargets, type)
|
||||
}
|
||||
|
||||
function canTransferPostscriptAs(type)
|
||||
{
|
||||
var targets = [Mimer.Mimer.OctetStream, Mimer.Mimer.Postscript];
|
||||
return has(targets, type)
|
||||
}
|
||||
|
||||
function canTransferPdfAs(type)
|
||||
function canConvertPlaintextTo(type)
|
||||
{
|
||||
var targets = ["application/octet-stream", "application/pdf"];
|
||||
var targets = pdfTargets;
|
||||
targets.push(Mimer.Mimer.Plaintext);
|
||||
return has(targets, type)
|
||||
}
|
||||
|
||||
function canConvertOfficeDocumentTo(type)
|
||||
{
|
||||
return has(pdfTargets, type)
|
||||
}
|
||||
|
||||
function canConvertSvgTo(type)
|
||||
{
|
||||
return has(pdfTargets, type)
|
||||
}
|
||||
|
||||
function canConvertImageTo(type)
|
||||
{
|
||||
var targets = ["application/octet-stream", "image/jpeg", "image/png", "image/pwg-raster", "image/urf", "image/gif"];
|
||||
var targets = [Mimer.Mimer.OctetStream, Mimer.Mimer.JPEG, Mimer.Mimer.PNG, Mimer.Mimer.RBMP,
|
||||
Mimer.Mimer.PWG, Mimer.Mimer.URF, Mimer.Mimer.PDF, Mimer.Mimer.Postscript];
|
||||
return has(targets, type)
|
||||
}
|
||||
|
||||
|
@ -225,249 +439,128 @@ function unitsIsDpi(resolution)
|
|||
return resolution.units == 3;
|
||||
}
|
||||
|
||||
function knownPaperSize(mediaName)
|
||||
{
|
||||
return Strings.media.hasOwnProperty(mediaName);
|
||||
}
|
||||
|
||||
function limitChoices(name, choices, mimeType, ConvertChecker)
|
||||
|
||||
function fixupChoices(name, choices, mimeType, printer)
|
||||
{
|
||||
switch(name) {
|
||||
case "document-format":
|
||||
if(mimeType == "application/pdf")
|
||||
if(mimeType == Mimer.Mimer.PDF)
|
||||
{
|
||||
if(ConvertChecker.pdf)
|
||||
{
|
||||
return choices.filter(canConvertPdfTo)
|
||||
}
|
||||
else
|
||||
{
|
||||
return choices.filter(canTransferPdfAs)
|
||||
}
|
||||
|
||||
return choices.filter(canConvertPdfTo)
|
||||
}
|
||||
else if(mimeType == "image/jpeg" || mimeType == "image/png")
|
||||
else if(mimeType == Mimer.Mimer.Plaintext)
|
||||
{
|
||||
return choices.filter(canConvertPlaintextTo)
|
||||
}
|
||||
else if(mimeType == Mimer.Mimer.Postscript)
|
||||
{
|
||||
return choices.filter(canTransferPostscriptAs)
|
||||
}
|
||||
else if(Mimer.Mimer.isOffice(mimeType))
|
||||
{
|
||||
return choices.filter(canConvertOfficeDocumentTo)
|
||||
}
|
||||
else if(mimeType == Mimer.Mimer.SVG)
|
||||
{
|
||||
return choices.filter(canConvertSvgTo)
|
||||
}
|
||||
else if(Mimer.Mimer.isImage(mimeType))
|
||||
{
|
||||
return choices.filter(canConvertImageTo);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ["application/octet-stream"];
|
||||
return [Mimer.Mimer.OctetStream];
|
||||
}
|
||||
case "printer-resolution":
|
||||
return choices.filter(unitsIsDpi);
|
||||
case "multiple-document-handling" :
|
||||
// Only collation settings valid, multiple documents not used
|
||||
return choices.filter(function(elem) {return elem.indexOf("collated") != -1});
|
||||
case "number-up":
|
||||
if(choices.constructor.name === "Object")
|
||||
{
|
||||
var choice_array = [];
|
||||
for(var i=choices.low; i <= choices.high; i++)
|
||||
{
|
||||
choice_array.push(i);
|
||||
}
|
||||
return choice_array;
|
||||
}
|
||||
else
|
||||
{
|
||||
return choices;
|
||||
}
|
||||
case "media":
|
||||
if(printer.attrs.hasOwnProperty("media-ready"))
|
||||
{
|
||||
for(var m in printer.attrs["media-ready"].value)
|
||||
{
|
||||
var value = printer.attrs["media-ready"].value[m];
|
||||
if(!has(choices, value))
|
||||
{
|
||||
choices.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return choices;
|
||||
default:
|
||||
return choices;
|
||||
}
|
||||
}
|
||||
|
||||
function selectIcon(icons)
|
||||
function isWaringState(printer)
|
||||
{
|
||||
for(var i=0; i < icons.length; i++)
|
||||
if(printer.attrs["printer-state"].value > 4)
|
||||
{
|
||||
if(endsWith("M.png", icons[i]) || endsWith("128x128.png", icons[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
if(printer.attrs.hasOwnProperty("printer-state-reasons"))
|
||||
{
|
||||
for(var i in printer.attrs["printer-state-reasons"].value)
|
||||
{
|
||||
return icons[i];
|
||||
var value = printer.attrs["printer-state-reasons"].value[i];
|
||||
if(value != "none" && !(endsWith("-report", value)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return icons[0];
|
||||
return false;
|
||||
}
|
||||
|
||||
var media =
|
||||
{"asme_f_28x40in": "28 x 40″",
|
||||
"choice_iso_a4_210x297mm_na_letter_8.5x11in": "A4 or US Letter",
|
||||
"iso_2a0_1189x1682mm": "2a0",
|
||||
"iso_a0_841x1189mm": "A0",
|
||||
"iso_a0x3_1189x2523mm": "A0x3",
|
||||
"iso_a10_26x37mm": "A10",
|
||||
"iso_a1_594x841mm": "A1",
|
||||
"iso_a1x3_841x1783mm": "A1x3",
|
||||
"iso_a1x4_841x2378mm": "A1x4",
|
||||
"iso_a2_420x594mm": "A2",
|
||||
"iso_a2x3_594x1261mm": "A2x3",
|
||||
"iso_a2x4_594x1682mm": "A2x4",
|
||||
"iso_a2x5_594x2102mm": "A2x5",
|
||||
"iso_a3-extra_322x445mm": "A3 (Extra)",
|
||||
"iso_a3_297x420mm": "A3",
|
||||
"iso_a3x3_420x891mm": "A3x3",
|
||||
"iso_a3x4_420x1189mm": "A3x4",
|
||||
"iso_a3x5_420x1486mm": "A3x5",
|
||||
"iso_a3x6_420x1783mm": "A3x6",
|
||||
"iso_a3x7_420x2080mm": "A3x7",
|
||||
"iso_a4-extra_235.5x322.3mm": "A4 (Extra)",
|
||||
"iso_a4-tab_225x297mm": "A4 (Tab)",
|
||||
"iso_a4_210x297mm": "A4",
|
||||
"iso_a4x3_297x630mm": "A4x3",
|
||||
"iso_a4x4_297x841mm": "A4x4",
|
||||
"iso_a4x5_297x1051mm": "A4x5",
|
||||
"iso_a4x6_297x1261mm": "A4x6",
|
||||
"iso_a4x7_297x1471mm": "A4x7",
|
||||
"iso_a4x8_297x1682mm": "A4x8",
|
||||
"iso_a4x9_297x1892mm": "A4x9",
|
||||
"iso_a5-extra_174x235mm": "A5 (Extra)",
|
||||
"iso_a5_148x210mm": "A5",
|
||||
"iso_a6_105x148mm": "A6",
|
||||
"iso_a7_74x105mm": "A7",
|
||||
"iso_a8_52x74mm": "A8",
|
||||
"iso_a9_37x52mm": "A9",
|
||||
"iso_b0_1000x1414mm": "B0",
|
||||
"iso_b10_31x44mm": "B10",
|
||||
"iso_b1_707x1000mm": "B1",
|
||||
"iso_b2_500x707mm": "B2",
|
||||
"iso_b3_353x500mm": "B3",
|
||||
"iso_b4_250x353mm": "B4",
|
||||
"iso_b5-extra_201x276mm": "B5 (Extra)",
|
||||
"iso_b5_176x250mm": "Envelope B5",
|
||||
"iso_b6_125x176mm": "B6",
|
||||
"iso_b6c4_125x324mm": "Envelope B6/C4",
|
||||
"iso_b7_88x125mm": "B7",
|
||||
"iso_b8_62x88mm": "B8",
|
||||
"iso_b9_44x62mm": "B9",
|
||||
"iso_c0_917x1297mm": "CEnvelope 0",
|
||||
"iso_c10_28x40mm": "CEnvelope 10",
|
||||
"iso_c1_648x917mm": "CEnvelope 1",
|
||||
"iso_c2_458x648mm": "CEnvelope 2",
|
||||
"iso_c3_324x458mm": "CEnvelope 3",
|
||||
"iso_c4_229x324mm": "CEnvelope 4",
|
||||
"iso_c5_162x229mm": "CEnvelope 5",
|
||||
"iso_c6_114x162mm": "CEnvelope 6",
|
||||
"iso_c6c5_114x229mm": "CEnvelope 6c5",
|
||||
"iso_c7_81x114mm": "CEnvelope 7",
|
||||
"iso_c7c6_81x162mm": "CEnvelope 7c6",
|
||||
"iso_c8_57x81mm": "CEnvelope 8",
|
||||
"iso_c9_40x57mm": "CEnvelope 9",
|
||||
"iso_dl_110x220mm": "Envelope DL",
|
||||
"iso_id-1_53.98x85.6mm": "Id-1",
|
||||
"iso_id-3_88x125mm": "Id-3",
|
||||
"iso_ra0_860x1220mm": "ISO RA0",
|
||||
"iso_ra1_610x860mm": "ISO RA1",
|
||||
"iso_ra2_430x610mm": "ISO RA2",
|
||||
"iso_ra3_305x430mm": "ISO RA3",
|
||||
"iso_ra4_215x305mm": "ISO RA4",
|
||||
"iso_sra0_900x1280mm": "ISO SRA0",
|
||||
"iso_sra1_640x900mm": "ISO SRA1",
|
||||
"iso_sra2_450x640mm": "ISO SRA2",
|
||||
"iso_sra3_320x450mm": "ISO SRA3",
|
||||
"iso_sra4_225x320mm": "ISO SRA4",
|
||||
"jis_b0_1030x1456mm": "JIS B0",
|
||||
"jis_b10_32x45mm": "JIS B10",
|
||||
"jis_b1_728x1030mm": "JIS B1",
|
||||
"jis_b2_515x728mm": "JIS B2",
|
||||
"jis_b3_364x515mm": "JIS B3",
|
||||
"jis_b4_257x364mm": "JIS B4",
|
||||
"jis_b5_182x257mm": "JIS B5",
|
||||
"jis_b6_128x182mm": "JIS B6",
|
||||
"jis_b7_91x128mm": "JIS B7",
|
||||
"jis_b8_64x91mm": "JIS B8",
|
||||
"jis_b9_45x64mm": "JIS B9",
|
||||
"jis_exec_216x330mm": "JIS Executive",
|
||||
"jpn_chou2_111.1x146mm": "Envelope Chou 2",
|
||||
"jpn_chou3_120x235mm": "Envelope Chou 3",
|
||||
"jpn_chou40_90x225mm": "Envelope Chou 40",
|
||||
"jpn_chou4_90x205mm": "Envelope Chou 4",
|
||||
"jpn_hagaki_100x148mm": "Hagaki",
|
||||
"jpn_kahu_240x322.1mm": "Envelope Kahu",
|
||||
"jpn_kaku1_270x382mm": "270 x 382mm",
|
||||
"jpn_kaku2_240x332mm": "Envelope Kahu 2",
|
||||
"jpn_kaku3_216x277mm": "216 x 277mm",
|
||||
"jpn_kaku4_197x267mm": "197 x 267mm",
|
||||
"jpn_kaku5_190x240mm": "190 x 240mm",
|
||||
"jpn_kaku7_142x205mm": "142 x 205mm",
|
||||
"jpn_kaku8_119x197mm": "119 x 197mm",
|
||||
"jpn_oufuku_148x200mm": "Oufuku Reply Postcard",
|
||||
"jpn_you4_105x235mm": "Envelope You 4",
|
||||
"na_10x11_10x11in": "10 x 11″",
|
||||
"na_10x13_10x13in": "10 x 13″",
|
||||
"na_10x14_10x14in": "10 x 14″",
|
||||
"na_10x15_10x15in": "10 x 15″",
|
||||
"na_11x12_11x12in": "11 x 12″",
|
||||
"na_11x15_11x15in": "11 x 15″",
|
||||
"na_12x19_12x19in": "12 x 19″",
|
||||
"na_5x7_5x7in": "5 x 7″",
|
||||
"na_6x9_6x9in": "6 x 9″",
|
||||
"na_7x9_7x9in": "7 x 9″",
|
||||
"na_9x11_9x11in": "9 x 11″",
|
||||
"na_a2_4.375x5.75in": "Envelope A2",
|
||||
"na_arch-a_9x12in": "9 x 12″",
|
||||
"na_arch-b_12x18in": "12 x 18″",
|
||||
"na_arch-c_18x24in": "18 x 24″",
|
||||
"na_arch-d_24x36in": "24 x 36″",
|
||||
"na_arch-e2_26x38in": "26 x 38″",
|
||||
"na_arch-e3_27x39in": "27 x 39″",
|
||||
"na_arch-e_36x48in": "36 x 48″",
|
||||
"na_b-plus_12x19.17in": "12 x 19.17″",
|
||||
"na_c5_6.5x9.5in": "Envelope C5",
|
||||
"na_c_17x22in": "17 x 22″",
|
||||
"na_d_22x34in": "22 x 34″",
|
||||
"na_e_34x44in": "34 x 44″",
|
||||
"na_edp_11x14in": "11 x 14″",
|
||||
"na_eur-edp_12x14in": "12 x 14″",
|
||||
"na_executive_7.25x10.5in": "Executive",
|
||||
"na_f_44x68in": "44 x 68″",
|
||||
"na_fanfold-eur_8.5x12in": "European Fanfold",
|
||||
"na_fanfold-us_11x14.875in": "US Fanfold",
|
||||
"na_foolscap_8.5x13in": "Foolscap",
|
||||
"na_govt-legal_8x13in": "8 x 13″",
|
||||
"na_govt-letter_8x10in": "8 x 10″",
|
||||
"na_index-3x5_3x5in": "3 x 5″",
|
||||
"na_index-4x6-ext_6x8in": "6 x 8″",
|
||||
"na_index-4x6_4x6in": "4 x 6″",
|
||||
"na_index-5x8_5x8in": "5 x 8″",
|
||||
"na_invoice_5.5x8.5in": "Statement",
|
||||
"na_ledger_11x17in": "11 x 17″",
|
||||
"na_legal-extra_9.5x15in": "US Legal (Extra)",
|
||||
"na_legal_8.5x14in": "US Legal",
|
||||
"na_letter-extra_9.5x12in": "US Letter (Extra)",
|
||||
"na_letter-plus_8.5x12.69in": "US Letter (Plus)",
|
||||
"na_letter_8.5x11in": "US Letter",
|
||||
"na_monarch_3.875x7.5in": "Envelope Monarch",
|
||||
"na_number-10_4.125x9.5in": "Envelope #10",
|
||||
"na_number-11_4.5x10.375in": "Envelope #11",
|
||||
"na_number-12_4.75x11in": "Envelope #12",
|
||||
"na_number-14_5x11.5in": "Envelope #14",
|
||||
"na_number-9_3.875x8.875in": "Envelope #9",
|
||||
"na_oficio_8.5x13.4in": "8.5 x 13.4″",
|
||||
"na_personal_3.625x6.5in": "Envelope Personal",
|
||||
"na_quarto_8.5x10.83in": "Quarto",
|
||||
"na_super-a_8.94x14in": "8.94 x 14″",
|
||||
"na_super-b_13x19in": "13 x 19″",
|
||||
"na_wide-format_30x42in": "30 x 42″",
|
||||
"oe_12x16_12x16in": "12 x 16″",
|
||||
"oe_14x17_14x17in": "14 x 17″",
|
||||
"oe_18x22_18x22in": "18 x 22″",
|
||||
"oe_a2plus_17x24in": "17 x 24″",
|
||||
"oe_business-card_2x3.5in": "2 x 3.5″",
|
||||
"oe_photo-10r_10x12in": "10 x 12″",
|
||||
"oe_photo-20r_20x24in": "20 x 24″",
|
||||
"oe_photo-l_3.5x5in": "3.5 x 5″",
|
||||
"oe_photo-s10r_10x15in": "10 x 15″",
|
||||
"oe_square-photo_4x4in": "4 x 4″",
|
||||
"oe_square-photo_5x5in": "5 x 5″",
|
||||
"om_16k_184x260mm": "184 x 260mm",
|
||||
"om_16k_195x270mm": "195 x 270mm",
|
||||
"om_business-card_55x85mm": "55 x 85mm",
|
||||
"om_business-card_55x91mm": "55 x 91mm",
|
||||
"om_card_54x86mm": "54 x 86mm",
|
||||
"om_dai-pa-kai_275x395mm": "275 x 395mm",
|
||||
"om_dsc-photo_89x119mm": "89 x 119mm",
|
||||
"om_folio-sp_215x315mm": "Folio",
|
||||
"om_folio_210x330mm": "Folio (Special)",
|
||||
"om_invite_220x220mm": "Envelope Invitation",
|
||||
"om_italian_110x230mm": "Envelope Italian",
|
||||
"om_juuro-ku-kai_198x275mm": "198 x 275mm",
|
||||
"om_large-photo_200x300": "200 x 300",
|
||||
"om_medium-photo_130x180mm": "130 x 180mm",
|
||||
"om_pa-kai_267x389mm": "267 x 389mm",
|
||||
"om_postfix_114x229mm": "Envelope Postfix",
|
||||
"om_small-photo_100x150mm": "100 x 150mm",
|
||||
"om_square-photo_89x89mm": "89 x 89mm",
|
||||
"om_wide-photo_100x200mm": "100 x 200mm",
|
||||
"prc_10_324x458mm": "Envelope Chinese #10",
|
||||
"prc_16k_146x215mm": "Chinese 16k",
|
||||
"prc_1_102x165mm": "Envelope Chinese #1",
|
||||
"prc_2_102x176mm": "Envelope Chinese #2",
|
||||
"prc_32k_97x151mm": "Chinese 32k",
|
||||
"prc_3_125x176mm": "Envelope Chinese #3",
|
||||
"prc_4_110x208mm": "Envelope Chinese #4",
|
||||
"prc_5_110x220mm": "Envelope Chinese #5",
|
||||
"prc_6_120x320mm": "Envelope Chinese #6",
|
||||
"prc_7_160x230mm": "Envelope Chinese #7",
|
||||
"prc_8_120x309mm": "Envelope Chinese #8",
|
||||
"roc_16k_7.75x10.75in": "ROC 16k",
|
||||
"roc_8k_10.75x15.5in": "ROC 8k"}
|
||||
function unknownForEmptyString(s)
|
||||
{
|
||||
if(s === "")
|
||||
{
|
||||
return qsTr("Unknown");
|
||||
}
|
||||
else
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
function existsAndNotEmpty(attrName, printer)
|
||||
{
|
||||
if(printer.attrs.hasOwnProperty(attrName))
|
||||
{
|
||||
return printer.attrs[attrName].value != ""
|
||||
}
|
||||
else
|
||||
{
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function basename(filewithpath)
|
||||
{
|
||||
return filewithpath.substring(filewithpath.lastIndexOf("/")+1);
|
||||
}
|
||||
|
|
|
@ -1,68 +1,53 @@
|
|||
#
|
||||
# Do NOT Edit the Auto-generated Part!
|
||||
# Generated by: spectacle version 0.27
|
||||
#
|
||||
|
||||
Name: harbour-seaprint
|
||||
|
||||
# >> macros
|
||||
# << macros
|
||||
|
||||
Summary: SeaPrint
|
||||
Version: 0.5.6
|
||||
Version: 0
|
||||
Release: 1
|
||||
Group: Qt/Qt
|
||||
License: LICENSE
|
||||
URL: http://example.org/
|
||||
License: GPLv3
|
||||
URL: https://github.com/attah/harbour-seaprint
|
||||
Source0: %{name}-%{version}.tar.bz2
|
||||
Source100: harbour-seaprint.yaml
|
||||
Requires: sailfishsilica-qt5 >= 0.10.9
|
||||
BuildRequires: pkgconfig(sailfishapp) >= 1.0.2
|
||||
BuildRequires: pkgconfig(Qt5Core)
|
||||
BuildRequires: pkgconfig(Qt5Qml)
|
||||
BuildRequires: pkgconfig(Qt5Quick)
|
||||
BuildRequires: pkgconfig(mlite5)
|
||||
BuildRequires: desktop-file-utils
|
||||
BuildRequires: pkgconfig(libcurl)
|
||||
BuildRequires: pkgconfig(poppler)
|
||||
BuildRequires: pkgconfig(poppler-glib)
|
||||
BuildRequires: pkgconfig(glib-2.0)
|
||||
BuildRequires: pkgconfig(cairo)
|
||||
BuildRequires: pkgconfig(libjpeg)
|
||||
|
||||
%define _source_payload w6T.xzdio
|
||||
%define _binary_payload w6T.xzdio
|
||||
|
||||
%description
|
||||
Short description of my Sailfish OS Application
|
||||
|
||||
Network printing for Sailfish OS
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}-%{version}
|
||||
|
||||
# >> setup
|
||||
# << setup
|
||||
|
||||
%build
|
||||
# >> build pre
|
||||
# << build pre
|
||||
|
||||
%qmake5 \
|
||||
VERSION=%{version}
|
||||
|
||||
make %{?_smp_mflags}
|
||||
|
||||
# >> build post
|
||||
# << build post
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
# >> install pre
|
||||
# << install pre
|
||||
%qmake5_install
|
||||
|
||||
# >> install post
|
||||
# << install post
|
||||
|
||||
desktop-file-install --delete-original \
|
||||
--dir %{buildroot}%{_datadir}/applications \
|
||||
%{buildroot}%{_datadir}/applications/*.desktop
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%{_bindir}
|
||||
%{_bindir}/%{name}
|
||||
%{_datadir}/%{name}
|
||||
%{_datadir}/applications/%{name}.desktop
|
||||
%{_datadir}/icons/hicolor/*/apps/%{name}.png
|
||||
# >> files
|
||||
# << files
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
Name: harbour-seaprint
|
||||
Summary: SeaPrint
|
||||
Version: 0.5.6
|
||||
Release: 1
|
||||
# The contents of the Group field should be one of the groups listed here:
|
||||
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
|
||||
Group: Qt/Qt
|
||||
URL: http://example.org/
|
||||
License: LICENSE
|
||||
# This must be generated before uploading a package to a remote build service.
|
||||
# Usually this line does not need to be modified.
|
||||
Sources:
|
||||
- '%{name}-%{version}.tar.bz2'
|
||||
Description: |
|
||||
Short description of my Sailfish OS Application
|
||||
Configure: none
|
||||
Builder: qmake5
|
||||
|
||||
QMakeOptions:
|
||||
- VERSION=%{version}
|
||||
|
||||
# This section specifies build dependencies that are resolved using pkgconfig.
|
||||
# This is the preferred way of specifying build dependencies for your package.
|
||||
PkgConfigBR:
|
||||
- sailfishapp >= 1.0.2
|
||||
- Qt5Core
|
||||
- Qt5Qml
|
||||
- Qt5Quick
|
||||
|
||||
# Build dependencies without a pkgconfig setup can be listed here
|
||||
# PkgBR:
|
||||
# - package-needed-to-build
|
||||
|
||||
# Runtime dependencies which are not automatically detected
|
||||
Requires:
|
||||
- sailfishsilica-qt5 >= 0.10.9
|
||||
|
||||
# All installed files
|
||||
Files:
|
||||
- '%{_bindir}'
|
||||
- '%{_datadir}/%{name}'
|
||||
- '%{_datadir}/applications/%{name}.desktop'
|
||||
- '%{_datadir}/icons/hicolor/*/apps/%{name}.png'
|
||||
|
||||
# For more information about yaml and what's supported in Sailfish OS
|
||||
# build system, please see https://wiki.merproject.org/wiki/Spectacle
|
|
@ -1,19 +1,24 @@
|
|||
#include <poppler/glib/poppler.h>
|
||||
#include <poppler/glib/poppler-document.h>
|
||||
|
||||
#include "convertchecker.h"
|
||||
#include <QProcess>
|
||||
#include <QtDebug>
|
||||
|
||||
ConvertChecker::ConvertChecker()
|
||||
ConvertChecker::ConvertChecker() : poppler("libpoppler-glib.so.8")
|
||||
{
|
||||
_pdf = false;
|
||||
QProcess* pdftoppm = new QProcess(this);
|
||||
pdftoppm->setProgram("pdftoppm");
|
||||
pdftoppm->setArguments({"-h"});
|
||||
pdftoppm->start();
|
||||
if(pdftoppm->waitForFinished(2000))
|
||||
_calligra = false;
|
||||
|
||||
QProcess calligraconverter(this);
|
||||
calligraconverter.setProgram("calligraconverter");
|
||||
calligraconverter.setArguments({"-h"});
|
||||
calligraconverter.start();
|
||||
|
||||
if(calligraconverter.waitForFinished(2000))
|
||||
{
|
||||
if(pdftoppm->exitStatus() == QProcess::NormalExit && pdftoppm->exitCode() == 0)
|
||||
if(calligraconverter.exitStatus() == QProcess::NormalExit && calligraconverter.exitCode() == 0)
|
||||
{
|
||||
_pdf = true;
|
||||
_calligra = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,35 +45,17 @@ ConvertChecker* ConvertChecker::instance()
|
|||
return m_Instance;
|
||||
}
|
||||
|
||||
quint32 ConvertChecker::pdfPages(QString filename)
|
||||
int ConvertChecker::pdfPages(QString filename)
|
||||
{
|
||||
quint32 pages = 0;
|
||||
if(!_pdf)
|
||||
{
|
||||
return pages;
|
||||
}
|
||||
FUNC(poppler, PopplerDocument*, poppler_document_new_from_file, const char*, const char*, GError**);
|
||||
FUNC(poppler, int, poppler_document_get_n_pages, PopplerDocument*);
|
||||
std::string url("file://");
|
||||
url.append(filename.toStdString());
|
||||
GError* error = nullptr;
|
||||
PopplerDocument* doc = poppler_document_new_from_file(url.c_str(), nullptr, &error);
|
||||
|
||||
QProcess* pdfinfo = new QProcess(this);
|
||||
pdfinfo->setProgram("pdfinfo");
|
||||
pdfinfo->setArguments({filename});
|
||||
pdfinfo->start();
|
||||
int pages = poppler_document_get_n_pages(doc);
|
||||
|
||||
if(!pdfinfo->waitForStarted(1000) || !pdfinfo->waitForFinished(1000))
|
||||
{
|
||||
pdfinfo->deleteLater();
|
||||
return pages;
|
||||
}
|
||||
QByteArray pdfInfoOutput = pdfinfo->readAllStandardOutput();
|
||||
pdfinfo->deleteLater();
|
||||
qDebug() << pdfInfoOutput;
|
||||
QList<QByteArray> pdfInfoOutputLines = pdfInfoOutput.split('\n');
|
||||
for(QList<QByteArray>::iterator it = pdfInfoOutputLines.begin(); it != pdfInfoOutputLines.end(); it++)
|
||||
{
|
||||
if(it->startsWith("Pages"))
|
||||
{
|
||||
QList<QByteArray> pagesTokens = it->split(' ');
|
||||
pages = pagesTokens.last().toInt();
|
||||
}
|
||||
}
|
||||
g_object_unref(doc);
|
||||
return pages;
|
||||
}
|
||||
|
|
|
@ -2,15 +2,16 @@
|
|||
#define CONVERTCHECKER_H
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include "madness.h"
|
||||
|
||||
class ConvertChecker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static ConvertChecker* instance();
|
||||
Q_PROPERTY(bool pdf MEMBER _pdf)
|
||||
Q_PROPERTY(bool calligra MEMBER _calligra CONSTANT)
|
||||
|
||||
Q_INVOKABLE quint32 pdfPages(QString pdf);
|
||||
Q_INVOKABLE int pdfPages(QString pdf);
|
||||
|
||||
signals:
|
||||
protected:
|
||||
|
@ -22,7 +23,8 @@ private:
|
|||
ConvertChecker(const ConvertChecker &);
|
||||
ConvertChecker& operator=(const ConvertChecker &);
|
||||
|
||||
bool _pdf;
|
||||
LibLoader poppler;
|
||||
bool _calligra;
|
||||
};
|
||||
|
||||
#endif // CONVERTCHECKER_H
|
||||
|
|
|
@ -1,393 +0,0 @@
|
|||
#include "convertworker.h"
|
||||
#include <sailfishapp.h>
|
||||
#include "papersizes.h"
|
||||
#include "convertchecker.h"
|
||||
#include <QImage>
|
||||
#include <QMatrix>
|
||||
#include <QPainter>
|
||||
|
||||
void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, QString PaperSize,
|
||||
quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble,
|
||||
bool ForcePortrait, quint32 pages)
|
||||
{
|
||||
env.append("HWRES_X="+QString::number(HwResX));
|
||||
env.append("HWRES_Y="+QString::number(HwResY));
|
||||
|
||||
if(urf)
|
||||
{
|
||||
env.append("URF=true");
|
||||
}
|
||||
|
||||
if(Quality >= 3 && Quality <= 5)
|
||||
{
|
||||
env.append("QUALITY="+QString::number(Quality));
|
||||
}
|
||||
|
||||
if(PaperSize != "")
|
||||
{
|
||||
env.append("PAGE_SIZE_NAME="+PaperSize);
|
||||
}
|
||||
|
||||
env.append("DUPLEX="+QString::number(TwoSided));
|
||||
env.append("TUMBLE="+QString::number(Tumble));
|
||||
|
||||
if(ForcePortrait)
|
||||
{
|
||||
env.append("FORCE_PORTRAIT=true");
|
||||
}
|
||||
|
||||
if(pages != 0)
|
||||
{
|
||||
env.append("PAGES="+QString::number(pages));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile,
|
||||
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||
quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble,
|
||||
quint32 PageRangeLow, quint32 PageRangeHigh)
|
||||
{
|
||||
quint32 pages = ConvertChecker::instance()->pdfPages(filename);
|
||||
if (!pages)
|
||||
{
|
||||
qDebug() << "pdfinfo returned 0 pages";
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Failed to get info about PDF file"));
|
||||
}
|
||||
|
||||
if(PageRangeHigh==0)
|
||||
{
|
||||
PageRangeHigh=pages;
|
||||
}
|
||||
|
||||
bool urf = false;
|
||||
bool ps = false;
|
||||
|
||||
if(targetFormat == "image/urf")
|
||||
{
|
||||
urf = true;
|
||||
}
|
||||
else if(targetFormat == "image/pwg-raster")
|
||||
{
|
||||
//ok
|
||||
}
|
||||
else if(targetFormat == "application/postscript")
|
||||
{
|
||||
ps = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
emit failed(tr("Unsupported target format"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(urf && (HwResX != HwResY))
|
||||
{ // URF only supports symmetric resolutions
|
||||
qDebug() << "Unsupported URF resolution" << PaperSize;
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Unsupported resolution (dpi)"));
|
||||
return;
|
||||
}
|
||||
|
||||
QString ShortPaperSize;
|
||||
if(PaperSize == "iso_a4_210x297mm")
|
||||
{
|
||||
ShortPaperSize = "A4";
|
||||
}
|
||||
else if (PaperSize == "iso_a3_297x420mm")
|
||||
{
|
||||
ShortPaperSize = "A3";
|
||||
}
|
||||
else if (PaperSize == "na_letter_8.5x11in")
|
||||
{
|
||||
ShortPaperSize = "letter";
|
||||
}
|
||||
else if (PaperSize == "na_legal_8.5x14in")
|
||||
{
|
||||
ShortPaperSize = "legal";
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Unsupported PDF paper size" << PaperSize;
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Unsupported PDF paper size"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(ps)
|
||||
{
|
||||
QProcess* pdftops = new QProcess(this);
|
||||
pdftops->setProgram("pdftops");
|
||||
QStringList PdfToPsArgs;
|
||||
if(TwoSided)
|
||||
{
|
||||
PdfToPsArgs.append("-duplex");
|
||||
}
|
||||
if(PageRangeLow != 0)
|
||||
{
|
||||
PdfToPsArgs << QStringList {"-f", QString::number(PageRangeLow), "-l", QString::number(PageRangeHigh)};
|
||||
}
|
||||
PdfToPsArgs << QStringList {"-paper", ShortPaperSize, filename, "-"};
|
||||
|
||||
pdftops->setArguments(PdfToPsArgs);
|
||||
|
||||
pdftops->setStandardOutputFile(tempfile->fileName(), QIODevice::Append);
|
||||
connect(pdftops, SIGNAL(finished(int, QProcess::ExitStatus)), pdftops, SLOT(deleteLater()));
|
||||
|
||||
pdftops->start();
|
||||
|
||||
qDebug() << "Starting";
|
||||
|
||||
if(!pdftops->waitForStarted())
|
||||
{
|
||||
qDebug() << "pdftops died";
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Conversion error"));
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Started";
|
||||
|
||||
if(!pdftops->waitForFinished(10000+5000*pages))
|
||||
{
|
||||
qDebug() << "pdftops failed";
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Conversion error"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
QProcess* pdftocairo = new QProcess(this);
|
||||
pdftocairo->setProgram("pdftocairo");
|
||||
QStringList PdfToCairoArgs;
|
||||
if(PageRangeLow != 0)
|
||||
{
|
||||
PdfToCairoArgs << QStringList {"-f", QString::number(PageRangeLow), "-l", QString::number(PageRangeHigh)};
|
||||
}
|
||||
PdfToCairoArgs << QStringList {"-pdf", "-paper", ShortPaperSize, filename, "-"};
|
||||
pdftocairo->setArguments(PdfToCairoArgs);
|
||||
|
||||
QProcess* pdftoppm = new QProcess(this);
|
||||
pdftoppm->setProgram("pdftoppm");
|
||||
QStringList Pdf2PpmArgs = {"-rx", QString::number(HwResX), "-ry", QString::number(HwResY)};
|
||||
if(Colors != 3)
|
||||
{
|
||||
Pdf2PpmArgs.append("-gray");
|
||||
}
|
||||
qDebug() << "pdf2ppm args is " << Pdf2PpmArgs;
|
||||
pdftoppm->setArguments(Pdf2PpmArgs);
|
||||
|
||||
|
||||
QProcess* ppm2pwg = new QProcess(this);
|
||||
// Yo dawg, I heard you like programs...
|
||||
ppm2pwg->setProgram("harbour-seaprint");
|
||||
ppm2pwg->setArguments({"ppm2pwg"});
|
||||
|
||||
QStringList env;
|
||||
ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble, true, pages);
|
||||
qDebug() << "ppm2pwg env is " << env;
|
||||
|
||||
ppm2pwg->setEnvironment(env);
|
||||
|
||||
pdftocairo->setStandardOutputProcess(pdftoppm);
|
||||
pdftoppm->setStandardOutputProcess(ppm2pwg);
|
||||
ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append);
|
||||
|
||||
connect(pdftocairo, SIGNAL(finished(int, QProcess::ExitStatus)), pdftocairo, SLOT(deleteLater()));
|
||||
connect(pdftoppm, SIGNAL(finished(int, QProcess::ExitStatus)), pdftoppm, SLOT(deleteLater()));
|
||||
connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater()));
|
||||
|
||||
qDebug() << "All connected";
|
||||
|
||||
pdftocairo->start();
|
||||
pdftoppm->start();
|
||||
ppm2pwg->start();
|
||||
|
||||
qDebug() << "Starting";
|
||||
|
||||
if(!pdftocairo->waitForStarted())
|
||||
{
|
||||
qDebug() << "pdftocairo died";
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Conversion error"));
|
||||
return;
|
||||
}
|
||||
if(!pdftoppm->waitForStarted())
|
||||
{
|
||||
qDebug() << "pdftoppm died";
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Conversion error"));
|
||||
return;
|
||||
}
|
||||
if(!ppm2pwg->waitForStarted())
|
||||
{
|
||||
qDebug() << "ppm2pwg died";
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Conversion error"));
|
||||
return;
|
||||
}
|
||||
qDebug() << "All started";
|
||||
|
||||
bool ppm2pwgSuccess = false;
|
||||
|
||||
for(size_t i = 0; i < (10*pages+10); i++)
|
||||
{
|
||||
if(ppm2pwg->waitForFinished(1000))
|
||||
{
|
||||
ppm2pwgSuccess = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
QList<QByteArray> ppm2pwgOutput = ppm2pwg->readAllStandardError().split('\n');
|
||||
for(QList<QByteArray>::iterator it = ppm2pwgOutput.begin(); it != ppm2pwgOutput.end(); it++)
|
||||
{
|
||||
if(it->startsWith("Page"))
|
||||
{
|
||||
QList<QByteArray> ppm2pwgTokens = it->split(' ');
|
||||
emit progress(ppm2pwgTokens.last().toInt()-1, pages);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!ppm2pwgSuccess)
|
||||
{
|
||||
qDebug() << "ppm2pwg failed";
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Conversion error"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "Finished";
|
||||
|
||||
emit done(request, tempfile);
|
||||
qDebug() << "posted";
|
||||
}
|
||||
|
||||
void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile,
|
||||
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||
quint32 HwResX, quint32 HwResY)
|
||||
{
|
||||
bool urf = false;
|
||||
QString imageFormat = "";
|
||||
QStringList supportedImageFormats = {"image/jpeg", "image/png", "image/gif"};
|
||||
|
||||
if(targetFormat == "image/urf")
|
||||
{
|
||||
urf = true;
|
||||
}
|
||||
else if(targetFormat == "image/pwg-raster")
|
||||
{
|
||||
//ok
|
||||
}
|
||||
else if(supportedImageFormats.contains(targetFormat))
|
||||
{
|
||||
imageFormat = targetFormat.split("/")[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
emit failed(tr("Unsupported target format"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(urf && (HwResX != HwResY))
|
||||
{ // URF only supports symmetric resolutions
|
||||
qDebug() << "Unsupported URF resolution" << PaperSize;
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Unsupported resolution (dpi)"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!PaperSizes.contains(PaperSize))
|
||||
{
|
||||
qDebug() << "Unsupported paper size" << PaperSize;
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Unsupported paper size"));
|
||||
return;
|
||||
}
|
||||
QPair<float,float> wh = PaperSizes[PaperSize];
|
||||
quint32 Width = qRound(wh.first/25.4*HwResX);
|
||||
quint32 Height = qRound(wh.second/25.4*HwResY);
|
||||
|
||||
qDebug() << "Size is" << Width << "x" << Height;
|
||||
|
||||
QImage inImage;
|
||||
if(!inImage.load(filename))
|
||||
{
|
||||
qDebug() << "failed to load";
|
||||
emit failed(tr("Failed to load image"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(inImage.width() > inImage.height())
|
||||
{
|
||||
inImage = inImage.transformed(QMatrix().rotate(90.0));
|
||||
}
|
||||
inImage = inImage.scaled(Width, Height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
QImage outImage = QImage(Width, Height, inImage.format());
|
||||
outImage.fill(Qt::white);
|
||||
QPainter painter(&outImage);
|
||||
int xOffset = (outImage.width()-inImage.width())/2;
|
||||
int yOffset = (outImage.height()-inImage.height())/2;
|
||||
painter.drawImage(xOffset, yOffset, inImage);
|
||||
painter.end();
|
||||
|
||||
if(imageFormat != "")
|
||||
{ // We are converting to a supported image format
|
||||
|
||||
QFile tempfileAsFile(tempfile->fileName());
|
||||
tempfileAsFile.open(QIODevice::Append);
|
||||
outImage.save(&tempfileAsFile, imageFormat.toStdString().c_str());
|
||||
tempfileAsFile.close();
|
||||
}
|
||||
else
|
||||
{ // We are converting to a raster format
|
||||
QTemporaryFile tmpImage;
|
||||
tmpImage.open();
|
||||
qDebug() << "Raw image: " << tmpImage.fileName();
|
||||
|
||||
outImage.save(tmpImage.fileName(), Colors == 1 ? "pgm" : "ppm");
|
||||
tmpImage.close();
|
||||
|
||||
QProcess* ppm2pwg = new QProcess(this);
|
||||
// Yo dawg, I heard you like programs...
|
||||
ppm2pwg->setProgram("harbour-seaprint");
|
||||
ppm2pwg->setArguments({"ppm2pwg"});
|
||||
|
||||
QStringList env;
|
||||
ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, false, false, false, 0);
|
||||
qDebug() << "ppm2pwg env is " << env;
|
||||
|
||||
ppm2pwg->setEnvironment(env);
|
||||
ppm2pwg->setStandardInputFile(tmpImage.fileName());
|
||||
ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append);
|
||||
|
||||
connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater()));
|
||||
|
||||
qDebug() << "All connected";
|
||||
ppm2pwg->start();
|
||||
|
||||
qDebug() << "Starting";
|
||||
|
||||
if(!ppm2pwg->waitForStarted())
|
||||
{
|
||||
qDebug() << "ppm2pwg died";
|
||||
tempfile->deleteLater();
|
||||
emit failed(tr("Conversion error"));
|
||||
return;
|
||||
}
|
||||
qDebug() << "All started";
|
||||
|
||||
ppm2pwg->waitForFinished();
|
||||
|
||||
qDebug() << "Finished";
|
||||
}
|
||||
|
||||
emit done(request, tempfile);
|
||||
qDebug() << "posted";
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef CONVERTWORKER_H
|
||||
#define CONVERTWORKER_H
|
||||
#include <QObject>
|
||||
#include <QtNetwork>
|
||||
|
||||
class ConvertWorker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile,
|
||||
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||
quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble,
|
||||
quint32 PageRangeLow, quint32 PageRangeHigh);
|
||||
|
||||
void convertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile,
|
||||
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||
quint32 HwResX, quint32 HwResY);
|
||||
|
||||
signals:
|
||||
void done(QNetworkRequest request, QTemporaryFile* data);
|
||||
void progress(qint64 done, qint64 pages);
|
||||
void failed(QString message);
|
||||
};
|
||||
|
||||
#endif // CONVERTWORKER_H
|
153
src/curlrequester.cpp
Normal file
153
src/curlrequester.cpp
Normal file
|
@ -0,0 +1,153 @@
|
|||
#include "curlrequester.h"
|
||||
#include <algorithm>
|
||||
#include "settings.h"
|
||||
|
||||
static size_t trampoline(char* dest, size_t size, size_t nmemb, void* userp)
|
||||
{
|
||||
CurlRequester* cid = (CurlRequester*)userp;
|
||||
return cid->requestWrite(dest, size*nmemb);
|
||||
}
|
||||
|
||||
CurlRequester::CurlRequester(QUrl addr, Role role, Bytestream* singleData)
|
||||
: _addr(addr), _canWrite(1), _canRead(), _reading(false), _done(false), _dest(nullptr), _size(0), _offset(0), _curl(curl_easy_init())
|
||||
{
|
||||
|
||||
curl_easy_setopt(_curl, CURLOPT_URL, addr.toString().toStdString().c_str());
|
||||
|
||||
bool verbose = QLoggingCategory::defaultCategory()->isDebugEnabled();
|
||||
|
||||
curl_easy_setopt(_curl, CURLOPT_VERBOSE, verbose);
|
||||
if(Settings::instance()->ignoreSslErrors())
|
||||
{
|
||||
curl_easy_setopt(_curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(_curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
curl_easy_setopt(_curl, CURLOPT_SSL_VERIFYSTATUS, 0L);
|
||||
}
|
||||
|
||||
_opts = NULL;
|
||||
_opts = curl_slist_append(_opts, "User-Agent: SeaPrint " SEAPRINT_VERSION);
|
||||
|
||||
|
||||
switch (role) {
|
||||
case IppRequest:
|
||||
{
|
||||
curl_easy_setopt(_curl, CURLOPT_POST, 1L);
|
||||
curl_easy_setopt(_curl, CURLOPT_READFUNCTION, trampoline);
|
||||
curl_easy_setopt(_curl, CURLOPT_READDATA, this);
|
||||
|
||||
_opts = curl_slist_append(_opts, "Expect:");
|
||||
if(singleData != nullptr)
|
||||
{
|
||||
curl_easy_setopt(_curl, CURLOPT_POSTFIELDSIZE, singleData->size());
|
||||
write((char*)(singleData->raw()), singleData->size());
|
||||
}
|
||||
else
|
||||
{
|
||||
_opts = curl_slist_append(_opts, "Transfer-Encoding: chunked");
|
||||
}
|
||||
_opts = curl_slist_append(_opts, "Content-Type: application/ipp");
|
||||
_opts = curl_slist_append(_opts, "Accept-Encoding: identity");
|
||||
break;
|
||||
}
|
||||
case HttpGetRequest:
|
||||
{
|
||||
curl_easy_setopt(_curl, CURLOPT_HTTPGET, 1L);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
curl_easy_setopt(_curl, CURLOPT_HTTPHEADER, _opts);
|
||||
|
||||
_worker = QtConcurrent::run([this](){
|
||||
Bytestream buf;
|
||||
curl_easy_setopt(_curl, CURLOPT_WRITEDATA, &buf);
|
||||
curl_easy_setopt(_curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||
|
||||
CURLcode res = curl_easy_perform(_curl);
|
||||
if(res != CURLE_OK)
|
||||
qDebug() << "curl_easy_perform() failed: " << curl_easy_strerror(res);
|
||||
|
||||
_result = res;
|
||||
_resultMsg = buf;
|
||||
});
|
||||
}
|
||||
|
||||
CurlRequester::~CurlRequester()
|
||||
{
|
||||
await();
|
||||
|
||||
if(_dest != nullptr)
|
||||
{
|
||||
delete _dest;
|
||||
}
|
||||
|
||||
curl_slist_free_all(_opts);
|
||||
curl_easy_cleanup(_curl);
|
||||
}
|
||||
|
||||
CURLcode CurlRequester::await(Bytestream* data)
|
||||
{
|
||||
while(_worker.isRunning() && !_canWrite.tryAcquire(1, 500))
|
||||
{}
|
||||
|
||||
_done = true;
|
||||
_canRead.release();
|
||||
_worker.waitForFinished();
|
||||
|
||||
if(data != nullptr)
|
||||
{
|
||||
(*data) = _resultMsg;
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
bool CurlRequester::write(const char *data, size_t size)
|
||||
{
|
||||
qDebug() << "write " << size;
|
||||
while(!_canWrite.tryAcquire(1, 500))
|
||||
{
|
||||
if(!_worker.isRunning())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(_dest != nullptr)
|
||||
{
|
||||
delete _dest;
|
||||
}
|
||||
_dest = new char[size];
|
||||
memcpy(_dest, data, size);
|
||||
_size = size;
|
||||
_offset = 0;
|
||||
_canRead.release();
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t CurlRequester::requestWrite(char* dest, size_t size)
|
||||
{
|
||||
if(!_reading)
|
||||
{
|
||||
_canRead.acquire();
|
||||
if(_done) // Can only have been set by await() - only relevant to check if strating to write
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
_reading = true;
|
||||
}
|
||||
|
||||
size_t remaining = _size - _offset;
|
||||
|
||||
size_t actualSize = std::min(size, remaining);
|
||||
|
||||
memcpy(dest, (_dest+_offset), actualSize);
|
||||
_offset += actualSize;
|
||||
|
||||
remaining = _size - _offset;
|
||||
if(remaining == 0)
|
||||
{
|
||||
_reading = false;
|
||||
_canWrite.release();
|
||||
}
|
||||
return actualSize;
|
||||
}
|
78
src/curlrequester.h
Normal file
78
src/curlrequester.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
#ifndef CURLREQUESTER_H
|
||||
#define CURLREQUESTER_H
|
||||
|
||||
#include <QUrl>
|
||||
#include <QThread>
|
||||
#include <QSemaphore>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <curl/curl.h>
|
||||
#include <bytestream.h>
|
||||
#include <QDebug>
|
||||
#include <functional>
|
||||
|
||||
class CurlRequester : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Role {
|
||||
IppRequest,
|
||||
HttpGetRequest
|
||||
};
|
||||
|
||||
CurlRequester(QUrl addr, Role role = IppRequest, Bytestream* = nullptr);
|
||||
~CurlRequester();
|
||||
|
||||
CURLcode await(Bytestream* = nullptr);
|
||||
|
||||
bool write(const char *data, size_t size);
|
||||
size_t requestWrite(char* dest, size_t size);
|
||||
|
||||
static size_t write_callback(char *ptr, size_t size, size_t nmemb, void* userdata)
|
||||
{
|
||||
size_t bytes_to_write = size*nmemb;
|
||||
((Bytestream*)userdata)->putBytes(ptr, bytes_to_write);
|
||||
return bytes_to_write;
|
||||
}
|
||||
|
||||
private:
|
||||
CurlRequester();
|
||||
|
||||
// Container for the cURL global init and cleanup
|
||||
class GlobalEnv
|
||||
{
|
||||
public:
|
||||
GlobalEnv()
|
||||
{
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
}
|
||||
~GlobalEnv()
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
};
|
||||
// Must be run exactly once, thus static
|
||||
static GlobalEnv _gEnv;
|
||||
|
||||
QUrl _addr;
|
||||
|
||||
QSemaphore _canWrite;
|
||||
QSemaphore _canRead;
|
||||
bool _reading;
|
||||
bool _done;
|
||||
|
||||
CURLcode _result;
|
||||
Bytestream _resultMsg;
|
||||
|
||||
char* _dest;
|
||||
size_t _size;
|
||||
size_t _offset;
|
||||
|
||||
friend class CurlWorker;
|
||||
|
||||
CURL* _curl;
|
||||
struct curl_slist* _opts = NULL;
|
||||
|
||||
QFuture<void> _worker;
|
||||
};
|
||||
|
||||
#endif // CURLREQUESTER_H
|
25
src/dbusadaptorbase.cpp
Normal file
25
src/dbusadaptorbase.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "dbusadaptorbase.h"
|
||||
#include <QtQuick>
|
||||
|
||||
void DBusAdaptorBase::doActivate()
|
||||
{
|
||||
QMetaObject::invokeMethod(_view->rootObject(), "activate");
|
||||
}
|
||||
|
||||
void DBusAdaptorBase::doOpen(const QString& fileName)
|
||||
{
|
||||
QMetaObject::invokeMethod(_view->rootObject(), "openFile", Q_ARG(QVariant, fileName));
|
||||
doActivate();
|
||||
}
|
||||
|
||||
void DBusAdaptorBase::doCreateFileAndOpen(const QString& fileContents, const QString& name)
|
||||
{
|
||||
QTemporaryFile tmpfile(QDir::tempPath() + "/" + name);
|
||||
tmpfile.setAutoRemove(false);
|
||||
tmpfile.open();
|
||||
tmpfile.write(fileContents.toUtf8());
|
||||
tmpfile.close();
|
||||
QMetaObject::invokeMethod(_view->rootObject(), "openFile", Q_ARG(QVariant, tmpfile.fileName()));
|
||||
|
||||
doActivate();
|
||||
}
|
24
src/dbusadaptorbase.h
Normal file
24
src/dbusadaptorbase.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef DBUSADAPTORBASE_H
|
||||
#define DBUSADAPTORBASE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtDBus/QDBusAbstractAdaptor>
|
||||
#include <QQuickView>
|
||||
|
||||
class DBusAdaptorBase
|
||||
{
|
||||
public:
|
||||
DBusAdaptorBase(QQuickView* view)
|
||||
: _view(view)
|
||||
{}
|
||||
|
||||
void doActivate();
|
||||
void doOpen(const QString& fileName);
|
||||
void doCreateFileAndOpen(const QString& fileContents, const QString& name);
|
||||
|
||||
protected:
|
||||
QQuickView* _view;
|
||||
|
||||
};
|
||||
|
||||
#endif // DBUSADAPTORBASE_H
|
31
src/freedesktopdbusadaptor.cpp
Normal file
31
src/freedesktopdbusadaptor.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "freedesktopdbusadaptor.h"
|
||||
|
||||
#include <QtQuick>
|
||||
|
||||
FreedesktopDBusAdaptor::FreedesktopDBusAdaptor(QQuickView *view)
|
||||
: QDBusAbstractAdaptor(view)
|
||||
, DBusAdaptorBase(view)
|
||||
{
|
||||
}
|
||||
|
||||
FreedesktopDBusAdaptor::~FreedesktopDBusAdaptor()
|
||||
{
|
||||
}
|
||||
|
||||
void FreedesktopDBusAdaptor::Open(const QStringList& uris, const QVariantMap& platformData)
|
||||
{
|
||||
qDebug() << platformData;
|
||||
if (!uris.isEmpty() && uris[0] != "") {
|
||||
doOpen(uris.at(0));
|
||||
}
|
||||
else if(platformData.contains("data"))
|
||||
{
|
||||
doCreateFileAndOpen(platformData["data"].toString(),
|
||||
(platformData.contains("name") ? platformData["name"].toString() : "seaprint"));
|
||||
}
|
||||
}
|
||||
|
||||
void FreedesktopDBusAdaptor::Activate(const QVariantMap&)
|
||||
{
|
||||
QMetaObject::invokeMethod(_view->rootObject(), "activate");
|
||||
}
|
21
src/freedesktopdbusadaptor.h
Normal file
21
src/freedesktopdbusadaptor.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef FREEDESKTOPDBUSADAPTOR_H
|
||||
#define FREEDESKTOPDBUSADAPTOR_H
|
||||
|
||||
#include "dbusadaptorbase.h"
|
||||
|
||||
class FreedesktopDBusAdaptor : public QDBusAbstractAdaptor, public DBusAdaptorBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Application")
|
||||
|
||||
public:
|
||||
FreedesktopDBusAdaptor(QQuickView *view);
|
||||
~FreedesktopDBusAdaptor();
|
||||
|
||||
public Q_SLOTS:
|
||||
Q_NOREPLY void Open(const QStringList& uris, const QVariantMap& platformData);
|
||||
Q_NOREPLY void Activate(const QVariantMap& platformData);
|
||||
|
||||
};
|
||||
|
||||
#endif // FREEDESKTOPDBUSADAPTOR_H
|
|
@ -1,14 +1,23 @@
|
|||
#include <QtQuick>
|
||||
#include <QVariant>
|
||||
#include <QDBusConnection>
|
||||
|
||||
#include <sailfishapp.h>
|
||||
#include <seaprint_version.h>
|
||||
#include <src/ippdiscovery.h>
|
||||
#include <src/ippprinter.h>
|
||||
#include <src/imageitem.h>
|
||||
#include <src/mimer.h>
|
||||
#include <src/convertchecker.h>
|
||||
#include <src/settings.h>
|
||||
#include <src/rangelistchecker.h>
|
||||
#include <src/freedesktopdbusadaptor.h>
|
||||
#include <src/seaprintdbusadaptor.h>
|
||||
#include "argget.h"
|
||||
#include <iostream>
|
||||
|
||||
#define PPM2PWG_MAIN ppm2pwg_main
|
||||
#include <ppm2pwg/ppm2pwg.cpp>
|
||||
Q_DECLARE_METATYPE(CURLcode)
|
||||
Q_DECLARE_METATYPE(Bytestream)
|
||||
Q_DECLARE_METATYPE(PrintParameters)
|
||||
|
||||
template <class T>
|
||||
static QObject* singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
|
@ -23,29 +32,63 @@ static QObject* singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngi
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(argc >= 1 && QString("ppm2pwg") == argv[1])
|
||||
bool prestart = false;
|
||||
std::string FileName;
|
||||
SwitchArg<bool> pretsartOpt(prestart, {"--prestart"}, "Run prestart");
|
||||
|
||||
PosArg fileArg(FileName, "File to print", true);
|
||||
ArgGet args({&pretsartOpt}, {&fileArg});
|
||||
if(!args.get_args(argc, argv))
|
||||
{
|
||||
return ppm2pwg_main(argc-1, &(argv[1]));
|
||||
return 1;
|
||||
}
|
||||
|
||||
qRegisterMetaType<CURLcode>();
|
||||
qRegisterMetaType<Bytestream>();
|
||||
qRegisterMetaType<PrintParameters>();
|
||||
|
||||
// Turn on/off logging according to setting
|
||||
QLoggingCategory::defaultCategory()->setEnabled(QtMsgType::QtDebugMsg, Settings::instance()->debugLog());
|
||||
|
||||
QGuiApplication* app = SailfishApp::application(argc, argv);
|
||||
|
||||
app->setOrganizationName(QStringLiteral("net.attah"));
|
||||
app->setApplicationName(QStringLiteral("seaprint"));
|
||||
app->setApplicationVersion(QStringLiteral(SEAPRINT_VERSION));
|
||||
|
||||
qmlRegisterSingletonType<IppDiscovery>("seaprint.ippdiscovery", 1, 0, "IppDiscovery", singletontype_provider<IppDiscovery>);
|
||||
qmlRegisterSingletonType<Mimer>("seaprint.mimer", 1, 0, "Mimer", singletontype_provider<Mimer>);
|
||||
qmlRegisterSingletonType<ConvertChecker>("seaprint.convertchecker", 1, 0, "ConvertChecker", singletontype_provider<ConvertChecker>);
|
||||
qmlRegisterSingletonType<Settings>("seaprint.settings", 1, 0, "SeaPrintSettings", singletontype_provider<Settings>);
|
||||
qmlRegisterSingletonType<RangeListChecker>("seaprint.rangelistchecker", 1, 0, "RangeListChecker", singletontype_provider<RangeListChecker>);
|
||||
|
||||
qmlRegisterType<IppPrinter>("seaprint.ippprinter", 1, 0, "IppPrinter");
|
||||
qmlRegisterType<ImageItem>("seaprint.imageitem", 1, 0, "ImageItem");
|
||||
qmlRegisterUncreatableType<IppMsg>("seaprint.ippmsg", 1, 0, "IppMsg", "Only used to supply an enum type");
|
||||
|
||||
QQuickView* view = SailfishApp::createView();
|
||||
|
||||
view->engine()->addImportPath(SailfishApp::pathTo("qml/pages").toString());
|
||||
view->engine()->addImageProvider(QLatin1String("ippdiscovery"), IppDiscovery::instance());
|
||||
|
||||
view->setSource(SailfishApp::pathToMainQml());
|
||||
view->show();
|
||||
return app->exec();
|
||||
|
||||
FreedesktopDBusAdaptor freedesktopDbus(view);
|
||||
SeaPrintDBusAdaptor seaprintDbus(view);
|
||||
|
||||
if (!QDBusConnection::sessionBus().registerObject("/net/attah/seaprint", view))
|
||||
qWarning() << "Could not register /net/attah/seaprint D-Bus object.";
|
||||
|
||||
if (!QDBusConnection::sessionBus().registerService("net.attah.seaprint"))
|
||||
qWarning() << "Could not register net.attah.seaprint D-Bus service.";
|
||||
|
||||
if(!FileName.empty())
|
||||
{
|
||||
qDebug() << "Opening" << FileName.c_str();
|
||||
QVariant fileNameVariant(FileName.c_str());
|
||||
QMetaObject::invokeMethod(view->rootObject(), "openFile", Q_ARG(QVariant, fileNameVariant));
|
||||
}
|
||||
if(!prestart)
|
||||
{
|
||||
view->show();
|
||||
}
|
||||
return app->exec();
|
||||
}
|
||||
|
|
29
src/imageitem.cpp
Normal file
29
src/imageitem.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include "imageitem.h"
|
||||
|
||||
ImageItem::ImageItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ImageItem::paint(QPainter *painter)
|
||||
{
|
||||
QImage scaled = _image.scaledToHeight(boundingRect().height(), Qt::SmoothTransformation);
|
||||
painter->drawImage(QPoint {0, 0}, scaled);
|
||||
}
|
||||
|
||||
QImage ImageItem::getImage() const
|
||||
{
|
||||
return _image;
|
||||
}
|
||||
|
||||
void ImageItem::setImage(const QImage &image)
|
||||
{
|
||||
_image = image;
|
||||
emit imageChanged();
|
||||
update();
|
||||
}
|
||||
|
||||
bool ImageItem::isValid() const
|
||||
{
|
||||
return !_image.isNull();
|
||||
}
|
31
src/imageitem.h
Normal file
31
src/imageitem.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef IMAGEITEM_H
|
||||
#define IMAGEITEM_H
|
||||
|
||||
#include <QQuickPaintedItem>
|
||||
#include <QPainter>
|
||||
#include <QImage>
|
||||
|
||||
class ImageItem : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QImage image READ getImage WRITE setImage NOTIFY imageChanged)
|
||||
Q_PROPERTY(bool valid READ isValid NOTIFY imageChanged)
|
||||
public:
|
||||
ImageItem();
|
||||
|
||||
void paint(QPainter *painter);
|
||||
|
||||
signals:
|
||||
void imageChanged();
|
||||
|
||||
private:
|
||||
QImage getImage() const;
|
||||
void setImage(const QImage &image);
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QImage _image;
|
||||
};
|
||||
|
||||
#endif // IMAGEITEM_H
|
|
@ -1,5 +1,6 @@
|
|||
#include "ippdiscovery.h"
|
||||
#include <seaprint_version.h>
|
||||
#include "ippprinter.h"
|
||||
#include "settings.h"
|
||||
|
||||
#define A 1
|
||||
#define PTR 12
|
||||
|
@ -9,16 +10,6 @@
|
|||
|
||||
#define ALL 255 //for querying
|
||||
|
||||
void put_addr(Bytestream& bts, QStringList addr)
|
||||
{
|
||||
for(int i = 0; i < addr.length(); i++)
|
||||
{
|
||||
QString elem = addr[i];
|
||||
bts << (quint8)elem.size() << elem.toStdString();
|
||||
}
|
||||
bts << (quint8)0;
|
||||
}
|
||||
|
||||
QStringList get_addr(Bytestream& bts)
|
||||
{
|
||||
QStringList addr;
|
||||
|
@ -46,13 +37,12 @@ QStringList get_addr(Bytestream& bts)
|
|||
return addr;
|
||||
}
|
||||
|
||||
IppDiscovery::IppDiscovery() : QStringListModel(), QQuickImageProvider(QQuickImageProvider::Image)
|
||||
IppDiscovery::IppDiscovery() : QStringListModel()
|
||||
{
|
||||
socket = new QUdpSocket(this);
|
||||
connect(socket, SIGNAL(readyRead()),
|
||||
this, SLOT(readPendingDatagrams()));
|
||||
connect(this, SIGNAL(favouritesChanged()),
|
||||
this, SLOT(update()));
|
||||
connect(socket, &QUdpSocket::readyRead, this, &IppDiscovery::readPendingDatagrams);
|
||||
connect(this, &IppDiscovery::favouritesChanged, this, &IppDiscovery::cleanUpdate);
|
||||
_transactionid = 0;
|
||||
}
|
||||
|
||||
IppDiscovery::~IppDiscovery() {
|
||||
|
@ -78,67 +68,214 @@ IppDiscovery* IppDiscovery::instance()
|
|||
}
|
||||
|
||||
void IppDiscovery::discover() {
|
||||
sendQuery(PTR, {"_ipp","_tcp","local"});
|
||||
sendQuery(PTR, {"_ipp._tcp.local", "_ipps._tcp.local"});
|
||||
}
|
||||
|
||||
void IppDiscovery::reset() {
|
||||
_ipp = QStringList();
|
||||
_rps = QMap<QString,QString>();
|
||||
_ports = QMap<QString,quint16>();
|
||||
_targets = QMap<QString,QString>();
|
||||
_ipp.clear();
|
||||
_rps.clear();
|
||||
_ports.clear();
|
||||
_targets.clear();
|
||||
|
||||
_AAs = QMultiMap<QString,QString>();
|
||||
_AAAAs = QMultiMap<QString,QString>();
|
||||
_AAs.clear();
|
||||
_AAAAs.clear();
|
||||
|
||||
_outstandingQueries.clear();
|
||||
|
||||
setStringList({});
|
||||
discover();
|
||||
}
|
||||
|
||||
void IppDiscovery::sendQuery(quint16 qtype, QStringList addr) {
|
||||
qDebug() << "discovering" << qtype << addr;
|
||||
|
||||
void IppDiscovery::sendQuery(quint16 qtype, QStringList addrs) {
|
||||
addrs.removeDuplicates();
|
||||
|
||||
QTime now = QTime::currentTime();
|
||||
QTime aWhileAgo = now.addSecs(-1);
|
||||
|
||||
for(QPair<quint16, QString> oq : _outstandingQueries.keys())
|
||||
{
|
||||
if(_outstandingQueries[oq] < aWhileAgo)
|
||||
{ // Housekeeping for _outstandingQueries
|
||||
_outstandingQueries.remove(oq);
|
||||
}
|
||||
else if(oq.first == qtype && addrs.contains(oq.second))
|
||||
{ // we recently asked about this, remove it
|
||||
addrs.removeOne(oq.second);
|
||||
}
|
||||
}
|
||||
|
||||
if(addrs.empty())
|
||||
{
|
||||
qDebug() << "nothing to do";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "discovering" << qtype << addrs;
|
||||
|
||||
Bytestream query;
|
||||
quint16 transactionid = 0;
|
||||
QMap<QString, quint16> suffixPositions;
|
||||
|
||||
quint16 flags = 0;
|
||||
quint16 questions = 1;
|
||||
quint16 questions = addrs.length();
|
||||
|
||||
query << transactionid << flags << questions << (quint16)0 << (quint16)0 << (quint16)0;
|
||||
put_addr(query, addr);
|
||||
query << qtype << (quint16)0x0001;
|
||||
query << _transactionid++ << flags << questions << (quint16)0 << (quint16)0 << (quint16)0;
|
||||
|
||||
QByteArray bytes((char*)(query.raw()), query.size());
|
||||
socket->writeDatagram(bytes, QHostAddress("224.0.0.251"), 5353);
|
||||
for(QString addr : addrs)
|
||||
{
|
||||
_outstandingQueries.insert({qtype, addr}, now);
|
||||
|
||||
QStringList addrParts = addr.split(".");
|
||||
QString addrPart, restAddr;
|
||||
while(!addrParts.isEmpty())
|
||||
{
|
||||
restAddr = addrParts.join(".");
|
||||
if(suffixPositions.contains(restAddr))
|
||||
{
|
||||
query << (quint16)(0xc000 | (0x0fff & suffixPositions[restAddr]));
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are putting in at least one part of the address, remember where that was
|
||||
suffixPositions.insert(restAddr, query.size());
|
||||
addrPart = addrParts.takeFirst();
|
||||
query << (quint8)addrPart.size() << addrPart.toStdString();
|
||||
}
|
||||
}
|
||||
if(addrParts.isEmpty())
|
||||
{
|
||||
// Whole addr was put in without c-pointers, 0-terminate it
|
||||
query << (quint8)0;
|
||||
}
|
||||
|
||||
query << qtype << (quint16)0x0001;
|
||||
|
||||
}
|
||||
|
||||
socket->writeDatagram((char*)(query.raw()), query.size(), QHostAddress("224.0.0.251"), 5353);
|
||||
}
|
||||
|
||||
QString make_addr(QString proto, int defaultPort, quint16 port, QString ip, QString rp)
|
||||
{
|
||||
QString maybePort = port != defaultPort ? ":"+QString::number(port) : "";
|
||||
QString addr = proto+"://"+ip+maybePort+"/"+rp;
|
||||
return addr;
|
||||
}
|
||||
|
||||
QString make_ipp_addr(quint16 port, QString ip, QString rp)
|
||||
{
|
||||
return make_addr("ipp", 631, port, ip, rp);
|
||||
}
|
||||
|
||||
QString make_ipps_addr(quint16 port, QString ip, QString rp)
|
||||
{
|
||||
return make_addr("ipps", 443, port, ip, rp);
|
||||
}
|
||||
|
||||
void IppDiscovery::cleanUpdate()
|
||||
{
|
||||
setStringList(_favourites);
|
||||
update();
|
||||
}
|
||||
|
||||
void IppDiscovery::update()
|
||||
{
|
||||
QStringList found;
|
||||
QList<QPair<QString,QString>> ippsIpRps;
|
||||
QString target, rp;
|
||||
|
||||
for(QStringList::Iterator it = _ipp.begin(); it != _ipp.end(); it++)
|
||||
for(QString it : _ipps)
|
||||
{
|
||||
quint16 port = _ports[*it];
|
||||
QString target = _targets[*it];
|
||||
QString rp = _rps[*it];
|
||||
if(!_targets.contains(it) || !_ports.contains(it) || !_rps.contains(it))
|
||||
continue;
|
||||
|
||||
quint16 port = _ports.value(it);
|
||||
target = _targets.value(it);
|
||||
rp = _rps.value(it);
|
||||
|
||||
|
||||
for(QMultiMap<QString,QString>::Iterator ait = _AAs.begin(); ait != _AAs.end(); ait++)
|
||||
{
|
||||
if(ait.key() == target)
|
||||
{
|
||||
QString ip = ait.value();
|
||||
QString maybePort = port != 631 ? ":"+QString::number(port) : "";
|
||||
QString addr = "ipp://"+ip+maybePort+"/"+rp;
|
||||
QString addr = make_ipps_addr(port, ip, rp);
|
||||
if(!found.contains(addr))
|
||||
{
|
||||
ippsIpRps.append({ip, rp});
|
||||
found.append(addr);
|
||||
found.sort(Qt::CaseInsensitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << _favourites << found;
|
||||
this->setStringList(_favourites+found);
|
||||
for(QString it : _ipp)
|
||||
{
|
||||
if(!_targets.contains(it) || !_ports.contains(it) || !_rps.contains(it))
|
||||
continue;
|
||||
|
||||
quint16 port = _ports.value(it);
|
||||
target = _targets.value(it);
|
||||
rp = _rps.value(it);
|
||||
|
||||
for(QMultiMap<QString,QString>::Iterator ait = _AAs.begin(); ait != _AAs.end(); ait++)
|
||||
{
|
||||
if(ait.key() == target)
|
||||
{
|
||||
QString ip = ait.value();
|
||||
QString addr = make_ipp_addr(port, ip, rp);
|
||||
|
||||
// IP+RP assumed unique, don't add ipp version of the printer if ipps already added
|
||||
if(!found.contains(addr) && !ippsIpRps.contains({ip, rp}))
|
||||
{
|
||||
found.append(addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
found.sort(Qt::CaseInsensitive);
|
||||
|
||||
// Counting on that _ipp duplicates doesn't resolve fully any erlier than their _ipps counterpart
|
||||
|
||||
// TODO?: replace this with some logic that can bpoth add and remove
|
||||
// and it can consider _favourites, so we can drop cleanUpdate
|
||||
for(QString f : found)
|
||||
{
|
||||
if(!this->stringList().contains(f))
|
||||
{
|
||||
if(this->insertRow(this->rowCount()))
|
||||
{
|
||||
QModelIndex index = this->index(this->rowCount() - 1, 0);
|
||||
this->setData(index, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IppDiscovery::updateAndQueryPtrs(QStringList& ptrs, QStringList new_ptrs)
|
||||
{
|
||||
new_ptrs.removeDuplicates();
|
||||
for(QString ptr : new_ptrs)
|
||||
{
|
||||
if(!ptrs.contains(ptr))
|
||||
{
|
||||
ptrs.append(ptr);
|
||||
}
|
||||
// If pointer does not resolve to a target or is missing information, query about it
|
||||
if(!_rps.contains(ptr))
|
||||
{
|
||||
// Avahi *really* hates sending TXT to anything else than a TXT query
|
||||
qDebug() << "querying txt " << ptr;
|
||||
sendQuery(TXT, {ptr});
|
||||
}
|
||||
if(!_targets.contains(ptr) || !_ports.contains(ptr))
|
||||
{
|
||||
qDebug() << "querying srv " << ptr;
|
||||
sendQuery(SRV, {ptr});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IppDiscovery::readPendingDatagrams()
|
||||
|
@ -151,8 +288,11 @@ void IppDiscovery::readPendingDatagrams()
|
|||
quint16 senderPort;
|
||||
|
||||
QStringList new_ipp_ptrs;
|
||||
QStringList new_ipps_ptrs;
|
||||
QStringList new_targets;
|
||||
|
||||
QString qaddr, aaddr, tmpname, target;
|
||||
|
||||
socket->readDatagram((char*)(resp.raw()), size, &sender, &senderPort);
|
||||
sender = QHostAddress(sender.toIPv4Address());
|
||||
|
||||
|
@ -165,7 +305,7 @@ void IppDiscovery::readPendingDatagrams()
|
|||
for(quint16 i = 0; i < questions; i++)
|
||||
{
|
||||
quint16 qtype, qflags;
|
||||
QString qaddr = get_addr(resp).join('.');
|
||||
qaddr = get_addr(resp).join('.');
|
||||
resp >> qtype >> qflags;
|
||||
}
|
||||
|
||||
|
@ -174,17 +314,21 @@ void IppDiscovery::readPendingDatagrams()
|
|||
quint16 atype, aflags, len;
|
||||
quint32 ttl;
|
||||
|
||||
QString aaddr = get_addr(resp).join('.');
|
||||
aaddr = get_addr(resp).join('.');
|
||||
resp >> atype >> aflags >> ttl >> len;
|
||||
|
||||
quint16 pos_before = resp.pos();
|
||||
if (atype == PTR)
|
||||
{
|
||||
QString tmpname = get_addr(resp).join(".");
|
||||
tmpname = get_addr(resp).join(".");
|
||||
if(aaddr.endsWith("_ipp._tcp.local"))
|
||||
{
|
||||
new_ipp_ptrs.append(tmpname);
|
||||
}
|
||||
else if(aaddr.endsWith("_ipps._tcp.local"))
|
||||
{
|
||||
new_ipps_ptrs.append(tmpname);
|
||||
}
|
||||
}
|
||||
else if(atype == TXT)
|
||||
{
|
||||
|
@ -196,6 +340,7 @@ void IppDiscovery::readPendingDatagrams()
|
|||
{
|
||||
std::string tmprp;
|
||||
tmp/tmp.remaining() >> tmprp;
|
||||
qDebug() << "tmprp" << aaddr << tmprp.c_str();
|
||||
_rps[aaddr] = tmprp.c_str();
|
||||
}
|
||||
}
|
||||
|
@ -204,17 +349,23 @@ void IppDiscovery::readPendingDatagrams()
|
|||
{
|
||||
quint16 prio, w, port;
|
||||
resp >> prio >> w >> port;
|
||||
QString target = get_addr(resp).join(".");
|
||||
target = get_addr(resp).join(".");
|
||||
_ports[aaddr] = port;
|
||||
_targets[aaddr] = target;
|
||||
new_targets.append(target);
|
||||
if(!new_targets.contains(target))
|
||||
{
|
||||
new_targets.append(target);
|
||||
}
|
||||
}
|
||||
else if(atype == A)
|
||||
{
|
||||
quint32 addr;
|
||||
resp >> addr;
|
||||
QHostAddress haddr(addr);
|
||||
_AAs.insert(aaddr, haddr.toString());
|
||||
if(!_AAs.contains(aaddr, haddr.toString()))
|
||||
{
|
||||
_AAs.insert(aaddr, haddr.toString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -230,7 +381,9 @@ void IppDiscovery::readPendingDatagrams()
|
|||
return;
|
||||
}
|
||||
qDebug() << "new ipp ptrs" << new_ipp_ptrs;
|
||||
qDebug() << "new ipps ptrs" << new_ipps_ptrs;
|
||||
qDebug() << "ipp ptrs" << _ipp;
|
||||
qDebug() << "ipps ptrs" << _ipps;
|
||||
qDebug() << "rps" << _rps;
|
||||
qDebug() << "ports" << _ports;
|
||||
qDebug() << "new targets" << new_targets;
|
||||
|
@ -238,87 +391,46 @@ void IppDiscovery::readPendingDatagrams()
|
|||
qDebug() << "AAs" << _AAs;
|
||||
qDebug() << "AAAAs" << _AAAAs;
|
||||
|
||||
for(QStringList::Iterator it = new_ipp_ptrs.begin(); it != new_ipp_ptrs.end(); it++)
|
||||
{
|
||||
if(!_ipp.contains(*it))
|
||||
{
|
||||
_ipp.append(*it);
|
||||
}
|
||||
// If pointer does not resolve to a target or is missing information, query about it
|
||||
if( !_targets.contains(*it) || !_ports.contains(*it) || !_rps.contains(*it))
|
||||
{ // if the PTR doesn't already resolve, ask for everything about it
|
||||
sendQuery(ALL, it->split('.'));
|
||||
}
|
||||
}
|
||||
for(QStringList::Iterator it = new_targets.begin(); it != new_targets.end(); it++)
|
||||
// These will send one query per unique new ptr.
|
||||
// some responders doesn't give TXT records for more than one thing at at time :(
|
||||
updateAndQueryPtrs(_ipps, new_ipps_ptrs);
|
||||
updateAndQueryPtrs(_ipp, new_ipp_ptrs);
|
||||
|
||||
QStringList unresolvedAddrs;
|
||||
|
||||
for(QString t : new_targets)
|
||||
{
|
||||
// If target does not resolve to an address, query about it
|
||||
if(!_AAs.contains(*it))
|
||||
if(!_AAs.contains(t))
|
||||
{
|
||||
sendQuery(ALL, it->split('.'));
|
||||
unresolvedAddrs.append(t);
|
||||
}
|
||||
}
|
||||
|
||||
if(!unresolvedAddrs.empty())
|
||||
{
|
||||
sendQuery(A, unresolvedAddrs);
|
||||
}
|
||||
|
||||
}
|
||||
this->update();
|
||||
|
||||
}
|
||||
|
||||
void IppDiscovery::ignoreKnownSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
|
||||
bool IppDiscovery::resolve(QUrl& url)
|
||||
{
|
||||
QList<QSslError> IgnoredSslErrors = {QSslError::NoError,
|
||||
QSslError::SelfSignedCertificate,
|
||||
QSslError::HostNameMismatch,
|
||||
QSslError::UnableToGetLocalIssuerCertificate,
|
||||
QSslError::UnableToVerifyFirstCertificate
|
||||
};
|
||||
QString host = url.host();
|
||||
|
||||
qDebug() << errors;
|
||||
for (QList<QSslError>::const_iterator it = errors.constBegin(); it != errors.constEnd(); it++) {
|
||||
if(!IgnoredSslErrors.contains(it->error())) {
|
||||
qDebug() << "Bad error: " << int(it->error()) << it->error();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// For whatever reason, it doesn't work to pass IgnoredSslErrors here
|
||||
reply->ignoreSslErrors(errors);
|
||||
}
|
||||
|
||||
QImage IppDiscovery::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
|
||||
{ //TODO: consider caching images (doesn't appear to be needed currently)
|
||||
Q_UNUSED(size);
|
||||
Q_UNUSED(requestedSize);
|
||||
qDebug() << "requesting image" << id;
|
||||
|
||||
QImage img;
|
||||
|
||||
QNetworkAccessManager* nam = new QNetworkAccessManager(this);
|
||||
QUrl url(id);
|
||||
qDebug() << url.host() << _AAs;
|
||||
// TODO IPv6
|
||||
if(_AAs.contains(url.host()))
|
||||
{ // TODO: retry potential other IPs
|
||||
url.setHost(_AAs.value(url.host()));
|
||||
}
|
||||
|
||||
QNetworkRequest request(url);
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint " SEAPRINT_VERSION);
|
||||
|
||||
QNetworkReply* reply = nam->get(request);
|
||||
|
||||
QEventLoop el;
|
||||
connect(reply, SIGNAL(finished()),&el,SLOT(quit()));
|
||||
connect(nam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
|
||||
this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList<QSslError>&)));
|
||||
el.exec();
|
||||
|
||||
if (reply->error() == QNetworkReply::NoError)
|
||||
if(host.endsWith("."))
|
||||
{
|
||||
QImageReader imageReader(reply);
|
||||
img = imageReader.read();
|
||||
}
|
||||
|
||||
delete nam;
|
||||
return img;
|
||||
host.chop(1);
|
||||
}
|
||||
|
||||
// TODO IPv6
|
||||
if(_AAs.contains(host))
|
||||
{ // TODO: retry potential other IPs
|
||||
url.setHost(_AAs.value(host));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,37 +1,38 @@
|
|||
#ifndef IPPDISCOVERY_H
|
||||
#define IPPDISCOVERY_H
|
||||
#include <QStringListModel>
|
||||
#include <QQuickImageProvider>
|
||||
#include <QUdpSocket>
|
||||
#include <QMutex>
|
||||
#include <QImageReader>
|
||||
#include <QtNetwork>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QEventLoop>
|
||||
#include "bytestream.h"
|
||||
|
||||
class IppDiscovery : public QStringListModel, public QQuickImageProvider
|
||||
class IppDiscovery : public QStringListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static IppDiscovery* instance();
|
||||
|
||||
Q_PROPERTY(QStringList favourites MEMBER _favourites NOTIFY favouritesChanged)
|
||||
|
||||
Q_INVOKABLE void discover();
|
||||
Q_INVOKABLE void reset();
|
||||
|
||||
bool resolve(QUrl& url);
|
||||
|
||||
signals:
|
||||
void favouritesChanged();
|
||||
void ignoreSslErrorsChanged();
|
||||
|
||||
public slots:
|
||||
void readPendingDatagrams();
|
||||
void cleanUpdate();
|
||||
void update();
|
||||
void ignoreKnownSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||
|
||||
protected:
|
||||
private:
|
||||
static IppDiscovery* m_Instance;
|
||||
|
||||
quint16 _transactionid;
|
||||
|
||||
IppDiscovery();
|
||||
~IppDiscovery();
|
||||
IppDiscovery(const IppDiscovery &);
|
||||
|
@ -39,9 +40,12 @@ private:
|
|||
|
||||
void sendQuery(quint16 qtype, QStringList addr);
|
||||
|
||||
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;
|
||||
void sendQuery(quint16 qtype, QStringList prefixes, QStringList suffixes);
|
||||
|
||||
void updateAndQueryPtrs(QStringList& ptrs, QStringList new_ptrs);
|
||||
|
||||
QStringList _ipp;
|
||||
QStringList _ipps;
|
||||
QMap<QString,QString> _rps;
|
||||
QMap<QString,quint16> _ports;
|
||||
QMap<QString,QString> _targets;
|
||||
|
@ -49,6 +53,8 @@ private:
|
|||
QMultiMap<QString,QString> _AAs;
|
||||
QMultiMap<QString,QString> _AAAAs;
|
||||
|
||||
QMap<QPair<quint16, QString>, QTime> _outstandingQueries;
|
||||
|
||||
QStringList _favourites;
|
||||
QUdpSocket* socket;
|
||||
};
|
||||
|
|
155
src/ippmsg.cpp
155
src/ippmsg.cpp
|
@ -6,8 +6,9 @@ IppMsg::IppMsg()
|
|||
{
|
||||
}
|
||||
|
||||
IppMsg::IppMsg(QJsonObject opAttrs, QJsonObject jobAttrs, quint8 majVsn, quint8 minVsn)
|
||||
IppMsg::IppMsg(Operation operation, QJsonObject opAttrs, QJsonObject jobAttrs, quint8 majVsn, quint8 minVsn)
|
||||
{
|
||||
_operation = operation;
|
||||
_majVsn = majVsn;
|
||||
_minVsn = minVsn;
|
||||
_opAttrs = opAttrs;
|
||||
|
@ -19,10 +20,10 @@ IppMsg::~IppMsg()
|
|||
{
|
||||
}
|
||||
|
||||
IppMsg::IppMsg(QNetworkReply* resp)
|
||||
|
||||
IppMsg::IppMsg(Bytestream& bts)
|
||||
{
|
||||
QByteArray tmp = resp->readAll();
|
||||
Bytestream bts(tmp.constData(), tmp.length());
|
||||
// Bytestream bts(resp.constData(), resp.length());
|
||||
|
||||
quint32 reqId;
|
||||
|
||||
|
@ -76,48 +77,64 @@ QJsonValue IppMsg::consume_value(quint8 tag, Bytestream& data)
|
|||
Q_ASSERT(false);
|
||||
case Integer:
|
||||
case Enum:
|
||||
quint32 tmp_u32;
|
||||
data >> tmp_len >> tmp_u32;
|
||||
{
|
||||
quint32 tmp_u32=0;
|
||||
if(!(data >>= (quint16)0))
|
||||
{
|
||||
data >> (quint16)4 >> tmp_u32;
|
||||
}
|
||||
value = (int)tmp_u32;
|
||||
break;
|
||||
}
|
||||
case Boolean:
|
||||
quint8 tmp_bool;
|
||||
data >> tmp_len >> tmp_bool;
|
||||
{
|
||||
quint8 tmp_bool=0;
|
||||
if(!(data >>= (quint16)0))
|
||||
{
|
||||
data >> (quint16)1 >> tmp_bool;
|
||||
}
|
||||
value = (bool)tmp_bool;
|
||||
break;
|
||||
}
|
||||
case DateTime:
|
||||
{
|
||||
quint16 year;
|
||||
quint8 month, day, hour, minutes, seconds, deci_seconds,
|
||||
plus_minus, utc_h_offset, utc_m_offset;
|
||||
data >> tmp_len >> year >> month >> day >> hour >> minutes >> seconds >> deci_seconds
|
||||
>> plus_minus >> utc_h_offset >> utc_m_offset;
|
||||
QDate date(year, month, day);
|
||||
QTime time(hour, minutes, seconds, deci_seconds*100);
|
||||
int offset_seconds = (plus_minus == '+' ? 1 : -1)*(utc_h_offset*60*60+utc_m_offset*60);
|
||||
value = QDateTime(date, time, Qt::OffsetFromUTC, offset_seconds).toString(Qt::ISODate);
|
||||
QDateTime tmp_datetime;
|
||||
if(!(data >>= (quint16)0))
|
||||
{
|
||||
quint16 year;
|
||||
quint8 month, day, hour, minutes, seconds, deci_seconds,
|
||||
plus_minus, utc_h_offset, utc_m_offset;
|
||||
data >> (quint16)11 >> year >> month >> day >> hour >> minutes >> seconds >> deci_seconds
|
||||
>> plus_minus >> utc_h_offset >> utc_m_offset;
|
||||
QDate date(year, month, day);
|
||||
QTime time(hour, minutes, seconds, deci_seconds*100);
|
||||
int offset_seconds = (plus_minus == '+' ? 1 : -1)*(utc_h_offset*60*60+utc_m_offset*60);
|
||||
tmp_datetime = QDateTime(date, time, Qt::OffsetFromUTC, offset_seconds);
|
||||
}
|
||||
value = tmp_datetime.toString(Qt::ISODate);
|
||||
break;
|
||||
}
|
||||
case Resolution:
|
||||
{
|
||||
qint32 x, y;
|
||||
qint8 units;
|
||||
QJsonObject tmp_res;
|
||||
data >> tmp_len >> x >> y >> units;
|
||||
tmp_res.insert("x", x);
|
||||
tmp_res.insert("y", y);
|
||||
tmp_res.insert("units", units);
|
||||
value = tmp_res;
|
||||
qint32 x=0;
|
||||
qint32 y=0;
|
||||
qint8 units=0;
|
||||
if(!(data >>= (quint16)0))
|
||||
{
|
||||
data >> (quint16)9 >> x >> y >> units;
|
||||
}
|
||||
value = QJsonObject {{"x", x}, {"y", y}, {"units", units}};
|
||||
break;
|
||||
}
|
||||
case IntegerRange:
|
||||
{
|
||||
qint32 low, high;
|
||||
data >> tmp_len >> low >> high;
|
||||
QJsonObject tmp_range;
|
||||
tmp_range.insert("low", low);
|
||||
tmp_range.insert("high", high);
|
||||
value = tmp_range;
|
||||
qint32 low=0;
|
||||
qint32 high=0;
|
||||
if(!(data >>= (quint16)0))
|
||||
{
|
||||
data >> (quint16)8 >> low >> high;
|
||||
}
|
||||
value = QJsonObject {{"low", low}, {"high", high}};
|
||||
break;
|
||||
}
|
||||
case OctetStringUnknown:
|
||||
|
@ -166,7 +183,7 @@ QJsonArray IppMsg::get_unnamed_attributes(Bytestream& data)
|
|||
QJsonArray untag_values(QJsonArray taggedValues)
|
||||
{
|
||||
QJsonArray res;
|
||||
foreach(QJsonValue it, taggedValues)
|
||||
for(QJsonValue it : taggedValues)
|
||||
{
|
||||
res.append(it.toObject()["value"]);
|
||||
}
|
||||
|
@ -258,22 +275,21 @@ QString IppMsg::consume_attribute(QJsonObject& attrs, Bytestream& data)
|
|||
name = tmp_str.c_str();
|
||||
|
||||
taggedValue = consume_value(tag, data);
|
||||
|
||||
QJsonArray unnamed = get_unnamed_attributes(data);
|
||||
|
||||
// qDebug() << name0 << tag << tmp_len << value << unnamed;
|
||||
|
||||
if(tag == BeginCollection)
|
||||
{
|
||||
// qDebug() << "Unnamed attrs for collection" << unnamed;
|
||||
|
||||
QJsonValue collected = collect_attributes(unnamed);
|
||||
// qDebug() << "collected" << collected;
|
||||
taggedValue = QJsonObject {{"tag", tag}, {"value", collected}};
|
||||
}
|
||||
|
||||
bool noList = (tag == Boolean || tag == IntegerRange);
|
||||
bool forceArray = ((name.endsWith("-supported") || name == "printer-icons") && !noList);
|
||||
bool forceArray = (!noList && (name.startsWith("marker-")
|
||||
|| name.startsWith("printer-firmware")
|
||||
|| name.endsWith("-supported")
|
||||
|| name == "printer-icons"
|
||||
|| name == "media-ready"
|
||||
|| name.endsWith("-reasons")));
|
||||
|
||||
if(!unnamed.empty() || forceArray)
|
||||
{
|
||||
|
@ -288,13 +304,13 @@ QString IppMsg::consume_attribute(QJsonObject& attrs, Bytestream& data)
|
|||
return name;
|
||||
}
|
||||
|
||||
QByteArray IppMsg::encode(Operation op)
|
||||
Bytestream IppMsg::encode()
|
||||
{
|
||||
Bytestream ipp;
|
||||
|
||||
ipp << _majVsn << _minVsn;
|
||||
|
||||
ipp << quint16(op);
|
||||
ipp << quint16(_operation);
|
||||
ipp << _reqid++;
|
||||
|
||||
|
||||
|
@ -304,11 +320,15 @@ QByteArray IppMsg::encode(Operation op)
|
|||
QStringList InitialAttrs = {"attributes-charset",
|
||||
"attributes-natural-language",
|
||||
"printer-uri",
|
||||
"job-id",
|
||||
"requesting-user-name"};
|
||||
foreach(QString key, InitialAttrs)
|
||||
for(QString key : InitialAttrs)
|
||||
{
|
||||
QJsonObject val = _opAttrs.take(key).toObject();
|
||||
encode_attr(ipp, val["tag"].toInt(), key, val["value"]);
|
||||
if(_opAttrs.find(key) != _opAttrs.end())
|
||||
{
|
||||
QJsonObject val = _opAttrs.take(key).toObject();
|
||||
encode_attr(ipp, val["tag"].toInt(), key, val["value"]);
|
||||
}
|
||||
}
|
||||
for(QJsonObject::iterator it = _opAttrs.begin(); it != _opAttrs.end(); it++)
|
||||
{ // encode any remaining op-attrs
|
||||
|
@ -319,7 +339,7 @@ QByteArray IppMsg::encode(Operation op)
|
|||
{
|
||||
QJsonObject tmpObj = ait->toObject();
|
||||
if (!tmpObj.isEmpty()) {
|
||||
ipp << quint8(2);
|
||||
ipp << quint8(JobAttrs);
|
||||
for(QJsonObject::iterator it = tmpObj.begin(); it != tmpObj.end(); it++)
|
||||
{
|
||||
QJsonObject val = it.value().toObject();
|
||||
|
@ -328,9 +348,9 @@ QByteArray IppMsg::encode(Operation op)
|
|||
}
|
||||
}
|
||||
|
||||
ipp << quint8(3);
|
||||
ipp << quint8(EndAttrs);
|
||||
|
||||
return QByteArray((char*)(ipp.raw()), ipp.size());
|
||||
return ipp;
|
||||
}
|
||||
|
||||
void IppMsg::encode_attr(Bytestream& msg, quint8 tag, QString name, QJsonValue value, bool inCollection)
|
||||
|
@ -342,7 +362,25 @@ void IppMsg::encode_attr(Bytestream& msg, quint8 tag, QString name, QJsonValue v
|
|||
name = "";
|
||||
}
|
||||
msg << tag << quint16(name.length()) << name.toStdString();
|
||||
if(value.isArray())
|
||||
{
|
||||
QJsonArray array = value.toArray();
|
||||
value = array.takeAt(0);
|
||||
encode_value(msg, tag, value);
|
||||
for(QJsonValue v : array)
|
||||
{
|
||||
msg << tag << quint16(0);
|
||||
encode_value(msg, tag, v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
encode_value(msg, tag, value);
|
||||
}
|
||||
}
|
||||
|
||||
void IppMsg::encode_value(Bytestream& msg, quint8 tag, QJsonValue value)
|
||||
{
|
||||
|
||||
switch (tag) {
|
||||
case OpAttrs:
|
||||
|
@ -359,7 +397,7 @@ void IppMsg::encode_attr(Bytestream& msg, quint8 tag, QString name, QJsonValue v
|
|||
}
|
||||
case Boolean:
|
||||
{
|
||||
quint32 tmp_u8 = value.toBool();
|
||||
quint8 tmp_u8 = value.toBool();
|
||||
msg << (quint16)1 << tmp_u8;
|
||||
break;
|
||||
}
|
||||
|
@ -386,19 +424,11 @@ void IppMsg::encode_attr(Bytestream& msg, quint8 tag, QString name, QJsonValue v
|
|||
case BeginCollection:
|
||||
{
|
||||
msg << (quint16)0; // length of value
|
||||
if(value.isObject())
|
||||
QJsonObject collection = value.toObject();
|
||||
for(QString key : collection.keys())
|
||||
{
|
||||
QJsonObject collection = value.toObject();
|
||||
foreach(QString key, collection.keys())
|
||||
{
|
||||
encode_attr(msg, collection[key].toObject()["tag"].toInt(), key,
|
||||
collection[key].toObject()["value"], true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO add support for 1-setOf in collections
|
||||
Q_ASSERT("FIXME-array");
|
||||
encode_attr(msg, collection[key].toObject()["tag"].toInt(), key,
|
||||
collection[key].toObject()["value"], true);
|
||||
}
|
||||
msg << (quint8)EndCollection << (quint16)0 << (quint16)0;
|
||||
break;
|
||||
|
@ -426,3 +456,8 @@ void IppMsg::encode_attr(Bytestream& msg, quint8 tag, QString name, QJsonValue v
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void IppMsg::setOpAttr(QString name, IppMsg::IppTag type, QJsonValue value)
|
||||
{
|
||||
_opAttrs.insert(name, QJsonObject {{"tag", type}, {"value", value}});
|
||||
}
|
||||
|
|
29
src/ippmsg.h
29
src/ippmsg.h
|
@ -1,15 +1,14 @@
|
|||
#ifndef IPP_PROTO_H
|
||||
#define IPP_PROTO_H
|
||||
#ifndef IPP_MSG_H
|
||||
#define IPP_MSG_H
|
||||
|
||||
#include "bytestream.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QObject>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QDate>
|
||||
#include <QTime>
|
||||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
#include <QtNetwork>
|
||||
#include <QNetworkReply>
|
||||
#include <QIODevice>
|
||||
|
||||
class IppMsg
|
||||
{
|
||||
|
@ -62,20 +61,23 @@ public:
|
|||
RestartJob = 0x000E,
|
||||
PausePrinter = 0x0010,
|
||||
ResumePrinter = 0x0011,
|
||||
PurgeJobs = 0x0012
|
||||
PurgeJobs = 0x0012,
|
||||
IdentifyPrinter = 0x003C
|
||||
};
|
||||
|
||||
explicit IppMsg();
|
||||
explicit IppMsg(QNetworkReply* resp);
|
||||
IppMsg(QJsonObject opAttrs, QJsonObject jobAttrs=QJsonObject(), quint8 majVsn=1, quint8 minVsn=1);
|
||||
explicit IppMsg(Bytestream& resp);
|
||||
IppMsg(Operation operation, QJsonObject opAttrs, QJsonObject jobAttrs=QJsonObject(), quint8 majVsn=1, quint8 minVsn=1);
|
||||
IppMsg(const IppMsg& other) = default;
|
||||
~IppMsg();
|
||||
|
||||
QByteArray encode(Operation op);
|
||||
Bytestream encode();
|
||||
QJsonObject getPrinterAttrs() {return _printerAttrs;}
|
||||
QJsonArray getJobAttrs() {return _jobAttrs;}
|
||||
QJsonObject getOpAttrs() {return _opAttrs;}
|
||||
|
||||
void setOpAttr(QString name, IppMsg::IppTag type, QJsonValue value);
|
||||
|
||||
quint16 getStatus() {return _status;}
|
||||
|
||||
|
||||
|
@ -86,6 +88,9 @@ private:
|
|||
QJsonValue collect_attributes(QJsonArray& attrs);
|
||||
QString consume_attribute(QJsonObject& attrs, Bytestream& data);
|
||||
void encode_attr(Bytestream& msg, quint8 tag, QString name, QJsonValue value, bool subCollection=false);
|
||||
void encode_value(Bytestream& msg, quint8 tag, QJsonValue value);
|
||||
|
||||
Operation _operation;
|
||||
|
||||
quint8 _majVsn;
|
||||
quint8 _minVsn;
|
||||
|
@ -99,4 +104,4 @@ private:
|
|||
static quint32 _reqid;
|
||||
};
|
||||
|
||||
#endif // IPP_PROTO_H
|
||||
#endif // IPP_MSG_H
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,22 +1,30 @@
|
|||
#ifndef IPPPRINTER_H
|
||||
#define IPPPRINTER_H
|
||||
|
||||
#include <QtNetwork>
|
||||
#include <QNetworkAccessManager>
|
||||
#include "ippmsg.h"
|
||||
#include "convertworker.h"
|
||||
#include "printerworker.h"
|
||||
#include "curlrequester.h"
|
||||
#include <QImage>
|
||||
|
||||
|
||||
class IppPrinter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class PrinterWorker;
|
||||
|
||||
Q_PROPERTY(QString url READ getUrl WRITE setUrl NOTIFY urlChanged)
|
||||
Q_PROPERTY(QJsonObject attrs MEMBER _attrs NOTIFY attrsChanged)
|
||||
Q_PROPERTY(QJsonObject jobAttrs MEMBER _jobAttrs NOTIFY jobAttrsChanged)
|
||||
Q_PROPERTY(QJsonArray jobs MEMBER _jobs NOTIFY jobsChanged)
|
||||
Q_PROPERTY(QJsonObject strings MEMBER _strings NOTIFY stringsChanged)
|
||||
Q_PROPERTY(QImage icon MEMBER _icon NOTIFY iconChanged)
|
||||
Q_PROPERTY(QStringList additionalDocumentFormats MEMBER _additionalDocumentFormats NOTIFY additionalDocumentFormatsChanged)
|
||||
Q_PROPERTY(QString busyMessage MEMBER _busyMessage NOTIFY busyMessageChanged)
|
||||
Q_PROPERTY(QString progress MEMBER _progress NOTIFY progressChanged)
|
||||
|
||||
Q_PROPERTY(bool correctSuffix READ correctSuffix NOTIFY attrsChanged)
|
||||
Q_PROPERTY(QStringList suffixes READ suffixes NOTIFY attrsChanged)
|
||||
|
||||
public:
|
||||
IppPrinter();
|
||||
|
@ -30,6 +38,10 @@ public:
|
|||
|
||||
Q_INVOKABLE bool getJobs();
|
||||
Q_INVOKABLE bool cancelJob(qint32 jobId);
|
||||
Q_INVOKABLE bool identify();
|
||||
|
||||
bool correctSuffix();
|
||||
QStringList suffixes();
|
||||
|
||||
signals:
|
||||
void urlChanged();
|
||||
|
@ -37,68 +49,90 @@ signals:
|
|||
void jobAttrsChanged();
|
||||
void jobsChanged();
|
||||
|
||||
void stringsChanged();
|
||||
void iconChanged();
|
||||
|
||||
void jobFinished(bool status);
|
||||
void cancelStatus(bool status);
|
||||
|
||||
void doConvertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile,
|
||||
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||
quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble,
|
||||
quint32 PageRangeLow, quint32 PageRangeHigh);
|
||||
void doDoGetPrinterAttributes(Bytestream msg);
|
||||
void doGetJobs(Bytestream msg);
|
||||
void doCancelJob(Bytestream msg);
|
||||
void doIdentify(Bytestream msg);
|
||||
|
||||
void doConvertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile,
|
||||
QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||
quint32 HwResX, quint32 HwResY);
|
||||
void doJustUpload(QString filename, Bytestream header);
|
||||
void doFixupPlaintext(QString filename, Bytestream header);
|
||||
void doPrintImageAsImage(QString filename, Bytestream header, QString targetFormat);
|
||||
|
||||
void doConvertPdf(QString filename, Bytestream header, PrintParameters Params);
|
||||
|
||||
void doConvertImage(QString filename, Bytestream header, PrintParameters Params, QMargins margins);
|
||||
|
||||
void doConvertOfficeDocument(QString filename, Bytestream header, PrintParameters Params);
|
||||
|
||||
void doConvertPlaintext(QString filename, Bytestream header, PrintParameters Params);
|
||||
|
||||
void doPrint(QString filename, QString mimeType, QString targetFormat, IppMsg job, PrintParameters Params, QMargins margins);
|
||||
void doPrint2(QString filename, QString mimeType, QString targetFormat, IppMsg createJob, IppMsg sendDocument, PrintParameters Params, QMargins margins);
|
||||
|
||||
void doGetStrings(QUrl url);
|
||||
void doGetImage(QUrl url);
|
||||
|
||||
void additionalDocumentFormatsChanged();
|
||||
void busyMessageChanged();
|
||||
void progressChanged();
|
||||
|
||||
public slots:
|
||||
void print(QJsonObject attrs, QString file,
|
||||
bool alwaysConvert, bool removeRedundantAttributesForRaster, bool alwaysUseMediaCol);
|
||||
|
||||
void print(QJsonObject attrs, QString file);
|
||||
|
||||
void onUrlChanged();
|
||||
void getPrinterAttributesFinished(QNetworkReply* reply);
|
||||
void printRequestFinished(QNetworkReply* reply);
|
||||
void getJobsRequestFinished(QNetworkReply* reply);
|
||||
void cancelJobFinished(QNetworkReply* reply);
|
||||
void MaybeGetStrings();
|
||||
void MaybeGetIcon(bool retry=false);
|
||||
void UpdateAdditionalDocumentFormats();
|
||||
void getPrinterAttributesFinished(CURLcode res, Bytestream data);
|
||||
void printRequestFinished(CURLcode res, Bytestream data);
|
||||
void getJobsRequestFinished(CURLcode res, Bytestream data);
|
||||
void cancelJobFinished(CURLcode res, Bytestream data);
|
||||
void identifyFinished(CURLcode res, Bytestream data);
|
||||
|
||||
void ignoreKnownSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||
void getStringsFinished(CURLcode res, Bytestream data);
|
||||
void getImageFinished(CURLcode res, Bytestream data);
|
||||
|
||||
void convertDone(QNetworkRequest request, QTemporaryFile* data);
|
||||
void convertFailed(QString message);
|
||||
|
||||
private:
|
||||
QUrl _url;
|
||||
QUrl httpUrl();
|
||||
void resolveUrl(QUrl& url);
|
||||
|
||||
QJsonObject opAttrs();
|
||||
|
||||
void adjustRasterSettings(QString filename, QString mimeType, QJsonObject& jobAttrs, PrintParameters& Params);
|
||||
|
||||
void setBusyMessage(QString msg);
|
||||
void setProgress(qint64 sent, qint64 total);
|
||||
|
||||
QJsonValue getAttrOrDefault(QJsonObject jobAttrs, QString name);
|
||||
bool isAllowedAddress(QUrl addr);
|
||||
|
||||
IppMsg mk_msg(QJsonObject opAttrs, QJsonObject jobAttrs=QJsonObject());
|
||||
QJsonValue getAttrOrDefault(QJsonObject jobAttrs, QString name, QString subkey = "");
|
||||
|
||||
QNetworkAccessManager* _nam;
|
||||
QNetworkAccessManager* _jobs_nam;
|
||||
QNetworkAccessManager* _job_cancel_nam;
|
||||
QNetworkAccessManager* _print_nam;
|
||||
IppMsg mk_msg(IppMsg::Operation operation, QJsonObject opAttrs, QJsonObject jobAttrs=QJsonObject());
|
||||
|
||||
QJsonObject _attrs;
|
||||
QJsonObject _jobAttrs;
|
||||
QJsonArray _jobs;
|
||||
|
||||
QJsonObject _strings;
|
||||
QImage _icon;
|
||||
|
||||
QStringList _additionalDocumentFormats;
|
||||
|
||||
QString _busyMessage;
|
||||
QString _progress;
|
||||
|
||||
QThread _workerThread;
|
||||
ConvertWorker* _worker;
|
||||
PrinterWorker* _worker;
|
||||
|
||||
bool _iconRetried = false;
|
||||
};
|
||||
|
||||
#endif // IPPPRINTER_H
|
||||
|
|
|
@ -1,4 +1,33 @@
|
|||
#include "mimer.h"
|
||||
#include <QDebug>
|
||||
|
||||
const QString Mimer::OctetStream = "application/octet-stream";
|
||||
|
||||
const QString Mimer::PDF = "application/pdf";
|
||||
const QString Mimer::Postscript = "application/postscript";
|
||||
const QString Mimer::PWG = "image/pwg-raster";
|
||||
const QString Mimer::URF = "image/urf";
|
||||
|
||||
const QString Mimer::PNG = "image/png";
|
||||
const QString Mimer::GIF = "image/gif";
|
||||
const QString Mimer::JPEG = "image/jpeg";
|
||||
const QString Mimer::TIFF = "image/tiff";
|
||||
const QString Mimer::SVG = "image/svg+xml";
|
||||
const QString Mimer::RBMP = "image/reverse-encoding-bmp";
|
||||
|
||||
const QString Mimer::DOC = "application/msword";
|
||||
const QString Mimer::DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
||||
const QString Mimer::RTF = "text/rtf";
|
||||
const QString Mimer::RTF_APP = "application/rtf";
|
||||
const QString Mimer::ODT = "application/vnd.oasis.opendocument.text";
|
||||
const QString Mimer::PPT = "application/vnd.ms-powerpoint";
|
||||
const QString Mimer::PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
||||
const QString Mimer::ODP = "application/vnd.oasis.opendocument.presentation";
|
||||
|
||||
const QString Mimer::Plaintext = "text/plain";
|
||||
|
||||
const QStringList Mimer::RasterFormats = {PWG, URF};
|
||||
const QStringList Mimer::OfficeFormats = {DOC, DOCX, RTF, RTF_APP, ODT, PPT, PPTX, ODP};
|
||||
|
||||
Mimer::Mimer()
|
||||
{
|
||||
|
@ -24,5 +53,14 @@ Mimer* Mimer::instance()
|
|||
}
|
||||
|
||||
QString Mimer::get_type(QString filename) {
|
||||
return _db.mimeTypeForFile(filename).name();
|
||||
QString type = _db.mimeTypeForFile(filename).name();
|
||||
qDebug() << "MimeType:" << type;
|
||||
if(type == PDF || type == Postscript || type == Plaintext || isImage(type) || isOffice(type))
|
||||
{
|
||||
return type;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
69
src/mimer.h
69
src/mimer.h
|
@ -12,6 +12,75 @@ class Mimer : public QObject
|
|||
public:
|
||||
static Mimer* instance();
|
||||
Q_INVOKABLE QString get_type(QString filename);
|
||||
|
||||
Q_PROPERTY(const QString OctetStream MEMBER OctetStream CONSTANT);
|
||||
|
||||
Q_PROPERTY(const QString PDF MEMBER PDF CONSTANT);
|
||||
Q_PROPERTY(const QString Postscript MEMBER Postscript CONSTANT);
|
||||
Q_PROPERTY(const QString PWG MEMBER PWG CONSTANT);
|
||||
Q_PROPERTY(const QString URF MEMBER URF CONSTANT);
|
||||
|
||||
Q_PROPERTY(const QString PNG MEMBER PNG CONSTANT);
|
||||
Q_PROPERTY(const QString GIF MEMBER GIF CONSTANT);
|
||||
Q_PROPERTY(const QString JPEG MEMBER JPEG CONSTANT);
|
||||
Q_PROPERTY(const QString TIFF MEMBER TIFF CONSTANT);
|
||||
Q_PROPERTY(const QString SVG MEMBER SVG CONSTANT);
|
||||
Q_PROPERTY(const QString RBMP MEMBER RBMP CONSTANT);
|
||||
|
||||
Q_PROPERTY(const QString DOC MEMBER DOC CONSTANT);
|
||||
Q_PROPERTY(const QString DOCX MEMBER DOCX CONSTANT);
|
||||
Q_PROPERTY(const QString RTF MEMBER RTF CONSTANT);
|
||||
Q_PROPERTY(const QString ODT MEMBER ODT CONSTANT);
|
||||
Q_PROPERTY(const QString PPT MEMBER PPT CONSTANT);
|
||||
Q_PROPERTY(const QString PPTX MEMBER PPTX CONSTANT);
|
||||
Q_PROPERTY(const QString ODP MEMBER ODP CONSTANT);
|
||||
|
||||
|
||||
Q_PROPERTY(const QString Plaintext MEMBER Plaintext CONSTANT);
|
||||
|
||||
Q_PROPERTY(const QStringList OfficeFormats MEMBER OfficeFormats CONSTANT);
|
||||
|
||||
static const QString OctetStream;
|
||||
|
||||
static const QString PDF;
|
||||
static const QString Postscript;
|
||||
static const QString PWG;
|
||||
static const QString URF;
|
||||
|
||||
static const QString PNG;
|
||||
static const QString GIF;
|
||||
static const QString JPEG;
|
||||
static const QString TIFF;
|
||||
static const QString SVG;
|
||||
static const QString RBMP;
|
||||
|
||||
static const QString DOC;
|
||||
static const QString DOCX;
|
||||
static const QString RTF;
|
||||
static const QString RTF_APP;
|
||||
static const QString ODT;
|
||||
static const QString PPT;
|
||||
static const QString PPTX;
|
||||
static const QString ODP;
|
||||
|
||||
static const QString Plaintext;
|
||||
|
||||
static const QStringList RasterFormats;
|
||||
static const QStringList OfficeFormats;
|
||||
|
||||
Q_INVOKABLE static bool isImage(QString mimeType)
|
||||
{
|
||||
return mimeType.startsWith("image/") && ! isRaster(mimeType);
|
||||
}
|
||||
Q_INVOKABLE static bool isRaster(QString mimeType)
|
||||
{
|
||||
return RasterFormats.contains(mimeType);
|
||||
}
|
||||
Q_INVOKABLE static bool isOffice(QString mimeType)
|
||||
{
|
||||
return OfficeFormats.contains(mimeType);
|
||||
}
|
||||
|
||||
private:
|
||||
Mimer();
|
||||
static Mimer* m_Instance;
|
||||
|
|
60
src/overrider.cpp
Normal file
60
src/overrider.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
#include "overrider.h"
|
||||
#include <QMutex>
|
||||
#include <QStandardPaths>
|
||||
#include <QtDebug>
|
||||
|
||||
Overrider::Overrider()
|
||||
{
|
||||
QFile file(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)+"/overrides");
|
||||
if(file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QJsonDocument JsonDocument = QJsonDocument::fromJson(file.readAll());
|
||||
|
||||
_overrides = JsonDocument.object();
|
||||
qDebug() << "overides loaded" << _overrides;
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
Overrider::~Overrider() {
|
||||
}
|
||||
|
||||
Overrider* Overrider::m_Instance = nullptr;
|
||||
|
||||
Overrider* Overrider::instance()
|
||||
{
|
||||
static QMutex mutex;
|
||||
if (!m_Instance)
|
||||
{
|
||||
mutex.lock();
|
||||
|
||||
if (!m_Instance)
|
||||
m_Instance = new Overrider();
|
||||
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
return m_Instance;
|
||||
}
|
||||
|
||||
bool Overrider::apply(QJsonObject& attrs)
|
||||
{
|
||||
bool applied = false;
|
||||
for(const QString& key : _overrides.keys())
|
||||
{
|
||||
if(attrs.contains(key))
|
||||
{
|
||||
QString match = attrs[key].toObject()["value"].toString();
|
||||
if(match != "" && _overrides[key].toObject().contains(match))
|
||||
{
|
||||
QJsonObject overrideden_data = _overrides[key].toObject()[match].toObject();
|
||||
for(const QString& o_key : overrideden_data.keys())
|
||||
{
|
||||
attrs.insert(o_key, overrideden_data[o_key]);
|
||||
}
|
||||
applied=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return applied;
|
||||
}
|
24
src/overrider.h
Normal file
24
src/overrider.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef OVERRIDER_H
|
||||
#define OVERRIDER_H
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QFile>
|
||||
|
||||
class Overrider
|
||||
{
|
||||
public:
|
||||
static Overrider* instance();
|
||||
bool apply(QJsonObject& attrs);
|
||||
|
||||
private:
|
||||
Overrider();
|
||||
~Overrider();
|
||||
Overrider(const Overrider &);
|
||||
Overrider& operator=(const Overrider &);
|
||||
|
||||
static Overrider* m_Instance;
|
||||
QJsonObject _overrides;
|
||||
};
|
||||
|
||||
#endif // OVERRIDER_H
|
236
src/papersizes.h
236
src/papersizes.h
|
@ -1,209 +1,41 @@
|
|||
#ifndef PAPERSIZES_H
|
||||
#define PAPERSIZES_H
|
||||
#include <QMap>
|
||||
#include <QPair>
|
||||
#include <QSizeF>
|
||||
|
||||
static QMap<QString, QString> CalligraPaperSizes =
|
||||
{{"iso_a0_841x1189mm", "A0"},
|
||||
{"iso_a1_594x841mm", "A1"},
|
||||
{"iso_a2_420x594mm", "A2"},
|
||||
{"iso_a3_297x420mm", "A3"},
|
||||
{"iso_a4_210x297mm", "A4"},
|
||||
{"iso_a5_148x210mm", "A5"},
|
||||
{"iso_a6_105x148mm", "A6"},
|
||||
{"iso_a7_74x105mm", "A7"},
|
||||
{"iso_a8_52x74mm", "A8"},
|
||||
{"iso_a9_37x52mm", "A9"},
|
||||
{"iso_b0_1000x1414mm", "B0"},
|
||||
{"iso_b1_707x1000mm", "B1"},
|
||||
{"iso_b2_500x707mm", "B2"},
|
||||
{"iso_b3_353x500mm", "B3"},
|
||||
{"iso_b4_250x353mm", "B4"},
|
||||
{"iso_b5_176x250mm", "B5"},
|
||||
{"iso_b6_125x176mm", "B6"},
|
||||
{"iso_b7_88x125mm", "B7"},
|
||||
{"iso_b8_62x88mm", "B8"},
|
||||
{"iso_b9_44x62mm", "B9"},
|
||||
{"iso_b10_31x44mm", "B10"},
|
||||
{"iso_c5_162x229mm", "C5E"},
|
||||
{"na_number-10_4.125x9.5in", "Comm10E"},
|
||||
{"iso_dl_110x220mm", "DLE"},
|
||||
{"na_executive_7.25x10.5in", "Executive"},
|
||||
{"om_folio_210x330mm", "Folio"},
|
||||
{"na_ledger_11x17in", "Ledger"},
|
||||
{"na_legal_8.5x14in", "Legal"},
|
||||
{"na_letter_8.5x11in", "Letter"},
|
||||
{"na_ledger_11x17in", "Tabloid"} // Dimension match
|
||||
};
|
||||
|
||||
static QMap<QString, QPair<float,float>> PaperSizes =
|
||||
{{"asme_f_28x40in", {711.20, 1016.00}},
|
||||
{"iso_2a0_1189x1682mm", {1189.00, 1682.00}},
|
||||
{"iso_a0_841x1189mm", {841.00, 1189.00}},
|
||||
{"iso_a0x3_1189x2523mm", {1189.00, 2523.00}},
|
||||
{"iso_a10_26x37mm", {26.00, 37.00}},
|
||||
{"iso_a1_594x841mm", {594.00, 841.00}},
|
||||
{"iso_a1x3_841x1783mm", {841.00, 1783.00}},
|
||||
{"iso_a1x4_841x2378mm", {841.00, 2378.00}},
|
||||
{"iso_a2_420x594mm", {420.00, 594.00}},
|
||||
{"iso_a2x3_594x1261mm", {594.00, 1261.00}},
|
||||
{"iso_a2x4_594x1682mm", {594.00, 1682.00}},
|
||||
{"iso_a2x5_594x2102mm", {594.00, 2102.00}},
|
||||
{"iso_a3-extra_322x445mm", {322.00, 445.00}},
|
||||
{"iso_a3_297x420mm", {297.00, 420.00}},
|
||||
{"iso_a3x3_420x891mm", {420.00, 891.00}},
|
||||
{"iso_a3x4_420x1189mm", {420.00, 1189.00}},
|
||||
{"iso_a3x5_420x1486mm", {420.00, 1486.00}},
|
||||
{"iso_a3x6_420x1783mm", {420.00, 1783.00}},
|
||||
{"iso_a3x7_420x2080mm", {420.00, 2080.00}},
|
||||
{"iso_a4-extra_235.5x322.3m", {235.50, 322.30}},
|
||||
{"iso_a4-tab_225x297mm", {225.00, 297.00}},
|
||||
{"iso_a4_210x297mm", {210.00, 297.00}},
|
||||
{"iso_a4x3_297x630mm", {297.00, 630.00}},
|
||||
{"iso_a4x4_297x841mm", {297.00, 841.00}},
|
||||
{"iso_a4x5_297x1051mm", {297.00, 1051.00}},
|
||||
{"iso_a4x6_297x1261mm", {297.00, 1261.00}},
|
||||
{"iso_a4x7_297x1471mm", {297.00, 1471.00}},
|
||||
{"iso_a4x8_297x1682mm", {297.00, 1682.00}},
|
||||
{"iso_a4x9_297x1892mm", {297.00, 1892.00}},
|
||||
{"iso_a5-extra_174x235mm", {174.00, 235.00}},
|
||||
{"iso_a5_148x210mm", {148.00, 210.00}},
|
||||
{"iso_a6_105x148mm", {105.00, 148.00}},
|
||||
{"iso_a7_74x105mm", {74.00, 105.00}},
|
||||
{"iso_a8_52x74mm", {52.00, 74.00}},
|
||||
{"iso_a9_37x52mm", {37.00, 52.00}},
|
||||
{"iso_b0_1000x1414mm", {1000.00, 1414.00}},
|
||||
{"iso_b10_31x44mm", {31.00, 44.00}},
|
||||
{"iso_b1_707x1000mm", {707.00, 1000.00}},
|
||||
{"iso_b2_500x707mm", {500.00, 707.00}},
|
||||
{"iso_b3_353x500mm", {353.00, 500.00}},
|
||||
{"iso_b4_250x353mm", {250.00, 353.00}},
|
||||
{"iso_b5-extra_201x276mm", {201.00, 276.00}},
|
||||
{"iso_b5_176x250mm", {176.00, 250.00}},
|
||||
{"iso_b6_125x176mm", {125.00, 176.00}},
|
||||
{"iso_b6c4_125x324mm", {125.00, 324.00}},
|
||||
{"iso_b7_88x125mm", {88.00, 125.00}},
|
||||
{"iso_b8_62x88mm", {62.00, 88.00}},
|
||||
{"iso_b9_44x62mm", {44.00, 62.00}},
|
||||
{"iso_c0_917x1297mm", {917.00, 1297.00}},
|
||||
{"iso_c10_28x40mm", {28.00, 40.00}},
|
||||
{"iso_c1_648x917mm", {648.00, 917.00}},
|
||||
{"iso_c2_458x648mm", {458.00, 648.00}},
|
||||
{"iso_c3_324x458mm", {324.00, 458.00}},
|
||||
{"iso_c4_229x324mm", {229.00, 324.00}},
|
||||
{"iso_c5_162x229mm", {162.00, 229.00}},
|
||||
{"iso_c6_114x162mm", {114.00, 162.00}},
|
||||
{"iso_c6c5_114x229mm", {114.00, 229.00}},
|
||||
{"iso_c7_81x114mm", {81.00, 114.00}},
|
||||
{"iso_c7c6_81x162mm", {81.00, 162.00}},
|
||||
{"iso_c8_57x81mm", {57.00, 81.00}},
|
||||
{"iso_c9_40x57mm", {40.00, 57.00}},
|
||||
{"iso_dl_110x220mm", {110.00, 220.00}},
|
||||
{"iso_id-1_53.98x85.6mm", {53.98, 85.60}},
|
||||
{"iso_id-3_88x125mm", {88.00, 125.00}},
|
||||
{"iso_ra0_860x1220mm", {860.00, 1220.00}},
|
||||
{"iso_ra1_610x860mm", {610.00, 860.00}},
|
||||
{"iso_ra2_430x610mm", {430.00, 610.00}},
|
||||
{"iso_ra3_305x430mm", {305.00, 430.00}},
|
||||
{"iso_ra4_215x305mm", {215.00, 305.00}},
|
||||
{"iso_sra0_900x1280mm", {900.00, 1280.00}},
|
||||
{"iso_sra1_640x900mm", {640.00, 900.00}},
|
||||
{"iso_sra2_450x640mm", {450.00, 640.00}},
|
||||
{"iso_sra3_320x450mm", {320.00, 450.00}},
|
||||
{"iso_sra4_225x320mm", {225.00, 320.00}},
|
||||
{"jis_b0_1030x1456mm", {1030.00, 1456.00}},
|
||||
{"jis_b10_32x45mm", {32.00, 45.00}},
|
||||
{"jis_b1_728x1030mm", {728.00, 1030.00}},
|
||||
{"jis_b2_515x728mm", {515.00, 728.00}},
|
||||
{"jis_b3_364x515mm", {364.00, 515.00}},
|
||||
{"jis_b4_257x364mm", {257.00, 364.00}},
|
||||
{"jis_b5_182x257mm", {182.00, 257.00}},
|
||||
{"jis_b6_128x182mm", {128.00, 182.00}},
|
||||
{"jis_b7_91x128mm", {91.00, 128.00}},
|
||||
{"jis_b8_64x91mm", {64.00, 91.00}},
|
||||
{"jis_b9_45x64mm", {45.00, 64.00}},
|
||||
{"jis_exec_216x330mm", {216.00, 330.00}},
|
||||
{"jpn_chou2_111.1x146mm", {111.10, 146.00}},
|
||||
{"jpn_chou3_120x235mm", {120.00, 235.00}},
|
||||
{"jpn_chou40_90x225mm", {90.00, 225.00}},
|
||||
{"jpn_chou4_90x205mm", {90.00, 205.00}},
|
||||
{"jpn_hagaki_100x148mm", {100.00, 148.00}},
|
||||
{"jpn_kahu_240x322.1mm", {240.00, 322.10}},
|
||||
{"jpn_kaku1_270x382mm", {270.00, 382.00}},
|
||||
{"jpn_kaku2_240x332mm", {240.00, 332.00}},
|
||||
{"jpn_kaku3_216x277mm", {216.00, 277.00}},
|
||||
{"jpn_kaku4_197x267mm", {197.00, 267.00}},
|
||||
{"jpn_kaku5_190x240mm", {190.00, 240.00}},
|
||||
{"jpn_kaku7_142x205mm", {142.00, 205.00}},
|
||||
{"jpn_kaku8_119x197mm", {119.00, 197.00}},
|
||||
{"jpn_oufuku_148x200mm", {148.00, 200.00}},
|
||||
{"jpn_you4_105x235mm", {105.00, 235.00}},
|
||||
{"na_10x11_10x11in", {254.00, 279.40}},
|
||||
{"na_10x13_10x13in", {254.00, 330.20}},
|
||||
{"na_10x14_10x14in", {254.00, 355.60}},
|
||||
{"na_10x15_10x15in", {254.00, 381.00}},
|
||||
{"na_11x12_11x12in", {279.40, 304.80}},
|
||||
{"na_11x15_11x15in", {279.40, 381.00}},
|
||||
{"na_12x19_12x19in", {304.80, 482.60}},
|
||||
{"na_5x7_5x7in", {127.00, 177.80}},
|
||||
{"na_6x9_6x9in", {152.40, 228.60}},
|
||||
{"na_7x9_7x9in", {177.80, 228.60}},
|
||||
{"na_9x11_9x11in", {228.60, 279.40}},
|
||||
{"na_a2_4.375x5.75in", {111.12, 146.05}},
|
||||
{"na_arch-a_9x12in", {228.60, 304.80}},
|
||||
{"na_arch-b_12x18in", {304.80, 457.20}},
|
||||
{"na_arch-c_18x24in", {457.20, 609.60}},
|
||||
{"na_arch-d_24x36in", {609.60, 914.40}},
|
||||
{"na_arch-e2_26x38in", {660.40, 965.20}},
|
||||
{"na_arch-e3_27x39in", {685.80, 990.60}},
|
||||
{"na_arch-e_36x48in", {914.40, 1219.20}},
|
||||
{"na_b-plus_12x19.17in", {304.80, 486.92}},
|
||||
{"na_c5_6.5x9.5in", {165.10, 241.30}},
|
||||
{"na_c_17x22in", {431.80, 558.80}},
|
||||
{"na_d_22x34in", {558.80, 863.60}},
|
||||
{"na_e_34x44in", {863.60, 1117.60}},
|
||||
{"na_edp_11x14in", {279.40, 355.60}},
|
||||
{"na_eur-edp_12x14in", {304.80, 355.60}},
|
||||
{"na_executive_7.25x10.5in", {184.15, 266.70}},
|
||||
{"na_f_44x68in", {1117.60, 1727.20}},
|
||||
{"na_fanfold-eur_8.5x12in", {215.90, 304.80}},
|
||||
{"na_fanfold-us_11x14.875in", {279.40, 377.82}},
|
||||
{"na_foolscap_8.5x13in", {215.90, 330.20}},
|
||||
{"na_govt-legal_8x13in", {203.20, 330.20}},
|
||||
{"na_govt-letter_8x10in", {203.20, 254.00}},
|
||||
{"na_index-3x5_3x5in", {76.20, 127.00}},
|
||||
{"na_index-4x6-ext_6x8in", {152.40, 203.20}},
|
||||
{"na_index-4x6_4x6in", {101.60, 152.40}},
|
||||
{"na_index-5x8_5x8in", {127.00, 203.20}},
|
||||
{"na_invoice_5.5x8.5in", {139.70, 215.90}},
|
||||
{"na_ledger_11x17in", {279.40, 431.80}},
|
||||
{"na_legal-extra_9.5x15in", {241.30, 381.00}},
|
||||
{"na_legal_8.5x14in", {215.90, 355.60}},
|
||||
{"na_letter-extra_9.5x12in", {241.30, 304.80}},
|
||||
{"na_letter-plus_8.5x12.69in", {215.90, 322.33}},
|
||||
{"na_letter_8.5x11in", {215.90, 279.40}},
|
||||
{"na_monarch_3.875x7.5in", {98.42, 190.50}},
|
||||
{"na_number-10_4.125x9.5in", {104.77, 241.30}},
|
||||
{"na_number-11_4.5x10.375in", {114.30, 263.52}},
|
||||
{"na_number-12_4.75x11in", {120.65, 279.40}},
|
||||
{"na_number-14_5x11.5in", {127.00, 292.10}},
|
||||
{"na_number-9_3.875x8.875in", {98.42, 225.42}},
|
||||
{"na_oficio_8.5x13.4in", {215.90, 340.36}},
|
||||
{"na_personal_3.625x6.5in", {92.07, 165.10}},
|
||||
{"na_quarto_8.5x10.83in", {215.90, 275.08}},
|
||||
{"na_super-a_8.94x14in", {227.08, 355.60}},
|
||||
{"na_super-b_13x19in", {330.20, 482.60}},
|
||||
{"na_wide-format_30x42in", {762.00, 1066.80}},
|
||||
{"oe_12x16_12x16in", {304.80, 406.40}},
|
||||
{"oe_14x17_14x17in", {355.60, 431.80}},
|
||||
{"oe_18x22_18x22in", {457.20, 558.80}},
|
||||
{"oe_a2plus_17x24in", {431.80, 609.60}},
|
||||
{"oe_business-card_2x3.5in", {50.80, 88.90}},
|
||||
{"oe_photo-10r_10x12in", {254.00, 304.80}},
|
||||
{"oe_photo-20r_20x24in", {508.00, 609.60}},
|
||||
{"oe_photo-l_3.5x5in", {88.90, 127.00}},
|
||||
{"oe_photo-s10r_10x15in", {254.00, 381.00}},
|
||||
{"oe_square-photo_4x4in", {101.60, 101.60}},
|
||||
{"oe_square-photo_5x5in", {127.00, 127.00}},
|
||||
{"om_16k_184x260mm", {184.00, 260.00}},
|
||||
{"om_16k_195x270mm", {195.00, 270.00}},
|
||||
{"om_business-card_55x85mm", {55.00, 85.00}},
|
||||
{"om_business-card_55x91mm", {55.00, 91.00}},
|
||||
{"om_card_54x86mm", {54.00, 86.00}},
|
||||
{"om_dai-pa-kai_275x395mm", {275.00, 395.00}},
|
||||
{"om_dsc-photo_89x119mm", {89.00, 119.00}},
|
||||
{"om_folio-sp_215x315mm", {215.00, 315.00}},
|
||||
{"om_folio_210x330mm", {210.00, 330.00}},
|
||||
{"om_invite_220x220mm", {220.00, 220.00}},
|
||||
{"om_italian_110x230mm", {110.00, 230.00}},
|
||||
{"om_juuro-ku-kai_198x275mm", {198.00, 275.00}},
|
||||
{"om_large-photo_200x300", {200.00, 300.00}},
|
||||
{"om_medium-photo_130x180mm", {130.00, 180.00}},
|
||||
{"om_pa-kai_267x389mm", {267.00, 389.00}},
|
||||
{"om_postfix_114x229mm", {114.00, 229.00}},
|
||||
{"om_small-photo_100x150mm", {100.00, 150.00}},
|
||||
{"om_square-photo_89x89mm", {89.00, 89.00}},
|
||||
{"om_wide-photo_100x200mm", {100.00, 200.00}},
|
||||
{"prc_10_324x458mm", {324.00, 458.00}},
|
||||
{"prc_16k_146x215mm", {146.00, 215.00}},
|
||||
{"prc_1_102x165mm", {102.00, 165.00}},
|
||||
{"prc_2_102x176mm", {102.00, 176.00}},
|
||||
{"prc_32k_97x151mm", {97.00, 151.00}},
|
||||
{"prc_3_125x176mm", {125.00, 176.00}},
|
||||
{"prc_4_110x208mm", {110.00, 208.00}},
|
||||
{"prc_5_110x220mm", {110.00, 220.00}},
|
||||
{"prc_6_120x320mm", {120.00, 320.00}},
|
||||
{"prc_7_160x230mm", {160.00, 230.00}},
|
||||
{"prc_8_120x309mm", {120.00, 309.00}},
|
||||
{"roc_16k_7.75x10.75in", {196.85, 273.05}},
|
||||
{"roc_8k_10.75x15.5in", {273.05, 393.70}}};
|
||||
|
||||
|
||||
#endif // PAPERSIZES_H
|
||||
|
|
812
src/printerworker.cpp
Normal file
812
src/printerworker.cpp
Normal file
|
@ -0,0 +1,812 @@
|
|||
#include "printerworker.h"
|
||||
#include "papersizes.h"
|
||||
#include "convertchecker.h"
|
||||
#include "mimer.h"
|
||||
#include <QImage>
|
||||
#include <QMatrix>
|
||||
#include <QPainter>
|
||||
#include <QTextDocument>
|
||||
#include <QPdfWriter>
|
||||
#include <QAbstractTextDocumentLayout>
|
||||
#include <QtSvg>
|
||||
#include "ippprinter.h"
|
||||
#include "pdf2printable.h"
|
||||
#include "ppm2pwg.h"
|
||||
#include "baselinify.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#define OK(call) if(!(call)) throw ConvertFailedException()
|
||||
|
||||
PrinterWorker::PrinterWorker(IppPrinter* parent)
|
||||
{
|
||||
_printer = parent;
|
||||
_url = parent->httpUrl();
|
||||
_thread.reset(new QThread);
|
||||
moveToThread(_thread.get());
|
||||
_thread->start();
|
||||
}
|
||||
|
||||
PrinterWorker::~PrinterWorker()
|
||||
{
|
||||
QMetaObject::invokeMethod(this, "cleanup");
|
||||
_thread->wait();
|
||||
}
|
||||
|
||||
void PrinterWorker::cleanup()
|
||||
{
|
||||
_thread->quit();
|
||||
}
|
||||
|
||||
void PrinterWorker::urlChanged(QUrl url)
|
||||
{
|
||||
_url = url;
|
||||
}
|
||||
|
||||
void PrinterWorker::getStrings(QUrl url)
|
||||
{
|
||||
CurlRequester cr(url, CurlRequester::HttpGetRequest);
|
||||
awaitResult(cr, "getStringsFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::getImage(QUrl url)
|
||||
{
|
||||
CurlRequester cr(url, CurlRequester::HttpGetRequest);
|
||||
awaitResult(cr, "getImageFinished");
|
||||
}
|
||||
|
||||
|
||||
void PrinterWorker::getPrinterAttributes(Bytestream msg)
|
||||
{
|
||||
CurlRequester cr(_url, CurlRequester::IppRequest, &msg);
|
||||
awaitResult(cr, "getPrinterAttributesFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::getJobs(Bytestream msg)
|
||||
{
|
||||
CurlRequester cr(_url, CurlRequester::IppRequest, &msg);
|
||||
awaitResult(cr, "getJobsRequestFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::cancelJob(Bytestream msg)
|
||||
{
|
||||
CurlRequester cr(_url, CurlRequester::IppRequest, &msg);
|
||||
awaitResult(cr, "cancelJobFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::identify(Bytestream msg)
|
||||
{
|
||||
CurlRequester cr(_url, CurlRequester::IppRequest, &msg);
|
||||
awaitResult(cr, "identifyFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::print2(QString filename, QString mimeType, QString targetFormat, IppMsg createJob, IppMsg sendDocument, PrintParameters Params, QMargins margins)
|
||||
{
|
||||
emit busyMessage(tr("Preparing"));
|
||||
|
||||
Bytestream header = createJob.encode();
|
||||
|
||||
CurlRequester cr(_url, CurlRequester::IppRequest, &header);
|
||||
|
||||
Bytestream resData;
|
||||
CURLcode res = cr.await(&resData);
|
||||
|
||||
if(res == CURLE_OK)
|
||||
{
|
||||
IppMsg resMsg(resData);
|
||||
qDebug() << resMsg.getOpAttrs() << resMsg.getJobAttrs();
|
||||
|
||||
QJsonObject resJobAttrs = resMsg.getJobAttrs()[0].toObject();
|
||||
if(resMsg.getStatus() <= 0xff && resJobAttrs.contains("job-id"))
|
||||
{
|
||||
int jobId = resJobAttrs["job-id"].toObject()["value"].toInt();
|
||||
sendDocument.setOpAttr("job-id", IppMsg::Integer, jobId);
|
||||
sendDocument.setOpAttr("last-document", IppMsg::Boolean, true);
|
||||
print(filename, mimeType, targetFormat, sendDocument, Params, margins);
|
||||
}
|
||||
else
|
||||
{
|
||||
resData.setPos(0);
|
||||
QMetaObject::invokeMethod(_printer, "printRequestFinished", Qt::QueuedConnection,
|
||||
Q_ARG(CURLcode, res),
|
||||
Q_ARG(Bytestream, resData));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMetaObject::invokeMethod(_printer, "printRequestFinished", Qt::QueuedConnection,
|
||||
Q_ARG(CURLcode, res),
|
||||
Q_ARG(Bytestream, resData));
|
||||
}
|
||||
}
|
||||
|
||||
void PrinterWorker::print(QString filename, QString mimeType, QString targetFormat, IppMsg job, PrintParameters Params, QMargins margins)
|
||||
{
|
||||
try
|
||||
{
|
||||
Mimer* mimer = Mimer::instance();
|
||||
|
||||
Bytestream contents = job.encode();
|
||||
|
||||
emit busyMessage(tr("Preparing"));
|
||||
|
||||
if((mimeType == targetFormat) && (targetFormat == Mimer::Postscript))
|
||||
{ // Can't process Postscript
|
||||
justUpload(filename, contents);
|
||||
}
|
||||
else if((mimeType == targetFormat) && (targetFormat == Mimer::Plaintext))
|
||||
{
|
||||
fixupPlaintext(filename, contents);
|
||||
}
|
||||
else if((mimeType != Mimer::SVG) && mimer->isImage(mimeType) && mimer->isImage(targetFormat))
|
||||
{ // Just make sure the image is in the desired format (and jpeg baseline-encoded), don't resize locally
|
||||
printImageAsImage(filename, contents, targetFormat);
|
||||
}
|
||||
else if(Params.format != PrintParameters::Invalid) // Params.format can be trusted
|
||||
{
|
||||
if(mimeType == Mimer::PDF)
|
||||
{
|
||||
convertPdf(filename, contents, Params);
|
||||
}
|
||||
else if(mimeType == Mimer::Plaintext)
|
||||
{
|
||||
if(Params.paperSizeH == 0 && Params.getPaperSizeWInMillimeters() < 26)
|
||||
{
|
||||
convertPlaintextLabel(filename, contents, Params);
|
||||
}
|
||||
else
|
||||
{
|
||||
convertPlaintext(filename, contents, Params);
|
||||
}
|
||||
}
|
||||
else if(Mimer::isImage(mimeType))
|
||||
{
|
||||
convertImage(filename, contents, Params, margins);
|
||||
}
|
||||
else if(Mimer::isOffice(mimeType))
|
||||
{
|
||||
convertOfficeDocument(filename, contents, Params);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit failed(tr("Cannot convert this file format"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emit failed(tr("Cannot convert this file format"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
catch(const ConvertFailedException& e)
|
||||
{
|
||||
emit failed(e.what() == QString("") ? tr("Print error") : e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void PrinterWorker::justUpload(QString filename, Bytestream header)
|
||||
{
|
||||
emit busyMessage(tr("Printing"));
|
||||
|
||||
CurlRequester cr(_url);
|
||||
|
||||
QFile file(filename);
|
||||
file.open(QFile::ReadOnly);
|
||||
|
||||
OK(cr.write((char*)header.raw(), header.size()));
|
||||
QByteArray tmp = file.readAll();
|
||||
OK(cr.write(tmp.data(), tmp.length()));
|
||||
file.close();
|
||||
|
||||
awaitResult(cr, "printRequestFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::printImageAsImage(QString filename, Bytestream header, QString targetFormat)
|
||||
{
|
||||
QString imageFormat = "";
|
||||
QStringList supportedImageFormats = {Mimer::JPEG, Mimer::PNG};
|
||||
|
||||
|
||||
if(targetFormat == Mimer::RBMP)
|
||||
{
|
||||
// ok
|
||||
}
|
||||
else if(supportedImageFormats.contains(targetFormat))
|
||||
{
|
||||
imageFormat = targetFormat.split("/")[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ConvertFailedException(tr("Unknown target format"));
|
||||
}
|
||||
|
||||
QString mimeType = Mimer::instance()->get_type(filename);
|
||||
Bytestream OutBts;
|
||||
|
||||
CurlRequester cr(_url);
|
||||
|
||||
if(mimeType == Mimer::JPEG && targetFormat == Mimer::JPEG)
|
||||
{
|
||||
std::ifstream ifs = std::ifstream(filename.toStdString(), std::ios::in | std::ios::binary);
|
||||
Bytestream InBts(ifs);
|
||||
|
||||
baselinify(InBts, OutBts);
|
||||
}
|
||||
else if(targetFormat == Mimer::RBMP)
|
||||
{
|
||||
QImageReader reader(filename);
|
||||
reader.setAutoTransform(true);
|
||||
QImage inImage = reader.read();
|
||||
QBuffer buf;
|
||||
|
||||
if(inImage.isNull())
|
||||
{
|
||||
qDebug() << "failed to load";
|
||||
throw ConvertFailedException(tr("Failed to load image"));
|
||||
}
|
||||
|
||||
// TODO: calculate paper width minus margins
|
||||
// (depends on understanding/parsing custom paper sizes)
|
||||
int width = 576;
|
||||
int height = inImage.height() * ((width*1.0)/inImage.width());
|
||||
inImage = inImage.scaled(width, height);
|
||||
inImage = inImage.convertToFormat(QImage::Format_Mono);
|
||||
inImage = inImage.transformed(QMatrix().scale(1,-1));
|
||||
buf.open(QIODevice::ReadWrite);
|
||||
inImage.save(&buf, "bmp");
|
||||
buf.seek(0);
|
||||
OutBts = Bytestream(buf.size());
|
||||
buf.read((char*)(OutBts.raw()), buf.size());
|
||||
}
|
||||
else if(targetFormat == mimeType)
|
||||
{
|
||||
std::ifstream ifs = std::ifstream(filename.toStdString(), std::ios::in | std::ios::binary);
|
||||
OutBts = Bytestream(ifs);
|
||||
}
|
||||
else
|
||||
{
|
||||
QImageReader reader(filename);
|
||||
reader.setAutoTransform(true);
|
||||
QImage inImage = reader.read();
|
||||
QBuffer buf;
|
||||
|
||||
if(inImage.isNull())
|
||||
{
|
||||
qDebug() << "failed to load";
|
||||
throw ConvertFailedException(tr("Failed to load image"));
|
||||
}
|
||||
|
||||
buf.open(QIODevice::ReadWrite);
|
||||
inImage.save(&buf, imageFormat.toStdString().c_str());
|
||||
buf.seek(0);
|
||||
OutBts = Bytestream(buf.size());
|
||||
buf.read((char*)(OutBts.raw()), buf.size());
|
||||
}
|
||||
|
||||
emit busyMessage(tr("Printing"));
|
||||
|
||||
OK(cr.write((char*)header.raw(), header.size()));
|
||||
OK(cr.write((char*)OutBts.raw(), OutBts.size()));
|
||||
|
||||
awaitResult(cr, "printRequestFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::fixupPlaintext(QString filename, Bytestream header)
|
||||
{
|
||||
CurlRequester cr(_url);
|
||||
|
||||
QFile inFile(filename);
|
||||
if(!inFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
throw ConvertFailedException(tr("Failed to open file"));
|
||||
}
|
||||
|
||||
QString allText = inFile.readAll();
|
||||
if(allText.startsWith("\f"))
|
||||
{
|
||||
allText.remove(0, 1);
|
||||
}
|
||||
|
||||
if(allText.endsWith("\f"))
|
||||
{
|
||||
allText.chop(1);
|
||||
}
|
||||
else if(allText.endsWith("\f\n"))
|
||||
{
|
||||
allText.chop(2);
|
||||
}
|
||||
|
||||
QStringList lines;
|
||||
|
||||
for(QString rnline : allText.split("\r\n"))
|
||||
{
|
||||
lines.append(rnline.split("\n"));
|
||||
}
|
||||
|
||||
QByteArray outData = lines.join("\r\n").toUtf8();
|
||||
|
||||
OK(cr.write((char*)header.raw(), header.size()));
|
||||
OK(cr.write(outData.data(), outData.length()));
|
||||
|
||||
awaitResult(cr, "printRequestFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::convertPdf(QString filename, Bytestream header, PrintParameters Params)
|
||||
{
|
||||
emit busyMessage(tr("Printing"));
|
||||
|
||||
CurlRequester cr(_url);
|
||||
|
||||
OK(cr.write((char*)header.raw(), header.size()));
|
||||
|
||||
write_fun WriteFun([&cr](unsigned char const* buf, unsigned int len) -> bool
|
||||
{
|
||||
if(len == 0)
|
||||
return true;
|
||||
return cr.write((const char*)buf, len);
|
||||
});
|
||||
|
||||
progress_fun ProgressFun([this](size_t page, size_t total) -> void
|
||||
{
|
||||
emit progress(page, total);
|
||||
});
|
||||
|
||||
bool verbose = QLoggingCategory::defaultCategory()->isDebugEnabled();
|
||||
|
||||
int res = pdf_to_printable(filename.toStdString(), WriteFun, Params, ProgressFun, verbose);
|
||||
|
||||
if(res != 0)
|
||||
{
|
||||
throw ConvertFailedException(tr("Conversion failed"));
|
||||
}
|
||||
|
||||
awaitResult(cr, "printRequestFinished");
|
||||
qDebug() << "Finished";
|
||||
}
|
||||
|
||||
void PrinterWorker::convertImage(QString filename, Bytestream header, PrintParameters Params, QMargins margins)
|
||||
{
|
||||
QString mimeType = Mimer::instance()->get_type(filename);
|
||||
|
||||
if(Params.format == PrintParameters::URF && (Params.hwResW != Params.hwResH))
|
||||
{ // URF only supports symmetric resolutions
|
||||
qDebug() << "Unsupported URF resolution";
|
||||
throw ConvertFailedException(tr("Unsupported resolution (dpi)"));
|
||||
}
|
||||
|
||||
qDebug() << "Size is" << Params.getPaperSizeWInPixels() << "x" << Params.getPaperSizeHInPixels();
|
||||
|
||||
int leftMarginPx = (margins.left()/2540.0)*Params.hwResW;
|
||||
int rightMarginPx = (margins.right()/2540.0)*Params.hwResW;
|
||||
int topMarginPx = (margins.top()/2540.0)*Params.hwResH;
|
||||
int bottomMarginPx = (margins.bottom()/2540.0)*Params.hwResH;
|
||||
|
||||
int totalXMarginPx = leftMarginPx+rightMarginPx;
|
||||
int totalYMarginPx = topMarginPx+bottomMarginPx;
|
||||
|
||||
size_t targetWidth = Params.getPaperSizeWInPixels()-totalXMarginPx;
|
||||
size_t targetHeight = Params.getPaperSizeHInPixels()-totalYMarginPx;
|
||||
|
||||
QImage inImage;
|
||||
if(mimeType == Mimer::SVG)
|
||||
{
|
||||
QSvgRenderer renderer(filename);
|
||||
if(!renderer.isValid())
|
||||
{
|
||||
qDebug() << "failed to load svg";
|
||||
throw ConvertFailedException(tr("Failed to load image"));
|
||||
}
|
||||
QSize defaultSize = renderer.defaultSize();
|
||||
QSize targetSize(targetWidth, targetHeight);
|
||||
|
||||
if(defaultSize.width() > defaultSize.height())
|
||||
{
|
||||
targetSize.transpose();
|
||||
}
|
||||
|
||||
QSize initialSize = defaultSize.scaled(targetSize, Qt::KeepAspectRatio);
|
||||
|
||||
inImage = QImage(initialSize, QImage::Format_RGB32);
|
||||
inImage.fill(QColor("white"));
|
||||
QPainter painter(&inImage);
|
||||
|
||||
renderer.render(&painter);
|
||||
painter.end(); // Or else the painter segfaults on destruction if we have messed with the image
|
||||
|
||||
if(inImage.width() > inImage.height())
|
||||
{
|
||||
inImage = inImage.transformed(QMatrix().rotate(270.0));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QImageReader reader(filename);
|
||||
reader.setAutoTransform(true);
|
||||
inImage = reader.read();
|
||||
|
||||
if(inImage.isNull())
|
||||
{
|
||||
qDebug() << "failed to load";
|
||||
throw ConvertFailedException(tr("Failed to load image"));
|
||||
}
|
||||
if(inImage.width() > inImage.height())
|
||||
{
|
||||
inImage = inImage.transformed(QMatrix().rotate(270.0));
|
||||
}
|
||||
|
||||
inImage = inImage.scaled(targetWidth, targetHeight,
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
|
||||
if(Params.format == PrintParameters::PDF || Params.format == PrintParameters::Postscript)
|
||||
{
|
||||
QTemporaryFile tmpPdfFile;
|
||||
tmpPdfFile.open();
|
||||
QPdfWriter pdfWriter(tmpPdfFile.fileName());
|
||||
pdfWriter.setCreator("SeaPrint " SEAPRINT_VERSION);
|
||||
QPageSize pageSize({Params.getPaperSizeWInPoints(), Params.getPaperSizeHInPoints()}, QPageSize::Point);
|
||||
pdfWriter.setPageSize(pageSize);
|
||||
pdfWriter.setResolution(Params.hwResH);
|
||||
QPainter painter(&pdfWriter);
|
||||
int xOffset = ((pdfWriter.width()-totalXMarginPx)-inImage.width())/2 + leftMarginPx;
|
||||
int yOffset = ((pdfWriter.height()-totalYMarginPx)-inImage.height())/2 + topMarginPx;
|
||||
painter.drawImage(xOffset, yOffset, inImage);
|
||||
painter.end();
|
||||
|
||||
convertPdf(tmpPdfFile.fileName(), header, Params);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t total_pages = Params.documentCopies*Params.pageCopies;
|
||||
|
||||
if(total_pages > 1 && Params.duplex)
|
||||
{ // Images are one page by definition - if we need to do client-side copies, they must be one-sided or we'd have to insert backsides
|
||||
qDebug() << "Inconsistent duplex setting";
|
||||
throw ConvertFailedException(tr("Inconsistent duplex setting"));
|
||||
}
|
||||
|
||||
QImage outImage = QImage(Params.getPaperSizeWInPixels(), Params.getPaperSizeHInPixels(), inImage.format());
|
||||
outImage.fill(Qt::white);
|
||||
QPainter painter(&outImage);
|
||||
int xOffset = ((outImage.width()-totalXMarginPx)-inImage.width())/2 + leftMarginPx;
|
||||
int yOffset = ((outImage.height()-totalYMarginPx)-inImage.height())/2 + topMarginPx;
|
||||
painter.drawImage(xOffset, yOffset, inImage);
|
||||
painter.end();
|
||||
|
||||
QBuffer buf;
|
||||
buf.open(QIODevice::ReadWrite);
|
||||
Bytestream fileHdr, outBts;
|
||||
|
||||
|
||||
if(inImage.allGray())
|
||||
{
|
||||
Params.colors = 1; // No need to waste space/bandwidth...
|
||||
}
|
||||
|
||||
outImage.save(&buf, Params.colors==1 ? "pgm" : "ppm");
|
||||
buf.seek(0);
|
||||
// Skip header - TODO consider reimplementing
|
||||
buf.readLine(255);
|
||||
buf.readLine(255);
|
||||
buf.readLine(255);
|
||||
|
||||
Bytestream inBts(Params.getPaperSizeWInPixels() * Params.getPaperSizeHInPixels() * Params.colors);
|
||||
|
||||
if((((size_t)buf.size())-buf.pos()) != inBts.size())
|
||||
{
|
||||
qDebug() << buf.size() << buf.pos() << inBts.size();
|
||||
throw ConvertFailedException();
|
||||
}
|
||||
|
||||
buf.read((char*)(inBts.raw()), inBts.size());
|
||||
|
||||
fileHdr << (Params.format == PrintParameters::URF ? make_urf_file_hdr(1) : make_pwg_file_hdr());
|
||||
|
||||
bool verbose = QLoggingCategory::defaultCategory()->isDebugEnabled();
|
||||
|
||||
bmp_to_pwg(inBts, outBts, 1, Params, verbose);
|
||||
|
||||
CurlRequester cr(_url);
|
||||
|
||||
emit busyMessage(tr("Printing"));
|
||||
|
||||
OK(cr.write((char*)header.raw(), header.size()));
|
||||
OK(cr.write((char*)fileHdr.raw(), fileHdr.size()));
|
||||
for(size_t c = 0; c < total_pages; c++)
|
||||
{
|
||||
OK(cr.write((char*)(outBts.raw()), outBts.size()));
|
||||
emit progress(c+1, total_pages);
|
||||
}
|
||||
|
||||
awaitResult(cr, "printRequestFinished");
|
||||
}
|
||||
|
||||
qDebug() << "posted";
|
||||
}
|
||||
|
||||
void PrinterWorker::convertOfficeDocument(QString filename, Bytestream header, PrintParameters Params)
|
||||
{
|
||||
if(Params.format == PrintParameters::URF && (Params.hwResW != Params.hwResH))
|
||||
{ // URF only supports symmetric resolutions
|
||||
qDebug() << "Unsupported URF resolution";
|
||||
throw ConvertFailedException(tr("Unsupported resolution (dpi)"));
|
||||
}
|
||||
|
||||
QString ShortPaperSize;
|
||||
if(CalligraPaperSizes.contains(Params.paperSizeName.c_str()))
|
||||
{
|
||||
ShortPaperSize = CalligraPaperSizes[Params.paperSizeName.c_str()];
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Unsupported PDF paper size" << Params.paperSizeName.c_str();
|
||||
throw ConvertFailedException(tr("Unsupported PDF paper size"));
|
||||
}
|
||||
|
||||
QProcess CalligraConverter(this);
|
||||
CalligraConverter.setProgram("calligraconverter");
|
||||
QStringList CalligraConverterArgs = {"--batch", "--mimetype", Mimer::PDF, "--print-orientation", "Portrait", "--print-papersize", ShortPaperSize};
|
||||
|
||||
CalligraConverterArgs << filename;
|
||||
|
||||
QTemporaryFile tmpPdfFile;
|
||||
tmpPdfFile.open();
|
||||
CalligraConverterArgs << tmpPdfFile.fileName();
|
||||
|
||||
qDebug() << "CalligraConverteArgs is" << CalligraConverterArgs;
|
||||
CalligraConverter.setArguments(CalligraConverterArgs);
|
||||
|
||||
CalligraConverter.start();
|
||||
|
||||
qDebug() << "CalligraConverter Starting";
|
||||
|
||||
if(!CalligraConverter.waitForStarted())
|
||||
{
|
||||
qDebug() << "CalligraConverter died";
|
||||
throw ConvertFailedException();
|
||||
}
|
||||
|
||||
qDebug() << "CalligraConverter Started";
|
||||
|
||||
if(!CalligraConverter.waitForFinished(-1))
|
||||
{
|
||||
qDebug() << "CalligraConverter failed";
|
||||
throw ConvertFailedException();
|
||||
}
|
||||
|
||||
// qDebug() << CalligraConverter->readAllStandardError();
|
||||
|
||||
convertPdf(tmpPdfFile.fileName(), header, Params);
|
||||
|
||||
qDebug() << "posted";
|
||||
}
|
||||
|
||||
void PrinterWorker::convertPlaintext(QString filename, Bytestream header, PrintParameters Params)
|
||||
{
|
||||
|
||||
QPageSize pageSize;
|
||||
|
||||
if(Params.paperSizeUnits == PrintParameters::Millimeters)
|
||||
{
|
||||
pageSize = QPageSize(QSizeF {Params.paperSizeW, Params.paperSizeH}, QPageSize::Millimeter);
|
||||
}
|
||||
else if(Params.paperSizeUnits == PrintParameters::Inches)
|
||||
{
|
||||
pageSize = QPageSize(QSizeF {Params.paperSizeW, Params.paperSizeH}, QPageSize::Inch);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Unsupported paper size" << Params.paperSizeName.c_str();
|
||||
throw ConvertFailedException(tr("Unsupported paper size"));
|
||||
}
|
||||
|
||||
QFile inFile(filename);
|
||||
if(!inFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
throw ConvertFailedException(tr("Failed to open file"));
|
||||
}
|
||||
|
||||
quint32 resolution = std::min(Params.hwResW, Params.hwResH);
|
||||
|
||||
QTemporaryFile tmpPdfFile;
|
||||
tmpPdfFile.open();
|
||||
|
||||
QPdfWriter pdfWriter(tmpPdfFile.fileName());
|
||||
pdfWriter.setCreator("SeaPrint " SEAPRINT_VERSION);
|
||||
|
||||
pdfWriter.setPageSize(pageSize);
|
||||
pdfWriter.setResolution(resolution);
|
||||
|
||||
qreal docHeight = pageSize.sizePixels(resolution).height();
|
||||
|
||||
QTextDocument doc;
|
||||
|
||||
QFont font = QFont("Courier");
|
||||
font.setPointSizeF(1);
|
||||
|
||||
qreal charHeight = 0;
|
||||
|
||||
// Find the optimal font size
|
||||
while(true) {
|
||||
QFont tmpFont = font;
|
||||
tmpFont.setPointSizeF(font.pointSizeF()+0.5);
|
||||
QFontMetricsF qfm(tmpFont, &pdfWriter);
|
||||
|
||||
charHeight = qfm.lineSpacing();
|
||||
|
||||
if(charHeight*66 > docHeight)
|
||||
{
|
||||
break;
|
||||
}
|
||||
font=tmpFont;
|
||||
}
|
||||
|
||||
QFontMetricsF qfm(font, &pdfWriter);
|
||||
|
||||
charHeight = qfm.height();
|
||||
|
||||
int textHeight = 60*charHeight;
|
||||
qreal margin = ((docHeight-textHeight)/2);
|
||||
qreal mmMargin = margin/(resolution/25.4);
|
||||
|
||||
doc.setDefaultFont(font);
|
||||
(void)doc.documentLayout(); // wat
|
||||
|
||||
// Needs to be before painter
|
||||
pdfWriter.setMargins({mmMargin, mmMargin, mmMargin, mmMargin});
|
||||
|
||||
QPainter painter(&pdfWriter);
|
||||
|
||||
doc.documentLayout()->setPaintDevice(painter.device());
|
||||
doc.setDocumentMargin(margin);
|
||||
|
||||
// Hack to make the document and pdfWriter margins overlap
|
||||
// Apparently calls to painter.translate() stack... who knew!
|
||||
painter.translate(-margin, -margin);
|
||||
|
||||
QRectF body = pageSize.rectPixels(resolution);
|
||||
doc.setPageSize(body.size());
|
||||
|
||||
QString allText = inFile.readAll();
|
||||
if(allText.startsWith("\f"))
|
||||
{
|
||||
allText.remove(0, 1);
|
||||
}
|
||||
|
||||
if(allText.endsWith("\f"))
|
||||
{
|
||||
allText.chop(1);
|
||||
}
|
||||
else if(allText.endsWith("\f\n"))
|
||||
{
|
||||
allText.chop(2);
|
||||
}
|
||||
|
||||
QStringList pages = allText.split('\f');
|
||||
|
||||
bool first = true;
|
||||
int pageCount = 0;
|
||||
|
||||
for(QString page : pages)
|
||||
{
|
||||
if(!first)
|
||||
{
|
||||
pdfWriter.newPage();
|
||||
}
|
||||
first = false;
|
||||
|
||||
if(page.endsWith("\n"))
|
||||
{
|
||||
page.chop(1);
|
||||
}
|
||||
doc.setPlainText(page);
|
||||
|
||||
int p = 0; // Page number in this document, starting from 0
|
||||
|
||||
while(true)
|
||||
{
|
||||
painter.save();
|
||||
painter.translate(body.left(), body.top() - p*body.height());
|
||||
QRectF view(0, p*body.height(), body.width(), body.height());
|
||||
painter.setClipRect(view);
|
||||
|
||||
QAbstractTextDocumentLayout::PaintContext context;
|
||||
context.clip = view;
|
||||
context.palette.setColor(QPalette::Text, Qt::black);
|
||||
doc.documentLayout()->draw(&painter, context);
|
||||
painter.restore();
|
||||
|
||||
p++;
|
||||
pageCount++;
|
||||
|
||||
if(p >= doc.pageCount())
|
||||
break;
|
||||
|
||||
pdfWriter.newPage();
|
||||
}
|
||||
}
|
||||
|
||||
painter.end();
|
||||
|
||||
convertPdf(tmpPdfFile.fileName(), header, Params);
|
||||
|
||||
qDebug() << "Finished";
|
||||
qDebug() << "posted";
|
||||
}
|
||||
|
||||
void PrinterWorker::convertPlaintextLabel(QString filename, Bytestream header, PrintParameters Params)
|
||||
{
|
||||
QFile inFile(filename);
|
||||
if(!inFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
throw ConvertFailedException(tr("Failed to open file"));
|
||||
}
|
||||
|
||||
QString allText = inFile.readAll();
|
||||
while(allText.endsWith('\n'))
|
||||
{
|
||||
allText.chop(1);
|
||||
}
|
||||
|
||||
if(allText.contains('\n') || allText.contains('\f'))
|
||||
{
|
||||
throw ConvertFailedException(tr("Multiline label not supported"));
|
||||
}
|
||||
|
||||
QTemporaryFile tmpPdfFile;
|
||||
tmpPdfFile.open();
|
||||
|
||||
// NB: running with rotated format - pdf2printable will sort that out
|
||||
int pixelHeight = Params.getPaperSizeWInPixels();
|
||||
QFont font = QFont("Arial");
|
||||
font.setPixelSize(pixelHeight);
|
||||
|
||||
QFontMetrics fm(font);
|
||||
QString bigText = "AXgjqÈÅÄÖþ";
|
||||
QRect rect = fm.boundingRect(bigText);
|
||||
|
||||
while(rect.height() > pixelHeight*(8.0/10.0))
|
||||
{
|
||||
font.setPixelSize(font.pixelSize()-1);
|
||||
fm = QFontMetrics(font);
|
||||
rect = fm.boundingRect(bigText);
|
||||
}
|
||||
|
||||
rect = fm.boundingRect(allText);
|
||||
|
||||
int pixelWidth = rect.width() + pixelHeight/2;
|
||||
float ratio = pixelWidth*1.0/pixelHeight;
|
||||
Params.paperSizeH = Params.paperSizeW * ratio;
|
||||
|
||||
QPdfWriter pdfWriter(tmpPdfFile.fileName());
|
||||
pdfWriter.setCreator("SeaPrint " SEAPRINT_VERSION);
|
||||
QPageSize pageSize({Params.getPaperSizeHInPoints(), Params.getPaperSizeWInPoints()}, QPageSize::Point);
|
||||
pdfWriter.setPageSize(pageSize);
|
||||
pdfWriter.setMargins({0,0,0,0});
|
||||
pdfWriter.setResolution(Params.hwResH);
|
||||
|
||||
QPainter painter(&pdfWriter);
|
||||
int xOffset = -rect.x() + pixelHeight/4;
|
||||
int yOffset = -rect.y() + pixelHeight/10;
|
||||
painter.setFont(font);
|
||||
painter.drawText(xOffset, yOffset, allText);
|
||||
painter.end();
|
||||
|
||||
convertPdf(tmpPdfFile.fileName(), header, Params);
|
||||
|
||||
qDebug() << "Finished";
|
||||
qDebug() << "posted";
|
||||
}
|
||||
|
||||
void PrinterWorker::awaitResult(CurlRequester& cr, QString callback)
|
||||
{
|
||||
Bytestream resMsg;
|
||||
CURLcode res = cr.await(&resMsg);
|
||||
QMetaObject::invokeMethod(_printer, callback.toStdString().c_str(), Qt::QueuedConnection,
|
||||
Q_ARG(CURLcode, res),
|
||||
Q_ARG(Bytestream, resMsg));
|
||||
}
|
72
src/printerworker.h
Normal file
72
src/printerworker.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
#ifndef PRINTERWORKER_H
|
||||
#define PRINTERWORKER_H
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
#include "curlrequester.h"
|
||||
#include "ippmsg.h"
|
||||
#include "ppm2pwg/printparameters.h"
|
||||
|
||||
class IppPrinter;
|
||||
|
||||
class ConvertFailedException: public std::exception
|
||||
{
|
||||
private:
|
||||
std::string _msg;
|
||||
public:
|
||||
ConvertFailedException(QString msg = "") : _msg(msg.toStdString())
|
||||
{
|
||||
}
|
||||
virtual const char* what() const throw()
|
||||
{
|
||||
return _msg.c_str();
|
||||
}
|
||||
};
|
||||
|
||||
class PrinterWorker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PrinterWorker(IppPrinter* parent);
|
||||
~PrinterWorker();
|
||||
|
||||
private:
|
||||
PrinterWorker();
|
||||
|
||||
public slots:
|
||||
void urlChanged(QUrl url);
|
||||
void getStrings(QUrl url);
|
||||
void getImage(QUrl url);
|
||||
void getPrinterAttributes(Bytestream msg);
|
||||
void getJobs(Bytestream msg);
|
||||
void cancelJob(Bytestream msg);
|
||||
void identify(Bytestream msg);
|
||||
void print(QString filename, QString mimeType, QString targetFormat, IppMsg job, PrintParameters Params, QMargins margins);
|
||||
void print2(QString filename, QString mimeType, QString targetFormat, IppMsg createJob, IppMsg sendDocument, PrintParameters Params, QMargins margins);
|
||||
|
||||
private slots:
|
||||
void cleanup();
|
||||
|
||||
signals:
|
||||
void progress(qint64 done, qint64 pages);
|
||||
void busyMessage(QString msg);
|
||||
void failed(QString message);
|
||||
|
||||
private:
|
||||
void justUpload(QString filename, Bytestream header);
|
||||
void printImageAsImage(QString filename, Bytestream header, QString targetFormat);
|
||||
void fixupPlaintext(QString filename, Bytestream header);
|
||||
void convertPdf(QString filename, Bytestream header, PrintParameters Params);
|
||||
void convertImage(QString filename, Bytestream header, PrintParameters Params, QMargins margins);
|
||||
void convertOfficeDocument(QString filename, Bytestream header, PrintParameters Params);
|
||||
void convertPlaintext(QString filename, Bytestream header, PrintParameters Params);
|
||||
void convertPlaintextLabel(QString filename, Bytestream header, PrintParameters Params);
|
||||
|
||||
void awaitResult(CurlRequester& cr, QString callback);
|
||||
|
||||
std::unique_ptr<QThread> _thread;
|
||||
QPointer<IppPrinter> _printer;
|
||||
QUrl _url;
|
||||
};
|
||||
|
||||
#endif // PRINTERWORKER_H
|
47
src/rangelistchecker.cpp
Normal file
47
src/rangelistchecker.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "rangelistchecker.h"
|
||||
|
||||
RangeListChecker::RangeListChecker()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RangeListChecker::~RangeListChecker()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RangeListChecker* RangeListChecker::m_Instance = 0;
|
||||
|
||||
RangeListChecker* RangeListChecker::instance()
|
||||
{
|
||||
static QMutex mutex;
|
||||
if (!m_Instance)
|
||||
{
|
||||
mutex.lock();
|
||||
|
||||
if (!m_Instance)
|
||||
m_Instance = new RangeListChecker;
|
||||
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
return m_Instance;
|
||||
}
|
||||
|
||||
QJsonArray RangeListChecker::parse(QString str) const
|
||||
{
|
||||
PrintParameters params;
|
||||
params.setPageRange(str.toStdString());
|
||||
QJsonArray ret;
|
||||
size_t previous = 0;
|
||||
for(const std::pair<size_t, size_t>& p : params.pageRangeList)
|
||||
{
|
||||
if(p.first <= previous)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
ret.append(QJsonObject {{"low", int(p.first)}, {"high", int(p.second)}});
|
||||
previous = p.second;
|
||||
}
|
||||
return ret;
|
||||
}
|
29
src/rangelistchecker.h
Normal file
29
src/rangelistchecker.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef RANGELISTCHECKER_H
|
||||
#define RANGELISTCHECKER_H
|
||||
|
||||
#include <QValidator>
|
||||
#include <QMutex>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "printparameters.h"
|
||||
|
||||
class RangeListChecker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static RangeListChecker* instance();
|
||||
|
||||
Q_INVOKABLE QJsonArray parse(QString str) const;
|
||||
|
||||
private:
|
||||
static RangeListChecker* m_Instance;
|
||||
|
||||
RangeListChecker();
|
||||
~RangeListChecker();
|
||||
RangeListChecker(const RangeListChecker &);
|
||||
RangeListChecker& operator=(const RangeListChecker &);
|
||||
|
||||
};
|
||||
|
||||
#endif // RANGELISTCHECKER_H
|
21
src/seaprintdbusadaptor.cpp
Normal file
21
src/seaprintdbusadaptor.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "seaprintdbusadaptor.h"
|
||||
#include <QtQuick>
|
||||
|
||||
SeaPrintDBusAdaptor::SeaPrintDBusAdaptor(QQuickView *view)
|
||||
: QDBusAbstractAdaptor(view)
|
||||
, DBusAdaptorBase(view)
|
||||
{
|
||||
}
|
||||
|
||||
SeaPrintDBusAdaptor::~SeaPrintDBusAdaptor()
|
||||
{
|
||||
}
|
||||
|
||||
void SeaPrintDBusAdaptor::Open(const QString& fileName)
|
||||
{
|
||||
doOpen(fileName);
|
||||
}
|
||||
void SeaPrintDBusAdaptor::OpenPlaintext(const QString& fileContents, const QString& name)
|
||||
{
|
||||
doCreateFileAndOpen(fileContents, name);
|
||||
}
|
21
src/seaprintdbusadaptor.h
Normal file
21
src/seaprintdbusadaptor.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef SEAPRINTDBUSADAPTOR_H
|
||||
#define SEAPRINTDBUSADAPTOR_H
|
||||
|
||||
#include "dbusadaptorbase.h"
|
||||
|
||||
class SeaPrintDBusAdaptor : public QDBusAbstractAdaptor, public DBusAdaptorBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "net.attah.seaprint")
|
||||
|
||||
public:
|
||||
SeaPrintDBusAdaptor(QQuickView *view);
|
||||
~SeaPrintDBusAdaptor();
|
||||
|
||||
public Q_SLOTS:
|
||||
Q_NOREPLY void Open(const QString& fileName);
|
||||
Q_NOREPLY void OpenPlaintext(const QString& fileContents, const QString& name);
|
||||
|
||||
};
|
||||
|
||||
#endif // SEAPRINTDBUSADAPTOR_H
|
61
src/settings.cpp
Normal file
61
src/settings.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
#include "settings.h"
|
||||
#include <QMutex>
|
||||
|
||||
|
||||
Settings::Settings() : _ignoreSslErrorsSetting("/apps/harbour-seaprint/settings/ignore-ssl-errors", this),
|
||||
_debugLogSetting("/apps/harbour-seaprint/settings/debug-log", this),
|
||||
_allowExternalConnectionsSetting("/apps/harbour-seaprint/settings/allow-external-connections", this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Settings::~Settings() {
|
||||
}
|
||||
|
||||
Settings* Settings::m_Instance = nullptr;
|
||||
|
||||
Settings* Settings::instance()
|
||||
{
|
||||
static QMutex mutex;
|
||||
if (!m_Instance)
|
||||
{
|
||||
mutex.lock();
|
||||
|
||||
if (!m_Instance)
|
||||
m_Instance = new Settings;
|
||||
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
return m_Instance;
|
||||
}
|
||||
|
||||
bool Settings::ignoreSslErrors()
|
||||
{
|
||||
return _ignoreSslErrorsSetting.value(_ignoreSslErrorsDefault).toBool();
|
||||
}
|
||||
|
||||
QString Settings::ignoreSslErrorsPath()
|
||||
{
|
||||
return _ignoreSslErrorsSetting.key();
|
||||
}
|
||||
|
||||
bool Settings::debugLog()
|
||||
{
|
||||
return _debugLogSetting.value(_debugLogDefault).toBool();
|
||||
}
|
||||
|
||||
QString Settings::debugLogPath()
|
||||
{
|
||||
return _debugLogSetting.key();
|
||||
}
|
||||
|
||||
bool Settings::allowExternalConnections()
|
||||
{
|
||||
return _allowExternalConnectionsSetting.value(_allowExternalConnectionsDefault).toBool();
|
||||
}
|
||||
|
||||
QString Settings::allowExternalConnectionsPath()
|
||||
{
|
||||
return _allowExternalConnectionsSetting.key();
|
||||
}
|
49
src/settings.h
Normal file
49
src/settings.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#include <mlite5/MGConfItem>
|
||||
|
||||
class Settings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
Q_PROPERTY(QString ignoreSslErrorsPath READ ignoreSslErrorsPath CONSTANT)
|
||||
Q_PROPERTY(bool ignoreSslErrorsDefault MEMBER _ignoreSslErrorsDefault CONSTANT)
|
||||
|
||||
Q_PROPERTY(QString debugLogPath READ debugLogPath CONSTANT)
|
||||
Q_PROPERTY(bool debugLogDefault MEMBER _debugLogDefault CONSTANT)
|
||||
|
||||
Q_PROPERTY(QString allowExternalConnectionsPath READ allowExternalConnectionsPath CONSTANT)
|
||||
Q_PROPERTY(bool allowExternalConnectionsDefault MEMBER _allowExternalConnectionsDefault CONSTANT)
|
||||
|
||||
public:
|
||||
static Settings* instance();
|
||||
|
||||
bool ignoreSslErrors();
|
||||
bool debugLog();
|
||||
bool allowExternalConnections();
|
||||
|
||||
private:
|
||||
Settings();
|
||||
~Settings();
|
||||
Settings(const Settings &);
|
||||
Settings& operator=(const Settings &);
|
||||
|
||||
static Settings* m_Instance;
|
||||
|
||||
MGConfItem _ignoreSslErrorsSetting;
|
||||
MGConfItem _debugLogSetting;
|
||||
MGConfItem _allowExternalConnectionsSetting;
|
||||
|
||||
QString ignoreSslErrorsPath();
|
||||
QString debugLogPath();
|
||||
QString allowExternalConnectionsPath();
|
||||
|
||||
bool _ignoreSslErrorsDefault = true;
|
||||
bool _debugLogDefault = false;
|
||||
bool _allowExternalConnectionsDefault = false;
|
||||
|
||||
};
|
||||
|
||||
#endif // SETTINGS_H
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
5532
translations/harbour-seaprint-nl.ts
Normal file
5532
translations/harbour-seaprint-nl.ts
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue