Only one line and add background color for empty strings

Julien LepillerSat Jun 23 12:48:53+0200 2018

52edc87

Only one line and add background color for empty strings

offlate/window.py

4040
        self.showUntranslated = showUntranslated
4141
        self.showFuzzy = showFuzzy
4242
        self.monospace = monospace
43+
        self.fuzzyColor = QBrush(QColor(255, 127, 80))
44+
        self.emptyColor = QBrush(QColor(255, 240, 235))
4345
        self.initUI()
4446
4547
    def updateContent(self):

6062
            item = QTreeWidgetItem([entry.msgids[0].replace('\n', ' '),
6163
                                    entry.msgstrs[0].replace('\n', ' ')])
6264
            if entry.isFuzzy():
63-
                item.setForeground(1, QBrush(QColor(255, 127, 80)))
65+
                item.setForeground(1, self.fuzzyColor)
66+
            if not entry.isTranslated():
67+
                item.setBackground(1, self.emptyColor)
6468
            item.setFont(0, QFont("sans-serif", 10))
6569
            item.setFont(1, QFont("sans-serif", 10))
6670
            item.setSizeHint(0, QSize(-1, 22))

154158
        if self.msgstr.__class__.__name__ == "SpellCheckEdit":
155159
            msgstr = self.msgstr.toPlainText()
156160
            data.update(0, msgstr)
157-
            item.setText(1, msgstr)
161+
            item.setText(1, msgstr.replace('\n', ' '))
158162
        else:
159163
            i = 0
160164
            for msgstr in data.msgstrs:
161165
                data.update(i, self.msgstr.widget(i).toPlainText())
162166
                i=i+1
163-
            item.setText(1, data.get(0))
167+
            item.setText(1, data.get(0).replace('\n', ' '))
164168
        item.setForeground(1, QBrush())
169+
        if data.isTranslated():
170+
            item.setBackground(1, QBrush())
171+
        else:
172+
            item.setBackground(1, self.emptyColor)
165173
166174
    def save(self):
167175
        self.project.save()