Merge branch 'qt5' of https://github.com/Chocobozzz/Clementine into qt5
This commit is contained in:
commit
074e3ba04a
|
@ -9,7 +9,7 @@ set(HEADERS
|
|||
fancytabwidget.h
|
||||
)
|
||||
|
||||
qt4_wrap_cpp(MOC ${HEADERS})
|
||||
qt5_wrap_cpp(MOC ${HEADERS})
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Stefan Derkits <stefan@derkits.at>
|
||||
Christian Wagner <christian.wagner86@gmx.at>
|
||||
Felix Winter <ixos01@gmail.com>
|
|
@ -0,0 +1,50 @@
|
|||
cmake_minimum_required( VERSION 2.6 FATAL_ERROR )
|
||||
|
||||
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII" )
|
||||
|
||||
set(MYGPO_QT_VERSION_SUFFIX 5)
|
||||
|
||||
macro(qt_wrap_cpp)
|
||||
qt5_wrap_cpp(${ARGN})
|
||||
endmacro()
|
||||
|
||||
# pkg-config names of QtCore and QtNetwork are Qt5Core and Qt5Network for
|
||||
# Qt5
|
||||
set(MYGPO_QT_MAJOR_VERSION "5")
|
||||
set(MYGPO_QT4_QJSON_DEP "")
|
||||
|
||||
# Don't use absolute path in Mygpo-qtTargets-$buildType.cmake
|
||||
# (This will have no effect with CMake < 2.8)
|
||||
# set(QT_USE_IMPORTED_TARGETS TRUE)
|
||||
|
||||
set( MYGPO_QT_VERSION_MAJOR "1" )
|
||||
set( MYGPO_QT_VERSION_MINOR "0" )
|
||||
set( MYGPO_QT_VERSION_PATCH "8" )
|
||||
set( MYGPO_QT_VERSION "${MYGPO_QT_VERSION_MAJOR}.${MYGPO_QT_VERSION_MINOR}.${MYGPO_QT_VERSION_PATCH}" )
|
||||
|
||||
#Configure Version.h.in with the actual version number
|
||||
configure_file( src/Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/Version.h )
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
ADD_DEFINITIONS( -Wcast-align -Wchar-subscripts -Wpointer-arith
|
||||
-Wwrite-strings -Wpacked -Wformat-security -Wmissing-format-attribute
|
||||
-Wold-style-cast -Woverloaded-virtual -Wnon-virtual-dtor -Wall -Wextra
|
||||
-Wformat=2 -Wundef -Wstack-protector -Wmissing-include-dirs
|
||||
-Winit-self -Wunsafe-loop-optimizations -ggdb3 -fno-inline -DQT_STRICT_ITERATORS )
|
||||
if ( NOT WIN32 )
|
||||
add_definitions( -fvisibility=hidden )
|
||||
endif()
|
||||
|
||||
check_cxx_compiler_flag( -Wlogical-op GNUCXX_HAS_WLOGICAL_OP )
|
||||
if ( GNUCXX_HAS_WLOGICAL_OP )
|
||||
add_definitions( -Wlogical-op )
|
||||
endif()
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
|
||||
set(MYGPO_QT_TARGET_NAME mygpo-qt${MYGPO_QT_VERSION_SUFFIX} CACHE INTERNAL "" FORCE )
|
||||
|
||||
add_subdirectory( src )
|
|
@ -0,0 +1,502 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
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 this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser 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 Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "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
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY 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
|
||||
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey 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 library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
|
@ -0,0 +1,18 @@
|
|||
get_filename_component(myDir ${CMAKE_CURRENT_LIST_FILE} PATH) # get the directory where I myself am
|
||||
get_filename_component(rootDir ${myDir}/@relInstallDir@ ABSOLUTE) # get the chosen install prefix
|
||||
|
||||
# set the version of myself
|
||||
set(MYGPO_QT_VERSION_MAJOR @MYGPO_QT_VERSION_MAJOR@)
|
||||
set(MYGPO_QT_VERSION_MINOR @MYGPO_QT_VERSION_MINOR@)
|
||||
set(MYGPO_QT_VERSION_PATCH @MYGPO_QT_VERSION_PATCH@)
|
||||
set(MYGPO_QT_VERSION ${MYGPO_QT_VERSION_MAJOR}.${MYGPO_QT_VERSION_MINOR}.${MYGPO_QT_VERSION_PATCH} )
|
||||
|
||||
# what is my include directory
|
||||
set(LIBMYGPO_QT_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@")
|
||||
|
||||
# import the exported targets
|
||||
include(${myDir}/Mygpo-qtTargets.cmake)
|
||||
|
||||
# set the expected library variable
|
||||
set(LIBMYGPO_QT_LIBRARIES mygpo-qt )
|
||||
set(LIBMYGPO_QT_FOUND "True")
|
|
@ -0,0 +1,10 @@
|
|||
set(PACKAGE_VERSION @MYGPO_QT_VERSION_MAJOR@.@MYGPO_QT_VERSION_MINOR@.@MYGPO_QT_VERSION_PATCH@)
|
||||
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
|
||||
endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
|
@ -0,0 +1,52 @@
|
|||
========== README ==========
|
||||
|
||||
=== What is libmygpo-qt ===
|
||||
|
||||
libmygpo-qt is a Qt Library that wraps the gpodder.net Web API (http://wiki.gpodder.org/wiki/Web_Services/API_2)
|
||||
|
||||
=== Copyright & License ===
|
||||
|
||||
Copyright 2010 - 2014 Stefan Derkits (stefan@derkits.at) , Christian Wagner (christian.wagner86@gmx.at) & Felix Winter (ixos01@gmail.com)
|
||||
|
||||
See COPYING File for License
|
||||
|
||||
=== Maintainer ===
|
||||
|
||||
Current Maintainer: Stefan Derkits (HorusHorrendus @ irc.freenode.net)
|
||||
|
||||
=== Requirements ===
|
||||
|
||||
-) Qt 4.6 or higher
|
||||
-) Cmake 2.6 or higher
|
||||
-) QJson
|
||||
|
||||
=== Qt5 Support ===
|
||||
|
||||
libmygpo-qt version 1.0.8 supports also building the library with Qt5. The API is the same as in the Qt4 library. To build the library with Qt5 add "-DBUILD_WITH_QT4=OFF" to your CMake
|
||||
command line. Please note that Qt5 support is still experimental. If you find anything to not work with Qt5, please report a bug.
|
||||
|
||||
==== Qt5 Requirements ===
|
||||
|
||||
-) CMake 2.8.9 or higher
|
||||
-) Qt 5.2 or higher
|
||||
|
||||
=== Links ===
|
||||
|
||||
Homepage: http://wiki.gpodder.org/wiki/Libmygpo-qt
|
||||
Git Repo: https://github.com/gpodder/libmygpo-qt
|
||||
Doxygen Documentation: http://stefan.derkits.at/libmygpo-doc/
|
||||
Bugreports: http://bugs.gpodder.org
|
||||
Contact: gpodder@freelists.org
|
||||
IRC Channel: #gpodder on FreeNode (irc.freenode.net)
|
||||
|
||||
=== How to Install ===
|
||||
|
||||
-) Create Directory "build"
|
||||
-) change into build and run "cmake .. -DCMAKE_BUILD_TYPE=Debug"
|
||||
-) make
|
||||
-) make install (might need root)
|
||||
|
||||
To use libmygpo-qt include the Header "ApiRequest.h" into your Code. You can find the cflags & linker flags for libmygpo-qt either via pkg-config (.pc file will be installed to your System)
|
||||
or via cmake (Mygpo-qtConfig.cmake will be installed to your system).
|
||||
|
||||
You can check the Example Application to see how you can use libmygpo-qt in your Application
|
|
@ -0,0 +1,50 @@
|
|||
# Find QJSON - JSON handling library for Qt
|
||||
#
|
||||
# This module defines
|
||||
# QJSON_FOUND - whether the qsjon library was found
|
||||
# QJSON_LIBRARIES - the qjson library
|
||||
# QJSON_INCLUDE_DIR - the include path of the qjson library
|
||||
#
|
||||
|
||||
if (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES)
|
||||
|
||||
# Already in cache
|
||||
set (QJSON_FOUND TRUE)
|
||||
|
||||
else (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES)
|
||||
|
||||
if (NOT WIN32)
|
||||
# use pkg-config to get the values of QJSON_INCLUDE_DIRS
|
||||
# and QJSON_LIBRARY_DIRS to add as hints to the find commands.
|
||||
include (FindPkgConfig)
|
||||
pkg_check_modules (QJSON REQUIRED QJson>=0.5)
|
||||
endif (NOT WIN32)
|
||||
|
||||
find_library (QJSON_LIBRARIES
|
||||
NAMES
|
||||
qjson
|
||||
PATHS
|
||||
${QJSON_LIBRARY_DIRS}
|
||||
${LIB_INSTALL_DIR}
|
||||
${KDE4_LIB_DIR}
|
||||
)
|
||||
|
||||
find_path (QJSON_INCLUDE_DIR
|
||||
NAMES
|
||||
parser.h
|
||||
PATH_SUFFIXES
|
||||
qjson
|
||||
PATHS
|
||||
${QJSON_INCLUDE_DIRS}
|
||||
${INCLUDE_INSTALL_DIR}
|
||||
${KDE4_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(QJSON DEFAULT_MSG QJSON_LIBRARIES QJSON_INCLUDE_DIR)
|
||||
|
||||
if ( UNIX AND NOT APPLE )
|
||||
set ( QJSON_LIBRARIES "${QJSON_LIBRARIES} ${QJSON_LDFLAGS}" CACHE INTERNAL "")
|
||||
endif ()
|
||||
|
||||
endif (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES)
|
|
@ -20,11 +20,11 @@
|
|||
* USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include <parser.h>
|
||||
|
||||
#include "AddRemoveResult.h"
|
||||
#include "AddRemoveResult_p.h"
|
||||
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
AddRemoveResultPrivate::AddRemoveResultPrivate( AddRemoveResult* qq, QNetworkReply* reply ) : q( qq ), m_reply( reply ), m_error( QNetworkReply::NoError )
|
||||
|
@ -64,7 +64,6 @@ QList< QPair< QUrl, QUrl > > AddRemoveResultPrivate::updateUrlsList() const
|
|||
|
||||
bool AddRemoveResultPrivate::parse( const QVariant& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
if( !data.canConvert( QVariant::Map ) )
|
||||
return false;
|
||||
QVariantMap resultMap = data.toMap();
|
||||
|
@ -78,9 +77,8 @@ bool AddRemoveResultPrivate::parse( const QVariant& data )
|
|||
|
||||
bool AddRemoveResultPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
|
@ -1,6 +1,6 @@
|
|||
/***************************************************************************
|
||||
* This file is part of libmygpo-qt *
|
||||
* Copyright (c) 2010 - 2013 Stefan Derkits <stefan@derkits.at> *
|
||||
* Copyright (c) 2010 - 2014 Stefan Derkits <stefan@derkits.at> *
|
||||
* Copyright (c) 2010 - 2011 Christian Wagner <christian.wagner86@gmx.at> *
|
||||
* Copyright (c) 2010 - 2011 Felix Winter <ixos01@gmail.com> *
|
||||
* *
|
|
@ -1,6 +1,6 @@
|
|||
/***************************************************************************
|
||||
* This file is part of libmygpo-qt *
|
||||
* Copyright (c) 2010 - 2013 Stefan Derkits <stefan@derkits.at> *
|
||||
* Copyright (c) 2010 - 2014 Stefan Derkits <stefan@derkits.at> *
|
||||
* Copyright (c) 2010 - 2011 Christian Wagner <christian.wagner86@gmx.at> *
|
||||
* Copyright (c) 2010 - 2011 Felix Winter <ixos01@gmail.com> *
|
||||
* *
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
*/
|
||||
QNetworkReply* suggestionsOpml( uint count );
|
||||
|
||||
QNetworkReply* downloadSubscriptionsOpml( const QString& username, const QString& device );
|
||||
QNetworkReply* downloadSubscriptionsOpml( const QString& username, const QString& device = QString() );
|
||||
|
||||
/**
|
||||
* Returns the TXT Result for the Simple API Call "Downloading Podcast Toplists"
|
||||
|
@ -111,7 +111,7 @@ public:
|
|||
*/
|
||||
QNetworkReply* suggestionsTxt( uint count );
|
||||
|
||||
QNetworkReply* downloadSubscriptionsTxt( const QString& username, const QString& device );
|
||||
QNetworkReply* downloadSubscriptionsTxt( const QString& username, const QString& device = QString() );
|
||||
|
||||
/**
|
||||
* Returns the TXT Result for the Simple API Call "Downloading Podcast Toplists"
|
||||
|
@ -153,9 +153,9 @@ public:
|
|||
*
|
||||
*/
|
||||
PodcastListPtr suggestions( uint count );
|
||||
|
||||
QNetworkReply* downloadSubscriptionsJson( const QString& username, const QString& device );
|
||||
|
||||
|
||||
QNetworkReply* downloadSubscriptionsJson( const QString& username, const QString& device = QString() );
|
||||
|
||||
//ADVANCED API
|
||||
|
||||
/**
|
|
@ -1,11 +1,5 @@
|
|||
# Extra bits for Clementine.
|
||||
set( MYGPO_QT_VERSION_MAJOR "1" )
|
||||
set( MYGPO_QT_VERSION_MINOR "0" )
|
||||
set( MYGPO_QT_VERSION_PATCH "7" )
|
||||
configure_file( Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/Version.h )
|
||||
include_directories("${QJSON_INCLUDEDIR}/qjson")
|
||||
|
||||
include_directories( ${QT_INCLUDES} ${QJSON_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
|
||||
include_directories( ${QJSON_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
|
||||
|
||||
set ( LIBMYGPO_QT_SRC
|
||||
Config.cpp
|
||||
|
@ -27,6 +21,7 @@ set ( LIBMYGPO_QT_SRC
|
|||
DeviceUpdates.cpp
|
||||
DeviceList.cpp
|
||||
Device.cpp
|
||||
qjsonwrapper/Json.cpp
|
||||
)
|
||||
|
||||
set ( LIBMYGPO_QT_MOC_H
|
||||
|
@ -80,9 +75,9 @@ set ( LIBMYGPO_QT_INSTALL_H
|
|||
AddRemoveResult.h
|
||||
)
|
||||
|
||||
QT4_WRAP_CPP(LIBMYGPO_QT_MOC_SRC ${LIBMYGPO_QT_MOC_H} )
|
||||
QT_WRAP_CPP(LIBMYGPO_QT_MOC_SRC ${LIBMYGPO_QT_MOC_H} )
|
||||
|
||||
add_library( mygpo-qt STATIC ${LIBMYGPO_QT_SRC} ${LIBMYGPO_QT_MOC_SRC} )
|
||||
add_library( ${MYGPO_QT_TARGET_NAME} STATIC ${LIBMYGPO_QT_SRC} ${LIBMYGPO_QT_MOC_SRC} )
|
||||
|
||||
target_link_libraries( mygpo-qt ${QJSON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} )
|
||||
set_target_properties( mygpo-qt PROPERTIES VERSION ${MYGPO_QT_VERSION} SOVERSION ${MYGPO_QT_SONAME} DEFINE_SYMBOL MYGPO_MAKEDLL)
|
||||
target_link_libraries( ${MYGPO_QT_TARGET_NAME} ${QJSON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} )
|
||||
qt5_use_modules( ${MYGPO_QT_TARGET_NAME} Core Network )
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "DeviceList_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -73,9 +73,8 @@ bool DeviceListPrivate::parse( const QVariant& data )
|
|||
|
||||
bool DeviceListPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "DeviceSyncResult_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -85,9 +85,8 @@ bool DeviceSyncResultPrivate::parse( const QVariant& data )
|
|||
|
||||
bool DeviceSyncResultPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
|
@ -108,7 +107,7 @@ void DeviceSyncResultPrivate::parseData()
|
|||
emit q->parseError();
|
||||
}
|
||||
}
|
||||
m_reply->deleteLater();
|
||||
m_reply->deleteLater();
|
||||
}
|
||||
|
||||
void DeviceSyncResultPrivate::error( QNetworkReply::NetworkError error )
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "DeviceUpdates_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -102,9 +102,8 @@ bool DeviceUpdatesPrivate::parse( const QVariant& data )
|
|||
|
||||
bool DeviceUpdatesPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "Episode_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -115,9 +115,8 @@ bool EpisodePrivate::parse ( const QVariant& data )
|
|||
|
||||
bool EpisodePrivate::parse ( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse ( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if ( ok )
|
||||
{
|
||||
if ( !parse ( variant ) ) return false;
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "EpisodeAction_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -163,9 +163,8 @@ bool EpisodeActionPrivate::parseActionType( const QString& data )
|
|||
|
||||
bool EpisodeActionPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
if( !parse( variant ) ) return false;
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "EpisodeActionList_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -88,9 +88,8 @@ bool EpisodeActionListPrivate::parse( const QVariant& data )
|
|||
|
||||
bool EpisodeActionListPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "EpisodeList_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -71,9 +71,8 @@ bool EpisodeListPrivate::parse( const QVariant& data )
|
|||
|
||||
bool EpisodeListPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
|
@ -20,47 +20,44 @@
|
|||
* USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QVariant>
|
||||
//#include <QVariant>
|
||||
#include <QList>
|
||||
#include <QUrl>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <serializer.h>
|
||||
|
||||
#include "JsonCreator.h"
|
||||
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
static qulonglong c_maxlonglong = (2^64)-1;
|
||||
|
||||
QByteArray JsonCreator::addRemoveSubsToJSON( const QList< QUrl >& add, const QList< QUrl >& remove )
|
||||
{
|
||||
QJson::Serializer serializer;
|
||||
QVariantMap jsonData;
|
||||
QVariant addVar( urlListToQVariantList( add ) );
|
||||
QVariant removeVar( urlListToQVariantList( remove ) );
|
||||
jsonData.insert( QString( QLatin1String( "add" ) ), addVar );
|
||||
jsonData.insert( QString( QLatin1String( "remove" ) ), removeVar );
|
||||
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
|
||||
QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) );
|
||||
return jsonByteArray;
|
||||
}
|
||||
|
||||
QByteArray JsonCreator::saveSettingsToJSON( const QMap< QString, QVariant >& set, const QList< QString >& remove )
|
||||
{
|
||||
QJson::Serializer serializer;
|
||||
QVariantMap jsonData;
|
||||
//QVariant setVar(stringMapToQVariantMap(set));
|
||||
QVariant removeVar( stringListToQVariantList( remove ) );
|
||||
jsonData.insert( QString( QLatin1String( "set" ) ), set );
|
||||
jsonData.insert( QString( QLatin1String( "remove" ) ), removeVar );
|
||||
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
|
||||
QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) );
|
||||
return jsonByteArray;
|
||||
}
|
||||
|
||||
QByteArray JsonCreator::episodeActionListToJSON( const QList<EpisodeActionPtr>& episodeActions )
|
||||
{
|
||||
QJson::Serializer serializer;
|
||||
QVariantList jsonData;
|
||||
|
||||
foreach( const EpisodeActionPtr episodeAction, episodeActions )
|
||||
|
@ -68,19 +65,18 @@ QByteArray JsonCreator::episodeActionListToJSON( const QList<EpisodeActionPtr>&
|
|||
jsonData.append( episodeActionToQVariantMap( episodeAction ) );
|
||||
}
|
||||
|
||||
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
|
||||
QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) );
|
||||
return jsonByteArray;
|
||||
}
|
||||
|
||||
QByteArray JsonCreator::renameDeviceStringToJSON( const QString& caption, const QString& type )
|
||||
{
|
||||
QJson::Serializer serializer;
|
||||
QVariantMap jsonData;
|
||||
QVariant captionVar( caption );
|
||||
QVariant typeVar( type );
|
||||
jsonData.insert( QString( QLatin1String( "caption" ) ), captionVar );
|
||||
jsonData.insert( QString( QLatin1String( "type" ) ), typeVar );
|
||||
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
|
||||
QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) );
|
||||
return jsonByteArray;
|
||||
|
||||
}
|
||||
|
@ -130,7 +126,7 @@ QByteArray JsonCreator::deviceSynchronizationListsToJSON(const QList< QStringLis
|
|||
jsonStr.append(syncVar);
|
||||
jsonStr.append(QLatin1String(" ,\"stop-synchronize\" : "));
|
||||
jsonStr.append(stopVar);
|
||||
jsonStr.append(QLatin1String(" }\n"));
|
||||
jsonStr.append(QLatin1String(" }"));
|
||||
return jsonStr.toLocal8Bit();
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "Podcast_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -181,9 +181,8 @@ bool PodcastPrivate::parse( const QVariant& data )
|
|||
|
||||
bool PodcastPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if ( ok )
|
||||
{
|
||||
if ( !parse( variant ) ) return false;
|
||||
|
@ -197,8 +196,6 @@ bool PodcastPrivate::parse( const QByteArray& data )
|
|||
|
||||
void PodcastPrivate::parseData()
|
||||
{
|
||||
//parsen und signal senden
|
||||
QJson::Parser parser;
|
||||
if ( parse( m_reply->readAll( ) ) )
|
||||
{
|
||||
emit q->finished();
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "PodcastList_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -71,9 +71,8 @@ bool PodcastListPrivate::parse( const QVariant& data )
|
|||
|
||||
bool PodcastListPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
|
@ -77,5 +77,5 @@ void RequestHandler::addAuthData( QNetworkRequest& request )
|
|||
|
||||
void RequestHandler::addUserAgent( QNetworkRequest &request )
|
||||
{
|
||||
request.setRawHeader("User-Agent", Config::instance()->userAgent().toAscii() );
|
||||
request.setRawHeader("User-Agent", Config::instance()->userAgent().toLatin1() );
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "Settings_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -49,9 +49,8 @@ bool SettingsPrivate::parse( const QVariant& data )
|
|||
|
||||
bool SettingsPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
|
@ -63,7 +62,6 @@ void SettingsPrivate::parseData()
|
|||
{
|
||||
if( m_reply->error() == QNetworkReply::NoError )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
if( parse( m_reply->readAll() ) )
|
||||
{
|
||||
emit q->finished();
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "TagList_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
|
@ -70,9 +70,8 @@ bool TagListPrivate::parse( const QVariant& data )
|
|||
|
||||
bool TagListPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
|
@ -74,7 +74,8 @@ QString UrlBuilder::getPodcastSearchUrl( const QString& query, Format f )
|
|||
|
||||
QString UrlBuilder::getSubscriptionsUrl( const QString& username, const QString& device, UrlBuilder::Format f)
|
||||
{
|
||||
return s_server % QLatin1String( "/subscriptions/" ) % username % QLatin1String( "/" ) % device % getFormatExtension( f );
|
||||
QString deviceString = device.isNull() ? QString(QLatin1String("")) : (QLatin1String( "/" ) % device);
|
||||
return s_server % QLatin1String( "/subscriptions/" ) % username % deviceString % getFormatExtension( f );
|
||||
}
|
||||
|
||||
QString UrlBuilder::getTopTagsUrl( uint i )
|
|
@ -0,0 +1,123 @@
|
|||
/* Copyright 2014, Uwe L. Korn <uwelk@xhochy.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "Json.h"
|
||||
|
||||
// Qt version specific includes
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
#include <QJsonDocument>
|
||||
#include <QMetaProperty>
|
||||
#else
|
||||
#include <qjson/parser.h>
|
||||
#include <qjson/qobjecthelper.h>
|
||||
#include <qjson/serializer.h>
|
||||
#endif
|
||||
|
||||
namespace QJsonWrapper
|
||||
{
|
||||
|
||||
QVariantMap
|
||||
qobject2qvariant( const QObject* object )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
QVariantMap map;
|
||||
if ( object == NULL )
|
||||
{
|
||||
return map;
|
||||
}
|
||||
|
||||
const QMetaObject* metaObject = object->metaObject();
|
||||
for ( int i = 0; i < metaObject->propertyCount(); ++i )
|
||||
{
|
||||
QMetaProperty metaproperty = metaObject->property( i );
|
||||
if ( metaproperty.isReadable() )
|
||||
{
|
||||
map[ QLatin1String( metaproperty.name() ) ] = object->property( metaproperty.name() );
|
||||
}
|
||||
}
|
||||
return map;
|
||||
#else
|
||||
return QJson::QObjectHelper::qobject2qvariant( object );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qvariant2qobject( const QVariantMap& variant, QObject* object )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
for ( QVariantMap::const_iterator iter = variant.begin(); iter != variant.end(); ++iter )
|
||||
{
|
||||
QVariant property = object->property( iter.key().toLatin1() );
|
||||
Q_ASSERT( property.isValid() );
|
||||
if ( property.isValid() )
|
||||
{
|
||||
QVariant value = iter.value();
|
||||
if ( value.canConvert( property.type() ) )
|
||||
{
|
||||
value.convert( property.type() );
|
||||
object->setProperty( iter.key().toLatin1(), value );
|
||||
} else if ( QString( QLatin1String("QVariant") ).compare( QLatin1String( property.typeName() ) ) == 0 ) {
|
||||
object->setProperty( iter.key().toLatin1(), value );
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
QJson::QObjectHelper::qvariant2qobject( variant, object );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QVariant
|
||||
parseJson( const QByteArray& jsonData, bool* ok )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson( jsonData, &error );
|
||||
if ( ok != NULL )
|
||||
{
|
||||
*ok = ( error.error == QJsonParseError::NoError );
|
||||
}
|
||||
return doc.toVariant();
|
||||
#else
|
||||
QJson::Parser p;
|
||||
return p.parse( jsonData, ok );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QByteArray
|
||||
toJson( const QVariant &variant, bool* ok )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
QJsonDocument doc = QJsonDocument::fromVariant( variant );
|
||||
if ( ok != NULL )
|
||||
{
|
||||
*ok = !doc.isNull();
|
||||
}
|
||||
return doc.toJson( QJsonDocument::Compact );
|
||||
#else
|
||||
QJson::Serializer serializer;
|
||||
return serializer.serialize( variant, ok );
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/* Copyright 2014, Uwe L. Korn <uwelk@xhochy.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef QJSONWRAPPER_JSON_H
|
||||
#define QJSONWRAPPER_JSON_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
namespace QJsonWrapper
|
||||
{
|
||||
QVariantMap qobject2qvariant( const QObject* object );
|
||||
void qvariant2qobject( const QVariantMap& variant, QObject* object );
|
||||
QVariant parseJson( const QByteArray& jsonData, bool* ok = 0 );
|
||||
QByteArray toJson( const QVariant &variant, bool* ok = 0 );
|
||||
}
|
||||
|
||||
#endif // QJSONWRAPPER_JSON_H
|
|
@ -6,7 +6,7 @@ set(HEADERS
|
|||
qprogressindicatorspinning.h
|
||||
)
|
||||
|
||||
qt4_wrap_cpp(MOC_SOURCES ${HEADERS})
|
||||
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND SOURCES
|
||||
|
@ -23,7 +23,7 @@ else()
|
|||
set(RESOURCES
|
||||
qprogressindicatorspinning_nonmac.qrc
|
||||
)
|
||||
qt4_add_resources(RESOURCES_SOURCES ${RESOURCES})
|
||||
qt5_add_resources(RESOURCES_SOURCES ${RESOURCES})
|
||||
endif()
|
||||
|
||||
add_library(Qocoa STATIC
|
||||
|
|
|
@ -5,18 +5,19 @@ add_definitions(-DQT_STATICPLUGIN)
|
|||
# Source files
|
||||
set(SQLITE-SOURCES
|
||||
qsql_sqlite.cpp
|
||||
smain.cpp
|
||||
clementinesqlcachedresult.cpp
|
||||
smain.cpp
|
||||
)
|
||||
|
||||
# Header files that have Q_OBJECT in
|
||||
set(SQLITE-MOC-HEADERS
|
||||
qsql_sqlite.h
|
||||
smain.h
|
||||
)
|
||||
|
||||
set(SQLITE-WIN32-RESOURCES qsqlite_resource.rc)
|
||||
|
||||
qt4_wrap_cpp(SQLITE-SOURCES-MOC ${SQLITE-MOC-HEADERS})
|
||||
qt5_wrap_cpp(SQLITE-SOURCES-MOC ${SQLITE-MOC-HEADERS})
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
|
@ -40,7 +41,9 @@ add_library(qsqlite STATIC
|
|||
${SQLITE-SOURCES-MOC}
|
||||
${SQLITE-WIN32-RESOURCES}
|
||||
)
|
||||
|
||||
set_property(TARGET qsqlite PROPERTY QT_STATICPLUGIN 1)
|
||||
|
||||
target_link_libraries(qsqlite
|
||||
${SQLITE_LIBRARIES}
|
||||
${QT_LIBRARIES}
|
||||
Qt5::Core Qt5::Sql
|
||||
)
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtSql module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
|
@ -21,30 +22,31 @@
|
|||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "clementinesqlcachedresult.h"
|
||||
|
||||
#include <qvariant.h>
|
||||
#include <qdatetime.h>
|
||||
#include <qvector.h>
|
||||
|
||||
#include "clementinesqlcachedresult.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*
|
||||
ClementineSqlCachedResult is a convenience class for databases that only allow
|
||||
forward only fetching. It will cache all the results so we can iterate
|
||||
|
@ -302,12 +304,19 @@ ClementineSqlCachedResult::ValueCache &ClementineSqlCachedResult::cache()
|
|||
|
||||
void ClementineSqlCachedResult::virtual_hook(int id, void *data)
|
||||
{
|
||||
switch (id) {
|
||||
case QSqlResult::DetachFromResultSet:
|
||||
case QSqlResult::SetNumericalPrecision:
|
||||
cleanup();
|
||||
break;
|
||||
default:
|
||||
QSqlResult::virtual_hook(id, data);
|
||||
}
|
||||
QSqlResult::virtual_hook(id, data);
|
||||
}
|
||||
|
||||
void ClementineSqlCachedResult::detachFromResultSet()
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
void ClementineSqlCachedResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy)
|
||||
{
|
||||
QSqlResult::setNumericalPrecisionPolicy(policy);
|
||||
cleanup();
|
||||
}
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtSql module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
|
@ -21,35 +22,47 @@
|
|||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CLEMENTINECACHEDRESULT_P_H
|
||||
#define CLEMENTINECACHEDRESULT_P_H
|
||||
#ifndef QSQLCACHEDRESULT_P_H
|
||||
#define QSQLCACHEDRESULT_P_H
|
||||
|
||||
#include <QSqlResult>
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtSql/qsqlresult.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QVariant;
|
||||
template <typename T> class QVector;
|
||||
|
||||
class ClementineSqlCachedResultPrivate;
|
||||
|
||||
class ClementineSqlCachedResult: public QSqlResult
|
||||
class Q_SQL_EXPORT ClementineSqlCachedResult: public QSqlResult
|
||||
{
|
||||
public:
|
||||
virtual ~ClementineSqlCachedResult();
|
||||
|
@ -77,9 +90,13 @@ protected:
|
|||
ValueCache &cache();
|
||||
|
||||
void virtual_hook(int id, void *data);
|
||||
void detachFromResultSet();
|
||||
void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy);
|
||||
private:
|
||||
bool cacheNext();
|
||||
ClementineSqlCachedResultPrivate *d;
|
||||
};
|
||||
|
||||
#endif // CLEMENTINESQLCACHEDRESULT_P_H
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QSQLCACHEDRESULT_P_H
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtSql module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
|
@ -21,8 +22,8 @@
|
|||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
|
@ -33,8 +34,7 @@
|
|||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
@ -59,7 +59,10 @@
|
|||
|
||||
#include <sqlite3.h>
|
||||
|
||||
Q_DECLARE_OPAQUE_POINTER(sqlite3*)
|
||||
Q_DECLARE_METATYPE(sqlite3*)
|
||||
|
||||
Q_DECLARE_OPAQUE_POINTER(sqlite3_stmt*)
|
||||
Q_DECLARE_METATYPE(sqlite3_stmt*)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -84,10 +87,14 @@ static QVariant::Type qGetColumnType(const QString &tpName)
|
|||
return QVariant::Int;
|
||||
if (typeName == QLatin1String("double")
|
||||
|| typeName == QLatin1String("float")
|
||||
|| typeName == QLatin1String("real")
|
||||
|| typeName.startsWith(QLatin1String("numeric")))
|
||||
return QVariant::Double;
|
||||
if (typeName == QLatin1String("blob"))
|
||||
return QVariant::ByteArray;
|
||||
if (typeName == QLatin1String("boolean")
|
||||
|| typeName == QLatin1String("bool"))
|
||||
return QVariant::Bool;
|
||||
return QVariant::String;
|
||||
}
|
||||
|
||||
|
@ -95,7 +102,7 @@ static QSqlError qMakeError(sqlite3 *access, const QString &descr, QSqlError::Er
|
|||
int errorCode = -1)
|
||||
{
|
||||
return QSqlError(descr,
|
||||
QString::fromUtf16(static_cast<const ushort *>(sqlite3_errmsg16(access))),
|
||||
QString(reinterpret_cast<const QChar *>(sqlite3_errmsg16(access))),
|
||||
type, errorCode);
|
||||
}
|
||||
|
||||
|
@ -104,6 +111,7 @@ class QSQLiteDriverPrivate
|
|||
public:
|
||||
inline QSQLiteDriverPrivate() : access(0) {}
|
||||
sqlite3 *access;
|
||||
QList <QSQLiteResult *> results;
|
||||
};
|
||||
|
||||
|
||||
|
@ -162,19 +170,44 @@ void QSQLiteResultPrivate::initColumns(bool emptyResultset)
|
|||
q->init(nCols);
|
||||
|
||||
for (int i = 0; i < nCols; ++i) {
|
||||
QString colName = QString::fromUtf16(
|
||||
static_cast<const ushort *>(sqlite3_column_name16(stmt, i))
|
||||
QString colName = QString(reinterpret_cast<const QChar *>(
|
||||
sqlite3_column_name16(stmt, i))
|
||||
).remove(QLatin1Char('"'));
|
||||
|
||||
// must use typeName for resolving the type to match QSqliteDriver::record
|
||||
QString typeName = QString::fromUtf16(
|
||||
static_cast<const ushort *>(sqlite3_column_decltype16(stmt, i)));
|
||||
|
||||
int dotIdx = colName.lastIndexOf(QLatin1Char('.'));
|
||||
QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), qGetColumnType(typeName));
|
||||
|
||||
QString typeName = QString(reinterpret_cast<const QChar *>(
|
||||
sqlite3_column_decltype16(stmt, i)));
|
||||
// sqlite3_column_type is documented to have undefined behavior if the result set is empty
|
||||
int stp = emptyResultset ? -1 : sqlite3_column_type(stmt, i);
|
||||
|
||||
QVariant::Type fieldType;
|
||||
|
||||
if (!typeName.isEmpty()) {
|
||||
fieldType = qGetColumnType(typeName);
|
||||
} else {
|
||||
// Get the proper type for the field based on stp value
|
||||
switch (stp) {
|
||||
case SQLITE_INTEGER:
|
||||
fieldType = QVariant::Int;
|
||||
break;
|
||||
case SQLITE_FLOAT:
|
||||
fieldType = QVariant::Double;
|
||||
break;
|
||||
case SQLITE_BLOB:
|
||||
fieldType = QVariant::ByteArray;
|
||||
break;
|
||||
case SQLITE_TEXT:
|
||||
fieldType = QVariant::String;
|
||||
break;
|
||||
case SQLITE_NULL:
|
||||
default:
|
||||
fieldType = QVariant::Invalid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int dotIdx = colName.lastIndexOf(QLatin1Char('.'));
|
||||
QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), fieldType);
|
||||
fld.setSqlType(stp);
|
||||
rInf.append(fld);
|
||||
}
|
||||
|
@ -245,9 +278,9 @@ bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &valu
|
|||
values[i + idx] = QVariant(QVariant::String);
|
||||
break;
|
||||
default:
|
||||
values[i + idx] = QString::fromUtf16(static_cast<const ushort *>(
|
||||
values[i + idx] = QString(reinterpret_cast<const QChar *>(
|
||||
sqlite3_column_text16(stmt, i)),
|
||||
sqlite3_column_bytes16(stmt, i) / sizeof(ushort));
|
||||
sqlite3_column_bytes16(stmt, i) / sizeof(QChar));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -259,6 +292,7 @@ bool QSQLiteResultPrivate::fetchNext(ClementineSqlCachedResult::ValueCache &valu
|
|||
q->setAt(QSql::AfterLastRow);
|
||||
sqlite3_reset(stmt);
|
||||
return false;
|
||||
case SQLITE_CONSTRAINT:
|
||||
case SQLITE_ERROR:
|
||||
// SQLITE_ERROR is a generic error code and we must call sqlite3_reset()
|
||||
// to get the specific error message.
|
||||
|
@ -285,24 +319,21 @@ QSQLiteResult::QSQLiteResult(const QSQLiteDriver* db)
|
|||
{
|
||||
d = new QSQLiteResultPrivate(this);
|
||||
d->access = db->d->access;
|
||||
db->d->results.append(this);
|
||||
}
|
||||
|
||||
QSQLiteResult::~QSQLiteResult()
|
||||
{
|
||||
const QSqlDriver *sqlDriver = driver();
|
||||
if (sqlDriver)
|
||||
qobject_cast<const QSQLiteDriver *>(sqlDriver)->d->results.removeOne(this);
|
||||
d->cleanup();
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QSQLiteResult::virtual_hook(int id, void *data)
|
||||
{
|
||||
switch (id) {
|
||||
case QSqlResult::DetachFromResultSet:
|
||||
if (d->stmt)
|
||||
sqlite3_reset(d->stmt);
|
||||
break;
|
||||
default:
|
||||
ClementineSqlCachedResult::virtual_hook(id, data);
|
||||
}
|
||||
ClementineSqlCachedResult::virtual_hook(id, data);
|
||||
}
|
||||
|
||||
bool QSQLiteResult::reset(const QString &query)
|
||||
|
@ -321,12 +352,14 @@ bool QSQLiteResult::prepare(const QString &query)
|
|||
|
||||
setSelect(false);
|
||||
|
||||
const void *pzTail = NULL;
|
||||
|
||||
#if (SQLITE_VERSION_NUMBER >= 3003011)
|
||||
int res = sqlite3_prepare16_v2(d->access, query.constData(), (query.size() + 1) * sizeof(QChar),
|
||||
&d->stmt, 0);
|
||||
&d->stmt, &pzTail);
|
||||
#else
|
||||
int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar),
|
||||
&d->stmt, 0);
|
||||
&d->stmt, &pzTail);
|
||||
#endif
|
||||
|
||||
if (res != SQLITE_OK) {
|
||||
|
@ -334,6 +367,11 @@ bool QSQLiteResult::prepare(const QString &query)
|
|||
"Unable to execute statement"), QSqlError::StatementError, res));
|
||||
d->finalize();
|
||||
return false;
|
||||
} else if (pzTail && !QString(reinterpret_cast<const QChar *>(pzTail)).trimmed().isEmpty()) {
|
||||
setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult",
|
||||
"Unable to execute multiple statements at a time"), QSqlError::StatementError, SQLITE_MISUSE));
|
||||
d->finalize();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -371,6 +409,7 @@ bool QSQLiteResult::exec()
|
|||
ba->size(), SQLITE_STATIC);
|
||||
break; }
|
||||
case QVariant::Int:
|
||||
case QVariant::Bool:
|
||||
res = sqlite3_bind_int(d->stmt, i + 1, value.toInt());
|
||||
break;
|
||||
case QVariant::Double:
|
||||
|
@ -403,7 +442,7 @@ bool QSQLiteResult::exec()
|
|||
}
|
||||
} else {
|
||||
setLastError(QSqlError(QCoreApplication::translate("QSQLiteResult",
|
||||
"Parameter count mismatch"), QString(), QSqlError::StatementError));
|
||||
"Parameter count mismatch") + QString::number(paramCount, 10) + "/" + QString::number(values.count(), 10), QString(), QSqlError::StatementError));
|
||||
return false;
|
||||
}
|
||||
d->skippedStatus = d->fetchNext(d->firstRow, 0, true);
|
||||
|
@ -449,9 +488,15 @@ QSqlRecord QSQLiteResult::record() const
|
|||
return d->rInf;
|
||||
}
|
||||
|
||||
void QSQLiteResult::detachFromResultSet()
|
||||
{
|
||||
if (d->stmt)
|
||||
sqlite3_reset(d->stmt);
|
||||
}
|
||||
|
||||
QVariant QSQLiteResult::handle() const
|
||||
{
|
||||
return qVariantFromValue(d->stmt);
|
||||
return QVariant::fromValue(d->stmt);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
@ -500,32 +545,6 @@ bool QSQLiteDriver::hasFeature(DriverFeature f) const
|
|||
return false;
|
||||
}
|
||||
|
||||
static int qGetSqliteTimeout(QString opts)
|
||||
{
|
||||
enum { DefaultTimeout = 5000 };
|
||||
|
||||
opts.remove(QLatin1Char(' '));
|
||||
foreach(QString option, opts.split(QLatin1Char(';'))) {
|
||||
if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) {
|
||||
bool ok;
|
||||
int nt = option.mid(21).toInt(&ok);
|
||||
if (ok)
|
||||
return nt;
|
||||
}
|
||||
}
|
||||
return DefaultTimeout;
|
||||
}
|
||||
|
||||
static int qGetSqliteOpenMode(QString opts)
|
||||
{
|
||||
opts.remove(QLatin1Char(' '));
|
||||
foreach(QString option, opts.split(QLatin1Char(';'))) {
|
||||
if (option == QLatin1String("QSQLITE_OPEN_READONLY"))
|
||||
return SQLITE_OPEN_READONLY;
|
||||
}
|
||||
return SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
|
||||
}
|
||||
|
||||
/*
|
||||
SQLite dbs have no user name, passwords, hosts or ports.
|
||||
just file names.
|
||||
|
@ -537,13 +556,35 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c
|
|||
|
||||
if (db.isEmpty())
|
||||
return false;
|
||||
bool sharedCache = false;
|
||||
int openMode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, timeOut=5000;
|
||||
QStringList opts=QString(conOpts).remove(QLatin1Char(' ')).split(QLatin1Char(';'));
|
||||
foreach(const QString &option, opts) {
|
||||
if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) {
|
||||
bool ok;
|
||||
int nt = option.mid(21).toInt(&ok);
|
||||
if (ok)
|
||||
timeOut = nt;
|
||||
}
|
||||
if (option == QLatin1String("QSQLITE_OPEN_READONLY"))
|
||||
openMode = SQLITE_OPEN_READONLY;
|
||||
if (option == QLatin1String("QSQLITE_ENABLE_SHARED_CACHE"))
|
||||
sharedCache = true;
|
||||
}
|
||||
|
||||
if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, qGetSqliteOpenMode(conOpts), NULL) == SQLITE_OK) {
|
||||
sqlite3_busy_timeout(d->access, qGetSqliteTimeout(conOpts));
|
||||
sqlite3_enable_shared_cache(sharedCache);
|
||||
|
||||
if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL) == SQLITE_OK) {
|
||||
sqlite3_busy_timeout(d->access, timeOut);
|
||||
setOpen(true);
|
||||
setOpenError(false);
|
||||
return true;
|
||||
} else {
|
||||
if (d->access) {
|
||||
sqlite3_close(d->access);
|
||||
d->access = 0;
|
||||
}
|
||||
|
||||
setLastError(qMakeError(d->access, tr("Error opening database"),
|
||||
QSqlError::ConnectionError));
|
||||
setOpenError(true);
|
||||
|
@ -554,6 +595,10 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c
|
|||
void QSQLiteDriver::close()
|
||||
{
|
||||
if (isOpen()) {
|
||||
foreach (QSQLiteResult *result, d->results) {
|
||||
result->d->finalize();
|
||||
}
|
||||
|
||||
if (sqlite3_close(d->access) != SQLITE_OK)
|
||||
setLastError(qMakeError(d->access, tr("Error closing database"),
|
||||
QSqlError::ConnectionError));
|
||||
|
@ -705,7 +750,7 @@ QSqlRecord QSQLiteDriver::record(const QString &tbl) const
|
|||
|
||||
QVariant QSQLiteDriver::handle() const
|
||||
{
|
||||
return qVariantFromValue(d->access);
|
||||
return QVariant::fromValue(d->access);
|
||||
}
|
||||
|
||||
QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtSql module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
|
@ -21,8 +22,8 @@
|
|||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
|
@ -33,8 +34,7 @@
|
|||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
@ -42,8 +42,8 @@
|
|||
#ifndef QSQL_SQLITE_H
|
||||
#define QSQL_SQLITE_H
|
||||
|
||||
#include <QSqlDriver>
|
||||
#include <QSqlResult>
|
||||
#include <QtSql/qsqldriver.h>
|
||||
#include <QtSql/qsqlresult.h>
|
||||
#include "clementinesqlcachedresult.h"
|
||||
|
||||
struct sqlite3;
|
||||
|
@ -79,6 +79,7 @@ protected:
|
|||
int numRowsAffected();
|
||||
QVariant lastInsertId() const;
|
||||
QSqlRecord record() const;
|
||||
void detachFromResultSet();
|
||||
void virtual_hook(int id, void *data);
|
||||
|
||||
private:
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"Keys": [ "QSQLITE" ]
|
||||
}
|
|
@ -1,59 +1,40 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qsqldriverplugin.h>
|
||||
#include <qstringlist.h>
|
||||
#include "qsql_sqlite.h"
|
||||
#include "smain.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QSQLiteDriverPlugin : public QSqlDriverPlugin
|
||||
{
|
||||
public:
|
||||
QSQLiteDriverPlugin();
|
||||
|
||||
QSqlDriver* create(const QString &);
|
||||
QStringList keys() const;
|
||||
};
|
||||
|
||||
QSQLiteDriverPlugin::QSQLiteDriverPlugin()
|
||||
: QSqlDriverPlugin()
|
||||
{
|
||||
|
@ -68,14 +49,4 @@ QSqlDriver* QSQLiteDriverPlugin::create(const QString &name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
QStringList QSQLiteDriverPlugin::keys() const
|
||||
{
|
||||
QStringList l;
|
||||
l << QLatin1String("QSQLITE");
|
||||
return l;
|
||||
}
|
||||
|
||||
Q_EXPORT_STATIC_PLUGIN(QSQLiteDriverPlugin)
|
||||
Q_EXPORT_PLUGIN2(qsqlite, QSQLiteDriverPlugin)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qsqldriverplugin.h>
|
||||
#include <qstringlist.h>
|
||||
#include "qsql_sqlite.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QSQLiteDriverPlugin : public QSqlDriverPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "qsqlite.json")
|
||||
|
||||
public:
|
||||
QSQLiteDriverPlugin();
|
||||
|
||||
QSqlDriver* create(const QString &);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
|
@ -1,11 +0,0 @@
|
|||
--- smain.cpp.old 2010-03-22 17:34:03.000000000 +0000
|
||||
+++ smain.cpp 2010-03-22 17:34:08.000000000 +0000
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#include <qsqldriverplugin.h>
|
||||
#include <qstringlist.h>
|
||||
-#include "../../../../src/sql/drivers/sqlite/qsql_sqlite.h"
|
||||
+#include "qsql_sqlite.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
@ -8,9 +8,11 @@ set(IOCOMPRESSOR-MOC-HEADERS
|
|||
qtiocompressor.h
|
||||
)
|
||||
|
||||
QT4_WRAP_CPP(IOCOMPRESSOR-SOURCES-MOC ${IOCOMPRESSOR-MOC-HEADERS})
|
||||
QT5_WRAP_CPP(IOCOMPRESSOR-SOURCES-MOC ${IOCOMPRESSOR-MOC-HEADERS})
|
||||
|
||||
ADD_LIBRARY(qtiocompressor STATIC
|
||||
${IOCOMPRESSOR-SOURCES}
|
||||
${IOCOMPRESSOR-SOURCES-MOC}
|
||||
)
|
||||
|
||||
QT5_USE_MODULES(qtiocompressor Core)
|
||||
|
|
|
@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 2.6)
|
|||
|
||||
set(SINGLEAPP-SOURCES
|
||||
qtlocalpeer.cpp
|
||||
qtlockedfile.cpp
|
||||
qtsingleapplication.cpp
|
||||
qtsinglecoreapplication.cpp
|
||||
)
|
||||
|
@ -19,9 +18,11 @@ elseif(WIN32)
|
|||
set(SINGLEAPP-SOURCES ${SINGLEAPP-SOURCES} qtlockedfile_unix.cpp)
|
||||
endif(WIN32)
|
||||
|
||||
QT4_WRAP_CPP(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS})
|
||||
QT5_WRAP_CPP(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS})
|
||||
|
||||
ADD_LIBRARY(qtsingleapplication STATIC
|
||||
${SINGLEAPP-SOURCES}
|
||||
${SINGLEAPP-SOURCES-MOC}
|
||||
)
|
||||
|
||||
QT5_USE_MODULES(qtsingleapplication Core Widgets Network)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "qtlockedfile.h"
|
|
@ -1 +0,0 @@
|
|||
#include "qtsingleapplication.h"
|
|
@ -1,58 +1,51 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** This file is part of a Qt Solutions component.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Solutions Commercial License Agreement provided
|
||||
** with the Software or, alternatively, in accordance with the terms
|
||||
** contained in a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Please note Third Party Software included with Qt Solutions may impose
|
||||
** additional restrictions and it is the user's responsibility to ensure
|
||||
** that they have met the licensing requirements of the GPL, LGPL, or Qt
|
||||
** Solutions Commercial license and the relevant license of the Third
|
||||
** Party Software they are using.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "qtlocalpeer.h"
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QTime>
|
||||
#include <QtDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QTime>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <QtCore/QLibrary>
|
||||
#include <QtCore/qt_windows.h>
|
||||
#include <QLibrary>
|
||||
#include <qt_windows.h>
|
||||
typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*);
|
||||
static PProcessIdToSessionId pProcessIdToSessionId = 0;
|
||||
#endif
|
||||
|
@ -60,12 +53,14 @@ static PProcessIdToSessionId pProcessIdToSessionId = 0;
|
|||
#include <time.h>
|
||||
#endif
|
||||
|
||||
namespace QtLP_Private {
|
||||
#include "qtlockedfile.cpp"
|
||||
#if defined(Q_OS_WIN)
|
||||
#include "qtlockedfile_win.cpp"
|
||||
#else
|
||||
#include "qtlockedfile_unix.cpp"
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* QtLocalPeer::ack = "ack";
|
||||
|
||||
|
@ -107,7 +102,6 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
|
|||
+ QLatin1Char('/') + socketName
|
||||
+ QLatin1String("-lockfile");
|
||||
lockFile.setFileName(lockName);
|
||||
lockFileCreated = !lockFile.exists();
|
||||
lockFile.open(QIODevice::ReadWrite);
|
||||
}
|
||||
|
||||
|
@ -118,7 +112,7 @@ bool QtLocalPeer::isClient()
|
|||
if (lockFile.isLocked())
|
||||
return false;
|
||||
|
||||
if (!lockFile.lock(QtLockedFile::WriteLock, false))
|
||||
if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
|
||||
return true;
|
||||
|
||||
bool res = server->listen(socketName);
|
||||
|
@ -137,16 +131,6 @@ bool QtLocalPeer::isClient()
|
|||
|
||||
|
||||
bool QtLocalPeer::sendMessage(const QString &message, int timeout)
|
||||
{
|
||||
return sendMessage(message.toUtf8(), timeout);
|
||||
}
|
||||
|
||||
bool QtLocalPeer::sendMessage(const char* message, int timeout)
|
||||
{
|
||||
return sendMessage(QByteArray(message), timeout);
|
||||
}
|
||||
|
||||
bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout)
|
||||
{
|
||||
if (!isClient())
|
||||
return false;
|
||||
|
@ -170,11 +154,15 @@ bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout)
|
|||
if (!connOk)
|
||||
return false;
|
||||
|
||||
QByteArray uMsg(message.toUtf8());
|
||||
QDataStream ds(&socket);
|
||||
ds.writeBytes(message.constData(), message.size());
|
||||
ds.writeBytes(uMsg.constData(), uMsg.size());
|
||||
bool res = socket.waitForBytesWritten(timeout);
|
||||
res &= socket.waitForReadyRead(timeout); // wait for ack
|
||||
res &= (socket.read(qstrlen(ack)) == ack);
|
||||
if (res) {
|
||||
res &= socket.waitForReadyRead(timeout); // wait for ack
|
||||
if (res)
|
||||
res &= (socket.read(qstrlen(ack)) == ack);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -200,19 +188,13 @@ void QtLocalPeer::receiveConnection()
|
|||
uMsgBuf += got;
|
||||
} while (remaining && got >= 0 && socket->waitForReadyRead(2000));
|
||||
if (got < 0) {
|
||||
qWarning() << "QtLocalPeer: Message reception failed" << socket->errorString();
|
||||
qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData());
|
||||
delete socket;
|
||||
return;
|
||||
}
|
||||
QString message(QString::fromUtf8(uMsg));
|
||||
socket->write(ack, qstrlen(ack));
|
||||
socket->waitForBytesWritten(1000);
|
||||
delete socket;
|
||||
emit messageReceived(uMsg); //### (might take a long time to return)
|
||||
emit messageReceived(QString::fromUtf8(uMsg));
|
||||
}
|
||||
|
||||
QtLocalPeer::~QtLocalPeer ()
|
||||
{
|
||||
if (lockFileCreated)
|
||||
lockFile.remove();
|
||||
emit messageReceived(message); //### (might take a long time to return)
|
||||
}
|
||||
|
|
|
@ -1,53 +1,48 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** This file is part of a Qt Solutions component.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Solutions Commercial License Agreement provided
|
||||
** with the Software or, alternatively, in accordance with the terms
|
||||
** contained in a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Please note Third Party Software included with Qt Solutions may impose
|
||||
** additional restrictions and it is the user's responsibility to ensure
|
||||
** that they have met the licensing requirements of the GPL, LGPL, or Qt
|
||||
** Solutions Commercial license and the relevant license of the Third
|
||||
** Party Software they are using.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTLOCALPEER_H
|
||||
#define QTLOCALPEER_H
|
||||
|
||||
#include <QtNetwork/QLocalServer>
|
||||
#include <QtNetwork/QLocalSocket>
|
||||
#include <QtCore/QDir>
|
||||
#include <QLocalServer>
|
||||
#include <QLocalSocket>
|
||||
#include <QDir>
|
||||
|
||||
#include "qtlockedfile.h"
|
||||
|
||||
|
@ -57,18 +52,13 @@ class QtLocalPeer : public QObject
|
|||
|
||||
public:
|
||||
QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
|
||||
~QtLocalPeer ();
|
||||
bool isClient();
|
||||
bool sendMessage(const QString &message, int timeout);
|
||||
bool sendMessage(const QByteArray &message, int timeout);
|
||||
bool sendMessage(const char* message, int timeout);
|
||||
QString applicationId() const
|
||||
{ return id; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void messageReceived(const QString &message);
|
||||
void messageReceived(const QByteArray &message);
|
||||
void messageReceived(const char* message);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void receiveConnection();
|
||||
|
@ -77,9 +67,10 @@ protected:
|
|||
QString id;
|
||||
QString socketName;
|
||||
QLocalServer* server;
|
||||
QtLockedFile lockFile;
|
||||
QtLP_Private::QtLockedFile lockFile;
|
||||
|
||||
private:
|
||||
static const char* ack;
|
||||
bool lockFileCreated;
|
||||
};
|
||||
|
||||
#endif // QTLOCALPEER_H
|
||||
|
|
|
@ -1,47 +1,40 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** This file is part of a Qt Solutions component.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Solutions Commercial License Agreement provided
|
||||
** with the Software or, alternatively, in accordance with the terms
|
||||
** contained in a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Please note Third Party Software included with Qt Solutions may impose
|
||||
** additional restrictions and it is the user's responsibility to ensure
|
||||
** that they have met the licensing requirements of the GPL, LGPL, or Qt
|
||||
** Solutions Commercial license and the relevant license of the Third
|
||||
** Party Software they are using.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qtlockedfile.h"
|
||||
|
|
|
@ -1,58 +1,51 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** This file is part of a Qt Solutions component.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Solutions Commercial License Agreement provided
|
||||
** with the Software or, alternatively, in accordance with the terms
|
||||
** contained in a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Please note Third Party Software included with Qt Solutions may impose
|
||||
** additional restrictions and it is the user's responsibility to ensure
|
||||
** that they have met the licensing requirements of the GPL, LGPL, or Qt
|
||||
** Solutions Commercial license and the relevant license of the Third
|
||||
** Party Software they are using.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTLOCKEDFILE_H
|
||||
#define QTLOCKEDFILE_H
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QFile>
|
||||
#ifdef Q_OS_WIN
|
||||
#include <QtCore/QVector>
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_WIN)
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_WIN)
|
||||
# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT)
|
||||
# define QT_QTLOCKEDFILE_EXPORT
|
||||
# elif defined(QT_QTLOCKEDFILE_IMPORT)
|
||||
|
@ -68,6 +61,8 @@
|
|||
# define QT_QTLOCKEDFILE_EXPORT
|
||||
#endif
|
||||
|
||||
namespace QtLP_Private {
|
||||
|
||||
class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile
|
||||
{
|
||||
public:
|
||||
|
@ -97,5 +92,5 @@ private:
|
|||
#endif
|
||||
LockMode m_lock_mode;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,47 +1,40 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** This file is part of a Qt Solutions component.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Solutions Commercial License Agreement provided
|
||||
** with the Software or, alternatively, in accordance with the terms
|
||||
** contained in a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Please note Third Party Software included with Qt Solutions may impose
|
||||
** additional restrictions and it is the user's responsibility to ensure
|
||||
** that they have met the licensing requirements of the GPL, LGPL, or Qt
|
||||
** Solutions Commercial license and the relevant license of the Third
|
||||
** Party Software they are using.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
|
|
@ -1,52 +1,45 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** This file is part of a Qt Solutions component.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Solutions Commercial License Agreement provided
|
||||
** with the Software or, alternatively, in accordance with the terms
|
||||
** contained in a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Please note Third Party Software included with Qt Solutions may impose
|
||||
** additional restrictions and it is the user's responsibility to ensure
|
||||
** that they have met the licensing requirements of the GPL, LGPL, or Qt
|
||||
** Solutions Commercial license and the relevant license of the Third
|
||||
** Party Software they are using.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qtlockedfile.h"
|
||||
#include <qt_windows.h>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QFileInfo>
|
||||
|
||||
#define MUTEX_PREFIX "QtLockedFile mutex "
|
||||
// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS
|
||||
|
@ -65,16 +58,24 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
|
|||
|
||||
Qt::HANDLE mutex;
|
||||
if (doCreate) {
|
||||
QT_WA( { mutex = CreateMutexW(NULL, FALSE, (WCHAR*)mname.utf16()); },
|
||||
#if (QT_VERSION < 0x050000)
|
||||
QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
|
||||
{ mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
|
||||
#else
|
||||
mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16());
|
||||
#endif
|
||||
if (!mutex) {
|
||||
qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (WCHAR*)mname.utf16()); },
|
||||
#if (QT_VERSION < 0x050000)
|
||||
QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
|
||||
{ mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
|
||||
#else
|
||||
mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16());
|
||||
#endif
|
||||
if (!mutex) {
|
||||
if (GetLastError() != ERROR_FILE_NOT_FOUND)
|
||||
qErrnoWarning("QtLockedFile::lock(): OpenMutex failed");
|
||||
|
|
|
@ -1,54 +1,46 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** This file is part of a Qt Solutions component.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Solutions Commercial License Agreement provided
|
||||
** with the Software or, alternatively, in accordance with the terms
|
||||
** contained in a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Please note Third Party Software included with Qt Solutions may impose
|
||||
** additional restrictions and it is the user's responsibility to ensure
|
||||
** that they have met the licensing requirements of the GPL, LGPL, or Qt
|
||||
** Solutions Commercial license and the relevant license of the Third
|
||||
** Party Software they are using.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "qtsingleapplication.h"
|
||||
#include "qtlocalpeer.h"
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
/*!
|
||||
\class QtSingleApplication qtsingleapplication.h
|
||||
|
@ -68,28 +60,31 @@
|
|||
that will be compared instead.
|
||||
|
||||
The application should create the QtSingleApplication object early
|
||||
in the startup phase, and call isRunning() or sendMessage() to
|
||||
find out if another instance of this application is already
|
||||
running. Startup parameters (e.g. the name of the file the user
|
||||
wanted this new instance to open) can be passed to the running
|
||||
instance in the sendMessage() function.
|
||||
in the startup phase, and call isRunning() to find out if another
|
||||
instance of this application is already running. If isRunning()
|
||||
returns false, it means that no other instance is running, and
|
||||
this instance has assumed the role as the running instance. In
|
||||
this case, the application should continue with the initialization
|
||||
of the application user interface before entering the event loop
|
||||
with exec(), as normal.
|
||||
|
||||
If isRunning() or sendMessage() returns false, it means that no
|
||||
other instance is running, and this instance has assumed the role
|
||||
as the running instance. The application should continue with the
|
||||
initialization of the application user interface before entering
|
||||
the event loop with exec(), as normal. The messageReceived()
|
||||
signal will be emitted when the application receives messages from
|
||||
another instance of the same application.
|
||||
The messageReceived() signal will be emitted when the running
|
||||
application receives messages from another instance of the same
|
||||
application. When a message is received it might be helpful to the
|
||||
user to raise the application so that it becomes visible. To
|
||||
facilitate this, QtSingleApplication provides the
|
||||
setActivationWindow() function and the activateWindow() slot.
|
||||
|
||||
If isRunning() or sendMessage() returns true, another instance is
|
||||
already running, and the application should terminate or enter
|
||||
client mode.
|
||||
If isRunning() returns true, another instance is already
|
||||
running. It may be alerted to the fact that another instance has
|
||||
started by using the sendMessage() function. Also data such as
|
||||
startup parameters (e.g. the name of the file the user wanted this
|
||||
new instance to open) can be passed to the running instance with
|
||||
this function. Then, the application should terminate (or enter
|
||||
client mode).
|
||||
|
||||
If a message is received it might be helpful to the user to raise
|
||||
the application so that it becomes visible. To facilitate this,
|
||||
QtSingleApplication provides the setActivationWindow() function
|
||||
and the activateWindow() slot.
|
||||
If isRunning() returns true, but sendMessage() fails, that is an
|
||||
indication that the running instance is frozen.
|
||||
|
||||
Here's an example that shows how to convert an existing
|
||||
application to use QtSingleApplication. It is very simple and does
|
||||
|
@ -103,7 +98,6 @@
|
|||
QApplication app(argc, argv);
|
||||
|
||||
MyMainWidget mmw;
|
||||
|
||||
mmw.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -114,19 +108,17 @@
|
|||
QtSingleApplication app(argc, argv);
|
||||
|
||||
if (app.isRunning())
|
||||
return 0;
|
||||
return !app.sendMessage(someDataString);
|
||||
|
||||
MyMainWidget mmw;
|
||||
|
||||
app.setActivationWindow(&mmw);
|
||||
|
||||
mmw.show();
|
||||
return app.exec();
|
||||
}
|
||||
\endcode
|
||||
|
||||
Once this QtSingleApplication instance is destroyed(for example,
|
||||
when the user quits), when the user next attempts to run the
|
||||
Once this QtSingleApplication instance is destroyed (normally when
|
||||
the process exits or crashes), when the user next attempts to run the
|
||||
application this instance will not, of course, be encountered. The
|
||||
next instance to call isRunning() or sendMessage() will assume the
|
||||
role as the new running instance.
|
||||
|
@ -144,8 +136,6 @@ void QtSingleApplication::sysInit(const QString &appId)
|
|||
actWin = 0;
|
||||
peer = new QtLocalPeer(this, appId);
|
||||
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
|
||||
connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
|
||||
connect(peer, SIGNAL(messageReceived(const char*)), SIGNAL(messageReceived(const char*)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -179,18 +169,6 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char *
|
|||
}
|
||||
|
||||
|
||||
/*!
|
||||
Creates a QtSingleApplication object. The application identifier
|
||||
will be QCoreApplication::applicationFilePath(). \a argc, \a
|
||||
argv, and \a type are passed on to the QAppliation constructor.
|
||||
*/
|
||||
QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type)
|
||||
: QApplication(argc, argv, type)
|
||||
{
|
||||
sysInit();
|
||||
}
|
||||
|
||||
|
||||
#if defined(Q_WS_X11)
|
||||
/*!
|
||||
Special constructor for X11, ref. the documentation of
|
||||
|
@ -267,16 +245,6 @@ bool QtSingleApplication::sendMessage(const QString &message, int timeout)
|
|||
return peer->sendMessage(message, timeout);
|
||||
}
|
||||
|
||||
bool QtSingleApplication::sendMessage(const QByteArray &message, int timeout)
|
||||
{
|
||||
return peer->sendMessage(message, timeout);
|
||||
}
|
||||
|
||||
bool QtSingleApplication::sendMessage(const char* message, int timeout)
|
||||
{
|
||||
return peer->sendMessage(message, timeout);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns the application identifier. Two processes with the same
|
||||
|
@ -303,16 +271,10 @@ QString QtSingleApplication::id() const
|
|||
void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
|
||||
{
|
||||
actWin = aw;
|
||||
if (activateOnMessage) {
|
||||
if (activateOnMessage)
|
||||
connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
|
||||
connect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
|
||||
connect(peer, SIGNAL(messageReceived(const char*)), this, SLOT(activateWindow()));
|
||||
}
|
||||
else {
|
||||
else
|
||||
disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
|
||||
disconnect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
|
||||
disconnect(peer, SIGNAL(messageReceived(const char*)), this, SLOT(activateWindow()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,55 +1,50 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** This file is part of a Qt Solutions component.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Solutions Commercial License Agreement provided
|
||||
** with the Software or, alternatively, in accordance with the terms
|
||||
** contained in a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Please note Third Party Software included with Qt Solutions may impose
|
||||
** additional restrictions and it is the user's responsibility to ensure
|
||||
** that they have met the licensing requirements of the GPL, LGPL, or Qt
|
||||
** Solutions Commercial license and the relevant license of the Third
|
||||
** Party Software they are using.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTSINGLEAPPLICATION_H
|
||||
#define QTSINGLEAPPLICATION_H
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QApplication>
|
||||
|
||||
class QtLocalPeer;
|
||||
|
||||
#if defined(Q_WS_WIN)
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_WIN32)
|
||||
# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT)
|
||||
# define QT_QTSINGLEAPPLICATION_EXPORT
|
||||
# elif defined(QT_QTSINGLEAPPLICATION_IMPORT)
|
||||
|
@ -72,7 +67,6 @@ class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication
|
|||
public:
|
||||
QtSingleApplication(int &argc, char **argv, bool GUIenabled = true);
|
||||
QtSingleApplication(const QString &id, int &argc, char **argv);
|
||||
QtSingleApplication(int &argc, char **argv, Type type);
|
||||
#if defined(Q_WS_X11)
|
||||
QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
|
||||
QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
|
||||
|
@ -91,15 +85,11 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
bool sendMessage(const QString &message, int timeout = 5000);
|
||||
bool sendMessage(const QByteArray &message, int timeout = 5000);
|
||||
bool sendMessage(const char* message, int timeout = 5000);
|
||||
void activateWindow();
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void messageReceived(const QString &message);
|
||||
void messageReceived(const QByteArray &message);
|
||||
void messageReceived(const char* message);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -107,3 +97,5 @@ private:
|
|||
QtLocalPeer *peer;
|
||||
QWidget *actWin;
|
||||
};
|
||||
|
||||
#endif // QTSINGLEAPPLICATION_H
|
||||
|
|
|
@ -1,231 +0,0 @@
|
|||
diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.cpp qtsingleapplication/qtlocalpeer.cpp
|
||||
--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.cpp 2009-12-16 10:43:33.000000000 +0000
|
||||
+++ qtsingleapplication/qtlocalpeer.cpp 2010-07-10 16:26:50.000000000 +0100
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "qtlocalpeer.h"
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QTime>
|
||||
+#include <QtDebug>
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <QtCore/QLibrary>
|
||||
@@ -59,14 +60,12 @@
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
-namespace QtLP_Private {
|
||||
#include "qtlockedfile.cpp"
|
||||
#if defined(Q_OS_WIN)
|
||||
#include "qtlockedfile_win.cpp"
|
||||
#else
|
||||
#include "qtlockedfile_unix.cpp"
|
||||
#endif
|
||||
-}
|
||||
|
||||
const char* QtLocalPeer::ack = "ack";
|
||||
|
||||
@@ -118,7 +117,7 @@
|
||||
if (lockFile.isLocked())
|
||||
return false;
|
||||
|
||||
- if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
|
||||
+ if (!lockFile.lock(QtLockedFile::WriteLock, false))
|
||||
return true;
|
||||
|
||||
bool res = server->listen(socketName);
|
||||
@@ -138,6 +137,11 @@
|
||||
|
||||
bool QtLocalPeer::sendMessage(const QString &message, int timeout)
|
||||
{
|
||||
+ return sendMessage(message.toUtf8(), timeout);
|
||||
+}
|
||||
+
|
||||
+bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout)
|
||||
+{
|
||||
if (!isClient())
|
||||
return false;
|
||||
|
||||
@@ -160,9 +164,8 @@
|
||||
if (!connOk)
|
||||
return false;
|
||||
|
||||
- QByteArray uMsg(message.toUtf8());
|
||||
QDataStream ds(&socket);
|
||||
- ds.writeBytes(uMsg.constData(), uMsg.size());
|
||||
+ ds.writeBytes(message.constData(), message.size());
|
||||
bool res = socket.waitForBytesWritten(timeout);
|
||||
res &= socket.waitForReadyRead(timeout); // wait for ack
|
||||
res &= (socket.read(qstrlen(ack)) == ack);
|
||||
@@ -195,9 +198,9 @@
|
||||
delete socket;
|
||||
return;
|
||||
}
|
||||
- QString message(QString::fromUtf8(uMsg));
|
||||
socket->write(ack, qstrlen(ack));
|
||||
socket->waitForBytesWritten(1000);
|
||||
delete socket;
|
||||
- emit messageReceived(message); //### (might take a long time to return)
|
||||
+ emit messageReceived(uMsg); //### (might take a long time to return)
|
||||
+ emit messageReceived(QString::fromUtf8(uMsg));
|
||||
}
|
||||
diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.h qtsingleapplication/qtlocalpeer.h
|
||||
--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.h 2009-12-16 10:43:33.000000000 +0000
|
||||
+++ qtsingleapplication/qtlocalpeer.h 2010-07-10 16:26:16.000000000 +0100
|
||||
@@ -49,9 +49,7 @@
|
||||
#include <QtNetwork/QLocalSocket>
|
||||
#include <QtCore/QDir>
|
||||
|
||||
-namespace QtLP_Private {
|
||||
#include "qtlockedfile.h"
|
||||
-}
|
||||
|
||||
class QtLocalPeer : public QObject
|
||||
{
|
||||
@@ -61,11 +59,13 @@
|
||||
QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
|
||||
bool isClient();
|
||||
bool sendMessage(const QString &message, int timeout);
|
||||
+ bool sendMessage(const QByteArray &message, int timeout);
|
||||
QString applicationId() const
|
||||
{ return id; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void messageReceived(const QString &message);
|
||||
+ void messageReceived(const QByteArray &message);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void receiveConnection();
|
||||
@@ -74,7 +74,7 @@
|
||||
QString id;
|
||||
QString socketName;
|
||||
QLocalServer* server;
|
||||
- QtLP_Private::QtLockedFile lockFile;
|
||||
+ QtLockedFile lockFile;
|
||||
|
||||
private:
|
||||
static const char* ack;
|
||||
diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlockedfile_win.cpp qtsingleapplication/qtlockedfile_win.cpp
|
||||
--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlockedfile_win.cpp 2009-12-16 10:43:33.000000000 +0000
|
||||
+++ qtsingleapplication/qtlockedfile_win.cpp 2010-07-10 16:26:33.000000000 +0100
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
Qt::HANDLE mutex;
|
||||
if (doCreate) {
|
||||
- QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
|
||||
+ QT_WA( { mutex = CreateMutexW(NULL, FALSE, (WCHAR*)mname.utf16()); },
|
||||
{ mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
|
||||
if (!mutex) {
|
||||
qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
|
||||
@@ -73,7 +73,7 @@
|
||||
}
|
||||
}
|
||||
else {
|
||||
- QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
|
||||
+ QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (WCHAR*)mname.utf16()); },
|
||||
{ mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
|
||||
if (!mutex) {
|
||||
if (GetLastError() != ERROR_FILE_NOT_FOUND)
|
||||
diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.cpp qtsingleapplication/qtsingleapplication.cpp
|
||||
--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.cpp 2009-12-16 10:43:33.000000000 +0000
|
||||
+++ qtsingleapplication/qtsingleapplication.cpp 2010-07-10 16:23:53.000000000 +0100
|
||||
@@ -144,6 +144,7 @@
|
||||
actWin = 0;
|
||||
peer = new QtLocalPeer(this, appId);
|
||||
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
|
||||
+ connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
|
||||
}
|
||||
|
||||
|
||||
@@ -265,6 +266,11 @@
|
||||
return peer->sendMessage(message, timeout);
|
||||
}
|
||||
|
||||
+bool QtSingleApplication::sendMessage(const QByteArray &message, int timeout)
|
||||
+{
|
||||
+ return peer->sendMessage(message, timeout);
|
||||
+}
|
||||
+
|
||||
|
||||
/*!
|
||||
Returns the application identifier. Two processes with the same
|
||||
@@ -291,10 +297,14 @@
|
||||
void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
|
||||
{
|
||||
actWin = aw;
|
||||
- if (activateOnMessage)
|
||||
+ if (activateOnMessage) {
|
||||
connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
|
||||
- else
|
||||
+ connect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
|
||||
+ }
|
||||
+ else {
|
||||
disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
|
||||
+ disconnect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
|
||||
+ }
|
||||
}
|
||||
|
||||
|
||||
diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.h qtsingleapplication/qtsingleapplication.h
|
||||
--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.h 2009-12-16 10:43:33.000000000 +0000
|
||||
+++ qtsingleapplication/qtsingleapplication.h 2010-07-10 16:23:53.000000000 +0100
|
||||
@@ -91,11 +91,13 @@
|
||||
|
||||
public Q_SLOTS:
|
||||
bool sendMessage(const QString &message, int timeout = 5000);
|
||||
+ bool sendMessage(const QByteArray &message, int timeout = 5000);
|
||||
void activateWindow();
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void messageReceived(const QString &message);
|
||||
+ void messageReceived(const QByteArray &message);
|
||||
|
||||
|
||||
private:
|
||||
diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.cpp qtsingleapplication/qtsinglecoreapplication.cpp
|
||||
--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.cpp 2009-12-16 10:43:33.000000000 +0000
|
||||
+++ qtsingleapplication/qtsinglecoreapplication.cpp 2010-07-10 16:32:33.000000000 +0100
|
||||
@@ -81,6 +81,7 @@
|
||||
{
|
||||
peer = new QtLocalPeer(this);
|
||||
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
|
||||
+ connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +95,7 @@
|
||||
{
|
||||
peer = new QtLocalPeer(this, appId);
|
||||
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
|
||||
+ connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +135,11 @@
|
||||
return peer->sendMessage(message, timeout);
|
||||
}
|
||||
|
||||
+bool QtSingleCoreApplication::sendMessage(const QByteArray &message, int timeout)
|
||||
+{
|
||||
+ return peer->sendMessage(message, timeout);
|
||||
+}
|
||||
+
|
||||
|
||||
/*!
|
||||
Returns the application identifier. Two processes with the same
|
||||
diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.h qtsingleapplication/qtsinglecoreapplication.h
|
||||
--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.h 2009-12-16 10:43:33.000000000 +0000
|
||||
+++ qtsingleapplication/qtsinglecoreapplication.h 2010-07-10 16:32:33.000000000 +0100
|
||||
@@ -62,10 +62,12 @@
|
||||
|
||||
public Q_SLOTS:
|
||||
bool sendMessage(const QString &message, int timeout = 5000);
|
||||
+ bool sendMessage(const QByteArray &message, int timeout = 5000);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void messageReceived(const QString &message);
|
||||
+ void messageReceived(const QByteArray &message);
|
||||
|
||||
|
||||
private:
|
|
@ -1,47 +1,40 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** This file is part of a Qt Solutions component.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Solutions Commercial License Agreement provided
|
||||
** with the Software or, alternatively, in accordance with the terms
|
||||
** contained in a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Please note Third Party Software included with Qt Solutions may impose
|
||||
** additional restrictions and it is the user's responsibility to ensure
|
||||
** that they have met the licensing requirements of the GPL, LGPL, or Qt
|
||||
** Solutions Commercial license and the relevant license of the Third
|
||||
** Party Software they are using.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
|
@ -81,8 +74,6 @@ QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv)
|
|||
{
|
||||
peer = new QtLocalPeer(this);
|
||||
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
|
||||
connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
|
||||
connect(peer, SIGNAL(messageReceived(const char*)), SIGNAL(messageReceived(const char*)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,8 +87,6 @@ QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc
|
|||
{
|
||||
peer = new QtLocalPeer(this, appId);
|
||||
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
|
||||
connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
|
||||
connect(peer, SIGNAL(messageReceived(const char*)), SIGNAL(messageReceived(const char*)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,16 +126,6 @@ bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout)
|
|||
return peer->sendMessage(message, timeout);
|
||||
}
|
||||
|
||||
bool QtSingleCoreApplication::sendMessage(const QByteArray &message, int timeout)
|
||||
{
|
||||
return peer->sendMessage(message, timeout);
|
||||
}
|
||||
|
||||
bool QtSingleCoreApplication::sendMessage(const char* message, int timeout)
|
||||
{
|
||||
return peer->sendMessage(message, timeout);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns the application identifier. Two processes with the same
|
||||
|
|
|
@ -1,51 +1,46 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** This file is part of a Qt Solutions component.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Solutions Commercial License Agreement provided
|
||||
** with the Software or, alternatively, in accordance with the terms
|
||||
** contained in a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Please note Third Party Software included with Qt Solutions may impose
|
||||
** additional restrictions and it is the user's responsibility to ensure
|
||||
** that they have met the licensing requirements of the GPL, LGPL, or Qt
|
||||
** Solutions Commercial license and the relevant license of the Third
|
||||
** Party Software they are using.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTSINGLECOREAPPLICATION_H
|
||||
#define QTSINGLECOREAPPLICATION_H
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QCoreApplication>
|
||||
|
||||
class QtLocalPeer;
|
||||
|
||||
|
@ -62,16 +57,14 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
bool sendMessage(const QString &message, int timeout = 5000);
|
||||
bool sendMessage(const QByteArray &message, int timeout = 5000);
|
||||
bool sendMessage(const char* message, int timeout = 5000);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void messageReceived(const QString &message);
|
||||
void messageReceived(const QByteArray &message);
|
||||
void messageReceived(const char* message);
|
||||
|
||||
|
||||
private:
|
||||
QtLocalPeer* peer;
|
||||
};
|
||||
|
||||
#endif // QTSINGLECOREAPPLICATION_H
|
||||
|
|
|
@ -11,6 +11,7 @@ set(QXT-MOC-HEADERS
|
|||
|
||||
find_package(X11)
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
|
||||
|
||||
if(WIN32)
|
||||
set(QXT-SOURCES ${QXT-SOURCES} qxtglobalshortcut_win.cpp)
|
||||
|
@ -20,9 +21,11 @@ else(WIN32)
|
|||
set(QXT-SOURCES ${QXT-SOURCES} qxtglobalshortcut_x11.cpp)
|
||||
endif(WIN32)
|
||||
|
||||
QT4_WRAP_CPP(QXT-SOURCES-MOC ${QXT-MOC-HEADERS})
|
||||
QT5_WRAP_CPP(QXT-SOURCES-MOC ${QXT-MOC-HEADERS})
|
||||
|
||||
ADD_LIBRARY(qxt STATIC
|
||||
${QXT-SOURCES}
|
||||
${QXT-SOURCES-MOC}
|
||||
)
|
||||
|
||||
QT5_USE_MODULES(qxt Core Widgets X11Extras)
|
||||
|
|
|
@ -1,432 +0,0 @@
|
|||
diff -ru libqxt-old/src/gui/keymapper_x11.h libqxt/src/gui/keymapper_x11.h
|
||||
--- libqxt-old/src/gui/keymapper_x11.h 2010-04-21 15:17:56.000000000 +0100
|
||||
+++ libqxt/src/gui/keymapper_x11.h 2010-04-21 15:18:16.000000000 +0100
|
||||
@@ -0,0 +1,364 @@
|
||||
+#ifndef KEYMAPPER_X11_H
|
||||
+#define KEYMAPPER_X11_H
|
||||
+
|
||||
+// (davidsansome) Nicked from qkeymapper_x11.cpp
|
||||
+
|
||||
+#include <Qt>
|
||||
+
|
||||
+#define XK_MISCELLANY
|
||||
+#define XK_LATIN1
|
||||
+#define XK_KOREAN
|
||||
+#define XK_XKB_KEYS
|
||||
+#include <X11/keysymdef.h>
|
||||
+
|
||||
+//
|
||||
+// Keyboard event translation
|
||||
+//
|
||||
+
|
||||
+#ifndef XK_ISO_Left_Tab
|
||||
+#define XK_ISO_Left_Tab 0xFE20
|
||||
+#endif
|
||||
+
|
||||
+#ifndef XK_dead_hook
|
||||
+#define XK_dead_hook 0xFE61
|
||||
+#endif
|
||||
+
|
||||
+#ifndef XK_dead_horn
|
||||
+#define XK_dead_horn 0xFE62
|
||||
+#endif
|
||||
+
|
||||
+#ifndef XK_Codeinput
|
||||
+#define XK_Codeinput 0xFF37
|
||||
+#endif
|
||||
+
|
||||
+#ifndef XK_Kanji_Bangou
|
||||
+#define XK_Kanji_Bangou 0xFF37 /* same as codeinput */
|
||||
+#endif
|
||||
+
|
||||
+// Fix old X libraries
|
||||
+#ifndef XK_KP_Home
|
||||
+#define XK_KP_Home 0xFF95
|
||||
+#endif
|
||||
+#ifndef XK_KP_Left
|
||||
+#define XK_KP_Left 0xFF96
|
||||
+#endif
|
||||
+#ifndef XK_KP_Up
|
||||
+#define XK_KP_Up 0xFF97
|
||||
+#endif
|
||||
+#ifndef XK_KP_Right
|
||||
+#define XK_KP_Right 0xFF98
|
||||
+#endif
|
||||
+#ifndef XK_KP_Down
|
||||
+#define XK_KP_Down 0xFF99
|
||||
+#endif
|
||||
+#ifndef XK_KP_Prior
|
||||
+#define XK_KP_Prior 0xFF9A
|
||||
+#endif
|
||||
+#ifndef XK_KP_Next
|
||||
+#define XK_KP_Next 0xFF9B
|
||||
+#endif
|
||||
+#ifndef XK_KP_End
|
||||
+#define XK_KP_End 0xFF9C
|
||||
+#endif
|
||||
+#ifndef XK_KP_Insert
|
||||
+#define XK_KP_Insert 0xFF9E
|
||||
+#endif
|
||||
+#ifndef XK_KP_Delete
|
||||
+#define XK_KP_Delete 0xFF9F
|
||||
+#endif
|
||||
+
|
||||
+// the next lines are taken from XFree > 4.0 (X11/XF86keysyms.h), defining some special
|
||||
+// multimedia keys. They are included here as not every system has them.
|
||||
+#define XF86XK_Standby 0x1008FF10
|
||||
+#define XF86XK_AudioLowerVolume 0x1008FF11
|
||||
+#define XF86XK_AudioMute 0x1008FF12
|
||||
+#define XF86XK_AudioRaiseVolume 0x1008FF13
|
||||
+#define XF86XK_AudioPlay 0x1008FF14
|
||||
+#define XF86XK_AudioStop 0x1008FF15
|
||||
+#define XF86XK_AudioPrev 0x1008FF16
|
||||
+#define XF86XK_AudioNext 0x1008FF17
|
||||
+#define XF86XK_HomePage 0x1008FF18
|
||||
+#define XF86XK_Calculator 0x1008FF1D
|
||||
+#define XF86XK_Mail 0x1008FF19
|
||||
+#define XF86XK_Start 0x1008FF1A
|
||||
+#define XF86XK_Search 0x1008FF1B
|
||||
+#define XF86XK_AudioRecord 0x1008FF1C
|
||||
+#define XF86XK_Back 0x1008FF26
|
||||
+#define XF86XK_Forward 0x1008FF27
|
||||
+#define XF86XK_Stop 0x1008FF28
|
||||
+#define XF86XK_Refresh 0x1008FF29
|
||||
+#define XF86XK_Favorites 0x1008FF30
|
||||
+#define XF86XK_AudioPause 0x1008FF31
|
||||
+#define XF86XK_AudioMedia 0x1008FF32
|
||||
+#define XF86XK_MyComputer 0x1008FF33
|
||||
+#define XF86XK_OpenURL 0x1008FF38
|
||||
+#define XF86XK_Launch0 0x1008FF40
|
||||
+#define XF86XK_Launch1 0x1008FF41
|
||||
+#define XF86XK_Launch2 0x1008FF42
|
||||
+#define XF86XK_Launch3 0x1008FF43
|
||||
+#define XF86XK_Launch4 0x1008FF44
|
||||
+#define XF86XK_Launch5 0x1008FF45
|
||||
+#define XF86XK_Launch6 0x1008FF46
|
||||
+#define XF86XK_Launch7 0x1008FF47
|
||||
+#define XF86XK_Launch8 0x1008FF48
|
||||
+#define XF86XK_Launch9 0x1008FF49
|
||||
+#define XF86XK_LaunchA 0x1008FF4A
|
||||
+#define XF86XK_LaunchB 0x1008FF4B
|
||||
+#define XF86XK_LaunchC 0x1008FF4C
|
||||
+#define XF86XK_LaunchD 0x1008FF4D
|
||||
+#define XF86XK_LaunchE 0x1008FF4E
|
||||
+#define XF86XK_LaunchF 0x1008FF4F
|
||||
+// end of XF86keysyms.h
|
||||
+
|
||||
+// Special keys used by Qtopia, mapped into the X11 private keypad range.
|
||||
+#define QTOPIAXK_Select 0x11000601
|
||||
+#define QTOPIAXK_Yes 0x11000602
|
||||
+#define QTOPIAXK_No 0x11000603
|
||||
+#define QTOPIAXK_Cancel 0x11000604
|
||||
+#define QTOPIAXK_Printer 0x11000605
|
||||
+#define QTOPIAXK_Execute 0x11000606
|
||||
+#define QTOPIAXK_Sleep 0x11000607
|
||||
+#define QTOPIAXK_Play 0x11000608
|
||||
+#define QTOPIAXK_Zoom 0x11000609
|
||||
+#define QTOPIAXK_Context1 0x1100060A
|
||||
+#define QTOPIAXK_Context2 0x1100060B
|
||||
+#define QTOPIAXK_Context3 0x1100060C
|
||||
+#define QTOPIAXK_Context4 0x1100060D
|
||||
+#define QTOPIAXK_Call 0x1100060E
|
||||
+#define QTOPIAXK_Hangup 0x1100060F
|
||||
+#define QTOPIAXK_Flip 0x11000610
|
||||
+
|
||||
+// keyboard mapping table
|
||||
+static const unsigned int KeyTbl[] = {
|
||||
+
|
||||
+ // misc keys
|
||||
+
|
||||
+ XK_Escape, Qt::Key_Escape,
|
||||
+ XK_Tab, Qt::Key_Tab,
|
||||
+ XK_ISO_Left_Tab, Qt::Key_Backtab,
|
||||
+ XK_BackSpace, Qt::Key_Backspace,
|
||||
+ XK_Return, Qt::Key_Return,
|
||||
+ XK_Insert, Qt::Key_Insert,
|
||||
+ XK_Delete, Qt::Key_Delete,
|
||||
+ XK_Clear, Qt::Key_Delete,
|
||||
+ XK_Pause, Qt::Key_Pause,
|
||||
+ XK_Print, Qt::Key_Print,
|
||||
+ 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq
|
||||
+ 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq
|
||||
+
|
||||
+ // cursor movement
|
||||
+
|
||||
+ XK_Home, Qt::Key_Home,
|
||||
+ XK_End, Qt::Key_End,
|
||||
+ XK_Left, Qt::Key_Left,
|
||||
+ XK_Up, Qt::Key_Up,
|
||||
+ XK_Right, Qt::Key_Right,
|
||||
+ XK_Down, Qt::Key_Down,
|
||||
+ XK_Prior, Qt::Key_PageUp,
|
||||
+ XK_Next, Qt::Key_PageDown,
|
||||
+
|
||||
+ // modifiers
|
||||
+
|
||||
+ XK_Shift_L, Qt::Key_Shift,
|
||||
+ XK_Shift_R, Qt::Key_Shift,
|
||||
+ XK_Shift_Lock, Qt::Key_Shift,
|
||||
+ XK_Control_L, Qt::Key_Control,
|
||||
+ XK_Control_R, Qt::Key_Control,
|
||||
+ XK_Meta_L, Qt::Key_Meta,
|
||||
+ XK_Meta_R, Qt::Key_Meta,
|
||||
+ XK_Alt_L, Qt::Key_Alt,
|
||||
+ XK_Alt_R, Qt::Key_Alt,
|
||||
+ XK_Caps_Lock, Qt::Key_CapsLock,
|
||||
+ XK_Num_Lock, Qt::Key_NumLock,
|
||||
+ XK_Scroll_Lock, Qt::Key_ScrollLock,
|
||||
+ XK_Super_L, Qt::Key_Super_L,
|
||||
+ XK_Super_R, Qt::Key_Super_R,
|
||||
+ XK_Menu, Qt::Key_Menu,
|
||||
+ XK_Hyper_L, Qt::Key_Hyper_L,
|
||||
+ XK_Hyper_R, Qt::Key_Hyper_R,
|
||||
+ XK_Help, Qt::Key_Help,
|
||||
+ 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab
|
||||
+ 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11)
|
||||
+ 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12)
|
||||
+
|
||||
+ // numeric and function keypad keys
|
||||
+
|
||||
+ XK_KP_Space, Qt::Key_Space,
|
||||
+ XK_KP_Tab, Qt::Key_Tab,
|
||||
+ XK_KP_Enter, Qt::Key_Enter,
|
||||
+ //XK_KP_F1, Qt::Key_F1,
|
||||
+ //XK_KP_F2, Qt::Key_F2,
|
||||
+ //XK_KP_F3, Qt::Key_F3,
|
||||
+ //XK_KP_F4, Qt::Key_F4,
|
||||
+ XK_KP_Home, Qt::Key_Home,
|
||||
+ XK_KP_Left, Qt::Key_Left,
|
||||
+ XK_KP_Up, Qt::Key_Up,
|
||||
+ XK_KP_Right, Qt::Key_Right,
|
||||
+ XK_KP_Down, Qt::Key_Down,
|
||||
+ XK_KP_Prior, Qt::Key_PageUp,
|
||||
+ XK_KP_Next, Qt::Key_PageDown,
|
||||
+ XK_KP_End, Qt::Key_End,
|
||||
+ XK_KP_Begin, Qt::Key_Clear,
|
||||
+ XK_KP_Insert, Qt::Key_Insert,
|
||||
+ XK_KP_Delete, Qt::Key_Delete,
|
||||
+ XK_KP_Equal, Qt::Key_Equal,
|
||||
+ XK_KP_Multiply, Qt::Key_Asterisk,
|
||||
+ XK_KP_Add, Qt::Key_Plus,
|
||||
+ XK_KP_Separator, Qt::Key_Comma,
|
||||
+ XK_KP_Subtract, Qt::Key_Minus,
|
||||
+ XK_KP_Decimal, Qt::Key_Period,
|
||||
+ XK_KP_Divide, Qt::Key_Slash,
|
||||
+
|
||||
+ // International input method support keys
|
||||
+
|
||||
+ // International & multi-key character composition
|
||||
+ XK_ISO_Level3_Shift, Qt::Key_AltGr,
|
||||
+ XK_Multi_key, Qt::Key_Multi_key,
|
||||
+ XK_Codeinput, Qt::Key_Codeinput,
|
||||
+ XK_SingleCandidate, Qt::Key_SingleCandidate,
|
||||
+ XK_MultipleCandidate, Qt::Key_MultipleCandidate,
|
||||
+ XK_PreviousCandidate, Qt::Key_PreviousCandidate,
|
||||
+
|
||||
+ // Misc Functions
|
||||
+ XK_Mode_switch, Qt::Key_Mode_switch,
|
||||
+ XK_script_switch, Qt::Key_Mode_switch,
|
||||
+
|
||||
+ // Japanese keyboard support
|
||||
+ XK_Kanji, Qt::Key_Kanji,
|
||||
+ XK_Muhenkan, Qt::Key_Muhenkan,
|
||||
+ //XK_Henkan_Mode, Qt::Key_Henkan_Mode,
|
||||
+ XK_Henkan_Mode, Qt::Key_Henkan,
|
||||
+ XK_Henkan, Qt::Key_Henkan,
|
||||
+ XK_Romaji, Qt::Key_Romaji,
|
||||
+ XK_Hiragana, Qt::Key_Hiragana,
|
||||
+ XK_Katakana, Qt::Key_Katakana,
|
||||
+ XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana,
|
||||
+ XK_Zenkaku, Qt::Key_Zenkaku,
|
||||
+ XK_Hankaku, Qt::Key_Hankaku,
|
||||
+ XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku,
|
||||
+ XK_Touroku, Qt::Key_Touroku,
|
||||
+ XK_Massyo, Qt::Key_Massyo,
|
||||
+ XK_Kana_Lock, Qt::Key_Kana_Lock,
|
||||
+ XK_Kana_Shift, Qt::Key_Kana_Shift,
|
||||
+ XK_Eisu_Shift, Qt::Key_Eisu_Shift,
|
||||
+ XK_Eisu_toggle, Qt::Key_Eisu_toggle,
|
||||
+ //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou,
|
||||
+ //XK_Zen_Koho, Qt::Key_Zen_Koho,
|
||||
+ //XK_Mae_Koho, Qt::Key_Mae_Koho,
|
||||
+ XK_Kanji_Bangou, Qt::Key_Codeinput,
|
||||
+ XK_Zen_Koho, Qt::Key_MultipleCandidate,
|
||||
+ XK_Mae_Koho, Qt::Key_PreviousCandidate,
|
||||
+
|
||||
+#ifdef XK_KOREAN
|
||||
+ // Korean keyboard support
|
||||
+ XK_Hangul, Qt::Key_Hangul,
|
||||
+ XK_Hangul_Start, Qt::Key_Hangul_Start,
|
||||
+ XK_Hangul_End, Qt::Key_Hangul_End,
|
||||
+ XK_Hangul_Hanja, Qt::Key_Hangul_Hanja,
|
||||
+ XK_Hangul_Jamo, Qt::Key_Hangul_Jamo,
|
||||
+ XK_Hangul_Romaja, Qt::Key_Hangul_Romaja,
|
||||
+ //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput,
|
||||
+ XK_Hangul_Codeinput, Qt::Key_Codeinput,
|
||||
+ XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja,
|
||||
+ XK_Hangul_Banja, Qt::Key_Hangul_Banja,
|
||||
+ XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja,
|
||||
+ XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja,
|
||||
+ //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate,
|
||||
+ //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate,
|
||||
+ //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate,
|
||||
+ XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate,
|
||||
+ XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate,
|
||||
+ XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate,
|
||||
+ XK_Hangul_Special, Qt::Key_Hangul_Special,
|
||||
+ //XK_Hangul_switch, Qt::Key_Hangul_switch,
|
||||
+ XK_Hangul_switch, Qt::Key_Mode_switch,
|
||||
+#endif // XK_KOREAN
|
||||
+
|
||||
+ // dead keys
|
||||
+ XK_dead_grave, Qt::Key_Dead_Grave,
|
||||
+ XK_dead_acute, Qt::Key_Dead_Acute,
|
||||
+ XK_dead_circumflex, Qt::Key_Dead_Circumflex,
|
||||
+ XK_dead_tilde, Qt::Key_Dead_Tilde,
|
||||
+ XK_dead_macron, Qt::Key_Dead_Macron,
|
||||
+ XK_dead_breve, Qt::Key_Dead_Breve,
|
||||
+ XK_dead_abovedot, Qt::Key_Dead_Abovedot,
|
||||
+ XK_dead_diaeresis, Qt::Key_Dead_Diaeresis,
|
||||
+ XK_dead_abovering, Qt::Key_Dead_Abovering,
|
||||
+ XK_dead_doubleacute, Qt::Key_Dead_Doubleacute,
|
||||
+ XK_dead_caron, Qt::Key_Dead_Caron,
|
||||
+ XK_dead_cedilla, Qt::Key_Dead_Cedilla,
|
||||
+ XK_dead_ogonek, Qt::Key_Dead_Ogonek,
|
||||
+ XK_dead_iota, Qt::Key_Dead_Iota,
|
||||
+ XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound,
|
||||
+ XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound,
|
||||
+ XK_dead_belowdot, Qt::Key_Dead_Belowdot,
|
||||
+ XK_dead_hook, Qt::Key_Dead_Hook,
|
||||
+ XK_dead_horn, Qt::Key_Dead_Horn,
|
||||
+
|
||||
+ // Special multimedia keys
|
||||
+ // currently only tested with MS internet keyboard
|
||||
+
|
||||
+ // browsing keys
|
||||
+ XF86XK_Back, Qt::Key_Back,
|
||||
+ XF86XK_Forward, Qt::Key_Forward,
|
||||
+ XF86XK_Stop, Qt::Key_Stop,
|
||||
+ XF86XK_Refresh, Qt::Key_Refresh,
|
||||
+ XF86XK_Favorites, Qt::Key_Favorites,
|
||||
+ XF86XK_AudioMedia, Qt::Key_LaunchMedia,
|
||||
+ XF86XK_OpenURL, Qt::Key_OpenUrl,
|
||||
+ XF86XK_HomePage, Qt::Key_HomePage,
|
||||
+ XF86XK_Search, Qt::Key_Search,
|
||||
+
|
||||
+ // media keys
|
||||
+ XF86XK_AudioLowerVolume, Qt::Key_VolumeDown,
|
||||
+ XF86XK_AudioMute, Qt::Key_VolumeMute,
|
||||
+ XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp,
|
||||
+ XF86XK_AudioPlay, Qt::Key_MediaPlay,
|
||||
+ XF86XK_AudioStop, Qt::Key_MediaStop,
|
||||
+ XF86XK_AudioPrev, Qt::Key_MediaPrevious,
|
||||
+ XF86XK_AudioNext, Qt::Key_MediaNext,
|
||||
+ XF86XK_AudioRecord, Qt::Key_MediaRecord,
|
||||
+
|
||||
+ // launch keys
|
||||
+ XF86XK_Mail, Qt::Key_LaunchMail,
|
||||
+ XF86XK_MyComputer, Qt::Key_Launch0,
|
||||
+ XF86XK_Calculator, Qt::Key_Launch1,
|
||||
+ XF86XK_Standby, Qt::Key_Standby,
|
||||
+
|
||||
+ XF86XK_Launch0, Qt::Key_Launch2,
|
||||
+ XF86XK_Launch1, Qt::Key_Launch3,
|
||||
+ XF86XK_Launch2, Qt::Key_Launch4,
|
||||
+ XF86XK_Launch3, Qt::Key_Launch5,
|
||||
+ XF86XK_Launch4, Qt::Key_Launch6,
|
||||
+ XF86XK_Launch5, Qt::Key_Launch7,
|
||||
+ XF86XK_Launch6, Qt::Key_Launch8,
|
||||
+ XF86XK_Launch7, Qt::Key_Launch9,
|
||||
+ XF86XK_Launch8, Qt::Key_LaunchA,
|
||||
+ XF86XK_Launch9, Qt::Key_LaunchB,
|
||||
+ XF86XK_LaunchA, Qt::Key_LaunchC,
|
||||
+ XF86XK_LaunchB, Qt::Key_LaunchD,
|
||||
+ XF86XK_LaunchC, Qt::Key_LaunchE,
|
||||
+ XF86XK_LaunchD, Qt::Key_LaunchF,
|
||||
+
|
||||
+ // Qtopia keys
|
||||
+ QTOPIAXK_Select, Qt::Key_Select,
|
||||
+ QTOPIAXK_Yes, Qt::Key_Yes,
|
||||
+ QTOPIAXK_No, Qt::Key_No,
|
||||
+ QTOPIAXK_Cancel, Qt::Key_Cancel,
|
||||
+ QTOPIAXK_Printer, Qt::Key_Printer,
|
||||
+ QTOPIAXK_Execute, Qt::Key_Execute,
|
||||
+ QTOPIAXK_Sleep, Qt::Key_Sleep,
|
||||
+ QTOPIAXK_Play, Qt::Key_Play,
|
||||
+ QTOPIAXK_Zoom, Qt::Key_Zoom,
|
||||
+ QTOPIAXK_Context1, Qt::Key_Context1,
|
||||
+ QTOPIAXK_Context2, Qt::Key_Context2,
|
||||
+ QTOPIAXK_Context3, Qt::Key_Context3,
|
||||
+ QTOPIAXK_Context4, Qt::Key_Context4,
|
||||
+ QTOPIAXK_Call, Qt::Key_Call,
|
||||
+ QTOPIAXK_Hangup, Qt::Key_Hangup,
|
||||
+ QTOPIAXK_Flip, Qt::Key_Flip,
|
||||
+
|
||||
+ 0, 0
|
||||
+};
|
||||
+
|
||||
+#endif // KEYMAPPER_X11_H
|
||||
diff -ru libqxt-old/src/gui/qxtglobalshortcut_win.cpp libqxt/src/gui/qxtglobalshortcut_win.cpp
|
||||
--- libqxt-old/src/gui/qxtglobalshortcut_win.cpp 2010-04-21 15:17:56.000000000 +0100
|
||||
+++ libqxt/src/gui/qxtglobalshortcut_win.cpp 2010-04-21 15:18:16.000000000 +0100
|
||||
@@ -156,6 +156,21 @@
|
||||
case Qt::Key_Slash:
|
||||
return VK_DIVIDE;
|
||||
|
||||
+ case Qt::Key_MediaNext:
|
||||
+ return VK_MEDIA_NEXT_TRACK;
|
||||
+ case Qt::Key_MediaPrevious:
|
||||
+ return VK_MEDIA_PREV_TRACK;
|
||||
+ case Qt::Key_MediaStop:
|
||||
+ return VK_MEDIA_STOP;
|
||||
+ case Qt::Key_MediaPlay:
|
||||
+ return VK_MEDIA_PLAY_PAUSE;
|
||||
+ case Qt::Key_VolumeDown:
|
||||
+ return VK_VOLUME_DOWN;
|
||||
+ case Qt::Key_VolumeUp:
|
||||
+ return VK_VOLUME_UP;
|
||||
+ case Qt::Key_VolumeMute:
|
||||
+ return VK_VOLUME_MUTE;
|
||||
+
|
||||
// numbers
|
||||
case Qt::Key_0:
|
||||
case Qt::Key_1:
|
||||
diff -ru libqxt-old/src/gui/qxtglobalshortcut_x11.cpp libqxt/src/gui/qxtglobalshortcut_x11.cpp
|
||||
--- libqxt-old/src/gui/qxtglobalshortcut_x11.cpp 2010-04-21 15:17:56.000000000 +0100
|
||||
+++ libqxt/src/gui/qxtglobalshortcut_x11.cpp 2010-04-21 15:18:16.000000000 +0100
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <QX11Info>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
+#include "keymapper_x11.h"
|
||||
+
|
||||
static int (*original_x_errhandler)(Display* display, XErrorEvent* event);
|
||||
|
||||
static int qxt_x_errhandler(Display* display, XErrorEvent *event)
|
||||
@@ -81,8 +83,25 @@
|
||||
|
||||
quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key)
|
||||
{
|
||||
+ // (davidsansome) Try the table from QKeyMapper first - this seems to be
|
||||
+ // the only way to get Keysyms for the media keys.
|
||||
+ unsigned int keysym = 0;
|
||||
+ int i = 0;
|
||||
+ while (KeyTbl[i]) {
|
||||
+ if (KeyTbl[i+1] == static_cast<uint>(key)) {
|
||||
+ keysym = KeyTbl[i];
|
||||
+ break;
|
||||
+ }
|
||||
+ i += 2;
|
||||
+ }
|
||||
+
|
||||
+ // If that didn't work then fall back on XStringToKeysym
|
||||
+ if (!keysym) {
|
||||
+ keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data());
|
||||
+ }
|
||||
+
|
||||
Display* display = QX11Info::display();
|
||||
- return XKeysymToKeycode(display, XStringToKeysym(QKeySequence(key).toString().toLatin1().data()));
|
||||
+ return XKeysymToKeycode(display, keysym);
|
||||
}
|
||||
|
||||
bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods)
|
|
@ -1,15 +0,0 @@
|
|||
Index: qxtglobalshortcut_x11.cpp
|
||||
===================================================================
|
||||
--- qxtglobalshortcut_x11.cpp (revision 1208)
|
||||
+++ qxtglobalshortcut_x11.cpp (working copy)
|
||||
@@ -74,8 +74,9 @@
|
||||
native |= ControlMask;
|
||||
if (modifiers & Qt::AltModifier)
|
||||
native |= Mod1Mask;
|
||||
+ if (modifiers & Qt::MetaModifier)
|
||||
+ native |= Mod4Mask;
|
||||
// TODO: resolve these?
|
||||
- //if (modifiers & Qt::MetaModifier)
|
||||
//if (modifiers & Qt::KeypadModifier)
|
||||
//if (modifiers & Qt::GroupSwitchModifier)
|
||||
return native;
|
|
@ -1,27 +1,33 @@
|
|||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) Qxt Foundation. Some rights reserved.
|
||||
**
|
||||
** This file is part of the QxtCore module of the Qxt library.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the Common Public License, version 1.0, as published
|
||||
** by IBM, and/or under the terms of the GNU Lesser General Public License,
|
||||
** version 2.1, as published by the Free Software Foundation.
|
||||
**
|
||||
** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
|
||||
** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
|
||||
** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
|
||||
** FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
** You should have received a copy of the CPL and the LGPL along with this
|
||||
** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
|
||||
** included with the source distribution for more information.
|
||||
** If you did not receive a copy of the licenses, contact the Qxt Foundation.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
**
|
||||
****************************************************************************/
|
||||
** Copyright (c) 2006 - 2011, the LibQxt project.
|
||||
** See the Qxt AUTHORS file for a list of authors and copyright holders.
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** * Neither the name of the LibQxt project nor the
|
||||
** names of its contributors may be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
*****************************************************************************/
|
||||
|
||||
#include "qxtglobal.h"
|
||||
|
||||
|
@ -74,7 +80,7 @@
|
|||
|
||||
\sa QXT_VERSION_STR
|
||||
*/
|
||||
const char* qxtVersion()
|
||||
const char * qxtVersion()
|
||||
{
|
||||
return QXT_VERSION_STR;
|
||||
}
|
||||
|
@ -170,13 +176,14 @@ void MyTestPrivate::doQuux() {
|
|||
* \relates <QxtPimpl>
|
||||
* Declares that a public class has a related private class.
|
||||
*
|
||||
* This shuold be put in the private section of the public class. The parameter is the name of the public class.
|
||||
* This shuold be put in the private section of the public class. The
|
||||
* parameter \a PUB must be the name of the public class.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \macro QXT_DECLARE_PUBLIC(PUB)
|
||||
* \relates <QxtPimpl>
|
||||
* Declares that a private class has a related public class.
|
||||
* Declares that a private class has a related public class named \a PUB.
|
||||
*
|
||||
* This may be put anywhere in the declaration of the private class. The parameter is the name of the public class.
|
||||
*/
|
||||
|
@ -187,23 +194,26 @@ void MyTestPrivate::doQuux() {
|
|||
* Initializes resources owned by the private class.
|
||||
*
|
||||
* This should be called from the public class's constructor,
|
||||
* before qxt_d() is used for the first time. The parameter is the name of the public class.
|
||||
* before qxt_d() is used for the first time. The parameter \a PUB must be
|
||||
* the name of the public class.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \macro QXT_D(PUB)
|
||||
* \relates <QxtPimpl>
|
||||
* Returns a reference in the current scope named "d" to the private class.
|
||||
* Returns a reference in the current scope named "d" to the private class
|
||||
* associated with the public class \a PUB.
|
||||
*
|
||||
* This function is only available in a class using \a QXT_DECLARE_PRIVATE.
|
||||
* This function is only available in a class using QXT_DECLARE_PRIVATE().
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \macro QXT_P(PUB)
|
||||
* \relates <QxtPimpl>
|
||||
* Creates a reference in the current scope named "q" to the public class.
|
||||
* Creates a reference in the current scope named "q" to the public class
|
||||
* named \a PUB.
|
||||
*
|
||||
* This macro only works in a class using \a QXT_DECLARE_PUBLIC.
|
||||
* This macro only works in a class using QXT_DECLARE_PUBLIC().
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -228,7 +238,7 @@ void MyTestPrivate::doQuux() {
|
|||
* \relates <QxtPimpl>
|
||||
* Returns a reference to the public class.
|
||||
*
|
||||
* This function is only available in a class using \a QXT_DECLARE_PUBLIC.
|
||||
* This function is only available in a class using QXT_DECLARE_PUBLIC().
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -236,6 +246,6 @@ void MyTestPrivate::doQuux() {
|
|||
* \relates <QxtPimpl>
|
||||
* Returns a const reference to the public class.
|
||||
*
|
||||
* This function is only available in a class using \a QXT_DECLARE_PUBLIC.
|
||||
* This function is only available in a class using QXT_DECLARE_PUBLIC().
|
||||
* This overload will be automatically used in const functions.
|
||||
*/
|
||||
|
|
|
@ -1,47 +1,57 @@
|
|||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) Qxt Foundation. Some rights reserved.
|
||||
**
|
||||
** This file is part of the QxtCore module of the Qxt library.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the Common Public License, version 1.0, as published
|
||||
** by IBM, and/or under the terms of the GNU Lesser General Public License,
|
||||
** version 2.1, as published by the Free Software Foundation.
|
||||
**
|
||||
** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
|
||||
** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
|
||||
** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
|
||||
** FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
** You should have received a copy of the CPL and the LGPL along with this
|
||||
** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
|
||||
** included with the source distribution for more information.
|
||||
** If you did not receive a copy of the licenses, contact the Qxt Foundation.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
**
|
||||
****************************************************************************/
|
||||
** Copyright (c) 2006 - 2011, the LibQxt project.
|
||||
** See the Qxt AUTHORS file for a list of authors and copyright holders.
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** * Neither the name of the LibQxt project nor the
|
||||
** names of its contributors may be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QXTGLOBAL_H
|
||||
#define QXTGLOBAL_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#define QXT_VERSION 0x000600
|
||||
#define QXT_VERSION_STR "0.6.0"
|
||||
#define QXT_VERSION 0x000700
|
||||
#define QXT_VERSION_STR "0.7.0"
|
||||
|
||||
//--------------------------global macros------------------------------
|
||||
|
||||
#ifndef QXT_NO_MACROS
|
||||
|
||||
#ifndef _countof
|
||||
#define _countof(x) (sizeof(x)/sizeof(*x))
|
||||
#endif
|
||||
|
||||
#endif // QXT_NO_MACROS
|
||||
|
||||
//--------------------------export macros------------------------------
|
||||
|
||||
#define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE
|
||||
|
||||
#if !defined(QXT_STATIC)
|
||||
#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
|
||||
# if defined(BUILD_QXT_CORE)
|
||||
# define QXT_CORE_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
|
@ -51,7 +61,7 @@
|
|||
# define QXT_CORE_EXPORT
|
||||
#endif // BUILD_QXT_CORE
|
||||
|
||||
#if !defined(QXT_STATIC)
|
||||
#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
|
||||
# if defined(BUILD_QXT_GUI)
|
||||
# define QXT_GUI_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
|
@ -61,7 +71,7 @@
|
|||
# define QXT_GUI_EXPORT
|
||||
#endif // BUILD_QXT_GUI
|
||||
|
||||
#if !defined(QXT_STATIC)
|
||||
#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
|
||||
# if defined(BUILD_QXT_NETWORK)
|
||||
# define QXT_NETWORK_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
|
@ -71,7 +81,7 @@
|
|||
# define QXT_NETWORK_EXPORT
|
||||
#endif // BUILD_QXT_NETWORK
|
||||
|
||||
#if !defined(QXT_STATIC)
|
||||
#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
|
||||
# if defined(BUILD_QXT_SQL)
|
||||
# define QXT_SQL_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
|
@ -81,7 +91,7 @@
|
|||
# define QXT_SQL_EXPORT
|
||||
#endif // BUILD_QXT_SQL
|
||||
|
||||
#if !defined(QXT_STATIC)
|
||||
#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
|
||||
# if defined(BUILD_QXT_WEB)
|
||||
# define QXT_WEB_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
|
@ -91,7 +101,7 @@
|
|||
# define QXT_WEB_EXPORT
|
||||
#endif // BUILD_QXT_WEB
|
||||
|
||||
#if !defined(QXT_STATIC)
|
||||
#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
|
||||
# if defined(BUILD_QXT_BERKELEY)
|
||||
# define QXT_BERKELEY_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
|
@ -101,7 +111,7 @@
|
|||
# define QXT_BERKELEY_EXPORT
|
||||
#endif // BUILD_QXT_BERKELEY
|
||||
|
||||
#if !defined(QXT_STATIC)
|
||||
#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
|
||||
# if defined(BUILD_QXT_ZEROCONF)
|
||||
# define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
|
@ -111,7 +121,7 @@
|
|||
# define QXT_ZEROCONF_EXPORT
|
||||
#endif // QXT_ZEROCONF_EXPORT
|
||||
|
||||
#if defined BUILD_QXT_CORE || defined BUILD_QXT_GUI || defined BUILD_QXT_SQL || defined BUILD_QXT_NETWORK || defined BUILD_QXT_WEB || defined BUILD_QXT_BERKELEY || defined BUILD_QXT_ZEROCONF
|
||||
#if defined(BUILD_QXT_CORE) || defined(BUILD_QXT_GUI) || defined(BUILD_QXT_SQL) || defined(BUILD_QXT_NETWORK) || defined(BUILD_QXT_WEB) || defined(BUILD_QXT_BERKELEY) || defined(BUILD_QXT_ZEROCONF)
|
||||
# define BUILD_QXT
|
||||
#endif
|
||||
|
||||
|
@ -167,6 +177,14 @@ protected:
|
|||
{
|
||||
return *qxt_p_ptr;
|
||||
}
|
||||
inline PUB* qxt_ptr()
|
||||
{
|
||||
return qxt_p_ptr;
|
||||
}
|
||||
inline const PUB* qxt_ptr() const
|
||||
{
|
||||
return qxt_p_ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
PUB* qxt_p_ptr;
|
||||
|
@ -198,6 +216,14 @@ public:
|
|||
{
|
||||
return *static_cast<PVT*>(pvt);
|
||||
}
|
||||
inline PVT * operator->()
|
||||
{
|
||||
return static_cast<PVT*>(pvt);
|
||||
}
|
||||
inline const PVT * operator->() const
|
||||
{
|
||||
return static_cast<PVT*>(pvt);
|
||||
}
|
||||
private:
|
||||
QxtPrivateInterface(const QxtPrivateInterface&) { }
|
||||
QxtPrivateInterface& operator=(const QxtPrivateInterface&) { }
|
||||
|
|
|
@ -1,47 +1,69 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) Qxt Foundation. Some rights reserved.
|
||||
**
|
||||
** This file is part of the QxtGui module of the Qxt library.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the Common Public License, version 1.0, as published
|
||||
** by IBM, and/or under the terms of the GNU Lesser General Public License,
|
||||
** version 2.1, as published by the Free Software Foundation.
|
||||
**
|
||||
** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
|
||||
** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
|
||||
** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
|
||||
** FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
** You should have received a copy of the CPL and the LGPL along with this
|
||||
** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
|
||||
** included with the source distribution for more information.
|
||||
** If you did not receive a copy of the licenses, contact the Qxt Foundation.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "qxtglobalshortcut.h"
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2006 - 2011, the LibQxt project.
|
||||
** See the Qxt AUTHORS file for a list of authors and copyright holders.
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** * Neither the name of the LibQxt project nor the
|
||||
** names of its contributors may be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
*****************************************************************************/
|
||||
|
||||
#include "qxtglobalshortcut_p.h"
|
||||
#include <QAbstractEventDispatcher>
|
||||
#include <QtDebug>
|
||||
|
||||
bool QxtGlobalShortcutPrivate::error = false;
|
||||
#ifndef Q_WS_MAC
|
||||
int QxtGlobalShortcutPrivate::ref = 0;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0;
|
||||
#endif
|
||||
#endif // Q_WS_MAC
|
||||
QHash<QPair<quint32, quint32>, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts;
|
||||
|
||||
QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier)
|
||||
{
|
||||
#ifndef Q_WS_MAC
|
||||
if (!ref++)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter);
|
||||
#else
|
||||
QAbstractEventDispatcher::instance()->installNativeEventFilter(this);
|
||||
#endif
|
||||
#endif // Q_WS_MAC
|
||||
}
|
||||
|
||||
QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate()
|
||||
{
|
||||
#ifndef Q_WS_MAC
|
||||
if (!--ref)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
QAbstractEventDispatcher::instance()->setEventFilter(prevEventFilter);
|
||||
#else
|
||||
QAbstractEventDispatcher::instance()->removeNativeEventFilter(this);
|
||||
#endif
|
||||
#endif // Q_WS_MAC
|
||||
}
|
||||
|
||||
bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut)
|
||||
|
@ -52,19 +74,23 @@ bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut)
|
|||
const quint32 nativeKey = nativeKeycode(key);
|
||||
const quint32 nativeMods = nativeModifiers(mods);
|
||||
const bool res = registerShortcut(nativeKey, nativeMods);
|
||||
shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p());
|
||||
if (!res)
|
||||
if (res)
|
||||
shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p());
|
||||
else
|
||||
qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString();
|
||||
return res;
|
||||
}
|
||||
|
||||
bool QxtGlobalShortcutPrivate::unsetShortcut()
|
||||
{
|
||||
bool res = false;
|
||||
const quint32 nativeKey = nativeKeycode(key);
|
||||
const quint32 nativeMods = nativeModifiers(mods);
|
||||
const bool res = unregisterShortcut(nativeKey, nativeMods);
|
||||
shortcuts.remove(qMakePair(nativeKey, nativeMods));
|
||||
if (!res)
|
||||
if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p())
|
||||
res = unregisterShortcut(nativeKey, nativeMods);
|
||||
if (res)
|
||||
shortcuts.remove(qMakePair(nativeKey, nativeMods));
|
||||
else
|
||||
qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString();
|
||||
key = Qt::Key(0);
|
||||
mods = Qt::KeyboardModifiers(0);
|
||||
|
@ -80,7 +106,7 @@ void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativ
|
|||
|
||||
/*!
|
||||
\class QxtGlobalShortcut
|
||||
\inmodule QxtGui
|
||||
\inmodule QxtWidgets
|
||||
\brief The QxtGlobalShortcut class provides a global shortcut aka "hotkey".
|
||||
|
||||
A global shortcut triggers even if the application is not active. This
|
||||
|
@ -189,3 +215,4 @@ void QxtGlobalShortcut::setDisabled(bool disabled)
|
|||
{
|
||||
qxt_d().enabled = !disabled;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,28 +1,34 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) Qxt Foundation. Some rights reserved.
|
||||
**
|
||||
** This file is part of the QxtGui module of the Qxt library.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the Common Public License, version 1.0, as published
|
||||
** by IBM, and/or under the terms of the GNU Lesser General Public License,
|
||||
** version 2.1, as published by the Free Software Foundation.
|
||||
**
|
||||
** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
|
||||
** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
|
||||
** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
|
||||
** FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
** You should have received a copy of the CPL and the LGPL along with this
|
||||
** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
|
||||
** included with the source distribution for more information.
|
||||
** If you did not receive a copy of the licenses, contact the Qxt Foundation.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef QXTGLOBALSHORTCUT_H
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2006 - 2011, the LibQxt project.
|
||||
** See the Qxt AUTHORS file for a list of authors and copyright holders.
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** * Neither the name of the LibQxt project nor the
|
||||
** names of its contributors may be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
*****************************************************************************/
|
||||
|
||||
#define QXTGLOBALSHORTCUT_H
|
||||
|
||||
#include "qxtglobal.h"
|
||||
|
@ -56,3 +62,4 @@ Q_SIGNALS:
|
|||
};
|
||||
|
||||
#endif // QXTGLOBALSHORTCUT_H
|
||||
|
||||
|
|
|
@ -1,207 +1,258 @@
|
|||
#include <Carbon/Carbon.h>
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) Qxt Foundation. Some rights reserved.
|
||||
**
|
||||
** This file is part of the QxtGui module of the Qxt library.
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the Common Public License, version 1.0, as published
|
||||
** by IBM, and/or under the terms of the GNU Lesser General Public License,
|
||||
** version 2.1, as published by the Free Software Foundation.
|
||||
**
|
||||
** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
|
||||
** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
|
||||
** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
|
||||
** FITNESS FOR A PARTICULAR PURPOSE.
|
||||
**
|
||||
** You should have received a copy of the CPL and the LGPL along with this
|
||||
** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
|
||||
** included with the source distribution for more information.
|
||||
** If you did not receive a copy of the licenses, contact the Qxt Foundation.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
**
|
||||
****************************************************************************/
|
||||
#include <Carbon/Carbon.h>
|
||||
#include "qxtglobalshortcut_p.h"
|
||||
#include <QMap>
|
||||
#include <QHash>
|
||||
#include <QtDebug>
|
||||
#include <QApplication>
|
||||
** Copyright (c) 2006 - 2011, the LibQxt project.
|
||||
** See the Qxt AUTHORS file for a list of authors and copyright holders.
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** * Neither the name of the LibQxt project nor the
|
||||
** names of its contributors may be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
*****************************************************************************/
|
||||
|
||||
typedef QPair<uint, uint> Identifier;
|
||||
static QMap<quint32, EventHotKeyRef> keyRefs;
|
||||
static QHash<Identifier, quint32> keyIDs;
|
||||
static quint32 hotKeySerial = 0;
|
||||
static bool qxt_mac_handler_installed = false;
|
||||
|
||||
OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data)
|
||||
{
|
||||
// pass event to the app event filter
|
||||
Q_UNUSED(data);
|
||||
qApp->macEventFilter(nextHandler, event);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
bool QxtGlobalShortcutPrivate::eventFilter(void* message)
|
||||
//bool QxtGlobalShortcutPrivate::macEventFilter(EventHandlerCallRef caller, EventRef event)
|
||||
{
|
||||
EventRef event = (EventRef) message;
|
||||
if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed)
|
||||
{
|
||||
EventHotKeyID keyID;
|
||||
GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID);
|
||||
Identifier id = keyIDs.key(keyID.id);
|
||||
activateShortcut(id.second, id.first);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
quint32 native = 0;
|
||||
if (modifiers & Qt::ShiftModifier)
|
||||
native |= shiftKeyBit;
|
||||
if (modifiers & Qt::ControlModifier)
|
||||
native |= cmdKey;
|
||||
if (modifiers & Qt::AltModifier)
|
||||
native |= optionKey;
|
||||
if (modifiers & Qt::MetaModifier)
|
||||
native |= controlKey;
|
||||
if (modifiers & Qt::KeypadModifier)
|
||||
native |= kEventKeyModifierNumLockMask;
|
||||
return native;
|
||||
}
|
||||
|
||||
quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key)
|
||||
{
|
||||
UTF16Char ch;
|
||||
// Constants found in NSEvent.h from AppKit.framework
|
||||
if (key == Qt::Key_Up) ch = 0xF700;
|
||||
else if (key == Qt::Key_Down) ch = 0xF701;
|
||||
else if (key == Qt::Key_Left) ch = 0xF702;
|
||||
else if (key == Qt::Key_Right) ch = 0xF703;
|
||||
else if (key >= Qt::Key_F1 && key <= Qt::Key_F35)
|
||||
ch = key - Qt::Key_F1 + 0xF704;
|
||||
else if (key == Qt::Key_Insert) ch = 0xF727;
|
||||
else if (key == Qt::Key_Delete) ch = 0xF728;
|
||||
else if (key == Qt::Key_Home) ch = 0xF729;
|
||||
else if (key == Qt::Key_End) ch = 0xF72B;
|
||||
else if (key == Qt::Key_PageUp) ch = 0xF72C;
|
||||
else if (key == Qt::Key_PageDown) ch = 0xF72D;
|
||||
else if (key == Qt::Key_Print) ch = 0xF72E;
|
||||
else if (key == Qt::Key_ScrollLock) ch = 0xF72F;
|
||||
else if (key == Qt::Key_Pause) ch = 0xF730;
|
||||
else if (key == Qt::Key_SysReq) ch = 0xF731;
|
||||
else if (key == Qt::Key_Stop) ch = 0xF734;
|
||||
else if (key == Qt::Key_Menu) ch = 0xF735;
|
||||
else if (key == Qt::Key_Select) ch = 0xF741;
|
||||
else if (key == Qt::Key_Execute) ch = 0xF742;
|
||||
else if (key == Qt::Key_Help) ch = 0xF746;
|
||||
else if (key == Qt::Key_Mode_switch) ch = 0xF747;
|
||||
else if (key == Qt::Key_Escape) ch = 27;
|
||||
else if (key == Qt::Key_Return) ch = 13;
|
||||
else if (key == Qt::Key_Enter) ch = 3;
|
||||
else if (key == Qt::Key_Tab) ch = 9;
|
||||
else ch = key;
|
||||
|
||||
KeyboardLayoutRef layout;
|
||||
KeyboardLayoutKind layoutKind;
|
||||
KLGetCurrentKeyboardLayout(&layout);
|
||||
KLGetKeyboardLayoutProperty(layout, kKLKind, const_cast<const void**>(reinterpret_cast<void**>(&layoutKind)));
|
||||
|
||||
if (layoutKind == kKLKCHRKind)
|
||||
{ // no Unicode available
|
||||
if (ch > 255) return 0;
|
||||
|
||||
char* data;
|
||||
KLGetKeyboardLayoutProperty(layout, kKLKCHRData, const_cast<const void**>(reinterpret_cast<void**>(&data)));
|
||||
int ct = *reinterpret_cast<short*>(data + 258);
|
||||
for (int i = 0; i < ct; i++)
|
||||
{
|
||||
char* keyTable = data + 260 + 128 * i;
|
||||
for (int j = 0; j < 128; j++)
|
||||
{
|
||||
if (keyTable[j] == ch) return j;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* data;
|
||||
KLGetKeyboardLayoutProperty(layout, kKLuchrData, const_cast<const void**>(reinterpret_cast<void**>(&data)));
|
||||
UCKeyboardLayout* header = reinterpret_cast<UCKeyboardLayout*>(data);
|
||||
UCKeyboardTypeHeader* table = header->keyboardTypeList;
|
||||
|
||||
for (quint32 i=0; i < header->keyboardTypeCount; i++)
|
||||
{
|
||||
UCKeyStateRecordsIndex* stateRec = 0;
|
||||
if (table[i].keyStateRecordsIndexOffset != 0)
|
||||
{
|
||||
stateRec = reinterpret_cast<UCKeyStateRecordsIndex*>(data + table[i].keyStateRecordsIndexOffset);
|
||||
if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0;
|
||||
}
|
||||
|
||||
UCKeyToCharTableIndex* charTable = reinterpret_cast<UCKeyToCharTableIndex*>(data + table[i].keyToCharTableIndexOffset);
|
||||
if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue;
|
||||
|
||||
for (quint32 j=0; j < charTable->keyToCharTableCount; j++)
|
||||
{
|
||||
UCKeyOutput* keyToChar = reinterpret_cast<UCKeyOutput*>(data + charTable->keyToCharTableOffsets[j]);
|
||||
for (quint32 k=0; k < charTable->keyToCharTableSize; k++)
|
||||
{
|
||||
if (keyToChar[k] & kUCKeyOutputTestForIndexMask)
|
||||
{
|
||||
long idx = keyToChar[k] & kUCKeyOutputGetIndexMask;
|
||||
if (stateRec && idx < stateRec->keyStateRecordCount)
|
||||
{
|
||||
UCKeyStateRecord* rec = reinterpret_cast<UCKeyStateRecord*>(data + stateRec->keyStateRecordOffsets[idx]);
|
||||
if (rec->stateZeroCharData == ch) return k;
|
||||
}
|
||||
}
|
||||
else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE)
|
||||
{
|
||||
if (keyToChar[k] == ch) return k;
|
||||
}
|
||||
} // for k
|
||||
} // for j
|
||||
} // for i
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods)
|
||||
{
|
||||
if (!qxt_mac_handler_installed)
|
||||
{
|
||||
EventTypeSpec t;
|
||||
t.eventClass = kEventClassKeyboard;
|
||||
t.eventKind = kEventHotKeyPressed;
|
||||
InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL);
|
||||
}
|
||||
|
||||
EventHotKeyID keyID;
|
||||
keyID.signature = 'cute';
|
||||
keyID.id = ++hotKeySerial;
|
||||
|
||||
EventHotKeyRef ref = 0;
|
||||
bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref);
|
||||
if (rv)
|
||||
{
|
||||
keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id);
|
||||
keyRefs.insert(keyID.id, ref);
|
||||
}
|
||||
qDebug() << ref;
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods)
|
||||
{
|
||||
Identifier id(nativeMods, nativeKey);
|
||||
if (!keyIDs.contains(id)) return false;
|
||||
|
||||
EventHotKeyRef ref = keyRefs.take(keyIDs[id]);
|
||||
keyIDs.remove(id);
|
||||
return !UnregisterEventHotKey(ref);
|
||||
}
|
||||
#include "qxtglobalshortcut_p.h"
|
||||
#include <QMap>
|
||||
#include <QHash>
|
||||
#include <QtDebug>
|
||||
#include <QApplication>
|
||||
|
||||
typedef QPair<uint, uint> Identifier;
|
||||
static QMap<quint32, EventHotKeyRef> keyRefs;
|
||||
static QHash<Identifier, quint32> keyIDs;
|
||||
static quint32 hotKeySerial = 0;
|
||||
static bool qxt_mac_handler_installed = false;
|
||||
|
||||
OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data)
|
||||
{
|
||||
Q_UNUSED(nextHandler);
|
||||
Q_UNUSED(data);
|
||||
if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed)
|
||||
{
|
||||
EventHotKeyID keyID;
|
||||
GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID);
|
||||
Identifier id = keyIDs.key(keyID.id);
|
||||
QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first);
|
||||
}
|
||||
return noErr;
|
||||
}
|
||||
|
||||
quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
quint32 native = 0;
|
||||
if (modifiers & Qt::ShiftModifier)
|
||||
native |= shiftKey;
|
||||
if (modifiers & Qt::ControlModifier)
|
||||
native |= cmdKey;
|
||||
if (modifiers & Qt::AltModifier)
|
||||
native |= optionKey;
|
||||
if (modifiers & Qt::MetaModifier)
|
||||
native |= controlKey;
|
||||
if (modifiers & Qt::KeypadModifier)
|
||||
native |= kEventKeyModifierNumLockMask;
|
||||
return native;
|
||||
}
|
||||
|
||||
quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key)
|
||||
{
|
||||
UTF16Char ch;
|
||||
// Constants found in NSEvent.h from AppKit.framework
|
||||
switch (key)
|
||||
{
|
||||
case Qt::Key_Return:
|
||||
return kVK_Return;
|
||||
case Qt::Key_Enter:
|
||||
return kVK_ANSI_KeypadEnter;
|
||||
case Qt::Key_Tab:
|
||||
return kVK_Tab;
|
||||
case Qt::Key_Space:
|
||||
return kVK_Space;
|
||||
case Qt::Key_Backspace:
|
||||
return kVK_Delete;
|
||||
case Qt::Key_Control:
|
||||
return kVK_Command;
|
||||
case Qt::Key_Shift:
|
||||
return kVK_Shift;
|
||||
case Qt::Key_CapsLock:
|
||||
return kVK_CapsLock;
|
||||
case Qt::Key_Option:
|
||||
return kVK_Option;
|
||||
case Qt::Key_Meta:
|
||||
return kVK_Control;
|
||||
case Qt::Key_F17:
|
||||
return kVK_F17;
|
||||
case Qt::Key_VolumeUp:
|
||||
return kVK_VolumeUp;
|
||||
case Qt::Key_VolumeDown:
|
||||
return kVK_VolumeDown;
|
||||
case Qt::Key_F18:
|
||||
return kVK_F18;
|
||||
case Qt::Key_F19:
|
||||
return kVK_F19;
|
||||
case Qt::Key_F20:
|
||||
return kVK_F20;
|
||||
case Qt::Key_F5:
|
||||
return kVK_F5;
|
||||
case Qt::Key_F6:
|
||||
return kVK_F6;
|
||||
case Qt::Key_F7:
|
||||
return kVK_F7;
|
||||
case Qt::Key_F3:
|
||||
return kVK_F3;
|
||||
case Qt::Key_F8:
|
||||
return kVK_F8;
|
||||
case Qt::Key_F9:
|
||||
return kVK_F9;
|
||||
case Qt::Key_F11:
|
||||
return kVK_F11;
|
||||
case Qt::Key_F13:
|
||||
return kVK_F13;
|
||||
case Qt::Key_F16:
|
||||
return kVK_F16;
|
||||
case Qt::Key_F14:
|
||||
return kVK_F14;
|
||||
case Qt::Key_F10:
|
||||
return kVK_F10;
|
||||
case Qt::Key_F12:
|
||||
return kVK_F12;
|
||||
case Qt::Key_F15:
|
||||
return kVK_F15;
|
||||
case Qt::Key_Help:
|
||||
return kVK_Help;
|
||||
case Qt::Key_Home:
|
||||
return kVK_Home;
|
||||
case Qt::Key_PageUp:
|
||||
return kVK_PageUp;
|
||||
case Qt::Key_Delete:
|
||||
return kVK_ForwardDelete;
|
||||
case Qt::Key_F4:
|
||||
return kVK_F4;
|
||||
case Qt::Key_End:
|
||||
return kVK_End;
|
||||
case Qt::Key_F2:
|
||||
return kVK_F2;
|
||||
case Qt::Key_PageDown:
|
||||
return kVK_PageDown;
|
||||
case Qt::Key_F1:
|
||||
return kVK_F1;
|
||||
case Qt::Key_Left:
|
||||
return kVK_LeftArrow;
|
||||
case Qt::Key_Right:
|
||||
return kVK_RightArrow;
|
||||
case Qt::Key_Down:
|
||||
return kVK_DownArrow;
|
||||
case Qt::Key_Up:
|
||||
return kVK_UpArrow;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
if (key == Qt::Key_Escape) ch = 27;
|
||||
else if (key == Qt::Key_Return) ch = 13;
|
||||
else if (key == Qt::Key_Enter) ch = 3;
|
||||
else if (key == Qt::Key_Tab) ch = 9;
|
||||
else ch = key;
|
||||
|
||||
CFDataRef currentLayoutData;
|
||||
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
|
||||
|
||||
if (currentKeyboard == NULL)
|
||||
return 0;
|
||||
|
||||
currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
|
||||
CFRelease(currentKeyboard);
|
||||
if (currentLayoutData == NULL)
|
||||
return 0;
|
||||
|
||||
UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData);
|
||||
UCKeyboardTypeHeader* table = header->keyboardTypeList;
|
||||
|
||||
uint8_t *data = (uint8_t*)header;
|
||||
// God, would a little documentation for this shit kill you...
|
||||
for (quint32 i=0; i < header->keyboardTypeCount; i++)
|
||||
{
|
||||
UCKeyStateRecordsIndex* stateRec = 0;
|
||||
if (table[i].keyStateRecordsIndexOffset != 0)
|
||||
{
|
||||
stateRec = reinterpret_cast<UCKeyStateRecordsIndex*>(data + table[i].keyStateRecordsIndexOffset);
|
||||
if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0;
|
||||
}
|
||||
|
||||
UCKeyToCharTableIndex* charTable = reinterpret_cast<UCKeyToCharTableIndex*>(data + table[i].keyToCharTableIndexOffset);
|
||||
if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue;
|
||||
|
||||
for (quint32 j=0; j < charTable->keyToCharTableCount; j++)
|
||||
{
|
||||
UCKeyOutput* keyToChar = reinterpret_cast<UCKeyOutput*>(data + charTable->keyToCharTableOffsets[j]);
|
||||
for (quint32 k=0; k < charTable->keyToCharTableSize; k++)
|
||||
{
|
||||
if (keyToChar[k] & kUCKeyOutputTestForIndexMask)
|
||||
{
|
||||
long idx = keyToChar[k] & kUCKeyOutputGetIndexMask;
|
||||
if (stateRec && idx < stateRec->keyStateRecordCount)
|
||||
{
|
||||
UCKeyStateRecord* rec = reinterpret_cast<UCKeyStateRecord*>(data + stateRec->keyStateRecordOffsets[idx]);
|
||||
if (rec->stateZeroCharData == ch) return k;
|
||||
}
|
||||
}
|
||||
else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE)
|
||||
{
|
||||
if (keyToChar[k] == ch) return k;
|
||||
}
|
||||
} // for k
|
||||
} // for j
|
||||
} // for i
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods)
|
||||
{
|
||||
if (!qxt_mac_handler_installed)
|
||||
{
|
||||
EventTypeSpec t;
|
||||
t.eventClass = kEventClassKeyboard;
|
||||
t.eventKind = kEventHotKeyPressed;
|
||||
InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL);
|
||||
}
|
||||
|
||||
EventHotKeyID keyID;
|
||||
keyID.signature = 'cute';
|
||||
keyID.id = ++hotKeySerial;
|
||||
|
||||
EventHotKeyRef ref = 0;
|
||||
bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref);
|
||||
if (rv)
|
||||
{
|
||||
keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id);
|
||||
keyRefs.insert(keyID.id, ref);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods)
|
||||
{
|
||||
Identifier id(nativeMods, nativeKey);
|
||||
if (!keyIDs.contains(id)) return false;
|
||||
|
||||
EventHotKeyRef ref = keyRefs.take(keyIDs[id]);
|
||||
keyIDs.remove(id);
|
||||
return !UnregisterEventHotKey(ref);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue