Commit cae87507 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add API to KisImportExportFilter to retrieve the last used configuration

parent d774830a
......@@ -157,6 +157,11 @@ KisPropertiesConfigurationSP KisImportExportFilter::defaultConfiguration(const Q
return 0;
}
KisPropertiesConfigurationSP KisImportExportFilter::lastSavedConfiguration(const QByteArray &from, const QByteArray &to) const
{
return defaultConfiguration(from, to);
}
KisConfigWidget *KisImportExportFilter::createConfigurationWidget(QWidget *, const QByteArray &from, const QByteArray &to) const
{
return 0;
......
......@@ -112,10 +112,18 @@ public:
* @brief defaultConfiguration defines the default settings for the given import export filter
* @param from The mimetype of the source file/document
* @param to The mimetype of the destination file/document
* @return a serializable KisPropertiesConfiguration object gthat
* @return a serializable KisPropertiesConfiguration object
*/
virtual KisPropertiesConfigurationSP defaultConfiguration(const QByteArray& from = "", const QByteArray& to = "") const;
/**
* @brief lastSavedConfiguration return the last saved configuration for this filter
* @param from The mimetype of the source file/document
* @param to The mimetype of the destination file/document
* @return a serializable KisPropertiesConfiguration object
*/
virtual KisPropertiesConfigurationSP lastSavedConfiguration(const QByteArray &from = "", const QByteArray &to = "") const;
/**
* @brief createConfigurationWidget creates a widget that can be used to define the settings for a given import/export filter
* @param parent the ownder of the widget; the caller is responsible for deleting
......
......@@ -78,7 +78,6 @@ void AnimaterionRenderer::slotRenderAnimation()
cfg->setProperty("last_frame", image->animationInterface()->playbackRange().end());
dlgAnimaterionRenderer.setSequenceConfiguration(cfg);
if (dlgAnimaterionRenderer.exec() == QDialog::Accepted) {
KisPropertiesConfigurationSP sequencecfg = dlgAnimaterionRenderer.getSequenceConfiguration();
kisConfig.setExportConfiguration("IMAGESEQUENCE", *sequencecfg.data());
......
......@@ -41,7 +41,7 @@
DlgAnimaterionRenderer::DlgAnimaterionRenderer(KisImageWSP image, QWidget *parent)
: KoDialog(parent)
, m_image(image)
, m_sequenceConfigWidget(0)
, m_frameExportConfigurationWidget(0)
{
setCaption(i18n("Render Animation"));
setButtons(Ok | Cancel);
......@@ -153,6 +153,14 @@ void DlgAnimaterionRenderer::setSequenceConfiguration(KisPropertiesConfiguration
}
}
KisPropertiesConfigurationSP DlgAnimaterionRenderer::getFrameExportConfiguration() const
{
if (m_frameExportConfigurationWidget) {
return m_frameExportConfigurationWidget->configuration();
}
return 0;
}
bool DlgAnimaterionRenderer::renderToVideo() const
{
return m_page->grpRender->isChecked();
......@@ -217,10 +225,10 @@ void DlgAnimaterionRenderer::sequenceMimeTypeSelected(int index)
{
qDebug() << ">>>>" << m_page->cmbMimetype->currentText() << m_page->cmbMimetype->currentIndex() << index;
if (m_sequenceConfigWidget) {
m_sequenceConfigLayout->removeWidget(m_sequenceConfigWidget);
delete m_sequenceConfigWidget;
m_sequenceConfigWidget = 0;
if (m_frameExportConfigurationWidget) {
m_sequenceConfigLayout->removeWidget(m_frameExportConfigurationWidget);
delete m_frameExportConfigurationWidget;
m_frameExportConfigurationWidget = 0;
}
QString mimetype = m_page->cmbMimetype->itemData(index).toString();
KoJsonTrader trader;
......@@ -248,13 +256,13 @@ void DlgAnimaterionRenderer::sequenceMimeTypeSelected(int index)
continue;
}
m_sequenceConfigWidget = filter->createConfigurationWidget(m_page->grpExportOptions, KisDocument::nativeFormatMimeType(), mimetype.toLatin1());
qDebug() << ">>>>" << loader->fileName() << mimetype << "has widget:" << m_sequenceConfigWidget;
if (m_sequenceConfigWidget) {
m_sequenceConfigLayout->addWidget(m_sequenceConfigWidget);
m_frameExportConfigurationWidget = filter->createConfigurationWidget(m_page->grpExportOptions, KisDocument::nativeFormatMimeType(), mimetype.toLatin1());
qDebug() << ">>>>" << loader->fileName() << mimetype << "has widget:" << m_frameExportConfigurationWidget;
if (m_frameExportConfigurationWidget) {
m_sequenceConfigLayout->addWidget(m_frameExportConfigurationWidget);
// XXX: Use the saved config here?
m_sequenceConfigWidget->setConfiguration(filter->defaultConfiguration());
m_sequenceConfigWidget->show();
m_frameExportConfigurationWidget->setConfiguration(filter->defaultConfiguration());
m_frameExportConfigurationWidget->show();
resize(sizeHint());
}
......
......@@ -55,6 +55,8 @@ public:
KisPropertiesConfigurationSP getSequenceConfiguration() const;
void setSequenceConfiguration(KisPropertiesConfigurationSP cfg);
KisPropertiesConfigurationSP getFrameExportConfiguration() const;
bool renderToVideo() const;
KisPropertiesConfigurationSP getVideoConfiguration() const;
......@@ -76,7 +78,7 @@ private:
QList<QSharedPointer<KisImportExportFilter>> m_filters;
QList<QWidget> m_configWidgets;
QHBoxLayout *m_sequenceConfigLayout;
KisConfigWidget *m_sequenceConfigWidget;
KisConfigWidget *m_frameExportConfigurationWidget;
};
#endif // DLG_ANIMATIONRENDERERIMAGE
......@@ -125,14 +125,13 @@ KisImportExportFilter::ConversionStatus KisPNGExport::convert(const QByteArray&
KisConfigWidget *wdg = createConfigurationWidget(kdb, from, to);
QString filterConfig = KisConfig().exportConfiguration("PNG");
// If a configuration object was passed to the convert method, we use that, otherwise we load from the settings
KisPropertiesConfigurationSP cfg(new KisPropertiesConfiguration());
if (configuration) {
cfg->fromXML(configuration->toXML());
}
else {
cfg->fromXML(filterConfig);
cfg = lastSavedConfiguration(from, to);
}
cfg->setProperty("ColorModelID", cs->colorModelId().id());
......@@ -221,6 +220,14 @@ KisPropertiesConfigurationSP KisPNGExport::defaultConfiguration(const QByteArray
return cfg;
}
KisPropertiesConfigurationSP KisPNGExport::lastSavedConfiguration(const QByteArray &/*from*/, const QByteArray &/*to*/) const
{
QString filterConfig = KisConfig().exportConfiguration("PNG");
KisPropertiesConfigurationSP cfg(new KisPropertiesConfiguration());
cfg->fromXML(filterConfig);
return cfg;
}
KisConfigWidget *KisPNGExport::createConfigurationWidget(QWidget *parent, const QByteArray &, const QByteArray &) const
{
return new KisWdgOptionsPNG(parent);
......
......@@ -55,6 +55,7 @@ public:
virtual KisImportExportFilter::ConversionStatus convert(const QByteArray& from, const QByteArray& to, KisPropertiesConfigurationSP configuration = 0);
KisPropertiesConfigurationSP defaultConfiguration(const QByteArray& from = "", const QByteArray& to = "") const;
KisPropertiesConfigurationSP lastSavedConfiguration(const QByteArray &from = "", const QByteArray &to = "") const;
KisConfigWidget *createConfigurationWidget(QWidget *parent, const QByteArray& from = "", const QByteArray& to = "") const;
};
......
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