Browse Source

change animation for sending messages #84

pull/130/head
DenioD 4 years ago
parent
commit
c69abfc7f9
  1. 2
      application.qrc
  2. BIN
      res/loaderblack.gif
  3. BIN
      res/loaderwhite.gif
  4. 94
      src/chatmodel.cpp
  5. 2
      src/mainwindow.ui

2
application.qrc

@ -55,6 +55,8 @@
<file>res/silentdragonlite-animated-dark.gif</file> <file>res/silentdragonlite-animated-dark.gif</file>
<file>res/silentdragonlite-animated-startup.gif</file> <file>res/silentdragonlite-animated-startup.gif</file>
<file>res/silentdragonlite-animated-startup-dark.gif</file> <file>res/silentdragonlite-animated-startup-dark.gif</file>
<file>res/loaderblack.gif</file>
<file>res/loaderwhite.gif</file>
</qresource> </qresource>
<qresource prefix="/translations"> <qresource prefix="/translations">
<file>res/silentdragonlite_de.qm</file> <file>res/silentdragonlite_de.qm</file>

BIN
res/loaderblack.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
res/loaderwhite.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

94
src/chatmodel.cpp

@ -580,44 +580,51 @@ void MainWindow::sendChat() {
qDebug() << "Tx aborted"; qDebug() << "Tx aborted";
} }
// Create a new Dialog to show that we are computing/sending the Tx auto movie = new QMovie(this);
auto d = new QDialog(this); auto movie1 = new QMovie(this);
auto connD = new Ui_ConnectionDialog(); movie->setFileName(":/img/res/loaderblack.gif");
connD->setupUi(d); movie1->setFileName(":/img/res/loaderwhite.gif");
QMovie *movie1 = new QMovie(":/img/res/silentdragonlite-animated.gif");;
QMovie *movie2 = new QMovie(":/img/res/silentdragonlite-animated-dark.gif");;
auto theme = Settings::getInstance()->get_theme_name(); auto theme = Settings::getInstance()->get_theme_name();
if (theme == "dark" || theme == "midnight") { if (theme == "dark" || theme == "midnight") {
movie2->setScaledSize(QSize(512,512));
connD->topIcon->setMovie(movie2); connect(movie, &QMovie::frameChanged, [=]{
movie2->start(); ui->sendChatButton->setIcon(movie->currentPixmap());
});
movie->start();
ui->sendChatButton->show();
} else { } else {
movie1->setScaledSize(QSize(512,512));
connD->topIcon->setMovie(movie1);
movie1->start();
}
connD->status->setText(tr("Please wait...")); connect(movie1, &QMovie::frameChanged, [=]{
connD->statusDetail->setText(tr("Your Message will be sent")); ui->sendChatButton->setIcon(movie1->currentPixmap());
});
movie1->start();
ui->sendChatButton->show();
}
d->show();
ui->memoTxtChat->clear(); ui->memoTxtChat->clear();
// And send the Tx // And send the Tx
rpc->executeTransaction(tx, rpc->executeTransaction(tx,
[=] (QString txid) { [=] (QString txid) {
ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid); ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid);
connD->status->setText(tr("Done!"));
connD->statusDetail->setText(txid);
QTimer::singleShot(1000, [=]() { QTimer::singleShot(1000, [=]() {
d->accept();
d->close(); if (theme == "dark" || theme == "midnight") {
delete connD; QPixmap send(":/icons/res/send-white.png");
delete d; QIcon sendIcon(send);
ui->sendChatButton->setIcon(sendIcon);
movie->stop();
}else{
QPixmap send(":/icons/res/sendBlack.png");
QIcon sendIcon(send);
ui->sendChatButton->setIcon(sendIcon);
movie1->stop();
}
}); });
@ -630,19 +637,31 @@ void MainWindow::sendChat() {
[=] (QString opid, QString errStr) { [=] (QString opid, QString errStr) {
ui->statusBar->showMessage(QObject::tr(" Tx ") % opid % QObject::tr(" failed"), 15 * 1000); ui->statusBar->showMessage(QObject::tr(" Tx ") % opid % QObject::tr(" failed"), 15 * 1000);
d->accept();
d->close();
delete connD;
delete d;
if (!opid.isEmpty()) if (!opid.isEmpty())
errStr = QObject::tr("The transaction with id ") % opid % QObject::tr(" failed. The error was") + ":\n\n" + errStr; errStr = QObject::tr("The transaction with id ") % opid % QObject::tr(" failed. The error was") + ":\n\n" + errStr;
QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok); QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok);
movie->stop();
if (theme == "dark" || theme == "midnight") {
QPixmap send(":/icons/res/send-white.png");
QIcon sendIcon(send);
ui->sendChatButton->setIcon(sendIcon);
movie->stop();
}else{
QPixmap send(":/icons/res/sendBlack.png");
QIcon sendIcon(send);
ui->sendChatButton->setIcon(sendIcon);
movie1->stop();
}
} }
); );
// rpc->refresh(true);
} }
QString MainWindow::doSendChatTxValidations(Tx tx) { QString MainWindow::doSendChatTxValidations(Tx tx) {
@ -760,8 +779,6 @@ Tx MainWindow::createTxForSafeContactRequest()
QString hashEncryptionKey = passphrase; QString hashEncryptionKey = passphrase;
int length = hashEncryptionKey.length(); int length = hashEncryptionKey.length();
qDebug()<<"Encryption String :"<<hashEncryptionKey;
////////////////Generate the secretkey for our message encryption ////////////////Generate the secretkey for our message encryption
char *hashEncryptionKeyraw = NULL; char *hashEncryptionKeyraw = NULL;
hashEncryptionKeyraw = new char[length+1]; hashEncryptionKeyraw = new char[length+1];
@ -784,20 +801,16 @@ Tx MainWindow::createTxForSafeContactRequest()
QString publicKey = QByteArray(reinterpret_cast<const char*>(pk), crypto_kx_PUBLICKEYBYTES).toHex(); QString publicKey = QByteArray(reinterpret_cast<const char*>(pk), crypto_kx_PUBLICKEYBYTES).toHex();
qDebug()<<"Publickey created Request: "<<publicKey;
QString hmemo= createHeaderMemo(type,cid,myAddr,"", publicKey); QString hmemo= createHeaderMemo(type,cid,myAddr,"", publicKey);
tx.toAddrs.push_back(ToFields{addr, amt, hmemo}); tx.toAddrs.push_back(ToFields{addr, amt, hmemo});
tx.toAddrs.push_back(ToFields{addr, amt, memo}); tx.toAddrs.push_back(ToFields{addr, amt, memo});
qDebug() << "pushback chattx";
tx.fee = Settings::getMinerFee(); tx.fee = Settings::getMinerFee();
} }
return tx; return tx;
qDebug() << "RequestTx created";
} }
void MainWindow::ContactRequest() { void MainWindow::ContactRequest() {
@ -843,15 +856,14 @@ void MainWindow::ContactRequest() {
// abort the Tx // abort the Tx
return; return;
qDebug() << "Tx aborted";
} }
// Create a new Dialog to show that we are computing/sending the Tx // Create a new Dialog to show that we are computing/sending the Tx
auto d = new QDialog(this); auto d = new QDialog(this);
auto connD = new Ui_ConnectionDialog(); auto connD = new Ui_ConnectionDialog();
connD->setupUi(d); connD->setupUi(d);
QMovie *movie1 = new QMovie(":/img/res/silentdragonlite-animated.gif");; QMovie *movie1 = new QMovie(":/img/res/silentdragonlite-animated.gif");
QMovie *movie2 = new QMovie(":/img/res/silentdragonlite-animated-dark.gif");; QMovie *movie2 = new QMovie(":/img/res/silentdragonlite-animated-dark.gif");
auto theme = Settings::getInstance()->get_theme_name(); auto theme = Settings::getInstance()->get_theme_name();
if (theme == "dark" || theme == "midnight") { if (theme == "dark" || theme == "midnight") {
movie2->setScaledSize(QSize(512,512)); movie2->setScaledSize(QSize(512,512));

2
src/mainwindow.ui

@ -426,7 +426,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1226</width> <width>1226</width>
<height>509</height> <height>493</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="sendToLayout"> <layout class="QVBoxLayout" name="sendToLayout">

Loading…
Cancel
Save