AddonManager: Don't overwrite displayed text after a module install/removal
This commit is contained in:
@@ -389,7 +389,7 @@ class AddonsInstaller(QtGui.QDialog):
|
||||
if macro.is_installed():
|
||||
self.listMacros.addItem(QtGui.QListWidgetItem(QtGui.QIcon.fromTheme('dialog-ok'), macro.name + str(' (Installed)')))
|
||||
else:
|
||||
self.listMacros.addItem(macro.name)
|
||||
self.listMacros.addItem(" "+macro.name)
|
||||
|
||||
def showlink(self,link):
|
||||
"""opens a link with the system browser"""
|
||||
@@ -423,7 +423,7 @@ class AddonsInstaller(QtGui.QDialog):
|
||||
self.labelDescription.setText(translate("AddonsInstaller", "Macro successfully installed. The macro is now available from the Macros dialog."))
|
||||
else:
|
||||
self.labelDescription.setText(translate("AddonsInstaller", "Unable to install"))
|
||||
self.update_status()
|
||||
self.update_status(soft=True)
|
||||
|
||||
def show_progress_bar(self, state):
|
||||
if state == True:
|
||||
@@ -490,24 +490,53 @@ class AddonsInstaller(QtGui.QDialog):
|
||||
self.labelDescription.setText(translate('AddonsInstaller', 'Macro successfully removed.'))
|
||||
else:
|
||||
self.labelDescription.setText(translate('AddonsInstaller', 'Macro could not be removed.'))
|
||||
self.update_status()
|
||||
self.update_status(soft=True)
|
||||
|
||||
def update_status(self,soft=False):
|
||||
|
||||
"Updates the list of wbs/macros. If soft is true, items are not recreated (and therefore display text no triggered)"
|
||||
|
||||
def update_status(self):
|
||||
self.listWorkbenches.clear()
|
||||
self.listMacros.clear()
|
||||
moddir = FreeCAD.getUserAppDataDir() + os.sep + "Mod"
|
||||
for wb in self.repos:
|
||||
if os.path.exists(os.path.join(moddir,wb[0])):
|
||||
self.listWorkbenches.addItem(QtGui.QListWidgetItem(QtGui.QIcon.fromTheme("dialog-ok"),str(wb[0]) + str(" (Installed)")))
|
||||
wb[2] = 1
|
||||
else:
|
||||
self.listWorkbenches.addItem(" "+str(wb[0]))
|
||||
wb[2] = 0
|
||||
for macro in self.macros:
|
||||
if macro.is_installed():
|
||||
self.listMacros.addItem(QtGui.QListWidgetItem(QtGui.QIcon.fromTheme('dialog-ok'), macro.name + str(' (Installed)')))
|
||||
else:
|
||||
self.listMacros.addItem(macro.name)
|
||||
if soft:
|
||||
for i in range(self.listWorkbenches.count()):
|
||||
txt = self.listWorkbenches.item(i).text().strip()
|
||||
if txt.endswith(" (Installed)"):
|
||||
txt = txt[:-12]
|
||||
elif txt.endswith(" (Update available)"):
|
||||
txt = txt[:-19]
|
||||
if os.path.exists(os.path.join(moddir,txt)):
|
||||
self.listWorkbenches.item(i).setText(txt+" (Installed)")
|
||||
self.listWorkbenches.item(i).setIcon(QtGui.QIcon.fromTheme("dialog-ok"))
|
||||
else:
|
||||
self.listWorkbenches.item(i).setText(" "+txt)
|
||||
self.listWorkbenches.item(i).setIcon(QtGui.QIcon())
|
||||
for i in range(self.listMacros.count()):
|
||||
txt = self.listMacros.item(i).text().strip()
|
||||
if txt.endswith(" (Installed)"):
|
||||
txt = txt[:-12]
|
||||
elif txt.endswith(" (Update available)"):
|
||||
txt = txt[:-19]
|
||||
if os.path.exists(os.path.join(moddir,txt)):
|
||||
self.listMacros.item(i).setText(txt+" (Installed)")
|
||||
self.listMacros.item(i).setIcon(QtGui.QIcon.fromTheme("dialog-ok"))
|
||||
else:
|
||||
self.listMacros.item(i).setText(" "+txt)
|
||||
self.listMacros.item(i).setIcon(QtGui.QIcon())
|
||||
else:
|
||||
self.listWorkbenches.clear()
|
||||
self.listMacros.clear()
|
||||
for wb in self.repos:
|
||||
if os.path.exists(os.path.join(moddir,wb[0])):
|
||||
self.listWorkbenches.addItem(QtGui.QListWidgetItem(QtGui.QIcon.fromTheme("dialog-ok"),str(wb[0]) + str(" (Installed)")))
|
||||
wb[2] = 1
|
||||
else:
|
||||
self.listWorkbenches.addItem(" "+str(wb[0]))
|
||||
wb[2] = 0
|
||||
for macro in self.macros:
|
||||
if macro.is_installed():
|
||||
self.listMacros.addItem(QtGui.QListWidgetItem(QtGui.QIcon.fromTheme('dialog-ok'), macro.name + str(' (Installed)')))
|
||||
else:
|
||||
self.listMacros.addItem(" "+macro.name)
|
||||
|
||||
def mark(self,repo):
|
||||
for i in range(self.listWorkbenches.count()):
|
||||
@@ -918,13 +947,14 @@ class InstallWorker(QtCore.QThread):
|
||||
macro_dir = FreeCAD.getUserMacroDir(True)
|
||||
if not os.path.exists(macro_dir):
|
||||
os.makedirs(macro_dir)
|
||||
for f in os.listdir(clonedir):
|
||||
if f.lower().endswith(".fcmacro"):
|
||||
print("copying macro:",f)
|
||||
symlink(os.path.join(clonedir, f), os.path.join(macro_dir, f))
|
||||
FreeCAD.ParamGet('User parameter:Plugins/'+self.repos[idx][0]).SetString("destination",clonedir)
|
||||
answer += translate("AddonsInstaller", "A macro has been installed and is available the Macros menu") + ": <b>"
|
||||
answer += f + "</b>"
|
||||
if os.path.exists(clonedir):
|
||||
for f in os.listdir(clonedir):
|
||||
if f.lower().endswith(".fcmacro"):
|
||||
print("copying macro:",f)
|
||||
symlink(os.path.join(clonedir, f), os.path.join(macro_dir, f))
|
||||
FreeCAD.ParamGet('User parameter:Plugins/'+self.repos[idx][0]).SetString("destination",clonedir)
|
||||
answer += translate("AddonsInstaller", "A macro has been installed and is available the Macros menu") + ": <b>"
|
||||
answer += f + "</b>"
|
||||
self.progressbar_show.emit(False)
|
||||
self.info_label.emit(answer)
|
||||
self.stop = True
|
||||
|
||||
Reference in New Issue
Block a user