mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
Fix image width in project description
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
#include <QString>
|
||||
#include <QTextObjectInterface>
|
||||
#include <QUrl>
|
||||
#include <memory>
|
||||
|
||||
/** Custom image text object to be used instead of the normal one in ProjectDescriptionPage.
|
||||
*
|
||||
@ -32,6 +33,14 @@ class VariableSizedImageObject final : public QObject, public QTextObjectInterfa
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QTextObjectInterface)
|
||||
|
||||
struct ImageMetadata {
|
||||
int posInDocument;
|
||||
QUrl url;
|
||||
QImage image;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
public:
|
||||
QSizeF intrinsicSize(QTextDocument* doc, int posInDocument, const QTextFormat& format) override;
|
||||
void drawObject(QPainter* painter, const QRectF& rect, QTextDocument* doc, int posInDocument, const QTextFormat& format) override;
|
||||
@ -49,13 +58,13 @@ class VariableSizedImageObject final : public QObject, public QTextObjectInterfa
|
||||
private:
|
||||
/** Adds the image to the document, in the given position.
|
||||
*/
|
||||
void parseImage(QTextDocument* doc, QImage image, int posInDocument);
|
||||
void parseImage(QTextDocument* doc, std::shared_ptr<ImageMetadata> meta);
|
||||
|
||||
/** Loads an image from an external source, and adds it to the document.
|
||||
*
|
||||
* This uses m_meta_entry to cache the image.
|
||||
*/
|
||||
void loadImage(QTextDocument* doc, const QUrl& source, int posInDocument);
|
||||
void loadImage(QTextDocument* doc, std::shared_ptr<ImageMetadata> meta);
|
||||
|
||||
private:
|
||||
QString m_meta_entry;
|
||||
|
Reference in New Issue
Block a user