Convert to PyQt5

This commit is contained in:
emdee 2022-11-20 03:41:26 +00:00
parent 82e0d92056
commit ba73b0ac36
11 changed files with 53 additions and 35 deletions

View File

@ -22,7 +22,7 @@
"""About dialog box."""
from PySide6 import QtCore, QtWidgets as QtGui
from PyQt5 import QtCore, QtWidgets as QtGui
from qweechat.version import qweechat_version

View File

@ -24,7 +24,9 @@
from pkg_resources import resource_filename
from PySide6 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import pyqtSignal
Signal = pyqtSignal
from qweechat.chat import ChatTextEdit
from qweechat.input import InputLineEdit
@ -145,7 +147,7 @@ class BufferWidget(QtWidgets.QWidget):
class Buffer(QtCore.QObject):
"""A WeeChat buffer."""
bufferInput = QtCore.Signal(str, str)
bufferInput = Signal(str, str)
def __init__(self, data=None):
QtCore.QObject.__init__(self)

View File

@ -24,7 +24,7 @@
import datetime
from PySide6 import QtCore, QtWidgets, QtGui
from PyQt5 import QtCore, QtWidgets, QtGui
from qweechat import config
from qweechat.weechat import color

View File

@ -33,14 +33,14 @@ CONFIG_FILENAME = '%s/qweechat.conf' % CONFIG_DIR
CONFIG_DEFAULT_RELAY_LINES = 50
CONFIG_DEFAULT_SECTIONS = ('relay', 'look', 'color')
CONFIG_DEFAULT_OPTIONS = (('relay.hostname', ''),
('relay.port', ''),
CONFIG_DEFAULT_OPTIONS = (('relay.hostname', '127.0.0.1'),
('relay.port', '9000'),
('relay.ssl', 'off'),
('relay.password', ''),
('relay.autoconnect', 'off'),
('relay.lines', str(CONFIG_DEFAULT_RELAY_LINES)),
('look.debug', 'off'),
('look.statusbar', 'off'))
('look.statusbar', 'on'))
# Default colors for WeeChat color options (option name, #rgb value)
CONFIG_DEFAULT_COLOR_OPTIONS = (

View File

@ -22,7 +22,7 @@
"""Connection window."""
from PySide6 import QtGui, QtWidgets
from PyQt5 import QtGui, QtWidgets
class ConnectionDialog(QtWidgets.QDialog):

View File

@ -22,7 +22,7 @@
"""Debug window."""
from PySide6 import QtWidgets
from PyQt5 import QtWidgets
from qweechat.chat import ChatTextEdit
from qweechat.input import InputLineEdit

View File

@ -22,15 +22,16 @@
"""Input line for chat and debug window."""
from PySide6 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtCore import pyqtSignal
Signal = pyqtSignal
class InputLineEdit(QtWidgets.QLineEdit):
"""Input line."""
bufferSwitchPrev = QtCore.Signal()
bufferSwitchNext = QtCore.Signal()
textSent = QtCore.Signal(str)
bufferSwitchPrev = Signal()
bufferSwitchNext = Signal()
textSent = Signal(str)
def __init__(self, scroll_widget):
super().__init__()

View File

@ -26,7 +26,9 @@ import hashlib
import secrets
import struct
from PySide6 import QtCore, QtNetwork
from PyQt5 import QtCore, QtNetwork
from PyQt5.QtCore import pyqtSignal
Signal = pyqtSignal
from qweechat import config
from qweechat.debug import DebugDialog
@ -98,8 +100,8 @@ NETWORK_STATUS = {
class Network(QtCore.QObject):
"""I/O with WeeChat/relay."""
statusChanged = QtCore.Signal(str, str)
messageFromWeechat = QtCore.Signal(QtCore.QByteArray)
statusChanged = Signal(str, str)
messageFromWeechat = Signal(QtCore.QByteArray)
def __init__(self, *args):
super().__init__(*args)

View File

@ -22,7 +22,7 @@
"""Preferences dialog box."""
from PySide6 import QtCore, QtWidgets as QtGui
from PyQt5 import QtCore, QtWidgets as QtGui
class PreferencesDialog(QtGui.QDialog):

View File

@ -37,7 +37,7 @@ import sys
import traceback
from pkg_resources import resource_filename
from PySide6 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtGui, QtWidgets
from qweechat import config
from qweechat.about import AboutDialog
@ -52,7 +52,7 @@ APP_NAME = 'QWeeChat'
AUTHOR = 'Sébastien Helleu'
WEECHAT_SITE = 'https://weechat.org/'
# not QFrame
class MainWindow(QtWidgets.QMainWindow):
"""Main window."""
@ -87,10 +87,16 @@ class MainWindow(QtWidgets.QMainWindow):
splitter.addWidget(self.list_buffers)
splitter.addWidget(self.stacked_buffers)
self.list_buffers.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
QtWidgets.QSizePolicy.Preferred)
self.stacked_buffers.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)
# MainWindow
self.setCentralWidget(splitter)
if self.config.getboolean('look', 'statusbar'):
self.statusBar().visible = True
self.statusBar().visible = True
# actions for menu and toolbar
actions_def = {
@ -139,7 +145,7 @@ class MainWindow(QtWidgets.QMainWindow):
}
self.actions = {}
for name, action in list(actions_def.items()):
self.actions[name] = QtGui.QAction(
self.actions[name] = QtWidgets.QAction(
QtGui.QIcon(
resource_filename(__name__, 'data/icons/%s' % action[0])),
name.capitalize(), self)
@ -164,20 +170,22 @@ class MainWindow(QtWidgets.QMainWindow):
self.network_status.setFixedWidth(200)
self.network_status.setContentsMargins(0, 0, 10, 0)
self.network_status.setAlignment(QtCore.Qt.AlignRight)
if hasattr(self.menu, 'setCornerWidget'):
self.menu.setCornerWidget(self.network_status,
QtCore.Qt.TopRightCorner)
if hasattr(self, 'menuBar'):
if hasattr(self.menu, 'setCornerWidget'):
self.menu.setCornerWidget(self.network_status,
QtCore.Qt.TopRightCorner)
self.network_status_set(STATUS_DISCONNECTED)
# toolbar
toolbar = self.addToolBar('toolBar')
toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
toolbar.addActions([self.actions['connect'],
self.actions['disconnect'],
self.actions['debug'],
self.actions['preferences'],
self.actions['about'],
self.actions['quit']])
if hasattr(self, 'addToolBar'):
toolbar = self.addToolBar('toolBar')
toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
toolbar.addActions([self.actions['connect'],
self.actions['disconnect'],
self.actions['debug'],
self.actions['preferences'],
self.actions['about'],
self.actions['quit']])
self.buffers[0].widget.input.setFocus()
@ -258,8 +266,12 @@ class MainWindow(QtWidgets.QMainWindow):
def network_status_set(self, status):
"""Set the network status."""
pal = self.network_status.palette()
pal.setColor(self.network_status.foregroundRole(),
try:
pal.setColor(self.network_status.foregroundRole(),
self.network.status_color(status))
except:
# dunno
pass
ssl = ' (SSL)' if status != STATUS_DISCONNECTED \
and self.network.is_ssl() else ''
self.network_status.setPalette(pal)
@ -525,7 +537,7 @@ class MainWindow(QtWidgets.QMainWindow):
if self.network.debug_dialog:
self.network.debug_dialog.close()
config.write(self.config)
QtWidgets.QMainWindow.closeEvent(self, event)
QtWidgets.QFrame.closeEvent(self, event)
def main():

View File

@ -1 +1,2 @@
PySide6
PyQt5