Skip to content

Commit d2e4f52

Browse files
committed
Merge 0a267f4 into merged_master (Bitcoin PR bitcoin-core/gui#46)
2 parents 9e0060a + 0a267f4 commit d2e4f52

15 files changed

+101
-25
lines changed

src/qt/bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
255255
void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
256256
{
257257
assert(!m_splash);
258-
m_splash = new SplashScreen(nullptr, networkStyle);
258+
m_splash = new SplashScreen(networkStyle);
259259
// We don't hold a direct pointer to the splash screen after creation, but the splash
260260
// screen will take care of deleting itself when finish() happens.
261261
m_splash->show();

src/qt/bitcoingui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ void BitcoinGUI::updateProxyIcon()
12841284
bool proxy_enabled = clientModel->getProxyInfo(ip_port);
12851285

12861286
if (proxy_enabled) {
1287-
if (labelProxyIcon->pixmap() == nullptr) {
1287+
if (!GUIUtil::HasPixmap(labelProxyIcon)) {
12881288
QString ip_port_q = QString::fromStdString(ip_port);
12891289
labelProxyIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/proxy").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
12901290
labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));

src/qt/bitcoingui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct BlockAndHeaderTipInfo;
4949
QT_BEGIN_NAMESPACE
5050
class QAction;
5151
class QComboBox;
52+
class QDateTime;
5253
class QMenu;
5354
class QProgressBar;
5455
class QProgressDialog;

src/qt/guiutil.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,4 +988,35 @@ void PopupMenu(QMenu* menu, const QPoint& point, QAction* at_action)
988988
menu->popup(point, at_action);
989989
}
990990

991+
QDateTime StartOfDay(const QDate& date)
992+
{
993+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
994+
return date.startOfDay();
995+
#else
996+
return QDateTime(date);
997+
#endif
998+
}
999+
1000+
bool HasPixmap(const QLabel* label)
1001+
{
1002+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
1003+
return !label->pixmap(Qt::ReturnByValue).isNull();
1004+
#else
1005+
return label->pixmap() != nullptr;
1006+
#endif
1007+
}
1008+
1009+
QImage GetImage(const QLabel* label)
1010+
{
1011+
if (!HasPixmap(label)) {
1012+
return QImage();
1013+
}
1014+
1015+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
1016+
return label->pixmap(Qt::ReturnByValue).toImage();
1017+
#else
1018+
return label->pixmap()->toImage();
1019+
#endif
1020+
}
1021+
9911022
} // namespace GUIUtil

src/qt/guiutil.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ namespace GUIUtil
300300
/**
301301
* Returns the distance in pixels appropriate for drawing a subsequent character after text.
302302
*
303-
* In Qt 5.12 and before the QFontMetrics::width() is used and it is deprecated since Qt 13.0.
303+
* In Qt 5.12 and before the QFontMetrics::width() is used and it is deprecated since Qt 5.13.
304304
* In Qt 5.11 the QFontMetrics::horizontalAdvance() was introduced.
305305
*/
306306
int TextWidth(const QFontMetrics& fm, const QString& text);
@@ -314,6 +314,44 @@ namespace GUIUtil
314314
* Call QMenu::popup() only on supported QT_QPA_PLATFORM.
315315
*/
316316
void PopupMenu(QMenu* menu, const QPoint& point, QAction* at_action = nullptr);
317+
318+
/**
319+
* Returns the start-moment of the day in local time.
320+
*
321+
* QDateTime::QDateTime(const QDate& date) is deprecated since Qt 5.15.
322+
* QDate::startOfDay() was introduced in Qt 5.14.
323+
*/
324+
QDateTime StartOfDay(const QDate& date);
325+
326+
/**
327+
* Returns true if pixmap has been set.
328+
*
329+
* QPixmap* QLabel::pixmap() is deprecated since Qt 5.15.
330+
*/
331+
bool HasPixmap(const QLabel* label);
332+
QImage GetImage(const QLabel* label);
333+
334+
/**
335+
* Splits the string into substrings wherever separator occurs, and returns
336+
* the list of those strings. Empty strings do not appear in the result.
337+
*
338+
* QString::split() signature differs in different Qt versions:
339+
* - QString::SplitBehavior is deprecated since Qt 5.15
340+
* - Qt::SplitBehavior was introduced in Qt 5.14
341+
* If {QString|Qt}::SkipEmptyParts behavior is required, use this
342+
* function instead of QString::split().
343+
*/
344+
template <typename SeparatorType>
345+
QStringList SplitSkipEmptyParts(const QString& string, const SeparatorType& separator)
346+
{
347+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
348+
return string.split(separator, Qt::SkipEmptyParts);
349+
#else
350+
return string.split(separator, QString::SkipEmptyParts);
351+
#endif
352+
}
353+
354+
317355
} // namespace GUIUtil
318356

