forked from ic005k/OCAuxiliaryTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
myapp.cpp
44 lines (35 loc) · 1016 Bytes
/
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
#include "myapp.h"
#include "mainwindow.h"
extern QString PlistFileName;
extern QVector<QString> openFileLists;
extern QWidgetList wdlist;
extern MainWindow* mw_one;
bool MyApplication::event(QEvent* event) {
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent* openEvent = static_cast<QFileOpenEvent*>(event);
PlistFileName = openEvent->file();
if (mw_one->isActiveWindow()) mw_one->openFile(PlistFileName);
}
return QApplication::event(event);
}
void MyApplication::new_win() {
if (!PlistFileName.isEmpty()) {
bool newfile = true;
for (int i = 0; i < openFileLists.count(); i++) {
if (openFileLists.at(i) == PlistFileName) {
newfile = false;
setActiveWindow(wdlist.at(i));
wdlist.at(i)->raise();
break;
}
}
if (newfile) {
MainWindow* mw = new MainWindow();
mw_one = mw;
mw->openFile(PlistFileName);
mw->show();
openFileLists.push_back(PlistFileName);
wdlist.push_back(mw);
}
}
}