aports/testing/mnemosyne/fix-loading-icons.patch
2023-05-25 21:50:01 +02:00

76 lines
3.7 KiB
Diff

Patch-Source: https://github.com/mnemosyne-proj/mnemosyne/commit/3c596c439feb7b3ed449100000de20dc87a35b6f
also manually patched for pixmaps dir
--
From 3c596c439feb7b3ed449100000de20dc87a35b6f Mon Sep 17 00:00:00 2001
From: Vlad <itraveller@mail.ru>
Date: Sun, 26 Feb 2023 21:21:58 +0300
Subject: [PATCH] Fix a bug causing the app to not find its icons.
The reason for the problem is that the icon paths were not tied to the script, but to the current working directory.
Fix #234
---
mnemosyne/pyqt_ui/about_dlg.py | 2 +-
mnemosyne/pyqt_ui/getting_started_dlg.py | 2 +-
mnemosyne/pyqt_ui/main_wdgt.ui | 24 ++++++++++++------------
mnemosyne/pyqt_ui/mnemosyne | 7 ++-----
mnemosyne/pyqt_ui/tip_dlg.py | 2 +-
5 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/mnemosyne/pyqt_ui/about_dlg.py b/mnemosyne/pyqt_ui/about_dlg.py
index 0d5926db..3b6a78eb 100755
--- a/mnemosyne/pyqt_ui/about_dlg.py
+++ b/mnemosyne/pyqt_ui/about_dlg.py
@@ -22,7 +22,7 @@ def __init__(self, **kwds):
# Note: the svg file does not seem to work under windows.
#watermark = QtGui.QPixmap("pixmaps/mnemosyne.svg").\
# scaledToHeight(200, QtCore.Qt.TransformationMode.SmoothTransformation)
- watermark = QtGui.QPixmap("pixmaps/mnemosyne.png")
+ watermark = QtGui.QPixmap("icons:mnemosyne.png")
self.watermark.setPixmap(watermark)
self.about_label.setText("<b>" + _("Mnemosyne") + " " + version + "</b><br><br>" + \
_("Main author: Peter Bienstman") + "<br><br>" + \
diff --git a/mnemosyne/pyqt_ui/getting_started_dlg.py b/mnemosyne/pyqt_ui/getting_started_dlg.py
index f125fb66..69edae43 100755
--- a/mnemosyne/pyqt_ui/getting_started_dlg.py
+++ b/mnemosyne/pyqt_ui/getting_started_dlg.py
@@ -20,7 +20,7 @@ def __init__(self, **kwds):
# Note: the svg file does not seem to work under windows.
#watermark = QtGui.QPixmap("pixmaps/mnemosyne.svg")\
# .scaledToHeight(200, QtCore.Qt.TransformationMode.SmoothTransformation)
- watermark = QtGui.QPixmap("pixmaps/mnemosyne.png")
+ watermark = QtGui.QPixmap("icons:mnemosyne.png")
self.setPixmap(QtWidgets.QWizard.WizardPixmap.WatermarkPixmap, watermark)
def activate(self):
diff --git a/mnemosyne/pyqt_ui/mnemosyne b/mnemosyne/pyqt_ui/mnemosyne
index 73660586..603cd457 100755
--- a/mnemosyne/pyqt_ui/mnemosyne
+++ b/mnemosyne/pyqt_ui/mnemosyne
@@ -203,11 +203,8 @@ font-size: 12px;
}"""
a.setStyleSheet(stylesheet)
-# FIXME: install in the system Python does not really work unless
-# you copy 'pixmaps' to 'C:\Program Files\Python311'
-# The statement below don't help.
-QtGui.QIcon.setFallbackSearchPaths(["C:/Program Files (x86)/Mnemosyne",
-"C:/Program Files/Python311/Lib/site-packages/Mnemosyne-2.10-py3.11.egg"])
+pixmaps_dir = '/usr/share/mnemosyne/pixmaps'
+QtCore.QDir.addSearchPath('icons', pixmaps_dir)
# Add other components we need. The translator should come first.
# The UI components should come in the order they should be instantiated,
diff --git a/mnemosyne/pyqt_ui/tip_dlg.py b/mnemosyne/pyqt_ui/tip_dlg.py
index ae12c25d..9eb891a5 100755
--- a/mnemosyne/pyqt_ui/tip_dlg.py
+++ b/mnemosyne/pyqt_ui/tip_dlg.py
@@ -71,7 +71,7 @@ def __init__(self, **kwds):
# Note: the svg file does not seem to work under windows.
#watermark = QtGui.QPixmap("pixmaps/mnemosyne.svg").\
# scaledToHeight(200, QtCore.Qt.TransformationMode.SmoothTransformation)
- watermark = QtGui.QPixmap("pixmaps/mnemosyne.png")
+ watermark = QtGui.QPixmap("icons:mnemosyne.png")
self.watermark.setPixmap(watermark)
self.update_dialog()