mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-18 01:44:47 -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
6 changed files with 24 additions and 0 deletions
|
|
@ -30,6 +30,9 @@
|
||||||
#include "core/Global.h"
|
#include "core/Global.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
#include "core/Metadata.h"
|
#include "core/Metadata.h"
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
#include "gui/macutils/MacUtils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
EntryModel::EntryModel(QObject* parent)
|
EntryModel::EntryModel(QObject* parent)
|
||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
|
|
@ -270,6 +273,11 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
||||||
} else if (role == Qt::ForegroundRole) {
|
} else if (role == Qt::ForegroundRole) {
|
||||||
if (entry->hasReferences()) {
|
if (entry->hasReferences()) {
|
||||||
QPalette p;
|
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));
|
return QVariant(p.color(QPalette::Active, QPalette::Mid));
|
||||||
} else if (entry->foregroundColor().isValid()) {
|
} else if (entry->foregroundColor().isValid()) {
|
||||||
return QVariant(entry->foregroundColor());
|
return QVariant(entry->foregroundColor());
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ public:
|
||||||
bool activateProcess(pid_t pid);
|
bool activateProcess(pid_t pid);
|
||||||
bool hideProcess(pid_t pid);
|
bool hideProcess(pid_t pid);
|
||||||
bool isHidden(pid_t pid);
|
bool isHidden(pid_t pid);
|
||||||
|
bool isDarkMode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void *self;
|
void *self;
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,6 @@
|
||||||
- (bool) activateProcess:(pid_t) pid;
|
- (bool) activateProcess:(pid_t) pid;
|
||||||
- (bool) hideProcess:(pid_t) pid;
|
- (bool) hideProcess:(pid_t) pid;
|
||||||
- (bool) isHidden:(pid_t) pid;
|
- (bool) isHidden:(pid_t) pid;
|
||||||
|
- (bool) isDarkMode;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -127,4 +127,12 @@ bool AppKit::isHidden(pid_t pid)
|
||||||
return [static_cast<id>(self) isHidden: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
|
@end
|
||||||
|
|
|
||||||
|
|
@ -70,3 +70,8 @@ bool MacUtils::isHidden()
|
||||||
{
|
{
|
||||||
return m_appkit->isHidden(m_appkit->ownProcessId());
|
return m_appkit->isHidden(m_appkit->ownProcessId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MacUtils::isDarkMode()
|
||||||
|
{
|
||||||
|
return m_appkit->isDarkMode();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ public:
|
||||||
bool raiseOwnWindow();
|
bool raiseOwnWindow();
|
||||||
bool hideOwnWindow();
|
bool hideOwnWindow();
|
||||||
bool isHidden();
|
bool isHidden();
|
||||||
|
bool isDarkMode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit MacUtils(QObject* parent = nullptr);
|
explicit MacUtils(QObject* parent = nullptr);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue