File fix-dark-theme.patch of Package khelpcenter
diff -ruNp a/mainwindow.cpp b/mainwindow.cpp
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -33,7 +33,11 @@
#include <QTextDocument>
#include <QTextEdit>
#include <QVBoxLayout>
-
+#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
+#include <QApplication>
+#include <QStyleHints>
+#include <QWebEngineSettings>
+#endif
#include <KActionCollection>
#include <KActionMenu>
#include <KBookmarkManager>
@@ -147,6 +151,11 @@ MainWindow::MainWindow()
statusBarMessage(i18n("Ready"));
enableCopyTextAction();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
+ applyContentColorScheme();
+ mDoc->page()->setBackgroundColor(Qt::transparent); // Prevent displaying a white page at startup
+#endif
+
readConfig();
}
@@ -440,6 +449,22 @@ void MainWindow::slotPrintPreview()
printDoc->printPreview();
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
+void MainWindow::applyContentColorScheme()
+{
+ auto colorScheme = QApplication::styleHints()->colorScheme();
+ mDoc->page()->settings()->setAttribute(QWebEngineSettings::ForceDarkMode, colorScheme == Qt::ColorScheme::Dark);
+}
+
+void MainWindow::changeEvent(QEvent *e)
+{
+ if (e->type() == QEvent::StyleChange) {
+ applyContentColorScheme();
+ }
+ QWidget::changeEvent(e);
+}
+#endif
+
#include "moc_mainwindow.cpp"
// vim:ts=2:sw=2:et
diff -ruNp a/mainwindow.h b/mainwindow.h
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -79,6 +79,9 @@ protected:
void readConfig();
void writeConfig();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
+ void changeEvent(QEvent *e) override;
+#endif
protected Q_SLOTS:
void enableLastSearchAction();
@@ -103,6 +106,9 @@ private Q_SLOTS:
private:
void updateFontScaleActions();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
+ void applyContentColorScheme();
+#endif
QSplitter *mSplitter = nullptr;
ViewContainer *mViewContainer = nullptr;