cards/qml/cards/Button.qml
author John Kern <johnk@symbian.org>
Mon, 25 Oct 2010 10:35:32 -0700
changeset 3 2e16639599b7
permissions -rwxr-xr-x
flipping cards example
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
     1
/****************************************************************************
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
     2
**
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
     3
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
     4
** All rights reserved.
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
     5
** Contact: Nokia Corporation (qt-info@nokia.com)
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
     6
**
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
     7
** This file is part of the QtDeclarative module of the Qt Toolkit.
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
     8
**
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
     9
** $QT_BEGIN_LICENSE:LGPL$
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    10
** Commercial Usage
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    11
** Licensees holding valid Qt Commercial licenses may use this file in
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    12
** accordance with the Qt Commercial License Agreement provided with the
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    13
** Software or, alternatively, in accordance with the terms contained in
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    14
** a written agreement between you and Nokia.
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    15
**
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    16
** GNU Lesser General Public License Usage
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    17
** Alternatively, this file may be used under the terms of the GNU Lesser
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    18
** General Public License version 2.1 as published by the Free Software
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    19
** Foundation and appearing in the file LICENSE.LGPL included in the
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    20
** packaging of this file.  Please review the following information to
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    21
** ensure the GNU Lesser General Public License version 2.1 requirements
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    23
**
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    24
** In addition, as a special exception, Nokia gives you certain additional
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    25
** rights.  These rights are described in the Nokia Qt LGPL Exception
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    27
**
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    28
** GNU General Public License Usage
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    29
** Alternatively, this file may be used under the terms of the GNU
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    30
** General Public License version 3.0 as published by the Free Software
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    31
** Foundation and appearing in the file LICENSE.GPL included in the
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    32
** packaging of this file.  Please review the following information to
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    33
** ensure the GNU General Public License version 3.0 requirements will be
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    34
** met: http://www.gnu.org/copyleft/gpl.html.
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    35
**
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    36
** If you have questions regarding the use of this file, please contact
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    37
** Nokia at qt-info@nokia.com.
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    38
** $QT_END_LICENSE$
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    39
**
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    40
****************************************************************************/
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    41
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    42
import Qt 4.7
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    43
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    44
BorderImage {
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    45
    id: button
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    46
    property string color: "blue"
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    47
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    48
    signal clicked
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    49
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    50
   // source: "images/button-" + color + ".png"; clip: true
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    51
    border { left: 10; top: 10; right: 10; bottom: 10 }
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    52
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    53
    Rectangle {
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    54
        id: shade
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    55
        anchors.fill: button; radius: 10; color: "black"; opacity: 0
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    56
    }
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    57
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    58
    Text {
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    59
        id: buttonText
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    60
        text: "Exit"
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    61
        anchors.centerIn: parent; anchors.verticalCenterOffset: -1
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    62
        font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    63
        style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    64
    }
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    65
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    66
    MouseArea {
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    67
        id: mouseArea
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    68
        anchors.fill: parent
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    69
        onClicked: Qt.quit()
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    70
    }
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    71
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    72
    states: State {
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    73
        name: "pressed"; when: mouseArea.pressed == true
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    74
        PropertyChanges { target: shade; opacity: .4 }
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    75
    }
2e16639599b7 flipping cards example
John Kern <johnk@symbian.org>
parents:
diff changeset
    76
}