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

Improvements to CFund GUI #368

Merged
merged 2 commits into from Dec 17, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
84 changes: 52 additions & 32 deletions src/qt/forms/cfund_voting.cpp
Expand Up @@ -134,50 +134,70 @@ void CFund_Voting::Refresh()
ui->windowMainTitle->setText(fSettings ? tr("Payment Request Voting") : tr("Proposal Voting"));

enableDisableButtons();
if (!fSettings)

int nCount = 0;

{
std::vector<CFund::CProposal> vec;
if(pblocktree->GetProposalIndex(vec))
{
BOOST_FOREACH(const CFund::CProposal& proposal, vec) {
if (proposal.fState != CFund::NIL)
continue;
QListWidget* whereToAdd = ui->notvotingList;
auto it = std::find_if( vAddedProposalVotes.begin(), vAddedProposalVotes.end(),
[&proposal](const std::pair<std::string, bool>& element){ return element.first == proposal.hash.ToString();} );
if (it != vAddedProposalVotes.end()) {
if (it->second)
whereToAdd = ui->votingyesList;
else
whereToAdd = ui->votingnoList;
}
std::vector<CFund::CProposal> vec;
if(pblocktree->GetProposalIndex(vec))
{
BOOST_FOREACH(const CFund::CProposal& proposal, vec) {
if (proposal.fState != CFund::NIL)
continue;
QListWidget* whereToAdd = ui->notvotingList;
auto it = std::find_if( vAddedProposalVotes.begin(), vAddedProposalVotes.end(),
[&proposal](const std::pair<std::string, bool>& element){ return element.first == proposal.hash.ToString();} );
if (it != vAddedProposalVotes.end()) {
if (it->second)
whereToAdd = ui->votingyesList;
else
whereToAdd = ui->votingnoList;
}
if (!fSettings)
{
QListWidgetItem *item = new QListWidgetItem(QString::fromStdString(proposal.strDZeel), whereToAdd);
item->setData(1, QString::fromStdString(proposal.hash.ToString()));
} else {
if (whereToAdd == ui->notvotingList)
nCount++;
}
}
}
else
}

{
std::vector<CFund::CPaymentRequest> vec;
if(pblocktree->GetPaymentRequestIndex(vec))
{
BOOST_FOREACH(const CFund::CPaymentRequest& prequest, vec) {
if (prequest.fState != CFund::NIL)
continue;
QListWidget* whereToAdd = ui->notvotingList;
auto it = std::find_if( vAddedPaymentRequestVotes.begin(), vAddedPaymentRequestVotes.end(),
[&prequest](const std::pair<std::string, int>& element){ return element.first == prequest.hash.ToString();} );
if (it != vAddedPaymentRequestVotes.end()) {
if (it->second)
whereToAdd = ui->votingyesList;
else
whereToAdd = ui->votingnoList;
}
std::vector<CFund::CPaymentRequest> vec;
if(pblocktree->GetPaymentRequestIndex(vec))
{
BOOST_FOREACH(const CFund::CPaymentRequest& prequest, vec) {
if (prequest.fState != CFund::NIL)
continue;
QListWidget* whereToAdd = ui->notvotingList;
auto it = std::find_if( vAddedPaymentRequestVotes.begin(), vAddedPaymentRequestVotes.end(),
[&prequest](const std::pair<std::string, int>& element){ return element.first == prequest.hash.ToString();} );
if (it != vAddedPaymentRequestVotes.end()) {
if (it->second)
whereToAdd = ui->votingyesList;
else
whereToAdd = ui->votingnoList;
}
if (fSettings)
{
QListWidgetItem *item = new QListWidgetItem(QString::fromStdString(prequest.strDZeel), whereToAdd);
item->setData(1, QString::fromStdString(prequest.hash.ToString()));
} else {
if (whereToAdd == ui->notvotingList)
nCount++;
}
}
}
}

if (nCount > 0)
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));
else
ui->otherViewLabel->setText("");

}

CFund_Voting::~CFund_Voting()
Expand Down
7 changes: 7 additions & 0 deletions src/qt/forms/cfund_voting.ui
Expand Up @@ -169,6 +169,13 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="otherViewLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
Expand Down
64 changes: 39 additions & 25 deletions src/qt/navcoingui.cpp
Expand Up @@ -891,6 +891,15 @@ void NavCoinGUI::cfundProposalsClicked()
dlg.exec();
}

