/** * @brief Sets the sprite model. * @param model The sprite model, or nullptr to remove any model. * This class does not take ownership on the model. * The model can be deleted safely. */ void SpritePreviewer::set_model(SpriteModel* model) { if (this->model != nullptr) { this->model->disconnect(this); this->model = nullptr; } this->model = model; if (model != nullptr) { connect(&model->get_selection_model(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(update_selection())); update_selection(); connect(model, SIGNAL(animation_frame_delay_changed(Index,uint32_t)), this, SLOT(update_frame_delay())); connect(model, SIGNAL(animation_image_changed(Index,QString)), this, SLOT(update_frames())); connect(model, SIGNAL(direction_position_changed(Index,QPoint)), this, SLOT(update_frames())); connect(model, SIGNAL(direction_size_changed(Index,QSize)), this, SLOT(update_frames())); connect(model, SIGNAL(direction_num_frames_changed(Index,int)), this, SLOT(update_frames())); connect(model, SIGNAL(direction_num_columns_changed(Index,int)), this, SLOT(update_frames())); connect(model, SIGNAL(direction_origin_changed(Index,QPoint)), this, SLOT(update_origin())); }
/** * @brief Sets the size of a direction. * * Emits direction_size_changed() if there is a change. * * @param index A direction index. * @param size The size to set. */ void SpriteModel::set_direction_size(const Index& index, const QSize& size) { if (!direction_exists(index)) { return; } SpriteAnimationDirectionData& direction = get_direction(index); if (Size::to_qsize(direction.get_size()) == size) { return; } direction.set_size(Size::to_solarus_size(size)); set_direction_image_dirty(index); emit direction_size_changed(index, size); }