From bdd54743c254ce6b8b4cfb04622323701a86dd04 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 21 Jul 2017 17:21:35 +0200 Subject: Use an AbstractButton in People.qml for the delegate Using Kube.Button currently crashes, due to the font.underline assignment in the contentItem (although it is replaced in People.qml). It seems the grouped property is somehow executed after the original content item was already destroyed, resulting in a SEGFAULT. --- framework/qml/AbstractButton.qml | 51 ++++++++++++++++++++++++++++++++++++++++ framework/qml/People.qml | 4 +--- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 framework/qml/AbstractButton.qml (limited to 'framework/qml') diff --git a/framework/qml/AbstractButton.qml b/framework/qml/AbstractButton.qml new file mode 100644 index 00000000..a92ab5df --- /dev/null +++ b/framework/qml/AbstractButton.qml @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2017 Michael Bohlender, + * Copyright (C) 2017 Christian Mollekopf, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License along + * with this program; 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.Templates 2.0 as T +import org.kube.framework 1.0 + +T.Button { + id: root + + width: Math.max(Units.gridUnit, contentItem.implicitWidth + leftPadding + rightPadding) + height: contentItem.implicitHeight + Units.smallSpacing * 2 + + padding: Units.largeSpacing + topPadding: Units.smallSpacing * 2 + bottomPadding: Units.smallSpacing *2 + + clip: true + hoverEnabled: true + Keys.onReturnPressed: root.clicked() + + background: Rectangle { + color: Colors.buttonColor + + border.width: 2 + border.color: root.activeFocus && !root.pressed ? Colors.highlightColor : Colors.buttonColor + + Rectangle { + anchors.fill: parent + visible: root.hovered || root.pressed + color: root.pressed ? Colors.textColor : Colors.viewBackgroundColor + opacity: 0.2 + } + } +} diff --git a/framework/qml/People.qml b/framework/qml/People.qml index bdb2cdf2..c2c6c9ef 100644 --- a/framework/qml/People.qml +++ b/framework/qml/People.qml @@ -134,15 +134,13 @@ FocusScope { filter: searchBar.text } - //TODO using Kube.Button currently crashes, but shouldn't - delegate: Button { + delegate: Kube.AbstractButton { id: delegateRoot height: Kube.Units.gridUnit * 3 width: Kube.Units.gridUnit * 10 activeFocusOnTab: true - Keys.onReturnPressed: delegateRoot.clicked() onClicked: { root.currentContact = model.domainObject -- cgit v1.2.3