Skip to content

Commit

Permalink
Begin dealing with .desktop fiels
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
probonopd committed Feb 15, 2025
1 parent f98da3c commit dc7ca59
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions siracusa.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,17 @@ def paint(self, painter: QtGui.QPainter, option: QtWidgets.QStyleOptionGraphicsI
text_rect = QtCore.QRectF(text_x, text_y - text_height, text_width, text_height)
painter.drawRect(text_rect)

# If the item extension is ".desktop", we read each line, find the line that starts with Icon=, and extract the icon name.
if os.path.splitext(self.file_path)[1].lower() == ".desktop":
with open(self.file_path, "r") as f:
for line in f:
if line.startswith("Icon="):
icon_name = line[5:].strip()
if icon_name:
self.icon = QtGui.QIcon.fromTheme(icon_name)
self.pixmap = self.icon.pixmap(QtCore.QSize(32, 32))
break

# Draw the icon
painter.drawPixmap(QtCore.QPointF(offset_x, offset_y), self.pixmap)

Expand Down

0 comments on commit dc7ca59

Please sign in to comment.