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);
198 //m_ui.video_frame->setText(i18n("Plug your camcorder and\npress connect button\nto initialize connection"));
199 if (KdenliveSettings::dvgrab_path().isEmpty()) {
200 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
201 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")));
202 else KdenliveSettings::setDvgrab_path(dvgrabpath);
205 if (!KdenliveSettings::dvgrab_path().isEmpty()) m_ui.video_frame->setPixmap(mergeSideBySide(KIcon("network-connect").pixmap(QSize(50, 50)), i18n("Plug your camcorder and\npress connect button\nto initialize connection\nFiles will be saved in:\n%1", KdenliveSettings::capturefolder())));
210 QPixmap RecMonitor::mergeSideBySide(const QPixmap& pix, const QString txt)
213 QRect r = QApplication::fontMetrics().boundingRect(QRect(0, 0, m_ui.video_frame->width(), m_ui.video_frame->height()), Qt::AlignLeft, txt);
214 int strWidth = r.width();
215 int strHeight = r.height();
216 int pixWidth = pix.width();
217 int pixHeight = pix.height();
218 QPixmap res(strWidth + 8 + pixWidth, qMax(strHeight, pixHeight));
219 res.fill(Qt::transparent);
221 p.drawPixmap(0, 0, pix);
222 p.drawText(QRect(pixWidth + 8, 0, strWidth, strHeight), 0, txt);
228 void RecMonitor::checkDeviceAvailability()
230 if (!KIO::NetAccess::exists(KUrl(KdenliveSettings::video4vdevice()), KIO::NetAccess::SourceSide , this)) {
231 m_playAction->setEnabled(false);
232 m_recAction->setEnabled(false);
233 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())));
234 //m_ui.video_frame->setText(i18n("Cannot read from device %1\nPlease check drivers and access rights.", KdenliveSettings::video4vdevice()));
235 } else //m_ui.video_frame->setText(i18n("Press play or record button\nto start video capture"));
236 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())));
239 void RecMonitor::slotDisconnect()
241 if (m_captureProcess->state() == QProcess::NotRunning) {
242 m_captureTime = KDateTime::currentLocalDateTime();
243 kDebug() << "CURRENT TIME: " << m_captureTime.toString();
244 m_didCapture = false;
245 slotStartCapture(false);
246 m_discAction->setIcon(KIcon("network-disconnect"));
247 m_discAction->setText(i18n("Disonnect"));
248 m_recAction->setEnabled(true);
249 m_stopAction->setEnabled(true);
250 m_playAction->setEnabled(true);
251 m_rewAction->setEnabled(true);
252 m_fwdAction->setEnabled(true);
254 m_captureProcess->write("q", 1);
255 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
256 if (m_didCapture) manageCapturedFiles();
257 m_didCapture = false;
261 void RecMonitor::slotRewind()
263 m_captureProcess->write("a", 1);
266 void RecMonitor::slotForward()
268 m_captureProcess->write("z", 1);
271 void RecMonitor::slotStopCapture()
274 switch (m_ui.device_selector->currentIndex()) {
276 m_captureProcess->write("\e", 2);
277 m_playAction->setIcon(m_playIcon);
281 m_captureProcess->write("q\n", 3);
282 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
286 m_captureProcess->write("q\n", 3);
287 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
294 void RecMonitor::slotStartCapture(bool play)
298 *captureProcess<<"dvgrab";
302 switch (m_recPanel->capture_format->currentItem()){
304 *captureProcess<<"--format"<<"dv1";
307 *captureProcess<<"--format"<<"dv2";
310 *captureProcess<<"--format"<<"hdv";
314 *captureProcess<<"--format"<<"raw";
318 if (KdenliveSettings::autosplit()) *captureProcess<<"--autosplit";
319 if (KdenliveSettings::timestamp()) *captureProcess<<"--timestamp";
320 *captureProcess<<"-i"<<"capture"<<"-";*/
323 QStringList captureArgs;
324 captureArgs<<"--format"<<"hdv"<<"-i"<<"capture"<<"-";
325 QStringList displayArgs;
327 displayArgs<<"-f"<<"mpegts"<<"-x"<<QString::number(m_ui.video_frame->width())<<"-y"<<QString::number(m_ui.video_frame->height())<<"-";
329 captureProcess->setStandardOutputProcess(displayProcess);
330 m_ui.video_frame->setScaledContents(false);
331 captureProcess->start("dvgrab",captureArgs);
332 displayProcess->start("ffplay", displayArgs);*/
335 if (m_captureProcess->state() != QProcess::NotRunning) {
336 if (m_ui.device_selector->currentIndex() == FIREWIRE) {
338 m_captureProcess->write("k", 1);
339 //captureProcess->write("\e", 2);
340 m_playAction->setIcon(m_playIcon);
343 m_captureProcess->write("p", 1);
344 m_playAction->setIcon(m_pauseIcon);
350 m_captureArgs.clear();
351 m_displayArgs.clear();
354 switch (m_ui.device_selector->currentIndex()) {
356 switch (KdenliveSettings::firewireformat()) {
359 m_captureArgs << "--format" << "raw";
360 m_displayArgs << "-f" << "dv";
364 m_captureArgs << "--format" << "dv1";
365 m_displayArgs << "-f" << "dv";
369 m_captureArgs << "--format" << "dv2";
370 m_displayArgs << "-f" << "dv";
374 m_captureArgs << "--format" << "hdv";
375 m_displayArgs << "-f" << "mpegts";
378 if (KdenliveSettings::firewireautosplit()) m_captureArgs << "--autosplit";
379 if (KdenliveSettings::firewiretimestamp()) m_captureArgs << "--timestamp";
380 m_captureArgs << "-i" << "capture" << "-";
381 m_displayArgs << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
383 m_captureProcess->setStandardOutputProcess(m_displayProcess);
384 m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
385 kDebug() << "Capture: Running dvgrab " << m_captureArgs.join(" ");
386 m_captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
387 if (play) m_captureProcess->write(" ", 1);
388 m_discAction->setEnabled(true);
391 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
392 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
393 m_captureProcess->setStandardOutputProcess(m_displayProcess);
394 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
395 m_captureProcess->start("ffmpeg", m_captureArgs);
401 if (m_ui.device_selector->currentIndex() != SCREENGRAB) {
402 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
403 m_displayProcess->start("ffplay", m_displayArgs);
404 m_ui.video_frame->setText(i18n("Initialising..."));
406 // do something when starting screen grab
410 void RecMonitor::slotRecord()
412 if (m_captureProcess->state() == QProcess::NotRunning && m_ui.device_selector->currentIndex() == FIREWIRE) {
416 switch (m_ui.device_selector->currentIndex()) {
418 m_captureProcess->write("\e", 2);
419 m_playAction->setIcon(m_playIcon);
420 m_isCapturing = false;
422 m_recAction->setChecked(false);
425 m_captureProcess->terminate();
427 //m_isCapturing = false;
428 QTimer::singleShot(1000, this, SLOT(slotStartCapture()));
431 //captureProcess->write("q\n", 3);
432 m_captureProcess->terminate();
433 m_ui.video_frame->setText(i18n("Encoding captured video..."));
434 // in case ffmpeg doesn't exit with the 'q' command, kill it one second later
435 //QTimer::singleShot(1000, captureProcess, SLOT(kill()));
439 } else if (m_ui.device_selector->currentIndex() == FIREWIRE) {
440 m_isCapturing = true;
442 m_captureProcess->write("c\n", 3);
445 if (m_captureProcess->state() == QProcess::NotRunning) {
446 m_recAction->setChecked(true);
447 QString extension = "mp4";
448 if (m_ui.device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension();
449 QString path = KdenliveSettings::capturefolder() + "/capture0000." + extension;
451 while (QFile::exists(path)) {
452 QString num = QString::number(i).rightJustified(4, '0', false);
453 path = KdenliveSettings::capturefolder() + "/capture" + num + '.' + extension;
457 m_captureFile = KUrl(path);
459 m_captureArgs.clear();
460 m_displayArgs.clear();
463 switch (m_ui.device_selector->currentIndex()) {
465 m_captureArgs << "--format" << "hdv" << "-i" << "capture" << "-";
466 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
467 m_captureProcess->setStandardOutputProcess(m_displayProcess);
468 kDebug() << "Capture: Running dvgrab " << m_captureArgs.join(" ");
469 m_captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
472 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-y" << m_captureFile.path() << "-f" << "mpegts" << "-vcodec" << "mpeg4" << "-acodec" << "mp2" << "-";
473 m_displayArgs << "-f" << "mpegts" << "-x" << QString::number(m_ui.video_frame->width()) << "-y" << QString::number(m_ui.video_frame->height()) << "-";
474 m_captureProcess->setStandardOutputProcess(m_displayProcess);
475 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
476 m_captureProcess->start("ffmpeg", m_captureArgs);
479 switch (KdenliveSettings::rmd_capture_type()) {
481 // Full screen capture, nothing special to do
485 m_captureArgs << "-width" << QString::number(KdenliveSettings::rmd_width()) << "-height" << QString::number(KdenliveSettings::rmd_height());
486 if (!KdenliveSettings::rmd_follow_mouse()) {
487 m_captureArgs << "-x" << QString::number(KdenliveSettings::rmd_offsetx()) << "-y" << QString::number(KdenliveSettings::rmd_offsety());
489 m_captureArgs << "--follow-mouse";
490 if (KdenliveSettings::rmd_hide_frame()) m_captureArgs << "--no-frame";
494 m_isCapturing = true;
495 if (KdenliveSettings::rmd_capture_audio()) {
496 m_captureArgs << "-freq" << KdenliveSettings::rmd_freq();
497 m_captureArgs << "-channels" << QString::number(KdenliveSettings::rmd_audio_channels());
498 if (KdenliveSettings::rmd_use_jack()) {
499 m_captureArgs << "-use-jack" << KdenliveSettings::rmd_jackports();
500 if (KdenliveSettings::rmd_jack_buffer() > 0.0)
501 m_captureArgs << "-ring-buffer-size" << QString::number(KdenliveSettings::rmd_jack_buffer());
503 if (!KdenliveSettings::rmd_alsadevicename().isEmpty())
504 m_captureArgs << "-device" << KdenliveSettings::rmd_alsadevicename();
505 if (KdenliveSettings::rmd_alsa_buffer() > 0)
506 m_captureArgs << "-buffer-size" << QString::number(KdenliveSettings::rmd_alsa_buffer());
508 } else m_captureArgs << "--no-sound";
510 if (KdenliveSettings::rmd_fullshots()) m_captureArgs << "--full-shots";
511 m_captureArgs << "-workdir" << KdenliveSettings::currenttmpfolder();
512 m_captureArgs << "-fps" << QString::number(KdenliveSettings::rmd_fps()) << "-o" << m_captureFile.path();
513 m_captureProcess->start(KdenliveSettings::rmd_path(), m_captureArgs);
514 kDebug() << "// RecordMyDesktop params: " << m_captureArgs;
521 if (m_ui.device_selector->currentIndex() != SCREENGRAB) {
522 m_isCapturing = true;
523 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
524 m_displayProcess->start("ffplay", m_displayArgs);
525 m_ui.video_frame->setText(i18n("Initialising..."));
529 m_displayProcess->kill();
530 //captureProcess->kill();
531 QTimer::singleShot(1000, this, SLOT(slotRecord()));
536 void RecMonitor::slotStartGrab(const QRect &rect) {
537 rgnGrab->deleteLater();
538 QApplication::restoreOverrideCursor();
540 if (rect.isNull()) return;
541 int width = rect.width();
542 int height = rect.height();
543 if (width % 2 != 0) width--;
544 if (height % 2 != 0) height--;
545 QString args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(width) + "x" + QString::number(height)).replace("%offset", "+" + QString::number(rect.x()) + "," + QString::number(rect.y()));
546 if (KdenliveSettings::screengrabenableaudio()) {
547 // also capture audio
548 if (KdenliveSettings::useosscapture()) m_captureArgs << KdenliveSettings::screengrabosscapture().simplified().split(' ');
549 else m_captureArgs << KdenliveSettings::screengrabalsacapture2().simplified().split(' ');
551 m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path();
552 m_isCapturing = true;
553 m_ui.video_frame->setText(i18n("Capturing..."));
554 if (KdenliveSettings::screengrabenableaudio() && !KdenliveSettings::useosscapture()) {
555 QStringList alsaArgs = KdenliveSettings::screengrabalsacapture().simplified().split(' ');
556 alsaProcess->setStandardOutputProcess(captureProcess);
557 kDebug() << "Capture: Running arecord " << alsaArgs.join(" ");
558 alsaProcess->start("arecord", alsaArgs);
560 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
561 captureProcess->start("ffmpeg", m_captureArgs);
564 void RecMonitor::slotProcessStatus(QProcess::ProcessState status)
566 if (status == QProcess::NotRunning) {
567 m_displayProcess->kill();
568 if (m_isCapturing && m_ui.device_selector->currentIndex() != FIREWIRE)
569 if (m_ui.autoaddbox->isChecked() && QFile::exists(m_captureFile.path())) emit addProjectClip(m_captureFile);
570 if (m_ui.device_selector->currentIndex() == FIREWIRE) {
571 m_discAction->setIcon(KIcon("network-connect"));
572 m_discAction->setText(i18n("Connect"));
573 m_playAction->setEnabled(false);
574 m_rewAction->setEnabled(false);
575 m_fwdAction->setEnabled(false);
576 m_recAction->setEnabled(false);
579 m_playAction->setIcon(m_playIcon);
580 m_recAction->setChecked(false);
581 m_stopAction->setEnabled(false);
582 m_ui.device_selector->setEnabled(true);
583 if (m_captureProcess && m_captureProcess->exitStatus() == QProcess::CrashExit) {
584 m_ui.video_frame->setText(i18n("Capture crashed, please check your parameters"));
586 if (m_ui.device_selector->currentIndex() != SCREENGRAB) m_ui.video_frame->setText(i18n("Not connected"));
587 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())));
589 m_isCapturing = false;
591 #if KDE_IS_VERSION(4,2,0)
592 // update free space info
593 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
594 if (info.isValid()) {
595 m_freeSpace->setValue(100 * info.used() / info.size());
596 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
601 if (m_ui.device_selector->currentIndex() != SCREENGRAB) m_stopAction->setEnabled(true);
602 m_ui.device_selector->setEnabled(false);
606 void RecMonitor::manageCapturedFiles()
609 switch (KdenliveSettings::firewireformat()) {
621 QDir dir(KdenliveSettings::capturefolder());
623 filters << "capture*" + extension;
624 const QStringList result = dir.entryList(filters, QDir::Files, QDir::Time);
625 KUrl::List capturedFiles;
626 foreach(const QString &name, result) {
627 KUrl url = KUrl(dir.filePath(name));
628 if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, this)) {
629 KFileItem file(KFileItem::Unknown, KFileItem::Unknown, url, true);
630 if (file.time(KFileItem::ModificationTime) > m_captureTime) capturedFiles.append(url);
633 kDebug() << "Found : " << capturedFiles.count() << " new capture files";
634 kDebug() << capturedFiles;
636 if (capturedFiles.count() > 0) {
637 ManageCapturesDialog *d = new ManageCapturesDialog(capturedFiles, this);
638 if (d->exec() == QDialog::Accepted) {
639 capturedFiles = d->importFiles();
640 foreach(const KUrl &url, capturedFiles) {
641 emit addProjectClip(url);
649 void RecMonitor::mousePressEvent(QMouseEvent * /*event*/)
651 #if KDE_IS_VERSION(4,2,0)
652 if (m_freeSpace->underMouse()) updatedFreeSpace();
656 #if KDE_IS_VERSION(4,2,0)
657 void RecMonitor::updatedFreeSpace()
659 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
660 if (info.isValid()) {
661 m_freeSpace->setValue(100 * info.used() / info.size());
662 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
663 m_freeSpace->update();
668 void RecMonitor::activateRecMonitor()
670 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
673 void RecMonitor::stop()
679 void RecMonitor::start()
685 void RecMonitor::refreshRecMonitor(bool visible)
688 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
693 void RecMonitor::slotPlay()
696 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
701 #include "recmonitor.moc"