diff --git a/app/app.pro b/app/app.pro index 1937bba52..a10ecb14e 100644 --- a/app/app.pro +++ b/app/app.pro @@ -49,7 +49,8 @@ HEADERS += \ pencilapplication.h \ exportmoviedialog.h \ app_util.h \ - errordialog.h + errordialog.h \ + imageseqdialog.h # popupcolorpalettewidget.h SOURCES += \ @@ -72,7 +73,8 @@ SOURCES += \ displayoptionwidget.cpp \ pencilapplication.cpp \ exportmoviedialog.cpp \ - errordialog.cpp + errordialog.cpp \ + imageseqdialog.cpp # spopupcolorpalettewidget.cpp FORMS += \ diff --git a/app/imageseqdialog.cpp b/app/imageseqdialog.cpp new file mode 100644 index 000000000..195cd23c8 --- /dev/null +++ b/app/imageseqdialog.cpp @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#include "imageseqdialog.h" +#include "editor.h" +#include "util.h" + +ImageSeqDialog::ImageSeqDialog(QWidget* parent ) : QDialog(parent) +{ + setWindowTitle(tr("Image Sequence Dialog")); + setFixedSize(300,180); +} + +void ImageSeqDialog::init() +{ + QVBoxLayout* lay = new QVBoxLayout; + QPushButton *okButton = new QPushButton(tr("OK")); + QPushButton *closeButton = new QPushButton(tr("Cancel")); + + QGroupBox* sequenceBox = new QGroupBox(); + QHBoxLayout* buttonsLayout = new QHBoxLayout; + + sequenceBoxLabel = new QLabel(this); + sequenceBoxLabel->setText(tr("Import an image every # frame")); + + mSequenceSpaceBox = new QSpinBox(this); + mSequenceSpaceBox->setRange(1,64); + mSequenceSpaceBox->setValue( 1 ); + + QGridLayout* gridLayout = new QGridLayout(); + sequenceBox->setLayout(gridLayout); + + connect(closeButton, &QAbstractButton::clicked, this, &QDialog::reject); + connect(okButton, &QAbstractButton::clicked, this, &QDialog::accept); + connect(mSequenceSpaceBox, SIGNAL(valueChanged(int)), this, SLOT(setSeqValue(int))); + + buttonsLayout->addWidget(okButton); + buttonsLayout->addWidget(closeButton); + + gridLayout->addWidget(sequenceBoxLabel, 0, 0); + gridLayout->addWidget(mSequenceSpaceBox, 1, 0); + + lay->addWidget(sequenceBox); + lay->addLayout(buttonsLayout); + + setLayout(lay); +} + +void ImageSeqDialog::setSeqValue(int number) +{ + SignalBlocker b1( mSequenceSpaceBox ); + mSequenceSpaceBox->setValue(number); +} + +void ImageSeqDialog::seqNumber(QString strImgFile, Editor *mEditor) +{ + int number = mSequenceSpaceBox->value(); + + mEditor->importImage( strImgFile ); + for (int i = 1; i < number; i++) + { + mEditor->scrubForward(); + } + +} diff --git a/app/imageseqdialog.h b/app/imageseqdialog.h new file mode 100644 index 000000000..06dbb9f38 --- /dev/null +++ b/app/imageseqdialog.h @@ -0,0 +1,32 @@ +#ifndef IMAGESEQDIALOG_H +#define IMAGESEQDIALOG_H + +#include + +class QSpinBox; +class QLabel; +class QGridLayout; +class QGroupBox; +class Editor; + +class ImageSeqDialog : public QDialog +{ + Q_OBJECT + +public: + ImageSeqDialog(QWidget *parent); + + void init(); + void seqNumber(QString strImgFile, Editor *mEditor); + +public slots: + void setSeqValue(int number); + +private: + void createIcons(); + + QSpinBox *mSequenceSpaceBox; + QLabel *sequenceBoxLabel; +}; + +#endif // IMAGESEQDIALOG_H diff --git a/app/mainwindow2.cpp b/app/mainwindow2.cpp index 1aef52689..8cedf15b3 100644 --- a/app/mainwindow2.cpp +++ b/app/mainwindow2.cpp @@ -60,6 +60,7 @@ GNU General Public License for more details. #include "preview.h" #include "timeline2.h" #include "errordialog.h" +#include "imageseqdialog.h" #include "colorbox.h" #include "util.h" @@ -694,6 +695,10 @@ void MainWindow2::importImageSequence() initialPath, tr("Images (*.png *.jpg *.jpeg *.tif *.tiff *.bmp)") ); + ImageSeqDialog* imageSeqDialog = new ImageSeqDialog( this ); + + imageSeqDialog->init(); + imageSeqDialog->exec(); for ( QString strImgFile : files ) { if ( strImgFile.endsWith( ".png" ) || @@ -703,8 +708,8 @@ void MainWindow2::importImageSequence() strImgFile.endsWith(".tiff") || strImgFile.endsWith( ".bmp" ) ) { - mEditor->importImage( strImgFile ); - mEditor->scrubForward(); + if (imageSeqDialog->result() == QDialog::Accepted) + imageSeqDialog->seqNumber(strImgFile, mEditor); } } } diff --git a/app/mainwindow2.h b/app/mainwindow2.h index 4fb95a1a8..c906307f1 100644 --- a/app/mainwindow2.h +++ b/app/mainwindow2.h @@ -39,6 +39,7 @@ class ColorBox; class RecentFileMenu; class Timeline2; class ActionCommands; +class ImageSeqDialog; #define PENCIL_WINDOW_TITLE QString("Pencil2D - Nightly Build %1").arg( __DATE__ )