From 0ba22ea05b742873dba97850c389d77d37f4af8e Mon Sep 17 00:00:00 2001 From: tobtoht Date: Sat, 30 Dec 2023 16:46:14 +0100 Subject: [PATCH] history: add option to show full txid --- src/model/HistoryView.cpp | 15 +++++++++++++++ src/model/HistoryView.h | 1 + src/model/TransactionHistoryModel.cpp | 3 +++ src/utils/config.cpp | 3 +++ src/utils/config.h | 5 ++++- 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/model/HistoryView.cpp b/src/model/HistoryView.cpp index 9fe311d..218ad50 100644 --- a/src/model/HistoryView.cpp +++ b/src/model/HistoryView.cpp @@ -5,6 +5,7 @@ #include "TransactionHistoryProxyModel.h" #include "utils/Utils.h" +#include "utils/config.h" #include #include @@ -56,6 +57,10 @@ void HistoryView::setHistoryModel(TransactionHistoryProxyModel *model) { } connect(m_columnActions, &QActionGroup::triggered, this, &HistoryView::toggleColumnVisibility); + m_headerMenu->addSeparator(); + auto action = m_headerMenu->addAction("Show full txid", this, &HistoryView::showFullTxid); + action->setCheckable(true); + action->setChecked(conf()->get(Config::historyShowFullTxid).toBool()); m_headerMenu->addSeparator(); m_headerMenu->addAction(tr("Fit to window"), this, &HistoryView::fitColumnsToWindow); m_headerMenu->addAction(tr("Fit to contents"), this, &HistoryView::fitColumnsToContents); @@ -154,6 +159,16 @@ void HistoryView::toggleColumnVisibility(QAction* action) action->setChecked(true); } +void HistoryView::showFullTxid(bool enabled) { + conf()->set(Config::historyShowFullTxid, enabled); + this->reset(); + + + if (!enabled) { + this->resizeColumnToContents(TransactionHistoryModel::TxID); + } +} + void HistoryView::fitColumnsToWindow() { header()->setSectionResizeMode(QHeaderView::ResizeToContents); diff --git a/src/model/HistoryView.h b/src/model/HistoryView.h index bab00f3..57262e0 100644 --- a/src/model/HistoryView.h +++ b/src/model/HistoryView.h @@ -27,6 +27,7 @@ public: private slots: void showHeaderMenu(const QPoint& position); void toggleColumnVisibility(QAction* action); + void showFullTxid(bool enabled); void fitColumnsToWindow(); void fitColumnsToContents(); void resetViewToDefaults(); diff --git a/src/model/TransactionHistoryModel.cpp b/src/model/TransactionHistoryModel.cpp index dd7eb74..2ea28a9 100644 --- a/src/model/TransactionHistoryModel.cpp +++ b/src/model/TransactionHistoryModel.cpp @@ -163,6 +163,9 @@ QVariant TransactionHistoryModel::parseTransactionInfo(const TransactionRow &tIn return amount; } case Column::TxID: { + if (conf()->get(Config::historyShowFullTxid).toBool()) { + return tInfo.hash(); + } return Utils::displayAddress(tInfo.hash(), 1); } case Column::FiatAmount: diff --git a/src/utils/config.cpp b/src/utils/config.cpp index 1ad5f38..0670df4 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -46,6 +46,9 @@ static const QHash configStrings = { {Config::enabledTabs, {QS("enabledTabs"), QStringList{"Home", "History", "Send", "Receive", "Calc"}}}, {Config::showSearchbar,{QS("showSearchbar"), true}}, + // History + {Config::historyShowFullTxid, {QS("historyShowFullTxid"), false}}, + // Receive {Config::showUsedAddresses,{QS("showUsedAddresses"), false}}, {Config::showHiddenAddresses,{QS("showHiddenAddresses"), false}}, diff --git a/src/utils/config.h b/src/utils/config.h index 224e305..cbc8878 100644 --- a/src/utils/config.h +++ b/src/utils/config.h @@ -48,7 +48,10 @@ public: // Tabs enabledTabs, showSearchbar, - + + // History + historyShowFullTxid, + // Receive showUsedAddresses, showHiddenAddresses,