1 // SPDX-License-Identifier: LGPL-2.1-or-later 2 // 3 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org> 4 // 5 6 #ifndef PROGRESS_FLOAT_ITEM_H 7 #define PROGRESS_FLOAT_ITEM_H 8 9 #include "AbstractFloatItem.h" 10 11 #include <QMutex> 12 #include <QTimer> 13 #include <QIcon> 14 15 namespace Marble 16 { 17 18 /** 19 * @brief A float item that shows a pie-chart progress 20 * indicator when downloads are active 21 */ 22 class ProgressFloatItem : public AbstractFloatItem 23 { 24 Q_OBJECT 25 Q_PLUGIN_METADATA(IID "org.kde.marble.ProgressFloatItem") 26 27 Q_INTERFACES( Marble::RenderPluginInterface ) 28 29 MARBLE_PLUGIN( ProgressFloatItem ) 30 31 public: 32 explicit ProgressFloatItem( const MarbleModel *marbleModel = nullptr ); 33 ~ProgressFloatItem () override; 34 35 QStringList backendTypes() const override; 36 37 QString name() const override; 38 39 QString guiString() const override; 40 41 QString nameId() const override; 42 43 QString version() const override; 44 45 QString description() const override; 46 47 QString copyrightYears() const override; 48 49 QVector<PluginAuthor> pluginAuthors() const override; 50 51 QIcon icon () const override; 52 53 void initialize () override; 54 55 bool isInitialized () const override; 56 57 QPainterPath backgroundShape() const override; 58 59 void paintContent( QPainter *painter ) override; 60 61 private Q_SLOTS: 62 void removeProgressItem(); 63 64 void handleProgress( int active, int queued ); 65 66 void hideProgress(); 67 68 void show(); 69 70 void scheduleRepaint(); 71 72 private: 73 Q_DISABLE_COPY( ProgressFloatItem ) 74 75 bool active() const; 76 77 void setActive( bool active ); 78 79 bool m_isInitialized; 80 81 int m_totalJobs; 82 83 int m_completedJobs; 84 85 qreal m_completed; 86 87 QTimer m_progressHideTimer; 88 89 QTimer m_progressShowTimer; 90 91 QMutex m_jobMutex; 92 93 bool m_active; 94 95 QIcon m_icon; 96 97 int m_fontSize; 98 99 QTimer m_repaintTimer; 100 }; 101 102 } 103 104 #endif 105 106