]> rtime.felk.cvut.cz Git - vajnamar/orte.git/blobdiff - orte/contrib/shape/MyQFrame.cpp
Shape: Add support to switch between scaling and rotation mode
[vajnamar/orte.git] / orte / contrib / shape / MyQFrame.cpp
index 8743270c62c88e3c0abe771dc451a4bfb08a733f..08b2140b8035b3a014f3a41f9bc8c8b1fc5c0a15 100644 (file)
@@ -8,12 +8,16 @@
 #include <QPolygon>
 #include <QMouseEvent>
 #include <QPaintEvent>
+#include <QKeyEvent>
 
 MyQFrame::MyQFrame( QWidget *parent)
         : QFrame( parent)
 {
     mousePressed=0;
     objects[0]=objects[1]=objects[2]=objects[3]=objects[4]=0;
+    rotation_mode=0;
+
+    setFocusPolicy(Qt::StrongFocus);
 
     connect(this,SIGNAL(changed()),this,SLOT(update()));
 }
@@ -92,3 +96,18 @@ void MyQFrame::mouseReleaseEvent (QMouseEvent *)
 {
     mousePressed=0;
 }
+void MyQFrame::keyPressEvent (QKeyEvent *e)
+{
+    if (e->key() == Qt::Key_Control)
+      rotation_mode=1;
+    else
+      QFrame::keyPressEvent(e);
+}
+
+void MyQFrame::keyReleaseEvent (QKeyEvent *e)
+{
+    if (e->key() == Qt::Key_Control)
+      rotation_mode=0;
+    else
+      QFrame::keyPressEvent(e);
+}