Skip to content

Commit

Permalink
new debugInfo button
Browse files Browse the repository at this point in the history
  • Loading branch information
dprojects committed Mar 30, 2022
1 parent 9ae2fb1 commit e3e74b9
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ Tools/getDimensions/__pycache__
Tools/scanObjects/__pycache__
Tools/sheet2export/__pycache__
Tools/setTextures/__pycache__
Tools/debugInfo/__pycache__
53 changes: 53 additions & 0 deletions Icons/debugInfo.xpm
@@ -0,0 +1,53 @@
/* XPM */
static char * debugInfo_xpm[] = {
"48 48 2 1",
" c None",
". c #000000",
" ",
" .. ",
" ... .. .. ",
" ... ........ ... ",
" ... .......... .... ",
" ... .......... .... ",
" ... ............ ... ",
" ... ............ ... ",
" .... .......... ... ",
" ... .......... .... ",
" .... ........ .... ",
" .... ..... .... ",
" ...... ......... ..... ",
" ....... ........... ..... ",
" .................... ...... ",
" ......................... ",
" ...................... ",
" ................... ",
" ................... ",
" ......................... ",
" ............................. ",
" ................................. ",
" .......................... ....... ",
" ............................ ..... ",
" ....... ..................... ... ",
" ...... ..................... ",
" ..... ..................... ",
" ... ........................ ",
" ............................. ",
" .................................. ",
" .................................... ",
" ...... ..................... ....... ",
" ..... ..................... ..... ",
" ..... ................... .... ",
" .... ..................... ... ",
" ... ......................... ",
" ............................. ",
" ...... ........................ ",
" ..... ............... ........ ",
" .... ............... ...... ",
" .... ............. ..... ",
" .... ........... ..... ",
" .... ........ .... ",
" ... ... ... ",
" ... .. ",
" ",
" ",
" "};
1 change: 1 addition & 0 deletions InitGui.py
Expand Up @@ -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())
Expand Down
88 changes: 88 additions & 0 deletions 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()
1 change: 0 additions & 1 deletion loadToolbar.py
Expand Up @@ -56,7 +56,6 @@ def getItems(iType):
parts = [
"Std_DlgMacroExecute",
"Std_DlgMacroExecuteDirect",
"Std_About",
"Std_DependencyGraph"
]

Expand Down
38 changes: 38 additions & 0 deletions loadTools.py
Expand Up @@ -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())

0 comments on commit e3e74b9

Please sign in to comment.