mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-30 23:50:05 +00:00 
			
		
		
		
	Animation widget incorrectly displays auto update disabled when animating
This commit is contained in:
		
							parent
							
								
									93ae58424c
								
							
						
					
					
						commit
						55d9fe1da8
					
				
					 4 changed files with 61 additions and 17 deletions
				
			
		|  | @ -711,7 +711,10 @@ void MainWindowImpl::ConnectAnimationSignals() | ||||||
|            &manager::TimelineManager::AnimationStateUpdated, |            &manager::TimelineManager::AnimationStateUpdated, | ||||||
|            animationDockWidget_, |            animationDockWidget_, | ||||||
|            &ui::AnimationDockWidget::UpdateAnimationState); |            &ui::AnimationDockWidget::UpdateAnimationState); | ||||||
| 
 |    connect(timelineManager_.get(), | ||||||
|  |            &manager::TimelineManager::ViewTypeUpdated, | ||||||
|  |            animationDockWidget_, | ||||||
|  |            &ui::AnimationDockWidget::UpdateViewType); | ||||||
|    connect(timelineManager_.get(), |    connect(timelineManager_.get(), | ||||||
|            &manager::TimelineManager::LiveStateUpdated, |            &manager::TimelineManager::LiveStateUpdated, | ||||||
|            animationDockWidget_, |            animationDockWidget_, | ||||||
|  |  | ||||||
|  | @ -166,6 +166,8 @@ void TimelineManager::SetViewType(types::MapTime viewType) | ||||||
|       // If the selected view type is archive, select using the pinned time
 |       // If the selected view type is archive, select using the pinned time
 | ||||||
|       p->SelectTimeAsync(p->pinnedTime_); |       p->SelectTimeAsync(p->pinnedTime_); | ||||||
|    } |    } | ||||||
|  | 
 | ||||||
|  |    Q_EMIT ViewTypeUpdated(viewType); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void TimelineManager::SetLoopTime(std::chrono::minutes loopTime) | void TimelineManager::SetLoopTime(std::chrono::minutes loopTime) | ||||||
|  |  | ||||||
|  | @ -20,20 +20,34 @@ static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||||
| class AnimationDockWidgetImpl | class AnimationDockWidgetImpl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit AnimationDockWidgetImpl(AnimationDockWidget* self) : self_ {self} {} |    explicit AnimationDockWidgetImpl(AnimationDockWidget* self) : self_ {self} | ||||||
|  |    { | ||||||
|  |       static const QString prefix   = QObject::tr("Auto Update"); | ||||||
|  |       static const QString disabled = QObject::tr("Disabled"); | ||||||
|  |       static const QString enabled  = QObject::tr("Enabled"); | ||||||
|  | 
 | ||||||
|  |       enabledString_  = QString("%1: %2").arg(prefix).arg(enabled); | ||||||
|  |       disabledString_ = QString("%1: %2").arg(prefix).arg(disabled); | ||||||
|  |    } | ||||||
|    ~AnimationDockWidgetImpl() = default; |    ~AnimationDockWidgetImpl() = default; | ||||||
| 
 | 
 | ||||||
|    const QIcon kPauseIcon_ {":/res/icons/font-awesome-6/pause-solid.svg"}; |    const QIcon kPauseIcon_ {":/res/icons/font-awesome-6/pause-solid.svg"}; | ||||||
|    const QIcon kPlayIcon_ {":/res/icons/font-awesome-6/play-solid.svg"}; |    const QIcon kPlayIcon_ {":/res/icons/font-awesome-6/play-solid.svg"}; | ||||||
| 
 | 
 | ||||||
|  |    QString enabledString_; | ||||||
|  |    QString disabledString_; | ||||||
|  | 
 | ||||||
|    AnimationDockWidget* self_; |    AnimationDockWidget* self_; | ||||||
| 
 | 
 | ||||||
|    types::AnimationState animationState_ {types::AnimationState::Pause}; |    types::AnimationState animationState_ {types::AnimationState::Pause}; | ||||||
|  |    types::MapTime        viewType_ {types::MapTime::Live}; | ||||||
|  |    bool                  isLive_ {true}; | ||||||
| 
 | 
 | ||||||
