59 lines
1.1 KiB
C++
Raw Normal View History

2023-07-21 21:46:24 +08:00
#include "mainwindow.h"
#include <QApplication>
#include <QSharedMemory>
#include <QMessageBox>
MainWindow* main_window=nullptr;
#include "only_run_by_file.h"
void onAppExit()
{
// 删除 run 文件
QFile::remove("run");
}
QString project_path;
QString map_path;
bool only_printf=false;
int main(int argc, char *argv[])
{
// for(int i=0;i<argc;i++)
// qDebug() <<argv[i];
if(argc>3)
{
project_path=argv[1];
map_path=argv[2];
only_printf=argv[3];
}else if(argc>2)
{
project_path=map_path=argv[1];
only_printf=argv[2];
}
if(argc>1)
{
project_path="./";
map_path="./";
only_printf=argv[1];
}
QApplication a(argc, argv);
only_run_by_file programController;
QObject::connect(&programController, &only_run_by_file::runFileDeleted, &a, &QCoreApplication::quit);
// 注册程序退出的处理函数
QObject::connect(&a, &QCoreApplication::aboutToQuit, onAppExit);
MainWindow w;
if(!only_printf) w.show();
return a.exec();
}