diff options
author | Pierre GRANDIN <pgrandin@users.noreply.github.com> | 2017-10-04 09:36:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-04 09:36:26 -0700 |
commit | a3435121850201dc163c5f55153ea4bc9d91e179 (patch) | |
tree | a5bb229776f049633129e97bdd8d80fee689be9e | |
parent | a381091a64f0d3305f2eb18e2dfd4801d5a5cdc8 (diff) | |
download | navit-a3435121850201dc163c5f55153ea4bc9d91e179.tar.gz |
Update:QML2:Various updates on the QML2 UI (#316)
* Adding qt5/qml2 UI proof of concept
* Code cleanup
* Minor cleanup
* Apply coding style by clang-format -style=WebKit
For better diff tracking, I applied coding style once more.
* Removed useless QtQuick.Controls dependency
* QML2 : Minor work around POIs
* QML2 : Use real POIs icons
* More minor work around POIs.
This commit adds a draft of POI display, and the possibility to set a POI as destination.
Also sets the current position to wherever we clicked on the map, to simulate routing using the Demo vehicle
* Renamed default skin to 'modern'
This will allow us to easily create other skins and make the skin to load configurable
* Added town search capability
* Resize the QNavitQuick object when exiting the menu
* Minor work on the qml2 gui
* Implemented street search
* Disabled virtual keyboard until it's ready
* More modular default country code
* Block draw operations when displaying the menu
* Removed useless QML ressources
* Prevents a segfault on country/town/street selection
* Prevents segfault when changing country
* Added bookmarks listing
* Added basic vehicles and bookmarks menu
* Removed useless QDebug
* Removed useless QDebug
* Added bookmarks list as a destination
* Code cleanup
* Switching to a reusable result list
* Added basic vehicles and bookmarks menu
* Added a basic bookmark QObject
* Added basic vehicles and bookmarks menu
* Added basic vehicles and bookmarks menu
* Code cleanup
* Use update path for icons assets
-rw-r--r-- | navit/gui/qt5_qml/CMakeLists.txt | 3 | ||||
-rw-r--r-- | navit/gui/qt5_qml/backend.cpp | 174 | ||||
-rw-r--r-- | navit/gui/qt5_qml/backend.h | 25 | ||||
-rw-r--r-- | navit/gui/qt5_qml/editor/qml.qrc | 7 | ||||
-rw-r--r-- | navit/gui/qt5_qml/gui_qt5_qml.qrc | 7 | ||||
-rw-r--r-- | navit/gui/qt5_qml/qml_bookmark.cpp | 32 | ||||
-rw-r--r-- | navit/gui/qt5_qml/qml_bookmark.h | 31 | ||||
-rw-r--r-- | navit/gui/qt5_qml/qml_poi.cpp | 3 | ||||
-rw-r--r-- | navit/gui/qt5_qml/qml_vehicle.cpp | 52 | ||||
-rw-r--r-- | navit/gui/qt5_qml/qml_vehicle.h | 40 | ||||
-rw-r--r-- | navit/gui/qt5_qml/skins/modern/bookmark.qml | 104 | ||||
-rw-r--r-- | navit/gui/qt5_qml/skins/modern/bookmarks.qml | 108 | ||||
-rw-r--r-- | navit/gui/qt5_qml/skins/modern/destination.qml | 3 | ||||
-rw-r--r-- | navit/gui/qt5_qml/skins/modern/main.qml | 44 | ||||
-rw-r--r-- | navit/gui/qt5_qml/skins/modern/poi.qml | 3 | ||||
-rw-r--r-- | navit/gui/qt5_qml/skins/modern/search.qml | 47 | ||||
-rw-r--r-- | navit/gui/qt5_qml/skins/modern/search_result_item.qml | 43 | ||||
-rw-r--r-- | navit/gui/qt5_qml/skins/modern/settings.qml | 3 | ||||
-rw-r--r-- | navit/gui/qt5_qml/skins/modern/vehicle.qml | 11 | ||||
-rw-r--r-- | navit/gui/qt5_qml/skins/modern/vehicles.qml | 46 |
20 files changed, 697 insertions, 89 deletions
diff --git a/navit/gui/qt5_qml/CMakeLists.txt b/navit/gui/qt5_qml/CMakeLists.txt index 052a112f4..770c9a2f0 100644 --- a/navit/gui/qt5_qml/CMakeLists.txt +++ b/navit/gui/qt5_qml/CMakeLists.txt @@ -5,4 +5,5 @@ set(CMAKE_AUTOMOC ON) qt5_add_resources(GUI_QT5_QML_QRC "gui_qt5_qml.qrc") -module_add_library(gui_qt5_qml gui_qt5_qml.cpp ${GUI_QT5_QML_QRC} backend.cpp qml_map.cpp qml_poi.cpp qml_search.cpp proxy.c)
\ No newline at end of file +module_add_library(gui_qt5_qml gui_qt5_qml.cpp ${GUI_QT5_QML_QRC} backend.cpp + qml_map.cpp qml_poi.cpp qml_vehicle.cpp qml_bookmark.cpp qml_search.cpp proxy.c) diff --git a/navit/gui/qt5_qml/backend.cpp b/navit/gui/qt5_qml/backend.cpp index ac1eb21a5..395fff425 100644 --- a/navit/gui/qt5_qml/backend.cpp +++ b/navit/gui/qt5_qml/backend.cpp @@ -7,6 +7,8 @@ #include "layout.h" #include "map.h" #include "transform.h" +#include "vehicle.h" +#include "bookmarks.h" #include "backend.h" #include "qml_map.h" @@ -25,6 +27,10 @@ extern "C" { Backend::Backend(QObject * parent):QObject(parent) { + set_default_country(); + this->search = NULL; + _current_town = NULL; + _current_street = NULL; } /** @@ -91,6 +97,48 @@ void Backend::get_maps() emit mapsChanged(); } + +/** + * @brief update the private m_vehicles list. Expected to be called from QML + * @param none + * @returns nothing + */ +void Backend::get_vehicles() +{ + struct attr attr,attr2,vattr; + struct attr_iter *iter; + struct attr active_vehicle; + _vehicles.clear(); + + iter=navit_attr_iter_new(); + if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) { + vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL); + navit_attr_iter_destroy(iter); + _vehicles.append(new VehicleObject(g_strdup(vattr.u.str), active_vehicle.u.vehicle, attr.u.vehicle)); + dbg(lvl_debug, "done\n"); + emit vehiclesChanged(); + return; + } + navit_attr_iter_destroy(iter); + + if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL)) + active_vehicle.u.vehicle=NULL; + iter=navit_attr_iter_new(); + while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) { + vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL); + dbg(lvl_debug, "adding vehicle %s\n", vattr.u.str); + _vehicles.append( + new VehicleObject( + g_strdup(vattr.u.str), + attr.u.vehicle == active_vehicle.u.vehicle, + attr.u.vehicle + ) + ); + } + navit_attr_iter_destroy(iter); + emit vehiclesChanged(); +} + /** * @brief set a pointer to the struct navit * for local use * @param none @@ -126,6 +174,39 @@ int Backend::filter_pois(struct item *item) } /** + * @brief update the private m_bookmarks list. Expected to be called from QML + * @param none + * @returns nothing + */ +void Backend::get_bookmarks() +{ + struct attr attr,mattr; + struct navigation * nav = NULL; + struct item *item; + struct coord c; + struct pcoord pc; + + _bookmarks.clear(); + + pc.pro = transform_get_projection(navit_get_trans(this->nav)); + + if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) { + bookmarks_item_rewind(mattr.u.bookmarks); + while ((item=bookmarks_get_item(mattr.u.bookmarks))) { + if (!item_attr_get(item, attr_label, &attr)) continue; + dbg(lvl_debug,"full_label: %s\n", attr.u.str); + if (item_coord_get(item, &c, 1)) { + pc.x = c.x; + pc.y = c.y; + dbg(lvl_debug, "coords : %i x %i\n", pc.x, pc.y); + _bookmarks.append(new BookmarkObject(attr.u.str, pc)); + } + } + } + emit bookmarksChanged(); +} + +/** * @brief update the private m_pois list. Expected to be called from QML * @param none * @returns nothing @@ -196,6 +277,15 @@ QQmlListProperty<QObject> Backend::getPois(){ } /** + * @brief get the Bookmarks as a QList + * @param none + * @returns the bookmarks QList + */ +QQmlListProperty<QObject> Backend::getBookmarks(){ + return QQmlListProperty<QObject>(this, _bookmarks); +} + +/** * @brief get the maps as a QList * @param none * @returns the maps QList @@ -204,6 +294,16 @@ QQmlListProperty<QObject> Backend::getMaps(){ return QQmlListProperty<QObject>(this, _maps); } + +/** + * @brief get the vehicles as a QList + * @param none + * @returns the vehicles QList + */ +QQmlListProperty<QObject> Backend::getVehicles(){ + return QQmlListProperty<QObject>(this, _vehicles); +} + /** * @brief get the search results as a QList * @param none @@ -224,6 +324,34 @@ PoiObject * Backend::activePoi() { return m_activePoi; } +/** + * @brief get the current bookmark. Used when displaying the relevant menu + * @param none + * @returns the current bookmark + */ +BookmarkObject * Backend::currentBookmark() { + return m_currentBookmark; +} + +/** + * @brief get the currently selected vehicle. Used when displaying the relevant menu + * @param none + * @returns the active POI + */ +VehicleObject * Backend::currentVehicle() { + struct attr attr; + dbg(lvl_debug, "name : %s\n", m_currentVehicle->name().toUtf8().data()); + if (m_currentVehicle->vehicle()) { + if (vehicle_get_attr(m_currentVehicle->vehicle(), attr_position_nmea, &attr, NULL)) + dbg(lvl_debug, "NMEA : %s\n", attr.u.str); + } else { + dbg(lvl_debug, "m_currentVehicle->v is null\n"); + } + + return m_currentVehicle; +} + + void Backend::block_draw(){ navit_block(this->nav, 1); dbg(lvl_debug, "Draw operations blocked per UI request\n"); @@ -256,11 +384,34 @@ void Backend::setActivePoi(int index) { navit_set_center(this->nav, &c, 1); emit activePoiChanged(); } +/** + * @brief set the current bookmark. Used when clicking on a bookmark list to display one single bookmark + * @param int index the index of the bookmark in the m_bookmarks list + * @returns nothing + */ +void Backend::setCurrentBookmark(int index) { + struct pcoord c; + m_currentBookmark = (BookmarkObject *)_bookmarks.at(index); + c = m_currentBookmark->coords(); + resize(320, 240); + navit_set_center(this->nav, &c, 1); + emit currentBookmarkChanged(); +} + +/** + * @brief set the current vehicle. Used when clicking on a vehicle list to display one single vehicle + * @param int index the index of the vehicle in the m_vehicles list + * @returns nothing + */ +void Backend::setCurrentVehicle(int index) { + m_currentVehicle = (VehicleObject *)_vehicles.at(index); + emit currentVehicleChanged(); +} /** - * @brief returns the icon (icons) absolute path + * @brief returns the icon absolute path * @param none - * @returns the icon (icons) absolute path as a QString + * @returns the icon absolute path as a QString */ QString Backend::get_icon_path(){ return QString(g_strjoin(NULL,"file://",getenv("NAVIT_SHAREDIR"),"/icons/",NULL)); @@ -288,9 +439,10 @@ void Backend::setActivePoiAsDestination(){ */ void Backend::searchValidateResult(int index){ SearchObject * r = (SearchObject *)_search_results.at(index); - dbg(lvl_debug, "Saving %s [%i] %x %x\n", - r->name().toUtf8().data(), - index, r->getCoords()->x, r->getCoords()->y); + dbg(lvl_debug, "Saving %s [%i] as search result\n", r->name().toUtf8().data(), index); + if (r->getCoords()){ + dbg(lvl_debug, "Item is at %x x %x\n", r->getCoords()->x, r->getCoords()->y); + } if (_search_context == attr_country_all) { _current_country = g_strdup(r->name().toUtf8().data()); _current_town = NULL; @@ -357,9 +509,6 @@ void Backend::updateSearch(QString text){ search->ms=navit_get_mapset(this->nav); search->sl=search_list_new(search->ms); search->partial = 1; - if ( _country_iso2 == NULL ){ - set_default_country(); - } dbg(lvl_debug,"attempting to use country '%s'\n", _country_iso2); search_attr.type=attr_country_iso2; search_attr.u.str=_country_iso2; @@ -389,7 +538,6 @@ void Backend::updateSearch(QString text){ if ( _search_context == attr_country_all && res->country) { char * label; label = g_strdup(res->country->name); - dbg(lvl_debug, "country result %s\n", label); _search_results.append( new SearchObject(label, get_country_icon(res->country->flag) , res->c) ); @@ -397,7 +545,6 @@ void Backend::updateSearch(QString text){ if ( _search_context == attr_town_name && res->town) { char * label; label = g_strdup(res->town->common.town_name); - dbg(lvl_debug, "town result %s\n", label); _search_results.append( new SearchObject(label, "icons/bigcity.png", res->c) ); @@ -405,7 +552,6 @@ void Backend::updateSearch(QString text){ if (res->street) { char * label; label = g_strdup(res->street->name); - dbg(lvl_debug, "street result %s\n", label); _search_results.append( new SearchObject(label, "icons/smallcity.png", res->c) ); @@ -431,17 +577,11 @@ void Backend::setSearchContext(QString text){ } QString Backend::currentCountry() { - if (_current_country == NULL) { - set_default_country(); - } dbg(lvl_debug, "Current country : %s/%s\n", _country_iso2, _current_country); return QString(_current_country); } QString Backend::currentCountryIso2() { - if (_country_iso2 == NULL) { - set_default_country(); - } dbg(lvl_debug, "Current country : %s/%s\n", _country_iso2, _current_country); return QString(_country_iso2); } diff --git a/navit/gui/qt5_qml/backend.h b/navit/gui/qt5_qml/backend.h index a164918e6..259be516c 100644 --- a/navit/gui/qt5_qml/backend.h +++ b/navit/gui/qt5_qml/backend.h @@ -2,12 +2,13 @@ #define BACKEND_H #include <QObject> -#include <QDebug> #include <QQmlApplicationEngine> #include <QQmlListProperty> #include "qml_map.h" #include "qml_poi.h" +#include "qml_bookmark.h" +#include "qml_vehicle.h" #include "coord.h" #include "item.h" @@ -17,8 +18,12 @@ class Backend : public QObject { Q_OBJECT Q_PROPERTY(QQmlListProperty<QObject> pois READ getPois NOTIFY poisChanged) + Q_PROPERTY(QQmlListProperty<QObject> bookmarks READ getBookmarks NOTIFY bookmarksChanged) Q_PROPERTY(QQmlListProperty<QObject> maps READ getMaps NOTIFY mapsChanged) + Q_PROPERTY(QQmlListProperty<QObject> vehicles READ getVehicles NOTIFY vehiclesChanged) Q_PROPERTY(PoiObject * activePoi READ activePoi NOTIFY activePoiChanged) + Q_PROPERTY(BookmarkObject * currentBookmark READ currentBookmark NOTIFY currentBookmarkChanged) + Q_PROPERTY(VehicleObject * currentVehicle READ currentVehicle NOTIFY currentVehicleChanged) Q_PROPERTY(QQmlListProperty<QObject> searchresults READ getSearchResults NOTIFY searchResultsChanged) // Search properties Q_PROPERTY(QString currentCountry READ currentCountry NOTIFY currentCountryChanged) @@ -35,9 +40,15 @@ public: QList < PoiObject * > pois; QQmlListProperty<QObject> getPois(); + QList < BookmarkObject * > bookmarks; + QQmlListProperty<QObject> getBookmarks(); QList < MapObject * > maps; QQmlListProperty<QObject> getMaps(); + QList < MapObject * > vehicles; + QQmlListProperty<QObject> getVehicles(); PoiObject * activePoi(); + BookmarkObject * currentBookmark(); + VehicleObject * currentVehicle(); QQmlListProperty<QObject> getSearchResults(); QString currentCountry(); QString currentCountryIso2(); @@ -48,8 +59,12 @@ signals: void displayMenu(QString source); void hideMenu(); void poisChanged(); + void bookmarksChanged(); void activePoiChanged(); + void currentBookmarkChanged(); + void currentVehicleChanged(); void mapsChanged(); + void vehiclesChanged(); void searchResultsChanged(); void currentCountryChanged(); void currentCountryIso2Changed(); @@ -59,9 +74,13 @@ signals: public slots: void get_maps(); void get_pois(); + void get_bookmarks(); + void get_vehicles(); QString get_icon_path(); QString get_country_icon(char * country_iso_code); void setActivePoi(int index); + void setCurrentBookmark(int index); + void setCurrentVehicle(int index); void setActivePoiAsDestination(); void updateSearch(QString text); void searchValidateResult(int index); @@ -77,8 +96,12 @@ private: int filter_pois(struct item *item); QQmlApplicationEngine* engine; QList<QObject *> _pois; + QList<QObject *> _bookmarks; QList<QObject *> _maps; + QList<QObject *> _vehicles; PoiObject * m_activePoi; + BookmarkObject * m_currentBookmark; + VehicleObject * m_currentVehicle; QList<QObject *> _search_results; void set_default_country(); char * _country_iso2; diff --git a/navit/gui/qt5_qml/editor/qml.qrc b/navit/gui/qt5_qml/editor/qml.qrc index 61cd75d03..a1db879a2 100644 --- a/navit/gui/qt5_qml/editor/qml.qrc +++ b/navit/gui/qt5_qml/editor/qml.qrc @@ -8,7 +8,10 @@ <file>skins/modern/MainButton.qml</file> <file>skins/modern/settings.qml</file> <file>skins/modern/maps.qml</file> + <file>skins/modern/poi.qml</file> <file>skins/modern/pois.qml</file> + <file>skins/modern/bookmark.qml</file> + <file>skins/modern/bookmarks.qml</file> <file>skins/modern/icons/appbar.home.variant.svg</file> <file>skins/modern/icons/appbar.rocket.svg</file> <file>skins/modern/icons/appbar.power.svg</file> @@ -24,7 +27,6 @@ <file>skins/modern/icons/appbar.location.checkin.svg</file> <file>skins/modern/icons/appbar.cogs.svg</file> <file>skins/modern/icons/bigcity.png</file> - <file>skins/modern/poi.qml</file> <file>skins/modern/search.qml</file> <file>skins/modern/destination.qml</file> <file>skins/modern/icons/appbar.city.svg</file> @@ -33,5 +35,8 @@ <file>skins/modern/icons/appbar.book.list.svg</file> <file>skins/modern/icons/smallcity.png</file> <file>skins/modern/destination_address.qml</file> + <file>skins/modern/search_result_item.qml</file> + <file>skins/modern/vehicles.qml</file> + <file>skins/modern/vehicle.qml</file> </qresource> </RCC> diff --git a/navit/gui/qt5_qml/gui_qt5_qml.qrc b/navit/gui/qt5_qml/gui_qt5_qml.qrc index 61cd75d03..a1db879a2 100644 --- a/navit/gui/qt5_qml/gui_qt5_qml.qrc +++ b/navit/gui/qt5_qml/gui_qt5_qml.qrc @@ -8,7 +8,10 @@ <file>skins/modern/MainButton.qml</file> <file>skins/modern/settings.qml</file> <file>skins/modern/maps.qml</file> + <file>skins/modern/poi.qml</file> <file>skins/modern/pois.qml</file> + <file>skins/modern/bookmark.qml</file> + <file>skins/modern/bookmarks.qml</file> <file>skins/modern/icons/appbar.home.variant.svg</file> <file>skins/modern/icons/appbar.rocket.svg</file> <file>skins/modern/icons/appbar.power.svg</file> @@ -24,7 +27,6 @@ <file>skins/modern/icons/appbar.location.checkin.svg</file> <file>skins/modern/icons/appbar.cogs.svg</file> <file>skins/modern/icons/bigcity.png</file> - <file>skins/modern/poi.qml</file> <file>skins/modern/search.qml</file> <file>skins/modern/destination.qml</file> <file>skins/modern/icons/appbar.city.svg</file> @@ -33,5 +35,8 @@ <file>skins/modern/icons/appbar.book.list.svg</file> <file>skins/modern/icons/smallcity.png</file> <file>skins/modern/destination_address.qml</file> + <file>skins/modern/search_result_item.qml</file> + <file>skins/modern/vehicles.qml</file> + <file>skins/modern/vehicle.qml</file> </qresource> </RCC> diff --git a/navit/gui/qt5_qml/qml_bookmark.cpp b/navit/gui/qt5_qml/qml_bookmark.cpp new file mode 100644 index 000000000..e215bcd11 --- /dev/null +++ b/navit/gui/qt5_qml/qml_bookmark.cpp @@ -0,0 +1,32 @@ +#include "qml_bookmark.h" + +BookmarkObject::BookmarkObject(QObject *parent) + : QObject(parent) +{ +} + +BookmarkObject::BookmarkObject( + const QString &name, + struct pcoord &coords, + QObject *parent) + : QObject(parent), m_name(name), m_coords(coords) +{ +} + +QString BookmarkObject::name() const +{ + return m_name; +} + +void BookmarkObject::setName(const QString &name) +{ + if (name != m_name) { + m_name = name; + emit nameChanged(); + } +} + +struct pcoord BookmarkObject::coords() const +{ + return m_coords; +} diff --git a/navit/gui/qt5_qml/qml_bookmark.h b/navit/gui/qt5_qml/qml_bookmark.h new file mode 100644 index 000000000..fa676582e --- /dev/null +++ b/navit/gui/qt5_qml/qml_bookmark.h @@ -0,0 +1,31 @@ +#ifndef BOOKMARKOBJECT_H +#define BOOKMARKOBJECT_H + +#include <QObject> +#include "coord.h" + +class BookmarkObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(struct pcoord coords NOTIFY coordsChanged) + +public: + BookmarkObject(QObject *parent=0); + BookmarkObject(const QString &name, struct pcoord &coords, QObject *parent=0); + QString name() const; + void setName(const QString &name); + + struct pcoord coords() const; + +signals: + void nameChanged(); + +private: + struct pcoord m_coords; + QString m_name; +}; + +#endif // BOOKMARKOBJECT_H + diff --git a/navit/gui/qt5_qml/qml_poi.cpp b/navit/gui/qt5_qml/qml_poi.cpp index 6a4c16884..93adf2925 100644 --- a/navit/gui/qt5_qml/qml_poi.cpp +++ b/navit/gui/qt5_qml/qml_poi.cpp @@ -1,4 +1,3 @@ -#include <QDebug> #include "qml_poi.h" PoiObject::PoiObject(QObject *parent) @@ -72,4 +71,4 @@ QString PoiObject::icon() const struct pcoord PoiObject::coords() const { return m_coords; -}
\ No newline at end of file +} diff --git a/navit/gui/qt5_qml/qml_vehicle.cpp b/navit/gui/qt5_qml/qml_vehicle.cpp new file mode 100644 index 000000000..bf79ad4c4 --- /dev/null +++ b/navit/gui/qt5_qml/qml_vehicle.cpp @@ -0,0 +1,52 @@ +#include "qml_vehicle.h" + +VehicleObject::VehicleObject(QObject *parent) + : QObject(parent) +{ +} + +VehicleObject::VehicleObject(const QString &name, const bool &active, struct vehicle *v, QObject *parent) + : QObject(parent), m_name(name), m_active(active), m_vehicle(v) +{ +} + +QString VehicleObject::name() const +{ + return m_name; +} + +void VehicleObject::setName(const QString &name) +{ + if (name != m_name) { + m_name = name; + emit nameChanged(); + } +} + +bool VehicleObject::active() const +{ + return m_active; +} + +void VehicleObject::setActive(const bool &active) +{ + if (active != m_active) { + m_active = active; + emit activeChanged(); + } +} + +struct vehicle * VehicleObject::vehicle() const +{ + return m_vehicle; +} + +void VehicleObject::setVehicle(struct vehicle * vehicle) +{ + if (vehicle != m_vehicle) { + m_vehicle = vehicle; + emit vehicleChanged(); + } +} + + diff --git a/navit/gui/qt5_qml/qml_vehicle.h b/navit/gui/qt5_qml/qml_vehicle.h new file mode 100644 index 000000000..84bb42160 --- /dev/null +++ b/navit/gui/qt5_qml/qml_vehicle.h @@ -0,0 +1,40 @@ +#ifndef VEHICLEOBJECT_H +#define VEHICLEOBJECT_H + +#include <QObject> +#include "item.h" +#include "vehicle.h" + +class VehicleObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) + //Q_PROPERTY(struct vehicle * vehicle READ vehicle WRITE setVehicle NOTIFY vehicleChanged) + +public: + VehicleObject(QObject *parent=0); + VehicleObject(const QString &name, const bool &active, struct vehicle *v, QObject *parent=0); + + QString name() const; + void setName(const QString &name); + + bool active() const; + void setActive(const bool &active); + + struct vehicle * vehicle() const; + void setVehicle(struct vehicle * vehicle); + +signals: + void nameChanged(); + void activeChanged(); + void vehicleChanged(); + +private: + QString m_name; + bool m_active; + struct vehicle *m_vehicle; +}; + +#endif // MAPOBJECT_H diff --git a/navit/gui/qt5_qml/skins/modern/bookmark.qml b/navit/gui/qt5_qml/skins/modern/bookmark.qml new file mode 100644 index 000000000..66261576c --- /dev/null +++ b/navit/gui/qt5_qml/skins/modern/bookmark.qml @@ -0,0 +1,104 @@ +import QtQuick 2.0 +import QtQuick.Layouts 1.0 +import com.navit.graphics_qt5 1.0 + + +Item { + id: bookmarkItem + visible: true + property var small_font_size : 16 + + + Text { + x: 8 + y: 8 + color: "#ffffff" + text: backend.currentBookmark.name + font.pixelSize: 32 + } + + Text { + x: 80 + y: 64 + color: "#ffffff" + text: qsTr("Type") + font.pixelSize: small_font_size + } + + Text { + x: 80 + y: 96 + color: "#ffffff" + text: qsTr("Distance") + font.pixelSize: small_font_size + } + + Text { + x: 160 + y: 64 + color: "#ffffff" + text: backend.currentBookmark.type + font.pixelSize: small_font_size + } + + Text { + x: 160 + y: 96 + color: "#ffffff" + text: backend.currentBookmark.distance + font.pixelSize: small_font_size + } + + Rectangle { + id: rectangle + x: 8 + y: 64 + height: 64 + width: height + color: "#ffffff" + radius: 8 + border.width: 1 + Image { + height: parent.width + width: parent.height + source : backend.get_icon_path() + backend.currentBookmark.icon + sourceSize.width: parent.width + sourceSize.height: parent.height + } + } + + ColumnLayout { + id: columnLayout + width: parent.width/2 + height: parent.height + anchors.right: parent.right + anchors.rightMargin: 0 + QNavitQuick { + id: navit1 + width: 300 + height: 240 + Component.onCompleted: { + navit1.setGraphicContext(graphics_qt5_context) + } + Component.onDestruction: { + console.log("Destroying a navit widget. Blocking draw operations") + backend.block_draw() + } + } + } + + MainButton { + id: mainButton3 + x: 8 + y: parent.height-78 + width: parent.width/2 - 16 + height: 64 + radius: 1 + text: "Set as destination" + icon: "icons/appbar.location.checkin.svg" + onClicked: { + backend.setCurrentBookmarkAsDestination() + } + } + +} diff --git a/navit/gui/qt5_qml/skins/modern/bookmarks.qml b/navit/gui/qt5_qml/skins/modern/bookmarks.qml new file mode 100644 index 000000000..b8e644081 --- /dev/null +++ b/navit/gui/qt5_qml/skins/modern/bookmarks.qml @@ -0,0 +1,108 @@ +import QtQuick 2.0 + +Item { + id: bookmarklist + ListView { + anchors.fill: parent + id: listView + model: backend.bookmarks + delegate: Item { + height: 64 + width: parent.width; + Rectangle { + color: "#1e1b18" + height: parent.height; + width: parent.width; + border.width: 1 + + Text { + text: name + color: "#ffffff" + anchors.verticalCenter: parent.verticalCenter + anchors.left: distanceText.right + anchors.leftMargin: 8 + } + + MouseArea { + id: mouse_area1 + z: 1 + hoverEnabled: false + anchors.fill: parent + + onClicked:{ + listView.currentIndex = index + backend.setCurrentBookmark(index); + menucontent.source = "bookmark.qml" + } + } + } + + } + + Component.onCompleted: backend.get_bookmarks() + } + + Rectangle { + height: 64 + width: height + + x: parent.width - width + y: parent.height - height * 2 + + color: "#35322f" + + Image { + anchors.centerIn: parent + source: "icons/appbar.chevron.up.svg" + } + + MouseArea { + anchors.fill: parent + id: listUp + + SmoothedAnimation { + target: listView + property: "contentY" + running: listUp.pressed + velocity: 1000 + to: 0 + } + onReleased: { + if (!listView.atYBeginning) + listView.flick(0, 1000) + } + } + } + + Rectangle { + height: 64 + width: height + + x: parent.width - width + y: parent.height - height + + color: "#35322f" + + Image { + anchors.centerIn: parent + source: "icons/appbar.chevron.down.svg" + } + + MouseArea { + anchors.fill: parent + id: listDown + + SmoothedAnimation { + target: listView + property: "contentY" + running: listDown.pressed + to: listView.contentHeight - listView.height + velocity: 1000 + } + onReleased: { + if (!listView.atYEnd) + listView.flick(0, -1000) + } + } + } +} diff --git a/navit/gui/qt5_qml/skins/modern/destination.qml b/navit/gui/qt5_qml/skins/modern/destination.qml index affd65026..00e1f5579 100644 --- a/navit/gui/qt5_qml/skins/modern/destination.qml +++ b/navit/gui/qt5_qml/skins/modern/destination.qml @@ -30,6 +30,9 @@ GridLayout { Layout.fillHeight: true Layout.fillWidth: true icon: "icons/appbar.location.svg" + onClicked: { + menucontent.source = "bookmarks.qml" + } } MainButton { diff --git a/navit/gui/qt5_qml/skins/modern/main.qml b/navit/gui/qt5_qml/skins/modern/main.qml index 0654e68d3..3c35a4dd0 100644 --- a/navit/gui/qt5_qml/skins/modern/main.qml +++ b/navit/gui/qt5_qml/skins/modern/main.qml @@ -2,29 +2,27 @@ import com.navit.graphics_qt5 1.0 import QtQuick 2.2 Rectangle { - width: 800 - height: 480 + width: 800 + height: 480 Connections { target: backend - onHideMenu: { - hideMainMenu() - } + onHideMenu: { + hideMainMenu() + } onDisplayMenu: { - mainMenu.submenu = source + mainMenu.submenu = source mainMenu.state = 'visible' - console.log("showing menu with submenu " + mainMenu.submenu) - mainMenu.source = '' // Needed when switching submenus from the code to refresh the menu - mainMenu.source = "menu.qml" - } + console.log("showing menu with submenu " + mainMenu.submenu) + mainMenu.source = '' // Needed when switching submenus from the code to refresh the menu + mainMenu.source = "menu.qml" + } } - function hideMainMenu(){ - mainMenu.source = '' - mainMenu.state = 'default' - backend.resize(navit1.width, navit1.height); - console.log("hiding menu window size " + navit1.width + " x " + navit1.height) - } + function hideMainMenu(){ + mainMenu.source = '' + mainMenu.state = 'default' + } color: "black" id: container @@ -33,10 +31,10 @@ Rectangle { id: navit1 width: parent.width height: parent.height - // focus: true + // focus: true opacity: 0; Component.onCompleted: { - console.log(width + "x" + height) + console.log(width + "x" + height) navit1.setGraphicContext(graphics_qt5_context); navit1.opacity = 1; } @@ -52,8 +50,8 @@ Rectangle { width: parent.width height: parent.height x: parent.width - opacity: 0 - property string submenu + opacity: 0 + property string submenu states: [ State { @@ -70,6 +68,12 @@ Rectangle { NumberAnimation { properties: "x,y,opacity";duration: 200 } + onRunningChanged: { + if ((mainMenu.opacity == 0) && (!running)){ + backend.resize(navit1.width, navit1.height); + console.log("transition done, hiding menu window size " + navit1.width + " x " + navit1.height) + } + } } ] } diff --git a/navit/gui/qt5_qml/skins/modern/poi.qml b/navit/gui/qt5_qml/skins/modern/poi.qml index 8501f517e..36168ecfe 100644 --- a/navit/gui/qt5_qml/skins/modern/poi.qml +++ b/navit/gui/qt5_qml/skins/modern/poi.qml @@ -99,9 +99,6 @@ Item { onClicked: { backend.setActivePoiAsDestination() } - } - - } diff --git a/navit/gui/qt5_qml/skins/modern/search.qml b/navit/gui/qt5_qml/skins/modern/search.qml index 510d18b75..cc420b87e 100644 --- a/navit/gui/qt5_qml/skins/modern/search.qml +++ b/navit/gui/qt5_qml/skins/modern/search.qml @@ -1,59 +1,20 @@ import QtQuick 2.0 Item { - Item { + Rectangle { x : 16 y : 64 width: parent.width-32 height: parent.height-64 id: searchResults + color: "#35322f" + ListView { anchors.fill: parent id: listView model: backend.searchresults - delegate: Item { - height: 64 - width: parent.width; - Rectangle { - color: "#1e1b18" - height: parent.height; - width: parent.width; - border.width: 1 - - Image { - id: image1 - height: 36; - width: 64 - source : icon - fillMode: Image.PreserveAspectFit - // sourceSize.width: parent.width - // sourceSize.height: parent.height - } - - Text { - text: name - color: "#ffffff" - anchors.verticalCenter: parent.verticalCenter - anchors.left: image1.right - anchors.leftMargin: 8 - } - - MouseArea { - id: mouse_area1 - z: 1 - hoverEnabled: false - anchors.fill: parent - - onClicked:{ - listView.currentIndex = index - backend.searchValidateResult(index) -// backend.setActivePoi(index); - // menucontent.source = "poi.qml" - } - } - } + delegate: Loader { source: "search_result_item.qml"} - } Component.onCompleted: { backend.updateSearch("") } diff --git a/navit/gui/qt5_qml/skins/modern/search_result_item.qml b/navit/gui/qt5_qml/skins/modern/search_result_item.qml new file mode 100644 index 000000000..6ba4bb283 --- /dev/null +++ b/navit/gui/qt5_qml/skins/modern/search_result_item.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 + + +Item { + height: 64 + width: searchResults.width; + Rectangle { + color: "#1e1b18" + height: parent.height; + width: parent.width; + + Image { + id: image1 + height: 36; + width: 64 + source : icon + fillMode: Image.PreserveAspectFit + } + + Text { + text: name + color: "#ffffff" + anchors.verticalCenter: parent.verticalCenter + anchors.left: image1.right + anchors.leftMargin: 8 + } + + MouseArea { + id: mouse_area1 + z: 1 + hoverEnabled: false + anchors.fill: parent + + onClicked:{ + listView.currentIndex = index + backend.searchValidateResult(index) + // backend.setActivePoi(index); + // menucontent.source = "poi.qml" + } + } + } +} + diff --git a/navit/gui/qt5_qml/skins/modern/settings.qml b/navit/gui/qt5_qml/skins/modern/settings.qml index d2a50d764..de7dc36f5 100644 --- a/navit/gui/qt5_qml/skins/modern/settings.qml +++ b/navit/gui/qt5_qml/skins/modern/settings.qml @@ -24,6 +24,9 @@ GridLayout { icon: "icons/appbar.transit.car.svg" Layout.fillHeight: true Layout.fillWidth: true + onClicked: { + menucontent.source = "vehicles.qml" + } } MainButton { text: "Display" diff --git a/navit/gui/qt5_qml/skins/modern/vehicle.qml b/navit/gui/qt5_qml/skins/modern/vehicle.qml new file mode 100644 index 000000000..de425cec8 --- /dev/null +++ b/navit/gui/qt5_qml/skins/modern/vehicle.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + Text { + x: 8 + y: 8 + color: "#ffffff" + text: backend.currentVehicle.name + font.pixelSize: 32 + } +} diff --git a/navit/gui/qt5_qml/skins/modern/vehicles.qml b/navit/gui/qt5_qml/skins/modern/vehicles.qml new file mode 100644 index 000000000..b96458b57 --- /dev/null +++ b/navit/gui/qt5_qml/skins/modern/vehicles.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 + +ListView { + id: list + model: backend.vehicles + delegate: Item { + height: 64 + width: parent.width; + Rectangle { + color: "#1e1b18" + height: parent.height; + width: parent.width; + border.width: 1 + + Image { + id: image1 + height: parent.height - 4; + source : "icons/appbar.transit.car.svg" + opacity: active ? 1 : 0.1 + } + + Text { + text: name + color: "#ffffff" + anchors.verticalCenter: parent.verticalCenter + anchors.left: image1.right + anchors.leftMargin: 8 + } + + MouseArea { + id: mouse_area1 + z: 1 + hoverEnabled: false + anchors.fill: parent + + onClicked:{ + list.currentIndex = index + backend.setCurrentVehicle(index); + menucontent.source = "vehicle.qml" + } + } + } + } + + Component.onCompleted: backend.get_vehicles() +} |