Rename option/field "server" to "hostname"

This commit is contained in:
Sébastien Helleu 2021-11-14 18:54:48 +01:00
parent c05ab0e534
commit ae648fd7f6
4 changed files with 20 additions and 20 deletions

View File

@ -42,7 +42,7 @@ You have to add a relay port in WeeChat, for example on port 1234:
In QWeeChat, click on connect and enter fields:
- `server`: the IP address or hostname of your machine with WeeChat running
- `hostname`: the IP address or hostname of your machine with WeeChat running
- `port`: the relay port (defined in WeeChat)
- `password`: the relay password (defined in WeeChat)
- `totp`: the Time-Based One-Time Password (optional, to set if required by WeeChat)

View File

@ -40,16 +40,16 @@ class ConnectionDialog(QtWidgets.QDialog):
self.fields = {}
focus = None
# server
grid.addWidget(QtWidgets.QLabel('<b>Server</b>'), 0, 0)
# hostname
grid.addWidget(QtWidgets.QLabel('<b>Hostname</b>'), 0, 0)
line_edit = QtWidgets.QLineEdit()
line_edit.setFixedWidth(200)
value = self.values.get('server', '')
value = self.values.get('hostname', '')
line_edit.insert(value)
grid.addWidget(line_edit, 0, 1)
self.fields['server'] = line_edit
self.fields['hostname'] = line_edit
if not focus and not value:
focus = 'server'
focus = 'hostname'
# port / SSL
grid.addWidget(QtWidgets.QLabel('<b>Port</b>'), 1, 0)

View File

@ -115,7 +115,7 @@ class Network(QtCore.QObject):
def _init_connection(self):
self.status = STATUS_DISCONNECTED
self._server = None
self._hostname = None
self._port = None
self._ssl = None
self._password = None
@ -236,9 +236,9 @@ class Network(QtCore.QObject):
"""Return True if SSL is used, False otherwise."""
return self._ssl
def connect_weechat(self, server, port, ssl, password, totp, lines):
def connect_weechat(self, hostname, port, ssl, password, totp, lines):
"""Connect to WeeChat."""
self._server = server
self._hostname = hostname
try:
self._port = int(port)
except ValueError:
@ -256,9 +256,9 @@ class Network(QtCore.QObject):
self._socket.abort()
if self._ssl:
self._socket.ignoreSslErrors()
self._socket.connectToHostEncrypted(self._server, self._port)
self._socket.connectToHostEncrypted(self._hostname, self._port)
else:
self._socket.connectToHost(self._server, self._port)
self._socket.connectToHost(self._hostname, self._port)
self.set_status(STATUS_CONNECTING)
def disconnect_weechat(self):
@ -316,7 +316,7 @@ class Network(QtCore.QObject):
def get_options(self):
"""Get connection options."""
return {
'server': self._server,
'hostname': self._hostname,
'port': self._port,
'ssl': 'on' if self._ssl else 'off',
'password': self._password,

View File

@ -188,12 +188,12 @@ class MainWindow(QtWidgets.QMainWindow):
# auto-connect to relay
if self.config.getboolean('relay', 'autoconnect'):
self.network.connect_weechat(
server=self.config.get('relay', 'server'),
port=self.config.get('relay', 'port'),
ssl=self.config.getboolean('relay', 'ssl'),
password=self.config.get('relay', 'password'),
hostname=self.config.get('relay', 'hostname', fallback=''),
port=self.config.get('relay', 'port', fallback=''),
ssl=self.config.getboolean('relay', 'ssl', fallback=''),
password=self.config.get('relay', 'password', fallback=''),
totp=None,
lines=self.config.get('relay', 'lines'),
lines=self.config.get('relay', 'lines', fallback=''),
)
self.show()
@ -230,8 +230,8 @@ class MainWindow(QtWidgets.QMainWindow):
def open_connection_dialog(self):
"""Open a dialog with connection settings."""
values = {}
for option in ('server', 'port', 'ssl', 'password', 'lines'):
values[option] = self.config.get('relay', option)
for option in ('hostname', 'port', 'ssl', 'password', 'lines'):
values[option] = self.config.get('relay', option, fallback='')
self.connection_dialog = ConnectionDialog(values, self)
self.connection_dialog.dialog_buttons.accepted.connect(
self.connect_weechat)
@ -239,7 +239,7 @@ class MainWindow(QtWidgets.QMainWindow):
def connect_weechat(self):
"""Connect to WeeChat."""
self.network.connect_weechat(
server=self.connection_dialog.fields['server'].text(),
hostname=self.connection_dialog.fields['hostname'].text(),
port=self.connection_dialog.fields['port'].text(),
ssl=self.connection_dialog.fields['ssl'].isChecked(),
password=self.connection_dialog.fields['password'].text(),