summaryrefslogtreecommitdiffstats
path: root/main.cpp
blob: 33e06ac57d68464d796be7a8b2a115a1dbf189f6 (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[])
{
#if SINGLE_APP
    SingleApplication app(argc, argv, "ijhackQtPass");
    if (app.isRunning()) {
        if (argc == 1 ) {
            app.sendMessage("show");
        } else if (argc >= 2) {
            QString text = "";
            for (int i = 1; i < argc; ++i) {
                text += argv[i];
                if (argc >= (i - 2)) {
                    text += " ";
                }
                app.sendMessage(text);
            }
        }
        return 0;
    }
#else
    QApplication app(argc, argv);
#endif
   
    QCoreApplication::setOrganizationName("IJHack");
    QCoreApplication::setOrganizationDomain("ijhack.org");
    QCoreApplication::setApplicationName("QtPass");
    QCoreApplication::setApplicationVersion("0.1.0");

    //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.checkConfig();
    w.show();

    return app.exec();
}