当前位置: 首页>>代码示例>>C++>>正文


C++ QApplication::arguments方法代码示例

本文整理汇总了C++中QApplication::arguments方法的典型用法代码示例。如果您正苦于以下问题:C++ QApplication::arguments方法的具体用法?C++ QApplication::arguments怎么用?C++ QApplication::arguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QApplication的用法示例。


在下文中一共展示了QApplication::arguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WebProcessMainQt

Q_DECL_EXPORT int WebProcessMainQt(int argc, char** argv)
{
    // Has to be done before QApplication is constructed in case
    // QApplication itself produces debug output.
    QByteArray suppressOutput = qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT");
    if (!suppressOutput.isEmpty() && suppressOutput != "0")
        qInstallMsgHandler(messageHandler);

    QApplication::setGraphicsSystem(QLatin1String("raster"));
    QApplication* app = new QApplication(argc, argv);
#ifndef NDEBUG
    if (!qgetenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH").isEmpty()) {
        qDebug() << "Waiting 3 seconds for debugger";
        sleep(3);
    }
#endif

#if USE(MEEGOTOUCH)
    new MComponentData(argc, argv);
#endif

    initializeProxy();

    srandom(time(0));

    JSC::initializeThreading();
    WTF::initializeMainThread();
    RunLoop::initializeMainRunLoop();

    // Create the connection.
    if (app->arguments().size() <= 1) {
        qDebug() << "Error: wrong number of arguments.";
        return 1;
    }

    bool wasNumber = false;
    int identifier = app->arguments().at(1).toInt(&wasNumber, 10);
    if (!wasNumber) {
        qDebug() << "Error: connection identifier wrong.";
        return 1;
    }

    WebKit::WebProcess::shared().initialize(identifier, RunLoop::main());

    RunLoop::run();

    // FIXME: Do more cleanup here.

    return 0;
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:50,代码来源:WebProcessMainQt.cpp

示例2: main

int main( int argc, char** argv ) {
	qDebug() << "JackMix starting";

	QApplication *qapp = new QApplication( argc, argv );
	QStringList args = qapp->arguments();
	JackMix::MidiControl::ControlSender midiControlSender("JackMix Control");
	QString file;
	for( int i=1; i<args.size(); ++i ) {
		qDebug() << QString( " arg %1: %2" ).arg( i ).arg( args[ i ] );
		if ( QFile::exists( args[ i ] ) )
			file = args[ i ];
	}

	JackMix::MainWindow *mw;
	if ( !file.isEmpty() )
		mw = new JackMix::MainWindow( file );
	else
		mw = new JackMix::MainWindow();
	mw->show();

	int ret = qapp->exec();

	delete mw;

	return ret;
}
开发者ID:dsheeler,项目名称:jackmix,代码行数:26,代码来源:main.cpp

示例3: qca

int
main (int argc, char **argv)
{
  // initialise the unportable debug library
  init_debuglib ();

  // now start the portable Qt code
  QApplication qca (argc, argv);

  qca.setOrganizationName ("Xinutec");
  qca.setApplicationName ("Groovy");

  QStringList args = qca.arguments ();

  if (args.contains ("--help"))
    return help (), EXIT_SUCCESS;
  if (args.contains ("--version"))
    return version (), EXIT_SUCCESS;

  LDEBUG << "initialising...";

  GrooveWindow mw;
  mw.show ();

  int retval = qca.exec ();

  // uninitialise unportable debug library
  uninit_debuglib ();

  LDEBUG << "terminating...";

  return retval;
}
开发者ID:pippijn,项目名称:libgroove,代码行数:33,代码来源:main.cpp

示例4: loadDatabase

void loadDatabase(QApplication& application)
{
    //QString path = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
    QString path = QString("%1/.CasparCG/Client").arg(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));

    QDir directory;
    if (!directory.exists(path))
        directory.mkpath(path);

    QString databaseLocation = QString("%1/%2.s3db").arg(path).arg(DATABASE_VERSION);
    if (application.arguments().contains("-database"))
        databaseLocation = QString("%1/%2%3.s3db").arg(path).arg(application.arguments().at(application.arguments().indexOf(QRegExp("-database")) + 1)).arg(DATABASE_VERSION);

    QSqlDatabase database = QSqlDatabase::addDatabase("QSQLITE");
    database.setDatabaseName(databaseLocation);
    if (!database.open())
        qCritical() << "Unable to open database";
}
开发者ID:seccpur,项目名称:Client,代码行数:18,代码来源:Main.cpp

