int main(int argc, char *argv[]) { QApplication a(argc, argv); setupApplication(&a); QStringList arguments = a.arguments(); CommandLine::CmdLine cmd(arguments); if (cmd.needProcess()) { // if console mode switch (cmd.process()) { case CommandLine::CmdLine::ProcessResult::Failed: { return 1; } case CommandLine::CmdLine::ProcessResult::Success: { return 0; } case CommandLine::CmdLine::ProcessResult::None: default: { break; } } } // gui mode AppUI::MainWindow w; w.show(); return a.exec(); }
int main(int argc, char *argv[]) { qRegisterMetaTypeStreamOperators<SQProfile>("SQProfile"); QApplication a(argc, argv); setupApplication(a); QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption configFileOption("c", "specify configuration file.", "config.ini"); parser.addOption(configFileOption); parser.process(a); QString configFile = parser.value(configFileOption); if (configFile.isEmpty()) { #ifdef Q_OS_WIN configFile = a.applicationDirPath() + "/config.ini"; #else QDir configDir = QDir::homePath() + "/.config/shadowsocks-qt5"; configFile = configDir.absolutePath() + "/config.ini"; if (!configDir.exists()) { configDir.mkpath(configDir.absolutePath()); } #endif } ConfigHelper conf(configFile); MainWindow w(&conf); mainWindow = &w; if (conf.isOnlyOneInstance() && w.isInstanceRunning()) { return -1; } w.startAutoStartConnections(); if (!conf.isHideWindowOnStartup()) { w.show(); } return a.exec(); }
bool NerdBaseApplication::setUp() { mSeedCommunication = new SeedUDPCommunication(); setupApplication(); buildSimulationModel(); return true; }
int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, LPSTR lpszCmdLine, int nCmdShow) { openConsoleWindow(); HINSTANCE hinst = hCurrentInst; registerWindowsClass(hinst); setupApplication(); double avg_frame_time = 0.0; double next_frame_time=-1.0, last_frame_time=0.0; int frame_num = 0; ::ShowWindow( hwnd, SW_SHOW ); ::SetForegroundWindow( hwnd ); ::SetFocus( hwnd ); // do the draw/update/event loop MSG msg; bool quit = false; while(!quit) { if( ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { if(msg.message == WM_QUIT) { cleanupApplication(); poWindow *win = (poWindow*)GetWindowLongPtr(hwnd,GWL_USERDATA); delete win; cleanupWindow(); break; } ::TranslateMessage( &msg ); ::DispatchMessage( &msg ); } double now = getTiming(); if(now >= next_frame_time) { next_frame_time = now + 1.0 / 60.0; double dt = now - last_frame_time; poWindow *win = (poWindow*)GetWindowLongPtr(hwnd,GWL_USERDATA); if(win) { win->makeCurrent(); win->update(); win->draw(); } SwapBuffers(dc); frame_num++; last_frame_time = now; } else { Sleep(1); } } cleanupWindow(); #if defined WIN32 && defined _DEBUG //_CrtDumpMemoryLeaks(); #endif return msg.wParam; }