FullRepresentation.qml 2.41 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright 2018  Friedrich W. H. Kossebau <kossebau@kde.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

18
import QtQuick 2.9
19

20
import QtQuick.Layouts 1.3
21 22

import org.kde.plasma.plasmoid 2.0
23
import org.kde.plasma.components 3.0 as PlasmaComponents
24

25
ColumnLayout {
26 27
    id: fullRoot

28
    Layout.margins: units.smallSpacing
29

30 31
    property alias model: topPanel.model

32
    TopPanel {
33
        id: topPanel
34

35
        Layout.fillWidth: true
36 37
    }

38 39
    SwitchPanel {
        Layout.fillWidth: true
40

41 42 43 44
        forecastViewTitle: model.forecastTitle
        forecastModel: root.forecastModel
        detailsModel: root.detailsModel
        noticesModel: root.noticesModel
45 46 47
    }

    PlasmaComponents.Label {
48
        readonly property string creditUrl: model.creditUrl
49

50 51
        Layout.alignment: Qt.AlignVCenter | Qt.AlignRight

52 53 54 55 56 57 58 59 60
        wrapMode: Text.WordWrap
        horizontalAlignment: Text.AlignRight
        font {
            pointSize: theme.smallestFont.pointSize
            underline: !!creditUrl
        }
        linkColor : color
        opacity: 0.6
        textFormat: Text.StyledText
61

62
        text: {
63
            var result = model.courtesy;
64 65 66 67 68 69 70 71 72 73
            if (creditUrl) {
                result = "<a href=\"" + creditUrl + "\">" + result + "</a>";
            }
            return result;
        }

        onLinkActivated: {
            Qt.openUrlExternally(link);
        }
    }
74 75 76 77 78 79 80 81 82 83 84 85 86

    // workaround for now to make applet state obvious and allow quick access to config dialog
    // follows approach by comic applet
    // TODO: remove when configurationRequired works and container cares for this
    PlasmaComponents.Button {
        anchors.centerIn: parent

        visible: root.needsConfiguration
        text: i18nc("@action:button", "Configure...")
        onClicked: {
            plasmoid.action("configure").trigger();
        }
    }
87
}