File indexing completed on 2024-12-15 04:14:22
0001 /* 0002 * Copyright (C) 2015 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public 0015 * License along with this library; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0017 * 0018 */ 0019 0020 #include <QStandardPaths> 0021 #include <QDir> 0022 0023 #include <KAboutData> 0024 #include <KLocalizedString> 0025 0026 #include <QApplication> 0027 #include <QCommandLineParser> 0028 #include <QCommandLineOption> 0029 #include <QIcon> 0030 0031 #include <iostream> 0032 0033 #include "peruse_helpers.h" 0034 #include "config-peruse.h" 0035 0036 #include <app_debug.h> 0037 0038 Q_DECL_EXPORT 0039 int main(int argc, char** argv) 0040 { 0041 QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 0042 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); 0043 QApplication app(argc, argv); 0044 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("peruse"))); 0045 app.setApplicationDisplayName("Peruse"); 0046 app.setOrganizationDomain("kde.org"); 0047 0048 KLocalizedString::setApplicationDomain("peruse"); 0049 KAboutData about(QStringLiteral("peruse"), i18n("Peruse Reader"), PERUSE_VERSION_STRING, i18n("Comic Book Reader by KDE"), 0050 KAboutLicense::GPL, i18n("© 2016-2021 KDE")); 0051 about.addAuthor(i18n("Dan Leinir Turthra Jensen"), QString("Maintainer and Lead Developer"), QStringLiteral("admin@leinir.dk"), QStringLiteral("https://leinir.dk/"), QStringLiteral("leinir")); 0052 about.setProductName("peruse/peruse"); 0053 about.setProgramLogo(app.windowIcon()); 0054 KAboutData::setApplicationData(about); 0055 0056 QCommandLineParser parser; 0057 parser.addOption(QCommandLineOption(QStringLiteral("clear-db"), i18n("Clear the metainfo cache and perform a full rescan."))); 0058 parser.addPositionalArgument(QStringLiteral("file"), i18n("Open file in peruse.")); 0059 parser.addHelpOption(); 0060 parser.process(app); 0061 0062 0063 QString filename; 0064 if (parser.positionalArguments().size() > 0) { 0065 filename = parser.positionalArguments().at(0); 0066 } 0067 0068 if (parser.positionalArguments().size() > 1) { 0069 parser.showHelp(1); 0070 } 0071 0072 if (parser.isSet(QStringLiteral("clear-db"))) { 0073 QString dbfile = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/library.sqlite"; 0074 if(QFile::exists(dbfile)) { 0075 qCDebug(APP_LOG) << "Remove database at" << dbfile; 0076 QFile::remove(dbfile); 0077 } 0078 } 0079 QString platformEnv(qgetenv("PLASMA_PLATFORM")); 0080 QString path = platformEnv.startsWith("phone") 0081 ? QStringLiteral("qrc:///qml/MobileMain.qml") 0082 : QStringLiteral("qrc:///qml/Main.qml"); 0083 0084 return PeruseHelpers::init(path, app, filename); 0085 }