-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (40 loc) · 1.48 KB
/
Copy pathmain.cpp
File metadata and controls
54 lines (40 loc) · 1.48 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
#include "TextEditorv102.h"
#include <QtWidgets/QApplication>
#include<QFile>
#include<QDebug>
#include <QTextStream>
#include <QFileSystemWatcher>
#include<QPixMap>
#include<QSplashScreen>
void openFileInEditor(const QString& fileName, TextEditorv102& editor) {
editor.openFile(fileName);
qDebug() << "Opening file in text editor:" << fileName;
}
int main(int argc, char* argv[]) {
QApplication a(argc, argv);
QPixmap originalPixmap("splash.png");
QPixmap resizedPixmap = originalPixmap.scaled(800, 600, Qt::KeepAspectRatio);
QSplashScreen splash(resizedPixmap);
splash.show();
TextEditorv102 w;
w.show();
splash.finish(&w);
QString commandFilePath = "C:\\Users\\malik\\source\\repos\\Dos v1\\dos_commands.txt";
QFileSystemWatcher watcher;
watcher.addPath(commandFilePath);
QObject::connect(&watcher, &QFileSystemWatcher::fileChanged, [&w, &commandFilePath]() {
QFile file(commandFilePath);
if (!file.exists() || !file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "dos_commands.txt does not exist or cannot be opened";
return;
}
QTextStream in(&file);
QString command = in.readAll().trimmed();
if (command.startsWith("edit")) {
QString fileName = command.mid(5).trimmed();
openFileInEditor(fileName, w);
}
file.close();
});
return a.exec();
}