Commit 5406eba0 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Make monitor detection more robust for fullscreen mode

parent 24f760e4
......@@ -752,30 +752,44 @@ void KdenliveSettingsDialog::initDevices()
m_configSdl.group_sdl->setEnabled(KdenliveSettings::audiobackend().startsWith(QLatin1String("sdl")));
// Fill monitors data
fillMonitorData();
connect(qApp, &QApplication::screenAdded, this, &KdenliveSettingsDialog::fillMonitorData);
connect(qApp, &QApplication::screenRemoved, this, &KdenliveSettingsDialog::fillMonitorData);
loadCurrentV4lProfileInfo();
}
void KdenliveSettingsDialog::fillMonitorData()
{
QSignalBlocker bk(m_configSdl.fullscreen_monitor);
m_configSdl.fullscreen_monitor->clear();
m_configSdl.fullscreen_monitor->addItem(i18n("auto"));
int ix = 0;
for (const QScreen* screen : qApp->screens()) {
#ifdef Q_OS_WIN
// Screen manufacturer, model and serial don't work under Windows
m_configSdl.fullscreen_monitor->addItem(QString("%1: %2").arg(QString::number(ix), screen->name()), QString::number(ix));
QString screenName = screen->name().isEmpty() ? i18n("Monitor %1", ix + 1) : QString("%1: %2").arg(ix + 1).arg(screen->name());
if (!screen->model().isEmpty()) {
screenName.append(QString(" - %1").arg(screen->model()));
}
if (!screen->manufacturer().isEmpty()) {
screenName.append(QString(" (%1)").arg(screen->manufacturer()));
}
m_configSdl.fullscreen_monitor->addItem(screenName, QString("%1:%2").arg(QString::number(ix), screen->serialNumber()));
ix++;
#else
m_configSdl.fullscreen_monitor->addItem(QString("%1 %2 (%3)").arg(screen->manufacturer(), screen->model(), screen->name()), screen->serialNumber());
#endif
}
if (!KdenliveSettings::fullscreen_monitor().isEmpty()) {
int ix = m_configSdl.fullscreen_monitor->findData(KdenliveSettings::fullscreen_monitor());
if (ix > -1) {
m_configSdl.fullscreen_monitor->setCurrentIndex(ix);
} else {
// Monitor not found, reset
m_configSdl.fullscreen_monitor->setCurrentIndex(0);
KdenliveSettings::setFullscreen_monitor(QString());
}
}
loadCurrentV4lProfileInfo();
}
void KdenliveSettingsDialog::slotReadAudioDevices()
{
QString result = QString(m_readProcess.readAllStandardOutput());
......
......@@ -98,6 +98,8 @@ private slots:
void downloadModelFinished(KJob* job);
void processArchive(const QString &path);
void doShowSpeechMessage(const QString &message, int messageType);
/** @brief fill list of connected monitors */
void fillMonitorData();
private:
KPageWidgetItem *m_page1;
......
......@@ -991,13 +991,15 @@ void Monitor::slotSwitchFullScreen(bool minimizeOnly)
bool screenFound = false;
int ix = -1;
if (!KdenliveSettings::fullscreen_monitor().isEmpty()) {
// If the platform does now provide screen serial number, use indexes
for (const QScreen* screen : qApp->screens()) {
#ifdef Q_OS_WIN
ix++;
if (QString::number(ix) == KdenliveSettings::fullscreen_monitor()) {
#else
if (screen->serialNumber() == KdenliveSettings::fullscreen_monitor()) {
#endif
bool match = KdenliveSettings::fullscreen_monitor() == QString("%1:%2").arg(QString::number(ix),screen->serialNumber());
// Check if monitor's index changed
if (!match && !screen->serialNumber().isEmpty()) {
match = KdenliveSettings::fullscreen_monitor().section(QLatin1Char(':'), 1) == screen->serialNumber();
}
if (match) {
// Match
m_glWidget->setParent(nullptr);
m_glWidget->move(screen->geometry().topLeft());
......
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