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

Public Member Functions

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 59 of file recorderdocker_dock.cpp.

Constructor & Destructor Documentation

◆ Private()

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

Definition at line 92 of file recorderdocker_dock.cpp.

93 : q(q_ptr)
94 , ui(new Ui::RecorderDocker())
95 , writer(es)
96 , statusBarLabel(new QLabel())
97 , statusBarWarningLabel(new QLabel())
98 {
100 statusBarWarningLabel->setPixmap(KisIconUtils::loadIcon("warning").pixmap(16, 16));
101 statusBarWarningLabel->hide();
102 warningTimer.setInterval(10000);
103 warningTimer.setSingleShot(true);
104 pausedTimer.setSingleShot(true);
105 connect(&warningTimer, SIGNAL(timeout()), q, SLOT(onWarningTimeout()));
106 connect(&pausedTimer, SIGNAL(timeout()), q, SLOT(onPausedTimeout()));
107 }
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
QScopedPointer< Ui::RecorderDocker > ui
RecorderDockerDock *const q
QIcon loadIcon(const QString &name)

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

Member Function Documentation

◆ getPrefix()

QString RecorderDockerDock::Private::getPrefix ( )
inline

Definition at line 226 of file recorderdocker_dock.cpp.

227 {
228 return !canvas ? ""
229 : canvas->imageView()->document()->documentInfo()->aboutInfo("creation-date").remove(QRegularExpression("[^0-9]"));
230 }

References canvas.

◆ loadRelevantExportSettings()

void RecorderDockerDock::Private::loadRelevantExportSettings ( )
inline

◆ loadSettings()

void RecorderDockerDock::Private::loadSettings ( )
inline

Definition at line 109 of file recorderdocker_dock.cpp.

110 {
111 RecorderConfig config(true);
112 snapshotDirectory = config.snapshotDirectory();
113 captureInterval = config.captureInterval();
114 format = config.format();
115 quality = config.quality();
116 compression = config.compression();
117 resolution = config.resolution();
118 writer.recorderThreads.set(config.threads());
119 realTimeCaptureMode = config.realTimeCaptureMode();
121 q->exportSettings->lockFps = true;
123 }
124 recordIsolateLayerMode = config.recordIsolateLayerMode();
125 recordAutomatically = config.recordAutomatically();
126
128 }
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 317 of file recorderdocker_dock.cpp.

317 {
318 if (statusBarWarningLabel->isHidden()) {
319 statusBarWarningLabel->setToolTip(hint);
320 statusBarWarningLabel->show();
321 warningTimer.start();
322 }
323 }

References statusBarWarningLabel, and warningTimer.

◆ updateComboResolution()

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

Definition at line 232 of file recorderdocker_dock.cpp.

233 {
234 const QStringList titles = {
235 i18nc("Use original resolution for the frames when recording the canvas", "Original"),
236 i18nc("Use the resolution two times smaller than the original resolution for the frames when recording the canvas", "Half"),
237 i18nc("Use the resolution four times smaller than the original resolution for the frames when recording the canvas", "Quarter")
238 };
239
240 QStringList items;
241 for (int index = 0, len = titles.length(); index < len; ++index) {
242 int divider = 1 << index;
243 items += QString("%1 (%2x%3)").arg(titles[index])
244 .arg((width / divider) & ~1)
245 .arg((height / divider) & ~1);
246 }
247 QSignalBlocker blocker(ui->comboResolution);
248 const int currentIndex = ui->comboResolution->currentIndex();
249 ui->comboResolution->clear();
250 ui->comboResolution->addItems(items);
251 ui->comboResolution->setCurrentIndex(currentIndex);
252 }

References ui.

◆ updateRecIndicator()

void RecorderDockerDock::Private::updateRecIndicator ( )
inline

Definition at line 284 of file recorderdocker_dock.cpp.

285 {
286 auto threads = writer.recorderThreads.get();
287 auto threadsInUse = writer.recorderThreads.getUsed();
288 QString label("<font style='letter-spacing:-4px'>");
289 QString activeColor;
290 QString inactiveColor;
291 for (unsigned int threadNr = 1; threadNr <= ThreadSystemValue::MaxThreadCount ; threadNr++)
292 {
293 if (threadNr > threads) {
294 activeColor = inactiveColorGray;
295 inactiveColor = inactiveColorGray;
296 } else if (threadNr > ThreadSystemValue::MaxRecordThreadCount) {
297 activeColor = activeColorRed;
298 inactiveColor = inactiveColorRed;
299 } else if (threadNr > ThreadSystemValue::IdealRecordThreadCount) {
300 activeColor = activeColorOrange;
301 inactiveColor = inactiveColorOrange;
302 } else {
303 activeColor = activeColorGreen;
304 inactiveColor = inactiveColorGreen;
305 }
306 label.append(QString("<font%1>▍</font>")
307 .arg(threadNr <= threadsInUse ? activeColor : inactiveColor));
308 }
309 // don't remove empty <font></font> tag else label will jump a few pixels around
310 label.append(QString("</font><font> %1 </font><font%2>●</font>")
311 .arg(i18nc("Recording symbol", "REC"))
312 .arg(paused ? "" : activeColorRed));
313 statusBarLabel->setText(label);
314 statusBarLabel->setToolTip(paused ? i18n("Recorder is paused") : QString(i18n("Active recording with %1 of %2 available threads")).arg(threadsInUse).arg(threads));
315 }
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 254 of file recorderdocker_dock.cpp.

