void QtHelpQtDoc::lookupDone(int code) { if(code==0) { KProcess* p = qobject_cast<KProcess*>(sender()); QString path = QDir::fromNativeSeparators(QString::fromLatin1(p->readAllStandardOutput().trimmed())); qCDebug(QTHELP) << "Detected doc path:" << path; if (!path.isEmpty()) { loadDirectory(path); loadDirectory(path+"/qch/"); } } sender()->deleteLater(); }
// Helper function to create the TreeView GtkWidget* ModelSelector::createTreeView () { loadDirectory(MODELS_FOLDER); GtkTreeModel *model = gtk_tree_model_filter_new(GTK_TREE_MODEL(_treeStore), NULL); GtkTreeModel *modelSorted = gtk_tree_model_sort_new_with_model(model); GtkWidget* treeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(modelSorted)); // Single column, containing model pathname GtkTreeViewColumn* col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, _("Value")); gtk_tree_view_column_set_spacing(col, 3); GtkCellRenderer* pixRenderer = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_column_pack_start(col, pixRenderer, FALSE); gtk_tree_view_column_set_attributes(col, pixRenderer, "pixbuf", IMAGE_COLUMN, NULL); GtkCellRenderer* rend = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, rend, FALSE); gtk_tree_view_column_set_attributes(col, rend, "text", NAME_COLUMN, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(treeView), col); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeView), FALSE); gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(modelSorted), NAME_COLUMN, GTK_SORT_ASCENDING); // Pack treeview into a scrolled window and return _selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeView)); g_signal_connect(G_OBJECT(_selection), "changed", G_CALLBACK(callbackSelChanged), this); // Pack treeview into a scrolled window and frame, and return return gtkutil::ScrolledFrame(treeView); }
void MapCollection::loadDirectory(String directory, MapDirectory& mapStructure) { DIR* dir = opendir(directory.c_str()); if (dir != 0) { dirent* dirent = 0; while ((dirent = readdir(dir)) != NULL) { String name = String(dirent->d_name); if (dirent->d_type == DT_DIR && name != "." && name != "..") { MapDirectory newDirectory; loadDirectory(directory + "/" + name, newDirectory); if (validDir(newDirectory)) { mapStructure.childDirectories.push_back(newDirectory); } } else if (dirent->d_type == DT_REG) { String extension = String(strrchr(dirent->d_name, '.')); if (dirent->d_name && extension == ".map" && (MapFormat::validMap(directory + "/" + String(dirent->d_name))))// && WorldGenerator::validJson( { mapStructure.childMaps.push_back(directory + "/" + dirent->d_name); } } } } }
void ImageProxy::directoryMode() { if(playMode == PLAY) { if(dirFilesIndex + 1 == dirFiles.size()) { dirFilesIndex = 0; } else { dirFilesIndex++; } } std::string newDirectory = config().get<std::string>("directory"); if(newDirectory != directory) { directory = newDirectory; dirFiles.clear(); loadDirectory(directory, dirFiles); } if(dirFiles.empty()) { logger.warn("directoryMode") << "Directory is empty: " << directory; return; } std::string filePath = directory + "/" + dirFiles[dirFilesIndex]; bool readRes = lms::imaging::readPNM(*outputImage, filePath); if(! readRes) { drawFailImage(*outputImage); logger.error("directoryMode") << "Could not read image: " << filePath; } }
void CFileBrowser::refresh(void){ //Update the tree CNotify notify; if ( link()->get_is_connected() == false ){ //Error::showNotConnected(); return; } ui->tree->clear(); topItem = new QTreeWidgetItem(); if ( topItem == NULL ){ notify.execError("Top Item is NULL"); return; } if ( ui->gotoLine->text() == "" ){ //Goto to "/" as the default directory ui->gotoLine->setText("/"); } topItem->setText(0, ui->gotoLine->text() ); topItem->setText(1, ui->gotoLine->text() ); topItem->setText(2, "false" ); ui->tree->addTopLevelItem(topItem); ui->tree->setCurrentItem(topItem, 0); loadDirectory(topItem); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); createActions(); createMenus(); initDirectories(&dirModel_confs, QStringList("*.xml"), ui->treeView_configs); initDirectories(&dirModel_elabs, QStringList("*.java"), ui->treeView_elaborations); connect(ui->elaborateButton, SIGNAL(clicked()), this, SLOT(elaborate())); ui->elaborateButton->setHidden(true); ui->tabWidget->setHidden(true); ui->treeView_configs->setVisible(true); ui->treeView_configs->setExpandsOnDoubleClick(false); ui->openFolder->setEnabled(false); setAcceptDrops( true); //Drag & Drop setWindowTitle(tr("ELCI (EL Configuration Interface)")); setMinimumSize(300, WIND_HEIGHT); resize(WIND_WIDTH, WIND_HEIGHT); setWindowIcon(QIcon(":/icon.ico")); loadDirectory(); }
void FileBrowserActivity::DoSearch(ByteString search) { if(!loadFiles) { loadDirectory(directory, search); } }
//! [0] MainWindow::MainWindow() : m_fileTree(m_namePool) { setupUi(this); new XmlSyntaxHighlighter(fileTree->document()); // Set up the font. { QFont font("Courier",10); font.setFixedPitch(true); fileTree->setFont(font); queryEdit->setFont(font); output->setFont(font); } const QString dir(QLibraryInfo::location(QLibraryInfo::ExamplesPath) + "/xmlpatterns/filetree"); qDebug() << dir; if (QDir(dir).exists()) loadDirectory(dir); else fileTree->setPlainText(tr("Use the Open menu entry to select a directory.")); const QStringList queries(QDir(":/queries/", "*.xq").entryList()); int len = queries.count(); for (int i = 0; i < len; ++i) queryBox->addItem(queries.at(i)); }
void FileBrowserActivity::DeleteSave(SaveFile * file) { String deleteMessage = "Are you sure you want to delete " + file->GetDisplayName() + ".cps?"; if (ConfirmPrompt::Blocking("Delete Save", deleteMessage)) { remove(file->GetName().c_str()); loadDirectory(directory, ""); } }
void ofxRGBDCaptureGui::objectDidRelease(ofxMSAInteractiveObject* object, int x, int y, int button){ if(object == btnSetDirectory){ loadDirectory(); } else if(object == btnCalibrateTab){ currentTab = TabCalibrate; currentTabObject = btnCalibrateTab; btnRecordBtn->setLabel("Capture Chessboard"); } else if(object == btnRecordTab){ currentTab = TabRecord; currentTabObject = btnRecordTab; btnRecordBtn->setLabel("Toggle Record"); } else if(object == btnPlaybackTab){ currentTab = TabPlayback; currentTabObject = btnPlaybackTab; btnRecordBtn->setLabel("Reset Camera"); } else if(object == btnRecordBtn){ if(currentTab == TabRecord){ toggleRecord(); } else if(currentTab == TabCalibrate){ captureCalibrationImage(); } else if(currentTab == TabPlayback){ cam.targetNode.setPosition(0, 0, 0); cam.targetNode.setOrientation(ofQuaternion()); cam.targetXRot = cam.targetYRot = cam.targetZRot = 0; } } else if(object == btnRenderBW){ currentRenderMode = RenderBW; currentRenderModeObject = btnRenderBW; } else if(object == btnRenderRainbow){ currentRenderMode = RenderRainbow; currentRenderModeObject = btnRenderRainbow; } else if(object == btnRenderPointCloud){ currentRenderMode = RenderPointCloud; currentRenderModeObject = btnRenderPointCloud; } else { for(int i = 0; i < btnTakes.size(); i++){ if(object == btnTakes[i].button){ loadSequenceForPlayback( i ); for(int b = 0; b < btnTakes.size(); b++){ btnTakes[b].isSelected = b == i; } break; } } } }
void ofxRGBDCaptureGui::loadDefaultDirectory(){ //create it if it doesn't exist string defaultDir = "depthframes"; if(!ofDirectory(defaultDir).exists()){ ofDirectory(defaultDir).create(true); } loadDirectory(defaultDir); }
void CFileBrowser::on_tree_itemActivated(QTreeWidgetItem* item, int column){ CNotify notify; qDebug("item activated %s %s", item->text(0).toLocal8Bit().constData(), item->text(1).toLocal8Bit().constData()); if ( column != 0 ){ notify.execError("Invalid Column"); return; } loadDirectory(item); item->setExpanded(true); }
void ofxRGBDCaptureGui::loadDirectory(){ if(recorder.numFramesWaitingCompession() != 0){ ofSystemAlertDialog("Cannot change directory while files are converting"); return; } ofFileDialogResult r = ofSystemLoadDialog("Select Record Directory", true); if(r.bSuccess){ loadDirectory(r.getPath()); } }
int main (int argc, char * const argv[]) { // check for enough args if (argc < 5) { usage(); return 0; } // get the number of images and thier size const unsigned int images = atoi(argv[1]); const unsigned int height = atoi(argv[2]); const unsigned int width = atoi(argv[3]); // check to make sure there are enough images if (argc < images + 4) { usage(); return 0; } // build the testing network // TODO: try to load from file first imageRecognizer test = imageRecognizer (images, height, width); std::vector<IplImage*> imageList; std::vector<std::vector<IplImage*> > imageListList; BF::path dirPath; int index; // load each set of training images, printing the index for each path along the way for (int dir = 5; dir < argc; ++dir) { dirPath = BF::path (argv[dir]); imageList = loadDirectory (dirPath); imageListList.push_back(imageList); index = test.addTrainData (imageList); std::cout << "Directory: '" << argv[dir] << "' assigned index: " << index << "\n"; } // print the original network test.print (); // train the network std::cout << "Beginning training.\n"; test.runTraining (); // print the trained network test.print (); // test the network std::cout << "Running a network test.\n"; test.runTest (); // save the network dirPath = BF::path (argv[4]); test.save (dirPath); // free some memory for (int i = 0; i < imageListList.size(); ++i) { unloadImages (imageListList[i]); } // done std::cout << "Yup\n"; return 0; }
void FileBrowserActivity::RenameSave(SaveFile * file) { ByteString newName = TextPrompt::Blocking("Rename", "Change save name", file->GetDisplayName(), "", 0).ToUtf8(); if (newName.length()) { newName = directory + PATH_SEP + newName + ".cps"; int ret = rename(file->GetName().c_str(), newName.c_str()); if (ret) ErrorMessage::Blocking("Error", "Could not rename file"); else loadDirectory(directory, ""); } else ErrorMessage::Blocking("Error", "No save name given"); }
FileBrowserActivity::FileBrowserActivity(ByteString directory, FileSelectedCallback * callback): WindowActivity(ui::Point(-1, -1), ui::Point(450, 300)), callback(callback), directory(directory), totalFiles(0) { ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 18), "Save Browser"); titleLabel->SetTextColour(style::Colour::WarningTitle); titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; AddComponent(titleLabel); ui::Textbox * textField = new ui::Textbox(ui::Point(8, 25), ui::Point(Size.X-16, 16), "", "[search]"); textField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; textField->SetActionCallback(new SearchAction(this)); AddComponent(textField); FocusComponent(textField); itemList = new ui::ScrollPanel(ui::Point(4, 45), ui::Point(Size.X-8, Size.Y-53)); itemList->Visible = false; AddComponent(itemList); progressBar = new ui::ProgressBar(ui::Point((Size.X-200)/2, 45+(Size.Y-66)/2), ui::Point(200, 17)); AddComponent(progressBar); infoText = new ui::Label(ui::Point((Size.X-200)/2, 45+(Size.Y-66)/2), ui::Point(200, 17), "No saves found"); AddComponent(infoText); filesX = 4; filesY = 3; buttonPadding = 2; fileX = 0; fileY = 0; buttonXOffset = 0; buttonYOffset = 0; buttonAreaWidth = itemList->Size.X; buttonAreaHeight = itemList->Size.Y;// - buttonYOffset - 18; buttonWidth = (buttonAreaWidth/filesX) - buttonPadding*2; buttonHeight = (buttonAreaHeight/filesY) - buttonPadding*2; loadDirectory(directory, ""); }
void TRXFile::load(Common::SeekableReadStream &trx) { uint32 magic = trx.readUint32BE(); if (magic != MKTAG('N', 'W', 'N', '2')) throw Common::Exception("Invalid magic %s", Common::debugTag(magic).c_str()); uint16 versionMajor = trx.readUint16LE(); uint16 versionMinor = trx.readUint16LE(); if ((versionMajor != 2) || (versionMinor != 3)) throw Common::Exception("Invalid version %d.%d", versionMajor, versionMinor); uint32 packetCount = trx.readUint32LE(); if ((uint)(trx.size() - trx.pos()) < (packetCount * 8)) throw Common::Exception("TRX won't fit the packet packets"); std::vector<Packet> packets; packets.resize(packetCount); loadDirectory(trx, packets); loadPackets(trx, packets); }
void loadExtensions() { #ifdef _WIN32 int oldmode; #endif mi = new MT3Interface(); # ifdef _WIN32 oldmode = SetErrorMode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS); SetCurrentDirectory(prefs.syspath[SP_EXTENSIONS]); # else chdir(prefs.syspath[SP_EXTENSIONS]); # endif loadDirectory(prefs.syspath[SP_EXTENSIONS]); # ifdef _WIN32 SetErrorMode(oldmode); SetCurrentDirectory(prefs.syspath[SP_ROOT]); # else chdir(prefs.syspath[SP_ROOT]); # endif }
// TODO: Interp/ignore prefixed drive numbers or things like ,s void NCbmKernHelper::doLoad() { if(!cpu) { std::cerr<<"NCbmKernHelper::doLoad No CPU!\n"; return; } if(!dos) { std::cerr<<"NCbmKernHelper::doLoad No DOS!\n"; return; } char fname[256]; unsigned int t; for(t=0;t<nameLen;t++) fname[t]=map->read8(nameAddr+t); fname[t]=0; DEBUG_OUT<<"Load "<<fname<<" from device "<<curDev<<","<<curSecond<<"\n"; unsigned int diskNum=0; switch(curDev) { case 1: diskNum=0; break; // "Default device num" case 8: diskNum=0; break; // Floppy Image #1 case 9: diskNum=1; break; // Floppy Image #2 case 10: diskNum=2; break; // Floppy Image #3 case 11: diskNum=3; break; // Floppy Image #4 default: std::cerr<<"Bad device number "<<curDev<<"!\n"; cpu->setRegister("p",0x81); cpu->setRegister("a",4); return; break; } dos->setDiskNum(diskNum); unsigned int start=0; if(curSecond==0) start=p3*256+p2; else start=dos->getStartAddress(fname); unsigned int readSize=0; if(fname[0]=='$') readSize=loadDirectory(fname,start,0xffff-start); else readSize=load(fname,start,2,0xffff-start); if(readSize) { cpu->setRegister("p",0); cpu->setRegister("y",(start+readSize+2)/256); cpu->setRegister("x",(start+readSize+2)&0xff); } else { std::cerr<<"NCbmKernHelper couldn't load "<<fname<<".\n"; cpu->setRegister("p",0x81); cpu->setRegister("a",4); } }
void DrishtiImport::loadDirectory() { QAction *action = qobject_cast<QAction *>(sender()); QString plugin = action->data().toString(); int idx = m_pluginDirTypes.indexOf(plugin); if (action) { QString dirname; dirname = QFileDialog::getExistingDirectory(0, "Directory", Global::previousDirectory(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog); if (dirname.size() == 0) return; loadDirectory(dirname, idx); } }
void DrishtiImport::dropEvent(QDropEvent *event) { if (event && event->mimeData()) { const QMimeData *data = event->mimeData(); if (data->hasUrls()) { QUrl url = data->urls()[0]; QFileInfo info(url.toLocalFile()); if (info.isDir()) loadDirectory(url.toLocalFile(), -1); if (info.exists() && info.isFile()) { QStringList flnms; for(uint i=0; i<data->urls().count(); i++) flnms << (data->urls())[i].toLocalFile(); loadFiles(flnms, -1); } } } }
void MapCollection::load(String directory) { loadDirectory(directory, rootDirectory); /*DIR* dir = opendir(directory.c_str()); if (dir != 0) { dirent* dire = 0; while ((dire = readdir(dir)) != NULL) { opendir(dire->d_reclen if (dire->d_type == DT_REG) { int a; a = 22; } else if (dire->d_type == DT_DIR) { int b; b = 22; } } }*/ }
DwarfClipboard::DwarfClipboard() { setupUi(this); createActions(); createTrayIcon(); trayIcon->setIcon(QIcon(":/icons/images/DwarfClipboard.png")); trayIcon->show(); setWindowTitle(tr("DwarfClipboard")); inputDelay = 100; thumbnailSize = 64; prevCursor.x = -30000; createShortcuts(); heartbeatTimer = new QTimer(this); connectedLabel = new QLabel(); createConnections(); recentModel = new DwarfClipboardModel(); tableViewRecent->setModel(recentModel); libraryModel = new DwarfClipboardModel(); treeViewLibrary->setModel(libraryModel); DFMgr = NULL; DF = NULL; Pos = NULL; connected = connectToDF(); loadConfig(); thumbnailSizeLineEdit->setText(QString("%1").arg(thumbnailSize)); inputDelayMsLineEdit->setText(QString("%1").arg(inputDelay)); tilesetPathButton->setText(DwarfClipboardPng::getTileSetPath()); colorPathButton->setText(DwarfClipboardPng::getColorPath()); copyShortcutButton->setText(copyShortcut->shortcut()); pasteDesignationShortcutButton->setText(pasteDesignationShortcut->shortcut()); pasteBuildingShortcutButton->setText(pasteBuildingShortcut->shortcut()); setCursorToPreviousPasteShortcutButton->setText(setCursorToPreviousPasteShortcut->shortcut()); heartbeatTimer->start(1000); Ui_MainWindow::statusBar->addPermanentWidget(connectedLabel); connectedIcon = QPixmap(":/icons/images/connect.png"); //This mess just converts the disconnected icon to look the same as a disabled one //It is the same code used in the icon object disconnectedIcon = QPixmap(":/icons/images/disconnect.png"); QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap generated = QApplication::style()->generatedIconPixmap(QIcon::Disabled, disconnectedIcon, &opt); disconnectedIcon = generated; loadDirectory(); loadBuildCommands(); if(connected){ connected = false; //this is ugly, but just ensures everything will be set proprly setConnected(); } else{ connected = true; setDisconnected(); } setupViews(); }
//! [1] void MainWindow::on_actionOpenDirectory_triggered() { const QString directoryName = QFileDialog::getExistingDirectory(this); if (!directoryName.isEmpty()) loadDirectory(directoryName); }
void loadDirectory(const char *dir) { char find[512]; char *e,*ext; #ifdef _WIN32 WIN32_FIND_DATA fd; HANDLE fh; bool ok; #else DIR *d; struct dirent *de; struct stat s; #endif strcpy(find,dir); e = strchr(find,0); # ifdef _WIN32 strcat(find,"*.*"); fh = FindFirstFile(find,&fd); ok = (fh!=INVALID_HANDLE_VALUE); while (ok){ if (fd.cFileName[0]!='.'){ strcpy(e,fd.cFileName); if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){ strcat(e,"\\"); SetCurrentDirectory(find); loadDirectory(find); } else{ ext = strrchr(fd.cFileName,'.'); if (stricmp(ext,".mtx")==0){ loadExtension(find); }; }; }; ok = FindNextFile(fh,&fd)!=0; }; FindClose(fh); # else if (*(e-1)!='/'){ *e++ = '/'; *e = 0; }; d = opendir(find); while ((de = readdir(d))){ if (de->d_name[0]!='.'){ strcpy(e,de->d_name); stat(find,&s); if ((s.st_mode & S_IFMT)==S_IFDIR){ chdir(find); loadDirectory(find); } else{ ext = strrchr(de->d_name,'.'); if (stricmp(ext,".mtx")==0) loadExtension(find); }; }; }; closedir(d); # endif }
void OwnCloudService::slotReplyFinished(QNetworkReply *reply) { qDebug() << "Reply from " << reply->url().path(); // qDebug() << reply->errorString(); // this should only be called from the settings dialog if (reply->url().path().endsWith(appInfoPath)) { qDebug() << "Reply from app info"; // check if everything is all right and call the callback method checkAppInfo(reply); return; } else { QByteArray arr = reply->readAll(); QString data = QString(arr); if (reply->url().path().endsWith(versionListPath)) { qDebug() << "Reply from version list"; // qDebug() << data; // handle the versions loading handleVersionsLoading(data); return; } else if (reply->url().path().endsWith(trashListPath)) { qDebug() << "Reply from trash list"; // qDebug() << data; // handle the loading of trashed notes handleTrashedLoading(data); return; } else if (reply->url().path().endsWith(capabilitiesPath)) { qDebug() << "Reply from capabilities page"; if (data.startsWith("<?xml version=")) { settingsDialog->setOKLabelData(3, "ok", SettingsDialog::OK); } else { settingsDialog->setOKLabelData(3, "not correct", SettingsDialog::Failure); } return; } else if (reply->url().path().endsWith(ownCloudTestPath)) { qDebug() << "Reply from ownCloud test page"; if (data.startsWith("<?xml version=")) { settingsDialog->setOKLabelData(2, "ok", SettingsDialog::OK); } else { settingsDialog->setOKLabelData(2, "not detected", SettingsDialog::Failure); } return; } else if (reply->url().path().endsWith(restoreTrashedNotePath)) { qDebug() << "Reply from ownCloud restore trashed note page"; // qDebug() << data; return; } else if (reply->url().path().endsWith(serverUrlPath + calendarPath)) { qDebug() << "Reply from ownCloud calendar page"; // qDebug() << data; QStringList calendarHrefList = parseCalendarHrefList(data); settingsDialog->refreshTodoCalendarList(calendarHrefList); return; } else if (reply->url().path() .startsWith(serverUrlPath + calendarPath)) { // check if we have a reply from a calendar item request if (reply->url().path().endsWith(".ics")) { qDebug() << "Reply from ownCloud calendar item ics page"; // qDebug() << data; // a workaround for a ownCloud error message if (data.indexOf( "<s:message>Unable to generate a URL for the named" " route \"tasksplus.page.index\" as such route" " does not exist.</s:message>") > 20) { data = ""; } // this will mostly happen after the PUT request to update // or create a todo item if (data == "") { // reload the todo list from server this->todoDialog->reloadTodoList(); } // increment the progress bar this->todoDialog->todoItemLoadingProgressBarIncrement(); // fetch the calendar item, that was already stored // by loadTodoItems() CalendarItem calItem = CalendarItem::fetchByUrlAndCalendar( reply->url().toString(), calendarName); if (calItem.isFetched()) { // update the item with the ics data bool wasUpdated = calItem.updateWithICSData(data); // if item wasn't updated (for example because it was no // VTODO item) we will remove it if (!wasUpdated) { calItem.remove(); return; } // reload the todo list items this->todoDialog->reloadTodoListItems(); qDebug() << __func__ << " - 'calItem': " << calItem; } } else { // this should be the reply of a calendar item list request qDebug() << "Reply from ownCloud calendar todo list page"; // qDebug() << data; // load the Todo items loadTodoItems(data); } } else if (reply->url().path() .startsWith(serverUrlPath + webdavPath)) { // this should be the reply of a calendar item list request qDebug() << "Reply from ownCloud webdav"; // load the directories loadDirectory(data); return; } else if (reply->url().toString() == serverUrl) { qDebug() << "Reply from main server url"; if (data != "") { settingsDialog->setOKLabelData(1, "ok", SettingsDialog::OK); } else { settingsDialog->setOKLabelData(1, "not found", SettingsDialog::Failure); } return; } } }
void DrishtiImport::registerPlugins() { m_pluginFileTypes.clear(); m_pluginFileDLib.clear(); m_pluginDirTypes.clear(); m_pluginDirDLib.clear(); QString plugindir = qApp->applicationDirPath() + QDir::separator() + "importplugins"; QStringList filters; #if defined(Q_OS_WIN32) filters << "*.dll"; #endif #ifdef Q_OS_MACX // look in drishti.app/importplugins QString sep = QDir::separator(); plugindir = qApp->applicationDirPath()+sep+".."+sep+".."+sep+"importplugins"; filters << "*.dylib"; #endif #if defined(Q_OS_LINUX) filters << "*.so"; #endif QDir dir(plugindir); dir.setFilter(QDir::Files); dir.setNameFilters(filters); QFileInfoList list = dir.entryInfoList(); if (list.size() == 0) { QMessageBox::information(0, "Error", QString("No plugins found in %1").arg(plugindir)); close(); } for (int i=0; i<list.size(); i++) { QString pluginflnm = list.at(i).absoluteFilePath(); QPluginLoader pluginLoader(pluginflnm); QObject *plugin = pluginLoader.instance(); if (plugin) { VolInterface *vi = qobject_cast<VolInterface *>(plugin); if (vi) { QStringList rs = vi->registerPlugin(); int idx = rs.indexOf("file"); if (idx == -1) idx = rs.indexOf("files"); if (idx >= 0) { if (rs.size() >= idx+1) { m_pluginFileTypes << rs[idx+1]; m_pluginFileDLib << pluginflnm; } else QMessageBox::information(0, "Error", QString("Received illegal files register string [%1] for plugin [%2]").\ arg(rs.join(" ")).arg(pluginflnm)); } idx = rs.indexOf("dir"); if (idx == -1) idx = rs.indexOf("directory"); if (idx >= 0) { QPair<QString, QStringList> ft; if (rs.size() >= idx+1) { m_pluginDirTypes << rs[idx+1]; m_pluginDirDLib << pluginflnm; } else QMessageBox::information(0, "Error", QString("Received illegal directory register string [%1] for plugin [%2]").\ arg(rs.join(" ")).arg(pluginflnm)); } } } else { QMessageBox::information(0, "Error", QString("Cannot load %1").arg(pluginflnm)); } } QMenu *loadDirMenu; QMenu *loadFileMenu; if (m_pluginDirTypes.size() > 0) loadDirMenu = ui.menuLoad->addMenu("Directory"); if (m_pluginFileTypes.size() > 0) loadFileMenu = ui.menuLoad->addMenu("Files"); for (int i=0; i<m_pluginDirTypes.size(); i++) { QAction *action = new QAction(this); action->setText(m_pluginDirTypes[i]); action->setData(m_pluginDirTypes[i]); action->setVisible(true); connect(action, SIGNAL(triggered()), this, SLOT(loadDirectory())); loadDirMenu->addAction(action); } for (int i=0; i<m_pluginFileTypes.size(); i++) { QAction *action = new QAction(this); action->setText(m_pluginFileTypes[i]); action->setData(m_pluginFileTypes[i]); action->setVisible(true); connect(action, SIGNAL(triggered()), this, SLOT(loadFiles())); loadFileMenu->addAction(action); } }
//This function may be recruse called void plainconf::loadConfFile(const char *path) { logToMem(LOG_LEVEL_INFO, "start parsing file %s", path); int type = checkFiletype(path); if (type == 0) return; else if (type == 2) loadDirectory(path, NULL); else if (type == 3) { AutoStr2 prefixPath = path; const char *p = strrchr(path, '/'); if (p) prefixPath.setStr(path, p - path); struct stat sb; //removed the wildchar filename, should be a directory if exist if (stat(prefixPath.c_str(), &sb) == -1) { logToMem(LOG_LEVEL_ERR, "LoadConfFile error 1, path:%s directory:%s", path, prefixPath.c_str()); return ; } if ((sb.st_mode & S_IFMT) != S_IFDIR) { logToMem(LOG_LEVEL_ERR, "LoadConfFile error 2, path:%s directory:%s", path, prefixPath.c_str()); return ; } loadDirectory(prefixPath.c_str(), p + 1); } else //existed file { //gModuleList.push_back(); //XmlNode *xmlNode = new XmlNode; FILE *fp = fopen(path, "r"); if (fp == NULL) { logToMem(LOG_LEVEL_ERR, "Cannot open configuration file: %s", path); return; } const int MAX_LINE_LENGTH = 8192; char sLine[MAX_LINE_LENGTH]; char *p; char sLines[MAX_LINE_LENGTH] = {0}; int lineNumber = 0; const int MAX_MULLINE_SIGN_LENGTH = 128; char sMultiLineModeSign[MAX_MULLINE_SIGN_LENGTH] = {0}; size_t nMultiLineModeSignLen = 0; //>0 is mulline mode while (fgets(sLine, MAX_LINE_LENGTH, fp), !feof(fp)) { ++lineNumber; p = sLine; if (nMultiLineModeSignLen) { //Check if reach the END of the milline mode size_t len = 0; const char *pLineStart = getStrNoSpace(p, len); if (len == nMultiLineModeSignLen && strncasecmp(pLineStart, sMultiLineModeSign, nMultiLineModeSignLen) == 0) { nMultiLineModeSignLen = 0; removeSpace(sLines, 1); //Remove the last \r\n so that if it is one line, it will still be one line parseLine(path, lineNumber, sLines); sLines[0] = 0x00; } else strcat(sLines, p); continue; } removeSpace(p, 0); removeSpace(p, 1); if (!isValidline(p)) continue; AutoStr2 pathInclude; if (isInclude(p, pathInclude)) { char achBuf[512] = {0}; getIncludeFile(pathInclude.c_str(), achBuf); loadConfFile(achBuf); } else { nMultiLineModeSignLen = checkMultiLineMode(p, sMultiLineModeSign, MAX_MULLINE_SIGN_LENGTH); if (nMultiLineModeSignLen > 0) strncat(sLines, p, strlen(p) - (3 + nMultiLineModeSignLen)); //need to continue else if (isChunkedLine(p)) { strncat(sLines, p, strlen(p) - 1); //strcatchr(sLines, ' ', MAX_LINE_LENGTH); //add a space at the end of the line which has a '\\' } else { strcat(sLines, p); parseLine(path, lineNumber, sLines); sLines[0] = 0x00; } } } fclose(fp); //Parsed, check in it checkInFile(path); } }
void MainWindow::on_actionOpenDirectory_triggered() { loadDirectory(QFileDialog::getExistingDirectory(this)); }
void ofxRGBDCaptureGui::setup(){ currentTab = TabCalibrate; currentRenderMode = RenderBW; downColor = ofColor(255, 120, 0); idleColor = ofColor(220, 200, 200); hoverColor = ofColor(255*.2, 255*.2, 30*.2); //setup buttons framewidth = 640; frameheight = 480; thirdWidth = framewidth/3; btnheight = 30; btnSetDirectory = new ofxMSAInteractiveObjectWithDelegate(); btnSetDirectory->setPosAndSize(0, 0, framewidth, btnheight); btnSetDirectory->setLabel("Load Directory"); buttonSet.push_back(btnSetDirectory); btnCalibrateTab = new ofxMSAInteractiveObjectWithDelegate(); btnCalibrateTab->setPosAndSize(0, btnheight, thirdWidth, btnheight); btnCalibrateTab->setLabel("Calibrate"); buttonSet.push_back(btnCalibrateTab); currentTabObject = btnCalibrateTab; btnRecordTab = new ofxMSAInteractiveObjectWithDelegate(); btnRecordTab->setPosAndSize(thirdWidth, btnheight, thirdWidth, btnheight); btnRecordTab->setLabel("Record"); buttonSet.push_back(btnRecordTab); btnPlaybackTab = new ofxMSAInteractiveObjectWithDelegate(); btnPlaybackTab->setPosAndSize(thirdWidth*2, btnheight, thirdWidth, btnheight); btnPlaybackTab->setLabel("Playback"); buttonSet.push_back(btnPlaybackTab); btnRenderBW = new ofxMSAInteractiveObjectWithDelegate(); btnRenderBW->setPosAndSize(0, btnheight*2+frameheight, thirdWidth, btnheight); btnRenderBW->setLabel("Blaick&White"); buttonSet.push_back(btnRenderBW); currentRenderModeObject = btnRenderBW; btnRenderRainbow = new ofxMSAInteractiveObjectWithDelegate(); btnRenderRainbow->setPosAndSize(thirdWidth, btnheight*2+frameheight, thirdWidth, btnheight); btnRenderRainbow->setLabel("Rainbow"); buttonSet.push_back(btnRenderRainbow); btnRenderPointCloud = new ofxMSAInteractiveObjectWithDelegate(); btnRenderPointCloud->setPosAndSize(thirdWidth*2, btnheight*2+frameheight, thirdWidth, btnheight); btnRenderPointCloud->setLabel("Pointcloud"); buttonSet.push_back(btnRenderPointCloud); btnRecordBtn = new ofxMSAInteractiveObjectWithDelegate(); btnRecordBtn->setPosAndSize(0, btnheight*3+frameheight, framewidth, btnheight); btnRecordBtn->setLabel("Capture Chessboard"); buttonSet.push_back(btnRecordBtn); for(int i = 0; i < buttonSet.size(); i++){ buttonSet[i]->setIdleColor(idleColor); buttonSet[i]->setDownColor(downColor); buttonSet[i]->setHoverColor(hoverColor); buttonSet[i]->disableKeyEvents(); buttonSet[i]->setDelegate(this); } previewRect = ofRectangle(0, btnheight*2, 640, 480); calibrationPreview.setup(10, 7, 2.5); alignment.setup(10, 7, 2.5); alignment.setupGui(0, btnheight*4+frameheight, ofGetWidth()); timeline.setup(); timeline.getColors().loadColors("defaultColors.xml"); timeline.setOffset(ofVec2f(0,btnRecordBtn->y+btnRecordBtn->height)); timeline.addElement("depth sequence", &depthSequence); timeline.setWidth(ofGetWidth()); timeline.setLoopType(OF_LOOP_NORMAL); depthSequence.setup(); ofxXmlSettings defaults; if(defaults.loadFile("defaults.xml")){ loadDirectory(defaults.getValue("currentDir", "")); } else{ loadDirectory("depthframes"); } updateTakeButtons(); cam.setup(); cam.loadCameraPosition(); cam.speed = 25; cam.setFarClip(50000); ofRegisterMouseEvents(this); ofRegisterKeyEvents(this); ofAddListener(ofEvents().windowResized, this, &ofxRGBDCaptureGui::windowResized); //ofAddListener(ofEvents().exit, this, &ofxRGBDCaptureGui::exit); ofAddListener(ofEvents().exit, this, &ofxRGBDCaptureGui::exit); ofAddListener(ofEvents().update, this, &ofxRGBDCaptureGui::update); ofAddListener(ofEvents().draw, this, &ofxRGBDCaptureGui::draw); createRainbowPallet(); depthImage.allocate(640, 480, OF_IMAGE_COLOR); recorder.setup(); }