Plasma

svg.h
1 /*
2  SPDX-FileCopyrightText: 2006-2007 Aaron Seigo <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef PLASMA_SVG_H
8 #define PLASMA_SVG_H
9 
10 #include <QObject>
11 #include <QPixmap>
12 
13 #include <plasma/plasma_export.h>
14 #include <plasma/theme.h>
15 
16 class QPainter;
17 class QPoint;
18 class QPointF;
19 class QRect;
20 class QRectF;
21 class QSize;
22 class QSizeF;
23 class QMatrix;
24 
25 namespace Plasma
26 {
27 
28 class FrameSvgPrivate;
29 class SvgPrivate;
30 
43 class PLASMA_EXPORT Svg : public QObject
44 {
45  Q_OBJECT
46  Q_PROPERTY(QSize size READ size WRITE resize NOTIFY sizeChanged)
47  Q_PROPERTY(bool multipleImages READ containsMultipleImages WRITE setContainsMultipleImages)
48  Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged)
49  Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache)
50  Q_PROPERTY(bool fromCurrentTheme READ fromCurrentTheme NOTIFY fromCurrentThemeChanged)
51  Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged)
52  Q_PROPERTY(Plasma::Svg::Status status READ status WRITE setStatus NOTIFY statusChanged)
53 
54 public:
55  enum Status {
56  Normal = 0,
57  Selected
58  };
59  Q_ENUM(Status)
60 
61 
75  explicit Svg(QObject *parent = nullptr);
76  ~Svg() override;
77 
86  void setDevicePixelRatio(qreal ratio);
87 
91  qreal devicePixelRatio();
92 
98  qreal scaleFactor() const;
99 
106  void setScaleFactor(qreal factor);
107 
115  void setColorGroup(Plasma::Theme::ColorGroup group);
116 
120  Plasma::Theme::ColorGroup colorGroup() const;
121 
134  Q_INVOKABLE QPixmap pixmap(const QString &elementID = QString());
135 
148  Q_INVOKABLE QImage image(const QSize &size, const QString &elementID = QString());
149 
164  Q_INVOKABLE void paint(QPainter *painter, const QPointF &point,
165  const QString &elementID = QString());
166 
181  Q_INVOKABLE void paint(QPainter *painter, int x, int y,
182  const QString &elementID = QString());
183 
193  Q_INVOKABLE void paint(QPainter *painter, const QRectF &rect,
194  const QString &elementID = QString());
195 
207  Q_INVOKABLE void paint(QPainter *painter, int x, int y, int width,
208  int height, const QString &elementID = QString());
209 
221  QSize size() const;
222 
236  Q_INVOKABLE void resize(qreal width, qreal height);
237 
250  Q_INVOKABLE void resize(const QSizeF &size);
251 
257  Q_INVOKABLE void resize();
258 
269  Q_INVOKABLE QSize elementSize(const QString &elementId) const;
270 
281  Q_INVOKABLE QRectF elementRect(const QString &elementId) const;
282 
289  Q_INVOKABLE bool hasElement(const QString &elementId) const;
290 
299  Q_INVOKABLE bool isValid() const;
300 
314  void setContainsMultipleImages(bool multiple);
315 
327  bool containsMultipleImages() const;
328 
343  virtual void setImagePath(const QString &svgFilePath);
344 
354  QString imagePath() const;
355 
372  void setUsingRenderingCache(bool useCache);
373 
380  bool isUsingRenderingCache() const;
381 
389  bool fromCurrentTheme() const;
390 
397  void setUseSystemColors(bool system);
398 
404  bool useSystemColors() const;
405 
416  void setTheme(Plasma::Theme *theme);
417 
425  Theme *theme() const;
426 
436  void setStatus(Svg::Status status);
437 
442  Svg::Status status() const;
443 
444 Q_SIGNALS:
456  void repaintNeeded();
457 
461  void sizeChanged();
462 
466  void imagePathChanged();
467 
471  void colorHintChanged();
472 
476  void colorGroupChanged();
477 
481  void fromCurrentThemeChanged(bool fromCurrentTheme);
482 
487  void statusChanged(Plasma::Svg::Status status);
488 
489 private:
490  SvgPrivate *const d;
491  bool eventFilter(QObject *watched, QEvent *event) override;
492 
493  Q_PRIVATE_SLOT(d, void themeChanged())
494  Q_PRIVATE_SLOT(d, void colorsChanged())
495 
496  friend class SvgPrivate;
497  friend class FrameSvgPrivate;
498  friend class FrameSvg;
499 };
500 
501 } // Plasma namespace
502 
503 #endif // multiple inclusion guard
504 
Provides an SVG with borders.
Definition: framesvg.h:63
Namespace for everything in libplasma.
Definition: datamodel.cpp:14
Interface to the Plasma theme.
Definition: theme.h:42
A theme aware image-centric SVG class.
Definition: svg.h:43
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Nov 26 2020 22:40:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.