Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Record only a section of the canvas

Luna Lovecraft86daf9ba2984
diff --git a/plugins/dockers/recorder/recorder_config.cpp b/plugins/dockers/recorder/recorder_config.cpp
index 3d54f128e1..9ab4f7f4ae 100644
--- a/plugins/dockers/recorder/recorder_config.cpp
+++ b/plugins/dockers/recorder/recorder_config.cpp
@@ -23,6 +23,7 @@ const QString keyThreads = "recorder/threads";
const QString keyRealTimeCaptureMode = "recorder/realtimecapturemode";
const QString keyRecordIsolateLayerMode = "recorder/recordisolatelayermode";
const QString keyRecordAutomatically = "recorder/recordautomatically";
+const QString keyFocusedRecording = "recorder/focusedrecording";
const QString defaultSnapshotDirectory = QDir::homePath() % QDir::separator() % "KritaRecorder";
}
@@ -148,6 +149,16 @@ void RecorderConfig::setRecordAutomatically(bool value)
config->writeEntry(keyRecordAutomatically, value);
}
+bool RecorderConfig::focusedRecord() const
+{
+ return config->readEntry(keyFocusedRecording, false);
+}
+
+void RecorderConfig::setFocusedRecord(bool value)
+{
+ return config->writeEntry(keyFocusedRecording, value);
+}
+
#ifdef Q_OS_ANDROID
const QString &RecorderConfig::defaultInternalSnapshotDirectory()
{
diff --git a/plugins/dockers/recorder/recorder_config.h b/plugins/dockers/recorder/recorder_config.h
index 62c3a3a39c..cc65f0ebe5 100644
--- a/plugins/dockers/recorder/recorder_config.h
+++ b/plugins/dockers/recorder/recorder_config.h
@@ -51,6 +51,9 @@ public:
bool recordAutomatically() const;
void setRecordAutomatically(bool value);
+ bool focusedRecord() const;
+ void setFocusedRecord(bool value);
+
#ifdef Q_OS_ANDROID
// Returns the internal storage directory that older versions of Krita
// defaulted to. Using this directory to store recordings is bogus, since
diff --git a/plugins/dockers/recorder/recorder_export.cpp b/plugins/dockers/recorder/recorder_export.cpp
index 7613504315..69a7825fc3 100644
--- a/plugins/dockers/recorder/recorder_export.cpp
+++ b/plugins/dockers/recorder/recorder_export.cpp
@@ -336,6 +336,8 @@ public:
void cleanupExporter()
{
+ preprocessor->undoPreprocessing();
+
if (exporter) {
exporter->reset();
exporter.reset();
diff --git a/plugins/dockers/recorder/recorder_export_preprocessor.cpp b/plugins/dockers/recorder/recorder_export_preprocessor.cpp
index 967d5c8023..1038ddd772 100644
--- a/plugins/dockers/recorder/recorder_export_preprocessor.cpp
+++ b/plugins/dockers/recorder/recorder_export_preprocessor.cpp
@@ -13,6 +13,7 @@
struct RecorderExportPreprocessor::Private {
QDir directory;
RecorderFormat format;
+ QStringList tails;
Private(QDir directory, RecorderFormat format)
: directory(directory)
@@ -23,6 +24,32 @@ struct RecorderExportPreprocessor::Private {
~Private()
{
}
+
+ void processTail()
+ {
+ if (!directory.exists())
+ return;
+
+ Q_FOREACH (QString file, directory.entryList({"*-tail.*"})) {
+ QString oldFile = file;
+ directory.rename(oldFile, file.remove("-tail"));
+
+ tails.append(file);
+ }
+ }
+
+ void restoreTail()
+ {
+ if (!directory.exists())
+ return;
+
+ Q_FOREACH (QString tail, tails) {
+ QString oldName = tail;
+ directory.rename(oldName, tail.replace(".", "-tail."));
+ }
+
+ tails.clear();
+ }
};
RecorderExportPreprocessor::RecorderExportPreprocessor(QDir directory, RecorderFormat format)
@@ -47,6 +74,8 @@ void RecorderExportPreprocessor::doPreprocessing()
return;
}
+ d->processTail();
+
QStringList fileNames = d->directory.entryList({"*." % RecorderFormatInfo::fileExtension(d->format)});
QRegularExpression fileRegex = RecorderConst::snapshotFilePatternFor(RecorderFormatInfo::fileExtension(d->format));
@@ -86,6 +115,8 @@ void RecorderExportPreprocessor::doPreprocessing()
}
int offset = 0;
+ QStringList new_tails = d->tails;
+
for (auto it = indecies.begin(); it != indecies.end(); ++it) {
int ind = *it;
@@ -101,7 +132,19 @@ void RecorderExportPreprocessor::doPreprocessing()
QString newName = QString("%2.%3").arg(QString("%1").arg(ind - offset, 7, 10, QLatin1Char('0')),
RecorderFormatInfo::fileExtension(d->format));
+ int tailIndex = d->tails.indexOf(oldName);
+ if (tailIndex != -1) {
+ new_tails[tailIndex] = newName;
+ }
+
// Hopefully nothing should go wrong
d->directory.rename(oldName, newName);
}
+
+ d->tails = new_tails;
+}
+
+void RecorderExportPreprocessor::undoPreprocessing()
+{
+ d->restoreTail();
}
diff --git a/plugins/dockers/recorder/recorder_export_preprocessor.h b/plugins/dockers/recorder/recorder_export_preprocessor.h
index 4b41a299bf..faa6be0e40 100644
--- a/plugins/dockers/recorder/recorder_export_preprocessor.h
+++ b/plugins/dockers/recorder/recorder_export_preprocessor.h
@@ -19,8 +19,11 @@ public:
void updateSettings(QDir directory, RecorderFormat format);
+ /// Renames tail frames, checks if there are no holes in the frames, and shifts the files to fill them
void doPreprocessing();
+ /// Restores tail frames, doesn't actually undo `doPreprocessing()`
+ void undoPreprocessing();
private:
struct Private;
QScopedPointer<Private> d;
diff --git a/plugins/dockers/recorder/recorder_image_copying_job.cpp b/plugins/dockers/recorder/recorder_image_copying_job.cpp
index 599341b9bd..39ad00caa1 100644
--- a/plugins/dockers/recorder/recorder_image_copying_job.cpp
+++ b/plugins/dockers/recorder/recorder_image_copying_job.cpp
@@ -6,11 +6,16 @@
#include "recorder_image_copying_job.h"
-RecorderImageCopyingJob::RecorderImageCopyingJob(KisPaintDeviceSP device, const QRect &rect, int writerId, int partIndex)
+RecorderImageCopyingJob::RecorderImageCopyingJob(KisPaintDeviceSP device,
+ const QRect &rect,
+ int writerId,
+ int partIndex,
+ QVector<QRect> regions)
: m_device(device)
, m_writerId(writerId)
, m_partIndex(partIndex)
, m_area(rect)
+ , m_regions(regions)
{
}
@@ -23,7 +28,7 @@ void RecorderImageCopyingJob::run()
m_outputDevice = new KisPaintDevice(m_device->colorSpace());
m_outputDevice->makeCloneFromRough(m_device, m_area);
- Q_EMIT sigImageCopyingDoneWithData(m_writerId, m_partIndex, m_outputDevice);
+ Q_EMIT sigImageCopyingDoneWithData(m_writerId, m_partIndex, m_regions, m_outputDevice);
}
bool RecorderImageCopyingJob::overrides(const KisSpontaneousJob *_otherJob)
diff --git a/plugins/dockers/recorder/recorder_image_copying_job.h b/plugins/dockers/recorder/recorder_image_copying_job.h
index 703a6f3dbf..4a9b8ca967 100644
--- a/plugins/dockers/recorder/recorder_image_copying_job.h
+++ b/plugins/dockers/recorder/recorder_image_copying_job.h
@@ -9,13 +9,14 @@
#include "kis_paint_device.h"
#include "kis_spontaneous_job.h"
+#include <qcontainerfwd.h>
class RecorderImageCopyingJob : public QObject, public KisSpontaneousJob
{
Q_OBJECT
public:
- RecorderImageCopyingJob(KisPaintDeviceSP device, const QRect &rect, int writerId, int index);
+ RecorderImageCopyingJob(KisPaintDeviceSP device, const QRect &rect, int writerId, int index, QVector<QRect> regions);
~RecorderImageCopyingJob();
void run() override;
@@ -28,7 +29,7 @@ public:
}
Q_SIGNALS:
- void sigImageCopyingDoneWithData(int writerId, int index, KisPaintDeviceSP device);
+ void sigImageCopyingDoneWithData(int writerId, int index, QVector<QRect> regions, KisPaintDeviceSP device);
private:
KisPaintDeviceSP m_device;
@@ -36,5 +37,6 @@ private:
int m_writerId;
int m_partIndex;
QRect m_area;
+ QVector<QRect> m_regions;
};
#endif
diff --git a/plugins/dockers/recorder/recorder_writer.cpp b/plugins/dockers/recorder/recorder_writer.cpp
index 9246daf08a..541cac00e6 100644
--- a/plugins/dockers/recorder/recorder_writer.cpp
+++ b/plugins/dockers/recorder/recorder_writer.cpp
@@ -28,6 +28,8 @@
#include <QVector>
#include <QSharedPointer>
#include <atomic>
+#include <QtMath>
+#include <qobjectdefs.h>
namespace
{
@@ -144,10 +146,23 @@ public:
Integer8BitsColorDepthID.id(),
KoColorSpaceRegistry::instance()->p709SRGBProfile());
- void captureImage(KisPaintDeviceSP device)
+ void captureImage(QRect area, KisPaintDevice* greaterImage)
{
KisImageSP image = canvas->image();
+ KisPaintDeviceSP device;
+
+ if (!greaterImage) {
+ // Create detached paint device that can be converted to target colorspace
+ device = new KisPaintDevice(image->colorSpace());
+ // we don't want image->barrierLock() because it will wait until the full stroke is finished
+ image->immediateLockForReadOnly();
+ device->makeCloneFromRough(image->projection(), area);
+ image->unlock();
+ } else {
+ device = greaterImage;
+ }
+
const bool needSrgbConversion = [&]() {
if (image->colorSpace()->colorDepthId() != Integer8BitsColorDepthID
|| image->colorSpace()->colorModelId() != RGBAColorModelID) {
@@ -170,8 +185,8 @@ public:
// truncate uneven image width/height making it even for subdivided size too
const quint32 bitmask = ~(0xFFFFFFFFu >> (31 - settings->resolution));
- const quint32 width = image->width() & bitmask;
- const quint32 height = image->height() & bitmask;
+ const quint32 width = area.width() & bitmask;
+ const quint32 height = area.height() & bitmask;
const int bufferSize = device->pixelSize() * width * height;
bool resize = imageBuffer.size() != bufferSize;
@@ -187,7 +202,7 @@ public:
frame = QImage(outData, outWidth, outHeight, QImage::Format_ARGB32);
}
- device->readBytes(reinterpret_cast<quint8 *>(imageBuffer.data()), 0, 0, width, height);
+ device->readBytes(reinterpret_cast<quint8 *>(imageBuffer.data()), area.x(), area.y(), width, height);
imageBufferWidth = width;
imageBufferHeight = height;
@@ -257,31 +272,31 @@ public:
}
}
- int writeFrame(int index)
+ bool writeFrame()
{
if (!outputDir->exists() && !outputDir->mkpath(settings->outputDirectory))
return false;
- const QString fileName = QString("%1").arg(index, 7, 10, QLatin1Char('0'));
- const QString &filePath = QString("%1%2.%3").arg(settings->outputDirectory, fileName,
+ const QString fileName = QString("%1").arg(partIndex, 7, 10, QLatin1Char('0'));
+ const QString &filePath = QString("%1%2.%3").arg(settings->outputDirectory,
+ fileName,
RecorderFormatInfo::fileExtension(settings->format));
int factor = -1; // default value
switch (settings->format) {
- case RecorderFormat::JPEG:
- factor = settings->quality; // 0...100
- break;
- case RecorderFormat::PNG:
- factor = qBound(0, 100 - (settings->compression * 10), 100); // 0..10 -> 100..0
- break;
+ case RecorderFormat::JPEG:
+ factor = settings->quality; // 0...100
+ break;
+ case RecorderFormat::PNG:
+ factor = qBound(0, 100 - (settings->compression * 10), 100); // 0..10 -> 100..0
+ break;
}
bool result = frame.save(filePath, RecorderFormatInfo::fileFormat(settings->format).data(), factor);
- if (!result)
+ if (!result) {
QFile(filePath).remove(); // remove corrupted frame
return result;
}
-
};
RecorderWriter::RecorderWriter(
@@ -298,14 +313,9 @@ RecorderWriter::~RecorderWriter()
delete d;
}
-void RecorderWriter::onCaptureImage(int writerId, int index, KisPaintDeviceSP device)
+bool RecorderWriter::onCaptureImageImpl(int index, bool tail, QRect region, KisPaintDevice* device)
{
- if (static_cast<int>(id) != writerId)
- return;
-
- d->isActive = true;
-
- d->captureImage(device);
+ d->captureImage(region, device);
// downscale image buffer
for (int res = 0; res < d->settings->resolution; ++res)
@@ -313,10 +323,9 @@ void RecorderWriter::onCaptureImage(int writerId, int index, KisPaintDeviceSP de
d->removeFrameTransparency();
- bool isFrameWritten = d->writeFrame(index);
+ d->partIndex = index;
- d->isActive = false;
- Q_EMIT capturingDone(id, isFrameWritten);
+ return d->writeFrame(tail);
}
bool RecorderWriter::isActive()
@@ -324,6 +333,45 @@ bool RecorderWriter::isActive()
return d->isActive;
}
+void RecorderWriter::onCaptureImage(int writerId, int index, QVector<QRect> regions, KisPaintDeviceSP device)
+{
+ if (static_cast<int>(id) != writerId)
+ return;
+
+ d->isActive = true;
+
+ // Sanity check
+ KIS_ASSERT(!regions.isEmpty());
+
+ KisPaintDeviceSP device;
+
+ if (regions.length() > 1) {
+ KisImageSP image = d->canvas->image();
+ device = new KisPaintDevice(image->colorSpace());
+
+ QRect united = regions.first();
+
+ Q_FOREACH (QRect r, regions) {
+ united = united.united(r);
+ }
+
+ image->immediateLockForReadOnly();
+ device->makeCloneFromRough(image->projection(), united);
+ image->unlock();
+ }
+
+ bool framesWrittens = true;
+
+ Q_FOREACH (QRect region, regions) {
+ framesWrittens &= onCaptureImageImpl(index, tail, region, regions.length() > 1 ? device.data() : nullptr);
+ index++;
+ }
+
+ d->isActive = false;
+
+ Q_EMIT capturingDone(id, framesWrittens);
+}
+
struct WriterPoolEl
{
using QThreadPtr = QSharedPointer<QThread>;
@@ -370,6 +418,8 @@ public:
WriterPool writerPool;
RecorderWriterSettings settings{};
QDir outputDir;
+ bool captureTail = false;
+ QRect oldRegion = QRect(-1, -1, -1, -1);
int findLastIndex(const QString &directory)
{
@@ -421,7 +471,7 @@ public:
for (auto &el : writerPool) {
el.thread->quit();
el.thread->wait(RecorderConst::waitThreadTimeoutMs);
- disconnect(q, SIGNAL(startCapturing(int, int, KisPaintDeviceSP)), el.writer.get(), SLOT(onCaptureImage(int, int, KisPaintDeviceSP)));
+ disconnect(q, SIGNAL(startCapturing(int, int, bool, QVector<QRect>)), el.writer.get(), SLOT(onCaptureImage(int, int, bool, QVector<QRect>)));
disconnect(el.writer.get(), SIGNAL(capturingDone(int, bool)), q, SLOT(onCapturingDone(int, bool)));
if (el.thread->isRunning())
{
@@ -465,7 +515,7 @@ public:
auto writerPtr = writerPool[newWorkerId].writer;
auto threadPtr = writerPool[newWorkerId].thread;
threadPtr->setObjectName(QString("Krita-Recorder-WriterPool#%1").arg(newWorkerId));
- connect(q, SIGNAL(startCapturing(int, int, KisPaintDeviceSP)), writerPtr.get(), SLOT(onCaptureImage(int, int, KisPaintDeviceSP)));
+ connect(q, SIGNAL(startCapturing(int, int, bool, QVector<QRect>)), writerPtr.get(), SLOT(onCaptureImage(int, int, bool, QVector<QRect>)));
connect(writerPtr.get(), SIGNAL(capturingDone(int, bool)), q, SLOT(onCapturingDone(int, bool)));
writerPtr->moveToThread(threadPtr.get());
threadPtr->start(QThread::IdlePriority);
@@ -562,6 +612,9 @@ void RecorderWriterManager::setup(const RecorderWriterSettings &settings)
void RecorderWriterManager::start(bool toggleEnabled)
{
+ removeTails();
+ tryRestoreRegion();
+
if (d->timer.isActive())
return;
@@ -584,12 +637,28 @@ void RecorderWriterManager::start(bool toggleEnabled)
}
}
+void RecorderWriterManager::removeTails()
+{
+ // Remove all tail frames
+ if(d->outputDir.exists()) {
+ Q_FOREACH (QString f, d->outputDir.entryList({"*-tail.*"}, QDir::Files)) {
+ d->outputDir.remove(f);
+ }
+ }
+}
+
bool RecorderWriterManager::stop(bool toggleEnabled)
{
//Check if the timer is active, so that we don't try to clear the writer pool multiple times
if (!d->timer.isActive())
return true;
+saveRegion();
+
+ //Capture some tail frame
+ d->captureTail = true;
+ onTimer();
+
d->timer.stop();
auto result = d->clearWriterPool();
recorderThreads.setUsed(0);
@@ -606,8 +675,9 @@ void RecorderWriterManager::setEnabled(bool enabled = false)
void RecorderWriterManager::onTimer()
{
- if (!d->enabled || !d->canvas)
+ if ((!d->enabled && !d->captureTail) || !d->canvas) {
return;
+ }
// take snapshots only if main window is active
// else some dialogs like filters may disappear when canvas->image()->lock() is called
@@ -619,7 +689,7 @@ void RecorderWriterManager::onTimer()
return;
}
- if (!d->imageModified)
+ if (!d->imageModified && !d->captureTail)
return;
d->imageModified = false;
@@ -639,17 +709,92 @@ void RecorderWriterManager::onTimer()
d->writerPool[d->freeWriterId].thread->setPriority(QThread::HighPriority);
recorderThreads.incUsedAndNotify();
- RecorderImageCopyingJob *job = new RecorderImageCopyingJob(d->canvas->image()->projection(),
- d->canvas->image()->bounds(),
- d->freeWriterId,
- ++d->partIndex);
+ QRect fullSize = d->canvas->image()->bounds();
+
+ QRect region = d->settings.focusedRecord && !d->captureTail ? d->canvas->regionOfInterest() : fullSize;
+
+ // Handle initialisation
+ if (d->oldRegion.width() == -1 || d->oldRegion.height() == 1) {
+ d->oldRegion = region;
+ }
+
+ bool interpolate = region != d->oldRegion;
+
+ int totalFrames = 1;
+ // Change in the region, let's generate some frames
+ if (interpolate) {
+ float diffX = abs(region.x() - d->oldRegion.x()) / (float)fullSize.width();
+ float diffY = abs(region.y() - d->oldRegion.y()) / (float)fullSize.height();
+ float diffW = abs(region.width() - d->oldRegion.width()) / (float)fullSize.width();
+ float diffH = abs(region.height() - d->oldRegion.height()) / (float)fullSize.height();
+
+ // Find the highest diff
+ float maxDiff = std::max({diffX, diffY, diffW, diffH});
+
+ // Maximum amount of interpolation frames to generate
+ const int maxFrames = 10;
+
+ // TODO: Potentially change the number of frames function from linear to smth else
+ int framesToGenerate = std::ceil(maxFrames * maxDiff);
+
+ totalFrames += framesToGenerate;
+ }
+
+ auto lerp = [](QRect a, QRect b, qreal t) {
+
+ KIS_SAFE_ASSERT_RECOVER(t <= 1);
+ QRect out;
+
+ out.setX(a.x() + t * (b.x() - a.x()));
+ out.setY(a.y() + t * (b.y() - a.y()));
+ out.setWidth(a.width() + t * (b.width() - a.width()));
+ out.setHeight(a.height() + t * (b.height() - a.height()));
+
+ return out;
+ };
+
+ //TODO: try other easing functions
+ auto easeOutCubic = [](qreal t) {
+ return 1 - qPow(1 - t, 3);
+ };
+
+ QVector<QRect> rects;
+
+ for (int frame = 0; frame < totalFrames; frame++) {
+ //Linear animations look really bad, so do easing
+ QRect interpolatedRect = lerp(d->oldRegion, region, easeOutCubic((qreal)(frame + 1) / (qreal)totalFrames));
+ rects.push_back(interpolatedRect);
+ };
+
+ QRect copyArea = rects.first();
+
+ if (rects.length() > 1) {
+ QRect united = rects.first();
+
+ Q_FOREACH (QRect r, rects) {
+ united = united.united(r);
+ }
+
+ copyArea = united;
+ }
+
+ RecorderImageCopyingJob *job =
+ new RecorderImageCopyingJob(d->canvas->image()->projection(), copyArea, d->freeWriterId, ++d->partIndex, rects);
connect(job,
- SIGNAL(sigImageCopyingDoneWithData(int, int, KisPaintDeviceSP)),
+ SIGNAL(sigImageCopyingDoneWithData(int, int, QVector<QRect>, KisPaintDeviceSP)),
this,
- SIGNAL(startCapturing(int, int, KisPaintDeviceSP)));
+ SIGNAL(startCapturing(int, int, QVector<QRect>, KisPaintDeviceSP)));
d->canvas->image()->addSpontaneousJob(job);
+
+ d->partIndex += totalFrames - 1;
+
+ if (!d->captureTail) {
+ d->oldRegion = region;
+ }
+
+ d->captureTail = false;
}
void RecorderWriterManager::onCapturingDone(int workerId, bool success)
@@ -687,3 +832,39 @@ void RecorderWriterManager::onToolPrimaryActionActivated(bool activated)
{
d->toolActivated = activated;
}
+
+//Need to save the region, so that there are no jumps when stopping and resuming the recording
+void RecorderWriterManager::saveRegion()
+{
+ const QString filename = "region";
+ QDir dir(d->outputDir);
+
+ QFile file(dir.filePath(filename));
+
+ if (!file.open(QIODevice::WriteOnly)) {
+ return;
+ }
+
+ QDataStream out(&file);
+ out << d->oldRegion;
+
+ file.close();
+}
+
+void RecorderWriterManager::tryRestoreRegion()
+{
+ const QString filename = "region";
+ QDir dir(d->outputDir);
+
+ QFile file(dir.filePath(filename));
+
+ if (!file.open(QIODevice::ReadOnly)) {
+ d->oldRegion = QRect(-1, -1, -1, -1);
+ return;
+ }
+
+ QDataStream out(&file);
+ out >> d->oldRegion;
+
+ file.close();
+}
diff --git a/plugins/dockers/recorder/recorder_writer.h b/plugins/dockers/recorder/recorder_writer.h
index 57fb891706..eeab051daa 100644
--- a/plugins/dockers/recorder/recorder_writer.h
+++ b/plugins/dockers/recorder/recorder_writer.h
@@ -10,9 +10,10 @@
#include "kis_types.h"
#include "recorder_format.h"
+#include <QMutex>
#include <QObject>
#include <QPointer>
-#include <QMutex>
+#include <kis_paint_device.h>
struct RecorderExportSettings;
class RecorderConfig;
@@ -29,6 +30,7 @@ struct RecorderWriterSettings
double captureInterval;
bool recordIsolateLayerMode;
bool realTimeCaptureMode;
+ bool focusedRecord;
};
// This class is used to provide mechanism ro sync the number of available
@@ -89,7 +91,10 @@ Q_SIGNALS:
void capturingDone(int writerId, bool success);
public Q_SLOTS:
- void onCaptureImage(int writerId, int index, KisPaintDeviceSP device);
+ void onCaptureImage(int writerId, int index, bool tail, QVector<QRect> regions);
+
+private:
+ bool onCaptureImageImpl(int index, bool tail, QRect region, KisPaintDevice* device);
private:
class Private;
@@ -120,6 +125,10 @@ public:
void setEnabled(bool enabled);
+ void removeTails();
+ void saveRegion();
+ void tryRestoreRegion();
+
Q_SIGNALS:
void started();
void stopped();
@@ -127,7 +136,7 @@ Q_SIGNALS:
void lowPerformanceWarning();
void recorderStopWarning();
- void startCapturing(int writerId, int index, KisPaintDeviceSP device);
+ void startCapturing(int writerId, int index, bool tail, QVector<QRect> regions);
private Q_SLOTS:
void onTimer();
diff --git a/plugins/dockers/recorder/recorderdocker.cpp b/plugins/dockers/recorder/recorderdocker.cpp
index 17bce8d310..c5782c0af9 100644
--- a/plugins/dockers/recorder/recorderdocker.cpp
+++ b/plugins/dockers/recorder/recorderdocker.cpp
@@ -52,6 +52,7 @@ RecorderDockerPlugin::RecorderDockerPlugin(QObject* parent, const QVariantList&)
: QObject(parent)
{
KoDockRegistry::instance()->add(new RecorderDockerDockFactory());
+ qRegisterMetaType<QVector<QRect>>();
}
RecorderDockerPlugin::~RecorderDockerPlugin()
diff --git a/plugins/dockers/recorder/recorderdocker.ui b/plugins/dockers/recorder/recorderdocker.ui
index 7c021581ec..0db83bed28 100644
--- a/plugins/dockers/recorder/recorderdocker.ui
+++ b/plugins/dockers/recorder/recorderdocker.ui
@@ -33,13 +33,13 @@
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="frameShape">
- <enum>QFrame::NoFrame</enum>
+ <enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
- <enum>QFrame::Plain</enum>
+ <enum>QFrame::Shadow::Plain</enum>
</property>
<property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
+ <enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
@@ -49,8 +49,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>324</width>
- <height>369</height>
+ <width>310</width>
+ <height>412</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@@ -108,8 +108,7 @@
<string/>
</property>
<property name="icon">
- <iconset theme="folder">
- <normaloff>.</normaloff>.</iconset>
+ <iconset theme="folder"/>
</property>
</widget>
</item>
@@ -133,8 +132,7 @@
<string/>
</property>
<property name="icon">
- <iconset theme="folder">
- <normaloff>.</normaloff>.</iconset>
+ <iconset theme="folder"/>
</property>
</widget>
</item>
@@ -143,7 +141,7 @@
<item>
<widget class="Line" name="line1">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
@@ -174,7 +172,7 @@
</size>
</property>
<property name="correctionMode">
- <enum>QAbstractSpinBox::CorrectToNearestValue</enum>
+ <enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
</property>
<property name="keyboardTracking">
<bool>false</bool>
@@ -204,7 +202,7 @@
</widget>
</item>
<item row="3" column="1">
- <widget class="KisSliderSpinBox" name="spinQuality" native="true">
+ <widget class="KisSliderSpinBox" name="spinQuality">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -310,7 +308,7 @@
<number>1</number>
</property>
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
@@ -370,13 +368,23 @@ Depending on timelapse speed, this may cause flickering in the resulting video.<
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxFocusedRecord">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Record only the visible area of the canvas.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>Record focused area</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="line2">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
@@ -395,7 +403,7 @@ Depending on timelapse speed, this may cause flickering in the resulting video.<
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -417,7 +425,7 @@ Depending on timelapse speed, this may cause flickering in the resulting video.<
<item>
<spacer name="verticalSpacer">
<property name="orientation">
- <enum>Qt::Vertical</enum>
+ <enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
diff --git a/plugins/dockers/recorder/recorderdocker_dock.cpp b/plugins/dockers/recorder/recorderdocker_dock.cpp
index 1ed0925c99..77b47f990b 100644
--- a/plugins/dockers/recorder/recorderdocker_dock.cpp
+++ b/plugins/dockers/recorder/recorderdocker_dock.cpp
@@ -86,6 +86,8 @@ public:
bool realTimeCaptureMode = false;
bool recordIsolateLayerMode = false;
bool recordAutomatically = false;
+ bool focusedRecord = false;
+
bool paused = true;
#ifdef Q_OS_ANDROID
bool internalMoveInProgress{false};
@@ -147,6 +149,7 @@ public:
}
recordIsolateLayerMode = config.recordIsolateLayerMode();
recordAutomatically = config.recordAutomatically();
+ focusedRecord = config.focusedRecord();
updateUiFormat();
}
@@ -244,7 +247,8 @@ public:
resolution,
captureInterval,
recordIsolateLayerMode,
- realTimeCaptureMode});
+ realTimeCaptureMode,
+ focusedRecord});
}
QString getPrefix()
@@ -437,6 +441,7 @@ RecorderDockerDock::RecorderDockerDock()
d->ui->checkBoxRealTimeCaptureMode->setChecked(d->realTimeCaptureMode);
d->ui->checkBoxRecordIsolateMode->setChecked(d->recordIsolateLayerMode);
d->ui->checkBoxAutoRecord->setChecked(d->recordAutomatically);
+ d->ui->checkBoxFocusedRecord->setChecked(d->focusedRecord);
KisActionRegistry *actionRegistry = KisActionRegistry::instance();
d->recordToggleAction = actionRegistry->makeQAction(keyActionRecordToggle, this);
@@ -465,6 +470,8 @@ RecorderDockerDock::RecorderDockerDock()
connect(d->ui->buttonRecordToggle, SIGNAL(toggled(bool)), this, SLOT(onRecordButtonToggled(bool)));
connect(d->ui->buttonExport, SIGNAL(clicked()), this, SLOT(onExportButtonClicked()));
+ connect(d->ui->checkBoxFocusedRecord, SIGNAL(toggled(bool)), this, SLOT(onFocusedCaptureToggled(bool)));
+
connect(&d->writer.recorderThreads, SIGNAL(notifyInUseChange(bool)), this, SLOT(onActiveRecording(bool)));
connect(&d->writer.recorderThreads, SIGNAL(notifyInUseChange(bool)), this, SLOT(onUpdateRecIndicator()));
connect(&d->writer, SIGNAL(started()), this, SLOT(onWriterStarted()));
@@ -654,6 +661,13 @@ void RecorderDockerDock::slotSelectSnapshotDirectory()
}
}
+void RecorderDockerDock::onFocusedCaptureToggled(bool checked)
+{
+ d->focusedRecord = checked;
+ RecorderConfig(false).setFocusedRecord(checked);
+ d->loadSettings();
+}
+
void RecorderDockerDock::onRecordIsolateLayerModeToggled(bool checked)
{
d->recordIsolateLayerMode = checked;
diff --git a/plugins/dockers/recorder/recorderdocker_dock.h b/plugins/dockers/recorder/recorderdocker_dock.h
index 0cf07b1cf2..0591ea283c 100644
--- a/plugins/dockers/recorder/recorderdocker_dock.h
+++ b/plugins/dockers/recorder/recorderdocker_dock.h
@@ -49,6 +49,7 @@ private Q_SLOTS:
void slotSelectSnapshotDirectory();
bool onRecordButtonToggled(bool checked);
void onExportButtonClicked();
+ void onFocusedCaptureToggled(bool checked);
void onWriterStarted();
void onWriterStopped();