timeruler: add context menu

Should have more stuff in it, this is a basic implementation
This commit is contained in:
itsmattkc
2020-10-12 00:19:01 +11:00
parent 3b6ebb6e30
commit 5b69137edf
7 changed files with 111 additions and 65 deletions
+5 -1
View File
@@ -42,6 +42,8 @@ SeekableWidget::SeekableWidget(QWidget* parent) :
// Set width of playhead marker
playhead_width_ = QFontMetricsWidth(fm, "H");
setContextMenuPolicy(Qt::CustomContextMenu);
}
void SeekableWidget::ConnectTimelinePoints(TimelinePoints *points)
@@ -78,7 +80,9 @@ const int &SeekableWidget::GetScroll() const
void SeekableWidget::mousePressEvent(QMouseEvent *event)
{
SeekToScreenPoint(event->pos().x());
if (event->button() == Qt::LeftButton) {
SeekToScreenPoint(event->pos().x());
}
}
void SeekableWidget::mouseMoveEvent(QMouseEvent *event)
+15
View File
@@ -27,6 +27,8 @@
#include "common/qtutils.h"
#include "config/config.h"
#include "core.h"
#include "widget/menu/menu.h"
#include "widget/menu/menushared.h"
OLIVE_NAMESPACE_ENTER
@@ -53,6 +55,9 @@ TimeRuler::TimeRuler(bool text_visible, bool cache_status_visible, QWidget* pare
// Force update if the default timecode display mode changes
connect(Core::instance(), &Core::TimecodeDisplayChanged, this, static_cast<void (TimeRuler::*)()>(&TimeRuler::update));
// Connect context menu
connect(this, &TimeRuler::customContextMenuRequested, this, &TimeRuler::ShowContextMenu);
}
void TimeRuler::SetPlaybackCache(PlaybackCache *cache)
@@ -297,6 +302,16 @@ int TimeRuler::CacheStatusHeight() const
return fontMetrics().height() / 4;
}
void TimeRuler::ShowContextMenu()
{
Menu m(this);
MenuShared::instance()->AddItemsForTimeRulerMenu(&m);
MenuShared::instance()->AboutToShowTimeRulerActions();
m.exec(QCursor::pos());
}
void TimeRuler::UpdateHeight()
{
int height = text_height();
+3
View File
@@ -64,6 +64,9 @@ private:
PlaybackCache* playback_cache_;
private slots:
void ShowContextMenu();
};
OLIVE_NAMESPACE_EXIT