1/*
2 * Copyright (C) 2016, 2017
3 *      Jean-Luc Barriere <jlbarriere68@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18import QtQuick 2.9
19import QtQuick.Controls 2.2
20
21Item {
22    property string message: ""
23    property alias backgroundColor: containerLayoutBackground.color
24    property alias labelColor: label.color
25
26    y: units.gu(2)
27    x: (parent.width - popover.width) / 2
28
29    Popup {
30        id: popover
31        width: label.paintedWidth + units.gu(6)
32
33        background: Rectangle {
34                id: containerLayoutBackground
35                anchors.fill: parent
36                color: styleMusic.popover.backgroundColor
37                radius: units.gu(1)
38                opacity: 0.7
39            }
40
41        Label {
42            id: label
43            text: message
44            anchors.centerIn: parent
45            verticalAlignment: Text.AlignVCenter
46            horizontalAlignment: Text.AlignHCenter
47            color: styleMusic.popover.labelColor
48            font.pointSize: units.fs("small")
49            font.weight: Font.Normal
50        }
51
52        onOpened: timer.start()
53    }
54
55    Timer {
56        id: timer
57        interval: 3000
58        onTriggered: {
59            popover.close();
60        }
61    }
62
63    function open(msgtxt) {
64        message = msgtxt;
65        popover.open();
66    }
67
68}
69