From 1418dc04e022c4d193c1fb0b5f9a0a4c53434d01 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 12 Oct 2023 13:36:35 +0200 Subject: [PATCH] ScreenRecorder: Allow only one screen recorder dialog at a time And show the dialog if it was already open but minimized. Change-Id: I9aebebba88488c795b253f6dadda7f356ffc9dc4 Reviewed-by: Marcus Tillmanns --- .../screenrecorder/screenrecorderplugin.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugins/screenrecorder/screenrecorderplugin.cpp b/src/plugins/screenrecorder/screenrecorderplugin.cpp index e5160eec348..e72ebf945e9 100644 --- a/src/plugins/screenrecorder/screenrecorderplugin.cpp +++ b/src/plugins/screenrecorder/screenrecorderplugin.cpp @@ -94,6 +94,19 @@ public: layout()->setSizeConstraint(QLayout::SetFixedSize); } + static void showDialog() + { + static QPointer staticInstance; + + if (staticInstance.isNull()) { + staticInstance = new ScreenRecorderDialog(Core::ICore::dialogParent()); + staticInstance->setAttribute(Qt::WA_DeleteOnClose); + } + staticInstance->show(); + staticInstance->raise(); + staticInstance->activateWindow(); + } + private: RecordWidget *m_recordWidget; TemporaryFile m_recordFile; @@ -132,9 +145,7 @@ private: return; } - auto dialog = new ScreenRecorderDialog(Core::ICore::dialogParent()); - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->show(); + ScreenRecorderDialog::showDialog(); } };