Example #1
0
int main(int argc, char** argv) {
   // Register a new Message Handler for qDebug/qWarning/qCritical/qFatal
#ifdef INSTALL_MESSAGE_HANDLER
   qInstallMsgHandler(messageHandler);
#endif

   // Create the Application
   QApplication app(argc, argv);
   app.setApplicationName(APP_NAME);
   app.setApplicationVersion(APP_VERSION);
   app.setOrganizationName(ORG_NAME);
   app.setOrganizationDomain(ORG_DOMAIN);

   // Init Resource Files
   Q_INIT_RESOURCE(qmls);

   // MainView, that will hold the QML UI
   MainView mainView;

#if defined(Q_OS_SYMBIAN)
   qt_SetDefaultIap(); // This will avoid the browser to keep asking for an IAP
#elif defined(Q_WS_MAEMO_5)
   mainView.setAttribute(Qt::WA_Maemo5NonComposited, true); //< This will avoid the use of Composite on this Parentless-Widget
   mainView.setAttribute(Qt::WA_Maemo5AutoOrientation, true); //< "Qt::WA_Maemo5PortraitOrientation" or "Qt::WA_Maemo5LandscapeOrientation" or "Qt::WA_Maemo5AutoOrientation"
#endif

#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
   //desktop build, just open a window
//   mainView.setWindowFlags(Qt::FramelessWindowHint);
   mainView.show();
#else
	//TODO recognise whether Q_OS_LINUX is defined and understand whether is meego or desktop linux
   //mobile builds, we want the whole screen!
   mainView.showFullScreen();
#endif


   // The Core of the Application
   Core core(&mainView);
   core.start();

   return app.exec();
}
Example #2
0
int main(int argc, char *argv[])
{

    
	QApplication a(argc, argv);
    
	try
	{
		MainScene scene(&a);

		QRect rec = QApplication::desktop()->screenGeometry();
		float screenHeight = rec.height();
		float screenWidth = rec.width();

#if TARGET_OS_IPHONE
		if( screenHeight/screenWidth == 0.75 )
			//c'est un iPad
			scene.setSceneRect(100, 0, 1440, 900);
		else
			//c'est un iPhone
			scene.setSceneRect(0, 0, 1440, 900);
#else
		scene.setSceneRect(0, 0, screenWidth, screenHeight);
#endif

		QFont font("Helvetica Neue", 30, -1, false);
		QFont sansFont("Helvetica", 30);

		a.setStyleSheet("background-color: black;");
		scene.setBackgroundBrush(QBrush(QColor(0, 0, 0)));
		
        MainView *view = new MainView(&scene);
        
        view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));

        //view->setScene(&scene);
        
        
		//qDebug() << screenHeight / screenWidth;

#if TARGET_OS_IPHONE
		if( screenHeight/screenWidth == 0.75 )
			//c'est un iPad
			view->fitInView(QRect(0, 0, rec.height()/1.9, rec.width()/1.57), Qt::KeepAspectRatio);
		else
			//c'est un iPhone
			view->fitInView(QRect(0, 0, rec.height()*2.1, rec.width()*2.1), Qt::KeepAspectRatio);
#endif


#ifdef __APPLE__
#if TARGET_OS_IPHONE
		view->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
		view->setFrameShape(QFrame::NoFrame);
#else
		//rien. le défaut est parfait sur Mac
#endif
        
#else
		view->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
		view->setFrameShape(QFrame::NoFrame);
#endif

		//view.setTransform(m);
		view->showFullScreen();

        
		//view.show();
		return a.exec();
	}
	catch (std::exception& e){
		QMessageBox::critical(0, "Genius Couleur", e.what());
		return 0;
	}

}
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QGuiApplication::setOrganizationName("Reach Technology");
    QGuiApplication::setOrganizationDomain("reachtech.com");
    QGuiApplication::setApplicationName("Qml-Viewer");
    QGuiApplication::setApplicationVersion(APP_VERSION);
    MainView view;

    QFileInfo settingsFile;

    QStringList args = app.arguments();
    foreach (QString item, args) {
        if(item == "--version" || item == "-v") {
            qDebug() << "QML Viewer " << APP_VERSION;
            return 0;
        }
    }

    QString sb(QGuiApplication::applicationDirPath());
    sb.append(QDir::separator());
    sb.append("settings.conf");
    // check to see if we have a settings file where we started from
    // if not fall back to system hard coded path
    QFileInfo file(sb);
    if (file.exists()) {
        qDebug() << "[QML] using local settings file:" << file.filePath();
        settingsFile.setFile(file.filePath());
    } else {
        qDebug() << "[QML] using system defined settings file:" << SYSTEM_SETTINGS_FILE;
        settingsFile.setFile(SYSTEM_SETTINGS_FILE);
    }

    #ifdef Q_OS_WIN
        QSettings settings(settingsFile.filePath(),QSettings::IniFormat);
    #else
        QSettings settings(settingsFile.filePath(),QSettings::NativeFormat);
    #endif

    settings.beginGroup(SYSTEM_SETTINGS_SECTION);
    int port = settings.value("port",4000).toInt();
    bool parseJSON = settings.value("parse_json", true).toBool();

    MainController controller(&view, port, parseJSON);

    QString test = settings.value("main_view").toString();

    view.setSource(QUrl::fromLocalFile(settings.value("main_view").toString()));
    view.setResizeMode(QQuickView::SizeRootObjectToView);

    if (settings.value("full_screen",false).toBool()) {
        view.showFullScreen();
    }

    if (settings.value("hide_curosr",false).toBool()) {
        view.setCursor(QCursor( Qt::BlankCursor ));
    }

    settings.endGroup();
    return app.exec();
}