Initial commit.
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.qmake.stash
|
||||
moc_*
|
||||
qrc_*
|
||||
*.o
|
||||
Makefile
|
||||
qteletextmaker
|
||||
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>.
|
||||
53
README.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# QTeletextMaker
|
||||
QTeletextMaker is a teletext page editor in development. It is written in C++ using the Qt 5 widget libraries, and released under the GNU General Public License v3.0
|
||||
|
||||
Features
|
||||
- Load and save teletext pages in .tti format.
|
||||
- Rendering of teletext pages in Levels 1, 1.5, 2.5 and 3.5
|
||||
- Rendering of Local Objects and side panels.
|
||||
- Interactive X/26 Local Enhancement Data triplet editor.
|
||||
- Palette editor.
|
||||
- Configurable zoom.
|
||||
- View teletext pages in 4:3, 16:9 pillar-box and 16:9 stretch aspect ratios.
|
||||
|
||||
Although designed on and developed for Linux, the Qt 5 libraries are cross platform so hopefully it should be compilable on Windows. And maybe MacOS as well.
|
||||
|
||||
## Building
|
||||
### Linux
|
||||
Install the QtCore, QtGui and QtWidgets libraries and build headers, along with the qmake tool. Then type `qmake && make -j3` in a terminal, you can replace -j3 with the number of processor cores used for the compile process.
|
||||
|
||||
The above will place the qteletextmaker executable in the same directory as the source, type `./qteletextmaker` in the terminal to launch. Optionally, type `make install` afterwards to place the exectuable into /usr/local/bin.
|
||||
|
||||
## Current limitations
|
||||
At the moment QTeletextMaker is in pre-alpha status so many features are not finished yet. The most-often encountered limitations are detailed here.
|
||||
|
||||
Spacing attributes are only accessible through an "Insert" menu. A toolbar to insert spacing attributes may be added in the future.
|
||||
|
||||
There is no visible widget for switching between subpages, use the PageUp and PageDown keys for this.
|
||||
|
||||
Undo only undoes keypresses, insertion of spacing attributes and CLUT changes. Other changes can't be undone, nor will they cause the "unsaved page" dialog to appear if the editor window is closed.
|
||||
|
||||
Keymapping between ASCII and Teletext character sets is not yet implemented e.g. in English pressing the hash key will type a pound sign instead, and in other languages the square and curly brackets keys need to be pressed to obtain the accented characters.
|
||||
|
||||
The following X/26 enhancement triplets are not rendered by the editor, although the list is fully aware of them.
|
||||
- Invocation of Objects from POP and GPOP pages.
|
||||
- DRCS characters.
|
||||
- Modified G0 and G2 character set designation using X/26 triplets with mode 01000.
|
||||
- Full screen and full row colours set by Active Objects.
|
||||
- Level 3.5 font style: bold, italic and proportional spacing.
|
||||
|
||||
## Using the X/26 triplet editor
|
||||
At present the editor only accepts raw triplet Address, Mode and Data numbers for input although the effects of the Triplet are shown in the list as a full description. The full behaviour of these enhancement triplets can be found in
|
||||
section 12.3 of the [Enhanced Teletext specification ETS 300 706](https://web.archive.org/web/20160326062859/https://www.phecap.nl/download/enhenced-teletext-specs.pdf) but some hints and tips are below.
|
||||
|
||||
### Address values
|
||||
Address values 0-39 select a Column Triplet and, with the exception of reserved and PDC Modes, set the column co-ordinate of the Active Position.
|
||||
|
||||
Address values 40-63 select a Row Triplet which has a different set of modes. Modes 4 (Set Active Position) and 1 (Full Row Colour) will set the row co-ordinate of the Active Position to the Address value minus 40, except for Address value 40 which will set the row co-ordinate to 24.
|
||||
|
||||
### Objects
|
||||
"Define ... Object" triplets need to declare that they are in the correct place in the triplet list e.g. if the Define Object triplet is at `d1 t3` in the list then the data field must show `Local: d1 t3`, otherwise the Object won't appear.
|
||||
|
||||
Insert and deleting triplets from the list will upset the Object pointers on both "Define" and "Invoke" triplets and will need to be corrected afterwards. A future version of the editor may adjust these pointers automatically.
|
||||
|
||||
"Invoke ... Object" triplets must point to a "Define ... Object" of the same type e.g. "Invoke *Active* Object" must point to a "Define *Active* Object", otherwise the Object won't appear.
|
||||
450
document.cpp
Normal file
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <vector>
|
||||
|
||||
#include "document.h"
|
||||
|
||||
#include "page.h"
|
||||
|
||||
TeletextDocument::TeletextDocument()
|
||||
{
|
||||
m_pageNumber = 0x198;
|
||||
m_description.clear();
|
||||
for (int i=0; i<6; i++)
|
||||
m_fastTextLink[i] = 0x8ff;
|
||||
m_empty = true;
|
||||
m_subPages.push_back(new TeletextPage);
|
||||
m_currentSubPageIndex = 0;
|
||||
m_undoStack = new QUndoStack(this);
|
||||
m_cursorRow = 1;
|
||||
m_cursorColumn = 0;
|
||||
}
|
||||
|
||||
TeletextDocument::~TeletextDocument()
|
||||
{
|
||||
for (auto &subPage : m_subPages)
|
||||
delete(subPage);
|
||||
}
|
||||
|
||||
void TeletextDocument::loadDocument(QFile *inFile)
|
||||
{
|
||||
QByteArray inLine;
|
||||
bool firstSubPageFound = false;
|
||||
int cycleCommandsFound = 0;
|
||||
int mostRecentCycleValue = -1;
|
||||
TeletextPage::CycleTypeEnum mostRecentCycleType;
|
||||
|
||||
TeletextPage* loadingPage = m_subPages[0];
|
||||
|
||||
for (;;) {
|
||||
inLine = inFile->readLine(160).trimmed();
|
||||
if (inLine.isEmpty())
|
||||
break;
|
||||
if (inLine.startsWith("DE,"))
|
||||
m_description = QString(inLine.remove(0, 3));
|
||||
if (inLine.startsWith("PN,")) {
|
||||
bool pageNumberOk;
|
||||
int pageNumberRead = inLine.mid(3, 3).toInt(&pageNumberOk, 16);
|
||||
if ((!pageNumberOk) || pageNumberRead < 0x100 || pageNumberRead > 0x8ff)
|
||||
pageNumberRead = 0x199;
|
||||
// When second and subsequent PN commands are found, firstSubPageFound==true at this point
|
||||
// This assumes that PN is the first command of a new subpage...
|
||||
if (firstSubPageFound) {
|
||||
m_subPages.push_back(new TeletextPage);
|
||||
loadingPage = m_subPages.back();
|
||||
}
|
||||
m_pageNumber = pageNumberRead;
|
||||
firstSubPageFound = true;
|
||||
}
|
||||
/* if (lineType == "SC,") {
|
||||
bool subPageNumberOk;
|
||||
int subPageNumberRead = inLine.mid(3, 4).toInt(&subPageNumberOk, 16);
|
||||
if ((!subPageNumberOk) || subPageNumberRead > 0x3f7f)
|
||||
subPageNumberRead = 0;
|
||||
loadingPage->setSubPageNumber(subPageNumberRead);
|
||||
}*/
|
||||
if (inLine.startsWith("PS,")) {
|
||||
bool pageStatusOk;
|
||||
int pageStatusRead = inLine.mid(3, 4).toInt(&pageStatusOk, 16);
|
||||
if (pageStatusOk) {
|
||||
loadingPage->setControlBit(0, pageStatusRead & 0x4000);
|
||||
for (int i=1, pageStatusBit=0x0001; i<8; i++, pageStatusBit<<=1)
|
||||
loadingPage->setControlBit(i, pageStatusRead & pageStatusBit);
|
||||
loadingPage->setDefaultNOS(((pageStatusRead & 0x0200) >> 9) | ((pageStatusRead & 0x0100) >> 7) | ((pageStatusRead & 0x0080) >> 5));
|
||||
}
|
||||
}
|
||||
if (inLine.startsWith("CT,") && (inLine.endsWith(",C") || inLine.endsWith(",T"))) {
|
||||
bool cycleValueOk;
|
||||
int cycleValueRead = inLine.mid(3, inLine.size()-5).toInt(&cycleValueOk);
|
||||
if (cycleValueOk) {
|
||||
cycleCommandsFound++;
|
||||
// House-keep CT command values, in case it's the only one within multiple subpages
|
||||
mostRecentCycleValue = cycleValueRead;
|
||||
loadingPage->setCycleValue(cycleValueRead);
|
||||
mostRecentCycleType = inLine.endsWith("C") ? TeletextPage::CTcycles : TeletextPage::CTseconds;
|
||||
loadingPage->setCycleType(mostRecentCycleType);
|
||||
}
|
||||
}
|
||||
if (inLine.startsWith("FL,")) {
|
||||
bool fastTextLinkOk;
|
||||
int fastTextLinkRead;
|
||||
QString flLine = QString(inLine.remove(0, 3));
|
||||
if (flLine.count(',') == 5)
|
||||
for (int i=0; i<6; i++) {
|
||||
fastTextLinkRead = flLine.section(',', i, i).toInt(&fastTextLinkOk, 16);
|
||||
if (fastTextLinkOk)
|
||||
m_fastTextLink[i] = fastTextLinkRead == 0 ? 0x8ff : fastTextLinkRead;
|
||||
}
|
||||
}
|
||||
if (inLine.startsWith("OL,"))
|
||||
loadingPage->loadPagePacket(inLine);
|
||||
}
|
||||
// If there's more than one subpage but only one valid CT command was found, apply it to all subpages
|
||||
// I don't know if this is correct
|
||||
if (cycleCommandsFound == 1 && m_subPages.size()>1)
|
||||
for (auto &subPage : m_subPages) {
|
||||
subPage->setCycleValue(mostRecentCycleValue);
|
||||
subPage->setCycleType(mostRecentCycleType);
|
||||
}
|
||||
subPageSelected();
|
||||
}
|
||||
|
||||
void TeletextDocument::saveDocument(QTextStream *outStream)
|
||||
{
|
||||
if (!m_description.isEmpty())
|
||||
*outStream << "DE," << m_description << endl;
|
||||
//TODO DS and SP commands
|
||||
|
||||
int subPageNumber = m_subPages.size()>1;
|
||||
|
||||
for (auto &subPage : m_subPages) {
|
||||
subPage->savePage(outStream, m_pageNumber, subPageNumber++);
|
||||
if (m_fastTextLink[0] != 0x8ff) {
|
||||
*outStream << "FL,";
|
||||
for (int i=0; i<6; i++) {
|
||||
*outStream << QString("%1").arg(m_fastTextLink[i], 3, 16, QChar('0'));
|
||||
if (i<5)
|
||||
*outStream << ',';
|
||||
}
|
||||
*outStream << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TeletextDocument::selectSubPageIndex(int newSubPageIndex, bool forceRefresh)
|
||||
{
|
||||
// forceRefresh overrides "beyond the last subpage" check, so inserting a subpage after the last one still shows - dangerous workaround?
|
||||
if (forceRefresh || (newSubPageIndex != m_currentSubPageIndex && newSubPageIndex < m_subPages.size()-1)) {
|
||||
emit aboutToChangeSubPage();
|
||||
m_currentSubPageIndex = newSubPageIndex;
|
||||
emit subPageSelected();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void TeletextDocument::selectSubPageNext()
|
||||
{
|
||||
if (m_currentSubPageIndex < m_subPages.size()-1) {
|
||||
emit aboutToChangeSubPage();
|
||||
m_currentSubPageIndex++;
|
||||
emit subPageSelected();
|
||||
}
|
||||
}
|
||||
|
||||
void TeletextDocument::selectSubPagePrevious()
|
||||
{
|
||||
if (m_currentSubPageIndex > 0) {
|
||||
emit aboutToChangeSubPage();
|
||||
m_currentSubPageIndex--;
|
||||
emit subPageSelected();
|
||||
}
|
||||
}
|
||||
|
||||
void TeletextDocument::insertSubPage(int beforeSubPageIndex, bool copySubPage)
|
||||
{
|
||||
TeletextPage *insertedSubPage;
|
||||
|
||||
if (copySubPage)
|
||||
insertedSubPage = new TeletextPage(*m_subPages.at(beforeSubPageIndex));
|
||||
else
|
||||
insertedSubPage = new TeletextPage;
|
||||
if (beforeSubPageIndex == m_subPages.size())
|
||||
m_subPages.push_back(insertedSubPage);
|
||||
else
|
||||
m_subPages.insert(m_subPages.begin()+beforeSubPageIndex, insertedSubPage);
|
||||
}
|
||||
|
||||
void TeletextDocument::deleteSubPage(int subPageToDelete)
|
||||
{
|
||||
delete(m_subPages[subPageToDelete]);
|
||||
m_subPages.erase(m_subPages.begin()+subPageToDelete);
|
||||
}
|
||||
|
||||
void TeletextDocument::setPageNumber(QString newPageNumberString)
|
||||
{
|
||||
// The LineEdit should check if a valid hex number was entered, but just in case...
|
||||
bool newPageNumberOk;
|
||||
int newPageNumberRead = newPageNumberString.toInt(&newPageNumberOk, 16);
|
||||
if (newPageNumberOk && newPageNumberRead >= 0x100 && newPageNumberRead <= 0x8fe)
|
||||
m_pageNumber = newPageNumberRead;
|
||||
}
|
||||
|
||||
void TeletextDocument::setDescription(QString newDescription)
|
||||
{
|
||||
m_description = newDescription;
|
||||
}
|
||||
|
||||
void TeletextDocument::setFastTextLink(int linkNumber, QString newPageNumberString)
|
||||
{
|
||||
// The LineEdit should check if a valid hex number was entered, but just in case...
|
||||
bool newPageNumberOk;
|
||||
int newPageNumberRead = newPageNumberString.toInt(&newPageNumberOk, 16);
|
||||
if (newPageNumberOk && newPageNumberRead >= 0x100 && newPageNumberRead <= 0x8ff)
|
||||
m_fastTextLink[linkNumber] = newPageNumberRead;
|
||||
}
|
||||
|
||||
void TeletextDocument::cursorUp()
|
||||
{
|
||||
if (--m_cursorRow == 0)
|
||||
m_cursorRow = 24;
|
||||
emit cursorMoved();
|
||||
}
|
||||
|
||||
void TeletextDocument::cursorDown()
|
||||
{
|
||||
if (++m_cursorRow == 25)
|
||||
m_cursorRow = 1;
|
||||
emit cursorMoved();
|
||||
}
|
||||
|
||||
void TeletextDocument::cursorLeft()
|
||||
{
|
||||
if (--m_cursorColumn == -1) {
|
||||
m_cursorColumn = 39;
|
||||
cursorUp();
|
||||
}
|
||||
emit cursorMoved();
|
||||
}
|
||||
|
||||
void TeletextDocument::cursorRight()
|
||||
{
|
||||
if (++m_cursorColumn == 40) {
|
||||
m_cursorColumn = 0;
|
||||
cursorDown();
|
||||
}
|
||||
emit cursorMoved();
|
||||
}
|
||||
|
||||
void TeletextDocument::moveCursor(int newCursorRow, int newCursorColumn)
|
||||
{
|
||||
m_cursorRow = newCursorRow;
|
||||
m_cursorColumn = newCursorColumn;
|
||||
emit cursorMoved();
|
||||
}
|
||||
|
||||
|
||||
OverwriteCharacterCommand::OverwriteCharacterCommand(TeletextDocument *teletextDocument, unsigned char newCharacter, QUndoCommand *parent) : QUndoCommand(parent)
|
||||
{
|
||||
m_teletextDocument = teletextDocument;
|
||||
m_subPageIndex = teletextDocument->currentSubPageIndex();
|
||||
m_row = teletextDocument->cursorRow();
|
||||
m_column = teletextDocument->cursorColumn();
|
||||
m_oldCharacter = teletextDocument->currentSubPage()->character(m_row, m_column);
|
||||
m_newCharacter = newCharacter;
|
||||
}
|
||||
|
||||
void OverwriteCharacterCommand::undo()
|
||||
{
|
||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||
m_teletextDocument->currentSubPage()->setCharacter(m_row, m_column, m_oldCharacter);
|
||||
m_teletextDocument->moveCursor(m_row, m_column);
|
||||
setText(QObject::tr("overwrite char"));
|
||||
emit m_teletextDocument->contentsChange(m_row);
|
||||
}
|
||||
|
||||
void OverwriteCharacterCommand::redo()
|
||||
{
|
||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||
m_teletextDocument->currentSubPage()->setCharacter(m_row, m_column, m_newCharacter);
|
||||
m_teletextDocument->moveCursor(m_row, m_column);
|
||||
m_teletextDocument->cursorRight();
|
||||
setText(QObject::tr("overwrite char"));
|
||||
emit m_teletextDocument->contentsChange(m_row);
|
||||
}
|
||||
|
||||
|
||||
ToggleMosaicBitCommand::ToggleMosaicBitCommand(TeletextDocument *teletextDocument, unsigned char bitToToggle, QUndoCommand *parent) : QUndoCommand(parent)
|
||||
{
|
||||
m_teletextDocument = teletextDocument;
|
||||
m_subPageIndex = teletextDocument->currentSubPageIndex();
|
||||
m_row = teletextDocument->cursorRow();
|
||||
m_column = teletextDocument->cursorColumn();
|
||||
m_oldCharacter = teletextDocument->currentSubPage()->character(m_row, m_column);
|
||||
if (bitToToggle == 0x20 || bitToToggle == 0x7f)
|
||||
m_newCharacter = bitToToggle;
|
||||
else
|
||||
m_newCharacter = m_oldCharacter ^ bitToToggle;
|
||||
}
|
||||
|
||||
void ToggleMosaicBitCommand::undo()
|
||||
{
|
||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||
m_teletextDocument->currentSubPage()->setCharacter(m_row, m_column, m_oldCharacter);
|
||||
m_teletextDocument->moveCursor(m_row, m_column);
|
||||
setText(QObject::tr("mosaic"));
|
||||
emit m_teletextDocument->contentsChange(m_row);
|
||||
}
|
||||
|
||||
void ToggleMosaicBitCommand::redo()
|
||||
{
|
||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||
m_teletextDocument->currentSubPage()->setCharacter(m_row, m_column, m_newCharacter);
|
||||
m_teletextDocument->moveCursor(m_row, m_column);
|
||||
setText(QObject::tr("mosaic"));
|
||||
emit m_teletextDocument->contentsChange(m_row);
|
||||
}
|
||||
|
||||
bool ToggleMosaicBitCommand::mergeWith(const QUndoCommand *command)
|
||||
{
|
||||
const ToggleMosaicBitCommand *previousCommand = static_cast<const ToggleMosaicBitCommand *>(command);
|
||||
|
||||
if (m_subPageIndex != previousCommand->m_subPageIndex || m_row != previousCommand->m_row || m_column != previousCommand->m_column)
|
||||
return false;
|
||||
m_newCharacter = previousCommand->m_newCharacter;
|
||||
return true;
|
||||
}
|
||||
|
||||
BackspaceCommand::BackspaceCommand(TeletextDocument *teletextDocument, QUndoCommand *parent) : QUndoCommand(parent)
|
||||
{
|
||||
m_teletextDocument = teletextDocument;
|
||||
m_subPageIndex = teletextDocument->currentSubPageIndex();
|
||||
m_row = teletextDocument->cursorRow();
|
||||
m_column = teletextDocument->cursorColumn()-1;
|
||||
if (m_column == -1) {
|
||||
m_column = 39;
|
||||
if (--m_row == 0)
|
||||
m_row = 24;
|
||||
}
|
||||
m_deletedCharacter = teletextDocument->currentSubPage()->character(m_row, m_column);
|
||||
}
|
||||
|
||||
void BackspaceCommand::undo()
|
||||
{
|
||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||
m_teletextDocument->currentSubPage()->setCharacter(m_row, m_column, m_deletedCharacter);
|
||||
m_teletextDocument->moveCursor(m_row, m_column);
|
||||
m_teletextDocument->cursorRight();
|
||||
setText(QObject::tr("backspace"));
|
||||
emit m_teletextDocument->contentsChange(m_row);
|
||||
}
|
||||
|
||||
void BackspaceCommand::redo()
|
||||
{
|
||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||
m_teletextDocument->currentSubPage()->setCharacter(m_row, m_column, 0x20);
|
||||
m_teletextDocument->moveCursor(m_row, m_column);
|
||||
setText(QObject::tr("backspace"));
|
||||
emit m_teletextDocument->contentsChange(m_row);
|
||||
}
|
||||
|
||||
|
||||
InsertSubPageCommand::InsertSubPageCommand(TeletextDocument *teletextDocument, bool afterCurrentSubPage, bool copySubPage, QUndoCommand *parent) : QUndoCommand(parent)
|
||||
{
|
||||
m_teletextDocument = teletextDocument;
|
||||
m_newSubPageIndex = teletextDocument->currentSubPageIndex()+afterCurrentSubPage;
|
||||
m_copySubPage = copySubPage;
|
||||
}
|
||||
|
||||
void InsertSubPageCommand::undo()
|
||||
{
|
||||
m_teletextDocument->deleteSubPage(m_newSubPageIndex);
|
||||
//TODO should we always wrench to "subpage viewed when we inserted"? Or just if subpage viewed is being deleted?
|
||||
m_teletextDocument->selectSubPageIndex(m_newSubPageIndex, true);
|
||||
setText(QObject::tr("insert subpage"));
|
||||
}
|
||||
|
||||
void InsertSubPageCommand::redo()
|
||||
{
|
||||
m_teletextDocument->insertSubPage(m_newSubPageIndex, m_copySubPage);
|
||||
m_teletextDocument->selectSubPageIndex(m_newSubPageIndex, true);
|
||||
setText(QObject::tr("insert subpage"));
|
||||
}
|
||||
|
||||
|
||||
SetColourCommand::SetColourCommand(TeletextDocument *teletextDocument, int colourIndex, int newColour, QUndoCommand *parent) : QUndoCommand(parent)
|
||||
{
|
||||
m_teletextDocument = teletextDocument;
|
||||
m_subPageIndex = teletextDocument->currentSubPageIndex();
|
||||
m_colourIndex = colourIndex;
|
||||
m_oldColour = teletextDocument->currentSubPage()->CLUT(colourIndex);
|
||||
m_newColour = newColour;
|
||||
}
|
||||
|
||||
void SetColourCommand::undo()
|
||||
{
|
||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||
m_teletextDocument->currentSubPage()->setCLUT(m_colourIndex, m_oldColour);
|
||||
emit m_teletextDocument->colourChanged(m_colourIndex);
|
||||
setText(QObject::tr("colour change"));
|
||||
emit m_teletextDocument->refreshNeeded();
|
||||
}
|
||||
|
||||
void SetColourCommand::redo()
|
||||
{
|
||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||
m_teletextDocument->currentSubPage()->setCLUT(m_colourIndex, m_newColour);
|
||||
emit m_teletextDocument->colourChanged(m_colourIndex);
|
||||
setText(QObject::tr("colour change"));
|
||||
emit m_teletextDocument->refreshNeeded();
|
||||
}
|
||||
|
||||
|
||||
ResetCLUTCommand::ResetCLUTCommand(TeletextDocument *teletextDocument, int colourTable, QUndoCommand *parent) : QUndoCommand(parent)
|
||||
{
|
||||
m_teletextDocument = teletextDocument;
|
||||
m_subPageIndex = teletextDocument->currentSubPageIndex();
|
||||
m_colourTable = colourTable;
|
||||
for (int i=m_colourTable*8; i<m_colourTable*8+8; i++)
|
||||
m_oldColourEntry[i&7] = teletextDocument->currentSubPage()->CLUT(i);
|
||||
}
|
||||
|
||||
void ResetCLUTCommand::undo()
|
||||
{
|
||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||
for (int i=m_colourTable*8; i<m_colourTable*8+8; i++) {
|
||||
m_teletextDocument->currentSubPage()->setCLUT(i, m_oldColourEntry[i&7]);
|
||||
emit m_teletextDocument->colourChanged(i);
|
||||
}
|
||||
setText(QObject::tr("CLUT %1 reset").arg(m_colourTable));
|
||||
emit m_teletextDocument->refreshNeeded();
|
||||
}
|
||||
|
||||
void ResetCLUTCommand::redo()
|
||||
{
|
||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||
for (int i=m_colourTable*8; i<m_colourTable*8+8; i++) {
|
||||
m_teletextDocument->currentSubPage()->setCLUT(i, m_teletextDocument->currentSubPage()->CLUT(i, 0));
|
||||
emit m_teletextDocument->colourChanged(i);
|
||||
}
|
||||
setText(QObject::tr("CLUT %1 reset").arg(m_colourTable));
|
||||
emit m_teletextDocument->refreshNeeded();
|
||||
}
|
||||
177
document.h
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DOCUMENT_H
|
||||
#define DOCUMENT_H
|
||||
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
#include <QTextStream>
|
||||
#include <QUndoCommand>
|
||||
#include <QUndoStack>
|
||||
#include <vector>
|
||||
#include "document.h"
|
||||
#include "page.h"
|
||||
|
||||
class TeletextDocument : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TeletextDocument();
|
||||
~TeletextDocument();
|
||||
bool isEmpty() const { return m_empty; }
|
||||
void setModified(bool);
|
||||
void loadDocument(QFile *);
|
||||
void saveDocument(QTextStream *);
|
||||
int numberOfSubPages() const { return m_subPages.size(); }
|
||||
TeletextPage* currentSubPage() const { return m_subPages[m_currentSubPageIndex]; }
|
||||
int currentSubPageIndex() const { return m_currentSubPageIndex; }
|
||||
void selectSubPageIndex(int, bool=false);
|
||||
void selectSubPageNext();
|
||||
void selectSubPagePrevious();
|
||||
void insertSubPage(int, bool);
|
||||
void deleteSubPage(int);
|
||||
int pageNumber() const { return m_pageNumber; }
|
||||
void setPageNumber(QString);
|
||||
QString description() const { return m_description; }
|
||||
void setDescription(QString);
|
||||
int fastTextLink(int linkNumber) const { return m_fastTextLink[linkNumber]; }
|
||||
void setFastTextLink(int, QString);
|
||||
QUndoStack *undoStack() const { return m_undoStack; }
|
||||
int cursorRow() const { return m_cursorRow; }
|
||||
int cursorColumn() const { return m_cursorColumn; }
|
||||
void cursorUp();
|
||||
void cursorDown();
|
||||
void cursorLeft();
|
||||
void cursorRight();
|
||||
void moveCursor(int, int);
|
||||
|
||||
signals:
|
||||
void cursorMoved();
|
||||
void colourChanged(int);
|
||||
void contentsChange(int);
|
||||
void aboutToChangeSubPage();
|
||||
void subPageSelected();
|
||||
void refreshNeeded();
|
||||
|
||||
private:
|
||||
QString m_description;
|
||||
bool m_empty;
|
||||
int m_pageNumber, m_currentSubPageIndex;
|
||||
int m_fastTextLink[6];
|
||||
std::vector<TeletextPage *> m_subPages;
|
||||
QUndoStack *m_undoStack;
|
||||
int m_cursorRow, m_cursorColumn;
|
||||
};
|
||||
|
||||
|
||||
class OverwriteCharacterCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
// enum { Id = 1 };
|
||||
|
||||
OverwriteCharacterCommand(TeletextDocument *, unsigned char, QUndoCommand *parent = 0);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
// int id() const override { return Id; }
|
||||
|
||||
private:
|
||||
TeletextDocument *m_teletextDocument;
|
||||
unsigned char m_oldCharacter, m_newCharacter;
|
||||
int m_subPageIndex, m_row, m_column;
|
||||
};
|
||||
|
||||
class ToggleMosaicBitCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
enum { Id = 2 };
|
||||
|
||||
ToggleMosaicBitCommand(TeletextDocument *, unsigned char, QUndoCommand *parent = 0);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
bool mergeWith(const QUndoCommand *) override;
|
||||
int id() const override { return Id; }
|
||||
|
||||
private:
|
||||
TeletextDocument *m_teletextDocument;
|
||||
unsigned char m_oldCharacter, m_newCharacter;
|
||||
int m_subPageIndex, m_row, m_column;
|
||||
};
|
||||
|
||||
class BackspaceCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
// enum { Id = 3 };
|
||||
|
||||
BackspaceCommand(TeletextDocument *, QUndoCommand *parent = 0);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
// int id() const override { return Id; }
|
||||
|
||||
private:
|
||||
TeletextDocument *m_teletextDocument;
|
||||
unsigned char m_deletedCharacter;
|
||||
int m_subPageIndex, m_row, m_column;
|
||||
};
|
||||
|
||||
class InsertSubPageCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
InsertSubPageCommand(TeletextDocument *, bool, bool, QUndoCommand *parent = 0);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
private:
|
||||
TeletextDocument *m_teletextDocument;
|
||||
int m_newSubPageIndex;
|
||||
bool m_copySubPage;
|
||||
};
|
||||
|
||||
class SetColourCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
SetColourCommand(TeletextDocument *, int, int, QUndoCommand *parent = 0);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
private:
|
||||
TeletextDocument *m_teletextDocument;
|
||||
int m_subPageIndex, m_colourIndex, m_oldColour, m_newColour;
|
||||
};
|
||||
|
||||
class ResetCLUTCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
ResetCLUTCommand(TeletextDocument *, int, QUndoCommand *parent = 0);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
private:
|
||||
TeletextDocument *m_teletextDocument;
|
||||
int m_subPageIndex, m_colourTable;
|
||||
int m_oldColourEntry[8];
|
||||
};
|
||||
#endif
|
||||
18
examples/Objects-32Shades.tti
Normal file
@@ -0,0 +1,18 @@
|
||||
DE,32 shades of grey
|
||||
PN,12900
|
||||
SC,0000
|
||||
PS,8000
|
||||
CT,8,T
|
||||
OL,28,@@@|g@@PDaHrLCQTUeYv]GbXfijznKs\wm{~O@@
|
||||
OL,26,@nd@hQHod@hQHpd@hQHqd@hQRrd@hQRsd@hQR_C
|
||||
OL,26,AxUH@@HB`HD@IF`IH@JJ`JL@KN`KP@LR`LT@MV`M
|
||||
OL,26,BX@NZ`N\@O^`OxUR@CHA`HAkWCCICkWE`IEkWGCJ
|
||||
OL,26,CGkWI`JIkWKCKKkWM`KMkWOCLOkWQ`LQkWSCMSkW
|
||||
OL,26,DU`MUkWWCNWkWY`NYkW[CO[kW]`O]kWCCC
|
||||
OL,4, 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||
OL,6,T
|
||||
OL,7,T
|
||||
OL,8,T
|
||||
OL,9,T \
|
||||
OL,10,T \
|
||||
OL,11,T \
|
||||
104
examples/Objects-528Shades.tti
Normal file
@@ -0,0 +1,104 @@
|
||||
DE,528 shades of colour
|
||||
PN,12801
|
||||
SC,0001
|
||||
PS,8000
|
||||
CT,30,T
|
||||
OL,26,@oD@FC@hQ]pD@Fc@hQ]qD@FCAhQ]rD@FcAhQ]sD@
|
||||
OL,26,AFCBhQ]tD@FcBhQ]uD@FCChQ]vD@FcChQ]wD@FCD
|
||||
OL,26,BhQ]xD@FcDhQ]yD@FCEhQ]zD@FcEhQ]{D@FCFhQ]
|
||||
OL,26,C|D@FcFhQ]}D@FCGhQ]~D@FcGhQ]_xU]@@@@kW
|
||||
OL,26,DA`@AkWB@ABkWC`ACkWD@BDkWE`BEkWF@CFkWG`C
|
||||
OL,26,EGkWH@DHkWI`DIkWJ@EJkWK`EKkWL@FLkWM`FMkW
|
||||
OL,26,FN@GNkWO`GOkWP@HPkWQ`HQkWR@IRkWS`ISkWT@J
|
||||
OL,26,GTkWU`JUkWV@KVkWW`KWkWX@LXkWY`LYkWZ@MZkW
|
||||
OL,26,H[`M[kW\@N\kW]`N]kW^@O^kW_`O_kW
|
||||
OL,1, Using an Object to build a F(1/3)
|
||||
OL,2, repetitive tartan pattern.
|
||||
OL,3, CLUTS 0 and 1.
|
||||
OL,4, 0 1 2 3
|
||||
OL,5, 01234567012345670123456701234567
|
||||
OL,7, 00 This page requires a Level 2.5 \
|
||||
OL,8, 1 decoder with support for \
|
||||
OL,9, 2 Active Objects within the \
|
||||
OL,10, 3 Local Enhancement Data. \
|
||||
OL,11, 4 \
|
||||
OL,12, 5 \
|
||||
OL,13, 6 \
|
||||
OL,14, 7 \
|
||||
OL,15, 10 \
|
||||
OL,16, 1 \
|
||||
OL,17, 2 \
|
||||
OL,18, 3 \
|
||||
OL,19, 4 \
|
||||
OL,20, 5 \
|
||||
OL,21, 6 \
|
||||
OL,22, 7 \
|
||||
PN,12802
|
||||
SC,0002
|
||||
PS,8000
|
||||
CT,30,T
|
||||
OL,26,@oD@FCHhQ]pD@FcHhQ]qD@FCIhQ]rD@FcIhQ]sD@
|
||||
OL,26,AFCJhQ]tD@FcJhQ]uD@FCKhQ]vD@FcKhQ]wD@FCL
|
||||
OL,26,BhQ]xD@FcLhQ]yD@FCMhQ]zD@FcMhQ]{D@FCNhQ]
|
||||
OL,26,C|D@FcNhQ]}D@FCOhQ]~D@FcOhQ]_xU]@@@@kW
|
||||
OL,26,DA`@AkWB@ABkWC`ACkWD@BDkWE`BEkWF@CFkWG`C
|
||||
OL,26,EGkWH@DHkWI`DIkWJ@EJkWK`EKkWL@FLkWM`FMkW
|
||||
OL,26,FN@GNkWO`GOkWP@HPkWQ`HQkWR@IRkWS`ISkWT@J
|
||||
OL,26,GTkWU`JUkWV@KVkWW`KWkWX@LXkWY`LYkWZ@MZkW
|
||||
OL,26,H[`M[kW\@N\kW]`N]kW^@O^kW_`O_kW
|
||||
OL,1, Using an Object to build a F(2/3)
|
||||
OL,2, repetitive tartan pattern.
|
||||
OL,3, CLUTS 2 and 3, default palette.
|
||||
OL,4, 0 1 2 3
|
||||
OL,5, 01234567012345670123456701234567
|
||||
OL,7, 20 This page requires a Level 2.5 \
|
||||
OL,8, 1 decoder with support for \
|
||||
OL,9, 2 Active Objects within the \
|
||||
OL,10, 3 Local Enhancement Data. \
|
||||
OL,11, 4 \
|
||||
OL,12, 5 \
|
||||
OL,13, 6 \
|
||||
OL,14, 7 \
|
||||
OL,15, 30 \
|
||||
OL,16, 1 \
|
||||
OL,17, 2 \
|
||||
OL,18, 3 \
|
||||
OL,19, 4 \
|
||||
OL,20, 5 \
|
||||
OL,21, 6 \
|
||||
OL,22, 7 \
|
||||
PN,12803
|
||||
SC,0003
|
||||
PS,8000
|
||||
CT,30,T
|
||||
OL,28,@@@@`P@p@PApAPBpBPCpCPDqLSUu]Wfyn[w}O@@
|
||||
OL,26,@oD@FCHhQ]pD@FcHhQ]qD@FCIhQ]rD@FcIhQ]sD@
|
||||
OL,26,AFCJhQ]tD@FcJhQ]uD@FCKhQ]vD@FcKhQ]wD@FCL
|
||||
OL,26,BhQ]xD@FcLhQ]yD@FCMhQ]zD@FcMhQ]{D@FCNhQ]
|
||||
OL,26,C|D@FcNhQ]}D@FCOhQ]~D@FcOhQ]_xU]@@@@kW
|
||||
OL,26,DA`@AkWB@ABkWC`ACkWD@BDkWE`BEkWF@CFkWG`C
|
||||
OL,26,EGkWH@DHkWI`DIkWJ@EJkWK`EKkWL@FLkWM`FMkW
|
||||
OL,26,FN@GNkWO`GOkWP@HPkWQ`HQkWR@IRkWS`ISkWT@J
|
||||
OL,26,GTkWU`JUkWV@KVkWW`KWkWX@LXkWY`LYkWZ@MZkW
|
||||
OL,26,H[`M[kW\@N\kW]`N]kW^@O^kW_`O_kW
|
||||
OL,1, Using an Object to build a F(3/3)
|
||||
OL,2, repetitive tartan pattern.
|
||||
OL,3, CLUTS 2 and 3, custom palette.
|
||||
OL,4, 0 1 2 3
|
||||
OL,5, 01234567012345670123456701234567
|
||||
OL,7, 20 This page requires a Level 2.5 \
|
||||
OL,8, 1 decoder with support for \
|
||||
OL,9, 2 Active Objects within the \
|
||||
OL,10, 3 Local Enhancement Data. \
|
||||
OL,11, 4 \
|
||||
OL,12, 5 \
|
||||
OL,13, 6 \
|
||||
OL,14, 7 \
|
||||
OL,15, 30 \
|
||||
OL,16, 1 \
|
||||
OL,17, 2 \
|
||||
OL,18, 3 \
|
||||
OL,19, 4 \
|
||||
OL,20, 5 \
|
||||
OL,21, 6 \
|
||||
OL,22, 7 \
|
||||
79
examples/Objects-FastDogCat.tti
Normal file
@@ -0,0 +1,79 @@
|
||||
DE,Object test based on clause 13.9 of ETSI EN 300 706
|
||||
PN,12001
|
||||
SC,0001
|
||||
PS,8000
|
||||
CT,30,T
|
||||
OL,26,@tD@T`NwdGhqIxD@T`NzdGhRS{D@T`N}dGhs\~D@
|
||||
OL,26,AT`N\`N_CxuI@IfAi`BImCilE`NEiaFigGikMIc
|
||||
OL,26,BNigOIlQ`AQiiRi`SIjxVS@IfAi`BImCilE`NEia
|
||||
OL,26,CFigGikMIcNigOIlQ`AQiiRi`SIjxw\@IfAi`BIm
|
||||
OL,26,DCilE`NEiaFigGikMIcNigOIlQ`AQiiRi`SIjB
|
||||
OL,1, This test is described in clause F(1/3)
|
||||
OL,2, 13.9 of ETSI EN 300 706. Adding objects
|
||||
OL,3, over the top line of each test should
|
||||
OL,4, match the expected result on the line
|
||||
OL,5, below.
|
||||
OL,6, The objects on this subpage do not set
|
||||
OL,7, the Active Position.
|
||||
OL,9, Level 1 DTHE FAST DOG ANDACATBRAN IN
|
||||
OL,10, b r g
|
||||
OL,12, Object LAZY COW FOXCSAT
|
||||
OL,13, p y
|
||||
OL,15, ActiveDTHE FAST DOG ANDACATBRAN IN
|
||||
OL,16, should beDTHE LAZY COW ANDAFOXCSAT IN
|
||||
OL,18, AdaptiveDTHE FAST DOG ANDACATBRAN IN
|
||||
OL,19, should beDTHE LAZY COW AND FOXCSATBIN
|
||||
OL,21, PassiveDTHE FAST DOG ANDACATBRAN IN
|
||||
OL,22, should beDTHEGLAZY COWDAND FOXCSATBIN
|
||||
PN,12002
|
||||
SC,0002
|
||||
PS,8000
|
||||
CT,30,T
|
||||
OL,26,@tD@T`NvdGhqIxD@T`NydGhrS{D@T`N|dGhs]~D@
|
||||
OL,26,AT`N\`N_CxuIiD@@IfAi`BImCilE`NEiaFigGik
|
||||
OL,26,BMIcNigOIlQ`AQiiRi`SIjxvSiD@@IfAi`BImCil
|
||||
OL,26,CE`NEiaFigGikMIcNigOIlQ`AQiiRi`SIjxw]iD@
|
||||
OL,26,D@IfAi`BImCilE`NEiaFigGikMIcNigOIlQ`AQii
|
||||
OL,26,ERi`SIjBBBBBBBBBBB
|
||||
OL,1, This test is described in clause F(2/3)
|
||||
OL,2, 13.9 of ETSI EN 300 706.
|
||||
OL,4, The objects on this subpage set the
|
||||
OL,5, Active Position to row 1 column 0. They
|
||||
OL,6, are invoked two rows above the "should
|
||||
OL,7, be" rows.
|
||||
OL,9, Level 1 DTHE FAST DOG ANDACATBRAN IN
|
||||
OL,10, b r g
|
||||
OL,12, Object LAZY COW FOXCSAT
|
||||
OL,13, p y
|
||||
OL,15, ActiveDTHE FAST DOG ANDACATBRAN IN
|
||||
OL,16, should beDTHE LAZY COW ANDAFOXCSAT IN
|
||||
OL,18, AdaptiveDTHE FAST DOG ANDACATBRAN IN
|
||||
OL,19, should beDTHE LAZY COW AND FOXCSATBIN
|
||||
OL,21, PassiveDTHE FAST DOG ANDACATBRAN IN
|
||||
OL,22, should beDTHEGLAZY COWDAND FOXCSATBIN
|
||||
PN,12003
|
||||
SC,0003
|
||||
PS,8000
|
||||
CT,30,T
|
||||
OL,26,@tD@T`NvdGiP@hQKxD@T`NydGiP@hrT{D@T`N|dG
|
||||
OL,26,AiP@hS^~D@T`N\`N_CxUK@IfAi`BImCilE`NEia
|
||||
OL,26,BFigGikMIcNigOIlQ`AQiiRi`SIjxvT@IfAi`BIm
|
||||
OL,26,CCilE`NEiaFigGikMIcNigOIlQ`AQiiRi`SIjxW^
|
||||
OL,26,D@IfAi`BImCilE`NEiaFigGikMIcNigOIlQ`AQii
|
||||
OL,26,ERi`SIjBBBBBBBBBBB
|
||||
OL,1, This test is described in clause F(3/3)
|
||||
OL,2, 13.9 of ETSI EN 300 706.
|
||||
OL,4, The objects on this subpage are invoked
|
||||
OL,5, two rows above the "should be" rows but
|
||||
OL,6, are preceded by an Origin Modifier with
|
||||
OL,7, a Row Offset of 1.
|
||||
OL,9, Level 1 DTHE FAST DOG ANDACATBRAN IN
|
||||
OL,10, b r g
|
||||
OL,12, Object LAZY COW FOXCSAT
|
||||
OL,13, p y
|
||||
OL,15, ActiveDTHE FAST DOG ANDACATBRAN IN
|
||||
OL,16, should beDTHE LAZY COW ANDAFOXCSAT IN
|
||||
OL,18, AdaptiveDTHE FAST DOG ANDACATBRAN IN
|
||||
OL,19, should beDTHE LAZY COW AND FOXCSATBIN
|
||||
OL,21, PassiveDTHE FAST DOG ANDACATBRAN IN
|
||||
OL,22, should beDTHEGLAZY COWDAND FOXCSATBIN
|
||||
34
examples/Rio.tti
Normal file
@@ -0,0 +1,34 @@
|
||||
DE,Duran Duran Rio album cover
|
||||
CT,30,T
|
||||
PN,15100
|
||||
SC,0000
|
||||
PS,8000
|
||||
OL,28,@@@|g@@@FtiioE@}BFw~Ls_w}ww]_}_wM@p
|
||||
OL,26,@jD@D@KoD@S`GV`KpD@Q`GqD@L`GV`KWcOXCH[`G
|
||||
OL,26,ArD@M`GP`KVcOZCHsD@M`GP`KPcOZCH]`J]A}tD@
|
||||
OL,26,BM`GP`K]cJuD@]cJxD@Sc@UCHVc@yD@Sc@XCH[cJ
|
||||
OL,26,CzD@O`GR`NS`KTc@WCHZcN{D@M`GR`NT`KYcN|D@
|
||||
OL,26,DS`NT`KTcN}D@TcN~D@UcND@VcNCCCC
|
||||
OL,1,A] \
|
||||
OL,2,A]GND U R A N D U R A N L \
|
||||
OL,3,A] \
|
||||
OL,4,Q] \ U*k] V+\
|
||||
OL,5,Q]V p \ U"]S8# V"o\
|
||||
OL,6,Q]V p,# W\ <,d l, U+]W8,,0V\
|
||||
OL,7,Q]V# W\ *##)$ Z(dY(.$S`,#U]W),,!V"o\
|
||||
OL,8,Q]V p,# W\Z (d #dYS8! U] \
|
||||
OL,9,Q]V,# W\Zp #,,0i Yxw|0Z,#U] \
|
||||
OL,10,Q]V p, W\Z #,Yx||tp~?~?~4 U] \
|
||||
OL,11,Q]Vp,# W\Z ,#Y{~}} `U] \
|
||||
OL,12,Q]V p W\Z )dYss//s| ~U] \
|
||||
OL,13,Q]V p,# W\ u$&~})(z5oU] \
|
||||
OL,14,Q]V# S\ p&Wo]U] \
|
||||
OL,15,Q]V p,# S\`& W"?]Uz] \
|
||||
OL,16,Q]V,# S\! Wk/o~//]U] R`8#\
|
||||
OL,17,Q]V p, W\ ot,,,x?yU] R`,! \
|
||||
OL,18,Q]Vp,# W\Z `&Y`o}|~g~a]U*]Rp&! \
|
||||
OL,19,Q]V W\Z 8&!Y "u+//y7z]U] \
|
||||
OL,20,Q] W\ "*a]U] S`8#\
|
||||
OL,21,Q] W\ pp||5o5~]U] S`,! \
|
||||
OL,22,Q] W\ `~2o?h]U`~]Sp&! \
|
||||
OL,23,Q] W\htu]Uh]S8& \
|
||||
34
examples/SidePanels-NightMail.tti
Normal file
@@ -0,0 +1,34 @@
|
||||
DE,Demo of 48 column display with side panels
|
||||
PN,12100
|
||||
SC,0000
|
||||
PS,8000
|
||||
CT,8,T
|
||||
OL,28,@@@|wxCu_@|wKpZA`UB_wLs_w}ww]_}_wM@@
|
||||
OL,26,@iAB@CBAl@jAB@CBlD@hPThRHAB@CBhPThQ^_C
|
||||
OL,26,AxVH@IrAirBIyCIViD@@IyAIVjD@@iwAiwBIyCIV
|
||||
OL,26,BkD@@iwAiwBIyCIWmD@@IwBIzCitDivEirFIWpD@
|
||||
OL,26,C@IyAIVtD@@iyAIVuD@@ipAiqBItCirDiyEIWxU^
|
||||
OL,26,D@`B@LB@IXAiXBIYCiYDIZEiZFI[Gi[HIPBB
|
||||
OL,1, "Night Mail" by W.H.Auden
|
||||
OL,2,ELevel 2.5 & side panels & adaptive objs
|
||||
OL,3, X|
|
||||
OL,4, This is the night mail crossing the bor
|
||||
OL,5, Bringing the cheque and the postal orde
|
||||
OL,6, Letters for the rich, letters for the p
|
||||
OL,7, The shop at the corner, the girl next d
|
||||
OL,8, Pulling up Beattock, a steady climb: X|
|
||||
OL,9, The gradient's against her, but she's o
|
||||
OL,10, X|
|
||||
OL,11, Past cotton-grass and moorland boulder
|
||||
OL,12, Shovelling white steam over her shoulde
|
||||
OL,13, Snorting noisily as she passes X|
|
||||
OL,14, Silent miles of wind-bent grasses. X|
|
||||
OL,15, X|
|
||||
OL,16, Birds turn their heads as she approache
|
||||
OL,17, Stare from bushes at her blank-faced co
|
||||
OL,18, Sheep-dogs cannot turn her course; X|
|
||||
OL,19, They slumber on with paws across. X|
|
||||
OL,20, In the farm she passes no-one wakes, X|
|
||||
OL,21, But a jug in a bedroom gently shakes.X|
|
||||
OL,22, X|
|
||||
OL,23,X123456789012345678901234567890123456789
|
||||
17
examples/ZZTop.tti
Normal file
@@ -0,0 +1,17 @@
|
||||
DE,ZZ Top logo
|
||||
CT,30,T
|
||||
PN,15000
|
||||
SC,0000
|
||||
PS,8000
|
||||
OL,28,@@@@`@@PMA|goApZA`UB_wLs_w}ww]_}_wM@p
|
||||
OL,26,@qD@CKXDkTPkyQKsrD@BkYCKSSKxTktsD@IkYJKS
|
||||
OL,26,AMKXNkTRkySKstD@GKXHkTLkYMKSPKxQktuD@FkY
|
||||
OL,26,BGKSJKXKkTOkyPKsvD@DKXEkTIkYJKSMKxNktcky
|
||||
OL,26,CdKswD@GKXHkTaKxbkt
|
||||
OL,9,Q x?!
|
||||
OL,10,S `~'pppp0pppp0pppp0
|
||||
OL,11,Q `~]S x^\?!"{?#c~'cg~'c'
|
||||
OL,12,Q x]S `~^\' `~' x}|?y///!
|
||||
OL,13,Q `~]S x^\?! #! "####"#!
|
||||
OL,14,Q x]S `~' Q^\?!
|
||||
OL,15,S x'
|
||||
BIN
images/copy.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
images/cut.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
images/new.png
Normal file
|
After Width: | Height: | Size: 852 B |
BIN
images/open.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
images/paste.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
images/save.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
images/teletextfont.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
53
main.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Q_INIT_RESOURCE(qteletextmaker);
|
||||
QApplication app(argc, argv);
|
||||
QCoreApplication::setApplicationName("QTeletextMaker");
|
||||
QCoreApplication::setOrganizationName("gkmac.co.uk");
|
||||
QCoreApplication::setOrganizationDomain("gkmac.co.uk");
|
||||
QCoreApplication::setApplicationVersion("0.1-alpha");
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription(QCoreApplication::applicationName());
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
parser.addPositionalArgument("file", "The file(s) to open.");
|
||||
parser.process(app);
|
||||
|
||||
MainWindow *mainWin = Q_NULLPTR;
|
||||
foreach (const QString &file, parser.positionalArguments()) {
|
||||
MainWindow *newWin = new MainWindow(file);
|
||||
newWin->tile(mainWin);
|
||||
newWin->show();
|
||||
mainWin = newWin;
|
||||
}
|
||||
|
||||
if (!mainWin)
|
||||
mainWin = new MainWindow;
|
||||
mainWin->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
363
mainwidget.cpp
Normal file
@@ -0,0 +1,363 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QBitmap>
|
||||
#include <QFrame>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
#include <QUndoCommand>
|
||||
#include <QWidget>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include "mainwidget.h"
|
||||
|
||||
#include "document.h"
|
||||
#include "page.h"
|
||||
#include "render.h"
|
||||
#include "x26triplets.h"
|
||||
|
||||
TeletextWidget::TeletextWidget(QFrame *parent) : QFrame(parent)
|
||||
{
|
||||
this->resize(QSize(480, 250));
|
||||
this->setAttribute(Qt::WA_NoSystemBackground);
|
||||
m_teletextDocument = new TeletextDocument();
|
||||
m_teletextPage = m_teletextDocument->currentSubPage();
|
||||
m_pageRender.setTeletextPage(m_teletextPage);
|
||||
m_insertMode = false;
|
||||
m_grid = false;
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
m_flashTiming = m_flashPhase = 0;
|
||||
connect(&m_pageRender, &TeletextPageRender::flashChanged, this, &TeletextWidget::updateFlashTimer);
|
||||
connect(&m_pageRender, &TeletextPageRender::sidePanelsChanged, this, &TeletextWidget::changeSize);
|
||||
connect(m_teletextDocument, &TeletextDocument::subPageSelected, this, &TeletextWidget::subPageSelected);
|
||||
connect(m_teletextDocument, &TeletextDocument::contentsChange, this, &TeletextWidget::refreshRow);
|
||||
connect(m_teletextDocument, &TeletextDocument::refreshNeeded, this, &TeletextWidget::refreshPage);
|
||||
}
|
||||
|
||||
TeletextWidget::~TeletextWidget()
|
||||
{
|
||||
if (m_flashTimer.isActive())
|
||||
m_flashTimer.stop();
|
||||
delete m_teletextDocument;
|
||||
}
|
||||
|
||||
void TeletextWidget::subPageSelected()
|
||||
{
|
||||
m_teletextPage = m_teletextDocument->currentSubPage();
|
||||
m_pageRender.setTeletextPage(m_teletextPage);
|
||||
refreshPage();
|
||||
}
|
||||
|
||||
void TeletextWidget::refreshRow(int rowChanged)
|
||||
{
|
||||
m_pageRender.renderPage(rowChanged);
|
||||
update();
|
||||
}
|
||||
|
||||
void TeletextWidget::refreshPage()
|
||||
{
|
||||
m_pageRender.decodePage();
|
||||
m_pageRender.renderPage();
|
||||
update();
|
||||
}
|
||||
|
||||
void TeletextWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
QPainter widgetPainter(this);
|
||||
|
||||
widgetPainter.drawPixmap(m_pageRender.leftSidePanelColumns()*12, 0, *m_pageRender.pagePixmap(m_flashPhase), 0, 0, 480, 250);
|
||||
if (m_pageRender.leftSidePanelColumns())
|
||||
widgetPainter.drawPixmap(0, 0, *m_pageRender.pagePixmap(m_flashPhase), 864-m_pageRender.leftSidePanelColumns()*12, 0, m_pageRender.leftSidePanelColumns()*12, 250);
|
||||
if (m_pageRender.rightSidePanelColumns())
|
||||
widgetPainter.drawPixmap(480+m_pageRender.leftSidePanelColumns()*12, 0, *m_pageRender.pagePixmap(m_flashPhase), 480, 0, m_pageRender.rightSidePanelColumns()*12, 250);
|
||||
if (this->hasFocus())
|
||||
widgetPainter.fillRect((m_teletextDocument->cursorColumn()+m_pageRender.leftSidePanelColumns())*12, m_teletextDocument->cursorRow()*10, 12, 10, QColor(128, 128, 128, 192));
|
||||
}
|
||||
|
||||
void TeletextWidget::updateFlashTimer(int newFlashTimer)
|
||||
{
|
||||
m_flashTiming = newFlashTimer;
|
||||
m_flashPhase = 0;
|
||||
if (newFlashTimer == 0) {
|
||||
m_flashTimer.stop();
|
||||
update();
|
||||
return;
|
||||
}
|
||||
m_flashTimer.start((newFlashTimer == 1) ? 500 : 167, this);
|
||||
}
|
||||
|
||||
void TeletextWidget::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (event->timerId() == m_flashTimer.timerId()) {
|
||||
if (m_flashTiming == 1)
|
||||
m_flashPhase += 3;
|
||||
else
|
||||
m_flashPhase++;
|
||||
if (m_flashPhase == 6)
|
||||
m_flashPhase = 0;
|
||||
update();
|
||||
} else
|
||||
QWidget::timerEvent(event);
|
||||
}
|
||||
|
||||
void TeletextWidget::toggleReveal(bool revealOn)
|
||||
{
|
||||
m_pageRender.setReveal(revealOn);
|
||||
update();
|
||||
}
|
||||
|
||||
void TeletextWidget::toggleMix(bool mixOn)
|
||||
{
|
||||
m_pageRender.setMix(mixOn);
|
||||
update();
|
||||
}
|
||||
|
||||
void TeletextWidget::toggleGrid(bool gridOn)
|
||||
{
|
||||
m_grid = gridOn;
|
||||
m_pageRender.setGrid(gridOn);
|
||||
m_pageRender.renderPage();
|
||||
}
|
||||
|
||||
void TeletextWidget::setControlBit(int bitNumber, bool active)
|
||||
{
|
||||
m_teletextPage->setControlBit(bitNumber, active);
|
||||
if (bitNumber == 1 || bitNumber == 2) {
|
||||
m_pageRender.decodePage();
|
||||
m_pageRender.renderPage();
|
||||
}
|
||||
}
|
||||
|
||||
void TeletextWidget::setDefaultCharSet(int newDefaultCharSet)
|
||||
{
|
||||
m_teletextPage->setDefaultCharSet(newDefaultCharSet);
|
||||
}
|
||||
|
||||
void TeletextWidget::setDefaultNOS(int newDefaultNOS)
|
||||
{
|
||||
m_teletextPage->setDefaultNOS(newDefaultNOS);
|
||||
}
|
||||
|
||||
void TeletextWidget::setDefaultScreenColour(int newColour)
|
||||
{
|
||||
m_teletextPage->setDefaultScreenColour(newColour);
|
||||
m_pageRender.decodePage();
|
||||
m_pageRender.renderPage();
|
||||
}
|
||||
|
||||
void TeletextWidget::setDefaultRowColour(int newColour)
|
||||
{
|
||||
m_teletextPage->setDefaultRowColour(newColour);
|
||||
m_pageRender.decodePage();
|
||||
m_pageRender.renderPage();
|
||||
}
|
||||
|
||||
void TeletextWidget::setColourTableRemap(int newMap)
|
||||
{
|
||||
m_teletextPage->setColourTableRemap(newMap);
|
||||
m_pageRender.decodePage();
|
||||
m_pageRender.renderPage();
|
||||
}
|
||||
|
||||
void TeletextWidget::setBlackBackgroundSubst(bool substOn)
|
||||
{
|
||||
m_teletextPage->setBlackBackgroundSubst(substOn);
|
||||
m_pageRender.decodePage();
|
||||
m_pageRender.renderPage();
|
||||
}
|
||||
|
||||
void TeletextWidget::setSidePanelWidths(int newLeftSidePanelColumns, int newRightSidePanelColumns)
|
||||
{
|
||||
m_teletextPage->setLeftSidePanelDisplayed(newLeftSidePanelColumns != 0);
|
||||
m_teletextPage->setRightSidePanelDisplayed(newRightSidePanelColumns != 0);
|
||||
if (newLeftSidePanelColumns)
|
||||
m_teletextPage->setSidePanelColumns((newLeftSidePanelColumns == 16) ? 0 : newLeftSidePanelColumns);
|
||||
else
|
||||
m_teletextPage->setSidePanelColumns((newRightSidePanelColumns == 0) ? 0 : 16-newRightSidePanelColumns);
|
||||
m_pageRender.updateSidePanels();
|
||||
}
|
||||
|
||||
void TeletextWidget::setSidePanelAtL35Only(bool newSidePanelAtL35Only)
|
||||
{
|
||||
m_teletextPage->setSidePanelStatusL25(!newSidePanelAtL35Only);
|
||||
m_pageRender.updateSidePanels();
|
||||
}
|
||||
|
||||
void TeletextWidget::changeSize()
|
||||
{
|
||||
setFixedSize(QSize(480+(pageRender()->leftSidePanelColumns()+pageRender()->rightSidePanelColumns())*12, 250));
|
||||
emit sizeChanged();
|
||||
}
|
||||
|
||||
void TeletextWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() < 0x01000000) {
|
||||
char keyPressed = *qPrintable(event->text());
|
||||
// if (attributes[cursorRow][cursorColumn].mosaics && (keyPressed < 0x40 || keyPressed > 0x5f) && (((keyPressed >= '1' && keyPressed <= '9') && (event->modifiers() & Qt::KeypadModifier)) || (keyPressed >= 'a' && keyPressed <= 'z'))) {
|
||||
if (m_pageRender.level1MosaicAttribute(m_teletextDocument->cursorRow(), m_teletextDocument->cursorColumn()) && (keyPressed < 0x40 || keyPressed > 0x5f) && (((keyPressed >= '1' && keyPressed <= '9') && (event->modifiers() & Qt::KeypadModifier)) || (keyPressed >= 'a' && keyPressed <= 'z'))) {
|
||||
if (!(m_teletextPage->character(m_teletextDocument->cursorRow(), m_teletextDocument->cursorColumn()) & 0x20))
|
||||
setCharacter(0x20);
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Q:
|
||||
case Qt::Key_7:
|
||||
toggleCharacterBit(0x01); // Top left
|
||||
break;
|
||||
case Qt::Key_W:
|
||||
case Qt::Key_8:
|
||||
toggleCharacterBit(0x02); // Top right
|
||||
break;
|
||||
case Qt::Key_A:
|
||||
case Qt::Key_4:
|
||||
toggleCharacterBit(0x04); // Middle left
|
||||
break;
|
||||
case Qt::Key_S:
|
||||
case Qt::Key_5:
|
||||
toggleCharacterBit(0x08); // Middle right
|
||||
break;
|
||||
case Qt::Key_Z:
|
||||
case Qt::Key_2:
|
||||
toggleCharacterBit(0x40); // Bottom left
|
||||
break;
|
||||
case Qt::Key_X:
|
||||
case Qt::Key_1:
|
||||
toggleCharacterBit(0x10); // Bottom right
|
||||
break;
|
||||
case Qt::Key_R:
|
||||
case Qt::Key_9:
|
||||
toggleCharacterBit(0x5f); // Invert
|
||||
break;
|
||||
case Qt::Key_F:
|
||||
case Qt::Key_6:
|
||||
toggleCharacterBit(0x7f); // Set all
|
||||
break;
|
||||
case Qt::Key_C:
|
||||
case Qt::Key_3:
|
||||
toggleCharacterBit(0x20); // Clear all
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (keyPressed == 0x20)
|
||||
setCharacter((event->modifiers() & Qt::ShiftModifier) ? 0x7f : 0x20);
|
||||
else
|
||||
setCharacter(keyPressed);
|
||||
return;
|
||||
}
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Backspace:
|
||||
backspaceEvent();
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
m_teletextDocument->cursorUp();
|
||||
update();
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
m_teletextDocument->cursorDown();
|
||||
update();
|
||||
break;
|
||||
case Qt::Key_Left:
|
||||
m_teletextDocument->cursorLeft();
|
||||
update();
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
m_teletextDocument->cursorRight();
|
||||
update();
|
||||
break;
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
m_teletextDocument->cursorDown();
|
||||
// fall through
|
||||
case Qt::Key_Home:
|
||||
m_teletextDocument->moveCursor(m_teletextDocument->cursorRow(), 0);
|
||||
update();
|
||||
break;
|
||||
case Qt::Key_End:
|
||||
m_teletextDocument->moveCursor(m_teletextDocument->cursorRow(), 39);
|
||||
update();
|
||||
break;
|
||||
|
||||
case Qt::Key_PageUp:
|
||||
m_teletextDocument->selectSubPageNext();
|
||||
break;
|
||||
case Qt::Key_PageDown:
|
||||
m_teletextDocument->selectSubPagePrevious();
|
||||
break;
|
||||
case Qt::Key_F5:
|
||||
m_pageRender.decodePage();
|
||||
m_pageRender.renderPage();
|
||||
update();
|
||||
break;
|
||||
default:
|
||||
QFrame::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void TeletextWidget::setCharacter(unsigned char newCharacter)
|
||||
{
|
||||
QUndoCommand *overwriteCharacterCommand = new OverwriteCharacterCommand(m_teletextDocument, newCharacter);
|
||||
m_teletextDocument->undoStack()->push(overwriteCharacterCommand);
|
||||
}
|
||||
|
||||
void TeletextWidget::toggleCharacterBit(unsigned char bitToToggle)
|
||||
{
|
||||
QUndoCommand *toggleMosaicBitCommand = new ToggleMosaicBitCommand(m_teletextDocument, bitToToggle);
|
||||
m_teletextDocument->undoStack()->push(toggleMosaicBitCommand);
|
||||
}
|
||||
|
||||
void TeletextWidget::backspaceEvent()
|
||||
{
|
||||
QUndoCommand *backspaceCommand = new BackspaceCommand(m_teletextDocument);
|
||||
m_teletextDocument->undoStack()->push(backspaceCommand);
|
||||
}
|
||||
|
||||
void TeletextWidget::cursorToMouse(QPoint mousePosition)
|
||||
{
|
||||
int newCursorRow = mousePosition.y() / 10;
|
||||
int newCursorColumn = mousePosition.x() / 12 - m_pageRender.leftSidePanelColumns();
|
||||
if (newCursorRow < 1)
|
||||
newCursorRow = 1;
|
||||
if (newCursorRow > 24)
|
||||
newCursorRow = 24;
|
||||
if (newCursorColumn < 0)
|
||||
newCursorColumn = 0;
|
||||
if (newCursorColumn > 39)
|
||||
newCursorColumn = 39;
|
||||
m_teletextDocument->moveCursor(newCursorRow, newCursorColumn);
|
||||
}
|
||||
|
||||
void TeletextWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
cursorToMouse(event->pos());
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void TeletextWidget::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
QFrame::focusInEvent(event);
|
||||
}
|
||||
|
||||
void TeletextWidget::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
QFrame::focusOutEvent(event);
|
||||
}
|
||||
96
mainwidget.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MAINWIDGET_H
|
||||
#define MAINWIDGET_H
|
||||
|
||||
#include <QBasicTimer>
|
||||
#include <QFrame>
|
||||
#include <QTextStream>
|
||||
#include <vector>
|
||||
|
||||
#include "document.h"
|
||||
#include "page.h"
|
||||
#include "render.h"
|
||||
|
||||
class QPaintEvent;
|
||||
|
||||
class TeletextWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TeletextWidget(QFrame *parent = 0);
|
||||
~TeletextWidget();
|
||||
void setCharacter(unsigned char);
|
||||
void toggleCharacterBit(unsigned char);
|
||||
void backspaceEvent();
|
||||
|
||||
QSize sizeHint() { return QSize(480+(pageRender()->leftSidePanelColumns()+pageRender()->rightSidePanelColumns())*12, 250); }
|
||||
|
||||
TeletextDocument* document() const { return m_teletextDocument; }
|
||||
TeletextPageRender *pageRender() { return &m_pageRender; }
|
||||
|
||||
signals:
|
||||
void sizeChanged();
|
||||
|
||||
public slots:
|
||||
void subPageSelected();
|
||||
void refreshPage();
|
||||
void toggleReveal(bool);
|
||||
void toggleMix(bool);
|
||||
void toggleGrid(bool);
|
||||
void updateFlashTimer(int);
|
||||
void refreshRow(int);
|
||||
|
||||
void setControlBit(int, bool);
|
||||
void setDefaultCharSet(int);
|
||||
void setDefaultNOS(int);
|
||||
void setDefaultScreenColour(int);
|
||||
void setDefaultRowColour(int);
|
||||
void setColourTableRemap(int);
|
||||
void setBlackBackgroundSubst(bool);
|
||||
void setSidePanelWidths(int, int);
|
||||
void setSidePanelAtL35Only(bool);
|
||||
void changeSize();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
void focusOutEvent(QFocusEvent *event) override;
|
||||
|
||||
TeletextPageRender m_pageRender;
|
||||
|
||||
private:
|
||||
TeletextDocument* m_teletextDocument;
|
||||
TeletextPage* m_teletextPage;
|
||||
bool m_insertMode, m_grid;
|
||||
QBasicTimer m_flashTimer;
|
||||
int m_flashTiming, m_flashPhase;
|
||||
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
void calculateDimensions();
|
||||
|
||||
void cursorToMouse(QPoint mousePosition);
|
||||
};
|
||||
|
||||
#endif
|
||||
834
mainwindow.cpp
Normal file
@@ -0,0 +1,834 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QList>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QRadioButton>
|
||||
#include <QScreen>
|
||||
#include <QSettings>
|
||||
#include <QStatusBar>
|
||||
#include <QToolBar>
|
||||
#include <iostream>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "mainwidget.h"
|
||||
#include "pageoptionsdockwidget.h"
|
||||
#include "palettedockwidget.h"
|
||||
#include "x26dockwidget.h"
|
||||
#include "x28dockwidget.h"
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
init();
|
||||
setCurrentFile(QString());
|
||||
m_textWidget->refreshPage();
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(const QString &fileName)
|
||||
{
|
||||
init();
|
||||
loadFile(fileName);
|
||||
m_textWidget->refreshPage();
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (maybeSave()) {
|
||||
writeSettings();
|
||||
event->accept();
|
||||
} else
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void MainWindow::newFile()
|
||||
{
|
||||
MainWindow *other = new MainWindow;
|
||||
other->tile(this);
|
||||
other->show();
|
||||
}
|
||||
|
||||
void MainWindow::open()
|
||||
{
|
||||
const QString fileName = QFileDialog::getOpenFileName(this);
|
||||
if (!fileName.isEmpty())
|
||||
openFile(fileName);
|
||||
}
|
||||
|
||||
void MainWindow::openFile(const QString &fileName)
|
||||
{
|
||||
MainWindow *existing = findMainWindow(fileName);
|
||||
if (existing) {
|
||||
existing->show();
|
||||
existing->raise();
|
||||
existing->activateWindow();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isUntitled && m_textWidget->document()->isEmpty() && !isWindowModified()) {
|
||||
loadFile(fileName);
|
||||
m_textWidget->refreshPage();
|
||||
return;
|
||||
}
|
||||
|
||||
MainWindow *other = new MainWindow(fileName);
|
||||
if (other->m_isUntitled) {
|
||||
delete other;
|
||||
return;
|
||||
}
|
||||
other->tile(this);
|
||||
other->show();
|
||||
}
|
||||
|
||||
bool MainWindow::save()
|
||||
{
|
||||
return m_isUntitled ? saveAs() : saveFile(m_curFile);
|
||||
}
|
||||
|
||||
bool MainWindow::saveAs()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), m_curFile);
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
|
||||
return saveFile(fileName);
|
||||
}
|
||||
|
||||
void MainWindow::exportURL()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(m_textWidget->document()->currentSubPage()->exportURLHash("http://www.zxnet.co.uk/teletext/editor/")));
|
||||
}
|
||||
|
||||
void MainWindow::about()
|
||||
{
|
||||
QMessageBox::about(this, tr("About QTeletextMaker"), tr("<b>QTeletextMaker</b><br><i>Pre-alpha version</i>.<br><br>Copyright (C) 2020 Gavin MacGregor<br><br>Released under the GNU General Public License version 3"));
|
||||
}
|
||||
|
||||
void MainWindow::init()
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
m_isUntitled = true;
|
||||
|
||||
m_textWidget = new TeletextWidget;
|
||||
|
||||
m_paletteDock = new PaletteDockWidget(m_textWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, m_paletteDock);
|
||||
m_x26Dock = new X26DockWidget(m_textWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, m_x26Dock);
|
||||
m_x28Dock = new X28DockWidget(m_textWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, m_x28Dock);
|
||||
m_pageOptionsDock = new PageOptionsDockWidget(m_textWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, m_pageOptionsDock);
|
||||
|
||||
createActions();
|
||||
createStatusBar();
|
||||
|
||||
readSettings();
|
||||
|
||||
m_textScene = new QGraphicsScene(this);
|
||||
m_textScene->setSceneRect(0, 0, 600, 288);
|
||||
m_fullScreenTopRectItem = new QGraphicsRectItem(0, 0, 600, 19);
|
||||
m_fullScreenTopRectItem->setPen(Qt::NoPen);
|
||||
m_fullScreenTopRectItem->setBrush(QBrush(QColor(0, 0, 0)));
|
||||
m_textScene->addItem(m_fullScreenTopRectItem);
|
||||
m_fullScreenBottomRectItem = new QGraphicsRectItem(0, 269, 600, 19);
|
||||
m_fullScreenBottomRectItem->setPen(Qt::NoPen);
|
||||
m_fullScreenBottomRectItem->setBrush(QBrush(QColor(0, 0, 0)));
|
||||
m_textScene->addItem(m_fullScreenBottomRectItem);
|
||||
|
||||
for (int r=0; r<25; r++) {
|
||||
m_fullRowLeftRectItem[r] = new QGraphicsRectItem(0, 19+r*10, 60, 10);
|
||||
m_fullRowLeftRectItem[r]->setPen(Qt::NoPen);
|
||||
m_fullRowLeftRectItem[r]->setBrush(QBrush(QColor(0, 0, 0)));
|
||||
m_textScene->addItem(m_fullRowLeftRectItem[r]);
|
||||
m_fullRowRightRectItem[r] = new QGraphicsRectItem(540, 19+r*10, 60, 10);
|
||||
m_fullRowRightRectItem[r]->setPen(Qt::NoPen);
|
||||
m_fullRowRightRectItem[r]->setBrush(QBrush(QColor(0, 0, 0)));
|
||||
m_textScene->addItem(m_fullRowRightRectItem[r]);
|
||||
}
|
||||
|
||||
m_textProxyWidget = m_textScene->addWidget(m_textWidget);
|
||||
m_textProxyWidget->setPos(60, 19);
|
||||
m_textProxyWidget->setAutoFillBackground(false);
|
||||
|
||||
m_textView = new QGraphicsView(this);
|
||||
m_textView->setScene(m_textScene);
|
||||
m_textView->setRenderHints(QPainter::SmoothPixmapTransform);
|
||||
m_textView->setBackgroundBrush(QBrush(QColor(32, 48, 96)));
|
||||
setSceneDimensions();
|
||||
setCentralWidget(m_textView);
|
||||
|
||||
connect(m_textWidget->document(), &TeletextDocument::cursorMoved, this, &MainWindow::updateCursorPosition);
|
||||
connect(m_textWidget->document()->undoStack(), &QUndoStack::cleanChanged, this, [=]() { setWindowModified(!m_textWidget->document()->undoStack()->isClean()); } );
|
||||
connect(m_textWidget->document(), &TeletextDocument::aboutToChangeSubPage, m_x26Dock, &X26DockWidget::unloadX26List);
|
||||
connect(m_textWidget->document(), &TeletextDocument::subPageSelected, this, &MainWindow::updatePageWidgets);
|
||||
connect(m_textWidget, &TeletextWidget::sizeChanged, this, &MainWindow::setSceneDimensions);
|
||||
connect(m_textWidget->pageRender(), &TeletextPageRender::fullScreenColourChanged, this, &MainWindow::updateFullScreenRectItems);
|
||||
connect(m_textWidget->pageRender(), &TeletextPageRender::fullRowColourChanged, this, &MainWindow::updateFullRowRectItems);
|
||||
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
|
||||
updatePageWidgets();
|
||||
}
|
||||
|
||||
void MainWindow::updateFullScreenRectItems(QColor newColor)
|
||||
{
|
||||
m_fullScreenTopRectItem->setBrush(QBrush(newColor));
|
||||
m_fullScreenBottomRectItem->setBrush(QBrush(newColor));
|
||||
}
|
||||
|
||||
void MainWindow::updateFullRowRectItems(int row, QColor newColor)
|
||||
{
|
||||
m_fullRowLeftRectItem[row]->setBrush(QBrush(newColor));
|
||||
m_fullRowRightRectItem[row]->setBrush(QBrush(newColor));
|
||||
}
|
||||
|
||||
void MainWindow::tile(const QMainWindow *previous)
|
||||
{
|
||||
//TODO sort out default tiling or positioning
|
||||
if (!previous)
|
||||
return;
|
||||
int topFrameWidth = previous->geometry().top() - previous->pos().y();
|
||||
if (!topFrameWidth)
|
||||
topFrameWidth = 40;
|
||||
const QPoint pos = previous->pos() + 2 * QPoint(topFrameWidth, topFrameWidth);
|
||||
if (QGuiApplication::primaryScreen()->availableGeometry().contains(rect().bottomRight() + pos))
|
||||
move(pos);
|
||||
}
|
||||
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
QToolBar *fileToolBar = addToolBar(tr("File"));
|
||||
fileToolBar->setObjectName("fileToolBar");
|
||||
|
||||
const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/images/new.png"));
|
||||
QAction *newAct = new QAction(newIcon, tr("&New"), this);
|
||||
newAct->setShortcuts(QKeySequence::New);
|
||||
newAct->setStatusTip(tr("Create a new file"));
|
||||
connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
|
||||
fileMenu->addAction(newAct);
|
||||
fileToolBar->addAction(newAct);
|
||||
|
||||
const QIcon openIcon = QIcon::fromTheme("document-open", QIcon(":/images/open.png"));
|
||||
QAction *openAct = new QAction(openIcon, tr("&Open..."), this);
|
||||
openAct->setShortcuts(QKeySequence::Open);
|
||||
openAct->setStatusTip(tr("Open an existing file"));
|
||||
connect(openAct, &QAction::triggered, this, &MainWindow::open);
|
||||
fileMenu->addAction(openAct);
|
||||
fileToolBar->addAction(openAct);
|
||||
|
||||
const QIcon saveIcon = QIcon::fromTheme("document-save", QIcon(":/images/save.png"));
|
||||
QAction *saveAct = new QAction(saveIcon, tr("&Save"), this);
|
||||
saveAct->setShortcuts(QKeySequence::Save);
|
||||
saveAct->setStatusTip(tr("Save the document to disk"));
|
||||
connect(saveAct, &QAction::triggered, this, &MainWindow::save);
|
||||
fileMenu->addAction(saveAct);
|
||||
fileToolBar->addAction(saveAct);
|
||||
|
||||
const QIcon saveAsIcon = QIcon::fromTheme("document-save-as");
|
||||
QAction *saveAsAct = fileMenu->addAction(saveAsIcon, tr("Save &As..."), this, &MainWindow::saveAs);
|
||||
saveAsAct->setShortcuts(QKeySequence::SaveAs);
|
||||
saveAsAct->setStatusTip(tr("Save the document under a new name"));
|
||||
|
||||
fileMenu->addSeparator();
|
||||
|
||||
QMenu *recentMenu = fileMenu->addMenu(tr("Recent"));
|
||||
connect(recentMenu, &QMenu::aboutToShow, this, &MainWindow::updateRecentFileActions);
|
||||
m_recentFileSubMenuAct = recentMenu->menuAction();
|
||||
|
||||
for (int i = 0; i < m_MaxRecentFiles; ++i) {
|
||||
m_recentFileActs[i] = recentMenu->addAction(QString(), this, &MainWindow::openRecentFile);
|
||||
m_recentFileActs[i]->setVisible(false);
|
||||
}
|
||||
|
||||
m_recentFileSeparator = fileMenu->addSeparator();
|
||||
|
||||
setRecentFilesVisible(MainWindow::hasRecentFiles());
|
||||
|
||||
QAction *exportAct = fileMenu->addAction(tr("Export to zxnet.co.uk"));
|
||||
exportAct->setStatusTip("Export URL to zxnet.co.uk online editor");
|
||||
connect(exportAct, &QAction::triggered, this, &MainWindow::exportURL);
|
||||
|
||||
QAction *closeAct = fileMenu->addAction(tr("&Close"), this, &QWidget::close);
|
||||
closeAct->setShortcut(tr("Ctrl+W"));
|
||||
closeAct->setStatusTip(tr("Close this window"));
|
||||
|
||||
const QIcon exitIcon = QIcon::fromTheme("application-exit");
|
||||
QAction *exitAct = fileMenu->addAction(exitIcon, tr("E&xit"), qApp, &QApplication::closeAllWindows);
|
||||
exitAct->setShortcuts(QKeySequence::Quit);
|
||||
exitAct->setStatusTip(tr("Exit the application"));
|
||||
|
||||
QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
|
||||
QToolBar *editToolBar = addToolBar(tr("Edit"));
|
||||
editToolBar->setObjectName("editToolBar");
|
||||
|
||||
QAction *undoAction = m_textWidget->document()->undoStack()->createUndoAction(this, tr("&Undo"));
|
||||
editMenu->addAction(undoAction);
|
||||
undoAction->setShortcuts(QKeySequence::Undo);
|
||||
QAction *redoAction = m_textWidget->document()->undoStack()->createRedoAction(this, tr("&Redo"));
|
||||
editMenu->addAction(redoAction);
|
||||
redoAction->setShortcuts(QKeySequence::Redo);
|
||||
|
||||
editMenu->addSeparator();
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
/* const QIcon cutIcon = QIcon::fromTheme("edit-cut", QIcon(":/images/cut.png"));
|
||||
QAction *cutAct = new QAction(cutIcon, tr("Cu&t"), this);
|
||||
cutAct->setShortcuts(QKeySequence::Cut);
|
||||
cutAct->setStatusTip(tr("Cut the current selection's contents to the "
|
||||
"clipboard"));
|
||||
connect(cutAct, &QAction::triggered, textWidget, &QTextEdit::cut);
|
||||
editMenu->addAction(cutAct);
|
||||
editToolBar->addAction(cutAct);
|
||||
|
||||
const QIcon copyIcon = QIcon::fromTheme("edit-copy", QIcon(":/images/copy.png"));
|
||||
QAction *copyAct = new QAction(copyIcon, tr("&Copy"), this);
|
||||
copyAct->setShortcuts(QKeySequence::Copy);
|
||||
copyAct->setStatusTip(tr("Copy the current selection's contents to the "
|
||||
"clipboard"));
|
||||
connect(copyAct, &QAction::triggered, textWidget, &QTextEdit::copy);
|
||||
editMenu->addAction(copyAct);
|
||||
editToolBar->addAction(copyAct);
|
||||
|
||||
const QIcon pasteIcon = QIcon::fromTheme("edit-paste", QIcon(":/images/paste.png"));
|
||||
QAction *pasteAct = new QAction(pasteIcon, tr("&Paste"), this);
|
||||
pasteAct->setShortcuts(QKeySequence::Paste);
|
||||
pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
|
||||
"selection"));
|
||||
connect(pasteAct, &QAction::triggered, textWidget, &QTextEdit::paste);
|
||||
editMenu->addAction(pasteAct);
|
||||
editToolBar->addAction(pasteAct);
|
||||
|
||||
editMenu->addSeparator();
|
||||
*/
|
||||
#endif // !QT_NO_CLIPBOARD
|
||||
|
||||
QAction *insertBeforeAct = editMenu->addAction(tr("&Insert subpage before"));
|
||||
insertBeforeAct->setStatusTip(tr("Insert a blank subpage before this subpage"));
|
||||
connect(insertBeforeAct, &QAction::triggered, [=]() { insertSubPage(false, false); });
|
||||
|
||||
QAction *insertAfterAct = editMenu->addAction(tr("Insert subpage after"));
|
||||
insertAfterAct->setStatusTip(tr("Insert a blank subpage after this subpage"));
|
||||
connect(insertAfterAct, &QAction::triggered, [=]() { insertSubPage(true, false); });
|
||||
|
||||
QAction *insertCopyAct = editMenu->addAction(tr("Insert subpage copy"));
|
||||
insertCopyAct->setStatusTip(tr("Insert a subpage that's a copy of this subpage"));
|
||||
connect(insertCopyAct, &QAction::triggered, [=]() { insertSubPage(false, true); });
|
||||
|
||||
QMenu *viewMenu = menuBar()->addMenu(tr("&View"));
|
||||
|
||||
QAction *revealAct = viewMenu->addAction(tr("&Reveal"));
|
||||
revealAct->setCheckable(true);
|
||||
revealAct->setStatusTip(tr("Toggle reveal"));
|
||||
connect(revealAct, &QAction::toggled, m_textWidget, &TeletextWidget::toggleReveal);
|
||||
|
||||
QAction *mixAct = viewMenu->addAction(tr("&Mix"));
|
||||
mixAct->setCheckable(true);
|
||||
mixAct->setStatusTip(tr("Toggle mix"));
|
||||
connect(mixAct, &QAction::toggled, m_textWidget, &TeletextWidget::toggleMix);
|
||||
|
||||
QAction *gridAct = viewMenu->addAction(tr("&Grid"));
|
||||
gridAct->setCheckable(true);
|
||||
gridAct->setStatusTip(tr("Toggle the text grid"));
|
||||
connect(gridAct, &QAction::toggled, m_textWidget, &TeletextWidget::toggleGrid);
|
||||
|
||||
QAction *showCodesAct = viewMenu->addAction(tr("Show codes"));
|
||||
showCodesAct->setCheckable(true);
|
||||
showCodesAct->setStatusTip(tr("Toggle showing of control codes"));
|
||||
connect(showCodesAct, &QAction::toggled, m_textWidget->pageRender(), &TeletextPageRender::setShowCodes);
|
||||
|
||||
viewMenu->addSeparator();
|
||||
|
||||
QMenu *borderSubMenu = viewMenu->addMenu(tr("Border"));
|
||||
m_borderActs[0] = borderSubMenu->addAction(tr("None"));
|
||||
m_borderActs[0]->setStatusTip(tr("View with no border"));
|
||||
m_borderActs[1] = borderSubMenu->addAction(tr("Minimal"));
|
||||
m_borderActs[1]->setStatusTip(tr("View with minimal border"));
|
||||
m_borderActs[2] = borderSubMenu->addAction(tr("Full"));
|
||||
m_borderActs[2]->setStatusTip(tr("View with full overscan border"));
|
||||
|
||||
QMenu *aspectRatioSubMenu = viewMenu->addMenu(tr("Aspect ratio"));
|
||||
m_aspectRatioActs[0] = aspectRatioSubMenu->addAction(tr("4:3"));
|
||||
m_aspectRatioActs[0]->setStatusTip(tr("View in 4:3 aspect ratio"));
|
||||
m_aspectRatioActs[1] = aspectRatioSubMenu->addAction(tr("16:9 pillarbox"));
|
||||
m_aspectRatioActs[1]->setStatusTip(tr("View in 16:9 with space on either side"));
|
||||
m_aspectRatioActs[2] = aspectRatioSubMenu->addAction(tr("16:9 stretch"));
|
||||
m_aspectRatioActs[2]->setStatusTip(tr("View in 16:9 with horizontally stretched text"));
|
||||
m_aspectRatioActs[3] = aspectRatioSubMenu->addAction(tr("Pixel 1:2"));
|
||||
m_aspectRatioActs[3]->setStatusTip(tr("View with 1:2 pixel mapping"));
|
||||
|
||||
QActionGroup *borderGroup = new QActionGroup(this);
|
||||
QActionGroup *aspectRatioGroup = new QActionGroup(this);
|
||||
for (int i=0; i<=3; i++) {
|
||||
m_aspectRatioActs[i]->setCheckable(true);
|
||||
connect(m_aspectRatioActs[i], &QAction::triggered, [=]() { setAspectRatio(i); });
|
||||
aspectRatioGroup->addAction(m_aspectRatioActs[i]);
|
||||
if (i == 3)
|
||||
break;
|
||||
m_borderActs[i]->setCheckable(true);
|
||||
connect(m_borderActs[i], &QAction::triggered, [=]() { setBorder(i); });
|
||||
borderGroup->addAction(m_borderActs[i]);
|
||||
}
|
||||
|
||||
QAction *zoomInAct = viewMenu->addAction(tr("Zoom In"));
|
||||
zoomInAct->setShortcuts(QKeySequence::ZoomIn);
|
||||
zoomInAct->setStatusTip(tr("Zoom in"));
|
||||
connect(zoomInAct, &QAction::triggered, this, &MainWindow::zoomIn);
|
||||
|
||||
QAction *zoomOutAct = viewMenu->addAction(tr("Zoom Out"));
|
||||
zoomOutAct->setShortcuts(QKeySequence::ZoomOut);
|
||||
zoomOutAct->setStatusTip(tr("Zoom out"));
|
||||
connect(zoomOutAct, &QAction::triggered, this, &MainWindow::zoomOut);
|
||||
|
||||
QAction *zoomResetAct = viewMenu->addAction(tr("Reset zoom"));
|
||||
zoomResetAct->setStatusTip(tr("Reset zoom level"));
|
||||
connect(zoomResetAct, &QAction::triggered, this, &MainWindow::zoomReset);
|
||||
|
||||
QMenu *insertMenu = menuBar()->addMenu(tr("&Insert"));
|
||||
|
||||
QMenu *alphaColourSubMenu = insertMenu->addMenu(tr("Alphanumeric colour"));
|
||||
QMenu *mosaicColourSubMenu = insertMenu->addMenu(tr("Mosaic colour"));
|
||||
for (int i=0; i<=7; i++) {
|
||||
const char *colours[] = { "Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White" };
|
||||
|
||||
QAction *alphaColour = alphaColourSubMenu->addAction(tr(colours[i]));
|
||||
alphaColour->setStatusTip(QString("Insert alphanumeric %1 attribute").arg(QString(colours[i]).toLower()));
|
||||
connect(alphaColour, &QAction::triggered, [=]() { m_textWidget->setCharacter(i); });
|
||||
|
||||
QAction *mosaicColour = mosaicColourSubMenu->addAction(tr(colours[i]));
|
||||
mosaicColour->setStatusTip(QString("Insert mosaic %1 attribute").arg(QString(colours[i]).toLower()));
|
||||
connect(mosaicColour, &QAction::triggered, [=]() { m_textWidget->setCharacter(i+0x10); });
|
||||
}
|
||||
|
||||
QMenu *mosaicsStyleSubMenu = insertMenu->addMenu(tr("Mosaics style"));
|
||||
QAction *mosaicsContiguousAct = mosaicsStyleSubMenu->addAction(tr("Contiguous mosaics"));
|
||||
mosaicsContiguousAct->setStatusTip(tr("Insert contiguous mosaics attribute"));
|
||||
connect(mosaicsContiguousAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x19); });
|
||||
QAction *mosaicsSeparatedAct = mosaicsStyleSubMenu->addAction(tr("Separated mosaics"));
|
||||
mosaicsSeparatedAct->setStatusTip(tr("Insert separated mosaics attribute"));
|
||||
connect(mosaicsSeparatedAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x1a); });
|
||||
|
||||
QMenu *mosaicsHoldSubMenu = insertMenu->addMenu(tr("Mosaics hold"));
|
||||
QAction *mosaicsHoldAct = mosaicsHoldSubMenu->addAction(tr("Hold mosaics"));
|
||||
mosaicsHoldAct->setStatusTip(tr("Insert hold mosaics attribute"));
|
||||
connect(mosaicsHoldAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x1e); });
|
||||
QAction *mosaicsReleaseAct = mosaicsHoldSubMenu->addAction(tr("Release mosaics"));
|
||||
mosaicsReleaseAct->setStatusTip(tr("Insert release mosaics attribute"));
|
||||
connect(mosaicsReleaseAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x1f); });
|
||||
|
||||
QMenu *backgroundColourSubMenu = insertMenu->addMenu(tr("Background colour"));
|
||||
QAction *backgroundNewAct = backgroundColourSubMenu->addAction(tr("New background"));
|
||||
backgroundNewAct->setStatusTip(tr("Insert new background attribute"));
|
||||
connect(backgroundNewAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x1d); });
|
||||
QAction *backgroundBlackAct = backgroundColourSubMenu->addAction(tr("Black background"));
|
||||
backgroundBlackAct->setStatusTip(tr("Insert black background attribute"));
|
||||
connect(backgroundBlackAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x1c); });
|
||||
|
||||
QMenu *textSizeSubMenu = insertMenu->addMenu(tr("Text size"));
|
||||
QAction *textSizeNormalAct = textSizeSubMenu->addAction(tr("Normal size"));
|
||||
textSizeNormalAct->setStatusTip(tr("Insert normal size attribute"));
|
||||
connect(textSizeNormalAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x0c); });
|
||||
QAction *textSizeHeightAct = textSizeSubMenu->addAction(tr("Double height"));
|
||||
textSizeHeightAct->setStatusTip(tr("Insert double height attribute"));
|
||||
connect(textSizeHeightAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x0d); });
|
||||
QAction *textSizeWidthAct = textSizeSubMenu->addAction(tr("Double width"));
|
||||
textSizeWidthAct->setStatusTip(tr("Insert double width attribute"));
|
||||
connect(textSizeWidthAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x0e); });
|
||||
QAction *textSizeDoubleAct = textSizeSubMenu->addAction(tr("Double size"));
|
||||
textSizeDoubleAct->setStatusTip(tr("Insert double size attribute"));
|
||||
connect(textSizeDoubleAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x0f); });
|
||||
|
||||
QAction *concealAct = insertMenu->addAction(tr("Conceal"));
|
||||
concealAct->setStatusTip(tr("Insert conceal attribute"));
|
||||
connect(concealAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x18); });
|
||||
|
||||
QMenu *flashSubMenu = insertMenu->addMenu(tr("Flash"));
|
||||
QAction *flashFlashingAct = flashSubMenu->addAction(tr("Flashing"));
|
||||
flashFlashingAct->setStatusTip(tr("Insert flashing attribute"));
|
||||
connect(flashFlashingAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x08); });
|
||||
QAction *flashSteadyAct = flashSubMenu->addAction(tr("Steady"));
|
||||
flashSteadyAct->setStatusTip(tr("Insert steady attribute"));
|
||||
connect(flashSteadyAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x09); });
|
||||
|
||||
QMenu *boxingSubMenu = insertMenu->addMenu(tr("Box"));
|
||||
QAction *boxingStartAct = boxingSubMenu->addAction(tr("Start box"));
|
||||
boxingStartAct->setStatusTip(tr("Insert start box attribute"));
|
||||
connect(boxingStartAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x0b); });
|
||||
QAction *boxingEndAct = boxingSubMenu->addAction(tr("End box"));
|
||||
boxingEndAct->setStatusTip(tr("Insert end box attribute"));
|
||||
connect(boxingEndAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x0a); });
|
||||
|
||||
QAction *escSwitchAct = insertMenu->addAction(tr("ESC/switch"));
|
||||
escSwitchAct->setStatusTip(tr("Insert ESC/switch character set attribute"));
|
||||
connect(escSwitchAct, &QAction::triggered, [=]() { m_textWidget->setCharacter(0x1b); });
|
||||
|
||||
QMenu *toolsMenu = menuBar()->addMenu(tr("&Tools"));
|
||||
|
||||
toolsMenu->addAction(m_pageOptionsDock->toggleViewAction());
|
||||
toolsMenu->addAction(m_x26Dock->toggleViewAction());
|
||||
toolsMenu->addAction(m_x28Dock->toggleViewAction());
|
||||
toolsMenu->addAction(m_paletteDock->toggleViewAction());
|
||||
|
||||
//FIXME is this main menubar separator to put help menu towards the right?
|
||||
menuBar()->addSeparator();
|
||||
|
||||
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||
QAction *aboutAct = helpMenu->addAction(tr("&About"), this, &MainWindow::about);
|
||||
aboutAct->setStatusTip(tr("Show the application's About box"));
|
||||
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
/*
|
||||
cutAct->setEnabled(false);
|
||||
copyAct->setEnabled(false);
|
||||
connect(textWidget, &QTextEdit::copyAvailable, cutAct, &QAction::setEnabled);
|
||||
connect(textWidget, &QTextEdit::copyAvailable, copyAct, &QAction::setEnabled);
|
||||
*/
|
||||
#endif // !QT_NO_CLIPBOARD
|
||||
}
|
||||
|
||||
void MainWindow::setSceneDimensions()
|
||||
{
|
||||
const float aspectRatioHorizontalScaling[4] = { 0.6, 0.6, 0.8, 0.5 };
|
||||
const int topBottomBorders[3] = { 0, 10, 19 };
|
||||
const int leftRightBorders[3][2] = { { 0, 0 }, { 24, 72 }, { 77, 183 } };
|
||||
int newSceneWidth;
|
||||
|
||||
int newViewAspectRatio = m_viewAspectRatio; // In case we need to narrow the characters to fit wide side panels in 4:3
|
||||
if (m_viewBorder == 0)
|
||||
newSceneWidth = m_textWidget->width();
|
||||
else
|
||||
newSceneWidth = 480+leftRightBorders[m_viewBorder][newViewAspectRatio == 1]*2;
|
||||
|
||||
//FIXME find a better way of narrowing characters to squeeze in side panels
|
||||
if (m_viewAspectRatio != 1 && m_textWidget->width() > 576)
|
||||
newViewAspectRatio = 3;
|
||||
|
||||
m_textScene->setSceneRect(0, 0, newSceneWidth, 250+topBottomBorders[m_viewBorder]*2);
|
||||
m_fullScreenTopRectItem->setRect(0, 0, newSceneWidth, topBottomBorders[m_viewBorder]);
|
||||
m_fullScreenBottomRectItem->setRect(0, 250+topBottomBorders[m_viewBorder], newSceneWidth, topBottomBorders[m_viewBorder]);
|
||||
m_textView->setTransform(QTransform((1+(float)m_viewZoom/2)*aspectRatioHorizontalScaling[newViewAspectRatio], 0, 0, 1+(float)m_viewZoom/2, 0, 0));
|
||||
if (m_viewBorder == 0)
|
||||
m_textProxyWidget->setPos(0, 0);
|
||||
else
|
||||
m_textProxyWidget->setPos(leftRightBorders[m_viewBorder][newViewAspectRatio == 1]-(m_textWidget->width()-480)/2, topBottomBorders[m_viewBorder]);
|
||||
for (int r=0; r<25; r++) {
|
||||
m_fullRowLeftRectItem[r]->setRect(0, topBottomBorders[m_viewBorder]+r*10, m_textWidget->x()+1, 10);
|
||||
m_fullRowRightRectItem[r]->setRect(m_textWidget->x()+m_textWidget->width()-1, topBottomBorders[m_viewBorder]+r*10, m_textWidget->x()+1, 10);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::insertSubPage(bool afterCurrentSubPage, bool copyCurrentSubPage)
|
||||
{
|
||||
QUndoCommand *insertSubPageCommand = new InsertSubPageCommand(m_textWidget->document(), afterCurrentSubPage, copyCurrentSubPage);
|
||||
m_textWidget->document()->undoStack()->push(insertSubPageCommand);
|
||||
}
|
||||
|
||||
void MainWindow::setBorder(int newViewBorder)
|
||||
{
|
||||
m_viewBorder = newViewBorder;
|
||||
setSceneDimensions();
|
||||
}
|
||||
|
||||
void MainWindow::setAspectRatio(int newViewAspectRatio)
|
||||
{
|
||||
m_viewAspectRatio = newViewAspectRatio;
|
||||
setSceneDimensions();
|
||||
}
|
||||
|
||||
void MainWindow::zoomIn()
|
||||
{
|
||||
if (m_viewZoom < 4)
|
||||
m_viewZoom++;
|
||||
setSceneDimensions();
|
||||
}
|
||||
|
||||
void MainWindow::zoomOut()
|
||||
{
|
||||
if (m_viewZoom > 0)
|
||||
m_viewZoom--;
|
||||
setSceneDimensions();
|
||||
}
|
||||
|
||||
void MainWindow::zoomReset()
|
||||
{
|
||||
m_viewZoom = 2;
|
||||
setSceneDimensions();
|
||||
}
|
||||
|
||||
void MainWindow::createStatusBar()
|
||||
{
|
||||
m_cursorStatus = new QLabel("Subpage 1/1 row 1 column 1");
|
||||
statusBar()->insertWidget(0, m_cursorStatus);
|
||||
m_levelSelect = new QLabel("Level");
|
||||
statusBar()->addPermanentWidget(m_levelSelect);
|
||||
|
||||
QRadioButton *level1 = new QRadioButton("1");
|
||||
QRadioButton *level15 = new QRadioButton("1.5");
|
||||
QRadioButton *level25 = new QRadioButton("2.5");
|
||||
QRadioButton *level35 = new QRadioButton("3.5");
|
||||
statusBar()->addPermanentWidget(level1);
|
||||
statusBar()->addPermanentWidget(level15);
|
||||
statusBar()->addPermanentWidget(level25);
|
||||
statusBar()->addPermanentWidget(level35);
|
||||
level1->toggle();
|
||||
connect(level1, &QAbstractButton::clicked, [=]() { m_textWidget->pageRender()->setRenderLevel(0); m_textWidget->update(); });
|
||||
connect(level15, &QAbstractButton::clicked, [=]() { m_textWidget->pageRender()->setRenderLevel(1); m_textWidget->update(); });
|
||||
connect(level25, &QAbstractButton::clicked, [=]() { m_textWidget->pageRender()->setRenderLevel(2); m_textWidget->update(); });
|
||||
connect(level35, &QAbstractButton::clicked, [=]() { m_textWidget->pageRender()->setRenderLevel(3); m_textWidget->update(); });
|
||||
statusBar()->showMessage(tr("Ready"));
|
||||
}
|
||||
|
||||
void MainWindow::readSettings()
|
||||
{
|
||||
//TODO window sizing
|
||||
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
|
||||
const QByteArray windowState = settings.value("windowState", QByteArray()).toByteArray();
|
||||
|
||||
m_viewBorder = settings.value("border", 2).toInt();
|
||||
m_viewBorder = (m_viewBorder < 0 || m_viewBorder > 2) ? 2 : m_viewBorder;
|
||||
m_borderActs[m_viewBorder]->setChecked(true);
|
||||
m_viewAspectRatio = settings.value("aspectratio", 0).toInt();
|
||||
m_viewAspectRatio = (m_viewAspectRatio < 0 || m_viewAspectRatio > 2) ? 0 : m_viewAspectRatio;
|
||||
m_aspectRatioActs[m_viewAspectRatio]->setChecked(true);
|
||||
m_viewZoom = settings.value("zoom", 2).toInt();
|
||||
m_viewZoom = (m_viewZoom < 0 || m_viewZoom > 4) ? 2 : m_viewZoom;
|
||||
|
||||
// zoom 0 = 420,426px, 1 = 620,570px, 2 = 780,720px
|
||||
if (geometry.isEmpty()) {
|
||||
const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
|
||||
if (availableGeometry.width() < 620 || availableGeometry.height() < 570) {
|
||||
resize(430, 430);
|
||||
m_viewZoom = 0;
|
||||
} else if (availableGeometry.width() < 780 || availableGeometry.height() < 720) {
|
||||
resize(620, 570);
|
||||
m_viewZoom = 1;
|
||||
} else
|
||||
resize(780, 720);
|
||||
// m_viewZoom = 2;
|
||||
move((availableGeometry.width() - width()) / 2, (availableGeometry.height() - height()) / 2);
|
||||
} else
|
||||
restoreGeometry(geometry);
|
||||
if (windowState.isEmpty()) {
|
||||
m_x26Dock->hide();
|
||||
m_x26Dock->setFloating(true);
|
||||
m_x28Dock->hide();
|
||||
m_x26Dock->setFloating(true);
|
||||
m_pageOptionsDock->hide();
|
||||
m_pageOptionsDock->setFloating(true);
|
||||
m_paletteDock->hide();
|
||||
m_paletteDock->setFloating(true);
|
||||
} else
|
||||
restoreState(windowState);
|
||||
}
|
||||
|
||||
void MainWindow::writeSettings()
|
||||
{
|
||||
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
settings.setValue("geometry", saveGeometry());
|
||||
settings.setValue("windowState", saveState());
|
||||
settings.setValue("border", m_viewBorder);
|
||||
settings.setValue("aspectratio", m_viewAspectRatio);
|
||||
settings.setValue("zoom", m_viewZoom);
|
||||
}
|
||||
|
||||
bool MainWindow::maybeSave()
|
||||
{
|
||||
if (m_textWidget->document()->undoStack()->isClean())
|
||||
return true;
|
||||
const QMessageBox::StandardButton ret = QMessageBox::warning(this, tr("QTeletextMaker"), tr("The document has been modified.\nDo you want to save your changes?"), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||
switch (ret) {
|
||||
case QMessageBox::Save:
|
||||
return save();
|
||||
case QMessageBox::Cancel:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::loadFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
QMessageBox::warning(this, tr("QTeletextMaker"), tr("Cannot read file %1:\n%2.").arg(QDir::toNativeSeparators(fileName), file.errorString()));
|
||||
setCurrentFile(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
m_textWidget->document()->loadDocument(&file);
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
setCurrentFile(fileName);
|
||||
statusBar()->showMessage(tr("File loaded"), 2000);
|
||||
}
|
||||
|
||||
void MainWindow::setRecentFilesVisible(bool visible)
|
||||
{
|
||||
m_recentFileSubMenuAct->setVisible(visible);
|
||||
m_recentFileSeparator->setVisible(visible);
|
||||
}
|
||||
|
||||
static inline QString recentFilesKey() { return QStringLiteral("recentFileList"); }
|
||||
static inline QString fileKey() { return QStringLiteral("file"); }
|
||||
|
||||
static QStringList readRecentFiles(QSettings &settings)
|
||||
{
|
||||
QStringList result;
|
||||
const int count = settings.beginReadArray(recentFilesKey());
|
||||
for (int i = 0; i < count; ++i) {
|
||||
settings.setArrayIndex(i);
|
||||
result.append(settings.value(fileKey()).toString());
|
||||
}
|
||||
settings.endArray();
|
||||
return result;
|
||||
}
|
||||
|
||||
static void writeRecentFiles(const QStringList &files, QSettings &settings)
|
||||
{
|
||||
const int count = files.size();
|
||||
settings.beginWriteArray(recentFilesKey());
|
||||
for (int i = 0; i < count; ++i) {
|
||||
settings.setArrayIndex(i);
|
||||
settings.setValue(fileKey(), files.at(i));
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
|
||||
bool MainWindow::hasRecentFiles()
|
||||
{
|
||||
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
const int count = settings.beginReadArray(recentFilesKey());
|
||||
settings.endArray();
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
void MainWindow::prependToRecentFiles(const QString &fileName)
|
||||
{
|
||||
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
|
||||
const QStringList oldRecentFiles = readRecentFiles(settings);
|
||||
QStringList recentFiles = oldRecentFiles;
|
||||
recentFiles.removeAll(fileName);
|
||||
recentFiles.prepend(fileName);
|
||||
if (oldRecentFiles != recentFiles)
|
||||
writeRecentFiles(recentFiles, settings);
|
||||
|
||||
setRecentFilesVisible(!recentFiles.isEmpty());
|
||||
}
|
||||
|
||||
void MainWindow::updateRecentFileActions()
|
||||
{
|
||||
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
|
||||
const QStringList recentFiles = readRecentFiles(settings);
|
||||
const int count = qMin(int(m_MaxRecentFiles), recentFiles.size());
|
||||
int i = 0;
|
||||
for ( ; i < count; ++i) {
|
||||
const QString fileName = MainWindow::strippedName(recentFiles.at(i));
|
||||
m_recentFileActs[i]->setText(tr("&%1 %2").arg(i + 1).arg(fileName));
|
||||
m_recentFileActs[i]->setData(recentFiles.at(i));
|
||||
m_recentFileActs[i]->setVisible(true);
|
||||
}
|
||||
for ( ; i < m_MaxRecentFiles; ++i)
|
||||
m_recentFileActs[i]->setVisible(false);
|
||||
}
|
||||
|
||||
void MainWindow::openRecentFile()
|
||||
{
|
||||
if (const QAction *action = qobject_cast<const QAction *>(sender()))
|
||||
openFile(action->data().toString());
|
||||
}
|
||||
|
||||
bool MainWindow::saveFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QFile::WriteOnly | QFile::Text)) {
|
||||
QMessageBox::warning(this, tr("QTeletextMaker"), tr("Cannot write file %1:\n%2.").arg(QDir::toNativeSeparators(fileName), file.errorString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out.setCodec("ISO-8859-1");
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
m_textWidget->document()->saveDocument(&out);
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
setCurrentFile(fileName);
|
||||
statusBar()->showMessage(tr("File saved"), 2000);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::setCurrentFile(const QString &fileName)
|
||||
{
|
||||
static int sequenceNumber = 1;
|
||||
|
||||
m_isUntitled = fileName.isEmpty();
|
||||
if (m_isUntitled)
|
||||
m_curFile = tr("untitled%1.tti").arg(sequenceNumber++);
|
||||
else
|
||||
m_curFile = QFileInfo(fileName).canonicalFilePath();
|
||||
|
||||
m_textWidget->document()->undoStack()->setClean();
|
||||
|
||||
if (!m_isUntitled && windowFilePath() != m_curFile)
|
||||
MainWindow::prependToRecentFiles(m_curFile);
|
||||
|
||||
setWindowFilePath(m_curFile);
|
||||
}
|
||||
|
||||
QString MainWindow::strippedName(const QString &fullFileName)
|
||||
{
|
||||
return QFileInfo(fullFileName).fileName();
|
||||
}
|
||||
|
||||
MainWindow *MainWindow::findMainWindow(const QString &fileName) const
|
||||
{
|
||||
QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();
|
||||
|
||||
foreach (QWidget *widget, QApplication::topLevelWidgets()) {
|
||||
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
|
||||
if (mainWin && mainWin->m_curFile == canonicalFilePath)
|
||||
return mainWin;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MainWindow::updateCursorPosition()
|
||||
{
|
||||
m_cursorStatus->setText(QString("Subpage %1/%2 row %3 column %4").arg(m_textWidget->document()->currentSubPageIndex()+1).arg(m_textWidget->document()->numberOfSubPages()).arg(m_textWidget->document()->cursorRow()).arg(m_textWidget->document()->cursorColumn()));
|
||||
}
|
||||
|
||||
void MainWindow::updatePageWidgets()
|
||||
{
|
||||
updateCursorPosition();
|
||||
m_paletteDock->updateAllColourButtons();
|
||||
m_x26Dock->loadX26List();
|
||||
m_x28Dock->updateWidgets();
|
||||
m_pageOptionsDock->updateWidgets();
|
||||
}
|
||||
122
mainwindow.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QMainWindow>
|
||||
#include <QLabel>
|
||||
|
||||
#include "mainwidget.h"
|
||||
#include "pageoptionsdockwidget.h"
|
||||
#include "palettedockwidget.h"
|
||||
#include "x26dockwidget.h"
|
||||
#include "x28dockwidget.h"
|
||||
|
||||
class QAction;
|
||||
class QMenu;
|
||||
class TeletextWidget;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow();
|
||||
explicit MainWindow(const QString &fileName);
|
||||
|
||||
void tile(const QMainWindow *previous);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void newFile();
|
||||
void open();
|
||||
bool save();
|
||||
bool saveAs();
|
||||
void exportURL();
|
||||
void updateRecentFileActions();
|
||||
void openRecentFile();
|
||||
void about();
|
||||
void updatePageWidgets();
|
||||
void updateCursorPosition();
|
||||
|
||||
void insertSubPage(bool, bool);
|
||||
|
||||
void setSceneDimensions();
|
||||
void setBorder(int);
|
||||
void setAspectRatio(int);
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void zoomReset();
|
||||
|
||||
void updateFullScreenRectItems(QColor);
|
||||
void updateFullRowRectItems(int, QColor);
|
||||
|
||||
private:
|
||||
enum { m_MaxRecentFiles = 10 };
|
||||
|
||||
void init();
|
||||
void createActions();
|
||||
void createStatusBar();
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
bool maybeSave();
|
||||
void openFile(const QString &fileName);
|
||||
void loadFile(const QString &fileName);
|
||||
static bool hasRecentFiles();
|
||||
void prependToRecentFiles(const QString &fileName);
|
||||
void setRecentFilesVisible(bool visible);
|
||||
bool saveFile(const QString &fileName);
|
||||
void setCurrentFile(const QString &fileName);
|
||||
static QString strippedName(const QString &fullFileName);
|
||||
MainWindow *findMainWindow(const QString &fileName) const;
|
||||
|
||||
TeletextWidget *m_textWidget;
|
||||
QGraphicsScene *m_textScene;
|
||||
QGraphicsProxyWidget *m_textProxyWidget;
|
||||
QGraphicsView *m_textView;
|
||||
QGraphicsRectItem *m_fullScreenTopRectItem, *m_fullScreenBottomRectItem;
|
||||
QGraphicsRectItem *m_fullRowLeftRectItem[25], *m_fullRowRightRectItem[25];
|
||||
|
||||
int m_viewBorder, m_viewAspectRatio, m_viewZoom;
|
||||
PaletteDockWidget *m_paletteDock;
|
||||
X26DockWidget *m_x26Dock;
|
||||
X28DockWidget *m_x28Dock;
|
||||
PageOptionsDockWidget *m_pageOptionsDock;
|
||||
|
||||
QAction *m_recentFileActs[m_MaxRecentFiles];
|
||||
QAction *m_recentFileSeparator;
|
||||
QAction *m_recentFileSubMenuAct;
|
||||
QAction *m_borderActs[3];
|
||||
QAction *m_aspectRatioActs[4];
|
||||
|
||||
QLabel *m_cursorStatus, *m_levelSelect;
|
||||
|
||||
QString m_curFile;
|
||||
bool m_isUntitled;
|
||||
};
|
||||
|
||||
#endif
|
||||
445
page.cpp
Normal file
@@ -0,0 +1,445 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QColor>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <algorithm>
|
||||
|
||||
#include "page.h"
|
||||
|
||||
TeletextPage::TeletextPage()
|
||||
{
|
||||
clearPage();
|
||||
}
|
||||
|
||||
// So far we only call clearPage() once, within the constructor
|
||||
void TeletextPage::clearPage()
|
||||
{
|
||||
for (int r=0; r<25; r++)
|
||||
for (int c=0; c<40; c++)
|
||||
m_level1Page[r][c] = 0x20;
|
||||
for (int i=0; i<8; i++)
|
||||
m_controlBits[i] = false;
|
||||
/* m_subPageNumber = 0x0000; */
|
||||
m_cycleValue = 8;
|
||||
m_cycleType = CTseconds;
|
||||
m_defaultCharSet = 0;
|
||||
m_defaultNOS = 0;
|
||||
m_secondCharSet = 0xf;
|
||||
m_secondNOS = 0x7;
|
||||
|
||||
m_defaultScreenColour = 0;
|
||||
m_defaultRowColour = 0;
|
||||
m_blackBackgroundSubst = false;
|
||||
m_colourTableRemap = 0;
|
||||
m_leftSidePanelDisplayed = m_rightSidePanelDisplayed = false;
|
||||
m_sidePanelStatusL25 = true;
|
||||
m_sidePanelColumns = 0;
|
||||
std::copy(defaultCLUT, defaultCLUT+32, m_CLUT);
|
||||
// If clearPage() is called outside constructor, we need to implement localEnhance.clear();
|
||||
}
|
||||
|
||||
void TeletextPage::loadPagePacket(QByteArray &inLine)
|
||||
{
|
||||
bool lineNumberOk;
|
||||
int lineNumber, secondCommaPosition;
|
||||
|
||||
secondCommaPosition = inLine.indexOf(",", 3);
|
||||
if (secondCommaPosition != 4 && secondCommaPosition != 5)
|
||||
return;
|
||||
lineNumber = inLine.mid(3, secondCommaPosition-3).toInt(&lineNumberOk, 10);
|
||||
if (lineNumberOk && lineNumber>=0 && lineNumber<=31) {
|
||||
inLine.remove(0, secondCommaPosition+1);
|
||||
if (lineNumber<=24) {
|
||||
for (int i=0, j=0; j<=39; i++, j++) {
|
||||
if (i == inLine.size())
|
||||
break;
|
||||
int myChar = inLine.at(i);
|
||||
if (myChar & 0x80)
|
||||
myChar &= 0x7f;
|
||||
else if (myChar == 0x10)
|
||||
myChar = 0x0d;
|
||||
else if (myChar == 0x1b) {
|
||||
i++;
|
||||
myChar = inLine.at(i)-0x40;
|
||||
}
|
||||
setCharacter(lineNumber, j, myChar);
|
||||
}
|
||||
}
|
||||
if (lineNumber == 26) {
|
||||
int designationCode = inLine.at(0) & 0x3f;
|
||||
|
||||
// TODO deal with gaps or out of order X26 designation codes in a more graceful way
|
||||
// At the moment gaps are dealt with by simply inserting "dummy" reserved 11110 Row
|
||||
// Triplets in case Local Objects are referenced within.
|
||||
// Out of order X26 designation codes aren't handled at all!
|
||||
if (designationCode*13 != localEnhance.size()) {
|
||||
qDebug("Gap or out of order X26 designation code");
|
||||
X26Triplet paddingX26Triplet;
|
||||
|
||||
paddingX26Triplet.setAddress(41);
|
||||
paddingX26Triplet.setMode(0x1e);
|
||||
paddingX26Triplet.setData(0);
|
||||
while (localEnhance.size() < designationCode*13)
|
||||
localEnhance.append(paddingX26Triplet);
|
||||
}
|
||||
|
||||
// Round loop counter to nearest multiple of 3 so an incomplete triplet doesn't crash us
|
||||
int inLineLength = (((inLine.size() <= 39) ? inLine.size() : 39) / 3) * 3;
|
||||
|
||||
for (int i=1; i<inLineLength; i+=3) {
|
||||
X26Triplet newX26Triplet;
|
||||
|
||||
newX26Triplet.setAddress(inLine.at(i) & 0x3f);
|
||||
newX26Triplet.setMode(inLine.at(i+1) & 0x1f);
|
||||
newX26Triplet.setData(((inLine.at(i+2) & 0x3f) << 1) | ((inLine.at(i+1) & 0x20) >> 5));
|
||||
localEnhance.append(newX26Triplet);
|
||||
// Break out of loop if termination marker (without a "...follow") is encountered
|
||||
if (newX26Triplet.mode() == 0x1f && newX26Triplet.address() == 0x3f && newX26Triplet.data() & 0x01)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lineNumber == 28) {
|
||||
int offset;
|
||||
|
||||
int designationCode = inLine.at(0) & 0x3f;
|
||||
switch (designationCode) {
|
||||
case 0:
|
||||
offset = 16;
|
||||
break;
|
||||
case 4:
|
||||
offset = 0;
|
||||
break;
|
||||
default:
|
||||
offset = -1;
|
||||
break;
|
||||
}
|
||||
if (offset >= 0) {
|
||||
int x28Triplets[13];
|
||||
|
||||
for (int i=1, j=0; i<39; i+=3, j++) {
|
||||
x28Triplets[j] = ((inLine.at(i+2) & 0x3f) << 12) | ((inLine.at(i+1) & 0x3f) << 6) | (inLine.at(i) & 0x3f);
|
||||
}
|
||||
|
||||
m_defaultCharSet = (x28Triplets[0] >> 10) & 0xF;
|
||||
m_defaultNOS = (x28Triplets[0] >> 7) & 0x7;
|
||||
m_secondCharSet = ((x28Triplets[1] << 1) & 0xE) | ((x28Triplets[0] >> 17) & 0x1);
|
||||
m_secondNOS = (x28Triplets[0] >> 14) & 0x7;
|
||||
|
||||
m_leftSidePanelDisplayed = (x28Triplets[1] >> 3) & 1;
|
||||
m_rightSidePanelDisplayed = (x28Triplets[1] >> 4) & 1;
|
||||
m_sidePanelStatusL25 = (x28Triplets[1] >> 5) & 1;
|
||||
m_sidePanelColumns = (x28Triplets[1] >> 6) & 0xF;
|
||||
|
||||
for (int c=0; c<16; c++) {
|
||||
int rtr = ((c * 12) + 28) / 18;
|
||||
int rsh = ((c * 12) + 28) % 18;
|
||||
int r = (x28Triplets[rtr] >> rsh) & 0xF;
|
||||
if (rsh == 16)
|
||||
r |= (x28Triplets[rtr+1] & 3) << 2;
|
||||
|
||||
int gtr = ((c * 12) + 32) / 18;
|
||||
int gsh = ((c * 12) + 32) % 18;
|
||||
int g = (x28Triplets[gtr] >> gsh) & 0xF;
|
||||
if (gsh == 16)
|
||||
g |= (x28Triplets[gtr+1] & 3) << 2;
|
||||
|
||||
int btr = ((c * 12) + 36) / 18;
|
||||
int bsh = ((c * 12) + 36) % 18;
|
||||
int b = (x28Triplets[btr] >> bsh) & 0xF;
|
||||
if (bsh == 16)
|
||||
b |= (x28Triplets[btr+1] & 3) << 2;
|
||||
|
||||
m_CLUT[offset+c] = (r << 8) | (g << 4) | b;
|
||||
}
|
||||
m_defaultScreenColour = (x28Triplets[12] >> 4) & 0x1f;
|
||||
m_defaultRowColour = (x28Triplets[12] >> 9) & 0x1f;
|
||||
m_blackBackgroundSubst = ((x28Triplets[12] >> 14) & 1);
|
||||
m_colourTableRemap = (x28Triplets[12] >> 15) & 7;
|
||||
}
|
||||
}
|
||||
} //TODO panic if invalid line number is encountered
|
||||
}
|
||||
|
||||
void TeletextPage::savePage(QTextStream *outStream, int pageNumber, int subPageNumber)
|
||||
{
|
||||
// int pageStatus = 0x8000 | (controlBits[0] << 14) | ((defaultPageNOS & 1) << 9) | ((defaultPageNOS & 2) << 7) | ((defaultPageNOS & 4) << 5);
|
||||
// for (int i=1; i<8; i++)
|
||||
// pageStatus |= controlBits[i] << i;
|
||||
*outStream << QString("PN,%1%2").arg(pageNumber, 3, 16, QChar('0')).arg(subPageNumber & 0xff, 2, 16, QChar('0')) << endl;
|
||||
*outStream << QString("SC,%1").arg(subPageNumber, 4, 16, QChar('0')) << endl;
|
||||
*outStream << QString("PS,%1").arg(0x8000 | controlBitsToPS(), 4, 16, QChar('0')) << endl;
|
||||
*outStream << QString("CT,%1,%2").arg(m_cycleValue).arg(m_cycleType==CTcycles ? 'C' : 'T') << endl;
|
||||
//TODO RE and maybe FLOF?
|
||||
if (int x28Result = x28Needed()) {
|
||||
if (x28Result & 1)
|
||||
*outStream << "OL,28," << x28toTTI(0) << endl;
|
||||
if (x28Result & 2)
|
||||
*outStream << "OL,28," << x28toTTI(4) << endl;
|
||||
}
|
||||
if (!localEnhance.isEmpty()) {
|
||||
int tripletNumber = 0;
|
||||
X26Triplet lastTriplet = localEnhance.at(localEnhance.size()-1);
|
||||
int terminatorNeeded = true; // Becomes false if a termination marker (without a "...follow") is already at the end
|
||||
|
||||
if (lastTriplet.mode() == 0x1f && lastTriplet.address() == 0x3f)
|
||||
if (lastTriplet.data() & 0x01)
|
||||
terminatorNeeded = false;
|
||||
else
|
||||
// Last termination marker has "follow" set but nothing follows, so write another one afterwards
|
||||
lastTriplet.setData(lastTriplet.data() | 0x01);
|
||||
else {
|
||||
// No termination marker there, so make up one
|
||||
lastTriplet.setAddress(0x3f);
|
||||
lastTriplet.setMode(0x1f);
|
||||
lastTriplet.setData(0x07);
|
||||
}
|
||||
|
||||
for (int d=0; d<16; d++) {
|
||||
*outStream << "OL,26," << (char)(d | 0x40);
|
||||
for (int t=0; t<13; t++) {
|
||||
if (tripletNumber < localEnhance.size()) {
|
||||
*outStream << (char)(0x40 | localEnhance.at(tripletNumber).address());
|
||||
*outStream << (char)(0x40 | (localEnhance.at(tripletNumber).mode() | ((localEnhance.at(tripletNumber).data() & 1) << 5)));
|
||||
*outStream << (char)(0x40 | (localEnhance.at(tripletNumber).data() >> 1));
|
||||
} else {
|
||||
*outStream << (char)(0x40 | lastTriplet.address());
|
||||
*outStream << (char)(0x40 | (lastTriplet.mode() | ((lastTriplet.data() & 1) << 5)));
|
||||
*outStream << (char)(0x40 | (lastTriplet.data() >> 1));
|
||||
terminatorNeeded = false;
|
||||
}
|
||||
tripletNumber++;
|
||||
}
|
||||
*outStream << endl;
|
||||
// If the last triplet of the last X26 row wasn't a termination marker,
|
||||
// terminatorNeeded ensures we write an additional X26 row full of termination markers.
|
||||
if (!terminatorNeeded && tripletNumber >= localEnhance.size())
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int r=1; r<25; r++) {
|
||||
bool blankRow = true;
|
||||
QString rowString;
|
||||
|
||||
rowString.append(QString("OL,%1,").arg(r));
|
||||
for (int c=0; c<40; c++) {
|
||||
unsigned char myChar = m_level1Page[r][c];
|
||||
if (myChar != 0x20)
|
||||
blankRow = false;
|
||||
if (myChar < 32) {
|
||||
rowString.append((char)0x1b);
|
||||
rowString.append((char)(myChar+0x40));
|
||||
} else
|
||||
rowString.append((char)myChar);
|
||||
}
|
||||
if (!blankRow)
|
||||
*outStream << rowString << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int TeletextPage::controlBitsToPS() const
|
||||
{
|
||||
//TODO map page language for regions other than 0
|
||||
int pageStatus = 0x8000 | (m_controlBits[0] << 14) | ((m_defaultNOS & 1) << 9) | ((m_defaultNOS & 2) << 7) | ((m_defaultNOS & 4) << 5);
|
||||
for (int i=1; i<8; i++)
|
||||
pageStatus |= m_controlBits[i] << (i-1);
|
||||
return pageStatus;
|
||||
}
|
||||
|
||||
QString TeletextPage::x28toTTI(int designationCode)
|
||||
{
|
||||
QString result;
|
||||
int x28Triplets[13] = {0};
|
||||
|
||||
int offset;
|
||||
|
||||
switch (designationCode) {
|
||||
case 0:
|
||||
offset = 16;
|
||||
break;
|
||||
case 4:
|
||||
offset = 0;
|
||||
break;
|
||||
}
|
||||
result.append(designationCode + 0x40);
|
||||
|
||||
x28Triplets[0] = ((m_secondCharSet & 1) << 17) | (m_secondNOS << 14) | (m_defaultCharSet << 10) | (m_defaultNOS << 7);
|
||||
x28Triplets[1] = (m_secondCharSet >> 1) | (m_leftSidePanelDisplayed << 3) | (m_rightSidePanelDisplayed << 4) | (m_sidePanelStatusL25 << 5) | (m_sidePanelColumns << 6);
|
||||
|
||||
for (int c=0; c<16; c++){
|
||||
int r = (m_CLUT[offset+c] & 0xF00) >> 8;
|
||||
int g = (m_CLUT[offset+c] & 0xF0) >> 4;
|
||||
int b = m_CLUT[offset+c] & 0xF;
|
||||
|
||||
int rtr = ((c * 12) + 28) / 18;
|
||||
int rsh = ((c * 12) + 28) % 18;
|
||||
x28Triplets[rtr] |= (r << rsh);
|
||||
if (rsh == 16)
|
||||
x28Triplets[rtr+1] |= (r >> 2) & 3;
|
||||
|
||||
int gtr = ((c * 12) + 32) / 18;
|
||||
int gsh = ((c * 12) + 32) % 18;
|
||||
x28Triplets[gtr] |= (g << gsh);
|
||||
if (gsh == 16)
|
||||
x28Triplets[gtr+1] |= (g >> 2) & 3;
|
||||
|
||||
int btr = ((c * 12) + 36) / 18;
|
||||
int bsh = ((c * 12) + 36) % 18;
|
||||
x28Triplets[btr] |= (b << bsh);
|
||||
if (bsh == 16)
|
||||
x28Triplets[btr+1] |= (b >> 2) & 3;
|
||||
}
|
||||
|
||||
x28Triplets[12] |= (m_defaultScreenColour << 4) | (m_defaultRowColour << 9) | (m_blackBackgroundSubst << 14) | (m_colourTableRemap << 15);
|
||||
|
||||
for (int i=0; i<13; i++) {
|
||||
result.append(0x40 | (x28Triplets[i] & 0x3F));
|
||||
result.append(0x40 | ((x28Triplets[i] & 0xFC0) >> 6));
|
||||
result.append(0x40 | ((x28Triplets[i] & 0x3F000) >> 12));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QString TeletextPage::exportURLHash(QString pageHash)
|
||||
{
|
||||
int hashDigits[1167]={0};
|
||||
int totalBits, charBit;
|
||||
const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
||||
|
||||
//TODO deal with "black text allowed"
|
||||
pageHash.append(QString("#%1:").arg(m_defaultNOS, 1, 16));
|
||||
for (int r=0; r<25; r++)
|
||||
for (int c=0; c<40; c++)
|
||||
for (int b=0; b<7; b++) {
|
||||
totalBits = (r * 40 + c) * 7 + b;
|
||||
charBit = ((m_level1Page[r][c]) >> (6 - b)) & 0x01;
|
||||
hashDigits[totalBits / 6] |= charBit << (5 - (totalBits % 6));
|
||||
}
|
||||
|
||||
for (int i=0; i<1167; i++)
|
||||
pageHash.append(base64[hashDigits[i]]);
|
||||
|
||||
// CLUTChangedResult = CLUTChanged();
|
||||
// if (leftSidePanel || rightSidePanel || defaultScreenColour !=0 || defaultRowColour !=0 || blackBackgroundSubst || colourTableRemap !=0 || CLUTChangedResult) {
|
||||
|
||||
if (int x28Result = x28Needed()) {
|
||||
QString x28StringBegin, x28StringEnd;
|
||||
|
||||
x28StringBegin.append(QString("00%1").arg((m_defaultCharSet << 3) | m_defaultNOS, 2, 16, QChar('0')).toUpper());
|
||||
x28StringBegin.append(QString("%1").arg((m_secondCharSet << 3) | m_secondNOS, 2, 16, QChar('0')).toUpper());
|
||||
x28StringBegin.append(QString("%1%2%3%4").arg(m_leftSidePanelDisplayed, 1, 10).arg(m_rightSidePanelDisplayed, 1, 10).arg(m_sidePanelStatusL25, 1, 10).arg(m_sidePanelColumns, 1, 16));
|
||||
|
||||
x28StringEnd = QString("%1%2%3%4").arg(m_defaultScreenColour, 2, 16, QChar('0')).arg(m_defaultRowColour, 2, 16, QChar('0')).arg(m_blackBackgroundSubst, 1, 10).arg(m_colourTableRemap, 1, 10);
|
||||
|
||||
if (x28Result & 1) {
|
||||
pageHash.append(":X280=");
|
||||
pageHash.append(x28StringBegin);
|
||||
pageHash.append(colourHash(1));
|
||||
pageHash.append(x28StringEnd);
|
||||
}
|
||||
if (x28Result & 2) {
|
||||
pageHash.append(":X284=");
|
||||
pageHash.append(x28StringBegin);
|
||||
pageHash.append(colourHash(0));
|
||||
pageHash.append(x28StringEnd);
|
||||
}
|
||||
}
|
||||
|
||||
if (!localEnhance.isEmpty()) {
|
||||
pageHash.append(":X26=");
|
||||
for (int i=0; i<localEnhance.size(); i++) {
|
||||
pageHash.append(base64[localEnhance.at(i).data() >> 1]);
|
||||
pageHash.append(base64[localEnhance.at(i).mode() | ((localEnhance.at(i).data() & 1) << 5)]);
|
||||
pageHash.append(base64[localEnhance.at(i).address()]);
|
||||
}
|
||||
//TODO need to add one or more terminators to X26
|
||||
}
|
||||
//TODO check if 0x8000 | is needed for zxnet
|
||||
pageHash.append(QString(":PS=%1").arg(0x8000 | controlBitsToPS(), 0, 16, QChar('0')));
|
||||
return pageHash;
|
||||
}
|
||||
|
||||
/* void TeletextPage::setSubPageNumber(int newSubPageNumber) { m_subPageNumber = newSubPageNumber; } */
|
||||
void TeletextPage::setControlBit(int bitNumber, bool active) { m_controlBits[bitNumber] = active; }
|
||||
void TeletextPage::setCycleValue(int newValue) { m_cycleValue = newValue; };
|
||||
void TeletextPage::setCycleType(CycleTypeEnum newType) { m_cycleType = newType; }
|
||||
void TeletextPage::setDefaultCharSet(int newDefaultCharSet) { m_defaultCharSet = newDefaultCharSet; }
|
||||
void TeletextPage::setDefaultNOS(int newDefaultNOS) { m_defaultNOS = newDefaultNOS; }
|
||||
|
||||
void TeletextPage::setSecondCharSet(int newSecondCharSet)
|
||||
{
|
||||
m_secondCharSet = newSecondCharSet;
|
||||
if (m_secondCharSet == 0xf)
|
||||
m_secondNOS = 0x7;
|
||||
}
|
||||
|
||||
void TeletextPage::setSecondNOS(int newSecondNOS) { m_secondNOS = newSecondNOS; }
|
||||
void TeletextPage::setCharacter(int row, int column, unsigned char newCharacter) { m_level1Page[row][column] = newCharacter; }
|
||||
void TeletextPage::setDefaultScreenColour(int newDefaultScreenColour) { m_defaultScreenColour = newDefaultScreenColour; }
|
||||
void TeletextPage::setDefaultRowColour(int newDefaultRowColour) { m_defaultRowColour = newDefaultRowColour; }
|
||||
void TeletextPage::setColourTableRemap(int newColourTableRemap) { m_colourTableRemap = newColourTableRemap; }
|
||||
void TeletextPage::setBlackBackgroundSubst(bool newBlackBackgroundSubst) { m_blackBackgroundSubst = newBlackBackgroundSubst; }
|
||||
|
||||
int TeletextPage::CLUT(int index, int renderLevel) const
|
||||
{
|
||||
if (renderLevel == 2)
|
||||
return index>=16 ? m_CLUT[index] : defaultCLUT[index];
|
||||
else
|
||||
return renderLevel==3 ? m_CLUT[index] : defaultCLUT[index];
|
||||
}
|
||||
|
||||
void TeletextPage::setCLUT(int index, int newColour) { m_CLUT[index] = newColour; }
|
||||
void TeletextPage::setLeftSidePanelDisplayed(bool newLeftSidePanelDisplayed) { m_leftSidePanelDisplayed = newLeftSidePanelDisplayed; }
|
||||
void TeletextPage::setRightSidePanelDisplayed(bool newRightSidePanelDisplayed) { m_rightSidePanelDisplayed = newRightSidePanelDisplayed; }
|
||||
void TeletextPage::setSidePanelColumns(int newSidePanelColumns) { m_sidePanelColumns = newSidePanelColumns; }
|
||||
void TeletextPage::setSidePanelStatusL25(bool newSidePanelStatusL25) { m_sidePanelStatusL25 = newSidePanelStatusL25; }
|
||||
|
||||
int TeletextPage::x28Needed()
|
||||
{
|
||||
int result = (m_leftSidePanelDisplayed || m_rightSidePanelDisplayed || m_defaultScreenColour !=0 || m_defaultRowColour !=0 || m_blackBackgroundSubst || m_colourTableRemap !=0 || m_defaultCharSet != 0 || m_secondCharSet != 0xf);
|
||||
|
||||
for (int i=0; i<16; i++)
|
||||
if (m_CLUT[i] != defaultCLUT[i]) {
|
||||
result |= 2;
|
||||
break;
|
||||
}
|
||||
for (int i=16; i<32; i++)
|
||||
if (m_CLUT[i] != defaultCLUT[i]) {
|
||||
result |= 1;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QString TeletextPage::colourHash(int whichCLUT)
|
||||
{
|
||||
QString resultHash;
|
||||
|
||||
for (int i=whichCLUT*16; i<whichCLUT*16+16; i++)
|
||||
resultHash.append(QString("%1").arg(m_CLUT[i], 3, 16, QChar('0')));
|
||||
return resultHash;
|
||||
}
|
||||
|
||||
QColor CLUTtoQColor(int myColour)
|
||||
{
|
||||
return QColor(((myColour & 0xf00) >> 8) * 17, ((myColour & 0x0f0) >> 4) * 17, (myColour & 0x00f) * 17);
|
||||
}
|
||||
110
page.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PAGE_H
|
||||
#define PAGE_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QColor>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "x26triplets.h"
|
||||
|
||||
QColor CLUTtoQColor(int myColour);
|
||||
|
||||
// If we inherit from QObject then we can't copy construct, so "make a new subpage that's a copy of this one" wouldn't work
|
||||
class TeletextPage //: public QObject
|
||||
{
|
||||
//Q_OBJECT
|
||||
|
||||
public:
|
||||
enum CycleTypeEnum { CTcycles, CTseconds };
|
||||
|
||||
TeletextPage();
|
||||
void clearPage();
|
||||
void loadPagePacket(QByteArray &);
|
||||
void savePage(QTextStream *, int, int);
|
||||
QString exportURLHash(QString);
|
||||
|
||||
/* void setSubPageNumber(int); */
|
||||
bool controlBit(int bitNumber) const { return m_controlBits[bitNumber]; }
|
||||
void setControlBit(int, bool);
|
||||
int cycleValue() const { return m_cycleValue; };
|
||||
void setCycleValue(int);
|
||||
CycleTypeEnum cycleType() const { return m_cycleType; };
|
||||
void setCycleType(CycleTypeEnum);
|
||||
int defaultCharSet() const { return m_defaultCharSet; }
|
||||
void setDefaultCharSet(int);
|
||||
int defaultNOS() const { return m_defaultNOS; }
|
||||
void setDefaultNOS(int);
|
||||
int secondCharSet() const { return m_secondCharSet; }
|
||||
void setSecondCharSet(int);
|
||||
int secondNOS() const { return m_secondNOS; }
|
||||
void setSecondNOS(int);
|
||||
unsigned char character(int row, int column) const { return m_level1Page[row][column]; }
|
||||
void setCharacter(int, int, unsigned char);
|
||||
int defaultScreenColour() const { return m_defaultScreenColour; }
|
||||
void setDefaultScreenColour(int);
|
||||
int defaultRowColour() const { return m_defaultRowColour; }
|
||||
void setDefaultRowColour(int);
|
||||
int colourTableRemap() const { return m_colourTableRemap; }
|
||||
void setColourTableRemap(int);
|
||||
bool blackBackgroundSubst() const { return m_blackBackgroundSubst; }
|
||||
void setBlackBackgroundSubst(bool);
|
||||
int CLUT(int index, int renderLevel=3) const;
|
||||
void setCLUT(int, int);
|
||||
bool leftSidePanelDisplayed() const { return m_leftSidePanelDisplayed; }
|
||||
void setLeftSidePanelDisplayed(bool);
|
||||
bool rightSidePanelDisplayed() const { return m_rightSidePanelDisplayed; }
|
||||
void setRightSidePanelDisplayed(bool);
|
||||
int sidePanelColumns() const { return m_sidePanelColumns; }
|
||||
void setSidePanelColumns(int);
|
||||
bool sidePanelStatusL25() const { return m_sidePanelStatusL25; }
|
||||
void setSidePanelStatusL25(bool);
|
||||
int x28Needed();
|
||||
QString colourHash(int);
|
||||
QList<X26Triplet> localEnhance;
|
||||
|
||||
protected:
|
||||
int controlBitsToPS() const;
|
||||
QString x28toTTI(int);
|
||||
|
||||
private:
|
||||
unsigned char m_level1Page[25][40];
|
||||
/* int m_subPageNumber; */
|
||||
bool m_controlBits[8];
|
||||
int m_cycleValue;
|
||||
CycleTypeEnum m_cycleType;
|
||||
int m_defaultCharSet, m_defaultNOS, m_secondCharSet, m_secondNOS;
|
||||
int m_defaultScreenColour, m_defaultRowColour, m_colourTableRemap, m_sidePanelColumns;
|
||||
bool m_blackBackgroundSubst, m_leftSidePanelDisplayed, m_rightSidePanelDisplayed, m_sidePanelStatusL25;
|
||||
int m_CLUT[32];
|
||||
|
||||
const int defaultCLUT[32] = {
|
||||
0x000, 0xf00, 0x0f0, 0xff0, 0x00f, 0xf0f, 0x0ff, 0xfff,
|
||||
0x000, 0x700, 0x070, 0x770, 0x007, 0x707, 0x077, 0x777,
|
||||
0xf05, 0xf70, 0x0f7, 0xffb, 0x0ca, 0x500, 0x652, 0xc77,
|
||||
0x333, 0xf77, 0x7f7, 0xff7, 0x77f, 0xf7f, 0x7ff, 0xddd
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
243
pageoptionsdockwidget.cpp
Normal file
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "pageoptionsdockwidget.h"
|
||||
|
||||
PageOptionsDockWidget::PageOptionsDockWidget(TeletextWidget *parent): QDockWidget(parent)
|
||||
{
|
||||
QVBoxLayout *pageOptionsLayout = new QVBoxLayout;
|
||||
QWidget *pageOptionsWidget = new QWidget;
|
||||
|
||||
m_parentMainWidget = parent;
|
||||
|
||||
this->setObjectName("PageOptionsDockWidget");
|
||||
this->setWindowTitle("Page options");
|
||||
|
||||
// Page number
|
||||
QHBoxLayout *pageNumberLayout = new QHBoxLayout;
|
||||
pageNumberLayout->addWidget(new QLabel(tr("Page number")));
|
||||
m_pageNumberEdit = new QLineEdit("100");
|
||||
m_pageNumberEdit->setMaxLength(3);
|
||||
m_pageNumberEdit->setInputMask("DHH");
|
||||
//TODO restrict first digit of page number to 1-8
|
||||
pageNumberLayout->addWidget(m_pageNumberEdit);
|
||||
connect(m_pageNumberEdit, &QLineEdit::textEdited, m_parentMainWidget->document(), &TeletextDocument::setPageNumber);
|
||||
|
||||
pageOptionsLayout->addLayout(pageNumberLayout);
|
||||
|
||||
// Page description
|
||||
m_pageDescriptionEdit = new QLineEdit();
|
||||
m_pageDescriptionEdit->setPlaceholderText("Page description");
|
||||
connect(m_pageDescriptionEdit, &QLineEdit::textEdited, m_parentMainWidget->document(), &TeletextDocument::setDescription);
|
||||
|
||||
pageOptionsLayout->addWidget(m_pageDescriptionEdit);
|
||||
|
||||
// FastText links
|
||||
QGridLayout *fastTextLayout = new QGridLayout;
|
||||
for (int i=0; i<6; i++) {
|
||||
const char *fastTextLabel[] = { "Red", "Green", "Yellow" ,"Blue", "Next", "Index" };
|
||||
|
||||
fastTextLayout->addWidget(new QLabel(fastTextLabel[i]), 0, i, 1, 1, Qt::AlignCenter);
|
||||
m_fastTextEdit[i] = new QLineEdit;
|
||||
m_fastTextEdit[i]->setMaxLength(3);
|
||||
m_fastTextEdit[i]->setInputMask("DHH");
|
||||
//TODO restrict first digit of page number to 1-8
|
||||
fastTextLayout->addWidget(m_fastTextEdit[i], 1, i, 1, 1);
|
||||
connect(m_fastTextEdit[i], &QLineEdit::textEdited, [=](QString value) { m_parentMainWidget->document()->setFastTextLink(i, value); } );
|
||||
}
|
||||
|
||||
pageOptionsLayout->addLayout(fastTextLayout);
|
||||
|
||||
QGroupBox *subPageGroupBox = new QGroupBox(tr("Subpage options"));
|
||||
QVBoxLayout *subPageOptionsLayout = new QVBoxLayout;
|
||||
|
||||
// Cycle
|
||||
QHBoxLayout *pageCycleLayout = new QHBoxLayout;
|
||||
pageCycleLayout->addWidget(new QLabel(tr("Page cycle")));
|
||||
m_cycleValueSpinBox = new QSpinBox;
|
||||
m_cycleValueSpinBox->setRange(1, 99);
|
||||
m_cycleValueSpinBox->setWrapping(true);
|
||||
pageCycleLayout->addWidget(m_cycleValueSpinBox);
|
||||
// Since TeletextPage doesn't inherit from QObject (so we can copy construct it) it doesn't have a slot
|
||||
// to connect to, so we need to use a lambda
|
||||
connect(m_cycleValueSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), [=](int index) { m_parentMainWidget->document()->currentSubPage()->setCycleValue(index); } );
|
||||
m_cycleTypeCombo = new QComboBox;
|
||||
m_cycleTypeCombo->addItem("cycles");
|
||||
m_cycleTypeCombo->addItem("seconds");
|
||||
pageCycleLayout->addWidget(m_cycleTypeCombo);
|
||||
connect(m_cycleTypeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index) { m_parentMainWidget->document()->currentSubPage()->setCycleType(index == 0 ? TeletextPage::CTcycles : TeletextPage::CTseconds); } );
|
||||
|
||||
subPageOptionsLayout->addLayout(pageCycleLayout);
|
||||
|
||||
// Page status bits
|
||||
for (int i=0; i<=7; i++) {
|
||||
const char *controlBitsLabel[] = { "C4 Erase page", "C5 Newsflash", "C6 Subtitle", "C7 Suppress header", "C8 Update page", "C9 Page not in sequence", "C10 Inhibit display", "C11 Serial magazine" };
|
||||
|
||||
m_controlBitsAct[i] = new QCheckBox(controlBitsLabel[i]);
|
||||
subPageOptionsLayout->addWidget(m_controlBitsAct[i]);
|
||||
connect(m_controlBitsAct[i], &QCheckBox::stateChanged, [=](bool active) { m_parentMainWidget->setControlBit(i, active); });
|
||||
}
|
||||
|
||||
// Region and language
|
||||
QGridLayout *regionLayout = new QGridLayout;
|
||||
regionLayout->addWidget(new QLabel(tr("Region")), 0, 0, 1, 1);
|
||||
m_defaultRegionCombo = new QComboBox;
|
||||
addRegionList(m_defaultRegionCombo);
|
||||
|
||||
regionLayout->addWidget(m_defaultRegionCombo, 0, 1, 1, 1, Qt::AlignTop);
|
||||
connect(m_defaultRegionCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=]{ setDefaultRegion(); });
|
||||
|
||||
m_defaultNOSCombo = new QComboBox;
|
||||
regionLayout->addWidget(m_defaultNOSCombo, 0, 2, 1, 1, Qt::AlignTop);
|
||||
connect(m_defaultNOSCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=]{ setDefaultNOS(); });
|
||||
|
||||
regionLayout->addWidget(new QLabel(tr("2nd region")), 1, 0, 1, 1);
|
||||
m_secondRegionCombo = new QComboBox;
|
||||
m_secondRegionCombo->addItem("Not needed", 15);
|
||||
addRegionList(m_secondRegionCombo);
|
||||
regionLayout->addWidget(m_secondRegionCombo, 1, 1, 1, 1, Qt::AlignTop);
|
||||
connect(m_secondRegionCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=]{ setSecondRegion(); });
|
||||
|
||||
m_secondNOSCombo = new QComboBox;
|
||||
regionLayout->addWidget(m_secondNOSCombo, 1, 2, 1, 1, Qt::AlignTop);
|
||||
connect(m_secondNOSCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=]{ setSecondNOS(); });
|
||||
|
||||
subPageOptionsLayout->addLayout(regionLayout);
|
||||
|
||||
subPageGroupBox->setLayout(subPageOptionsLayout);
|
||||
pageOptionsLayout->addWidget(subPageGroupBox);
|
||||
|
||||
pageOptionsLayout->addStretch(1);
|
||||
|
||||
pageOptionsWidget->setLayout(pageOptionsLayout);
|
||||
this->setWidget(pageOptionsWidget);
|
||||
|
||||
}
|
||||
|
||||
void PageOptionsDockWidget::addRegionList(QComboBox *regionCombo)
|
||||
{
|
||||
regionCombo->addItem("0", 0);
|
||||
regionCombo->addItem("1", 1);
|
||||
regionCombo->addItem("2", 2);
|
||||
regionCombo->addItem("3", 3);
|
||||
regionCombo->addItem("4", 4);
|
||||
regionCombo->addItem("6", 6);
|
||||
regionCombo->addItem("8", 8);
|
||||
regionCombo->addItem("10", 10);
|
||||
}
|
||||
|
||||
void PageOptionsDockWidget::updateWidgets()
|
||||
{
|
||||
m_pageNumberEdit->blockSignals(true);
|
||||
m_pageNumberEdit->setText(QString::number(m_parentMainWidget->document()->pageNumber(), 16).toUpper());
|
||||
m_pageNumberEdit->blockSignals(false);
|
||||
m_pageDescriptionEdit->blockSignals(true);
|
||||
m_pageDescriptionEdit->setText(m_parentMainWidget->document()->description());
|
||||
m_pageDescriptionEdit->blockSignals(false);
|
||||
for (int i=0; i<6; i++) {
|
||||
m_fastTextEdit[i]->blockSignals(true);
|
||||
m_fastTextEdit[i]->setText(QString::number(m_parentMainWidget->document()->fastTextLink(i), 16).toUpper());
|
||||
m_fastTextEdit[i]->blockSignals(false);
|
||||
}
|
||||
m_cycleValueSpinBox->blockSignals(true);
|
||||
m_cycleValueSpinBox->setValue(m_parentMainWidget->document()->currentSubPage()->cycleValue());
|
||||
m_cycleValueSpinBox->blockSignals(false);
|
||||
m_cycleTypeCombo->blockSignals(true);
|
||||
m_cycleTypeCombo->setCurrentIndex(m_parentMainWidget->document()->currentSubPage()->cycleType() == TeletextPage::CTseconds);
|
||||
m_cycleTypeCombo->blockSignals(false);
|
||||
for (int i=0; i<=7; i++) {
|
||||
m_controlBitsAct[i]->blockSignals(true);
|
||||
m_controlBitsAct[i]->setChecked(m_parentMainWidget->document()->currentSubPage()->controlBit(i));
|
||||
m_controlBitsAct[i]->blockSignals(false);
|
||||
}
|
||||
m_defaultRegionCombo->blockSignals(true);
|
||||
m_defaultRegionCombo->setCurrentText(QString::number(m_parentMainWidget->document()->currentSubPage()->defaultCharSet()));
|
||||
m_defaultRegionCombo->blockSignals(false);
|
||||
m_defaultNOSCombo->blockSignals(true);
|
||||
updateDefaultNOSOptions();
|
||||
m_defaultNOSCombo->setCurrentIndex(m_defaultNOSCombo->findData((m_parentMainWidget->document()->currentSubPage()->defaultCharSet() << 3) | m_parentMainWidget->document()->currentSubPage()->defaultNOS()));
|
||||
m_defaultNOSCombo->blockSignals(false);
|
||||
m_secondRegionCombo->blockSignals(true);
|
||||
m_secondRegionCombo->setCurrentText(QString::number(m_parentMainWidget->document()->currentSubPage()->secondCharSet()));
|
||||
m_secondRegionCombo->blockSignals(false);
|
||||
m_secondNOSCombo->blockSignals(true);
|
||||
updateSecondNOSOptions();
|
||||
m_secondNOSCombo->setCurrentIndex(m_defaultNOSCombo->findData((m_parentMainWidget->document()->currentSubPage()->secondCharSet() << 3) | m_parentMainWidget->document()->currentSubPage()->secondNOS()));
|
||||
m_secondNOSCombo->blockSignals(false);
|
||||
}
|
||||
|
||||
void PageOptionsDockWidget::updateDefaultNOSOptions()
|
||||
{
|
||||
while (m_defaultNOSCombo->count() > 0)
|
||||
m_defaultNOSCombo->removeItem(0);
|
||||
for (int i=0; i<languageComboBoxItemCount; i++)
|
||||
if ((languageComboBoxItems[i].bits >> 3) == m_parentMainWidget->document()->currentSubPage()->defaultCharSet())
|
||||
m_defaultNOSCombo->addItem(languageComboBoxItems[i].name, languageComboBoxItems[i].bits);
|
||||
}
|
||||
|
||||
void PageOptionsDockWidget::updateSecondNOSOptions()
|
||||
{
|
||||
while (m_secondNOSCombo->count() > 0)
|
||||
m_secondNOSCombo->removeItem(0);
|
||||
for (int i=0; i<languageComboBoxItemCount; i++)
|
||||
if ((languageComboBoxItems[i].bits >> 3) == m_parentMainWidget->document()->currentSubPage()->secondCharSet())
|
||||
m_secondNOSCombo->addItem(languageComboBoxItems[i].name, languageComboBoxItems[i].bits);
|
||||
}
|
||||
|
||||
void PageOptionsDockWidget::setDefaultRegion()
|
||||
{
|
||||
m_parentMainWidget->document()->currentSubPage()->setDefaultCharSet(m_defaultRegionCombo->currentData().toInt());
|
||||
m_defaultNOSCombo->blockSignals(true);
|
||||
updateDefaultNOSOptions();
|
||||
setDefaultNOS();
|
||||
m_defaultNOSCombo->blockSignals(false);
|
||||
m_parentMainWidget->refreshPage();
|
||||
}
|
||||
|
||||
void PageOptionsDockWidget::setDefaultNOS()
|
||||
{
|
||||
m_parentMainWidget->document()->currentSubPage()->setDefaultNOS(m_defaultNOSCombo->currentData().toInt() & 0x07);
|
||||
m_parentMainWidget->refreshPage();
|
||||
}
|
||||
|
||||
void PageOptionsDockWidget::setSecondRegion()
|
||||
{
|
||||
m_parentMainWidget->document()->currentSubPage()->setSecondCharSet(m_secondRegionCombo->currentData().toInt());
|
||||
m_secondNOSCombo->blockSignals(true);
|
||||
updateSecondNOSOptions();
|
||||
setSecondNOS();
|
||||
m_secondNOSCombo->blockSignals(false);
|
||||
m_parentMainWidget->refreshPage();
|
||||
}
|
||||
|
||||
void PageOptionsDockWidget::setSecondNOS()
|
||||
{
|
||||
m_parentMainWidget->document()->currentSubPage()->setSecondNOS(m_secondNOSCombo->currentData().toInt() & 0x07);
|
||||
m_parentMainWidget->refreshPage();
|
||||
}
|
||||
110
pageoptionsdockwidget.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PAGEOPTIONSDOCKWIDGET_H
|
||||
#define PAGEOPTIONSDOCKWIDGET_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDockWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
|
||||
#include "mainwidget.h"
|
||||
|
||||
class PageOptionsDockWidget : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PageOptionsDockWidget(TeletextWidget *parent);
|
||||
void updateWidgets();
|
||||
|
||||
private:
|
||||
TeletextWidget *m_parentMainWidget;
|
||||
QLineEdit *m_pageNumberEdit, *m_pageDescriptionEdit;
|
||||
QSpinBox *m_cycleValueSpinBox;
|
||||
QComboBox *m_cycleTypeCombo;
|
||||
QCheckBox *m_controlBitsAct[8];
|
||||
QComboBox *m_defaultRegionCombo, *m_defaultNOSCombo, *m_secondRegionCombo, *m_secondNOSCombo;
|
||||
QLineEdit *m_fastTextEdit[6];
|
||||
|
||||
void addRegionList(QComboBox *);
|
||||
void setDefaultRegion();
|
||||
void setDefaultNOS();
|
||||
void setSecondRegion();
|
||||
void setSecondNOS();
|
||||
void updateDefaultNOSOptions();
|
||||
void updateSecondNOSOptions();
|
||||
};
|
||||
|
||||
struct languageComboBoxItem {
|
||||
QString name;
|
||||
int bits;
|
||||
};
|
||||
|
||||
static const int languageComboBoxItemCount = 36;
|
||||
|
||||
static const languageComboBoxItem languageComboBoxItems[languageComboBoxItemCount] {
|
||||
{ "English", 0x00 } ,
|
||||
{ "German", 0x01 } ,
|
||||
{ "Swedish/Finnish/Hungarian", 0x02 } ,
|
||||
{ "Italian", 0x03 } ,
|
||||
{ "French", 0x04 } ,
|
||||
{ "Portuguese/Spanish", 0x05 } ,
|
||||
{ "Czech/Slovak", 0x06 } ,
|
||||
|
||||
{ "Polish", 0x08 } ,
|
||||
{ "German", 0x09 } ,
|
||||
{ "Swedish/Finnish/Hungarian", 0x0a } ,
|
||||
{ "Italian", 0x0b } ,
|
||||
{ "French", 0x0c } ,
|
||||
{ "Czech/Slovak", 0x0e } ,
|
||||
|
||||
{ "English", 0x10 } ,
|
||||
{ "German", 0x11 } ,
|
||||
{ "Swedish/Finnish/Hungarian", 0x12 } ,
|
||||
{ "Italian", 0x13 } ,
|
||||
{ "French", 0x14 } ,
|
||||
{ "Portuguese/Spanish", 0x15 } ,
|
||||
{ "Turkish", 0x16 } ,
|
||||
|
||||
{ "Serbian/Croatian/Slovenian", 0x1d } ,
|
||||
{ "Rumanian", 0x1f } ,
|
||||
|
||||
{ "Serbian/Croatian", 0x20 } ,
|
||||
{ "German", 0x21 } ,
|
||||
{ "Estonian", 0x22 } ,
|
||||
{ "Lettish/Lithuanian", 0x23 } ,
|
||||
{ "Russian/Bulgarian", 0x24 } ,
|
||||
{ "Ukrainian", 0x25 } ,
|
||||
{ "Czech/Slovak", 0x26 } ,
|
||||
|
||||
{ "Turkish", 0x36 } ,
|
||||
{ "Greek", 0x37 } ,
|
||||
|
||||
{ "English", 0x40 } ,
|
||||
{ "French", 0x44 } ,
|
||||
{ "Arabic", 0x47 } ,
|
||||
|
||||
{ "Hebrew", 0x55 } ,
|
||||
{ "Arabic", 0x57 } ,
|
||||
};
|
||||
|
||||
#endif
|
||||
118
palettedockwidget.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QColorDialog>
|
||||
#include <QDialog>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QUndoCommand>
|
||||
#include <math.h>
|
||||
|
||||
#include "palettedockwidget.h"
|
||||
|
||||
#include "document.h"
|
||||
#include "mainwidget.h"
|
||||
|
||||
PaletteDockWidget::PaletteDockWidget(TeletextWidget *parent): QDockWidget(parent)
|
||||
{
|
||||
QGridLayout *paletteGridLayout = new QGridLayout;
|
||||
QWidget *paletteGridWidget = new QWidget;
|
||||
|
||||
m_parentMainWidget = parent;
|
||||
|
||||
this->setObjectName("PaletteDockWidget");
|
||||
this->setWindowTitle("Palette");
|
||||
for (int r=0, i=0; r<=3; r++) {
|
||||
paletteGridLayout->addWidget(new QLabel(tr("CLUT %1").arg(r)), r, 0);
|
||||
m_resetButton[r] = new QPushButton(tr("Reset"));
|
||||
paletteGridLayout->addWidget(m_resetButton[r], r, 9);
|
||||
connect(m_resetButton[r], &QAbstractButton::clicked, [=]() { resetCLUT(r); });
|
||||
for (int c=0; c<=7; c++, i++) {
|
||||
if (i == 8)
|
||||
continue;
|
||||
m_colourButton[i] = new QPushButton();
|
||||
m_colourButton[i]->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
paletteGridLayout->addWidget(m_colourButton[i], r, c+1);
|
||||
connect(m_colourButton[i], &QAbstractButton::clicked, [=]() { selectColour(i); });
|
||||
}
|
||||
}
|
||||
paletteGridWidget->setLayout(paletteGridLayout);
|
||||
this->setWidget(paletteGridWidget);
|
||||
connect(m_parentMainWidget->document(), &TeletextDocument::colourChanged, this, &PaletteDockWidget::updateColourButton);
|
||||
}
|
||||
|
||||
void PaletteDockWidget::updateColourButton(int colourIndex)
|
||||
{
|
||||
if (colourIndex == 8)
|
||||
return;
|
||||
QString colourString = QString("%1").arg(m_parentMainWidget->document()->currentSubPage()->CLUT(colourIndex), 3, 16, QChar('0'));
|
||||
m_colourButton[colourIndex]->setText(colourString);
|
||||
|
||||
// Set text itself to black or white so it can be seen over background colour - http://alienryderflex.com/hsp.html
|
||||
int r = m_parentMainWidget->document()->currentSubPage()->CLUT(colourIndex) >> 8;
|
||||
int g = (m_parentMainWidget->document()->currentSubPage()->CLUT(colourIndex) >> 4) & 0xf;
|
||||
int b = m_parentMainWidget->document()->currentSubPage()->CLUT(colourIndex) & 0xf;
|
||||
char blackOrWhite = (sqrt(r*r*0.299 + g*g*0.587 + b*b*0.114) > 7.647) ? '0' : 'f';
|
||||
|
||||
QString qss = QString("background-color: #%1; color: #%2%2%2; border: none").arg(colourString).arg(blackOrWhite);
|
||||
m_colourButton[colourIndex]->setStyleSheet(qss);
|
||||
|
||||
if (m_parentMainWidget->document()->currentSubPage()->CLUT(colourIndex) == m_parentMainWidget->document()->currentSubPage()->CLUT(colourIndex, 0)) {
|
||||
// Default colour was set, disable Reset button if all colours in row are default as well
|
||||
for (int i=colourIndex & 0x18; i<(colourIndex & 0x18)+8; i++) {
|
||||
if (i == 8)
|
||||
continue;
|
||||
if (m_parentMainWidget->document()->currentSubPage()->CLUT(i) != m_parentMainWidget->document()->currentSubPage()->CLUT(i, 0)) {
|
||||
m_resetButton[colourIndex>>3]->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_resetButton[colourIndex>>3]->setEnabled(false);
|
||||
} else
|
||||
m_resetButton[colourIndex>>3]->setEnabled(true);
|
||||
}
|
||||
|
||||
void PaletteDockWidget::updateAllColourButtons()
|
||||
{
|
||||
for (int i=0; i<32; i++)
|
||||
updateColourButton(i);
|
||||
}
|
||||
|
||||
void PaletteDockWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
updateAllColourButtons();
|
||||
}
|
||||
|
||||
void PaletteDockWidget::selectColour(int colourIndex)
|
||||
{
|
||||
const QColor newColour = QColorDialog::getColor(CLUTtoQColor(m_parentMainWidget->document()->currentSubPage()->CLUT(colourIndex)), this, "Select Colour");
|
||||
|
||||
if (newColour.isValid()) {
|
||||
QUndoCommand *setColourCommand = new SetColourCommand(m_parentMainWidget->document(), colourIndex, ((newColour.red() & 0xf0) << 4) | (newColour.green() & 0xf0) | ((newColour.blue() & 0xf0) >> 4));
|
||||
m_parentMainWidget->document()->undoStack()->push(setColourCommand);
|
||||
}
|
||||
}
|
||||
|
||||
void PaletteDockWidget::resetCLUT(int colourTable)
|
||||
{
|
||||
QUndoCommand *resetCLUTCommand = new ResetCLUTCommand(m_parentMainWidget->document(), colourTable);
|
||||
m_parentMainWidget->document()->undoStack()->push(resetCLUTCommand);
|
||||
}
|
||||
53
palettedockwidget.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PALETTEDOCKWIDGET_H
|
||||
#define PALETTEDOCKWIDGET_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "mainwidget.h"
|
||||
|
||||
class PaletteDockWidget : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PaletteDockWidget(TeletextWidget *parent);
|
||||
void updateAllColourButtons();
|
||||
|
||||
public slots:
|
||||
void updateColourButton(int);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
|
||||
private slots:
|
||||
void selectColour(int);
|
||||
|
||||
private:
|
||||
void resetCLUT(int);
|
||||
|
||||
QPushButton *m_colourButton[32], *m_resetButton[4];
|
||||
|
||||
TeletextWidget *m_parentMainWidget;
|
||||
};
|
||||
|
||||
#endif
|
||||
31
qteletextmaker.pro
Normal file
@@ -0,0 +1,31 @@
|
||||
QT += widgets
|
||||
requires(qtConfig(filedialog))
|
||||
|
||||
HEADERS = document.h \
|
||||
mainwidget.h \
|
||||
mainwindow.h \
|
||||
page.h \
|
||||
pageoptionsdockwidget.h \
|
||||
palettedockwidget.h \
|
||||
render.h \
|
||||
x26dockwidget.h \
|
||||
x26model.h \
|
||||
x26triplets.h \
|
||||
x28dockwidget.h
|
||||
SOURCES = document.cpp \
|
||||
main.cpp \
|
||||
mainwidget.cpp \
|
||||
mainwindow.cpp \
|
||||
pageoptionsdockwidget.cpp \
|
||||
palettedockwidget.cpp \
|
||||
page.cpp \
|
||||
render.cpp \
|
||||
x26dockwidget.cpp \
|
||||
x26model.cpp \
|
||||
x26triplets.cpp \
|
||||
x28dockwidget.cpp
|
||||
RESOURCES = qteletextmaker.qrc
|
||||
|
||||
# install
|
||||
target.path = /usr/local/bin
|
||||
INSTALLS += target
|
||||
11
qteletextmaker.qrc
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>images/teletextfont.png</file>
|
||||
<file>images/copy.png</file>
|
||||
<file>images/cut.png</file>
|
||||
<file>images/new.png</file>
|
||||
<file>images/open.png</file>
|
||||
<file>images/paste.png</file>
|
||||
<file>images/save.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
1074
render.cpp
Normal file
246
render.h
Normal file
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef RENDER_H
|
||||
#define RENDER_H
|
||||
|
||||
#include <QBitmap>
|
||||
#include <QMap>
|
||||
#include <QMultiMap>
|
||||
#include <vector>
|
||||
|
||||
#include "page.h"
|
||||
|
||||
|
||||
struct textCharacter {
|
||||
unsigned char code=0x20;
|
||||
int set=0;
|
||||
int diacritical=0;
|
||||
};
|
||||
|
||||
struct displayAttributes {
|
||||
bool doubleHeight=false;
|
||||
bool doubleWidth=false;
|
||||
bool boxingWindow=false;
|
||||
bool conceal=false;
|
||||
bool invert=false;
|
||||
bool underlineSeparated=false;
|
||||
bool forceContiguous=false;
|
||||
};
|
||||
|
||||
struct textAttributes {
|
||||
int foreColour=0x07;
|
||||
int backColour=0x00;
|
||||
struct flashFunctions {
|
||||
int mode=0;
|
||||
int ratePhase=0;
|
||||
int phaseNumber=0;
|
||||
} flash;
|
||||
displayAttributes display;
|
||||
/* font style */
|
||||
};
|
||||
|
||||
struct textCell {
|
||||
textCharacter character;
|
||||
textAttributes attribute;
|
||||
bool bottomHalf=false;
|
||||
bool rightHalf=false;
|
||||
bool level1Mosaic=false;
|
||||
int level1CharSet=0;
|
||||
};
|
||||
|
||||
struct applyAttributes {
|
||||
bool applyForeColour=false;
|
||||
bool applyBackColour=false;
|
||||
bool applyFlash=false;
|
||||
bool applyDisplayAttributes=false;
|
||||
bool applyTextSizeOnly=false;
|
||||
bool applyBoxingOnly=false;
|
||||
bool applyConcealOnly=false;
|
||||
bool applyContiguousOnly=false;
|
||||
bool copyAboveAttributes=false;
|
||||
textAttributes attribute;
|
||||
};
|
||||
|
||||
class ActivePosition
|
||||
{
|
||||
public:
|
||||
ActivePosition();
|
||||
int row() const { return (m_row == -1) ? 0 : m_row; }
|
||||
int column() const { return (m_column == -1) ? 0 : m_column; }
|
||||
bool isDeployed() const { return m_row != -1; }
|
||||
bool setRow(int);
|
||||
bool setColumn(int);
|
||||
// bool setRowAndColumn(int, int);
|
||||
|
||||
private:
|
||||
int m_row, m_column;
|
||||
};
|
||||
|
||||
|
||||
class TextLayer
|
||||
{
|
||||
public:
|
||||
// TextLayer(TeletextPage* thePage) : currentPage(thePage) { };
|
||||
virtual ~TextLayer() = default;
|
||||
void setTeletextPage(TeletextPage*);
|
||||
virtual textCharacter character(int, int) =0;
|
||||
virtual void attributes(int, int, applyAttributes *) =0;
|
||||
virtual int fullScreenColour() const =0;
|
||||
virtual int fullRowColour(int) const =0;
|
||||
virtual bool fullRowDownwards(int) const =0;
|
||||
virtual int objectType() const =0;
|
||||
void setFullScreenColour(int);
|
||||
void setFullRowColour(int, int, bool);
|
||||
|
||||
// TODO replace ints with proper classes
|
||||
QMultiMap<int, int> enhanceMap;
|
||||
|
||||
protected:
|
||||
TeletextPage* m_teletextPage;
|
||||
int m_layerFullScreenColour=-1;
|
||||
int m_layerFullRowColour[25];
|
||||
bool m_layerFullRowDownwards[25];
|
||||
applyAttributes m_applyAttributes;
|
||||
};
|
||||
|
||||
class EnhanceLayer: public TextLayer
|
||||
{
|
||||
public:
|
||||
EnhanceLayer();
|
||||
textCharacter character(int, int);
|
||||
void attributes(int, int, applyAttributes *);
|
||||
int fullScreenColour() const { return m_layerFullScreenColour; };
|
||||
int fullRowColour(int r) const { return m_layerFullRowColour[r]; };
|
||||
bool fullRowDownwards(int r) const { return m_layerFullRowDownwards[r]; };
|
||||
int objectType() const { return m_objectType; };
|
||||
void setObjectType(int);
|
||||
void setOrigin(int, int);
|
||||
|
||||
protected:
|
||||
int m_objectType=0;
|
||||
int m_originR=0;
|
||||
int m_originC=0;
|
||||
int m_rowCached=-1;
|
||||
int m_rightMostColumn[25];
|
||||
};
|
||||
|
||||
class Level1Layer: public TextLayer
|
||||
{
|
||||
public:
|
||||
// Level1Layer(TeletextPage *thePage) : TextLayer(thePage) { };
|
||||
Level1Layer();
|
||||
textCharacter character(int, int);
|
||||
void attributes(int, int, applyAttributes *);
|
||||
int fullScreenColour() const { return -1; };
|
||||
int fullRowColour(int) const { return -1; };
|
||||
bool fullRowDownwards(int) const { return false; };
|
||||
int objectType() const { return 0; }
|
||||
bool isRowBottomHalf(int r) const { return m_rowHeight[r]==RHbottomhalf; }
|
||||
|
||||
private:
|
||||
void updateRowCache(int);
|
||||
|
||||
struct level1CacheAttributes {
|
||||
int foreColour=0x07;
|
||||
int backColour=0x00;
|
||||
unsigned char sizeCode=0x0c;
|
||||
bool mosaics=false;
|
||||
bool separated=false;
|
||||
bool held=false;
|
||||
bool escSwitch=false;
|
||||
unsigned char holdChar=0x20;
|
||||
bool holdSeparated=false;
|
||||
};
|
||||
level1CacheAttributes m_attributeCache[40];
|
||||
int m_rowCached=-1;
|
||||
bool m_rowHasDoubleHeightAttr[25];
|
||||
enum rowHeightEnum { RHnormal=-1, RHtophalf, RHbottomhalf } m_rowHeight[25];
|
||||
};
|
||||
|
||||
class TeletextPageRender : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TeletextPageRender();
|
||||
~TeletextPageRender();
|
||||
void decodePage();
|
||||
void renderPage();
|
||||
void renderPage(int r);
|
||||
void setTeletextPage(TeletextPage*);
|
||||
void updateSidePanels();
|
||||
void buildEnhanceMap(TextLayer *, int=0);
|
||||
QPixmap* pagePixmap(int i) const { return m_pagePixmap[i]; };
|
||||
bool level1MosaicAttribute(int r, int c) const { return m_cell[r][c].level1Mosaic; };
|
||||
int level1CharSet(int r, int c) const { return m_cell[r][c].level1CharSet; };
|
||||
int leftSidePanelColumns() const { return m_leftSidePanelColumns; };
|
||||
int rightSidePanelColumns() const { return m_rightSidePanelColumns; };
|
||||
void setGrid(bool);
|
||||
|
||||
public slots:
|
||||
void setReveal(bool);
|
||||
void setMix(bool);
|
||||
void setShowCodes(bool);
|
||||
void setRenderLevel(int);
|
||||
|
||||
signals:
|
||||
void fullScreenColourChanged(QColor);
|
||||
void fullRowColourChanged(int, QColor);
|
||||
void flashChanged(int);
|
||||
void sidePanelsChanged();
|
||||
|
||||
protected:
|
||||
void updateFlashRequired(int);
|
||||
inline void setFullScreenColour(int);
|
||||
inline void setFullRowColour(int, int);
|
||||
|
||||
QBitmap* m_fontBitmap;
|
||||
QPixmap* m_pagePixmap[6];
|
||||
int m_finalFullScreenColour, m_renderLevel;
|
||||
QColor m_finalFullScreenQColor;
|
||||
int m_leftSidePanelColumns, m_rightSidePanelColumns;
|
||||
bool m_reveal, m_mix, m_grid, m_showCodes;
|
||||
Level1Layer m_level1Layer;
|
||||
std::vector<TextLayer *> m_textLayer;
|
||||
const int m_foregroundRemap[8] = { 0, 0, 0, 8, 8, 16, 16, 16 };
|
||||
const int m_backgroundRemap[8] = { 0, 8, 16, 8, 16, 8, 16, 24 };
|
||||
|
||||
private:
|
||||
textCell m_cell[25][72];
|
||||
TeletextPage* m_teletextPage;
|
||||
int m_flashRequired;
|
||||
int m_fullRowColour[25];
|
||||
QColor m_fullRowQColor[25];
|
||||
int m_flashRow[25];
|
||||
bool m_concealRow[25];
|
||||
};
|
||||
|
||||
static const QMap<int, int> g0CharacterMap {
|
||||
{ 0x00, 12 }, { 0x01, 15 }, { 0x02, 22 }, { 0x03, 16 }, { 0x04, 14 }, { 0x05, 19 }, { 0x06, 11 },
|
||||
{ 0x08, 18 }, { 0x09, 15 }, { 0x0a, 22 }, { 0x0b, 16 }, { 0x0c, 14 }, { 0x0e, 11 },
|
||||
{ 0x10, 12 }, { 0x11, 15 }, { 0x12, 22 }, { 0x13, 16 }, { 0x14, 14 }, { 0x15, 19 }, { 0x16, 23 },
|
||||
{ 0x1d, 21 }, { 0x1f, 20 },
|
||||
{ 0x20, 1 }, { 0x21, 15 }, { 0x22, 13 }, { 0x23, 17 }, { 0x24, 2 }, { 0x25, 3 }, { 0x26, 11 },
|
||||
{ 0x36, 23 }, { 0x37, 4 },
|
||||
{ 0x40, 12 }, { 0x44, 14 }, { 0x47, 5 },
|
||||
{ 0x55, 6 }, { 0x57, 5 }
|
||||
};
|
||||
|
||||
#endif
|
||||
195
x26dockwidget.cpp
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QActionGroup>
|
||||
#include <QButtonGroup>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QShortcut>
|
||||
#include <QSpinBox>
|
||||
#include <QStandardItemModel>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "x26dockwidget.h"
|
||||
|
||||
X26DockWidget::X26DockWidget(TeletextWidget *parent): QDockWidget(parent)
|
||||
{
|
||||
QVBoxLayout *x26Layout = new QVBoxLayout;
|
||||
QWidget *x26Widget = new QWidget;
|
||||
m_parentMainWidget = parent;
|
||||
|
||||
this->setObjectName("x26DockWidget");
|
||||
this->setWindowTitle("X/26 triplets");
|
||||
|
||||
// Table listing of local enhancements
|
||||
m_x26View = new QTableView;
|
||||
m_x26Model = new X26Model(m_parentMainWidget);
|
||||
m_x26View->setModel(m_x26Model);
|
||||
m_x26View->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
m_x26View->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_x26View->setColumnWidth(0, 50);
|
||||
m_x26View->setColumnWidth(1, 50);
|
||||
m_x26View->setColumnWidth(2, 200);
|
||||
m_x26View->setColumnWidth(3, 200);
|
||||
x26Layout->addWidget(m_x26View);
|
||||
|
||||
// "Temporary" widgets to edit raw triplet values
|
||||
QHBoxLayout *rawTripletLayout = new QHBoxLayout;
|
||||
|
||||
rawTripletLayout->addWidget(new QLabel(tr("Address")));
|
||||
m_rawTripletAddressSpinBox = new QSpinBox;
|
||||
m_rawTripletAddressSpinBox->setMaximum(63);
|
||||
rawTripletLayout->addWidget(m_rawTripletAddressSpinBox);
|
||||
|
||||
rawTripletLayout->addWidget(new QLabel(tr("Mode")));
|
||||
m_rawTripletModeSpinBox = new QSpinBox;
|
||||
m_rawTripletModeSpinBox->setMaximum(31);
|
||||
rawTripletLayout->addWidget(m_rawTripletModeSpinBox);
|
||||
|
||||
rawTripletLayout->addWidget(new QLabel(tr("Data")));
|
||||
m_rawTripletDataSpinBox = new QSpinBox;
|
||||
m_rawTripletDataSpinBox->setMaximum(127);
|
||||
rawTripletLayout->addWidget(m_rawTripletDataSpinBox);
|
||||
|
||||
connect(m_rawTripletAddressSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &X26DockWidget::rawTripletAddressSpinBoxChanged);
|
||||
connect(m_rawTripletModeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &X26DockWidget::rawTripletModeSpinBoxChanged);
|
||||
connect(m_rawTripletDataSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &X26DockWidget::rawTripletDataSpinBoxChanged);
|
||||
|
||||
x26Layout->addLayout(rawTripletLayout);
|
||||
|
||||
// Insert and delete widgets
|
||||
QHBoxLayout *insertDeleteLayout = new QHBoxLayout;
|
||||
|
||||
m_insertPushButton = new QPushButton(tr("Insert triplet"));
|
||||
insertDeleteLayout->addWidget(m_insertPushButton);
|
||||
m_deletePushButton = new QPushButton(tr("Delete triplet"));
|
||||
insertDeleteLayout->addWidget(m_deletePushButton);
|
||||
|
||||
connect(m_insertPushButton, &QPushButton::clicked, this, &X26DockWidget::insertTriplet);
|
||||
connect(m_deletePushButton, &QPushButton::clicked, this, &X26DockWidget::deleteTriplet);
|
||||
|
||||
x26Layout->addLayout(insertDeleteLayout);
|
||||
|
||||
x26Widget->setLayout(x26Layout);
|
||||
this->setWidget(x26Widget);
|
||||
|
||||
m_x26View->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_x26View, &QWidget::customContextMenuRequested, this, &X26DockWidget::customMenuRequested);
|
||||
|
||||
connect(m_x26View, &QAbstractItemView::clicked, this, &X26DockWidget::rowClicked);
|
||||
|
||||
QShortcut* insertShortcut = new QShortcut(QKeySequence(Qt::Key_Insert), m_x26View);
|
||||
connect(insertShortcut, &QShortcut::activated, this, &X26DockWidget::insertTriplet);
|
||||
QShortcut* deleteShortcut = new QShortcut(QKeySequence(Qt::Key_Delete), m_x26View);
|
||||
connect(deleteShortcut, &QShortcut::activated, this, &X26DockWidget::deleteTriplet);
|
||||
}
|
||||
|
||||
void X26DockWidget::loadX26List()
|
||||
{
|
||||
m_x26Model->setX26ListLoaded(true);
|
||||
}
|
||||
|
||||
void X26DockWidget::unloadX26List()
|
||||
{
|
||||
m_x26Model->setX26ListLoaded(false);
|
||||
m_rawTripletAddressSpinBox->setEnabled(false);
|
||||
m_rawTripletDataSpinBox->setEnabled(false);
|
||||
m_rawTripletModeSpinBox->setEnabled(false);
|
||||
}
|
||||
|
||||
void X26DockWidget::rowClicked(const QModelIndex &index)
|
||||
{
|
||||
updateRawTripletWidgets(index);
|
||||
}
|
||||
|
||||
void X26DockWidget::updateRawTripletWidgets(const QModelIndex &index)
|
||||
{
|
||||
m_rawTripletAddressSpinBox->setEnabled(true);
|
||||
m_rawTripletDataSpinBox->setEnabled(true);
|
||||
m_rawTripletModeSpinBox->setEnabled(true);
|
||||
m_rawTripletAddressSpinBox->blockSignals(true);
|
||||
m_rawTripletModeSpinBox->blockSignals(true);
|
||||
m_rawTripletDataSpinBox->blockSignals(true);
|
||||
m_rawTripletAddressSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole).toInt());
|
||||
m_rawTripletModeSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 1), Qt::UserRole).toInt());
|
||||
m_rawTripletDataSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 2), Qt::UserRole).toInt());
|
||||
m_rawTripletAddressSpinBox->blockSignals(false);
|
||||
m_rawTripletModeSpinBox->blockSignals(false);
|
||||
m_rawTripletDataSpinBox->blockSignals(false);
|
||||
}
|
||||
void X26DockWidget::rawTripletAddressSpinBoxChanged(int newValue)
|
||||
{
|
||||
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 0), newValue, Qt::UserRole);
|
||||
}
|
||||
|
||||
void X26DockWidget::rawTripletModeSpinBoxChanged(int newValue)
|
||||
{
|
||||
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 1), newValue, Qt::UserRole);
|
||||
}
|
||||
|
||||
void X26DockWidget::rawTripletDataSpinBoxChanged(int newValue)
|
||||
{
|
||||
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 2), newValue, Qt::UserRole);
|
||||
}
|
||||
|
||||
void X26DockWidget::tripletDataChanged(int newValue, int bitMask, int bitShift)
|
||||
{
|
||||
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 2), (m_x26Model->data(m_x26Model->index(m_x26View->currentIndex().row(), 2), Qt::UserRole).toInt() & bitMask) | (newValue << bitShift), Qt::UserRole);
|
||||
updateRawTripletWidgets(m_x26View->currentIndex());
|
||||
}
|
||||
void X26DockWidget::insertTriplet()
|
||||
{
|
||||
QModelIndex index = m_x26View->currentIndex();
|
||||
|
||||
if (index.isValid())
|
||||
m_x26Model->insertRow(index.row(), QModelIndex());
|
||||
else
|
||||
m_x26Model->insertFirstRow();
|
||||
}
|
||||
|
||||
void X26DockWidget::deleteTriplet()
|
||||
{
|
||||
QModelIndex index = m_x26View->currentIndex();
|
||||
if (index.isValid())
|
||||
m_x26Model->removeRow(index.row(), index.parent());
|
||||
}
|
||||
|
||||
void X26DockWidget::customMenuRequested(QPoint pos)
|
||||
{
|
||||
QModelIndex index = m_x26View->indexAt(pos);
|
||||
|
||||
QMenu *menu = new QMenu(this);
|
||||
|
||||
QAction *insertAct = new QAction("Insert triplet", this);
|
||||
menu->addAction(insertAct);
|
||||
connect(insertAct, &QAction::triggered, this, &X26DockWidget::insertTriplet);
|
||||
if (index.isValid()) {
|
||||
QAction *deleteAct = new QAction("Delete triplet", this);
|
||||
menu->addAction(deleteAct);
|
||||
connect(deleteAct, &QAction::triggered, this, &X26DockWidget::deleteTriplet);
|
||||
}
|
||||
menu->popup(m_x26View->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
65
x26dockwidget.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef X26DOCKWIDGET_H
|
||||
#define X26DOCKWIDGET_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDockWidget>
|
||||
#include <QGroupBox>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QSpinBox>
|
||||
#include <QTableView>
|
||||
|
||||
#include "mainwidget.h"
|
||||
#include "x26model.h"
|
||||
|
||||
class X26DockWidget : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
X26DockWidget(TeletextWidget *parent);
|
||||
|
||||
public slots:
|
||||
void insertTriplet();
|
||||
void deleteTriplet();
|
||||
void customMenuRequested(QPoint pos);
|
||||
void loadX26List();
|
||||
void unloadX26List();
|
||||
void rowClicked(const QModelIndex &);
|
||||
void updateRawTripletWidgets(const QModelIndex &);
|
||||
void rawTripletAddressSpinBoxChanged(int);
|
||||
void rawTripletModeSpinBoxChanged(int);
|
||||
void rawTripletDataSpinBoxChanged(int);
|
||||
void tripletDataChanged(int, int=0, int=0);
|
||||
|
||||
private:
|
||||
QTableView *m_x26View;
|
||||
X26Model *m_x26Model;
|
||||
// "Temporary" widgets to edit raw triplet values
|
||||
QSpinBox *m_rawTripletAddressSpinBox, *m_rawTripletModeSpinBox, *m_rawTripletDataSpinBox;
|
||||
QPushButton *m_insertPushButton, *m_deletePushButton;
|
||||
|
||||
TeletextWidget *m_parentMainWidget;
|
||||
};
|
||||
|
||||
#endif
|
||||
614
x26model.cpp
Normal file
@@ -0,0 +1,614 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QList>
|
||||
|
||||
#include "x26model.h"
|
||||
|
||||
X26Model::X26Model(TeletextWidget *parent): QAbstractListModel(parent)
|
||||
{
|
||||
m_parentMainWidget = parent;
|
||||
m_listLoaded = true;
|
||||
}
|
||||
|
||||
void X26Model::setX26ListLoaded(bool newListLoaded)
|
||||
{
|
||||
beginResetModel();
|
||||
m_listLoaded = newListLoaded;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
int X26Model::rowCount(const QModelIndex & /*parent*/) const
|
||||
{
|
||||
return m_listLoaded ? m_parentMainWidget->document()->currentSubPage()->localEnhance.size() : 0;
|
||||
}
|
||||
|
||||
int X26Model::columnCount(const QModelIndex & /*parent*/) const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
QVariant X26Model::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
int mode = m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).mode();
|
||||
|
||||
// Qt::UserRole will always return the raw values
|
||||
if (role == Qt::UserRole)
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address();
|
||||
case 1:
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).mode();
|
||||
case 2:
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
// Show row number only if address part of triplet actually represents a row
|
||||
// i.e. Full row colour, Set Active Position and Origin Modifier
|
||||
if (!m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
|
||||
return "";
|
||||
// For Origin Modifier address of 40 refers to same row, so show it as 0
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).mode() == 0x10) {
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() == 40)
|
||||
return 0;
|
||||
else
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).addressRow();
|
||||
}
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).mode() == 0x01 || m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).mode() == 0x04)
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).addressRow();
|
||||
else
|
||||
return "";
|
||||
case 1:
|
||||
if (!m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).addressColumn();
|
||||
// For Set Active Position and Origin Modifier, data is the column
|
||||
else if (mode == 0x04 || mode == 0x10)
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
QString result;
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
switch (index.column()) {
|
||||
case 2:
|
||||
if (!m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
|
||||
mode |= 0x20;
|
||||
return (modeTripletName[mode]);
|
||||
case 3:
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
|
||||
// Row address group
|
||||
switch (mode) {
|
||||
case 0x01: // Full row colour
|
||||
case 0x07: // Address row 0
|
||||
if ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60) == 0x60)
|
||||
result = ", down to bottom";
|
||||
else if ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60) == 0x00)
|
||||
result = ", this row only";
|
||||
// fall-through
|
||||
case 0x00: // Full screen colour
|
||||
if (!(result.isEmpty()) || (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60) == 0x00) {
|
||||
result.prepend(QString("CLUT %1:%2").arg((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x18) >> 3).arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x07));
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
case 0x04: // Set Active Position
|
||||
case 0x10: // Origin Modifier
|
||||
// For Set Active Position and Origin Modifier, data is the column, so return blank
|
||||
return "";
|
||||
case 0x11 ... 0x13: // Invoke object
|
||||
switch (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x18) {
|
||||
case 0x08:
|
||||
return QString("Local: d%1 t%2").arg((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >> 4) | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x01) << 3)).arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x0f);
|
||||
case 0x10:
|
||||
result = "POP";
|
||||
break;
|
||||
case 0x18:
|
||||
result = "GPOP";
|
||||
break;
|
||||
// case 0x00: won't happen since that would make a column triplet, not a row triplet
|
||||
}
|
||||
result.append(QString(": subpage %1 pkt %2 trplt %3 bits ").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x0f).arg((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x03) + 1).arg(((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60) >> 5) * 3 + (mode & 0x03)));
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x10)
|
||||
result.append("10-18");
|
||||
else
|
||||
result.append("1-9");
|
||||
return result;
|
||||
case 0x15 ... 0x17: // Define object
|
||||
result = (QString("Local: d%1 t%2, ").arg((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >> 4) | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 1) << 3)).arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x0f));
|
||||
switch (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x18) {
|
||||
case 0x08:
|
||||
result.append("L2.5 only");
|
||||
break;
|
||||
case 0x10:
|
||||
result.append("L3.5 only");
|
||||
break;
|
||||
case 0x18:
|
||||
result.append("L2.5 and 3.5");
|
||||
break;
|
||||
// case 0x00: won't happen since that would make a column triplet, not a row triplet
|
||||
}
|
||||
return result;
|
||||
case 0x18: // DRCS mode
|
||||
result = (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x40) == 0x40 ? "Normal" : "Global";
|
||||
result.append(QString(": subpage %1, ").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x0f));
|
||||
switch (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x30) {
|
||||
case 0x10:
|
||||
result.append("L2.5 only");
|
||||
break;
|
||||
case 0x20:
|
||||
result.append("L3.5 only");
|
||||
break;
|
||||
case 0x30:
|
||||
result.append("L2.5 and 3.5");
|
||||
break;
|
||||
//case 0x00:
|
||||
// result = "Reserved";
|
||||
// break;
|
||||
}
|
||||
return result;
|
||||
case 0x1f: // Termination
|
||||
switch (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x07) {
|
||||
case 0x00:
|
||||
return "Intermed (G)POP subpage. End of object, more follows";
|
||||
break;
|
||||
case 0x01:
|
||||
return "Intermed (G)POP subpage. End of last object on page";
|
||||
break;
|
||||
case 0x02:
|
||||
return "Last (G)POP subpage. End of object, more follows";
|
||||
break;
|
||||
case 0x03:
|
||||
return "Last (G)POP subpage. End of last object on page";
|
||||
break;
|
||||
case 0x04:
|
||||
return "Local object definitions. End of object, more follows";
|
||||
break;
|
||||
case 0x05:
|
||||
return "Local object definitions. End of last object on page";
|
||||
break;
|
||||
case 0x06:
|
||||
return "End of local enhance data. Local objects follow";
|
||||
break;
|
||||
case 0x07:
|
||||
return "End of local enhance data. No local objects";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x08 ... 0x0d: // PDC
|
||||
return QString("0x%1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data(), 2, 16, QChar('0'));
|
||||
}
|
||||
else
|
||||
// Column address group
|
||||
switch (mode) {
|
||||
case 0x00: // Foreground colour
|
||||
case 0x03: // Background colour
|
||||
if (!(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60))
|
||||
return QString("CLUT %1:%2").arg((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x18) >> 3).arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x07);
|
||||
break;
|
||||
case 0x01: // G1 mosaic character
|
||||
case 0x02: // G3 mosaic character at level 1.5
|
||||
case 0x09: // G0 character
|
||||
case 0x0b: // G3 mosaic character at level >=2.5
|
||||
case 0x0f ... 0x1f: // G2 character or G0 diacrtitical mark
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >= 0x20)
|
||||
return QString("0x%1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data(), 2, 16);
|
||||
break;
|
||||
case 0x07: // Flash functions
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() < 0x18) {
|
||||
switch (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x03) {
|
||||
case 0x00:
|
||||
result = "Steady";
|
||||
break;
|
||||
case 0x01:
|
||||
result = "Normal";
|
||||
break;
|
||||
case 0x02:
|
||||
result = "Invert";
|
||||
break;
|
||||
case 0x03:
|
||||
result = "Adj CLUT";
|
||||
break;
|
||||
}
|
||||
switch (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x1c) {
|
||||
case 0x00:
|
||||
result.append(", 1Hz");
|
||||
break;
|
||||
case 0x04:
|
||||
result.append(", 2Hz ph 1");
|
||||
break;
|
||||
case 0x08:
|
||||
result.append(", 2Hz ph 2");
|
||||
break;
|
||||
case 0x0c:
|
||||
result.append(", 2Hz ph 3");
|
||||
break;
|
||||
case 0x10:
|
||||
result.append(", 2Hz inc");
|
||||
break;
|
||||
case 0x14:
|
||||
result.append(", 2Hz dec");
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
//TODO case 0x08: // G0 and G2 designation
|
||||
case 0x0c: // Display attributes
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x02)
|
||||
result.append("Boxing ");
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x04)
|
||||
result.append("Conceal ");
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x10)
|
||||
result.append("Invert ");
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x20)
|
||||
result.append("Underline ");
|
||||
if (result.isEmpty())
|
||||
result = "None";
|
||||
else
|
||||
// Chop off the last space
|
||||
result.chop(1);
|
||||
switch (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x41) {
|
||||
case 0x00:
|
||||
result.append(", normal size");
|
||||
break;
|
||||
case 0x01:
|
||||
result.append(", double height");
|
||||
break;
|
||||
case 0x40:
|
||||
result.append(", double width");
|
||||
break;
|
||||
case 0x41:
|
||||
result.append(", double size");
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
case 0x0d: // DRCS character
|
||||
result = (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x40) == 0x40 ? "Normal" : "Global";
|
||||
result.append(QString(": %1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x3f));
|
||||
return result;
|
||||
case 0x0e: // Font style
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x01)
|
||||
result.append("Proportional ");
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x02)
|
||||
result.append("Bold ");
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x04)
|
||||
result.append("Italic ");
|
||||
if (result.isEmpty())
|
||||
result = "None";
|
||||
else
|
||||
// Chop off the last space
|
||||
result.chop(1);
|
||||
result.append(QString(", %1 row(s)").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >> 4));
|
||||
return result;
|
||||
case 0x06: // PDC
|
||||
return QString("0x%1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data(), 2, 16, QChar('0'));
|
||||
default: // Reserved
|
||||
return QString("Reserved 0x%1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data(), 2, 16, QChar('0'));
|
||||
}
|
||||
// Reserved mode or data
|
||||
return QString("Reserved 0x%1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data(), 2, 16, QChar('0'));
|
||||
}
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
switch (index.column()) {
|
||||
case 2:
|
||||
if (!m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
|
||||
mode |= 0x20;
|
||||
return mode;
|
||||
case 3:
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
|
||||
// Row address group
|
||||
switch (mode) {
|
||||
case 0x00: // Full screen colour
|
||||
case 0x01: // Full row colour
|
||||
case 0x07: // Address row 0
|
||||
// Colour index
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x1f;
|
||||
case 0x11 ... 0x13: // Invoke object
|
||||
// Local, POP or GPOP
|
||||
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x18) >> 3) - 1;
|
||||
case 0x15 ... 0x17: // Define object
|
||||
// Required at level 2.5 and/or 3.5
|
||||
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x18) >> 3) - 1;
|
||||
case 0x1f: // Termination
|
||||
// Intermed POP subpage|Last POP subpage|Local Object|Local enhance
|
||||
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x06) >> 1);
|
||||
default:
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data();
|
||||
}
|
||||
else
|
||||
// Column address group
|
||||
switch (mode) {
|
||||
case 0x00: // Foreground colour
|
||||
case 0x03: // Background colour
|
||||
// Colour index
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x1f;
|
||||
case 0x07: // Flash functions
|
||||
// Flash mode
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x03;
|
||||
case 0x0c: // Display attributes
|
||||
// underline/separated, invert, conceal, boxing/window
|
||||
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x06) >> 1) | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x30) >> 2);
|
||||
case 0x0e: // Font style
|
||||
// Proportional, Bold, Italics
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x07;
|
||||
default:
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data();
|
||||
}
|
||||
case 4:
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
|
||||
// Row address group
|
||||
switch (mode) {
|
||||
case 0x01: // Full row colour
|
||||
case 0x07: // Address row 0
|
||||
// "this row only" or "down to bottom"
|
||||
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60) == 0x60) ? 1 : 0;
|
||||
case 0x11 ... 0x13: // Invoke object
|
||||
// Object source
|
||||
//TODO POP and GPOP, if ((x26Triplet.address() & 0x08) == 0x08)
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 1) << 7);
|
||||
case 0x1f: // Termination
|
||||
// More follows/Last
|
||||
// return entire value as dropdown text changes depending on setting
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x07;
|
||||
}
|
||||
else
|
||||
// Column address group
|
||||
switch (mode) {
|
||||
case 0x07: // Flash functions
|
||||
// Flash rate and phase
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >> 2;
|
||||
case 0x0c: // Display attributes
|
||||
// Text size
|
||||
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x01) | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x40) >> 5);
|
||||
case 0x0e: // Font style
|
||||
// Number of rows
|
||||
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >> 4;
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return false;
|
||||
|
||||
int mode = m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).mode();
|
||||
|
||||
if (role == Qt::UserRole && value.canConvert<int>() && index.column() <= 2) {
|
||||
int intValue = value.toInt();
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress(intValue);
|
||||
break;
|
||||
case 1:
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setMode(intValue);
|
||||
break;
|
||||
case 2:
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue);
|
||||
break;
|
||||
}
|
||||
emit dataChanged(createIndex(index.row(), 0), createIndex(index.row(), 4), {role});
|
||||
m_parentMainWidget->refreshPage();
|
||||
return true;
|
||||
}
|
||||
if (role == Qt::EditRole && value.canConvert<int>()) {
|
||||
int intValue = value.toInt();
|
||||
if (intValue < 0)
|
||||
return false;
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
if (intValue > 24)
|
||||
return false;
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddressRow(intValue);
|
||||
break;
|
||||
case 1:
|
||||
if (intValue > 39)
|
||||
return false;
|
||||
// For Set Active Position and Origin Modifier, data is the column
|
||||
if (mode == 0x04 || mode == 0x10)
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue);
|
||||
else
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddressColumn(intValue);
|
||||
break;
|
||||
case 2:
|
||||
if (intValue < 0x20 && !m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet()) {
|
||||
// Changing mode from column triplet to row triplet
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddressRow(1);
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(0);
|
||||
}
|
||||
if (intValue >= 0x20 && m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet()) {
|
||||
// Changing mode from row triplet to column triplet
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddressColumn(0);
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(0);
|
||||
}
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setMode(intValue & 0x1f);
|
||||
break;
|
||||
case 3:
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
|
||||
// Row address group
|
||||
switch (mode) {
|
||||
case 0x00: // Full screen colour
|
||||
case 0x01: // Full row colour
|
||||
case 0x07: // Address row 0
|
||||
// Colour index
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60) | intValue);
|
||||
break;
|
||||
case 0x04: // Set Active Position
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue);
|
||||
break;
|
||||
case 0x11 ... 0x13: // Invoke object
|
||||
// Local, POP or GPOP
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x67) | ((intValue+1) << 3));
|
||||
break;
|
||||
case 0x15 ... 0x17: // Define object
|
||||
// required at level 2.5 and/or 3.5
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x67) | ((intValue+1) << 3));
|
||||
break;
|
||||
case 0x1f: // Termination
|
||||
// Intermed POP subpage|Last POP subpage|Local Object|Local enhance
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x01) | (intValue << 1));
|
||||
break;
|
||||
}
|
||||
else
|
||||
// Column address group
|
||||
switch (mode) {
|
||||
case 0x07: // Flash functions
|
||||
// Flash mode
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x1c) | intValue);
|
||||
break;
|
||||
case 0x0c: // Display attributes
|
||||
// underline/separated, invert, conceal, boxing/window
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x41) | ((intValue & 0x0c) << 2) | ((intValue & 0x03) << 1));
|
||||
break;
|
||||
case 0x0e: // Font style
|
||||
// Proportional, Bold, Italics
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x70) | intValue);
|
||||
break;
|
||||
default:
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
|
||||
// Row address group
|
||||
switch (mode) {
|
||||
case 0x00: // Full screen colour
|
||||
case 0x01: // Full row colour
|
||||
case 0x07: // Address row 0
|
||||
// "this row only" or "down to bottom"
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x1f) | (intValue * 0x60));
|
||||
break;
|
||||
case 0x11 ... 0x13: // Invoke object
|
||||
// Object source
|
||||
//TODO POP and GPOP, if ((x26Triplet.address() & 0x08) == 0x08)
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue & 0x7f);
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x3e) | (intValue >> 7));
|
||||
break;
|
||||
case 0x1f: // Termination
|
||||
// More follows/Last
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x06) | intValue);
|
||||
break;
|
||||
}
|
||||
else
|
||||
// Column address group
|
||||
switch (mode) {
|
||||
case 0x07: // Flash functions
|
||||
// Flash rate and phase
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x03) | (intValue << 2));
|
||||
break;
|
||||
case 0x0c: // Display attributes
|
||||
// Text size
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x36) | ((intValue & 0x02) << 5) | (intValue & 0x01));
|
||||
break;
|
||||
case 0x0e: // Font style
|
||||
// Number of rows
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x07) | (intValue << 4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
emit dataChanged(index, index, {role});
|
||||
m_parentMainWidget->refreshPage();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant X26Model::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (orientation == Qt::Horizontal) {
|
||||
switch (section) {
|
||||
case 0:
|
||||
return tr("Row");
|
||||
case 1:
|
||||
return tr("Col");
|
||||
case 2:
|
||||
return tr("Mode");
|
||||
case 3:
|
||||
return tr("Data");
|
||||
default:
|
||||
return QString("");
|
||||
}
|
||||
} else if (orientation == Qt::Vertical)
|
||||
return QString("d%1 t%2").arg(section / 13).arg(section % 13);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool X26Model::insertFirstRow()
|
||||
{
|
||||
X26Triplet firstTriplet;
|
||||
|
||||
firstTriplet.setAddress(63);
|
||||
firstTriplet.setMode(31);
|
||||
firstTriplet.setData(7);
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, 0);
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance.insert(0, firstTriplet);
|
||||
endInsertRows();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool X26Model::insertRows(int position, int rows, const QModelIndex &parent)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
X26Triplet copyTriplet = m_parentMainWidget->document()->currentSubPage()->localEnhance.at(position);
|
||||
|
||||
beginInsertRows(QModelIndex(), position, position+rows-1);
|
||||
for (int row=0; row<rows; ++row)
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance.insert(position+row, copyTriplet);
|
||||
endInsertRows();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool X26Model::removeRows(int position, int rows, const QModelIndex &index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
beginRemoveRows(QModelIndex(), position, position+rows-1);
|
||||
|
||||
for (int row=0; row<rows; ++row)
|
||||
m_parentMainWidget->document()->currentSubPage()->localEnhance.removeAt(position+row);
|
||||
|
||||
endRemoveRows();
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
Qt::ItemFlags X26Model::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QAbstractItemModel::flags(index);
|
||||
|
||||
if (index.column() <= 1)
|
||||
return QAbstractItemModel::flags(index);
|
||||
if (index.column() >= 2)
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
*/
|
||||
129
x26model.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef X26MODEL_H
|
||||
#define X26MODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include "mainwidget.h"
|
||||
|
||||
class X26Model : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
X26Model(TeletextWidget *parent);
|
||||
void setX26ListLoaded(bool);
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override ;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
bool insertFirstRow();
|
||||
bool insertRows(int position, int rows, const QModelIndex &parent);
|
||||
bool removeRows(int position, int rows, const QModelIndex &index);
|
||||
// Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
private:
|
||||
TeletextWidget *m_parentMainWidget;
|
||||
bool m_listLoaded;
|
||||
};
|
||||
|
||||
static const QString modeTripletName[64] {
|
||||
// Row triplet modes
|
||||
"Full screen colour",
|
||||
"Full row colour",
|
||||
"Reserved 0x02",
|
||||
"Reserved 0x03",
|
||||
|
||||
"Set Active Position",
|
||||
"Reserved 0x05",
|
||||
"Reserved 0x06",
|
||||
"Address row 0",
|
||||
|
||||
"PDC origin, source",
|
||||
"PDC month and day",
|
||||
"PDC cursor and start hour",
|
||||
"PDC cursor and end hour",
|
||||
|
||||
"PDC cursor local offset",
|
||||
"PDC series ID and code",
|
||||
"Reserved 0x0e",
|
||||
"Reserved 0x0f",
|
||||
|
||||
"Origin modifier",
|
||||
"Invoke active object",
|
||||
"Invoke adaptive object",
|
||||
"Invoke passive object",
|
||||
|
||||
"Reserved 0x14",
|
||||
"Define active object",
|
||||
"Define adaptive object",
|
||||
"Define passive object",
|
||||
|
||||
"DRCS mode",
|
||||
"Reserved 0x19",
|
||||
"Reserved 0x1a",
|
||||
"Reserved 0x1b",
|
||||
|
||||
"Reserved 0x1c",
|
||||
"Reserved 0x1d",
|
||||
"Reserved 0x1e",
|
||||
"Termination marker",
|
||||
|
||||
// Column triplet modes
|
||||
"Foreground colour",
|
||||
"G1 character",
|
||||
"G3 character, level 1.5",
|
||||
"Background colour",
|
||||
|
||||
"Reserved 0x04",
|
||||
"Reserved 0x05",
|
||||
"PDC cursor, start end min",
|
||||
"Additional flash functions",
|
||||
|
||||
"Modified G0/G2 character set",
|
||||
"G0 character",
|
||||
"Reserved 0x0a",
|
||||
"G3 character, level 2.5",
|
||||
|
||||
"Display attributes",
|
||||
"DRCS character",
|
||||
"Font style",
|
||||
"G2 character",
|
||||
|
||||
"G0 character no diacritical",
|
||||
"G0 character diacritical 1",
|
||||
"G0 character diacritical 2",
|
||||
"G0 character diacritical 3",
|
||||
"G0 character diacritical 4",
|
||||
"G0 character diacritical 5",
|
||||
"G0 character diacritical 6",
|
||||
"G0 character diacritical 7",
|
||||
"G0 character diacritical 8",
|
||||
"G0 character diacritical 9",
|
||||
"G0 character diacritical A",
|
||||
"G0 character diacritical B",
|
||||
"G0 character diacritical C",
|
||||
"G0 character diacritical D",
|
||||
"G0 character diacritical E",
|
||||
"G0 character diacritical F"
|
||||
};
|
||||
|
||||
#endif
|
||||
26
x26triplets.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "x26triplets.h"
|
||||
|
||||
void X26Triplet::setAddress(int newAddress) { myTriplet.m_address = newAddress; }
|
||||
void X26Triplet::setMode(int newMode) { myTriplet.m_mode = newMode; }
|
||||
void X26Triplet::setData(int newData) { myTriplet.m_data = newData; }
|
||||
void X26Triplet::setAddressRow(int newAddressRow) { myTriplet.m_address = (newAddressRow == 24) ? 40 : newAddressRow+40; }
|
||||
void X26Triplet::setAddressColumn(int newAddressColumn) { myTriplet.m_address = newAddressColumn; }
|
||||
52
x26triplets.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef X26TRIPLETS_H
|
||||
#define X26TRIPLETS_H
|
||||
|
||||
class X26Triplet
|
||||
{
|
||||
public:
|
||||
// X26Triplet() {}
|
||||
// X26Triplet(const X26Triplet &other);
|
||||
|
||||
// X26Triplet &operator=(const X26Triplet &other);
|
||||
|
||||
int address() const { return myTriplet.m_address; }
|
||||
int mode() const { return myTriplet.m_mode; }
|
||||
int data() const { return myTriplet.m_data; }
|
||||
int addressRow() const { return (myTriplet.m_address == 40) ? 24 : myTriplet.m_address-40; }
|
||||
int addressColumn() const { return (myTriplet.m_address); }
|
||||
bool isRowTriplet() const { return (myTriplet.m_address >= 40); }
|
||||
|
||||
void setAddress(int);
|
||||
void setMode(int);
|
||||
void setData(int);
|
||||
void setAddressRow(int);
|
||||
void setAddressColumn(int);
|
||||
|
||||
private:
|
||||
struct x26TripletStruct {
|
||||
int m_address;
|
||||
int m_mode;
|
||||
int m_data;
|
||||
} myTriplet;
|
||||
};
|
||||
|
||||
#endif
|
||||
142
x28dockwidget.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QSpinBox>
|
||||
|
||||
#include "x28dockwidget.h"
|
||||
|
||||
X28DockWidget::X28DockWidget(TeletextWidget *parent): QDockWidget(parent)
|
||||
{
|
||||
QGridLayout *x28Layout = new QGridLayout;
|
||||
QWidget *x28Widget = new QWidget;
|
||||
|
||||
m_parentMainWidget = parent;
|
||||
|
||||
this->setObjectName("X28DockWidget");
|
||||
this->setWindowTitle("X/28 enhancements");
|
||||
x28Layout->addWidget(new QLabel(tr("Default screen colour")), 0, 0, 1, 1);
|
||||
x28Layout->addWidget(new QLabel(tr("Default row colour")), 1, 0, 1, 1);
|
||||
m_defaultScreenColourCombo = new QComboBox;
|
||||
m_defaultRowColourCombo = new QComboBox;
|
||||
for (int r=0; r<=3; r++)
|
||||
for (int c=0; c<=7; c++) {
|
||||
m_defaultScreenColourCombo->addItem(tr("CLUT %1:%2").arg(r).arg(c));
|
||||
m_defaultRowColourCombo->addItem(tr("CLUT %1:%2").arg(r).arg(c));
|
||||
}
|
||||
x28Layout->addWidget(m_defaultScreenColourCombo, 0, 1, 1, 1, Qt::AlignTop);
|
||||
connect(m_defaultScreenColourCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index){ m_parentMainWidget->setDefaultScreenColour(index); });
|
||||
x28Layout->addWidget(m_defaultRowColourCombo, 1, 1, 1, 1, Qt::AlignTop);
|
||||
connect(m_defaultRowColourCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index){ m_parentMainWidget->setDefaultRowColour(index); });
|
||||
x28Layout->addWidget(new QLabel(tr("Colour remapping")), 2, 0, 1, 1);
|
||||
m_colourTableCombo = new QComboBox;
|
||||
m_colourTableCombo->addItem("Fore 0 Back 0");
|
||||
m_colourTableCombo->addItem("Fore 0 Back 1");
|
||||
m_colourTableCombo->addItem("Fore 0 Back 2");
|
||||
m_colourTableCombo->addItem("Fore 1 Back 1");
|
||||
m_colourTableCombo->addItem("Fore 1 Back 2");
|
||||
m_colourTableCombo->addItem("Fore 2 Back 1");
|
||||
m_colourTableCombo->addItem("Fore 2 Back 2");
|
||||
m_colourTableCombo->addItem("Fore 2 Back 3");
|
||||
x28Layout->addWidget(m_colourTableCombo, 2, 1, 1, 1, Qt::AlignTop);
|
||||
connect(m_colourTableCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index){ m_parentMainWidget->setColourTableRemap(index); });
|
||||
m_blackBackgroundSubstAct = new QCheckBox("Black background colour substitution");
|
||||
x28Layout->addWidget(m_blackBackgroundSubstAct, 3, 0, 1, 2, Qt::AlignTop);
|
||||
connect(m_blackBackgroundSubstAct, &QCheckBox::stateChanged, m_parentMainWidget, &TeletextWidget::setBlackBackgroundSubst);
|
||||
|
||||
x28Layout->addWidget(new QLabel(tr("Left side panel columns")), 4, 0, 1, 1);
|
||||
m_leftSidePanelSpinBox = new QSpinBox(this);
|
||||
m_leftSidePanelSpinBox->setMaximum(16);
|
||||
x28Layout->addWidget(m_leftSidePanelSpinBox, 4, 1, 1, 1, Qt::AlignTop);
|
||||
connect(m_leftSidePanelSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), [=](int index){ setLeftSidePanelWidth(index); });
|
||||
|
||||
x28Layout->addWidget(new QLabel(tr("Right side panel columns")), 5, 0, 1, 1);
|
||||
m_rightSidePanelSpinBox = new QSpinBox(this);
|
||||
m_rightSidePanelSpinBox->setMaximum(16);
|
||||
x28Layout->addWidget(m_rightSidePanelSpinBox, 5, 1, 1, 1, Qt::AlignTop);
|
||||
connect(m_rightSidePanelSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), [=](int index){ setRightSidePanelWidth(index); });
|
||||
|
||||
m_sidePanelStatusAct = new QCheckBox("Side panels at level 3.5 only");
|
||||
x28Layout->addWidget(m_sidePanelStatusAct, 6, 0, 1, 2, Qt::AlignTop);
|
||||
connect(m_sidePanelStatusAct, &QCheckBox::stateChanged, m_parentMainWidget, &TeletextWidget::setSidePanelAtL35Only);
|
||||
|
||||
x28Layout->setRowStretch(6, 1);
|
||||
x28Widget->setLayout(x28Layout);
|
||||
this->setWidget(x28Widget);
|
||||
}
|
||||
|
||||
void X28DockWidget::setLeftSidePanelWidth(int newLeftPanelSize)
|
||||
{
|
||||
if (newLeftPanelSize && m_rightSidePanelSpinBox->value()) {
|
||||
int newRightPanelSize = 16-newLeftPanelSize;
|
||||
m_rightSidePanelSpinBox->blockSignals(true);
|
||||
m_rightSidePanelSpinBox->setValue(newRightPanelSize);
|
||||
m_rightSidePanelSpinBox->blockSignals(false);
|
||||
}
|
||||
m_parentMainWidget->setSidePanelWidths(newLeftPanelSize, m_rightSidePanelSpinBox->value());
|
||||
}
|
||||
|
||||
void X28DockWidget::setRightSidePanelWidth(int newRightPanelSize)
|
||||
{
|
||||
if (newRightPanelSize && m_leftSidePanelSpinBox->value()) {
|
||||
int newLeftPanelSize = 16-newRightPanelSize;
|
||||
m_leftSidePanelSpinBox->blockSignals(true);
|
||||
m_leftSidePanelSpinBox->setValue(newLeftPanelSize);
|
||||
m_leftSidePanelSpinBox->blockSignals(false);
|
||||
}
|
||||
m_parentMainWidget->setSidePanelWidths(m_leftSidePanelSpinBox->value(), newRightPanelSize);
|
||||
}
|
||||
|
||||
void X28DockWidget::updateWidgets()
|
||||
{
|
||||
int leftSidePanelColumnsResult = 0;
|
||||
int rightSidePanelColumnsResult = 0;
|
||||
|
||||
m_defaultScreenColourCombo->blockSignals(true);
|
||||
m_defaultScreenColourCombo->setCurrentIndex(m_parentMainWidget->document()->currentSubPage()->defaultScreenColour());
|
||||
m_defaultScreenColourCombo->blockSignals(false);
|
||||
m_defaultRowColourCombo->blockSignals(true);
|
||||
m_defaultRowColourCombo->setCurrentIndex(m_parentMainWidget->document()->currentSubPage()->defaultRowColour());
|
||||
m_defaultRowColourCombo->blockSignals(false);
|
||||
m_colourTableCombo->blockSignals(true);
|
||||
m_colourTableCombo->setCurrentIndex(m_parentMainWidget->document()->currentSubPage()->colourTableRemap());
|
||||
m_colourTableCombo->blockSignals(false);
|
||||
m_blackBackgroundSubstAct->blockSignals(true);
|
||||
m_blackBackgroundSubstAct->setChecked(m_parentMainWidget->document()->currentSubPage()->blackBackgroundSubst());
|
||||
m_blackBackgroundSubstAct->blockSignals(false);
|
||||
|
||||
if (m_parentMainWidget->document()->currentSubPage()->leftSidePanelDisplayed())
|
||||
leftSidePanelColumnsResult = (m_parentMainWidget->document()->currentSubPage()->sidePanelColumns() == 0) ? 16 : m_parentMainWidget->document()->currentSubPage()->sidePanelColumns();
|
||||
|
||||
if (m_parentMainWidget->document()->currentSubPage()->rightSidePanelDisplayed())
|
||||
rightSidePanelColumnsResult = 16-m_parentMainWidget->document()->currentSubPage()->sidePanelColumns();
|
||||
|
||||
m_leftSidePanelSpinBox->blockSignals(true);
|
||||
m_leftSidePanelSpinBox->setValue(leftSidePanelColumnsResult);
|
||||
m_leftSidePanelSpinBox->blockSignals(false);
|
||||
m_rightSidePanelSpinBox->blockSignals(true);
|
||||
m_rightSidePanelSpinBox->setValue(rightSidePanelColumnsResult);
|
||||
m_rightSidePanelSpinBox->blockSignals(false);
|
||||
m_sidePanelStatusAct->blockSignals(true);
|
||||
m_sidePanelStatusAct->setChecked(!m_parentMainWidget->document()->currentSubPage()->sidePanelStatusL25());
|
||||
m_sidePanelStatusAct->blockSignals(false);
|
||||
}
|
||||
48
x28dockwidget.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Gavin MacGregor
|
||||
*
|
||||
* This file is part of QTeletextMaker.
|
||||
*
|
||||
* QTeletextMaker 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.
|
||||
*
|
||||
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef X28DOCKWIDGET_H
|
||||
#define X28DOCKWIDGET_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDockWidget>
|
||||
#include <QSpinBox>
|
||||
|
||||
#include "mainwidget.h"
|
||||
|
||||
class X28DockWidget : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
X28DockWidget(TeletextWidget *parent);
|
||||
void updateWidgets();
|
||||
|
||||
private:
|
||||
void setLeftSidePanelWidth(int);
|
||||
void setRightSidePanelWidth(int);
|
||||
|
||||
TeletextWidget *m_parentMainWidget;
|
||||
QComboBox *m_defaultScreenColourCombo, *m_defaultRowColourCombo, *m_colourTableCombo;
|
||||
QCheckBox *m_blackBackgroundSubstAct, *m_sidePanelStatusAct;
|
||||
QSpinBox *m_leftSidePanelSpinBox, *m_rightSidePanelSpinBox;
|
||||
};
|
||||
|
||||
#endif
|
||||