File indexing completed on 2024-05-05 10:07:27
0001 /*************************************************************************** 0002 * Copyright (C) 2008-2010 by Daniel Nicoletti * 0003 * dantti12@gmail.com * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; see the file COPYING. If not, write to * 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0018 * Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 0021 #include "PkSession.h" 0022 #include <config.h> 0023 0024 #include <QApplication> 0025 #include <QDebug> 0026 #include <QIcon> 0027 #include <QSessionManager> 0028 0029 #include <KAboutData> 0030 #include <KConfig> 0031 #include <KDBusService> 0032 #include <KLocalizedString> 0033 0034 #include <QLoggingCategory> 0035 0036 Q_LOGGING_CATEGORY(APPER_SESSION, "apper.session") 0037 0038 int main(int argc, char **argv) 0039 { 0040 QApplication app(argc, argv); 0041 app.setWindowIcon(QIcon::fromTheme(QLatin1String("system-software-install"))); 0042 0043 KLocalizedString::setApplicationDomain("apper"); 0044 0045 KAboutData aboutData(QLatin1String("PkSession"), 0046 QLatin1String("apper"), 0047 QLatin1String(APPER_VERSION), 0048 i18n("Apper PackageKit Session helper"), 0049 KAboutLicense::GPL); 0050 0051 aboutData.addAuthor(i18n("Daniel Nicoletti"), QString(), QLatin1String("dantti12@gmail.com"), QLatin1String("http://dantti.wordpress.com")); 0052 aboutData.addAuthor(i18n("Trever Fischer"), QString(), QLatin1String("wm161@wm161.net"), QLatin1String("http://wm161.net")); 0053 0054 aboutData.addCredit(i18n("Adrien Bustany"), i18n("libpackagekit-qt and other stuff"), QLatin1String("@")); 0055 KAboutData::setApplicationData(aboutData); 0056 0057 // Let's ensure we only have one PkSession at any one time on the same session 0058 KDBusService service(KDBusService::Unique); 0059 auto disableSessionManagement = [](QSessionManager &sm) { 0060 sm.setRestartHint(QSessionManager::RestartNever); 0061 }; 0062 QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); 0063 QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); 0064 0065 PkSession session; 0066 return app.exec(); 0067 }