Prevent the animated background/foreground from restarting itself if the image is the exact same as the currently playing one
This commit is contained in:
		
							parent
							
								
									7378205523
								
							
						
					
					
						commit
						7e2ec58c7e
					
				@ -21,6 +21,7 @@ private:
 | 
			
		||||
  QWidget *m_parent;
 | 
			
		||||
  QMovie *m_movie;
 | 
			
		||||
  AOApplication *ao_app;
 | 
			
		||||
  QString last_image;
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -7,6 +7,7 @@ AOScene::AOScene(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)
 | 
			
		||||
  m_parent = parent;
 | 
			
		||||
  ao_app = p_ao_app;
 | 
			
		||||
  m_movie = new QMovie(this);
 | 
			
		||||
  last_image = "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AOScene::set_image(QString p_image)
 | 
			
		||||
@ -15,6 +16,9 @@ void AOScene::set_image(QString p_image)
 | 
			
		||||
  QString default_path = ao_app->get_default_background_path(p_image + ".png");
 | 
			
		||||
  QString animated_background_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image));
 | 
			
		||||
 | 
			
		||||
  if (file_exists(animated_background_path) && animated_background_path == last_image)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QPixmap background(background_path);
 | 
			
		||||
  QPixmap default_bg(default_path);
 | 
			
		||||
 | 
			
		||||
@ -32,11 +36,16 @@ void AOScene::set_image(QString p_image)
 | 
			
		||||
  {
 | 
			
		||||
    this->setMovie(m_movie);
 | 
			
		||||
    m_movie->start();
 | 
			
		||||
    last_image = animated_background_path;
 | 
			
		||||
  }
 | 
			
		||||
  else if (file_exists(background_path))
 | 
			
		||||
  {
 | 
			
		||||
    this->setPixmap(background.scaled(w, h));
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    this->setPixmap(default_bg.scaled(w, h));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AOScene::set_legacy_desk(QString p_image)
 | 
			
		||||
@ -48,6 +57,9 @@ void AOScene::set_legacy_desk(QString p_image)
 | 
			
		||||
  QString animated_desk_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image));
 | 
			
		||||
  QString default_path = ao_app->get_image_suffix(ao_app->get_default_background_path(p_image));
 | 
			
		||||
 | 
			
		||||
  if (file_exists(animated_desk_path) && animated_desk_path == last_image)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QPixmap f_desk;
 | 
			
		||||
 | 
			
		||||
  int vp_width = m_parent->width();
 | 
			
		||||
@ -73,6 +85,7 @@ void AOScene::set_legacy_desk(QString p_image)
 | 
			
		||||
  {
 | 
			
		||||
    this->setMovie(m_movie);
 | 
			
		||||
    m_movie->start();
 | 
			
		||||
    last_image = animated_desk_path;
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user