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

Upgrading from Qt5 #1589

Closed
wants to merge 8 commits into from
Closed
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
314 changes: 272 additions & 42 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

32 changes: 26 additions & 6 deletions .github/workflows/ci/workflow_context.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ vars:
python: '3.9'
os: Linux
platform: ubuntu-18.04
system_deps:

- &dist_macos
variant: macOS
Expand Down Expand Up @@ -66,12 +67,30 @@ jobs:
python: '3.10'

# Qt GUI tests.
- <<: *test
- &test_gui
<<: *test
type: test_gui_qt
variant: Qt GUI
reqs: ['dist', 'dist_extra_gui_qt', 'test']
variant: PyQt5 GUI
qt_api: PyQt5
reqs: ['dist', 'dist_extra_gui_qt', 'dist_pyqt5', 'setup', 'test']
skiplists: ['job_test_gui_qt']
test_args: test/gui_qt
- <<: *test_gui
platform: ubuntu-20.04
variant: PyQt6 GUI
qt_api: PyQt6
reqs: ['dist', 'dist_extra_gui_qt', 'dist_pyqt6', 'setup', 'test']
system_deps: libegl1
- <<: *test_gui
variant: PySide2 GUI
qt_api: PySide2
reqs: ['dist', 'dist_extra_gui_qt', 'dist_pyside2', 'setup', 'test']
- <<: *test_gui
platform: ubuntu-20.04
variant: PySide6 GUI
qt_api: PySide6
reqs: ['dist', 'dist_extra_gui_qt', 'dist_pyside6', 'setup', 'test']
system_deps: libegl1

# Packaging tests.
- <<: *dist_other
Expand All @@ -87,15 +106,16 @@ jobs:
type: build
needs: [test_linux]
reqs: ['build', 'setup']
cache_extra_deps: ['reqs/dist_*.txt', 'linux/appimage/deps.sh']
cache_extra_deps: ['reqs/dist_extra*.txt', 'reqs/dist_plugins.txt', 'reqs/dist_pyqt5', 'linux/appimage/deps.sh']
skiplists: ['job_build', 'os_linux']
system_deps: libdbus-1-dev libdbus-glib-1-dev libudev-dev libusb-1.0-0-dev
- <<: *build
<<: *dist_macos
needs: [test_macos]
cache_extra_deps: ['reqs/dist_*.txt', 'osx/deps.sh']
cache_extra_deps: ['reqs/dist_extra*.txt', 'reqs/dist_plugins.txt', 'reqs/dist_pyqt5', 'osx/deps.sh']
skiplists: ['job_build', 'os_macos']
- <<: *build
<<: *dist_win
needs: [test_windows]
cache_extra_deps: ['reqs/dist_*.txt', 'windows/dist_deps.sh']
cache_extra_deps: ['reqs/dist_extra*.txt', 'reqs/dist_plugins.txt', 'reqs/dist_pyqt5', 'windows/dist_deps.sh']
skiplists: ['job_build', 'os_windows']
8 changes: 6 additions & 2 deletions .github/workflows/ci/workflow_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ jobs:
run: setup_osx_python '<@ j.python @>'

<% endif %>
<% if j.type == 'build' and j.os == 'Linux' %>
<% if j.os == 'Linux' and j.system_deps %>
- name: Install system dependencies
run: apt_get_install libdbus-1-dev libdbus-glib-1-dev libudev-dev libusb-1.0-0-dev
run: apt_get_install <@ j.system_deps @>

<% endif %>
- name: Setup Python environment
Expand All @@ -154,6 +154,10 @@ jobs:
# Test {{{

- name: Run tests
<% if j.type == 'test_gui_qt' %>
env:
QT_API: <@ j.qt_api @>
<% endif %>
run: run_tests <@ j.test_args @>


Expand Down
4 changes: 2 additions & 2 deletions plover/gui_qt/about_dialog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import re

from PyQt5.QtWidgets import QDialog
from qtpy.QtWidgets import QDialog

import plover

