Example #1
0
int main (int argc, char *argv[])
{
  // construct core app
  QCoreApplication app (argc, argv);

  // get arguments
  QString encoding = app.arguments().at(1);
  QString inFile = app.arguments().at(2);
  QString outFile = app.arguments().at(3);

  Kate::TextBuffer buffer (0);

  // set codec
  buffer.setFallbackTextCodec (QTextCodec::codecForName ("ISO 8859-15"));
  buffer.setTextCodec (QTextCodec::codecForName (encoding.toLatin1()));

  // switch to Mac EOL, this will test eol detection, as files are normal unix or dos
  buffer.setEndOfLineMode (Kate::TextBuffer::eolMac);

  // load file
  bool encodingErrors = false;
  bool tooLongLines = false;
  if (!buffer.load (inFile, encodingErrors, tooLongLines) || encodingErrors)
    return 1;

  // save file
  if (!buffer.save (outFile))
    return 1;

  return 0;
}
Example #2
0
void QGBSettings::initialize(const QCoreApplication & appli){
  appli.setOrganizationName("Satellite");
  appli.setOrganizationDomain("satellite.epfl.ch");
  appli.setApplicationName("QGoldenBook");

  d_instance = new QGBSettings();
}
Example #3
0
void grabUVContext::toolOnSetup( MEvent &event )
{
	MPxTexContext::toolOnSetup( event );

	QCoreApplication *app = qApp;
	app->installEventFilter(this);
}
Example #4
0
void Global::initialize()
{
    // stop init process and exit if the class was allready initialized
    if(Global::init) {
        return;
    }

    // simplefy application instance
    QCoreApplication* app = QApplication::instance();


    // init settings
    QString strConfigFile = QFileInfo(app->applicationFilePath()).baseName() + ".ini";
    if(!QFile::exists(strConfigFile)) {
        qFatal("Cannot find Config file:\r\n%s", qPrintable(strConfigFile));
    }
    Global::settings = new QSettings(strConfigFile, QSettings::IniFormat);


    Global::strServerHostname = Global::settings->value("server/hostname", Global::strServerHostname).toString();
    Global::intServerPort = Global::settings->value("server/port", Global::intServerPort).toUInt();
    Global::strSessionName = Global::settings->value("session/name", Global::strSessionName).toString();


    // init socket
    Global::socketServer = new QTcpSocket(app);

    // init EleaphRpc handler
    Global::eleaphRpc = new EleaphRpc(app);
    Global::eleaphRpc->addDevice(Global::socketServer, IEleaph::NeverForgetDevice);

    // class was successfull initialized!
    Global::init = true;
}
Example #5
0
void loadTranslations( QCoreApplication &app, QTranslator &translator )
{
    const QString lang = QLocale::system().name();
    QString code;

    int index = lang.indexOf ( '_' );
    if ( lang == "C" ) {
        code = "en";
    }
    else if ( index != -1 ) {
        code = lang.left ( index );
    }
    else {
        index = lang.indexOf ( '@' );
        if ( index != -1 )
            code = lang.left ( index );
        else
            code = lang;
    }

    QString const i18nDir = "/usr/share/marble/translations";
    QString const relativeDir = app.applicationDirPath() + "/translations";
    foreach( const QString &path, QStringList() << i18nDir << relativeDir << QDir::currentPath() ) {
        foreach( const QString &lang, QStringList() << lang << code ) {
            QFileInfo translations = QFileInfo( path + "/routing-instructions_" + lang + ".qm" );
            if ( translations.exists() && translator.load( translations.absoluteFilePath() ) ) {
                app.installTranslator( &translator );
                return;
            }
        }
    }
}
Example #6
0
void Global::initialize()
{
    // stop init process and exit if the class was allready initialized
    if(Global::init) {
        return;
    }

    // simplefy application instance
    QCoreApplication* app = QCoreApplication::instance();

    /// init settings
    QString strConfigFile = QFileInfo(app->applicationFilePath()).baseName() + ".ini";
    if(!QFile::exists(strConfigFile)) {
        qFatal("Cannot find Config file:\r\n%s", qPrintable(strConfigFile));
    }
    Global::settings = new QSettings(strConfigFile, QSettings::IniFormat);

    /// init database helper
    QSqlDatabase database = QSqlDatabase::addDatabase(Global::getConfigValue("database/driver").toString(), "sqm");
    database.setDatabaseName(Global::getConfigValue("database/name", "").toString());
    database.setHostName(Global::getConfigValue("database/hostname", "").toString());
    database.setPort(Global::getConfigValue("database/port", 0).toInt());
    database.setUserName(Global::getConfigValue("database/username", "").toString());
    database.setPassword(Global::getConfigValue("database/password", "").toString());
    database.setConnectOptions(Global::getConfigValue("database/connectoptions", "").toString());
    if(database.open()) {
        printf("Datenbank Verbindung erfolgreich!");
    } else {
        qFatal("Datenbank Verbindung NICHT erfolgreich!");
    }
    Global::databaseHelper = new DatabaseHelper("sqm");

    // class was successfull initialized!
    Global::init = true;
}
KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url)
{
    QString parentApp;
    QCoreApplication *app = QCoreApplication::instance();
    if (app) {
        parentApp = app->applicationName();
    }

    auto filter = [&parentApp](const KPluginMetaData &md) -> bool
    {
        const QString pa = md.value(QStringLiteral("X-KDE-ParentApp"));
        return (pa.isEmpty() || pa == parentApp) && !md.value(QStringLiteral("X-Plasma-DropUrlPatterns")).isEmpty();
    };
    KPluginInfo::List allApplets =  KPluginInfo::fromMetaData(KPackage::PackageLoader::self()->findPackages("Plasma/Applet", QString(), filter).toVector());

    KPluginInfo::List filtered;
    foreach (const KPluginInfo &info, allApplets) {
        QStringList urlPatterns = info.property("X-Plasma-DropUrlPatterns").toStringList();
        foreach (const QString &glob, urlPatterns) {
            QRegExp rx(glob);
            rx.setPatternSyntax(QRegExp::Wildcard);
            if (rx.exactMatch(url.toString())) {
#ifndef NDEBUG
                // qCDebug(LOG_PLASMA) << info.name() << "matches" << glob << url;
#endif
                filtered << info;
            }
        }
Example #8
0
int main(int argc, char *argv[])
{
	Q_INIT_RESOURCE(resources);

	Core::resetCore();
	
	//Start QApplication with or without GUI support.
	bool useGui = false;
	for(int i = 0; i < argc; ++i) {
		if(QString(argv[i]) == "-gui") {
			useGui = true;
		}
	}
	QCoreApplication *app = 0;
	if(useGui) {
		app = new QApplication(argc, argv);
	}
	else {
		app = new QCoreApplication(argc, argv); 
	}

	ASeriesClientApplication *nerd = new ASeriesClientApplication();
	nerd->startApplication();
	
	app->exec();


	Core::getInstance()->waitForAllThreadsToComplete();
	Core::resetCore();

	delete app;

	return 0;

}
QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context)
    : mainContext(context)
{
#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 32
    if (qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")) {
        static QBasicMutex mutex;
        QMutexLocker locker(&mutex);
        if (!g_thread_supported())
            g_thread_init(NULL);
    }
#endif

    if (mainContext) {
        g_main_context_ref(mainContext);
    } else {
        QCoreApplication *app = QCoreApplication::instance();
        if (app && QThread::currentThread() == app->thread()) {
            mainContext = g_main_context_default();
            g_main_context_ref(mainContext);
        } else {
            mainContext = g_main_context_new();
        }
    }

#if GLIB_CHECK_VERSION (2, 22, 0)
    g_main_context_push_thread_default (mainContext);
#endif

    // setup post event source
    postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs,
                                                                        sizeof(GPostEventSource)));
    postEventSource->serialNumber.store(1);
    postEventSource->d = this;
    g_source_set_can_recurse(&postEventSource->source, true);
    g_source_attach(&postEventSource->source, mainContext);

    // setup socketNotifierSource
    socketNotifierSource =
        reinterpret_cast<GSocketNotifierSource *>(g_source_new(&socketNotifierSourceFuncs,
                                                               sizeof(GSocketNotifierSource)));
    (void) new (&socketNotifierSource->pollfds) QList<GPollFDWithQSocketNotifier *>();
    g_source_set_can_recurse(&socketNotifierSource->source, true);
    g_source_attach(&socketNotifierSource->source, mainContext);

    // setup normal and idle timer sources
    timerSource = reinterpret_cast<GTimerSource *>(g_source_new(&timerSourceFuncs,
                                                                sizeof(GTimerSource)));
    (void) new (&timerSource->timerList) QTimerInfoList();
    timerSource->processEventsFlags = QEventLoop::AllEvents;
    timerSource->runWithIdlePriority = false;
    g_source_set_can_recurse(&timerSource->source, true);
    g_source_attach(&timerSource->source, mainContext);

    idleTimerSource = reinterpret_cast<GIdleTimerSource *>(g_source_new(&idleTimerSourceFuncs,
                                                                        sizeof(GIdleTimerSource)));
    idleTimerSource->timerSource = timerSource;
    g_source_set_can_recurse(&idleTimerSource->source, true);
    g_source_set_priority(&idleTimerSource->source, G_PRIORITY_DEFAULT_IDLE);
    g_source_attach(&idleTimerSource->source, mainContext);
}
Example #10
0
int main(int argc, char *argv[]) {
  QCoreApplication app (argc, argv);
  
  if (app.arguments().size() != 2) {
    qCritical("You have to specify the file containing the json code");
    exit (1);
  }
  
  QString filename = app.arguments()[1];
  if (!QFile::exists ( filename )) {
    qCritical ("The file you specified doesn't exist!");
    exit (1);
  }
  
  Parser driver;
  bool ok;

  QFile file (filename);
  QVariant data = driver.parse (&file, &ok);
  if (!ok) {
    qCritical("%s:%i - Error: %s", filename.toLatin1().data(), driver.errorLine(), qPrintable(driver.errorString()));
    exit (1);
  }
  else {
    qDebug() << "json object successfully converted to:";
    qDebug() << data;
  }

  qDebug() << "JOB DONE, BYE";
  return 0;
}
Example #11
0
void grabUVContext::toolOffCleanup()
{
	QCoreApplication *app = qApp;
	app->removeEventFilter(this);

	MPxTexContext::toolOffCleanup();
}
bool qtnStartInplaceEdit(QWidget* editor)
{
    if (!editor)
        return false;

    if (g_inplaceEditor)
    {
        Q_ASSERT(false);
        qtnStopInplaceEdit();
    }

    QCoreApplication* app = QCoreApplication::instance();
    if (!app)
    {
        Q_ASSERT(false);
        return false;
    }

    g_inplaceEditor = editor;
    g_inplaceEditorHandler = new QtnInplaceEditorHandler();

    // move focus to editor
    if (QApplication::focusWidget() != g_inplaceEditor->focusWidget())
        g_inplaceEditor->setFocus();

    // connect to editor destroyed signal
    QObject::connect(  g_inplaceEditor, &QObject::destroyed
                     , g_inplaceEditorHandler, &QtnInplaceEditorHandler::OnEditorDestroyed);

    // install application event filter
    app->installEventFilter(g_inplaceEditorHandler);

    return true;
}
QApplicationActivityObserver * QApplicationActivityObserver::instance()
{
	static QMutex mymutex;
	static QScopedPointer<QApplicationActivityObserver> instance;
	QMutexLocker locker(&mymutex);

	// Creating instance
	if (instance.isNull())
	{
		instance.reset(new QApplicationActivityObserver());
	}

	// Installing event filter
	static bool installed_filter = false;
	if (!installed_filter)
	{
		QCoreApplication * app = QCoreApplication::instance();
		if (app)
		{
			app->installEventFilter(instance.data());
			installed_filter = true;
			qDebug()<<__FUNCTION__<<"Successfully installed event filter.";
		}
		else
		{
			qWarning()<<__FUNCTION__<<"installing event filter failed because QCoreApplication instance doesn't exist, will try later.";
		}
	}

	return instance.data();
}
Example #14
0
void MainWindow::on_about()
{
	QCoreApplication * app = QCoreApplication::instance();
	QMessageBox::about(this, app->applicationName(), app->applicationName()
			+ ": example of Qt using marnav\n\nVersion: " + app->applicationVersion()
			+ "\n\nSee file: LICENSE");
}
Example #15
0
/*!
    Enters the main event loop and waits until exit() is called.
    Returns the value that was passed to exit().

    If \a flags are specified, only events of the types allowed by
    the \a flags will be processed.

    It is necessary to call this function to start event handling. The
    main event loop receives events from the window system and
    dispatches these to the application widgets.

    Generally speaking, no user interaction can take place before
    calling exec(). As a special case, modal widgets like QMessageBox
    can be used before calling exec(), because modal widgets
    use their own local event loop.

    To make your application perform idle processing (i.e. executing a
    special function whenever there are no pending events), use a
    QTimer with 0 timeout. More sophisticated idle processing schemes
    can be achieved using processEvents().

    \sa QApplication::quit(), exit(), processEvents()
*/
int QEventLoop::exec(ProcessEventsFlags flags)
{
    Q_D(QEventLoop);
    //we need to protect from race condition with QThread::exit
    QMutexLocker locker(&static_cast<QThreadPrivate *>(QObjectPrivate::get(d->threadData->thread))->mutex);
    if (d->threadData->quitNow)
        return -1;

    if (d->inExec) {
        qWarning("QEventLoop::exec: instance %p has already called exec()", this);
        return -1;
    }
    d->inExec = true;
    d->exit = false;
    ++d->threadData->loopLevel;
    d->threadData->eventLoops.push(this);
    locker.unlock();

    // remove posted quit events when entering a new event loop
    QCoreApplication *app = QCoreApplication::instance();
    if (app && app->thread() == thread())
        QCoreApplication::removePostedEvents(app, QEvent::Quit);

#if defined(QT_NO_EXCEPTIONS)
    while (!d->exit)
        processEvents(flags | WaitForMoreEvents | EventLoopExec);
#else
    try {
        while (!d->exit)
            processEvents(flags | WaitForMoreEvents | EventLoopExec);
    } catch (...) {
        qWarning("Qt has caught an exception thrown from an event handler. Throwing\n"
                 "exceptions from an event handler is not supported in Qt. You must\n"
                 "reimplement QApplication::notify() and catch all exceptions there.\n");

        // copied from below
        locker.relock();
        QEventLoop *eventLoop = d->threadData->eventLoops.pop();
        Q_ASSERT_X(eventLoop == this, "QEventLoop::exec()", "internal error");
        Q_UNUSED(eventLoop); // --release warning
        d->inExec = false;
        --d->threadData->loopLevel;

        throw;
    }
#endif

    // copied above
    locker.relock();
    QEventLoop *eventLoop = d->threadData->eventLoops.pop();
    Q_ASSERT_X(eventLoop == this, "QEventLoop::exec()", "internal error");
    Q_UNUSED(eventLoop); // --release warning
    d->inExec = false;
    --d->threadData->loopLevel;

    return d->returnCode;
}
void AMCrashMonitorSupport::report(){
	QCoreApplication *app = QApplication::instance();

	QStringList appArguments = app->arguments();
	if(!appArguments.contains("--enableCrashMonitor"))
		return;

	kill(globalCrashMonitorPID, SIGUSR2);
}
Example #17
0
/*!
    Enters the main event loop and waits until exit() is called.
    Returns the value that was passed to exit().

    If \a flags are specified, only events of the types allowed by
    the \a flags will be processed.

    It is necessary to call this function to start event handling. The
    main event loop receives events from the window system and
    dispatches these to the application widgets.

    Generally speaking, no user interaction can take place before
    calling exec(). As a special case, modal widgets like QMessageBox
    can be used before calling exec(), because modal widgets
    use their own local event loop.

    To make your application perform idle processing (i.e. executing a
    special function whenever there are no pending events), use a
    QTimer with 0 timeout. More sophisticated idle processing schemes
    can be achieved using processEvents().

    \sa QCoreApplication::quit(), exit(), processEvents()
*/
int QEventLoop::exec(ProcessEventsFlags flags)
{
    Q_D(QEventLoop);
    //we need to protect from race condition with QThread::exit
    QMutexLocker locker(&static_cast<QThreadPrivate *>(QObjectPrivate::get(d->threadData->thread))->mutex);
    if (d->threadData->quitNow)
        return -1;

    if (d->inExec) {
        qWarning("QEventLoop::exec: instance %p has already called exec()", this);
        return -1;
    }

    struct LoopReference {
        QEventLoopPrivate *d;
        QMutexLocker &locker;

        bool exceptionCaught;
        LoopReference(QEventLoopPrivate *d, QMutexLocker &locker) : d(d), locker(locker), exceptionCaught(true)
        {
            d->inExec = true;
            d->exit.storeRelease(false);
            ++d->threadData->loopLevel;
            d->threadData->eventLoops.push(d->q_func());
            locker.unlock();
        }

        ~LoopReference()
        {
            if (exceptionCaught) {
                qWarning("Qt has caught an exception thrown from an event handler. Throwing\n"
                         "exceptions from an event handler is not supported in Qt.\n"
                         "You must not let any exception whatsoever propagate through Qt code.\n"
                         "If that is not possible, in Qt 5 you must at least reimplement\n"
                         "QCoreApplication::notify() and catch all exceptions there.\n");
            }
            locker.relock();
            QEventLoop *eventLoop = d->threadData->eventLoops.pop();
            Q_ASSERT_X(eventLoop == d->q_func(), "QEventLoop::exec()", "internal error");
            Q_UNUSED(eventLoop); // --release warning
            d->inExec = false;
            --d->threadData->loopLevel;
        }
    };
    LoopReference ref(d, locker);

    // remove posted quit events when entering a new event loop
    QCoreApplication *app = QCoreApplication::instance();
    if (app && app->thread() == thread())
        QCoreApplication::removePostedEvents(app, QEvent::Quit);

    while (!d->exit.loadAcquire())
        processEvents(flags | WaitForMoreEvents | EventLoopExec);

    ref.exceptionCaught = false;
    return d->returnCode.load();
}
Example #18
0
void MainWindow::on_about()
{
	QCoreApplication* app = QCoreApplication::instance();
	QString version;
	if (app) {
		version = QString("\n\nVersion: ") + app->applicationVersion();
	}
	QMessageBox::about(this, "qtnavigator", "qtnavigator : navigation software" + version);
}
Example #19
0
void ServiceApp::start()
{
  QCoreApplication *app = application();
  app->setApplicationName(SCHAT_NAME);
  app->setApplicationVersion(SCHAT_VERSION);
  app->setOrganizationName(LS("IMPOMEZIA"));
  app->setOrganizationDomain(SCHAT_DOMAIN);

  m_init = new NodeInit(LS("schatd2"), app);
}
Example #20
0
/*!
    Enters the main event loop and waits until exit() is called.
    Returns the value that was passed to exit().

    If \a flags are specified, only events of the types allowed by
    the \a flags will be processed.

    It is necessary to call this function to start event handling. The
    main event loop receives events from the window system and
    dispatches these to the application widgets.

    Generally speaking, no user interaction can take place before
    calling exec(). As a special case, modal widgets like QMessageBox
    can be used before calling exec(), because modal widgets
    use their own local event loop.

    To make your application perform idle processing (i.e. executing a
    special function whenever there are no pending events), use a
    QTimer with 0 timeout. More sophisticated idle processing schemes
    can be achieved using processEvents().

    \sa QApplication::quit(), exit(), processEvents()
*/
int QEventLoop::exec(ProcessEventsFlags flags)
{
    Q_D(QEventLoop);
    if (d->threadData->quitNow)
        return -1;

    if (d->inExec) {
        qWarning("QEventLoop::exec: instance %p has already called exec()", this);
        return -1;
    }
    d->inExec = true;
    d->exit = false;
    ++d->threadData->loopLevel;
    d->threadData->eventLoops.push(this);

    // remove posted quit events when entering a new event loop
    QCoreApplication *app = QCoreApplication::instance();
    if (app && app->thread() == thread())
        QCoreApplication::removePostedEvents(app, QEvent::Quit);

#if defined(QT_NO_EXCEPTIONS)
    while (!d->exit) {
        //printf("** qeventloop() 1 right before handle_events\n");
        processEvents(flags | WaitForMoreEvents | EventLoopExec);
    }
#else
    try {
        while (!d->exit) {
            processEvents(flags | WaitForMoreEvents | EventLoopExec);
        }
    } catch (...) {
        qWarning("Qt has caught an exception thrown from an event handler. Throwing\n"
                 "exceptions from an event handler is not supported in Qt. You must\n"
                 "reimplement QApplication::notify() and catch all exceptions there.\n");

        // copied from below
        QEventLoop *eventLoop = d->threadData->eventLoops.pop();
        Q_ASSERT_X(eventLoop == this, "QEventLoop::exec()", "internal error");
        Q_UNUSED(eventLoop); // --release warning
        d->inExec = false;
        --d->threadData->loopLevel;

        throw;
    }
#endif

    // copied above
    QEventLoop *eventLoop = d->threadData->eventLoops.pop();
    Q_ASSERT_X(eventLoop == this, "QEventLoop::exec()", "internal error");
    Q_UNUSED(eventLoop); // --release warning
    d->inExec = false;
    --d->threadData->loopLevel;

    return d->returnCode;
}
Example #21
0
void MainWindow::getMayaWindow()
{
    QCoreApplication*  app = qApp;
    if (app) {
        cout << "Application name is '" << app->applicationName().toStdString() << "'" << endl;
    }
    else
    {
        cout << "No maya app detected: " << app << endl;
    }
}
Example #22
0
QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context)
    : mainContext(context)
{
    if (qgetenv("QT_NO_THREADED_GLIB").isEmpty()) {
        static int dummyValue = 0; // only used for its address
        QMutexLocker locker(QMutexPool::instance()->get(&dummyValue));
        if (!g_thread_supported())
            g_thread_init(NULL);
    }

    if (mainContext) {
        g_main_context_ref(mainContext);
    } else {
        QCoreApplication *app = QCoreApplication::instance();
        if (app && QThread::currentThread() == app->thread()) {
            mainContext = g_main_context_default();
            g_main_context_ref(mainContext);
        } else {
            mainContext = g_main_context_new();
        }
    }

    // setup post event source
    postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs,
                                                                        sizeof(GPostEventSource)));
    postEventSource->serialNumber = 1;
    g_source_set_can_recurse(&postEventSource->source, true);
    g_source_attach(&postEventSource->source, mainContext);

    // setup socketNotifierSource
    socketNotifierSource =
        reinterpret_cast<GSocketNotifierSource *>(g_source_new(&socketNotifierSourceFuncs,
                                                               sizeof(GSocketNotifierSource)));
    (void) new (&socketNotifierSource->pollfds) QList<GPollFDWithQSocketNotifier *>();
    g_source_set_can_recurse(&socketNotifierSource->source, true);
    g_source_attach(&socketNotifierSource->source, mainContext);

    // setup normal and idle timer sources
    timerSource = reinterpret_cast<GTimerSource *>(g_source_new(&timerSourceFuncs,
                                                                sizeof(GTimerSource)));
    (void) new (&timerSource->timerList) QTimerInfoList();
    timerSource->processEventsFlags = QEventLoop::AllEvents;
    timerSource->runWithIdlePriority = false;
    g_source_set_can_recurse(&timerSource->source, true);
    g_source_attach(&timerSource->source, mainContext);

    idleTimerSource = reinterpret_cast<GIdleTimerSource *>(g_source_new(&idleTimerSourceFuncs,
                                                                        sizeof(GIdleTimerSource)));
    idleTimerSource->timerSource = timerSource;
    g_source_set_can_recurse(&idleTimerSource->source, true);
    g_source_set_priority(&idleTimerSource->source, G_PRIORITY_DEFAULT_IDLE);
    g_source_attach(&idleTimerSource->source, mainContext);
}
// --------------------------------------------------------------------------
ctkErrorLogQtMessageHandler::ctkErrorLogQtMessageHandler() : Superclass()
{
  this->SavedQtMessageHandler = 0;

  QCoreApplication * coreApp = QCoreApplication::instance();

  // Keep track of all instantiated ctkErrorLogModel
  QList<QVariant> handlers = coreApp->property("ctkErrorLogQtMessageHandlers").toList();
  handlers << QVariant::fromValue(this);
  //handlers << QVariant::fromValue(QPointer<ctkErrorLogQtMessageHandler>(this));
  coreApp->setProperty("ctkErrorLogQtMessageHandlers", handlers);
}
Example #24
0
 inline QDBusDefaultConnection(BusType type, const char *name)
     : QDBusConnection(connectToBus(type, QString::fromLatin1(name))), ownName(name)
 {
     // make sure this connection is running on the main thread
     QCoreApplication *instance = QCoreApplication::instance();
     if (!instance) {
         qWarning("QDBusConnection: %s D-Bus connection created before QCoreApplication. Application may misbehave.",
                  type == SessionBus ? "session" : type == SystemBus ? "system" : "generic");
     } else if (QDBusConnectionPrivate::d(*this)) {
         QDBusConnectionPrivate::d(*this)->moveToThread(instance->thread());
     }
 }
Example #25
0
int main(int argc, char *argv[]) {
  QCoreApplication app (argc, argv);
  QTime time;
  int   duration;

 
  CmdLineParser cmd (app.arguments());
  CmdLineParser::Result res = cmd.parse();
  if (res == CmdLineParser::Help)
      return 0;
  else if (res == CmdLineParser::Error)
      return -1;

  QString filename = cmd.file();
  if (!QFile::exists ( filename )) {
    qCritical ("The file you specified doesn't exist!");
    exit (1);
  }
  
  Parser parser;
  bool ok;

  QFile file (filename);
  time.start();
  QVariant data = parser.parse (&file, &ok);
  duration = time.elapsed();
  if (!ok) {
    qCritical("%s:%i - Error: %s", filename.toLatin1().data(), parser.errorLine(), qPrintable(parser.errorString()));
    exit (1);
  }
  else {
    qDebug() << "Parsing of" << filename << "took" << duration << "ms";
    if (!cmd.quiet())
      qDebug() << data;
  }

  if (cmd.serialize()) {
    // serializer tests
    qDebug() << "Serializing... ";
    QJson::Serializer serializer;
    serializer.setIndentMode(cmd.indentationMode());
    time.start();
    QByteArray b = serializer.serialize(data);
    duration = time.elapsed();
    qDebug() << "Serialization took:" << duration << "ms";
    if (!cmd.quiet())
     qDebug() << b;
  }

  qDebug() << "JOB DONE, BYE";
  return 0;
}
Example #26
0
int main(int argc, char *argv[])
{
#ifdef _WIN32
	timeBeginPeriod(1);
#endif

	//initialize ressources (compiled images, etc.)
	Q_INIT_RESOURCE(resources);

	Core::resetCore();

	//Start QApplication with or without GUI support.
	bool useGui = true;
	for(int i = 0; i < argc; ++i) {
		if(QString(argv[i]) == "-nogui") {
			useGui = false;
		}
		else if(QString(argv[i]) == "-gui") {
			useGui = true;
		}
	}
	QCoreApplication *app = 0;
	if(useGui) {
		app = new QApplication(argc, argv);
	}
	else {
		app = new QCoreApplication(argc, argv); 
	}

	OrcsModelOptimizerApplication *nerd = 
			new OrcsModelOptimizerApplication();

	nerd->startApplication();
	
	app->exec();

	Core::getInstance()->waitForAllThreadsToComplete();

	Core::resetCore();

	delete app;


#ifdef _WIN32
	timeEndPeriod(1);
#endif

	return 0;


}
Example #27
0
void Robot::logInit()
{
   QCoreApplication *pApp = QCoreApplication::instance();
   QsLogging::Logger& logger = QsLogging::Logger::instance();
   logger.setLoggingLevel(QsLogging::TraceLevel);
   //Log to file
   const QString logPath(QDir(pApp->applicationDirPath()).filePath("Log.txt"));
   QsLogging::DestinationPtr fileDestination(
      QsLogging::DestinationFactory::MakeFileDestination(logPath) );
   logger.addDestination(fileDestination);
   //Log to standard output
   QsLogging::DestinationPtr debugDestination = QsLogging::DestinationFactory::MakeDebugOutputDestination();
   logger.addDestination(debugDestination);
}
Example #28
0
int main (int argc, char *argv[]) {
	QCoreApplication a (argc, argv);
	Nuria::HttpServer server;

	server.root ()->connectSlot ("index", mySlot);

	if (!server.listen (QHostAddress::Any, 3000)) {
		nError() << "Failed to listen on port 3000.";
		return 1;
	}

	nLog() << "Listening on all interfaces on port 3000.";
	return a.exec ();
}
Example #29
0
void MyService::start()
{
    try
    {
        QCoreApplication *app = application();
        qDebug() << "Service started!";
        qDebug() << app->applicationDirPath();
        //MyClass.dosomething();
    }
    catch(...)
    {
        qCritical() << "An unknown error in the start";
    }
}
Example #30
0
	void start()
	{
		QCoreApplication *app = application();
		
		QServer* tcpServer = createServer();
		if (tcpServer)
		{
			tcpServer->listen();

			if (!tcpServer->isListening()) {
				logMessage(QString("Failed to bind to port %1").arg(tcpServer->serverPort()), QtServiceBase::Error);
				app->quit();
			}
		}
	}