wip: finished work on the TopPanel Widget, added weather icons, changed timeofday icons

This commit is contained in:
Ignacio Muñoz Fernandez 2020-11-25 15:59:38 +01:00 committed by Dan Albert
parent 718b3f2623
commit ca30af4238
21 changed files with 81 additions and 26 deletions

View File

@ -87,10 +87,10 @@ def load_icons():
ICONS["Terrain_TheChannel"] = QPixmap("./resources/ui/terrain_channel.gif") ICONS["Terrain_TheChannel"] = QPixmap("./resources/ui/terrain_channel.gif")
ICONS["Terrain_Syria"] = QPixmap("./resources/ui/terrain_syria.gif") ICONS["Terrain_Syria"] = QPixmap("./resources/ui/terrain_syria.gif")
ICONS["Dawn"] = QPixmap("./resources/ui/daytime/dawn.png") ICONS["Dawn"] = QPixmap("./resources/ui/conditions/timeofday/dawn.png")
ICONS["Day"] = QPixmap("./resources/ui/daytime/day.png") ICONS["Day"] = QPixmap("./resources/ui/conditions/timeofday/day.png")
ICONS["Dusk"] = QPixmap("./resources/ui/daytime/dusk.png") ICONS["Dusk"] = QPixmap("./resources/ui/conditions/timeofday/dusk.png")
ICONS["Night"] = QPixmap("./resources/ui/daytime/night.png") ICONS["Night"] = QPixmap("./resources/ui/conditions/timeofday/night.png")
ICONS["Money"] = QPixmap("./resources/ui/misc/"+get_theme_icons()+"/money_icon.png") ICONS["Money"] = QPixmap("./resources/ui/misc/"+get_theme_icons()+"/money_icon.png")
ICONS["PassTurn"] = QPixmap("./resources/ui/misc/"+get_theme_icons()+"/hourglass.png") ICONS["PassTurn"] = QPixmap("./resources/ui/misc/"+get_theme_icons()+"/hourglass.png")
@ -121,6 +121,24 @@ def load_icons():
ICONS["TaskSEAD"] = QPixmap("./resources/ui/tasks/sead.png") ICONS["TaskSEAD"] = QPixmap("./resources/ui/tasks/sead.png")
ICONS["TaskEmpty"] = QPixmap("./resources/ui/tasks/empty.png") ICONS["TaskEmpty"] = QPixmap("./resources/ui/tasks/empty.png")
"""
Weather Icons
"""
ICONS["Weather_day-clear"] = QPixmap("./resources/ui/conditions/weather/day-clear.png")
ICONS["Weather_day-cloudy-fog"] = QPixmap("./resources/ui/conditions/weather/day-cloudy-fog.png")
ICONS["Weather_day-fog"] = QPixmap("./resources/ui/conditions/weather/day-fog.png")
ICONS["Weather_day-partly-cloudy"] = QPixmap("./resources/ui/conditions/weather/day-partly-cloudy.png")
ICONS["Weather_day-rain"] = QPixmap("./resources/ui/conditions/weather/day-rain.png")
ICONS["Weather_day-thunderstorm"] = QPixmap("./resources/ui/conditions/weather/day-thunderstorm.png")
ICONS["Weather_day-totally-cloud"] = QPixmap("./resources/ui/conditions/weather/day-totally-cloud.png")
ICONS["Weather_night-clear"] = QPixmap("./resources/ui/conditions/weather/night-clear.png")
ICONS["Weather_night-cloudy-fog"] = QPixmap("./resources/ui/conditions/weather/night-cloudy-fog.png")
ICONS["Weather_night-fog"] = QPixmap("./resources/ui/conditions/weather/night-fog.png")
ICONS["Weather_night-partly-cloudy"] = QPixmap("./resources/ui/conditions/weather/night-partly-cloudy.png")
ICONS["Weather_night-rain"] = QPixmap("./resources/ui/conditions/weather/night-rain.png")
ICONS["Weather_night-thunderstorm"] = QPixmap("./resources/ui/conditions/weather/night-thunderstorm.png")
ICONS["Weather_night-totally-cloud"] = QPixmap("./resources/ui/conditions/weather/night-totally-cloud.png")
EVENT_ICONS: Dict[str, QPixmap] = {} EVENT_ICONS: Dict[str, QPixmap] = {}

View File

