Skip to content

Commit

Permalink
Improvements of messages GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
xdn-project committed Jun 1, 2016
1 parent fb52b54 commit 69857c5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CryptoNoteWallet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set(CN_PROJECT_NAME "digitalnotewallet")
set(CN_CURRENCY_DISPLAY_NAME "DigitalNote")
set(CN_CURRENCY_TICKER "XDN")
set(CN_VERSION 1.0.8-beta)
set(CN_VERSION 1.0.9-beta)
8 changes: 4 additions & 4 deletions src/CryptoNoteWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class RpcNode : CryptoNote::INodeObserver, public Node {
const CryptoNote::Currency& m_currency;
CryptoNote::NodeRpcProxy m_node;

void peerCountUpdated(size_t count) {
void peerCountUpdated(size_t count) override {
m_callback.peerCountUpdated(*this, count);
}

Expand Down Expand Up @@ -242,15 +242,15 @@ class InprocessNode : CryptoNote::INodeObserver, public Node {
CryptoNote::InProcessNode m_node;
std::future<bool> m_nodeServerFuture;

void peerCountUpdated(size_t count) {
void peerCountUpdated(size_t count) override {
m_callback.peerCountUpdated(*this, count);
}

void localBlockchainUpdated(uint64_t height) {
void localBlockchainUpdated(uint32_t height) override {
m_callback.localBlockchainUpdated(*this, height);
}

void lastKnownBlockHeightUpdated(uint64_t height) {
void lastKnownBlockHeightUpdated(uint32_t height) override {
m_callback.lastKnownBlockHeightUpdated(*this, height);
}
};
Expand Down
24 changes: 11 additions & 13 deletions src/gui/SendMessageFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,17 @@ QString SendMessageFrame::extractAddress(const QString& _addressString) const {

void SendMessageFrame::recalculateFeeValue() {
QString messageText = m_ui->m_messageTextEdit->toPlainText();
quint32 messageSize = messageText.length() ;
quint32 messageSize = messageText.length();
if (messageSize > 0) {
--messageSize;
}

quint64 fee = MINIMAL_MESSAGE_FEE;
if (m_ui->m_ttlCheck->checkState() == Qt::Checked) {
fee = 0;
quint64 fee = MESSAGE_AMOUNT * m_addressFrames.size();
if (m_ui->m_ttlCheck->checkState() == Qt::Unchecked) {
fee += MINIMAL_MESSAGE_FEE + messageSize * MESSAGE_CHAR_PRICE;
}

m_ui->m_feeSpin->setMinimum(CurrencyAdapter::instance().formatAmount(MESSAGE_AMOUNT * m_addressFrames.size() +
fee + messageSize * MESSAGE_CHAR_PRICE).toDouble());
m_ui->m_feeSpin->setMinimum(CurrencyAdapter::instance().formatAmount(fee).toDouble());

m_ui->m_feeSpin->setValue(m_ui->m_feeSpin->minimum());
}
Expand Down Expand Up @@ -160,19 +159,18 @@ void SendMessageFrame::sendClicked() {
messages.append({messageString.toStdString(), address.toStdString()});
}

quint64 ttl = 0;
if (m_ui->m_ttlCheck->checkState() == Qt::Checked) {
ttl = QDateTime::currentDateTimeUtc().toTime_t() + m_ui->m_ttlSlider->value() * MIN_TTL;
}

quint64 fee = CurrencyAdapter::instance().parseAmount(m_ui->m_feeSpin->cleanText());
fee -= MESSAGE_AMOUNT * transfers.size();
if (fee < MINIMAL_MESSAGE_FEE) {
if (ttl == 0 && fee < MINIMAL_MESSAGE_FEE) {
QCoreApplication::postEvent(&MainWindow::instance(), new ShowMessageEvent(tr("Incorrect fee value"), QtCriticalMsg));
return;
}

quint64 ttl = 0;
if (m_ui->m_ttlCheck->checkState() == Qt::Checked) {
ttl = QDateTime::currentDateTimeUtc().toTime_t() + m_ui->m_ttlSlider->value() * MIN_TTL;
fee = 0;
}

if (WalletAdapter::instance().isOpen()) {
WalletAdapter::instance().sendMessage(transfers, fee, m_ui->m_mixinSlider->value(), messages, ttl);
}
Expand Down
4 changes: 4 additions & 0 deletions src/gui/TransactionsModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ QVariant TransactionsModel::getDisplayRole(const QModelIndex& _index) const {

QVariant TransactionsModel::getDecorationRole(const QModelIndex& _index) const {
if(_index.column() == COLUMN_STATE) {
if (_index.data(ROLE_FEE).toULongLong() == 0 && _index.data(ROLE_TYPE).value<quint8>() != static_cast<quint8>(TransactionType::MINED)) {
return QPixmap(":icons/tx-message").scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}

quint64 numberOfConfirmations = _index.data(ROLE_NUMBER_OF_CONFIRMATIONS).value<quint64>();
switch (numberOfConfirmations) {
case 0:
Expand Down
Binary file added src/icons/tx_message.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<file alias="mining">icons/mining.png</file>
<file alias="deposits">icons/deposits.png</file>
<file alias="tx-deposit">icons/tx_deposit.png</file>
<file alias="tx-message">icons/tx_message.png</file>
</qresource>
<qresource prefix="/images">
<file alias="splash">images/splash.png</file>
Expand Down

0 comments on commit 69857c5

Please sign in to comment.