File indexing completed on 2024-04-21 15:38:23
0001 /*************************************************************************** 0002 main.cpp - description 0003 ------------------- 0004 begin : Sat Dec 7 16:14:51 CET 2002 0005 copyright : (C) 2002 by Koos Vriezen 0006 email : 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 #include <unistd.h> 0018 0019 #include "config-kmplayer.h" 0020 #include <KAboutData> 0021 #include <KLocalizedString> 0022 0023 #include <QCommandLineParser> 0024 #include <QApplication> 0025 #include <QPointer> 0026 #include <qfileinfo.h> 0027 0028 #include "kmplayer.h" 0029 0030 static QUrl makeUrl(const QString& link) 0031 { 0032 QFileInfo info(link); 0033 if (info.exists()) 0034 return QUrl::fromLocalFile(info.absoluteFilePath()); 0035 return QUrl::fromUserInput(link); 0036 } 0037 0038 extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv) 0039 { 0040 setsid (); 0041 0042 QApplication app(argc, argv); 0043 KLocalizedString::setApplicationDomain("kmplayer"); 0044 0045 KAboutData aboutData(QStringLiteral("kmplayer"), 0046 i18n("KMPlayer"), 0047 QStringLiteral(KMPLAYER_VERSION_STRING), 0048 i18n("Media player"), KAboutLicense::GPL, 0049 i18n("(c) 2002-2016, Koos Vriezen"), QString(), QStringLiteral("http://kmplayer.kde.org")); 0050 aboutData.addAuthor(i18n("Koos Vriezen"), i18n("Maintainer"), QStringLiteral("koos.vriezen@gmail.com")); 0051 aboutData.setProductName(QByteArray("kmplayer")); 0052 aboutData.setOrganizationDomain(QByteArray("kde.org")); 0053 aboutData.setDesktopFileName(QStringLiteral("org.kde.kmplayer")); 0054 KAboutData::setApplicationData(aboutData); 0055 0056 QApplication::setWindowIcon(QIcon::fromTheme(QLatin1String("kmplayer"))); 0057 0058 QCommandLineParser parser; 0059 aboutData.setupCommandLine(&parser); 0060 parser.setApplicationDescription(aboutData.shortDescription()); 0061 parser.addHelpOption(); 0062 parser.addVersionOption(); 0063 parser.addPositionalArgument(QStringLiteral("File"), i18n("file to open"), i18n("+[File]")); 0064 parser.process(app); 0065 0066 aboutData.processCommandLine(&parser); 0067 0068 KMPlayer::Ids::init(); 0069 0070 QPointer <KMPlayerApp> kmplayer; 0071 0072 if (app.isSessionRestored ()) { 0073 RESTORE (KMPlayerApp); 0074 } else { 0075 kmplayer = new KMPlayerApp (); 0076 kmplayer->show(); 0077 0078 QUrl url; 0079 QStringList args = parser.positionalArguments(); 0080 if (args.size() == 1) 0081 url = makeUrl(args[0]); 0082 if (args.size() > 1) { 0083 for (int i = 0; i < args.size(); i++) { 0084 QUrl url1 = makeUrl(args[i]); 0085 if (url1.isValid()) 0086 kmplayer->addUrl(url1); 0087 } 0088 } 0089 kmplayer->openDocumentFile (url); 0090 } 0091 int retvalue = app.exec (); 0092 0093 delete kmplayer; 0094 0095 KMPlayer::Ids::reset(); 0096 0097 return retvalue; 0098 }