Skip to content

Commit

Permalink
Merging develop to Master for 4.3.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Ney committed Dec 1, 2020
2 parents d684c44 + a638665 commit 51f3443
Show file tree
Hide file tree
Showing 27 changed files with 346 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .github/scripts/05-binary-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
OS=${1}
GITHUB_WORKSPACE=${2}

export BOOST_TEST_LOG_LEVEL=error
# "all" is too much log information. This will increase from verbosity from error"
#export BOOST_TEST_LOG_LEVEL=all

if [[ ${OS} == "windows" ]]; then
echo "----------------------------------------"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-raven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- release*
pull_request:
branches:
- master
- develop
- release*
paths-ignore:
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 4)
define(_CLIENT_VERSION_MINOR, 3)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2020)
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ RES_ICONS = \
qt/res/icons/editcopy.png \
qt/res/icons/editpaste.png \
qt/res/icons/export.png \
qt/res/icons/external_link.png \
qt/res/icons/external_link_dark.png \
qt/res/icons/eye.png \
qt/res/icons/eye_minus.png \
qt/res/icons/eye_plus.png \
Expand Down
185 changes: 183 additions & 2 deletions src/chainparamsseeds.h

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/bind.hpp>
// Fixing Boost 1.73 compile errors
#include <boost/bind/bind.hpp>
using namespace boost::placeholders;
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/thread.hpp>
#include <openssl/crypto.h>
Expand Down
7 changes: 4 additions & 3 deletions src/qt/assetrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class AssetRecord
public:

AssetRecord():
name(""), quantity(0), units(0), fIsAdministrator(false)
name(""), quantity(0), units(0), fIsAdministrator(false), ipfshash("")
{
}

AssetRecord(const std::string _name, const CAmount& _quantity, const int _units, const bool _fIsAdministrator):
name(_name), quantity(_quantity), units(_units), fIsAdministrator(_fIsAdministrator)
AssetRecord(const std::string _name, const CAmount& _quantity, const int _units, const bool _fIsAdministrator, const std::string _ipfshash):
name(_name), quantity(_quantity), units(_units), fIsAdministrator(_fIsAdministrator), ipfshash(_ipfshash)
{
}

