Skip to content

Commit

Permalink
Corrected menu items and toolbar buttons which remained disabled afte…
Browse files Browse the repository at this point in the history
…r connecting to simulator.
  • Loading branch information
albar965 committed Jul 16, 2023
1 parent 666bee4 commit bad0b3c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This text is partially Markdown, hence sometimes strange formatting.
**This is a stable release of *Little Navmap* which fixes several bugs and adds
improvements as well as new features.**

**Notable changes: Windows Installation program, Prepar3D v6 support,
**Notable changes: Windows Installation program, Prepar3D v6 support,
fix for MSFS waypoint moved to North issue, Little Navconnect tray icon and more.**

**Also update *Little Navconnect* and *Little Xpconnect* if you're using one of them to
Expand Down Expand Up @@ -93,7 +93,7 @@ A big thank you to all who reported bugs and issues!

### Flight Plan and Export

* Corrected wrong error message for procedures having a MAP lower than airport elevation.
* Corrected wrong error message for procedures having a MAP lower than airport elevation.
Example: FAUP RNAV UP1F1 (R35)
* Fix in flight plan export for MSFS where several waypoints are moved to North. Thanks to Github user
[eaides](https://github.com/eaides) for the hint. #1038
Expand All @@ -113,6 +113,7 @@ A big thank you to all who reported bugs and issues!
This resulted in a random crash to desktop while loading the scenery library.
* Fixed crash when loading Active Sky files if Active Sky file path was set manually and removed
later on.
* Corrected menu items and toolbar buttons which remained disabled after connecting to simulator.

## Little Navconnect Version 2.8.7

Expand Down
3 changes: 1 addition & 2 deletions src/common/htmlinfobuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ void HtmlInfoBuilder::airportText(const MapAirport& airport, const map::WeatherC
arg(Unit::altFeet(transitionLevel)).arg(transitionLevel / 100.f, 3, 'f', 0, QChar('0')));

// Sunrise and sunset ===========================
QDateTime datetime =
NavApp::isConnectedAndAircraft() ? NavApp::getUserAircraft().getZuluTime() : QDateTime::currentDateTimeUtc();
QDateTime datetime = NavApp::isConnectedAndAircraft() ? NavApp::getUserAircraft().getZuluTime() : QDateTime::currentDateTimeUtc();

if(datetime.isValid())
{
Expand Down
2 changes: 2 additions & 0 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,8 @@ void MainWindow::connectAllSlots()
// Messages about database query result status - use queued to avoid blocking paint
connect(mapWidget, &MapPaintWidget::resultTruncated, this, &MainWindow::resultTruncated, Qt::QueuedConnection);

connect(mapWidget, &MapWidget::userAircraftValidChanged, this, &MainWindow::updateActionStates);

connect(databaseManager, &DatabaseManager::preDatabaseLoad, this, &MainWindow::preDatabaseLoad);
connect(databaseManager, &DatabaseManager::postDatabaseLoad, this, &MainWindow::postDatabaseLoad);

Expand Down
32 changes: 22 additions & 10 deletions src/mapgui/mapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2362,11 +2362,19 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
using atools::geo::angleAbsDiff;

const atools::fs::sc::SimConnectUserAircraft& aircraft = simulatorData.getUserAircraftConst();

// Emit signal later once all values are updated - check for aircraft state changes
bool userAircraftValidToggled = getScreenIndexConst()->getUserAircraft().isFullyValid() != aircraft.isFullyValid();

getScreenIndex()->updateSimData(simulatorData);

if(databaseLoadStatus || !aircraft.isValid())
{
getScreenIndex()->updateLastSimData(atools::fs::sc::SimConnectData());

// Update action states if needed
if(userAircraftValidToggled)
emit userAircraftValidChanged();
return;
}

Expand All @@ -2384,8 +2392,8 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
QPoint aircraftPoint = conv.wToS(aircraft.getPosition(), CoordinateConverter::DEFAULT_WTOS_SIZE, &visible);

// Difference from last movement on map
const atools::fs::sc::SimConnectUserAircraft& last = getScreenIndexConst()->getLastUserAircraft();
QPoint aircraftPointDiff = aircraftPoint - conv.wToS(last.getPosition());
const atools::fs::sc::SimConnectUserAircraft& lastAircraft = getScreenIndexConst()->getLastUserAircraft();
QPoint aircraftPointDiff = aircraftPoint - conv.wToS(lastAircraft.getPosition());
const OptionData& od = OptionData::instance();

// Zoom to aircraft and next waypoint - depends on various criteria
Expand Down Expand Up @@ -2488,18 +2496,18 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
}

// Check if position has changed significantly
bool posHasChanged = !last.isValid() || // No previous position
bool posHasChanged = !lastAircraft.isValid() || // No previous position
aircraftPointDiff.manhattanLength() >= deltas.manhattanLengthDelta; // Screen position has changed

// Check if any data like heading has changed which requires a redraw
bool dataHasChanged = posHasChanged ||
last.isFlying() != aircraft.isFlying() ||
last.isOnGround() != aircraft.isOnGround() ||
angleAbsDiff(last.getHeadingDegMag(),
lastAircraft.isFlying() != aircraft.isFlying() ||
lastAircraft.isOnGround() != aircraft.isOnGround() ||
angleAbsDiff(lastAircraft.getHeadingDegMag(),
aircraft.getHeadingDegMag()) > deltas.headingDelta || // Heading has changed
almostNotEqual(last.getIndicatedSpeedKts(),
almostNotEqual(lastAircraft.getIndicatedSpeedKts(),
aircraft.getIndicatedSpeedKts(), deltas.speedDelta) || // Speed has changed
almostNotEqual(last.getPosition().getAltitude(),
almostNotEqual(lastAircraft.getPosition().getAltitude(),
aircraft.getActualAltitudeFt(), deltas.altitudeDelta); // Altitude has changed

// Force an update every five seconds to avoid hanging map view if aircraft does not move on map
Expand All @@ -2510,8 +2518,8 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
lastSimUpdateMs = now;

// Check for takeoff, landing and fuel consumption changes ===========
simDataCalcTakeoffLanding(aircraft, last);
simDataCalcFuelOnOff(aircraft, last);
simDataCalcTakeoffLanding(aircraft, lastAircraft);
simDataCalcFuelOnOff(aircraft, lastAircraft);

if(dataHasChanged)
// Also changes local "last"
Expand Down Expand Up @@ -2756,6 +2764,10 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
if(!updatesEnabled())
setUpdatesEnabled(true);
} // if(now - lastSimUpdateMs > deltas.timeDeltaMs)

// Update action states if needed
if(userAircraftValidToggled)
emit userAircraftValidChanged();
}

void MapWidget::mainWindowShown()
Expand Down
3 changes: 3 additions & 0 deletions src/mapgui/mapwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ class MapWidget :
void showGridConfiguration();

signals:
/* Emitted when connection is established and user aircraft turned from invalid to valid */
void userAircraftValidChanged();

/* Fuel flow started or stopped */
void aircraftEngineStarted(const atools::fs::sc::SimConnectUserAircraft& aircraft);
void aircraftEngineStopped(const atools::fs::sc::SimConnectUserAircraft& aircraft);
Expand Down

0 comments on commit bad0b3c

Please sign in to comment.