DeviceWatcher.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef DEVICEWATCHER_H
  2. #define DEVICEWATCHER_H
  3. #include "MultimediaService.h"
  4. #include <QGuiApplication>
  5. #include "DiskDeviceWatcher/DiskDeviceWatcher.h"
  6. #include <QObject>
  7. #include <QProcess>
  8. #include <QScopedPointer>
  9. class DeviceWatcherPrivate;
  10. class DeviceWatcher : public QObject
  11. {
  12. Q_OBJECT
  13. Q_DISABLE_COPY(DeviceWatcher)
  14. #ifdef g_DeviceWatcher
  15. #undef g_DeviceWatcher
  16. #endif
  17. #define g_DeviceWatcher (DeviceWatcher::instance())
  18. public:
  19. inline static DeviceWatcher* instance() {
  20. static DeviceWatcher* deviceWatcher(new DeviceWatcher(qGuiApp));
  21. return deviceWatcher;
  22. }
  23. void synchronize();
  24. void deviceWatcherCheckStatus(const int type);
  25. signals:
  26. void onDeviceWatcherStatus(const int type, const int status);
  27. void onMusicFilePath(const QString &path, const int type);
  28. void onImageFilePath(const QString &path, const int type);
  29. void onVideoFilePath(const QString &path, const int type);
  30. protected:
  31. void timerEvent(QTimerEvent* event);
  32. private slots:
  33. void onDiskDeviceChange(const QString &device, const DiskDeviceWatcher::Action action);
  34. void onUSBFilePath(const QString &path, const int index);
  35. void onSDFilePath(const QString &path, const int index);
  36. void onFinish();
  37. private:
  38. explicit DeviceWatcher(QObject *parent = NULL);
  39. ~DeviceWatcher();
  40. void onDiskDeviceChangeHandler(const QString &device, const DiskDeviceWatcher::Action action);
  41. friend class DeviceWatcherPrivate;
  42. QScopedPointer<DeviceWatcherPrivate> m_Private;
  43. };
  44. #endif // DEVICEWATCHER_H