Skip to content

Commit 1b1077b

Browse files
author
alex v
authored
Improvements to CFund GUI (#368)
* - Shows the amount of pending proposals/p.requests on the other view - When the dialog is shown, clicking the button opens the view with new entries. * show right category on dialog
1 parent fe5f8c7 commit 1b1077b

4 files changed

Lines changed: 101 additions & 57 deletions

File tree

src/qt/forms/cfund_voting.cpp

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -134,50 +134,70 @@ void CFund_Voting::Refresh()
134134
ui->windowMainTitle->setText(fSettings ? tr("Payment Request Voting") : tr("Proposal Voting"));
135135

136136
enableDisableButtons();
137-
if (!fSettings)
137+
138+
int nCount = 0;
139+
138140
{
139-
std::vector<CFund::CProposal> vec;
140-
if(pblocktree->GetProposalIndex(vec))
141-
{
142-
BOOST_FOREACH(const CFund::CProposal& proposal, vec) {
143-
if (proposal.fState != CFund::NIL)
144-
continue;
145-
QListWidget* whereToAdd = ui->notvotingList;
146-
auto it = std::find_if( vAddedProposalVotes.begin(), vAddedProposalVotes.end(),
147-
[&proposal](const std::pair<std::string, bool>& element){ return element.first == proposal.hash.ToString();} );
148-
if (it != vAddedProposalVotes.end()) {
149-
if (it->second)
150-
whereToAdd = ui->votingyesList;
151-
else
152-
whereToAdd = ui->votingnoList;
153-
}
141+
std::vector<CFund::CProposal> vec;
142+
if(pblocktree->GetProposalIndex(vec))
143+
{
144+
BOOST_FOREACH(const CFund::CProposal& proposal, vec) {
145+
if (proposal.fState != CFund::NIL)
146+
continue;
147+
QListWidget* whereToAdd = ui->notvotingList;
148+
auto it = std::find_if( vAddedProposalVotes.begin(), vAddedProposalVotes.end(),
149+
[&proposal](const std::pair<std::string, bool>& element){ return element.first == proposal.hash.ToString();} );
150+
if (it != vAddedProposalVotes.end()) {
151+
if (it->second)
152+
whereToAdd = ui->votingyesList;
153+
else
154+
whereToAdd = ui->votingnoList;
155+
}
156+
if (!fSettings)
157+
{
154158
QListWidgetItem *item = new QListWidgetItem(QString::fromStdString(proposal.strDZeel), whereToAdd);
155159
item->setData(1, QString::fromStdString(proposal.hash.ToString()));
160+
} else {
161+
if (whereToAdd == ui->notvotingList)
162+
nCount++;
156163
}
157164
}
158165
}
159-
else
166+
}
167+
160168
{
161-
std::vector<CFund::CPaymentRequest> vec;
162-
if(pblocktree->GetPaymentRequestIndex(vec))
163-
{
164-
BOOST_FOREACH(const CFund::CPaymentRequest& prequest, vec) {
165-
if (prequest.fState != CFund::NIL)
166-
continue;
167-
QListWidget* whereToAdd = ui->notvotingList;
168-
auto it = std::find_if( vAddedPaymentRequestVotes.begin(), vAddedPaymentRequestVotes.end(),
169-
[&prequest](const std::pair<std::string, int>& element){ return element.first == prequest.hash.ToString();} );
170-
if (it != vAddedPaymentRequestVotes.end()) {
171-
if (it->second)
172-
whereToAdd = ui->votingyesList;
173-
else
174-
whereToAdd = ui->votingnoList;
175-
}
169+
std::vector<CFund::CPaymentRequest> vec;
170+
if(pblocktree->GetPaymentRequestIndex(vec))
171+
{
172+
BOOST_FOREACH(const CFund::CPaymentRequest& prequest, vec) {
173+
if (prequest.fState != CFund::NIL)
174+
continue;
175+
QListWidget* whereToAdd = ui->notvotingList;
176+
auto it = std::find_if( vAddedPaymentRequestVotes.begin(), vAddedPaymentRequestVotes.end(),
177+
[&prequest](const std::pair<std::string, int>& element){ return element.first == prequest.hash.ToString();} );
178+
if (it != vAddedPaymentRequestVotes.end()) {
179+
if (it->second)
180+
whereToAdd = ui->votingyesList;
181+
else
182+
whereToAdd = ui->votingnoList;
183+
}
184+
if (fSettings)
185+
{
176186
QListWidgetItem *item = new QListWidgetItem(QString::fromStdString(prequest.strDZeel), whereToAdd);
177187
item->setData(1, QString::fromStdString(prequest.hash.ToString()));
188+
} else {
189+
if (whereToAdd == ui->notvotingList)
190+
nCount++;
178191
}
179192
}
180193
}
194+
}
195+
196+
if (nCount > 0)
197+
ui->otherViewLabel->setText(fSettings ? tr("There are %1 new Proposals on the other view.").arg(nCount) : tr("There are %1 new Payment Requests on the other view.").arg(nCount));
198+
else
199+
ui->otherViewLabel->setText("");
200+
181201
}
182202

183203
CFund_Voting::~CFund_Voting()

src/qt/forms/cfund_voting.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@
169169
</property>
170170
</widget>
171171
</item>
172+
<item>
173+
<widget class="QLabel" name="otherViewLabel">
174+
<property name="text">
175+
<string/>
176+
</property>
177+
</widget>
178+
</item>
172179
<item>
173180
<spacer name="horizontalSpacer_3">
174181
<property name="orientation">

src/qt/navcoingui.cpp

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,15 @@ void NavCoinGUI::cfundProposalsClicked()
891891
dlg.exec();
892892
}
893893

894+
void NavCoinGUI::cfundProposalsOpen(bool fMode)
895+
{
896+
if(!clientModel || !clientModel->getOptionsModel())
897+
return;
898+
899+
CFund_Voting dlg(this, fMode);
900+
dlg.exec();
901+
}
902+
894903
void NavCoinGUI::cfundPaymentRequestsClicked()
895904
{
896905
if(!clientModel || !clientModel->getOptionsModel())
@@ -1797,40 +1806,45 @@ void NavCoinGUI::updateStakingStatus()
17971806
}
17981807
else if (nLastCoinStakeSearchInterval && nWeight)
17991808
{
1800-
bool fFound = false;
1801-
std::vector<CFund::CProposal> vec;
1802-
if(pblocktree->GetProposalIndex(vec))
1809+
bool fFoundProposal = false;
1810+
bool fFoundPaymentRequest = false;
18031811
{
1804-
BOOST_FOREACH(const CFund::CProposal& proposal, vec) {
1805-
if (proposal.fState != CFund::NIL)
1806-
continue;
1807-
auto it = std::find_if( vAddedProposalVotes.begin(), vAddedProposalVotes.end(),
1808-
[&proposal](const std::pair<std::string, int>& element){ return element.first == proposal.hash.ToString();} );
1809-
if (it == vAddedProposalVotes.end()) {
1810-
fFound = true;
1811-
break;
1812+
std::vector<CFund::CProposal> vec;
1813+
if(pblocktree->GetProposalIndex(vec))
1814+
{
1815+
BOOST_FOREACH(const CFund::CProposal& proposal, vec) {
1816+
if (proposal.fState != CFund::NIL)
1817+
continue;
1818+
auto it = std::find_if( vAddedProposalVotes.begin(), vAddedProposalVotes.end(),
1819+
[&proposal](const std::pair<std::string, int>& element){ return element.first == proposal.hash.ToString();} );
1820+
if (it == vAddedProposalVotes.end()) {
1821+
fFoundProposal = true;
1822+
break;
1823+
}
18121824
}
18131825
}
18141826
}
1815-
1816-
std::vector<CFund::CPaymentRequest> vec2;
1817-
if(!fFound && pblocktree->GetPaymentRequestIndex(vec2))
18181827
{
1819-
BOOST_FOREACH(const CFund::CPaymentRequest& prequest, vec2) {
1820-
if (prequest.fState != CFund::NIL)
1821-
continue;
1822-
auto it = std::find_if( vAddedPaymentRequestVotes.begin(), vAddedPaymentRequestVotes.end(),
1823-
[&prequest](const std::pair<std::string, int>& element){ return element.first == prequest.hash.ToString();} );
1824-
if (it == vAddedPaymentRequestVotes.end()) {
1825-
fFound = true;
1826-
break;
1828+
std::vector<CFund::CPaymentRequest> vec;
1829+
if(pblocktree->GetPaymentRequestIndex(vec))
1830+
{
1831+
BOOST_FOREACH(const CFund::CPaymentRequest& prequest, vec) {
1832+
if (prequest.fState != CFund::NIL)
1833+
continue;
1834+
auto it = std::find_if( vAddedPaymentRequestVotes.begin(), vAddedPaymentRequestVotes.end(),
1835+
[&prequest](const std::pair<std::string, int>& element){ return element.first == prequest.hash.ToString();} );
1836+
if (it == vAddedPaymentRequestVotes.end()) {
1837+
fFoundPaymentRequest = true;
1838+
break;
1839+
}
18271840
}
18281841
}
18291842
}
1830-
if (fFound && !this->fDontShowAgain && (this->lastDialogShown + (60*60*24)) < GetTimeNow()) {
1843+
if ((fFoundPaymentRequest || fFoundProposal) && !this->fDontShowAgain && (this->lastDialogShown + (60*60*24)) < GetTimeNow()) {
18311844
QCheckBox *cb = new QCheckBox("Don't show this notification again until wallet is restarted.");
18321845
QMessageBox msgbox;
1833-
msgbox.setText(tr("There are new proposals or payment requests in the Community Fund.<br><br>As a staker it's important to engage in the voting process.<br><br>Please cast your vote using the voting dialog!"));
1846+
QString sWhat = fFoundProposal && fFoundPaymentRequest ? tr("Proposals and Payment Requests") : (fFoundProposal ? tr("Proposals") : tr("Payment Requests"));
1847+
msgbox.setText(tr("There are new %1 in the Community Fund.<br><br>As a staker it's important to engage in the voting process.<br><br>Please cast your vote using the voting dialog!").arg(sWhat));
18341848
msgbox.setIcon(QMessageBox::Icon::Warning);
18351849
msgbox.setCheckBox(cb);
18361850
QAbstractButton* pButtonInfo = msgbox.addButton(tr("Read about the Community Fund"), QMessageBox::YesRole);
@@ -1848,7 +1862,7 @@ void NavCoinGUI::updateStakingStatus()
18481862
}
18491863

18501864
if (msgbox.clickedButton()==pButtonOpen) {
1851-
cfundProposalsClicked();
1865+
cfundProposalsOpen(fFoundPaymentRequest);
18521866
}
18531867
if (msgbox.clickedButton()==pButtonInfo) {
18541868
QString link = QString("https://navcoin.org/en/community-fund/");

src/qt/navcoingui.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ class NavCoinGUI : public QMainWindow
177177

178178
void updateWeight();
179179

180+
void cfundProposalsOpen(bool fMode);
181+
182+
180183

181184
Q_SIGNALS:
182185
/** Signal raised when a URI was entered or dragged to the GUI */

0 commit comments

Comments
 (0)