Skip to content

Commit

Permalink
Merge branch 'master' into pathpocketshape_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Russ4262 committed Jun 16, 2019
2 parents 3e126bc + 6259e1e commit 0215998
Show file tree
Hide file tree
Showing 14 changed files with 288 additions and 24 deletions.
26 changes: 16 additions & 10 deletions src/Mod/AddonManager/AddonManager.py
Expand Up @@ -258,10 +258,16 @@ def add_addon_repo(self, addon_repo):

from PySide import QtGui
self.repos.append(addon_repo)
if addon_repo[2] == 1 :
self.dialog.listWorkbenches.addItem(QtGui.QListWidgetItem(QtGui.QIcon(":/icons/button_valid.svg"),str(addon_repo[0]) + str(" ("+translate("AddonsInstaller","Installed")+")")))
import AddonManager_rc
addonicon = QtGui.QIcon(":/icons/" + addon_repo[0] + "_workbench_icon.svg")
if addonicon.isNull():
addonicon = QtGui.QIcon(":/icons/Group.svg")
if addon_repo[2] == 1:
item = QtGui.QListWidgetItem(addonicon,str(addon_repo[0]) + str(" ("+translate("AddonsInstaller","Installed")+")"))
item.setBackground(QtGui.QBrush(QtGui.QColor(0,182,41)))
self.dialog.listWorkbenches.addItem(item)
else:
self.dialog.listWorkbenches.addItem(QtGui.QListWidgetItem(QtGui.QIcon(":/icons/Group.svg"),str(addon_repo[0])))
self.dialog.listWorkbenches.addItem(QtGui.QListWidgetItem(addonicon,str(addon_repo[0])))

def show_information(self, label):

Expand Down Expand Up @@ -358,7 +364,9 @@ def add_macro(self, macro):
from PySide import QtGui
self.macros.append(macro)
if macro.is_installed():
self.dialog.listMacros.addItem(QtGui.QListWidgetItem(QtGui.QIcon(":/icons/button_valid.svg"), macro.name + str(' (Installed)')))
item = QtGui.QListWidgetItem(QtGui.QIcon(":/icons/applications-python.svg"), macro.name + str(' (Installed)'))
item.setBackground(QtGui.QBrush(QtGui.QColor(0,182,41)))
self.dialog.listMacros.addItem(item)
else:
self.dialog.listMacros.addItem(QtGui.QListWidgetItem(QtGui.QIcon(":/icons/applications-python.svg"),macro.name))

Expand Down Expand Up @@ -400,15 +408,13 @@ def show_progress_bar(self, state):
"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)
Expand Down Expand Up @@ -535,7 +541,7 @@ def update_status(self,soft=False):
wb[2] = 0
for macro in self.macros:
if macro.is_installed():
self.dialog.listMacros.addItem(QtGui.QListWidgetItem(QtGui.QIcon(":/icons/button_valid.svg"), macro.name + " ("+translate("AddonsInstaller","Installed")+")"))
self.dialog.listMacros.addItem(item)
else:
self.dialog.listMacros.addItem(QtGui.QListWidgetItem(QtGui.QIcon(":/icons/applications-python.svg"),+macro.name))

Expand All @@ -548,7 +554,7 @@ def mark(self,repo):
w = self.dialog.listWorkbenches.item(i)
if w.text().startswith(str(repo)):
w.setText(str(repo) + str(" ("+translate("AddonsInstaller","Update available")+")"))
w.setIcon(QtGui.QIcon(":/icons/debug-marker.svg"))
w.setBackground(QtGui.QBrush(QtGui.QColor(182,90,0)))
if not repo in self.doUpdate:
self.doUpdate.append(repo)

Expand Down
16 changes: 15 additions & 1 deletion src/Mod/AddonManager/CMakeLists.txt
@@ -1,3 +1,7 @@
IF (BUILD_GUI)
PYSIDE_WRAP_RC(AddonManager_QRC_SRCS Resources/AddonManager.qrc)
ENDIF (BUILD_GUI)

SET(AddonManager_SRCS
Init.py
InitGui.py
Expand All @@ -12,14 +16,24 @@ SET(AddonManager_SRCS
SOURCE_GROUP("" FILES ${AddonManager_SRCS})

ADD_CUSTOM_TARGET(AddonManager ALL
SOURCES ${AddonManager_SRCS}
SOURCES ${AddonManager_SRCS} ${AddonManager_QRC_SRCS}
)

fc_copy_sources(AddonManager "${CMAKE_BINARY_DIR}/Mod/AddonManager" ${AddonManager_SRCS})

IF (BUILD_GUI)
fc_target_copy_resource(AddonManager
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR}/Mod/AddonManager
AddonManager_rc.py)
ENDIF (BUILD_GUI)

INSTALL(
FILES
${AddonManager_SRCS}
${AddonManager_QRC_SRCS}
DESTINATION
Mod/AddonManager
)


31 changes: 31 additions & 0 deletions src/Mod/AddonManager/Resources/AddonManager.qrc
@@ -0,0 +1,31 @@
<RCC>
<qresource>
<file>icons/A2plus_workbench-icon.svg</file>
<file>icons/Airplane_workbench-icon.svg</file>
<file>icons/Arch_Textures_workbench_icon.svg</file>
<file>icons/BIM_workbench_icon.svg</file>
<file>icons/BOLTS_workbench_icon.svg</file>
<file>icons/cfd_workbench_icon.svg</file>
<file>icons/Curves_workbench_icon.svg</file>
<file>icons/Defeaturing_workbench_icon.svg</file>
<file>icons/Dodo_workbench_icon.svg</file>
<file>icons/EM_workbench_icon.svg</file>
<file>icons/ExplodedAssembly_workbench_icon.svg</file>
<file>icons/Fasteners_workbench_icon.svg</file>
<file>icons/Flamingo_workbench_icon.svg</file>
<file>icons/GDT_workbench_icon.svg</file>
<file>icons/Gears_workbench_icon.svg</file>
<file>icons/Glider_workbench_icon.svg</file>
<file>icons/Kicad-StepUp-tools-workbench_icon.svg</file>
<file>icons/Lattice2_workbench_icon.svg</file>
<file>icons/Lithophane_workbench_icon.svg</file>
<file>icons/Manipulator_workbench_icon.svg</file>
<file>icons/PartOMagic_workbench_icon.svg</file>
<file>icons/Plot_workbench_icon.svg</file>
<file>icons/Pyrate_workbench_icon.svg</file>
<file>icons/Reporting_workbench_icon.svg</file>
<file>icons/SheetMetal_workbench_icon.svg</file>
<file>icons/Ship_workbench_icon.svg</file>
<file>icons/Timber_workbench_icon.svg</file>
</qresource>
</RCC>
11 changes: 11 additions & 0 deletions src/Mod/AddonManager/addonmanager_utilities.py
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions src/Mod/AddonManager/addonmanager_workers.py
Expand Up @@ -35,6 +35,7 @@
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
Expand Down Expand Up @@ -382,12 +383,12 @@ def run(self):

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"

Expand All @@ -402,6 +403,11 @@ def loadImages(self,message):
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)
Expand All @@ -426,7 +432,7 @@ def loadImages(self,message):
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

Expand Down Expand Up @@ -547,7 +553,7 @@ def run(self):
try:
answer = repo.pull()
except:
print("Error updating module",repos[idx][1]," - Please fix manually")
print("Error updating module",self.repos[idx][1]," - Please fix manually")
answer = repo.status()
print(answer)
else:
Expand Down

0 comments on commit 0215998

Please sign in to comment.