Implemented object selection widgets in action dialogs
This commit is contained in:
@ -26,6 +26,7 @@ INCLUDEPATH += \
|
||||
|
||||
HEADERS += \
|
||||
src/closeeventfilter.h \
|
||||
src/editor/dialogs/actions/setgravitydialog.h \
|
||||
src/editor/dialogs/actions/speedhorizontaldialog.h \
|
||||
src/editor/dialogs/actions/movefreedialog.h \
|
||||
src/editor/dialogs/actions/movetowardsdialog.h \
|
||||
@ -38,6 +39,8 @@ HEADERS += \
|
||||
src/editor/roomscene.h \
|
||||
src/editor/widgets/actiondragwidget.h \
|
||||
src/editor/widgets/draggabletreeview.h \
|
||||
src/editor/widgets/objectparentselectorwidget.h \
|
||||
src/editor/widgets/objectselectorwidget.h \
|
||||
src/editor/widgets/qlineeditwithmenu.h \
|
||||
src/editor/widgets/qscrollareawithmenu.h \
|
||||
src/editor/widgets/roomeditwidget.h \
|
||||
@ -94,6 +97,7 @@ HEADERS += \
|
||||
SOURCES += \
|
||||
src/closeeventfilter.cpp \
|
||||
src/editor/dialogs/actions/executecodedialog.cpp \
|
||||
src/editor/dialogs/actions/setgravitydialog.cpp \
|
||||
src/editor/dialogs/actions/speedhorizontaldialog.cpp \
|
||||
src/editor/dialogs/actions/movefreedialog.cpp \
|
||||
src/editor/dialogs/actions/movetowardsdialog.cpp \
|
||||
@ -105,6 +109,8 @@ SOURCES += \
|
||||
src/editor/roomscene.cpp \
|
||||
src/editor/widgets/actiondragwidget.cpp \
|
||||
src/editor/widgets/draggabletreeview.cpp \
|
||||
src/editor/widgets/objectparentselectorwidget.cpp \
|
||||
src/editor/widgets/objectselectorwidget.cpp \
|
||||
src/editor/widgets/qlineeditwithmenu.cpp \
|
||||
src/editor/widgets/qscrollareawithmenu.cpp \
|
||||
src/editor/widgets/roomeditwidget.cpp \
|
||||
@ -158,6 +164,7 @@ SOURCES += \
|
||||
src/projectserialization.cpp
|
||||
|
||||
FORMS += \
|
||||
src/editor/dialogs/actions/setgravitydialog.ui \
|
||||
src/editor/dialogs/actions/speedhorizontaldialog.ui \
|
||||
src/editor/dialogs/actions/movefreedialog.ui \
|
||||
src/editor/dialogs/actions/movetowardsdialog.ui \
|
||||
@ -190,7 +197,8 @@ FORMS += \
|
||||
src/editor/dialogs/triggersdialog.ui \
|
||||
src/editor/dialogs/userdefinedconstantsdialog.ui \
|
||||
src/editor/widgets/actionscontainerwidget.ui\
|
||||
src/editor/dialogs/actions/movefixeddialog.ui
|
||||
src/editor/dialogs/actions/movefixeddialog.ui \
|
||||
src/editor/widgets/objectselectorwidget.ui
|
||||
|
||||
RESOURCES += \
|
||||
src/editor/resources_editor.qrc \
|
||||
|
@ -1,31 +1,54 @@
|
||||
#include "executecodedialog.h"
|
||||
|
||||
#include <QRadioButton>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "projectcontainer.h"
|
||||
#include "widgets/objectselectorwidget.h"
|
||||
|
||||
ExecuteCodeDialog::ExecuteCodeDialog(ExecuteCodeAction &action, QWidget *parent) :
|
||||
ExecuteCodeDialog::ExecuteCodeDialog(ExecuteCodeAction &action, ProjectTreeModel *projectModel, QWidget *parent) :
|
||||
CodeEditorDialog{tr("Execute Code"), parent},
|
||||
m_action{action},
|
||||
m_radioButtonSelf{new QRadioButton{tr("Self"), this}},
|
||||
m_radioButtonOther{new QRadioButton{tr("Other"), this}},
|
||||
m_radioButtonObject{new QRadioButton{tr("Object"), this}}
|
||||
m_radioButtonObject{new QRadioButton{tr("Object"), this}},
|
||||
m_objectSelector{new ObjectSelectorWidget{this}}
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
|
||||
#endif
|
||||
setWindowFlag(Qt::WindowCloseButtonHint);
|
||||
|
||||
m_objectSelector->setProjectModel(projectModel);
|
||||
|
||||
m_objectSelector->setEmptySelectionText(tr("self"));
|
||||
m_objectSelector->setShowClearObjectAction(false);
|
||||
|
||||
addToolbarWidget(new QLabel{tr("Applies to:"), this});
|
||||
addToolbarWidget(m_radioButtonSelf);
|
||||
addToolbarWidget(m_radioButtonOther);
|
||||
addToolbarWidget(m_radioButtonObject);
|
||||
auto action_ = addToolbarWidget(m_objectSelector);
|
||||
|
||||
m_radioButtonSelf->setChecked(m_action.appliesTo == ExecuteCodeAction::AppliesTo::Self);
|
||||
m_radioButtonOther->setChecked(m_action.appliesTo == ExecuteCodeAction::AppliesTo::Other);
|
||||
m_radioButtonObject->setChecked(m_action.appliesTo == ExecuteCodeAction::AppliesTo::Object);
|
||||
connect(m_radioButtonObject, &QRadioButton::toggled,
|
||||
m_objectSelector, &QWidget::setVisible);
|
||||
connect(m_radioButtonObject, &QRadioButton::toggled,
|
||||
action_, &QAction::setVisible);
|
||||
|
||||
m_radioButtonSelf->setChecked(std::holds_alternative<AppliesToSelf>(m_action.appliesTo));
|
||||
m_radioButtonOther->setChecked(std::holds_alternative<AppliesToOther>(m_action.appliesTo));
|
||||
{
|
||||
auto ptr = std::get_if<AppliesToObject>(&m_action.appliesTo);
|
||||
m_radioButtonObject->setChecked(ptr != nullptr);
|
||||
m_objectSelector->setVisible(ptr != nullptr);
|
||||
action_->setVisible(ptr != nullptr);
|
||||
if (ptr)
|
||||
m_objectSelector->setObject(ptr->objectName);
|
||||
else
|
||||
m_objectSelector->clearObject();
|
||||
}
|
||||
|
||||
setScript(m_action.script);
|
||||
|
||||
@ -46,11 +69,11 @@ void ExecuteCodeDialog::accept()
|
||||
}
|
||||
|
||||
if (m_radioButtonSelf->isChecked())
|
||||
m_action.appliesTo = ExecuteCodeAction::AppliesTo::Self;
|
||||
m_action.appliesTo = AppliesToSelf{};
|
||||
else if (m_radioButtonOther->isChecked())
|
||||
m_action.appliesTo = ExecuteCodeAction::AppliesTo::Other;
|
||||
m_action.appliesTo = AppliesToOther{};
|
||||
else if (m_radioButtonObject->isChecked())
|
||||
m_action.appliesTo = ExecuteCodeAction::AppliesTo::Object;
|
||||
m_action.appliesTo = AppliesToObject{ .objectName = m_objectSelector->objectName() };
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(this, tr("No Applies To selected!"), tr("No Applies To selected!"));
|
||||
|
@ -4,13 +4,15 @@
|
||||
|
||||
class QRadioButton;
|
||||
struct ExecuteCodeAction;
|
||||
class ProjectTreeModel;
|
||||
class ObjectSelectorWidget;
|
||||
|
||||
class ExecuteCodeDialog : public CodeEditorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ExecuteCodeDialog(ExecuteCodeAction &action, QWidget *parent = nullptr);
|
||||
explicit ExecuteCodeDialog(ExecuteCodeAction &action, ProjectTreeModel *projectModel, QWidget *parent = nullptr);
|
||||
|
||||
void accept() override;
|
||||
|
||||
@ -20,4 +22,6 @@ private:
|
||||
QRadioButton * const m_radioButtonSelf;
|
||||
QRadioButton * const m_radioButtonOther;
|
||||
QRadioButton * const m_radioButtonObject;
|
||||
|
||||
ObjectSelectorWidget * const m_objectSelector;
|
||||
};
|
||||
|
@ -3,13 +3,23 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
MoveFixedDialog::MoveFixedDialog(MoveFixedAction &action, QWidget *parent) :
|
||||
MoveFixedDialog::MoveFixedDialog(MoveFixedAction &action, ProjectTreeModel *projectModel, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::MoveFixedDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
{
|
||||
QSizePolicy sp_retain = m_ui->widgetObject->sizePolicy();
|
||||
sp_retain.setRetainSizeWhenHidden(true);
|
||||
m_ui->widgetObject->setSizePolicy(sp_retain);
|
||||
}
|
||||
m_ui->widgetObject->setProjectModel(projectModel);
|
||||
|
||||
m_ui->widgetObject->setEmptySelectionText(tr("self"));
|
||||
m_ui->widgetObject->setShowClearObjectAction(false);
|
||||
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok))
|
||||
button->setIcon(QIcon{":/qtgameengine/icons/ok.png"});
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Cancel))
|
||||
|
@ -6,13 +6,14 @@
|
||||
|
||||
namespace Ui { class MoveFixedDialog; }
|
||||
class MoveFixedAction;
|
||||
class ProjectTreeModel;
|
||||
|
||||
class MoveFixedDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MoveFixedDialog(MoveFixedAction &action, QWidget *parent = nullptr);
|
||||
explicit MoveFixedDialog(MoveFixedAction &action, ProjectTreeModel *projectModel, QWidget *parent = nullptr);
|
||||
~MoveFixedDialog() override;
|
||||
|
||||
private:
|
||||
|
@ -50,7 +50,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonObject">
|
||||
<property name="text">
|
||||
@ -59,12 +59,9 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
<widget class="ObjectSelectorWidget" name="widgetObject" native="true">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -285,6 +282,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ObjectSelectorWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/objectselectorwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../resources_editor.qrc"/>
|
||||
</resources>
|
||||
@ -321,5 +326,21 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>radioButtonObject</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widgetObject</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>127</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>289</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
@ -3,13 +3,23 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
MoveFreeDialog::MoveFreeDialog(MoveFreeAction &action, QWidget *parent) :
|
||||
MoveFreeDialog::MoveFreeDialog(MoveFreeAction &action, ProjectTreeModel *projectModel, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::MoveFreeDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
{
|
||||
QSizePolicy sp_retain = m_ui->widgetObject->sizePolicy();
|
||||
sp_retain.setRetainSizeWhenHidden(true);
|
||||
m_ui->widgetObject->setSizePolicy(sp_retain);
|
||||
}
|
||||
m_ui->widgetObject->setProjectModel(projectModel);
|
||||
|
||||
m_ui->widgetObject->setEmptySelectionText(tr("self"));
|
||||
m_ui->widgetObject->setShowClearObjectAction(false);
|
||||
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok))
|
||||
button->setIcon(QIcon{":/qtgameengine/icons/ok.png"});
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Cancel))
|
||||
|
@ -6,13 +6,14 @@
|
||||
|
||||
namespace Ui { class MoveFreeDialog; }
|
||||
class MoveFreeAction;
|
||||
class ProjectTreeModel;
|
||||
|
||||
class MoveFreeDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MoveFreeDialog(MoveFreeAction &action, QWidget *parent = nullptr);
|
||||
explicit MoveFreeDialog(MoveFreeAction &action, ProjectTreeModel *projectModel, QWidget *parent = nullptr);
|
||||
~MoveFreeDialog() override;
|
||||
|
||||
private:
|
||||
|
@ -50,7 +50,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonObject">
|
||||
<property name="text">
|
||||
@ -59,12 +59,9 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
<widget class="ObjectSelectorWidget" name="widgetObject" native="true">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -188,6 +185,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ObjectSelectorWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/objectselectorwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../resources_editor.qrc"/>
|
||||
</resources>
|
||||
@ -224,5 +229,21 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>radioButtonObject</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widgetObject</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>127</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>289</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
@ -3,13 +3,23 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
MoveTowardsDialog::MoveTowardsDialog(MoveTowardsAction &action, QWidget *parent) :
|
||||
MoveTowardsDialog::MoveTowardsDialog(MoveTowardsAction &action, ProjectTreeModel *projectModel, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::MoveTowardsDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
{
|
||||
QSizePolicy sp_retain = m_ui->widgetObject->sizePolicy();
|
||||
sp_retain.setRetainSizeWhenHidden(true);
|
||||
m_ui->widgetObject->setSizePolicy(sp_retain);
|
||||
}
|
||||
m_ui->widgetObject->setProjectModel(projectModel);
|
||||
|
||||
m_ui->widgetObject->setEmptySelectionText(tr("self"));
|
||||
m_ui->widgetObject->setShowClearObjectAction(false);
|
||||
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok))
|
||||
button->setIcon(QIcon{":/qtgameengine/icons/ok.png"});
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Cancel))
|
||||
|
@ -6,13 +6,14 @@
|
||||
|
||||
namespace Ui { class MoveTowardsDialog; }
|
||||
class MoveTowardsAction;
|
||||
class ProjectTreeModel;
|
||||
|
||||
class MoveTowardsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MoveTowardsDialog(MoveTowardsAction &action, QWidget *parent = nullptr);
|
||||
explicit MoveTowardsDialog(MoveTowardsAction &action, ProjectTreeModel *projectModel, QWidget *parent = nullptr);
|
||||
~MoveTowardsDialog() override;
|
||||
|
||||
private:
|
||||
|
@ -50,7 +50,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonObject">
|
||||
<property name="text">
|
||||
@ -59,12 +59,9 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
<widget class="ObjectSelectorWidget" name="widgetObject" native="true">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -201,6 +198,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ObjectSelectorWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/objectselectorwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../resources_editor.qrc"/>
|
||||
</resources>
|
||||
@ -237,5 +242,21 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>radioButtonObject</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widgetObject</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>127</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>289</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
29
src/editor/dialogs/actions/setgravitydialog.cpp
Normal file
29
src/editor/dialogs/actions/setgravitydialog.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "setgravitydialog.h"
|
||||
#include "ui_setgravitydialog.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
SetGravityDialog::SetGravityDialog(SetGravityAction &action, ProjectTreeModel *projectModel, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::SetGravityDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
{
|
||||
QSizePolicy sp_retain = m_ui->widgetObject->sizePolicy();
|
||||
sp_retain.setRetainSizeWhenHidden(true);
|
||||
m_ui->widgetObject->setSizePolicy(sp_retain);
|
||||
}
|
||||
m_ui->widgetObject->setProjectModel(projectModel);
|
||||
|
||||
m_ui->widgetObject->setEmptySelectionText(tr("self"));
|
||||
m_ui->widgetObject->setShowClearObjectAction(false);
|
||||
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok))
|
||||
button->setIcon(QIcon{":/qtgameengine/icons/ok.png"});
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Cancel))
|
||||
button->setIcon(QIcon{":/qtgameengine/icons/delete.png"});
|
||||
}
|
||||
|
||||
SetGravityDialog::~SetGravityDialog() = default;
|
23
src/editor/dialogs/actions/setgravitydialog.h
Normal file
23
src/editor/dialogs/actions/setgravitydialog.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class SetGravityDialog; }
|
||||
struct SetGravityAction;
|
||||
class ProjectTreeModel;
|
||||
|
||||
class SetGravityDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SetGravityDialog(SetGravityAction &action, ProjectTreeModel *projectModel, QWidget *parent = nullptr);
|
||||
~SetGravityDialog() override;
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::SetGravityDialog> m_ui;
|
||||
|
||||
SetGravityAction &m_action;
|
||||
};
|
249
src/editor/dialogs/actions/setgravitydialog.ui
Normal file
249
src/editor/dialogs/actions/setgravitydialog.ui
Normal file
@ -0,0 +1,249 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SetGravityDialog</class>
|
||||
<widget class="QDialog" name="SetGravityDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>435</width>
|
||||
<height>429</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Set Gravity</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1,0">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../resources_editor.qrc">:/qtgameengine/icons/action-set-gravity.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Applies to</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonSelf">
|
||||
<property name="text">
|
||||
<string>Self</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonOther">
|
||||
<property name="text">
|
||||
<string>Other</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonObject">
|
||||
<property name="text">
|
||||
<string>Object:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ObjectSelectorWidget" name="widgetObject" native="true">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelDirection">
|
||||
<property name="text">
|
||||
<string>direction:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxDirection</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxDirection"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelGravity">
|
||||
<property name="text">
|
||||
<string>gravity:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxGravity</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxGravity"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxRelative">
|
||||
<property name="text">
|
||||
<string>Relative</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ObjectSelectorWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/objectselectorwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../resources_editor.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>SetGravityDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>257</x>
|
||||
<y>419</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>SetGravityDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>325</x>
|
||||
<y>419</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>radioButtonObject</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widgetObject</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>127</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>289</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -3,13 +3,23 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
SpeedHorizontalDialog::SpeedHorizontalDialog(SpeedHorizontalAction &action, QWidget *parent) :
|
||||
SpeedHorizontalDialog::SpeedHorizontalDialog(SpeedHorizontalAction &action, ProjectTreeModel *projectModel, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::SpeedHorizontalDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
{
|
||||
QSizePolicy sp_retain = m_ui->widgetObject->sizePolicy();
|
||||
sp_retain.setRetainSizeWhenHidden(true);
|
||||
m_ui->widgetObject->setSizePolicy(sp_retain);
|
||||
}
|
||||
m_ui->widgetObject->setProjectModel(projectModel);
|
||||
|
||||
m_ui->widgetObject->setEmptySelectionText(tr("self"));
|
||||
m_ui->widgetObject->setShowClearObjectAction(false);
|
||||
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok))
|
||||
button->setIcon(QIcon{":/qtgameengine/icons/ok.png"});
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Cancel))
|
||||
|
@ -6,13 +6,14 @@
|
||||
|
||||
namespace Ui { class SpeedHorizontalDialog; }
|
||||
struct SpeedHorizontalAction;
|
||||
class ProjectTreeModel;
|
||||
|
||||
class SpeedHorizontalDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SpeedHorizontalDialog(SpeedHorizontalAction &action, QWidget *parent = nullptr);
|
||||
explicit SpeedHorizontalDialog(SpeedHorizontalAction &action, ProjectTreeModel *projectModel, QWidget *parent = nullptr);
|
||||
~SpeedHorizontalDialog() override;
|
||||
|
||||
private:
|
||||
|
@ -6,31 +6,183 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>435</width>
|
||||
<height>429</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Speed Horizontal</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>240</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1,0">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../resources_editor.qrc">:/qtgameengine/icons/action-speed-horizontal.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Applies to</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonSelf">
|
||||
<property name="text">
|
||||
<string>Self</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonOther">
|
||||
<property name="text">
|
||||
<string>Other</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonObject">
|
||||
<property name="text">
|
||||
<string>Object:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ObjectSelectorWidget" name="widgetObject" native="true">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelHorSpeed">
|
||||
<property name="text">
|
||||
<string>hor. speed:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxHorSpeed</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxHorSpeed"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxRelative">
|
||||
<property name="text">
|
||||
<string>Relative</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ObjectSelectorWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/objectselectorwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../resources_editor.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
@ -39,8 +191,8 @@
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
<x>257</x>
|
||||
<y>419</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
@ -55,8 +207,8 @@
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
<x>325</x>
|
||||
<y>419</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
@ -64,5 +216,21 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>radioButtonObject</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widgetObject</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>127</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>289</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
@ -3,13 +3,23 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
SpeedVerticalDialog::SpeedVerticalDialog(SpeedVerticalAction &action, QWidget *parent) :
|
||||
SpeedVerticalDialog::SpeedVerticalDialog(SpeedVerticalAction &action, ProjectTreeModel *projectModel, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::SpeedVerticalDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
{
|
||||
QSizePolicy sp_retain = m_ui->widgetObject->sizePolicy();
|
||||
sp_retain.setRetainSizeWhenHidden(true);
|
||||
m_ui->widgetObject->setSizePolicy(sp_retain);
|
||||
}
|
||||
m_ui->widgetObject->setProjectModel(projectModel);
|
||||
|
||||
m_ui->widgetObject->setEmptySelectionText(tr("self"));
|
||||
m_ui->widgetObject->setShowClearObjectAction(false);
|
||||
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok))
|
||||
button->setIcon(QIcon{":/qtgameengine/icons/ok.png"});
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Cancel))
|
||||
|
@ -6,13 +6,14 @@
|
||||
|
||||
namespace Ui { class SpeedVerticalDialog; }
|
||||
struct SpeedVerticalAction;
|
||||
class ProjectTreeModel;
|
||||
|
||||
class SpeedVerticalDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SpeedVerticalDialog(SpeedVerticalAction &action, QWidget *parent = nullptr);
|
||||
explicit SpeedVerticalDialog(SpeedVerticalAction &action, ProjectTreeModel *projectModel, QWidget *parent = nullptr);
|
||||
~SpeedVerticalDialog() override;
|
||||
|
||||
private:
|
||||
|
@ -6,31 +6,183 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>435</width>
|
||||
<height>429</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Speed Vertical</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>240</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1,0">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../resources_editor.qrc">:/qtgameengine/icons/action-speed-vertical.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Applies to</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonSelf">
|
||||
<property name="text">
|
||||
<string>Self</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonOther">
|
||||
<property name="text">
|
||||
<string>Other</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonObject">
|
||||
<property name="text">
|
||||
<string>Object:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ObjectSelectorWidget" name="widgetObject" native="true">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelVertSpeed">
|
||||
<property name="text">
|
||||
<string>vert. speed:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxVertSpeed</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxVertSpeed"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxRelative">
|
||||
<property name="text">
|
||||
<string>Relative</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ObjectSelectorWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/objectselectorwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../resources_editor.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
@ -39,8 +191,8 @@
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
<x>257</x>
|
||||
<y>419</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
@ -55,8 +207,8 @@
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
<x>325</x>
|
||||
<y>419</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
@ -64,5 +216,21 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>radioButtonObject</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widgetObject</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>127</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>289</x>
|
||||
<y>115</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
@ -115,9 +115,9 @@ void CodeEditorDialog::changed()
|
||||
}
|
||||
}
|
||||
|
||||
void CodeEditorDialog::addToolbarWidget(QWidget *widget)
|
||||
QAction *CodeEditorDialog::addToolbarWidget(QWidget *widget)
|
||||
{
|
||||
m_ui->toolBar->addWidget(widget);
|
||||
return m_ui->toolBar->addWidget(widget);
|
||||
}
|
||||
|
||||
void CodeEditorDialog::loadCode()
|
||||
|
@ -30,7 +30,7 @@ protected slots:
|
||||
protected:
|
||||
bool m_unsavedChanges{};
|
||||
|
||||
void addToolbarWidget(QWidget *widget);
|
||||
QAction *addToolbarWidget(QWidget *widget);
|
||||
|
||||
private slots:
|
||||
void loadCode();
|
||||
|
@ -22,10 +22,8 @@ ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel
|
||||
m_collisionEvents{m_object.collisionEvents},
|
||||
m_eventsModel{std::make_unique<ObjectEventsModel>(m_events, m_collisionEvents)},
|
||||
m_menuSprites{new QMenu{this}},
|
||||
m_menuParents{new QMenu{this}},
|
||||
m_menuMaskSprites{new QMenu{this}},
|
||||
m_spriteName{object.spriteName},
|
||||
m_parentName{object.parentName},
|
||||
m_maskSpriteName{object.maskSpriteName}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
@ -37,13 +35,20 @@ ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel
|
||||
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Cancel))
|
||||
button->setIcon(QIcon{":/qtgameengine/icons/delete.png"});
|
||||
|
||||
m_ui->widgetParent->setProjectModel(&m_projectModel);
|
||||
m_ui->widgetParent->setForbiddenObjectName(m_object.name);
|
||||
m_ui->actionsWidget->setProjectModel(&m_projectModel);
|
||||
|
||||
m_ui->lineEditName->setText(m_object.name);
|
||||
m_ui->lineEditSprite->setText(m_spriteName.isEmpty() ? tr("<no sprite>") : m_spriteName);
|
||||
m_ui->lineEditParent->setText(m_parentName.isEmpty() ? tr("<no parent>") : m_parentName);
|
||||
m_ui->widgetParent->setEmptySelectionText(tr("<no parent>"));
|
||||
if (QSignalBlocker blocker{m_ui->widgetParent}; object.parentName.isEmpty())
|
||||
m_ui->widgetParent->clearObject();
|
||||
else
|
||||
m_ui->widgetParent->setObject(object.parentName);
|
||||
m_ui->lineEditMask->setText(m_maskSpriteName.isEmpty() ? tr("<same as sprite>") : m_maskSpriteName);
|
||||
updateSpritePreview();
|
||||
m_ui->toolButtonSprite->setMenu(m_menuSprites);
|
||||
m_ui->toolButtonParent->setMenu(m_menuParents);
|
||||
m_ui->toolButtonMask->setMenu(m_menuMaskSprites);
|
||||
m_ui->checkBoxVisible->setChecked(m_object.visible);
|
||||
m_ui->checkBoxSolid->setChecked(m_object.solid);
|
||||
@ -51,7 +56,6 @@ ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel
|
||||
m_ui->checkBoxPersistent->setChecked(m_object.persistent);
|
||||
|
||||
m_ui->lineEditSprite->setMenu(m_menuSprites);
|
||||
m_ui->lineEditParent->setMenu(m_menuParents);
|
||||
m_ui->lineEditMask->setMenu(m_menuMaskSprites);
|
||||
|
||||
m_ui->listViewEvents->setModel(m_eventsModel.get());
|
||||
@ -104,11 +108,12 @@ ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel
|
||||
|
||||
connect(m_menuSprites, &QMenu::aboutToShow,
|
||||
this, &ObjectPropertiesDialog::spritesMenuAboutToShow);
|
||||
connect(m_menuParents, &QMenu::aboutToShow,
|
||||
this, &ObjectPropertiesDialog::parentsMenuAboutToShow);
|
||||
connect(m_menuMaskSprites, &QMenu::aboutToShow,
|
||||
this, &ObjectPropertiesDialog::maskSpritesMenuAboutToShow);
|
||||
|
||||
connect(m_ui->widgetParent, &ObjectSelectorWidget::changed,
|
||||
this, &ObjectPropertiesDialog::changed);
|
||||
|
||||
connect(m_ui->listViewEvents->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||
this, &ObjectPropertiesDialog::currentEventChanged);
|
||||
|
||||
@ -148,7 +153,7 @@ void ObjectPropertiesDialog::accept()
|
||||
m_object.solid = m_ui->checkBoxSolid->isChecked();
|
||||
m_object.depth = m_ui->spinBoxDepth->value();
|
||||
m_object.persistent = m_ui->checkBoxPersistent->isChecked();
|
||||
m_object.parentName = m_parentName;
|
||||
m_object.parentName = m_ui->widgetParent->objectName();
|
||||
m_object.maskSpriteName = m_maskSpriteName;
|
||||
m_object.events = std::move(m_events);
|
||||
m_object.collisionEvents = std::move(m_collisionEvents);
|
||||
@ -283,11 +288,9 @@ void ObjectPropertiesDialog::objectNameChanged(const Object &object, const QStri
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
if (!m_parentName.isEmpty() && m_parentName == oldName)
|
||||
{
|
||||
m_parentName = object.name;
|
||||
m_ui->lineEditParent->setText(object.name);
|
||||
}
|
||||
if (QSignalBlocker blocker{m_ui->widgetParent};
|
||||
!m_ui->widgetParent->objectName().isEmpty() && m_ui->widgetParent->objectName() == oldName)
|
||||
m_ui->widgetParent->setObject(object.name);
|
||||
}
|
||||
|
||||
void ObjectPropertiesDialog::spriteNameChanged(const Sprite &sprite, const QString &oldName)
|
||||
@ -314,11 +317,9 @@ void ObjectPropertiesDialog::spriteNameChanged(const Sprite &sprite, const QStri
|
||||
|
||||
void ObjectPropertiesDialog::objectAboutToBeRemoved(const Object &object)
|
||||
{
|
||||
if (!m_parentName.isEmpty() && m_parentName == object.name)
|
||||
{
|
||||
m_parentName.clear();
|
||||
m_ui->lineEditParent->setText(tr("<no parent>"));
|
||||
}
|
||||
if (QSignalBlocker blocker{m_ui->widgetParent};
|
||||
!m_ui->widgetParent->objectName().isEmpty() && m_ui->widgetParent->objectName() == object.name)
|
||||
m_ui->widgetParent->clearObject();
|
||||
}
|
||||
|
||||
void ObjectPropertiesDialog::spriteAboutToBeRemoved(const Sprite &sprite)
|
||||
@ -365,29 +366,6 @@ void ObjectPropertiesDialog::spritesMenuAboutToShow()
|
||||
[&sprite,this](){ setSprite(sprite); });
|
||||
}
|
||||
|
||||
void ObjectPropertiesDialog::parentsMenuAboutToShow()
|
||||
{
|
||||
m_menuParents->clear();
|
||||
m_menuParents->addAction(tr("<no parent>"), this, &ObjectPropertiesDialog::clearParent);
|
||||
for (const Object &object : m_projectModel.project()->objects)
|
||||
{
|
||||
QIcon icon;
|
||||
if (!object.spriteName.isEmpty())
|
||||
{
|
||||
const auto &sprites = m_projectModel.project()->sprites;
|
||||
const auto iter = std::find_if(std::cbegin(sprites), std::cend(sprites),
|
||||
[&](const Sprite &sprite){ return sprite.name == object.spriteName; });
|
||||
if (iter != std::cend(sprites))
|
||||
{
|
||||
if (!iter->pixmaps.empty())
|
||||
icon = iter->pixmaps.front();
|
||||
}
|
||||
}
|
||||
m_menuParents->addAction(icon, object.name, this,
|
||||
[&object,this](){ setParent(object); });
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectPropertiesDialog::maskSpritesMenuAboutToShow()
|
||||
{
|
||||
m_menuMaskSprites->clear();
|
||||
@ -449,26 +427,6 @@ void ObjectPropertiesDialog::setSprite(const Sprite &sprite)
|
||||
changed();
|
||||
}
|
||||
|
||||
void ObjectPropertiesDialog::clearParent()
|
||||
{
|
||||
m_parentName.clear();
|
||||
m_ui->lineEditParent->setText(tr("<no parent>"));
|
||||
changed();
|
||||
}
|
||||
|
||||
void ObjectPropertiesDialog::setParent(const Object &object)
|
||||
{
|
||||
if (&m_object == &object)
|
||||
{
|
||||
QMessageBox::warning(this, tr("This will create a loop in parents."), tr("This will create a loop in parents."));
|
||||
return;
|
||||
}
|
||||
|
||||
m_parentName = object.name;
|
||||
m_ui->lineEditParent->setText(object.name);
|
||||
changed();
|
||||
}
|
||||
|
||||
void ObjectPropertiesDialog::clearMaskSprite()
|
||||
{
|
||||
m_maskSpriteName.clear();
|
||||
|
@ -42,7 +42,6 @@ private slots:
|
||||
void spritePixmapsChanged(const Sprite &sprite);
|
||||
|
||||
void spritesMenuAboutToShow();
|
||||
void parentsMenuAboutToShow();
|
||||
void maskSpritesMenuAboutToShow();
|
||||
void currentEventChanged(const QModelIndex &index);
|
||||
void eventsContextMenuRequested(const QPoint &pos);
|
||||
@ -51,9 +50,6 @@ private slots:
|
||||
void clearSprite();
|
||||
void setSprite(const Sprite &sprite);
|
||||
|
||||
void clearParent();
|
||||
void setParent(const Object &object);
|
||||
|
||||
void clearMaskSprite();
|
||||
void setMaskSprite(const Sprite &sprite);
|
||||
|
||||
@ -74,11 +70,9 @@ private:
|
||||
const std::unique_ptr<ObjectEventsModel> m_eventsModel;
|
||||
|
||||
QMenu * const m_menuSprites;
|
||||
QMenu * const m_menuParents;
|
||||
QMenu * const m_menuMaskSprites;
|
||||
|
||||
QString m_spriteName;
|
||||
QString m_parentName;
|
||||
QString m_maskSpriteName;
|
||||
|
||||
bool m_unsavedChanges{};
|
||||
|
@ -204,42 +204,12 @@
|
||||
<string>Parent:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditParent</cstring>
|
||||
<cstring>widgetParent</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEditWithMenu" name="lineEditParent">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The parent from which events and actions are</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><no parent></string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButtonParent">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="ObjectParentSelectorWidget" name="widgetParent" native="true"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
@ -431,6 +401,12 @@
|
||||
<extends>QLineEdit</extends>
|
||||
<header>widgets/qlineeditwithmenu.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ObjectParentSelectorWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/objectparentselectorwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../resources_editor.qrc"/>
|
||||
|
BIN
src/editor/icons/action-set-gravity.png
Normal file
BIN
src/editor/icons/action-set-gravity.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -54,6 +54,8 @@ QVariant ActionsContainerModel::data(const QModelIndex &index, int role) const
|
||||
return tr("Set the horizontal speed");
|
||||
else if (std::holds_alternative<SpeedVerticalAction>(action))
|
||||
return tr("Set the vertical speed");
|
||||
else if (std::holds_alternative<SetGravityAction>(action))
|
||||
return tr("Set the gravity");
|
||||
else if (std::holds_alternative<ExecuteCodeAction>(action))
|
||||
return tr("Execute a piece of code");
|
||||
else
|
||||
@ -72,6 +74,8 @@ QVariant ActionsContainerModel::data(const QModelIndex &index, int role) const
|
||||
return QIcon{":/qtgameengine/icons/action-speed-horizontal.png"};
|
||||
else if (std::holds_alternative<SpeedVerticalAction>(action))
|
||||
return QIcon{":/qtgameengine/icons/action-speed-vertical.png"};
|
||||
else if (std::holds_alternative<SetGravityAction>(action))
|
||||
return QIcon{":/qtgameengine/icons/action-set-gravity.png"};
|
||||
else if (std::holds_alternative<ExecuteCodeAction>(action))
|
||||
return QIcon{":/qtgameengine/icons/action-execute-code.png"};
|
||||
else
|
||||
|
@ -28,7 +28,8 @@ public:
|
||||
bool removeRows(int row, int count, const QModelIndex &parent) override;
|
||||
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
|
||||
|
||||
ActionsContainer *actionsContainer() const { return m_actionsContainer; }
|
||||
ActionsContainer *actionsContainer() { return m_actionsContainer; }
|
||||
const ActionsContainer *actionsContainer() const { return m_actionsContainer; }
|
||||
void setActionsContainer(ActionsContainer *actionsContainer);
|
||||
|
||||
Action *getAction(const QModelIndex &index);
|
||||
|
@ -5,6 +5,7 @@
|
||||
<file>icons/action-move-fixed.png</file>
|
||||
<file>icons/action-move-free.png</file>
|
||||
<file>icons/action-move-towards.png</file>
|
||||
<file>icons/action-set-gravity.png</file>
|
||||
<file>icons/action-speed-horizontal.png</file>
|
||||
<file>icons/action-speed-vertical.png</file>
|
||||
<file>icons/add.png</file>
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "dialogs/actions/movetowardsdialog.h"
|
||||
#include "dialogs/actions/speedhorizontaldialog.h"
|
||||
#include "dialogs/actions/speedverticaldialog.h"
|
||||
#include "dialogs/actions/setgravitydialog.h"
|
||||
#include "dialogs/actions/executecodedialog.h"
|
||||
|
||||
namespace {
|
||||
@ -21,6 +22,7 @@ template<> struct ActionDialogForImpl<MoveFreeAction> { using Dialog = MoveFreeD
|
||||
template<> struct ActionDialogForImpl<MoveTowardsAction> { using Dialog = MoveTowardsDialog; };
|
||||
template<> struct ActionDialogForImpl<SpeedHorizontalAction> { using Dialog = SpeedHorizontalDialog; };
|
||||
template<> struct ActionDialogForImpl<SpeedVerticalAction> { using Dialog = SpeedVerticalDialog; };
|
||||
template<> struct ActionDialogForImpl<SetGravityAction> { using Dialog = SetGravityDialog; };
|
||||
template<> struct ActionDialogForImpl<ExecuteCodeAction> { using Dialog = ExecuteCodeDialog; };
|
||||
template<typename T> using ActionDialogFor = ActionDialogForImpl<T>::Dialog;
|
||||
}
|
||||
@ -61,6 +63,8 @@ ActionsContainerWidget::ActionsContainerWidget(QWidget *parent) :
|
||||
this, &ActionsContainerWidget::createNewAction<SpeedHorizontalAction>);
|
||||
connect(m_ui->toolButtonSpeedVertical, &QAbstractButton::clicked,
|
||||
this, &ActionsContainerWidget::createNewAction<SpeedVerticalAction>);
|
||||
connect(m_ui->toolButtonSetGravity, &QAbstractButton::clicked,
|
||||
this, &ActionsContainerWidget::createNewAction<SetGravityAction>);
|
||||
connect(m_ui->toolButtonExecuteCode, &QAbstractButton::clicked,
|
||||
this, &ActionsContainerWidget::createNewAction<ExecuteCodeAction>);
|
||||
|
||||
@ -69,12 +73,18 @@ ActionsContainerWidget::ActionsContainerWidget(QWidget *parent) :
|
||||
m_ui->toolButtonMoveTowards->setAction(MoveTowardsAction{});
|
||||
m_ui->toolButtonSpeedHorizontal->setAction(SpeedHorizontalAction{});
|
||||
m_ui->toolButtonSpeedVertical->setAction(SpeedVerticalAction{});
|
||||
m_ui->toolButtonSetGravity->setAction(SetGravityAction{});
|
||||
m_ui->toolButtonExecuteCode->setAction(ExecuteCodeAction{});
|
||||
}
|
||||
|
||||
ActionsContainerWidget::~ActionsContainerWidget() = default;
|
||||
|
||||
ActionsContainer *ActionsContainerWidget::actionsContainer() const
|
||||
ActionsContainer *ActionsContainerWidget::actionsContainer()
|
||||
{
|
||||
return m_actionsModel->actionsContainer();
|
||||
}
|
||||
|
||||
const ActionsContainer *ActionsContainerWidget::actionsContainer() const
|
||||
{
|
||||
return m_actionsModel->actionsContainer();
|
||||
}
|
||||
@ -95,37 +105,43 @@ void ActionsContainerWidget::actionDoubleClicked(const QModelIndex &index)
|
||||
|
||||
if (auto ptr = std::get_if<MoveFixedAction>(action))
|
||||
{
|
||||
MoveFixedDialog dialog{*ptr, this};
|
||||
MoveFixedDialog dialog{*ptr, m_projectModel, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<MoveFreeAction>(action))
|
||||
{
|
||||
MoveFreeDialog dialog{*ptr, this};
|
||||
MoveFreeDialog dialog{*ptr, m_projectModel, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<MoveTowardsAction>(action))
|
||||
{
|
||||
MoveTowardsDialog dialog{*ptr, this};
|
||||
MoveTowardsDialog dialog{*ptr, m_projectModel, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<SpeedHorizontalAction>(action))
|
||||
{
|
||||
SpeedHorizontalDialog dialog{*ptr, this};
|
||||
SpeedHorizontalDialog dialog{*ptr, m_projectModel, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<SpeedVerticalAction>(action))
|
||||
{
|
||||
SpeedVerticalDialog dialog{*ptr, this};
|
||||
SpeedVerticalDialog dialog{*ptr, m_projectModel, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<SetGravityAction>(action))
|
||||
{
|
||||
SetGravityDialog dialog{*ptr, m_projectModel, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<ExecuteCodeAction>(action))
|
||||
{
|
||||
ExecuteCodeDialog dialog{*ptr, this};
|
||||
ExecuteCodeDialog dialog{*ptr, m_projectModel, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
@ -205,7 +221,7 @@ void ActionsContainerWidget::createNewAction()
|
||||
return;
|
||||
|
||||
T action;
|
||||
ActionDialogFor<T> dialog{action, this};
|
||||
ActionDialogFor<T> dialog{action, m_projectModel, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
m_actionsModel->appendAction(std::move(action));
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
namespace Ui { class ActionsContainerWidget; }
|
||||
class ActionsContainerModel;
|
||||
class ProjectTreeModel;
|
||||
|
||||
class ActionsContainerWidget : public QWidget
|
||||
{
|
||||
@ -17,7 +18,12 @@ public:
|
||||
explicit ActionsContainerWidget(QWidget *parent = nullptr);
|
||||
~ActionsContainerWidget();
|
||||
|
||||
ActionsContainer *actionsContainer() const;
|
||||
ProjectTreeModel *projectModel() { return m_projectModel; }
|
||||
const ProjectTreeModel *projectModel() const { return m_projectModel; }
|
||||
void setProjectModel(ProjectTreeModel *projectModel) { m_projectModel = projectModel; }
|
||||
|
||||
ActionsContainer *actionsContainer();
|
||||
const ActionsContainer *actionsContainer() const;
|
||||
void setActionsContainer(ActionsContainer *actionsContainer);
|
||||
|
||||
signals:
|
||||
@ -35,4 +41,6 @@ private:
|
||||
const std::unique_ptr<Ui::ActionsContainerWidget> m_ui;
|
||||
|
||||
const std::unique_ptr<ActionsContainerModel> m_actionsModel;
|
||||
|
||||
ProjectTreeModel *m_projectModel{};
|
||||
};
|
||||
|
@ -257,13 +257,13 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QToolButton" name="toolButtonSetGravity">
|
||||
<widget class="ActionDragWidget" name="toolButtonSetGravity">
|
||||
<property name="toolTip">
|
||||
<string>Set Gravity</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/action.png</normaloff>:/qtgameengine/icons/action.png</iconset>
|
||||
<normaloff>:/qtgameengine/icons/action-set-gravity.png</normaloff>:/qtgameengine/icons/action-set-gravity.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
14
src/editor/widgets/objectparentselectorwidget.cpp
Normal file
14
src/editor/widgets/objectparentselectorwidget.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "objectparentselectorwidget.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
void ObjectParentSelectorWidget::setObject(const QString &objectName)
|
||||
{
|
||||
if (!m_forbiddenObjectName.isEmpty() && m_forbiddenObjectName == objectName)
|
||||
{
|
||||
QMessageBox::warning(this, tr("This will create a loop in parents."), tr("This will create a loop in parents."));
|
||||
return;
|
||||
}
|
||||
|
||||
ObjectSelectorWidget::setObject(objectName);
|
||||
}
|
19
src/editor/widgets/objectparentselectorwidget.h
Normal file
19
src/editor/widgets/objectparentselectorwidget.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "objectselectorwidget.h"
|
||||
|
||||
class ObjectParentSelectorWidget : public ObjectSelectorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using ObjectSelectorWidget::ObjectSelectorWidget;
|
||||
|
||||
QString forbiddenObjectName() const { return m_forbiddenObjectName; };
|
||||
void setForbiddenObjectName(const QString &forbiddenObjectName) { m_forbiddenObjectName = forbiddenObjectName; }
|
||||
|
||||
void setObject(const QString &objectName) override;
|
||||
|
||||
private:
|
||||
QString m_forbiddenObjectName;
|
||||
};
|
83
src/editor/widgets/objectselectorwidget.cpp
Normal file
83
src/editor/widgets/objectselectorwidget.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
#include "objectselectorwidget.h"
|
||||
#include "ui_objectselectorwidget.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QDebug>
|
||||
|
||||
#include "models/projecttreemodel.h"
|
||||
#include "projectcontainer.h"
|
||||
|
||||
ObjectSelectorWidget::ObjectSelectorWidget(QWidget *parent) :
|
||||
QWidget{parent},
|
||||
m_ui{std::make_unique<Ui::ObjectSelectorWidget>()},
|
||||
m_menuObjects{new QMenu{this}}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->lineEdit->setMenu(m_menuObjects);
|
||||
m_ui->toolButton->setMenu(m_menuObjects);
|
||||
|
||||
connect(m_menuObjects, &QMenu::aboutToShow,
|
||||
this, &ObjectSelectorWidget::menuAboutToShow);
|
||||
}
|
||||
|
||||
ObjectSelectorWidget::~ObjectSelectorWidget() = default;
|
||||
|
||||
void ObjectSelectorWidget::setObject(const QString &objectName)
|
||||
{
|
||||
if (m_objectName == objectName)
|
||||
return;
|
||||
|
||||
m_objectName = objectName;
|
||||
m_ui->lineEdit->setText(objectName);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void ObjectSelectorWidget::clearObject()
|
||||
{
|
||||
if (m_objectName.isEmpty())
|
||||
return;
|
||||
|
||||
m_objectName.clear();
|
||||
m_ui->lineEdit->setText(m_emptySelectionText);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void ObjectSelectorWidget::setEmptySelectionText(const QString &emptySelectionText)
|
||||
{
|
||||
m_emptySelectionText = emptySelectionText;
|
||||
if (m_objectName.isEmpty())
|
||||
m_ui->lineEdit->setText(m_emptySelectionText);
|
||||
}
|
||||
|
||||
void ObjectSelectorWidget::menuAboutToShow()
|
||||
{
|
||||
if (!m_projectModel)
|
||||
{
|
||||
qCritical() << "no project model!";
|
||||
return;
|
||||
}
|
||||
|
||||
m_menuObjects->clear();
|
||||
|
||||
if (m_showClearObjectAction)
|
||||
m_menuObjects->addAction(m_emptySelectionText, this, &ObjectSelectorWidget::clearObject);
|
||||
|
||||
for (const Object &object : m_projectModel->project()->objects)
|
||||
{
|
||||
QIcon icon;
|
||||
if (!object.spriteName.isEmpty())
|
||||
{
|
||||
const auto &sprites = m_projectModel->project()->sprites;
|
||||
const auto iter = std::find_if(std::cbegin(sprites), std::cend(sprites),
|
||||
[&](const Sprite &sprite){ return sprite.name == object.spriteName; });
|
||||
if (iter != std::cend(sprites))
|
||||
{
|
||||
if (!iter->pixmaps.empty())
|
||||
icon = iter->pixmaps.front();
|
||||
}
|
||||
}
|
||||
m_menuObjects->addAction(icon, object.name, this,
|
||||
[&object,this](){ setObject(object.name); });
|
||||
}
|
||||
}
|
51
src/editor/widgets/objectselectorwidget.h
Normal file
51
src/editor/widgets/objectselectorwidget.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class ObjectSelectorWidget; }
|
||||
class ProjectTreeModel;
|
||||
|
||||
class ObjectSelectorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString emptySelectionText READ emptySelectionText WRITE setEmptySelectionText DESIGNABLE true FINAL)
|
||||
Q_PROPERTY(bool showClearObjectAction READ showClearObjectAction WRITE setShowClearObjectAction DESIGNABLE true FINAL)
|
||||
|
||||
public:
|
||||
explicit ObjectSelectorWidget(QWidget *parent = nullptr);
|
||||
~ObjectSelectorWidget() override;
|
||||
|
||||
ProjectTreeModel *projectModel() { return m_projectModel; }
|
||||
const ProjectTreeModel *projectModel() const { return m_projectModel; }
|
||||
void setProjectModel(ProjectTreeModel *projectModel) { m_projectModel = projectModel; }
|
||||
|
||||
QString objectName() const { return m_objectName; }
|
||||
virtual void setObject(const QString &objectName);
|
||||
void clearObject();
|
||||
|
||||
QString emptySelectionText() const { return m_emptySelectionText; }
|
||||
void setEmptySelectionText(const QString &emptySelectionText);
|
||||
|
||||
bool showClearObjectAction() const { return m_showClearObjectAction; }
|
||||
void setShowClearObjectAction(bool showClearObjectAction) { m_showClearObjectAction = showClearObjectAction; }
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
private slots:
|
||||
void menuAboutToShow();
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::ObjectSelectorWidget> m_ui;
|
||||
|
||||
ProjectTreeModel *m_projectModel{};
|
||||
|
||||
QString m_objectName;
|
||||
|
||||
QString m_emptySelectionText;
|
||||
bool m_showClearObjectAction;
|
||||
|
||||
QMenu * const m_menuObjects;
|
||||
};
|
59
src/editor/widgets/objectselectorwidget.ui
Normal file
59
src/editor/widgets/objectselectorwidget.ui
Normal file
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ObjectSelectorWidget</class>
|
||||
<widget class="QWidget" name="ObjectSelectorWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>168</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEditWithMenu" name="lineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QLineEditWithMenu</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>widgets/qlineeditwithmenu.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -157,35 +157,51 @@ struct Font
|
||||
} range;
|
||||
};
|
||||
|
||||
struct MoveFixedAction {
|
||||
struct AppliesToSelf {
|
||||
|
||||
};
|
||||
|
||||
struct AppliesToOther {
|
||||
|
||||
};
|
||||
|
||||
struct AppliesToObject {
|
||||
QString objectName;
|
||||
};
|
||||
|
||||
using AppliesTo = std::variant<
|
||||
AppliesToSelf,
|
||||
AppliesToOther,
|
||||
AppliesToObject
|
||||
>;
|
||||
|
||||
struct MoveFixedAction {
|
||||
AppliesTo appliesTo{AppliesToSelf{}};
|
||||
};
|
||||
|
||||
struct MoveFreeAction {
|
||||
|
||||
AppliesTo appliesTo{AppliesToSelf{}};
|
||||
};
|
||||
|
||||
struct MoveTowardsAction {
|
||||
|
||||
AppliesTo appliesTo{AppliesToSelf{}};
|
||||
};
|
||||
|
||||
struct SpeedHorizontalAction {
|
||||
AppliesTo appliesTo{AppliesToSelf{}};
|
||||
};
|
||||
|
||||
struct SetGravityAction {
|
||||
AppliesTo appliesTo{AppliesToSelf{}};
|
||||
};
|
||||
|
||||
struct SpeedVerticalAction {
|
||||
|
||||
AppliesTo appliesTo{AppliesToSelf{}};
|
||||
};
|
||||
|
||||
struct ExecuteCodeAction {
|
||||
enum class AppliesTo {
|
||||
Self,
|
||||
Other,
|
||||
Object
|
||||
};
|
||||
|
||||
AppliesTo appliesTo{AppliesToSelf{}};
|
||||
QString script;
|
||||
AppliesTo appliesTo{AppliesTo::Self};
|
||||
};
|
||||
|
||||
using Action = std::variant<
|
||||
@ -194,6 +210,7 @@ using Action = std::variant<
|
||||
MoveTowardsAction,
|
||||
SpeedHorizontalAction,
|
||||
SpeedVerticalAction,
|
||||
SetGravityAction,
|
||||
ExecuteCodeAction
|
||||
>;
|
||||
|
||||
|
@ -262,87 +262,143 @@ QDataStream &operator>>(QDataStream &ds, Font &font)
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const AppliesToSelf &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
//ds << action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, AppliesToSelf &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
//ds >> action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const AppliesToOther &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
//ds << action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, AppliesToOther &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
//ds >> action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const AppliesToObject &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
ds << action.objectName;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, AppliesToObject &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
ds >> action.objectName;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const MoveFixedAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds << action.;
|
||||
ds << action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, MoveFixedAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds >> action.;
|
||||
ds >> action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const MoveFreeAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds << action.;
|
||||
ds << action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, MoveFreeAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds >> action.;
|
||||
ds >> action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const MoveTowardsAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds << action.;
|
||||
ds << action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, MoveTowardsAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds >> action.;
|
||||
ds >> action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const SpeedHorizontalAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds << action.;
|
||||
ds << action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, SpeedHorizontalAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds >> action.;
|
||||
ds >> action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const SpeedVerticalAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds << action.;
|
||||
ds << action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, SpeedVerticalAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds >> action.;
|
||||
ds >> action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const SetGravityAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
ds << action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, SetGravityAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
ds >> action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const ExecuteCodeAction &action)
|
||||
{
|
||||
ds << action.script;
|
||||
ds << action.appliesTo;
|
||||
ds << action.appliesTo
|
||||
<< action.script;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, ExecuteCodeAction &action)
|
||||
{
|
||||
ds >> action.script;
|
||||
ds >> action.appliesTo;
|
||||
ds >> action.appliesTo
|
||||
>> action.script;
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,12 @@ QDataStream &operator<<(QDataStream &ds, const Script &script);
|
||||
QDataStream &operator>>(QDataStream &ds, Script &script);
|
||||
QDataStream &operator<<(QDataStream &ds, const Font &font);
|
||||
QDataStream &operator>>(QDataStream &ds, Font &font);
|
||||
QDataStream &operator<<(QDataStream &ds, const AppliesToSelf &action);
|
||||
QDataStream &operator>>(QDataStream &ds, AppliesToSelf &action);
|
||||
QDataStream &operator<<(QDataStream &ds, const AppliesToOther &action);
|
||||
QDataStream &operator>>(QDataStream &ds, AppliesToOther &action);
|
||||
QDataStream &operator<<(QDataStream &ds, const AppliesToObject &action);
|
||||
QDataStream &operator>>(QDataStream &ds, AppliesToObject &action);
|
||||
QDataStream &operator<<(QDataStream &ds, const MoveFixedAction &action);
|
||||
QDataStream &operator>>(QDataStream &ds, MoveFixedAction &action);
|
||||
QDataStream &operator<<(QDataStream &ds, const MoveFreeAction &action);
|
||||
@ -38,6 +44,8 @@ QDataStream &operator<<(QDataStream &ds, const SpeedHorizontalAction &action);
|
||||
QDataStream &operator>>(QDataStream &ds, SpeedHorizontalAction &action);
|
||||
QDataStream &operator<<(QDataStream &ds, const SpeedVerticalAction &action);
|
||||
QDataStream &operator>>(QDataStream &ds, SpeedVerticalAction &action);
|
||||
QDataStream &operator<<(QDataStream &ds, const SetGravityAction &action);
|
||||
QDataStream &operator>>(QDataStream &ds, SetGravityAction &action);
|
||||
QDataStream &operator<<(QDataStream &ds, const ExecuteCodeAction &action);
|
||||
QDataStream &operator>>(QDataStream &ds, ExecuteCodeAction &action);
|
||||
QDataStream &operator<<(QDataStream &ds, const TimeLine &timeLine);
|
||||
|
Reference in New Issue
Block a user