diff options
Diffstat (limited to 'MainApp.cpp')
-rw-r--r-- | MainApp.cpp | 99 |
1 files changed, 45 insertions, 54 deletions
diff --git a/MainApp.cpp b/MainApp.cpp index f4c858d..10492f7 100644 --- a/MainApp.cpp +++ b/MainApp.cpp @@ -80,7 +80,6 @@ MainApp::MainApp(Navigation *navigation):QMainWindow(Q_NULLPTR, Qt::FramelessWin lineEdit.setGeometry(QRect(LEFT_OFFSET + searchBtn.width() + SPACER, 0, lineEdit.width(), lineEdit.height())); lineEdit.setVisible(false); - QFile file(NAVI_CONFIG_FILEPATH); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -150,8 +149,6 @@ void MainApp::DisplayLineEdit(bool display) { mutex.lock(); - this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB)); - if (display) { lineEdit.setVisible(true); @@ -162,13 +159,11 @@ void MainApp::DisplayLineEdit(bool display) if (pResultList) { pResultList->removeEventFilter(this); - delete pResultList; - pResultList = NULL; + pResultList->setVisible(false); } if (pInfoPanel) { - delete pInfoPanel; - pInfoPanel = NULL; + pInfoPanel->setVisible(false); } lineEdit.setText(tr("")); lineEdit.setVisible(false); @@ -193,7 +188,7 @@ void MainApp::UpdateAglSurfaces() system(cmd); } -void MainApp::DisplayResultList(bool display, bool RefreshDisplay) +void MainApp::DisplayResultList(bool display) { mutex.lock(); @@ -215,32 +210,25 @@ void MainApp::DisplayResultList(bool display, bool RefreshDisplay) //font.setPointSize(FONT_SIZE_LIST); //pResultList->setFont(font); pResultList->installEventFilter(this); - } - pResultList->setGeometry(QRect( LEFT_OFFSET+searchBtn.width()+SPACER, searchBtn.height()+SPACER, - DISPLAY_WIDTH, DISPLAY_HEIGHT)); - if (RefreshDisplay) - { - this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB)); + pResultList->setGeometry(QRect(LEFT_OFFSET + searchBtn.width() + SPACER, + searchBtn.height() + SPACER, + DISPLAY_WIDTH, + DISPLAY_HEIGHT)); } pResultList->setVisible(true); pResultList->setFocus(); + pResultList->update(); } else { if (pResultList) { pResultList->removeEventFilter(this); - pResultList->deleteLater(); - pResultList = NULL; + pResultList->setVisible(false); + pResultList->update(); } - lineEdit.setFocus(); - - if (RefreshDisplay) - { - this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB)); - } } mutex.unlock(); @@ -251,7 +239,8 @@ void MainApp::textChanged(const QString & text) TRACE_INFO("New text is: %s", qPrintable(text)); /* do not handle text input if info panel is displayed: */ - if (pInfoPanel) return; + if (pInfoPanel && pInfoPanel->isVisible()) + return; mutex.lock(); @@ -308,7 +297,7 @@ void MainApp::itemClicked() mutex.lock(); if (isInfoScreen) { - DisplayInformation(true, false); + DisplayInformation(true); } else { @@ -521,7 +510,7 @@ bool MainApp::eventFilter(QObject *obj, QEvent *ev) { case Qt::Key_Escape: TRACE_DEBUG("Escape !"); - DisplayInformation(false, false); + DisplayInformation(false); DisplayResultList(true); FillResultList(Businesses, currentIndex); break; @@ -577,9 +566,20 @@ void MainApp::SetDestination(int index) SetWayPoints(0); mutex.unlock(); + + if (navWinRaiseCb) { + // Attempt to let any outstanding repaints finish by flushing + // and then waiting slightly before raising the nav window. + // It's currently unclear why repaints can be missed if this + // is not done. + qApp->processEvents(); + + //TRACE_DEBUG("Calling nav window raise callback"); + QTimer::singleShot(100, this, SLOT(callNavWinRaiseCb())); + } } -void MainApp::DisplayInformation(bool display, bool RefreshDisplay) +void MainApp::DisplayInformation(bool display) { mutex.lock(); if (display) @@ -603,18 +603,20 @@ void MainApp::DisplayInformation(bool display, bool RefreshDisplay) /* select the first selected item : */ currentIndex = pResultList->indexOfTopLevelItem(*SelectedItems.begin()); - /* Resize window: */ - DisplayResultList(false, false); + /* Hide results */ + DisplayResultList(false); /* Display info for the selected item: */ - QRect rect( LEFT_OFFSET+searchBtn.width()+SPACER, searchBtn.height()+SPACER, - DISPLAY_WIDTH, DISPLAY_HEIGHT); - pInfoPanel = new InfoPanel(this, Businesses[currentIndex], rect); - - if (RefreshDisplay) - { - this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB)); + if (!pInfoPanel) { + QRect rect(LEFT_OFFSET + searchBtn.width() + SPACER, + searchBtn.height(), + DISPLAY_WIDTH, + DISPLAY_HEIGHT); + pInfoPanel = new InfoPanel(this, rect); } + pInfoPanel->populateInfo(Businesses[currentIndex]); + pInfoPanel->setVisible(true); + pInfoPanel->update(); connect(pInfoPanel->getGoButton(), SIGNAL(clicked(bool)), this, SLOT(goClicked())); connect(pInfoPanel->getCancelButton(), SIGNAL(clicked(bool)), this, SLOT(cancelClicked())); @@ -623,17 +625,12 @@ void MainApp::DisplayInformation(bool display, bool RefreshDisplay) { if (pInfoPanel) { + pInfoPanel->setVisible(false); pInfoPanel->getGoButton()->disconnect(); pInfoPanel->getCancelButton()->disconnect(); - delete pInfoPanel; - pInfoPanel = NULL; + pInfoPanel->update(); } lineEdit.setFocus(); - - if (RefreshDisplay) - { - this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB)); - } } mutex.unlock(); @@ -666,8 +663,6 @@ void MainApp::networkReplySearch(QNetworkReply* reply) return; } - - currentIndex = 0; Businesses.clear(); ParseJsonBusinessList(buf.data(), Businesses); @@ -883,28 +878,24 @@ int MainApp::StartMonitoringUserInput() void MainApp::SetWayPoints(uint32_t myRoute) { /* set the destination : */ + naviapi->broadcastStatus("stop"); naviapi->sendWaypoint(this->destinationLatitude, this->destinationLongitude); - - /* reset search: */ - currentSearchingText = tr(""); - currentSearchedText = tr(""); - currentIndex = 0; - Businesses.clear(); } void MainApp::goClicked() { TRACE_DEBUG("Go clicked !"); + DisplayInformation(false); + DisplayResultList(true); + SetDestination(currentIndex); - DisplayLineEdit(false); } void MainApp::cancelClicked() { TRACE_DEBUG("Cancel clicked !"); - DisplayInformation(false, false); - DisplayResultList(true, false); - FillResultList(Businesses, currentIndex); + DisplayInformation(false); + DisplayResultList(true); } void MainApp::getAllSessions_reply(const std::map< uint32_t, std::string >& allSessions) |