int main( int argc, char** argv ) { QString calligraVersion(CALLIGRA_VERSION_STRING); QString version; #ifdef CALLIGRA_GIT_SHA1_STRING QString gitVersion(CALLIGRA_GIT_SHA1_STRING); version = QString("%1 (git %2)").arg(calligraVersion).arg(gitVersion).toLatin1(); #else version = calligraVersion; #endif KLocalizedString::setApplicationDomain("krita"); KAboutData aboutData(QStringLiteral("kritasketch"), i18n("Krita Sketch"), QStringLiteral("0.1"), i18n("Krita Sketch: Painting on the Go for Artists"), KAboutLicense::GPL, i18n("(c) 1999-%1 The Krita team.\n").arg(CALLIGRA_YEAR), QString(), QStringLiteral("https://www.krita.org"), QStringLiteral("*****@*****.**")); #if defined HAVE_X11 QCoreApplication::setAttribute(Qt::AA_X11InitThreads); #endif QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); SketchApplication app(argc, argv); KAboutData::setApplicationData( aboutData ); app.setWindowIcon(KisIconUtils::loadIcon("kritasketch")); QCommandLineParser parser; aboutData.setupCommandLine(&parser); parser.addHelpOption(); parser.addVersionOption(); parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("vkb"), i18n("Use the virtual keyboard"))); parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("windowed"), i18n("Open sketch in a window, otherwise defaults to full-screen"))); parser.addPositionalArgument(QStringLiteral("[file(s)]"), i18n("Images to open")); parser.process(app); aboutData.processCommandLine(&parser); QStringList fileNames; Q_FOREACH (const QString &fileName, parser.positionalArguments()) { const QString absoluteFilePath = QDir::current().absoluteFilePath(fileName); if (QFile::exists(absoluteFilePath)) { fileNames << absoluteFilePath; } } // QT5TODO: untested replacement of KIconLoader::global()->addAppDir("krita"); QStringList themeSearchPaths = QIcon::themeSearchPaths(); themeSearchPaths.append(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "krita/pics", QStandardPaths::LocateDirectory)); QIcon::setThemeSearchPaths(themeSearchPaths); // Initialize all Calligra directories etc. KoGlobal::initialize(); // for cursors KoResourcePaths::addResourceType("kis_pics", "data", "krita/pics/"); // for images in the paintop box KoResourcePaths::addResourceType("kis_images", "data", "krita/images/"); KoResourcePaths::addResourceType("icc_profiles", "data", "krita/profiles/"); KisOpenGL::initialize(); QDir appdir(app.applicationDirPath()); appdir.cdUp(); #ifdef Q_OS_WIN QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); // If there's no kdehome, set it and restart the process. //QMessageBox::information(0, i18nc("@title:window", "Krita sketch", "KDEHOME: " + env.value("KDEHOME")); if (!env.contains("KDEHOME") ) { _putenv_s("KDEHOME", QDesktopServices::storageLocation(QDesktopServices::DataLocation).toLocal8Bit()); } if (!env.contains("KDESYCOCA")) { _putenv_s("KDESYCOCA", QString(appdir.absolutePath() + "/sycoca").toLocal8Bit()); } if (!env.contains("XDG_DATA_DIRS")) { _putenv_s("XDG_DATA_DIRS", QString(appdir.absolutePath() + "/share").toLocal8Bit()); } if (!env.contains("KDEDIR")) { _putenv_s("KDEDIR", appdir.absolutePath().toLocal8Bit()); } if (!env.contains("KDEDIRS")) { _putenv_s("KDEDIRS", appdir.absolutePath().toLocal8Bit()); } _putenv_s("PATH", QString(appdir.absolutePath() + "/bin" + ";" + appdir.absolutePath() + "/lib" + ";" + appdir.absolutePath() + "/lib" + "/kde4" + ";" + appdir.absolutePath()).toLocal8Bit()); app.addLibraryPath(appdir.absolutePath()); app.addLibraryPath(appdir.absolutePath() + "/bin"); app.addLibraryPath(appdir.absolutePath() + "/lib"); app.addLibraryPath(appdir.absolutePath() + "/lib/kde4"); #endif #if defined Q_OS_WIN KisTabletSupportWin::init(); #elif defined HAVE_X11 KisTabletSupportX11::init(); // TODO: who owns the filter object? app.installNativeEventFilter(new KisTabletSupportX11()); #endif app.start(); MainWindow window(fileNames); // QT5TODO // if (parser.isSet("vkb")) { // app.setInputContext(new SketchInputContext(&app)); // } if (parser.isSet("windowed")) { window.show(); } else { window.showFullScreen(); } return app.exec(); }
int main( int argc, char** argv ) { QString calligraVersion(CALLIGRA_VERSION_STRING); QString version; #ifdef CALLIGRA_GIT_SHA1_STRING QString gitVersion(CALLIGRA_GIT_SHA1_STRING); version = QString("%1 (git %2)").arg(calligraVersion).arg(gitVersion).toLatin1(); #else version = calligraVersion; #endif KAboutData aboutData("kritasketch", "krita", ki18n("Krita Sketch"), "0.1", ki18n("Krita Sketch: Painting on the Go for Artists"), KAboutData::License_GPL, ki18n("(c) 1999-%1 The Krita team.\n").subs(CALLIGRA_YEAR), KLocalizedString(), "http://www.krita.org", "*****@*****.**"); KCmdLineArgs::init (argc, argv, &aboutData); KCmdLineOptions options; options.add( "+[files]", ki18n( "Images to open" ) ); options.add( "vkb", ki18n( "Use the virtual keyboard" ) ); options.add( "windowed", ki18n( "Open sketch in a window, otherwise defaults to full-screen" ) ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); QStringList fileNames; if (args->count() > 0) { for (int i = 0; i < args->count(); ++i) { QString fileName = args->arg(i); if (QFile::exists(fileName)) { fileNames << fileName; } } } SketchApplication app; app.setApplicationName("kritasketch"); KIconLoader::global()->addAppDir("krita"); QDir appdir(app.applicationDirPath()); appdir.cdUp(); #ifdef Q_OS_WIN QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); // If there's no kdehome, set it and restart the process. //QMessageBox::information(0, i18nc("@title:window", "Krita sketch", "KDEHOME: " + env.value("KDEHOME")); if (!env.contains("KDEHOME") ) { _putenv_s("KDEHOME", QDesktopServices::storageLocation(QDesktopServices::DataLocation).toLocal8Bit()); } if (!env.contains("KDESYCOCA")) { _putenv_s("KDESYCOCA", QString(appdir.absolutePath() + "/sycoca").toLocal8Bit()); } if (!env.contains("XDG_DATA_DIRS")) { _putenv_s("XDG_DATA_DIRS", QString(appdir.absolutePath() + "/share").toLocal8Bit()); } if (!env.contains("KDEDIR")) { _putenv_s("KDEDIR", appdir.absolutePath().toLocal8Bit()); } if (!env.contains("KDEDIRS")) { _putenv_s("KDEDIRS", appdir.absolutePath().toLocal8Bit()); } _putenv_s("PATH", QString(appdir.absolutePath() + "/bin" + ";" + appdir.absolutePath() + "/lib" + ";" + appdir.absolutePath() + "/lib" + "/kde4" + ";" + appdir.absolutePath()).toLocal8Bit()); app.addLibraryPath(appdir.absolutePath()); app.addLibraryPath(appdir.absolutePath() + "/bin"); app.addLibraryPath(appdir.absolutePath() + "/lib"); app.addLibraryPath(appdir.absolutePath() + "/lib/kde4"); #endif #if defined Q_OS_WIN KisTabletSupportWin::init(); app.setEventFilter(&KisTabletSupportWin::eventFilter); #elif defined HAVE_X11 KisTabletSupportX11::init(); app.setEventFilter(&KisTabletSupportX11::eventFilter); #endif #if defined HAVE_X11 QApplication::setAttribute(Qt::AA_X11InitThreads); #endif app.start(); MainWindow window(fileNames); if (args->isSet("vkb")) { app.setInputContext(new SketchInputContext(&app)); } if (args->isSet("windowed")) { window.show(); } else { window.showFullScreen(); } return app.exec(); }
int main( int argc, char** argv ) { QString version = CalligraVersionWrapper::versionString(true); K4AboutData aboutData("calligragemini", "calligrawords", ki18n("Calligra Gemini"), version.toLatin1(), ki18n("Calligra Gemini: Writing and Presenting at Home and on the Go"), K4AboutData::License_GPL, ki18n("(c) 1999-%1 The Calligra team and KO GmbH.\n").subs(CalligraVersionWrapper::versionYear()), KLocalizedString(), "http://www.calligra.org", "*****@*****.**"); KCmdLineArgs::init (argc, argv, &aboutData); KCmdLineOptions options; options.add( "+[files]", ki18n( "Document to open" ) ); options.add( "vkb", ki18n( "Use the virtual keyboard" ) ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); QStringList fileNames; if (args->count() > 0) { for (int i = 0; i < args->count(); ++i) { QString fileName = args->arg(i); if (QFile::exists(fileName)) { fileNames << fileName; } } } KApplication app; app.setApplicationName("calligragemini"); KIconLoader::global()->addAppDir("calligrawords"); KIconLoader::global()->addAppDir("words"); KIconLoader::global()->addAppDir("calligrastage"); KIconLoader::global()->addAppDir("stage"); #ifdef Q_OS_WIN QDir appdir(app.applicationDirPath()); appdir.cdUp(); QString envStringSet; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); if (!env.contains("KDESYCOCA")) { _putenv_s("KDESYCOCA", QString(appdir.absolutePath() + "/sycoca").toLocal8Bit()); envStringSet.append("KDESYCOCA "); } if (!env.contains("XDG_DATA_DIRS")) { _putenv_s("XDG_DATA_DIRS", QString(appdir.absolutePath() + "/share").toLocal8Bit()); envStringSet.append("XDG_DATA_DIRS "); } _putenv_s("PATH", QString(appdir.absolutePath() + "/bin" + ";" + appdir.absolutePath() + "/lib" + ";" + appdir.absolutePath() + "/lib" + "/kde4" + ";" + appdir.absolutePath()).toLocal8Bit()); if(envStringSet.length() > 0) { qDebug() << envStringSet << "were set from main, restarting application in new environment!"; // Pass all the arguments along, but don't include the application name... QProcess::startDetached(app.applicationFilePath(), KCmdLineArgs::allArguments().mid(1)); exit(0); } app.addLibraryPath(appdir.absolutePath()); app.addLibraryPath(appdir.absolutePath() + "/bin"); app.addLibraryPath(appdir.absolutePath() + "/lib"); app.addLibraryPath(appdir.absolutePath() + "/lib/kde4"); QStringList iconThemePaths; iconThemePaths << appdir.absolutePath() + "/share/icons"; QIcon::setThemeSearchPaths(iconThemePaths); QIcon::setThemeName("oxygen"); #endif if (qgetenv("KDE_FULL_SESSION").isEmpty()) { // There are two themes that work for Krita, oxygen and plastique. Try to set plastique first, then oxygen qobject_cast<QApplication*>(QApplication::instance())->setStyle("Plastique"); qobject_cast<QApplication*>(QApplication::instance())->setStyle("Oxygen"); } // then create the pixmap from an xpm: we cannot get the // location of our datadir before we've started our components, // so use an xpm. // QPixmap pm(splash_screen_xpm); // QSplashScreen splash(pm); // splash.show(); // splash.showMessage("."); app.processEvents(); #if defined HAVE_X11 QApplication::setAttribute(Qt::AA_X11InitThreads); #endif MainWindow window(fileNames); if (args->isSet("vkb")) { // app.setInputContext(new SketchInputContext(&app)); } #ifdef Q_OS_WIN window.showMaximized(); #else window.show(); #endif // splash.finish(&window); return app.exec(); }
int main(int argc, char** argv) { QApplication app(argc, argv); app.setApplicationDisplayName("Peruse"); app.setOrganizationDomain("kde.org"); QCommandLineParser parser; // TODO file option for opening comics by passing them through on the command line parser.addHelpOption(); parser.process(app); if (parser.positionalArguments().size() > 1) { parser.showHelp(1); } KDeclarative::KDeclarative kdeclarative; QQmlEngine engine; kdeclarative.setDeclarativeEngine(&engine); kdeclarative.setupBindings(); bool osIsWindows = false; #ifdef Q_OS_WIN // Because windows is a bit funny with paths and whatnot, just so the thing with the lib paths... QDir appdir(qApp->applicationDirPath()); appdir.cdUp(); engine.addImportPath(appdir.canonicalPath() + "/lib/qml"); osIsWindows = true; // Hey, let's try and avoid all those extra stale processes, right? qputenv("KDE_FORK_SLAVES", "true"); #endif engine.rootContext()->setContextProperty("osIsWindows", osIsWindows); QQmlContext* objectContext = engine.rootContext(); QString platformEnv(qgetenv("PLASMA_PLATFORM")); engine.rootContext()->setContextProperty("PLASMA_PLATFORM", platformEnv); // Yes, i realise this is a touch on the ugly side. I have found no better way to allow for // things like the archive book model to create imageproviders for the archives engine.rootContext()->setContextProperty("globalQmlEngine", &engine); engine.rootContext()->setContextProperty("maxTextureSize", getMaxTextureSize()); QString path; if (platformEnv.startsWith("phone")) { path = QStandardPaths::locate(QStandardPaths::DataLocation, "qml/MobileMain.qml"); } else { path = QStandardPaths::locate(QStandardPaths::DataLocation, "qml/Main.qml"); } int rt = 0; QQmlComponent component(&engine, path); if (component.isError()) { qCritical() << "Failed to load the component from disk. Reported error was:" << component.errorString(); rt = -1; } else { if(component.status() == QQmlComponent::Ready) { QObject* obj = component.create(objectContext); if(obj) { rt = app.exec(); } else { qCritical() << "Failed to create an object from our component"; rt = -2; } } else { qCritical() << "Failed to make the Qt Quick component ready. Status is:" << component.status(); rt = -3; } } return rt; }
int main( int argc, char** argv ) { QString calligraVersion(CALLIGRA_VERSION_STRING); QString version; #ifdef CALLIGRA_GIT_SHA1_STRING QString gitVersion(CALLIGRA_GIT_SHA1_STRING); version = QString("%1 (git %2)").arg(calligraVersion).arg(gitVersion).toLatin1(); #else version = calligraVersion; #endif KAboutData aboutData("kritagemini", "krita", ki18n("Krita Gemini"), version.toLatin1(), ki18n("Krita Gemini: Painting at Home and on the Go for Artists"), KAboutData::License_GPL, ki18n("(c) 1999-%1 The Krita team and KO GmbH.\n").subs(CALLIGRA_YEAR), KLocalizedString(), "http://www.kritastudio.com", "*****@*****.**"); KCmdLineArgs::init (argc, argv, &aboutData); KCmdLineOptions options; options.add( "+[files]", ki18n( "Images to open" ) ); options.add( "vkb", ki18n( "Use the virtual keyboard" ) ); options.add( "fullscreen", ki18n( "Use full-screen display" ) ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); QStringList fileNames; if (args->count() > 0) { for (int i = 0; i < args->count(); ++i) { QString fileName = args->arg(i); if (QFile::exists(fileName)) { fileNames << fileName; } } } KApplication app; app.setApplicationName("kritagemini"); KIconLoader::global()->addAppDir("krita"); KIconLoader::global()->addAppDir("kritasketch"); #ifdef Q_OS_WIN QDir appdir(app.applicationDirPath()); appdir.cdUp(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); // If there's no kdehome, set it and restart the process. //QMessageBox::information(0, "krita sketch", "KDEHOME: " + env.value("KDEHOME")); if (!env.contains("KDEHOME") ) { _putenv_s("KDEHOME", QDesktopServices::storageLocation(QDesktopServices::DataLocation).toLocal8Bit()); } if (!env.contains("KDESYCOCA")) { _putenv_s("KDESYCOCA", QString(appdir.absolutePath() + "/sycoca").toLocal8Bit()); } if (!env.contains("XDG_DATA_DIRS")) { _putenv_s("XDG_DATA_DIRS", QString(appdir.absolutePath() + "/share").toLocal8Bit()); } if (!env.contains("KDEDIR")) { _putenv_s("KDEDIR", appdir.absolutePath().toLocal8Bit()); } if (!env.contains("KDEDIRS")) { _putenv_s("KDEDIRS", appdir.absolutePath().toLocal8Bit()); } _putenv_s("PATH", QString(appdir.absolutePath() + "/bin" + ";" + appdir.absolutePath() + "/lib" + ";" + appdir.absolutePath() + "/lib" + "/kde4" + ";" + appdir.absolutePath()).toLocal8Bit()); app.addLibraryPath(appdir.absolutePath()); app.addLibraryPath(appdir.absolutePath() + "/bin"); app.addLibraryPath(appdir.absolutePath() + "/lib"); app.addLibraryPath(appdir.absolutePath() + "/lib/kde4"); #endif #if defined Q_OS_WIN KisTabletSupportWin::init(); app.setEventFilter(&KisTabletSupportWin::eventFilter); #elif defined Q_WS_X11 KisTabletSupportX11::init(); app.setEventFilter(&KisTabletSupportX11::eventFilter); #endif if (qgetenv("KDE_FULL_SESSION").isEmpty()) { // There are two themes that work for Krita, oxygen and plastique. Try to set plastique first, then oxygen qobject_cast<QApplication*>(QApplication::instance())->setStyle("Plastique"); qobject_cast<QApplication*>(QApplication::instance())->setStyle("Oxygen"); } bool showFullscreen = false; if (args->isSet("fullscreen")) { showFullscreen = true; } // then create the pixmap from an xpm: we cannot get the // location of our datadir before we've started our components, // so use an xpm. // If fullscreen, hide splash screen QPixmap pm(splash_screen_xpm); QSplashScreen splash(pm); if (!showFullscreen) { splash.show(); splash.showMessage("."); app.processEvents(); } #if defined Q_WS_X11 && QT_VERSION >= 0x040800 QApplication::setAttribute(Qt::AA_X11InitThreads); #endif MainWindow window(fileNames); if (args->isSet("vkb")) { app.setInputContext(new SketchInputContext(&app)); } if (showFullscreen) { window.showFullScreen(); } else { #ifdef Q_OS_WIN window.showMaximized(); #else window.show(); #endif } splash.finish(&window); return app.exec(); }
//Imports void B9SupportStructure::ImportAttachmentDataFromStls() { int i; bool s; bool triangleError; STLTri* pLoadedTri = NULL; Triangle3D newtri; QDir appdir(CROSS_OS_GetDirectoryFromLocationTag("APPLICATION_DIR")); QStringList filters; B9SupportAttachmentData importedData; qDebug() << "B9SupportStructure: Importing Stl Attachments..."; //Import All Stl in the application directory begining with "SUPPORT" filters << "SUPPORT_*"; appdir.setNameFilters(filters); QFileInfoList stlFiles = appdir.entryInfoList(); for(i = 0; i < stlFiles.size(); i++) { B9ModelLoader stlLoader(stlFiles[i].filePath(),s); if(s) { while(stlLoader.LoadNextTri(pLoadedTri,triangleError)) { if(triangleError) { qDebug() << "B9SupportStructure: ErrorLoading triangle"; return; } newtri.normal.setX(pLoadedTri->nx); newtri.normal.setY(pLoadedTri->ny); newtri.normal.setZ(pLoadedTri->nz); newtri.vertex[0].setX(pLoadedTri->x0); newtri.vertex[0].setY(pLoadedTri->y0); newtri.vertex[0].setZ(pLoadedTri->z0); newtri.vertex[1].setX(pLoadedTri->x1); newtri.vertex[1].setY(pLoadedTri->y1); newtri.vertex[1].setZ(pLoadedTri->z1); newtri.vertex[2].setX(pLoadedTri->x2); newtri.vertex[2].setY(pLoadedTri->y2); newtri.vertex[2].setZ(pLoadedTri->z2); delete pLoadedTri; newtri.UpdateBounds(); importedData.GetTriangles()->push_back(newtri); } //save the data into the Static List. importedData.SetName(stlFiles[i].baseName().remove("SUPPORT_")); importedData.CenterGeometry();//center the triangles around 0,0,0 B9SupportStructure::AttachmentDataList.push_back(importedData); //clear out importedData importedData = B9SupportAttachmentData(); } else { qDebug() << "B9SupportStructure: Error Loading: " << stlFiles[i].fileName(); } } qDebug() << "B9SupportStructure: Succesfully Loaded " << B9SupportStructure::AttachmentDataList.size() << " Attachment Types"; }