File indexing completed on 2024-05-12 03:48:19

0001 /*
0002     File                 : Image.h
0003     Project              : LabPlot
0004     Description          : Worksheet element to draw images
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2019-2022 Alexander Semke <alexander.semke@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef IMAGE_H
0011 #define IMAGE_H
0012 
0013 #include "backend/lib/macros.h"
0014 #include "backend/worksheet/WorksheetElement.h"
0015 
0016 #include <QPen>
0017 
0018 class Line;
0019 class ImagePrivate;
0020 class QBrush;
0021 class QFont;
0022 
0023 class Image : public WorksheetElement {
0024     Q_OBJECT
0025 
0026 public:
0027     explicit Image(const QString& name);
0028     ~Image() override;
0029 
0030     QIcon icon() const override;
0031     virtual void setParentGraphicsItem(QGraphicsItem*) override;
0032 
0033     void save(QXmlStreamWriter*) const override;
0034     bool load(XmlStreamReader*, bool preview) override;
0035     void loadThemeConfig(const KConfig&) override;
0036     void saveThemeConfig(const KConfig&) override;
0037 
0038     CLASS_D_ACCESSOR_DECL(QString, fileName, FileName)
0039     BASIC_D_ACCESSOR_DECL(bool, embedded, Embedded)
0040     BASIC_D_ACCESSOR_DECL(qreal, opacity, Opacity)
0041     BASIC_D_ACCESSOR_DECL(int, width, Width)
0042     BASIC_D_ACCESSOR_DECL(int, height, Height)
0043     BASIC_D_ACCESSOR_DECL(bool, keepRatio, KeepRatio)
0044 
0045     Line* borderLine() const;
0046 
0047     void retransform() override;
0048     void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override;
0049 
0050     typedef ImagePrivate Private;
0051 
0052 protected:
0053     Image(const QString&, ImagePrivate*);
0054 
0055 private:
0056     Q_DECLARE_PRIVATE(Image)
0057     void init();
0058 
0059 Q_SIGNALS:
0060     void fileNameChanged(const QString&);
0061     void embeddedChanged(bool);
0062     void opacityChanged(float);
0063     void widthChanged(int);
0064     void heightChanged(int);
0065     void keepRatioChanged(bool);
0066     void borderPenChanged(QPen&);
0067     void borderOpacityChanged(float);
0068 };
0069 
0070 #endif