FreeCAD

Форк
0
/
NavigationIndicatorGui.py 
833 строки · 23.3 Кб
1
# Navigation indicator for FreeCAD
2
# Copyright (C) 2016, 2017, 2018 triplus @ FreeCAD
3
#
4
#
5
# This library is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU Lesser General Public
7
# License as published by the Free Software Foundation; either
8
# version 2.1 of the License, or (at your option) any later version.
9
#
10
# This library is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# Lesser General Public License for more details.
14
#
15
# You should have received a copy of the GNU Lesser General Public
16
# License along with this library; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
18

19
"""Navigation indicator for FreeCAD."""
20

21
import Tux_rc
22
import FreeCAD as App
23
import FreeCADGui as Gui
24
from PySide import QtGui
25
from PySide import QtCore
26

27
mw = Gui.getMainWindow()
28
statusBar = mw.statusBar()
29
p = App.ParamGet("User parameter:Tux/NavigationIndicator")
30
pView = App.ParamGet("User parameter:BaseApp/Preferences/View")
31
pMWin = App.ParamGet("User parameter:BaseApp/Preferences/MainWindow")
32

33
try:
34
    _encoding = QtGui.QApplication.UnicodeUTF8
35

36
    def translate(context, text):
37
        "convenience function for Qt 4 translator"
38
        return QtGui.QApplication.translate(context, text, None, _encoding)
39

40
except AttributeError:
41

42
    def translate(context, text):
43
        "convenience function for Qt 5 translator"
44
        return QtGui.QApplication.translate(context, text, None)
45

46

47
class IndicatorButton(QtGui.QPushButton):
48
    """Detect language change events."""
49

50
    def __init__(self, parent=None):
51
        super(IndicatorButton, self).__init__()
52

53
    def changeEvent(self, event):
54
        """Change events."""
55
        if event.type() == QtCore.QEvent.LanguageChange:
56
            retranslateUi()
57
            onTooltip()
58
            self.adjustSize()
59
        return super(IndicatorButton, self).changeEvent(event)
60

61
    def onChange(self, paramGrp, param):
62
        if param == "NavigationStyle":
63
            setCurrent()
64

65
    def mousePressEvent(self, event):
66
        RePopulateIcons()
67
        return super(IndicatorButton, self).mousePressEvent(event)
68

69

70
def RePopulateIcons():
71
    curStyleSheet = pMWin.GetString("StyleSheet")
72
    if "dark" in curStyleSheet.lower():
73
        StyleSheetType = "light"
74
    else:
75
        StyleSheetType = "dark"
76

77
    a1.setIcon(QtGui.QIcon(":/icons/NavigationBlender_" + StyleSheetType + ".svg"))
78
    a2.setIcon(QtGui.QIcon(":/icons/NavigationCAD_" + StyleSheetType + ".svg"))
79
    a3.setIcon(QtGui.QIcon(":/icons/NavigationGesture_" + StyleSheetType + ".svg"))
80
    a4.setIcon(QtGui.QIcon(":/icons/NavigationMayaGesture_" + StyleSheetType + ".svg"))
81
    a5.setIcon(QtGui.QIcon(":/icons/NavigationOpenCascade_" + StyleSheetType + ".svg"))
82
    a6.setIcon(QtGui.QIcon(":/icons/NavigationOpenInventor_" + StyleSheetType + ".svg"))
83
    a7.setIcon(QtGui.QIcon(":/icons/NavigationOpenSCAD_" + StyleSheetType + ".svg"))
84
    a8.setIcon(QtGui.QIcon(":/icons/NavigationRevit_" + StyleSheetType + ".svg"))
85
    a9.setIcon(QtGui.QIcon(":/icons/NavigationTinkerCAD_" + StyleSheetType + ".svg"))
86
    a10.setIcon(QtGui.QIcon(":/icons/NavigationTouchpad_" + StyleSheetType + ".svg"))
87

88

89
def retranslateUi():
90
    """Retranslate navigation indicator on language change"""
91

92
    text01 = translate("NavigationIndicator", "Select")
93
    text02 = translate("NavigationIndicator", "Zoom")
94
    text03 = translate("NavigationIndicator", "Rotate")
95
    text04 = translate("NavigationIndicator", "Pan")
96
    text05 = translate("NavigationIndicator", "Tilt")
97
    text06 = translate("NavigationIndicator", "Navigation style")
98
    text07 = translate("NavigationIndicator", "Page Up or Page Down key.")
99
    text08 = translate("NavigationIndicator", "Rotation focus")
100
    text09 = translate("NavigationIndicator", "Middle mouse button or H key.")
101
    text10 = translate("NavigationIndicator", "Middle mouse button.")
102

103
    global t0
104
    t0 = translate("NavigationIndicator", "Navigation style not recognized.")
105

106
    global t1
107
    t1 = (
108
        "<p align='center'><b>Blender</b> "
109
        + text06
110
        + """</p>
111
    <table>
112
     <tr>
113
      <th><small>"""
114
        + text01
115
        + """</small></th>
116
      <th><small>"""
117
        + text02
118
        + """</small></th>
119
      <th><small>"""
120
        + text03
121
        + """</small></th>
122
      <th><small>"""
123
        + text04
124
        + """</small></th>
125
      <th><small>"""
126
        + text04
127
        + """</small></th>
128
     </tr>
129
     <tr>
130
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
131
      <td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
132
      <td align='center'><img src=':/icons/Navigation_Mouse_Middle.svg'></td>
133
      <td align='center'><img src=':/icons/Navigation_Mouse_ShiftMiddle.svg'></td>
134
      <td align='center'><img src=':/icons/Navigation_Mouse_LeftRight.svg'></td>
135
     </tr>
136
    </table>
137
    <b>"""
138
        + text08
139
        + ":</b> "
140
        + text10
141
        + "</small></p>"
142
    )
143

144
    global t2
145
    t2 = (
146
        "<p align='center'><b>CAD</b> "
147
        + text06
148
        + """</p>
149
    <table>
150
     <tr>
151
      <th><small>"""
152
        + text01
153
        + """</small></th>
154
      <th><small>"""
155
        + text02
156
        + """</small></th>
157
      <th><small>"""
158
        + text03
159
        + """</small></th>
160
      <th><small>"""
161
        + text03
162
        + """</small></th>
163
      <th><small>"""
164
        + text04
165
        + """</small></th>
166
     </tr>
167
     <tr>
168
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
169
      <td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
170
      <td align='center'><img src=':/icons/Navigation_Mouse_MiddleLeft.svg'></td>
171
      <td align='center'><img src=':/icons/Navigation_Mouse_MiddleRight.svg'></td>
172
      <td align='center'><img src=':/icons/Navigation_Mouse_Middle.svg'></td>
173
     </tr>
174
    </table>
175
    <b>"""
176
        + text08
177
        + ":</b> "
178
        + text10
179
        + "</small></p>"
180
    )
181

182
    global t3
183
    t3 = (
184
        "<p align='center'><b>Gesture</b> "
185
        + text06
186
        + """</p>
187
    <table>
188
     <tr>
189
      <th><small>"""
190
        + text01
191
        + """</small></th>
192
      <th><small>"""
193
        + text02
194
        + """</small></th>
195
      <th><small>"""
196
        + text03
197
        + """</small></th>
198
      <th><small>"""
199
        + text03
200
        + """</small></th>
201
      <th><small>"""
202
        + text04
203
        + """</small></th>
204
      <th><small>"""
205
        + text05
206
        + """</small></th>
207
     </tr>
208
     <tr>
209
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
210
      <td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
211
      <td align='center'><img src=':/icons/Navigation_Mouse_LeftMove.svg'></td>
212
      <td align='center'><img src=':/icons/Navigation_Mouse_AltLeft.svg'></td>
213
      <td align='center'><img src=':/icons/Navigation_Mouse_Right.svg'></td>
214
      <td align='center'><img src=':/icons/Navigation_Mouse_LeftRight.svg'></td>
215
     </tr>
216
     <tr>
217
      <th><small>"""
218
        + text01
219
        + """</small></th>
220
      <th><small>"""
221
        + text02
222
        + """</small></th>
223
      <th><small>"""
224
        + text03
225
        + """</small></th>
226
      <th><small>"""
227
        + text04
228
        + """</small></th>
229
      <th><small>"""
230
        + text04
231
        + """</small></th>
232
      <th><small>"""
233
        + text05
234
        + """</small></th>
235
     </tr>
236
     <tr>
237
      <td align='center'><img src=':/icons/Navigation_Gesture_SelectTouch.svg'></td>
238
      <td align='center'><img src=':/icons/Navigation_Gesture_ZoomTouch.svg'></td>
239
      <td align='center'><img src=':/icons/Navigation_Gesture_RotateTouch.svg'></td>
240
      <td align='center'><img src=':/icons/Navigation_Gesture_PanTouch.svg'></td>
241
      <td align='center'><img src=':/icons/Navigation_Gesture_PanTouchAlt.svg'></td>
242
      <td align='center'><img src=':/icons/Navigation_Gesture_TiltTouch.svg'></td>
243
     </tr>
244
    </table>
245
    <p><small><b>"""
246
        + text02
247
        + ":</b> "
248
        + text07
249
        + """<br>
250
    <b>"""
251
        + text08
252
        + ":</b> "
253
        + text09
254
        + "</small></p>"
255
    )
