Port the experimental application to kirigami

This commit is contained in:
Aleix Pol 2016-06-05 22:42:19 +02:00
parent cc3f16ef34
commit d6eb2d07bc
6 changed files with 188 additions and 218 deletions

93
app/qml/Device.qml Normal file
View file

@ -0,0 +1,93 @@
/*
* Copyright 2015 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* 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 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()
}
}
}
}
}

View file

@ -1,56 +0,0 @@
/*
* Copyright 2015 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* 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 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
}
}
}

View file

@ -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}
);
}
}
}

View file

@ -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);
}
}
}
}

View file

@ -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 }
}

View file

@ -1,8 +1,8 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>qml/main.qml</file>
<file>qml/DeviceDelegate.qml</file>
<file>qml/mpris.qml</file>
<file>qml/mousepad.qml</file>
<file>qml/Device.qml</file>
</qresource>
</RCC>