1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:BSD$
|
---|
10 | ** You may use this file under the terms of the BSD license as follows:
|
---|
11 | **
|
---|
12 | ** "Redistribution and use in source and binary forms, with or without
|
---|
13 | ** modification, are permitted provided that the following conditions are
|
---|
14 | ** met:
|
---|
15 | ** * Redistributions of source code must retain the above copyright
|
---|
16 | ** notice, this list of conditions and the following disclaimer.
|
---|
17 | ** * Redistributions in binary form must reproduce the above copyright
|
---|
18 | ** notice, this list of conditions and the following disclaimer in
|
---|
19 | ** the documentation and/or other materials provided with the
|
---|
20 | ** distribution.
|
---|
21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
---|
22 | ** the names of its contributors may be used to endorse or promote
|
---|
23 | ** products derived from this software without specific prior written
|
---|
24 | ** permission.
|
---|
25 | **
|
---|
26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
---|
29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
---|
30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
---|
36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
---|
37 | ** $QT_END_LICENSE$
|
---|
38 | **
|
---|
39 | ****************************************************************************/
|
---|
40 |
|
---|
41 | //! [0]
|
---|
42 | CONFIG += uitools
|
---|
43 | //! [0]
|
---|
44 |
|
---|
45 |
|
---|
46 | //! [1]
|
---|
47 | #include <QtUiTools>
|
---|
48 | //! [1]
|
---|
49 |
|
---|
50 |
|
---|
51 | //! [2]
|
---|
52 | void on_<object name>_<signal name>(<signal parameters>);
|
---|
53 | //! [2]
|
---|
54 |
|
---|
55 |
|
---|
56 | //! [3]
|
---|
57 | CONFIG += release
|
---|
58 | //! [3]
|
---|
59 |
|
---|
60 |
|
---|
61 | //! [4]
|
---|
62 | target.path = $$[QT_INSTALL_PLUGINS]/designer
|
---|
63 | INSTALLS += target
|
---|
64 | //! [4]
|
---|
65 |
|
---|
66 |
|
---|
67 | //! [5]
|
---|
68 | QT += script
|
---|
69 | //! [5]
|
---|
70 |
|
---|
71 |
|
---|
72 | //! [6]
|
---|
73 | widget.text = 'Hi - I was built ' + new Date().toString();
|
---|
74 | //! [6]
|
---|
75 |
|
---|
76 |
|
---|
77 | //! [7]
|
---|
78 | class MyExtension: public QObject,
|
---|
79 | public QdesignerContainerExtension
|
---|
80 | {
|
---|
81 | Q_OBJECT
|
---|
82 | Q_INTERFACE(QDesignerContainerExtension)
|
---|
83 |
|
---|
84 | ...
|
---|
85 | }
|
---|
86 | //! [7]
|
---|
87 |
|
---|
88 |
|
---|
89 | //! [8]
|
---|
90 | QObject *ANewExtensionFactory::createExtension(QObject *object,
|
---|
91 | const QString &iid, QObject *parent) const
|
---|
92 | {
|
---|
93 | if (iid != Q_TYPEID(QDesignerContainerExtension))
|
---|
94 | return 0;
|
---|
95 |
|
---|
96 | if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
|
---|
97 | (object))
|
---|
98 | return new MyContainerExtension(widget, parent);
|
---|
99 |
|
---|
100 | return 0;
|
---|
101 | }
|
---|
102 | //! [8]
|
---|
103 |
|
---|
104 |
|
---|
105 | //! [9]
|
---|
106 | QObject *AGeneralExtensionFactory::createExtension(QObject *object,
|
---|
107 | const QString &iid, QObject *parent) const
|
---|
108 | {
|
---|
109 | MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
|
---|
110 |
|
---|
111 | if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
|
---|
112 | return new MyTaskMenuExtension(widget, parent);
|
---|
113 |
|
---|
114 | } else if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) {
|
---|
115 | return new MyContainerExtension(widget, parent);
|
---|
116 |
|
---|
117 | } else {
|
---|
118 | return 0;
|
---|
119 | }
|
---|
120 | }
|
---|
121 | //! [9]
|
---|
122 |
|
---|
123 |
|
---|
124 | //! [10]
|
---|
125 | void MyPlugin::initialize(QDesignerFormEditorInterface *formEditor)
|
---|
126 | {
|
---|
127 | if (initialized)
|
---|
128 | return;
|
---|
129 |
|
---|
130 | QExtensionManager *manager = formEditor->extensionManager();
|
---|
131 | Q_ASSERT(manager != 0);
|
---|
132 |
|
---|
133 | manager->registerExtensions(new MyExtensionFactory(manager),
|
---|
134 | Q_TYPEID(QDesignerTaskMenuExtension));
|
---|
135 |
|
---|
136 | initialized = true;
|
---|
137 | }
|
---|
138 | //! [10]
|
---|