forked from Larswad/uno2iec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.hpp
executable file
·154 lines (135 loc) · 4.6 KB
/
mainwindow.hpp
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP
#include <QMainWindow>
#include <QStandardItemModel>
#include <QFileInfo>
#include <QFileSystemWatcher>
#include <QtSerialPort/QtSerialPort>
#include <QMap>
#include "interface.hpp"
#include "logger.hpp"
#include "settingsdialog.hpp"
namespace Ui {
class MainWindow;
}
struct CbmMachineTheme {
QString bootText;
QString font;
uchar fgColorIndex;
uchar frColorIndex;
uchar bgColorIndex;
uchar cursorWidth;
};
typedef QMap<QString, const QRgb*> EmulatorPaletteMap;
typedef QMap<QString, CbmMachineTheme*> CbmMachineThemeMap;
typedef QMap<QChar, QString> FacilityMap;
class MainWindow : public QMainWindow, public Logging::ILogTransport, public Interface::IFileOpsNotify,
public ISendLine
{
Q_OBJECT
typedef QMap<QString, QFileInfo> QFileInfoMap;
public:
explicit MainWindow(QWidget* parent = 0);
~MainWindow();
void writeTextToDirList(const QString& text, bool atCursor = true);
void processAddNewFacility(const QString &str);
void checkVersion();
void closeEvent(QCloseEvent* event);
// IMountNotifyListener interface implementation
void directoryChanged(const QString& newPath);
void imageMounted(const QString& imagePath, FileDriverBase* pFileSystem);
void imageUnmounted();
void fileLoading(const QString& fileName, ushort fileSize);
void fileSaving(const QString& fileName);
void bytesRead(uint numBytes);
void bytesWritten(uint numBytes);
void fileClosed(const QString &lastFileName);
bool isWriteProtected() const;
ushort deviceNumber() const;
void setDeviceNumber(ushort deviceNumber);
void deviceReset();
void writePort(const QByteArray& data, bool flush);
// ISendLine interface implementation.
void send(short lineNo, const QString &text);
// ILogTransport implementation.
void appendTime(const QString& dateTime);
void appendLevelAndFacility(Logging::LogLevelE level, const QString& levelFacility);
void appendMessage(const QString& msg);
public slots:
void onCommandIssued(const QString& cmd);
private slots:
void onDirListColorSelected(QAction *pAction);
void onCbmMachineSelected(QAction *pAction);
void onDataAvailable();
void on_clearLog_clicked();
void on_pauseLog_toggled(bool checked);
void on_saveLog_clicked();
void on_saveHtml_clicked();
void on_resetArduino_clicked();
void on_imageFilter_textChanged(const QString &filter);
void on_mountSelected_clicked();
void on_actionAbout_triggered();
void on_unmountCurrent_clicked();
void on_actionSettings_triggered();
void on_reloadImageDir_clicked();
void on_dirList_doubleClicked(const QModelIndex &index);
void on_directoryChanged(const QString& path);
void on_filterSetup_clicked();
void simTimerExpired();
void simTimerExpiredNoResp();
void on_actionSingle_file_mount_triggered();
private:
bool checkConnectRequest(QByteArray& buffer);
void enumerateComPorts();
void usePortByFriendlyName(const QString &friendlyName);
void processDebug(const QString &str);
void watchDirectory(const QString& dir);
void updateImageList(bool reloadDirectory = true);
void boldifyItem(QStandardItem *pItem);
void readSettings();
void writeSettings() const;
void setupActionGroups();
void selectActionByName(const QList<QAction *>& actions, const QString& name) const;
void updateDirListColors();
void getBgFrAndFgColors(QColor &bgColor, QColor& frColor, QColor &fgColor);
void getMachineAndPaletteTheme(CbmMachineTheme*& pMachine, const QRgb *&pEmulatorPalette);
void cbmCursorVisible(bool visible = true);
Ui::MainWindow *ui;
QSerialPort m_port;
QByteArray m_pendingBuffer;
QByteArray m_unexpectedBuffer;
bool m_isConnected;
FacilityMap m_clientFacilities;
Interface m_iface;
QList<QSerialPortInfo> m_ports;
QStandardItemModel* m_dirListItemModel;
QFileInfoList m_filteredInfoList;
QFileInfoList m_infoList;
bool m_isInitialized;
QStringList m_imageDirListing;
AppSettings m_appSettings;
ushort m_totalReadWritten;
QString m_loadSaveName;
QFileSystemWatcher m_fsWatcher;
//#ifdef QT_DEBUG
QByteArray m_delayedData;
QFile m_simFile;
//#endif
enum ProcessingState {
simsOff, // No simulation, a REAL command.
simsDriveStat,
simsDriveStatString,
simsOpenResponse,
simsDisplayDirEntry,
simsDriveCmd,
simsLoadCmd,
simsOpenSaveResponse,
simsSaveCmd,
simsCloseCmd
} m_simulatedState;
void simulateData(const QByteArray& data);
void processData(void);
void delayedSimulate(ProcessingState newState, const QByteArray &data);
void delayedSimNoResponse(ProcessingState newState, const QByteArray& data);
};
#endif // MAINWINDOW_HPP