[LyX/master] Also change pdf module highlighting on the fly on mode change
Juergen Spitzmueller
spitz at lyx.org
Tue Sep 5 08:32:21 UTC 2023
commit 7c8c3657fdebf38d35a44c0e7e50a092d106addf
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Tue Sep 5 11:48:53 2023 +0200
Also change pdf module highlighting on the fly on mode change
---
src/frontends/qt/GuiDocument.cpp | 28 ++++++++++++++++++++++++++--
src/frontends/qt/GuiDocument.h | 6 ++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index bd72195..46f2a9c 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -1782,8 +1782,11 @@ GuiDocument::GuiDocument(GuiView & lv)
pdfSupportModule->subjectLE));
pdfSupportModule->keywordsLE->setValidator(new NoNewLineValidator(
pdfSupportModule->keywordsLE));
- (void) new LaTeXHighlighter(pdfSupportModule->optionsTE->document(), true, true);
- (void) new LaTeXHighlighter(pdfSupportModule->metadataTE->document(), true, true);
+
+ pdf_options_highlighter_ = new LaTeXHighlighter(
+ pdfSupportModule->optionsTE->document(), true, true);
+ pdf_metadata_highlighter_ = new LaTeXHighlighter(
+ pdfSupportModule->metadataTE->document(), true, true);
for (int i = 0; backref_opts[i][0]; ++i)
pdfSupportModule->backrefCO->addItem(qt_(backref_opts_gui[i]));
@@ -1840,6 +1843,9 @@ GuiDocument::GuiDocument(GuiView & lv)
docPS->addPanel(outputModule, N_("Output"));
docPS->addPanel(preambleModule, N_("LaTeX Preamble"));
docPS->setCurrentPanel("Document Class");
+
+ // Filter out (dark/light) mode changes
+ installEventFilter(this);
}
@@ -5391,6 +5397,24 @@ void GuiDocument::setOutputSync(bool on)
}
+bool GuiDocument::eventFilter(QObject * sender, QEvent * event)
+{
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ // mode switch: colors need to be updated
+ // and the highlighting redone
+ if (pdf_options_highlighter_) {
+ pdf_options_highlighter_->setupColors();
+ pdf_options_highlighter_->rehighlight();
+ }
+ if (pdf_metadata_highlighter_) {
+ pdf_metadata_highlighter_->setupColors();
+ pdf_metadata_highlighter_->rehighlight();
+ }
+ }
+ return QWidget::eventFilter(sender, event);
+}
+
+
} // namespace frontend
} // namespace lyx
diff --git a/src/frontends/qt/GuiDocument.h b/src/frontends/qt/GuiDocument.h
index 12f1cd7..c99345c 100644
--- a/src/frontends/qt/GuiDocument.h
+++ b/src/frontends/qt/GuiDocument.h
@@ -360,6 +360,12 @@ private:
/// Track whether we prompted the user about unapplied
/// changes
bool prompted_;
+
+ /// LaTeX syntax highlighter
+ LaTeXHighlighter * pdf_options_highlighter_;
+ LaTeXHighlighter * pdf_metadata_highlighter_;
+protected:
+ bool eventFilter(QObject * sender, QEvent * event) override;
};
More information about the lyx-cvs
mailing list