]> git.sesse.net Git - kdenlive/commitdiff
add config button to rec monitor
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 22 Jul 2008 18:01:53 +0000 (18:01 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 22 Jul 2008 18:01:53 +0000 (18:01 +0000)
svn path=/branches/KDE4/; revision=2344

src/kdenlivesettingsdialog.cpp
src/kdenlivesettingsdialog.h
src/mainwindow.cpp
src/mainwindow.h
src/recmonitor.cpp
src/recmonitor.h

index d1056d0bf8f4857c3e15fc8dcadfd5e2b659369d..67de3edc7e1505df33d47087bd805c93f5fc6200 100644 (file)
@@ -105,6 +105,27 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent): KConfigDialog(
 
 KdenliveSettingsDialog::~KdenliveSettingsDialog() {}
 
+void KdenliveSettingsDialog::showPage(int page, int option) {
+    switch (page) {
+    case 1:
+        setCurrentPage(page1);
+        break;
+    case 2:
+        setCurrentPage(page2);
+        break;
+    case 3:
+        setCurrentPage(page3);
+        break;
+    case 4:
+        setCurrentPage(page4);
+        m_configCapture.tabWidget->setCurrentIndex(option);
+        break;
+    case 5:
+        setCurrentPage(page5);
+        break;
+
+    }
+}
 
 void KdenliveSettingsDialog::slotEditVideoApplication() {
     KService::Ptr service;
index 20bb0a63ef83305d8b295805fd199e7fa2f882c1..3c60607045d7ee73ee94e6b2ec6de9f1350252d8 100644 (file)
@@ -37,6 +37,7 @@ class KdenliveSettingsDialog : public KConfigDialog {
 public:
     KdenliveSettingsDialog(QWidget * parent = 0);
     ~KdenliveSettingsDialog();
+    void showPage(int page, int option);
 
 protected:
     virtual bool hasChanged();
index d390f31da6e3692d70cbf6a35083d2f5cdd48dd9..22cfe6864fd41fbeb442a5a66dc8b05d0c4bd31f 100644 (file)
@@ -164,6 +164,7 @@ MainWindow::MainWindow(QWidget *parent)
     addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
 
     connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
+    connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
 
     undoViewDock = new QDockWidget(i18n("Undo History"), this);
     undoViewDock->setObjectName("undo_history");
@@ -1097,18 +1098,21 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     m_activeDocument = doc;
 }
 
-void MainWindow::slotPreferences() {
+void MainWindow::slotPreferences(int page, int option) {
     //An instance of your dialog could be already created and could be
     // cached, in which case you want to display the cached dialog
     // instead of creating another one
-    if (KConfigDialog::showDialog("settings"))
+    if (KConfigDialog::showDialog("settings")) {
+        if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
         return;
+    }
 
     // KConfigDialog didn't find an instance of this dialog, so lets
     // create it :
     KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
     dialog->show();
+    if (page != -1) dialog->showPage(page, option);
 }
 
 void MainWindow::updateConfiguration() {
index 7f1f3f52a28670f1025a9f7811397becb86f64a7..0ab4b46d80632899dca0c7b7fc3d01eff13e6c78 100644 (file)
@@ -175,7 +175,7 @@ private slots:
     void saveFile();
     void saveFileAs();
     void saveFileAs(const QString &outputFileName);
-    void slotPreferences();
+    void slotPreferences(int page = -1, int option = -1);
     void updateConfiguration();
     void slotConnectMonitors();
     void slotRaiseMonitor(bool clipMonitor);
index 1680a9232c32619606632b7674943860a84d24fa..2a2f0a9017c651c9e3d6b4bfb9b2868b0e11c63c 100644 (file)
@@ -48,7 +48,7 @@ RecMonitor::RecMonitor(QString name, QWidget *parent)
 
     QToolBar *toolbar = new QToolBar(name, this);
     QHBoxLayout *layout = new QHBoxLayout;
-
+    layout->setContentsMargins(0, 0, 0, 0);
     m_playIcon = KIcon("media-playback-start");
     m_pauseIcon = KIcon("media-playback-pause");
 
@@ -71,6 +71,12 @@ RecMonitor::RecMonitor(QString name, QWidget *parent)
     connect(m_recAction, SIGNAL(triggered()), this, SLOT(slotRecord()));
     m_recAction->setCheckable(true);
 
+    toolbar->addSeparator();
+
+    QAction *configAction = toolbar->addAction(KIcon("configure"), i18n("Configure"));
+    connect(configAction, SIGNAL(triggered()), this, SLOT(slotConfigure()));
+    configAction->setCheckable(false);
+
     layout->addWidget(toolbar);
     ui.control_frame_firewire->setLayout(layout);
 
@@ -104,6 +110,10 @@ QString RecMonitor::name() const {
     return m_name;
 }
 
+void RecMonitor::slotConfigure() {
+    emit showConfigDialog(4, ui.device_selector->currentIndex());
+}
+
 void RecMonitor::slotVideoDeviceChanged(int ix) {
     switch (ix) {
     case SCREENGRAB:
@@ -113,7 +123,7 @@ void RecMonitor::slotVideoDeviceChanged(int ix) {
         m_recAction->setEnabled(true);
         m_stopAction->setEnabled(false);
         m_playAction->setEnabled(false);
-       ui.video_frame->setPixmap(mergeSideBySide(KIcon("video-display").pixmap(QSize(50, 50)), i18n("Press record button\nto start screen capture")));
+        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())));
         //ui.video_frame->setText(i18n("Press record button\nto start screen capture"));
         break;
     case VIDEO4LINUX:
@@ -133,23 +143,23 @@ void RecMonitor::slotVideoDeviceChanged(int ix) {
         m_rewAction->setEnabled(false);
         m_fwdAction->setEnabled(false);
         //ui.video_frame->setText(i18n("Plug your camcorder and\npress connect button\nto initialize connection"));
-       ui.video_frame->setPixmap(mergeSideBySide(KIcon("network-connect").pixmap(QSize(50, 50)), i18n("Plug your camcorder and\npress connect button\nto initialize connection")));
+        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())));
         break;
     }
 }
 
