Krita Source Code Documentation
Loading...
Searching...
No Matches
RecorderDockerDock::Private Class Reference

Public Member Functions

bool canRecord ()
 
QString getPrefix ()
 
void loadRelevantExportSettings ()
 
void loadSettings ()
 
 Private (const RecorderExportSettings &es, RecorderDockerDock *q_ptr)
 
void showWarning (const QString &hint)
 
void updateComboResolution (quint32 width, quint32 height)
 
void updateRecIndicator ()
 
void updateRecordStatus (bool isRecording)
 
void updateThreadUi ()
 
void updateUiFormat ()
 
void updateUiForRealTimeMode ()
 
void updateWriterSettings ()
 

Public Attributes

QPointer< KisCanvas2 > canvas
 
double captureInterval = 0.
 
int compression = 0
 
QMap< QString, bool > enabledIds
 
QAction * exportAction = nullptr
 
bool focusedRecord = false
 
RecorderFormat format = RecorderFormat::JPEG
 
QString outputDirectory
 
bool paused = true
 
QTimer pausedTimer
 
QString prefix
 
RecorderDockerDock *const q
 
int quality = 0
 
bool realTimeCaptureMode = false
 
bool recordAutomatically = false
 
bool recordIsolateLayerMode = false
 
QAction * recordToggleAction = nullptr
 
int resolution = 0
 
QString snapshotDirectory
 
QLabel * statusBarLabel
 
QLabel * statusBarWarningLabel
 
QPalette threadsSliderPalette
 
QPalette threadsSpinPalette
 
QScopedPointer< Ui::RecorderDocker > ui
 
QTimer warningTimer
 
RecorderWriterManager writer
 

Detailed Description

Definition at line 82 of file recorderdocker_dock.cpp.

Constructor & Destructor Documentation

◆ Private()

RecorderDockerDock::Private::Private ( const RecorderExportSettings & es,
RecorderDockerDock * q_ptr )
inline

Definition at line 120 of file recorderdocker_dock.cpp.

121 : q(q_ptr)
122 , ui(new Ui::RecorderDocker())
123 , writer(es)
124 , statusBarLabel(new QLabel())
125 , statusBarWarningLabel(new QLabel())
126 {
128 statusBarWarningLabel->setPixmap(KisIconUtils::loadIcon("warning").pixmap(16, 16));
129 statusBarWarningLabel->hide();
130 warningTimer.setInterval(10000);
131 warningTimer.setSingleShot(true);
132 pausedTimer.setSingleShot(true);
133 connect(&warningTimer, SIGNAL(timeout()), q, SLOT(onWarningTimeout()));
134 connect(&pausedTimer, SIGNAL(timeout()), q, SLOT(onPausedTimeout()));
135 }
QScopedPointer< Ui::RecorderDocker > ui
RecorderDockerDock *const q
QIcon loadIcon(const QString &name)

References KisIconUtils::loadIcon(), RecorderDockerDock::onPausedTimeout(), RecorderDockerDock::onWarningTimeout(), pausedTimer, q, statusBarWarningLabel, updateRecIndicator(), and warningTimer.

Member Function Documentation

◆ canRecord()

bool RecorderDockerDock::Private::canRecord ( )
inline

Definition at line 139 of file recorderdocker_dock.cpp.

140 {
141 QSize imageSize = canvas->image()->size();
142
143 // We always convert to RGBA8, so can assume 4 bytes/pixel
144 quint64 totalSize = (quint64)imageSize.width() * (quint64)imageSize.height() * 4;
145
146 return totalSize <= 2147483647;
147 }

References canvas.

◆ getPrefix()

QString RecorderDockerDock::Private::getPrefix ( )
inline

Definition at line 271 of file recorderdocker_dock.cpp.

272 {
273 return !canvas ? ""
274 : canvas->imageView()->document()->documentInfo()->aboutInfo("creation-date").remove(QRegularExpression("[^0-9]"));
275 }

References canvas.

◆ loadRelevantExportSettings()

void RecorderDockerDock::Private::loadRelevantExportSettings ( )
inline

◆ loadSettings()

void RecorderDockerDock::Private::loadSettings ( )
inline

Definition at line 149 of file recorderdocker_dock.cpp.

