diff --git a/src/revpicommander/helper.py b/src/revpicommander/helper.py index 09cfbd0..db60bed 100644 --- a/src/revpicommander/helper.py +++ b/src/revpicommander/helper.py @@ -134,14 +134,15 @@ class RevPiSettings: self._settings.beginWriteArray("connections") self._settings.setArrayIndex(count_settings) - self.internal_id = uuid4().hex + if not self.internal_id: + self.internal_id = uuid4().hex if not self.internal_id: create_new_array_member() else: # Always search setting in array, because connection manager could reorganize array indexes - index = -1 + new_setting = True for index in range(count_settings): self._settings.setArrayIndex(index) @@ -150,12 +151,14 @@ class RevPiSettings: if self._settings.value("address") == self.address: # Set missing internal_id self.internal_id = uuid4().hex + new_setting = False break else: if self._settings.value("internal_id") == self.internal_id: + new_setting = False break - if index == count_settings - 1: + if new_setting: # On this point, we iterate all settings and found none, so create new one create_new_array_member() @@ -665,17 +668,21 @@ def all_revpi_settings() -> [RevPiSettings]: def import_old_settings(): - if not settings.value("revpicommander/imported_settings", False, type=bool): - settings.setValue("revpicommander/imported_settings", True) + """Try to import saved connections from old storage to new setting object.""" + if settings.value("revpicommander/imported_settings", False, type=bool): + return + settings.setValue("revpicommander/imported_settings", True) - old_settings = QtCore.QSettings("revpipyplc", "revpipyload") - count_settings = old_settings.beginReadArray("connections") - old_settings.endArray() + old_settings = QtCore.QSettings("revpipyplc", "revpipyload") + count_settings = old_settings.beginReadArray("connections") + old_settings.endArray() - lst_revpi_settings = [RevPiSettings(i, settings_storage=old_settings) for i in range(count_settings)] - for revpi_setting in lst_revpi_settings: + for i in range(count_settings): + try: + revpi_setting = RevPiSettings(i, settings_storage=old_settings) revpi_setting._settings = settings revpi_setting.save_settings() - + except Exception as e: + pi.logger.warning("Could not import saved connection {0}".format(i)) import_old_settings() diff --git a/src/revpicommander/locale/revpicommander_de.ts b/src/revpicommander/locale/revpicommander_de.ts index a154800..d39e7dc 100644 --- a/src/revpicommander/locale/revpicommander_de.ts +++ b/src/revpicommander/locale/revpicommander_de.ts @@ -101,62 +101,62 @@ Nicht gespeicherte Änderunen gehen verloren ConnectionManager - + SIMULATING SIMULATION - + NOT CONNECTED NICHT VERBUNDEN - + SERVER ERROR SERVER FEHLER - + RUNNING LÄUFT - + PLC FILE NOT FOUND SPS PROGRAMM NICHT GEFUNDEN - + NOT RUNNING (NO STATUS) LÄUFT NICHT (KEIN STATUS) - + PROGRAM KILLED PROGRAMM GETÖTET - + PROGRAM TERMED PROGRAMM BEENDET - + NOT RUNNING LÄUFT NICHT - + FINISHED WITH CODE {0} BEENDET MIT CODE {0} - + Error Fehler - + The combination of username and password was rejected from the SSH server. Try again. @@ -165,7 +165,7 @@ Try again. Bitte erneut versuchen. - + Could not establish a SSH connection to server: {0} @@ -174,7 +174,7 @@ Bitte erneut versuchen. {0} - + Can not connect to RevPi XML-RPC Service! This could have the following reasons: The RevPi is not online, the XML-RPC service is not running / bind to localhost or the ACL permission is not set for your IP!!! @@ -665,15 +665,15 @@ Ungesicherte Änderungen gehen verloren. New connection - Neue Verbindung + Neue Verbindung - + Question Frage - + Do you really want to quit? Unsaved changes will be lost. Soll das Fenster wirklich geschlossen werden? diff --git a/src/revpicommander/revpiplclist.py b/src/revpicommander/revpiplclist.py index d8ac40e..f509a67 100644 --- a/src/revpicommander/revpiplclist.py +++ b/src/revpicommander/revpiplclist.py @@ -25,7 +25,6 @@ class RevPiPlcList(QtWidgets.QDialog, Ui_diag_connections): def __init__(self, parent=None): super(RevPiPlcList, self).__init__(parent) self.setupUi(self) - self.__default_name = self.tr("New connection") self.__default_port = 55123 self.__current_item = QtWidgets.QTreeWidgetItem() # type: QtWidgets.QTreeWidgetItem