Warning, file /network/ktp-send-file/main.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Main 0003 * 0004 * Copyright (C) 2011 David Edmundson <kde@davidedmundson.co.uk> 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Lesser General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2.1 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Lesser General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Lesser General Public 0017 * License along with this library; if not, write to the Free Software 0018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 0019 */ 0020 0021 // KDE 0022 #include <QFileDialog> 0023 #include <KLocalizedString> 0024 #include <KAboutData> 0025 #include <QApplication> 0026 #include <QPushButton> 0027 0028 #include "mainwindow.h" 0029 #include "version.h" 0030 0031 int main(int argc, char *argv[]) 0032 { 0033 QApplication app(argc, argv); 0034 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("telepathy-kde"))); 0035 KAboutData aboutData("ktp-send-file", 0036 i18n("Telepathy Send File"), 0037 KTP_SEND_FILE_VERSION); 0038 aboutData.addAuthor(i18n("David Edmundson"), i18n("Author"), "kde@davidedmundson.co.uk"); 0039 aboutData.setProductName("telepathy/send-file"); 0040 KAboutData::setApplicationData(aboutData); 0041 0042 QCommandLineParser parser; 0043 parser.addPositionalArgument("file", i18n("The files to send"), i18n("[files...]")); 0044 aboutData.setupCommandLine(&parser); 0045 parser.process(app); 0046 aboutData.processCommandLine(&parser); 0047 0048 0049 QList<QUrl> filesToSend; 0050 0051 if (parser.positionalArguments().isEmpty()) { 0052 QFileDialog *fileDialog = new QFileDialog(Q_NULLPTR, i18n("Select Files To Send")); 0053 fileDialog->setAcceptMode(QFileDialog::AcceptOpen); 0054 fileDialog->exec(); 0055 filesToSend = fileDialog->selectedUrls(); 0056 fileDialog->deleteLater(); 0057 } else { 0058 Q_FOREACH(const QString &fileToSend, parser.positionalArguments()) { 0059 filesToSend.append(QUrl::fromUserInput(fileToSend)); 0060 } 0061 } 0062 0063 if (! filesToSend.isEmpty()) { 0064 MainWindow *w = new MainWindow(filesToSend); 0065 w->show(); 0066 return app.exec(); 0067 } else { 0068 return -1; 0069 } 0070 0071 } 0072