qt6 fixes
This commit is contained in:
parent
e29185c293
commit
c7580c3a35
3 changed files with 33 additions and 7 deletions
|
@ -45,6 +45,10 @@ class ConnectionDialog(QtWidgets.QDialog):
|
|||
line_edit = QtWidgets.QLineEdit()
|
||||
line_edit.setFixedWidth(200)
|
||||
value = self.values.get('hostname', '')
|
||||
if value in ['None', None]:
|
||||
value = '0'
|
||||
elif type(value) == int:
|
||||
value = str(value)
|
||||
line_edit.insert(value)
|
||||
grid.addWidget(line_edit, 0, 1)
|
||||
self.fields['hostname'] = line_edit
|
||||
|
@ -56,6 +60,10 @@ class ConnectionDialog(QtWidgets.QDialog):
|
|||
line_edit = QtWidgets.QLineEdit()
|
||||
line_edit.setFixedWidth(200)
|
||||
value = self.values.get('port', '')
|
||||
if value in ['None', None]:
|
||||
value = '0'
|
||||
elif type(value) == int:
|
||||
value = str(value)
|
||||
line_edit.insert(value)
|
||||
grid.addWidget(line_edit, 1, 1)
|
||||
self.fields['port'] = line_edit
|
||||
|
@ -73,6 +81,10 @@ class ConnectionDialog(QtWidgets.QDialog):
|
|||
line_edit.setFixedWidth(200)
|
||||
line_edit.setEchoMode(QtWidgets.QLineEdit.Password)
|
||||
value = self.values.get('password', '')
|
||||
if value in ['None', None]:
|
||||
value = '0'
|
||||
elif type(value) == int:
|
||||
value = str(value)
|
||||
line_edit.insert(value)
|
||||
grid.addWidget(line_edit, 2, 1)
|
||||
self.fields['password'] = line_edit
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
"""Input line for chat and debug window."""
|
||||
|
||||
from qtpy import QtCore, QtWidgets
|
||||
from qtpy.QtCore import pyqtSignal as Signal
|
||||
from qtpy.QtCore import Signal
|
||||
|
||||
class InputLineEdit(QtWidgets.QLineEdit):
|
||||
"""Input line."""
|
||||
|
|
|
@ -27,7 +27,8 @@ import secrets
|
|||
import struct
|
||||
|
||||
from qtpy import QtCore, QtNetwork
|
||||
from qtoy.QtCore import pyqtSignal as Signal
|
||||
# from PyQt5.QtCore import pyqtSignal as Signal
|
||||
from qtpy.QtCore import Signal
|
||||
|
||||
from qweechat import config
|
||||
from qweechat.debug import DebugDialog
|
||||
|
@ -231,7 +232,19 @@ class Network(QtCore.QObject):
|
|||
|
||||
def is_connected(self):
|
||||
"""Return True if the socket is connected, False otherwise."""
|
||||
return self._socket.state() == QtNetwork.QAbstractSocket.ConnectedState
|
||||
return is_state(self, at='ConnectedState')
|
||||
|
||||
def is_state(self, at='ConnectedState'):
|
||||
"""Return True if the socket is connected, False otherwise."""
|
||||
if hasattr(QtNetwork.QAbstractSocket, 'ConnectedState'):
|
||||
if self._socket.state() == getattr(QtNetwork.QAbstractSocket, at):
|
||||
return True
|
||||
return False
|
||||
if hasattr(QtNetwork.QAbstractSocket, 'SocketState'):
|
||||
if self._socket.state() == getattr(QtNetwork.QAbstractSocket.SocketState, at):
|
||||
return True
|
||||
return False
|
||||
return False
|
||||
|
||||
def is_ssl(self):
|
||||
"""Return True if SSL is used, False otherwise."""
|
||||
|
@ -251,9 +264,10 @@ class Network(QtCore.QObject):
|
|||
self._lines = int(lines)
|
||||
except ValueError:
|
||||
self._lines = config.CONFIG_DEFAULT_RELAY_LINES
|
||||
if self._socket.state() == QtNetwork.QAbstractSocket.ConnectedState:
|
||||
# AttributeError: type object 'QAbstractSocket' has no attribute 'ConnectedState'
|
||||
if self.is_connected():
|
||||
return
|
||||
if self._socket.state() != QtNetwork.QAbstractSocket.UnconnectedState:
|
||||
if not self.is_state('UnconnectedState'):
|
||||
self._socket.abort()
|
||||
if self._ssl:
|
||||
self._socket.ignoreSslErrors()
|
||||
|
@ -264,10 +278,10 @@ class Network(QtCore.QObject):
|
|||
|
||||
def disconnect_weechat(self):
|
||||
"""Disconnect from WeeChat."""
|
||||
if self._socket.state() == QtNetwork.QAbstractSocket.UnconnectedState:
|
||||
if self.is_state('UnconnectedState'):
|
||||
self.set_status(STATUS_DISCONNECTED)
|
||||
return
|
||||
if self._socket.state() == QtNetwork.QAbstractSocket.ConnectedState:
|
||||
if self.is_state('ConnectedState'):
|
||||
self.send_to_weechat('quit\n')
|
||||
self._socket.waitForBytesWritten(1000)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue