forked from BlueQuartzSoftware/MetaForge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrashdelegate.py
More file actions
48 lines (38 loc) · 1.67 KB
/
trashdelegate.py
File metadata and controls
48 lines (38 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# This Python file uses the following encoding: utf-8
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
import PySide2.QtCore
qt_version = PySide2.QtCore.__version_info__
if qt_version[1] == 12:
from generated_5_12.resources_rc import *
elif qt_version[1] == 15:
from generated_5_15.resources_rc import *
from metaforgestyledatahelper import MetaForgeStyleDataHelper
class TrashDelegate(QItemDelegate):
pressed = Signal(QModelIndex)
def __init__(self, parent=None, stylehelper: MetaForgeStyleDataHelper=None):
QItemDelegate.__init__(self, parent)
self.style_helper = stylehelper
def createEditor(self, parent, option, index):
source_index = index.model().mapToSource(index)
if source_index.isValid():
self.pressed.emit(source_index)
def paint(self, painter, option, index):
super().paint(painter, option, index)
if self.style_helper == None:
icon = QIcon(QPixmap(':/resources/Images/close-pushed@2x.png'))
elif self.style_helper.css_file_path == "resources/StyleSheets/light.css":
icon = QIcon(QPixmap(':/resources/Images/close-pushed@2x.png'))
elif self.style_helper.css_file_path == "resources/StyleSheets/dark.css":
icon = QIcon(QPixmap(':/resources/Images/dark/close-pushed@2x.png'))
else:
icon = QIcon(QPixmap(':/resources/Images/close-pushed@2x.png'))
painter.save()
line_1x = icon.pixmap(16,16)
painter.drawPixmap(option.rect.x()+option.rect.width()/2 - 8 ,
option.rect.y()+option.rect.height()/2 - 8,
16,
16,
line_1x)
painter.restore()