示例5: main

int main (int argc, char *argv[])
{
  QApplication app (argc, argv);
  QStringList args = app.arguments();
  QString dirname = args.count() > 1 ? args.at(1) : QString(".");
  Slideshow widget (dirname);
  widget.show ();

  return app.exec ();
}
开发者ID:NB-Dev,项目名称:slideshow-qgl,代码行数:10,代码来源:main.cpp

示例6: main

Q_DECL_EXPORT
#endif
int main(int argc, char **argv)
{
    QApplication *application;
    QDeclarativeView *view;
#ifdef HAS_BOOSTER
    application = MDeclarativeCache::qApplication(argc, argv);
    view = MDeclarativeCache::qDeclarativeView();
#else
    qWarning() << Q_FUNC_INFO << "Warning! Running without booster. This may be a bit slower.";
    QApplication stackApp(argc, argv);
    QDeclarativeView stackView;
    application = &stackApp;
    view = &stackView;
#endif

    bool isFullscreen = false;
    QStringList arguments = application->arguments();
    for (int i = 0; i < arguments.count(); ++i) {
        QString parameter = arguments.at(i);
        if (parameter == "-fullscreen") {
            isFullscreen = true;
        } else if (parameter == "-help") {
            qDebug() << "Contacts application";
            qDebug() << "-fullscreen   - show QML fullscreen";
            exit(0);
        }
    }

    QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));

    if (QFile::exists("main.qml"))
        view->setSource(QUrl::fromLocalFile("main.qml"));
    else
        view->setSource(QUrl("qrc:/qml/main.qml"));

    view->setAttribute(Qt::WA_OpaquePaintEvent);
    view->setAttribute(Qt::WA_NoSystemBackground);
    view->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
    view->viewport()->setAttribute(Qt::WA_NoSystemBackground);

    // TODO: we could do with a plugin to access QDesktopServices paths
    view->rootContext()->setContextProperty("systemAvatarDirectory", QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
    view->rootContext()->setContextProperty("DocumentsLocation", QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));

    if (isFullscreen)
        view->showFullScreen();
    else
        view->show();

    return application->exec();
}
开发者ID:chriadam,项目名称:qmlcontacts,代码行数:53,代码来源:main.cpp

示例7: LoadTranslate

void LoadTranslate(QApplication& app) {
    QTranslator *translator = new QTranslator();
    QString tnapplang;
    QString tnappcoun;
    QString clangcode = "";
    QStringList allappargs = app.arguments();
    QList<QPair<QString, QString> > oppairs;
    for (QList<QString>::const_iterator i = allappargs.constBegin(); i < allappargs.constEnd(); ++i) {
        if (i->count('=') == 1) {
            oppairs.append(QPair<QString, QString>(i->section('=', 0, 0).simplified(), i->section('=',1, 1).simplified()));
        }
    }
    for (QList<QPair<QString, QString> >::const_iterator i = oppairs.constBegin(); i < oppairs.constEnd(); ++i) {
        if (i->first.contains("lang", Qt::CaseInsensitive))
        {
            clangcode = i->second;
            tnapplang = clangcode.left(2);
            if (clangcode.contains('_') && clangcode.size() == 5)
            {
                tnappcoun = clangcode.section('_', -1, -1);
            }
            break;
        }
    }
    if (clangcode.isEmpty())
    {
        clangcode = QLocale::system().name();
        tnapplang = clangcode.left(2);
        if (clangcode.contains('_') && clangcode.size() == 5)
        {
            tnappcoun = clangcode.section('_', -1, -1);
        }
    }

    QString tranlateUrl;
    if (tnappcoun.isEmpty()) {
        tranlateUrl = QString(":/po/%1.qm").arg(tnapplang);
    } else {
        tranlateUrl = QString(":/po/%1_%2.qm").arg(tnapplang).arg(tnappcoun);
    }

    if (!QFile::exists(tranlateUrl)) {
        tranlateUrl = ":/po/en_US.qm";
    }

    qDebug()<<&app<<"Load translate file: "<<tranlateUrl;

    if (!translator->load(tranlateUrl)){
        qDebug()<<"Load Translater Failed";
    }
    app.installTranslator(translator);
}
开发者ID:Abuchidefan,项目名称:deepin-windows-installer,代码行数:52,代码来源:config.cpp

