Add room history mechanism (Syncplay#336)

* new 'roomhistory' value in configuration
* change gui room input to combobox to display history
* update history upon startup using the configuration room
This commit is contained in:
Gabriel Dolberg 2020-07-17 18:09:09 +03:00
parent 1ad10632c6
commit a6676020c3
2 changed files with 20 additions and 4 deletions

View File

@ -29,6 +29,7 @@ class ConfigurationGetter(object):
"noGui": False, "noGui": False,
"noStore": False, "noStore": False,
"room": "", "room": "",
"roomhistory": [],
"password": None, "password": None,
"playerPath": None, "playerPath": None,
"perPlayerArguments": None, "perPlayerArguments": None,
@ -149,6 +150,7 @@ class ConfigurationGetter(object):
] ]
self._serialised = [ self._serialised = [
"roomhistory",
"perPlayerArguments", "perPlayerArguments",
"mediaSearchDirectories", "mediaSearchDirectories",
"trustedDomains", "trustedDomains",
@ -181,7 +183,7 @@ class ConfigurationGetter(object):
self._iniStructure = { self._iniStructure = {
"server_data": ["host", "port", "password"], "server_data": ["host", "port", "password"],
"client_settings": [ "client_settings": [
"name", "room", "playerPath", "name", "room", "roomhistory", "playerPath",
"perPlayerArguments", "slowdownThreshold", "perPlayerArguments", "slowdownThreshold",
"rewindThreshold", "fastforwardThreshold", "rewindThreshold", "fastforwardThreshold",
"slowOnDesync", "rewindOnDesync", "slowOnDesync", "rewindOnDesync",

View File

@ -380,6 +380,15 @@ class ConfigDialog(QtWidgets.QDialog):
settings.setValue("publicServers", servers) settings.setValue("publicServers", servers)
self.hostCombobox.setEditText(currentServer) self.hostCombobox.setEditText(currentServer)
def updateRoomHistory(self, newRoom=None):
if newRoom is None:
newRoom = self.defaultroomCombobox.currentText()
roomHistory = self.config['roomhistory']
if newRoom in roomHistory:
roomHistory.remove(newRoom)
roomHistory.insert(0, newRoom)
self.config['roomhistory'] = roomHistory
def showErrorMessage(self, errorMessage): def showErrorMessage(self, errorMessage):
QtWidgets.QMessageBox.warning(self, "Syncplay", errorMessage) QtWidgets.QMessageBox.warning(self, "Syncplay", errorMessage)
@ -447,6 +456,7 @@ class ConfigDialog(QtWidgets.QDialog):
else: else:
self.config['file'] = str(self.mediapathTextbox.text()) self.config['file'] = str(self.mediapathTextbox.text())
self.config['publicServers'] = self.publicServerAddresses self.config['publicServers'] = self.publicServerAddresses
self.config['room'] = self.defaultroomCombobox.currentText()
self.pressedclosebutton = False self.pressedclosebutton = False
self.close() self.close()
@ -599,7 +609,11 @@ class ConfigDialog(QtWidgets.QDialog):
self.usernameTextbox.setObjectName("name") self.usernameTextbox.setObjectName("name")
self.serverpassLabel = QLabel(getMessage("password-label"), self) self.serverpassLabel = QLabel(getMessage("password-label"), self)
self.defaultroomTextbox = QLineEdit(self) self.defaultroomCombobox = QtWidgets.QComboBox(self)
self.updateRoomHistory(config['room'])
for roomHistoryValue in self.config['roomhistory']:
self.defaultroomCombobox.addItem(roomHistoryValue)
self.defaultroomCombobox.setEditable(True)
self.usernameLabel = QLabel(getMessage("name-label"), self) self.usernameLabel = QLabel(getMessage("name-label"), self)
self.serverpassTextbox = QLineEdit(self) self.serverpassTextbox = QLineEdit(self)
self.serverpassTextbox.setText(self.storedPassword) self.serverpassTextbox.setText(self.storedPassword)
@ -614,7 +628,7 @@ class ConfigDialog(QtWidgets.QDialog):
self.hostCombobox.editTextChanged.connect(self.updatePasswordVisibilty) self.hostCombobox.editTextChanged.connect(self.updatePasswordVisibilty)
self.hostCombobox.currentIndexChanged.connect(self.updatePasswordVisibilty) self.hostCombobox.currentIndexChanged.connect(self.updatePasswordVisibilty)
self.defaultroomLabel.setObjectName("room") self.defaultroomLabel.setObjectName("room")
self.defaultroomTextbox.setObjectName("room") self.defaultroomCombobox.setObjectName("room")
self.connectionSettingsLayout = QtWidgets.QGridLayout() self.connectionSettingsLayout = QtWidgets.QGridLayout()
self.connectionSettingsLayout.addWidget(self.hostLabel, 0, 0) self.connectionSettingsLayout.addWidget(self.hostLabel, 0, 0)
@ -624,7 +638,7 @@ class ConfigDialog(QtWidgets.QDialog):
self.connectionSettingsLayout.addWidget(self.usernameLabel, 2, 0) self.connectionSettingsLayout.addWidget(self.usernameLabel, 2, 0)
self.connectionSettingsLayout.addWidget(self.usernameTextbox, 2, 1) self.connectionSettingsLayout.addWidget(self.usernameTextbox, 2, 1)
self.connectionSettingsLayout.addWidget(self.defaultroomLabel, 3, 0) self.connectionSettingsLayout.addWidget(self.defaultroomLabel, 3, 0)
self.connectionSettingsLayout.addWidget(self.defaultroomTextbox, 3, 1) self.connectionSettingsLayout.addWidget(self.defaultroomCombobox, 3, 1)
self.connectionSettingsLayout.setSpacing(10) self.connectionSettingsLayout.setSpacing(10)
self.connectionSettingsGroup.setLayout(self.connectionSettingsLayout) self.connectionSettingsGroup.setLayout(self.connectionSettingsLayout)
if isMacOS(): if isMacOS():