From e3e74b98eced136e0a5a1b157101d8d8f815d817 Mon Sep 17 00:00:00 2001 From: dprojects Date: Wed, 30 Mar 2022 17:55:39 +0200 Subject: [PATCH] new debugInfo button --- .gitignore | 1 + Icons/debugInfo.xpm | 53 ++++++++++++++++++++++ InitGui.py | 1 + Tools/debugInfo/debugInfo.py | 88 ++++++++++++++++++++++++++++++++++++ loadToolbar.py | 1 - loadTools.py | 38 ++++++++++++++++ 6 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 Icons/debugInfo.xpm create mode 100644 Tools/debugInfo/debugInfo.py diff --git a/.gitignore b/.gitignore index debd752..26514db 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ Tools/getDimensions/__pycache__ Tools/scanObjects/__pycache__ Tools/sheet2export/__pycache__ Tools/setTextures/__pycache__ +Tools/debugInfo/__pycache__ diff --git a/Icons/debugInfo.xpm b/Icons/debugInfo.xpm new file mode 100644 index 0000000..4995185 --- /dev/null +++ b/Icons/debugInfo.xpm @@ -0,0 +1,53 @@ +/* XPM */ +static char * debugInfo_xpm[] = { +"48 48 2 1", +" c None", +". c #000000", +" ", +" .. ", +" ... .. .. ", +" ... ........ ... ", +" ... .......... .... ", +" ... .......... .... ", +" ... ............ ... ", +" ... ............ ... ", +" .... .......... ... ", +" ... .......... .... ", +" .... ........ .... ", +" .... ..... .... ", +" ...... ......... ..... ", +" ....... ........... ..... ", +" .................... ...... ", +" ......................... ", +" ...................... ", +" ................... ", +" ................... ", +" ......................... ", +" ............................. ", +" ................................. ", +" .......................... ....... ", +" ............................ ..... ", +" ....... ..................... ... ", +" ...... ..................... ", +" ..... ..................... ", +" ... ........................ ", +" ............................. ", +" .................................. ", +" .................................... ", +" ...... ..................... ....... ", +" ..... ..................... ..... ", +" ..... ................... .... ", +" .... ..................... ... ", +" ... ......................... ", +" ............................. ", +" ...... ........................ ", +" ..... ............... ........ ", +" .... ............... ...... ", +" .... ............. ..... ", +" .... ........... ..... ", +" .... ........ .... ", +" ... ... ... ", +" ... .. ", +" ", +" ", +" "}; diff --git a/InitGui.py b/InitGui.py index 4a3b22e..9dc360d 100644 --- a/InitGui.py +++ b/InitGui.py @@ -29,6 +29,7 @@ def Initialize(self): self.appendToolbar("Coding", loadToolbar.getItems("Coding")) self.appendToolbar("Coding", ["CODE"] ) + self.appendToolbar("Coding", ["DEBUGINFO"] ) self.appendToolbar("Manage", ["SETTEXTURES"] ) self.appendMenu("Woodworking", loadMenu.getItems()) diff --git a/Tools/debugInfo/debugInfo.py b/Tools/debugInfo/debugInfo.py new file mode 100644 index 0000000..9860ced --- /dev/null +++ b/Tools/debugInfo/debugInfo.py @@ -0,0 +1,88 @@ +import FreeCAD +import FreeCADGui as Gui + +# ############################################################################ +# This part of code has been created by Werner Mayer (wmayer) at forum: +# https://forum.freecadweb.org/viewtopic.php?p=187448#p187448 +# ############################################################################ + +from PySide import QtCore +from PySide import QtGui + +class AboutInfo(QtCore.QObject): + def eventFilter(self, obj, ev): + if obj.metaObject().className() == "Gui::Dialog::AboutDialog": + if ev.type() == ev.ChildPolished: + mo = obj.metaObject() + index = mo.indexOfMethod("on_copyButton_clicked()") + if index > 0: + mo.invokeMethod(obj, "on_copyButton_clicked") + QtGui.qApp.postEvent(obj, QtGui.QCloseEvent()) + + return False + +ai=AboutInfo() +QtGui.qApp.installEventFilter(ai) +Gui.runCommand("Std_About") +QtGui.qApp.removeEventFilter(ai) + +# ############################################################################ +# by dprojects below: +# ############################################################################ + +def showQtGUI(): + + class QtMainClass(QtGui.QDialog): + + def __init__(self): + super(QtMainClass, self).__init__() + self.initUI() + + def initUI(self): + + # main window + self.result = userCancelled + self.setGeometry(450, 100, 410, 500) + self.setWindowTitle("Platform details for bug report") + self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) + + # output + Info = "" + Info += "Has been copied to clipboard: \n" + + self.oInfo1 = QtGui.QLabel(Info, self) + self.oInfo1.move(5, 10) + + self.o = QtGui.QTextEdit(self) + self.o.setMinimumSize(400, 350) + self.o.setMaximumSize(400, 350) + self.o.move(5, 40) + + self.o.setPlainText("") + self.o.paste() + + Info = "" + Info += "Note: \n\n" + Info += "CTRL-V - to paste it at your forum topic \n\n" + Info += "CTRL-A, CTRL-C - to copy again" + + self.oInfo2 = QtGui.QLabel(Info, self) + self.oInfo2.move(5, 400) + + # show + self.show() + + userCancelled = "Cancelled" + userOK = "OK" + + form = QtMainClass() + form.exec_() + + if form.result == userCancelled: + pass + +# ################################################################################################################### +# MAIN +# ################################################################################################################### + +showQtGUI() diff --git a/loadToolbar.py b/loadToolbar.py index 37739e6..9927d64 100644 --- a/loadToolbar.py +++ b/loadToolbar.py @@ -56,7 +56,6 @@ def getItems(iType): parts = [ "Std_DlgMacroExecute", "Std_DlgMacroExecuteDirect", - "Std_About", "Std_DependencyGraph" ] diff --git a/loadTools.py b/loadTools.py index b44315a..2392e23 100644 --- a/loadTools.py +++ b/loadTools.py @@ -161,3 +161,41 @@ def IsActive(self): FreeCADGui.addCommand("SETTEXTURES", SETTEXTURES()) +# ###################################################################################################################### +class DEBUGINFO(): + + def GetResources(self): + return {"Pixmap" : os.path.join(iconPath, "debugInfo.xpm"), + "Accel" : "", + "MenuText": "DEBUGINFO", + "ToolTip" : "copy platform details to clipboard for bug report purposes"} + + def Activated(self): + + import os, sys + import fakemodule + + modulePath = sys.path + + module = "debugInfo" + + path = os.path.dirname(fakemodule.__file__) + path = os.path.join(path, "Tools") + path = os.path.join(path, module) + sys.path.append(path) + + if module in sys.modules: + del sys.modules[module] + + __import__(module, globals(), locals(), [], 0) + + sys.path = modulePath + + return + + def IsActive(self): + # not needed now, maybe in the future + return True + +FreeCADGui.addCommand("DEBUGINFO", DEBUGINFO()) +