Expand All @@ -48,6 +48,7 @@ class AssetRecord
CAmount quantity;
int units;
bool fIsAdministrator;
std::string ipfshash;
/**@}*/

};
Expand Down
30 changes: 27 additions & 3 deletions src/qt/assettablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class AssetTablePriv {
// retrieve units for asset
uint8_t units = OWNER_UNITS;
bool fIsAdministrator = true;
std::string ipfsHash = "";

if (setAssetsToSkip.count(bal->first))
continue;
Expand All @@ -67,6 +68,7 @@ class AssetTablePriv {
return;
}
units = assetData.units;
ipfsHash = assetData.strIPFSHash;
// If we have the administrator asset, add it to the skip listå
if (balances.count(bal->first + OWNER_TAG)) {
setAssetsToSkip.insert(bal->first + OWNER_TAG);
Expand All @@ -82,7 +84,7 @@ class AssetTablePriv {
continue;
}
}
cachedBalances.append(AssetRecord(bal->first, bal->second, units, fIsAdministrator));
cachedBalances.append(AssetRecord(bal->first, bal->second, units, fIsAdministrator, EncodeAssetData(ipfsHash)));
}
}
}
Expand Down Expand Up @@ -158,8 +160,25 @@ QVariant AssetTableModel::data(const QModelIndex &index, int role) const
case FormattedAmountRole:
return QString::fromStdString(rec->formattedQuantity());
case AdministratorRole:
{
return rec->fIsAdministrator;
case AssetIPFSHashRole:
return QString::fromStdString(rec->ipfshash);
case AssetIPFSHashDecorationRole:
{
if (index.column() == Quantity)
return QVariant();

if (rec->ipfshash.size() == 0)
return QVariant();

QPixmap pixmap;

if (darkModeEnabled)
pixmap = QPixmap::fromImage(QImage(":/icons/external_link_dark"));
else
pixmap = QPixmap::fromImage(QImage(":/icons/external_link"));

return pixmap;
}
case Qt::DecorationRole:
{
Expand Down Expand Up @@ -235,7 +254,7 @@ QModelIndex AssetTableModel::index(int row, int column, const QModelIndex &paren

QString AssetTableModel::formatTooltip(const AssetRecord *rec) const
{
QString tooltip = formatAssetName(rec) + QString("\n") + formatAssetQuantity(rec);
QString tooltip = formatAssetName(rec) + QString("\n") + formatAssetQuantity(rec) + QString("\n") + formatAssetData(rec);
return tooltip;
}

Expand All @@ -247,4 +266,9 @@ QString AssetTableModel::formatAssetName(const AssetRecord *wtx) const
QString AssetTableModel::formatAssetQuantity(const AssetRecord *wtx) const
{
return QString::fromStdString(wtx->formattedQuantity());
}

QString AssetTableModel::formatAssetData(const AssetRecord *wtx) const
{
return QString::fromStdString(wtx->ipfshash);
}
7 changes: 6 additions & 1 deletion src/qt/assettablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ class AssetTableModel : public QAbstractTableModel
/** Formatted amount, without brackets when unconfirmed */
FormattedAmountRole = 102,
/** AdministratorRole */
AdministratorRole = 103
AdministratorRole = 103,
/** RVN or name of an asset */
AssetIPFSHashRole = 104,
/** IPFS Decoration Role */
AssetIPFSHashDecorationRole = 105
};

int rowCount(const QModelIndex &parent) const;
Expand All @@ -52,6 +56,7 @@ class AssetTableModel : public QAbstractTableModel
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
QString formatTooltip(const AssetRecord *rec) const;
QString formatAssetData(const AssetRecord *wtx) const;
QString formatAssetName(const AssetRecord *wtx) const;
QString formatAssetQuantity(const AssetRecord *wtx) const;

Expand Down
3 changes: 3 additions & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <QDebug>
#include <QTimer>

// Fixing Boost 1.73 compile errors
#include <boost/bind/bind.hpp>
using namespace boost::placeholders;
class CBlockIndex;

static int64_t nLastHeaderTipUpdateNotification = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/qt/myrestrictedassettablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include <QIcon>
#include <QList>

// Fixing Boost 1.73 compile errors
#include <boost/bind/bind.hpp>
using namespace boost::placeholders;

// Amount column is right-aligned it contains numbers
static int column_alignments[] = {
Qt::AlignLeft|Qt::AlignVCenter, /* date */
Expand Down
75 changes: 66 additions & 9 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <QAbstractItemDelegate>
#include <QPainter>
#include <QDesktopServices>
#include <QMouseEvent>
#include <validation.h>
#include <utiltime.h>

Expand All @@ -29,8 +31,10 @@

#include <QDebug>
#include <QTimer>
#include <QPainterPath>
#include <QGraphicsDropShadowEffect>
#include <QScrollBar>
#include <QUrl>

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
#define QTversionPreFiveEleven
Expand Down Expand Up @@ -163,11 +167,13 @@ Q_OBJECT

/** Get the icon for the administrator of the asset */
QPixmap pixmap = qvariant_cast<QPixmap>(index.data(Qt::DecorationRole));
QPixmap ipfspixmap = qvariant_cast<QPixmap>(index.data(AssetTableModel::AssetIPFSHashDecorationRole));

bool admin = index.data(AssetTableModel::AdministratorRole).toBool();

/** Need to know the heigh to the pixmap. If it is 0 we don't we dont own this asset so dont have room for the icon */
int nIconSize = admin ? pixmap.height() : 0;
int nIPFSIconSize = ipfspixmap.height();
int extraNameSpacing = 12;
if (nIconSize)
extraNameSpacing = 0;
Expand All @@ -188,7 +194,8 @@ Q_OBJECT
/** Create the three main rectangles (Icon, Name, Amount) */
QRect assetAdministratorRect(QPoint(20, gradientRect.top() + halfheight/2 - 3*ypad), QSize(nIconSize, nIconSize));
QRect assetNameRect(gradientRect.left() + xspace - extraNameSpacing, gradientRect.top()+ypad+(halfheight/2), gradientRect.width() - xspace, halfheight + ypad);
QRect amountRect(gradientRect.left() + xspace, gradientRect.top()+ypad+(halfheight/2), gradientRect.width() - xspace - 16, halfheight);
QRect amountRect(gradientRect.left() + xspace, gradientRect.top()+ypad+(halfheight/2), gradientRect.width() - xspace - 24, halfheight);
QRect ipfsLinkRect(QPoint(gradientRect.right() - nIconSize/2, gradientRect.top() + halfheight/1.5), QSize(nIconSize/2, nIconSize/2));

// Create the gradient for the asset items
QLinearGradient gradient(mainRect.topLeft(), mainRect.bottomRight());
Expand Down Expand Up @@ -224,6 +231,9 @@ Q_OBJECT
if (nIconSize)
painter->drawPixmap(assetAdministratorRect, pixmap);

if (nIPFSIconSize)
painter->drawPixmap(ipfsLinkRect, ipfspixmap);

/** Create the font that is used for painting the asset name */
QFont nameFont;
#if !defined(Q_OS_MAC)
Expand Down Expand Up @@ -271,7 +281,6 @@ Q_OBJECT
painter->setPen(penName);
painter->drawText(assetNameRect, Qt::AlignLeft|Qt::AlignVCenter, name);


/** Paint the amount */
painter->setFont(amountFont);
painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
Expand Down Expand Up @@ -338,7 +347,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent)
connect(asset_typing_delay, SIGNAL(timeout()), this, SLOT(assetSearchChanged()));

connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex)));
connect(ui->listAssets, SIGNAL(clicked(QModelIndex)), this, SLOT(handleAssetClicked(QModelIndex)));
ui->listAssets->viewport()->installEventFilter(this);

