Esempio n. 1
1
void Dialog::on_button_1_clicked()
{
  QFileDialog d;

  //enum ViewMode { Detail, List };
  d.setViewMode(QFileDialog::Detail);

  //enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
  d.setFileMode(QFileDialog::ExistingFiles);

  //enum AcceptMode { AcceptOpen, AcceptSave };
  d.setAcceptDrops(QFileDialog::AcceptOpen);

  //enum Option { ShowDirsOnly, DontResolveSymlinks, DontConfirmOverwrite, DontUseSheet, DontUseNativeDialog, ReadOnly, HideNameFilterDetails }
  d.setOptions(QFileDialog::ReadOnly);

  d.exec();

  std::stringstream s;
  if (d.result() == QDialog::Accepted)
  {
    s << "Number of files selected: " << d.selectedFiles().size() << '\n';
    const auto v = d.selectedFiles();
    for (auto f: v) s << f.toStdString() << '\n';
  }
  else
  {
    assert(d.result() == QDialog::Rejected);
    s << "Dialog closed with cancel or close\n";
  }
  ui->text_1->setPlainText(s.str().c_str());
}
Esempio n. 2
0
  void TabEdit::changePOTCAR(QListWidgetItem *item)
  {
    QSettings settings; // Already set up in avogadro/src/main.cpp

    // Get symbol and filename
    QStringList strl = item->text().split(":");
    QString symbol   = strl.at(0).trimmed();
    QString filename = strl.at(1).trimmed();

    QStringList files;
    QString path = settings.value("xtalopt/templates/potcarPath", "").toString();
    QFileDialog dialog (NULL, QString("Select pot file for atom %1").arg(symbol), path);
    dialog.selectFile(filename);
    dialog.setFileMode(QFileDialog::ExistingFile);
    if (dialog.exec()) {
      files = dialog.selectedFiles();
      if (files.size() != 1) { return;} // Only one file per element
      filename = files.first();
      settings.setValue("xtalopt/templates/potcarPath", dialog.directory().absolutePath());
    }
    else { return;} // User cancel file selection.
    // "POTCAR info" is of type
    // QList<QHash<QString, QString> >
    // e.g. a list of hashes containing
    // [atomic symbol : pseudopotential file] pairs
    QVariantList potcarInfo = m_opt->optimizer()->getData("POTCAR info").toList();
    QVariantHash hash = potcarInfo.at(ui_list_optStep->currentRow()).toHash();
    hash.insert(symbol,QVariant(filename));
    potcarInfo.replace(ui_list_optStep->currentRow(), hash);
    m_opt->optimizer()->setData("POTCAR info", potcarInfo);
    qobject_cast<VASPOptimizer*>(m_opt->optimizer())->buildPOTCARs();
    updateEditWidget();
  }
