From 7d4149e61fbb299e95968da22daa0818e30802b9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 14 Apr 2015 15:53:12 +0200 Subject: move ui loader interfaces to own module it's backwards to declare the interface as part of the designer library itself, as that obviously pulls in half of designer itself into custom widget plugins which should be perfectly usable from the stand-alone ui loader in uitools. also, designer isn't built for embedded systems, so the bundling needlessly limited the availability of widget plugins. so move the relevant headers into a separate include-only module. the designer module retains forwarding headers, as the old includes obviously need to continue working. [ChangeLog][UiTools] Custom widget plugins should now use QT+=uiplugin instead of QT+=designer. This makes them usable on embedded systems. Task-number: QTBUG-44724 Change-Id: I5535b10d2f095b257eeda9681f60b2f8c699f7d7 Reviewed-by: Friedemann Kleint --- .../containerextension/multipagewidgetplugin.h | 2 +- examples/designer/customwidgetplugin/analogclock.h | 2 +- .../customwidgetplugin/customwidgetplugin.h | 2 +- .../customwidgetplugin/customwidgetplugin.pro | 2 +- examples/designer/designer.pro | 3 - .../designer/taskmenuextension/tictactoeplugin.h | 2 +- .../designer/worldtimeclockplugin/worldtimeclock.h | 2 +- .../worldtimeclockplugin/worldtimeclockplugin.h | 2 +- .../worldtimeclockplugin/worldtimeclockplugin.pro | 2 +- examples/uitools/uitools.pro | 2 +- .../components/widgetbox/widgetboxtreewidget.cpp | 3 +- src/designer/src/designer/doc/qtdesigner.qdocconf | 2 + src/designer/src/lib/lib.pro | 3 +- src/designer/src/lib/shared/plugindialog.cpp | 3 +- src/designer/src/lib/shared/pluginmanager.cpp | 3 +- .../src/lib/shared/qdesigner_formbuilder.cpp | 4 +- src/designer/src/lib/shared/qsimpleresource.cpp | 3 +- src/designer/src/lib/shared/widgetdatabase.cpp | 3 +- src/designer/src/lib/shared/widgetfactory.cpp | 3 +- src/designer/src/lib/uilib/customwidget.h | 92 ------- src/designer/src/lib/uilib/customwidget.qdoc | 293 --------------------- src/designer/src/lib/uilib/formbuilder.cpp | 2 +- src/designer/src/lib/uilib/qdesignerexportwidget.h | 54 ---- src/designer/src/lib/uilib/uilib.pri | 3 +- .../src/plugins/activeqt/qaxwidgetplugin.h | 2 +- .../src/plugins/qquickwidget/qquickwidget_plugin.h | 2 +- .../src/plugins/qwebview/qwebview_plugin.h | 2 +- src/designer/src/src.pro | 3 + src/designer/src/uiplugin/customwidget.h | 92 +++++++ src/designer/src/uiplugin/customwidget.qdoc | 293 +++++++++++++++++++++ src/designer/src/uiplugin/qdesignerexportwidget.h | 54 ++++ src/designer/src/uiplugin/uiplugin.pro | 6 + src/designer/src/uitools/quiloader.cpp | 3 +- src/designer/src/uitools/uitools.pro | 5 + sync.profile | 10 + 35 files changed, 496 insertions(+), 468 deletions(-) delete mode 100644 src/designer/src/lib/uilib/customwidget.h delete mode 100644 src/designer/src/lib/uilib/customwidget.qdoc delete mode 100644 src/designer/src/lib/uilib/qdesignerexportwidget.h create mode 100644 src/designer/src/uiplugin/customwidget.h create mode 100644 src/designer/src/uiplugin/customwidget.qdoc create mode 100644 src/designer/src/uiplugin/qdesignerexportwidget.h create mode 100644 src/designer/src/uiplugin/uiplugin.pro diff --git a/examples/designer/containerextension/multipagewidgetplugin.h b/examples/designer/containerextension/multipagewidgetplugin.h index 34a183668..edb897b1d 100644 --- a/examples/designer/containerextension/multipagewidgetplugin.h +++ b/examples/designer/containerextension/multipagewidgetplugin.h @@ -42,7 +42,7 @@ #ifndef MULTIPAGEWIDGETPLUGIN_H #define MULTIPAGEWIDGETPLUGIN_H -#include +#include QT_BEGIN_NAMESPACE class QIcon; diff --git a/examples/designer/customwidgetplugin/analogclock.h b/examples/designer/customwidgetplugin/analogclock.h index 1ea6d9eb4..daec72452 100644 --- a/examples/designer/customwidgetplugin/analogclock.h +++ b/examples/designer/customwidgetplugin/analogclock.h @@ -42,7 +42,7 @@ #define ANALOGCLOCK_H #include -#include +#include class QDESIGNER_WIDGET_EXPORT AnalogClock : public QWidget { diff --git a/examples/designer/customwidgetplugin/customwidgetplugin.h b/examples/designer/customwidgetplugin/customwidgetplugin.h index a5037477d..dd48fbf87 100644 --- a/examples/designer/customwidgetplugin/customwidgetplugin.h +++ b/examples/designer/customwidgetplugin/customwidgetplugin.h @@ -41,7 +41,7 @@ #ifndef CUSTOMWIDGETPLUGIN_H #define CUSTOMWIDGETPLUGIN_H -#include +#include //! [0] class AnalogClockPlugin : public QObject, public QDesignerCustomWidgetInterface diff --git a/examples/designer/customwidgetplugin/customwidgetplugin.pro b/examples/designer/customwidgetplugin/customwidgetplugin.pro index 0e2006f37..4c2c29843 100644 --- a/examples/designer/customwidgetplugin/customwidgetplugin.pro +++ b/examples/designer/customwidgetplugin/customwidgetplugin.pro @@ -1,5 +1,5 @@ #! [0] -QT += widgets designer +QT += widgets uiplugin #! [0] QTDIR_build { diff --git a/examples/designer/designer.pro b/examples/designer/designer.pro index 38987f8da..2248d3ec1 100644 --- a/examples/designer/designer.pro +++ b/examples/designer/designer.pro @@ -14,8 +14,5 @@ solaris-cc*:SUBDIRS -= calculatorbuilder \ qtNomakeTools( \ containerextension \ - customwidgetplugin \ taskmenuextension \ - worldtimeclockbuilder \ - worldtimeclockplugin \ ) diff --git a/examples/designer/taskmenuextension/tictactoeplugin.h b/examples/designer/taskmenuextension/tictactoeplugin.h index 6ed8b7659..783caa93d 100644 --- a/examples/designer/taskmenuextension/tictactoeplugin.h +++ b/examples/designer/taskmenuextension/tictactoeplugin.h @@ -42,7 +42,7 @@ #ifndef TICTACTOEPLUGIN_H #define TICTACTOEPLUGIN_H -#include +#include QT_BEGIN_NAMESPACE class QIcon; diff --git a/examples/designer/worldtimeclockplugin/worldtimeclock.h b/examples/designer/worldtimeclockplugin/worldtimeclock.h index e0220a8dc..8aede328c 100644 --- a/examples/designer/worldtimeclockplugin/worldtimeclock.h +++ b/examples/designer/worldtimeclockplugin/worldtimeclock.h @@ -43,7 +43,7 @@ #include #include -#include +#include //! [0] //! [1] class QDESIGNER_WIDGET_EXPORT WorldTimeClock : public QWidget diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h index 7ed81ba6f..0a4a40745 100644 --- a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h +++ b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h @@ -41,7 +41,7 @@ #ifndef WORLDTIMECLOCKPLUGIN_H #define WORLDTIMECLOCKPLUGIN_H -#include +#include //! [0] class WorldTimeClockPlugin : public QObject, diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro index 80a97152a..e8a2d2aab 100644 --- a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro +++ b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro @@ -1,5 +1,5 @@ #! [0] -QT += widgets designer +QT += widgets uiplugin #! [0] QTDIR_build { diff --git a/examples/uitools/uitools.pro b/examples/uitools/uitools.pro index c2e3c3405..39bf8e30b 100644 --- a/examples/uitools/uitools.pro +++ b/examples/uitools/uitools.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs SUBDIRS = multipleinheritance -!wince*:contains(QT_BUILD_PARTS, tools): SUBDIRS += textfinder +!wince: SUBDIRS += textfinder diff --git a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp index 1b16831ba..cc1c7570e 100644 --- a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp +++ b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp @@ -44,9 +44,10 @@ // sdk #include #include -#include #include +#include + #include #include #include diff --git a/src/designer/src/designer/doc/qtdesigner.qdocconf b/src/designer/src/designer/doc/qtdesigner.qdocconf index cad640eaa..0f9f4a270 100644 --- a/src/designer/src/designer/doc/qtdesigner.qdocconf +++ b/src/designer/src/designer/doc/qtdesigner.qdocconf @@ -30,9 +30,11 @@ qhp.QtDesigner.subprojects.classes.sortPages = true language = Cpp headerdirs += .. \ + ../../uiplugin \ ../../lib sourcedirs = .. \ + ../../uiplugin \ ../../lib exampledirs = ../../../../../examples/designer \ diff --git a/src/designer/src/lib/lib.pro b/src/designer/src/lib/lib.pro index 642fa617c..2a597d0cf 100644 --- a/src/designer/src/lib/lib.pro +++ b/src/designer/src/lib/lib.pro @@ -1,10 +1,9 @@ MODULE = designer TARGET = QtDesigner -QT = core-private gui-private widgets-private xml +QT = core-private gui-private widgets-private xml uiplugin MODULE_PLUGIN_TYPES = designer -MODULE_CONFIG = designer_defines load(qt_module) DEFINES += \ diff --git a/src/designer/src/lib/shared/plugindialog.cpp b/src/designer/src/lib/shared/plugindialog.cpp index 3f8f9da39..ecf9acb81 100644 --- a/src/designer/src/lib/shared/plugindialog.cpp +++ b/src/designer/src/lib/shared/plugindialog.cpp @@ -37,9 +37,10 @@ #include #include -#include #include +#include + #include #include #include diff --git a/src/designer/src/lib/shared/pluginmanager.cpp b/src/designer/src/lib/shared/pluginmanager.cpp index e7dca4358..856e07cf4 100644 --- a/src/designer/src/lib/shared/pluginmanager.cpp +++ b/src/designer/src/lib/shared/pluginmanager.cpp @@ -36,10 +36,11 @@ #include "qdesigner_qsettings_p.h" #include -#include #include #include +#include + #include #include #include diff --git a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp index 2e50172d8..8ad93be50 100644 --- a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp +++ b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp @@ -41,15 +41,15 @@ #include // sdk #include -#include #include #include #include #include #include -#include #include +#include + // shared #include #include diff --git a/src/designer/src/lib/shared/qsimpleresource.cpp b/src/designer/src/lib/shared/qsimpleresource.cpp index 21295f766..989b0bc8e 100644 --- a/src/designer/src/lib/shared/qsimpleresource.cpp +++ b/src/designer/src/lib/shared/qsimpleresource.cpp @@ -41,9 +41,10 @@ #include #include #include -#include #include +#include + #include #include #include diff --git a/src/designer/src/lib/shared/widgetdatabase.cpp b/src/designer/src/lib/shared/widgetdatabase.cpp index 311078449..4840bee14 100644 --- a/src/designer/src/lib/shared/widgetdatabase.cpp +++ b/src/designer/src/lib/shared/widgetdatabase.cpp @@ -40,11 +40,12 @@ #include "qdesigner_utils_p.h" #include -#include #include #include #include +#include + #include #include diff --git a/src/designer/src/lib/shared/widgetfactory.cpp b/src/designer/src/lib/shared/widgetfactory.cpp index ebc22520a..2208db2d5 100644 --- a/src/designer/src/lib/shared/widgetfactory.cpp +++ b/src/designer/src/lib/shared/widgetfactory.cpp @@ -55,13 +55,14 @@ // sdk #include #include -#include #include #include #include #include #include +#include + #include #include #include diff --git a/src/designer/src/lib/uilib/customwidget.h b/src/designer/src/lib/uilib/customwidget.h deleted file mode 100644 index 3c9083fdc..000000000 --- a/src/designer/src/lib/uilib/customwidget.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CUSTOMWIDGET_H -#define CUSTOMWIDGET_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QWidget; -class QDesignerFormEditorInterface; - -class QDesignerCustomWidgetInterface -{ -public: - virtual ~QDesignerCustomWidgetInterface() {} - - virtual QString name() const = 0; - virtual QString group() const = 0; - virtual QString toolTip() const = 0; - virtual QString whatsThis() const = 0; - virtual QString includeFile() const = 0; - virtual QIcon icon() const = 0; - - virtual bool isContainer() const = 0; - - virtual QWidget *createWidget(QWidget *parent) = 0; - - virtual bool isInitialized() const { return false; } - virtual void initialize(QDesignerFormEditorInterface *core) { Q_UNUSED(core); } - - virtual QString domXml() const - { - return QString::fromUtf8("") - .arg(name()).arg(name().toLower()); - } - - virtual QString codeTemplate() const { return QString(); } -}; - -#define QDesignerCustomWidgetInterface_iid "org.qt-project.QDesignerCustomWidgetInterface" - -Q_DECLARE_INTERFACE(QDesignerCustomWidgetInterface, QDesignerCustomWidgetInterface_iid) - -class QDesignerCustomWidgetCollectionInterface -{ -public: - virtual ~QDesignerCustomWidgetCollectionInterface() {} - - virtual QList customWidgets() const = 0; -}; - -#define QDesignerCustomWidgetCollectionInterface_iid "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface" - -Q_DECLARE_INTERFACE(QDesignerCustomWidgetCollectionInterface, QDesignerCustomWidgetCollectionInterface_iid) - -QT_END_NAMESPACE - -#endif // CUSTOMWIDGET_H diff --git a/src/designer/src/lib/uilib/customwidget.qdoc b/src/designer/src/lib/uilib/customwidget.qdoc deleted file mode 100644 index e8e4a4b76..000000000 --- a/src/designer/src/lib/uilib/customwidget.qdoc +++ /dev/null @@ -1,293 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QDesignerCustomWidgetInterface - - \brief The QDesignerCustomWidgetInterface class enables Qt Designer - to access and construct custom widgets. - - \inmodule QtDesigner - - QDesignerCustomWidgetInterface provides a custom widget with an - interface. The class contains a set of functions that must be subclassed - to return basic information about the widget, such as its class name and - the name of its header file. Other functions must be implemented to - initialize the plugin when it is loaded, and to construct instances of - the custom widget for \QD to use. - - When implementing a custom widget you must subclass - QDesignerCustomWidgetInterface to expose your widget to \QD. For - example, this is the declaration for the plugin used in the - \l{Custom Widget Plugin Example}{Custom Widget Plugin example} that - enables an analog clock custom widget to be used by \QD: - - \snippet customwidgetplugin/customwidgetplugin.h 0 - - Note that the only part of the class definition that is specific - to this particular custom widget is the class name. In addition, - since we are implementing an interface, we must ensure that it's - made known to the meta object system using the Q_INTERFACES() - macro. This enables \QD to use the qobject_cast() function to - query for supported interfaces using nothing but a QObject - pointer. - - After \QD loads a custom widget plugin, it calls the interface's - initialize() function to enable it to set up any resources that it - may need. This function is called with a QDesignerFormEditorInterface - parameter that provides the plugin with a gateway to all of \QD's API. - - \QD constructs instances of the custom widget by calling the plugin's - createWidget() function with a suitable parent widget. Plugins must - construct and return an instance of a custom widget with the specified - parent widget. - - Exporting your custom widget plugin to \QD using the Q_PLUGIN_METADATA() - macro. For example, if a library called \c libcustomwidgetplugin.so - (on Unix) or \c libcustomwidget.dll (on Windows) contains a widget - class called \c MyCustomWidget, we can export it by adding the - following line to the file containing the plugin header: - - \snippet plugins/doc_src_qtdesigner.cpp 14 - - This macro ensures that \QD can access and construct the custom widget. - Without this macro, there is no way for \QD to use it. - - When implementing a custom widget plugin, you build it as a - separate library. If you want to include several custom widget - plugins in the same library, you must in addition subclass - QDesignerCustomWidgetCollectionInterface. - - \warning If your custom widget plugin contains QVariant - properties, be aware that only the following \l - {QVariant::Type}{types} are supported: - - \list - \li QVariant::ByteArray - \li QVariant::Bool - \li QVariant::Color - \li QVariant::Cursor - \li QVariant::Date - \li QVariant::DateTime - \li QVariant::Double - \li QVariant::Int - \li QVariant::Point - \li QVariant::Rect - \li QVariant::Size - \li QVariant::SizePolicy - \li QVariant::String - \li QVariant::Time - \li QVariant::UInt - \endlist - - For a complete example using the QDesignerCustomWidgetInterface - class, see the \l {customwidgetplugin}{Custom Widget - Example}. The example shows how to create a custom widget plugin - for \QD. - - \sa QDesignerCustomWidgetCollectionInterface, {Creating Custom Widgets for Qt Designer} -*/ - -/*! - \fn QDesignerCustomWidgetInterface::~QDesignerCustomWidgetInterface() - - Destroys the custom widget interface. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::name() const - - Returns the class name of the custom widget supplied by the interface. - - The name returned \e must be identical to the class name used for the - custom widget. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::group() const - - Returns the name of the group to which the custom widget belongs. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::toolTip() const - - Returns a short description of the widget that can be used by \QD - in a tool tip. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::whatsThis() const - - Returns a description of the widget that can be used by \QD in - "What's This?" help for the widget. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::includeFile() const - - Returns the path to the include file that \l uic uses when - creating code for the custom widget. -*/ - -/*! - \fn QIcon QDesignerCustomWidgetInterface::icon() const - - Returns the icon used to represent the custom widget in \QD's - widget box. -*/ - -/*! - \fn bool QDesignerCustomWidgetInterface::isContainer() const - - Returns true if the custom widget is intended to be used as a - container; otherwise returns false. - - Most custom widgets are not used to hold other widgets, so their - implementations of this function will return false, but custom - containers will return true to ensure that they behave correctly - in \QD. -*/ - -/*! - \fn QWidget *QDesignerCustomWidgetInterface::createWidget(QWidget *parent) - - Returns a new instance of the custom widget, with the given \a - parent. -*/ - -/*! - \fn bool QDesignerCustomWidgetInterface::isInitialized() const - - Returns true if the widget has been initialized; otherwise returns - false. - - \sa initialize() -*/ - -/*! - \fn void QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface *formEditor) - - Initializes the widget for use with the specified \a formEditor - interface. - - \sa isInitialized() -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::domXml() const - - Returns the XML that is used to describe the custom widget's - properties to \QD. -*/ - -/*! - \fn QString QDesignerCustomWidgetInterface::codeTemplate() const - - This function is reserved for future use by \QD. - - \omit - Returns the code template that \QD includes in forms that contain - the custom widget when they are saved. - \endomit -*/ - -/*! - \macro QDESIGNER_WIDGET_EXPORT - \relates QDesignerCustomWidgetInterface - \since 4.1 - - This macro is used when defining custom widgets to ensure that they are - correctly exported from plugins for use with \QD. - - On some platforms, the symbols required by \QD to create new widgets - are removed from plugins by the build system, making them unusable. - Using this macro ensures that the symbols are retained on those platforms, - and has no side effects on other platforms. - - For example, the \l{worldtimeclockplugin}{World Time Clock Plugin} - example exports a custom widget class with the following declaration: - - \snippet worldtimeclockplugin/worldtimeclock.h 0 - \dots - \snippet worldtimeclockplugin/worldtimeclock.h 2 - - \sa {Creating Custom Widgets for Qt Designer} -*/ - - - - - -/*! - \class QDesignerCustomWidgetCollectionInterface - - \brief The QDesignerCustomWidgetCollectionInterface class allows - you to include several custom widgets in one single library. - - \inmodule QtDesigner - - When implementing a custom widget plugin, you build it as a - separate library. If you want to include several custom widget - plugins in the same library, you must in addition subclass - QDesignerCustomWidgetCollectionInterface. - - QDesignerCustomWidgetCollectionInterface contains one single - function returning a list of the collection's - QDesignerCustomWidgetInterface objects. For example, if you have - several custom widgets \c CustomWidgetOne, \c CustomWidgetTwo and - \c CustomWidgetThree, the class definition may look like this: - - \snippet plugins/doc_src_qtdesigner.cpp 12 - - In the class constructor you add the interfaces to your custom - widgets to the list which you return in the customWidgets() - function: - - \snippet plugins/doc_src_qtdesigner.cpp 13 - - Note that instead of exporting each custom widget plugin using the - Q_PLUGIN_METADATA() macro, you export the entire collection. The - Q_PLUGIN_METADATA() macro ensures that \QD can access and construct - the custom widgets. Without this macro, there is no way for \QD to - use them. - - \sa QDesignerCustomWidgetInterface, {Creating Custom Widgets for - Qt Designer} -*/ - -/*! - \fn QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface() { - - Destroys the custom widget collection interface. -*/ - -/*! - \fn QList QDesignerCustomWidgetCollectionInterface::customWidgets() const - - Returns a list of interfaces to the collection's custom widgets. -*/ diff --git a/src/designer/src/lib/uilib/formbuilder.cpp b/src/designer/src/lib/uilib/formbuilder.cpp index 17cc314f0..f29257cd0 100644 --- a/src/designer/src/lib/uilib/formbuilder.cpp +++ b/src/designer/src/lib/uilib/formbuilder.cpp @@ -31,11 +31,11 @@ ** ****************************************************************************/ -#include "customwidget.h" #include "formbuilder.h" #include "formbuilderextra_p.h" #include "ui4_p.h" +#include #include QT_BEGIN_NAMESPACE diff --git a/src/designer/src/lib/uilib/qdesignerexportwidget.h b/src/designer/src/lib/uilib/qdesignerexportwidget.h deleted file mode 100644 index ff7e28ad9..000000000 --- a/src/designer/src/lib/uilib/qdesignerexportwidget.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDESIGNEREXPORTWIDGET_H -#define QDESIGNEREXPORTWIDGET_H - -#include - -QT_BEGIN_NAMESPACE - -#if 0 -// pragma for syncqt, don't remove. -#pragma qt_class(QDesignerExportWidget) -#endif - -#if defined(QDESIGNER_EXPORT_WIDGETS) -# define QDESIGNER_WIDGET_EXPORT Q_DECL_EXPORT -#else -# define QDESIGNER_WIDGET_EXPORT Q_DECL_IMPORT -#endif - -QT_END_NAMESPACE - -#endif //QDESIGNEREXPORTWIDGET_H diff --git a/src/designer/src/lib/uilib/uilib.pri b/src/designer/src/lib/uilib/uilib.pri index d0002b481..26510bcb3 100644 --- a/src/designer/src/lib/uilib/uilib.pri +++ b/src/designer/src/lib/uilib/uilib.pri @@ -3,14 +3,13 @@ INCLUDEPATH += $$PWD DEFINES += QT_DESIGNER -QT += widgets +QT += widgets uiplugin # Input HEADERS += \ $$PWD/ui4_p.h \ $$PWD/abstractformbuilder.h \ $$PWD/formbuilder.h \ - $$PWD/customwidget.h \ $$PWD/properties_p.h \ $$PWD/formbuilderextra_p.h \ $$PWD/resourcebuilder_p.h \ diff --git a/src/designer/src/plugins/activeqt/qaxwidgetplugin.h b/src/designer/src/plugins/activeqt/qaxwidgetplugin.h index 1834b2ea1..8a6709a66 100644 --- a/src/designer/src/plugins/activeqt/qaxwidgetplugin.h +++ b/src/designer/src/plugins/activeqt/qaxwidgetplugin.h @@ -34,7 +34,7 @@ #ifndef ACTIVEXPLUGIN_H #define ACTIVEXPLUGIN_H -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/designer/src/plugins/qquickwidget/qquickwidget_plugin.h b/src/designer/src/plugins/qquickwidget/qquickwidget_plugin.h index 93107127d..7c832fecf 100644 --- a/src/designer/src/plugins/qquickwidget/qquickwidget_plugin.h +++ b/src/designer/src/plugins/qquickwidget/qquickwidget_plugin.h @@ -35,7 +35,7 @@ #define QQUICKWIDGET_PLUGIN_H #include -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/designer/src/plugins/qwebview/qwebview_plugin.h b/src/designer/src/plugins/qwebview/qwebview_plugin.h index 077d5a273..c402c6671 100644 --- a/src/designer/src/plugins/qwebview/qwebview_plugin.h +++ b/src/designer/src/plugins/qwebview/qwebview_plugin.h @@ -34,7 +34,7 @@ #ifndef QWEBPAGE_PLUGIN_H #define QWEBPAGE_PLUGIN_H -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/designer/src/src.pro b/src/designer/src/src.pro index e02ca8efb..6915e34e9 100644 --- a/src/designer/src/src.pro +++ b/src/designer/src/src.pro @@ -1,6 +1,7 @@ TEMPLATE = subdirs SUBDIRS = \ + uiplugin \ uitools \ lib \ components \ @@ -8,6 +9,8 @@ SUBDIRS = \ contains(QT_CONFIG, shared): SUBDIRS += plugins +uitools.depends = uiplugin +lib.depends = uiplugin components.depends = lib designer.depends = components plugins.depends = lib diff --git a/src/designer/src/uiplugin/customwidget.h b/src/designer/src/uiplugin/customwidget.h new file mode 100644 index 000000000..3c9083fdc --- /dev/null +++ b/src/designer/src/uiplugin/customwidget.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Designer of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CUSTOMWIDGET_H +#define CUSTOMWIDGET_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QWidget; +class QDesignerFormEditorInterface; + +class QDesignerCustomWidgetInterface +{ +public: + virtual ~QDesignerCustomWidgetInterface() {} + + virtual QString name() const = 0; + virtual QString group() const = 0; + virtual QString toolTip() const = 0; + virtual QString whatsThis() const = 0; + virtual QString includeFile() const = 0; + virtual QIcon icon() const = 0; + + virtual bool isContainer() const = 0; + + virtual QWidget *createWidget(QWidget *parent) = 0; + + virtual bool isInitialized() const { return false; } + virtual void initialize(QDesignerFormEditorInterface *core) { Q_UNUSED(core); } + + virtual QString domXml() const + { + return QString::fromUtf8("") + .arg(name()).arg(name().toLower()); + } + + virtual QString codeTemplate() const { return QString(); } +}; + +#define QDesignerCustomWidgetInterface_iid "org.qt-project.QDesignerCustomWidgetInterface" + +Q_DECLARE_INTERFACE(QDesignerCustomWidgetInterface, QDesignerCustomWidgetInterface_iid) + +class QDesignerCustomWidgetCollectionInterface +{ +public: + virtual ~QDesignerCustomWidgetCollectionInterface() {} + + virtual QList customWidgets() const = 0; +}; + +#define QDesignerCustomWidgetCollectionInterface_iid "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface" + +Q_DECLARE_INTERFACE(QDesignerCustomWidgetCollectionInterface, QDesignerCustomWidgetCollectionInterface_iid) + +QT_END_NAMESPACE + +#endif // CUSTOMWIDGET_H diff --git a/src/designer/src/uiplugin/customwidget.qdoc b/src/designer/src/uiplugin/customwidget.qdoc new file mode 100644 index 000000000..e8e4a4b76 --- /dev/null +++ b/src/designer/src/uiplugin/customwidget.qdoc @@ -0,0 +1,293 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QDesignerCustomWidgetInterface + + \brief The QDesignerCustomWidgetInterface class enables Qt Designer + to access and construct custom widgets. + + \inmodule QtDesigner + + QDesignerCustomWidgetInterface provides a custom widget with an + interface. The class contains a set of functions that must be subclassed + to return basic information about the widget, such as its class name and + the name of its header file. Other functions must be implemented to + initialize the plugin when it is loaded, and to construct instances of + the custom widget for \QD to use. + + When implementing a custom widget you must subclass + QDesignerCustomWidgetInterface to expose your widget to \QD. For + example, this is the declaration for the plugin used in the + \l{Custom Widget Plugin Example}{Custom Widget Plugin example} that + enables an analog clock custom widget to be used by \QD: + + \snippet customwidgetplugin/customwidgetplugin.h 0 + + Note that the only part of the class definition that is specific + to this particular custom widget is the class name. In addition, + since we are implementing an interface, we must ensure that it's + made known to the meta object system using the Q_INTERFACES() + macro. This enables \QD to use the qobject_cast() function to + query for supported interfaces using nothing but a QObject + pointer. + + After \QD loads a custom widget plugin, it calls the interface's + initialize() function to enable it to set up any resources that it + may need. This function is called with a QDesignerFormEditorInterface + parameter that provides the plugin with a gateway to all of \QD's API. + + \QD constructs instances of the custom widget by calling the plugin's + createWidget() function with a suitable parent widget. Plugins must + construct and return an instance of a custom widget with the specified + parent widget. + + Exporting your custom widget plugin to \QD using the Q_PLUGIN_METADATA() + macro. For example, if a library called \c libcustomwidgetplugin.so + (on Unix) or \c libcustomwidget.dll (on Windows) contains a widget + class called \c MyCustomWidget, we can export it by adding the + following line to the file containing the plugin header: + + \snippet plugins/doc_src_qtdesigner.cpp 14 + + This macro ensures that \QD can access and construct the custom widget. + Without this macro, there is no way for \QD to use it. + + When implementing a custom widget plugin, you build it as a + separate library. If you want to include several custom widget + plugins in the same library, you must in addition subclass + QDesignerCustomWidgetCollectionInterface. + + \warning If your custom widget plugin contains QVariant + properties, be aware that only the following \l + {QVariant::Type}{types} are supported: + + \list + \li QVariant::ByteArray + \li QVariant::Bool + \li QVariant::Color + \li QVariant::Cursor + \li QVariant::Date + \li QVariant::DateTime + \li QVariant::Double + \li QVariant::Int + \li QVariant::Point + \li QVariant::Rect + \li QVariant::Size + \li QVariant::SizePolicy + \li QVariant::String + \li QVariant::Time + \li QVariant::UInt + \endlist + + For a complete example using the QDesignerCustomWidgetInterface + class, see the \l {customwidgetplugin}{Custom Widget + Example}. The example shows how to create a custom widget plugin + for \QD. + + \sa QDesignerCustomWidgetCollectionInterface, {Creating Custom Widgets for Qt Designer} +*/ + +/*! + \fn QDesignerCustomWidgetInterface::~QDesignerCustomWidgetInterface() + + Destroys the custom widget interface. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::name() const + + Returns the class name of the custom widget supplied by the interface. + + The name returned \e must be identical to the class name used for the + custom widget. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::group() const + + Returns the name of the group to which the custom widget belongs. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::toolTip() const + + Returns a short description of the widget that can be used by \QD + in a tool tip. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::whatsThis() const + + Returns a description of the widget that can be used by \QD in + "What's This?" help for the widget. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::includeFile() const + + Returns the path to the include file that \l uic uses when + creating code for the custom widget. +*/ + +/*! + \fn QIcon QDesignerCustomWidgetInterface::icon() const + + Returns the icon used to represent the custom widget in \QD's + widget box. +*/ + +/*! + \fn bool QDesignerCustomWidgetInterface::isContainer() const + + Returns true if the custom widget is intended to be used as a + container; otherwise returns false. + + Most custom widgets are not used to hold other widgets, so their + implementations of this function will return false, but custom + containers will return true to ensure that they behave correctly + in \QD. +*/ + +/*! + \fn QWidget *QDesignerCustomWidgetInterface::createWidget(QWidget *parent) + + Returns a new instance of the custom widget, with the given \a + parent. +*/ + +/*! + \fn bool QDesignerCustomWidgetInterface::isInitialized() const + + Returns true if the widget has been initialized; otherwise returns + false. + + \sa initialize() +*/ + +/*! + \fn void QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface *formEditor) + + Initializes the widget for use with the specified \a formEditor + interface. + + \sa isInitialized() +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::domXml() const + + Returns the XML that is used to describe the custom widget's + properties to \QD. +*/ + +/*! + \fn QString QDesignerCustomWidgetInterface::codeTemplate() const + + This function is reserved for future use by \QD. + + \omit + Returns the code template that \QD includes in forms that contain + the custom widget when they are saved. + \endomit +*/ + +/*! + \macro QDESIGNER_WIDGET_EXPORT + \relates QDesignerCustomWidgetInterface + \since 4.1 + + This macro is used when defining custom widgets to ensure that they are + correctly exported from plugins for use with \QD. + + On some platforms, the symbols required by \QD to create new widgets + are removed from plugins by the build system, making them unusable. + Using this macro ensures that the symbols are retained on those platforms, + and has no side effects on other platforms. + + For example, the \l{worldtimeclockplugin}{World Time Clock Plugin} + example exports a custom widget class with the following declaration: + + \snippet worldtimeclockplugin/worldtimeclock.h 0 + \dots + \snippet worldtimeclockplugin/worldtimeclock.h 2 + + \sa {Creating Custom Widgets for Qt Designer} +*/ + + + + + +/*! + \class QDesignerCustomWidgetCollectionInterface + + \brief The QDesignerCustomWidgetCollectionInterface class allows + you to include several custom widgets in one single library. + + \inmodule QtDesigner + + When implementing a custom widget plugin, you build it as a + separate library. If you want to include several custom widget + plugins in the same library, you must in addition subclass + QDesignerCustomWidgetCollectionInterface. + + QDesignerCustomWidgetCollectionInterface contains one single + function returning a list of the collection's + QDesignerCustomWidgetInterface objects. For example, if you have + several custom widgets \c CustomWidgetOne, \c CustomWidgetTwo and + \c CustomWidgetThree, the class definition may look like this: + + \snippet plugins/doc_src_qtdesigner.cpp 12 + + In the class constructor you add the interfaces to your custom + widgets to the list which you return in the customWidgets() + function: + + \snippet plugins/doc_src_qtdesigner.cpp 13 + + Note that instead of exporting each custom widget plugin using the + Q_PLUGIN_METADATA() macro, you export the entire collection. The + Q_PLUGIN_METADATA() macro ensures that \QD can access and construct + the custom widgets. Without this macro, there is no way for \QD to + use them. + + \sa QDesignerCustomWidgetInterface, {Creating Custom Widgets for + Qt Designer} +*/ + +/*! + \fn QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface() { + + Destroys the custom widget collection interface. +*/ + +/*! + \fn QList QDesignerCustomWidgetCollectionInterface::customWidgets() const + + Returns a list of interfaces to the collection's custom widgets. +*/ diff --git a/src/designer/src/uiplugin/qdesignerexportwidget.h b/src/designer/src/uiplugin/qdesignerexportwidget.h new file mode 100644 index 000000000..ff7e28ad9 --- /dev/null +++ b/src/designer/src/uiplugin/qdesignerexportwidget.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Designer of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDESIGNEREXPORTWIDGET_H +#define QDESIGNEREXPORTWIDGET_H + +#include + +QT_BEGIN_NAMESPACE + +#if 0 +// pragma for syncqt, don't remove. +#pragma qt_class(QDesignerExportWidget) +#endif + +#if defined(QDESIGNER_EXPORT_WIDGETS) +# define QDESIGNER_WIDGET_EXPORT Q_DECL_EXPORT +#else +# define QDESIGNER_WIDGET_EXPORT Q_DECL_IMPORT +#endif + +QT_END_NAMESPACE + +#endif //QDESIGNEREXPORTWIDGET_H diff --git a/src/designer/src/uiplugin/uiplugin.pro b/src/designer/src/uiplugin/uiplugin.pro new file mode 100644 index 000000000..7c41ea78c --- /dev/null +++ b/src/designer/src/uiplugin/uiplugin.pro @@ -0,0 +1,6 @@ +TARGET = QtUiPlugin +CONFIG += no_private_module header_module +QT += widgets + +MODULE_CONFIG = designer_defines +load(qt_module) diff --git a/src/designer/src/uitools/quiloader.cpp b/src/designer/src/uitools/quiloader.cpp index af2ee4fd9..a225744e1 100644 --- a/src/designer/src/uitools/quiloader.cpp +++ b/src/designer/src/uitools/quiloader.cpp @@ -34,7 +34,8 @@ #include "quiloader.h" #include "quiloader_p.h" -#include "customwidget.h" + +#include #include #include diff --git a/src/designer/src/uitools/uitools.pro b/src/designer/src/uitools/uitools.pro index 9cdc59633..b9e500080 100644 --- a/src/designer/src/uitools/uitools.pro +++ b/src/designer/src/uitools/uitools.pro @@ -5,6 +5,11 @@ include(../lib/uilib/uilib.pri) QMAKE_DOCS = $$PWD/doc/qtuitools.qdocconf +# QtUiPlugins end up in designer for historical reasons. However, if +# designer isn't actually built, we need to claim the plugin type here. +!qtBuildPart(tools): \ + MODULE_PLUGIN_TYPES = designer + load(qt_module) HEADERS += quiloader.h diff --git a/sync.profile b/sync.profile index 97beabbb3..ff59ca3c2 100644 --- a/sync.profile +++ b/sync.profile @@ -2,6 +2,7 @@ "QtCLucene" => "$basedir/src/assistant/clucene", "QtHelp" => "$basedir/src/assistant/help", "QtUiTools" => "$basedir/src/designer/src/uitools", + "QtUiPlugin" => "$basedir/src/designer/src/uiplugin", "QtDesigner" => "$basedir/src/designer/src/lib", "QtDesignerComponents" => "$basedir/src/designer/src/components/lib", ); @@ -9,6 +10,15 @@ ); %classnames = ( ); +%deprecatedheaders = ( + "QtDesigner" => { + "customwidget.h" => "QtUiPlugin/customwidget.h", + "QDesignerCustomWidgetInterface" => "QtUiPlugin/QDesignerCustomWidgetInterface", + "QDesignerCustomWidgetCollectionInterface" => "QtUiPlugin/QDesignerCustomWidgetCollectionInterface", + "qdesignerexportwidget.h" => "QtUiPlugin/qdesignerexportwidget.h", + "QDesignerExportWidget" => "QtUiPlugin/QDesignerExportWidget" + } +); # Module dependencies. # Every module that is required to build this module should have one entry. # Each of the module version specifiers can take one of the following values: -- cgit v1.2.3