Bug 478155 - Cannot interact with a modal QFontDialog
Summary: Cannot interact with a modal QFontDialog
Status: RESOLVED FIXED
Alias: None
Product: plasma-integration
Classification: Plasma
Component: general (show other bugs)
Version: 5.90.0
Platform: Neon Linux
: HI major
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords: qt6
: 483872 485272 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-12-06 10:28 UTC by Zhora Zmeikin
Modified: 2024-04-10 17:27 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0.4


Attachments
A window that cannot be interacted with (43.97 KB, image/png)
2023-12-06 10:28 UTC, Zhora Zmeikin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zhora Zmeikin 2023-12-06 10:28:55 UTC
Created attachment 163937 [details]
A window that cannot be interacted with

STEPS TO REPRODUCE
1. Take a screenshot using Spectacle
2. Click "Show annotation tools".
3. Navigate to the Text tool.
4. Try changing the font.

And you'll notice that the font selection window just hangs. You can't click on it, you can only close it.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Neon (Unstable), Wayland
KDE Plasma Version: 5.90.0
KDE Frameworks Version: 5.246.0
Qt Version: 6.6.0
Comment 1 Eric Armbruster 2023-12-06 11:51:59 UTC
Can reproduce.
Comment 2 Noah Davis 2023-12-06 19:45:06 UTC
Apparently the dialog is usable while Spectacle is being inspected with GammaRay, but not otherwise. The code involving the font dialog has not been touched in a while, so I'm inclined to believe that the bug comes from somewhere outside of Spectacle, but I'm not sure where.
Comment 3 Nate Graham 2023-12-07 20:39:20 UTC
The way font strings are serialized in config files changes between Qt5 and Qt6, which may be related.
Comment 4 Noah Davis 2023-12-08 10:49:03 UTC
(In reply to Nate Graham from comment #3)
> The way font strings are serialized in config files changes between Qt5 and
> Qt6, which may be related.

The bug still happens even if there are no font settings in the config file.
Comment 5 Noah Davis 2023-12-08 10:49:52 UTC
Also, this is a recent change even if you were already using the Qt6-only version of spectacle.
Comment 7 Nicolas Fella 2023-12-10 22:32:42 UTC
it has something to do with the modality of the dialog

in https://invent.kde.org/plasma/plasma-integration/-/blob/master/qt6/src/platformtheme/kdeplatformfontdialoghelper.cpp?ref_type=heads#L43 we get Qt::WindowModal and set that on the QFontDialog. When I change that to ApplicationModal it works.

Or if I in https://invent.kde.org/graphics/spectacle/-/blob/master/src/Gui/SpectacleWindow.cpp#L345 replace open() with show() it also works.

I don't fully understand it though
Comment 8 Noah Davis 2023-12-11 20:09:41 UTC
I get the bug with QFontDialog under the following conditions:

```
// Calling QDialog::open().
// This sets the modality to Qt::WindowModal via QWidget::setWindowModality() and then calls QWidget::show().
// QWidget::setWindowModality() sets the specific type of modality and also sets the Qt::WA_ShowModal attribute.
// When Qt::WA_ShowModal is set, the modality is set to Qt::ApplicationModal if it is currently set to Qt::NonModal
// and otherwise keeps the current modality.
// If the widget has the attribute Qt::WA_WState_Created, the current modality is applied to the widget's windowHandle.
dialog->open();

// Setting Qt::ApplicationModal and calling QWidget::show().
dialog->setWindowModality(Qt::ApplicationModal);
dialog->show();

// Setting the dialog as modal via QDialog::setModal() and calling QWidget::show().
// This has the same behavior as setting the modality to Qt::ApplicationModal.
dialog->setModal(true);
dialog->show();
```

If I only call QWidget::show(), the QFontDialog can be used, but the dialog is non-modal.
Comment 9 Noah Davis 2023-12-26 22:13:46 UTC
It seems that Qt Designer (the Qt Widgets one) also has this problem with modal font dialogs.
Comment 10 Noah Davis 2024-01-30 01:33:19 UTC
Git commit 7cb638347fd0c906eb0ddfdc8f1954dd8089be4b by Noah Davis.
Committed on 30/01/2024 at 01:32.
Pushed by ndavis into branch 'master'.

Workaround modal QFontDialogs being unusable

M  +5    -1    src/Gui/SpectacleWindow.cpp

https://invent.kde.org/graphics/spectacle/-/commit/7cb638347fd0c906eb0ddfdc8f1954dd8089be4b
Comment 11 Noah Davis 2024-01-30 01:34:12 UTC
Git commit 9bda6f78610094b5b8300682c9bbe38089209fa3 by Noah Davis.
Committed on 30/01/2024 at 01:33.
Pushed by ndavis into branch 'release/24.02'.

Workaround modal QFontDialogs being unusable
(cherry picked from commit 7cb638347fd0c906eb0ddfdc8f1954dd8089be4b)

M  +5    -1    src/Gui/SpectacleWindow.cpp

https://invent.kde.org/graphics/spectacle/-/commit/9bda6f78610094b5b8300682c9bbe38089209fa3
Comment 12 Nicolas Fella 2024-03-21 17:11:48 UTC
*** Bug 483872 has been marked as a duplicate of this bug. ***
Comment 13 Bug Janitor Service 2024-03-21 17:21:58 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-integration/-/merge_requests/141
Comment 14 Nate Graham 2024-04-09 14:59:19 UTC
*** Bug 485272 has been marked as a duplicate of this bug. ***
Comment 15 Nicolas Fella 2024-04-10 17:16:48 UTC
Git commit 9419f251b6633d9c440bfc662c80e75eeee3404c by Nicolas Fella.
Committed on 10/04/2024 at 17:15.
Pushed by nicolasfella into branch 'master'.

Revert "Implement Font dialogs"

This breaks interacting with modal font dialogs. Revert this because
 ugly QML font dialogs are better than broken ones in most apps

This reverts commit 53cfae46b00f7844718bb75c469cfcf6efcb070d.

M  +0    -1    qt6/autotests/CMakeLists.txt
M  +0    -1    qt6/src/platformtheme/CMakeLists.txt
D  +0    -64   qt6/src/platformtheme/kdeplatformfontdialoghelper.cpp
D  +0    -32   qt6/src/platformtheme/kdeplatformfontdialoghelper.h
M  +1    -3    qt6/src/platformtheme/kdeplatformtheme.cpp

https://invent.kde.org/plasma/plasma-integration/-/commit/9419f251b6633d9c440bfc662c80e75eeee3404c
Comment 16 Nicolas Fella 2024-04-10 17:26:46 UTC
Git commit cbc0e44bafde499618df85625b1966ba310a0094 by Nicolas Fella.
Committed on 10/04/2024 at 17:26.
Pushed by nicolasfella into branch 'Plasma/6.0'.

Revert "Implement Font dialogs"

This breaks interacting with modal font dialogs. Revert this because
 ugly QML font dialogs are better than broken ones in most apps

This reverts commit 53cfae46b00f7844718bb75c469cfcf6efcb070d.
(cherry picked from commit 9419f251b6633d9c440bfc662c80e75eeee3404c)

M  +0    -1    qt6/autotests/CMakeLists.txt
M  +0    -1    qt6/src/platformtheme/CMakeLists.txt
D  +0    -64   qt6/src/platformtheme/kdeplatformfontdialoghelper.cpp
D  +0    -32   qt6/src/platformtheme/kdeplatformfontdialoghelper.h
M  +1    -3    qt6/src/platformtheme/kdeplatformtheme.cpp

https://invent.kde.org/plasma/plasma-integration/-/commit/cbc0e44bafde499618df85625b1966ba310a0094