Skip to content

Commit

Permalink
history: add option to show full txid
Browse files Browse the repository at this point in the history
  • Loading branch information
tobtoht committed Dec 30, 2023
1 parent 7e19d52 commit 0ba22ea
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/model/HistoryView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "TransactionHistoryProxyModel.h"
#include "utils/Utils.h"
#include "utils/config.h"

#include <QHeaderView>
#include <QMenu>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/model/HistoryView.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class HistoryView : public QTreeView
private slots:
void showHeaderMenu(const QPoint& position);
void toggleColumnVisibility(QAction* action);
void showFullTxid(bool enabled);
void fitColumnsToWindow();
void fitColumnsToContents();
void resetViewToDefaults();
Expand Down
3 changes: 3 additions & 0 deletions src/model/TransactionHistoryModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions src/utils/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ static const QHash<Config::ConfigKey, ConfigDirective> 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}},
Expand Down
5 changes: 4 additions & 1 deletion src/utils/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ class Config : public QObject
// Tabs
enabledTabs,
showSearchbar,


// History
historyShowFullTxid,

// Receive
showUsedAddresses,
showHiddenAddresses,
Expand Down

0 comments on commit 0ba22ea

Please sign in to comment.