]> git.sur5r.net Git - minitube/commitdiff
Better context menu code, also working on Windows
authorFlavio <flavio@odisseo.local>
Fri, 18 Jul 2014 22:29:54 +0000 (00:29 +0200)
committerFlavio <flavio@odisseo.local>
Fri, 18 Jul 2014 22:29:54 +0000 (00:29 +0200)
src/channelview.cpp
src/channelview.h

index eef1a7200fbd7ac7e7122826551c1cdc4fa6e9a8..318f66694e8549531339e106a76fc1c2bf70dc97 100644 (file)
@@ -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());
index 1a6fd5afd6bce94990147e5d202a99a8e3f03595..f8fa2067a81092905717009702a09b12ead17a5b 100644 (file)
@@ -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);