-
Notifications
You must be signed in to change notification settings - Fork 26
/
myapp.cpp
47 lines (37 loc) · 1.01 KB
/
myapp.cpp
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
#include "myapp.h"
#include "mainwindow.h"
extern QString fileName, CurVersion;
extern QVector<QString> filelist;
extern QWidgetList wdlist;
extern MainWindow* mw_one;
bool MyApplication::event(QEvent* event) {
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent* openEvent = static_cast<QFileOpenEvent*>(event);
fileName = openEvent->file();
if (mw_one->isActiveWindow()) {
}
mw_one->loadFile(mw_one->openFile(fileName), -1, -1);
}
return QApplication::event(event);
}
void MyApplication::new_win() {
if (!fileName.isEmpty()) {
bool newfile = true;
for (int i = 0; i < filelist.count(); i++) {
if (filelist.at(i) == fileName) {
newfile = false;
setActiveWindow(wdlist.at(i));
wdlist.at(i)->raise();
break;
}
}
if (newfile) {
MainWindow* mw = new MainWindow();
mw_one = mw;
mw->loadFile(mw->openFile(fileName), -1, -1);
mw->show();
filelist.push_back(fileName);
wdlist.push_back(mw);
}
}
}