Skip to content

Commit

Permalink
Use more license friendly and theme aware icons
Browse files Browse the repository at this point in the history
  • Loading branch information
chocolateimage committed Jan 27, 2025
1 parent 46ae4c8 commit 7bb2ba1
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 26 deletions.
35 changes: 15 additions & 20 deletions levelbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ def __init__(self, icon, text, onclick=None, tooltip=None):
super().__init__(" " + text) # " " is a lazy way to fix icon spacing
self.setFlat(True)

icon_darkmode = icon.replace(".svg", "") + "-darkmode.svg"
if utils.is_dark_mode() and os.path.exists(icon_darkmode):
self.setIcon(QtGui.QIcon(icon_darkmode))
else:
self.setIcon(QtGui.QIcon(icon))
self.setIcon(QtGui.QIcon(utils.get_icon_path(icon)))

self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
if tooltip != None:
Expand Down Expand Up @@ -125,16 +121,16 @@ def __init__(self, data, mw):
)
if self.data["min_bpm"] == self.data["max_bpm"]:
bpmtext = self.get_float_string(self.data["min_bpm"])
self.add_metadata("ui/heart-solid.svg", bpmtext + " BPM")
self.add_metadata("heart", bpmtext + " BPM")
if self.data["approval"] == -1:
self.add_metadata(
"ui/x.svg",
"x",
"Non-Referred",
tooltip="Non-Referred: a trusted member of the community has checked for correct\nBPM/offset, metadata, and cues to ensure playability, and has found that this level\ndoes not meet standards.",
)
elif self.data["approval"] >= 10:
self.add_metadata(
"ui/checkmark.svg",
"checkmark",
"Reviewed",
onclick=lambda: self.change_facet_approval(True),
tooltip="Peer-Reviewed: a trusted member of the community has checked for correct\nBPM/offset, metadata, and cues to ensure playability.",
Expand Down Expand Up @@ -216,7 +212,7 @@ def add_tag(self, text):

def add_author(self, author):
self.add_metadata(
"ui/user-solid.svg",
"user",
author,
onclick=lambda: self.change_facet_author(author),
)
Expand Down Expand Up @@ -256,25 +252,24 @@ def update_download_button_(self):
if self.is_installed():
self.lblInstalled.setVisible(True)
self.btnDownload.setToolTip("Uninstall")
if os.name == "nt":
self.btnDownload.setIcon(QtGui.QIcon("ui/trash-solid.svg"))
else:
if QtGui.QIcon.hasThemeIcon("user-trash-full-symbolic"):
self.btnDownload.setIcon(
QtGui.QIcon.fromTheme("user-trash-full-symbolic")
)
else:
self.btnDownload.setIcon(QtGui.QIcon(utils.get_icon_path("trash")))
self.bgcolor = "green"
else:
self.lblInstalled.setVisible(False)
self.btnDownload.setToolTip("Install")
if os.name == "nt":
self.btnDownload.setIcon(QtGui.QIcon("ui/download-solid.svg"))
if QtGui.QIcon.hasThemeIcon("download"):
self.btnDownload.setIcon(QtGui.QIcon.fromTheme("download"))
elif QtGui.QIcon.hasThemeIcon("folder-download-symbolic"):
self.btnDownload.setIcon(
QtGui.QIcon.fromTheme("folder-download-symbolic")
)
else:
if QtGui.QIcon.hasThemeIcon("download"):
self.btnDownload.setIcon(QtGui.QIcon.fromTheme("download"))
else:
self.btnDownload.setIcon(
QtGui.QIcon.fromTheme("folder-download-symbolic")
)
self.btnDownload.setIcon(QtGui.QIcon(utils.get_icon_path("download")))
self.bgcolor = None
self.repaint()

Expand Down
File renamed without changes
1 change: 1 addition & 0 deletions ui/checkmark-lightmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ui/download-darkmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ui/download-lightmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion ui/download-solid.svg

This file was deleted.

1 change: 1 addition & 0 deletions ui/heart-darkmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ui/heart-lightmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion ui/heart-solid-darkmode.svg

This file was deleted.

1 change: 0 additions & 1 deletion ui/heart-solid.svg

This file was deleted.

1 change: 1 addition & 0 deletions ui/trash-darkmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ui/trash-lightmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion ui/trash-solid.svg

This file was deleted.

1 change: 1 addition & 0 deletions ui/user-darkmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ui/user-lightmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion ui/user-solid-darkmode.svg

This file was deleted.

1 change: 0 additions & 1 deletion ui/user-solid.svg

This file was deleted.

File renamed without changes
9 changes: 9 additions & 0 deletions ui/x-lightmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,10 @@ def is_dark_mode():
background_color.red() + background_color.green() + background_color.blue()
) / 3
return brightness < 128


def get_icon_path(icon_name):
if is_dark_mode():
return "ui/" + icon_name + "-darkmode.svg"
else:
return "ui/" + icon_name + "-lightmode.svg"

0 comments on commit 7bb2ba1

Please sign in to comment.