int main(int argc, char *argv[]) { QApplication app(argc, argv); qDebug() << "Application dir:" << QApplication::applicationDirPath(); qDebug() << "Data dir:" << _find_data_dir(""); // Chossing proper GUI style from config.ini file. QSettings settings("config.ini", QSettings::IniFormat); // Dude, this default style is really amazing... // Seriously? // No... QString guiStyle = settings.value("gui_style","DefaultAwesomeStyle").toString(); app.setStyle(QStyleFactory::create( guiStyle )); // Customize some elements: app.setStyleSheet("QGroupBox { font-weight: bold; } "); QFont font; font.setFamily(font.defaultFamily()); font.setPixelSize(10); app.setFont(font); // removing old log file QFile::remove(AB_LOG); QGLFormat glFormat(QGL::SampleBuffers); #ifdef Q_OS_MAC glFormat.setProfile( QGLFormat::CoreProfile ); glFormat.setVersion( 4, 1 ); #endif #ifdef USE_OPENGL_330 #ifdef Q_OS_LINUX glFormat.setProfile( QGLFormat::CoreProfile ); glFormat.setVersion( 3, 3 ); #endif #endif QGLFormat::setDefaultFormat(glFormat); qInstallMessageHandler(customMessageHandler); qDebug() << "Starting application:"; if(!checkOpenGL()){ AllAboutDialog msgBox; msgBox.setPixmap(":/resources/icon-off.png"); msgBox.setText("Fatal Error!"); #ifdef USE_OPENGL_330 msgBox.setInformativeText("Sorry but it seems that your graphics card does not support openGL 3.3.\n" "Program will not run :(\n" "See " AB_LOG " file for more info."); #else msgBox.setInformativeText("Sorry but it seems that your graphics card does not support openGL 4.0.\n" "Program will not run :(\n" "See " AB_LOG " file for more info."); #endif msgBox.show(); return app.exec(); }else{ MainWindow window; window.setWindowTitle(AWESOME_BUMP_VERSION); window.resize(window.sizeHint()); int desktopArea = QApplication::desktop()->width() * QApplication::desktop()->height(); int widgetArea = window.width() * window.height(); if (((float)widgetArea / (float)desktopArea) < 0.75f) window.show(); else window.showMaximized(); return app.exec(); } }
int main(int argc, char *argv[]) { QApplication app(argc, argv); qDebug() << "Application dir:" << QApplication::applicationDirPath(); qDebug() << "Data dir:" << _find_data_dir(""); // Chossing proper GUI style from config.ini file. QSettings settings("config.ini", QSettings::IniFormat); // Dude, this default style is really amazing... // Seriously? // No... QString guiStyle = settings.value("gui_style","DefaultAwesomeStyle").toString(); app.setStyle(QStyleFactory::create( guiStyle )); // Customize some elements: app.setStyleSheet("QGroupBox { font-weight: bold; } "); QFont font; font.setFamily(font.defaultFamily()); font.setPixelSize(10); app.setFont(font); // removing old log file QFile::remove(AB_LOG); QGLFormat glFormat(QGL::SampleBuffers); #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) /* * Commenting out the next line because it causes rendering to fail. QGLFormat::CoreProfile * disables all OpenGL functions that are depreciated as of OpenGL 3.0. This fix is a workaround. * The full solution is to replace all depreciated OpenGL functions with their current implements. */ # if defined(Q_OS_MAC) glFormat.setProfile( QGLFormat::CoreProfile ); # endif glFormat.setVersion( GL_MAJOR, GL_MINOR ); #endif QGLFormat::setDefaultFormat(glFormat); qInstallMessageHandler(customMessageHandler); qDebug() << "Starting application:"; if(!checkOpenGL()){ AllAboutDialog msgBox; msgBox.setPixmap(":/resources/icon-off.png"); msgBox.setText("Fatal Error!"); msgBox.setInformativeText(QString("Sorry but it seems that your graphics card does not support openGL %1.%2.\n" "Program will not run :(\n" "See " AB_LOG " file for more info.").arg(GL_MAJOR).arg(GL_MINOR)); msgBox.show(); return app.exec(); }else{ MainWindow window; window.setWindowTitle(AWESOME_BUMP_VERSION); window.resize(window.sizeHint()); int desktopArea = QApplication::desktop()->width() * QApplication::desktop()->height(); int widgetArea = window.width() * window.height(); if (((float)widgetArea / (float)desktopArea) < 0.75f) window.show(); else window.showMaximized(); return app.exec(); } }