Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staking reward setup GUI #605

Merged
merged 23 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from 22 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
12 changes: 10 additions & 2 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ QT_MOC_CPP = \
qt/moc_communityfundcreatepaymentrequestdialog.cpp \
qt/moc_peertablemodel.cpp \
qt/moc_paymentserver.cpp \
qt/moc_qvalidatedlineedit.cpp \
qt/moc_qvalidatedplaintextedit.cpp \
qt/moc_qjsonmodel.cpp \
qt/moc_qvalidatedlineedit.cpp \
qt/moc_qvalidatedplaintextedit.cpp \
qt/moc_qvalidatedspinbox.cpp \
qt/moc_qvaluecombobox.cpp \
qt/moc_receivecoinsdialog.cpp \
Expand All @@ -171,6 +172,7 @@ QT_MOC_CPP = \
qt/moc_sendcommunityfunddialog.cpp \
qt/moc_communityfundsuccessdialog.cpp \
qt/moc_signverifymessagedialog.cpp \
qt/moc_splitrewards.cpp \
qt/moc_splashscreen.cpp \
qt/moc_trafficgraphwidget.cpp \
qt/moc_transactiondesc.cpp \
Expand Down Expand Up @@ -229,6 +231,8 @@ NAVCOIN_QT_H = \
qt/guiconstants.h \
qt/guiutil.h \
qt/intro.h \
qt/qjsonitem.h \
qt/qjsonmodel.h \
qt/listview.h \
qt/macdockiconhandler.h \
qt/macnotificationhandler.h \
Expand Down Expand Up @@ -268,6 +272,7 @@ NAVCOIN_QT_H = \
qt/communityfundsuccessdialog.h \
qt/signverifymessagedialog.h \
qt/skinize.h \
qt/splitrewards.h \
qt/splashscreen.h \
qt/trafficgraphwidget.h \
qt/transactiondesc.h \
Expand Down Expand Up @@ -414,6 +419,8 @@ NAVCOIN_QT_CPP += \
qt/communityfunddisplaydetailed.cpp \
qt/communityfundcreateproposaldialog.cpp \
qt/communityfundcreatepaymentrequestdialog.cpp \
qt/qjsonitem.cpp \
qt/qjsonmodel.cpp \
qt/paymentrequestplus.cpp \
qt/paymentserver.cpp \
qt/receivecoinsdialog.cpp \
Expand All @@ -424,6 +431,7 @@ NAVCOIN_QT_CPP += \
qt/sendcommunityfunddialog.cpp \
qt/communityfundsuccessdialog.cpp \
qt/signverifymessagedialog.cpp \
qt/splitrewards.cpp \
qt/transactiondesc.cpp \
qt/transactiondescdialog.cpp \
qt/transactionfilterproxy.cpp \
Expand Down
9 changes: 8 additions & 1 deletion src/qt/forms/overviewpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>822</width>
<height>690</height>
<height>755</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -1052,6 +1052,13 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Set up Staking Rewards</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="votingStatusLabel">
<property name="sizePolicy">
Expand Down
11 changes: 11 additions & 0 deletions src/qt/navcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ NavCoinGUI::NavCoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
unlockWalletAction(0),
lockWalletAction(0),
toggleStakingAction(0),
splitRewardAction(0),
lastDialogShown(0),
platformStyle(platformStyle),
updatePriceAction(0),
Expand Down Expand Up @@ -403,6 +404,9 @@ void NavCoinGUI::createActions()
toggleStakingAction = new QAction(tr("Toggle &Staking"), this);
toggleStakingAction->setStatusTip(tr("Toggle Staking"));

splitRewardAction = new QAction(tr("Set up staking rewards"), this);
splitRewardAction->setStatusTip(tr("Configure how to split the staking rewards"));

historyAction = new QAction(platformStyle->SingleColorIcon(":/icons/history"), tr("&Transactions"), this);
historyAction->setStatusTip(tr("Browse transaction history"));
historyAction->setToolTip(historyAction->statusTip());
Expand Down Expand Up @@ -431,6 +435,7 @@ void NavCoinGUI::createActions()
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
connect(toggleStakingAction, SIGNAL(triggered()), this, SLOT(toggleStaking()));
connect(splitRewardAction, SIGNAL(triggered()), this, SLOT(splitRewards()));
#endif // ENABLE_WALLET

quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), tr("E&xit"), this);
Expand Down Expand Up @@ -569,6 +574,7 @@ void NavCoinGUI::createMenuBar()
settings->addAction(changePassphraseAction);
settings->addSeparator();
settings->addAction(toggleStakingAction);
settings->addAction(splitRewardAction);
settings->addSeparator();
settings->addAction(updatePriceAction);
}
Expand Down Expand Up @@ -1632,6 +1638,11 @@ void NavCoinGUI::toggleStaking()
CClientUIInterface::MSG_INFORMATION);
}

void NavCoinGUI::splitRewards()
{
walletFrame->splitRewards();
}

#ifdef ENABLE_WALLET


