aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/SectionHeader.qml
blob: 6bbe07a6312a9d2f9e75c81ac606e33b417d0903 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

import QtQuick

// A drawer page's section title: accent glyph, bold label, and a divider
// with space above it, which is what separates the sections. The divider is
// at 0.3: the 0.12 one the pages used before read too faint. The first
// section of a page sets divider: false. Children (a switch, a level) are
// laid on the right; anchor them to the bottom, where the label sits.
Item {
    property string glyph
    property string label
    property bool divider: true

    width: parent ? parent.width : 0
    implicitHeight: headerText.implicitHeight + (divider ? 18 : 10)

    Rectangle {
        visible: parent.divider
        width: parent.width
        height: 1
        color: Qt.alpha(Theme.text, 0.3)
    }

    Text {
        id: headerGlyph
        anchors { left: parent.left; verticalCenter: headerText.verticalCenter }
        text: parent.glyph
        font { family: Theme.iconFamily; pixelSize: Theme.fontSize }
        color: Theme.accent
    }

    Text {
        id: headerText
        anchors { left: headerGlyph.right; leftMargin: 8; bottom: parent.bottom }
        text: parent.label
        font { family: Theme.fontFamily; pixelSize: Theme.fontSize + 1; bold: true }
        color: Theme.text
    }
}