Bug 454999 - FormLayout adds an extra margin when used in KCMs
Summary: FormLayout adds an extra margin when used in KCMs
Status: CONFIRMED
Alias: None
Product: frameworks-kirigami
Classification: Unclassified
Component: general (show other bugs)
Version: Master
Platform: Other Linux
: NOR normal (vote)
Target Milestone: Not decided
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-07 20:43 UTC by Thiago Sueto
Modified: 2022-06-08 19:16 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thiago Sueto 2022-06-07 20:43:11 UTC
See this thread: https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/770#note_391758

Relevant code: https://invent.kde.org/plasma/plasma-desktop/-/blob/work/thiago/morecomponents/kcms/componentchooser/package/contents/ui/main.qml

Top padding by default looks like this: https://invent.kde.org/plasma/plasma-desktop/uploads/dc4b35dd87c75f52b6d23b5b99ae6c13/Screenshot_20220204_005022.png

When it should look like this: https://invent.kde.org/plasma/plasma-desktop/uploads/7a4fd46b33211bdd7af2f40a1593d780/Screenshot_20220204_005503.png

Analogously to the Notifications KCM: https://invent.kde.org/plasma/plasma-desktop/uploads/fa8ec0fb5ab72eb3af898aa69810607e/Screenshot_20220204_005101.png

Code example taken from MR:

```
import QtQuick 2.12
import QtQuick.Layouts 1.15

import org.kde.kirigami 2.7 as Kirigami
import org.kde.kcm 1.5 as KCM

KCM.SimpleKCM {
    topPadding: 0
    bottomPadding: 0
    Kirigami.FormLayout {
        id: form

        readonly property int longestComboBox: Math.max(browserCombo.implicitWidth,
                                                        fileManagerCombo.implicitWidth,
                                                        textEditorCombo.implicitWidth,
                                                        pdfViewerCombo.implicitWidth,
                                                        imageViewerCombo.implicitWidth,
                                                        musicPlayerCombo.implicitWidth,
                                                        videoPlayerCombo.implicitWidth,
                                                        emailCombo.implicitWidth,
                                                        archiveCombo.implicitWidth,
                                                        terminalCombo.implicitWidth,
                                                        mapCombo.implicitWidth,
                                                        dialerCombo.implicitWidth)
        Item {
            Kirigami.FormData.label: i18n("Internet")
            Kirigami.FormData.isSection: true
        }
        ComponentComboBox {
            id: browserCombo
            Layout.preferredWidth: form.longestComboBox
            component: kcm.browsers
            label: i18n("Web browser:")
        }
[...extracodehere...]
}
```
Comment 1 Méven Car 2022-06-08 07:31:37 UTC
It seems due to the `Kirigami.FormData.isSection` that by default will add some margin/space between sections, but here they are no previous items.

from kirigami FormLayout.qml
```
                //if section, label goes after the separator
                if (item.Kirigami.FormData.isSection) {
                    //put an extra spacer
                    var placeHolder = placeHolderComponent.createObject(lay, {item: item});
                    itemContainer.parent = lay;
                }
```
We probably need a way to disable this added placeHolder.
Comment 2 Nate Graham 2022-06-08 19:16:51 UTC
At least when it's the first item, yeah.