File indexing completed on 2024-04-28 04:50:50
0001 /* 0002 * osdwidget.h 0003 * 0004 * Copyright (C) 2009-2011 Christoph Pfister <christophpfister@gmail.com> 0005 * 0006 * This program is free software; you can redistribute it and/or modify 0007 * it under the terms of the GNU General Public License as published by 0008 * the Free Software Foundation; either version 2 of the License, or 0009 * (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License along 0017 * with this program; if not, write to the Free Software Foundation, Inc., 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 0019 */ 0020 0021 #ifndef OSDWIDGET_H 0022 #define OSDWIDGET_H 0023 0024 #include <QWidget> 0025 0026 class OsdObject 0027 { 0028 public: 0029 OsdObject() { } 0030 virtual ~OsdObject() { } 0031 0032 virtual QPixmap paintOsd(QRect &rect, const QFont &font, 0033 Qt::LayoutDirection direction) = 0; 0034 }; 0035 0036 class OsdWidget : public QWidget 0037 { 0038 Q_OBJECT 0039 public: 0040 explicit OsdWidget(QWidget *parent); 0041 ~OsdWidget(); 0042 0043 void showText(const QString &text, int duration); // duration: msecs 0044 0045 void showObject(OsdObject *osdObject_, int duration); // duration: msecs 0046 void hideObject(); 0047 0048 protected: 0049 void paintEvent(QPaintEvent *) override; 0050 0051 private slots: 0052 void hideOsd(); 0053 0054 private: 0055 QRect rect; 0056 QPixmap pixmap; 0057 OsdObject *osdObject; 0058 QTimer *timer; 0059 }; 0060 0061 #endif /* OSDWIDGET_H */