From 813738836406d417369976cc23a8ef37c5437853 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 25 Oct 2022 01:59:48 -0400 Subject: [PATCH] Fix QPalette highlights not working for all macOS themes --- CHANGELOG.md | 1 + src/editor.cpp | 8 ++------ src/mainwindow.cpp | 4 +--- src/ui/newmappopup.cpp | 9 ++------- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c90b0d14..4b3ce800 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Metatile behaviors with no constant will now display their value in the Tileset Editor. - Fix incorrect limits on Floor Number and Border Width/Height in the New Map Options window. - Fix Border Width/Height being set to 0 when creating a new map from an existing layout. +- Fix certain UI elements not highlighting red on some platforms. ## [4.5.0] - 2021-12-26 ### Added diff --git a/src/editor.cpp b/src/editor.cpp index 77380aab..69a501b5 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -265,14 +265,10 @@ void Editor::addNewWildMonGroup(QWidget *window) { lineEdit->setValidator(validator); connect(lineEdit, &QLineEdit::textChanged, [this, &lineEdit, &buttonBox](QString text){ if (this->project->encounterGroupLabels.contains(text)) { - QPalette palette = lineEdit->palette(); - QColor color = Qt::red; - color.setAlpha(25); - palette.setColor(QPalette::Base, color); - lineEdit->setPalette(palette); + lineEdit->setStyleSheet("QLineEdit { background-color: rgba(255, 0, 0, 25%) }"); buttonBox.button(QDialogButtonBox::Ok)->setDisabled(true); } else { - lineEdit->setPalette(QPalette()); + lineEdit->setStyleSheet(""); buttonBox.button(QDialogButtonBox::Ok)->setEnabled(true); } }); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cb6ec632..08eb3a3f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2590,9 +2590,7 @@ void MainWindow::on_pushButton_ChangeDimensions_clicked() } QLabel *errorLabel = new QLabel(); - QPalette errorPalette; - errorPalette.setColor(QPalette::WindowText, Qt::red); - errorLabel->setPalette(errorPalette); + errorLabel->setStyleSheet("QLabel { color: red }"); errorLabel->setVisible(false); QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); diff --git a/src/ui/newmappopup.cpp b/src/ui/newmappopup.cpp index 2796ae63..31d85954 100644 --- a/src/ui/newmappopup.cpp +++ b/src/ui/newmappopup.cpp @@ -6,7 +6,6 @@ #include #include -#include #include struct NewMapPopup::Settings NewMapPopup::settings = {}; @@ -228,13 +227,9 @@ void NewMapPopup::useLayout(QString layoutId) { void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) { if (project->mapNames.contains(text)) { - QPalette palette = this->ui->lineEdit_NewMap_Name->palette(); - QColor color = Qt::red; - color.setAlpha(25); - palette.setColor(QPalette::Base, color); - this->ui->lineEdit_NewMap_Name->setPalette(palette); + this->ui->lineEdit_NewMap_Name->setStyleSheet("QLineEdit { background-color: rgba(255, 0, 0, 25%) }"); } else { - this->ui->lineEdit_NewMap_Name->setPalette(QPalette()); + this->ui->lineEdit_NewMap_Name->setStyleSheet(""); } }