From a9790cc158955cb6774e662432bddcbd66274130 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Fri, 3 Jan 2020 17:41:32 -0500 Subject: Rework to raise navigation app and improve behavior Add callback to raise navigation app via homescreen and hook it up to the "Go" button handling. Additionally, testing of this addition revealed that the result list and information panel state is fragile and easily gotten into a bad state with respect to repaints when raising the navigation app. To fix this, the code has been reworked to change InfoPanel into an actual widget and keep it and the result list widget around; manipulating their visibilty rather than recreating them and forcing whole-window repaints. As well, a slight delay is used before raising the navigation app to let all repaints finish. Ideally this would not be required, but the app likely needs a more significant rewrite to fix it. Bug-AGL: SPEC-3079 Signed-off-by: Scott Murray Change-Id: Id8dce33e2a2135179644305a88b340ecd1d7d3c5 --- main.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 2f360f3..8bf8b51 100644 --- a/main.cpp +++ b/main.cpp @@ -12,21 +12,29 @@ using namespace std; -QLibWindowmanager* qwm; -LibHomeScreen* hs; -QString graphic_role; -MainApp *mainapp; +static QLibWindowmanager* qwm; +static LibHomeScreen* hs; +static QString graphic_role; +static MainApp *mainapp; -void SyncDrawHandler(json_object *object) +static void SyncDrawHandler(json_object *object) { qwm->endDraw(graphic_role); } -void TapShortcutHandler(json_object *object) +static void ShowWindowHandler(json_object *object) { qwm->activateWindow(graphic_role); } +// Callback to drive raising navigation app +static void NavWindowRaiseHandler(void) +{ + if (hs) { + hs->showWindow("navigation", nullptr); + } +} + int main(int argc, char *argv[], char *env[]) { int opt; @@ -65,12 +73,15 @@ int main(int argc, char *argv[], char *env[]) hs->init(port, token.c_str()); - hs->set_event_handler(LibHomeScreen::Event_TapShortcut, TapShortcutHandler); + hs->set_event_handler(LibHomeScreen::Event_ShowWindow, ShowWindowHandler); - //force setting + // force setting mainapp->setInfoScreen(true); mainapp->setKeyboard(true); + // hook up callback to start/raise navigation app + mainapp->setNavWindowRaiseCallback(NavWindowRaiseHandler); + /* then, authenticate connexion to POI service: */ if (mainapp->AuthenticatePOI(credentialsFile) < 0) { -- cgit 1.2.3-korg