Krita Source Code Documentation
Loading...
Searching...
No Matches
KisAnimationRenderingOptions.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
8
9#include <QStandardPaths>
10#include <QFileInfo>
11
12#include <KisFileUtils.h>
13
14#ifdef Q_OS_ANDROID
15#include <QJsonDocument>
16#endif
17
22
23#ifndef Q_OS_ANDROID
24QString KisAnimationRenderingOptions::resolveAbsoluteDocumentFilePath(const QString &documentPath) const
25{
26 return
27 !documentPath.isEmpty() ?
28 documentPath :
29 QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
30}
31
32QString KisAnimationRenderingOptions::resolveAbsoluteVideoFilePath(const QString &documentPath) const
33{
34 const QString basePath = resolveAbsoluteDocumentFilePath(documentPath);
36}
37
38QString KisAnimationRenderingOptions::resolveAbsoluteFramesDirectory(const QString &documentPath) const
39{
41 return QFileInfo(resolveAbsoluteVideoFilePath()).absolutePath();
42 }
43
44 const QString basePath = resolveAbsoluteDocumentFilePath(documentPath);
46}
47
52
57#endif
58
79
81{
83
84 config->setProperty("basename", basename);
85 config->setProperty("last_document_path", lastDocumentPath);
86 config->setProperty("directory", directory);
87 config->setProperty("first_frame", firstFrame);
88 config->setProperty("last_frame", lastFrame);
89 config->setProperty("sequence_start", sequenceStart);
90 config->setProperty("frame_mimetype", frameMimeType);
91
92 config->setProperty("encode_video", shouldEncodeVideo);
93#ifndef Q_OS_ANDROID
94 config->setProperty("delete_sequence", shouldDeleteSequence);
95#endif
96 config->setProperty("only_unique_frames", wantsOnlyUniqueFrameSequence);
97
98 config->setProperty("framerate", frameRate);
99 config->setProperty("height", height);
100 config->setProperty("width", width);
101 config->setProperty("include_audio", includeAudio);
102 config->setProperty("filename", videoFileName);
103
104#ifdef Q_OS_ANDROID
105 config->setProperty("video_format_key", videoFormatKey);
106 config->setProperty("video_format_preferences_json", videoFormatPreferencesJson);
107#else
108 config->setProperty("video_mimetype", videoMimeType);
109 config->setProperty("ffmpeg_path", ffmpegPath);
110 config->setProperty("custom_ffmpeg_options", customFFMpegOptions);
111#endif
112
113 config->setPrefixedProperties("frame_export/", frameExportConfig);
114
115 return config;
116}
117
119{
120 basename = config->getPropertyLazy("basename", basename);
121 lastDocumentPath = config->getPropertyLazy("last_document_path", "");
122 directory = config->getPropertyLazy("directory", directory);
123 firstFrame = config->getPropertyLazy("first_frame", 0);
124 lastFrame = config->getPropertyLazy("last_frame", 0);
125 sequenceStart = config->getPropertyLazy("sequence_start", 0);
126 frameMimeType = config->getPropertyLazy("frame_mimetype", frameMimeType);
127
128#ifdef Q_OS_ANDROID
129 bool encodeVideoDefault = true;
130#else
131 bool encodeVideoDefault = false;
132#endif
133 shouldEncodeVideo = config->getPropertyLazy("encode_video", encodeVideoDefault);
134#ifndef Q_OS_ANDROID
135 shouldDeleteSequence = config->getPropertyLazy("delete_sequence", false);
136#endif
137 wantsOnlyUniqueFrameSequence = config->getPropertyLazy("only_unique_frames", false);
138
139 frameRate = config->getPropertyLazy("framerate", 25);
140 height = config->getPropertyLazy("height", 0);
141 width = config->getPropertyLazy("width", 0);
142 includeAudio = config->getPropertyLazy("include_audio", true);
143 videoFileName = config->getPropertyLazy("filename", "");
144
145#ifdef Q_OS_ANDROID
146 videoFormatKey = config->getPropertyLazy("video_format_key", QString());
147 videoFormatPreferencesJson = config->getPropertyLazy("video_format_preferences_json", QString());
148#else
149 videoMimeType = config->getPropertyLazy("video_mimetype", videoMimeType);
150 ffmpegPath = config->getPropertyLazy("ffmpeg_path", "");
151 customFFMpegOptions = config->getPropertyLazy("custom_ffmpeg_options", "");
152#endif
153
155 config->getPrefixedProperties("frame_export/", frameExportConfig);
156
157}
QString resolveAbsoluteDocumentFilePath(const QString &documentPath) const
void fromProperties(KisPropertiesConfigurationSP config)
KisPropertiesConfigurationSP frameExportConfig
KisPropertiesConfigurationSP toProperties() const
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
QString resolveAbsoluteFilePath(const QString &baseDir, const QString &fileName)
Resolve absolute file path from a file path and base dir.