Skip to content

Commit

Permalink
AddonManager: Fixed macro copying and centre manager dialog over FC w…
Browse files Browse the repository at this point in the history
…indow
  • Loading branch information
yorikvanhavre committed Oct 1, 2018
1 parent 0e6f14e commit 1d3f3ab
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/Mod/AddonManager/AddonManager.py
Expand Up @@ -45,7 +45,7 @@
import tempfile

from PySide import QtCore, QtGui
import FreeCAD
import FreeCAD,FreeCADGui
if sys.version_info.major < 3:
import urllib2
else:
Expand Down Expand Up @@ -83,7 +83,7 @@ def translate(context, text, disambig=None):

def symlink(source, link_name):
if os.path.exists(link_name):
print("symlink already exists")
print("macro already exists")
else:
os_symlink = getattr(os, "symlink", None)
if callable(os_symlink):
Expand Down Expand Up @@ -209,6 +209,11 @@ def __init__(self):
else:
self.buttonCheck.show()

# center the dialog over the FreeCAD window
mw = FreeCADGui.getMainWindow()
self.move(mw.frameGeometry().topLeft() + mw.rect().center() - self.rect().center())


def reject(self):
# ensure all threads are finished before closing
oktoclose = True
Expand Down Expand Up @@ -974,17 +979,18 @@ def run(self):
self.info_label.emit("Downloading module...")
self.download(self.repos[idx][1],clonedir)
answer = translate("AddonsInstaller", "Workbench successfully installed. Please restart FreeCAD to apply the changes.")
# symlink any macro contained in the module to the macros folder
macro_dir = get_macro_dir()
if not os.path.exists(macro_dir):
os.makedirs(macro_dir)
for f in os.listdir(clonedir):
if f.lower().endswith(".fcmacro"):
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)
# symlink any macro contained in the module to the macros folder
macro_dir = get_macro_dir()
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>"
self.progressbar_show.emit(False)
self.info_label.emit(answer)
self.stop = True

Expand Down

0 comments on commit 1d3f3ab

Please sign in to comment.