Expand Down
2 changes: 2 additions & 0 deletions src/qt/navcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class NavCoinGUI : public QMainWindow
QAction *unlockWalletAction;
QAction *lockWalletAction;
QAction *toggleStakingAction;
QAction *splitRewardAction;
QPushButton *topMenu1; // Home
QPushButton *topMenu2; // Send
QPushButton *topMenu3; // Recieve
Expand Down Expand Up @@ -275,6 +276,7 @@ private Q_SLOTS:
void updateDisplayUnit(int unit);
/** Toggle Staking **/
void toggleStaking();
void splitRewards();
#ifndef Q_OS_MAC
/** Handle tray icon clicked */
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
Expand Down
7 changes: 7 additions & 0 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,10 @@ void OverviewPage::updateStakeReportNow()
{
updateStakeReport(true);
}

void OverviewPage::on_pushButton_clicked()
{
SplitRewardsDialog dlg(this);
dlg.setModel(walletModel);
dlg.exec();
}
5 changes: 3 additions & 2 deletions src/qt/overviewpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define NAVCOIN_QT_OVERVIEWPAGE_H

#include "amount.h"
#include "splitrewards.h"

#include <QWidget>
#include <QPushButton>
Expand Down Expand Up @@ -61,11 +62,11 @@ public Q_SLOTS:
void updateStakeReportNow();
void updateStakeReportbalanceChanged(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount);
void setVotingStatus(QString text);

void on_pushButton_clicked();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proletesseract could we maybe use another name for this method? it reads very generic and does not refer to its real meaning

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that was just what was autogenerated by QT Creator. I'll commit the change when i get a chance.


Q_SIGNALS:
void transactionClicked(const QModelIndex &index);
void outOfSyncWarningClicked();
void outOfSyncWarningClicked();

private:
Ui::OverviewPage *ui;
Expand Down
136 changes: 136 additions & 0 deletions src/qt/qjsonitem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/***********************************************
Copyright (C) 2014 Schutz Sacha
This file is part of QJsonModel (https://github.com/dridk/QJsonmodel).

QJsonModel is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

QJsonModel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with QJsonModel. If not, see <http://www.gnu.org/licenses/>.

**********************************************/

#include "qjsonitem.h"

QJsonTreeItem::QJsonTreeItem(QJsonTreeItem *parent)
{

mParent = parent;


}

QJsonTreeItem::~QJsonTreeItem()
{
qDeleteAll(mChilds);

}

void QJsonTreeItem::appendChild(QJsonTreeItem *item)
{
mChilds.append(item);
}

QJsonTreeItem *QJsonTreeItem::child(int row)
{
return mChilds.value(row);
}

QJsonTreeItem *QJsonTreeItem::parent()
{
return mParent;
}

int QJsonTreeItem::childCount() const
{
return mChilds.count();
}

int QJsonTreeItem::row() const
{
if (mParent)
return mParent->mChilds.indexOf(const_cast<QJsonTreeItem*>(this));

return 0;
}

void QJsonTreeItem::setKey(const QString &key)
{
mKey = key;
}

void QJsonTreeItem::setValue(const QString &value)
{
mValue = value;
}

void QJsonTreeItem::setType(const QJsonValue::Type &type)
{
mType = type;
}

QString QJsonTreeItem::key() const
{
return mKey;
}

QString QJsonTreeItem::value() const
{
return mValue;
}

QJsonValue::Type QJsonTreeItem::type() const
{
return mType;
}

QJsonTreeItem* QJsonTreeItem::load(const QJsonValue& value, QJsonTreeItem* parent)
{


QJsonTreeItem * rootItem = new QJsonTreeItem(parent);
rootItem->setKey("root");

if ( value.isObject())
{

//Get all QJsonValue childs
for (QString key: value.toObject().keys()){
QJsonValue v = value.toObject().value(key);
QJsonTreeItem * child = load(v,rootItem);
child->setKey(key);
child->setType(v.type());
rootItem->appendChild(child);

}

}

else if ( value.isArray())
{
//Get all QJsonValue childs
int index = 0;
for (QJsonValue v: value.toArray()){

QJsonTreeItem * child = load(v,rootItem);
child->setKey(QString::number(index));
child->setType(v.type());
rootItem->appendChild(child);
++index;
}
}
else
{
rootItem->setValue(value.toVariant().toString());
rootItem->setType(value.type());
}

return rootItem;
}
43 changes: 43 additions & 0 deletions src/qt/qjsonitem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef JSONITEM_H
#define JSONITEM_H

#include <QtCore>
#include <QJsonValue>
#include <QJsonArray>
#include <QJsonObject>

class QJsonTreeItem
{
public:
QJsonTreeItem(QJsonTreeItem * parent = 0);
~QJsonTreeItem();
void appendChild(QJsonTreeItem * item);
QJsonTreeItem *child(int row);
QJsonTreeItem *parent();
int childCount() const;
int row() const;
void setKey(const QString& key);
void setValue(const QString& value);
void setType(const QJsonValue::Type& type);
QString key() const;
QString value() const;
QJsonValue::Type type() const;


static QJsonTreeItem* load(const QJsonValue& value, QJsonTreeItem * parent = 0);

protected:


private:
QString mKey;
QString mValue;
QJsonValue::Type mType;

QList<QJsonTreeItem*> mChilds;
QJsonTreeItem * mParent;


};

#endif // JSONITEM_H
Loading