Expand Down Expand Up @@ -34,7 +34,7 @@ def __init__(self, engine):
<h2>Credits:</h2>
<p>%(credits)s</p>
''' % {
'icon' : ':/plover.png',
'icon' : 'plover:plover.png',
'name' : plover.__name__.capitalize(),
'version' : plover.__version__,
'description': plover.__long_description__,
Expand Down
8 changes: 4 additions & 4 deletions plover/gui_qt/add_translation_dialog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5.QtWidgets import QDialogButtonBox
from qtpy.QtWidgets import QDialogButtonBox

from plover import _

Expand All @@ -12,14 +12,14 @@ class AddTranslationDialog(Tool, Ui_AddTranslationDialog):
__doc__ = _('Add a new translation to the dictionary.')

TITLE = _('Add Translation')
ICON = ':/translation_add.svg'
ICON = 'plover:translation_add.svg'
ROLE = 'add_translation'
SHORTCUT = 'Ctrl+N'

def __init__(self, engine, dictionary_path=None):
super().__init__(engine)
self.setupUi(self)
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
self.add_translation.select_dictionary(dictionary_path)
self.add_translation.mappingValid.connect(self.on_mapping_valid)
engine.signal_connect('config_changed', self.on_config_changed)
Expand All @@ -29,7 +29,7 @@ def __init__(self, engine, dictionary_path=None):
self.finished.connect(self.save_state)

def on_mapping_valid(self, valid):
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(valid)
self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(valid)

def on_config_changed(self, config_update):
if 'translation_frame_opacity' in config_update:
Expand Down
10 changes: 5 additions & 5 deletions plover/gui_qt/add_translation_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from html import escape as html_escape
from os.path import split as os_path_split

from PyQt5.QtCore import QEvent, pyqtSignal
from PyQt5.QtWidgets import QApplication, QWidget
from qtpy.QtCore import QEvent, Signal
from qtpy.QtWidgets import QApplication, QWidget

from plover import _
from plover.misc import shorten_path
Expand All @@ -24,7 +24,7 @@ class AddTranslationWidget(QWidget, Ui_AddTranslationWidget):

EngineState = namedtuple('EngineState', 'dictionary_filter translator starting_stroke')

mappingValid = pyqtSignal(bool)
mappingValid = Signal(bool)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -102,12 +102,12 @@ def select_dictionary(self, dictionary_path):
self._update_items()

def eventFilter(self, watched, event):
if event.type() == QEvent.FocusIn:
if event.type() == QEvent.Type.FocusIn:
if watched == self.strokes:
self._focus_strokes()
elif watched == self.translation:
self._focus_translation()
elif event.type() == QEvent.FocusOut:
elif event.type() == QEvent.Type.FocusOut:
if watched in (self.strokes, self.translation):
self._unfocus()
return False
Expand Down
45 changes: 22 additions & 23 deletions plover/gui_qt/config_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
from copy import copy
from functools import partial

from PyQt5.QtCore import (
from qtpy.QtCore import (
Qt,
QVariant,
pyqtSignal,
Signal,
)
from PyQt5.QtWidgets import (
from qtpy.QtWidgets import (
QCheckBox,
QComboBox,
QDialog,
Expand Down Expand Up @@ -37,7 +36,7 @@

class NopeOption(QLabel):

valueChanged = pyqtSignal(bool)
valueChanged = Signal(bool)

def __init__(self):
super().__init__()
Expand All @@ -51,7 +50,7 @@ def setValue(self, value):

class BooleanOption(QCheckBox):

valueChanged = pyqtSignal(bool)
valueChanged = Signal(bool)

def __init__(self):
super().__init__()
Expand All @@ -73,7 +72,7 @@ def __init__(self, maximum=None, minimum=None):

class ChoiceOption(QComboBox):

valueChanged = pyqtSignal(str)
valueChanged = Signal(str)

def __init__(self, choices=None):
super().__init__()
Expand All @@ -91,7 +90,7 @@ def on_activated(self, index):

class FileOption(QGroupBox, Ui_FileWidget):

valueChanged = pyqtSignal(str)
valueChanged = Signal(str)

def __init__(self, dialog_title, dialog_filter):
super().__init__()
Expand Down Expand Up @@ -123,9 +122,9 @@ class TableOption(QTableWidget):
def __init__(self):
super().__init__()
self.horizontalHeader().setStretchLastSection(True)
self.setSelectionMode(self.SingleSelection)
self.setSelectionMode(self.SelectionMode.SingleSelection)
self.setTabKeyNavigation(False)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.verticalHeader().hide()
self.currentItemChanged.connect(self._on_current_item_changed)

Expand All @@ -149,7 +148,7 @@ def _on_current_item_changed(self, current, previous):

class KeymapOption(TableOption):

valueChanged = pyqtSignal(QVariant)
valueChanged = Signal(object)

class ItemDelegate(QStyledItemDelegate):

Expand Down Expand Up @@ -191,7 +190,7 @@ def setValue(self, value):
row += 1
self.insertRow(row)
item = QTableWidgetItem(key)
item.setFlags(item.flags() & ~Qt.ItemIsEditable)
item.setFlags(item.flags() & ~Qt.ItemFlag.ItemIsEditable)
self.setItem(row, 0, item)
item = QTableWidgetItem(action)
self.setItem(row, 1, item)
Expand All @@ -203,8 +202,8 @@ def setValue(self, value):
def _on_cell_changed(self, row, column):
if self._updating:
return
key = self.item(row, 0).data(Qt.DisplayRole)
action = self.item(row, 1).data(Qt.DisplayRole)
key = self.item(row, 0).data(Qt.ItemDataRole.DisplayRole)
action = self.item(row, 1).data(Qt.ItemDataRole.DisplayRole)
bindings = self._value.get_bindings()
if action:
bindings[key] = action
Expand All @@ -216,7 +215,7 @@ def _on_cell_changed(self, row, column):

class MultipleChoicesOption(TableOption):

valueChanged = pyqtSignal(QVariant)
valueChanged = Signal(object)

LABELS = (
# i18n: Widget: “MultipleChoicesOption”.
Expand Down Expand Up @@ -257,11 +256,11 @@ def setValue(self, value):
row += 1
self.insertRow(row)
item = QTableWidgetItem(self._choices[choice])
item.setFlags(item.flags() & ~Qt.ItemIsEditable)
item.setFlags(item.flags() & ~Qt.ItemFlag.ItemIsEditable)
self.setItem(row, 0, item)
item = QTableWidgetItem()
item.setFlags((item.flags() & ~Qt.ItemIsEditable) | Qt.ItemIsUserCheckable)
item.setCheckState(Qt.Checked if choice in value else Qt.Unchecked)
item.setFlags((item.flags() & ~Qt.ItemFlag.ItemIsEditable) | Qt.ItemFlag.ItemIsUserCheckable)
item.setCheckState(Qt.CheckState.Checked if choice in value else Qt.CheckState.Unchecked)
self.setItem(row, 1, item)
self.resizeColumnsToContents()
self.setMinimumSize(self.viewportSizeHint())
Expand All @@ -271,7 +270,7 @@ def _on_cell_changed(self, row, column):
if self._updating:
return
assert column == 1
choice = self._reversed_choices[self.item(row, 0).data(Qt.DisplayRole)]
choice = self._reversed_choices[self.item(row, 0).data(Qt.ItemDataRole.DisplayRole)]
if self.item(row, 1).checkState():
self._value.add(choice)
else:
Expand All @@ -281,7 +280,7 @@ def _on_cell_changed(self, row, column):

class BooleanAsDualChoiceOption(ChoiceOption):

valueChanged = pyqtSignal(bool)
valueChanged = Signal(bool)

def __init__(self, choice_false, choice_true):
choices = { False: choice_false, True: choice_true }
Expand Down Expand Up @@ -437,8 +436,8 @@ def __init__(self, engine):
(option_by_name[option_name], update_fn)
for option_name, update_fn in option.dependents
]
self.buttons.button(QDialogButtonBox.Ok).clicked.connect(self.on_apply)
self.buttons.button(QDialogButtonBox.Apply).clicked.connect(self.on_apply)
self.buttons.button(QDialogButtonBox.StandardButton.Ok).clicked.connect(self.on_apply)
self.buttons.button(QDialogButtonBox.StandardButton.Apply).clicked.connect(self.on_apply)
self.tabs.currentWidget().setFocus()
self.restore_state()
self.finished.connect(self.save_state)
Expand Down Expand Up @@ -491,7 +490,7 @@ def _create_option_widget(self, option):

def keyPressEvent(self, event):
# Disable Enter/Return key to trigger "OK".
if event.key() in (Qt.Key_Enter, Qt.Key_Return):
if event.key() in (Qt.Key.Key_Enter, Qt.Key.Key_Return):
return
super().keyPressEvent(event)

Expand Down
2 changes: 1 addition & 1 deletion plover/gui_qt/config_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</property>
<property name="windowIcon">
<iconset resource="resources/resources.qrc">
<normaloff>:/plover.png</normaloff>:/plover.png</iconset>
<normaloff>:/plover/plover.png</normaloff>:/plover/plover.png</iconset>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
Expand Down
Loading