Esempio n. 3
0
void CDPWizard::promptForFileName(QLineEdit * theLineEdit, QString theShortName, QString theLongName)
{
    QSettings myQSettings;
    QString myFilterList;
    FileReader::getGdalDriverMap(myFilterList);
    QString myWorkDirString = myQSettings.readEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Dir",QDir::homeDirPath());

    std::cout << "Filter List: " << myFilterList << std::endl;
    QString myFileNameQString;
    QFileDialog myFileDialog (myWorkDirString,myFilterList,0,"Select " + theLongName ,"Select " + theLongName);
    QString myLastFilter = myQSettings.readEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Filter","");
    if (!myLastFilter.isEmpty())
    {
      myFileDialog.setSelectedFilter(myLastFilter);
    }
    if ( myFileDialog.exec() == QDialog::Accepted )
    {
      myFileNameQString = myFileDialog.selectedFile();
      theLineEdit->setText(myFileNameQString);
      QFileInfo myFileInfo(myFileNameQString);
      myQSettings.writeEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Dir",myFileInfo.dirPath());
      myQSettings.writeEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Filter",myFileDialog.selectedFilter());
      checkInputFilenames();
    }
}
Esempio n. 4
0
void MainWindow::saveFileAs()
{
    QFileDialog *saveWindow = new QFileDialog(this);
    FILE *saveFile;
    QTextStream *fileStream;
    QByteArray filenameFopen;

    saveWindow->setAcceptMode(QFileDialog::AcceptSave);
    saveWindow->setFileMode(QFileDialog::AnyFile);
    saveWindow->show();

    if(saveWindow->exec())
    {
        //convert Qstring to char* for the fopen function
        filenameFopen = saveWindow->selectedFiles()[0].toLocal8Bit();
        saveFile = fopen(filenameFopen.data(), "w");

        if(saveFile == NULL)
        {
            cout << "Erreur" << endl;
        }
        else
        {
            fileStream = new QTextStream(saveFile,QIODevice::ReadWrite);
            currentDocument->save(*fileStream, 4);
            fclose(saveFile);
            fileSaved = true;
        }
    }

}
Esempio n. 5
0
void PaletteView::exportPalette(int start, int length) {
	if (start >= 512) {
		return;
	}
	if (start + length > 512) {
		length = 512 - start;
	}
	m_controller->threadInterrupt();
	QFileDialog* dialog = GBAApp::app()->getSaveFileDialog(this, tr("Export palette"), tr("Windows PAL (*.pal);;Adobe Color Table (*.act)"));
	if (!dialog->exec()) {
		m_controller->threadContinue();
		return;
	}
	QString filename = dialog->selectedFiles()[0];
	VFile* vf = VFileDevice::open(filename, O_WRONLY | O_CREAT | O_TRUNC);
	if (!vf) {
		m_controller->threadContinue();
		return;
	}
	QString filter = dialog->selectedNameFilter();
	if (filter.contains("*.pal")) {
		GBAExportPaletteRIFF(vf, length, &m_controller->thread()->gba->video.palette[start]);
	} else if (filter.contains("*.act")) {
		GBAExportPaletteACT(vf, length, &m_controller->thread()->gba->video.palette[start]);
	}
	vf->close(vf);
	m_controller->threadContinue();
}
void QmitkBSplineRegistrationView::SelectDeformationField()
{ 
  // SELECT FOLDER DIALOG
  QFileDialog* w = new QFileDialog( this, "Select Deformation Field" );
  w->setFileMode( QFileDialog::ExistingFiles );
  w->setFilter( "Images (*.mhd)" );
  w->setDirectory("G:\\home\\vanbrugg\\testimages\\deformable"); 

  // RETRIEVE SELECTION
  if ( w->exec() != QDialog::Accepted )
  {
    return;
    cout << "Failed to load" << endl;
  }

  QStringList filenames = w->selectedFiles();
  QStringList::Iterator it = filenames.begin();
  if( it != filenames.end() ) {
    std::string filename = ( *it ).toStdString();
    ++it;     
    QString qStr = QString( filename.c_str() );
    m_Controls.m_DeformationField->setText(qStr); 
  }
   
}
Esempio n. 7
0
void QtDcm::openDicomdir()
{
    this->clearDisplay();
    d->mode = QtDcm::CD;
    // Open a QFileDialog for choosing a Dicomdir
    QFileDialog * dialog = new QFileDialog( this );
    dialog->setFileMode ( QFileDialog::ExistingFile );
    dialog->setDirectory ( QDir::home().dirName() );
    dialog->setWindowTitle ( tr ( "Open dicomdir" ) );
    QStringList filters;
    filters << "Dicomdir files (dicomdir* DICOMDIR*)";
    filters << "Any files (*)";
    dialog->setNameFilters(filters);

    QString fileName;

    if ( dialog->exec() )
    {
        fileName = dialog->selectedFiles() [0];
    }

    dialog->close();

    if ( !fileName.isEmpty() )   // A file has been chosen
    {
        if (QString::compare(fileName, "dicomdir", Qt::CaseInsensitive))
        {
            QtDcmManager::instance()->setDicomdir ( fileName );
            this->loadPatientsFromDicomdir();
        }
    }

    dialog->deleteLater();
}
Esempio n. 8
0
  void TabProgress::injectStructureProgress()
  {
    // It doesn't matter what xtal was selected
    m_context_xtal = NULL;

    // Prompt for filename
    QSettings settings; // Already set up in avogadro/src/main.cpp
    QString filename = settings.value("xtalopt/opt/seedPath",
                                      m_opt->filePath).toString();

    // Launch file dialog
    QFileDialog dialog (m_dialog,
                        QString("Select structure file to use as seed"),
                        filename,
                        "Common formats (*POSCAR *CONTCAR *.got *.cml *cif"
                        " *.out);;All Files (*)");
    dialog.selectFile(filename);
    dialog.setFileMode(QFileDialog::ExistingFile);
    if (dialog.exec())
      filename = dialog.selectedFiles().first();
    else { return;} // User cancel file selection.

    settings.setValue("xtalopt/opt/seedPath", filename);

    // Load in background
    QtConcurrent::run(this, &TabProgress::injectStructureProgress_,
                      filename);
  }
