Files

182 lines
6.5 KiB
QML
Raw Permalink Normal View History

2024-10-20 21:21:05 +02:00
/*
* This file is part of the Flowee project
* Copyright (C) 2024-2026 Tom Zander <tom@flowee.org>
2024-10-20 21:21:05 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick
2024-10-21 13:28:00 +02:00
import QtQuick.Layouts
2024-10-20 21:21:05 +02:00
import "../Flowee" as Flowee
import Flowee.org.pay
2024-10-20 21:21:05 +02:00
// the widget that shows up on the AccountHistory
// allowing one to change the timeline filters
Item {
id: root
2024-10-21 13:28:00 +02:00
implicitHeight: coreColumn.height + 10
width: parent.width
2024-10-20 21:21:05 +02:00
function toggleFlag(flag, on) {
var cf = portfolio.current.transactions.includeFlags
if (((cf & flag) > 0) === on) // nothing to do.
return
2024-10-20 21:21:05 +02:00
if (on)
cf += flag
2024-10-20 21:21:05 +02:00
else
cf -= flag
2024-10-20 21:21:05 +02:00
portfolio.current.transactions.includeFlags = cf
}
2024-10-21 13:28:00 +02:00
ColumnLayout {
2024-10-20 21:21:05 +02:00
id: coreColumn
2024-10-21 13:28:00 +02:00
width: parent.width
2024-10-20 21:21:05 +02:00
spacing: 10
Flowee.Label {
2024-10-23 12:50:31 +02:00
text: qsTr("Transactions Filter")
2024-10-20 21:21:05 +02:00
}
Flow {
width: parent.width
spacing: 12
2024-10-20 21:21:05 +02:00
Rectangle {
2024-10-21 13:28:00 +02:00
width: 80
height: 80
radius: 40
2024-10-20 21:21:05 +02:00
border.width: 3
2024-10-21 13:28:00 +02:00
color: checked ? palette.alternateBase : palette.base
border.color: checked ? palette.midlight : palette.mid
Image {
source: "qrc:/tx-receiving" + (Pay.useDarkSkin ? "-light.svg" : ".svg")
2024-10-21 13:28:00 +02:00
width: 50
height: 50
smooth: true
y: 11
x: 12
opacity: parent.checked ? 1 : 0.5
}
property bool checked: (portfolio.current.transactions.includeFlags
& Wallet.IncludeReceivedTransactions)
=== Wallet.IncludeReceivedTransactions
2024-10-20 21:21:05 +02:00
MouseArea {
anchors.fill: parent
onClicked: toggleFlag(Wallet.IncludeReceivedTransactions, !parent.checked)
}
Rectangle {
visible: !parent.checked
width: parent.width * 1.4
height: 3
anchors.centerIn: parent
rotation: -45
color: mainWindow.errorRedBg
2024-10-20 21:21:05 +02:00
}
}
Rectangle {
2024-10-21 13:28:00 +02:00
width: 80
height: 80
radius: 40
2024-10-20 21:21:05 +02:00
border.width: 3
2024-10-21 13:28:00 +02:00
color: checked ? palette.alternateBase : palette.base
border.color: checked ? palette.midlight : palette.mid
Image {
source: "qrc:/tx-send" + (Pay.useDarkSkin ? "-light.svg" : ".svg")
2024-10-21 13:28:00 +02:00
width: 50
height: 50
smooth: true
x: 15
y: 11
opacity: parent.checked ? 1 : 0.5
}
property bool checked: (portfolio.current.transactions.includeFlags
& Wallet.IncludeSentTransactions)
=== Wallet.IncludeSentTransactions
MouseArea {
anchors.fill: parent
onClicked: toggleFlag(Wallet.IncludeSentTransactions, !parent.checked)
}
Rectangle {
visible: !parent.checked
width: parent.width * 1.4
height: 3
anchors.centerIn: parent
rotation: -45
color: mainWindow.errorRedBg
}
}
Rectangle {
id: cfCheckbox
width: 80
height: 80
radius: 6
color: checked ? palette.alternateBase : palette.base
border.width: 3
border.color: checked ? palette.midlight : palette.mid
visible: portfolio.current.hasAnonimityTransactions
property bool checked: (portfolio.current.transactions.includeFlags
& Wallet.IncludeCFs) > 0
Image {
source: "qrc:/cf.svg"
width: 60
height: 60
smooth: true
anchors.centerIn: parent
opacity: cfCheckbox.checked ? 1 : 0.5
2024-10-20 21:21:05 +02:00
}
MouseArea {
anchors.fill: parent
onClicked: toggleFlag(Wallet.IncludeCFs, !cfCheckbox.checked)
2024-10-20 21:21:05 +02:00
}
}
}
2024-10-21 13:28:00 +02:00
Flowee.CheckBox {
id: commentCheckbox
2024-10-21 13:28:00 +02:00
width: parent.width
text: qsTr("Only with a comment", "This is a statement about a transaction")
2024-10-23 12:50:31 +02:00
checked: !(portfolio.current.transactions.includeFlags & Wallet.IncludeTxWithoutComment) > 0
onToggled: toggleFlag(Wallet.IncludeTxWithoutComment, !checked)
}
Flowee.TextField {
id: filterTextField
Layout.fillWidth: true
text: portfolio.current.transactions.filterString
2026-02-13 14:05:21 +01:00
onDisplayTextChanged: portfolio.current.transactions.filterString = displayText
placeholderText: qsTr("Filter on transaction details")
inputMethodHints: Qt.ImhNoAutoUppercase
Image {
source: "qrc:/backspace" + (Pay.useDarkSkin ? "-light.svg" : ".svg")
width: 22
height: 15
anchors.right: parent.right
anchors.rightMargin: 6
anchors.verticalCenter: parent.verticalCenter
MouseArea {
anchors.fill: parent
anchors.margins: -10
onClicked: {
filterTextField.text = ""
root.forceActiveFocus()
}
}
}
2024-10-21 13:28:00 +02:00
}
2024-10-20 21:21:05 +02:00
}
}