Files
amnezia-client/client/ui/qml/Pages/PageSites.qml
T

194 lines
5.0 KiB
QML
Raw Normal View History

2021-07-28 16:13:29 +07:00
import QtQuick 2.12
import QtQuick.Controls 2.12
2021-08-09 00:41:52 +07:00
import Qt.labs.platform 1.0
import QtQuick.Dialogs 1.0
2021-09-14 00:39:07 +03:00
import PageEnum 1.0
2021-08-19 01:27:22 +03:00
import "./"
import "../Controls"
import "../Config"
2021-08-09 00:41:52 +07:00
2021-09-14 00:39:07 +03:00
PageBase {
2021-07-28 16:13:29 +07:00
id: root
2021-09-14 00:39:07 +03:00
page: PageEnum.Sites
logic: SitesLogic
2021-09-08 15:09:16 +03:00
BackButton {
id: back
}
2021-11-17 15:01:48 +03:00
Caption {
id: caption
text: SitesLogic.labelSitesAddCustomText
}
LabelType {
id: lb_addr
2021-07-28 16:13:29 +07:00
color: "#333333"
text: qsTr("Web site/Hostname/IP address/Subnet")
x: 20
2021-11-17 15:01:48 +03:00
anchors.top: caption.bottom
anchors.topMargin: 10
width: parent.width
2021-07-28 16:13:29 +07:00
height: 21
}
2021-11-17 15:01:48 +03:00
2021-07-28 16:13:29 +07:00
TextFieldType {
2021-11-17 15:01:48 +03:00
anchors.top: lb_addr.bottom
anchors.topMargin: 10
anchors.left: parent.left
anchors.leftMargin: 20
anchors.right: sites_add.left
anchors.rightMargin: 10
2021-07-28 16:13:29 +07:00
height: 31
placeholderText: qsTr("yousite.com or IP address")
2021-09-03 20:17:13 +03:00
text: SitesLogic.lineEditSitesAddCustomText
2021-08-09 00:41:52 +07:00
onEditingFinished: {
2021-09-03 20:17:13 +03:00
SitesLogic.lineEditSitesAddCustomText = text
2021-08-09 00:41:52 +07:00
}
onAccepted: {
2021-09-03 20:17:13 +03:00
SitesLogic.onPushButtonAddCustomSitesClicked()
2021-08-09 00:41:52 +07:00
}
2021-07-28 16:13:29 +07:00
}
2021-11-17 15:01:48 +03:00
2021-07-28 16:13:29 +07:00
BlueButtonType {
id: sites_add
2021-11-17 15:01:48 +03:00
anchors.right: sites_import.left
anchors.rightMargin: 10
anchors.top: lb_addr.bottom
anchors.topMargin: 10
2021-07-28 16:13:29 +07:00
width: 51
height: 31
font.pixelSize: 24
text: "+"
2021-08-09 00:41:52 +07:00
onClicked: {
2021-09-03 20:17:13 +03:00
SitesLogic.onPushButtonAddCustomSitesClicked()
2021-08-09 00:41:52 +07:00
}
2021-07-28 16:13:29 +07:00
}
BasicButtonType {
id: sites_import
2021-11-17 15:01:48 +03:00
anchors.right: parent.right
anchors.rightMargin: 20
anchors.top: lb_addr.bottom
anchors.topMargin: 10
2021-07-28 16:13:29 +07:00
width: 51
height: 31
background: Rectangle {
anchors.fill: parent
radius: 4
color: parent.containsMouse ? "#211966" : "#100A44"
}
font.pixelSize: 16
contentItem: Item {
anchors.fill: parent
Image {
anchors.centerIn: parent
width: 20
height: 20
source: "qrc:/images/folder.png"
fillMode: Image.Stretch
}
}
antialiasing: true
2021-08-09 00:41:52 +07:00
onClicked: {
fileDialog.open()
}
}
FileDialog {
id: fileDialog
title: qsTr("Import IP addresses")
visible: false
folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
onAccepted: {
2021-09-03 20:17:13 +03:00
SitesLogic.onPushButtonSitesImportClicked(fileUrl)
2021-08-09 00:41:52 +07:00
}
2021-07-28 16:13:29 +07:00
}
2021-11-17 15:01:48 +03:00
2021-08-09 01:34:25 +07:00
ListView {
2021-07-28 16:13:29 +07:00
id: tb
x: 20
2021-11-17 15:01:48 +03:00
anchors.top: sites_add.bottom
anchors.topMargin: 10
width: parent.width - 40
anchors.bottom: sites_delete.top
anchors.bottomMargin: 10
2021-08-09 01:34:25 +07:00
spacing: 1
2021-07-28 16:13:29 +07:00
clip: true
property int currentRow: -1
2021-09-03 20:17:13 +03:00
model: SitesLogic.tableViewSitesModel
2021-07-28 16:13:29 +07:00
delegate: Item {
2021-08-09 01:34:25 +07:00
implicitWidth: 170 * 2
2021-07-28 16:13:29 +07:00
implicitHeight: 30
2021-08-09 01:34:25 +07:00
Item {
width: 170
height: 30
anchors.left: parent.left
id: c1
Rectangle {
anchors.top: parent.top
width: parent.width
height: 1
color: "lightgray"
visible: index !== tb.currentRow
}
Rectangle {
anchors.fill: parent
color: "#63B4FB"
visible: index === tb.currentRow
2021-07-28 16:13:29 +07:00
2021-08-09 01:34:25 +07:00
}
Text {
text: url_path
anchors.fill: parent
leftPadding: 10
verticalAlignment: Text.AlignVCenter
}
2021-07-28 16:13:29 +07:00
}
2021-08-09 01:34:25 +07:00
Item {
anchors.left: c1.right
width: 170
height: 30
Rectangle {
anchors.top: parent.top
width: parent.width
height: 1
color: "lightgray"
visible: index !== tb.currentRow
}
Rectangle {
anchors.fill: parent
color: "#63B4FB"
visible: index === tb.currentRow
2021-07-28 16:13:29 +07:00
2021-08-09 01:34:25 +07:00
}
Text {
text: ip
anchors.fill: parent
leftPadding: 10
verticalAlignment: Text.AlignVCenter
}
2021-07-28 16:13:29 +07:00
}
MouseArea {
anchors.fill: parent
onClicked: {
2021-08-09 01:34:25 +07:00
tb.currentRow = index
2021-07-28 16:13:29 +07:00
}
}
}
}
2021-11-17 15:01:48 +03:00
BlueButtonType {
id: sites_delete
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
height: 31
font.pixelSize: 16
text: qsTr("Delete selected")
onClicked: {
SitesLogic.onPushButtonSitesDeleteClicked(tb.currentRow)
}
}
2021-07-28 16:13:29 +07:00
}