本文整理汇总了C++中Launcher::setupServices方法的典型用法代码示例。如果您正苦于以下问题:C++ Launcher::setupServices方法的具体用法?C++ Launcher::setupServices怎么用?C++ Launcher::setupServices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Launcher
的用法示例。
在下文中一共展示了Launcher::setupServices方法的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());
}