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>
34 #if KDE_IS_VERSION(4,2,0)
35 #include <KDiskFreeSpaceInfo>
38 #include <QMouseEvent>
40 #include <QToolButton>
45 RecMonitor::RecMonitor(QString name, QWidget *parent) :
55 m_ui.video_frame->setAttribute(Qt::WA_PaintOnScreen);
56 m_ui.device_selector->setCurrentIndex(KdenliveSettings::defaultcapture());
57 connect(m_ui.device_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(slotVideoDeviceChanged(int)));
61 QToolBar *toolbar = new QToolBar(name, this);
62 QHBoxLayout *layout = new QHBoxLayout;
63 layout->setContentsMargins(0, 0, 0, 0);
64 m_playIcon = KIcon("media-playback-start");
65 m_pauseIcon = KIcon("media-playback-pause");
67 m_discAction = toolbar->addAction(KIcon("network-connect"), i18n("Connect"));
68 connect(m_discAction, SIGNAL(triggered()), this, SLOT(slotDisconnect()));
70 m_rewAction = toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind"));
71 connect(m_rewAction, SIGNAL(triggered()), this, SLOT(slotRewind()));
73 m_playAction = toolbar->addAction(m_playIcon, i18n("Play"));
74 connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotStartCapture()));
76 m_stopAction = toolbar->addAction(KIcon("media-playback-stop"), i18n("Stop"));
77 connect(m_stopAction, SIGNAL(triggered()), this, SLOT(slotStopCapture()));
78 m_stopAction->setEnabled(false);
79 m_fwdAction = toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward"));
80 connect(m_fwdAction, SIGNAL(triggered()), this, SLOT(slotForward()));
82 m_recAction = toolbar->addAction(KIcon("media-record"), i18n("Record"));
83 connect(m_recAction, SIGNAL(triggered()), this, SLOT(slotRecord()));
84 m_recAction->setCheckable(true);
86 toolbar->addSeparator();
88 QAction *configAction = toolbar->addAction(KIcon("configure"), i18n("Configure"));
89 connect(configAction, SIGNAL(triggered()), this, SLOT(slotConfigure()));
90 configAction->setCheckable(false);
92 layout->addWidget(toolbar);
94 #if KDE_IS_VERSION(4,2,0)
95 m_freeSpace = new KCapacityBar(KCapacityBar::DrawTextInline, this);
96 m_freeSpace->setMaximumWidth(150);
97 QFontMetricsF fontMetrics(font());
98 m_freeSpace->setMaximumHeight(fontMetrics.height() * 1.2);
100 layout->addWidget(m_freeSpace);
103 m_ui.control_frame_firewire->setLayout(layout);
105 slotVideoDeviceChanged(m_ui.device_selector->currentIndex());
106 m_displayProcess = new QProcess;
107 m_captureProcess = new QProcess;
109 connect(m_captureProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(slotProcessStatus(QProcess::ProcessState)));
111 QStringList env = QProcess::systemEnvironment();
112 env << "SDL_WINDOWID=" + QString::number(m_ui.video_frame->winId());
114 QString videoDriver = KdenliveSettings::videodrivername();
115 if (!videoDriver.isEmpty()) {
116 if (videoDriver == "x11_noaccel") {
117 env << "SDL_VIDEO_YUV_HWACCEL=0";
118 env << "SDL_VIDEODRIVER=x11";
119 } else env << "SDL_VIDEODRIVER=" + videoDriver;
121 setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 1);
123 m_displayProcess->setEnvironment(env);
125 if (KdenliveSettings::video4capture().isEmpty()) {
126 QString captureCommand;
127 if (!KdenliveSettings::video4adevice().isEmpty()) captureCommand = "-f " + KdenliveSettings::video4aformat() + " -i " + KdenliveSettings::video4adevice();
129 captureCommand += " -f " + KdenliveSettings::video4vformat() + " -s " + KdenliveSettings::video4size() + " -r " + QString::number(KdenliveSettings::video4rate()) + " -i " + KdenliveSettings::video4vdevice();
130 KdenliveSettings::setVideo4capture(captureCommand);
133 kDebug() << "/////// BUILDING MONITOR, ID: " << m_ui.video_frame->winId();
136 RecMonitor::~RecMonitor()
138 delete m_captureProcess;
139 delete m_displayProcess;
142 QString RecMonitor::name() const
147 void RecMonitor::slotConfigure()
149 emit showConfigDialog(4, m_ui.device_selector->currentIndex());
152 void RecMonitor::slotUpdateCaptureFolder()
154 if (m_captureProcess) m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
155 slotVideoDeviceChanged(m_ui.device_selector->currentIndex());
156 kDebug() << "// UPDATE CAPT FOLD: " << KdenliveSettings::capturefolder();
158 #if KDE_IS_VERSION(4,2,0)
159 // update free space info
164 void RecMonitor::slotVideoDeviceChanged(int ix)
168 m_discAction->setEnabled(false);
169 m_rewAction->setEnabled(false);
170 m_fwdAction->setEnabled(false);
171 m_recAction->setEnabled(true);
172 m_stopAction->setEnabled(false);
173 m_playAction->setEnabled(false);
174 if (KdenliveSettings::rmd_path().isEmpty()) {
175 QString rmdpath = KStandardDirs::findExe("recordmydesktop");
176 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")));
177 else KdenliveSettings::setRmd_path(rmdpath);
179 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())));
180 //m_ui.video_frame->setText(i18n("Press record button\nto start screen capture"));
183 m_discAction->setEnabled(false);
184 m_rewAction->setEnabled(false);
185 m_fwdAction->setEnabled(false);
186 m_recAction->setEnabled(true);
187 m_stopAction->setEnabled(false);
188 m_playAction->setEnabled(true);
189 checkDeviceAvailability();
192 m_discAction->setEnabled(true);
193 m_recAction->setEnabled(false);
194 m_stopAction->setEnabled(false);
195 m_playAction->setEnabled(false);
196 m_rewAction->setEnabled(false);
197 m_fwdAction->setEnabled(false);
199 // Check that dvgab is available
200 if (KdenliveSettings::dvgrab_path().isEmpty()) {
201 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
202 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")));
203 else KdenliveSettings::setDvgrab_path(dvgrabpath);
206 QString capturefile = KdenliveSettings::capturefolder();
207 if (!capturefile.endsWith("/")) capturefile.append("/");
208 QString capturename = KdenliveSettings::dvgrabfilename();
209 if (capturename.isEmpty()) capturename = "capture";
211 switch (KdenliveSettings::firewireformat()) {
223 capturename.append("xxx" + extension);
224 capturefile.append(capturename);
225 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", capturefile)));
231 QPixmap RecMonitor::mergeSideBySide(const QPixmap& pix, const QString txt)
234 QRect r = QApplication::fontMetrics().boundingRect(QRect(0, 0, m_ui.video_frame->width(), m_ui.video_frame->height()), Qt::AlignLeft, txt);
235 int strWidth = r.width();
236 int strHeight = r.height();
237 int pixWidth = pix.width();
238 int pixHeight = pix.height();
239 QPixmap res(strWidth + 8 + pixWidth, qMax(strHeight, pixHeight));
240 res.fill(Qt::transparent);
242 p.drawPixmap(0, 0, pix);
243 p.drawText(QRect(pixWidth + 8, 0, strWidth, strHeight), 0, txt);
249 void RecMonitor::checkDeviceAvailability()
251 if (!KIO::NetAccess::exists(KUrl(KdenliveSettings::video4vdevice()), KIO::NetAccess::SourceSide , this)) {
252 m_playAction->setEnabled(false);
253 m_recAction->setEnabled(false);
254 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())));
255 //m_ui.video_frame->setText(i18n("Cannot read from device %1\nPlease check drivers and access rights.", KdenliveSettings::video4vdevice()));
256 } else //m_ui.video_frame->setText(i18n("Press play or record button\nto start video capture"));
257 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())));
260 void RecMonitor::slotDisconnect()
262 if (m_captureProcess->state() == QProcess::NotRunning) {
263 m_captureTime = KDateTime::currentLocalDateTime();
264 kDebug() << "CURRENT TIME: " << m_captureTime.toString();
265 m_didCapture = false;
266 slotStartCapture(false);
267 m_discAction->setIcon(KIcon("network-disconnect"));
268 m_discAction->setText(i18n("Disonnect"));
269 m_recAction->setEnabled(true);
270 m_stopAction->setEnabled(true);
271 m_playAction->setEnabled(true);
272 m_rewAction->setEnabled(true);
273 m_fwdAction->setEnabled(true);
275 m_captureProcess->write("q", 1);
276 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
277 if (m_didCapture) manageCapturedFiles();
278 m_didCapture = false;
282 void RecMonitor::slotRewind()
284 m_captureProcess->write("a", 1);
287 void RecMonitor::slotForward()
289 m_captureProcess->write("z", 1);
292 void RecMonitor::slotStopCapture()
295 switch (m_ui.device_selector->currentIndex()) {
297 m_captureProcess->write("\e", 2);
298 m_playAction->setIcon(m_playIcon);
302 m_captureProcess->write("q\n", 3);
303 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
307 m_captureProcess->write("q\n", 3);
308 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
315 void RecMonitor::slotStartCapture(bool play)
317 if (m_captureProcess->state() != QProcess::NotRunning) {
318 if (m_ui.device_selector->currentIndex() == FIREWIRE) {
320 m_captureProcess->write("k", 1);
321 //captureProcess->write("\e", 2);
322 m_playAction->setIcon(m_playIcon);
325 m_captureProcess->write("p", 1);
326 m_playAction->setIcon(m_pauseIcon);
332 m_captureArgs.clear();
333 m_displayArgs.clear();
335 QString capturename = KdenliveSettings::dvgrabfilename();
336 QStringList dvargs = KdenliveSettings::dvgrabextra().simplified().split(" ", QString::SkipEmptyParts);
338 switch (m_ui.device_selector->currentIndex()) {
340 switch (KdenliveSettings::firewireformat()) {
343 m_captureArgs << "--format" << "raw";
344 m_displayArgs << "-f" << "dv";
348 m_captureArgs << "--format" << "dv1";
349 m_displayArgs << "-f" << "dv";
353 m_captureArgs << "--format" << "dv2";
354 m_displayArgs << "-f" << "dv";
358 m_captureArgs << "--format" << "hdv";
359 m_displayArgs << "-f" << "mpegts";
362 if (KdenliveSettings::firewireautosplit()) m_captureArgs << "--autosplit";
363 if (KdenliveSettings::firewiretimestamp()) m_captureArgs << "--timestamp";
364 if (!dvargs.isEmpty()) {
365 m_captureArgs << dvargs;
367 m_captureArgs << "-i";
368 if (capturename.isEmpty()) capturename = "capture";
369 m_captureArgs << capturename << "-";
371 m_displayArgs << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
373 m_captureProcess->setStandardOutputProcess(m_displayProcess);
374 m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
375 kDebug() << "Capture: Running dvgrab " << m_captureArgs.join(" ");
376 m_captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
377 if (play) m_captureProcess->write(" ", 1);
378 m_discAction->setEnabled(true);
381 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
382 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
383 m_captureProcess->setStandardOutputProcess(m_displayProcess);
384 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
385 m_captureProcess->start("ffmpeg", m_captureArgs);
391 if (m_ui.device_selector->currentIndex() != SCREENGRAB) {
392 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
393 m_displayProcess->start("ffplay", m_displayArgs);
394 m_ui.video_frame->setText(i18n("Initialising..."));
396 // do something when starting screen grab
400 void RecMonitor::slotRecord()
402 if (m_captureProcess->state() == QProcess::NotRunning && m_ui.device_selector->currentIndex() == FIREWIRE) {
406 switch (m_ui.device_selector->currentIndex()) {
408 m_captureProcess->write("\e", 2);
409 m_playAction->setIcon(m_playIcon);
410 m_isCapturing = false;
412 m_recAction->setChecked(false);
415 m_captureProcess->terminate();
417 //m_isCapturing = false;
418 QTimer::singleShot(1000, this, SLOT(slotStartCapture()));
421 //captureProcess->write("q\n", 3);
422 m_captureProcess->terminate();
423 m_ui.video_frame->setText(i18n("Encoding captured video..."));
424 // in case ffmpeg doesn't exit with the 'q' command, kill it one second later
425 //QTimer::singleShot(1000, captureProcess, SLOT(kill()));
429 } else if (m_ui.device_selector->currentIndex() == FIREWIRE) {
430 m_isCapturing = true;
432 m_captureProcess->write("c\n", 3);
435 if (m_captureProcess->state() == QProcess::NotRunning) {
436 m_recAction->setChecked(true);
437 QString extension = "mp4";
438 if (m_ui.device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension();
439 QString path = KdenliveSettings::capturefolder() + "/capture0000." + extension;
441 while (QFile::exists(path)) {
442 QString num = QString::number(i).rightJustified(4, '0', false);
443 path = KdenliveSettings::capturefolder() + "/capture" + num + '.' + extension;
446 m_captureFile = KUrl(path);
448 m_captureArgs.clear();
449 m_displayArgs.clear();
451 QString capturename = KdenliveSettings::dvgrabfilename();
452 if (capturename.isEmpty()) capturename = "capture";
454 switch (m_ui.device_selector->currentIndex()) {
456 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-y" << m_captureFile.path() << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
457 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
458 m_captureProcess->setStandardOutputProcess(m_displayProcess);
459 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
460 m_captureProcess->start("ffmpeg", m_captureArgs);
463 switch (KdenliveSettings::rmd_capture_type()) {
465 // Full screen capture, nothing special to do
469 m_captureArgs << "-width" << QString::number(KdenliveSettings::rmd_width()) << "-height" << QString::number(KdenliveSettings::rmd_height());
470 if (!KdenliveSettings::rmd_follow_mouse()) {
471 m_captureArgs << "-x" << QString::number(KdenliveSettings::rmd_offsetx()) << "-y" << QString::number(KdenliveSettings::rmd_offsety());
473 m_captureArgs << "--follow-mouse";
474 if (KdenliveSettings::rmd_hide_frame()) m_captureArgs << "--no-frame";
478 m_isCapturing = true;
479 if (KdenliveSettings::rmd_capture_audio()) {
480 m_captureArgs << "-freq" << KdenliveSettings::rmd_freq();
481 m_captureArgs << "-channels" << QString::number(KdenliveSettings::rmd_audio_channels());
482 if (KdenliveSettings::rmd_use_jack()) {
483 m_captureArgs << "-use-jack" << KdenliveSettings::rmd_jackports();
484 if (KdenliveSettings::rmd_jack_buffer() > 0.0)
485 m_captureArgs << "-ring-buffer-size" << QString::number(KdenliveSettings::rmd_jack_buffer());
487 if (!KdenliveSettings::rmd_alsadevicename().isEmpty())
488 m_captureArgs << "-device" << KdenliveSettings::rmd_alsadevicename();
489 if (KdenliveSettings::rmd_alsa_buffer() > 0)
490 m_captureArgs << "-buffer-size" << QString::number(KdenliveSettings::rmd_alsa_buffer());
492 } else m_captureArgs << "--no-sound";
494 if (KdenliveSettings::rmd_fullshots()) m_captureArgs << "--full-shots";
495 m_captureArgs << "-workdir" << KdenliveSettings::currenttmpfolder();
496 m_captureArgs << "-fps" << QString::number(KdenliveSettings::rmd_fps()) << "-o" << m_captureFile.path();
497 m_captureProcess->start(KdenliveSettings::rmd_path(), m_captureArgs);
498 kDebug() << "// RecordMyDesktop params: " << m_captureArgs;
505 if (m_ui.device_selector->currentIndex() != SCREENGRAB) {
506 m_isCapturing = true;
507 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
508 m_displayProcess->start("ffplay", m_displayArgs);
509 m_ui.video_frame->setText(i18n("Initialising..."));
513 m_displayProcess->kill();
514 //captureProcess->kill();
515 QTimer::singleShot(1000, this, SLOT(slotRecord()));
520 void RecMonitor::slotStartGrab(const QRect &rect) {
521 rgnGrab->deleteLater();
522 QApplication::restoreOverrideCursor();
524 if (rect.isNull()) return;
525 int width = rect.width();
526 int height = rect.height();
527 if (width % 2 != 0) width--;
528 if (height % 2 != 0) height--;
529 QString args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(width) + "x" + QString::number(height)).replace("%offset", "+" + QString::number(rect.x()) + "," + QString::number(rect.y()));
530 if (KdenliveSettings::screengrabenableaudio()) {
531 // also capture audio
532 if (KdenliveSettings::useosscapture()) m_captureArgs << KdenliveSettings::screengrabosscapture().simplified().split(' ');
533 else m_captureArgs << KdenliveSettings::screengrabalsacapture2().simplified().split(' ');
535 m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path();
536 m_isCapturing = true;
537 m_ui.video_frame->setText(i18n("Capturing..."));
538 if (KdenliveSettings::screengrabenableaudio() && !KdenliveSettings::useosscapture()) {
539 QStringList alsaArgs = KdenliveSettings::screengrabalsacapture().simplified().split(' ');
540 alsaProcess->setStandardOutputProcess(captureProcess);
541 kDebug() << "Capture: Running arecord " << alsaArgs.join(" ");
542 alsaProcess->start("arecord", alsaArgs);
544 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
545 captureProcess->start("ffmpeg", m_captureArgs);
548 void RecMonitor::slotProcessStatus(QProcess::ProcessState status)
550 if (status == QProcess::NotRunning) {
551 m_displayProcess->kill();
552 if (m_isCapturing && m_ui.device_selector->currentIndex() != FIREWIRE)
553 if (m_ui.autoaddbox->isChecked() && QFile::exists(m_captureFile.path())) emit addProjectClip(m_captureFile);
554 if (m_ui.device_selector->currentIndex() == FIREWIRE) {
555 m_discAction->setIcon(KIcon("network-connect"));
556 m_discAction->setText(i18n("Connect"));
557 m_playAction->setEnabled(false);
558 m_rewAction->setEnabled(false);
559 m_fwdAction->setEnabled(false);
560 m_recAction->setEnabled(false);
563 m_playAction->setIcon(m_playIcon);
564 m_recAction->setChecked(false);
565 m_stopAction->setEnabled(false);
566 m_ui.device_selector->setEnabled(true);
567 if (m_captureProcess && m_captureProcess->exitStatus() == QProcess::CrashExit) {
568 m_ui.video_frame->setText(i18n("Capture crashed, please check your parameters"));
570 if (m_ui.device_selector->currentIndex() != SCREENGRAB) m_ui.video_frame->setText(i18n("Not connected"));
571 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())));
573 m_isCapturing = false;
575 #if KDE_IS_VERSION(4,2,0)
576 // update free space info
577 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
578 if (info.isValid()) {
579 m_freeSpace->setValue(100 * info.used() / info.size());
580 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
585 if (m_ui.device_selector->currentIndex() != SCREENGRAB) m_stopAction->setEnabled(true);
586 m_ui.device_selector->setEnabled(false);
590 void RecMonitor::manageCapturedFiles()
593 switch (KdenliveSettings::firewireformat()) {
605 QDir dir(KdenliveSettings::capturefolder());
607 QString capturename = KdenliveSettings::dvgrabfilename();
608 if (capturename.isEmpty()) capturename = "capture";
609 filters << capturename + "*" + extension;
610 const QStringList result = dir.entryList(filters, QDir::Files, QDir::Time);
611 KUrl::List capturedFiles;
612 foreach(const QString &name, result) {
613 KUrl url = KUrl(dir.filePath(name));
614 if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, this)) {
615 KFileItem file(KFileItem::Unknown, KFileItem::Unknown, url, true);
616 if (file.time(KFileItem::ModificationTime) > m_captureTime) capturedFiles.append(url);
619 kDebug() << "Found : " << capturedFiles.count() << " new capture files";
620 kDebug() << capturedFiles;
622 if (capturedFiles.count() > 0) {
623 ManageCapturesDialog *d = new ManageCapturesDialog(capturedFiles, this);
624 if (d->exec() == QDialog::Accepted) {
625 capturedFiles = d->importFiles();
626 foreach(const KUrl &url, capturedFiles) {
627 emit addProjectClip(url);
635 void RecMonitor::mousePressEvent(QMouseEvent * /*event*/)
637 #if KDE_IS_VERSION(4,2,0)
638 if (m_freeSpace->underMouse()) updatedFreeSpace();
642 #if KDE_IS_VERSION(4,2,0)
643 void RecMonitor::updatedFreeSpace()
645 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
646 if (info.isValid()) {
647 m_freeSpace->setValue(100 * info.used() / info.size());
648 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
649 m_freeSpace->update();
654 void RecMonitor::activateRecMonitor()
656 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
659 void RecMonitor::stop()
665 void RecMonitor::start()
671 void RecMonitor::refreshRecMonitor(bool visible)
674 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
679 void RecMonitor::slotPlay()
682 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
687 #include "recmonitor.moc"