@ -1,10 +1,12 @@
import datetime import datetime
import logging
from PySide2.QtCore import Qt from PySide2.QtCore import Qt
from PySide2.QtWidgets import QLabel, QHBoxLayout, QGroupBox, QVBoxLayout, QFrame, QSizePolicy, QStyle, QPushButton, QGridLayout from PySide2.QtWidgets import QLabel, QHBoxLayout, QGroupBox, QVBoxLayout, QFrame, QSizePolicy, QStyle, QPushButton, QGridLayout
from PySide2.QtGui import QFont from PySide2.QtGui import QFont
from game.weather import Conditions, TimeOfDay, Weather from game.weather import Conditions, TimeOfDay, Weather
from game.utils import meter_to_nm
from dcs.weather import Weather as PydcsWeather from dcs.weather import Weather as PydcsWeather
from qt_ui.windows.weather.QWeatherInfoWindow import QWeatherInfoWindow from qt_ui.windows.weather.QWeatherInfoWindow import QWeatherInfoWindow
@ -88,12 +90,15 @@ class QWeatherWidget(QGroupBox):
self.layout.addLayout(self.textLayout) self.layout.addLayout(self.textLayout)
self.forecastClouds = QLabel('') self.forecastClouds = QLabel('')
self.forecastClouds.setProperty('style', 'text-sm')
self.textLayout.addWidget(self.forecastClouds) self.textLayout.addWidget(self.forecastClouds)
self.forecastRain = QLabel('') self.forecastRain = QLabel('')
self.forecastRain.setProperty('style', 'text-sm')
self.textLayout.addWidget(self.forecastRain) self.textLayout.addWidget(self.forecastRain)
self.forecastFog = QLabel('') self.forecastFog = QLabel('')
self.forecastFog.setProperty('style', 'text-sm')
self.textLayout.addWidget(self.forecastFog) self.textLayout.addWidget(self.forecastFog)
self.details = QPushButton("Weather") self.details = QPushButton("Weather")
@ -114,53 +119,66 @@ class QWeatherWidget(QGroupBox):
self.turn self.turn
self.conditions = conditions self.conditions = conditions
if conditions and turn > 0: if not conditions:
self.details.setDisabled(True) self.details.setDisabled(True)
else: else:
self.details.setDisabled(False) self.details.setDisabled(False)
self.updateIcon() self.updateForecast()
self.updateText()
pass def updateForecast(self):
def updateIcon(self):
"""
Updates the Forecast Icon based on turn conditions
"""
pass
def updateText(self):
""" """
Updates the Forecast Text based on turn conditions Updates the Forecast Text based on turn conditions
""" """
cloudDensity = self.conditions.weather.clouds.density cloudDensity = self.conditions.weather.clouds.density or 0
precipitation = self.conditions.weather.clouds.precipitation precipitation = self.conditions.weather.clouds.precipitation or None
fog = self.conditions.weather.fog or None
icon = []
is_night = self.conditions.time_of_day == TimeOfDay.Night
time = 'night' if is_night else 'day'
if cloudDensity <= 0: if cloudDensity <= 0:
self.forecastClouds.setText('Sunny') self.forecastClouds.setText('Sunny')
icon = [time, 'clear']
if cloudDensity > 0 and cloudDensity < 3: if cloudDensity > 0 and cloudDensity < 3:
self.forecastClouds.setText('Partly Cloudy') self.forecastClouds.setText('Partly Cloudy')
icon = [time, 'partly-cloudy']
if cloudDensity > 3 and cloudDensity < 6: if cloudDensity >= 3 and cloudDensity < 5:
self.forecastClouds.setText('Mostly Cloudy') self.forecastClouds.setText('Mostly Cloudy')
icon = [time, 'partly-cloudy']
if cloudDensity > 6: if cloudDensity >= 5:
self.forecastClouds.setText('Totally Cloudy') self.forecastClouds.setText('Totally Cloudy')
icon = [time, 'partly-cloudy']
if precipitation == PydcsWeather.Preceptions.Rain: if precipitation == PydcsWeather.Preceptions.Rain:
self.forecastRain.setText('Rain') self.forecastRain.setText('Rain')
icon = [time, 'rain']
elif precipitation == PydcsWeather.Preceptions.Thunderstorm: elif precipitation == PydcsWeather.Preceptions.Thunderstorm:
self.forecastRain.setText('Thunderstorm') self.forecastRain.setText('Thunderstorm')
icon = [time, 'thunderstorm']
else: else:
self.forecastRain.setText('No Rain') self.forecastRain.setText('No Rain')
if not self.conditions.weather.fog: if not fog:
self.textLayout.removeWidget(self.forecastFog) self.forecastFog.setText('No fog')
else:
visvibilityNm = round(meter_to_nm(fog.visibility), 1)
self.forecastFog.setText('Fog vis: {}nm'.format(visvibilityNm))
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']
self.weather_icon.setPixmap(icon)
def updateDetailsBtn(self): def updateDetailsBtn(self):

View File

@ -504,10 +504,22 @@ QWidget[style="baseMenuHeader"]{
color:white; color:white;
}*/ }*/
QLabel[style="small"]{ QLabel[style="small"], QLabel[style="text-xs"]{
font-size: 8px; font-size: 8px;
} }
QLabel[style="text-sm"]{
font-size: 10px;
}
QLabel[style="text-md"] {
font-size: 12px;
}
QLabel[style="text-xl"] {
font-size: 14px;
}
QFrame[style="QConditionsWidget"] { QFrame[style="QConditionsWidget"] {
margin: 0px; margin: 0px;
border: 0px; border: 0px;
@ -521,4 +533,11 @@ QGroupBox[style="QWeatherWidget"] {
margin-right: 5px; margin-right: 5px;
margin-top: 1ex; margin-top: 1ex;
margin-bottom: 5px; margin-bottom: 5px;
}
QGroupBox[style="QWeatherWidget"] QLabel[style="text-sm"] {
padding: 0px;
margin: 0px;
font-size: 9px;
line-height: 9px;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B