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