diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp index add0de131..f22bf238e 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp @@ -35,6 +35,7 @@ #include "retroshare/rspeers.h" #include "gui/common/FilesDefs.h" #include "util/imageutil.h" +#include "util/RsQtVersion.h" #include @@ -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) { diff --git a/retroshare-gui/src/gui/common/AvatarDialog.cpp b/retroshare-gui/src/gui/common/AvatarDialog.cpp index a5e8d15d4..c89483499 100644 --- a/retroshare-gui/src/gui/common/AvatarDialog.cpp +++ b/retroshare-gui/src/gui/common/AvatarDialog.cpp @@ -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) diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index eb2d235b7..6a50480f5 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -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 \ diff --git a/retroshare-gui/src/util/RsQtVersion.cpp b/retroshare-gui/src/util/RsQtVersion.cpp new file mode 100644 index 000000000..0762e5510 --- /dev/null +++ b/retroshare-gui/src/util/RsQtVersion.cpp @@ -0,0 +1,36 @@ +/******************************************************************************* + * util/RsQtVersion.cpp * + * * + * Copyright (C) 2025 Retroshare Team * + * * + * 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 . * + * * + *******************************************************************************/ + +#include + +// Functions to compile with Qt 4, Qt 5 and Qt 6 + +#if QT_VERSION < QT_VERSION_CHECK (5, 15, 0) +#include +QPixmap QLabel_pixmap(QLabel* label) +{ + const QPixmap *pixmap = label->pixmap(); + if (pixmap) { + return *pixmap; + } + + return QPixmap(); +} +#endif diff --git a/retroshare-gui/src/util/RsQtVersion.h b/retroshare-gui/src/util/RsQtVersion.h index cce082627..3631a0bac 100644 --- a/retroshare-gui/src/util/RsQtVersion.h +++ b/retroshare-gui/src/util/RsQtVersion.h @@ -1,5 +1,5 @@ /******************************************************************************* - * util/qthreadutils.h * + * util/RsQtVersion.h * * * * Copyright (C) 2013 Retroshare Team * * * @@ -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