forked from dubstar-04/PathHelperFace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitHelperFace.py
73 lines (57 loc) · 3.08 KB
/
InitHelperFace.py
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
# -*- coding: utf-8 -*-
# ***************************************************************************
# * *
# * Copyright (c) 2020 Daniel Wood <[email protected]> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
import FreeCADGui
from PySide import QtGui
import PathHelperFaceGui, PathHelperFace
import os
__dir__ = os.path.dirname(__file__)
iconPath = os.path.join( __dir__, 'Icons' )
def getIcon(iconName):
return os.path.join( iconPath , iconName)
def updateMenu(workbench):
if workbench == 'PathWorkbench':
print('Path Helperface loaded:', workbench)
mw = FreeCADGui.getMainWindow()
addonMenu = None
# Find the main path menu
pathMenu = mw.findChild(QtGui.QMenu, "&Path")
for menu in pathMenu.actions():
if menu.text() == "Path Addons":
# create a new addon menu
addonMenu = menu.menu()
break
if addonMenu is None:
addonMenu = QtGui.QMenu("Path Addons")
addonMenu.setObjectName("Path_Addons")
# Find the dressup menu entry
dressupMenu = mw.findChild(QtGui.QMenu, "Path Dressup")
pathMenu.insertMenu(dressupMenu.menuAction(), addonMenu)
# create an action for this addon
action = QtGui.QAction(addonMenu)
action.setText("Helper Face")
action.setIcon(QtGui.QPixmap(getIcon('Path_HelperFace.svg')))
action.setStatusTip("Create a helper face")
action.triggered.connect(PathHelperFaceGui.Show)
# append this addon to addon menu
addonMenu.addAction(action)
FreeCADGui.getMainWindow().workbenchActivated.connect(updateMenu)