コード例 #1
0
ファイル: main.cpp プロジェクト: DavidMolinari/sonic-pi
int main(int argc, char *argv[])
{
#ifndef Q_OS_MAC
  Q_INIT_RESOURCE(SonicPi);
#endif

  QApplication app(argc, argv);
  qRegisterMetaType<SonicPiLog::MultiMessage>("SonicPiLog::MultiMessage");

  QString systemLocale = QLocale::system().name();

  QTranslator qtTranslator;
  qtTranslator.load("qt_" + systemLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
  app.installTranslator(&qtTranslator);

  QTranslator translator;
  bool i18n = translator.load("sonic-pi_" + systemLocale, ":/lang/") || systemLocale.startsWith("en") || systemLocale == "C";
  app.installTranslator(&translator);

  app.setApplicationName(QObject::tr("Sonic Pi"));
  app.setStyle("gtk");

#ifdef Q_OS_MAC
  app.setAttribute( Qt::AA_UseHighDpiPixmaps );
  QMainWindow* splashWindow = new QMainWindow(0, Qt::FramelessWindowHint);
  QLabel* imageLabel = new QLabel();
  splashWindow->setAttribute( Qt::WA_TranslucentBackground);
  QPixmap image(":/images/[email protected]");
  imageLabel->setPixmap(image);
  splashWindow->setCentralWidget(imageLabel);
  splashWindow->setMinimumHeight(image.height()/2);
  splashWindow->setMaximumHeight(image.height()/2);
  splashWindow->setMinimumWidth(image.width()/2);
  splashWindow->setMaximumWidth(image.width()/2);

  splashWindow->raise();
  splashWindow->show();

  MainWindow mainWin(app, i18n, splashWindow);
  return app.exec();
#else
  QPixmap pixmap(":/images/splash.png");
  QSplashScreen *splash = new QSplashScreen(pixmap);
  splash->setMask(pixmap.mask());
  splash->show();
  splash->repaint();

  MainWindow mainWin(app, i18n, splash);
  return app.exec();
#endif

}
コード例 #2
0
ファイル: main.cpp プロジェクト: nixz/covise
int main(int argC, char *argV[])
{
    // Check for options
    int parmInd;
    for (parmInd = 1; parmInd < argC; parmInd++)
    {
        // Break out on first parm not starting with a dash
        if (argV[parmInd][0] != '-')
            break;
        else if (!strcmp(argV[parmInd], "-s")
                 || !strcmp(argV[parmInd], "-S"))
        {
            // sag ja zu schema
        }
        else
        {
            std::cout << "Unknown option " << argV[parmInd]
                      << "', ignoring it.\n";
        }
    }
    //     if (parmInd + 1 != argC)
    //     {
    //        usage();
    //        return 1;
    //     }
    QString filename = argV[parmInd];
    Q_INIT_RESOURCE(application);
    QApplication app(argC, argV);
    coEditorMainWindow mainWin(filename);

    mainWin.show();
    return app.exec();

    return (0);
}
コード例 #3
0
ファイル: main.cpp プロジェクト: SorinS/fop-miniscribus
int main(int argc, char *argv[])
{	
	QApplication app(argc, argv);
	MainWindow mainWin(argc,argv);
	mainWin.show();
	return app.exec();
}
コード例 #4
0
 int main(int argc, char **argv)
 {
     QApplication app(argc, argv);
     MainWindow mainWin();
     mainWin.resize(800, 600);
     mainWin.show();
     return app.exec();
 }
コード例 #5
0
ファイル: main.cpp プロジェクト: Andreas665/qt
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QMap<QString, QSize> customSizeHints = parseCustomSizeHints(argc, argv);
    MainWindow mainWin(customSizeHints);
    mainWin.resize(800, 600);
    mainWin.show();
    return app.exec();
}
コード例 #6
0
ファイル: pfocusLogBrowser.cpp プロジェクト: C-CINA/2dx
/***************************************************************************
 *   Main Program                                                          *
 ***************************************************************************/
int main(int argc, char *argv[])
{
  QApplication pfocusLogBrowser(argc, argv);  // log browser main application
  LBMainWindow mainWin(argc, argv);  // create the main window for the GUI
  mainWin.show();  // display the main window for the GUI application
  mainWin.raise(); // raises the window on top of the parent widget stack
  mainWin.activateWindow(); // activates the window an thereby putting it on top-level
  return pfocusLogBrowser.exec();  // exec the GUI application and terminate the current process
}
コード例 #7
0
ファイル: main.cpp プロジェクト: vermosen/fixedIncomeBacktest
int main (int argc, char *argv[]) {

	Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.yield.curve.analyser.client");

	mainWindow mainWin(1200, 1800);

	//Shows the window and returns when it is closed.
	return app->run(mainWin);

}
コード例 #8
0
ファイル: main.cpp プロジェクト: rimlester/Soundboard
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
    sf::SoundBuffer soundBuffers[NUM_COL][MAX_PER_COL];
    sf::Sound sounds[NUM_COL][MAX_PER_COL];
    sf::Image buttons[NUM_COL][MAX_PER_COL];
    sf::Sprite btns[NUM_COL][MAX_PER_COL];
    sf::RenderWindow mainWin(sf::VideoMode(W_WIDTH, W_HEIGHT, 32), "Soundboard - by eyeosk", sf::Style::Close);
    sf::Image background;
    sf::Image header;
    sf::Sprite bg;
    sf::Sprite hd;
    hd.SetY(0);
    hd.SetX(W_WIDTH/4);
    bg.SetX(0);
    bg.SetY(0);
    background.LoadFromFile("background.png");
    header.LoadFromFile("header.png");
    bg.SetImage(background);
    hd.SetImage(header);
    int numInCol[NUM_COL];
    for(int i = 0; i < NUM_COL; i++){
        loadBuffers(soundBuffers[i], i);
        numInCol[i] = loadImages(buttons[i], i);
        setSprites(buttons[i], btns[i], numInCol[i]);
        setBuffers(soundBuffers[i], sounds[i], numInCol[i]);
        setSpritesPos(btns[i], i, numInCol[i]);
    }
    mainWin.SetFramerateLimit(360);
    while(mainWin.IsOpened()){
        sf::Event mainEvent;
        while(mainWin.GetEvent(mainEvent)){
            if(mainEvent.Type == sf::Event::Closed  || (mainEvent.Type == sf::Event::KeyPressed && mainEvent.Key.Code == sf::Key::Escape)){
                mainWin.Close();
            }
            if(mainEvent.Type == sf::Event::MouseButtonPressed){
                for(int i = 0; i < NUM_COL; i++){
                    for(int j = 0; j < numInCol[i]; j++){
                        if(checktangle(i, j, mainEvent.MouseButton.X, mainEvent.MouseButton.Y)){
                            sounds[i][j].Play();
                        }
                    }
                }
            }
        }
        mainWin.Clear();
        mainWin.Draw(bg);
        mainWin.Draw(hd);
        for(int i =0; i < NUM_COL; i++){
            for(int j = 0; j < numInCol[i]; j++){
                mainWin.Draw(btns[i][j]);
            }
        }
        mainWin.Display();
    }
    return 0;
}
コード例 #9
0
ファイル: main.cpp プロジェクト: AhmedAMohamed/graphviz
int main(int argc, char *argv[])
{
    Q_INIT_RESOURCE(mdi);
    int ret;

    QApplication app(argc, argv);
    char **files = parseArgs(argc, argv);
    CMainWindow mainWin(&files);
    mainWin.show();
    ret = app.exec();
    return ret;
}
コード例 #10
0
ファイル: main.cpp プロジェクト: nholthaus/gtest-runner
int main(int argc, char *argv[])
{
	Q_INIT_RESOURCE(resources);

// Enable high-DPI scaling with Qt 5.6+
#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0))
	QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
	
	QApplication app(argc, argv);	
	app.setOrganizationName(APPINFO::organization);
	app.setOrganizationDomain(APPINFO::oranizationDomain);
	app.setApplicationName(APPINFO::name);
	app.setApplicationVersion(APPINFO::version);

	QCommandLineParser parser;

	QCommandLineOption addTestsOption(QStringList() << "a" << "add", "Add tests executables (comma separated)", "tests", "");
	QCommandLineOption resetOption(QStringList() << "r" << "reset", "Reset gtest-runner to it's original factory settings. This removes all tests and test data.");

	parser.setApplicationDescription("An automated test runner and user interface for google test unit tests.");
	auto helpOption = parser.addHelpOption();
	auto versionOption = parser.addVersionOption();
	parser.addOption(addTestsOption);
	parser.addOption(resetOption);
	
	parser.process(app);

	if (parser.isSet(helpOption))
	{
		parser.showHelp();
		exit(0);
	}

	if (parser.isSet(versionOption))
	{
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0))
		parser.showVersion();
