Import Upstream version 5.15.3+dfsg

This commit is contained in:
openKylinBot 2022-05-19 17:35:53 +08:00
commit 6b9b2c9d1e
2475 changed files with 677095 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,894 @@
QT AUTOMOTIVE SUITE LICENSE AGREEMENT
Agreement version 3.0
This Qt Automotive Suite License Agreement (“Agreement”) is a legal agreement
between The Qt Company (as defined below) and the Licensee (as defined below)
for the license of Licensed Software (as defined below). Capitalized terms used
herein are defined in Section 1.
WHEREAS:
(A) Licensee wishes to use the Licensed Software for the purpose of developing
and distributing Applications and/or Devices; and
(B) The Qt Company is willing to grant the Licensee a right to use Licensed
Software for such purpose pursuant to term and conditions of this Agreement.
NOW, THEREFORE, THE PARTIES HEREBY AGREE AS FOLLOWS:
1. DEFINITIONS
"Affiliate" of a Party shall mean an entity (i) which is directly or indirectly
controlling such Party; (ii) which is under the same direct or indirect
ownership or control as such Party; or (iii) which is directly or indirectly
owned or controlled by such Party. For these purposes, an entity shall be
treated as being controlled by another if that other entity has fifty percent
(50 %) or more of the votes in such entity, is able to direct its affairs and/or
to control the composition of its board of directors or equivalent body.
"Applications" shall mean Licensee's software products created using the
Licensed Software in connection with the Program, which may include the
Redistributables, or part thereof.
"Contractor(s)" shall mean third party consultants, distributors and contractors
performing services to a Party under applicable contractual arrangement.
"Customer(s)" shall mean Licensee's end users to whom Licensee, directly or
indirectly, distributes copies of the Redistributables.
"Deployment Platforms" shall mean operating systems specified in the License
Certificate, in which the Redistributables can be distributed pursuant to the
terms and conditions of this Agreement.
"Designated User(s)" shall mean the employee(s) of Licensee or Licensee's
Affiliates acting within the scope of their employment or Licensee's
Contractors acting within the scope of their services for Licensee and on behalf
of Licensee. Designated Users shall be named in the License Certificate.
"Development License" shall mean the license needed by the Licensee for each
Designated User to use the Licensed Software under the license grant described
in Section 3.1 of this Agreement.
"Development Platforms" shall mean those operating systems specified in the
License Certificate, in which the Licensed Software can be used under the
Development License, but not distributed in any form or used for any other
purpose.
"Devices" shall mean hardware devices or products that 1) are manufactured
and/or distributed by the Licensee or its Affiliates or Contractors in
connection with the Program, and (2)(i) incorporate or integrate the
Redistributables or parts thereof; or (ii) do not incorporate or integrate
the Redistributables at the time of distribution, but where, when used by a
Customer, the main user interface or substantial functionality of such
device is provided by Application(s) or otherwise depends on the Licensed
Software.
"Distribution License(s)" shall mean the license required for distribution of
Redistributables in accordance with the license grant described in Section
3.2(ii)-(iii) of this Agreement.
"Distribution License Packs" shall mean set of prepaid Distribution Licenses
for distribution of Redistributables, as defined in The Qt Company's standard
price list, quote, Purchase Order confirmation or in an appendix hereto, as the
case may be.
"Initial Support Term" shall mean a time period of twelve (12) months,
calculated from the effective date of this Agreement.
"Intellectual Property Rights" shall mean patents (including utility models),
design patents, and designs (whether or not capable of registration), chip
topography rights and other like protection, copyrights, trademarks, service
marks, trade names, logos or other words or symbols and any other form of
statutory protection of any kind and applications for any of the foregoing
as well as any trade secrets.
"Licensee" shall mean the individual or legal entity that is party to this
Agreement, as identified on the signature page hereof.
"License Certificate" shall mean a certificate accompanying the Licensed
Software and generated for each Designated User respectively. License
Certificate will specify the Designated User, the Development Platforms,
Deployment Platforms, Program and the Term of this Agreement. The terms of the
License Certificate are considered part of this Agreement and shall be updated
from time to time to reflect any changes to the foregoing terms relating to
Licensee's rights to the Licensed Software.
"Licensee's Records" shall mean books and records that are likely to contain
information bearing on Licensee's compliance with this Agreement or the payments
due to The Qt Company under this Agreement, including, but not limited to:
assembly logs, sales records and distribution records.
"Licensee´s SDK Contractors" shall mean Contractors of Licensee, who have
purchased or received SDK from the Licensee relating to the Program.
"License Fee" shall mean the fee charged to the Licensee for rights granted
under the terms of this Agreement.
"Licensed Software" shall mean all versions of The Qt Company's computer
software products, online or electronic documentation, associated media and
printed materials, including the source code, example programs and the
documentation, licensed to the Licensee under this Agreement. Licensed Software
does not include Third Party Software (as defined in Section 4) or Open Source
Qt.
"Modified Software" shall mean bug-fixes, error corrections, patches or
modifications made to the Licensed Software by Licensee, including documentation
related thereto.
"Online Services" shall mean any services or access to systems made available
by The Qt Company to the Licensee over the Internet relating to the Licensed
Software or for the purpose of use by the Licensee of the Licensed Software or
Support. Use of any such Online Services is discretionary for the Licensee and
some of them may be subject to additional fees.
"Open Source Qt" shall mean all versions of The Qt Company's Qt computer
software products, online or electronic documentation, associated media and
printed materials, including the source code, example programs and the
documentation available under the terms of the GNU Lesser General Public
License, version 2.1 or later ("LGPL") or the GNU General Public License,
version 2.0 or later ("GPL").
"Party" or "Parties" shall mean Licensee and/or The Qt Company.
"Program" shall mean Licensee´s business program for which purpose the Licensee
is entitled to use the Licensed Software and grant the Licensee's SDK
Contractors a right to use the Licensed Software as part of a SDK.
"Redistributables" shall mean the portions of the Licensed Software set forth
in Appendix 1, Section 1 that may be distributed pursuant to the terms of this
Agreement in object code form only, including any relevant documentation. Where
relevant, any reference to Licensed Software in this Agreement shall include and
refer also to Redistributables.
"SDK" or "Software Development Kit" shall mean a combination of software modules
including Licensed Software intended to be utilized in connection with the
Program.
"Submitted Modified Software" shall have the meaning as set forth in Section
2.3.
"Support" shall mean standard developer support that is provided by
The Qt Company to assist Designated Users in using the Licensed Software in
accordance with The Qt Company's standard support terms.
"Support Renewal Term" shall mean a time period of twelve (12) months,
calculated from the end of the Initial Support Term or previous Support Renewal
Term, as applicable.
"Support Term" shall mean the Initial Support Term and any possible Support
Renewal Terms(s) during which time the Licensee is eligible to receive for
Support for the Licensed Software.
"Taxes" shall have the meaning set forth in Section 10.5.
"Term" shall mean the validity period of this Agreement, as set forth in the
License Certificate.
“The Qt Company” shall mean:
(i) in the event Licensee is an individual residing in the United States or a
legal entity incorporated in the United States or having its headquarters in the
United States, The Qt Company Inc., a Delaware corporation with its office at
2350 Mission College Blvd., Suite 1020, Santa Clara, CA 95054, USA.; or
(ii) in the event the Licensee is an individual residing outside of the United
States or a legal entity incorporated outside of the United States or having its
registered office outside of the United States, The Qt Company Ltd., a Finnish
company with its registered office at Bertel Jungin aukio D3A, 02600 Espoo,
Finland.
"Updates" shall mean a release or version of the Licensed Software containing
bug fixes, error corrections and other changes that are generally made available
to users of the Licensed Software that have contracted for Support. Updates are
generally depicted as a change to the digits following the decimal in the
Licensed Software version number. The Qt Company shall make Updates available to
the Licensee under the Support. Updates shall be considered as part of the
Licensed Software hereunder.
"Upgrades" shall mean a release or version of the Licensed Software containing
enhancements and new features and are generally depicted as a change to the
first digit of the Licensed Software version number. In the event Upgrades are
provided to the Licensee under this Agreement, they shall be considered as part
of the Licensed Software hereunder.
2. OWNERSHIP 2.1
Ownership of The Qt Company
The Licensed Software is protected by copyright laws and international copyright
treaties, as well as other intellectual property laws and treaties. The Licensed
Software is licensed, not sold.
All The Qt Company's Intellectual Property Rights are and shall remain the
exclusive property of The Qt Company or its licensors respectively.
2.2 Ownership of Licensee
All the Licensee's Intellectual Property Rights are and shall remain the
exclusive property of the Licensee or its licensors respectively.
All Intellectual Property Rights to the Modified Software, Applications and
Devices shall remain with the Licensee and no rights thereto shall be granted by
the Licensee to The Qt Company under this Agreement (except as set forth in
Section 2.3 below).
2.3 Modified Software
Licensee may create Modified Software that breaks the source or binary
compatibility with the Licensed Software. This includes, but is not limited to,
changing the application programming interfaces ("API") by adding, changing or
deleting any variable, method, or class signature in the Licensed Software
and/or any inter-process protocols, services or standards in the Licensed
Software libraries. To the extent that Licensee breaks source or binary
compatibility with the Licensed Software, Licensee acknowledges that The Qt
Company's ability to provide Support may be prevented or limited and Licensee's
ability to make use of Updates may be restricted.
To the extent Licensee submits Modified Software to The Qt Company ("Submitted
Modified Software"), Licensee hereby grants The Qt Company a sublicensable,
assignable, irrevocable, perpetual, worldwide, non-exclusive, royalty-free and
fully paid-up license, under all of Licensee's Intellectual Property Rights, to
reproduce, adapt, translate, modify, and prepare derivative works of, publicly
display, publicly perform, sublicense, make available and distribute such
Submitted Modified Software as The Qt Company sees fit at its free and absolute
discretion. For the sake of clarity, the Licensee shall have no obligation to
provide Modified Software to The Qt Company.
3. LICENSES GRANTED
3.1 Development with Licensed Software
Subject to the terms of this Agreement, The Qt Company grants to Licensee a
personal, worldwide, non- exclusive, non-transferable license, valid for the
Term, to use, modify and copy the Licensed Software by Designated Users on the
Development Platforms for the sole purposes of designing, developing,
demonstrating and testing Application(s) and/or Devices, and to provide thereto
related support and other services to end-user Customers.
Licensee may install copies of the Licensed Software on an unlimited number of
computers provided that (i) only the Designated Users may use the Licensed
Software, and (ii) all Designated Users must have a valid Development License to
use Licensed Software.
Licensee may at any time designate another Designated User to replace a
then-current Designated User by notifying The Qt Company in writing, provided
that any Designated User may be replaced only once during any six-month period.
3.2 Distribution of Redistributables
Subject to the terms of this Agreement, The Qt Company grants to Licensee a
personal, worldwide, non- exclusive, non-transferable license, valid for the
Term, to (i) distribute, by itself or through its Contractors, Redistributables
as installed, incorporated or integrated into Applications for execution on the
Deployment Platforms, and (ii) distribute, by itself or through one or more
tiers of Contractors, Redistributables as installed, incorporated or integrated,
or intended to be installed, incorporated or integrated into Devices for
execution on the Deployment Platforms, and (iii) grant sublicenses to
Redistributables, as distributed hereunder, for Customers solely for Customer's
internal use and to the extent necessary in order for the Customers to use the
Applications and/or Devices for their respective intended purposes.
Right to distribute the Redistributables as provided herein is conditional upon
the Licensee having purchased and paid the appropriate amount of Development and
Distribution Licenses from The Qt Company before distributing any
Redistributables to Customers.
For the avoidance of any doubt it is specifically acknowledged and agreed that
distribution of Redistributables solely as installed, incorporated or integrated
into Applications for execution on the Deployment Platform(s), as specified in
(i) of the first paragraph of Section 3.2 above, i.e. with no connection to
Devices or intention to use in connection therewith, shall not require a
Distribution License.
3.3 SDK License
The Qt Company grants to Licensee a personal, worldwide, non-exclusive,
non-transferable license, valid for the Term, to (i) distribute Licensed
Software as a part of the SDK to Licensee´s SDK Contractors in connection with
the Program and (ii) in connection with the Program, by itself or by Licensee's
SDK Contractors, combine, incorporate or integrate Licensed Software with, or
use Licensed Software for creation of, any software created with or
incorporating Open Source Qt, provided, however, that:
(i) the Licensee´s SDK Contractors are only entitled to use the Licensed
Software as part of SDK and for the sole purpose of developing software for
Devices that are distributed under the Program; and
(ii) Licensee´s SDK Contractors shall not be entitled to distribute the SDK or
any part thereof to any third parties.
For the avoidance of any doubt, the distribution of such software development
tools that do not contain Licensed Software shall not be covered by this
Agreement.
3.4 Further Requirements
The licenses granted above in this Section 3 by The Qt Company to Licensee are
conditional and subject to Licensee's compliance with the following terms:
(i) Licensee shall not remove or alter any copyright, trademark or other
proprietary rights notice contained in any portion of the Licensed Software;
(ii) Applications and SDKs must add primary and substantial functionality to the
Licensed Software;
(iii) Applications may not pass on functionality which in any way makes it
possible for others to create software with the Licensed Software; provided
however that Licensee may use the Licensed Software's scripting and QML ("Qt
Quick") functionality solely in order to enable scripting, themes and styles
that augment the functionality and appearance of the Application(s) without
adding primary and substantial functionality to the Application(s);
(iv) Applications and SDKs must not compete with the Licensed Software;
(v) Licensee shall not use The Qt Company's or any of its suppliers' names,
logos, or trademarks to market Applications or SDKs, except that Licensee may
use "Built with Qt" logo to indicate that Application(s) was developed using
the Licensed Software;
(vi) Except as expressly provided in Section 3.3, Licensee shall not
distribute, sublicense or disclose source code of Licensed Software to any third
party (provided however that Licensee may appoint employee(s) of Contractors as
Designated Users to use Licensed Software pursuant to this Agreement);
(vii) Licensee shall not grant the Customers a right to (i) make copies of the
Redistributables except when and to the extent required to use the Applications
and/or Devices for their intended purpose, (ii) modify the Redistributables or
create derivative works thereof, (iii) decompile, disassemble or otherwise
reverse engineer Redistributables, or (iv) redistribute any copy or portion of
the Redistributables to any third party, except as part of the onward sale of
the Device on which the Redistributables are installed;
(viii) Except as expressly provided in Section 3.3, Licensee shall not and
shall cause that its Affiliates, Contractors and Licensee's SDK Contractors
shall not a) in any way, combine, incorporate or integrate Licensed Software
with, or use Licensed Software for creation of, any software created with or
incorporating Open Source Qt or b) incorporate or integrate Applications into a
hardware device or product other than a Device, unless Licensee has received an
advance written permission from The Qt Company to do so. Unless specifically
otherwise agreed, any and all distribution by the Licensee during the Term of
a hardware device or product a) which incorporate or integrate any part of
Licensed Software or Open Source Qt; or b) where the main user interface or
substantial functionality is provided by software build with Licensed
Software or Open Source Qt or otherwise depends on the Licensed Software or Open
Open Source Qt, shall be considered as distribution under this Agreement and
dependent on compliance thereof (including but not limited to obligation to
pay applicable License Fees for such distribution);
(ix) Licensee shall cause all of its Affiliates and Contractors entitled to make
use of the licenses granted under this Agreement, to be contractually bound to
comply with the relevant terms of this Agreement and not to use the Licensed
Software beyond the terms hereof and for any purposes other than operating
within the scope of their services for Licensee. Licensee shall be responsible
for any and all actions and omissions of its Affiliates and Contractors relating
to the Licensed Software and use thereof (including but not limited to payment
of all applicable License Fees);
(x) Except when and to the extent explicitly provided in this Section 3,
Licensee shall not transfer, publish, disclose, display or otherwise make
available the Licensed Software;
(xi) Licensee shall not take any action inconsistent with The Qt Company's
Intellectual Property Rights; and
(xii) Attempt or enlist a third party to conduct or attempt to conduct any of
the above.
Above terms shall not be applicable if and to the extent they conflict with any
mandatory provisions of any applicable laws.
Any use of Licensed Software beyond the provisions of this Agreement is strictly
prohibited and requires an additional license from The Qt Company.
4. THIRD PARTY SOFTWARE
The Licensed Software may provide links to third party libraries or code
(collectively "Third Party Software") to implement various functions. Third
Party Software does not comprise part of the Licensed Software. In some cases,
access to Third Party Software may be included in the Licensed Software. Such
Third Party Software will be listed in the ".../src/3rdparty" source tree
delivered with the Licensed Software or documented in the Licensed Software, as
such may be amended from time to time. Licensee acknowledges that use or
distribution of Third Party Software is in all respects subject to applicable
license terms of applicable third party right holders. 5. PRE-RELEASE CODE
The Licensed Software may contain pre-release code and functionality marked or
otherwise stated as "Technology Preview", "Alpha", "Beta" or similar
designation. Such pre-release code may be present in order to provide
experimental support for new platforms or preliminary versions of one or more
new functionalities. The pre-release code may not be at the level of performance
and compatibility of a final, generally available, product offering of the
Licensed Software. The pre-release parts of the Licensed Software may not
operate correctly, may contain errors and may be substantially modified by The
Qt Company prior to the first commercial product release, if any. The Qt Company
is under no obligation to make pre-release code commercially available, or
provide any Support or Updates relating thereto. The Qt Company assumes no
liability whatsoever regarding any pre-release code, but any use thereof is
exclusively at Licensee's own risk and expense.
6. LIMITED WARRANTY AND WARRANTY DISCLAIMER
The Qt Company hereby represents and warrants that it has the power and
authority to grant the rights and licenses granted to Licensee under this
Agreement.
Except as set forth above, the Licensed Software is licensed to Licensee "as
is".
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE QT COMPANY ON BEHALF OF
ITSELF AND ITS LICENSORS, SUPPLIERS AND AFFILIATES, DISCLAIMS ALL WARRANTIES,
EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT
WITH REGARD TO THE LICENSED SOFTWARE. THE QT COMPANY DOES NOT WARRANT THAT THE
LICENSED SOFTWARE WILL SATISFY LICENSEE'S REQUIREMENTS OR THAT IT WILL OPERATE
WITHOUT DEFECT OR ERROR OR THAT THE OPERATION THEREOF WILL BE UNINTERRUPTED. ALL
USE OF AND RELIANCE ON THE LICENSED SOFTWARE IS AT THE SOLE RISK OF AND
RESPONSIBILITY OF LICENSEE.
Licensee's exclusive remedy and The Qt Company's entire liability for Licensed
Software shall be limited, at The Qt Company's option, to correction of the
error, replacement of the Licensed Software or return of the applicable fees
paid for the defective Licensed Software for the time period during which the
License is not able to utilize the Licensed Software under the terms of this
Agreement.
7. INDEMNIFICATION AND LIMITATION OF LIABILITY
7.1 Limitation of Liability
EXCEPT FOR (I) CASES OF GROSS NEGLIGENCE OR INTENTIONAL MISCONDUCT, (II)
LICENSEE'S DUTY TO PAY ALL APPLICABLE LICENSE FEES AND COMPENSATIONS, AND (III)
BREACH OF CONFIDENTIALITY, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, IN NO
EVENT SHALL EITHER PARTY BE LIABLE TO THE OTHER PARTY FOR ANY LOSS OF PROFIT,
LOSS OF DATA, LOSS OF BUSINESS OR GOODWILL OR ANY OTHER INDIRECT, SPECIAL,
CONSEQUENTIAL, INCIDENTAL OR PUNITIVE COST, DAMAGES OR EXPENSE OF ANY KIND,
HOWSOEVER ARISING UNDER OR IN CONNECTION WITH THIS AGREEMENT.
EXCEPT FOR (I) CASES OF GROSS NEGLIGENCE OR INTENTIONAL MISCONDUCT, (II)
LICENSEE'S DUTY TO PAY ALL APPLICABLE LICENSE FEES AND COMPENSATIONS, AND (III)
BREACH OF CONFIDENTIALITY, AND TO THE EXTENT PERMITTED BY APPLICABLE LAW, IN NO
EVENT SHALL EITHER PARTY'S TOTAL AGGREGATE LIABILITY UNDER THIS AGREEMENT EXCEED
THE AGGREGATE LICENSE FEES RECEIVED BY THE QT COMPANY FROM LICENSEE DURING THE
PERIOD OF TWELVE (12) MONTHS IMMEDIATELY PRECEDING THE EVENT RESULTING IN SUCH
LIABILITY.
THE PROVISIONS OF THIS SECTION 7 ALLOCATE THE RISKS UNDER THIS AGREEMENT BETWEEN
THE QT COMPANY AND LICENSEE AND THE PARTIES HAVE RELIED UPON THE LIMITATIONS SET
FORTH HEREIN IN DETERMINING WHETHER TO ENTER INTO THIS AGREEMENT.
7.2 Licensee´s Indemnification
Licensee shall indemnify and hold harmless The Qt Company from and against any
claim, injury, judgment, settlement, loss or expense, including attorneys' fees
related to: (a) Licensee's misrepresentation in connection with The Qt Company
or the Licensed Software or breach of this Agreement, (b) the Application or
Device (except where such cause of liability is solely attributable to the
Licensed Software).
8. SUPPORT, UPDATES AND ONLINE SERVICES
Licensee will be eligible to receive Support and Updates and to use the Online
Services during the Support Term. Unless otherwise decided by The Company at its
free and absolute discretion, Upgrades will not be included in the Support but
may be available subject to additional fees.
Licenses granted under this Agreement shall include a prepaid Initial Support
Term.
Initial Support Term shall be automatically extended to one or more Support
Renewal Term(s), unless and until either Party notifies the other Party in
writing that it does not wish to continue the Support, such notification to be
provided to the other Party no less than ninety (90) days before expiry of the
Initial Support Term or respective Support Renewal Term. During any such Support
Renewal Term Support shall be available subject to prices and terms agreed
between the Parties or, if no advance agreement exists, subject to The Qt
Company's standard pricing applicable at the commencement date of any such
Support Renewal Term. From time to time The Qt Company may change Support
provided within each Support plan; provided that during the respective Initial
Support Term or Support Renewal Term (as the case may be), the level of Support
provided by The Qt Company may not be reduced without the consent of the
Licensee.
Unless otherwise agreed, The Qt Company shall not be responsible for providing
any service or support to the Customers.
9. CONFIDENTIALITY
Each Party acknowledges that during the Term of this Agreement each Party may
receive information about the other Party's business, business methods, business
plans, customers, business relations, technology, and other information,
including the terms of this Agreement, that is confidential and of great value
to the other Party, and the value of which would be significantly reduced if
disclosed to third parties ("Confidential Information"). Accordingly, when a
Party (the "Receiving Party") receives Confidential Information from the other
Party (the "Disclosing Party"), the Receiving Party shall only disclose such
information to employees and Contractors on a need to know basis, and shall
cause its employees and employees of its Affiliates to: (i) maintain any and all
Confidential Information in confidence; (ii) not disclose the Confidential
Information to a third party without the Disclosing Party's prior written
approval; and (iii) not, directly or indirectly, use the Confidential
Information for any purpose other than for exercising its rights and fulfilling
its responsibilities pursuant to this Agreement. Each Party shall take
reasonable measures to protect the Confidential Information of the other Party,
which measures shall not be less than the measures taken by such Party to
protect its own confidential and proprietary information.
Obligation of confidentiality shall not apply to information that (i) is or
becomes generally known to the public through no act or omission of the
Receiving Party; (ii) was in the Receiving Party's lawful possession prior to
the disclosure hereunder and was not subject to limitations on disclosure or
use; (iii) is developed independently by employees or Contractors of the
Receiving Party or other persons working for the Receiving Party who have not
had access to the Confidential Information of the Disclosing Party, as proven by
the written records of the Receiving Party; (iv) is lawfully disclosed to the
Receiving Party without restrictions, by a third party not under an obligation
of confidentiality; or (v) the Receiving Party is legally compelled to disclose,
in which case the Receiving Party shall notify the Disclosing Party of such
compelled disclosure and assert the privileged and confidential nature of the
information and cooperate fully with the Disclosing Party to limit the scope of
disclosure and the dissemination of disclosed Confidential Information to the
minimum extent necessary.
The obligations under this Section 9 shall continue to remain in force for a
period of five (5) years after the last disclosure, and, with respect to trade
secrets, for so long as such trade secrets are protected under applicable trade
secret laws.
10. FEES, DELIVERY AND PAYMENT
10.1 License Fees
License Fees are described in The Qt Company's standard price list, quote or
Purchase Order confirmation or in an appendix hereto, as the case may be. The
License Fees shall not be refunded or claimed as a credit, even on the ground
that Distribution Licenses are not used, i.e. Redistributables are not actually
distributed corresponding to the Distribution Licenses purchased, or for any
other reason.
10.2 Ordering Licenses
Licensee may purchase Development Licenses and Distribution Licenses pursuant to
agreed pricing terms or, if no specific pricing terms have been agreed upon, at
The Qt Company's standard pricing terms applicable at the time of purchase.
Licensee shall submit all purchase orders for Development Licenses and
Distribution Licenses to The Qt Company by email or any other method acceptable
to The Qt Company (each such order is referred to herein as a "Purchase Order")
for confirmation, whereupon the Purchase Order shall become binding between the
Parties.
10.3 Distribution
License Packs Unless otherwise agreed, the Distribution Licenses are bought by
way of Distribution License Packs.
Upon due payment of the ordered Distribution License Pack(s), the Licensee will
have an account of Distribution Licenses available for installing, bundling or
integrating (all jointly "installing") the Redistributables with the Devices or
for otherwise distributing the Redistributables in accordance with this
Agreement.
Each time Licensee "installs" or distributes a copy of Redistributables, then
one Distribution License is used, and Licensee's account of available
Distribution Licenses is decreased accordingly.
Licensee may "install" copies of the Redistributables so long as Licensee has
Distribution Licenses remaining on its account.
Redistributables will be deemed to have been "installed" into a Device when one
of the following circumstances shall have occurred: a) the Redistributables
have been loaded onto the Device and used outside of the Licensee's premises or
b) the Device has been fully tested and placed into Licensee's inventory (or
sold) for the first time (i.e., Licensee will not be required to use (or pay
for) more than one Distribution License for each individual Device, e.g. in a
situation where a Device is returned to Licensee's inventory after delivery to
a distributor or sale to a Customer). In addition, if Licensee includes a
back-up copy of the Redistributables on a CD-ROM or other storage medium
along with the product, that backup copy of the Redistributables will not
be deemed to have been "installed" and will not require an additional
Distribution License.
10.4 Payment Terms
License Fees and any other charges under this Agreement shall be paid by
Licensee no later than thirty (30) days from the date of the applicable invoice
from The Qt Company.
The Qt Company will submit an invoice to Licensee after the date of this
Agreement and/or after The Qt Company receives a Purchase Order from Licensee.
A late payment charge of the lower of (a) one percent per month; or (b) the
interest rate stipulated by applicable law, shall be charged on any unpaid
balances that remain past due.
The Qt Company shall have the right to suspend, terminate or withhold grants of
all rights to the Licensed Software hereunder, including but not limited to the
Developer License, Distribution License, and Support, should Licensee fail to
make payment in a timely fashion.
10.5 Taxes
All License Fees and other charges payable hereunder are gross amounts but
exclusive of any value added tax, use tax, sales tax and other taxes, duties or
tariffs ("Taxes"). Such applicable Taxes shall be paid by Licensee, or, where
applicable, in lieu of payment of such Taxes, Licensee shall provide an
exemption certificate to The Qt Company and any applicable authority.
11 RECORD-KEEPING AND REPORTING OBLIGATIONS; AUDIT RIGHTS
11.1 Licensee's Record-keeping
Licensee shall at all times maintain accurate and up-to-date written records of
Licensee's activities related to the use of Licensed Software and distribution
of Redistributables. The records shall be adequate to determine Licensee's
compliance with the provisions of this Agreement and to demonstrate the number
of Designated Users and Redistributables distributed by Licensee. The records
shall conform to good accounting practices reasonably acceptable to The Qt
Company.
Licensee shall, within thirty (30) days from the end of each calendar
quarter, deliver to The Qt Company a report detailing the number of Designated
Users and copies of Redistributables distributed by Licensee during that
calendar quarter, and also detailing the number of undistributed copies of
Redistributables made by Licensee and remaining in its account (i.e.,
undistributed copies for which Distribution Licenses have been or need to be
obtained from The Qt Company). Such report shall contain such other information
as The Qt Company shall reasonably require from time to time.
11.2. The Qt Company's Audit Rights
The Qt Company or an independent auditor acting on behalf of The Qt Company's,
may, upon at least five (5) business days' prior written notice and at its
expense, audit Licensee with respect to the use of the Redistributables, but
not more frequently than once during each 6-month period. Such audit may be
conducted by mail, electronic means or through an in-person visit to
Licensee's place of business. Any such in-person audit shall be conducted
during regular business hours at Licensee's facilities and shall not
unreasonably interfere with Licensee's business activities. The Qt Company or
the independent auditor acting on behalf of The Qt Company shall be entitled to
inspect Licensee's Records. All such Licensee's Records and use thereof shall be
subject to an obligation of confidentiality under this Agreement.
If an audit reveals that Licensee is using the Licensed Software beyond scope of
the licenses Licensee has paid for, Licensee agrees to immediately pay The Qt
Company any amounts owed for such unauthorized use.
In addition, in the event the audit reveals a material violation of the terms of
this Agreement (underpayment of more than 5% of License Fees shall always be
deemed a material violation for purposes of this section), then the Licensee
shall pay The Qt Company's reasonable cost of conducting such audit.
12 TERM AND TERMINATION
12.1 Term
This Agreement shall enter into force upon due acceptance by both Parties and
remain in force for the Term, unless and until terminated pursuant to the terms
of this Section 12.
12.2 Termination by The Qt Company
The Qt Company shall have the right to terminate this Agreement upon thirty
(30) days prior written notice if (i) the Licensee is in material breach of any
obligation of this Agreement and fails to remedy such breach within such notice
period; (ii) or Licensee or any of its Affiliates bring a suit before any court
or administrative agency or otherwise assert a claim against The Qt Company's
or any of its Affiliates' Intellectual Property Rights or validity thereof.
12.3 Mutual Right to Terminate
Either Party shall have the right to terminate this Agreement immediately upon
written notice in the event that the other Party becomes insolvent, files for
any form of bankruptcy, makes any assignment for the benefit of creditors, has a
receiver, administrative receiver or officer appointed over the whole or a
substantial part of its assets, ceases to conduct business, or an act equivalent
to any of the above occurs under the laws of the jurisdiction of the other
Party.
12.4 Parties´ Rights and Duties upon Termination
Upon expiry or termination of the Agreement for any reason, Licensee shall,
within 30 days after such termination, cease and shall cause all Designated
Users (including those of its Affiliates' and Contractors') and Licensee's SDK
Contractors to cease using the Licensed Software and distribution of the
Redistributables under this Agreement. Notwithstanding the above, in the event
the Agreement expires or is terminated for reason other than by The Qt Company
pursuant to Section 12.2, the Licensee is entitled, for a period of six (6)
months after the effective date of termination, to continue distribution of
Devices under the Distribution Licenses paid but unused at such effective date
of termination.
Upon any such termination the Licensee shall destroy or return to The Qt
Company all copies of the Licensed Software and all related materials and will
certify the same to The Qt Company upon its request, provided however that
Licensee may retain and exploit such copies of the Licensed Software as it may
reasonably require in providing continued support to Customers.
Expiry or termination of this Agreement for any reason whatsoever shall not
relieve Licensee of its obligation to pay any License Fees accrued or payable
to The Qt Company prior to the effective date of termination, and Licensee shall
immediately pay to The Qt Company all such fees upon the effective date of
termination. Termination of this Agreement shall not affect any rights of
Customers to continue use of Applications and Devices (and therein incorporated
Redistributables).
13.GOVERNING LAW AND LEGAL VENUE
In the event this Agreement is in the name of The Qt Company Inc., a Delaware
Corporation, then:
(i) this Agreement shall be construed and interpreted in accordance with the
laws of the State of California, USA, excluding its choice of law provisions;
(ii) the United Nations Convention on Contracts for the International Sale of
Goods will not apply to this Agreement; and
(iii) any dispute, claim or controversy arising out of or relating to this
Agreement or the breach, termination, enforcement, interpretation or validity
thereof, including the determination of the scope or applicability of this
Agreement to arbitrate, shall be determined by arbitration in San Francisco,
USA, before one arbitrator. The arbitration shall be administered by JAMS
pursuant to JAMS' Streamlined Arbitration Rules and Procedures. Judgment on the
Award may be entered in any court having jurisdiction. This Section shall not
preclude parties from seeking provisional remedies in aid of arbitration from a
court of appropriate jurisdiction.
In the event this Agreement is in the name of The Qt Company Ltd., a Finnish
Company, then:
(i) this Agreement shall be construed and interpreted in accordance with the
laws of Finland, excluding its choice of law provisions;
(ii) the United Nations Convention on Contracts for the International Sale of
Goods will not apply to this Agreement; and
(iii) any disputes, controversy or claim arising out of or relating to this
Agreement, or the breach, termination or validity thereof shall be shall be
finally settled by arbitration in accordance with the Arbitration Rules of
Finland Chamber of Commerce. The arbitration tribunal shall consist of one (1),
or if either Party so requires, of three (3), arbitrators. The award shall be
final and binding and enforceable in any court of competent jurisdiction. The
arbitration shall be held in Helsinki, Finland and the process shall be
conducted in the English language. This Section shall not preclude parties from
seeking provisional remedies in aid of arbitration from a court of appropriate
jurisdiction.
14. GENERAL PROVISIONS
14.1 No Assignment Licensee
shall not be entitled to assign or transfer all or any of its rights, benefits
and obligations under this Agreement without the prior written consent of The Qt
Company, which shall not be unreasonably withheld or delayed. The Qt Company
shall be entitled to freely assign or transfer any of its rights, benefits or
obligations under this Agreement.
14.2 No Third Party Representations
Licensee shall make no representations or warranties concerning the Licensed
Software on behalf of The Qt Company. Any representation or warranty Licensee
makes or purports to make on The Qt Company's behalf shall be void as to The Qt
Company.
14.3 Surviving Sections
Any terms and conditions that by their nature or otherwise reasonably should
survive termination of this Agreement shall so be deemed to survive.
14.4 Entire Agreement
This Agreement, the exhibits hereto, the License Certificate and any applicable
Purchase Order constitute the complete agreement between the Parties and
supersedes all prior or contemporaneous discussions, representations, and
proposals, written or oral, with respect to the subject matters discussed
herein. In the event of any conflict or inconsistency between this Agreement and
any Purchase Order, the terms of this Agreement will prevail over the terms of
the Purchase Order with respect to such conflict or inconsistency.
14.5 Modifications
No modification of this Agreement shall be effective unless contained in a
writing executed by an authorized representative of each Party. No term or
condition contained in Licensee's Purchase Order shall apply unless expressly
accepted by The Qt Company in writing.
14.6 Force Majeure
Except for the payment obligations hereunder, neither Party shall be liable to
the other for any delay or non-performance of its obligations hereunder in the
event and to the extent that such delay or non- performance is due to an event
of act of God, terrorist attack or other similar unforeseeable catastrophic
event that prevents either Party for fulfilling its obligations under this
Agreement and which such Party cannot avoid or circumvent ("Force Majeure
Event"). If the Force Majeure Event results in a delay or non- performance of a
Party for a period of three (3) months or longer, then either Party shall have
the right to terminate this Agreement with immediate effect without any
liability (except for the obligations of payment arising prior to the event of
Force Majeure) towards the other Party.
14.7 Notices
Any notice given by one Party to the other shall be deemed properly given and
deemed received if specifically acknowledged by the receiving Party in writing
or when successfully delivered to the recipient by hand, fax, or special courier
during normal business hours on a business day to the addresses specified for
The Qt Company in the beginning of this Agreement, and for the Licensee in the
Licensees account profile. Each communication and document made or delivered by
one Party to the other Party pursuant to this Agreement shall be in the English
language.
14.8 Export Control
Licensee acknowledges that the Redistributables may be subject to export
control restrictions under the applicable laws of respective countries.
Licensee shall fully comply with all applicable export license restrictions
and requirements as well as with all lawses hereunder and shall procure all
necessary governmental authorizations, including without limitation, all
necessary licenses, approvals, permissions or consents, where necessary for
the re- exportation of the Redistributables, Applications
and/or Devices.
14.9 No Implied License
There are no implied licenses or other implied rights granted under this
Agreement, and all rights, save for those expressly granted hereunder, shall
remain with The Qt Company and its licensors. In addition, no licenses or
immunities are granted to the combination of the Licensed Software with any
other software or hardware not delivered by The Qt Company under this Agreement.
14.10 Attorney Fees
The prevailing Party in any action to enforce this Agreement shall be entitled
to recover its attorney's fees and costs in connection with such action.
14.11 Severability
If any provision of this Agreement shall be adjudged by any court of competent
jurisdiction to be unenforceable or invalid, that provision shall be limited or
eliminated to the minimum extent necessary so that this Agreement shall
otherwise remain in full force and effect and enforceable.
IN WITNESS WHEREOF, the Parties hereto, intending to be legally bound hereby,
have caused this Agreement to be executed by Licensees authorized
representative installing the Licensed Software and accepting the terms hereof
in connection therewith.
Appendix 1
1. Parts of the Licensed Software that are permitted for distribution in object
code form only ("Redistributables") under this Agreement:
- The Licensed Software's essential and add-on libraries
- The Licensed Software's configuration tool ("qtconfig")
- The Licensed Software's help tool ("Qt Assistant")
- The Licensed Software's internationalization tools ("Qt Linguist", "lupdate",
"lrelease")
- The Licensed Software's QML ("Qt Quick") launcher tool ("qmlscene" and
"qmlviewer")
- The Licensed Software's installer framework
2. Parts of the Licensed Software that are not permitted for distribution
include, but are not limited to:
- The Licensed Software's source code and header files
- The Licensed Software's documentation
- The Licensed Software's documentation generation tool ("qdoc")
- The Licensed Software's tool for writing makefiles ("qmake")
- The Licensed Software's Meta Object Compiler ("moc")
- The Licensed Software's User Interface Compiler ("uic" or in the case of Qt Jambi: "juic")
- The Licensed Software's Resource Compiler ("rcc")
- The Licensed Software's generator (only in the case of Qt Jambi if applicable)
- The Licensed Software's parts of the IDE tool ("Qt Creator")
- The Licensed Software's Emulator
- Build scripts, recipes and other material for creating the
configuration of Licensed Software and/or 3rd party components, including the
reference operating system configuration delivered in conjunction with the

