Add menu option to allow screenshots

* Fix #7580
* Also refactor the code to move everything into MainWindow
This commit is contained in:
Jonathan White 2022-11-24 21:09:01 -05:00
parent f9f82e9705
commit 0a2e716525
8 changed files with 48 additions and 28 deletions

View file

@ -183,21 +183,9 @@ int main(int argc, char** argv)
MainWindow mainWindow;
#ifndef QT_DEBUG
// Disable screen capture if capable and not explicitly allowed
if (osUtils->canPreventScreenCapture() && !parser.isSet(allowScreenCaptureOption)) {
// This ensures any top-level windows (Main Window, Modal Dialogs, etc.) are excluded from screenshots
QObject::connect(&app, &QGuiApplication::focusWindowChanged, &mainWindow, [&](QWindow* window) {
if (window) {
if (!osUtils->setPreventScreenCapture(window, true)) {
mainWindow.displayGlobalMessage(
QObject::tr("Warning: Failed to prevent screenshots on a top level window!"),
MessageWidget::Error);
}
}
});
}
#endif
// Disable screen capture if not explicitly allowed
// This ensures any top-level windows (Main Window, Modal Dialogs, etc.) are excluded from screenshots
mainWindow.setAllowScreenCapture(parser.isSet(allowScreenCaptureOption));
const bool pwstdin = parser.isSet(pwstdinOption);
if (!fileNames.isEmpty() && pwstdin) {