diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp index cdc2c4d0..cf112d79 100644 --- a/src/core/flameshot.cpp +++ b/src/core/flameshot.cpp @@ -37,7 +37,6 @@ Flameshot::Flameshot() : m_captureWindow(nullptr) - , m_have_external_widgets(false) #if defined(Q_OS_MACOS) , m_HotkeyScreenshotCapture(nullptr) , m_HotkeyScreenshotHistory(nullptr) @@ -412,13 +411,12 @@ void Flameshot::exportCapture(QPixmap capture, if (!(tasks & CR::UPLOAD)) { emit captureTaken(capture); } - if (!m_have_external_widgets) - qApp->quit(); -} - -void Flameshot::setExternalWidgets() -{ - m_have_external_widgets = true; + // hacks: close a window to trigger qt's quitOnLastWindowClose + // if not create tmp_window and close, the `flameshot gui` won't exit after + // click copy button + QWidget* tmp = new QWidget(); + tmp->show(); + tmp->close(); } // STATIC ATTRIBUTES diff --git a/src/core/flameshot.h b/src/core/flameshot.h index 3519ea11..ec8ce98c 100644 --- a/src/core/flameshot.h +++ b/src/core/flameshot.h @@ -47,7 +47,6 @@ public slots: public: static void setOrigin(Origin origin); static Origin origin(); - void setExternalWidgets(); signals: void captureTaken(QPixmap p); @@ -60,7 +59,6 @@ public slots: private: Flameshot(); bool resolveAnyConfigErrors(); - bool m_have_external_widgets; // class members static Origin m_origin; diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 92cf10cc..1f2bc24a 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -1200,7 +1200,6 @@ void CaptureWidget::handleToolSignal(CaptureTool::Request r) w->setAttribute(Qt::WA_DeleteOnClose); w->activateWindow(); w->show(); - Flameshot::instance()->setExternalWidgets(); } break; case CaptureTool::REQ_INCREASE_TOOL_SIZE: