harbour-muchkin/qml/Main.qml

82 lines
1.9 KiB
QML
Raw Normal View History

2015-02-21 14:19:19 +00:00
import QtQuick 2.0
import Sailfish.Silica 1.0
2021-05-10 18:59:52 +00:00
import io.thp.pyotherside 1.3
2015-02-21 14:19:19 +00:00
Page {
property alias mainList: mainList
2021-05-16 19:59:28 +00:00
SilicaFlickable {
id: mainList
anchors.fill: parent
2021-05-10 18:59:52 +00:00
2021-05-16 19:59:28 +00:00
PullDownMenu {
MenuItem {
text: "About"
onClicked: pageStack.push(Qt.resolvedUrl("About.qml"))
}
MenuItem {
text: "Refresh"
onClicked: mainList.reload()
}
2021-05-10 18:59:52 +00:00
}
2021-05-16 19:59:28 +00:00
PageHeader {
id: header
width: parent.width
title: "Select the webapp to unify"
}
SilicaGridView {
anchors.top: header.bottom
width: parent.width
height: parent.height
cellWidth: width / 4
cellHeight: cellWidth
model: ListModel {
id: appsList
}
delegate: GridItem {
menu: Component {
ContextMenu {
MenuItem {
text: attrs.Name
}
2021-05-10 18:59:52 +00:00
}
}
2021-05-16 19:59:28 +00:00
Image {
anchors.centerIn: parent
source: attrs.Icon
}
2021-05-10 18:59:52 +00:00
2021-05-16 19:59:28 +00:00
onClicked: {
pageStack.push(Qt.resolvedUrl("Icon.qml"), {attrs: attrs});
}
2021-05-10 18:59:52 +00:00
}
}
2021-05-16 19:59:28 +00:00
function reload(){
appsList.clear()
py.addImportPath(Qt.resolvedUrl("../src"))
2021-05-10 18:59:52 +00:00
py.importModule("main", function(){
py.call("main.get_web_icons", [], function(apps){
for(var i=0; i < apps.length; i++){
2021-05-16 19:59:28 +00:00
appsList.append({attrs: apps[i]})
2021-05-10 18:59:52 +00:00
}
})
})
}
2021-05-16 19:59:28 +00:00
Python {
id: py
Component.onCompleted: {
mainList.reload()
}
}
2015-02-21 14:19:19 +00:00
}
2021-05-16 19:59:28 +00:00
2015-02-21 14:19:19 +00:00
}