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());
}
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();

}
void MainWindow::OpenWAVFile()
{
QFileDialog *g  = new QFileDialog(this);
#if  QT_VERSION==0x040806 || defined(Q_OS_UNIX)
g->setNameFilter("Audio Files (*.wav | *.mp3)");
#else
g->setNameFilter("Audio Files (*.wav;*.mp3)");
#endif
#if QT_VERSION>=0x050000 && !defined(Q_OS_UNIX)
g->setDirectory(lastdirR);
#endif
if(g->exec())
{
ui->listWidget->clear();
f = fopen(g->selectedFiles().at(0).toLocal8Bit().constData(),"rb");
fread(&format,1,44,f);
fclose(f);
ui->locut->setMaximum(format.SampleRate/2);
ui->hicut->setMaximum(format.SampleRate/2);
ui->locutslider->setMaximum(format.SampleRate/2);
ui->hicutslider->setMaximum(format.SampleRate/2);

filename = g->selectedFiles().at(0);
QFileInfo info(g->selectedFiles().at(0));
lastdirR = info.absolutePath();
ui->actionApply_Effect->setEnabled(true);
ui->pushButton->setEnabled(true);
}
}
Beispiel #4
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;
}
Beispiel #5
0
void MainWindow::choosePath() {
    QFileDialog dirDialog;
    dirDialog.setFileMode(QFileDialog::DirectoryOnly);
    dirDialog.setDirectory(ui->lineEdit_3->text());
    if(dirDialog.exec()) {
        if(!dirDialog.selectedFiles().isEmpty())
            ui->lineEdit_3->setText(dirDialog.selectedFiles().at(0));
    }
}
Beispiel #6
0
void MainWindow::browseButtonClicked()
{
	QFileDialog tmp;
	if (tmp.exec())
	{
		if (tmp.selectedFiles().size() > 0)
		{
			ui.logFileLineEdit->setText(tmp.selectedFiles()[0]);
		}
	}
}
void ZoneViewerWindow::selectAssetDir()
{
    QFileDialog fd;
    fd.setFileMode(QFileDialog::Directory);
    fd.setDirectory(m_scene->assetPath());
    fd.setWindowTitle("Select an asset directory");
    // OpenGL rendering interferes wtih QFileDialog
    m_viewport->setAnimation(false);
    if((fd.exec() == QDialog::Accepted) && (fd.selectedFiles().count() > 0))
        m_scene->setAssetPath(fd.selectedFiles().value(0));
    m_viewport->setAnimation(true);
}
Beispiel #8
0
void MainWindow::on_actionSave_triggered()
{
#ifdef full_gui_functionality
    QFileDialog dialog;
    dialog.setFileMode(QFileDialog::AnyFile);
    dialog.setAcceptMode(QFileDialog::AcceptMode::AcceptSave);
    if(dialog.exec()) {
        ofstream f(dialog.selectedFiles()[0].toStdString());
        f << ui->plainTextEdit->toPlainText().toStdString();
        old_adress = dialog.selectedFiles()[0].toStdString();
    }
#endif
}
Beispiel #9
0
void PresetManager::loadDialogAccepted()
{
    QFileDialog *dialog = qobject_cast<QFileDialog*>(sender());
    if (!dialog || (dialog->selectedFiles().size() == 0))
    {
        return;
    }
    m_presetFile.setFile(dialog->selectedFiles().first());
    dialog->deleteLater();

    // read presets
    readPresetFile();
}
Beispiel #10
0
std::fstream* openFileUI(QWidget* parent, bool save, QString filter, QString* name = 0) {
    QFileDialog dialog (parent);
    dialog.setFileMode(save ? QFileDialog::FileMode::AnyFile : QFileDialog::FileMode::ExistingFile);
    dialog.setNameFilter(filter);
    dialog.setAcceptMode(save ? QFileDialog::AcceptMode::AcceptSave : QFileDialog::AcceptMode::AcceptOpen);
    if (dialog.exec()) {
        if (name != nullptr)
            *name = dialog.selectedFiles().front();
        std::fstream* stream = new std::fstream();
        stream->open(dialog.selectedFiles().front().toStdString(), save ? std::ios_base::out : std::ios_base::in);
        return stream;
    } else {
        return nullptr;
    }
}
Beispiel #11
0
void MainWindow::on_actionLoad_triggered()
{
#ifdef full_gui_functionality
    QFileDialog dialog;
    dialog.setFileMode(QFileDialog::AnyFile);
    if(dialog.exec()) {
        ifstream f(dialog.selectedFiles()[0].toStdString());
        stringstream ff;
        ff << f.rdbuf();
        auto qtxt = QString::fromStdString(ff.str());
        ui->plainTextEdit->setPlainText(qtxt);
        old_adress = dialog.selectedFiles()[0].toStdString();
    }
#endif
}
Beispiel #12
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 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); 
  }
   
}
Beispiel #14
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()
Beispiel #15
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();
        }
    }
}
void FileSelector::on_actionChoose_file_triggered()
{
    QFileDialog* lFileDlg  = new QFileDialog (NULL);
    lFileDlg->setOptions(0);
    lFileDlg->setWindowTitle(tr("Open image"));
    lFileDlg->setFilter(tr("Image Files (*.png *.bmp *.jpg)"));
    if (!lFileDlg->exec() || !lFileDlg->selectedFiles().size())
    {
        delete lFileDlg;
        return;
    }
    QString filepath = lFileDlg->selectedFiles().at(0);
    delete lFileDlg;

    addFile(filepath);
}
Beispiel #17
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();
    }
}
Beispiel #18
0
void PrefixDialog::on_cmdEXE_clicked()
{
	QFileDialog *dlg = new QFileDialog (this, tr("Select Windows program to run"), pr->path() + "/drive_c", tr("Windows executables (*.exe)"));
    dlg->setFileMode(QFileDialog::ExistingFile);
    if (dlg->exec() == QDialog::Accepted)
	{
		if (QMessageBox::question(this, tr("Desktop icon"), tr("Do you want to create desktop icon for this application?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
		{
			//open shortcut dialog
			ShortCutDialog *scut = new ShortCutDialog(this, pr->name(), pr->path(), dlg->selectedFiles().at(0));
			scut->exec();
			pr->makeDesktopIcon(scut->name(), scut->path(), "");
		}
		pr->runApplication(dlg->selectedFiles().at(0));
	}
}
Beispiel #19
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;
}
Beispiel #20
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;
}
void MainWindow::on_selectPicture_clicked()
{
    //get image fname
    QFileDialog dialog;
    dialog.setFileMode(QFileDialog::AnyFile);
    dialog.setNameFilter("Image files (*.png *.xpm *.jpg *.bmp *.jpeg)");
    if(dialog.exec()==0 || dialog.selectedFiles().size()==0 ) return;
    imageToSearch = dialog.selectedFiles()[0];

    //display
    QGraphicsScene *scn = new QGraphicsScene(ui->imageView);
    scn->setSceneRect(QRect(1,1,ui->imageView->rect().width()-2,ui->imageView->rect().height()-2));
    ui->imageView->setScene(scn);
    QPixmap pix(imageToSearch);
    scn->addPixmap(pix);
}
Beispiel #22
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();
}
Beispiel #23
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);
    }
}
Beispiel #24
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);
  }
Beispiel #25
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;
        }
    }

}
Beispiel #26
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
        }
    }
}
Beispiel #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?
	}
}
Beispiel #28
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();
}
Beispiel #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?");
        }
    }
}
Beispiel #30
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;
}