-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathInitGui.py
91 lines (79 loc) · 3.81 KB
/
InitGui.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# *************************************************************************
# * *
# * Copyright (c) 2019-2024 Hakan Seven, Geolta, Paul Ebbers *
# * *
# * 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 3 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 os
import FreeCAD as App
import FreeCADGui as Gui
import FCBinding
import Parameters_Ribbon
import shutil
from PySide.QtCore import Signal, QObject
import sys
def QT_TRANSLATE_NOOP(context, text):
return text
translate = App.Qt.translate
# check if there is a "RibbonStructure.json". if not create one
file = os.path.join(os.path.dirname(FCBinding.__file__), "RibbonStructure.json")
file_default = os.path.join(
os.path.dirname(FCBinding.__file__), "RibbonStructure_default.json"
)
source = os.path.join(os.path.dirname(FCBinding.__file__), "CreateStructure.txt")
source_default = os.path.join(
os.path.dirname(FCBinding.__file__), "CreateStructure.txt"
)
# check if file exits
fileExists = os.path.isfile(file)
# if not, copy and rename
if fileExists is False:
shutil.copy(source, file)
# check if file exits
fileExists = os.path.isfile(file_default)
# if not, copy and rename
if fileExists is False:
shutil.copy(source_default, file_default)
# remove the test workbench
Gui.removeWorkbench("TestWorkbench")
USECUSTOMOVERLAY = os.path.join(os.path.dirname(FCBinding.__file__), "OVERLAY_DISABLED")
if (
Parameters_Ribbon.USE_FC_OVERLAY is False
or os.path.exists(USECUSTOMOVERLAY) is True
):
# Disable the overlay function
preferences = App.ParamGet("User parameter:BaseApp/Preferences/DockWindows")
preferences.SetBool("ActivateOverlay", False)
# make sure that the ribbon will be shown on startup -> reset OverlayTop
preferences = App.ParamGet(
"User parameter:BaseApp/MainWindow/DockWindows/OverlayTop"
)
preferences.SetString("Widgets", "")
if Parameters_Ribbon.USE_FC_OVERLAY is True:
# Disable the overlay function
preferences = App.ParamGet("User parameter:BaseApp/Preferences/DockWindows")
preferences.SetBool("ActivateOverlay", True)
try:
print(translate("FreeCAD Ribbon", "Activating Ribbon Bar..."))
mw = Gui.getMainWindow()
mw.workbenchActivated.connect(FCBinding.run)
except Exception as e:
if Parameters_Ribbon.DEBUG_MODE is True:
print(f"{e.with_traceback(e.__traceback__)}, 0")
Gui.addLanguagePath(os.path.join(os.path.dirname(FCBinding.__file__), "translations"))
Gui.updateLocale()