CategoryItem.qml 1.87 KB
Newer Older
1
2
3
4
5
/*
 *   SPDX-FileCopyrightText: 2021 Jan Blackquill <uhhadd@gmail.com>
 *
 *   SPDX-License-Identifier: LGPL-2.0-only
 */
6
7
8
import QtQuick 2.5
import QtQuick.Controls 2.5 as QQC2
import QtQuick.Layouts 1.1
9
import org.kde.kirigami 2.13 as Kirigami
10

11
12
Kirigami.BasicListItem {
    id: delegate
13
14

    property bool showArrow: false
15
    property bool selected: delegate.highlighted || delegate.pressed
16
    property bool isSearching: false
17

18
19
    leading: Item {
        width: (model.DepthRole > 1 && delegate.isSearching) ? (( model.DepthRole - 1 ) * Kirigami.Units.iconSizes.smallMedium) + Kirigami.Units.largeSpacing : 0
20
    }
21
22
    // We are manipulating the padding in the leading item itself, so set this to 0
    leadingPadding: 0
23
24

    icon: model.decoration
25
26
    text: model.display
    Accessible.name: model.display
27

28
29
30
31
32
33
34
35
36
37
    trailing: RowLayout {
        Rectangle {
            id: defaultIndicator
            radius: width * 0.5
            implicitWidth: Kirigami.Units.largeSpacing
            implicitHeight: Kirigami.Units.largeSpacing
            visible: model.showDefaultIndicator && systemsettings.defaultsIndicatorsVisible
            Kirigami.Theme.colorSet: Kirigami.Theme.View
            color: Kirigami.Theme.neutralTextColor
        }
38

39
40
41
42
43
        // Extra space to make the defaults indicators line up vertically for all items
        Item {
            visible: defaultIndicator.visible && !arrow.visible
            implicitWidth: arrow.Layout.preferredWidth
        }
44

45
46
47
        Kirigami.Icon {
            id: arrow
            Layout.alignment: Qt.AlignVCenter
48
            Layout.preferredHeight: Kirigami.Units.iconSizes.small
49
            opacity: 0.7
50
            Layout.preferredWidth: Layout.preferredHeight
51
52
53
54
            source: (LayoutMirroring.enabled ? "go-next-symbolic-rtl" : "go-next-symbolic")
            visible: delegate.showArrow
            selected: delegate.selected
        }
55
    }
56
}