|
|
@ -115,6 +115,7 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
|
// Initialize to the balances tab
|
|
|
|
ui->tabWidget->setCurrentIndex(0); |
|
|
|
|
|
|
|
|
|
|
|
setupSendTab(); |
|
|
|
setupTransactionsTab(); |
|
|
|
setupReceiveTab(); |
|
|
@ -1148,8 +1149,30 @@ void MainWindow::getQRCode(QString addr) { |
|
|
|
// Display QR Code for address
|
|
|
|
qrui.qrcodeDisplayAddr->setQrcodeString(addr); |
|
|
|
|
|
|
|
// Set text/tip
|
|
|
|
qrui.saveQRCodeBtn->setText(tr("Save")); |
|
|
|
qrui.saveQRCodeBtn->setToolTip(tr("Save QR Code to file")); |
|
|
|
|
|
|
|
auto isDialogAlive = std::make_shared<bool>(true); |
|
|
|
|
|
|
|
// Connect and handle Save button
|
|
|
|
QObject::connect(qrui.saveQRCodeBtn, &QPushButton::clicked, [&] () { |
|
|
|
qDebug() << "Save QR Code clicked"; |
|
|
|
QString fileName = QFileDialog::getSaveFileName(this, |
|
|
|
tr("Save QR Code to file"), "", |
|
|
|
tr("Portable Network Graphics (*.png);;All Files (*)")); |
|
|
|
|
|
|
|
if (fileName.isEmpty()) |
|
|
|
return; |
|
|
|
else { |
|
|
|
QFile file(fileName); |
|
|
|
// TODO: fix this. Saves as black image instead of QR code
|
|
|
|
qrui.qrcodeDisplayAddr->grab().save(fileName, "png", -1); |
|
|
|
statusBar()->showMessage(tr("QR code saved"), 3000); |
|
|
|
d.close(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
d.exec(); |
|
|
|
*isDialogAlive = false; |
|
|
|
} |
|
|
@ -1450,8 +1473,10 @@ void MainWindow::setupPeersTab() { |
|
|
|
|
|
|
|
auto bannedPeerModel = dynamic_cast<BannedPeersTableModel *>(ui->bannedPeersTable->model()); |
|
|
|
QString addr = bannedPeerModel->getAddress(index.row()); |
|
|
|
qint64 asn = bannedPeerModel->getASN(index.row()); |
|
|
|
QString ip = peer2ip(addr); |
|
|
|
QString subnet = bannedPeerModel->getSubnet(index.row()); |
|
|
|
QString as = QString::number(asn); |
|
|
|
//qint64 banned_until = bannedPeerModel->getBannedUntil(index.row());
|
|
|
|
|
|
|
|
if(!ip.isEmpty()) { |
|
|
@ -1471,6 +1496,14 @@ void MainWindow::setupPeersTab() { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
if(!as.isEmpty()) { |
|
|
|
menu.addAction(tr("View ASN on bgpview.io (3rd party service)"), [=] () { |
|
|
|
QString url = "https://bgpview.io/asn/" + as; |
|
|
|
qDebug() << "opening " << url; |
|
|
|
QDesktopServices::openUrl(QUrl(url)); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
if(!ip.isEmpty()) { |
|
|
|
menu.addAction(tr("Unban this peer"), [=] () { |
|
|
|
ui->statusBar->showMessage(tr("Unbanning peer...")); |
|
|
@ -2190,7 +2223,7 @@ void MainWindow::rescanButtonClicked(int number) { |
|
|
|
if (dialog.exec() == QDialog::Accepted) { |
|
|
|
|
|
|
|
// Show message in status bar
|
|
|
|
ui->statusBar->showMessage(tr("Rescanning..."), 3 * 1000); |
|
|
|
ui->statusBar->showMessage(tr("Rescanning...")); |
|
|
|
|
|
|
|
// Close settings
|
|
|
|
QWidget *modalWidget = QApplication::activeModalWidget(); |
|
|
@ -2204,50 +2237,33 @@ void MainWindow::rescanButtonClicked(int number) { |
|
|
|
// Call rescan RPC
|
|
|
|
rpc->rescan(rescanHeight, [=] (QJsonValue response){ |
|
|
|
qDebug() << "rescanning finished" << response; |
|
|
|
ui->statusBar->showMessage(tr("Rescanning finished"), 3000); |
|
|
|
}); |
|
|
|
|
|
|
|
// TODO: Display progress somewhere by reading debug.log
|
|
|
|
#ifdef Q_OS_LINUX |
|
|
|
auto debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, ".hush/HUSH3/debug.log"); |
|
|
|
if(!QFile(debugLocation).exists()) { |
|
|
|
// legacy location
|
|
|
|
debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, ".komodo/HUSH3/debug.log"); |
|
|
|
} |
|
|
|
#elif defined(Q_OS_DARWIN) |
|
|
|
auto debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, "Library/Application Support/Hush/HUSH3/debug.log"); |
|
|
|
if(!QFile(debugLocation).exists()) { |
|
|
|
// legacy location
|
|
|
|
debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, "Library/Application Support/Komodo/HUSH3/debug.log"); |
|
|
|
} |
|
|
|
#else |
|
|
|
auto debugLocation = QStandardPaths::locate(QStandardPaths::AppDataLocation, "../../Hush/HUSH3/debug.log"); |
|
|
|
if(!QFile(debugLocation).exists()) { |
|
|
|
// legacy location
|
|
|
|
debugLocation = QStandardPaths::locate(QStandardPaths::AppDataLocation, "../../Komodo/HUSH3/debug.log"); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
if(QFile(debugLocation).exists()){ |
|
|
|
qDebug() << "Found debug.log at "+ debugLocation; |
|
|
|
QFile debugLog(debugLocation); |
|
|
|
|
|
|
|
if(debugLog.open(QIODevice::ReadOnly)){ |
|
|
|
debugLog.seek(debugLog.size()-1); |
|
|
|
int count = 0; |
|
|
|
int lines = 25; |
|
|
|
while ( (count < lines) && (debugLog.pos() > 0) ) |
|
|
|
{ |
|
|
|
QString ch = debugLog.read(1); |
|
|
|
debugLog.seek(debugLog.pos()-2); |
|
|
|
if (ch == "\n") |
|
|
|
count++; |
|
|
|
} |
|
|
|
qDebug() << "debug.log =" + debugLog.readAll(); |
|
|
|
debugLog.close(); |
|
|
|
}else{ |
|
|
|
qDebug() <<"couldn't open debug.log for reading"; |
|
|
|
// Get rescan info
|
|
|
|
QTimer *rescanTimer = new QTimer(this); |
|
|
|
QObject::connect(rescanTimer, &QTimer::timeout, [=]() { |
|
|
|
rpc->getRescanInfo([=] (QJsonValue response){ |
|
|
|
|
|
|
|
|
|
|
|
auto rescanning = response.toObject().value("rescanning").toBool(); |
|
|
|
auto rescan_progress = response.toObject().value("rescan_progress").toString(); |
|
|
|
auto rescan_start_height = (qint64)response.toObject().value("rescan_start_height").toInt(); |
|
|
|
auto rescan_height = (qint64)response.toObject().value("rescan_height").toInt(); |
|
|
|
double percent = QString(rescan_progress).toDouble() * 100; |
|
|
|
qDebug() << "getrescaninfo" << rescanning << " " << percent << " " << rescan_start_height << " " << rescan_height; |
|
|
|
|
|
|
|
if(rescanning){ |
|
|
|
qDebug() << "Rescanning..."; |
|
|
|
ui->statusBar->showMessage(tr("Rescanning... ") + QString::number(percent)+ "% " + QObject::tr("at height") + " " + QString::number(rescan_height)); |
|
|
|
} |
|
|
|
else{ |
|
|
|
qDebug() << "rescanTimer Stop"; |
|
|
|
rescanTimer->stop(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
rescanTimer->start(1000); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|