Added ability to jump between markers with Alt+Arrows in media view.

This commit is contained in:
23rd
2026-04-06 08:56:43 +03:00
parent 00bd28278d
commit 783ed506bd
2 changed files with 35 additions and 0 deletions
@@ -6261,6 +6261,38 @@ void OverlayWidget::handleKeyPress(not_null<QKeyEvent*> e) {
} else if (key == Qt::Key_Space) {
playbackPauseResume();
return;
} else if (modifiers.testFlag(Qt::AltModifier)
&& (key == Qt::Key_Left || key == Qt::Key_Right)
&& _streamed->controls
&& !_streamed->controls->timestamps().empty()) {
const auto &timestamps = _streamed->controls->timestamps();
const auto &state = _streamed->instance.info().video.state;
const auto duration = state.duration;
if (duration > 0) {
const auto progress = state.position
/ float64(duration);
const auto eps = 0.005;
if (key == Qt::Key_Right) {
for (const auto &ts : timestamps) {
if (ts.position > progress + eps) {
activateControls();
restartAtProgress(ts.position);
return;
}
}
} else {
for (auto i = int(timestamps.size()) - 1; i >= 0; --i) {
if (timestamps[i].position < progress - eps) {
activateControls();
restartAtProgress(timestamps[i].position);
return;
}
}
activateControls();
restartAtSeekPosition(0);
}
}
return;
} else if (_fullScreenVideo) {
if (key == Qt::Key_Escape) {
playbackToggleFullScreen();
@@ -72,6 +72,9 @@ public:
void setTimestamps(std::vector<TimestampData> timestamps);
void setInFullScreen(bool inFullScreen);
[[nodiscard]] bool hasTimestamps() const;
[[nodiscard]] auto &timestamps() const {
return _timestamps;
}
[[nodiscard]] bool hasMenu() const;
[[nodiscard]] bool dragging() const;