Skip to content

Commit

Permalink
[#3505] use QT APIs screenAdded and screenRemoved to reiniitalize Fla…
Browse files Browse the repository at this point in the history
…meshot when the display configuration changes
  • Loading branch information
leehambley committed May 27, 2024
1 parent a1dda59 commit 4b54150
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QApplication>
#include <QDir>
#include <QLibraryInfo>
#include <QScreen>
#include <QSharedMemory>
#include <QTimer>
#include <QTranslator>
Expand Down Expand Up @@ -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 */
QObject::connect(qApp, &QGuiApplication::screenAdded, [](QScreen *screen){
qInfo() << "Screen added. Reinitializing application.";
configureApp(true);
});
QObject::connect(qApp, &QGuiApplication::screenRemoved, [](QScreen *screen){
// Code to handle screen removed
qInfo() << "Screen removed. Reinitializing application.";
reinitializeAsQApplication(argc, argv);
});

#if !(defined(Q_OS_MACOS) || defined(Q_OS_WIN))
new FlameshotDBusAdapter(c);
QDBusConnection dbus = QDBusConnection::sessionBus();
Expand Down

0 comments on commit 4b54150

Please sign in to comment.