From 37f0ab1f8cc96229fe1367ab452c2f3c2f09b532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20T=C3=BCrkoglu?= Date: Fri, 11 Apr 2025 03:50:37 +1000 Subject: [PATCH] Add flag to enable/disable screenshots (#1301) * Bump TransformerKit to fix compile Fixes build issue with Xcode 15 by raising minimum deployment target to 10.13 * Add flag to disable screenshots Make it possible to disable/enable screenshots, this is disabled by default, to enable use: $ defaults write com.hicknhacksoftware.MacPass AllowScreenshots YES and to disable it use: $ defaults write com.hicknhacksoftware.MacPass AllowScreenshots NO --------- Co-authored-by: Michael Starke --- Cartfile.resolved | 2 +- MacPass/MPDocumentWindowController.m | 8 ++++++++ MacPass/MPSettingsHelper.h | 1 + MacPass/MPSettingsHelper.m | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 8b9548f8..070f21b1 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -2,4 +2,4 @@ binary "https://sparkle-project.org/Carthage/Sparkle.json" "2.6.4" github "MacPass/KeePassKit" "3.3.2" github "MacPass/KissXML" "503fc012b73a4507965019720cbf1c157e849657" github "MacPass/TransformerKit" "3232b04c568df7f98b33ceb21a2090a9ccbc2065" -github "mstarke/HNHUi" "6.0.1" \ No newline at end of file +github "mstarke/HNHUi" "6.0.1" diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index 867cdccb..fdea245a 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -100,6 +100,14 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); [super windowDidLoad]; self.window.delegate = self.documentWindowDelegate; + BOOL allowScreenshots = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyAllowScreenshots]; + if(!allowScreenshots) { + self.window.sharingType = NSWindowSharingNone; + } + else { + self.window.sharingType = NSWindowSharingReadOnly; + } + if (@available(macOS 11.0, *)) { /* let the user decide how to dipsplay the toolbar */ BOOL useUnifiedToolbar = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyUseUnifiedToolbar]; diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h index 0704732e..64e8a8d4 100644 --- a/MacPass/MPSettingsHelper.h +++ b/MacPass/MPSettingsHelper.h @@ -105,6 +105,7 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyFaviconDownloadMethod; /* UI */ APPKIT_EXTERN NSString *const kMPSettingsKeyUseUnifiedToolbar; +APPKIT_EXTERN NSString *const kMPSettingsKeyAllowScreenshots; typedef NS_ENUM(NSUInteger, MPFileChangeStrategy) { MPFileChangeStrategyAsk, diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index a36928a5..fb4d4141 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -101,6 +101,7 @@ NSString *const kMPSettingsKeyAllowRemoteFetchOfPluginRepository NSString *const kMPSettingsKeyFaviconDownloadMethod = @"FaviconDownloadMethod"; NSString *const kMPSettingsKeyUseUnifiedToolbar = @"UseUnifiedToolbar"; +NSString *const kMPSettingsKeyAllowScreenshots = @"AllowScreenshots"; /* Deprecated */ NSString *const kMPDeprecatedSettingsKeyRememberKeyFilesForDatabases = @"kMPSettingsKeyRememberKeyFilesForDatabases"; @@ -186,6 +187,7 @@ NSString *const kMPDepricatedSettingsKeyEntryTouchIdDatabaseEncryptedKeyFormat kMPSettingsKeyFaviconDownloadMethod: @(MPFaviconDownloadMethodDirect), // Download directly from host kMPSettingsKeyGloablAutotypeAlwaysShowCandidateSelection: @NO, kMPSettingsKeyUseUnifiedToolbar: @YES, // Do not use unified toolbar under Big Sur and above + kMPSettingsKeyAllowScreenshots: @NO, // Do not allow screenshots or screen recordings of MacPass kMPSettingsKeyFocusSearchAfterUnlock: @NO, // Do not enter search directly after unlocking the database kMPSettingsKeyUsePrivateBrowsingWhenOpeningURLs: @NO // No private mode when option URLs by default };