Add copy button
offlate/window.py
90 | 90 | self.filechooser.addItem(project) | |
91 | 91 | self.filechooser.currentIndexChanged.connect(self.changefile) | |
92 | 92 | ||
93 | + | self.buttons = QVBoxLayout() | |
94 | + | self.copyButton = QPushButton(self.tr("Copy")) | |
95 | + | self.copyButton.clicked.connect(self.copy) | |
96 | + | self.buttons.addWidget(self.copyButton) | |
97 | + | ||
93 | 98 | if self.filechooser.count() > 1: | |
94 | 99 | vbox.addWidget(self.filechooser) | |
95 | 100 | ||
… | |||
97 | 102 | vbox.addWidget(self.treeWidget, 4) | |
98 | 103 | self.hbox = QHBoxLayout() | |
99 | 104 | self.hbox.addWidget(self.msgid) | |
105 | + | self.hbox.addLayout(self.buttons) | |
100 | 106 | self.hbox.addWidget(self.msgstr) | |
101 | 107 | vbox.addLayout(self.hbox, 1) | |
102 | 108 | size = self.treeWidget.size() | |
… | |||
117 | 123 | nextItem = self.treeWidget.itemFromIndex(self.treeWidget.indexAbove(index)) | |
118 | 124 | self.treeWidget.setCurrentItem(nextItem) | |
119 | 125 | ||
126 | + | def copy(self): | |
127 | + | if self.msgstr.__class__.__name__ == "SpellCheckEdit": | |
128 | + | text = self.msgid.toPlainText() | |
129 | + | self.msgstr.setText(text) | |
130 | + | else: | |
131 | + | text = self.msgid.currentWidget().toPlainText() | |
132 | + | self.msgstr.currentWidget().setText(text) | |
133 | + | ||
120 | 134 | def selectItem(self, current, old): | |
121 | 135 | if current == None: | |
122 | 136 | return | |
123 | 137 | data = current.data(0, Qt.UserRole) | |
124 | 138 | self.hbox.removeWidget(self.msgid) | |
139 | + | self.hbox.removeItem(self.buttons) | |
125 | 140 | self.hbox.removeWidget(self.msgstr) | |
126 | 141 | self.msgid.deleteLater() | |
127 | 142 | self.msgstr.deleteLater() | |
… | |||
163 | 178 | self.msgstr.textChanged.connect(self.modify) | |
164 | 179 | focuser = self.msgstr | |
165 | 180 | self.hbox.addWidget(self.msgid) | |
181 | + | self.hbox.addLayout(self.buttons) | |
166 | 182 | self.hbox.addWidget(self.msgstr) | |
167 | 183 | focuser.setFocus() | |
168 | 184 |