Skip to content

Commit

Permalink
Merge pull request #621 from CandyFace/#620-adjustable-frame-spacing
Browse files Browse the repository at this point in the history
Added dialog to adjust frame spacing for imported image sequence
  • Loading branch information
chchwy committed Mar 13, 2017
2 parents 3235fa2 + 6bdad7f commit 384aa9d
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/app.pro
Expand Up @@ -49,7 +49,8 @@ HEADERS += \
pencilapplication.h \
exportmoviedialog.h \
app_util.h \
errordialog.h
errordialog.h \
imageseqdialog.h
# popupcolorpalettewidget.h

SOURCES += \
Expand All @@ -72,7 +73,8 @@ SOURCES += \
displayoptionwidget.cpp \
pencilapplication.cpp \
exportmoviedialog.cpp \
errordialog.cpp
errordialog.cpp \
imageseqdialog.cpp
# spopupcolorpalettewidget.cpp

FORMS += \
Expand Down
67 changes: 67 additions & 0 deletions app/imageseqdialog.cpp
@@ -0,0 +1,67 @@
#include <QtWidgets>
#include <QSpinBox>
#include <QGridLayout>
#include <QGroupBox>

#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();
}

}
32 changes: 32 additions & 0 deletions app/imageseqdialog.h
@@ -0,0 +1,32 @@
#ifndef IMAGESEQDIALOG_H
#define IMAGESEQDIALOG_H

#include <QDialog>

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
9 changes: 7 additions & 2 deletions app/mainwindow2.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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" ) ||
Expand All @@ -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);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/mainwindow2.h
Expand Up @@ -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__ )

Expand Down

0 comments on commit 384aa9d

Please sign in to comment.