File indexing completed on 2024-04-21 05:52:50

0001 /*
0002  * Copyright 2010-2012 Bart Kroon <bart@tarmack.eu>
0003  * Copyright 2012, 2013 Martin Sandsmark <martin.sandsmark@kde.org>
0004  * 
0005  * Redistribution and use in source and binary forms, with or without
0006  * modification, are permitted provided that the following conditions
0007  * are met:
0008  * 
0009  * 1. Redistributions of source code must retain the above copyright
0010  *   notice, this list of conditions and the following disclaimer.
0011  * 2. Redistributions in binary form must reproduce the above copyright
0012  *   notice, this list of conditions and the following disclaimer in the
0013  *   documentation and/or other materials provided with the distribution.
0014  * 
0015  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0016  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0017  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0018  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0019  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0020  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0021  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0022  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0023  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0024  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0025  */
0026 
0027 #include "Mangonel.h"
0028 #include "IconProvider.h"
0029 
0030 #include <QApplication>
0031 #include <KDBusService>
0032 #include <KAboutData>
0033 #include <klocalizedstring.h>
0034 #include <QQmlApplicationEngine>
0035 #include <QQuickWindow>
0036 #include <QSurfaceFormat>
0037 
0038 
0039 int main(int argc, char** argv)
0040 {
0041     QApplication app(argc, argv);
0042     app.setOrganizationName("KDE");
0043     app.setQuitOnLastWindowClosed(false);
0044 
0045     KAboutData aboutData (
0046                        QStringLiteral("mangonel"),
0047                        i18n("Mangonel"),
0048                        QStringLiteral("1.1"));
0049     aboutData.setShortDescription(i18n("A simple application launcher by KDE."));
0050     aboutData.setLicense(KAboutLicense::BSDL);
0051     aboutData.setHomepage(QByteArray("www.tarmack.eu/mangonel/"));
0052     aboutData.addAuthor(i18n("Martin Sandsmark"), i18n("Developer"), "martin.sandsmark@kde.org", "http://iskrembilen.com/");
0053     aboutData.addAuthor(i18n("Bart Kroon"), i18n("Developer, original author"), "", "http://tarmack.eu/");
0054     KAboutData::setApplicationData(aboutData);
0055 
0056     KDBusService service(KDBusService::Unique);
0057     QObject::connect(&service, &KDBusService::activateRequested, Mangonel::instance(), &Mangonel::triggered);
0058 
0059     QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat();
0060     defaultFormat.setOption(QSurfaceFormat::ResetNotification);
0061     QSurfaceFormat::setDefaultFormat(defaultFormat);
0062 
0063 
0064     qmlRegisterSingletonType<Mangonel>("org.kde", 1, 0, "Mangonel", [](QQmlEngine *, QJSEngine*) -> QObject* {
0065         QQmlEngine::setObjectOwnership(Mangonel::instance(), QQmlEngine::CppOwnership);
0066         return Mangonel::instance();
0067     });
0068     QQuickWindow::setDefaultAlphaBuffer(true);
0069 
0070     QQmlApplicationEngine qmlEngine;
0071     qmlEngine.addImageProvider("icon", new IconProvider);
0072     qmlEngine.load(QUrl("qrc:/main.qml"));
0073     return app.exec();
0074 }
0075 
0076 // kate: indent-mode cstyle; space-indent on; indent-width 4;