PySide2: qApp -> QApplication

This commit is contained in:
looooo
2018-04-12 17:03:30 +02:00
committed by wmayer
parent 0bd9f17baf
commit be5ea8391c
33 changed files with 63 additions and 63 deletions

View File

@@ -828,9 +828,9 @@ def survey(callback=False):
FreeCAD.SurveyDialog.update(1,t)
if FreeCAD.GuiUp and t:
if showUnit:
QtGui.qApp.clipboard().setText(t)
QtGui.QApplication.clipboard().setText(t)
else:
QtGui.qApp.clipboard().setText(str(u.Value))
QtGui.QApplication.clipboard().setText(str(u.Value))
else:
# single element(s)
for el in o.SubElementNames:
@@ -870,9 +870,9 @@ def survey(callback=False):
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: " + el + ", Zcoord: " + utf8_decode(t) + "\n")
if FreeCAD.GuiUp and t:
if showUnit:
QtGui.qApp.clipboard().setText(t)
QtGui.QApplication.clipboard().setText(t)
else:
QtGui.qApp.clipboard().setText(str(u.Value))
QtGui.QApplication.clipboard().setText(str(u.Value))
FreeCAD.SurveyObserver.selection.extend(newsels)
if hasattr(FreeCAD,"SurveyObserver"):
@@ -990,9 +990,9 @@ class SurveyTaskPanel:
t = u.getUserPreferred()[0]
t = t.encode("utf8")
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("surveyUnits",True):
QtGui.qApp.clipboard().setText(t)
QtGui.QApplication.clipboard().setText(t)
else:
QtGui.qApp.clipboard().setText(str(u.Value/u.getUserPreferred()[1]))
QtGui.QApplication.clipboard().setText(str(u.Value/u.getUserPreferred()[1]))
def clipArea(self):
if hasattr(FreeCAD,"SurveyObserver"):
@@ -1000,9 +1000,9 @@ class SurveyTaskPanel:
t = u.getUserPreferred()[0]
t = t.encode("utf8").replace("^2","²")
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("surveyUnits",True):
QtGui.qApp.clipboard().setText(t)
QtGui.QApplication.clipboard().setText(t)
else:
QtGui.qApp.clipboard().setText(str(u.Value/u.getUserPreferred()[1]))
QtGui.QApplication.clipboard().setText(str(u.Value/u.getUserPreferred()[1]))
def newline(self,length=0,area=0):
FreeCADGui.Selection.clearSelection()
@@ -1050,7 +1050,7 @@ class SurveyTaskPanel:
import csv
rows = self.tree.topLevelItemCount()
if rows:
filename = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(), translate("Arch","Export CSV File"), None, "CSV file (*.csv)");
filename = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(), translate("Arch","Export CSV File"), None, "CSV file (*.csv)");
if filename:
with open(filename[0].encode("utf8"), 'wb') as csvfile:
csvfile = csv.writer(csvfile,delimiter="\t")

View File

@@ -116,7 +116,7 @@ class Nester:
self.setCounter(self.progress)
if FreeCAD.GuiUp:
from PySide import QtGui
QtGui.qApp.processEvents()
QtGui.QApplication.processEvents()
if not self.running:
return False
return True

View File

@@ -1344,7 +1344,7 @@ class NestTaskPanel:
self.form.ButtonStop.setEnabled(True)
self.form.ButtonStart.setEnabled(False)
self.form.ButtonPreview.setEnabled(False)
QtGui.qApp.processEvents()
QtGui.QApplication.processEvents()
result = self.nester.run()
self.form.progressBar.hide()
self.form.ButtonStart.setEnabled(True)

View File

@@ -314,7 +314,7 @@ class _ArchScheduleTaskPanel:
self.form.list.setRowCount(0)
def importCSV(self):
filename = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(), translate("Arch","Import CSV File"), None, "CSV file (*.csv)");
filename = QtGui.QFileDialog.getOpenFileName(QtGui.QApplication.activeWindow(), translate("Arch","Import CSV File"), None, "CSV file (*.csv)");
if filename:
self.form.list.clearContents()
import csv
@@ -333,7 +333,7 @@ class _ArchScheduleTaskPanel:
def exportCSV(self):
if self.obj:
if self.obj.Result:
filename = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(), translate("Arch","Export CSV File"), None, "CSV file (*.csv)");
filename = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(), translate("Arch","Export CSV File"), None, "CSV file (*.csv)");
if filename:
# the following line crashes, couldn't fnid out why
# self.obj.Result.exportFile(str(filename[0].encode("utf8")))

