From ca247357e9975c826efde086d8b587b3c8e37a8b Mon Sep 17 00:00:00 2001 From: Jon Spock Date: Wed, 10 Jul 2019 19:34:53 -0700 Subject: [PATCH 1/3] fix/change QT deprecated code --- src/qt/bitcoingui.cpp | 4 ++-- src/qt/receivecoinsdialog.cpp | 6 ++---- src/qt/rpcconsole.cpp | 21 +++++++-------------- src/qt/splashscreen.cpp | 3 ++- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index c44bfefa1..f1a25f11b 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -63,6 +63,7 @@ #include #include #include +#include const std::string BitcoinGUI::DEFAULT_UIPLATFORM = #if defined(Q_OS_MAC) @@ -86,8 +87,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node &node, const Config *configIn, QSettings settings; if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) { // Restore failed (perhaps missing setting), center the window - move(QApplication::desktop()->availableGeometry().center() - - frameGeometry().center()); + move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center()); } if (DVTUI::customThemeIsSet()) { diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index 4c3cd54ff..d7c87092a 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -254,10 +254,8 @@ void ReceiveCoinsDialog::copyColumnToClipboard(int column) { if (!firstIndex.isValid()) { return; } - GUIUtil::setClipboard( - model->getRecentRequestsTableModel() - ->data(firstIndex.child(firstIndex.row(), column), Qt::EditRole) - .toString()); + GUIUtil::setClipboard( + model->getRecentRequestsTableModel()->data(firstIndex.sibling(firstIndex.row(), column), Qt::EditRole).toString()); } // context menu diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index e1f123429..745d72a54 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -42,6 +42,7 @@ #include #include #include +#include // TODO: add a scrollback limit, as there is currently none // TODO: make it possible to filter out categories (esp debug messages when @@ -521,8 +522,7 @@ RPCConsole::RPCConsole(interfaces::Node &node, if (!restoreGeometry( settings.value("RPCConsoleWindowGeometry").toByteArray())) { // Restore failed (perhaps missing setting), center the window - move(QApplication::desktop()->availableGeometry().center() - - frameGeometry().center()); + move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center()); } if(DVTUI::customThemeIsSet()) { QString appstyle = "fusion"; @@ -705,18 +705,11 @@ void RPCConsole::setClientModel(ClientModel *model) { // to use int (instead of int64_t), because signal mapper only supports // int or objects, which is okay because max bantime (1 year) is < // int_max. - QSignalMapper *signalMapper = new QSignalMapper(this); - signalMapper->setMapping(banAction1h, 60 * 60); - signalMapper->setMapping(banAction24h, 60 * 60 * 24); - signalMapper->setMapping(banAction7d, 60 * 60 * 24 * 7); - signalMapper->setMapping(banAction365d, 60 * 60 * 24 * 365); - connect(banAction1h, SIGNAL(triggered()), signalMapper, SLOT(map())); - connect(banAction24h, SIGNAL(triggered()), signalMapper, SLOT(map())); - connect(banAction7d, SIGNAL(triggered()), signalMapper, SLOT(map())); - connect(banAction365d, SIGNAL(triggered()), signalMapper, SLOT(map())); - connect(signalMapper, SIGNAL(mapped(int)), this, - SLOT(banSelectedNode(int))); - + connect(banAction1h, &QAction::triggered, [this]() { banSelectedNode(60*60); }); + connect(banAction24h, &QAction::triggered, [this]() { banSelectedNode(24*60*60); }); + connect(banAction7d, &QAction::triggered, [this]() { banSelectedNode(7*24*60*60); }); + connect(banAction365d, &QAction::triggered, [this]() { banSelectedNode(365*24*60*60); }); + // peer table context menu signals connect(ui->peerWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index c56567fb1..923d30c05 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -24,6 +24,7 @@ #include #include #include +#include SplashScreen::SplashScreen(interfaces::Node &node, Qt::WindowFlags f, const NetworkStyle *networkStyle) @@ -123,7 +124,7 @@ SplashScreen::SplashScreen(interfaces::Node &node, Qt::WindowFlags f, pixmap.size().height() / devicePixelRatio)); resize(r.size()); setFixedSize(r.size()); - move(QApplication::desktop()->screenGeometry().center() - r.center()); + move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center()); subscribeToCoreSignals(); installEventFilter(this); From 668e449da51cd37543119c85cbeebed6a5dfee11 Mon Sep 17 00:00:00 2001 From: Jon Spock Date: Wed, 10 Jul 2019 19:50:52 -0700 Subject: [PATCH 2/3] Replace QSignalMapper in transactionview --- src/qt/transactionview.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index e2983cb5b..ea8259b90 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -173,12 +172,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, contextMenu->addAction(abandonAction); contextMenu->addAction(editLabelAction); - mapperThirdPartyTxUrls = new QSignalMapper(this); - // Connect actions - connect(mapperThirdPartyTxUrls, SIGNAL(mapped(QString)), this, - SLOT(openThirdPartyTxUrl(QString))); - connect(amountWidget, &QLineEdit::textChanged, this, &TransactionView::changedAmount); connect(dateWidget, @@ -260,10 +254,8 @@ void TransactionView::setModel(WalletModel *_model) { contextMenu->addSeparator(); } contextMenu->addAction(thirdPartyTxUrlAction); - connect(thirdPartyTxUrlAction, SIGNAL(triggered()), - mapperThirdPartyTxUrls, SLOT(map())); - mapperThirdPartyTxUrls->setMapping(thirdPartyTxUrlAction, - listUrls[i].trimmed()); + auto l = listUrls[i]; + connect(thirdPartyTxUrlAction, &QAction::triggered, [l]() {(void)l.trimmed();}); } } } From c0e33acb9fce8be360fb8cea90cdfc6e47b8a0ed Mon Sep 17 00:00:00 2001 From: Jon Spock Date: Thu, 11 Jul 2019 22:39:19 -0700 Subject: [PATCH 3/3] Fix connect to thirdPartylTxUrlAction --- src/qt/transactionview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index ea8259b90..56c08408e 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -255,7 +255,7 @@ void TransactionView::setModel(WalletModel *_model) { } contextMenu->addAction(thirdPartyTxUrlAction); auto l = listUrls[i]; - connect(thirdPartyTxUrlAction, &QAction::triggered, [l]() {(void)l.trimmed();}); + connect(thirdPartyTxUrlAction, &QAction::triggered, [this,l]() {openThirdPartyTxUrl(l.trimmed());}); } } }