150 {
151 RecorderConfig config(true);
152 snapshotDirectory = config.snapshotDirectory();
153#ifdef Q_OS_ANDROID
154 fixInternalSnapshotDirectory();
155#endif
156 captureInterval = config.captureInterval();
157 format = config.format();
158 quality = config.quality();
159 compression = config.compression();
160 resolution = config.resolution();
161 writer.recorderThreads.set(config.threads());
162 realTimeCaptureMode = config.realTimeCaptureMode();
164 q->exportSettings->lockFps = true;
166 }
167 recordIsolateLayerMode = config.recordIsolateLayerMode();
168 recordAutomatically = config.recordAutomatically();
169 focusedRecord = config.focusedRecord();
170
172 }
ThreadCounter recorderThreads
bool set(int value)

References RecorderConfig::captureInterval(), captureInterval, RecorderConfig::compression(), compression, RecorderDockerDock::exportSettings, RecorderConfig::focusedRecord(), focusedRecord, RecorderConfig::format(), format, RecorderExportSettings::lockFps, q, RecorderConfig::quality(), quality, RecorderConfig::realTimeCaptureMode(), realTimeCaptureMode, RecorderExportSettings::realTimeCaptureModeWasSet, RecorderConfig::recordAutomatically(), recordAutomatically, RecorderWriterManager::recorderThreads, RecorderConfig::recordIsolateLayerMode(), recordIsolateLayerMode, RecorderConfig::resolution(), resolution, ThreadCounter::set(), RecorderConfig::snapshotDirectory(), snapshotDirectory, RecorderConfig::threads(), updateUiFormat(), and writer.

◆ showWarning()

void RecorderDockerDock::Private::showWarning ( const QString & hint)
inline

Definition at line 362 of file recorderdocker_dock.cpp.

362 {
363 if (statusBarWarningLabel->isHidden()) {
364 statusBarWarningLabel->setToolTip(hint);
365 statusBarWarningLabel->show();
366 warningTimer.start();
367 }
368 }

References statusBarWarningLabel, and warningTimer.

◆ updateComboResolution()

void RecorderDockerDock::Private::updateComboResolution ( quint32 width,
quint32 height )
inline

Definition at line 277 of file recorderdocker_dock.cpp.

278 {
279 const QStringList titles = {
280 i18nc("Use original resolution for the frames when recording the canvas", "Original"),
281 i18nc("Use the resolution two times smaller than the original resolution for the frames when recording the canvas", "Half"),
282 i18nc("Use the resolution four times smaller than the original resolution for the frames when recording the canvas", "Quarter")
283 };
284
285 QStringList items;
286 for (int index = 0, len = titles.length(); index < len; ++index) {
287 int divider = 1 << index;
288 items += QString("%1 (%2x%3)").arg(titles[index])
289 .arg((width / divider) & ~1)
290 .arg((height / divider) & ~1);
291 }
292 QSignalBlocker blocker(ui->comboResolution);
293 const int currentIndex = ui->comboResolution->currentIndex();
294 ui->comboResolution->clear();
295 ui->comboResolution->addItems(items);
296 ui->comboResolution->setCurrentIndex(currentIndex);
297 }

References ui.

◆ updateRecIndicator()

void RecorderDockerDock::Private::updateRecIndicator ( )
inline

Definition at line 335 of file recorderdocker_dock.cpp.

