Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to PyQt6 #331

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions i18n_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import os
import re
import shutil
import subprocess
import sys
import shutil
from argparse import ArgumentParser
from pathlib import Path
from typing import Iterable
Expand All @@ -29,8 +29,8 @@

TS_DIR = Path("lisp/i18n/ts")
QM_DIR = Path("lisp/i18n/qm")
PYLUPDATE = "pylupdate5"
LRELEASE = "lrelease" if shutil.which("lrelease") else "lrelease-qt5"
PYLUPDATE = "pylupdate6"
LRELEASE = "lrelease" if shutil.which("lrelease") else "lrelease-qt6"


def dirs_path(path: str):
Expand Down Expand Up @@ -61,9 +61,10 @@ def modules_sources(
):
for module_path in modules_path:
if module_path.stem != "__pycache__":
yield module_path.stem, source_files(
module_path, extensions, exclude
),
yield (
module_path.stem,
source_files(module_path, extensions, exclude),
)


def pylupdate(
Expand Down
8 changes: 4 additions & 4 deletions lisp/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
from os.path import exists, dirname, abspath

from PyQt5.QtWidgets import QDialog, qApp
from PyQt6.QtWidgets import QDialog, QApplication

from lisp import layout, __version__ as lisp_version
from lisp.command.stack import CommandsStack
Expand Down Expand Up @@ -140,7 +140,7 @@ def __new_session_dialog(self):
try:
# Prompt the user for a new layout
dialog = LayoutSelect(self, parent=self.window)
if dialog.exec() == QDialog.Accepted:
if dialog.exec() == QDialog.DialogCode.Accepted:
# If a file is selected load it, otherwise load the layout
if dialog.sessionPath:
self.__load_from_file(dialog.sessionPath)
Expand All @@ -150,12 +150,12 @@ def __new_session_dialog(self):
if self.__session is None:
# If the user close the dialog, and no layout exists
# the application is closed
qApp.quit()
QApplication.instance().quit()
except Exception:
logger.critical(
translate("ApplicationError", "Startup error"), exc_info=True
)
qApp.quit()
QApplication.instance().quit()

def __new_session(self, layout):
self.__delete_session()
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from threading import Lock

from PyQt5.QtCore import QTimer
from PyQt6.QtCore import QTimer


class Clock(QTimer):
Expand Down
4 changes: 2 additions & 2 deletions lisp/core/plugins_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
from typing import Dict, Type, Union

from lisp import USER_PLUGINS_PATH, app_dirs, PLUGINS_PACKAGE, PLUGINS_PATH
from lisp.core.configuration import JSONFileConfiguration, DummyConfiguration
from lisp.core.configuration import JSONFileConfiguration
from lisp.core.loading import load_classes
from lisp.core.plugin import Plugin, PluginNotLoadedError, PluginState
from lisp.core.plugin import Plugin, PluginNotLoadedError
from lisp.core.plugin_loader import PluginsLoader
from lisp.ui.ui_utils import translate, install_translation

Expand Down
2 changes: 1 addition & 1 deletion lisp/core/qmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from abc import ABCMeta

from PyQt5.QtCore import QObject
from PyQt6.QtCore import QObject


class QMeta(type(QObject), type):
Expand Down
5 changes: 3 additions & 2 deletions lisp/core/session_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def __init__(self, uri: str = ""):
split = urlsplit(uri)

if split.scheme == "":
self._uri = urlunsplit(("file", "", quote(self.path_to_absolute(uri)), "", ""))
self._uri = urlunsplit(
("file", "", quote(self.path_to_absolute(uri)), "", "")
)
else:
self._uri = uri

Expand Down Expand Up @@ -67,4 +69,3 @@ def path_to_absolute(cls, path):
from lisp.application import Application

return Application().session.abs_path(path)

4 changes: 2 additions & 2 deletions lisp/core/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from threading import RLock
from types import MethodType, BuiltinMethodType

from PyQt5.QtCore import QEvent, QObject
from PyQt5.QtWidgets import QApplication
from PyQt6.QtCore import QEvent, QObject
from PyQt6.QtWidgets import QApplication

from lisp.core.decorators import async_function
from lisp.core.util import weak_call_proxy
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/singleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from abc import ABCMeta

from PyQt5.QtCore import QObject
from PyQt6.QtCore import QObject

from lisp.core.qmeta import QABCMeta

Expand Down
2 changes: 1 addition & 1 deletion lisp/cues/media_cue.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from threading import Lock

from PyQt5.QtCore import QT_TRANSLATE_NOOP
from PyQt6.QtCore import QT_TRANSLATE_NOOP

from lisp.core.decorators import async_function
from lisp.core.fade_functions import FadeInType, FadeOutType
Expand Down
4 changes: 2 additions & 2 deletions lisp/layout/cue_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from abc import abstractmethod

from PyQt5.QtCore import Qt
from PyQt6.QtCore import Qt

from lisp.command.cue import UpdateCueCommand, UpdateCuesCommand
from lisp.command.model import ModelRemoveItemsCommand
Expand Down Expand Up @@ -217,7 +217,7 @@ def show_cue_context_menu(self, cues, position):
if cues:
menu = self.CuesMenu.create_qmenu(cues, self.view)
# Avoid "leaking" references kept in the menu
menu.setAttribute(Qt.WA_DeleteOnClose)
menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.move(position)
menu.show()

Expand Down
3 changes: 2 additions & 1 deletion lisp/layout/cue_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

from functools import partial

from PyQt5.QtWidgets import QAction, QMenu
from PyQt6.QtGui import QAction
from PyQt6.QtWidgets import QMenu

from lisp.core.class_based_registry import ClassBasedRegistry
from lisp.core.util import greatest_common_superclass
Expand Down
8 changes: 4 additions & 4 deletions lisp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
from functools import partial
from logging.handlers import RotatingFileHandler

from PyQt5.QtCore import QLocale, QLibraryInfo, QTimer
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication
from PyQt6.QtCore import QLocale, QLibraryInfo, QTimer
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QApplication

from lisp import app_dirs, DEFAULT_APP_CONFIG, USER_APP_CONFIG, plugins
from lisp.application import Application
Expand Down Expand Up @@ -124,7 +124,7 @@ def main():
)

