mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:00:04 +00:00
Add timeline controls to hotkeys
This commit is contained in:
parent
1b8d35ba3e
commit
7564a2af18
4 changed files with 63 additions and 2 deletions
|
|
@ -32,6 +32,15 @@ static const std::unordered_map<types::Hotkey, QKeySequence> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@ static const std::unordered_map<Hotkey, std::string> 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<Hotkey, std::string> hotkeyLongName_ {
|
||||
|
|
@ -42,6 +47,11 @@ static const std::unordered_map<Hotkey, std::string> 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_)
|
||||
|
|
|
|||
|
|
@ -26,10 +26,15 @@ enum class Hotkey
|
|||
MapZoomOut,
|
||||
ProductTiltDecrease,
|
||||
ProductTiltIncrease,
|
||||
TimelineStepBegin,
|
||||
TimelineStepBack,
|
||||
TimelinePlay,
|
||||
TimelineStepNext,
|
||||
TimelineStepEnd,
|
||||
Unknown
|
||||
};
|
||||
typedef scwx::util::
|
||||
Iterator<Hotkey, Hotkey::ChangeMapStyle, Hotkey::ProductTiltIncrease>
|
||||
Iterator<Hotkey, Hotkey::ChangeMapStyle, Hotkey::TimelineStepEnd>
|
||||
HotkeyIterator;
|
||||
|
||||
Hotkey GetHotkeyFromShortName(const std::string& name);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "animation_dock_widget.hpp"
|
||||
#include "ui_animation_dock_widget.h"
|
||||
|
||||
#include <scwx/qt/manager/hotkey_manager.hpp>
|
||||
#include <scwx/qt/settings/general_settings.hpp>
|
||||
#include <scwx/qt/util/time.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
|
@ -39,6 +40,9 @@ public:
|
|||
|
||||
AnimationDockWidget* self_;
|
||||
|
||||
std::shared_ptr<manager::HotkeyManager> 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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue