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