mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#16701: Replace functions deprecated in Qt 5.13
This commit is contained in:
parent
16b2591e77
commit
d4a1decb73
@ -117,7 +117,7 @@ public:
|
||||
ensurePolished();
|
||||
const QFontMetrics fm(fontMetrics());
|
||||
int h = 0;
|
||||
int w = fm.width(BitcoinUnits::format(BitcoinUnits::DASH, BitcoinUnits::maxMoney(), false, BitcoinUnits::separatorAlways));
|
||||
int w = GUIUtil::TextWidth(fm, BitcoinUnits::format(BitcoinUnits::DASH, BitcoinUnits::maxMoney(), false, BitcoinUnits::separatorAlways));
|
||||
w += 2; // cursor blinking space
|
||||
w += GUIUtil::dashThemeActive() ? 24 : 0; // counteract padding from css
|
||||
return QSize(w, h);
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include <QButtonGroup>
|
||||
#include <QComboBox>
|
||||
#include <QDateTime>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QListWidget>
|
||||
#include <QMenu>
|
||||
@ -54,6 +53,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QMimeData>
|
||||
#include <QProgressDialog>
|
||||
#include <QScreen>
|
||||
#include <QSettings>
|
||||
#include <QShortcut>
|
||||
#include <QStackedWidget>
|
||||
@ -89,7 +89,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
|
||||
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());
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
@ -1324,7 +1324,7 @@ void BitcoinGUI::updateWidth()
|
||||
continue;
|
||||
}
|
||||
QFontMetrics fm(button->font());
|
||||
nWidthWidestButton = std::max<int>(nWidthWidestButton, fm.width(button->text()));
|
||||
nWidthWidestButton = std::max<int>(nWidthWidestButton, GUIUtil::TextWidth(fm, button->text()));
|
||||
++nButtonsVisible;
|
||||
}
|
||||
// Add 30 per button as padding and use minimum 980 which is the minimum required to show all tab's contents
|
||||
@ -1990,7 +1990,7 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() :
|
||||
const QFontMetrics fm(GUIUtil::getFontNormal());
|
||||
for (const BitcoinUnits::Unit unit : units)
|
||||
{
|
||||
max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit)));
|
||||
max_width = qMax(max_width, GUIUtil::TextWidth(fm, BitcoinUnits::name(unit)));
|
||||
}
|
||||
setMinimumSize(max_width, 0);
|
||||
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDoubleValidator>
|
||||
#include <QFileDialog>
|
||||
@ -1832,7 +1831,7 @@ qreal calculateIdealFontSize(int width, const QString& text, QFont font, qreal m
|
||||
while(font_size >= minPointSize) {
|
||||
font.setPointSizeF(font_size);
|
||||
QFontMetrics fm(font);
|
||||
if (fm.width(text) < width) {
|
||||
if (TextWidth(fm, text) < width) {
|
||||
break;
|
||||
}
|
||||
font_size -= 0.5;
|
||||
@ -1872,4 +1871,13 @@ void PolishProgressDialog(QProgressDialog* dialog)
|
||||
#endif
|
||||
}
|
||||
|
||||
int TextWidth(const QFontMetrics& fm, const QString& text)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
||||
return fm.horizontalAdvance(text);
|
||||
#else
|
||||
return fm.width(text);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace GUIUtil
|
||||
|
@ -467,6 +467,14 @@ namespace GUIUtil
|
||||
|
||||
// Fix known bugs in QProgressDialog class.
|
||||
void PolishProgressDialog(QProgressDialog* dialog);
|
||||
|
||||
/**
|
||||
* Returns the distance in pixels appropriate for drawing a subsequent character after text.
|
||||
*
|
||||
* In Qt 5.12 and before the QFontMetrics::width() is used and it is deprecated since Qt 13.0.
|
||||
* In Qt 5.11 the QFontMetrics::horizontalAdvance() was introduced.
|
||||
*/
|
||||
int TextWidth(const QFontMetrics& fm, const QString& text);
|
||||
} // namespace GUIUtil
|
||||
|
||||
#endif // BITCOIN_QT_GUIUTIL_H
|
||||
|
@ -497,7 +497,7 @@ void OptionsDialog::updateWidth()
|
||||
continue;
|
||||
}
|
||||
QFontMetrics fm(button->font());
|
||||
nWidthWidestButton = std::max<int>(nWidthWidestButton, fm.width(button->text()));
|
||||
nWidthWidestButton = std::max<int>(nWidthWidestButton, GUIUtil::TextWidth(fm, button->text()));
|
||||
++nButtonsVisible;
|
||||
}
|
||||
// Add 10 per button as padding and use minimum 585 which is what we used in css before
|
||||
|
@ -31,12 +31,12 @@
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QDir>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFontDatabase>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QScreen>
|
||||
#include <QSettings>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
@ -466,7 +466,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, QWidget* parent, Qt::WindowFlags
|
||||
QSettings settings;
|
||||
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());
|
||||
}
|
||||
|
||||
QChar nonbreaking_hyphen(8209);
|
||||
|
@ -9,22 +9,22 @@
|
||||
|
||||
#include <qt/splashscreen.h>
|
||||
|
||||
#include <qt/guiutil.h>
|
||||
#include <qt/networkstyle.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <clientversion.h>
|
||||
#include <interfaces/handler.h>
|
||||
#include <interfaces/node.h>
|
||||
#include <interfaces/wallet.h>
|
||||
#include <qt/guiutil.h>
|
||||
#include <qt/networkstyle.h>
|
||||
#include <ui_interface.h>
|
||||
#include <util/system.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCloseEvent>
|
||||
#include <QDesktopWidget>
|
||||
#include <QPainter>
|
||||
#include <QScreen>
|
||||
|
||||
|
||||
SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const NetworkStyle *networkStyle) :
|
||||
@ -89,7 +89,7 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
|
||||
fontBold.setPointSize(50 * fontFactor);
|
||||
pixPaint.setFont(fontBold);
|
||||
QFontMetrics fm = pixPaint.fontMetrics();
|
||||
int titleTextWidth = fm.width(titleText);
|
||||
int titleTextWidth = GUIUtil::TextWidth(fm, titleText);
|
||||
if (titleTextWidth > width * 0.8) {
|
||||
fontFactor = 0.75;
|
||||
}
|
||||
@ -97,14 +97,14 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
|
||||
fontBold.setPointSize(50 * fontFactor);
|
||||
pixPaint.setFont(fontBold);
|
||||
fm = pixPaint.fontMetrics();
|
||||
titleTextWidth = fm.width(titleText);
|
||||
titleTextWidth = GUIUtil::TextWidth(fm, titleText);
|
||||
int titleTextHeight = fm.height();
|
||||
pixPaint.drawText((width / 2) - (titleTextWidth / 2), titleTextHeight + paddingTop, titleText);
|
||||
|
||||
fontNormal.setPointSize(16 * fontFactor);
|
||||
pixPaint.setFont(fontNormal);
|
||||
fm = pixPaint.fontMetrics();
|
||||
int versionTextWidth = fm.width(versionText);
|
||||
int versionTextWidth = GUIUtil::TextWidth(fm, versionText);
|
||||
pixPaint.drawText((width / 2) - (versionTextWidth / 2), titleTextHeight + paddingTop + titleVersionVSpace, versionText);
|
||||
|
||||
// draw additional text if special network
|
||||
@ -112,7 +112,7 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
|
||||
fontBold.setPointSize(10 * fontFactor);
|
||||
pixPaint.setFont(fontBold);
|
||||
fm = pixPaint.fontMetrics();
|
||||
int titleAddTextWidth = fm.width(titleAddText);
|
||||
int titleAddTextWidth = GUIUtil::TextWidth(fm, titleAddText);
|
||||
// Draw the badge background with the network-specific color
|
||||
QRect badgeRect = QRect(width - titleAddTextWidth - 20, 5, width, fm.height() + 10);
|
||||
QColor badgeColor = networkStyle->getBadgeColor();
|
||||
@ -128,7 +128,7 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
|
||||
QRect r(QPoint(), QSize(width, height));
|
||||
resize(r.size());
|
||||
setFixedSize(r.size());
|
||||
move(QApplication::desktop()->screenGeometry().center() - r.center());
|
||||
move(QGuiApplication::primaryScreen()->geometry().center() - r.center());
|
||||
|
||||
subscribeToCoreSignals();
|
||||
installEventFilter(this);
|
||||
|
Loading…
Reference in New Issue
Block a user