Skip to content

Commit 85478f4

Browse files
committed
snack info message signal
1 parent dacdefc commit 85478f4

File tree

7 files changed

+27
-30
lines changed

7 files changed

+27
-30
lines changed

src/guiinterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class CClientUIInterface
7373
/** Predefined combinations for certain default usage cases */
7474
MSG_INFORMATION = ICON_INFORMATION,
7575
MSG_WARNING = (ICON_WARNING | BTN_OK | MODAL),
76-
MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL)
76+
MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL),
77+
MSG_INFORMATION_SNACK = 1U << 2
7778
};
7879

7980
/** Show message box. */

src/qt/pivx/PIVXGUI.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ void PIVXGUI::message(const QString& title, const QString& message, unsigned int
333333

334334
if (ret != NULL)
335335
*ret = r;
336-
} else
336+
} else if(style & CClientUIInterface::MSG_INFORMATION_SNACK){
337+
messageInfo(message);
338+
}else
337339
notificator->notify((Notificator::Class) nNotifyIcon, strTitle, message);
338340

339341
// TODO: Furszy remove this please..
@@ -496,14 +498,8 @@ bool PIVXGUI::addWallet(const QString& name, WalletModel* walletModel)
496498
connect(sendWidget, SIGNAL(message(QString, QString, unsigned int)), this, SLOT(message(QString, QString, unsigned int)));
497499
connect(topBar, SIGNAL(message(QString, QString, unsigned int)), this, SLOT(message(QString, QString, unsigned int)));
498500
connect(privacyWidget, SIGNAL(message(QString, QString, unsigned int)), this, SLOT(message(QString, QString, unsigned int)));
499-
connect(addressesWidget,
500-
SIGNAL(message(const QString&,const QString&, unsigned int, bool* ret)),
501-
this, SLOT(message(QString&, QString&, unsigned int, bool* ret))
502-
);
503-
connect(settingsWidget,
504-
&SettingsWidget::message,
505-
[this](const QString& title, const QString& body, unsigned int style, bool* ret){message(title, body, style, ret);}
506-
);
501+
connect(addressesWidget, &AddressesWidget::message,this, &PIVXGUI::message);
502+
connect(settingsWidget, &SettingsWidget::message, this, &PIVXGUI::message);
507503

508504
return true;
509505
}

src/qt/pivx/addresseswidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ void AddressesWidget::onStoreContactClicked(){
209209
// TODO: Update address status on text change..
210210
if (!walletModel->validateAddress(address)) {
211211
setCssEditLine(ui->lineEditAddress, false, true);
212-
emit message("", tr("Invalid Contact Address"), CClientUIInterface::MSG_INFORMATION, nullptr);
212+
emit message("", tr("Invalid Contact Address"), CClientUIInterface::MSG_INFORMATION_SNACK, nullptr);
213213
return;
214214
}
215215

216216
CBitcoinAddress pivAdd = CBitcoinAddress(address.toUtf8().constData());
217217
if (walletModel->isMine(pivAdd)) {
218218
setCssEditLine(ui->lineEditAddress, false, true);
219-
emit message("", tr("Cannot store your own address as contact"), CClientUIInterface::MSG_INFORMATION, nullptr);
219+
emit message("", tr("Cannot store your own address as contact"), CClientUIInterface::MSG_INFORMATION_SNACK, nullptr);
220220
return;
221221
}
222222

@@ -232,9 +232,9 @@ void AddressesWidget::onStoreContactClicked(){
232232
ui->listAddresses->setVisible(true);
233233
}
234234

235-
emit message("", tr("New Contact Stored"), CClientUIInterface::MSG_INFORMATION, nullptr);
235+
emit message("", tr("New Contact Stored"), CClientUIInterface::MSG_INFORMATION_SNACK, nullptr);
236236
} else {
237-
emit message("", tr("Error Storing Contact"), CClientUIInterface::MSG_INFORMATION, nullptr);
237+
emit message("", tr("Error Storing Contact"), CClientUIInterface::MSG_INFORMATION_SNACK, nullptr);
238238
}
239239

240240
}

src/qt/pivx/privacywidget.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void PrivacyWidget::onSendClicked(){
255255
}
256256

257257
if(!GUIUtil::requestUnlock(walletModel, AskPassphraseDialog::Context::Mint_zPIV, true)){
258-
emit message("", tr("You need to unlock the wallet to be able to mint zPIV"), CClientUIInterface::MSG_INFORMATION);
258+
emit message("", tr("You need to unlock the wallet to be able to mint zPIV"), CClientUIInterface::MSG_INFORMATION_SNACK);
259259
return;
260260
}
261261

