int main(int argc, char *argv[]) { LXQt::Application a(argc, argv); LXQt::Translator::translateApplication(); LXQt::PowerManager powermanager(&a); LXQt::ScreenSaver screensaver(&a); QCommandLineParser parser; parser.setApplicationDescription(QStringLiteral("lxqt-leave")); parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption logoutOption(QStringLiteral("logout"), QCoreApplication::translate("main", "Logout.")); parser.addOption(logoutOption); QCommandLineOption lockscreenOption(QStringLiteral("lockscreen"), QCoreApplication::translate("main", "Lockscreen.")); parser.addOption(lockscreenOption); QCommandLineOption suspendOption(QStringLiteral("suspend"), QCoreApplication::translate("main", "Suspend.")); parser.addOption(suspendOption); QCommandLineOption hibernateOption(QStringLiteral("hibernate"), QCoreApplication::translate("main", "Hibernate.")); parser.addOption(hibernateOption); QCommandLineOption shutdownOption(QStringLiteral("shutdown"), QCoreApplication::translate("main", "Shutdown.")); parser.addOption(shutdownOption); QCommandLineOption rebootOption(QStringLiteral("reboot"), QCoreApplication::translate("main", "Reboot.")); parser.addOption(rebootOption); parser.process(a); if (parser.isSet(logoutOption)) { powermanager.logout(); return 0; } if (parser.isSet(lockscreenOption)) { a.connect(&screensaver, &LXQt::ScreenSaver::done, &a, &LXQt::Application::quit); screensaver.lockScreen(); a.exec(); return 0; } if (parser.isSet(suspendOption)) { powermanager.suspend(); return 0; } if (parser.isSet(hibernateOption)) { powermanager.hibernate(); return 0; } if (parser.isSet(shutdownOption)) { powermanager.shutdown(); return 0; } if (parser.isSet(rebootOption)) { powermanager.reboot(); return 0; } LeaveDialog dialog; dialog.setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, dialog.size(), qApp->desktop()->screenGeometry(QCursor::pos()))); dialog.setMaximumSize(dialog.minimumSize()); return dialog.exec(); }
QT_USE_NAMESPACE int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QCommandLineParser parser; parser.setApplicationDescription(QLatin1String("winrtrunner installs, runs, and collects test " "results for packages made with Qt.")); parser.addPositionalArgument(QStringLiteral("package [arguments]"), QLatin1String("The executable or package manifest to act upon. " "Arguments after the package name will be passed " "to the application when it starts.")); QCommandLineOption testOption(QStringLiteral("test"), QLatin1String("Install, start, collect output, stop (if needed), " "and uninstall the package. This is the " "default action of winrtrunner.")); parser.addOption(testOption); QCommandLineOption startOption(QStringLiteral("start"), QLatin1String("Start the package. The package is installed if " "it is not already installed. Pass --install to " "force reinstallation.")); parser.addOption(startOption); QCommandLineOption debugOption(QStringLiteral("debug"), QLatin1String("Start the package with the debugger attached. " "The package is installed if it is not already " "installed. Pass --install to force " "reinstallation."), QLatin1Literal("debugger")); parser.addOption(debugOption); QCommandLineOption debuggerArgumentsOption(QStringLiteral("debugger-arguments"), QLatin1String("Arguments that are passed to the " "debugger when --debug is used. If no " "debugger was provided this option is " "ignored."), QLatin1String("arguments")); parser.addOption(debuggerArgumentsOption); QCommandLineOption suspendOption(QStringLiteral("suspend"), QLatin1String("Suspend a running package. When combined " "with --stop or --test, the app will be " "suspended before being terminated.")); parser.addOption(suspendOption); QCommandLineOption stopOption(QStringLiteral("stop"), QLatin1String("Terminate a running package. Can be be " "combined with --start and --suspend.")); parser.addOption(stopOption); QCommandLineOption waitOption(QStringLiteral("wait"), QLatin1String("If the package is running, waits the given " "number of seconds before continuing to the next " "task. Passing 0 causes the runner to wait " "indefinitely."), QStringLiteral("seconds")); parser.addOption(waitOption); QCommandLineOption installOption(QStringLiteral("install"), QStringLiteral("(Re)installs the package.")); parser.addOption(installOption); QCommandLineOption removeOption(QStringLiteral("remove"), QStringLiteral("Uninstalls the package.")); parser.addOption(removeOption); QCommandLineOption deviceOption(QStringLiteral("device"), QLatin1String("Specifies the device to target as a device name " " or index. Use --list-devices to find available " "devices. The default device is the first device " "found for the active run profile."), QStringLiteral("name|index")); parser.addOption(deviceOption); QCommandLineOption profileOption(QStringLiteral("profile"), QStringLiteral("Force a particular run profile."), QStringLiteral("name")); parser.addOption(profileOption); QCommandLineOption listDevicesOption(QStringLiteral("list-devices"), QLatin1String("List the available devices " "(for use with --device).")); parser.addOption(listDevicesOption); QCommandLineOption verbosityOption(QStringLiteral("verbose"), QLatin1String("The verbosity level of the message output " "(0 - silent, 1 - info, 2 - debug). Defaults to 1."), QStringLiteral("level"), QStringLiteral("1")); parser.addOption(verbosityOption); QCommandLineOption ignoreErrorsOption(QStringLiteral("ignore-errors"), QStringLiteral("Always exit with code 0, regardless of the error state.")); parser.addOption(ignoreErrorsOption); parser.addHelpOption(); parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); QStringList arguments = QCoreApplication::arguments(); parser.parse(arguments); QStringList filterRules = QStringList() // Default logging rules << QStringLiteral("qt.winrtrunner.warning=true") << QStringLiteral("qt.winrtrunner.critical=true") << QStringLiteral("qt.winrtrunner.app=true"); if (parser.isSet(verbosityOption)) { bool ok; uint verbosity = parser.value(verbosityOption).toUInt(&ok); if (!ok || verbosity > 2) { qCCritical(lcWinRtRunner) << "Incorrect value specified for verbosity."; parser.showHelp(1); } switch (verbosity) { case 2: // Enable debug print filterRules.append(QStringLiteral("qt.winrtrunner.debug=true")); break; case 1: // Remove warnings filterRules.removeFirst(); // fall through case 0: // Silent filterRules.removeFirst(); // fall through default: // Impossible break; } } QLoggingCategory::setFilterRules(filterRules.join(QLatin1Char('\n'))); if (parser.isSet(listDevicesOption)) { std::wcout << "Available devices:\n"; const QMap<QString, QStringList> deviceNames = Runner::deviceNames(); foreach (const QString &profile, deviceNames.keys()) { std::wcout << reinterpret_cast<const wchar_t *>(profile.utf16()) << ":\n"; int index = 0; foreach (const QString &device, deviceNames.value(profile)) { std::wcout << " " << index++ << ' ' << reinterpret_cast<const wchar_t *>(device.utf16()) << '\n'; } } std::wcout << std::endl; return 0; }