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< KisCanvas2canvas
 
double captureInterval = 0.
 
int compression = 0
 
QMap< QString, bool > enabledIds
 
QAction * exportAction = nullptr
 
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 65 of file recorderdocker_dock.cpp.

Constructor & Destructor Documentation

◆ Private()

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

Definition at line 101 of file recorderdocker_dock.cpp.

102 : q(q_ptr)
103 , ui(new Ui::RecorderDocker())
104 , writer(es)
105 , statusBarLabel(new QLabel())
106 , statusBarWarningLabel(new QLabel())
107 {
109 statusBarWarningLabel->setPixmap(KisIconUtils::loadIcon("warning").pixmap(16, 16));
110 statusBarWarningLabel->hide();
111 warningTimer.setInterval(10000);
112 warningTimer.setSingleShot(true);
113 pausedTimer.setSingleShot(true);
114 connect(&warningTimer, SIGNAL(timeout()), q, SLOT(onWarningTimeout()));
115 connect(&pausedTimer, SIGNAL(timeout()), q, SLOT(onPausedTimeout()));
116 }
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 120 of file recorderdocker_dock.cpp.

121 {
122 QSize imageSize = canvas->image()->size();
123
124 // We always convert to RGBA8, so can assume 4 bytes/pixel
125 quint64 totalSize = (quint64)imageSize.width() * (quint64)imageSize.height() * 4;
126
127 return totalSize <= 2147483647;
128 }

References canvas.

◆ getPrefix()

QString RecorderDockerDock::Private::getPrefix ( )
inline

Definition at line 250 of file recorderdocker_dock.cpp.

251 {
252 return !canvas ? ""
253 : canvas->imageView()->document()->documentInfo()->aboutInfo("creation-date").remove(QRegularExpression("[^0-9]"));
254 }

References canvas.

◆ loadRelevantExportSettings()

void RecorderDockerDock::Private::loadRelevantExportSettings ( )
inline

◆ loadSettings()

void RecorderDockerDock::Private::loadSettings ( )
inline

Definition at line 130 of file recorderdocker_dock.cpp.

131 {
132 RecorderConfig config(true);
133 snapshotDirectory = config.snapshotDirectory();
134#ifdef Q_OS_ANDROID
135 fixInternalSnapshotDirectory();
136#endif
137 captureInterval = config.captureInterval();
138 format = config.format();
139 quality = config.quality();
140 compression = config.compression();
141 resolution = config.resolution();
142 writer.recorderThreads.set(config.threads());
143 realTimeCaptureMode = config.realTimeCaptureMode();
145 q->exportSettings->lockFps = true;
147 }
148 recordIsolateLayerMode = config.recordIsolateLayerMode();
149 recordAutomatically = config.recordAutomatically();
150
152 }
ThreadCounter recorderThreads
bool set(int value)

References RecorderConfig::captureInterval(), captureInterval, RecorderConfig::compression(), compression, RecorderDockerDock::exportSettings, 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 347 of file recorderdocker_dock.cpp.

347 {
348 if (statusBarWarningLabel->isHidden()) {
349 statusBarWarningLabel->setToolTip(hint);
350 statusBarWarningLabel->show();
351 warningTimer.start();
352 }
353 }

References statusBarWarningLabel, and warningTimer.

◆ updateComboResolution()

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

Definition at line 256 of file recorderdocker_dock.cpp.

257 {
258 const QStringList titles = {
259 i18nc("Use original resolution for the frames when recording the canvas", "Original"),
260 i18nc("Use the resolution two times smaller than the original resolution for the frames when recording the canvas", "Half"),
261 i18nc("Use the resolution four times smaller than the original resolution for the frames when recording the canvas", "Quarter")
262 };
263
264 QStringList items;
265 for (int index = 0, len = titles.length(); index < len; ++index) {
266 int divider = 1 << index;
267 items += QString("%1 (%2x%3)").arg(titles[index])
268 .arg((width / divider) & ~1)
269 .arg((height / divider) & ~1);
270 }
271 QSignalBlocker blocker(ui->comboResolution);
272 const int currentIndex = ui->comboResolution->currentIndex();
273 ui->comboResolution->clear();
274 ui->comboResolution->addItems(items);
275 ui->comboResolution->setCurrentIndex(currentIndex);
276 }

References ui.

◆ updateRecIndicator()

void RecorderDockerDock::Private::updateRecIndicator ( )
inline

Definition at line 314 of file recorderdocker_dock.cpp.

