switch from PyQt6 to PySide6

PySide6 uses LGPL instead of GPL, which is much nicer to work with.
This commit is contained in:
2022-01-30 10:50:31 +01:00
parent f33c8b0da5
commit f0555df0a9
30 changed files with 83 additions and 122 deletions

View File

@@ -1,7 +1,7 @@
import math
from PyQt6.QtWidgets import QScrollBar
from PyQt6.QtCore import pyqtSignal
from PySide6.QtWidgets import QScrollBar
from PySide6.QtCore import Signal
import logging
log = logging.getLogger("scaledScrollBar")
@@ -10,7 +10,7 @@ log = logging.getLogger("scaledScrollBar")
class ScaledScrollBar(QScrollBar):
is_huge = False
valueChanged = pyqtSignal(str)
scaledValueChanged = Signal(str)
"""Signal emitted when the scroll bar value changes.
**Note**: The value is a string and must be parsed into an int.
QT's signal api only supports 32bit integers. Ints larger
@@ -49,6 +49,6 @@ class ScaledScrollBar(QScrollBar):
if self.is_huge:
real_value = (value / self.maximum()) * self.real_maximum
# print("scaled value changed: %d -> %d (%f)" % (value, real_value, value / self.maximum()))
self.valueChanged.emit(str(int(real_value)))
self.scaledValueChanged.emit(str(int(real_value)))
else:
self.valueChanged.emit(str(int(value)))
self.scaledValueChanged.emit(str(int(value)))

View File

@@ -1,8 +1,9 @@
import textwrap
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QFont, QPixmap
from PyQt6.QtWidgets import *
import PySide6
from PySide6.QtCore import Qt
from PySide6.QtGui import QFont, QPixmap
from PySide6.QtWidgets import *
import constants
from label import Label
@@ -33,7 +34,7 @@ class AboutDialog(QDialog):
hbox = QHBoxLayout(heading)
hbox.addWidget(app_icon)
hbox.addWidget(VBox(heading_app_name, version))
hbox.addSpacerItem(QSpacerItem(1, 1, hPolicy=QSizePolicy.Policy.Expanding))
hbox.addSpacerItem(QSpacerItem(1, 1, hData=QSizePolicy.Policy.Expanding))
heading.layout = hbox
self.layout.addWidget(heading)
@@ -54,20 +55,24 @@ class AboutDialog(QDialog):
result.layout = QVBoxLayout(result)
label = Label(self.tr(textwrap.dedent("""
Log file viewer<br>
(c) 2021 Open Text Corporation<br>
<a href="https://www.opentext.com/">License: GPL</a>""")))
(c) 2022 Open Text Corporation<br>
<a href="https://www.opentext.com/">License: LGPL v3</a>""")))
result.layout.addWidget(label)
return result
def _license(self) -> QWidget:
dependencies = """
<ul>
<li>PySide6 {pyside} (LGPL v3) - <a href="https://doc.qt.io/qtforpython-6/">https://doc.qt.io/qtforpython-6/</a></li>
<li>Qt6 {qt} (LGPL v3) - <a href="https://code.qt.io/cgit/qt/qtbase.git/">https://code.qt.io/cgit/qt/qtbase.git/</a></li>
<li>urllib3 (MIT) - <a href="https://urllib3.readthedocs.io/en/stable/">https://urllib3.readthedocs.io/en/stable/</a></li>
<li>watchdog 2.16 (Apache 2.0) - <a href="https://github.com/gorakhargosh/watchdog">https://github.com/gorakhargosh/watchdog</a></li>
</ul>""".format(pyside=PySide6.__version__, qt=PySide6.QtCore.__version__)
label = self.tr(textwrap.dedent(dependencies))
result = QWidget()
result.layout = QVBoxLayout(result)
result.layout.addWidget(Label(self.tr(textwrap.dedent("""
<ul>
<li>PyQt6 6.2.1 (GPL v3)</li>
<li>Qt6 6.2.1 (LGPL v3) - <a href="https://code.qt.io/cgit/qt/qtbase.git/">https://code.qt.io/cgit/qt/qtbase.git/</a></li>
<li>watchdog 2.16 (Apache 2.0)</li>
</ul>"""))))
result.layout.addWidget(Label(label))
return result
def _version(self):
@@ -75,3 +80,4 @@ class AboutDialog(QDialog):
line = f.readline()
version = line.strip()
return version

View File

