Move FindDevicesPage functionality to the drawer

This commit is contained in:
Darshan Phaldesai 2024-11-13 20:22:11 -07:00
parent 1fc8b56783
commit 83520ae156
3 changed files with 69 additions and 129 deletions

View file

@ -35,7 +35,6 @@ ecm_target_qml_sources(kdeconnect-app SOURCES
qml/presentationRemote.qml qml/presentationRemote.qml
qml/PluginItem.qml qml/PluginItem.qml
qml/DevicePage.qml qml/DevicePage.qml
qml/FindDevicesPage.qml
qml/runcommand.qml qml/runcommand.qml
qml/volume.qml qml/volume.qml
qml/MprisSlider.qml qml/MprisSlider.qml

View file

@ -1,88 +0,0 @@
/*
* SPDX-FileCopyrightText: 2016 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.kdeconnect
Kirigami.ScrollablePage
{
id: root
Component {
id: deviceComp
DevicePage {}
}
objectName: "FindDevices"
title: i18ndc("kdeconnect-app", "Title of the page listing the devices", "Devices")
supportsRefreshing: true
onRefreshingChanged: {
DaemonDbusInterface.forceOnNetworkChange()
refreshResetTimer.start()
}
Timer {
id: refreshResetTimer
interval: 1000
onTriggered: root.refreshing = false
}
ListView {
id: devices
section {
property: "status"
delegate: Kirigami.ListSectionHeader {
width: ListView.view.width
text: switch (parseInt(section))
{
case DevicesModel.Paired:
return i18nd("kdeconnect-app", "Remembered")
case DevicesModel.Reachable:
return i18nd("kdeconnect-app", "Available")
case (DevicesModel.Reachable | DevicesModel.Paired):
return i18nd("kdeconnect-app", "Connected")
}
}
}
Kirigami.PlaceholderMessage {
text: i18nd("kdeconnect-app", "No devices found")
icon.name: 'edit-none-symbolic'
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: devices.count === 0
}
model: DevicesSortProxyModel {
sourceModel: DevicesModel {}
}
delegate: ItemDelegate {
id: delegate
icon.name: iconName
text: model.name
width: ListView.view.width
highlighted: false
contentItem: Kirigami.IconTitleSubtitle {
title: delegate.text
subtitle: toolTip
icon: icon.fromControlsIcon(delegate.icon)
}
onClicked: {
pageStack.push(
deviceComp,
{currentDevice: device}
);
}
}
}
}

View file

@ -24,6 +24,11 @@ Kirigami.ApplicationWindow {
configGroupName: "MainWindow" configGroupName: "MainWindow"
} }
Component {
id: deviceComp
DevicePage {}
}
globalDrawer: Kirigami.OverlayDrawer { globalDrawer: Kirigami.OverlayDrawer {
id: drawer id: drawer
edge: Qt.application.layoutDirection === Qt.RightToLeft ? Qt.RightEdge : Qt.LeftEdge edge: Qt.application.layoutDirection === Qt.RightToLeft ? Qt.RightEdge : Qt.LeftEdge
@ -50,7 +55,6 @@ Kirigami.ApplicationWindow {
contentItem: ColumnLayout { contentItem: ColumnLayout {
spacing: 0 spacing: 0
QQC2.ToolBar { QQC2.ToolBar {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: pageStack.globalToolBar.preferredHeight Layout.preferredHeight: pageStack.globalToolBar.preferredHeight
@ -72,57 +76,78 @@ Kirigami.ApplicationWindow {
} }
} }
} }
QQC2.ScrollView {
QQC2.ItemDelegate { Layout.fillWidth: true
id: findDevicesAction ListView {
text: i18nd("kdeconnect-app", "Find devices...") id: devices
icon.name: "list-add"
checked: pageStack.currentItem && pageStack.currentItem.objectName == "FindDevices"
Layout.fillWidth: true Layout.fillWidth: true
onClicked: { section {
root.pageStack.clear() property: "status"
root.pageStack.push(Qt.resolvedUrl("FindDevicesPage.qml")); delegate: Kirigami.ListSectionHeader {
width: ListView.view.width
text: switch (parseInt(section)) {
case DevicesModel.Paired:
return i18nd("kdeconnect-app", "Remembered")
case DevicesModel.Reachable:
return i18nd("kdeconnect-app", "Available")
case (DevicesModel.Reachable | DevicesModel.Paired):
return i18nd("kdeconnect-app", "Connected")
} }
} }
Kirigami.Separator {
Layout.fillWidth: true
} }
Kirigami.PlaceholderMessage {
Repeater { text: i18nd("kdeconnect-app", "No devices found")
icon.name: 'edit-none-symbolic'
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: devices.count === 0
}
model: DevicesSortProxyModel { model: DevicesSortProxyModel {
sourceModel: DevicesModel { sourceModel: DevicesModel {}
displayFilter: DevicesModel.Paired | DevicesModel.Reachable
}
} }
delegate: QQC2.ItemDelegate {
id: delegate
icon.name: iconName
text: model.name
width: ListView.view.width
highlighted: false
QQC2.ItemDelegate {
Layout.fillWidth: true
contentItem: Kirigami.IconTitleSubtitle { contentItem: Kirigami.IconTitleSubtitle {
icon.name: model.iconName title: delegate.text
icon.width: Kirigami.Units.iconSizes.smallMedium subtitle: toolTip
title: model.name icon: icon.fromControlsIcon(delegate.icon)
subtitle: model.toolTip
} }
enabled: status & DevicesModel.Reachable
checked: pageStack.currentItem && pageStack.currentItem.currentDevice == device
onClicked: { onClicked: {
root.pageStack.pop(0) pageStack.clear()
root.pageStack.push( pageStack.push(
Qt.resolvedUrl("DevicePage.qml"), deviceComp,
{currentDevice: device} {currentDevice: device}
); );
} }
} }
} }
}
Item { Item {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
} }
QQC2.Button {
text: i18nc("@action:intoolbar", "Refresh")
icon.name: 'view-refresh-symbolic'
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing
onClicked: {
refresh
}
}
QQC2.ItemDelegate { QQC2.ItemDelegate {
text: i18n("Settings") text: i18n("Settings")
icon.name: "settings-configure" icon.name: "settings-configure"
@ -139,4 +164,8 @@ Kirigami.ApplicationWindow {
} }
pageStack.initialPage: Qt.resolvedUrl("NoDeviceSelected.qml") pageStack.initialPage: Qt.resolvedUrl("NoDeviceSelected.qml")
function refresh() {
DaemonDbusInterface.forceOnNetworkChange()
}
} }