mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Blacken.
This commit is contained in:
@@ -18,10 +18,12 @@ class QTimeTurnWidget(QGroupBox):
|
||||
"""
|
||||
UI Component to display current turn and time info
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
super(QTimeTurnWidget, self).__init__("Turn")
|
||||
self.setStyleSheet('padding: 0px; margin-left: 5px; margin-right: 0px; margin-top: 1ex; margin-bottom: 5px; border-right: 0px')
|
||||
self.setStyleSheet(
|
||||
"padding: 0px; margin-left: 5px; margin-right: 0px; margin-top: 1ex; margin-bottom: 5px; border-right: 0px"
|
||||
)
|
||||
|
||||
self.icons = {
|
||||
TimeOfDay.Dawn: CONST.ICONS["Dawn"],
|
||||
@@ -55,20 +57,21 @@ class QTimeTurnWidget(QGroupBox):
|
||||
"""
|
||||
self.daytime_icon.setPixmap(self.icons[conditions.time_of_day])
|
||||
self.date_display.setText(conditions.start_time.strftime("%d %b %Y"))
|
||||
self.time_display.setText(
|
||||
conditions.start_time.strftime("%H:%M:%S Local"))
|
||||
self.time_display.setText(conditions.start_time.strftime("%H:%M:%S Local"))
|
||||
self.setTitle(f"Turn {turn}")
|
||||
|
||||
|
||||
class QWeatherWidget(QGroupBox):
|
||||
"""
|
||||
UI Component to display current weather forecast
|
||||
"""
|
||||
|
||||
turn = None
|
||||
conditions = None
|
||||
|
||||
def __init__(self):
|
||||
super(QWeatherWidget, self).__init__("")
|
||||
self.setProperty('style', 'QWeatherWidget')
|
||||
self.setProperty("style", "QWeatherWidget")
|
||||
|
||||
self.icons = {
|
||||
TimeOfDay.Dawn: CONST.ICONS["Dawn"],
|
||||
@@ -83,17 +86,15 @@ class QWeatherWidget(QGroupBox):
|
||||
self.makeWeatherIcon()
|
||||
self.makeCloudRainFogWidget()
|
||||
self.makeWindsWidget()
|
||||
|
||||
|
||||
def makeWeatherIcon(self):
|
||||
"""Makes the Weather Icon Widget
|
||||
"""
|
||||
"""Makes the Weather Icon Widget"""
|
||||
self.weather_icon = QLabel()
|
||||
self.weather_icon.setPixmap(self.icons[TimeOfDay.Dawn])
|
||||
self.layout.addWidget(self.weather_icon)
|
||||
|
||||
def makeCloudRainFogWidget(self):
|
||||
"""Makes the Cloud, Rain, Fog Widget
|
||||
"""
|
||||
"""Makes the Cloud, Rain, Fog Widget"""
|
||||
self.textLayout = QVBoxLayout()
|
||||
self.layout.addLayout(self.textLayout)
|
||||
|
||||
@@ -107,43 +108,41 @@ class QWeatherWidget(QGroupBox):
|
||||
self.textLayout.addWidget(self.forecastFog)
|
||||
|
||||
def makeWindsWidget(self):
|
||||
"""Factory for the winds widget.
|
||||
"""
|
||||
"""Factory for the winds widget."""
|
||||
windsLayout = QGridLayout()
|
||||
self.layout.addLayout(windsLayout)
|
||||
|
||||
windsLayout.addWidget(self.makeIcon(CONST.ICONS['Weather_winds']), 0, 0, 3, 1)
|
||||
windsLayout.addWidget(self.makeIcon(CONST.ICONS["Weather_winds"]), 0, 0, 3, 1)
|
||||
|
||||
windsLayout.addWidget(self.makeLabel('At GL'), 0, 1)
|
||||
windsLayout.addWidget(self.makeLabel('At FL08'), 1, 1)
|
||||
windsLayout.addWidget(self.makeLabel('At FL26'), 2, 1)
|
||||
windsLayout.addWidget(self.makeLabel("At GL"), 0, 1)
|
||||
windsLayout.addWidget(self.makeLabel("At FL08"), 1, 1)
|
||||
windsLayout.addWidget(self.makeLabel("At FL26"), 2, 1)
|
||||
|
||||
self.windGLSpeedLabel = self.makeLabel('0kts')
|
||||
self.windGLDirLabel = self.makeLabel('0º')
|
||||
self.windGLSpeedLabel = self.makeLabel("0kts")
|
||||
self.windGLDirLabel = self.makeLabel("0º")
|
||||
windsLayout.addWidget(self.windGLSpeedLabel, 0, 2)
|
||||
windsLayout.addWidget(self.windGLDirLabel, 0, 3)
|
||||
|
||||
|
||||
self.windFL08SpeedLabel = self.makeLabel('0kts')
|
||||
self.windFL08DirLabel = self.makeLabel('0º')
|
||||
self.windFL08SpeedLabel = self.makeLabel("0kts")
|
||||
self.windFL08DirLabel = self.makeLabel("0º")
|
||||
windsLayout.addWidget(self.windFL08SpeedLabel, 1, 2)
|
||||
windsLayout.addWidget(self.windFL08DirLabel, 1, 3)
|
||||
|
||||
self.windFL26SpeedLabel = self.makeLabel('0kts')
|
||||
self.windFL26DirLabel = self.makeLabel('0º')
|
||||
self.windFL26SpeedLabel = self.makeLabel("0kts")
|
||||
self.windFL26DirLabel = self.makeLabel("0º")
|
||||
windsLayout.addWidget(self.windFL26SpeedLabel, 2, 2)
|
||||
windsLayout.addWidget(self.windFL26DirLabel, 2, 3)
|
||||
|
||||
def makeLabel(self, text: str = '') -> QLabel:
|
||||
def makeLabel(self, text: str = "") -> QLabel:
|
||||
"""Shorthand to generate a QLabel with widget standard style
|
||||
|
||||
:arg pixmap QPixmap for the icon.
|
||||
"""
|
||||
label = QLabel(text)
|
||||
label.setProperty('style', 'text-sm')
|
||||
label.setProperty("style", "text-sm")
|
||||
|
||||
return label
|
||||
|
||||
|
||||
def makeIcon(self, pixmap: QPixmap) -> QLabel:
|
||||
"""Shorthand to generate a QIcon with pixmap.
|
||||
|
||||
@@ -167,26 +166,28 @@ class QWeatherWidget(QGroupBox):
|
||||
self.updateWinds()
|
||||
|
||||
def updateWinds(self):
|
||||
"""Updates the UI with the current conditions wind info.
|
||||
"""
|
||||
"""Updates the UI with the current conditions wind info."""
|
||||
windGlSpeed = mps(self.conditions.weather.wind.at_0m.speed or 0)
|
||||
windGlDir = str(self.conditions.weather.wind.at_0m.direction or 0).rjust(3, '0')
|
||||
self.windGLSpeedLabel.setText(f'{int(windGlSpeed.knots)}kts')
|
||||
self.windGLDirLabel.setText(f'{windGlDir}º')
|
||||
windGlDir = str(self.conditions.weather.wind.at_0m.direction or 0).rjust(3, "0")
|
||||
self.windGLSpeedLabel.setText(f"{int(windGlSpeed.knots)}kts")
|
||||
self.windGLDirLabel.setText(f"{windGlDir}º")
|
||||
|
||||
windFL08Speed = mps(self.conditions.weather.wind.at_2000m.speed or 0)
|
||||
windFL08Dir = str(self.conditions.weather.wind.at_2000m.direction or 0).rjust(3, '0')
|
||||
self.windFL08SpeedLabel.setText(f'{int(windFL08Speed.knots)}kts')
|
||||
self.windFL08DirLabel.setText(f'{windFL08Dir}º')
|
||||
windFL08Dir = str(self.conditions.weather.wind.at_2000m.direction or 0).rjust(
|
||||
3, "0"
|
||||
)
|
||||
self.windFL08SpeedLabel.setText(f"{int(windFL08Speed.knots)}kts")
|
||||
self.windFL08DirLabel.setText(f"{windFL08Dir}º")
|
||||
|
||||
windFL26Speed = mps(self.conditions.weather.wind.at_8000m.speed or 0)
|
||||
windFL26Dir = str(self.conditions.weather.wind.at_8000m.direction or 0).rjust(3, '0')
|
||||
self.windFL26SpeedLabel.setText(f'{int(windFL26Speed.knots)}kts')
|
||||
self.windFL26DirLabel.setText(f'{windFL26Dir}º')
|
||||
windFL26Dir = str(self.conditions.weather.wind.at_8000m.direction or 0).rjust(
|
||||
3, "0"
|
||||
)
|
||||
self.windFL26SpeedLabel.setText(f"{int(windFL26Speed.knots)}kts")
|
||||
self.windFL26DirLabel.setText(f"{windFL26Dir}º")
|
||||
|
||||
def updateForecast(self):
|
||||
"""Updates the Forecast Text and icon with the current conditions wind info.
|
||||
"""
|
||||
"""Updates the Forecast Text and icon with the current conditions wind info."""
|
||||
icon = []
|
||||
if self.conditions.weather.clouds is None:
|
||||
cloudDensity = 0
|
||||
@@ -197,44 +198,44 @@ class QWeatherWidget(QGroupBox):
|
||||
|
||||
fog = self.conditions.weather.fog or None
|
||||
is_night = self.conditions.time_of_day == TimeOfDay.Night
|
||||
time = 'night' if is_night else 'day'
|
||||
time = "night" if is_night else "day"
|
||||
|
||||
if cloudDensity <= 0:
|
||||
self.forecastClouds.setText('Sunny')
|
||||
icon = [time, 'clear']
|
||||
|
||||
self.forecastClouds.setText("Sunny")
|
||||
icon = [time, "clear"]
|
||||
|
||||
if cloudDensity > 0 and cloudDensity < 3:
|
||||
self.forecastClouds.setText('Partly Cloudy')
|
||||
icon = [time, 'partly-cloudy']
|
||||
self.forecastClouds.setText("Partly Cloudy")
|
||||
icon = [time, "partly-cloudy"]
|
||||
|
||||
if cloudDensity >= 3 and cloudDensity < 5:
|
||||
self.forecastClouds.setText('Mostly Cloudy')
|
||||
icon = [time, 'partly-cloudy']
|
||||
self.forecastClouds.setText("Mostly Cloudy")
|
||||
icon = [time, "partly-cloudy"]
|
||||
|
||||
if cloudDensity >= 5:
|
||||
self.forecastClouds.setText('Totally Cloudy')
|
||||
icon = [time, 'partly-cloudy']
|
||||
self.forecastClouds.setText("Totally Cloudy")
|
||||
icon = [time, "partly-cloudy"]
|
||||
|
||||
if precipitation == PydcsWeather.Preceptions.Rain:
|
||||
self.forecastRain.setText('Rain')
|
||||
icon = [time, 'rain']
|
||||
self.forecastRain.setText("Rain")
|
||||
icon = [time, "rain"]
|
||||
|
||||
elif precipitation == PydcsWeather.Preceptions.Thunderstorm:
|
||||
self.forecastRain.setText('Thunderstorm')
|
||||
icon = [time, 'thunderstorm']
|
||||
|
||||
self.forecastRain.setText("Thunderstorm")
|
||||
icon = [time, "thunderstorm"]
|
||||
|
||||
else:
|
||||
self.forecastRain.setText('No Rain')
|
||||
self.forecastRain.setText("No Rain")
|
||||
|
||||
if not fog:
|
||||
self.forecastFog.setText('No fog')
|
||||
else:
|
||||
self.forecastFog.setText("No fog")
|
||||
else:
|
||||
visibility = round(fog.visibility.nautical_miles, 1)
|
||||
self.forecastFog.setText(f'Fog vis: {visibility}nm')
|
||||
icon = [time, ('cloudy' if cloudDensity > 1 else None), 'fog']
|
||||
self.forecastFog.setText(f"Fog vis: {visibility}nm")
|
||||
icon = [time, ("cloudy" if cloudDensity > 1 else None), "fog"]
|
||||
|
||||
icon_key = "Weather_{}".format('-'.join(filter(None.__ne__, icon)))
|
||||
icon = CONST.ICONS.get(icon_key) or CONST.ICONS['Weather_night-partly-cloudy']
|
||||
icon_key = "Weather_{}".format("-".join(filter(None.__ne__, icon)))
|
||||
icon = CONST.ICONS.get(icon_key) or CONST.ICONS["Weather_night-partly-cloudy"]
|
||||
self.weather_icon.setPixmap(icon)
|
||||
|
||||
|
||||
@@ -245,7 +246,7 @@ class QConditionsWidget(QFrame):
|
||||
|
||||
def __init__(self):
|
||||
super(QConditionsWidget, self).__init__()
|
||||
self.setProperty('style', 'QConditionsWidget')
|
||||
self.setProperty("style", "QConditionsWidget")
|
||||
|
||||
self.layout = QGridLayout()
|
||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||
@@ -254,11 +255,13 @@ class QConditionsWidget(QFrame):
|
||||
self.setLayout(self.layout)
|
||||
|
||||
self.time_turn_widget = QTimeTurnWidget()
|
||||
self.time_turn_widget.setStyleSheet('QGroupBox { margin-right: 0px; }')
|
||||
self.time_turn_widget.setStyleSheet("QGroupBox { margin-right: 0px; }")
|
||||
self.layout.addWidget(self.time_turn_widget, 0, 0)
|
||||
|
||||
self.weather_widget = QWeatherWidget()
|
||||
self.weather_widget.setStyleSheet('QGroupBox { margin-top: 5px; margin-left: 0px; border-left: 0px; }')
|
||||
self.weather_widget.setStyleSheet(
|
||||
"QGroupBox { margin-top: 5px; margin-left: 0px; border-left: 0px; }"
|
||||
)
|
||||
self.weather_widget.hide()
|
||||
self.layout.addWidget(self.weather_widget, 0, 1)
|
||||
|
||||
@@ -271,4 +274,3 @@ class QConditionsWidget(QFrame):
|
||||
self.time_turn_widget.setCurrentTurn(turn, conditions)
|
||||
self.weather_widget.setCurrentTurn(turn, conditions)
|
||||
self.weather_widget.show()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user