1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "recmonitor.h"
23 #include "kdenlivesettings.h"
24 #include "managecapturesdialog.h"
29 #include <KStandardDirs>
31 #include <KIO/NetAccess>
33 #include <KDiskFreeSpaceInfo>
35 #include <QMouseEvent>
37 #include <QToolButton>
42 RecMonitor::RecMonitor(QString name, QWidget *parent) :
52 m_ui.video_frame->setAttribute(Qt::WA_PaintOnScreen);
53 m_ui.device_selector->setCurrentIndex(KdenliveSettings::defaultcapture());
54 connect(m_ui.device_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(slotVideoDeviceChanged(int)));
58 QToolBar *toolbar = new QToolBar(name, this);
59 QHBoxLayout *layout = new QHBoxLayout;
60 layout->setContentsMargins(0, 0, 0, 0);
61 m_playIcon = KIcon("media-playback-start");
62 m_pauseIcon = KIcon("media-playback-pause");
64 m_discAction = toolbar->addAction(KIcon("network-connect"), i18n("Connect"));
65 connect(m_discAction, SIGNAL(triggered()), this, SLOT(slotDisconnect()));
67 m_rewAction = toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind"));
68 connect(m_rewAction, SIGNAL(triggered()), this, SLOT(slotRewind()));
70 m_playAction = toolbar->addAction(m_playIcon, i18n("Play"));
71 connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotStartCapture()));
73 m_stopAction = toolbar->addAction(KIcon("media-playback-stop"), i18n("Stop"));
74 connect(m_stopAction, SIGNAL(triggered()), this, SLOT(slotStopCapture()));
75 m_stopAction->setEnabled(false);
76 m_fwdAction = toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward"));
77 connect(m_fwdAction, SIGNAL(triggered()), this, SLOT(slotForward()));
79 m_recAction = toolbar->addAction(KIcon("media-record"), i18n("Record"));
80 connect(m_recAction, SIGNAL(triggered()), this, SLOT(slotRecord()));
81 m_recAction->setCheckable(true);
83 toolbar->addSeparator();
85 QAction *configAction = toolbar->addAction(KIcon("configure"), i18n("Configure"));
86 connect(configAction, SIGNAL(triggered()), this, SLOT(slotConfigure()));
87 configAction->setCheckable(false);
89 layout->addWidget(toolbar);
91 #if KDE_IS_VERSION(4,2,0)
92 m_freeSpace = new KCapacityBar(KCapacityBar::DrawTextInline, this);
93 m_freeSpace->setMaximumWidth(150);
94 QFontMetricsF fontMetrics(font());
95 m_freeSpace->setMaximumHeight(fontMetrics.height() * 1.5);
96 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
97 if( info.isValid() ) {
98 m_freeSpace->setValue(100 * info.used() / info.size());
99 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
100 m_freeSpace->update();
103 layout->addWidget(m_freeSpace);
106 m_ui.control_frame_firewire->setLayout(layout);
108 slotVideoDeviceChanged(m_ui.device_selector->currentIndex());
109 m_displayProcess = new QProcess;
110 m_captureProcess = new QProcess;
112 connect(m_captureProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(slotProcessStatus(QProcess::ProcessState)));
114 QStringList env = QProcess::systemEnvironment();
115 env << "SDL_WINDOWID=" + QString::number(m_ui.video_frame->winId());
117 QString videoDriver = KdenliveSettings::videodrivername();
118 if (!videoDriver.isEmpty()) {
119 if (videoDriver == "x11_noaccel") {
120 env << "SDL_VIDEO_YUV_HWACCEL=0";
121 env << "SDL_VIDEODRIVER=x11";
122 } else env << "SDL_VIDEODRIVER=" + videoDriver;
124 setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 1);
126 m_displayProcess->setEnvironment(env);
128 if (KdenliveSettings::video4capture().isEmpty()) {
129 QString captureCommand;
130 if (!KdenliveSettings::video4adevice().isEmpty()) captureCommand = "-f " + KdenliveSettings::video4aformat() + " -i " + KdenliveSettings::video4adevice();
132 captureCommand += " -f " + KdenliveSettings::video4vformat() + " -s " + KdenliveSettings::video4size() + " -r " + QString::number(KdenliveSettings::video4rate()) + " -i " + KdenliveSettings::video4vdevice();
133 KdenliveSettings::setVideo4capture(captureCommand);
136 kDebug() << "/////// BUILDING MONITOR, ID: " << m_ui.video_frame->winId();
139 RecMonitor::~RecMonitor()
141 delete m_captureProcess;
142 delete m_displayProcess;
145 QString RecMonitor::name() const
150 void RecMonitor::slotConfigure()
152 emit showConfigDialog(4, m_ui.device_selector->currentIndex());
155 void RecMonitor::slotUpdateCaptureFolder()
157 if (m_captureProcess) m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
158 slotVideoDeviceChanged(m_ui.device_selector->currentIndex());
159 kDebug()<<"// UPDATE CAPT FOLD: "<<KdenliveSettings::capturefolder();
161 #if KDE_IS_VERSION(4,2,0)
162 // update free space info
163 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
164 if( info.isValid() ) {
165 m_freeSpace->setValue(100 * info.used() / info.size());
166 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
167 m_freeSpace->update();
172 void RecMonitor::slotVideoDeviceChanged(int ix)
176 m_discAction->setEnabled(false);
177 m_rewAction->setEnabled(false);
178 m_fwdAction->setEnabled(false);
179 m_recAction->setEnabled(true);
180 m_stopAction->setEnabled(false);
181 m_playAction->setEnabled(false);
182 if (KdenliveSettings::rmd_path().isEmpty()) {
183 QString rmdpath = KStandardDirs::findExe("recordmydesktop");
184 if (rmdpath.isEmpty()) m_ui.video_frame->setPixmap(mergeSideBySide(KIcon("dialog-warning").pixmap(QSize(50, 50)), i18n("Recordmydesktop utility not found,\n please install it for screen grabs")));
185 else KdenliveSettings::setRmd_path(rmdpath);
187 if (!KdenliveSettings::rmd_path().isEmpty()) m_ui.video_frame->setPixmap(mergeSideBySide(KIcon("video-display").pixmap(QSize(50, 50)), i18n("Press record button\nto start screen capture\nFiles will be saved in:\n%1", KdenliveSettings::capturefolder())));
188 //m_ui.video_frame->setText(i18n("Press record button\nto start screen capture"));
191 m_discAction->setEnabled(false);
192 m_rewAction->setEnabled(false);
193 m_fwdAction->setEnabled(false);
194 m_recAction->setEnabled(true);
195 m_stopAction->setEnabled(false);
196 m_playAction->setEnabled(true);
197 checkDeviceAvailability();
200 m_discAction->setEnabled(true);
201 m_recAction->setEnabled(false);
202 m_stopAction->setEnabled(false);
203 m_playAction->setEnabled(false);
204 m_rewAction->setEnabled(false);
205 m_fwdAction->setEnabled(false);
206 //m_ui.video_frame->setText(i18n("Plug your camcorder and\npress connect button\nto initialize connection"));
207 if (KdenliveSettings::dvgrab_path().isEmpty()) {
208 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
209 if (dvgrabpath.isEmpty()) m_ui.video_frame->setPixmap(mergeSideBySide(KIcon("dialog-warning").pixmap(QSize(50, 50)), i18n("dvgrab utility not found,\n please install it for firewire capture")));
210 else KdenliveSettings::setDvgrab_path(dvgrabpath);
213 if (!KdenliveSettings::dvgrab_path().isEmpty()) m_ui.video_frame->setPixmap(mergeSideBySide(KIcon("network-connect").pixmap(QSize(50, 50)), i18n("Plug your camcorder and\npress connect button\nto initialize connection\nFiles will be saved in:\n%1", KdenliveSettings::capturefolder())));
218 QPixmap RecMonitor::mergeSideBySide(const QPixmap& pix, const QString txt)
221 QRect r = QApplication::fontMetrics().boundingRect(QRect(0, 0, m_ui.video_frame->width(), m_ui.video_frame->height()), Qt::AlignLeft, txt);
222 int strWidth = r.width();
223 int strHeight = r.height();
224 int pixWidth = pix.width();
225 int pixHeight = pix.height();
226 QPixmap res(strWidth + 8 + pixWidth, qMax(strHeight, pixHeight));
227 res.fill(Qt::transparent);
229 p.drawPixmap(0, 0, pix);
230 p.drawText(QRect(pixWidth + 8, 0, strWidth, strHeight), 0, txt);
236 void RecMonitor::checkDeviceAvailability()
238 if (!KIO::NetAccess::exists(KUrl(KdenliveSettings::video4vdevice()), KIO::NetAccess::SourceSide , this)) {
239 m_playAction->setEnabled(false);
240 m_recAction->setEnabled(false);
241 m_ui.video_frame->setPixmap(mergeSideBySide(KIcon("camera-web").pixmap(QSize(50, 50)), i18n("Cannot read from device %1\nPlease check drivers and access rights.", KdenliveSettings::video4vdevice())));
242 //m_ui.video_frame->setText(i18n("Cannot read from device %1\nPlease check drivers and access rights.", KdenliveSettings::video4vdevice()));
243 } else //m_ui.video_frame->setText(i18n("Press play or record button\nto start video capture"));
244 m_ui.video_frame->setPixmap(mergeSideBySide(KIcon("camera-web").pixmap(QSize(50, 50)), i18n("Press play or record button\nto start video capture\nFiles will be saved in:\n%1", KdenliveSettings::capturefolder())));
247 void RecMonitor::slotDisconnect()
249 if (m_captureProcess->state() == QProcess::NotRunning) {
250 m_captureTime = KDateTime::currentLocalDateTime();
251 kDebug() << "CURRENT TIME: " << m_captureTime.toString();
252 m_didCapture = false;
253 slotStartCapture(false);
254 m_discAction->setIcon(KIcon("network-disconnect"));
255 m_discAction->setText(i18n("Disonnect"));
256 m_recAction->setEnabled(true);
257 m_stopAction->setEnabled(true);
258 m_playAction->setEnabled(true);
259 m_rewAction->setEnabled(true);
260 m_fwdAction->setEnabled(true);
262 m_captureProcess->write("q", 1);
263 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
264 if (m_didCapture) manageCapturedFiles();
265 m_didCapture = false;
269 void RecMonitor::slotRewind()
271 m_captureProcess->write("a", 1);
274 void RecMonitor::slotForward()
276 m_captureProcess->write("z", 1);
279 void RecMonitor::slotStopCapture()
282 switch (m_ui.device_selector->currentIndex()) {
284 m_captureProcess->write("\e", 2);
285 m_playAction->setIcon(m_playIcon);
289 m_captureProcess->write("q\n", 3);
290 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
294 m_captureProcess->write("q\n", 3);
295 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
302 void RecMonitor::slotStartCapture(bool play)
306 *captureProcess<<"dvgrab";
310 switch (m_recPanel->capture_format->currentItem()){
312 *captureProcess<<"--format"<<"dv1";
315 *captureProcess<<"--format"<<"dv2";
318 *captureProcess<<"--format"<<"hdv";
322 *captureProcess<<"--format"<<"raw";
326 if (KdenliveSettings::autosplit()) *captureProcess<<"--autosplit";
327 if (KdenliveSettings::timestamp()) *captureProcess<<"--timestamp";
328 *captureProcess<<"-i"<<"capture"<<"-";*/
331 QStringList captureArgs;
332 captureArgs<<"--format"<<"hdv"<<"-i"<<"capture"<<"-";
333 QStringList displayArgs;
335 displayArgs<<"-f"<<"mpegts"<<"-x"<<QString::number(m_ui.video_frame->width())<<"-y"<<QString::number(m_ui.video_frame->height())<<"-";
337 captureProcess->setStandardOutputProcess(displayProcess);
338 m_ui.video_frame->setScaledContents(false);
339 captureProcess->start("dvgrab",captureArgs);
340 displayProcess->start("ffplay", displayArgs);*/
343 if (m_captureProcess->state() != QProcess::NotRunning) {
344 if (m_ui.device_selector->currentIndex() == FIREWIRE) {
346 m_captureProcess->write("k", 1);
347 //captureProcess->write("\e", 2);
348 m_playAction->setIcon(m_playIcon);
351 m_captureProcess->write("p", 1);
352 m_playAction->setIcon(m_pauseIcon);
358 m_captureArgs.clear();
359 m_displayArgs.clear();
362 switch (m_ui.device_selector->currentIndex()) {
364 switch (KdenliveSettings::firewireformat()) {
367 m_captureArgs << "--format" << "raw";
368 m_displayArgs << "-f" << "dv";
372 m_captureArgs << "--format" << "dv1";
373 m_displayArgs << "-f" << "dv";
377 m_captureArgs << "--format" << "dv2";
378 m_displayArgs << "-f" << "dv";
382 m_captureArgs << "--format" << "hdv";
383 m_displayArgs << "-f" << "mpegts";
386 if (KdenliveSettings::firewireautosplit()) m_captureArgs << "--autosplit";
387 if (KdenliveSettings::firewiretimestamp()) m_captureArgs << "--timestamp";
388 m_captureArgs << "-i" << "capture" << "-";
389 m_displayArgs << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
391 m_captureProcess->setStandardOutputProcess(m_displayProcess);
392 m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
393 kDebug() << "Capture: Running dvgrab " << m_captureArgs.join(" ");
394 m_captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
395 if (play) m_captureProcess->write(" ", 1);
396 m_discAction->setEnabled(true);
399 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
400 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
401 m_captureProcess->setStandardOutputProcess(m_displayProcess);
402 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
403 m_captureProcess->start("ffmpeg", m_captureArgs);
409 if (m_ui.device_selector->currentIndex() != SCREENGRAB) {
410 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
411 m_displayProcess->start("ffplay", m_displayArgs);
412 m_ui.video_frame->setText(i18n("Initialising..."));
414 // do something when starting screen grab
418 void RecMonitor::slotRecord()
420 if (m_captureProcess->state() == QProcess::NotRunning && m_ui.device_selector->currentIndex() == FIREWIRE) {
424 switch (m_ui.device_selector->currentIndex()) {
426 m_captureProcess->write("\e", 2);
427 m_playAction->setIcon(m_playIcon);
428 m_isCapturing = false;
430 m_recAction->setChecked(false);
433 m_captureProcess->terminate();
435 //m_isCapturing = false;
436 QTimer::singleShot(1000, this, SLOT(slotStartCapture()));
439 //captureProcess->write("q\n", 3);
440 m_captureProcess->terminate();
441 m_ui.video_frame->setText(i18n("Encoding captured video..."));
442 // in case ffmpeg doesn't exit with the 'q' command, kill it one second later
443 //QTimer::singleShot(1000, captureProcess, SLOT(kill()));
447 } else if (m_ui.device_selector->currentIndex() == FIREWIRE) {
448 m_isCapturing = true;
450 m_captureProcess->write("c\n", 3);
453 if (m_captureProcess->state() == QProcess::NotRunning) {
454 m_recAction->setChecked(true);
455 QString extension = "mp4";
456 if (m_ui.device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension();
457 QString path = KdenliveSettings::capturefolder() + "/capture0000." + extension;
459 while (QFile::exists(path)) {
460 QString num = QString::number(i).rightJustified(4, '0', false);
461 path = KdenliveSettings::capturefolder() + "/capture" + num + '.' + extension;
465 m_captureFile = KUrl(path);
467 m_captureArgs.clear();
468 m_displayArgs.clear();
471 switch (m_ui.device_selector->currentIndex()) {
473 m_captureArgs << "--format" << "hdv" << "-i" << "capture" << "-";
474 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
475 m_captureProcess->setStandardOutputProcess(m_displayProcess);
476 kDebug() << "Capture: Running dvgrab " << m_captureArgs.join(" ");
477 m_captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
480 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-y" << m_captureFile.path() << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
481 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
482 m_captureProcess->setStandardOutputProcess(m_displayProcess);
483 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
484 m_captureProcess->start("ffmpeg", m_captureArgs);
487 switch (KdenliveSettings::rmd_capture_type()) {
489 // Full screen capture, nothing special to do
493 m_captureArgs << "-width" << QString::number(KdenliveSettings::rmd_width()) << "-height" << QString::number(KdenliveSettings::rmd_height());
494 if (!KdenliveSettings::rmd_follow_mouse()) {
495 m_captureArgs << "-x" << QString::number(KdenliveSettings::rmd_offsetx()) << "-y" << QString::number(KdenliveSettings::rmd_offsety());
497 m_captureArgs << "--follow-mouse";
498 if (KdenliveSettings::rmd_hide_frame()) m_captureArgs << "--no-frame";
502 m_isCapturing = true;
503 if (KdenliveSettings::rmd_capture_audio()) {
504 m_captureArgs << "-freq" << KdenliveSettings::rmd_freq();
505 m_captureArgs << "-channels" << QString::number(KdenliveSettings::rmd_audio_channels());
506 if (KdenliveSettings::rmd_use_jack()) {
507 m_captureArgs << "-use-jack" << KdenliveSettings::rmd_jackports();
508 if (KdenliveSettings::rmd_jack_buffer() > 0.0)
509 m_captureArgs << "-ring-buffer-size" << QString::number(KdenliveSettings::rmd_jack_buffer());
511 if (!KdenliveSettings::rmd_alsadevicename().isEmpty())
512 m_captureArgs << "-device" << KdenliveSettings::rmd_alsadevicename();
513 if (KdenliveSettings::rmd_alsa_buffer() > 0)
514 m_captureArgs << "-buffer-size" << QString::number(KdenliveSettings::rmd_alsa_buffer());
516 } else m_captureArgs << "--no-sound";
518 if (KdenliveSettings::rmd_fullshots()) m_captureArgs << "--full-shots";
519 m_captureArgs << "-workdir" << KdenliveSettings::currenttmpfolder();
520 m_captureArgs << "-fps" << QString::number(KdenliveSettings::rmd_fps()) << "-o" << m_captureFile.path();
521 m_captureProcess->start(KdenliveSettings::rmd_path(), m_captureArgs);
522 kDebug() << "// RecordMyDesktop params: " << m_captureArgs;
529 if (m_ui.device_selector->currentIndex() != SCREENGRAB) {
530 m_isCapturing = true;
531 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
532 m_displayProcess->start("ffplay", m_displayArgs);
533 m_ui.video_frame->setText(i18n("Initialising..."));
537 m_displayProcess->kill();
538 //captureProcess->kill();
539 QTimer::singleShot(1000, this, SLOT(slotRecord()));
544 void RecMonitor::slotStartGrab(const QRect &rect) {
545 rgnGrab->deleteLater();
546 QApplication::restoreOverrideCursor();
548 if (rect.isNull()) return;
549 int width = rect.width();
550 int height = rect.height();
551 if (width % 2 != 0) width--;
552 if (height % 2 != 0) height--;
553 QString args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(width) + "x" + QString::number(height)).replace("%offset", "+" + QString::number(rect.x()) + "," + QString::number(rect.y()));
554 if (KdenliveSettings::screengrabenableaudio()) {
555 // also capture audio
556 if (KdenliveSettings::useosscapture()) m_captureArgs << KdenliveSettings::screengrabosscapture().simplified().split(' ');
557 else m_captureArgs << KdenliveSettings::screengrabalsacapture2().simplified().split(' ');
559 m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path();
560 m_isCapturing = true;
561 m_ui.video_frame->setText(i18n("Capturing..."));
562 if (KdenliveSettings::screengrabenableaudio() && !KdenliveSettings::useosscapture()) {
563 QStringList alsaArgs = KdenliveSettings::screengrabalsacapture().simplified().split(' ');
564 alsaProcess->setStandardOutputProcess(captureProcess);
565 kDebug() << "Capture: Running arecord " << alsaArgs.join(" ");
566 alsaProcess->start("arecord", alsaArgs);
568 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
569 captureProcess->start("ffmpeg", m_captureArgs);
572 void RecMonitor::slotProcessStatus(QProcess::ProcessState status)
574 if (status == QProcess::NotRunning) {
575 m_displayProcess->kill();
576 if (m_isCapturing && m_ui.device_selector->currentIndex() != FIREWIRE)
577 if (m_ui.autoaddbox->isChecked() && QFile::exists(m_captureFile.path())) emit addProjectClip(m_captureFile);
578 if (m_ui.device_selector->currentIndex() == FIREWIRE) {
579 m_discAction->setIcon(KIcon("network-connect"));
580 m_discAction->setText(i18n("Connect"));
581 m_playAction->setEnabled(false);
582 m_rewAction->setEnabled(false);
583 m_fwdAction->setEnabled(false);
584 m_recAction->setEnabled(false);
587 m_playAction->setIcon(m_playIcon);
588 m_recAction->setChecked(false);
589 m_stopAction->setEnabled(false);
590 m_ui.device_selector->setEnabled(true);
591 if (m_captureProcess && m_captureProcess->exitStatus() == QProcess::CrashExit) {
592 m_ui.video_frame->setText(i18n("Capture crashed, please check your parameters"));
594 if (m_ui.device_selector->currentIndex() != SCREENGRAB) m_ui.video_frame->setText(i18n("Not connected"));
595 else m_ui.video_frame->setPixmap(mergeSideBySide(KIcon("video-display").pixmap(QSize(50, 50)), i18n("Press record button\nto start screen capture\nFiles will be saved in:\n%1", KdenliveSettings::capturefolder())));
597 m_isCapturing = false;
599 #if KDE_IS_VERSION(4,2,0)
600 // update free space info
601 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
602 if( info.isValid() ) {
603 m_freeSpace->setValue(100 * info.used() / info.size());
604 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
609 if (m_ui.device_selector->currentIndex() != SCREENGRAB) m_stopAction->setEnabled(true);
610 m_ui.device_selector->setEnabled(false);
614 void RecMonitor::manageCapturedFiles()
617 switch (KdenliveSettings::firewireformat()) {
629 QDir dir(KdenliveSettings::capturefolder());
631 filters << "capture*" + extension;
632 const QStringList result = dir.entryList(filters, QDir::Files, QDir::Time);
633 KUrl::List capturedFiles;
634 foreach(const QString &name, result) {
635 KUrl url = KUrl(dir.filePath(name));
636 if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, this)) {
637 KFileItem file(KFileItem::Unknown, KFileItem::Unknown, url, true);
638 if (file.time(KFileItem::ModificationTime) > m_captureTime) capturedFiles.append(url);
641 kDebug() << "Found : " << capturedFiles.count() << " new capture files";
642 kDebug() << capturedFiles;
644 if (capturedFiles.count() > 0) {
645 ManageCapturesDialog *d = new ManageCapturesDialog(capturedFiles, this);
646 if (d->exec() == QDialog::Accepted) {
647 capturedFiles = d->importFiles();
648 foreach(const KUrl &url, capturedFiles) {
649 emit addProjectClip(url);
657 void RecMonitor::mousePressEvent(QMouseEvent * /*event*/)
662 void RecMonitor::activateRecMonitor()
664 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
667 void RecMonitor::stop()
673 void RecMonitor::start()
679 void RecMonitor::refreshRecMonitor(bool visible)
682 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
687 void RecMonitor::slotPlay()
690 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
695 #include "recmonitor.moc"