Skip to content

Commit

Permalink
Improved display if flight rules in information display and tooltips.…
Browse files Browse the repository at this point in the history
… Showing flight rules and icon for all sources now.

Now showing selected source for weather in map in the information display.
Information and simulator aircraft progress icons are now correctly scaled according to text size.
Fixed issue where font size was not reloaded when loading information on startup was off.
Now allowing font sizes up to 200 percent instead of 150.
#6
  • Loading branch information
albar965 committed Sep 15, 2018
1 parent 5d61389 commit db1b1c5
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 94 deletions.
172 changes: 96 additions & 76 deletions src/common/htmlinfobuilder.cpp

Large diffs are not rendered by default.

35 changes: 30 additions & 5 deletions src/common/htmlinfobuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,21 @@ class HtmlInfoBuilder
void aircraftOnlineText(const atools::fs::sc::SimConnectAircraft& aircraft, const atools::sql::SqlRecord& onlineRec,
atools::util::HtmlBuilder& html);

void setSymbolSize(const QSize& value)
{
symbolSize = value;
}

void setSymbolSizeVehicle(const QSize& value)
{
symbolSizeVehicle = value;
}

void setSymbolSizeTitle(const QSize& value)
{
symbolSizeTitle = value;
}

private:
void head(atools::util::HtmlBuilder& html, const QString& text) const;

Expand Down Expand Up @@ -300,14 +315,14 @@ class HtmlInfoBuilder
void dateAndTime(const atools::fs::sc::SimConnectUserAircraft *userAircraft,
atools::util::HtmlBuilder& html) const;
void addMetarLine(atools::util::HtmlBuilder& html, const QString& heading, const QString& metar,
const QString& station = QString(),
const QDateTime& timestamp = QDateTime(), bool fsMetar = false) const;
const QString& station,
const QDateTime& timestamp, bool fsMetar, bool mapDisplay) const;

void decodedMetar(atools::util::HtmlBuilder& html, const map::MapAirport& airport,
const map::MapAirport& reportAirport, const atools::fs::weather::Metar& metar,
bool isInterpolated, bool isFsxP3d) const;
bool isInterpolated, bool isFsxP3d, bool mapDisplay) const;
void decodedMetars(atools::util::HtmlBuilder& html, const atools::fs::weather::MetarResult& metar,
const map::MapAirport& airport, const QString& name) const;
const map::MapAirport& airport, const QString& name, bool mapDisplay) const;

bool buildWeatherContext(map::WeatherContext& lastContext, map::WeatherContext& newContext,
const map::MapAirport& airport);
Expand All @@ -317,7 +332,17 @@ class HtmlInfoBuilder
QString airplaneType(const atools::fs::sc::SimConnectAircraft& aircraft) const;
void airportRow(const map::MapAirport& ap, atools::util::HtmlBuilder& html) const;

void flightRulesText(const map::MapAirport& airport, atools::util::HtmlBuilder& html) const;
void addFlightRulesSuffix(atools::util::HtmlBuilder& html, const atools::fs::weather::Metar& metar,
bool mapDisplay) const;

/* Airport, navaid and userpoint icon size */
QSize symbolSize = QSize(18, 18);

/* Airport, navaid and userpoint icon title size */
QSize symbolSizeTitle = QSize(24, 24);

/* Aircraft size */
QSize symbolSizeVehicle = QSize(28, 28);

MainWindow *mainWindow = nullptr;
MapQuery *mapQuery;
Expand Down
15 changes: 11 additions & 4 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,13 @@ void MainWindow::connectAllSlots()
connect(ui->actionMapShowWeatherVatsim, &QAction::toggled, this, &MainWindow::updateMapObjectsShown);
connect(ui->actionMapShowWeatherIvao, &QAction::toggled, this, &MainWindow::updateMapObjectsShown);

// Update map weather source hightlights
connect(ui->actionMapShowWeatherSimulator, &QAction::toggled, infoController, &InfoController::updateAirport);
connect(ui->actionMapShowWeatherActiveSky, &QAction::toggled, infoController, &InfoController::updateAirport);
connect(ui->actionMapShowWeatherNoaa, &QAction::toggled, infoController, &InfoController::updateAirport);
connect(ui->actionMapShowWeatherVatsim, &QAction::toggled, infoController, &InfoController::updateAirport);
connect(ui->actionMapShowWeatherIvao, &QAction::toggled, infoController, &InfoController::updateAirport);

