Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authortenzap <46226844+tenzap@users.noreply.github.com>2021-11-25 06:35:38 +0300
committerGitHub <noreply@github.com>2021-11-25 06:35:38 +0300
commit61e378077e9b80c27012fe6b0a955dab8fd27c59 (patch)
tree5a89eb8394d241bbed14352d1c17012d3cbd02fc /src/gui
parent296cbf0df77020336060795a30fad87cd4994c90 (diff)
Fix compilation on macOS when clang < 9 or Qt < 5.12 (#7117)
* fix compilation on Qt not having QOperatingSystemVersion::MacOSBigSur The code uses 'QOperatingSystemVersion::MacOSBigSur' which doesn't exist in all Qt versions (it has been backported to Qt 5.12.10+ & 5.15.1+ only). On older macos systems like El Capitan the last supported version of Qt is 5.11 This will fix compilation issue on such older systems and on systems running with Qt not supporting QOperatingSystemVersion::MacOSBigSur Compilation error was: error: no member named 'MacOSBigSur' in 'QOperatingSystemVersion' * Fix compilation when osx <= 10.9 * AppKitImpl.mm: button property is new in 10.10. It is used for a feature of KeePassXC that is only available from 10.17 onwards. So we don't need it when compiling on <= 10.9 error: property 'button' not found on object of type 'NSStatusItem *' NSString* appearance = [dummy.button.effectiveAppearance.name lowercaseString]; ^ * The code uses @available syntax which is supported by AppleClang >= 9 or LLVM >= 5. We check __clang_major__ to allow compilation on older versions of macOS that don't have a recent clang. For example on El Capitan. * Fix compilation when osx <= 10.8 * AppKitImpl.mm: AXIsProcessTrustedWithOptions exists from 10.9 onwards error: use of undeclared identifier 'kAXTrustedCheckOptionPrompt' error: use of undeclared identifier 'AXIsProcessTrustedWithOptions' * Fix compilation when osx <= 10.7 * MacUtils.cpp: CoreGraphics exists from 10.8 onwards only, capslock detection feature would have to be implemented on OSX <= 10.7 * AppKitImpl.mm: CGDisplayStreamRef exists from 10.8 onwards only. It is used for a feature of KeePassXC that is only available from 10.15 onwards. So we don't need it when compiling on <= 10.7 error: unknown type name 'CGDisplayStreamRef' * AppKitImpl.mm: Syntax is not understood by 10.7, update it to be understandable by <= 10.7 error: expected method to read dictionary element not found on object of type 'NSDictionary *' NSRunningApplication* app = userInfo[NSWorkspaceApplicationKey]; ^ * The code uses @available syntax which is supported by AppleClang >= 9 or LLVM >= 5. We check __clang_major__ to allow compilation on older versions of macOS that don't have a recent clang. * Fix compilation error on OS X 10.11 src/core/Alloc.cpp:44:10: error: no type named 'free' in namespace 'std' std::free(ptr); ~~~~~^ This is a regression, since it was fixed in [1] Per [2], std::free() needs #include <cstdlib>. That file is included indirectly on newer systems. [1] https://github.com/keepassxreboot/keepassxc/commit/7c6c027d33b06eb706f93e3d178a2305d7bcfd56 [2] https://en.cppreference.com/w/cpp/memory/c/free * fix compilation when macos SDK <= 10.14 These methods are only available from macOS 10.15 - kSecAccessControlWatch - LAPolicy.deviceOwnerAuthenticationWithBiometricsOrWatch The code uses @available syntax which is supported by AppleClang >= 9 or LLVM >= 5. We check __clang_major__ to allow compilation on older versions of macOS that don't have a recent clang.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/osutils/macutils/AppKitImpl.mm10
-rw-r--r--src/gui/osutils/macutils/MacUtils.cpp7
-rw-r--r--src/gui/styles/base/BaseStyle.cpp8
3 files changed, 24 insertions, 1 deletions
diff --git a/src/gui/osutils/macutils/AppKitImpl.mm b/src/gui/osutils/macutils/AppKitImpl.mm
index 76fe7fe06..a94d9efb6 100644
--- a/src/gui/osutils/macutils/AppKitImpl.mm
+++ b/src/gui/osutils/macutils/AppKitImpl.mm
@@ -60,7 +60,7 @@
- (void) didDeactivateApplicationObserver:(NSNotification*) notification
{
NSDictionary* userInfo = notification.userInfo;
- NSRunningApplication* app = userInfo[NSWorkspaceApplicationKey];
+ NSRunningApplication* app = [userInfo objectForKey:NSWorkspaceApplicationKey];
if (app.processIdentifier != [self ownProcessId]) {
self.lastActiveApplication = app;
@@ -139,6 +139,7 @@
//
- (bool) isStatusBarDark
{
+#if __clang_major__ >= 9 && MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
if (@available(macOS 10.17, *)) {
// This is an ugly hack, but I couldn't find a way to access QTrayIcon's NSStatusItem.
NSStatusItem* dummy = [[NSStatusBar systemStatusBar] statusItemWithLength:0];
@@ -146,6 +147,7 @@
[[NSStatusBar systemStatusBar] removeStatusItem:dummy];
return [appearance containsString:@"dark"];
}
+#endif
return [self isDarkMode];
}
@@ -166,9 +168,13 @@
//
- (bool) enableAccessibility
{
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
// Request accessibility permissions for Auto-Type type on behalf of the user
NSDictionary* opts = @{static_cast<id>(kAXTrustedCheckOptionPrompt): @YES};
return AXIsProcessTrustedWithOptions(static_cast<CFDictionaryRef>(opts));
+#else
+ return YES;
+#endif
}
//
@@ -176,6 +182,7 @@
//
- (bool) enableScreenRecording
{
+#if __clang_major__ >= 9 && MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
if (@available(macOS 10.15, *)) {
// Request screen recording permission on macOS 10.15+
// This is necessary to get the current window title
@@ -193,6 +200,7 @@
return NO;
}
}
+#endif
return YES;
}
diff --git a/src/gui/osutils/macutils/MacUtils.cpp b/src/gui/osutils/macutils/MacUtils.cpp
index 6e4b478bf..5b4751603 100644
--- a/src/gui/osutils/macutils/MacUtils.cpp
+++ b/src/gui/osutils/macutils/MacUtils.cpp
@@ -26,7 +26,10 @@
#include <QWindow>
#include <ApplicationServices/ApplicationServices.h>
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
#include <CoreGraphics/CGEventSource.h>
+#endif
#define INVALID_KEYCODE 0xFFFF
@@ -138,7 +141,11 @@ void MacUtils::setLaunchAtStartup(bool enable)
bool MacUtils::isCapslockEnabled()
{
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
return (CGEventSourceFlagsState(kCGEventSourceStateHIDSystemState) & kCGEventFlagMaskAlphaShift) != 0;
+#else
+ return false;
+#endif
}
/**
diff --git a/src/gui/styles/base/BaseStyle.cpp b/src/gui/styles/base/BaseStyle.cpp
index 0068943b4..ec3fd9b8a 100644
--- a/src/gui/styles/base/BaseStyle.cpp
+++ b/src/gui/styles/base/BaseStyle.cpp
@@ -41,8 +41,10 @@
#ifdef Q_OS_MACOS
#include <QMainWindow>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
#include <QOperatingSystemVersion>
#endif
+#endif
#include "gui/Icons.h"
@@ -279,16 +281,22 @@ namespace Phantom
#ifdef Q_OS_MACOS
QColor tabBarBase(const QPalette& pal)
{
+#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 10) && QT_VERSION < QT_VERSION_CHECK(5, 13, 0) \
+ || QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSBigSur) {
return hack_isLightPalette(pal) ? QRgb(0xD4D4D4) : QRgb(0x2A2A2A);
}
+#endif
return hack_isLightPalette(pal) ? QRgb(0xDD1D1D1) : QRgb(0x252525);
}
QColor tabBarBaseInactive(const QPalette& pal)
{
+#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 10) && QT_VERSION < QT_VERSION_CHECK(5, 13, 0) \
+ || QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSBigSur) {
return hack_isLightPalette(pal) ? QRgb(0xF5F5F5) : QRgb(0x2D2D2D);
}
+#endif
return hack_isLightPalette(pal) ? QRgb(0xF4F4F4) : QRgb(0x282828);
}
#endif