From 9162c56419090e330d6851121dc5312dbc3c2589 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sun, 20 Nov 2016 10:54:33 +0400 Subject: [PATCH] Refactor HelpMessageDialog to reuse it for PS help info, add PS info to help menu (#1144) --- src/qt/bitcoingui.cpp | 20 ++++++++++++++++++-- src/qt/bitcoingui.h | 3 +++ src/qt/dash.cpp | 2 +- src/qt/overviewpage.cpp | 38 +++---------------------------------- src/qt/utilitydialog.cpp | 41 +++++++++++++++++++++++++++++++++++++--- src/qt/utilitydialog.h | 8 +++++++- 6 files changed, 70 insertions(+), 42 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index ca91f6893..62ab14fde 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -108,6 +108,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n openRPCConsoleAction(0), openAction(0), showHelpMessageAction(0), + showPrivateSendHelpAction(0), trayIcon(0), trayIconMenu(0), dockIconMenu(0), @@ -154,7 +155,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n #endif rpcConsole = new RPCConsole(platformStyle, 0); - helpMessageDialog = new HelpMessageDialog(this, false); + helpMessageDialog = new HelpMessageDialog(this, HelpMessageDialog::cmdline); #ifdef ENABLE_WALLET if(enableWallet) { @@ -425,12 +426,17 @@ void BitcoinGUI::createActions() showHelpMessageAction->setMenuRole(QAction::NoRole); showHelpMessageAction->setStatusTip(tr("Show the Dash Core help message to get a list with possible Dash Core command-line options")); + showPrivateSendHelpAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation), tr("&PrivateSend information"), this); + showPrivateSendHelpAction->setMenuRole(QAction::NoRole); + showPrivateSendHelpAction->setStatusTip(tr("Show the PrivateSend basic information")); + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden())); connect(showHelpMessageAction, SIGNAL(triggered()), this, SLOT(showHelpMessageClicked())); + connect(showPrivateSendHelpAction, SIGNAL(triggered()), this, SLOT(showPrivateSendHelpClicked())); // Jump directly to tabs in RPC-console connect(openInfoAction, SIGNAL(triggered()), this, SLOT(showInfo())); @@ -525,6 +531,7 @@ void BitcoinGUI::createMenuBar() QMenu *help = appMenuBar->addMenu(tr("&Help")); help->addAction(showHelpMessageAction); + help->addAction(showPrivateSendHelpAction); help->addSeparator(); help->addAction(aboutAction); help->addAction(aboutQtAction); @@ -740,7 +747,7 @@ void BitcoinGUI::aboutClicked() if(!clientModel) return; - HelpMessageDialog dlg(this, true); + HelpMessageDialog dlg(this, HelpMessageDialog::about); dlg.exec(); } @@ -802,6 +809,15 @@ void BitcoinGUI::showHelpMessageClicked() helpMessageDialog->show(); } +void BitcoinGUI::showPrivateSendHelpClicked() +{ + if(!clientModel) + return; + + HelpMessageDialog dlg(this, HelpMessageDialog::pshelp); + dlg.exec(); +} + #ifdef ENABLE_WALLET void BitcoinGUI::openClicked() { diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 2aebb9d34..c42b6cd14 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -123,6 +123,7 @@ private: QAction *showBackupsAction; QAction *openAction; QAction *showHelpMessageAction; + QAction *showPrivateSendHelpAction; QSystemTrayIcon *trayIcon; QMenu *trayIconMenu; @@ -238,6 +239,8 @@ private Q_SLOTS: /** Show help message dialog */ void showHelpMessageClicked(); + /** Show PrivateSend help message dialog */ + void showPrivateSendHelpClicked(); #ifndef Q_OS_MAC /** Handle tray icon clicked */ void trayIconActivated(QSystemTrayIcon::ActivationReason reason); diff --git a/src/qt/dash.cpp b/src/qt/dash.cpp index d34399ea1..9a3d611eb 100644 --- a/src/qt/dash.cpp +++ b/src/qt/dash.cpp @@ -609,7 +609,7 @@ int main(int argc, char *argv[]) // but before showing splash screen. if (mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { - HelpMessageDialog help(NULL, mapArgs.count("-version")); + HelpMessageDialog help(NULL, mapArgs.count("-version") ? HelpMessageDialog::about : HelpMessageDialog::cmdline); help.showOrPrint(); return EXIT_SUCCESS; } diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 28f29d7b9..9938337dc 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -16,6 +16,7 @@ #include "platformstyle.h" #include "transactionfilterproxy.h" #include "transactiontablemodel.h" +#include "utilitydialog.h" #include "walletmodel.h" #include "init.h" #include "masternode-sync.h" @@ -579,41 +580,8 @@ void OverviewPage::privateSendReset(){ } void OverviewPage::privateSendInfo(){ - - // Artificial long boxtitle to ensure minimum width without overwriting the global CSS styles - QString placeHolder = " "; - QString infoBoxTitle = tr("PrivateSend") + placeHolder; - - QMessageBox::information(this, infoBoxTitle, - tr("\ -

PrivateSend Basics

\ -PrivateSend gives you true financial privacy by obscuring the origins of your funds. \ -All the Dash in your wallet is comprised of different \"inputs\" which you can think of as separate, discrete coins.
\ -PrivateSend uses an innovative process to mix your inputs with the inputs of two other people, without having your coins ever leave your wallet. \ -You retain control of your money at all times..
\ -The PrivateSend process works like this:\ -
    \ -
  1. PrivateSend begins by breaking your transaction inputs down into standard denominations. \ -These denominations are 0.1 DASH, 1 DASH, 10 DASH, and 100 DASH--sort of like the paper money you use every day.
  2. \ -
  3. Your wallet then sends requests to specially configured software nodes on the network, called \"masternodes.\" \ -These masternodes are informed then that you are interested in mixing a certain denomination. \ -No identifiable information is sent to the masternodes, so they never know \"who\" you are.
  4. \ -
  5. When two other people send similar messages, indicating that they wish to mix the same denomination, a mixing session begins. \ -The masternode mixes up the inputs and instructs all three users' wallets to pay the now-transformed input back to themselves. \ -Your wallet pays that denomination directly to itself, but in a different address (called a change address).
  6. \ -
  7. In order to fully obscure your funds, your wallet must repeat this process a number of times with each denomination. \ -Each time the process is completed, it's called a \"round.\" Each round of PrivateSend makes it exponentially more difficult to determine where your funds originated.
  8. \ -
  9. This mixing process happens in the background without any intervention on your part. When you wish to make a transaction, \ -your funds will already be anonymized. No additional waiting is required.
  10. \ -

\ -IMPORTANT: Your wallet only contains 1000 of these \"change addresses.\" Every time a mixing event happens, up to 9 of your addresses are used up. \ -This means those 1000 addresses last for about 100 mixing events. When 900 of them are used, your wallet must create more addresses. \ -It can only do this, however, if you have automatic backups enabled.
\ -Consequently, users who have backups disabled will also have PrivateSend disabled.
\ -For more info see https://dashpay.atlassian.net/wiki/display/DOC/PrivateSend \ - "), - QMessageBox::Ok, QMessageBox::Ok); - + HelpMessageDialog dlg(this, HelpMessageDialog::pshelp); + dlg.exec(); } void OverviewPage::togglePrivateSend(){ diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index d288ecd68..41b324b83 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -28,7 +28,7 @@ #include /** "Help message" or "About" dialog box */ -HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : +HelpMessageDialog::HelpMessageDialog(QWidget *parent, HelpMode helpMode) : QDialog(parent), ui(new Ui::HelpMessageDialog) { @@ -44,7 +44,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : version += " " + tr("(%1-bit)").arg(32); #endif - if (about) + if (helpMode == about) { setWindowTitle(tr("About Dash Core")); @@ -65,7 +65,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : ui->aboutMessage->setText(version + "

" + licenseInfoHTML); ui->aboutMessage->setWordWrap(true); ui->helpMessage->setVisible(false); - } else { + } else if (helpMode == cmdline) { setWindowTitle(tr("Command-line options")); QString header = tr("Usage:") + "\n" + " dash-qt [" + tr("command-line options") + "] " + "\n"; @@ -127,6 +127,41 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : ui->helpMessage->moveCursor(QTextCursor::Start); ui->scrollArea->setVisible(false); ui->aboutLogo->setVisible(false); + } else if (helpMode == pshelp) { + setWindowTitle(tr("PrivateSend information")); + + ui->aboutMessage->setTextFormat(Qt::RichText); + ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + ui->aboutMessage->setText(tr("\ +

PrivateSend Basics

\ +PrivateSend gives you true financial privacy by obscuring the origins of your funds. \ +All the Dash in your wallet is comprised of different \"inputs\" which you can think of as separate, discrete coins.
\ +PrivateSend uses an innovative process to mix your inputs with the inputs of two other people, without having your coins ever leave your wallet. \ +You retain control of your money at all times..
\ +The PrivateSend process works like this:\ +
    \ +
  1. PrivateSend begins by breaking your transaction inputs down into standard denominations. \ +These denominations are 0.1 DASH, 1 DASH, 10 DASH, and 100 DASH--sort of like the paper money you use every day.
  2. \ +
  3. Your wallet then sends requests to specially configured software nodes on the network, called \"masternodes.\" \ +These masternodes are informed then that you are interested in mixing a certain denomination. \ +No identifiable information is sent to the masternodes, so they never know \"who\" you are.
  4. \ +
  5. When two other people send similar messages, indicating that they wish to mix the same denomination, a mixing session begins. \ +The masternode mixes up the inputs and instructs all three users' wallets to pay the now-transformed input back to themselves. \ +Your wallet pays that denomination directly to itself, but in a different address (called a change address).
  6. \ +
  7. In order to fully obscure your funds, your wallet must repeat this process a number of times with each denomination. \ +Each time the process is completed, it's called a \"round.\" Each round of PrivateSend makes it exponentially more difficult to determine where your funds originated.
  8. \ +
  9. This mixing process happens in the background without any intervention on your part. When you wish to make a transaction, \ +your funds will already be anonymized. No additional waiting is required.
  10. \ +

\ +IMPORTANT: Your wallet only contains 1000 of these \"change addresses.\" Every time a mixing event happens, up to 9 of your addresses are used up. \ +This means those 1000 addresses last for about 100 mixing events. When 900 of them are used, your wallet must create more addresses. \ +It can only do this, however, if you have automatic backups enabled.
\ +Consequently, users who have backups disabled will also have PrivateSend disabled.
\ +For more info see https://dashpay.atlassian.net/wiki/display/DOC/PrivateSend \ + ")); + ui->aboutMessage->setWordWrap(true); + ui->helpMessage->setVisible(false); + ui->aboutLogo->setVisible(false); } // Theme dependent Gfx in About popup QString helpMessageGfx = ":/images/" + GUIUtil::getThemeName() + "/about"; diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h index 843bd7f67..32041f364 100644 --- a/src/qt/utilitydialog.h +++ b/src/qt/utilitydialog.h @@ -21,7 +21,13 @@ class HelpMessageDialog : public QDialog Q_OBJECT public: - explicit HelpMessageDialog(QWidget *parent, bool about); + enum HelpMode { + about, + cmdline, + pshelp + }; + + explicit HelpMessageDialog(QWidget *parent, HelpMode helpMode); ~HelpMessageDialog(); void printToConsole();