UrlWindow.qml 2.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
    Copyright 2011-2012 Heikki Holstila <heikki.holstila@gmail.com>

    This file is part of FingerTerm.

    FingerTerm 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.

    FingerTerm 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 FingerTerm.  If not, see <http://www.gnu.org/licenses/>.
*/

John Brooks's avatar
John Brooks committed
20
import QtQuick 2.0
21

22
PopupWindow {
23 24
    id: urlWindow

25
    property var urls: [""]
26 27 28 29 30 31

    Component {
        id: listDelegate
        Rectangle {
            color: "#909090"
            width: parent.width
32
            height: openButton.height+(4*window.pixelRatio)
33 34
            border.width: 1
            border.color: "#ffffff"
35
            radius: window.radiusSmall
36 37 38 39 40 41
            clip: true

            Text {
                text: modelData
                color: "#ffffff"
                anchors.verticalCenter: parent.verticalCenter
42
                x: 8*window.pixelRatio
43
                width: openButton.x - x
44
                font.pointSize: window.uiFontSize
45 46 47 48 49 50 51
                elide: Text.ElideRight
            }
            Button {
                id: openButton
                text: "Open"
                anchors.right: copyButton.left
                anchors.verticalCenter: parent.verticalCenter
52 53
                anchors.rightMargin: window.paddingSmall
                width: 70*window.pixelRatio
54 55 56 57 58 59 60 61 62
                onClicked: {
                    Qt.openUrlExternally(modelData);
                }
            }
            Button {
                id: copyButton
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                text: "Copy"
63 64
                width: 70*window.pixelRatio
                anchors.rightMargin: window.paddingSmall
65 66 67 68 69 70 71 72 73 74 75 76
                onClicked: {
                    util.copyTextToClipboard(modelData);
                }
            }
        }
    }

    Text {
        visible: urlWindow.urls.length == 0
        anchors.centerIn: parent
        color: "#ffffff"
        text: "No URLs"
77
        font.pointSize: window.uiFontSize + 4*window.pixelRatio
78 79 80 81 82 83
    }

    ListView {
        anchors.fill: parent
        delegate: listDelegate
        model: urlWindow.urls
84 85
        spacing: window.paddingSmall
        anchors.margins: window.paddingSmall
86 87 88 89 90 91
        clip: true
    }

    Button {
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.bottom: parent.bottom
92
        anchors.bottomMargin: window.paddingMedium
93
        text: "Back"
Pekka Vuorela's avatar
Pekka Vuorela committed
94
        onClicked: urlWindow.show = false
95 96
    }
}