// Sun shading
connect(ui->actionMapShowSunShading, &QAction::toggled, this, &MainWindow::updateMapObjectsShown);
connect(ui->actionMapShowSunShadingSimulatorTime, &QAction::triggered, this, &MainWindow::sunShadingTimeChanged);
Expand Down Expand Up @@ -1354,10 +1361,10 @@ void MainWindow::resultTruncated(int truncatedTo)

void MainWindow::distanceChanged()
{
#ifdef DEBUG_INFORMATION
qDebug() << Q_FUNC_INFO << "minimumZoom" << mapWidget->minimumZoom() << "maximumZoom" << mapWidget->maximumZoom()
<< "step" << mapWidget->zoomStep() << "distance" << mapWidget->distance() << "zoom" << mapWidget->zoom();
#endif
// #ifdef DEBUG_INFORMATION
// qDebug() << Q_FUNC_INFO << "minimumZoom" << mapWidget->minimumZoom() << "maximumZoom" << mapWidget->maximumZoom()
// << "step" << mapWidget->zoomStep() << "distance" << mapWidget->distance() << "zoom" << mapWidget->zoom();
// #endif

mapDistanceLabel->setText(Unit::distMeter(static_cast<float>(mapWidget->distance() * 1000.f)));
}
Expand Down
29 changes: 25 additions & 4 deletions src/info/infocontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ InfoController::InfoController(MainWindow *parent)

infoBuilder = new HtmlInfoBuilder(mainWindow, true);

// Set search path to silence text browser warnings
Ui::MainWindow *ui = NavApp::getMainUi();
// Get base font size for widgets
infoFontPtSize = static_cast<float>(ui->textBrowserAirportInfo->font().pointSizeF());
simInfoFontPtSize = static_cast<float>(ui->textBrowserAircraftInfo->font().pointSizeF());

// Set search path to silence text browser warnings
QStringList paths({QApplication::applicationDirPath()});
ui->textBrowserAirportInfo->setSearchPaths(paths);
ui->textBrowserRunwayInfo->setSearchPaths(paths);
Expand Down Expand Up @@ -368,14 +369,14 @@ void InfoController::restoreState()
map::MapObjectTypes(refsStrList.at(i + 1).toInt()),
refsStrList.at(i).toInt(), false /* airport from nav database */);

updateTextEditFontSizes();
showInformationInternal(res, map::NONE, false /* show windows */, false /* scroll to top */);

Ui::MainWindow *ui = NavApp::getMainUi();
atools::gui::WidgetState(lnm::INFOWINDOW_WIDGET).restore({ui->tabWidgetInformation,
ui->tabWidgetAircraft,
ui->tabWidgetLegend});
}
updateTextEditFontSizes();
}

