From bb005f4136e74260ec3564c31c944c8272ea4329 Mon Sep 17 00:00:00 2001 From: Darcy Shen Date: Tue, 21 Nov 2023 16:00:30 +0800 Subject: [PATCH] [35_3] dark mode for svg icons on Windows/Linux/macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 沈浪熊猫儿 --- src/Plugins/Qt/qt_picture.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Plugins/Qt/qt_picture.cpp b/src/Plugins/Qt/qt_picture.cpp index e78e9df391..e577b66d95 100644 --- a/src/Plugins/Qt/qt_picture.cpp +++ b/src/Plugins/Qt/qt_picture.cpp @@ -99,7 +99,11 @@ qt_load_icon (url file_name) { #ifdef OS_MINGW return QIcon (qt_load_svg_icon (svg)); #else - return QIcon (to_qstring (as_string (svg))); + if (occurs ("dark", tm_style_sheet)) { + return QIcon (qt_load_svg_icon (svg)); + } else { + return QIcon (to_qstring (as_string (svg))); + } #endif } else { return QIcon (as_pixmap (*xpm_image (file_name))); @@ -388,6 +392,11 @@ qt_load_svg_icon (url file_name) { QPainter painter (pm); renderer.render (&painter); + if (occurs ("dark", tm_style_sheet) && may_transform (file_name, *pm)) { + invert_colors (*pm); + saturate (*pm); + } + QPixmap icon (pm->size ()); icon.convertFromImage (*pm); return icon;