Browse Source

Add a setting to disable the mouse, part of #46

Lionel CHAZALLON 9 years ago
parent
commit
e768dc55e0
3 changed files with 23 additions and 3 deletions
  1. 4 0
      resources/settings/settings_description.json
  2. 18 2
      src/ui/KonvergoWindow.cpp
  3. 1 1
      src/ui/KonvergoWindow.h

+ 4 - 0
resources/settings/settings_description.json

@@ -49,6 +49,10 @@
         "default": false,
         "hidden": true,
         "platforms": [ "oe_rpi" ]
+      },
+      {
+        "value": "disablemouse",
+        "default": false
       }
     ]
   },

+ 18 - 2
src/ui/KonvergoWindow.cpp

@@ -21,6 +21,16 @@ bool MouseEventFilter::eventFilter(QObject* watched, QEvent* event)
 {
   SystemComponent& system = SystemComponent::Get();
 
+  // ignore mouse events if mouse is disabled
+  if  (SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "disablemouse").toBool() &&
+       ((event->type() == QEvent::MouseMove) ||
+        (event->type() == QEvent::MouseButtonPress) ||
+        (event->type() == QEvent::MouseButtonRelease) ||
+        (event->type() == QEvent::MouseButtonDblClick)))
+  {
+    return true;
+  }
+
   if (event->type() == QEvent::KeyPress)
   {
     // In konvergo we intercept all keyboard events and translate them
@@ -83,7 +93,7 @@ KonvergoWindow::KonvergoWindow(QWindow* parent) : QQuickWindow(parent), m_debugL
   loadGeometry();
 
   connect(SettingsComponent::Get().getSection(SETTINGS_SECTION_MAIN), &SettingsSection::valuesUpdated,
-          this, &KonvergoWindow::updateFullscreenSetting);
+          this, &KonvergoWindow::updateMainSectionSettings);
 
   connect(this, &KonvergoWindow::visibilityChanged,
           this, &KonvergoWindow::onVisibilityChanged);
@@ -214,8 +224,14 @@ void KonvergoWindow::playerWindowVisible(bool visible)
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-void KonvergoWindow::updateFullscreenSetting(const QVariantMap& values)
+void KonvergoWindow::updateMainSectionSettings(const QVariantMap& values)
 {
+  // update mouse visibility if needed
+  if (values.find("disablemouse") != values.end())
+  {
+    SystemComponent::Get().setCursorVisibility(!SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "disablemouse").toBool());
+  }
+
   if (values.find("fullscreen") == values.end())
     return;
 

+ 1 - 1
src/ui/KonvergoWindow.h

@@ -56,7 +56,7 @@ private slots:
   void closingWindow();
   void enableVideoWindow();
   void onVisibilityChanged(QWindow::Visibility visibility);
-  void updateFullscreenSetting(const QVariantMap& values);
+  void updateMainSectionSettings(const QVariantMap& values);
   void updateFullscreenState();
   void onScreenCountChanged(int newCount);
   void handleHostCommand(QString hostCommand);