diff --git a/app/qml/Device.qml b/app/qml/Device.qml new file mode 100644 index 000000000..1b3d8e1d6 --- /dev/null +++ b/app/qml/Device.qml @@ -0,0 +1,93 @@ +/* + * Copyright 2015 Aleix Pol Gonzalez + * + * 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 . + */ + +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 +import org.kde.kirigami 1.0 as Kirigami +import org.kde.kdeconnect 1.0 + +Kirigami.Page +{ + id: deviceView + property QtObject currentDevice + title: currentDevice.name + + Loader { + anchors.fill: parent + Layout.fillHeight: true + Layout.fillWidth: true + + sourceComponent: deviceView.currentDevice.isTrusted ? trustedDevice : untrustedDevice + Component { + id: trustedDevice + ColumnLayout { + id: trustedView + Layout.fillHeight: true + Layout.fillWidth: true + + Kirigami.BasicListItem { + label: i18n("Un-Pair") + onClicked: deviceView.currentDevice.unpair() + } + Kirigami.BasicListItem { + label: i18n("Send Ping") + onClicked: deviceView.currentDevice.pluginCall("ping", "sendPing"); + } + Kirigami.BasicListItem { + label: i18n("Open Multimedia Remote Control") + onClicked: pageStack.push( + "qrc:/qml/mpris.qml", + { mprisInterface: MprisDbusInterfaceFactory.create(deviceView.currentDevice.id()) } + ); + } + Kirigami.BasicListItem { + label: i18n("Mouse Pad") + onClicked: pageStack.push( + "qrc:/qml/mousepad.qml", + { remoteControlInterface: RemoteControlDbusInterfaceFactory.create(deviceView.currentDevice.id()) } + ); + } + Kirigami.BasicListItem { + property var lockIface: LockDeviceDbusInterfaceFactory.create(deviceView.currentDevice.id()) + label: lockIface.isLocked ? i18n("Unlock") : i18n("Lock") + onClicked: { + lockIface.isLocked = !lockIface.isLocked; + } + } + + Item { Layout.fillHeight: true } + } + } + Component { + id: untrustedDevice + ColumnLayout { + id: untrustedView + Layout.fillHeight: true + Layout.fillWidth: true + + Kirigami.BasicListItem { + label: i18n("Pair") + onClicked: deviceView.currentDevice.requestPair() + } + } + } + } +} diff --git a/app/qml/DeviceDelegate.qml b/app/qml/DeviceDelegate.qml deleted file mode 100644 index 2b528ca0d..000000000 --- a/app/qml/DeviceDelegate.qml +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2015 Aleix Pol Gonzalez - * - * 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 . - */ - -import QtQuick 2.2 -import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.1 -import org.kde.kquickcontrolsaddons 2.0 -import org.kde.kdeconnect 1.0 - -Item -{ - height: info.height - signal clicked - QIconItem { - id: icon - width: 40 - height: parent.height - icon: iconName - anchors.verticalCenter: parent.verticalCenter - } - MouseArea { - anchors.fill: parent - onClicked: parent.clicked() - } - ColumnLayout { - id: info - anchors { - left: icon.right - top: parent.top - right: parent.right - } - property bool expand: false - Label { - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - text: display + "\n" + toolTip - } - } -} diff --git a/app/qml/main.qml b/app/qml/main.qml index c9050a6c4..132b08f93 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -21,36 +21,20 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 +import org.kde.kirigami 1.0 as Kirigami import org.kde.kdeconnect 1.0 -ApplicationWindow +Kirigami.ApplicationWindow { id: root visible: true width: 400 height: 500 - title: i18n("KDE Connect") - toolBar: RowLayout { - Button { - iconName: "go-previous" - enabled: stack.depth>1 - onClicked: stack.pop() - } - Label { - Layout.fillWidth: true - text: i18n("KDE Connect") - font.pointSize: 20 - } - } - StackView { - id: stack - anchors { - fill: parent - margins: 5 - } - initialItem: ScrollView { - Layout.fillHeight: true + pageStack.initialPage: Kirigami.Page { + title: i18n("KDE Connect") + ScrollView { + anchors.fill: parent ListView { id: devicesView @@ -70,86 +54,21 @@ ApplicationWindow } } - spacing: 5 model: DevicesSortProxyModel { sourceModel: DevicesModel { id: connectDeviceModel displayFilter: DevicesModel.Reachable } } - delegate: DeviceDelegate { + delegate: Kirigami.BasicListItem { width: ListView.view.width + icon: iconName + label: display + "\n" + toolTip onClicked: { - var data = { - item: deviceViewComponent, - properties: {currentDevice: device} - }; - stack.push(data); - } - } - } - } - } - - Component { - id: deviceViewComponent - Loader { - id: deviceView - property QtObject currentDevice - Layout.fillHeight: true - Layout.fillWidth: true - - sourceComponent: currentDevice.isTrusted ? trustedDevice : untrustedDevice - Component { - id: trustedDevice - ColumnLayout { - id: trustedView - Layout.fillHeight: true - Layout.fillWidth: true - - Button { - text: i18n("Un-Pair") - onClicked: deviceView.currentDevice.unpair() - } - Button { - text: i18n("Send Ping") - onClicked: deviceView.currentDevice.pluginCall("ping", "sendPing"); - } - Button { - text: i18n("Open Multimedia Remote Control") - onClicked: stack.push( { - item: "qrc:/qml/mpris.qml", - properties: { mprisInterface: MprisDbusInterfaceFactory.create(deviceView.currentDevice.id()) } - } ); - } - Button { - text: i18n("Mouse Pad") - onClicked: stack.push( { - item: "qrc:/qml/mousepad.qml", - properties: { remoteControlInterface: RemoteControlDbusInterfaceFactory.create(deviceView.currentDevice.id()) } - } ); - } - Button { - property var lockIface: LockDeviceDbusInterfaceFactory.create(deviceView.currentDevice.id()) - text: lockIface.isLocked ? i18n("Unlock") : i18n("Lock") - onClicked: { - lockIface.isLocked = !lockIface.isLocked; - } - } - - Item { Layout.fillHeight: true } - } - } - Component { - id: untrustedDevice - ColumnLayout { - id: untrustedView - Layout.fillHeight: true - Layout.fillWidth: true - - Button { - text: i18n("Pair") - onClicked: deviceView.currentDevice.requestPair() + root.pageStack.push( + "qrc:/qml/Device.qml", + {currentDevice: device} + ); } } } diff --git a/app/qml/mousepad.qml b/app/qml/mousepad.qml index 302d16dc6..a3b1f020d 100644 --- a/app/qml/mousepad.qml +++ b/app/qml/mousepad.qml @@ -21,47 +21,54 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 +import org.kde.kirigami 1.0 as Kirigami -ColumnLayout +Kirigami.Page { id: mousepad + title: i18n("Remote Control") property QtObject remoteControlInterface - MouseArea { - id: area - Layout.fillWidth: true - Layout.fillHeight: true - property var lastPos: Qt.point(-1, -1) + ColumnLayout + { + anchors.fill: parent - onClicked: mousepad.remoteControlInterface.sendCommand("singleclick", true); - - onPositionChanged: { - if (lastPos.x > -1) { -// console.log("move", mouse.x, mouse.y, lastPos) - var delta = Qt.point(mouse.x-lastPos.x, mouse.y-lastPos.y); - - remoteControlInterface.moveCursor(delta); - } - lastPos = Qt.point(mouse.x, mouse.y); - } - onReleased: { - lastPos = Qt.point(-1, -1) - } - } - RowLayout { - Layout.fillWidth: true - - Button { + MouseArea { + id: area Layout.fillWidth: true + Layout.fillHeight: true + property var lastPos: Qt.point(-1, -1) + onClicked: mousepad.remoteControlInterface.sendCommand("singleclick", true); + + onPositionChanged: { + if (lastPos.x > -1) { + // console.log("move", mouse.x, mouse.y, lastPos) + var delta = Qt.point(mouse.x-lastPos.x, mouse.y-lastPos.y); + + remoteControlInterface.moveCursor(delta); + } + lastPos = Qt.point(mouse.x, mouse.y); + } + onReleased: { + lastPos = Qt.point(-1, -1) + } } - Button { + RowLayout { Layout.fillWidth: true - onClicked: mousepad.remoteControlInterface.sendCommand("middleclick", true); - } - Button { - Layout.fillWidth: true - onClicked: mousepad.remoteControlInterface.sendCommand("rightclick", true); + + Button { + Layout.fillWidth: true + onClicked: mousepad.remoteControlInterface.sendCommand("singleclick", true); + } + Button { + Layout.fillWidth: true + onClicked: mousepad.remoteControlInterface.sendCommand("middleclick", true); + } + Button { + Layout.fillWidth: true + onClicked: mousepad.remoteControlInterface.sendCommand("rightclick", true); + } } } } diff --git a/app/qml/mpris.qml b/app/qml/mpris.qml index 0dd66f2c0..7c2f6ba68 100644 --- a/app/qml/mpris.qml +++ b/app/qml/mpris.qml @@ -21,52 +21,59 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 +import org.kde.kirigami 1.0 as Kirigami -ColumnLayout +Kirigami.Page { id: root property QtObject mprisInterface + title: i18n("Multimedia Controls") - Component.onCompleted: { - mprisInterface.requestPlayerList(); - } + ColumnLayout + { + anchors.fill: parent - Item { Layout.fillHeight: true } - ComboBox { - Layout.fillWidth: true - model: root.mprisInterface.playerList - onCurrentTextChanged: root.mprisInterface.player = currentText - } - Label { - Layout.fillWidth: true - text: root.mprisInterface.nowPlaying - } - RowLayout { - Layout.fillWidth: true - Button { - Layout.fillWidth: true - iconName: "media-skip-backward" - onClicked: root.mprisInterface.sendAction("Previous") + Component.onCompleted: { + mprisInterface.requestPlayerList(); } - Button { + + Item { Layout.fillHeight: true } + ComboBox { Layout.fillWidth: true - iconName: root.mprisInterface.isPlaying ? "media-playback-pause" : "media-playback-start" - onClicked: root.mprisInterface.sendAction("PlayPause"); + model: root.mprisInterface.playerList + onCurrentTextChanged: root.mprisInterface.player = currentText } - Button { + Label { Layout.fillWidth: true - iconName: "media-skip-forward" - onClicked: root.mprisInterface.sendAction("Next") + text: root.mprisInterface.nowPlaying } + RowLayout { + Layout.fillWidth: true + Button { + Layout.fillWidth: true + iconName: "media-skip-backward" + onClicked: root.mprisInterface.sendAction("Previous") + } + Button { + Layout.fillWidth: true + iconName: root.mprisInterface.isPlaying ? "media-playback-pause" : "media-playback-start" + onClicked: root.mprisInterface.sendAction("PlayPause"); + } + Button { + Layout.fillWidth: true + iconName: "media-skip-forward" + onClicked: root.mprisInterface.sendAction("Next") + } + } + RowLayout { + Layout.fillWidth: true + Label { text: i18n("Volume:") } + Slider { + value: root.mprisInterface.volume + maximumValue: 100 + Layout.fillWidth: true + } + } + Item { Layout.fillHeight: true } } - RowLayout { - Layout.fillWidth: true - Label { text: i18n("Volume:") } - Slider { - value: root.mprisInterface.volume - maximumValue: 100 - Layout.fillWidth: true - } - } - Item { Layout.fillHeight: true } } diff --git a/app/resources.qrc b/app/resources.qrc index 225f85136..df128d27d 100644 --- a/app/resources.qrc +++ b/app/resources.qrc @@ -1,8 +1,8 @@ qml/main.qml - qml/DeviceDelegate.qml qml/mpris.qml qml/mousepad.qml + qml/Device.qml