Changeset View
Changeset View
Standalone View
Standalone View
src/qmlcontrols/kcmcontrols/qml/SimpleKCM.qml
Show All 11 Lines | 1 | /* | |||
---|---|---|---|---|---|
12 | 12 | | |||
13 | You should have received a copy of the GNU Library General Public License | 13 | You should have received a copy of the GNU Library General Public License | ||
14 | along with this library; see the file COPYING.LIB. If not, write to | 14 | along with this library; see the file COPYING.LIB. If not, write to | ||
15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
16 | Boston, MA 02110-1301, USA. | 16 | Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | import QtQuick 2.7 | 19 | import QtQuick 2.7 | ||
20 | import QtQuick.Controls 2.2 as QtControls | ||||
20 | import org.kde.kirigami 2.2 as Kirigami | 21 | import org.kde.kirigami 2.2 as Kirigami | ||
21 | import org.kde.kcm 1.1 as KCM | 22 | import org.kde.kcm 1.1 as KCM | ||
22 | 23 | | |||
23 | /** | 24 | /** | ||
24 | * This component is intended to be used as root item for | 25 | * This component is intended to be used as root item for | ||
25 | * KControl modules with arbitrary content, as per the User interface guidelines, | 26 | * KControl modules with arbitrary content, as per the User interface guidelines, | ||
26 | * usually a Kirigami.FormLayout as its main component. | 27 | * usually a Kirigami.FormLayout as its main component. | ||
27 | * header and footer properties can be used. | 28 | * header and footer properties can be used. | ||
Show All 16 Lines | |||||
44 | */ | 45 | */ | ||
45 | Kirigami.ScrollablePage { | 46 | Kirigami.ScrollablePage { | ||
46 | id: root | 47 | id: root | ||
47 | 48 | | |||
48 | title: kcm.name | 49 | title: kcm.name | ||
49 | implicitWidth: Kirigami.Units.gridUnit * 20 | 50 | implicitWidth: Kirigami.Units.gridUnit * 20 | ||
50 | implicitHeight: Math.min(flickable.contentHeight, Kirigami.Units.gridUnit * 20) | 51 | implicitHeight: Math.min(flickable.contentHeight, Kirigami.Units.gridUnit * 20) | ||
51 | 52 | | |||
53 | leftPadding: Kirigami.Settings.isMobile ? 0 : 4 | ||||
54 | topPadding: headerParent.contentItem ? 0 : (Kirigami.Settings.isMobile ? 0 : 4) | ||||
55 | rightPadding: (Kirigami.Settings.isMobile ? 0 : 4) | ||||
56 | bottomPadding: footerParent.contentItem ? 0 : (Kirigami.Settings.isMobile ? 0 : 4) | ||||
57 | | ||||
58 | header: QtControls.Control { | ||||
59 | id: headerParent | ||||
60 | visible: contentItem && contentItem.visible | ||||
61 | height: visible ? implicitHeight : 0 | ||||
62 | leftPadding: 4 | ||||
63 | topPadding: 4 | ||||
64 | rightPadding: 4 | ||||
65 | bottomPadding: 4 | ||||
66 | } | ||||
67 | | ||||
68 | footer: QtControls.Control { | ||||
69 | id: footerParent | ||||
70 | visible: contentItem && contentItem.visible | ||||
71 | height: visible ? implicitHeight : 0 | ||||
72 | leftPadding: 4 | ||||
73 | topPadding: 4 | ||||
74 | rightPadding: 4 | ||||
75 | bottomPadding: 4 | ||||
76 | } | ||||
77 | | ||||
78 | Component.onCompleted: { | ||||
79 | if (footer && footer != footerParent) { | ||||
80 | var f = footer | ||||
81 | | ||||
82 | footerParent.contentItem = f | ||||
83 | footer = footerParent | ||||
84 | f.visible = true | ||||
85 | f.parent = footerParent | ||||
86 | } | ||||
87 | | ||||
88 | if (header && header != headerParent) { | ||||
89 | var h = header | ||||
90 | | ||||
91 | headerParent.contentItem = h | ||||
92 | header = headerParent | ||||
93 | h.visible = true | ||||
94 | h.parent = headerParent | ||||
95 | } | ||||
96 | } | ||||
97 | | ||||
52 | children: [ | 98 | children: [ | ||
53 | Kirigami.Separator { | 99 | Kirigami.Separator { | ||
54 | z: 999 | 100 | z: 999 | ||
55 | anchors { | 101 | anchors { | ||
56 | left: parent.left | 102 | left: parent.left | ||
57 | right: parent.right | 103 | right: parent.right | ||
58 | top: parent.top | 104 | top: parent.top | ||
59 | topMargin: root.header ? root.header.height : 0 | 105 | topMargin: root.header ? root.header.height : 0 | ||
Show All 15 Lines |