mirror of
https://github.com/seiichiro0185/sailotp.git
synced 2024-11-14 21:16:42 +00:00
#38: Add a search box to the main view.
This commit is contained in:
parent
f1d195fa1d
commit
da4f2bbd73
2 changed files with 49 additions and 21 deletions
|
@ -65,7 +65,7 @@ ApplicationWindow
|
||||||
|
|
||||||
// Add an entry to the list
|
// Add an entry to the list
|
||||||
function appendOTP(title, secret, type, counter, fav, len, diff) {
|
function appendOTP(title, secret, type, counter, fav, len, diff) {
|
||||||
listModel.append({"secret": secret, "title": title, "fav": fav, "type": type, "counter": counter, "len": len, "diff": diff, "otp": "------"});
|
listModel.append({"secret": secret, "title": title, "fav": fav, "type": type, "counter": counter, "len": len, "diff": diff, "otp": "------", "itemVisible": true});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the OTP shown on the Cover
|
// Set the OTP shown on the Cover
|
||||||
|
|
|
@ -130,12 +130,15 @@ Page {
|
||||||
hintText: qsTr("Pull down to add a OTP")
|
hintText: qsTr("Pull down to add a OTP")
|
||||||
}
|
}
|
||||||
|
|
||||||
header: Row {
|
header: Column {
|
||||||
|
width: parent.width
|
||||||
|
height: headerRow.height + searchRow.height
|
||||||
|
Row {
|
||||||
|
id: headerRow
|
||||||
height: Theme.itemSizeSmall
|
height: Theme.itemSizeSmall
|
||||||
width: parent.width
|
width: parent.width
|
||||||
ProgressBar {
|
ProgressBar {
|
||||||
id: updateProgress
|
id: updateProgress
|
||||||
anchors.top: parent.top
|
|
||||||
// Hack to get the Progress Bar in roughly the same spot on Light and Dark Ambiances
|
// Hack to get the Progress Bar in roughly the same spot on Light and Dark Ambiances
|
||||||
anchors.topMargin: Theme.colorScheme === 0 ? Theme.paddingLarge * 1.1 : Theme.paddingSmall * 0.6
|
anchors.topMargin: Theme.colorScheme === 0 ? Theme.paddingLarge * 1.1 : Theme.paddingSmall * 0.6
|
||||||
height: Theme.itemSizeSmall
|
height: Theme.itemSizeSmall
|
||||||
|
@ -153,12 +156,37 @@ Page {
|
||||||
title: "SailOTP"
|
title: "SailOTP"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Row {
|
||||||
|
id: searchRow
|
||||||
|
width: parent.width
|
||||||
|
TextField {
|
||||||
|
id: searchField
|
||||||
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
|
width: parent.width - clearIcon.width
|
||||||
|
EnterKey.enabled: false
|
||||||
|
inputMethodHints: Qt.ImhNoPredictiveText // Qt.ImhPreferUppercase | Qt.ImhNoAutoUppercase
|
||||||
|
placeholderText: qsTr("Search")
|
||||||
|
onTextChanged: {
|
||||||
|
for (var i = 0; i < appWin.listModel.count; i++) {
|
||||||
|
appWin.listModel.get(i).itemVisible = appWin.listModel.get(i).title.toString().indexOf(searchField.text) > -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IconButton {
|
||||||
|
id: clearIcon
|
||||||
|
icon.source: "image://theme/icon-m-backspace"
|
||||||
|
onClicked: searchField.text = ""
|
||||||
|
enabled: searchField.text.length > 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delegate: ListItem {
|
delegate: ListItem {
|
||||||
id: otpListItem
|
id: otpListItem
|
||||||
menu: otpContextMenu
|
menu: otpContextMenu
|
||||||
contentHeight: Theme.itemSizeMedium
|
contentHeight: visible ? Theme.itemSizeMedium : 0
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
visible: itemVisible
|
||||||
|
|
||||||
function remove() {
|
function remove() {
|
||||||
// Show 5s countdown, then delete from DB and List
|
// Show 5s countdown, then delete from DB and List
|
||||||
|
@ -237,7 +265,7 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show an update button on HTOP-Type Tokens
|
// Show an update button on HOTP type tokens
|
||||||
IconButton {
|
IconButton {
|
||||||
icon.source: "image://theme/icon-m-refresh"
|
icon.source: "image://theme/icon-m-refresh"
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
Loading…
Reference in a new issue