Code reformatted using kde-dev-scripts/astyle-kdelibs
This commit is contained in:
parent
b996033ca1
commit
b506f3486b
32
src/main.cpp
32
src/main.cpp
|
@ -11,10 +11,9 @@
|
|||
|
||||
using namespace Snore;
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app ( argc, argv );
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("snore-send");
|
||||
app.setOrganizationName("snore-send");
|
||||
app.setApplicationVersion(Snore::Version::version());
|
||||
|
@ -33,47 +32,41 @@ int main ( int argc, char *argv[] )
|
|||
QCommandLineOption applicationName(QStringList() << "a" << "application", "Set the notification applicattion.", "application", app.applicationName());
|
||||
parser.addOption(applicationName);
|
||||
|
||||
|
||||
QCommandLineOption alertName(QStringList() << "c" << "alert", "Set the notification alert class.","alert", "Default");
|
||||
QCommandLineOption alertName(QStringList() << "c" << "alert", "Set the notification alert class.", "alert", "Default");
|
||||
parser.addOption(alertName);
|
||||
|
||||
QCommandLineOption iconPath(QStringList() << "i" << "icon", "Set the notification icon.","icon", ":/root/snore.png");
|
||||
QCommandLineOption iconPath(QStringList() << "i" << "icon", "Set the notification icon.", "icon", ":/root/snore.png");
|
||||
parser.addOption(iconPath);
|
||||
|
||||
QCommandLineOption backend(QStringList() << "b" << "backend", "Set the notification backend.","backend");
|
||||
QCommandLineOption backend(QStringList() << "b" << "backend", "Set the notification backend.", "backend");
|
||||
parser.addOption(backend);
|
||||
|
||||
QCommandLineOption silent(QStringList() << "silent", "Don't print to stdout.");
|
||||
parser.addOption(silent);
|
||||
|
||||
|
||||
|
||||
parser.process(app);
|
||||
if(parser.isSet(title) && parser.isSet(message))
|
||||
{
|
||||
if (parser.isSet(title) && parser.isSet(message)) {
|
||||
SnoreCore core;
|
||||
|
||||
core.loadPlugins(SnorePlugin::BACKEND);
|
||||
if(parser.isSet(backend)?!core.setPrimaryNotificationBackend(parser.value(backend)):!core.setPrimaryNotificationBackend())
|
||||
{
|
||||
if (parser.isSet(backend) ? !core.setPrimaryNotificationBackend(parser.value(backend)) : !core.setPrimaryNotificationBackend()) {
|
||||
std::cerr << "Failed to set backend: " << qPrintable(parser.value(backend)) << " avalible backends: " << qPrintable(core.notificationBackends().join(", ")) << std::endl;
|
||||
return 1;
|
||||
}
|
||||
Icon icon(parser.value(iconPath));
|
||||
Application application(parser.value(applicationName),icon);
|
||||
Alert alert(parser.value(alertName),icon);
|
||||
Application application(parser.value(applicationName), icon);
|
||||
Alert alert(parser.value(alertName), icon);
|
||||
application.addAlert(alert);
|
||||
|
||||
core.registerApplication(application);
|
||||
|
||||
Notification n(application, alert, parser.value(title), parser.value(message),icon);
|
||||
Notification n(application, alert, parser.value(title), parser.value(message), icon);
|
||||
|
||||
core.broadcastNotification(n);
|
||||
int returnCode = -1;
|
||||
|
||||
app.connect(&core, &SnoreCore::notificationClosed, [&](Notification noti){
|
||||
if(!parser.isSet(silent))
|
||||
{
|
||||
app.connect(&core, &SnoreCore::notificationClosed, [&](Notification noti) {
|
||||
if (!parser.isSet(silent)) {
|
||||
QString reason;
|
||||
QDebug(&reason) << noti.closeReason();
|
||||
std::cout << qPrintable(reason) << std::endl;
|
||||
|
@ -87,4 +80,3 @@ int main ( int argc, char *argv[] )
|
|||
parser.showHelp(1);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue