diff --git a/qweechat/about.py b/qweechat/about.py index 01b7605..ac28af0 100644 --- a/qweechat/about.py +++ b/qweechat/about.py @@ -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 diff --git a/qweechat/buffer.py b/qweechat/buffer.py index 2f6e32f..b51afd6 100644 --- a/qweechat/buffer.py +++ b/qweechat/buffer.py @@ -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) diff --git a/qweechat/chat.py b/qweechat/chat.py index b8a3788..328de1a 100644 --- a/qweechat/chat.py +++ b/qweechat/chat.py @@ -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 diff --git a/qweechat/config.py b/qweechat/config.py index 42fbba4..ffdf793 100644 --- a/qweechat/config.py +++ b/qweechat/config.py @@ -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 = ( diff --git a/qweechat/connection.py b/qweechat/connection.py index c9631ff..43d898f 100644 --- a/qweechat/connection.py +++ b/qweechat/connection.py @@ -22,7 +22,7 @@ """Connection window.""" -from PySide6 import QtGui, QtWidgets +from PyQt5 import QtGui, QtWidgets class ConnectionDialog(QtWidgets.QDialog): diff --git a/qweechat/debug.py b/qweechat/debug.py index 3267adc..785be98 100644 --- a/qweechat/debug.py +++ b/qweechat/debug.py @@ -22,7 +22,7 @@ """Debug window.""" -from PySide6 import QtWidgets +from PyQt5 import QtWidgets from qweechat.chat import ChatTextEdit from qweechat.input import InputLineEdit diff --git a/qweechat/input.py b/qweechat/input.py index 1ec3d3d..739a63f 100644 --- a/qweechat/input.py +++ b/qweechat/input.py @@ -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__() diff --git a/qweechat/network.py b/qweechat/network.py index b7d802c..5e3fe65 100644 --- a/qweechat/network.py +++ b/qweechat/network.py @@ -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) diff --git a/qweechat/preferences.py b/qweechat/preferences.py index f760bbc..fc415da 100644 --- a/qweechat/preferences.py +++ b/qweechat/preferences.py @@ -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): diff --git a/qweechat/qweechat.py b/qweechat/qweechat.py index f58d920..96f8f6a 100644 --- a/qweechat/qweechat.py +++ b/qweechat/qweechat.py @@ -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(): diff --git a/requirements.txt b/requirements.txt index 7fa34f0..c698f7e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -PySide6 +PyQt5 +