~ps-jenkins/ubuntu-ui-extras/trusty-proposed

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/Extras/Browser/TabsList.qml

  • Committer: Ugo Riboni
  • Date: 2013-07-02 19:40:38 UTC
  • Revision ID: ugo.riboni@canonical.com-20130702194038-v9l2q3v2xxjjxn8v
Remove all browser work and leave only an example component and skeleton build system

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2013 Canonical Ltd.
3
 
 *
4
 
 * This file is part of webbrowser-app.
5
 
 *
6
 
 * webbrowser-app is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; version 3.
9
 
 *
10
 
 * webbrowser-app is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
 */
18
 
 
19
 
import QtQuick 2.0
20
 
import Ubuntu.Components 0.1
21
 
import Ubuntu.Components.ListItems 0.1 as ListItem
22
 
 
23
 
Rectangle {
24
 
    color: "#AEA79F"
25
 
 
26
 
    property alias model: listview.model
27
 
 
28
 
    signal newTabClicked()
29
 
    signal switchToTabClicked(int index)
30
 
    signal tabRemoved(int index)
31
 
 
32
 
    Label {
33
 
        id: heading
34
 
        anchors {
35
 
            top: parent.top
36
 
            left: parent.left
37
 
            right: parent.right
38
 
            margins: units.gu(1)
39
 
        }
40
 
        height: units.gu(2)
41
 
        font.bold: true
42
 
        // TRANSLATORS: %1 refers to the number of open tabs
43
 
        text: i18n.tr("Open pages %1").arg(listview.count)
44
 
    }
45
 
 
46
 
    Item {
47
 
        anchors {
48
 
            top: heading.bottom
49
 
            bottom: parent.bottom
50
 
            left: parent.left
51
 
            right: parent.right
52
 
            margins: units.gu(1)
53
 
        }
54
 
 
55
 
        PageDelegate {
56
 
            id: newTabDelegate
57
 
            objectName: "newTabDelegate"
58
 
            anchors {
59
 
                left: parent.left
60
 
                top: parent.top
61
 
                bottom: parent.bottom
62
 
            }
63
 
            width: units.gu(10)
64
 
            color: "white"
65
 
            Label {
66
 
                anchors.centerIn: parent
67
 
                fontSize: "x-large"
68
 
                text: i18n.tr("+")
69
 
            }
70
 
            MouseArea {
71
 
                anchors.fill: parent
72
 
                onClicked: newTabClicked()
73
 
            }
74
 
        }
75
 
 
76
 
        ListView {
77
 
            id: listview
78
 
 
79
 
            anchors {
80
 
                left: newTabDelegate.right
81
 
                leftMargin: units.gu(1)
82
 
                right: parent.right
83
 
                top: parent.top
84
 
                bottom: parent.bottom
85
 
            }
86
 
 
87
 
            orientation: ListView.Horizontal
88
 
            spacing: units.gu(1)
89
 
            clip: true
90
 
 
91
 
            currentIndex: model.currentIndex
92
 
 
93
 
            delegate: ListItem.Empty {
94
 
                width: units.gu(10)
95
 
                height: parent.height
96
 
                showDivider: false
97
 
 
98
 
                // FIXME: http://pad.lv/1187476 makes it impossible to swipe a
99
 
                // delegate up/down to remove it from an horizontal listview.
100
 
                removable: true
101
 
                onItemRemoved: tabRemoved(index)
102
 
 
103
 
                PageDelegate {
104
 
                    anchors.fill: parent
105
 
                    color: (index == listview.currentIndex) ? "#2C001E" : "white"
106
 
                    title: model.title
107
 
                }
108
 
 
109
 
                onClicked: switchToTabClicked(index)
110
 
            }
111
 
        }
112
 
    }
113
 
}