255 {
256 recordToggleAction->setChecked(isRecording);
257 recordToggleAction->setEnabled(true);
258
259 QSignalBlocker blocker(ui->buttonRecordToggle);
260 ui->buttonRecordToggle->setChecked(isRecording);
261 ui->buttonRecordToggle->setIcon(KisIconUtils::loadIcon(isRecording ? "media-playback-stop" : "media-record"));
262 ui->buttonRecordToggle->setText(isRecording ? i18nc("Stop recording the canvas", "Stop")
263 : i18nc("Start recording the canvas", "Record"));
264 ui->buttonRecordToggle->setEnabled(true);
265
266 ui->widgetSettings->setEnabled(!isRecording);
267
268 statusBarLabel->setVisible(isRecording);
269
270 if (!canvas)
271 return;
272
273 KisStatusBar *statusBar = canvas->viewManager()->statusBar();
274 if (isRecording) {
276 statusBar->addExtraWidget(statusBarLabel);
278 } else {
281 }
282 }
void removeExtraWidget(QWidget *widget)
void addExtraWidget(QWidget *widget)

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

◆ updateThreadUi()

void RecorderDockerDock::Private::updateThreadUi ( )
inline

Definition at line 325 of file recorderdocker_dock.cpp.

326 {
327 QString toolTipText;
328 auto threads = writer.recorderThreads.get();
330 // Number of threads exceeds ideal thread count
331 // -> switch color of threads slider and spin wheel to red
332 QPalette pal;
333 pal.setColor(QPalette::Text, textColorRed);
334 pal.setColor(QPalette::Button, buttonColorRed);
335 ui->spinThreads->setPalette(pal);
336 ui->sliderThreads->setPalette(pal);
337 toolTipText = QString(
338 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.")
340 } else if (threads > ThreadSystemValue::IdealRecordThreadCount) {
341 // Number of threads exceeds ideal recorder thread count
342 // -> switch color of threads slider and spin wheel to orange
343 QPalette pal;
344 pal.setColor(QPalette::Text, textColorOrange);
345 pal.setColor(QPalette::Button, buttonColorOrange);
346 ui->spinThreads->setPalette(pal);
347 ui->sliderThreads->setPalette(pal);
348 toolTipText = QString(
349 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.")
351 } else {
352 ui->spinThreads->setPalette(threadsSpinPalette);
353 ui->sliderThreads->setPalette(threadsSliderPalette);
354 toolTipText = i18n("Set the number of threads to be used for recording.");
355 }
356 ui->spinThreads->setToolTip(toolTipText);
357 ui->sliderThreads->setToolTip(toolTipText);
358 }

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

◆ updateUiFormat()

void RecorderDockerDock::Private::updateUiFormat ( )
inline

Definition at line 136 of file recorderdocker_dock.cpp.

136 {
137 int index = 0;
138 QString title;
139 QString hint;
140 int minValue = 0;
141 int maxValue = 0;
142 QString suffix;
143 int factor = 0;
144 switch (format) {
146 index = 0;
147 title = i18nc("Title for label. JPEG Quality level", "Quality:");
148 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.");
149 minValue = 1;
150 maxValue = 100;
151 suffix = "%";
152 factor = quality;
153 break;
155 index = 1;
156 title = i18nc("Title for label. PNG Compression level", "Compression:");
157 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.");
158 minValue = 0;
159 maxValue = 5;
160 suffix = "";
161 factor = compression;
162 break;
163 }
164
165 ui->comboFormat->setCurrentIndex(index);
166 ui->labelQuality->setText(title);
167 ui->spinQuality->setToolTip(hint);
168 QSignalBlocker blocker(ui->spinQuality);
169 ui->spinQuality->setMinimum(minValue);
170 ui->spinQuality->setMaximum(maxValue);
171 ui->spinQuality->setValue(factor);
172 ui->spinQuality->setSuffix(suffix);
173 }

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

◆ updateUiForRealTimeMode()

void RecorderDockerDock::Private::updateUiForRealTimeMode ( )
inline

Definition at line 175 of file recorderdocker_dock.cpp.

175 {
176 QString title;
177 double minValue = 0;
178 double maxValue = 0;
179 double value = 0;
180 int decimals = 0;
181 QString suffix;
182 QSignalBlocker blocker(ui->spinRate);
183
185 title = i18nc("Title for label. Video frames per second", "Video FPS:");
186 minValue = 1;
187 maxValue = 60;
188 decimals = 0;
190 suffix = "";
191 disconnect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onCaptureIntervalChanged(double)));
192 connect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onVideoFPSChanged(double)));
193 } else {
194 title = i18nc("Title for label. Capture rate", "Capture interval:");
195 minValue = 0.10;
196 maxValue = 100.0;
197 decimals = 1;
199 suffix = " sec.";
200 disconnect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onVideoFPSChanged(double)));
201 connect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onCaptureIntervalChanged(double)));
202 }
203
204 ui->labelRate->setText(title);
205 ui->spinRate->setDecimals(decimals);
206 ui->spinRate->setMinimum(minValue);
207 ui->spinRate->setMaximum(maxValue);
208 ui->spinRate->setSuffix(suffix);
209 ui->spinRate->setValue(value);
210 }
float value(const T *src, size_t ch)
void onCaptureIntervalChanged(double interval)
void onVideoFPSChanged(double interval)