336 {
337 uint threads = writer.recorderThreads.get();
338 uint threadsInUse = writer.recorderThreads.getUsed();
339 QString label("<font style='letter-spacing:-4px'>");
340 QString threadColor;
341 for (unsigned int threadNr = 1; threadNr <= ThreadSystemValue::MaxThreadCount ; threadNr++)
342 {
343 if (threadNr > threads) {
344 threadColor = colorNormal;
345 } else if (threadNr > ThreadSystemValue::MaxRecordThreadCount) {
346 threadColor = threadNr <= threadsInUse ? activeColorNegative : inactiveColorNegative;
347 } else if (threadNr > ThreadSystemValue::IdealRecordThreadCount) {
348 threadColor = threadNr <= threadsInUse ? activeColorNeutral : inactiveColorNeutral;
349 } else {
350 threadColor = threadNr <= threadsInUse ? activeColorPositive : inactiveColorPositive;
351 }
352 label.append(QString("<font color='%1'>▍</font>").arg(threadColor));
353 }
354 // don't remove empty <font></font> tag else label will jump a few pixels around
355 label.append(QString("</font><font> %1 </font><font color='%2'>●</font>")
356 .arg(i18nc("Recording symbol", "REC"))
357 .arg(paused ? "" : activeColorNegative));
358 statusBarLabel->setText(label);
359 statusBarLabel->setToolTip(paused ? i18n("Recorder is paused") : QString(i18n("Active recording with %1 of %2 available threads")).arg(threadsInUse).arg(threads));
360 }
unsigned int uint
unsigned int getUsed() const
unsigned int get() const
const unsigned int IdealRecordThreadCount
const unsigned int MaxThreadCount
const unsigned int MaxRecordThreadCount

References ThreadCounter::get(), ThreadCounter::getUsed(), ThreadSystemValue::IdealRecordThreadCount, ThreadSystemValue::MaxRecordThreadCount, ThreadSystemValue::MaxThreadCount, paused, RecorderWriterManager::recorderThreads, statusBarLabel, and writer.

◆ updateRecordStatus()

void RecorderDockerDock::Private::updateRecordStatus ( bool isRecording)
inline

Definition at line 299 of file recorderdocker_dock.cpp.

300 {
301 QSignalBlocker blocker(ui->buttonRecordToggle);
302 recordToggleAction->setChecked(isRecording);
303 recordToggleAction->setEnabled(true);
304
305 ui->buttonRecordToggle->setChecked(isRecording);
306 ui->buttonRecordToggle->setIcon(KisIconUtils::loadIcon(isRecording ? "media-playback-stop" : "media-record"));
307 ui->buttonRecordToggle->setText(isRecording ? i18nc("Stop recording the canvas", "Stop")
308 : i18nc("Start recording the canvas", "Record"));
309
310 if (canRecord()) {
311 ui->buttonRecordToggle->setEnabled(true);
312 ui->buttonRecordToggle->setToolTip("");
313 } else {
314 ui->buttonRecordToggle->setEnabled(false);
315 ui->buttonRecordToggle->setToolTip(i18n("Image too large to be recorded"));
316 }
317 ui->widgetSettings->setEnabled(!isRecording);
318
319 statusBarLabel->setVisible(isRecording);
320
321 if (!canvas)
322 return;
323
324 KisStatusBar *statusBar = canvas->viewManager()->statusBar();
325 if (isRecording) {
327 statusBar->addExtraWidget(statusBarLabel);
329 } else {
332 }
333 }
void removeExtraWidget(QWidget *widget)
void addExtraWidget(QWidget *widget)

References KisStatusBar::addExtraWidget(), canRecord(), canvas, KisIconUtils::loadIcon(), recordToggleAction, KisStatusBar::removeExtraWidget(), statusBarLabel, statusBarWarningLabel, ui, and updateRecIndicator().

◆ updateThreadUi()

void RecorderDockerDock::Private::updateThreadUi ( )
inline

Definition at line 370 of file recorderdocker_dock.cpp.

