first re-commit.
44
.gitignore
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# qt specific
|
||||
build*
|
||||
doc/
|
||||
|
||||
moc_*
|
||||
*.autosave
|
||||
raDIYo.pro.user
|
||||
*.pro.user.*
|
||||
*.pro.user
|
||||
*.user
|
||||
ui_*
|
23
.qmake.stash
Normal file
@@ -0,0 +1,23 @@
|
||||
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
|
||||
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 10
|
||||
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 2
|
||||
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 1
|
||||
QMAKE_CXX.COMPILER_MACROS = \
|
||||
QT_COMPILER_STDCXX \
|
||||
QMAKE_GCC_MAJOR_VERSION \
|
||||
QMAKE_GCC_MINOR_VERSION \
|
||||
QMAKE_GCC_PATCH_VERSION
|
||||
QMAKE_CXX.INCDIRS = \
|
||||
/usr/include/c++/10 \
|
||||
/usr/include/arm-linux-gnueabihf/c++/10 \
|
||||
/usr/include/c++/10/backward \
|
||||
/usr/lib/gcc/arm-linux-gnueabihf/10/include \
|
||||
/usr/local/include \
|
||||
/usr/include/arm-linux-gnueabihf \
|
||||
/usr/include
|
||||
QMAKE_CXX.LIBDIRS = \
|
||||
/usr/lib/gcc/arm-linux-gnueabihf/10 \
|
||||
/usr/lib/arm-linux-gnueabihf \
|
||||
/usr/lib \
|
||||
/lib/arm-linux-gnueabihf \
|
||||
/lib
|
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>.
|
50
README.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Aufgabenstellung IoT Native Entwicklung
|
||||
|
||||
**Abstract**:
|
||||
Ein Erzeuger generiert Werte die an einen Verbraucher übertragen werden.
|
||||
Der Verbraucher zeigt die einzelnen Werte in der Konsole an.
|
||||
Der Erzeuger kann erst neue Werte an den Verbraucher senden, wenn der Verbraucher den Wert verbraucht (ausgegeben) hat.
|
||||
|
||||
**Feature**:
|
||||
Der Erzeuger überträgt ein variables Objekt an einen Verbraucher der das Objekt auf der Konsole ausgibt
|
||||
|
||||
**Scenario**: Das erzeugte, variable Objekt stellt in der ersten Ausprägung einen Sekunden Zeitwert mit aktuellem Zeitstempel in msec dar
|
||||
**Given** der aktuelle Zeitwert in Sekunden
|
||||
**When** das Objekt erstellt wird
|
||||
**Then** Sekunden Wert und ein Zeitstempel in msec wird in das Objekt eingetragen
|
||||
|
||||
**Scenario**: Das Objekt wird an den Verbraucher übertragen
|
||||
**Given** ein erstelltes Objekt
|
||||
**When** das Objekt übertragen wird
|
||||
**Then** wird auf den Verbraucher gewartet bis er das Objekt verarbeiten kann
|
||||
|
||||
**Scenario**: Das Objekt ist im Verbraucher angekommen
|
||||
**Given** ein übertragenes Objekt
|
||||
**When** das Objekt ausgegeben ist
|
||||
**Then** wird der Erzeuger informiert ein neues Objekt zu erzeugen
|
||||
|
||||
**Scenario**: Das Objekt wird im Verbraucher ausgegeben
|
||||
**Given** eine übertragenes Objekt
|
||||
**When** das Objekt ausgegeben wird
|
||||
**Then** der Wert in Sekunden wird numerisch, der Zeitstempel in lesbarer vollständiger Form, ausgegeben
|
||||
|
||||
**Scenario**: Das Objekt wird vom Erzeuger übertragen
|
||||
**Given** ein erstelltes Objekt
|
||||
**When** das Objekt übertragen wird
|
||||
**Then** der Erzeuger wartet bis der Verbraucher eine Erzeugung angefordert hat
|
||||
|
||||
**Scenario**: Das Objekt wird übertragen
|
||||
**Given** ein erstelltes Objekt
|
||||
**When** das Objekt übertragen wird
|
||||
**Then** das Objekt wird serialisiert über einen Socket übertragen
|
||||
|
||||
## Development Guidelines
|
||||
|
||||
- Die Verwendung von C++ Standards, C11 und neuer
|
||||
- Die Implementierung soll eine Linux und Windows Plattform abdecken
|
||||
- Das Build System für die gesamte Anwendung ist CMake
|
||||
- Die gesamte Anwendung verfügt über Unit Tests die mit google test zu erstellen sind
|
||||
- Die Versionsverwaltung git ist zu verwenden
|
||||
- Eine Dokumentation des Anwendungsentwurfs ist verfügbar
|
||||
- Die Übertragung kann von Sockets auf andere Mechanismen (Shared File) umgestellt werden. Der Impact auf die Anwendung soll begrenzt sein.
|
||||
|
12
README.md.backup
Normal file
@@ -0,0 +1,12 @@
|
||||
# README.md raDIYo
|
||||
|
||||
### Eine Mediaplayer-Software für den RaspberryPi, zugleich ein Hardware-Updgrade eines Nora 'Rienzi' Radios, Bj. ca. 1935
|
||||
|
||||
|
||||
Der Raspberry Pi eignet sich mit etwas Zusatzhardware bekanntermaßen hervorragend als Mediaplayer,da lag es nahe, einen Pi4 Internetradio-Wecker zu verwenden.
|
||||
|
||||
Impl.
|
||||
|
||||
|
||||
|
||||
Arch.
|
279
SWPiGPIO.cpp
Normal file
@@ -0,0 +1,279 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx PiGPIO
|
||||
Copyright © 2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
|
||||
#include <SWPiGPIO.h>
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
|
||||
#include <cstdint>
|
||||
//#include <pigpio.h>
|
||||
//#include "/usr/include/pigpio.h"
|
||||
|
||||
#include <pigpiod_if2.h>
|
||||
|
||||
PiGPIO::PiGPIO()
|
||||
{
|
||||
//::gpioInitialise();
|
||||
// Connect to Pi.
|
||||
constexpr char* optHost = nullptr;
|
||||
constexpr char* optPort = nullptr;
|
||||
PI = ::pigpio_start( optHost, optPort );
|
||||
qDebug() << " -- PiGPIO::PiGPIO(): " << PI;
|
||||
if( PI < 0 )
|
||||
qDebug() << "-- PiGPIO::PiGPIO() FAIL";
|
||||
}
|
||||
|
||||
|
||||
PiGPIO::~PiGPIO()
|
||||
{
|
||||
::pigpio_stop( PI );
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Implementierung für Linux
|
||||
*/
|
||||
|
||||
PiGRotaryDial::PiGRotaryDial( unsigned dialA, unsigned dialB, unsigned button, QObject* parent )
|
||||
: QObject( parent ),
|
||||
_dialA( dialA ), _dialB( dialB ), _button( button )
|
||||
|
||||
{
|
||||
|
||||
_Pi = PiGPIO::Instance().PI;
|
||||
|
||||
//_mode = mode;
|
||||
//_cb = cb_func;
|
||||
_levA = 0;
|
||||
_levB = 0;
|
||||
_step = 0;
|
||||
|
||||
::set_mode( _Pi, _dialA, PI_INPUT );
|
||||
::set_mode( _Pi, _dialB, PI_INPUT );
|
||||
::set_mode( _Pi, _button, PI_INPUT );
|
||||
|
||||
// pull up is needed as encoder common is grounded
|
||||
|
||||
::set_pull_up_down( _Pi, _dialA, PI_PUD_UP );
|
||||
::set_pull_up_down( _Pi, _dialB, PI_PUD_UP );
|
||||
::set_pull_up_down( _Pi, _button, PI_PUD_UP );
|
||||
|
||||
_glitch = 1000;
|
||||
|
||||
::set_glitch_filter( _Pi, _dialA, _glitch );
|
||||
::set_glitch_filter( _Pi, _dialB, _glitch );
|
||||
::set_glitch_filter( _Pi, _button, _glitch );
|
||||
|
||||
_oldState = ( ::gpio_read( _Pi, _dialA ) << 1) | ::gpio_read( _Pi, _dialB );
|
||||
|
||||
// monitor encoder level changes
|
||||
//int callback_ex(int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)
|
||||
// typedef void (*CBFuncEx_t)(int pi, unsigned user_gpio, unsigned level, uint32_t tick, void * userdata);
|
||||
_callbackIdA = ::callback_ex( _Pi, _dialA, EITHER_EDGE, PiGPIOPulse, this );
|
||||
_callbackIdB = ::callback_ex( _Pi, _dialB, EITHER_EDGE, PiGPIOPulse, this );
|
||||
_callbackIdC = ::callback_ex( _Pi, _button, EITHER_EDGE, PiGPIOPulse, this );
|
||||
}
|
||||
|
||||
|
||||
PiGRotaryDial::~PiGRotaryDial()
|
||||
{
|
||||
|
||||
if( _callbackIdA >= 0 )
|
||||
{
|
||||
::callback_cancel( _callbackIdA );
|
||||
_callbackIdA = -1;
|
||||
}
|
||||
|
||||
if( _callbackIdB >= 0 )
|
||||
{
|
||||
::callback_cancel( _callbackIdB );
|
||||
_callbackIdB = -1;
|
||||
}
|
||||
|
||||
if( _callbackIdC >= 0 )
|
||||
{
|
||||
::callback_cancel( _callbackIdC );
|
||||
_callbackIdC = -1;
|
||||
}
|
||||
|
||||
::set_glitch_filter( _Pi, _dialA, 0 );
|
||||
::set_glitch_filter( _Pi, _dialB, 0 );
|
||||
::set_glitch_filter( _Pi, _button, 0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PiGRotaryDial::setGlitchFilter( int glitch )
|
||||
{
|
||||
if( _glitch == glitch )
|
||||
return;
|
||||
_glitch = glitch;
|
||||
::set_glitch_filter( _Pi, _dialA, glitch );
|
||||
::set_glitch_filter( _Pi, _dialB, glitch );
|
||||
::set_glitch_filter( _Pi, _button, glitch );
|
||||
}
|
||||
|
||||
|
||||
void PiGRotaryDial::pulse( unsigned gpio, unsigned level )
|
||||
{
|
||||
|
||||
|
||||
if( level == PI_TIMEOUT )
|
||||
return;
|
||||
if( gpio == _button )
|
||||
return handleClick( level );
|
||||
|
||||
if( gpio == _dialA )
|
||||
_levA = level;
|
||||
else
|
||||
_levB = level;
|
||||
|
||||
// sourceworx proudly presents:
|
||||
// den primitivstmöglichen Auslese-algorithmus
|
||||
// für Rotary-Dials.
|
||||
// Die klugen Varianten stehen hier:
|
||||
// https://www.best-microcontroller-projects.com/rotary-encoder.html
|
||||
// https://web.engr.oregonstate.edu/~traylor/ece473/student_projects/ReadingEncoderSwitches.pdf
|
||||
|
||||
// wenn sich was geändert hatte ...
|
||||
if( gpio == _dialB && level == 1 )
|
||||
{
|
||||
// bestimmt der andere Kontakt die
|
||||
// die Drehrichtung
|
||||
|
||||
int delta = _levA ? -1 : +1;
|
||||
//qDebug() << "###### EMIT: " << delta;
|
||||
emit deltaChanged( delta );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PiGRotaryDial::handleClick( unsigned level )
|
||||
{
|
||||
if( !_pressed && level == 0 )
|
||||
{
|
||||
_pressed = true;
|
||||
return;
|
||||
}
|
||||
if( _pressed && level == 1 )
|
||||
{
|
||||
_pressed = false;
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // Q_OS_LINUX
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
source::worx PiGPIO
|
||||
Copyright © 2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
|
||||
PiGPIO::PiGPIO()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PiGPIO::~PiGPIO()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PiGRotaryDial::PiGRotaryDial( unsigned dialA, unsigned dialB, unsigned button, QObject* parent )
|
||||
: QObject( parent ),
|
||||
_dialA( dialA ), _dialB( dialB ), _button( button )
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PiGRotaryDial::~PiGRotaryDial()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PiGRotaryDial::setGlitchFilter( int )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PiGRotaryDial::pulse( unsigned, unsigned )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif //Q_OS_WIN
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
source::worx PiGPIO
|
||||
Copyright © 2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
||||
void PiGRotaryDial::PiGPIOPulse( int pi, unsigned gpio, unsigned level, uint32_t tick, void *user )
|
||||
{
|
||||
|
||||
Q_UNUSED( pi );
|
||||
Q_UNUSED( tick );
|
||||
|
||||
// Need a static callback to link with C.
|
||||
PiGRotaryDial* mySelf = static_cast<PiGRotaryDial*>( user );
|
||||
if( mySelf )
|
||||
mySelf->pulse( gpio, level ); // Call the instance callback.
|
||||
}
|
||||
|
||||
/*
|
||||
void PiGRotaryDial::setPosition( int position )
|
||||
{
|
||||
_step = position * 4;
|
||||
}
|
||||
|
||||
|
||||
int PiGRotaryDial::position()
|
||||
{
|
||||
return _step / 4;
|
||||
}
|
||||
*/
|
162
SWPiGPIO.h
Normal file
@@ -0,0 +1,162 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx PiGPIO
|
||||
Copyright © 2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWPIGPIO_H
|
||||
#define SWPIGPIO_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class PiGPIOFactory;
|
||||
class PiGPIOLinFactory;
|
||||
class PiGPIOWinFactory;
|
||||
class PiGPIOWidget;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
// Fake4Win
|
||||
typedef void (*CBFuncEx_t)( int pi, unsigned user_gpio, unsigned level, uint32_t tick, void * userdata );
|
||||
|
||||
extern int PI_INPUT;
|
||||
extern int PI_PUD_UP;
|
||||
extern int EITHER_EDGE;
|
||||
extern int PI_TIMEOUT;
|
||||
//int PI_TIMEOUT = 42;
|
||||
|
||||
extern int set_mode(int,int,int);
|
||||
extern int set_pull_up_down(int,int,int);
|
||||
extern int set_glitch_filter(int,int,int);
|
||||
extern int callback_cancel(int);
|
||||
extern int callback_ex(int,unsigned,int,CBFuncEx_t,void*);
|
||||
extern int gpio_read(int,int);
|
||||
|
||||
#endif //Q_OS_WIN
|
||||
|
||||
|
||||
/**
|
||||
* @brief @brief Prototypische Implementierung eines Wrappers für die 'pigpiod' library.
|
||||
*/
|
||||
|
||||
class PiGPIO
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static PiGPIO& Instance()
|
||||
{
|
||||
static PiGPIO _Instance; // Guaranteed to be destroyed.
|
||||
return _Instance; // Instantiated on first use.
|
||||
}
|
||||
|
||||
|
||||
PiGPIO( PiGPIO const& ) = delete;
|
||||
void operator=(PiGPIO const&) = delete;
|
||||
|
||||
~PiGPIO();
|
||||
|
||||
int PI;
|
||||
|
||||
private:
|
||||
|
||||
PiGPIO();
|
||||
|
||||
bool _initCalled = false;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
+---------+ +---------+ 0
|
||||
| | | |
|
||||
A | | | |
|
||||
| | | |
|
||||
+---------+ +---------+ +----- 1
|
||||
|
||||
+---------+ +---------+ 0
|
||||
| | | |
|
||||
B | | | |
|
||||
| | | |
|
||||
----+ +---------+ +---------+ 1
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Implentiert die Anbindung eines RotaryDials (Dreh-Drück Regler)
|
||||
* an die Benutzeroberfläche
|
||||
*
|
||||
* Version über den 'pigpiod' _ohne_ direkten Hardwarezugriff (welcher root-Rechte
|
||||
* benötigen würde)
|
||||
*/
|
||||
|
||||
class PiGRotaryDial : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit PiGRotaryDial( unsigned dialA, unsigned dialB, unsigned button, QObject* parent = nullptr );
|
||||
virtual ~PiGRotaryDial();
|
||||
void setGlitchFilter( int glitch );
|
||||
|
||||
signals:
|
||||
|
||||
void clicked();
|
||||
void deltaChanged( int value );
|
||||
|
||||
protected:
|
||||
|
||||
void pulse( unsigned gpio, unsigned level );
|
||||
void handleClick( unsigned level );
|
||||
//void handlePulse( int value );
|
||||
|
||||
// Need a static callback to link with C.
|
||||
static void PiGPIOPulse( int Pi, unsigned gpio, unsigned level, uint32_t tick, void *user );
|
||||
|
||||
/*
|
||||
constexpr const static int Transits[16]=
|
||||
{
|
||||
// 0000 0001 0010 0011 0100 0101 0110 0111
|
||||
0, -1, 1, 0, 1, 0, 0, -1,
|
||||
// 1000 1001 1010 1011 1100 1101 1110 1111
|
||||
-1, 0, 0, 1, 0, 1, -1, 0
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
int _Pi = -1;
|
||||
unsigned _dialA = -1;
|
||||
unsigned _dialB = -1;
|
||||
unsigned _button = -1;
|
||||
int _callbackIdA = -1;
|
||||
int _callbackIdB = -1;
|
||||
int _callbackIdC = -1;
|
||||
int _levA = -1;
|
||||
int _levB = -1;
|
||||
int _oldState = -1;
|
||||
int _glitch = -1;
|
||||
int _step = 0;
|
||||
int _oldStep = 0;
|
||||
|
||||
bool _pressed = false;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SWPIGPIO_H
|
10
data/radiyo.senderlist.csv
Normal file
@@ -0,0 +1,10 @@
|
||||
egoFM HQ;http://streams.egofm.de/egoFM-hq
|
||||
Flux FM Berlin;http://streams.fluxfm.de/live/mp3-128/audio/
|
||||
egoFM Snow;http://streams.egofm.de/egoSNOW-egoFM
|
||||
egoFM Riff;http://streams.egofm.de/egoRIFF-hq
|
||||
Flux FM 60s: Back to the Sixties;http://streams.fluxfm.de/60er/mp3-128/streams.fluxfm.de/
|
||||
egoFM SUN;http://streams.egofm.de/egoSUN-hq
|
||||
egoFM Hall of Fame;http://streams.egofm.de/egoFMHallOfFame-hq
|
||||
Flux FM 90s: Der 90er Channel;http://streams.fluxfm.de/90er/mp3-128/audio/
|
||||
Flux FM 70s: Der 70er Channel;http://streams.fluxfm.de/70er/mp3-128/audio/
|
||||
Jäger Music Radio;http://streams.fluxfm.de/studio56/mp3-128/audio/
|
|
5
data/radiyo.titlelabel.css
Normal file
@@ -0,0 +1,5 @@
|
||||
margin-left: 0px;
|
||||
border: 2px solid gray;
|
||||
border-radius: 12px;
|
||||
color: %1;
|
||||
background: rgb(44,44,44);
|
BIN
fonts/Afterclap_Personal_Use.otf
Normal file
BIN
fonts/JosefinSans-SemiBold.ttf
Normal file
BIN
fonts/JosefinSans-VariableFont_wght.ttf
Normal file
BIN
fonts/SelznickRemixNF.ttf
Normal file
BIN
fonts/gradogradoonf.regular.ttf
Normal file
BIN
fonts/valleygrrrlnf.regular.ttf
Normal file
BIN
images/btn.pdn
Normal file
BIN
images/btn2.pdn
Normal file
BIN
images/radiyo.alarm.checked.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
images/radiyo.alarm.hover.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
images/radiyo.alarm.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
images/radiyo.bluetooth.checked.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
images/radiyo.bluetooth.hover.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
images/radiyo.bluetooth.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
images/radiyo.btn.clock.pdn
Normal file
BIN
images/radiyo.btn.tpl.pdn
Normal file
BIN
images/radiyo.clock.checked.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
images/radiyo.clock.hover.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
images/radiyo.clock.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
images/radiyo.digiclock.checked.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
images/radiyo.digiclock.hover.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
images/radiyo.digiclock.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
images/radiyo.down.checked.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
images/radiyo.down.hover.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
images/radiyo.down.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
images/radiyo.halt.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
images/radiyo.pause.checked.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
images/radiyo.pause.hover.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
images/radiyo.pause.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
images/radiyo.play.checked.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
images/radiyo.play.hover.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
images/radiyo.play.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
images/radiyo.sender.checked.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
images/radiyo.sender.hover.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
images/radiyo.sender.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
images/radiyo.setup.checked.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
images/radiyo.setup.hover.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
images/radiyo.setup.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
images/radiyo.shutdown.checked.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
images/radiyo.shutdown.hover.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
images/radiyo.shutdown.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
images/radiyo.songs.checked.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
images/radiyo.songs.hover.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
images/radiyo.songs.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
images/radiyo.stop.checked.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
images/radiyo.stop.hover.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
images/radiyo.stop.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
images/radiyo.usb.checked.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
images/radiyo.usb.hover - Kopie.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
images/radiyo.usb.hover.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
images/radiyo.usb.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
images/radiyo.weekday.checked.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
images/radiyo.weekday.hover.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
images/radiyo.weekday.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
62
main.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCheckBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
|
||||
#include <SWPiGPIO.h>
|
||||
#include <raDIYo.h>
|
||||
#include <swtoggleswitch.h>
|
||||
|
||||
/**
|
||||
BUGS:
|
||||
|
||||
- play pause nicht Rotary synchron
|
||||
- Icon-hint auch für linken rotary? '<-->' wäre konsequent
|
||||
- dazu setup opfern
|
||||
- ein-hand bedienung: Volume per Left-Rotary ?
|
||||
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[] )
|
||||
{
|
||||
|
||||
|
||||
QCoreApplication::setOrganizationName ( raDIYo::OrgName );
|
||||
QCoreApplication::setOrganizationDomain( raDIYo::DomainName );
|
||||
QCoreApplication::setApplicationName ( raDIYo::AppName );
|
||||
|
||||
QApplication application( argc, argv );
|
||||
|
||||
// get the dimension available on this screen
|
||||
QSize availableSize = QGuiApplication::primaryScreen()->availableGeometry().size();
|
||||
int width = availableSize.width();
|
||||
int height = availableSize.height();
|
||||
int xpos = ( width - RaDIYo::SWScreenLargeX ) / 2;
|
||||
int ypos = ( height - RaDIYo::SWScreenLargeY ) / 2;
|
||||
|
||||
|
||||
RaDIYo raDIYo;
|
||||
|
||||
raDIYo.move( xpos, ypos + 40 );
|
||||
raDIYo.show();
|
||||
|
||||
return application.exec();
|
||||
|
||||
}
|
515
raDIYo.cpp
Normal file
@@ -0,0 +1,515 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStandardPaths>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QAction>
|
||||
#include <QCoreApplication>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QTime>
|
||||
#include <QUrl>
|
||||
#include <QFileInfo>
|
||||
#include <QStyle>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QFontDatabase>
|
||||
#include <QByteArray>
|
||||
#include <QFileInfo>
|
||||
|
||||
|
||||
//#include <stdio.h>
|
||||
#include <raDIYo.h>
|
||||
#include <swcontrol.h>
|
||||
#include <swdialbutton.h>
|
||||
|
||||
#include <swsendercontrol.h>
|
||||
#include <swsongscontrol.h>
|
||||
#include <swshutdowncontrol.h>
|
||||
#include <swclockcontrol.h>
|
||||
#include <swalarmcontrol.h>
|
||||
#include <swsetupcontrol.h>
|
||||
#include <swusbcontrol.h>
|
||||
#include <swbluetoothcontrol.h>
|
||||
#include <swplayercontrol.h>
|
||||
|
||||
#include <SWPiGPIO.h>
|
||||
|
||||
|
||||
RaDIYo::RaDIYo()
|
||||
: QWidget( nullptr )
|
||||
{
|
||||
|
||||
|
||||
setupUi( this );
|
||||
|
||||
// startup
|
||||
|
||||
// Das ist die Bildschirmgröße des Raspi 7 inch displays
|
||||
resize( SWScreenLargeX, SWScreenLargeY );
|
||||
|
||||
setupFonts();
|
||||
setupControls();
|
||||
setupConnections();
|
||||
setupDefaults();
|
||||
|
||||
// bei untätigkeit kommt wieder die Uhr
|
||||
//_idleTimer.setInterval( raDIYo::IdleTimeOut );
|
||||
//_idleTimer.setSingleShot( true );
|
||||
|
||||
// hier sind wir auch für die voreinstellungen zuständig: falls
|
||||
// nicht vorhanden, default setzen
|
||||
|
||||
// '_alarmControl->onShow();' stellt den Alarmtimer ein
|
||||
// Das gehört hierher ins setup, weil
|
||||
// wir den Alarm auch gesetzt haben wollen
|
||||
// _ohne_ das AlarmConmtrol aufrufen zu müssen.
|
||||
|
||||
_alarmControl->onShow();
|
||||
|
||||
|
||||
// wir starten mit der Uhr
|
||||
onChangeState( RaDIYo::Clock );
|
||||
|
||||
// Der Startwert für die Lautstärke
|
||||
// ist 20% vom Maximum und muss
|
||||
// hier als Absolutwert gesetzt werden
|
||||
// weil zur Laufzeit nur mit deltas
|
||||
// gearbeitet wird.
|
||||
|
||||
int vol = 20;
|
||||
_nowPlaying.volume = vol;
|
||||
_volumeWidget->setValue( vol );
|
||||
_playerControl->setValue( vol );
|
||||
|
||||
// not least
|
||||
_version->setText( raDIYo::Version );
|
||||
qDebug( raDIYo::Version );
|
||||
|
||||
}
|
||||
|
||||
|
||||
RaDIYo::~RaDIYo()
|
||||
{
|
||||
_playerControl->stopPlaying();
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
delete _dialLeft;
|
||||
delete _dialRight;
|
||||
#endif
|
||||
|
||||
for( SWControl* ctrl : _controls )
|
||||
delete ctrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Behandelt die 'direkten' (vom touchscreen) Buttonsclicks aus der Buttongroup
|
||||
* und den 'indirekten' Aufruf über die RotaryDials: Wenn die Buttonleiste aktiv ist,
|
||||
* wird beim Klick auf den SenderButton auch 'idActivated(newId)' gesendet.
|
||||
*
|
||||
* @param newID id des Buttons ( entspricht der id des neuen Controls )
|
||||
*/
|
||||
|
||||
void RaDIYo::onChangeState( int newState )
|
||||
{
|
||||
|
||||
//qDebug() << " ------- RaDIYo::onChangeState: " << newState << ": " << stateName( newState ) << " old: " << stateName( _curCtrlIdx );
|
||||
|
||||
bool pauseClicked = false;
|
||||
|
||||
switch( newState )
|
||||
{
|
||||
|
||||
// wir sind am abspielen, pause geklickt
|
||||
case RaDIYo::Pause :
|
||||
|
||||
// hide button
|
||||
pauseClicked = true;
|
||||
newState = RaDIYo::Play;
|
||||
// fallthrough ...
|
||||
|
||||
// play button geklickt
|
||||
case RaDIYo::Play :
|
||||
|
||||
showTitleText( pauseClicked );
|
||||
_playerControl->togglePlaying( !pauseClicked );
|
||||
_buttonPlay->setVisible( pauseClicked );
|
||||
_buttonPause->setVisible( !pauseClicked );
|
||||
break;
|
||||
|
||||
case RaDIYo::Stop :
|
||||
|
||||
showTitleText( false );
|
||||
_playerControl->stopPlaying();
|
||||
// Pause gilt nicht mehr nach 'stop'
|
||||
_buttonPlay->setVisible( true );
|
||||
_buttonPause->setVisible( false );
|
||||
// fallthrough..
|
||||
|
||||
case RaDIYo::Back :
|
||||
|
||||
//_curCtrlIdx = _lstState;
|
||||
newState = Clock; //?? oder select
|
||||
|
||||
} // switch
|
||||
|
||||
|
||||
if( _curCtrlIdx == newState )
|
||||
return;
|
||||
|
||||
// Hier wird unterschieden zwischen 'echten' Controls ('play', 'sender' ...)
|
||||
// und dummies ohne eigene Seite ('stop', 'pause', 'back' )
|
||||
|
||||
_upMode = true;
|
||||
SWControl* newControl = _controls[newState];
|
||||
|
||||
// wenn vorhanden ...
|
||||
if( nullptr != newControl )
|
||||
{
|
||||
// ... dann das alte aus-
|
||||
_controls[_curCtrlIdx]->fadeOut();
|
||||
//_curCtrlIdx = newState;
|
||||
|
||||
// und das neue Control einblenden ...
|
||||
newControl->fadeIn();
|
||||
|
||||
// Kontrolle übergeben ...
|
||||
_activeReceiver = newControl;
|
||||
|
||||
// Wird das 'neue' Control vom RotaryDial gesteuert?
|
||||
if( !newControl->acceptDial() )
|
||||
{
|
||||
_activeReceiver = static_cast<SWDialHandler*>( &_raDIYoButtons );
|
||||
_upMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
_buttonBack->setVisible( _upMode );
|
||||
_buttonShutdown->setVisible( !_upMode );
|
||||
|
||||
_curCtrlIdx = newState;
|
||||
|
||||
_raDIYoButtons.setCurrentActiveId( _curCtrlIdx );
|
||||
bool isPlaying = _playerState == QMediaPlayer::PlayingState;
|
||||
_buttonStop->setEnabled( isPlaying );
|
||||
|
||||
|
||||
}
|
||||
|
||||
void RaDIYo::showTitleText( bool pauseClicked )
|
||||
{
|
||||
QString color = pauseClicked ? "rgb(181,181,181)" : "white" ;
|
||||
_currentTitle->setStyleSheet( _titleCss.arg( color ) );
|
||||
_currentTitle->setText( _nowPlaying.title );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Wird nicht verwendet
|
||||
void RaDIYo::onIdleTimeOut()
|
||||
{
|
||||
// swap back
|
||||
onChangeState( RaDIYo::Clock );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Slot, der bei Zustandsänderungen des Players
|
||||
* aufgerufen wird
|
||||
* @param state der neue PlayerState
|
||||
*/
|
||||
|
||||
void RaDIYo::onPlayingChanged( QMediaPlayer::State state )
|
||||
{
|
||||
bool callStop = false;
|
||||
|
||||
// State-Änderung kommt von 'innen', also vom Player weil der Song zu Ende ist.
|
||||
if( _curCtrlIdx == RaDIYo::Play && state == QMediaPlayer::StoppedState )
|
||||
callStop = true;
|
||||
|
||||
_playerState = state;
|
||||
|
||||
if( callStop )
|
||||
onChangeState( RaDIYo::Stop );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Es wurde ein Sender oder Song aus der jeweiligen ListView ausgewählt.
|
||||
* @param item der Sender/Song
|
||||
|
||||
* @brief Event von aussen: Ein PlayListEntry wurde aktiviert
|
||||
* und wir jetzt abgespielt.
|
||||
* @param item
|
||||
*/
|
||||
|
||||
void RaDIYo::onPlayUrl( SWUrl item )
|
||||
{
|
||||
_nowPlaying = item;
|
||||
onPlayCurrentUrl();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief von aussen und von innen, spielt
|
||||
* die derzeitige defaultquelle ab, wird
|
||||
* vom Wecker benutzt.
|
||||
*/
|
||||
|
||||
void RaDIYo::onPlayCurrentUrl()
|
||||
{
|
||||
_playerControl->setUrl( _nowPlaying.urlText );
|
||||
onChangeState( RaDIYo::Play );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
void RaDIYo::onRightButtonClicked()
|
||||
{
|
||||
onChangeState( _upMode ? RaDIYo::Back : RaDIYo::Shutdown );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Behandelt Impulse der Linken DialControls.
|
||||
* @param delta: +1 oder -1 je nach Drehrichtung
|
||||
*/
|
||||
|
||||
void RaDIYo::onRightDeltaChanged( int delta )
|
||||
{
|
||||
// 'setValue( value )' reicht hier nicht,
|
||||
// denn der neue Wert muss weiter gereicht
|
||||
// werden, also 'onDialDeltaChanged'
|
||||
|
||||
_volumeWidget->onDialDeltaChanged( delta );
|
||||
_playerControl->onDialDeltaChanged( delta );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Der linke Button wird an das aktive Control
|
||||
* weitergeleitet.
|
||||
*/
|
||||
|
||||
void RaDIYo::onLeftButtonClicked()
|
||||
{
|
||||
// ex.left
|
||||
Q_ASSERT( _activeReceiver != nullptr );
|
||||
_activeReceiver->onDialPushed();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief KISS: der rechte Regler steuert immer die Lautstärke.
|
||||
*/
|
||||
|
||||
void RaDIYo::onLeftDeltaChanged( int delta )
|
||||
{
|
||||
|
||||
|
||||
|
||||
Q_ASSERT( _activeReceiver != nullptr );
|
||||
_activeReceiver->onDialDeltaChanged( delta );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// --- Setup
|
||||
///
|
||||
|
||||
|
||||
/**
|
||||
* @brief Fonts explicit laden, _vor_ setupUi
|
||||
*/
|
||||
|
||||
void RaDIYo::setupFonts()
|
||||
{
|
||||
|
||||
QStringList fontList = QDir( raDIYo::FontDir ).entryList();
|
||||
for( const QString& fontName : fontList )
|
||||
QFontDatabase::addApplicationFont( raDIYo::FontDir + fontName );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @param id
|
||||
* @param control
|
||||
*/
|
||||
|
||||
void RaDIYo::addControl( int id, SWControl* control )
|
||||
{
|
||||
_controls[ id ] = control;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief setupControls
|
||||
*/
|
||||
|
||||
void RaDIYo::setupControls()
|
||||
{
|
||||
|
||||
// Setup Controls: 'RaDIYo' Buttons
|
||||
|
||||
_raDIYoButtons.addKeyButton( _buttonPlay, Play, "play" );
|
||||
_raDIYoButtons.addKeyButton( _buttonPause, Pause, "pause" );
|
||||
_raDIYoButtons.addKeyButton( _buttonStop, Stop, "stop" );
|
||||
_raDIYoButtons.addKeyButton( _buttonAlarm, Alarm, "alarm" );
|
||||
_raDIYoButtons.addKeyButton( _buttonClock, Clock, "clock" );
|
||||
_raDIYoButtons.addKeyButton( _buttonSender, Sender, "sender" );
|
||||
_raDIYoButtons.addKeyButton( _buttonSongs, Songs, "songs" );
|
||||
_raDIYoButtons.addKeyButton( _buttonUSB, USB, "usb" );
|
||||
_raDIYoButtons.addKeyButton( _buttonBack, Back, "down" );
|
||||
_raDIYoButtons.addKeyButton( _buttonShutdown, Shutdown, "shutdown" );
|
||||
|
||||
// Startzustand darstellen
|
||||
_buttonBack->hide();
|
||||
_buttonPause->hide();
|
||||
|
||||
// Alle Controls
|
||||
_senderControl = new SWSenderControl( this, &_mainSettings );
|
||||
_songsControl = new SWSongsControl( this, &_mainSettings );
|
||||
_playerControl = new SWPlayerControl( this, &_mainSettings );
|
||||
_alarmControl = new SWAlarmControl( this, &_mainSettings );
|
||||
_usbControl = new SWUSBControl( this, &_mainSettings );
|
||||
|
||||
// Leere Plätze mit 'nullptr' als solche kennzeichnen
|
||||
addControl( Play, _playerControl );
|
||||
addControl( Pause, nullptr );
|
||||
addControl( Stop, nullptr );
|
||||
addControl( Clock, new SWClockControl( this, &_mainSettings ) );
|
||||
addControl( Alarm, _alarmControl ) ;
|
||||
addControl( Sender, _senderControl );
|
||||
addControl( Songs, _songsControl );
|
||||
addControl( USB, _usbControl );
|
||||
addControl( Back, nullptr );
|
||||
addControl( Shutdown, new SWShutdownControl( this, &_mainSettings ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void RaDIYo::setupConnections()
|
||||
{
|
||||
|
||||
// Linux, kompiliert auch unter Win
|
||||
_dialLeft = new PiGRotaryDial( 22, 27, 17, this );
|
||||
_dialRight = new PiGRotaryDial( 06, 13, 05, this );
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
|
||||
connect( _dialLeft, SIGNAL(clicked()), this, SLOT(onLeftButtonClicked() ) );
|
||||
connect( _dialLeft, SIGNAL(deltaChanged(int)), this, SLOT(onLeftDeltaChanged(int) ) );
|
||||
|
||||
connect( _dialRight, SIGNAL(clicked()), this, SLOT(onRightButtonClicked() ) );
|
||||
connect( _dialRight, SIGNAL(deltaChanged(int)), this, SLOT(onRightDeltaChanged(int) ) );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
// Setup Controls: Fake Dials
|
||||
|
||||
connect( &_dialDialog.leftDial().pushButton(), &QPushButton::clicked, this, &RaDIYo::onLeftButtonClicked );
|
||||
connect( &_dialDialog, &SWDummyDialDialog::leftDeltaChanged, this, &RaDIYo::onLeftDeltaChanged );
|
||||
|
||||
connect( &_dialDialog.rightDial().pushButton(), &QPushButton::clicked, this, &RaDIYo::onRightButtonClicked );
|
||||
connect( &_dialDialog, &SWDummyDialDialog::rightDeltaChanged, this, &RaDIYo::onRightDeltaChanged );
|
||||
|
||||
_dialDialog.show();
|
||||
|
||||
#endif
|
||||
|
||||
connect( _senderControl, SIGNAL( entryActivated(SWUrl) ), this, SLOT( onPlayUrl(SWUrl) ) );
|
||||
connect( _songsControl, SIGNAL( entryActivated(SWUrl) ), this, SLOT( onPlayUrl(SWUrl) ) );
|
||||
connect( _usbControl, SIGNAL( entryActivated(SWUrl) ), this, SLOT( onPlayUrl(SWUrl) ) );
|
||||
connect( _usbControl, SIGNAL( driveMounted(int) ), this, SLOT( onChangeState(int) ) );
|
||||
|
||||
qRegisterMetaType< QMediaPlayer::State>(" QMediaPlayer::State");
|
||||
connect( _playerControl, SIGNAL( stateChanged(QMediaPlayer::State) ), this, SLOT( onPlayingChanged(QMediaPlayer::State) ) );
|
||||
|
||||
// Der Wecker sendet ggf auch ...
|
||||
connect( _alarmControl, SIGNAL( playCurrentUrl() ), this, SLOT( onPlayCurrentUrl() ) );
|
||||
connect( &_raDIYoButtons,SIGNAL( idClicked(int) ), this, SLOT( onChangeState(int) ) );
|
||||
// weiterleiten
|
||||
connect( _volumeWidget, SIGNAL( deltaChanged(int) ), this, SLOT( onRightDeltaChanged(int) ) );
|
||||
}
|
||||
|
||||
|
||||
void RaDIYo::setupDefaults()
|
||||
{
|
||||
|
||||
// default Sender belegen
|
||||
if( !_mainSettings.contains( raDIYo::KeyDefaultSender ) )
|
||||
_mainSettings.setValue( raDIYo::KeyDefaultSender, raDIYo::DefaultSender );
|
||||
|
||||
// default playlist item soll nicht leer sein
|
||||
QString defSender =_mainSettings.value( raDIYo::KeyDefaultSender ).toString();
|
||||
_nowPlaying = SWUrl( defSender, raDIYo::DefaultVolume );
|
||||
_playerControl->setUrl( _nowPlaying.urlText );
|
||||
|
||||
// wir nehmen den default-sender
|
||||
_currentTitle->setText( _nowPlaying.title );
|
||||
|
||||
// not least: Pfad setzen
|
||||
// windows: c:\users\chris\<my.Radiyo>
|
||||
// linux: /home/chris/<my.Radiyo>
|
||||
|
||||
QString songsPath = _mainSettings.value( raDIYo::KeySongsPath ).toString();
|
||||
if( songsPath.isEmpty() )
|
||||
{
|
||||
songsPath = QStandardPaths::writableLocation( QStandardPaths::DocumentsLocation );
|
||||
songsPath += _mainSettings.value( raDIYo::KeySongsDir, raDIYo::SongsDir ).toString();
|
||||
_mainSettings.setValue( raDIYo::KeySongsPath, songsPath );
|
||||
}
|
||||
|
||||
// css kram erzeugen
|
||||
_titleCss = readResource( raDIYo::ResTitleStyle );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Debugfunktion, die den Namen eines State ausgibt.
|
||||
* @param state
|
||||
*/
|
||||
|
||||
QString RaDIYo::stateName( int state )
|
||||
{
|
||||
|
||||
switch( state )
|
||||
{
|
||||
case Sender: return "Sender";
|
||||
case Songs: return "Songs";
|
||||
case USB: return "USB";
|
||||
case Clock: return "Clock";
|
||||
case Alarm: return "Alarm";
|
||||
case Play: return "Player";
|
||||
case Pause: return "Pause";
|
||||
case Stop: return "Stop";
|
||||
case Back: return "Back";
|
||||
case Shutdown: return "Shutdown";
|
||||
}
|
||||
return "42";
|
||||
}
|
||||
|
194
raDIYo.h
Normal file
@@ -0,0 +1,194 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef RADIYO_H
|
||||
#define RADIYO_H
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
#include <QMap>
|
||||
#include <QMediaPlayer>
|
||||
#include <QStack>
|
||||
|
||||
#include <swurl.h>
|
||||
#include <swbuttongroup.h>
|
||||
#include <raDIYoglobals.h>
|
||||
#include <swcontrol.h>
|
||||
#include <swdummydialdialog.h>
|
||||
#include <swdialwidget.h>
|
||||
//#include <swplayercontrol.h>
|
||||
#include <raDIYo.h>
|
||||
#include <ui_raDIYo.h>
|
||||
|
||||
#include <swbuttongroup.h>
|
||||
|
||||
/**
|
||||
|
||||
@mainpage raDIYo
|
||||
|
||||
@section sec1 raDIYo
|
||||
|
||||
Eine Mediaplayer-Software für den RaspberryPi, zugleich ein
|
||||
Hardware-Updgrade eines Nora 'Rienzi' Radios, Bj. ca. 1935
|
||||
|
||||
|
||||
@section sec3 Ideen & TODO:
|
||||
|
||||
@subsection sec3_1 TODO 1.0.xx RC
|
||||
|
||||
@remarks
|
||||
|
||||
Für 1.0x
|
||||
|
||||
- lib vlc player nehmen!
|
||||
- videos einbauen, fürs geschmäckle
|
||||
- artist anzeigen
|
||||
- progressbar anzeigen
|
||||
- volume % einblenden
|
||||
- Qt 6.x upgrade
|
||||
- Gestensteuerung via Ultraschall Sensor
|
||||
- Dazu Arduino Bindings
|
||||
- Config per App
|
||||
- Röhrenoszi als Pegel Anzeige ??
|
||||
- mp3 taglib einsetzen
|
||||
- peak level halten im SpectroViewer
|
||||
- Player verbessern: Loop / Shuffle
|
||||
- Player verbessern: Lieblinslautstärke pro song speichern
|
||||
- Player verbessern: Liste weiterspielen
|
||||
|
||||
@bug
|
||||
|
||||
- Bluetooth-Einbindung läuft nur über Systemeinstellungen
|
||||
|
||||
*/
|
||||
|
||||
|
||||
namespace raDIYo
|
||||
{
|
||||
// misc
|
||||
//#define raDIYo:Version "Version 0.0.01 / 19.12.2020"
|
||||
[[maybe_unused]] constexpr static const char* Version = "raDIYo 0.5.45 / 01.12.2022 © 2020-22 chris@sourceworx.org";
|
||||
|
||||
[[maybe_unused]] constexpr static const char* OrgName = "source::worx";
|
||||
[[maybe_unused]] constexpr static const char* DomainName = "sourceworx.org";
|
||||
[[maybe_unused]] constexpr static const char* AppName = "raDIYo";
|
||||
}
|
||||
|
||||
class SWDialHandler;
|
||||
class PiGRotaryDial;
|
||||
class SWControl;
|
||||
class SWPlayerControl;
|
||||
class SWSenderControl;
|
||||
class SWSongsControl;
|
||||
class SWAlarmControl;
|
||||
class SWUSBControl;
|
||||
|
||||
|
||||
/**
|
||||
* @brief The RaDIYo class: Erbt alles von RaDIYoWidget,
|
||||
* Dort wird das GUI implementiert, hier werden die
|
||||
* Zustandssteuerungen behandelt
|
||||
*/
|
||||
|
||||
class RaDIYo : public QWidget, private Ui_RaDIYoWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
constexpr static const int SWScreenSmallX = 480;
|
||||
constexpr static const int SWScreenSmallY = 320;
|
||||
constexpr static const int SWScreenLargeX = 800;
|
||||
constexpr static const int SWScreenLargeY = 480 - 40;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Play = 0,
|
||||
Pause,
|
||||
Stop,
|
||||
Clock,
|
||||
Alarm,
|
||||
Sender,
|
||||
Songs,
|
||||
USB,
|
||||
Back,
|
||||
Shutdown,
|
||||
ControlsSize
|
||||
} ControlType;
|
||||
|
||||
RaDIYo();
|
||||
virtual ~RaDIYo();
|
||||
|
||||
public slots:
|
||||
|
||||
void onChangeState( int id );
|
||||
// dial handling: kommt von aussen
|
||||
void onLeftButtonClicked();
|
||||
void onLeftDeltaChanged(int);
|
||||
|
||||
void onRightButtonClicked();
|
||||
void onRightDeltaChanged(int);
|
||||
|
||||
public slots:
|
||||
|
||||
void onPlayingChanged( QMediaPlayer::State state );
|
||||
void onPlayCurrentUrl();
|
||||
void onPlayUrl( SWUrl item );
|
||||
|
||||
protected:
|
||||
|
||||
using SWControlMap = QMap<int, SWControl*>;
|
||||
|
||||
void onIdleTimeOut();
|
||||
QString stateName( int state );
|
||||
|
||||
void showTitleText( bool pauseClicked );
|
||||
void addControl( int id, SWControl* control );
|
||||
|
||||
void setupFonts();
|
||||
void setupControls();
|
||||
void setupConnections();
|
||||
void setupDefaults();
|
||||
|
||||
SWDialHandler* _activeReceiver = nullptr; // das aktive Control, bzw. die Buttongroup
|
||||
int _curCtrlIdx = RaDIYo::Songs; // index des aktiven Controls
|
||||
bool _upMode = false;
|
||||
|
||||
QMediaPlayer::State _playerState = QMediaPlayer::StoppedState;
|
||||
|
||||
SWPlayerControl* _playerControl = nullptr;
|
||||
SWSenderControl* _senderControl = nullptr;
|
||||
SWSongsControl* _songsControl = nullptr;
|
||||
SWAlarmControl* _alarmControl = nullptr;
|
||||
SWUSBControl* _usbControl = nullptr;
|
||||
|
||||
SWUrl _nowPlaying;
|
||||
QString _titleCss;
|
||||
QTimer _idleTimer;
|
||||
|
||||
SWDummyDialDialog _dialDialog; // fake dials für windows
|
||||
PiGRotaryDial* _dialLeft = nullptr; // raspi rotary dials
|
||||
PiGRotaryDial* _dialRight = nullptr;
|
||||
|
||||
QSettings _mainSettings;
|
||||
|
||||
SWDialButtonGroup _raDIYoButtons;
|
||||
SWControlMap _controls; // alle Controls
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // RADIYO_H
|
115
raDIYo.pro
Normal file
@@ -0,0 +1,115 @@
|
||||
QT += core gui multimedia widgets bluetooth
|
||||
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
# um die Dateien im 'data' dir zu finden ?? ->
|
||||
# https://stackoverflow.com/questions/16250593/reading-from-and-writing-to-file-in-the-qt-resource-system-qt-5-0-2
|
||||
INCLUDEPATH += .
|
||||
|
||||
linux {
|
||||
LIBS += -lpigpio -lpigpiod_if2 -lrt
|
||||
# FIXME SOURCES +=
|
||||
}
|
||||
|
||||
windows {
|
||||
#LIBS += -lpigpio -lpigpiod_if2 -lrt
|
||||
# FIXME SOURCES +=
|
||||
}
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
SWPiGPIO.cpp \
|
||||
main.cpp \
|
||||
raDIYoglobals.cpp \
|
||||
raDIYo.cpp \
|
||||
swadjustabledigit.cpp \
|
||||
swalarmcontrol.cpp \
|
||||
swbarwidget.cpp \
|
||||
swbasecontrol.cpp \
|
||||
swbluetoothcontrol.cpp \
|
||||
swbuttongroup.cpp \
|
||||
swclockcontrol.cpp \
|
||||
swcontrol.cpp \
|
||||
swdialbutton.cpp \
|
||||
swdialhandler.cpp \
|
||||
swdialcontrol.cpp \
|
||||
swdialwidget.cpp \
|
||||
swdummydialdialog.cpp \
|
||||
swdummypushdial.cpp \
|
||||
swfftcalc.cpp \
|
||||
swflipdigit.cpp \
|
||||
swlistcontrol.cpp \
|
||||
swradiobutton.cpp \
|
||||
swrangevalue.cpp \
|
||||
swurl.cpp \
|
||||
swusbcontrol.cpp \
|
||||
swplayercontrol.cpp \
|
||||
swsendercontrol.cpp \
|
||||
swsetupcontrol.cpp \
|
||||
swshutdowncontrol.cpp \
|
||||
swsongscontrol.cpp \
|
||||
swspectrumwidget.cpp \
|
||||
swtoggleswitch.cpp \
|
||||
swvolumewidget.cpp
|
||||
|
||||
HEADERS += \
|
||||
SWPiGPIO.h \
|
||||
raDIYoglobals.h \
|
||||
raDIYo.h \
|
||||
swadjustabledigit.h \
|
||||
swalarmcontrol.h \
|
||||
swbarwidget.h \
|
||||
swbasecontrol.h \
|
||||
swbluetoothcontrol.h \
|
||||
swbuttongroup.h \
|
||||
swclockcontrol.h \
|
||||
swcontrol.h \
|
||||
swdialbutton.h \
|
||||
swdialhandler.h \
|
||||
swdialcontrol.h \
|
||||
swdialwidget.h \
|
||||
swdummydialdialog.h \
|
||||
swdummypushdial.h \
|
||||
swfftcalc.h \
|
||||
swflipdigit.h \
|
||||
swlistcontrol.h \
|
||||
swradiobutton.h \
|
||||
swrangevalue.h \
|
||||
swurl.h \
|
||||
swusbcontrol.h \
|
||||
swplayercontrol.h \
|
||||
swsendercontrol.h \
|
||||
swsetupcontrol.h \
|
||||
swshutdowncontrol.h \
|
||||
swsongscontrol.h \
|
||||
swspectrumwidget.h \
|
||||
swtoggleswitch.h \
|
||||
swvolumewidget.h
|
||||
|
||||
FORMS += \
|
||||
raDIYo.ui \
|
||||
swalarmcontrol.ui \
|
||||
swbasecontrol.ui \
|
||||
swbluetoothcontrol.ui \
|
||||
swclockcontrol.ui \
|
||||
swdummydialdialog.ui \
|
||||
swdummypushdial.ui \
|
||||
swlistcontrol.ui \
|
||||
swplayercontrol.ui \
|
||||
swsetupcontrol.ui \
|
||||
swshutdowncontrol.ui
|
||||
|
||||
RESOURCES += \
|
||||
raDIYo.qrc
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
|
||||
|
52
raDIYo.qrc
Normal file
@@ -0,0 +1,52 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>data/radiyo.senderlist.csv</file>
|
||||
<file>data/radiyo.titlelabel.css</file>
|
||||
<file>fonts/Afterclap_Personal_Use.otf</file>
|
||||
<file>fonts/JosefinSans-SemiBold.ttf</file>
|
||||
<file>fonts/JosefinSans-VariableFont_wght.ttf</file>
|
||||
<file>fonts/SelznickRemixNF.ttf</file>
|
||||
<file>fonts/gradogradoonf.regular.ttf</file>
|
||||
<file>fonts/valleygrrrlnf.regular.ttf</file>
|
||||
<file>images/radiyo.alarm.checked.png</file>
|
||||
<file>images/radiyo.alarm.hover.png</file>
|
||||
<file>images/radiyo.alarm.png</file>
|
||||
<file>images/radiyo.bluetooth.checked.png</file>
|
||||
<file>images/radiyo.bluetooth.hover.png</file>
|
||||
<file>images/radiyo.bluetooth.png</file>
|
||||
<file>images/radiyo.clock.checked.png</file>
|
||||
<file>images/radiyo.clock.hover.png</file>
|
||||
<file>images/radiyo.clock.png</file>
|
||||
<file>images/radiyo.halt.png</file>
|
||||
<file>images/radiyo.pause.checked.png</file>
|
||||
<file>images/radiyo.pause.hover.png</file>
|
||||
<file>images/radiyo.pause.png</file>
|
||||
<file>images/radiyo.play.checked.png</file>
|
||||
<file>images/radiyo.play.hover.png</file>
|
||||
<file>images/radiyo.play.png</file>
|
||||
<file>images/radiyo.sender.checked.png</file>
|
||||
<file>images/radiyo.sender.hover.png</file>
|
||||
<file>images/radiyo.sender.png</file>
|
||||
<file>images/radiyo.setup.checked.png</file>
|
||||
<file>images/radiyo.setup.hover.png</file>
|
||||
<file>images/radiyo.setup.png</file>
|
||||
<file>images/radiyo.shutdown.checked.png</file>
|
||||
<file>images/radiyo.shutdown.hover.png</file>
|
||||
<file>images/radiyo.shutdown.png</file>
|
||||
<file>images/radiyo.songs.checked.png</file>
|
||||
<file>images/radiyo.songs.hover.png</file>
|
||||
<file>images/radiyo.songs.png</file>
|
||||
<file>images/radiyo.stop.checked.png</file>
|
||||
<file>images/radiyo.stop.hover.png</file>
|
||||
<file>images/radiyo.stop.png</file>
|
||||
<file>images/radiyo.usb.checked.png</file>
|
||||
<file>images/radiyo.usb.hover.png</file>
|
||||
<file>images/radiyo.usb.png</file>
|
||||
<file>images/radiyo.weekday.checked.png</file>
|
||||
<file>images/radiyo.weekday.hover.png</file>
|
||||
<file>images/radiyo.weekday.png</file>
|
||||
<file>images/radiyo.down.checked.png</file>
|
||||
<file>images/radiyo.down.hover.png</file>
|
||||
<file>images/radiyo.down.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
552
raDIYo.ui
Normal file
@@ -0,0 +1,552 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RaDIYoWidget</class>
|
||||
<widget class="QWidget" name="RaDIYoWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SWRadiyo</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:black;
|
||||
color:grey;</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="_currentTitle">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>5</x>
|
||||
<y>328</y>
|
||||
<width>790</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Valley Grrrl NF</family>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">padding-bottom: 7px;
|
||||
margin-left: 0px;
|
||||
border: 2px solid gray;
|
||||
border-radius: 3px;
|
||||
border-color: rgb( 66,66,66 );
|
||||
background:rgb(44,44,44);
|
||||
color: rgb( 181, 181, 181 );
|
||||
</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>russisches Kriegsschiff, fick dich!</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWVolumeWidget" name="_volumeWidget" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>247</x>
|
||||
<y>264</y>
|
||||
<width>306</width>
|
||||
<height>58</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background: gold;</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWRadioButton" name="_buttonSender">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>557</x>
|
||||
<y>260</y>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
background-image:url( :/images/radiyo.sender.png);
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-image:url( :/images/radiyo.sender.checked.png);
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background-image:url( :/images/radiyo.sender.hover.png);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWRadioButton" name="_buttonClock">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>260</y>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
background-image:url(:/images/radiyo.clock.png);
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-image:url(:/images/radiyo.clock.checked.png);
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background-image:url(:/images/radiyo.clock.hover.png);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWRadioButton" name="_buttonAlarm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>260</y>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
background-image:url(:/images/radiyo.alarm.png)
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-image:url(:/images/radiyo.alarm.checked.png)
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background-image:url(:/images/radiyo.alarm.hover.png)
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWRadioButton" name="_buttonPlay">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>260</y>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
background-image:url(:/images/radiyo.play.png);
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-image:url(:/images/radiyo.play.checked.png);
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background-image:url(:/images/radiyo.play.hover.png);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWRadioButton" name="_buttonSongs">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>617</x>
|
||||
<y>260</y>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
background-image:url(:/images/radiyo.songs.png);
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-image:url(:/images/radiyo.songs.checked.png);
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background-image:url(:/images/radiyo.songs.hover.png);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="_version">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>2</x>
|
||||
<y>373</y>
|
||||
<width>800</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Josefin Sans SemiBold</family>
|
||||
<pointsize>12</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:rgb( 234, 234, 234 );</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWRadioButton" name="_buttonUSB">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>677</x>
|
||||
<y>260</y>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
background-image:url(:/images/radiyo.usb.png);
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-image:url(:/images/radiyo.usb.checked.png);
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background-image:url(:/images/radiyo.usb.hover.png);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWRadioButton" name="_buttonPause">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>260</y>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
background-image:url(:/images/radiyo.pause.png);
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-image:url(:/images/radiyo.pause.checked.png);
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background-image:url(:/images/radiyo.pause.hover.png);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWRadioButton" name="_buttonShutdown">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>737</x>
|
||||
<y>260</y>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
background-image: url(:/images/radiyo.shutdown.png);
|
||||
}
|
||||
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-image: url(:/images/radiyo.shutdown.checked.png);
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background-image: url(:/images/radiyo.shutdown.hover.png);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWRadioButton" name="_buttonBack">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>737</x>
|
||||
<y>260</y>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
background-image: url(:/images/radiyo.down.png);
|
||||
}
|
||||
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-image: url(:/images/radiyo.down.checked.png);
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background-image: url(:/images/radiyo.down.hover.png);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWRadioButton" name="_buttonStop">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>260</y>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
background-image: url(:/images/radiyo.stop.png);
|
||||
}
|
||||
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
background-image: url(:/images/radiyo.stop.checked.png);
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background-image: url(:/images/radiyo.stop.hover.png);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SWVolumeWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>swvolumewidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SWRadioButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>swradiobutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
58
raDIYoglobals.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <raDIYoglobals.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief liest einen String aus den Resourcen und gibt ihn zurück
|
||||
* @param fileName Der Bezeichner
|
||||
* @return
|
||||
*/
|
||||
|
||||
QString readResource( const QString& fileName )
|
||||
{
|
||||
|
||||
QFile resourceFile( fileName );
|
||||
|
||||
if( !resourceFile.open( QFile::ReadOnly | QFile::Text) )
|
||||
return resourceFile.errorString();
|
||||
|
||||
QTextStream in( &resourceFile );
|
||||
QString text = in.readAll();
|
||||
resourceFile.close();
|
||||
|
||||
return text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief formatInt: Formatiert einen Integer in einen QString
|
||||
* @param value der Zahlenwert
|
||||
* @param len die Anzeigelänge
|
||||
*/
|
||||
|
||||
QString formatInt(int value, int len )
|
||||
{
|
||||
QString result( "%0" );
|
||||
result = result.arg( value, len, 10, QChar( '0' ) );
|
||||
return result;
|
||||
}
|
79
raDIYoglobals.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef RADIYOGLOBALS_H
|
||||
#define RADIYOGLOBALS_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QColor>
|
||||
#include <QString>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMetaType>
|
||||
|
||||
using SWColorVec = QVector<QColor>;
|
||||
using SWValVec = QVector<float>;
|
||||
|
||||
QString readResource( const QString& fileName );
|
||||
QString formatInt(int value, int len );
|
||||
|
||||
|
||||
/**
|
||||
* @brief Globale Konstanten und Voreinstellungen.
|
||||
*/
|
||||
|
||||
|
||||
namespace raDIYo
|
||||
{
|
||||
// basics
|
||||
[[maybe_unused]] constexpr static const char* KeyPlayerVolume = "PlayerVolume";
|
||||
[[maybe_unused]] constexpr static const char* KeySongsDir = "SongsDir";
|
||||
[[maybe_unused]] constexpr static const char* SongsDir = "/my.raDIYo/";
|
||||
[[maybe_unused]] constexpr static const char* SenderFile = "/my.raDIYo.csv";
|
||||
[[maybe_unused]] constexpr static const char* KeySongsPath = "SongsPath";
|
||||
[[maybe_unused]] constexpr static const char* KeySenderPath = "SenderFile";
|
||||
[[maybe_unused]] constexpr static const char* MountDir = "/media/";
|
||||
[[maybe_unused]] constexpr static const char* ResSenderList = ":/data/radiyo.senderlist.csv";
|
||||
[[maybe_unused]] constexpr static const char* ResTitleStyle = ":/data/radiyo.titlelabel.css";
|
||||
[[maybe_unused]] constexpr static const char* KeyDefaultSender = "DefaultSender";
|
||||
[[maybe_unused]] constexpr static const char* DefaultSender = "egoFM;http://streams.egofm.de/egoFM-hq";
|
||||
[[maybe_unused]] constexpr static const int DefaultVolume = 20; // 20%
|
||||
|
||||
// alarm handling
|
||||
[[maybe_unused]] constexpr static const char* KeyAlarmEnabled = "AlarmEnabled";
|
||||
[[maybe_unused]] constexpr static const bool AlarmEnabled = false;
|
||||
[[maybe_unused]] constexpr static const char* KeyAlarmRepeat = "AlarmRepeat";
|
||||
[[maybe_unused]] constexpr static const bool AlarmRepeat = false;
|
||||
[[maybe_unused]] constexpr static const char* KeyWeekdaysOnly = "WeekdaysOnly";
|
||||
[[maybe_unused]] constexpr static const bool WeekdaysOnly = true;
|
||||
[[maybe_unused]] constexpr static const char* KeyAlarmHour = "AlarmHour";
|
||||
[[maybe_unused]] constexpr static const int AlarmHour = 05;
|
||||
[[maybe_unused]] constexpr static const char* KeyAlarmMinute = "AlarmMinute";
|
||||
[[maybe_unused]] constexpr static const int AlarmMinute = 59;
|
||||
|
||||
|
||||
// optik, haptik :)
|
||||
[[maybe_unused]] constexpr static const char* FontDir = ":/fonts/";
|
||||
[[maybe_unused]] constexpr static const char* NoMedia = "(no media)";
|
||||
[[maybe_unused]] constexpr static const int IdleTimeOut = 20000; // 20 sec
|
||||
[[maybe_unused]] constexpr static const int HighlightWidth = 3;
|
||||
|
||||
// restart etc.
|
||||
[[maybe_unused]] constexpr static const char* CmdShutDown = "sudo halt";
|
||||
[[maybe_unused]] constexpr static const char* CmdReboot = "sudo reboot";
|
||||
[[maybe_unused]] constexpr static const char* CmdRestart = "kill -9 `pidof raDIYo`; x-terminal-emulator -e /home/pi/raDIYo/raDIYo";
|
||||
[[maybe_unused]] constexpr static const char* CmdVolume = "/usr/bin/amixer -q sset 'Master' %0% ";
|
||||
|
||||
}
|
||||
|
||||
#endif // RADIYOGLOBALS_H
|
146
swadjustabledigit.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include <swadjustabledigit.h>
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Standartkonstruktor: Erzeugt ein AdjustableDigit Widget, also
|
||||
* eine FlipDigit, deren Zahlerwert per Maus, Touchscreen oder RotaryDial
|
||||
* geändert werden kann.
|
||||
* Erbt von @see SWFlipDigit
|
||||
* @param parent
|
||||
*/
|
||||
|
||||
SWAdjustableDigit::SWAdjustableDigit( QWidget* parent )
|
||||
: SWFlipDigit( parent )
|
||||
{
|
||||
_fontScale = 0.75; //0.85
|
||||
|
||||
//_fontFamily = "Valley Grrrl NF";
|
||||
//_fontFamily = "Lansbury FG";
|
||||
//_fontFamily = "Selznick Remix NF";
|
||||
//_fontFamily = "Josefin Sans Thin";
|
||||
//_fontFamily = "ThickDeco";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Setzt einen Zahlenwert. Wenn der Wert nicht in den
|
||||
* vorgegebenen Wertebereich passt, wird er angepasst und
|
||||
* SIGNAL valueOverflow ausgelöst.
|
||||
* @see setRange
|
||||
*/
|
||||
|
||||
void SWAdjustableDigit::setValue( int value )
|
||||
{
|
||||
|
||||
_value = qBound( _rangeFrom, value, _rangeTo );
|
||||
|
||||
if( value > _rangeTo )
|
||||
emit valueOverflow( value );
|
||||
else if( value < _rangeFrom )
|
||||
emit valueOverflow( value );
|
||||
preparePixmap();
|
||||
update();
|
||||
|
||||
emit valueChanged( _value );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Teil der Maussteuerung, mit der Zahlenwert der Klappzahl
|
||||
* geändert werden kann.
|
||||
* @param event
|
||||
*/
|
||||
|
||||
void SWAdjustableDigit::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
// timer merken
|
||||
_timerID = startTimer( 200 );
|
||||
// aktuelle Y-Pos/Höhe des Mauszeigers merken, um
|
||||
// delta plus oder minus zu ermitteln
|
||||
_posY = event->pos().y();
|
||||
int middle = rect().height() / 2;
|
||||
_delta = _posY >= middle ? -1 : +1 ;
|
||||
setValue( _value + _delta );
|
||||
_waiting = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Teil der Maussteuerung, mit der Zahlenwert der Klappzahl
|
||||
* geändert werden kann.
|
||||
* @param event
|
||||
*/
|
||||
|
||||
void SWAdjustableDigit::mouseMoveEvent( QMouseEvent* event )
|
||||
{
|
||||
|
||||
// Wenn wir uns dem Digit 'rausgezappelt haben, dann ist schluss ...
|
||||
if( !rect().contains( event->pos() ) )
|
||||
mouseReleaseEvent( event );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Teil der Maussteuerung, mit der Zahlenwert der Klappzahl
|
||||
* geändert werden kann.
|
||||
* @param event
|
||||
*/
|
||||
|
||||
void SWAdjustableDigit::mouseReleaseEvent( QMouseEvent* )
|
||||
{
|
||||
// und schluss
|
||||
killTimer( _timerID );
|
||||
_delta = 0;
|
||||
_timerID = -1;
|
||||
_waiting = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Timersteuerung. Verlangsamt die Wertänderung per Maus.
|
||||
*/
|
||||
|
||||
void SWAdjustableDigit::timerEvent( QTimerEvent* )
|
||||
{
|
||||
// zwei Fälle: der erste TimerEvent kommt
|
||||
// wenn die 'Festhalthürde' von 200 ms genommen ist,
|
||||
// dann kommen die Hoch/Runterzähl TickerEvents.
|
||||
|
||||
// zähltimer tick
|
||||
if( !_waiting && _delta )
|
||||
{
|
||||
setValue( _value + _delta );
|
||||
return;
|
||||
}
|
||||
|
||||
// erster Timer: alten Timer wegschmeissen ...
|
||||
killTimer( _timerID );
|
||||
// ...und den neuen schnelleren starten
|
||||
_timerID = startTimer( 100 );
|
||||
_waiting = false;
|
||||
|
||||
}
|
63
swadjustabledigit.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWADJUSTABLEDIGIT_H
|
||||
#define SWADJUSTABLEDIGIT_H
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <swflipdigit.h>
|
||||
#include <swdialwidget.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Erweiterte 'SWFlipDigit', die sich auch mit der Maus einstellen
|
||||
* lässt.
|
||||
*/
|
||||
|
||||
class SWAdjustableDigit : public SWFlipDigit
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit SWAdjustableDigit( QWidget* parent = nullptr );
|
||||
virtual ~SWAdjustableDigit() = default;
|
||||
|
||||
void setValue( int n ) override;
|
||||
|
||||
signals:
|
||||
|
||||
void valueOverflow( int value );
|
||||
void valueChanged( int newValue );
|
||||
// fulfill interface of SWDialAdapter
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
|
||||
void mousePressEvent( QMouseEvent* event ) override;
|
||||
void mouseMoveEvent( QMouseEvent* event ) override;
|
||||
void mouseReleaseEvent( QMouseEvent* event ) override;
|
||||
void timerEvent( QTimerEvent* event ) override;
|
||||
|
||||
bool _waiting = false;
|
||||
int _delta = 0;
|
||||
int _timerID = -1;
|
||||
int _posY = -1;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SWADJUSTABLEDIGIT_H
|
231
swalarmcontrol.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QKeyEvent>
|
||||
#include <QDateTime>
|
||||
#include <QTime>
|
||||
#include <QAction>
|
||||
#include <QtMath>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <swalarmcontrol.h>
|
||||
|
||||
#include <raDIYo.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Das AlarmControl steuert den Wecker.
|
||||
* @param parent
|
||||
* @param psettings
|
||||
*/
|
||||
|
||||
SWAlarmControl::SWAlarmControl( QWidget* parent, QSettings* psettings )
|
||||
: SWDialControl( parent, psettings )
|
||||
{
|
||||
|
||||
Ui_SWAlarmControl::setupUi( this );
|
||||
setHeaderText( "Alarm" );
|
||||
|
||||
connect( &_alarmTimer, SIGNAL( timeout() ), this, SLOT( onWakeUp() ) );
|
||||
// die Minuten beobachten, um die Stunden anzupassen
|
||||
connect( _digitMinute, SIGNAL( valueOverflow(int) ), this, SLOT( onMinuteOverflow(int) ) );
|
||||
connect( _digitHour, SIGNAL( valueOverflow(int) ), this, SLOT( onHourOverflow(int) ) );
|
||||
|
||||
connect( _switchAlarm, SIGNAL( widgetClicked(SWDialWidget*) ), this, SLOT( onWidgetClicked(SWDialWidget*) ) );
|
||||
connect( _switchRepeat, SIGNAL( widgetClicked(SWDialWidget*) ), this, SLOT( onWidgetClicked(SWDialWidget*) ) );
|
||||
connect( _switchWeekdays, SIGNAL( widgetClicked(SWDialWidget*) ), this, SLOT( onWidgetClicked(SWDialWidget*) ) );
|
||||
|
||||
connect( _digitMinute, &SWAdjustableDigit::valueChanged, this, [=]{ if( _alarmEnabled ) setAlarm(); } );
|
||||
connect( _digitHour, &SWAdjustableDigit::valueChanged, this, [=]{ if( _alarmEnabled ) setAlarm(); } );
|
||||
|
||||
_digitHour->setRange( 0, 23 );
|
||||
_digitMinute->setRange( 0, 59 );
|
||||
|
||||
collectDialWidgets();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SWAlarmControl::onMinuteOverflow( int value )
|
||||
{
|
||||
|
||||
int hour = _digitHour->value();
|
||||
if( value < 0 )
|
||||
{
|
||||
_digitMinute->setValue( 59 );
|
||||
_digitHour->setValue( hour-1 );
|
||||
}
|
||||
else if( value > 59 )
|
||||
{
|
||||
_digitMinute->setValue( 0 );
|
||||
_digitHour->setValue( hour+1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SWAlarmControl::onHourOverflow( int value )
|
||||
{
|
||||
// Stunde < 0: Stunde zurück
|
||||
if( value < 0 )
|
||||
_digitHour->setValue( 23 );
|
||||
else if( value > 23 )
|
||||
_digitHour->setValue( 0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SWAlarmControl::onShow()
|
||||
{
|
||||
|
||||
current().setHightlighted( true );
|
||||
|
||||
// sync sttings -> screen
|
||||
_alarmEnabled = settings().value( raDIYo::KeyAlarmEnabled, raDIYo::AlarmEnabled ).toBool();
|
||||
_switchAlarm->setChecked( _alarmEnabled );
|
||||
|
||||
_alarmRepeat = settings().value( raDIYo::KeyAlarmRepeat, raDIYo::AlarmRepeat ).toBool();
|
||||
_switchRepeat->setChecked( _alarmWeekdays );
|
||||
|
||||
_alarmWeekdays = settings().value( raDIYo::KeyWeekdaysOnly, raDIYo::WeekdaysOnly ).toBool();
|
||||
_switchWeekdays->setChecked( _alarmWeekdays );
|
||||
|
||||
// die Uhrzeit setzen
|
||||
int alarmHour = settings().value( raDIYo::KeyAlarmHour, raDIYo::KeyAlarmHour ).toInt();
|
||||
int alarmMinute = settings().value( raDIYo::KeyAlarmMinute, raDIYo::KeyAlarmMinute ).toInt();
|
||||
_digitHour->setValue( alarmHour );
|
||||
_digitMinute->setValue( alarmMinute );
|
||||
|
||||
setAlarm();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SWAlarmControl::onHide()
|
||||
{
|
||||
|
||||
// sync screen to settings
|
||||
settings().setValue( raDIYo::KeyAlarmEnabled, _switchAlarm->isChecked() );
|
||||
settings().setValue( raDIYo::KeyAlarmRepeat, _switchRepeat->isChecked() );
|
||||
settings().setValue( raDIYo::KeyWeekdaysOnly, _switchWeekdays->isChecked() );
|
||||
|
||||
settings().setValue( raDIYo::KeyAlarmHour, _digitHour->value() );
|
||||
settings().setValue( raDIYo::KeyAlarmMinute, _digitMinute->value() );
|
||||
|
||||
setAlarm();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SWAlarmControl::onWidgetClicked( SWDialWidget* child )
|
||||
{
|
||||
if( _switchAlarm == child )
|
||||
{
|
||||
_alarmEnabled = !_alarmEnabled;
|
||||
_switchAlarm->setChecked( _alarmEnabled );
|
||||
_labelAlarm->setText( _alarmEnabled ? SWAlarmOn : SWAlarmOff );
|
||||
_switchRepeat->setEnabled( _alarmEnabled );
|
||||
_switchWeekdays->setEnabled( _alarmEnabled );
|
||||
goto end;
|
||||
}
|
||||
|
||||
if( _switchRepeat == child )
|
||||
{
|
||||
_alarmRepeat = !_alarmRepeat;
|
||||
_switchRepeat->setChecked( _alarmRepeat );
|
||||
_labelRepeat->setText( _alarmRepeat ? SWAlarmRepeat : SWAlarmOnce );
|
||||
goto end;
|
||||
}
|
||||
|
||||
if( _switchWeekdays == child )
|
||||
{
|
||||
_alarmWeekdays = !_alarmWeekdays;
|
||||
_switchWeekdays->setChecked( _alarmWeekdays );
|
||||
_labelWeekdays->setText( _alarmWeekdays ? SWAlarmWeekdays : SWAlarmAlldays );
|
||||
goto end;
|
||||
}
|
||||
|
||||
//if( _digitHour == child || _digitMinute == child )
|
||||
// onTimeChanged( 42 );
|
||||
|
||||
end:
|
||||
|
||||
setAlarm();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Berechnet den nächsten Alarmzeitpunkt aus den Vorgaben der Benutzeroberfläche
|
||||
* und startet den Alarmtimer.
|
||||
*/
|
||||
|
||||
void SWAlarmControl::setAlarm()
|
||||
{
|
||||
|
||||
_alarmTimer.stop();
|
||||
if( !_alarmEnabled )
|
||||
return;
|
||||
|
||||
/*
|
||||
if( !_alarmEnabled )
|
||||
{
|
||||
_labelAlarm->setText( SWAlarmOff );
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
// ab hier: alarm gewüschnt
|
||||
|
||||
int hour = _digitHour->value();
|
||||
int minute = _digitMinute->value();
|
||||
|
||||
// timer basteln
|
||||
QTime alarmTime( hour, minute );
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
|
||||
int millisToAlarm = 1000 * now.time().secsTo( alarmTime );
|
||||
int shiftDays = 0;
|
||||
// ist der Alarm nicht mehr heute?
|
||||
if( millisToAlarm < 0 )
|
||||
shiftDays = 1;
|
||||
|
||||
// Gnade am Wochenende?
|
||||
if( _alarmWeekdays )
|
||||
{
|
||||
int today = now.date().dayOfWeek();
|
||||
// samstag?
|
||||
shiftDays += today >= 6 ? (today == 7) ? 1 : 2 : 0 ;
|
||||
}
|
||||
|
||||
millisToAlarm += shiftDays * SecsPerDay * 1000;
|
||||
_labelAlarm->setText( SWAlarmOn + now.addMSecs( millisToAlarm ).toString( " dd.MM, hh:mm" ) );
|
||||
_alarmTimer.start( millisToAlarm );
|
||||
}
|
||||
|
||||
|
||||
void SWAlarmControl::onWakeUp()
|
||||
{
|
||||
_alarmTimer.stop();
|
||||
emit playCurrentUrl();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
82
swalarmcontrol.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWALARMCONTROL_H
|
||||
#define SWALARMCONTROL_H
|
||||
|
||||
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
#include <swbuttongroup.h>
|
||||
|
||||
#include <ui_swalarmcontrol.h>
|
||||
#include <swdialcontrol.h>
|
||||
#include <swurl.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Das 'Wecker'-Control des RaDIYos.
|
||||
*/
|
||||
|
||||
class SWAlarmControl : public SWDialControl, private Ui_SWAlarmControl
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit SWAlarmControl( QWidget* parent, QSettings* settings );
|
||||
virtual ~SWAlarmControl() = default;
|
||||
|
||||
signals:
|
||||
|
||||
void playCurrentUrl();
|
||||
|
||||
public slots:
|
||||
|
||||
void onShow() override;
|
||||
void onHide() override;
|
||||
void onWakeUp();
|
||||
|
||||
void setAlarm();
|
||||
|
||||
public slots:
|
||||
|
||||
void onWidgetClicked( SWDialWidget* ) override;
|
||||
|
||||
protected slots:
|
||||
|
||||
void onMinuteOverflow( int value );
|
||||
void onHourOverflow( int value );
|
||||
|
||||
protected:
|
||||
|
||||
const char* SWAlarmOn = "Alarm:";
|
||||
const char* SWAlarmOff = "Alarm off";
|
||||
const char* SWAlarmOnce = "Only once";
|
||||
const char* SWAlarmRepeat = "Repeat Alarm daily";
|
||||
const char* SWAlarmWeekdays = "Weekdays only";
|
||||
const char* SWAlarmAlldays = "Alldays";
|
||||
|
||||
static const int SecsPerDay = 86400;
|
||||
|
||||
bool _alarmEnabled = false;
|
||||
bool _alarmRepeat = false;
|
||||
bool _alarmWeekdays = false;
|
||||
|
||||
QTimer _alarmTimer;
|
||||
|
||||
};
|
||||
|
||||
#endif // SWALARMCONTROL_H
|
271
swalarmcontrol.ui
Normal file
@@ -0,0 +1,271 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SWAlarmControl</class>
|
||||
<widget class="QWidget" name="SWAlarmControl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>275</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<widget class="QLabel" name="_labelAlarm">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>92</y>
|
||||
<width>260</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Josefin Sans</family>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Alarm OFF</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWToggleSwitch" name="_switchAlarm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>5</x>
|
||||
<y>92</y>
|
||||
<width>76</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>01</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="_labelWeekdays">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>196</y>
|
||||
<width>261</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Josefin Sans</family>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Weekdays only</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWToggleSwitch" name="_switchWeekdays">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>5</x>
|
||||
<y>196</y>
|
||||
<width>76</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>03</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWAdjustableDigit" name="_digitHour" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>360</x>
|
||||
<y>90</y>
|
||||
<width>210</width>
|
||||
<height>168</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>04</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:gold</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWAdjustableDigit" name="_digitMinute" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>580</x>
|
||||
<y>90</y>
|
||||
<width>210</width>
|
||||
<height>168</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>05</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:gold</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="_labelRepeat">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>145</y>
|
||||
<width>261</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Josefin Sans</family>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Repeat Alarm daily</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWToggleSwitch" name="_switchRepeat">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>5</x>
|
||||
<y>145</y>
|
||||
<width>76</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>02</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SWAdjustableDigit</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>swadjustabledigit.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SWToggleSwitch</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>swtoggleswitch.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
151
swbarwidget.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <swbarwidget.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief SWBarWidget::SWBarWidget : Konstruktor.
|
||||
* Hier werden die für alle Subklassen gemeinsam gültigen
|
||||
* Paramter initialisiert, etwa @see setColorRange, @see calcSizeRatio
|
||||
*/
|
||||
|
||||
SWBarWidget::SWBarWidget( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
|
||||
|
||||
// Papas Lieblingsfarben
|
||||
QStringList list { "#010130", "#20014e", "#0C0786", "#40039C",
|
||||
"#6A00A7", "#8F0DA3", "#B02A8F", "#CA4678",
|
||||
"#E06461", "#F1824C", "#FCA635", "#FCCC25",
|
||||
"#FFEE00", "#EFF821" };
|
||||
setColorRange( list );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief gibt die Anzahl der Balken des Diagramms zurück.
|
||||
*/
|
||||
|
||||
int SWBarWidget::numBars()
|
||||
{
|
||||
return _numBars;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setzt die die Anzahl der Balken des Diagramms.
|
||||
*/
|
||||
|
||||
void SWBarWidget::setNumBars( int bars )
|
||||
{
|
||||
Q_ASSERT( bars > 0 );
|
||||
_numBars = bars;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gibt die Anzahl der Blöcke pro Balken des Diagramms zurück.
|
||||
*/
|
||||
|
||||
int SWBarWidget::numBlocks()
|
||||
{
|
||||
return _numBlocks;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setzt die Anzahl der Blöcke pro Balken des Diagramms.
|
||||
*
|
||||
*/
|
||||
|
||||
void SWBarWidget::setNumBlocks( int blocks )
|
||||
{
|
||||
Q_ASSERT( blocks > 0 );
|
||||
_numBlocks = blocks;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gib denb Abstand in Pixeln zwischen Blöcken und Balken zurück.
|
||||
* Default ist 3.
|
||||
*/
|
||||
|
||||
int SWBarWidget::padding()
|
||||
{
|
||||
return _padding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Setzt das 'padding', also den Abstand zwischen Blöcken und Balken des Diagramms
|
||||
* @param padding der Abstand in Pixeln.
|
||||
*/
|
||||
|
||||
void SWBarWidget::setPadding( int padding )
|
||||
{
|
||||
_padding = padding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Intere Funktion zur Ermittlung der Farbe eines Blocks.
|
||||
*/
|
||||
|
||||
QColor SWBarWidget::getBlockColor( int x, int y )
|
||||
{
|
||||
Q_UNUSED( x )
|
||||
int virtIdx = _numBlocks - 1 - y;
|
||||
double _sizeRatio = (double) _numBlocks / (double) _colors.size();
|
||||
int realIdx = (int) ( (double) virtIdx / _sizeRatio );
|
||||
return _colors[ realIdx ];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setzt die Farbliste zur Darstellung der Blöcke eines Balkens.
|
||||
* @param colorlist Eine Stringliste mit den Hexcodes der Farben.
|
||||
*/
|
||||
|
||||
void SWBarWidget::setColorRange( const QStringList& colorlist )
|
||||
{
|
||||
Q_ASSERT( !colorlist.empty() );
|
||||
|
||||
_colors.clear();
|
||||
for( const QString& color : colorlist )
|
||||
_colors.append( QColor( color ) );
|
||||
_numBlocks =_colors.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt die Farbliste zur Darstellung der Blöcke eines Balkens.
|
||||
* @param Ein Vector mit QColors.
|
||||
*/
|
||||
|
||||
void SWBarWidget::setColorRange( const SWColorVec& colorlist )
|
||||
{
|
||||
Q_ASSERT( !colorlist.empty() );
|
||||
|
||||
_colors.clear();
|
||||
for( const QColor& color : colorlist )
|
||||
_colors.append( color );
|
||||
_numBlocks =_colors.size();
|
||||
}
|
68
swbarwidget.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWBARWIDGET_H
|
||||
#define SWBARWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <raDIYoglobals.h>
|
||||
#include <swdialhandler.h>
|
||||
#include <swrangevalue.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Abstrakte Basisklasse für Balkendiagramme.
|
||||
* @see SWDialHandler
|
||||
* @see SWVolumeWidget
|
||||
* @see SWSpectrumWidget
|
||||
*/
|
||||
|
||||
class SWBarWidget : public QWidget, public SWDialHandler, public SWRangeValue
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit SWBarWidget( QWidget* parent = 0 );
|
||||
virtual ~SWBarWidget() = default;
|
||||
|
||||
virtual void paintEvent( QPaintEvent* event ) override = 0;
|
||||
|
||||
int numBars();
|
||||
void setNumBars( int bars );
|
||||
|
||||
int numBlocks();
|
||||
void setNumBlocks( int blocks );
|
||||
|
||||
int padding();
|
||||
void setPadding( int padding );
|
||||
|
||||
void setColorRange( const QStringList& colorlist );
|
||||
void setColorRange( const SWColorVec& colorlist );
|
||||
|
||||
protected:
|
||||
|
||||
QColor getBlockColor( int x, int y );
|
||||
|
||||
int _numBars = -1;
|
||||
int _numBlocks = -1;
|
||||
int _padding = 3;
|
||||
|
||||
SWColorVec _colors;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SWBARWIDGET_H
|
51
swbasecontrol.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <swbasecontrol.h>
|
||||
#include <ui_swbasecontrol.h>
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor.
|
||||
* @param parent das Elternwidget
|
||||
* @param settings das Settingsobjekt des MainWidget.
|
||||
*/
|
||||
|
||||
SWBaseControl::SWBaseControl( QWidget* parent, QSettings* settings )
|
||||
: SWControl( parent, settings )
|
||||
|
||||
{
|
||||
Ui_SWBaseControl::setupUi( this );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gibt den Header-Text zurück.
|
||||
*/
|
||||
|
||||
QString SWBaseControl::headerText()
|
||||
{
|
||||
return _headerLabel->text();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setzt den Headertext des Controls. Der Headertext zeigt die die Funktion
|
||||
* des Controls an: Sender, Songs, Alarm etc.
|
||||
*/
|
||||
|
||||
void SWBaseControl::setHeaderText( const QString& headerText )
|
||||
{
|
||||
_headerLabel->setText( headerText );
|
||||
}
|
42
swbasecontrol.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWBASECONTROL_H
|
||||
#define SWBASECONTROL_H
|
||||
|
||||
|
||||
#include <swcontrol.h>
|
||||
#include <ui_swbasecontrol.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Basisklasse für alle Controls, die einen Headertext anzeigen.
|
||||
*/
|
||||
|
||||
class SWBaseControl : public SWControl, protected Ui_SWBaseControl
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit SWBaseControl( QWidget* parent, QSettings* settings );
|
||||
virtual ~SWBaseControl() = default;
|
||||
|
||||
QString headerText();
|
||||
void setHeaderText( const QString& headerText );
|
||||
|
||||
};
|
||||
|
||||
#endif // SWBASECONTROL_H
|
50
swbasecontrol.ui
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SWBaseControl</class>
|
||||
<widget class="QWidget" name="SWBaseControl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>255</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:black;
|
||||
color:rgb( 234, 234, 234 ); </string>
|
||||
</property>
|
||||
<widget class="QLabel" name="_headerLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>5</x>
|
||||
<y>42</y>
|
||||
<width>795</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Valley Grrrl NF</family>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">padding-top: 2px;
|
||||
border: 2px solid gray;
|
||||
border-radius: 3px;
|
||||
border-color: rgb( 66,66,66 );
|
||||
background:rgb(44,44,44);
|
||||
color: rgb( 181, 181, 181 );</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HeaderLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
160
swbluetoothcontrol.cpp
Normal file
@@ -0,0 +1,160 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <swbluetoothcontrol.h>
|
||||
|
||||
#include <QBluetoothLocalDevice>
|
||||
#include <QBluetoothAddress>
|
||||
|
||||
using QBTState = QBluetoothLocalDevice::Pairing;
|
||||
using QBTLocDev = QBluetoothLocalDevice;
|
||||
using QBTAgent = QBluetoothDeviceDiscoveryAgent;
|
||||
using QBTDevInfo = QBluetoothDeviceInfo;
|
||||
|
||||
SWBlueToothControl::SWBlueToothControl( QWidget* parent, QSettings* settings )
|
||||
: SWListControl( parent, settings )
|
||||
{
|
||||
|
||||
Ui_SWBlueToothControl::setupUi( this );
|
||||
setHeaderText( "Bluetooth " );
|
||||
_contentView->resize( 790, 130 );
|
||||
|
||||
_localDevice.powerOn();
|
||||
_localDevice.setHostMode( QBTLocDev::HostDiscoverable );
|
||||
|
||||
/*
|
||||
// Get connected devices
|
||||
QList<QBluetoothAddress> remotes;
|
||||
remotes = _localDevice.connectedDevices();
|
||||
for( const auto& entry : remotes )
|
||||
qDebug() << "remote entry: " << entry;
|
||||
*/
|
||||
|
||||
//_discoveryAgent.setInquiryType( QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry );
|
||||
|
||||
connect( _buttonScan, &QPushButton::toggled, this,
|
||||
[=](bool enabled )
|
||||
{
|
||||
_buttonScan->setChecked( enabled );
|
||||
//_buttonScan->setEnabled( enabled );
|
||||
enabled ? _discoveryAgent.start() : _discoveryAgent.stop();
|
||||
_buttonScan->setText( enabled ? "scanning..." : "start scan" );
|
||||
} );
|
||||
|
||||
connect( &_discoveryAgent, &QBTAgent::finished, this,
|
||||
[=]
|
||||
{
|
||||
_buttonScan->setChecked( false );
|
||||
//_buttonScan->setEnabled( true );
|
||||
_buttonScan->setText( "start scan" );
|
||||
} );
|
||||
|
||||
connect( &_discoveryAgent, SIGNAL( deviceDiscovered(QBluetoothDeviceInfo) ),
|
||||
this, SLOT( addDevice(QBluetoothDeviceInfo) )
|
||||
);
|
||||
|
||||
connect( _contentView, SIGNAL( itemActivated(QListWidgetItem*) ),
|
||||
this, SLOT( onItemActivated(QListWidgetItem*) )
|
||||
);
|
||||
|
||||
connect( &_localDevice, SIGNAL( pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)),
|
||||
this, SLOT(pairingDone(QBluetoothAddress,QBluetoothLocalDevice::Pairing)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wird beim Einbblenden des Controls automatisch
|
||||
* aufgerufen. Überladene Funktion, inm diesem Fall ein Dummy
|
||||
* ohne Funktion.
|
||||
*/
|
||||
|
||||
void SWBlueToothControl::onShow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wird beim Ausblenden des Controls automatisch aufgerufen.
|
||||
* Überladene Funktion, stoppt in diesem Fall einen eventuell
|
||||
* noch aktiven Scan-Process.
|
||||
*/
|
||||
|
||||
void SWBlueToothControl::onHide()
|
||||
{
|
||||
_discoveryAgent.stop();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fügt ein BlueTooth-Device in die Device-Liste hinzu.
|
||||
*/
|
||||
|
||||
void SWBlueToothControl::addDevice( const QBluetoothDeviceInfo& info )
|
||||
{
|
||||
|
||||
QString label = info.name(); //QString("%1 %2").arg(info.address().toString()).arg(info.name());
|
||||
QList<QListWidgetItem*> items = _contentView->findItems( label, Qt::MatchExactly );
|
||||
if( !items.empty() )
|
||||
return;
|
||||
|
||||
QListWidgetItem& item = createItem( label, info.address().toString() );
|
||||
QBTState pairingStatus = _localDevice.pairingStatus( info.address() );
|
||||
bool paired = ( pairingStatus == QBTLocDev::Paired || pairingStatus == QBTLocDev::AuthorizedPaired );
|
||||
QColor bg = paired ? Qt::green : Qt::white ;
|
||||
item.setForeground( bg );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Überladene Funktion, wird ein beim aktivieren eines Eintrag der Device-Liste
|
||||
* aufgerufen und bindet das Device als Soud-Sink ein.
|
||||
*/
|
||||
|
||||
void SWBlueToothControl::onItemActivated( QListWidgetItem* item )
|
||||
{
|
||||
|
||||
QString addrStr= item->data( SWListControlRole ).toString();
|
||||
qDebug() << "BT Pair device: " << addrStr;
|
||||
QBluetoothAddress address( addrStr );
|
||||
|
||||
QBTState pairingStatus = _localDevice.pairingStatus( address );
|
||||
bool paired = ( pairingStatus == QBTState::Paired || pairingStatus == QBTState::AuthorizedPaired );
|
||||
QBTState newState = paired ? QBTState::Paired : QBTState::Unpaired;
|
||||
_localDevice.requestPairing( address, newState );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SIGNAL, wird nach dem Erfolgreichen Einbinden eines BlueTooth Device aufgerufen.
|
||||
* Passt die Listenabzeige der Devices entsprechend der Verbindungszustands der Devices
|
||||
* an.
|
||||
*/
|
||||
|
||||
void SWBlueToothControl::pairingDone( const QBluetoothAddress &address, QBTState pairing )
|
||||
{
|
||||
|
||||
QList<QListWidgetItem*> items = _contentView->findItems( address.toString(), Qt::MatchContains );
|
||||
QColor foreground = Qt::red;
|
||||
if( pairing == QBTLocDev::Paired || pairing == QBTLocDev::AuthorizedPaired )
|
||||
foreground = Qt::green;
|
||||
|
||||
for (int var = 0; var < items.count(); ++var)
|
||||
items.at(var)->setForeground( foreground );
|
||||
|
||||
}
|
||||
|
69
swbluetoothcontrol.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWBLUETOOTHCONTROL_H
|
||||
#define SWBLUETOOTHCONTROL_H
|
||||
|
||||
|
||||
#include <swlistcontrol.h>
|
||||
#include <ui_swbluetoothcontrol.h>
|
||||
|
||||
|
||||
#include <QBluetoothDeviceDiscoveryAgent>
|
||||
#include <QBluetoothLocalDevice>
|
||||
|
||||
//#include <QDialog>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Das Bluetooth Control. Bindet Bluetooth Soundquellen ein.
|
||||
*/
|
||||
|
||||
class SWBlueToothControl : public SWListControl, private Ui_SWBlueToothControl
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit SWBlueToothControl( QWidget* parent, QSettings* settings );
|
||||
virtual ~SWBlueToothControl() = default;
|
||||
|
||||
public slots:
|
||||
|
||||
void onShow() override;
|
||||
void onHide() override;
|
||||
|
||||
void addDevice( const QBluetoothDeviceInfo& );
|
||||
//void on_power_clicked(bool clicked);
|
||||
//void on_discoverable_clicked(bool clicked );
|
||||
//void displayPairingMenu(const QPoint& pos );
|
||||
void pairingDone( const QBluetoothAddress&, QBluetoothLocalDevice::Pairing );
|
||||
|
||||
void onItemActivated( QListWidgetItem* item ) override;
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
//void onDialPushed() override;
|
||||
//void onDialDeltaChanged( int value ) override;
|
||||
|
||||
private:
|
||||
|
||||
QBluetoothDeviceDiscoveryAgent _discoveryAgent;
|
||||
QBluetoothLocalDevice _localDevice;
|
||||
|
||||
};
|
||||
|
||||
#endif // SWBLUETOOTHCONTROL_H
|
77
swbluetoothcontrol.ui
Normal file
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SWBlueToothControl</class>
|
||||
<widget class="QWidget" name="SWBlueToothControl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>255</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="SWDialButton" name="_buttonScan">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>5</x>
|
||||
<y>210</y>
|
||||
<width>150</width>
|
||||
<height>42</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Josefin Sans</family>
|
||||
<pointsize>14</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTipDuration">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
padding-bottom: 0px;
|
||||
margin-left: 0px;
|
||||
border: 2px solid gray;
|
||||
border-radius: 3px;
|
||||
border-color: rgb( 66,66,66 );
|
||||
background:rgb(44,44,44);
|
||||
color: rgb( 181, 181, 181 );
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
border-color: white;
|
||||
}
|
||||
|
||||
QPushButton:checked
|
||||
{
|
||||
background:rgb(99,99,99);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>start scan</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SWDialButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>swdialbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
126
swbuttongroup.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
#include <swbuttongroup.h>
|
||||
|
||||
#include <raDIYoglobals.h>
|
||||
#include <swradiobutton.h>
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
|
||||
SWDialButtonGroup::SWDialButtonGroup(QObject *parent)
|
||||
: QButtonGroup{parent}
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SWDialButtonGroup::addKeyButton( SWRadioButton* button, int id, const QString& key )
|
||||
{
|
||||
button->setKey( key );
|
||||
QButtonGroup::addButton( button, id );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gibt den Button mit gegebenen ID zurück
|
||||
*/
|
||||
|
||||
SWRadioButton& SWDialButtonGroup::buttonAt( int id )
|
||||
{
|
||||
// Du HONK! Das ist der Index, _nicht_ die ID
|
||||
//return *( dynamic_cast<SWDialButton*>( buttons().at( id ) ) );
|
||||
return *( dynamic_cast<SWRadioButton*>( button( id ) ) );
|
||||
|
||||
}
|
||||
|
||||
void SWDialButtonGroup::setCurrentActiveId( int newID )
|
||||
{
|
||||
// schon Ok, dass darf vorkommen
|
||||
//Q_ASSERT( newID >= 0 );
|
||||
//Q_ASSERT( newID < buttons().size() );
|
||||
if( newID >= 0 && newID < buttons().size() )
|
||||
{
|
||||
// unhover & uncheck current button
|
||||
if( _hoverdID > -1 )
|
||||
buttonAt( _hoverdID ).unHover();
|
||||
_checkedID = _hoverdID = newID;
|
||||
buttonAt(_checkedID ).setChecked( true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 'Klick' von aussen, kommt von den RotaryDials.
|
||||
* Wird 'umgewandelt' in SIGNAL 'idClicked'
|
||||
*/
|
||||
|
||||
void SWDialButtonGroup::onDialPushed()
|
||||
{
|
||||
|
||||
Q_ASSERT( _hoverdID >= 0 );
|
||||
Q_ASSERT( _hoverdID < buttons().size() );
|
||||
|
||||
emit idClicked( _hoverdID );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param delta
|
||||
* Schiebt den 'Hover'-Anzeigestatus zum nächsten Button innerhalb der Buttongroup.
|
||||
* @param forward Vorwärts, also auf dem Bildschirm nach rechts oder eben nach links.
|
||||
*
|
||||
* Das ist ein Hack: Ich möchte einem einzelnen Button den Focus, also hier den Hover-Zustand
|
||||
* aus dem Programm heraus zuweisen. Das wird für die Steuerung per RotaryDial gebraucht.
|
||||
* Experimente ::notify( QHoverEvent( QHoverEnter ... ) waren erstmal ohne Wirkung.
|
||||
* Derzeit wird einfach ein ge-hovertes (helleres) Icon gesetzt.
|
||||
*/
|
||||
|
||||
void SWDialButtonGroup::onDialDeltaChanged( int delta )
|
||||
{
|
||||
|
||||
int listSize = buttons().size();
|
||||
if( !listSize )
|
||||
return;
|
||||
|
||||
// hatten wir schon einen button ge-hovert?
|
||||
if( _hoverdID > -1 )
|
||||
buttonAt( _hoverdID ).unHover();
|
||||
|
||||
// wir sucne den nächsten Button zum Hovern, einen,
|
||||
// der nicht 'gecheckt' oder 'unsichtbar' ist.
|
||||
//SWRadioButton* tmpBtn = nullptr;
|
||||
QAbstractButton* tmpBtn = nullptr;
|
||||
|
||||
do
|
||||
{
|
||||
_hoverdID = ( _hoverdID + delta ) % listSize;
|
||||
if( _hoverdID < 0 )
|
||||
_hoverdID = listSize - 1;
|
||||
|
||||
//tmpBtn = buttons().at( _hoverdID );
|
||||
tmpBtn = button( _hoverdID );
|
||||
}
|
||||
while( !tmpBtn->isEnabled()|| tmpBtn->isChecked() || !tmpBtn->isVisible() );
|
||||
//while( !tmpBtn->isVisible() );
|
||||
|
||||
buttonAt( _hoverdID ).hover();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
53
swbuttongroup.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWBUTTONGROUP_H
|
||||
#define SWBUTTONGROUP_H
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QObject>
|
||||
#include <swdialhandler.h>
|
||||
|
||||
|
||||
class SWRadioButton;
|
||||
|
||||
|
||||
class SWDialButtonGroup : public QButtonGroup, public SWDialHandler
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
explicit SWDialButtonGroup(QObject *parent = nullptr);
|
||||
|
||||
|
||||
void addKeyButton( SWRadioButton* button, int id, const QString& key );
|
||||
SWRadioButton& buttonAt( int id );
|
||||
|
||||
void setCurrentActiveId( int newID );
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
void onDialPushed() override;
|
||||
void onDialDeltaChanged( int delta ) override;
|
||||
|
||||
protected:
|
||||
|
||||
int _checkedID = -1; // die aktive, ge-checkte id
|
||||
int _hoverdID = -1; // die vom Dial ge-hoverte id
|
||||
|
||||
};
|
||||
|
||||
#endif // SWBUTTONGROUP_H
|
136
swclockcontrol.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QKeyEvent>
|
||||
#include <QTime>
|
||||
#include <QAction>
|
||||
|
||||
#include <swclockcontrol.h>
|
||||
|
||||
|
||||
|
||||
SWClockControl::SWClockControl( QWidget* parent, QSettings* settings )
|
||||
: SWControl( parent, settings )
|
||||
{
|
||||
setupUi( this );
|
||||
setAcceptDial( false );
|
||||
|
||||
|
||||
|
||||
_flipHour->setTransition ( SWFlipDigit::Flip );
|
||||
_flipMinute->setTransition( SWFlipDigit::Flip );
|
||||
_flipSecond->setTransition( SWFlipDigit::Flip );
|
||||
|
||||
_flipHour->show();
|
||||
_flipMinute->show();
|
||||
_flipSecond->show();
|
||||
|
||||
QPalette pal = palette();
|
||||
pal.setColor( QPalette::Window, Qt::black );
|
||||
setPalette( pal );
|
||||
|
||||
_ticker.start( 1000, this );
|
||||
QTime time = QTime::currentTime();
|
||||
_flipHour->setValue( time.hour() );
|
||||
_flipMinute->setValue( time.minute() );
|
||||
|
||||
updateTime();
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWClockControl::~SWClockControl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SWClockControl::updateTime()
|
||||
{
|
||||
QTime now = QTime::currentTime();
|
||||
_flipHour->flipTo( now.hour() );
|
||||
_flipMinute->flipTo( now.minute() );
|
||||
_flipSecond->flipTo( now.second() );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SWClockControl::switchTransition( int delta )
|
||||
{
|
||||
int i = ( _flipHour->transition() + delta + 3) % 3;
|
||||
_flipHour->setTransition( (SWFlipDigit::FlipMode) i );
|
||||
_flipMinute->setTransition( (SWFlipDigit::FlipMode) i );
|
||||
updateTime();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void SWClockControl::resizeEvent(QResizeEvent*)
|
||||
{
|
||||
int digitsWidth = width() / 3;
|
||||
int digitsHeight = digitsWidth * 1.2;
|
||||
|
||||
int y = (double) (height() - digitsHeight) / 1.8;
|
||||
|
||||
_flipHour->resize( digitsWidth, digitsHeight );
|
||||
_flipHour->move( 0, y );
|
||||
|
||||
_flipMinute->resize( digitsWidth, digitsHeight );
|
||||
_flipMinute->move( width() / 3, y );
|
||||
|
||||
_flipSecond->resize( digitsWidth, digitsHeight );
|
||||
_flipSecond->move( width() /3 * 2, y );
|
||||
}
|
||||
*/
|
||||
|
||||
void SWClockControl::timerEvent( QTimerEvent* event )
|
||||
{
|
||||
Q_UNUSED( event )
|
||||
updateTime();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SWClockControl::chooseSlide()
|
||||
{
|
||||
_flipHour->setTransition( SWFlipDigit::Slide );
|
||||
_flipMinute->setTransition( SWFlipDigit::Slide );
|
||||
_flipSecond->setTransition( SWFlipDigit::Slide );
|
||||
updateTime();
|
||||
}
|
||||
|
||||
|
||||
void SWClockControl::chooseFlip()
|
||||
{
|
||||
_flipHour->setTransition( SWFlipDigit::Flip );
|
||||
_flipMinute->setTransition( SWFlipDigit::Flip );
|
||||
_flipSecond->setTransition( SWFlipDigit::Flip );
|
||||
updateTime();
|
||||
}
|
||||
|
||||
|
||||
void SWClockControl::chooseRotate()
|
||||
{
|
||||
_flipHour->setTransition( SWFlipDigit::Rotate );
|
||||
_flipMinute->setTransition( SWFlipDigit::Rotate );
|
||||
_flipSecond->setTransition( SWFlipDigit::Rotate );
|
||||
updateTime();
|
||||
}
|
||||
|
||||
|
||||
|
60
swclockcontrol.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWCLOCKCONTROL_H
|
||||
#define SWCLOCKCONTROL_H
|
||||
|
||||
#include <QBasicTimer>
|
||||
#include <swcontrol.h>
|
||||
#include <swflipdigit.h>
|
||||
#include <ui_swclockcontrol.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Das Clock-Control ist die 'Hauptseite' der RaDIYo-Gui und zeigt die
|
||||
* Uhrzeit als FlipClock an.
|
||||
* @see SWControl
|
||||
* @see SWFlipDigit
|
||||
*/
|
||||
|
||||
class SWClockControl : public SWControl, private Ui_SWClock
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit SWClockControl( QWidget* parent, QSettings* settings );
|
||||
virtual ~SWClockControl();
|
||||
|
||||
void timerEvent( QTimerEvent* event ) override;
|
||||
|
||||
void updateTime();
|
||||
void switchTransition( int delta );
|
||||
|
||||
protected slots:
|
||||
|
||||
void chooseSlide();
|
||||
void chooseFlip();
|
||||
void chooseRotate();
|
||||
|
||||
protected:
|
||||
|
||||
QBasicTimer _ticker;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SWCLOCKCONTROL_H
|
66
swclockcontrol.ui
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SWClock</class>
|
||||
<widget class="QWidget" name="SWClock">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>275</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="SWFlipDigit" name="_flipHour" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>42</y>
|
||||
<width>254</width>
|
||||
<height>215</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:darkBlue</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWFlipDigit" name="_flipMinute" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>274</x>
|
||||
<y>42</y>
|
||||
<width>254</width>
|
||||
<height>215</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:darkBlue</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="SWFlipDigit" name="_flipSecond" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>537</x>
|
||||
<y>42</y>
|
||||
<width>254</width>
|
||||
<height>215</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:darkBlue</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SWFlipDigit</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>swflipdigit.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
115
swcontrol.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QLinearGradient>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <swcontrol.h>
|
||||
|
||||
|
||||
SWControl::SWControl( QWidget* parent, QSettings* settings )
|
||||
: QWidget( parent ), _settings{ settings }
|
||||
{
|
||||
|
||||
_effect = new QGraphicsOpacityEffect;
|
||||
//setGraphicsEffect( _effect );
|
||||
|
||||
_animFadeIn = new QPropertyAnimation( _effect, "opacity" );
|
||||
_animFadeIn->setDuration( SWFadingDuration );
|
||||
_animFadeIn->setStartValue( 0.0 );
|
||||
_animFadeIn->setEndValue( 1.0 );
|
||||
//_animFadeIn->setEasingCurve( QEasingCurve::InBack );
|
||||
|
||||
_animFadeOut = new QPropertyAnimation( _effect, "opacity" );
|
||||
_animFadeOut->setDuration( SWFadingDuration );
|
||||
_animFadeOut->setStartValue( 1.0 );
|
||||
_animFadeOut->setEndValue( 0.0 );
|
||||
//_animFadeOut->setEasingCurve( QEasingCurve::OutBack );
|
||||
|
||||
connect( _animFadeOut, &QPropertyAnimation::finished, [=] { hide(); } );
|
||||
hide();
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWControl::~SWControl()
|
||||
{
|
||||
// ??
|
||||
//saveSettings();
|
||||
delete _effect;
|
||||
delete _animFadeIn;
|
||||
delete _animFadeOut;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QSettings& SWControl::settings()
|
||||
{
|
||||
Q_ASSERT( nullptr != _settings );
|
||||
return *_settings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Wird beim vor dem Einblenden des Controls
|
||||
* aufgerufen, um ggf. eine Eingabemaske vorzubereiten.
|
||||
* Die Funktion ist nur dann nötig, wenn Eingabemöglichkeiten
|
||||
* vorhanden sind, deswegen nicht abstract sondern in einer
|
||||
* dummy-Implementierung
|
||||
*/
|
||||
|
||||
void SWControl::onShow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Wird nach dem Ausblenden des Controls aufgerufen.
|
||||
* @see onShow()
|
||||
*/
|
||||
|
||||
void SWControl::onHide()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Blendet das Control ein
|
||||
* @see onShow()
|
||||
*/
|
||||
|
||||
void SWControl::fadeIn()
|
||||
{
|
||||
onShow();
|
||||
show();
|
||||
setGraphicsEffect( _effect );
|
||||
_animFadeIn->start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Blendet das Control aus
|
||||
* @see onHide()
|
||||
*/
|
||||
|
||||
void SWControl::fadeOut()
|
||||
{
|
||||
onHide();
|
||||
setGraphicsEffect( _effect );
|
||||
_animFadeOut->start();
|
||||
}
|
||||
|
66
swcontrol.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWCONTROL_H
|
||||
#define SWCONTROL_H
|
||||
|
||||
|
||||
#include <QSettings>
|
||||
#include <QWidget>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
|
||||
#include <swdialhandler.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Basisklasse für alle 'Controls'. Erbt von QWidget und stellt
|
||||
* die Basisfunktionalität aller Controls zur Verfügung:
|
||||
* - Animiertes Ein- und Ausblenden der Benutzeroberfläche
|
||||
* - Automatischen Laden und Sichern der Nutzerdaten beim Aktivieren und Deaktivieren.
|
||||
* @see SWClockControl etc.
|
||||
*/
|
||||
|
||||
class SWControl : public QWidget, public SWDialHandler
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit SWControl( QWidget* parent, QSettings* settings );
|
||||
virtual ~SWControl();
|
||||
|
||||
virtual void fadeIn();
|
||||
virtual void fadeOut();
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void onShow();
|
||||
virtual void onHide();
|
||||
|
||||
protected:
|
||||
|
||||
QSettings& settings();
|
||||
|
||||
static const int SWFadingDuration = 650;
|
||||
|
||||
QSettings* _settings = nullptr;
|
||||
QGraphicsOpacityEffect* _effect = nullptr;
|
||||
QPropertyAnimation* _animFadeIn = nullptr;
|
||||
QPropertyAnimation* _animFadeOut = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif // SWCONTROL_H
|
43
swdialbutton.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
||||
#include <swdialbutton.h>
|
||||
#include <QDebug>
|
||||
|
||||
/**
|
||||
* @brief Standardkostruktor.
|
||||
*/
|
||||
|
||||
SWDialButton::SWDialButton( QWidget* parent )
|
||||
: QPushButton( parent )
|
||||
{
|
||||
setAcceptDial( false );
|
||||
// clicks auf mich weiterleiten
|
||||
connect( this, &QPushButton::clicked, this, [=]{ emit widgetClicked(this); } );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Zeichnet diesen Button. Überschriebene Methode, ruft zusätzlich zu
|
||||
* @see QPushButton::paintEvent( event ) auch @drawMark() auf, um
|
||||
* den Button ggf. als 'aktiviert', als Bereit zur Eingabe per RotaryDial,
|
||||
* darzustellen.
|
||||
*/
|
||||
|
||||
void SWDialButton::paintEvent( QPaintEvent *event )
|
||||
{
|
||||
QPushButton::paintEvent( event );
|
||||
drawMark( this );
|
||||
}
|
53
swdialbutton.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWDIALBUTTON_H
|
||||
#define SWDIALBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QDebug>
|
||||
|
||||
#include <swdialwidget.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Ein QPushButtonder der sich programmatisch 'hovern'
|
||||
* und per RotaryControl bedienen lässt.
|
||||
*
|
||||
* @see QPushButton,
|
||||
* @see SWDialWidget
|
||||
*/
|
||||
|
||||
class SWDialButton : public QPushButton, public SWDialWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit SWDialButton( QWidget* parent = nullptr );
|
||||
virtual ~SWDialButton() = default;
|
||||
|
||||
signals:
|
||||
|
||||
void widgetClicked( SWDialWidget* );
|
||||
|
||||
protected:
|
||||
|
||||
void paintEvent( QPaintEvent* ) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // SWDIALBUTTON_H
|
107
swdialcontrol.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <swdialcontrol.h>
|
||||
|
||||
|
||||
|
||||
SWDialControl::SWDialControl( QWidget* parent, QSettings* settings )
|
||||
: SWBaseControl( parent, settings )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sammelt alle Kindwidgets, die den Aspekt 'SWDialWidget' implementieren.
|
||||
* Wird im Konstruktor aufgerufen.
|
||||
* @see SWDialWidget
|
||||
*/
|
||||
|
||||
void SWDialControl::collectDialWidgets()
|
||||
{
|
||||
|
||||
// speichert die Dialwidgets sortiert nach ihrem AccessibleName
|
||||
// über den namen wird eine 'KlickOrder' im Sinne einer TabOrder simuliert
|
||||
QMap<QString, SWDialWidget*> tmpMap;
|
||||
QList<QWidget*> widgets = findChildren<QWidget*>();
|
||||
for( QWidget* entry : widgets )
|
||||
{
|
||||
SWDialWidget* dialWdgt = dynamic_cast<SWDialWidget*>( entry );
|
||||
if( nullptr != dialWdgt )
|
||||
{
|
||||
tmpMap.insert( entry->accessibleName(), dialWdgt );
|
||||
_crntIdx = 0;
|
||||
}
|
||||
}
|
||||
// die nach namen sortierten DialWidgets unter beibehaltung der Reihenfolge
|
||||
// ins _dialWidgets Array übernehmen
|
||||
for( SWDialWidget* dialWdgt : tmpMap )
|
||||
_dialWidgets.append( dialWdgt );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gibt das aktuell aktive DialWidget zurück
|
||||
*/
|
||||
|
||||
SWDialWidget& SWDialControl::current()
|
||||
{
|
||||
Q_ASSERT( _crntIdx > -1 && _crntIdx < _dialWidgets.size() );
|
||||
return *_dialWidgets[ _crntIdx ];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Wird beim Drücken des RotaryDials aufgerufen.
|
||||
* Das Signal wir an das aktuell aktive Control
|
||||
* weitergereicht.
|
||||
*/
|
||||
|
||||
void SWDialControl::onDialPushed()
|
||||
{
|
||||
|
||||
if( current().acceptDial() )
|
||||
current().toggleDialInput();
|
||||
onWidgetClicked( ¤t() );
|
||||
update();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Wird beim Drehen des RotaryDials aufgerufen.
|
||||
* @param value die Winkelstellung, also der Zahlenwert, des RotaryDials.
|
||||
* Wird an das aktuell aktive Dial weitergereicht.
|
||||
*/
|
||||
|
||||
void SWDialControl::onDialDeltaChanged( int delta )
|
||||
{
|
||||
|
||||
// weiterreichen falls erwünscht...
|
||||
if( current().hasDialInput() )
|
||||
return current().onDialDeltaChanged( delta );
|
||||
|
||||
// ...sonst zum nächtsten Handler 'weiterdrehen'
|
||||
current().setHightlighted( false );
|
||||
_crntIdx = ( _crntIdx + delta ) % _dialWidgets.size();
|
||||
if( _crntIdx < 0 )
|
||||
_crntIdx = _dialWidgets.size() - 1;
|
||||
current().setHightlighted( true );
|
||||
update();
|
||||
}
|
61
swdialcontrol.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWDIALCONTROL_H
|
||||
#define SWDIALCONTROL_H
|
||||
|
||||
#include <QButtonGroup>
|
||||
|
||||
#include <swbasecontrol.h>
|
||||
#include <swsetupcontrol.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Basisklasse für Controls, die über eine eigene Benutzeroberfläche verfügen.
|
||||
*
|
||||
* Die einzelnen Kind-elemente (Buttons, Switches, Digits ...) können per DialControl angesteuert
|
||||
* und ausgelöst werden werden.
|
||||
*/
|
||||
|
||||
class SWDialControl : public SWBaseControl
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit SWDialControl( QWidget* parent, QSettings* settings );
|
||||
virtual ~SWDialControl() = default;
|
||||
|
||||
public slots:
|
||||
|
||||
void onDialPushed() override;
|
||||
void onDialDeltaChanged( int delta ) override;
|
||||
|
||||
virtual void onWidgetClicked( SWDialWidget* ) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
void collectDialWidgets();
|
||||
SWDialWidget& current();
|
||||
|
||||
using SWDialList = QVector<SWDialWidget*>;
|
||||
|
||||
SWDialList _dialWidgets;
|
||||
int _crntIdx = -1;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SWDIALCONTROL_H
|
52
swdialhandler.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
|
||||
#include <swdialhandler.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Ist die Reaktion auf Rotarydials eingeschaltet?
|
||||
*/
|
||||
|
||||
bool SWDialHandler::acceptDial()
|
||||
{
|
||||
return _acceptDial;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Schaltet die Reaktion auf Rotarydials ein oder aus.
|
||||
* @param acceptDial
|
||||
*/
|
||||
|
||||
void SWDialHandler::setAcceptDial( bool acceptDial )
|
||||
{
|
||||
_acceptDial = acceptDial;
|
||||
}
|
||||
|
||||
|
||||
void SWDialHandler::onDialPushed()
|
||||
{
|
||||
qDebug() << "BASE SWDialHandler::onDialPushed";
|
||||
}
|
||||
|
||||
|
||||
void SWDialHandler::onDialDeltaChanged( int )
|
||||
{
|
||||
qDebug() << "BASE SWDialHandler::onDialDeltaChanged";
|
||||
}
|
52
swdialhandler.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SWDIALHANDLER_H
|
||||
#define SWDIALHANDLER_H
|
||||
|
||||
|
||||
/**
|
||||
* @brief Modelliert den Aspekt des 'Empfangenkönnens' von Signals eines RotaryDials.
|
||||
*
|
||||
* Wird den entsprechenden Unterklassen per Mehrfachvererbung zugeordnet.
|
||||
*
|
||||
* @see SWControl
|
||||
* @see SWDialButtonGroup
|
||||
* @see SWBarWidget
|
||||
* @see SWDialWidget
|
||||
*/
|
||||
|
||||
class SWDialHandler
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
explicit SWDialHandler() = default;
|
||||
virtual ~SWDialHandler() = default;
|
||||
|
||||
bool acceptDial();
|
||||
void setAcceptDial( bool acceptDial );
|
||||
|
||||
// wir sind kein QObject, deshalb keine public slots
|
||||
virtual void onDialPushed();
|
||||
virtual void onDialDeltaChanged( int value );
|
||||
|
||||
protected:
|
||||
|
||||
bool _acceptDial = true;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SWDIALHANDLER_H
|
72
swdialwidget.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/***************************************************************************
|
||||
|
||||
source::worx raDIYo
|
||||
Copyright © 2020-2022 c.holzheuer
|
||||
chris@sourceworx.org
|
||||
|
||||
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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
|
||||
#include <swdialwidget.h>
|
||||
|
||||
|
||||
//??
|
||||
const QPen SWDialWidget::MarkPen1 = QPen( Qt::white, 4 );
|
||||
const QPen SWDialWidget::MarkPen2 = QPen( Qt::darkRed, 4 );
|
||||
|
||||
|
||||
const QPen& SWDialWidget::getPen()
|
||||
{
|
||||
if( hasDialInput() )
|
||||
return MarkPen2;
|
||||
return MarkPen1;
|
||||
}
|
||||
|
||||
|
||||
bool SWDialWidget::isHighlighted()
|
||||
{
|
||||
return _isHighlighted;
|
||||
}
|
||||
|
||||
|
||||
void SWDialWidget::setHightlighted( bool marked )
|
||||
{
|
||||
_isHighlighted = marked;
|
||||
|
||||
}
|
||||
|
||||
bool SWDialWidget::hasDialInput()
|
||||
{
|
||||
return _hasDialInput;
|
||||
}
|
||||
|
||||
void SWDialWidget::toggleDialInput()
|
||||
{
|
||||
setDialInput( !hasDialInput() );
|
||||
}
|
||||
|
||||
void SWDialWidget::setDialInput( bool active )
|
||||
{
|
||||
_hasDialInput = active;
|
||||
}
|
||||
|
||||
|
||||
void SWDialWidget::drawMark( QWidget* target )
|
||||
{
|
||||
if( !isHighlighted() )
|
||||
return;
|
||||
|
||||
QPainter painter( target );
|
||||
painter.setPen( getPen() );
|
||||
painter.setBrush( Qt::NoBrush );
|
||||
//painter.drawRect( target->rect() );
|
||||
painter.drawRoundedRect( target->rect(), 8, 8 );
|
||||
}
|