mainwindow.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. @class: MainWindow
  3. @description: MainWindow is ThinkContacts' main class. MainWindow sets the graphical
  4. user interface, uses ThinkGearStreamParser to parse the byte sequence sent by the headset
  5. using the algorithm provided by the headset’s company, uses Bluetooth Manager to achieve
  6. connection with the headset, loads the contacts’ information from the phone’s address book,
  7. uses PictureFlow to build the animated image, shows the widget that displays the contacts’
  8. names and pictures, and implements algorithms to control the flow of images on
  9. PictureFlow and to make a phone call when required.
  10. @author: Mirko Perkusich
  11. Taciana Rached
  12. */
  13. /*
  14. Copyright (c) 2010 Embedded Systems and Pervasive Laboratory, Federal
  15. University of Campina Grande, Brazil, Angelo Perkusich, Mirko Perkusich,
  16. Taciana Rached
  17. Permission is hereby granted, free of charge, to any person obtaining a
  18. copy of this software and associated documentation files (the
  19. "Software"), to deal in the Software without restriction, including
  20. without limitation the rights to use, copy, modify, merge, publish,
  21. distribute, sublicense, and/or sell copies of the Software, and to
  22. permit persons to whom the Software is furnished to do so, subject to
  23. the following conditions:
  24. The above copyright notice and this permission notice shall be included
  25. in all copies or substantial portions of the Software.
  26. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  27. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  29. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  30. CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  31. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  32. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  33. */
  34. #ifndef MAINWINDOW_H
  35. #define MAINWINDOW_H
  36. #include <QObject>
  37. #include <QMainWindow>
  38. #include <QWidget>
  39. #include <QVBoxLayout>
  40. #include <QHBoxLayout>
  41. #include <QLabel>
  42. #include <QProgressBar>
  43. #include <QMainWindow>
  44. #include <QPushButton>
  45. #include <QSpacerItem>
  46. #include <QDebug>
  47. #include <QContact>
  48. #include <QContactPhoneNumber>
  49. #include <QContactThumbnail>
  50. #include <QContactManager>
  51. #include <QProcess>
  52. #include "bluetoothmanager.h"
  53. #include "pictureflow.h"
  54. #include "ThinkGearStreamParser.h"
  55. using namespace QtMobility;
  56. class MainWindow : public QMainWindow
  57. {
  58. Q_OBJECT
  59. public:
  60. /**
  61. * Constructor
  62. */
  63. explicit MainWindow(QWidget *parent = 0);
  64. public slots:
  65. /**
  66. * Classifies data read by the BluetoothManager through ThinkGearStreamParser
  67. * @param data QByteArray read by BluetoothManager.
  68. */
  69. void classifyData(QByteArray data);
  70. /**
  71. * Sets meditation's progress bar and calculates if the application should
  72. * make a call or not based on inMedLevel.
  73. * @param inMedLevel is the meditation level calculated by ThinkGearStreamParser.
  74. */
  75. void meditationReceived(int inMedLevel);
  76. /**
  77. * Sets attention's progress bar and calculates if the application should
  78. * make a call or not based on inALevel.
  79. * @param inALevel is the attention level calculated by ThinkGearStreamParser.
  80. */
  81. void attentionReceived(int inALevel);
  82. /**
  83. * Sets the graphical user interface after bluetooth connection with the headset
  84. * is established.
  85. */
  86. void setWindow();
  87. /**
  88. * Makes a phone call to the contact currently located at the center of the screen.
  89. */
  90. void makeCall();
  91. /**
  92. * Loads information from the phone's addressbook contacts to PictureFlow widget.
  93. */
  94. void loadContactsInfo();
  95. private:
  96. /** Bluetooth connection manager. */
  97. BluetoothManager btManager;
  98. /** Stream parser. */
  99. ThinkGearStreamParser parser;
  100. /** Animated image widget. */
  101. PictureFlow *pFlow;
  102. /** List with all the contacts on the phone's addressbook. */
  103. QList<QContact> contacts;
  104. /** Progress bars for meditation and attention. */
  105. QProgressBar *medProgBar, *aProgBar;
  106. /** Connect and Quit buttons. */
  107. QPushButton *connectButton, *quitButton;
  108. /**
  109. *Sets the initial graphical user interface.
  110. */
  111. void setMainWindow();
  112. /**
  113. * Sets up the connections between the objects
  114. */
  115. void setupConnections();
  116. };
  117. #endif // MAINWINDOW_H