@@ -268,7 +268,7 @@ void PrivacyWidget::onSendClicked(){
268268

269269
if (value <= 0 || !isValid) {
270270
setCssEditLine(ui->lineEditAmount, false, true);
271-
emit message("", tr("Invalid value"), CClientUIInterface::MSG_INFORMATION);
271+
emit message("", tr("Invalid value"), CClientUIInterface::MSG_INFORMATION_SNACK);
272272
return;
273273
}
274274

@@ -285,10 +285,10 @@ void PrivacyWidget::onSendClicked(){
285285
void PrivacyWidget::mint(CAmount value){
286286
std::string strError;
287287
if(!walletModel->mintCoins(value, CoinControlDialog::coinControl, strError)){
288-
emit message("", tr(strError.data()), CClientUIInterface::MSG_INFORMATION);
288+
emit message("", tr(strError.data()), CClientUIInterface::MSG_INFORMATION_SNACK);
289289
}else{
290290
// Mint succeed
291-
emit message("", tr("zPIV minted successfully"), CClientUIInterface::MSG_INFORMATION);
291+
emit message("", tr("zPIV minted successfully"), CClientUIInterface::MSG_INFORMATION_SNACK);
292292

293293
// clear
294294
ui->lineEditAmount->clear();
@@ -312,7 +312,7 @@ void PrivacyWidget::spend(CAmount value){
312312
emit message("", receipt.GetStatusMessage().data(), CClientUIInterface::MSG_INFORMATION);
313313
}else{
314314
// Spend succeed
315-
emit message("", tr("zPIV converted back to PIV"), CClientUIInterface::MSG_INFORMATION);
315+
emit message("", tr("zPIV converted back to PIV"), CClientUIInterface::MSG_INFORMATION_SNACK);
316316

317317
// clear
318318
ui->lineEditAmount->clear();

src/qt/pivx/pwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void PWidget::changeTheme(bool isLightTheme, QString& theme){
2626
}
2727

2828
void PWidget::inform(const QString& message){
29-
emitMessage("", message, CClientUIInterface::MSG_INFORMATION);
29+
emitMessage("", message, CClientUIInterface::MSG_INFORMATION_SNACK);
3030
}
3131

3232
void PWidget::warn(const QString& title, const QString& message){

src/qt/pivx/send.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void SendWidget::addEntry(){
226226
entry->setNumber(1);
227227
}else if(entries.length() == MAX_SEND_POPUP_ENTRIES){
228228
// TODO: Snackbar notifying that it surpassed the max amount of entries
229-
emit message("", tr("Maximum amount of outputs reached"),CClientUIInterface::MSG_INFORMATION);
229+
emit message("", tr("Maximum amount of outputs reached"), CClientUIInterface::MSG_INFORMATION_SNACK);
230230
return;
231231
}
232232

@@ -272,15 +272,15 @@ void SendWidget::onSendClicked(){
272272
recipients.append(entry->getValue());
273273
}else{
274274
// Invalid entry.. todo: notificate user about this.
275-
emit message("", tr("Invalid entry"),CClientUIInterface::MSG_INFORMATION);
275+
emit message("", tr("Invalid entry"),CClientUIInterface::MSG_INFORMATION_SNACK);
276276
return;
277277
}
278278

279279
}
280280

281281
if (recipients.isEmpty()) {
282282
//todo: notificate user about this.
283-
emit message("", tr("No set recipients"),CClientUIInterface::MSG_INFORMATION);
283+
emit message("", tr("No set recipients"),CClientUIInterface::MSG_INFORMATION_SNACK);
284284
return;
285285
}
286286

@@ -294,7 +294,7 @@ void SendWidget::onSendClicked(){
294294
// Unlock wallet was cancelled
295295
//TODO: Check what is this --> fNewRecipientAllowed = true;
296296
// TODO: Notify the user..
297-
emit message("", tr("Cannot send, wallet locked"),CClientUIInterface::MSG_INFORMATION);
297+
emit message("", tr("Cannot send, wallet locked"),CClientUIInterface::MSG_INFORMATION_SNACK);
298298
return;
299299
}
300300

@@ -327,7 +327,7 @@ bool SendWidget::send(QList<SendCoinsRecipient> recipients){
327327
if (prepareStatus.status != WalletModel::OK) {
328328
// TODO: Check why this??
329329
//fNewRecipientAllowed = true;
330-
emit message("", tr("Prepare status failed.."),CClientUIInterface::MSG_INFORMATION);
330+
emit message("", tr("Prepare status failed.."),CClientUIInterface::MSG_INFORMATION_SNACK);
331331
return false;
332332
}
333333

@@ -352,7 +352,7 @@ bool SendWidget::send(QList<SendCoinsRecipient> recipients){
352352
//coinControlUpdateLabels();
353353
//
354354
clearAll();
355-
emit message("", tr("Transaction sent"),CClientUIInterface::MSG_INFORMATION);
355+
emit message("", tr("Transaction sent"),CClientUIInterface::MSG_INFORMATION_SNACK);
356356
return true;
357357
}
358358

@@ -419,7 +419,7 @@ bool SendWidget::sendZpiv(QList<SendCoinsRecipient> recipients){
419419
outputs
420420
)
421421
) {
422-
emit message("", tr("zPIV transaction sent!"), CClientUIInterface::MSG_INFORMATION);
422+
emit message("", tr("zPIV transaction sent!"), CClientUIInterface::MSG_INFORMATION_SNACK);
423423
clearAll();
424424
return true;
425425
} else {
@@ -549,7 +549,7 @@ void SendWidget::onChangeAddressClicked(){
549549
if (dialog->getAddress(walletModel, &ret)) {
550550
coinControl->destChange = CBitcoinAddress(ret.toStdString()).Get();
551551
}else{
552-
emit message("", tr("Invalid change address"), CClientUIInterface::MSG_INFORMATION);
552+
emit message("", tr("Invalid change address"), CClientUIInterface::MSG_INFORMATION_SNACK);
553553
}
554554
}
555555
}

src/qt/pivx/tooltipmenu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ void TooltipMenu::deleteClicked(){
5151
);
5252
if (ret) {
5353
if (this->walletModel->getAddressTableModel()->removeRows(index.row(), 1, index)) {
54-
emit message("", tr("Contact Deleted"), CClientUIInterface::MSG_INFORMATION);
54+
emit message("", tr("Contact Deleted"), CClientUIInterface::MSG_INFORMATION_SNACK);
5555
} else {
56-
emit message("", tr("Error deleting a contact"), CClientUIInterface::MSG_INFORMATION);
56+
emit message("", tr("Error deleting a contact"), CClientUIInterface::MSG_INFORMATION_SNACK);
5757
}
5858
hide();
5959
}

0 commit comments

Comments
 (0)