2020-11-27 19:09:47 +01:00
|
|
|
import QtQuick 2.8
|
2017-08-29 23:58:49 +02:00
|
|
|
import QtQuick.Layouts 1.1
|
2020-11-30 18:25:28 +01:00
|
|
|
import QtQuick.Controls 2.15 as QQ2 // for ComboBox (PlasmaComponents3 version clips the end of the text)
|
2017-09-08 16:59:53 +02:00
|
|
|
import QtQml 2.2
|
2017-08-29 23:58:49 +02:00
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
2020-11-27 19:09:47 +01:00
|
|
|
import org.kde.plasma.components 2.0 as PlasmaComponents // for vertical TabBar
|
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents3
|
2017-08-29 23:58:49 +02:00
|
|
|
import martchus.syncthingplasmoid 0.6 as SyncthingPlasmoid
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: root
|
|
|
|
|
2019-08-08 21:35:56 +02:00
|
|
|
// ensure keyboard events can be received after initialization
|
|
|
|
Component.onCompleted: forceActiveFocus()
|
|
|
|
|
2017-09-18 20:29:36 +02:00
|
|
|
// update the size when settings changed
|
|
|
|
Connections {
|
|
|
|
target: plasmoid.nativeInterface
|
2019-11-30 18:43:24 +01:00
|
|
|
onSizeChanged: {
|
|
|
|
switch (plasmoid.location) {
|
|
|
|
case PlasmaCore.Types.Floating:
|
|
|
|
case PlasmaCore.Types.TopEdge:
|
|
|
|
case PlasmaCore.Types.BottomEdge:
|
|
|
|
case PlasmaCore.Types.LeftEdge:
|
|
|
|
case PlasmaCore.Types.RightEdge:
|
|
|
|
// set the parent's width and height so it will shrink again when decreasing the size
|
|
|
|
var size = plasmoid.nativeInterface.size
|
|
|
|
parent.width = units.gridUnit * size.width
|
|
|
|
parent.height = units.gridUnit * size.height
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
2017-09-18 20:29:36 +02:00
|
|
|
}
|
|
|
|
|
2017-10-04 00:31:51 +02:00
|
|
|
// define shortcuts to trigger actions for currently selected item
|
|
|
|
function clickCurrentItemButton(buttonName) {
|
2018-03-26 22:56:55 +02:00
|
|
|
mainTabGroup.currentTab.item.view.clickCurrentItemButton(buttonName)
|
2017-10-04 00:31:51 +02:00
|
|
|
}
|
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+R"
|
|
|
|
onActivated: clickCurrentItemButton("rescanButton")
|
|
|
|
}
|
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+P"
|
|
|
|
onActivated: clickCurrentItemButton("resumePauseButton")
|
|
|
|
}
|
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+O"
|
|
|
|
onActivated: clickCurrentItemButton("openButton")
|
|
|
|
}
|
|
|
|
|
|
|
|
// define custom key handling for switching tabs, selecting items and filtering
|
2017-08-29 23:58:49 +02:00
|
|
|
Keys.onPressed: {
|
2017-09-26 23:46:20 +02:00
|
|
|
// note: event only received after clicking the tab buttons in plasmoidviewer
|
|
|
|
// but works as expected in plasmashell
|
2017-09-09 21:40:00 +02:00
|
|
|
switch (event.key) {
|
2017-08-29 23:58:49 +02:00
|
|
|
case Qt.Key_Up:
|
2017-09-26 23:46:20 +02:00
|
|
|
switch (event.modifiers) {
|
|
|
|
case Qt.NoModifier:
|
|
|
|
// select previous item in current tab
|
|
|
|
mainTabGroup.currentTab.item.view.decrementCurrentIndex()
|
|
|
|
break
|
|
|
|
case Qt.ShiftModifier:
|
|
|
|
// select previous connection
|
|
|
|
--plasmoid.nativeInterface.currentConnectionConfigIndex
|
|
|
|
break
|
|
|
|
}
|
2017-09-09 21:40:00 +02:00
|
|
|
break
|
2017-08-29 23:58:49 +02:00
|
|
|
case Qt.Key_Down:
|
2017-09-26 23:46:20 +02:00
|
|
|
switch (event.modifiers) {
|
|
|
|
case Qt.NoModifier:
|
|
|
|
// select next item in current tab
|
|
|
|
mainTabGroup.currentTab.item.view.incrementCurrentIndex()
|
|
|
|
break
|
|
|
|
case Qt.ShiftModifier:
|
|
|
|
// select previous connection
|
|
|
|
++plasmoid.nativeInterface.currentConnectionConfigIndex
|
|
|
|
break
|
|
|
|
}
|
2017-09-09 21:40:00 +02:00
|
|
|
break
|
2017-09-12 00:01:19 +02:00
|
|
|
case Qt.Key_Left:
|
2017-09-26 23:46:20 +02:00
|
|
|
// select previous tab
|
2017-09-12 00:01:19 +02:00
|
|
|
switch (mainTabGroup.currentTab) {
|
|
|
|
case dirsPage:
|
2020-05-26 18:12:16 +02:00
|
|
|
recentChangesPage.clicked()
|
2017-09-12 00:01:19 +02:00
|
|
|
break
|
|
|
|
case devicesPage:
|
|
|
|
dirsTabButton.clicked()
|
|
|
|
break
|
|
|
|
case downloadsPage:
|
|
|
|
devsTabButton.clicked()
|
|
|
|
break
|
2020-05-26 18:12:16 +02:00
|
|
|
case recentChangesPage:
|
|
|
|
downloadsTabButton.clicked()
|
|
|
|
break
|
2017-09-12 00:01:19 +02:00
|
|
|
}
|
|
|
|
break
|
|
|
|
case Qt.Key_Right:
|
2017-09-26 23:46:20 +02:00
|
|
|
// select next tab
|
2017-09-12 00:01:19 +02:00
|
|
|
switch (mainTabGroup.currentTab) {
|
|
|
|
case dirsPage:
|
|
|
|
devsTabButton.clicked()
|
|
|
|
break
|
|
|
|
case devicesPage:
|
|
|
|
downloadsTabButton.clicked()
|
|
|
|
break
|
|
|
|
case downloadsPage:
|
2020-05-26 18:12:16 +02:00
|
|
|
recentChangesTabButton.clicked()
|
2017-09-12 00:01:19 +02:00
|
|
|
break
|
2020-05-26 18:12:16 +02:00
|
|
|
case recentChangesPage:
|
|
|
|
dirsTabButton.clicked()
|
2017-09-12 00:01:19 +02:00
|
|
|
}
|
|
|
|
break
|
2017-08-29 23:58:49 +02:00
|
|
|
case Qt.Key_Enter:
|
2017-09-09 21:40:00 +02:00
|
|
|
|
2017-09-26 23:46:20 +02:00
|
|
|
// fallthrough
|
2017-08-29 23:58:49 +02:00
|
|
|
case Qt.Key_Return:
|
2017-09-26 23:46:20 +02:00
|
|
|
// toggle expanded state of current item
|
2017-10-04 00:31:51 +02:00
|
|
|
var currentItem = mainTabGroup.currentTab.item.view.currentItem
|
|
|
|
if (currentItem) {
|
2017-08-29 23:58:49 +02:00
|
|
|
currentItem.expanded = !currentItem.expanded
|
|
|
|
}
|
2017-09-09 21:40:00 +02:00
|
|
|
break
|
2017-08-29 23:58:49 +02:00
|
|
|
case Qt.Key_Escape:
|
2019-03-19 22:55:40 +01:00
|
|
|
var filter = findCurrentFilter()
|
2017-10-01 17:54:11 +02:00
|
|
|
if (filter && filter.text !== "") {
|
|
|
|
// reset filter
|
2019-03-19 22:55:40 +01:00
|
|
|
filter.explicitelyShown = false
|
2017-10-01 17:54:11 +02:00
|
|
|
filter.text = ""
|
|
|
|
event.accepted = true
|
|
|
|
} else {
|
|
|
|
// hide plasmoid
|
|
|
|
plasmoid.expanded = false
|
|
|
|
}
|
2017-09-09 21:40:00 +02:00
|
|
|
break
|
2017-09-08 16:59:53 +02:00
|
|
|
case Qt.Key_1:
|
2017-09-09 21:40:00 +02:00
|
|
|
dirsTabButton.clicked()
|
|
|
|
break
|
2017-09-08 16:59:53 +02:00
|
|
|
case Qt.Key_2:
|
2017-09-09 21:40:00 +02:00
|
|
|
devsTabButton.clicked()
|
|
|
|
break
|
2017-09-08 16:59:53 +02:00
|
|
|
case Qt.Key_3:
|
2017-09-09 21:40:00 +02:00
|
|
|
downloadsTabButton.clicked()
|
|
|
|
break
|
2020-05-26 18:12:16 +02:00
|
|
|
case Qt.Key_4:
|
|
|
|
recentChangesTabButton.clicked()
|
|
|
|
break
|
2017-09-26 23:46:20 +02:00
|
|
|
default:
|
2017-10-01 17:54:11 +02:00
|
|
|
sendKeyEventToFilter(event)
|
2017-09-26 23:46:20 +02:00
|
|
|
return
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2017-09-26 23:46:20 +02:00
|
|
|
event.accepted = true
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
|
2019-03-19 22:55:40 +01:00
|
|
|
function findCurrentFilter() {
|
|
|
|
return mainTabGroup.currentTab.item.filter
|
|
|
|
}
|
|
|
|
|
2017-10-01 17:54:11 +02:00
|
|
|
function sendKeyEventToFilter(event) {
|
2019-03-19 22:55:40 +01:00
|
|
|
var filter = findCurrentFilter()
|
2017-10-01 17:54:11 +02:00
|
|
|
if (!filter || event.text === "" || filter.activeFocus) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (event.key === Qt.Key_Backspace && filter.text === "") {
|
2019-03-19 22:55:40 +01:00
|
|
|
filter.explicitelyShown = false
|
2017-10-01 17:54:11 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if (event.matches(StandardKey.Paste)) {
|
|
|
|
filter.paste()
|
|
|
|
} else {
|
|
|
|
filter.text = ""
|
|
|
|
filter.text += event.text
|
|
|
|
}
|
|
|
|
filter.forceActiveFocus()
|
|
|
|
}
|
|
|
|
|
2017-08-29 23:58:49 +02:00
|
|
|
// heading and right-corner buttons
|
|
|
|
RowLayout {
|
2017-09-08 16:59:53 +02:00
|
|
|
id: toolBar
|
2017-08-29 23:58:49 +02:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2021-10-15 22:18:30 +02:00
|
|
|
ToolButton {
|
2017-09-08 16:59:53 +02:00
|
|
|
id: connectButton
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "disconnected"
|
|
|
|
PropertyChanges {
|
|
|
|
target: connectButton
|
|
|
|
text: qsTr("Connect")
|
2021-10-15 22:18:30 +02:00
|
|
|
icon.source: "image://fa/refresh"
|
2020-05-25 18:39:00 +02:00
|
|
|
visible: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "connecting"
|
|
|
|
PropertyChanges {
|
|
|
|
target: connectButton
|
|
|
|
visible: false
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "paused"
|
|
|
|
PropertyChanges {
|
|
|
|
target: connectButton
|
|
|
|
text: qsTr("Resume")
|
2021-10-15 22:18:30 +02:00
|
|
|
icon.source: "image://fa/play"
|
2020-05-25 18:39:00 +02:00
|
|
|
visible: true
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "idle"
|
|
|
|
PropertyChanges {
|
|
|
|
target: connectButton
|
|
|
|
text: qsTr("Pause")
|
2021-10-15 22:18:30 +02:00
|
|
|
icon.source: "image://fa/pause"
|
2020-05-25 18:39:00 +02:00
|
|
|
visible: true
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
]
|
|
|
|
state: {
|
2017-09-09 21:40:00 +02:00
|
|
|
switch (plasmoid.nativeInterface.connection.status) {
|
2017-09-08 16:59:53 +02:00
|
|
|
case SyncthingPlasmoid.Data.Disconnected:
|
2017-09-09 21:40:00 +02:00
|
|
|
return "disconnected"
|
2020-05-25 18:39:00 +02:00
|
|
|
case SyncthingPlasmoid.Data.Reconnecting:
|
|
|
|
return "connecting";
|
2017-09-08 16:59:53 +02:00
|
|
|
case SyncthingPlasmoid.Data.Paused:
|
2017-09-09 21:40:00 +02:00
|
|
|
return "paused"
|
2017-09-08 16:59:53 +02:00
|
|
|
default:
|
2017-09-09 21:40:00 +02:00
|
|
|
return "idle"
|
2017-09-08 16:59:53 +02:00
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.ToolTip {
|
|
|
|
text: connectButton.text
|
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
onClicked: {
|
2017-09-09 21:40:00 +02:00
|
|
|
switch (plasmoid.nativeInterface.connection.status) {
|
2017-09-08 16:59:53 +02:00
|
|
|
case SyncthingPlasmoid.Data.Disconnected:
|
2017-09-09 21:40:00 +02:00
|
|
|
plasmoid.nativeInterface.connection.connect()
|
|
|
|
break
|
2020-05-25 18:39:00 +02:00
|
|
|
case SyncthingPlasmoid.Data.Reconnecting:
|
|
|
|
break
|
2017-09-08 16:59:53 +02:00
|
|
|
case SyncthingPlasmoid.Data.Paused:
|
2017-09-09 21:40:00 +02:00
|
|
|
plasmoid.nativeInterface.connection.resumeAllDevs()
|
|
|
|
break
|
2017-09-08 16:59:53 +02:00
|
|
|
default:
|
2017-09-09 21:40:00 +02:00
|
|
|
plasmoid.nativeInterface.connection.pauseAllDevs()
|
|
|
|
break
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
2020-11-27 19:09:47 +01:00
|
|
|
|
2017-10-04 00:31:51 +02:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+Shift+P"
|
|
|
|
onActivated: connectButton.clicked()
|
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
}
|
2021-10-15 22:18:30 +02:00
|
|
|
ToolButton {
|
2017-09-08 16:59:53 +02:00
|
|
|
id: startStopButton
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "running"
|
|
|
|
PropertyChanges {
|
|
|
|
target: startStopButton
|
|
|
|
visible: true
|
|
|
|
text: qsTr("Stop")
|
2021-10-15 22:18:30 +02:00
|
|
|
icon.source: "image://fa/stop"
|
2020-11-27 19:09:47 +01:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: startStopToolTip
|
|
|
|
text: (plasmoid.nativeInterface.service.userScope ? "systemctl --user stop " : "systemctl stop ")
|
2017-09-09 21:40:00 +02:00
|
|
|
+ plasmoid.nativeInterface.service.unitName
|
2017-09-08 16:59:53 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "stopped"
|
|
|
|
PropertyChanges {
|
|
|
|
target: startStopButton
|
|
|
|
visible: true
|
|
|
|
text: qsTr("Start")
|
2021-10-15 22:18:30 +02:00
|
|
|
icon.source: "image://fa/play"
|
2020-11-27 19:09:47 +01:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: startStopToolTip
|
|
|
|
text: (plasmoid.nativeInterface.service.userScope ? "systemctl --user start " : "systemctl start ")
|
2017-09-09 21:40:00 +02:00
|
|
|
+ plasmoid.nativeInterface.service.unitName
|
2017-09-08 16:59:53 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "irrelevant"
|
|
|
|
PropertyChanges {
|
|
|
|
target: startStopButton
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
state: {
|
2017-09-09 21:40:00 +02:00
|
|
|
var nativeInterface = plasmoid.nativeInterface
|
2017-09-08 16:59:53 +02:00
|
|
|
// the systemd unit status is only relevant when connected to the local instance
|
2017-09-09 21:40:00 +02:00
|
|
|
if (!nativeInterface.local
|
2018-04-02 20:26:00 +02:00
|
|
|
|| !nativeInterface.startStopEnabled) {
|
2017-09-09 21:40:00 +02:00
|
|
|
return "irrelevant"
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
// show start/stop button only when the configured unit is available
|
2017-09-09 21:40:00 +02:00
|
|
|
var service = nativeInterface.service
|
2017-10-03 23:31:22 +02:00
|
|
|
if (!service || !service.systemdAvailable) {
|
2017-09-09 21:40:00 +02:00
|
|
|
return "irrelevant"
|
2017-09-08 16:59:53 +02:00
|
|
|
}
|
2017-09-09 21:40:00 +02:00
|
|
|
return service.running ? "running" : "stopped"
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
onClicked: plasmoid.nativeInterface.service.toggleRunning()
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.ToolTip {
|
|
|
|
id: startStopToolTip
|
|
|
|
}
|
2017-10-04 00:31:51 +02:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+Shift+S"
|
|
|
|
onActivated: {
|
|
|
|
if (startStopButton.visible) {
|
|
|
|
startStopButton.clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
}
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.ToolButton {
|
2017-10-01 21:42:26 +02:00
|
|
|
id: showNewNotifications
|
2020-11-27 19:09:47 +01:00
|
|
|
icon.name: "emblem-warning"
|
2017-10-01 21:42:26 +02:00
|
|
|
visible: plasmoid.nativeInterface.notificationsAvailable
|
|
|
|
onClicked: {
|
|
|
|
plasmoid.nativeInterface.showNotificationsDialog()
|
|
|
|
plasmoid.expanded = false
|
|
|
|
}
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.ToolTip {
|
|
|
|
text: qsTr("Show new notifications")
|
|
|
|
}
|
2017-10-01 21:42:26 +02:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+N"
|
|
|
|
onActivated: {
|
|
|
|
if (showNewNotifications.visible) {
|
|
|
|
showNewNotifications.clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-15 22:18:30 +02:00
|
|
|
ToolButton {
|
|
|
|
icon.source: "image://fa/info"
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.ToolTip {
|
|
|
|
text: qsTr("About Syncthing Tray")
|
|
|
|
}
|
2019-02-17 23:49:39 +01:00
|
|
|
onClicked: {
|
|
|
|
plasmoid.nativeInterface.showAboutDialog()
|
|
|
|
plasmoid.expanded = false
|
|
|
|
}
|
|
|
|
}
|
2021-10-15 22:18:30 +02:00
|
|
|
ToolButton {
|
2017-09-26 23:46:20 +02:00
|
|
|
id: showOwnIdButton
|
2021-10-15 22:18:30 +02:00
|
|
|
icon.source: "image://fa/qrcode"
|
2017-09-08 16:59:53 +02:00
|
|
|
onClicked: {
|
|
|
|
plasmoid.nativeInterface.showOwnDeviceId()
|
|
|
|
plasmoid.expanded = false
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.ToolTip {
|
|
|
|
text: qsTr("Show own device ID")
|
|
|
|
}
|
2017-09-26 23:46:20 +02:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+I"
|
|
|
|
onActivated: showOwnIdButton.clicked()
|
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
}
|
2021-10-15 22:18:30 +02:00
|
|
|
ToolButton {
|
2017-09-26 23:46:20 +02:00
|
|
|
id: showLogButton
|
2021-10-15 22:18:30 +02:00
|
|
|
icon.source: "image://fa/file-code-o"
|
2017-09-08 16:59:53 +02:00
|
|
|
onClicked: {
|
|
|
|
plasmoid.nativeInterface.showLog()
|
|
|
|
plasmoid.expanded = false
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.ToolTip {
|
|
|
|
text: qsTr("Show Syncthing log")
|
|
|
|
}
|
2017-09-26 23:46:20 +02:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+L"
|
|
|
|
onActivated: showLogButton.clicked()
|
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
}
|
2021-10-15 22:18:30 +02:00
|
|
|
ToolButton {
|
2017-09-26 23:46:20 +02:00
|
|
|
id: rescanAllDirsButton
|
2021-10-15 22:18:30 +02:00
|
|
|
icon.source: "image://fa/search"
|
2017-09-08 16:59:53 +02:00
|
|
|
onClicked: plasmoid.nativeInterface.connection.rescanAllDirs()
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.ToolTip {
|
|
|
|
text: qsTr("Rescan all directories")
|
|
|
|
}
|
2017-09-26 23:46:20 +02:00
|
|
|
Shortcut {
|
2017-10-04 00:31:51 +02:00
|
|
|
sequence: "Ctrl+Shift+R"
|
2017-09-26 23:46:20 +02:00
|
|
|
onActivated: rescanAllDirsButton.clicked()
|
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
}
|
2021-10-15 22:18:30 +02:00
|
|
|
ToolButton {
|
2017-09-26 23:46:20 +02:00
|
|
|
id: settingsButton
|
2021-10-15 22:18:30 +02:00
|
|
|
icon.source: "image://fa/cogs"
|
2017-09-08 16:59:53 +02:00
|
|
|
onClicked: {
|
|
|
|
plasmoid.nativeInterface.showSettingsDlg()
|
|
|
|
plasmoid.expanded = false
|
|
|
|
}
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.ToolTip {
|
|
|
|
text: qsTr("Settings")
|
|
|
|
}
|
2017-09-26 23:46:20 +02:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+S"
|
|
|
|
onActivated: settingsButton.clicked()
|
|
|
|
}
|
2017-09-08 16:59:53 +02:00
|
|
|
}
|
2021-10-15 22:18:30 +02:00
|
|
|
ToolButton {
|
2017-09-26 23:46:20 +02:00
|
|
|
id: webUIButton
|
2021-10-15 22:18:30 +02:00
|
|
|
icon.source: "image://fa/syncthing"
|
2017-09-08 16:59:53 +02:00
|
|
|
onClicked: {
|
2017-09-09 21:40:00 +02:00
|
|
|
plasmoid.nativeInterface.showWebUI()
|
2017-09-08 16:59:53 +02:00
|
|
|
plasmoid.expanded = false
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.ToolTip {
|
|
|
|
text: qsTr("Open Syncthing")
|
|
|
|
}
|
2017-09-26 23:46:20 +02:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+W"
|
|
|
|
onActivated: webUIButton.clicked()
|
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2020-11-30 18:25:28 +01:00
|
|
|
QQ2.ComboBox {
|
2020-11-27 19:09:47 +01:00
|
|
|
id: connectionConfigsMenu
|
|
|
|
model: plasmoid.nativeInterface.connectionConfigNames
|
2020-04-28 00:10:04 +02:00
|
|
|
visible: plasmoid.nativeInterface.connectionConfigNames.length > 1
|
2020-11-27 19:09:47 +01:00
|
|
|
currentIndex: plasmoid.nativeInterface.currentConnectionConfigIndex
|
|
|
|
onCurrentIndexChanged: plasmoid.nativeInterface.currentConnectionConfigIndex = currentIndex
|
2020-11-30 18:25:28 +01:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.maximumWidth: implicitWidth
|
2020-04-13 02:46:13 +02:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+Shift+C"
|
2020-11-27 19:09:47 +01:00
|
|
|
onActivated: connectionConfigsMenu.popup()
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlasmaCore.SvgItem {
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
Layout.preferredHeight: 2
|
|
|
|
elementId: "horizontal-line"
|
2019-02-17 23:45:53 +01:00
|
|
|
svg: PlasmaCore.Svg {
|
|
|
|
imagePath: "widgets/line"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// global statistics and traffic
|
|
|
|
GridLayout {
|
2019-02-27 20:42:41 +01:00
|
|
|
Layout.leftMargin: 5
|
2019-02-17 23:45:53 +01:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: false
|
2019-07-21 22:33:52 +02:00
|
|
|
columns: 3
|
2019-02-17 23:45:53 +01:00
|
|
|
rowSpacing: 1
|
|
|
|
columnSpacing: 4
|
|
|
|
|
2021-10-15 22:18:30 +02:00
|
|
|
Image {
|
2019-02-17 23:45:53 +01:00
|
|
|
Layout.preferredWidth: 16
|
|
|
|
Layout.preferredHeight: 16
|
2021-10-15 22:18:30 +02:00
|
|
|
height: 16
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: "image://fa/globe"
|
2019-02-17 23:45:53 +01:00
|
|
|
}
|
2019-02-27 20:42:41 +01:00
|
|
|
StatisticsView {
|
|
|
|
Layout.leftMargin: 4
|
|
|
|
statistics: plasmoid.nativeInterface.globalStatistics
|
2019-07-21 22:33:52 +02:00
|
|
|
context: qsTr("Global")
|
2019-02-17 23:45:53 +01:00
|
|
|
}
|
|
|
|
|
2019-07-21 22:33:52 +02:00
|
|
|
IconLabel {
|
2019-02-17 23:45:53 +01:00
|
|
|
Layout.leftMargin: 10
|
2021-10-15 22:18:30 +02:00
|
|
|
iconSource: "image://fa/cloud-download"
|
2019-07-21 22:33:52 +02:00
|
|
|
iconOpacity: plasmoid.nativeInterface.hasIncomingTraffic ? 1.0 : 0.5
|
2019-02-17 23:45:53 +01:00
|
|
|
text: plasmoid.nativeInterface.incomingTraffic
|
2019-07-21 22:33:52 +02:00
|
|
|
tooltip: qsTr("Global incoming traffic")
|
2019-02-17 23:45:53 +01:00
|
|
|
}
|
|
|
|
|
2021-10-15 22:18:30 +02:00
|
|
|
Image {
|
2019-02-17 23:45:53 +01:00
|
|
|
Layout.preferredWidth: 16
|
|
|
|
Layout.preferredHeight: 16
|
2021-10-15 22:18:30 +02:00
|
|
|
height: 16
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: "image://fa/home"
|
2019-02-17 23:45:53 +01:00
|
|
|
}
|
2019-02-27 20:42:41 +01:00
|
|
|
StatisticsView {
|
|
|
|
Layout.leftMargin: 4
|
|
|
|
statistics: plasmoid.nativeInterface.localStatistics
|
2019-07-21 22:33:52 +02:00
|
|
|
context: qsTr("Local")
|
2019-02-17 23:45:53 +01:00
|
|
|
}
|
|
|
|
|
2019-07-21 22:33:52 +02:00
|
|
|
IconLabel {
|
2019-02-17 23:45:53 +01:00
|
|
|
Layout.leftMargin: 10
|
2021-10-15 22:18:30 +02:00
|
|
|
iconSource: "image://fa/cloud-upload"
|
2019-07-21 22:33:52 +02:00
|
|
|
iconOpacity: plasmoid.nativeInterface.hasOutgoingTraffic ? 1.0 : 0.5
|
2019-02-17 23:45:53 +01:00
|
|
|
text: plasmoid.nativeInterface.outgoingTraffic
|
2019-07-21 22:33:52 +02:00
|
|
|
tooltip: qsTr("Global outgoing traffic")
|
2019-02-17 23:45:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlasmaCore.SvgItem {
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
Layout.preferredHeight: 2
|
|
|
|
elementId: "horizontal-line"
|
2017-08-29 23:58:49 +02:00
|
|
|
svg: PlasmaCore.Svg {
|
|
|
|
imagePath: "widgets/line"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// tab "widget"
|
|
|
|
RowLayout {
|
2019-10-27 18:54:52 +01:00
|
|
|
id: tabWidget
|
2017-08-29 23:58:49 +02:00
|
|
|
spacing: 0
|
2019-11-30 18:43:24 +01:00
|
|
|
Layout.minimumWidth: units.gridUnit * plasmoid.nativeInterface.size.width
|
|
|
|
Layout.minimumHeight: units.gridUnit * plasmoid.nativeInterface.size.height
|
2017-08-29 23:58:49 +02:00
|
|
|
|
2019-03-19 22:55:40 +01:00
|
|
|
ColumnLayout {
|
|
|
|
spacing: 0
|
2018-06-30 17:45:03 +02:00
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
2017-08-29 23:58:49 +02:00
|
|
|
|
2019-03-19 22:55:40 +01:00
|
|
|
PlasmaComponents.TabBar {
|
|
|
|
id: tabBar
|
|
|
|
tabPosition: Qt.LeftEdge
|
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
|
|
|
|
|
|
|
PlasmaComponents.TabButton {
|
|
|
|
id: dirsTabButton
|
2021-10-15 22:18:30 +02:00
|
|
|
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("folder")
|
2019-03-19 22:55:40 +01:00
|
|
|
tab: dirsPage
|
|
|
|
}
|
|
|
|
PlasmaComponents.TabButton {
|
|
|
|
id: devsTabButton
|
2021-10-15 22:18:30 +02:00
|
|
|
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("sitemap")
|
2019-03-19 22:55:40 +01:00
|
|
|
tab: devicesPage
|
|
|
|
}
|
|
|
|
PlasmaComponents.TabButton {
|
|
|
|
id: downloadsTabButton
|
2021-10-15 22:18:30 +02:00
|
|
|
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("download")
|
2019-03-19 22:55:40 +01:00
|
|
|
tab: downloadsPage
|
|
|
|
}
|
2020-01-18 16:37:20 +01:00
|
|
|
PlasmaComponents.TabButton {
|
|
|
|
id: recentChangesTabButton
|
2021-10-15 22:18:30 +02:00
|
|
|
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("history")
|
2020-01-18 16:37:20 +01:00
|
|
|
tab: recentChangesPage
|
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2019-03-19 22:55:40 +01:00
|
|
|
Item {
|
|
|
|
Layout.fillHeight: true
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2019-03-20 17:37:34 +01:00
|
|
|
TinyButton {
|
2019-03-19 22:55:40 +01:00
|
|
|
id: searchButton
|
2020-11-27 19:09:47 +01:00
|
|
|
icon.name: "search"
|
2019-03-19 22:55:40 +01:00
|
|
|
enabled: mainTabGroup.currentTab === dirsPage
|
|
|
|
tooltip: qsTr("Toggle filter")
|
|
|
|
onClicked: {
|
|
|
|
var filter = findCurrentFilter()
|
|
|
|
if (!filter) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (!filter.explicitelyShown) {
|
|
|
|
filter.explicitelyShown = true
|
|
|
|
filter.forceActiveFocus()
|
|
|
|
} else {
|
|
|
|
filter.explicitelyShown = false
|
|
|
|
filter.text = ""
|
|
|
|
}
|
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
2019-03-19 22:55:40 +01:00
|
|
|
|
2017-08-29 23:58:49 +02:00
|
|
|
PlasmaCore.SvgItem {
|
|
|
|
Layout.preferredWidth: 2
|
|
|
|
Layout.fillHeight: true
|
|
|
|
elementId: "vertical-line"
|
|
|
|
svg: PlasmaCore.Svg {
|
|
|
|
imagePath: "widgets/line"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PlasmaComponents.TabGroup {
|
|
|
|
id: mainTabGroup
|
|
|
|
currentTab: dirsPage
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
PlasmaExtras.ConditionalLoader {
|
|
|
|
id: dirsPage
|
2017-09-09 21:40:00 +02:00
|
|
|
when: mainTabGroup.currentTab === dirsPage
|
2017-08-29 23:58:49 +02:00
|
|
|
source: Qt.resolvedUrl("DirectoriesPage.qml")
|
|
|
|
}
|
|
|
|
PlasmaExtras.ConditionalLoader {
|
|
|
|
id: devicesPage
|
2017-09-09 21:40:00 +02:00
|
|
|
when: mainTabGroup.currentTab === devicesPage
|
2017-08-29 23:58:49 +02:00
|
|
|
source: Qt.resolvedUrl("DevicesPage.qml")
|
|
|
|
}
|
|
|
|
PlasmaExtras.ConditionalLoader {
|
|
|
|
id: downloadsPage
|
2017-09-09 21:40:00 +02:00
|
|
|
when: mainTabGroup.currentTab === downloadsPage
|
2017-08-29 23:58:49 +02:00
|
|
|
source: Qt.resolvedUrl("DownloadsPage.qml")
|
|
|
|
}
|
2020-01-18 16:37:20 +01:00
|
|
|
PlasmaExtras.ConditionalLoader {
|
|
|
|
id: recentChangesPage
|
|
|
|
when: mainTabGroup.currentTab === recentChangesPage
|
|
|
|
source: Qt.resolvedUrl("RecentChangesPage.qml")
|
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|