# Qt platform translation
qt_tr_path = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
qt_tr_path = QLibraryInfo.path(QLibraryInfo.LibraryPath.TranslationsPath)
# install_translation("qt", tr_path=qt_tr_path)
install_translation("qtbase", tr_path=qt_tr_path)
# Main app translations
Expand Down
24 changes: 13 additions & 11 deletions lisp/plugins/action_cues/collection_cue.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with Linux Show Player. If not, see <http://www.gnu.org/licenses/>.

from PyQt5.QtCore import Qt, QT_TRANSLATE_NOOP
from PyQt5.QtWidgets import (
from PyQt6.QtCore import Qt, QT_TRANSLATE_NOOP
from PyQt6.QtWidgets import (
QVBoxLayout,
QSizePolicy,
QDialogButtonBox,
Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(self, **kwargs):

self.cueDialog = CueSelectDialog(
cues=Application().cue_model,
selection_mode=QAbstractItemView.ExtendedSelection,
selection_mode=QAbstractItemView.SelectionMode.ExtendedSelection,
)
self.collectionModel = CollectionModel()

Expand All @@ -85,20 +85,20 @@ def __init__(self, **kwargs):
# Buttons
self.dialogButtons = QDialogButtonBox(self.collectionGroup)
self.dialogButtons.setSizePolicy(
QSizePolicy.Minimum, QSizePolicy.Minimum
QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum
)
self.collectionGroup.layout().addWidget(self.dialogButtons)

self.addButton = QPushButton(self.dialogButtons)
self.dialogButtons.addButton(
self.addButton, QDialogButtonBox.ActionRole
self.addButton, QDialogButtonBox.ButtonRole.ActionRole
)
self.addButton.clicked.connect(self._showAddCueDialog)

self.delButton = QPushButton(self.dialogButtons)
self.delButton.setEnabled(False)
self.dialogButtons.addButton(
self.delButton, QDialogButtonBox.ActionRole
self.delButton, QDialogButtonBox.ButtonRole.ActionRole
)
self.delButton.clicked.connect(self._removeCurrentCue)

Expand Down Expand Up @@ -136,7 +136,7 @@ def _addCue(self, cue, action):
self.delButton.setEnabled(True)

def _showAddCueDialog(self):
if self.cueDialog.exec() == QDialog.Accepted:
if self.cueDialog.exec() == QDialog.DialogCode.Accepted:
for target in self.cueDialog.selected_cues():
self._addCue(target, target.CueActions[0])

Expand All @@ -162,10 +162,12 @@ def __init__(self, cueModel, cueSelect, **kwargs):
self.setShowGrid(False)
self.setAlternatingRowColors(True)

self.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(
QHeaderView.ResizeMode.Stretch
)
self.horizontalHeader().setHighlightSections(False)

self.verticalHeader().sectionResizeMode(QHeaderView.Fixed)
self.verticalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Fixed)
self.verticalHeader().setDefaultSectionSize(26)
self.verticalHeader().setHighlightSections(False)

Expand All @@ -188,7 +190,7 @@ def __init__(self):
]
)

def setData(self, index, value, role=Qt.DisplayRole):
def setData(self, index, value, role=Qt.ItemDataRole.DisplayRole):
result = super().setData(index, value, role)

