| 209 | } |
| 210 | |
| 211 | void MainApplication::UpdateValues() { |
| 212 | if(!g_WelcomeShown) { |
| 213 | const auto time_now = std::chrono::steady_clock::now(); |
| 214 | const auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(time_now - this->start_time).count(); |
| 215 | if(diff >= 1000) { |
| 216 | this->ShowNotification(cfg::Strings.GetString(320)); |
| 217 | g_WelcomeShown = true; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | const auto cur_time = hos::GetCurrentTime(g_Settings.json_settings.general.value().use_12h_time.value()); |
| 222 | const auto battery_val = hos::GetBatteryLevel(); |
| 223 | const auto is_charging = hos::IsCharging(); |
| 224 | if((this->cur_battery_val != battery_val) || !this->read_values_once) { |
| 225 | if(battery_val <= 10) { |
| 226 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/0.png")))); |
| 227 | } |
| 228 | else if((battery_val > 10) && (battery_val <= 20)) { |
| 229 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/10.png")))); |
| 230 | } |
| 231 | else if((battery_val > 20) && (battery_val <= 30)) { |
| 232 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/20.png")))); |
| 233 | } |
| 234 | else if((battery_val > 30) && (battery_val <= 40)) { |
| 235 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/30.png")))); |
| 236 | } |
| 237 | else if((battery_val > 40) && (battery_val <= 50)) { |
| 238 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/40.png")))); |
| 239 | } |
| 240 | else if((battery_val > 50) && (battery_val <= 60)) { |
| 241 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/50.png")))); |
| 242 | } |
| 243 | else if((battery_val > 60) && (battery_val <= 70)) { |
| 244 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/60.png")))); |
| 245 | } |
| 246 | else if((battery_val > 70) && (battery_val <= 80)) { |
| 247 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/70.png")))); |
| 248 | } |
| 249 | else if((battery_val > 80) && (battery_val <= 90)) { |
| 250 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/80.png")))); |
| 251 | } |
| 252 | else if((battery_val > 90) && (battery_val < 100)) { |
| 253 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/90.png")))); |
| 254 | } |
| 255 | else if(battery_val == 100) { |
| 256 | this->battery_img->SetImage(pu::sdl2::TextureHandle::New(pu::ui::render::LoadImageFromFile(g_Settings.PathForResource("/Battery/100.png")))); |
| 257 | } |
| 258 | this->battery_img->SetWidth(80); |
| 259 | this->battery_img->SetHeight(80); |
| 260 | this->battery_text->SetText(std::to_string(battery_val) + "%"); |
| 261 | this->cur_battery_val = battery_val; |
| 262 | } |
| 263 | if((this->cur_is_charging != is_charging) || !this->read_values_once) { |
| 264 | this->battery_charge_img->SetVisible(is_charging); |
| 265 | this->cur_is_charging = is_charging; |
| 266 | } |
| 267 | if((this->cur_time != cur_time) || !this->read_values_once) { |
| 268 | this->time_text->SetText(cur_time); |
no test coverage detected