#else
		qDebug() << "gtest-runner" << APPINFO::version;
#endif
		exit(0);
	}

	bool reset = parser.isSet(resetOption);
	QStringList tests = parser.value(addTestsOption).split(',');

	MainWindow mainWin(tests, reset);
	mainWin.show();
	return app.exec();
}
コード例 #11
0
ファイル: inviwo.cpp プロジェクト: Ojaswi/inviwo
int main(int argc, char** argv) {
    std::string basePath = inviwo::filesystem::findBasePath();

    inviwo::LogCentral::init();
    inviwo::LogCentral::getPtr()->registerLogger(new inviwo::FileLogger(basePath));
    inviwo::InviwoApplicationQt inviwoApp("Inviwo v" + IVW_VERSION, basePath, argc, argv);
    inviwoApp.setWindowIcon(QIcon(":/icons/inviwo_light.png"));
    inviwoApp.setAttribute(Qt::AA_NativeWindows);
    QFile styleSheetFile(":/stylesheets/inviwo.qss");
    styleSheetFile.open(QFile::ReadOnly);
    QString styleSheet = QString::fromUtf8(styleSheetFile.readAll());
    inviwoApp.setStyleSheet(styleSheet);
    styleSheetFile.close();

    inviwo::InviwoMainWindow mainWin(&inviwoApp);
    // setup core application
    inviwoApp.setMainWindow(&mainWin);
    // initialize and show splash screen
    inviwo::InviwoSplashScreen splashScreen(
        &mainWin, inviwoApp.getCommandLineParser()->getShowSplashScreen());
    inviwoApp.setProgressCallback([&splashScreen](std::string s){splashScreen.showMessage(s);});

    splashScreen.show();
    splashScreen.showMessage("Loading application...");
    
    // Initialize application and register modules
    splashScreen.showMessage("Initializing modules...");
    inviwoApp.initialize(&inviwo::registerAllModules);
    inviwoApp.processEvents();
    // setup main window
    mainWin.initialize();
    inviwoApp.processEvents();
    splashScreen.showMessage("Loading workspace...");
    inviwoApp.processEvents();
    mainWin.showWindow();
    inviwoApp.processEvents();    // Make sure the gui is done loading before loading workspace
    mainWin.openLastWorkspace();  // open last workspace
    splashScreen.finish(&mainWin);

#if defined(REG_INVIWOUNITTESTSMODULE) && defined(IVW_RUN_UNITTEST_ON_STARTUP)
    inviwo::UnitTestsModule::runAllTests();
#endif

    // process last arguments
    if (mainWin.processCommandLineArgs()) {
        return inviwoApp.exec();
    } else {
        mainWin.exitInviwo();
        return 0;
    }
}
コード例 #12
0
ファイル: main.cpp プロジェクト: inequation/particlasm
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QMap<QString, QSize> customSizeHints = parseCustomSizeHints(argc, argv);
    MainWindow mainWin(customSizeHints);
    mainWin.resize(800, 600);
    mainWin.show();
    while (mainWin.isVisible()) {
		app.processEvents();
		app.sendPostedEvents();
    }
    //return app.exec();
    return 0;
}
コード例 #13
0
int main( int argc, char *argv[] )
{
    QApplication app( argc, argv );

    QCoreApplication::setOrganizationDomain( "OrgDomain" );
	QCoreApplication::setOrganizationName( "OrgName" );
	QCoreApplication::setApplicationName( "Fibernavigator 2" );
	QCoreApplication::setApplicationVersion( "1.0.0" );

    Q_INIT_RESOURCE( resources );

    QStringList args = app.arguments();

    qInstallMsgHandler( noOutput );
    bool debug = false;
    for ( int i = 1; i < args.size(); ++i )
    {
        if ( args.at( i ) == "-v" )
        {
            verbose = true;
        }
        if ( args.at( i ) == "-d" )
        {
            debug = true;
        }
        if ( args.at( i ) == "-l" )
        {
            logToFile = true;
        }
    }
    out = new QTextStream( stdout );
    qInstallMsgHandler( logOutput );

#ifdef __DEBUG__
    debug = true;
#endif

    Models::init();

    MainWindow mainWin( debug );
    mainWin.show();

    for ( int i = 1; i < args.size(); ++i )
    {
        mainWin.load( args.at( i ) );
    }

    return app.exec();
}
コード例 #14
0
ファイル: qtapp.cpp プロジェクト: sigurdstorve/supersplines
// A simple Qt application containing a single QwtPlot to plot a curve
// Simple least squares spline function approximation to CSV time signal.
int main(int argc, char** argv) {
    QApplication app(argc, argv);
    
    if (argc != 2) {
        std::cout << "Usage: " << argv[0] << " <csv file>\n";
        exit(0);
    }
    
    std::cout << "Qt version: ";
    std::cout << QT_VERSION_STR << std::endl;

    MyMainWindow mainWin(argv[1]);
    
    return app.exec();
}
コード例 #15
0
ファイル: qt4Main.cpp プロジェクト: matoilic/ardoor
/*!
The main procedure holding the Qt application instance as well as the main
window instance of our class qt4MainWindow.
*/
int main(int argc, char *argv[])
{  
   // main Qt application instance
   QApplication app(argc, argv);
   
   // add plugins folder to the library path
   app.addLibraryPath(app.applicationDirPath() + "/plugins");
   
   // create one main window and show it
   qt4MainWindow mainWin(argc, argv);
   mainWin.show();
   
   // let's rock ...
   return app.exec();
}
コード例 #16
0
int main(int argc, char* argv[]) {
    Q_INIT_RESOURCE(DriverStationDisplay);

    QApplication app(argc, argv);
    app.setOrganizationName("FRC Team 3512");
    app.setApplicationName("DriverStationDisplay");

    QRect screenDims = QApplication::desktop()->screenGeometry();

    MainWindow mainWin(screenDims.width(), screenDims.height() - 240);
    mainWin.setWindowIcon(QIcon(":/images/Spartatroniks.ico"));
    mainWin.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
    mainWin.show();

    return app.exec();
}
コード例 #17
0
ファイル: main.cpp プロジェクト: PeteBoucher/sonic-pi
int main(int argc, char *argv[])
{
        Q_INIT_RESOURCE(application);

    QApplication app(argc, argv);
    app.setStyle("gtk");
    QPixmap pixmap(":/images/splash.png");
    QSplashScreen splash(pixmap);
    splash.setMask(pixmap.mask());
    splash.show();
    splash.repaint();

    //    QIcon icon(":images/app.icns");
    MainWindow mainWin(app, splash);

    //    mainWin.setWindowIcon(icon);
    return app.exec();
}
コード例 #18
0
ファイル: main.cpp プロジェクト: charliedurrant/sonic-pi
int main(int argc, char *argv[])
{
  // Q_INIT_RESOURCE(application);

  QApplication app(argc, argv);
  app.setApplicationName("Sonic Pi");
  app.setStyle("gtk");

#ifdef Q_OS_MAC
  app.setAttribute( Qt::AA_UseHighDpiPixmaps );
#endif

  QMainWindow* splashWindow = new QMainWindow(0, Qt::FramelessWindowHint);
  QLabel* imageLabel = new QLabel();

  splashWindow->setAttribute( Qt::WA_TranslucentBackground);

#ifdef Q_OS_MAC
  QPixmap image(":/images/[email protected]");
  imageLabel->setPixmap(image);
  splashWindow->setCentralWidget(imageLabel);
  splashWindow->setMinimumHeight(image.height()/2);
  splashWindow->setMaximumHeight(image.height()/2);
  splashWindow->setMinimumWidth(image.width()/2);
  splashWindow->setMaximumWidth(image.width()/2);
  sleep(3);
#else
  QPixmap image(":/images/splash.png");
  imageLabel->setPixmap(image);
  splashWindow->setCentralWidget(imageLabel);
  splashWindow->setMinimumHeight(image.height());
  splashWindow->setMaximumHeight(image.height());
  splashWindow->setMinimumWidth(image.width());
  splashWindow->setMaximumWidth(image.width());
  QIcon icon(":images/app.icns");
  mainWin.setWindowIcon(icon);
#endif

  splashWindow->raise();
  splashWindow->show();
  MainWindow mainWin(app, splashWindow);
  return app.exec();
}
コード例 #19
0
ファイル: main.cpp プロジェクト: asctec-andre/ssl-vision
int main(int argc, char *argv[])
{
  signal(SIGINT,HandleStop);
  QApplication app(argc, argv);

  GetOpt opts(argc, argv);
  bool help=false;
  bool start=false;
  bool enforce_affinity=false;
  int ecode=0;
  opts.addSwitch("help",&help);
  opts.addShortOptSwitch( 'a',QString("Enforce Processor Affinity"),&enforce_affinity, false);
  opts.addShortOptSwitch( 's',QString("Start Capturing Immediately"),&start, false);
  if (!opts.parse()) {
    fprintf(stderr,"Invalid command line parameters!\n");
    help=true;
    ecode=1;
  }

  if (help) {
    printf("SSL-Vision command line options:\n");
    printf(" -s        Start capture immediately\n");
    printf(" -a        Set Processor Affinity\n");
    printf(" --help    Show this help\n");
    exit(ecode);
  }

  printPathWarning();

  MainWindow mainWin(start, enforce_affinity);
  mainWinPtr = &mainWin;
  //if desired, launch a particular style:
  // app.setStyle(new QPlastiqueStyle());
  // app.setStyle(new QCleanlooksStyle());
  mainWin.show();
  mainWin.init();

  int retval = app.exec();

  return retval;
}
コード例 #20
0
ファイル: Main.cpp プロジェクト: TLCasella/FractureUtility
//FLTK Callbacks
int main(int argc, char *argv[]) {
    ShaderBindings::Initialize();
    GetTaskManager().AddThread(ThreadName::Main, std::this_thread::get_id());
    // create FLTK window:
    if (argc == 1)
    {
        MainWindow mainWin(Global::WindowWidth, Global::WindowHeight, "Fracture Map Utility Application");
        Global::gMainWindow = &mainWin;
        mainWin.resizable(mainWin);
        mainWin.show(argc,argv); // glut will die unless parent window visible

        Fl::first_window(&mainWin);
        Fl::grab(mainWin);
        Fl::grab(0);

        return Fl::run();
    }
    else if (argc == 3)
    {
        FractureScene scene;
        MainWindowDummy windowDummy;
        Global::gMainWindow = &windowDummy;

        scene.NewFractureObject(argv[1]);
        while(Global::IsResourceLoading()) { }
        scene.LoadFractureMap(argv[2]);
        while(Global::IsResourceLoading()) { }
        scene.FractureMesh();
        while(Global::IsResourceLoading())
        {
            GetTaskManager().RunThreadTasks();
        }
        return EXIT_SUCCESS;
    }
    else
    {
        std::cout << "Invalid number of arguments." << std::endl;
        return EXIT_FAILURE;
    }
}
コード例 #21
0
ファイル: main.cpp プロジェクト: Voral/qtDbf
int main(int argc, char *argv[])
{
    Q_INIT_RESOURCE(qtDbf);

    QApplication app(argc, argv);

    QSettings settings("voral", "qtDbf");
    QString dbfLocal = settings.value("dbflocal", QLocale::system().name().left(2)).toString();

    QCoreApplication::setOrganizationName("voral"); // was Hevele-Hegyi-Istvan
    QCoreApplication::setOrganizationDomain("va-soft.ru"); // was hevele.juniorcom.ro
    QCoreApplication::setApplicationName("qtDbf");

    QTranslator translator;
    if (dbfLocal.compare("en"))
    {
        QString dbfDirPath="";

#ifdef Q_OS_UNIX
        if (QFile::exists("/usr/local/share/qtdbf/"))
        {
            dbfDirPath = "/usr/local/share/qtdbf/";
        }
        else
        {
            if (QFile::exists("/usr/share/qtdbf/"))
            {
                dbfDirPath = "/usr/share/qtdbf/";
            }
            else
            {
                dbfDirPath = app.applicationDirPath();
            }
        }
#else
        dbfDirPath = app.applicationDirPath();
#endif
        dbfDirPath += "/lang/qtdbf_";
        dbfDirPath += dbfLocal;
        dbfDirPath += ".qm";

        QFileInfo f(dbfDirPath);
        if (f.exists())
        {
            translator.load(dbfDirPath);
            app.installTranslator(&translator);
        }
    }
    QFont dbfFont("Verdana", 10, QFont::Normal);

    QApplication::setFont(dbfFont);
    {
        QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "dbfEditor");
        db.setDatabaseName(":memory:");
        db.open();
        if (db.lastError().isValid())
           {
            QMessageBox::critical(0, QObject::tr("Error"), db.lastError().text());
            return 2;
           }
    }

    QString dbfFileName;
    if (app.arguments().count()>1) dbfFileName +=app.arguments().at(1);

    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

    if (dbfFileName.isEmpty())
        {
            QString currentDirectory;
            QSettings settings;
            currentDirectory= settings.value("dbfeditor/currentdir", "./").toString();

            dbfFileName = QFileDialog::getOpenFileName(0, QObject::tr("Open File"),currentDirectory,"DBF Files(*.dbf);;All Files (*)");
            if (dbfFileName.isEmpty())
            {
                return 1;
            }

            QFileInfo fileInfo(dbfFileName);
            currentDirectory = fileInfo.absolutePath();
            settings.setValue("dbfeditor/currentdir", currentDirectory);
        }
    MainWindow mainWin(dbfFileName);
    mainWin.show();
    int result = app.exec();
    QSqlDatabase::removeDatabase("dbfEditor");
    return result;
}
コード例 #22
0
ファイル: main.cpp プロジェクト: andreaswatch/dizuo
///////////////////////////////////////////////////////////////////////////////
// main function of a windows application
///////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdArgs, int cmdShow)
{
    // register UpDown control from comctl32.dll brfore creating windows
    INITCOMMONCONTROLSEX commonCtrls;
    commonCtrls.dwSize = sizeof(commonCtrls);
    commonCtrls.dwICC = ICC_UPDOWN_CLASS;
    ::InitCommonControlsEx(&commonCtrls);

    // create model and view components for controllers
    ModelGL modelGL;
    Win::ViewGL viewGL;
    Win::ViewFormGL viewFormGL(&modelGL);

    // create main window
    Win::ControllerMain mainCtrl;
    Win::Window mainWin(hInst, L"OpenGL Projection Matrix", 0, &mainCtrl);
    mainWin.setMenuName(MAKEINTRESOURCE(IDR_MENU_MAIN));
    mainWin.setWindowStyleEx(WS_EX_WINDOWEDGE);
    if(mainWin.create())
        Win::log("Main window is created.");
    else
        Win::log("[ERROR] Failed to create main window.");

    // create OpenGL rendering window as a child
    Win::ControllerGL glCtrl(&modelGL, &viewGL);
    Win::Window glWin(hInst, L"WindowGL", mainWin.getHandle(), &glCtrl);
    glWin.setClassStyle(CS_OWNDC);
    glWin.setWindowStyle(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
    glWin.setWidth(300);
    glWin.setHeight(600);
    if(glWin.create())
        Win::log("OpenGL child window is created.");
    else
        Win::log("[ERROR] Failed to create OpenGL window.");

    // create a child dialog box contains controls
    Win::ControllerFormGL formCtrl(&modelGL, &viewFormGL);
    Win::DialogWindow glDialog(hInst, IDD_FORMVIEW, mainWin.getHandle(), &formCtrl);
    glDialog.setWidth(300);
    glDialog.setHeight(600);
    if(glDialog.create())
        Win::log("OpenGL form dialog is created.");
    else
        Win::log("[ERROR] Failed to create OpenGL form dialog.");

    // place windows in the right position ================
    const int GL_WIDTH = 300;
    const int GL_HEIGHT = 600;
    const int DIALOG_WIDTH = 365;
    int winWidth;
    int winHeight;

    RECT rect = {0, 0, GL_WIDTH, GL_HEIGHT};                            // exact client size for OpenGL display, 300x600
    DWORD style = ::GetWindowLong(glWin.getHandle(), GWL_STYLE);        // get current window style
    DWORD styleEx = ::GetWindowLong(glWin.getHandle(), GWL_EXSTYLE);    // get current extended window style

    // adjust window size of glWin because camera display should have 300x600 client area
    // It modifies rect struct.
    ::AdjustWindowRectEx(&rect, style, FALSE, styleEx);
    winWidth = rect.right - rect.left;
    winHeight = rect.bottom - rect.top;

    // set glWin first with adjusted window size
    ::SetWindowPos(glWin.getHandle(), 0, 0, 0, winWidth, winHeight, SWP_NOZORDER);

    // set glDialog
    ::SetWindowPos(glDialog.getHandle(), 0, winWidth, 0, DIALOG_WIDTH, winHeight, SWP_NOZORDER);

    // compute window width and height
    winWidth = (rect.right - rect.left) + DIALOG_WIDTH;
    winHeight = rect.bottom - rect.top;

    // set mainWin
    rect.left = 0;
    rect.right = winWidth;
    rect.top = 0;
    rect.bottom = winHeight;
    style = ::GetWindowLong(mainWin.getHandle(), GWL_STYLE);
    styleEx = ::GetWindowLong(mainWin.getHandle(), GWL_EXSTYLE);
    ::AdjustWindowRectEx(&rect, style, TRUE, styleEx);
    ::SetWindowPos(mainWin.getHandle(), 0, 0, 0, (rect.right-rect.left), (rect.bottom-rect.top), SWP_NOZORDER);

    // show all windows
    glWin.show();
    glDialog.show();
    mainWin.show();


    // main message loop //////////////////////////////////////////////////////
    int exitCode;
    HACCEL hAccelTable = 0;
    //hAccelTable = ::LoadAccelerators(hInst, MAKEINTRESOURCE(ID_ACCEL));
    exitCode = mainMessageLoop(hAccelTable);

    Win::log("Application is terminated.");
    return exitCode;
}
コード例 #23
0
int GuiLoader::openGUI(int argc, char *argv[]) {

	QManagedApplication a(argc, argv);

	QMessageBox msgBox;

	std::string lockFilePath = ColorKeeperModel::getLockFilePath("lock");
	LockServer server;
	if (!server.isServerUp() ) {
		msgBox.setText(
				"ColorKeeper is already running (have a look in your sys tray).<br>If you're sure ColorKeeper isn't running (may happen in case of session crash),<br>you'll find some help in the <a href=https://sites.google.com/a/mikrosimage.eu/colortribe/trouble-shootings>trouble-shootings section on ColorTribe web site. ");
		msgBox.exec();
		exit(1);
	}
	QFile lockFile(QString::fromStdString(lockFilePath));
	if (lockFile.open(QIODevice::WriteOnly))
		lockFile.close();
	ColorKeeperModel::shouldDelete = true;

	if (!QSystemTrayIcon::isSystemTrayAvailable()) {
		msgBox.setText(
				"I couldn't detect any system tray and ColorKeeper needs one.<br>Please check if you didn't remove it.<br>You'll find some help in the <a href=https://sites.google.com/a/mikrosimage.eu/colortribe/trouble-shootings>trouble-shootings section on ColorTribe web site</a>.");
		msgBox.exec();
		exit(1);
	}

	QApplication::setQuitOnLastWindowClosed(false);
	QPixmap pixmap("./img/splash.png");
	QSplashScreen splash(pixmap);
	splash.show();
	QString message = "Version ";
	message.append(QString::number(ColorKeeperModel::version_major));
	message.append(QString(ColorKeeperModel::version_minor.c_str()));

	splash.showMessage(message, Qt::AlignBottom | Qt::AlignLeft, QColor(255,
			255, 255));

	QKeeperMainWindow mainWin(a);

	a.processEvents();

#ifdef __APPLE__
	QFile file("style/macOSStyle.qss");
#else
	QFile file("style/style.qss");
#endif
	if (file.open(QIODevice::ReadOnly)) {
		// Applique la CSS a la fenetre Qt
		QString styleSheet = QLatin1String(file.readAll());
		a.setStyleSheet(styleSheet);
		mainWin.setStyleSheet(styleSheet);
		file.close();
	}

	//mainWin.show();
	splash.finish(&mainWin);

	QCoreApplication::setOrganizationName("HD3D");
	QCoreApplication::setApplicationName("ColorKeeper");

	//	QString path = QCoreApplication::applicationDirPath() ;
	//	path.append("/../PlugIns");
	//QCoreApplication::addLibraryPath(path);
	//QCoreApplicatop,

	_isLoaded = true;

	ColorKeeperModel::Instance().sendAMailCalibrationRequest();
	return a.exec();

}
コード例 #24
0
ファイル: inviwo.cpp プロジェクト: ResearchDaniel/inviwo
int main(int argc, char** argv) {
    std::string basePath = inviwo::filesystem::findBasePath();

    inviwo::LogCentral::init();
    auto filelogger = std::make_shared<inviwo::FileLogger>(basePath);
    inviwo::LogCentral::getPtr()->registerLogger(filelogger);
    inviwo::InviwoApplicationQt inviwoApp("Inviwo v" + IVW_VERSION, argc, argv);
    inviwoApp.setWindowIcon(QIcon(":/icons/inviwo_light.png"));
    inviwoApp.setAttribute(Qt::AA_NativeWindows);
    QFile styleSheetFile(":/stylesheets/inviwo.qss");
    styleSheetFile.open(QFile::ReadOnly);
    QString styleSheet = QString::fromUtf8(styleSheetFile.readAll());
    inviwoApp.setStyleSheet(styleSheet);
    styleSheetFile.close();

    auto& clp = inviwoApp.getCommandLineParser();

    inviwo::InviwoMainWindow mainWin(&inviwoApp);
    // setup core application
    inviwoApp.setMainWindow(&mainWin);
    // initialize and show splash screen
    inviwo::InviwoSplashScreen splashScreen(&mainWin, clp.getShowSplashScreen());
    inviwoApp.setProgressCallback([&splashScreen](std::string s) { splashScreen.showMessage(s); });

    splashScreen.show();
    splashScreen.showMessage("Loading application...");

    // Initialize application and register modules
    splashScreen.showMessage("Initializing modules...");
    inviwoApp.registerModules(&inviwo::registerAllModules);
    inviwoApp.processEvents();

    // Do this after registerModules if some arguments were added
    clp.parse(inviwo::CommandLineParser::Mode::Normal);

    // setup main window
    mainWin.initialize();
    inviwoApp.processEvents();
    splashScreen.showMessage("Loading workspace...");
    inviwoApp.processEvents();
    mainWin.showWindow();
    inviwoApp.processEvents();  // Make sure the gui is done loading before loading workspace

    mainWin.openLastWorkspace(clp.getWorkspacePath());  // open last workspace
    splashScreen.finish(&mainWin);

    inviwoApp.processEvents();
    clp.processCallbacks(); // run any command line callbacks from modules.
    inviwoApp.processEvents();

    inviwo::util::OnScopeExit clearNetwork([&](){
        inviwoApp.getProcessorNetwork()->clear();
    });

    // process last arguments
    if (!clp.getQuitApplicationAfterStartup()) {
        return inviwoApp.exec();
    }
    else {
        mainWin.exitInviwo(false);
        return 0;
    }
}
コード例 #25
0
ファイル: main.cpp プロジェクト: LI-COR/eddypro-gui
/// \fn int main(int argc, char *argv[])
/// \brief Entry point of the application.
///
/// \file main.cpp
/// \brief Entry point for the GUI application
///
/// This file contains main().
///////////////////
/// \brief main
/// \param argc
/// \param argv
/// \return
///
int main(int argc, char *argv[])
{
#if QT_DEBUG
    // logger creation
#endif

    // initialize resources at startup (qrc file loading)
#if defined(Q_OS_MAC)
    Q_INIT_RESOURCE(eddypro_mac);
#elif defined(Q_OS_WIN)
    Q_INIT_RESOURCE(eddypro_win);
#else
    Q_INIT_RESOURCE(eddypro_lin);
#endif

    qApp->setAttribute(Qt::AA_UseHighDpiPixmaps);

#if defined(Q_OS_MAC)
    qApp->setAttribute(Qt::AA_DontShowIconsInMenus);

    // workaround necessary in case of widget painting issues
//    qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#endif

    QApplication::setColorSpec(QApplication::ManyColor);
//    QApplication::setDesktopSettingsAware(false);

    QApplication::setEffectEnabled(Qt::UI_AnimateMenu);
    QApplication::setEffectEnabled(Qt::UI_FadeMenu);
    QApplication::setEffectEnabled(Qt::UI_AnimateCombo);
    QApplication::setEffectEnabled(Qt::UI_AnimateTooltip);
    QApplication::setEffectEnabled(Qt::UI_FadeTooltip);

    ///
    /// A set of flags to workaroud issues in specific cases
    ///
    //  QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
    QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
    //  QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
    //  QCoreApplication::setAttribute(Qt::AA_ForceRasterWidgets);
    //  QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
    //  QCoreApplication::setAttribute(Qt::AA_SetPalette);
    //  QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);

    QApplication app(argc, argv);
    app.setApplicationName(Defs::APP_NAME);
    app.setApplicationDisplayName(Defs::APP_NAME);
    app.setOrganizationName(Defs::ORG_NAME);
    app.setOrganizationDomain(Defs::ORG_DOMAIN);

    qDebug() << "currentUnicodeVersion" << QChar::currentUnicodeVersion();

    // fix order of library paths
    // see https://bugreports.qt-project.org/browse/QTBUG-40738
    QString executable = QLatin1String(argv[0]);
    QtHelper::prependApplicationPathToLibraryPaths(executable);
    qDebug() << "library paths" << QApplication::libraryPaths();

#if defined(Q_OS_MAC)
    // file to open at start
    auto fileToOpen = QString();
    // install event filter to open clicked files in Mac OS X
    OpenFileFilter openFileFilter;
    app.installEventFilter(&openFileFilter);
    app.processEvents();
    auto requestedFile = openFileFilter.fileRequested();
    if (requestedFile.endsWith(QStringLiteral(".eddypro")))
    {
        fileToOpen = requestedFile;
    }
#endif

    // custom ttf setup
    int fontId_1 = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fonts/OpenSans-Regular.ttf"));
    Q_ASSERT(fontId_1 != -1);
    qDebug() << QFontDatabase::applicationFontFamilies(fontId_1);
    int fontId_2 = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fonts/OpenSans-Italic.ttf"));
    Q_ASSERT(fontId_2 != -1);
    qDebug() << QFontDatabase::applicationFontFamilies(fontId_2);
    int fontId_3 = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fonts/OpenSans-Bold.ttf"));
    Q_ASSERT(fontId_3 != -1);
    qDebug() << QFontDatabase::applicationFontFamilies(fontId_3);
    int fontId_4 = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fonts/OpenSans-Semibold.ttf"));
    Q_ASSERT(fontId_4 != -1);
    qDebug() << QFontDatabase::applicationFontFamilies(fontId_4);
    int fontId_5 = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/fonts/OpenSans-BoldItalic.ttf"));
    Q_ASSERT(fontId_5 != -1);
    qDebug() << QFontDatabase::applicationFontFamilies(fontId_5);

    // load translation file embedded in resources
    QTranslator appTranslator;
    bool ok = appTranslator.load(QStringLiteral(":/tra/en"));
    qDebug() << "loading translation:" << ok;
    app.installTranslator(&appTranslator);

    // working dir
    QDir dir = QDir::current();
    qDebug() << "current dir" << dir.absolutePath();

    QString currentWorkingDir = QDir::currentPath();
    QString installationDir = qApp->applicationDirPath();
    qDebug() << "currentWorkingDir" << currentWorkingDir;
    qDebug() << "installationDir" << installationDir;
    if (currentWorkingDir != installationDir)
    {
        QDir::setCurrent(installationDir);
    }
    qDebug() << "currentWorkingDir" << QDir::currentPath();
    qDebug() << "currentWorkingDir" << QCoreApplication::applicationDirPath();

    // styles
    qDebug() << "------------------------------------------------------------";
    qDebug() << "Default Style: " << app.style()->metaObject()->className();

    MyStyle myStyle(app.style()->objectName());
    app.setStyle(&myStyle);

#if defined(Q_OS_WIN)
    FileUtils::loadStyleSheetFile(QStringLiteral(":/css/winstyle"));
#elif defined(Q_OS_MAC)
    FileUtils::loadStyleSheetFile(QStringLiteral(":/css/macstyle"));
#elif defined(Q_OS_LINUX)
    FileUtils::loadStyleSheetFile(QStringLiteral(":/css/linstyle"));
#endif

    QString appEnvPath = FileUtils::setupEnv();
    if (appEnvPath.isEmpty())
    {
        WidgetUtils::critical(nullptr,
                              QObject::tr("Cannot proceed"),
                              QObject::tr("Home Path not available."));
        return 1000;
    }
    qDebug() << "appEnvPath" << appEnvPath;

    // check for command line arguments
    QTextStream stream(stdout);

//#ifdef QT_DEBUG
//    bool getLogFile = true;
//#else
    bool getLogFile = false;
//#endif
    QString filename = doArgs(app.arguments(), stream, &getLogFile);
    qDebug() << "filename:" << filename;
    qDebug() << "getLogFile:" << getLogFile;

#if defined(Q_OS_MAC)
    if (!fileToOpen.isEmpty())
    {
        filename = fileToOpen;
    }
#endif

    // log file
    QFile logFile(appEnvPath
                  + QLatin1Char('/')
                  + Defs::LOG_FILE_DIR
                  + QLatin1Char('/')
                  + Defs::APP_NAME_LCASE
                  + QStringLiteral("_gui.")
                  + Defs::LOG_FILE_EXT);
    if (getLogFile)
    {
        if (logFile.size() > 1048576)
            logFile.remove();

        if (logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
        {
            outputStream = new QTextStream(&logFile);
            QtMessageHandler oldMsgHandler(qInstallMessageHandler(logOutput));
            Q_UNUSED(oldMsgHandler);
        }
        else
        {
            qDebug() << "Error opening logFile file '" << Defs::APP_NAME_LCASE
                     << "'. All debug output redirected to console.";
        }
    }

    // create and show splash screen
    QPixmap pixmap(QStringLiteral(":/icons/splash-img"));
#if defined(Q_OS_MAC)
    pixmap.setDevicePixelRatio(2.0);
#endif
    CustomSplashScreen splash(pixmap, Qt::WindowStaysOnTopHint);
    auto show_splash =
        GlobalSettings::getFirstAppPersistentSettings(Defs::CONFGROUP_GENERAL,
                                                      Defs::CONF_GEN_SHOW_SPLASH,
                                                      true).toBool();

#if defined(Q_OS_MAC)
    auto is_full_screen_set =
        GlobalSettings::getFirstAppPersistentSettings(Defs::CONFGROUP_WINDOW,
                                                      Defs::CONF_WIN_FULLSCREEN,
                                                      true).toBool();
    if (is_full_screen_set)
    {
        show_splash = false;
    }
#endif
    qDebug() << "show_splash:" << show_splash;

    if (show_splash)
    {
        QFont splashFont;
        splashFont.setFamily(QStringLiteral("Open Sans"));
        splashFont.setBold(false);
        splashFont.setPixelSize(12);

        splash.setFont(splashFont);
        splash.setMessageRect(QRect(0, 427, 600, 25), Qt::AlignCenter); // Setting the message position.
        splash.show();
        splash.showStatusMessage(QObject::tr("Initializing..."));
    }
    qApp->processEvents();

    QLocale::setDefault(QLocale::C);

    if (show_splash)
    {
        splash.showStatusMessage(QObject::tr("Loading..."));
        splash.setProgressValue(20);
        splash.setProgressValue(30);
        splash.repaint();
    }
    qApp->processEvents();

//#if defined(Q_OS_MAC)
//    MainWindow mainWin(filename, appEnvPath, &splash, 0,
//                       Qt::WindowFlags()
//                       Window|WindowTitleHint|WindowSystemMenuHint|WindowMinMaxButtonsHint|WindowCloseButtonHint|WindowFullscreenButtonHint
//                       Qt::Window | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint
//                       );
//#elif defined(Q_OS_WIN)
    MainWindow mainWin(filename, appEnvPath, &splash);
//#endif

    if (show_splash)
    {
        splash.setProgressValue(40);
        splash.setProgressValue(50);
        splash.setProgressValue(60);
    }
    mainWin.show();

    if (show_splash)
    {
        splash.setProgressValue(70);
        splash.setProgressValue(80);
        splash.clearMessage();
        splash.showStatusMessage(QObject::tr("Loading complete."));
        splash.setProgressValue(90);
        splash.setProgressValue(100);
        splash.repaint();
    }
//    qApp->processEvents();

    qDebug() << "applicationDisplayName" << qApp->applicationDisplayName();

#if defined(Q_OS_MAC)
    qDebug() << "____________________________________________________";
    auto docExtraction = extractDocs(installationDir);
    qDebug() << "docs.zip extraction:" << docExtraction;
    qDebug() << "____________________________________________________";
#endif
    qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++";

    const int returnVal = app.exec();

    // cleanup
//    if (logFile)
//    {
//        logFile->close();
//        delete logFile;
//    }

    if (outputStream)
    {
        delete outputStream;
    }

    return returnVal;
}
コード例 #26
0
ファイル: main.cpp プロジェクト: PappBence/q4wine
int main(int argc, char *argv[])
{
    QtSingleApplication app(argc, argv);
    QTextStream QErr(stderr);

    QString exec_binary;
    if (app.arguments().count()>2){
        if ((app.arguments().at(1)=="--binary") or (app.arguments().at(1)=="-b")){
            exec_binary = app.arguments().at(2);
            if (app.sendMessage(exec_binary))
                return 0;
        }
    }

    if (app.sendMessage(""))
        return 0;

    //! This is need for libq4wine-core.so import;
    typedef void *CoreLibPrototype (bool);
    CoreLibPrototype *CoreLibClassPointer;
    std::auto_ptr<corelib> CoreLib;
    QLibrary libq4wine;

    // Loading libq4wine-core.so
    libq4wine.setFileName("libq4wine-core");

    if (!libq4wine.load()){
        libq4wine.load();
    }

    // Getting corelib calss pointer
    CoreLibClassPointer = (CoreLibPrototype *) libq4wine.resolve("createCoreLib");
    CoreLib.reset((corelib *)CoreLibClassPointer(true));

    if (!CoreLib.get()){
        QErr<<"[EE] Can't load shared library."<<endl;
        return -1;
    }

    QTranslator qtt;

#ifdef RELEASE
    QString i18nPath = QString("%1/share/%2/i18n").arg(APP_PREF).arg(APP_SHORT_NAME);
#else
    QString i18nPath = QString("%1/i18n").arg(APP_BUILD);
#endif


    qtt.load(CoreLib->getTranslationLang(), i18nPath);
    app.installTranslator(&qtt);

    if (!CoreLib->checkDirs()){
        return -1;
    }

    DataBase db;

    if (!db.checkDb()){
        QErr<<"[EE] Can't init database engine."<<endl;
        return -1;
    }

    if (!CoreLib->isConfigured()){
        Wizard firstSetupWizard(1);
        if (firstSetupWizard.exec()==QDialog::Rejected){
            QErr<<"[EE] App not configured! Re run wizard, or delete q4wine broken config files."<<endl;
            return -1;
        }
    }

    QTextStream Qcout(stdout);
    int result, startState=0;

    if (app.arguments().count()>1){
        if ((app.arguments().at(1)=="--version") or (app.arguments().at(1)=="-v")){
            Qcout<<QString("%1 %2").arg(APP_SHORT_NAME).arg(APP_VERS)<<endl;
            Qcout<<QString("(Copyright (C) 2008-2009, brezblock core team.")<<endl;
            Qcout<<QString("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.")<<endl;
            Qcout<<QObject::tr("This is free software: you are free to change and redistribute it.")<<endl;
            Qcout<<QObject::tr("There is NO WARRANTY, to the extent permitted by law.")<<endl;
            CoreLib->getBuildFlags();
            Qcout<<QObject::tr("Author: %1.").arg("Malakhov Alexey aka John Brezerk")<<endl;
            return 0;
        } else if ((app.arguments().at(1)=="--minimize") or (app.arguments().at(1)=="-m")) {
            startState = 1;
        } else if ((app.arguments().at(1)=="--binary") or (app.arguments().at(1)=="-b")) {
            //startState = 1;
        } else {
            Qcout<<QObject::tr("Usage:")<<endl;
            Qcout<<QString("  %1 -b <unix_path_to_windown_binary>").arg(APP_SHORT_NAME)<<endl;
            Qcout<<QObject::tr("  %1 [KEY]...").arg(APP_SHORT_NAME)<<endl;
            Qcout<<QObject::tr("GUI utility for wine applications and prefixes management.")<<endl<<endl;
            Qcout<<QObject::tr("KEYs list:")<<endl;
            Qcout<<qSetFieldWidth(25)<<left<<"  -h,  --help"<<QObject::tr("display this help and exit")<<qSetFieldWidth(0)<<endl;
            Qcout<<qSetFieldWidth(25)<<left<<"  -v,  --version"<<QObject::tr("output version information and exit")<<qSetFieldWidth(0)<<endl;
            Qcout<<qSetFieldWidth(25)<<left<<"  -b,  --binary"<<QObject::tr("Open q4wine run dialog for windows binary")<<qSetFieldWidth(0)<<endl;
            Qcout<<qSetFieldWidth(25)<<left<<"  -m,  --minimize"<<QObject::tr("minimize %1 main window on startup").arg(APP_SHORT_NAME)<<qSetFieldWidth(0)<<endl;
            Qcout<<endl;
            Qcout<<QObject::tr("Report %1 bugs to %2").arg(APP_SHORT_NAME).arg(APP_BUG_EMAIL)<<endl;
            Qcout<<QObject::tr("%1 homepage: <%2>").arg(APP_SHORT_NAME).arg(APP_WEBSITTE)<<endl;
            Qcout<<QObject::tr("General help using GNU software: <http://www.gnu.org/gethelp/>")<<endl;
            return 0;
        }
    }

    MainWindow mainWin(startState, exec_binary);
    app.setActivationWindow(&mainWin);
    QObject::connect(&app, SIGNAL(messageReceived(const QString&)), &mainWin, SLOT(messageReceived(const QString&)));
    result = app.exec();
    db.close();
    return result;
}
コード例 #27
0
ファイル: main.cpp プロジェクト: wangfeilong321/vdpm
///////////////////////////////////////////////////////////////////////////////
// main function of a windows application
///////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdArgs, int cmdShow)
{
    // set log mode: FILE, DIALOG or BOTH
    //Win::logMode(Win::LOG_MODE_BOTH);
    Win::logMode(Win::LOG_MODE_FILE); // LOG_MODE_FILE is default

    // register slider(trackbar) from comctl32.dll brfore creating windows
    INITCOMMONCONTROLSEX commonCtrls;
    commonCtrls.dwSize = sizeof(commonCtrls);
    commonCtrls.dwICC = ICC_BAR_CLASSES;        // trackbar is in this class
    ::InitCommonControlsEx(&commonCtrls);

    // get app name from resource file
    wchar_t name[256];
    ::LoadString(hInst, IDS_APP_NAME, name, 256);

    Win::ControllerMain mainCtrl;
    Win::Window mainWin(hInst, name, 0, &mainCtrl);

    // add menu to window class
    mainWin.setMenuName(MAKEINTRESOURCE(IDR_MAIN_MENU));
    mainWin.setWidth(300);
    mainWin.setHeight(460);
    mainWin.setWindowStyleEx(WS_EX_WINDOWEDGE);

    // create a window and show
    if(mainWin.create())
        Win::log("Main window is created.");
    else
        Win::log("[ERROR] Failed to create main window.");

    // create model and view components for controller
    ModelGL modelGL;
    Win::ViewGL viewGL;
    Win::ViewFormGL viewFormGL;

    // create OpenGL rendering window as a child
    Win::ControllerGL glCtrl(&modelGL, &viewGL);
    Win::Window glWin(hInst, L"WindowGL", mainWin.getHandle(), &glCtrl);
    glWin.setClassStyle(CS_OWNDC);
    glWin.setWindowStyle(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
    glWin.setWidth(300);
    glWin.setHeight(300);
    if(glWin.create())
        Win::log("OpenGL window is created.");
    else
        Win::log("[ERROR] Failed to create OpenGL window.");

    // create a child dialog box contains controls
    Win::ControllerFormGL formCtrl(&modelGL, &viewFormGL);
    Win::DialogWindow glDialog(hInst, IDD_CONTROLS, mainWin.getHandle(), &formCtrl);
    glDialog.setWidth(300);
    glDialog.setHeight(160);
    if(glDialog.create())
        Win::log("OpenGL form dialog is created.");
    else
        Win::log("[ERROR] Failed to create OpenGL form dialog.");

    // create status bar window using CreateWindowEx()
    // mainWin must pass WM_SIZE message to the status bar
    // So, mainWin accesses the status bar with GetDlgItem(handle, IDC_STATUSBAR).
    HWND statusHandle = ::CreateWindowEx(0, STATUSCLASSNAME, 0, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
                                         0, 0, 0, 0, mainWin.getHandle(), (HMENU)IDC_STATUSBAR, ::GetModuleHandle(0), 0);
    if(statusHandle)
        Win::log("Status bar window is created.");
    else
        Win::log("[ERROR] Failed to create status bar window.");
    ::SendMessage(statusHandle, SB_SETTEXT, 0, (LPARAM)L"Ready");

    // send window handles to mainCtrl, they are used for resizing window
    mainCtrl.setGLHandle(glWin.getHandle());
    mainCtrl.setFormHandle(glDialog.getHandle());

    // place the opengl form dialog in right place, bottome of the opengl rendering window
    ::SetWindowPos(glDialog.getHandle(), 0, 0, 300, 300, 160, SWP_NOZORDER);

    // compute height of all sub-windows
    int height = 0;
    RECT rect;
    ::GetWindowRect(glWin.getHandle(), &rect);      // get size of glWin
    height += rect.bottom - rect.top;
    ::GetWindowRect(glDialog.getHandle(), &rect);   // get size of glDialog
    height += rect.bottom - rect.top;
    ::GetWindowRect(statusHandle, &rect);           // get size of status bar
    height += rect.bottom - rect.top;

    // resize main window, so all sub windows are fit into the client area of main window
    DWORD style = (DWORD)::GetWindowLongPtr(mainWin.getHandle(), GWL_STYLE);       // get current window style
    DWORD styleEx = (DWORD)::GetWindowLongPtr(mainWin.getHandle(), GWL_EXSTYLE);   // get current extended window style
    rect.left = 0;
    rect.right = 300;
    rect.top = 0;
    rect.bottom = height;
    ::AdjustWindowRectEx(&rect, style, TRUE, styleEx);
    ::SetWindowPos(mainWin.getHandle(), 0, 100, 100, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER);

    // show all windows
    glWin.show();
    glDialog.show();
    mainWin.show();
    //::SendMessage(mainWin.getHandle(), WM_NCPAINT, 1, 0);   // repaint window frame

    // main message loop //////////////////////////////////////////////////////
    int exitCode;
    HACCEL hAccelTable = 0;
    //hAccelTable = ::LoadAccelerators(hInst, MAKEINTRESOURCE(ID_ACCEL));
    exitCode = mainMessageLoop(hAccelTable);

    Win::log("Application terminated.");
    return exitCode;
}
コード例 #28
0
ファイル: main.cpp プロジェクト: zhenggao2/ltetoolset2
int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    //software license validation
    bool isValid = false;
    QString validTime;

//    QFile logFile("./output/decoded_str.lic");
//    logFile.open(QIODevice::Append);

    QFile file("./config/license.lic");
    if(!file.open(QIODevice::ReadOnly))
    {
        //logFile.write("Fail to open license file");
        return 1;
    }
    QByteArray bytes = file.readAll();
    file.close();

    file.setFileName("./config/decoded_license.lic");
    if(!file.open(QIODevice::ReadOnly))
    {
        //logFile.write("Fail to open decoded license file");
        return 1;
    }
    QByteArray bytesDecoded = file.readAll();
    file.close();

    QString hostName = QHostInfo::localHostName();
    QList<QNetworkInterface> ifList = QNetworkInterface::allInterfaces();
    for(QList<QNetworkInterface>::iterator it = ifList.begin(); it != ifList.end(); ++it)
    {
        QString hardwareName = it->hardwareAddress().replace(':', '-');

        QString magicNumber = "7F51";
        QString key1 = hardwareName + ";;" + hostName + ";;";
        key1 = magicNumber + key1;
        QString key2 = "61431749";

        QBitArray bits = bytesToBits(bytes);
        QBitArray bitsDecoded = bytesToBits(bytesDecoded);
        QBitArray bitsKey1 = bytesToBits(QByteArray::fromStdString(key1.toStdString()));
        QBitArray bitsKey2 = bytesToBits(QByteArray::fromStdString(key2.toStdString()));

        bits ^= bitsDecoded;
        bits ^= bitsKey2;
        bits ^= bitsKey1;
        QByteArray bytes2 = bitsToBytes(bits);
        validTime = QString::fromStdString(bytes2.toStdString()).mid(key1.size(), QString("yyyymmddhhmmss").size());    //already UTC timezone
        if(validTime.isNull() || validTime.size() < QString("yyyymmddhhmmss").size())
        {
            continue;
        }

        QDateTime dt = QDateTime::currentDateTimeUtc();
        QString curTime = dt.toString("yyyyMMddHHmmss");

        //1st check: time valid?
        bool timeValid = false;
        if(curTime < validTime)
        {
            timeValid = true;
        }

        //2nd check: license valid?
        bool licValid = true;
        for(int i = 0; i < bytes2.size(); ++i)
        {
            if(i >= key1.size() && i <= key1.size() + validTime.size() - 1)
            {
                continue;
            }
            else if(bytes2.at(i) != '\0')
            {
                licValid = false;
                break;
            }
        }

        if(timeValid && licValid)
        {
            isValid = true;

//            logFile.write("\n----------\n");
//            logFile.write(key1.toStdString().c_str());
//            logFile.write("\n");
//            logFile.write(bytes2);
//            logFile.write("\n");
//            logFile.write(validTime.toStdString().c_str());
//            logFile.write("\n----------\n");

            break;
        }
    }

//    logFile.close();

    LteMainWindow mainWin(validTime);
    if(isValid)
    {
        mainWin.show();
    }

    return app.exec();
}