[vlc-commits] qt: add isDark() function to the SystemPalette class
Fatih Uzunoglu
git at videolan.org
Fri Jul 3 14:59:00 CEST 2020
vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Fri Jun 26 23:26:52 2020 +0300| [970f1ec0013928d857822feff7fd8612e10d33b1] | committer: Pierre Lamot
qt: add isDark() function to the SystemPalette class
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=970f1ec0013928d857822feff7fd8612e10d33b1
---
modules/gui/qt/util/systempalette.cpp | 4 ++++
modules/gui/qt/util/systempalette.hpp | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/modules/gui/qt/util/systempalette.cpp b/modules/gui/qt/util/systempalette.cpp
index c7fcfb3000..a2d0e5156a 100644
--- a/modules/gui/qt/util/systempalette.cpp
+++ b/modules/gui/qt/util/systempalette.cpp
@@ -78,3 +78,7 @@ QColor SystemPalette::shadow() const
return m_palette.color(QPalette::Normal, QPalette::Shadow);
}
+bool SystemPalette::isDark() const
+{
+ return base().lightness() < text().lightness();
+}
diff --git a/modules/gui/qt/util/systempalette.hpp b/modules/gui/qt/util/systempalette.hpp
index bedf2782cf..00f5f31bc2 100644
--- a/modules/gui/qt/util/systempalette.hpp
+++ b/modules/gui/qt/util/systempalette.hpp
@@ -90,6 +90,8 @@ class SystemPalette : public QObject
Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged)
Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged)
+ Q_PROPERTY(bool isDark READ isDark NOTIFY paletteChanged)
+
public:
SystemPalette(QObject* parent = nullptr);
@@ -155,6 +157,8 @@ public:
QColor mid() const;
QColor shadow() const;
+ bool isDark() const;
+
signals:
void paletteChanged();
More information about the vlc-commits
mailing list