..
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145 | /*
* Copyright 2011 Marco Martin <[email protected]>
* Copyright 2014 Kai Uwe Broulik <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kcoreaddons 1.0 as KCoreAddons
import org.kde.kquickcontrolsaddons 2.0
// Unfortunately ColumnLayout was a pain to use, so it's a Column with Rows inside
Column {
id: detailsItem
spacing: jobItem.layoutSpacing
readonly property int eta: jobItem.getData(jobsSource.data, "eta", 0)
readonly property string speed: jobItem.getData(jobsSource.data, "speed", '')
property int leftColumnWidth
function localizeProcessedAmount(id) {
if (!jobsSource.data[modelData]) {
return ""
}
var unit = jobsSource.data[modelData]["processedUnit" + id]
var processed = jobsSource.data[modelData]["processedAmount" + id]
var total = jobsSource.data[modelData]["totalAmount" + id]
//if bytes localise the unit
if (unit === "bytes") {
return i18nc("How much many bytes (or whether unit in the locale has been copied over total", "%1 of %2",
KCoreAddons.Format.formatByteSize(processed),
KCoreAddons.Format.formatByteSize(total))
//else print something only if is interesting data (ie more than one file/directory etc to copy
} else if (total > 1) {
// HACK Actually the owner of the job is responsible for sending the unit in a user-displayable
// way but this has been broken for years and every other unit (other than files and dirs) is correct
if (unit === "files") {
return i18ncp("Either just 1 file or m of n files are being processed", "1 file", "%2 of %1 files", total, processed)
} else if (unit === "dirs") {
return i18ncp("Either just 1 dir or m of n dirs are being processed", "1 dir", "%2 of %1 dirs", total, processed)
}
return i18n("%1 of %2 %3", processed, total, unit)
} else {
return ""
}
}
// The 2 main labels (eg. Source and Destination)
Repeater {
model: 2
RowLayout {
width: parent.width
spacing: jobItem.layoutSpacing
visible: labelNameText.text !== "" || labelText.text !== ""
PlasmaComponents.Label {
id: labelNameText
Layout.minimumWidth: leftColumnWidth
Layout.maximumWidth: leftColumnWidth
height: paintedHeight
onPaintedWidthChanged: {
if (paintedWidth > leftColumnWidth) {
leftColumnWidth = paintedWidth
}
}
font: theme.smallestFont
text: jobItem["labelName" + index] ? i18nc("placeholder is row description, such as Source or Destination", "%1:", jobItem["labelName" + index]) : ""
horizontalAlignment: Text.AlignRight
}
PlasmaComponents.Label {
id: labelText
Layout.fillWidth: true
height: paintedHeight
font: theme.smallestFont
text: jobItem["label" + index] ? jobItem["label" + index] : ""
elide: Text.ElideMiddle
PlasmaCore.ToolTipArea {
anchors.fill: parent
subText: labelText.truncated ? jobItem["label" + index] : ""
}
}
}
}
// The three details rows (eg. how many files and folders have been copied and the total amount etc)
Repeater {
model: 3
PlasmaComponents.Label {
id: detailsLabel
anchors {
left: parent.left
leftMargin: leftColumnWidth + jobItem.layoutSpacing
right: parent.right
}
height: paintedHeight
text: localizeProcessedAmount(index)
font: theme.smallestFont
visible: text !== ""
}
}
PlasmaComponents.Label {
id: speedLabel
anchors {
left: parent.left
leftMargin: leftColumnWidth + jobItem.layoutSpacing
right: parent.right
}
height: paintedHeight
font: theme.smallestFont
text: eta > 0 ? i18nc("Speed and estimated time to completion", "%1 (%2 remaining)", speed, KCoreAddons.Format.formatSpelloutDuration(eta)) : speed
visible: eta > 0 || parseInt(speed) > 0
}
}
|
|