int main(int argc, char *argv[]){ QApplication a(argc, argv); QCoreApplication::setOrganizationName("ckb"); // Although the daemon runs as root, the GUI needn't and shouldn't be, as it has the potential to corrupt settings data. if(getuid() == 0){ printf("The ckb GUI should not be run as root.\n"); return 0; } // Seed the RNG for UsbIds qsrand(QDateTime::currentMSecsSinceEpoch()); #ifdef Q_OS_MACX disableAppNap(); #endif #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) // Enable HiDPI support qApp->setAttribute(Qt::AA_UseHighDpiPixmaps); #endif // If launched with --version, print version info and then quit if(qApp->arguments().contains("--version")){ printf("ckb %s\n", CKB_VERSION_STR); return 0; } // Kill existing app when launched with --close if(qApp->arguments().contains("--close")){ if(isRunning("Close")) printf("Asking existing instance to close.\n"); else printf("ckb is not running.\n"); return 0; } // Launch in background if requested, or if re-launching a previous session bool background = qApp->arguments().contains("--background") || qApp->arguments().contains("-session") || qApp->arguments().contains("--session"); if(isRunning(background ? 0 : "Open")){ printf("ckb is already running. Exiting.\n"); return 0; } MainWindow w; if(!background) w.show(); return a.exec(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); if(isRunning()) return 0; #ifdef __APPLE__ disableAppNap(); #endif #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) // Enable HiDPI support qApp->setAttribute(Qt::AA_UseHighDpiPixmaps); #endif MainWindow w; if(!qApp->arguments().contains("--background")) w.show(); return a.exec(); }
int main(int argc, char *argv[]){ QApplication a(argc, argv); QCoreApplication::setOrganizationName("ckb"); // Seed the RNG for UsbIds qsrand(QDateTime::currentMSecsSinceEpoch()); #ifdef Q_OS_MACX disableAppNap(); #endif #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) // Enable HiDPI support qApp->setAttribute(Qt::AA_UseHighDpiPixmaps); #endif // If launched with --version, print version info and then quit if(qApp->arguments().contains("--version")){ printf("ckb %s\n", CKB_VERSION_STR); return 0; } // Kill existing app when launched with --close if(qApp->arguments().contains("--close")){ if(isRunning("Close")) printf("Asking existing instance to close.\n"); else printf("ckb is not running.\n"); return 0; } // Launch in background if requested bool background = qApp->arguments().contains("--background"); if(isRunning(background ? 0 : "Open")){ printf("ckb is already running. Exiting.\n"); return 0; } MainWindow w; if(!background) w.show(); return a.exec(); }