Commit 08e1ed1b authored by Jouni Pentikäinen's avatar Jouni Pentikäinen

Allow importing animation frames through a simple file dialog

parent 65a15c6f
......@@ -18,6 +18,7 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<Action name="file_import_file"/>
<Action name="file_export_file"/>
<Action name="file_export_pdf"/>
<Action name="file_import_animation"/>
<Action name="file_export_animation"/>
<Separator/>
<Action name="save_incremental_version"/>
......
......@@ -118,6 +118,19 @@
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="file_import_animation">
<icon></icon>
<text>Import animation frames...</text>
<whatsThis></whatsThis>
<toolTip>Import animation frames</toolTip>
<iconText>Import animation frames</iconText>
<activationFlags>1</activationFlags>
<activationConditions>0</activationConditions>
<shortcut></shortcut>
<defaultShortcut></defaultShortcut>
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="file_export_animation">
<icon></icon>
<text>Expor&amp;t animation...</text>
......
......@@ -118,6 +118,7 @@
#include "kis_action_manager.h"
#include "thememanager.h"
#include "kis_resource_server_provider.h"
#include "kis_animation_importer.h"
#ifdef HAVE_OPENGL
#include "kis_animation_exporter.h"
#endif
......@@ -219,6 +220,7 @@ public:
KisAction *printAction;
KisAction *printActionPreview;
KisAction *exportPdf;
KisAction *importAnimation;
#ifdef HAVE_OPENGL
KisAction *exportAnimation;
#endif
......@@ -748,6 +750,22 @@ void KisMainWindow::addViewAndNotifyLoadingCompleted(KisDocument *document)
emit guiLoadingFinished();
}
QStringList KisMainWindow::showOpenFileDialog()
{
KoFileDialog dialog(this, KoFileDialog::ImportFiles, "OpenDocument");
dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
dialog.setMimeTypeFilters(KisImportExportManager::mimeFilter(KIS_MIME_TYPE,
KisImportExportManager::Import,
KisDocumentEntry::extraNativeMimeTypes()));
QStringList filters = dialog.nameFilters();
filters << i18n("All files (*.*)");
dialog.setNameFilters(filters);
dialog.setHideNameFilterDetailsOption();
dialog.setCaption(isImporting() ? i18n("Import Images") : i18n("Open Images"));
return dialog.filenames();
}
// Separate from openDocument to handle async loading (remote URLs)
void KisMainWindow::slotLoadCompleted()
{
......@@ -1198,19 +1216,7 @@ void KisMainWindow::slotFileNew()
void KisMainWindow::slotFileOpen()
{
QStringList urls;
KoFileDialog dialog(this, KoFileDialog::ImportFiles, "OpenDocument");
dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
dialog.setMimeTypeFilters(KisImportExportManager::mimeFilter(KIS_MIME_TYPE,
KisImportExportManager::Import,
KisDocumentEntry::extraNativeMimeTypes()));
QStringList filters = dialog.nameFilters();
filters << i18n("All files (*.*)");
dialog.setNameFilters(filters);
dialog.setHideNameFilterDetailsOption();
dialog.setCaption(isImporting() ? i18n("Import Images") : i18n("Open Images"));
urls = dialog.filenames();
QStringList urls = showOpenFileDialog();
if (urls.isEmpty())
return;
......@@ -1480,6 +1486,19 @@ KisPrintJob* KisMainWindow::exportToPdf(KoPageLayout pageLayout, QString pdfFile
return printJob;
}
void KisMainWindow::importAnimation()
{
if (!activeView()) return;
KisDocument *document = activeView()->document();
if (!document) return;
KisAnimationImporterUI importer(this);
importer.importSequence(document);
activeView()->canvasBase()->refetchDataFromImage();
}
void KisMainWindow::exportAnimation()
{
#ifdef HAVE_OPENGL
......@@ -2093,6 +2112,10 @@ void KisMainWindow::createActions()
d->exportPdf = actionManager->createAction("file_export_pdf");
connect(d->exportPdf, SIGNAL(triggered()), this, SLOT(exportToPdf()));
d->importAnimation = actionManager->createAction("file_import_animation");
connect(d->importAnimation, SIGNAL(triggered()), this, SLOT(importAnimation()));
#ifdef HAVE_OPENGL
d->exportAnimation = actionManager->createAction("file_export_animation");
connect(d->exportAnimation, SIGNAL(triggered()), this, SLOT(exportAnimation()));
......
......@@ -140,6 +140,8 @@ public:
void addViewAndNotifyLoadingCompleted(KisDocument *document);
QStringList showOpenFileDialog();
Q_SIGNALS:
/**
......@@ -257,6 +259,7 @@ private Q_SLOTS:
KisPrintJob* exportToPdf(KoPageLayout pageLayout, QString pdfFileName = QString());
void importAnimation();
void exportAnimation();
/**
......
......@@ -18,6 +18,8 @@
#include "kis_animation_importer.h"
#include "KisMainWindow.h"
#include "KoFileDialog.h"
#include "KoColorSpace.h"
#include "KisPart.h"
#include "KisDocument.h"
......@@ -28,6 +30,36 @@
#include "kis_raster_keyframe_channel.h"
#include "commands/kis_image_layer_add_command.h"
struct KisAnimationImporterUI::Private
{
KisMainWindow *mainWindow;
Private(KisMainWindow *parent)
: mainWindow(parent)
{}
};
KisAnimationImporterUI::KisAnimationImporterUI(KisMainWindow *mainWindow)
: m_d(new Private(mainWindow))
{
}
KisAnimationImporterUI::~KisAnimationImporterUI()
{}
void KisAnimationImporterUI::importSequence(KisDocument *document)
{
QStringList urls = m_d->mainWindow->showOpenFileDialog();
if (urls.isEmpty()) return;
urls.sort();
KisAnimationImporter importer(document->image());
importer.import(urls, 0, 1);
}
struct KisAnimationImporter::Private
{
KisImageSP image;
......
......@@ -23,6 +23,23 @@
#include "kritaui_export.h"
class KisDocument;
class KisMainWindow;
class KRITAUI_EXPORT KisAnimationImporterUI : public QObject
{
Q_OBJECT
public:
KisAnimationImporterUI(KisMainWindow *parent);
~KisAnimationImporterUI();
void importSequence(KisDocument *document);
private:
class Private;
QScopedPointer<Private> m_d;
};
class KRITAUI_EXPORT KisAnimationImporter : public QObject
{
......
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