~josephjamesmills/ubuntutv/maps_fanart

« back to all changes in this revision

Viewing changes to components/ContextMenu.qml

  • Committer: Joseph Mills
  • Date: 2012-07-28 14:57:10 UTC
  • Revision ID: josephjamesmills@gmail.com-20120728145710-sy00cvq1ja8o9qad
Lots of cool stuff. watch my youtube videos to see  what else has been added

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** This file is part of Qt Media Hub**
 
2
 
 
3
Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).*
 
4
All rights reserved.
 
5
 
 
6
Contact:  Nokia Corporation qmh-development@qt-project.org
 
7
 
 
8
You may use this file under the terms of the BSD license
 
9
as follows:
 
10
 
 
11
Redistribution and use in source and binary forms, with or
 
12
without modification, are permitted provided that the following
 
13
conditions are met:
 
14
* Redistributions of source code must retain the above copyright
 
15
notice, this list of conditions and the following disclaimer.
 
16
 
 
17
* Redistributions in binary form must reproduce the above copyright
 
18
notice, this list of conditions and the following disclaimer in the
 
19
documentation and/or other materials provided with the distribution.
 
20
 
 
21
* Neither the name of Nokia Corporation and its Subsidiary(-ies)
 
22
nor the names of its contributors may be used to endorse or promote
 
23
products derived from this software without specific prior
 
24
written permission.
 
25
 
 
26
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
27
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
28
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 
29
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 
30
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 
31
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
32
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
33
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
34
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 
35
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
36
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 
37
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/
 
38
 
 
39
import QtQuick 1.1
 
40
 
 
41
FocusScope {
 
42
    id: root
 
43
    width: actionListView.width + 20
 
44
    height: glassTitleBar.height + actionListView.height + 10
 
45
 
 
46
    property alias model: actionListView.model
 
47
    property alias title : titleBarText.text
 
48
    signal opened
 
49
    signal closed
 
50
 
 
51
    opacity: 0
 
52
 
 
53
    function close() {
 
54
        opacity = 0
 
55
        root.closed()
 
56
    }
 
57
 
 
58
    function open() {
 
59
        opacity = 1;
 
60
        root.opened()
 
61
    }
 
62
 
 
63
    Behavior on opacity {
 
64
        NumberAnimation { }
 
65
    }
 
66
 
 
67
    BorderImage {
 
68
        id: panel
 
69
        source: themeResourcePath + "/media/OverlayDialogBackground.png"
 
70
        border { top: 20; left: 20; bottom: 20; right: 20; }
 
71
        anchors.fill: parent
 
72
    }
 
73
 
 
74
    ActionListView {
 
75
        id: actionListView
 
76
        focus: true
 
77
        hideItemBackground: true
 
78
        anchors.top: glassTitleBar.bottom
 
79
        anchors.horizontalCenter: panel.horizontalCenter
 
80
        anchors.bottomMargin : panel.border.bottom
 
81
        onActivated: root.close()
 
82
    }
 
83
 
 
84
    Image {
 
85
        id: glassTitleBar
 
86
        source: themeResourcePath + "/media/GlassTitleBar.png"
 
87
        anchors.top: panel.top
 
88
        width: panel.width
 
89
        height: titleBarText.height + 10
 
90
 
 
91
        Text {
 
92
            id: titleBarText
 
93
            anchors.centerIn: parent
 
94
            color: "white"
 
95
            text: "Default dialog title"
 
96
            font.bold: true
 
97
            font.pointSize: 14
 
98
        }
 
99
    }
 
100
 
 
101
    Image {
 
102
        id: closeButton
 
103
        source: themeResourcePath + "/media/" + (closeButtonMouseArea.pressed ? "DialogCloseButton-focus.png" : "DialogCloseButton.png")
 
104
        anchors.top: panel.top
 
105
        anchors.right: panel.right
 
106
        anchors { rightMargin: 10; topMargin: 5; }
 
107
        MouseArea {
 
108
            id: closeButtonMouseArea
 
109
            anchors.fill: parent;
 
110
 
 
111
            onClicked: root.close();
 
112
        }
 
113
    }
 
114
 
 
115
    Keys.onMenuPressed: root.close()
 
116
}
 
117