mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 20:30:05 +00:00
Adding animation control signals
This commit is contained in:
parent
b50bfc564f
commit
5453997208
2 changed files with 134 additions and 3 deletions
|
|
@ -15,16 +15,31 @@ namespace ui
|
|||
static const std::string logPrefix_ = "scwx::qt::ui::animation_dock_widget";
|
||||
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||
|
||||
enum class AnimationState
|
||||
{
|
||||
Play,
|
||||
Pause
|
||||
};
|
||||
|
||||
class AnimationDockWidgetImpl
|
||||
{
|
||||
public:
|
||||
explicit AnimationDockWidgetImpl() = default;
|
||||
~AnimationDockWidgetImpl() = default;
|
||||
explicit AnimationDockWidgetImpl(AnimationDockWidget* self) : self_ {self} {}
|
||||
~AnimationDockWidgetImpl() = default;
|
||||
|
||||
AnimationDockWidget* self_;
|
||||
|
||||
AnimationState animationState_ {AnimationState::Pause};
|
||||
|
||||
std::chrono::sys_days selectedDate_ {};
|
||||
std::chrono::seconds selectedTime_ {};
|
||||
|
||||
void ConnectSignals();
|
||||
};
|
||||
|
||||
AnimationDockWidget::AnimationDockWidget(QWidget* parent) :
|
||||
QDockWidget(parent),
|
||||
p {std::make_unique<AnimationDockWidgetImpl>()},
|
||||
p {std::make_unique<AnimationDockWidgetImpl>(this)},
|
||||
ui(new Ui::AnimationDockWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
@ -66,6 +81,9 @@ AnimationDockWidget::AnimationDockWidget(QWidget* parent) :
|
|||
|
||||
// Evaluate every 15 seconds, every second is unnecessary
|
||||
maxDateTimer->start(15000);
|
||||
|
||||
// Connect widget signals
|
||||
p->ConnectSignals();
|
||||
}
|
||||
|
||||
AnimationDockWidget::~AnimationDockWidget()
|
||||
|
|
@ -73,6 +91,101 @@ AnimationDockWidget::~AnimationDockWidget()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void AnimationDockWidgetImpl::ConnectSignals()
|
||||
{
|
||||
// View type
|
||||
QObject::connect(self_->ui->liveViewRadioButton,
|
||||
&QRadioButton::toggled,
|
||||
self_,
|
||||
[this](bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
emit self_->ViewTypeChanged(types::MapTime::Live);
|
||||
}
|
||||
});
|
||||
QObject::connect(self_->ui->archiveViewRadioButton,
|
||||
&QRadioButton::toggled,
|
||||
self_,
|
||||
[this](bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
emit self_->ViewTypeChanged(types::MapTime::Archive);
|
||||
}
|
||||
});
|
||||
|
||||
// Date/time controls
|
||||
QObject::connect( //
|
||||
self_->ui->dateEdit,
|
||||
&QDateTimeEdit::dateChanged,
|
||||
self_,
|
||||
[this](QDate date)
|
||||
{
|
||||
if (date.isValid())
|
||||
{
|
||||
selectedDate_ = date.toStdSysDays();
|
||||
emit self_->DateTimeChanged(selectedDate_ + selectedTime_);
|
||||
}
|
||||
});
|
||||
QObject::connect(
|
||||
self_->ui->timeEdit,
|
||||
&QDateTimeEdit::timeChanged,
|
||||
self_,
|
||||
[this](QTime time)
|
||||
{
|
||||
if (time.isValid())
|
||||
{
|
||||
selectedTime_ =
|
||||
std::chrono::seconds(time.msecsSinceStartOfDay() / 1000);
|
||||
emit self_->DateTimeChanged(selectedDate_ + selectedTime_);
|
||||
}
|
||||
});
|
||||
|
||||
// Loop controls
|
||||
QObject::connect(self_->ui->loopTimeSpinBox,
|
||||
&QSpinBox::valueChanged,
|
||||
self_,
|
||||
[this](int i)
|
||||
{ emit self_->LoopTimeChanged(std::chrono::minutes(i)); });
|
||||
QObject::connect(self_->ui->loopSpeedSpinBox,
|
||||
&QDoubleSpinBox::valueChanged,
|
||||
self_,
|
||||
[this](double d) { emit self_->LoopSpeedChanged(d); });
|
||||
|
||||
// Animation controls
|
||||
QObject::connect(self_->ui->beginButton,
|
||||
&QAbstractButton::clicked,
|
||||
self_,
|
||||
[this]() { emit self_->AnimationStepBeginSelected(); });
|
||||
QObject::connect(self_->ui->stepBackButton,
|
||||
&QAbstractButton::clicked,
|
||||
self_,
|
||||
[this]() { emit self_->AnimationStepBackSelected(); });
|
||||
QObject::connect(self_->ui->playButton,
|
||||
&QAbstractButton::clicked,
|
||||
self_,
|
||||
[this]()
|
||||
{
|
||||
if (animationState_ == AnimationState::Pause)
|
||||
{
|
||||
emit self_->AnimationPlaySelected();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit self_->AnimationPauseSelected();
|
||||
}
|
||||
});
|
||||
QObject::connect(self_->ui->stepNextButton,
|
||||
&QAbstractButton::clicked,
|
||||
self_,
|
||||
[this]() { emit self_->AnimationStepNextSelected(); });
|
||||
QObject::connect(self_->ui->endButton,
|
||||
&QAbstractButton::clicked,
|
||||
self_,
|
||||
[this]() { emit self_->AnimationStepEndSelected(); });
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/types/map_types.hpp>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
namespace Ui
|
||||
|
|
@ -24,6 +28,20 @@ public:
|
|||
explicit AnimationDockWidget(QWidget* parent = nullptr);
|
||||
~AnimationDockWidget();
|
||||
|
||||
signals:
|
||||
void ViewTypeChanged(types::MapTime viewType);
|
||||
void DateTimeChanged(std::chrono::system_clock::time_point dateTime);
|
||||
|
||||
void LoopTimeChanged(std::chrono::minutes loopTime);
|
||||
void LoopSpeedChanged(double loopSpeed);
|
||||
|
||||
void AnimationStepBeginSelected();
|
||||
void AnimationStepBackSelected();
|
||||
void AnimationPauseSelected();
|
||||
void AnimationPlaySelected();
|
||||
void AnimationStepNextSelected();
|
||||
void AnimationStepEndSelected();
|
||||
|
||||
private:
|
||||
friend class AnimationDockWidgetImpl;
|
||||
std::unique_ptr<AnimationDockWidgetImpl> p;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue