Move printMessage in ArchCommands.

Messages are translatable.
This commit is contained in:
Jonathan Wiedemann 2016-07-24 16:09:34 +02:00 committed by Yorik van Havre
parent 15b70be51b
commit 41307ef5a1
4 changed files with 34 additions and 33 deletions

View File

@ -1,3 +1,5 @@
# -*- coding: utf8 -*-
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
@ -214,15 +216,15 @@ class _CommandBuilding:
else: else:
warning = True warning = True
if warning : if warning :
message = "You can put anything but Site and Building object in a Building object.\n\ message = translate( "Arch" , "You can put anything but Site and Building object in a Building object.\n\
Building object are not allowed to accept Site and Building object.\n\ Building object are not allowed to accept Site and Building object.\n\
Site and Building objects will be removed from the selection.\n\ Site and Building objects will be removed from the selection.\n\
You can change that in the preferences.\n" You can change that in the preferences.\n" )
self.printMessage( message ) ArchCommands.printMessage( message )
if sel and len(buildingobj) == 0: if sel and len(buildingobj) == 0:
message = "There is no valid object in the selection.\n\ message = translate( "Arch" , "There is no valid object in the selection.\n\
Building creation aborted.\n" Building creation aborted.\n" )
self.printMessage( message ) ArchCommands.printMessage( message )
else : else :
ss = "[ " ss = "[ "
for o in buildingobj: for o in buildingobj:
@ -234,11 +236,6 @@ Building creation aborted.\n"
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
def printMessage(self, message):
FreeCAD.Console.PrintMessage(translate("Arch", message))
if FreeCAD.GuiUp :
reply = QtGui.QMessageBox.information(None,"", message)
class _Building(ArchFloor._Floor): class _Building(ArchFloor._Floor):
"The Building object" "The Building object"
def __init__(self,obj): def __init__(self,obj):

View File

@ -937,6 +937,16 @@ def getExtrusionData(shape):
return [faces[p[0]][0],faces[p[1]][0].CenterOfMass.sub(faces[p[0]][0].CenterOfMass)] return [faces[p[0]][0],faces[p[1]][0].CenterOfMass.sub(faces[p[0]][0].CenterOfMass)]
return None return None
def printMessage( message ):
FreeCAD.Console.PrintMessage( message )
if FreeCAD.GuiUp :
reply = QtGui.QMessageBox.information( None , "" , message.decode('utf8') )
def printWarning( message ):
FreeCAD.Console.PrintMessage( message )
if FreeCAD.GuiUp :
reply = QtGui.QMessageBox.warning( None , "" , message.decode('utf8') )
# command definitions ############################################### # command definitions ###############################################

View File

@ -1,3 +1,5 @@
# -*- coding: utf8 -*-
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
@ -72,15 +74,15 @@ class _CommandFloor:
else: else:
warning = True warning = True
if warning : if warning :
message = "You can put anything but Site, Building, Floor object in a Floor object.\n\ message = translate( "Arch" , "You can put anything but Site, Building, Floor object in a Floor object.\n\
Floor object are not allowed to accept Site or Building object.\n\ Floor object are not allowed to accept Site or Building object.\n\
Site, Building and Floor objects will be removed from the selection.\n\ Site, Building and Floor objects will be removed from the selection.\n\
You can change that in the preferences.\n" You can change that in the preferences.\n" )
self.printMessage( message ) ArchCommands.printMessage( message )
if sel and len(floorobj) == 0: if sel and len(floorobj) == 0:
message = "There is no valid object in the selection.\n\ message = translate( "Arch" , "There is no valid object in the selection.\n\
Floor creation aborted.\n" Floor creation aborted.\n" )
self.printMessage( message ) ArchCommands.printMessage( message )
else : else :
ss = "[ " ss = "[ "
for o in floorobj: for o in floorobj:
@ -92,11 +94,6 @@ Floor creation aborted.\n"
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
def printMessage(self, message):
FreeCAD.Console.PrintMessage(translate("Arch", message))
if FreeCAD.GuiUp :
reply = QtGui.QMessageBox.information(None,"", message)
class _Floor: class _Floor:
"The Floor object" "The Floor object"
def __init__(self,obj): def __init__(self,obj):

View File

@ -1,3 +1,5 @@
# -*- coding: utf8 -*-
#*************************************************************************** #***************************************************************************
#* * #* *
#* Copyright (c) 2011 * #* Copyright (c) 2011 *
@ -74,15 +76,15 @@ class _CommandSite:
else: else:
warning = True warning = True
if warning : if warning :
message = "Please select only Building objects or nothing!\n\ message = translate( "Arch" , "Please select only Building objects or nothing!\n\
Site are not allowed to accept other object than Building.\n\ Site are not allowed to accept other object than Building.\n\
Other objects will be removed from the selection.\n\ Other objects will be removed from the selection.\n\
You can change that in the preferences." You can change that in the preferences." )
self.printMessage( message ) ArchCommands.printMessage( message )
if sel and len(siteobj) == 0: if sel and len(siteobj) == 0:
message = "There is no valid object in the selection.\n\ message = translate( "Arch" , "There is no valid object in the selection.\n\
Site creation aborted." Site creation aborted." )
self.printMessage( message ) ArchCommands.printMessage( message )
else : else :
ss = "[ " ss = "[ "
for o in siteobj: for o in siteobj:
@ -94,11 +96,6 @@ Site creation aborted."
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
def printMessage(self, message):
FreeCAD.Console.PrintMessage(translate("Arch", message))
if FreeCAD.GuiUp :
reply = QtGui.QMessageBox.information(None,"", message)
class _Site(ArchFloor._Floor): class _Site(ArchFloor._Floor):
"The Site object" "The Site object"
def __init__(self,obj): def __init__(self,obj):