1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "edit3dactions.h"
#include "edit3dview.h"
#include <viewmanager.h>
#include <nodeinstanceview.h>
#include <nodemetainfo.h>
#include <qmldesignerplugin.h>
#include "seekerslider.h"
#include <utils/algorithm.h>
#include <QDebug>
namespace QmlDesigner {
Edit3DActionTemplate::Edit3DActionTemplate(const QString &description,
SelectionContextOperation action,
Edit3DView *view,
View3DActionType type)
: DefaultAction(description)
, m_action(action)
, m_view(view)
, m_type(type)
{}
void Edit3DActionTemplate::actionTriggered(bool b)
{
if (m_type != View3DActionType::Empty && m_type != View3DActionType::SelectBackgroundColor
&& m_type != View3DActionType::SelectGridColor) {
m_view->emitView3DAction(m_type, b);
}
if (m_action)
m_action(m_selectionContext);
}
Edit3DWidgetActionTemplate::Edit3DWidgetActionTemplate(QWidgetAction *widget)
: PureActionInterface(widget)
{
}
Edit3DAction::Edit3DAction(const QByteArray &menuId,
View3DActionType type,
const QString &description,
const QKeySequence &key,
bool checkable,
bool checked,
const QIcon &icon,
Edit3DView *view,
SelectionContextOperation selectionAction,
const QString &toolTip)
: Edit3DAction(menuId, type, view, new Edit3DActionTemplate(description,
selectionAction,
view,
type))
{
action()->setShortcut(key);
action()->setShortcutContext(Qt::WidgetWithChildrenShortcut);
action()->setCheckable(checkable);
action()->setChecked(checked);
// Description will be used as tooltip by default if no explicit tooltip is provided
if (!toolTip.isEmpty())
action()->setToolTip(toolTip);
action()->setIcon(icon);
}
Edit3DAction::Edit3DAction(const QByteArray &menuId,
View3DActionType type,
Edit3DView *view,
PureActionInterface *pureInt)
: AbstractAction(pureInt)
, m_menuId(menuId)
, m_actionType(type)
{
view->registerEdit3DAction(this);
}
QByteArray Edit3DAction::category() const
{
return QByteArray();
}
View3DActionType Edit3DAction::actionType() const
{
return m_actionType;
}
bool Edit3DAction::isVisible([[maybe_unused]] const SelectionContext &selectionContext) const
{
return true;
}
bool Edit3DAction::isEnabled(const SelectionContext &selectionContext) const
{
return isVisible(selectionContext);
}
Edit3DCameraAction::Edit3DCameraAction(const QByteArray &menuId,
View3DActionType type,
const QString &description,
const QKeySequence &key,
bool checkable,
bool checked,
const QIcon &icon,
Edit3DView *view,
SelectionContextOperation selectionAction)
: Edit3DAction(menuId, type, description, key, checkable, checked, icon, view, selectionAction)
{
}
bool Edit3DCameraAction::isEnabled(const SelectionContext &selectionContext) const
{
return Utils::anyOf(selectionContext.selectedModelNodes(),
[](const ModelNode &node) { return node.metaInfo().isQtQuick3DCamera(); });
}
Edit3DParticleSeekerAction::Edit3DParticleSeekerAction(const QByteArray &menuId,
View3DActionType type,
Edit3DView *view)
: Edit3DAction(menuId,
type,
view,
new Edit3DWidgetActionTemplate(
new SeekerSliderAction(nullptr)))
{
m_seeker = qobject_cast<SeekerSliderAction *>(action());
}
SeekerSliderAction *Edit3DParticleSeekerAction::seekerAction()
{
return m_seeker;
}
bool Edit3DParticleSeekerAction::isVisible(const SelectionContext &) const
{
return m_seeker->isVisible();
}
bool Edit3DParticleSeekerAction::isEnabled(const SelectionContext &) const
{
return m_seeker->isEnabled();
}
}
|