File indexing completed on 2025-01-05 03:59:26

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org>
0004 //
0005 
0006 #ifndef MARBLE_PROGRESS_FLOAT_ITEM_H
0007 #define MARBLE_PROGRESS_FLOAT_ITEM_H
0008 
0009 #include <QMutex>
0010 #include <QTimer>
0011 #include <QIcon>
0012 
0013 #include "AbstractFloatItem.h"
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 
0033     explicit ProgressFloatItem( const MarbleModel *marbleModel = nullptr );
0034     ~ProgressFloatItem () override;
0035 
0036     QStringList backendTypes() const override;
0037 
0038     QString name() const override;
0039 
0040     QString guiString() const override;
0041 
0042     QString nameId() const override;
0043 
0044     QString version() const override;
0045 
0046     QString description() const override;
0047 
0048     QString copyrightYears() const override;
0049 
0050     QVector<PluginAuthor> pluginAuthors() const override;
0051 
0052     QIcon icon () const override;
0053 
0054     void initialize () override;
0055 
0056     bool isInitialized () const override;
0057 
0058     QPainterPath backgroundShape() const override;
0059 
0060     void paintContent( QPainter *painter ) override;
0061 
0062 private Q_SLOTS:
0063 
0064     void removeProgressItem();
0065 
0066     void handleProgress( int active, int queued );
0067 
0068     void hideProgress();
0069 
0070     void show();
0071 
0072     void scheduleRepaint();
0073 
0074 private:
0075 
0076     Q_DISABLE_COPY( ProgressFloatItem )
0077 
0078     bool active() const;
0079 
0080     void setActive( bool active );
0081 
0082     bool m_isInitialized;
0083 
0084     int m_totalJobs;
0085 
0086     int m_completedJobs;
0087 
0088     qreal m_completed;
0089 
0090     QTimer m_progressHideTimer;
0091 
0092     QTimer m_progressShowTimer;
0093 
0094     QMutex m_jobMutex;
0095 
0096     bool m_active;
0097 
0098     int m_fontSize;
0099 
0100     QTimer m_repaintTimer;
0101 };
0102 
0103 } // namespace Marble
0104 
0105 #endif // MARBLE_PROGRESS_FLOAT_ITEM_H