From b6f7876e1e4afe255bfa2dc208e92048bf7cf33e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 22 Jul 2008 18:01:53 +0000 Subject: [PATCH] add config button to rec monitor svn path=/branches/KDE4/; revision=2344 --- src/kdenlivesettingsdialog.cpp | 21 ++++++++++++ src/kdenlivesettingsdialog.h | 1 + src/mainwindow.cpp | 8 +++-- src/mainwindow.h | 2 +- src/recmonitor.cpp | 58 ++++++++++++++++++++++------------ src/recmonitor.h | 4 ++- 6 files changed, 69 insertions(+), 25 deletions(-) diff --git a/src/kdenlivesettingsdialog.cpp b/src/kdenlivesettingsdialog.cpp index d1056d0b..67de3edc 100644 --- a/src/kdenlivesettingsdialog.cpp +++ b/src/kdenlivesettingsdialog.cpp @@ -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; diff --git a/src/kdenlivesettingsdialog.h b/src/kdenlivesettingsdialog.h index 20bb0a63..3c606070 100644 --- a/src/kdenlivesettingsdialog.h +++ b/src/kdenlivesettingsdialog.h @@ -37,6 +37,7 @@ class KdenliveSettingsDialog : public KConfigDialog { public: KdenliveSettingsDialog(QWidget * parent = 0); ~KdenliveSettingsDialog(); + void showPage(int page, int option); protected: virtual bool hasChanged(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d390f31d..22cfe686 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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 (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() { diff --git a/src/mainwindow.h b/src/mainwindow.h index 7f1f3f52..0ab4b46d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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); diff --git a/src/recmonitor.cpp b/src/recmonitor.cpp index 1680a923..2a2f0a90 100644 --- a/src/recmonitor.cpp +++ b/src/recmonitor.cpp @@ -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); diff --git a/src/recmonitor.h b/src/recmonitor.h index 3ff604d5..5de70a90 100644 --- a/src/recmonitor.h +++ b/src/recmonitor.h @@ -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 -- 2.39.2