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 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

◆ getPrefix()

QString RecorderDockerDock::Private::getPrefix ( )
inline

Definition at line 238 of file recorderdocker_dock.cpp.

239 {
240 return !canvas ? ""
241 : canvas->imageView()->document()->documentInfo()->aboutInfo("creation-date").remove(QRegularExpression("[^0-9]"));
242 }

References canvas.

◆ loadRelevantExportSettings()

void RecorderDockerDock::Private::loadRelevantExportSettings ( )
inline

◆ loadSettings()

void RecorderDockerDock::Private::loadSettings ( )
inline

Definition at line 118 of file recorderdocker_dock.cpp.

119 {
120 RecorderConfig config(true);
121 snapshotDirectory = config.snapshotDirectory();
122#ifdef Q_OS_ANDROID
123 fixInternalSnapshotDirectory();
124#endif
125 captureInterval = config.captureInterval();
126 format = config.format();
127 quality = config.quality();
128 compression = config.compression();
129 resolution = config.resolution();
130 writer.recorderThreads.set(config.threads());
131 realTimeCaptureMode = config.realTimeCaptureMode();
133 q->exportSettings->lockFps = true;
135 }
136 recordIsolateLayerMode = config.recordIsolateLayerMode();
137 recordAutomatically = config.recordAutomatically();
138
140 }
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 329 of file recorderdocker_dock.cpp.

329 {
330 if (statusBarWarningLabel->isHidden()) {
331 statusBarWarningLabel->setToolTip(hint);
332 statusBarWarningLabel->show();
333 warningTimer.start();
334 }
335 }

References statusBarWarningLabel, and warningTimer.

◆ updateComboResolution()

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

Definition at line 244 of file recorderdocker_dock.cpp.

245 {
246 const QStringList titles = {
247 i18nc("Use original resolution for the frames when recording the canvas", "Original"),
248 i18nc("Use the resolution two times smaller than the original resolution for the frames when recording the canvas", "Half"),
249 i18nc("Use the resolution four times smaller than the original resolution for the frames when recording the canvas", "Quarter")
250 };
251
252 QStringList items;
253 for (int index = 0, len = titles.length(); index < len; ++index) {
254 int divider = 1 << index;
255 items += QString("%1 (%2x%3)").arg(titles[index])
256 .arg((width / divider) & ~1)
257 .arg((height / divider) & ~1);
258 }
259 QSignalBlocker blocker(ui->comboResolution);
260 const int currentIndex = ui->comboResolution->currentIndex();
261 ui->comboResolution->clear();
262 ui->comboResolution->addItems(items);
263 ui->comboResolution->setCurrentIndex(currentIndex);
264 }

References ui.

◆ updateRecIndicator()

void RecorderDockerDock::Private::updateRecIndicator ( )
inline

Definition at line 296 of file recorderdocker_dock.cpp.

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

267 {
268 recordToggleAction->setChecked(isRecording);
269 recordToggleAction->setEnabled(true);
270
271 QSignalBlocker blocker(ui->buttonRecordToggle);
272 ui->buttonRecordToggle->setChecked(isRecording);
273 ui->buttonRecordToggle->setIcon(KisIconUtils::loadIcon(isRecording ? "media-playback-stop" : "media-record"));
274 ui->buttonRecordToggle->setText(isRecording ? i18nc("Stop recording the canvas", "Stop")
275 : i18nc("Start recording the canvas", "Record"));
276 ui->buttonRecordToggle->setEnabled(true);
277
278 ui->widgetSettings->setEnabled(!isRecording);
279
280 statusBarLabel->setVisible(isRecording);
281
282 if (!canvas)
283 return;
284
285 KisStatusBar *statusBar = canvas->viewManager()->statusBar();
286 if (isRecording) {
288 statusBar->addExtraWidget(statusBarLabel);
290 } else {
293 }
294 }
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 337 of file recorderdocker_dock.cpp.