315 {
316 auto threads = writer.recorderThreads.get();
317 auto threadsInUse = writer.recorderThreads.getUsed();
318 QString label("<font style='letter-spacing:-4px'>");
319 QString activeColor;
320 QString inactiveColor;
321 for (unsigned int threadNr = 1; threadNr <= ThreadSystemValue::MaxThreadCount ; threadNr++)
322 {
323 if (threadNr > threads) {
324 activeColor = inactiveColorGray;
325 inactiveColor = inactiveColorGray;
326 } else if (threadNr > ThreadSystemValue::MaxRecordThreadCount) {
327 activeColor = activeColorRed;
328 inactiveColor = inactiveColorRed;
329 } else if (threadNr > ThreadSystemValue::IdealRecordThreadCount) {
330 activeColor = activeColorOrange;
331 inactiveColor = inactiveColorOrange;
332 } else {
333 activeColor = activeColorGreen;
334 inactiveColor = inactiveColorGreen;
335 }
336 label.append(QString("<font%1>▍</font>")
337 .arg(threadNr <= threadsInUse ? activeColor : inactiveColor));
338 }
339 // don't remove empty <font></font> tag else label will jump a few pixels around
340 label.append(QString("</font><font> %1 </font><font%2>●</font>")
341 .arg(i18nc("Recording symbol", "REC"))
342 .arg(paused ? "" : activeColorRed));
343 statusBarLabel->setText(label);
344 statusBarLabel->setToolTip(paused ? i18n("Recorder is paused") : QString(i18n("Active recording with %1 of %2 available threads")).arg(threadsInUse).arg(threads));
345 }
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 278 of file recorderdocker_dock.cpp.

279 {
280 recordToggleAction->setChecked(isRecording);
281 recordToggleAction->setEnabled(true);
282
283 QSignalBlocker blocker(ui->buttonRecordToggle);
284 ui->buttonRecordToggle->setChecked(isRecording);
285 ui->buttonRecordToggle->setIcon(KisIconUtils::loadIcon(isRecording ? "media-playback-stop" : "media-record"));
286 ui->buttonRecordToggle->setText(isRecording ? i18nc("Stop recording the canvas", "Stop")
287 : i18nc("Start recording the canvas", "Record"));
288
289 if (canRecord()) {
290 ui->buttonRecordToggle->setEnabled(true);
291 ui->buttonRecordToggle->setToolTip("");
292 } else {
293 ui->buttonRecordToggle->setEnabled(false);
294 ui->buttonRecordToggle->setToolTip(i18n("Image too large to be recorded"));
295 }
296 ui->widgetSettings->setEnabled(!isRecording);
297
298 statusBarLabel->setVisible(isRecording);
299
300 if (!canvas)
301 return;
302
303 KisStatusBar *statusBar = canvas->viewManager()->statusBar();
304 if (isRecording) {
306 statusBar->addExtraWidget(statusBarLabel);
308 } else {
311 }
312 }
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 355 of file recorderdocker_dock.cpp.

356 {
357 QString toolTipText;
358 auto threads = writer.recorderThreads.get();
360 // Number of threads exceeds ideal thread count
361 // -> switch color of threads slider and spin wheel to red
362 QPalette pal;
363 pal.setColor(QPalette::Text, textColorRed);
364 pal.setColor(QPalette::Button, buttonColorRed);
365 ui->spinThreads->setPalette(pal);
366 ui->sliderThreads->setPalette(pal);
367 toolTipText = QString(
368 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.")
370 } else if (threads > ThreadSystemValue::IdealRecordThreadCount) {
371 // Number of threads exceeds ideal recorder thread count
372 // -> switch color of threads slider and spin wheel to orange
373 QPalette pal;
374 pal.setColor(QPalette::Text, textColorOrange);
375 pal.setColor(QPalette::Button, buttonColorOrange);
376 ui->spinThreads->setPalette(pal);
377 ui->sliderThreads->setPalette(pal);
378 toolTipText = QString(
379 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.")
381 } else {
382 ui->spinThreads->setPalette(threadsSpinPalette);
383 ui->sliderThreads->setPalette(threadsSliderPalette);
384 toolTipText = i18n("Set the number of threads to be used for recording.");
385 }
386 ui->spinThreads->setToolTip(toolTipText);
387 ui->sliderThreads->setToolTip(toolTipText);
388 }

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

◆ updateUiFormat()

void RecorderDockerDock::Private::updateUiFormat ( )
inline

Definition at line 160 of file recorderdocker_dock.cpp.

160 {
161 int index = 0;
162 QString title;
163 QString hint;
164 int minValue = 0;
165 int maxValue = 0;
166 QString suffix;
167 int factor = 0;
168 switch (format) {
170 index = 0;
171 title = i18nc("Title for label. JPEG Quality level", "Quality:");
172 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.");
173 minValue = 1;
174 maxValue = 100;
175 suffix = "%";
176 factor = quality;
177 break;
179 index = 1;
180 title = i18nc("Title for label. PNG Compression level", "Compression:");
181 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.");
182 minValue = 0;
183 maxValue = 5;
184 suffix = "";
185 factor = compression;
186 break;
187 }
188
189 ui->comboFormat->setCurrentIndex(index);
190 ui->labelQuality->setText(title);
191 ui->spinQuality->setToolTip(hint);
192 QSignalBlocker blocker(ui->spinQuality);
193 ui->spinQuality->setMinimum(minValue);
194 ui->spinQuality->setMaximum(maxValue);
195 ui->spinQuality->setValue(factor);
196 ui->spinQuality->setSuffix(suffix);
197 }

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

◆ updateUiForRealTimeMode()

void RecorderDockerDock::Private::updateUiForRealTimeMode ( )
inline

Definition at line 199 of file recorderdocker_dock.cpp.

199 {
200 QString title;
201 double minValue = 0;
202 double maxValue = 0;
203 double value = 0;
204 int decimals = 0;
205 QString suffix;
206 QSignalBlocker blocker(ui->spinRate);
207
209 title = i18nc("Title for label. Video frames per second", "Video FPS:");
210 minValue = 1;
211 maxValue = 60;
212 decimals = 0;
214 suffix = "";
215 disconnect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onCaptureIntervalChanged(double)));
216 connect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onVideoFPSChanged(double)));
217 } else {
218 title = i18nc("Title for label. Capture rate", "Capture interval:");
219 minValue = 0.10;
220 maxValue = 100.0;
221 decimals = 1;
223 suffix = " sec.";
224 disconnect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onVideoFPSChanged(double)));
225 connect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onCaptureIntervalChanged(double)));
226 }
227
228 ui->labelRate->setText(title);
229 ui->spinRate->setDecimals(decimals);
230 ui->spinRate->setMinimum(minValue);
231 ui->spinRate->setMaximum(maxValue);
232 ui->spinRate->setSuffix(suffix);
233 ui->spinRate->setValue(value);
234 }
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 72 of file recorderdocker_dock.cpp.

