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
tabordereditor_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
9
10#include <iconloader_p.h>
11
12#include <QtDesigner/abstractformeditor.h>
13#include <QtDesigner/abstractformwindow.h>
14#include <QtDesigner/abstractformwindowmanager.h>
15
17
18using namespace Qt::StringLiterals;
19
20namespace qdesigner_internal {
21
22TabOrderEditorPlugin::TabOrderEditorPlugin() = default;
23
25
27{
28 return m_initialized;
29}
30
31void TabOrderEditorPlugin::initialize(QDesignerFormEditorInterface *core)
32{
33 Q_ASSERT(!isInitialized());
34
35 m_action = new QAction(tr("Edit Tab Order"), this);
36 m_action->setObjectName(u"_qt_edit_tab_order_action"_s);
37 m_action->setIcon(createIconSet("tabordertool.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, &TabOrderEditorPlugin::addFormWindow);
46
47 connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::formWindowRemoved,
48 this, &TabOrderEditorPlugin::removeFormWindow);
49
50 connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::activeFormWindowChanged,
51 this, &TabOrderEditorPlugin::activeFormWindowChanged);
52}
53
54void TabOrderEditorPlugin::activeFormWindowChanged(QDesignerFormWindowInterface *formWindow)
55{
56 m_action->setEnabled(formWindow != nullptr);
57}
58
59QDesignerFormEditorInterface *TabOrderEditorPlugin::core() const
60{
61 return m_core;
62}
63
64void TabOrderEditorPlugin::addFormWindow(QDesignerFormWindowInterface *formWindow)
65{
66 Q_ASSERT(formWindow != nullptr);
67 Q_ASSERT(m_tools.contains(formWindow) == false);
68
69 TabOrderEditorTool *tool = new TabOrderEditorTool(formWindow, this);
70 m_tools[formWindow] = tool;
71 connect(m_action, &QAction::triggered, tool->action(), &QAction::trigger);
72 formWindow->registerTool(tool);
73}
74
75void TabOrderEditorPlugin::removeFormWindow(QDesignerFormWindowInterface *formWindow)
76{
77 Q_ASSERT(formWindow != nullptr);
78 Q_ASSERT(m_tools.contains(formWindow) == true);
79
80 TabOrderEditorTool *tool = m_tools.value(formWindow);
81 m_tools.remove(formWindow);
82 disconnect(m_action, &QAction::triggered, tool->action(), &QAction::trigger);
83 // ### FIXME disable the tool
84
85 delete tool;
86}
87
89{
90 return m_action;
91}
92
93} // namespace qdesigner_internal
94
95QT_END_NAMESPACE
96
97#include "moc_tabordereditor_plugin.cpp"
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.
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.
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.