Added Qt dependent macro for QLabel::pixmap

This commit is contained in:
thunder2 2025-07-25 00:35:17 +02:00
parent fce618f2aa
commit 32350dfe83
5 changed files with 52 additions and 4 deletions

View file

@ -35,6 +35,7 @@
#include "retroshare/rspeers.h"
#include "gui/common/FilesDefs.h"
#include "util/imageutil.h"
#include "util/RsQtVersion.h"
#include <iostream>
@ -700,7 +701,7 @@ void IdEditDialog::removeAvatar()
void IdEditDialog::updateInterface()
{
QPixmap pixmap = ui->avatarLabel->pixmap(Qt::ReturnByValue);
QPixmap pixmap = QLabel_pixmap(ui->avatarLabel);
if (!pixmap.isNull()) {
ui->removeButton->setEnabled(true);
} else if (mEditGroup.mImage.mSize > 0) {

View file

@ -42,6 +42,7 @@
#include "gui/common/FilesDefs.h"
#include "util/HandleRichText.h"
#include "util/imageutil.h"
#include "util/RsQtVersion.h"
#include "retroshare/rsinit.h"
#define ICONNAME "groupicon.png"
@ -107,7 +108,7 @@ void AvatarDialog::removeAvatar()
void AvatarDialog::updateInterface()
{
QPixmap pixmap = ui->avatarLabel->pixmap(Qt::ReturnByValue);
QPixmap pixmap = QLabel_pixmap(ui->avatarLabel);
if (!pixmap.isNull()) {
ui->removeButton->setEnabled(true);
} else {
@ -123,7 +124,7 @@ void AvatarDialog::setAvatar(const QPixmap &avatar)
void AvatarDialog::getAvatar(QPixmap &avatar)
{
avatar = ui->avatarLabel->pixmap(Qt::ReturnByValue);
avatar = QLabel_pixmap(ui->avatarLabel);
}
void AvatarDialog::getAvatar(QByteArray &avatar)

View file

@ -816,6 +816,7 @@ SOURCES += main.cpp \
util/misc.cpp \
util/HandleRichText.cpp \
util/ObjectPainter.cpp \
util/RsQtVersion.cpp \
util/RsFile.cpp \
util/RichTextEdit.cpp \
util/ClickableLabel.cpp \

View file

@ -0,0 +1,36 @@
/*******************************************************************************
* util/RsQtVersion.cpp *
* *
* Copyright (C) 2025 Retroshare Team <retroshare.project@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#include <QtGlobal>
// Functions to compile with Qt 4, Qt 5 and Qt 6
#if QT_VERSION < QT_VERSION_CHECK (5, 15, 0)
#include <QLabel>
QPixmap QLabel_pixmap(QLabel* label)
{
const QPixmap *pixmap = label->pixmap();
if (pixmap) {
return *pixmap;
}
return QPixmap();
}
#endif

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* util/qthreadutils.h *
* util/RsQtVersion.h *
* *
* Copyright (C) 2013 Retroshare Team <retroshare.project@gmail.com> *
* *
@ -61,4 +61,13 @@
#define QFontMetrics_horizontalAdvance(fontMetrics, text) fontMetrics.width(text)
#endif
#if QT_VERSION >= QT_VERSION_CHECK (6, 6, 0)
#define QLabel_pixmap(label) label->pixmap()
#elif QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
#define QLabel_pixmap(label) label->pixmap(Qt::ReturnByValue)
#else
class QLabel;
extern QPixmap QLabel_pixmap(QLabel* label);
#endif
#endif