summaryrefslogtreecommitdiffstats
path: root/main.cpp
blob: a7a82d947b3941480da472852d3f4fe659f1eba2 (plain)
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
46
47
48
#include "mainwindow.h"
#include <QApplication>
#include <QTranslator>

int main(int argc, char *argv[])
{
    // check for stupid apple psid or whatever flag
    QString text = "";
    for (int i = 1; i < argc; ++i) {
        if (i > 1) {
            text += " ";
        }
        text += argv[i];
    }
#if SINGLE_APP
    QString name = qgetenv("USER");
    if (name.isEmpty())
        name = qgetenv("USERNAME");
    //qDebug() << name;
    SingleApplication app(argc, argv, name + "QtPass");
    if (app.isRunning()) {
        app.sendMessage(text);
        return 0;
    }
#else
    QApplication app(argc, argv);
#endif

    QCoreApplication::setOrganizationName("IJHack");
    QCoreApplication::setOrganizationDomain("ijhack.org");
    QCoreApplication::setApplicationName("QtPass");
    QCoreApplication::setApplicationVersion(VERSION);

    //Setup and load translator for localization
    QTranslator translator;
    QString locale = QLocale::system().name();
    translator.load(QString(":localization/localization_") + locale + QString(".qm"));
    app.installTranslator(&translator);

    MainWindow w;

    app.setActiveWindow(&w);
    app.setWindowIcon(QIcon(":artwork/icon.png"));
    w.setApp(&app);
    w.setText(text);
    w.show();
    return app.exec();
}