Sftp qml module polished
This commit is contained in:
parent
a72547096f
commit
9b3382d2b8
5 changed files with 106 additions and 100 deletions
|
@ -65,7 +65,7 @@ SftpPlugin::~SftpPlugin()
|
||||||
{
|
{
|
||||||
QDBusConnection::sessionBus().unregisterObject(dbusPath(), QDBusConnection::UnregisterTree);
|
QDBusConnection::sessionBus().unregisterObject(dbusPath(), QDBusConnection::UnregisterTree);
|
||||||
removeFromDolphin();
|
removeFromDolphin();
|
||||||
umount();
|
unmount();
|
||||||
kDebug(kdeconnect_kded()) << "Destroyed device:" << device()->name();
|
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)));
|
connect(m_d->mounter, SIGNAL(failed(QString)), this, SLOT(onFailed(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SftpPlugin::umount()
|
void SftpPlugin::unmount()
|
||||||
{
|
{
|
||||||
kDebug(kdeconnect_kded()) << "Device:" << device()->name();
|
kDebug(kdeconnect_kded()) << "Device:" << device()->name();
|
||||||
delete m_d->mounter.data();
|
delete m_d->mounter.data();
|
||||||
|
|
|
@ -54,7 +54,7 @@ public Q_SLOTS:
|
||||||
virtual void connected();
|
virtual void connected();
|
||||||
|
|
||||||
Q_SCRIPTABLE void mount();
|
Q_SCRIPTABLE void mount();
|
||||||
Q_SCRIPTABLE void umount();
|
Q_SCRIPTABLE void unmount();
|
||||||
Q_SCRIPTABLE bool mountAndWait();
|
Q_SCRIPTABLE bool mountAndWait();
|
||||||
Q_SCRIPTABLE bool isMounted();
|
Q_SCRIPTABLE bool isMounted();
|
||||||
|
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright 2014 Samoilenko Yuri <kinnalru@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License or (at your option) version 3 or any later version
|
|
||||||
* accepted by the membership of KDE e.V. (or its successor approved
|
|
||||||
* by the membership of KDE e.V.), which shall act as a proxy
|
|
||||||
* defined in Section 14 of version 3 of the license.
|
|
||||||
*
|
|
||||||
* 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 General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 1.1
|
|
||||||
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
|
|
||||||
property string deviceId: ""
|
|
||||||
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 {
|
|
||||||
id: startupCheck
|
|
||||||
onSuccess: {
|
|
||||||
console.log("222SUCC:" + result)
|
|
||||||
if (result) {
|
|
||||||
button.state = "MOUNTED"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
button.state = "UNMOUNTED"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onError: {
|
|
||||||
console.log("Error:" + message)
|
|
||||||
state = "UNMOUNTED"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
|
|
||||||
console.log("onCompleted device:" + deviceId)
|
|
||||||
|
|
||||||
sftp.mounted.connect(function() {
|
|
||||||
browse.state = "MOUNTED"
|
|
||||||
})
|
|
||||||
|
|
||||||
sftp.unmounted.connect(function() {
|
|
||||||
browse.state = "UNMOUNTED"
|
|
||||||
})
|
|
||||||
|
|
||||||
startupCheck.pendingCall = sftp.isMounted()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -41,10 +41,48 @@ PlasmaComponents.ListItem
|
||||||
text: display
|
text: display
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowseButton {
|
PlasmaComponents.Button
|
||||||
|
{
|
||||||
id: browse
|
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
|
height: browse.height
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
62
plasmoid/package/contents/ui/Sftp.qml
Normal file
62
plasmoid/package/contents/ui/Sftp.qml
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/**
|
||||||
|
* Copyright 2014 Samoilenko Yuri <kinnalru@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of
|
||||||
|
* the License or (at your option) version 3 or any later version
|
||||||
|
* accepted by the membership of KDE e.V. (or its successor approved
|
||||||
|
* by the membership of KDE e.V.), which shall act as a proxy
|
||||||
|
* defined in Section 14 of version 3 of the license.
|
||||||
|
*
|
||||||
|
* 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 General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 1.1
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||||
|
import org.kde.kdeconnect 1.0
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property string deviceId: ""
|
||||||
|
property bool isMounted: false
|
||||||
|
property variant sftp: SftpDbusInterfaceFactory.create(deviceId)
|
||||||
|
|
||||||
|
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.pendingCall = sftp.isMounted()
|
||||||
|
}
|
||||||
|
|
||||||
|
function browse() {
|
||||||
|
sftp.startBrowsing()
|
||||||
|
}
|
||||||
|
|
||||||
|
function unmount() {
|
||||||
|
sftp.unmount()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue