Add utility func for setting window icon

This commit is contained in:
RumovZ 2021-10-17 17:56:40 +02:00
parent f0d7e6f4d1
commit 7eec241c82
3 changed files with 10 additions and 9 deletions

View File

@ -14,6 +14,7 @@ from aqt.utils import (
qconnect,
restoreGeom,
saveGeom,
setWindowIcon,
tr,
)
from aqt.webview import AnkiWebView
@ -47,9 +48,7 @@ class CardInfoDialog(QDialog):
disable_help_button(self)
restoreGeom(self, self.GEOMETRY_KEY)
addCloseShortcut(self)
icon = QIcon()
icon.addPixmap(QPixmap("icons:anki.png"), QIcon.Mode.Normal, QIcon.State.Off)
self.setWindowIcon(icon)
setWindowIcon(self)
self.web = AnkiWebView(title=self.TITLE)
self.web.setVisible(False)

View File

@ -17,9 +17,7 @@ from aqt.qt import (
QCheckBox,
QDialog,
QDialogButtonBox,
QIcon,
QKeySequence,
QPixmap,
QShortcut,
Qt,
QTimer,
@ -30,7 +28,7 @@ from aqt.qt import (
from aqt.reviewer import replay_audio
from aqt.sound import av_player, play_clicked_audio
from aqt.theme import theme_manager
from aqt.utils import disable_help_button, restoreGeom, saveGeom, tr
from aqt.utils import disable_help_button, restoreGeom, saveGeom, setWindowIcon, tr
from aqt.webview import AnkiWebView
LastStateAndMod = tuple[str, int, int]
@ -52,10 +50,8 @@ class Previewer(QDialog):
self._parent = parent
self._close_callback = on_close
self.mw = mw
icon = QIcon()
icon.addPixmap(QPixmap("icons:anki.png"), QIcon.Mode.Normal, QIcon.State.Off)
disable_help_button(self)
self.setWindowIcon(icon)
setWindowIcon(self)
def card(self) -> Card | None:
raise NotImplementedError

View File

@ -406,6 +406,12 @@ def disable_help_button(widget: QWidget) -> None:
)
def setWindowIcon(widget: QWidget) -> None:
icon = QIcon()
icon.addPixmap(QPixmap("icons:anki.png"), QIcon.Mode.Normal, QIcon.State.Off)
widget.setWindowIcon(icon)
# File handling
######################################################################