introPage.qml 4.03 KB
Newer Older
Marco Martin's avatar
Marco Martin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
   Copyright (c) 2017 Marco Martin <mart@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

19
20
import QtQuick 2.5
import QtQuick.Controls 2.5 as QQC2
Marco Martin's avatar
Marco Martin committed
21
import QtQuick.Layouts 1.1
22
23

import org.kde.kirigami 2.5 as Kirigami
Marco Martin's avatar
Marco Martin committed
24
25

Rectangle {
26
    id: root
Marco Martin's avatar
Marco Martin committed
27
    color: Kirigami.Theme.backgroundColor
Tien Do Nam's avatar
Tien Do Nam committed
28
    property int verticalMargin: Kirigami.Units.gridUnit * 3
29
30
31
32
33
34
35
36
37
38
39
40

    signal focusNextRequest()
    signal focusPreviousRequest()

    function focusFirstChild() {
        iconsRow.children[0].focus = true;
    }

    function focusLastChild() {
        iconsRow.children[iconsRow.children.length-1].focus = true;
    }

Tien Do Nam's avatar
Tien Do Nam committed
41
    RowLayout {
Marco Martin's avatar
Marco Martin committed
42
        anchors {
Tien Do Nam's avatar
Tien Do Nam committed
43
44
            bottom: parent.verticalCenter
            bottomMargin: verticalMargin
Marco Martin's avatar
Marco Martin committed
45
46
            horizontalCenter: parent.horizontalCenter
        }
Tien Do Nam's avatar
Tien Do Nam committed
47
        Layout.alignment: Qt.AlignHCenter
Marco Martin's avatar
Marco Martin committed
48
49
        Kirigami.Icon {
            Layout.alignment: Qt.AlignHCenter
50
            source: "preferences-system"
Marco Martin's avatar
Marco Martin committed
51
52
53
            width: Kirigami.Units.iconSizes.enormous
            height: width
        }
Tien Do Nam's avatar
Tien Do Nam committed
54
55
56
57
58
59
60
        Item {
            width: Kirigami.Units.largeSpacing
        }
        ColumnLayout {
            RowLayout {
                Kirigami.Icon {
                    Layout.alignment: Qt.AlignHCenter
David Redondo's avatar
David Redondo committed
61
62
63
                    source: Qt.resolvedUrl("../images/plasma-logo.svg")
                    color: Kirigami.Theme.textColor
                    isMask: true
Tien Do Nam's avatar
Tien Do Nam committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
                    width: Kirigami.Units.iconSizes.medium
                    height: width
                }
                Kirigami.Heading {
                    text: i18n("Plasma")
                    level: 1
                    font.weight: Font.Bold
                }
            }
            
            Kirigami.Heading {
                text: i18n("System Settings")
                level: 1
            }
Marco Martin's avatar
Marco Martin committed
78
        }
79
    }
Tien Do Nam's avatar
Tien Do Nam committed
80

81
82
    ColumnLayout {
        anchors {
Tien Do Nam's avatar
Tien Do Nam committed
83
84
            top: parent.verticalCenter
            topMargin: verticalMargin
85
86
            horizontalCenter: parent.horizontalCenter
        }
87
        width: Math.round(parent.width * 0.8)
Tien Do Nam's avatar
Tien Do Nam committed
88

89
90
        Kirigami.Heading {
            Layout.alignment: Qt.AlignHCenter
Tien Do Nam's avatar
Tien Do Nam committed
91
            Layout.bottomMargin: Kirigami.Units.largeSpacing
92
            level: 3
93
            wrapMode: Text.NoWrap
Tien Do Nam's avatar
Tien Do Nam committed
94
            text: i18n("Frequently Used")
95
96
        }
        RowLayout {
Marco Martin's avatar
Marco Martin committed
97
            id: iconsRow
98
99
100
            Layout.fillWidth: true
            Layout.alignment: Qt.AlignHCenter
            spacing: Kirigami.Units.largeSpacing
101
102
103
104
            property int spaceForIcon: Math.max((iconsRow.parent.width - iconsRow.spacing * 4) / 5, Kirigami.Units.iconSizes.medium)
            property int iconSize: iconsRow.spaceForIcon >= Kirigami.Units.iconSizes.huge
                        ? Kirigami.Units.iconSizes.huge
                        : (iconsRow.spaceForIcon >= Kirigami.Units.iconSizes.large ? Kirigami.Units.iconSizes.large : Kirigami.Units.iconSizes.medium)
105
106

            Repeater {
107
                id: mostUsedRepeater
108
109
110
111
                model: systemsettings.mostUsedModel
                delegate: IntroIcon {
                    icon: model.decoration
                    text: model.display
112
113
114
115
                    iconSize: iconsRow.iconSize
                    Layout.minimumWidth: iconsRow.spaceForIcon
                    Layout.maximumWidth: Layout.minimumWidth
                    visible: (index + 1) * iconSize + index * iconsRow.spacing  < iconsRow.parent.width
116
117
                }
            }
Marco Martin's avatar
Marco Martin committed
118
119
        }
    }
Tien Do Nam's avatar
Tien Do Nam committed
120
    
Marco Martin's avatar
Marco Martin committed
121
}