33#include " QGraphicsDropShadowEffect"
44#include " QListView"
55
6+ #include " qt/pivx/qtutils.h"
7+ #include " guiutil.h"
8+ #include " amount.h"
9+ #include " optionsmodel.h"
10+
611RequestDialog::RequestDialog (QWidget *parent) :
712 QDialog(parent),
813 ui(new Ui::RequestDialog)
@@ -30,18 +35,6 @@ RequestDialog::RequestDialog(QWidget *parent) :
3035 shadowEffect->setYOffset (3 );
3136 shadowEffect->setBlurRadius (6 );
3237
33- QGraphicsDropShadowEffect* shadowEffect2 = new QGraphicsDropShadowEffect ();
34- shadowEffect2->setColor (QColor (0 , 0 , 0 , 22 ));
35- shadowEffect2->setXOffset (0 );
36- shadowEffect2->setYOffset (3 );
37- shadowEffect2->setBlurRadius (6 );
38-
39- QGraphicsDropShadowEffect* shadowEffect3 = new QGraphicsDropShadowEffect ();
40- shadowEffect3->setColor (QColor (0 , 0 , 0 , 22 ));
41- shadowEffect3->setXOffset (0 );
42- shadowEffect3->setYOffset (3 );
43- shadowEffect3->setBlurRadius (6 );
44-
4538 // Combo Coins
4639
4740 ui->comboBoxCoin ->setProperty (" cssClass" , " btn-combo-coins" );
@@ -60,7 +53,8 @@ RequestDialog::RequestDialog(QWidget *parent) :
6053 ui->labelSubtitleLabel ->setProperty (" cssClass" , " text-title2-dialog" );
6154
6255 ui->lineEditLabel ->setPlaceholderText (" Enter a label to be saved withing the address" );
63- ui->lineEditLabel ->setProperty (" cssClass" , " edit-primary-dialog" );
56+ setCssEditLineDialog (ui->lineEditLabel , true );
57+
6458 ui->lineEditLabel ->setAttribute (Qt::WA_MacShowFocusRect, 0 );
6559 ui->lineEditLabel ->setGraphicsEffect (shadowEffect);
6660
@@ -70,9 +64,9 @@ RequestDialog::RequestDialog(QWidget *parent) :
7064 ui->labelSubtitleAmount ->setProperty (" cssClass" , " text-title2-dialog" );
7165
7266 ui->lineEditAmount ->setPlaceholderText (" 0.00" );
73- ui->lineEditAmount -> setProperty ( " cssClass " , " edit-primary-dialog " );
67+ setCssEditLineDialog ( ui->lineEditAmount , true );
7468 ui->lineEditAmount ->setAttribute (Qt::WA_MacShowFocusRect, 0 );
75- ui->layoutAmount ->setGraphicsEffect (shadowEffect2 );
69+ ui->layoutAmount ->setGraphicsEffect (shadowEffect );
7670
7771
7872 // Description
@@ -81,9 +75,9 @@ RequestDialog::RequestDialog(QWidget *parent) :
8175 ui->labelSubtitleDescription ->setProperty (" cssClass" , " text-title2-dialog" );
8276
8377 ui->lineEditDescription ->setPlaceholderText (" Add descripcion " );
84- ui->lineEditDescription -> setProperty ( " cssClass " , " edit-primary-dialog " );
78+ setCssEditLineDialog ( ui->lineEditDescription , true );
8579 ui->lineEditDescription ->setAttribute (Qt::WA_MacShowFocusRect, 0 );
86- ui->lineEditDescription ->setGraphicsEffect (shadowEffect3 );
80+ ui->lineEditDescription ->setGraphicsEffect (shadowEffect );
8781
8882
8983 // Stack
@@ -122,14 +116,71 @@ RequestDialog::RequestDialog(QWidget *parent) :
122116 connect (ui->btnCancel , SIGNAL (clicked ()), this , SLOT (close ()));
123117 connect (ui->btnEsc , SIGNAL (clicked ()), this , SLOT (close ()));
124118 connect (ui->btnSave , SIGNAL (clicked ()), this , SLOT (onNextClicked ()));
119+
120+ // TODO: Change copy address for save image (the method is already implemented in other class called exportQr or something like that)
121+ connect (ui->btnCopyAddress , SIGNAL (clicked ()), this , SLOT (onCopyClicked ()));
122+ }
123+
124+ void RequestDialog::setWalletModel (WalletModel *model){
125+ this ->walletModel = model;
125126}
126127
127128
128129void RequestDialog::onNextClicked (){
129- pos = 1 ;
130- ui->stack ->setCurrentIndex (pos);
131- ui->labelTitle ->setText (" Request for 200 PIV" );
132- ui->buttonsStack ->setVisible (false );
130+
131+ if (walletModel) {
132+ // info
133+ info = new SendCoinsRecipient ();
134+
135+
136+ info->label = ui->lineEditLabel ->text ();
137+ info->message = ui->lineEditDescription ->text ();
138+ info->address = QString::fromStdString (walletModel->getNewAddress ().ToString ());
139+ int displayUnit = walletModel->getOptionsModel ()->getDisplayUnit ();
140+ bool isValueValid = true ;
141+ CAmount value = GUIUtil::parseValue (
142+ ui->lineEditAmount ->text (),
143+ displayUnit,
144+ &isValueValid
145+ );
146+ info->amount = value;
147+
148+ if (value <= 0 || !isValueValid){
149+ // TODO: Notify problem..
150+ return ;
151+ }
152+ // TODO: validate address etc etc.
153+
154+ // TODO: Complete amount and QR.
155+
156+ ui->labelTitle ->setText (" Request for " + BitcoinUnits::format (displayUnit, value, false , BitcoinUnits::separatorAlways));
157+ updateQr (info->address );
158+ ui->buttonsStack ->setVisible (false );
159+ pos = 1 ;
160+ ui->stack ->setCurrentIndex (pos);
161+ }
162+ }
163+
164+ void RequestDialog::onCopyClicked (){
165+ if (info) {
166+ GUIUtil::setClipboard (GUIUtil::formatBitcoinURI (*info));
167+ // TODO: Notify
168+ // window->messageInfo(tr("Address copied"));
169+ close ();
170+ }
171+ }
172+
173+ void RequestDialog::updateQr (QString str){
174+ QString uri = GUIUtil::formatBitcoinURI (*info);
175+ ui->labelQrImg ->setText (" " );
176+ QString error;
177+ QPixmap pixmap = encodeToQr (uri, error);
178+ if (!pixmap.isNull ()){
179+ qrImage = &pixmap;
180+ ui->labelQrImg ->setPixmap (qrImage->scaled (ui->labelQrImg ->width (), ui->labelQrImg ->height ()));
181+ }else {
182+ ui->labelQrImg ->setText (!error.isEmpty () ? error : " Error encoding address" );
183+ }
133184}
134185
135186RequestDialog::~RequestDialog ()
0 commit comments