当前位置: 首页>>代码示例>>C++>>正文


C++ Launcher::cleanup方法代码示例

本文整理汇总了C++中Launcher::cleanup方法的典型用法代码示例。如果您正苦于以下问题:C++ Launcher::cleanup方法的具体用法?C++ Launcher::cleanup怎么用?C++ Launcher::cleanup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Launcher的用法示例。


在下文中一共展示了Launcher::cleanup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);
    app.setApplicationName(QStringLiteral("ksbinit"));
    app.setApplicationVersion(QStringLiteral("0.1"));
    app.setOrganizationDomain(QStringLiteral("kde.org"));
    app.setOrganizationName(QStringLiteral("KDE"));

    QCommandLineParser parser;
    parser.setApplicationDescription(QStringLiteral("KDE Sandbox Init - a helper utility to improve integration "
                                                    "of sandboxed KDE application with the outside environment."));

    QCommandLineOption nokdeinit(QStringLiteral("no-kdeinit"),
                                 QStringLiteral("Launch the application directly instead of using kdeinit5"));
    parser.addOption(nokdeinit);
    parser.addPositionalArgument(QStringLiteral("app"),
                                 QStringLiteral("Application to launch"),
                                 QStringLiteral("APP [ARGS]"));
    parser.addHelpOption();
    parser.addVersionOption();

    QStringList args = app.arguments();

    parser.parse(args);

    if (parser.isSet(QStringLiteral("help")) && parser.positionalArguments().isEmpty()) {
        parser.showHelp();
        // exit 0
    }
    if (parser.isSet(QStringLiteral("version")) && parser.positionalArguments().isEmpty()) {
        parser.showVersion();
        // exit 0
    }

    // Remove our name from the args list, this leaves name of the app to launch
    // and its arguments
    args.removeFirst();

    Launcher::Flags flags = Launcher::NoFlags;
    if (parser.isSet(nokdeinit)) {
        args.removeFirst();
        flags |= Launcher::NoKDEInit;
    }

    Launcher launcher;
    QObject::connect(&launcher, &Launcher::quit,
                     &app, &QCoreApplication::quit);

    // Connects to the outside bus via DBUS_SESSION_BUS_ADDRESS
    if (!launcher.connectToWorld()) {
        qFatal("Failed to establish connection with the outside session bus: %s", qPrintable(launcher.errorText()));
    }

    // Launches new DBus session inside sandbox and connects to it too
    if (!launcher.connectToSandbox()) {
        qFatal("Failed to establish connection with the sandbox session bus: %s", qPrintable(launcher.errorText()));
    }

    // Create bunch of default KDE DBus services on the sandbox bus. We will
    // relay calls to them to the actual session bus
    if (!launcher.setupServices()) {
        qFatal("Failed to setup DBus services: %s", qPrintable(launcher.errorText()));
    }

    // Now launch the application itself
    if (!launcher.launchApp(args, flags)) {
        qFatal("Failed to start application: %s", qPrintable(launcher.errorText()));
    }

    const int thisRet = app.exec();

    // Clean up while QApp stil exists
    launcher.cleanup();

    return (launcher.retVal() == -1 ? thisRet : launcher.retVal());
}
开发者ID:danvratil,项目名称:ksbinit,代码行数:76,代码来源:main.cpp


注:本文中的Launcher::cleanup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。