示例8: main

int main( int argc, char ** argv )
{
    QApplication app ( argc, argv );

    if(app.arguments().count()<2)
       qFatal("./qxtflowview /path/to/images");

    FsImageModel model(app.arguments().at(1));

//     QTreeView view;
//     view.setModel(&model);
//     view.show();


    QxtFlowView w;
    w.setSlideSize(QSize( 4*60,3*60));
    w.resize(800, 600);
    w.setModel(&model);
    w.show();

    return app.exec();
}
开发者ID:develnk,项目名称:qxtweb-qt5,代码行数:22,代码来源:main.cpp

示例9: main

int main(int argc, char **argv) {
    qDebug() << QStyleFactory::keys();
    QApplication::setStyle(QStyleFactory::create("Fusion"));
    QApplication *app = new QApplication(argc,argv);
    if (app->arguments().contains("-test")) testing = true;
    //BootConfig *bc = new BootConfig();
    //bc->show();
    MainWindow *mw = new MainWindow();
    mw->show();
    //NixosJsonOptions *win = new NixosJsonOptions();
    //win->show();
    app->exec();
    delete mw;
    //do_test1(gpt);
    qDebug("shutting down");
    delete app;
    return 0;
}
开发者ID:cleverca22,项目名称:nixos-installer,代码行数:18,代码来源:main.cpp

示例10: parse

    void parse(QApplication const& _app) {
      QString _argument;

      for (auto& _arg : _app.arguments()) {
        if (_arg[0] == '+') {
          _argument = "";

          for (int i = 1; i < _arg.size(); ++i) {
            _argument += _arg[i];
          }
        } else {
          keyValues_[_argument] += _arg + " ";
        }
      }

      for (auto& _keyValue : keyValues_) {
        _keyValue.second = _keyValue.second.trimmed();
      }
    }
开发者ID:cr8tr,项目名称:omnidome,代码行数:19,代码来源:omnidome.cpp

示例11: main

Q_DECL_EXPORT
#endif
int main(int argc, char **argv)
{
    QApplication *application;
    QDeclarativeView *view;
#ifdef HAS_BOOSTER
    application = MDeclarativeCache::qApplication(argc, argv);
    view = MDeclarativeCache::qDeclarativeView();
#else
    qWarning() << Q_FUNC_INFO << "Warning! Running without booster. This may be a bit slower.";
    QApplication stackApp(argc, argv);
    QDeclarativeView stackView;
    application = &stackApp;
    view = &stackView;
#endif

    QString path;
    QString urlstring;
    bool isFullscreen = false;
    QStringList arguments = application->arguments();
    for (int i = 0; i < arguments.count(); ++i) {
        QString parameter = arguments.at(i);
        if (parameter == "-path") {
            if (i + 1 >= arguments.count())
                qFatal("-path requires an argument");
            path = arguments.at(i + 1);
            i++;
        } else if (parameter == "-url") {
            if (i + 1 >= arguments.count())
                qFatal("-path requires an argument");
            urlstring = arguments.at(i + 1);
            i++;
        } else if (parameter == "-fullscreen") {
            isFullscreen = true;
        } else if (parameter == "-help") {
            qDebug() << "Fast QML-only application launcher";
            qDebug() << "-fullscreen   - show QML fullscreen";
            qDebug() << "-path         - path to cd to before launching -url";
            qDebug() << "-url          - file to launch (default: main.qml inside -path)";
            exit(0);
        }
    }

    if (!path.isEmpty())
        QDir::setCurrent(path);

    QUrl url;
    if (urlstring.isEmpty())
        url = QUrl::fromLocalFile("main.qml");
    else
        url = QUrl::fromUserInput(urlstring);
        

    QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));
    view->setSource(url);
    view->setAttribute(Qt::WA_OpaquePaintEvent);
    view->setAttribute(Qt::WA_NoSystemBackground);
    view->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
    view->viewport()->setAttribute(Qt::WA_NoSystemBackground);

    if (isFullscreen)
        view->showFullScreen();
    else
        view->show();

    return application->exec();
}
开发者ID:nemomobile-graveyard,项目名称:qmllauncher,代码行数:68,代码来源:main.cpp

