summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/components/edit3d/edit3dactions.h
blob: bad427a25be11ed5df01725e4fb1e457a6f5ec1a (plain)
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
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

#include <abstractaction.h>

#include <QAction>
#include <QWidgetAction>
#include <QIcon>

class QWidgetAction;
namespace QmlDesigner {

using SelectionContextOperation = std::function<void(const SelectionContext &)>;
class Edit3DView;
class SeekerSliderAction;

class Edit3DActionTemplate : public DefaultAction
{
    Q_OBJECT

public:
    Edit3DActionTemplate(const QString &description,
                         SelectionContextOperation action,
                         Edit3DView *view,
                         View3DActionType type);

    void actionTriggered(bool b) override;

    SelectionContextOperation m_action;
    Edit3DView *m_view = nullptr;
    View3DActionType m_type;
};

class Edit3DWidgetActionTemplate : public PureActionInterface
{
    Q_DISABLE_COPY(Edit3DWidgetActionTemplate)

public:
    explicit Edit3DWidgetActionTemplate(QWidgetAction *widget);
    virtual void setSelectionContext(const SelectionContext &) {}
};

class Edit3DAction : public AbstractAction
{
public:
    Edit3DAction(const QByteArray &menuId,
                 View3DActionType type,
                 const QString &description,
                 const QKeySequence &key,
                 bool checkable,
                 bool checked,
                 const QIcon &icon,
                 Edit3DView *view,
                 SelectionContextOperation selectionAction = nullptr,
                 const QString &toolTip = {});

    Edit3DAction(const QByteArray &menuId,
                 View3DActionType type,
                 Edit3DView *view,
                 PureActionInterface *pureInt);

    QByteArray category() const override;

    int priority() const override
    {
        return CustomActionsPriority;
    }

    Type type() const override
    {
        return ActionInterface::Edit3DAction;
    }

    QByteArray menuId() const override
    {
        return m_menuId;
    }

    View3DActionType actionType() const;

protected:
    bool isVisible(const SelectionContext &selectionContext) const override;
    bool isEnabled(const SelectionContext &selectionContext) const override;

private:
    QByteArray m_menuId;
    View3DActionType m_actionType;
};

class Edit3DCameraAction : public Edit3DAction
{
public:
    Edit3DCameraAction(const QByteArray &menuId,
                       View3DActionType type,
                       const QString &description,
                       const QKeySequence &key,
                       bool checkable,
                       bool checked,
                       const QIcon &icon,
                       Edit3DView *view,
                       SelectionContextOperation selectionAction = nullptr);

protected:
    bool isEnabled(const SelectionContext &selectionContext) const override;
};

class Edit3DParticleSeekerAction : public Edit3DAction
{
public:
    Edit3DParticleSeekerAction(const QByteArray &menuId,
                               View3DActionType type,
                               Edit3DView *view);

    SeekerSliderAction *seekerAction();

protected:
    bool isVisible(const SelectionContext &) const override;
    bool isEnabled(const SelectionContext &) const override;

private:
    SeekerSliderAction *m_seeker = nullptr;
};

} // namespace QmlDesigner