Bug 493581

Summary: PromptDialog minimum width does not consider subtitle width if its text is set imperatively
Product: [Frameworks and Libraries] frameworks-kirigami Reporter: Plata <plata.hill>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: akselmo, kde, kdebugger444, nate, notmart
Priority: NOR    
Version: 6.6.0   
Target Milestone: Not decided   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=493663
Latest Commit: Version Fixed In: 6.8
Sentry Crash Report:
Attachments: Telly Skout
PromptDialog with long subtitle
Minimal example

Description Plata 2024-09-24 11:58:25 UTC
Created attachment 174024 [details]
Telly Skout

SUMMARY
The PromptDialog width depends on the title only. This looks very weird if the title is short.

STEPS TO REPRODUCE
Create a PromptDialog with short title but long subtitle.

OBSERVED RESULT
The width of the PromptDialog is too small.

EXPECTED RESULT
The width is reasonable.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.1.5
KDE Frameworks Version: 6.6.0
Qt Version: 6.7.2
Comment 1 Akseli Lahtinen 2024-09-27 08:31:49 UTC
Created attachment 174132 [details]
PromptDialog with long subtitle

I am unable to reproduce this using newest kirigami + kirigami-gallery

This is the prompt dialog code:

```qml

    Kirigami.PromptDialog {
        id: textPromptDialog
        title: "New Folder"
        subtitle: "Long subtitle aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

        standardButtons: Kirigami.Dialog.NoButton
        customFooterActions: [
            Kirigami.Action {
                text: qsTr("Create Folder")
                icon.name: "dialog-ok"
                onTriggered: {
                    showPassiveNotification("Created");
                    textPromptDialog.close();
                }
            },
            Kirigami.Action {
                text: qsTr("Cancel")
                icon.name: "dialog-cancel"
                onTriggered: {
                    textPromptDialog.close();
                }
            }
        ]

        FormCard.FormTextFieldDelegate {
            label: qsTr("Folder name:")
            leftPadding: 0
            rightPadding: 0
        }
    }

```
Comment 2 Plata 2024-09-27 10:24:22 UTC
It works as expected if the subtitle is known at creation time.