示例12: main

hosted_button_id=RZ2A2ZB93827Y";

int main(int argc, char **argv)
{
    QApplication app (argc, argv);
    app.setOrganizationName("SfietKonstantin");
    app.setApplicationName("qfb-mobile");

//    QFB::QueryManager queryManager;
    QFB::LoginManager loginManager;
    TokenManager tokenManager;
    Me me;
//    PostUpdateRelay postUpdateRelay;

    qmlRegisterType<UserInfoHelper>("org.SfietKonstantin.qfb.mobile", 4, 0, "QFBUserInfoHelper");
//    qmlRegisterType<BackPixmapItem>("org.SfietKonstantin.qfb.mobile", 4, 0,
//                                    "QFBBackPixmapItem");
    qmlRegisterType<PostHelper>("org.SfietKonstantin.qfb.mobile", 4, 0, "QFBPostHelper");
//    qmlRegisterType<MobilePostValidator>("org.SfietKonstantin.qfb.mobile", 4, 0,
//                                         "QFBMobilePostValidator");

    QDeclarativeView view;
#ifdef MEEGO_EDITION_HARMATTAN
    QGLFormat format = QGLFormat::defaultFormat();
    format.setSampleBuffers(false);
    format.setSwapInterval(1);
    QGLWidget* glWidget = new QGLWidget(format);
    glWidget->setAutoFillBackground(false);
    view.setViewport(glWidget);
    PagePixmapProvider *pagePixmapProvider = new PagePixmapProvider(glWidget);
#else
    PagePixmapProvider *pagePixmapProvider = new PagePixmapProvider(&view);
#endif

#ifndef MEEGO_EDITION_HARMATTAN
    view.engine()->addImportPath(IMPORT_PATH);
#endif
    view.engine()->addImageProvider("pagepixmapprovider", pagePixmapProvider);
    view.engine()->setNetworkAccessManagerFactory(new NetworkAccessManagerFactory());
//    view.rootContext()->setContextProperty("QUERY_MANAGER", &queryManager);
    view.rootContext()->setContextProperty("LOGIN_MANAGER", &loginManager);
    view.rootContext()->setContextProperty("TOKEN_MANAGER", &tokenManager);
//    view.rootContext()->setContextProperty("POST_UPDATE_RELAY", &postUpdateRelay);
    view.rootContext()->setContextProperty("ME", &me);
    view.rootContext()->setContextProperty("DATA_PATH", DATA_PATH);
    view.rootContext()->setContextProperty("FACEBOOK_PAGE", FACEBOOK_PAGE);
    view.rootContext()->setContextProperty("PAYPAL_DONATE", PAYPAL_DONATE);
    view.rootContext()->setContextProperty("VERSION_MAJOR", QString::number(VERSION_MAJOR));
    view.rootContext()->setContextProperty("VERSION_MINOR", QString::number(VERSION_MINOR));
    view.rootContext()->setContextProperty("VERSION_PATCH", QString::number(VERSION_PATCH));

    // Friends specific
    QString clientId;
    QPluginLoader pluginLoader (CLIENT_ID_PLUGIN);
    if (pluginLoader.load()) {
        QObject *plugin = pluginLoader.instance();
        Interface *castedPlugin = qobject_cast<Interface *>(plugin);
        if (castedPlugin) {
            clientId = castedPlugin->clientId();
            qDebug() << "Client id loaded";
        }
    }

    if (clientId.isEmpty()) {
        if (app.arguments().count() == 2) {
            clientId = app.arguments().at(1);
        } else {
            qDebug() << "Failed to find the client id";
            return -1;
        }
    }
    view.rootContext()->setContextProperty("CLIENT_ID", clientId);
    // End Friends specific

    view.setSource(QUrl(MAIN_QML_FILE));
    view.showFullScreen();
    QObject::connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));

    return app.exec();
}
开发者ID:SfietKonstantin,项目名称:friends-qml,代码行数:80,代码来源:main.cpp

