Use extra page for fields
This commit is contained in:
parent
7fbc1fe0f6
commit
b1bd12755c
|
@ -39,12 +39,6 @@ Kirigami.ScrollablePage {
|
||||||
onTriggered: insertEntry("Node")
|
onTriggered: insertEntry("Node")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onBackRequested: {
|
|
||||||
if (fieldsSheet.sheetOpen) {
|
|
||||||
event.accepted = true
|
|
||||||
fieldsSheet.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: Kirigami.Theme.backgroundColor
|
color: Kirigami.Theme.backgroundColor
|
||||||
}
|
}
|
||||||
|
@ -118,108 +112,6 @@ Kirigami.ScrollablePage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// component representing a field
|
|
||||||
Component {
|
|
||||||
id: fieldsListDelegateComponent
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: fieldsListItem
|
|
||||||
width: fieldsSheet.width
|
|
||||||
|
|
||||||
Kirigami.ListItemDragHandle {
|
|
||||||
listItem: fieldsListItem
|
|
||||||
listView: fieldsListView
|
|
||||||
onMoveRequested: fieldsListView.model.moveRows(
|
|
||||||
fieldsListView.model.index(-1, 0),
|
|
||||||
oldIndex, 1,
|
|
||||||
fieldsListView.model.index(-1,
|
|
||||||
0), newIndex)
|
|
||||||
}
|
|
||||||
Controls.TextField {
|
|
||||||
text: model.key ? model.key : ""
|
|
||||||
onEditingFinished: fieldsListView.model.setData(
|
|
||||||
fieldsListView.model.index(index, 0),
|
|
||||||
text)
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
Controls.TextField {
|
|
||||||
text: model.actualValue ? model.actualValue : ""
|
|
||||||
echoMode: model.isPassword
|
|
||||||
&& (!activeFocus
|
|
||||||
|| !main.showPasswordsOnFocus) ? TextInput.PasswordEchoOnEdit : TextInput.Normal
|
|
||||||
onEditingFinished: fieldsListView.model.setData(
|
|
||||||
fieldsListView.model.index(index, 1),
|
|
||||||
text)
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
Controls.Button {
|
|
||||||
id: fieldsListItemToolButton
|
|
||||||
text: qsTr("⋮")
|
|
||||||
flat: true
|
|
||||||
onClicked: fieldsListItemMenu.open()
|
|
||||||
Layout.maximumWidth: Kirigami.Units.iconSizes.medium
|
|
||||||
Layout.maximumHeight: Kirigami.Units.iconSizes.large
|
|
||||||
|
|
||||||
Controls.Menu {
|
|
||||||
id: fieldsListItemMenu
|
|
||||||
y: fieldsListItemToolButton.height
|
|
||||||
|
|
||||||
Controls.MenuItem {
|
|
||||||
icon.name: model.isPassword ? "password-show-off" : "password-show-on"
|
|
||||||
text: model.isPassword ? qsTr("Mark as normal field") : qsTr(
|
|
||||||
"Mark as password field")
|
|
||||||
onClicked: fieldsListView.model.setData(
|
|
||||||
fieldsListView.model.index(index, 0),
|
|
||||||
model.isPassword ? 0 : 1, 0x0100 + 1)
|
|
||||||
}
|
|
||||||
Controls.MenuItem {
|
|
||||||
icon.name: "edit-copy"
|
|
||||||
text: qsTr("Copy password")
|
|
||||||
onClicked: showPassiveNotification(
|
|
||||||
nativeInterface.copyToClipboard(
|
|
||||||
model.actualValue) ? qsTr("Copied") : qsTr(
|
|
||||||
"Unable to access clipboard"))
|
|
||||||
}
|
|
||||||
Controls.MenuItem {
|
|
||||||
icon.name: "edit-delete"
|
|
||||||
text: qsTr("Delete field")
|
|
||||||
onClicked: fieldsListView.model.removeRows(index, 1)
|
|
||||||
}
|
|
||||||
Controls.MenuItem {
|
|
||||||
icon.name: "list-add"
|
|
||||||
text: qsTr("Insert empty field after this")
|
|
||||||
onClicked: fieldsListView.model.insertRows(index + 1, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// "sheet" to display field model
|
|
||||||
Kirigami.OverlaySheet {
|
|
||||||
id: fieldsSheet
|
|
||||||
parent: applicationWindow().overlay
|
|
||||||
header: Kirigami.Heading {
|
|
||||||
text: qsTr("Edit account ") + nativeInterface.currentAccountName
|
|
||||||
}
|
|
||||||
|
|
||||||
ListView {
|
|
||||||
id: fieldsListView
|
|
||||||
implicitWidth: Kirigami.Units.gridUnit * 30
|
|
||||||
model: nativeInterface.fieldModel
|
|
||||||
moveDisplaced: Transition {
|
|
||||||
YAnimator {
|
|
||||||
duration: Kirigami.Units.longDuration
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delegate: Kirigami.DelegateRecycler {
|
|
||||||
width: parent ? parent.width : implicitWidth
|
|
||||||
sourceComponent: fieldsListDelegateComponent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// component representing an entry
|
// component representing an entry
|
||||||
Component {
|
Component {
|
||||||
id: listDelegateComponent
|
id: listDelegateComponent
|
||||||
|
@ -250,9 +142,6 @@ Kirigami.ScrollablePage {
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
height: Math.max(
|
|
||||||
implicitHeight,
|
|
||||||
Kirigami.Units.iconSizes.smallMedium)
|
|
||||||
text: model.name
|
text: model.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +238,7 @@ Kirigami.ScrollablePage {
|
||||||
root.pushStackEntry(entryModel, modelIndex)
|
root.pushStackEntry(entryModel, modelIndex)
|
||||||
} else {
|
} else {
|
||||||
nativeInterface.currentAccountIndex = modelIndex
|
nativeInterface.currentAccountIndex = modelIndex
|
||||||
fieldsSheet.open()
|
root.pushAccountEdit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
import QtQuick 2.4
|
||||||
|
import QtQuick.Layouts 1.2
|
||||||
|
import QtQml.Models 2.2
|
||||||
|
import QtQuick.Controls 2.4 as Controls
|
||||||
|
import org.kde.kirigami 2.5 as Kirigami
|
||||||
|
|
||||||
|
Kirigami.ScrollablePage {
|
||||||
|
id: page
|
||||||
|
property var main: undefined
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
title: nativeInterface.currentAccountName
|
||||||
|
background: Rectangle {
|
||||||
|
color: Kirigami.Theme.backgroundColor
|
||||||
|
}
|
||||||
|
|
||||||
|
// component representing a field
|
||||||
|
Component {
|
||||||
|
id: fieldsListDelegateComponent
|
||||||
|
|
||||||
|
Kirigami.BasicListItem {
|
||||||
|
id: fieldsListItem
|
||||||
|
contentItem: RowLayout {
|
||||||
|
Kirigami.ListItemDragHandle {
|
||||||
|
listItem: fieldsListItem
|
||||||
|
listView: fieldsListView
|
||||||
|
onMoveRequested: fieldsListView.model.moveRows(
|
||||||
|
fieldsListView.model.index(-1, 0),
|
||||||
|
oldIndex, 1,
|
||||||
|
fieldsListView.model.index(-1, 0),
|
||||||
|
newIndex)
|
||||||
|
}
|
||||||
|
Controls.TextField {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: model.key ? model.key : ""
|
||||||
|
onEditingFinished: fieldsListView.model.setData(
|
||||||
|
fieldsListView.model.index(index,
|
||||||
|
0), text)
|
||||||
|
}
|
||||||
|
Controls.TextField {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: model.actualValue ? model.actualValue : ""
|
||||||
|
echoMode: model.isPassword
|
||||||
|
&& (!activeFocus
|
||||||
|
|| !main.showPasswordsOnFocus) ? TextInput.PasswordEchoOnEdit : TextInput.Normal
|
||||||
|
onEditingFinished: fieldsListView.model.setData(
|
||||||
|
fieldsListView.model.index(index,
|
||||||
|
1), text)
|
||||||
|
}
|
||||||
|
Kirigami.Icon {
|
||||||
|
source: "handle-right"
|
||||||
|
width: Kirigami.Units.iconSizes.smallMedium
|
||||||
|
height: Kirigami.Units.iconSizes.smallMedium
|
||||||
|
Layout.fillHeight: true
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
onClicked: fieldContextMenu.popup()
|
||||||
|
onPressAndHold: fieldContextMenu.popup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Controls.Menu {
|
||||||
|
id: fieldContextMenu
|
||||||
|
Controls.MenuItem {
|
||||||
|
icon.name: model.isPassword ? "password-show-off" : "password-show-on"
|
||||||
|
text: model.isPassword ? qsTr("Mark as normal field") : qsTr(
|
||||||
|
"Mark as password field")
|
||||||
|
onClicked: fieldsListView.model.setData(
|
||||||
|
fieldsListView.model.index(index, 0),
|
||||||
|
model.isPassword ? 0 : 1, 0x0100 + 1)
|
||||||
|
}
|
||||||
|
Controls.MenuItem {
|
||||||
|
icon.name: "edit-copy"
|
||||||
|
text: qsTr("Copy password")
|
||||||
|
onClicked: showPassiveNotification(
|
||||||
|
nativeInterface.copyToClipboard(
|
||||||
|
model.actualValue) ? qsTr("Copied") : qsTr(
|
||||||
|
"Unable to access clipboard"))
|
||||||
|
}
|
||||||
|
Controls.MenuItem {
|
||||||
|
icon.name: "edit-delete"
|
||||||
|
text: qsTr("Delete field")
|
||||||
|
onClicked: fieldsListView.model.removeRows(index, 1)
|
||||||
|
}
|
||||||
|
Controls.MenuItem {
|
||||||
|
icon.name: "list-add"
|
||||||
|
text: qsTr("Insert empty field after this")
|
||||||
|
onClicked: fieldsListView.model.insertRows(index + 1, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// list view to edit the currently selected account
|
||||||
|
ListView {
|
||||||
|
id: fieldsListView
|
||||||
|
implicitWidth: Kirigami.Units.gridUnit * 30
|
||||||
|
model: nativeInterface.fieldModel
|
||||||
|
moveDisplaced: Transition {
|
||||||
|
YAnimator {
|
||||||
|
duration: Kirigami.Units.longDuration
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delegate: Kirigami.DelegateRecycler {
|
||||||
|
width: parent ? parent.width : implicitWidth
|
||||||
|
sourceComponent: fieldsListDelegateComponent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
qml/main.qml
11
qml/main.qml
|
@ -201,6 +201,13 @@ Kirigami.ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: fieldsComponent
|
||||||
|
FieldsPage {
|
||||||
|
main: root
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function clearStack() {
|
function clearStack() {
|
||||||
pageStack.pop(root.pageStack.initialPage, Controls.StackView.Immediate)
|
pageStack.pop(root.pageStack.initialPage, Controls.StackView.Immediate)
|
||||||
}
|
}
|
||||||
|
@ -214,6 +221,10 @@ Kirigami.ApplicationWindow {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pushAccountEdit() {
|
||||||
|
pageStack.push(fieldsComponent.createObject(root))
|
||||||
|
}
|
||||||
|
|
||||||
function createFileActions(files) {
|
function createFileActions(files) {
|
||||||
return files.map(function (filePath) {
|
return files.map(function (filePath) {
|
||||||
return this.createObject(root, {
|
return this.createObject(root, {
|
||||||
|
|
|
@ -7,5 +7,6 @@
|
||||||
<file alias="BasicDialog.qml">../qml/BasicDialog.qml</file>
|
<file alias="BasicDialog.qml">../qml/BasicDialog.qml</file>
|
||||||
<file alias="PasswordDialog.qml">../qml/PasswordDialog.qml</file>
|
<file alias="PasswordDialog.qml">../qml/PasswordDialog.qml</file>
|
||||||
<file alias="EntriesPage.qml">../qml/EntriesPage.qml</file>
|
<file alias="EntriesPage.qml">../qml/EntriesPage.qml</file>
|
||||||
|
<file alias="FieldsPage.qml">../qml/FieldsPage.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Loading…
Reference in New Issue