summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1281583)
raw | patch | inline | side by side (parent: 1281583)
author | Manisha Agrawal <manisha.agrawal@ti.com> | |
Thu, 13 Dec 2018 19:52:03 +0000 (19:52 +0000) | ||
committer | Manisha Agrawal <manisha.agrawal@ti.com> | |
Thu, 13 Dec 2018 19:52:03 +0000 (19:52 +0000) |
Signed-off-by: Manisha Agrawal <manisha.agrawal@ti.com>
keyword.cpp | patch | blob | history | |
keyword.h | patch | blob | history |
diff --git a/keyword.cpp b/keyword.cpp
index 0e67f9d1de6b375aec913262ac22c4a58b3d75e9..853a294b3d32afd79955d5e01b631ebdfd62012e 100755 (executable)
--- a/keyword.cpp
+++ b/keyword.cpp
-/*\r
-* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/\r
-*\r
-*\r
-* Redistribution and use in source and binary forms, with or without\r
-* modification, are permitted provided that the following conditions\r
-* are met:\r
-*\r
-* Redistributions of source code must retain the above copyright\r
-* notice, this list of conditions and the following disclaimer.\r
-*\r
-* Redistributions in binary form must reproduce the above copyright\r
-* notice, this list of conditions and the following disclaimer in the\r
-* documentation and/or other materials provided with the\r
-* distribution.\r
-*\r
-* Neither the name of Texas Instruments Incorporated nor the names of\r
-* its contributors may be used to endorse or promote products derived\r
-* from this software without specific prior written permission.\r
-*\r
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*\r
-*/\r
-#include <QCoreApplication>\r
-#include <QDebug>\r
-#include <QTimer>\r
-#include "keyword.h"\r
-\r
-QT_USE_NAMESPACE\r
-\r
-Keyword::Keyword(QObject *qmlCompObject)\r
-{\r
- m_digitArray[0] = qmlCompObject->findChild<QObject *>("myDigit1");\r
- m_digitArray[1] = qmlCompObject->findChild<QObject *>("myDigit2");\r
- m_digitArray[2] = qmlCompObject->findChild<QObject *>("myDigit3");\r
- m_digitArray[3] = qmlCompObject->findChild<QObject *>("myDigit4");\r
-\r
- m_qmlCompObject = qmlCompObject;\r
-\r
- //initialize the displayed digits as 3337\r
- for (int i = 0; i < 3; i++){\r
- m_counter[i] = 0;\r
- }\r
-\r
- m_counter[3] = 5;\r
-\r
- /* Substract the keyword with 3 as the keyword is matched to the "model" index and not\r
- * the value at that index. Check the PathView in Digit.qml to understand model. A PathView\r
- * displays data from models created from built-in QML types. A model provides a\r
- * set of data that is used to create the items for the view. To avoid many scrolls to\r
- * to set the password, password is restricted between 3 and 8 and mmWave part number is\r
- * 6843, which is set as initial password*/\r
- m_keyword[0] = 3;//6 - 3;\r
- m_keyword[1] = 5;//8 - 3;\r
- m_keyword[2] = 1;//4 - 3;\r
- m_keyword[3] = 0;//3 - 3;\r
-\r
- qDebug() << " keyword index" << m_keyword[0] << m_keyword[1] << m_keyword[2] << m_keyword[3];\r
- m_activeIndex = 0;\r
-\r
- m_digitArray[m_activeIndex]->setProperty("borderColor", "red");\r
- m_digitArray[m_activeIndex]->setProperty("borderWidth", 9);\r
- m_digitArray[m_activeIndex]->setProperty("digit", m_counter[0]);\r
-\r
- for (int i = 1; i < 4; i++){\r
- if(m_digitArray[i]){\r
- m_digitArray[i]->setProperty("borderColor", "black");\r
- m_digitArray[i]->setProperty("borderWidth", 1);\r
- m_digitArray[i]->setProperty("digit", m_counter[i]);\r
- }\r
- }\r
-\r
- m_numtimes_keyword_match = 1;\r
-}\r
-\r
-Keyword::~Keyword()\r
-{\r
- for (int i = 0; i < 4 ; i++){\r
- m_digitArray[i] = nullptr;\r
- m_counter[i] = 0;\r
- }\r
-}\r
-\r
-void Keyword::emitKeywordQuit()\r
-{\r
- qDebug() << "Emit keywordQuit signal\n";\r
- emit keywordQuit();\r
-}\r
-\r
-void Keyword::handleDownGesture()\r
-{\r
- bool keyMatch = false;\r
- m_counter[m_activeIndex] = (m_counter[m_activeIndex] + 1) % 6;\r
-\r
- m_digitArray[m_activeIndex]->setProperty("digit", m_counter[m_activeIndex]);\r
-\r
- keyMatch = ((m_digitArray[0]->property("digit") == m_keyword[0]) &&\r
- (m_digitArray[1]->property("digit") == m_keyword[1]) &&\r
- (m_digitArray[2]->property("digit") == m_keyword[2]) &&\r
- (m_digitArray[3]->property("digit") == m_keyword[3]));\r
-\r
- //Refresh the screen with updated digit\r
- QTimer::singleShot(0, m_qmlCompObject, SLOT(update()));\r
-\r
- if (keyMatch == true){\r
- m_qmlCompObject->setProperty("mypaused", false);\r
- m_numtimes_keyword_match -= 1;\r
- if(m_numtimes_keyword_match <= 0){\r
- QTimer::singleShot(5000, this, SLOT(emitKeywordQuit()));\r
- }\r
- }\r
-}\r
-\r
-void Keyword::handleRightGesture()\r
-{\r
- m_digitArray[m_activeIndex]->setProperty("borderColor", "black");\r
- m_digitArray[m_activeIndex]->setProperty("borderWidth", 2);\r
- m_activeIndex = (m_activeIndex + 1) % 4;\r
-\r
- m_digitArray[m_activeIndex]->setProperty("borderColor", "red");\r
- m_digitArray[m_activeIndex]->setProperty("borderWidth", 9);\r
-\r
- //Refresh the screen with updated digit index\r
- QTimer::singleShot(0, m_qmlCompObject, SLOT(update()));\r
-}\r
-\r
-void Keyword::handleMotionDetected()\r
-{\r
- m_qmlCompObject->setProperty("color", "gray");\r
- m_qmlCompObject->setProperty("myvisibility", true);\r
-}\r
-\r
-void Keyword::handleNoActivity()\r
-{\r
- m_qmlCompObject->setProperty("color", "black");\r
- m_qmlCompObject->setProperty("myvisibility", false);\r
-}\r
+/*
+* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
+*
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of Texas Instruments Incorporated nor the names of
+* its contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+#include <QCoreApplication>
+#include <QDebug>
+#include <QTimer>
+#include "keyword.h"
+
+QT_USE_NAMESPACE
+
+Keyword::Keyword(QObject *qmlCompObject)
+{
+ m_digitArray[0] = qmlCompObject->findChild<QObject *>("myDigit1");
+ m_digitArray[1] = qmlCompObject->findChild<QObject *>("myDigit2");
+ m_digitArray[2] = qmlCompObject->findChild<QObject *>("myDigit3");
+ m_digitArray[3] = qmlCompObject->findChild<QObject *>("myDigit4");
+
+ m_qmlCompObject = qmlCompObject;
+
+ //initialize the displayed digits as 3337
+ for (int i = 0; i < 3; i++){
+ m_counter[i] = 0;
+ }
+
+ m_counter[3] = 5;
+
+ /* Substract the keyword with 3 as the keyword is matched to the "model" index and not
+ * the value at that index. Check the PathView in Digit.qml to understand model. A PathView
+ * displays data from models created from built-in QML types. A model provides a
+ * set of data that is used to create the items for the view. To avoid many scrolls to
+ * to set the password, password is restricted between 3 and 8 and mmWave part number is
+ * 6843, which is set as initial password*/
+ m_keyword[0] = 3;//6 - 3;
+ m_keyword[1] = 5;//8 - 3;
+ m_keyword[2] = 1;//4 - 3;
+ m_keyword[3] = 0;//3 - 3;
+
+ qDebug() << " keyword index" << m_keyword[0] << m_keyword[1] << m_keyword[2] << m_keyword[3];
+ m_activeIndex = 0;
+
+ m_digitArray[m_activeIndex]->setProperty("borderColor", "red");
+ m_digitArray[m_activeIndex]->setProperty("borderWidth", 9);
+ m_digitArray[m_activeIndex]->setProperty("digit", m_counter[0]);
+
+ for (int i = 1; i < 4; i++){
+ if(m_digitArray[i]){
+ m_digitArray[i]->setProperty("borderColor", "black");
+ m_digitArray[i]->setProperty("borderWidth", 1);
+ m_digitArray[i]->setProperty("digit", m_counter[i]);
+ }
+ }
+
+ m_numtimes_keyword_match = 1;
+}
+
+Keyword::~Keyword()
+{
+ for (int i = 0; i < 4 ; i++){
+ m_digitArray[i] = nullptr;
+ m_counter[i] = 0;
+ }
+}
+
+void Keyword::emitKeywordQuit()
+{
+ qDebug() << "Emit keywordQuit signal\n";
+ emit keywordQuit();
+}
+
+void Keyword::handleDownGesture()
+{
+ bool keyMatch = false;
+ m_counter[m_activeIndex] = (m_counter[m_activeIndex] + 1) % 6;
+
+ m_digitArray[m_activeIndex]->setProperty("digit", m_counter[m_activeIndex]);
+
+ keyMatch = ((m_digitArray[0]->property("digit") == m_keyword[0]) &&
+ (m_digitArray[1]->property("digit") == m_keyword[1]) &&
+ (m_digitArray[2]->property("digit") == m_keyword[2]) &&
+ (m_digitArray[3]->property("digit") == m_keyword[3]));
+
+ //Refresh the screen with updated digit
+ QTimer::singleShot(0, m_qmlCompObject, SLOT(update()));
+
+ if (keyMatch == true){
+ m_qmlCompObject->setProperty("mypaused", false);
+ m_numtimes_keyword_match -= 1;
+ if(m_numtimes_keyword_match <= 0){
+ QTimer::singleShot(5000, this, SLOT(emitKeywordQuit()));
+ }
+ }
+}
+
+void Keyword::handleRightGesture()
+{
+ m_digitArray[m_activeIndex]->setProperty("borderColor", "black");
+ m_digitArray[m_activeIndex]->setProperty("borderWidth", 2);
+ m_activeIndex = (m_activeIndex + 1) % 4;
+
+ m_digitArray[m_activeIndex]->setProperty("borderColor", "red");
+ m_digitArray[m_activeIndex]->setProperty("borderWidth", 9);
+
+ //Refresh the screen with updated digit index
+ QTimer::singleShot(0, m_qmlCompObject, SLOT(update()));
+}
+
+void Keyword::handleMotionDetected()
+{
+ m_qmlCompObject->setProperty("color", "gray");
+ m_qmlCompObject->setProperty("myvisibility", true);
+}
+
+void Keyword::handleNoActivity()
+{
+ m_qmlCompObject->setProperty("color", "black");
+ m_qmlCompObject->setProperty("myvisibility", false);
+}
diff --git a/keyword.h b/keyword.h
index 109212dd078bdada8560c2bb853757986ec06a35..821b78e2291308559073d3e43c7c7e58837d5343 100755 (executable)
--- a/keyword.h
+++ b/keyword.h
-/*\r
-* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/\r
-*\r
-*\r
-* Redistribution and use in source and binary forms, with or without\r
-* modification, are permitted provided that the following conditions\r
-* are met:\r
-*\r
-* Redistributions of source code must retain the above copyright\r
-* notice, this list of conditions and the following disclaimer.\r
-*\r
-* Redistributions in binary form must reproduce the above copyright\r
-* notice, this list of conditions and the following disclaimer in the\r
-* documentation and/or other materials provided with the\r
-* distribution.\r
-*\r
-* Neither the name of Texas Instruments Incorporated nor the names of\r
-* its contributors may be used to endorse or promote products derived\r
-* from this software without specific prior written permission.\r
-*\r
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*\r
-*/\r
-#ifndef KEYWORD_H\r
-#define KEYWORD_H\r
-\r
-#include <QByteArray>\r
-#include <QObject>\r
-\r
-\r
-QT_USE_NAMESPACE\r
-\r
-QT_BEGIN_NAMESPACE\r
-\r
-QT_END_NAMESPACE\r
-\r
-class Keyword : public QObject\r
-{\r
- Q_OBJECT\r
-\r
-public:\r
- Keyword(QObject *object);\r
- ~Keyword();\r
- unsigned int m_keyword[4];\r
- int m_numtimes_keyword_match;\r
-\r
-signals:\r
- void keywordQuit();\r
-\r
-public slots:\r
- void handleDownGesture();\r
- void handleRightGesture();\r
- void handleMotionDetected();\r
- void handleNoActivity();\r
- void emitKeywordQuit();\r
-\r
-private:\r
- QObject *m_digitArray[4];\r
- unsigned char m_counter[4];\r
- unsigned char m_activeIndex;\r
- QObject *m_qmlCompObject;\r
-};\r
-\r
-#endif\r
+/*
+* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
+*
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of Texas Instruments Incorporated nor the names of
+* its contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+#ifndef KEYWORD_H
+#define KEYWORD_H
+
+#include <QByteArray>
+#include <QObject>
+
+
+QT_USE_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+
+QT_END_NAMESPACE
+
+class Keyword : public QObject
+{
+ Q_OBJECT
+
+public:
+ Keyword(QObject *object);
+ ~Keyword();
+ unsigned int m_keyword[4];
+ int m_numtimes_keyword_match;
+
+signals:
+ void keywordQuit();
+
+public slots:
+ void handleDownGesture();
+ void handleRightGesture();
+ void handleMotionDetected();
+ void handleNoActivity();
+ void emitKeywordQuit();
+
+private:
+ QObject *m_digitArray[4];
+ unsigned char m_counter[4];
+ unsigned char m_activeIndex;
+ QObject *m_qmlCompObject;
+};
+
+#endif