if result and role == CueClassRole:
Expand All @@ -197,7 +199,7 @@ def setData(self, index, value, role=Qt.DisplayRole):
self.dataChanged.emit(
self.index(index.row(), 1),
self.index(index.row(), 1),
[Qt.DisplayRole, Qt.EditRole],
[Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole],
)

return result
Expand Down
22 changes: 11 additions & 11 deletions lisp/plugins/action_cues/command_cue.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import logging
import subprocess

from PyQt5.QtCore import Qt, QT_TRANSLATE_NOOP
from PyQt5.QtWidgets import QVBoxLayout, QGroupBox, QLineEdit, QCheckBox
from PyQt6.QtCore import Qt, QT_TRANSLATE_NOOP
from PyQt6.QtWidgets import QVBoxLayout, QGroupBox, QLineEdit, QCheckBox

from lisp import RUNNING_IN_FLATPAK
from lisp.core.decorators import async_function
Expand Down Expand Up @@ -120,7 +120,7 @@ class CommandCueSettings(SettingsPage):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setLayout(QVBoxLayout())
self.layout().setAlignment(Qt.AlignTop)
self.layout().setAlignment(Qt.AlignmentFlag.AlignTop)

self.group = QGroupBox(self)
self.group.setLayout(QVBoxLayout(self.group))
Expand Down Expand Up @@ -171,10 +171,10 @@ def enableCheck(self, enabled):
self.runOnHost.setTristate(enabled)

if enabled:
self.noOutputCheckBox.setCheckState(Qt.PartiallyChecked)
self.killCheckBox.setCheckState(Qt.PartiallyChecked)
self.killCheckBox.setCheckState(Qt.PartiallyChecked)
self.runOnHost.setChecked(Qt.PartiallyChecked)
self.noOutputCheckBox.setCheckState(Qt.CheckState.PartiallyChecked)
self.killCheckBox.setCheckState(Qt.CheckState.PartiallyChecked)
self.killCheckBox.setCheckState(Qt.CheckState.PartiallyChecked)
self.runOnHost.setChecked(Qt.CheckState.PartiallyChecked)

def loadSettings(self, settings):
self.commandLineEdit.setText(settings.get("command", ""))
Expand All @@ -191,13 +191,13 @@ def getSettings(self):
and self.commandLineEdit.text().strip()
):
settings["command"] = self.commandLineEdit.text()
if self.noOutputCheckBox.checkState() != Qt.PartiallyChecked:
if self.noOutputCheckBox.checkState() != Qt.CheckState.PartiallyChecked:
settings["no_output"] = self.noOutputCheckBox.isChecked()
if self.noErrorCheckBox.checkState() != Qt.PartiallyChecked:
if self.noErrorCheckBox.checkState() != Qt.CheckState.PartiallyChecked:
settings["no_error"] = self.noErrorCheckBox.isChecked()
if self.killCheckBox.checkState() != Qt.PartiallyChecked:
if self.killCheckBox.checkState() != Qt.CheckState.PartiallyChecked:
settings["kill"] = self.killCheckBox.isChecked()
if self.runOnHost.checkState() != Qt.PartiallyChecked:
if self.runOnHost.checkState() != Qt.CheckState.PartiallyChecked:
settings["run_on_host"] = self.runOnHost.isChecked()

return settings
Expand Down
10 changes: 5 additions & 5 deletions lisp/plugins/action_cues/index_action_cue.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with Linux Show Player. If not, see <http://www.gnu.org/licenses/>.

from PyQt5.QtCore import Qt, QT_TRANSLATE_NOOP
from PyQt5.QtWidgets import (
from PyQt6.QtCore import Qt, QT_TRANSLATE_NOOP
from PyQt6.QtWidgets import (
QCheckBox,
QGroupBox,
QLabel,
Expand Down Expand Up @@ -69,7 +69,7 @@ class IndexActionCueSettings(SettingsPage):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.setLayout(QVBoxLayout())
self.layout().setAlignment(Qt.AlignTop)
self.layout().setAlignment(Qt.AlignmentFlag.AlignTop)

self._cue_index = 0
self._target_class = Cue
Expand All @@ -88,7 +88,7 @@ def __init__(self, **kwargs):
self.indexGroup.layout().addWidget(self.targetIndexSpin, 1, 0)

self.targetIndexLabel = QLabel(self)
self.targetIndexLabel.setAlignment(Qt.AlignCenter)
self.targetIndexLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.indexGroup.layout().addWidget(self.targetIndexLabel, 1, 1)

self.actionGroup = QGroupBox(self)
Expand All @@ -107,7 +107,7 @@ def __init__(self, **kwargs):
self.layout().addWidget(self.suggestionGroup)

self.suggestionPreview = QLineEdit(self.suggestionGroup)
self.suggestionPreview.setAlignment(Qt.AlignCenter)
self.suggestionPreview.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.suggestionPreview.setText(
IndexActionCueSettings.DEFAULT_SUGGESTION
)
Expand Down
Loading