Skip to content

Commit bc3b551

Browse files
albumart-qt: Resolve Qt deprecation warnings
1 parent 6f86dc0 commit bc3b551

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/albumart-qt/albumart.cc

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ class AlbumArtQt : public GeneralPlugin {
4545

4646
class ArtLabel : public QLabel {
4747
public:
48-
ArtLabel (QWidget * parent = 0, Qt::WindowFlags f = 0) : QLabel(parent, f)
48+
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
49+
ArtLabel (QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) : QLabel (parent, f)
50+
#else
51+
ArtLabel (QWidget * parent = nullptr, Qt::WindowFlags f = 0) : QLabel (parent, f)
52+
#endif
4953
{
5054
init ();
5155
}
5256

53-
ArtLabel (const QString & text, QWidget * parent = 0, Qt::WindowFlags f = 0) : QLabel (text, parent, f)
57+
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
58+
ArtLabel (const QString & text, QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) : QLabel (text, parent, f)
59+
#else
60+
ArtLabel (const QString & text, QWidget * parent = nullptr, Qt::WindowFlags f = 0) : QLabel (text, parent, f)
61+
#endif
5462
{
5563
init ();
5664
}
@@ -74,14 +82,24 @@ class ArtLabel : public QLabel {
7482
virtual void resizeEvent (QResizeEvent * event)
7583
{
7684
QLabel::resizeEvent (event);
77-
const QPixmap * pm = pixmap ();
7885

79-
if ( ! origPixmap.isNull () && pm && ! pm->isNull () &&
86+
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
87+
QPixmap pm = pixmap (Qt::ReturnByValue);
88+
if (! origPixmap.isNull () && ! pm.isNull () &&
89+
(size ().width () <= origSize.width () + MARGIN ||
90+
size ().height () <= origSize.height () + MARGIN ||
91+
pm.size ().width () != origSize.width () ||
92+
pm.size ().height () != origSize.height ()))
93+
drawArt ();
94+
#else
95+
const QPixmap * pm = pixmap ();
96+
if (! origPixmap.isNull () && pm && ! pm->isNull () &&
8097
(size ().width () <= origSize.width () + MARGIN ||
8198
size ().height () <= origSize.height () + MARGIN ||
8299
pm->size ().width () != origSize.width () ||
83100
pm->size ().height () != origSize.height ()))
84101
drawArt ();
102+
#endif
85103
}
86104

87105
private:
@@ -126,7 +144,7 @@ class ArtLabel : public QLabel {
126144
}
127145

128146
#ifdef Q_OS_MAC
129-
repaint();
147+
repaint();
130148
#endif
131149
}
132150
};

0 commit comments

Comments
 (0)