File diff suppressed because it is too large Load Diff

6
.qmake.conf Normal file
View File

@ -0,0 +1,6 @@
load(qt_build_config)
android|boot2qt: CONFIG -= headersclean
DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS QT_NO_LINKED_LIST
MODULE_VERSION = 5.15.3

1
.tag Normal file
View File

@ -0,0 +1 @@
5be95f966aabc5170f0aacfd4b0a46217241bfd6

450
LICENSE.FDL Normal file
View File

@ -0,0 +1,450 @@
GNU Free Documentation License
Version 1.3, 3 November 2008
Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
<http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
1. APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The "Document", below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as "you". You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The "Invariant Sections" are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The "Cover Texts" are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML, PostScript or PDF designed for human modification. Examples of
transparent image formats include PNG, XCF and JPG. Opaque formats
include proprietary formats that can be read and edited only by
proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, "Title Page" means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
The "publisher" means any person or entity that distributes copies of
the Document to the public.
A section "Entitled XYZ" means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as "Acknowledgements",
"Dedications", "Endorsements", or "History".) To "Preserve the Title"
of such a section when you modify the Document means that it remains a
section "Entitled XYZ" according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no
other conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to
give them a chance to provide you with an updated version of the
Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
C. State on the Title page the name of the publisher of the
Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled "History", Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled "History" in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the "History" section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
K. For any section Entitled "Acknowledgements" or "Dedications",
Preserve the Title of the section, and preserve in the section all
the substance and tone of each of the contributor acknowledgements
and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
M. Delete any section Entitled "Endorsements". Such a section
may not be included in the Modified Version.
N. Do not retitle any existing section to be Entitled "Endorsements"
or to conflict in title with any Invariant Section.
O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled "History"
in the various original documents, forming one section Entitled
"History"; likewise combine any sections Entitled "Acknowledgements",
and any sections Entitled "Dedications". You must delete all sections
Entitled "Endorsements".
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other
documents released under this License, and replace the individual
copies of this License in the various documents with a single copy
that is included in the collection, provided that you follow the rules
of this License for verbatim copying of each of the documents in all
other respects.
You may extract a single document from such a collection, and
distribute it individually under this License, provided you insert a
copy of this License into the extracted document, and follow this
License in all other respects regarding verbatim copying of that
document.
7. AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an "aggregate" if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
8. TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, or distribute it is void, and
will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
10. FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions of the
GNU Free Documentation 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. See
http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation. If the Document
specifies that a proxy can decide which future versions of this
License can be used, that proxy's public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.
11. RELICENSING
"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server. A
"Massive Multiauthor Collaboration" (or "MMC") contained in the site
means any set of copyrightable works thus published on the MMC site.
"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
"Incorporate" means to publish or republish a Document, in whole or in
part, as part of another Document.
An MMC is "eligible for relicensing" if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole or
in part into the MMC, (1) had no cover texts or invariant sections, and
(2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
Copyright (c) YEAR YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the "with...Texts." line with this:
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.

339
LICENSE.GPL2 Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 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.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
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 Program or any portion
of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
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 Program, 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 Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) 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; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, 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 executable. However, as a
special exception, the source code 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.
If distribution of executable or 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 counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program 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.
5. 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 Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program 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 to
this License.
7. 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 Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program 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 Program.
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.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program 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.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies 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 Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, 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
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. 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 PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
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 program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, 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.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

674
LICENSE.GPL3 Normal file
View File

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

704
LICENSE.GPL3-EXCEPT Normal file
View File

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

165
LICENSE.LGPL3 Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
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 that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU 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 as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

5
configure.json Normal file
View File

@ -0,0 +1,5 @@
{
"subconfigs": [
"src/script"
]
}

48
dist/changes-5.0.1 vendored Normal file
View File

@ -0,0 +1,48 @@
Qt 5.0.1 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.0.0.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://qt-project.org/doc/qt-5.0/
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
http://bugreports.qt-project.org/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* General *
****************************************************************************
General Improvements
--------------------
-modularized Qt Script Tools documentation; did not exist previously
Third party components
----------------------
****************************************************************************
* Library *
****************************************************************************
- no changes for this version
****************************************************************************
* Platform Specific Changes *
****************************************************************************
****************************************************************************
* Compiler Specific Changes *
****************************************************************************
****************************************************************************
* Plugins *
****************************************************************************

25
dist/changes-5.0.2 vendored Normal file
View File

@ -0,0 +1,25 @@
Qt 5.0.2 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.0.0 and 5.0.1.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://qt-project.org/doc/qt-5.0/
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
http://bugreports.qt-project.org/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* General *
****************************************************************************
General Improvements
--------------------
- This release contains only minor code improvements.

22
dist/changes-5.1.0 vendored Normal file
View File

@ -0,0 +1,22 @@
Qt 5.1 introduces many new features and improvements as well as bugfixes
over the 5.0.x series. For more details, refer to the online documentation
included in this distribution. The documentation is also available online:
http://qt-project.org/doc/qt-5.1
The Qt version 5.1 series is binary compatible with the 5.0.x series.
Applications compiled for 5.0 will continue to run with 5.1.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
http://bugreports.qt-project.org/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* General *
****************************************************************************
- This release contains only minor code improvements.

25
dist/changes-5.1.1 vendored Normal file
View File

@ -0,0 +1,25 @@
Qt 5.1.1 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.1.0.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://qt-project.org/doc/qt-5.1/
The Qt version 5.1 series is binary compatible with the 5.0.x series.
Applications compiled for 5.0 will continue to run with 5.1.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
http://bugreports.qt-project.org/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* General *
****************************************************************************
- This release contains only minor code improvements.

26
dist/changes-5.10.1 vendored Normal file
View File

@ -0,0 +1,26 @@
Qt 5.10.1 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.10.0.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://doc.qt.io/qt-5/index.html
The Qt version 5.10 series is binary compatible with the 5.9.x series.
Applications compiled for 5.9 will continue to run with 5.10.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
This release contains all fixes included in the Qt 5.9.4 release.
****************************************************************************
* Qt 5.10.1 Changes *
****************************************************************************
- This release contains only minor code improvements.

22
dist/changes-5.11.0 vendored Normal file
View File

@ -0,0 +1,22 @@
Qt 5.11 introduces many new features and improvements as well as bugfixes
over the 5.10.x series. For more details, refer to the online documentation
included in this distribution. The documentation is also available online:
http://doc.qt.io/qt-5/index.html
The Qt version 5.11 series is binary compatible with the 5.10.x series.
Applications compiled for 5.10 will continue to run with 5.11.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* Qt 5.11.0 Changes *
****************************************************************************
- This release contains only minor code improvements.

29
dist/changes-5.11.1 vendored Normal file
View File

@ -0,0 +1,29 @@
Qt 5.11.1 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.11.0.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://doc.qt.io/qt-5/index.html
The Qt version 5.11 series is binary compatible with the 5.10.x series.
Applications compiled for 5.10 will continue to run with 5.11.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* Qt 5.11.1 Changes *
****************************************************************************
****************************************************************************
* QtScript *
****************************************************************************
- [QTBUG-68367] Fix incorrect script evaluations on 64-bit systems with
gcc 8.

24
dist/changes-5.11.2 vendored Normal file
View File

