Changeset View
Changeset View
Standalone View
Standalone View
modules/ECMAddQtDesignerPlugin.cmake
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
67 | # ecm_qtdesignerplugin_widget(<widgetid> | 67 | # ecm_qtdesignerplugin_widget(<widgetid> | ||
68 | # [CLASS_NAME <class_name>] | 68 | # [CLASS_NAME <class_name>] | ||
69 | # [INCLUDE_FILE <include_file>] | 69 | # [INCLUDE_FILE <include_file>] | ||
70 | # [CONTAINER] | 70 | # [CONTAINER] | ||
71 | # [ICON <iconfile>] | 71 | # [ICON <iconfile>] | ||
72 | # [TOOLTIP <tooltip>] | 72 | # [TOOLTIP <tooltip>] | ||
73 | # [WHATSTHIS <whatsthis>] | 73 | # [WHATSTHIS <whatsthis>] | ||
74 | # [GROUP <group>] | 74 | # [GROUP <group>] | ||
75 | # [CREATE_WIDGET_CODE <create_widget_code>] | 75 | # [CREATE_WIDGET_CODE_FROM_VARIABLE <create_widget_code_variable>] | ||
76 | # [INITIALIZE_CODE <initialize_code] | 76 | # [INITIALIZE_CODE_FROM_VARIABLE <initialize_code_variable] | ||
77 | # [DOM_XML <dom_xml>] | 77 | # [DOM_XML_FROM_VARIABLE <dom_xml_variable>] | ||
78 | # [IMPL_CLASS_NAME <impl_class_name>] | 78 | # [IMPL_CLASS_NAME <impl_class_name>] | ||
79 | # [CONSTRUCTOR_ARGS_CODE <constructor_args_code>] | 79 | # [CONSTRUCTOR_ARGS_CODE <constructor_args_code>] | ||
80 | # [CONSTRUCTOR_ARGS_CODE_FROM_VARIABLE <constructor_args_code_variable>] | ||||
80 | # ) | 81 | # ) | ||
81 | # | 82 | # | ||
82 | # ``CLASS_NAME`` specifies the name of the widget class, including namespaces. | 83 | # ``CLASS_NAME`` specifies the name of the widget class, including namespaces. | ||
83 | # The default is "<widgetid>". | 84 | # The default is "<widgetid>". | ||
84 | # | 85 | # | ||
85 | # ``INCLUDE_FILE`` specifies the include file to use for the class of this | 86 | # ``INCLUDE_FILE`` specifies the include file to use for the class of this | ||
86 | # widget. The default is derived from <class_name> as configured by the | 87 | # widget. The default is derived from <class_name> as configured by the | ||
87 | # ``DEFAULT_HEADER_*`` options of ``ecm_add_qtdesignerplugin``, also replacing | 88 | # ``DEFAULT_HEADER_*`` options of ``ecm_add_qtdesignerplugin``, also replacing | ||
Show All 12 Lines | |||||
100 | # | 101 | # | ||
101 | # ``WHATSTHIS`` specifies the What's-This text to use for this widget. | 102 | # ``WHATSTHIS`` specifies the What's-This text to use for this widget. | ||
102 | # Defaults to the tooltip. | 103 | # Defaults to the tooltip. | ||
103 | # | 104 | # | ||
104 | # ``GROUP`` specifies the group in Qt Designer where the widget will be placed. | 105 | # ``GROUP`` specifies the group in Qt Designer where the widget will be placed. | ||
105 | # The default is set as configured by the ``DEFAULT_GROUP`` option of | 106 | # The default is set as configured by the ``DEFAULT_GROUP`` option of | ||
106 | # ``ecm_add_qtdesignerplugin``. | 107 | # ``ecm_add_qtdesignerplugin``. | ||
107 | # | 108 | # | ||
108 | # ``CREATE_WIDGET_CODE`` specifies C++ code to use as factory code to create | 109 | # ``CREATE_WIDGET_CODE_FROM_VARIABLE`` specifies the variable to get from the | ||
109 | # an instance of the widget, for the override of | 110 | # C++ code to use as factory code to create an instance of the widget, | ||
111 | # for the override of | ||||
110 | # ``QDesignerCustomWidgetInterface::createWidget(QWidget* parent)``. | 112 | # ``QDesignerCustomWidgetInterface::createWidget(QWidget* parent)``. | ||
111 | # Replace any occurence of ";" with "@SEMICOLON@", as needed to pass the raw | 113 | # The default is "return new <impl_class_name><constructor_args_code>;". | ||
112 | # code via CMake. The default is | | |||
113 | # "return new <impl_class_name><constructor_args_code>;". | | |||
114 | # | 114 | # | ||
115 | # ``INITIALIZE_CODE`` specifies C++ code to use with the override of | 115 | # ``INITIALIZE_CODE_FROM_VARIABLE`` specifies the variable to get from the C++ | ||
116 | # code to use with the override of | ||||
116 | # ``QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface* core)``. | 117 | # ``QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface* core)``. | ||
117 | # The code has to use the present class member ``m_initialized`` to track and | 118 | # The code has to use the present class member ``m_initialized`` to track and | ||
118 | # update the state. Replace any occurence of ";" with "@SEMICOLON@", as needed | 119 | # update the state. The default code simply sets ``m_initialized`` to | ||
119 | # to pass the raw code via CMake. The default code simply sets | 120 | # ``true``, if it was not before. | ||
120 | # ``m_initialized`` to ``true``, if it was not before. | 121 | # | ||
121 | # | 122 | # ``DOM_XML_FROM_VARIABLE`` specifies the variable to get from the string to | ||
122 | # ``DOM_XML`` specifies the string to use with the optional override of | 123 | # use with the optional override of | ||
123 | # ``QDesignerCustomWidgetInterface::domXml()``. Replace any occurence of ";" | 124 | # ``QDesignerCustomWidgetInterface::domXml()``. | ||
124 | # with "@SEMICOLON@", as needed to pass the raw XML string via CMake. | | |||
125 | # Default does not override. | 125 | # Default does not override. | ||
126 | # | 126 | # | ||
127 | # ``IMPL_CLASS_NAME`` specifies the name of the widget class to use for the | 127 | # ``IMPL_CLASS_NAME`` specifies the name of the widget class to use for the | ||
128 | # widget instance with Qt Designer. The default is "<class_name>". | 128 | # widget instance with Qt Designer. The default is "<class_name>". | ||
129 | # | 129 | # | ||
130 | # ``CONSTRUCTOR_ARGS_CODE`` specifies the C++ code to use for the constructor | 130 | # ``CONSTRUCTOR_ARGS_CODE`` specifies the C++ code to use for the constructor | ||
131 | # arguments with the default of <create_widget_code>. Note that the | 131 | # arguments with the default of ``CREATE_WIDGET_CODE_FROM_VARIABLE``. Note | ||
132 | # parentheses are required. The default is "(parent)". | 132 | # that the parentheses are required. The default is "(parent)". | ||
133 | # | ||||
134 | # ``CONSTRUCTOR_ARGS_CODE_FROM_VARIABLE`` specifies the variable to get from | ||||
135 | # the C++ code instead of passing it directly via ``CONSTRUCTOR_ARGS_CODE``. | ||||
136 | # This can be needed if the code is more complex and e.g. includes ";" chars. | ||||
133 | # | 137 | # | ||
134 | # | 138 | # | ||
135 | # | 139 | # | ||
136 | # Example usage: | 140 | # Example usage: | ||
137 | # | 141 | # | ||
138 | # .. code-block:: cmake | 142 | # .. code-block:: cmake | ||
139 | # | 143 | # | ||
140 | # ecm_qtdesignerplugin_widget(FooWidget | 144 | # ecm_qtdesignerplugin_widget(FooWidget | ||
141 | # TOOLTIP "Enables to browse foo." | 145 | # TOOLTIP "Enables to browse foo." | ||
142 | # GROUP "Views (Foo)" | 146 | # GROUP "Views (Foo)" | ||
143 | # ) | 147 | # ) | ||
144 | # | 148 | # | ||
149 | # set(BarWidget_CREATE_WIDGET_CODE | ||||
150 | # " | ||||
151 | # auto* widget = new BarWidget(parent); | ||||
152 | # widget->setBar("Example bar"); | ||||
153 | # return widget; | ||||
154 | # ") | ||||
155 | # | ||||
145 | # ecm_qtdesignerplugin_widget(BarWidget | 156 | # ecm_qtdesignerplugin_widget(BarWidget | ||
146 | # TOOLTIP "Displays bars." | 157 | # TOOLTIP "Displays bars." | ||
147 | # GROUP "Display (Foo)" | 158 | # GROUP "Display (Foo)" | ||
159 | # CREATE_WIDGET_CODE_FROM_VARIABLE BarWidget_CREATE_WIDGET_CODE | ||||
148 | # ) | 160 | # ) | ||
149 | # | 161 | # | ||
150 | # ecm_add_qtdesignerplugin(foowidgets | 162 | # ecm_add_qtdesignerplugin(foowidgets | ||
151 | # NAME FooWidgets | 163 | # NAME FooWidgets | ||
152 | # OUTPUT_NAME foo2widgets | 164 | # OUTPUT_NAME foo2widgets | ||
153 | # WIDGETS | 165 | # WIDGETS | ||
154 | # FooWidget | 166 | # FooWidget | ||
155 | # BarWidget | 167 | # BarWidget | ||
Show All 29 Lines | |||||
185 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 197 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
186 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 198 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
187 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 199 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
188 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 200 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
189 | 201 | | |||
190 | include(CMakeParseArguments) | 202 | include(CMakeParseArguments) | ||
191 | 203 | | |||
192 | # helper method | 204 | # helper method | ||
193 | # unescapes "@SEMICOLON@" into ";" | | |||
194 | function(_ecm_qtdesignerplugin_unescape_code _varName input) | | |||
195 | string(REPLACE "@SEMICOLON@" ";" _code ${input}) | | |||
196 | set(${_varName} "${_code}" PARENT_SCOPE) | | |||
197 | endfunction() | | |||
198 | | ||||
199 | # helper method | | |||
200 | # escapes string for C++ code | 205 | # escapes string for C++ code | ||
201 | function(_ecm_qtdesignerplugin_escape_cpp_string _varName input) | 206 | function(_ecm_qtdesignerplugin_escape_cpp_string _varName input) | ||
202 | string(REPLACE "\"" "\\\"" _string ${input}) | 207 | string(REPLACE "\"" "\\\"" _string ${input}) | ||
203 | set(${_varName} "${_string}" PARENT_SCOPE) | 208 | set(${_varName} "${_string}" PARENT_SCOPE) | ||
204 | endfunction() | 209 | endfunction() | ||
205 | 210 | | |||
206 | # To make the data about the widgets available to the function ecm_add_qtdesignerplugin, | 211 | # To make the data about the widgets available to the function ecm_add_qtdesignerplugin, | ||
207 | # variables are created in the scope of the caller of this method, protected by | 212 | # variables are created in the scope of the caller of this method, protected by | ||
208 | # a namespace for this macro file, and otherwise from the widget id and the property id: | 213 | # a namespace for this macro file, and otherwise from the widget id and the property id: | ||
209 | # ECM_QTDESIGNERPLUGIN_${widget}_${property} | 214 | # ECM_QTDESIGNERPLUGIN_${widget}_${property} | ||
210 | function(ecm_qtdesignerplugin_widget widget) | 215 | function(ecm_qtdesignerplugin_widget widget) | ||
211 | set(options | 216 | set(options | ||
212 | CONTAINER | 217 | CONTAINER | ||
213 | ) | 218 | ) | ||
214 | set(oneValueArgs | 219 | set(oneValueArgs | ||
215 | CLASS_NAME | 220 | CLASS_NAME | ||
216 | INCLUDE_FILE | 221 | INCLUDE_FILE | ||
217 | ICON | 222 | ICON | ||
218 | TOOLTIP | 223 | TOOLTIP | ||
219 | WHATSTHIS | 224 | WHATSTHIS | ||
220 | GROUP | 225 | GROUP | ||
221 | CREATE_WIDGET_CODE | 226 | CREATE_WIDGET_CODE_FROM_VARIABLE | ||
222 | INITIALIZE_CODE | 227 | INITIALIZE_CODE_FROM_VARIABLE | ||
223 | DOM_XML | 228 | DOM_XML_FROM_VARIABLE | ||
224 | IMPL_CLASS_NAME | 229 | IMPL_CLASS_NAME | ||
225 | CONSTRUCTOR_ARGS_CODE | 230 | CONSTRUCTOR_ARGS_CODE | ||
231 | CONSTRUCTOR_ARGS_CODE_FROM_VARIABLE | ||||
226 | ) | 232 | ) | ||
227 | set(multiValueArgs | 233 | set(multiValueArgs | ||
228 | ) | 234 | ) | ||
229 | cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | 235 | cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
230 | 236 | | |||
231 | if(NOT ARGS_CLASS_NAME) | 237 | if(NOT ARGS_CLASS_NAME) | ||
232 | set(ARGS_CLASS_NAME "${widget}") | 238 | set(ARGS_CLASS_NAME "${widget}") | ||
233 | endif() | 239 | endif() | ||
234 | if(NOT ARGS_TOOLTIP) | 240 | if(NOT ARGS_TOOLTIP) | ||
235 | set(ARGS_TOOLTIP "${ARGS_CLASS_NAME} Widget") | 241 | set(ARGS_TOOLTIP "${ARGS_CLASS_NAME} Widget") | ||
236 | endif() | 242 | endif() | ||
237 | if(NOT ARGS_WHATSTHIS) | 243 | if(NOT ARGS_WHATSTHIS) | ||
238 | set(ARGS_WHATSTHIS "${ARGS_TOOLTIP}") | 244 | set(ARGS_WHATSTHIS "${ARGS_TOOLTIP}") | ||
239 | endif() | 245 | endif() | ||
240 | if(ARGS_CONTAINER) | 246 | if(ARGS_CONTAINER) | ||
241 | set(_is_container TRUE) | 247 | set(_is_container TRUE) | ||
242 | else() | 248 | else() | ||
243 | set(_is_container FALSE) | 249 | set(_is_container FALSE) | ||
244 | endif() | 250 | endif() | ||
245 | if(NOT ARGS_CREATE_WIDGET_CODE) | 251 | if(ARGS_CONSTRUCTOR_ARGS_CODE AND ARGS_CONSTRUCTOR_ARGS_CODE_FROM_VARIABLE) | ||
252 | message(FATAL_ERROR "Either CONSTRUCTOR_ARGS_CODE or CONSTRUCTOR_ARGS_CODE_FROM_VARIABLE can be passed when calling ecm_qtdesignerplugin_widget().") | ||||
253 | endif() | ||||
254 | if(NOT ARGS_CREATE_WIDGET_CODE_FROM_VARIABLE) | ||||
246 | if(NOT ARGS_IMPL_CLASS_NAME) | 255 | if(NOT ARGS_IMPL_CLASS_NAME) | ||
247 | set(ARGS_IMPL_CLASS_NAME "${ARGS_CLASS_NAME}") | 256 | set(ARGS_IMPL_CLASS_NAME "${ARGS_CLASS_NAME}") | ||
248 | endif() | 257 | endif() | ||
249 | if(NOT ARGS_CONSTRUCTOR_ARGS_CODE) | 258 | if(ARGS_CONSTRUCTOR_ARGS_CODE_FROM_VARIABLE) | ||
250 | set(ARGS_CONSTRUCTOR_ARGS_CODE "(parent)") | 259 | set(_constructor_args "${${ARGS_CONSTRUCTOR_ARGS_CODE_FROM_VARIABLE}}") | ||
260 | elseif(ARGS_CONSTRUCTOR_ARGS_CODE) | ||||
261 | set(_constructor_args "${ARGS_CONSTRUCTOR_ARGS_CODE}") | ||||
262 | else() | ||||
263 | set(_constructor_args "(parent)") | ||||
251 | endif() | 264 | endif() | ||
252 | set(ARGS_CREATE_WIDGET_CODE " return new ${ARGS_IMPL_CLASS_NAME}${ARGS_CONSTRUCTOR_ARGS_CODE};") | 265 | set(_create_widget_code " return new ${ARGS_IMPL_CLASS_NAME}${_constructor_args};") | ||
253 | else() | 266 | else() | ||
254 | _ecm_qtdesignerplugin_unescape_code(ARGS_CREATE_WIDGET_CODE "${ARGS_CREATE_WIDGET_CODE}") | 267 | set(_create_widget_code "${${ARGS_CREATE_WIDGET_CODE_FROM_VARIABLE}}") | ||
255 | endif() | 268 | endif() | ||
256 | if(ARGS_ICON) | 269 | if(ARGS_ICON) | ||
257 | if (NOT IS_ABSOLUTE ${ARGS_ICON}) | 270 | if (NOT IS_ABSOLUTE ${ARGS_ICON}) | ||
258 | set(ARGS_ICON "${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_ICON}") | 271 | set(ARGS_ICON "${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_ICON}") | ||
259 | endif() | 272 | endif() | ||
260 | if(NOT EXISTS "${ARGS_ICON}") | 273 | if(NOT EXISTS "${ARGS_ICON}") | ||
261 | message(FATAL_ERROR "No such file as passed with ICON when calling ecm_qtdesignerplugin_widget(): ${ARGS_ICON}") | 274 | message(FATAL_ERROR "No such file as passed with ICON when calling ecm_qtdesignerplugin_widget(): ${ARGS_ICON}") | ||
262 | endif() | 275 | endif() | ||
263 | endif() | 276 | endif() | ||
264 | 277 | | |||
265 | # store data about widget, so ecm_add_qtdesignerplugin can access it | 278 | # store data about widget, so ecm_add_qtdesignerplugin can access it | ||
266 | set(ECM_QTDESIGNERPLUGIN_${widget}_CLASS_NAME "${ARGS_CLASS_NAME}" PARENT_SCOPE) | 279 | set(ECM_QTDESIGNERPLUGIN_${widget}_CLASS_NAME "${ARGS_CLASS_NAME}" PARENT_SCOPE) | ||
267 | set(ECM_QTDESIGNERPLUGIN_${widget}_INCLUDE_FILE "${ARGS_INCLUDE_FILE}" PARENT_SCOPE) | 280 | set(ECM_QTDESIGNERPLUGIN_${widget}_INCLUDE_FILE "${ARGS_INCLUDE_FILE}" PARENT_SCOPE) | ||
268 | set(ECM_QTDESIGNERPLUGIN_${widget}_TOOLTIP "${ARGS_TOOLTIP}" PARENT_SCOPE) | 281 | set(ECM_QTDESIGNERPLUGIN_${widget}_TOOLTIP "${ARGS_TOOLTIP}" PARENT_SCOPE) | ||
269 | set(ECM_QTDESIGNERPLUGIN_${widget}_WHATSTHIS "${ARGS_WHATSTHIS}" PARENT_SCOPE) | 282 | set(ECM_QTDESIGNERPLUGIN_${widget}_WHATSTHIS "${ARGS_WHATSTHIS}" PARENT_SCOPE) | ||
270 | set(ECM_QTDESIGNERPLUGIN_${widget}_GROUP "${ARGS_GROUP}" PARENT_SCOPE) | 283 | set(ECM_QTDESIGNERPLUGIN_${widget}_GROUP "${ARGS_GROUP}" PARENT_SCOPE) | ||
271 | set(ECM_QTDESIGNERPLUGIN_${widget}_ICON "${ARGS_ICON}" PARENT_SCOPE) | 284 | set(ECM_QTDESIGNERPLUGIN_${widget}_ICON "${ARGS_ICON}" PARENT_SCOPE) | ||
272 | set(ECM_QTDESIGNERPLUGIN_${widget}_IS_CONTAINER "${_is_container}" PARENT_SCOPE) | 285 | set(ECM_QTDESIGNERPLUGIN_${widget}_IS_CONTAINER "${_is_container}" PARENT_SCOPE) | ||
273 | set(ECM_QTDESIGNERPLUGIN_${widget}_CREATE_WIDGET_CODE "${ARGS_CREATE_WIDGET_CODE}" PARENT_SCOPE) | 286 | set(ECM_QTDESIGNERPLUGIN_${widget}_CREATE_WIDGET_CODE "${_create_widget_code}" PARENT_SCOPE) | ||
274 | set(ECM_QTDESIGNERPLUGIN_${widget}_INITIALIZE_CODE "${ARGS_INITIALIZE_CODE}" PARENT_SCOPE) | 287 | set(ECM_QTDESIGNERPLUGIN_${widget}_INITIALIZE_CODE "${${INITIALIZE_CODE_FROM_VARIABLE}}" PARENT_SCOPE) | ||
275 | set(ECM_QTDESIGNERPLUGIN_${widget}_DOM_XML "${ARGS_DOM_XML}" PARENT_SCOPE) | 288 | set(ECM_QTDESIGNERPLUGIN_${widget}_DOM_XML "${${ARGS_DOM_XML_FROM_VARIABLE}}" PARENT_SCOPE) | ||
276 | endfunction() | 289 | endfunction() | ||
277 | 290 | | |||
278 | # helper method | 291 | # helper method | ||
279 | function(_ecm_qtdesignerplugin_write_widget designer_src_file widget default_group rc_icon_dir) | 292 | function(_ecm_qtdesignerplugin_write_widget designer_src_file widget default_group rc_icon_dir) | ||
280 | # prepare data | 293 | # prepare data | ||
281 | set(_classname "${ECM_QTDESIGNERPLUGIN_${widget}_CLASS_NAME}") | 294 | set(_classname "${ECM_QTDESIGNERPLUGIN_${widget}_CLASS_NAME}") | ||
282 | set(_factory_classname "${_classname}QtDesignerWidgetFactory") | 295 | set(_factory_classname "${_classname}QtDesignerWidgetFactory") | ||
283 | string(REPLACE "::" "__" _factory_classname "${_factory_classname}") | 296 | string(REPLACE "::" "__" _factory_classname "${_factory_classname}") | ||
284 | set(ECM_QTDESIGNERPLUGIN_${widget}_FACTORY_CLASS_NAME "${_factory_classname}" PARENT_SCOPE) | 297 | set(ECM_QTDESIGNERPLUGIN_${widget}_FACTORY_CLASS_NAME "${_factory_classname}" PARENT_SCOPE) | ||
285 | if(ECM_QTDESIGNERPLUGIN_${widget}_IS_CONTAINER) | 298 | if(ECM_QTDESIGNERPLUGIN_${widget}_IS_CONTAINER) | ||
286 | set(_is_container "true") | 299 | set(_is_container "true") | ||
287 | else() | 300 | else() | ||
288 | set(_is_container "false") | 301 | set(_is_container "false") | ||
289 | endif() | 302 | endif() | ||
290 | _ecm_qtdesignerplugin_escape_cpp_string(_tooltip "${ECM_QTDESIGNERPLUGIN_${widget}_TOOLTIP}") | 303 | _ecm_qtdesignerplugin_escape_cpp_string(_tooltip "${ECM_QTDESIGNERPLUGIN_${widget}_TOOLTIP}") | ||
291 | _ecm_qtdesignerplugin_escape_cpp_string(_whatsthis "${ECM_QTDESIGNERPLUGIN_${widget}_WHATSTHIS}") | 304 | _ecm_qtdesignerplugin_escape_cpp_string(_whatsthis "${ECM_QTDESIGNERPLUGIN_${widget}_WHATSTHIS}") | ||
292 | set(_group ${ECM_QTDESIGNERPLUGIN_${widget}_GROUP}) | 305 | set(_group ${ECM_QTDESIGNERPLUGIN_${widget}_GROUP}) | ||
293 | if(NOT _group) | 306 | if(NOT _group) | ||
294 | set(_group "${default_group}") | 307 | set(_group "${default_group}") | ||
295 | endif() | 308 | endif() | ||
296 | _ecm_qtdesignerplugin_escape_cpp_string(_group "${_group}") | 309 | _ecm_qtdesignerplugin_escape_cpp_string(_group "${_group}") | ||
297 | set(_dom_xml "${ECM_QTDESIGNERPLUGIN_${widget}_DOM_XML}") | 310 | set(_dom_xml "${ECM_QTDESIGNERPLUGIN_${widget}_DOM_XML}") | ||
298 | if(_dom_xml) | 311 | if(_dom_xml) | ||
299 | _ecm_qtdesignerplugin_unescape_code(_dom_xml "${_dom_xml}") | | |||
300 | string(REPLACE "\"" "\\\"" _dom_xml "${_dom_xml}") | 312 | string(REPLACE "\"" "\\\"" _dom_xml "${_dom_xml}") | ||
301 | set(_dom_xml_method " QString domXml() const override { return QStringLiteral(\"${_dom_xml}\"); }") | 313 | set(_dom_xml_method " QString domXml() const override { return QStringLiteral(\"${_dom_xml}\"); }") | ||
302 | else() | 314 | else() | ||
303 | set(_dom_xml_method) | 315 | set(_dom_xml_method) | ||
304 | endif() | 316 | endif() | ||
305 | set(_icon "${ECM_QTDESIGNERPLUGIN_${widget}_ICON}") | 317 | set(_icon "${ECM_QTDESIGNERPLUGIN_${widget}_ICON}") | ||
306 | if(_icon) | 318 | if(_icon) | ||
307 | get_filename_component(_icon_filename ${_icon} NAME) | 319 | get_filename_component(_icon_filename ${_icon} NAME) | ||
308 | set(_icon_construct "QIcon(QStringLiteral(\":${rc_icon_dir}/${_icon_filename}\"))") | 320 | set(_icon_construct "QIcon(QStringLiteral(\":${rc_icon_dir}/${_icon_filename}\"))") | ||
309 | else() | 321 | else() | ||
310 | set(_icon_construct "QIcon()") | 322 | set(_icon_construct "QIcon()") | ||
311 | endif() | 323 | endif() | ||
312 | set(_initialize_code "${ECM_QTDESIGNERPLUGIN_${widget}_INITIALIZE_CODE}") | 324 | set(_initialize_code "${ECM_QTDESIGNERPLUGIN_${widget}_INITIALIZE_CODE}") | ||
313 | if(NOT _initialize_code) | 325 | if(NOT _initialize_code) | ||
314 | set(_initialize_code | 326 | set(_initialize_code | ||
315 | " Q_UNUSED(core); | 327 | " Q_UNUSED(core); | ||
316 | 328 | | |||
317 | if (m_initialized) return; | 329 | if (m_initialized) return; | ||
318 | 330 | | |||
319 | m_initialized = true;" | 331 | m_initialized = true;" | ||
320 | ) | 332 | ) | ||
321 | else() | | |||
322 | _ecm_qtdesignerplugin_unescape_code(_initialize_code "${_initialize_code}") | | |||
323 | endif() | 333 | endif() | ||
324 | 334 | | |||
325 | # write code | 335 | # write code | ||
326 | file(APPEND ${designer_src_file} " | 336 | file(APPEND ${designer_src_file} " | ||
327 | class ${_factory_classname} | 337 | class ${_factory_classname} | ||
328 | : public QObject | 338 | : public QObject | ||
329 | , public QDesignerCustomWidgetInterface | 339 | , public QDesignerCustomWidgetInterface | ||
330 | { | 340 | { | ||
▲ Show 20 Lines • Show All 335 Lines • Show Last 20 Lines |