Add copy button

Julien LepillerThu Aug 16 16:27:43+0200 2018

6b5d03a

Add copy button

offlate/window.py

9090
            self.filechooser.addItem(project)
9191
        self.filechooser.currentIndexChanged.connect(self.changefile)
9292
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+
9398
        if self.filechooser.count() > 1:
9499
            vbox.addWidget(self.filechooser)
95100

97102
        vbox.addWidget(self.treeWidget, 4)
98103
        self.hbox = QHBoxLayout()
99104
        self.hbox.addWidget(self.msgid)
105+
        self.hbox.addLayout(self.buttons)
100106
        self.hbox.addWidget(self.msgstr)
101107
        vbox.addLayout(self.hbox, 1)
102108
        size = self.treeWidget.size()

117123
        nextItem = self.treeWidget.itemFromIndex(self.treeWidget.indexAbove(index))
118124
        self.treeWidget.setCurrentItem(nextItem)
119125
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+
120134
    def selectItem(self, current, old):
121135
        if current == None:
122136
            return
123137
        data = current.data(0, Qt.UserRole)
124138
        self.hbox.removeWidget(self.msgid)
139+
        self.hbox.removeItem(self.buttons)
125140
        self.hbox.removeWidget(self.msgstr)
126141
        self.msgid.deleteLater()
127142
        self.msgstr.deleteLater()

163178
            self.msgstr.textChanged.connect(self.modify)
164179
            focuser = self.msgstr
165180
        self.hbox.addWidget(self.msgid)
181+
        self.hbox.addLayout(self.buttons)
166182
        self.hbox.addWidget(self.msgstr)
167183
        focuser.setFocus()
168184