Skip to content

Commit 0b8cb5d

Browse files
Merge pull request #605 from aguycalled/split-staking-rewards
Staking reward setup GUI
2 parents c8d9d72 + 869676c commit 0b8cb5d

21 files changed

Lines changed: 950 additions & 120 deletions

‎src/Makefile.qt.include‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ QT_MOC_CPP = \
158158
qt/moc_communityfundcreatepaymentrequestdialog.cpp \
159159
qt/moc_peertablemodel.cpp \
160160
qt/moc_paymentserver.cpp \
161-
qt/moc_qvalidatedlineedit.cpp \
162-
qt/moc_qvalidatedplaintextedit.cpp \
161+
qt/moc_qjsonmodel.cpp \
162+
qt/moc_qvalidatedlineedit.cpp \
163+
qt/moc_qvalidatedplaintextedit.cpp \
163164
qt/moc_qvalidatedspinbox.cpp \
164165
qt/moc_qvaluecombobox.cpp \
165166
qt/moc_receivecoinsdialog.cpp \
@@ -171,6 +172,7 @@ QT_MOC_CPP = \
171172
qt/moc_sendcommunityfunddialog.cpp \
172173
qt/moc_communityfundsuccessdialog.cpp \
173174
qt/moc_signverifymessagedialog.cpp \
175+
qt/moc_splitrewards.cpp \
174176
qt/moc_splashscreen.cpp \
175177
qt/moc_trafficgraphwidget.cpp \
176178
qt/moc_transactiondesc.cpp \
@@ -229,6 +231,8 @@ NAVCOIN_QT_H = \
229231
qt/guiconstants.h \
230232
qt/guiutil.h \
231233
qt/intro.h \
234+
qt/qjsonitem.h \
235+
qt/qjsonmodel.h \
232236
qt/listview.h \
233237
qt/macdockiconhandler.h \
234238
qt/macnotificationhandler.h \
@@ -268,6 +272,7 @@ NAVCOIN_QT_H = \
268272
qt/communityfundsuccessdialog.h \
269273
qt/signverifymessagedialog.h \
270274
qt/skinize.h \
275+
qt/splitrewards.h \
271276
qt/splashscreen.h \
272277
qt/trafficgraphwidget.h \
273278
qt/transactiondesc.h \
@@ -414,6 +419,8 @@ NAVCOIN_QT_CPP += \
414419
qt/communityfunddisplaydetailed.cpp \
415420
qt/communityfundcreateproposaldialog.cpp \
416421
qt/communityfundcreatepaymentrequestdialog.cpp \
422+
qt/qjsonitem.cpp \
423+
qt/qjsonmodel.cpp \
417424
qt/paymentrequestplus.cpp \
418425
qt/paymentserver.cpp \
419426
qt/receivecoinsdialog.cpp \
@@ -424,6 +431,7 @@ NAVCOIN_QT_CPP += \
424431
qt/sendcommunityfunddialog.cpp \
425432
qt/communityfundsuccessdialog.cpp \
426433
qt/signverifymessagedialog.cpp \
434+
qt/splitrewards.cpp \
427435
qt/transactiondesc.cpp \
428436
qt/transactiondescdialog.cpp \
429437
qt/transactionfilterproxy.cpp \

‎src/qt/forms/overviewpage.ui‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>822</width>
10-
<height>690</height>
10+
<height>755</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -1052,6 +1052,13 @@
10521052
</property>
10531053
</widget>
10541054
</item>
1055+
<item alignment="Qt::AlignLeft">
1056+
<widget class="QPushButton" name="showStakingSetup">
1057+
<property name="text">
1058+
<string>Set up Staking Rewards</string>
1059+
</property>
1060+
</widget>
1061+
</item>
10551062
<item>
10561063
<widget class="QLabel" name="votingStatusLabel">
10571064
<property name="sizePolicy">

‎src/qt/navcoingui.cpp‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ NavCoinGUI::NavCoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
153153
unlockWalletAction(0),
154154
lockWalletAction(0),
155155
toggleStakingAction(0),
156+
splitRewardAction(0),
156157
lastDialogShown(0),
157158
platformStyle(platformStyle),
158159
updatePriceAction(0),
@@ -403,6 +404,9 @@ void NavCoinGUI::createActions()
403404
toggleStakingAction = new QAction(tr("Toggle &Staking"), this);
404405
toggleStakingAction->setStatusTip(tr("Toggle Staking"));
405406

407+
splitRewardAction = new QAction(tr("Set up staking rewards"), this);
408+
splitRewardAction->setStatusTip(tr("Configure how to split the staking rewards"));
409+
406410
historyAction = new QAction(platformStyle->SingleColorIcon(":/icons/history"), tr("&Transactions"), this);
407411
historyAction->setStatusTip(tr("Browse transaction history"));
408412
historyAction->setToolTip(historyAction->statusTip());
@@ -431,6 +435,7 @@ void NavCoinGUI::createActions()
431435
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
432436
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
433437
connect(toggleStakingAction, SIGNAL(triggered()), this, SLOT(toggleStaking()));
438+
connect(splitRewardAction, SIGNAL(triggered()), this, SLOT(splitRewards()));
434439
#endif // ENABLE_WALLET
435440

436441
quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), tr("E&xit"), this);
@@ -569,6 +574,7 @@ void NavCoinGUI::createMenuBar()
569574
settings->addAction(changePassphraseAction);
570575
settings->addSeparator();
571576
settings->addAction(toggleStakingAction);
577+
settings->addAction(splitRewardAction);
572578
settings->addSeparator();
573579
settings->addAction(updatePriceAction);
574580
}
@@ -1632,6 +1638,11 @@ void NavCoinGUI::toggleStaking()
16321638
CClientUIInterface::MSG_INFORMATION);
16331639
}
16341640

1641+
void NavCoinGUI::splitRewards()
1642+
{
1643+
walletFrame->splitRewards();
1644+
}
1645+
16351646
#ifdef ENABLE_WALLET
16361647

16371648

‎src/qt/navcoingui.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class NavCoinGUI : public QMainWindow
136136
QAction *unlockWalletAction;
137137
QAction *lockWalletAction;
138138
QAction *toggleStakingAction;
139+
QAction *splitRewardAction;
139140
QPushButton *topMenu1; // Home
140141
QPushButton *topMenu2; // Send
141142
QPushButton *topMenu3; // Recieve
@@ -275,6 +276,7 @@ private Q_SLOTS:
275276
void updateDisplayUnit(int unit);
276277
/** Toggle Staking **/
277278
void toggleStaking();
279+
void splitRewards();
278280
#ifndef Q_OS_MAC
279281
/** Handle tray icon clicked */
280282
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);

‎src/qt/overviewpage.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,10 @@ void OverviewPage::updateStakeReportNow()
418418
{
419419
updateStakeReport(true);
420420
}
421+
422+
void OverviewPage::on_showStakingSetup_clicked()
423+
{
424+
SplitRewardsDialog dlg(this);
425+
dlg.setModel(walletModel);
426+
dlg.exec();
427+
}

‎src/qt/overviewpage.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define NAVCOIN_QT_OVERVIEWPAGE_H
77

88
#include "amount.h"
9+
#include "splitrewards.h"
910

1011
#include <QWidget>
1112
#include <QPushButton>
@@ -61,11 +62,11 @@ public Q_SLOTS:
6162
void updateStakeReportNow();
6263
void updateStakeReportbalanceChanged(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount);
6364
void setVotingStatus(QString text);
64-
65+
void on_showStakingSetup_clicked();
6566

6667
Q_SIGNALS:
6768
void transactionClicked(const QModelIndex &index);
68-
void outOfSyncWarningClicked();
69+
void outOfSyncWarningClicked();
6970

7071
private:
7172
Ui::OverviewPage *ui;

