-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
45 lines (38 loc) · 1.16 KB
/
main.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
45
#include <QApplication>
#include <QDebug>
#include <QLocale>
#include <QString>
#include <QTranslator>
#include <QProcess>
#include "BigPictureTV.h"
#include "Utils.h"
bool isAnotherInstanceRunning(const QString& processName)
{
QProcess process;
process.start("tasklist", QStringList() << "/FI" << QString("IMAGENAME eq %1").arg(processName));
process.waitForFinished();
QString output = process.readAllStandardOutput();
int count = output.count(processName, Qt::CaseInsensitive);
return count > 1;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(false);
if (Utils::isWindows10()) {
a.setStyle("fusion");
}
const QString processName = "BigPictureTV.exe";
if (isAnotherInstanceRunning(processName)) {
qDebug() << "Another instance is already running. Exiting...";
return 0;
}
QLocale locale;
QString languageCode = locale.name().section('_', 0, 0);
QTranslator translator;
if (translator.load(":/translations/BigPictureTV_" + languageCode + ".qm")) {
a.installTranslator(&translator);
}
BigPictureTV w;
return a.exec();
}