Files

91 lines
3.6 KiB
QML
Raw Permalink Normal View History

/*
* This file is part of the Flowee project
2024-02-10 14:42:03 +01:00
* Copyright (C) 2022-2024 Tom Zander <tom@flowee.org>
*
* 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/>.
*/
2022-11-26 10:46:57 +01:00
import QtQuick
2025-06-18 17:48:29 +02:00
import QtQuick.Controls.Basic as QQC2
ConfigItem {
id: root
property QtObject account: null
2024-05-28 23:23:31 +02:00
property QtObject detailsAction: QQC2.Action {
text: qsTr("Details")
onTriggered: {
portfolio.current = root.account;
accountOverlay.state = "accountDetails";
}
}
2024-05-28 23:23:31 +02:00
property QtObject archiveAction: QQC2.Action {
2022-09-07 20:32:05 +02:00
text: root.account != null && root.account.isArchived ? qsTr("Unarchive") : qsTr("Archive Wallet")
2024-02-10 14:42:03 +01:00
onTriggered: {
/*
* Toggling archive means this list and the list-item will be removed and a new one created at
* another place on screen.
* Focus is lost when the item that holds it suddenly dies, so let make sure it is moved
* somewhere useful first, allowing keyboard shortcuts to still work after.
*/
mainScreen.forceActiveFocus(); // when the parent item is removed, make sure _something_ has focus
root.account.isArchived = !root.account.isArchived
}
}
2024-05-28 23:23:31 +02:00
property QtObject primaryAction: QQC2.Action {
2022-12-19 14:06:27 +01:00
enabled: root.account != null && !root.account.isPrimaryAccount
text: enabled ? qsTr("Make Primary") : qsTr("★ Primary")
2022-12-19 14:06:27 +01:00
onTriggered: root.account.isPrimaryAccount = !root.account.isPrimaryAccount
}
2024-05-28 23:23:31 +02:00
property QtObject encryptAction: QQC2.Action {
text: qsTr("Protect With Pin...")
onTriggered: {
portfolio.current = root.account;
accountOverlay.state = "startWalletEncryption";
}
}
2024-05-28 23:23:31 +02:00
property QtObject openWalletAction: QQC2.Action {
text: qsTr("Open", "Open encrypted wallet")
onTriggered: tabbar.currentIndex = 0
}
2024-05-28 23:23:31 +02:00
property QtObject closeWalletAction: QQC2.Action {
text: qsTr("Close", "Close encrypted wallet")
onTriggered: root.account.closeWallet();
}
onAboutToOpen: {
var items = [];
2022-08-18 21:49:06 +02:00
var onMainView = (accountOverlay.state === "showTransactions")
2023-02-24 23:44:10 +01:00
if (onMainView
|| (accountOverlay.state === "accountDetails"
2023-05-01 21:11:54 +02:00
&& portfolio.current !== root.account))
2022-08-18 21:49:06 +02:00
items.push(detailsAction);
var encrypted = root.account.needsPinToOpen;
var decrypted = root.account.isDecrypted;
2023-06-28 22:46:22 +02:00
if (root.account.needsPinToPay && decrypted)
items.push(closeWalletAction);
2022-08-18 21:49:06 +02:00
if (onMainView && encrypted && !decrypted && tabbar.currentIndex != 0)
items.push(openWalletAction);
var singleAccountSetup = portfolio.singleAccountSetup
var isArchived = root.account.isArchived;
if (!singleAccountSetup && !isArchived)
items.push(primaryAction);
2023-02-24 23:44:10 +01:00
if (!encrypted)
items.push(encryptAction);
if (!singleAccountSetup)
items.push(archiveAction);
setMenuActions(items);
}
}