mirroritem.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * Copyright (c) 2011-2012 Nokia Corporation.
  3. */
  4. #ifndef MIRRORITEM_H
  5. #define MIRRORITEM_H
  6. #include <QByteArray>
  7. // Unlike the other APIs in Qt Mobility, the Qt Mobility Multimedia API is not
  8. // in the Qt Mobility namespace.
  9. #include <QCamera>
  10. #include <QDeclarativeItem>
  11. #include <QImage>
  12. #include <QList>
  13. #include <QVariant>
  14. #include "videoif.h"
  15. // Forward declarations
  16. class MyVideoSurface;
  17. class QEvent;
  18. class QPainter;
  19. class QStyleOptionGraphicsItem;
  20. class QWidget;
  21. /*!
  22. \class MirrorItem
  23. \brief The actual mirror that shows mirror customized camera viewfinder pictures
  24. */
  25. class MirrorItem : public QDeclarativeItem, public VideoIF
  26. {
  27. Q_OBJECT
  28. Q_PROPERTY(int effectId READ effectId WRITE setEffectId NOTIFY effectIdChanged)
  29. public:
  30. explicit MirrorItem(QDeclarativeItem *parent = 0);
  31. virtual ~MirrorItem();
  32. public: // From QDeclarativeItem
  33. bool sceneEvent(QEvent *event);
  34. void paint(QPainter *painter,
  35. const QStyleOptionGraphicsItem *option,
  36. QWidget *widget);
  37. public:
  38. void updateVideo();
  39. // Property setters and getters
  40. int effectId() const;
  41. void setEffectId(int id);
  42. public slots:
  43. void enableCamera(QVariant enable);
  44. void enableCameraAt(QVariant enable, QVariant cameraIndex);
  45. void pauseCamera();
  46. void enableEffect(QVariant id, QVariant strength, QVariant count);
  47. void saveToFile();
  48. private slots:
  49. void startCamera();
  50. void stopCamera();
  51. void handleCameraError(QCamera::Error);
  52. private:
  53. void keepPaintingStoredPicture();
  54. void doSave(QImage image);
  55. signals:
  56. void minimizeMirror();
  57. void maximizeMirror();
  58. // Property signals
  59. void effectIdChanged(int id);
  60. private: // Data
  61. QCamera* m_camera; // Owned
  62. MyVideoSurface* m_myVideoSurface; // Not owned
  63. QImage m_lastPicture;
  64. QList<QByteArray> m_devices;
  65. double m_strength;
  66. double m_count;
  67. int m_deviceId;
  68. int m_effectId;
  69. int m_pinchCounter;
  70. bool m_showViewFinder;
  71. bool m_keepPaintingStoredPicture;
  72. bool m_signalSent;
  73. };
  74. QML_DECLARE_TYPE(MirrorItem)
  75. #endif // MIRRORITEM_H