@@ -45,43 +45,49 @@ void InfoContent::setWebEngineTheme()
4545 script.setRunsOnSubFrames (true );
4646
4747 script.setSourceCode (QString (R"(
48- (function applyQtTheme() {
49-
50- // Vänta tills <html> faktiskt finns
51- if (!document.documentElement) {
52- requestAnimationFrame(applyQtTheme);
53- return;
54- }
55-
56- // Se till att <head> finns
57- let head = document.head;
58- if (!head) {
59- head = document.createElement('head');
60- document.documentElement.appendChild(head);
61- }
62-
63- // Återanvänd style om den redan finns
64- let style = document.getElementById('qt-theme-style');
65- if (!style) {
66- style = document.createElement('style');
67- style.id = 'qt-theme-style';
68- head.appendChild(style);
69- }
70-
71- // Trusted Types-safe: använd textContent
72- style.textContent = `
73- html, body {
74- background-color: %1 !important;
75- color: %2 !important;
48+ (function applyQtTheme() {
49+
50+ // Dont run without document
51+ if (!document.documentElement) {
52+ requestAnimationFrame(applyQtTheme);
53+ return;
7654 }
7755
78- ::-webkit-scrollbar-track {
79- background: %1;
56+ // make sure there is a <head>
57+ let head = document.head;
58+ if (!head) {
59+ head = document.createElement('head');
60+ document.documentElement.appendChild(head);
8061 }
8162
82- `;
83- })();
84- )" ).arg (bg.name (), text.name ()));
63+ let style = document.getElementById('qt-theme-style');
64+ if (!style) {
65+ style = document.createElement('style');
66+ style.id = 'qt-theme-style';
67+ head.appendChild(style);
68+ }
69+
70+ // Trusted Types-safe: use textContent
71+ style.textContent = `
72+ html, body {
73+ background-color: %1 !important;
74+ color: %2 !important;
75+ }
76+
77+ html {
78+ scrollbar-color: %2 %1;
79+ }
80+
81+ /* fallback old Chromium */
82+ ::-webkit-scrollbar-track {
83+ background: %1;
84+ }
85+ ::-webkit-scrollbar-thumb {
86+ background-color: %2;
87+ }
88+
89+ `;
90+ })();)" ).arg (bg.name (), text.name ()));
8591
8692
8793 QWebEngineProfile::defaultProfile ()
@@ -98,6 +104,9 @@ InfoContent::InfoContent(QWidget *parent)
98104 layout->setSpacing (8 );
99105
100106 infoWebEngineView = new QWebEngineView (this );
107+ infoWebEngineView->page ()->setBackgroundColor (
108+ palette ().color (QPalette::Base)
109+ );
101110 setWebEngineTheme ();
102111
103112 infoWebEngineView->setHtml (
0 commit comments