Minimal example to reproduce the problem:
```qml
    Kirigami.PromptDialog {
        id: textPromptDialog
        title: "Title"
        subtitle: "empty"
        Component.onCompleted: {
            subtitle = "A long subtitle which should change the width of the PromptDialog"
        }
    }
```
Comment 3 Plata 2024-09-27 10:26:59 UTC
Created attachment 174134 [details]
Minimal example
Comment 4 Akseli Lahtinen 2024-09-27 11:27:10 UTC
(In reply to Plata from comment #2)
> It works as expected if the subtitle is known at creation time.
> 
> Minimal example to reproduce the problem:
> ```qml
>     Kirigami.PromptDialog {
>         id: textPromptDialog
>         title: "Title"
>         subtitle: "empty"
>         Component.onCompleted: {
>             subtitle = "A long subtitle which should change the width of the
> PromptDialog"
>         }
>     }
> ```

Thanks, i could repro it now!
Comment 5 Bug Janitor Service 2024-09-30 12:17:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1628
Comment 6 Akseli Lahtinen 2024-10-02 12:46:12 UTC
Git commit e2c12d3b97709d21bf8b5e1e13ed233d2a66983b by Akseli Lahtinen.
Committed on 02/10/2024 at 12:46.
Pushed by akselmo into branch 'master'.

Use TextEdit instead of QQC2.TextArea in SelectableLabel, add context menu to SelectableLabel

SelectableLabel wont resize properly when using QQC2.TextArea, likely due to TextArea having it's own
resizing and background handling. 

TextEdit is handled more like a Label is, so it resizes correctly. We just have to manually make it use the proper colors, which was doable with Kirigami.

SelectableLabel also has its own, smaller context menu now.

M  +69   -4    src/controls/SelectableLabel.qml

https://invent.kde.org/frameworks/kirigami/-/commit/e2c12d3b97709d21bf8b5e1e13ed233d2a66983b
Comment 7 David Edmundson 2024-10-02 21:25:07 UTC
Unfortunately it had to be reverted, reopening this bug
Comment 8 Bug Janitor Service 2024-10-03 08:38:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1631
Comment 9 Akseli Lahtinen 2024-10-03 12:13:32 UTC
Git commit 090042a7e51c21e40b8866b35d5301da3d2b7677 by Akseli Lahtinen.
Committed on 03/10/2024 at 12:13.
Pushed by akselmo into branch 'master'.

Create SelectableText, deprecate SelectableLabel

This creates a new SelectableText element that is supposed
to replace SelectableLabel due to resizing issues.

SelectableLabel uses TextArea, which has features Label does
not really need. TextArea also has issues when resizing,
since the ImplicitSize resizing is disabled after the initialization.
This can cause problems with dynamically changing content, where
the TextArea size wont update based on the content.

TextEdit has ImplicitSizes as read-only, but it resizes
automatically based on the text content. It's wrapped inside a Control.

SelectableText also has a simpler context menu, with only
Copy and SelectAll buttons.

I chose the name SelectableText since this is based on TextEdit, not
label.

M  +4    -0    src/CMakeLists.txt
M  +1    -1    src/controls/SelectableLabel.qml
A  +127  -0    src/controls/SelectableText.qml     [License: LGPL(v2.0+)]

https://invent.kde.org/frameworks/kirigami/-/commit/090042a7e51c21e40b8866b35d5301da3d2b7677
Comment 10 Bug Janitor Service 2024-10-03 12:21:41 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1632
Comment 11 Akseli Lahtinen 2024-10-03 12:47:16 UTC
Git commit 692a35c76a28879d0421e1a7dd5006c9a6df210e by Akseli Lahtinen.
Committed on 03/10/2024 at 12:47.
Pushed by akselmo into branch 'master'.

PromptDialog: Port to SelectableText

SelectableLabel does not resize correctly due to using TextArea, if the
text inside the dialog is dynamically changed. This is because TextArea disables resizing the implicitSizes after initialization.

Use the new SelectableText item instead, which works with
dynamic resizing.

M  +1    -1    src/dialogs/PromptDialog.qml

https://invent.kde.org/frameworks/kirigami/-/commit/692a35c76a28879d0421e1a7dd5006c9a6df210e
Comment 12 Nate Graham 2024-10-03 16:28:34 UTC
Reverted again; re-opening.
Comment 13 Bug Janitor Service 2024-10-07 08:41:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1635
Comment 14 Bug Janitor Service 2024-10-07 08:42:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1636
Comment 15 Bug Janitor Service 2024-10-08 12:02:14 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1638
Comment 16 Akseli Lahtinen 2024-10-10 09:28:39 UTC
Git commit 1c54d7d246dbb6c2bf083429f40aee07bcbdcf4a by Akseli Lahtinen.
Committed on 10/10/2024 at 09:28.
Pushed by akselmo into branch 'master'.

Modify SelectableLabel to use TextEdit instead

Discussion: https://invent.kde.org/frameworks/kirigami/-/issues/91

SelectableLabel wont resize properly when using QQC2.TextArea, due to
TextArea having implicitSize resizing disabled after the initial size.

TextEdit is handled more like a Label is, so it resizes correctly.
Wrapping it inside Control and exposing the expected properties and
signals it should be a drop-in replacement for the old TextArea based
SelectableLabel.

SelectableLabel also has its own, smaller context menu now.

Note that this may be API breaking so we need to do a lot of testing.

M  +166  -40   src/controls/SelectableLabel.qml

https://invent.kde.org/frameworks/kirigami/-/commit/1c54d7d246dbb6c2bf083429f40aee07bcbdcf4a
Comment 17 Plata 2024-10-11 09:16:44 UTC
*** Bug 494397 has been marked as a duplicate of this bug. ***