widget.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
  3. * All rights reserved.
  4. * This component and the accompanying materials are made available
  5. * under the terms of "Eclipse Public License v1.0"
  6. * which accompanies this distribution, and is available
  7. * at the URL "http://www.eclipse.org/legal/epl-v10.html".
  8. *
  9. * Initial Contributors:
  10. * Nokia Corporation - initial contribution.
  11. *
  12. * Contributors:
  13. *
  14. * Description: Part of Qt NFC Setting sample application.
  15. */
  16. /*!
  17. * \file
  18. * \brief Declaration of the Widget class.
  19. *
  20. * This file contains the declaration of the Widget class that acts as the
  21. * central widget of the main window of the application.
  22. *
  23. * \note The MainWindow class declared in mainwindow.h is not documented here,
  24. * as it is a class generated by the Qt Creator project wizard.
  25. */
  26. #ifndef WIDGET_H
  27. #define WIDGET_H
  28. #include <QtGui/QWidget>
  29. #include "nfcsettings.h"
  30. namespace Ui {
  31. class Widget;
  32. }
  33. /*!
  34. * \brief The central widget of the Qt NFC Settings application main window.
  35. *
  36. * This class represents the user interface of the application. The user
  37. * interface contains a label for showing the current NFC mode setting value,
  38. * a secondary label for showing any error messages and a push button used to
  39. * exit the application.
  40. *
  41. * The Widget class corresponds to the Qt Designer UI file widget.ui. A Widget
  42. * is shown as the central widget in the <code>QMainWindow</code> derived
  43. * MainWindow that is the top-level widget of this application.
  44. *
  45. * An instance of the class NfcSettings is constructed when the widget is
  46. * constructed to obtain information on whether device supports NFC and if so,
  47. * what the current NFC mode is. This information is displayed on the label
  48. * that is a child of this central widget.
  49. *
  50. * \note The MainWindow class is not documented here, as it is a class generated
  51. * by the Qt Creator project wizard.
  52. *
  53. * \see MainWindow, NfcSettings
  54. */
  55. class Widget : public QWidget
  56. {
  57. Q_OBJECT
  58. public:
  59. /*!
  60. * \brief C++ constructor.
  61. *
  62. * Initializes a new Widget instance. Sets up the user interface, fetches
  63. * the initial value of the NFC mode setting and connects the mode change
  64. * and error signals to the handleNfcModeChange() and handleNfcError() slots
  65. * implemented in this class for handling them.
  66. *
  67. * \param parent The widget that is to be the parent of this widget, always
  68. * an instance of MainWindow.
  69. * \see MainWindow, NfcSettings
  70. */
  71. explicit Widget(QWidget *parent = 0);
  72. /*!
  73. * \brief C++ destructor.
  74. *
  75. * Releases any resources allocated by this Widget instance.
  76. */
  77. ~Widget();
  78. protected slots:
  79. /*!
  80. * \brief Displays the NFC feature support level on a label in the user
  81. * interface.
  82. *
  83. * This function maps the NFC feature enumeration value to a human readable
  84. * message and displays on the user interface.
  85. *
  86. * \note Even though this function is declared as a slot, there is not
  87. * corresponding signal in the NfcSettings class as the NFC feature
  88. * support cannot change at runtime.
  89. *
  90. * \param nfcFeature The level of NFC support provided by the device and
  91. * current software version, i.e. whether NFC hardware is present and
  92. * supported by the software.
  93. * \see NfcSettings::NfcFeature, NfcSettings::nfcFeature()
  94. */
  95. void displayNfcFeature(NfcSettings::NfcFeature nfcFeature);
  96. /*!
  97. * \brief Displays the current NFC mode on a label in the user interface.
  98. *
  99. * This function maps the NFC mode enumeration value to a human readable
  100. * message and displays on the user interface.
  101. *
  102. * \param nfcMode The current value of the NFC mode setting.
  103. * \see NfcSettings::NfcMode, NfcSettings::nfcModeChanged()
  104. */
  105. void displayNfcMode(NfcSettings::NfcMode nfcMode);
  106. /*!
  107. * \brief Displays the latest NFC error message on a label in the user
  108. * interface.
  109. *
  110. * This function maps the NFC error enumeration value to a human readable
  111. * status message and displays it along with the associated error code on
  112. * the user interface.
  113. *
  114. * \param nfcError The general reason for the error.
  115. * \param error A platform specific error code giving a more detailed
  116. * description of the error that took place.
  117. * \see NfcSettings::NfcError, NfcSettings::nfcErrorOccurred()
  118. */
  119. void displayNfcError(NfcSettings::NfcError nfcError, int error);
  120. private:
  121. /*! \brief An instance of the UI class generated from Qt Designer file widget.ui, owned. */
  122. Ui::Widget *ui;
  123. /*! \brief The NFC settings object used to query and monitor the NFC mode setting, owned. */
  124. NfcSettings *m_nfcSettings;
  125. };
  126. #endif // WIDGET_H