View File

@@ -184,7 +184,7 @@ def explore(filename=None):
if not filename:
from PySide import QtGui
filename = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),'IFC files','*.ifc')
filename = QtGui.QFileDialog.getOpenFileName(QtGui.QApplication.activeWindow(),'IFC files','*.ifc')
if filename:
filename = filename[0]

View File

@@ -1388,7 +1388,7 @@ def explore(filename=None):
"explore the contents of an ifc file in a Qt dialog"
if not filename:
from PySide import QtGui
filename = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),'IFC files','*.ifc')
filename = QtGui.QFileDialog.getOpenFileName(QtGui.QApplication.activeWindow(),'IFC files','*.ifc')
if filename:
filename = filename[0]
if filename:

View File

@@ -252,7 +252,7 @@ class _TaskPanelFemResultShow:
self.mesh_obj.ViewObject.setNodeColorByScalars(self.result_obj.NodeNumbers, self.result_obj.StressValues)
(minm, avg, maxm) = self.get_result_stats("Sabs")
self.set_result_stats("MPa", minm, avg, maxm)
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def max_shear_selected(self, state):
FreeCAD.FEM_dialog["results_type"] = "MaxShear"
@@ -261,7 +261,7 @@ class _TaskPanelFemResultShow:
self.mesh_obj.ViewObject.setNodeColorByScalars(self.result_obj.NodeNumbers, self.result_obj.MaxShear)
(minm, avg, maxm) = self.get_result_stats("MaxShear")
self.set_result_stats("MPa", minm, avg, maxm)
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def max_prin_selected(self, state):
FreeCAD.FEM_dialog["results_type"] = "MaxPrin"
@@ -270,7 +270,7 @@ class _TaskPanelFemResultShow:
self.mesh_obj.ViewObject.setNodeColorByScalars(self.result_obj.NodeNumbers, self.result_obj.PrincipalMax)
(minm, avg, maxm) = self.get_result_stats("MaxPrin")
self.set_result_stats("MPa", minm, avg, maxm)
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def temperature_selected(self, state):
FreeCAD.FEM_dialog["results_type"] = "Temp"
@@ -279,7 +279,7 @@ class _TaskPanelFemResultShow:
self.mesh_obj.ViewObject.setNodeColorByScalars(self.result_obj.NodeNumbers, self.result_obj.Temperature)
(minm, avg, maxm) = self.get_result_stats("Temp")
self.set_result_stats("K", minm, avg, maxm)
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def massflowrate_selected(self, state):
FreeCAD.FEM_dialog["results_type"] = "MFlow"
@@ -288,7 +288,7 @@ class _TaskPanelFemResultShow:
self.mesh_obj.ViewObject.setNodeColorByScalars(self.result_obj.NodeNumbers, self.result_obj.MassFlowRate)
(minm, avg, maxm) = self.get_result_stats("MFlow")
self.set_result_stats("kg/s", minm, avg, maxm)
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def networkpressure_selected(self, state):
FreeCAD.FEM_dialog["results_type"] = "NPress"
@@ -297,7 +297,7 @@ class _TaskPanelFemResultShow:
self.mesh_obj.ViewObject.setNodeColorByScalars(self.result_obj.NodeNumbers, self.result_obj.NetworkPressure)
(minm, avg, maxm) = self.get_result_stats("NPress")
self.set_result_stats("MPa", minm, avg, maxm)
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def min_prin_selected(self, state):
FreeCAD.FEM_dialog["results_type"] = "MinPrin"
@@ -306,7 +306,7 @@ class _TaskPanelFemResultShow:
self.mesh_obj.ViewObject.setNodeColorByScalars(self.result_obj.NodeNumbers, self.result_obj.PrincipalMin)
(minm, avg, maxm) = self.get_result_stats("MinPrin")
self.set_result_stats("MPa", minm, avg, maxm)
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def peeq_selected(self, state):
FreeCAD.FEM_dialog["results_type"] = "Peeq"
@@ -315,7 +315,7 @@ class _TaskPanelFemResultShow:
self.mesh_obj.ViewObject.setNodeColorByScalars(self.result_obj.NodeNumbers, self.result_obj.Peeq)
(minm, avg, maxm) = self.get_result_stats("Peeq")
self.set_result_stats("", minm, avg, maxm)
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def user_defined_text(self, equation):
FreeCAD.FEM_dialog["results_type"] = "user"
@@ -357,7 +357,7 @@ class _TaskPanelFemResultShow:
if self.suitable_results:
self.mesh_obj.ViewObject.setNodeColorByScalars(self.result_obj.NodeNumbers, UserDefinedFormula)
self.set_result_stats("", minm, avg, maxm)
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
del x, y, z, T, Von, Peeq, P1, P2, P3, sx, sy, sz, ex, ey, ez, MF, NP # Dummy use of the variables to get around flake8 error
def select_displacement_type(self, disp_type):
@@ -373,7 +373,7 @@ class _TaskPanelFemResultShow:
self.mesh_obj.ViewObject.setNodeColorByScalars(self.result_obj.NodeNumbers, displacements)
(minm, avg, maxm) = self.get_result_stats(disp_type)
self.set_result_stats("mm", minm, avg, maxm)
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def set_result_stats(self, unit, minm, avg, maxm):
self.form.le_min.setProperty("unit", unit)
@@ -401,7 +401,7 @@ class _TaskPanelFemResultShow:
if self.suitable_results:
self.mesh_obj.ViewObject.setNodeDisplacementByVectors(self.result_obj.NodeNumbers, self.result_obj.DisplacementVectors)
self.update_displacement()
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def hsb_disp_factor_changed(self, value):
self.form.sb_displacement_factor.setValue(value)

