Add more actions and improve error message when dragged into empty actions container
This commit is contained in:
@ -26,9 +26,11 @@ INCLUDEPATH += \
|
||||
|
||||
HEADERS += \
|
||||
src/closeeventfilter.h \
|
||||
src/editor/dialogs/actions/speedhorizontaldialog.h \
|
||||
src/editor/dialogs/actions/movefreedialog.h \
|
||||
src/editor/dialogs/actions/movetowardsdialog.h \
|
||||
src/editor/dialogs/actions/executecodedialog.h \
|
||||
src/editor/dialogs/actions/speedverticaldialog.h \
|
||||
src/editor/dialogs/genericcodeeditordialog.h \
|
||||
src/editor/dialogs/includedfilepropertiesdialog.h \
|
||||
src/editor/dialogs/transparentbackgroundsettingsdialog.h \
|
||||
@ -92,8 +94,10 @@ HEADERS += \
|
||||
SOURCES += \
|
||||
src/closeeventfilter.cpp \
|
||||
src/editor/dialogs/actions/executecodedialog.cpp \
|
||||
src/editor/dialogs/actions/speedhorizontaldialog.cpp \
|
||||
src/editor/dialogs/actions/movefreedialog.cpp \
|
||||
src/editor/dialogs/actions/movetowardsdialog.cpp \
|
||||
src/editor/dialogs/actions/speedverticaldialog.cpp \
|
||||
src/editor/dialogs/genericcodeeditordialog.cpp \
|
||||
src/editor/dialogs/includedfilepropertiesdialog.cpp \
|
||||
src/editor/dialogs/transparentbackgroundsettingsdialog.cpp \
|
||||
@ -154,8 +158,10 @@ SOURCES += \
|
||||
src/projectserialization.cpp
|
||||
|
||||
FORMS += \
|
||||
src/editor/dialogs/actions/speedhorizontaldialog.ui \
|
||||
src/editor/dialogs/actions/movefreedialog.ui \
|
||||
src/editor/dialogs/actions/movetowardsdialog.ui \
|
||||
src/editor/dialogs/actions/speedverticaldialog.ui \
|
||||
src/editor/dialogs/includedfilepropertiesdialog.ui \
|
||||
src/editor/dialogs/transparentbackgroundsettingsdialog.ui \
|
||||
src/editor/mainwindow.ui \
|
||||
|
@ -253,6 +253,9 @@
|
||||
<property name="text">
|
||||
<string>Speed:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
|
@ -143,6 +143,9 @@
|
||||
<property name="text">
|
||||
<string>direction:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxDirection</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
@ -153,6 +156,9 @@
|
||||
<property name="text">
|
||||
<string>speed:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxSpeed</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
|
@ -1,12 +1,19 @@
|
||||
#include "movetowardsdialog.h"
|
||||
#include "ui_movetowardsdialog.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
MoveTowardsDialog::MoveTowardsDialog(MoveTowardsAction &action, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::MoveTowardsDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
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"});
|
||||
}
|
||||
|
||||
MoveTowardsDialog::~MoveTowardsDialog() = default;
|
||||
|
@ -6,31 +6,204 @@
|
||||
<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>Move Towards</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-move-towards.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">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonObject">
|
||||
<property name="text">
|
||||
<string>Object:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</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="labelX">
|
||||
<property name="text">
|
||||
<string>x:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxX</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxX"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelY">
|
||||
<property name="text">
|
||||
<string>y:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxY</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxY"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxRelative">
|
||||
<property name="text">
|
||||
<string>Relative</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxSpeed"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelSpeed">
|
||||
<property name="text">
|
||||
<string>speed:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxSpeed</cstring>
|
||||
</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/>
|
||||
<resources>
|
||||
<include location="../../resources_editor.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
@ -39,8 +212,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 +228,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>
|
||||
|
19
src/editor/dialogs/actions/speedhorizontaldialog.cpp
Normal file
19
src/editor/dialogs/actions/speedhorizontaldialog.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "speedhorizontaldialog.h"
|
||||
#include "ui_speedhorizontaldialog.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
SpeedHorizontalDialog::SpeedHorizontalDialog(SpeedHorizontalAction &action, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::SpeedHorizontalDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
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"});
|
||||
}
|
||||
|
||||
SpeedHorizontalDialog::~SpeedHorizontalDialog() = default;
|
22
src/editor/dialogs/actions/speedhorizontaldialog.h
Normal file
22
src/editor/dialogs/actions/speedhorizontaldialog.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class SpeedHorizontalDialog; }
|
||||
struct SpeedHorizontalAction;
|
||||
|
||||
class SpeedHorizontalDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SpeedHorizontalDialog(SpeedHorizontalAction &action, QWidget *parent = nullptr);
|
||||
~SpeedHorizontalDialog() override;
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::SpeedHorizontalDialog> m_ui;
|
||||
|
||||
SpeedHorizontalAction &m_action;
|
||||
};
|
68
src/editor/dialogs/actions/speedhorizontaldialog.ui
Normal file
68
src/editor/dialogs/actions/speedhorizontaldialog.ui
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SpeedHorizontalDialog</class>
|
||||
<widget class="QDialog" name="SpeedHorizontalDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>SpeedHorizontalDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>SpeedHorizontalDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
19
src/editor/dialogs/actions/speedverticaldialog.cpp
Normal file
19
src/editor/dialogs/actions/speedverticaldialog.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "speedverticaldialog.h"
|
||||
#include "ui_speedverticaldialog.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
SpeedVerticalDialog::SpeedVerticalDialog(SpeedVerticalAction &action, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::SpeedVerticalDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
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"});
|
||||
}
|
||||
|
||||
SpeedVerticalDialog::~SpeedVerticalDialog() = default;
|
22
src/editor/dialogs/actions/speedverticaldialog.h
Normal file
22
src/editor/dialogs/actions/speedverticaldialog.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class SpeedVerticalDialog; }
|
||||
struct SpeedVerticalAction;
|
||||
|
||||
class SpeedVerticalDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SpeedVerticalDialog(SpeedVerticalAction &action, QWidget *parent = nullptr);
|
||||
~SpeedVerticalDialog() override;
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::SpeedVerticalDialog> m_ui;
|
||||
|
||||
SpeedVerticalAction &m_action;
|
||||
};
|
68
src/editor/dialogs/actions/speedverticaldialog.ui
Normal file
68
src/editor/dialogs/actions/speedverticaldialog.ui
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SpeedVerticalDialog</class>
|
||||
<widget class="QDialog" name="SpeedVerticalDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>SpeedVerticalDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>SpeedVerticalDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
BIN
src/editor/icons/action-speed-horizontal.png
Normal file
BIN
src/editor/icons/action-speed-horizontal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
src/editor/icons/action-speed-vertical.png
Normal file
BIN
src/editor/icons/action-speed-vertical.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -50,6 +50,10 @@ QVariant ActionsContainerModel::data(const QModelIndex &index, int role) const
|
||||
return tr("Set direction and speed of motion");
|
||||
else if (std::holds_alternative<MoveTowardsAction>(action))
|
||||
return tr("Move towards point (99, 99)");
|
||||
else if (std::holds_alternative<SpeedHorizontalAction>(action))
|
||||
return tr("Set the horizontal speed");
|
||||
else if (std::holds_alternative<SpeedVerticalAction>(action))
|
||||
return tr("Set the vertical speed");
|
||||
else if (std::holds_alternative<ExecuteCodeAction>(action))
|
||||
return tr("Execute a piece of code");
|
||||
else
|
||||
@ -64,8 +68,12 @@ QVariant ActionsContainerModel::data(const QModelIndex &index, int role) const
|
||||
return QIcon{":/qtgameengine/icons/action-move-free.png"};
|
||||
else if (std::holds_alternative<MoveTowardsAction>(action))
|
||||
return QIcon{":/qtgameengine/icons/action-move-towards.png"};
|
||||
else if (std::holds_alternative<SpeedHorizontalAction>(action))
|
||||
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<ExecuteCodeAction>(action))
|
||||
return QIcon{":/qtgameengine/icons/action-code.png"};
|
||||
return QIcon{":/qtgameengine/icons/action-execute-code.png"};
|
||||
else
|
||||
{
|
||||
qWarning() << "unknown action type";
|
||||
@ -132,11 +140,6 @@ QMimeData *ActionsContainerModel::mimeData(const QModelIndexList &indexes) const
|
||||
|
||||
bool ActionsContainerModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!m_actionsContainer)
|
||||
{
|
||||
qWarning() << "no container";
|
||||
return false;
|
||||
}
|
||||
// if the drop is on an item, reject drop
|
||||
if (parent.isValid() && row == -1 && column == -1)
|
||||
{
|
||||
@ -149,11 +152,6 @@ bool ActionsContainerModel::canDropMimeData(const QMimeData *data, Qt::DropActio
|
||||
|
||||
bool ActionsContainerModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
if (!m_actionsContainer)
|
||||
{
|
||||
qWarning() << "no container";
|
||||
return false;
|
||||
}
|
||||
// check if the action is supported
|
||||
if (!data || !(action == Qt::CopyAction || action == Qt::MoveAction))
|
||||
{
|
||||
@ -200,6 +198,12 @@ bool ActionsContainerModel::dropMimeData(const QMimeData *data, Qt::DropAction a
|
||||
qWarning() << "empty actions";
|
||||
return false;
|
||||
}
|
||||
if (!m_actionsContainer)
|
||||
{
|
||||
qWarning() << "no container";
|
||||
emit actionsContainerMissing();
|
||||
return false;
|
||||
}
|
||||
|
||||
beginInsertRows({}, row, row + actions.size() - 1);
|
||||
auto iter = std::next(std::begin(*m_actionsContainer), row);
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
void actionsContainerMissing();
|
||||
|
||||
private:
|
||||
ActionsContainer *m_actionsContainer{};
|
||||
|
@ -1,10 +1,12 @@
|
||||
<RCC>
|
||||
<qresource prefix="/qtgameengine">
|
||||
<file>icons/action.png</file>
|
||||
<file>icons/action-code.png</file>
|
||||
<file>icons/action-execute-code.png</file>
|
||||
<file>icons/action-move-fixed.png</file>
|
||||
<file>icons/action-move-free.png</file>
|
||||
<file>icons/action-move-towards.png</file>
|
||||
<file>icons/action-speed-horizontal.png</file>
|
||||
<file>icons/action-speed-vertical.png</file>
|
||||
<file>icons/add.png</file>
|
||||
<file>icons/arrow-down.png</file>
|
||||
<file>icons/arrow-left.png</file>
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "dialogs/actions/movefixeddialog.h"
|
||||
#include "dialogs/actions/movefreedialog.h"
|
||||
#include "dialogs/actions/movetowardsdialog.h"
|
||||
#include "dialogs/actions/speedhorizontaldialog.h"
|
||||
#include "dialogs/actions/speedverticaldialog.h"
|
||||
#include "dialogs/actions/executecodedialog.h"
|
||||
|
||||
namespace {
|
||||
@ -17,6 +19,8 @@ template<typename T> struct ActionDialogForImpl;
|
||||
template<> struct ActionDialogForImpl<MoveFixedAction> { using Dialog = MoveFixedDialog; };
|
||||
template<> struct ActionDialogForImpl<MoveFreeAction> { using Dialog = MoveFreeDialog; };
|
||||
template<> struct ActionDialogForImpl<MoveTowardsAction> { using Dialog = MoveTowardsDialog; };
|
||||
template<> struct ActionDialogForImpl<SpeedHorizontalAction> { using Dialog = SpeedHorizontalDialog; };
|
||||
template<> struct ActionDialogForImpl<SpeedVerticalAction> { using Dialog = SpeedVerticalDialog; };
|
||||
template<> struct ActionDialogForImpl<ExecuteCodeAction> { using Dialog = ExecuteCodeDialog; };
|
||||
template<typename T> using ActionDialogFor = ActionDialogForImpl<T>::Dialog;
|
||||
}
|
||||
@ -33,6 +37,9 @@ ActionsContainerWidget::ActionsContainerWidget(QWidget *parent) :
|
||||
connect(m_actionsModel.get(), &ActionsContainerModel::changed,
|
||||
this, &ActionsContainerWidget::changed);
|
||||
|
||||
connect(m_actionsModel.get(), &ActionsContainerModel::actionsContainerMissing,
|
||||
this, &ActionsContainerWidget::actionsContainerMissing);
|
||||
|
||||
connect(m_ui->listViewActions, &QListView::customContextMenuRequested,
|
||||
this, &ActionsContainerWidget::actionsContextMenuRequested);
|
||||
|
||||
@ -50,12 +57,18 @@ ActionsContainerWidget::ActionsContainerWidget(QWidget *parent) :
|
||||
this, &ActionsContainerWidget::createNewAction<MoveFreeAction>);
|
||||
connect(m_ui->toolButtonMoveTowards, &QAbstractButton::clicked,
|
||||
this, &ActionsContainerWidget::createNewAction<MoveTowardsAction>);
|
||||
connect(m_ui->toolButtonSpeedHorizontal, &QAbstractButton::clicked,
|
||||
this, &ActionsContainerWidget::createNewAction<SpeedHorizontalAction>);
|
||||
connect(m_ui->toolButtonSpeedVertical, &QAbstractButton::clicked,
|
||||
this, &ActionsContainerWidget::createNewAction<SpeedVerticalAction>);
|
||||
connect(m_ui->toolButtonExecuteCode, &QAbstractButton::clicked,
|
||||
this, &ActionsContainerWidget::createNewAction<ExecuteCodeAction>);
|
||||
|
||||
m_ui->toolButtonMoveFixed->setAction(MoveFixedAction{});
|
||||
m_ui->toolButtonMoveFree->setAction(MoveFreeAction{});
|
||||
m_ui->toolButtonMoveTowards->setAction(MoveTowardsAction{});
|
||||
m_ui->toolButtonSpeedHorizontal->setAction(SpeedHorizontalAction{});
|
||||
m_ui->toolButtonSpeedVertical->setAction(SpeedVerticalAction{});
|
||||
m_ui->toolButtonExecuteCode->setAction(ExecuteCodeAction{});
|
||||
}
|
||||
|
||||
@ -98,6 +111,18 @@ void ActionsContainerWidget::actionDoubleClicked(const QModelIndex &index)
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<SpeedHorizontalAction>(action))
|
||||
{
|
||||
SpeedHorizontalDialog dialog{*ptr, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<SpeedVerticalAction>(action))
|
||||
{
|
||||
SpeedVerticalDialog dialog{*ptr, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<ExecuteCodeAction>(action))
|
||||
{
|
||||
ExecuteCodeDialog dialog{*ptr, this};
|
||||
@ -167,6 +192,12 @@ void ActionsContainerWidget::actionsContextMenuRequested(const QPoint &pos)
|
||||
menu.exec(m_ui->listViewActions->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void ActionsContainerWidget::actionsContainerMissing()
|
||||
{
|
||||
QMessageBox::warning(this, tr("You need to select or add an event before you can add actions"),
|
||||
tr("You need to select or add an event before you can add actions"));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void ActionsContainerWidget::createNewAction()
|
||||
{
|
||||
|
@ -26,6 +26,7 @@ signals:
|
||||
private slots:
|
||||
void actionDoubleClicked(const QModelIndex &index);
|
||||
void actionsContextMenuRequested(const QPoint &pos);
|
||||
void actionsContainerMissing();
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
|
@ -240,13 +240,13 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QToolButton" name="toolButtonSpeedVertical">
|
||||
<widget class="ActionDragWidget" name="toolButtonSpeedVertical">
|
||||
<property name="toolTip">
|
||||
<string>Speed Vertical</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-speed-vertical.png</normaloff>:/qtgameengine/icons/action-speed-vertical.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
@ -336,13 +336,13 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QToolButton" name="toolButtonSpeedHorizontal">
|
||||
<widget class="ActionDragWidget" name="toolButtonSpeedHorizontal">
|
||||
<property name="toolTip">
|
||||
<string>Speed Horizontal</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-speed-horizontal.png</normaloff>:/qtgameengine/icons/action-speed-horizontal.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
@ -1450,7 +1450,7 @@
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/action-code.png</normaloff>:/qtgameengine/icons/action-code.png</iconset>
|
||||
<normaloff>:/qtgameengine/icons/action-execute-code.png</normaloff>:/qtgameengine/icons/action-execute-code.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -169,6 +169,14 @@ struct MoveTowardsAction {
|
||||
|
||||
};
|
||||
|
||||
struct SpeedHorizontalAction {
|
||||
|
||||
};
|
||||
|
||||
struct SpeedVerticalAction {
|
||||
|
||||
};
|
||||
|
||||
struct ExecuteCodeAction {
|
||||
enum class AppliesTo {
|
||||
Self,
|
||||
@ -184,6 +192,8 @@ using Action = std::variant<
|
||||
MoveFixedAction,
|
||||
MoveFreeAction,
|
||||
MoveTowardsAction,
|
||||
SpeedHorizontalAction,
|
||||
SpeedVerticalAction,
|
||||
ExecuteCodeAction
|
||||
>;
|
||||
|
||||
|
@ -304,6 +304,34 @@ QDataStream &operator>>(QDataStream &ds, MoveTowardsAction &action)
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const SpeedHorizontalAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds << action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, SpeedHorizontalAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds >> action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const SpeedVerticalAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds << action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, SpeedVerticalAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds >> action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const ExecuteCodeAction &action)
|
||||
{
|
||||
ds << action.script;
|
||||
|
@ -34,6 +34,10 @@ QDataStream &operator<<(QDataStream &ds, const MoveFreeAction &action);
|
||||
QDataStream &operator>>(QDataStream &ds, MoveFreeAction &action);
|
||||
QDataStream &operator<<(QDataStream &ds, const MoveTowardsAction &action);
|
||||
QDataStream &operator>>(QDataStream &ds, MoveTowardsAction &action);
|
||||
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 ExecuteCodeAction &action);
|
||||
QDataStream &operator>>(QDataStream &ds, ExecuteCodeAction &action);
|
||||
QDataStream &operator<<(QDataStream &ds, const TimeLine &timeLine);
|
||||
|
Reference in New Issue
Block a user