This repository was archived by the owner on Mar 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathlens_command.py
More file actions
77 lines (59 loc) · 2.1 KB
/
Copy pathlens_command.py
File metadata and controls
77 lines (59 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import Utils
import WorkspaceView
import FreeCADGui as Gui
from PySide import QtGui, QtWidgets, QtCore
class LensCommand:
def GetResources(self):
return {
"Pixmap": Utils.icon_ondsel_path_disconnected,
"Accel": "Ctrl+L",
"MenuText": Utils.LENS_TOOLBARITEM_TEXT,
"ToolTip": "Show the Ondsel Lens Addon in an MDI view.",
}
def Activated(self):
start_mdi_tab()
def IsActive(self):
return True
class LensWorkbenchManipulator:
def modifyMenuBar(self):
return [
{"insert": Utils.NAME_COMMAND, "menuItem": "Std_WhatsThis", "after": ""}
]
def modifyToolBars(self):
return [{"append": Utils.NAME_COMMAND, "toolBar": "File"}]
def find_subwindow(main_window):
from PySide import QtWidgets
subwindows = main_window.findChildren(QtWidgets.QMdiSubWindow)
for subwindow in subwindows:
if subwindow.widget().centralWidget().objectName() == "WorkspaceView":
return subwindow
return None
def start_mdi_tab():
main_window = Gui.getMainWindow()
subwindow = find_subwindow(main_window)
if subwindow:
mdi_area = main_window.findChild(QtWidgets.QMdiArea)
mdi_area.setActiveSubWindow(subwindow)
else:
if WorkspaceView.wsv:
del WorkspaceView.wsv
WorkspaceView.wsv = WorkspaceView.WorkspaceView(main_window)
main_window.addWindow(WorkspaceView.wsv)
subwindow = find_subwindow(main_window)
if subwindow:
subwindow.setWindowTitle("Ondsel Lens")
subwindow.setWindowIcon(QtGui.QIcon(Utils.icon_ondsel_path_connected))
subwindow.showMaximized()
def init_toolbar_icon():
if WorkspaceView.wsv:
WorkspaceView.wsv.init_toolbar_icon()
def ensure_mdi_tab():
main_window = Gui.getMainWindow()
timer = QtCore.QTimer(main_window)
def check_mdi_tab_visible():
subwindow = find_subwindow(main_window)
if subwindow:
start_mdi_tab()
timer.stop()
timer.timeout.connect(check_mdi_tab_visible)
timer.start(500)