View File

@@ -142,13 +142,13 @@ def export(objs,filename):
if os.path.exists(outfpath_stp):
sayzw("File cannot be compressed because a file with the same name exists '"+ outfpath_stp +"'")
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
reply = QtGui.QMessageBox.information(None,"info", "File cannot be compressed because\na file with the same name exists\n'"+ outfpath_stp + "'")
else:
ImportGui.export(objs,outfpath_stp)
if 0: #os.path.exists(namefpath):
sayzw("File cannot be compressed because a file with the same name exists '" + namefpath + "'")
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
reply = QtGui.QMessageBox.information(None,"info", "File cannot be compressed because\na file with the same name exists\n'"+ namefpath+ "'")
else:
with builtin.open(outfpath_stp, 'rb') as f_in:

View File

@@ -261,7 +261,7 @@ class MaterialEditor:
def openfile(self):
"Opens a FCMat file"
filename = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),'Open FreeCAD Material file','*.FCMat')
filename = QtGui.QFileDialog.getOpenFileName(QtGui.QApplication.activeWindow(),'Open FreeCAD Material file','*.FCMat')
if filename:
self.clearEditor()
import importFCMat
@@ -275,7 +275,7 @@ class MaterialEditor:
name = str(self.widget.Editor.findItems(translate("Material","Name"),QtCore.Qt.MatchRecursive,0)[0].text(1))
if not name:
name = "Material"
filename = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(),'Save FreeCAD Material file',name+'.FCMat')
filename = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(),'Save FreeCAD Material file',name+'.FCMat')
if filename:
d = self.getDict()
if d:

View File

@@ -30,10 +30,10 @@ from ViewProviderHole import ViewProviderHole
class HoleGui:
def getMainWindow(self):
"returns the main window"
# using QtGui.qApp.activeWindow() isn't very reliable because if another
# using QtGui.QApplication.activeWindow() isn't very reliable because if another
# widget than the mainwindow is active (e.g. a dialog) the wrong widget is
# returned
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -82,10 +82,10 @@ class TaskHole:
def getMainWindow(self):
"returns the main window"
# using QtGui.qApp.activeWindow() isn't very reliable because if another
# using QtGui.QApplication.activeWindow() isn't very reliable because if another
# widget than the mainwindow is active (e.g. a dialog) the wrong widget is
# returned
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -13,10 +13,10 @@ def proceed():
compute()
except:
hide()
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
def compute():
QtGui.qApp.setOverrideCursor(QtCore.Qt.WaitCursor)
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
if FreeCAD.ActiveDocument==None:
FreeCAD.newDocument("Gear")
@@ -232,7 +232,7 @@ def compute():
App.ActiveDocument.recompute()
Gui.SendMsgToActiveView("ViewFit")
QtGui.qApp.restoreOverrideCursor()
QtGui.QApplication.restoreOverrideCursor()
hide()

View File