‎src/qt/qjsonitem.cpp‎

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/***********************************************
2+
Copyright (C) 2014 Schutz Sacha
3+
This file is part of QJsonModel (https://github.com/dridk/QJsonmodel).
4+
5+
QJsonModel is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
QJsonModel is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with QJsonModel. If not, see <http://www.gnu.org/licenses/>.
17+
18+
**********************************************/
19+
20+
#include "qjsonitem.h"
21+
22+
QJsonTreeItem::QJsonTreeItem(QJsonTreeItem *parent)
23+
{
24+
25+
mParent = parent;
26+
27+
28+
}
29+
30+
QJsonTreeItem::~QJsonTreeItem()
31+
{
32+
qDeleteAll(mChilds);
33+
34+
}
35+
36+
void QJsonTreeItem::appendChild(QJsonTreeItem *item)
37+
{
38+
mChilds.append(item);
39+
}
40+
41+
QJsonTreeItem *QJsonTreeItem::child(int row)
42+
{
43+
return mChilds.value(row);
44+
}
45+
46+
QJsonTreeItem *QJsonTreeItem::parent()
47+
{
48+
return mParent;
49+
}
50+
51+
int QJsonTreeItem::childCount() const
52+
{
53+
return mChilds.count();
54+
}
55+
56+
int QJsonTreeItem::row() const
57+
{
58+
if (mParent)
59+
return mParent->mChilds.indexOf(const_cast<QJsonTreeItem*>(this));
60+
61+
return 0;
62+
}
63+
64+
void QJsonTreeItem::setKey(const QString &key)
65+
{
66+
mKey = key;
67+
}
68+
69+
void QJsonTreeItem::setValue(const QString &value)
70+
{
71+
mValue = value;
72+
}
73+
74+
void QJsonTreeItem::setType(const QJsonValue::Type &type)
75+
{
76+
mType = type;
77+
}
78+
79+
QString QJsonTreeItem::key() const
80+
{
81+
return mKey;
82+
}
83+
84+
QString QJsonTreeItem::value() const
85+
{
86+
return mValue;
87+
}
88+
89+
QJsonValue::Type QJsonTreeItem::type() const
90+
{
91+
return mType;
92+
}
93+
94+
QJsonTreeItem* QJsonTreeItem::load(const QJsonValue& value, QJsonTreeItem* parent)
95+
{
96+
97+
98+
QJsonTreeItem * rootItem = new QJsonTreeItem(parent);
99+
rootItem->setKey("root");
100+
101+
if ( value.isObject())
102+
{
103+
104+
//Get all QJsonValue childs
105+
for (QString key: value.toObject().keys()){
106+
QJsonValue v = value.toObject().value(key);
107+
QJsonTreeItem * child = load(v,rootItem);
108+
child->setKey(key);
109+
child->setType(v.type());
110+
rootItem->appendChild(child);
111+
112+
}
113+
114+
}
115+
116+
else if ( value.isArray())
117+
{
118+
//Get all QJsonValue childs
119+
int index = 0;
120+
for (QJsonValue v: value.toArray()){
121+
122+
QJsonTreeItem * child = load(v,rootItem);
123+
child->setKey(QString::number(index));
124+
child->setType(v.type());
125+
rootItem->appendChild(child);
126+
++index;
127+
}
128+
}
129+
else
130+
{
131+
rootItem->setValue(value.toVariant().toString());
132+
rootItem->setType(value.type());
133+
}
134+
135+
return rootItem;
136+
}

‎src/qt/qjsonitem.h‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef JSONITEM_H
2+
#define JSONITEM_H
3+
4+
#include <QtCore>
5+
#include <QJsonValue>
6+
#include <QJsonArray>
7+
#include <QJsonObject>
8+
9+
class QJsonTreeItem
10+
{
11+
public:
12+
QJsonTreeItem(QJsonTreeItem * parent = 0);
13+
~QJsonTreeItem();
14+
void appendChild(QJsonTreeItem * item);
15+
QJsonTreeItem *child(int row);
16+
QJsonTreeItem *parent();
17+
int childCount() const;
18+
int row() const;
19+
void setKey(const QString& key);
20+
void setValue(const QString& value);
21+
void setType(const QJsonValue::Type& type);
22+
QString key() const;
23+
QString value() const;
24+
QJsonValue::Type type() const;
25+
26+
27+
static QJsonTreeItem* load(const QJsonValue& value, QJsonTreeItem * parent = 0);
28+
29+
protected:
30+
31+
32+
private:
33+
QString mKey;
34+
QString mValue;
35+
QJsonValue::Type mType;
36+
37+
QList<QJsonTreeItem*> mChilds;
38+
QJsonTreeItem * mParent;
39+
40+
41+
};
42+
43+
#endif // JSONITEM_H

0 commit comments

Comments
 (0)