[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kmahjongg/qgraphic] /: Add mouse wheel rotating view.
From:       Christian Krippendorf <Coding () Christian-Krippendorf ! de>
Date:       2013-01-03 17:47:15
Message-ID: 20130103174715.065BFA6091 () git ! kde ! org
[Download RAW message or body]

Git commit 3bdbcf5e579255287651e7bf185d5d4dfff5b561 by Christian Krippendorf.
Committed on 03/01/2013 at 18:46.
Pushed by krippendorf into branch 'qgraphic'.

Add mouse wheel rotating view.

M  +9    -0    GameScene.cpp
M  +9    -0    GameScene.h
M  +2    -0    kmahjongg.cpp

http://commits.kde.org/kmahjongg/3bdbcf5e579255287651e7bf185d5d4dfff5b561

diff --git a/GameScene.cpp b/GameScene.cpp
index 7cbcaa9..2865eea 100644
--- a/GameScene.cpp
+++ b/GameScene.cpp
@@ -225,3 +225,12 @@ void GameScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * pMouseEvent)
 {
     pMouseEvent->ignore();
 }
+
+void GameScene::wheelEvent(QGraphicsSceneWheelEvent* pMouseEvent)
+{
+    if (pMouseEvent->delta() < 0) {
+        emit rotateCW();
+    } else {
+        emit rotateCCW();
+    }
+}
diff --git a/GameScene.h b/GameScene.h
index b22f854..7f8b114 100644
--- a/GameScene.h
+++ b/GameScene.h
@@ -112,12 +112,21 @@ public:
     void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *pMouseEvent);
 
     /**
+     * Override from QGraphicsScene.
+     * Mouse wheel rotates view. */
+    void wheelEvent(QGraphicsSceneWheelEvent *pMouseEvent);
+
+    /**
      * Test if the item is selectable or not.
      *
      * @param pGameItem The game item to test.
      * @return True if selectable else false. */
     bool isSelectable(const GameItem * const pGameItem) const;
 
+signals:
+    void rotateCW();
+    void rotateCCW();
+
 private:
     /**
      * Initialize the m_pGameItemsArray. */
diff --git a/kmahjongg.cpp b/kmahjongg.cpp
index 0132748..40b7b3c 100644
--- a/kmahjongg.cpp
+++ b/kmahjongg.cpp
@@ -124,6 +124,8 @@ KMahjongg::KMahjongg(QWidget *parent)
                 SLOT(showItemNumber(int, int, int)));
     connect(m_pGameView, SIGNAL(gameOver(unsigned short, unsigned short)), this,
                 SLOT(gameOver(unsigned short, unsigned short)));
+    connect(m_pGameScene, SIGNAL(rotateCW()), m_pGameView, SLOT(angleSwitchCW()));
+    connect(m_pGameScene, SIGNAL(rotateCCW()), m_pGameView, SLOT(angleSwitchCCW()));
 
 
     mFinished = false;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic