Skip to content

Commit

Permalink
Update for qt v5.12
Browse files Browse the repository at this point in the history
Deprecated in qt5:
QHeaderView::setClickable
QHeaderView::setResizeMode
QDesktopServices::storageLocation
Qt::escape
qVariantCanConvert
  • Loading branch information
cryptostiltskin committed Jun 12, 2019
1 parent 31258b9 commit 1dd3ce8
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 8 deletions.
9 changes: 2 additions & 7 deletions Espers-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@ TEMPLATE = app
TARGET = Espers-qt
VERSION = 0.8.7.5
INCLUDEPATH += src src/json src/qt
QT += core gui widgets network
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
DEFINES += ENABLE_WALLET
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
CONFIG += no_include_pwd
CONFIG += thread
CONFIG += widgets
CONFIG += static
CONFIG += openssl

QMAKE_CXXFLAGS += -fpermissive

greaterThan(QT_MAJOR_VERSION, 4) {
QT += widgets
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
}

# WIN32 OS
# for boost 1.66 on windows, add (MinGW_Version)-mt-s-x32-(Boost_Version)
# as a reference refer to the below section
Expand Down
6 changes: 5 additions & 1 deletion src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ void AddressBookPage::setModel(AddressTableModel *model)
// Set column widths
ui->tableView->horizontalHeader()->resizeSection(
AddressTableModel::Address, 320);
#if QT_VERSION < 0x050000
ui->tableView->horizontalHeader()->setResizeMode(
AddressTableModel::Label, QHeaderView::Stretch);

#else
ui->tableView->horizontalHeader()->setSectionResizeMode(
AddressTableModel::Label, QHeaderView::Stretch);
#endif
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(selectionChanged()));

Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#endif

#include <QMessageBox>
#if QT_VERSION < 0x050000
#include <QTextCodec>
#endif
#include <QLocale>
#include <QTimer>
#include <QTranslator>
Expand Down
11 changes: 11 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@
#include <QMovie>
#include <QFileDialog>
#include <QDesktopServices>
#include <QStandardPaths>
#include <QTimer>
#include <QDragEnterEvent>
#if QT_VERSION < 0x050000
#include <QUrl>
#endif
#include <QMimeData>
#include <QStyle>
#include <QToolButton>
Expand Down Expand Up @@ -343,7 +346,11 @@ void BitcoinGUI::createActions()
aboutAction = new QAction(QIcon(":icons/Espers"), tr("&About Espers"), this);
aboutAction->setToolTip(tr("Show information about Espers"));
aboutAction->setMenuRole(QAction::AboutRole);
#if QT_VERSION < 0x050000
aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
#else
aboutQtAction = new QAction(QIcon(":/qt-project.org/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
#endif
aboutQtAction->setToolTip(tr("Show information about Qt"));
aboutQtAction->setMenuRole(QAction::AboutQtRole);
optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
Expand Down Expand Up @@ -1044,7 +1051,11 @@ void BitcoinGUI::encryptWallet()

void BitcoinGUI::backupWallet()
{
#if QT_VERSION < 0x050000
QString saveDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
#else
QString saveDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
#endif
QString filename = QFileDialog::getSaveFileName(this, tr("Backup Wallet"), saveDir, tr("Wallet Data (*.dat)"));
if(!filename.isEmpty()) {
if(!walletModel->backupWallet(filename)) {
Expand Down
4 changes: 4 additions & 0 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) :
connect(ui->treeWidget, SIGNAL(itemChanged( QTreeWidgetItem*, int)), this, SLOT(viewItemChanged( QTreeWidgetItem*, int)));

// click on header
#if QT_VERSION < 0x050000
ui->treeWidget->header()->setClickable(true);
#else
ui->treeWidget->header()->setSectionsClickable(true);
#endif
connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, SLOT(headerSectionClicked(int)));

// ok button
Expand Down
2 changes: 2 additions & 0 deletions src/qt/macdockiconhandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ - (void)handleDockClickEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAp
this->setMainWindow(NULL);
#if QT_VERSION < 0x050000
qt_mac_set_dock_menu(this->m_dockMenu);
#elif QT_VERSION >= 0x050200
this->m_dockMenu->setAsDockMenu();
#endif
[pool release];
}
Expand Down
4 changes: 4 additions & 0 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ class TxViewDelegate : public QAbstractItemDelegate
bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool();
QVariant value = index.data(Qt::ForegroundRole);
QColor foreground = option.palette.color(QPalette::Text);
#if QT_VERSION < 0x050000
if(qVariantCanConvert<QColor>(value))
#else
if(value.canConvert(QMetaType::QColor))
#endif
{
foreground = qvariant_cast<QColor>(value);
}
Expand Down
4 changes: 4 additions & 0 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ void SendCoinsDialog::on_sendButton_clicked()
QStringList formatted;
foreach(const SendCoinsRecipient &rcp, recipients)
{
#if QT_VERSION < 0x050000
formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount), Qt::escape(rcp.label), rcp.address));
#else
formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount), rcp.label.toHtmlEscaped(), rcp.address));
#endif
}

fNewRecipientAllowed = false;
Expand Down
4 changes: 4 additions & 0 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ void TransactionView::setModel(WalletModel *model)
transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Status, 23);
transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Date, 120);
transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Type, 120);
#if QT_VERSION < 0x050000
transactionView->horizontalHeader()->setResizeMode(TransactionTableModel::ToAddress, QHeaderView::Stretch);
#else
transactionView->horizontalHeader()->setSectionResizeMode(TransactionTableModel::ToAddress, QHeaderView::Stretch);
#endif
transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Amount, 100);
}
}
Expand Down

0 comments on commit 1dd3ce8

Please sign in to comment.