void NavCoinGUI::cfundProposalsOpen(bool fMode)
{
if(!clientModel || !clientModel->getOptionsModel())
return;

CFund_Voting dlg(this, fMode);
dlg.exec();
}

void NavCoinGUI::cfundPaymentRequestsClicked()
{
if(!clientModel || !clientModel->getOptionsModel())
Expand Down Expand Up @@ -1797,40 +1806,45 @@ void NavCoinGUI::updateStakingStatus()
}
else if (nLastCoinStakeSearchInterval && nWeight)
{
bool fFound = false;
std::vector<CFund::CProposal> vec;
if(pblocktree->GetProposalIndex(vec))
bool fFoundProposal = false;
bool fFoundPaymentRequest = false;
{
BOOST_FOREACH(const CFund::CProposal& proposal, vec) {
if (proposal.fState != CFund::NIL)
continue;
auto it = std::find_if( vAddedProposalVotes.begin(), vAddedProposalVotes.end(),
[&proposal](const std::pair<std::string, int>& element){ return element.first == proposal.hash.ToString();} );
if (it == vAddedProposalVotes.end()) {
fFound = true;
break;
std::vector<CFund::CProposal> vec;
if(pblocktree->GetProposalIndex(vec))
{
BOOST_FOREACH(const CFund::CProposal& proposal, vec) {
if (proposal.fState != CFund::NIL)
continue;
auto it = std::find_if( vAddedProposalVotes.begin(), vAddedProposalVotes.end(),
[&proposal](const std::pair<std::string, int>& element){ return element.first == proposal.hash.ToString();} );
if (it == vAddedProposalVotes.end()) {
fFoundProposal = true;
break;
}
}
}
}

std::vector<CFund::CPaymentRequest> vec2;
if(!fFound && pblocktree->GetPaymentRequestIndex(vec2))
{
BOOST_FOREACH(const CFund::CPaymentRequest& prequest, vec2) {
if (prequest.fState != CFund::NIL)
continue;
auto it = std::find_if( vAddedPaymentRequestVotes.begin(), vAddedPaymentRequestVotes.end(),
[&prequest](const std::pair<std::string, int>& element){ return element.first == prequest.hash.ToString();} );
if (it == vAddedPaymentRequestVotes.end()) {
fFound = true;
break;
std::vector<CFund::CPaymentRequest> vec;
if(pblocktree->GetPaymentRequestIndex(vec))
{
BOOST_FOREACH(const CFund::CPaymentRequest& prequest, vec) {
if (prequest.fState != CFund::NIL)
continue;
auto it = std::find_if( vAddedPaymentRequestVotes.begin(), vAddedPaymentRequestVotes.end(),
[&prequest](const std::pair<std::string, int>& element){ return element.first == prequest.hash.ToString();} );
if (it == vAddedPaymentRequestVotes.end()) {
fFoundPaymentRequest = true;
break;
}
}
}
}
if (fFound && !this->fDontShowAgain && (this->lastDialogShown + (60*60*24)) < GetTimeNow()) {
if ((fFoundPaymentRequest || fFoundProposal) && !this->fDontShowAgain && (this->lastDialogShown + (60*60*24)) < GetTimeNow()) {
QCheckBox *cb = new QCheckBox("Don't show this notification again until wallet is restarted.");
QMessageBox msgbox;
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!"));
QString sWhat = fFoundProposal && fFoundPaymentRequest ? tr("Proposals and Payment Requests") : (fFoundProposal ? tr("Proposals") : tr("Payment Requests"));
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));
msgbox.setIcon(QMessageBox::Icon::Warning);
msgbox.setCheckBox(cb);
QAbstractButton* pButtonInfo = msgbox.addButton(tr("Read about the Community Fund"), QMessageBox::YesRole);
Expand All @@ -1848,7 +1862,7 @@ void NavCoinGUI::updateStakingStatus()
}

if (msgbox.clickedButton()==pButtonOpen) {
cfundProposalsClicked();
cfundProposalsOpen(fFoundPaymentRequest);
}
if (msgbox.clickedButton()==pButtonInfo) {
QString link = QString("https://navcoin.org/en/community-fund/");
Expand Down
3 changes: 3 additions & 0 deletions src/qt/navcoingui.h
Expand Up @@ -177,6 +177,9 @@ class NavCoinGUI : public QMainWindow

void updateWeight();

void cfundProposalsOpen(bool fMode);



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