diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 509bed1e7..32d58130e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,78 +1,76 @@ # before add_subdirectory() ! if(MSVC) add_definitions(-D_USE_MATH_DEFINES=1) endif(MSVC) if(NOT MARBLE_NO_DBUS) add_definitions(-DMARBLE_DBUS) endif() if( Qt5Quick_FOUND ) OPTION(IGNORE_CMAKE_INSTALL_PREFIX_FOR_DECLARATIVE_PLUGINS "Install Marble Qt Declarative plugins to QT_IMPORTS_DIR even if that is out of the CMAKE_INSTALL_PREFIX") IF(QT_IMPORTS_DIR) SET(MARBLE_QT_IMPORTS_DIR ${QT_IMPORTS_DIR}) ELSE() # Fallback when FindQt.cmake (part of cmake) does not define QT_IMPORTS_DIR. Get it from qmake instead. EXEC_PROGRAM( qmake ARGS "-query QT_INSTALL_QML" OUTPUT_VARIABLE MARBLE_QT_IMPORTS_DIR ) ENDIF() STRING(LENGTH "${CMAKE_INSTALL_PREFIX}" _MARBLE_CMAKE_INSTALL_PREFIX_LEN) STRING(LENGTH "${MARBLE_QT_IMPORTS_DIR}" _MARBLE_QT_IMPORTS_DIR_LEN) IF(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) IF(NOT ${_MARBLE_QT_IMPORTS_DIR_LEN} LESS ${_MARBLE_CMAKE_INSTALL_PREFIX_LEN}) STRING(SUBSTRING ${MARBLE_QT_IMPORTS_DIR} 0 ${_MARBLE_CMAKE_INSTALL_PREFIX_LEN} _MARBLE_QT_IMPORTS_DIR_START) IF(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL ${_MARBLE_QT_IMPORTS_DIR_START}) IF(NOT ${IGNORE_CMAKE_INSTALL_PREFIX_FOR_DECLARATIVE_PLUGINS}) MESSAGE(STATUS "Please include ${MARBLE_PLUGIN_INSTALL_PATH} in the QML_IMPORT_PATH environment variable to use Marble's Qt declarative plugins.") MESSAGE(STATUS "Note: Marble Desktop does not make use of declarative plugins. Ignore the message above if you only intend to use the Desktop version.") SET(MARBLE_QT_IMPORTS_DIR ${MARBLE_PLUGIN_INSTALL_PATH}) ENDIF() ENDIF() ELSE() IF(NOT ${IGNORE_CMAKE_INSTALL_PREFIX_FOR_DECLARATIVE_PLUGINS}) MESSAGE(STATUS "Please include ${MARBLE_PLUGIN_INSTALL_PATH} in the QML_IMPORT_PATH environment variable to use Marble's Qt declarative plugins.") MESSAGE(STATUS "Note: Marble Desktop does not make use of declarative plugins. Ignore the message above if you only intend to use the Desktop version.") SET(MARBLE_QT_IMPORTS_DIR ${MARBLE_PLUGIN_INSTALL_PATH}) ENDIF() ENDIF() ENDIF() ENDIF() macro_optional_find_package(ZLIB QUIET) marble_set_package_properties(ZLIB PROPERTIES DESCRIPTION "general-purpose lossless data-compression library") marble_set_package_properties(ZLIB PROPERTIES URL "http://www.zlib.net/") marble_set_package_properties(ZLIB PROPERTIES TYPE OPTIONAL PURPOSE "When found, system zlib is used. When not found, a Marble internal zlib is used.") if(NOT ZLIB_FOUND) add_subdirectory( 3rdparty/zlib ) set(ZLIB_LIBRARIES zlibstatic) set(ZLIB_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/zlib" "${CMAKE_CURRENT_BINARY_DIR}/3rdparty/zlib") endif() add_subdirectory( 3rdparty/sgp4 ) add_subdirectory( lib/marble ) add_subdirectory( lib/astro ) add_subdirectory( lib/marble/declarative ) add_subdirectory( plugins ) option(BUILD_MARBLE_APPS "Build Marble Desktop/Mobile applications" ON) add_feature_info("Marble Desktop/Mobile applications" BUILD_MARBLE_APPS "Build Marble Desktop/Mobile applications. Toggle with BUILD_MARBLE_APPS=YES/NO.") if(BUILD_MARBLE_APPS) add_subdirectory( apps ) endif() add_subdirectory( bindings ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-marble.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-marble.h ) if(APPLE) add_subdirectory( mac ) endif(APPLE) -# FIXME ktimezonewidget.h is gone -#add_subdirectory( plasmoid ) - +add_subdirectory( plasma ) add_subdirectory( plasmarunner ) add_subdirectory( thumbnailer ) diff --git a/src/lib/marble/declarative/MarbleDeclarativePlugin.h b/src/lib/marble/declarative/MarbleDeclarativePlugin.h index 504276d69..676021cec 100644 --- a/src/lib/marble/declarative/MarbleDeclarativePlugin.h +++ b/src/lib/marble/declarative/MarbleDeclarativePlugin.h @@ -1,33 +1,34 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2010 Dennis Nienhüser // #ifndef MARBLE_DECLARATIVE_PLUGIN_H #define MARBLE_DECLARATIVE_PLUGIN_H #include "marble_declarative_export.h" #include /** * Registers MarbleQuickItem, MarbleRunnerManager and MarbleThemeManager * as QQml extensions for use in QML. */ class MARBLE_DECLARATIVE_EXPORT MarbleDeclarativePlugin : public QQmlExtensionPlugin { - Q_PLUGIN_METADATA(IID "org.kde.marble.MarbleDeclarativePlugin") + // Disabled for now while libmarbledeclarative is used as shared library + // Q_PLUGIN_METADATA(IID "org.kde.marble.MarbleDeclarativePlugin") Q_OBJECT public: /** Overriding QQmlExtensionPlugin to register types */ virtual void registerTypes( const char *uri ); void initializeEngine( QQmlEngine *engine, const char *); }; #endif diff --git a/src/lib/marble/declarative/MarbleQuickItem.cpp b/src/lib/marble/declarative/MarbleQuickItem.cpp index df0e9188c..a2c72f56d 100644 --- a/src/lib/marble/declarative/MarbleQuickItem.cpp +++ b/src/lib/marble/declarative/MarbleQuickItem.cpp @@ -1,952 +1,963 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2014 Adam Dabrowski // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace Marble { //TODO - move to separate files class QuickItemSelectionRubber : public AbstractSelectionRubber { //TODO: support rubber selection in MarbleQuickItem public: void show() { m_visible = true; } void hide() { m_visible = false; } bool isVisible() const { return m_visible; } const QRect &geometry() const { return m_geometry; } void setGeometry(const QRect &/*geometry*/) {} private: QRect m_geometry; bool m_visible; }; //TODO - implement missing functionalities class MarbleQuickInputHandler : public MarbleDefaultInputHandler { public: MarbleQuickInputHandler(MarbleAbstractPresenter *marblePresenter, MarbleQuickItem *marbleQuick) : MarbleDefaultInputHandler(marblePresenter) ,m_marbleQuick(marbleQuick) { setInertialEarthRotationEnabled(false); //Disabled by default, it's buggy. TODO - fix } bool acceptMouse() { return true; } void pinch(QPointF center, qreal scale, Qt::GestureState state) { //TODO - this whole thing should be moved to MarbleAbstractPresenter (void)handlePinch(center, scale, state); } void handleMouseButtonPressAndHold(const QPoint &position) { m_marbleQuick->reverseGeocoding(position); } private Q_SLOTS: void showLmbMenu(int x, int y) { m_marbleQuick->selectPlacemarkAt(x, y); } void showRmbMenu(int, int) {} void openItemToolTip() {} void setCursor(const QCursor &cursor) { m_marbleQuick->setCursor(cursor); } private Q_SLOTS: void installPluginEventFilter(RenderPlugin *) {} private: bool layersEventFilter(QObject *o, QEvent *e) { return m_marbleQuick->layersEventFilter(o, e); } //empty - don't check. It would be invalid with quick items void checkReleasedMove(QMouseEvent *) {} bool handleTouch(QTouchEvent *event) { if (event->touchPoints().count() > 1) { //not handling multi-touch at all, let PinchArea or MultiPointTouchArea take care of it return false; } if (event->touchPoints().count() == 1) { //handle - but do not accept. I.e. pinchArea still needs to get this QTouchEvent::TouchPoint p = event->touchPoints().at(0); if (event->type() == QEvent::TouchBegin) { QMouseEvent press(QMouseEvent::MouseButtonPress, p.pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); handleMouseEvent(&press); } else if (event->type() == QEvent::TouchUpdate) { QMouseEvent move(QMouseEvent::MouseMove, p.pos(), Qt::NoButton, Qt::LeftButton, Qt::NoModifier); handleMouseEvent(&move); } else if (event->type() == QEvent::TouchEnd) { QMouseEvent release(QMouseEvent::MouseButtonRelease, p.pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); handleMouseEvent(&release); } } return false; } AbstractSelectionRubber *selectionRubber() { return &m_selectionRubber; } MarbleQuickItem *m_marbleQuick; QuickItemSelectionRubber m_selectionRubber; bool m_usePinchArea; }; class MarbleQuickItemPrivate { public: explicit MarbleQuickItemPrivate(MarbleQuickItem *marble) : m_marble(marble), m_model(), m_map(&m_model), m_presenter(&m_map), m_positionVisible(false), m_currentPosition(marble), m_inputHandler(&m_presenter, marble), m_placemarkDelegate(nullptr), m_placemarkItem(nullptr), m_placemark(nullptr), m_reverseGeocoding(&m_model) { m_currentPosition.setName(QObject::tr("Current Location")); } private: MarbleQuickItem *m_marble; friend class MarbleQuickItem; MarbleModel m_model; MarbleMap m_map; MarbleAbstractPresenter m_presenter; bool m_positionVisible; Placemark m_currentPosition; MarbleQuickInputHandler m_inputHandler; QQmlComponent* m_placemarkDelegate; QQuickItem* m_placemarkItem; Placemark* m_placemark; ReverseGeocodingRunnerManager m_reverseGeocoding; }; MarbleQuickItem::MarbleQuickItem(QQuickItem *parent) : QQuickPaintedItem(parent) ,d(new MarbleQuickItemPrivate(this)) { qRegisterMetaType("Placemark*"); foreach (AbstractFloatItem *item, d->m_map.floatItems()) { if (item->nameId() == "license") { item->setPosition(QPointF(5.0, -10.0)); } else { item->hide(); } } d->m_model.positionTracking()->setTrackVisible(false); connect(&d->m_map, SIGNAL(repaintNeeded(QRegion)), this, SLOT(update())); connect(this, SIGNAL(widthChanged()), this, SLOT(resizeMap())); connect(this, SIGNAL(heightChanged()), this, SLOT(resizeMap())); connect(&d->m_map, SIGNAL(visibleLatLonAltBoxChanged(GeoDataLatLonAltBox)), this, SLOT(updatePositionVisibility())); connect(&d->m_map, SIGNAL(visibleLatLonAltBoxChanged(GeoDataLatLonAltBox)), this, SIGNAL(visibleLatLonAltBoxChanged())); + connect(&d->m_map, SIGNAL(radiusChanged(int)), this, SIGNAL(radiusChanged(int))); connect(&d->m_map, SIGNAL(radiusChanged(int)), this, SIGNAL(zoomChanged())); connect(&d->m_reverseGeocoding, SIGNAL(reverseGeocodingFinished(GeoDataCoordinates,GeoDataPlacemark)), this, SLOT(handleReverseGeocoding(GeoDataCoordinates,GeoDataPlacemark))); setAcceptedMouseButtons(Qt::AllButtons); installEventFilter(&d->m_inputHandler); } void MarbleQuickItem::resizeMap() { const int minWidth = 100; const int minHeight = 100; int newWidth = width() > minWidth ? (int)width() : minWidth; int newHeight = height() > minHeight ? (int)height() : minHeight; d->m_map.setSize(newWidth, newHeight); update(); updatePositionVisibility(); } void MarbleQuickItem::positionDataStatusChanged(PositionProviderStatus status) { if (status == PositionProviderStatusAvailable) { emit positionAvailableChanged(true); } else { emit positionAvailableChanged(false); } } void MarbleQuickItem::positionChanged(const GeoDataCoordinates &, GeoDataAccuracy) { updatePositionVisibility(); } void MarbleQuickItem::updatePositionVisibility() { updatePlacemarks(); bool isVisible = false; if ( positionAvailable() ) { if ( d->m_map.viewport()->viewLatLonAltBox().contains(d->m_model.positionTracking()->currentLocation()) ) { isVisible = true; } } if ( isVisible != d->m_positionVisible ) { d->m_positionVisible = isVisible; emit positionVisibleChanged( isVisible ); } } void MarbleQuickItem::updateCurrentPosition(const GeoDataCoordinates &coordinates) { d->m_currentPosition.placemark().setCoordinate(coordinates); emit currentPositionChanged(&d->m_currentPosition); } void MarbleQuickItem::updatePlacemarks() { if (!d->m_placemarkDelegate || !d->m_placemark) { return; } if (!d->m_placemarkItem) { QQmlContext * context = new QQmlContext(qmlContext(d->m_placemarkDelegate)); QObject * component = d->m_placemarkDelegate->create(context); d->m_placemarkItem = qobject_cast( component ); if (d->m_placemarkItem) { d->m_placemarkItem->setParentItem( this ); d->m_placemarkItem->setProperty("placemark", QVariant::fromValue(d->m_placemark)); } else { delete component; return; } } qreal x = 0; qreal y = 0; const bool visible = d->m_map.viewport()->screenCoordinates(d->m_placemark->placemark().coordinate(), x, y); d->m_placemarkItem->setVisible(visible); if (visible) { d->m_placemarkItem->setProperty("xPos", QVariant::fromValue(x)); d->m_placemarkItem->setProperty("yPos", QVariant::fromValue(y)); } } void MarbleQuickItem::handleReverseGeocoding(const GeoDataCoordinates &coordinates, const GeoDataPlacemark &placemark) { if (d->m_placemark && d->m_placemark->placemark().coordinate() == coordinates) { d->m_placemark->setGeoDataPlacemark(placemark); updatePlacemarks(); } } void MarbleQuickItem::paint(QPainter *painter) { //TODO - much to be done here still, i.e paint !enabled version QPaintDevice *paintDevice = painter->device(); QRect rect = contentsBoundingRect().toRect(); painter->end(); { GeoPainter geoPainter(paintDevice, d->m_map.viewport(), d->m_map.mapQuality()); d->m_map.paint(geoPainter, rect); } painter->begin(paintDevice); } void MarbleQuickItem::classBegin() { } void MarbleQuickItem::componentComplete() { } int MarbleQuickItem::mapWidth() const { return d->m_map.width(); } int MarbleQuickItem::mapHeight() const { return d->m_map.height(); } bool MarbleQuickItem::showFrameRate() const { return d->m_map.showFrameRate(); } MarbleQuickItem::Projection MarbleQuickItem::projection() const { return (Projection)d->m_map.projection(); } QString MarbleQuickItem::mapThemeId() const { return d->m_map.mapThemeId(); } bool MarbleQuickItem::showAtmosphere() const { return d->m_map.showAtmosphere(); } bool MarbleQuickItem::showCompass() const { return d->m_map.showCompass(); } bool MarbleQuickItem::showClouds() const { return d->m_map.showClouds(); } bool MarbleQuickItem::showCrosshairs() const { return d->m_map.showCrosshairs(); } bool MarbleQuickItem::showGrid() const { return d->m_map.showGrid(); } bool MarbleQuickItem::showOverviewMap() const { return d->m_map.showOverviewMap(); } bool MarbleQuickItem::showOtherPlaces() const { return d->m_map.showOtherPlaces(); } bool MarbleQuickItem::showScaleBar() const { return d->m_map.showScaleBar(); } bool MarbleQuickItem::showBackground() const { return d->m_map.showBackground(); } bool MarbleQuickItem::showPositionMarker() const { QList plugins = d->m_map.renderPlugins(); foreach (const RenderPlugin * plugin, plugins) { if (plugin->nameId() == "positionMarker") { return plugin->visible(); } } return false; } QString MarbleQuickItem::positionProvider() const { if ( d->m_model.positionTracking()->positionProviderPlugin() ) { return d->m_model.positionTracking()->positionProviderPlugin()->nameId(); } return QString(); } MarbleModel* MarbleQuickItem::model() { return &d->m_model; } const MarbleModel* MarbleQuickItem::model() const { return &d->m_model; } MarbleMap* MarbleQuickItem::map() { return &d->m_map; } const MarbleMap* MarbleQuickItem::map() const { return &d->m_map; } bool MarbleQuickItem::inertialGlobeRotation() const { return d->m_inputHandler.inertialEarthRotationEnabled(); } QQmlComponent *MarbleQuickItem::placemarkDelegate() const { return d->m_placemarkDelegate; } void MarbleQuickItem::reverseGeocoding(const QPoint &point) { qreal lon, lat; d->m_map.viewport()->geoCoordinates(point.x(), point.y(), lon, lat); auto const coordinates = GeoDataCoordinates(lon, lat, 0.0, GeoDataCoordinates::Degree); delete d->m_placemarkItem; d->m_placemarkItem = nullptr; delete d->m_placemark; d->m_placemark = new Placemark(this); d->m_placemark->placemark().setCoordinate(coordinates); d->m_reverseGeocoding.reverseGeocoding(coordinates); } qreal MarbleQuickItem::speed() const { return d->m_model.positionTracking()->speed(); } qreal MarbleQuickItem::angle() const { bool routeExists = d->m_model.routingManager()->routingModel()->route().distance() != 0; bool onRoute = !d->m_model.routingManager()->routingModel()->deviatedFromRoute(); if ( routeExists && onRoute) { GeoDataCoordinates curPoint = d->m_model.positionTracking()->positionProviderPlugin()->position(); return d->m_model.routingManager()->routingModel()->route().currentSegment().projectedDirection(curPoint); } else { return d->m_model.positionTracking()->direction(); } } bool MarbleQuickItem::positionAvailable() const { return d->m_model.positionTracking()->status() == PositionProviderStatusAvailable; } bool MarbleQuickItem::positionVisible() { return d->m_positionVisible; } qreal MarbleQuickItem::distanceFromPointToCurrentLocation(const QPoint & position) const { if ( positionAvailable() ) { qreal lon1; qreal lat1; d->m_map.viewport()->geoCoordinates(position.x(), position.y(), lon1, lat1, GeoDataCoordinates::Radian ); GeoDataCoordinates currentCoordinates = d->m_model.positionTracking()->currentLocation(); qreal lon2 = currentCoordinates.longitude(); qreal lat2 = currentCoordinates.latitude(); return distanceSphere(lon1, lat1, lon2, lat2) * d->m_model.planetRadius(); } return 0; } qreal MarbleQuickItem::angleFromPointToCurrentLocation( const QPoint & position ) const { if ( positionAvailable() ) { qreal x, y; PositionTracking const * positionTracking = d->m_model.positionTracking(); map()->viewport()->screenCoordinates( positionTracking->currentLocation(), x, y ); return atan2( y-position.y(), x-position.x() ) * RAD2DEG; } return 0; } Placemark * MarbleQuickItem::currentPosition() const { return &d->m_currentPosition; } QPointF MarbleQuickItem::screenCoordinatesFromCoordinate(Coordinate * coordinate) const { qreal x; qreal y; d->m_map.viewport()->screenCoordinates(coordinate->coordinates(), x, y); return QPointF(x, y); } + void MarbleQuickItem::setRadius(int radius) + { + d->m_map.setRadius(radius); + } + void MarbleQuickItem::setZoom(int newZoom, FlyToMode mode) { d->m_presenter.setZoom(newZoom, mode); } void MarbleQuickItem::setZoomToMaximumLevel() { d->m_presenter.setZoom(d->m_map.maximumZoom()); } void MarbleQuickItem::centerOn(const GeoDataPlacemark& placemark, bool animated) { d->m_presenter.centerOn(placemark, animated); } void MarbleQuickItem::centerOn(const GeoDataLatLonBox& box, bool animated) { d->m_presenter.centerOn(box, animated); } void MarbleQuickItem::centerOn(const GeoDataCoordinates &coordinate) { GeoDataLookAt target = d->m_presenter.lookAt(); target.setCoordinates(coordinate); d->m_presenter.flyTo(target, Automatic); } void MarbleQuickItem::centerOn(qreal longitude, qreal latitude) { d->m_presenter.centerOn(longitude, latitude); } void MarbleQuickItem::centerOnCoordinates(qreal longitude, qreal latitude) { centerOn(longitude, latitude); } void MarbleQuickItem::centerOnCurrentPosition() { GeoDataCoordinates coordinates = d->m_model.positionTracking()->currentLocation(); if ( coordinates == GeoDataCoordinates() ) { return; } d->m_presenter.centerOn(coordinates, true); if (d->m_presenter.zoom() < 3000) { d->m_presenter.setZoom(3250); } } void MarbleQuickItem::selectPlacemarkAt(int x, int y) { auto features = d->m_map.whichFeatureAt(QPoint(x, y)); if (features.empty()) { features = d->m_map.whichBuildingAt(QPoint(x, y)); } QVector placemarks; foreach(auto feature, features) { if (feature->nodeType() == GeoDataTypes::GeoDataPlacemarkType) { placemarks << static_cast(feature); } } // Select bookmarks only if nothing else is found qSort(placemarks.begin(), placemarks.end(), [] (GeoDataPlacemark const *a, GeoDataPlacemark const *b) { int const left = a->visualCategory() == GeoDataFeature::Bookmark ? -1 : a->visualCategory(); int const right = b->visualCategory() == GeoDataFeature::Bookmark ? -1 : b->visualCategory(); return left > right; }); foreach(auto placemark, placemarks) { if (d->m_placemark && placemark->coordinate() == d->m_placemark->placemark().coordinate()) { d->m_placemark->deleteLater(); d->m_placemark = nullptr; } else { d->m_placemark->deleteLater(); d->m_placemark = new Placemark(this); d->m_placemark->setGeoDataPlacemark(*placemark); } delete d->m_placemarkItem; d->m_placemarkItem = nullptr; updatePlacemarks(); return; } if (d->m_placemark) { d->m_placemark->deleteLater(); d->m_placemark = nullptr; delete d->m_placemarkItem; d->m_placemarkItem = nullptr; updatePlacemarks(); } } void MarbleQuickItem::goHome() { d->m_presenter.goHome(); } void MarbleQuickItem::zoomIn(FlyToMode mode) { d->m_presenter.zoomIn(mode); } void MarbleQuickItem::zoomOut(FlyToMode mode) { d->m_presenter.zoomOut(mode); } void MarbleQuickItem::handlePinchStarted(const QPointF &point) { pinch(point, 1, Qt::GestureStarted); } void MarbleQuickItem::handlePinchFinished(const QPointF &point) { pinch(point, 1, Qt::GestureFinished); } void MarbleQuickItem::handlePinchUpdated(const QPointF &point, qreal scale) { scale = sqrt(sqrt(scale)); scale = qBound(static_cast(0.5), scale, static_cast(2.0)); pinch(point, scale, Qt::GestureUpdated); } void MarbleQuickItem::setMapWidth(int mapWidth) { if (d->m_map.width() == mapWidth) { return; } d->m_map.setSize(mapWidth, mapHeight()); emit mapWidthChanged(mapWidth); } void MarbleQuickItem::setMapHeight(int mapHeight) { if (this->mapHeight() == mapHeight) { return; } d->m_map.setSize(mapWidth(), mapHeight); emit mapHeightChanged(mapHeight); } void MarbleQuickItem::setShowFrameRate(bool showFrameRate) { if (this->showFrameRate() == showFrameRate) { return; } d->m_map.setShowFrameRate(showFrameRate); emit showFrameRateChanged(showFrameRate); } void MarbleQuickItem::setProjection(Projection projection) { if (this->projection() == projection) { return; } d->m_map.setProjection((Marble::Projection)projection); emit projectionChanged(projection); } void MarbleQuickItem::setMapThemeId(const QString& mapThemeId) { if (this->mapThemeId() == mapThemeId) { return; } bool const showCompass = d->m_map.showCompass(); bool const showOverviewMap = d->m_map.showOverviewMap(); bool const showOtherPlaces = d->m_map.showOtherPlaces(); bool const showGrid = d->m_map.showGrid(); bool const showScaleBar = d->m_map.showScaleBar(); d->m_map.setMapThemeId(mapThemeId); // Map themes are allowed to change properties. Enforce ours. d->m_map.setShowCompass(showCompass); d->m_map.setShowOverviewMap(showOverviewMap); d->m_map.setShowOtherPlaces(showOtherPlaces); d->m_map.setShowGrid(showGrid); d->m_map.setShowScaleBar(showScaleBar); emit mapThemeIdChanged(mapThemeId); } void MarbleQuickItem::setShowAtmosphere(bool showAtmosphere) { if (this->showAtmosphere() == showAtmosphere) { return; } d->m_map.setShowAtmosphere(showAtmosphere); emit showAtmosphereChanged(showAtmosphere); } void MarbleQuickItem::setShowCompass(bool showCompass) { if (this->showCompass() == showCompass) { return; } d->m_map.setShowCompass(showCompass); emit showCompassChanged(showCompass); } void MarbleQuickItem::setShowClouds(bool showClouds) { if (this->showClouds() == showClouds) { return; } d->m_map.setShowClouds(showClouds); emit showCloudsChanged(showClouds); } void MarbleQuickItem::setShowCrosshairs(bool showCrosshairs) { if (this->showCrosshairs() == showCrosshairs) { return; } d->m_map.setShowCrosshairs(showCrosshairs); emit showCrosshairsChanged(showCrosshairs); } void MarbleQuickItem::setShowGrid(bool showGrid) { if (this->showGrid() == showGrid) { return; } d->m_map.setShowGrid(showGrid); emit showGridChanged(showGrid); } void MarbleQuickItem::setShowOverviewMap(bool showOverviewMap) { if (this->showOverviewMap() == showOverviewMap) { return; } d->m_map.setShowOverviewMap(showOverviewMap); emit showOverviewMapChanged(showOverviewMap); } void MarbleQuickItem::setShowOtherPlaces(bool showOtherPlaces) { if (this->showOtherPlaces() == showOtherPlaces) { return; } d->m_map.setShowOtherPlaces(showOtherPlaces); emit showOtherPlacesChanged(showOtherPlaces); } void MarbleQuickItem::setShowScaleBar(bool showScaleBar) { if (this->showScaleBar() == showScaleBar) { return; } d->m_map.setShowScaleBar(showScaleBar); emit showScaleBarChanged(showScaleBar); } void MarbleQuickItem::setShowBackground(bool showBackground) { if (this->showBackground() == showBackground) { return; } d->m_map.setShowBackground(showBackground); emit showBackgroundChanged(showBackground); } void MarbleQuickItem::setShowPositionMarker(bool showPositionMarker) { if (this->showPositionMarker() == showPositionMarker) { return; } QList plugins = d->m_map.renderPlugins(); foreach ( RenderPlugin * plugin, plugins ) { if ( plugin->nameId() == "positionMarker" ) { plugin->setVisible(showPositionMarker); break; } } emit showPositionMarkerChanged(showPositionMarker); } void MarbleQuickItem::setPositionProvider(const QString &positionProvider) { QString name; if ( d->m_model.positionTracking()->positionProviderPlugin() ) { name = d->m_model.positionTracking()->positionProviderPlugin()->nameId(); if ( name == positionProvider ) { return; } } if ( positionProvider.isEmpty() ) { d->m_model.positionTracking()->setPositionProviderPlugin( nullptr ); return; } QList plugins = d->m_model.pluginManager()->positionProviderPlugins(); foreach (const PositionProviderPlugin* plugin, plugins) { if ( plugin->nameId() == positionProvider) { PositionProviderPlugin * newPlugin = plugin->newInstance(); d->m_model.positionTracking()->setPositionProviderPlugin(newPlugin); connect(newPlugin, SIGNAL(statusChanged(PositionProviderStatus)), this, SLOT(positionDataStatusChanged(PositionProviderStatus))); connect(newPlugin, SIGNAL(positionChanged(GeoDataCoordinates,GeoDataAccuracy)), this, SLOT(updateCurrentPosition(GeoDataCoordinates))); connect(newPlugin, SIGNAL(positionChanged(GeoDataCoordinates,GeoDataAccuracy)), this, SIGNAL(speedChanged())); connect(newPlugin, SIGNAL(positionChanged(GeoDataCoordinates,GeoDataAccuracy)), this, SIGNAL(angleChanged())); emit positionProviderChanged(positionProvider); break; } } } void MarbleQuickItem::setInertialGlobeRotation(bool inertialGlobeRotation) { if (inertialGlobeRotation == d->m_inputHandler.inertialEarthRotationEnabled()) { return; } d->m_inputHandler.setInertialEarthRotationEnabled(inertialGlobeRotation); emit inertialGlobeRotationChanged(inertialGlobeRotation); } void MarbleQuickItem::setPluginSetting(const QString &pluginId, const QString &key, const QString &value) { foreach (RenderPlugin* plugin, d->m_map.renderPlugins()) { if (plugin->nameId() == pluginId) { plugin->setSetting(key, value); } } } void MarbleQuickItem::setPropertyEnabled(const QString &property, bool enabled) { d->m_map.setPropertyValue(property, enabled); } bool MarbleQuickItem::isPropertyEnabled(const QString &property) const { return d->m_map.propertyValue(property); } void MarbleQuickItem::setShowRuntimeTrace(bool showRuntimeTrace) { d->m_map.setShowRuntimeTrace(showRuntimeTrace); update(); } void MarbleQuickItem::setShowDebugPolygons(bool showDebugPolygons) { d->m_map.setShowDebugPolygons(showDebugPolygons); update(); } void MarbleQuickItem::setPlacemarkDelegate(QQmlComponent *placemarkDelegate) { if (d->m_placemarkDelegate == placemarkDelegate) { return; } delete d->m_placemarkItem; d->m_placemarkItem = nullptr; d->m_placemarkDelegate = placemarkDelegate; emit placemarkDelegateChanged(placemarkDelegate); } void MarbleQuickItem::loadSettings() { QSettings settings; settings.beginGroup("MarbleQuickItem"); double lon = settings.value("centerLon", QVariant(0.0)).toDouble(); double lat = settings.value("centerLat", QVariant(0.0)).toDouble(); centerOn(lon, lat); int const zoom = settings.value("zoom", QVariant(0)).toInt(); if (zoom > 0) { setZoom(zoom); } settings.endGroup(); d->m_model.routingManager()->readSettings(); d->m_model.bookmarkManager()->loadFile( "bookmarks/bookmarks.kml" ); d->m_model.bookmarkManager()->setShowBookmarks(true); } void MarbleQuickItem::writeSettings() { QSettings settings; settings.beginGroup("MarbleQuickItem"); settings.setValue("centerLon", QVariant(d->m_map.centerLongitude())); settings.setValue("centerLat", QVariant(d->m_map.centerLatitude())); settings.setValue("zoom", QVariant(zoom())); settings.endGroup(); d->m_model.routingManager()->writeSettings(); } QObject *MarbleQuickItem::getEventFilter() const { //We would want to install the same event filter for abstract layer QuickItems such as PinchArea return &d->m_inputHandler; } void MarbleQuickItem::pinch(const QPointF& center, qreal scale, Qt::GestureState state) { d->m_inputHandler.pinch(center, scale, state); } MarbleInputHandler *MarbleQuickItem::inputHandler() { return &d->m_inputHandler; } + int MarbleQuickItem::radius() const + { + return d->m_map.radius(); + } + int MarbleQuickItem::zoom() const { return d->m_presenter.logzoom(); } bool MarbleQuickItem::layersEventFilter(QObject *, QEvent *) { //Does nothing, but can be reimplemented in a subclass return false; } } diff --git a/src/lib/marble/declarative/MarbleQuickItem.h b/src/lib/marble/declarative/MarbleQuickItem.h index b36402ecc..66313069f 100644 --- a/src/lib/marble/declarative/MarbleQuickItem.h +++ b/src/lib/marble/declarative/MarbleQuickItem.h @@ -1,225 +1,229 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2014 Adam Dabrowski // #ifndef MARBLEQUICKITEM_H #define MARBLEQUICKITEM_H #include "marble_declarative_export.h" #include #include #include "GeoDataPlacemark.h" #include "MarbleGlobal.h" #include "PositionProviderPluginInterface.h" #include "MarbleMap.h" #include "Placemark.h" namespace Marble { class MarbleModel; class MarbleInputHandler; class MarbleQuickItemPrivate; //Class is still being developed class MARBLE_DECLARATIVE_EXPORT MarbleQuickItem : public QQuickPaintedItem { Q_OBJECT Q_ENUMS(Projection) Q_PROPERTY(int mapWidth READ mapWidth WRITE setMapWidth NOTIFY mapWidthChanged) Q_PROPERTY(int mapHeight READ mapHeight WRITE setMapHeight NOTIFY mapHeightChanged) Q_PROPERTY(int zoom READ zoom WRITE setZoom NOTIFY zoomChanged) + Q_PROPERTY(int radius READ radius WRITE setRadius NOTIFY radiusChanged) Q_PROPERTY(bool showFrameRate READ showFrameRate WRITE setShowFrameRate NOTIFY showFrameRateChanged) Q_PROPERTY(Projection projection READ projection WRITE setProjection NOTIFY projectionChanged) Q_PROPERTY(QString mapThemeId READ mapThemeId WRITE setMapThemeId NOTIFY mapThemeIdChanged) Q_PROPERTY(bool showAtmosphere READ showAtmosphere WRITE setShowAtmosphere NOTIFY showAtmosphereChanged) Q_PROPERTY(bool showCompass READ showCompass WRITE setShowCompass NOTIFY showCompassChanged) Q_PROPERTY(bool showClouds READ showClouds WRITE setShowClouds NOTIFY showCloudsChanged) Q_PROPERTY(bool showCrosshairs READ showCrosshairs WRITE setShowCrosshairs NOTIFY showCrosshairsChanged) Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid NOTIFY showGridChanged) Q_PROPERTY(bool showOverviewMap READ showOverviewMap WRITE setShowOverviewMap NOTIFY showOverviewMapChanged) Q_PROPERTY(bool showOtherPlaces READ showOtherPlaces WRITE setShowOtherPlaces NOTIFY showOtherPlacesChanged) Q_PROPERTY(bool showScaleBar READ showScaleBar WRITE setShowScaleBar NOTIFY showScaleBarChanged) Q_PROPERTY(bool showBackground READ showBackground WRITE setShowBackground NOTIFY showBackgroundChanged) Q_PROPERTY(bool showPositionMarker READ showPositionMarker WRITE setShowPositionMarker NOTIFY showPositionMarkerChanged) Q_PROPERTY(QString positionProvider READ positionProvider WRITE setPositionProvider NOTIFY positionProviderChanged) Q_PROPERTY(bool positionAvailable READ positionAvailable NOTIFY positionAvailableChanged) Q_PROPERTY(bool positionVisible READ positionVisible NOTIFY positionVisibleChanged) Q_PROPERTY(MarbleMap* marbleMap READ map NOTIFY marbleMapChanged) Q_PROPERTY(Placemark* currentPosition READ currentPosition NOTIFY currentPositionChanged) Q_PROPERTY(qreal speed READ speed NOTIFY speedChanged) Q_PROPERTY(qreal angle READ angle NOTIFY angleChanged) Q_PROPERTY(bool inertialGlobeRotation READ inertialGlobeRotation WRITE setInertialGlobeRotation NOTIFY inertialGlobeRotationChanged) Q_PROPERTY(QQmlComponent* placemarkDelegate READ placemarkDelegate WRITE setPlacemarkDelegate NOTIFY placemarkDelegateChanged) public: explicit MarbleQuickItem(QQuickItem *parent = 0); enum Projection{ Spherical = Marble::Spherical, Equirectangular = Marble::Equirectangular, Mercator = Marble::Mercator, Gnomonic = Marble::Gnomonic, Stereographic = Marble::Stereographic, LambertAzimuthal = Marble::LambertAzimuthal, AzimuthalEquidistant = Marble::AzimuthalEquidistant, VerticalPerspective = Marble::VerticalPerspective }; MarbleInputHandler *inputHandler(); int zoom() const; + int radius() const; public Q_SLOTS: void goHome(); void setZoom(int zoom, FlyToMode mode = Instant); Q_INVOKABLE void setZoomToMaximumLevel(); + void setRadius(int radius); void centerOn(const GeoDataPlacemark& placemark, bool animated = false); void centerOn(const GeoDataLatLonBox& box, bool animated = false); void centerOn(const GeoDataCoordinates& coordinate); void centerOn(qreal longitude, qreal latitude); Q_INVOKABLE void centerOnCoordinates(qreal longitude, qreal latitude); Q_INVOKABLE void centerOnCurrentPosition(); Q_INVOKABLE void selectPlacemarkAt(int x, int y); void zoomIn(FlyToMode mode = Automatic); void zoomOut(FlyToMode mode = Automatic); Q_INVOKABLE void handlePinchStarted(const QPointF &point); Q_INVOKABLE void handlePinchFinished(const QPointF &point); Q_INVOKABLE void handlePinchUpdated(const QPointF &point, qreal scale); void setMapWidth(int mapWidth); void setMapHeight(int mapHeight); void setShowFrameRate(bool showFrameRate); void setProjection(Projection projection); void setMapThemeId(const QString& mapThemeId); void setShowAtmosphere(bool showAtmosphere); void setShowCompass(bool showCompass); void setShowClouds(bool showClouds); void setShowCrosshairs(bool showCrosshairs); void setShowGrid(bool showGrid); void setShowOverviewMap(bool showOverviewMap); void setShowOtherPlaces(bool showOtherPlaces); void setShowScaleBar(bool showScaleBar); void setShowBackground(bool showBackground); void setShowPositionMarker(bool showPositionMarker); void setPositionProvider(const QString & positionProvider); void setInertialGlobeRotation(bool inertialGlobeRotation); void setPluginSetting(const QString &plugin, const QString &key, const QString &value); void setPropertyEnabled(const QString &property, bool enabled); bool isPropertyEnabled(const QString &property) const; Q_INVOKABLE void setShowRuntimeTrace(bool showRuntimeTrace); Q_INVOKABLE void setShowDebugPolygons(bool showDebugPolygons); void setPlacemarkDelegate(QQmlComponent* placemarkDelegate); Q_INVOKABLE void loadSettings(); Q_INVOKABLE void writeSettings(); public: void paint(QPainter *painter); // QQmlParserStatus interface public: void classBegin(); void componentComplete(); public: virtual bool layersEventFilter(QObject *o, QEvent *e); int mapWidth() const; int mapHeight() const; bool showFrameRate() const; Projection projection() const; QString mapThemeId() const; bool showAtmosphere() const; bool showCompass() const; bool showClouds() const; bool showCrosshairs() const; bool showGrid() const; bool showOverviewMap() const; bool showOtherPlaces() const; bool showScaleBar() const; bool showBackground() const; bool showPositionMarker() const; QString positionProvider() const; bool positionAvailable() const; bool positionVisible(); Q_INVOKABLE qreal distanceFromPointToCurrentLocation(const QPoint & position) const; Q_INVOKABLE qreal angleFromPointToCurrentLocation(const QPoint & position) const; Placemark* currentPosition() const; Q_INVOKABLE QPointF screenCoordinatesFromCoordinate(Coordinate * coordinate) const; qreal speed() const; qreal angle() const; MarbleModel* model(); const MarbleModel* model() const; MarbleMap* map(); const MarbleMap* map() const; bool inertialGlobeRotation() const; QQmlComponent* placemarkDelegate() const; void reverseGeocoding(const QPoint &point); Q_SIGNALS: void mapWidthChanged(int mapWidth); void mapHeightChanged(int mapHeight); void showFrameRateChanged(bool showFrameRate); void projectionChanged(Projection projection); void mapThemeIdChanged(const QString& mapThemeId); void showAtmosphereChanged(bool showAtmosphere); void showCompassChanged(bool showCompass); void showCloudsChanged(bool showClouds); void showCrosshairsChanged(bool showCrosshairs); void showGridChanged(bool showGrid); void showOverviewMapChanged(bool showOverviewMap); void showOtherPlacesChanged(bool showOtherPlaces); void showScaleBarChanged(bool showScaleBar); void showBackgroundChanged(bool showBackground); void showPositionMarkerChanged(bool showPositionMarker); void positionProviderChanged(const QString & positionProvider); void positionAvailableChanged(bool positionAvailable); void positionVisibleChanged(bool positionVisible); void marbleMapChanged(); void visibleLatLonAltBoxChanged(); void currentPositionChanged(Placemark* currentPosition); void angleChanged(); void speedChanged(); void zoomChanged(); + void radiusChanged(int radius); void inertialGlobeRotationChanged(bool inertialGlobeRotation); void placemarkDelegateChanged(QQmlComponent* placemarkDelegate); protected: QObject *getEventFilter() const; void pinch(const QPointF& center, qreal scale, Qt::GestureState state); private Q_SLOTS: void resizeMap(); void positionDataStatusChanged(PositionProviderStatus status); void positionChanged(const GeoDataCoordinates &, GeoDataAccuracy); void updatePositionVisibility(); void updateCurrentPosition(const GeoDataCoordinates & coordinates); void updatePlacemarks(); void handleReverseGeocoding(const GeoDataCoordinates &coordinates, const GeoDataPlacemark &placemark); private: typedef QSharedPointer MarbleQuickItemPrivatePtr; MarbleQuickItemPrivatePtr d; friend class MarbleQuickItemPrivate; }; } #endif // MARBLEQUICKITEM_H diff --git a/src/plasma/CMakeLists.txt b/src/plasma/CMakeLists.txt new file mode 100644 index 000000000..196834d57 --- /dev/null +++ b/src/plasma/CMakeLists.txt @@ -0,0 +1,17 @@ +set(KDE_SKIP_UNINSTALL_TARGET ON CACHE BOOL "KDE uninstall target must be disabled") +find_package(ECM QUIET) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH}) +if(ECM_FOUND) + include(KDEInstallDirs) +endif() +macro_optional_find_package(KF5 QUIET COMPONENTS Config Plasma Service) + +if (NOT KF5_FOUND) + return() +endif() + + +add_subdirectory(qmlplugin) + +add_subdirectory(applets) +add_subdirectory(wallpapers) diff --git a/src/plasma/applets/CMakeLists.txt b/src/plasma/applets/CMakeLists.txt new file mode 100644 index 000000000..ff61e5d2c --- /dev/null +++ b/src/plasma/applets/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(worldclock) diff --git a/src/plasma/applets/worldclock/CMakeLists.txt b/src/plasma/applets/worldclock/CMakeLists.txt new file mode 100644 index 000000000..6e280bbe8 --- /dev/null +++ b/src/plasma/applets/worldclock/CMakeLists.txt @@ -0,0 +1 @@ +plasma_install_package(package org.kde.plasma.worldclock) diff --git a/src/plasma/applets/worldclock/Messages.sh b/src/plasma/applets/worldclock/Messages.sh new file mode 100644 index 000000000..6cd42cca2 --- /dev/null +++ b/src/plasma/applets/worldclock/Messages.sh @@ -0,0 +1,2 @@ +#! /usr/bin/env bash +$XGETTEXT `find . -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.plasma.worldclock.pot diff --git a/src/plasma/applets/worldclock/package/contents/config/config.qml b/src/plasma/applets/worldclock/package/contents/config/config.qml new file mode 100644 index 000000000..1b4b14f66 --- /dev/null +++ b/src/plasma/applets/worldclock/package/contents/config/config.qml @@ -0,0 +1,36 @@ +/* + * Copyright 2016 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + */ + +import QtQuick 2.1 + +import org.kde.plasma.configuration 2.0 + +ConfigModel { + ConfigCategory { + name: i18n("Map Display") + icon: "preferences-desktop-display" + source: "configMapDisplay.qml" + } + +/* TODO: readd later + ConfigCategory { + name: i18n("Time Zones") + icon: "preferences-system-time" + source: "configTimeZones.qml" + } +*/ +} diff --git a/src/plasma/applets/worldclock/package/contents/config/main.xml b/src/plasma/applets/worldclock/package/contents/config/main.xml new file mode 100644 index 000000000..0c62518ac --- /dev/null +++ b/src/plasma/applets/worldclock/package/contents/config/main.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + Equirectangular + + + + false + + + + + + diff --git a/src/plasma/applets/worldclock/package/contents/ui/configMapDisplay.qml b/src/plasma/applets/worldclock/package/contents/ui/configMapDisplay.qml new file mode 100644 index 000000000..29fc967a9 --- /dev/null +++ b/src/plasma/applets/worldclock/package/contents/ui/configMapDisplay.qml @@ -0,0 +1,72 @@ +/* + * Copyright 2016 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + */ + +import QtQuick 2.1 +import QtQuick.Controls 1.0 as QtControls +import QtQuick.Layouts 1.0 + +ColumnLayout { + id: mapDisplayPage + + property int cfg_projection: plasmoid.configuration.projection // Enum needs manual set/get for now + property alias cfg_showDate: showDateCheckBox.checked + + GridLayout { + columns: 2 + + QtControls.Label { + Layout.row: 0 + Layout.column: 0 + Layout.alignment: Qt.AlignRight + anchors { + verticalCenter: projectionComboBox.verticalCenter + } + text: i18n("Projection:") + } + + QtControls.ComboBox { + id: projectionComboBox + model: [ + i18n("Equirectangular"), + i18n("Mercator") + ] + onCurrentIndexChanged: { + cfg_projection = currentIndex; + } + Component.onCompleted: { + currentIndex = plasmoid.configuration.projection; + } + } + + QtControls.Label { + Layout.row: 4 + Layout.column: 0 + Layout.alignment: Qt.AlignRight + text: i18n("Show date:") + } + + QtControls.CheckBox { + Layout.row: 4 + Layout.column: 1 + id: showDateCheckBox + } + } + + Item { // tighten layout + Layout.fillHeight: true + } +} diff --git a/src/plasma/applets/worldclock/package/contents/ui/configTimeZones.qml b/src/plasma/applets/worldclock/package/contents/ui/configTimeZones.qml new file mode 100644 index 000000000..97cb8c6be --- /dev/null +++ b/src/plasma/applets/worldclock/package/contents/ui/configTimeZones.qml @@ -0,0 +1,42 @@ +/* + * Copyright 2016 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + */ + +import QtQuick 2.1 +import QtQuick.Controls 1.0 as QtControls +import QtQuick.Layouts 1.0 + +ColumnLayout { + id: timeZonesPage + + property alias cfg_customTimeZone: customTimeZoneCheckBox.checked + + RowLayout { + QtControls.Label { + text: i18n("Use custom time zone selection:") + } + + QtControls.CheckBox { + id: customTimeZoneCheckBox + } + } + + QtControls.TableView { + id: timeZoneView + Layout.fillHeight: true + } +} + diff --git a/src/plasma/applets/worldclock/package/contents/ui/main.qml b/src/plasma/applets/worldclock/package/contents/ui/main.qml new file mode 100644 index 000000000..9a306d58d --- /dev/null +++ b/src/plasma/applets/worldclock/package/contents/ui/main.qml @@ -0,0 +1,127 @@ +/* + * Copyright 2016 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + */ + +import QtQuick 2.1 +import QtQuick.Layouts 1.1 + +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras + +import org.kde.marble.private.plasma 0.20 + +Item { + id: root + + readonly property date currentDateTime: dataSource.data.Local ? dataSource.data.Local.DateTime : new Date() + + Plasmoid.toolTipMainText: Qt.formatTime(currentDateTime) + Plasmoid.toolTipSubText: Qt.formatDate(currentDateTime, Qt.locale().dateFormat(Locale.LongFormat)) + + PlasmaCore.DataSource { + id: dataSource + engine: "time" + connectedSources: ["Local"] + interval: 60000 + intervalAlignment: PlasmaCore.Types.AlignToMinute + } + + Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation + + Plasmoid.fullRepresentation: MarbleItem { + id: marbleItem + + enabled: false // do not handle input + Layout.minimumWidth: units.gridUnit * 20 + Layout.minimumHeight: units.gridUnit * 10 + + radius: { + var ratio = width/height; + if (projection === MarbleItem.Equirectangular) { + if (ratio > 2) { + return height / 2; + } + return width / 4; + } else { + if (ratio > 1) { + return height / 4; + } + return width / 4 + } + } + + // Theme settings. + projection: (plasmoid.configuration.projection === 0) ? MarbleItem.Equirectangular : MarbleItem.Mercator + mapThemeId: "earth/bluemarble/bluemarble.dgml" + + // Visibility of layers/plugins. + showAtmosphere: false + showClouds: false + showBackground: false + + showGrid: false + showCrosshairs: false + showCompass: false + showOverviewMap: false + showScaleBar: false + // TODO: showCredit: false + + Component.onCompleted: { + marbleMap.setShowSunShading(true); + marbleMap.setShowCityLights(true); + + marbleMap.setShowPlaces(false); + marbleMap.setShowOtherPlaces(false); + marbleMap.setShowCities(false); + marbleMap.setShowTerrain(false); + + // will depend on plasmoid.configuration.centerSun + marbleMap.setLockToSubSolarPoint(true); + marbleMap.setSubSolarPointIconVisible(true); + } + + ColumnLayout { + anchors.centerIn: parent + + PlasmaExtras.Heading { + id: timeLabel + + Layout.alignment: Qt.AlignHCenter + + level: 1 + text: plasmoid.configuration.showDate ? Qt.formatDateTime(currentDateTime) : Qt.formatTime(currentDateTime) + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + /* + PlasmaExtras.Heading { + id: timezoneLabel + + Layout.alignment: Qt.AlignHCenter + + level: 3 + text: "Internet" + + visible: text.length > 0 + horizontalAlignment: Text.AlignHCenter + } + */ + } + } +} diff --git a/src/plasma/applets/worldclock/package/metadata.desktop b/src/plasma/applets/worldclock/package/metadata.desktop new file mode 100644 index 000000000..f22a5b774 --- /dev/null +++ b/src/plasma/applets/worldclock/package/metadata.desktop @@ -0,0 +1,21 @@ +[Desktop Entry] +Name=World Clock +# not yet... Comment=Shows the time in different parts of the world + +Icon=marble +Type=Service + +X-KDE-ServiceTypes=Plasma/Applet + +X-KDE-PluginInfo-Author=Friedrich W. H. Kossebau +X-KDE-PluginInfo-Email=kossebau@kde.org +X-KDE-PluginInfo-Name=org.kde.plasma.worldclock +X-KDE-PluginInfo-Version=0.2 +X-KDE-PluginInfo-Website=https://marble.kde.org/ +X-KDE-PluginInfo-Category=Date and Time +X-KDE-PluginInfo-License=LGPL + +X-Plasma-API=declarativeappletscript +X-Plasma-StandAloneApp=true +X-Plasma-NotificationArea=false +X-Plasma-MainScript=ui/main.qml diff --git a/src/plasma/qmlplugin/CMakeLists.txt b/src/plasma/qmlplugin/CMakeLists.txt new file mode 100644 index 000000000..8cb8a8156 --- /dev/null +++ b/src/plasma/qmlplugin/CMakeLists.txt @@ -0,0 +1,16 @@ +include_directories( + ${CMAKE_SOURCE_DIR}/src/lib/marble/declarative +) + +set(marblequick_SRCS + qmlplugin.cpp +) + +install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/marble/private/plasma) +add_library(marblequick SHARED ${marblequick_SRCS}) + +target_link_libraries(marblequick + marbledeclarative +) + +install(TARGETS marblequick DESTINATION ${QML_INSTALL_DIR}/org/kde/marble/private/plasma) diff --git a/src/plasma/qmlplugin/qmldir b/src/plasma/qmlplugin/qmldir new file mode 100644 index 000000000..0e503ea2c --- /dev/null +++ b/src/plasma/qmlplugin/qmldir @@ -0,0 +1,2 @@ +module org.kde.marble.private.plasma +plugin marblequick diff --git a/src/plasma/qmlplugin/qmlplugin.cpp b/src/plasma/qmlplugin/qmlplugin.cpp new file mode 100644 index 000000000..af5acf873 --- /dev/null +++ b/src/plasma/qmlplugin/qmlplugin.cpp @@ -0,0 +1,18 @@ +/* + * Copyright 2016 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + */ + +#include "qmlplugin.h" diff --git a/src/plasma/qmlplugin/qmlplugin.h b/src/plasma/qmlplugin/qmlplugin.h new file mode 100644 index 000000000..1003c1be5 --- /dev/null +++ b/src/plasma/qmlplugin/qmlplugin.h @@ -0,0 +1,35 @@ +/* + * Copyright 2016 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + */ + +#ifndef PLUGIN_H +#define PLUGIN_H + +#include + +/** + * For now installing this separate Marble QtQuick plugin under a private namespace, + * org.kde.marble.private.plasma (see qmldir) + * until we have sorted out a general public Marble QtQuick plugin API + * and libmarbledeclarative is turned back into a plugin instead of shared library + */ +class MarbleQuickPlugin : public MarbleDeclarativePlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") +}; + +#endif // PLUGIN_H diff --git a/src/plasma/wallpapers/CMakeLists.txt b/src/plasma/wallpapers/CMakeLists.txt new file mode 100644 index 000000000..ede0b7a57 --- /dev/null +++ b/src/plasma/wallpapers/CMakeLists.txt @@ -0,0 +1 @@ +plasma_install_package(worldmap org.kde.plasma.wallpaper.worldmap wallpapers wallpaper) diff --git a/src/plasma/wallpapers/worldmap/Messages.sh b/src/plasma/wallpapers/worldmap/Messages.sh new file mode 100644 index 000000000..f52fb4c6c --- /dev/null +++ b/src/plasma/wallpapers/worldmap/Messages.sh @@ -0,0 +1,2 @@ +#! /usr/bin/env bash +$XGETTEXT `find . -name \*.qml` -o $podir/plasma_wallpaper_org.kde.plasma.worldmap.pot diff --git a/src/plasma/wallpapers/worldmap/contents/config/main.xml b/src/plasma/wallpapers/worldmap/contents/config/main.xml new file mode 100644 index 000000000..3132a1091 --- /dev/null +++ b/src/plasma/wallpapers/worldmap/contents/config/main.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + Equirectangular + + + + diff --git a/src/plasma/wallpapers/worldmap/contents/ui/config.qml b/src/plasma/wallpapers/worldmap/contents/ui/config.qml new file mode 100644 index 000000000..93d467ea8 --- /dev/null +++ b/src/plasma/wallpapers/worldmap/contents/ui/config.qml @@ -0,0 +1,66 @@ +/* + * Copyright 2016 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + */ + +import QtQuick 2.1 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 1.0 as QtControls + +// for "units" +import org.kde.plasma.core 2.0 as PlasmaCore + + +ColumnLayout { + id: root + property int cfg_projection: plasmoid.configuration.projection // Enum needs manual set/get for now + + RowLayout { + spacing: units.largeSpacing / 2 + + // To allow aligned integration in the settings form, + // "formAlignment" is a property injected by the config containment + // which defines the offset of the value fields + QtControls.Label { + Layout.minimumWidth: width + Layout.maximumWidth: width + width: formAlignment - units.largeSpacing + horizontalAlignment: Text.AlignRight + anchors { + verticalCenter: projectionComboBox.verticalCenter + } + + // use i18nd, as textdomain otherwise would be defined by config containment + text: i18nd("plasma_wallpaper_org.kde.plasma.worldmap", "Projection:") + } + QtControls.ComboBox { + id: projectionComboBox + model: [ + i18nd("plasma_wallpaper_org.kde.plasma.worldmap", "Equirectangular"), + i18nd("plasma_wallpaper_org.kde.plasma.worldmap", "Mercator") + ] + onCurrentIndexChanged: { + cfg_projection = currentIndex; + } + Component.onCompleted: { + currentIndex = plasmoid.configuration.projection; + } + } + } + + Item { // tighten layout + Layout.fillHeight: true + } +} diff --git a/src/plasma/wallpapers/worldmap/contents/ui/main.qml b/src/plasma/wallpapers/worldmap/contents/ui/main.qml new file mode 100644 index 000000000..5410d9cee --- /dev/null +++ b/src/plasma/wallpapers/worldmap/contents/ui/main.qml @@ -0,0 +1,72 @@ +/* + * Copyright 2016 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + */ + +import QtQuick 2.1 + +import org.kde.plasma.extras 2.0 as PlasmaExtras + +import org.kde.marble.private.plasma 0.20 + +MarbleItem { + id: marbleItem + + enabled: false // do not handle input + + radius: { + var ratio = width/height; + if (projection === MarbleItem.Equirectangular) { + if (ratio > 2) { + return height / 2; + } + return width / 4; + } else { + if (ratio > 1) { + return height / 4; + } + return width / 4 + } + } + + // Theme settings. + projection: (wallpaper.configuration.projection === 0) ? MarbleItem.Equirectangular : MarbleItem.Mercator + mapThemeId: "earth/bluemarble/bluemarble.dgml" + + // Visibility of layers/plugins. + showAtmosphere: false + showClouds: false + showBackground: false + + showGrid: false + showCrosshairs: false + showCompass: false + showOverviewMap: false + showScaleBar: false + + Component.onCompleted: { + marbleMap.setShowSunShading(true); + marbleMap.setShowCityLights(true); + + marbleMap.setShowPlaces(false); + marbleMap.setShowCities(false); + marbleMap.setShowTerrain(false); + marbleMap.setShowOtherPlaces(false); + + // will depend on wallpaper.configuration.centerSun + marbleMap.setLockToSubSolarPoint(true); + marbleMap.setSubSolarPointIconVisible(true); + } +} diff --git a/src/plasma/wallpapers/worldmap/metadata.desktop b/src/plasma/wallpapers/worldmap/metadata.desktop new file mode 100644 index 000000000..b4d584d33 --- /dev/null +++ b/src/plasma/wallpapers/worldmap/metadata.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Name=World Map +Type=Service +Icon=marble + +X-KDE-ServiceTypes=Plasma/Wallpaper +X-KDE-PluginInfo-Author=Friedrich W. H. Kossebau +X-KDE-PluginInfo-Email=kossebau@kde.org +X-KDE-PluginInfo-License=LGPL +X-KDE-PluginInfo-Name=org.kde.plasma.worldmap +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=https://marble.kde.org/ +X-Plasma-MainScript=ui/main.qml