Skip to content

Commit

Permalink
qtdragon/hd/lathe -fix setup page image display
Browse files Browse the repository at this point in the history
webengine needs the path location of the image
  • Loading branch information
c-morley committed Dec 1, 2024
1 parent 7aeb79d commit 1ed894e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
14 changes: 9 additions & 5 deletions share/qtvcp/screens/qtdragon/qtdragon_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

class HandlerClass:
def __init__(self, halcomp, widgets, paths):
self.p = paths
self.h = halcomp
self.w = widgets
self.gcodes = GCodes(widgets)
Expand Down Expand Up @@ -145,6 +146,9 @@ def __init__(self, halcomp, widgets, paths):
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
STATUS.connect('status-message', lambda w, d, o: self.add_external_status(d,o))

self.swoopPath = os.path.join(paths.IMAGEDIR,'lcnc_swoop.png')
self.swoopURL = QtCore.QUrl.fromLocalFile(self.swoopPath)

txt1 = _translate("HandlerClass","Setup Tab")
txt2 = _translate("HandlerClass","If you select a file with .html as a file ending, it will be shown here.")
txt3 = _translate("HandlerClass","Documents online")
Expand All @@ -165,7 +169,7 @@ def __init__(self, halcomp, widgets, paths):
</body>
</html>
"""%( txt1, txt2, txt3, txt4, os.path.expanduser('~/linuxcnc'), txt5,
os.path.join(paths.IMAGEDIR,'lcnc_swoop.png'))
self.swoopPath)

def class_patch__(self):
# override file manager load button
Expand Down Expand Up @@ -264,7 +268,7 @@ def initialized__(self):
if os.path.exists(self.default_setup):
self.w.webwidget.load(QtCore.QUrl.fromLocalFile(self.default_setup))
else:
self.w.webwidget.setHtml(self.html)
self.w.webwidget.setHtml(self.html, self.swoopURL)
self.w.webwidget.page().urlChanged.connect(self.onLoadFinished)

except Exception as e:
Expand Down Expand Up @@ -1395,7 +1399,7 @@ def load_code(self, fname):
self.w.webwidget.loadFile(fname)
self.add_status("{} : {}".format(_translate("HandlerClass","Loaded HTML file"), fname), CRITICAL)
else:
self.w.webwidget.setHtml(self.html)
self.w.webwidget.setHtml(self.html, self.swoopURL)
except Exception as e:
self.add_status("{} {} : {}".format(_translate("HandlerClass","Error loading HTML file"), fname,e))
# look for PDF setup files
Expand Down Expand Up @@ -1648,7 +1652,7 @@ def homeWeb(self):
if os.path.exists(self.default_setup):
self.w.webwidget.load(QtCore.QUrl.fromLocalFile(self.default_setup))
else:
self.w.webwidget.setHtml(self.html)
self.w.webwidget.setHtml(self.html, self.swoopURL)
except:
pass
# setup tab's web page back button
Expand All @@ -1660,7 +1664,7 @@ def back(self):
if os.path.exists(self.default_setup):
self.w.webwidget.load(QtCore.QUrl.fromLocalFile(self.default_setup))
else:
self.w.webwidget.setHtml(self.html)
self.w.webwidget.setHtml(self.html, self.swoopURL)
except:
pass

Expand Down
14 changes: 9 additions & 5 deletions share/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ def __init__(self, halcomp, widgets, paths):
txt3 = _translate("HandlerClass","Documents online")
txt4 = _translate("HandlerClass","QtDragon online")
txt5 = _translate("HandlerClass","Local files")

self.swoopPath = os.path.join(paths.IMAGEDIR,'lcnc_swoop.png')
self.swoopURL = QtCore.QUrl.fromLocalFile(self.swoopPath)

self.html = """<html>
<head>
<title>Test page for the download:// scheme</title>
Expand All @@ -165,7 +169,7 @@ def __init__(self, halcomp, widgets, paths):
</body>
</html>
"""%( txt1, txt2, txt3, txt4, os.path.expanduser('~/linuxcnc'), txt5,
os.path.join(paths.IMAGEDIR,'lcnc_swoop.png'))
self.swoopPath)

def class_patch__(self):
# override file manager load button
Expand Down Expand Up @@ -453,7 +457,7 @@ def init_widgets(self):
if os.path.exists(self.default_setup):
self.w.web_view.load(QtCore.QUrl.fromLocalFile(self.default_setup))
else:
self.w.web_view.setHtml(self.html)
self.w.web_view.setHtml(self.html, self.swoopURL)
self.w.web_view.page().urlChanged.connect(self.onLoadFinished)
except Exception as e:
print("No default setup file found - {}".format(e))
Expand Down Expand Up @@ -1461,7 +1465,7 @@ def load_code(self, fname):
self.w.web_view.load(QtCore.QUrl.fromLocalFile(fname))
self.add_status("{} : {}".format(_translate("HandlerClass","Loaded HTML file"), fname))
else:
self.w.web_view.setHtml(self.html)
self.w.web_view.setHtml(self.html, self.swoopURL)
except Exception as e:
self.add_status("{} {} :()".format(_translate("HandlerClass","Can not Load HTML file"), fname,e))
# look for PDF setup files
Expand Down Expand Up @@ -1697,7 +1701,7 @@ def homeWeb(self):
if os.path.exists(self.default_setup):
self.w.web_view.load(QtCore.QUrl.fromLocalFile(self.default_setup))
else:
self.w.web_view.setHtml(self.html)
self.w.web_view.setHtml(self.html, self.swoopURL)
except:
pass
# setup tab's web page back button
Expand All @@ -1709,7 +1713,7 @@ def back(self):
if os.path.exists(self.default_setup):
self.w.web_view.load(QtCore.QUrl.fromLocalFile(self.default_setup))
else:
self.w.web_view.setHtml(self.html)
self.w.web_view.setHtml(self.html, self.swoopURL)
except:
pass

Expand Down
14 changes: 9 additions & 5 deletions share/qtvcp/screens/qtdragon_lathe/qtdragon_lathe_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def __init__(self, halcomp, widgets, paths):
txt3 = _translate("HandlerClass","Documents online")
txt4 = _translate("HandlerClass","QtDragon online")
txt5 = _translate("HandlerClass","Local files")

self.swoopPath = os.path.join(paths.IMAGEDIR,'lcnc_swoop.png')
self.swoopURL = QtCore.QUrl.fromLocalFile(self.swoopPath)

self.html = """<html>
<head>
<title>Test page for the download:// scheme</title>
Expand All @@ -170,7 +174,7 @@ def __init__(self, halcomp, widgets, paths):
</body>
</html>
"""%( txt1, txt2, txt3, txt4, os.path.expanduser('~/linuxcnc'), txt5,
os.path.join(paths.IMAGEDIR,'lcnc_swoop.png'))
self.swoopPath)

def class_patch__(self):
# override file manager load button
Expand Down Expand Up @@ -269,7 +273,7 @@ def initialized__(self):
if os.path.exists(self.default_setup):
self.w.webwidget.load(QtCore.QUrl.fromLocalFile(self.default_setup))
else:
self.w.webwidget.setHtml(self.html)
self.w.webwidget.setHtml(self.html, self.swoopURL)
self.w.webwidget.page().urlChanged.connect(self.onLoadFinished)

except Exception as e:
Expand Down Expand Up @@ -1403,7 +1407,7 @@ def load_code(self, fname):
self.w.webwidget.loadFile(fname)
self.add_status("{} : {}".format(_translate("HandlerClass","Loaded HTML file"), fname), CRITICAL)
else:
self.w.webwidget.setHtml(self.html)
self.w.webwidget.setHtml(self.html, self.swoopURL)
except Exception as e:
self.add_status("{} {} : {}".format(_translate("HandlerClass","Error loading HTML file"), fname,e))
# look for PDF setup files
Expand Down Expand Up @@ -1656,7 +1660,7 @@ def homeWeb(self):
if os.path.exists(self.default_setup):
self.w.webwidget.load(QtCore.QUrl.fromLocalFile(self.default_setup))
else:
self.w.webwidget.setHtml(self.html)
self.w.webwidget.setHtml(self.html, self.swoopURL)
except:
pass
# setup tab's web page back button
Expand All @@ -1668,7 +1672,7 @@ def back(self):
if os.path.exists(self.default_setup):
self.w.webwidget.load(QtCore.QUrl.fromLocalFile(self.default_setup))
else:
self.w.webwidget.setHtml(self.html)
self.w.webwidget.setHtml(self.html, self.swoopURL)
except:
pass

Expand Down

0 comments on commit 1ed894e

Please sign in to comment.