File: main.cpp

package info (click to toggle)
gammaray 3.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,612 kB
  • sloc: cpp: 94,643; ansic: 2,227; sh: 336; python: 164; yacc: 90; lex: 82; xml: 61; makefile: 26
file content (59 lines) | stat: -rw-r--r-- 2,159 bytes parent folder | download
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
49
50
51
52
53
54
55
56
57
58
59
/*
  main.cpp

  This file is part of GammaRay, the Qt application inspection and manipulation tool.

  SPDX-FileCopyrightText: 2013 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
  Author: Volker Krause <volker.krause@kdab.com>

  SPDX-License-Identifier: GPL-2.0-or-later

  Contact KDAB at <info@kdab.com> for commercial licensing options.
*/

#include <config-gammaray.h>
#include <config-gammaray-version.h>

#include "client.h"
#include "clientconnectionmanager.h"

#include <common/objectbroker.h>
#include <common/paths.h>
#include <common/translator.h>

#include <QApplication>
#include <QStringList>

using namespace GammaRay;

int main(int argc, char **argv)
{
    QCoreApplication::setOrganizationName(QStringLiteral("KDAB"));
    QCoreApplication::setOrganizationDomain(QStringLiteral("kdab.com"));
    QCoreApplication::setApplicationName(QStringLiteral("GammaRay"));
    QCoreApplication::setApplicationVersion(QStringLiteral(GAMMARAY_COMPACT_VERSION_STRING));
    QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); // for QWebEngine
    QGuiApplication::setDesktopFileName(QStringLiteral("GammaRay"));

    QApplication app(argc, argv);
    Paths::setRelativeRootPath(GAMMARAY_INVERSE_LIBEXEC_DIR);
    Translator::loadStandAloneTranslations();
    ClientConnectionManager::init();

    QUrl serverUrl;
    if (app.arguments().size() == 2) {
        serverUrl = QUrl::fromUserInput(app.arguments().at(1));
    } else {
        serverUrl.setScheme(QStringLiteral("tcp"));
        serverUrl.setHost(QStringLiteral(GAMMARAY_DEFAULT_LOCAL_ADDRESS));
        serverUrl.setPort(Client::defaultPort());
    }

    ClientConnectionManager conMan;
    QObject::connect(&conMan, &ClientConnectionManager::ready, &conMan, &ClientConnectionManager::createMainWindow);
    QObject::connect(&conMan, &ClientConnectionManager::disconnected, QApplication::instance(), &QCoreApplication::quit);
    QObject::connect(&conMan, &ClientConnectionManager::persistentConnectionError, &conMan,
                     &ClientConnectionManager::handlePersistentConnectionError);
    conMan.connectToHost(serverUrl);
    return app.exec();
}