int main(int argc, char *argv[]) #endif { #ifndef LITEAPP_LIBRARY #if defined(_MSC_VER) && defined(_DEBUG) _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); #endif #endif QApplication app(argc, argv); #if QT_VERSION >= 0x050100 app.setAttribute(Qt::AA_UseHighDpiPixmaps); #endif //QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); QTranslator translator; QTranslator qtTranslator; QString resPath = LiteApp::getResoucePath(); QString locale = QLocale::system().name(); QString qss; QSettings global(resPath+"/liteapp/config/global.ini",QSettings::IniFormat); bool storeLocal = global.value(LITEIDE_STORELOCAL,false).toBool(); if (storeLocal) { const QSettings settings(resPath+"/liteapp/config/liteide.ini", QSettings::IniFormat); locale = settings.value(LITEAPP_LANGUAGE,locale).toString(); qss = settings.value(LITEAPP_QSS,"default.qss").toString(); } else { const QSettings settings(QSettings::IniFormat,QSettings::UserScope,"liteide","liteide"); locale = settings.value(LITEAPP_LANGUAGE,locale).toString(); qss = settings.value(LITEAPP_QSS,"default.qss").toString(); } if (!locale.isEmpty()) { const QString &liteideTrPath = resPath+"/translations"; if (translator.load(QLatin1String("liteide_") + locale, liteideTrPath)) { const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); const QString &qtTrFile = QLatin1String("qt_") + locale; // Binary installer puts Qt tr files into creatorTrPath app.installTranslator(&translator); if (qtTranslator.load(qtTrFile, qtTrPath) || qtTranslator.load(qtTrFile, liteideTrPath)) { app.installTranslator(&qtTranslator); } app.setProperty("liteide_locale", locale); } } if (!qss.isEmpty()) { QFile f(resPath+"/liteapp/qss/"+qss); if (f.open(QFile::ReadOnly)) { QString styleSheet = QLatin1String(f.readAll()); app.setStyleSheet(styleSheet); } } QDir::addSearchPath("icon",resPath); QDir::addSearchPath("icon",resPath+"/liteapp"); QDir::addSearchPath("icon",":/"); #if QT_VERSION >= 0x050000 QString storage = QStandardPaths::writableLocation(QStandardPaths::DataLocation); #else QString storage = QDesktopServices::storageLocation(QDesktopServices::DataLocation); #endif QDir dir(storage); dir.mkdir("liteide"); QStringList argList; QStringList fileList; if (argc >= 2) { for (int i = 1; i < argc; i++) { QString arg = argv[i]; if (arg.startsWith("-")) { argList.append(arg); continue; } else { fileList.append(arg); } } } IApplication *liteApp = LiteApp::NewApplication(true,0); if (fileList.size() == 1) { QString file = fileList.at(0); QFileInfo f(file); if (f.isFile()) { liteApp->fileManager()->addFolderList(f.path()); liteApp->fileManager()->openEditor(file); } else if (f.isDir()) { liteApp->fileManager()->addFolderList(file); } } else { foreach(QString file, fileList) { QFileInfo f(file); if (f.isFile()) { liteApp->fileManager()->openEditor(file); } else if (f.isDir()) { liteApp->fileManager()->addFolderList(file); } } }
int main(int argc, char *argv[]) #endif { #ifndef LITEAPP_LIBRARY #if defined(_MSC_VER) && defined(_DEBUG) _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); #endif #endif #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QApplication app(argc, argv); QStringList arguments = app.arguments(); //init load file or folder list QStringList fileList; //liteide --select-env [system|win32|cross-linux64|...] select init environment id //liteide --reset-setting reset current setting //liteide --local-setting force user local setting //liteide --user-setting force use user setting QString flagSelectEnv = "--select-env"; QString argSelectEnv; QString flagResetSetting = "--reset-setting"; QString flagLocalSetting = "--local-setting"; QString flagUserSetting = "--user-setting"; bool argResetSetting = false; bool argLocalSetting = false; bool argUserSetting = false; for(int i = 1; i < arguments.size(); i++) { QString arg = arguments[i]; if (arg.startsWith("-")) { if (arg.indexOf(flagSelectEnv+"=") == 0) { argSelectEnv = arg.mid(flagSelectEnv.length()+1); } else if (arg == flagSelectEnv) { i++; if (i < arguments.size()) { argSelectEnv = arguments[i]; } } else if (arg == flagResetSetting) { argResetSetting = true; } else if (arg == flagLocalSetting) { argLocalSetting = true; } else if (arg == flagUserSetting) { argUserSetting = true; } continue; } fileList.append(arg); } //save to global if (!argSelectEnv.isEmpty()) { LiteApp::s_cookie.insert(flagSelectEnv,argSelectEnv); } if (argLocalSetting) { LiteApp::s_cookie.insert(flagLocalSetting,true); } if (argUserSetting) { LiteApp::s_cookie.insert(flagUserSetting,true); } #if QT_VERSION >= 0x050100 app.setAttribute(Qt::AA_UseHighDpiPixmaps); #endif //QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); QTranslator translator; QTranslator qtTranslator; QString resPath = LiteApp::getResoucePath(); QString locale = QLocale::system().name(); QString qss; QSettings global(resPath+"/liteapp/config/global.ini",QSettings::IniFormat); bool storeLocal = global.value(LITEIDE_STORELOCAL,false).toBool(); if (argUserSetting) { storeLocal = false; } else if (argLocalSetting) { storeLocal = true; } if (storeLocal) { QSettings settings(resPath+"/liteapp/config/liteide.ini", QSettings::IniFormat); if (argResetSetting) { settings.clear(); } locale = settings.value(LITEAPP_LANGUAGE,locale).toString(); qss = settings.value(LITEAPP_QSS,"default.qss").toString(); } else { QSettings settings(QSettings::IniFormat,QSettings::UserScope,"liteide","liteide"); if (argResetSetting) { settings.clear(); } locale = settings.value(LITEAPP_LANGUAGE,locale).toString(); qss = settings.value(LITEAPP_QSS,"default.qss").toString(); } if (!locale.isEmpty()) { const QString &liteideTrPath = resPath+"/translations"; if (translator.load(QLatin1String("liteide_") + locale, liteideTrPath)) { const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); const QString &qtTrFile = QLatin1String("qt_") + locale; // Binary installer puts Qt tr files into creatorTrPath app.installTranslator(&translator); if (qtTranslator.load(qtTrFile, qtTrPath) || qtTranslator.load(qtTrFile, liteideTrPath)) { app.installTranslator(&qtTranslator); } app.setProperty("liteide_locale", locale); } } if (!qss.isEmpty()) { QFile f(resPath+"/liteapp/qss/"+qss); if (f.open(QFile::ReadOnly)) { QString styleSheet = QLatin1String(f.readAll()); app.setStyleSheet(styleSheet); } } IApplication *liteApp = LiteApp::NewApplication("default",0); foreach(QString file, fileList) { QFileInfo f(file); if (f.isFile()) { liteApp->fileManager()->openEditor(file); } else if (f.isDir()) { liteApp->fileManager()->addFolderList(file); } }