371 {
372 QString toolTipText;
373 auto threads = writer.recorderThreads.get();
375 // Number of threads exceeds ideal thread count
376 // -> switch color of threads slider and spin wheel to red
377 QPalette pal;
378 pal.setColor(QPalette::Text, textColorNegative);
379 pal.setColor(QPalette::Button, buttonColorNegative);
380 ui->spinThreads->setPalette(pal);
381 ui->sliderThreads->setPalette(pal);
382 toolTipText = QString(
383 i18n("Set the number of recording threads.\nThe number of threads exceeds the ideal max number of your hardware setup.\nPlease be aware, that a number greater than %1 probably won't give you any performance boost.")
385 } else if (threads > ThreadSystemValue::IdealRecordThreadCount) {
386 // Number of threads exceeds ideal recorder thread count
387 // -> switch color of threads slider and spin wheel to orange
388 QPalette pal;
389 pal.setColor(QPalette::Text, textColorNeutral);
390 pal.setColor(QPalette::Button, buttonColorNeutral);
391 ui->spinThreads->setPalette(pal);
392 ui->sliderThreads->setPalette(pal);
393 toolTipText = QString(
394 i18n("Set the number of recording threads.\nAccording to your hardware setup you should record with no more than %1 threads.\nYou can play around with one or two more threads, but keep an eye on your overall system performance.")
396 } else {
397 ui->spinThreads->setPalette(threadsSpinPalette);
398 ui->sliderThreads->setPalette(threadsSliderPalette);
399 toolTipText = i18n("Set the number of threads to be used for recording.");
400 }
401 ui->spinThreads->setToolTip(toolTipText);
402 ui->sliderThreads->setToolTip(toolTipText);
403 }

References ThreadCounter::get(), ThreadSystemValue::IdealRecordThreadCount, ThreadSystemValue::MaxRecordThreadCount, RecorderWriterManager::recorderThreads, threadsSliderPalette, threadsSpinPalette, ui, and writer.

◆ updateUiFormat()

void RecorderDockerDock::Private::updateUiFormat ( )
inline

Definition at line 180 of file recorderdocker_dock.cpp.

180 {
181 int index = 0;
182 QString title;
183 QString hint;
184 int minValue = 0;
185 int maxValue = 0;
186 QString suffix;
187 int factor = 0;
188 switch (format) {
190 index = 0;
191 title = i18nc("Title for label. JPEG Quality level", "Quality:");
192 hint = i18nc("@tooltip", "Greater value will produce a larger file and a better quality. Doesn't affect CPU consumption.\nValues lower than 50 are not recommended due to high artifacts.");
193 minValue = 1;
194 maxValue = 100;
195 suffix = "%";
196 factor = quality;
197 break;
199 index = 1;
200 title = i18nc("Title for label. PNG Compression level", "Compression:");
201 hint = i18nc("@tooltip", "Greater value will produce a smaller file but will require more from your CPU. Doesn't affect quality.\nCompression set to 0 is not recommended due to high disk space consumption.\nValues above 3 are not recommended due to high performance impact.");
202 minValue = 0;
203 maxValue = 5;
204 suffix = "";
205 factor = compression;
206 break;
207 }
208
209 ui->comboFormat->setCurrentIndex(index);
210 ui->labelQuality->setText(title);
211 ui->spinQuality->setToolTip(hint);
212 QSignalBlocker blocker(ui->spinQuality);
213 ui->spinQuality->setMinimum(minValue);
214 ui->spinQuality->setMaximum(maxValue);
215 ui->spinQuality->setValue(factor);
216 ui->spinQuality->setSuffix(suffix);
217 }

References compression, format, JPEG, PNG, quality, and ui.

◆ updateUiForRealTimeMode()

void RecorderDockerDock::Private::updateUiForRealTimeMode ( )
inline

Definition at line 219 of file recorderdocker_dock.cpp.

219 {
220 QString title;
221 double minValue = 0;
222 double maxValue = 0;
223 double value = 0;
224 int decimals = 0;
225 QString suffix;
226 QSignalBlocker blocker(ui->spinRate);
227
229 title = i18nc("Title for label. Video frames per second", "Video FPS:");
230 minValue = 1;
231 maxValue = 60;
232 decimals = 0;
234 suffix = "";
235 disconnect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onCaptureIntervalChanged(double)));
236 connect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onVideoFPSChanged(double)));
237 } else {
238 title = i18nc("Title for label. Capture rate", "Capture interval:");
239 minValue = 0.10;
240 maxValue = 100.0;
241 decimals = 1;
243 suffix = " sec.";
244 disconnect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onVideoFPSChanged(double)));
245 connect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onCaptureIntervalChanged(double)));
246 }
247
248 ui->labelRate->setText(title);
249 ui->spinRate->setDecimals(decimals);
250 ui->spinRate->setMinimum(minValue);
251 ui->spinRate->setMaximum(maxValue);
252 ui->spinRate->setSuffix(suffix);
253 ui->spinRate->setValue(value);
254 }
float value(const T *src, size_t ch)
void onCaptureIntervalChanged(double interval)
void onVideoFPSChanged(double interval)

References captureInterval, RecorderDockerDock::exportSettings, RecorderExportSettings::fps, RecorderDockerDock::onCaptureIntervalChanged(), RecorderDockerDock::onVideoFPSChanged(), q, realTimeCaptureMode, ui, and value().

