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
view3d_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 LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6#include "view3d_tool.h"
7
8#include <QtDesigner/qdesignerformeditorinterface.h>
9#include <QtDesigner/qdesignerformwindowmanagerinterface.h>
10
11#include <QtGui/qaction.h>
12
13#include <QtCore/qdebug.h>
14#include <QtCore/qtplugin.h>
15
16QView3DPlugin::QView3DPlugin()
17{
18 m_core = 0;
19 m_action = 0;
20}
21
23{
24 return m_core != 0;
25}
26
27void QView3DPlugin::initialize(QDesignerFormEditorInterface *core)
28{
29 Q_ASSERT(!isInitialized());
30
31 m_action = new QAction(tr("3D View"), this);
32 m_core = core;
33 setParent(core);
34
35 connect(core->formWindowManager(), SIGNAL(formWindowAdded(QDesignerFormWindowInterface*)),
36 this, SLOT(addFormWindow(QDesignerFormWindowInterface*)));
37
38 connect(core->formWindowManager(), SIGNAL(formWindowRemoved(QDesignerFormWindowInterface*)),
39 this, SLOT(removeFormWindow(QDesignerFormWindowInterface*)));
40
41 connect(core->formWindowManager(), SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)),
42 this, SLOT(activeFormWindowChanged(QDesignerFormWindowInterface*)));
43}
44
45QAction *QView3DPlugin::action() const
46{
47 return m_action;
48}
49
51{
52 return m_core;
53}
54
55void QView3DPlugin::activeFormWindowChanged(QDesignerFormWindowInterface *formWindow)
56{
57 m_action->setEnabled(formWindow != 0);
58}
59
60void QView3DPlugin::addFormWindow(QDesignerFormWindowInterface *formWindow)
61{
62 Q_ASSERT(formWindow != 0);
63 Q_ASSERT(m_tool_list.contains(formWindow) == false);
64
65 QView3DTool *tool = new QView3DTool(formWindow, this);
66 m_tool_list[formWindow] = tool;
67 connect(m_action, SIGNAL(triggered()), tool->action(), SLOT(trigger()));
68 formWindow->registerTool(tool);
69}
70
71void QView3DPlugin::removeFormWindow(QDesignerFormWindowInterface *formWindow)
72{
73 Q_ASSERT(formWindow != 0);
74 Q_ASSERT(m_tool_list.contains(formWindow));
75
76 QView3DTool *tool = m_tool_list.value(formWindow);
77 m_tool_list.remove(formWindow);
78 disconnect(m_action, SIGNAL(triggered()), tool->action(), SLOT(trigger()));
79
80 delete tool;
81}
void initialize(QDesignerFormEditorInterface *core) override
Initializes the plugin interface for the specified core interface.
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.
bool isInitialized() const override
Returns true if the plugin interface is initialized; otherwise returns false.
QAction * action() const override