// start with displaying the "out of sync" warnings
showOutOfSyncWarning(true);
Expand Down Expand Up @@ -409,43 +418,78 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent)
issueSub = new QAction(tr("Issue Sub Asset"), this);
issueUnique = new QAction(tr("Issue Unique Asset"), this);
reissue = new QAction(tr("Reissue Asset"), this);
openURL = new QAction(tr("Open IPFS in Browser"), this);

sendAction->setObjectName("Send");
issueSub->setObjectName("Sub");
issueUnique->setObjectName("Unique");
reissue->setObjectName("Reissue");
copyNameAction->setObjectName("Copy Name");
copyAmountAction->setObjectName("Copy Amount");
openURL->setObjectName("Browse");

// context menu
contextMenu = new QMenu(this);
contextMenu->addAction(sendAction);
contextMenu->addAction(issueSub);
contextMenu->addAction(issueUnique);
contextMenu->addAction(reissue);
contextMenu->addAction(openURL);
contextMenu->addSeparator();
contextMenu->addAction(copyNameAction);
contextMenu->addAction(copyAmountAction);
// context menu signals
}

bool OverviewPage::eventFilter(QObject *object, QEvent *event)
{
// If the asset viewport is being clicked
if (object == ui->listAssets->viewport() && event->type() == QEvent::MouseButtonPress) {

// Grab the mouse event
QMouseEvent * mouseEv = static_cast<QMouseEvent*>(event);

// Select the current index at the mouse location
QModelIndex currentIndex = ui->listAssets->indexAt(mouseEv->pos());

// Open the menu on right click, direct url on left click
if (mouseEv->buttons() & Qt::RightButton ) {
handleAssetRightClicked(currentIndex);
} else if (mouseEv->buttons() & Qt::LeftButton) {
openIPFSForAsset(currentIndex);
}
}

return QWidget::eventFilter(object, event);
}

void OverviewPage::handleTransactionClicked(const QModelIndex &index)
{
if(filter)
Q_EMIT transactionClicked(filter->mapToSource(index));
}

void OverviewPage::handleAssetClicked(const QModelIndex &index)
void OverviewPage::handleAssetRightClicked(const QModelIndex &index)
{
if(assetFilter) {
// Grab the data elements from the index that we need to disable and enable menu items
QString name = index.data(AssetTableModel::AssetNameRole).toString();
QString ipfshash = index.data(AssetTableModel::AssetIPFSHashRole).toString();

if (IsAssetNameAnOwner(name.toStdString())) {
name = name.left(name.size() - 1);
sendAction->setDisabled(true);
} else {
sendAction->setDisabled(false);
}

// If the ipfs hash isn't there or doesn't start with Qm, disable the action item
if (ipfshash.count() > 0 && ipfshash.indexOf("Qm") == 0) {
openURL->setDisabled(false);
} else {
openURL->setDisabled(true);
}

if (!index.data(AssetTableModel::AdministratorRole).toBool()) {
issueSub->setDisabled(true);
issueUnique->setDisabled(true);
Expand All @@ -466,20 +510,22 @@ void OverviewPage::handleAssetClicked(const QModelIndex &index)

if (action) {
if (action->objectName() == "Send")
Q_EMIT assetSendClicked(assetFilter->mapToSource(index));
Q_EMIT assetSendClicked(assetFilter->mapToSource(index));
else if (action->objectName() == "Sub")
Q_EMIT assetIssueSubClicked(assetFilter->mapToSource(index));
Q_EMIT assetIssueSubClicked(assetFilter->mapToSource(index));
else if (action->objectName() == "Unique")
Q_EMIT assetIssueUniqueClicked(assetFilter->mapToSource(index));
Q_EMIT assetIssueUniqueClicked(assetFilter->mapToSource(index));
else if (action->objectName() == "Reissue")
Q_EMIT assetReissueClicked(assetFilter->mapToSource(index));
Q_EMIT assetReissueClicked(assetFilter->mapToSource(index));
else if (action->objectName() == "Copy Name")
GUIUtil::setClipboard(index.data(AssetTableModel::AssetNameRole).toString());
else if (action->objectName() == "Copy Amount")
GUIUtil::setClipboard(index.data(AssetTableModel::FormattedAmountRole).toString());
else if (action->objectName() == "Browse") {
QDesktopServices::openUrl(QUrl::fromUserInput("https://cloudflare-ipfs.com/ipfs/" + ipfshash));
}
}
}

}

void OverviewPage::handleOutOfSyncWarningClicks()
Expand Down Expand Up @@ -645,3 +691,14 @@ void OverviewPage::assetSearchChanged()
return;
assetFilter->setAssetNamePrefix(ui->assetSearch->text());
}

void OverviewPage::openIPFSForAsset(const QModelIndex &index)
{
// Get the ipfs hash of the asset clicked
QString ipfshash = index.data(AssetTableModel::AssetIPFSHashRole).toString();

// If the ipfs hash isn't there or doesn't start with Qm, disable the action item
if (ipfshash.count() > 0 && ipfshash.indexOf("Qm") == 0) {
QDesktopServices::openUrl(QUrl::fromUserInput("https://cloudflare-ipfs.com/ipfs/" + ipfshash));
}
}
Loading

0 comments on commit 51f3443

Please sign in to comment.