Commit 9b3382d2 authored by Samoilenko Yuri's avatar Samoilenko Yuri
Browse files

Sftp qml module polished

parent a7254709
......@@ -65,7 +65,7 @@ SftpPlugin::~SftpPlugin()
{
QDBusConnection::sessionBus().unregisterObject(dbusPath(), QDBusConnection::UnregisterTree);
removeFromDolphin();
umount();
unmount();
kDebug(kdeconnect_kded()) << "Destroyed device:" << device()->name();
}
......@@ -113,7 +113,7 @@ void SftpPlugin::mount()
connect(m_d->mounter, SIGNAL(failed(QString)), this, SLOT(onFailed(QString)));
}
void SftpPlugin::umount()
void SftpPlugin::unmount()
{
kDebug(kdeconnect_kded()) << "Device:" << device()->name();
delete m_d->mounter.data();
......
......@@ -54,7 +54,7 @@ public Q_SLOTS:
virtual void connected();
Q_SCRIPTABLE void mount();
Q_SCRIPTABLE void umount();
Q_SCRIPTABLE void unmount();
Q_SCRIPTABLE bool mountAndWait();
Q_SCRIPTABLE bool isMounted();
......
......@@ -41,11 +41,49 @@ PlasmaComponents.ListItem
text: display
}
BrowseButton {
PlasmaComponents.Button
{
id: browse
deviceId: root.deviceId
checkable: true
state: "UNMOUNTED"
states: [
State {
name: "UNMOUNTED"
PropertyChanges { target: browse; checked: false; text: "Browse" }
},
State {
name: "MOUNTING"
PropertyChanges { target: browse; checked: true; text: "Mounting..." }
},
State {
name: "MOUNTED"
PropertyChanges { target: browse; checked: false; text: "Unmount" }
}
]
Sftp {
id: sftp
deviceId: root.deviceId
onMounted: browse.state = "MOUNTED"
onUnmounted: browse.state = "UNMOUNTED"
onError: browse.state = "UNMOUNTED"
}
onClicked: {
if (state == "UNMOUNTED") {
state = "MOUNTING"
sftp.browse()
}
else if (state == "MOUNTED") {
sftp.unmount()
state = "UNMOUNTED"
}
}
}
height: browse.height
width: parent.width
}
......
......@@ -23,72 +23,40 @@ import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import org.kde.kdeconnect 1.0
PlasmaComponents.Button
{
id: button
checkable: true
QtObject {
id: root
property string deviceId: ""
property bool isMounted: false
property variant sftp: SftpDbusInterfaceFactory.create(deviceId)
state: "UNMOUNTED"
states: [
State {
name: "UNMOUNTED"
PropertyChanges { target: button; checked: false; text: "Browse" }
},
State {
name: "MOUNTING"
PropertyChanges { target: button; checked: true; text: "Mounting..." }
},
State {
name: "MOUNTED"
PropertyChanges { target: button; checked: false; text: "Unmount" }
}
]
onClicked: {
if (state == "UNMOUNTED") {
state = "MOUNTING"
sftp.startBrowsing()
}
else if (state == "MOUNTED") {
sftp.umount()
state = "UNMOUNTED"
}
}
DBusAsyncResponse {
property variant nested: DBusAsyncResponse {
id: startupCheck
onSuccess: {
console.log("222SUCC:" + result)
if (result) {
button.state = "MOUNTED"
}
else {
button.state = "UNMOUNTED"
}
}
onError: {
console.log("Error:" + message)
state = "UNMOUNTED"
}
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: {
console.log("onCompleted device:" + deviceId)
sftp.mounted.connect(function() {
browse.state = "MOUNTED"
})
sftp.unmounted.connect(function() {
browse.state = "UNMOUNTED"
})
sftp.mounted.connect(mounted)
sftp.unmounted.connect(unmounted)
startupCheck.pendingCall = sftp.isMounted()
}
function browse() {
sftp.startBrowsing()
}
function unmount() {
sftp.unmount()
}
}
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