File indexing completed on 2024-04-28 04:21:27

0001 // SPDX-FileCopyrightText: 2003-2022 Jesper K. Pedersen <blackie@kde.org>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 #ifndef SPEEDDISPLAY_H
0006 #define SPEEDDISPLAY_H
0007 
0008 #include <QLabel>
0009 #include <chrono>
0010 
0011 class QTimeLine;
0012 class QTimer;
0013 class QLabel;
0014 class QHBoxLayout;
0015 
0016 namespace Viewer
0017 {
0018 
0019 class TransientDisplay : public QLabel
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     explicit TransientDisplay(QWidget *parent);
0025     enum FadeAction { FadeOut,
0026                       NoFadeOut };
0027     void display(const QString &text, std::chrono::milliseconds duration = std::chrono::seconds(1), FadeAction action = FadeOut);
0028 
0029 private:
0030     void go(std::chrono::milliseconds duration);
0031     void setAlphaChannel(int alpha);
0032     void setAlphaChannel(int background, int label);
0033 
0034     QTimer *m_timer;
0035     QTimeLine *m_timeLine;
0036     FadeAction m_nextFadeAction;
0037 };
0038 }
0039 
0040 #endif /* SPEEDDISPLAY_H */
0041 
0042 // vi:expandtab:tabstop=4 shiftwidth=4: