Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Draft] ShapeString Task Panel Allow Windows...
....Users to view Font Files without the need to modify permissions on the Fonts folder. Also keeping the rest of FreeCAD file dialog boxes as standard.
  • Loading branch information
Syres916 authored and WandererFan committed Oct 11, 2019
1 parent 90fad81 commit 867a09f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Mod/Draft/DraftGui.py
Expand Up @@ -39,7 +39,7 @@
"""

import six

import platform
import FreeCAD, FreeCADGui, os, Draft, sys, traceback, DraftVecUtils, math

try:
Expand Down Expand Up @@ -2459,6 +2459,7 @@ def __init__(self):

self.stringText = translate("draft","Default")
self.task.leString.setText(self.stringText)
self.platWinDialog(1)
self.task.fcFontFile.setFileName(Draft.getParam("FontFile",""))
self.fileSpec = Draft.getParam("FontFile","")
self.point = FreeCAD.Vector(0.0,0.0,0.0)
Expand Down Expand Up @@ -2530,19 +2531,29 @@ def createObject(self):
except Exception as e:
FreeCAD.Console.PrintError("Draft_ShapeString: error delaying commit\n")

def platWinDialog(self, OnOff):
tDialog = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Dialog")
if platform.system() == 'Windows':
if OnOff == 1:
return tDialog.SetBool("DontUseNativeDialog", True)
else:
return tDialog.SetBool("DontUseNativeDialog", False)

This comment has been minimized.

Copy link
@vocx-fc

vocx-fc Oct 11, 2019

Contributor

@Syres916 This seems like a boolean test. You should probably test like this

if OnOff:
    return tDialog.SetBool("DontUseNativeDialog", True)
else:
    return tDialog.SetBool("DontUseNativeDialog", False)

And the function can be called like

platWinDialog(True)
platWinDialog(False)

Instead of using 1 or 0, it's best to use boolean values True and False.


def accept(self):
self.createObject();
if self.call: self.view.removeEventCallback("SoEvent",self.call)
FreeCADGui.ActiveDocument.resetEdit()
FreeCADGui.Snapper.off()
self.sourceCmd.creator.finish(self.sourceCmd)
self.platWinDialog(0)
return True

def reject(self):
if self.call: self.view.removeEventCallback("SoEvent",self.call)
FreeCADGui.ActiveDocument.resetEdit()
FreeCADGui.Snapper.off()
self.sourceCmd.creator.finish(self.sourceCmd)
self.platWinDialog(0)
return True

if not hasattr(FreeCADGui,"draftToolBar"):
Expand Down

0 comments on commit 867a09f

Please sign in to comment.