Mercurial > projects > dil
comparison trunk/src/translator/translator.py @ 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 | 312da78ab301 |
comparison
equal
deleted
inserted
replaced
481:04adc4e3fdda | 482:1401e38d1e2e |
---|---|
8 from PyQt4 import QtCore, QtGui | 8 from PyQt4 import QtCore, QtGui |
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 from ui_project_properties import Ui_ProjectProperties | 13 from ui_project_properties import Ui_ProjectPropertiesDialog |
14 from ui_msg_form import Ui_MsgForm | 14 from ui_msg_form import Ui_MsgForm |
15 from ui_closing_project import Ui_ClosingProjectDialog | 15 from ui_closing_project import Ui_ClosingProjectDialog |
16 | 16 |
17 from project import Project, newProjectData | 17 from project import Project, newProjectData |
18 | 18 |
92 about = QtGui.QDialog() | 92 about = QtGui.QDialog() |
93 Ui_AboutDialog().setupUi(about) | 93 Ui_AboutDialog().setupUi(about) |
94 about.exec_() | 94 about.exec_() |
95 | 95 |
96 def showProjectProperties(self): | 96 def showProjectProperties(self): |
97 dialog = QtGui.QDialog() | 97 dialog = ProjectPropertiesDialog(self.project) |
98 Ui_ProjectProperties().setupUi(dialog) | |
99 dialog.exec_() | 98 dialog.exec_() |
99 self.projectTree.updateProjectName() | |
100 | 100 |
101 def createNewProject(self): | 101 def createNewProject(self): |
102 if self.rejectClosingProject(): | 102 if self.rejectClosingProject(): |
103 return | 103 return |
104 dialog = NewProjectDialog() | 104 dialog = NewProjectDialog() |
131 self.closeProject() | 131 self.closeProject() |
132 | 132 |
133 def addCatalogue(self): | 133 def addCatalogue(self): |
134 filePath = QtGui.QFileDialog.getOpenFileName(self, "Select Project File", g_CWD, "Catalogue (*%s)" % g_catExt); | 134 filePath = QtGui.QFileDialog.getOpenFileName(self, "Select Project File", g_CWD, "Catalogue (*%s)" % g_catExt); |
135 filePath = str(filePath) | 135 filePath = str(filePath) |
136 # TODO: | |
137 #self.project.addLangFile(filePath) | |
136 | 138 |
137 def addNewCatalogue(self): | 139 def addNewCatalogue(self): |
138 pass | 140 pass |
139 | 141 |
140 def rejectClosingProject(self): | 142 def rejectClosingProject(self): |
497 QtGui.QTreeWidget.__init__(self, parent) | 499 QtGui.QTreeWidget.__init__(self, parent) |
498 self.project = None | 500 self.project = None |
499 self.topItem = None | 501 self.topItem = None |
500 self.msgIDsItem = None | 502 self.msgIDsItem = None |
501 self.headerItem().setHidden(True) | 503 self.headerItem().setHidden(True) |
504 self.ignoreItemChanged = False | |
502 | 505 |
503 def itemChanged(self, item, column): | 506 def itemChanged(self, item, column): |
507 if self.ignoreItemChanged: | |
508 return | |
504 text = unicode(item.text(0)) | 509 text = unicode(item.text(0)) |
505 #if hasattr(item, "textChanged"): | 510 #if hasattr(item, "textChanged"): |
506 #item.textChanged(text) | 511 #item.textChanged(text) |
507 if isinstance(item, ProjectItem): | 512 if isinstance(item, ProjectItem): |
508 self.project.setName(text) | 513 self.project.setName(text) |
552 print "LangFileItem" | 557 print "LangFileItem" |
553 | 558 |
554 def showMenuMsgIDItem(self, item): | 559 def showMenuMsgIDItem(self, item): |
555 print "MsgIDItem" | 560 print "MsgIDItem" |
556 | 561 |
562 def updateProjectName(self): | |
563 self.ignoreItemChanged = True | |
564 self.topItem.setText(0, self.project.name) | |
565 self.ignoreItemChanged = False | |
566 | |
557 def clear(self): | 567 def clear(self): |
558 self.project = None | 568 self.project = None |
559 self.topItem = None | 569 self.topItem = None |
560 self.msgIDsItem = None | 570 self.msgIDsItem = None |
561 Qt.disconnect(self, Qt.SIGNAL("itemChanged(QTreeWidgetItem*,int)"), self.itemChanged) | 571 Qt.disconnect(self, Qt.SIGNAL("itemChanged(QTreeWidgetItem*,int)"), self.itemChanged) |
587 | 597 |
588 def discardAll(self): | 598 def discardAll(self): |
589 self.done(self.DiscardAll) | 599 self.done(self.DiscardAll) |
590 | 600 |
591 | 601 |
602 class ProjectPropertiesDialog(QtGui.QDialog, Ui_ProjectPropertiesDialog): | |
603 def __init__(self, project): | |
604 QtGui.QDialog.__init__(self) | |
605 self.setupUi(self) | |
606 Qt.connect(self.pickFileButton, Qt.SIGNAL("clicked()"), self.pickFilePath) | |
607 | |
608 self.project = project | |
609 self.projectNameField.setText(self.project.name) | |
610 self.buildScriptField.setText(self.project.buildScript) | |
611 self.creationDateField.setText(self.project.creationDate) | |
612 | |
613 def pickFilePath(self): | |
614 filePath = QtGui.QFileDialog.getOpenFileName(self, "Select Build Script File", g_CWD, "Python Script (*.py)"); | |
615 if filePath: | |
616 self.buildScriptField.setText(str(filePath)) | |
617 | |
618 def accept(self): | |
619 self.project.setName(unicode(self.projectNameField.text())) | |
620 self.project.setBuildScript(unicode(self.buildScriptField.text())) | |
621 self.project.setCreationDate(str(self.creationDateField.text())) | |
622 QtGui.QDialog.accept(self) | |
623 | |
624 | |
592 class NewProjectDialog(QtGui.QDialog, Ui_NewProjectDialog): | 625 class NewProjectDialog(QtGui.QDialog, Ui_NewProjectDialog): |
593 def __init__(self): | 626 def __init__(self): |
594 QtGui.QDialog.__init__(self) | 627 QtGui.QDialog.__init__(self) |
595 self.setupUi(self) | 628 self.setupUi(self) |
596 | |
597 Qt.connect(self.pickFileButton, Qt.SIGNAL("clicked()"), self.pickFilePath) | 629 Qt.connect(self.pickFileButton, Qt.SIGNAL("clicked()"), self.pickFilePath) |
598 | 630 |
599 def pickFilePath(self): | 631 def pickFilePath(self): |
600 filePath = QtGui.QFileDialog.getSaveFileName(self, "New Project File", g_CWD, "Translator Project (*%s)" % g_projectExt); | 632 filePath = QtGui.QFileDialog.getSaveFileName(self, "New Project File", g_CWD, "Translator Project (*%s)" % g_projectExt); |
601 if not filePath: | 633 if filePath: |
602 return | 634 filePath = str(filePath) # Convert QString |
603 filePath = str(filePath) # Convert QString | 635 if os.path.splitext(filePath)[1] != g_projectExt: |
604 if os.path.splitext(filePath)[1] != g_projectExt: | 636 filePath += g_projectExt |
605 filePath += g_projectExt | 637 self.projectFilePath.setText(filePath) |
606 self.projectFilePath.setText(filePath) | |
607 | 638 |
608 def accept(self): | 639 def accept(self): |
609 projectName = str(self.projectName.text()) | 640 projectName = str(self.projectName.text()) |
610 filePath = str(self.projectFilePath.text()) | 641 filePath = str(self.projectFilePath.text()) |
611 | 642 |