diff options
Diffstat (limited to 'examples/quick/demos/rssnews/content/CategoryDelegate.qml')
-rw-r--r-- | examples/quick/demos/rssnews/content/CategoryDelegate.qml | 143 |
1 files changed, 93 insertions, 50 deletions
diff --git a/examples/quick/demos/rssnews/content/CategoryDelegate.qml b/examples/quick/demos/rssnews/content/CategoryDelegate.qml index bb2b3581df..cb48715609 100644 --- a/examples/quick/demos/rssnews/content/CategoryDelegate.qml +++ b/examples/quick/demos/rssnews/content/CategoryDelegate.qml @@ -3,80 +3,123 @@ ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtQml module of the Qt Toolkit. +** This file is part of the examples of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import QtQuick 2.2 +import QtGraphicalEffects 1.0 -Item { +Rectangle { id: delegate - width: delegate.ListView.view.width; height: 60 + property bool selected: ListView.isCurrentItem + property real itemSize + width: itemSize + height: itemSize - Text { - text: name - color: delegate.ListView.isCurrentItem ? "white" : "black" - font { family: "Helvetica"; pixelSize: 16; bold: true } - anchors { - left: parent.left; leftMargin: 15 - verticalCenter: parent.verticalCenter - } + Image { + anchors.centerIn: parent + source: image } - BusyIndicator { - scale: 0.6 - on: delegate.ListView.isCurrentItem && window.loading - anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter } - } + Item { + id: title + anchors.fill: parent + + Text { + id: titleText + + anchors { + left: parent.left; leftMargin: 20 + right: parent.right; rightMargin: 20 + top: parent.top; topMargin: 20 + } + font { pixelSize: 18; bold: true } + text: name + color: selected ? "#ffffff" : "#ebebdd" + Behavior on color { ColorAnimation { duration: 150 } } + } - Rectangle { - width: delegate.width; height: 1; color: "#cccccc" - anchors.bottom: delegate.bottom - visible: delegate.ListView.isCurrentItem ? false : true + DropShadow { + source: titleText + anchors.fill: titleText + horizontalOffset: selected ? 3 : 1 + verticalOffset: selected ? 3 : 1 + radius: 4 + color: "#2f1000" + samples: 8 + + Behavior on horizontalOffset { NumberAnimation { duration: 300 } } + Behavior on verticalOffset { NumberAnimation { duration: 300 } } + } + + states: [ + State { + name: "selected" + when: selected + PropertyChanges { target: title; scale: "1.1" } + }] + + transitions: [ + Transition { + to: "selected" + SequentialAnimation { + id: titleAnimation + PropertyAnimation { target: title; property: "scale"; duration: 300 } + } + }, + Transition { + to: "" + animations: titleAnimation + }] } - Rectangle { - width: delegate.width; height: 1; color: "white" - visible: delegate.ListView.isCurrentItem ? false : true + + BusyIndicator { + scale: 0.8 + visible: delegate.ListView.isCurrentItem && window.loading + anchors.centerIn: parent } MouseArea { anchors.fill: delegate onClicked: { delegate.ListView.view.currentIndex = index - window.currentFeed = feed + if (window.currentFeed == feed) + feedModel.reload() + else + window.currentFeed = feed } } } |