diff --git a/src/qmlcontrols/kcmcontrols/qml/GridViewKCM.qml b/src/qmlcontrols/kcmcontrols/qml/GridViewKCM.qml index 83097a5..c535ff9 100644 --- a/src/qmlcontrols/kcmcontrols/qml/GridViewKCM.qml +++ b/src/qmlcontrols/kcmcontrols/qml/GridViewKCM.qml @@ -1,117 +1,116 @@ /* Copyright (c) 2017 Marco Martin 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. */ import QtQuick 2.7 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.2 as QtControls import org.kde.kirigami 2.2 as Kirigami import org.kde.kcm 1.1 as KCM /** - * This component is intended to be used as the root item for most of the - * KControl modules which are based upon a grid view of thumbnails, such as theme - * or wallpaper selectors. - * It has a big GridView as its main item, the implementation is free to add extra - * content in the header or footer properties. + * This component is intended to be used as the root item for KCMs that are based upon + * a grid view of thumbnails, such as the theme or wallpaper selectors. + * It contains a GridView as its main item. + * It is possible to specify a header and footer component. * @code * import org.kde.kcm 1.1 as KCM * KCM.GridViewKCM { * header: Item {...} * view.model: kcm.model * view.delegate: KCM.GridDelegate {...} * footer: Item {...} * } * @endcode * @inherits org.kde.kirigami.Page */ Kirigami.Page { id: root /** * view: GridView * Exposes the internal GridView: in order to set a model or a delegate to it, * use the following code: * @code * import org.kde.kcm 1.1 as KCM * KCM.GridViewKCM { * ... * view.model: kcm.model * view.delegate: KCM.GridDelegate {...} * ... * } * @endcode */ property alias view: scroll.view title: kcm.name implicitWidth: { var width = 0; // Show three columns at once, every colum occupies implicitCellWidth + Units.gridUnit width += 3 * (view.implicitCellWidth + Kirigami.Units.gridUnit); var scrollBar = scroll.QtControls.ScrollBar.vertical; width += scrollBar.width + scrollBar.leftPadding + scrollBar.rightPadding; width += scroll.leftPadding + scroll.rightPadding width += root.leftPadding + root.rightPadding; return width; } implicitHeight: view.implicitCellHeight * 3 + (header ? header.height : 0) + (footer ? footer.height : 0) + Kirigami.Units.gridUnit flickable: scroll.view //NOTE: this should be smallspacing buit we need a pixel size in order to align with systemsettings widgets leftPadding: Kirigami.Settings.isMobile ? 0 : headerParent.leftPadding topPadding: headerParent.contentItem ? 0 : leftPadding rightPadding: leftPadding bottomPadding: footerParent.contentItem ? 0 : leftPadding header: QtControls.Control { id: headerParent height: contentItem ? implicitHeight : 0 } footer: QtControls.Control { id: footerParent height: contentItem ? implicitHeight : 0 } Component.onCompleted: { if (footer && footer != footerParent) { var f = footer footerParent.contentItem = f footer = footerParent f.parent = footerParent } if (header && header != headerParent) { var f = header headerParent.contentItem = f header = headerParent f.parent = headerParent } } KCM.GridView { id: scroll anchors.fill: parent } } diff --git a/src/qmlcontrols/kcmcontrols/qml/ScrollViewKCM.qml b/src/qmlcontrols/kcmcontrols/qml/ScrollViewKCM.qml index 19ce23f..be66c0d 100644 --- a/src/qmlcontrols/kcmcontrols/qml/ScrollViewKCM.qml +++ b/src/qmlcontrols/kcmcontrols/qml/ScrollViewKCM.qml @@ -1,103 +1,102 @@ /* Copyright (c) 2017 Marco Martin 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. */ import QtQuick 2.7 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.2 as QtControls import org.kde.kirigami 2.2 as Kirigami import org.kde.kcm 1.1 as KCM import "." as Priv /** - * This component is intended to be used as the root item for most of the - * KControl modules which are based upon a list view or another vertical flickable - * It has a big ScrollView as its main item, the implementation is free to add extra - * content in the header or footer properties. + * This component is intended to be used as the root item for KCMs that are based upon a list view or another vertical flickable. + * It contains a ScrollView as its main item. + * It is possible to specify a header and footer component. * @code * import org.kde.kcm 1.2 as KCM * KCM.ScrollViewKCM { * header: Item {...} * view: ListView { * ... * } * footer: Item {...} * } * @endcode * @inherits org.kde.kirigami.Page */ Kirigami.Page { id: root /** * view: GridView * Exposes the internal flickable */ property alias view: scroll.view title: kcm.name implicitWidth: Kirigami.Units.gridUnit * 20 implicitHeight: view && view.contentHeight > 0 ? Math.min(view.contentHeight, Kirigami.Units.gridUnit * 20) : Kirigami.Units.gridUnit * 20 //flickable: scroll.view //NOTE: this should be smallspacing buit we need a pixel size in order to align with systemsettings widgets leftPadding: Kirigami.Settings.isMobile ? 0 : 4 topPadding: headerParent.contentItem ? 0 : (Kirigami.Settings.isMobile ? 0 : 4) rightPadding: (Kirigami.Settings.isMobile ? 0 : 4) bottomPadding: footerParent.contentItem ? 0 : (Kirigami.Settings.isMobile ? 0 : 4) header: QtControls.Control { id: headerParent visible: root.contentItem && root.contentItem.visible height: visible ? implicitHeight : 0 leftPadding: 4 topPadding: 4 rightPadding: 4 bottomPadding: 4 } footer: QtControls.Control { id: footerParent visible: root.contentItem && root.contentItem.visible height: visible ? implicitHeight : 0 leftPadding: 4 topPadding: 4 rightPadding: 4 bottomPadding: 4 } Component.onCompleted: { if (footer && footer != footerParent) { var f = footer footerParent.contentItem = f footer = footerParent f.parent = footerParent } if (header && header != headerParent) { var h = header headerParent.contentItem = h header = headerParent h.parent = headerParent } } Priv.ScrollView { id: scroll anchors.fill: parent } } diff --git a/src/qmlcontrols/kcmcontrols/qml/SimpleKCM.qml b/src/qmlcontrols/kcmcontrols/qml/SimpleKCM.qml index 6cfb086..02c49d6 100644 --- a/src/qmlcontrols/kcmcontrols/qml/SimpleKCM.qml +++ b/src/qmlcontrols/kcmcontrols/qml/SimpleKCM.qml @@ -1,118 +1,118 @@ /* Copyright (c) 2017 Marco Martin 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. */ import QtQuick 2.7 import QtQuick.Controls 2.2 as QtControls import org.kde.kirigami 2.2 as Kirigami import org.kde.kcm 1.1 as KCM /** * This component is intended to be used as root item for - * KControl modules with arbitrary content, as per the User interface guidelines, - * usually a Kirigami.FormLayout as its main component. - * header and footer properties can be used. + * KCMs with arbitrary content. Often a Kirigami.FormLayout + * is used as main element. + * It is possible to specify a header and footer component. * @code * import org.kde.kcm 1.1 as KCM * import org.kde.kirigami 2.3 as Kirigami * KCM.SimpleKCM { * Kirigami.FormLayout { * TextField { * Kirigami.FormData.label: "Label:" * } * TextField { * Kirigami.FormData.label: "Label:" * } * } * footer: Item {...} * } * @endcode * @inherits org.kde.kirigami.ScrollablePage */ Kirigami.ScrollablePage { id: root title: kcm.name leftPadding: Kirigami.Settings.isMobile ? 0 : 4 topPadding: headerParent.contentItem ? 0 : (Kirigami.Settings.isMobile ? 0 : 4) rightPadding: (Kirigami.Settings.isMobile ? 0 : 4) bottomPadding: footerParent.contentItem ? 0 : (Kirigami.Settings.isMobile ? 0 : 4) header: QtControls.Control { id: headerParent visible: contentItem ? contentItem.visible : false height: visible ? implicitHeight : 0 leftPadding: 4 topPadding: 4 rightPadding: 4 bottomPadding: 4 } footer: QtControls.Control { id: footerParent visible: contentItem ? contentItem.visible : false height: visible ? implicitHeight : 0 leftPadding: 4 topPadding: 4 rightPadding: 4 bottomPadding: 4 } Component.onCompleted: { if (footer && footer != footerParent) { var f = footer footerParent.contentItem = f footer = footerParent footer.visible = true f.parent = footerParent } if (header && header != headerParent) { var h = header headerParent.contentItem = h header = headerParent header.visible = true h.parent = headerParent } } children: [ Kirigami.Separator { z: 999 anchors { left: parent.left right: parent.right top: parent.top topMargin: root.header.visible ? root.header.height : 0 } visible: !root.flickable.atYBeginning && !Kirigami.Settings.isMobile }, Kirigami.Separator { z: 999 anchors { left: parent.left right: parent.right bottom: parent.bottom bottomMargin: root.footer.visible ? root.footer.height : 0 } visible: !root.flickable.atYEnd && !Kirigami.Settings.isMobile } ] }