45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
|
|
#include <QApplication>
|
|||
|
|
#include <QCommandLineOption>
|
|||
|
|
#include <QCommandLineParser>
|
|||
|
|
#include <QIcon>
|
|||
|
|
|
|||
|
|
#include "MainWindow.h"
|
|||
|
|
#include "Version.h"
|
|||
|
|
|
|||
|
|
int main(int argc, char* argv[])
|
|||
|
|
{
|
|||
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|||
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|||
|
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
|||
|
|
#endif
|
|||
|
|
QApplication application(argc, argv);
|
|||
|
|
application.setApplicationName(
|
|||
|
|
QString::fromUtf8(PARKINGSPACEGUIDEVIEW_APP_NAME));
|
|||
|
|
application.setApplicationVersion(
|
|||
|
|
QString::fromLatin1(PARKINGSPACEGUIDEVIEW_VERSION_STRING));
|
|||
|
|
application.setWindowIcon(QIcon(QStringLiteral(":/app/logo.png")));
|
|||
|
|
|
|||
|
|
QCommandLineParser parser;
|
|||
|
|
parser.setApplicationDescription(
|
|||
|
|
QStringLiteral("ParkingSpaceGuideApp 远程停机引导显示端"));
|
|||
|
|
parser.addHelpOption();
|
|||
|
|
parser.addVersionOption();
|
|||
|
|
QCommandLineOption discoveryPortOption(
|
|||
|
|
QStringList() << QStringLiteral("discovery-port"),
|
|||
|
|
QStringLiteral("UDP设备发现端口,默认5555。"),
|
|||
|
|
QStringLiteral("port"),
|
|||
|
|
QStringLiteral("5555"));
|
|||
|
|
parser.addOption(discoveryPortOption);
|
|||
|
|
parser.process(application);
|
|||
|
|
|
|||
|
|
bool portOk = false;
|
|||
|
|
int discoveryPort = parser.value(discoveryPortOption).toInt(&portOk);
|
|||
|
|
if (!portOk || discoveryPort <= 0 || discoveryPort > 65535) {
|
|||
|
|
discoveryPort = 5555;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
MainWindow window(discoveryPort);
|
|||
|
|
window.show();
|
|||
|
|
return application.exec();
|
|||
|
|
}
|