File indexing completed on 2024-04-28 03:50:22
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #ifndef PROGRESS_FLOAT_ITEM_H 0007 #define PROGRESS_FLOAT_ITEM_H 0008 0009 #include "AbstractFloatItem.h" 0010 0011 #include <QMutex> 0012 #include <QTimer> 0013 #include <QIcon> 0014 0015 namespace Marble 0016 { 0017 0018 /** 0019 * @brief A float item that shows a pie-chart progress 0020 * indicator when downloads are active 0021 */ 0022 class ProgressFloatItem : public AbstractFloatItem 0023 { 0024 Q_OBJECT 0025 Q_PLUGIN_METADATA(IID "org.kde.marble.ProgressFloatItem") 0026 0027 Q_INTERFACES( Marble::RenderPluginInterface ) 0028 0029 MARBLE_PLUGIN( ProgressFloatItem ) 0030 0031 public: 0032 explicit ProgressFloatItem( const MarbleModel *marbleModel = nullptr ); 0033 ~ProgressFloatItem () override; 0034 0035 QStringList backendTypes() const override; 0036 0037 QString name() const override; 0038 0039 QString guiString() const override; 0040 0041 QString nameId() const override; 0042 0043 QString version() const override; 0044 0045 QString description() const override; 0046 0047 QString copyrightYears() const override; 0048 0049 QVector<PluginAuthor> pluginAuthors() const override; 0050 0051 QIcon icon () const override; 0052 0053 void initialize () override; 0054 0055 bool isInitialized () const override; 0056 0057 QPainterPath backgroundShape() const override; 0058 0059 void paintContent( QPainter *painter ) override; 0060 0061 private Q_SLOTS: 0062 void removeProgressItem(); 0063 0064 void handleProgress( int active, int queued ); 0065 0066 void hideProgress(); 0067 0068 void show(); 0069 0070 void scheduleRepaint(); 0071 0072 private: 0073 Q_DISABLE_COPY( ProgressFloatItem ) 0074 0075 bool active() const; 0076 0077 void setActive( bool active ); 0078 0079 bool m_isInitialized; 0080 0081 int m_totalJobs; 0082 0083 int m_completedJobs; 0084 0085 qreal m_completed; 0086 0087 QTimer m_progressHideTimer; 0088 0089 QTimer m_progressShowTimer; 0090 0091 QMutex m_jobMutex; 0092 0093 bool m_active; 0094 0095 QIcon m_icon; 0096 0097 int m_fontSize; 0098 0099 QTimer m_repaintTimer; 0100 }; 0101 0102 } 0103 0104 #endif 0105