Cleanup code

This commit is contained in:
Paul Ebbers 2025-02-23 18:03:29 +01:00
parent b49c45ab94
commit 948fd924ca
2 changed files with 5 additions and 37 deletions

View File

@ -1,10 +1,6 @@
import FreeCAD as App
import FreeCADGui as Gui
from PySide.QtWidgets import QWidgetAction, QToolBar, QMainWindow, QWidget, QDialog
from PySide.QtGui import QCursor, QShortcut, QKeySequence, QAction
from PySide.QtCore import Qt
# Avoid garbage collection by storing the action in a global variable
wax = None
sea = None
@ -18,19 +14,16 @@ def QT_TRANSLATE_NOOP(context, text):
return text
# class SearchBox:
mw = Gui.getMainWindow()
def addToolSearchBox():
global wax, sea, tbr
mw = Gui.getMainWindow()
import SearchBox
from PySide.QtWidgets import QToolBar
from PySide6.QtWidgets import QToolBar
from PySide6.QtGui import QShortcut, QKeySequence
if mw:
if sea is None:
wax = SearchBox.SearchBoxFunction()
wax = SearchBox.SearchBoxFunction(mw)
if tbr is None:
tbr = QToolBar("SearchBar") # QtGui.QDockWidget()
# Include FreeCAD in the name so that one can find windows labeled with
@ -39,31 +32,7 @@ def addToolSearchBox():
tbr.addAction(wax)
mw.addToolBar(tbr)
tbr.show()
# self.shortcut = QShortcut(QKeySequence("Alt+R"), self)
# self.shortcut.activated.connect(self.AddPointerBox)
# self.AddPointerBox()
print("shortcut toggled")
return
def AddPointerBox():
import SearchBox
print("shortcut toggled")
Dialog = QDialog()
cursor = QCursor()
cursorPosition = cursor.pos()
Dialog.geometry().setX(cursorPosition.x())
Dialog.geometry().setY(cursorPosition.y())
Action = SearchBox.SearchBoxFunction()
Dialog.addAction(Action)
Dialog.show()
return
return
addToolSearchBox()

View File

@ -63,11 +63,10 @@ def easyToolTipWidget(html):
return foo
def SearchBoxFunction():
def SearchBoxFunction(mw):
import SearchBoxLight
global wax, sea, tbr
mw = Gui.getMainWindow()
if mw:
if sea is None: