forked from qt-creator/qt-creator
QmlDesigner: Break dependency to View3DActionCommand
The node instance view and his commands should be not called directly from other views. There are special classes QmlItem which can do it but every change should go through the model. Change-Id: I734e5538d7f6ecb07d736912f647c5eb92dc7631 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -18,30 +18,37 @@ namespace QmlDesigner {
|
||||
|
||||
Edit3DActionTemplate::Edit3DActionTemplate(const QString &description,
|
||||
SelectionContextOperation action,
|
||||
View3DActionCommand::Type type)
|
||||
: DefaultAction(description),
|
||||
m_action(action),
|
||||
m_type(type)
|
||||
{ }
|
||||
AbstractView *view,
|
||||
View3DActionType type)
|
||||
: DefaultAction(description)
|
||||
, m_action(action)
|
||||
, m_view(view)
|
||||
, m_type(type)
|
||||
{}
|
||||
|
||||
void Edit3DActionTemplate::actionTriggered(bool b)
|
||||
{
|
||||
if (m_type != View3DActionCommand::Empty && m_type != View3DActionCommand::SelectBackgroundColor
|
||||
&& m_type != View3DActionCommand::SelectGridColor) {
|
||||
auto view = QmlDesignerPlugin::instance()->viewManager().nodeInstanceView();
|
||||
View3DActionCommand cmd(m_type, b);
|
||||
view->view3DAction(cmd);
|
||||
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);
|
||||
}
|
||||
|
||||
Edit3DAction::Edit3DAction(const QByteArray &menuId, View3DActionCommand::Type type,
|
||||
const QString &description, const QKeySequence &key, bool checkable,
|
||||
bool checked, const QIcon &iconOff, const QIcon &iconOn,
|
||||
SelectionContextOperation selectionAction, const QString &toolTip)
|
||||
: AbstractAction(new Edit3DActionTemplate(description, selectionAction, type))
|
||||
Edit3DAction::Edit3DAction(const QByteArray &menuId,
|
||||
View3DActionType type,
|
||||
const QString &description,
|
||||
const QKeySequence &key,
|
||||
bool checkable,
|
||||
bool checked,
|
||||
const QIcon &iconOff,
|
||||
const QIcon &iconOn,
|
||||
AbstractView *view,
|
||||
SelectionContextOperation selectionAction,
|
||||
const QString &toolTip)
|
||||
: AbstractAction(new Edit3DActionTemplate(description, selectionAction, view, type))
|
||||
, m_menuId(menuId)
|
||||
{
|
||||
action()->setShortcut(key);
|
||||
@@ -81,12 +88,17 @@ bool Edit3DAction::isEnabled(const SelectionContext &selectionContext) const
|
||||
return isVisible(selectionContext);
|
||||
}
|
||||
|
||||
Edit3DCameraAction::Edit3DCameraAction(const QByteArray &menuId, View3DActionCommand::Type type,
|
||||
const QString &description, const QKeySequence &key,
|
||||
bool checkable, bool checked, const QIcon &iconOff,
|
||||
Edit3DCameraAction::Edit3DCameraAction(const QByteArray &menuId,
|
||||
View3DActionType type,
|
||||
const QString &description,
|
||||
const QKeySequence &key,
|
||||
bool checkable,
|
||||
bool checked,
|
||||
const QIcon &iconOff,
|
||||
const QIcon &iconOn,
|
||||
AbstractView *view,
|
||||
SelectionContextOperation selectionAction)
|
||||
: Edit3DAction(menuId, type, description, key, checkable, checked, iconOff, iconOn, selectionAction)
|
||||
: Edit3DAction(menuId, type, description, key, checkable, checked, iconOff, iconOn, view, selectionAction)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user