Mercurial > projects > dil
changeset 482:1401e38d1e2e
Translator: implemented project properties dialog.
Added language file properties dialog.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 17 Nov 2007 23:16:12 +0100 |
parents | 04adc4e3fdda |
children | 180711cc4b66 |
files | trunk/AUTHORS trunk/src/translator/langfile_properties.ui trunk/src/translator/project.py trunk/src/translator/project_properties.ui trunk/src/translator/translator.py trunk/src/translator/ui_langfile_properties.py trunk/src/translator/ui_project_properties.py |
diffstat | 7 files changed, 326 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/AUTHORS Wed Nov 14 22:07:50 2007 +0100 +++ b/trunk/AUTHORS Sat Nov 17 23:16:12 2007 +0100 @@ -2,8 +2,8 @@ Aziz Köksal <aziz.koeksal@gmail.com> "All rights to the code I've written will pass over to Jari-Matti Mäkelä, in case I catch the bus or the bus catches me. - My death won't probably be announced anywhere on - the internet, therefore my testament will become effective if I don't + My death will probably not be made known anywhere on the internet, + therefore my testament will become effective if I don't show any signs of life for 6 months on the internet. Within this time limit I may always revoke or edit this testament, by committing to the hg repository at http://hg.sharesource.org/dil/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/translator/langfile_properties.ui Sat Nov 17 23:16:12 2007 +0100 @@ -0,0 +1,128 @@ +<ui version="4.0" > + <class>LangFilePropertiesDialog</class> + <widget class="QDialog" name="LangFilePropertiesDialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>228</height> + </rect> + </property> + <property name="windowTitle" > + <string>Language File Properties</string> + </property> + <layout class="QVBoxLayout" > + <item> + <layout class="QGridLayout" > + <item row="1" column="0" > + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Language code:</string> + </property> + <property name="alignment" > + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="buddy" > + <cstring>langCodeField</cstring> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="langCodeField" /> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>Creation date:</string> + </property> + <property name="alignment" > + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="buddy" > + <cstring>creationDateField</cstring> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="creationDateField" /> + </item> + <item row="0" column="1" > + <widget class="QTextEdit" name="authorsField" /> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="label_3" > + <property name="text" > + <string>Author(s):</string> + </property> + <property name="alignment" > + <set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>10</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons" > + <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>LangFilePropertiesDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>227</x> + <y>278</y> + </hint> + <hint type="destinationlabel" > + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>LangFilePropertiesDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>295</x> + <y>284</y> + </hint> + <hint type="destinationlabel" > + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- a/trunk/src/translator/project.py Wed Nov 14 22:07:50 2007 +0100 +++ b/trunk/src/translator/project.py Sat Nov 17 23:16:12 2007 +0100 @@ -94,8 +94,16 @@ def setName(self, name): self.name = name + def setBuildScript(self, filePath): + self.buildScript = filePath + + def setCreationDate(self, date): + self.creationDate = date + def save(self): self.doc["Name"] = self.name + self.doc["BuildScript"] = self.buildScript + self.doc["CreationDate"] = self.creationDate file_ = open(self.projectPath, "w") yaml.dump(self.doc, stream=file_, allow_unicode=True) file_.close()
--- a/trunk/src/translator/project_properties.ui Wed Nov 14 22:07:50 2007 +0100 +++ b/trunk/src/translator/project_properties.ui Sat Nov 17 23:16:12 2007 +0100 @@ -1,12 +1,12 @@ <ui version="4.0" > - <class>ProjectProperties</class> - <widget class="QDialog" name="ProjectProperties" > + <class>ProjectPropertiesDialog</class> + <widget class="QDialog" name="ProjectPropertiesDialog" > <property name="geometry" > <rect> <x>0</x> <y>0</y> <width>400</width> - <height>148</height> + <height>152</height> </rect> </property> <property name="windowTitle" > @@ -34,18 +34,42 @@ <item row="1" column="0" > <widget class="QLabel" name="label" > <property name="text" > - <string>Build command:</string> + <string>Build script:</string> </property> <property name="alignment" > <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> <property name="buddy" > - <cstring>buildCommandField</cstring> + <cstring>buildScriptField</cstring> </property> </widget> </item> <item row="1" column="1" > - <widget class="QLineEdit" name="buildCommandField" /> + <layout class="QHBoxLayout" > + <item> + <widget class="QLineEdit" name="buildScriptField" /> + </item> + <item> + <widget class="QToolButton" name="pickFileButton" > + <property name="text" > + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="creationDateField" /> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="label_3" > + <property name="text" > + <string>Creation date:</string> + </property> + <property name="alignment" > + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> </item> </layout> </item> @@ -79,7 +103,7 @@ <connection> <sender>buttonBox</sender> <signal>accepted()</signal> - <receiver>ProjectProperties</receiver> + <receiver>ProjectPropertiesDialog</receiver> <slot>accept()</slot> <hints> <hint type="sourcelabel" > @@ -95,7 +119,7 @@ <connection> <sender>buttonBox</sender> <signal>rejected()</signal> - <receiver>ProjectProperties</receiver> + <receiver>ProjectPropertiesDialog</receiver> <slot>reject()</slot> <hints> <hint type="sourcelabel" >
--- a/trunk/src/translator/translator.py Wed Nov 14 22:07:50 2007 +0100 +++ b/trunk/src/translator/translator.py Sat Nov 17 23:16:12 2007 +0100 @@ -10,7 +10,7 @@ from ui_translator import Ui_MainWindow from ui_about import Ui_AboutDialog from ui_new_project import Ui_NewProjectDialog -from ui_project_properties import Ui_ProjectProperties +from ui_project_properties import Ui_ProjectPropertiesDialog from ui_msg_form import Ui_MsgForm from ui_closing_project import Ui_ClosingProjectDialog @@ -94,9 +94,9 @@ about.exec_() def showProjectProperties(self): - dialog = QtGui.QDialog() - Ui_ProjectProperties().setupUi(dialog) + dialog = ProjectPropertiesDialog(self.project) dialog.exec_() + self.projectTree.updateProjectName() def createNewProject(self): if self.rejectClosingProject(): @@ -133,6 +133,8 @@ def addCatalogue(self): filePath = QtGui.QFileDialog.getOpenFileName(self, "Select Project File", g_CWD, "Catalogue (*%s)" % g_catExt); filePath = str(filePath) + # TODO: + #self.project.addLangFile(filePath) def addNewCatalogue(self): pass @@ -499,8 +501,11 @@ self.topItem = None self.msgIDsItem = None self.headerItem().setHidden(True) + self.ignoreItemChanged = False def itemChanged(self, item, column): + if self.ignoreItemChanged: + return text = unicode(item.text(0)) #if hasattr(item, "textChanged"): #item.textChanged(text) @@ -554,6 +559,11 @@ def showMenuMsgIDItem(self, item): print "MsgIDItem" + def updateProjectName(self): + self.ignoreItemChanged = True + self.topItem.setText(0, self.project.name) + self.ignoreItemChanged = False + def clear(self): self.project = None self.topItem = None @@ -589,21 +599,42 @@ self.done(self.DiscardAll) +class ProjectPropertiesDialog(QtGui.QDialog, Ui_ProjectPropertiesDialog): + def __init__(self, project): + QtGui.QDialog.__init__(self) + self.setupUi(self) + Qt.connect(self.pickFileButton, Qt.SIGNAL("clicked()"), self.pickFilePath) + + self.project = project + self.projectNameField.setText(self.project.name) + self.buildScriptField.setText(self.project.buildScript) + self.creationDateField.setText(self.project.creationDate) + + def pickFilePath(self): + filePath = QtGui.QFileDialog.getOpenFileName(self, "Select Build Script File", g_CWD, "Python Script (*.py)"); + if filePath: + self.buildScriptField.setText(str(filePath)) + + def accept(self): + self.project.setName(unicode(self.projectNameField.text())) + self.project.setBuildScript(unicode(self.buildScriptField.text())) + self.project.setCreationDate(str(self.creationDateField.text())) + QtGui.QDialog.accept(self) + + class NewProjectDialog(QtGui.QDialog, Ui_NewProjectDialog): def __init__(self): QtGui.QDialog.__init__(self) self.setupUi(self) - Qt.connect(self.pickFileButton, Qt.SIGNAL("clicked()"), self.pickFilePath) def pickFilePath(self): filePath = QtGui.QFileDialog.getSaveFileName(self, "New Project File", g_CWD, "Translator Project (*%s)" % g_projectExt); - if not filePath: - return - filePath = str(filePath) # Convert QString - if os.path.splitext(filePath)[1] != g_projectExt: - filePath += g_projectExt - self.projectFilePath.setText(filePath) + if filePath: + filePath = str(filePath) # Convert QString + if os.path.splitext(filePath)[1] != g_projectExt: + filePath += g_projectExt + self.projectFilePath.setText(filePath) def accept(self): projectName = str(self.projectName.text())
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/translator/ui_langfile_properties.py Sat Nov 17 23:16:12 2007 +0100 @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'langfile_properties.ui' +# +# Created: Sat Nov 17 23:14:57 2007 +# by: PyQt4 UI code generator 4.1 +# +# WARNING! All changes made in this file will be lost! + +import sys +from PyQt4 import QtCore, QtGui + +class Ui_LangFilePropertiesDialog(object): + def setupUi(self, LangFilePropertiesDialog): + LangFilePropertiesDialog.setObjectName("LangFilePropertiesDialog") + LangFilePropertiesDialog.resize(QtCore.QSize(QtCore.QRect(0,0,400,228).size()).expandedTo(LangFilePropertiesDialog.minimumSizeHint())) + + self.vboxlayout = QtGui.QVBoxLayout(LangFilePropertiesDialog) + self.vboxlayout.setObjectName("vboxlayout") + + self.gridlayout = QtGui.QGridLayout() + self.gridlayout.setObjectName("gridlayout") + + self.label_2 = QtGui.QLabel(LangFilePropertiesDialog) + self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_2.setObjectName("label_2") + self.gridlayout.addWidget(self.label_2,1,0,1,1) + + self.langCodeField = QtGui.QLineEdit(LangFilePropertiesDialog) + self.langCodeField.setObjectName("langCodeField") + self.gridlayout.addWidget(self.langCodeField,1,1,1,1) + + self.label = QtGui.QLabel(LangFilePropertiesDialog) + self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label.setObjectName("label") + self.gridlayout.addWidget(self.label,2,0,1,1) + + self.creationDateField = QtGui.QLineEdit(LangFilePropertiesDialog) + self.creationDateField.setObjectName("creationDateField") + self.gridlayout.addWidget(self.creationDateField,2,1,1,1) + + self.authorsField = QtGui.QTextEdit(LangFilePropertiesDialog) + self.authorsField.setObjectName("authorsField") + self.gridlayout.addWidget(self.authorsField,0,1,1,1) + + self.label_3 = QtGui.QLabel(LangFilePropertiesDialog) + self.label_3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTop|QtCore.Qt.AlignTrailing) + self.label_3.setObjectName("label_3") + self.gridlayout.addWidget(self.label_3,0,0,1,1) + self.vboxlayout.addLayout(self.gridlayout) + + spacerItem = QtGui.QSpacerItem(20,10,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Fixed) + self.vboxlayout.addItem(spacerItem) + + self.buttonBox = QtGui.QDialogButtonBox(LangFilePropertiesDialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.NoButton|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName("buttonBox") + self.vboxlayout.addWidget(self.buttonBox) + self.label_2.setBuddy(self.langCodeField) + self.label.setBuddy(self.creationDateField) + + self.retranslateUi(LangFilePropertiesDialog) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),LangFilePropertiesDialog.accept) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),LangFilePropertiesDialog.reject) + QtCore.QMetaObject.connectSlotsByName(LangFilePropertiesDialog) + + def retranslateUi(self, LangFilePropertiesDialog): + LangFilePropertiesDialog.setWindowTitle(QtGui.QApplication.translate("LangFilePropertiesDialog", "Language File Properties", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("LangFilePropertiesDialog", "Language code:", None, QtGui.QApplication.UnicodeUTF8)) + self.label.setText(QtGui.QApplication.translate("LangFilePropertiesDialog", "Creation date:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_3.setText(QtGui.QApplication.translate("LangFilePropertiesDialog", "Author(s):", None, QtGui.QApplication.UnicodeUTF8)) +
--- a/trunk/src/translator/ui_project_properties.py Wed Nov 14 22:07:50 2007 +0100 +++ b/trunk/src/translator/ui_project_properties.py Sat Nov 17 23:16:12 2007 +0100 @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'project_properties.ui' # -# Created: Sun Oct 21 17:33:29 2007 +# Created: Sat Nov 17 23:14:55 2007 # by: PyQt4 UI code generator 4.1 # # WARNING! All changes made in this file will be lost! @@ -10,54 +10,73 @@ import sys from PyQt4 import QtCore, QtGui -class Ui_ProjectProperties(object): - def setupUi(self, ProjectProperties): - ProjectProperties.setObjectName("ProjectProperties") - ProjectProperties.resize(QtCore.QSize(QtCore.QRect(0,0,400,148).size()).expandedTo(ProjectProperties.minimumSizeHint())) +class Ui_ProjectPropertiesDialog(object): + def setupUi(self, ProjectPropertiesDialog): + ProjectPropertiesDialog.setObjectName("ProjectPropertiesDialog") + ProjectPropertiesDialog.resize(QtCore.QSize(QtCore.QRect(0,0,400,152).size()).expandedTo(ProjectPropertiesDialog.minimumSizeHint())) - self.vboxlayout = QtGui.QVBoxLayout(ProjectProperties) + self.vboxlayout = QtGui.QVBoxLayout(ProjectPropertiesDialog) self.vboxlayout.setObjectName("vboxlayout") self.gridlayout = QtGui.QGridLayout() self.gridlayout.setObjectName("gridlayout") - self.label_2 = QtGui.QLabel(ProjectProperties) + self.label_2 = QtGui.QLabel(ProjectPropertiesDialog) self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.label_2.setObjectName("label_2") self.gridlayout.addWidget(self.label_2,0,0,1,1) - self.projectNameField = QtGui.QLineEdit(ProjectProperties) + self.projectNameField = QtGui.QLineEdit(ProjectPropertiesDialog) self.projectNameField.setObjectName("projectNameField") self.gridlayout.addWidget(self.projectNameField,0,1,1,1) - self.label = QtGui.QLabel(ProjectProperties) + self.label = QtGui.QLabel(ProjectPropertiesDialog) self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.label.setObjectName("label") self.gridlayout.addWidget(self.label,1,0,1,1) - self.buildCommandField = QtGui.QLineEdit(ProjectProperties) - self.buildCommandField.setObjectName("buildCommandField") - self.gridlayout.addWidget(self.buildCommandField,1,1,1,1) + self.hboxlayout = QtGui.QHBoxLayout() + self.hboxlayout.setObjectName("hboxlayout") + + self.buildScriptField = QtGui.QLineEdit(ProjectPropertiesDialog) + self.buildScriptField.setObjectName("buildScriptField") + self.hboxlayout.addWidget(self.buildScriptField) + + self.pickFileButton = QtGui.QToolButton(ProjectPropertiesDialog) + self.pickFileButton.setObjectName("pickFileButton") + self.hboxlayout.addWidget(self.pickFileButton) + self.gridlayout.addLayout(self.hboxlayout,1,1,1,1) + + self.creationDateField = QtGui.QLineEdit(ProjectPropertiesDialog) + self.creationDateField.setObjectName("creationDateField") + self.gridlayout.addWidget(self.creationDateField,2,1,1,1) + + self.label_3 = QtGui.QLabel(ProjectPropertiesDialog) + self.label_3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_3.setObjectName("label_3") + self.gridlayout.addWidget(self.label_3,2,0,1,1) self.vboxlayout.addLayout(self.gridlayout) spacerItem = QtGui.QSpacerItem(20,40,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding) self.vboxlayout.addItem(spacerItem) - self.buttonBox = QtGui.QDialogButtonBox(ProjectProperties) + self.buttonBox = QtGui.QDialogButtonBox(ProjectPropertiesDialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.NoButton|QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.vboxlayout.addWidget(self.buttonBox) self.label_2.setBuddy(self.projectNameField) - self.label.setBuddy(self.buildCommandField) + self.label.setBuddy(self.buildScriptField) + + self.retranslateUi(ProjectPropertiesDialog) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),ProjectPropertiesDialog.accept) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),ProjectPropertiesDialog.reject) + QtCore.QMetaObject.connectSlotsByName(ProjectPropertiesDialog) - self.retranslateUi(ProjectProperties) - QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),ProjectProperties.accept) - QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),ProjectProperties.reject) - QtCore.QMetaObject.connectSlotsByName(ProjectProperties) + def retranslateUi(self, ProjectPropertiesDialog): + ProjectPropertiesDialog.setWindowTitle(QtGui.QApplication.translate("ProjectPropertiesDialog", "Project Properties", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("ProjectPropertiesDialog", "Project name:", None, QtGui.QApplication.UnicodeUTF8)) + self.label.setText(QtGui.QApplication.translate("ProjectPropertiesDialog", "Build script:", None, QtGui.QApplication.UnicodeUTF8)) + self.pickFileButton.setText(QtGui.QApplication.translate("ProjectPropertiesDialog", "...", None, QtGui.QApplication.UnicodeUTF8)) + self.label_3.setText(QtGui.QApplication.translate("ProjectPropertiesDialog", "Creation date:", None, QtGui.QApplication.UnicodeUTF8)) - def retranslateUi(self, ProjectProperties): - ProjectProperties.setWindowTitle(QtGui.QApplication.translate("ProjectProperties", "Project Properties", None, QtGui.QApplication.UnicodeUTF8)) - self.label_2.setText(QtGui.QApplication.translate("ProjectProperties", "Project name:", None, QtGui.QApplication.UnicodeUTF8)) - self.label.setText(QtGui.QApplication.translate("ProjectProperties", "Build command:", None, QtGui.QApplication.UnicodeUTF8)) -