From cd12f05dc1bb958043631587acd2ab74e3de0238 Mon Sep 17 00:00:00 2001 From: Max Lapan Date: Tue, 16 Mar 2010 16:01:16 +0300 Subject: [PATCH] Context menu. --- mainwidget.cpp | 19 +++++++++++++++++++ mainwidget.hpp | 1 + 2 files changed, 20 insertions(+) diff --git a/mainwidget.cpp b/mainwidget.cpp index 5f4771c..8149f1f 100644 --- a/mainwidget.cpp +++ b/mainwidget.cpp @@ -155,3 +155,22 @@ void MainWidget::applySettings () else _timer->setInterval (1000 * 60 * _settings->updateInterval ()); } + + +void MainWidget::mousePressEvent (QMouseEvent *event) +{ + QMenu menu; + QAction *settingsAction, *updateAction, *todo; + + settingsAction = menu.addAction (tr ("Settings")); + updateAction = menu.addAction (tr ("Update")); + + todo = menu.exec (event->pos ()); + if (!todo) + return; + + if (todo == settingsAction) + settingsDialog (); + if (todo == updateAction) + _traffic->update (); +} diff --git a/mainwidget.hpp b/mainwidget.hpp index 9fb10cd..00df461 100644 --- a/mainwidget.hpp +++ b/mainwidget.hpp @@ -34,6 +34,7 @@ public slots: protected: void paintEvent (QPaintEvent *event); + void mousePressEvent (QMouseEvent *event); void updateSize (); void applySettings (); -- 1.7.9.5