Add shortcut for previous item
offlate/window.py
111 | 111 | index = self.treeWidget.currentIndex() | |
112 | 112 | nextItem = self.treeWidget.itemFromIndex(self.treeWidget.indexBelow(index)) | |
113 | 113 | self.treeWidget.setCurrentItem(nextItem) | |
114 | - | self.msgstr.setFocus() | |
114 | + | ||
115 | + | def previousItem(self): | |
116 | + | index = self.treeWidget.currentIndex() | |
117 | + | nextItem = self.treeWidget.itemFromIndex(self.treeWidget.indexAbove(index)) | |
118 | + | self.treeWidget.setCurrentItem(nextItem) | |
115 | 119 | ||
116 | 120 | def selectItem(self, current, old): | |
117 | 121 | if current == None: | |
… | |||
123 | 127 | self.msgstr.deleteLater() | |
124 | 128 | ||
125 | 129 | font = "monospace" if self.monospace else "sans-serif" | |
130 | + | focuser = None | |
126 | 131 | ||
127 | 132 | if len(data.msgstrs) > 1: | |
128 | 133 | self.msgid = QTabWidget(); | |
… | |||
144 | 149 | form.setText(msgstr) | |
145 | 150 | form.textChanged.connect(self.modify) | |
146 | 151 | self.msgstr.addTab(form, str(i)) | |
152 | + | if i == 0: | |
153 | + | focuser = form | |
147 | 154 | i=i+1 | |
148 | 155 | else: | |
149 | 156 | self.msgid = QTextEdit() | |
… | |||
154 | 161 | self.msgstr.setFont(QFont(font)) | |
155 | 162 | self.msgstr.setText(data.msgstrs[0]) | |
156 | 163 | self.msgstr.textChanged.connect(self.modify) | |
164 | + | focuser = self.msgstr | |
157 | 165 | self.hbox.addWidget(self.msgid) | |
158 | 166 | self.hbox.addWidget(self.msgstr) | |
167 | + | focuser.setFocus() | |
159 | 168 | ||
160 | 169 | def modify(self): | |
161 | 170 | item = self.treeWidget.currentItem() | |
… | |||
473 | 482 | total += 1 | |
474 | 483 | if d.isTranslated() and not d.isFuzzy(): | |
475 | 484 | translated += 1 | |
476 | - | percent = 100 if total == 0 else math.floor(100 * translated / total) | |
485 | + | percent = 100 if total == 0 else math.floor(1000 * translated / total)/10 | |
477 | 486 | self.countLabel.setText(self.tr("{} translated on {} total ({}%).").format(translated, total, percent)) | |
478 | 487 | ||
479 | 488 | def save(self): | |
… | |||
516 | 525 | for i in range(0, self.tabs.count()): | |
517 | 526 | self.tabs.widget(i).setFont(self.monospaceAct.isChecked()) | |
518 | 527 | ||
528 | + | def previousItem(self): | |
529 | + | self.tabs.currentWidget().previousItem() | |
530 | + | ||
519 | 531 | def nextItem(self): | |
520 | 532 | self.tabs.currentWidget().nextItem() | |
521 | 533 | ||
… | |||
568 | 580 | self.monospaceAct.setChecked(False) | |
569 | 581 | self.monospaceAct.triggered.connect(self.setFont) | |
570 | 582 | ||
571 | - | self.nextShortcut = QShortcut(QKeySequence("Ctrl+Return"), self) | |
583 | + | self.previousShortcut = QShortcut(QKeySequence("Ctrl+Up"), self) | |
584 | + | self.previousShortcut.activated.connect(self.previousItem) | |
585 | + | ||
586 | + | self.previous2Shortcut = QShortcut(QKeySequence("Ctrl+Shift+Return"), self) | |
587 | + | self.previous2Shortcut.activated.connect(self.previousItem) | |
588 | + | ||
589 | + | self.nextShortcut = QShortcut(QKeySequence("Ctrl+Down"), self) | |
572 | 590 | self.nextShortcut.activated.connect(self.nextItem) | |
573 | 591 | ||
592 | + | self.next2Shortcut = QShortcut(QKeySequence("Ctrl+Return"), self) | |
593 | + | self.next2Shortcut.activated.connect(self.nextItem) | |
594 | + | ||
574 | 595 | self.countLabel = QLabel() | |
575 | 596 | self.statusBar() | |
576 | 597 | self.statusBar().addWidget(self.countLabel) |