Improve how we handle the different plugin pages
This commit is contained in:
parent
1e574d18e3
commit
f654e75820
6 changed files with 79 additions and 45 deletions
|
@ -59,37 +59,21 @@ Kirigami.Page
|
|||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
Kirigami.BasicListItem {
|
||||
readonly property var fu: PluginChecker {
|
||||
id: mprisChecker
|
||||
pluginName: "mpriscontrol"
|
||||
}
|
||||
enabled: mprisChecker.available
|
||||
PluginItem {
|
||||
label: i18n("Multimedia control")
|
||||
onClicked: pageStack.push(
|
||||
"qrc:/qml/mpris.qml",
|
||||
{ mprisInterface: MprisDbusInterfaceFactory.create(deviceView.currentDevice.id()) }
|
||||
);
|
||||
interfaceFactory: MprisDbusInterfaceFactory
|
||||
component: "qrc:/qml/mpris.qml"
|
||||
pluginName: "mprisremote"
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
readonly property var fu: PluginChecker {
|
||||
id: mousepadChecker
|
||||
pluginName: "mousepad"
|
||||
}
|
||||
enabled: mousepadChecker.available
|
||||
PluginItem {
|
||||
label: i18n("Remote input")
|
||||
onClicked: pageStack.push(
|
||||
"qrc:/qml/mousepad.qml",
|
||||
{ remoteControlInterface: RemoteControlDbusInterfaceFactory.create(deviceView.currentDevice.id()) }
|
||||
);
|
||||
interfaceFactory: RemoteControlDbusInterfaceFactory
|
||||
component: "qrc:/qml/mousepad.qml"
|
||||
pluginName: "remotecontrol"
|
||||
}
|
||||
Kirigami.BasicListItem {
|
||||
readonly property var fu: PluginChecker {
|
||||
id: lockdeviceChecker
|
||||
PluginItem {
|
||||
readonly property var lockIface: LockDeviceDbusInterfaceFactory.create(deviceView.currentDevice.id())
|
||||
pluginName: "lockdevice"
|
||||
}
|
||||
enabled: lockdeviceChecker.available
|
||||
property var lockIface: LockDeviceDbusInterfaceFactory.create(deviceView.currentDevice.id())
|
||||
label: lockIface.isLocked ? i18n("Unlock") : i18n("Lock")
|
||||
onClicked: {
|
||||
lockIface.isLocked = !lockIface.isLocked;
|
||||
|
|
|
@ -55,8 +55,8 @@ Kirigami.Page
|
|||
label: display + "\n" + toolTip
|
||||
enabled: !(status & DevicesModel.Paired)
|
||||
onClicked: {
|
||||
root.pageStack.clear()
|
||||
root.pageStack.push(
|
||||
pageStack.clear()
|
||||
pageStack.push(
|
||||
"qrc:/qml/DevicePage.qml",
|
||||
{currentDevice: device}
|
||||
);
|
||||
|
|
49
app/qml/PluginItem.qml
Normal file
49
app/qml/PluginItem.qml
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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.BasicListItem
|
||||
{
|
||||
property alias pluginName: checker.pluginName
|
||||
property var interfaceFactory
|
||||
property string component
|
||||
|
||||
readonly property var checker: PluginChecker {
|
||||
id: checker
|
||||
deviceId: deviceView.currentDevice.id()
|
||||
}
|
||||
enabled: checker.available
|
||||
onClicked: {
|
||||
if (component === "")
|
||||
return;
|
||||
|
||||
var obj = interfaceFactory.create(checker.deviceId);
|
||||
var page = pageStack.push(
|
||||
component,
|
||||
{ pluginInterface: obj }
|
||||
);
|
||||
obj.parent = page
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ Kirigami.Page
|
|||
{
|
||||
id: mousepad
|
||||
title: i18n("Remote Control")
|
||||
property QtObject remoteControlInterface
|
||||
property QtObject pluginInterface
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
|
@ -39,14 +39,14 @@ Kirigami.Page
|
|||
Layout.fillHeight: true
|
||||
property var lastPos: Qt.point(-1, -1)
|
||||
|
||||
onClicked: mousepad.remoteControlInterface.sendCommand("singleclick", true);
|
||||
onClicked: mousepad.pluginInterface.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);
|
||||
pluginInterface.moveCursor(delta);
|
||||
}
|
||||
lastPos = Qt.point(mouse.x, mouse.y);
|
||||
}
|
||||
|
@ -59,15 +59,15 @@ Kirigami.Page
|
|||
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
onClicked: mousepad.remoteControlInterface.sendCommand("singleclick", true);
|
||||
onClicked: mousepad.pluginInterface.sendCommand("singleclick", true);
|
||||
}
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
onClicked: mousepad.remoteControlInterface.sendCommand("middleclick", true);
|
||||
onClicked: mousepad.pluginInterface.sendCommand("middleclick", true);
|
||||
}
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
onClicked: mousepad.remoteControlInterface.sendCommand("rightclick", true);
|
||||
onClicked: mousepad.pluginInterface.sendCommand("rightclick", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.kde.kirigami 1.0 as Kirigami
|
|||
Kirigami.Page
|
||||
{
|
||||
id: root
|
||||
property QtObject mprisInterface
|
||||
property QtObject pluginInterface
|
||||
title: i18n("Multimedia Controls")
|
||||
|
||||
ColumnLayout
|
||||
|
@ -34,42 +34,42 @@ Kirigami.Page
|
|||
anchors.fill: parent
|
||||
|
||||
Component.onCompleted: {
|
||||
mprisInterface.requestPlayerList();
|
||||
pluginInterface.requestPlayerList();
|
||||
}
|
||||
|
||||
Item { Layout.fillHeight: true }
|
||||
ComboBox {
|
||||
Layout.fillWidth: true
|
||||
model: root.mprisInterface.playerList
|
||||
onCurrentTextChanged: root.mprisInterface.player = currentText
|
||||
model: root.pluginInterface.playerList
|
||||
onCurrentTextChanged: root.pluginInterface.player = currentText
|
||||
}
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: root.mprisInterface.nowPlaying
|
||||
text: root.pluginInterface.nowPlaying
|
||||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
iconName: "media-skip-backward"
|
||||
onClicked: root.mprisInterface.sendAction("Previous")
|
||||
onClicked: root.pluginInterface.sendAction("Previous")
|
||||
}
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
iconName: root.mprisInterface.isPlaying ? "media-playback-pause" : "media-playback-start"
|
||||
onClicked: root.mprisInterface.sendAction("PlayPause");
|
||||
iconName: root.pluginInterface.isPlaying ? "media-playback-pause" : "media-playback-start"
|
||||
onClicked: root.pluginInterface.sendAction("PlayPause");
|
||||
}
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
iconName: "media-skip-forward"
|
||||
onClicked: root.mprisInterface.sendAction("Next")
|
||||
onClicked: root.pluginInterface.sendAction("Next")
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Label { text: i18n("Volume:") }
|
||||
Slider {
|
||||
value: root.mprisInterface.volume
|
||||
value: root.pluginInterface.volume
|
||||
maximumValue: 100
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<file>qml/main.qml</file>
|
||||
<file>qml/mpris.qml</file>
|
||||
<file>qml/mousepad.qml</file>
|
||||
<file>qml/PluginItem.qml</file>
|
||||
<file>qml/DevicePage.qml</file>
|
||||
<file>qml/FindDevicesPage.qml</file>
|
||||
</qresource>
|
||||
|
|
Loading…
Reference in a new issue