Warning, /multimedia/haruna/src/qml/Osd.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2020 George Florea Bănuș <georgefb899@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Controls
0009 
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.haruna
0012 import org.kde.haruna.settings
0013 
0014 Item {
0015     id: root
0016 
0017     required property int maxWidth
0018     property bool active: mpv.isReady
0019     property alias label: label
0020 
0021     Label {
0022         id: label
0023 
0024         property int textWidth: Math.ceil(textMetrics.advanceWidth) + padding * 2
0025 
0026         x: Kirigami.Units.largeSpacing
0027         y: Kirigami.Units.largeSpacing
0028         width: textWidth > root.maxWidth ? maxWidth : undefined
0029         visible: false
0030         background: Rectangle {
0031             color: Kirigami.Theme.backgroundColor
0032         }
0033         padding: Kirigami.Units.largeSpacing
0034         font.pointSize: parseInt(GeneralSettings.osdFontSize)
0035         maximumLineCount: 5
0036         wrapMode: Text.WrapAnywhere
0037 
0038         TextMetrics {
0039             id: textMetrics
0040 
0041             font: label.font
0042             text: label.text
0043         }
0044     }
0045 
0046     Timer {
0047         id: timer
0048         running: false
0049         repeat: false
0050         interval: 3000
0051 
0052         onTriggered: {
0053             label.visible = false
0054         }
0055     }
0056 
0057     function message(text) {
0058         if (!root.active) {
0059             return
0060         }
0061 
0062         if (text === "" || text === null || text === undefined) {
0063             return
0064         }
0065 
0066         const osdFontSize = parseInt(GeneralSettings.osdFontSize)
0067         if (osdFontSize === 0) {
0068             return;
0069         }
0070 
0071         timer.restart()
0072         label.text = text
0073         label.visible = true
0074     }
0075 
0076 }