示例13: cout

int	main(int ac, char *ag[])
{
  QToyunda              *toyunda;
  QApplication		*qapp;
  SQArgDescMap		optionDesc;
  QMap<QString, QVariant> option;
  QDebugErrorHandler    *errorHandler;

  errorHandler = new QDebugErrorHandler();
  defineOption(optionDesc);
  qapp = new QApplication(ac, ag);
  // Handle arguments
  QStringList arg = qapp->arguments();
  arg.removeFirst();
  bool vopt = SQArg::fillWithDesc(option, arg, optionDesc);
  // Help
  if (option["help"].toBool() || vopt == false) {
    QTextStream cout(stdout);
    cout << "QToyunda\nSynopsis : ";
    cout << "./qtoyunda --player playername --renderer renderername --video videofile --subtitle subtitlefile\n\n";
    cout.flush();
    if (option["help"].toBool()) {
      cout << "All option available :\n";
      cout.flush();
      SQArg::generateLongHelp(optionDesc);
      return 0;
    }
    return 1;
  }
  // Player and renderer option
  QStringList playerOption;
  if (!option["playeroption"].toString().isEmpty())
      playerOption = option["playeroption"].toString().split(",");
  QStringList rendererOption;
  if (!option["rendereroption"].toString().isEmpty())
      rendererOption = option["rendereroption"].toString().split(",");
  rendererOption << "logo=:/main/Toyunda logo.png";
  qDebug() << rendererOption;
  toyunda = new QToyunda(errorHandler);
  toyunda->setPlayerName(option["player"].toString());
  toyunda->setRendererName(option["renderer"].toString());
  toyunda->setPlayerOption(playerOption);
  toyunda->setRendererOption(rendererOption);

  QDir pluginPath = qApp->applicationDirPath();
  pluginPath.cd("plugins");
  toyunda->setPluginDirectory(pluginPath);
  toyunda->loadPlugins();

  // FIXME playeroptionhelp and roh must not depend and toyunda
  if (option["playeroptionhelp"].toBool()) {
    toyunda->showPlayerOption();
    return 0;
  }
  if (option["rendereroptionhelp"].toBool()) {
    toyunda->showRendererOption();
    return 0;
  }
  qDebug() << "Init toyunda";
  if (!toyunda->init())
  {
      qCritical() << "Can't init qtoyunda, abord";
      return 1;
  }
  qDebug() << "Load files";
  toyunda->load(option["video"].toString(), option["subtitle"].toString());
  qDebug() << "Play the video";
  toyunda->play();
  toyunda->showRenderer();
  int ret = qapp->exec();
  toyunda->dispose();
  return ret;
}
开发者ID:Toyunda,项目名称:toyunda,代码行数:73,代码来源:main.cpp

示例14: main

