Skip to content

Commit f56acf4

Browse files
committed
Eliminate use of Qt resource system
The binary format changes between minor releases of Qt, so cannot be used in an Addon
1 parent d58b366 commit f56acf4

File tree

97 files changed

+2001
-223138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2001
-223138
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# SPDX License ID: LGPL-2.1
22
.idea
33
__pycache*
4+
.DS_Store

AddonManager.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
from addonmanager_update_all_gui import UpdateAllGUI
5050
import addonmanager_utilities as utils
5151
import addonmanager_freecad_interface as fci
52-
import AddonManager_rc # pylint: disable=unused-import
5352
from composite_view import CompositeView
5453
from Widgets.addonmanager_widget_global_buttons import WidgetGlobalButtonBar
5554
from Widgets.addonmanager_widget_progress_bar import Progress
@@ -105,22 +104,22 @@ def get_icon(repo: Addon, update: bool = False) -> QtGui.QIcon:
105104
"""Returns an icon for an Addon. Uses a cached icon if possible, unless update is True,
106105
in which case the icon is regenerated."""
107106

107+
icon_path = os.path.join(os.path.dirname(__file__), "Resources", "icons")
108+
path = ""
109+
108110
if not update and repo.icon and not repo.icon.isNull() and repo.icon.isValid():
109111
return repo.icon
110112

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"))
113114
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"))
116116
elif repo.repo_type == Addon.Kind.MACRO:
117117
if repo.macro and repo.macro.icon:
118+
default_icon = QtGui.QIcon(os.path.join(icon_path, "document-python.svg"))
118119
if os.path.isabs(repo.macro.icon):
119120
path = repo.macro.icon
120-
default_icon = QtGui.QIcon(":/icons/document-python.svg")
121121
else:
122122
path = os.path.join(os.path.dirname(repo.macro.src_filename), repo.macro.icon)
123-
default_icon = QtGui.QIcon(":/icons/document-python.svg")
124123
elif repo.macro and repo.macro.xpm:
125124
cache_path = fci.DataPaths().cache_dir
126125
am_path = os.path.join(cache_path, "AddonManager", "MacroIcons")
@@ -131,20 +130,17 @@ def get_icon(repo: Addon, update: bool = False) -> QtGui.QIcon:
131130
f.write(repo.macro.xpm)
132131
default_icon = QtGui.QIcon(repo.macro.xpm)
133132
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"))
136134
elif repo.repo_type == Addon.Kind.PACKAGE:
137135
# The cache might not have been downloaded yet, check to see if it's there...
138136
if os.path.isfile(repo.get_cached_icon_filename()):
139137
path = repo.get_cached_icon_filename()
140138
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"))
143140
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"))
146142
else:
147-
default_icon = QtGui.QIcon(":/icons/document-package.svg")
143+
default_icon = QtGui.QIcon(os.path.join(icon_path, "document-package.svg"))
148144

149145
if QtCore.QFile.exists(path):
150146
addon_icon = QtGui.QIcon(path)
@@ -279,7 +275,8 @@ def launch(self) -> None:
279275
self.dialog.layout().addWidget(self.button_bar)
280276

281277
# 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")))
283280

284281
dev_mode_active = fci.Preferences().get("developerMode")
285282

@@ -406,7 +403,8 @@ def reject(self) -> None:
406403
# display restart dialog
407404
m = QtWidgets.QMessageBox()
408405
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")))
410408
m.setText(
411409
translate(
412410
"AddonsInstaller",

AddonManagerOptions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ def __init__(self, _=None):
4242
self.form = fci.loadUi(os.path.join(os.path.dirname(__file__), "AddonManagerOptions.ui"))
4343
self.table_model = CustomRepoDataModel()
4444
self.form.customRepositoriesTableView.setModel(self.table_model)
45-
45+
icon_path = os.path.join(os.path.dirname(__file__), "Resources", "icons")
4646
self.form.addCustomRepositoryButton.setIcon(
47-
QtGui.QIcon.fromTheme("add", QtGui.QIcon(":/icons/list-add.svg"))
47+
QtGui.QIcon.fromTheme("add", QtGui.QIcon(os.path.join(icon_path, "list-add.svg")))
4848
)
4949
self.form.removeCustomRepositoryButton.setIcon(
50-
QtGui.QIcon.fromTheme("remove", QtGui.QIcon(":/icons/list-remove.svg"))
50+
QtGui.QIcon.fromTheme("remove", QtGui.QIcon(os.path.join(icon_path, "list-remove.svg")))
5151
)
5252

5353
self.form.customRepositoriesTableView.horizontalHeader().setStretchLastSection(False)

0 commit comments

Comments
 (0)