MCPcopy Create free account
hub / github.com/Tencent/libpag / main

Function main

viewer/src/main.cpp:30–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28#include "task/PAGTaskFactory.h"
29
30int main(int argc, char* argv[]) {
31 bool cpuMode = false;
32 std::string filePath;
33
34 for (int i = 0; i < argc; i++) {
35 auto arg = std::string(argv[i]);
36 auto lowerArg = arg;
37 std::transform(lowerArg.begin(), lowerArg.end(), lowerArg.begin(), ::tolower);
38 if (lowerArg == "-cpu") {
39 cpuMode = true;
40 } else if (argc > 1) {
41 filePath = arg;
42 }
43 }
44
45 if (cpuMode) {
46 QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
47 }
48
49 QApplication::setApplicationName("PAGViewer");
50 QApplication::setOrganizationName("Tencent");
51 QSurfaceFormat defaultFormat = QSurfaceFormat();
52 defaultFormat.setRenderableType(QSurfaceFormat::RenderableType::OpenGL);
53 defaultFormat.setVersion(3, 2);
54 defaultFormat.setProfile(QSurfaceFormat::CoreProfile);
55 QSurfaceFormat::setDefaultFormat(defaultFormat);
56 QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
57 QQuickStyle::setStyle("Universal");
58 QFont defaultFonts("Helvetica Neue,PingFang SC");
59 defaultFonts.setStyleHint(QFont::SansSerif);
60 QApplication::setFont(defaultFonts);
61 std::vector<std::string> fallbackList = {"PingFang SC", "Apple Color Emoji", "Microsoft YaHei"};
62 pag::PAGFont::SetFallbackFontNames(fallbackList);
63
64 pag::PAGViewer app(argc, argv);
65 QApplication::setWindowIcon(QIcon(":/images/window-icon.png"));
66 qmlRegisterType<pag::PAGView>("PAG", 1, 0, "PAGView");
67 qmlRegisterType<pag::PAGTaskFactory>("PAG", 1, 0, "PAGTaskFactory");
68 qmlRegisterType<pag::PluginInstallerModel>("PAG", 1, 0, "PluginInstallerModel");
69 app.openFile(QString::fromLocal8Bit(filePath.data()));
70
71 pag::InitUpdater();
72
73 return QApplication::exec();
74}

Callers

nothing calls this directly

Calls 4

transformFunction · 0.85
InitUpdaterFunction · 0.85
openFileMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected