Krita Source Code Documentation
Loading...
Searching...
No Matches
utils.py
Go to the documentation of this file.
1"""
2SPDX-FileCopyrightText: 2022 Ivan Santa Maria <ghevan@gmail.com>
3
4SPDX-License-Identifier: GPL-2.0-or-later
5"""
6try:
7 from PyQt6.QtGui import QIcon, QPixmap, QColor, QPainter
8except:
9 from PyQt5.QtGui import QIcon, QPixmap, QColor, QPainter
10
11needDarkIcon = False
12
13def setNeedDarkIcon(color):
14 global needDarkIcon
15 needDarkIcon = True if color.value() > 100 else False
16 return
17
18def getThemedIcon(filepath) -> QIcon:
19 global needDarkIcon
20 pixmap = QPixmap(filepath)
21 painter = QPainter(pixmap)
22 painter.setCompositionMode(QPainter.CompositionMode.CompositionMode_SourceIn)
23
24 if needDarkIcon:
25 painter.fillRect(pixmap.rect(),QColor(32,32,32))
26 else:
27 painter.fillRect(pixmap.rect(),QColor(255,255,255))
28
29 painter.end()
30 return QIcon(pixmap)
setNeedDarkIcon(color)
Definition utils.py:13
QIcon getThemedIcon(filepath)
Definition utils.py:18