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
4#include <QtGui/qaction.h>
5
8
9#include <QtDesigner/abstractformeditor.h>
10#include <QtDesigner/abstractformwindow.h>
11#include <QtDesigner/abstractformwindowmanager.h>
12
14
15using namespace Qt::StringLiterals;
16
17namespace qdesigner_internal {
18
19TabOrderEditorPlugin::TabOrderEditorPlugin() = default;
20
22
24{
25 return m_initialized;
26}
27
28void TabOrderEditorPlugin::initialize(QDesignerFormEditorInterface *core)
29{
30 Q_ASSERT(!isInitialized());
31
32 m_action = new QAction(tr("Edit Tab Order"), this);
33 m_action->setObjectName(u"_qt_edit_tab_order_action"_s);
34 QIcon icon = QIcon::fromTheme(u"designer-edit-tabs"_s,
35 QIcon(core->resourceLocation() + "/tabordertool.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, &TabOrderEditorPlugin::addFormWindow);
45
46 connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::formWindowRemoved,
47 this, &TabOrderEditorPlugin::removeFormWindow);
48
49 connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::activeFormWindowChanged,
50 this, &TabOrderEditorPlugin::activeFormWindowChanged);
51}
52
53void TabOrderEditorPlugin::activeFormWindowChanged(QDesignerFormWindowInterface *formWindow)
54{
55 m_action->setEnabled(formWindow != nullptr);
56}
57
58QDesignerFormEditorInterface *TabOrderEditorPlugin::core() const
59{
60 return m_core;
61}
62
63void TabOrderEditorPlugin::addFormWindow(QDesignerFormWindowInterface *formWindow)
64{
65 Q_ASSERT(formWindow != nullptr);
66 Q_ASSERT(m_tools.contains(formWindow) == false);
67
68 TabOrderEditorTool *tool = new TabOrderEditorTool(formWindow, this);
69 m_tools[formWindow] = tool;
70 connect(m_action, &QAction::triggered, tool->action(), &QAction::trigger);
71 formWindow->registerTool(tool);
72}
73
74void TabOrderEditorPlugin::removeFormWindow(QDesignerFormWindowInterface *formWindow)
75{
76 Q_ASSERT(formWindow != nullptr);
77 Q_ASSERT(m_tools.contains(formWindow) == true);
78
79 TabOrderEditorTool *tool = m_tools.value(formWindow);
80 m_tools.remove(formWindow);
81 disconnect(m_action, &QAction::triggered, tool->action(), &QAction::trigger);
82 // ### FIXME disable the tool
83
84 delete tool;
85}
86
88{
89 return m_action;
90}
91
92} // namespace qdesigner_internal
93
94QT_END_NAMESPACE
95
96#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.