From: Flavio Date: Fri, 18 Jul 2014 22:29:54 +0000 (+0200) Subject: Better context menu code, also working on Windows X-Git-Tag: 2.2~3 X-Git-Url: https://git.sur5r.net/?p=minitube;a=commitdiff_plain;h=52d1cfda8446577408104f8b10fabc3fa7b8c8f8 Better context menu code, also working on Windows --- diff --git a/src/channelview.cpp b/src/channelview.cpp index eef1a72..318f666 100644 --- a/src/channelview.cpp +++ b/src/channelview.cpp @@ -72,10 +72,6 @@ ChannelView::ChannelView(QWidget *parent) : QListView(parent), setMouseTracking(true); - setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), - SLOT(showContextMenu(const QPoint &))); - connect(this, SIGNAL(clicked(const QModelIndex &)), SLOT(itemActivated(const QModelIndex &))); connect(this, SIGNAL(entered(const QModelIndex &)), @@ -186,6 +182,13 @@ void ChannelView::disappear() { MainWindow::instance()->showActionInStatusBar(action, false); } +void ChannelView::mousePressEvent(QMouseEvent *event) { + if (event->button() == Qt::RightButton) + showContextMenu(event->pos()); + else + QListView::mousePressEvent(event); +} + void ChannelView::mouseMoveEvent(QMouseEvent *event) { QListView::mouseMoveEvent(event); const QModelIndex index = indexAt(event->pos()); diff --git a/src/channelview.h b/src/channelview.h index 1a6fd5a..f8fa206 100644 --- a/src/channelview.h +++ b/src/channelview.h @@ -42,6 +42,7 @@ public slots: void disappear(); protected: + void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void leaveEvent(QEvent *event); void paintEvent(QPaintEvent *event);