References captureInterval, connect(), 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 66 of file recorderdocker_dock.cpp.

◆ captureInterval

double RecorderDockerDock::Private::captureInterval = 0.

Definition at line 75 of file recorderdocker_dock.cpp.

◆ compression

int RecorderDockerDock::Private::compression = 0

Definition at line 78 of file recorderdocker_dock.cpp.

◆ enabledIds

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

Definition at line 90 of file recorderdocker_dock.cpp.

◆ exportAction

QAction* RecorderDockerDock::Private::exportAction = nullptr

Definition at line 70 of file recorderdocker_dock.cpp.

◆ format

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

Definition at line 76 of file recorderdocker_dock.cpp.

◆ outputDirectory

QString RecorderDockerDock::Private::outputDirectory

Definition at line 74 of file recorderdocker_dock.cpp.

◆ paused

bool RecorderDockerDock::Private::paused = true

Definition at line 83 of file recorderdocker_dock.cpp.

◆ pausedTimer

QTimer RecorderDockerDock::Private::pausedTimer

Definition at line 84 of file recorderdocker_dock.cpp.

◆ prefix

QString RecorderDockerDock::Private::prefix

Definition at line 73 of file recorderdocker_dock.cpp.

◆ q

RecorderDockerDock* const RecorderDockerDock::Private::q

Definition at line 62 of file recorderdocker_dock.cpp.

◆ quality

int RecorderDockerDock::Private::quality = 0

Definition at line 77 of file recorderdocker_dock.cpp.

◆ realTimeCaptureMode

bool RecorderDockerDock::Private::realTimeCaptureMode = false

Definition at line 80 of file recorderdocker_dock.cpp.

◆ recordAutomatically

bool RecorderDockerDock::Private::recordAutomatically = false

Definition at line 82 of file recorderdocker_dock.cpp.

◆ recordIsolateLayerMode

bool RecorderDockerDock::Private::recordIsolateLayerMode = false

Definition at line 81 of file recorderdocker_dock.cpp.

◆ recordToggleAction

QAction* RecorderDockerDock::Private::recordToggleAction = nullptr

Definition at line 69 of file recorderdocker_dock.cpp.

◆ resolution

int RecorderDockerDock::Private::resolution = 0

Definition at line 79 of file recorderdocker_dock.cpp.

◆ snapshotDirectory

QString RecorderDockerDock::Private::snapshotDirectory

Definition at line 72 of file recorderdocker_dock.cpp.

◆ statusBarLabel

QLabel* RecorderDockerDock::Private::statusBarLabel

Definition at line 87 of file recorderdocker_dock.cpp.

◆ statusBarWarningLabel

QLabel* RecorderDockerDock::Private::statusBarWarningLabel

Definition at line 88 of file recorderdocker_dock.cpp.

◆ threadsSliderPalette

QPalette RecorderDockerDock::Private::threadsSliderPalette

Definition at line 64 of file recorderdocker_dock.cpp.

◆ threadsSpinPalette

QPalette RecorderDockerDock::Private::threadsSpinPalette

Definition at line 65 of file recorderdocker_dock.cpp.

◆ ui

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

Definition at line 63 of file recorderdocker_dock.cpp.

◆ warningTimer

QTimer RecorderDockerDock::Private::warningTimer

Definition at line 85 of file recorderdocker_dock.cpp.

◆ writer

RecorderWriterManager RecorderDockerDock::Private::writer

Definition at line 67 of file recorderdocker_dock.cpp.


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