fix - MacOS - Take screenshot option sometimes doesn't work (because of Mission Control feature)

(cherry picked from commit fdb086a5eb3106200fe4eb751eaa6d641ede25c4)
This commit is contained in:
Yuriy Puchkov
2021-01-29 11:47:18 +02:00
parent 595454af5c
commit c3ee36f809

View File

@@ -233,6 +233,19 @@ void Controller::requestCapture(const CaptureRequest& request)
void Controller::startVisualCapture(const uint id,
const QString& forcedSavePath)
{
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
// This is required on MacOS because of Mission Control. If you'll switch to
// another Desktop you cannot take a new screenshot from the tray, you have
// to switch back to the Flameshot Desktop manually. It is not obvious and a
// large number of users are confused and report a bug.
if (m_captureWindow) {
m_captureWindow->close();
delete m_captureWindow;
m_captureWindow = nullptr;
}
#endif
if (!m_captureWindow) {
QWidget* modalWidget = nullptr;
do {
@@ -346,8 +359,14 @@ void Controller::enableTrayIcon()
ConfigHandler().setDisabledTrayIcon(false);
QAction* captureAction = new QAction(tr("&Take Screenshot"), this);
connect(captureAction, &QAction::triggered, this, [this]() {
// Wait 400 ms to hide the QMenu
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
// It seems it is not relevant for MacOS (Wait 400 ms to hide the QMenu)
startVisualCapture();
#else
// Wait 400 ms to hide the QMenu
doLater(400, this, [this]() { this->startVisualCapture(); });
#endif
});
QAction* launcherAction = new QAction(tr("&Open Launcher"), this);
connect(launcherAction,