2015-06-13 00:30:38 +01:00
/ *
2020-08-17 10:48:10 +01:00
* SPDX - FileCopyrightText: 2015 Aleix Pol Gonzalez < aleixpol @ kde . org >
2015-06-13 00:30:38 +01:00
*
2020-08-17 10:48:10 +01:00
* SPDX - License - Identifier: GPL - 2.0 - only OR GPL - 3.0 - only OR LicenseRef - KDE - Accepted - GPL
2015-06-13 00:30:38 +01:00
* /
2023-12-23 16:48:04 +00:00
import QtQuick
import QtQuick . Controls as QQC2
import QtQuick . Layouts
import org . kde . kirigami as Kirigami
import org . kde . kdeconnect
2024-09-17 19:09:09 +01:00
import org . kde . config as KConfig
2015-06-13 00:30:38 +01:00
2022-12-13 20:50:13 +00:00
Kirigami . ApplicationWindow {
2015-06-13 00:30:38 +01:00
id: root
2022-12-13 20:50:13 +00:00
property int columnWidth: Kirigami . Units . gridUnit * 13
minimumWidth: Kirigami . Units . gridUnit * 15
minimumHeight: Kirigami . Units . gridUnit * 15
wideScreen: width > columnWidth * 5
pageStack.globalToolBar.canContainHandles: true
pageStack.globalToolBar.showNavigationButtons: applicationWindow ( ) . pageStack . currentIndex > 0 ? Kirigami.ApplicationHeaderStyle.ShowBackButton : 0
2024-09-17 19:09:09 +01:00
KConfig . WindowStateSaver {
configGroupName: "MainWindow"
}
2022-12-13 20:50:13 +00:00
globalDrawer: Kirigami . OverlayDrawer {
id: drawer
edge: Qt . application . layoutDirection === Qt . RightToLeft ? Qt.RightEdge : Qt . LeftEdge
modal: Kirigami . Settings . isMobile || ( applicationWindow ( ) . width < Kirigami . Units . gridUnit * 50 && ! collapsed ) // Only modal when not collapsed, otherwise collapsed won't show.
width: Kirigami . Units . gridUnit * 16
2023-08-24 07:39:15 +01:00
onModalChanged: drawerOpen = ! modal
2015-06-13 00:30:38 +01:00
2022-12-13 20:50:13 +00:00
Behavior on width {
NumberAnimation {
duration: Kirigami . Units . longDuration
easing.type: Easing . InOutQuad
}
2020-09-25 13:12:22 +01:00
}
2022-12-13 20:50:13 +00:00
Kirigami.Theme.colorSet: Kirigami . Theme . Window
2020-09-25 13:12:22 +01:00
2022-12-13 20:50:13 +00:00
handleClosedIcon.source: modal ? null : "sidebar-expand-left"
handleOpenIcon.source: modal ? null : "sidebar-collapse-left"
handleVisible: modal
2016-08-21 17:45:49 +01:00
2022-12-13 20:50:13 +00:00
leftPadding: 0
rightPadding: 0
topPadding: 0
bottomPadding: 0
2016-08-21 16:55:13 +01:00
2022-12-13 20:50:13 +00:00
contentItem: ColumnLayout {
spacing: 0
2015-06-19 06:14:02 +01:00
2022-12-13 20:50:13 +00:00
QQC2 . ToolBar {
Layout.fillWidth: true
Layout.preferredHeight: pageStack . globalToolBar . preferredHeight
2018-11-05 00:41:04 +00:00
2022-12-13 20:50:13 +00:00
leftPadding: Kirigami . Units . largeSpacing
rightPadding: Kirigami . Units . largeSpacing
topPadding: Kirigami . Units . smallSpacing
bottomPadding: Kirigami . Units . smallSpacing
2020-09-19 13:51:11 +01:00
2022-12-13 20:50:13 +00:00
contentItem: Kirigami . Heading {
2020-09-19 13:51:11 +01:00
text: announcedNameProperty . value
elide: Qt . ElideRight
2018-11-05 00:41:04 +00:00
2022-12-13 20:50:13 +00:00
DBusProperty {
id: announcedNameProperty
object: DaemonDbusInterface
read: "announcedName"
defaultValue: ""
2020-09-19 13:51:11 +01:00
}
2016-08-21 18:38:15 +01:00
}
}
2019-10-15 19:13:17 +01:00
2023-11-14 22:48:56 +00:00
QQC2 . ItemDelegate {
2022-12-13 20:50:13 +00:00
id: findDevicesAction
text: i18nd ( "kdeconnect-app" , "Find devices..." )
2023-11-14 22:48:56 +00:00
icon.name: "list-add"
2022-12-13 20:50:13 +00:00
checked: pageStack . currentItem && pageStack . currentItem . objectName == "FindDevices"
Layout.fillWidth: true
onClicked: {
2016-06-08 17:37:57 +01:00
root . pageStack . clear ( )
2022-12-13 20:50:13 +00:00
root . pageStack . push ( Qt . resolvedUrl ( "FindDevicesPage.qml" ) ) ;
2015-06-13 00:30:38 +01:00
}
}
2016-08-21 16:55:13 +01:00
2022-12-13 20:50:13 +00:00
Kirigami . Separator {
Layout.fillWidth: true
2016-08-21 16:55:13 +01:00
}
2022-12-13 20:50:13 +00:00
Repeater {
model: DevicesSortProxyModel {
sourceModel: DevicesModel {
displayFilter: DevicesModel . Paired | DevicesModel . Reachable
}
}
2023-11-14 22:48:56 +00:00
QQC2 . ItemDelegate {
2022-12-13 20:50:13 +00:00
Layout.fillWidth: true
2024-01-09 21:38:35 +00:00
contentItem: Kirigami . IconTitleSubtitle {
icon.name: model . iconName
icon.width: Kirigami . Units . iconSizes . smallMedium
title: model . name
subtitle: model . toolTip
}
2022-12-13 20:50:13 +00:00
enabled: status & DevicesModel . Reachable
checked: pageStack . currentItem && pageStack . currentItem . currentDevice == device
onClicked: {
2024-03-12 14:26:37 +00:00
root . pageStack . pop ( 0 )
2022-12-13 20:50:13 +00:00
root . pageStack . push (
Qt . resolvedUrl ( "DevicePage.qml" ) ,
{ currentDevice: device }
) ;
}
2016-08-21 16:55:13 +01:00
}
}
2022-12-13 20:50:13 +00:00
Item {
Layout.fillHeight: true
Layout.fillWidth: true
}
2023-11-14 22:48:56 +00:00
QQC2 . ItemDelegate {
2022-12-13 20:50:13 +00:00
text: i18n ( "Settings" )
2023-11-14 22:48:56 +00:00
icon.name: "settings-configure"
Layout.fillWidth: true
2024-01-10 22:21:31 +00:00
onClicked: pageStack . pushDialogLayer ( Qt . resolvedUrl ( "Settings.qml" ) , { } , {
2022-12-13 21:16:10 +00:00
title: i18n ( "Settings" ) ,
} ) ;
2022-12-13 20:50:13 +00:00
}
2015-06-13 00:30:38 +01:00
}
}
2016-06-08 17:37:57 +01:00
2016-06-08 17:38:48 +01:00
contextDrawer: Kirigami . ContextDrawer {
id: contextDrawer
}
2019-10-15 19:06:04 +01:00
pageStack.initialPage: Qt . resolvedUrl ( "FindDevicesPage.qml" )
2015-06-13 00:30:38 +01:00
}