@@ -4,12 +4,12 @@ import math
import os
import time
from typing import Callable, List
from PyQt6 import QtGui
from PySide6 import QtGui
from PyQt6.QtCore import *
from PyQt6.QtGui import *
from PyQt6.QtGui import QMouseEvent
from PyQt6.QtWidgets import *
from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtGui import QMouseEvent
from PySide6.QtWidgets import *
import constants
from ScaledScrollBar import ScaledScrollBar
@@ -19,7 +19,7 @@ from highlighted_range import HighlightedRange
from highlightingdialog import HighlightingDialog
from line import Line
from logFileModel import LogFileModel
from raven.pluginregistry import PluginRegistry
from ravenui import RavenUI
from settings import Settings
@@ -86,7 +86,7 @@ class BigText(QWidget):
self.v_scroll_bar = ScaledScrollBar()
# self.v_scroll_bar.setPageStep(1)
self.v_scroll_bar.valueChanged.connect(self.big_text.v_scroll_event)
self.v_scroll_bar.scaledValueChanged.connect(self.big_text.v_scroll_event)
self.grid.addWidget(self.big_text, 0, 0)
self.grid.addWidget(self.h_scroll_bar, 1, 0)
@@ -271,11 +271,13 @@ class InnerBigText(QWidget):
self._left_offset = self._left_offset + 2
self.update()
@Slot()
def h_scroll_event(self, left_offset: int):
self._left_offset = left_offset
# print("left_offset: %d" % left_offset)
self.update()
@Slot()
def v_scroll_event(self, byte_offset: str):
self._byte_offset = int(byte_offset)
self.update()
@@ -354,13 +356,13 @@ class InnerBigText(QWidget):
dialog = QFileDialog(self)
(selected_file, _filter) = dialog.getSaveFileName(
caption=self.tr("Save File"),
directory=os.path.dirname(self.model.get_file())
dir=os.path.dirname(self.model.get_file())
)
if selected_file:
self.model.write_range(start, end, selected_file)
open_tab = self.model.settings.session.getboolean("general", "open_tab_on_save_as_file")
if open_tab:
RavenUI.window.open_file(selected_file)
PluginRegistry.execute("open_file", selected_file)
def _select_all(self):
self.selection_highlight.start_byte = 0

View File

@@ -1,12 +1,12 @@
import re
from PyQt6.QtGui import QColor, QPixmap, QIcon
from PyQt6.QtWidgets import QWidget, QHBoxLayout, QPushButton, QColorDialog, QSizePolicy, QComboBox
from PySide6.QtGui import QColor, QPixmap, QIcon
from PySide6.QtWidgets import QWidget, QHBoxLayout, QPushButton, QColorDialog, QSizePolicy, QComboBox
class ColorButton(QWidget):
def __init__(self, color: str):
super(QWidget, self).__init__()
def __init__(self, color: str, parent=None):
super(ColorButton, self).__init__(parent)
self.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
self.layout = QHBoxLayout(self)

View File

@@ -1,4 +1,4 @@
from PyQt6.QtCore import QSettings
from PySide6.QtCore import QSettings
class CuteSettings:

View File

@@ -4,8 +4,8 @@ import tempfile
import threading
from typing import Optional, Callable
from PyQt6.QtCore import QRunnable, QThreadPool
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QCheckBox, QPushButton
from PySide6.QtCore import QRunnable, QThreadPool
from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QCheckBox, QPushButton
from bigtext import BigText
from logFileModel import LogFileModel

View File

@@ -1,5 +1,5 @@
from PyQt6.QtWidgets import *
from PyQt6.QtCore import *
from PySide6.QtWidgets import *
from PySide6.QtCore import *
from bigtext import BigText
from filterviewsyncer import FilterViewSyncer

View File

@@ -1,4 +1,4 @@
from PyQt6.QtWidgets import QWidget, QHBoxLayout
from PySide6.QtWidgets import QWidget, QHBoxLayout
class HBox(QWidget):

View File

@@ -3,7 +3,7 @@ from typing import Optional
from highlight import Highlight
from highlighted_range import HighlightedRange
from line import Line
from PyQt6.QtGui import *
from PySide6.QtGui import QBrush, QColor
from typing import List
import re

View File

@@ -3,8 +3,8 @@ from typing import Optional, List
from highlight import Highlight
from highlighted_range import HighlightedRange
from line import Line
from PyQt6.QtCore import *
from PyQt6.QtGui import *
from PySide6.QtCore import Qt
from PySide6.QtGui import QBrush, QColor
from settings import Settings

View File

