updated to video creation
This commit is contained in:
@@ -7,14 +7,18 @@ from kivy.uix.textinput import TextInput
|
||||
from kivy.uix.filechooser import FileChooserIconView
|
||||
from kivy.uix.widget import Widget
|
||||
from kivy.uix.image import Image
|
||||
from kivy.uix.carousel import Carousel
|
||||
from kivy.uix.progressbar import ProgressBar
|
||||
from kivy.graphics import Color, Rectangle, Line
|
||||
from kivy.uix.scrollview import ScrollView
|
||||
from kivy.uix.popup import Popup
|
||||
from kivy.uix.gridlayout import GridLayout
|
||||
from kivy.properties import StringProperty
|
||||
from kivy.clock import Clock
|
||||
import os
|
||||
import json
|
||||
import shutil
|
||||
import threading
|
||||
from geopy.geocoders import Nominatim
|
||||
from config import RESOURCES_FOLDER
|
||||
|
||||
@@ -25,10 +29,91 @@ class PauseEditScreen(Screen):
|
||||
super().__init__(**kwargs)
|
||||
self.pauses = []
|
||||
self.on_save_callback = None
|
||||
self.loading_popup = None
|
||||
self.carousel = None
|
||||
|
||||
def on_pre_enter(self):
|
||||
"""Called when entering the screen"""
|
||||
self.build_pause_layout()
|
||||
self.show_loading_popup()
|
||||
# Delay the layout building to show loading popup first
|
||||
Clock.schedule_once(self.start_loading_process, 0.1)
|
||||
|
||||
def show_loading_popup(self):
|
||||
"""Show loading popup while building the layout"""
|
||||
layout = BoxLayout(orientation='vertical', spacing=20, padding=20)
|
||||
|
||||
# Loading animation/progress bar
|
||||
progress = ProgressBar(
|
||||
max=100,
|
||||
size_hint_y=None,
|
||||
height=20
|
||||
)
|
||||
|
||||
# Animate the progress bar
|
||||
def animate_progress(dt):
|
||||
if progress.value < 95:
|
||||
progress.value += 5
|
||||
else:
|
||||
progress.value = 10 # Reset for continuous animation
|
||||
|
||||
Clock.schedule_interval(animate_progress, 0.1)
|
||||
|
||||
loading_label = Label(
|
||||
text="Loading pause information...\nPlease wait",
|
||||
color=(1, 1, 1, 1),
|
||||
font_size=16,
|
||||
halign="center",
|
||||
text_size=(300, None)
|
||||
)
|
||||
|
||||
layout.add_widget(loading_label)
|
||||
layout.add_widget(progress)
|
||||
|
||||
self.loading_popup = Popup(
|
||||
title="Loading Pauses",
|
||||
content=layout,
|
||||
size_hint=(0.8, 0.3),
|
||||
auto_dismiss=False
|
||||
)
|
||||
self.loading_popup.open()
|
||||
|
||||
def start_loading_process(self, dt):
|
||||
"""Start the loading process in background"""
|
||||
# Run the heavy loading in a separate thread
|
||||
thread = threading.Thread(target=self.load_data_background)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
def load_data_background(self):
|
||||
"""Load pause data in background thread"""
|
||||
try:
|
||||
# Load pauses
|
||||
self.load_pauses()
|
||||
|
||||
# Pre-process location suggestions to speed up UI
|
||||
for pause in self.pauses:
|
||||
lat = pause["location"]["latitude"]
|
||||
lon = pause["location"]["longitude"]
|
||||
# Cache the location suggestion
|
||||
if 'location_suggestion' not in pause:
|
||||
pause['location_suggestion'] = self.suggest_location_name(lat, lon)
|
||||
|
||||
# Schedule UI update on main thread
|
||||
Clock.schedule_once(self.finish_loading, 0)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error loading pause data: {e}")
|
||||
Clock.schedule_once(self.finish_loading, 0)
|
||||
|
||||
def finish_loading(self, dt):
|
||||
"""Finish loading and build the UI"""
|
||||
try:
|
||||
self.build_pause_layout()
|
||||
finally:
|
||||
# Close loading popup
|
||||
if self.loading_popup:
|
||||
self.loading_popup.dismiss()
|
||||
self.loading_popup = None
|
||||
|
||||
def suggest_location_name(self, lat, lon):
|
||||
"""Simplified and improved location suggestion with focus on practical results"""
|
||||
|
||||
Reference in New Issue
Block a user