ExtensibleFileDialog::ExtensibleFileDialog(QWidget *parent, bool extended, Qt::WFlags flags)
	: QFileDialog(parent, flags)
{
	d_extension = 0;

	d_extension_toggle = new QPushButton(tr("<< &Advanced"));
	d_extension_toggle->setCheckable(true);
	if (extended)
		d_extension_toggle->toggle();
	d_extension_toggle->hide(); // show only for d_extension != 0

	QGridLayout *main_layout = qobject_cast<QGridLayout*>(layout());
	if (main_layout) {
		d_extension_row = main_layout->rowCount();
		main_layout->addWidget(d_extension_toggle, d_extension_row, main_layout->columnCount()-1);
		main_layout->setRowStretch(d_extension_row, 0);
		main_layout->setRowStretch(d_extension_row+1, 0);
	} else {
		// fallback in case QFileDialog uses a different layout in the future (=> main_layout==0)
		// would probably look a mess, but at least all functions would be accessible
		layout()->addWidget(d_extension_toggle);
	}

    QList<QUrl> urls;
    urls << QUrl::fromLocalFile("");
    urls << QUrl::fromLocalFile(QDir::homePath());
	urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
    urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
	setSidebarUrls(urls);

	connect(this, SIGNAL(accepted()), this, SLOT(close()));
    connect(this, SIGNAL(rejected()), this, SLOT(close()));
}
Example #2
0
ScFileWidget::ScFileWidget(QWidget * parent)
	: QFileDialog(parent, Qt::Widget)
{
	setSizeGripEnabled(false);
	setModal(false);
	setViewMode(QFileDialog::List);
	setWindowFlags(Qt::Widget);


#ifdef Q_OS_MAC
	QList<QUrl> urls;
	QUrl computer(QUrl::fromLocalFile(QLatin1String("")));
	if (!urls.contains(computer))
		urls << computer;
	QUrl volumes(QUrl::fromLocalFile("/Volumes"));
	if (!urls.contains(volumes))
		urls << volumes;
	//desktop too?	QUrl computer(QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)));
	setSidebarUrls(urls);
#endif
	QList<QPushButton *> b = findChildren<QPushButton *>();
	QListIterator<QPushButton *> i(b);
	while (i.hasNext())
		i.next()->setVisible(false);
	setMinimumSize(QSize(480, 310));
	setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
Example #3
0
QNapiOpenDialog::QNapiOpenDialog( QWidget * parent, const QString & caption,
									const QString & init_path,
									FilterMode filterMode )
							: QFileDialog(parent)
{
	setAttribute(Qt::WA_QuitOnClose, false);
	setWindowTitle(caption);

	if(filterMode == Movies)
	{
#if QT_VERSION >= 0x040400
		setNameFilter
#else
		setFilter
#endif
				(tr("Filmy (*.avi *.asf *.divx *.mkv *.mov *.mp4 *.mpeg *.mpg *.ogm "
					"*.rm *.rmvb *.wmv);;Wszystkie pliki (*.*)"));
	}
	else if(filterMode == Subtitles)
	{
#if QT_VERSION >= 0x040400
		setNameFilter
#else
		setFilter
#endif
				(tr("Napisy (*.txt);;Wszystkie pliki (*.*)"));
	}

	if(QFileInfo(init_path).isDir())
		setDirectory(init_path);
	else
		setDirectory(QDir::currentPath());

	QStringList sideUrls;
	
#ifdef Q_WS_MAC
	sideUrls << "/Volumes";
	setAttribute(Qt::WA_MacBrushedMetal, GlobalConfig().useBrushedMetal());
#endif

	sideUrls << QString(QDir::homePath() + "/Movies") << QString(QDir::homePath() + "/movies")
				<< QString(QDir::homePath() + "/Video") << QString(QDir::homePath() + "/video")
				<< QString(QDir::homePath() + "/Filmy") << QString(QDir::homePath() + "/filmy")
				<< QString(QDir::homePath() + "/Wideo") << QString(QDir::homePath() + "/wideo");

	QList<QUrl> urls = sidebarUrls();

	foreach(QString sideUrl, sideUrls)
	{
		if(!QDir().exists(sideUrl)) continue;
		QUrl url = QUrl::fromLocalFile(sideUrl);
		if(!urls.contains(url))
			urls << url;
	}

	setSidebarUrls(urls);
}
Example #4
0
QNapiOpenDialog::QNapiOpenDialog(QWidget* parent, const QString& caption,
                                 const QString& init_path,
                                 FilterMode filterMode)
    : QFileDialog(parent), staticConfig(LibQNapi::staticConfig()) {
  setAttribute(Qt::WA_QuitOnClose, false);
  setWindowTitle(caption);

  if (filterMode == Movies) {
    setNameFilter(tr("Video files (%1);;All files (*.*)")
                      .arg(staticConfig->movieExtensionsFilter()));
  } else if (filterMode == Subtitles) {
    setNameFilter(tr("Subtitles files (%1);;All files (*.*)")
                      .arg(staticConfig->subtitleExtensionsFilter()));
  }

  if (QFileInfo(init_path).isDir())
    setDirectory(init_path);
  else
    setDirectory(QDir::currentPath());

  QStringList sideUrls;

#ifdef Q_OS_MAC
  sideUrls << "/Volumes";
#endif

  sideUrls << QString(QDir::homePath() + "/Movies")
           << QString(QDir::homePath() + "/movies")
           << QString(QDir::homePath() + "/Video")
           << QString(QDir::homePath() + "/video")
           << QString(QDir::homePath() + "/Videos")
           << QString(QDir::homePath() + "/videos")
           << QString(QDir::homePath() + "/Filmy")
           << QString(QDir::homePath() + "/wideo");

  QList<QUrl> urls = sidebarUrls();

  foreach (QString sideUrl, sideUrls) {
    if (!QDir().exists(sideUrl)) continue;
    QUrl url = QUrl::fromLocalFile(sideUrl);
    if (!urls.contains(url)) urls << url;
  }

  setSidebarUrls(urls);
}
Example #5
0
void
pfmPage::slotPFMFileBrowse ()
{
    QStringList         files, filters;
    QString             file;


    QFileDialog *fd = new QFileDialog (this, tr ("pfmLoadM Open PFM Structure"));
    fd->setViewMode (QFileDialog::List);


    //  Always add the current working directory and the last used directory to the sidebar URLs in case we're running from the command line.
    //  This function is in the nvutility library.

    setSidebarUrls (fd, pfm_global->output_dir);


    filters << tr ("PFM (*.pfm)");

    fd->setFilters (filters);
    fd->setFileMode (QFileDialog::AnyFile);
    fd->selectFilter (tr ("PFM (*.pfm)"));

    if (fd->exec () == QDialog::Accepted)
    {
        //  Save the directory that we were in when we selected a file.

        pfm_global->output_dir = fd->directory ().absolutePath ();

        files = fd->selectedFiles ();

        pfm_def->name = files.at (0);


        if (!pfm_def->name.isEmpty())
        {
            if (!pfm_def->name.endsWith (".pfm")) pfm_def->name.append (".pfm");


            //  This will trigger slotPFMFileEdit.

            pfm_file_edit->setText (pfm_def->name);
        }
    }
}
Example #6
0
FileDialog::FileDialog( QWidget *parent, const QString &caption,
					   const QString &directory, const QString &filter ) :
	QFileDialog( parent, caption, directory, filter )
{
#if (QT_VERSION >= 0x040806 && QT_VERSION < 0x050000) || QT_VERSION > 0x050200
	setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif

	// Add additional locations to the sidebar
	QList<QUrl> urls = sidebarUrls();
#if QT_VERSION >= 0x050000
	urls << QUrl::fromLocalFile( QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ) );
#else
	urls << QUrl::fromLocalFile( QDesktopServices::storageLocation( QDesktopServices::DesktopLocation ) );
#endif
	// Find downloads directory
	QDir downloadDir( QDir::homePath() + "/Downloads" );
	if ( ! downloadDir.exists() )
#if QT_VERSION >= 0x050000
		downloadDir = QStandardPaths::writableLocation( QStandardPaths::DownloadLocation );
#else
		downloadDir = QDesktopServices::storageLocation( QDesktopServices::DocumentsLocation ) + "/Downloads";
#endif
	if ( downloadDir.exists() )
		urls << QUrl::fromLocalFile( downloadDir.absolutePath() );

#if QT_VERSION >= 0x050000
	urls << QUrl::fromLocalFile( QStandardPaths::writableLocation( QStandardPaths::MusicLocation ) );
#else
	urls << QUrl::fromLocalFile( QDesktopServices::storageLocation( QDesktopServices::MusicLocation ) );
#endif
	urls << QUrl::fromLocalFile( ConfigManager::inst()->workingDir() );

	// Add `/Volumes` directory on OS X systems, this allows the user to browse
	// external disk drives.
#ifdef LMMS_BUILD_APPLE
	QDir volumesDir( QDir("/Volumes") );
	if ( volumesDir.exists() )
		urls << QUrl::fromLocalFile( volumesDir.absolutePath() );
#endif

	setSidebarUrls(urls);
}
Example #7
0
void
pfmPage::slotAreaFileBrowse ()
{
    QFileDialog fd (this, tr ("pfmLoadM Area File"));
    fd.setViewMode (QFileDialog::List);


    //  Always add the current working directory and the last used directory to the sidebar URLs in case we're running from the command line.
    //  This function is in the nvutility library.

    setSidebarUrls (&fd, pfm_global->area_dir);


    QStringList filters;
    filters << tr ("Area file (*.ARE *.are *.afs)");

    fd.setFilters (filters);
    fd.setFileMode (QFileDialog::ExistingFile);
    fd.selectFilter (tr ("Area file (*.ARE *.are *.afs)"));


    QStringList files;
    if (fd.exec () == QDialog::Accepted)
    {
        //  Save the directory that we were in when we selected a file.

        pfm_global->area_dir = fd.directory ().absolutePath ();

        files = fd.selectedFiles ();

        pfm_def->area = files.at (0);


        if (!pfm_def->area.isEmpty())
        {
            area_edit->setText (pfm_def->area);

            if (!pfm_file_edit->text ().isEmpty () && !area_edit->text ().isEmpty ()) setButtonText (QWizard::NextButton, tr ("Next"));
        }
    }
}
Example #8
0
void
pfmPage::slotFeatureFileBrowse ()
{
    QFileDialog *fd = new QFileDialog (this, tr ("pfmLoadM Feature File"));
    fd->setViewMode (QFileDialog::List);


    //  Always add the current working directory and the last used directory to the sidebar URLs in case we're running from the command line.
    //  This function is in the nvutility library.

    setSidebarUrls (fd, pfm_global->feature_dir);


    QStringList filters;
    filters << tr ("Binary Feature Data (*.bfd)");

    fd->setFilters (filters);
    fd->setFileMode (QFileDialog::ExistingFile);
    fd->selectFilter (tr ("Binary Feature Data (*.bfd)"));


    QStringList files;
    if (fd->exec () == QDialog::Accepted)
    {
        //  Save the directory that we were in when we selected a file.

        pfm_global->feature_dir = fd->directory ().absolutePath ();

        files = fd->selectedFiles ();

        pfm_def->feature = files.at (0);


        if (!pfm_def->feature.isEmpty())
        {
            feature_edit->setText (pfm_def->feature);
        }
    }
}
Example #9
0
void mosaicPage::slotTxtFileBrowse ()
{
  QStringList         files, filters;
  QString             file;


  QFileDialog *fd = new QFileDialog (this, tr ("pfmChartsImage Select Mission Parameters File"));
  fd->setViewMode (QFileDialog::List);


  //  Always add the current working directory and the last used directory to the sidebar URLs in case we're running from the command line.
  //  This function is in the nvutility library.

  setSidebarUrls (fd, options->param_dir);


  filters << tr ("Text (*.txt)");

  fd->setFilters (filters);
  fd->setFileMode (QFileDialog::ExistingFile);
  fd->selectFilter (tr ("Text (*.txt)"));

  if (fd->exec () == QDialog::Accepted)
    {
      files = fd->selectedFiles ();

      QString txt_file_name = files.at (0);


      if (!txt_file_name.isEmpty())
        {
          txt_file_edit->setText (txt_file_name);

	  NV_CHAR txt_file[512];
	  strcpy (txt_file, txt_file_name.toAscii ());

	  FILE *fp;

	  if ((fp = fopen (txt_file, "r")) == NULL)
	    {
	      QMessageBox::warning (this, tr ("Select Mission Parameters File"),
				    tr ("The file ") + txt_file_name + 
				    tr (" could not be opened.") +
				    tr ("  The error message returned was:\n\n") +
				    QString (strerror (errno)));

              return;
	    }


	  NV_CHAR string[128];
	  NV_FLOAT64 roll_bias = 0.0, pitch_bias = 0.0, heading_bias = 0.0, pixel_size = 0.0, focal_length = 0.0, 
	    col_offset = 0.0, row_offset = 0.0, time_delay = 0.0;
          NV_INT32 ms;

	  while (fgets (string, sizeof (string), fp) != NULL)
	    {
	      if (strstr (string, "camera_boresight_roll:"))
		sscanf (string, "camera_boresight_roll: %lf", &roll_bias);

	      if (strstr (string, "camera_boresight_pitch:"))
		sscanf (string, "camera_boresight_pitch: %lf", &pitch_bias);

	      if (strstr (string, "camera_boresight_heading:"))
		sscanf (string, "camera_boresight_heading: %lf", &heading_bias);

	      if (strstr (string, "pixel_size:"))
		sscanf (string, "pixel_size: %lf", &pixel_size);

	      if (strstr (string, "focal_length:"))
		sscanf (string, "focal_length: %lf", &focal_length);

	      if (strstr (string, "principal_point_offsets:"))
		sscanf (string, "principal_point_offsets: %lf, %lf", &col_offset, &row_offset);

	      if (strstr (string, "camera_trig_delay:"))
                {
                  sscanf (string, "camera_trig_delay: %d", &ms);
                  time_delay = (NV_FLOAT64) ms / 1000.0;
                }
	    }
	  fclose (fp);

	  timeSpin->setValue (time_delay);
	  rollSpin->setValue (roll_bias);
	  pitchSpin->setValue (pitch_bias);
	  headingSpin->setValue (heading_bias);
	  focalSpin->setValue (focal_length);
	  pixelSpin->setValue (pixel_size);
	  colSpin->setValue (col_offset);
	  rowSpin->setValue (row_offset);
        }

      options->param_dir = fd->directory ().absolutePath ();
    }
}