00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <QtDesigner/QDesignerContainerExtension>
00025 #include <QtDesigner/QDesignerCustomWidgetInterface>
00026
00027 #include <QtCore/qplugin.h>
00028 #include <QtGui/QIcon>
00029 #include <QtGui/QLineEdit>
00030
00031 #include "xform.h"
00032 #include "pathdeform.h"
00033 #include "gradients.h"
00034 #include "pathstroke.h"
00035 #include "hoverpoints.h"
00036 #include "composition.h"
00037
00038 class QDesignerFormEditorInterface;
00039 class PathDeformRendererEx : public PathDeformRenderer
00040 {
00041 Q_OBJECT
00042 public:
00043 PathDeformRendererEx(QWidget *parent) : PathDeformRenderer(parent) { }
00044 QSize sizeHint() const { return QSize(300, 200); }
00045 };
00046
00047 class DemoPlugin : public QDesignerCustomWidgetInterface
00048 {
00049 Q_INTERFACES(QDesignerCustomWidgetInterface)
00050 public:
00051 DemoPlugin() : m_initialized(false) { }
00052 bool isContainer() const { return false; }
00053 bool isInitialized() const { return m_initialized; }
00054 QIcon icon() const { return QIcon(); }
00055 QString codeTemplate() const { return QString(); }
00056 QString whatsThis() const { return QString(); }
00057 QString toolTip() const { return QString(); }
00058 QString group() const { return "Arthur Widgets [Demo]"; }
00059 void initialize(QDesignerFormEditorInterface *)
00060 {
00061 if (m_initialized)
00062 return;
00063 m_initialized = true;
00064 }
00065 private:
00066 bool m_initialized;
00067 };
00068
00069 class DeformPlugin : public QObject, public DemoPlugin
00070 {
00071 Q_OBJECT
00072 public:
00073 DeformPlugin(QObject *parent = 0) : QObject(parent) { }
00074
00075 QString includeFile() const { return "deform.h"; }
00076 QString name() const { return "PathDeformRendererEx"; }
00077
00078 QWidget *createWidget(QWidget *parent)
00079 {
00080 PathDeformRenderer *deform = new PathDeformRendererEx(parent);
00081 deform->setRadius(70);
00082 deform->setAnimated(false);
00083 deform->setFontSize(20);
00084 deform->setText("Arthur Widgets Demo");
00085
00086 return deform;
00087 }
00088
00089 };
00090
00091 class XFormRendererEx : public XFormView
00092 {
00093 Q_OBJECT
00094 public:
00095 XFormRendererEx(QWidget *parent) : XFormView(parent) { textEditor = new QLineEdit; }
00096 QSize sizeHint() const { return QSize(300, 200); }
00097
00098 public slots:
00099 void setText(const QString &text) { textEditor->setText(text); }
00100 };
00101
00102 class XFormPlugin : public QObject, public DemoPlugin
00103 {
00104 Q_OBJECT
00105 public:
00106 XFormPlugin(QObject *parent = 0) : QObject(parent) { }
00107 QString includeFile() const { return "xform.h"; }
00108 QString name() const { return "XFormRendererEx"; }
00109
00110 QWidget *createWidget(QWidget *parent)
00111 {
00112 XFormRendererEx *xform = new XFormRendererEx(parent);
00113 xform->setText("Qt - Hello World!!");
00114 return xform;
00115 }
00116 };
00117
00118
00119 class GradientEditorPlugin : public QObject, public DemoPlugin
00120 {
00121 Q_OBJECT
00122 public:
00123 GradientEditorPlugin(QObject *parent = 0) : QObject(parent) { }
00124 QString includeFile() const { return "gradients.h"; }
00125 QString name() const { return "GradientEditor"; }
00126
00127 QWidget *createWidget(QWidget *parent)
00128 {
00129 GradientEditor *editor = new GradientEditor(parent);
00130 return editor;
00131 }
00132 };
00133
00134 class GradientRendererEx : public GradientRenderer
00135 {
00136 Q_OBJECT
00137 public:
00138 GradientRendererEx(QWidget *p) : GradientRenderer(p) { }
00139 QSize sizeHint() const { return QSize(300, 200); }
00140 };
00141
00142 class GradientRendererPlugin : public QObject, public DemoPlugin
00143 {
00144 Q_OBJECT
00145 public:
00146 GradientRendererPlugin(QObject *parent = 0) : QObject(parent) { }
00147 QString includeFile() const { return "gradients.h"; }
00148 QString name() const { return "GradientRendererEx"; }
00149
00150 QWidget *createWidget(QWidget *parent)
00151 {
00152 GradientRenderer *renderer = new GradientRendererEx(parent);
00153 renderer->setConicalGradient();
00154 return renderer;
00155 }
00156 };
00157
00158 class PathStrokeRendererEx : public PathStrokeRenderer
00159 {
00160 Q_OBJECT
00161 public:
00162 PathStrokeRendererEx(QWidget *p) : PathStrokeRenderer(p) { }
00163 QSize sizeHint() const { return QSize(300, 200); }
00164 };
00165
00166 class StrokeRenderPlugin : public QObject, public DemoPlugin
00167 {
00168 Q_OBJECT
00169 public:
00170 StrokeRenderPlugin(QObject *parent = 0) : QObject(parent) { }
00171 QString includeFile() const { return "pathstroke.h"; }
00172 QString name() const { return "PathStrokeRendererEx"; }
00173
00174 QWidget *createWidget(QWidget *parent)
00175 {
00176 PathStrokeRenderer *stroke = new PathStrokeRendererEx(parent);
00177 return stroke;
00178 }
00179 };
00180
00181
00182 class CompositionModePlugin : public QObject, public DemoPlugin
00183 {
00184 Q_OBJECT
00185 public:
00186 CompositionModePlugin(QObject *parent = 0) : QObject(parent) { }
00187 QString includeFile() const { return "composition.h"; }
00188 QString name() const { return "CompositionRenderer"; }
00189
00190 QWidget *createWidget(QWidget *parent)
00191 {
00192 CompositionRenderer *renderer = new CompositionRenderer(parent);
00193 renderer->setAnimationEnabled(false);
00194 return renderer;
00195 }
00196 };
00197
00198
00199 class ArthurPlugins : public QObject, public QDesignerCustomWidgetCollectionInterface
00200 {
00201 Q_OBJECT
00202 Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
00203 public:
00204 QList<QDesignerCustomWidgetInterface*> customWidgets() const
00205 {
00206 QList<QDesignerCustomWidgetInterface *> plugins;
00207 plugins
00208 << new DeformPlugin
00209 << new XFormPlugin
00210 << new GradientEditorPlugin
00211 << new GradientRendererPlugin
00212 << new StrokeRenderPlugin
00213 << new CompositionModePlugin;
00214 return plugins;
00215 }
00216 };
00217
00218
00219 #include "plugin.moc"
00220
00221 Q_EXPORT_PLUGIN(ArthurPlugins)