@ -0,0 +1,24 @@
Qt 5.11.2 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.11.0 through 5.11.1.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://doc.qt.io/qt-5/index.html
The Qt version 5.11 series is binary compatible with the 5.10.x series.
Applications compiled for 5.10 will continue to run with 5.11.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* Qt 5.11.2 Changes *
****************************************************************************
- This release contains only minor code improvements.

20
dist/changes-5.11.3 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.11.3 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.11.0 through 5.11.2.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://doc.qt.io/qt-5/index.html
The Qt version 5.11 series is binary compatible with the 5.10.x series.
Applications compiled for 5.10 will continue to run with 5.11.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

18
dist/changes-5.12.0 vendored Normal file
View File

@ -0,0 +1,18 @@
Qt 5.12 introduces many new features and improvements as well as bugfixes
over the 5.11.x series. For more details, refer to the online documentation
included in this distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.12 series is binary compatible with the 5.11.x series.
Applications compiled for 5.11 will continue to run with 5.12.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

20
dist/changes-5.12.1 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.12.1 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.12.0.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://doc.qt.io/qt-5/index.html
The Qt version 5.12 series is binary compatible with the 5.11.x series.
Applications compiled for 5.11 will continue to run with 5.12.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

28
dist/changes-5.12.10 vendored Normal file
View File

@ -0,0 +1,28 @@
Qt 5.12.10 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.12.9.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5.12/index.html
The Qt version 5.12 series is binary compatible with the 5.11.x series.
Applications compiled for 5.11 will continue to run with 5.12.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* Important Behavior Changes *
****************************************************************************
****************************************************************************
* Library *
****************************************************************************

20
dist/changes-5.12.2 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.12.2 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.12.0 through 5.12.1.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.12 series is binary compatible with the 5.11.x series.
Applications compiled for 5.11 will continue to run with 5.12.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

20
dist/changes-5.12.3 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.12.3 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.12.0 through 5.12.2.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.12 series is binary compatible with the 5.11.x series.
Applications compiled for 5.11 will continue to run with 5.12.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

20
dist/changes-5.12.4 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.12.4 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.12.0 through 5.12.3.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.12 series is binary compatible with the 5.11.x series.
Applications compiled for 5.11 will continue to run with 5.12.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

20
dist/changes-5.12.5 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.12.5 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.12.0 through 5.12.4.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.12 series is binary compatible with the 5.11.x series.
Applications compiled for 5.11 will continue to run with 5.12.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

18
dist/changes-5.13.0 vendored Normal file
View File

@ -0,0 +1,18 @@
Qt 5.13 introduces many new features and improvements as well as bugfixes
over the 5.12.x series. For more details, refer to the online documentation
included in this distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.13 series is binary compatible with the 5.12.x series.
Applications compiled for 5.12 will continue to run with 5.13.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

20
dist/changes-5.13.1 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.13.1 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.13.0.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.13 series is binary compatible with the 5.12.x series.
Applications compiled for 5.12 will continue to run with 5.13.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

20
dist/changes-5.13.2 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.13.2 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.13.0 through 5.13.1.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.13 series is binary compatible with the 5.12.x series.
Applications compiled for 5.12 will continue to run with 5.13.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

18
dist/changes-5.14.0 vendored Normal file
View File

@ -0,0 +1,18 @@
Qt 5.14 introduces many new features and improvements as well as bugfixes
over the 5.13.x series. For more details, refer to the online documentation
included in this distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.14 series is binary compatible with the 5.13.x series.
Applications compiled for 5.13 will continue to run with 5.14.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

20
dist/changes-5.14.1 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.14.1 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.14.0.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.14 series is binary compatible with the 5.13.x series.
Applications compiled for 5.13 will continue to run with 5.14.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

20
dist/changes-5.14.2 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.14.2 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.14.0 through 5.14.1.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.14 series is binary compatible with the 5.13.x series.
Applications compiled for 5.13 will continue to run with 5.14.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

18
dist/changes-5.15.0 vendored Normal file
View File

@ -0,0 +1,18 @@
Qt 5.15 introduces many new features and improvements as well as bugfixes
over the 5.14.x series. For more details, refer to the online documentation
included in this distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.15 series is binary compatible with the 5.14.x series.
Applications compiled for 5.14 will continue to run with 5.15.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

20
dist/changes-5.15.1 vendored Normal file
View File

@ -0,0 +1,20 @@
Qt 5.15.1 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.15.0.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5/index.html
The Qt version 5.15 series is binary compatible with the 5.14.x series.
Applications compiled for 5.14 will continue to run with 5.15.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
- This release contains only minor code improvements.

28
dist/changes-5.15.2 vendored Normal file
View File

@ -0,0 +1,28 @@
Qt 5.15.2 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.15.1.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
https://doc.qt.io/qt-5.15/index.html
The Qt version 5.15 series is binary compatible with the 5.14.x series.
Applications compiled for 5.14 will continue to run with 5.15.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* Important Behavior Changes *
****************************************************************************
****************************************************************************
* Library *
****************************************************************************

25
dist/changes-5.9.4 vendored Normal file
View File

@ -0,0 +1,25 @@
Qt 5.9.4 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.9.0.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://doc.qt.io/qt-5/index.html
The Qt version 5.9 series is binary compatible with the 5.8.x series.
Applications compiled for 5.8 will continue to run with 5.9.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* Qt 5.9.4 Changes *
****************************************************************************
- This release contains only minor code improvements.

24
dist/changes-5.9.5 vendored Normal file
View File

@ -0,0 +1,24 @@
Qt 5.9.5 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.9.0.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://doc.qt.io/qt-5/index.html
The Qt version 5.9 series is binary compatible with the 5.8.x series.
Applications compiled for 5.8 will continue to run with 5.9.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* Qt 5.9.5 Changes *
****************************************************************************
- This release contains only minor code improvements.

24
dist/changes-5.9.6 vendored Normal file
View File

@ -0,0 +1,24 @@
Qt 5.9.6 is a bug-fix release. It maintains both forward and backward
compatibility (source and binary) with Qt 5.9.0 through 5.9.5.
For more details, refer to the online documentation included in this
distribution. The documentation is also available online:
http://doc.qt.io/qt-5/index.html
The Qt version 5.9 series is binary compatible with the 5.8.x series.
Applications compiled for 5.8 will continue to run with 5.9.
Some of the changes listed in this file include issue tracking numbers
corresponding to tasks in the Qt Bug Tracker:
https://bugreports.qt.io/
Each of these identifiers can be entered in the bug tracker to obtain more
information about a particular change.
****************************************************************************
* Qt 5.9.6 Changes *
****************************************************************************
- This release contains only minor code improvements.

2
examples/examples.pro Normal file
View File

@ -0,0 +1,2 @@
TEMPLATE = subdirs
SUBDIRS += script

9
examples/script/README Normal file
View File

@ -0,0 +1,9 @@
Qt is provided with a powerful embedded scripting environment through the Qt Script
classes.
These examples demonstrate the fundamental aspects of scripting applications
with Qt.
Documentation for these examples can be found via the Examples
link in the main Qt documentation.

View File

@ -0,0 +1,281 @@
Function.prototype.bind = function() {
var func = this;
var thisObject = arguments[0];
var args = Array.prototype.slice.call(arguments, 1);
return function() {
return func.apply(thisObject, args);
}
}
//! [0]
function Calculator(ui)
{
this.ui = ui;
this.pendingAdditiveOperator = Calculator.NO_OPERATOR;
this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR;
this.sumInMemory = 0;
this.sumSoFar = 0;
this.factorSoFar = 0;
this.waitingForOperand = true;
with (ui) {
display.text = "0";
zeroButton.clicked.connect(this.digitClicked.bind(this, 0));
oneButton.clicked.connect(this.digitClicked.bind(this, 1));
twoButton.clicked.connect(this.digitClicked.bind(this, 2));
threeButton.clicked.connect(this.digitClicked.bind(this, 3));
fourButton.clicked.connect(this.digitClicked.bind(this, 4));
fiveButton.clicked.connect(this.digitClicked.bind(this, 5));
sixButton.clicked.connect(this.digitClicked.bind(this, 6));
sevenButton.clicked.connect(this.digitClicked.bind(this, 7));
eightButton.clicked.connect(this.digitClicked.bind(this, 8));
nineButton.clicked.connect(this.digitClicked.bind(this, 9));
pointButton.clicked.connect(this, "pointClicked");
changeSignButton.clicked.connect(this, "changeSignClicked");
backspaceButton.clicked.connect(this, "backspaceClicked");
clearButton.clicked.connect(this, "clear");
clearAllButton.clicked.connect(this, "clearAll");
clearMemoryButton.clicked.connect(this, "clearMemory");
readMemoryButton.clicked.connect(this, "readMemory");
setMemoryButton.clicked.connect(this, "setMemory");
addToMemoryButton.clicked.connect(this, "addToMemory");
divisionButton.clicked.connect(this.multiplicativeOperatorClicked.bind(this, Calculator.DIVISION_OPERATOR));
timesButton.clicked.connect(this.multiplicativeOperatorClicked.bind(this, Calculator.TIMES_OPERATOR));
minusButton.clicked.connect(this.additiveOperatorClicked.bind(this, Calculator.MINUS_OPERATOR));
plusButton.clicked.connect(this.additiveOperatorClicked.bind(this, Calculator.PLUS_OPERATOR));
squareRootButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.SQUARE_OPERATOR));
powerButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.POWER_OPERATOR));
reciprocalButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.RECIPROCAL_OPERATOR));
equalButton.clicked.connect(this, "equalClicked");
}
}
//! [0]
Calculator.NO_OPERATOR = 0;
Calculator.SQUARE_OPERATOR = 1;
Calculator.POWER_OPERATOR = 2;
Calculator.RECIPROCAL_OPERATOR = 3;
Calculator.DIVISION_OPERATOR = 4;
Calculator.TIMES_OPERATOR = 5;
Calculator.MINUS_OPERATOR = 6;
Calculator.PLUS_OPERATOR = 7;
Calculator.prototype.abortOperation = function()
{
this.clearAll();
this.ui.display.text = "####";
}
Calculator.prototype.calculate = function(rightOperand, pendingOperator)
{
if (pendingOperator == Calculator.PLUS_OPERATOR) {
this.sumSoFar += rightOperand;
} else if (pendingOperator == Calculator.MINUS_OPERATOR) {
this.sumSoFar -= rightOperand;
} else if (pendingOperator == Calculator.TIMES_OPERATOR) {
this.factorSoFar *= rightOperand;
} else if (pendingOperator == Calculator.DIVISION_OPERATOR) {
if (rightOperand == 0)
return false;
this.factorSoFar /= rightOperand;
}
return true;
}
//! [1]
Calculator.prototype.digitClicked = function(digitValue)
{
if ((digitValue == 0) && (this.ui.display.text == "0"))
return;
if (this.waitingForOperand) {
this.ui.display.clear();
this.waitingForOperand = false;
}
this.ui.display.text += digitValue;
}
//! [1]
Calculator.prototype.unaryOperatorClicked = function(op)
{
var operand = this.ui.display.text - 0;
var result = 0;
if (op == Calculator.SQUARE_OPERATOR) {
if (operand < 0) {
this.abortOperation();
return;
}
result = Math.sqrt(operand);
} else if (op == Calculator.POWER_OPERATOR) {
result = Math.pow(operand, 2);
} else if (op == Calculator.RECIPROCAL_OPERATOR) {
if (operand == 0.0) {
this.abortOperation();
return;
}
result = 1 / operand;
}
this.ui.display.text = result + "";
this.waitingForOperand = true;
}
Calculator.prototype.additiveOperatorClicked = function(op)
{
var operand = this.ui.display.text - 0;
if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) {
if (!this.calculate(operand, this.pendingMultiplicativeOperator)) {
this.abortOperation();
return;
}
this.ui.display.text = this.factorSoFar + "";
operand = this.factorSoFar;
this.factorSoFar = 0;
this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR;
}
if (this.pendingAdditiveOperator != Calculator.NO_OPERATOR) {
if (!this.calculate(operand, this.pendingAdditiveOperator)) {
this.abortOperation();
return;
}
this.ui.display.text = this.sumSoFar + "";
} else {
this.sumSoFar = operand;
}
this.pendingAdditiveOperator = op;
this.waitingForOperand = true;
}
Calculator.prototype.multiplicativeOperatorClicked = function(op)
{
var operand = this.ui.display.text - 0;
if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) {
if (!this.calculate(operand, this.pendingMultiplicativeOperator)) {
this.abortOperation();
return;
}
this.ui.display.text = this.factorSoFar + "";
} else {
this.factorSoFar = operand;
}
this.pendingMultiplicativeOperator = op;
this.waitingForOperand = true;
}
Calculator.prototype.equalClicked = function()
{
var operand = this.ui.display.text - 0;
if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) {
if (!this.calculate(operand, this.pendingMultiplicativeOperator)) {
this.abortOperation();
return;
}
operand = this.factorSoFar;
this.factorSoFar = 0.0;
this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR;
}
if (this.pendingAdditiveOperator != Calculator.NO_OPERATOR) {
if (!this.calculate(operand, this.pendingAdditiveOperator)) {
this.abortOperation();
return;
}
this.pendingAdditiveOperator = Calculator.NO_OPERATOR;
} else {
this.sumSoFar = operand;
}
this.ui.display.text = this.sumSoFar + "";
this.sumSoFar = 0.0;
this.waitingForOperand = true;
}
Calculator.prototype.pointClicked = function()
{
if (this.waitingForOperand)
this.ui.display.text = "0";
if (this.ui.display.text.indexOf(".") == -1)
this.ui.display.text += ".";
this.waitingForOperand = false;
}
//! [2]
Calculator.prototype.changeSignClicked = function()
{
var text = this.ui.display.text;
var value = text - 0;
if (value > 0) {
text = "-" + text;
} else if (value < 0) {
text = text.slice(1);
}
this.ui.display.text = text;
}
//! [2]
Calculator.prototype.backspaceClicked = function()
{
if (this.waitingForOperand)
return;
var text = this.ui.display.text;
text = text.slice(0, -1);
if (text.length == 0) {
text = "0";
this.waitingForOperand = true;
}
this.ui.display.text = text;
}
Calculator.prototype.clear = function()
{
if (this.waitingForOperand)
return;
this.ui.display.text = "0";
this.waitingForOperand = true;
}
Calculator.prototype.clearAll = function()
{
this.sumSoFar = 0.0;
this.factorSoFar = 0.0;
this.pendingAdditiveOperator = Calculator.NO_OPERATOR;
this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR;
this.ui.display.text = "0";
this.waitingForOperand = true;
}
Calculator.prototype.clearMemory = function()
{
this.sumInMemory = 0.0;
}
Calculator.prototype.readMemory = function()
{
this.ui.display.text = this.sumInMemory + "";
this.waitingForOperand = true;
}
Calculator.prototype.setMemory = function()
{
this.equalClicked();
this.sumInMemory = this.ui.display.text - 0;
}
Calculator.prototype.addToMemory = function()
{
this.equalClicked();
this.sumInMemory += this.ui.display.text - 0;
}

View File

@ -0,0 +1,11 @@
QT += script widgets uitools
RESOURCES += calculator.qrc
SOURCES += main.cpp
QMAKE_PROJECT_NAME = scripted_calculator
qtHaveModule(scripttools): QT += scripttools
target.path = $$[QT_INSTALL_EXAMPLES]/script/calculator
INSTALLS += target
maemo5: CONFIG += qt_example

View File

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/" >
<file>calculator.js</file>
<file>calculator.ui</file>
</qresource>
</RCC>

View File

@ -0,0 +1,416 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Calculator</class>
<widget class="QWidget" name="Calculator">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>314</width>
<height>301</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>314</width>
<height>301</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1024</width>
<height>768</height>
</size>
</property>
<property name="windowTitle">
<string>Calculator</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>10</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QToolButton" name="backspaceButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Backspace</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QToolButton" name="clearMemoryButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>MC</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QToolButton" name="sevenButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>7</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="eightButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>8</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QToolButton" name="nineButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>9</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QToolButton" name="divisionButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>/</string>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QToolButton" name="squareRootButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Sqrt</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QToolButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item row="1" column="4" colspan="2">
<widget class="QToolButton" name="clearAllButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Clear All</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="6">
<widget class="QLineEdit" name="display">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxLength">
<number>24</number>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QToolButton" name="readMemoryButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>MR</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QToolButton" name="fourButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>4</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="fiveButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>5</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QToolButton" name="sixButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>6</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QToolButton" name="timesButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>*</string>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QToolButton" name="powerButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>x^2</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QToolButton" name="setMemoryButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>MS</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QToolButton" name="oneButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QToolButton" name="twoButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>2</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QToolButton" name="threeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>3</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QToolButton" name="minusButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="4" column="5">
<widget class="QToolButton" name="reciprocalButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>1/x</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QToolButton" name="addToMemoryButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>M+</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QToolButton" name="zeroButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QToolButton" name="pointButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>.</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QToolButton" name="changeSignButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>+-</string>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QToolButton" name="plusButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="5" column="5">
<widget class="QToolButton" name="equalButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>=</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,110 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QApplication>
#include <QUiLoader>
#include <QtScript>
#include <QWidget>
#include <QFile>
#include <QMainWindow>
#include <QLineEdit>
#ifndef QT_NO_SCRIPTTOOLS
#include <QScriptEngineDebugger>
#endif
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(calculator);
QApplication app(argc, argv);
//! [0a]
QScriptEngine engine;
//! [0a]
#if !defined(QT_NO_SCRIPTTOOLS)
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
QMainWindow *debugWindow = debugger.standardWindow();
debugWindow->resize(1024, 640);
#endif
//! [0b]
QString scriptFileName(":/calculator.js");
QFile scriptFile(scriptFileName);
scriptFile.open(QIODevice::ReadOnly);
engine.evaluate(scriptFile.readAll(), scriptFileName);
scriptFile.close();
//! [0b]
//! [1]
QUiLoader loader;
QFile uiFile(":/calculator.ui");
uiFile.open(QIODevice::ReadOnly);
QWidget *ui = loader.load(&uiFile);
uiFile.close();
//! [1]
//! [2]
QScriptValue ctor = engine.evaluate("Calculator");
QScriptValue scriptUi = engine.newQObject(ui, QScriptEngine::ScriptOwnership);
QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi);
//! [2]
#if !defined(QT_NO_SCRIPTTOOLS)
QLineEdit *display = ui->findChild<QLineEdit*>("display");
QObject::connect(display, SIGNAL(returnPressed()),
debugWindow, SLOT(show()));
#endif
//! [3]
ui->show();
return app.exec();
//! [3]
}

View File

