Commit a5091191 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Show the export configuration widget

Now all we need to do is fix all other export filters other than
png to create an export widget, a default configuration setting
and use them internally, too, instead of hard-coded dialogs in
the export method.

Note: we might also need a currentConfiguration() method in
KisImportExportFilter. We'll need to pass the configuration to
KisImportExportManager all the way down to the actual filter.
And when the split-up is really done, we can make it possible
to pass a filter config file on the command-line for the conversion
system.
parent dcfd3fc9
......@@ -159,6 +159,7 @@ KisPropertiesConfigurationSP KisImportExportFilter::defaultConfiguration(const Q
KisConfigWidget *KisImportExportFilter::createConfigurationWidget(QWidget *, const QByteArray &from, const QByteArray &to) const
{
qDebug() << "KisImportExportFilter::createConfigurationWidget()";
return 0;
}
......
......@@ -114,7 +114,7 @@ public:
* @param to The mimetype of the destination file/document
* @return a serializable KisPropertiesConfiguration object gthat
*/
KisPropertiesConfigurationSP defaultConfiguration(const QByteArray& from = "", const QByteArray& to = "") const;
virtual KisPropertiesConfigurationSP defaultConfiguration(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
......@@ -124,7 +124,7 @@ public:
*
* @return the widget
*/
KisConfigWidget *createConfigurationWidget(QWidget *parent, const QByteArray& from = "", const QByteArray& to = "") const;
virtual KisConfigWidget *createConfigurationWidget(QWidget *parent, const QByteArray& from = "", const QByteArray& to = "") const;
Q_SIGNALS:
......
......@@ -34,10 +34,14 @@
#include <kis_image_animation_interface.h>
#include <kis_time_range.h>
#include <KisImportExportManager.h>
#include <kis_config_widget.h>
#include <KisDocument.h>
#include <QHBoxLayout>
DlgAnimaterionRenderer::DlgAnimaterionRenderer(KisImageWSP image, QWidget *parent)
: KoDialog(parent)
, m_image(image)
, m_sequenceConfigWidget(0)
{
setCaption(i18n("Render Animation"));
setButtons(Ok | Cancel);
......@@ -56,6 +60,8 @@ DlgAnimaterionRenderer::DlgAnimaterionRenderer(KisImageWSP image, QWidget *paren
m_page->intEnd->setMaximum(image->animationInterface()->fullClipRange().end());
m_page->intEnd->setValue(image->animationInterface()->playbackRange().end());
m_sequenceConfigLayout = new QHBoxLayout(m_page->grpExportOptions);
QStringList mimes = KisImportExportManager::mimeFilter(KisImportExportManager::Export);
mimes.sort();
Q_FOREACH(const QString &mime, mimes) {
......@@ -107,7 +113,10 @@ DlgAnimaterionRenderer::DlgAnimaterionRenderer(KisImageWSP image, QWidget *paren
}
connect(m_page->cmbRenderType, SIGNAL(activated(int)), this, SLOT(selectRenderType(int)));
selectRenderType(m_page->cmbRenderType->currentIndex());
connect(m_page->grpRender, SIGNAL(toggled(bool)), this, SLOT(toggleSequenceType(bool)));
connect(m_page->cmbMimetype, SIGNAL(activated(int)), this, SLOT(sequenceMimeTypeSelected(int)));
sequenceMimeTypeSelected(m_page->cmbMimetype->currentIndex());
}
DlgAnimaterionRenderer::~DlgAnimaterionRenderer()
......@@ -127,7 +136,7 @@ KisPropertiesConfigurationSP DlgAnimaterionRenderer::getSequenceConfiguration()
return cfg;
}
void DlgAnimaterionRenderer::setSequenceConfiguration(KisPropertiesConfigurationSP cfg) const
void DlgAnimaterionRenderer::setSequenceConfiguration(KisPropertiesConfigurationSP cfg)
{
m_page->txtBasename->setText(cfg->getString("basename", "frame"));
m_page->dirRequester->setFileName(cfg->getString("directory", QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)));
......@@ -138,6 +147,7 @@ void DlgAnimaterionRenderer::setSequenceConfiguration(KisPropertiesConfiguration
for (int i = 0; i < m_page->cmbMimetype->count(); ++i) {
if (m_page->cmbMimetype->itemData(i).toString() == mimetype) {
m_page->cmbMimetype->setCurrentIndex(i);
sequenceMimeTypeSelected(i);
break;
}
}
......@@ -159,7 +169,7 @@ KisPropertiesConfigurationSP DlgAnimaterionRenderer::getVideoConfiguration() con
return cfg;
}
void DlgAnimaterionRenderer::setVideoConfiguration(KisPropertiesConfigurationSP cfg) const
void DlgAnimaterionRenderer::setVideoConfiguration(KisPropertiesConfigurationSP cfg)
{
}
......@@ -173,7 +183,7 @@ KisPropertiesConfigurationSP DlgAnimaterionRenderer::getencoderConfiguration() c
return cfg;
}
void DlgAnimaterionRenderer::getencoderConfiguration(KisPropertiesConfigurationSP cfg) const
void DlgAnimaterionRenderer::getencoderConfiguration(KisPropertiesConfigurationSP cfg)
{
}
......@@ -202,3 +212,55 @@ void DlgAnimaterionRenderer::toggleSequenceType(bool toggle)
}
}
}
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;
}
QString mimetype = m_page->cmbMimetype->itemData(index).toString();
KoJsonTrader trader;
QList<QPluginLoader *>list = trader.query("Krita/FileFilter", "");
Q_FOREACH(QPluginLoader *loader, list) {
QJsonObject json = loader->metaData().value("MetaData").toObject();
if (json.value("X-KDE-Export").toString().split(",").contains(mimetype)) {
KLibFactory *factory = qobject_cast<KLibFactory *>(loader->instance());
if (!factory) {
warnUI << loader->errorString();
continue;
}
QObject* obj = factory->create<KisImportExportFilter>(0);
if (!obj || !obj->inherits("KisImportExportFilter")) {
delete obj;
continue;
}
KisImportExportFilter *filter(static_cast<KisImportExportFilter*>(obj));
if (!filter) {
delete obj;
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);
// XXX: Use the saved config here?
m_sequenceConfigWidget->setConfiguration(filter->defaultConfiguration());
m_sequenceConfigWidget->show();
resize(sizeHint());
}
delete filter;
break;
}
}
}
......@@ -27,6 +27,8 @@
#include <kis_types.h>
class KisImportExportFilter;
class KisConfigWidget;
class QHBoxLayout;
class WdgAnimaterionRenderer : public QWidget, public Ui::WdgAnimaterionRenderer
{
......@@ -51,20 +53,21 @@ public:
~DlgAnimaterionRenderer();
KisPropertiesConfigurationSP getSequenceConfiguration() const;
void setSequenceConfiguration(KisPropertiesConfigurationSP cfg) const;
void setSequenceConfiguration(KisPropertiesConfigurationSP cfg);
bool renderToVideo() const;
KisPropertiesConfigurationSP getVideoConfiguration() const;
void setVideoConfiguration(KisPropertiesConfigurationSP cfg) const;
void setVideoConfiguration(KisPropertiesConfigurationSP cfg);
KisPropertiesConfigurationSP getencoderConfiguration() const;
void getencoderConfiguration(KisPropertiesConfigurationSP cfg) const;
void getencoderConfiguration(KisPropertiesConfigurationSP cfg);
private Q_SLOTS:
void selectRenderType(int renderType);
void toggleSequenceType(bool toggle);
void sequenceMimeTypeSelected(int index);
private:
......@@ -72,6 +75,8 @@ private:
WdgAnimaterionRenderer *m_page;
QList<QSharedPointer<KisImportExportFilter>> m_filters;
QList<QWidget> m_configWidgets;
QHBoxLayout *m_sequenceConfigLayout;
KisConfigWidget *m_sequenceConfigWidget;
};
#endif // DLG_ANIMATIONRENDERERIMAGE
......@@ -223,6 +223,7 @@ KisPropertiesConfigurationSP KisPNGExport::defaultConfiguration(const QByteArray
KisConfigWidget *KisPNGExport::createConfigurationWidget(QWidget *parent, const QByteArray &, const QByteArray &) const
{
qDebug() << "KisPNGExport::createConfigurationWidget()";
return new KisWdgOptionsPNG(parent);
}
......
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