mirror of
				https://gitlab.com/comunic/comunicmessages
				synced 2025-11-04 04:04:10 +00:00 
			
		
		
		
	Can load remote images and cache them locally.
This commit is contained in:
		
							
								
								
									
										41
									
								
								data/qlabelholder.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								data/qlabelholder.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
/**
 | 
			
		||||
 * QLabelHolder
 | 
			
		||||
 *
 | 
			
		||||
 * This file should be referenced by ImageLoadHelper ONLY !!!
 | 
			
		||||
 *
 | 
			
		||||
 * @author Pierre HUBERT
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include <QLabel>
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class is used to avoid memory leak if attempting to
 | 
			
		||||
 * apply downloaded image to a deleted label
 | 
			
		||||
 */
 | 
			
		||||
class QLabelHolder : public QObject
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    QLabelHolder(QLabel *label) {
 | 
			
		||||
        mLabel = label;
 | 
			
		||||
        connect(label, &QLabel::destroyed, this, &QLabelHolder::deleted);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QLabel *label(){
 | 
			
		||||
        return mLabel;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
 | 
			
		||||
    void deleted(){
 | 
			
		||||
        mLabel = nullptr;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
 | 
			
		||||
    //Private fields
 | 
			
		||||
    QLabel *mLabel;
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user