Warning, /network/kdeconnect-kde/plasmoid/package/contents/ui/DeviceDelegate.qml is written in an unsupported language. File is not indexed.
0001 /** 0002 * SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Layouts 0009 import org.kde.plasma.core as PlasmaCore 0010 import org.kde.plasma.components as PlasmaComponents 0011 import org.kde.kdeconnect 0012 import QtQuick.Controls 0013 import org.kde.kirigami as Kirigami 0014 import org.kde.plasma.extras as PlasmaExtras 0015 import QtQuick.Dialogs 0016 import QtCore 0017 0018 PlasmaComponents.ItemDelegate 0019 { 0020 id: root 0021 readonly property QtObject device: DeviceDbusInterfaceFactory.create(model.deviceId) 0022 0023 hoverEnabled: false 0024 down: false 0025 0026 DropArea { 0027 id: fileDropArea 0028 anchors.fill: parent 0029 0030 onDropped: { 0031 if (drop.hasUrls) { 0032 0033 var urls = []; 0034 0035 for (var v in drop.urls) { 0036 if (drop.urls[v] != null) { 0037 if (urls.indexOf(drop.urls[v].toString()) == -1) { 0038 urls.push(drop.urls[v].toString()); 0039 } 0040 } 0041 } 0042 0043 var i; 0044 for (i = 0; i < urls.length; i++) { 0045 share.plugin.shareUrl(urls[i]); 0046 } 0047 } 0048 drop.accepted = true; 0049 } 0050 0051 PlasmaCore.ToolTipArea { 0052 id: dropAreaToolTip 0053 anchors.fill: parent 0054 location: plasmoid.location 0055 active: true 0056 mainText: i18n("File Transfer") 0057 subText: i18n("Drop a file to transfer it onto your phone.") 0058 } 0059 } 0060 0061 contentItem: ColumnLayout { 0062 spacing: Kirigami.Units.smallSpacing 0063 0064 RowLayout 0065 { 0066 width: parent.width 0067 spacing: Kirigami.Units.smallSpacing 0068 0069 Battery { 0070 id: battery 0071 device: root.device 0072 } 0073 0074 Connectivity { 0075 id: connectivity 0076 device: root.device 0077 } 0078 0079 PlasmaComponents.Label { 0080 id: deviceName 0081 elide: Text.ElideRight 0082 text: model.name 0083 Layout.fillWidth: true 0084 textFormat: Text.PlainText 0085 } 0086 0087 PlasmaComponents.ToolButton { 0088 VirtualMonitor { 0089 id: vd 0090 device: root.device 0091 } 0092 icon.name: "video-monitor" 0093 text: i18n("Virtual Display") 0094 visible: vd.available 0095 onClicked: { 0096 if (!vd.plugin.requestVirtualMonitor()) { 0097 console.warn("Failed to create the virtual monitor") 0098 } 0099 } 0100 } 0101 RowLayout 0102 { 0103 id: connectionInformation 0104 visible: connectivity.available 0105 spacing: Kirigami.Units.smallSpacing 0106 0107 // TODO: In the future, when the Connectivity Report plugin supports more than one 0108 // subscription, add more signal strength icons to represent all the available 0109 // connections. 0110 0111 Kirigami.Icon { 0112 id: celluarConnectionStrengthIcon 0113 source: connectivity.iconName 0114 Layout.preferredHeight: connectivityText.height 0115 Layout.preferredWidth: Layout.preferredHeight 0116 Layout.alignment: Qt.AlignCenter 0117 visible: valid 0118 } 0119 0120 PlasmaComponents.Label { 0121 // Fallback plain-text label. Only show this if the icon doesn't work. 0122 id: connectivityText 0123 text: connectivity.displayString 0124 textFormat: Text.PlainText 0125 visible: !celluarConnectionStrengthIcon.visible 0126 } 0127 } 0128 0129 RowLayout 0130 { 0131 id: batteryInformation 0132 visible: (battery.available && battery.charge > -1) 0133 spacing: Kirigami.Units.smallSpacing 0134 0135 Kirigami.Icon { 0136 id: batteryIcon 0137 source: battery.iconName 0138 // Make the icon the same size as the text so that it doesn't dominate 0139 Layout.preferredHeight: batteryPercent.height 0140 Layout.preferredWidth: Layout.preferredHeight 0141 Layout.alignment: Qt.AlignCenter 0142 } 0143 0144 PlasmaComponents.Label { 0145 id: batteryPercent 0146 text: i18nc("Battery charge percentage", "%1%", battery.charge) 0147 textFormat: Text.PlainText 0148 } 0149 } 0150 0151 PlasmaComponents.ToolButton { 0152 id: overflowMenu 0153 icon.name: "application-menu" 0154 checked: menu.status === PlasmaExtras.Menu.Open 0155 0156 onPressed: menu.openRelative() 0157 0158 PlasmaExtras.Menu { 0159 id: menu 0160 visualParent: overflowMenu 0161 placement: PlasmaExtras.Menu.BottomPosedLeftAlignedPopup 0162 0163 //Share 0164 PlasmaExtras.MenuItem 0165 { 0166 property FileDialog data: FileDialog { 0167 id: fileDialog 0168 title: i18n("Please choose a file") 0169 currentFolder: StandardPaths.writableLocation(StandardPaths.HomeLocation) 0170 fileMode: FileDialog.OpenFiles 0171 onAccepted: fileDialog.selectedFiles.forEach(url => share.plugin.shareUrl(url)) 0172 } 0173 0174 id: shareFile 0175 icon: "document-share" 0176 visible: share.available 0177 text: i18n("Share file") 0178 onClicked: fileDialog.open() 0179 } 0180 0181 //Clipboard 0182 PlasmaExtras.MenuItem 0183 { 0184 property Clipboard data: Clipboard { 0185 id: clipboard 0186 device: root.device 0187 } 0188 0189 id: sendclipboard 0190 icon: "klipper" 0191 visible: clipboard.available && clipboard.clipboard.isAutoShareDisabled 0192 text: i18n("Send Clipboard") 0193 0194 onClicked: { 0195 clipboard.sendClipboard() 0196 } 0197 } 0198 0199 0200 //Find my phone 0201 PlasmaExtras.MenuItem 0202 { 0203 property FindMyPhone data: FindMyPhone { 0204 id: findmyphone 0205 device: root.device 0206 } 0207 0208 id: ring 0209 icon: "irc-voice" 0210 visible: findmyphone.available 0211 text: i18n("Ring my phone") 0212 0213 onClicked: { 0214 findmyphone.ring() 0215 } 0216 } 0217 0218 //SFTP 0219 PlasmaExtras.MenuItem 0220 { 0221 property Sftp data: Sftp { 0222 id: sftp 0223 device: root.device 0224 } 0225 0226 id: browse 0227 icon: "document-open-folder" 0228 visible: sftp.available 0229 text: i18n("Browse this device") 0230 0231 onClicked: { 0232 sftp.browse() 0233 } 0234 } 0235 0236 //SMS 0237 PlasmaExtras.MenuItem 0238 { 0239 property SMS data: SMS { 0240 id: sms 0241 device: root.device 0242 } 0243 0244 icon: "message-new" 0245 visible: sms.available 0246 text: i18n("SMS Messages") 0247 0248 onClicked: { 0249 sms.plugin.launchApp() 0250 } 0251 } 0252 } 0253 } 0254 } 0255 0256 //RemoteKeyboard 0257 PlasmaComponents.ItemDelegate { 0258 visible: remoteKeyboard.remoteState 0259 Layout.fillWidth: true 0260 0261 contentItem: RowLayout { 0262 width: parent.width 0263 spacing: 5 0264 0265 PlasmaComponents.Label { 0266 id: remoteKeyboardLabel 0267 text: i18n("Remote Keyboard") 0268 } 0269 0270 RemoteKeyboard { 0271 id: remoteKeyboard 0272 device: root.device 0273 Layout.fillWidth: true 0274 } 0275 } 0276 } 0277 0278 //Notifications 0279 PlasmaComponents.ItemDelegate { 0280 visible: notificationsModel.count>0 0281 enabled: true 0282 Layout.fillWidth: true 0283 0284 contentItem: RowLayout { 0285 spacing: Kirigami.Units.smallSpacing 0286 0287 PlasmaComponents.Label { 0288 text: i18n("Notifications:") 0289 } 0290 0291 PlasmaComponents.ToolButton { 0292 enabled: true 0293 visible: notificationsModel.isAnyDimissable; 0294 Layout.alignment: Qt.AlignRight 0295 icon.name: "edit-clear-history" 0296 ToolTip.text: i18n("Dismiss all notifications") 0297 onClicked: notificationsModel.dismissAll(); 0298 } 0299 } 0300 } 0301 Repeater { 0302 id: notificationsView 0303 model: NotificationsModel { 0304 id: notificationsModel 0305 deviceId: root.device.id() 0306 } 0307 delegate: PlasmaComponents.ItemDelegate { 0308 id: listitem 0309 enabled: true 0310 onClicked: checked = !checked 0311 Layout.fillWidth: true 0312 0313 property bool replying: false 0314 0315 contentItem: ColumnLayout { 0316 spacing: Kirigami.Units.smallSpacing 0317 0318 RowLayout { 0319 spacing: Kirigami.Units.smallSpacing 0320 0321 Kirigami.Icon { 0322 id: notificationIcon 0323 source: appIcon 0324 width: (valid && appIcon.length) ? dismissButton.width : 0 0325 height: width 0326 Layout.alignment: Qt.AlignLeft 0327 } 0328 0329 PlasmaComponents.Label { 0330 id: notificationLabel 0331 text: appName + ": " + (title.length>0 ? (appName==title?notitext:title+": "+notitext) : model.name) 0332 elide: listitem.checked ? Text.ElideNone : Text.ElideRight 0333 maximumLineCount: listitem.checked ? 0 : 1 0334 wrapMode: Text.WordWrap 0335 Layout.fillWidth: true 0336 } 0337 0338 PlasmaComponents.ToolButton { 0339 id: replyButton 0340 visible: repliable 0341 enabled: repliable && !replying 0342 icon.name: "mail-reply-sender" 0343 ToolTip.text: i18n("Reply") 0344 onClicked: { replying = true; replyTextField.forceActiveFocus(); } 0345 } 0346 0347 PlasmaComponents.ToolButton { 0348 id: dismissButton 0349 visible: notificationsModel.isAnyDimissable; 0350 enabled: dismissable 0351 Layout.alignment: Qt.AlignRight 0352 icon.name: "window-close" 0353 ToolTip.text: i18n("Dismiss") 0354 onClicked: dbusInterface.dismiss(); 0355 } 0356 } 0357 0358 RowLayout { 0359 visible: replying 0360 width: notificationLabel.width + replyButton.width + dismissButton.width + Kirigami.Units.smallSpacing * 2 0361 spacing: Kirigami.Units.smallSpacing 0362 0363 PlasmaComponents.Button { 0364 Layout.alignment: Qt.AlignBottom 0365 id: replyCancelButton 0366 text: i18n("Cancel") 0367 display: PlasmaComponents.AbstractButton.IconOnly 0368 PlasmaComponents.ToolTip { 0369 text: parent.text 0370 } 0371 icon.name: "dialog-cancel" 0372 onClicked: { 0373 replyTextField.text = ""; 0374 replying = false; 0375 } 0376 } 0377 0378 PlasmaComponents.TextArea { 0379 id: replyTextField 0380 placeholderText: i18nc("@info:placeholder", "Reply to %1…", appName) 0381 wrapMode: TextEdit.Wrap 0382 Layout.fillWidth: true 0383 Keys.onPressed: { 0384 if ((event.key == Qt.Key_Return || event.key == Qt.Key_Enter) && !(event.modifiers & Qt.ShiftModifier)) { 0385 replySendButton.clicked(); 0386 event.accepted = true; 0387 } 0388 if (event.key == Qt.Key_Escape) { 0389 replyCancelButton.clicked(); 0390 event.accepted = true; 0391 } 0392 } 0393 } 0394 0395 PlasmaComponents.Button { 0396 Layout.alignment: Qt.AlignBottom 0397 id: replySendButton 0398 text: i18n("Send") 0399 icon.name: "document-send" 0400 enabled: replyTextField.text 0401 onClicked: { 0402 dbusInterface.sendReply(replyTextField.text); 0403 replyTextField.text = ""; 0404 replying = false; 0405 } 0406 } 0407 } 0408 } 0409 } 0410 } 0411 0412 RemoteCommands { 0413 id: rc 0414 device: root.device 0415 } 0416 0417 // Commands 0418 RowLayout { 0419 visible: rc.available 0420 width: parent.width 0421 spacing: Kirigami.Units.smallSpacing 0422 0423 PlasmaComponents.Label { 0424 text: i18n("Run command") 0425 Layout.fillWidth: true 0426 } 0427 0428 PlasmaComponents.Button 0429 { 0430 id: addCommandButton 0431 icon.name: "list-add" 0432 ToolTip.text: i18n("Add command") 0433 onClicked: rc.plugin.editCommands() 0434 visible: rc.plugin && rc.plugin.canAddCommand 0435 } 0436 } 0437 Repeater { 0438 id: commandsView 0439 visible: rc.available 0440 model: RemoteCommandsModel { 0441 id: commandsModel 0442 deviceId: rc.device.id() 0443 } 0444 delegate: PlasmaComponents.ItemDelegate { 0445 enabled: true 0446 onClicked: rc.plugin.triggerCommand(key) 0447 Layout.fillWidth: true 0448 0449 contentItem: PlasmaComponents.Label { 0450 text: name + "\n" + command 0451 } 0452 } 0453 } 0454 0455 // Share 0456 Share { 0457 id: share 0458 device: root.device 0459 } 0460 } 0461 }