Warning, file /education/parley/src/practice/imagewidget.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2009 Daniel Laidig <d.laidig@gmx.de> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef PRACTICE_IMAGEWIDGET_H 0007 #define PRACTICE_IMAGEWIDGET_H 0008 0009 #include <QWidget> 0010 0011 class QTimeLine; 0012 0013 namespace Practice 0014 { 0015 class ImageWidget : public QWidget 0016 { 0017 Q_OBJECT 0018 0019 public: 0020 explicit ImageWidget(QWidget *parent = nullptr); 0021 0022 void setPixmap(const QPixmap &pixmap); 0023 void setScalingEnabled(bool scaling, bool onlyDownscaling = true); 0024 void setKeepAspectRatio(Qt::AspectRatioMode mode); 0025 void setFadingEnabled(bool fading); 0026 void setAlignment(Qt::Alignment alignment); 0027 0028 protected: 0029 void paintEvent(QPaintEvent *e) override; 0030 void resizeEvent(QResizeEvent *e) override; 0031 0032 Q_SIGNALS: 0033 void sizeChanged(); 0034 0035 private Q_SLOTS: 0036 void scalePixmap(bool smooth = true); 0037 void animationFinished(); 0038 0039 private: 0040 bool m_fading{true}; 0041 bool m_scaling{true}; 0042 bool m_onlyDownscaling{true}; 0043 Qt::AspectRatioMode m_keepAspectRatio{Qt::KeepAspectRatio}; 0044 Qt::Alignment m_alignment{Qt::AlignCenter}; 0045 QPixmap m_originalPixmap; 0046 QPixmap m_scaledPixmap; 0047 QPixmap m_scaledBackupPixmap; 0048 QPixmap m_animationPixmap; 0049 bool m_scaledPixmapOutOfDate; 0050 /// Timer used to delay the smooth scaling 0051 QTimer *m_scaleTimer{nullptr}; 0052 QTimeLine *m_animation{nullptr}; 0053 }; 0054 0055 } 0056 0057 #endif // PRACTICE_IMAGEWIDGET_H