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"));
167 } else slotVideoDeviceChanged(device_selector->currentIndex());
168 kDebug() << "// UPDATE CAPT FOLD: " << KdenliveSettings::capturefolder();
170 #if KDE_IS_VERSION(4,2,0)
171 // update free space info
172 slotUpdateFreeSpace();
176 void RecMonitor::slotVideoDeviceChanged(int ix)
180 m_discAction->setEnabled(false);
181 m_rewAction->setEnabled(false);
182 m_fwdAction->setEnabled(false);
183 m_recAction->setEnabled(true);
184 m_stopAction->setEnabled(false);
185 m_playAction->setEnabled(false);
186 if (KdenliveSettings::rmd_path().isEmpty()) {
187 QString rmdpath = KStandardDirs::findExe("recordmydesktop");
188 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")));
189 else KdenliveSettings::setRmd_path(rmdpath);
191 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())));
192 //video_frame->setText(i18n("Press record button\nto start screen capture"));
195 m_discAction->setEnabled(false);
196 m_rewAction->setEnabled(false);
197 m_fwdAction->setEnabled(false);
198 m_recAction->setEnabled(true);
199 m_stopAction->setEnabled(false);
200 m_playAction->setEnabled(true);
201 checkDeviceAvailability();
204 m_discAction->setEnabled(true);
205 m_recAction->setEnabled(false);
206 m_stopAction->setEnabled(false);
207 m_playAction->setEnabled(false);
208 m_rewAction->setEnabled(false);
209 m_fwdAction->setEnabled(false);
211 // Check that dvgab is available
212 if (KdenliveSettings::dvgrab_path().isEmpty()) {
213 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
214 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")));
215 else KdenliveSettings::setDvgrab_path(dvgrabpath);
218 QString capturefile = KdenliveSettings::capturefolder();
219 if (!capturefile.endsWith("/")) capturefile.append("/");
220 QString capturename = KdenliveSettings::dvgrabfilename();
221 if (capturename.isEmpty()) capturename = "capture";
223 switch (KdenliveSettings::firewireformat()) {
235 capturename.append("xxx" + extension);
236 capturefile.append(capturename);
237 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)));
243 QPixmap RecMonitor::mergeSideBySide(const QPixmap& pix, const QString txt)
246 QRect r = QApplication::fontMetrics().boundingRect(QRect(0, 0, video_frame->width(), video_frame->height()), Qt::AlignLeft, txt);
247 int strWidth = r.width();
248 int strHeight = r.height();
249 int pixWidth = pix.width();
250 int pixHeight = pix.height();
251 QPixmap res(strWidth + 8 + pixWidth, qMax(strHeight, pixHeight));
252 res.fill(Qt::transparent);
254 p.drawPixmap(0, 0, pix);
255 p.drawText(QRect(pixWidth + 8, 0, strWidth, strHeight), 0, txt);
261 void RecMonitor::checkDeviceAvailability()
263 if (!KIO::NetAccess::exists(KUrl(KdenliveSettings::video4vdevice()), KIO::NetAccess::SourceSide , this)) {
264 m_playAction->setEnabled(false);
265 m_recAction->setEnabled(false);
266 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())));
267 //video_frame->setText(i18n("Cannot read from device %1\nPlease check drivers and access rights.", KdenliveSettings::video4vdevice()));
268 } else //video_frame->setText(i18n("Press play or record button\nto start video capture"));
269 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())));
272 void RecMonitor::slotDisconnect()
274 if (m_captureProcess->state() == QProcess::NotRunning) {
275 m_captureTime = KDateTime::currentLocalDateTime();
276 kDebug() << "CURRENT TIME: " << m_captureTime.toString();
277 m_didCapture = false;
278 slotStartCapture(false);
279 m_discAction->setIcon(KIcon("network-disconnect"));
280 m_discAction->setText(i18n("Disonnect"));
281 m_recAction->setEnabled(true);
282 m_stopAction->setEnabled(true);
283 m_playAction->setEnabled(true);
284 m_rewAction->setEnabled(true);
285 m_fwdAction->setEnabled(true);
287 m_captureProcess->write("q", 1);
288 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
289 if (m_didCapture) manageCapturedFiles();
290 m_didCapture = false;
294 void RecMonitor::slotRewind()
296 m_captureProcess->write("a", 1);
299 void RecMonitor::slotForward()
301 m_captureProcess->write("z", 1);
304 void RecMonitor::slotStopCapture()
307 switch (device_selector->currentIndex()) {
309 m_captureProcess->write("\e", 2);
310 m_playAction->setIcon(m_playIcon);
314 m_captureProcess->write("q\n", 3);
315 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
319 m_captureProcess->write("q\n", 3);
320 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
327 void RecMonitor::slotStartCapture(bool play)
329 if (m_captureProcess->state() != QProcess::NotRunning) {
330 if (device_selector->currentIndex() == FIREWIRE) {
332 m_captureProcess->write("k", 1);
333 //captureProcess->write("\e", 2);
334 m_playAction->setIcon(m_playIcon);
337 m_captureProcess->write("p", 1);
338 m_playAction->setIcon(m_pauseIcon);
344 m_captureArgs.clear();
345 m_displayArgs.clear();
347 QString capturename = KdenliveSettings::dvgrabfilename();
348 QStringList dvargs = KdenliveSettings::dvgrabextra().simplified().split(" ", QString::SkipEmptyParts);
350 switch (device_selector->currentIndex()) {
352 switch (KdenliveSettings::firewireformat()) {
355 m_captureArgs << "--format" << "raw";
356 m_displayArgs << "-f" << "dv";
360 m_captureArgs << "--format" << "dv1";
361 m_displayArgs << "-f" << "dv";
365 m_captureArgs << "--format" << "dv2";
366 m_displayArgs << "-f" << "dv";
370 m_captureArgs << "--format" << "hdv";
371 m_displayArgs << "-f" << "mpegts";
374 if (KdenliveSettings::firewireautosplit()) m_captureArgs << "--autosplit";
375 if (KdenliveSettings::firewiretimestamp()) m_captureArgs << "--timestamp";
376 if (!dvargs.isEmpty()) {
377 m_captureArgs << dvargs;
379 m_captureArgs << "-i";
380 if (capturename.isEmpty()) capturename = "capture";
381 m_captureArgs << capturename << "-";
383 m_displayArgs << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
385 m_captureProcess->setStandardOutputProcess(m_displayProcess);
386 m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
387 kDebug() << "Capture: Running dvgrab " << m_captureArgs.join(" ");
389 m_captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
390 if (play) m_captureProcess->write(" ", 1);
391 m_discAction->setEnabled(true);
394 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
395 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
396 m_captureProcess->setStandardOutputProcess(m_displayProcess);
397 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
398 m_captureProcess->start("ffmpeg", m_captureArgs);
404 if (device_selector->currentIndex() != SCREENGRAB) {
405 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
406 m_displayProcess->start("ffplay", m_displayArgs);
407 video_frame->setText(i18n("Initialising..."));
409 // do something when starting screen grab
413 void RecMonitor::slotRecord()
415 if (m_captureProcess->state() == QProcess::NotRunning && device_selector->currentIndex() == FIREWIRE) {
419 switch (device_selector->currentIndex()) {
421 m_captureProcess->write("\e", 2);
422 m_playAction->setIcon(m_playIcon);
423 m_isCapturing = false;
425 m_recAction->setChecked(false);
428 m_captureProcess->terminate();
430 //m_isCapturing = false;
431 QTimer::singleShot(1000, this, SLOT(slotStartCapture()));
434 //captureProcess->write("q\n", 3);
435 m_captureProcess->terminate();
436 video_frame->setText(i18n("Encoding captured video..."));
437 // in case ffmpeg doesn't exit with the 'q' command, kill it one second later
438 //QTimer::singleShot(1000, captureProcess, SLOT(kill()));
442 } else if (device_selector->currentIndex() == FIREWIRE) {
443 m_isCapturing = true;
445 m_captureProcess->write("c\n", 3);
446 m_spaceTimer.start();
449 if (m_captureProcess->state() == QProcess::NotRunning) {
450 m_recAction->setChecked(true);
451 QString extension = "mp4";
452 if (device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension();
453 QString path = KdenliveSettings::capturefolder() + "/capture0000." + extension;
455 while (QFile::exists(path)) {
456 QString num = QString::number(i).rightJustified(4, '0', false);
457 path = KdenliveSettings::capturefolder() + "/capture" + num + '.' + extension;
460 m_captureFile = KUrl(path);
462 m_captureArgs.clear();
463 m_displayArgs.clear();
465 QString capturename = KdenliveSettings::dvgrabfilename();
466 if (capturename.isEmpty()) capturename = "capture";
468 switch (device_selector->currentIndex()) {
470 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-y" << m_captureFile.path() << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
471 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
472 m_captureProcess->setStandardOutputProcess(m_displayProcess);
473 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
474 m_captureProcess->start("ffmpeg", m_captureArgs);
477 switch (KdenliveSettings::rmd_capture_type()) {
479 // Full screen capture, nothing special to do
483 m_captureArgs << "-width" << QString::number(KdenliveSettings::rmd_width()) << "-height" << QString::number(KdenliveSettings::rmd_height());
484 if (!KdenliveSettings::rmd_follow_mouse()) {
485 m_captureArgs << "-x" << QString::number(KdenliveSettings::rmd_offsetx()) << "-y" << QString::number(KdenliveSettings::rmd_offsety());
487 m_captureArgs << "--follow-mouse";
488 if (KdenliveSettings::rmd_hide_frame()) m_captureArgs << "--no-frame";
492 m_isCapturing = true;
493 if (KdenliveSettings::rmd_capture_audio()) {
494 m_captureArgs << "-freq" << KdenliveSettings::rmd_freq();
495 m_captureArgs << "-channels" << QString::number(KdenliveSettings::rmd_audio_channels());
496 if (KdenliveSettings::rmd_use_jack()) {
497 m_captureArgs << "-use-jack" << KdenliveSettings::rmd_jackports();
498 if (KdenliveSettings::rmd_jack_buffer() > 0.0)
499 m_captureArgs << "-ring-buffer-size" << QString::number(KdenliveSettings::rmd_jack_buffer());
501 if (!KdenliveSettings::rmd_alsadevicename().isEmpty())
502 m_captureArgs << "-device" << KdenliveSettings::rmd_alsadevicename();
503 if (KdenliveSettings::rmd_alsa_buffer() > 0)
504 m_captureArgs << "-buffer-size" << QString::number(KdenliveSettings::rmd_alsa_buffer());
506 } else m_captureArgs << "--no-sound";
508 if (KdenliveSettings::rmd_fullshots()) m_captureArgs << "--full-shots";
509 m_captureArgs << "-workdir" << KdenliveSettings::currenttmpfolder();
510 m_captureArgs << "-fps" << QString::number(KdenliveSettings::rmd_fps()) << "-o" << m_captureFile.path();
511 m_captureProcess->start(KdenliveSettings::rmd_path(), m_captureArgs);
512 kDebug() << "// RecordMyDesktop params: " << m_captureArgs;
519 if (device_selector->currentIndex() != SCREENGRAB) {
520 m_isCapturing = true;
521 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
522 m_displayProcess->start("ffplay", m_displayArgs);
523 video_frame->setText(i18n("Initialising..."));
527 m_displayProcess->kill();
528 //captureProcess->kill();
529 QTimer::singleShot(1000, this, SLOT(slotRecord()));
534 void RecMonitor::slotStartGrab(const QRect &rect) {
535 rgnGrab->deleteLater();
536 QApplication::restoreOverrideCursor();
538 if (rect.isNull()) return;
539 int width = rect.width();
540 int height = rect.height();
541 if (width % 2 != 0) width--;
542 if (height % 2 != 0) height--;
543 QString args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(width) + "x" + QString::number(height)).replace("%offset", "+" + QString::number(rect.x()) + "," + QString::number(rect.y()));
544 if (KdenliveSettings::screengrabenableaudio()) {
545 // also capture audio
546 if (KdenliveSettings::useosscapture()) m_captureArgs << KdenliveSettings::screengrabosscapture().simplified().split(' ');
547 else m_captureArgs << KdenliveSettings::screengrabalsacapture2().simplified().split(' ');
549 m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path();
550 m_isCapturing = true;
551 video_frame->setText(i18n("Capturing..."));
552 if (KdenliveSettings::screengrabenableaudio() && !KdenliveSettings::useosscapture()) {
553 QStringList alsaArgs = KdenliveSettings::screengrabalsacapture().simplified().split(' ');
554 alsaProcess->setStandardOutputProcess(captureProcess);
555 kDebug() << "Capture: Running arecord " << alsaArgs.join(" ");
556 alsaProcess->start("arecord", alsaArgs);
558 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
559 captureProcess->start("ffmpeg", m_captureArgs);
562 void RecMonitor::slotProcessStatus(QProcess::ProcessState status)
564 if (status == QProcess::NotRunning) {
565 m_displayProcess->kill();
566 if (m_isCapturing && device_selector->currentIndex() != FIREWIRE)
567 if (autoaddbox->isChecked() && QFile::exists(m_captureFile.path())) emit addProjectClip(m_captureFile);
568 if (device_selector->currentIndex() == FIREWIRE) {
569 m_discAction->setIcon(KIcon("network-connect"));
570 m_discAction->setText(i18n("Connect"));
571 m_playAction->setEnabled(false);
572 m_rewAction->setEnabled(false);
573 m_fwdAction->setEnabled(false);
574 m_recAction->setEnabled(false);
577 m_playAction->setIcon(m_playIcon);
578 m_recAction->setChecked(false);
579 m_stopAction->setEnabled(false);
580 device_selector->setEnabled(true);
581 if (m_captureProcess && m_captureProcess->exitStatus() == QProcess::CrashExit) {
582 video_frame->setText(i18n("Capture crashed, please check your parameters"));
584 if (device_selector->currentIndex() != SCREENGRAB) video_frame->setText(i18n("Not connected"));
585 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())));
587 m_isCapturing = false;
590 #if KDE_IS_VERSION(4,2,0)
591 // update free space info
592 slotUpdateFreeSpace();
596 if (device_selector->currentIndex() != SCREENGRAB) m_stopAction->setEnabled(true);
597 device_selector->setEnabled(false);
601 void RecMonitor::manageCapturedFiles()
604 switch (KdenliveSettings::firewireformat()) {
616 QDir dir(KdenliveSettings::capturefolder());
618 QString capturename = KdenliveSettings::dvgrabfilename();
619 if (capturename.isEmpty()) capturename = "capture";
620 filters << capturename + "*" + extension;
621 const QStringList result = dir.entryList(filters, QDir::Files, QDir::Time);
622 KUrl::List capturedFiles;
623 foreach(const QString &name, result) {
624 KUrl url = KUrl(dir.filePath(name));
625 if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, this)) {
626 KFileItem file(KFileItem::Unknown, KFileItem::Unknown, url, true);
627 if (file.time(KFileItem::ModificationTime) > m_captureTime) capturedFiles.append(url);
630 kDebug() << "Found : " << capturedFiles.count() << " new capture files";
631 kDebug() << capturedFiles;
633 if (capturedFiles.count() > 0) {
634 ManageCapturesDialog *d = new ManageCapturesDialog(capturedFiles, this);
635 if (d->exec() == QDialog::Accepted) {
636 capturedFiles = d->importFiles();
637 foreach(const KUrl &url, capturedFiles) {
638 emit addProjectClip(url);
646 void RecMonitor::mousePressEvent(QMouseEvent * /*event*/)
648 #if KDE_IS_VERSION(4,2,0)
649 if (m_freeSpace->underMouse()) slotUpdateFreeSpace();
653 void RecMonitor::slotUpdateFreeSpace()
655 #if KDE_IS_VERSION(4,2,0)
656 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
657 if (info.isValid()) {
658 m_freeSpace->setValue(100 * info.used() / info.size());
659 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
660 m_freeSpace->update();
665 void RecMonitor::activateRecMonitor()
667 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
670 void RecMonitor::stop()
676 void RecMonitor::start()
682 void RecMonitor::refreshRecMonitor(bool visible)
685 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
690 void RecMonitor::slotPlay()
693 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
697 void RecMonitor::slotReadDvgrabInfo()
699 QString data = m_captureProcess->readAllStandardError().simplified();
700 data = data.section('"', 2, 2).simplified();
701 m_dvinfo.setText(data.left(11));
702 m_dvinfo.updateGeometry();
705 #include "recmonitor.moc"