256

257
    global t4
258
    t4 = (
259
        "<p align='center'><b>MayaGesture</b> "
260
        + text06
261
        + """</p>
262
    <table>
263
     <tr>
264
      <th><small>"""
265
        + text01
266
        + """</small></th>
267
      <th><small>"""
268
        + text02
269
        + """</small></th>
270
      <th><small>"""
271
        + text02
272
        + """</small></th>
273
      <th><small>"""
274
        + text03
275
        + """</small></th>
276
      <th><small>"""
277
        + text04
278
        + """</small></th>
279
      <th><small>"""
280
        + text05
281
        + """</small></th>
282
     </tr>
283
     <tr>
284
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
285
      <td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
286
      <td align='center'><img src=':/icons/Navigation_Mouse_AltRight.svg'></td>
287
      <td align='center'><img src=':/icons/Navigation_Mouse_AltLeft.svg'></td>
288
      <td align='center'><img src=':/icons/Navigation_Mouse_AltMiddle.svg'></td>
289
      <td align='center'><img src=':/icons/Navigation_Mouse_AltLeftRight.svg'></td>
290
     </tr>
291
     <tr>
292
      <th><small>"""
293
        + text01
294
        + """</small></th>
295
      <th><small>"""
296
        + text02
297
        + """</small></th>
298
      <th><small>"""
299
        + text03
300
        + """</small></th>
301
      <th><small>"""
302
        + text04
303
        + """</small></th>
304
      <th><small>"""
305
        + text04
306
        + """</small></th>
307
      <th><small>"""
308
        + text05
309
        + """</small></th>
310
     </tr>
311
     <tr>
312
      <td align='center'><img src=':/icons/Navigation_Gesture_SelectTouch.svg'></td>
313
      <td align='center'><img src=':/icons/Navigation_Gesture_ZoomTouch.svg'></td>
314
      <td align='center'><img src=':/icons/Navigation_Gesture_RotateTouch.svg'></td>
315
      <td align='center'><img src=':/icons/Navigation_Gesture_PanTouch.svg'></td>
316
      <td align='center'><img src=':/icons/Navigation_Gesture_PanTouchAlt.svg'></td>
317
      <td align='center'><img src=':/icons/Navigation_Gesture_TiltTouch.svg'></td>
318
     </tr>
319
    </table>
320
    <p><small><b>"""
321
        + text02
322
        + ":</b> "
323
        + text07
324
        + """<br>
325
    <b>"""
326
        + text08
327
        + ":</b> "
328
        + text09
329
        + "</small></p>"
330
    )
331

332
    global t5
