76 lines
2.2 KiB
C++
76 lines
2.2 KiB
C++
#include "mainwindow.h"
|
|
#include "IWheelMeasureStatus.h"
|
|
#include "IVrWheelMeasureConfig.h"
|
|
#include "CrashHandler.h"
|
|
|
|
#include <QApplication>
|
|
#include <QMetaType>
|
|
#include <QVector>
|
|
#include <QList>
|
|
#include <QPersistentModelIndex>
|
|
#include <QAbstractItemModel>
|
|
#include <QSharedMemory>
|
|
#include <QSystemSemaphore>
|
|
#include <QMessageBox>
|
|
#include <QStandardPaths>
|
|
#include <QDir>
|
|
#include <QDebug>
|
|
|
|
#include "Version.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QApplication a(argc, argv);
|
|
|
|
// 设置应用程序信息
|
|
a.setApplicationName("WheelMeasureApp");
|
|
a.setApplicationVersion(GetWheelMeasureFullVersion());
|
|
a.setOrganizationName("VisionRobot");
|
|
|
|
// 注册Qt元类型
|
|
qRegisterMetaType<QVector<int>>("QVector<int>");
|
|
qRegisterMetaType<QList<QPersistentModelIndex>>("QList<QPersistentModelIndex>");
|
|
qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>("QAbstractItemModel::LayoutChangeHint");
|
|
qRegisterMetaType<Qt::SortOrder>("Qt::SortOrder");
|
|
|
|
// 注册自定义元类型
|
|
qRegisterMetaType<WheelCameraParam>("WheelCameraParam");
|
|
qRegisterMetaType<WheelCameraPlaneCalibParam>("WheelCameraPlaneCalibParam");
|
|
qRegisterMetaType<WheelMeasureConfigResult>("WheelMeasureConfigResult");
|
|
qRegisterMetaType<WheelMeasureData>("WheelMeasureData");
|
|
qRegisterMetaType<WheelMeasureResult>("WheelMeasureResult");
|
|
|
|
// 单实例检查
|
|
const QString appKey = "WheelMeasureApp_SingleInstance_Key";
|
|
|
|
QSystemSemaphore semaphore(appKey + "_semaphore", 1);
|
|
semaphore.acquire();
|
|
|
|
QSharedMemory sharedMemory(appKey + "_memory");
|
|
|
|
bool isRunning = false;
|
|
|
|
if (sharedMemory.attach()) {
|
|
isRunning = true;
|
|
} else {
|
|
if (!sharedMemory.create(1)) {
|
|
qDebug() << "Unable to create shared memory segment:" << sharedMemory.errorString();
|
|
isRunning = true;
|
|
}
|
|
}
|
|
|
|
semaphore.release();
|
|
|
|
if (isRunning) {
|
|
QMessageBox::information(nullptr,
|
|
QObject::tr("应用程序已运行"),
|
|
QObject::tr("车轮拱高测量应用程序已经在运行中,请勿重复启动!"),
|
|
QMessageBox::Ok);
|
|
return 0;
|
|
}
|
|
|
|
MainWindow w;
|
|
w.show();
|
|
return a.exec();
|
|
}
|