diff --git a/scwx-qt/source/scwx/qt/settings/hotkey_settings.cpp b/scwx-qt/source/scwx/qt/settings/hotkey_settings.cpp index c6aece74..0b22f9e9 100644 --- a/scwx-qt/source/scwx/qt/settings/hotkey_settings.cpp +++ b/scwx-qt/source/scwx/qt/settings/hotkey_settings.cpp @@ -32,6 +32,15 @@ static const std::unordered_map kDefaultHotkeys_ { QKeySequence {Qt::Key::Key_BracketLeft}}, {types::Hotkey::ProductTiltIncrease, QKeySequence {Qt::Key::Key_BracketRight}}, + {types::Hotkey::TimelineStepBegin, + QKeySequence {QKeyCombination {Qt::KeyboardModifier::ControlModifier, + Qt::Key::Key_Left}}}, + {types::Hotkey::TimelineStepBack, QKeySequence {Qt::Key::Key_Left}}, + {types::Hotkey::TimelinePlay, QKeySequence {Qt::Key::Key_Space}}, + {types::Hotkey::TimelineStepNext, QKeySequence {Qt::Key::Key_Right}}, + {types::Hotkey::TimelineStepEnd, + QKeySequence {QKeyCombination {Qt::KeyboardModifier::ControlModifier, + Qt::Key::Key_Right}}}, {types::Hotkey::Unknown, QKeySequence {}}}; static bool IsHotkeyValid(const std::string& value); @@ -107,7 +116,7 @@ bool operator==(const HotkeySettings& lhs, const HotkeySettings& rhs) static bool IsHotkeyValid(const std::string& value) { - return QKeySequence {QString::fromStdString(value)} + return QKeySequence::fromString(QString::fromStdString(value)) .toString() .toStdString() == value; } diff --git a/scwx-qt/source/scwx/qt/types/hotkey_types.cpp b/scwx-qt/source/scwx/qt/types/hotkey_types.cpp index b76c76a5..c0989888 100644 --- a/scwx-qt/source/scwx/qt/types/hotkey_types.cpp +++ b/scwx-qt/source/scwx/qt/types/hotkey_types.cpp @@ -26,6 +26,11 @@ static const std::unordered_map hotkeyShortName_ { {Hotkey::MapZoomOut, "map_zoom_out"}, {Hotkey::ProductTiltDecrease, "product_tilt_decrease"}, {Hotkey::ProductTiltIncrease, "product_tilt_increase"}, + {Hotkey::TimelineStepBegin, "timeline_step_begin"}, + {Hotkey::TimelineStepBack, "timeline_step_back"}, + {Hotkey::TimelinePlay, "timeline_play"}, + {Hotkey::TimelineStepNext, "timeline_step_next"}, + {Hotkey::TimelineStepEnd, "timeline_step_end"}, {Hotkey::Unknown, "?"}}; static const std::unordered_map hotkeyLongName_ { @@ -42,6 +47,11 @@ static const std::unordered_map hotkeyLongName_ { {Hotkey::MapZoomOut, "Map Zoom Out"}, {Hotkey::ProductTiltDecrease, "Product Tilt Decrease"}, {Hotkey::ProductTiltIncrease, "Product Tilt Increase"}, + {Hotkey::TimelineStepBegin, "Timeline Step Begin"}, + {Hotkey::TimelineStepBack, "Timeline Step Back"}, + {Hotkey::TimelinePlay, "Timeline Play/Pause"}, + {Hotkey::TimelineStepNext, "Timeline Step Next"}, + {Hotkey::TimelineStepEnd, "Timeline Step End"}, {Hotkey::Unknown, "?"}}; SCWX_GET_ENUM(Hotkey, GetHotkeyFromShortName, hotkeyShortName_) diff --git a/scwx-qt/source/scwx/qt/types/hotkey_types.hpp b/scwx-qt/source/scwx/qt/types/hotkey_types.hpp index 22699eb8..434a01b7 100644 --- a/scwx-qt/source/scwx/qt/types/hotkey_types.hpp +++ b/scwx-qt/source/scwx/qt/types/hotkey_types.hpp @@ -26,10 +26,15 @@ enum class Hotkey MapZoomOut, ProductTiltDecrease, ProductTiltIncrease, + TimelineStepBegin, + TimelineStepBack, + TimelinePlay, + TimelineStepNext, + TimelineStepEnd, Unknown }; typedef scwx::util:: - Iterator + Iterator HotkeyIterator; Hotkey GetHotkeyFromShortName(const std::string& name); diff --git a/scwx-qt/source/scwx/qt/ui/animation_dock_widget.cpp b/scwx-qt/source/scwx/qt/ui/animation_dock_widget.cpp index f19be01f..ccc6bdca 100644 --- a/scwx-qt/source/scwx/qt/ui/animation_dock_widget.cpp +++ b/scwx-qt/source/scwx/qt/ui/animation_dock_widget.cpp @@ -1,6 +1,7 @@ #include "animation_dock_widget.hpp" #include "ui_animation_dock_widget.h" +#include #include #include #include @@ -39,6 +40,9 @@ public: AnimationDockWidget* self_; + std::shared_ptr hotkeyManager_ { + manager::HotkeyManager::Instance()}; + types::AnimationState animationState_ {types::AnimationState::Pause}; types::MapTime viewType_ {types::MapTime::Live}; bool isLive_ {true}; @@ -220,6 +224,39 @@ void AnimationDockWidgetImpl::ConnectSignals() &QAbstractButton::clicked, self_, [this]() { Q_EMIT self_->AnimationStepEndSelected(); }); + + // Shortcuts + QObject::connect(hotkeyManager_.get(), + &manager::HotkeyManager::HotkeyPressed, + self_, + [this](types::Hotkey hotkey, bool /* isAutoRepeat */) + { + switch (hotkey) + { + case types::Hotkey::TimelineStepBegin: + Q_EMIT self_->AnimationStepBeginSelected(); + break; + + case types::Hotkey::TimelineStepBack: + Q_EMIT self_->AnimationStepBackSelected(); + break; + + case types::Hotkey::TimelinePlay: + Q_EMIT self_->AnimationPlaySelected(); + break; + + case types::Hotkey::TimelineStepNext: + Q_EMIT self_->AnimationStepNextSelected(); + break; + + case types::Hotkey::TimelineStepEnd: + Q_EMIT self_->AnimationStepEndSelected(); + break; + + default: + break; + } + }); } void AnimationDockWidget::UpdateAnimationState(types::AnimationState state)