333
    t5 = (
334
        "<p align='center'><b>OpenCascade</b> "
335
        + text06
336
        + """</p>
337
    <table>
338
     <tr>
339
      <th><small>"""
340
        + text01
341
        + """</small></th>
342
      <th><small>"""
343
        + text02
344
        + """</small></th>
345
      <th><small>"""
346
        + text02
347
        + """</small></th>
348
      <th><small>"""
349
        + text03
350
        + """</small></th>
351
      <th><small>"""
352
        + text04
353
        + """</small></th>
354
      <th><small>"""
355
        + text04
356
        + """</small></th>
357
     </tr>
358
     <tr>
359
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
360
      <td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
361
      <td align='center'><img src=':/icons/Navigation_Mouse_CtrlLeft.svg'></td>
362
      <td align='center'><img src=':/icons/Navigation_Mouse_CtrlRight.svg'></td>
363
      <td align='center'><img src=':/icons/Navigation_Mouse_CtrlMiddle.svg'></td>
364
      <td align='center'><img src=':/icons/Navigation_Mouse_Middle.svg'></td>
365
     </tr>
366
    </table>"""
367
    )
368

369
    global t6
370
    t6 = (
371
        "<p align='center'><b>OpenInventor</b> "
372
        + text06
373
        + """</p>
374
    <table>
375
     <tr>
376
      <th><small>"""
377
        + text01
378
        + """</small></th>
379
      <th><small>"""
380
        + text02
381
        + """</small></th>
382
      <th><small>"""
383
        + text02
384
        + """</small></th>
385
      <th><small>"""
386
        + text03
387
        + """</small></th>
388
      <th><small>"""
389
        + text04
390
        + """</small></th>
391
     </tr>
392
     <tr>
393
      <td align='center'><img src=':/icons/Navigation_Mouse_ShiftLeft.svg'></td>
394
      <td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
395
      <td align='center'><img src=':/icons/Navigation_Mouse_MiddleLeft.svg'></td>
396
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
397
      <td align='center'><img src=':/icons/Navigation_Mouse_Middle.svg'></td>
398
     </tr>
399
    </table>
400
    <b>"""
401
        + text08
402
        + ":</b> "
403
        + text10
404
        + "</small></p>"
405
    )
406

407
    global t7
408
    t7 = (
409
        "<p align='center'><b>OpenSCAD</b> "
410
        + text06
411
        + """</p>
412
    <table>
413
     <tr>
414
      <th><small>"""
415
        + text01
416
        + """</small></th>
417
      <th><small>"""
418
        + text02
419
        + """</small></th>
420
      <th><small>"""
421
        + text02
422
        + """</small></th>
423
      <th><small>"""
424
        + text03
425
        + """</small></th>
426
      <th><small>"""
427
        + text03
428
        + """</small></th>
429
      <th><small>"""
430
        + text04
431
        + """</small></th>
432
     </tr>
433
     <tr>
434
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
435
      <td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
436
      <td align='center'><img src=':/icons/Navigation_Mouse_Middle.svg'></td>
437
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
438
      <td align='center'><img src=':/icons/Navigation_Mouse_MiddleRight.svg'></td>
439
      <td align='center'><img src=':/icons/Navigation_Mouse_Right.svg'></td>
440
     </tr>
441
    </table>"""
442
    )
443

444
    global t8
445
    t8 = (
446
        "<p align='center'><b>Revit</b> "
447
        + text06
448
        + """</p>
449
    <table>
450
     <tr>
451
      <th><small>"""
452
        + text01
453
        + """</small></th>
454
      <th><small>"""
455
        + text02
456
        + """</small></th>
457
      <th><small>"""
458
        + text03
459
        + """</small></th>
460
      <th><small>"""
461
        + text04
462
        + """</small></th>
463
      <th><small>"""
464
        + text04
465
        + """</small></th>
466
     </tr>
467
     <tr>
468
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
469
      <td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
470
      <td align='center'><img src=':/icons/Navigation_Mouse_ShiftMiddle.svg'></td>
471
      <td align='center'><img src=':/icons/Navigation_Mouse_Middle.svg'></td>
472
      <td align='center'><img src=':/icons/Navigation_Mouse_LeftRight.svg'></td>
473
     </tr>
474
    </table>
475
    <b>"""
476
        + text08
477
        + ":</b> "
478
        + text10
479
        + "</small></p>"
480
    )
481

482
    global t9
483
    t9 = (
484
        "<p align='center'><b>TinkerCAD</b> "
485
        + text06
486
        + """</p>
487
    <table>
488
     <tr>
489
      <th><small>"""
490
        + text01
491
        + """</small></th>
492
      <th><small>"""
493
        + text02
494
        + """</small></th>
495
      <th><small>"""
496
        + text03
497
        + """</small></th>
498
      <th><small>"""
499
        + text04
500
        + """</small></th>
501
     </tr>
502
     <tr>
503
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
504
      <td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
505
      <td align='center'><img src=':/icons/Navigation_Mouse_Right.svg'></td>
506
      <td align='center'><img src=':/icons/Navigation_Mouse_Middle.svg'></td>
507
     </tr>
508
    </table>"""
509
    )
510

511
    global t10
512
    t10 = (
513
        "<p align='center'><b>Touchpad</b> "
514
        + text06
515
        + """</p>
516
    <table>
517
     <tr>
518
      <th><small>"""
519
        + text01
520
        + """</small></th>
521
      <th><small>"""
522
        + text02
523
        + """</small></th>
524
      <th><small>"""
525
        + text02
526
        + """</small></th>
527
      <th><small>"""
528
        + text03
529
        + """</small></th>
530
      <th><small>"""
531
        + text03
532
        + """</small></th>
533
      <th><small>"""
534
        + text04
535
        + """</small></th>
536
     </tr>
537
     <tr>
538
      <td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
539
      <td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
540
      <td align='center'><img src=':/icons/Navigation_Mouse_ShiftCtrlMove.svg'></td>
541
      <td align='center'><img src=':/icons/Navigation_Mouse_AltMove.svg'></td>
542
      <td align='center'><img src=':/icons/Navigation_Mouse_ShiftLeft.svg'></td>
543
      <td align='center'><img src=':/icons/Navigation_Mouse_ShiftMove.svg'></td>
544
     </tr>
545
     <tr>
546
      <th><small>"""
547
        + text01
548
        + """</small></th>
549
      <th><small>"""
550
        + text02
551
        + """</small></th>
552
      <th><small>"""
553
        + text03
554
        + """</small></th>
555
      <th><small>"""
556
        + text03
557
        + """</small></th>
558
      <th><small>"""
559
        + text04
560
        + """</small></th>
561
     </tr>
562
     <tr>
563
      <td align='center'><img src=':/icons/Navigation_Touchpad_Left.svg'></td>
564
      <td align='center'><img src=':/icons/Navigation_Touchpad_ShiftCtrlTouch.svg'></td>
565
      <td align='center'><img src=':/icons/Navigation_Touchpad_AltTouch.svg'></td>
566
      <td align='center'><img src=':/icons/Navigation_Touchpad_ShiftLeftTouch.svg'></td>
567
      <td align='center'><img src=':/icons/Navigation_Touchpad_ShiftTouch.svg'></td>
568
     </tr>
569
    </table>
570
    <p><small><b>"""
571
        + text02
572
        + ":</b> "
573
        + text07
574
        + "</p>"
575
    )
576

577
    menuSettings.setTitle(translate("NavigationIndicator", "Settings"))
578
    menuOrbit.setTitle(translate("NavigationIndicator", "Orbit style"))
579
    aCompact.setText(translate("NavigationIndicator", "Compact"))
580
    aTooltip.setText(translate("NavigationIndicator", "Tooltip"))
581
    aTurntable.setText(translate("NavigationIndicator", "Turntable"))
582
    aFreeTurntable.setText(translate("NavigationIndicator", "Free Turntable"))
583
    aTrackball.setText(translate("NavigationIndicator", "Trackball"))
584
    a0.setText(translate("NavigationIndicator", "Undefined"))
585

586

587
indicator = IndicatorButton(statusBar)
588
indicator.setFlat(True)
589
indicator.adjustSize()
590
indicator.setObjectName("NavigationIndicator")
591

592
menu = QtGui.QMenu(indicator)
593
indicator.setMenu(menu)
594

595
menuSettings = QtGui.QMenu(menu)
596
menuOrbit = QtGui.QMenu(menu)
597

598
aCompact = QtGui.QAction(menuSettings)
599
aCompact.setCheckable(True)
600
aTooltip = QtGui.QAction(menuSettings)
601
aTooltip.setCheckable(True)
602

603
gOrbit = QtGui.QActionGroup(menuSettings)
604

605
aTurntable = QtGui.QAction(gOrbit)
606
aTurntable.setObjectName("NavigationIndicator_Turntable")
607
aTurntable.setCheckable(True)
608
aTrackball = QtGui.QAction(gOrbit)
609
aTrackball.setObjectName("NavigationIndicator_Trackball")
610
aTrackball.setCheckable(True)
611
aFreeTurntable = QtGui.QAction(gOrbit)
612
aFreeTurntable.setObjectName("NavigationIndicator_FreeTurntable")
613
aFreeTurntable.setCheckable(True)
614

615
menuOrbit.addAction(aTurntable)
616
menuOrbit.addAction(aTrackball)
617
menuOrbit.addAction(aFreeTurntable)
618

619
menuSettings.addMenu(menuOrbit)
620
menuSettings.addSeparator()
621
menuSettings.addAction(aCompact)
622
menuSettings.addAction(aTooltip)
623

624
gStyle = QtGui.QActionGroup(menu)
625

626
a0 = QtGui.QAction(gStyle)
627
a0.setIcon(QtGui.QIcon(":/icons/NavigationUndefined.svg"))
628
a0.setData("Undefined  ")
629
a0.setObjectName("Indicator_NavigationUndefined")
630

631
a1 = QtGui.QAction(gStyle)
632
a1.setText("Blender  ")
633
a1.setData("Gui::BlenderNavigationStyle")
634
a1.setObjectName("Indicator_NavigationBlender")
635

636
a2 = QtGui.QAction(gStyle)
637
a2.setText("CAD  ")
638
a2.setData("Gui::CADNavigationStyle")
639
a2.setObjectName("Indicator_NavigationCAD")
640

641
a3 = QtGui.QAction(gStyle)
642
a3.setText("Gesture  ")
643
a3.setData("Gui::GestureNavigationStyle")
644
a3.setObjectName("Indicator_NavigationGesture")
645

646
a4 = QtGui.QAction(gStyle)
647
a4.setText("MayaGesture  ")
648
a4.setData("Gui::MayaGestureNavigationStyle")
649
a4.setObjectName("Indicator_NavigationMayaGesture")
650

651
a5 = QtGui.QAction(gStyle)
652
a5.setText("OpenCascade  ")
653
a5.setData("Gui::OpenCascadeNavigationStyle")
654
a5.setObjectName("Indicator_NavigationOpenCascade")
655

656
a6 = QtGui.QAction(gStyle)
657
a6.setText("OpenInventor  ")
658
a6.setData("Gui::InventorNavigationStyle")
659
a6.setObjectName("Indicator_NavigationOpenInventor")
660

661
a7 = QtGui.QAction(gStyle)
662
a7.setText("OpenSCAD  ")
663
a7.setData("Gui::OpenSCADNavigationStyle")
664
a7.setObjectName("Indicator_NavigationOpenSCAD")
665

666
a8 = QtGui.QAction(gStyle)
667
a8.setText("Revit  ")
668
a8.setData("Gui::RevitNavigationStyle")
669
a8.setObjectName("Indicator_NavigationRevit")
670

671
a9 = QtGui.QAction(gStyle)
672
a9.setText("TinkerCAD  ")
673
a9.setData("Gui::TinkerCADNavigationStyle")
674
a9.setObjectName("Indicator_NavigationTinkerCAD")
675

676
a10 = QtGui.QAction(gStyle)
677
a10.setText("Touchpad  ")
678
a10.setData("Gui::TouchpadNavigationStyle")
679
a10.setObjectName("Indicator_NavigationTouchpad")
680

681
RePopulateIcons()
682

683
menu.addMenu(menuSettings)
684
menu.addSeparator()
685
menu.addAction(a0)
686
menu.addAction(a1)
687
menu.addAction(a2)
688
menu.addAction(a3)
689
menu.addAction(a4)
690
menu.addAction(a5)
691
menu.addAction(a6)
692
menu.addAction(a7)
693
menu.addAction(a8)
694
menu.addAction(a9)
695
menu.addAction(a10)
696

697
pView.Attach(indicator)
698

699

700
def onCompact():
701
    """Enable or disable compact mode."""
