mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-06 05:57:37 +03:00
Add menu option to allow screenshots
* Fix #7580 * Also refactor the code to move everything into MainWindow
This commit is contained in:
parent
df40742223
commit
90bbb66409
8 changed files with 48 additions and 28 deletions
|
@ -259,6 +259,7 @@ MainWindow::MainWindow()
|
|||
m_showToolbarSeparator = config()->get(Config::GUI_ApplicationTheme).toString() != "classic";
|
||||
|
||||
m_ui->actionEntryAutoType->setVisible(autoType()->isAvailable());
|
||||
m_ui->actionAllowScreenCapture->setVisible(osUtils->canPreventScreenCapture());
|
||||
|
||||
m_inactivityTimer = new InactivityTimer(this);
|
||||
connect(m_inactivityTimer, SIGNAL(inactivityDetected()), this, SLOT(lockDatabasesAfterInactivity()));
|
||||
|
@ -563,6 +564,7 @@ MainWindow::MainWindow()
|
|||
connect(m_ui->actionUserGuide, SIGNAL(triggered()), SLOT(openUserGuide()));
|
||||
connect(m_ui->actionOnlineHelp, SIGNAL(triggered()), SLOT(openOnlineHelp()));
|
||||
connect(m_ui->actionKeyboardShortcuts, SIGNAL(triggered()), SLOT(openKeyboardShortcuts()));
|
||||
connect(m_ui->actionAllowScreenCapture, &QAction::toggled, this, &MainWindow::setAllowScreenCapture);
|
||||
|
||||
connect(osUtils, &OSUtilsBase::statusbarThemeChanged, this, &MainWindow::updateTrayIcon);
|
||||
|
||||
|
@ -1658,11 +1660,27 @@ void MainWindow::applySettingsChanges()
|
|||
updateTrayIcon();
|
||||
}
|
||||
|
||||
void MainWindow::focusWindowChanged(QWindow* focusWindow)
|
||||
void MainWindow::setAllowScreenCapture(bool state)
|
||||
{
|
||||
if (focusWindow != windowHandle()) {
|
||||
m_allowScreenCapture = state;
|
||||
for (auto window : qApp->allWindows()) {
|
||||
osUtils->setPreventScreenCapture(window, !m_allowScreenCapture);
|
||||
}
|
||||
m_ui->actionAllowScreenCapture->blockSignals(true);
|
||||
m_ui->actionAllowScreenCapture->setChecked(m_allowScreenCapture);
|
||||
m_ui->actionAllowScreenCapture->blockSignals(false);
|
||||
}
|
||||
|
||||
void MainWindow::focusWindowChanged(QWindow* window)
|
||||
{
|
||||
if (window != windowHandle()) {
|
||||
m_lastFocusOutTime = Clock::currentMilliSecondsSinceEpoch();
|
||||
}
|
||||
|
||||
if (!osUtils->setPreventScreenCapture(window, !m_allowScreenCapture) && !m_allowScreenCapture) {
|
||||
displayGlobalMessage(QObject::tr("Warning: Failed to block screenshot capture on a top-level window."),
|
||||
MessageWidget::Error);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::trayIconTriggered(QSystemTrayIcon::ActivationReason reason)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue