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>
34 #include <KApplication>
36 #if KDE_IS_VERSION(4,2,0)
37 #include <KDiskFreeSpaceInfo>
40 #include <QMouseEvent>
42 #include <QToolButton>
47 RecMonitor::RecMonitor(QString name, QWidget *parent) :
57 video_frame->setAttribute(Qt::WA_PaintOnScreen);
58 device_selector->setCurrentIndex(KdenliveSettings::defaultcapture());
59 connect(device_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(slotVideoDeviceChanged(int)));
63 QToolBar *toolbar = new QToolBar(name, this);
64 QHBoxLayout *layout = new QHBoxLayout;
65 layout->setContentsMargins(0, 0, 0, 0);
66 m_playIcon = KIcon("media-playback-start");
67 m_pauseIcon = KIcon("media-playback-pause");
69 m_discAction = toolbar->addAction(KIcon("network-connect"), i18n("Connect"));
70 connect(m_discAction, SIGNAL(triggered()), this, SLOT(slotDisconnect()));
72 m_rewAction = toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind"));
73 connect(m_rewAction, SIGNAL(triggered()), this, SLOT(slotRewind()));
75 m_playAction = toolbar->addAction(m_playIcon, i18n("Play"));
76 connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotStartCapture()));
78 m_stopAction = toolbar->addAction(KIcon("media-playback-stop"), i18n("Stop"));
79 connect(m_stopAction, SIGNAL(triggered()), this, SLOT(slotStopCapture()));
80 m_stopAction->setEnabled(false);
81 m_fwdAction = toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward"));
82 connect(m_fwdAction, SIGNAL(triggered()), this, SLOT(slotForward()));
84 m_recAction = toolbar->addAction(KIcon("media-record"), i18n("Record"));
85 connect(m_recAction, SIGNAL(triggered()), this, SLOT(slotRecord()));
86 m_recAction->setCheckable(true);
88 toolbar->addSeparator();
90 QAction *configAction = toolbar->addAction(KIcon("configure"), i18n("Configure"));
91 connect(configAction, SIGNAL(triggered()), this, SLOT(slotConfigure()));
92 configAction->setCheckable(false);
94 layout->addWidget(toolbar);
96 layout->addWidget(&m_dvinfo);
98 #if KDE_IS_VERSION(4,2,0)
99 m_freeSpace = new KCapacityBar(KCapacityBar::DrawTextInline, this);
100 m_freeSpace->setMaximumWidth(150);
101 QFontMetricsF fontMetrics(font());
102 m_freeSpace->setMaximumHeight(fontMetrics.height() * 1.2);
103 slotUpdateFreeSpace();
104 layout->addWidget(m_freeSpace);
105 connect(&m_spaceTimer, SIGNAL(timeout()), this, SLOT(slotUpdateFreeSpace()));
106 m_spaceTimer.setInterval(30000);
107 m_spaceTimer.setSingleShot(false);
110 control_frame_firewire->setLayout(layout);
112 slotVideoDeviceChanged(device_selector->currentIndex());
113 m_displayProcess = new QProcess;
114 m_captureProcess = new QProcess;
116 connect(m_captureProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(slotProcessStatus(QProcess::ProcessState)));
117 connect(m_captureProcess, SIGNAL(readyReadStandardError()), this, SLOT(slotReadDvgrabInfo()));
119 QStringList env = QProcess::systemEnvironment();
120 env << "SDL_WINDOWID=" + QString::number(video_frame->winId());
122 QString videoDriver = KdenliveSettings::videodrivername();
123 if (!videoDriver.isEmpty()) {
124 if (videoDriver == "x11_noaccel") {
125 env << "SDL_VIDEO_YUV_HWACCEL=0";
126 env << "SDL_VIDEODRIVER=x11";
127 } else env << "SDL_VIDEODRIVER=" + videoDriver;
129 setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 1);
131 m_displayProcess->setEnvironment(env);
133 if (KdenliveSettings::video4capture().isEmpty()) {
134 QString captureCommand;
135 if (!KdenliveSettings::video4adevice().isEmpty()) captureCommand = "-f " + KdenliveSettings::video4aformat() + " -i " + KdenliveSettings::video4adevice() + " -acodec " + KdenliveSettings::video4acodec();
137 captureCommand += " -f " + KdenliveSettings::video4vformat() + " -s " + KdenliveSettings::video4size() + " -r " + QString::number(KdenliveSettings::video4rate()) + " -i " + KdenliveSettings::video4vdevice() + " -vcodec " + KdenliveSettings::video4vcodec();;
138 KdenliveSettings::setVideo4capture(captureCommand);
141 kDebug() << "/////// BUILDING MONITOR, ID: " << video_frame->winId();
144 RecMonitor::~RecMonitor()
146 #if KDE_IS_VERSION(4,2,0)
149 delete m_captureProcess;
150 delete m_displayProcess;
153 QString RecMonitor::name() const
158 void RecMonitor::slotConfigure()
160 emit showConfigDialog(4, device_selector->currentIndex());
163 void RecMonitor::slotUpdateCaptureFolder(const QString currentProjectFolder)
165 if (KdenliveSettings::capturetoprojectfolder()) m_capturePath = currentProjectFolder;
166 else m_capturePath = KdenliveSettings::capturefolder();
167 if (m_captureProcess) m_captureProcess->setWorkingDirectory(m_capturePath);
168 if (m_captureProcess->state() != QProcess::NotRunning) {
169 if (device_selector->currentIndex() == FIREWIRE)
170 KMessageBox::information(this, i18n("You need to disconnect and reconnect in the capture monitor to apply your changes"), i18n("Capturing"));
171 else KMessageBox::information(this, i18n("You need to stop capture before your changes can be applied"), i18n("Capturing"));
172 } else slotVideoDeviceChanged(device_selector->currentIndex());
174 #if KDE_IS_VERSION(4,2,0)
175 // update free space info
176 slotUpdateFreeSpace();
180 void RecMonitor::slotVideoDeviceChanged(int ix)
184 m_discAction->setEnabled(false);
185 m_rewAction->setEnabled(false);
186 m_fwdAction->setEnabled(false);
187 m_recAction->setEnabled(true);
188 m_stopAction->setEnabled(false);
189 m_playAction->setEnabled(false);
190 if (KdenliveSettings::rmd_path().isEmpty()) {
191 QString rmdpath = KStandardDirs::findExe("recordmydesktop");
192 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")));
193 else KdenliveSettings::setRmd_path(rmdpath);
195 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", m_capturePath)));
196 //video_frame->setText(i18n("Press record button\nto start screen capture"));
199 m_discAction->setEnabled(false);
200 m_rewAction->setEnabled(false);
201 m_fwdAction->setEnabled(false);
202 m_recAction->setEnabled(true);
203 m_stopAction->setEnabled(false);
204 m_playAction->setEnabled(true);
205 checkDeviceAvailability();
208 m_discAction->setEnabled(true);
209 m_recAction->setEnabled(false);
210 m_stopAction->setEnabled(false);
211 m_playAction->setEnabled(false);
212 m_rewAction->setEnabled(false);
213 m_fwdAction->setEnabled(false);
215 // Check that dvgab is available
216 if (KdenliveSettings::dvgrab_path().isEmpty()) {
217 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
218 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")));
219 else KdenliveSettings::setDvgrab_path(dvgrabpath);
222 QString capturefile = m_capturePath;
223 if (!capturefile.endsWith("/")) capturefile.append("/");
224 QString capturename = KdenliveSettings::dvgrabfilename();
225 if (capturename.isEmpty()) capturename = "capture";
227 switch (KdenliveSettings::firewireformat()) {
239 capturename.append("xxx" + extension);
240 capturefile.append(capturename);
241 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)));
247 QPixmap RecMonitor::mergeSideBySide(const QPixmap& pix, const QString txt)
250 QRect r = QApplication::fontMetrics().boundingRect(QRect(0, 0, video_frame->width(), video_frame->height()), Qt::AlignLeft, txt);
251 int strWidth = r.width();
252 int strHeight = r.height();
253 int pixWidth = pix.width();
254 int pixHeight = pix.height();
255 QPixmap res(strWidth + 8 + pixWidth, qMax(strHeight, pixHeight));
256 res.fill(Qt::transparent);
258 p.drawPixmap(0, 0, pix);
259 p.setPen(kapp->palette().text().color());
260 p.drawText(QRect(pixWidth + 8, 0, strWidth, strHeight), 0, txt);
266 void RecMonitor::checkDeviceAvailability()
268 if (!KIO::NetAccess::exists(KUrl(KdenliveSettings::video4vdevice()), KIO::NetAccess::SourceSide , this)) {
269 m_playAction->setEnabled(false);
270 m_recAction->setEnabled(false);
271 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())));
272 //video_frame->setText(i18n("Cannot read from device %1\nPlease check drivers and access rights.", KdenliveSettings::video4vdevice()));
273 } else //video_frame->setText(i18n("Press play or record button\nto start video capture"));
274 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", m_capturePath)));
277 void RecMonitor::slotDisconnect()
279 if (m_captureProcess->state() == QProcess::NotRunning) {
280 m_captureTime = KDateTime::currentLocalDateTime();
281 kDebug() << "CURRENT TIME: " << m_captureTime.toString();
282 m_didCapture = false;
283 slotStartCapture(false);
284 m_discAction->setIcon(KIcon("network-disconnect"));
285 m_discAction->setText(i18n("Disconnect"));
286 m_recAction->setEnabled(true);
287 m_stopAction->setEnabled(true);
288 m_playAction->setEnabled(true);
289 m_rewAction->setEnabled(true);
290 m_fwdAction->setEnabled(true);
292 m_captureProcess->write("q", 1);
293 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
294 if (m_didCapture) manageCapturedFiles();
295 m_didCapture = false;
299 void RecMonitor::slotRewind()
301 m_captureProcess->write("a", 1);
304 void RecMonitor::slotForward()
306 m_captureProcess->write("z", 1);
309 void RecMonitor::slotStopCapture()
312 switch (device_selector->currentIndex()) {
314 m_captureProcess->write("\e", 2);
315 m_playAction->setIcon(m_playIcon);
320 m_captureProcess->write("q\n", 3);
321 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
328 void RecMonitor::slotStartCapture(bool play)
330 if (m_captureProcess->state() != QProcess::NotRunning) {
331 if (device_selector->currentIndex() == FIREWIRE) {
333 m_captureProcess->write("k", 1);
334 //captureProcess->write("\e", 2);
335 m_playAction->setIcon(m_playIcon);
338 m_captureProcess->write("p", 1);
339 m_playAction->setIcon(m_pauseIcon);
345 m_captureArgs.clear();
346 m_displayArgs.clear();
348 QString capturename = KdenliveSettings::dvgrabfilename();
349 QStringList dvargs = KdenliveSettings::dvgrabextra().simplified().split(" ", QString::SkipEmptyParts);
351 switch (device_selector->currentIndex()) {
353 switch (KdenliveSettings::firewireformat()) {
356 m_captureArgs << "--format" << "raw";
357 m_displayArgs << "-f" << "dv";
361 m_captureArgs << "--format" << "dv1";
362 m_displayArgs << "-f" << "dv";
366 m_captureArgs << "--format" << "dv2";
367 m_displayArgs << "-f" << "dv";
371 m_captureArgs << "--format" << "hdv";
372 m_displayArgs << "-f" << KdenliveSettings::video4container();
375 if (KdenliveSettings::firewireautosplit()) m_captureArgs << "--autosplit";
376 if (KdenliveSettings::firewiretimestamp()) m_captureArgs << "--timestamp";
377 if (!dvargs.isEmpty()) {
378 m_captureArgs << dvargs;
380 m_captureArgs << "-i";
381 if (capturename.isEmpty()) capturename = "capture";
382 m_captureArgs << capturename << "-";
384 m_displayArgs << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
386 m_captureProcess->setStandardOutputProcess(m_displayProcess);
387 m_captureProcess->setWorkingDirectory(m_capturePath);
388 kDebug() << "Capture: Running dvgrab " << m_captureArgs.join(" ");
390 m_captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
391 if (play) m_captureProcess->write(" ", 1);
392 m_discAction->setEnabled(true);
395 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-f" << KdenliveSettings::video4container() << "-";
396 m_displayArgs << "-f" << KdenliveSettings::video4container() << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
397 m_captureProcess->setStandardOutputProcess(m_displayProcess);
398 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
399 m_captureProcess->start("ffmpeg", m_captureArgs);
405 if (device_selector->currentIndex() != SCREENGRAB) {
406 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
407 m_displayProcess->start("ffplay", m_displayArgs);
408 video_frame->setText(i18n("Initialising..."));
410 // do something when starting screen grab
414 void RecMonitor::slotRecord()
416 if (m_captureProcess->state() == QProcess::NotRunning && device_selector->currentIndex() == FIREWIRE) {
420 switch (device_selector->currentIndex()) {
422 m_captureProcess->write("\e", 2);
423 m_playAction->setIcon(m_playIcon);
424 m_isCapturing = false;
426 m_recAction->setChecked(false);
429 m_captureProcess->terminate();
431 //m_isCapturing = false;
432 QTimer::singleShot(1000, this, SLOT(slotStartCapture()));
435 //captureProcess->write("q\n", 3);
436 m_captureProcess->terminate();
437 video_frame->setText(i18n("Encoding captured video..."));
438 // in case ffmpeg doesn't exit with the 'q' command, kill it one second later
439 //QTimer::singleShot(1000, captureProcess, SLOT(kill()));
443 } else if (device_selector->currentIndex() == FIREWIRE) {
444 m_isCapturing = true;
446 m_captureProcess->write("c\n", 3);
447 #if KDE_IS_VERSION(4,2,0)
448 m_spaceTimer.start();
452 if (m_captureProcess->state() == QProcess::NotRunning) {
453 m_recAction->setChecked(true);
454 QString extension = "mp4";
455 if (device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension();
456 else if (device_selector->currentIndex() == VIDEO4LINUX) extension = KdenliveSettings::video4extension();
457 QString path = m_capturePath + "/capture0000." + extension;
459 while (QFile::exists(path)) {
460 QString num = QString::number(i).rightJustified(4, '0', false);
461 path = m_capturePath + "/capture" + num + '.' + extension;
464 m_captureFile = KUrl(path);
466 m_captureArgs.clear();
467 m_displayArgs.clear();
469 QString capturename = KdenliveSettings::dvgrabfilename();
470 if (capturename.isEmpty()) capturename = "capture";
472 switch (device_selector->currentIndex()) {
474 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-y" << m_captureFile.path() << "-f" << KdenliveSettings::video4container() << "-acodec" << KdenliveSettings::video4acodec() << "-vcodec" << KdenliveSettings::video4vcodec() << "-";
475 m_displayArgs << "-f" << KdenliveSettings::video4container() << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
476 m_captureProcess->setStandardOutputProcess(m_displayProcess);
477 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
478 m_captureProcess->start("ffmpeg", m_captureArgs);
481 switch (KdenliveSettings::rmd_capture_type()) {
483 // Full screen capture, nothing special to do
487 m_captureArgs << "--width" << QString::number(KdenliveSettings::rmd_width()) << "--height" << QString::number(KdenliveSettings::rmd_height());
488 if (!KdenliveSettings::rmd_follow_mouse()) {
489 m_captureArgs << "-x" << QString::number(KdenliveSettings::rmd_offsetx()) << "-y" << QString::number(KdenliveSettings::rmd_offsety());
491 m_captureArgs << "--follow-mouse";
492 if (KdenliveSettings::rmd_hide_frame()) m_captureArgs << "--no-frame";
496 if (KdenliveSettings::rmd_hide_mouse()) m_captureArgs << "--no-cursor";
497 m_isCapturing = true;
498 if (KdenliveSettings::rmd_capture_audio()) {
499 m_captureArgs << "--freq" << KdenliveSettings::rmd_freq();
500 m_captureArgs << "--channels" << QString::number(KdenliveSettings::rmd_audio_channels());
501 if (KdenliveSettings::rmd_use_jack()) {
502 m_captureArgs << "--use-jack";
503 QStringList ports = KdenliveSettings::rmd_jackports().split(" ", QString::SkipEmptyParts);
504 for (int i = 0; i < ports.count(); ++i) {
505 m_captureArgs << ports.at(i);
507 if (KdenliveSettings::rmd_jack_buffer() > 0.0)
508 m_captureArgs << "--ring-buffer-size" << QString::number(KdenliveSettings::rmd_jack_buffer());
510 if (!KdenliveSettings::rmd_alsadevicename().isEmpty())
511 m_captureArgs << "--device" << KdenliveSettings::rmd_alsadevicename();
512 if (KdenliveSettings::rmd_alsa_buffer() > 0)
513 m_captureArgs << "--buffer-size" << QString::number(KdenliveSettings::rmd_alsa_buffer());
515 } else m_captureArgs << "--no-sound";
517 if (KdenliveSettings::rmd_fullshots()) m_captureArgs << "--full-shots";
518 m_captureArgs << "--v_bitrate" << QString::number(KdenliveSettings::rmd_bitrate());
519 m_captureArgs << "--v_quality" << QString::number(KdenliveSettings::rmd_quality());
520 m_captureArgs << "--workdir" << KdenliveSettings::currenttmpfolder();
521 m_captureArgs << "--fps" << QString::number(KdenliveSettings::rmd_fps()) << "-o" << m_captureFile.path();
522 m_captureProcess->start(KdenliveSettings::rmd_path(), m_captureArgs);
523 kDebug() << "// RecordMyDesktop params: " << m_captureArgs;
530 if (device_selector->currentIndex() != SCREENGRAB) {
531 m_isCapturing = true;
532 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
533 m_displayProcess->start("ffplay", m_displayArgs);
534 video_frame->setText(i18n("Initialising..."));
538 m_displayProcess->kill();
539 //captureProcess->kill();
540 QTimer::singleShot(1000, this, SLOT(slotRecord()));
545 void RecMonitor::slotStartGrab(const QRect &rect) {
546 rgnGrab->deleteLater();
547 QApplication::restoreOverrideCursor();
549 if (rect.isNull()) return;
550 int width = rect.width();
551 int height = rect.height();
552 if (width % 2 != 0) width--;
553 if (height % 2 != 0) height--;
554 QString args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(width) + "x" + QString::number(height)).replace("%offset", "+" + QString::number(rect.x()) + "," + QString::number(rect.y()));
555 if (KdenliveSettings::screengrabenableaudio()) {
556 // also capture audio
557 if (KdenliveSettings::useosscapture()) m_captureArgs << KdenliveSettings::screengrabosscapture().simplified().split(' ');
558 else m_captureArgs << KdenliveSettings::screengrabalsacapture2().simplified().split(' ');
560 m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path();
561 m_isCapturing = true;
562 video_frame->setText(i18n("Capturing..."));
563 if (KdenliveSettings::screengrabenableaudio() && !KdenliveSettings::useosscapture()) {
564 QStringList alsaArgs = KdenliveSettings::screengrabalsacapture().simplified().split(' ');
565 alsaProcess->setStandardOutputProcess(captureProcess);
566 kDebug() << "Capture: Running arecord " << alsaArgs.join(" ");
567 alsaProcess->start("arecord", alsaArgs);
569 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
570 captureProcess->start("ffmpeg", m_captureArgs);
573 void RecMonitor::slotProcessStatus(QProcess::ProcessState status)
575 if (status == QProcess::NotRunning) {
576 m_displayProcess->kill();
577 if (m_isCapturing && device_selector->currentIndex() != FIREWIRE)
578 if (autoaddbox->isChecked() && QFile::exists(m_captureFile.path())) emit addProjectClip(m_captureFile);
579 if (device_selector->currentIndex() == FIREWIRE) {
580 m_discAction->setIcon(KIcon("network-connect"));
581 m_discAction->setText(i18n("Connect"));
582 m_playAction->setEnabled(false);
583 m_rewAction->setEnabled(false);
584 m_fwdAction->setEnabled(false);
585 m_recAction->setEnabled(false);
588 m_playAction->setIcon(m_playIcon);
589 m_recAction->setChecked(false);
590 m_stopAction->setEnabled(false);
591 device_selector->setEnabled(true);
592 if (m_captureProcess && m_captureProcess->exitStatus() == QProcess::CrashExit) {
593 video_frame->setText(i18n("Capture crashed, please check your parameters"));
595 if (device_selector->currentIndex() != SCREENGRAB) {
596 video_frame->setText(i18n("Not connected"));
598 if (m_captureProcess->exitCode() != 0) {
599 video_frame->setText(i18n("Capture crashed, please check your parameters\nRecordMyDesktop exit code: %1", QString::number(m_captureProcess->exitCode())));
601 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", m_capturePath)));
605 m_isCapturing = false;
607 #if KDE_IS_VERSION(4,2,0)
609 // update free space info
610 slotUpdateFreeSpace();
614 if (device_selector->currentIndex() != SCREENGRAB) m_stopAction->setEnabled(true);
615 device_selector->setEnabled(false);
619 void RecMonitor::manageCapturedFiles()
622 switch (KdenliveSettings::firewireformat()) {
634 QDir dir(m_capturePath);
636 QString capturename = KdenliveSettings::dvgrabfilename();
637 if (capturename.isEmpty()) capturename = "capture";
638 filters << capturename + "*" + extension;
639 const QStringList result = dir.entryList(filters, QDir::Files, QDir::Time);
640 KUrl::List capturedFiles;
641 foreach(const QString & name, result) {
642 KUrl url = KUrl(dir.filePath(name));
643 if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, this)) {
644 KFileItem file(KFileItem::Unknown, KFileItem::Unknown, url, true);
645 if (file.time(KFileItem::ModificationTime) > m_captureTime) capturedFiles.append(url);
648 kDebug() << "Found : " << capturedFiles.count() << " new capture files";
649 kDebug() << capturedFiles;
651 if (capturedFiles.count() > 0) {
652 ManageCapturesDialog *d = new ManageCapturesDialog(capturedFiles, this);
653 if (d->exec() == QDialog::Accepted) {
654 capturedFiles = d->importFiles();
655 foreach(const KUrl & url, capturedFiles) {
656 emit addProjectClip(url);
664 void RecMonitor::mousePressEvent(QMouseEvent * /*event*/)
666 #if KDE_IS_VERSION(4,2,0)
667 if (m_freeSpace->underMouse()) slotUpdateFreeSpace();
671 void RecMonitor::slotUpdateFreeSpace()
673 #if KDE_IS_VERSION(4,2,0)
674 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(m_capturePath);
675 if (info.isValid()) {
676 m_freeSpace->setValue(100 * info.used() / info.size());
677 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
678 m_freeSpace->update();
683 void RecMonitor::activateRecMonitor()
685 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
688 void RecMonitor::stop()
694 void RecMonitor::start()
700 void RecMonitor::refreshRecMonitor(bool visible)
703 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
708 void RecMonitor::slotPlay()
711 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
715 void RecMonitor::slotReadDvgrabInfo()
717 QString data = m_captureProcess->readAllStandardError().simplified();
718 data = data.section('"', 2, 2).simplified();
719 m_dvinfo.setText(data.left(11));
720 m_dvinfo.updateGeometry();
723 #include "recmonitor.moc"