Convert to PyQt5
This commit is contained in:
parent
82e0d92056
commit
ba73b0ac36
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
"""About dialog box."""
|
"""About dialog box."""
|
||||||
|
|
||||||
from PySide6 import QtCore, QtWidgets as QtGui
|
from PyQt5 import QtCore, QtWidgets as QtGui
|
||||||
|
|
||||||
from qweechat.version import qweechat_version
|
from qweechat.version import qweechat_version
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
|
|
||||||
from pkg_resources import resource_filename
|
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.chat import ChatTextEdit
|
||||||
from qweechat.input import InputLineEdit
|
from qweechat.input import InputLineEdit
|
||||||
@ -145,7 +147,7 @@ class BufferWidget(QtWidgets.QWidget):
|
|||||||
class Buffer(QtCore.QObject):
|
class Buffer(QtCore.QObject):
|
||||||
"""A WeeChat buffer."""
|
"""A WeeChat buffer."""
|
||||||
|
|
||||||
bufferInput = QtCore.Signal(str, str)
|
bufferInput = Signal(str, str)
|
||||||
|
|
||||||
def __init__(self, data=None):
|
def __init__(self, data=None):
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from PySide6 import QtCore, QtWidgets, QtGui
|
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||||
|
|
||||||
from qweechat import config
|
from qweechat import config
|
||||||
from qweechat.weechat import color
|
from qweechat.weechat import color
|
||||||
|
@ -33,14 +33,14 @@ CONFIG_FILENAME = '%s/qweechat.conf' % CONFIG_DIR
|
|||||||
CONFIG_DEFAULT_RELAY_LINES = 50
|
CONFIG_DEFAULT_RELAY_LINES = 50
|
||||||
|
|
||||||
CONFIG_DEFAULT_SECTIONS = ('relay', 'look', 'color')
|
CONFIG_DEFAULT_SECTIONS = ('relay', 'look', 'color')
|
||||||
CONFIG_DEFAULT_OPTIONS = (('relay.hostname', ''),
|
CONFIG_DEFAULT_OPTIONS = (('relay.hostname', '127.0.0.1'),
|
||||||
('relay.port', ''),
|
('relay.port', '9000'),
|
||||||
('relay.ssl', 'off'),
|
('relay.ssl', 'off'),
|
||||||
('relay.password', ''),
|
('relay.password', ''),
|
||||||
('relay.autoconnect', 'off'),
|
('relay.autoconnect', 'off'),
|
||||||
('relay.lines', str(CONFIG_DEFAULT_RELAY_LINES)),
|
('relay.lines', str(CONFIG_DEFAULT_RELAY_LINES)),
|
||||||
('look.debug', 'off'),
|
('look.debug', 'off'),
|
||||||
('look.statusbar', 'off'))
|
('look.statusbar', 'on'))
|
||||||
|
|
||||||
# Default colors for WeeChat color options (option name, #rgb value)
|
# Default colors for WeeChat color options (option name, #rgb value)
|
||||||
CONFIG_DEFAULT_COLOR_OPTIONS = (
|
CONFIG_DEFAULT_COLOR_OPTIONS = (
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
"""Connection window."""
|
"""Connection window."""
|
||||||
|
|
||||||
from PySide6 import QtGui, QtWidgets
|
from PyQt5 import QtGui, QtWidgets
|
||||||
|
|
||||||
|
|
||||||
class ConnectionDialog(QtWidgets.QDialog):
|
class ConnectionDialog(QtWidgets.QDialog):
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
"""Debug window."""
|
"""Debug window."""
|
||||||
|
|
||||||
from PySide6 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
|
|
||||||
from qweechat.chat import ChatTextEdit
|
from qweechat.chat import ChatTextEdit
|
||||||
from qweechat.input import InputLineEdit
|
from qweechat.input import InputLineEdit
|
||||||
|
@ -22,15 +22,16 @@
|
|||||||
|
|
||||||
"""Input line for chat and debug window."""
|
"""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):
|
class InputLineEdit(QtWidgets.QLineEdit):
|
||||||
"""Input line."""
|
"""Input line."""
|
||||||
|
|
||||||
bufferSwitchPrev = QtCore.Signal()
|
bufferSwitchPrev = Signal()
|
||||||
bufferSwitchNext = QtCore.Signal()
|
bufferSwitchNext = Signal()
|
||||||
textSent = QtCore.Signal(str)
|
textSent = Signal(str)
|
||||||
|
|
||||||
def __init__(self, scroll_widget):
|
def __init__(self, scroll_widget):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -26,7 +26,9 @@ import hashlib
|
|||||||
import secrets
|
import secrets
|
||||||
import struct
|
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 import config
|
||||||
from qweechat.debug import DebugDialog
|
from qweechat.debug import DebugDialog
|
||||||
@ -98,8 +100,8 @@ NETWORK_STATUS = {
|
|||||||
class Network(QtCore.QObject):
|
class Network(QtCore.QObject):
|
||||||
"""I/O with WeeChat/relay."""
|
"""I/O with WeeChat/relay."""
|
||||||
|
|
||||||
statusChanged = QtCore.Signal(str, str)
|
statusChanged = Signal(str, str)
|
||||||
messageFromWeechat = QtCore.Signal(QtCore.QByteArray)
|
messageFromWeechat = Signal(QtCore.QByteArray)
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
super().__init__(*args)
|
super().__init__(*args)
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
"""Preferences dialog box."""
|
"""Preferences dialog box."""
|
||||||
|
|
||||||
from PySide6 import QtCore, QtWidgets as QtGui
|
from PyQt5 import QtCore, QtWidgets as QtGui
|
||||||
|
|
||||||
|
|
||||||
class PreferencesDialog(QtGui.QDialog):
|
class PreferencesDialog(QtGui.QDialog):
|
||||||
|
@ -37,7 +37,7 @@ import sys
|
|||||||
import traceback
|
import traceback
|
||||||
from pkg_resources import resource_filename
|
from pkg_resources import resource_filename
|
||||||
|
|
||||||
from PySide6 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
from qweechat import config
|
from qweechat import config
|
||||||
from qweechat.about import AboutDialog
|
from qweechat.about import AboutDialog
|
||||||
@ -52,7 +52,7 @@ APP_NAME = 'QWeeChat'
|
|||||||
AUTHOR = 'Sébastien Helleu'
|
AUTHOR = 'Sébastien Helleu'
|
||||||
WEECHAT_SITE = 'https://weechat.org/'
|
WEECHAT_SITE = 'https://weechat.org/'
|
||||||
|
|
||||||
|
# not QFrame
|
||||||
class MainWindow(QtWidgets.QMainWindow):
|
class MainWindow(QtWidgets.QMainWindow):
|
||||||
"""Main window."""
|
"""Main window."""
|
||||||
|
|
||||||
@ -87,10 +87,16 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
splitter.addWidget(self.list_buffers)
|
splitter.addWidget(self.list_buffers)
|
||||||
splitter.addWidget(self.stacked_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)
|
self.setCentralWidget(splitter)
|
||||||
|
|
||||||
if self.config.getboolean('look', 'statusbar'):
|
if self.config.getboolean('look', 'statusbar'):
|
||||||
self.statusBar().visible = True
|
self.statusBar().visible = True
|
||||||
|
self.statusBar().visible = True
|
||||||
|
|
||||||
# actions for menu and toolbar
|
# actions for menu and toolbar
|
||||||
actions_def = {
|
actions_def = {
|
||||||
@ -139,7 +145,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
}
|
}
|
||||||
self.actions = {}
|
self.actions = {}
|
||||||
for name, action in list(actions_def.items()):
|
for name, action in list(actions_def.items()):
|
||||||
self.actions[name] = QtGui.QAction(
|
self.actions[name] = QtWidgets.QAction(
|
||||||
QtGui.QIcon(
|
QtGui.QIcon(
|
||||||
resource_filename(__name__, 'data/icons/%s' % action[0])),
|
resource_filename(__name__, 'data/icons/%s' % action[0])),
|
||||||
name.capitalize(), self)
|
name.capitalize(), self)
|
||||||
@ -164,12 +170,14 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
self.network_status.setFixedWidth(200)
|
self.network_status.setFixedWidth(200)
|
||||||
self.network_status.setContentsMargins(0, 0, 10, 0)
|
self.network_status.setContentsMargins(0, 0, 10, 0)
|
||||||
self.network_status.setAlignment(QtCore.Qt.AlignRight)
|
self.network_status.setAlignment(QtCore.Qt.AlignRight)
|
||||||
|
if hasattr(self, 'menuBar'):
|
||||||
if hasattr(self.menu, 'setCornerWidget'):
|
if hasattr(self.menu, 'setCornerWidget'):
|
||||||
self.menu.setCornerWidget(self.network_status,
|
self.menu.setCornerWidget(self.network_status,
|
||||||
QtCore.Qt.TopRightCorner)
|
QtCore.Qt.TopRightCorner)
|
||||||
self.network_status_set(STATUS_DISCONNECTED)
|
self.network_status_set(STATUS_DISCONNECTED)
|
||||||
|
|
||||||
# toolbar
|
# toolbar
|
||||||
|
if hasattr(self, 'addToolBar'):
|
||||||
toolbar = self.addToolBar('toolBar')
|
toolbar = self.addToolBar('toolBar')
|
||||||
toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
|
toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
|
||||||
toolbar.addActions([self.actions['connect'],
|
toolbar.addActions([self.actions['connect'],
|
||||||
@ -258,8 +266,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
def network_status_set(self, status):
|
def network_status_set(self, status):
|
||||||
"""Set the network status."""
|
"""Set the network status."""
|
||||||
pal = self.network_status.palette()
|
pal = self.network_status.palette()
|
||||||
|
try:
|
||||||
pal.setColor(self.network_status.foregroundRole(),
|
pal.setColor(self.network_status.foregroundRole(),
|
||||||
self.network.status_color(status))
|
self.network.status_color(status))
|
||||||
|
except:
|
||||||
|
# dunno
|
||||||
|
pass
|
||||||
ssl = ' (SSL)' if status != STATUS_DISCONNECTED \
|
ssl = ' (SSL)' if status != STATUS_DISCONNECTED \
|
||||||
and self.network.is_ssl() else ''
|
and self.network.is_ssl() else ''
|
||||||
self.network_status.setPalette(pal)
|
self.network_status.setPalette(pal)
|
||||||
@ -525,7 +537,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
if self.network.debug_dialog:
|
if self.network.debug_dialog:
|
||||||
self.network.debug_dialog.close()
|
self.network.debug_dialog.close()
|
||||||
config.write(self.config)
|
config.write(self.config)
|
||||||
QtWidgets.QMainWindow.closeEvent(self, event)
|
QtWidgets.QFrame.closeEvent(self, event)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -1 +1,2 @@
|
|||||||
PySide6
|
PyQt5
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user