void InfoController::updateAirport()
Expand Down Expand Up @@ -561,7 +562,9 @@ void InfoController::showInformationInternal(map::MapSearchResult result, map::M
// Airport ================================================================
if(!result.airports.isEmpty())
{
#ifdef DEBUG_INFORMATION
qDebug() << "Found airport" << result.airports.first().ident;
#endif

// Only one airport shown - have to make a copy here since currentSearchResult might be equal to result
// when updating
Expand Down Expand Up @@ -773,8 +776,9 @@ bool InfoController::updateNavaidInternal(const map::MapSearchResult& result, bo
// Userpoints on top of the list
for(map::MapUserpoint userpoint: result.userpoints)
{
#ifdef DEBUG_INFORMATION
qDebug() << "Found waypoint" << userpoint.ident;

#endif
// Get updated object in case of changes in the database
mapQuery->updateUserdataPoint(userpoint);

Expand All @@ -787,7 +791,9 @@ bool InfoController::updateNavaidInternal(const map::MapSearchResult& result, bo

for(const map::MapVor& vor : result.vors)
{
#ifdef DEBUG_INFORMATION
qDebug() << "Found vor" << vor.ident;
#endif

if(!bearingChanged)
currentSearchResult.vors.append(vor);
Expand All @@ -798,7 +804,9 @@ bool InfoController::updateNavaidInternal(const map::MapSearchResult& result, bo

for(const map::MapNdb& ndb : result.ndbs)
{
#ifdef DEBUG_INFORMATION
qDebug() << "Found ndb" << ndb.ident;
#endif

if(!bearingChanged)
currentSearchResult.ndbs.append(ndb);
Expand All @@ -809,7 +817,9 @@ bool InfoController::updateNavaidInternal(const map::MapSearchResult& result, bo

for(const map::MapWaypoint& waypoint : result.waypoints)
{
#ifdef DEBUG_INFORMATION
qDebug() << "Found waypoint" << waypoint.ident;
#endif

if(!bearingChanged)
currentSearchResult.waypoints.append(waypoint);
Expand All @@ -820,7 +830,9 @@ bool InfoController::updateNavaidInternal(const map::MapSearchResult& result, bo

for(const map::MapAirway& airway : result.airways)
{
#ifdef DEBUG_INFORMATION
qDebug() << "Found airway" << airway.name;
#endif

if(!bearingChanged)
currentSearchResult.airways.append(airway);
Expand Down Expand Up @@ -1053,7 +1065,8 @@ void InfoController::updateAircraftInfo()
void InfoController::optionsChanged()
{
updateTextEditFontSizes();
showInformationInternal(currentSearchResult, map::NONE, false /* Show windows */, false /* scroll to top */);
updateAllInformation();
updateAircraftInfo();
}

/* Update font size in text browsers if options have changed */
Expand All @@ -1077,6 +1090,14 @@ void InfoController::updateTextEditFontSizes()
setTextEditFontSize(ui->textBrowserAircraftInfo, simInfoFontPtSize, sizePercent);
setTextEditFontSize(ui->textBrowserAircraftProgressInfo, simInfoFontPtSize, sizePercent);
setTextEditFontSize(ui->textBrowserAircraftAiInfo, simInfoFontPtSize, sizePercent);

// Adjust symbol sizes
int infoFontPixelSize = ui->textBrowserAirportInfo->fontMetrics().height();
infoBuilder->setSymbolSize(QSize(infoFontPixelSize, infoFontPixelSize));
infoBuilder->setSymbolSizeTitle(QSize(infoFontPixelSize, infoFontPixelSize) * 3 / 2);

int simInfoFontPixelSize = ui->textBrowserAircraftInfo->fontMetrics().height();
infoBuilder->setSymbolSizeVehicle(QSize(simInfoFontPixelSize, simInfoFontPixelSize) * 3 / 2);
}

/* Set font size in text edit based on percent of original size */
Expand Down
5 changes: 5 additions & 0 deletions src/navapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,11 @@ MapWidget *NavApp::getMapWidget()
return mainWindow->getMapWidget();
}

map::MapWeatherSource NavApp::getMapWeatherSource()
{
return mainWindow->getMapWidget()->getMapWeatherSource();
}

RouteController *NavApp::getRouteController()
{
return mainWindow->getRouteController();
Expand Down
2 changes: 2 additions & 0 deletions src/navapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ class NavApp :

static StyleHandler *getStyleHandler();

static map::MapWeatherSource getMapWeatherSource();

private:
/* Database query helpers and caches */
static AirportQuery *airportQuerySim, *airportQueryNav;
Expand Down
8 changes: 4 additions & 4 deletions src/options/options.ui
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ A restart is required for the settings to take effect.</string>
<number>70</number>
</property>
<property name="maximum">
<number>150</number>
<number>200</number>
</property>
<property name="singleStep">
<number>10</number>
Expand All @@ -429,7 +429,7 @@ A restart is required for the settings to take effect.</string>
<number>50</number>
</property>
<property name="maximum">
<number>150</number>
<number>200</number>
</property>
<property name="singleStep">
<number>10</number>
Expand Down Expand Up @@ -457,7 +457,7 @@ A restart is required for the settings to take effect.</string>
<number>70</number>
</property>
<property name="maximum">
<number>150</number>
<number>200</number>
</property>
<property name="singleStep">
<number>10</number>
Expand Down Expand Up @@ -499,7 +499,7 @@ A restart is required for the settings to take effect.</string>
<number>50</number>
</property>
<property name="maximum">
<number>150</number>
<number>200</number>
</property>
<property name="singleStep">
<number>10</number>
Expand Down
3 changes: 2 additions & 1 deletion src/weather/weatherreporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class WeatherReporter :
atools::fs::weather::MetarResult getIvaoMetar(const QString& airportIcao, const atools::geo::Pos& pos);

/* For display. Source depends on settings and parsed objects are cached. */
atools::fs::weather::Metar getAirportWeather(const QString& airportIcao, const atools::geo::Pos& airportPos, map::MapWeatherSource source);
atools::fs::weather::Metar getAirportWeather(const QString& airportIcao, const atools::geo::Pos& airportPos,
map::MapWeatherSource source);

/* Does nothing currently */
void preDatabaseLoad();
Expand Down

0 comments on commit db1b1c5

Please sign in to comment.