forked from ciphrex/mSIGNA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignaturedialog.cpp
90 lines (72 loc) · 2.11 KB
/
signaturedialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
///////////////////////////////////////////////////////////////////////////////
//
// mSIGNA
//
// signaturedialog.cpp
//
// Copyright (c) 2013-2014 Eric Lombrozo
//
// All Rights Reserved.
#include "signaturedialog.h"
// Models/Views
#include "signaturemodel.h"
#include "signatureview.h"
#include "signatureactions.h"
#include <CoinDB/SynchedVault.h>
#include <QLabel>
#include <QVBoxLayout>
SignatureDialog::SignatureDialog(CoinDB::SynchedVault& synchedVault, const bytes_t& txHash, QWidget* parent)
: QDialog(parent), m_synchedVault(synchedVault)
{
resize(QSize(700, 200));
m_model = new SignatureModel(m_synchedVault, txHash, this);
m_model->updateAll();
m_view = new SignatureView(this);
m_view->setModel(m_model);
m_view->updateColumns();
m_actions = new SignatureActions(m_synchedVault, *this);
connect(m_actions, &SignatureActions::error, [this](const QString& msg) { emit error(msg); });
m_view->setMenu(m_actions->getMenu());
if (m_actions) { m_view->setMenu(m_actions->getMenu()); }
QLabel* hashLabel = new QLabel(tr("Hash: ") + QString::fromStdString(uchar_vector(txHash).getHex()));
m_sigsNeededLabel = new QLabel();
updateCaption();
QVBoxLayout* mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(hashLabel);
mainLayout->addWidget(m_sigsNeededLabel);
mainLayout->addWidget(m_view);
setLayout(mainLayout);
setWindowTitle(tr("Transaction Signatures"));
}
SignatureDialog::~SignatureDialog()
{
delete m_model;
delete m_view;
delete m_actions;
}
void SignatureDialog::updateTx()
{
updateKeychains();
updateCaption();
emit txUpdated();
}
void SignatureDialog::updateKeychains()
{
m_model->updateAll();
m_view->updateColumns();
emit keychainsUpdated();
}
void SignatureDialog::updateCaption()
{
unsigned int sigsNeeded = m_model->getSigsNeeded();
QString caption;
if (sigsNeeded == 0)
{
caption = tr("Transaction is signed.");
}
else
{
caption = tr("Additional signatures required: ") + QString::number(sigsNeeded);
}
m_sigsNeededLabel->setText(caption);
}