Store the last used port and use it as default.
When opening a port for the first time the dropdown text will be blank (forcing you to use a port instead of accidentally selecting the first port in the list) but thereafter it will show the previously used port.
This commit is contained in:
commit
1db68ebd65
@ -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 = []
|
||||
|
@ -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.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
|
||||
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(),
|
||||
|
Loading…
Reference in New Issue
Block a user