Commit cb683563 authored by Scott Petrovic's avatar Scott Petrovic

updated the UI on Render Animation so the options change by export type

parent b0ad3614
......@@ -88,6 +88,9 @@ void AnimaterionRenderer::slotRenderAnimation()
cfg->fromXML(kisConfig.exportConfiguration("FFMPEG_CONFIG"));
dlgAnimationRenderer.setEncoderConfiguration(cfg);
// update the UI to show the selected export options
dlgAnimationRenderer.updateExportUIOptions();
if (dlgAnimationRenderer.exec() == QDialog::Accepted) {
KisPropertiesConfigurationSP sequenceConfig = dlgAnimationRenderer.getSequenceConfiguration();
......
......@@ -65,6 +65,7 @@ DlgAnimationRenderer::DlgAnimationRenderer(KisDocument *doc, QWidget *parent)
m_page = new WdgAnimaterionRenderer(this);
m_page->layout()->setMargin(0);
m_page->dirRequester->setMode(KoFileDialog::OpenDirectory);
QString lastLocation = cfg.readEntry<QString>("AnimationRenderer/last_sequence_export_location", QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
m_page->dirRequester->setFileName(lastLocation);
......@@ -97,7 +98,6 @@ DlgAnimationRenderer::DlgAnimationRenderer(KisDocument *doc, QWidget *parent)
}
setMainWidget(m_page);
resize(m_page->sizeHint());
KoJsonTrader trader;
QList<QPluginLoader *>list = trader.query("Krita/AnimationExporter", "");
......@@ -139,7 +139,6 @@ DlgAnimationRenderer::DlgAnimationRenderer(KisDocument *doc, QWidget *parent)
qDeleteAll(list);
connect(m_page->grpRender, SIGNAL(toggled(bool)), this, SLOT(toggleSequenceType(bool)));
connect(m_page->bnExportOptions, SIGNAL(clicked()), this, SLOT(sequenceMimeTypeSelected()));
connect(m_page->bnRenderOptions, SIGNAL(clicked()), this, SLOT(selectRenderOptions()));
......@@ -147,22 +146,28 @@ DlgAnimationRenderer::DlgAnimationRenderer(KisDocument *doc, QWidget *parent)
m_page->ffmpegLocation->setMode(KoFileDialog::OpenFile);
connect(m_page->ffmpegLocation, SIGNAL(fileSelected(QString)), this, SLOT(ffmpegLocationChanged(QString)));
m_page->grpRender->setChecked(cfg.readEntry<bool>("AnimationRenderer/render_animation", false));
m_page->chkDeleteSequence->setChecked(cfg.readEntry<bool>("AnimationRenderer/delete_sequence", false));
m_page->cmbRenderType->setCurrentIndex(cfg.readEntry<int>("AnimationRenderer/render_type", 0));
connect(m_page->shouldExportOnlyImageSequence, SIGNAL(toggled(bool)), this, SLOT(slotExportTypeChanged()));
connect(m_page->shouldExportOnlyVideo, SIGNAL(toggled(bool)), this, SLOT(slotExportTypeChanged()));
connect(m_page->shouldExportAll, SIGNAL(toggled(bool)), this, SLOT(slotExportTypeChanged()));
updateExportUIOptions();
// connect and cold init
connect(m_page->cmbRenderType, SIGNAL(currentIndexChanged(int)), this, SLOT(selectRenderType(int)));
selectRenderType(m_page->cmbRenderType->currentIndex());
resize(m_page->sizeHint());
}
DlgAnimationRenderer::~DlgAnimationRenderer()
{
KisConfig cfg;
cfg.writeEntry<bool>("AnimationRenderer/render_animation", m_page->grpRender->isChecked());
cfg.writeEntry<QString>("AnimationRenderer/last_sequence_export_location", m_page->dirRequester->fileName());
cfg.writeEntry<int>("AnimationRenderer/render_type", m_page->cmbRenderType->currentIndex());
cfg.writeEntry<bool>("AnimationRenderer/delete_sequence", m_page->chkDeleteSequence->isChecked());
cfg.setCustomFFMpegPath(m_page->ffmpegLocation->fileName());
if (m_encoderConfigWidget) {
......@@ -230,16 +235,13 @@ KisPropertiesConfigurationSP DlgAnimationRenderer::getFrameExportConfiguration()
return 0;
}
bool DlgAnimationRenderer::renderToVideo() const
{
return m_page->grpRender->isChecked();
}
KisPropertiesConfigurationSP DlgAnimationRenderer::getVideoConfiguration() const
{
if (!m_page->grpRender->isChecked()) {
// don't continue if we are only exporting image sequence
if (m_page->shouldExportOnlyImageSequence->isChecked()) {
return 0;
}
KisPropertiesConfigurationSP cfg = new KisPropertiesConfiguration();
QString filename = m_page->videoFilename->fileName();
if (QFileInfo(filename).completeSuffix().isEmpty()) {
......@@ -247,10 +249,15 @@ KisPropertiesConfigurationSP DlgAnimationRenderer::getVideoConfiguration() const
filename += "." + KisMimeDatabase::suffixesForMimeType(mimetype).first();
}
cfg->setProperty("filename", filename);
cfg->setProperty("delete_sequence", m_page->chkDeleteSequence->isChecked());
cfg->setProperty("first_frame", m_page->intStart->value());
cfg->setProperty("last_frame", m_page->intEnd->value());
cfg->setProperty("sequence_start", m_page->sequenceStart->value());
// delete image sequence if we are only exporting out video
cfg->setProperty("delete_sequence", m_page->shouldExportOnlyVideo->isChecked());
return cfg;
}
......@@ -260,9 +267,11 @@ void DlgAnimationRenderer::setVideoConfiguration(KisPropertiesConfigurationSP /*
KisPropertiesConfigurationSP DlgAnimationRenderer::getEncoderConfiguration() const
{
if (!m_page->grpRender->isChecked()) {
// don't continue if we are only exporting image sequence
if (m_page->shouldExportOnlyImageSequence->isChecked()) {
return 0;
}
KisPropertiesConfigurationSP cfg = new KisPropertiesConfiguration();
if (m_encoderConfigWidget) {
cfg = m_encoderConfigWidget->configuration();
......@@ -337,17 +346,6 @@ void DlgAnimationRenderer::selectRenderOptions()
}
void DlgAnimationRenderer::toggleSequenceType(bool toggle)
{
m_page->cmbMimetype->setEnabled(!toggle);
for (int i = 0; i < m_page->cmbMimetype->count(); ++i) {
if (m_page->cmbMimetype->itemData(i).toString() == "image/png") {
m_page->cmbMimetype->setCurrentIndex(i);
break;
}
}
}
void DlgAnimationRenderer::sequenceMimeTypeSelected()
{
int index = m_page->cmbMimetype->currentIndex();
......@@ -382,9 +380,24 @@ void DlgAnimationRenderer::ffmpegLocationChanged(const QString &s)
cfg.setCustomFFMpegPath(s);
}
void DlgAnimationRenderer::updateExportUIOptions() {
KisConfig cfg;
// read in what type to export to. Defaults to image sequence only
QString exportType = cfg.readEntry<QString>("AnimationRenderer/export_type", "ImageSequence");
if (exportType == "ImageSequence") {
m_page->shouldExportOnlyImageSequence->setChecked(true);
} else if (exportType == "Video") {
m_page->shouldExportOnlyVideo->setChecked(true);
} else {
m_page->shouldExportAll->setChecked(true); // export to both
}
}
void DlgAnimationRenderer::slotButtonClicked(int button)
{
if (button == KoDialog::Ok && m_page->grpRender->isChecked()) {
if (button == KoDialog::Ok && !m_page->shouldExportOnlyImageSequence->isChecked()) {
QString ffmpeg = m_page->ffmpegLocation->fileName();
if (m_page->videoFilename->fileName().isEmpty()) {
QMessageBox::warning(this, i18nc("@title:window", "Krita"), i18n("Please enter a file name to render to."));
......@@ -441,3 +454,53 @@ QString DlgAnimationRenderer::findFFMpeg()
return result;
}
void DlgAnimationRenderer::slotExportTypeChanged()
{
KisConfig cfg;
// if a video format needs to be outputted
if (m_page->shouldExportAll->isChecked() || m_page->shouldExportOnlyVideo->isChecked()) {
// videos always uses PNG for creating video, so disable the ability to change the format
m_page->cmbMimetype->setEnabled(false);
for (int i = 0; i < m_page->cmbMimetype->count(); ++i) {
if (m_page->cmbMimetype->itemData(i).toString() == "image/png") {
m_page->cmbMimetype->setCurrentIndex(i);
break;
}
}
}
// if only exporting video
if (m_page->shouldExportOnlyVideo) {
m_page->cmbMimetype->setEnabled(false); // allow to change image format
m_page->imageSequenceOptionsGroup->setVisible(false);
m_page->videoOptionsGroup->setVisible(false); //shrinks the horizontal space temporarily to help resize() work
m_page->videoOptionsGroup->setVisible(true);
cfg.writeEntry<QString>("AnimationRenderer/export_type", "Video");
}
// if only an image sequence needs to be output
if (m_page->shouldExportOnlyImageSequence->isChecked()) {
m_page->cmbMimetype->setEnabled(true); // allow to change image format
m_page->videoOptionsGroup->setVisible(false);
m_page->imageSequenceOptionsGroup->setVisible(true);
cfg.writeEntry<QString>("AnimationRenderer/export_type", "ImageSequence");
}
// show all options
if (m_page->shouldExportAll->isChecked() ) {
m_page->imageSequenceOptionsGroup->setVisible(true);
m_page->videoOptionsGroup->setVisible(true);
cfg.writeEntry<QString>("AnimationRenderer/export_type", "VideoAndImageSequence");
}
// for the resize to work as expected, try to hide elements first before displaying other ones.
// if the widget gets bigger at any point, the resize will use that, even if elements are hidden later to make it smaller
resize(m_page->sizeHint());
}
......@@ -58,8 +58,6 @@ public:
KisPropertiesConfigurationSP getFrameExportConfiguration() const;
bool renderToVideo() const;
KisPropertiesConfigurationSP getVideoConfiguration() const;
void setVideoConfiguration(KisPropertiesConfigurationSP cfg);
......@@ -68,14 +66,19 @@ public:
QSharedPointer<KisImportExportFilter> encoderFilter() const;
// fires when the render animation action is called. makes sure the correct export type is selected for the UI
void updateExportUIOptions();
private Q_SLOTS:
void selectRenderType(int i);
void selectRenderOptions();
void toggleSequenceType(bool toggle);
void sequenceMimeTypeSelected();
void ffmpegLocationChanged(const QString&);
void slotExportTypeChanged();
protected Q_SLOTS:
void slotButtonClicked(int button);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment