Move Action change dialogs
This commit is contained in:
@@ -26,6 +26,9 @@ INCLUDEPATH += \
|
||||
|
||||
HEADERS += \
|
||||
src/closeeventfilter.h \
|
||||
src/editor/dialogs/actions/movefreedialog.h \
|
||||
src/editor/dialogs/actions/movetowardsdialog.h \
|
||||
src/editor/dialogs/actions/executecodedialog.h \
|
||||
src/editor/dialogs/genericcodeeditordialog.h \
|
||||
src/editor/dialogs/includedfilepropertiesdialog.h \
|
||||
src/editor/dialogs/transparentbackgroundsettingsdialog.h \
|
||||
@@ -46,7 +49,6 @@ HEADERS += \
|
||||
src/editor/mainwindow.h \
|
||||
src/editor/dialogs/addeventdialog.h \
|
||||
src/editor/dialogs/backgroundpropertiesdialog.h \
|
||||
src/editor/dialogs/codeactiondialog.h \
|
||||
src/editor/dialogs/codeeditordialog.h \
|
||||
src/editor/dialogs/createspritedialog.h \
|
||||
src/editor/dialogs/deletemomentsdialog.h \
|
||||
@@ -89,6 +91,9 @@ HEADERS += \
|
||||
|
||||
SOURCES += \
|
||||
src/closeeventfilter.cpp \
|
||||
src/editor/dialogs/actions/executecodedialog.cpp \
|
||||
src/editor/dialogs/actions/movefreedialog.cpp \
|
||||
src/editor/dialogs/actions/movetowardsdialog.cpp \
|
||||
src/editor/dialogs/genericcodeeditordialog.cpp \
|
||||
src/editor/dialogs/includedfilepropertiesdialog.cpp \
|
||||
src/editor/dialogs/transparentbackgroundsettingsdialog.cpp \
|
||||
@@ -109,7 +114,6 @@ SOURCES += \
|
||||
src/editor/mainwindow.cpp \
|
||||
src/editor/dialogs/addeventdialog.cpp \
|
||||
src/editor/dialogs/backgroundpropertiesdialog.cpp \
|
||||
src/editor/dialogs/codeactiondialog.cpp \
|
||||
src/editor/dialogs/codeeditordialog.cpp \
|
||||
src/editor/dialogs/createspritedialog.cpp \
|
||||
src/editor/dialogs/deletemomentsdialog.cpp \
|
||||
@@ -150,6 +154,8 @@ SOURCES += \
|
||||
src/projectserialization.cpp
|
||||
|
||||
FORMS += \
|
||||
src/editor/dialogs/actions/movefreedialog.ui \
|
||||
src/editor/dialogs/actions/movetowardsdialog.ui \
|
||||
src/editor/dialogs/includedfilepropertiesdialog.ui \
|
||||
src/editor/dialogs/transparentbackgroundsettingsdialog.ui \
|
||||
src/editor/mainwindow.ui \
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "codeactiondialog.h"
|
||||
#include "executecodedialog.h"
|
||||
|
||||
#include <QRadioButton>
|
||||
#include <QLabel>
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "projectcontainer.h"
|
||||
|
||||
CodeActionDialog::CodeActionDialog(ExecuteCodeAction &action, QWidget *parent) :
|
||||
ExecuteCodeDialog::ExecuteCodeDialog(ExecuteCodeAction &action, QWidget *parent) :
|
||||
CodeEditorDialog{tr("Execute Code"), parent},
|
||||
m_action{action},
|
||||
m_radioButtonSelf{new QRadioButton{tr("Self"), this}},
|
||||
@@ -30,14 +30,14 @@ CodeActionDialog::CodeActionDialog(ExecuteCodeAction &action, QWidget *parent) :
|
||||
setScript(m_action.script);
|
||||
|
||||
connect(m_radioButtonSelf, &QRadioButton::toggled,
|
||||
this, &CodeActionDialog::changed);
|
||||
this, &ExecuteCodeDialog::changed);
|
||||
connect(m_radioButtonOther, &QRadioButton::toggled,
|
||||
this, &CodeActionDialog::changed);
|
||||
this, &ExecuteCodeDialog::changed);
|
||||
connect(m_radioButtonObject, &QRadioButton::toggled,
|
||||
this, &CodeActionDialog::changed);
|
||||
this, &ExecuteCodeDialog::changed);
|
||||
}
|
||||
|
||||
void CodeActionDialog::accept()
|
||||
void ExecuteCodeDialog::accept()
|
||||
{
|
||||
if (!m_unsavedChanges)
|
||||
{
|
@@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "codeeditordialog.h"
|
||||
#include "dialogs/codeeditordialog.h"
|
||||
|
||||
class QRadioButton;
|
||||
struct ExecuteCodeAction;
|
||||
|
||||
class CodeActionDialog : public CodeEditorDialog
|
||||
class ExecuteCodeDialog : public CodeEditorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CodeActionDialog(ExecuteCodeAction &action, QWidget *parent = nullptr);
|
||||
explicit ExecuteCodeDialog(ExecuteCodeAction &action, QWidget *parent = nullptr);
|
||||
|
||||
void accept() override;
|
||||
|
@@ -149,6 +149,10 @@
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/blue-arrow-up-left.png</normaloff>:/qtgameengine/icons/blue-arrow-up-left.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -156,6 +160,10 @@
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/blue-stop.png</normaloff>:/qtgameengine/icons/blue-stop.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -185,6 +193,10 @@
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/blue-arrow-up-right.png</normaloff>:/qtgameengine/icons/blue-arrow-up-right.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -203,6 +215,10 @@
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/blue-arrow-down-left.png</normaloff>:/qtgameengine/icons/blue-arrow-down-left.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -221,6 +237,10 @@
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/blue-arrow-down-right.png</normaloff>:/qtgameengine/icons/blue-arrow-down-right.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
19
src/editor/dialogs/actions/movefreedialog.cpp
Normal file
19
src/editor/dialogs/actions/movefreedialog.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "movefreedialog.h"
|
||||
#include "ui_movefreedialog.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
MoveFreeDialog::MoveFreeDialog(MoveFreeAction &action, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::MoveFreeDialog>()},
|
||||
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"});
|
||||
}
|
||||
|
||||
MoveFreeDialog::~MoveFreeDialog() = default;
|
22
src/editor/dialogs/actions/movefreedialog.h
Normal file
22
src/editor/dialogs/actions/movefreedialog.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class MoveFreeDialog; }
|
||||
class MoveFreeAction;
|
||||
|
||||
class MoveFreeDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MoveFreeDialog(MoveFreeAction &action, QWidget *parent = nullptr);
|
||||
~MoveFreeDialog() override;
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::MoveFreeDialog> m_ui;
|
||||
|
||||
MoveFreeAction &m_action;
|
||||
};
|
222
src/editor/dialogs/actions/movefreedialog.ui
Normal file
222
src/editor/dialogs/actions/movefreedialog.ui
Normal file
@@ -0,0 +1,222 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MoveFreeDialog</class>
|
||||
<widget class="QDialog" name="MoveFreeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>435</width>
|
||||
<height>429</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Move Free</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-move-free.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="labelDirection">
|
||||
<property name="text">
|
||||
<string>direction:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxDirection"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelSpeed">
|
||||
<property name="text">
|
||||
<string>speed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxSpeed"/>
|
||||
</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>
|
||||
<resources>
|
||||
<include location="../../resources_editor.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>MoveFreeDialog</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>MoveFreeDialog</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>
|
12
src/editor/dialogs/actions/movetowardsdialog.cpp
Normal file
12
src/editor/dialogs/actions/movetowardsdialog.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "movetowardsdialog.h"
|
||||
#include "ui_movetowardsdialog.h"
|
||||
|
||||
MoveTowardsDialog::MoveTowardsDialog(MoveTowardsAction &action, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::MoveTowardsDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
MoveTowardsDialog::~MoveTowardsDialog() = default;
|
22
src/editor/dialogs/actions/movetowardsdialog.h
Normal file
22
src/editor/dialogs/actions/movetowardsdialog.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class MoveTowardsDialog; }
|
||||
class MoveTowardsAction;
|
||||
|
||||
class MoveTowardsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MoveTowardsDialog(MoveTowardsAction &action, QWidget *parent = nullptr);
|
||||
~MoveTowardsDialog() override;
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::MoveTowardsDialog> m_ui;
|
||||
|
||||
MoveTowardsAction &m_action;
|
||||
};
|
68
src/editor/dialogs/actions/movetowardsdialog.ui
Normal file
68
src/editor/dialogs/actions/movetowardsdialog.ui
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MoveTowardsDialog</class>
|
||||
<widget class="QDialog" name="MoveTowardsDialog">
|
||||
<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>MoveTowardsDialog</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>MoveTowardsDialog</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>
|
BIN
src/editor/icons/blue-arrow-down-left.png
Normal file
BIN
src/editor/icons/blue-arrow-down-left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
BIN
src/editor/icons/blue-arrow-down-right.png
Normal file
BIN
src/editor/icons/blue-arrow-down-right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
BIN
src/editor/icons/blue-arrow-up-left.png
Normal file
BIN
src/editor/icons/blue-arrow-up-left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
BIN
src/editor/icons/blue-arrow-up-right.png
Normal file
BIN
src/editor/icons/blue-arrow-up-right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
BIN
src/editor/icons/blue-stop.png
Normal file
BIN
src/editor/icons/blue-stop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
@@ -207,23 +207,12 @@ bool ActionsContainerModel::dropMimeData(const QMimeData *data, Qt::DropAction a
|
||||
iter = m_actionsContainer->insert(iter, std::move(action));
|
||||
endInsertRows();
|
||||
|
||||
if (!actions.isEmpty())
|
||||
emit changed();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QMap<int, QVariant> ActionsContainerModel::itemData(const QModelIndex &index) const
|
||||
{
|
||||
auto itemData = QAbstractListModel::itemData(index);
|
||||
qDebug() << index << itemData;
|
||||
return itemData;
|
||||
}
|
||||
|
||||
bool ActionsContainerModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
|
||||
{
|
||||
auto setItemData = QAbstractListModel::setItemData(index, roles);
|
||||
qDebug() << index << roles << setItemData;
|
||||
return setItemData;
|
||||
}
|
||||
|
||||
bool ActionsContainerModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
qDebug() << row << count << parent.isValid();
|
||||
@@ -251,6 +240,9 @@ bool ActionsContainerModel::removeRows(int row, int count, const QModelIndex &pa
|
||||
m_actionsContainer->erase(begin, end);
|
||||
endRemoveRows();
|
||||
|
||||
if (count)
|
||||
emit changed();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -272,6 +264,7 @@ bool ActionsContainerModel::moveRows(const QModelIndex &sourceParent, int source
|
||||
m_actionsContainer->splice(std::next(std::begin(*m_actionsContainer), destinationChild), *m_actionsContainer, std::next(std::begin(*m_actionsContainer), sourceRow));
|
||||
endMoveRows();
|
||||
|
||||
emit changed();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -338,3 +331,31 @@ const Action *ActionsContainerModel::getAction(int row) const
|
||||
|
||||
return &*std::next(std::cbegin(*m_actionsContainer), row);
|
||||
}
|
||||
|
||||
void ActionsContainerModel::appendAction(Action &&action)
|
||||
{
|
||||
if (!m_actionsContainer)
|
||||
{
|
||||
qWarning() << "invalid actions container";
|
||||
return;
|
||||
}
|
||||
|
||||
beginInsertRows({}, m_actionsContainer->size(), m_actionsContainer->size());
|
||||
m_actionsContainer->push_back(std::move(action));
|
||||
endInsertRows();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void ActionsContainerModel::appendAction(const Action &action)
|
||||
{
|
||||
if (!m_actionsContainer)
|
||||
{
|
||||
qWarning() << "invalid actions container";
|
||||
return;
|
||||
}
|
||||
|
||||
beginInsertRows({}, m_actionsContainer->size(), m_actionsContainer->size());
|
||||
m_actionsContainer->push_back(action);
|
||||
endInsertRows();
|
||||
emit changed();
|
||||
}
|
||||
|
@@ -25,9 +25,6 @@ public:
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
|
||||
QMap<int, QVariant> itemData(const QModelIndex &index) const override;
|
||||
bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) override;
|
||||
|
||||
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;
|
||||
|
||||
@@ -39,6 +36,12 @@ public:
|
||||
Action *getAction(int row);
|
||||
const Action *getAction(int row) const;
|
||||
|
||||
void appendAction(Action &&action);
|
||||
void appendAction(const Action &action);
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
private:
|
||||
ActionsContainer *m_actionsContainer{};
|
||||
};
|
||||
|
@@ -95,8 +95,13 @@
|
||||
<file>icons/undo.png</file>
|
||||
<file>icons/unlock.png</file>
|
||||
<file>icons/blue-arrow-down.png</file>
|
||||
<file>icons/blue-arrow-down-left.png</file>
|
||||
<file>icons/blue-arrow-down-right.png</file>
|
||||
<file>icons/blue-arrow-left.png</file>
|
||||
<file>icons/blue-arrow-right.png</file>
|
||||
<file>icons/blue-arrow-up.png</file>
|
||||
<file>icons/blue-arrow-up-left.png</file>
|
||||
<file>icons/blue-arrow-up-right.png</file>
|
||||
<file>icons/blue-stop.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@@ -7,8 +7,19 @@
|
||||
#include <QKeySequence>
|
||||
|
||||
#include "models/actionscontainermodel.h"
|
||||
#include "dialogs/codeactiondialog.h"
|
||||
#include "dialogs/actions/movefixeddialog.h"
|
||||
#include "dialogs/actions/movefreedialog.h"
|
||||
#include "dialogs/actions/movetowardsdialog.h"
|
||||
#include "dialogs/actions/executecodedialog.h"
|
||||
|
||||
namespace {
|
||||
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<ExecuteCodeAction> { using Dialog = ExecuteCodeDialog; };
|
||||
template<typename T> using ActionDialogFor = ActionDialogForImpl<T>::Dialog;
|
||||
}
|
||||
|
||||
ActionsContainerWidget::ActionsContainerWidget(QWidget *parent) :
|
||||
QWidget{parent},
|
||||
@@ -19,6 +30,9 @@ ActionsContainerWidget::ActionsContainerWidget(QWidget *parent) :
|
||||
|
||||
m_ui->listViewActions->setModel(m_actionsModel.get());
|
||||
|
||||
connect(m_actionsModel.get(), &ActionsContainerModel::changed,
|
||||
this, &ActionsContainerWidget::changed);
|
||||
|
||||
connect(m_ui->listViewActions, &QListView::customContextMenuRequested,
|
||||
this, &ActionsContainerWidget::actionsContextMenuRequested);
|
||||
|
||||
@@ -31,15 +45,13 @@ ActionsContainerWidget::ActionsContainerWidget(QWidget *parent) :
|
||||
});
|
||||
|
||||
connect(m_ui->toolButtonMoveFixed, &QAbstractButton::clicked,
|
||||
this, [this](){
|
||||
MoveFixedAction action;
|
||||
MoveFixedDialog dialog{action, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
// TODO insert into model
|
||||
emit changed();
|
||||
}
|
||||
});
|
||||
this, &ActionsContainerWidget::createNewAction<MoveFixedAction>);
|
||||
connect(m_ui->toolButtonMoveFree, &QAbstractButton::clicked,
|
||||
this, &ActionsContainerWidget::createNewAction<MoveFreeAction>);
|
||||
connect(m_ui->toolButtonMoveTowards, &QAbstractButton::clicked,
|
||||
this, &ActionsContainerWidget::createNewAction<MoveTowardsAction>);
|
||||
connect(m_ui->toolButtonExecuteCode, &QAbstractButton::clicked,
|
||||
this, &ActionsContainerWidget::createNewAction<ExecuteCodeAction>);
|
||||
|
||||
m_ui->toolButtonMoveFixed->setAction(MoveFixedAction{});
|
||||
m_ui->toolButtonMoveFree->setAction(MoveFreeAction{});
|
||||
@@ -74,9 +86,21 @@ void ActionsContainerWidget::actionDoubleClicked(const QModelIndex &index)
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<MoveFreeAction>(action))
|
||||
{
|
||||
MoveFreeDialog dialog{*ptr, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<MoveTowardsAction>(action))
|
||||
{
|
||||
MoveTowardsDialog dialog{*ptr, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<ExecuteCodeAction>(action))
|
||||
{
|
||||
CodeActionDialog dialog{*ptr, this};
|
||||
ExecuteCodeDialog dialog{*ptr, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
@@ -142,3 +166,15 @@ void ActionsContainerWidget::actionsContextMenuRequested(const QPoint &pos)
|
||||
}
|
||||
menu.exec(m_ui->listViewActions->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void ActionsContainerWidget::createNewAction()
|
||||
{
|
||||
if (!m_actionsModel->actionsContainer())
|
||||
return;
|
||||
|
||||
T action;
|
||||
ActionDialogFor<T> dialog{action, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
m_actionsModel->appendAction(std::move(action));
|
||||
}
|
||||
|
@@ -28,6 +28,9 @@ private slots:
|
||||
void actionsContextMenuRequested(const QPoint &pos);
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
void createNewAction();
|
||||
|
||||
const std::unique_ptr<Ui::ActionsContainerWidget> m_ui;
|
||||
|
||||
const std::unique_ptr<ActionsContainerModel> m_actionsModel;
|
||||
|
Reference in New Issue
Block a user