Commit c7e56b4c4e985156f8a1a6c18d23d3ef7fe17311

Authored by ra1nb0w
Committed by David Gräff
1 parent 84f258e2

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>
openhantek/src/widgets/sispinbox.cpp
@@ -41,6 +41,8 @@ SiSpinBox::SiSpinBox(Unit unit, QWidget *parent) : QDoubleSpinBox(parent) { @@ -41,6 +41,8 @@ SiSpinBox::SiSpinBox(Unit unit, QWidget *parent) : QDoubleSpinBox(parent) {
41 this->init(); 41 this->init();
42 42
43 this->setUnit(unit); 43 this->setUnit(unit);
  44 +
  45 + this->setBackground();
44 } 46 }
45 47
46 /// \brief Cleans up the main window. 48 /// \brief Cleans up the main window.
@@ -177,3 +179,10 @@ void SiSpinBox::init() { @@ -177,3 +179,10 @@ void SiSpinBox::init() {
177 179
178 /// \brief Resets the ::steppedTo flag after the value has been changed. 180 /// \brief Resets the ::steppedTo flag after the value has been changed.
179 void SiSpinBox::resetSteppedTo() { this->steppedTo = false; } 181 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
@@ -31,6 +31,7 @@ class SiSpinBox : public QDoubleSpinBox { @@ -31,6 +31,7 @@ class SiSpinBox : public QDoubleSpinBox {
31 31
32 private: 32 private:
33 void init(); 33 void init();
  34 + void setBackground();
34 35
35 Unit unit; ///< The SI unit used for this spin box 36 Unit unit; ///< The SI unit used for this spin box
36 QString unitPostfix; ///< Shown after the unit 37 QString unitPostfix; ///< Shown after the unit