Mercurial > projects > dil
changeset 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 | 0934a8274539 5968e273449b |
files | trunk/src/translator/langfile.py trunk/src/translator/project.py trunk/src/translator/translator.py trunk/src/translator/translator.ui trunk/src/translator/ui_translator.py |
diffstat | 5 files changed, 52 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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_)))
--- 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"
--- 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 @@ <property name="title" > <string>&File</string> </property> + <addaction name="action_Open_Project" /> <addaction name="action_New_Project" /> + <addaction name="action_Close_Project" /> <addaction name="separator" /> <addaction name="action_Quit" /> </widget> @@ -67,7 +69,7 @@ </action> <action name="action_New_Project" > <property name="text" > - <string>&New Project</string> + <string>&New Project...</string> </property> <property name="shortcut" > <string>Ctrl+N</string> @@ -85,7 +87,23 @@ </action> <action name="action_Build_Project" > <property name="text" > - <string>Build Project</string> + <string>&Build Project</string> + </property> + </action> + <action name="action_Open_Project" > + <property name="text" > + <string>&Open Project...</string> + </property> + <property name="shortcut" > + <string>Ctrl+O</string> + </property> + </action> + <action name="action_Close_Project" > + <property name="text" > + <string>&Close Project</string> + </property> + <property name="shortcut" > + <string>Ctrl+W</string> </property> </action> </widget>
--- 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))