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

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2008 Dennis Nienhüser <nienhueser@kde.org>
0004 // SPDX-FileCopyrightText: 2013 Mohammed Nafees <nafees.technocool@gmail.com>
0005 //
0006 
0007 #ifndef MARBLE_NAVIGATION_FLOAT_ITEM_H
0008 #define MARBLE_NAVIGATION_FLOAT_ITEM_H
0009 
0010 #include <QMenu>
0011 
0012 #include "MarbleGlobal.h"
0013 #include "AbstractFloatItem.h"
0014 
0015 namespace Ui
0016 {
0017     class Navigation;
0018 }
0019 
0020 namespace Marble
0021 {
0022 
0023 class MarbleWidget;
0024 class WidgetGraphicsItem;
0025 
0026 /**
0027  * @short Provides a float item with zoom and move controls
0028  *
0029  */
0030 class NavigationFloatItem : public AbstractFloatItem
0031 {
0032     Q_OBJECT
0033     Q_PLUGIN_METADATA(IID "org.kde.marble.NavigationFloatItem")
0034 
0035     Q_INTERFACES( Marble::RenderPluginInterface )
0036 
0037     MARBLE_PLUGIN( NavigationFloatItem )
0038 
0039 public:
0040 
0041     explicit NavigationFloatItem( const MarbleModel *marbleModel = nullptr );
0042     ~NavigationFloatItem() override;
0043 
0044     QStringList backendTypes() const override;
0045 
0046     QString name() const override;
0047 
0048     QString guiString() const override;
0049 
0050     QString nameId() const override;
0051 
0052     QString version() const override;
0053 
0054     QString description() const override;
0055 
0056     QString copyrightYears() const override;
0057 
0058     QVector<PluginAuthor> pluginAuthors() const override;
0059 
0060     QIcon icon () const override;
0061 
0062     void initialize () override;
0063 
0064     bool isInitialized () const override;
0065 
0066     void setProjection( const ViewportParams *viewport ) override;
0067 
0068     static QPixmap pixmap( const QString &Id );
0069 
0070     QHash<QString,QVariant> settings() const override;
0071 
0072     void setSettings( const QHash<QString, QVariant> &settings ) override;
0073 
0074 protected:
0075 
0076     bool eventFilter( QObject *object, QEvent *e ) override;
0077     void paintContent( QPainter *painter ) override;
0078     void contextMenuEvent( QWidget *w, QContextMenuEvent *e ) override;
0079 
0080 private Q_SLOTS:
0081 
0082     /** Map theme was changed, adjust controls */
0083     void selectTheme( const QString& theme );
0084 
0085     /** Enable/disable zoom in/out buttons */
0086     void updateButtons( int zoomValue );
0087 
0088     void activateCurrentPositionButton();
0089     void activateHomeButton();
0090     void centerOnCurrentLocation();
0091 
0092 private:
0093 
0094     /** MarbleWidget this float item is installed as event filter for */
0095     MarbleWidget *m_marbleWidget;
0096 
0097     /** The GraphicsItem presenting the widgets. NavigationFloatItem doesn't take direct ownership
0098         of this */
0099     WidgetGraphicsItem *m_widgetItem;
0100 
0101     /** Navigation controls */
0102     Ui::Navigation *m_navigationWidget;
0103 
0104     /** Used Profile */
0105     MarbleGlobal::Profiles m_profiles;
0106 
0107     /** Radius of the viewport last time */
0108     int m_oldViewportRadius;
0109 
0110     int m_maxZoom;
0111     int m_minZoom;
0112 
0113     QMenu *m_contextMenu;
0114     QAction *m_activateCurrentPositionButtonAction;
0115     QAction *m_activateHomeButtonAction;
0116 
0117     bool m_showHomeButton;
0118 };
0119 
0120 } // namespace Marble
0121 
0122 #endif // MARBLE_NAVIGATION_FLOAT_ITEM_H