@ -0,0 +1,830 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "context2d.h"
#include <QVariant>
#include <qmath.h>
#define qClamp(val, min, max) qMin(qMax(val, min), max)
static QList<qreal> parseNumbersList(QString::const_iterator &itr)
{
QList<qreal> points;
QString temp;
while ((*itr).isSpace())
++itr;
while ((*itr).isNumber() ||
(*itr) == '-' || (*itr) == '+' || (*itr) == '.') {
temp = QString();
if ((*itr) == '-')
temp += *itr++;
else if ((*itr) == '+')
temp += *itr++;
while ((*itr).isDigit())
temp += *itr++;
if ((*itr) == '.')
temp += *itr++;
while ((*itr).isDigit())
temp += *itr++;
while ((*itr).isSpace())
++itr;
if ((*itr) == ',')
++itr;
points.append(temp.toDouble());
//eat spaces
while ((*itr).isSpace())
++itr;
}
return points;
}
QColor colorFromString(const QString &name)
{
QString::const_iterator itr = name.constBegin();
QList<qreal> compo;
if (name.startsWith("rgba(")) {
++itr; ++itr; ++itr; ++itr; ++itr;
compo = parseNumbersList(itr);
if (compo.size() != 4) {
return QColor();
}
//alpha seems to be always between 0-1
compo[3] *= 255;
return QColor((int)compo[0], (int)compo[1],
(int)compo[2], (int)compo[3]);
} else if (name.startsWith("rgb(")) {
++itr; ++itr; ++itr; ++itr;
compo = parseNumbersList(itr);
if (compo.size() != 3) {
return QColor();
}
return QColor((int)qClamp(compo[0], qreal(0), qreal(255)),
(int)qClamp(compo[1], qreal(0), qreal(255)),
(int)qClamp(compo[2], qreal(0), qreal(255)));
} else {
//QRgb color;
//CSSParser::parseColor(name, color);
return QColor(name);
}
}
static QPainter::CompositionMode compositeOperatorFromString(const QString &compositeOperator)
{
if ( compositeOperator == "source-over" ) {
return QPainter::CompositionMode_SourceOver;
} else if ( compositeOperator == "source-out" ) {
return QPainter::CompositionMode_SourceOut;
} else if ( compositeOperator == "source-in" ) {
return QPainter::CompositionMode_SourceIn;
} else if ( compositeOperator == "source-atop" ) {
return QPainter::CompositionMode_SourceAtop;
} else if ( compositeOperator == "destination-atop" ) {
return QPainter::CompositionMode_DestinationAtop;
} else if ( compositeOperator == "destination-in" ) {
return QPainter::CompositionMode_DestinationIn;
} else if ( compositeOperator == "destination-out" ) {
return QPainter::CompositionMode_DestinationOut;
} else if ( compositeOperator == "destination-over" ) {
return QPainter::CompositionMode_DestinationOver;
} else if ( compositeOperator == "darker" ) {
return QPainter::CompositionMode_SourceOver;
} else if ( compositeOperator == "lighter" ) {
return QPainter::CompositionMode_SourceOver;
} else if ( compositeOperator == "copy" ) {
return QPainter::CompositionMode_Source;
} else if ( compositeOperator == "xor" ) {
return QPainter::CompositionMode_Xor;
}
return QPainter::CompositionMode_SourceOver;
}
static QString compositeOperatorToString(QPainter::CompositionMode op)
{
switch (op) {
case QPainter::CompositionMode_SourceOver:
return "source-over";
case QPainter::CompositionMode_DestinationOver:
return "destination-over";
case QPainter::CompositionMode_Clear:
return "clear";
case QPainter::CompositionMode_Source:
return "source";
case QPainter::CompositionMode_Destination:
return "destination";
case QPainter::CompositionMode_SourceIn:
return "source-in";
case QPainter::CompositionMode_DestinationIn:
return "destination-in";
case QPainter::CompositionMode_SourceOut:
return "source-out";
case QPainter::CompositionMode_DestinationOut:
return "destination-out";
case QPainter::CompositionMode_SourceAtop:
return "source-atop";
case QPainter::CompositionMode_DestinationAtop:
return "destination-atop";
case QPainter::CompositionMode_Xor:
return "xor";
case QPainter::CompositionMode_Plus:
return "plus";
case QPainter::CompositionMode_Multiply:
return "multiply";
case QPainter::CompositionMode_Screen:
return "screen";
case QPainter::CompositionMode_Overlay:
return "overlay";
case QPainter::CompositionMode_Darken:
return "darken";
case QPainter::CompositionMode_Lighten:
return "lighten";
case QPainter::CompositionMode_ColorDodge:
return "color-dodge";
case QPainter::CompositionMode_ColorBurn:
return "color-burn";
case QPainter::CompositionMode_HardLight:
return "hard-light";
case QPainter::CompositionMode_SoftLight:
return "soft-light";
case QPainter::CompositionMode_Difference:
return "difference";
case QPainter::CompositionMode_Exclusion:
return "exclusion";
default:
break;
}
return QString();
}
void Context2D::save()
{
m_stateStack.push(m_state);
}
void Context2D::restore()
{
if (!m_stateStack.isEmpty()) {
m_state = m_stateStack.pop();
m_state.flags = AllIsFullOfDirt;
}
}
void Context2D::scale(qreal x, qreal y)
{
m_state.matrix.scale(x, y);
m_state.flags |= DirtyTransformationMatrix;
}
void Context2D::rotate(qreal angle)
{
m_state.matrix.rotate(qRadiansToDegrees(angle));
m_state.flags |= DirtyTransformationMatrix;
}
void Context2D::translate(qreal x, qreal y)
{
m_state.matrix.translate(x, y);
m_state.flags |= DirtyTransformationMatrix;
}
void Context2D::transform(qreal m11, qreal m12, qreal m21, qreal m22,
qreal dx, qreal dy)
{
QTransform mat(m11, m12,
m21, m22,
dx, dy);
m_state.matrix *= mat;
m_state.flags |= DirtyTransformationMatrix;
}
void Context2D::setTransform(qreal m11, qreal m12, qreal m21, qreal m22,
qreal dx, qreal dy)
{
QTransform mat(m11, m12,
m21, m22,
dx, dy);
m_state.matrix = mat;
m_state.flags |= DirtyTransformationMatrix;
}
QString Context2D::globalCompositeOperation() const
{
return compositeOperatorToString(m_state.globalCompositeOperation);
}
void Context2D::setGlobalCompositeOperation(const QString &op)
{
QPainter::CompositionMode mode =
compositeOperatorFromString(op);
m_state.globalCompositeOperation = mode;
m_state.flags |= DirtyGlobalCompositeOperation;
}
QVariant Context2D::strokeStyle() const
{
return m_state.strokeStyle;
}
void Context2D::setStrokeStyle(const QVariant &style)
{
if (style.canConvert<CanvasGradient>()) {
CanvasGradient cg = qvariant_cast<CanvasGradient>(style);
m_state.strokeStyle = cg.value;
} else {
QColor color = colorFromString(style.toString());
m_state.strokeStyle = color;
}
m_state.flags |= DirtyStrokeStyle;
}
QVariant Context2D::fillStyle() const
{
return m_state.fillStyle;
}
//! [3]
void Context2D::setFillStyle(const QVariant &style)
{
if (style.canConvert<CanvasGradient>()) {
CanvasGradient cg = qvariant_cast<CanvasGradient>(style);
m_state.fillStyle = cg.value;
} else {
QColor color = colorFromString(style.toString());
m_state.fillStyle = color;
}
m_state.flags |= DirtyFillStyle;
}
//! [3]
qreal Context2D::globalAlpha() const
{
return m_state.globalAlpha;
}
void Context2D::setGlobalAlpha(qreal alpha)
{
m_state.globalAlpha = alpha;
m_state.flags |= DirtyGlobalAlpha;
}
CanvasGradient Context2D::createLinearGradient(qreal x0, qreal y0,
qreal x1, qreal y1)
{
QLinearGradient g(x0, y0, x1, y1);
return CanvasGradient(g);
}
CanvasGradient Context2D::createRadialGradient(qreal x0, qreal y0,
qreal r0, qreal x1,
qreal y1, qreal r1)
{
QRadialGradient g(QPointF(x1, y1), r0+r1, QPointF(x0, y0));
return CanvasGradient(g);
}
qreal Context2D::lineWidth() const
{
return m_state.lineWidth;
}
void Context2D::setLineWidth(qreal w)
{
m_state.lineWidth = w;
m_state.flags |= DirtyLineWidth;
}
//! [0]
QString Context2D::lineCap() const
{
switch (m_state.lineCap) {
case Qt::FlatCap:
return "butt";
case Qt::SquareCap:
return "square";
case Qt::RoundCap:
return "round";
default: ;
}
return QString();
}
void Context2D::setLineCap(const QString &capString)
{
Qt::PenCapStyle style;
if (capString == "round")
style = Qt::RoundCap;
else if (capString == "square")
style = Qt::SquareCap;
else //if (capString == "butt")
style = Qt::FlatCap;
m_state.lineCap = style;
m_state.flags |= DirtyLineCap;
}
//! [0]
QString Context2D::lineJoin() const
{
switch (m_state.lineJoin) {
case Qt::RoundJoin:
return "round";
case Qt::BevelJoin:
return "bevel";
case Qt::MiterJoin:
return "miter";
default: ;
}
return QString();
}
void Context2D::setLineJoin(const QString &joinString)
{
Qt::PenJoinStyle style;
if (joinString == "round")
style = Qt::RoundJoin;
else if (joinString == "bevel")
style = Qt::BevelJoin;
else //if (joinString == "miter")
style = Qt::MiterJoin;
m_state.lineJoin = style;
m_state.flags |= DirtyLineJoin;
}
qreal Context2D::miterLimit() const
{
return m_state.miterLimit;
}
void Context2D::setMiterLimit(qreal m)
{
m_state.miterLimit = m;
m_state.flags |= DirtyMiterLimit;
}
void Context2D::setShadowOffsetX(qreal x)
{
m_state.shadowOffsetX = x;
m_state.flags |= DirtyShadowOffsetX;
}
void Context2D::setShadowOffsetY(qreal y)
{
m_state.shadowOffsetY = y;
m_state.flags |= DirtyShadowOffsetY;
}
void Context2D::setShadowBlur(qreal b)
{
m_state.shadowBlur = b;
m_state.flags |= DirtyShadowBlur;
}
void Context2D::setShadowColor(const QString &str)
{
m_state.shadowColor = colorFromString(str);
m_state.flags |= DirtyShadowColor;
}
qreal Context2D::shadowOffsetX() const
{
return m_state.shadowOffsetX;
}
qreal Context2D::shadowOffsetY() const
{
return m_state.shadowOffsetY;
}
qreal Context2D::shadowBlur() const
{
return m_state.shadowBlur;
}
QString Context2D::shadowColor() const
{
return m_state.shadowColor.name();
}
void Context2D::clearRect(qreal x, qreal y, qreal w, qreal h)
{
beginPainting();
m_painter.save();
m_painter.setTransform(QTransform(m_state.matrix), false);
m_painter.setCompositionMode(QPainter::CompositionMode_Source);
m_painter.fillRect(QRectF(x, y, w, h), QColor(0, 0, 0, 0));
m_painter.restore();
scheduleChange();
}
//! [1]
void Context2D::fillRect(qreal x, qreal y, qreal w, qreal h)
{
beginPainting();
m_painter.save();
m_painter.setTransform(QTransform(m_state.matrix), false);
m_painter.fillRect(QRectF(x, y, w, h), m_painter.brush());
m_painter.restore();
scheduleChange();
}
//! [1]
void Context2D::strokeRect(qreal x, qreal y, qreal w, qreal h)
{
QPainterPath path;
path.addRect(x, y, w, h);
beginPainting();
m_painter.save();
m_painter.setTransform(QTransform(m_state.matrix), false);
m_painter.strokePath(path, m_painter.pen());
m_painter.restore();
scheduleChange();
}
void Context2D::beginPath()
{
m_path = QPainterPath();
}
void Context2D::closePath()
{
m_path.closeSubpath();
}
void Context2D::moveTo(qreal x, qreal y)
{
QPointF pt = m_state.matrix.map(QPointF(x, y));
m_path.moveTo(pt);
}
void Context2D::lineTo(qreal x, qreal y)
{
QPointF pt = m_state.matrix.map(QPointF(x, y));
m_path.lineTo(pt);
}
void Context2D::quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y)
{
QPointF cp = m_state.matrix.map(QPointF(cpx, cpy));
QPointF xy = m_state.matrix.map(QPointF(x, y));
m_path.quadTo(cp, xy);
}
void Context2D::bezierCurveTo(qreal cp1x, qreal cp1y,
qreal cp2x, qreal cp2y, qreal x, qreal y)
{
QPointF cp1 = m_state.matrix.map(QPointF(cp1x, cp1y));
QPointF cp2 = m_state.matrix.map(QPointF(cp2x, cp2y));
QPointF end = m_state.matrix.map(QPointF(x, y));
m_path.cubicTo(cp1, cp2, end);
}
void Context2D::arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius)
{
//FIXME: this is surely busted
QPointF st = m_state.matrix.map(QPointF(x1, y1));
QPointF end = m_state.matrix.map(QPointF(x2, y2));
m_path.arcTo(st.x(), st.y(),
end.x()-st.x(), end.y()-st.y(),
radius, 90);
}
void Context2D::rect(qreal x, qreal y, qreal w, qreal h)
{
QPainterPath path; path.addRect(x, y, w, h);
path = m_state.matrix.map(path);
m_path.addPath(path);
}
void Context2D::arc(qreal xc, qreal yc, qreal radius,
qreal sar, qreal ear,
bool anticlockwise)
{
//### HACK
// In Qt we don't switch the coordinate system for degrees
// and still use the 0,0 as bottom left for degrees so we need
// to switch
sar = -sar;
ear = -ear;
anticlockwise = !anticlockwise;
//end hack
float sa = qRadiansToDegrees(sar);
float ea = qRadiansToDegrees(ear);
double span = 0;
double xs = xc - radius;
double ys = yc - radius;
double width = radius*2;
double height = radius*2;
if (!anticlockwise && (ea < sa)) {
span += 360;
} else if (anticlockwise && (sa < ea)) {
span -= 360;
}
//### this is also due to switched coordinate system
// we would end up with a 0 span instead of 360
if (!(qFuzzyCompare(span + (ea - sa) + 1, 1) &&
qFuzzyCompare(qAbs(span), 360))) {
span += ea - sa;
}
QPainterPath path;
path.moveTo(QPointF(xc + radius * cos(sar),
yc - radius * sin(sar)));
path.arcTo(xs, ys, width, height, sa, span);
path = m_state.matrix.map(path);
m_path.addPath(path);
}
void Context2D::fill()
{
beginPainting();
m_painter.fillPath(m_path, m_painter.brush());
scheduleChange();
}
void Context2D::stroke()
{
beginPainting();
m_painter.save();
m_painter.setTransform(QTransform(m_state.matrix), false);
QPainterPath tmp = m_state.matrix.inverted().map(m_path);
m_painter.strokePath(tmp, m_painter.pen());
m_painter.restore();
scheduleChange();
}
void Context2D::clip()
{
m_state.clipPath = m_path;
m_state.flags |= DirtyClippingRegion;
}
bool Context2D::isPointInPath(qreal x, qreal y) const
{
return m_path.contains(QPointF(x, y));
}
ImageData Context2D::getImageData(qreal sx, qreal sy, qreal sw, qreal sh)
{
Q_UNUSED(sx);
Q_UNUSED(sy);
Q_UNUSED(sw);
Q_UNUSED(sh);
return ImageData();
}
void Context2D::putImageData(ImageData image, qreal dx, qreal dy)
{
Q_UNUSED(image);
Q_UNUSED(dx);
Q_UNUSED(dy);
}
Context2D::Context2D(QObject *parent)
: QObject(parent), m_changeTimerId(-1)
{
reset();
}
const QImage &Context2D::endPainting()
{
if (m_painter.isActive())
m_painter.end();
return m_image;
}
void Context2D::beginPainting()
{
if (!m_painter.isActive()) {
m_painter.begin(&m_image);
m_painter.setRenderHint(QPainter::Antialiasing);
if (!m_state.clipPath.isEmpty())
m_painter.setClipPath(m_state.clipPath);
m_painter.setBrush(m_state.fillStyle);
m_painter.setOpacity(m_state.globalAlpha);
QPen pen;
pen.setBrush(m_state.strokeStyle);
if (pen.style() == Qt::NoPen)
pen.setStyle(Qt::SolidLine);
pen.setCapStyle(m_state.lineCap);
pen.setJoinStyle(m_state.lineJoin);
pen.setWidthF(m_state.lineWidth);
pen.setMiterLimit(m_state.miterLimit);
m_painter.setPen(pen);
} else {
if ((m_state.flags & DirtyClippingRegion) && !m_state.clipPath.isEmpty())
m_painter.setClipPath(m_state.clipPath);
if (m_state.flags & DirtyFillStyle)
m_painter.setBrush(m_state.fillStyle);
if (m_state.flags & DirtyGlobalAlpha)
m_painter.setOpacity(m_state.globalAlpha);
if (m_state.flags & DirtyGlobalCompositeOperation)
m_painter.setCompositionMode(m_state.globalCompositeOperation);
if (m_state.flags & MDirtyPen) {
QPen pen = m_painter.pen();
if (m_state.flags & DirtyStrokeStyle)
pen.setBrush(m_state.strokeStyle);
if (m_state.flags & DirtyLineWidth)
pen.setWidthF(m_state.lineWidth);
if (m_state.flags & DirtyLineCap)
pen.setCapStyle(m_state.lineCap);
if (m_state.flags & DirtyLineJoin)
pen.setJoinStyle(m_state.lineJoin);
if (m_state.flags & DirtyMiterLimit)
pen.setMiterLimit(m_state.miterLimit);
m_painter.setPen(pen);
}
m_state.flags = 0;
}
}
void Context2D::clear()
{
endPainting();
m_image.fill(qRgba(0,0,0,0));
scheduleChange();
}
void Context2D::reset()
{
m_stateStack.clear();
m_state.matrix = QTransform();
m_state.clipPath = QPainterPath();
m_state.globalAlpha = 1.0;
m_state.globalCompositeOperation = QPainter::CompositionMode_SourceOver;
m_state.strokeStyle = Qt::black;
m_state.fillStyle = Qt::black;
m_state.lineWidth = 1;
m_state.lineCap = Qt::FlatCap;
m_state.lineJoin = Qt::MiterJoin;
m_state.miterLimit = 10;
m_state.shadowOffsetX = 0;
m_state.shadowOffsetY = 0;
m_state.shadowBlur = 0;
m_state.shadowColor = qRgba(0, 0, 0, 0);
m_state.flags = AllIsFullOfDirt;
clear();
}
void Context2D::setSize(int width, int height)
{
endPainting();
QImage newi(width, height, QImage::Format_ARGB32_Premultiplied);
newi.fill(qRgba(0,0,0,0));
QPainter p(&newi);
p.drawImage(0, 0, m_image);
p.end();
m_image = newi;
scheduleChange();
}
void Context2D::setSize(const QSize &size)
{
setSize(size.width(), size.height());
}
QSize Context2D::size() const
{
return m_image.size();
}
void Context2D::drawImage(DomImage *image, qreal dx, qreal dy)
{
if (!image)
return;
if (dx < 0) {
qreal sx = qAbs(dx);
qreal sy = qAbs(dy);
qreal sw = image->width() - sx;
qreal sh = image->height() - sy;
drawImage(image, sx, sy, sw, sh, 0, 0, sw, sh);
} else {
beginPainting();
m_painter.drawImage(QPointF(dx, dy), image->image());
scheduleChange();
}
}
void Context2D::drawImage(DomImage *image, qreal dx, qreal dy,
qreal dw, qreal dh)
{
if (!image)
return;
beginPainting();
m_painter.drawImage(QRectF(dx, dy, dw, dh).toRect(), image->image());
scheduleChange();
}
void Context2D::drawImage(DomImage *image, qreal sx, qreal sy,
qreal sw, qreal sh, qreal dx, qreal dy,
qreal dw, qreal dh)
{
if (!image)
return;
beginPainting();
m_painter.drawImage(QRectF(dx, dy, dw, dh), image->image(),
QRectF(sx, sy, sw, sh));
scheduleChange();
}
//! [2]
void Context2D::scheduleChange()
{
if (m_changeTimerId == -1)
m_changeTimerId = startTimer(0);
}
void Context2D::timerEvent(QTimerEvent *e)
{
if (e->timerId() == m_changeTimerId) {
killTimer(m_changeTimerId);
m_changeTimerId = -1;
emit changed(endPainting());
} else {
QObject::timerEvent(e);
}
}
//! [2]

View File

@ -0,0 +1,270 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef CONTEXT2D_H
#define CONTEXT2D_H
#include "domimage.h"
#include <QPainter>
#include <QPainterPath>
#include <QString>
#include <QStack>
#include <QMetaType>
#include <QTimerEvent>
// [3]
class CanvasGradient
{
public:
CanvasGradient(const QGradient &v)
: value(v) {}
CanvasGradient() {}
QGradient value;
};
// [3]
Q_DECLARE_METATYPE(CanvasGradient)
Q_DECLARE_METATYPE(CanvasGradient*)
class ImageData {
};
class QContext2DCanvas;
//! [0]
class Context2D : public QObject
{
Q_OBJECT
// compositing
Q_PROPERTY(qreal globalAlpha READ globalAlpha WRITE setGlobalAlpha)
Q_PROPERTY(QString globalCompositeOperation READ globalCompositeOperation WRITE setGlobalCompositeOperation)
Q_PROPERTY(QVariant strokeStyle READ strokeStyle WRITE setStrokeStyle)
Q_PROPERTY(QVariant fillStyle READ fillStyle WRITE setFillStyle)
// line caps/joins
Q_PROPERTY(qreal lineWidth READ lineWidth WRITE setLineWidth)
Q_PROPERTY(QString lineCap READ lineCap WRITE setLineCap)
Q_PROPERTY(QString lineJoin READ lineJoin WRITE setLineJoin)
Q_PROPERTY(qreal miterLimit READ miterLimit WRITE setMiterLimit)
// shadows
Q_PROPERTY(qreal shadowOffsetX READ shadowOffsetX WRITE setShadowOffsetX)
Q_PROPERTY(qreal shadowOffsetY READ shadowOffsetY WRITE setShadowOffsetY)
Q_PROPERTY(qreal shadowBlur READ shadowBlur WRITE setShadowBlur)
Q_PROPERTY(QString shadowColor READ shadowColor WRITE setShadowColor)
//! [0]
public:
Context2D(QObject *parent = 0);
void setSize(int width, int height);
void setSize(const QSize &size);
QSize size() const;
void clear();
void reset();
// compositing
qreal globalAlpha() const; // (default 1.0)
QString globalCompositeOperation() const; // (default over)
QVariant strokeStyle() const; // (default black)
QVariant fillStyle() const; // (default black)
void setGlobalAlpha(qreal alpha);
void setGlobalCompositeOperation(const QString &op);
void setStrokeStyle(const QVariant &style);
void setFillStyle(const QVariant &style);
// line caps/joins
qreal lineWidth() const; // (default 1)
QString lineCap() const; // "butt", "round", "square" (default "butt")
QString lineJoin() const; // "round", "bevel", "miter" (default "miter")
qreal miterLimit() const; // (default 10)
void setLineWidth(qreal w);
void setLineCap(const QString &s);
void setLineJoin(const QString &s);
void setMiterLimit(qreal m);
// shadows
qreal shadowOffsetX() const; // (default 0)
qreal shadowOffsetY() const; // (default 0)
qreal shadowBlur() const; // (default 0)
QString shadowColor() const; // (default black)
void setShadowOffsetX(qreal x);
void setShadowOffsetY(qreal y);
void setShadowBlur(qreal b);
void setShadowColor(const QString &str);
//! [1]
public slots:
void save(); // push state on state stack
void restore(); // pop state stack and restore state
void scale(qreal x, qreal y);
void rotate(qreal angle);
void translate(qreal x, qreal y);
void transform(qreal m11, qreal m12, qreal m21, qreal m22,
qreal dx, qreal dy);
void setTransform(qreal m11, qreal m12, qreal m21, qreal m22,
qreal dx, qreal dy);
CanvasGradient createLinearGradient(qreal x0, qreal y0,
qreal x1, qreal y1);
CanvasGradient createRadialGradient(qreal x0, qreal y0,
qreal r0, qreal x1,
qreal y1, qreal r1);
// rects
void clearRect(qreal x, qreal y, qreal w, qreal h);
void fillRect(qreal x, qreal y, qreal w, qreal h);
void strokeRect(qreal x, qreal y, qreal w, qreal h);
// path API
void beginPath();
void closePath();
void moveTo(qreal x, qreal y);
void lineTo(qreal x, qreal y);
void quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y);
void bezierCurveTo(qreal cp1x, qreal cp1y,
qreal cp2x, qreal cp2y, qreal x, qreal y);
void arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius);
void rect(qreal x, qreal y, qreal w, qreal h);
void arc(qreal x, qreal y, qreal radius,
qreal startAngle, qreal endAngle,
bool anticlockwise);
void fill();
void stroke();
void clip();
bool isPointInPath(qreal x, qreal y) const;
//! [1]
// drawing images
void drawImage(DomImage *image, qreal dx, qreal dy);
void drawImage(DomImage *image, qreal dx, qreal dy,
qreal dw, qreal dh);
void drawImage(DomImage *image, qreal sx, qreal sy,
qreal sw, qreal sh, qreal dx, qreal dy,
qreal dw, qreal dh);
// pixel manipulation
ImageData getImageData(qreal sx, qreal sy, qreal sw, qreal sh);
void putImageData(ImageData image, qreal dx, qreal dy);
//! [2]
signals:
void changed(const QImage &image);
//! [2]
protected:
void timerEvent(QTimerEvent *e);
private:
void beginPainting();
const QImage &endPainting();
void scheduleChange();
int m_changeTimerId;
QImage m_image;
QPainter m_painter;
QPainterPath m_path;
enum DirtyFlag {
DirtyTransformationMatrix = 0x00001,
DirtyClippingRegion = 0x00002,
DirtyStrokeStyle = 0x00004,
DirtyFillStyle = 0x00008,
DirtyGlobalAlpha = 0x00010,
DirtyLineWidth = 0x00020,
DirtyLineCap = 0x00040,
DirtyLineJoin = 0x00080,
DirtyMiterLimit = 0x00100,
MDirtyPen = DirtyStrokeStyle
| DirtyLineWidth
| DirtyLineCap
| DirtyLineJoin
| DirtyMiterLimit,
DirtyShadowOffsetX = 0x00200,
DirtyShadowOffsetY = 0x00400,
DirtyShadowBlur = 0x00800,
DirtyShadowColor = 0x01000,
DirtyGlobalCompositeOperation = 0x2000,
DirtyFont = 0x04000,
DirtyTextAlign = 0x08000,
DirtyTextBaseline = 0x10000,
AllIsFullOfDirt = 0xfffff
};
struct State {
State() : flags(0) {}
QTransform matrix;
QPainterPath clipPath;
QBrush strokeStyle;
QBrush fillStyle;
qreal globalAlpha;
qreal lineWidth;
Qt::PenCapStyle lineCap;
Qt::PenJoinStyle lineJoin;
qreal miterLimit;
qreal shadowOffsetX;
qreal shadowOffsetY;
qreal shadowBlur;
QColor shadowColor;
QPainter::CompositionMode globalCompositeOperation;
QFont font;
int textAlign;
int textBaseline;
int flags;
};
State m_state;
QStack<State> m_stateStack;
};
#endif

