# HG changeset patch # User Aziz K?ksal # Date 1192222300 -7200 # Node ID cdbb2bf6dd072d2d169d9fcce8827ee1e84320f8 # Parent 2c177053cd15afe73acf21831a81387621202cc8 Translator: applied some fixes and made some additions. diff -r 2c177053cd15 -r cdbb2bf6dd07 trunk/src/translator/langfile.py --- a/trunk/src/translator/langfile.py Fri Oct 12 22:16:21 2007 +0200 +++ b/trunk/src/translator/langfile.py Fri Oct 12 22:51:40 2007 +0200 @@ -2,6 +2,7 @@ # Author: Aziz Köksal # License: GPL2 import exceptions +import yaml class LangFile: class LoadingError(exceptions.Exception): @@ -42,7 +43,7 @@ not msg.has_key("LastEdited"): raise LoadingError("") - def checkType(var, type_, msg=""): + def checkType(self, var, type_, msg=""): if not isinstance(var, type_): raise LoadingError(msg) diff -r 2c177053cd15 -r cdbb2bf6dd07 trunk/src/translator/project.py --- a/trunk/src/translator/project.py Fri Oct 12 22:16:21 2007 +0200 +++ b/trunk/src/translator/project.py Fri Oct 12 22:51:40 2007 +0200 @@ -4,6 +4,7 @@ import langfile import datetime import exceptions +import yaml class Project: class LoadingError(exceptions.Exception): @@ -28,7 +29,7 @@ self.name = doc["Name"] self.source = doc["SourceLangFile"] self.langFilePaths = doc["LangFiles"] - self.msgids = doc["MsgIDs"] + self.msgIDs = doc["MsgIDs"] self.creationDate = doc["CreationDate"] except KeyError, e: raise LoadingError("Missing member '%s' in '%s'" % (e.message, filePath)) @@ -36,7 +37,7 @@ self.checkType(self.name, str) self.checkType(self.source, str) self.checkType(self.langFilePaths, list) - for path in self.langFilesPaths: + for path in self.langFilePaths: self.checkType(path, str) self.checkType(self.msgIDs, list) for msg in self.msgIDs: @@ -52,7 +53,7 @@ for filePath in self.langFilePaths: self.langFiles += LangFile(filePath) - def checkType(var, type_): + def checkType(self, var, type_): if not isinstance(var, type_): raise LoadingException("%s is not of type %s" % (str(var), str(type_))) diff -r 2c177053cd15 -r cdbb2bf6dd07 trunk/src/translator/translator.py --- a/trunk/src/translator/translator.py Fri Oct 12 22:16:21 2007 +0200 +++ b/trunk/src/translator/translator.py Fri Oct 12 22:51:40 2007 +0200 @@ -11,7 +11,7 @@ from ui_about import Ui_AboutDialog from ui_new_project import Ui_NewProjectDialog -import project +from project import Project g_scriptDir = sys.path[0] g_CWD = os.getcwd() @@ -28,6 +28,7 @@ # Custom connections QtCore.QObject.connect(self.action_About, QtCore.SIGNAL("triggered()"), self.showAboutDialog) QtCore.QObject.connect(self.action_New_Project, QtCore.SIGNAL("triggered()"), self.createNewProject) + QtCore.QObject.connect(self.action_Open_Project, QtCore.SIGNAL("triggered()"), self.openProject) self.readSettings() @@ -39,6 +40,11 @@ def createNewProject(self): NewProjectDialog().exec_() + def openProject(self): + filePath = QtGui.QFileDialog.getOpenFileName(self, "Select Project File", g_CWD, "Translator Project (*.tproj)"); + + project = Project(filePath) + def closeEvent(self, event): self.writeSettings() @@ -78,10 +84,9 @@ yaml.dump(g_settings, open(g_settingsFile, "w")) #default_flow_style=False -class ProjectTree(QtGui.QTreeWidget) - QtGui.QTreeWidget.__init__(self) - def __init__(self): - pass +class ProjectTree(QtGui.QTreeWidget): + def __init__(self, parent): + QtGui.QTreeWidget.__init__(self, parent) class NewProjectDialog(QtGui.QDialog, Ui_NewProjectDialog): @@ -92,7 +97,7 @@ QtCore.QObject.connect(self.pickFileButton, QtCore.SIGNAL("clicked()"), self.pickFilePath) def pickFilePath(self): - filePath = QtGui.QFileDialog.getSaveFileName(self, "Select Project File", g_CWD, "Translator Project (*.tproj)"); + filePath = QtGui.QFileDialog.getSaveFileName(self, "New Project File", g_CWD, "Translator Project (*.tproj)"); filePath = str(filePath) # Convert QString if os.path.splitext(filePath)[1] != ".tproj": filePath += ".tproj" diff -r 2c177053cd15 -r cdbb2bf6dd07 trunk/src/translator/translator.ui --- a/trunk/src/translator/translator.ui Fri Oct 12 22:16:21 2007 +0200 +++ b/trunk/src/translator/translator.ui Fri Oct 12 22:51:40 2007 +0200 @@ -28,7 +28,9 @@ &File + + @@ -67,7 +69,7 @@ - &New Project + &New Project... Ctrl+N @@ -85,7 +87,23 @@ - Build Project + &Build Project + + + + + &Open Project... + + + Ctrl+O + + + + + &Close Project + + + Ctrl+W diff -r 2c177053cd15 -r cdbb2bf6dd07 trunk/src/translator/ui_translator.py --- a/trunk/src/translator/ui_translator.py Fri Oct 12 22:16:21 2007 +0200 +++ b/trunk/src/translator/ui_translator.py Fri Oct 12 22:51:40 2007 +0200 @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'translator.ui' # -# Created: Fri Oct 12 22:15:30 2007 +# Created: Fri Oct 12 22:49:36 2007 # by: PyQt4 UI code generator 4.1 # # WARNING! All changes made in this file will be lost! @@ -57,7 +57,15 @@ self.action_Build_Project = QtGui.QAction(MainWindow) self.action_Build_Project.setObjectName("action_Build_Project") + + self.action_Open_Project = QtGui.QAction(MainWindow) + self.action_Open_Project.setObjectName("action_Open_Project") + + self.action_Close_Project = QtGui.QAction(MainWindow) + self.action_Close_Project.setObjectName("action_Close_Project") + self.menu_File.addAction(self.action_Open_Project) self.menu_File.addAction(self.action_New_Project) + self.menu_File.addAction(self.action_Close_Project) self.menu_File.addSeparator() self.menu_File.addAction(self.action_Quit) self.menu_Help.addAction(self.action_About) @@ -81,9 +89,13 @@ self.action_Quit.setText(QtGui.QApplication.translate("MainWindow", "&Quit", None, QtGui.QApplication.UnicodeUTF8)) self.action_Quit.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+Q", None, QtGui.QApplication.UnicodeUTF8)) self.action_About.setText(QtGui.QApplication.translate("MainWindow", "&About", None, QtGui.QApplication.UnicodeUTF8)) - self.action_New_Project.setText(QtGui.QApplication.translate("MainWindow", "&New Project", None, QtGui.QApplication.UnicodeUTF8)) + self.action_New_Project.setText(QtGui.QApplication.translate("MainWindow", "&New Project...", None, QtGui.QApplication.UnicodeUTF8)) self.action_New_Project.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+N", None, QtGui.QApplication.UnicodeUTF8)) self.action_Add_catalogue.setText(QtGui.QApplication.translate("MainWindow", "&Add catalogue", None, QtGui.QApplication.UnicodeUTF8)) self.action_Properties.setText(QtGui.QApplication.translate("MainWindow", "&Properties", None, QtGui.QApplication.UnicodeUTF8)) - self.action_Build_Project.setText(QtGui.QApplication.translate("MainWindow", "Build Project", None, QtGui.QApplication.UnicodeUTF8)) + self.action_Build_Project.setText(QtGui.QApplication.translate("MainWindow", "&Build Project", None, QtGui.QApplication.UnicodeUTF8)) + self.action_Open_Project.setText(QtGui.QApplication.translate("MainWindow", "&Open Project...", None, QtGui.QApplication.UnicodeUTF8)) + self.action_Open_Project.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+O", None, QtGui.QApplication.UnicodeUTF8)) + self.action_Close_Project.setText(QtGui.QApplication.translate("MainWindow", "&Close Project", None, QtGui.QApplication.UnicodeUTF8)) + self.action_Close_Project.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+W", None, QtGui.QApplication.UnicodeUTF8))