Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
buddyeditor_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
5
#
include
<
QtGui
/
qaction
.
h
>
6
7
#
include
"buddyeditor_plugin.h"
8
#
include
"buddyeditor_tool.h"
9
10
#
include
<
iconloader_p
.
h
>
11
12
#
include
<
QtDesigner
/
abstractformwindow
.
h
>
13
#
include
<
QtDesigner
/
abstractformwindowmanager
.
h
>
14
#
include
<
QtDesigner
/
abstractformeditor
.
h
>
15
16
QT_BEGIN_NAMESPACE
17
18
using
namespace
Qt::StringLiterals;
19
20
namespace
qdesigner_internal
{
21
22
BuddyEditorPlugin
::BuddyEditorPlugin() =
default
;
23
24
BuddyEditorPlugin
::~
BuddyEditorPlugin
() =
default
;
25
26
bool
BuddyEditorPlugin
::
isInitialized
()
const
27
{
28
return
m_initialized;
29
}
30
31
void
BuddyEditorPlugin
::initialize(QDesignerFormEditorInterface *core)
32
{
33
Q_ASSERT(!
isInitialized
(
)
);
34
35
m_action =
new
QAction(tr(
"Edit Buddies"
),
this
);
36
m_action->setObjectName(u"__qt_edit_buddies_action"_s);
37
m_action->setIcon(createIconSet(
"buddytool.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
, &BuddyEditorPlugin::addFormWindow);
46
47
connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::formWindowRemoved,
48
this
, &
BuddyEditorPlugin
::removeFormWindow);
49
50
connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::activeFormWindowChanged,
51
this
, &BuddyEditorPlugin::activeFormWindowChanged);
52
}
53
54
QDesignerFormEditorInterface *
BuddyEditorPlugin
::
core
()
const
55
{
56
return
m_core;
57
}
58
59
void
BuddyEditorPlugin
::addFormWindow(QDesignerFormWindowInterface *formWindow)
60
{
61
Q_ASSERT(formWindow !=
nullptr
);
62
Q_ASSERT(m_tools.contains(formWindow) ==
false
);
63
64
BuddyEditorTool
*tool =
new
BuddyEditorTool(formWindow,
this
);
65
m_tools[formWindow] = tool;
66
connect(m_action, &QAction::triggered, tool
->
action
(
)
, &QAction::trigger);
67
formWindow->registerTool(tool);
68
}
69
70
void
BuddyEditorPlugin
::removeFormWindow(QDesignerFormWindowInterface *formWindow)
71
{
72
Q_ASSERT(formWindow !=
nullptr
);
73
Q_ASSERT(m_tools.contains(formWindow) ==
true
);
74
75
BuddyEditorTool
*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
83
QAction *
BuddyEditorPlugin
::
action
()
const
84
{
85
return
m_action;
86
}
87
88
void
BuddyEditorPlugin
::activeFormWindowChanged(QDesignerFormWindowInterface *formWindow)
89
{
90
m_action->setEnabled(formWindow !=
nullptr
);
91
}
92
93
}
// namespace qdesigner_internal
94
95
QT_END_NAMESPACE
qdesigner_internal::BuddyEditorPlugin
Definition
buddyeditor_plugin.h:25
qdesigner_internal::BuddyEditorPlugin::isInitialized
bool isInitialized() const override
Returns true if the plugin interface is initialized; otherwise returns false.
Definition
buddyeditor_plugin.cpp:26
qdesigner_internal::BuddyEditorPlugin::core
QDesignerFormEditorInterface * core() const override
Returns the core form editor interface associated with this component.
Definition
buddyeditor_plugin.cpp:54
qdesigner_internal::BuddyEditorPlugin::action
QAction * action() const override
Returns the action associated with this interface.
Definition
buddyeditor_plugin.cpp:83
qdesigner_internal::BuddyEditorPlugin::~BuddyEditorPlugin
~BuddyEditorPlugin() override
qdesigner_internal::BuddyEditorTool
Definition
buddyeditor_tool.h:25
qdesigner_internal::BuddyEditorTool::action
QAction * action() const override
Definition
buddyeditor_tool.cpp:68
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qdesigner_internal
Auxiliary methods to store/retrieve settings.
Definition
buddyeditor.cpp:67
qttools
src
designer
src
components
buddyeditor
buddyeditor_plugin.cpp
Generated on
for Qt by
1.18.0