View File

@ -0,0 +1,23 @@
TEMPLATE = app
QT += widgets script
# Input
HEADERS += qcontext2dcanvas.h \
context2d.h \
domimage.h \
environment.h \
window.h
SOURCES += qcontext2dcanvas.cpp \
context2d.cpp \
domimage.cpp \
environment.cpp \
window.cpp \
main.cpp
RESOURCES += context2d.qrc
qtHaveModule(scripttools): QT += scripttools
target.path = $$[QT_INSTALL_EXAMPLES]/script/context2d
INSTALLS += target
maemo5: CONFIG += qt_example

View File

@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file>scripts</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,339 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example script/context2d
\title Context2D Example
This Qt Script example is an implementation of the Context2D API.
\image context2d-example.png
Context2D is part of the specification for the HTML \c{<canvas>}
element. It can be used to draw graphics via scripting. A good
resource for learning more about the HTML \c{<canvas>} element is
the \l{http://developer.mozilla.org/en/docs/HTML:Canvas}{Mozilla Developer Center}.
\section1 Using The HTML Canvas Element in a Web Browser
First, let's look at how the \c{<canvas>} element is typically
used in a web browser. The following HTML snippet defines a
canvas of size 400x400 pixels with id \c{mycanvas}:
\code
<canvas width="400" height="400" id="mycanvas">Fallback content goes here.</canvas>
\endcode
To draw on the canvas, we must first obtain a reference to the
DOM element corresponding to the \c{<canvas>} tag and then call
the element's getContext() function. The resulting object
implements the Context2D API that we use to draw.
\code
<script>
var canvas = document.getElementById("mycanvas");
var ctx = canvas.getContext("2d");
// Draw a face
ctx.beginPath();
ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle
ctx.moveTo(110,75);
ctx.arc(75,75,35,0,Math.PI,false); // Mouth
ctx.moveTo(65,65);
ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye
ctx.moveTo(95,65);
ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye
ctx.stroke();
</script>
\endcode
When the page is rendered by a browser that supports the
\c{<canvas>} tag, this would be the result:
\image context2d-example-smileysmile.png
\section1 Using Qt Script to script a Canvas
The goal of this example is to be able to evaluate scripts
that use the Context2D API, and render the results. Basic
interaction (mouse, keyboard) should also be supported.
In other words, we want to present scripts with an execution
environment that very much resembles that of a web browser. Of
course, our environment is only a small subset of what a browser
provides; i.e. we don't provide a full DOM API, only what is
needed to run "self-contained" Context2D scripts (i.e. scripts
that don't depend on other parts of the DOM document).
Our "Context2D-browser" is set up through the following steps:
\list
\li Create an Environment.
\li Create a Context2D, and a QContext2DCanvas widget to render it.
\li Add the canvas object to the environment; this will enable
scripts to obtain a reference to it.
\li Evaluate scripts in the environment.
\endlist
Once a script has been evaluated, the application handles any
timer events and input events that occur subsequently
(i.e. forwards events to their associated script targets).
\section1 The Context2D Class
The "heart" of this example is the Context2D C++ class that implements
the drawing API. Its interface is defined in terms of properties
and slots. Note that this class isn't tied to Qt Script in any
way.
\snippet script/context2d/context2d.h 0
The properties define various aspects of the Context2D
configuration.
\snippet script/context2d/context2d.h 1
The slots define the operations that can be performed.
\snippet script/context2d/context2d.h 2
The changed() signal is emitted when the contents of the drawing
area has changed, so that clients associated with the Context2D
object (i.e. the canvas widget that renders it) are notified.
\section2 Implementation
Conveniently enough, the concepts, data structures and operations
of the Context2D API map more or less directly to Qt's painting
API. Conceptually, all we have to do is initialize a QPainter
according to the Context2D properties, and use functions like
QPainter::strokePath() to do the painting. Painting is done on a
QImage.
\snippet script/context2d/context2d.cpp 0
The property accessors and most of the slots manipulate the
internal Context2D state in some way. For the \c{lineCap}
property, Context2D uses a string representation; we therefore
have to map it from/to a Qt::PenCapStyle. The \c{lineJoin}
property is handled in the same fashion. All the property setters
also set a \e{dirty flag} for the property; this is used to
decide which aspects of the QPainter that need to be updated
before doing the next painting operation.
\snippet script/context2d/context2d.cpp 3
The implementation of the \c{fillStyle} property is interesting,
since the value can be either a string or a \c{CanvasGradient}.
We handle this by having the property be of type QVariant,
and check the actual type of the value to see how to handle the
write.
\snippet script/context2d/context2d.cpp 1
Context2D does not have a concept of a paint event; painting
operations can happen at any time. We would like to be efficient,
and not have to call QPainter::begin() and QPainter::end() for
every painting operation, since typically many painting operations
will follow in quick succession. The implementations of the
painting operations use a helper function, beginPainting(), that
activates the QPainter if it isn't active already, and updates
the state of the QPainter (brush, pen, etc.) so that it reflects
the current Context2D state.
\snippet script/context2d/context2d.cpp 2
The implementation of each painting operation ends by calling
scheduleChange(), which will post a zero-timer event if one is
not already pending. When the application returns to the event
loop later (presumably after all the drawing operations have
finished), the timer will trigger, QPainter::end() will be
called, and the changed() signal is emitted with the new
image as argument. The net effect is that there will typically
be only a single (QPainter::begin(), QPainter::end()) pair
executed for the full sequence of painting operations.
\section1 The Canvas Widget
\snippet script/context2d/qcontext2dcanvas.h 0
The QContext2DCanvas class provides a widget that renders
the contents of a Context2D object. It also provides a
minimal scripting API, most notably the getContext() function.
\snippet script/context2d/qcontext2dcanvas.cpp 3
The constructor connects to the changed() signal of the
Context2D object, so that the widget can update itself
when it needs to do so. Mouse tracking is enabled so that
mouse move events will be received even when no mouse
buttons are depressed.
\snippet script/context2d/qcontext2dcanvas.cpp 0
The getContext() function asks the environment to wrap the
Context2D object; the resulting proxy object makes the
Context2D API available to scripts.
\snippet script/context2d/qcontext2dcanvas.cpp 1
The paintEvent() function simply paints the contents that
was last received from the Context2D object.
\snippet script/context2d/qcontext2dcanvas.cpp 2
The canvas widget reimplements mouse and key event handlers, and
forwards these events to the scripting environment. The
environment will take care of delivering the event to the proper
script target, if any.
\section1 The Environment
\snippet script/context2d/environment.h 0
The Environment class provides a scripting environment where a
Canvas C++ object can be registered, looked up by ID (name),
and where scripts can be evaluated. The environment has a
\c{document} property, just like the scripting environment of a
web browser, so that scripts can call
\c{document.getElementById()} to obtain a reference to a canvas.
\snippet script/context2d/environment.h 1
The Environment class provides the timer attributes of the DOM
Window Object interface. This enables us to support scripts that
do animation, for example.
\snippet script/context2d/environment.h 2
The scriptError() signal is emitted when evaluation of a script
causes a script exception. For example, if a mouse press handler
or timeout handler causes an exception, the environment's client(s)
will be notified of this and can report the error.
\snippet script/context2d/environment.cpp 0
The constructor initializes the environment. First it creates
the QScriptEngine that will be used to evaluate scripts. It
creates the Document object that provides the getElementById()
function. Note that the QScriptEngine::ExcludeSuperClassContents
flag is specified to avoid the wrapper objects from exposing properties
and methods inherited from QObject. Next, the environment wraps
a pointer to \e{itself}; this is to prepare for setting this object
as the script engine's Global Object. The properties of the standard
Global Object are copied, so that these will also be available in
our custom Global Object. We also create two self-references to the
object; again, this is to provide a minimal level of compabilitity
with the scripting environment that web browsers provide.
\snippet script/context2d/environment.cpp 5
The addCanvas() function adds the given canvas to the list of
registered canvas objects. The canvasByName() function looks up
a canvas by QObject::objectName(). This function is used to
implement the \c{document.getElementById()} script function.
\snippet script/context2d/environment.cpp 1
The setInterval() and clearInterval() implementations use a QHash
to map from timer ID to the QScriptValue that holds the expression
to evaluate when the timer is triggered. A helper function,
maybeEmitScriptError(), is called after invoking the script handler;
it will emit the scriptError() signal if the script engine has an
uncaught exception.
\snippet script/context2d/environment.cpp 2
The toWrapper() functions creates a QScriptValue that wraps the
given QObject. Note that the QScriptEngine::PreferExistingWrapperObject
flag is specified; this guarantees that a single, unique wrapper
object will be returned, even if toWrapper() is called several times
with the same argument. This is important, since it is possible that
a script can set new properties on the resulting wrapper object (e.g.
event handlers like \c{onmousedown}), and we want these to persist.
\snippet script/context2d/environment.cpp 3
The handleEvent() function determines if there exists a handler
for the given event in the environment, and if so, invokes that
handler. Since the script expects a DOM event, the Qt C++ event
must be converted to a DOM event before it is passed to the
script. This mapping is relatively straightforward, but again,
we only implement a subset of the full DOM API; just enough to
get most scripts to work.
\snippet script/context2d/environment.cpp 4
The newFakeDomEvent() function is a helper function that creates
a new script object and initializes it with default values for
the attributes defined in the DOM Event and DOM UIEvent
interfaces.
\snippet script/context2d/environment.h 3
The Document class defines two slots that become available to
scripts: getElementById() and getElementsByTagName().
When the tag name is "canvas", getElementsByTagName() will
return a list of all canvas objects that are registered in
the environment.
\section1 The Application Window
\snippet script/context2d/window.cpp 0
The Window constructor creates an Environment object and
connects to its scriptError() signal. It then creates a
Context2D object, and a QContext2DCanvas widget to hold it.
The canvas widget is given the name \c{tutorial}, and added to the
environment; scripts can access the canvas by e.g.
\c{document.getElementById('tutorial')}.
\snippet script/context2d/window.cpp 1
The window contains a list widget that is populated with
available scripts (read from a \c{scripts/} folder).
\snippet script/context2d/window.cpp 2
When an item is selected, the corresponding script is
evaluated in the environment.
\snippet script/context2d/window.cpp 3
When the "Run in Debugger" button is clicked, the Qt Script debugger will
automatically be invoked when the first statement of the script is
reached. This enables the user to inspect the scripting environment and
control further execution of the script; e.g. he can single-step through
the script and/or set breakpoints. It is also possible to enter script
statements in the debugger's console widget, e.g. to perform custom
Context2D drawing operations, interactively.
\snippet script/context2d/window.cpp 4
If the evaluation of a script causes an uncaught exception, the Qt Script
debugger will automatically be invoked; this enables the user to get an
idea of what went wrong.
*/

View File

@ -0,0 +1,166 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "domimage.h"
#include <QVariant>
#include <qscriptcontext.h>
QScriptValue DomImage::s_self;
DomImage::DomImage()
{
}
int DomImage::width() const
{
return m_image.width();
}
int DomImage::height() const
{
return m_image.height();
}
QString DomImage::src() const
{
return m_src;
}
void DomImage::setSrc(const QString &src)
{
m_src = src;
m_image = QImage(m_src);
}
QString DomImage::name() const
{
return m_src;
}
static QScriptValue Image(QScriptContext *context, QScriptEngine *env)
{
QScriptValue val = context->thisObject();
DomImage *image = new DomImage();
QScriptValue klass = env->newVariant(QVariant::fromValue(image));
klass.setPrototype(DomImage::s_self);
return klass;
}
static QScriptValue width(QScriptContext *context, QScriptEngine *)
{
QScriptValue val = context->thisObject();
DomImage *image = qvariant_cast<DomImage*> (val.toVariant());
if (image)
return image->width();
return 0;
}
static QScriptValue height(QScriptContext *context, QScriptEngine *)
{
QScriptValue val = context->thisObject();
DomImage *image = qvariant_cast<DomImage*> (val.toVariant());
if (image)
return image->height();
return 0;
}
static QScriptValue setSrc(QScriptContext *context, QScriptEngine *env)
{
QScriptValue val = context->thisObject();
QString src = context->argument(0).toString();
DomImage *image = qvariant_cast<DomImage*> (val.toVariant());
if (image)
image->setSrc(src);
return env->undefinedValue();
}
static QScriptValue name(QScriptContext *context, QScriptEngine *)
{
QScriptValue val = context->thisObject();
DomImage *image = qvariant_cast<DomImage*> (val.toVariant());
if (image)
return image->name();
return QString();
}
void DomImage::setup(QScriptEngine *e)
{
qRegisterMetaType<DomImage>();
e->globalObject().setProperty("Image",
e->newFunction(::Image, 0));
s_self = e->newObject();
s_self.setProperty("setSrc", e->newFunction(&::setSrc, 1));
s_self.setProperty("width", e->newFunction(&::width));
s_self.setProperty("height", e->newFunction(&::height));
s_self.setProperty("name", e->newFunction(&::name));
e->setDefaultPrototype(qMetaTypeId<DomImage>(), s_self);
}

View File

@ -0,0 +1,96 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef DOMIMAGE_H
#define DOMIMAGE_H
#include <QPixmap>
#include <QImage>
#include <QMetaType>
#include <qscriptengine.h>
class DomImage
{
public:
DomImage();
static void setup(QScriptEngine *e);
int width() const;
int height() const;
QString src() const;
void setSrc(const QString &src);
QString name() const;
static QScriptValue s_self;
const QImage &image() const
{
return m_image;
}
private:
QImage m_image;
QString m_src;
//attribute boolean isMap;
//attribute DOMString longDesc;
//attribute DOMString useMap;
//attribute DOMString align;
//attribute DOMString alt;
//attribute DOMString border;
//attribute long vspace;
//attribute long hspace;
};
Q_DECLARE_METATYPE(DomImage)
Q_DECLARE_METATYPE(DomImage*)
#endif

View File

@ -0,0 +1,587 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "environment.h"
#include "qcontext2dcanvas.h"
#include "context2d.h"
#include <QScriptValueIterator>
#include <QDateTime>
struct FakeDomEvent
{
enum KeyCodes {
DOM_VK_UNDEFINED = 0x0,
DOM_VK_RIGHT_ALT = 0x12,
DOM_VK_LEFT_ALT = 0x12,
DOM_VK_LEFT_CONTROL = 0x11,
DOM_VK_RIGHT_CONTROL = 0x11,
DOM_VK_LEFT_SHIFT = 0x10,
DOM_VK_RIGHT_SHIFT = 0x10,
DOM_VK_META = 0x9D,
DOM_VK_BACK_SPACE = 0x08,
DOM_VK_CAPS_LOCK = 0x14,
DOM_VK_DELETE = 0x7F,
DOM_VK_END = 0x23,
DOM_VK_ENTER = 0x0D,
DOM_VK_ESCAPE = 0x1B,
DOM_VK_HOME = 0x24,
DOM_VK_NUM_LOCK = 0x90,
DOM_VK_PAUSE = 0x13,
DOM_VK_PRINTSCREEN = 0x9A,
DOM_VK_SCROLL_LOCK = 0x91,
DOM_VK_SPACE = 0x20,
DOM_VK_TAB = 0x09,
DOM_VK_LEFT = 0x25,
DOM_VK_RIGHT = 0x27,
DOM_VK_UP = 0x26,
DOM_VK_DOWN = 0x28,
DOM_VK_PAGE_DOWN = 0x22,
DOM_VK_PAGE_UP = 0x21,
DOM_VK_F1 = 0x70,
DOM_VK_F2 = 0x71,
DOM_VK_F3 = 0x72,
DOM_VK_F4 = 0x73,
DOM_VK_F5 = 0x74,
DOM_VK_F6 = 0x75,
DOM_VK_F7 = 0x76,
DOM_VK_F8 = 0x77,
DOM_VK_F9 = 0x78,
DOM_VK_F10 = 0x79,
DOM_VK_F11 = 0x7A,
DOM_VK_F12 = 0x7B,
DOM_VK_F13 = 0xF000,
DOM_VK_F14 = 0xF001,
DOM_VK_F15 = 0xF002,
DOM_VK_F16 = 0xF003,
DOM_VK_F17 = 0xF004,
DOM_VK_F18 = 0xF005,
DOM_VK_F19 = 0xF006,
DOM_VK_F20 = 0xF007,
DOM_VK_F21 = 0xF008,
DOM_VK_F22 = 0xF009,
DOM_VK_F23 = 0xF00A,
DOM_VK_F24 = 0xF00B
};
static int qtToDomKey(int keyCode);
};
int FakeDomEvent::qtToDomKey(int keyCode)
{
switch (keyCode) {
case Qt::Key_Backspace:
return DOM_VK_BACK_SPACE;
case Qt::Key_Enter:
return DOM_VK_ENTER;
case Qt::Key_Return:
return DOM_VK_ENTER;
case Qt::Key_NumLock:
return DOM_VK_NUM_LOCK;
case Qt::Key_Alt:
return DOM_VK_RIGHT_ALT;
case Qt::Key_Control:
return DOM_VK_LEFT_CONTROL;
case Qt::Key_Shift:
return DOM_VK_LEFT_SHIFT;
case Qt::Key_Meta:
return DOM_VK_META;
case Qt::Key_CapsLock:
return DOM_VK_CAPS_LOCK;
case Qt::Key_Delete:
return DOM_VK_DELETE;
case Qt::Key_End:
return DOM_VK_END;
case Qt::Key_Escape:
return DOM_VK_ESCAPE;
case Qt::Key_Home:
return DOM_VK_HOME;
case Qt::Key_Pause:
return DOM_VK_PAUSE;
case Qt::Key_Print:
return DOM_VK_PRINTSCREEN;
case Qt::Key_ScrollLock:
return DOM_VK_SCROLL_LOCK;
case Qt::Key_Left:
return DOM_VK_LEFT;
case Qt::Key_Right:
return DOM_VK_RIGHT;
case Qt::Key_Up:
return DOM_VK_UP;
case Qt::Key_Down:
return DOM_VK_DOWN;
case Qt::Key_PageDown:
return DOM_VK_PAGE_DOWN;
case Qt::Key_PageUp:
return DOM_VK_PAGE_UP;
case Qt::Key_F1:
return DOM_VK_F1;
case Qt::Key_F2:
return DOM_VK_F2;
case Qt::Key_F3:
return DOM_VK_F3;
case Qt::Key_F4:
return DOM_VK_F4;
case Qt::Key_F5:
return DOM_VK_F5;
case Qt::Key_F6:
return DOM_VK_F6;
case Qt::Key_F7:
return DOM_VK_F7;
case Qt::Key_F8:
return DOM_VK_F8;
case Qt::Key_F9:
return DOM_VK_F9;
case Qt::Key_F10:
return DOM_VK_F10;
case Qt::Key_F11:
return DOM_VK_F11;
case Qt::Key_F12:
return DOM_VK_F12;
case Qt::Key_F13:
return DOM_VK_F13;
case Qt::Key_F14:
return DOM_VK_F14;
case Qt::Key_F15:
return DOM_VK_F15;
case Qt::Key_F16:
return DOM_VK_F16;
case Qt::Key_F17:
return DOM_VK_F17;
case Qt::Key_F18:
return DOM_VK_F18;
case Qt::Key_F19:
return DOM_VK_F19;
case Qt::Key_F20:
return DOM_VK_F20;
case Qt::Key_F21:
return DOM_VK_F21;
case Qt::Key_F22:
return DOM_VK_F22;
case Qt::Key_F23:
return DOM_VK_F23;
case Qt::Key_F24:
return DOM_VK_F24;
}
return keyCode;
}
//! [0]
Environment::Environment(QObject *parent)
: QObject(parent)
{
m_engine = new QScriptEngine(this);
m_document = m_engine->newQObject(
new Document(this), QScriptEngine::QtOwnership,
QScriptEngine::ExcludeSuperClassContents);
CanvasGradientPrototype::setup(m_engine);
m_originalGlobalObject = m_engine->globalObject();
reset();
}
//! [0]
Environment::~Environment()
{
}
QScriptEngine *Environment::engine() const
{
return m_engine;
}
QScriptValue Environment::document() const
{
return m_document;
}
int Environment::setTimeout(const QScriptValue &expression, int delay)
{
if (expression.isString() || expression.isFunction()) {
int timerId = startTimer(delay);
m_timeoutHash.insert(timerId, expression);
return timerId;
}
return -1;
}
void Environment::clearTimeout(int timerId)
{
killTimer(timerId);
m_timeoutHash.remove(timerId);
}
//! [1]
int Environment::setInterval(const QScriptValue &expression, int delay)
{
if (expression.isString() || expression.isFunction()) {
int timerId = startTimer(delay);
m_intervalHash.insert(timerId, expression);
return timerId;
}
return -1;
}
void Environment::clearInterval(int timerId)
{
killTimer(timerId);
m_intervalHash.remove(timerId);
}
void Environment::timerEvent(QTimerEvent *event)
{
int id = event->timerId();
QScriptValue expression = m_intervalHash.value(id);
if (!expression.isValid()) {
expression = m_timeoutHash.value(id);
if (expression.isValid())
killTimer(id);
}
if (expression.isString()) {
evaluate(expression.toString());
} else if (expression.isFunction()) {
expression.call();
}
maybeEmitScriptError();
}
//! [1]
//! [5]
void Environment::addCanvas(QContext2DCanvas *canvas)
{
m_canvases.append(canvas);
}
QContext2DCanvas *Environment::canvasByName(const QString &name) const
{
for (int i = 0; i < m_canvases.size(); ++i) {
QContext2DCanvas *canvas = m_canvases.at(i);
if (canvas->objectName() == name)
return canvas;
}
return 0;
}
//! [5]
QList<QContext2DCanvas*> Environment::canvases() const
{
return m_canvases;
}
void Environment::reset()
{
if (m_engine->isEvaluating())
m_engine->abortEvaluation();
{
QHash<int, QScriptValue>::const_iterator it;
for (it = m_intervalHash.constBegin(); it != m_intervalHash.constEnd(); ++it)
killTimer(it.key());
m_intervalHash.clear();
for (it = m_timeoutHash.constBegin(); it != m_timeoutHash.constEnd(); ++it)
killTimer(it.key());
m_timeoutHash.clear();
}
for (int i = 0; i < m_canvases.size(); ++i)
m_canvases.at(i)->reset();
QScriptValue self = m_engine->newQObject(
this, QScriptEngine::QtOwnership,
QScriptEngine::ExcludeSuperClassContents);
{
QScriptValueIterator it(m_originalGlobalObject);
while (it.hasNext()) {
it.next();
self.setProperty(it.scriptName(), it.value(), it.flags());
}
}
self.setProperty("self", self);
self.setProperty("window", self);
QScriptValue navigator = m_engine->newObject();
navigator.setProperty("appCodeName", "context2d");
navigator.setProperty("appMinorVersion", 1);
navigator.setProperty("appVersion", 1);
navigator.setProperty("browserLanguage", "en_US");
navigator.setProperty("cookieEnabled", false);
navigator.setProperty("cpuClass", "i686");
navigator.setProperty("onLine", false);
navigator.setProperty("platform", "bogus OS");
navigator.setProperty("systemLanguage", "en_US");
navigator.setProperty("userAgent", "Context2D/1.1");
navigator.setProperty("userLanguage", "en_US");
self.setProperty("navigator", navigator);
m_engine->setGlobalObject(self);
m_engine->collectGarbage();
}
QScriptValue Environment::evaluate(const QString &code, const QString &fileName)
{
return m_engine->evaluate(code, fileName);
}
bool Environment::hasIntervalTimers() const
{
return !m_intervalHash.isEmpty();
}
// This is used by the Context2D Qt Script benchmark.
void Environment::triggerTimers()
{
for (int x = 0; x < 2; ++x) {
QList<int> timerIds = x ? m_intervalHash.keys() : m_timeoutHash.keys();
for (int i = 0; i < timerIds.size(); ++i) {
QTimerEvent fakeEvent(timerIds.at(i));
timerEvent(&fakeEvent);
}
}
}
//! [2]
QScriptValue Environment::toWrapper(QObject *object)
{
return m_engine->newQObject(object, QScriptEngine::QtOwnership,
QScriptEngine::PreferExistingWrapperObject
| QScriptEngine::ExcludeSuperClassContents);
}
//! [2]
//! [3]
void Environment::handleEvent(QContext2DCanvas *canvas, QMouseEvent *e)
{
QString type;
switch (e->type()) {
case QEvent::MouseButtonPress:
type = "mousedown"; break;
case QEvent::MouseButtonRelease:
type = "mouseup"; break;
case QEvent::MouseMove:
type = "mousemove"; break;
default: break;
}
if (type.isEmpty())
return;
QScriptValue handlerObject;
QScriptValue handler = eventHandler(canvas, type, &handlerObject);
if (!handler.isFunction())
return;
QScriptValue scriptEvent = newFakeDomEvent(type, toWrapper(canvas));
// MouseEvent
scriptEvent.setProperty("screenX", e->globalX(), QScriptValue::ReadOnly);
scriptEvent.setProperty("screenY", e->globalY(), QScriptValue::ReadOnly);
scriptEvent.setProperty("clientX", e->x(), QScriptValue::ReadOnly);
scriptEvent.setProperty("clientY", e->y(), QScriptValue::ReadOnly);
scriptEvent.setProperty("layerX", e->x(), QScriptValue::ReadOnly);
scriptEvent.setProperty("layerY", e->y(), QScriptValue::ReadOnly);
scriptEvent.setProperty("pageX", e->x(), QScriptValue::ReadOnly);
scriptEvent.setProperty("pageY", e->y(), QScriptValue::ReadOnly);
scriptEvent.setProperty("altKey", (e->modifiers() & Qt::AltModifier) != 0,
QScriptValue::ReadOnly);
scriptEvent.setProperty("ctrlKey", (e->modifiers() & Qt::ControlModifier) != 0,
QScriptValue::ReadOnly);
scriptEvent.setProperty("metaKey", (e->modifiers() & Qt::MetaModifier) != 0,
QScriptValue::ReadOnly);
scriptEvent.setProperty("shiftKey", (e->modifiers() & Qt::ShiftModifier) != 0,
QScriptValue::ReadOnly);
int button = 0;
if (e->button() == Qt::RightButton)
button = 2;
else if (e->button() == Qt::MidButton)
button = 1;
scriptEvent.setProperty("button", button);
scriptEvent.setProperty("relatedTarget", m_engine->nullValue(),
QScriptValue::ReadOnly);
handler.call(handlerObject, QScriptValueList() << scriptEvent);
maybeEmitScriptError();
}
//! [3]
void Environment::handleEvent(QContext2DCanvas *canvas, QKeyEvent *e)
{
QString type;
switch (e->type()) {
case QEvent::KeyPress:
type = "keydown"; break;
case QEvent::KeyRelease:
type = "keyup"; break;
default: break;
}
if (type.isEmpty())
return;
QScriptValue handlerObject;
QScriptValue handler = eventHandler(canvas, type, &handlerObject);
if (!handler.isFunction())
return;
QScriptValue scriptEvent = newFakeDomEvent(type, toWrapper(canvas));
// KeyEvent
scriptEvent.setProperty("isChar", !e->text().isEmpty());
scriptEvent.setProperty("charCode", e->text());
scriptEvent.setProperty("keyCode", FakeDomEvent::qtToDomKey(e->key()));
scriptEvent.setProperty("which", e->key());
handler.call(handlerObject, QScriptValueList() << scriptEvent);
maybeEmitScriptError();
}
QScriptValue Environment::eventHandler(QContext2DCanvas *canvas, const QString &type,
QScriptValue *who)
{
QString handlerName = "on" + type;
QScriptValue obj = toWrapper(canvas);
QScriptValue handler = obj.property(handlerName);
if (!handler.isValid()) {
obj = m_document;
handler = obj.property(handlerName);
}
if (who && handler.isFunction())
*who = obj;
return handler;
}
//! [4]
QScriptValue Environment::newFakeDomEvent(const QString &type, const QScriptValue &target)
{
QScriptValue e = m_engine->newObject();
// Event
e.setProperty("type", type, QScriptValue::ReadOnly);
e.setProperty("bubbles", true, QScriptValue::ReadOnly);
e.setProperty("cancelable", false, QScriptValue::ReadOnly);
e.setProperty("target", target, QScriptValue::ReadOnly);
e.setProperty("currentTarget", target, QScriptValue::ReadOnly);
e.setProperty("eventPhase", 3); // bubbling
e.setProperty("timeStamp", static_cast<int>(QDateTime::currentDateTime().toSecsSinceEpoch()));
// UIEvent
e.setProperty("detail", 0, QScriptValue::ReadOnly);
e.setProperty("view", m_engine->globalObject(), QScriptValue::ReadOnly);
return e;
}
//! [4]
void Environment::maybeEmitScriptError()
{
if (m_engine->hasUncaughtException())
emit scriptError(m_engine->uncaughtException());
}
Document::Document(Environment *env)
: QObject(env)
{
}
Document::~Document()
{
}
QScriptValue Document::getElementById(const QString &id) const
{
Environment *env = qobject_cast<Environment*>(parent());
QContext2DCanvas *canvas = env->canvasByName(id);
if (!canvas)
return QScriptValue();
return env->toWrapper(canvas);
}
QScriptValue Document::getElementsByTagName(const QString &name) const
{
if (name != "canvas")
return QScriptValue();
Environment *env = qobject_cast<Environment*>(parent());
QList<QContext2DCanvas*> list = env->canvases();
QScriptValue result = env->engine()->newArray(list.size());
for (int i = 0; i < list.size(); ++i)
result.setProperty(i, env->toWrapper(list.at(i)));
return result;
}
void Document::addEventListener(const QString &type, const QScriptValue &listener,
bool useCapture)
{
Q_UNUSED(useCapture);
if (listener.isFunction()) {
Environment *env = qobject_cast<Environment*>(parent());
QScriptValue self = env->toWrapper(this);
self.setProperty("on" + type, listener);
}
}
QColor colorFromString(const QString &name);
CanvasGradientPrototype::CanvasGradientPrototype(QObject *parent)
: QObject(parent)
{
}
void CanvasGradientPrototype::addColorStop(qreal offset, const QString &color)
{
CanvasGradient *self = qscriptvalue_cast<CanvasGradient*>(thisObject());
if (!self || (self->value.type() == QGradient::NoGradient))
return;
self->value.setColorAt(offset, colorFromString(color));
}
void CanvasGradientPrototype::setup(QScriptEngine *engine)
{
CanvasGradientPrototype *proto = new CanvasGradientPrototype();
engine->setDefaultPrototype(qMetaTypeId<CanvasGradient>(),
engine->newQObject(proto, QScriptEngine::ScriptOwnership,
QScriptEngine::ExcludeSuperClassContents));
}

View File

@ -0,0 +1,156 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
#include <qobject.h>
#include <qlist.h>
#include <qhash.h>
#include <QTimerEvent>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QScriptEngine>
#include <QScriptable>
class QContext2DCanvas;
//! [0]
class Environment : public QObject
{
Q_OBJECT
Q_PROPERTY(QScriptValue document READ document)
public:
Environment(QObject *parent = 0);
~Environment();
QScriptValue document() const;
void addCanvas(QContext2DCanvas *canvas);
QContext2DCanvas *canvasByName(const QString &name) const;
QList<QContext2DCanvas*> canvases() const;
QScriptValue evaluate(const QString &code,
const QString &fileName = QString());
QScriptValue toWrapper(QObject *object);
void handleEvent(QContext2DCanvas *canvas, QMouseEvent *e);
void handleEvent(QContext2DCanvas *canvas, QKeyEvent *e);
void reset();
//! [0]
QScriptEngine *engine() const;
bool hasIntervalTimers() const;
void triggerTimers();
//! [1]
public slots:
int setInterval(const QScriptValue &expression, int delay);
void clearInterval(int timerId);
int setTimeout(const QScriptValue &expression, int delay);
void clearTimeout(int timerId);
//! [1]
//! [2]
signals:
void scriptError(const QScriptValue &error);
//! [2]
protected:
void timerEvent(QTimerEvent *event);
private:
QScriptValue eventHandler(QContext2DCanvas *canvas,
const QString &type, QScriptValue *who);
QScriptValue newFakeDomEvent(const QString &type,
const QScriptValue &target);
void maybeEmitScriptError();
QScriptEngine *m_engine;
QScriptValue m_originalGlobalObject;
QScriptValue m_document;
QList<QContext2DCanvas*> m_canvases;
QHash<int, QScriptValue> m_intervalHash;
QHash<int, QScriptValue> m_timeoutHash;
};
//! [3]
class Document : public QObject
{
Q_OBJECT
public:
Document(Environment *env);
~Document();
public slots:
QScriptValue getElementById(const QString &id) const;
QScriptValue getElementsByTagName(const QString &name) const;
// EventTarget
void addEventListener(const QString &type, const QScriptValue &listener,
bool useCapture);
};
//! [3]
class CanvasGradientPrototype : public QObject, public QScriptable
{
Q_OBJECT
protected:
CanvasGradientPrototype(QObject *parent = 0);
public:
static void setup(QScriptEngine *engine);
public slots:
void addColorStop(qreal offset, const QString &color);
};
#endif

View File

@ -0,0 +1,73 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "window.h"
#include <QApplication>
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(context2d);
QApplication app(argc, argv);
Window win;
bool smallScreen = QApplication::arguments().contains("-small-screen");
#if defined(Q_WS_MAEMO_5)
win.showMaximized();
#else
if (!smallScreen) {
win.show();
} else {
win.showFullScreen();
}
#endif
return app.exec();
}

View File

@ -0,0 +1,152 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qcontext2dcanvas.h"
#include "context2d.h"
#include "environment.h"
#include "domimage.h"
#include <QPainter>
#include <QPaintEvent>
//! [3]
QContext2DCanvas::QContext2DCanvas(Context2D *context, Environment *env, QWidget *parent)
: QWidget(parent), m_context(context), m_env(env)
{
QObject::connect(context, SIGNAL(changed(QImage)), this, SLOT(contentsChanged(QImage)));
setMouseTracking(true);
}
//! [3]
QContext2DCanvas::~QContext2DCanvas()
{
}
Context2D *QContext2DCanvas::context() const
{
return m_context;
}
//! [0]
QScriptValue QContext2DCanvas::getContext(const QString &str)
{
if (str != "2d")
return QScriptValue();
return m_env->toWrapper(m_context);
}
//! [0]
//! [1]
void QContext2DCanvas::contentsChanged(const QImage &image)
{
m_image = image;
update();
}
void QContext2DCanvas::paintEvent(QPaintEvent *e)
{
QPainter p(this);
p.setClipRect(e->rect());
p.drawImage(0, 0, m_image);
}
//! [1]
//! [2]
void QContext2DCanvas::mouseMoveEvent(QMouseEvent *e)
{
m_env->handleEvent(this, e);
}
void QContext2DCanvas::mousePressEvent(QMouseEvent *e)
{
m_env->handleEvent(this, e);
}
void QContext2DCanvas::mouseReleaseEvent(QMouseEvent *e)
{
m_env->handleEvent(this, e);
}
void QContext2DCanvas::keyPressEvent(QKeyEvent *e)
{
m_env->handleEvent(this, e);
}
void QContext2DCanvas::keyReleaseEvent(QKeyEvent *e)
{
m_env->handleEvent(this, e);
}
//! [2]
void QContext2DCanvas::resizeEvent(QResizeEvent *e)
{
m_context->setSize(e->size().width(), e->size().height());
}
void QContext2DCanvas::resize(int width, int height)
{
QWidget::resize(width, height);
}
void QContext2DCanvas::reset()
{
m_context->reset();
}
void QContext2DCanvas::addEventListener(const QString &type, const QScriptValue &listener,
bool useCapture)
{
Q_UNUSED(useCapture);
if (listener.isFunction()) {
QScriptValue self = m_env->toWrapper(this);
self.setProperty("on" + type, listener);
}
}

View File

@ -0,0 +1,107 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QCONTEXT2DCANVAS_H
#define QCONTEXT2DCANVAS_H
#include <qscriptengine.h>
#include <qscriptcontext.h>
#include <qscriptvalue.h>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QPaintEvent;
class QResizeEvent;
class QMouseEvent;
class QKeyEvent;
QT_END_NAMESPACE
class Environment;
class Context2D;
//! [0]
class QContext2DCanvas : public QWidget
{
Q_OBJECT
public:
QContext2DCanvas(Context2D *context, Environment *env, QWidget *parent = 0);
~QContext2DCanvas();
Context2D *context() const;
void reset();
public slots:
QScriptValue getContext(const QString &str);
void resize(int width, int height);
// EventTarget
void addEventListener(const QString &type, const QScriptValue &listener,
bool useCapture);
protected:
virtual void paintEvent(QPaintEvent *e);
virtual void mouseMoveEvent(QMouseEvent *e);
virtual void mousePressEvent(QMouseEvent *e);
virtual void mouseReleaseEvent(QMouseEvent *e);
virtual void keyPressEvent(QKeyEvent *e);
virtual void keyReleaseEvent(QKeyEvent *e);
virtual void resizeEvent(QResizeEvent *e);
private slots:
void contentsChanged(const QImage &image);
//! [0]
private:
Context2D *m_context;
Environment *m_env;
QImage m_image;
};
#endif

View File

@ -0,0 +1,21 @@
var ctx = document.getElementById('tutorial').getContext('2d');
// draw background
ctx.fillStyle = '#FD0';
ctx.fillRect(0,0,75,75);
ctx.fillStyle = '#6C0';
ctx.fillRect(75,0,75,75);
ctx.fillStyle = '#09F';
ctx.fillRect(0,75,75,75);
ctx.fillStyle = '#F30';
ctx.fillRect(75,75,75,75);
ctx.fillStyle = '#FFF';
// set transparency value
ctx.globalAlpha = 0.2;
// Draw semi transparent circles
for (i=0;i<7;i++){
ctx.beginPath();
ctx.arc(75,75,10+10*i,0,Math.PI*2,true);
ctx.fill();
}

View File

@ -0,0 +1,30 @@
var canvas = document.getElementById('tutorial');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
// Draw shapes
for (i=0;i<4;i++){
for(j=0;j<3;j++){
ctx.beginPath();
var x = 25+j*50; // x coordinate
var y = 25+i*50; // y coordinate
var radius = 20; // Arc radius
var startAngle = 0; // Starting point on circle
var endAngle = Math.PI+(Math.PI*j)/2; // End point on circle
var clockwise = i%2==0 ? false : true; // clockwise or anticlockwise
ctx.arc(x,y,radius,startAngle,endAngle, clockwise);
if (i>1){
ctx.fill();
} else {
ctx.stroke();
}
}
}
}

