API Documentation
Loading...
Searching...
No Matches
DeviceWatcher.h
Go to the documentation of this file.
1#pragma once
2#include "DLLInfo.h"
3#include <QtCore/QEvent>
4#include <QtCore/QObject>
5namespace NDEVR
6{
7 class DeviceWatcherPrivate;
8 /**--------------------------------------------------------------------------------------------------
9 \brief Watches and alerts the program when a USB device is plugged in or unplugged.
10 **/
11 class NDEVR_WIDGETS_API DeviceWatcher : public QObject
12 {
13 Q_OBJECT
14 Q_DECLARE_PRIVATE(DeviceWatcher)
15 public:
16 explicit DeviceWatcher(QObject* parent = 0);
18
19 bool start();
20 bool stop();
21 bool isRunning() const;
22
23 void appendEventReceiver(QObject* receiver);
25 signals:
26 void deviceAdded(const QString& dev);
27 void deviceChanged(const QString& dev); //when umounting the device
28 void deviceRemoved(const QString& dev);
29
30 protected:
31 bool running;
32 DeviceWatcherPrivate* d_ptr;
33 };
34
35 /**--------------------------------------------------------------------------------------------------
36 \brief The event that is triggered when a USB device is plugged in or unplugged.
37 **/
39 {
40 public:
41 enum Action { Add, Remove, Change };
42 //static const Type EventType; //VC link error
43
44 explicit QDeviceChangeEvent(Action action, const QString& device);
45
46 Action action() const { return m_action; }
47 QString device() const { return m_device; }
48 static Type registeredType()
49 {
50 static Type EventType = static_cast<Type>(registerEventType());
51 return EventType;
52 }
53
54 private:
55 Action m_action;
56 QString m_device;
57 };
58}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:59
Watches and alerts the program when a USB device is plugged in or unplugged.
Definition DeviceWatcher.h:12
bool running
Definition DeviceWatcher.h:31
void deviceAdded(const QString &dev)
void deviceRemoved(const QString &dev)
void appendEventReceiver(QObject *receiver)
void deviceChanged(const QString &dev)
DeviceWatcherPrivate * d_ptr
Definition DeviceWatcher.h:32
bool isRunning() const
static DeviceWatcher & DefaultWatcher()
DeviceWatcher(QObject *parent=0)
The event that is triggered when a USB device is plugged in or unplugged.
Definition DeviceWatcher.h:39
QDeviceChangeEvent(Action action, const QString &device)
QString device() const
Definition DeviceWatcher.h:47
Action
Definition DeviceWatcher.h:41
static Type registeredType()
Definition DeviceWatcher.h:48
Action action() const
Definition DeviceWatcher.h:46
Definition ACIColor.h:37