File indexing completed on 2024-05-05 03:50:46

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 NAVIGATION_FLOAT_ITEM_H
0008 #define NAVIGATION_FLOAT_ITEM_H
0009 
0010 #include <QMenu>
0011 
0012 #include "MarbleGlobal.h"
0013 
0014 #include "AbstractFloatItem.h"
0015 
0016 namespace Ui
0017 {
0018     class Navigation;
0019 }
0020 
0021 namespace Marble
0022 {
0023 
0024 class MarbleWidget;
0025 class WidgetGraphicsItem;
0026 
0027 /**
0028  * @short Provides a float item with zoom and move controls
0029  *
0030  */
0031 class NavigationFloatItem: public AbstractFloatItem
0032 {
0033     Q_OBJECT
0034     Q_PLUGIN_METADATA(IID "org.kde.marble.NavigationFloatItem")
0035 
0036     Q_INTERFACES( Marble::RenderPluginInterface )
0037 
0038 MARBLE_PLUGIN( NavigationFloatItem )
0039 
0040  public:
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     bool eventFilter( QObject *object, QEvent *e ) override;
0076     void paintContent( QPainter *painter ) override;
0077     void contextMenuEvent( QWidget *w, QContextMenuEvent *e ) override;
0078 
0079  private Q_SLOTS:
0080     /** Map theme was changed, adjust controls */
0081     void selectTheme( const QString& theme );
0082 
0083     /** Enable/disable zoom in/out buttons */
0084     void updateButtons( int zoomValue );
0085 
0086     void activateCurrentPositionButton();
0087     void activateHomeButton();
0088     void centerOnCurrentLocation();
0089 
0090  private:
0091     /** MarbleWidget this float item is installed as event filter for */
0092     MarbleWidget *m_marbleWidget;
0093 
0094     /** The GraphicsItem presenting the widgets. NavigationFloatItem doesn't take direct ownership
0095         of this */
0096     WidgetGraphicsItem *m_widgetItem;
0097 
0098     /** Navigation controls */
0099     Ui::Navigation *m_navigationWidget;
0100 
0101     /** Used Profile */
0102     MarbleGlobal::Profiles m_profiles;
0103 
0104     /** Radius of the viewport last time */
0105     int m_oldViewportRadius;
0106 
0107     int m_maxZoom;
0108     int m_minZoom;
0109 
0110     QMenu *m_contextMenu;
0111     QAction *m_activateCurrentPositionButtonAction;
0112     QAction *m_activateHomeButtonAction;
0113 
0114     bool m_showHomeButton;
0115 };
0116 
0117 }
0118 
0119 #endif // NAVIGATION_FLOAT_ITEM_H