Skip to content

Commit

Permalink
Merge pull request #1600 from janbar/qt6_navigation_voice
Browse files Browse the repository at this point in the history
Navigation Voice for Qt6 and Qt5
  • Loading branch information
Framstag authored Sep 14, 2024
2 parents b354d8d + e78b667 commit 286e56f
Show file tree
Hide file tree
Showing 12 changed files with 493 additions and 110 deletions.
59 changes: 31 additions & 28 deletions libosmscout-client-qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ set(HEADER_FILES
include/osmscoutclientqt/InstalledMapsModel.h
include/osmscoutclientqt/Voice.h
include/osmscoutclientqt/VoiceManager.h
include/osmscoutclientqt/VoicePlayer.h
include/osmscoutclientqt/VoiceCorePlayerImpl.h
include/osmscoutclientqt/AvailableVoicesModel.h
include/osmscoutclientqt/InstalledVoicesModel.h
)
Expand Down Expand Up @@ -109,32 +111,33 @@ set(SOURCE_FILES
src/osmscoutclientqt/InstalledMapsModel.cpp
src/osmscoutclientqt/Voice.cpp
src/osmscoutclientqt/VoiceManager.cpp
src/osmscoutclientqt/VoicePlayer.cpp
src/osmscoutclientqt/AvailableVoicesModel.cpp
src/osmscoutclientqt/InstalledVoicesModel.cpp
)

if (QT_VERSION_MAJOR EQUAL 6)
osmscout_library_project(
NAME OSMScoutClientQt
ALIAS ClientQt
OUTPUT_NAME "osmscout_client_qt"
SOURCE ${SOURCE_FILES}
HEADER ${HEADER_FILES}
INCLUDEDIR osmscoutclientqt
TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/include/osmscoutclientqt/ClientQtFeatures.h.cmake
TARGET OSMScout::OSMScout OSMScout::Map OSMScout::MapQt Qt::Core Qt6::Core5Compat Qt::Gui Qt::Quick Qt::Multimedia OSMScout::Client
)
osmscout_library_project(
NAME OSMScoutClientQt
ALIAS ClientQt
OUTPUT_NAME "osmscout_client_qt"
SOURCE ${SOURCE_FILES}
HEADER ${HEADER_FILES}
INCLUDEDIR osmscoutclientqt
TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/include/osmscoutclientqt/ClientQtFeatures.h.cmake
TARGET OSMScout::OSMScout OSMScout::Map OSMScout::MapQt Qt::Core Qt6::Core5Compat Qt::Gui Qt::Quick Qt::Multimedia OSMScout::Client
)
else ()
osmscout_library_project(
NAME OSMScoutClientQt
ALIAS ClientQt
OUTPUT_NAME "osmscout_client_qt"
SOURCE ${SOURCE_FILES}
HEADER ${HEADER_FILES}
INCLUDEDIR osmscoutclientqt
TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/include/osmscoutclientqt/ClientQtFeatures.h.cmake
TARGET OSMScout::OSMScout OSMScout::Map OSMScout::MapQt Qt::Core Qt::Gui Qt::Quick Qt::Multimedia OSMScout::Client
)
osmscout_library_project(
NAME OSMScoutClientQt
ALIAS ClientQt
OUTPUT_NAME "osmscout_client_qt"
SOURCE ${SOURCE_FILES}
HEADER ${HEADER_FILES}
INCLUDEDIR osmscoutclientqt
TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/include/osmscoutclientqt/ClientQtFeatures.h.cmake
TARGET OSMScout::OSMScout OSMScout::Map OSMScout::MapQt Qt::Core Qt::Gui Qt::Quick Qt::Multimedia OSMScout::Client
)
endif ()

if(MARISA_FOUND)
Expand All @@ -143,12 +146,12 @@ if(MARISA_FOUND)
endif()

if(APPLE AND OSMSCOUT_BUILD_FRAMEWORKS)
set_target_properties(OSMScoutClientQt PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION C
MACOSX_FRAMEWORK_IDENTIFIER com.cmake.dynamicFramework
#MACOSX_FRAMEWORK_INFO_PLIST Info.plist
PUBLIC_HEADER "${HEADER_FILES}"
CODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
OUTPUT_NAME "OSMScoutClientQt")
set_target_properties(OSMScoutClientQt PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION C
MACOSX_FRAMEWORK_IDENTIFIER com.cmake.dynamicFramework
#MACOSX_FRAMEWORK_INFO_PLIST Info.plist
PUBLIC_HEADER "${HEADER_FILES}"
CODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
OUTPUT_NAME "OSMScoutClientQt")
endif()
2 changes: 2 additions & 0 deletions libosmscout-client-qt/include/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ osmscoutclientqtHeader = [
'osmscoutclientqt/InstalledMapsModel.h',
'osmscoutclientqt/Voice.h',
'osmscoutclientqt/VoiceManager.h',
'osmscoutclientqt/VoicePlayer.h',
'osmscoutclientqt/VoiceCorePlayerImpl.h',
'osmscoutclientqt/AvailableVoicesModel.h',
'osmscoutclientqt/InstalledVoicesModel.h',
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@

#include <QAbstractListModel>
#include <QList>
#include <QMediaPlayer>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QMediaPlaylist>
#endif

namespace osmscout {

class VoiceCorePlayer;

/**
* Model providing access to currently installed voices on device
* + entry for configuration without voice commands.
Expand Down Expand Up @@ -89,10 +87,7 @@ public slots:
SettingsRef settings;

// we setup QObject parents, objects are cleaned after Module destruction
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QMediaPlaylist *currentPlaylist{nullptr};
#endif
QMediaPlayer *mediaPlayer{nullptr};
VoiceCorePlayer *mediaPlayer{nullptr};
};
}
#endif //OSMSCOUT_CLIENT_QT_INSTALLEDVOICESMODEL_H
22 changes: 4 additions & 18 deletions libosmscout-client-qt/include/osmscoutclientqt/NavigationModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <osmscoutclient/DBThread.h>

#include <osmscoutclientqt/Router.h>
#include <osmscoutclientqt/VoicePlayer.h>

#include <osmscout/navigation/Navigation.h>
#include <osmscout/navigation/Engine.h>
Expand All @@ -43,24 +44,12 @@
#include <QtGlobal>
#include <QObject>
#include <QTimer>
#include <QMediaPlayer>
#include <QDateTime>

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QMediaPlaylist>
#endif

#include <optional>

namespace osmscout {

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
using QtMediaPlayerState = QMediaPlayer::State;
#else
using QtMediaPlayerState = QMediaPlayer::PlaybackState;
#endif


/**
* \ingroup QtAPI
*/
Expand Down Expand Up @@ -112,7 +101,7 @@ public slots:

void onVoiceChanged(const QString);

void playerStateChanged(QtMediaPlayerState state);
void playerStateChanged(VoicePlayer::PlaybackState state);

public:
NavigationModule(QThread *thread,
Expand Down Expand Up @@ -141,12 +130,9 @@ public slots:

// voice route instructions
QString voiceDir;
// player and playlist should be created in module thread, not in UI thread (constructor)
// player should be created in module thread, not in UI thread (constructor)
// we setup QObject parents, objects are cleaned after Module destruction
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QMediaPlaylist *currentPlaylist{nullptr};
#endif
QMediaPlayer *mediaPlayer{nullptr};
VoiceCorePlayer *mediaPlayer{nullptr};
std::vector<osmscout::VoiceInstructionMessage::VoiceSample> nextMessage;

osmscout::RouteDescriptionRef routeDescription;
Expand Down
Loading

0 comments on commit 286e56f

Please sign in to comment.