|    std::chrono::sys_days selectedDate_ {}; |    std::chrono::sys_days selectedDate_ {}; | ||||||
|    std::chrono::seconds  selectedTime_ {}; |    std::chrono::seconds  selectedTime_ {}; | ||||||
| 
 | 
 | ||||||
|    void ConnectSignals(); |    void ConnectSignals(); | ||||||
|  |    void UpdateAutoUpdateLabel(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| AnimationDockWidget::AnimationDockWidget(QWidget* parent) : | AnimationDockWidget::AnimationDockWidget(QWidget* parent) : | ||||||
|  | @ -211,32 +225,56 @@ void AnimationDockWidgetImpl::ConnectSignals() | ||||||
| 
 | 
 | ||||||
| void AnimationDockWidget::UpdateAnimationState(types::AnimationState state) | void AnimationDockWidget::UpdateAnimationState(types::AnimationState state) | ||||||
| { | { | ||||||
|    // Update icon to opposite of state
 |    if (p->animationState_ != state) | ||||||
|    switch (state) |  | ||||||
|    { |    { | ||||||
|    case types::AnimationState::Pause: |       // Update icon to opposite of state
 | ||||||
|       ui->playButton->setIcon(p->kPlayIcon_); |       switch (state) | ||||||
|       break; |       { | ||||||
|  |       case types::AnimationState::Pause: | ||||||
|  |          ui->playButton->setIcon(p->kPlayIcon_); | ||||||
|  |          break; | ||||||
| 
 | 
 | ||||||
|    case types::AnimationState::Play: |       case types::AnimationState::Play: | ||||||
|       ui->playButton->setIcon(p->kPauseIcon_); |          ui->playButton->setIcon(p->kPauseIcon_); | ||||||
|       break; |          break; | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       p->animationState_ = state; | ||||||
|  |       p->UpdateAutoUpdateLabel(); | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void AnimationDockWidget::UpdateLiveState(bool isLive) | void AnimationDockWidget::UpdateLiveState(bool isLive) | ||||||
| { | { | ||||||
|    static const QString prefix   = tr("Auto Update"); |    if (p->isLive_ != isLive) | ||||||
|    static const QString disabled = tr("Disabled"); |  | ||||||
|    static const QString enabled  = tr("Enabled"); |  | ||||||
| 
 |  | ||||||
|    if (isLive) |  | ||||||
|    { |    { | ||||||
|       ui->autoUpdateLabel->setText(QString("%1: %2").arg(prefix).arg(enabled)); |       p->isLive_ = isLive; | ||||||
|  |       p->UpdateAutoUpdateLabel(); | ||||||
|  |    } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void AnimationDockWidget::UpdateViewType(types::MapTime viewType) | ||||||
|  | { | ||||||
|  |    if (p->viewType_ != viewType) | ||||||
|  |    { | ||||||
|  |       p->viewType_ = viewType; | ||||||
|  |       p->UpdateAutoUpdateLabel(); | ||||||
|  |    } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void AnimationDockWidgetImpl::UpdateAutoUpdateLabel() | ||||||
|  | { | ||||||
|  |    // Display "Auto Update: Enabled" if:
 | ||||||
|  |    // - The map is live, and auto-updating (map widget update)
 | ||||||
|  |    // - "Live" is selected, and the map is playing (timeline manager update)
 | ||||||
|  |    if (isLive_ || (viewType_ == types::MapTime::Live && | ||||||
|  |                    animationState_ == types::AnimationState::Play)) | ||||||
|  |    { | ||||||
|  |       self_->ui->autoUpdateLabel->setText(enabledString_); | ||||||
|    } |    } | ||||||
|    else |    else | ||||||
|    { |    { | ||||||
|       ui->autoUpdateLabel->setText(QString("%1: %2").arg(prefix).arg(disabled)); |       self_->ui->autoUpdateLabel->setText(disabledString_); | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -31,6 +31,7 @@ public: | ||||||
| public slots: | public slots: | ||||||
|    void UpdateAnimationState(types::AnimationState state); |    void UpdateAnimationState(types::AnimationState state); | ||||||
|    void UpdateLiveState(bool isLive); |    void UpdateLiveState(bool isLive); | ||||||
|  |    void UpdateViewType(types::MapTime viewType); | ||||||
| 
 | 
 | ||||||
| signals: | signals: | ||||||
|    void ViewTypeChanged(types::MapTime viewType); |    void ViewTypeChanged(types::MapTime viewType); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat