Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ RES_ICONS = \
qt/res/icons/about.png \
qt/res/icons/about_qt.png \
qt/res/icons/asset_administrator.png \
qt/res/icons/rectangle.png \
qt/res/icons/rectanglesvg.svg \
qt/res/icons/bluerectangle.png \
qt/res/icons/ravencointext.svg \
qt/res/icons/raven.ico \
qt/res/icons/raven_testnet.ico \
qt/res/icons/raven.png \
Expand Down
127 changes: 94 additions & 33 deletions src/qt/assetsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "platformstyle.h"
#include "sendassetsentry.h"
#include "walletmodel.h"
#include "assettablemodel.h"

#include "base58.h"
#include "chainparams.h"
Expand All @@ -27,7 +28,9 @@
#include "wallet/fees.h"
#include "createassetdialog.h"
#include "reissueassetdialog.h"
#include "guiconstants.h"

#include <QGraphicsDropShadowEffect>
#include <QFontMetrics>
#include <QMessageBox>
#include <QScrollBar>
Expand Down Expand Up @@ -116,9 +119,6 @@ AssetsDialog::AssetsDialog(const PlatformStyle *_platformStyle, QWidget *parent)
minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool());

/** RVN START */
connect(ui->createAssetButton, SIGNAL(clicked()), this, SLOT(createAssetButtonClicked()));
connect(ui->reissueAssetButton, SIGNAL(clicked()), this, SLOT(reissueAssetButtonClicked()));

// If the network is regtest. Add some helper buttons to the asset GUI
if (Params().NetworkIDString() != "regtest") {
ui->mineButton->hide();
Expand All @@ -129,6 +129,10 @@ AssetsDialog::AssetsDialog(const PlatformStyle *_platformStyle, QWidget *parent)
ui->mineBlocksCount->setToolTip(tr("The number of blocks to mine"));
connect(ui->mineButton, SIGNAL(clicked()), this, SLOT(mineButtonClicked()));
}

setupAssetControlFrame();
setupScrollView();
setupFeeControl();
/** RVN END */
}

Expand Down Expand Up @@ -226,6 +230,77 @@ AssetsDialog::~AssetsDialog()
delete ui;
}

void AssetsDialog::setupAssetControlFrame()
{
/** Update the assetcontrol frame */
ui->frameAssetControl->setStyleSheet(".QFrame {background-color: white; padding-top: 10px; padding-right: 5px; border: none;}");
ui->widgetAssetControl->setStyleSheet(".QWidget {background-color: transparent;}");
/** Create the shadow effects on the frames */

ui->frameAssetControl->setGraphicsEffect(GUIUtil::getShadowEffect());

ui->labelAssetControlFeatures->setStyleSheet(COLOR_LABEL_STRING);
ui->labelAssetControlFeatures->setFont(GUIUtil::getTopLabelFont());

ui->labelAssetControlQuantityText->setStyleSheet(COLOR_LABEL_STRING);
ui->labelAssetControlQuantityText->setFont(GUIUtil::getSubLabelFont());

ui->labelAssetControlAmountText->setStyleSheet(COLOR_LABEL_STRING);
ui->labelAssetControlAmountText->setFont(GUIUtil::getSubLabelFont());

ui->labelAssetControlFeeText->setStyleSheet(COLOR_LABEL_STRING);
ui->labelAssetControlFeeText->setFont(GUIUtil::getSubLabelFont());

ui->labelAssetControlAfterFeeText->setStyleSheet(COLOR_LABEL_STRING);
ui->labelAssetControlAfterFeeText->setFont(GUIUtil::getSubLabelFont());

ui->labelAssetControlBytesText->setStyleSheet(COLOR_LABEL_STRING);
ui->labelAssetControlBytesText->setFont(GUIUtil::getSubLabelFont());

ui->labelAssetControlLowOutputText->setStyleSheet(COLOR_LABEL_STRING);
ui->labelAssetControlLowOutputText->setFont(GUIUtil::getSubLabelFont());

ui->labelAssetControlChangeText->setStyleSheet(COLOR_LABEL_STRING);
ui->labelAssetControlChangeText->setFont(GUIUtil::getSubLabelFont());

// Align the other labels next to the input buttons to the text in the same height
ui->labelAssetControlAutomaticallySelected->setStyleSheet(COLOR_LABEL_STRING);

// Align the Custom change address checkbox
ui->checkBoxAssetControlChange->setStyleSheet(COLOR_LABEL_STRING);

}

void AssetsDialog::setupScrollView()
{
/** Update the scrollview*/
ui->scrollArea->setStyleSheet(".QScrollArea{background-color: white; border: none}");
ui->scrollArea->setGraphicsEffect(GUIUtil::getShadowEffect());

// Add some spacing so we can see the whole card
ui->entries->setContentsMargins(10,10,20,0);
ui->scrollAreaWidgetContents->setStyleSheet(".QWidget{ background-color: white;}");
}

void AssetsDialog::setupFeeControl()
{
/** Update the coincontrol frame */
ui->frameFee->setStyleSheet(" .QFrame {background-color: white; padding-top: 10px; padding-right: 5px; border: none;}");
/** Create the shadow effects on the frames */

ui->frameFee->setGraphicsEffect(GUIUtil::getShadowEffect());

ui->labelFeeHeadline->setStyleSheet(COLOR_LABEL_STRING);
ui->labelFeeHeadline->setFont(GUIUtil::getSubLabelFont());

ui->labelSmartFee3->setStyleSheet(COLOR_LABEL_STRING);
ui->labelCustomPerKilobyte->setStyleSheet(COLOR_LABEL_STRING);
ui->radioSmartFee->setStyleSheet(COLOR_LABEL_STRING);
ui->radioCustomFee->setStyleSheet(COLOR_LABEL_STRING);
ui->checkBoxMinimumFee->setStyleSheet(COLOR_LABEL_STRING);

}

void AssetsDialog::on_sendButton_clicked()
{
if(!model || !model->getOptionsModel())
Expand Down Expand Up @@ -887,36 +962,6 @@ void AssetsDialog::assetControlUpdateLabels()
}

/** RVN START */
void AssetsDialog::createAssetButtonClicked()
{
WalletModel::UnlockContext ctx(model->requestUnlock());
if(!ctx.isValid())
{
// Unlock wallet was cancelled
return;
}

CreateAssetDialog dlg(platformStyle, 0, model, clientModel);
dlg.setModel(model);
dlg.setClientModel(clientModel);
dlg.exec();
}

void AssetsDialog::reissueAssetButtonClicked()
{
WalletModel::UnlockContext ctx(model->requestUnlock());
if(!ctx.isValid())
{
// Unlock wallet was cancelled
return;
}

ReissueAssetDialog dlg(platformStyle, 0, model, clientModel);
dlg.setModel(model);
dlg.setClientModel(clientModel);
dlg.exec();
}

void AssetsDialog::mineButtonClicked()
{

Expand Down Expand Up @@ -965,4 +1010,20 @@ void AssetsDialog::processNewTransaction()
}
}
}

void AssetsDialog::focusAsset(const QModelIndex &idx)
{

clear();

SendAssetsEntry *entry = qobject_cast<SendAssetsEntry*>(ui->entries->itemAt(0)->widget());
if(entry)
{
SendAssetsRecipient recipient;
recipient.assetName = idx.data(AssetTableModel::AssetNameRole).toString();

entry->setValue(recipient);
entry->setFocus();
}
}
/** RVN END */
6 changes: 4 additions & 2 deletions src/qt/assetsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class AssetsDialog : public QDialog

void setClientModel(ClientModel *clientModel);
void setModel(WalletModel *model);
void setupAssetControlFrame();
void setupScrollView();
void setupFeeControl();

/** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907).
*/
Expand Down Expand Up @@ -99,10 +102,9 @@ private Q_SLOTS:
void customFeeFeatureChanged(bool);

/** RVN START */
void createAssetButtonClicked();
void reissueAssetButtonClicked();
void mineButtonClicked();
void assetControlUpdateSendCoinsDialog();
void focusAsset(const QModelIndex& index);
/** RVN END */

Q_SIGNALS:
Expand Down
25 changes: 25 additions & 0 deletions src/qt/assettablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,31 @@ QVariant AssetTableModel::data(const QModelIndex &index, int role) const
return QVariant();
AssetRecord *rec = static_cast<AssetRecord*>(index.internalPointer());

switch (role)
{
case AmountRole:
return rec->quantity;
case AssetNameRole:
return QString::fromStdString(rec->name);
case FormattedAmountRole:
return QString::fromStdString(rec->formattedQuantity());
case BackgroundRole:
{
if (rec->fIsAdministrator)
return QPixmap::fromImage(QImage(":/icons/rectangle"));
else
return QPixmap::fromImage(QImage(":/icons/bluerectangle"));
}
case AdministratorRole:
{
return rec->fIsAdministrator;
}
case Qt::DecorationRole:
{
QPixmap pixmap = QPixmap::fromImage(QImage(":/icons/asset_administrator"));
return rec->fIsAdministrator ? pixmap : QVariant();
}
}
switch (index.column())
{
case Name:
Expand Down
16 changes: 16 additions & 0 deletions src/qt/assettablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ class AssetTableModel : public QAbstractTableModel
Quantity = 1
};

/** Roles to get specific information from a transaction row.
These are independent of column.
*/
enum RoleIndex {
/** Net amount of transaction */
AmountRole = 100,
/** RVN or name of an asset */
AssetNameRole = 101,
/** Formatted amount, without brackets when unconfirmed */
FormattedAmountRole = 102,
/** Background image */
BackgroundRole = 103,
/** AdministratorRole */
AdministratorRole = 104
};

int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
Expand Down
Loading