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()
165 if (m_captureProcess) m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
166 if (m_captureProcess->state() != QProcess::NotRunning) {
167 if (device_selector->currentIndex() == FIREWIRE)
168 KMessageBox::information(this, i18n("You need to disconnect and reconnect in the capture monitor to apply your changes"), i18n("Capturing"));
169 else KMessageBox::information(this, i18n("You need to stop capture before your changes can be applied"), i18n("Capturing"));
170 } else slotVideoDeviceChanged(device_selector->currentIndex());
171 kDebug() << "// UPDATE CAPT FOLD: " << KdenliveSettings::capturefolder();
173 #if KDE_IS_VERSION(4,2,0)
174 // update free space info
175 slotUpdateFreeSpace();
179 void RecMonitor::slotVideoDeviceChanged(int ix)
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(false);
189 if (KdenliveSettings::rmd_path().isEmpty()) {
190 QString rmdpath = KStandardDirs::findExe("recordmydesktop");
191 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")));
192 else KdenliveSettings::setRmd_path(rmdpath);
194 if (!KdenliveSettings::rmd_path().isEmpty()) video_frame->setPixmap(mergeSideBySide(KIcon("video-display").pixmap(QSize(50, 50)), i18n("Press record button\nto start screen capture\nFiles will be saved in:\n%1", KdenliveSettings::capturefolder())));
195 //video_frame->setText(i18n("Press record button\nto start screen capture"));
198 m_discAction->setEnabled(false);
199 m_rewAction->setEnabled(false);
200 m_fwdAction->setEnabled(false);
201 m_recAction->setEnabled(true);
202 m_stopAction->setEnabled(false);
203 m_playAction->setEnabled(true);
204 checkDeviceAvailability();
207 m_discAction->setEnabled(true);
208 m_recAction->setEnabled(false);
209 m_stopAction->setEnabled(false);
210 m_playAction->setEnabled(false);
211 m_rewAction->setEnabled(false);
212 m_fwdAction->setEnabled(false);
214 // Check that dvgab is available
215 if (KdenliveSettings::dvgrab_path().isEmpty()) {
216 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
217 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")));
218 else KdenliveSettings::setDvgrab_path(dvgrabpath);
221 QString capturefile = KdenliveSettings::capturefolder();
222 if (!capturefile.endsWith("/")) capturefile.append("/");
223 QString capturename = KdenliveSettings::dvgrabfilename();
224 if (capturename.isEmpty()) capturename = "capture";
226 switch (KdenliveSettings::firewireformat()) {
238 capturename.append("xxx" + extension);
239 capturefile.append(capturename);
240 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)));
246 QPixmap RecMonitor::mergeSideBySide(const QPixmap& pix, const QString txt)
249 QRect r = QApplication::fontMetrics().boundingRect(QRect(0, 0, video_frame->width(), video_frame->height()), Qt::AlignLeft, txt);
250 int strWidth = r.width();
251 int strHeight = r.height();
252 int pixWidth = pix.width();
253 int pixHeight = pix.height();
254 QPixmap res(strWidth + 8 + pixWidth, qMax(strHeight, pixHeight));
255 res.fill(Qt::transparent);
257 p.drawPixmap(0, 0, pix);
258 p.setPen(kapp->palette().text().color());
259 p.drawText(QRect(pixWidth + 8, 0, strWidth, strHeight), 0, txt);
265 void RecMonitor::checkDeviceAvailability()
267 if (!KIO::NetAccess::exists(KUrl(KdenliveSettings::video4vdevice()), KIO::NetAccess::SourceSide , this)) {
268 m_playAction->setEnabled(false);
269 m_recAction->setEnabled(false);
270 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())));
271 //video_frame->setText(i18n("Cannot read from device %1\nPlease check drivers and access rights.", KdenliveSettings::video4vdevice()));
272 } else //video_frame->setText(i18n("Press play or record button\nto start video capture"));
273 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())));
276 void RecMonitor::slotDisconnect()
278 if (m_captureProcess->state() == QProcess::NotRunning) {
279 m_captureTime = KDateTime::currentLocalDateTime();
280 kDebug() << "CURRENT TIME: " << m_captureTime.toString();
281 m_didCapture = false;
282 slotStartCapture(false);
283 m_discAction->setIcon(KIcon("network-disconnect"));
284 m_discAction->setText(i18n("Disconnect"));
285 m_recAction->setEnabled(true);
286 m_stopAction->setEnabled(true);
287 m_playAction->setEnabled(true);
288 m_rewAction->setEnabled(true);
289 m_fwdAction->setEnabled(true);
291 m_captureProcess->write("q", 1);
292 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
293 if (m_didCapture) manageCapturedFiles();
294 m_didCapture = false;
298 void RecMonitor::slotRewind()
300 m_captureProcess->write("a", 1);
303 void RecMonitor::slotForward()
305 m_captureProcess->write("z", 1);
308 void RecMonitor::slotStopCapture()
311 switch (device_selector->currentIndex()) {
313 m_captureProcess->write("\e", 2);
314 m_playAction->setIcon(m_playIcon);
319 m_captureProcess->write("q\n", 3);
320 QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
327 void RecMonitor::slotStartCapture(bool play)
329 if (m_captureProcess->state() != QProcess::NotRunning) {
330 if (device_selector->currentIndex() == FIREWIRE) {
332 m_captureProcess->write("k", 1);
333 //captureProcess->write("\e", 2);
334 m_playAction->setIcon(m_playIcon);
337 m_captureProcess->write("p", 1);
338 m_playAction->setIcon(m_pauseIcon);
344 m_captureArgs.clear();
345 m_displayArgs.clear();
347 QString capturename = KdenliveSettings::dvgrabfilename();
348 QStringList dvargs = KdenliveSettings::dvgrabextra().simplified().split(" ", QString::SkipEmptyParts);
350 switch (device_selector->currentIndex()) {
352 switch (KdenliveSettings::firewireformat()) {
355 m_captureArgs << "--format" << "raw";
356 m_displayArgs << "-f" << "dv";
360 m_captureArgs << "--format" << "dv1";
361 m_displayArgs << "-f" << "dv";
365 m_captureArgs << "--format" << "dv2";
366 m_displayArgs << "-f" << "dv";
370 m_captureArgs << "--format" << "hdv";
371 m_displayArgs << "-f" << KdenliveSettings::video4container();
374 if (KdenliveSettings::firewireautosplit()) m_captureArgs << "--autosplit";
375 if (KdenliveSettings::firewiretimestamp()) m_captureArgs << "--timestamp";
376 if (!dvargs.isEmpty()) {
377 m_captureArgs << dvargs;
379 m_captureArgs << "-i";
380 if (capturename.isEmpty()) capturename = "capture";
381 m_captureArgs << capturename << "-";
383 m_displayArgs << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
385 m_captureProcess->setStandardOutputProcess(m_displayProcess);
386 m_captureProcess->setWorkingDirectory(KdenliveSettings::capturefolder());
387 kDebug() << "Capture: Running dvgrab " << m_captureArgs.join(" ");
389 m_captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
390 if (play) m_captureProcess->write(" ", 1);
391 m_discAction->setEnabled(true);
394 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-f" << KdenliveSettings::video4container() << "-";
395 m_displayArgs << "-f" << KdenliveSettings::video4container() << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
396 m_captureProcess->setStandardOutputProcess(m_displayProcess);
397 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
398 m_captureProcess->start("ffmpeg", m_captureArgs);
404 if (device_selector->currentIndex() != SCREENGRAB) {
405 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
406 m_displayProcess->start("ffplay", m_displayArgs);
407 video_frame->setText(i18n("Initialising..."));
409 // do something when starting screen grab
413 void RecMonitor::slotRecord()
415 if (m_captureProcess->state() == QProcess::NotRunning && device_selector->currentIndex() == FIREWIRE) {
419 switch (device_selector->currentIndex()) {
421 m_captureProcess->write("\e", 2);
422 m_playAction->setIcon(m_playIcon);
423 m_isCapturing = false;
425 m_recAction->setChecked(false);
428 m_captureProcess->terminate();
430 //m_isCapturing = false;
431 QTimer::singleShot(1000, this, SLOT(slotStartCapture()));
434 //captureProcess->write("q\n", 3);
435 m_captureProcess->terminate();
436 video_frame->setText(i18n("Encoding captured video..."));
437 // in case ffmpeg doesn't exit with the 'q' command, kill it one second later
438 //QTimer::singleShot(1000, captureProcess, SLOT(kill()));
442 } else if (device_selector->currentIndex() == FIREWIRE) {
443 m_isCapturing = true;
445 m_captureProcess->write("c\n", 3);
446 #if KDE_IS_VERSION(4,2,0)
447 m_spaceTimer.start();
451 if (m_captureProcess->state() == QProcess::NotRunning) {
452 m_recAction->setChecked(true);
453 QString extension = "mp4";
454 if (device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension();
455 else if (device_selector->currentIndex() == VIDEO4LINUX) extension = KdenliveSettings::video4extension();
456 QString path = KdenliveSettings::capturefolder() + "/capture0000." + extension;
458 while (QFile::exists(path)) {
459 QString num = QString::number(i).rightJustified(4, '0', false);
460 path = KdenliveSettings::capturefolder() + "/capture" + num + '.' + extension;
463 m_captureFile = KUrl(path);
465 m_captureArgs.clear();
466 m_displayArgs.clear();
468 QString capturename = KdenliveSettings::dvgrabfilename();
469 if (capturename.isEmpty()) capturename = "capture";
471 switch (device_selector->currentIndex()) {
473 m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << KdenliveSettings::video4encoding().simplified().split(' ') << "-y" << m_captureFile.path() << "-f" << KdenliveSettings::video4container() << "-acodec" << KdenliveSettings::video4acodec() << "-vcodec" << KdenliveSettings::video4vcodec() << "-";
474 m_displayArgs << "-f" << KdenliveSettings::video4container() << "-x" << QString::number(video_frame->width()) << "-y" << QString::number(video_frame->height()) << "-";
475 m_captureProcess->setStandardOutputProcess(m_displayProcess);
476 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
477 m_captureProcess->start("ffmpeg", m_captureArgs);
480 switch (KdenliveSettings::rmd_capture_type()) {
482 // Full screen capture, nothing special to do
486 m_captureArgs << "--width" << QString::number(KdenliveSettings::rmd_width()) << "--height" << QString::number(KdenliveSettings::rmd_height());
487 if (!KdenliveSettings::rmd_follow_mouse()) {
488 m_captureArgs << "-x" << QString::number(KdenliveSettings::rmd_offsetx()) << "-y" << QString::number(KdenliveSettings::rmd_offsety());
490 m_captureArgs << "--follow-mouse";
491 if (KdenliveSettings::rmd_hide_frame()) m_captureArgs << "--no-frame";
495 if (KdenliveSettings::rmd_hide_mouse()) m_captureArgs << "--no-cursor";
496 m_isCapturing = true;
497 if (KdenliveSettings::rmd_capture_audio()) {
498 m_captureArgs << "--freq" << KdenliveSettings::rmd_freq();
499 m_captureArgs << "--channels" << QString::number(KdenliveSettings::rmd_audio_channels());
500 if (KdenliveSettings::rmd_use_jack()) {
501 m_captureArgs << "--use-jack";
502 QStringList ports = KdenliveSettings::rmd_jackports().split(" ", QString::SkipEmptyParts);
503 for (int i = 0; i < ports.count(); ++i) {
504 m_captureArgs << ports.at(i);
506 if (KdenliveSettings::rmd_jack_buffer() > 0.0)
507 m_captureArgs << "--ring-buffer-size" << QString::number(KdenliveSettings::rmd_jack_buffer());
509 if (!KdenliveSettings::rmd_alsadevicename().isEmpty())
510 m_captureArgs << "--device" << KdenliveSettings::rmd_alsadevicename();
511 if (KdenliveSettings::rmd_alsa_buffer() > 0)
512 m_captureArgs << "--buffer-size" << QString::number(KdenliveSettings::rmd_alsa_buffer());
514 } else m_captureArgs << "--no-sound";
516 if (KdenliveSettings::rmd_fullshots()) m_captureArgs << "--full-shots";
517 m_captureArgs << "--v_bitrate" << QString::number(KdenliveSettings::rmd_bitrate());
518 m_captureArgs << "--v_quality" << QString::number(KdenliveSettings::rmd_quality());
519 m_captureArgs << "--workdir" << KdenliveSettings::currenttmpfolder();
520 m_captureArgs << "--fps" << QString::number(KdenliveSettings::rmd_fps()) << "-o" << m_captureFile.path();
521 m_captureProcess->start(KdenliveSettings::rmd_path(), m_captureArgs);
522 kDebug() << "// RecordMyDesktop params: " << m_captureArgs;
529 if (device_selector->currentIndex() != SCREENGRAB) {
530 m_isCapturing = true;
531 kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
532 m_displayProcess->start("ffplay", m_displayArgs);
533 video_frame->setText(i18n("Initialising..."));
537 m_displayProcess->kill();
538 //captureProcess->kill();
539 QTimer::singleShot(1000, this, SLOT(slotRecord()));
544 void RecMonitor::slotStartGrab(const QRect &rect) {
545 rgnGrab->deleteLater();
546 QApplication::restoreOverrideCursor();
548 if (rect.isNull()) return;
549 int width = rect.width();
550 int height = rect.height();
551 if (width % 2 != 0) width--;
552 if (height % 2 != 0) height--;
553 QString args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(width) + "x" + QString::number(height)).replace("%offset", "+" + QString::number(rect.x()) + "," + QString::number(rect.y()));
554 if (KdenliveSettings::screengrabenableaudio()) {
555 // also capture audio
556 if (KdenliveSettings::useosscapture()) m_captureArgs << KdenliveSettings::screengrabosscapture().simplified().split(' ');
557 else m_captureArgs << KdenliveSettings::screengrabalsacapture2().simplified().split(' ');
559 m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path();
560 m_isCapturing = true;
561 video_frame->setText(i18n("Capturing..."));
562 if (KdenliveSettings::screengrabenableaudio() && !KdenliveSettings::useosscapture()) {
563 QStringList alsaArgs = KdenliveSettings::screengrabalsacapture().simplified().split(' ');
564 alsaProcess->setStandardOutputProcess(captureProcess);
565 kDebug() << "Capture: Running arecord " << alsaArgs.join(" ");
566 alsaProcess->start("arecord", alsaArgs);
568 kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
569 captureProcess->start("ffmpeg", m_captureArgs);
572 void RecMonitor::slotProcessStatus(QProcess::ProcessState status)
574 if (status == QProcess::NotRunning) {
575 m_displayProcess->kill();
576 if (m_isCapturing && device_selector->currentIndex() != FIREWIRE)
577 if (autoaddbox->isChecked() && QFile::exists(m_captureFile.path())) emit addProjectClip(m_captureFile);
578 if (device_selector->currentIndex() == FIREWIRE) {
579 m_discAction->setIcon(KIcon("network-connect"));
580 m_discAction->setText(i18n("Connect"));
581 m_playAction->setEnabled(false);
582 m_rewAction->setEnabled(false);
583 m_fwdAction->setEnabled(false);
584 m_recAction->setEnabled(false);
587 m_playAction->setIcon(m_playIcon);
588 m_recAction->setChecked(false);
589 m_stopAction->setEnabled(false);
590 device_selector->setEnabled(true);
591 if (m_captureProcess && m_captureProcess->exitStatus() == QProcess::CrashExit) {
592 video_frame->setText(i18n("Capture crashed, please check your parameters"));
594 if (device_selector->currentIndex() != SCREENGRAB) {
595 video_frame->setText(i18n("Not connected"));
597 if (m_captureProcess->exitCode() != 0) {
598 video_frame->setText(i18n("Capture crashed, please check your parameters\nRecordMyDesktop exit code: %1", QString::number(m_captureProcess->exitCode())));
600 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())));
604 m_isCapturing = false;
606 #if KDE_IS_VERSION(4,2,0)
608 // update free space info
609 slotUpdateFreeSpace();
613 if (device_selector->currentIndex() != SCREENGRAB) m_stopAction->setEnabled(true);
614 device_selector->setEnabled(false);
618 void RecMonitor::manageCapturedFiles()
621 switch (KdenliveSettings::firewireformat()) {
633 QDir dir(KdenliveSettings::capturefolder());
635 QString capturename = KdenliveSettings::dvgrabfilename();
636 if (capturename.isEmpty()) capturename = "capture";
637 filters << capturename + "*" + extension;
638 const QStringList result = dir.entryList(filters, QDir::Files, QDir::Time);
639 KUrl::List capturedFiles;
640 foreach(const QString &name, result) {
641 KUrl url = KUrl(dir.filePath(name));
642 if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, this)) {
643 KFileItem file(KFileItem::Unknown, KFileItem::Unknown, url, true);
644 if (file.time(KFileItem::ModificationTime) > m_captureTime) capturedFiles.append(url);
647 kDebug() << "Found : " << capturedFiles.count() << " new capture files";
648 kDebug() << capturedFiles;
650 if (capturedFiles.count() > 0) {
651 ManageCapturesDialog *d = new ManageCapturesDialog(capturedFiles, this);
652 if (d->exec() == QDialog::Accepted) {
653 capturedFiles = d->importFiles();
654 foreach(const KUrl &url, capturedFiles) {
655 emit addProjectClip(url);
663 void RecMonitor::mousePressEvent(QMouseEvent * /*event*/)
665 #if KDE_IS_VERSION(4,2,0)
666 if (m_freeSpace->underMouse()) slotUpdateFreeSpace();
670 void RecMonitor::slotUpdateFreeSpace()
672 #if KDE_IS_VERSION(4,2,0)
673 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(KdenliveSettings::capturefolder());
674 if (info.isValid()) {
675 m_freeSpace->setValue(100 * info.used() / info.size());
676 m_freeSpace->setText(i18n("Free space: %1", KIO::convertSize(info.available())));
677 m_freeSpace->update();
682 void RecMonitor::activateRecMonitor()
684 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
687 void RecMonitor::stop()
693 void RecMonitor::start()
699 void RecMonitor::refreshRecMonitor(bool visible)
702 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
707 void RecMonitor::slotPlay()
710 //if (!m_isActive) m_monitorManager->activateRecMonitor(m_name);
714 void RecMonitor::slotReadDvgrabInfo()
716 QString data = m_captureProcess->readAllStandardError().simplified();
717 data = data.section('"', 2, 2).simplified();
718 m_dvinfo.setText(data.left(11));
719 m_dvinfo.updateGeometry();
722 #include "recmonitor.moc"