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