View File

@ -0,0 +1,26 @@
function drawShape() {
// get the canvas element using the DOM
var canvas = document.getElementById('tutorial');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
// Draw shapes
ctx.beginPath();
ctx.moveTo(75,40);
ctx.bezierCurveTo(75,37,70,25,50,25);
ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
ctx.bezierCurveTo(20,80,40,102,75,120);
ctx.bezierCurveTo(110,102,130,80,130,62.5);
ctx.bezierCurveTo(130,62.5,130,25,100,25);
ctx.bezierCurveTo(85,25,75,37,75,40);
ctx.fill();
ctx.globalAlpha = 0.5;
}
}
drawShape();

View File

@ -0,0 +1,99 @@
function init(){
clock();
setInterval('clock()',1000);
}
function clock(){
var now = new Date();
var ctx = document.getElementById('tutorial').getContext('2d');
ctx.save();
ctx.clearRect(0,0,150,150);
ctx.translate(75,75);
ctx.scale(0.4,0.4);
ctx.rotate(-Math.PI/2);
ctx.strokeStyle = "black";
ctx.fillStyle = "white";
ctx.lineWidth = 8;
ctx.lineCap = "round";
// Hour marks
ctx.save();
ctx.beginPath();
for (i=0;i<12;i++){
ctx.rotate(Math.PI/6);
ctx.moveTo(100,0);
ctx.lineTo(120,0);
}
ctx.stroke();
ctx.restore();
// Minute marks
ctx.save();
ctx.lineWidth = 5;
ctx.beginPath();
for (i=0;i<60;i++){
if (i%5!=0) {
ctx.moveTo(117,0);
ctx.lineTo(120,0);
}
ctx.rotate(Math.PI/30);
}
ctx.stroke();
ctx.restore();
var sec = now.getSeconds();
var min = now.getMinutes();
var hr = now.getHours();
hr = hr>=12 ? hr-12 : hr;
ctx.fillStyle = "black";
// write Hours
ctx.save();
ctx.rotate( hr*(Math.PI/6) + (Math.PI/360)*min + (Math.PI/21600)*sec )
ctx.lineWidth = 14;
ctx.beginPath();
ctx.moveTo(-20,0);
ctx.lineTo(80,0);
ctx.stroke();
ctx.restore();
// write Minutes
ctx.save();
ctx.rotate( (Math.PI/30)*min + (Math.PI/1800)*sec )
ctx.lineWidth = 10;
ctx.beginPath();
ctx.moveTo(-28,0);
ctx.lineTo(112,0);
ctx.stroke();
ctx.restore();
// Write seconds
ctx.save();
ctx.rotate(sec * Math.PI/30);
ctx.strokeStyle = "#D40000";
ctx.fillStyle = "#D40000";
ctx.lineWidth = 6;
ctx.beginPath();
ctx.moveTo(-30,0);
ctx.lineTo(83,0);
ctx.stroke();
ctx.beginPath();
ctx.arc(0,0,10,0,Math.PI*2,true);
ctx.fill();
ctx.beginPath();
ctx.arc(95,0,10,0,Math.PI*2,true);
ctx.stroke();
ctx.fillStyle = "#555";
ctx.arc(0,0,3,0,Math.PI*2,true);
ctx.fill();
ctx.restore();
ctx.beginPath();
ctx.lineWidth = 14;
ctx.strokeStyle = '#325FA2';
ctx.arc(0,0,142,0,Math.PI*2,true);
ctx.stroke();
ctx.restore();
}
init();

View File

@ -0,0 +1,8 @@
var ctx = document.getElementById('tutorial').getContext('2d');
for (i=0;i<6;i++){
for (j=0;j<6;j++){
ctx.fillStyle = 'rgb(' + Math.floor(255-42.5*i) + ',' +
Math.floor(255-42.5*j) + ',0)';
ctx.fillRect(j*25,i*25,25,25);
}
}

View File

@ -0,0 +1,20 @@
var ctx = document.getElementById('tutorial').getContext('2d');
// Create gradients
var lingrad = ctx.createLinearGradient(0,0,0,150);
lingrad.addColorStop(0, '#00ABEB');
lingrad.addColorStop(0.5, '#fff');
lingrad.addColorStop(0.5, '#66CC00');
lingrad.addColorStop(1, '#fff');
var lingrad2 = ctx.createLinearGradient(0,50,0,95);
lingrad2.addColorStop(0.5, '#000');
lingrad2.addColorStop(1, 'rgba(0,0,0,0)');
// assign gradients to fill and stroke styles
ctx.fillStyle = lingrad;
ctx.strokeStyle = lingrad2;
// draw shapes
ctx.fillRect(10,10,130,130);
ctx.strokeRect(50,50,50,50);

View File

@ -0,0 +1,24 @@
var ctx = document.getElementById('tutorial').getContext('2d');
var lineCap = ['butt','round','square'];
// Draw guides
ctx.save();
ctx.strokeStyle = '#09f';
ctx.beginPath();
ctx.moveTo(10,10);
ctx.lineTo(140,10);
ctx.moveTo(10,140);
ctx.lineTo(140,140);
ctx.stroke();
// Draw lines
ctx.strokeStyle = 'black';
for (i=0;i<lineCap.length;i++){
ctx.lineWidth = 15;
ctx.lineCap = lineCap[i];
ctx.beginPath();
ctx.moveTo(25+i*50,10);
ctx.lineTo(25+i*50,140);
ctx.stroke();
}
ctx.restore();

View File

@ -0,0 +1,10 @@
var ctx = document.getElementById('tutorial').getContext('2d');
ctx.save();
for (i=0;i<10;i++){
ctx.lineWidth = 1+i;
ctx.beginPath();
ctx.moveTo(5+i*14,5);
ctx.lineTo(5+i*14,140);
ctx.stroke();
}
ctx.restore();

View File

@ -0,0 +1,20 @@
var canvas = document.getElementById('tutorial');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
// Draw shapes
ctx.beginPath();
ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle
ctx.moveTo(110,75);
ctx.arc(75,75,35,0,Math.PI,false); // Mouth
ctx.moveTo(65,65);
ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye
ctx.moveTo(95,65);
ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye
ctx.stroke();
}

View File

@ -0,0 +1,24 @@
var canvas = document.getElementById('tutorial');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
// Filled triangle
ctx.beginPath();
ctx.moveTo(25,25);
ctx.lineTo(105,25);
ctx.lineTo(25,105);
ctx.fill();
// Stroked triangle
ctx.beginPath();
ctx.moveTo(125,125);
ctx.lineTo(125,45);
ctx.lineTo(45,125);
ctx.closePath();
ctx.stroke();
}

View File

