Mercurial > projects > dil
annotate src/translator/translator.py @ 806:bcb74c9b895c
Moved out files in the trunk folder to the root.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sun, 09 Mar 2008 00:12:19 +0100 |
parents | trunk/src/translator/translator.py@312da78ab301 |
children |
rev | line source |
---|---|
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
1 #! /usr/bin/python |
435
156d6301d79e
Added PyQt4 application for creating and managing translations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
156d6301d79e
Added PyQt4 application for creating and managing translations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
3 # Author: Aziz Köksal |
156d6301d79e
Added PyQt4 application for creating and managing translations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
4 # License: GPL2 |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
5 import sys, os |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
6 import yaml |
438
2c177053cd15
Translator: added modules langfile and project.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
437
diff
changeset
|
7 |
435
156d6301d79e
Added PyQt4 application for creating and managing translations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
8 from PyQt4 import QtCore, QtGui |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
9 # User interface modules |
435
156d6301d79e
Added PyQt4 application for creating and managing translations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
10 from ui_translator import Ui_MainWindow |
436
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
11 from ui_about import Ui_AboutDialog |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
12 from ui_new_project import Ui_NewProjectDialog |
482
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
13 from ui_project_properties import Ui_ProjectPropertiesDialog |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
14 from ui_msg_form import Ui_MsgForm |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
15 from ui_closing_project import Ui_ClosingProjectDialog |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
16 |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
17 from project import Project, newProjectData |
438
2c177053cd15
Translator: added modules langfile and project.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
437
diff
changeset
|
18 |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
19 g_scriptDir = sys.path[0] |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
20 g_CWD = os.getcwd() |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
21 g_projectExt = ".tproj" |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
22 g_catExt = ".cat" |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
23 g_settingsFile = os.path.join(g_scriptDir, "settings.yaml") |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
24 g_settings = {} |
436
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
25 |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
26 Qt = QtCore.Qt |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
27 Qt.connect = QtCore.QObject.connect |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
28 Qt.disconnect = QtCore.QObject.disconnect |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
29 Qt.SIGNAL = QtCore.SIGNAL |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
30 Qt.SLOT = QtCore.SLOT |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
31 |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
32 def QTabWidgetCloseAll(self): |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
33 for i in range(self.count()-1,-1,-1): |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
34 widget = self.widget(i) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
35 self.removeTab(i) |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
36 widget.close() |
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
37 QtGui.QTabWidget.closeAll = QTabWidgetCloseAll |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
38 |
436
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
39 class MainWindow(QtGui.QMainWindow, Ui_MainWindow): |
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
40 def __init__(self): |
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
41 QtGui.QMainWindow.__init__(self) |
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
42 self.setupUi(self) |
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
43 |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
44 self.project = None |
436
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
45 # Modifications |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
46 self.pages = QtGui.QTabWidget() |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
47 self.setCentralWidget(self.pages) |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
48 self.disableMenuItems() |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
49 self.projectDock = QtGui.QDockWidget("Project", self) |
551
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
50 self.projectTree = ProjectTree(self.projectDock, self) |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
51 self.projectDock.setWidget(self.projectTree) |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
52 self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.projectDock) |
436
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
53 # Custom connections |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
54 triggered = Qt.SIGNAL("triggered()") |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
55 Qt.connect(self.action_About, triggered, self.showAboutDialog) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
56 Qt.connect(self.action_New_Project, triggered, self.createNewProject) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
57 Qt.connect(self.action_Open_Project, triggered, self.openProjectAction) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
58 Qt.connect(self.action_Close_Project, triggered, self.closeProjectAction) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
59 Qt.connect(self.action_Save, triggered, self.saveForm) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
60 Qt.connect(self.action_Save_All, triggered, self.saveAllForms) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
61 Qt.connect(self.action_Close, triggered, self.closeForm) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
62 Qt.connect(self.action_Close_All, triggered, self.closeAllForms) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
63 Qt.connect(self.action_Properties, triggered, self.showProjectProperties) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
64 Qt.connect(self.action_Add_Catalogue, triggered, self.addCatalogue) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
65 Qt.connect(self.action_Add_New_Catalogue, triggered, self.addNewCatalogue) |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
66 Qt.connect(self.projectTree, Qt.SIGNAL("itemDoubleClicked(QTreeWidgetItem*,int)"), self.projectTreeItemDblClicked) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
67 Qt.connect(self.projectTree, Qt.SIGNAL("onKeyEnter"), self.projectTreeItemActivated) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
68 Qt.connect(self.projectTree, Qt.SIGNAL("onKeyDelete"), self.projectTreeItemDeleted) |
436
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
69 |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
70 shortcut = QtGui.QShortcut(QtGui.QKeySequence(Qt.CTRL+Qt.Key_Tab), self) |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
71 Qt.connect(shortcut, Qt.SIGNAL("activated()"), self.nextDocument) |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
72 shortcut = QtGui.QShortcut(QtGui.QKeySequence(Qt.CTRL+Qt.SHIFT+Qt.Key_Tab), self) |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
73 Qt.connect(shortcut, Qt.SIGNAL("activated()"), self.prevDocument) |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
74 |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
75 self.readSettings() |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
76 |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
77 def nextDocument(self): |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
78 count = self.pages.count() |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
79 if count < 1: return |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
80 index = self.pages.currentIndex()+1 |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
81 if index == count: index = 0 |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
82 self.pages.setCurrentIndex(index) |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
83 |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
84 def prevDocument(self): |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
85 count = self.pages.count() |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
86 if count < 1: return |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
87 index = self.pages.currentIndex()-1 |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
88 if index == -1: index = count-1 |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
89 self.pages.setCurrentIndex(index) |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
90 |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
91 def showAboutDialog(self): |
436
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
92 about = QtGui.QDialog() |
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
93 Ui_AboutDialog().setupUi(about) |
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
94 about.exec_() |
435
156d6301d79e
Added PyQt4 application for creating and managing translations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
95 |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
96 def showProjectProperties(self): |
482
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
97 dialog = ProjectPropertiesDialog(self.project) |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
98 dialog.exec_() |
482
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
99 self.projectTree.updateProjectName() |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
100 |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
101 def createNewProject(self): |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
102 if self.rejectClosingProject(): |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
103 return |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
104 dialog = NewProjectDialog() |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
105 code = dialog.exec_() |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
106 if code == QtGui.QDialog.Accepted: |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
107 self.closeProject() |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
108 self.openProject(str(dialog.projectFilePath.text())) |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
109 |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
110 def openProjectAction(self): |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
111 if self.rejectClosingProject(): |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
112 return |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
113 filePath = QtGui.QFileDialog.getOpenFileName(self, "Select Project File", g_CWD, "Translator Project (*%s)" % g_projectExt); |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
114 filePath = str(filePath) |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
115 if filePath: |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
116 self.closeProject() |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
117 self.openProject(filePath) |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
118 |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
119 def openProject(self, filePath): |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
120 from errors import LoadingError |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
121 try: |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
122 self.project = Project(filePath) |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
123 except LoadingError, e: |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
124 QtGui.QMessageBox.critical(self, "Error", u"Couldn't load project file:\n\n"+str(e)) |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
125 return |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
126 self.enableMenuItems() |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
127 self.projectTree.setProject(self.project) |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
128 |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
129 def closeProjectAction(self): |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
130 if not self.rejectClosingProject(): |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
131 self.closeProject() |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
132 |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
133 def addCatalogue(self): |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
134 filePath = QtGui.QFileDialog.getOpenFileName(self, "Select Project File", g_CWD, "Catalogue (*%s)" % g_catExt); |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
135 filePath = str(filePath) |
482
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
136 # TODO: |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
137 #self.project.addLangFile(filePath) |
439
cdbb2bf6dd07
Translator: applied some fixes and made some additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
438
diff
changeset
|
138 |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
139 def addNewCatalogue(self): |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
140 pass |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
141 |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
142 def rejectClosingProject(self): |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
143 if self.project == None: |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
144 return False |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
145 |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
146 modifiedDocs = [] |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
147 # Check if any open document is modified. |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
148 for i in range(0, self.pages.count()): |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
149 if self.pages.widget(i).isModified: |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
150 modifiedDocs += [self.pages.widget(i)] |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
151 # Display dialog if so. |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
152 if len(modifiedDocs): |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
153 dialog = ClosingProjectDialog(modifiedDocs) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
154 code = dialog.exec_() |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
155 if code == dialog.Accepted: |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
156 for doc in dialog.getSelectedDocs(): |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
157 self.saveDocument(doc) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
158 elif code == dialog.Rejected: |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
159 return True |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
160 elif code == dialog.DiscardAll: |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
161 pass |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
162 |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
163 return False |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
164 |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
165 def closeProject(self): |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
166 if self.project == None: |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
167 return |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
168 self.project.save() |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
169 del self.project |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
170 self.project = None |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
171 self.disableMenuItems() |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
172 self.projectTree.clear() |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
173 self.pages.closeAll() |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
174 |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
175 def enableMenuItems(self): |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
176 #self.action_Close_Project.setEnabled(True) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
177 for action in [ self.action_Save, |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
178 self.action_Save_All, |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
179 self.action_Close, |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
180 self.action_Close_All ]: |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
181 action.setEnabled(True) |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
182 self.menubar.insertMenu(self.menu_Help.menuAction(), self.menu_Project) |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
183 |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
184 def disableMenuItems(self): |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
185 #self.action_Close_Project.setEnabled(False) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
186 for action in [ self.action_Save, |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
187 self.action_Save_All, |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
188 self.action_Close, |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
189 self.action_Close_All ]: |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
190 action.setEnabled(False) |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
191 self.menubar.removeAction(self.menu_Project.menuAction()) |
439
cdbb2bf6dd07
Translator: applied some fixes and made some additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
438
diff
changeset
|
192 |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
193 def projectTreeItemDblClicked(self, item, int): |
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
194 self.projectTreeItemActivated(item) |
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
195 |
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
196 def projectTreeItemActivated(self, item): |
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
197 if item == None: |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
198 return |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
199 |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
200 if isinstance(item, LangFileItem): |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
201 msgForm = None |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
202 if not item.isDocOpen(): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
203 msgForm = item.openDoc() |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
204 msgForm.setModifiedCallback(self.formModified) |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
205 else: |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
206 msgForm = item.openDoc() |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
207 index = self.pages.indexOf(msgForm) |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
208 if index == -1: |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
209 index = self.pages.addTab(msgForm, msgForm.getDocumentTitle()) |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
210 self.pages.setCurrentIndex(index) |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
211 msgForm.updateData() |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
212 |
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
213 def projectTreeItemDeleted(self, item): |
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
214 pass |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
215 |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
216 def formModified(self, form): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
217 # Append an asterisk to the tab label |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
218 index = self.pages.indexOf(form) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
219 text = form.getDocumentTitle() + "*" |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
220 self.pages.setTabText(index, text) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
221 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
222 def saveForm(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
223 self.saveDocument(self.pages.currentWidget()) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
224 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
225 def saveAllForms(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
226 for i in range(0, self.pages.count()): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
227 self.saveDocument(self.pages.widget(i)) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
228 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
229 def saveDocument(self, form): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
230 if form.isModified: |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
231 # Reset tab text. |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
232 index = self.pages.indexOf(form) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
233 text = form.getDocumentTitle() |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
234 self.pages.setTabText(index, text) |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
235 |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
236 form.save() |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
237 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
238 def closeForm(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
239 if self.pages.currentWidget(): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
240 self.closeDocument(self.pages.currentWidget()) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
241 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
242 def closeAllForms(self): |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
243 for i in range(self.pages.count()-1, -1, -1): |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
244 self.closeDocument(self.pages.widget(i)) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
245 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
246 def closeDocument(self, form): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
247 if form.isModified: |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
248 MB = QtGui.QMessageBox |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
249 button = MB.question(self, "Closing Document", "The document '%s' has been modified.\nDo you want to save the changes?" % form.getDocumentFullPath(), MB.Save | MB.Discard | MB.Cancel, MB.Cancel) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
250 if button == MB.Cancel: |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
251 return False |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
252 if button == MB.Save: |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
253 self.saveDocument(form) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
254 index = self.pages.indexOf(form) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
255 self.pages.removeTab(index) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
256 form.close() |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
257 return True |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
258 |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
259 def closeEvent(self, event): |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
260 if self.rejectClosingProject(): |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
261 event.ignore() |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
262 return |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
263 self.closeProject() |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
264 self.writeSettings() |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
265 # Closing application |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
266 |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
267 def moveToCenterOfDesktop(self): |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
268 rect = QtGui.QApplication.desktop().geometry() |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
269 self.move(rect.center() - self.rect().center()) |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
270 |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
271 def readSettings(self): |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
272 # Set default size |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
273 self.resize(QtCore.QSize(500, 400)) |
438
2c177053cd15
Translator: added modules langfile and project.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
437
diff
changeset
|
274 doc = {} |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
275 try: |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
276 doc = yaml.load(open(g_settingsFile, "r")) |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
277 except: |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
278 self.moveToCenterOfDesktop() |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
279 return |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
280 |
438
2c177053cd15
Translator: added modules langfile and project.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
437
diff
changeset
|
281 g_settings = doc |
2c177053cd15
Translator: added modules langfile and project.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
437
diff
changeset
|
282 if not isinstance(doc, dict): |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
283 g_settings = {} |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
284 |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
285 try: |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
286 coord = doc["Window"] |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
287 size = QtCore.QSize(coord["Size"][0], coord["Size"][1]) |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
288 point = QtCore.QPoint(coord["Pos"][0], coord["Pos"][1]) |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
289 self.resize(size) |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
290 self.move(point) |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
291 except: |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
292 self.moveToCenterOfDesktop() |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
293 |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
294 def writeSettings(self): |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
295 # Save window coordinates |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
296 g_settings["Window"] = { |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
297 "Pos" : [self.pos().x(), self.pos().y()], |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
298 "Size" : [self.size().width(), self.size().height()] |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
299 } |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
300 yaml.dump(g_settings, open(g_settingsFile, "w")) #default_flow_style=False |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
301 |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
302 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
303 class Document(QtGui.QWidget): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
304 def __init__(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
305 QtGui.QWidget.__init__(self) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
306 self.isModified = False |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
307 self.modifiedCallback = None |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
308 self.documentTitle = "" |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
309 self.documentFullPath = "" |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
310 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
311 def modified(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
312 if not self.isModified: |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
313 self.isModified = True |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
314 self.modifiedCallback(self) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
315 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
316 def setModifiedCallback(self, func): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
317 self.modifiedCallback = func |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
318 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
319 def save(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
320 self.isModified = False |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
321 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
322 def close(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
323 self.emit(Qt.SIGNAL("closed()")) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
324 QtGui.QWidget.close(self) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
325 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
326 def getDocumentTitle(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
327 return self.documentTitle |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
328 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
329 def getDocumentFullPath(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
330 return self.documentFullPath |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
331 |
551
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
332 |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
333 class MessageItem(QtGui.QTreeWidgetItem): |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
334 def __init__(self, msg): |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
335 QtGui.QTreeWidgetItem.__init__(self, [str(msg["ID"]), msg["Text"], "Done"]) |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
336 self.msg = msg |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
337 |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
338 def getID(self): |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
339 return self.msg["ID"] |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
340 |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
341 def setMsgText(self, text): |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
342 self.msg["Text"] = text |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
343 |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
344 def setMsgAnnot(self, text): |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
345 self.msg["Annot"] = text |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
346 |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
347 |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
348 class MsgForm(Document, Ui_MsgForm): |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
349 def __init__(self, langFile): |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
350 Document.__init__(self) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
351 self.documentTitle = langFile.getFileName() |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
352 self.documentFullPath = langFile.getFilePath() |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
353 self.setupUi(self) |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
354 self.vboxlayout.setMargin(0) |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
355 |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
356 self.langFile = langFile |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
357 self.currentItem = None |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
358 self.colID = 0 |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
359 self.colText = 1 |
551
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
360 #self.colStat = 2 |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
361 #self.treeWidget.setColumnCount(3) |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
362 self.treeWidget.setColumnCount(2) |
551
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
363 self.treeWidget.setHeaderLabels(["ID", "Text"]) #, "Status" |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
364 self.msgItemDict = {} # Maps msg IDs to msg items. |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
365 for msg in self.langFile.messages: |
551
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
366 item = MessageItem(msg) |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
367 self.msgItemDict[msg["ID"]] = item |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
368 self.treeWidget.addTopLevelItem(item) |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
369 |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
370 Qt.connect(self.treeWidget, Qt.SIGNAL("currentItemChanged (QTreeWidgetItem *,QTreeWidgetItem *)"), self.treeItemChanged) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
371 Qt.connect(self.translEdit, Qt.SIGNAL("textChanged()"), self.translEditTextChanged) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
372 Qt.connect(self.translAnnotEdit, Qt.SIGNAL("textChanged()"), self.translAnnotEditTextChanged) |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
373 |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
374 #self.translEdit.focusOutEvent = self.translEditFocusOut |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
375 |
551
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
376 def sourceMsgChanged(self, msg): |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
377 # TODO: |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
378 pass |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
379 |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
380 def treeItemChanged(self, current, previous): |
472
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
381 if current == None: |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
382 self.setTranslMsg("") |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
383 self.setSourceMsg("") |
472
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
384 return |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
385 ID = current.getID() |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
386 # Set the text controls. |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
387 # The slots receiving text changed signals do nothing if self.currentItem is None. |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
388 self.currentItem = None |
472
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
389 self.setTranslMsg(self.langFile.getMsg(ID)) |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
390 self.setSourceMsg(self.langFile.source.getMsg(ID)) |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
391 self.currentItem = current |
472
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
392 |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
393 def setTranslMsg(self, msg): |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
394 self.translEdit.setText(msg["Text"]) |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
395 self.translAnnotEdit.setText(msg["Annot"]) |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
396 |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
397 def setSourceMsg(self, msg): |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
398 self.sourceEdit.setText(msg["Text"]) |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
399 self.sourceAnnotEdit.setText(msg["Annot"]) |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
400 |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
401 #def translEditFocusOut(self, event): |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
402 #if self.currentItem: |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
403 #print self.currentItem.text(self.colText) |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
404 #if self.translEdit.document().isModified(): |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
405 #self.translEdit.document().setModified(False) |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
406 #print "translEdit was modified" |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
407 #QtGui.QTextEdit.focusOutEvent(self.translEdit, event) |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
408 |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
409 def translEditTextChanged(self): |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
410 if self.currentItem: |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
411 text = unicode(self.translEdit.toPlainText()) |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
412 self.currentItem.setText(self.colText, text) |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
413 self.currentItem.setMsgText(text) |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
414 self.modified() |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
415 |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
416 def translAnnotEditTextChanged(self): |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
417 if self.currentItem: |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
418 text = unicode(self.translAnnotEdit.toPlainText()) |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
419 self.currentItem.setMsgAnnot(text) |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
420 self.modified() |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
421 |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
422 def updateData(self): |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
423 if self.currentItem == None: |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
424 return |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
425 ID = self.currentItem.getID() |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
426 msg = self.langFile.source.getMsg(ID) |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
427 text = self.sourceEdit.toPlainText() |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
428 if text != msg["Text"]: |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
429 self.sourceEdit.setText(msg["Text"]) |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
430 text = self.sourceAnnotEdit.toPlainText() |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
431 if text != msg["Annot"]: |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
432 self.sourceAnnotEdit.setText(msg["Annot"]) |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
433 |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
434 def save(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
435 Document.save(self) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
436 self.langFile.save() |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
437 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
438 |
472
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
439 class MsgFormSource(MsgForm): |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
440 def __init__(self, langFile): |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
441 MsgForm.__init__(self, langFile) |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
442 |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
443 for x in [self.translEdit, |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
444 self.translAnnotEdit, |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
445 self.label_4, |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
446 self.label_5]: |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
447 x.close() |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
448 |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
449 Qt.connect(self.sourceEdit, Qt.SIGNAL("textChanged()"), self.sourceEditTextChanged) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
450 Qt.connect(self.sourceAnnotEdit, Qt.SIGNAL("textChanged()"), self.sourceAnnotEditTextChanged) |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
451 |
472
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
452 def treeItemChanged(self, current, previous): |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
453 if current == None: |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
454 self.setSourceMsg("") |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
455 return |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
456 ID = current.getID() |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
457 self.currentItem = None |
472
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
458 self.setSourceMsg(self.langFile.getMsg(ID)) |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
459 self.currentItem = current |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
460 |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
461 def sourceEditTextChanged(self): |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
462 if self.currentItem: |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
463 text = unicode(self.sourceEdit.toPlainText()) |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
464 self.currentItem.setText(self.colText, text) |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
465 self.currentItem.setMsgText(text) |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
466 self.modified() |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
467 |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
468 def sourceAnnotEditTextChanged(self): |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
469 if self.currentItem: |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
470 text = unicode(self.sourceAnnotEdit.toPlainText()) |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
471 #self.currentItem.setText(self.colAnnot, text) |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
472 self.currentItem.setMsgAnnot(text) |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
473 self.modified() |
475
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
474 |
70fdd0701a77
Translator: messages can be edited now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
472
diff
changeset
|
475 |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
476 class MsgIDItem(QtGui.QTreeWidgetItem): |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
477 def __init__(self, parent, text): |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
478 QtGui.QTreeWidgetItem.__init__(self, parent, [text]) |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
479 self.setFlags(self.flags()|Qt.ItemIsEditable); |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
480 |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
481 class LangFileItem(QtGui.QTreeWidgetItem): |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
482 def __init__(self, parent, langFile): |
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
483 QtGui.QTreeWidgetItem.__init__(self, parent, [langFile.langCode]) |
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
484 self.langFile = langFile |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
485 self.msgForm = None |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
486 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
487 def isDocOpen(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
488 return self.msgForm != None |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
489 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
490 def openDoc(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
491 if self.msgForm == None: |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
492 if self.langFile.isSource: |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
493 self.msgForm = MsgFormSource(self.langFile) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
494 else: |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
495 self.msgForm = MsgForm(self.langFile) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
496 Qt.connect(self.msgForm, Qt.SIGNAL("closed()"), self.docClosed) |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
497 return self.msgForm |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
498 |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
499 def docClosed(self): |
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
500 self.msgForm = None |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
501 |
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
502 class ProjectItem(QtGui.QTreeWidgetItem): |
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
503 def __init__(self, text): |
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
504 QtGui.QTreeWidgetItem.__init__(self, [text]) |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
505 self.setFlags(self.flags()|Qt.ItemIsEditable); |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
506 |
439
cdbb2bf6dd07
Translator: applied some fixes and made some additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
438
diff
changeset
|
507 class ProjectTree(QtGui.QTreeWidget): |
551
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
508 def __init__(self, parent, mainWindow): |
439
cdbb2bf6dd07
Translator: applied some fixes and made some additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
438
diff
changeset
|
509 QtGui.QTreeWidget.__init__(self, parent) |
551
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
510 self.mainWindow = mainWindow |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
511 self.project = None |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
512 self.topItem = None |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
513 self.msgIDsItem = None |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
514 self.headerItem().setHidden(True) |
482
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
515 self.ignoreItemChanged = False |
438
2c177053cd15
Translator: added modules langfile and project.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
437
diff
changeset
|
516 |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
517 def itemChanged(self, item, column): |
482
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
518 if self.ignoreItemChanged: |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
519 return |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
520 text = unicode(item.text(0)) |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
521 #if hasattr(item, "textChanged"): |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
522 #item.textChanged(text) |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
523 if isinstance(item, ProjectItem): |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
524 self.project.setName(text) |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
525 print text |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
526 |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
527 def keyReleaseEvent(self, event): |
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
528 Qt = QtCore.Qt |
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
529 key = event.key() |
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
530 if key in [Qt.Key_Enter, Qt.Key_Return]: |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
531 self.emit(Qt.SIGNAL("onKeyEnter"), self.currentItem()) |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
532 elif key == Qt.Key_Delete: |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
533 self.emit(Qt.SIGNAL("onKeyDelete"), self.currentItem()) |
476
773ddddb583d
Translator: made central widget a QTabWidget.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
475
diff
changeset
|
534 |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
535 def setProject(self, project): |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
536 self.project = project |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
537 |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
538 self.topItem = ProjectItem(self.project.name) |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
539 self.addTopLevelItem(self.topItem) |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
540 |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
541 for langFile in self.project.langFiles: |
471
b6fa41e6f0b4
Translator: implemented some functionality of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
460
diff
changeset
|
542 langFileItem = LangFileItem(self.topItem, langFile) |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
543 |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
544 self.msgIDsItem = QtGui.QTreeWidgetItem(self.topItem, ["Message IDs"]) |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
545 for msgID in self.project.msgIDs: |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
546 MsgIDItem(self.msgIDsItem, msgID["Name"]) |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
547 |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
548 for x in [self.topItem, self.msgIDsItem]: |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
549 x.setExpanded(True) |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
550 |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
551 Qt.connect(self, Qt.SIGNAL("itemChanged(QTreeWidgetItem*,int)"), self.itemChanged) |
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
552 |
472
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
553 def contextMenuEvent(self, event): |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
554 item = self.itemAt(event.pos()) |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
555 func_map = { |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
556 None : lambda item: None, |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
557 QtGui.QTreeWidgetItem : lambda item: None, |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
558 ProjectItem : self.showMenuProjectItem, |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
559 LangFileItem : self.showMenuLangFileItem, |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
560 MsgIDItem : self.showMenuMsgIDItem |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
561 } |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
562 func_map[type(item)](item) |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
563 |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
564 def showMenuProjectItem(self, item): |
551
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
565 mousePos = QtGui.QCursor.pos() |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
566 menu = QtGui.QMenu() |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
567 actions = {} |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
568 actions[menu.addAction("Build")] = lambda: None |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
569 actions[menu.addAction("Properties")] = lambda: self.mainWindow.showProjectProperties() |
312da78ab301
Translator: changed type of LastEd field in cat files to int.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
482
diff
changeset
|
570 actions[menu.exec_(mousePos)]() |
472
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
571 |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
572 def showMenuLangFileItem(self, item): |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
573 print "LangFileItem" |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
574 |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
575 def showMenuMsgIDItem(self, item): |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
576 print "MsgIDItem" |
30925590f392
Translator: implemented more functionalities of MsgForm.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
471
diff
changeset
|
577 |
482
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
578 def updateProjectName(self): |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
579 self.ignoreItemChanged = True |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
580 self.topItem.setText(0, self.project.name) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
581 self.ignoreItemChanged = False |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
582 |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
583 def clear(self): |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
584 self.project = None |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
585 self.topItem = None |
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
586 self.msgIDsItem = None |
481
04adc4e3fdda
Translator: some fixes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
479
diff
changeset
|
587 Qt.disconnect(self, Qt.SIGNAL("itemChanged(QTreeWidgetItem*,int)"), self.itemChanged) |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
588 QtGui.QTreeWidget.clear(self) |
438
2c177053cd15
Translator: added modules langfile and project.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
437
diff
changeset
|
589 |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
590 |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
591 class ClosingProjectDialog(QtGui.QDialog, Ui_ClosingProjectDialog): |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
592 DiscardAll = 2 |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
593 def __init__(self, docs): |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
594 QtGui.QDialog.__init__(self) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
595 self.setupUi(self) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
596 Qt.connect(self.button_Discard_All, Qt.SIGNAL("clicked()"), self.discardAll) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
597 |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
598 self.items = [] |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
599 for doc in docs: |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
600 title = doc.getDocumentTitle() |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
601 path = doc.getDocumentFullPath() |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
602 item = QtGui.QTreeWidgetItem([title, path]) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
603 item.doc = doc |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
604 item.setFlags(item.flags()|Qt.ItemIsUserCheckable); |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
605 item.setCheckState(0, Qt.Checked) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
606 self.items += [item] |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
607 self.treeWidget.addTopLevelItems(self.items) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
608 |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
609 self.button_Cancel.setFocus() |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
610 |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
611 def getSelectedDocs(self): |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
612 return [item.doc for item in self.items if item.checkState(0)] |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
613 |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
614 def discardAll(self): |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
615 self.done(self.DiscardAll) |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
616 |
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
617 |
482
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
618 class ProjectPropertiesDialog(QtGui.QDialog, Ui_ProjectPropertiesDialog): |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
619 def __init__(self, project): |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
620 QtGui.QDialog.__init__(self) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
621 self.setupUi(self) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
622 Qt.connect(self.pickFileButton, Qt.SIGNAL("clicked()"), self.pickFilePath) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
623 |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
624 self.project = project |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
625 self.projectNameField.setText(self.project.name) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
626 self.buildScriptField.setText(self.project.buildScript) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
627 self.creationDateField.setText(self.project.creationDate) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
628 |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
629 def pickFilePath(self): |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
630 filePath = QtGui.QFileDialog.getOpenFileName(self, "Select Build Script File", g_CWD, "Python Script (*.py)"); |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
631 if filePath: |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
632 self.buildScriptField.setText(str(filePath)) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
633 |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
634 def accept(self): |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
635 self.project.setName(unicode(self.projectNameField.text())) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
636 self.project.setBuildScript(unicode(self.buildScriptField.text())) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
637 self.project.setCreationDate(str(self.creationDateField.text())) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
638 QtGui.QDialog.accept(self) |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
639 |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
640 |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
641 class NewProjectDialog(QtGui.QDialog, Ui_NewProjectDialog): |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
642 def __init__(self): |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
643 QtGui.QDialog.__init__(self) |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
644 self.setupUi(self) |
477
3b5421d40f9b
Translator: major changes and additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
476
diff
changeset
|
645 Qt.connect(self.pickFileButton, Qt.SIGNAL("clicked()"), self.pickFilePath) |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
646 |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
647 def pickFilePath(self): |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
648 filePath = QtGui.QFileDialog.getSaveFileName(self, "New Project File", g_CWD, "Translator Project (*%s)" % g_projectExt); |
482
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
649 if filePath: |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
650 filePath = str(filePath) # Convert QString |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
651 if os.path.splitext(filePath)[1] != g_projectExt: |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
652 filePath += g_projectExt |
1401e38d1e2e
Translator: implemented project properties dialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
481
diff
changeset
|
653 self.projectFilePath.setText(filePath) |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
654 |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
655 def accept(self): |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
656 projectName = str(self.projectName.text()) |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
657 filePath = str(self.projectFilePath.text()) |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
658 |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
659 MB = QtGui.QMessageBox |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
660 if projectName == "": |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
661 MB.warning(self, "Warning", "Please, enter a name for the project.") |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
662 return |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
663 if filePath == "": |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
664 MB.warning(self, "Warning", "Please, choose or enter a path for the project file.") |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
665 return |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
666 |
460
77c17bbe9d20
Translator: added new modules; applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
442
diff
changeset
|
667 projectData = newProjectData(projectName) |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
668 |
442
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
669 if os.path.splitext(filePath)[1] != g_projectExt: |
5968e273449b
Translator: added new modules; made fixes and many additions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
439
diff
changeset
|
670 filePath += g_projectExt |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
671 |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
672 try: |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
673 yaml.dump(projectData, open(filePath, "w"), default_flow_style=False) |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
674 except Exception, e: |
479
044b5393f8bc
Translator: added ClosingProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
477
diff
changeset
|
675 MB.critical(self, "Error", str(e)) |
437
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
676 return |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
677 |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
678 # Accept and close dialog. |
7ac9f94ca7ff
Translator: added NewProjectDialog.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
436
diff
changeset
|
679 QtGui.QDialog.accept(self) |
435
156d6301d79e
Added PyQt4 application for creating and managing translations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
680 |
156d6301d79e
Added PyQt4 application for creating and managing translations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
681 if __name__ == "__main__": |
436
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
682 app = QtGui.QApplication(sys.argv) |
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
683 main = MainWindow() |
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
684 main.show() |
0dba4c0e5234
Added AboutDialog to translator.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
435
diff
changeset
|
685 sys.exit(app.exec_()) |