mirror of https://github.com/qt/qtgrpc.git
Add Qt Core and Qt Gui types as documented protobuf modules
Change-Id: I40225ddbb082babf109a4fafb4bf700bcc3acf30 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
9bc8f327bb
commit
2ed9177f22
|
|
@ -1,118 +0,0 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
|
||||
|
||||
/*!
|
||||
\module QtProtobufQtTypes
|
||||
\title Protobuf Qt types module
|
||||
\brief Provides support for using native Qt types in protobuf.
|
||||
|
||||
Qt::ProtobufQtCoreTypes, Qt::ProtobufQtGuiTypes are libraries with
|
||||
pre-defined protobuf messages designed to encapsulate a selection
|
||||
of Qt Core and Qt Gui types.
|
||||
|
||||
List of supported types:
|
||||
|
||||
\list QtCore
|
||||
\li QByteArray \note Type reflects the \e bytes protobuf type.
|
||||
\li QChar
|
||||
\li QDate
|
||||
\li QDateTime
|
||||
\li QPoint
|
||||
\li QPointF
|
||||
\li QRect
|
||||
\li QRectF
|
||||
\li QSize
|
||||
\li QSizeF
|
||||
\li QString \note Type reflects the \e string protobuf type.
|
||||
\li QTime
|
||||
\li QUrl
|
||||
\li QUuid
|
||||
\li QVersionNumber
|
||||
\endlist
|
||||
|
||||
\list QtGui
|
||||
\li QImage
|
||||
\li QMatrix4x4
|
||||
\li QQuaternion
|
||||
\li QRgba64
|
||||
\li QTransform
|
||||
\li QVector2D
|
||||
\li QVector3D
|
||||
\li QVector4D
|
||||
\endlist
|
||||
|
||||
\section1 Qt Core usage
|
||||
To enable QtCore types support add ProtobufQtCoreTypes as a dependency
|
||||
to your CMake project:
|
||||
\badcode
|
||||
...
|
||||
find_package(Qt REQUIRED COMPONENTS Protobuf ProtobufQtCoreTypes)
|
||||
... # After target creation
|
||||
target_link_libraries(${TARGET} PRIVATE Qt::ProtobufQtCoreTypes)
|
||||
\endcode
|
||||
|
||||
Before any serialization/deserialization of messages that use QtCore types
|
||||
as fields, call the registration method:
|
||||
\code
|
||||
// e.g. in main.cpp
|
||||
QtProtobuf::qRegisterProtobufQtCoreTypes();
|
||||
...
|
||||
\endcode
|
||||
|
||||
\section1 Qt Gui usage
|
||||
To enable QtGui types support add ProtobufQtGuiTypes as a dependency
|
||||
to your CMake project:
|
||||
\badcode
|
||||
...
|
||||
find_package(Qt REQUIRED COMPONENTS Protobuf ProtobufQtGuiTypes)
|
||||
... # After target creation
|
||||
target_link_libraries(${TARGET} PRIVATE Qt::ProtobufQtGuiTypes)
|
||||
\endcode
|
||||
|
||||
Before any serialization/deserialization of messages that use QtGui types
|
||||
as fields, call the registration method:
|
||||
\code
|
||||
// e.g. in main.cpp
|
||||
QtProtobuf::qRegisterProtobufQtGuiTypes();
|
||||
...
|
||||
\endcode
|
||||
|
||||
\section2 QImage serialization
|
||||
The ProtobufQtGuiTypes library provides possibility to work with QImage
|
||||
class. In common case the library converts all QImages into \c {PNG}
|
||||
extension. But if the QImage was created using
|
||||
\l {https://doc.qt.io/qt-6/qimage.html#Format-enum} a
|
||||
{floating point formats}, then conversion to \c {PNG} will lead
|
||||
to data loss. To prevent data loss the library automatically converts
|
||||
the QImage to \c {TIFF} extension, if it is supported by the system,
|
||||
otherwise converts to \c {PNG}.
|
||||
\note if you don't want to use \c{TIFF}, you need to convert the image
|
||||
explicitly into a non-floating point format.
|
||||
|
||||
All supported messages are described in special .proto files:
|
||||
|
||||
- QtCore.proto - describes Qt types from QtCore module
|
||||
- QtGui.proto - describes Qt types from QtGui module
|
||||
|
||||
These files are also useful if you would like to generate code for other
|
||||
languages or frameworks.
|
||||
|
||||
Import the required Qt types module in your interface .proto file,
|
||||
for example:
|
||||
\badcode
|
||||
syntax = "proto3";
|
||||
|
||||
package project.module.component;
|
||||
|
||||
import "QtCore/QtCore.proto";
|
||||
|
||||
message QUrlMessage {
|
||||
QtCore.QUrl url = 1;
|
||||
}
|
||||
\endcode
|
||||
|
||||
The QtProtobuf generator detects Qt types, supplied by the
|
||||
ProtobufQtCoreTypes and ProtobufQtGuiTypes packages, and
|
||||
uses them directly. This gives you flexibility to use these
|
||||
types without additional conversion.
|
||||
*/
|
||||
|
|
@ -17,3 +17,7 @@ qt_internal_add_protobuf_module(ProtobufQtCoreTypes
|
|||
PRIVATE_HEADER_FILTERS
|
||||
".*\\.qpb\\.h"
|
||||
)
|
||||
|
||||
qt_internal_add_docs(ProtobufQtCoreTypes
|
||||
doc/protobufqtcoretypes.qdocconf
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
|
||||
|
||||
project = QtProtobufQtCoreTypes
|
||||
description = Qt Protobuf Qt Core Types Reference Documentation
|
||||
version = $QT_VERSION
|
||||
qhp.projects = QtProtobufQtCoreTypes
|
||||
|
||||
qhp.QtProtobufQtCoreTypes.file = qtprotobufqtcoretypes.qhp
|
||||
qhp.QtProtobufQtCoreTypes.namespace = org.qt-project.qtprotobuf.$QT_VERSION_TAG
|
||||
qhp.QtProtobufQtCoreTypes.virtualFolder = qtprotobufqtcoretypes
|
||||
qhp.QtProtobufQtCoreTypes.indexRoot =
|
||||
|
||||
qhp.QtProtobufQtCoreTypes.subprojects = classes
|
||||
qhp.QtProtobufQtCoreTypes.subprojects.classes.title = C++ Classes
|
||||
qhp.QtProtobufQtCoreTypes.subprojects.classes.indexTitle = Protobuf Qt Core types module
|
||||
qhp.QtProtobufQtCoreTypes.subprojects.classes.selectors = class doc:headerfile
|
||||
qhp.QtProtobufQtCoreTypes.subprojects.classes.sortPages = true
|
||||
|
||||
depends += qtdoc qtcore qtprotobuf
|
||||
|
||||
{headerdirs,sourcedirs} += ..
|
||||
|
||||
navigation.cppclassespage = "Protobuf Qt Core types module"
|
||||
|
||||
# Fail the documentation build if there are more warnings than the limit
|
||||
warninglimit = 0
|
||||
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
|
||||
|
||||
/*!
|
||||
\module QtProtobufQtCoreTypes
|
||||
\modulestate Technical Preview
|
||||
\title Protobuf Qt Core types module
|
||||
\ingroup frameworks-technologies
|
||||
\qtcmakepackage ProtobufQtCoreTypes
|
||||
\qtvariable protobufqtcoretypes
|
||||
\since 6.6
|
||||
|
||||
\brief Provides support for using native Qt Core types in protobuf.
|
||||
|
||||
Qt::ProtobufQtCoreTypes is a library with pre-defined protobuf messages
|
||||
designed to encapsulate a selection of Qt Core types.
|
||||
|
||||
List of supported Qt Core types:
|
||||
\list
|
||||
\li QByteArray \note Type reflects the \e bytes protobuf type.
|
||||
\li QChar
|
||||
\li QDate
|
||||
\li QDateTime
|
||||
\li QPoint
|
||||
\li QPointF
|
||||
\li QRect
|
||||
\li QRectF
|
||||
\li QSize
|
||||
\li QSizeF
|
||||
\li QString \note Type reflects the \e string protobuf type.
|
||||
\li QTime
|
||||
\li QUrl
|
||||
\li QUuid
|
||||
\li QVersionNumber
|
||||
\endlist
|
||||
|
||||
\section1 Qt Core usage
|
||||
To enable Qt Core types support, add ProtobufQtCoreTypes as a dependency
|
||||
to your CMake project:
|
||||
\badcode
|
||||
...
|
||||
find_package(Qt REQUIRED COMPONENTS Protobuf ProtobufQtCoreTypes)
|
||||
... # After target creation
|
||||
target_link_libraries(${TARGET} PRIVATE Qt::ProtobufQtCoreTypes)
|
||||
\endcode
|
||||
|
||||
Before any serialization or deserialization of messages that use Qt Core
|
||||
types as fields, call the registration method:
|
||||
\code
|
||||
// e.g. in main.cpp
|
||||
QtProtobuf::qRegisterProtobufQtCoreTypes();
|
||||
...
|
||||
\endcode
|
||||
|
||||
All supported messages are described in a special .proto file,
|
||||
\e {QtCore.proto}, that describes Qt types from the Qt Core module.
|
||||
|
||||
You can also use the file to generate code for other
|
||||
languages or frameworks.
|
||||
|
||||
Import the required Qt Core types module in your interface .proto file.
|
||||
For example:
|
||||
\badcode
|
||||
syntax = "proto3";
|
||||
|
||||
package project.module.component;
|
||||
|
||||
import "QtCore/QtCore.proto";
|
||||
|
||||
message QUrlMessage {
|
||||
QtCore.QUrl url = 1;
|
||||
}
|
||||
\endcode
|
||||
|
||||
The QtProtobuf generator detects Qt Core types, supplied by the
|
||||
ProtobufQtCoreTypes package, and uses them directly. This gives
|
||||
you the flexibility to use these types without additional conversion.
|
||||
*/
|
||||
|
|
@ -18,3 +18,7 @@ qt_internal_add_protobuf_module(ProtobufQtGuiTypes
|
|||
PRIVATE_HEADER_FILTERS
|
||||
".*\\.qpb\\.h"
|
||||
)
|
||||
|
||||
qt_internal_add_docs(ProtobufQtGuiTypes
|
||||
doc/protobufqtguitypes.qdocconf
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
|
||||
|
||||
project = QtProtobufQtGuiTypes
|
||||
description = Qt Protobuf Qt GUI Types Reference Documentation
|
||||
version = $QT_VERSION
|
||||
|
||||
qhp.projects = QtProtobufQtGuiTypes
|
||||
qhp.QtProtobufQtGuiTypes.file = qtprotobufqtguitypes.qhp
|
||||
qhp.QtProtobufQtGuiTypes.namespace = org.qt-project.qtprotobuf.$QT_VERSION_TAG
|
||||
qhp.QtProtobufQtGuiTypes.virtualFolder = qtprotobufqtguitypes
|
||||
qhp.QtProtobufQtGuiTypes.indexRoot =
|
||||
|
||||
qhp.QtProtobufQtGuiTypes.subprojects = classes
|
||||
qhp.QtProtobufQtGuiTypes.subprojects.classes.title = C++ Classes
|
||||
qhp.QtProtobufQtGuiTypes.subprojects.classes.indexTitle = Protobuf Qt GUI types module
|
||||
qhp.QtProtobufQtGuiTypes.subprojects.classes.selectors = class doc:headerfile
|
||||
qhp.QtProtobufQtGuiTypes.subprojects.classes.sortPages = true
|
||||
|
||||
depends += qtdoc qtgui qtprotobuf
|
||||
|
||||
{headerdirs,sourcedirs} += ..
|
||||
|
||||
navigation.cppclassespage = "Protobuf Qt GUI types module"
|
||||
|
||||
# Fail the documentation build if there are more warnings than the limit
|
||||
warninglimit = 0
|
||||
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
|
||||
|
||||
/*!
|
||||
\module QtProtobufQtGuiTypes
|
||||
\modulestate Technical Preview
|
||||
\title Protobuf Qt GUI types module
|
||||
\ingroup frameworks-technologies
|
||||
\qtcmakepackage ProtobufQtGuiTypes
|
||||
\qtvariable protobufqtguitypes
|
||||
\since 6.6
|
||||
|
||||
\brief Provides support for using native Qt Gui types in protobuf.
|
||||
|
||||
Qt::ProtobufQtGuiTypes is a library with pre-defined protobuf messages
|
||||
designed to encapsulate a selection of Qt Gui types.
|
||||
|
||||
List of supported Qt Gui types:
|
||||
\list
|
||||
\li QImage
|
||||
\li QMatrix4x4
|
||||
\li QQuaternion
|
||||
\li QRgba64
|
||||
\li QTransform
|
||||
\li QVector2D
|
||||
\li QVector3D
|
||||
\li QVector4D
|
||||
\endlist
|
||||
|
||||
\section1 Qt GUI usage
|
||||
To enable Qt GUI types support, add ProtobufQtGuiTypes as a dependency
|
||||
to your CMake project:
|
||||
\badcode
|
||||
...
|
||||
find_package(Qt REQUIRED COMPONENTS Protobuf ProtobufQtGuiTypes)
|
||||
... # After target creation
|
||||
target_link_libraries(${TARGET} PRIVATE Qt::ProtobufQtGuiTypes)
|
||||
\endcode
|
||||
|
||||
Before any serialization or deserialization of messages that use Qt GUI
|
||||
types as fields, call the registration method:
|
||||
\code
|
||||
// e.g. in main.cpp
|
||||
QtProtobuf::qRegisterProtobufQtGuiTypes();
|
||||
...
|
||||
\endcode
|
||||
|
||||
All supported messages are described in a special .proto file,
|
||||
\e {QtGui.proto}, that describes Qt types from the Qt GUI module.
|
||||
|
||||
You can also use the file to generate code for other
|
||||
languages or frameworks.
|
||||
|
||||
Import the required Qt GUI types module in your interface .proto file
|
||||
For example:
|
||||
\badcode
|
||||
syntax = "proto3";
|
||||
|
||||
package project.module.component;
|
||||
|
||||
import "QtGui/QtGui.proto";
|
||||
|
||||
message QMatrix4x4Message {
|
||||
QtGui.QMatrix4x4 matrix = 1;
|
||||
}
|
||||
\endcode
|
||||
|
||||
The QtProtobuf generator detects Qt GUI types, supplied by the
|
||||
ProtobufQtGuiTypes package, and uses them directly. This gives
|
||||
you the flexibility to use these types without additional conversion.
|
||||
|
||||
\section2 QImage serialization
|
||||
The ProtobufQtGuiTypes library provides the possibility to work with the
|
||||
QImage class. Usually, the library converts all QImage objects in
|
||||
to \c PNG format. But if the QImage was created using
|
||||
\l {https://doc.qt.io/qt-6/qimage.html#Format-enum} a
|
||||
{floating point formats}, then conversion to \c PNG will lead
|
||||
to data loss. To prevent data loss, the library automatically converts
|
||||
the image file to \c TIFF format, if it is supported by the system,
|
||||
otherwise converts to \c PNG.
|
||||
\note if you don't want to use \c TIFF, you need to convert the image
|
||||
explicitly into a non-floating point format.
|
||||
*/
|
||||
Loading…
Reference in New Issue