Merge pull request 'Replace showMessageBox with Qt builtin' (#218) from tobtoht/feather:messagebox_cleanup into master

Reviewed-on: feather/feather#218
remotes/1691844314220217825/master
tobtoht 3 years ago
commit c5f0962e40

@ -36,8 +36,6 @@
<file>assets/images/eye_blind.png</file>
<file>assets/images/feather.png</file>
<file>assets/images/file.png</file>
<file>assets/images/ghost.png</file>
<file>assets/images/ghost_icon.png</file>
<file>assets/images/gnome-calc.png</file>
<file>assets/images/history.png</file>
<file>assets/images/info.png</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

@ -14,6 +14,7 @@
#include <QKeyEvent>
#include <QMenu>
#include <QAction>
#include <QMessageBox>
CoinsWidget::CoinsWidget(QWidget *parent)
: QWidget(parent)
@ -197,7 +198,7 @@ void CoinsWidget::onSweepOutput() {
qCritical() << "key image: " << keyImage;
if (!keyImageKnown) {
Utils::showMessageBox("Unable to sweep output", "Unable to sweep output: key image unknown", true);
QMessageBox::warning(this, "Unable to sweep output", "Unable to sweep output: key image unknown");
return;
}

@ -104,7 +104,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
"Try to explain not only what the bug is, but how it occurs.</body>");
});
connect(ui->actionShow_debug_info, &QAction::triggered, this, &MainWindow::showDebugInfo);
connect(ui->actionOfficialWebsite, &QAction::triggered, [=] { Utils::externalLinkWarning("https://featherwallet.org"); });
connect(ui->actionOfficialWebsite, &QAction::triggered, [=] { Utils::externalLinkWarning(this, "https://featherwallet.org"); });
#if defined(HAS_XMRTO)
// xmr.to connects/widget
@ -115,7 +115,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
connect(m_ctx->XMRTo, &XmrTo::connectionError, ui->xmrToWidget, &XMRToWidget::onConnectionError);
connect(m_ctx->XMRTo, &XmrTo::connectionSuccess, ui->xmrToWidget, &XMRToWidget::onConnectionSuccess);
connect(m_ctx, &AppContext::balanceUpdated, ui->xmrToWidget, &XMRToWidget::onBalanceUpdated);
connect(m_ctx->XMRTo, &XmrTo::openURL, this, [=](const QString &url){ Utils::externalLinkWarning(url); });
connect(m_ctx->XMRTo, &XmrTo::openURL, this, [=](const QString &url){ Utils::externalLinkWarning(this, url); });
ui->xmrToWidget->setHistoryModel(m_ctx->XMRTo->tableModel);
#else
ui->tabExchanges->setTabVisible(0, false);
@ -243,13 +243,13 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
"for developers only. Your coins are WORTHLESS.");
if(m_ctx->networkType == NetworkType::STAGENET) {
if (config()->get(Config::warnOnStagenet).toBool()) {
Utils::showMessageBox("Warning", worthlessWarning.arg("stagenet"), true);
QMessageBox::warning(this, "Warning", worthlessWarning.arg("stagenet"));
config()->set(Config::warnOnStagenet, false);
}
}
else if(m_ctx->networkType == NetworkType::TESTNET){
if (config()->get(Config::warnOnTestnet).toBool()) {
Utils::showMessageBox("Warning", worthlessWarning.arg("testnet"), true);
QMessageBox::warning(this, "Warning", worthlessWarning.arg("testnet"));
config()->set(Config::warnOnTestnet, false);
}
}
@ -463,7 +463,7 @@ void MainWindow::initMenu() {
if(fn.isEmpty()) return;
if(!fn.endsWith(".csv")) fn += ".csv";
m_ctx->currentWallet->history()->writeCSV(fn);
Utils::showMessageBox("CSV export", QString("Transaction history exported to %1").arg(fn), false);
QMessageBox::information(this, "CSV export", QString("Transaction history exported to %1").arg(fn));
});
// Contact widget
@ -471,7 +471,7 @@ void MainWindow::initMenu() {
if(m_ctx->currentWallet == nullptr) return;
auto *model = m_ctx->currentWallet->addressBookModel();
if (model->rowCount() <= 0){
Utils::showMessageBox("Error", "Addressbook empty", true);
QMessageBox::warning(this, "Error", "Addressbook empty");
return;
}
@ -481,7 +481,7 @@ void MainWindow::initMenu() {
qint64 now = QDateTime::currentDateTime().currentMSecsSinceEpoch();
QString fn = QString("%1/monero-contacts_%2.csv").arg(targetDir, QString::number(now / 1000));
if(model->writeCSV(fn))
Utils::showMessageBox("Address book exported", QString("Address book exported to %1").arg(fn), false);
QMessageBox::information(this, "Address book exported", QString("Address book exported to %1").arg(fn));
});
connect(ui->actionImportContactsCSV, &QAction::triggered, this, &MainWindow::importContacts);
@ -560,7 +560,7 @@ void MainWindow::touchbarShowWallet() {
}
void MainWindow::onWalletCreatedError(const QString &err) {
Utils::showMessageBox("Wallet creation error", err, true);
QMessageBox::warning(this, "Wallet creation error", err);
this->showWizard(WalletWizard::Page_CreateWallet);
}
@ -737,12 +737,12 @@ void MainWindow::onCreateTransactionSuccess(PendingTransaction *tx, const QStrin
err = QString("%1 %2").arg(err).arg(tx_err);
qDebug() << Q_FUNC_INFO << err;
Utils::showMessageBox("Transaction error", err, true);
QMessageBox::warning(this, "Transactions error", err);
m_ctx->currentWallet->disposeTransaction(tx);
} else if (tx->txCount() == 0) {
err = QString("%1 %2").arg(err).arg("No unmixable outputs to sweep.");
qDebug() << Q_FUNC_INFO << err;
Utils::showMessageBox("Transaction error", err, true);
QMessageBox::warning(this, "Transaction error", err);
m_ctx->currentWallet->disposeTransaction(tx);
} else {
const auto &description = m_ctx->tmpTxDescription;
@ -968,12 +968,12 @@ void MainWindow::menuWalletOpenClicked() {
QFileInfo infoPath(path);
if(!infoPath.isReadable()) {
Utils::showMessageBox("Cannot read wallet file", "Permission error.", true);
QMessageBox::warning(this, "Cannot read wallet file", "Permission error.");
return;
}
if(path == m_ctx->walletPath) {
Utils::showMessageBox("Wallet already opened", "Please open another wallet.", true);
QMessageBox::warning(this, "Wallet already opened", "Please open another wallet.");
return;
}
@ -1051,7 +1051,7 @@ void MainWindow::showSendScreen(const CCSEntry &entry) {
void MainWindow::onViewOnBlockExplorer(const QString &txid) {
QString blockExplorerLink = Utils::blockExplorerLink(config()->get(Config::blockExplorer).toString(), m_ctx->networkType, txid);
Utils::externalLinkWarning(blockExplorerLink);
Utils::externalLinkWarning(this, blockExplorerLink);
}
void MainWindow::onAddContact(const QString &address, const QString &name) {

@ -276,7 +276,7 @@ bool Utils::testSocks5(const QString &host, quint16 port){
return false;
}
void Utils::externalLinkWarning(const QString &url){
void Utils::externalLinkWarning(QWidget *parent, const QString &url){
if(!config()->get(Config::warnOnExternalLink).toBool()) {
QDesktopServices::openUrl(QUrl(url));
return;
@ -286,7 +286,7 @@ void Utils::externalLinkWarning(const QString &url){
body += QString("%1\n\n").arg(url);
body += "You will NOT be using Tor.";
switch (Utils::showMessageBox("External link warning", body, true)) {
switch (QMessageBox::warning(parent, "External link warning", body, QMessageBox::Cancel|QMessageBox::Ok)) {
case QMessageBox::Cancel:
break;
default:
@ -327,26 +327,6 @@ bool Utils::walletExists(QString name, const QString &path) {
return Utils::fileExists(walletPath);
}
int Utils::showMessageBox(const QString &windowTitle, const QString &body, bool warning){
QMessageBox msgBox(QApplication::activeWindow());
msgBox.setWindowTitle(windowTitle);
msgBox.setText(body);
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
if(warning) {
QPixmap iconWarning = QPixmap(":/assets/images/ghost_icon.png");
msgBox.setIconPixmap(iconWarning);
}
else {
QPixmap iconInfo = QPixmap(":/assets/images/info.png")
.scaled(QSize(48,48), Qt::KeepAspectRatio, Qt::SmoothTransformation);
msgBox.setIconPixmap(iconInfo);
}
return msgBox.exec();
}
void Utils::copyToClipboard(const QString &string){
QClipboard * clipboard = QApplication::clipboard();
if (!clipboard) {

@ -75,8 +75,7 @@ public:
static QStringList readJsonStringToQStringList(const QString &input);
static void applicationLogHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
static void openWindow(QWidget *w);
static void externalLinkWarning(const QString &url);
static int showMessageBox(const QString &windowTitle, const QString &body, bool warning);
static void externalLinkWarning(QWidget *parent, const QString &url);
static QList<processStruct> procList();
static bool dirExists(const QString &path);
static QString barrayToString(const QByteArray &data);
@ -98,8 +97,6 @@ public:
static QString formatBytes(quint64 bytes);
static QString amountToCurrencyString(double amount, const QString &currencyCode);
static QStringList randomHTTPAgents;
template<typename QEnum>
static QString QtEnumToString (const QEnum value)
{

@ -42,7 +42,7 @@ void CCSWidget::linkClicked() {
auto entry = m_model->entry(index.row());
if (entry)
Utils::externalLinkWarning(entry->url);
Utils::externalLinkWarning(this, entry->url);
}
void CCSWidget::donateClicked() {

@ -113,14 +113,14 @@ void NodeWidget::onContextWSStatusURL() {
QModelIndex index = ui->wsView->currentIndex();
if (!index.isValid()) return;
FeatherNode node = m_wsModel->node(index.row());
Utils::externalLinkWarning(node.as_url());
Utils::externalLinkWarning(this, node.as_url());
}
void NodeWidget::onContextCustomStatusURL() {
QModelIndex index = ui->customView->currentIndex();
if (!index.isValid()) return;
FeatherNode node = m_customModel->node(index.row());
Utils::externalLinkWarning(node.as_url());
Utils::externalLinkWarning(this, node.as_url());
}
void NodeWidget::onContextDisconnect() {

@ -37,7 +37,7 @@ void RedditWidget::linkClicked() {
auto post = m_model->post(index.row());
if (post) {
Utils::externalLinkWarning(post->url);
Utils::externalLinkWarning(this, post->url);
}
}

@ -155,7 +155,7 @@ void XMRigWidget::onStartClicked() {
if(username.isEmpty()) {
QString err = "Please specify a receiving address on the Settings screen";
ui->console->appendPlainText(err);
Utils::showMessageBox("Error", err, true);
QMessageBox::warning(this, "Error", err);
return;
}
@ -286,7 +286,7 @@ void XMRigWidget::onSoloChecked(int state) {
void XMRigWidget::linkClicked() {
QModelIndex index = ui->tableView->currentIndex();
auto download_link = m_urls.at(index.row());
Utils::externalLinkWarning(download_link);
Utils::externalLinkWarning(this, download_link);
}
QStandardItemModel *XMRigWidget::model() {

@ -8,6 +8,7 @@
#include <QPushButton>
#include <QFileDialog>
#include <QMessageBox>
// @TODO: rescan wallet dir on wizard open
@ -27,7 +28,7 @@ OpenWalletPage::OpenWalletPage(AppContext *ctx, QWidget *parent) :
QFileInfo infoPath(path);
if(!infoPath.isReadable()) {
Utils::showMessageBox("Cannot read wallet file", "Permission error.", true);
QMessageBox::warning(this, "Cannot read wallet file", "Permission error.");
return;
}
@ -67,7 +68,7 @@ int OpenWalletPage::nextId() const {
bool OpenWalletPage::validatePage() {
QModelIndex index = ui->walletTable->currentIndex();
if(!index.isValid()) {
Utils::showMessageBox("Wallet not selected", "Please select a wallet from the list.", true);
QMessageBox::warning(this, "Wallet not selected", "Please select a wallet from the list.");
return false;
}
QString walletPath = index.model()->data(index.siblingAtColumn(WalletKeysFilesModel::ModelColumns::Path), Qt::UserRole).toString();

@ -86,7 +86,7 @@ void XMRToWidget::onCreateOrder() {
auto amount = ui->lineAmount->text();
if(amount.isEmpty()) {
Utils::showMessageBox("Cannot create XMR.To order", "Invalid amount", false);
QMessageBox::warning(this, "Cannot create XMR.To order", "Invalid amount");
return;
}
@ -99,7 +99,7 @@ void XMRToWidget::onCreateOrder() {
auto available = m_unlockedBalance;
if(amount_xmr > available){
Utils::showMessageBox("Cannot create XMR.To order", "Not enough Monero to create order.", false);
QMessageBox::warning(this, "Cannot create XMR.To order", "Not enough Monero to create order.");
return;
}

Loading…
Cancel
Save