@@ -1,5 +1,5 @@
from PyQt6.QtCore import *
from PyQt6.QtGui import *
from PySide6.QtCore import Qt
from PySide6.QtGui import QBrush, QPen
class HighlightedRange:

View File

@@ -1,5 +1,5 @@
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QDialog, QLineEdit, QLabel, QGridLayout, QCheckBox, QListWidget, QListWidgetItem, \
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QDialog, QLineEdit, QLabel, QGridLayout, QCheckBox, QListWidget, QListWidgetItem, \
QPushButton, QDialogButtonBox, QMessageBox, QSizePolicy
from colorbutton import ColorButton

View File

@@ -1,5 +1,5 @@
from PyQt6.QtWidgets import QLabel
from PyQt6.QtCore import Qt
from PySide6.QtWidgets import QLabel
from PySide6.QtCore import Qt
class Label(QLabel):
@@ -7,4 +7,5 @@ class Label(QLabel):
super(Label, self).__init__(text)
self.setTextInteractionFlags(Qt.TextInteractionFlag.TextBrowserInteraction)
self.setTextInteractionFlags(Qt.TextInteractionFlag.LinksAccessibleByMouse)
self.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)
self.setOpenExternalLinks(True)

View File

@@ -1,5 +1,4 @@
import unicodedata
from typing import Dict
import constants

View File

@@ -1,9 +1,7 @@
import math
import re
from typing import List, Optional
from PyQt6.QtCore import pyqtSignal
from PySide6.QtCore import Signal
from highlight_regex import HighlightRegex
from highlighting import Highlighting
from line import Line
@@ -14,7 +12,7 @@ from settings import Settings
class LogFileModel:
_query_highlight: Optional[HighlightRegex] = None
file_size_changed = pyqtSignal(str)
file_size_changed = Signal()
"""Fires when the file size changed. **Note:** uses strings,
because int in Qt signal are limited to 32bit."""

View File

@@ -2,17 +2,16 @@ import logging
import signal
import ctypes
from PyQt6 import QtCore
from PyQt6.QtWidgets import *
from PyQt6.QtCore import *
from PyQt6.QtGui import *
from PySide6 import QtCore
from PySide6.QtWidgets import QApplication
from PySide6.QtCore import QTimer
from PySide6.QtGui import QIcon
import sys
import constants
from raven.pluginregistry import PluginRegistry
from ravenui import RavenUI
logging.basicConfig(level=logging.INFO)
log = logging.getLogger("main")

View File

@@ -1,9 +0,0 @@
import glob
import os
from PyQt6.lupdate import lupdate
if __name__ == "__main__":
python_files = glob.glob(r"*.py")
print(python_files)
lupdate(python_files, ["messages_de.ts"])

View File

@@ -1,9 +1,10 @@
import logging
from typing import List
from PyQt6.QtWidgets import *
from PyQt6.QtGui import *
from PyQt6.QtCore import Qt
from PySide6.QtWidgets import *
from PySide6.QtGui import *
from PySide6.QtCore import Qt
import urlutils
from cutesettings import CuteSettings
from raven.pluginregistry import PluginRegistry

View File

@@ -1,9 +1,6 @@
from types import ModuleType
from typing import Dict, Optional
from inspect import isclass
from pkgutil import iter_modules
from pathlib import Path
from os.path import dirname
from importlib import import_module
from inspect import signature
from raven.pluginbase import PluginBase

View File

@@ -1,7 +1,7 @@
import os.path
from typing import Callable, Optional
from PyQt6.QtWidgets import QMessageBox
from PySide6.QtWidgets import QMessageBox
from fulltabwidget import FullTabWidget
from logFileModel import LogFileModel

View File

@@ -1,5 +1,5 @@
from raven.plugins.ravenlog.Tab import Tab
from PyQt6.QtWidgets import *
from PySide6.QtWidgets import QTextEdit, QVBoxLayout
class NotesWidget(Tab):

View File

@@ -1,6 +1,6 @@
from typing import Callable
from PyQt6.QtCore import Qt
from PySide6.QtCore import Qt
from raven.pluginbase import PluginBase
from raven.pluginregistry import PluginRegistry

View File

@@ -1,8 +1,7 @@
import os
from typing import Callable
from pathlib import Path
from PyQt6.QtGui import QAction, QIcon
from PyQt6.QtWidgets import QMenu, QFileDialog
from PySide6.QtWidgets import QFileDialog
from raven.pluginbase import PluginBase
from raven.pluginregistry import PluginRegistry
@@ -47,8 +46,9 @@ class OpenFilePlugin(PluginBase):
dialog = QFileDialog()
(selected_file, _filter) = dialog.getOpenFileName(
caption=self.tr("Open File"),
directory=directory
dir=directory
)
# directory=directory
if selected_file:
self.open_file(selected_file)
@@ -71,7 +71,7 @@ class OpenFilePlugin(PluginBase):
files = self._get_recent_files()
for file in files:
action = RAction(os.path.basename(file))
action.set_action(lambda x, f=file: self.open_file(f))
action.set_action(lambda _="", f=file: self.open_file(f))
self._menu_recent_files.add_action(action)
def _remember_recent_file(self, file: str):

View File

@@ -1,6 +1,6 @@
from abc import abstractmethod
from PyQt6.QtWidgets import QWidget
from PySide6.QtWidgets import QWidget
class Tab(QWidget):

View File

@@ -1,8 +1,8 @@
import sys
from typing import Optional
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QDockWidget, QLabel
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QDockWidget
import constants
from aboutdialog import AboutDialog

View File

@@ -1,6 +1,4 @@
PyQt6==6.2.2
PyQt6-Qt6==6.2.2
PyQt6-sip==13.2.0
PySide6==6.2.2.1
six==1.16.0
urllib3==1.26.8
watchdog==2.1.6

View File

@@ -1,37 +1,10 @@
# extract icons from dll on windows
# https://mail.python.org/pipermail/python-win32/2009-April/009078.html
import re
import time
from highlighted_range import HighlightedRange
from line import Line
import PySide6.QtCore
result = []
# Prints PySide6 version
print(PySide6.__version__)
byte_offset = 123
text = "2021-09-21 08:40:38,187 [catalina-exec-37] INFO c.r.c.s.l.SearchAdapter - Fetched 0 fields, 1 folders, 0 content requests for 1 documents; took 763ms (including 0ms to fetch field names). [project=axcelerate.lds_5m_review2, session=37891bc0-a67e-4c43-90c0-c20da567f491, user=r-162] [kttsjx2h.48z.9ls] 2021-09-21 08:47:16,529 [BravaJobHandler-12] INFO c.r.b.c.f.i.DoneNotifierRunnable - CORE job for 'complete document request with output format xdl (source n.pdf)' complete. Notifying Brava server about completion for numId=LDS_001:00095883.. Extracting and moving XDL and SVG/Thumbs took 31ms (from remote stream from 172.28.60.208:51048,com.recommind.rmi.ssl.SslRmiExporter$CheckedSslRmiClientSocketFactory). Notifying with URL https://localhost:8889/BravaServer/done/xc_E4E99FE32A313D2FBA8D29F846C0EF439E8AE2BE159164D04B2AFD862F714BED_ (context switch time 0ms) [project=axcelerate.lds_5m_review2, session=500380b9-94c5-4740-b30a-81e9f6cd071d, user=r-377] [kttsjx2h.8ys.kai]"
start = time.time()
line = Line(byte_offset=byte_offset, byte_end=byte_offset + len(text.encode("utf8")), line=text)
regex = re.compile(r"\w", flags=re.IGNORECASE)
match_iter = re.finditer(regex, line.line())
for match in match_iter:
start_char = match.start(0)
end_char = match.end(0)
start_column = line.char_to_column(start_char)
end_column = line.char_to_column(end_char)
result.append(HighlightedRange(start_column, end_column - start_column, highlight_full_line=True, brush=None,
brush_full_line=None))
end = time.time()
print("duration: %.3f" % ((end - start) * 1000))
result = []
start = time.time()
for i in range(0, 10000):
result.append(i)
end = time.time()
print("duration: %.3f" % ((end - start) * 1000))
# Prints the Qt version used to compile PySide6
print(PySide6.QtCore.__version__)

View File

@@ -1,9 +1,6 @@
import os
from typing import Mapping, Optional
from typing import Optional
from PyQt6.QtWidgets import *
from PyQt6.QtCore import *
from PyQt6.QtGui import *
from PySide6.QtWidgets import QWidget, QTabWidget, QVBoxLayout
from bigtext import BigText
from fulltabwidget import FullTabWidget

View File

@@ -4,7 +4,6 @@ from configparser import ConfigParser
from os.path import join
from logFileModel import LogFileModel
from line import Line
from settings import Settings

View File

@@ -1,4 +1,4 @@
from PyQt6.QtWidgets import QWidget, QVBoxLayout
from PySide6.QtWidgets import QWidget, QVBoxLayout
class VBox(QWidget):