diff --git a/src/main.cpp b/src/main.cpp index 23d3157e01..1a3ade27d4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -148,6 +149,17 @@ int main(int argc, char* argv[]) auto c = Flameshot::instance(); FlameshotDaemon::start(); + /* Register handlers for when the screen configuration changes to reinit the app to fix #3505 */ + QObject::connect(qApp, &QGuiApplication::screenAdded, [](QScreen *screen){ + qDebug() << "Screen added. Reinitializing application."; + configureApp(true); + }); + QObject::connect(qApp, &QGuiApplication::screenRemoved, [](QScreen *screen){ + // Code to handle screen removed + qDebug() << "Screen removed. Reinitializing application."; + configureApp(true); + }); + #if !(defined(Q_OS_MACOS) || defined(Q_OS_WIN)) new FlameshotDBusAdapter(c); QDBusConnection dbus = QDBusConnection::sessionBus();