mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-13 08:19:50 -05:00
Fix referenced entry color on macOS dark mode (#2984)
Introduce macUtils()->isDarkMode() function to detect Mojave dark mode and correct reference entry text color. Fixes #860.
This commit is contained in:
parent
cc27a367d6
commit
e7815787c7
@ -30,6 +30,9 @@
|
||||
#include "core/Global.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
#ifdef Q_OS_MACOS
|
||||
#include "gui/macutils/MacUtils.h"
|
||||
#endif
|
||||
|
||||
EntryModel::EntryModel(QObject* parent)
|
||||
: QAbstractTableModel(parent)
|
||||
@ -270,6 +273,11 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
||||
} else if (role == Qt::ForegroundRole) {
|
||||
if (entry->hasReferences()) {
|
||||
QPalette p;
|
||||
#ifdef Q_OS_MACOS
|
||||
if (macUtils()->isDarkMode()) {
|
||||
return QVariant(p.color(QPalette::Inactive, QPalette::Dark));
|
||||
}
|
||||
#endif
|
||||
return QVariant(p.color(QPalette::Active, QPalette::Mid));
|
||||
} else if (entry->foregroundColor().isValid()) {
|
||||
return QVariant(entry->foregroundColor());
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
bool activateProcess(pid_t pid);
|
||||
bool hideProcess(pid_t pid);
|
||||
bool isHidden(pid_t pid);
|
||||
bool isDarkMode();
|
||||
|
||||
private:
|
||||
void *self;
|
||||
|
@ -30,5 +30,6 @@
|
||||
- (bool) activateProcess:(pid_t) pid;
|
||||
- (bool) hideProcess:(pid_t) pid;
|
||||
- (bool) isHidden:(pid_t) pid;
|
||||
- (bool) isDarkMode;
|
||||
|
||||
@end
|
||||
|
@ -127,4 +127,12 @@ bool AppKit::isHidden(pid_t pid)
|
||||
return [static_cast<id>(self) isHidden:pid];
|
||||
}
|
||||
|
||||
bool AppKit::isDarkMode()
|
||||
{
|
||||
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain];
|
||||
id style = [dict objectForKey:@"AppleInterfaceStyle"];
|
||||
return ( style && [style isKindOfClass:[NSString class]]
|
||||
&& NSOrderedSame == [style caseInsensitiveCompare:@"dark"] );
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -70,3 +70,8 @@ bool MacUtils::isHidden()
|
||||
{
|
||||
return m_appkit->isHidden(m_appkit->ownProcessId());
|
||||
}
|
||||
|
||||
bool MacUtils::isDarkMode()
|
||||
{
|
||||
return m_appkit->isDarkMode();
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
bool raiseOwnWindow();
|
||||
bool hideOwnWindow();
|
||||
bool isHidden();
|
||||
bool isDarkMode();
|
||||
|
||||
private:
|
||||
explicit MacUtils(QObject* parent = nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user