File indexing completed on 2024-12-08 04:33:00
0001 /* 0002 * SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "config-ruqola.h" 0008 #include "managerdatapaths.h" 0009 #include "ruqola.h" 0010 #include "ruqolacommandlineoptions.h" 0011 #include "ruqolaglobalconfig.h" 0012 #include <KCrash> 0013 #include <KLocalizedString> 0014 #include <QApplication> 0015 #include <QCommandLineParser> 0016 0017 #include "ruqolamainwindow.h" 0018 0019 #if HAVE_KUSERFEEDBACK 0020 #include "userfeedback/ruqolauserfeedbackprovider.h" 0021 #endif 0022 0023 #include <iostream> 0024 0025 #include <KAboutData> 0026 #include <QDirIterator> 0027 #include <QIcon> 0028 0029 #if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) 0030 #include <KDBusService> 0031 #endif 0032 0033 int main(int argc, char *argv[]) 0034 { 0035 QApplication app(argc, argv); 0036 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("ruqola"))); 0037 0038 KCrash::initialize(); 0039 0040 #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) 0041 QApplication::setStyle(QStringLiteral("breeze")); 0042 #endif 0043 KLocalizedString::setApplicationDomain(QByteArrayLiteral("ruqola")); 0044 0045 KAboutData aboutData(QStringLiteral("ruqola"), 0046 i18n("Ruqola"), 0047 QStringLiteral(RUQOLA_VERSION), 0048 i18n("Rocket Chat Client"), 0049 KAboutLicense::GPL_V2, 0050 i18n("Copyright © 2020-2024 Ruqola authors")); 0051 0052 aboutData.addAuthor(i18n("Laurent Montel"), i18n("Maintainer"), QStringLiteral("montel@kde.org")); 0053 aboutData.addAuthor(i18n("Riccardo Iaconelli"), i18n("Original Author"), QStringLiteral("riccardo@kde.org")); 0054 0055 aboutData.setOrganizationDomain(QByteArrayLiteral("kde.org")); 0056 aboutData.setProductName(QByteArrayLiteral("ruqola")); 0057 aboutData.addCredit(i18n("David Faure"), i18n("Bug fixing, delegates etc."), QStringLiteral("faure@kde.org")); 0058 aboutData.addCredit(i18n("Kevin Funk"), i18n("Bug fixing"), QStringLiteral("kfunk@kde.org")); 0059 aboutData.addCredit(i18n("Olivier JG"), i18n("Bug fixing"), QStringLiteral("olivier.de.gaalon@kdab.com")); 0060 aboutData.addCredit(i18n("Milian Wolff"), i18n("Bug fixing"), QStringLiteral("mail@milianw.de")); 0061 aboutData.addCredit(i18n("Till Adam"), i18n("Windows compile bug fixing"), QStringLiteral("adam@kde.org")); 0062 aboutData.addCredit(i18n("Shantanu Tushar"), i18n("Bug fixing"), QStringLiteral("shantanu@kde.org")); 0063 aboutData.addCredit(i18n("Alessandro Ambrosano"), i18n("Bug fixing"), QStringLiteral("alessandro.ambrosano@gmail.com")); 0064 aboutData.addCredit(i18n("Hannah von Reth"), i18n("Bug fixing for Windows/Mac"), QStringLiteral("vonreth@kde.org")); 0065 aboutData.addCredit(i18n("Allen Winter"), i18n("Packaging"), QStringLiteral("allen.winter@kdab.com")); 0066 aboutData.addCredit(i18n("Waqar Ahmed"), i18n("Bug fixing (compile, network crash...)"), QStringLiteral("waqar.17a@gmail.com")); 0067 aboutData.addCredit(i18n("Nicolas Fella"), i18n("Optimization, fix windows/mac support"), QStringLiteral("nicolas.fella@gmx.de")); 0068 0069 KAboutData::setApplicationData(aboutData); 0070 0071 QCommandLineParser parser; 0072 ruqolaOptions(&parser); 0073 0074 aboutData.setupCommandLine(&parser); 0075 parser.process(app); 0076 aboutData.processCommandLine(&parser); 0077 #if HAVE_KUSERFEEDBACK 0078 if (parser.isSet(QStringLiteral("feedback"))) { 0079 auto userFeedback = new RuqolaUserFeedbackProvider; 0080 QTextStream(stdout) << userFeedback->describeDataSources() << '\n'; 0081 delete userFeedback; 0082 return 0; 0083 } 0084 #endif 0085 0086 if (parser.isSet(QStringLiteral("list-accounts"))) { 0087 const QString configPath = ManagerDataPaths::self()->path(ManagerDataPaths::Config, QString()); 0088 QDirIterator it(configPath, 0089 QStringList() << QStringLiteral("ruqola.conf"), 0090 QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot, 0091 QDirIterator::Subdirectories); 0092 std::cout << qPrintable(i18n("The following accounts are available:")) << std::endl; 0093 while (it.hasNext()) { 0094 QString result = it.next(); 0095 result.remove(configPath + QLatin1Char('/')); 0096 result.remove(QStringLiteral("/ruqola.conf")); 0097 std::cout << " " << result.toLocal8Bit().data() << std::endl; 0098 } 0099 return 0; 0100 } 0101 0102 (void)Ruqola::self(); 0103 0104 if (RuqolaGlobalConfig::self()->useCustomFont()) { 0105 qApp->setFont(RuqolaGlobalConfig::self()->generalFont()); 0106 } else { 0107 #ifdef Q_OS_WIN 0108 qApp->setFont(QFont(QStringLiteral("Segoe UI Emoji"))); 0109 #endif 0110 } 0111 0112 #if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) 0113 // TODO Port to something like KDSingleApplication 0114 KDBusService service(KDBusService::Unique); 0115 #endif 0116 auto mw = new RuqolaMainWindow(); 0117 #if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) 0118 QObject::connect(&service, &KDBusService::activateRequested, mw, &RuqolaMainWindow::slotActivateRequested); 0119 #endif 0120 mw->parseCommandLine(&parser); 0121 0122 mw->show(); 0123 const int val = app.exec(); 0124 return val; 0125 }