File indexing completed on 2024-05-05 10:03:04
0001 /* 0002 This file is part of KCachegrind. 0003 0004 SPDX-FileCopyrightText: 2003-2016 Josef Weidendorfer <Josef.Weidendorfer@gmx.de> 0005 0006 SPDX-License-Identifier: GPL-2.0-only 0007 */ 0008 0009 /* 0010 * KCachegrind startup 0011 */ 0012 0013 // for KCACHEGRIND_VERSION 0014 #include "../version.h" 0015 0016 0017 #include <QApplication> 0018 #include <QCommandLineParser> 0019 #include <KAboutData> 0020 #include <KLocalizedString> 0021 #include <KSharedConfig> 0022 #include <KDBusService> 0023 0024 #include "kdeconfig.h" 0025 #include "toplevel.h" 0026 #include "tracedata.h" 0027 #include "loader.h" 0028 0029 int main( int argc, char ** argv ) 0030 { 0031 QApplication a(argc, argv); 0032 KLocalizedString::setApplicationDomain("kcachegrind"); 0033 KAboutData aboutData(QStringLiteral("kcachegrind"), 0034 i18n("KCachegrind"), 0035 KCACHEGRIND_VERSION, 0036 i18n("KDE Frontend for Callgrind/Cachegrind"), 0037 KAboutLicense::GPL, 0038 i18n("(C) 2002 - 2016"), QString(), 0039 QStringLiteral("https://kcachegrind.github.io")); 0040 aboutData.addAuthor(i18n("Josef Weidendorfer"), 0041 i18n("Author/Maintainer"), 0042 QStringLiteral("Josef.Weidendorfer@gmx.de")); 0043 aboutData.setOrganizationDomain("kde.org"); 0044 aboutData.setDesktopFileName(QStringLiteral("org.kde.kcachegrind")); 0045 0046 KAboutData::setApplicationData(aboutData); 0047 QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("kcachegrind"))); 0048 0049 KDBusService service(KDBusService::Multiple); 0050 0051 // KGlobal::locale()->insertCatalog("kcachegrind_qt"); 0052 Loader::initLoaders(); 0053 0054 KConfig* kc = KSharedConfig::openConfig().data(); 0055 ConfigStorage::setStorage(new KDEConfigStorage(kc)); 0056 0057 if (a.isSessionRestored()){ 0058 int n = 1; 0059 while (KMainWindow::canBeRestored(n)){ 0060 (new TopLevel())->restore(n); 0061 n++; 0062 } 0063 } 0064 else { 0065 TopLevel* t; 0066 0067 QCommandLineParser parser; 0068 parser.addPositionalArgument(QStringLiteral("trace"), i18n("Show information of this trace"), i18n("[trace...]")); 0069 aboutData.setupCommandLine(&parser); 0070 parser.process(a); 0071 aboutData.processCommandLine(&parser); 0072 0073 int nbArgs = parser.positionalArguments().count(); 0074 if (nbArgs>0) { 0075 t = new TopLevel(); 0076 t->show(); 0077 foreach(const QString &arg, parser.positionalArguments()) { 0078 t->loadDelayed(arg); 0079 } 0080 } 0081 else { 0082 // load trace in current dir 0083 t = new TopLevel(); 0084 t->show(); 0085 t->loadDelayed(QStringLiteral(".")); 0086 } 0087 } 0088 0089 a.connect( &a, &QGuiApplication::lastWindowClosed, &a, &QCoreApplication::quit ); 0090 int res = a.exec(); 0091 0092 // to make leak checking in valgrind happy... 0093 Loader::deleteLoaders(); 0094 ProfileContext::cleanup(); 0095 ConfigStorage::cleanup(); 0096 0097 return res; 0098 }