[LyX/master] Allow for runtime (dark/light) mode switch
Juergen Spitzmueller
spitz at lyx.org
Thu Mar 4 11:32:40 UTC 2021
commit 812b6f7d69e691a04ba22477d4e443d3fb4f8757
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Thu Mar 4 12:35:38 2021 +0100
Allow for runtime (dark/light) mode switch
---
src/frontends/qt/GuiToolbar.cpp | 8 ++++++++
src/frontends/qt/GuiToolbar.h | 3 +++
src/frontends/qt/GuiView.cpp | 13 +++++++++++++
src/frontends/qt/GuiView.h | 2 ++
4 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/src/frontends/qt/GuiToolbar.cpp b/src/frontends/qt/GuiToolbar.cpp
index 5600f4a..8057d84 100644
--- a/src/frontends/qt/GuiToolbar.cpp
+++ b/src/frontends/qt/GuiToolbar.cpp
@@ -116,6 +116,14 @@ void GuiToolbar::fill()
}
+void GuiToolbar::refill()
+{
+ filled_ = false;
+ clear();
+ fill();
+}
+
+
void GuiToolbar::showEvent(QShowEvent * ev)
{
fill();
diff --git a/src/frontends/qt/GuiToolbar.h b/src/frontends/qt/GuiToolbar.h
index 262b09e..d658f3f 100644
--- a/src/frontends/qt/GuiToolbar.h
+++ b/src/frontends/qt/GuiToolbar.h
@@ -152,6 +152,9 @@ public:
///
void toggle();
+ ///
+ void refill();
+
/// toggles movability
void movable(bool silent = false);
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index a48540d..c226968 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -1470,6 +1470,12 @@ bool GuiView::event(QEvent * e)
return QMainWindow::event(e);
}
+ case QEvent::ApplicationPaletteChange: {
+ // runtime switch from/to dark mode
+ refillToolbars();
+ return QMainWindow::event(e);
+ }
+
default:
return QMainWindow::event(e);
}
@@ -1739,6 +1745,13 @@ void GuiView::updateToolbars()
}
+void GuiView::refillToolbars()
+{
+ for (auto const & tb_p : d.toolbars_)
+ tb_p.second->refill();
+}
+
+
void GuiView::setBuffer(Buffer * newBuffer, bool switch_to)
{
LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << endl);
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index 4c610e0..f5024e5 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -149,6 +149,8 @@ public:
/// updates the possible layouts selectable
void updateLayoutList();
void updateToolbars();
+ /// refill the toolbars (dark mode switch)
+ void refillToolbars();
///
LayoutBox * getLayoutDialog() const;
More information about the lyx-cvs
mailing list