Q_DECL_EXPORT
#endif
int main(int argc, char *argv[])
{
#if defined(Q_WS_X11)
#if QT_VERSION >= 0x040800
    QApplication::setAttribute(Qt::AA_X11InitThreads, true);
#else
    XInitThreads();
    QApplication::setAttribute(static_cast<Qt::ApplicationAttribute>(10), true);
#endif
#endif

    QApplication *application;
    QDeclarativeView *view;
#ifdef HARMATTAN_BOOSTER
    application = MDeclarativeCache::qApplication(argc, argv);
    view = MDeclarativeCache::qDeclarativeView();
#else
    qWarning() << Q_FUNC_INFO << "Warning! Running without booster. This may be a bit slower.";
    QApplication stackApp(argc, argv);
    QmlApplicationViewer stackView;
    application = &stackApp;
    view = &stackView;
    stackView.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
#endif
    application->setQuitOnLastWindowClosed(true);

    // FIXME uncommenting this will make UI not loaded
    // QMozContext::GetInstance();

    QString path;
    QString urlstring;
    QString qmlstring;
#ifdef __arm__
    bool isFullscreen = true;
#else
    bool isFullscreen = false;
#endif
#if !defined(Q_WS_MAEMO_5)
    bool glwidget = true;
#else
    bool glwidget = false;
#endif
    QStringList arguments = application->arguments();
    for (int i = 0; i < arguments.count(); ++i) {
        QString parameter = arguments.at(i);
        if (parameter == "-path") {
            if (i + 1 >= arguments.count())
                qFatal("-path requires an argument");
            path = arguments.at(i + 1);
            i++;
        } else if (parameter == "-url") {
            if (i + 1 >= arguments.count())
                qFatal("-url requires an argument");
            urlstring = arguments.at(i + 1);
            i++;
        } else if (parameter == "-qml") {
            if (i + 1 >= arguments.count())
                qFatal("-qml requires an argument");
            qmlstring = arguments.at(i + 1);
            i++;
        } else if (parameter == "-fullscreen") {
            isFullscreen = true;
        } else if (parameter == "-no-glwidget") {
            glwidget = false;
        } else if (parameter == "-glwidget") {
            glwidget = true;
        } else if (parameter == "-help") {
            qDebug() << "EMail application";
            qDebug() << "-fullscreen   - show QML fullscreen";
            qDebug() << "-path         - path to cd to before launching -url";
            qDebug() << "-qml          - file to launch (default: main.qml inside -path)";
            qDebug() << "-url          - url to load";
            qDebug() << "-no-glwidget  - Don't use QGLWidget viewport";
            exit(0);
        } 
    }

    if (!path.isEmpty())
        QDir::setCurrent(path);

    qmlRegisterType<QMozContext>("QtMozilla", 1, 0, "QMozContext");
    qmlRegisterType<QGraphicsMozView>("QtMozilla", 1, 0, "QGraphicsMozView");
    qmlRegisterType<QDeclarativeMozView>("QtMozilla", 1, 0, "QDeclarativeMozView");

    QUrl qml;
    if (qmlstring.isEmpty())
#if defined(__arm__) && !defined(Q_WS_MAEMO_5)
        qml = QUrl("qrc:/qml/main_meego.qml");
#else
        qml = QUrl("qrc:/qml/main.qml");
#endif
    else
开发者ID:romaxa,项目名称:qmlmozbrowser,代码行数:94,代码来源:main.cpp

示例15: main

int main (int argc, char *argv[]) {
	QApplication app (argc, argv);
	QStringList args = app.arguments ();
	if (!args.isEmpty ()) args.pop_front ();	// The command itself
	qputenv ("DESKTOP_STARTUP_ID", qgetenv ("STARTUP_ID_COPY"));	// for startup notifications (set via rkward.desktop)
	qputenv ("STARTUP_ID_COPY", "");

	// Parse arguments that need handling in the wrapper
	bool usage = false;
	QStringList debugger_args;
	QStringList file_args;
	bool reuse = false;
	bool warn_external = true;
	QString r_exe_arg;
	int debug_level = 2;

	for (int i=0; i < args.size (); ++i) {
		if (args[i] == "--debugger") {
			args.removeAt (i);
			while (i < args.size ()) {
				QString arg = args.takeAt (i);
				if (arg == "--") break;
				debugger_args.append (arg);
			}
			if (debugger_args.isEmpty ()) usage = true;
		} else if (args[i] == "--r-executable") {
			if ((i+1) < args.size ()) {
				r_exe_arg = args.takeAt (i + 1);
			} else usage = true;
			args.removeAt (i);
			--i;
		} else if (args[i] == "--debug-level") {
			if ((i+1) < args.size ()) {
				debug_level = args[i+1].toInt ();
			}
		} else if (args[i] == "--reuse") {
			reuse = true;
		} else if (args[i] == "--nowarn-external") {
			warn_external = false;
		} else if (args[i].startsWith ("--")) {
			// all RKWard and KDE options (other than --reuse) are of the for --option <value>. So skip over the <value>
			i++;
		} else {
			QUrl url (args[i]);
			if (url.isRelative ()) {
				file_args.append (QDir::current ().absoluteFilePath (url.toLocalFile ()));
			} else {
				file_args.append (args[i]);
			}
		}
	}

	if (reuse) {
		if (!QDBusConnection::sessionBus ().isConnected ()) {
			if (debug_level > 2) qDebug ("Could not connect to session dbus");
		} else {
			QDBusInterface iface (RKDBUS_SERVICENAME, "/", "", QDBusConnection::sessionBus ());
			if (iface.isValid ()) {
				QDBusReply<void> reply = iface.call ("openAnyUrl", file_args, warn_external);
				if (!reply.isValid ()) {
					if (debug_level > 2) qDebug ("Error while placing dbus call: %s", qPrintable (reply.error ().message ()));
					return 1;
				}
				return 0;
			}
		}
	}

	// MacOS may need some path adjustments, first
#ifdef Q_WS_MAC
	QString oldpath = qgetenv ("PATH");
	if (!oldpath.contains (INSTALL_PATH)) {
		//ensure that PATH is set to include what we deliver with the bundle
		qputenv ("PATH", QString ("%1/bin:%1/sbin:%2").arg (INSTALL_PATH).arg (oldpath).toLocal8Bit ());
		if (debug_level > 3) qDebug ("Adjusting system path to %s", qPrintable (qgetenv ("PATH")));
	}
	// ensure that RKWard finds its own packages
	qputenv ("R_LIBS", R_LIBS);
	QProcess::execute ("launchctl", QStringList () << "load" << "-w" << INSTALL_PATH "/Library/LaunchAgents/org.freedesktop.dbus-session.plist");
#endif

	// Locate KDE and RKWard installations
	QString kde4_config_exe = findExeAtPath ("kde4-config", QDir::currentPath ());
	if (kde4_config_exe.isNull ()) kde4_config_exe = findExeAtPath ("kde4-config", app.applicationDirPath ());
	if (kde4_config_exe.isNull ()) kde4_config_exe = findExeAtPath ("kde4-config", QDir (app.applicationDirPath ()).filePath ("KDE/bin"));
	if (kde4_config_exe.isNull ()) {
#ifdef Q_WS_WIN
	QStringList syspath = QString (qgetenv ("PATH")).split (';');
#else
	QStringList syspath = QString (qgetenv ("PATH")).split (':');
#endif
		for (int i = 0; i < syspath.size (); ++i) {
			kde4_config_exe = findExeAtPath ("kde4-config", syspath[i]);
			if (!kde4_config_exe.isNull ()) break;
		}
	}

	if (kde4_config_exe.isNull ()) {
		QMessageBox::critical (0, "Could not find KDE installation", "The KDE installation could not be found (kde4-config). When moving / copying RKWard, make sure to copy the whole application folder, or create a shorcut / link, instead.");
		exit (1);
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:rkward,代码行数:101,代码来源:rkward_startup_wrapper.cpp


注:本文中的QApplication::arguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。