/usr/share/kde4/apps/plasma/plasmoids/notifier/contents/ui/DeviceItem.qml is in kde-workspace-data 4:4.8.2a-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | /*
* Copyright 2011 Viranch Mehta <viranch.mehta@gmail.com>
*
* 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 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 Qt 4.7
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import org.kde.qtextracomponents 0.1
Item {
id: deviceItem
property string udi
property string icon
property alias deviceName: deviceLabel.text
property string emblemIcon
property int state
property alias leftActionIcon: leftAction.icon
property bool mounted
property bool expanded: (notifierDialog.currentExpanded==index)
property alias percentUsage: freeSpaceBar.value
signal leftActionTriggered
height: container.childrenRect.height + padding.margins.top + padding.margins.bottom
PlasmaCore.FrameSvgItem {
id: padding
imagePath: "widgets/viewitem"
prefix: "hover"
opacity: 0
anchors.fill: parent
}
MouseArea {
id: container
anchors {
fill: parent
topMargin: padding.margins.top
leftMargin: padding.margins.left
rightMargin: padding.margins.right
bottomMargin: padding.margins.bottom
}
hoverEnabled: true
onEntered: {
notifierDialog.currentIndex = index;
notifierDialog.highlightItem.opacity = 1;
}
onExited: {
notifierDialog.highlightItem.opacity = expanded ? 1 : 0;
}
onClicked: {
if (leftAction.visible
&& mouse.x>=leftAction.x && mouse.x<=leftAction.x+leftAction.width
&& mouse.y>=leftAction.y && mouse.y<=leftAction.y+leftAction.height)
{
leftActionTriggered();
}
else {
var actions = hpSource.data[udi]["actions"];
if (actions.length==1) {
service = hpSource.serviceForSource(udi);
operation = service.operationDescription("invokeAction");
operation.predicate = actions[0]["predicate"];
service.startOperationCall(operation);
} else {
notifierDialog.currentExpanded = expanded ? -1 : index;
}
}
}
// FIXME: Device item loses focus on mounting/unmounting it,
// or specifically, when some UI element changes.
QIconItem {
id: deviceIcon
width: 32
height: 32
z: 900
icon: QIcon(deviceItem.icon)
anchors {
left: parent.left
top: parent.top
}
QIconItem {
id: emblem
width: 16
height: 16
icon: deviceItem.state == 0 ? QIcon(emblemIcon) : QIcon();
anchors {
left: parent.left
bottom: parent.bottom
}
}
}
Column {
id: labelsColumn
spacing: padding.margins.top/2
z: 900
anchors {
top: parent.top
left: deviceIcon.right
right: leftAction.left
leftMargin: padding.margins.left
}
PlasmaComponents.Label {
id: deviceLabel
height: paintedHeight
}
PlasmaComponents.Label {
id: deviceStatus
height: paintedHeight
// FIXME: state changes do not reach the plasmoid if the
// device was already attached when the plasmoid was
// initialized
text: deviceItem.state ==0 ? container.idleStatus() : (deviceItem.state==1 ? i18nc("Accessing is a less technical word for Mounting; translation should be short and mean \'Currently mounting this device\'", "Accessing...") : i18nc("Removing is a less technical word for Unmounting; translation shoud be short and mean \'Currently unmounting this device\'", "Removing..."))
font.italic: true
font.pointSize: theme.smallestFont.pointSize
color: "#99"+(theme.textColor.toString().substr(1))
opacity: container.containsMouse || expanded ? 1 : 0;
Behavior on opacity { NumberAnimation { duration: 150 } }
}
PlasmaComponents.ProgressBar {
id: freeSpaceBar
height: deviceStatus.height
anchors {
left: parent.left
right: parent.right
}
opacity: mounted ? deviceStatus.opacity : 0
minimumValue: 0
maximumValue: 100
orientation: Qt.Horizontal
}
}
function idleStatus() {
var actions = hpSource.data[udi]["actions"];
if (actions.length > 1) {
return i18n("%1 actions for this device", actions.length);
} else {
return actions[0]["text"];
}
}
PlasmaCore.ToolTip {
target: freeSpaceBar
subText: i18nc("@info:status Free disk space", "%1 free", model["Free Space Text"])
}
QIconItem {
id: leftAction
width: 22
height: 22
z: 900
anchors {
right: parent.right
verticalCenter: deviceIcon.verticalCenter
}
visible: !busySpinner.visible
}
PlasmaCore.ToolTip {
target: leftAction
subText: {
if (!model["Accessible"]) {
return i18n("Click to mount this device.")
} else if (model["Device Types"].indexOf("Optical Disk") != -1) {
return i18n("Click to eject this disc.")
} else if (model["Removable"]) {
return i18n("Click to safely remove this device.")
} else {
return i18n("Click to access this device from other applications.")
}
}
}
PlasmaCore.ToolTip {
target: deviceIcon
subText: {
if (model["Accessible"] || deviceItem.state != 0) {
if (model["Removable"]) {
return i18n("It is currently <b>not safe</b> to remove this device: applications may be accessing it. Click the eject button to safely remove this device.")
} else {
return i18n("This device is currently accessible.")
}
} else {
if (model["Removable"]) {
if (model["In Use"]) {
return i18n("It is currently <b>not safe</b> to remove this device: applications may be accessing other volumes on this device. Click the eject button on these other volumes to safely remove this device.");
} else {
return i18n("It is currently safe to remove this device.")
}
} else {
return i18n("This device is not currently accessible.")
}
}
}
}
PlasmaComponents.BusyIndicator {
id: busySpinner
width: 22
height: 22
anchors {
right: parent.right
verticalCenter: deviceIcon.verticalCenter
}
running: visible
visible: deviceItem.state != 0
}
ListView {
id: actionsList
anchors {
top: labelsColumn.bottom
left: deviceIcon.right
right: leftAction.right
}
interactive: false
model: hpSource.data[udi]["actions"]
property int actionVerticalMargins: 5
property int actionIconHeight: 30
height: expanded ? ((actionIconHeight+(2*actionVerticalMargins))*model.length)+anchors.topMargin : 0
opacity: expanded ? 1 : 0
delegate: actionItem
highlight: actionHighlighter
Behavior on opacity { NumberAnimation { duration: 150 } }
}
Component {
id: actionItem
ActionItem {
icon: modelData["icon"]
label: modelData["text"]
predicate: modelData["predicate"]
}
}
Component {
id: actionHighlighter
PlasmaCore.FrameSvgItem {
width: actionsList.width
imagePath: "widgets/viewitem"
prefix: "hover"
opacity: 0
Behavior on opacity {
NumberAnimation {
duration: 250
easing.type: Easing.OutQuad
}
}
}
}
}
function makeCurrent()
{
notifierDialog.currentIndex = index;
notifierDialog.highlightItem.opacity=1;
}
}
|