33 lines
947 B
C++
33 lines
947 B
C++
#include "mainwindow.h"
|
|
#include "SingleInstanceManager.h"
|
|
|
|
#include <QApplication>
|
|
#include <QIcon>
|
|
#include <QMessageBox>
|
|
#include <QObject>
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QApplication a(argc, argv);
|
|
|
|
// 设置应用程序图标
|
|
a.setWindowIcon(QIcon(":/common/resource/logo.png"));
|
|
|
|
// 使用 SingleInstanceManager 检查单例
|
|
SingleInstanceManager instanceManager("ParticleSizeApp_SingleInstance_Key");
|
|
|
|
if (instanceManager.isAnotherInstanceRunning()) {
|
|
// 已有实例在运行,显示提示信息并退出
|
|
QMessageBox::information(nullptr,
|
|
QObject::tr("应用程序已运行"),
|
|
QObject::tr("粒子尺寸应用程序已经在运行中,请勿重复启动!"),
|
|
QMessageBox::Ok);
|
|
return 0;
|
|
}
|
|
|
|
// 没有其他实例运行,正常启动应用程序
|
|
MainWindow w;
|
|
w.show();
|
|
|
|
return a.exec();
|
|
} |