File indexing completed on 2024-04-28 05:50:39
0001 /* 0002 This source file is part of Konsole, a terminal emulator. 0003 0004 SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef COLORSCHEMEWALLPAPER_H 0010 #define COLORSCHEMEWALLPAPER_H 0011 // STD 0012 #include <memory> 0013 0014 // Qt 0015 #include <QMetaType> 0016 #include <QMovie> 0017 #include <QPointF> 0018 #include <QSharedData> 0019 0020 // Konsole 0021 #include "../characters/CharacterColor.h" 0022 0023 class QPixmap; 0024 class QPainter; 0025 0026 namespace Konsole 0027 { 0028 /** 0029 * This class holds the wallpaper pixmap associated with a color scheme. 0030 * The wallpaper object is shared between multiple TerminalDisplay. 0031 */ 0032 class ColorSchemeWallpaper : public QSharedData 0033 { 0034 public: 0035 enum FillStyle { 0036 Tile = 0, 0037 Stretch, 0038 Crop, 0039 Adapt, 0040 NoScaling, 0041 }; 0042 Q_ENUM(FillStyle) 0043 0044 enum FlipType { 0045 NoFlip = 0, 0046 Horizontal, 0047 Vertical, 0048 Both, 0049 }; 0050 Q_ENUM(FlipType) 0051 0052 typedef QExplicitlySharedDataPointer<ColorSchemeWallpaper> Ptr; 0053 0054 explicit ColorSchemeWallpaper(const QString &path, 0055 const ColorSchemeWallpaper::FillStyle style, 0056 const QPointF &anchor, 0057 const qreal &opacity, 0058 const ColorSchemeWallpaper::FlipType flipType); 0059 ~ColorSchemeWallpaper(); 0060 0061 void load(); 0062 0063 /** Returns true if wallpaper available and drawn */ 0064 bool draw(QPainter &painter, const QRect rect, qreal bgColorOpacity, const QColor &backgroundColor); 0065 0066 bool isNull() const; 0067 0068 QString path() const; 0069 0070 FillStyle style() const; 0071 0072 QPointF anchor() const; 0073 0074 qreal opacity() const; 0075 0076 FlipType flipType() const; 0077 0078 bool isAnimated() const; 0079 0080 int getFrameDelay() const; 0081 0082 private: 0083 Q_GADGET 0084 Q_DISABLE_COPY(ColorSchemeWallpaper) 0085 0086 QString _path; 0087 std::unique_ptr<QPixmap> _picture; 0088 std::unique_ptr<QMovie> _movie; 0089 FillStyle _style; 0090 QPointF _anchor; 0091 qreal _opacity; 0092 FlipType _flipType; 0093 bool _isAnimated; 0094 int _frameDelay; 0095 0096 QRectF ScaledRect(const QSize viewportSize, const QSize pictureSize, const QRect rect); 0097 Qt::AspectRatioMode RatioMode(); 0098 QImage FlipImage(const QImage image, const ColorSchemeWallpaper::FlipType flipType); 0099 }; 0100 0101 } 0102 0103 #endif