cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [1/2] git commit: add ubuntu platform
Date Tue, 03 Dec 2013 00:30:22 GMT
Updated Branches:
  refs/heads/dev 26bb70b46 -> d709f6bd7


add ubuntu platform


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/commit/fe4fe1a8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/tree/fe4fe1a8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/diff/fe4fe1a8

Branch: refs/heads/dev
Commit: fe4fe1a893a48cb11dbf9dbbdb0afdb9f09e269b
Parents: ae72bbc
Author: Maxim Ermilov <maxim.ermilov@canonical.com>
Authored: Sun Oct 20 16:54:15 2013 +0400
Committer: Maxim Ermilov <maxim.ermilov@canonical.com>
Committed: Sun Oct 20 16:54:15 2013 +0400

----------------------------------------------------------------------
 plugin.xml               |  6 ++++++
 src/ubuntu/vibration.cpp | 38 ++++++++++++++++++++++++++++++++++
 src/ubuntu/vibration.h   | 47 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/fe4fe1a8/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 15a9ca7..3cc6f4b 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -63,6 +63,12 @@
         </config-file>
     </platform>
 
+    <!-- ubuntu -->
+    <platform name="ubuntu">
+        <header-file src="src/ubuntu/vibration.h" />
+        <source-file src="src/ubuntu/vibration.cpp" />
+    </platform>
+
     <!-- ios -->
     <platform name="ios">
         <config-file target="config.xml" parent="/*">

http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/fe4fe1a8/src/ubuntu/vibration.cpp
----------------------------------------------------------------------
diff --git a/src/ubuntu/vibration.cpp b/src/ubuntu/vibration.cpp
new file mode 100644
index 0000000..b6cfb70
--- /dev/null
+++ b/src/ubuntu/vibration.cpp
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright 2013 Canonical Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+#include <QFeedbackHapticsEffect>
+#include "vibration.h"
+
+void Vibration::vibrate(int, int, int mills) {
+    QFeedbackHapticsEffect *vibrate = new QFeedbackHapticsEffect;
+    vibrate->setIntensity(1.0);
+    vibrate->setDuration(mills);
+
+    connect(vibrate, &QFeedbackHapticsEffect::stateChanged, [&]() {
+        QFeedbackEffect *effect = qobject_cast<QFeedbackEffect *>(sender());
+        if (!effect)
+            return;
+        if (effect->state() == QFeedbackEffect::Stopped)
+            effect->deleteLater();
+    });
+
+    vibrate->start();
+}
+

http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/fe4fe1a8/src/ubuntu/vibration.h
----------------------------------------------------------------------
diff --git a/src/ubuntu/vibration.h b/src/ubuntu/vibration.h
new file mode 100644
index 0000000..051dcdd
--- /dev/null
+++ b/src/ubuntu/vibration.h
@@ -0,0 +1,47 @@
+/*
+ *
+ * Copyright 2013 Canonical Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+#ifndef _VIBRATION_H_SFAFKNVX3456
+#define _VIBRATION_H_SFAFKNVX3456
+
+#include <QtQuick>
+#include <cplugin.h>
+
+class Vibration: public CPlugin {
+    Q_OBJECT
+public:
+    explicit Vibration(Cordova *cordova): CPlugin(cordova) {
+    }
+
+    virtual const QString fullName() override {
+        return Vibration::fullID();
+    }
+
+    virtual const QString shortName() override {
+        return "Vibration";
+    }
+
+    static const QString fullID() {
+        return "Vibration";
+    }
+public slots:
+    void vibrate(int, int, int mills);
+};
+
+#endif


Mime
View raw message