-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathportscanner.h
More file actions
77 lines (71 loc) · 2.32 KB
/
Copy pathportscanner.h
File metadata and controls
77 lines (71 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef PORTSCANNER_H
#define PORTSCANNER_H
#include <QImage>
#include <QList>
#include <QObject>
#include <QSerialPortInfo>
#include <QSettings>
#include "devices/device.h"
#include "devices/outdated_ardwiino.h"
#include "programmer.h"
class PortScanner : public QObject {
Q_OBJECT
Q_PROPERTY(QList<QObject*> model READ model NOTIFY modelChanged)
Q_PROPERTY(Device* selected READ getSelected WRITE setSelected NOTIFY selectedChanged)
Q_PROPERTY(bool isGraphical READ isGraphical NOTIFY graphicalChanged)
Q_PROPERTY(bool hasSelected MEMBER m_hasSelected NOTIFY hasSelectedChanged)
public:
explicit PortScanner(Programmer* programmer, QObject* parent = nullptr);
void add(UsbDevice_t device);
void remove(UsbDevice_t device);
signals:
void graphicalChanged();
void modelChanged();
void selectedChanged();
void hasSelectedChanged();
public slots:
bool isGraphical() const {
return m_graphical;
}
void setSelected(Device* port);
Device* getSelected() const {
return m_selected;
}
void update();
void serialDeviceDetected(const QSerialPortInfo& port);
void serialDeviceUnplugged(const QSerialPortInfo& port);
void fixLinux();
void toggleGraphics();
QString findElement(QString base, int width, int heither, int mouseX, int mouseY);
QList<QObject*> model() const {
return m_model;
}
inline QString getOSString() {
#ifdef Q_OS_LINUX
return "<br />If you are not able to detect any devices, you may need to add yourself to the uucp and dialout groups. <br /> For information, <a href=\"https://www.arduino.cc/en/guide/linux#toc6\">click here</a>.<br/>Is your gamepad not detected in game? Click the button below to fix the problem. <br/> Note that this fix will need to be applied after every reboot.";
#else
return "";
#endif
}
inline bool isLinux() {
#ifdef Q_OS_LINUX
return true;
#endif
return false;
}
private:
void scanDevices();
void add(Device* device);
void remove(Device* device);
bool m_hasSelected;
void clearImages();
QList<QObject*> m_model;
Device* m_selected;
Programmer* programmer;
QStringList images;
bool m_graphical;
QSettings settings;
QList<QProcess*> m_processes;
Device* m_emptyDevice;
};
#endif // PORTSCANNER_H