-QPixmap RecMonitor::mergeSideBySide( const QPixmap& pix, const QString txt )
-{
+QPixmap RecMonitor::mergeSideBySide(const QPixmap& pix, const QString txt) {
     QPainter p;
-    int strWidth = p.fontMetrics().boundingRect( QRect(0, 0, ui.video_frame->width(), ui.video_frame->height()), Qt::AlignLeft, txt ).width();
-    int strHeight = p.fontMetrics().height();
+    QRect r = p.fontMetrics().boundingRect(QRect(0, 0, ui.video_frame->width(), ui.video_frame->height()), Qt::AlignLeft, txt);
+    int strWidth = r.width();
+    int strHeight = r.height();
     int pixWidth = pix.width();
     int pixHeight = pix.height();
-    QPixmap res( strWidth + 8 + pixWidth, qMax( strHeight, pixHeight ) );
+    QPixmap res(strWidth + 8 + pixWidth, qMax(strHeight, pixHeight));
     res.fill(Qt::transparent);
-    p.begin( &res );
-    p.drawPixmap(0,0, pix );
-    p.drawText( QRect( pixWidth +8, 0, strWidth, pixHeight), 0, txt );
+    p.begin(&res);
+    p.drawPixmap(0, 0, pix);
+    p.drawText(QRect(pixWidth + 8, 0, strWidth, strHeight), 0, txt);
     p.end();
     return res;
 }
@@ -159,10 +169,10 @@ void RecMonitor::checkDeviceAvailability() {
     if (!KIO::NetAccess::exists(KUrl(KdenliveSettings::video4vdevice()), KIO::NetAccess::SourceSide , this)) {
         m_playAction->setEnabled(false);
         m_recAction->setEnabled(false);
-       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())));
+        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())));
         //ui.video_frame->setText(i18n("Cannot read from device %1\nPlease check drivers and access rights.", KdenliveSettings::video4vdevice()));
     } else //ui.video_frame->setText(i18n("Press play or record button\nto start video capture"));
-       ui.video_frame->setPixmap(mergeSideBySide(KIcon("camera-web").pixmap(QSize(50, 50)), i18n("Press play or record button\nto start video capture")));
+        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())));
 }
 
 void RecMonitor::slotDisconnect() {
@@ -363,10 +373,10 @@ void RecMonitor::slotRecord() {
                 const QRect rect = QApplication::desktop()->screenGeometry();
                 args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(rect.width()) + "x" + QString::number(rect.height())).replace("%offset", QString());
                 kDebug() << "// capture params: " << args;
-               if (KdenliveSettings::screengrabenableaudio()) {
-                   // also capture audio
-                   m_captureArgs << KdenliveSettings::screengrabaudiocapture().simplified().split(' ');
-               }
+                if (KdenliveSettings::screengrabenableaudio()) {
+                    // also capture audio
+                    m_captureArgs << KdenliveSettings::screengrabaudiocapture().simplified().split(' ');
+                }
                 m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path();
                 ui.video_frame->setText(i18n("Capturing..."));
                 m_isCapturing = true;
@@ -407,8 +417,8 @@ void RecMonitor::slotStartGrab(const QRect &rect) {
     QString args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(width) + "x" + QString::number(height)).replace("%offset", "+" + QString::number(rect.x()) + "," + QString::number(rect.y()));
     kDebug() << "// capture params: " << args;
     if (KdenliveSettings::screengrabenableaudio()) {
-       // also capture audio
-       m_captureArgs << KdenliveSettings::screengrabaudiocapture().simplified().split(' ');
+        // also capture audio
+        m_captureArgs << KdenliveSettings::screengrabaudiocapture().simplified().split(' ');
     }
     m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path();
     m_isCapturing = true;
@@ -427,8 +437,8 @@ void RecMonitor::slotProcessStatus(QProcess::ProcessState status) {
             m_playAction->setEnabled(false);
             m_rewAction->setEnabled(false);
             m_fwdAction->setEnabled(false);
+            m_recAction->setEnabled(false);
         }
-        m_isCapturing = false;
         m_isPlaying = false;
         m_playAction->setIcon(m_playIcon);
         m_recAction->setChecked(false);
@@ -436,7 +446,13 @@ void RecMonitor::slotProcessStatus(QProcess::ProcessState status) {
         ui.device_selector->setEnabled(true);
         if (captureProcess && captureProcess->exitStatus() == QProcess::CrashExit) {
             ui.video_frame->setText(i18n("Capture crashed, please check your parameters"));
-        } else ui.video_frame->setText(i18n("Not connected"));
+        } else {
+            ui.video_frame->setText(i18n("Not connected"));
+            if (m_isCapturing && ui.device_selector->currentIndex() == FIREWIRE) {
+                //TODO: show dialog asking user confirmation for captured files
+            }
+        }
+        m_isCapturing = false;
     } else {
         if (ui.device_selector->currentIndex() != SCREENGRAB) m_stopAction->setEnabled(true);
         ui.device_selector->setEnabled(false);
index 3ff604d52c103e3887307dcdce65ac6b91f54b4f..5de70a90c1a88c04442170add67a8441bb23de9c 100644 (file)
@@ -72,7 +72,7 @@ private:
     QAction *m_stopAction;
     QAction *m_discAction;
     void checkDeviceAvailability();
-    QPixmap mergeSideBySide( const QPixmap& pix, const QString txt );
+    QPixmap mergeSideBySide(const QPixmap& pix, const QString txt);
 
 private slots:
     void slotStartCapture(bool play = true);
@@ -84,6 +84,7 @@ private slots:
     void slotForward();
     void slotDisconnect();
     void slotStartGrab(const QRect &rect);
+    void slotConfigure();
 
 public slots:
     void refreshRecMonitor(bool visible);
@@ -96,6 +97,7 @@ signals:
     void renderPosition(int);
     void durationChanged(int);
     void addProjectClip(KUrl);
+    void showConfigDialog(int, int);
 };
 
 #endif