Commit 182da7bf authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Browse button on plasmoid only visible if sftp plugin enabled

parent c6354f19
......@@ -28,12 +28,12 @@ QtObject {
id: root
property string deviceId: ""
property variant device: DeviceDbusInterfaceFactory.create(deviceId)
property bool available: false
property bool charging: false
property int charge: -1
property string displayString: (available && charge > -1) ? ((charging) ? (i18n("Charging, %1").arg(charge)) : (i18n("Discharging, %1").arg(charge))) : i18n("No info")
property variant device: DeviceDbusInterfaceFactory.create(deviceId)
property variant battery: null
property variant nested1: DBusAsyncResponse {
......@@ -48,6 +48,7 @@ QtObject {
onSuccess: root.charge = result
}
/* Note: magically called by qml */
onAvailableChanged: {
if (available) {
battery = DeviceBatteryDbusInterfaceFactory.create(deviceId)
......
......@@ -36,21 +36,22 @@ PlasmaComponents.ListItem
Row
{
PlasmaComponents.Label {
width: parent.width - browse.width
width: browse.visible? parent.width - browse.width : parent.width
horizontalAlignment: Text.AlignHCenter
text: display
}
PlasmaComponents.Button
{
id: browse
iconSource: "document-open-folder"
Sftp {
id: sftp
deviceId: root.deviceId
}
id: browse
iconSource: "document-open-folder"
visible: sftp.available
onClicked: {
sftp.browse()
}
......@@ -63,12 +64,12 @@ PlasmaComponents.ListItem
//Battery
PlasmaComponents.ListItem {
Battery {
id: battery
deviceId: root.deviceId
}
sectionDelegate: true
visible: battery.available
PlasmaComponents.Label {
......@@ -80,7 +81,7 @@ PlasmaComponents.ListItem
anchors.right: parent.right
}
}
//Notifications
PlasmaComponents.ListItem {
visible: notificationsModel.count>0
......@@ -122,11 +123,9 @@ PlasmaComponents.ListItem
onClicked: dbusInterface.dismiss();
}
}
//FIXME
//Repeater.onItemAdded: plasmoid.status = "NeedsAttentionStatus";
}
//TODO: Other information could be displayed here
//NOTE: More information could be displayed here
}
}
......@@ -28,29 +28,24 @@ QtObject {
id: root
property string deviceId: ""
property bool isMounted: false
property variant sftp: SftpDbusInterfaceFactory.create(deviceId)
property variant device: DeviceDbusInterfaceFactory.create(deviceId)
property bool available: false
property bool isMounted: false
property variant sftp: null
property variant nested: DBusAsyncResponse {
id: startupCheck
onSuccess: (result) ? root.mounted() : root.unmounted()
onError: root.error(message)
}
signal mounted
signal unmounted
signal error(string message)
onMounted: isMounted = true
onUnmounted: isMounted = false
Component.onCompleted: {
sftp.mounted.connect(mounted)
sftp.unmounted.connect(unmounted)
startupCheck.setPendingCall(sftp.isMounted())
}
function browse() {
startupCheck.setPendingCall(sftp.startBrowsing())
}
......@@ -58,5 +53,36 @@ QtObject {
function unmount() {
sftp.unmount()
}
Component.onCompleted: {
device.pluginsChanged.connect(pluginsChanged)
device.pluginsChanged()
}
/* Note: magically called by qml */
onAvailableChanged: {
if (available) {
sftp = SftpDbusInterfaceFactory.create(deviceId)
sftp.mounted.connect(mounted)
sftp.unmounted.connect(unmounted)
startupCheck.setPendingCall(sftp.isMounted())
}
else {
sftp = null
}
}
function pluginsChanged() {
var result = DBusResponseWaiter.waitForReply(device.hasPlugin("kdeconnect_sftp"))
if (result && result != "error") {
available = true
}
else {
available = false
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment