blob: 3d277b6914fea0ed1eb2e29b6a6c48b625e7f550 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*
* Copyright (C) 2008-2014 The Communi Project
*
* This example is free, and not covered by the BSD license. There is no
* restriction applied to their modification, redistribution, using and so on.
* You can study them, modify them, use them in your own program - either
* completely or partially.
*/
import QtQuick 2.1
import QtQuick.Controls 1.0
import Communi 3.0
Rectangle {
id: background
property alias bufferModel: listView.model
property IrcBuffer currentBuffer
signal closed(IrcBuffer buffer)
color: "#edf3fe"
Rectangle {
id: frame
anchors.fill: parent
anchors.topMargin: -1
color: "transparent"
border.color: "#aaa"
}
Menu {
id: menu
MenuItem {
text: qsTr("Close")
shortcut: qsTr("Ctrl+W")
enabled: !!currentBuffer
onTriggered: closed(currentBuffer)
}
}
ScrollView {
id: scrollView
anchors.fill: parent
anchors.topMargin: -1
ListView {
id: listView
delegate: Rectangle {
property bool first: index === 0
property bool current: model.buffer === currentBuffer
anchors.left: parent ? parent.left : undefined
anchors.right: parent ? parent.right : undefined
anchors.margins: 1
height: Math.max(21, label.implicitHeight + 5)
color: first ? "#ddd" : current ? "#b5d5ff" : "transparent"
Rectangle {
visible: first
width: parent.width
height: 1
anchors.bottom: parent.bottom
anchors.fill: parent
anchors.leftMargin: -1
anchors.rightMargin: -1
color: "transparent"
border.color: "#aaa"
}
Label {
id: label
text: model.title
font.bold: first
anchors.margins: 2
anchors.leftMargin: 6
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressed: {
currentBuffer = model.buffer
if (mouse.button === Qt.RightButton)
menu.popup()
}
}
}
}
}
}
|