319357
#endif // BITCOIN_QT_GUIUTIL_H

src/qt/optionsmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static ProxySetting GetProxySetting(QSettings &settings, const QString &name)
219219
return default_val;
220220
}
221221
// contains IP at index 0 and port at index 1
222-
QStringList ip_port = settings.value(name).toString().split(":", QString::SkipEmptyParts);
222+
QStringList ip_port = GUIUtil::SplitSkipEmptyParts(settings.value(name).toString(), ":");
223223
if (ip_port.size() == 2) {
224224
return {true, ip_port.at(0), ip_port.at(1)};
225225
} else { // Invalid: return default

src/qt/overviewpage.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <QAbstractItemDelegate>
2121
#include <QApplication>
22+
#include <QDateTime>
2223
#include <QPainter>
2324
#include <QStatusTipEvent>
2425

src/qt/paymentserver.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <QApplication>
2727
#include <QByteArray>
2828
#include <QDataStream>
29-
#include <QDateTime>
3029
#include <QDebug>
3130
#include <QFile>
3231
#include <QFileOpenEvent>

src/qt/qrimagewidget.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,12 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)
101101

102102
QImage QRImageWidget::exportImage()
103103
{
104-
if(!pixmap())
105-
return QImage();
106-
return pixmap()->toImage();
104+
return GUIUtil::GetImage(this);
107105
}
108106

109107
void QRImageWidget::mousePressEvent(QMouseEvent *event)
110108
{
111-
if(event->button() == Qt::LeftButton && pixmap())
112-
{
109+
if (event->button() == Qt::LeftButton && GUIUtil::HasPixmap(this)) {
113110
event->accept();
114111
QMimeData *mimeData = new QMimeData;
115112
mimeData->setImageData(exportImage());
@@ -124,7 +121,7 @@ void QRImageWidget::mousePressEvent(QMouseEvent *event)
124121

125122
void QRImageWidget::saveImage()
126123
{
127-
if(!pixmap())
124+
if (!GUIUtil::HasPixmap(this))
128125
return;
129126
QString fn = GUIUtil::getSaveFileName(this, tr("Save QR Code"), QString(), tr("PNG Image (*.png)"), nullptr);
130127
if (!fn.isEmpty())
@@ -135,14 +132,14 @@ void QRImageWidget::saveImage()
135132

136133
void QRImageWidget::copyImage()
137134
{
138-
if(!pixmap())
135+
if (!GUIUtil::HasPixmap(this))
139136
return;
140137
QApplication::clipboard()->setImage(exportImage());
141138
}
142139

143140
void QRImageWidget::contextMenuEvent(QContextMenuEvent *event)
144141
{
145-
if(!pixmap())
142+
if (!GUIUtil::HasPixmap(this))
146143
return;
147144
contextMenu->exec(event->globalPos());
148145
}

src/qt/rpcconsole.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <wallet/wallet.h>
3030
#endif
3131

32+
#include <QDateTime>
3233
#include <QFont>
3334
#include <QKeyEvent>
3435
#include <QMenu>

0 commit comments

Comments
 (0)