Skip to content

Commit c7e56b4

Browse files
ra1nb0wDavid Gräff
authored andcommitted
fix Dark mode background introduced with MacOS 10.14 (mojave) (#264)
this fix set the correct background when you change the style. without the patch and with Dark mode the text and background are white; with this patch the text remain white but the background will be set to dark. thanks to @gmittone Signed-off-by: Davide `rainbow` Gerhard <rainbow@irh.it>
1 parent 84f258e commit c7e56b4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

openhantek/src/widgets/sispinbox.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ SiSpinBox::SiSpinBox(Unit unit, QWidget *parent) : QDoubleSpinBox(parent) {
4141
this->init();
4242

4343
this->setUnit(unit);
44+
45+
this->setBackground();
4446
}
4547

4648
/// \brief Cleans up the main window.
@@ -177,3 +179,10 @@ void SiSpinBox::init() {
177179

178180
/// \brief Resets the ::steppedTo flag after the value has been changed.
179181
void SiSpinBox::resetSteppedTo() { this->steppedTo = false; }
182+
183+
// fix Dark mode background introduced with MacOS 10.24 (mojave)
184+
void SiSpinBox::setBackground() {
185+
QPalette palette;
186+
QColor background = palette.color(QPalette::Window);
187+
this->setStyleSheet("background-color: " + background.name());
188+
}

openhantek/src/widgets/sispinbox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class SiSpinBox : public QDoubleSpinBox {
3131

3232
private:
3333
void init();
34+
void setBackground();
3435

3536
Unit unit; ///< The SI unit used for this spin box
3637
QString unitPostfix; ///< Shown after the unit

0 commit comments

Comments
 (0)