comparison trunk/src/translator/translator.py @ 439:cdbb2bf6dd07

Translator: applied some fixes and made some additions.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Fri, 12 Oct 2007 22:51:40 +0200
parents 2c177053cd15
children 5968e273449b
comparison
equal deleted inserted replaced
438:2c177053cd15 439:cdbb2bf6dd07
9 # User interface modules 9 # User interface modules
10 from ui_translator import Ui_MainWindow 10 from ui_translator import Ui_MainWindow
11 from ui_about import Ui_AboutDialog 11 from ui_about import Ui_AboutDialog
12 from ui_new_project import Ui_NewProjectDialog 12 from ui_new_project import Ui_NewProjectDialog
13 13
14 import project 14 from project import Project
15 15
16 g_scriptDir = sys.path[0] 16 g_scriptDir = sys.path[0]
17 g_CWD = os.getcwd() 17 g_CWD = os.getcwd()
18 g_settingsFile = os.path.join(g_scriptDir, "settings.yaml") 18 g_settingsFile = os.path.join(g_scriptDir, "settings.yaml")
19 g_settings = {} 19 g_settings = {}
26 # Modifications 26 # Modifications
27 27
28 # Custom connections 28 # Custom connections
29 QtCore.QObject.connect(self.action_About, QtCore.SIGNAL("triggered()"), self.showAboutDialog) 29 QtCore.QObject.connect(self.action_About, QtCore.SIGNAL("triggered()"), self.showAboutDialog)
30 QtCore.QObject.connect(self.action_New_Project, QtCore.SIGNAL("triggered()"), self.createNewProject) 30 QtCore.QObject.connect(self.action_New_Project, QtCore.SIGNAL("triggered()"), self.createNewProject)
31 QtCore.QObject.connect(self.action_Open_Project, QtCore.SIGNAL("triggered()"), self.openProject)
31 32
32 self.readSettings() 33 self.readSettings()
33 34
34 def showAboutDialog(self): 35 def showAboutDialog(self):
35 about = QtGui.QDialog() 36 about = QtGui.QDialog()
36 Ui_AboutDialog().setupUi(about) 37 Ui_AboutDialog().setupUi(about)
37 about.exec_() 38 about.exec_()
38 39
39 def createNewProject(self): 40 def createNewProject(self):
40 NewProjectDialog().exec_() 41 NewProjectDialog().exec_()
42
43 def openProject(self):
44 filePath = QtGui.QFileDialog.getOpenFileName(self, "Select Project File", g_CWD, "Translator Project (*.tproj)");
45
46 project = Project(filePath)
41 47
42 def closeEvent(self, event): 48 def closeEvent(self, event):
43 self.writeSettings() 49 self.writeSettings()
44 50
45 def moveToCenterOfDesktop(self): 51 def moveToCenterOfDesktop(self):
76 "Size" : [self.size().width(), self.size().height()] 82 "Size" : [self.size().width(), self.size().height()]
77 } 83 }
78 yaml.dump(g_settings, open(g_settingsFile, "w")) #default_flow_style=False 84 yaml.dump(g_settings, open(g_settingsFile, "w")) #default_flow_style=False
79 85
80 86
81 class ProjectTree(QtGui.QTreeWidget) 87 class ProjectTree(QtGui.QTreeWidget):
82 QtGui.QTreeWidget.__init__(self) 88 def __init__(self, parent):
83 def __init__(self): 89 QtGui.QTreeWidget.__init__(self, parent)
84 pass
85 90
86 91
87 class NewProjectDialog(QtGui.QDialog, Ui_NewProjectDialog): 92 class NewProjectDialog(QtGui.QDialog, Ui_NewProjectDialog):
88 def __init__(self): 93 def __init__(self):
89 QtGui.QDialog.__init__(self) 94 QtGui.QDialog.__init__(self)
90 self.setupUi(self) 95 self.setupUi(self)
91 96
92 QtCore.QObject.connect(self.pickFileButton, QtCore.SIGNAL("clicked()"), self.pickFilePath) 97 QtCore.QObject.connect(self.pickFileButton, QtCore.SIGNAL("clicked()"), self.pickFilePath)
93 98
94 def pickFilePath(self): 99 def pickFilePath(self):
95 filePath = QtGui.QFileDialog.getSaveFileName(self, "Select Project File", g_CWD, "Translator Project (*.tproj)"); 100 filePath = QtGui.QFileDialog.getSaveFileName(self, "New Project File", g_CWD, "Translator Project (*.tproj)");
96 filePath = str(filePath) # Convert QString 101 filePath = str(filePath) # Convert QString
97 if os.path.splitext(filePath)[1] != ".tproj": 102 if os.path.splitext(filePath)[1] != ".tproj":
98 filePath += ".tproj" 103 filePath += ".tproj"
99 self.projectFilePath.setText(filePath) 104 self.projectFilePath.setText(filePath)
100 105