From c20da220d09133b213afbcdad4199296623d495a Mon Sep 17 00:00:00 2001 From: dynobo Date: Thu, 25 Apr 2024 14:23:52 +0200 Subject: [PATCH 1/5] chore: format with updated ruff --- bundle/platforms/linux_briefcase.py | 6 ++---- bundle/platforms/macos_briefcase.py | 3 +-- bundle/platforms/windows_briefcase.py | 3 +-- normcap/__init__.py | 1 + normcap/app.py | 1 + normcap/gui/localization.py | 1 + normcap/gui/system_info.py | 1 + normcap/gui/window.py | 1 - tests/tests_gui/test_update_check.py | 9 ++++++--- 9 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bundle/platforms/linux_briefcase.py b/bundle/platforms/linux_briefcase.py index b768411fa..554a3cf07 100644 --- a/bundle/platforms/linux_briefcase.py +++ b/bundle/platforms/linux_briefcase.py @@ -77,11 +77,9 @@ def run_framework(self) -> None: self._add_metainfo_to_appimage() self.run(cmd="briefcase package linux appimage", cwd=self.PROJECT_PATH) - def bundle_tesseract(self) -> None: - ... + def bundle_tesseract(self) -> None: ... - def install_system_deps(self) -> None: - ... + def install_system_deps(self) -> None: ... def pre_framework(self) -> None: self._patch_briefcase_appimage_to_run_cmd() diff --git a/bundle/platforms/macos_briefcase.py b/bundle/platforms/macos_briefcase.py index 1b62ca3c0..0114a947d 100644 --- a/bundle/platforms/macos_briefcase.py +++ b/bundle/platforms/macos_briefcase.py @@ -89,5 +89,4 @@ def install_system_deps(self) -> None: self.run(cmd="brew install tesseract") self.run(cmd="brew install dylibbundler") - def pre_framework(self) -> None: - ... + def pre_framework(self) -> None: ... diff --git a/bundle/platforms/windows_briefcase.py b/bundle/platforms/windows_briefcase.py index ca4984d8d..8d3dee3b1 100644 --- a/bundle/platforms/windows_briefcase.py +++ b/bundle/platforms/windows_briefcase.py @@ -200,8 +200,7 @@ def run_framework(self) -> None: self._patch_windows_installer() self.run(cmd="briefcase package windows VisualStudio", cwd=self.PROJECT_PATH) - def install_system_deps(self) -> None: - ... + def install_system_deps(self) -> None: ... def pre_framework(self) -> None: self.bundle_tesseract() diff --git a/normcap/__init__.py b/normcap/__init__.py index 169da241d..1feb3085a 100644 --- a/normcap/__init__.py +++ b/normcap/__init__.py @@ -1,2 +1,3 @@ """Normcap Package.""" + __version__ = "0.5.4" diff --git a/normcap/app.py b/normcap/app.py index 0c9d509d2..508f0556d 100644 --- a/normcap/app.py +++ b/normcap/app.py @@ -1,4 +1,5 @@ """Start main application logic.""" + import logging import signal import sys diff --git a/normcap/gui/localization.py b/normcap/gui/localization.py index 3541ed8c7..d2683340f 100644 --- a/normcap/gui/localization.py +++ b/normcap/gui/localization.py @@ -1,4 +1,5 @@ """Load translations dictionary for usage in GUI.""" + import gettext from pathlib import Path diff --git a/normcap/gui/system_info.py b/normcap/gui/system_info.py index 593473512..94d5bc9ee 100644 --- a/normcap/gui/system_info.py +++ b/normcap/gui/system_info.py @@ -1,4 +1,5 @@ """Gather relevant system information.""" + import functools import logging import os diff --git a/normcap/gui/window.py b/normcap/gui/window.py index 97994ee5e..86706d195 100644 --- a/normcap/gui/window.py +++ b/normcap/gui/window.py @@ -10,7 +10,6 @@ nevertheless display potentially multiple windows in fullscreen on multiple displays. """ - import logging from dataclasses import dataclass from typing import Callable, Optional, cast diff --git a/tests/tests_gui/test_update_check.py b/tests/tests_gui/test_update_check.py index 0cff25e57..126218a05 100644 --- a/tests/tests_gui/test_update_check.py +++ b/tests/tests_gui/test_update_check.py @@ -147,9 +147,12 @@ def _mocked_downloader_get(cls, url: str, timeout: float): monkeypatch.setattr(downloader.Downloader, "get", _mocked_downloader_get) # WHEN the update check is triggered (with debug log level) - with caplog.at_level(logging.DEBUG), qtbot.wait_signal( - checker.com.on_version_checked, timeout=200, raising=False - ) as result: + with ( + caplog.at_level(logging.DEBUG), + qtbot.wait_signal( + checker.com.on_version_checked, timeout=200, raising=False + ) as result, + ): checker.com.check.emit() # THEN the update message is (not) shown with certain text From b82bc12cd3351eadba582001777ece4038766640 Mon Sep 17 00:00:00 2001 From: dynobo Date: Thu, 25 Apr 2024 20:26:46 +0200 Subject: [PATCH 2/5] chore: bump pyside6 and mkdocs --- pyproject.toml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6e1e7259f..70433a5db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,8 +27,8 @@ classifiers = [ "Operating System :: MacOS", ] dependencies = [ - "shiboken6==6.6.1", - "PySide6-Essentials==6.6.1", + "shiboken6==6.7.0", + "PySide6-Essentials==6.7.0", "jeepney==0.8.0", ] @@ -52,14 +52,14 @@ dependencies = ["babel", "toml"] [tool.hatch.envs.default] dependencies = [ "babel>=2.12.1", - "briefcase==0.3.16", # pinned because building relies on it! + "briefcase==0.3.16", # pinned because building relies on it! "coverage[toml]>=6.5", "coveralls>=3.3.1", # "mdformat-gfm>=0.3.5", # until fixed https://github.com/hukkin/mdformat-gfm/issues/31 "mdformat-simple-breaks>=0.0.1", "mdformat-mkdocs>=2.0.1", "mdformat-frontmatter>=2.0.1", - "mkdocs-material==9.5.5", # pinned because docs rely on it! + "mkdocs-material==9.5.19", # pinned because docs rely on it! "mkdocs-glightbox>=0.3.5", "mypy>=1.3.0", "pip-audit>=2.5.5", @@ -100,8 +100,9 @@ charts = [ "pydeps normcap --max-bacon=1 -o=pydeps_internal.png -T=png", ] # Main tasks: -check = ["locales-compile", "fmt-check", "typing", "test", "security"] -pre-commit = ["locales-compile", "fmt", "typing", "test", "security", "charts"] +# ONHOLD: Re-add "typing" to check and pre-commit when PySide6 6.7.1 is released +check = ["locales-compile", "fmt-check", "test", "security"] +pre-commit = ["locales-compile", "fmt", "test", "security", "charts"] locales-compile = "python bundle/l10n.py" locales-update = "python bundle/l10n.py --update-all" create-locale = "python bundle/l10n.py --create-new" @@ -242,7 +243,7 @@ sources = ["normcap"] icon = "bundle/imgs/normcap" installer_icon = "bundle/imgs/normcap_install" installer_background = "bundle/imgs/normcap_install_bg" -requires = ["PySide6-Essentials==6.6.1", "shiboken6==6.6.1", "jeepney==0.8.0"] +requires = ["PySide6-Essentials==6.7.0", "shiboken6==6.7.0", "jeepney==0.8.0"] cleanup_paths = [ # Globs "**/[pP]y[sS]ide6/*[qQ]t*[oO]pen[gG][lL]*", From 1dba3d3b052d141fe366a780f834b7c40bb13796 Mon Sep 17 00:00:00 2001 From: dynobo Date: Thu, 25 Apr 2024 20:36:46 +0200 Subject: [PATCH 3/5] fix(gui): loading indicator crashs due to early hide event --- normcap/gui/loading_indicator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/normcap/gui/loading_indicator.py b/normcap/gui/loading_indicator.py index e619ffdc7..dd585e97b 100644 --- a/normcap/gui/loading_indicator.py +++ b/normcap/gui/loading_indicator.py @@ -9,7 +9,6 @@ def __init__( self, parent: QtWidgets.QWidget, size: int = 128, center_on_parent: bool = True ) -> None: super().__init__(parent=parent) - self.setVisible(False) self.dot_count = 9 self.dot_size_factor = 1.6 @@ -20,6 +19,8 @@ def __init__( self.counter = 0 self.timer = None + self.setVisible(False) + if size: self.setMinimumSize(size, size) self.setMaximumSize(size, size) From 09996523193a3972c32baef8192775588713de5f Mon Sep 17 00:00:00 2001 From: dynobo Date: Fri, 26 Apr 2024 12:06:35 +0200 Subject: [PATCH 4/5] test: fix failures due to window positioning on wayland --- normcap/resources/locales/README.md | 4 ++-- tests/conftest.py | 7 ++++++- tests/integration/test_tray_menu.py | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/normcap/resources/locales/README.md b/normcap/resources/locales/README.md index 951882fea..40d523ff6 100644 --- a/normcap/resources/locales/README.md +++ b/normcap/resources/locales/README.md @@ -16,13 +16,13 @@ | Locale | Progress | Translated | | :--------------------------------------- | -------: | ---------: | | [de_DE](./de_DE/LC_MESSAGES/messages.po) | 100% | 68 of 68 | -| [es_ES](./es_ES/LC_MESSAGES/messages.po) | 8% | 6 of 68 | +| [es_ES](./es_ES/LC_MESSAGES/messages.po) | 100% | 68 of 68 | | [fr_FR](./fr_FR/LC_MESSAGES/messages.po) | 8% | 6 of 68 | | [hi_IN](./hi_IN/LC_MESSAGES/messages.po) | 8% | 6 of 68 | | [it_IT](./it_IT/LC_MESSAGES/messages.po) | 8% | 6 of 68 | | [pl_PL](./pl_PL/LC_MESSAGES/messages.po) | 8% | 6 of 68 | | [pt_PT](./pt_PT/LC_MESSAGES/messages.po) | 8% | 6 of 68 | -| [ru_RU](./ru_RU/LC_MESSAGES/messages.po) | 8% | 6 of 68 | +| [ru_RU](./ru_RU/LC_MESSAGES/messages.po) | 100% | 68 of 68 | | [sv_SE](./sv_SE/LC_MESSAGES/messages.po) | 100% | 68 of 68 | | [uk_UA](./uk_UA/LC_MESSAGES/messages.po) | 8% | 6 of 68 | | [zh_CN](./zh_CN/LC_MESSAGES/messages.po) | 8% | 6 of 68 | diff --git a/tests/conftest.py b/tests/conftest.py index d12bb1f56..533374316 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -156,7 +156,7 @@ def basic_cli_args(): @pytest.fixture() -def run_normcap(monkeypatch, qapp, basic_cli_args): +def run_normcap(monkeypatch, qapp, qtbot, basic_cli_args): trays = [] def _run_normcap(extra_cli_args: Optional[list[str]] = None): @@ -166,6 +166,10 @@ def _run_normcap(extra_cli_args: Optional[list[str]] = None): monkeypatch.setattr(app, "_get_application", lambda: qapp) _, tray = app._prepare() + + # wait for windows to be created and moved on wayland + qtbot.wait(50) + tray._EXIT_DELAY = 0.1 trays.append(tray) return tray @@ -240,6 +244,7 @@ def _select_region(on: QtWidgets.QWidget, pos: tuple[QtCore.QPoint, QtCore.QPoin qtbot.mousePress(on, QtCore.Qt.MouseButton.LeftButton, pos=top_left) qtbot.mouseMove(on, pos=bottom_right) qtbot.mouseRelease(on, QtCore.Qt.MouseButton.LeftButton, pos=bottom_right) + qtbot.wait(500) return _select_region diff --git a/tests/integration/test_tray_menu.py b/tests/integration/test_tray_menu.py index 489f7deca..9d321d20b 100644 --- a/tests/integration/test_tray_menu.py +++ b/tests/integration/test_tray_menu.py @@ -51,6 +51,9 @@ def test_tray_menu_capture(monkeypatch, qtbot, run_normcap, select_region): capture_action = tray.tray_menu.findChild(QtGui.QAction, "capture") capture_action.trigger() + # wait for windows to be created and moved on wayland + qtbot.wait(50) + select_region(on=tray.windows[0], pos=testcase.coords) # THEN text should be captured From 269b2cd54699ea9d98fec7588d56eca12a9d7562 Mon Sep 17 00:00:00 2001 From: dynobo Date: Fri, 26 Apr 2024 12:13:22 +0200 Subject: [PATCH 5/5] chore: re-enable mdformat-gfm --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 70433a5db..6a9278d31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ dependencies = [ "briefcase==0.3.16", # pinned because building relies on it! "coverage[toml]>=6.5", "coveralls>=3.3.1", - # "mdformat-gfm>=0.3.5", # until fixed https://github.com/hukkin/mdformat-gfm/issues/31 + "mdformat-gfm>=0.3.6", "mdformat-simple-breaks>=0.0.1", "mdformat-mkdocs>=2.0.1", "mdformat-frontmatter>=2.0.1",