qt, refactor: Fix 'pixmap is deprecated' warnings
This commit is contained in:
4 files changed
+36
-9
No files matched your search
@@ -1305,7 +1305,7 @@ void BitcoinGUI::updateProxyIcon()
|
|||||||
bool proxy_enabled = clientModel->getProxyInfo(ip_port);
|
bool proxy_enabled = clientModel->getProxyInfo(ip_port);
|
||||||
|
|
||||||
if (proxy_enabled) {
|
if (proxy_enabled) {
|
||||||
if (labelProxyIcon->pixmap() == nullptr) {
|
if (!GUIUtil::HasPixmap(labelProxyIcon)) {
|
||||||
QString ip_port_q = QString::fromStdString(ip_port);
|
QString ip_port_q = QString::fromStdString(ip_port);
|
||||||
labelProxyIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/proxy").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
|
labelProxyIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/proxy").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
|
||||||
labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));
|
labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));
|
||||||
|
|||||||
@@ -929,4 +929,26 @@ QDateTime StartOfDay(const QDate& date)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasPixmap(const QLabel* label)
|
||||||
|
{
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
|
return !label->pixmap(Qt::ReturnByValue).isNull();
|
||||||
|
#else
|
||||||
|
return label->pixmap() != nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage GetImage(const QLabel* label)
|
||||||
|
{
|
||||||
|
if (!HasPixmap(label)) {
|
||||||
|
return QImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
|
return label->pixmap(Qt::ReturnByValue).toImage();
|
||||||
|
#else
|
||||||
|
return label->pixmap()->toImage();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace GUIUtil
|
} // namespace GUIUtil
|
||||||
@@ -312,6 +312,14 @@ namespace GUIUtil
|
|||||||
*/
|
*/
|
||||||
QDateTime StartOfDay(const QDate& date);
|
QDateTime StartOfDay(const QDate& date);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if pixmap has been set.
|
||||||
|
*
|
||||||
|
* QPixmap* QLabel::pixmap() is deprecated since Qt 5.15.
|
||||||
|
*/
|
||||||
|
bool HasPixmap(const QLabel* label);
|
||||||
|
QImage GetImage(const QLabel* label);
|
||||||
|
|
||||||
} // namespace GUIUtil
|
} // namespace GUIUtil
|
||||||
|
|
||||||
#endif // BITCOIN_QT_GUIUTIL_H
|
#endif // BITCOIN_QT_GUIUTIL_H
|
||||||
@@ -95,15 +95,12 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)
|
|||||||
|
|
||||||
QImage QRImageWidget::exportImage()
|
QImage QRImageWidget::exportImage()
|
||||||
{
|
{
|
||||||
if(!pixmap())
|
return GUIUtil::GetImage(this);
|
||||||
return QImage();
|
|
||||||
return pixmap()->toImage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QRImageWidget::mousePressEvent(QMouseEvent *event)
|
void QRImageWidget::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(event->button() == Qt::LeftButton && pixmap())
|
if (event->button() == Qt::LeftButton && GUIUtil::HasPixmap(this)) {
|
||||||
{
|
|
||||||
event->accept();
|
event->accept();
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
mimeData->setImageData(exportImage());
|
mimeData->setImageData(exportImage());
|
||||||
@@ -118,7 +115,7 @@ void QRImageWidget::mousePressEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
void QRImageWidget::saveImage()
|
void QRImageWidget::saveImage()
|
||||||
{
|
{
|
||||||
if(!pixmap())
|
if (!GUIUtil::HasPixmap(this))
|
||||||
return;
|
return;
|
||||||
QString fn = GUIUtil::getSaveFileName(this, tr("Save QR Code"), QString(), tr("PNG Image (*.png)"), nullptr);
|
QString fn = GUIUtil::getSaveFileName(this, tr("Save QR Code"), QString(), tr("PNG Image (*.png)"), nullptr);
|
||||||
if (!fn.isEmpty())
|
if (!fn.isEmpty())
|
||||||
@@ -129,14 +126,14 @@ void QRImageWidget::saveImage()
|
|||||||
|
|
||||||
void QRImageWidget::copyImage()
|
void QRImageWidget::copyImage()
|
||||||
{
|
{
|
||||||
if(!pixmap())
|
if (!GUIUtil::HasPixmap(this))
|
||||||
return;
|
return;
|
||||||
QApplication::clipboard()->setImage(exportImage());
|
QApplication::clipboard()->setImage(exportImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QRImageWidget::contextMenuEvent(QContextMenuEvent *event)
|
void QRImageWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
if(!pixmap())
|
if (!GUIUtil::HasPixmap(this))
|
||||||
return;
|
return;
|
||||||
contextMenu->exec(event->globalPos());
|
contextMenu->exec(event->globalPos());
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user