Changeset View
Changeset View
Standalone View
Standalone View
interfaces/context.h
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
55 | The plugin that originally gets the contextmenu event shouldn't add its own | 55 | The plugin that originally gets the contextmenu event shouldn't add its own | ||
56 | actions directly to the menu but instead use the same mechanism. | 56 | actions directly to the menu but instead use the same mechanism. | ||
57 | 57 | | |||
58 | <b>How to show a context menu from a plugin:</b> | 58 | <b>How to show a context menu from a plugin:</b> | ||
59 | -# Create a QMenu in context menu event handler: @code QMenu menu(this); @endcode | 59 | -# Create a QMenu in context menu event handler: @code QMenu menu(this); @endcode | ||
60 | -# Create a context: @code FileContext context(list). @endcode | 60 | -# Create a context: @code FileContext context(list). @endcode | ||
61 | -# Query for plugins: | 61 | -# Query for plugins: | ||
62 | @code QList<ContextMenuExtension> extensions = | 62 | @code QList<ContextMenuExtension> extensions = | ||
63 | ICore::self()->pluginController()->queryPluginsForContextMenuExtensions( context ); @endcode | 63 | ICore::self()->pluginController()->queryPluginsForContextMenuExtensions(context, &menu); @endcode | ||
64 | -# Populate the menu: | 64 | -# Populate the menu: | ||
65 | @code ContextMenuExtension::populateMenu(menu, extensions); @endcode | 65 | @code ContextMenuExtension::populateMenu(menu, extensions); @endcode | ||
66 | -# Show the popup menu: @code menu.exec(mapToGlobal(pos)); @endcode | 66 | -# Show the popup menu: @code menu.exec(mapToGlobal(pos)); @endcode | ||
67 | 67 | | |||
68 | <b>How to fill a context menu from a plugin:</b> | 68 | <b>How to fill a context menu from a plugin:</b> | ||
69 | -# Implement the @code contextMenuExtension(Context*) @endcode | 69 | -# Implement the @code contextMenuExtension(Context*, QWidget*) @endcode | ||
70 | function in your plugin class. | 70 | function in your plugin class. | ||
71 | -# Depending on the context fill the returned ContextMenuExtension with actions:\n | 71 | -# Depending on the context fill the returned ContextMenuExtension with actions:\n | ||
72 | @code | 72 | @code | ||
73 | ContextMenuExtension ext; | 73 | ContextMenuExtension ext; | ||
74 | if (context->hasType(Context::EditorContext)) | 74 | if (context->hasType(Context::EditorContext)) | ||
75 | { | 75 | { | ||
76 | ext.addAction(ContextMenuExtension::EditorGroup, new QAction(...)); | 76 | ext.addAction(ContextMenuExtension::EditorGroup, new QAction(...)); | ||
77 | } | 77 | } | ||
▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines |