Minor UI changes.

- The 'save' button is disabled and shows 'No changes' at first. Editing contentEdit's text
enables the button and makes it show 'Save'.
 - The 'save' button is disabled and shows 'Saving...' when the page is being saved, and stays
disabled until contentEdit's text has been changed again.
 - The 'save' button shows 'Saved' once the page has been successfully saved. fixes #560
 - contentEdit is readonly when the page is being saved
This commit is contained in:
Clément Schreiner 2012-03-23 09:53:57 +01:00
commit a1a68847bb
2 changed files with 14 additions and 6 deletions

View file

@ -45,6 +45,7 @@ class MainWindow(QtMainWindow):
self._currentTabChanged) self._currentTabChanged)
self.connect(self.ui.saveButton, SIGNAL("clicked()"), self.savePage) self.connect(self.ui.saveButton, SIGNAL("clicked()"), self.savePage)
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
self.connect(self.ui.contentEdit, SIGNAL("textChanged()"), self._textChanged)
if self.weboob.count_backends() == 0: if self.weboob.count_backends() == 0:
self.backendsConfig() self.backendsConfig()
@ -66,6 +67,10 @@ class MainWindow(QtMainWindow):
if self.backend is not None: if self.backend is not None:
self.showPreview() self.showPreview()
def _textChanged(self):
self.ui.saveButton.setEnabled(True)
self.ui.saveButton.setText('Save')
def loadPage(self): def loadPage(self):
_id = unicode(self.ui.idEdit.text()) _id = unicode(self.ui.idEdit.text())
if not _id: if not _id:
@ -109,6 +114,8 @@ class MainWindow(QtMainWindow):
minor = self.ui.minorBox.isChecked() minor = self.ui.minorBox.isChecked()
if new_content != self.content.content: if new_content != self.content.content:
self.ui.saveButton.setEnabled(False) self.ui.saveButton.setEnabled(False)
self.ui.saveButton.setText('Saving...')
self.ui.contentEdit.setReadOnly(True)
self.content.content = new_content self.content.content = new_content
message = unicode(self.ui.descriptionEdit.text()) message = unicode(self.ui.descriptionEdit.text())
self.process = QtDo(self.weboob, self._savePage_cb, self._savePage_eb) self.process = QtDo(self.weboob, self._savePage_cb, self._savePage_eb)
@ -117,7 +124,8 @@ class MainWindow(QtMainWindow):
def _savePage_cb(self, backend, data): def _savePage_cb(self, backend, data):
if not backend: if not backend:
self.process = None self.process = None
self.ui.saveButton.setEnabled(True) self.ui.saveButton.setText('Saved')
self.ui.contentEdit.setReadOnly(False)
return return
self.ui.descriptionEdit.clear() self.ui.descriptionEdit.clear()

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>469</width> <width>498</width>
<height>520</height> <height>543</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -89,7 +89,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Save</string> <string>No changes</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -102,8 +102,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>469</width> <width>498</width>
<height>20</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">