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 layout->addWidget(&m_dvinfo);
96 #if KDE_IS_VERSION(4,2,0)
97 m_freeSpace = new KCapacityBar(KCapacityBar::DrawTextInline, this);
98 m_freeSpace->setMaximumWidth(150);
99 QFontMetricsF fontMetrics(font());
100 m_freeSpace->setMaximumHeight(fontMetrics.height() * 1.2);
102 layout->addWidget(m_freeSpace);
105 m_ui.control_frame_firewire->setLayout(layout);
107 slotVideoDeviceChanged(m_ui.device_selector->currentIndex());
108 m_displayProcess = new QProcess;
109 m_captureProcess = new QProcess;
111 connect(m_captureProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(slotProcessStatus(QProcess::ProcessState)));
113 QStringList env = QProcess::systemEnvironment();
114 env << "SDL_WINDOWID=" + QString::number(m_ui.video_frame->winId());
116 QString videoDriver = KdenliveSettings::videodrivername();
117 if (!videoDriver.isEmpty()) {
118 if (videoDriver == "x11_noaccel") {
119 env << "SDL_VIDEO_YUV_HWACCEL=0";
120 env << "SDL_VIDEODRIVER=x11";
121 } else env << "SDL_VIDEODRIVER=" + videoDriver;
123 setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 1);
125 m_displayProcess->setEnvironment(env);
127 if (KdenliveSettings::video4capture().isEmpty()) {
128 QString captureCommand;
129 if (!KdenliveSettings::video4adevice().isEmpty()) captureCommand = "-f " + KdenliveSettings::video4aformat() + " -i " + KdenliveSettings::video4adevice();
131 captureCommand += " -f " + KdenliveSettings::video4vformat() + " -s " + KdenliveSettings::video4size() + " -r " + QString::number(KdenliveSettings::video4rate()) + " -i " + KdenliveSettings::video4vdevice();
132 KdenliveSettings::setVideo4capture(captureCommand);
135 kDebug() << "/////// BUILDING MONITOR, ID: " << m_ui.video_frame->winId();
138 RecMonitor::~RecMonitor()
140 delete m_captureProcess;
141 delete m_displayProcess;
144 QString RecMonitor::name() const
149 void RecMonitor::slotConfigure()
151 emit showConfigDialog(4, m_ui.device_selector->currentIndex());
154 void RecMonitor::slotUpdateCaptureFolder()
156 if (m_captureProcess) m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
157 slotVideoDeviceChanged(m_ui.device_selector->currentIndex());
158 kDebug() << "// UPDATE CAPT FOLD: " << KdenliveSettings::capturefolder();
160 #if KDE_IS_VERSION(4,2,0)
161 // update free space info
166 void RecMonitor::slotVideoDeviceChanged(int ix)
170 m_discAction->setEnabled(false);
171 m_rewAction->setEnabled(false);
172 m_fwdAction->setEnabled(false);
173 m_recAction->setEnabled(true);
174 m_stopAction->setEnabled(false);
175 m_playAction->setEnabled(false);
176 if (KdenliveSettings::rmd_path().isEmpty()) {
177 QString rmdpath = KStandardDirs::findExe("recordmydesktop");
178 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")));
179 else KdenliveSettings::setRmd_path(rmdpath);
181 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())));
182 //m_ui.video_frame->setText(i18n("Press record button\nto start screen capture"));
185 m_discAction->setEnabled(false);
186 m_rewAction->setEnabled(false);
187 m_fwdAction->setEnabled(false);
188 m_recAction->setEnabled(true);
189 m_stopAction->setEnabled(false);
190 m_playAction->setEnabled(true);
191 checkDeviceAvailability();
194 m_discAction->setEnabled(true);
195 m_recAction->setEnabled(false);
196 m_stopAction->setEnabled(false);
197 m_playAction->setEnabled(false);
198 m_rewAction->setEnabled(false);
199 m_fwdAction->setEnabled(false);
201 // Check that dvgab is available
202 if (KdenliveSettings::dvgrab_path().isEmpty()) {
203 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
204 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")));
205 else KdenliveSettings::setDvgrab_path(dvgrabpath);
208 QString capturefile = KdenliveSettings::capturefolder();
209 if (!capturefile.endsWith("/")) capturefile.append("/");
210 QString capturename = KdenliveSettings::dvgrabfilename();
211 if (capturename.isEmpty()) capturename = "capture";
213 switch (KdenliveSettings::firewireformat()) {
225 capturename.append("xxx" + extension);
226 capturefile.append(capturename);
227 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)));
233 QPixmap RecMonitor::mergeSideBySide(const QPixmap& pix, const QString txt)
236 QRect r = QApplication::fontMetrics().boundingRect(QRect(0, 0, m_ui.video_frame->width(), m_ui.video_frame->height()), Qt::AlignLeft, txt);
237 int strWidth = r.width();
238 int strHeight = r.height();
239 int pixWidth = pix.width();
240 int pixHeight = pix.height();
241 QPixmap res(strWidth + 8 + pixWidth, qMax(strHeight, pixHeight));
242 res.fill(Qt::transparent);
244 p.drawPixmap(0, 0, pix);
245 p.drawText(QRect(pixWidth + 8, 0, strWidth, strHeight), 0, txt);
251 void RecMonitor::checkDeviceAvailability()
253 if (!KIO::NetAccess::exists(KUrl(KdenliveSettings::video4vdevice()), KIO::NetAccess::SourceSide , this)) {
254 m_playAction->setEnabled(false);
255 m_recAction->setEnabled(false);
256 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())));
257 //m_ui.video_frame->setText(i18n("Cannot read from device %1\nPlease check drivers and access rights.", KdenliveSettings::video4vdevice()));
258 } else //m_ui.video_frame->setText(i18n("Press play or record button\nto start video capture"));
259 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())));
262 void RecMonitor::slotDisconnect()
264 if (m_captureProcess->state() == QProcess::NotRunning) {
265 m_captureTime = KDateTime::currentLocalDateTime();
266 kDebug() << "CURRENT TIME: " << m_captureTime.toString();
267 m_didCapture = false;
268 slotStartCapture(false);
269 m_discAction->setIcon(KIcon("network-disconnect"));
270 m_discAction->setText(i18n("Disonnect"));
271 m_recAction->setEnabled(true);
272 m_stopAction->setEnabled(true);
273 m_playAction->setEnabled(true);
274 m_rewAction->setEnabled(true);
275 m_fwdAction->setEnabled(true);
277 m_captureProcess->write("q", 1);
278 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
279 if (m_didCapture) manageCapturedFiles();
280 m_didCapture = false;
284 void RecMonitor::slotRewind()
286 m_captureProcess->write("a", 1);
289 void RecMonitor::slotForward()
291 m_captureProcess->write("z", 1);
294 void RecMonitor::slotStopCapture()
297 switch (m_ui.device_selector->currentIndex()) {
299 m_captureProcess->write("\e", 2);
300 m_playAction->setIcon(m_playIcon);
304 m_captureProcess->write("q\n", 3);
305 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
309 m_captureProcess->write("q\n", 3);
310 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
317 void RecMonitor::slotStartCapture(bool play)
319 if (m_captureProcess->state() != QProcess::NotRunning) {
320 if (m_ui.device_selector->currentIndex() == FIREWIRE) {
322 m_captureProcess->write("k", 1);
323 //captureProcess->write("\e", 2);
324 m_playAction->setIcon(m_playIcon);
327 m_captureProcess->write("p", 1);
328 m_playAction->setIcon(m_pauseIcon);
334 m_captureArgs.clear();
335 m_displayArgs.clear();
337 QString capturename = KdenliveSettings::dvgrabfilename();
338 QStringList dvargs = KdenliveSettings::dvgrabextra().simplified().split(" ", QString::SkipEmptyParts);
340 switch (m_ui.device_selector->currentIndex()) {
342 switch (KdenliveSettings::firewireformat()) {
345 m_captureArgs << "--format" << "raw";
346 m_displayArgs << "-f" << "dv";
350 m_captureArgs << "--format" << "dv1";
351 m_displayArgs << "-f" << "dv";
355 m_captureArgs << "--format" << "dv2";
356 m_displayArgs << "-f" << "dv";
360 m_captureArgs << "--format" << "hdv";
361 m_displayArgs << "-f" << "mpegts";
364 if (KdenliveSettings::firewireautosplit()) m_captureArgs << "--autosplit";
365 if (KdenliveSettings::firewiretimestamp()) m_captureArgs << "--timestamp";
366 if (!dvargs.isEmpty()) {
367 m_captureArgs << dvargs;
369 m_captureArgs << "-i";
370 if (capturename.isEmpty()) capturename = "capture";
371 m_captureArgs << capturename << "-";
373 m_displayArgs << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
375 m_captureProcess->setStandardOutputProcess(m_displayProcess);
376 m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
377 kDebug() << "Capture: Running dvgrab " << m_captureArgs.join(" ");
378 connect(m_captureProcess, SIGNAL(readyReadStandardError()), this, SLOT(slotReadDvgrabInfo()));
379 m_captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
380 if (play) m_captureProcess->write(" ", 1);
381 m_discAction->setEnabled(true);
384 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
385 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
386 m_captureProcess->setStandardOutputProcess(m_displayProcess);
387 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
388 m_captureProcess->start("ffmpeg", m_captureArgs);
394 if (m_ui.device_selector->currentIndex() != SCREENGRAB) {
395 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
396 m_displayProcess->start("ffplay", m_displayArgs);
397 m_ui.video_frame->setText(i18n("Initialising..."));
399 // do something when starting screen grab
403 void RecMonitor::slotRecord()
405 if (m_captureProcess->state() == QProcess::NotRunning && m_ui.device_selector->currentIndex() == FIREWIRE) {
409 switch (m_ui.device_selector->currentIndex()) {
411 m_captureProcess->write("\e", 2);
412 m_playAction->setIcon(m_playIcon);
413 m_isCapturing = false;
415 m_recAction->setChecked(false);
418 m_captureProcess->terminate();
420 //m_isCapturing = false;
421 QTimer::singleShot(1000, this, SLOT(slotStartCapture()));
424 //captureProcess->write("q\n", 3);
425 m_captureProcess->terminate();
426 m_ui.video_frame->setText(i18n("Encoding captured video..."));
427 // in case ffmpeg doesn't exit with the 'q' command, kill it one second later
428 //QTimer::singleShot(1000, captureProcess, SLOT(kill()));
432 } else if (m_ui.device_selector->currentIndex() == FIREWIRE) {
433 m_isCapturing = true;
435 m_captureProcess->write("c\n", 3);
438 if (m_captureProcess->state() == QProcess::NotRunning) {
439 m_recAction->setChecked(true);
440 QString extension = "mp4";
441 if (m_ui.device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension();
442 QString path = KdenliveSettings::capturefolder() + "/capture0000." + extension;
444 while (QFile::exists(path)) {
445 QString num = QString::number(i).rightJustified(4, '0', false);
446 path = KdenliveSettings::capturefolder() + "/capture" + num + '.' + extension;
449 m_captureFile = KUrl(path);
451 m_captureArgs.clear();
452 m_displayArgs.clear();
454 QString capturename = KdenliveSettings::dvgrabfilename();
455 if (capturename.isEmpty()) capturename = "capture";
457 switch (m_ui.device_selector->currentIndex()) {
459 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-y" << m_captureFile.path() << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
460 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
461 m_captureProcess->setStandardOutputProcess(m_displayProcess);
462 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
463 m_captureProcess->start("ffmpeg", m_captureArgs);
466 switch (KdenliveSettings::rmd_capture_type()) {
468 // Full screen capture, nothing special to do
472 m_captureArgs << "-width" << QString::number(KdenliveSettings::rmd_width()) << "-height" << QString::number(KdenliveSettings::rmd_height());
473 if (!KdenliveSettings::rmd_follow_mouse()) {
474 m_captureArgs << "-x" << QString::number(KdenliveSettings::rmd_offsetx()) << "-y" << QString::number(KdenliveSettings::rmd_offsety());
476 m_captureArgs << "--follow-mouse";
477 if (KdenliveSettings::rmd_hide_frame()) m_captureArgs << "--no-frame";
481 m_isCapturing = true;
482 if (KdenliveSettings::rmd_capture_audio()) {
483 m_captureArgs << "-freq" << KdenliveSettings::rmd_freq();
484 m_captureArgs << "-channels" << QString::number(KdenliveSettings::rmd_audio_channels());
485 if (KdenliveSettings::rmd_use_jack()) {
486 m_captureArgs << "-use-jack" << KdenliveSettings::rmd_jackports();
487 if (KdenliveSettings::rmd_jack_buffer() > 0.0)
488 m_captureArgs << "-ring-buffer-size" << QString::number(KdenliveSettings::rmd_jack_buffer());
490 if (!KdenliveSettings::rmd_alsadevicename().isEmpty())
491 m_captureArgs << "-device" << KdenliveSettings::rmd_alsadevicename();
492 if (KdenliveSettings::rmd_alsa_buffer() > 0)
493 m_captureArgs << "-buffer-size" << QString::number(KdenliveSettings::rmd_alsa_buffer());
495 } else m_captureArgs << "--no-sound";
497 if (KdenliveSettings::rmd_fullshots()) m_captureArgs << "--full-shots";
498 m_captureArgs << "-workdir" << KdenliveSettings::currenttmpfolder();
499 m_captureArgs << "-fps" << QString::number(KdenliveSettings::rmd_fps()) << "-o" << m_captureFile.path();
500 m_captureProcess->start(KdenliveSettings::rmd_path(), m_captureArgs);
501 kDebug() << "// RecordMyDesktop params: " << m_captureArgs;
508 if (m_ui.device_selector->currentIndex() != SCREENGRAB) {
509 m_isCapturing = true;
510 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
511 m_displayProcess->start("ffplay", m_displayArgs);
512 m_ui.video_frame->setText(i18n("Initialising..."));
516 m_displayProcess->kill();
517 //captureProcess->kill();
518 QTimer::singleShot(1000, this, SLOT(slotRecord()));
523 void RecMonitor::slotStartGrab(const QRect &rect) {
524 rgnGrab->deleteLater();
525 QApplication::restoreOverrideCursor();
527 if (rect.isNull()) return;
528 int width = rect.width();
529 int height = rect.height();
530 if (width % 2 != 0) width--;
531 if (height % 2 != 0) height--;
532 QString args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(width) + "x" + QString::number(height)).replace("%offset", "+" + QString::number(rect.x()) + "," + QString::number(rect.y()));
533 if (KdenliveSettings::screengrabenableaudio()) {
534 // also capture audio
535 if (KdenliveSettings::useosscapture()) m_captureArgs << KdenliveSettings::screengrabosscapture().simplified().split(' ');
536 else m_captureArgs << KdenliveSettings::screengrabalsacapture2().simplified().split(' ');
538 m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path();
539 m_isCapturing = true;
540 m_ui.video_frame->setText(i18n("Capturing..."));
541 if (KdenliveSettings::screengrabenableaudio() && !KdenliveSettings::useosscapture()) {
542 QStringList alsaArgs = KdenliveSettings::screengrabalsacapture().simplified().split(' ');
543 alsaProcess->setStandardOutputProcess(captureProcess);
544 kDebug() << "Capture: Running arecord " << alsaArgs.join(" ");
545 alsaProcess->start("arecord", alsaArgs);
547 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
548 captureProcess->start("ffmpeg", m_captureArgs);
551 void RecMonitor::slotProcessStatus(QProcess::ProcessState status)
553 if (status == QProcess::NotRunning) {
554 m_displayProcess->kill();
555 if (m_isCapturing && m_ui.device_selector->currentIndex() != FIREWIRE)
556 if (m_ui.autoaddbox->isChecked() && QFile::exists(m_captureFile.path())) emit addProjectClip(m_captureFile);
557 if (m_ui.device_selector->currentIndex() == FIREWIRE) {
558 m_discAction->setIcon(KIcon("network-connect"));
559 m_discAction->setText(i18n("Connect"));
560 m_playAction->setEnabled(false);
561 m_rewAction->setEnabled(false);
562 m_fwdAction->setEnabled(false);
563 m_recAction->setEnabled(false);
566 m_playAction->setIcon(m_playIcon);
567 m_recAction->setChecked(false);
568 m_stopAction->setEnabled(false);
569 m_ui.device_selector->setEnabled(true);
570 if (m_captureProcess && m_captureProcess->exitStatus() == QProcess::CrashExit) {
571 m_ui.video_frame->setText(i18n("Capture crashed, please check your parameters"));
573 if (m_ui.device_selector->currentIndex() != SCREENGRAB) m_ui.video_frame->setText(i18n("Not connected"));
574 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())));
576 m_isCapturing = false;
578 #if KDE_IS_VERSION(4,2,0)
579 // update free space info
580 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
581 if (info.isValid()) {
582 m_freeSpace->setValue(100 * info.used() / info.size());
583 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
588 if (m_ui.device_selector->currentIndex() != SCREENGRAB) m_stopAction->setEnabled(true);
589 m_ui.device_selector->setEnabled(false);
593 void RecMonitor::manageCapturedFiles()
596 switch (KdenliveSettings::firewireformat()) {
608 QDir dir(KdenliveSettings::capturefolder());
610 QString capturename = KdenliveSettings::dvgrabfilename();
611 if (capturename.isEmpty()) capturename = "capture";
612 filters << capturename + "*" + extension;
613 const QStringList result = dir.entryList(filters, QDir::Files, QDir::Time);
614 KUrl::List capturedFiles;
615 foreach(const QString &name, result) {
616 KUrl url = KUrl(dir.filePath(name));
617 if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, this)) {
618 KFileItem file(KFileItem::Unknown, KFileItem::Unknown, url, true);
619 if (file.time(KFileItem::ModificationTime) > m_captureTime) capturedFiles.append(url);
622 kDebug() << "Found : " << capturedFiles.count() << " new capture files";
623 kDebug() << capturedFiles;
625 if (capturedFiles.count() > 0) {
626 ManageCapturesDialog *d = new ManageCapturesDialog(capturedFiles, this);
627 if (d->exec() == QDialog::Accepted) {
628 capturedFiles = d->importFiles();
629 foreach(const KUrl &url, capturedFiles) {
630 emit addProjectClip(url);
638 void RecMonitor::mousePressEvent(QMouseEvent * /*event*/)
640 #if KDE_IS_VERSION(4,2,0)
641 if (m_freeSpace->underMouse()) updatedFreeSpace();
645 #if KDE_IS_VERSION(4,2,0)
646 void RecMonitor::updatedFreeSpace()
648 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
649 if (info.isValid()) {
650 m_freeSpace->setValue(100 * info.used() / info.size());
651 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
652 m_freeSpace->update();
657 void RecMonitor::activateRecMonitor()
659 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
662 void RecMonitor::stop()
668 void RecMonitor::start()
674 void RecMonitor::refreshRecMonitor(bool visible)
677 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
682 void RecMonitor::slotPlay()
685 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
689 void RecMonitor::slotReadDvgrabInfo()
691 QString data = m_captureProcess->readAllStandardError().simplified();
692 data = data.section('"', 2, 2).simplified();
693 m_dvinfo.setText(data);
694 m_dvinfo.updateGeometry();
698 #include "recmonitor.moc"