[LyX/master] Add method to check whether LyX runs in dark mode
Juergen Spitzmueller
spitz at lyx.org
Tue Jan 19 08:21:19 UTC 2021
commit 3f1799b2c821a41fe35db71aeb69dee9f3214839
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Tue Jan 19 09:21:36 2021 +0100
Add method to check whether LyX runs in dark mode
---
src/frontends/Application.h | 5 +++++
src/frontends/qt/GuiApplication.cpp | 5 +++++
src/frontends/qt/GuiApplication.h | 1 +
3 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/frontends/Application.h b/src/frontends/Application.h
index 59806c0..053a699 100644
--- a/src/frontends/Application.h
+++ b/src/frontends/Application.h
@@ -203,6 +203,11 @@ public:
/// Like getRgbColor(), but static and slower
static bool getRgbColorUncached(ColorCode col, RGBColor & rgbcol);
+ /**
+ * @return true if LyX uses a dark theme
+ */
+ virtual bool isInDarkMode() = 0;
+
/** Eg, passing Color_black returns "000000",
* passing Color_white returns "ffffff".
*/
diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp
index 0016f6d..3247402 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -2895,6 +2895,11 @@ bool GuiApplication::notify(QObject * receiver, QEvent * event)
return false;
}
+bool GuiApplication::isInDarkMode()
+{
+ return colorCache().isDarkMode();
+}
+
bool GuiApplication::getRgbColor(ColorCode col, RGBColor & rgbcol)
{
diff --git a/src/frontends/qt/GuiApplication.h b/src/frontends/qt/GuiApplication.h
index e6a96c3..2622c71 100644
--- a/src/frontends/qt/GuiApplication.h
+++ b/src/frontends/qt/GuiApplication.h
@@ -74,6 +74,7 @@ public:
void exit(int status) override;
bool event(QEvent * e) override;
bool getRgbColor(ColorCode col, RGBColor & rgbcol) override;
+ bool isInDarkMode() override;
std::string const hexName(ColorCode col) override;
void registerSocketCallback(int fd, SocketCallback func) override;
void unregisterSocketCallback(int fd) override;
More information about the lyx-cvs
mailing list