Allow markers to be selected
This commit is contained in:
@@ -31,7 +31,8 @@ namespace olive {
|
||||
|
||||
Marker::Marker(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
marker_color_(7) //green FIXME: add default color to config
|
||||
marker_color_(7), //green FIXME: add default color to config
|
||||
active_(false)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setMinimumSize(20, 20);
|
||||
@@ -40,6 +41,16 @@ Marker::Marker(QWidget *parent) :
|
||||
connect(this, &Marker::customContextMenuRequested, this, &Marker::ShowContextMenu);
|
||||
}
|
||||
|
||||
void Marker::set_active(bool active)
|
||||
{
|
||||
active_ = active;
|
||||
}
|
||||
|
||||
bool Marker::active()
|
||||
{
|
||||
return active_;
|
||||
}
|
||||
|
||||
void Marker::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QFontMetrics fm = fontMetrics();
|
||||
@@ -54,7 +65,11 @@ void Marker::paintEvent(QPaintEvent *event)
|
||||
int x = half_width; //3
|
||||
|
||||
QPainter p(this);
|
||||
p.setPen(Qt::black);
|
||||
if (active_) {
|
||||
p.setPen(Qt::white);
|
||||
} else {
|
||||
p.setPen(Qt::black);
|
||||
}
|
||||
p.setBrush(ColorCoding::GetColor(marker_color_).toQColor());
|
||||
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
@@ -73,6 +88,15 @@ void Marker::paintEvent(QPaintEvent *event)
|
||||
p.drawPolygon(points, 6);
|
||||
}
|
||||
|
||||
void Marker::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
active_ = !active_;
|
||||
update();
|
||||
emit markerSelected(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Marker::ShowContextMenu() {
|
||||
Menu m(this);
|
||||
|
||||
@@ -81,6 +105,9 @@ void Marker::ShowContextMenu() {
|
||||
connect(&color_coding_menu, &ColorLabelMenu::ColorSelected, this, &Marker::ColorChanged);
|
||||
m.addMenu(&color_coding_menu);
|
||||
|
||||
m.addSeparator();
|
||||
MenuShared::instance()->AddItemsForEditMenu(&m, false);
|
||||
|
||||
m.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user