49
49
from addonmanager_update_all_gui import UpdateAllGUI
50
50
import addonmanager_utilities as utils
51
51
import addonmanager_freecad_interface as fci
52
- import AddonManager_rc # pylint: disable=unused-import
53
52
from composite_view import CompositeView
54
53
from Widgets .addonmanager_widget_global_buttons import WidgetGlobalButtonBar
55
54
from Widgets .addonmanager_widget_progress_bar import Progress
@@ -105,22 +104,22 @@ def get_icon(repo: Addon, update: bool = False) -> QtGui.QIcon:
105
104
"""Returns an icon for an Addon. Uses a cached icon if possible, unless update is True,
106
105
in which case the icon is regenerated."""
107
106
107
+ icon_path = os .path .join (os .path .dirname (__file__ ), "Resources" , "icons" )
108
+ path = ""
109
+
108
110
if not update and repo .icon and not repo .icon .isNull () and repo .icon .isValid ():
109
111
return repo .icon
110
112
111
- path = ":/icons/" + repo .name .replace (" " , "_" )
112
- default_icon = QtGui .QIcon (":/icons/document-package.svg" )
113
+ default_icon = QtGui .QIcon (os .path .join (icon_path , "document-package.svg" ))
113
114
if repo .repo_type == Addon .Kind .WORKBENCH :
114
- path += "_workbench_icon.svg"
115
- default_icon = QtGui .QIcon (":/icons/document-package.svg" )
115
+ default_icon = QtGui .QIcon (os .path .join (icon_path , "document-package.svg" ))
116
116
elif repo .repo_type == Addon .Kind .MACRO :
117
117
if repo .macro and repo .macro .icon :
118
+ default_icon = QtGui .QIcon (os .path .join (icon_path , "document-python.svg" ))
118
119
if os .path .isabs (repo .macro .icon ):
119
120
path = repo .macro .icon
120
- default_icon = QtGui .QIcon (":/icons/document-python.svg" )
121
121
else :
122
122
path = os .path .join (os .path .dirname (repo .macro .src_filename ), repo .macro .icon )
123
- default_icon = QtGui .QIcon (":/icons/document-python.svg" )
124
123
elif repo .macro and repo .macro .xpm :
125
124
cache_path = fci .DataPaths ().cache_dir
126
125
am_path = os .path .join (cache_path , "AddonManager" , "MacroIcons" )
@@ -131,20 +130,17 @@ def get_icon(repo: Addon, update: bool = False) -> QtGui.QIcon:
131
130
f .write (repo .macro .xpm )
132
131
default_icon = QtGui .QIcon (repo .macro .xpm )
133
132
else :
134
- path += "_macro_icon.svg"
135
- default_icon = QtGui .QIcon (":/icons/document-python.svg" )
133
+ default_icon = QtGui .QIcon (os .path .join (icon_path , "document-python.svg" ))
136
134
elif repo .repo_type == Addon .Kind .PACKAGE :
137
135
# The cache might not have been downloaded yet, check to see if it's there...
138
136
if os .path .isfile (repo .get_cached_icon_filename ()):
139
137
path = repo .get_cached_icon_filename ()
140
138
elif repo .contains_workbench ():
141
- path += "_workbench_icon.svg"
142
- default_icon = QtGui .QIcon (":/icons/document-package.svg" )
139
+ default_icon = QtGui .QIcon (os .path .join (icon_path , "document-package.svg" ))
143
140
elif repo .contains_macro ():
144
- path += "_macro_icon.svg"
145
- default_icon = QtGui .QIcon (":/icons/document-python.svg" )
141
+ default_icon = QtGui .QIcon (os .path .join (icon_path , "document-python.svg" ))
146
142
else :
147
- default_icon = QtGui .QIcon (":/icons/ document-package.svg" )
143
+ default_icon = QtGui .QIcon (os . path . join ( icon_path , " document-package.svg") )
148
144
149
145
if QtCore .QFile .exists (path ):
150
146
addon_icon = QtGui .QIcon (path )
@@ -279,7 +275,8 @@ def launch(self) -> None:
279
275
self .dialog .layout ().addWidget (self .button_bar )
280
276
281
277
# set nice icons to everything, by theme with fallback to FreeCAD icons
282
- self .dialog .setWindowIcon (QtGui .QIcon (":/icons/AddonManager.svg" ))
278
+ icon_path = os .path .join (os .path .dirname (__file__ ), "Resources" , "icons" )
279
+ self .dialog .setWindowIcon (QtGui .QIcon (os .path .join (icon_path , "addon_manager.svg" )))
283
280
284
281
dev_mode_active = fci .Preferences ().get ("developerMode" )
285
282
@@ -406,7 +403,8 @@ def reject(self) -> None:
406
403
# display restart dialog
407
404
m = QtWidgets .QMessageBox ()
408
405
m .setWindowTitle (translate ("AddonsInstaller" , "Addon manager" ))
409
- m .setWindowIcon (QtGui .QIcon (":/icons/AddonManager.svg" ))
406
+ icon_path = os .path .join (os .path .dirname (__file__ ), "Resources" , "icons" )
407
+ m .setWindowIcon (QtGui .QIcon (os .path .join (icon_path , "addon_manager.svg" )))
410
408
m .setText (
411
409
translate (
412
410
"AddonsInstaller" ,
0 commit comments