qt: Disable macOS system focus rectangles for dash themes (#3556)

* qt: Disable macOS system focus rectangles for dash themes

The focus rects drawn by macOS are in the color the user selected in the
OS settings as selection color. This just doesn't always fit into the coloring of the dash specific themes.

* Apply review suggestion

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
dustinface 2020-07-09 01:27:53 +02:00 committed by xdustinface
parent d296cbdca1
commit 067622764c
12 changed files with 33 additions and 0 deletions

View File

@ -33,6 +33,8 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent) :
GUIUtil::updateFonts();
GUIUtil::disableMacFocusRect(this);
ui->passEdit1->setMinimumSize(ui->passEdit1->sizeHint());
ui->passEdit2->setMinimumSize(ui->passEdit2->sizeHint());
ui->passEdit3->setMinimumSize(ui->passEdit3->sizeHint());

View File

@ -65,6 +65,8 @@ CoinControlDialog::CoinControlDialog(const PlatformStyle *_platformStyle, QWidge
GUIUtil::updateFonts();
GUIUtil::disableMacFocusRect(this);
// context menu actions
QAction *copyAddressAction = new QAction(tr("Copy address"), this);
QAction *copyLabelAction = new QAction(tr("Copy label"), this);

View File

@ -21,6 +21,8 @@ EditAddressDialog::EditAddressDialog(Mode _mode, QWidget *parent) :
{
ui->setupUi(this);
GUIUtil::disableMacFocusRect(this);
GUIUtil::setupAddressWidget(ui->addressEdit, this);
switch(mode)

View File

@ -1449,6 +1449,17 @@ bool dashThemeActive()
return theme != traditionalTheme;
}
void disableMacFocusRect(const QWidget* w)
{
#ifdef Q_OS_MAC
for (const auto& c : w->findChildren<QWidget*>()) {
if (c->testAttribute(Qt::WA_MacShowFocusRect)) {
c->setAttribute(Qt::WA_MacShowFocusRect, !dashThemeActive());
}
}
#endif
}
void setClipboard(const QString& str)
{
QApplication::clipboard()->setText(str, QClipboard::Clipboard);

View File

@ -307,6 +307,10 @@ namespace GUIUtil
/** Check if a dash specific theme is activated (light/dark) */
bool dashThemeActive();
/** Disable the OS default focus rect for macOS because we have custom focus rects
* set in the css files */
void disableMacFocusRect(const QWidget* w);
/* Convert QString to OS specific boost path through UTF-8 */
fs::path qstringToBoostPath(const QString &path);

View File

@ -205,6 +205,7 @@ bool Intro::pickDataDirectory()
{
/* Let the user choose one */
Intro intro;
GUIUtil::disableMacFocusRect(&intro);
intro.setDataDirectory(dataDirDefaultCurrent);
intro.setWindowIcon(QIcon(":icons/bitcoin"));

View File

@ -17,6 +17,7 @@ OpenURIDialog::OpenURIDialog(QWidget *parent) :
{
ui->setupUi(this);
GUIUtil::updateFonts();
GUIUtil::disableMacFocusRect(this);
#if QT_VERSION >= 0x040700
ui->uriEdit->setPlaceholderText("dash:");
#endif

View File

@ -40,6 +40,8 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
GUIUtil::updateFonts();
GUIUtil::disableMacFocusRect(this);
/* Main elements init */
ui->databaseCache->setMinimum(nMinDbCache);
ui->databaseCache->setMaximum(nMaxDbCache);

View File

@ -477,6 +477,8 @@ RPCConsole::RPCConsole(const PlatformStyle *_platformStyle, QWidget *parent) :
ui->banHeading
}, GUIUtil::FontWeight::Bold, 16);
GUIUtil::disableMacFocusRect(this);
QSettings settings;
if (!restoreGeometry(settings.value("RPCConsoleWindowGeometry").toByteArray())) {
// Restore failed (perhaps missing setting), center the window

View File

@ -23,6 +23,8 @@ SendCoinsEntry::SendCoinsEntry(const PlatformStyle *_platformStyle, QWidget *par
{
ui->setupUi(this);
GUIUtil::disableMacFocusRect(this);
setCurrentWidget(ui->SendCoins);
if (platformStyle->getUseExtraSpacing())

View File

@ -69,6 +69,8 @@ SignVerifyMessageDialog::SignVerifyMessageDialog(const PlatformStyle *_platformS
GUIUtil::setFont({ui->statusLabel_SM, ui->statusLabel_VM}, GUIUtil::FontWeight::Bold);
GUIUtil::updateFonts();
GUIUtil::disableMacFocusRect(this);
}
SignVerifyMessageDialog::~SignVerifyMessageDialog()

View File

@ -109,6 +109,8 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent):
// Pass through messages from transactionView
connect(transactionView, SIGNAL(message(QString,QString,unsigned int)), this, SIGNAL(message(QString,QString,unsigned int)));
GUIUtil::disableMacFocusRect(this);
}
WalletView::~WalletView()