AddonManager: Misc fixes from forum testers

This commit is contained in:
Yorik van Havre
2019-06-15 17:53:36 -03:00
parent 0620caea33
commit caef4b6c68
3 changed files with 22 additions and 7 deletions

View File

@@ -400,15 +400,13 @@ class CommandAddonManager:
"shows or hides the progress bar"
if state == True:
self.dialog.listWorkbenches.setEnabled(False)
self.dialog.listMacros.setEnabled(False)
self.dialog.tabWidget.setEnabled(False)
self.dialog.buttonInstall.setEnabled(False)
self.dialog.buttonUninstall.setEnabled(False)
self.dialog.progressBar.show()
else:
self.dialog.progressBar.hide()
self.dialog.listWorkbenches.setEnabled(True)
self.dialog.listMacros.setEnabled(True)
self.dialog.tabWidget.setEnabled(True)
if not (self.firsttime and self.firstmacro):
self.dialog.buttonInstall.setEnabled(True)
self.dialog.buttonUninstall.setEnabled(True)

View File

@@ -97,6 +97,17 @@ def urlopen(url):
return u
def getserver(url):
"""returns the server part of an url"""
if sys.version_info.major < 3:
from urlparse import urlparse
else:
from urllib.parse import urlparse
return '{uri.scheme}://{uri.netloc}/'.format(uri=urlparse(url))
def update_macro_details(old_macro, new_macro):
"""Update a macro with information from another one

View File

@@ -35,6 +35,7 @@ from addonmanager_macro import Macro
from addonmanager_utilities import urlopen
from addonmanager_utilities import translate
from addonmanager_utilities import symlink
from addonmanager_utilities import getserver
MACROS_BLACKLIST = ["BOLTS","WorkFeatures","how to install","PartsLibrary","FCGear"]
OBSOLETE = ["assembly2","drawing_dimensioning","cura_engine"] # These addons will print an additional message informing the user
@@ -382,12 +383,12 @@ class ShowWorker(QtCore.QThread):
self.info_label.emit( message )
self.progressbar_show.emit(False)
l = self.loadImages( message )
l = self.loadImages( message, url )
if l:
self.info_label.emit( l )
self.stop = True
def loadImages(self,message):
def loadImages(self,message,url):
"checks if the given page contains images and downloads them"
@@ -402,6 +403,11 @@ class ShowWorker(QtCore.QThread):
if not os.path.exists(store):
os.makedirs(store)
for path in imagepaths:
if "?" in path:
# remove everything after the ?
path = path.split("?")[0]
if not path.startswith("http"):
path = getserver(url) + path
name = path.split("/")[-1]
if name and path.startswith("http"):
storename = os.path.join(store,name)
@@ -426,7 +432,7 @@ class ShowWorker(QtCore.QThread):
pix = pix.fromImage(img.scaled(300,300,QtCore.Qt.KeepAspectRatio,QtCore.Qt.FastTransformation))
pix.save(storename, "jpeg",100)
message = message.replace(path,"file://"+storename.replace("\\","/"))
message = message.replace(path,"file:///"+storename.replace("\\","/"))
return message
return None