From 12fb6c3932e3c72796b56761b9c9eff2add3a5e2 Mon Sep 17 00:00:00 2001 From: Gerrit Vermeulen Date: Tue, 10 Dec 2013 16:14:32 +0200 Subject: [PATCH 1/2] Store the last used port and use it as default. --- colourterm/mainwindow.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/colourterm/mainwindow.py b/colourterm/mainwindow.py index 99c6b7e..5217f37 100644 --- a/colourterm/mainwindow.py +++ b/colourterm/mainwindow.py @@ -201,11 +201,14 @@ class MainWindow(QtGui.QMainWindow, UiMainWindow): def on_open_action_triggered(self): self.connect_dialog.update_port_combobox() + settings = QtCore.QSettings() + self.connect_dialog.port_edit.setEditText(unicode(settings.value(u'previous-port', u'').toString())) if self.connect_dialog.exec_() == QtGui.QDialog.Accepted: if not self.device_closed: self.device_closed = True self.device.close() try: + settings.setValue(u'previous-port', self.connect_dialog.get_port()) self.device = Serial( port=self.connect_dialog.get_port(), baudrate=self.connect_dialog.get_baud(), From ec3009950bdda18aed44ddc18d22a0022239cb8e Mon Sep 17 00:00:00 2001 From: Gerrit Vermeulen Date: Wed, 11 Dec 2013 09:20:24 +0200 Subject: [PATCH 2/2] Add a set_port method to ConnectDialog and use that instead of accessing the port_edit widget directly. --- colourterm/connectdialog.py | 3 +++ colourterm/mainwindow.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/colourterm/connectdialog.py b/colourterm/connectdialog.py index 1aac1ac..6e5733d 100644 --- a/colourterm/connectdialog.py +++ b/colourterm/connectdialog.py @@ -209,6 +209,9 @@ class ConnectDialog(QtGui.QDialog, UiConnectDialog): def get_hardware_handshake(self): return self.hardware_checkbox.isChecked() + def set_port(self, port): + self.port_edit.setEditText(port) + def update_port_combobox(self): self.port_edit.clear() ports = [] diff --git a/colourterm/mainwindow.py b/colourterm/mainwindow.py index 5217f37..d221577 100644 --- a/colourterm/mainwindow.py +++ b/colourterm/mainwindow.py @@ -202,7 +202,7 @@ class MainWindow(QtGui.QMainWindow, UiMainWindow): def on_open_action_triggered(self): self.connect_dialog.update_port_combobox() settings = QtCore.QSettings() - self.connect_dialog.port_edit.setEditText(unicode(settings.value(u'previous-port', u'').toString())) + self.connect_dialog.set_port(unicode(settings.value(u'previous-port', u'').toString())) if self.connect_dialog.exec_() == QtGui.QDialog.Accepted: if not self.device_closed: self.device_closed = True