Code cleanup
This commit is contained in:
@@ -131,10 +131,10 @@ void Marker::mousePressEvent(QMouseEvent* e)
|
||||
return;
|
||||
}
|
||||
if (e->button() == Qt::LeftButton || e->button() == Qt::RightButton) {
|
||||
static_cast<SeekableWidget*>(parent())->SeekToScreenPoint(this->x() + 4);
|
||||
SeekableParent()->SeekToScreenPoint(this->x() + 4);
|
||||
if (!active_) {
|
||||
if (e->modifiers() != Qt::ShiftModifier) {
|
||||
static_cast<SeekableWidget *>(parent())->DeselectAllMarkers();
|
||||
SeekableParent()->DeselectAllMarkers();
|
||||
}
|
||||
emit ActiveChanged(true);
|
||||
} else {
|
||||
@@ -160,19 +160,19 @@ void Marker::mouseMoveEvent(QMouseEvent* e)
|
||||
|
||||
int new_position = marker_start_x_ + e->globalPos().x() - click_position_.x();
|
||||
|
||||
rational marker_time = static_cast<SeekableWidget *>(parent())->ScreenToTime(new_position);
|
||||
rational marker_time = SeekableParent()->ScreenToTime(new_position);
|
||||
|
||||
if (Core::instance()->snapping()) {
|
||||
rational movement;
|
||||
static_cast<SeekableWidget *>(parent())->GetSnapService()->SnapPoint({marker_time}, &movement);
|
||||
SeekableParent()->GetSnapService()->SnapPoint({marker_time}, &movement);
|
||||
if (!movement.isNull()) {
|
||||
marker_time += movement;
|
||||
}
|
||||
|
||||
new_position = static_cast<SeekableWidget *>(parent())->TimeToScene(marker_time);
|
||||
new_position = SeekableParent()->TimeToScene(marker_time);
|
||||
}
|
||||
|
||||
if (new_position > -marker_width_ / 2 && new_position < static_cast<SeekableWidget *>(parent())->width() - marker_width_ / 2) {
|
||||
if (new_position > -marker_width_ / 2 && new_position < SeekableParent()->width() - marker_width_ / 2) {
|
||||
this->move(new_position-2, this->pos().y());
|
||||
repaint();
|
||||
}
|
||||
@@ -182,7 +182,7 @@ void Marker::mouseMoveEvent(QMouseEvent* e)
|
||||
void Marker::mouseReleaseEvent(QMouseEvent* e)
|
||||
{
|
||||
if (dragging_) {
|
||||
rational time = static_cast<SeekableWidget *>(parent())->SceneToTime(this->x()+4);
|
||||
rational time = SeekableParent()->SceneToTime(this->x() + 4);
|
||||
time = time < 0.0 ? 0.0 : time;
|
||||
emit TimeChanged(TimeRange(time, time));
|
||||
|
||||
@@ -192,6 +192,11 @@ void Marker::mouseReleaseEvent(QMouseEvent* e)
|
||||
drag_allowed_ = false;
|
||||
}
|
||||
|
||||
SeekableWidget* Marker::SeekableParent()
|
||||
{
|
||||
return static_cast<SeekableWidget *>(parent());
|
||||
}
|
||||
|
||||
void Marker::ShowContextMenu()
|
||||
{
|
||||
// Only show context menu if we clicked on the icon and not the label
|
||||
@@ -244,7 +249,7 @@ void Marker::SetName(QString s)
|
||||
|
||||
void Marker::SetTime(TimeRange time)
|
||||
{
|
||||
move(static_cast<SeekableWidget *>(parent())->TimeToScene(time.in())-2, y());
|
||||
move(SeekableParent()->TimeToScene(time.in())-2, y());
|
||||
}
|
||||
|
||||
} // namespace olive
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
class SeekableWidget;
|
||||
|
||||
class Marker : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -40,6 +42,8 @@ class Marker : public QWidget {
|
||||
|
||||
void Rename();
|
||||
|
||||
SeekableWidget* SeekableParent();
|
||||
|
||||
public slots:
|
||||
void SetColor(int c);
|
||||
void SetActive(bool active);
|
||||
@@ -51,7 +55,6 @@ class Marker : public QWidget {
|
||||
virtual void mousePressEvent(QMouseEvent* event) override;
|
||||
virtual void mouseMoveEvent(QMouseEvent* event) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
//virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
|
||||
|
||||
signals:
|
||||
//void MouseClicked();
|
||||
|
||||
Reference in New Issue
Block a user