Small UI fixes. Compatibility with Qt version < 4.7.

- error callback for loadHistory, to make the reload button enabled again after an error
 - remove descriptionEdit's placeholder (for compatibilty with earlier versions of Qt)
 - add placeholder text to descriptionEdit if supported by the user's version of Qt
 - set contentEdit read-only while loading a new page
 - saveButton was still showing "Saving" after saving had failed
This commit is contained in:
Clément Schreiner 2012-03-25 10:22:27 +02:00
commit 5daf71effe
2 changed files with 19 additions and 4 deletions

View file

@ -62,6 +62,9 @@ class MainWindow(QtMainWindow):
SIGNAL("clicked()"),
self.loadHistory)
if hasattr(self.ui.descriptionEdit, "setPlaceholderText"):
self.ui.descriptionEdit.setPlaceholderText("Edit summary")
if self.weboob.count_backends() == 0:
self.backendsConfig()
else:
@ -102,6 +105,7 @@ class MainWindow(QtMainWindow):
self.ui.loadButton.setEnabled(False)
self.ui.loadButton.setText('Loading...')
self.ui.contentEdit.setReadOnly(True)
backend = str(self.ui.backendBox.currentText())
self.process = QtDo(self.weboob,
@ -184,6 +188,7 @@ class MainWindow(QtMainWindow):
QMessageBox.critical(self, self.tr('Error while saving page'),
content, QMessageBox.Ok)
self.ui.saveButton.setEnabled(True)
self.ui.saveButton.setText("Save")
def loadPreview(self):
""" Loads the current page's preview into the preview QTextEdit """
@ -208,7 +213,9 @@ class MainWindow(QtMainWindow):
"Summary"])
self.ui.historyTable.setColumnWidth(3, 1000)
self.process = QtDo(self.weboob, self._gotRevision)
self.process = QtDo(self.weboob,
self._gotRevision,
self._errorHistory)
self.process.do('iter_revisions',
self.content.id,
max_results=self.ui.nbRevBox.value(),
@ -245,3 +252,14 @@ class MainWindow(QtMainWindow):
self.ui.historyTable.setItem(row, 3, item_summary)
self.ui.historyTable.setCurrentCell(row, 0)
def _errorHistory(self, backend, error, backtrace):
""" Loading the history has failed """
content = unicode(self.tr('Unable to load history:\n%s\n')) % to_unicode(error)
if logging.root.level == logging.DEBUG:
content += '\n%s\n' % to_unicode(backtrace)
QMessageBox.critical(self, self.tr('Error while loading history'),
content, QMessageBox.Ok)
self.ui.loadHistoryButton.setEnabled(True)
self.ui.loadHistoryButton.setText("Reload")

View file

@ -147,9 +147,6 @@
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Edit summary</string>
</property>
</widget>
</item>
<item>