Kirigami2

PageTab.qml
1 /*
2  * SPDX-FileCopyrightText: 2021 Carson Black <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.12
8 import QtQuick.Layouts 1.12
9 import QtQuick.Controls 2.12 as QQC2
10 import org.kde.kirigami 2.12 as Kirigami
11 import "templates" as T
12 
13 T.PageTab {
14  id: control
15 
16  implicitWidth: vertical ? verticalTitleRow.implicitWidth : horizontalTitleRow.implicitWidth
17  implicitHeight: vertical ? verticalTitleRow.implicitHeight : horizontalTitleRow.implicitHeight
18 
19  background: Rectangle {
20  border {
21  width: activeFocus ? 2 : 0
22  color: Kirigami.Theme.textColor
23  }
24  color: {
25  if (control.active) {
26  return Kirigami.ColorUtils.adjustColor(Kirigami.Theme.activeTextColor, {"alpha": 0.2*255})
27  } else if (control.needsAttention) {
28  return Kirigami.ColorUtils.adjustColor(Kirigami.Theme.negativeTextColor, {"alpha": 0.2*255})
29  } else {
30  return "transparent"
31  }
32  }
33  }
34 
35  PrivateSwipeHighlight {
36  states: [
37  State { name: "highlighted"; when: control.active },
38  State { name: "requestingAttention"; when: control.needsAttention }
39  ]
40  }
41 
42  PrivateSwipeProgress {
43  anchors.fill: parent
44  visible: control.progress !== undefined
45  progress: control.progress
46  }
47 
48  RowLayout {
49  id: verticalTitleRow
50  anchors.fill: parent
51  Accessible.ignored: true
52  visible: vertical
53 
54  ColumnLayout {
55  Layout.margins: Kirigami.Settings.isMobile ? Kirigami.Units.smallSpacing : Kirigami.Units.largeSpacing
56  Layout.alignment: Qt.AlignCenter
57 
58  Kirigami.Icon {
59  visible: !!control.icon.name
60  source: control.icon.name
61 
62  Layout.preferredHeight: (control.presentation === T.PageTab.Presentation.Large)
63  ? Kirigami.Units.iconSizes.medium
64  : (Kirigami.Settings.isMobile ? Kirigami.Units.iconSizes.smallMedium : Kirigami.Units.iconSizes.small)
65  Layout.preferredWidth: Layout.preferredHeight
66 
67  Layout.alignment: (Qt.AlignHCenter | Qt.AlignBottom)
68  }
69  Kirigami.Heading {
70  level: (control.presentation === T.PageTab.Presentation.Large) ? 2 : 5
71  text: control.title
72  horizontalAlignment: Text.AlignHCenter
73  elide: Text.ElideRight
74 
75  Layout.fillWidth: true
76  Layout.alignment: Qt.AlignCenter
77  }
78  }
79  }
80 
81  RowLayout {
82  id: horizontalTitleRow
83  anchors.fill: parent
84  Accessible.ignored: true
85  visible: !vertical
86 
87  RowLayout {
88  Layout.margins: (control.presentation === T.PageTab.Presentation.Large) ? Kirigami.Units.largeSpacing*2 : Kirigami.Units.largeSpacing
89  Layout.alignment: Qt.AlignVCenter
90 
91  Kirigami.Icon {
92  visible: !!control.icon.name
93  source: control.icon.name
94 
95  Layout.preferredHeight: (control.presentation === T.PageTab.Presentation.Large)
96  ? Kirigami.Units.iconSizes.medium
97  : (Kirigami.Settings.isMobile ? Kirigami.Units.iconSizes.smallMedium : Kirigami.Units.iconSizes.small)
98  Layout.preferredWidth: Layout.preferredHeight
99 
100  Layout.alignment: (Qt.AlignLeft | Qt.AlignVCenter)
101  }
102  Kirigami.Heading {
103  level: (control.presentation === T.PageTab.Presentation.Large) ? 1 : 2
104  text: control.title
105 
106  Layout.fillWidth: true
107  Layout.alignment: (Qt.AlignLeft | Qt.AlignVCenter)
108  }
109  }
110  }
111 
112  Layout.fillHeight: true
113  Layout.alignment: Qt.AlignHCenter
114 }
QStringView level(QStringView ifopt)
QString name(StandardShortcut id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:14:23 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.