◆ captureInterval

double RecorderDockerDock::Private::captureInterval = 0.

Definition at line 81 of file recorderdocker_dock.cpp.

◆ compression

int RecorderDockerDock::Private::compression = 0

Definition at line 84 of file recorderdocker_dock.cpp.

◆ enabledIds

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

Definition at line 99 of file recorderdocker_dock.cpp.

◆ exportAction

QAction* RecorderDockerDock::Private::exportAction = nullptr

Definition at line 76 of file recorderdocker_dock.cpp.

◆ format

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

Definition at line 82 of file recorderdocker_dock.cpp.

◆ outputDirectory

QString RecorderDockerDock::Private::outputDirectory

Definition at line 80 of file recorderdocker_dock.cpp.

◆ paused

bool RecorderDockerDock::Private::paused = true

Definition at line 89 of file recorderdocker_dock.cpp.

◆ pausedTimer

QTimer RecorderDockerDock::Private::pausedTimer

Definition at line 93 of file recorderdocker_dock.cpp.

◆ prefix

QString RecorderDockerDock::Private::prefix

Definition at line 79 of file recorderdocker_dock.cpp.

◆ q

RecorderDockerDock* const RecorderDockerDock::Private::q

Definition at line 68 of file recorderdocker_dock.cpp.

◆ quality

int RecorderDockerDock::Private::quality = 0

Definition at line 83 of file recorderdocker_dock.cpp.

◆ realTimeCaptureMode

bool RecorderDockerDock::Private::realTimeCaptureMode = false

Definition at line 86 of file recorderdocker_dock.cpp.

◆ recordAutomatically

bool RecorderDockerDock::Private::recordAutomatically = false

Definition at line 88 of file recorderdocker_dock.cpp.

◆ recordIsolateLayerMode

bool RecorderDockerDock::Private::recordIsolateLayerMode = false

Definition at line 87 of file recorderdocker_dock.cpp.

◆ recordToggleAction

QAction* RecorderDockerDock::Private::recordToggleAction = nullptr

Definition at line 75 of file recorderdocker_dock.cpp.

◆ resolution

int RecorderDockerDock::Private::resolution = 0

Definition at line 85 of file recorderdocker_dock.cpp.

◆ snapshotDirectory

QString RecorderDockerDock::Private::snapshotDirectory

Definition at line 78 of file recorderdocker_dock.cpp.

◆ statusBarLabel

QLabel* RecorderDockerDock::Private::statusBarLabel

Definition at line 96 of file recorderdocker_dock.cpp.

◆ statusBarWarningLabel

QLabel* RecorderDockerDock::Private::statusBarWarningLabel

Definition at line 97 of file recorderdocker_dock.cpp.

◆ threadsSliderPalette

QPalette RecorderDockerDock::Private::threadsSliderPalette

Definition at line 70 of file recorderdocker_dock.cpp.

◆ threadsSpinPalette

QPalette RecorderDockerDock::Private::threadsSpinPalette

Definition at line 71 of file recorderdocker_dock.cpp.

◆ ui

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

Definition at line 69 of file recorderdocker_dock.cpp.

◆ warningTimer

QTimer RecorderDockerDock::Private::warningTimer

Definition at line 94 of file recorderdocker_dock.cpp.

◆ writer

RecorderWriterManager RecorderDockerDock::Private::writer

Definition at line 73 of file recorderdocker_dock.cpp.


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