summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSebastien Braun2010-10-05 15:32:11 +0200
committerSebastien Braun2010-10-05 18:15:51 +0200
commit21e7bf3b7579c4d9a5cf747ddd64f2fcfa2bf6bb (patch)
tree6bf660a09b3b682af4ba9dd732994ace3e829387 /src/gui
parentImplement example privileged SayHelloHandler. (diff)
downloadpvs-21e7bf3b7579c4d9a5cf747ddd64f2fcfa2bf6bb.tar.gz
pvs-21e7bf3b7579c4d9a5cf747ddd64f2fcfa2bf6bb.tar.xz
pvs-21e7bf3b7579c4d9a5cf747ddd64f2fcfa2bf6bb.zip
Implement context menu in pvsmgr[touch] by pressing the Menu key for 5 seconds.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/frame.cpp67
-rw-r--r--src/gui/frame.h2
2 files changed, 64 insertions, 5 deletions
diff --git a/src/gui/frame.cpp b/src/gui/frame.cpp
index 32257ec..ccc49cb 100644
--- a/src/gui/frame.cpp
+++ b/src/gui/frame.cpp
@@ -19,12 +19,14 @@
*/
#include <src/input/inputEvent.h>
+#include <src/input/inputHandlerChain.h>
#include "frame.h"
#include <src/gui/mainWindow.h>
#include <iostream>
#include <QPixmap>
#define MOUSE_MOTION_SEND_INTERVAL 100 /* msecs */
+#define SPECIAL_EVENT_WAIT_TIME 5000 /* msecs */
Frame::Frame(const QString & text, QWidget * parent) :
QLabel(parent), _clientVNCThread(0)
@@ -73,6 +75,11 @@ Frame::Frame(const QString & text, QWidget * parent) :
_mousePositionChanged = true;
+ _specialEventTimer = new QTimer(this);
+ _specialEventTimer->setInterval(SPECIAL_EVENT_WAIT_TIME);
+ _specialEventTimer->setSingleShot(true);
+ connect(_specialEventTimer, SIGNAL(timeout()), this, SLOT(showSpecialEventMenu()));
+
}
Frame::~Frame()
@@ -499,9 +506,18 @@ void Frame::keyPressEvent(QKeyEvent* event)
{
if(_remoteControlEnabled)
{
- // The action of the keyboard may depend on the position of the pointer
- sendMouseMotionEvent();
- sendInputEvent(InputEvent::keyboardPress(event->key(), event->modifiers()));
+ if(event->key() == Qt::Key_Menu)
+ {
+ qDebug("Menu has been pressed");
+ if(!event->isAutoRepeat())
+ _specialEventTimer->start();
+ }
+ else
+ {
+ // The action of the keyboard may depend on the position of the pointer
+ sendMouseMotionEvent();
+ sendInputEvent(InputEvent::keyboardPress(event->key(), event->modifiers()));
+ }
}
else
{
@@ -513,9 +529,27 @@ void Frame::keyReleaseEvent(QKeyEvent* event)
{
if(_remoteControlEnabled)
{
- // The action of the keyboard may depend on the position of the pointer
sendMouseMotionEvent();
- sendInputEvent(InputEvent::keyboardRelease(event->key(), event->modifiers()));
+ if(event->key() == Qt::Key_Menu)
+ {
+ if(!event->isAutoRepeat())
+ {
+ qDebug("Menu has been released");
+ if(_specialEventTimer->isActive())
+ {
+ qDebug("Pressing key on client");
+ // Pressing the key has been deferred, so do it now:
+ sendInputEvent(InputEvent::keyboardPress(event->key(), event->modifiers()));
+ }
+ sendInputEvent(InputEvent::keyboardRelease(event->key(), event->modifiers()));
+ _specialEventTimer->stop();
+ }
+ }
+ else
+ {
+ // The action of the keyboard may depend on the position of the pointer
+ sendInputEvent(InputEvent::keyboardRelease(event->key(), event->modifiers()));
+ }
}
else
{
@@ -550,3 +584,26 @@ bool Frame::event(QEvent* event)
}
return QLabel::event(event);
}
+
+void Frame::showSpecialEventMenu()
+{
+ qDebug("Trying to show menu...");
+ QMenu* menu = new QMenu(this);
+ QList<SpecialInputEventDescription> specialEvents = privileged_handler_chain::describe();
+ QList<SpecialInputEventDescription>::iterator iter;
+ int i;
+ for(i = 0, iter = specialEvents.begin();
+ iter != specialEvents.end();
+ iter++, i++)
+ {
+ QAction* act = menu->addAction((*iter).descriptionString);
+ act->setData(i);
+ }
+ QAction* selected = menu->exec(QCursor::pos());
+ if(selected)
+ {
+ int index = selected->data().toInt();
+ sendInputEvent(specialEvents.at(index).toEvent());
+ }
+ delete menu;
+}
diff --git a/src/gui/frame.h b/src/gui/frame.h
index 19b330a..8271670 100644
--- a/src/gui/frame.h
+++ b/src/gui/frame.h
@@ -78,6 +78,7 @@ private Q_SLOTS:
void remoteControlClicked();
void remoteControlAllClicked();
void sendMouseMotionEvent();
+ void showSpecialEventMenu();
signals:
void clicked();
@@ -107,6 +108,7 @@ private:
bool _mousePositionChanged;
QTimer* _mouseMotionEventTimer;
bool _mouseOver;
+ QTimer* _specialEventTimer;
QPoint rescalePosition(QPointF guiPosition);
void updateMousePosition(QMouseEvent* event);
void sendInputEvent(InputEvent const&);