@ -0,0 +1,83 @@
function roundedRect(ctx,x,y,width,height,radius){
ctx.beginPath();
ctx.moveTo(x,y+radius);
ctx.lineTo(x,y+height-radius);
ctx.quadraticCurveTo(x,y+height,x+radius,y+height);
ctx.lineTo(x+width-radius,y+height);
ctx.quadraticCurveTo(x+width,y+height,x+width,y+height-radius);
ctx.lineTo(x+width,y+radius);
ctx.quadraticCurveTo(x+width,y,x+width-radius,y);
ctx.lineTo(x+radius,y);
ctx.quadraticCurveTo(x,y,x,y+radius);
ctx.stroke();
}
var canvas = document.getElementById('tutorial');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
// Draw shapes
roundedRect(ctx,12,12,150,150,15);
roundedRect(ctx,19,19,150,150,9);
roundedRect(ctx,53,53,49,33,10);
roundedRect(ctx,53,119,49,16,6);
roundedRect(ctx,135,53,49,33,10);
roundedRect(ctx,135,119,25,49,10);
// Character 1
ctx.beginPath();
ctx.arc(37,37,13,Math.PI/7,-Math.PI/7,false);
ctx.lineTo(34,37);
ctx.fill();
// blocks
for(i=0;i<8;i++){
ctx.fillRect(51+i*16,35,4,4);
}
for(i=0;i<6;i++){
ctx.fillRect(115,51+i*16,4,4);
}
for(i=0;i<8;i++){
ctx.fillRect(51+i*16,99,4,4);
}
// character 2
ctx.beginPath();
ctx.moveTo(83,116);
ctx.lineTo(83,102);
ctx.bezierCurveTo(83,94,89,88,97,88);
ctx.bezierCurveTo(105,88,111,94,111,102);
ctx.lineTo(111,116);
ctx.lineTo(106.333,111.333);
ctx.lineTo(101.666,116);
ctx.lineTo(97,111.333);
ctx.lineTo(92.333,116);
ctx.lineTo(87.666,111.333);
ctx.lineTo(83,116);
ctx.fill();
ctx.fillStyle = "white";
ctx.beginPath();
ctx.moveTo(91,96);
ctx.bezierCurveTo(88,96,87,99,87,101);
ctx.bezierCurveTo(87,103,88,106,91,106);
ctx.bezierCurveTo(94,106,95,103,95,101);
ctx.bezierCurveTo(95,99,94,96,91,96);
ctx.moveTo(103,96);
ctx.bezierCurveTo(100,96,99,99,99,101);
ctx.bezierCurveTo(99,103,100,106,103,106);
ctx.bezierCurveTo(106,106,107,103,107,101);
ctx.bezierCurveTo(107,99,106,96,103,96);
ctx.fill();
ctx.fillStyle = "black";
ctx.beginPath();
ctx.arc(101,102,2,0,Math.PI*2,true);
ctx.fill();
ctx.beginPath();
ctx.arc(89,102,2,0,Math.PI*2,true);
ctx.fill();
}

View File

@ -0,0 +1,58 @@
var counter = 0;
var PIXEL_SIZE = 4;
var temp_1 = 0;
function init()
{
setInterval('render()',50);
}
function dist(a, b, c, d)
{
return Math.sqrt((a - c) * (a - c) + (b - d) * (b - d));
}
function render()
{
var canvas = document.getElementById('tutorial');
canvas.resize(128, 128);
var ctx = canvas.getContext('2d');
ctx.save();
var time = counter * 5;
for( y = 0; y < 128; y+=PIXEL_SIZE) {
for( x = 0 ; x < 128; x+=PIXEL_SIZE) {
var temp_val = Math.floor(Math.sin(dist(x + time, y, 128.0, 128.0) / 8.0)
+ Math.sin(dist(x, y, 64.0, 64.0) / 8.0)
+ Math.sin(dist(x, y + time / 7, 192.0, 64) / 7.0)
+ Math.sin(dist(x, y, 192.0, 100.0) / 8.0));
var temp_col = Math.floor((2 + temp_val) * 50);
var rand_red = temp_col * 3;
var rand_green = temp_col ;
var rand_blue = 128 - temp_col;
ctx.fillStyle = "rgb("+rand_red+","+rand_green+","+rand_blue+")";
ctx.fillRect(x,y,PIXEL_SIZE,PIXEL_SIZE);
}
}
ctx.restore();
counter++;
}
init();

View File

@ -0,0 +1,235 @@
// globals
playarea_canvas = document.getElementById('tutorial');
playarea_canvas.resize(320,200);
playarea = playarea_canvas.getContext('2d');
//p1_scr = document.getElementById('p1_scr');
//p2_scr = document.getElementById('p2_scr');
//status_msg = document.getElementById('status');
//debug = document.getElementById('debug');
ball_direction = 0;
up = -1;
down = 1;
//key codes
key_up = 38;
key_down = 40;
key_W = 87;
key_S = 83;
key_pause = 32;
speed = 2; //controls the speed of the ball
paddle_inc = 10; //how many pixels paddle can move in either direction
pause = false;
player_1 = 0; //player IDs
player_2 = 1;
player_1_scr = 0; //player scores
player_2_scr = 0;
player_1_direction = null; //null = no movement whatsoever
player_2_direction = null;
pa = new Array();
divider = new Array();
paddle_1 = new Array();
paddle_2 = new Array();
ball = new Array();
function sleep(numberMillis)
{
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
function init()
{
pa['width'] = 150;
pa['height'] = 140;
pa['player_margin'] = 10; //area behind player paddles
pa['foreground'] = "#FFFFFF";
pa['background'] = "#000000";
divider['pos'] = pa['width']/2;
divider['width'] = 4;
paddle_1['width'] = 8;
paddle_1['height'] = 64;
paddle_1['x'] = pa['player_margin'];
paddle_1['y'] = (pa['height'] /2 ) - (paddle_1['height'] / 2);
paddle_2['width'] = 8;
paddle_2['height'] = 64;
paddle_2['x'] = (pa['width'] - pa['player_margin'] - paddle_2['width']);
paddle_2['y'] = (pa['height'] /2 ) - (paddle_2['height'] / 2);
ball['width'] = 10;
ball['height'] = 10;
ball['x'] = (pa['width']/2) - (ball['width'] / 2);
ball['y'] = (pa['height']/2) - (ball['height'] / 2);
ball_direction = Math.random() * 360; //initialize ball direction, which is determined by angle, at random
speed = 2;
}
function renderPlayarea()
{
playarea.beginPath();
playarea.clearRect(0,0,pa['width'],pa['height']);
playarea.fillStyle = pa['background'];
playarea.strokeStyle = pa['foreground'];
playarea.fillRect(0,0, pa['width'], pa['height']);
//move paddles
if(player_1_direction != null)
{
if(player_1_direction == up)
paddle_1['y'] = paddle_1['y'] - paddle_inc;
else
paddle_1['y'] = paddle_1['y'] + paddle_inc;
}
if(player_2_direction != null)
{
if(player_2_direction == up)
paddle_2['y'] = paddle_2['y'] - paddle_inc;
else
paddle_2['y'] = paddle_2['y'] + paddle_inc;
}
playarea.rect(paddle_1['x'],paddle_1['y'],paddle_1['width'],paddle_1['height']);
playarea.rect(paddle_2['x'],paddle_2['y'],paddle_2['width'],paddle_2['height']);
//move ball
playarea.rect(ball['x'], ball['y'], ball['width'], ball['height']);
ball['x'] = ball['x'] + Math.cos((ball_direction)*Math.PI/180) * speed;
ball['y'] = ball['y'] + Math.sin((ball_direction)*Math.PI/180) * speed;
playarea.fillStyle = pa['foreground'];
playarea.fill();
playarea.beginPath();
//redraw divider
playarea.lineWidth = divider['width'];
playarea.lineTo(divider['pos'], 0);
playarea.lineTo(divider['pos'], pa['height'] = 200);
playarea.lineWidth = 1;
playarea.stroke();
playarea.closePath();
}
function testCollisions()
{
//make sure paddles don't go beyond play area
if(((paddle_1['y'] <= 0) && (player_1_direction == up)) || ((paddle_1['y'] >= (pa['height'] - paddle_1['height'])) && (player_1_direction == down)))
player_1_direction = null;
if(((paddle_2['y'] <= 0) && (player_2_direction == up)) || ((paddle_2['y'] >= (pa['height'] - paddle_2['height'])) && (player_2_direction == down)))
player_2_direction = null;
//check to see if ball went beyond paddles, and if so, score accordingly and reset playarea
if(ball['x'] <= 0)
{
setScore(player_2);
init()
sleep(1000);
}
if(ball['x'] >= (pa['width'] - ball['width']))
{
setScore(player_1);
init();
sleep(1000);
}
//check to see if ball hit top or bottom wall. if so, change direction
if((ball['y'] >= (pa['height'] - ball['height'])) || ball['y'] <= 0)
ball_direction = -ball_direction;
//check to see if the ball hit a paddle, and if so, change ball angle dependant on where it hit the paddle
if((ball['x'] <= (paddle_1['x'] + paddle_1['width'])) && (ball['y'] >= paddle_1['y']) && (ball['y'] <= (paddle_1['y'] + paddle_1['height'])))
{
ball_direction = -ball_direction/2;
speed += .5;
}
if(((ball['x'] + ball['width']) >= paddle_2['x']) && (ball['y'] >= paddle_2['y']) && (ball['y'] <= (paddle_2['y'] + paddle_2['height'])))
{
ball_direction = (180+ball_direction)/2;
speed += .5;
}
}
function setScore(p)
{
if(p == player_1)
{
player_1_scr++;
//p1_scr.firstChild.nodeValue = player_1_scr;
}
if(p == player_2)
{
player_2_scr++;
//p2_scr.firstChild.nodeValue = player_2_scr;
}
}
//handle input
document.onkeydown = function(ev)
{
switch(ev.keyCode)
{
case key_W:
player_1_direction = up;
break;
case key_S:
player_1_direction = down;
break;
case key_up:
player_2_direction = up;
break;
case key_down:
player_2_direction = down;
break;
}
}
document.onkeyup = function(ev)
{
switch(ev.keyCode)
{
case key_W:
case key_S:
player_1_direction = null;
break;
case key_up:
case key_down:
player_2_direction = null;
break;
case key_pause:
if(pause == false)
{
clearInterval(game);
//status_msg.style.visibility = "visible";
pause = true;
}
else
{
game = setInterval(main, 25);
//status_msg.style.visibility = "hidden";
pause = false;
}
break;
}
}
function main()
{
testCollisions();
renderPlayarea();
}
init();
game = setInterval(main, 25);

View File

@ -0,0 +1,21 @@
var canvas = document.getElementById('tutorial');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
// Draw shapes
ctx.beginPath();
ctx.moveTo(75,25);
ctx.quadraticCurveTo(25,25,25,62.5);
ctx.quadraticCurveTo(25,100,50,100);
ctx.quadraticCurveTo(50,120,30,125);
ctx.quadraticCurveTo(60,120,65,100);
ctx.quadraticCurveTo(125,100,125,62.5);
ctx.quadraticCurveTo(125,25,75,25);
ctx.stroke();
}

View File

@ -0,0 +1,19 @@
var ctx = document.getElementById('tutorial').getContext('2d');
// Draw background
ctx.fillStyle = 'rgb(255,221,0)';
ctx.fillRect(0,0,150,37.5);
ctx.fillStyle = 'rgb(102,204,0)';
ctx.fillRect(0,37.5,150,37.5);
ctx.fillStyle = 'rgb(0,153,255)';
ctx.fillRect(0,75,150,37.5);
ctx.fillStyle = 'rgb(255,51,0)';
ctx.fillRect(0,112.5,150,37.5);
// Draw semi transparent rectangles
for (i=0;i<10;i++){
ctx.fillStyle = 'rgba(255,255,255,'+(i+1)/10+')';
for (j=0;j<4;j++){
ctx.fillRect(5+i*14,5+j*37.5,14,27.5)
}
}

View File

@ -0,0 +1,16 @@
var ctx = document.getElementById('tutorial').getContext('2d');
ctx.translate(75,75);
for (i=1;i<6;i++){ // Loop through rings (from inside to out)
ctx.save();
ctx.fillStyle = 'rgb('+(51*i)+','+(255-51*i)+',255)';
for (j=0;j<i*6;j++){ // draw individual dots
ctx.rotate(Math.PI*2/(i*6));
ctx.beginPath();
ctx.arc(0,i*12.5,5,0,Math.PI*2,true);
ctx.fill();
}
ctx.restore();
}

View File

@ -0,0 +1,67 @@
var ctx = document.getElementById('tutorial').getContext('2d');
ctx.strokeStyle = "#fc0";
ctx.lineWidth = 1.5;
ctx.fillRect(0,0,300,300);
// Uniform scaling
ctx.save()
ctx.translate(50,50);
drawSpirograph(ctx,22,6,5); // no scaling
ctx.translate(100,0);
ctx.scale(0.75,0.75);
drawSpirograph(ctx,22,6,5);
ctx.translate(133.333,0);
ctx.scale(0.75,0.75);
drawSpirograph(ctx,22,6,5);
ctx.restore();
// Non uniform scaling (y direction)
ctx.strokeStyle = "#0cf";
ctx.save()
ctx.translate(50,150);
ctx.scale(1,0.75);
drawSpirograph(ctx,22,6,5);
ctx.translate(100,0);
ctx.scale(1,0.75);
drawSpirograph(ctx,22,6,5);
ctx.translate(100,0);
ctx.scale(1,0.75);
drawSpirograph(ctx,22,6,5);
ctx.restore();
// Non uniform scaling (x direction)
ctx.strokeStyle = "#cf0";
ctx.save()
ctx.translate(50,250);
ctx.scale(0.75,1);
drawSpirograph(ctx,22,6,5);
ctx.translate(133.333,0);
ctx.scale(0.75,1);
drawSpirograph(ctx,22,6,5);
ctx.translate(177.777,0);
ctx.scale(0.75,1);
drawSpirograph(ctx,22,6,5);
ctx.restore();
function drawSpirograph(ctx,R,r,O){
var x1 = R-O;
var y1 = 0;
var i = 1;
ctx.beginPath();
ctx.moveTo(x1,y1);
do {
if (i>20000) break;
var x2 = (R+r)*Math.cos(i*Math.PI/72) - (r+O)*Math.cos(((R+r)/r)*(i*Math.PI/72))
var y2 = (R+r)*Math.sin(i*Math.PI/72) - (r+O)*Math.sin(((R+r)/r)*(i*Math.PI/72))
ctx.lineTo(x2,y2);
x1 = x2;
y1 = y2;
i++;
} while (x2 != R-O && y2 != 0 );
ctx.stroke();
}

View File

@ -0,0 +1,10 @@
var ctx = document.getElementById('tutorial').getContext('2d');
for (i=0;i<6;i++){
for (j=0;j<6;j++){
ctx.strokeStyle = 'rgb(0,' + Math.floor(255-42.5*i) + ',' +
Math.floor(255-42.5*j) + ')';
ctx.beginPath();
ctx.arc(12.5+j*25,12.5+i*25,10,0,Math.PI*2,true);
ctx.stroke();
}
}

View File

@ -0,0 +1,29 @@
var ctx = document.getElementById('tutorial').getContext('2d');
ctx.fillRect(0,0,300,300);
for (var i=0;i<3;i++) {
for (var j=0;j<3;j++) {
ctx.save();
ctx.strokeStyle = "#9CFF00";
ctx.translate(50+j*100,50+i*100);
drawSpirograph(ctx,20*(j+2)/(j+1),-8*(i+3)/(i+1),10);
ctx.restore();
}
}
function drawSpirograph(ctx,R,r,O){
var x1 = R-O;
var y1 = 0;
var i = 1;
ctx.beginPath();
ctx.moveTo(x1,y1);
do {
if (i>20000) break;
var x2 = (R+r)*Math.cos(i*Math.PI/72) - (r+O)*Math.cos(((R+r)/r)*(i*Math.PI/72))
var y2 = (R+r)*Math.sin(i*Math.PI/72) - (r+O)*Math.sin(((R+r)/r)*(i*Math.PI/72))
ctx.lineTo(x2,y2);
x1 = x2;
y1 = y2;
i++;
} while (x2 != R-O && y2 != 0 );
ctx.stroke();
}

View File

@ -0,0 +1,190 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "window.h"
#include "environment.h"
#include "context2d.h"
#include "qcontext2dcanvas.h"
#include <QHBoxLayout>
#include <QListWidget>
#include <QDir>
#include <QMessageBox>
#ifndef QT_NO_SCRIPTTOOLS
#include <QAction>
#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
#include <QVBoxLayout>
#include <QScriptEngineDebugger>
#endif
static QString scriptsDir()
{
if (QFile::exists("./scripts"))
return "./scripts";
return ":/scripts";
}
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)
#ifndef QT_NO_SCRIPTTOOLS
, m_debugger(0), m_debugWindow(0)
#endif
{
m_env = new Environment(this);
QObject::connect(m_env, SIGNAL(scriptError(QScriptValue)),
this, SLOT(reportScriptError(QScriptValue)));
Context2D *context = new Context2D(this);
context->setSize(150, 150);
m_canvas = new QContext2DCanvas(context, m_env, this);
m_canvas->setFixedSize(context->size());
m_canvas->setObjectName("tutorial");
m_env->addCanvas(m_canvas);
//! [0]
#ifndef QT_NO_SCRIPTTOOLS
QVBoxLayout *vbox = new QVBoxLayout();
vbox->addWidget(m_canvas);
m_debugButton = new QPushButton(tr("Run in Debugger"));
connect(m_debugButton, SIGNAL(clicked()), this, SLOT(runInDebugger()));
vbox->addWidget(m_debugButton);
#endif
QHBoxLayout *hbox = new QHBoxLayout(this);
m_view = new QListWidget(this);
m_view->setEditTriggers(QAbstractItemView::NoEditTriggers);
hbox->addWidget(m_view);
#ifndef QT_NO_SCRIPTTOOLS
hbox->addLayout(vbox);
#else
hbox->addWidget(m_canvas);
#endif
//! [1]
QDir dir(scriptsDir());
QFileInfoList entries = dir.entryInfoList(QStringList() << "*.js");
for (int i = 0; i < entries.size(); ++i)
m_view->addItem(entries.at(i).fileName());
connect(m_view, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(selectScript(QListWidgetItem*)));
//! [1]
setWindowTitle(tr("Context 2D"));
}
//! [2]
void Window::selectScript(QListWidgetItem *item)
{
QString fileName = item->text();
runScript(fileName, /*debug=*/false);
}
//! [2]
void Window::reportScriptError(const QScriptValue &error)
{
QMessageBox::warning(this, tr("Context 2D"), tr("Line %0: %1")
.arg(error.property("lineNumber").toInt32())
.arg(error.toString()));
}
#ifndef QT_NO_SCRIPTTOOLS
//! [3]
void Window::runInDebugger()
{
QListWidgetItem *item = m_view->currentItem();
if (item) {
QString fileName = item->text();
runScript(fileName, /*debug=*/true);
}
}
//! [3]
#endif
//! [4]
void Window::runScript(const QString &fileName, bool debug)
{
QFile file(scriptsDir() + "/" + fileName);
file.open(QIODevice::ReadOnly);
QString contents = file.readAll();
file.close();
m_env->reset();
#ifndef QT_NO_SCRIPTTOOLS
if (debug) {
if (!m_debugger) {
m_debugger = new QScriptEngineDebugger(this);
m_debugWindow = m_debugger->standardWindow();
m_debugWindow->setWindowModality(Qt::ApplicationModal);
m_debugWindow->resize(1280, 704);
}
m_debugger->attachTo(m_env->engine());
m_debugger->action(QScriptEngineDebugger::InterruptAction)->trigger();
} else {
if (m_debugger)
m_debugger->detach();
}
#else
Q_UNUSED(debug);
#endif
QScriptValue ret = m_env->evaluate(contents, fileName);
#ifndef QT_NO_SCRIPTTOOLS
if (m_debugWindow)
m_debugWindow->hide();
#endif
if (ret.isError())
reportScriptError(ret);
}
//! [4]

View File

@ -0,0 +1,90 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef WINDOW_H
#define WINDOW_H
#include <QWidget>
class Environment;
class QContext2DCanvas;
QT_BEGIN_NAMESPACE
class QListWidget;
class QListWidgetItem;
class QMainWindow;
class QPushButton;
class QScriptValue;
class QScriptEngineDebugger;
QT_END_NAMESPACE
class Window : public QWidget
{
Q_OBJECT
public:
Window(QWidget *parent = 0);
private slots:
void selectScript(QListWidgetItem *item);
void reportScriptError(const QScriptValue &value);
#ifndef QT_NO_SCRIPTTOOLS
void runInDebugger();
#endif
private:
void runScript(const QString &fileName, bool debug);
QListWidget *m_view;
Environment *m_env;
QContext2DCanvas *m_canvas;
#ifndef QT_NO_SCRIPTTOOLS
QScriptEngineDebugger *m_debugger;
QPushButton *m_debugButton;
QMainWindow *m_debugWindow;
#endif
};
#endif // WINDOW_H

View File

@ -0,0 +1,319 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtScript/QScriptClassPropertyIterator>
#include <QtScript/QScriptContext>
#include <QtScript/QScriptEngine>
#include "bytearrayclass.h"
#include "bytearrayprototype.h"
#include <stdlib.h>
Q_DECLARE_METATYPE(QByteArray*)
Q_DECLARE_METATYPE(ByteArrayClass*)
class ByteArrayClassPropertyIterator : public QScriptClassPropertyIterator
{
public:
ByteArrayClassPropertyIterator(const QScriptValue &object);
~ByteArrayClassPropertyIterator();
bool hasNext() const;
void next();
bool hasPrevious() const;
void previous();
void toFront();
void toBack();
QScriptString name() const;
uint id() const;
private:
int m_index;
int m_last;
};
//! [0]
ByteArrayClass::ByteArrayClass(QScriptEngine *engine)
: QObject(engine), QScriptClass(engine)
{
qScriptRegisterMetaType<QByteArray>(engine, toScriptValue, fromScriptValue);
length = engine->toStringHandle(QLatin1String("length"));
proto = engine->newQObject(new ByteArrayPrototype(this),
QScriptEngine::QtOwnership,
QScriptEngine::SkipMethodsInEnumeration
| QScriptEngine::ExcludeSuperClassMethods
| QScriptEngine::ExcludeSuperClassProperties);
QScriptValue global = engine->globalObject();
proto.setPrototype(global.property("Object").property("prototype"));
ctor = engine->newFunction(construct, proto);
ctor.setData(engine->toScriptValue(this));
}
//! [0]
ByteArrayClass::~ByteArrayClass()
{
}
//! [3]
QScriptClass::QueryFlags ByteArrayClass::queryProperty(const QScriptValue &object,
const QScriptString &name,
QueryFlags flags, uint *id)
{
QByteArray *ba = qscriptvalue_cast<QByteArray*>(object.data());
if (!ba)
return {};
if (name == length) {
return flags;
} else {
bool isArrayIndex;
qint32 pos = name.toArrayIndex(&isArrayIndex);
if (!isArrayIndex)
return {};
*id = pos;
if ((flags & HandlesReadAccess) && (pos >= ba->size()))
flags &= ~HandlesReadAccess;
return flags;
}
}
//! [3]
//! [4]
QScriptValue ByteArrayClass::property(const QScriptValue &object,
const QScriptString &name, uint id)
{
QByteArray *ba = qscriptvalue_cast<QByteArray*>(object.data());
if (!ba)
return QScriptValue();
if (name == length) {
return ba->length();
} else {
qint32 pos = id;
if ((pos < 0) || (pos >= ba->size()))
return QScriptValue();
return uint(ba->at(pos)) & 255;
}
return QScriptValue();
}
//! [4]
//! [5]
void ByteArrayClass::setProperty(QScriptValue &object,
const QScriptString &name,
uint id, const QScriptValue &value)
{
QByteArray *ba = qscriptvalue_cast<QByteArray*>(object.data());
if (!ba)
return;
if (name == length) {
resize(*ba, value.toInt32());
} else {
qint32 pos = id;
if (pos < 0)
return;
if (ba->size() <= pos)
resize(*ba, pos + 1);
(*ba)[pos] = char(value.toInt32());
}
}
//! [5]
//! [6]
QScriptValue::PropertyFlags ByteArrayClass::propertyFlags(
const QScriptValue &/*object*/, const QScriptString &name, uint /*id*/)
{
if (name == length) {
return QScriptValue::Undeletable
| QScriptValue::SkipInEnumeration;
}
return QScriptValue::Undeletable;
}
//! [6]
//! [7]
QScriptClassPropertyIterator *ByteArrayClass::newIterator(const QScriptValue &object)
{
return new ByteArrayClassPropertyIterator(object);
}
//! [7]
QString ByteArrayClass::name() const
{
return QLatin1String("ByteArray");
}
QScriptValue ByteArrayClass::prototype() const
{
return proto;
}
QScriptValue ByteArrayClass::constructor()
{
return ctor;
}
//! [10]
QScriptValue ByteArrayClass::newInstance(int size)
{
engine()->reportAdditionalMemoryCost(size);
return newInstance(QByteArray(size, /*ch=*/0));
}
//! [10]
//! [1]
QScriptValue ByteArrayClass::newInstance(const QByteArray &ba)
{
QScriptValue data = engine()->newVariant(QVariant::fromValue(ba));
return engine()->newObject(this, data);
}
//! [1]
//! [2]
QScriptValue ByteArrayClass::construct(QScriptContext *ctx, QScriptEngine *)
{
ByteArrayClass *cls = qscriptvalue_cast<ByteArrayClass*>(ctx->callee().data());
if (!cls)
return QScriptValue();
QScriptValue arg = ctx->argument(0);
if (arg.instanceOf(ctx->callee()))
return cls->newInstance(qscriptvalue_cast<QByteArray>(arg));
int size = arg.toInt32();
return cls->newInstance(size);
}
//! [2]
QScriptValue ByteArrayClass::toScriptValue(QScriptEngine *eng, const QByteArray &ba)
{
QScriptValue ctor = eng->globalObject().property("ByteArray");
ByteArrayClass *cls = qscriptvalue_cast<ByteArrayClass*>(ctor.data());
if (!cls)
return eng->newVariant(QVariant::fromValue(ba));
return cls->newInstance(ba);
}
void ByteArrayClass::fromScriptValue(const QScriptValue &obj, QByteArray &ba)
{
ba = qvariant_cast<QByteArray>(obj.data().toVariant());
}
//! [9]
void ByteArrayClass::resize(QByteArray &ba, int newSize)
{
int oldSize = ba.size();
ba.resize(newSize);
if (newSize > oldSize)
engine()->reportAdditionalMemoryCost(newSize - oldSize);
}
//! [9]
ByteArrayClassPropertyIterator::ByteArrayClassPropertyIterator(const QScriptValue &object)
: QScriptClassPropertyIterator(object)
{
toFront();
}
ByteArrayClassPropertyIterator::~ByteArrayClassPropertyIterator()
{
}
//! [8]
bool ByteArrayClassPropertyIterator::hasNext() const
{
QByteArray *ba = qscriptvalue_cast<QByteArray*>(object().data());
return m_index < ba->size();
}
void ByteArrayClassPropertyIterator::next()
{
m_last = m_index;
++m_index;
}
bool ByteArrayClassPropertyIterator::hasPrevious() const
{
return (m_index > 0);
}
void ByteArrayClassPropertyIterator::previous()
{
--m_index;
m_last = m_index;
}
void ByteArrayClassPropertyIterator::toFront()
{
m_index = 0;
m_last = -1;
}
void ByteArrayClassPropertyIterator::toBack()
{
QByteArray *ba = qscriptvalue_cast<QByteArray*>(object().data());
m_index = ba->size();
m_last = -1;
}
QScriptString ByteArrayClassPropertyIterator::name() const
{
return object().engine()->toStringHandle(QString::number(m_last));
}
uint ByteArrayClassPropertyIterator::id() const
{
return m_last;
}
//! [8]

View File

@ -0,0 +1,106 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef BYTEARRAYCLASS_H
#define BYTEARRAYCLASS_H
#include <QtCore/QObject>
#include <QtScript/QScriptClass>
#include <QtScript/QScriptString>
QT_BEGIN_NAMESPACE
class QScriptContext;
QT_END_NAMESPACE
class ByteArrayClass : public QObject, public QScriptClass
{
Q_OBJECT
public:
ByteArrayClass(QScriptEngine *engine);
~ByteArrayClass();
QScriptValue constructor();
QScriptValue newInstance(int size = 0);
QScriptValue newInstance(const QByteArray &ba);
QueryFlags queryProperty(const QScriptValue &object,
const QScriptString &name,
QueryFlags flags, uint *id);
QScriptValue property(const QScriptValue &object,
const QScriptString &name, uint id);
void setProperty(QScriptValue &object, const QScriptString &name,
uint id, const QScriptValue &value);
QScriptValue::PropertyFlags propertyFlags(
const QScriptValue &object, const QScriptString &name, uint id);
QScriptClassPropertyIterator *newIterator(const QScriptValue &object);
QString name() const;
QScriptValue prototype() const;
private:
static QScriptValue construct(QScriptContext *ctx, QScriptEngine *eng);
static QScriptValue toScriptValue(QScriptEngine *eng, const QByteArray &ba);
static void fromScriptValue(const QScriptValue &obj, QByteArray &ba);
void resize(QByteArray &ba, int newSize);
QScriptString length;
QScriptValue proto;
QScriptValue ctor;
};
#endif

View File

@ -0,0 +1,6 @@
SOURCES += $$PWD/bytearrayclass.cpp \
$$PWD/bytearrayprototype.cpp
HEADERS += $$PWD/bytearrayclass.h \
$$PWD/bytearrayprototype.h
INCLUDEPATH += $$PWD

View File

@ -0,0 +1,145 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "bytearrayprototype.h"
#include <QtScript/QScriptEngine>
Q_DECLARE_METATYPE(QByteArray*)
ByteArrayPrototype::ByteArrayPrototype(QObject *parent)
: QObject(parent)
{
}
ByteArrayPrototype::~ByteArrayPrototype()
{
}
//! [0]
QByteArray *ByteArrayPrototype::thisByteArray() const
{
return qscriptvalue_cast<QByteArray*>(thisObject().data());
}
//! [0]
void ByteArrayPrototype::chop(int n)
{
thisByteArray()->chop(n);
}
bool ByteArrayPrototype::equals(const QByteArray &other)
{
return *thisByteArray() == other;
}
QByteArray ByteArrayPrototype::left(int len) const
{
return thisByteArray()->left(len);
}
//! [1]
QByteArray ByteArrayPrototype::mid(int pos, int len) const
{
return thisByteArray()->mid(pos, len);
}
QScriptValue ByteArrayPrototype::remove(int pos, int len)
{
thisByteArray()->remove(pos, len);
return thisObject();
}
//! [1]
QByteArray ByteArrayPrototype::right(int len) const
{
return thisByteArray()->right(len);
}
QByteArray ByteArrayPrototype::simplified() const
{
return thisByteArray()->simplified();
}
QByteArray ByteArrayPrototype::toBase64() const
{
return thisByteArray()->toBase64();
}
QByteArray ByteArrayPrototype::toLower() const
{
return thisByteArray()->toLower();
}
QByteArray ByteArrayPrototype::toUpper() const
{
return thisByteArray()->toUpper();
}
QByteArray ByteArrayPrototype::trimmed() const
{
return thisByteArray()->trimmed();
}
void ByteArrayPrototype::truncate(int pos)
{
thisByteArray()->truncate(pos);
}
QString ByteArrayPrototype::toLatin1String() const
{
return QString::fromLatin1(*thisByteArray());
}
//! [2]
QScriptValue ByteArrayPrototype::valueOf() const
{
return thisObject().data();
}
//! [2]

View File

@ -0,0 +1,89 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef BYTEARRAYPROTOTYPE_H
#define BYTEARRAYPROTOTYPE_H
#include <QtCore/QByteArray>
#include <QtCore/QObject>
#include <QtScript/QScriptable>
#include <QtScript/QScriptValue>
//! [0]
class ByteArrayPrototype : public QObject, public QScriptable
{
Q_OBJECT
public:
ByteArrayPrototype(QObject *parent = 0);
~ByteArrayPrototype();
public slots:
void chop(int n);
bool equals(const QByteArray &other);
QByteArray left(int len) const;
QByteArray mid(int pos, int len = -1) const;
QScriptValue remove(int pos, int len);
QByteArray right(int len) const;
QByteArray simplified() const;
QByteArray toBase64() const;
QByteArray toLower() const;
QByteArray toUpper() const;
QByteArray trimmed() const;
void truncate(int pos);
QString toLatin1String() const;
QScriptValue valueOf() const;
private:
QByteArray *thisByteArray() const;
};
//! [0]
#endif

View File

@ -0,0 +1,12 @@
QT = core script
win32: CONFIG += console
mac:CONFIG -= app_bundle
SOURCES += main.cpp
include(bytearrayclass.pri)
target.path = $$[QT_INSTALL_EXAMPLES]/script/customclass
INSTALLS += target
maemo5: CONFIG += qt_example

View File

@ -0,0 +1,85 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QCoreApplication>
#include <QtDebug>
#include <QtScript>
#include "bytearrayclass.h"
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QScriptEngine eng;
ByteArrayClass *baClass = new ByteArrayClass(&eng);
eng.globalObject().setProperty("ByteArray", baClass->constructor());
qDebug() << "ba = new ByteArray(4):" << eng.evaluate("ba = new ByteArray(4)").toString();
qDebug() << "ba instanceof ByteArray:" << eng.evaluate("ba instanceof ByteArray").toBool();
qDebug() << "ba.length:" << eng.evaluate("ba.length").toNumber();
qDebug() << "ba[1] = 123; ba[1]:" << eng.evaluate("ba[1] = 123; ba[1]").toNumber();
qDebug() << "ba[7] = 224; ba.length:" << eng.evaluate("ba[7] = 224; ba.length").toNumber();
qDebug() << "for-in loop:" << eng.evaluate("result = '';\n"
"for (var p in ba) {\n"
" if (result.length > 0)\n"
" result += ', ';\n"
" result += '(' + p + ',' + ba[p] + ')';\n"
"} result").toString();
qDebug() << "ba.toBase64():" << eng.evaluate("b64 = ba.toBase64()").toString();
qDebug() << "ba.toBase64().toLatin1String():" << eng.evaluate("b64.toLatin1String()").toString();
qDebug() << "ba.valueOf():" << eng.evaluate("ba.valueOf()").toString();
qDebug() << "ba.chop(2); ba.length:" << eng.evaluate("ba.chop(2); ba.length").toNumber();
qDebug() << "ba2 = new ByteArray(ba):" << eng.evaluate("ba2 = new ByteArray(ba)").toString();
qDebug() << "ba2.equals(ba):" << eng.evaluate("ba2.equals(ba)").toBool();
qDebug() << "ba2.equals(new ByteArray()):" << eng.evaluate("ba2.equals(new ByteArray())").toBool();
return 0;
}

View File

@ -0,0 +1,18 @@
//! [0]
listWidget.addItem("Red");
listWidget.addItem("Blue");
listWidget.addItem("Green");
listWidget.addItem("Cyan");
listWidget.addItem("Yellow");
listWidget.addItem("Purple");
listWidget.addItems(["Orange", "Gray"]);
//! [0]
//! [1]
listWidget.currentItemChanged.connect(
function(item)
{
listWidget.setBackgroundColor(item.text);
}
);
//! [1]

View File

@ -0,0 +1,9 @@
QT += widgets script
RESOURCES += defaultprototypes.qrc
SOURCES += main.cpp prototypes.cpp
HEADERS += prototypes.h
target.path = $$[QT_INSTALL_EXAMPLES]/script/defaultprototypes
INSTALLS += target
maemo5: CONFIG += qt_example

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/" >
<file>code.js</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -0,0 +1,124 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example script/defaultprototypes
\title Default Prototypes Example
This Qt Script example shows how to use default prototypes
to make a non-QObject-based type scriptable.
\image defaultprototypes-example.png
With QScriptEngine::setDefaultPrototype() you can specify
a Qt Script object that defines a scripting interface for
a C++ type; Qt Script operations on values of such types
will then be delegated to your prototype object. In this
example, a simple scripting interface for QListWidgetItem is
defined, so that the text of items can easily be accessed from
script code.
To define a scripting API for QListWidgetItem in terms of
Qt properties and slots, we subclass QObject and QScriptable.
\snippet script/defaultprototypes/prototypes.h 0
A single property, \c{text}, is defined, along with a slot,
\c{toString}.
\snippet script/defaultprototypes/prototypes.cpp 0
The implementation of the property accessors use
the qscriptvalue_cast() function to cast the script object
to a QListWidgetItem pointer. The normal C++ QListWidgetItem
API is then used to implement the desired functionality.
Although not shown here, it is possible to throw a script
exception from a prototype function; for example, you could throw
a TypeError exception if the qscriptvalue_cast() fails.
QListWidgetItems are usually added to a QListWidget. While
QListWidget is a QObject-based class, not all the functionality
needed for this example are present. We can solve this by creating
a default prototype for the QListWidget class as well. The
prototype will augment the functionality already provided by the
Qt Script QObject integration; i.e. if a property or slot is not
found in the QListWidget object itself, the prototype will be used
as a fallback.
\snippet script/defaultprototypes/prototypes.h 1
The additional slots will make it possible to add items to
a QListWidget from script code, and to set the background
color of the widget from a string.
\snippet script/defaultprototypes/prototypes.cpp 1
Again, we use qscriptvalue_cast() to cast the script object
to the relevant C++ type, in this case a QListWidget pointer.
The addItem() and addItems() functions simply forward their
arguments to the corresponding functions in the QListWidget
class. setBackgroundColor() gets the widget's palette, creates
a QColor from the given string argument and changes the palette
accordingly.
\snippet script/defaultprototypes/main.cpp 0
The relevant C++ types must be made known to Qt's meta type
system.
\snippet script/defaultprototypes/main.cpp 1
For each type that we want to associate a prototype object with,
we create an instance of the prototype class, pass it to
QScriptEngine::newQObject(), and then create the link between
the C++ type and the resulting script object by calling
QScriptEngine::setDefaultPrototype().
\snippet script/defaultprototypes/main.cpp 2
In this example, a single QListWidget object is added as
a global script variable, called \c{listWidget}. Script code
can add items to this widget by calling addItem() or addItems().
\snippet script/defaultprototypes/code.js 0
Script code can connect to signals of the QListWidget object;
signal handlers can use the interface defined in
the QListWidgetItem prototype to manipulate item arguments.
\snippet script/defaultprototypes/code.js 1
Not shown in this example is how to make QListWidgetItem
constructible from Qt Script code, i.e. to be able to
write "new QListWidgetItem()" in a script. In order to do
this, you have to define your own script constructor for
the type. The constructor would just be a factory function
that constructs a new C++ QListWidgetItem and returns it
back to the script. See QScriptEngine::newFunction() for more
information.
*/

View File

@ -0,0 +1,95 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtWidgets/QListWidgetItem>
#include <QtWidgets/QApplication>
#include <QtScript>
#include "prototypes.h"
//! [0]
Q_DECLARE_METATYPE(QListWidgetItem*)
Q_DECLARE_METATYPE(QListWidget*)
//! [0]
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(defaultprototypes);
QApplication app(argc, argv);
//! [1]
QScriptEngine engine;
ListWidgetItemPrototype lwiProto;
engine.setDefaultPrototype(qMetaTypeId<QListWidgetItem*>(),
engine.newQObject(&lwiProto));
ListWidgetPrototype lwProto;
engine.setDefaultPrototype(qMetaTypeId<QListWidget*>(),
engine.newQObject(&lwProto));
//! [1]
//! [2]
QListWidget listWidget;
engine.globalObject().setProperty("listWidget",
engine.newQObject(&listWidget));
//! [2]
QFile file(":/code.js");
file.open(QIODevice::ReadOnly);
QScriptValue result = engine.evaluate(file.readAll());
file.close();
if (engine.hasUncaughtException()) {
int lineNo = engine.uncaughtExceptionLineNumber();
qWarning() << "line" << lineNo << ":" << result.toString();
}
listWidget.show();
return app.exec();
}

View File

@ -0,0 +1,126 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "prototypes.h"
#include <QtWidgets/QListWidgetItem>
#include <QtWidgets/QListWidget>
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>
#include <QDebug>
Q_DECLARE_METATYPE(QListWidgetItem*)
Q_DECLARE_METATYPE(QListWidget*)
//! [0]
ListWidgetItemPrototype::ListWidgetItemPrototype(QObject *parent)
: QObject(parent)
{
}
QString ListWidgetItemPrototype::text() const
{
QListWidgetItem *item = qscriptvalue_cast<QListWidgetItem*>(thisObject());
if (item)
return item->text();
return QString();
}
void ListWidgetItemPrototype::setText(const QString &text)
{
QListWidgetItem *item = qscriptvalue_cast<QListWidgetItem*>(thisObject());
if (item)
item->setText(text);
}
QString ListWidgetItemPrototype::toString() const
{
return QString("ListWidgetItem(text = %0)").arg(text());
}
//! [0]
//! [1]
ListWidgetPrototype::ListWidgetPrototype(QObject *parent)
: QObject(parent)
{
}
void ListWidgetPrototype::addItem(const QString &text)
{
QListWidget *widget = qscriptvalue_cast<QListWidget*>(thisObject());
if (widget)
widget->addItem(text);
}
void ListWidgetPrototype::addItems(const QStringList &texts)
{
QListWidget *widget = qscriptvalue_cast<QListWidget*>(thisObject());
if (widget)
widget->addItems(texts);
}
void ListWidgetPrototype::setBackgroundColor(const QString &colorName)
{
QListWidget *widget = qscriptvalue_cast<QListWidget*>(thisObject());
if (widget) {
#ifdef Q_WS_MAEMO_5
QString style = QString("QListWidget::item {background-color: %1;}").arg(colorName);
style += "QListWidget::item {selection-color: black;}";
widget->setStyleSheet(style);
#else
QPalette palette = widget->palette();
QColor color(colorName);
palette.setBrush(QPalette::Base, color);
widget->setPalette(palette);
#endif
}
}
//! [1]

View File

@ -0,0 +1,87 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef PROTOTYPES_H
#define PROTOTYPES_H
#include <QtCore/QObject>
#include <QtScript/QScriptable>
//! [0]
class ListWidgetItemPrototype : public QObject, public QScriptable
{
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText)
public:
ListWidgetItemPrototype(QObject *parent = 0);
QString text() const;
void setText(const QString &text);
public slots:
QString toString() const;
};
//! [0]
//! [1]
class ListWidgetPrototype : public QObject, public QScriptable
{
Q_OBJECT
public:
ListWidgetPrototype(QObject *parent = 0);
public slots:
void addItem(const QString &text);
void addItems(const QStringList &texts);
void setBackgroundColor(const QString &colorName);
};
//! [1]
#endif

View File

@ -0,0 +1,128 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example script/helloscript
\title Hello Script Example
The Hello Script example shows the basic use of Qt Script: How to embed
a script engine into the application, how to evaluate a script, and how
to process the result of the evaluation. The example also shows how to
apply internationalization to scripts.
\snippet script/helloscript/main.cpp 0
The application will load the script file to evaluate from a resource, so
we first make sure that the resource is initialized.
\snippet script/helloscript/main.cpp 1
We attempt to load a translation, and install translation functions in the
script engine. How to produce a translation is explained later.
\snippet script/helloscript/main.cpp 2
A push button is created and exported to the script environment as a
global variable, \c button. Scripts will be able to access properties,
signals and slots of the button as properties of the \c button script
object; the script object acts as a proxy to the C++ button object.
\snippet script/helloscript/main.cpp 3
The contents of the script file are read.
\snippet script/helloscript/helloscript.js 0
The script sets the \c text (note that the qTr() function is used to allow
for translation) and \c styleSheet properties of the button, and calls the
button's \c show() slot.
\snippet script/helloscript/main.cpp 4
The script is evaluated. Note that the file name is passed as the
(optional) second parameter; this makes it possible for the script engine
to produce a meaningful backtrace if something goes wrong, and makes the
qTr() function be able to resolve the translations that are associated
with this script.
\snippet script/helloscript/main.cpp 5
If the result is an Error object (e.g. the script contained a syntax
error, or tried to call a function that doesn't exist), we obtain
the line number and string representation of the error and display
it in a message box.
\snippet script/helloscript/main.cpp 6
If the evaluation went well, the application event loop is entered.
\section1 Translating the Application
The Qt Script internalization support builds on what Qt already provides
for C++; see the \l{Hello tr() Example} for an introduction.
Since we haven't made the translation file \c helloscript_la.qm, the
source text is shown when we run the application ("Hello world!").
To generate the translation file, run \c lupdate as follows:
\code
lupdate helloscript.js -ts helloscript_la.ts
\endcode
You should now have a file \c helloscript_la.ts in the current
directory. Run \c linguist to edit the translation:
\code
linguist helloscript_la.ts
\endcode
You should now see the text "helloscript.js" in the top left pane.
Double-click it, then click on "Hello world!" and enter "Orbis, te
saluto!" in the \gui Translation pane (the middle right of the
window). Don't forget the exclamation mark!
Click the \gui Done checkbox and choose \gui File|Save from the
menu bar. The TS file will no longer contain
\snippet code/doc_src_examples_hellotr.qdoc 3
but instead will have
\snippet code/doc_src_examples_hellotr.qdoc 4
To see the application running in Latin, we have to generate a QM
file from the TS file. Generating a QM file can be achieved
either from within \e {Qt Linguist} (for a single TS file), or
by using the command line program \c lrelease which will produce one
QM file for each of the TS files listed in the project file.
Generate \c hellotr_la.qm from \c hellotr_la.ts by choosing
\gui File|Release from \e {Qt Linguist}'s menu bar and pressing
\gui Save in the file save dialog that pops up. Now run the \c helloscript
program again. This time the button will be labelled "Orbis, te
saluto!".
*/

View File

@ -0,0 +1,5 @@
//! [0]
button.text = qsTr('Hello World!');
button.styleSheet = 'font-style: italic';
button.show();
//! [0]

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