◆ updateWriterSettings()

void RecorderDockerDock::Private::updateWriterSettings ( )
inline

Member Data Documentation

◆ canvas

QPointer<KisCanvas2> RecorderDockerDock::Private::canvas

Definition at line 89 of file recorderdocker_dock.cpp.

◆ captureInterval

double RecorderDockerDock::Private::captureInterval = 0.

Definition at line 98 of file recorderdocker_dock.cpp.

◆ compression

int RecorderDockerDock::Private::compression = 0

Definition at line 101 of file recorderdocker_dock.cpp.

◆ enabledIds

QMap<QString, bool> RecorderDockerDock::Private::enabledIds

Definition at line 118 of file recorderdocker_dock.cpp.

◆ exportAction

QAction* RecorderDockerDock::Private::exportAction = nullptr

Definition at line 93 of file recorderdocker_dock.cpp.

◆ focusedRecord

bool RecorderDockerDock::Private::focusedRecord = false

Definition at line 106 of file recorderdocker_dock.cpp.

◆ format

RecorderFormat RecorderDockerDock::Private::format = RecorderFormat::JPEG

Definition at line 99 of file recorderdocker_dock.cpp.

◆ outputDirectory

QString RecorderDockerDock::Private::outputDirectory

Definition at line 97 of file recorderdocker_dock.cpp.

◆ paused

bool RecorderDockerDock::Private::paused = true

Definition at line 108 of file recorderdocker_dock.cpp.

◆ pausedTimer

QTimer RecorderDockerDock::Private::pausedTimer

Definition at line 112 of file recorderdocker_dock.cpp.

◆ prefix

QString RecorderDockerDock::Private::prefix

Definition at line 96 of file recorderdocker_dock.cpp.

◆ q

RecorderDockerDock* const RecorderDockerDock::Private::q

Definition at line 85 of file recorderdocker_dock.cpp.

◆ quality

int RecorderDockerDock::Private::quality = 0

Definition at line 100 of file recorderdocker_dock.cpp.

◆ realTimeCaptureMode

bool RecorderDockerDock::Private::realTimeCaptureMode = false

Definition at line 103 of file recorderdocker_dock.cpp.

◆ recordAutomatically

bool RecorderDockerDock::Private::recordAutomatically = false

Definition at line 105 of file recorderdocker_dock.cpp.

◆ recordIsolateLayerMode

bool RecorderDockerDock::Private::recordIsolateLayerMode = false

Definition at line 104 of file recorderdocker_dock.cpp.

◆ recordToggleAction

QAction* RecorderDockerDock::Private::recordToggleAction = nullptr

Definition at line 92 of file recorderdocker_dock.cpp.

◆ resolution

int RecorderDockerDock::Private::resolution = 0

Definition at line 102 of file recorderdocker_dock.cpp.

◆ snapshotDirectory

QString RecorderDockerDock::Private::snapshotDirectory

Definition at line 95 of file recorderdocker_dock.cpp.

◆ statusBarLabel

QLabel* RecorderDockerDock::Private::statusBarLabel

Definition at line 115 of file recorderdocker_dock.cpp.

◆ statusBarWarningLabel

QLabel* RecorderDockerDock::Private::statusBarWarningLabel

Definition at line 116 of file recorderdocker_dock.cpp.

◆ threadsSliderPalette

QPalette RecorderDockerDock::Private::threadsSliderPalette

Definition at line 87 of file recorderdocker_dock.cpp.

◆ threadsSpinPalette

QPalette RecorderDockerDock::Private::threadsSpinPalette

Definition at line 88 of file recorderdocker_dock.cpp.

◆ ui

QScopedPointer<Ui::RecorderDocker> RecorderDockerDock::Private::ui

Definition at line 86 of file recorderdocker_dock.cpp.

◆ warningTimer

QTimer RecorderDockerDock::Private::warningTimer

Definition at line 113 of file recorderdocker_dock.cpp.

◆ writer

RecorderWriterManager RecorderDockerDock::Private::writer

Definition at line 90 of file recorderdocker_dock.cpp.


The documentation for this class was generated from the following file: