| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the demonstration applications of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include <QtDesigner/QDesignerContainerExtension>
|
|---|
| 43 | #include <QtDesigner/QDesignerCustomWidgetInterface>
|
|---|
| 44 |
|
|---|
| 45 | #include <QtCore/qplugin.h>
|
|---|
| 46 | #include <QtGui/QIcon>
|
|---|
| 47 | #include <QtGui/QPixmap>
|
|---|
| 48 |
|
|---|
| 49 | #include "xform.h"
|
|---|
| 50 | #include "pathdeform.h"
|
|---|
| 51 | #include "gradients.h"
|
|---|
| 52 | #include "pathstroke.h"
|
|---|
| 53 | #include "hoverpoints.h"
|
|---|
| 54 | #include "composition.h"
|
|---|
| 55 |
|
|---|
| 56 | QT_FORWARD_DECLARE_CLASS(QDesignerFormEditorInterface)
|
|---|
| 57 |
|
|---|
| 58 | static inline QString customWidgetDomXml(const QString &className)
|
|---|
| 59 | {
|
|---|
| 60 | QString rc = QLatin1String("<ui language=\"c++\"><widget class=\"");
|
|---|
| 61 | rc += className;
|
|---|
| 62 | rc += QLatin1String("\" name=\"");
|
|---|
| 63 | QString objectName = className;
|
|---|
| 64 | objectName[0] = objectName.at(0).toLower();
|
|---|
| 65 | rc += objectName;
|
|---|
| 66 | rc += QLatin1String("\"/></ui>");
|
|---|
| 67 | return rc;
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | class PathDeformRendererEx : public PathDeformRenderer
|
|---|
| 71 | {
|
|---|
| 72 | Q_OBJECT
|
|---|
| 73 | public:
|
|---|
| 74 | PathDeformRendererEx(QWidget *parent) : PathDeformRenderer(parent) { }
|
|---|
| 75 | QSize sizeHint() const { return QSize(300, 200); }
|
|---|
| 76 | };
|
|---|
| 77 |
|
|---|
| 78 | class DemoPlugin : public QDesignerCustomWidgetInterface
|
|---|
| 79 | {
|
|---|
| 80 | Q_INTERFACES(QDesignerCustomWidgetInterface)
|
|---|
| 81 |
|
|---|
| 82 | protected:
|
|---|
| 83 | DemoPlugin(const QString &className);
|
|---|
| 84 |
|
|---|
| 85 | public:
|
|---|
| 86 | QString name() const { return m_className; }
|
|---|
| 87 | bool isContainer() const { return false; }
|
|---|
| 88 | bool isInitialized() const { return m_initialized; }
|
|---|
| 89 | QIcon icon() const { return QIcon(); }
|
|---|
| 90 | QString codeTemplate() const { return QString(); }
|
|---|
| 91 | QString whatsThis() const { return QString(); }
|
|---|
| 92 | QString toolTip() const { return QString(); }
|
|---|
| 93 | QString group() const { return "Arthur Widgets [Demo]"; }
|
|---|
| 94 | void initialize(QDesignerFormEditorInterface *)
|
|---|
| 95 | {
|
|---|
| 96 | if (m_initialized)
|
|---|
| 97 | return;
|
|---|
| 98 | m_initialized = true;
|
|---|
| 99 | }
|
|---|
| 100 | QString domXml() const { return m_domXml; }
|
|---|
| 101 |
|
|---|
| 102 | private:
|
|---|
| 103 | const QString m_className;
|
|---|
| 104 | const QString m_domXml;
|
|---|
| 105 | bool m_initialized;
|
|---|
| 106 | };
|
|---|
| 107 |
|
|---|
| 108 | DemoPlugin::DemoPlugin(const QString &className) :
|
|---|
| 109 | m_className(className),
|
|---|
| 110 | m_domXml(customWidgetDomXml(className)),
|
|---|
| 111 | m_initialized(false)
|
|---|
| 112 | {
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | class DeformPlugin : public QObject, public DemoPlugin
|
|---|
| 116 | {
|
|---|
| 117 | Q_OBJECT
|
|---|
| 118 |
|
|---|
| 119 | public:
|
|---|
| 120 | DeformPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("PathDeformRendererEx")) { }
|
|---|
| 121 | QString includeFile() const { return "deform.h"; }
|
|---|
| 122 |
|
|---|
| 123 | QWidget *createWidget(QWidget *parent)
|
|---|
| 124 | {
|
|---|
| 125 | PathDeformRenderer *deform = new PathDeformRendererEx(parent);
|
|---|
| 126 | deform->setRadius(70);
|
|---|
| 127 | deform->setAnimated(false);
|
|---|
| 128 | deform->setFontSize(20);
|
|---|
| 129 | deform->setText("Arthur Widgets Demo");
|
|---|
| 130 |
|
|---|
| 131 | return deform;
|
|---|
| 132 | }
|
|---|
| 133 | };
|
|---|
| 134 |
|
|---|
| 135 | class XFormRendererEx : public XFormView
|
|---|
| 136 | {
|
|---|
| 137 | Q_OBJECT
|
|---|
| 138 | public:
|
|---|
| 139 | XFormRendererEx(QWidget *parent) : XFormView(parent) {}
|
|---|
| 140 | QSize sizeHint() const { return QSize(300, 200); }
|
|---|
| 141 | };
|
|---|
| 142 |
|
|---|
| 143 | class XFormPlugin : public QObject, public DemoPlugin
|
|---|
| 144 | {
|
|---|
| 145 | Q_OBJECT
|
|---|
| 146 | public:
|
|---|
| 147 | XFormPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("XFormRendererEx")) { }
|
|---|
| 148 | QString includeFile() const { return "xform.h"; }
|
|---|
| 149 |
|
|---|
| 150 | QWidget *createWidget(QWidget *parent)
|
|---|
| 151 | {
|
|---|
| 152 | XFormRendererEx *xform = new XFormRendererEx(parent);
|
|---|
| 153 | xform->setText("Qt - Hello World!!");
|
|---|
| 154 | xform->setPixmap(QPixmap(":/trolltech/arthurplugin/bg1.jpg"));
|
|---|
| 155 | return xform;
|
|---|
| 156 | }
|
|---|
| 157 | };
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | class GradientEditorPlugin : public QObject, public DemoPlugin
|
|---|
| 161 | {
|
|---|
| 162 | Q_OBJECT
|
|---|
| 163 | public:
|
|---|
| 164 | GradientEditorPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("GradientEditor")) { }
|
|---|
| 165 | QString includeFile() const { return "gradients.h"; }
|
|---|
| 166 |
|
|---|
| 167 | QWidget *createWidget(QWidget *parent)
|
|---|
| 168 | {
|
|---|
| 169 | GradientEditor *editor = new GradientEditor(parent);
|
|---|
| 170 | return editor;
|
|---|
| 171 | }
|
|---|
| 172 | };
|
|---|
| 173 |
|
|---|
| 174 | class GradientRendererEx : public GradientRenderer
|
|---|
| 175 | {
|
|---|
| 176 | Q_OBJECT
|
|---|
| 177 | public:
|
|---|
| 178 | GradientRendererEx(QWidget *p) : GradientRenderer(p) { }
|
|---|
| 179 | QSize sizeHint() const { return QSize(300, 200); }
|
|---|
| 180 | };
|
|---|
| 181 |
|
|---|
| 182 | class GradientRendererPlugin : public QObject, public DemoPlugin
|
|---|
| 183 | {
|
|---|
| 184 | Q_OBJECT
|
|---|
| 185 | public:
|
|---|
| 186 | GradientRendererPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("GradientRendererEx")) { }
|
|---|
| 187 | QString includeFile() const { return "gradients.h"; }
|
|---|
| 188 |
|
|---|
| 189 | QWidget *createWidget(QWidget *parent)
|
|---|
| 190 | {
|
|---|
| 191 | GradientRenderer *renderer = new GradientRendererEx(parent);
|
|---|
| 192 | renderer->setConicalGradient();
|
|---|
| 193 | return renderer;
|
|---|
| 194 | }
|
|---|
| 195 | };
|
|---|
| 196 |
|
|---|
| 197 | class PathStrokeRendererEx : public PathStrokeRenderer
|
|---|
| 198 | {
|
|---|
| 199 | Q_OBJECT
|
|---|
| 200 | public:
|
|---|
| 201 | PathStrokeRendererEx(QWidget *p) : PathStrokeRenderer(p) { }
|
|---|
| 202 | QSize sizeHint() const { return QSize(300, 200); }
|
|---|
| 203 | };
|
|---|
| 204 |
|
|---|
| 205 | class StrokeRenderPlugin : public QObject, public DemoPlugin
|
|---|
| 206 | {
|
|---|
| 207 | Q_OBJECT
|
|---|
| 208 | public:
|
|---|
| 209 | StrokeRenderPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("PathStrokeRendererEx")) { }
|
|---|
| 210 | QString includeFile() const { return "pathstroke.h"; }
|
|---|
| 211 |
|
|---|
| 212 | QWidget *createWidget(QWidget *parent)
|
|---|
| 213 | {
|
|---|
| 214 | PathStrokeRenderer *stroke = new PathStrokeRendererEx(parent);
|
|---|
| 215 | return stroke;
|
|---|
| 216 | }
|
|---|
| 217 | };
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 | class CompositionModePlugin : public QObject, public DemoPlugin
|
|---|
| 221 | {
|
|---|
| 222 | Q_OBJECT
|
|---|
| 223 | public:
|
|---|
| 224 | CompositionModePlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("CompositionRenderer")) { }
|
|---|
| 225 | QString includeFile() const { return "composition.h"; }
|
|---|
| 226 |
|
|---|
| 227 | QWidget *createWidget(QWidget *parent)
|
|---|
| 228 | {
|
|---|
| 229 | CompositionRenderer *renderer = new CompositionRenderer(parent);
|
|---|
| 230 | renderer->setAnimationEnabled(false);
|
|---|
| 231 | return renderer;
|
|---|
| 232 | }
|
|---|
| 233 | };
|
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 | class ArthurPlugins : public QObject, public QDesignerCustomWidgetCollectionInterface
|
|---|
| 237 | {
|
|---|
| 238 | Q_OBJECT
|
|---|
| 239 | Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
|
|---|
| 240 |
|
|---|
| 241 | public:
|
|---|
| 242 | ArthurPlugins(QObject *parent = 0);
|
|---|
| 243 | QList<QDesignerCustomWidgetInterface*> customWidgets() const { return m_plugins; }
|
|---|
| 244 |
|
|---|
| 245 | private:
|
|---|
| 246 | QList<QDesignerCustomWidgetInterface *> m_plugins;
|
|---|
| 247 | };
|
|---|
| 248 |
|
|---|
| 249 | ArthurPlugins::ArthurPlugins(QObject *parent) :
|
|---|
| 250 | QObject(parent)
|
|---|
| 251 | {
|
|---|
| 252 | m_plugins << new DeformPlugin(this)
|
|---|
| 253 | << new XFormPlugin(this)
|
|---|
| 254 | << new GradientEditorPlugin(this)
|
|---|
| 255 | << new GradientRendererPlugin(this)
|
|---|
| 256 | << new StrokeRenderPlugin(this)
|
|---|
| 257 | << new CompositionModePlugin(this);
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | #include "plugin.moc"
|
|---|
| 261 |
|
|---|
| 262 | Q_EXPORT_PLUGIN2(ArthurPlugins, ArthurPlugins)
|
|---|