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// Qt-Security score:significant reason:default
4
7
8#include <iconloader_p.h>
9
10#include <QtDesigner/abstractformeditor.h>
11#include <QtDesigner/abstractformwindowmanager.h>
12
13#include <QtGui/qaction.h>
14
16
17using namespace Qt::StringLiterals;
18
19namespace qdesigner_internal {
20
21SignalSlotEditorPlugin::SignalSlotEditorPlugin() = default;
22
24
26{
27 return m_initialized;
28}
29
30void SignalSlotEditorPlugin::initialize(QDesignerFormEditorInterface *core)
31{
32 Q_ASSERT(!isInitialized());
33
34 m_action = new QAction(tr("Edit Signals/Slots"), this);
35 m_action->setObjectName(u"__qt_edit_signals_slots_action"_s);
36 m_action->setShortcut(tr("F4"));
37 m_action->setIcon(createIconSet("signalslottool.png"_L1));
38 m_action->setEnabled(false);
39
40 setParent(core);
41 m_core = core;
42 m_initialized = true;
43
44 connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::formWindowAdded,
45 this, &SignalSlotEditorPlugin::addFormWindow);
46
47 connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::formWindowRemoved,
48 this, &SignalSlotEditorPlugin::removeFormWindow);
49
50 connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::activeFormWindowChanged,
51 this, &SignalSlotEditorPlugin::activeFormWindowChanged);
52}
53
54QDesignerFormEditorInterface *SignalSlotEditorPlugin::core() const
55{
56 return m_core;
57}
58
59void SignalSlotEditorPlugin::addFormWindow(QDesignerFormWindowInterface *formWindow)
60{
61 Q_ASSERT(formWindow != nullptr);
62 Q_ASSERT(m_tools.contains(formWindow) == false);
63
64 SignalSlotEditorTool *tool = new SignalSlotEditorTool(formWindow, this);
65 connect(m_action, &QAction::triggered, tool->action(), &QAction::trigger);
66 m_tools[formWindow] = tool;
67 formWindow->registerTool(tool);
68}
69
70void SignalSlotEditorPlugin::removeFormWindow(QDesignerFormWindowInterface *formWindow)
71{
72 Q_ASSERT(formWindow != nullptr);
73 Q_ASSERT(m_tools.contains(formWindow) == true);
74
75 SignalSlotEditorTool *tool = m_tools.value(formWindow);
76 m_tools.remove(formWindow);
77 disconnect(m_action, &QAction::triggered, tool->action(), &QAction::trigger);
78 // ### FIXME disable the tool
79
80 delete tool;
81}
82
84{
85 return m_action;
86}
87
88void SignalSlotEditorPlugin::activeFormWindowChanged(QDesignerFormWindowInterface *formWindow)
89{
90 m_action->setEnabled(formWindow != nullptr);
91}
92
93} // namespace qdesigner_internal
94
95QT_END_NAMESPACE
96
97#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.