Move color to TimelineMarker and make sure all instances of a marker update on color change

This commit is contained in:
Thomas Wilshaw
2021-10-22 22:15:50 +01:00
parent 562b0e3a7f
commit 575ce39696
5 changed files with 29 additions and 3 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ void Marker::ShowContextMenu() {
// Color menu
ColorLabelMenu color_coding_menu;
connect(&color_coding_menu, &ColorLabelMenu::ColorSelected, this, &Marker::SetColor);
connect(&color_coding_menu, &ColorLabelMenu::ColorSelected, this, &Marker::ColorChanged);
m.addMenu(&color_coding_menu);
m.exec(QCursor::pos());
+4 -1
View File
@@ -34,6 +34,9 @@ class Marker : public QWidget {
public:
Marker(QWidget* parent = nullptr);
public slots:
void SetColor(int c);
protected:
void paintEvent(QPaintEvent* event) override;
//virtual void mouseReleaseEvent(QMouseEvent* event) override;
@@ -42,6 +45,7 @@ class Marker : public QWidget {
signals:
//void MouseClicked();
//void MouseDoubleClicked();
void ColorChanged(int c);
private:
@@ -49,7 +53,6 @@ class Marker : public QWidget {
private slots:
void ShowContextMenu();
void SetColor(int c);
};
} // namespace olive
+3
View File
@@ -143,6 +143,9 @@ void SeekableWidget::addMarker(TimelineMarker* marker)
Marker *marker_widget = new Marker(this);
marker_map_.insert(marker, marker_widget);
connect(marker_widget, &Marker::ColorChanged, marker, &TimelineMarker::set_color);
connect(marker, &TimelineMarker::ColorChanged, marker_widget, &Marker::SetColor);
marker_widget->move(TimeToScreen(marker->time().in()), 20);
marker_widget->show();
}