Commit ad1636bd authored by Aurélien Bertron's avatar Aurélien Bertron Committed by Jean-Baptiste Mardelle
Browse files

Add screen selection in screen grab widget

Fix #243
parent 32423ba3
......@@ -107,6 +107,7 @@
#include <QUndoGroup>
#include <KConfigGroup>
#include <QDesktopWidget>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QScreen>
......@@ -284,6 +285,18 @@ void MainWindow::init()
QToolBar *recToolbar = new QToolBar(grabWidget);
grabLayout->addWidget(recToolbar);
grabLayout->addStretch(10);
// Check number of monitors for FFmpeg screen capture
int screens = QApplication::desktop()->screenCount();
if (screens > 1) {
QComboBox *screenCombo = new QComboBox(recToolbar);
for (int ix = 0; ix < screens; ix++) {
screenCombo->addItem(i18n("Monitor %1", ix));
}
connect(screenCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), m_clipMonitor, &Monitor::slotSetScreen);
recToolbar->addWidget(screenCombo);
// Update screen grab monitor choice in case we changed from fullscreen
screenCombo->setEnabled(KdenliveSettings::grab_capture_type() == 0);
}
QAction *recAction = m_clipMonitor->recAction();
addAction(QStringLiteral("screengrab_record"), recAction);
recToolbar->addAction(recAction);
......
......@@ -20,6 +20,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QComboBox>
#include <QDBusAbstractAdaptor>
#include <QDockWidget>
#include <QEvent>
......
......@@ -2112,6 +2112,11 @@ void Monitor::removeSnapPoint(int pos)
m_snaps->removePoint(pos);
}
void Monitor::slotSetScreen(int screenIndex)
{
emit screenChanged(screenIndex);
}
void Monitor::slotZoomIn()
{
m_glMonitor->slotZoom(true);
......
......@@ -273,6 +273,7 @@ private slots:
void removeSnapPoint(int pos);
public slots:
void slotSetScreen(int screenIndex);
void slotOpenDvdFile(const QString &);
// void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
void updateClipProducer(const std::shared_ptr<Mlt::Producer> &prod);
......@@ -325,6 +326,7 @@ public slots:
void refreshMonitorIfActive(bool directUpdate = false) override;
signals:
void screenChanged(int screenIndex);
void seekPosition(int pos);
void updateScene();
/** @brief Request a timeline seeking if diff is true, position is a relative offset, otherwise an absolute position */
......
......@@ -46,6 +46,7 @@ RecManager::RecManager(Monitor *parent)
, m_recToolbar(new QToolBar(parent))
, m_checkAudio(false)
, m_checkVideo(false)
, m_screenIndex(-1)
{
m_playAction = m_recToolbar->addAction(QIcon::fromTheme(QStringLiteral("media-playback-start")), i18n("Preview"));
m_playAction->setCheckable(true);
......@@ -65,17 +66,6 @@ RecManager::RecManager(Monitor *parent)
m_recAudio->setChecked(KdenliveSettings::v4l_captureaudio());
m_recVideo->setChecked(KdenliveSettings::v4l_capturevideo());
// Check number of monitors for FFmpeg screen capture
int screens = QApplication::desktop()->screenCount();
if (screens > 1) {
m_screenCombo = new QComboBox(parent);
for (int ix = 0; ix < screens; ix++) {
m_screenCombo->addItem(i18n("Monitor %1", ix));
}
m_recToolbar->addWidget(m_screenCombo);
// Update screen grab monitor choice in case we changed from fullscreen
m_screenCombo->setEnabled(KdenliveSettings::grab_capture_type() == 0);
}
QWidget *spacer = new QWidget(parent);
spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_recToolbar->addWidget(spacer);
......@@ -135,6 +125,7 @@ RecManager::RecManager(Monitor *parent)
connect(m_switchRec, &QAction::toggled, m_monitor, &Monitor::slotSwitchRec);
m_recToolbar->setVisible(false);
slotVideoDeviceChanged();
connect(m_monitor, &Monitor::screenChanged, this, &RecManager::slotSetScreen);
}
RecManager::~RecManager() = default;
......@@ -236,12 +227,7 @@ void RecManager::slotRecord(bool record)
}
m_captureFile = QUrl::fromLocalFile(path);
QString captureSize;
int screen = -1;
if (m_screenCombo) {
// Multi monitor setup, capture monitor selected by user
screen = m_screenCombo->currentIndex();
}
QRect screenSize = QApplication::desktop()->screenGeometry(screen);
QRect screenSize = QApplication::desktop()->screenGeometry(m_screenIndex);
QStringList captureArgs;
#ifdef Q_OS_WIN
captureArgs << QStringLiteral("-f") << QStringLiteral("gdigrab");
......@@ -409,6 +395,11 @@ Mlt::Producer *RecManager::createV4lProducer()
return prod;
}
void RecManager::slotSetScreen(int screenIndex)
{
m_screenIndex = screenIndex;
}
void RecManager::slotPreview(bool preview)
{
if (m_device_selector->currentData().toInt() == Video4Linux) {
......
......@@ -77,7 +77,6 @@ private:
QAction *m_playAction;
QAction *m_showLogAction;
QToolBar *m_recToolbar;
QComboBox *m_screenCombo{nullptr};
QToolButton *m_audioCaptureButton;
QComboBox *m_device_selector;
QComboBox *m_audio_device;
......@@ -87,8 +86,10 @@ private:
bool m_checkAudio;
bool m_checkVideo;
Mlt::Producer *createV4lProducer();
int m_screenIndex;
private slots:
void slotSetScreen(int ScreenIndex);
void slotRecord(bool record);
void slotPreview(bool record);
void slotProcessStatus(int exitCode, QProcess::ExitStatus exitStatus);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment