Lots of fixes and added more dialogs

This commit is contained in:
2022-01-11 02:35:26 +01:00
parent b8c62a923e
commit 7fdcd5386d
76 changed files with 2196 additions and 196 deletions

View File

@@ -1,7 +1,10 @@
QT = core gui widgets multimedia
CONFIG += c++latest
QMAKE_CXXFLAGS += -std=c++23
QMAKE_CXXFLAGS += \
-std=c++23 \
-Wno-missing-field-initializers \
-Wno-sign-compare
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
@@ -13,6 +16,7 @@ HEADERS += \
dialogs/fontpropertiesdialog.h \
dialogs/imageeditordialog.h \
dialogs/includedfilesdialog.h \
dialogs/installextensiondialog.h \
dialogs/maskpropertiesdialog.h \
dialogs/objectinformationdialog.h \
dialogs/objectpropertiesdialog.h \
@@ -28,6 +32,8 @@ HEADERS += \
includedfilesmodel.h \
jshighlighter.h \
mainwindow.h \
objectactionsmodel.h \
objecteventsmodel.h \
pathpointsmodel.h \
pathpointswidget.h \
projectcontainer.h \
@@ -41,6 +47,8 @@ HEADERS += \
dialogs/soundpropertiesdialog.h \
dialogs/spritepropertiesdialog.h \
spritesmodel.h \
timelineactionsmodel.h \
timelinemomentsmodel.h \
triggersmodel.h
SOURCES += main.cpp \
@@ -51,6 +59,7 @@ SOURCES += main.cpp \
dialogs/fontpropertiesdialog.cpp \
dialogs/imageeditordialog.cpp \
dialogs/includedfilesdialog.cpp \
dialogs/installextensiondialog.cpp \
dialogs/maskpropertiesdialog.cpp \
dialogs/objectinformationdialog.cpp \
dialogs/objectpropertiesdialog.cpp \
@@ -65,6 +74,8 @@ SOURCES += main.cpp \
includedfilesmodel.cpp \
jshighlighter.cpp \
mainwindow.cpp \
objectactionsmodel.cpp \
objecteventsmodel.cpp \
pathpointsmodel.cpp \
pathpointswidget.cpp \
projectcontainer.cpp \
@@ -78,6 +89,8 @@ SOURCES += main.cpp \
dialogs/soundpropertiesdialog.cpp \
dialogs/spritepropertiesdialog.cpp \
spritesmodel.cpp \
timelineactionsmodel.cpp \
timelinemomentsmodel.cpp \
triggersmodel.cpp
FORMS += \
@@ -86,6 +99,7 @@ FORMS += \
dialogs/fontpropertiesdialog.ui \
dialogs/imageeditordialog.ui \
dialogs/includedfilesdialog.ui \
dialogs/installextensiondialog.ui \
dialogs/maskpropertiesdialog.ui \
dialogs/objectinformationdialog.ui \
dialogs/objectpropertiesdialog.ui \

View File

@@ -21,6 +21,7 @@ CodeEditorWidget::CodeEditorWidget(QWidget *parent) :
void CodeEditorWidget::updateLineNumberAreaWidth(int newBlockCount)
{
Q_UNUSED(newBlockCount)
setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
}

View File

@@ -18,16 +18,20 @@ ConstantsModel::ConstantsModel(ProjectContainer &project, QObject *parent) :
int ConstantsModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return 0;
}
int ConstantsModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return NumberOfColumns;
}
QVariant ConstantsModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(index)
Q_UNUSED(role)
return {};
}

View File

@@ -32,11 +32,11 @@ BackgroundPropertiesDialog::BackgroundPropertiesDialog(Background &background, P
connect(&m_projectModel, &ProjectTreeModel::backgroundNameChanged,
this, &BackgroundPropertiesDialog::backgroundNameChanged);
connect(m_ui->pushButtonLoad, &QAbstractButton::pressed,
connect(m_ui->pushButtonLoad, &QAbstractButton::clicked,
this, &BackgroundPropertiesDialog::loadBackground);
connect(m_ui->pushButtonSave, &QAbstractButton::pressed,
connect(m_ui->pushButtonSave, &QAbstractButton::clicked,
this, &BackgroundPropertiesDialog::saveBackground);
connect(m_ui->pushButtonEdit, &QAbstractButton::pressed,
connect(m_ui->pushButtonEdit, &QAbstractButton::clicked,
this, &BackgroundPropertiesDialog::editBackground);
connect(m_ui->lineEditName, &QLineEdit::textChanged,

View File

@@ -4,7 +4,6 @@
#include <QString>
#include <memory>
#include <optional>
namespace Ui { class BackgroundPropertiesDialog; }
struct Background;

View File

@@ -5,16 +5,21 @@
#include <QFont>
#include <QLabel>
#include <QTextBlock>
#include <QMessageBox>
#include <QSignalBlocker>
#include "jshighlighter.h"
CodeEditorDialog::CodeEditorDialog(QWidget *parent) :
CodeEditorDialog::CodeEditorDialog(const QString &title, QWidget *parent) :
QDialog{parent},
m_ui{std::make_unique<Ui::CodeEditorDialog>()},
m_title{title},
m_labelPosition{new QLabel{this}}
{
m_ui->setupUi(this);
updateTitle();
m_labelPosition->setFrameStyle(QFrame::Sunken);
m_ui->statusbar->addWidget(m_labelPosition);
@@ -37,6 +42,8 @@ CodeEditorDialog::CodeEditorDialog(QWidget *parent) :
connect(m_ui->actionPrint, &QAction::triggered,
this, &CodeEditorDialog::print);
connect(m_ui->codeEdit, &QPlainTextEdit::textChanged,
this, &CodeEditorDialog::changed);
connect(m_ui->codeEdit, &QPlainTextEdit::textChanged,
this, &CodeEditorDialog::updatePosition);
connect(m_ui->codeEdit, &QPlainTextEdit::cursorPositionChanged,
@@ -45,6 +52,72 @@ CodeEditorDialog::CodeEditorDialog(QWidget *parent) :
CodeEditorDialog::~CodeEditorDialog() = default;
void CodeEditorDialog::accept()
{
if (!m_unsavedChanges)
{
QDialog::reject();
return;
}
QDialog::accept();
}
void CodeEditorDialog::reject()
{
if (!m_unsavedChanges)
{
QDialog::reject();
return;
}
const auto result = QMessageBox::warning(
this,
tr("The Script has been modified."),
tr("Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Save
);
switch (result)
{
case QMessageBox::Save:
accept();
return;
case QMessageBox::Discard:
QDialog::reject();
return;
case QMessageBox::Cancel:
return;
default:
qWarning() << "unexpected dialog result" << result;
}
}
QString CodeEditorDialog::script() const
{
return m_ui->codeEdit->toPlainText();
}
void CodeEditorDialog::setScript(const QString &script)
{
QSignalBlocker blocker{m_ui->codeEdit};
m_ui->codeEdit->setPlainText(script);
}
void CodeEditorDialog::changed()
{
if (!m_unsavedChanges)
{
m_unsavedChanges = true;
updateTitle();
}
}
void CodeEditorDialog::addToolbarWidget(QWidget *widget)
{
m_ui->toolBar->addWidget(widget);
}
void CodeEditorDialog::load()
{
@@ -82,3 +155,11 @@ void CodeEditorDialog::updatePosition()
m_labelPosition->setText(tr("%0/%1: %2").arg(lines).arg(m_ui->codeEdit->blockCount()).arg(position));
}
void CodeEditorDialog::updateTitle()
{
setWindowTitle(tr("%0%1")
.arg(m_title)
.arg(m_unsavedChanges ? tr("*") : QString{})
);
}

View File

@@ -12,9 +12,26 @@ class CodeEditorDialog : public QDialog
Q_OBJECT
public:
explicit CodeEditorDialog(QWidget *parent = nullptr);
explicit CodeEditorDialog(const QString &title, QWidget *parent = nullptr);
~CodeEditorDialog();
void accept() override;
void reject() override;
const QString &title() const { return m_title; }
void setTitle(const QString &title) { if (m_title == title) return; m_title = title; updateTitle(); }
QString script() const;
void setScript(const QString &script);
protected slots:
void changed();
protected:
bool m_unsavedChanges{};
void addToolbarWidget(QWidget *widget);
private slots:
void load();
void save();
@@ -22,9 +39,12 @@ private slots:
void updatePosition();
protected:
private:
void updateTitle();
const std::unique_ptr<Ui::CodeEditorDialog> m_ui;
private:
QString m_title;
QLabel * const m_labelPosition;
};

View File

@@ -10,7 +10,7 @@ CreateSpriteDialog::CreateSpriteDialog(QWidget *parent) :
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags(windowFlags() & ~Qt::Dialog | Qt::Window);
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowCloseButtonHint);

View File

@@ -36,6 +36,9 @@
<property name="text">
<string>Width:</string>
</property>
<property name="buddy">
<cstring>spinBoxWidth</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
@@ -43,6 +46,9 @@
<property name="text">
<string>Height:</string>
</property>
<property name="buddy">
<cstring>spinBoxHeight</cstring>
</property>
</widget>
</item>
<item row="0" column="1">

View File

@@ -18,7 +18,7 @@ EditSpriteDialog::EditSpriteDialog(const std::vector<QPixmap> &pixmaps, const QS
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags(windowFlags() & ~Qt::Dialog | Qt::Window);
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowMinimizeButtonHint);
setWindowFlag(Qt::WindowMaximizeButtonHint);

View File

@@ -1,6 +1,8 @@
#include "extensionpackagesdialog.h"
#include "ui_extensionpackagesdialog.h"
#include "installextensiondialog.h"
ExtensionPackagesDialog::ExtensionPackagesDialog(QWidget *parent) :
QDialog{parent},
m_ui{std::make_unique<Ui::ExtensionPackagesDialog>()}
@@ -8,7 +10,7 @@ ExtensionPackagesDialog::ExtensionPackagesDialog(QWidget *parent) :
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags(windowFlags() & ~Qt::Dialog | Qt::Window);
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowCloseButtonHint);
@@ -16,8 +18,19 @@ ExtensionPackagesDialog::ExtensionPackagesDialog(QWidget *parent) :
button->setIcon(QIcon{":/qtgameengine/icons/ok.png"});
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Cancel))
button->setIcon(QIcon{":/qtgameengine/icons/delete.png"});
m_ui->buttonBox->addButton(tr("Install"), QDialogButtonBox::ActionRole)
->setIcon(QIcon{":/qtgameengine/icons/extension-packages-file.png"});
if (auto button = m_ui->buttonBox->addButton(tr("Install"), QDialogButtonBox::ActionRole))
{
button->setIcon(QIcon{":/qtgameengine/icons/extension-packages-file.png"});
connect(button, &QAbstractButton::clicked,
this, &ExtensionPackagesDialog::install);
}
}
ExtensionPackagesDialog::~ExtensionPackagesDialog() = default;
void ExtensionPackagesDialog::install()
{
InstallExtensionDialog dialog{this};
dialog.exec();
}

View File

@@ -14,6 +14,9 @@ public:
explicit ExtensionPackagesDialog(QWidget *parent = nullptr);
~ExtensionPackagesDialog();
private slots:
void install();
private:
const std::unique_ptr<Ui::ExtensionPackagesDialog> m_ui;
};

View File

@@ -35,13 +35,13 @@ FontPropertiesDialog::FontPropertiesDialog(Font &font, ProjectTreeModel &project
connect(&m_projectModel, &ProjectTreeModel::fontNameChanged,
this, &FontPropertiesDialog::fontNameChanged);
connect(m_ui->pushButtonNormal, &QAbstractButton::pressed,
connect(m_ui->pushButtonNormal, &QAbstractButton::clicked,
this, &FontPropertiesDialog::normalRange);
connect(m_ui->pushButtonDigits, &QAbstractButton::pressed,
connect(m_ui->pushButtonDigits, &QAbstractButton::clicked,
this, &FontPropertiesDialog::digitsRange);
connect(m_ui->pushButtonAll, &QAbstractButton::pressed,
connect(m_ui->pushButtonAll, &QAbstractButton::clicked,
this, &FontPropertiesDialog::allRange);
connect(m_ui->pushButtonLetters, &QAbstractButton::pressed,
connect(m_ui->pushButtonLetters, &QAbstractButton::clicked,
this, &FontPropertiesDialog::lettersRange);
connect(m_ui->lineEditName, &QLineEdit::textChanged,
@@ -64,6 +64,12 @@ FontPropertiesDialog::~FontPropertiesDialog() = default;
void FontPropertiesDialog::accept()
{
if (!m_unsavedChanges)
{
QDialog::reject();
return;
}
if (m_font.name != m_ui->lineEditName->text())
{
if (!m_projectModel.rename<Font>(m_font, m_ui->lineEditName->text()))

View File

@@ -8,7 +8,7 @@ GameInformationDialog::GameInformationDialog(QWidget *parent) :
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags(windowFlags() & ~Qt::Dialog | Qt::Window);
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowMinimizeButtonHint);
setWindowFlag(Qt::WindowMaximizeButtonHint);

View File

@@ -11,7 +11,7 @@ GlobalGameSettingsDialog::GlobalGameSettingsDialog(QWidget *parent) :
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags(windowFlags() & ~Qt::Dialog | Qt::Window);
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowCloseButtonHint);

View File

@@ -106,6 +106,9 @@
<property name="text">
<string>Color outside the room region:</string>
</property>
<property name="buddy">
<cstring>toolButtonColorOutside</cstring>
</property>
</widget>
</item>
<item>

View File

@@ -12,7 +12,7 @@ ImageEditorDialog::ImageEditorDialog(const QPixmap &pixmap, const QString &title
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags(windowFlags() & ~Qt::Dialog | Qt::Window);
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowMinimizeButtonHint);
setWindowFlag(Qt::WindowMaximizeButtonHint);

View File

@@ -25,35 +25,67 @@
</widget>
</item>
<item>
<widget class="QListView" name="listView"/>
<widget class="QListView" name="listView">
<property name="toolTip">
<string>This is the list of files to be included when creating a stand-alone game.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButtonAdd">
<property name="toolTip">
<string>Add a file to be included</string>
</property>
<property name="text">
<string>Add</string>
<string>&amp;Add</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/add.png</normaloff>:/qtgameengine/icons/add.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonChange">
<property name="toolTip">
<string>Change the properties of the included file</string>
</property>
<property name="text">
<string>Change</string>
<string>&amp;Change</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/replace.png</normaloff>:/qtgameengine/icons/replace.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonDelete">
<property name="toolTip">
<string>Delete the indicated included file</string>
</property>
<property name="text">
<string>Delete</string>
<string>&amp;Delete</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/delete.png</normaloff>:/qtgameengine/icons/delete.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonClear">
<property name="toolTip">
<string>Clear the list of included files</string>
</property>
<property name="text">
<string>Clear</string>
<string>&amp;Clear</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
</widget>
</item>
@@ -74,7 +106,9 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../resources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>

View File

@@ -0,0 +1,16 @@
#include "installextensiondialog.h"
#include "ui_installextensiondialog.h"
InstallExtensionDialog::InstallExtensionDialog(QWidget *parent) :
QDialog{parent},
m_ui{std::make_unique<Ui::InstallExtensionDialog>()}
{
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowCloseButtonHint);
}
InstallExtensionDialog::~InstallExtensionDialog() = default;

View File

@@ -0,0 +1,19 @@
#pragma once
#include <QDialog>
#include <memory>
namespace Ui { class InstallExtensionDialog; }
class InstallExtensionDialog : public QDialog
{
Q_OBJECT
public:
explicit InstallExtensionDialog(QWidget *parent = nullptr);
~InstallExtensionDialog();
private:
const std::unique_ptr<Ui::InstallExtensionDialog> m_ui;
};

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InstallExtensionDialog</class>
<widget class="QDialog" name="InstallExtensionDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Installing Extension Packages</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labelInstalledPackages">
<property name="text">
<string>Installed Packages:</string>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="listView"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>InstallExtensionDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>350</x>
<y>149</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>InstallExtensionDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>350</x>
<y>149</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -8,7 +8,7 @@ MaskPropertiesDialog::MaskPropertiesDialog(QWidget *parent) :
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags(windowFlags() & ~Qt::Dialog | Qt::Window);
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowCloseButtonHint);
}

View File

@@ -1,11 +1,228 @@
#include "objectpropertiesdialog.h"
#include "ui_objectpropertiesdialog.h"
#include <QMenu>
#include <QDebug>
#include <QMessageBox>
#include <algorithm>
#include "projectcontainer.h"
#include "projecttreemodel.h"
#include "objecteventsmodel.h"
#include "objectactionsmodel.h"
ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel &projectModel, QWidget *parent) :
QDialog{parent},
m_ui{std::make_unique<Ui::ObjectPropertiesDialog>()}
m_ui{std::make_unique<Ui::ObjectPropertiesDialog>()},
m_object{object},
m_projectModel{projectModel},
m_eventsModel{std::make_unique<ObjectEventsModel>()},
m_actionsModel{std::make_unique<ObjectActionsModel>()},
m_spritesMenu{new QMenu{m_ui->toolButtonSprite}},
m_spriteName{object.spriteName}
{
m_ui->setupUi(this);
updateTitle();
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"});
m_ui->lineEditName->setText(m_object.name);
m_ui->lineEditSprite->setText(m_spriteName.isEmpty() ? tr("<no sprite>") : m_spriteName);
if (!m_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 == m_spriteName; });
if (iter == std::cend(sprites))
qWarning() << "sprite" << m_spriteName << "not found";
else
m_ui->labelSpritePreview->setPixmap(iter->pixmaps.empty() ? QPixmap{} : iter->pixmaps.front().scaled(m_ui->labelSpritePreview->size(), Qt::KeepAspectRatio));
}
m_ui->toolButtonSprite->setMenu(m_spritesMenu);
m_ui->checkBoxVisible->setChecked(m_object.visible);
m_ui->checkBoxSolid->setChecked(m_object.solid);
m_ui->spinBoxDepth->setValue(m_object.depth);
m_ui->checkBoxPersistent->setChecked(m_object.persistent);
m_ui->listViewEvents->setModel(m_eventsModel.get());
connect(&m_projectModel, &ProjectTreeModel::objectNameChanged,
this, &ObjectPropertiesDialog::objectNameChanged);
connect(m_ui->pushButtonNewSprite, &QAbstractButton::clicked,
this, &ObjectPropertiesDialog::newSprite);
connect(m_ui->pushButtonEditSprite, &QAbstractButton::clicked,
this, &ObjectPropertiesDialog::editSprite);
connect(m_ui->pushButtonShowInformation, &QAbstractButton::clicked,
this, &ObjectPropertiesDialog::showInformation);
connect(m_ui->pushButtonAddEvent, &QAbstractButton::clicked,
this, &ObjectPropertiesDialog::addEvent);
connect(m_ui->pushButtonDeleteEvent, &QAbstractButton::clicked,
this, &ObjectPropertiesDialog::deleteEvent);
connect(m_ui->pushButtonChangeEvent, &QAbstractButton::clicked,
this, &ObjectPropertiesDialog::replaceEvent);
connect(m_ui->lineEditName, &QLineEdit::textChanged,
this, &ObjectPropertiesDialog::changed);
connect(m_ui->checkBoxVisible, &QCheckBox::toggled,
this, &ObjectPropertiesDialog::changed);
connect(m_ui->checkBoxSolid, &QCheckBox::toggled,
this, &ObjectPropertiesDialog::changed);
connect(m_ui->spinBoxDepth, &QSpinBox::valueChanged,
this, &ObjectPropertiesDialog::changed);
connect(m_ui->checkBoxPersistent, &QCheckBox::toggled,
this, &ObjectPropertiesDialog::changed);
connect(m_spritesMenu, &QMenu::aboutToShow,
this, &ObjectPropertiesDialog::spritesMenuAboutToShow);
}
ObjectPropertiesDialog::~ObjectPropertiesDialog() = default;
void ObjectPropertiesDialog::accept()
{
if (!m_unsavedChanges)
{
QDialog::reject();
return;
}
if (m_object.name != m_ui->lineEditName->text())
{
if (!m_projectModel.rename<Object>(m_object, m_ui->lineEditName->text()))
{
QMessageBox::critical(this, tr("Renaming Object failed!"), tr("Renaming Object failed!"));
return;
}
}
m_object.spriteName = m_spriteName;
m_object.visible = m_ui->checkBoxVisible->isChecked();
m_object.solid = m_ui->checkBoxSolid->isChecked();
m_object.depth = m_ui->spinBoxDepth->value();
m_object.persistent = m_ui->checkBoxPersistent->isChecked();
QDialog::accept();
}
void ObjectPropertiesDialog::reject()
{
if (!m_unsavedChanges)
{
QDialog::reject();
return;
}
const auto result = QMessageBox::warning(
this,
tr("The Object has been modified."),
tr("Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Save
);
switch (result)
{
case QMessageBox::Save:
accept();
return;
case QMessageBox::Discard:
QDialog::reject();
return;
case QMessageBox::Cancel:
return;
default:
qWarning() << "unexpected dialog result" << result;
}
}
void ObjectPropertiesDialog::newSprite()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void ObjectPropertiesDialog::editSprite()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void ObjectPropertiesDialog::showInformation()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void ObjectPropertiesDialog::addEvent()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void ObjectPropertiesDialog::deleteEvent()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void ObjectPropertiesDialog::replaceEvent()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void ObjectPropertiesDialog::changed()
{
if (!m_unsavedChanges)
{
m_unsavedChanges = true;
updateTitle();
}
}
void ObjectPropertiesDialog::objectNameChanged(const Object &object)
{
if (&object != &m_object)
return;
{
QSignalBlocker blocker{m_ui->lineEditName};
m_ui->lineEditName->setText(object.name);
}
updateTitle();
}
void ObjectPropertiesDialog::spritesMenuAboutToShow()
{
m_spritesMenu->clear();
m_spritesMenu->addAction(tr("<no sprite>"), this, &ObjectPropertiesDialog::clearSprite);
for (const auto &sprite : m_projectModel.project()->sprites)
m_spritesMenu->addAction(sprite.pixmaps.empty() ? QPixmap{} : sprite.pixmaps.front(),
sprite.name,
this,
[&sprite,this](){ setSprite(sprite); });
}
void ObjectPropertiesDialog::clearSprite()
{
m_ui->labelSpritePreview->setPixmap(QPixmap{});
m_ui->lineEditSprite->setText(tr("<no sprite>"));
m_spriteName = QString{};
changed();
}
void ObjectPropertiesDialog::setSprite(const Sprite &sprite)
{
m_ui->labelSpritePreview->setPixmap(sprite.pixmaps.empty() ? QPixmap{} : sprite.pixmaps.front().scaled(m_ui->labelSpritePreview->size(), Qt::KeepAspectRatio));
m_ui->lineEditSprite->setText(sprite.name);
m_spriteName = sprite.name;
changed();
}
void ObjectPropertiesDialog::updateTitle()
{
setWindowTitle(tr("Object Properties: %0%1")
.arg(m_object.name)
.arg(m_unsavedChanges ? tr("*") : QString{})
);
}

View File

@@ -4,9 +4,13 @@
#include <memory>
class QMenu;
namespace Ui { class ObjectPropertiesDialog; }
struct Object;
class ProjectTreeModel;
class ObjectEventsModel;
class ObjectActionsModel;
class Sprite;
class ObjectPropertiesDialog : public QDialog
{
@@ -16,6 +20,40 @@ public:
explicit ObjectPropertiesDialog(Object &object, ProjectTreeModel &projectModel, QWidget *parent = nullptr);
~ObjectPropertiesDialog();
void accept() override;
void reject() override;
private slots:
void newSprite();
void editSprite();
void showInformation();
void addEvent();
void deleteEvent();
void replaceEvent();
void changed();
void objectNameChanged(const Object &object);
void spritesMenuAboutToShow();
void clearSprite();
void setSprite(const Sprite &sprite);
private:
void updateTitle();
const std::unique_ptr<Ui::ObjectPropertiesDialog> m_ui;
Object &m_object;
ProjectTreeModel &m_projectModel;
const std::unique_ptr<ObjectEventsModel> m_eventsModel;
const std::unique_ptr<ObjectActionsModel> m_actionsModel;
QMenu * const m_spritesMenu;
QString m_spriteName;
bool m_unsavedChanges{};
};

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>794</width>
<height>466</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,9 +17,473 @@
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/object-file.png</normaloff>:/qtgameengine/icons/object-file.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0,1,0">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelName">
<property name="text">
<string>Name:</string>
</property>
<property name="buddy">
<cstring>lineEditName</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditName">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>The name of the object</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxSprite">
<property name="title">
<string>Sprite</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="labelSpritePreview">
<property name="minimumSize">
<size>
<width>32</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLineEdit" name="lineEditSprite">
<property name="toolTip">
<string>The sprite used to represent the object</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonSprite">
<property name="text">
<string>...</string>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPushButton" name="pushButtonNewSprite">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Create a new sprite for this object</string>
</property>
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonEditSprite">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Edit the sprite for this object</string>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBoxVisible">
<property name="toolTip">
<string>Whether the object is visible</string>
</property>
<property name="text">
<string>Visible</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxSolid">
<property name="toolTip">
<string>Whether the object is solid</string>
</property>
<property name="text">
<string>Solid</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="labelDepth">
<property name="text">
<string>Depth:</string>
</property>
<property name="buddy">
<cstring>spinBoxDepth</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBoxDepth">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>The depth at which the object is drawn</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBoxPersistent">
<property name="toolTip">
<string>Wheter the object is persistent between rooms</string>
</property>
<property name="text">
<string>Persistent</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelParent">
<property name="text">
<string>Parent:</string>
</property>
<property name="buddy">
<cstring>lineEditParent</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" 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>&lt;no parent&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonParent">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="lineEditMask">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>The image used as a collision mask for the object</string>
</property>
<property name="text">
<string>&lt;same as sprite&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonMask">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelMask">
<property name="text">
<string>Mask:</string>
</property>
<property name="buddy">
<cstring>lineEditMask</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonShowInformation">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Show the information about the object</string>
</property>
<property name="text">
<string>Show Information</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/info.png</normaloff>:/qtgameengine/icons/info.png</iconset>
</property>
</widget>
</item>
<item>
<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>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="labelEvents">
<property name="text">
<string>Events:</string>
</property>
<property name="buddy">
<cstring>listViewEvents</cstring>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="listViewEvents">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonAddEvent">
<property name="toolTip">
<string>Click here to add another event</string>
</property>
<property name="text">
<string>Add Event</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="pushButtonDeleteEvent">
<property name="toolTip">
<string>Delete the currently selected event</string>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonChangeEvent">
<property name="toolTip">
<string>Change which event has this behaviour</string>
</property>
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="labelActions">
<property name="text">
<string>Actions:</string>
</property>
<property name="buddy">
<cstring>listViewActions</cstring>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="listViewActions">
<property name="toolTip">
<string>Drag actions here</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>68</width>
<height>390</height>
</rect>
</property>
<attribute name="label">
<string>Page 1</string>
</attribute>
</widget>
<widget class="QWidget" name="page_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>68</width>
<height>390</height>
</rect>
</property>
<attribute name="label">
<string>Page 2</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
</resources>
<connections/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ObjectPropertiesDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>138</x>
<y>511</y>
</hint>
<hint type="destinationlabel">
<x>423</x>
<y>266</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ObjectPropertiesDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>138</x>
<y>511</y>
</hint>
<hint type="destinationlabel">
<x>423</x>
<y>266</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -108,11 +108,11 @@ PathPropertiesDialog::PathPropertiesDialog(Path &path, ProjectTreeModel &project
connect(m_ui->checkBoxClosed, &QCheckBox::toggled,
m_ui->widget, &PathPointsWidget::setClosed);
connect(m_ui->pushButtonAdd, &QAbstractButton::pressed,
connect(m_ui->pushButtonAdd, &QAbstractButton::clicked,
this, &PathPropertiesDialog::add);
connect(m_ui->pushButtonInsert, &QAbstractButton::pressed,
connect(m_ui->pushButtonInsert, &QAbstractButton::clicked,
this, &PathPropertiesDialog::insert);
connect(m_ui->pushButtonDelete, &QAbstractButton::pressed,
connect(m_ui->pushButtonDelete, &QAbstractButton::clicked,
this, &PathPropertiesDialog::delete_);
connect(m_ui->lineEditName, &QLineEdit::textChanged,

View File

@@ -191,6 +191,9 @@
<property name="text">
<string>X:</string>
</property>
<property name="buddy">
<cstring>spinBoxX</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
@@ -208,6 +211,9 @@
<property name="text">
<string>Y:</string>
</property>
<property name="buddy">
<cstring>spinBoxY</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
@@ -225,6 +231,9 @@
<property name="text">
<string>sp:</string>
</property>
<property name="buddy">
<cstring>spinBoxSp</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
@@ -341,6 +350,9 @@
<property name="text">
<string>Precision:</string>
</property>
<property name="buddy">
<cstring>spinBoxPrecision</cstring>
</property>
</widget>
</item>
<item row="0" column="1">

View File

@@ -10,7 +10,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) :
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags(windowFlags() & ~Qt::Dialog | Qt::Window);
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowCloseButtonHint);

View File

@@ -10,36 +10,38 @@
#include "projecttreemodel.h"
ScriptPropertiesDialog::ScriptPropertiesDialog(Script &script, ProjectTreeModel &projectModel, QWidget *parent) :
CodeEditorDialog{parent},
CodeEditorDialog{tr("Script Properties: %0").arg(script.name), parent},
m_script{script},
m_projectModel{projectModel},
m_lineEditName{new QLineEdit{this}}
{
updateTitle();
{
auto label = new QLabel{tr("Name:"), this};
label->setBuddy(m_lineEditName);
m_ui->toolBar->addWidget(label);
addToolbarWidget(label);
}
m_lineEditName->setMaximumWidth(100);
m_ui->toolBar->addWidget(m_lineEditName);
addToolbarWidget(m_lineEditName);
m_lineEditName->setText(m_script.name);
m_ui->codeEdit->setPlainText(m_script.script);
setScript(m_script.script);
connect(&m_projectModel, &ProjectTreeModel::scriptNameChanged,
this, &ScriptPropertiesDialog::scriptNameChanged);
connect(m_lineEditName, &QLineEdit::textChanged,
this, &ScriptPropertiesDialog::changed);
connect(m_ui->codeEdit, &QPlainTextEdit::textChanged,
this, &ScriptPropertiesDialog::changed);
}
void ScriptPropertiesDialog::accept()
{
if (!m_unsavedChanges)
{
QDialog::reject();
return;
}
if (m_script.name != m_lineEditName->text())
{
if (!m_projectModel.rename<Script>(m_script, m_lineEditName->text()))
@@ -49,68 +51,20 @@ void ScriptPropertiesDialog::accept()
}
}
m_script.script = m_ui->codeEdit->toPlainText();
m_script.script = script();
CodeEditorDialog::accept();
}
void ScriptPropertiesDialog::reject()
{
if (!m_unsavedChanges)
{
CodeEditorDialog::reject();
return;
}
const auto result = QMessageBox::warning(
this,
tr("The Script has been modified."),
tr("Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Save
);
switch (result)
{
case QMessageBox::Save:
accept();
return;
case QMessageBox::Discard:
CodeEditorDialog::reject();
return;
case QMessageBox::Cancel:
return;
default:
qWarning() << "unexpected dialog result" << result;
}
}
void ScriptPropertiesDialog::changed()
{
if (!m_unsavedChanges)
{
m_unsavedChanges = true;
updateTitle();
}
}
void ScriptPropertiesDialog::scriptNameChanged(const Script &script)
{
if (&script != &m_script)
return;
setTitle(tr("Script Properties: %0").arg(script.name));
{
QSignalBlocker blocker{m_lineEditName};
m_lineEditName->setText(script.name);
}
updateTitle();
}
void ScriptPropertiesDialog::updateTitle()
{
setWindowTitle(tr("Script Properties: %0%1")
.arg(m_script.name)
.arg(m_unsavedChanges ? tr("*") : QString{})
);
}

View File

@@ -12,20 +12,13 @@ public:
ScriptPropertiesDialog(Script &script, ProjectTreeModel &projectModel, QWidget *parent = nullptr);
void accept() override;
void reject() override;
private slots:
void changed();
void scriptNameChanged(const Script &script);
private:
void updateTitle();
Script &m_script;
ProjectTreeModel &m_projectModel;
bool m_unsavedChanges{};
QLineEdit * const m_lineEditName;
};

View File

@@ -48,15 +48,15 @@ SoundPropertiesDialog::SoundPropertiesDialog(Sound &sound, ProjectTreeModel &pro
connect(&m_projectModel, &ProjectTreeModel::soundNameChanged,
this, &SoundPropertiesDialog::soundNameChanged);
connect(m_ui->pushButtonLoad, &QAbstractButton::pressed,
connect(m_ui->pushButtonLoad, &QAbstractButton::clicked,
this, &SoundPropertiesDialog::loadSound);
connect(m_ui->pushButtonPlay, &QAbstractButton::pressed,
connect(m_ui->pushButtonPlay, &QAbstractButton::clicked,
this, &SoundPropertiesDialog::playSound);
connect(m_ui->pushButtonStop, &QAbstractButton::pressed,
connect(m_ui->pushButtonStop, &QAbstractButton::clicked,
this, &SoundPropertiesDialog::stopSound);
connect(m_ui->pushButtonSave, &QAbstractButton::pressed,
connect(m_ui->pushButtonSave, &QAbstractButton::clicked,
this, &SoundPropertiesDialog::saveSound);
connect(m_ui->pushButtonEdit, &QAbstractButton::pressed,
connect(m_ui->pushButtonEdit, &QAbstractButton::clicked,
this, &SoundPropertiesDialog::editSound);
connect(m_ui->lineEditName, &QLineEdit::textChanged,

View File

@@ -5,7 +5,6 @@
#include <QSoundEffect>
#include <memory>
#include <optional>
namespace Ui { class SoundPropertiesDialog; }
struct Sound;

View File

@@ -37,15 +37,15 @@ SpritePropertiesDialog::SpritePropertiesDialog(Sprite &sprite, ProjectTreeModel
connect(&m_projectModel, &ProjectTreeModel::spriteNameChanged,
this, &SpritePropertiesDialog::spriteNameChanged);
connect(m_ui->pushButtonLoad, &QAbstractButton::pressed,
connect(m_ui->pushButtonLoad, &QAbstractButton::clicked,
this, &SpritePropertiesDialog::loadSprite);
connect(m_ui->pushButtonSave, &QAbstractButton::pressed,
connect(m_ui->pushButtonSave, &QAbstractButton::clicked,
this, &SpritePropertiesDialog::saveSprite);
connect(m_ui->pushButtonEdit, &QAbstractButton::pressed,
connect(m_ui->pushButtonEdit, &QAbstractButton::clicked,
this, &SpritePropertiesDialog::editSprite);
connect(m_ui->pushButtonCenterOrigin, &QAbstractButton::pressed,
connect(m_ui->pushButtonCenterOrigin, &QAbstractButton::clicked,
this, &SpritePropertiesDialog::centerOrigin);
connect(m_ui->pushButtonModifyCollisionmask, &QAbstractButton::pressed,
connect(m_ui->pushButtonModifyCollisionmask, &QAbstractButton::clicked,
this, &SpritePropertiesDialog::modifyMask);
connect(m_ui->lineEditName, &QLineEdit::textChanged,

View File

@@ -4,7 +4,6 @@
#include <QString>
#include <memory>
#include <optional>
namespace Ui { class SpritePropertiesDialog; }
struct Sprite;

View File

@@ -1,11 +1,188 @@
#include "timelinepropertiesdialog.h"
#include "ui_timelinepropertiesdialog.h"
#include <QDebug>
#include <QMessageBox>
#include "projectcontainer.h"
#include "projecttreemodel.h"
#include "timelinemomentsmodel.h"
#include "timelineactionsmodel.h"
TimeLinePropertiesDialog::TimeLinePropertiesDialog(TimeLine &timeLine, ProjectTreeModel &projectModel, QWidget *parent) :
QDialog{parent},
m_ui{std::make_unique<Ui::TimeLinePropertiesDialog>()}
m_ui{std::make_unique<Ui::TimeLinePropertiesDialog>()},
m_timeLine{timeLine},
m_projectModel{projectModel},
m_momentsModel{std::make_unique<TimelineMomentsModel>(this)},
m_actionsModel{std::make_unique<TimelineActionsModel>(this)}
{
m_ui->setupUi(this);
updateTitle();
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"});
m_ui->lineEditName->setText(m_timeLine.name);
m_ui->listViewMoments->setModel(m_momentsModel.get());
m_ui->listViewActions->setModel(m_actionsModel.get());
connect(&m_projectModel, &ProjectTreeModel::timeLineNameChanged,
this, &TimeLinePropertiesDialog::timeLineNameChanged);
connect(m_ui->lineEditName, &QLineEdit::textChanged,
this, &TimeLinePropertiesDialog::changed);
connect(m_ui->pushButtonAdd, &QAbstractButton::clicked,
this, &TimeLinePropertiesDialog::add);
connect(m_ui->pushButtonChange, &QAbstractButton::clicked,
this, &TimeLinePropertiesDialog::change);
connect(m_ui->pushButtonDelete, &QAbstractButton::clicked,
this, &TimeLinePropertiesDialog::delete_);
connect(m_ui->pushButtonClear, &QAbstractButton::clicked,
this, &TimeLinePropertiesDialog::clear);
connect(m_ui->pushButtonShift, &QAbstractButton::clicked,
this, &TimeLinePropertiesDialog::shift);
connect(m_ui->pushButtonDuplicate, &QAbstractButton::clicked,
this, &TimeLinePropertiesDialog::duplicate);
connect(m_ui->pushButtonSpread, &QAbstractButton::clicked,
this, &TimeLinePropertiesDialog::spread);
connect(m_ui->pushButtonMerge, &QAbstractButton::clicked,
this, &TimeLinePropertiesDialog::merge);
connect(m_ui->pushButtonShowInformation, &QAbstractButton::clicked,
this, &TimeLinePropertiesDialog::showInformation);
}
TimeLinePropertiesDialog::~TimeLinePropertiesDialog() = default;
void TimeLinePropertiesDialog::accept()
{
if (!m_unsavedChanges)
{
QDialog::reject();
return;
}
if (m_timeLine.name != m_ui->lineEditName->text())
{
if (!m_projectModel.rename<TimeLine>(m_timeLine, m_ui->lineEditName->text()))
{
QMessageBox::critical(this, tr("Renaming Time Line failed!"), tr("Renaming Time Line failed!"));
return;
}
}
// TODO
QDialog::accept();
}
void TimeLinePropertiesDialog::reject()
{
if (!m_unsavedChanges)
{
QDialog::reject();
return;
}
const auto result = QMessageBox::warning(
this,
tr("The Time Line has been modified."),
tr("Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Save
);
switch (result)
{
case QMessageBox::Save:
accept();
return;
case QMessageBox::Discard:
QDialog::reject();
return;
case QMessageBox::Cancel:
return;
default:
qWarning() << "unexpected dialog result" << result;
}
}
void TimeLinePropertiesDialog::changed()
{
if (!m_unsavedChanges)
{
m_unsavedChanges = true;
updateTitle();
}
}
void TimeLinePropertiesDialog::timeLineNameChanged(const TimeLine &timeLine)
{
if (&timeLine != &m_timeLine)
return;
{
QSignalBlocker blocker{m_ui->lineEditName};
m_ui->lineEditName->setText(timeLine.name);
}
updateTitle();
}
void TimeLinePropertiesDialog::add()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TimeLinePropertiesDialog::change()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TimeLinePropertiesDialog::delete_()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TimeLinePropertiesDialog::clear()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TimeLinePropertiesDialog::shift()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TimeLinePropertiesDialog::duplicate()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TimeLinePropertiesDialog::spread()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TimeLinePropertiesDialog::merge()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TimeLinePropertiesDialog::showInformation()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TimeLinePropertiesDialog::updateTitle()
{
setWindowTitle(tr("Time Line Properties: %0%1")
.arg(m_timeLine.name)
.arg(m_unsavedChanges ? tr("*") : QString{})
);
}

View File

@@ -7,6 +7,8 @@
namespace Ui { class TimeLinePropertiesDialog; }
struct TimeLine;
class ProjectTreeModel;
class TimelineMomentsModel;
class TimelineActionsModel;
class TimeLinePropertiesDialog : public QDialog
{
@@ -16,6 +18,34 @@ public:
explicit TimeLinePropertiesDialog(TimeLine &timeLine, ProjectTreeModel &projectModel, QWidget *parent = nullptr);
~TimeLinePropertiesDialog();
void accept() override;
void reject() override;
private slots:
void changed();
void timeLineNameChanged(const TimeLine &timeLine);
void add();
void change();
void delete_();
void clear();
void shift();
void duplicate();
void spread();
void merge();
void showInformation();
private:
void updateTitle();
const std::unique_ptr<Ui::TimeLinePropertiesDialog> m_ui;
TimeLine &m_timeLine;
ProjectTreeModel &m_projectModel;
const std::unique_ptr<TimelineMomentsModel> m_momentsModel;
const std::unique_ptr<TimelineActionsModel> m_actionsModel;
bool m_unsavedChanges{};
};

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>838</width>
<height>533</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,9 +17,341 @@
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/timeline-file.png</normaloff>:/qtgameengine/icons/timeline-file.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,1,0">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labelName">
<property name="text">
<string>Name:</string>
</property>
<property name="buddy">
<cstring>lineEditName</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditName">
<property name="toolTip">
<string>The name of the time line</string>
</property>
</widget>
</item>
<item>
<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>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pushButtonAdd">
<property name="toolTip">
<string>Click here to add another moment</string>
</property>
<property name="text">
<string>&amp;Add</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/add.png</normaloff>:/qtgameengine/icons/add.png</iconset>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButtonChange">
<property name="toolTip">
<string>Change the moment</string>
</property>
<property name="text">
<string>&amp;Change</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/replace.png</normaloff>:/qtgameengine/icons/replace.png</iconset>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButtonDelete">
<property name="toolTip">
<string>Delete moments</string>
</property>
<property name="text">
<string>&amp;Delete</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/delete.png</normaloff>:/qtgameengine/icons/delete.png</iconset>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButtonShift">
<property name="toolTip">
<string>Shift moments by an amount</string>
</property>
<property name="text">
<string>&amp;Shift</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-right.png</normaloff>:/qtgameengine/icons/arrow-right.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButtonClear">
<property name="toolTip">
<string>Clear all moments</string>
</property>
<property name="text">
<string>C&amp;lear</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButtonDuplicate">
<property name="toolTip">
<string>Duplicate moments</string>
</property>
<property name="text">
<string>D&amp;uplicate</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/copy.png</normaloff>:/qtgameengine/icons/copy.png</iconset>
</property>
</widget>
</item>
<item row="2" column="0">
<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="4" column="0">
<widget class="QPushButton" name="pushButtonSpread">
<property name="toolTip">
<string>Spread out the moments adding additional time between them</string>
</property>
<property name="text">
<string>S&amp;pread</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/scale.png</normaloff>:/qtgameengine/icons/scale.png</iconset>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="pushButtonMerge">
<property name="toolTip">
<string>Merge a number of moments into one</string>
</property>
<property name="text">
<string>&amp;Merge</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/merge.png</normaloff>:/qtgameengine/icons/merge.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<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>
<widget class="QPushButton" name="pushButtonShowInformation">
<property name="toolTip">
<string>Show information about the time line</string>
</property>
<property name="text">
<string>Show &amp;Information</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/info.png</normaloff>:/qtgameengine/icons/info.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<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>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="labelMoments">
<property name="text">
<string>Moments:</string>
</property>
<property name="buddy">
<cstring>listViewMoments</cstring>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="listViewMoments">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="labelActions">
<property name="text">
<string>Actions:</string>
</property>
<property name="buddy">
<cstring>listViewActions</cstring>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="listViewActions">
<property name="toolTip">
<string>Drag actions here</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>68</width>
<height>457</height>
</rect>
</property>
<attribute name="label">
<string>Page 1</string>
</attribute>
</widget>
<widget class="QWidget" name="page_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>68</width>
<height>457</height>
</rect>
</property>
<attribute name="label">
<string>Page 2</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
</resources>
<connections/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>TimeLinePropertiesDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>150</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>256</x>
<y>239</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>TimeLinePropertiesDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>150</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>256</x>
<y>239</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -1,10 +1,10 @@
#include "triggerconditiondialog.h"
TriggerConditionDialog::TriggerConditionDialog(QWidget *parent) :
CodeEditorDialog{parent}
CodeEditorDialog{tr("Trigger condition"), parent}
{
#ifdef Q_OS_LINUX
setWindowFlags(windowFlags() & ~Qt::Dialog | Qt::Window);
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowMinimizeButtonHint);
setWindowFlag(Qt::WindowMaximizeButtonHint);

View File

@@ -1,6 +1,9 @@
#include "triggersdialog.h"
#include "ui_triggersdialog.h"
#include <QDebug>
#include <QMessageBox>
#include "projectcontainer.h"
#include "triggersmodel.h"
#include "triggerconditiondialog.h"
@@ -20,14 +23,50 @@ TriggersDialog::TriggersDialog(ProjectContainer &project, QWidget *parent) :
m_ui->listView->setModel(m_model.get());
connect(m_ui->pushButtonUseCodeEditor, &QAbstractButton::pressed,
connect(m_ui->pushButtonAdd, &QAbstractButton::clicked,
this, &TriggersDialog::add);
connect(m_ui->pushButtonDelete, &QAbstractButton::clicked,
this, &TriggersDialog::delete_);
connect(m_ui->pushButtonLoad, &QAbstractButton::clicked,
this, &TriggersDialog::load);
connect(m_ui->pushButtonSave, &QAbstractButton::clicked,
this, &TriggersDialog::save);
connect(m_ui->pushButtonClear, &QAbstractButton::clicked,
this, &TriggersDialog::clear);
connect(m_ui->pushButtonUseCodeEditor, &QAbstractButton::clicked,
this, &TriggersDialog::openCodeEditor);
}
void TriggersDialog::add()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TriggersDialog::delete_()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TriggersDialog::load()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TriggersDialog::save()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void TriggersDialog::clear()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
TriggersDialog::~TriggersDialog() = default;
void TriggersDialog::openCodeEditor()
{
TriggerConditionDialog dialog{this};
dialog.exec();
if (dialog.exec() == QDialog::Accepted)
m_ui->plainTextEdit->setPlainText(dialog.script());
}

View File

@@ -17,6 +17,12 @@ public:
~TriggersDialog();
private slots:
void add();
void delete_();
void load();
void save();
void clear();
void openCodeEditor();
private:

View File

@@ -24,6 +24,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>List of all defined triggers. Click on a trigger to change it</string>
</property>
</widget>
</item>
<item>
@@ -36,6 +39,10 @@
<property name="text">
<string>&amp;Load</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
</widget>
</item>
<item row="0" column="1">
@@ -46,6 +53,10 @@
<property name="text">
<string>&amp;Delete</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/delete.png</normaloff>:/qtgameengine/icons/delete.png</iconset>
</property>
</widget>
</item>
<item row="0" column="0">
@@ -56,6 +67,10 @@
<property name="text">
<string>&amp;Add</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/add.png</normaloff>:/qtgameengine/icons/add.png</iconset>
</property>
</widget>
</item>
<item row="2" column="0">
@@ -66,6 +81,10 @@
<property name="text">
<string>&amp;Clear</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
@@ -76,6 +95,10 @@
<property name="text">
<string>&amp;Save</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
</widget>
</item>
</layout>
@@ -103,20 +126,34 @@
<property name="text">
<string>Name:</string>
</property>
<property name="buddy">
<cstring>lineEditName</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditName"/>
<widget class="QLineEdit" name="lineEditName">
<property name="toolTip">
<string>Type here a name for the trigger</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelCondition">
<property name="text">
<string>Condition:</string>
</property>
<property name="buddy">
<cstring>plainTextEdit</cstring>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit"/>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="toolTip">
<string>Type here the condition for the trigger</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
@@ -135,6 +172,9 @@
</item>
<item>
<widget class="QPushButton" name="pushButtonUseCodeEditor">
<property name="toolTip">
<string>Use the code editor to edit the condition</string>
</property>
<property name="text">
<string>&amp;Use code editor</string>
</property>
@@ -153,6 +193,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="radioButtonBegin">
<property name="toolTip">
<string>Event will be checked at the beginning of each step</string>
</property>
<property name="text">
<string>Begin of step</string>
</property>
@@ -160,6 +203,9 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonMiddle">
<property name="toolTip">
<string>Event will be checked in the middle of each step (just before the step event)</string>
</property>
<property name="text">
<string>Middle of step</string>
</property>
@@ -167,6 +213,9 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonEnd">
<property name="toolTip">
<string>Event will be checked at the end of each step</string>
</property>
<property name="text">
<string>End of step</string>
</property>
@@ -179,17 +228,26 @@
<property name="text">
<string>Constant name:</string>
</property>
<property name="buddy">
<cstring>lineEditConstantName</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditConstantName"/>
<widget class="QLineEdit" name="lineEditConstantName">
<property name="toolTip">
<string>When required you can provide a constant name that you can use in code to call the event</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../resources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>

View File

@@ -1,6 +1,9 @@
#include "userdefinedconstantsdialog.h"
#include "ui_userdefinedconstantsdialog.h"
#include <QDebug>
#include <QMessageBox>
#include "projectcontainer.h"
#include "constantsmodel.h"
@@ -18,6 +21,70 @@ UserDefinedConstantsDialog::UserDefinedConstantsDialog(ProjectContainer &project
button->setIcon(QIcon{":/qtgameengine/icons/delete.png"});
m_ui->treeView->setModel(m_model.get());
connect(m_ui->pushButtonInsert, &QAbstractButton::clicked,
this, &UserDefinedConstantsDialog::insert);
connect(m_ui->pushButtonAdd, &QAbstractButton::clicked,
this, &UserDefinedConstantsDialog::add);
connect(m_ui->pushButtonDelete, &QAbstractButton::clicked,
this, &UserDefinedConstantsDialog::delete_);
connect(m_ui->pushButtonClear, &QAbstractButton::clicked,
this, &UserDefinedConstantsDialog::clear);
connect(m_ui->pushButtonUp, &QAbstractButton::clicked,
this, &UserDefinedConstantsDialog::up);
connect(m_ui->pushButtonDown, &QAbstractButton::clicked,
this, &UserDefinedConstantsDialog::down);
connect(m_ui->pushButtonSort, &QAbstractButton::clicked,
this, &UserDefinedConstantsDialog::sort);
connect(m_ui->pushButtonLoad, &QAbstractButton::clicked,
this, &UserDefinedConstantsDialog::load);
connect(m_ui->pushButtonSave, &QAbstractButton::clicked,
this, &UserDefinedConstantsDialog::save);
}
UserDefinedConstantsDialog::~UserDefinedConstantsDialog() = default;
void UserDefinedConstantsDialog::insert()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void UserDefinedConstantsDialog::add()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void UserDefinedConstantsDialog::delete_()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void UserDefinedConstantsDialog::clear()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void UserDefinedConstantsDialog::up()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void UserDefinedConstantsDialog::down()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void UserDefinedConstantsDialog::sort()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void UserDefinedConstantsDialog::load()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void UserDefinedConstantsDialog::save()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}

View File

@@ -16,6 +16,17 @@ public:
explicit UserDefinedConstantsDialog(ProjectContainer &project, QWidget *parent = nullptr);
~UserDefinedConstantsDialog();
private slots:
void insert();
void add();
void delete_();
void clear();
void up();
void down();
void sort();
void load();
void save();
private:
const std::unique_ptr<Ui::UserDefinedConstantsDialog> m_ui;

View File

@@ -32,65 +32,128 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pushButtonInsert">
<property name="toolTip">
<string>Insert a constant before the current one</string>
</property>
<property name="text">
<string>&amp;Insert</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/add.png</normaloff>:/qtgameengine/icons/add.png</iconset>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButtonSort">
<property name="toolTip">
<string>Sort the constants</string>
</property>
<property name="text">
<string>&amp;Sort</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/sort.png</normaloff>:/qtgameengine/icons/sort.png</iconset>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButtonDelete">
<property name="toolTip">
<string>Delete the current constant</string>
</property>
<property name="text">
<string>&amp;Delete</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/delete.png</normaloff>:/qtgameengine/icons/delete.png</iconset>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="pushButtonLoad">
<property name="toolTip">
<string>Load the constants from a text file</string>
</property>
<property name="text">
<string>&amp;Load</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonUp">
<property name="toolTip">
<string>Moves the constant up</string>
</property>
<property name="text">
<string>&amp;Up</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-up.png</normaloff>:/qtgameengine/icons/arrow-up.png</iconset>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButtonAdd">
<property name="toolTip">
<string>Append a constant at the end of the list</string>
</property>
<property name="text">
<string>&amp;Add</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/add.png</normaloff>:/qtgameengine/icons/add.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButtonClear">
<property name="toolTip">
<string>Clear all the constants</string>
</property>
<property name="text">
<string>&amp;Clear</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButtonDown">
<property name="toolTip">
<string>Moves the constant down</string>
</property>
<property name="text">
<string>Do&amp;wn</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-down.png</normaloff>:/qtgameengine/icons/arrow-down.png</iconset>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="pushButtonSave">
<property name="toolTip">
<string>Save the constants to a text file</string>
</property>
<property name="text">
<string>Sa&amp;ve</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
</widget>
</item>
</layout>

View File

@@ -27,11 +27,33 @@ void DrawingCanvasWidget::setScale(float scale)
void DrawingCanvasWidget::paintEvent(QPaintEvent *ev)
{
QWidget::paintEvent(ev);
if (!m_pixmap)
{
QWidget::paintEvent(ev);
return;
}
QBrush brush;
{
QPixmap pixmap{32, 32};
{
QPainter painter{&pixmap};
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::gray);
painter.drawRect(0, 0, 16, 16);
painter.drawRect(16, 16, 16, 16);
painter.setBrush(Qt::white);
painter.drawRect(0, 16, 16, 16);
painter.drawRect(16, 0, 16, 16);
}
brush.setTexture(std::move(pixmap));
}
QPainter painter{this};
painter.drawPixmap(QRect{QPoint{}, m_pixmap->size() * m_scale}, *m_pixmap);
painter.setPen(Qt::NoPen);
painter.setBrush(std::move(brush));
painter.drawRect(rect());
painter.drawPixmap(rect(), *m_pixmap);
}

View File

@@ -23,8 +23,11 @@ bit_cast(const From& src) noexcept
return dst;
}
#if !__cpp_lib_to_underlying
template <typename EnumT, typename = std::enable_if_t<std::is_enum<EnumT>{}>>
constexpr std::underlying_type_t<EnumT> to_underlying(EnumT e) noexcept {
return static_cast<std::underlying_type_t<EnumT>>(e);
}
#endif
} // namespace std

BIN
icons/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
icons/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
icons/merge.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
icons/replace.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
icons/sort.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -10,10 +10,13 @@ IncludedFilesModel::IncludedFilesModel(ProjectContainer &project, QObject *paren
int IncludedFilesModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return 0;
}
QVariant IncludedFilesModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(index)
Q_UNUSED(role)
return {};
}

View File

@@ -1,6 +1,6 @@
#include <QApplication>
#include <QStyleFactory>
#include <QDebug>
#include <QCommandLineParser>
#include "mainwindow.h"
@@ -21,9 +21,21 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
QCoreApplication::setOrganizationDomain("brunner.ninja");
QCoreApplication::setOrganizationName("brunner.ninja");
QCoreApplication::setApplicationName("QtGameMaker");
QCoreApplication::setApplicationVersion("1.0");
QCommandLineParser parser;
parser.setApplicationDescription(QCoreApplication::applicationName());
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("project", "The project to open.");
parser.process(app);
QApplication::setStyle(QStyleFactory::create("Windows"));
MainWindow mainWindow;
MainWindow mainWindow{parser.positionalArguments().value(0)};
mainWindow.show();
return app.exec();

View File

@@ -41,9 +41,10 @@ template<> struct PropertiesDialogForDetail<Room> { using Type = RoomPropertiesD
template<typename T> using PropertiesDialogFor = typename PropertiesDialogForDetail<T>::Type;
}
MainWindow::MainWindow(QWidget *parent) :
MainWindow::MainWindow(const QString &filePath, QWidget *parent) :
QMainWindow{parent},
m_ui{std::make_unique<Ui::MainWindow>()},
m_filePath{filePath},
m_projectTreeModel{std::make_unique<ProjectTreeModel>(m_project, this)}
{
m_ui->setupUi(this);
@@ -145,6 +146,9 @@ MainWindow::MainWindow(QWidget *parent) :
this, &MainWindow::changed);
updateTitle();
if (!m_filePath.isEmpty())
loadFile(m_filePath);
}
void MainWindow::closeEvent(QCloseEvent *event)
@@ -388,58 +392,7 @@ void MainWindow::openFile()
if (path.isEmpty())
return;
ProjectContainer project;
{
QFile file{path};
if (!file.open(QIODevice::ReadOnly))
{
QMessageBox::warning(this, tr("Could not load game!"), tr("Could not load game!") + "\n\n" + file.errorString());
return;
}
QDataStream dataStream{&file};
dataStream >> project;
}
m_ui->mdiArea->closeAllSubWindows();
if (!m_ui->mdiArea->subWindowList().empty())
return;
if (m_unsavedChanges)
{
const auto result = QMessageBox::warning(
this,
tr("The Game has been modified."),
tr("Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Save
);
switch (result)
{
case QMessageBox::Save:
saveFile();
if (m_unsavedChanges)
return;
else
break;
case QMessageBox::Discard:
break;
case QMessageBox::Cancel:
return;
default:
qWarning() << "unexpected dialog result" << result;
return;
}
}
m_project = std::move(project);
m_projectTreeModel->setProject(&m_project);
m_filePath = path;
m_unsavedChanges = false;
updateTitle();
loadFile(path);
}
void MainWindow::saveFile()
@@ -537,15 +490,18 @@ void MainWindow::create()
{
switch (m_projectTreeModel->nodeType(index))
{
case ProjectTreeModel::NodeType::Sprite:
case ProjectTreeModel::NodeType::Sound:
case ProjectTreeModel::NodeType::Background:
case ProjectTreeModel::NodeType::Path:
case ProjectTreeModel::NodeType::Script:
case ProjectTreeModel::NodeType::Font:
case ProjectTreeModel::NodeType::TimeLine:
case ProjectTreeModel::NodeType::Object:
case ProjectTreeModel::NodeType::Room:
using NodeType = ProjectTreeModel::NodeType;
case NodeType::Root:
break;
case NodeType::Sprite:
case NodeType::Sound:
case NodeType::Background:
case NodeType::Path:
case NodeType::Script:
case NodeType::Font:
case NodeType::TimeLine:
case NodeType::Object:
case NodeType::Room:
if (!m_projectTreeModel->insertRows(index.row(), 1, index.parent()))
QMessageBox::warning(this, tr("Inserting failed!"), tr("Inserting failed!"));
break;
@@ -669,6 +625,8 @@ void MainWindow::about()
void MainWindow::rowsInserted(const QModelIndex &parent, int first, int last)
{
Q_UNUSED(last)
m_ui->treeView->expand(parent);
const auto index = m_projectTreeModel->index(first, 0, parent);
m_ui->treeView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
@@ -701,6 +659,62 @@ void MainWindow::modelAboutToBeReset()
modelAboutToBeResetFor<Room>();
}
void MainWindow::loadFile(const QString &path)
{
ProjectContainer project;
{
QFile file{path};
if (!file.open(QIODevice::ReadOnly))
{
QMessageBox::warning(this, tr("Could not load game!"), tr("Could not load game!") + "\n\n" + file.errorString());
return;
}
QDataStream dataStream{&file};
dataStream >> project;
}
m_ui->mdiArea->closeAllSubWindows();
if (!m_ui->mdiArea->subWindowList().empty())
return;
if (m_unsavedChanges)
{
const auto result = QMessageBox::warning(
this,
tr("The Game has been modified."),
tr("Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Save
);
switch (result)
{
case QMessageBox::Save:
saveFile();
if (m_unsavedChanges)
return;
else
break;
case QMessageBox::Discard:
break;
case QMessageBox::Cancel:
return;
default:
qWarning() << "unexpected dialog result" << result;
return;
}
}
m_project = std::move(project);
m_projectTreeModel->setProject(&m_project);
m_filePath = path;
m_unsavedChanges = false;
updateTitle();
}
void MainWindow::updateTitle()
{
setWindowTitle(tr("%0%1 - Qt Gamemaker 1.0 Ultimate")
@@ -726,6 +740,7 @@ void MainWindow::openOrActivateWindow(QMdiSubWindow * &ptr, Targs &&...args)
});
connect(subwindow, &QMdiSubWindow::windowStateChanged,
action, [action](Qt::WindowStates oldState, Qt::WindowStates newState){
Q_UNUSED(oldState)
action->setChecked(newState.testFlag(Qt::WindowActive));
});
connect(dialog, &QWidget::windowTitleChanged, action, &QAction::setText);
@@ -770,6 +785,7 @@ bool MainWindow::doubleClickedFor(const QModelIndex &index)
});
connect(subwindow, &QMdiSubWindow::windowStateChanged,
action, [action](Qt::WindowStates oldState, Qt::WindowStates newState){
Q_UNUSED(oldState)
action->setChecked(newState.testFlag(Qt::WindowActive));
});
connect(dialog, &QWidget::windowTitleChanged, action, &QAction::setText);

View File

@@ -16,7 +16,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
explicit MainWindow(const QString &filePath, QWidget *parent = nullptr);
~MainWindow();
protected:
@@ -64,6 +64,7 @@ private slots:
void modelAboutToBeReset();
private:
void loadFile(const QString &path);
void updateTitle();
template<typename T, typename ...Targs>

19
objectactionsmodel.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "objectactionsmodel.h"
ObjectActionsModel::ObjectActionsModel(QObject *parent) :
QAbstractListModel{parent}
{
}
int ObjectActionsModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return 0;
}
QVariant ObjectActionsModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(index)
Q_UNUSED(role)
return {};
}

14
objectactionsmodel.h Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include <QAbstractListModel>
class ObjectActionsModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit ObjectActionsModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
};

19
objecteventsmodel.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "objecteventsmodel.h"
ObjectEventsModel::ObjectEventsModel(QObject *parent) :
QAbstractListModel{parent}
{
}
int ObjectEventsModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return 0;
}
QVariant ObjectEventsModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(index)
Q_UNUSED(role)
return {};
}

14
objecteventsmodel.h Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include <QAbstractListModel>
class ObjectEventsModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit ObjectEventsModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
};

View File

@@ -18,11 +18,13 @@ PathPointsModel::PathPointsModel(std::vector<Path::Point> &points, QObject *pare
int PathPointsModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return m_points.size();
}
int PathPointsModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return NumberOfColumns;
}

View File

@@ -66,6 +66,8 @@ void PathPointsWidget::setSelectedIndex(const std::optional<std::size_t> &select
void PathPointsWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
if (m_showGrid)
{
if (!m_gridBrush || m_gridBrush->gridX != m_gridX || m_gridBrush->gridY != m_gridY)
@@ -174,6 +176,7 @@ createNew:
}
update();
break;
default:;
}
}
@@ -186,6 +189,7 @@ void PathPointsWidget::mouseReleaseEvent(QMouseEvent *event)
case Qt::LeftButton:
m_dragIndex = std::nullopt;
break;
default:;
}
}

View File

@@ -220,12 +220,22 @@ QDataStream &operator>>(QDataStream &ds, TimeLine &timeLine)
QDataStream &operator<<(QDataStream &ds, const Object &object)
{
ds << object.name;
ds << object.spriteName;
ds << object.visible;
ds << object.solid;
ds << object.depth;
ds << object.persistent;
return ds;
}
QDataStream &operator>>(QDataStream &ds, Object &object)
{
ds >> object.name;
ds >> object.spriteName;
ds >> object.visible;
ds >> object.solid;
ds >> object.depth;
ds >> object.persistent;
return ds;
}

View File

@@ -85,6 +85,11 @@ struct TimeLine
struct Object
{
QString name;
QString spriteName;
bool visible{true};
bool solid{};
int depth{};
bool persistent{};
};
struct Room

View File

@@ -6,7 +6,7 @@
#include <utility>
#include <algorithm>
//#include "futurecpp.h"
#include "futurecpp.h"
#include "projectcontainer.h"
namespace {
@@ -261,6 +261,8 @@ Qt::ItemFlags ProjectTreeModel::flags(const QModelIndex &index) const
switch (nodeType(index))
{
case NodeType::Root:
break;
case NodeType::Sprite:
case NodeType::Sound:
case NodeType::Background:
@@ -297,6 +299,9 @@ bool ProjectTreeModel::setData(const QModelIndex &index, const QVariant &value,
bool ProjectTreeModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
{
Q_UNUSED(destinationParent)
Q_UNUSED(destinationChild)
qDebug() << sourceParent << sourceRow << count;
return false;
@@ -602,36 +607,53 @@ QVariant ProjectTreeModel::iconFor<Background>(const Background &entry) const
template<>
QVariant ProjectTreeModel::iconFor<Path>(const Path &entry) const
{
Q_UNUSED(entry)
return QPixmap{":/qtgameengine/icons/path-file.png"}.scaled(16, 16);
}
template<>
QVariant ProjectTreeModel::iconFor<Script>(const Script &entry) const
{
Q_UNUSED(entry)
return QPixmap{":/qtgameengine/icons/script-file.png"}.scaled(16, 16);
}
template<>
QVariant ProjectTreeModel::iconFor<Font>(const Font &entry) const
{
Q_UNUSED(entry)
return QPixmap{":/qtgameengine/icons/font-file.png"}.scaled(16, 16);
}
template<>
QVariant ProjectTreeModel::iconFor<TimeLine>(const TimeLine &entry) const
{
Q_UNUSED(entry)
return QPixmap{":/qtgameengine/icons/timeline-file.png"}.scaled(16, 16);
}
template<>
QVariant ProjectTreeModel::iconFor<Object>(const Object &entry) const
{
return QPixmap{":/qtgameengine/icons/object-file.png"}.scaled(16, 16);
if (m_project && !entry.spriteName.isEmpty())
{
const auto iter = std::find_if(std::cbegin(m_project->sprites), std::cend(m_project->sprites),
[&](const Sprite &sprite){ return sprite.name == entry.spriteName; });
if (iter == std::cend(m_project->sprites))
qWarning() << "sprite" << entry.spriteName << "not found";
else if (!iter->pixmaps.empty() && !iter->pixmaps.front().isNull())
return iter->pixmaps.front().scaled(16, 16, Qt::KeepAspectRatio);
}
QPixmap pixmap{16, 16};
pixmap.fill(Qt::white);
return pixmap;
}
template<>
QVariant ProjectTreeModel::iconFor<Room>(const Room &entry) const
{
Q_UNUSED(entry)
return QPixmap{":/qtgameengine/icons/room-file.png"}.scaled(16, 16);
}

View File

@@ -49,7 +49,10 @@ public:
Qt::DropActions supportedDragActions() const override;
Qt::DropActions supportedDropActions() const override;
ProjectContainer *project() { return m_project; }
const ProjectContainer *project() const { return m_project; }
void setProject(ProjectContainer *project);
NodeType nodeType(const QModelIndex &index) const;
template<typename T> QModelIndex rootFor() const;

View File

@@ -71,5 +71,10 @@
<file>icons/center.png</file>
<file>icons/grid.png</file>
<file>icons/constants.png</file>
<file>icons/add.png</file>
<file>icons/replace.png</file>
<file>icons/info.png</file>
<file>icons/merge.png</file>
<file>icons/sort.png</file>
</qresource>
</RCC>

View File

@@ -11,6 +11,7 @@ SpritesModel::SpritesModel(const std::vector<QPixmap> &pixmaps, QObject *parent)
int SpritesModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return m_pixmaps.size();
}

19
timelineactionsmodel.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "timelineactionsmodel.h"
TimelineActionsModel::TimelineActionsModel(QObject *parent) :
QAbstractListModel{parent}
{
}
int TimelineActionsModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return 0;
}
QVariant TimelineActionsModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(index)
Q_UNUSED(role)
return {};
}

14
timelineactionsmodel.h Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include <QAbstractListModel>
class TimelineActionsModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit TimelineActionsModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
};

19
timelinemomentsmodel.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "timelinemomentsmodel.h"
TimelineMomentsModel::TimelineMomentsModel(QObject *parent) :
QAbstractListModel{parent}
{
}
int TimelineMomentsModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return 0;
}
QVariant TimelineMomentsModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(index)
Q_UNUSED(role)
return {};
}

14
timelinemomentsmodel.h Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include <QAbstractListModel>
class TimelineMomentsModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit TimelineMomentsModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
};

View File

@@ -10,10 +10,13 @@ TriggersModel::TriggersModel(ProjectContainer &project, QObject *parent) :
int TriggersModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return 0;
}
QVariant TriggersModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(index)
Q_UNUSED(role)
return {};
}