Add ChangeImageSizeDialog

This commit is contained in:
2025-12-08 10:05:52 +01:00
parent c65cb9dc7b
commit be9aa14b53
6 changed files with 190 additions and 3 deletions
+3
View File
@@ -32,6 +32,7 @@ HEADERS += \
src/editor/dialogs/actions/movetowardsdialog.h \
src/editor/dialogs/actions/executecodedialog.h \
src/editor/dialogs/actions/speedverticaldialog.h \
src/editor/dialogs/changeimagesizedialog.h \
src/editor/dialogs/genericcodeeditordialog.h \
src/editor/dialogs/includedfilepropertiesdialog.h \
src/editor/dialogs/transparentbackgroundsettingsdialog.h \
@@ -109,6 +110,7 @@ SOURCES += \
src/editor/dialogs/actions/movefreedialog.cpp \
src/editor/dialogs/actions/movetowardsdialog.cpp \
src/editor/dialogs/actions/speedverticaldialog.cpp \
src/editor/dialogs/changeimagesizedialog.cpp \
src/editor/dialogs/genericcodeeditordialog.cpp \
src/editor/dialogs/includedfilepropertiesdialog.cpp \
src/editor/dialogs/transparentbackgroundsettingsdialog.cpp \
@@ -183,6 +185,7 @@ FORMS += \
src/editor/dialogs/actions/movefreedialog.ui \
src/editor/dialogs/actions/movetowardsdialog.ui \
src/editor/dialogs/actions/speedverticaldialog.ui \
src/editor/dialogs/changeimagesizedialog.ui \
src/editor/dialogs/includedfilepropertiesdialog.ui \
src/editor/dialogs/transparentbackgroundsettingsdialog.ui \
src/editor/mainwindow.ui \
@@ -0,0 +1,20 @@
#include "changeimagesizedialog.h"
#include "ui_changeimagesizedialog.h"
#include "editorguiutils.h"
ChangeImageSizeDialog::ChangeImageSizeDialog(QWidget *parent) :
QDialog{parent},
m_ui{std::make_unique<Ui::ChangeImageSizeDialog>()}
{
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowCloseButtonHint);
improveButtonBox(m_ui->buttonBox);
}
ChangeImageSizeDialog::~ChangeImageSizeDialog() = default;
@@ -0,0 +1,18 @@
#pragma once
#include <QDialog>
#include <memory>
namespace Ui { class ChangeImageSizeDialog; }
class ChangeImageSizeDialog : public QDialog
{
Q_OBJECT
public:
explicit ChangeImageSizeDialog(QWidget *parent = nullptr);
~ChangeImageSizeDialog() override;
private:
const std::unique_ptr<Ui::ChangeImageSizeDialog> m_ui;
};
+143
View File
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChangeImageSizeDialog</class>
<widget class="QDialog" name="ChangeImageSizeDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>336</width>
<height>332</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>The size of the image(s) is not equal to the current image. What should happen?</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxSize">
<property name="title">
<string>Size</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="radioButtonOriginalSize">
<property name="text">
<string>Keep original size</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonNewSize">
<property name="text">
<string>Use new size</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonMaximalSize">
<property name="text">
<string>Use maximal size</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxPlacement">
<property name="title">
<string>Placement</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="radioButtonPlaceTopLeft">
<property name="text">
<string>Place at left-top</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonPlaceCenter">
<property name="text">
<string>Place in center</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStretch">
<property name="text">
<string>Stretch</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ChangeImageSizeDialog</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>ChangeImageSizeDialog</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>
@@ -2,7 +2,6 @@
#include "ui_createspritedialog.h"
#include <QMessageBox>
#include <QPushButton>
#include "editorguiutils.h"
+6 -2
View File
@@ -9,6 +9,7 @@
#include "createspritedialog.h"
#include "imageeditordialog.h"
#include "imagehelpers.h"
#include "changeimagesizedialog.h"
EditSpriteDialog::EditSpriteDialog(const std::vector<QPixmap> &pixmaps, const QString &spriteName,
EditorSettings &settings, QWidget *parent) :
@@ -176,8 +177,11 @@ void EditSpriteDialog::addFromFile()
if (!m_model->empty() && m_model->front().size() != pixmap.size())
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
return;
ChangeImageSizeDialog dialog{this};
if (dialog.exec() == QDialog::Accepted)
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
}
else
{