338 {
339 QString toolTipText;
340 auto threads = writer.recorderThreads.get();
342 // Number of threads exceeds ideal thread count
343 // -> switch color of threads slider and spin wheel to red
344 QPalette pal;
345 pal.setColor(QPalette::Text, textColorRed);
346 pal.setColor(QPalette::Button, buttonColorRed);
347 ui->spinThreads->setPalette(pal);
348 ui->sliderThreads->setPalette(pal);
349 toolTipText = QString(
350 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.")
352 } else if (threads > ThreadSystemValue::IdealRecordThreadCount) {
353 // Number of threads exceeds ideal recorder thread count
354 // -> switch color of threads slider and spin wheel to orange
355 QPalette pal;
356 pal.setColor(QPalette::Text, textColorOrange);
357 pal.setColor(QPalette::Button, buttonColorOrange);
358 ui->spinThreads->setPalette(pal);
359 ui->sliderThreads->setPalette(pal);
360 toolTipText = QString(
361 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.")
363 } else {
364 ui->spinThreads->setPalette(threadsSpinPalette);
365 ui->sliderThreads->setPalette(threadsSliderPalette);
366 toolTipText = i18n("Set the number of threads to be used for recording.");
367 }
368 ui->spinThreads->setToolTip(toolTipText);
369 ui->sliderThreads->setToolTip(toolTipText);
370 }

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

◆ updateUiFormat()

void RecorderDockerDock::Private::updateUiFormat ( )
inline

Definition at line 148 of file recorderdocker_dock.cpp.

148 {
149 int index = 0;
150 QString title;
151 QString hint;
152 int minValue = 0;
153 int maxValue = 0;
154 QString suffix;
155 int factor = 0;
156 switch (format) {
158 index = 0;
159 title = i18nc("Title for label. JPEG Quality level", "Quality:");
160 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.");
161 minValue = 1;
162 maxValue = 100;
163 suffix = "%";
164 factor = quality;
165 break;
167 index = 1;
168 title = i18nc("Title for label. PNG Compression level", "Compression:");
169 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.");
170 minValue = 0;
171 maxValue = 5;
172 suffix = "";
173 factor = compression;
174 break;
175 }
176
177 ui->comboFormat->setCurrentIndex(index);
178 ui->labelQuality->setText(title);
179 ui->spinQuality->setToolTip(hint);
180 QSignalBlocker blocker(ui->spinQuality);
181 ui->spinQuality->setMinimum(minValue);
182 ui->spinQuality->setMaximum(maxValue);
183 ui->spinQuality->setValue(factor);
184 ui->spinQuality->setSuffix(suffix);
185 }

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

◆ updateUiForRealTimeMode()

void RecorderDockerDock::Private::updateUiForRealTimeMode ( )
inline

Definition at line 187 of file recorderdocker_dock.cpp.

187 {
188 QString title;
189 double minValue = 0;
190 double maxValue = 0;
191 double value = 0;
192 int decimals = 0;
193 QString suffix;
194 QSignalBlocker blocker(ui->spinRate);
195
197 title = i18nc("Title for label. Video frames per second", "Video FPS:");
198 minValue = 1;
199 maxValue = 60;
200 decimals = 0;
202 suffix = "";
203 disconnect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onCaptureIntervalChanged(double)));
204 connect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onVideoFPSChanged(double)));
205 } else {
206 title = i18nc("Title for label. Capture rate", "Capture interval:");
207 minValue = 0.10;
208 maxValue = 100.0;
209 decimals = 1;
211 suffix = " sec.";
212 disconnect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onVideoFPSChanged(double)));
213 connect(ui->spinRate, SIGNAL(valueChanged(double)), q, SLOT(onCaptureIntervalChanged(double)));
214 }
215
216 ui->labelRate->setText(title);
217 ui->spinRate->setDecimals(decimals);
218 ui->spinRate->setMinimum(minValue);
219 ui->spinRate->setMaximum(maxValue);
220 ui->spinRate->setSuffix(suffix);
221 ui->spinRate->setValue(value);
222 }
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: