[kde-doc-english] playground/utils/synaptiks

Sebastian Wiesner basti.wiesner at gmx.net
Mon Mar 8 21:04:08 CET 2010


SVN commit 1100834 by swiesner:

FEATURE: Implemented cursor motion speed settings
GUI: Added page with cursor motion speed settings to touchpad configuration
Added minimumSpeed, maximumSpeed and accelerationFactor properties to Touchpad

 M  +18 -0     daemon/org.kde.Touchpad.xml  
 M  +2 -0      daemon/synaptiksdaemon.cpp  
 M  +36 -0     daemon/touchpad.cpp  
 M  +98 -0     daemon/touchpad.h  
 M  +24 -0     daemon/touchpadadaptor.cpp  
 M  +9 -0      daemon/touchpadadaptor.h  
 M  +1 -0      kcmodule/CMakeLists.txt  
 M  +1 -0      kcmodule/synaptikskcm.cpp  
 M  +22 -0     kcmodule/synaptikswidgets.cpp  
 M  +10 -0     kcmodule/synaptikswidgets.h  
 A             kcmodule/ui/motionpage.ui  
 M  +21 -0     synaptiks.kcfg  


--- trunk/playground/utils/synaptiks/daemon/org.kde.Touchpad.xml #1100833:1100834
@@ -10,6 +10,24 @@
     <method name="setOn">
       <arg name="on" type="b" direction="in"/>
     </method>
+    <method name="minimumSpeed">
+      <arg type="d" direction="out"/>
+    </method>
+    <method name="setMinimumSpeed">
+      <arg name="speed" type="d" direction="in"/>
+    </method>
+    <method name="maximumSpeed">
+      <arg type="d" direction="out"/>
+    </method>
+    <method name="setMaximumSpeed">
+      <arg name="speed" type="d" direction="in"/>
+    </method>
+    <method name="accelerationFactor">
+      <arg type="d" direction="out"/>
+    </method>
+    <method name="setAccelerationFactor">
+      <arg name="accel" type="d" direction="in"/>
+    </method>
     <method name="circularScrolling">
       <arg type="b" direction="out"/>
     </method>
--- trunk/playground/utils/synaptiks/daemon/synaptiksdaemon.cpp #1100833:1100834
@@ -238,6 +238,8 @@
     names
         // general configuration
         << "CircularTouchpad"
+        // motion configuration
+        << "MinimumSpeed" << "MaximumSpeed" << "AccelerationFactor"
         // scrolling configuration
         << "CircularScrolling" << "CircularScrollingTrigger"
         << "HorizontalTwoFingerScrolling" << "VerticalTwoFingerScrolling"
--- trunk/playground/utils/synaptiks/daemon/touchpad.cpp #1100833:1100834
@@ -36,6 +36,7 @@
 
 
 static const char OFF[] = "Synaptics Off";
+static const char MOVE_SPEED[] = "Synaptics Move Speed";
 static const char CIRCULAR_SCROLLING[] = "Synaptics Circular Scrolling";
 static const char CIRCULAR_SCROLLING_TRIGGER[] =
     "Synaptics Circular Scrolling Trigger";
@@ -49,6 +50,11 @@
 static const char CIRCULAR_PAD[] = "Synaptics Circular Pad";
 static const char CAPABILITIES[] = "Synaptics Capabilities";
 
+enum MoveSpeedItem {
+    MinimumItem = 0,
+    MaximumItem = 1,
+    AccelerationItem = 2,
+};
 
 enum EdgeSrollingItem {
     VerticalEdgeItem = 0,
@@ -126,6 +132,36 @@
     d->device->setProperty(OFF, !on);
 }
 
+float Touchpad::minimumSpeed() const {
+    Q_D(const Touchpad);
+    return d->device->property<float>(MOVE_SPEED, MinimumItem);
+}
+
+void Touchpad::setMinimumSpeed(float speed) {
+    Q_D(Touchpad);
+    d->device->setProperty(MOVE_SPEED, speed, MinimumItem);
+}
+
+float Touchpad::maximumSpeed() const {
+    Q_D(const Touchpad);
+    return d->device->property<float>(MOVE_SPEED, MaximumItem);
+}
+
+void Touchpad::setMaximumSpeed(float speed) {
+    Q_D(Touchpad);
+    d->device->setProperty(MOVE_SPEED, speed, MaximumItem);
+}
+
+float Touchpad::accelerationFactor() const {
+    Q_D(const Touchpad);
+    return d->device->property<float>(MOVE_SPEED, AccelerationItem);
+}
+
+void Touchpad::setAccelerationFactor(float accel) {
+    Q_D(Touchpad);
+    d->device->setProperty(MOVE_SPEED, accel, AccelerationItem);
+}
+
 bool Touchpad::circularScrolling() const {
     Q_D(const Touchpad);
     return d->device->property<bool>(CIRCULAR_SCROLLING, 0);
--- trunk/playground/utils/synaptiks/daemon/touchpad.h #1100833:1100834
@@ -119,6 +119,56 @@
                    DESIGNABLE false)
 
         /**
+         * @brief The minimum speed of cursor motion.
+         *
+         * This property defines the scaling between touchpad coordinates
+         * and screen coordinates at slow finger movement.  In other words,
+         * if the finger is moved very slow across the touchpad, this value
+         * will be used to scale touchpad coordinates to screen coordinates.
+         *
+         * @sa setMinimumSpeed(float)
+         * @sa minimumSpeed()
+         * @sa maximumSpeed
+         * @sa accelerationFactor
+         */
+        Q_PROPERTY(float minimumSpeed READ minimumSpeed
+                   WRITE setMinimumSpeed DESIGNABLE false)
+
+        /**
+         * @brief The maximum speed of cursor motion.
+         *
+         * This property defines the scaling between touchpad coordinates
+         * and screen coordinates at fast finger movement.  In other words,
+         * if the finger is moved very fast across the touchpad, this value
+         * will be used to scale touchpad coordinates to screen coordinates.
+         *
+         * @sa setMaximumSpeed(float)
+         * @sa maximumSpeed()
+         * @sa minimumSpeed
+         * @sa accelerationFactor
+         */
+        Q_PROPERTY(float maximumSpeed READ maximumSpeed
+                   WRITE setMaximumSpeed DESIGNABLE false)
+
+        /**
+         * @brief The scaling between #minimumSpeed and #maximumSpeed.
+         *
+         * This property defines, how the pointer is accelerated between
+         * #minimumSpeed and #maximumSpeed as the finger speed increases on
+         * the touchpad.
+         *
+         * If #minimumSpeed and #maximumSpeed have the same value,
+         * acceleration is disabled, and this property has no effect.
+         *
+         * @sa setAccelerationFactor(float)
+         * @sa accelerationFactor()
+         * @sa minimumSpeed
+         * @sa maximumSpeed
+         */
+        Q_PROPERTY(float accelerationFactor READ accelerationFactor
+                   WRITE setAccelerationFactor DESIGNABLE false)
+
+        /**
          * @brief Whether circular scrolling is enabled or not.
          *
          * If circular scrolling is enabled, the user can scroll by moving
@@ -573,6 +623,54 @@
         Q_SCRIPTABLE void setOn(bool on);
 
         /**
+         * @brief Return the minimum motion speed.
+         *
+         * @return the minimum motion speed
+         * @sa minimumSpeed
+         */
+        Q_SCRIPTABLE float minimumSpeed() const;
+
+        /**
+         * @brief Set the minimum motion speed
+         *
+         * @param speed the speed value
+         * @sa minimumSpeed
+         */
+        Q_SCRIPTABLE void setMinimumSpeed(float speed);
+
+        /**
+         * @brief Return the maximum motion speed.
+         *
+         * @return the maximum motion speed
+         * @sa maximumSpeed
+         */
+        Q_SCRIPTABLE float maximumSpeed() const;
+
+        /**
+         * @brief Set the maximum motion speed
+         *
+         * @param speed the speed value
+         * @sa maximumSpeed
+         */
+        Q_SCRIPTABLE void setMaximumSpeed(float speed);
+
+        /**
+         * @brief Get the acceleration factor.
+         *
+         * @return the acceleration factor
+         * @sa accelerationFactor
+         */
+        Q_SCRIPTABLE float accelerationFactor() const;
+
+        /**
+         * @brief Set the acceleration factor.
+         *
+         * @param accel the acceleration factor
+         * @sa accelerationFactor
+         */
+        Q_SCRIPTABLE void setAccelerationFactor(float accel);
+
+        /**
          * @brief Is circular scrolling enabled?
          *
          * @return @c true, if circular scrolling is enabled, @c false
--- trunk/playground/utils/synaptiks/daemon/touchpadadaptor.cpp #1100833:1100834
@@ -56,6 +56,30 @@
     this->setPropertyOrDBusError("on", on);
 }
 
+double TouchpadAdaptor::minimumSpeed() const {
+    return this->propertyOrDBusError("minimumSpeed").toDouble();
+}
+
+void TouchpadAdaptor::setMinimumSpeed(double speed) {
+    this->setPropertyOrDBusError("minimumSpeed", speed);
+}
+
+double TouchpadAdaptor::maximumSpeed() const {
+    return this->propertyOrDBusError("maximumSpeed").toDouble();
+}
+
+void TouchpadAdaptor::setMaximumSpeed(double speed) {
+    this->setPropertyOrDBusError("maximumSpeed", speed);
+}
+
+double TouchpadAdaptor::accelerationFactor() const {
+    return this->propertyOrDBusError("accelerationFactor").toDouble();
+}
+
+void TouchpadAdaptor::setAccelerationFactor(double accel) {
+    this->setPropertyOrDBusError("accelerationFactor", accel);
+}
+
 bool TouchpadAdaptor::circularScrolling() const {
     return this->propertyOrDBusError("circularScrolling").toBool();
 }
--- trunk/playground/utils/synaptiks/daemon/touchpadadaptor.h #1100833:1100834
@@ -56,6 +56,15 @@
         bool isOn() const;
         void setOn(bool on);
 
+        double minimumSpeed() const;
+        void setMinimumSpeed(double speed);
+
+        double maximumSpeed() const;
+        void setMaximumSpeed(double speed);
+
+        double accelerationFactor() const;
+        void setAccelerationFactor(double accel);
+
         bool circularScrolling() const;
         void setCircularScrolling(bool enabled);
 
--- trunk/playground/utils/synaptiks/kcmodule/CMakeLists.txt #1100833:1100834
@@ -7,6 +7,7 @@
 kde4_add_ui_files(kcm_synaptiks_sources
   ui/autotouchpadcontrolpage.ui
   ui/generalpage.ui
+  ui/motionpage.ui
   ui/scrollingpage.ui
   ui/tappingpage.ui
   ui/notificationspage.ui
--- trunk/playground/utils/synaptiks/kcmodule/synaptikskcm.cpp #1100833:1100834
@@ -106,6 +106,7 @@
     KTabWidget *touchpadConfig = new KTabWidget(configWidget);
     QList<QWidget *> pages;
     pages << new GeneralPage(configWidget)
+          << new MotionPage(configWidget)
           << new ScrollingPage(configWidget)
           << new TappingPage(configWidget);
     foreach (QWidget *page, pages) {
--- trunk/playground/utils/synaptiks/kcmodule/synaptikswidgets.cpp #1100833:1100834
@@ -32,6 +32,7 @@
 #include "ui_touchpadinformationpage.h"
 #include "ui_autotouchpadcontrolpage.h"
 #include "ui_generalpage.h"
+#include "ui_motionpage.h"
 #include "ui_scrollingpage.h"
 #include "ui_tappingpage.h"
 #include "ui_notificationspage.h"
@@ -126,6 +127,27 @@
     ui.setupUi(this);
 }
 
+MotionPage::MotionPage(QWidget *parent): QWidget(parent) {
+    Ui::MotionPage ui;
+    ui.setupUi(this);
+    this->connect(ui.kcfg_MinimumSpeed, SIGNAL(valueChanged(double)),
+                  SLOT(disableAccelerationFactor()));
+    this->connect(ui.kcfg_MaximumSpeed, SIGNAL(valueChanged(double)),
+                  SLOT(disableAccelerationFactor()));
+}
+
+void MotionPage::disableAccelerationFactor() {
+    QRegExp pattern("kcfg_.+Speed");
+    QList<KDoubleNumInput*> speedInputs =
+        this->findChildren<KDoubleNumInput*>(pattern);
+    Q_ASSERT(speedInputs.size() == 2);
+    KDoubleNumInput *accelFactor = this->findChild<KDoubleNumInput*>(
+            "kcfg_AccelerationFactor");
+    Q_ASSERT(accelFactor);
+    accelFactor->setDisabled(
+        speedInputs[0]->value() == speedInputs[1]->value());
+}
+
 ScrollingPage::ScrollingPage(QWidget *parent): QWidget(parent) {
     Ui::ScrollingPage ui;
     ui.setupUi(this);
--- trunk/playground/utils/synaptiks/kcmodule/synaptikswidgets.h #1100833:1100834
@@ -61,6 +61,16 @@
         GeneralPage(QWidget *parent=0);
     };
 
+    class MotionPage: public QWidget {
+        Q_OBJECT
+
+    public:
+        MotionPage(QWidget *parent=0);
+
+    public Q_SLOTS:
+        void disableAccelerationFactor();
+    };
+
     class ScrollingPage: public QWidget {
         Q_OBJECT
 
--- trunk/playground/utils/synaptiks/synaptiks.kcfg #1100833:1100834
@@ -53,6 +53,27 @@
       <default>false</default>
     </entry>
   </group>
+  <group name="Motion">
+    <entry name="MinimumSpeed" type="Double">
+      <label>Minimum cursor motion speed</label>
+      <default>0.5</default>
+      <min>0</min>
+      <max>2</max>
+    </entry>
+    <entry name="MaximumSpeed" type="Double">
+      <label>Maximum cursor motion speed</label>
+      <default>1</default>
+      <min>0</min>
+      <max>2</max>
+    </entry>
+    <entry name="AccelerationFactor" type="Double">
+      <label>Acceleration factor between MinimumSpeed and
+MaximumSpeed</label>
+      <default>0.2</default>
+      <min>0</min>
+      <max>1</max>
+    </entry>
+  </group>
   <group name="Scrolling">
     <entry name="CircularScrolling" type="Bool">
       <label>Enable or disable circular scrolling</label>



More information about the kde-doc-english mailing list