HomeDirPlugin::HomeDirPlugin(unsigned base) : Plugin(base) { #ifdef WIN32 m_bDefault = true; m_bSave = true; HKEY subKey; if (RegOpenKeyExA(HKEY_CURRENT_USER, key_name, 0, KEY_READ | KEY_QUERY_VALUE, &subKey) == ERROR_SUCCESS){ DWORD vType = REG_SZ; DWORD vCount = 0; if (RegQueryValueExA(subKey, path_value, NULL, &vType, NULL, &vCount) == ERROR_SUCCESS){ m_homeDir = ""; m_homeDir.append(vCount, '\x00'); RegQueryValueExA(subKey, path_value, NULL, &vType, (unsigned char*)m_homeDir.c_str(), &vCount); m_bDefault = false; } RegCloseKey(subKey); } #endif string value; CmdParam p = { "-b:", I18N_NOOP("Set home directory"), &value }; Event e(EventArg, &p); if (e.process()){ m_homeDir = value; #ifdef WIN32 m_bSave = false; #endif } if (m_homeDir.empty()) m_homeDir = defaultPath(); QString d = QFile::decodeName(m_homeDir.c_str()); #ifdef WIN32 d = d.replace(QRegExp("/"), "\\"); if (d.length() && (d[(int)(d.length() - 1)] == '\\')) d = d.left(d.length() - 1); if (d.length() && d[(int)(d.length() - 1)] == ':') d += "\\"; #else if (d.length() && (d[(int)(d.length() - 1)] == '/')) d = d.left(d.length() - 1); #endif QDir dir(d); if (!dir.exists()) { m_homeDir = defaultPath(); #ifdef WIN32 m_bDefault = true; m_bSave = false; #endif } }
AddSwitchEntityDialog::AddSwitchEntityDialog( QWidget* parent) :BaseAddEntityDialog(parent, QDialogButtonBox::Ok | QDialogButtonBox::Cancel) { setAcceptDrops(true); setAttribute( Qt::WA_DeleteOnClose, true ); FilePath defaultPath(ProjectManager::Instance()->CurProjectDataSourcePath()); SceneEditor2 *scene = QtMainWindow::Instance()->GetCurrentScene(); if(scene) { FilePath scenePath = scene->GetScenePath(); if(scenePath.Exists()) { defaultPath = scenePath.GetDirectory(); } } SelectEntityPathWidget* firstWidget = new SelectEntityPathWidget(parent, defaultPath.GetAbsolutePathname(),""); SelectEntityPathWidget* secondWidget = new SelectEntityPathWidget(parent, defaultPath.GetAbsolutePathname(),""); SelectEntityPathWidget* thirdWidget = new SelectEntityPathWidget(parent, defaultPath.GetAbsolutePathname(),""); AddControlToUserContainer(firstWidget, "First Entity:"); AddControlToUserContainer(secondWidget, "Second Entity:"); AddControlToUserContainer(thirdWidget, "Third Entity:"); pathWidgets.push_back(firstWidget); pathWidgets.push_back(secondWidget); pathWidgets.push_back(thirdWidget); propEditor->setVisible(false); propEditor->setMinimumHeight(0); propEditor->setMaximumSize(propEditor->maximumWidth(), 0); }
PathSettingWidget::PathSettingWidget(string &pathValue_, const char *labelText, const char *pathDefaultLabel_, const char *pathBrowseLabel_, const char *pathDefaultValue_) : pathValue(pathValue_) { pathDefaultLabel = pathDefaultLabel_; pathBrowseLabel = pathBrowseLabel_; pathDefaultValue = pathDefaultValue_; layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); setLayout(layout); label = new QLabel(labelText); layout->addWidget(label); controlLayout = new QHBoxLayout; controlLayout->setSpacing(Style::WidgetSpacing); layout->addLayout(controlLayout); path = new QLineEdit; path->setReadOnly(true); controlLayout->addWidget(path); pathSelect = new QPushButton("Select ..."); controlLayout->addWidget(pathSelect); pathDefault = new QPushButton("Default"); controlLayout->addWidget(pathDefault); connect(pathSelect, SIGNAL(released()), this, SLOT(selectPath())); connect(pathDefault, SIGNAL(released()), this, SLOT(defaultPath())); updatePath(); }
/* * call-seq: * dir_dialog([parent], [options]) -> String * * shows an DirDialog. * ===Arguments * * parent of this window or nil * * *options: Hash with possible options to set: * * path String default path * * message String * * style Integer * * pos WX::Point * * must_exist Style Flag does set MUST_EXIST * * change_dir Style Flag does set CHANGE_DIR * ===Return value * selected path */ DLL_LOCAL VALUE _getUserDir(int argc,VALUE *argv,VALUE self) { VALUE parent,hash; rb_scan_args(argc, argv, "01:",&parent,&hash); app_protected(); wxString message(wxDirSelectorPromptStr); wxString defaultPath(wxEmptyString); int style(wxDD_DEFAULT_STYLE); wxPoint pos(wxDefaultPosition); if(rb_obj_is_kind_of(hash,rb_cHash)) { set_default_values(hash,message,defaultPath,style); set_hash_option(hash,"pos",pos); set_style_flags(hash,style); } return wrap(wxDirSelector(message, defaultPath,style,pos, unwrap<wxWindow*>(parent))); }
DataFileLoader::DataFileLoader(QObject *parent) : QObject(parent), m_lastCsvPath(QDir::homePath()), m_lastChemStationDlgSize(QSize(0,0)), m_defaultPathsToTry([]() { QStringList pathsToTry = { QDir::homePath() }; #ifdef Q_OS_UNIX pathsToTry.append( { "/home", "/" } ); #elif defined Q_OS_WIN char drive = 'C'; do { pathsToTry.append(QString(drive) + ":\\"); drive++; } while (drive <= 'Z'); pathsToTry.append( { "A:\\", "B:\\" } ); #endif // Q_OS_ return pathsToTry; }()) { m_lastChemStationPath = defaultPath(); m_loadChemStationDataDlg = new LoadChemStationDataDialog(); m_loadCsvFileDlg = new LoadCsvFileDialog(); if (m_loadChemStationDataDlg == nullptr || m_loadCsvFileDlg == nullptr) throw std::bad_alloc(); for (const CsvFileLoader::Encoding &enc : CsvFileLoader::SUPPORTED_ENCODINGS) m_loadCsvFileDlg->addEncoding(enc.name, enc.displayedName, enc.canHaveBom); }
void DataFileLoader::loadUserSettings(const QVariant &settings) { if (!settings.canConvert<EMT::StringVariantMap>()) return; EMT::StringVariantMap map = settings.value<EMT::StringVariantMap>(); if (map.contains(LAST_CHEMSTATION_LOAD_PATH_SETTINGS_TAG)) { const QVariant &v = map[LAST_CHEMSTATION_LOAD_PATH_SETTINGS_TAG]; m_lastChemStationPath = v.toString(); } if (map.contains(LAST_CSV_LOAD_PATH_SETTINGS_TAG)) { const QVariant &v = map[LAST_CSV_LOAD_PATH_SETTINGS_TAG]; m_lastCsvPath = v.toString(); } if (map.contains(LAST_CHEMSTATION_DLG_SIZE_TAG)) { const QVariant &v = map[LAST_CHEMSTATION_DLG_SIZE_TAG]; m_lastChemStationDlgSize = v.toSize(); } /* Act upon the loaded settings where necessary */ if (m_lastChemStationPath.length() > 0) { if (!isDirectoryUsable(m_lastChemStationPath)) m_lastChemStationPath = defaultPath(); m_loadChemStationDataDlg->expandToPath(m_lastChemStationPath); } }
void DataFileLoader::loadChemStationFile() { int ret; if (m_lastChemStationDlgSize.width() > 0 && m_lastChemStationDlgSize.height() > 0) m_loadChemStationDataDlg->resize(m_lastChemStationDlgSize); if (!isDirectoryUsable(m_lastChemStationPath)) m_lastChemStationPath = defaultPath(); m_loadChemStationDataDlg->expandToPath(m_lastChemStationPath); ret = m_loadChemStationDataDlg->exec(); m_lastChemStationDlgSize = m_loadChemStationDataDlg->size(); if (ret != QDialog::Accepted) return; LoadChemStationDataDialog::LoadInfo loadInfo = m_loadChemStationDataDlg->loadInfo(); switch (loadInfo.loadingMode) { case LoadChemStationDataDialog::LoadingMode::SINGLE_FILE: loadChemStationFileSingle(loadInfo.path); break; case LoadChemStationDataDialog::LoadingMode::MULTIPLE_DIRECTORIES: loadChemStationFileMultipleDirectories(loadInfo.dirPaths, loadInfo.filter); break; case LoadChemStationDataDialog::LoadingMode::WHOLE_DIRECTORY: loadChemStationFileWholeDirectory(loadInfo.path, loadInfo.filter); break; } }
bool Config::parseCommandLine(const std::vector<CL_String8>& args) { namespace po = boost::program_options; po::options_description consoleDesc; consoleDesc.add_options() ("help,h", "Receive this message") ("patcherupdate", "Indicates that the patcher itself has just received an update") ("defaultconfig", "Write defaultConfig.xml file") ("shard", po::value<std::string>(), "The shard you want to connect to. If empty, shard selection dialog is shown. Shard name can also be given without --shard prefix") ; // transform vector to default argc, argv int argc = args.size(); #ifdef WIN32 char** argv = new char*[argc]; #else char* argv[argc]; #endif for (int i = 0; i < argc; ++i) { argv[i] = const_cast<char*>(args[i].c_str()); } po::variables_map consoleOptions; try { // parse console po::positional_options_description p; p.add("shard", 1); po::store(po::command_line_parser(argc, argv).options(consoleDesc).positional(p).run(), consoleOptions); if (consoleOptions.count("help")) { std::cout << consoleDesc << std::endl; return false; } if (consoleOptions.count("defaultconfig")) { // write default config boost::filesystem::path defaultPath("defaultConfig.xml"); save(defaultPath, true); } po::notify(consoleOptions); if (consoleOptions.count("shard") > 0) { UnicodeString shard = StringConverter::fromUtf8(consoleOptions["shard"].as<std::string>()); setShardName(shard); } } catch (const std::exception& ex) { LOG_EMERGENCY << "Error parsing command line: " << ex.what() << std::endl; return false; } #ifdef WIN32 free(argv); #endif return true; }
QString path() { auto app = QCoreApplication::instance(); return (app->property(overrideFlagProperty).toBool()) ? app->property(overrideFileProperty).toString() : defaultPath(); }
// Broker real entry; various system-invoked entrypoints call here. int run_broker(int argc, char *argv[], bool hidden) { try { BootstrapOptions bootOptions(argv[0]); string defaultPath (bootOptions.module.loadDir); // Parse only the common, load, and log options to see which // modules need to be loaded. Once the modules are loaded, // the command line will be re-parsed with all of the // module-supplied options. try { bootOptions.parse (argc, argv, bootOptions.common.config, true); if (hidden) bootOptions.log.sinkOptions->detached(); qpid::log::Logger::instance().configure(bootOptions.log); } catch (const std::exception& e) { // Couldn't configure logging so write the message direct to stderr. cerr << "Unexpected error: " << e.what() << endl; return 1; } for (vector<string>::iterator iter = bootOptions.module.load.begin(); iter != bootOptions.module.load.end(); iter++) qpid::tryShlib (iter->data(), false); if (!bootOptions.module.noLoad) { bool isDefault = defaultPath == bootOptions.module.loadDir; qpid::loadModuleDir (bootOptions.module.loadDir, isDefault); } // Parse options options.reset(new QpiddOptions(argv[0])); options->parse(argc, argv, options->common.config); // Options that just print information. if (options->common.help || options->common.version) { if (options->common.version) cout << "qpidd (" << qpid::product << ") version " << qpid::version << endl; else if (options->common.help) options->usage(); return 0; } // Everything else is driven by the platform-specific broker // logic. QpiddBroker broker; return broker.execute(options.get()); } catch(const exception& e) { QPID_LOG(critical, "Unexpected error: " << e.what()); } return 1; }
void QgsBinaryWidgetWrapper::setContent() { QgsSettings s; QString file = QFileDialog::getOpenFileName( nullptr, tr( "Embed File" ), defaultPath(), tr( "All files" ) + " (*.*)" ); QFileInfo fi( file ); if ( file.isEmpty() || !fi.exists() ) { return; } s.setValue( QStringLiteral( "/UI/lastBinaryDir" ), fi.absolutePath() ); QFile fileSource( file ); if ( !fileSource.open( QIODevice::ReadOnly ) ) { return; } setValue( fileSource.readAll() ); emitValueChanged(); }
void QgsBinaryWidgetWrapper::saveContent() { QgsSettings s; QString file = QFileDialog::getSaveFileName( nullptr, tr( "Save Contents to File" ), defaultPath(), tr( "All files" ) + " (*.*)" ); if ( file.isEmpty() ) { return; } QFileInfo fi( file ); s.setValue( QStringLiteral( "/UI/lastBinaryDir" ), fi.absolutePath() ); QFile fileOut( file ); fileOut.open( QIODevice::WriteOnly ); fileOut.write( mValue ); fileOut.close(); if ( mMessageBar ) mMessageBar->pushSuccess( QString(), tr( "Saved content to <a href=\"%1\">%2</a>" ).arg( QUrl::fromLocalFile( file ).toString(), QDir::toNativeSeparators( file ) ) ); }
HeadTracker::HeadTracker() : lastTimeStampMs(0) , samplingRateHz(0) , tc(0.7) { // Try and open default path String defaultPath("/dev/tty.usbmodem1411"); SerialPortConfig portConfig(115200, 8, SerialPortConfig::SERIALPORT_PARITY_NONE, SerialPortConfig::STOPBITS_1, SerialPortConfig::FLOWCONTROL_NONE); port = new SerialPort(defaultPath, portConfig); if(port->exists()) { stream = new SerialPortInputStream(port); stream->setNotify(SerialPortInputStream::NOTIFY_ON_CHAR, '\n'); stream->addChangeListener(this); } else { // Warn user no head tracker is there } }
static void fillDefaultOptions() { char tmp[1024]; char *defcxx = PROG_CXX; defaultProgram(&cc, PROG_CC); if ( streq(cc, "gcc") ) /* TBD: MINGW */ defcxx = "g++"; defaultProgram(&cxx, defcxx); if ( !ld ) /* not specified */ { ld = (shared ? SO_LD : PROG_LD); if ( cppfiles.size > 0 && streq(ld, cc) ) ld = cxx; } #if defined(HOST_TOOLCHAIN_MSC) if ( strcmp(LIB_PL_DEBUG,pllib) == 0 ) ensureOption(&coptions, "/MDd"); else ensureOption(&coptions, "/MD"); ensureOption(&coptions, "/D__WINDOWS__"); ensureOption(&coptions, "/nologo"); ensureOption(&ldoptions, "/nologo"); #endif tmpPath(&ctmp, "ctmp-"); tmpPath(&pltmp, "pltmp-"); #if defined(__CYGWIN__) /* Compile generates .exe files on Cygwin */ replaceExtension(ctmp, "exe", tmp); free(ctmp); ctmp = strdup(tmp); #endif #if defined(HOST_OS_WINDOWS) /* Saved states have the .exe extension under Windows */ replaceExtension(pltmp, "exe", tmp); free(pltmp); pltmp = strdup(tmp); #endif if ( shared && !out && !nolink ) { fprintf(stderr, "%s: \"-o out\" required for linking shared object\n", plld); exit(1); } #if defined(HOST_OS_WINDOWS) if ( out && !nolink ) { replaceExtension(out, shared || embed_shared ? "dll" : "exe", tmp); out = strdup(tmp); } #endif defaultPath(&out, PROG_OUT); defaultProgram(&plgoal, "version"); defaultProgram(&pltoplevel, "prolog"); defaultProgram(&plinitfile, "none"); defaultProgram(&plsysinit, "none"); #ifdef __WINDOWS__ sprintf(tmp, "%s/lib", plbase); #else sprintf(tmp, "%s/lib/%s", plbase, plarch); #endif prependArgList(&libdirs, tmp); sprintf(tmp, "%s/include", plbase); prependArgList(&includedirs, tmp); }
int main(int argc, char **argv) { int special; plld = argv[0]; argc--; argv++; catchSignals(); if ( argc == 0 ) { fprintf(stderr, "No input files. Use %s -help.\n", plld); exit(0); } putenv("PLLD=true"); /* for subprograms */ verbose = FALSE; if ( argc > 2 && streq(argv[0], "-pl") ) special = 2; else special = 0; /* swipl-ld [-pl x] -v: verbose */ if ( argc-special == 1 && streq(argv[special], "-v") ) { arglist coptions; int i; memset(&coptions, 0, sizeof(coptions)); for(i=special; i < argc; i++) appendArgList(&coptions, argv[i]); callprog(PROG_CC, &coptions); return 0; } parseOptions(argc, argv); defaultProgram(&pl, PROG_PL); if ( build_defaults ) { nostate = TRUE; /* not needed and Prolog won't run */ defaultProgram(&cc, C_CC); #ifdef PLBASE defaultPath(&plbase, PLBASE); #else defaultPath(&plbase, PLHOME); #endif defaultPath(&plarch, PLARCH); defaultProgram(&pllib, C_PLLIB); addOptionString(C_LIBS); appendArgList(&ldoptions, C_LDFLAGS); appendArgList(&coptions, C_CFLAGS); appendArgList(&cppoptions, C_CFLAGS); #ifdef SO_EXT soext = strdup(SO_EXT); #endif #ifdef O_PLMT ensureOption(&coptions, "-D_REENTRANT"); ensureOption(&cppoptions, "-D_REENTRANT"); #ifdef _THREAD_SAFE /* FreeBSD */ ensureOption(&coptions, "-D_THREAD_SAFE"); ensureOption(&cppoptions, "-D_THREAD_SAFE"); #endif #endif } else { getPrologOptions(); } fillDefaultOptions(); if ( show_version ) { callprog(cc, &coptions); exit(0); } compileObjectFiles(); if ( !nolink ) { if ( shared ) linkSharedObject(); else { linkBaseExecutable(); if ( !nostate ) { createSavedState(); createOutput(); } } } removeTempFiles(); return 0; }
/******************************* * PROLOG OPTIONS * *******************************/ static void getPrologOptions() { FILE *fd; char cmd[512]; sprintf(cmd, "%s --dump-runtime-variables", pl); if ( verbose ) printf("\teval `%s`\n", cmd); if ( (fd = popen(cmd, "r")) ) { char buf[256]; while( fgets(buf, sizeof(buf), fd) ) { char name[100]; char value[256]; char *v; if ( sscanf(buf, "%[^=]=%[^;\n]", name, value) == 2 ) { v = value; if ( *v == '"' ) { char *e = ++v; while(*e && *e != '"') e++; while(e>v && isspace(CTOI(e[-1]))) e--; *e = '\0'; } if ( streq(name, "CC") ) defaultProgram(&cc, v); else if ( streq(name, "PLBASE") ) defaultPath(&plbase, v); else if ( streq(name, "PLARCH") ) defaultPath(&plarch, v); else if ( streq(name, "PLLIBS") ) /* Always required. */ pllibs = strdup(v); else if ( streq(name, "PLLIB") ) defaultProgram(&pllib, v); else if ( streq(name, "PLLDFLAGS") ) appendArgList(&ldoptions, v); else if ( streq(name, "PLCFLAGS") ) { appendArgList(&coptions, v); appendArgList(&cppoptions, v); } else if ( streq(name, "PLSOEXT") ) soext = strdup(v); else if ( streq(name, "PLTHREADS") && streq(v, "yes") ) { ensureOption(&coptions, "-D_REENTRANT"); ensureOption(&cppoptions, "-D_REENTRANT"); #ifdef _THREAD_SAFE /* FreeBSD */ ensureOption(&coptions, "-D_THREAD_SAFE"); ensureOption(&cppoptions, "-D_THREAD_SAFE"); #endif } else continue; if ( verbose ) fprintf(stderr, "\t\t%s=\"%s\"\n", name, v); } else { fprintf(stderr, "Unparsed Prolog option: %s\n", buf); } } pclose(fd); #if defined(__WINDOWS__) && defined(HOST_OS_WINDOWS) sprintf(buf, "%s/bin/%s", plbase, PROG_PL); #else sprintf(buf, "%s/bin/%s/%s", plbase, plarch, PROG_PL); #endif defaultPath(&plexe, buf); } else { fprintf(stderr, "%s: failed to run %s: %s", plld, cmd, oserror()); error(1); } }