Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3505] use QT APIs screenAdded and screenRemoved to reiniitalize Fla… #3618

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 */
leehambley marked this conversation as resolved.
Show resolved Hide resolved
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();
Expand Down