Skip to content

Commit bad0b3c

Browse files
committed
Corrected menu items and toolbar buttons which remained disabled after connecting to simulator.
1 parent 666bee4 commit bad0b3c

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

CHANGELOG.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This text is partially Markdown, hence sometimes strange formatting.
1111
**This is a stable release of *Little Navmap* which fixes several bugs and adds
1212
improvements as well as new features.**
1313

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

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

9494
### Flight Plan and Export
9595

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

117118
## Little Navconnect Version 2.8.7
118119

src/common/htmlinfobuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ void HtmlInfoBuilder::airportText(const MapAirport& airport, const map::WeatherC
279279
arg(Unit::altFeet(transitionLevel)).arg(transitionLevel / 100.f, 3, 'f', 0, QChar('0')));
280280

281281
// Sunrise and sunset ===========================
282-
QDateTime datetime =
283-
NavApp::isConnectedAndAircraft() ? NavApp::getUserAircraft().getZuluTime() : QDateTime::currentDateTimeUtc();
282+
QDateTime datetime = NavApp::isConnectedAndAircraft() ? NavApp::getUserAircraft().getZuluTime() : QDateTime::currentDateTimeUtc();
284283

285284
if(datetime.isValid())
286285
{

src/gui/mainwindow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,8 @@ void MainWindow::connectAllSlots()
15901590
// Messages about database query result status - use queued to avoid blocking paint
15911591
connect(mapWidget, &MapPaintWidget::resultTruncated, this, &MainWindow::resultTruncated, Qt::QueuedConnection);
15921592

1593+
connect(mapWidget, &MapWidget::userAircraftValidChanged, this, &MainWindow::updateActionStates);
1594+
15931595
connect(databaseManager, &DatabaseManager::preDatabaseLoad, this, &MainWindow::preDatabaseLoad);
15941596
connect(databaseManager, &DatabaseManager::postDatabaseLoad, this, &MainWindow::postDatabaseLoad);
15951597

src/mapgui/mapwidget.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,11 +2362,19 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
23622362
using atools::geo::angleAbsDiff;
23632363

23642364
const atools::fs::sc::SimConnectUserAircraft& aircraft = simulatorData.getUserAircraftConst();
2365+
2366+
// Emit signal later once all values are updated - check for aircraft state changes
2367+
bool userAircraftValidToggled = getScreenIndexConst()->getUserAircraft().isFullyValid() != aircraft.isFullyValid();
2368+
23652369
getScreenIndex()->updateSimData(simulatorData);
23662370

23672371
if(databaseLoadStatus || !aircraft.isValid())
23682372
{
23692373
getScreenIndex()->updateLastSimData(atools::fs::sc::SimConnectData());
2374+
2375+
// Update action states if needed
2376+
if(userAircraftValidToggled)
2377+
emit userAircraftValidChanged();
23702378
return;
23712379
}
23722380

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

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

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

24902498
// Check if position has changed significantly
2491-
bool posHasChanged = !last.isValid() || // No previous position
2499+
bool posHasChanged = !lastAircraft.isValid() || // No previous position
24922500
aircraftPointDiff.manhattanLength() >= deltas.manhattanLengthDelta; // Screen position has changed
24932501

24942502
// Check if any data like heading has changed which requires a redraw
24952503
bool dataHasChanged = posHasChanged ||
2496-
last.isFlying() != aircraft.isFlying() ||
2497-
last.isOnGround() != aircraft.isOnGround() ||
2498-
angleAbsDiff(last.getHeadingDegMag(),
2504+
lastAircraft.isFlying() != aircraft.isFlying() ||
2505+
lastAircraft.isOnGround() != aircraft.isOnGround() ||
2506+
angleAbsDiff(lastAircraft.getHeadingDegMag(),
24992507
aircraft.getHeadingDegMag()) > deltas.headingDelta || // Heading has changed
2500-
almostNotEqual(last.getIndicatedSpeedKts(),
2508+
almostNotEqual(lastAircraft.getIndicatedSpeedKts(),
25012509
aircraft.getIndicatedSpeedKts(), deltas.speedDelta) || // Speed has changed
2502-
almostNotEqual(last.getPosition().getAltitude(),
2510+
almostNotEqual(lastAircraft.getPosition().getAltitude(),
25032511
aircraft.getActualAltitudeFt(), deltas.altitudeDelta); // Altitude has changed
25042512

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

25122520
// Check for takeoff, landing and fuel consumption changes ===========
2513-
simDataCalcTakeoffLanding(aircraft, last);
2514-
simDataCalcFuelOnOff(aircraft, last);
2521+
simDataCalcTakeoffLanding(aircraft, lastAircraft);
2522+
simDataCalcFuelOnOff(aircraft, lastAircraft);
25152523

25162524
if(dataHasChanged)
25172525
// Also changes local "last"
@@ -2756,6 +2764,10 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
27562764
if(!updatesEnabled())
27572765
setUpdatesEnabled(true);
27582766
} // if(now - lastSimUpdateMs > deltas.timeDeltaMs)
2767+
2768+
// Update action states if needed
2769+
if(userAircraftValidToggled)
2770+
emit userAircraftValidChanged();
27592771
}
27602772

27612773
void MapWidget::mainWindowShown()

src/mapgui/mapwidget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ class MapWidget :
244244
void showGridConfiguration();
245245

246246
signals:
247+
/* Emitted when connection is established and user aircraft turned from invalid to valid */
248+
void userAircraftValidChanged();
249+
247250
/* Fuel flow started or stopped */
248251
void aircraftEngineStarted(const atools::fs::sc::SimConnectUserAircraft& aircraft);
249252
void aircraftEngineStopped(const atools::fs::sc::SimConnectUserAircraft& aircraft);

0 commit comments

Comments
 (0)