1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the Qt Designer of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #include "abstractformwindowmanager.h"
30 
31 #include <QtCore/qmap.h>
32 
33 QT_BEGIN_NAMESPACE
34 
35 /*!
36     \class QDesignerFormWindowManagerInterface
37 
38     \brief The QDesignerFormWindowManagerInterface class allows you to
39     manipulate the collection of form windows in Qt Designer, and
40     control Qt Designer's form editing actions.
41 
42     \inmodule QtDesigner
43 
44     QDesignerFormWindowManagerInterface is not intended to be
45     instantiated directly. \QD uses the form window manager to
46     control the various form windows in its workspace. You can
47     retrieve an interface to \QD's form window manager using
48     the QDesignerFormEditorInterface::formWindowManager()
49     function. For example:
50 
51     \snippet lib/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp 0
52 
53     When implementing a custom widget plugin, a pointer to \QD's
54     current QDesignerFormEditorInterface object (\c formEditor in the
55     example above) is provided by the
56     QDesignerCustomWidgetInterface::initialize() function's parameter.
57     You must subclass the QDesignerCustomWidgetInterface to expose
58     your plugin to Qt Designer.
59 
60     The form window manager interface provides the createFormWindow()
61     function that enables you to create a new form window which you
62     can add to the collection of form windows that the manager
63     maintains, using the addFormWindow() slot. It also provides the
64     formWindowCount() function returning the number of form windows
65     currently under the manager's control, the formWindow() function
66     returning the form window associated with a given index, and the
67     activeFormWindow() function returning the currently selected form
68     window. The removeFormWindow() slot allows you to reduce the
69     number of form windows the manager must maintain, and the
70     setActiveFormWindow() slot allows you to change the form window
71     focus in \QD's workspace.
72 
73     In addition, QDesignerFormWindowManagerInterface contains a
74     collection of functions that enables you to intervene and control
75     \QD's form editing actions. All these functions return the
76     original action, making it possible to propagate the function
77     further after intervention.
78 
79     Finally, the interface provides three signals which are emitted
80     when a form window is added, when the currently selected form
81     window changes, or when a form window is removed, respectively. All
82     the signals carry the form window in question as their parameter.
83 
84     \sa QDesignerFormEditorInterface, QDesignerFormWindowInterface
85 */
86 
87 /*!
88     \enum QDesignerFormWindowManagerInterface::Action
89 
90     Specifies an action of \QD.
91 
92     \sa action()
93 
94     \since 5.0
95     \value CutAction         Clipboard Cut
96     \value CopyAction        Clipboard Copy
97     \value PasteAction       Clipboard Paste
98     \value DeleteAction      Clipboard Delete
99     \value SelectAllAction   Select All
100     \value LowerAction       Lower current widget
101     \value RaiseAction       Raise current widget
102     \value UndoAction        Undo
103     \value RedoAction        Redo
104     \value HorizontalLayoutAction Lay out using QHBoxLayout
105     \value VerticalLayoutAction   Lay out using QVBoxLayout
106     \value SplitHorizontalAction  Lay out in horizontal QSplitter
107     \value SplitVerticalAction    Lay out in vertical QSplitter
108     \value GridLayoutAction       Lay out using QGridLayout
109     \value FormLayoutAction       Lay out using QFormLayout
110     \value BreakLayoutAction      Break existing layout
111     \value AdjustSizeAction       Adjust size
112     \value SimplifyLayoutAction   Simplify QGridLayout or QFormLayout
113     \value DefaultPreviewAction   Create a preview in default style
114     \value FormWindowSettingsDialogAction Show dialog with form settings
115 */
116 
117 /*!
118     \enum QDesignerFormWindowManagerInterface::ActionGroup
119 
120     Specifies an action group of \QD.
121 
122     \sa actionGroup()
123     \since 5.0
124     \value StyledPreviewActionGroup Action group containing styled preview actions
125 */
126 
127 /*!
128     Constructs an interface with the given \a parent for the form window
129     manager.
130 */
QDesignerFormWindowManagerInterface(QObject * parent)131 QDesignerFormWindowManagerInterface::QDesignerFormWindowManagerInterface(QObject *parent)
132     : QObject(parent)
133 {
134 }
135 
136 /*!
137     Destroys the interface for the form window manager.
138 */
139 QDesignerFormWindowManagerInterface::~QDesignerFormWindowManagerInterface() = default;
140 
141 /*!
142     Allows you to intervene and control \QD's "cut" action. The function
143     returns the original action.
144 
145     \sa QAction
146     \obsolete
147 
148     Use action() instead.
149 */
150 #if QT_CONFIG(clipboard)
actionCut() const151 QAction *QDesignerFormWindowManagerInterface::actionCut() const
152 {
153     return action(CutAction);
154 }
155 #endif
156 
157 /*!
158     Allows you to intervene and control \QD's "copy" action. The
159     function returns the original action.
160 
161     \sa QAction
162     \obsolete
163 
164     Use action() instead.
165 */
166 #if QT_CONFIG(clipboard)
actionCopy() const167 QAction *QDesignerFormWindowManagerInterface::actionCopy() const
168 {
169     return action(CopyAction);
170 }
171 #endif
172 
173 /*!
174     Allows you to intervene and control \QD's "paste" action. The
175     function returns the original action.
176 
177     \sa QAction
178     \obsolete
179 
180     Use action() instead.
181 */
182 #if QT_CONFIG(clipboard)
actionPaste() const183 QAction *QDesignerFormWindowManagerInterface::actionPaste() const
184 {
185     return action(PasteAction);
186 }
187 #endif
188 
189 /*!
190     Allows you to intervene and control \QD's "delete" action. The function
191     returns the original action.
192 
193     \sa QAction
194     \obsolete
195 
196     Use action() instead.
197 */
actionDelete() const198 QAction *QDesignerFormWindowManagerInterface::actionDelete() const
199 {
200     return action(DeleteAction);
201 }
202 
203 /*!
204     Allows you to intervene and control \QD's "select all" action. The
205     function returns the original action.
206 
207     \sa QAction
208     \obsolete
209 
210     Use action() instead.
211 */
actionSelectAll() const212 QAction *QDesignerFormWindowManagerInterface::actionSelectAll() const
213 {
214     return action(SelectAllAction);
215 }
216 
217 /*!
218     Allows you to intervene and control the action of lowering a form
219     window in \QD's workspace. The function returns the original
220     action.
221 
222     \sa QAction
223     \obsolete
224 
225     Use action() instead.
226 */
227 
actionLower() const228 QAction *QDesignerFormWindowManagerInterface::actionLower() const
229 {
230     return action(LowerAction);
231 }
232 
233 /*!
234     Allows you to intervene and control the action of raising of a
235     form window in \QD's workspace. The function returns the original
236     action.
237 
238     \sa QAction
239     \obsolete
240 
241     Use action() instead.
242 */
actionRaise() const243 QAction *QDesignerFormWindowManagerInterface::actionRaise() const
244 {
245     return action(RaiseAction);
246 }
247 
248 /*!
249     Allows you to intervene and control a request for horizontal
250     layout for a form window in \QD's workspace. The function returns
251     the original action.
252 
253     \sa QAction
254     \obsolete
255 
256     Use action() instead.
257 */
actionHorizontalLayout() const258 QAction *QDesignerFormWindowManagerInterface::actionHorizontalLayout() const
259 {
260     return action(HorizontalLayoutAction);
261 }
262 
263 /*!
264     Allows you to intervene and control a request for vertical layout
265     for a form window in \QD's workspace. The function returns the
266     original action.
267 
268     \sa QAction
269     \obsolete
270 
271     Use action() instead.
272 */
actionVerticalLayout() const273 QAction *QDesignerFormWindowManagerInterface::actionVerticalLayout() const
274 {
275     return action(VerticalLayoutAction);
276 }
277 
278 /*!
279     Allows you to intervene and control \QD's "split horizontal"
280     action. The function returns the original action.
281 
282     \sa QAction
283     \obsolete
284 
285     Use action() instead.
286 */
actionSplitHorizontal() const287 QAction *QDesignerFormWindowManagerInterface::actionSplitHorizontal() const
288 {
289     return action(SplitHorizontalAction);
290 }
291 
292 /*!
293     Allows you to intervene and control \QD's "split vertical"
294     action. The function returns the original action.
295 
296     \sa QAction
297     \obsolete
298 
299     Use action() instead.
300 */
actionSplitVertical() const301 QAction *QDesignerFormWindowManagerInterface::actionSplitVertical() const
302 {
303     return action(SplitVerticalAction);
304 }
305 
306 /*!
307     Allows you to intervene and control a request for grid layout for
308     a form window in \QD's workspace. The function returns the
309     original action.
310 
311     \sa QAction
312     \obsolete
313 
314     Use action() instead.
315 */
actionGridLayout() const316 QAction *QDesignerFormWindowManagerInterface::actionGridLayout() const
317 {
318     return action(GridLayoutAction);
319 }
320 
321 /*!
322     Allows you to intervene and control \QD's "form layout" action. The
323     function returns the original action.
324 
325     \sa QAction
326     \since 4.4
327     \obsolete
328 
329     Use action() instead.
330 */
331 
actionFormLayout() const332 QAction *QDesignerFormWindowManagerInterface::actionFormLayout() const
333 {
334     return action(FormLayoutAction);
335 }
336 
337 /*!
338     Allows you to intervene and control \QD's "break layout" action. The
339     function returns the original action.
340 
341     \sa QAction
342     \obsolete
343 
344     Use action() instead.
345 */
actionBreakLayout() const346 QAction *QDesignerFormWindowManagerInterface::actionBreakLayout() const
347 {
348     return action(BreakLayoutAction);
349 }
350 
351 /*!
352     Allows you to intervene and control \QD's "adjust size" action. The
353     function returns the original action.
354 
355     \sa QAction
356     \obsolete
357 
358     Use action() instead.
359 */
actionAdjustSize() const360 QAction *QDesignerFormWindowManagerInterface::actionAdjustSize() const
361 {
362     return action(AdjustSizeAction);
363 }
364 
365 /*!
366     Allows you to intervene and control \QD's "simplify layout" action. The
367     function returns the original action.
368 
369     \sa QAction
370     \since 4.4
371     \obsolete
372 
373     Use action() instead.
374 */
375 
actionSimplifyLayout() const376 QAction *QDesignerFormWindowManagerInterface::actionSimplifyLayout() const
377 {
378     return action(SimplifyLayoutAction);
379 }
380 
381 /*!
382   \fn virtual QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::activeFormWindow() const
383    Returns the currently active form window in \QD's workspace.
384 
385    \sa setActiveFormWindow(), removeFormWindow()
386 */
387 
388 /*!
389     \fn virtual QDesignerFormEditorInterface *QDesignerFormWindowManagerInterface::core() const
390     Returns a pointer to \QD's current QDesignerFormEditorInterface
391     object.
392 */
393 
394 /*!
395    \fn virtual void QDesignerFormWindowManagerInterface::addFormWindow(QDesignerFormWindowInterface *formWindow)
396    Adds the given \a formWindow to the collection of windows that
397    \QD's form window manager maintains.
398 
399    \sa formWindowAdded()
400 */
401 
402 /*!
403    \fn virtual void QDesignerFormWindowManagerInterface::removeFormWindow(QDesignerFormWindowInterface *formWindow)
404    Removes the given \a formWindow from the collection of windows that
405    \QD's form window manager maintains.
406 
407    \sa formWindow(), formWindowRemoved()
408 */
409 
410 /*!
411    \fn virtual void QDesignerFormWindowManagerInterface::setActiveFormWindow(QDesignerFormWindowInterface *formWindow)
412    Sets the given \a formWindow to be the currently active form window in
413    \QD's workspace.
414 
415    \sa activeFormWindow(), activeFormWindowChanged()
416 */
417 
418 /*!
419    \fn int QDesignerFormWindowManagerInterface::formWindowCount() const
420    Returns the number of form windows maintained by \QD's form window
421    manager.
422 */
423 
424 /*!
425    \fn QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::formWindow(int index) const
426    Returns the form window at the given \a index.
427 
428    \sa setActiveFormWindow(), removeFormWindow()
429 */
430 
431 /*!
432   \fn QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::createFormWindow(QWidget *parent, Qt::WindowFlags flags)
433 
434    Creates a form window with the given \a parent and the given window
435    \a flags.
436 
437    \sa addFormWindow()
438 */
439 
440 /*!
441   \fn QPixmap QDesignerFormWindowManagerInterface::createPreviewPixmap() const
442 
443   Creates a pixmap representing the preview of the currently active form.
444 */
445 
446 /*!
447     Allows you to intervene and control \QD's "undo" action. The
448     function returns the original action.
449 
450     \sa QAction
451     \obsolete
452 
453     Use action() instead.
454 */
actionUndo() const455 QAction *QDesignerFormWindowManagerInterface::actionUndo() const
456 {
457     return action(UndoAction);
458 }
459 
460 /*!
461     Allows you to intervene and control \QD's "redo" action. The
462     function returns the original action.
463 
464     \sa QAction
465     \obsolete
466 
467     Use action() instead.
468 */
actionRedo() const469 QAction *QDesignerFormWindowManagerInterface::actionRedo() const
470 {
471     return action(RedoAction);
472 }
473 
474 /*!
475     \fn void QDesignerFormWindowManagerInterface::formWindowAdded(QDesignerFormWindowInterface *formWindow)
476 
477     This signal is emitted when a new form window is added to the
478     collection of windows that \QD's form window manager maintains. A
479     pointer to the new \a formWindow is passed as an argument.
480 
481     \sa addFormWindow(), setActiveFormWindow()
482 */
483 
484 /*!
485     \fn void QDesignerFormWindowManagerInterface::formWindowSettingsChanged(QDesignerFormWindowInterface *formWindow)
486 
487     This signal is emitted when the settings of the form window change. It can be used to update
488     window titles, etc. accordingly. A pointer to the \a formWindow is passed as an argument.
489 
490     \sa FormWindowSettingsDialogAction
491 */
492 
493 /*!
494     \fn void QDesignerFormWindowManagerInterface::formWindowRemoved(QDesignerFormWindowInterface *formWindow)
495 
496     This signal is emitted when a form window is removed from the
497     collection of windows that \QD's form window manager maintains. A
498     pointer to the removed \a formWindow is passed as an argument.
499 
500     \sa removeFormWindow()
501 */
502 
503 /*!
504     \fn void QDesignerFormWindowManagerInterface::activeFormWindowChanged(QDesignerFormWindowInterface *formWindow)
505 
506     This signal is emitted when the contents of the currently active
507     form window in \QD's workspace changed. A pointer to the currently
508     active \a formWindow is passed as an argument.
509 
510     \sa activeFormWindow()
511 */
512 
513 /*!
514     \fn void QDesignerFormWindowManagerInterface::dragItems(const QList<QDesignerDnDItemInterface*> &item_list)
515 
516     \internal
517 */
518 
519 /*!
520     \fn virtual QAction QDesignerFormWindowManagerInterface::action(Action action) const
521 
522     Returns the action specified by the enumeration value \a action.
523 
524     Obsoletes the action accessors of Qt 4.X.
525 
526     \since 5.0
527 */
528 
529 /*!
530     \fn virtual QActionGroup *QDesignerFormWindowManagerInterface::actionGroup(ActionGroup actionGroup) const
531 
532     Returns the action group specified by the enumeration value \a actionGroup.
533 
534     \since 5.0
535 */
536 
537 /*!
538     \fn virtual void QDesignerFormWindowManagerInterface::showPreview()
539 
540     Show a preview of the current form using the default parameters.
541 
542     \since 5.0
543     \sa closeAllPreviews()
544 */
545 
546 /*!
547     \fn virtual void QDesignerFormWindowManagerInterface::closeAllPreviews()
548 
549     Close all currently open previews.
550 
551     \since 5.0
552     \sa showPreview()
553 */
554 
555 /*!
556     \fn virtual void QDesignerFormWindowManagerInterface::showPluginDialog()
557 
558     Opens a dialog showing the plugins loaded by \QD's and its plugin load failures.
559 
560     \since 5.0
561 */
562 
563 QT_END_NAMESPACE
564