QML UI: Subscription UI and compatibility fixes
[gpodder.git] / data / ui / qml / ContextMenu.qml
blob8969b6bff483347e045526c96f39eeef31c3b675
2 import Qt 4.7
4 import 'config.js' as Config
6 Item {
7     id: contextMenuArea
9     property bool subscribeMode: true
11     property variant items: []
13     signal close
14     signal response(int index)
16     MouseArea {
17         anchors.fill: parent
18     }
20     Rectangle {
21         color: "black"
22         anchors.fill: parent
23         opacity: .9
24     }
26     ListView {
27         visible: !contextMenuArea.subscribeMode
28         model: contextMenuArea.items
29         anchors.fill: parent
31         header: Item { height: Config.headerHeight * 2 }
32         footer: Item { height: Config.headerHeight }
34         delegate: SelectableItem {
35             Text {
36                 anchors.leftMargin: Config.switcherWidth
37                 anchors {
38                     left: parent.left
39                     right: parent.right
40                     verticalCenter: parent.verticalCenter
41                 }
42                 color: "white"
43                 font.pixelSize: parent.height * .3
44                 text: modelData.caption
45             }
47             onSelected: {
48                 contextMenuArea.response(index)
49                 contextMenuArea.close()
50             }
51         }
52     }
54     function showSubscribe() {
55         contextMenuArea.subscribeMode = true
56         contextMenuArea.state = 'opened'
57         subscribe.show()
58     }
60     Subscribe {
61         id: subscribe
62         visible: contextMenuArea.subscribeMode && (contextMenuArea.state == 'opened')
63         anchors.fill: parent
64         anchors.topMargin: Config.headerHeight
66         onSubscribe: {
67             controller.addSubscription(url)
68             contextMenuArea.close()
69         }
70     }