Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
signalsloteditor_plugin.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
6
7#include <QtDesigner/abstractformeditor.h>
8#include <QtDesigner/abstractformwindowmanager.h>
9
10#include <QtGui/qaction.h>
11
13
14using namespace Qt::StringLiterals;
15
16namespace qdesigner_internal {
17
18SignalSlotEditorPlugin::SignalSlotEditorPlugin() = default;
19
21
23{
24 return m_initialized;
25}
26
27void SignalSlotEditorPlugin::initialize(QDesignerFormEditorInterface *core)
28{
29 Q_ASSERT(!isInitialized());
30
31 m_action = new QAction(tr("Edit Signals/Slots"), this);
32 m_action->setObjectName(u"__qt_edit_signals_slots_action"_s);
33 m_action->setShortcut(tr("F4"));
34 QIcon icon = QIcon::fromTheme(u"designer-edit-signals"_s,
35 QIcon(core->resourceLocation() + "/signalslottool.png"_L1));
36 m_action->setIcon(icon);
37 m_action->setEnabled(false);
38
39 setParent(core);
40 m_core = core;
41 m_initialized = true;
42
43 connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::formWindowAdded,
44 this, &SignalSlotEditorPlugin::addFormWindow);
45
46 connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::formWindowRemoved,
47 this, &SignalSlotEditorPlugin::removeFormWindow);
48
49 connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::activeFormWindowChanged,
50 this, &SignalSlotEditorPlugin::activeFormWindowChanged);
51}
52
53QDesignerFormEditorInterface *SignalSlotEditorPlugin::core() const
54{
55 return m_core;
56}
57
58void SignalSlotEditorPlugin::addFormWindow(QDesignerFormWindowInterface *formWindow)
59{
60 Q_ASSERT(formWindow != nullptr);
61 Q_ASSERT(m_tools.contains(formWindow) == false);
62
63 SignalSlotEditorTool *tool = new SignalSlotEditorTool(formWindow, this);
64 connect(m_action, &QAction::triggered, tool->action(), &QAction::trigger);
65 m_tools[formWindow] = tool;
66 formWindow->registerTool(tool);
67}
68
69void SignalSlotEditorPlugin::removeFormWindow(QDesignerFormWindowInterface *formWindow)
70{
71 Q_ASSERT(formWindow != nullptr);
72 Q_ASSERT(m_tools.contains(formWindow) == true);
73
74 SignalSlotEditorTool *tool = m_tools.value(formWindow);
75 m_tools.remove(formWindow);
76 disconnect(m_action, &QAction::triggered, tool->action(), &QAction::trigger);
77 // ### FIXME disable the tool
78
79 delete tool;
80}
81
83{
84 return m_action;
85}
86
87void SignalSlotEditorPlugin::activeFormWindowChanged(QDesignerFormWindowInterface *formWindow)
88{
89 m_action->setEnabled(formWindow != nullptr);
90}
91
92} // namespace qdesigner_internal
93
94QT_END_NAMESPACE
95
96#include "moc_signalsloteditor_plugin.cpp"
bool isInitialized() const override
Returns true if the plugin interface is initialized; otherwise returns false.
QAction * action() const override
Returns the action associated with this interface.
QDesignerFormEditorInterface * core() const override
Returns the core form editor interface associated with this component.
void initialize(QDesignerFormEditorInterface *core) override
Initializes the plugin interface for the specified core interface.
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.