예제 #1
0
    def closeEvent(self, *args, **kwargs):
        # Restore output stream
        sys.stdout = sys.__stdout__
        # Terminate the running threads.
        # Set the shutdown flag on each thread to trigger a clean shutdown of each thread.
        self.mainWindow.myRpcWd.shutdown_flag.set()
        logging.debug("Saving stuff & closing...")
        try:
            self.mainWindow.hwdevice.clearDevice()
        except Exception as e:
            logging.warning(str(e))

        # Update window/splitter size
        self.cache['window_width'] = self.width()
        self.cache['window_height'] = self.height()
        self.cache['splitter_x'] = self.mainWindow.splitter.sizes()[0]
        self.cache['splitter_y'] = self.mainWindow.splitter.sizes()[1]
        self.cache['console_hidden'] = (
            self.mainWindow.btn_consoleToggle.text() == 'Show')

        # persist cache
        saveCacheSettings(self.cache)

        # clear / close DB
        self.db.removeTable('UTXOS')
        self.db.close()

        # Adios
        print("Bye Bye.")
        return QMainWindow.closeEvent(self, *args, **kwargs)
예제 #2
0
    def closeEvent(self, *args, **kwargs):
        # Restore output stream
        sys.stdout = sys.__stdout__

        # Terminate the running threads.
        # Set the shutdown flag on each thread to trigger a clean shutdown of each thread.
        self.mainWindow.myRpcWd.shutdown_flag.set()
        logging.debug("Saving stuff & closing...")
        try:
            self.mainWindow.hwdevice.clearDevice()
        except Exception as e:
            logging.warning(str(e))

        # Update window/splitter size
        self.cache['window_width'] = self.width()
        self.cache['window_height'] = self.height()
        self.cache['splitter_x'] = self.mainWindow.splitter.sizes()[0]
        self.cache['splitter_y'] = self.mainWindow.splitter.sizes()[1]
        self.cache['console_hidden'] = (
            self.mainWindow.btn_consoleToggle.text() == 'Show')

        # Update mnList order to cache settings
        mnOrder = {}
        mnList = self.mainWindow.tabMain.myList
        for i in range(mnList.count()):
            mnName = mnList.itemWidget(mnList.item(i)).alias
            mnOrder[mnName] = i
        self.cache['mnList_order'] = mnOrder

        # persist cache
        saveCacheSettings(self.cache)

        # Clear Rewards and Governance DB
        try:
            self.db.open()
        except Exception:
            pass
        self.db.removeTable('REWARDS')
        self.db.removeTable('PROPOSALS')
        self.db.removeTable('MY_VOTES')

        # close database
        self.db.close()

        # Adios
        print("Bye Bye.")

        # Return
        return QMainWindow.closeEvent(self, *args, **kwargs)