| 1 | /* |
| 2 | Copyright (C) 2024 UBports Foundation. |
| 3 | |
| 4 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License 3 as published by |
| 6 | the Free Software Foundation. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program. If not, see http://www.gnu.org/licenses/. |
| 15 | |
| 16 | Authors: Michael Zanetti <[email protected]> |
| 17 | Riccardo Padovani <[email protected]> |
| 18 | David Planella <[email protected]> |
| 19 | */ |
| 20 | |
| 21 | #include <QtGui/QGuiApplication> |
| 22 | #include <QtQuick/QQuickView> |
| 23 | #include <QtQml/QtQml> |
| 24 | #include <QLibrary> |
| 25 | #include <QDir> |
| 26 | |
| 27 | #include <QDebug> |
| 28 | |
| 29 | #include "config.h"cxx . . $ `<file>/build/app/config.h`/ |
| 30 | |
| 31 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 32 | { |
| 33 | QGuiApplicationcxx . . $ QGuiApplication# acxx . . $ QGuiApplication#QGuiApplication(6e9b1c7df49e191d).(argc, argv); |
| 34 | QQuickViewcxx . . $ QQuickView# viewcxx . . $ QQuickView#QQuickView(35681b993d9a3c79).; |
| 35 | view.setResizeModecxx . . $ QQuickView#setResizeMode(a59df3724df848c).(QQuickViewcxx . . $ QQuickView#::SizeRootObjectToViewcxx . . $ QQuickView#SizeRootObjectToView.); |
| 36 | |
| 37 | // Set up import paths |
| 38 | QStringListcxx . . $ QStringList# importPathList = view.enginecxx . . $ QQuickView#engine(a2abd829983e1876).()->importPathListcxx . . $ QQmlEngine#importPathList(e1dbd5c4feadc8f5).(); |
| 39 | |
| 40 | QStringListcxx . . $ QStringList# args = a.argumentscxx . . $ QCoreApplication#arguments(669a05bc42dd57cc).(); |
| 41 | if (args.containscxx . . $ QStringList#contains(8cce4688c16f48f3).("-h"cxx . . $ QString#QString(85c52e162fed56f9).) || args.containscxx . . $ QStringList#contains(8cce4688c16f48f3).("--help"cxx . . $ QString#QString(85c52e162fed56f9).)) { |
| 42 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). "usage: " +cxx . . $ operator+(c75c3ae4eb9af1a8). args.atcxx . . $ QList#at(e2681f9bb6b2f357).(0) +cxx . . $ operator+(3d22f08efddf8107). " [-h|--help] [-I <path>] [-q <qmlfile>]"; |
| 43 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " -h|--help Print this help."; |
| 44 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " -I <path> Give a path for an additional QML import directory. May be used multiple times."; |
| 45 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " -q <qmlfile> Give an alternative location for the main qml file."; |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | QStringcxx . . $ QString# qmlfilecxx . . $ QString#QString(ced63f7c635d850d).; |
| 50 | for (int i = 0; i < args.countcxx . . $ QList#count(455f465bc33b4cdf).(); i++) { |
| 51 | if (args.atcxx . . $ QList#at(e2681f9bb6b2f357).(i) ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "-I" && args.countcxx . . $ QList#count(455f465bc33b4cdf).() > i + 1) { |
| 52 | QStringcxx . . $ QString# addedPath = argscxx . . $ QString#QString(132dd6869045752b)..atcxx . . $ QList#at(e2681f9bb6b2f357).(i+1); |
| 53 | if (addedPath.startsWithcxx . . $ QString#startsWith(7cf081d1b6a1defd).('.'cxx . . $ QChar#QChar(f349c77f591a7878).)) { |
| 54 | addedPath =cxx . . $ QString#`operator=`(4f35bf974e7f8568). addedPath.rightcxx . . $ QString#right(3f3c3d0e9c0eb37f).(addedPath.lengthcxx . . $ QString#length(455f465bc33b4cdf).() - 1); |
| 55 | addedPath.prependcxx . . $ QString#prepend(6a89d0b7f4d2681c).(QDircxx . . $ QDir#::currentPathcxx . . $ QDir#currentPath(4365c3963150523e).()); |
| 56 | } |
| 57 | importPathList.appendcxx . . $ QList#append(77d9f17553126ecb).(addedPath); |
| 58 | } else if (args.atcxx . . $ QList#at(e2681f9bb6b2f357).(i) ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "-q" && args.countcxx . . $ QList#count(455f465bc33b4cdf).() > i + 1) { |
| 59 | qmlfile =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). args.atcxx . . $ QList#at(e2681f9bb6b2f357).(i+1); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | if (args.containscxx . . $ QStringList#contains(9b0c247ef39438e0).(QLatin1Stringcxx . . $ QLatin1String#QLatin1String(aac1607cfe1c1740).("-testability")) || getenv("QT_LOAD_TESTABILITY")) { |
| 64 | QLibrarycxx . . $ QLibrary# testLibcxx . . $ QLibrary#QLibrary(6b24f83d17022bd9).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("qttestability")); |
| 65 | if (testLib.loadcxx . . $ QLibrary#load(c9857a73d68e59ba).()) { |
| 66 | typedef void (*TasInitializecxx . . $ main(afcd3168fc1188a4).TasInitialize#)(void); |
| 67 | TasInitializecxx . . $ main(afcd3168fc1188a4).TasInitialize# initFunction = (TasInitializecxx . . $ main(afcd3168fc1188a4).TasInitialize#)testLib.resolvecxx . . $ QLibrary#resolve(3efb40c7f910a1d9).("qt_testability_init"); |
| 68 | if (initFunction) { |
| 69 | initFunction(); |
| 70 | } else { |
| 71 | qCriticalcxx . . $ `<external>/10450329605257866924/qlogging.h:167:9`!("Library qttestability resolve failed!"); |
| 72 | } |
| 73 | } else { |
| 74 | qCriticalcxx . . $ `<external>/10450329605257866924/qlogging.h:167:9`!("Library qttestability load failed!"); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | view.enginecxx . . $ QQuickView#engine(a2abd829983e1876).()->rootContextcxx . . $ QQmlEngine#rootContext(84d4a38f80cd3330).()->setContextPropertycxx . . $ QQmlContext#setContextProperty(1c60a90c724e6bfb).("i18nDirectory"cxx . . $ QString#QString(85c52e162fed56f9)., I18nDirectorycxx . . $ QVariant#QVariant(3520e46b33348bf6).()); |
| 79 | |
| 80 | view.enginecxx . . $ QQuickView#engine(a2abd829983e1876).()->setImportPathListcxx . . $ QQmlEngine#setImportPathList(631c0101495f0328).(importPathList); |
| 81 | |
| 82 | // load the qml file |
| 83 | if (qmlfile.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 84 | QStringListcxx . . $ QStringList# paths = QStandardPathscxx . . $ QStandardPaths#::standardLocationscxx . . $ QStandardPaths#standardLocations(88c3720734e7e359).(QStandardPathscxx . . $ QStandardPaths#::DataLocationcxx . . $ QStandardPaths#DataLocation.); |
| 85 | paths.prependcxx . . $ QList#prepend(77d9f17553126ecb).(QDircxx . . $ QDir#::currentPathcxx . . $ QDir#currentPath(4365c3963150523e).()); |
| 86 | paths.prependcxx . . $ QList#prepend(77d9f17553126ecb).(QCoreApplicationcxx . . $ QCoreApplication#::applicationDirPathcxx . . $ QCoreApplication#applicationDirPath(4365c3963150523e).()); |
| 87 | paths.prependcxx . . $ QList#prepend(77d9f17553126ecb).(AssetsDircxx . . $ AssetsDir(4365c3963150523e).()); |
| 88 | |
| 89 | foreachcxx . . $ `<external>/15045578679651060896/qglobal.h:1145:13`! (const QString &path, paths) { |
| 90 | QFileInfocxx . . $ QFileInfo# ficxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(path +cxx . . $ operator+(3d22f08efddf8107). "/lomiri-calculator-app.qml"); |
| 91 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Trying to load QML from:" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). fi.filePathcxx . . $ QFileInfo#filePath(6ef7b6c27b00b43d).(); |
| 92 | if (fi.existscxx . . $ QFileInfo#exists(50ce9a9e25b4a850).()) { |
| 93 | qmlfile =cxx . . $ QString#`operator=`(4f35bf974e7f8568). fi.filePathcxx . . $ QFileInfo#filePath(6ef7b6c27b00b43d).(); |
| 94 | break; |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "using main qml file from:" <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). qmlfile; |
| 99 | view.setSourcecxx . . $ QQuickView#setSource(37355d2f77053a23).(QUrlcxx . . $ QUrl#::fromLocalFilecxx . . $ QUrl#fromLocalFile(daf4b0201622af21).(qmlfile)); |
| 100 | view.showcxx . . $ QWindow#show(49f6e7a06ebc5aa8).(); |
| 101 | return a.execcxx . . $ QGuiApplication#exec(b126dc7c1de90089).(); |
| 102 | } |