From d65f5e59e123b153156cbbcfcc81d5eddaac8b16 Mon Sep 17 00:00:00 2001 From: dynobo Date: Sat, 18 May 2024 21:07:36 +0200 Subject: [PATCH] fix(gui): add workaround for showFullScreen --- CHANGELOG | 1 + normcap/gui/window.py | 9 +- normcap/resources/locales/README.md | 130 ++++++++++++++-------------- 3 files changed, 74 insertions(+), 66 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index bb80134e..275e85ff 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ - All: Add french translation. Thanks, [@NathanBnm](https://github.com/NathanBnm)! ([#648](https://github.com/dynobo/normcap/pull/648)) - Linux: Fix crash on wayland in case of user's home directory contains special character. Thanks, [@supersonictw](https://github.com/supersonictw)! ([#643](https://github.com/dynobo/normcap/issues/643)) +- Linux: Fix issue on Ubuntu/Unity where the window doesn't show up. ([#651](https://github.com/dynobo/normcap/pull/651)) ## v0.5.6 (2024-05-08) diff --git a/normcap/gui/window.py b/normcap/gui/window.py index 382fe31a..95844f78 100644 --- a/normcap/gui/window.py +++ b/normcap/gui/window.py @@ -162,13 +162,20 @@ def set_fullscreen(self) -> None: self.setMinimumSize(self.geometry().size()) self.setMaximumSize(self.geometry().size()) + if system_info.desktop_environment == DesktopEnvironment.UNITY: + # For unknown reason .showFullScreen() on Ubuntu 24.04 does not show the + # window. Showing the Window in normal state upfront seems to help. + # (It seems like .setWindowState(WindowFullScreen) should not be set before + # .setVisible(True) on that system. Might be a QT bug.) + self.show() + self.showFullScreen() self.setFocus() # On Wayland, setting geometry doesn't move the window to the right screen, as # only the compositor is allowed to do this. In case of multi-display setups, we # need to use hacks to position the window: - if system_info.display_manager_is_wayland() and len(system_info.screens()) > 1: + if system_info.display_manager_is_wayland(): self._move_to_screen_on_wayland() def clear_selection(self) -> None: diff --git a/normcap/resources/locales/README.md b/normcap/resources/locales/README.md index 2e0408a1..71949adc 100644 --- a/normcap/resources/locales/README.md +++ b/normcap/resources/locales/README.md @@ -32,12 +32,12 @@ 1. Open one of the translations (`.po`-files) linked in the "Status" table above. 1. In the file, each string is represented by its English text (`msgid`-field), its - translation into the target language (`msgstr`-field) and maybe a translator - comment (`#` lines above). + translation into the target language (`msgstr`-field) and maybe a translator + comment (`#` lines above). 1. Read the `msgstr`'s one by one and check them for wording, spelling and punctuation. 1. Propose any changes preferably right away as Pull Request, or if you don't feel - comfortable in doing that, report your finding as - [new issue](https://github.com/dynobo/normcap/issues/new). + comfortable in doing that, report your finding as + [new issue](https://github.com/dynobo/normcap/issues/new). _NOTE:_: Details about the `.po`-file format can be found in the [official specification](https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html), if needed. @@ -46,60 +46,60 @@ _NOTE:_: Details about the `.po`-file format can be found in the 1. Pick a translation from the "Status" table which is fairly complete 1. Run NormCap (>= `v0.5.0beta1`) with that language, either by changing your system's - language to the target language or by starting NormCap with an environment variable - set: + language to the target language or by starting NormCap with an environment variable + set: - on Linux: - Python package: - ``` - LANGUAGE= normcap - ``` + ``` + LANGUAGE= normcap + ``` - AppImage: - ``` - LANGUAGE= NormCap-[...].AppImage - ``` + ``` + LANGUAGE= NormCap-[...].AppImage + ``` - FlatPak: - ``` - LANGUAGE= flatpak run --command=normcap com.github.dynobo.normcap - ``` + ``` + LANGUAGE= flatpak run --command=normcap com.github.dynobo.normcap + ``` - on macOS: - DMG: - ``` - LANG= /Applications/NormCap.app/Contents/MacOS/NormCap - ``` + ``` + LANG= /Applications/NormCap.app/Contents/MacOS/NormCap + ``` - on Windows: - Python package: - ``` - set LANG= - normcap - ``` + ``` + set LANG= + normcap + ``` - MSI installed: - ``` - set LANG= - %LOCALAPPDATA%\Programs\NormCap\NormCap.exe - ``` + ``` + set LANG= + %LOCALAPPDATA%\Programs\NormCap\NormCap.exe + ``` 1. Navigate through the user interface and proofread any text. Pay special attention to - whether the presentation of the text looks good. (E.g. strings are too long/short, - wrong line breaks, ...) + whether the presentation of the text looks good. (E.g. strings are too long/short, + wrong line breaks, ...) 1. Propose any changes preferably right away as Pull Request, or if you don't feel - comfortable in doing that, report your finding as - [new issue](https://github.com/dynobo/normcap/issues/new). + comfortable in doing that, report your finding as + [new issue](https://github.com/dynobo/normcap/issues/new). ## Improve existing translations 1. Identify the file that corresponds to the local you want to edit. You can click the - link in the table above, or you can navigate manually to the file at - `./normcap/resources/locales//LC_MESSAGES/messages.po` + link in the table above, or you can navigate manually to the file at + `./normcap/resources/locales//LC_MESSAGES/messages.po` 1. Open this `messages.po` file and edit the translations. If you like, use the - [Free PO-Editor](https://pofile.net/free-po-editor) for easier editing. - \ - **Important:** + [Free PO-Editor](https://pofile.net/free-po-editor) for easier editing. + \ + **Important:** - Never translate any variables which are written in curly brackets, e.g. `{count}`! - Don't bother with updating the header section at the top, it will get overwritten - automatically. + automatically. 1. Propose the changed file in a new Pull Request. \ - (In case you are not familiar with - git, you can also always propose a correction or change via a - [new issue](https://github.com/dynobo/normcap/issues/new).) + (In case you are not familiar with + git, you can also always propose a correction or change via a + [new issue](https://github.com/dynobo/normcap/issues/new).) ## Add new translation @@ -114,35 +114,35 @@ virtual Python environment via `hatch shell`. _Note_: All commands should be run in the repository's root directory. 1. Research the `LOCALE_NAME` (e.g. `en_EN` or `de_AT`) of the language which shall be - added. `gettext`'s - [locale names](https://www.gnu.org/software/gettext/manual/html_node/Locale-Names.html) - should be specified in the format `_`. Visit the - lists of available - [language codes](https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html) - and - [country codes](https://www.gnu.org/software/gettext/manual/html_node/Country-Codes.html) - to identify possible values. + added. `gettext`'s + [locale names](https://www.gnu.org/software/gettext/manual/html_node/Locale-Names.html) + should be specified in the format `_`. Visit the + lists of available + [language codes](https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html) + and + [country codes](https://www.gnu.org/software/gettext/manual/html_node/Country-Codes.html) + to identify possible values. 1. Run the following command to create an initial `messages.po`-file for the language. - Make sure to replace `` by the string identified in step 1. - ```sh - hatch run create-locale - ``` + Make sure to replace `` by the string identified in step 1. + ```sh + hatch run create-locale + ``` 1. Edit the file `./normcap/resources/locales//LC_MESSAGES/messages.po` - which was created in step 2. Add your translations as the respective `msgstr`. If - you like, use the [Free PO-Editor](https://pofile.net/free-po-editor) for easier - editing. \ - **Important:** + which was created in step 2. Add your translations as the respective `msgstr`. If + you like, use the [Free PO-Editor](https://pofile.net/free-po-editor) for easier + editing. \ + **Important:** - Never translate any variables which are written in curly brackets, e.g. `{count}`! - Don't bother with updating the header section at the top, it will get overwritten - automatically. + automatically. 1. Compile the new `.po` file to the machine-readable `.mo` file: - ```sh - hatch run locales-compile - ``` + ```sh + hatch run locales-compile + ``` 1. To test your translation, run NormCap with the `LANGUAGE` environment variable set: - ```sh - LANGUAGE= python normcap/app.py - ``` + ```sh + LANGUAGE= python normcap/app.py + ``` 1. Propose the inclusion of your new `.po`-file via a pull request to `main`. ## Update template and languages files @@ -151,6 +151,6 @@ This is only necessary, when translatable strings in NormCap's source code got c (created, modified or deleted). 1. Generate `.pot` file and update all existing `.po` files: - ```sh - hatch run locales-update - ``` + ```sh + hatch run locales-update + ```