702

703
    if aCompact.isChecked():
704
        p.SetBool("Compact", 1)
705
    else:
706
        p.SetBool("Compact", 0)
707

708
    setCurrent()
709

710

711
def setCompact(action):
712
    """Set compact mode."""
713

714
    if p.GetBool("Compact", 0):
715
        indicator.setText("")
716
    else:
717
        indicator.setText(action.text())
718
        indicator.adjustSize()
719

720

721
def onTooltip():
722
    """Enable or disable verbose tooltips."""
723

724
    if aTooltip.isChecked():
725
        a0.setToolTip(t0)
726
        a1.setToolTip(t1)
727
        a2.setToolTip(t2)
728
        a3.setToolTip(t3)
729
        a4.setToolTip(t4)
730
        a5.setToolTip(t5)
731
        a6.setToolTip(t6)
732
        a7.setToolTip(t7)
733
        a8.setToolTip(t8)
734
        a9.setToolTip(t9)
735
        a10.setToolTip(t10)
736
        p.SetBool("Tooltip", 1)
737
    else:
738
        for i in gStyle.actions():
739
            i.setToolTip("")
740
        p.SetBool("Tooltip", 0)
741

742
    setCurrent()
743

744

745
def onOrbit():
746
    """Use turntable or trackball orbit style."""
747

748
    if aTurntable.isChecked():
749
        pView.SetInt("OrbitStyle", 0)
750
    elif aTrackball.isChecked():
751
        pView.SetInt("OrbitStyle", 1)
752
    elif aFreeTurntable.isChecked():
753
        pView.SetInt("OrbitStyle", 2)
754

755

756
def onOrbitShow():
757
    """Set turntable or trackball orbit style."""
758

759
    OrbitStyle = pView.GetInt("OrbitStyle", 0)
760
    gOrbit.blockSignals(True)
761
    if OrbitStyle == 0:
762
        aTurntable.setChecked(True)
763
    elif OrbitStyle == 1:
764
        aTrackball.setChecked(True)
765
    elif OrbitStyle == 2:
766
        aFreeTurntable.setChecked(True)
767
    gOrbit.blockSignals(False)
768

769

770
def onMenu(action):
771
    """Set navigation style on selection."""
772
    pView.SetString("NavigationStyle", action.data())
773

774

775
def setCurrent():
776
    """Set navigation style on start and on interval."""
777
    gStyle.blockSignals(True)
778

779
    s = False
780
    actions = gStyle.actions()
781
    current = pView.GetString("NavigationStyle")
782

783
    if current and current != "Undefined":
784
        for i in actions:
785
            if i.data() == current:
786
                s = True
787
                setCompact(i)
788
                menu.setDefaultAction(i)
789
                indicator.setIcon(i.icon())
790
                indicator.setToolTip(i.toolTip())
791
            else:
792
                pass
793
    else:
794
        s = True
795
        pView.SetString("NavigationStyle", a2.data())
796

797
    if s:
798
        a0.setVisible(False)
799
    else:
800
        a0.setVisible(True)
801
        a0.setEnabled(True)
802
        setCompact(a0)
803
        menu.setDefaultAction(a0)
804
        indicator.setIcon(a0.icon())
805
        indicator.setToolTip(a0.toolTip())
806

807
    gStyle.blockSignals(False)
808

809

810
if p.GetBool("Compact", 0):
811
    aCompact.setChecked(True)
812

813
if p.GetBool("Tooltip", 1):
814
    aTooltip.setChecked(True)
815

816
retranslateUi()
817
onCompact()
818
onTooltip()
819

820
label = statusBar.children()[2]
821
statusBar.removeWidget(label)
822
statusBar.addPermanentWidget(indicator)
823
statusBar.addPermanentWidget(label)
824
label.show()
825

826
setCurrent()
827

828
gStyle.triggered.connect(onMenu)
829
gOrbit.triggered.connect(onOrbit)
830
aCompact.triggered.connect(onCompact)
831
aTooltip.triggered.connect(onTooltip)
832
menuOrbit.aboutToShow.connect(onOrbitShow)
833
menu.aboutToHide.connect(indicator.clearFocus)
834

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.