From 239e0e58dd211152713bc0998d7ca6c2c994989e Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Mon, 21 Dec 2015 00:54:05 +0100 Subject: [PATCH] Blurs UI while processing Before the processing of a query starts, it will blur the UI. This gives feedback to the user that something is happening, and is simple to implement because I am too lazy to move the processing in a separate thread. --- CHANGELOG | 1 + relational_gui/guihandler.py | 55 +++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4e42ab0..5044c50 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ 2.2 - Added again make install target - Ctrl+C in the terminal will terminate the GUI +- Blurs UI while processing 2.1 - Introduced sessions; GUI loads the same relations of the previous time diff --git a/relational_gui/guihandler.py b/relational_gui/guihandler.py index 5b35028..ec9eb13 100644 --- a/relational_gui/guihandler.py +++ b/relational_gui/guihandler.py @@ -133,34 +133,43 @@ class relForm(QtWidgets.QMainWindow): self.showRelation(self.selectedRelation) def execute(self): - '''Executes the query''' - if self.multiline: - return self._run_multiline() - # Single line query - query = self.ui.txtQuery.text() - res_rel = self.ui.txtResult.text() # result relation's name + blur = QtWidgets.QGraphicsBlurEffect() + self.setGraphicsEffect(blur) + QtCore.QCoreApplication.processEvents() try: - self.selectedRelation = self.user_interface.execute(query, res_rel) - self.updateRelations() # update the list - self.showRelation(self.selectedRelation) - except Exception as e: - return self.error(e) + '''Executes the query''' + if self.multiline: + return self._run_multiline() - # Adds to history - item = u'%s = %s' % ( - self.ui.txtResult.text(), - self.ui.txtQuery.text() - ) - hitem = QtWidgets.QListWidgetItem(None, 0) - hitem.setText(item) - self.ui.lstHistory.addItem(hitem) - self.ui.lstHistory.setCurrentItem(hitem) + # Single line query + query = self.ui.txtQuery.text() + res_rel = self.ui.txtResult.text() # result relation's name + + try: + self.selectedRelation = self.user_interface.execute(query, res_rel) + self.updateRelations() # update the list + self.showRelation(self.selectedRelation) + except Exception as e: + return self.error(e) + + # Adds to history + item = u'%s = %s' % ( + self.ui.txtResult.text(), + self.ui.txtQuery.text() + ) + hitem = QtWidgets.QListWidgetItem(None, 0) + hitem.setText(item) + self.ui.lstHistory.addItem(hitem) + self.ui.lstHistory.setCurrentItem(hitem) + + self.qcounter += 1 + # Sets the result relation name to none + self.ui.txtResult.setText(u"_last%d" % self.qcounter) + finally: + blur.setBlurRadius(0) - self.qcounter += 1 - # Sets the result relation name to none - self.ui.txtResult.setText(u"_last%d" % self.qcounter) def showRelation(self, rel): '''Shows the selected relation into the table'''