@@ -31,7 +31,7 @@ class TaskWizardShaft:
Gui = FreeCADGui
def __init__(self, doc):
mw = QtGui.qApp.activeWindow()
mw = QtGui.QApplication.activeWindow()
#cw = mw.centralWidget() # This is a qmdiarea widget
cw = mw.findChild(QtGui.QMdiArea)
self.doc = doc
@@ -87,7 +87,7 @@ class TaskWizardShaft:
self.form.setLayout(layout)
# Switch to feature window
mdi=QtGui.qApp.activeWindow().findChild(QtGui.QMdiArea)
mdi=QtGui.QApplication.activeWindow().findChild(QtGui.QMdiArea)
cw.setActiveSubWindow(featureWindow)
def slotAllx(self):

View File

@@ -247,7 +247,7 @@ class CommandJobTemplateExport:
job = self.GetJob()
dialog = DlgJobTemplateExport(job)
if dialog.exec_() == 1:
foo = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(),
foo = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(),
"Path - Job Template",
PathPreferences.filePath(),
"job_*.json")[0]

View File

@@ -137,7 +137,7 @@ class CommandPathPost:
filename = "%s%03d%s" % (fn, n, ext)
if openDialog:
foo = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(), "Output File", filename)
foo = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(), "Output File", filename)
if foo:
filename = foo[0]
else:

View File

@@ -279,7 +279,7 @@ class JobPreferencesPage:
path = self.form.leDefaultJobTemplate.text()
if not path:
path = self.bestGuessForFilePath()
foo = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),
foo = QtGui.QFileDialog.getOpenFileName(QtGui.QApplication.activeWindow(),
"Path - Job Template",
path,
"job_*.json")[0]
@@ -289,13 +289,13 @@ class JobPreferencesPage:
def browseDefaultFilePath(self):
path = self.bestGuessForFilePath()
foo = QtGui.QFileDialog.getExistingDirectory(QtGui.qApp.activeWindow(), "Path - External File Directory", path)
foo = QtGui.QFileDialog.getExistingDirectory(QtGui.QApplication.activeWindow(), "Path - External File Directory", path)
if foo:
self.form.leDefaultFilePath.setText(foo)
def browseOutputFile(self):
path = self.form.leOutputFile.text()
foo = QtGui.QFileDialog.getExistingDirectory(QtGui.qApp.activeWindow(), "Path - Output File/Directory", path)
foo = QtGui.QFileDialog.getExistingDirectory(QtGui.QApplication.activeWindow(), "Path - Output File/Directory", path)
if foo:
self.form.leOutputFile.setText(foo)

View File

@@ -151,7 +151,7 @@ class TaskPanel:
return False
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -110,7 +110,7 @@ class TaskPanel:
return False
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -99,7 +99,7 @@ class TaskPanel:
return False
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -105,7 +105,7 @@ class TaskPanel:
return False
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -127,7 +127,7 @@ class TaskPanel:
return False
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -119,7 +119,7 @@ class TaskPanel:
self.onData)
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -93,7 +93,7 @@ class TaskPanel:
self.retranslateUi()
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -107,7 +107,7 @@ class TaskPanel:
self.onData)
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -82,7 +82,7 @@ class TaskPanel:
self.retranslateUi()
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -86,7 +86,7 @@ class TaskPanel:
self.retranslateUi()
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -106,7 +106,7 @@ class TaskPanel:
self.retranslateUi()
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -165,7 +165,7 @@ class TaskPanel:
self.onData)
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -84,7 +84,7 @@ class TaskPanel:
self.retranslateUi()
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -166,7 +166,7 @@ class TaskPanel:
self.TSections,
self.ship.Shape)
def getMainWindow(self):
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i

View File

@@ -207,7 +207,7 @@ def setColors(html):
"#windowcolor":"#FFFFFF",
"#windowtextcolor":"#000000"}
try:
palette = QtGui.qApp.palette()
palette = QtGui.QApplication.palette()
except:
pass
else:

View File

@@ -14,7 +14,7 @@ def makeSnapshotWithGui():
import FreeCADGui
def getMainWindow():
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
@@ -37,7 +37,7 @@ def makeSnapshotWithGui():
view.saveImage('crystal.png',800,600,'Current')
FreeCAD.closeDocument(doc.Name)
# close the application
QtGui.qApp.quit()
QtGui.QApplication.quit()
def makeSnapshotWithoutGui():
from pivy import coin

View File

@@ -77,10 +77,10 @@ class TaskPanel:
def getMainWindow(self):
"returns the main window"
# using QtGui.qApp.activeWindow() isn't very reliable because if another
# using QtGui.QApplication.activeWindow() isn't very reliable because if another
# widget than the mainwindow is active (e.g. a dialog) the wrong widget is
# returned
toplevel = QtGui.qApp.topLevelWidgets()
toplevel = QtGui.QApplication.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i