Esempio n. 9
0
void MainWindow::on_actionOpen_triggered()
{
    on_actionReal_Time_toggled(false);
    QFileDialog * dialog = new QFileDialog(this);
    dialog->setNameFilter(tr("data files (*.txt)"));
    dialog->setDirectory(QDir::currentPath());
    dialog->exec();
    QStringList filename_list = dialog->selectedFiles();
    QString datafilename = filename_list.first();

    QFile datafile(datafilename);
    if (!datafile.open(QIODevice::ReadOnly))
        return;

    QTextStream in_stream(&datafile);

    QVector<QPoint> in_points;

    while (!in_stream.atEnd())
    {
        float x, y;
        in_stream >> x >> y;
        in_points << QPoint(x, y);
        //qDebug() << x << ", " << y;
    }

    if (in_points.last().x() == 0 && in_points.last().y() == 0)
    {
        in_points.pop_back();
    }

    points = in_points;
    update();
    //on_actionPerform_triggered();
}
Esempio n. 10
0
void preferencedialog::addCal(){
    QFileDialog caldialog;
    caldialog.setFileMode(QFileDialog::ExistingFiles);
    caldialog.setNameFilter("*.cal");
    caldialog.setViewMode(QFileDialog::Detail);
    caldialog.setDirectory("./");

    QStringList stringlist;
    QStringList reducedCalNames;

    for(int i=0; i<calNames.size(); i++){
        QString zahl;
        zahl.setNum(i);
        reducedCalNames.push_back("  "+zahl+":   ..."+calNames.at(i).right(50));
    }

    if (caldialog.exec())
        stringlist = caldialog.selectedFiles();

    for(int i=0; i<stringlist.size(); i++){
        QString zahl;
        zahl.setNum(i);
        calNames.push_back(stringlist.at(i));
        reducedCalNames.push_back("  "+zahl+":   ..."+stringlist.at(i).right(50));
    }

    bla->setStringList(reducedCalNames);
    ui->listView->setModel(bla);



}
Esempio n. 11
0
void
WaveMaker::loadFile()
{
  QFileDialog* fd = new QFileDialog(this, "Wave Maker Input File", TRUE);
  fd->setMode(QFileDialog::AnyFile);
  fd->setViewMode(QFileDialog::Detail);
  QString fileName;
  if (fd->exec() == QDialog::Accepted)
    {
      fileName = fd->selectedFile();
      printf("Loading new file: %s\n", fileName.latin1());
      setComment("File Name", fileName);
      wave.clear();
      QFile file(fileName);
      if (file.open(IO_ReadOnly))
        {
          QTextStream stream(&file);
          double value;
          while (!stream.atEnd())
            {
              stream >> value;
              wave.push_back(value);
            }
          filename = fileName;
        }
void ossimQtSingleImageWindow::openImage()
{
    QString caption = "iview : open image";
    QString directory;
    if (!theLastOpenedDirectory.empty())
    {
        if (theLastOpenedDirectory.exists())
        {
            directory = theLastOpenedDirectory.c_str();
        }
    }

    QFileDialog* fd = new QFileDialog( this, caption, directory );
    fd->setFileMode( QFileDialog::ExistingFile );

    ossimFilename fileName;

    if ( fd->exec() == QDialog::Accepted )
    {
        fileName = fd->selectedFile().ascii();
        theLastOpenedDirectory = fileName.path();
    }

    delete fd;
    fd = 0;

    if (fileName.empty())
    {
        return;
    }

    displayImage(fileName);
}
Esempio n. 13
0
void MainWindow::open_file_locally()
{
  QFileDialog dlg;

  dlg.setAcceptMode(QFileDialog::AcceptOpen);
  dlg.exec();
}
Esempio n. 14
0
void MainWindow::save_file_locally()
{
  QFileDialog dlg;

  dlg.setAcceptMode(QFileDialog::AcceptSave);
  dlg.exec();
}
Esempio n. 15
0
void FileNameEditorWidget::buttonPressed() {
  QFileDialog *dlg = new QFileDialog(this, "Choose a file", basePath, fileFilter);
  dlg->setModal(true);
  dlg->setFileMode(QFileDialog::ExistingFile);

  if (dlg->exec() == QDialog::Accepted) {
    QString file = dlg->selectedFiles().first();

    if (!file.isNull()) {
      QStringList currentDir = QDir::currentPath().split(QDir::separator());
      QStringList filePath = QFileInfo(file).dir().absolutePath().split(QDir::separator());
      QString relativePath = "";

      while ((!currentDir.empty() && !filePath.empty()) && (currentDir.front()
             == filePath.front())) {
        currentDir.pop_front();
        filePath.pop_front();
      }

      while (!currentDir.empty()) {
        relativePath += "..";
        relativePath += QDir::separator();
        currentDir.pop_front();
      }

      if (!filePath.empty())
        relativePath += filePath.join((const QString) (QChar) QDir::separator())
                        + QDir::separator();

      setFileName(relativePath + QFileInfo(file).fileName());
    }
  }

  delete dlg;
}
Esempio n. 16
0
/**
 * @brief Stores the debug information to a markdown file
 */
void SettingsDialog::on_saveDebugInfoButton_clicked() {
    QFileDialog dialog;
    dialog.setFileMode(QFileDialog::AnyFile);
    dialog.setAcceptMode(QFileDialog::AcceptSave);
    dialog.setDirectory(QDir::homePath());
    dialog.setNameFilter("Markdown files (*.md)");
    dialog.setWindowTitle("Save debug information");
    dialog.selectFile("QOwnNotes Debug Information.md");
    int ret = dialog.exec();

    if (ret == QDialog::Accepted) {
        QStringList fileNames = dialog.selectedFiles();
        if (fileNames.size() == 0) {
            return;
        }

        QFile file(fileNames.at(0));

        if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
            qWarning() << file.errorString();
            return;
        }

        QTextStream out(&file);
        out.setCodec("UTF-8");
        out << ui->debugInfoTextEdit->toPlainText();
        file.flush();
        file.close();
    }
}
Esempio n. 17
0
bool FileSystem::saveAsDialog()
{
    QFileDialog dialog;
    dialog.setMimeTypeFilters(Config::supportedSaveMimeTypes());
    dialog.setAcceptMode(QFileDialog::AcceptSave);
    dialog.selectFile(getCurrentAbsoluteFileName());
    dialog.setDirectory(getCurrentAbsoluteFileName());
    dialog.selectMimeTypeFilter("image/jpeg");

    bool success;
    if(dialog.exec())
    {
        QImage img;
        if(SaveConfirmation::imageWasChanged(getCurrentAbsoluteFileName()))
        {
            img = SaveConfirmation::getChagedImage(getCurrentAbsoluteFileName());
            success = img.save(dialog.selectedFiles().first());
            if(success)
                SaveConfirmation::deleteImage(getCurrentAbsoluteFileName());
        }
        else
        {
            img.load(getCurrentAbsoluteFileName());
            success = img.save(dialog.selectedFiles().first());
        }
    }

    return success;
}
Esempio n. 18
0
void MainWindow::loadData()
{
    QFileDialog *fd = new QFileDialog(this, tr("请选择导入文件"), QDir::currentPath()+"/config","*.ini *.xml");
    fd->setFileMode(QFileDialog::AnyFile);
    fd->setViewMode(QFileDialog::Detail);
    QStringList fileNamesList;
    if(fd->exec()) // ok
    {
        fileNamesList=fd->selectedFiles();
    }
    else
    {
        QMessageBox::warning(this, tr("警告"), tr("获取数据文件失败") );
        return ;
    }
    ui->view->zoom(1.0);
    scalingSpinBox->setValue(1.0);
    QString fileName = fileNamesList.at(0).toLocal8Bit().constData();
    QStringList fileType = fileName.split(".");
    if(fileType.last() == "xml")
    {
        ReadFileBase *file = new XmlFile(fileName);
        scene->loadData(file);
    }
    else if(fileType.last() == "ini")
    {
        ReadFileBase *file = new DataReader(fileName);
        CFGManager::Instance()->loadCFGFile(fileName);//读取静态文件
        this->setObName(CFGManager::Instance()->getRelationMap());
        scene->loadData(file);
    }
    else
        return;
}
Esempio n. 19
0
void MainWindow::save_as()

{
  QFileDialog dialog;

  dialog.setAcceptMode(QFileDialog::AcceptSave);
  dialog.setFileMode(QFileDialog::AnyFile);
  dialog.setDefaultSuffix("xml");
  dialog.setNameFilter(tr("xml files (*.xml)"));

  if (dialog.exec() == QDialog::Accepted)
    {
      this->filename = dialog.selectedFiles().at(0);

      if (!this->save(this->filename))
        {
          this->filename = "";

          QMessageBox message;

          message.setText("Could not save the file.");
          message.exec();
        }
      else  // set the new window title
        {
          this->update_title();
          this->change_happened = false; // reset the change watcher
        }
    }
}
Esempio n. 20
0
void AppImportFile::open()
{
    const QString MetaIOImageFilter("MetaIO Image (*.mhd)"), DICOMImageFilter("DICOM Images (*.dcm)"), AllFilesFilter("All Files (*)");
    QStringList imagesFilter;
    imagesFilter << MetaIOImageFilter << DICOMImageFilter << AllFilesFilter;

    QFileDialog *openDialog = new QFileDialog(0);
    openDialog->setWindowTitle(tr("Select files to open..."));
    openDialog->setDirectory(m_workingDirectory);
    openDialog->setNameFilters(imagesFilter);
    openDialog->selectNameFilter (m_lastExtension);
    openDialog->setFileMode(QFileDialog::ExistingFiles);
    openDialog->setAcceptMode(QFileDialog::AcceptOpen);

    if (openDialog->exec() == QDialog::Accepted)
    {
        QStringList fileNames = openDialog->selectedFiles();

        emit selectedFiles(fileNames);

        m_workingDirectory = QFileInfo(fileNames.first()).dir().path();
        m_lastExtension = openDialog->selectedNameFilter();

        writeSettings();
    }
    delete openDialog;
}
Esempio n. 21
0
void MainWindow::on_action_Export_Scenes_triggered()
{
    QFileDialog fileDialog;
    fileDialog.setWindowTitle(tr("Export"));
    // Set the dialog for saving files, sets the dialog button to "Save"
    fileDialog.setAcceptMode(QFileDialog::AcceptSave);
    // Set the dialog to display the Desktop folder as default location
    fileDialog.setDirectory(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
    // Set the dialog to return the file name wheather the file exists or not
    fileDialog.setFileMode(QFileDialog::AnyFile);
    fileDialog.setNameFilter(tr("XML Data File") + " (*.xml)");

    bool wasFileSelected = fileDialog.exec();
    QString filePath;
    if (wasFileSelected) {
        filePath = fileDialog.selectedFiles().at(0);

        qDebug() << "Exporting file: " + filePath;
        try {
            _sceneDataFile->exportTo(filePath);
        }
        catch (SceneDataFileException& exception)
        {
            QMessageBox::critical(this,
                                  tr("ERROR: File Export Failed"),
                                  exception.getMessage());

            return; // If export failed
        }
    }
    else
    {
        return; // If no file was selected
    }
} // on_action_Export_Scenes_triggered()
Esempio n. 22
0
void MainWindow::onChangeDataDirectory()
{
    QFileDialog dlg;

    dlg.setAcceptMode(QFileDialog::AcceptOpen);
    dlg.setFileMode(QFileDialog::Directory);
    dlg.setOption(QFileDialog::ShowDirsOnly, true);

    if (dlg.exec()) {
        QString path = dlg.selectedFiles().at(0);
        DatabaseDlg dbdlg(QDir(path), this);

        if (dbdlg.exec()) {
            Parser *p = new Parser(path, m_output);

            p->restrictYears(dbdlg.getSelectedYears());

            activateWindow();
            raise();

            p->moveToThread(&m_thread);

            connect(&m_thread, SIGNAL(finished()), p, SLOT(deleteLater()));
            connect(p, SIGNAL(finished()), this, SLOT(onParseFinished()));
            connect(this, SIGNAL(parse()), p, SLOT(parse()));

            m_thread.start();

            emit parse();
        }
    }
}
Esempio n. 23
0
QString MainWindow::ChooseFile(QString filename){

    QFileDialog *fd = new QFileDialog(this,tr("Choose Dataset File"), "/Users/Zhangjun/Documents/C++Work/BPNN/data","" );

    fd->setFileMode(QFileDialog::ExistingFile);

    fd->setViewMode(QFileDialog::Detail);

    QStringList filters;

    filters << "*.csv" << "*.dat" << "*.txt" << "*.*";

    fd->setNameFilters(filters);

    QStringList fileNamesList;

    if(fd->exec()) // ok
    {

            fileNamesList = fd->selectedFiles();

            QString fileName = fileNamesList.at(0).toLocal8Bit().constData();

            return fileName;

    }else{

        return filename;

    }


}
void MainWindow::on_actionLoad_triggered()
{
    QFileDialog dg;
    dg.setToolTip(tr("Open file with gamers names"));
    dg.setLabelText(QFileDialog::Accept,tr("Open"));
    dg.setLabelText(QFileDialog::LookIn,tr("Open"));
    dg.setWindowTitle("Open file with gamers names");

    if ( QDialog::Rejected  == dg.exec())
    {
        return;
    }
    QFile file(dg.selectedFiles().at(0)) ;

    if(!file.open(QIODevice::ReadOnly))
        qWarning("failed to open file %s",dg.selectedFiles().at(0).toStdString().c_str());
    else
    {
#if DEBUG
        qWarning("successed to open file %s",dg.selectedFiles().at(0).toStdString().c_str());
#endif
    }
    QString str;

    QByteArray arr = file.readAll();

    str = str.fromLocal8Bit(arr );

    md->set_gamers( str.split(","));
    file.close();

}
Esempio n. 25
0
void interface::DialogOBJ()
{
    QString filetemporaire;

    {   QFileDialog dialog;
        dialog.setFileMode(QFileDialog::ExistingFile);
        //dialog.setNameFilter(tr("Text files(*.obj)"));
        dialog.setWindowTitle("Selectionner le fichier OBJ");


        if(dialog.exec()) {
            QStringList selectedFiles;
            selectedFiles = dialog.selectedFiles();
            if(selectedFiles.length() == 1)
                filetemporaire = selectedFiles.first();
        }
    }

    if(!filetemporaire.isEmpty())
    {
        string file;
        file = filetemporaire.toStdString();
        objetteste.loadobjet(file);
    }
}
Esempio n. 26
0
File FileDialogs::savePlaylist()
{
    QStringList filters;
    filters << filterByType(File::M3U)
            << filterByType(File::M3UClean)
            << filterByType(File::M3UUdpxy)
            << filterByType(File::CSV)
            << filterByType(File::JS);

    QFileDialog dialog;
    dialog.setAcceptMode(QFileDialog::AcceptSave);
    dialog.setFileMode(QFileDialog::AnyFile);
    dialog.setConfirmOverwrite(true);
    dialog.setNameFilters(filters);

    QString fileName;
    File::Type type = File::Unknown;
    if (dialog.exec()) {
        fileName = dialog.selectedFiles()[0];

        for (int i = 0; i < 50; i++) {
            if (dialog.selectedNameFilter() == filterByType(File::Type(i))) {
                type = File::Type(i);
            }
        }
    }

    File file;
    file.path = fileName;
    file.type = type;
    return file;
}
Esempio n. 27
0
void MainWindow::actionOpen()
{
	QString filePath;
	QFileDialog* fileDialog = new QFileDialog(this,
						  tr("Select File to open"),
						  m_pathImport,
						  tr("All Compatible (*.wzm *.pie *.obj);;"
						     "WZM models (*.wzm);;"
						     "PIE models (*.pie);;"
						     "OBJ files (*.obj)"));
	fileDialog->setFileMode(QFileDialog::ExistingFile);
	fileDialog->exec();

	if (fileDialog->result() == QDialog::Accepted)
	{
		filePath = fileDialog->selectedFiles().first();

		// refresh import working dir
		m_pathImport = fileDialog->directory().absolutePath();
		m_settings->setValue(WMIT_SETTINGS_IMPORTVAL, m_pathImport);

		PrependFileToRecentList(filePath);
	}

	delete fileDialog;
	fileDialog = nullptr;

	if (!filePath.isEmpty())
	{
		openFile(filePath);
		// else popup on fail?
	}
}
Esempio n. 28
0
File FileDialogs::openPlaylist()
{
    QStringList filters;
    filters << filterByType(File::M3U)
            << filterByType(File::CSV)
            << filterByType(File::JS);

    QFileDialog dialog;
    dialog.setAcceptMode(QFileDialog::AcceptOpen);
    dialog.setFileMode(QFileDialog::ExistingFile);
    dialog.setNameFilters(filters);

    QString fileName;
    File::Type type = File::Unknown;
    if (dialog.exec()) {
        fileName = dialog.selectedFiles()[0];

        for (int i = 0; i < 50; i++) {
            if (dialog.selectedNameFilter() == filterByType(File::Type(i))) {
                type = File::Type(i);
            }
        }
    }

    File file;
    file.path = fileName;
    file.type = type;
    return file;
}
Esempio n. 29
0
void ProjectManager::SaveProjectAs()
{
    if(m_pBoek == NULL)
    {
        QMessageBox box(QMessageBox::Information, "Geen project", "Er is geen project geopend!");
        box.exec();
        return;
    }

    QFileDialog fileDialog;
    fileDialog.setFileMode(QFileDialog::AnyFile);
    fileDialog.setAcceptMode(QFileDialog::AcceptSave);

    if(fileDialog.exec())
    {
        QStringList files = fileDialog.selectedFiles();
        if(files.size() >= 1)
        {
            m_saveLocation = files.first();
            save(m_saveLocation);
        }
        else
        {
            qWarning("No files selected in QFileDialog but user still managed to click save?");
        }
    }
}
Esempio n. 30
0
//-----------------------------------------------------------------------------------
void Editor::on_action_LOAD_triggered()
{
    QFileDialog dialog {this};
    dialog.setFileMode(QFileDialog::ExistingFile);
    dialog.setViewMode(QFileDialog::List);
    dialog.setOption(QFileDialog::DontUseCustomDirectoryIcons);
    dialog.setNameFilter("Text (*.mu *.txt)");
    dialog.exec();
    auto files = dialog.selectedFiles();
    if (files.isEmpty())
        return;

    auto fileName = files[0];

    std::ifstream reader (fileName.toStdString(), std::ios_base::binary);

    if (!reader.good()) {
        QMessageBox::warning(this, "IO Error", "Could not load the file specified", QMessageBox::Ok, QMessageBox::Ok);
        return;
    }

    std::string data;
    do {
        char buffer[4096];
        reader.read(buffer, 4096);
        data.append(buffer, reader.gcount());
    } while (reader.gcount() == 4096);

    qDebug() << QString::fromStdString(data);
    builder_.loadMarkup(data);
    builder_.generateUiElements(ui->viewPort->layout());
}