source: trunk/tools/designer/src/lib/sdk/taskmenu.qdoc@ 651

Last change on this file since 651 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

  • Property svn:eol-style set to native
File size: 6.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 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:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this 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 have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/*!
43 \class QDesignerTaskMenuExtension
44 \brief The QDesignerTaskMenuExtension class allows you to add custom
45 menu entries to Qt Designer's task menu.
46 \inmodule QtDesigner
47
48 QDesignerTaskMenuExtension provides an interface for creating
49 custom task menu extensions. It is typically used to create task
50 menu entries that are specific to a plugin in \QD.
51
52 \QD uses the QDesignerTaskMenuExtension to feed its task
53 menu. Whenever a task menu is requested, \QD will query
54 for the selected widget's task menu extension.
55
56 \image taskmenuextension-example-faded.png
57
58 A task menu extension is a collection of QActions. The actions
59 appear as entries in the task menu when the plugin with the
60 specified extension is selected. The image above shows the custom
61 \gui {Edit State...} action which appears in addition to \QD's
62 default task menu entries: \gui Cut, \gui Copy, \gui Paste etc.
63
64 To create a custom task menu extension, your extension class must
65 inherit from both QObject and QDesignerTaskMenuExtension. For
66 example:
67
68 \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 9
69
70 Since we are implementing an interface, we must ensure that it
71 is made known to the meta-object system using the Q_INTERFACES()
72 macro. This enables \QD to use the qobject_cast() function to
73 query for supported interfaces using nothing but a QObject
74 pointer.
75
76 You must reimplement the taskActions() function to return a list
77 of actions that will be included in \QD task menu. Optionally, you
78 can reimplement the preferredEditAction() function to set the
79 action that is invoked when selecting your plugin and pressing
80 \key F2. The preferred edit action must be one of the actions
81 returned by taskActions() and, if it's not defined, pressing the
82 \key F2 key will simply be ignored.
83
84 In \QD, extensions are not created until they are required. A
85 task menu extension, for example, is created when you click the
86 right mouse button over a widget in \QD's workspace. For that
87 reason you must also construct an extension factory, using either
88 QExtensionFactory or a subclass, and register it using \QD's
89 \l {QExtensionManager}{extension manager}.
90
91 When a task menu extension is required, \QD's \l
92 {QExtensionManager}{extension manager} will run through all its
93 registered factories calling QExtensionFactory::createExtension()
94 for each until it finds one that is able to create a task menu
95 extension for the selected widget. This factory will then make an
96 instance of the extension.
97
98 There are four available types of extensions in \QD:
99 QDesignerContainerExtension, QDesignerMemberSheetExtension,
100 QDesignerPropertySheetExtension, and QDesignerTaskMenuExtension.
101 \QD's behavior is the same whether the requested extension is
102 associated with a container, a member sheet, a property sheet or a
103 task menu.
104
105 The QExtensionFactory class provides a standard extension factory,
106 and can also be used as an interface for custom extension
107 factories. You can either create a new QExtensionFactory and
108 reimplement the QExtensionFactory::createExtension() function. For
109 example:
110