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

2
src/mainwindow.ui

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

Loading…
Cancel
Save