microkodi/microkodi/qml/Main.qml

117 lines
2.5 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Window {
id: window
visible: true
title: "Hello World"
visibility: Window.Maximized
flags: Qt.FramelessWindowHint
property var wallpaperIndex: 0
property var isLoading: false
property var bridge
property var currentTime: initialTime
Connections {
target: bridge
function onIsLoading(loading) {
isLoading = loading
}
function onNotification(text) {
notificationModel.append({"message": text})
}
}
Image {
id: wallpaperImage
height: window.height
width: window.width
visible: true
source: wallpapers[wallpaperIndex]
fillMode: Image.PreserveAspectCrop
}
Popup {
visible: isLoading
x: Math.round((parent.width - width) / 2)
y: Math.round((parent.height - height) / 2)
width: 100
height: 100
background: BusyIndicator {
running: isLoading
width: 100
height: 100
}
}
Timer {
interval: 30 * 1000
running: !isLoading
repeat: true
onTriggered: wallpaperIndex = (wallpaperIndex + 1) % wallpapers.length
}
Timer {
interval: 5 * 1000
running: true
repeat: true
onTriggered: currentTime = bridge.currentTime()
}
Label {
text: currentTime
anchors.right: wallpaperImage.right
anchors.top: wallpaperImage.top
anchors.topMargin: 20
anchors.rightMargin: 20
font.pixelSize: window.height * 0.1
}
ListModel {
id: notificationModel
}
Timer {
interval: 8 * 1000
running: notificationModel.count > 0
repeat: true
onTriggered: notificationModel.remove(0, 1)
}
Component {
id: notificationDelegate
Rectangle {
color: "#37474F"
width: 400
height: 100
radius: 10
Label {
text: message
color: "white"
font.pixelSize: 20
anchors.fill: parent
anchors.margins: 10
}
}
}
ListView {
anchors.right: wallpaperImage.right
anchors.top: wallpaperImage.top
anchors.topMargin: 20 * 2 + window.height * 0.1
anchors.rightMargin: 20
width: 400
height: window.height * 0.9 - 20 * 2
spacing: 50
model: notificationModel
delegate: notificationDelegate
}
}