File indexing completed on 2024-04-21 03:48:37

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2005-2007 Torsten Rahn <tackat@kde.org>
0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
0005 //
0006 
0007 //
0008 // Testapplication with controls
0009 //
0010 
0011 
0012 #ifndef MARBLE_CONTROLVIEW_H
0013 #define MARBLE_CONTROLVIEW_H
0014 
0015 
0016 #include <QWidget>
0017 #include <QPointer>
0018 
0019 #include "MarbleWidget.h"
0020 
0021 class QPrintDialog;
0022 class QTextDocument;
0023 class QMainWindow;
0024 class QDockWidget;
0025 class QPrinter;
0026 class QActionGroup;
0027 class QPixmap;
0028 
0029 namespace Marble
0030 {
0031 
0032 class TourWidget;
0033 class CurrentLocationWidget;
0034 class MapThemeManager;
0035 class ConflictDialog;
0036 class MarbleModel;
0037 class MergeItem;
0038 class CloudSyncManager;
0039 
0040 class ControlView : public QWidget
0041 {
0042     Q_OBJECT
0043 
0044  public:
0045     explicit ControlView( QWidget * = nullptr );
0046     ~ControlView() override;
0047 
0048     /**
0049       * Returns the version of the Marble applications (which differs from
0050       * the Marble library version).
0051       */
0052     static QString applicationVersion();
0053 
0054     MarbleWidget      *marbleWidget()        { return m_marbleWidget; }
0055     MarbleModel       *marbleModel()         { return m_marbleWidget->model(); }
0056     MapThemeManager   *mapThemeManager();
0057 
0058     void zoomIn();
0059     void zoomOut();
0060     void moveLeft();
0061     void moveRight();
0062     void moveUp();
0063     void moveDown();
0064 
0065     void addGeoDataFile( const QString &filename );
0066 
0067     QPixmap mapScreenShot() { return m_marbleWidget->mapScreenShot(); }
0068     
0069     /**
0070       * Returns a default map theme: earth/srtm/srtm.dgml if installed,
0071       * any other theme id if earth/srtm/srtm.dgml is not installed,
0072       * or an empty string if no themes are installed at all
0073       */
0074     QString defaultMapThemeId() const;
0075 
0076     /**
0077       * Returns the editor used to launch a map editor application
0078       */
0079     QString externalMapEditor() const;
0080 
0081     /**
0082       * Change the editor to launch via @see launchExternalMapEditor. Recognized values
0083       * are 'potlatch', 'josm', 'merkaartor'
0084       */
0085     void setExternalMapEditor( const QString &editor );
0086 
0087     QList<QAction*> setupDockWidgets( QMainWindow* mainWindow );
0088 
0089     CurrentLocationWidget* currentLocationWidget();
0090 
0091     void setWorkOffline( bool workOffline );
0092 
0093     CloudSyncManager* cloudSyncManager();
0094 
0095     /**
0096      * Opens the passed Geo URI
0097      * @return true if uri could be parsed and opened
0098      * @see Marble::GeoUriParser for details
0099      */
0100     bool openGeoUri( const QString& geoUriString );
0101 
0102     static QActionGroup* createViewSizeActionGroup( QObject* parent );
0103 
0104  public Q_SLOTS:
0105     void printMapScreenShot( const QPointer<QPrintDialog>& dialog );
0106     void printPreview();
0107     void paintPrintPreview( QPrinter * printer );
0108 
0109     /**
0110       * Start the configured external map editor (or update it if it is already running)
0111       */
0112     void launchExternalMapEditor();
0113 
0114     /**
0115      *  Toggles all of the docking panels on or off
0116      */
0117     void togglePanelVisibility();
0118 
0119     void handleTourLinkClicked( const QString &path );
0120 
0121     void openTour( const QString &filename );
0122 
0123 Q_SIGNALS:
0124     void showMapWizard();
0125     void mapThemeDeleted();
0126 
0127 protected:
0128     void closeEvent( QCloseEvent *event ) override;
0129     /**
0130      * @brief Reimplementation of the dragEnterEvent() function in QWidget.
0131      */
0132     void dragEnterEvent(QDragEnterEvent *event) override;
0133 
0134     /**
0135      * @brief Reimplementation of the dropEvent() function in QWidget.
0136      */
0137     void dropEvent(QDropEvent *event) override;
0138 
0139 private Q_SLOTS:
0140     void showSearch();
0141     // Bookmark sync slots
0142     void showConflictDialog( MergeItem *item );
0143     void updateAnnotationDockVisibility();
0144     void updateAnnotationDock();
0145     
0146  private:
0147     /**
0148       * Try to reach an external application server at localhost:8111. If none is running,
0149       * start the given application
0150       * @param application Executable to start when no server is running
0151       * @param argument Argument to set the download region for the external application.
0152       * Use placeholders %1-%4 for the borders
0153       */
0154     void synchronizeWithExternalMapEditor( const QString &application, const QString &argument );
0155 
0156     static void printPixmap( QPrinter * printer, const QPixmap& pixmap );
0157     void printMap( QTextDocument &document, QString &text, QPrinter *printer );
0158     void printLegend( QTextDocument &document, QString &text );
0159     void printRouteSummary( QTextDocument &document, QString &text );
0160     void printDrivingInstructions( QTextDocument &document, QString &text );
0161     static void printDrivingInstructionsAdvice( QTextDocument &document, QString &text );
0162     static void addViewSizeAction( QActionGroup* actionGroup, const QString &nameTemplate, int width, int height );
0163 
0164     MapThemeManager   *const m_mapThemeManager;
0165     MarbleWidget      *m_marbleWidget;
0166     QString            m_externalEditor;
0167     QDockWidget       *m_searchDock;
0168     CurrentLocationWidget* m_locationWidget;
0169     ConflictDialog *m_conflictDialog;
0170     CloudSyncManager *m_cloudSyncManager;
0171     QAction         *m_togglePanelVisibilityAction;
0172     QList<QAction*>  m_panelActions;
0173     QList<bool>      m_panelVisibility;
0174     bool             m_isPanelVisible;
0175     TourWidget      *m_tourWidget;
0176     QDockWidget     *m_annotationDock;
0177     RenderPlugin    *m_annotationPlugin;
0178 };
0179 
0180 }
0181 
0182 #endif