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 <KMessageBox>
35 #if KDE_IS_VERSION(4,2,0)
36 #include <KDiskFreeSpaceInfo>
39 #include <QMouseEvent>
41 #include <QToolButton>
46 RecMonitor::RecMonitor(QString name, QWidget *parent) :
56 video_frame->setAttribute(Qt::WA_PaintOnScreen);
57 device_selector->setCurrentIndex(KdenliveSettings::defaultcapture());
58 connect(device_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(slotVideoDeviceChanged(int)));
62 QToolBar *toolbar = new QToolBar(name, this);
63 QHBoxLayout *layout = new QHBoxLayout;
64 layout->setContentsMargins(0, 0, 0, 0);
65 m_playIcon = KIcon("media-playback-start");
66 m_pauseIcon = KIcon("media-playback-pause");
68 m_discAction = toolbar->addAction(KIcon("network-connect"), i18n("Connect"));
69 connect(m_discAction, SIGNAL(triggered()), this, SLOT(slotDisconnect()));
71 m_rewAction = toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind"));
72 connect(m_rewAction, SIGNAL(triggered()), this, SLOT(slotRewind()));
74 m_playAction = toolbar->addAction(m_playIcon, i18n("Play"));
75 connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotStartCapture()));
77 m_stopAction = toolbar->addAction(KIcon("media-playback-stop"), i18n("Stop"));
78 connect(m_stopAction, SIGNAL(triggered()), this, SLOT(slotStopCapture()));
79 m_stopAction->setEnabled(false);
80 m_fwdAction = toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward"));
81 connect(m_fwdAction, SIGNAL(triggered()), this, SLOT(slotForward()));
83 m_recAction = toolbar->addAction(KIcon("media-record"), i18n("Record"));
84 connect(m_recAction, SIGNAL(triggered()), this, SLOT(slotRecord()));
85 m_recAction->setCheckable(true);
87 toolbar->addSeparator();
89 QAction *configAction = toolbar->addAction(KIcon("configure"), i18n("Configure"));
90 connect(configAction, SIGNAL(triggered()), this, SLOT(slotConfigure()));
91 configAction->setCheckable(false);
93 layout->addWidget(toolbar);
95 layout->addWidget(&m_dvinfo);
97 #if KDE_IS_VERSION(4,2,0)
98 m_freeSpace = new KCapacityBar(KCapacityBar::DrawTextInline, this);
99 m_freeSpace->setMaximumWidth(150);
100 QFontMetricsF fontMetrics(font());
101 m_freeSpace->setMaximumHeight(fontMetrics.height() * 1.2);
102 slotUpdateFreeSpace();
103 layout->addWidget(m_freeSpace);
104 connect(&m_spaceTimer, SIGNAL(timeout()), this, SLOT(slotUpdateFreeSpace()));
105 m_spaceTimer.setInterval(30000);
106 m_spaceTimer.setSingleShot(false);
109 control_frame_firewire->setLayout(layout);
111 slotVideoDeviceChanged(device_selector->currentIndex());
112 m_displayProcess = new QProcess;
113 m_captureProcess = new QProcess;
115 connect(m_captureProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(slotProcessStatus(QProcess::ProcessState)));
116 connect(m_captureProcess, SIGNAL(readyReadStandardError()), this, SLOT(slotReadDvgrabInfo()));
118 QStringList env = QProcess::systemEnvironment();
119 env << "SDL_WINDOWID=" + QString::number(video_frame->winId());
121 QString videoDriver = KdenliveSettings::videodrivername();
122 if (!videoDriver.isEmpty()) {
123 if (videoDriver == "x11_noaccel") {
124 env << "SDL_VIDEO_YUV_HWACCEL=0";
125 env << "SDL_VIDEODRIVER=x11";
126 } else env << "SDL_VIDEODRIVER=" + videoDriver;
128 setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 1);
130 m_displayProcess->setEnvironment(env);
132 if (KdenliveSettings::video4capture().isEmpty()) {
133 QString captureCommand;
134 if (!KdenliveSettings::video4adevice().isEmpty()) captureCommand = "-f " + KdenliveSettings::video4aformat() + " -i " + KdenliveSettings::video4adevice();
136 captureCommand += " -f " + KdenliveSettings::video4vformat() + " -s " + KdenliveSettings::video4size() + " -r " + QString::number(KdenliveSettings::video4rate()) + " -i " + KdenliveSettings::video4vdevice();
137 KdenliveSettings::setVideo4capture(captureCommand);
140 kDebug() << "/////// BUILDING MONITOR, ID: " << video_frame->winId();
143 RecMonitor::~RecMonitor()
146 delete m_captureProcess;
147 delete m_displayProcess;
150 QString RecMonitor::name() const
155 void RecMonitor::slotConfigure()
157 emit showConfigDialog(4, device_selector->currentIndex());
160 void RecMonitor::slotUpdateCaptureFolder()
162 if (m_captureProcess) m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
163 if (m_captureProcess->state() != QProcess::NotRunning) {
164 if (device_selector->currentIndex() == FIREWIRE)
165 KMessageBox::information(this, i18n("You need to disconnect and reconnect in the capture monitor to apply your changes"), i18n("Capturing"));
166 else KMessageBox::information(this, i18n("You need to stop capture before your changes can be applied"), i18n("Capturing"));
168 else slotVideoDeviceChanged(device_selector->currentIndex());
169 kDebug() << "// UPDATE CAPT FOLD: " << KdenliveSettings::capturefolder();
171 #if KDE_IS_VERSION(4,2,0)
172 // update free space info
173 slotUpdateFreeSpace();
177 void RecMonitor::slotVideoDeviceChanged(int ix)
181 m_discAction->setEnabled(false);
182 m_rewAction->setEnabled(false);
183 m_fwdAction->setEnabled(false);
184 m_recAction->setEnabled(true);
185 m_stopAction->setEnabled(false);
186 m_playAction->setEnabled(false);
187 if (KdenliveSettings::rmd_path().isEmpty()) {
188 QString rmdpath = KStandardDirs::findExe("recordmydesktop");
189 if (rmdpath.isEmpty()) video_frame->setPixmap(mergeSideBySide(KIcon("dialog-warning").pixmap(QSize(50, 50)), i18n("Recordmydesktop utility not found,\n please install it for screen grabs")));
190 else KdenliveSettings::setRmd_path(rmdpath);
192 if (!KdenliveSettings::rmd_path().isEmpty()) 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())));
193 //video_frame->setText(i18n("Press record button\nto start screen capture"));
196 m_discAction->setEnabled(false);
197 m_rewAction->setEnabled(false);
198 m_fwdAction->setEnabled(false);
199 m_recAction->setEnabled(true);
200 m_stopAction->setEnabled(false);
201 m_playAction->setEnabled(true);
202 checkDeviceAvailability();
205 m_discAction->setEnabled(true);
206 m_recAction->setEnabled(false);
207 m_stopAction->setEnabled(false);
208 m_playAction->setEnabled(false);
209 m_rewAction->setEnabled(false);
210 m_fwdAction->setEnabled(false);
212 // Check that dvgab is available
213 if (KdenliveSettings::dvgrab_path().isEmpty()) {
214 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
215 if (dvgrabpath.isEmpty()) video_frame->setPixmap(mergeSideBySide(KIcon("dialog-warning").pixmap(QSize(50, 50)), i18n("dvgrab utility not found,\n please install it for firewire capture")));
216 else KdenliveSettings::setDvgrab_path(dvgrabpath);
219 QString capturefile = KdenliveSettings::capturefolder();
220 if (!capturefile.endsWith("/")) capturefile.append("/");
221 QString capturename = KdenliveSettings::dvgrabfilename();
222 if (capturename.isEmpty()) capturename = "capture";
224 switch (KdenliveSettings::firewireformat()) {
236 capturename.append("xxx" + extension);
237 capturefile.append(capturename);
238 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", capturefile)));
244 QPixmap RecMonitor::mergeSideBySide(const QPixmap& pix, const QString txt)
247 QRect r = QApplication::fontMetrics().boundingRect(QRect(0, 0, video_frame->width(), video_frame->height()), Qt::AlignLeft, txt);
248 int strWidth = r.width();
249 int strHeight = r.height();
250 int pixWidth = pix.width();
251 int pixHeight = pix.height();
252 QPixmap res(strWidth + 8 + pixWidth, qMax(strHeight, pixHeight));
253 res.fill(Qt::transparent);
255 p.drawPixmap(0, 0, pix);
256 p.drawText(QRect(pixWidth + 8, 0, strWidth, strHeight), 0, txt);
262 void RecMonitor::checkDeviceAvailability()
264 if (!KIO::NetAccess::exists(KUrl(KdenliveSettings::video4vdevice()), KIO::NetAccess::SourceSide , this)) {
265 m_playAction->setEnabled(false);
266 m_recAction->setEnabled(false);
267 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())));
268 //video_frame->setText(i18n("Cannot read from device %1\nPlease check drivers and access rights.", KdenliveSettings::video4vdevice()));
269 } else //video_frame->setText(i18n("Press play or record button\nto start video capture"));
270 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())));
273 void RecMonitor::slotDisconnect()
275 if (m_captureProcess->state() == QProcess::NotRunning) {
276 m_captureTime = KDateTime::currentLocalDateTime();
277 kDebug() << "CURRENT TIME: " << m_captureTime.toString();
278 m_didCapture = false;
279 slotStartCapture(false);
280 m_discAction->setIcon(KIcon("network-disconnect"));
281 m_discAction->setText(i18n("Disonnect"));
282 m_recAction->setEnabled(true);
283 m_stopAction->setEnabled(true);
284 m_playAction->setEnabled(true);
285 m_rewAction->setEnabled(true);
286 m_fwdAction->setEnabled(true);
288 m_captureProcess->write("q", 1);
289 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
290 if (m_didCapture) manageCapturedFiles();
291 m_didCapture = false;
295 void RecMonitor::slotRewind()
297 m_captureProcess->write("a", 1);
300 void RecMonitor::slotForward()
302 m_captureProcess->write("z", 1);
305 void RecMonitor::slotStopCapture()
308 switch (device_selector->currentIndex()) {
310 m_captureProcess->write("\e", 2);
311 m_playAction->setIcon(m_playIcon);
315 m_captureProcess->write("q\n", 3);
316 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
320 m_captureProcess->write("q\n", 3);
321 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
328 void RecMonitor::slotStartCapture(bool play)
330 if (m_captureProcess->state() != QProcess::NotRunning) {
331 if (device_selector->currentIndex() == FIREWIRE) {
333 m_captureProcess->write("k", 1);
334 //captureProcess->write("\e", 2);
335 m_playAction->setIcon(m_playIcon);
338 m_captureProcess->write("p", 1);
339 m_playAction->setIcon(m_pauseIcon);
345 m_captureArgs.clear();
346 m_displayArgs.clear();
348 QString capturename = KdenliveSettings::dvgrabfilename();
349 QStringList dvargs = KdenliveSettings::dvgrabextra().simplified().split(" ", QString::SkipEmptyParts);
351 switch (device_selector->currentIndex()) {
353 switch (KdenliveSettings::firewireformat()) {
356 m_captureArgs << "--format" << "raw";
357 m_displayArgs << "-f" << "dv";
361 m_captureArgs << "--format" << "dv1";
362 m_displayArgs << "-f" << "dv";
366 m_captureArgs << "--format" << "dv2";
367 m_displayArgs << "-f" << "dv";
371 m_captureArgs << "--format" << "hdv";
372 m_displayArgs << "-f" << "mpegts";
375 if (KdenliveSettings::firewireautosplit()) m_captureArgs << "--autosplit";
376 if (KdenliveSettings::firewiretimestamp()) m_captureArgs << "--timestamp";
377 if (!dvargs.isEmpty()) {
378 m_captureArgs << dvargs;
380 m_captureArgs << "-i";
381 if (capturename.isEmpty()) capturename = "capture";
382 m_captureArgs << capturename << "-";
384 m_displayArgs << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
386 m_captureProcess->setStandardOutputProcess(m_displayProcess);
387 m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
388 kDebug() << "Capture: Running dvgrab " << m_captureArgs.join(" ");
390 m_captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
391 if (play) m_captureProcess->write(" ", 1);
392 m_discAction->setEnabled(true);
395 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
396 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
397 m_captureProcess->setStandardOutputProcess(m_displayProcess);
398 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
399 m_captureProcess->start("ffmpeg", m_captureArgs);
405 if (device_selector->currentIndex() != SCREENGRAB) {
406 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
407 m_displayProcess->start("ffplay", m_displayArgs);
408 video_frame->setText(i18n("Initialising..."));
410 // do something when starting screen grab
414 void RecMonitor::slotRecord()
416 if (m_captureProcess->state() == QProcess::NotRunning && device_selector->currentIndex() == FIREWIRE) {
420 switch (device_selector->currentIndex()) {
422 m_captureProcess->write("\e", 2);
423 m_playAction->setIcon(m_playIcon);
424 m_isCapturing = false;
426 m_recAction->setChecked(false);
429 m_captureProcess->terminate();
431 //m_isCapturing = false;
432 QTimer::singleShot(1000, this, SLOT(slotStartCapture()));
435 //captureProcess->write("q\n", 3);
436 m_captureProcess->terminate();
437 video_frame->setText(i18n("Encoding captured video..."));
438 // in case ffmpeg doesn't exit with the 'q' command, kill it one second later
439 //QTimer::singleShot(1000, captureProcess, SLOT(kill()));
443 } else if (device_selector->currentIndex() == FIREWIRE) {
444 m_isCapturing = true;
446 m_captureProcess->write("c\n", 3);
447 m_spaceTimer.start();
450 if (m_captureProcess->state() == QProcess::NotRunning) {
451 m_recAction->setChecked(true);
452 QString extension = "mp4";
453 if (device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension();
454 QString path = KdenliveSettings::capturefolder() + "/capture0000." + extension;
456 while (QFile::exists(path)) {
457 QString num = QString::number(i).rightJustified(4, '0', false);
458 path = KdenliveSettings::capturefolder() + "/capture" + num + '.' + extension;
461 m_captureFile = KUrl(path);
463 m_captureArgs.clear();
464 m_displayArgs.clear();
466 QString capturename = KdenliveSettings::dvgrabfilename();
467 if (capturename.isEmpty()) capturename = "capture";
469 switch (device_selector->currentIndex()) {
471 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-y" << m_captureFile.path() << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
472 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
473 m_captureProcess->setStandardOutputProcess(m_displayProcess);
474 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
475 m_captureProcess->start("ffmpeg", m_captureArgs);
478 switch (KdenliveSettings::rmd_capture_type()) {
480 // Full screen capture, nothing special to do
484 m_captureArgs << "-width" << QString::number(KdenliveSettings::rmd_width()) << "-height" << QString::number(KdenliveSettings::rmd_height());
485 if (!KdenliveSettings::rmd_follow_mouse()) {
486 m_captureArgs << "-x" << QString::number(KdenliveSettings::rmd_offsetx()) << "-y" << QString::number(KdenliveSettings::rmd_offsety());
488 m_captureArgs << "--follow-mouse";
489 if (KdenliveSettings::rmd_hide_frame()) m_captureArgs << "--no-frame";
493 m_isCapturing = true;
494 if (KdenliveSettings::rmd_capture_audio()) {
495 m_captureArgs << "-freq" << KdenliveSettings::rmd_freq();
496 m_captureArgs << "-channels" << QString::number(KdenliveSettings::rmd_audio_channels());
497 if (KdenliveSettings::rmd_use_jack()) {
498 m_captureArgs << "-use-jack" << KdenliveSettings::rmd_jackports();
499 if (KdenliveSettings::rmd_jack_buffer() > 0.0)
500 m_captureArgs << "-ring-buffer-size" << QString::number(KdenliveSettings::rmd_jack_buffer());
502 if (!KdenliveSettings::rmd_alsadevicename().isEmpty())
503 m_captureArgs << "-device" << KdenliveSettings::rmd_alsadevicename();
504 if (KdenliveSettings::rmd_alsa_buffer() > 0)
505 m_captureArgs << "-buffer-size" << QString::number(KdenliveSettings::rmd_alsa_buffer());
507 } else m_captureArgs << "--no-sound";
509 if (KdenliveSettings::rmd_fullshots()) m_captureArgs << "--full-shots";
510 m_captureArgs << "-workdir" << KdenliveSettings::currenttmpfolder();
511 m_captureArgs << "-fps" << QString::number(KdenliveSettings::rmd_fps()) << "-o" << m_captureFile.path();
512 m_captureProcess->start(KdenliveSettings::rmd_path(), m_captureArgs);
513 kDebug() << "// RecordMyDesktop params: " << m_captureArgs;
520 if (device_selector->currentIndex() != SCREENGRAB) {
521 m_isCapturing = true;
522 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
523 m_displayProcess->start("ffplay", m_displayArgs);
524 video_frame->setText(i18n("Initialising..."));
528 m_displayProcess->kill();
529 //captureProcess->kill();
530 QTimer::singleShot(1000, this, SLOT(slotRecord()));
535 void RecMonitor::slotStartGrab(const QRect &rect) {
536 rgnGrab->deleteLater();
537 QApplication::restoreOverrideCursor();
539 if (rect.isNull()) return;
540 int width = rect.width();
541 int height = rect.height();
542 if (width % 2 != 0) width--;
543 if (height % 2 != 0) height--;
544 QString args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(width) + "x" + QString::number(height)).replace("%offset", "+" + QString::number(rect.x()) + "," + QString::number(rect.y()));
545 if (KdenliveSettings::screengrabenableaudio()) {
546 // also capture audio
547 if (KdenliveSettings::useosscapture()) m_captureArgs << KdenliveSettings::screengrabosscapture().simplified().split(' ');
548 else m_captureArgs << KdenliveSettings::screengrabalsacapture2().simplified().split(' ');
550 m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path();
551 m_isCapturing = true;
552 video_frame->setText(i18n("Capturing..."));
553 if (KdenliveSettings::screengrabenableaudio() && !KdenliveSettings::useosscapture()) {
554 QStringList alsaArgs = KdenliveSettings::screengrabalsacapture().simplified().split(' ');
555 alsaProcess->setStandardOutputProcess(captureProcess);
556 kDebug() << "Capture: Running arecord " << alsaArgs.join(" ");
557 alsaProcess->start("arecord", alsaArgs);
559 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
560 captureProcess->start("ffmpeg", m_captureArgs);
563 void RecMonitor::slotProcessStatus(QProcess::ProcessState status)
565 if (status == QProcess::NotRunning) {
566 m_displayProcess->kill();
567 if (m_isCapturing && device_selector->currentIndex() != FIREWIRE)
568 if (autoaddbox->isChecked() && QFile::exists(m_captureFile.path())) emit addProjectClip(m_captureFile);
569 if (device_selector->currentIndex() == FIREWIRE) {
570 m_discAction->setIcon(KIcon("network-connect"));
571 m_discAction->setText(i18n("Connect"));
572 m_playAction->setEnabled(false);
573 m_rewAction->setEnabled(false);
574 m_fwdAction->setEnabled(false);
575 m_recAction->setEnabled(false);
578 m_playAction->setIcon(m_playIcon);
579 m_recAction->setChecked(false);
580 m_stopAction->setEnabled(false);
581 device_selector->setEnabled(true);
582 if (m_captureProcess && m_captureProcess->exitStatus() == QProcess::CrashExit) {
583 video_frame->setText(i18n("Capture crashed, please check your parameters"));
585 if (device_selector->currentIndex() != SCREENGRAB) video_frame->setText(i18n("Not connected"));
586 else 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())));
588 m_isCapturing = false;
591 #if KDE_IS_VERSION(4,2,0)
592 // update free space info
593 slotUpdateFreeSpace();
597 if (device_selector->currentIndex() != SCREENGRAB) m_stopAction->setEnabled(true);
598 device_selector->setEnabled(false);
602 void RecMonitor::manageCapturedFiles()
605 switch (KdenliveSettings::firewireformat()) {
617 QDir dir(KdenliveSettings::capturefolder());
619 QString capturename = KdenliveSettings::dvgrabfilename();
620 if (capturename.isEmpty()) capturename = "capture";
621 filters << capturename + "*" + extension;
622 const QStringList result = dir.entryList(filters, QDir::Files, QDir::Time);
623 KUrl::List capturedFiles;
624 foreach(const QString &name, result) {
625 KUrl url = KUrl(dir.filePath(name));
626 if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, this)) {
627 KFileItem file(KFileItem::Unknown, KFileItem::Unknown, url, true);
628 if (file.time(KFileItem::ModificationTime) > m_captureTime) capturedFiles.append(url);
631 kDebug() << "Found : " << capturedFiles.count() << " new capture files";
632 kDebug() << capturedFiles;
634 if (capturedFiles.count() > 0) {
635 ManageCapturesDialog *d = new ManageCapturesDialog(capturedFiles, this);
636 if (d->exec() == QDialog::Accepted) {
637 capturedFiles = d->importFiles();
638 foreach(const KUrl &url, capturedFiles) {
639 emit addProjectClip(url);
647 void RecMonitor::mousePressEvent(QMouseEvent * /*event*/)
649 #if KDE_IS_VERSION(4,2,0)
650 if (m_freeSpace->underMouse()) slotUpdateFreeSpace();
654 void RecMonitor::slotUpdateFreeSpace()
656 #if KDE_IS_VERSION(4,2,0)
657 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
658 if (info.isValid()) {
659 m_freeSpace->setValue(100 * info.used() / info.size());
660 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
661 m_freeSpace->update();
666 void RecMonitor::activateRecMonitor()
668 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
671 void RecMonitor::stop()
677 void RecMonitor::start()
683 void RecMonitor::refreshRecMonitor(bool visible)
686 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
691 void RecMonitor::slotPlay()
694 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
698 void RecMonitor::slotReadDvgrabInfo()
700 QString data = m_captureProcess->readAllStandardError().simplified();
701 data = data.section('"', 2, 2).simplified();
702 m_dvinfo.setText(data.left(11));
703 m_dvinfo.updateGeometry();
706 #include "recmonitor.moc"