Ejemplo n.º 1
0
QString QG_FileDialog::getSaveFile(RS2::FormatType* type){
    setAcceptMode ( QFileDialog::AcceptSave );
    // read default settings:
    RS_SETTINGS->beginGroup("/Paths");
    QString defDir = RS_SETTINGS->readEntry("/Save",
                                              RS_SYSTEM->getHomeDir());
/*    QString defFilter = RS_SETTINGS->readEntry("/SaveFilter",
                                                 "Drawing Exchange DXF 2000 (*.dxf)");*/
    RS_SETTINGS->endGroup();

    RS_DEBUG->print("defDir: %s", defDir.toLatin1().data());
    QString fn = "";
    QStringList filters;
#ifdef USE_DXFRW
    filters << fDxf2000 << fDxfrw2000  << fDxfR12 << fLff << fCxf << fJww;
#else
    filters << fDxf2000 << fDxfR12 << fLff << fCxf << fJww;
#endif

    setWindowTitle(tr("Save Drawing As"));
    setFileMode(QFileDialog::AnyFile);
    setDirectory(defDir);
    setFilters(filters);
#if QT_VERSION >= 0x040400
    selectNameFilter(fDxf2000);
#endif
    ftype= RS2::FormatDXF;
    RS_DEBUG->print("defFilter: %s", fDxf2000.toLatin1().data());

    if (exec()==QDialog::Accepted) {
        QStringList fl = selectedFiles();
        if (!fl.isEmpty())
            fn = fl[0];
        fn = QDir::convertSeparators( QFileInfo(fn).absoluteFilePath() );
        getType(selectedFilter());
        if (type!=NULL)
                *type = ftype;
        // append default extension:
        if (QFileInfo(fn).fileName().indexOf('.')==-1) {
            fn += getExtension(ftype);
        }

    // store new default settings:
        RS_SETTINGS->beginGroup("/Paths");
        RS_SETTINGS->writeEntry("/Save", QFileInfo(fn).absolutePath());
        //RS_SETTINGS->writeEntry("/SaveFilter", fileDlg->selectedFilter());
        RS_SETTINGS->endGroup();
    }

    return fn;
}
Ejemplo n.º 2
0
void EngineManagementWidget::browseDefaultLocation()
{
	auto dlg = new QFileDialog(
		this, tr("Choose Directory"),
		ui->m_defaultLocationEdit->text());
	dlg->setFileMode(QFileDialog::Directory);
	dlg->setOption(QFileDialog::ShowDirsOnly);
	dlg->setAttribute(Qt::WA_DeleteOnClose);
	dlg->setAcceptMode(QFileDialog::AcceptOpen);

	connect(dlg, &QFileDialog::fileSelected, [=](const QString& dir)
	{
		ui->m_defaultLocationEdit->setText(dir);
		QSettings().setValue("ui/default_engine_location", dir);
	});
	dlg->open();
}
Ejemplo n.º 3
0
//------------------------------------------------------------------------------
//
XxMarkersFileDialog::XxMarkersFileDialog( 
   const QString& dirName,
   const QString& filter,
   bool           modal,
   bool           threeWay,
   QWidget*       parent
) :
   BaseClass( parent, tr("Save as"), dirName, filter)
{
   setModal( modal );
   setAcceptMode( QFileDialog::AcceptSave );
   
   // Hack to embed XxMarkersWidget into the QFileDialog, since the
   // convenient Qt3 addWidgets doesn't exist anymore
   QVBoxLayout *l = qFindChild<QVBoxLayout*>(this);
   Q_ASSERT(l);
   _markersWidget = new XxMarkersWidget( threeWay );
   l->addWidget(_markersWidget);
}
Ejemplo n.º 4
0
    wxQtFileDialog( wxWindow *parent, wxDialog *handler,
                    const wxString& message, const wxString& defaultDir,
                    const wxString& defaultFile, const wxString& wildCard, long style )
        : wxQtEventSignalHandler(parent, handler)
    {
        setLabelText(QFileDialog::LookIn, wxQtConvertString(message));
        setDirectory(wxQtConvertString(defaultDir));
        selectFile(wxQtConvertString(defaultFile));

        SetWildcard(wildCard);

        if (style & wxFD_FILE_MUST_EXIST)
            setFileMode(ExistingFile);
        else if (style & wxFD_MULTIPLE)
            setFileMode(ExistingFiles);

        if (style & wxFD_SAVE)
            setAcceptMode(AcceptSave);
            
        if (style & wxFD_CHANGE_DIR)
            connect(this, &QDialog::accepted, this, &wxQtFileDialog::changeDirectory);
    }
Ejemplo n.º 5
0
void MainWindow::openArchive()
{
    Interface *iface = qobject_cast<Interface*>(m_part);
    Q_ASSERT(iface);
    Q_UNUSED(iface);

    Kerfuffle::PluginManager pluginManager;
    auto dlg = new QFileDialog(this, i18nc("to open an archive", "Open Archive"));

    dlg->setMimeTypeFilters(pluginManager.supportedMimeTypes());
    dlg->setFileMode(QFileDialog::ExistingFile);
    dlg->setAcceptMode(QFileDialog::AcceptOpen);

    connect(dlg, &QDialog::finished, this, [this, dlg](int result) {
        if (result == QDialog::Accepted) {
            openUrl(dlg->selectedUrls().first());
        }
        dlg->deleteLater();
    });

    dlg->open();
}
ExportDissectionDialog::ExportDissectionDialog(QWidget *parent, capture_file *cap_file, export_type_e export_type):
    QFileDialog(parent),
    export_type_(export_type),
    cap_file_(cap_file)
  #if !defined(Q_OS_WIN)
    , save_bt_(NULL)
 #endif /* Q_OS_WIN */
{
#if !defined(Q_OS_WIN)
    QDialogButtonBox *button_box = findChild<QDialogButtonBox *>();
    QGridLayout *fd_grid = qobject_cast<QGridLayout*>(layout());
    QHBoxLayout *h_box = new QHBoxLayout();
    QStringList name_filters;
    int last_row;

    setWindowTitle(tr("Wireshark: Export Packet Dissections"));
    setAcceptMode(QFileDialog::AcceptSave);
    setLabelText(FileType, tr("Export as:"));

    // export_type_map_keys() sorts alphabetically. We don't want that.
    name_filters
            << tr("Plain text (*.txt)")
            << tr("Comma Separated Values - summary (*.csv)")
            << tr("PSML - summary (*.psml, *.xml)")
            << tr("PDML - details (*.pdml, *.xml)")
            << tr("C Arrays - bytes (*.c, *.h)");
    export_type_map_[name_filters[0]] = export_type_text;
    export_type_map_[name_filters[1]] = export_type_csv;
    export_type_map_[name_filters[2]] = export_type_psml;
    export_type_map_[name_filters[3]] = export_type_pdml;
    export_type_map_[name_filters[4]] = export_type_carrays;
    setNameFilters(name_filters);
    selectNameFilter(export_type_map_.key(export_type));
    exportTypeChanged(export_type_map_.key(export_type));

    last_row = fd_grid->rowCount();
    fd_grid->addItem(new QSpacerItem(1, 1), last_row, 0);
    fd_grid->addLayout(h_box, last_row, 1);

    /* Init the export range */
    packet_range_init(&print_args_.range, cap_file_);
    /* Default to displayed packets */
    print_args_.range.process_filtered = TRUE;

    packet_range_group_box_.initRange(&print_args_.range);
    h_box->addWidget(&packet_range_group_box_);

    h_box->addWidget(&packet_format_group_box_, 0, Qt::AlignTop);

    if (button_box) {
        button_box->addButton(QDialogButtonBox::Help);
        connect(button_box, SIGNAL(helpRequested()), this, SLOT(on_buttonBox_helpRequested()));

        save_bt_ = button_box->button(QDialogButtonBox::Save);
    }

    if (save_bt_) {
        connect(&packet_range_group_box_, SIGNAL(validityChanged(bool)),
                this, SLOT(checkValidity()));
        connect(&packet_format_group_box_, SIGNAL(formatChanged()),
                this, SLOT(checkValidity()));
    }
    connect(this, SIGNAL(filterSelected(QString)), this, SLOT(exportTypeChanged(QString)));

    // Grow the dialog to account for the extra widgets.
    resize(width(), height() + (packet_range_group_box_.height() * 2 / 3));

#else // Q_OS_WIN
#endif // Q_OS_WIN
}
Ejemplo n.º 7
0
QString QG_FileDialog::getSaveFile(RS2::FormatType* type){
    setAcceptMode ( QFileDialog::AcceptSave );
    // read default settings:
    RS_SETTINGS->beginGroup("/Paths");
    QString defDir = RS_SETTINGS->readEntry("/Save",
                                              RS_SYSTEM->getHomeDir());
/*    QString defFilter = RS_SETTINGS->readEntry("/SaveFilter",
                                                 "Drawing Exchange DXF 2000 (*.dxf)");*/
    RS_SETTINGS->endGroup();

    if(!defDir.endsWith("/") && !defDir.endsWith("\\"))
        defDir += QDir::separator();

    RS_DEBUG->print("defDir: %s", defDir.toLatin1().data());

    // setup filters
    QStringList filters;

    filters << fDxfrw2007 << fDxfrw2004 << fDxfrw2000 << fDxfrw14 << fDxfrw12 << fLff << fCxf << fJww;

    ftype = RS2::FormatDXFRW;
    RS_DEBUG->print("defFilter: %s", fDxfrw2007.toLatin1().data());

    // when defFilter is added the below should use the default extension.
    // generate an untitled name
    QString fn = "Untitled";
    if(QFile::exists( defDir + fn + getExtension( ftype ) ))
    {
        int fileCount = 1;
        while(QFile::exists( defDir + fn + QString("%1").arg(fileCount) +
                             getExtension(ftype)) )
            ++fileCount;
        fn += QString("%1").arg(fileCount);
    }

    // initialize dialog properties
    setWindowTitle(tr("Save %1 As").arg(name));
    setFileMode(QFileDialog::AnyFile);
    setDirectory(defDir);
    setFilters(filters);
    selectNameFilter(fDxfrw2007);
    selectFile(fn);
    auto&& ext=getExtension(ftype);
    if(ext.size()==4){
        if(ext[0]=='.') ext.remove(0,1);
    }
    if(ext.size()==3) setDefaultSuffix (ext);


    // only return non empty string when we have a complete, user approved, file name.
    if (exec()!=QDialog::Accepted)
        return QString("");

    QStringList fl = selectedFiles();
    if (fl.isEmpty())
        return QString("");

    QFileInfo fi = QFileInfo( fl[0] );
    fn = QDir::toNativeSeparators( fi.absoluteFilePath() );

    getType(selectedFilter());
    if (type!=NULL)
        *type = ftype;

    // append default extension:
    if (fi.fileName().endsWith(".dxf",Qt::CaseInsensitive)==-1)
        fn += getExtension(ftype);

    // store new default settings:
    RS_SETTINGS->beginGroup("/Paths");
    RS_SETTINGS->writeEntry("/Save", fi.absolutePath());
    //RS_SETTINGS->writeEntry("/SaveFilter", fileDlg->selectedFilter());
    RS_SETTINGS->endGroup();

    return fn;
}
Ejemplo n.º 8
0
QString QG_FileDialog::getOpenFile(RS2::FormatType* type){
//    bool fileAccepted = false;
    setAcceptMode ( QFileDialog::AcceptOpen );
    // read default settings:
    RS_SETTINGS->beginGroup("/Paths");
    QString defDir = RS_SETTINGS->readEntry("/Open",
                                              RS_SYSTEM->getHomeDir());
    RS_SETTINGS->endGroup();

    RS_DEBUG->print("defDir: %s", defDir.toLatin1().data());
    QString fn = "";
    QStringList filters;
#ifdef USE_DXFRW
    filters << fDxf << fDxfrw  << fDxf1 << fLff << fCxf << fJww;
#else
    filters << fDxf << fDxf1 << fLff << fCxf << fJww;
#endif

    setWindowTitle(tr("Open Drawing"));
#if QT_VERSION >= 0x040400
    setNameFilters(filters);
#endif
    setDirectory(defDir);
    setFileMode(QFileDialog::ExistingFile);
#if QT_VERSION >= 0x040400
    selectNameFilter(fDxfrw);
#endif
    ftype= RS2::FormatDXFRW;
    RS_DEBUG->print("defFilter: %s", fDxfrw.toLatin1().data());

    /* preview RVT PORT preview is currently not supported by QT4
    RS_Graphic* gr = new RS_Graphic;
    QG_GraphicView* prev = new QG_GraphicView(parent);
    prev->setContainer(gr);
    prev->setBorders(1, 1, 1, 1);
    fileDlg->setContentsPreviewEnabled(true);
    fileDlg->setContentsPreview(prev, prev); */

    if (exec()==QDialog::Accepted) {
        QStringList fl = selectedFiles();
        if (!fl.isEmpty()) {
            fn = fl[0];
        }
        fn = QDir::convertSeparators( QFileInfo(fn).absoluteFilePath() );

        if (type!=NULL) {
                getType(selectedFilter());
                *type = ftype;
        }

    // store new default settings:
        RS_SETTINGS->beginGroup("/Paths");
        RS_SETTINGS->writeEntry("/Open", QFileInfo(fn).absolutePath());
        RS_SETTINGS->writeEntry("/OpenFilter", selectedFilter());
        RS_SETTINGS->endGroup();
    }

    RS_DEBUG->print("QG_FileDialog::getOpenFileName: fileName: %s", fn.toLatin1().data());
    RS_DEBUG->print("QG_FileDialog::getOpenFileName: OK");

    // RVT PORT delete prev;
    // RVT PORT delete gr;
    return fn;
}
Ejemplo n.º 9
0
SaveFileDialog::SaveFileDialog (QWidget *parent, SaveFileOptions opt)
	: QFileDialog(parent, tr("Save file"), tr("Keystore.xkey"), tr("Keystore Files (*.xkey)")), mSaveOpt(opt)
{
	setAcceptMode(AcceptSave);
}
Ejemplo n.º 10
0
int FileSaveDialog::Init(const QString& path)
{
  QStringList imageFilters;
  imageFilters.append(tr("Windows Bitmap (*.bmp)"));
  imageFilters.append(tr("JPG/JPEG Format (*.jpg)"));
  imageFilters.append(tr("JP2 Format (*.jp2)"));
  imageFilters.append(tr("PNG Format (*.png)"));
  imageFilters.append(tr("JPEGXR Format (*.jxr *.wdp *.hdp)"));
  //imageFilters.append(tr("RAW Image Data (*.raw)"));

  setFilters(imageFilters);
  setAcceptMode(QFileDialog::AcceptSave);

  setDirectory(path);

  m_optionsLayout = new QStackedLayout();
  if(0 == m_optionsLayout)
    return -1;

  m_pngFilterLayout = new QVBoxLayout(&m_pngFilterGroupBox);
  if(0 == m_pngFilterLayout)
    return -1;

  m_pngMainLayout = new QVBoxLayout(&m_pngOptionsWidget);
  if(0 == m_pngMainLayout)
    return -1;

  m_jpegxrQualityLayout = new QHBoxLayout(&m_jpegxrQualityGroupBox);
  if(0 == m_jpegxrQualityLayout)
    return -1;

  m_jpegxrOverlapLayout = new QVBoxLayout(&m_jpegxrOverlapGroupBox);
  if(0 == m_jpegxrOverlapLayout)
    return -1;

  m_jpegxrTilesLayout = new QVBoxLayout();
  if(0 == m_jpegxrTilesLayout)
    return -1;

  m_jpegxrTilingModeLayout = new QVBoxLayout();
  if(0 == m_jpegxrTilingModeLayout)
    return -1;

  m_jpegxrTilingLayout = new QHBoxLayout(&m_jpegxrTilingGroupBox);
  if(0 == m_jpegxrTilingLayout)
    return -1;

  m_jpegxrTilesXLayout = new QHBoxLayout(&m_jpegxrTilesXGroupBox);
  if(0 == m_jpegxrTilesXLayout)
    return -1;

  m_jpegxrTilesYLayout = new QHBoxLayout(&m_jpegxrTilesYGroupBox);
  if(0 == m_jpegxrTilesYLayout)
    return -1;

  m_jpegxrTFLayout = new QHBoxLayout();
  if(0 == m_jpegxrTFLayout)
    return -1;

  m_jpegxrBitstreamLayout = new QVBoxLayout(&m_jpegxrBitstreamGroupBox);
  if(0 == m_jpegxrBitstreamLayout)
    return -1;

  m_jpegxrBTLayout = new QVBoxLayout();
  if(0 == m_jpegxrBTLayout)
    return -1;

  m_jpegxrFBTrimLayout = new QVBoxLayout(&m_jpegxrFBTrimGroupBox);
  if(0 == m_jpegxrFBTrimLayout)
    return -1;

  m_jpegxrBandsLayout = new QVBoxLayout(&m_jpegxrBandsGroupBox);
  if(0 == m_jpegxrBandsLayout)
    return -1;

  m_jpegxrSamplingLayout = new QVBoxLayout(&m_jpegxrSamplingGroupBox);
  if(0 == m_jpegxrSamplingLayout)
    return -1;

  m_jpegxrSBLayout = new QHBoxLayout();
  if(0 == m_jpegxrSBLayout)
    return -1;

  m_jpegxrAQualityLayout = new QHBoxLayout(&m_jpegxrAQualityGroupBox);
  if(0 == m_jpegxrAQualityLayout)
    return -1;

  m_jpegxrMainLayout = new QVBoxLayout(&m_jpegxrOptionsWidget);
  if(0 == m_jpegxrMainLayout)
    return -1;

  m_jpegTypeLayout = new QVBoxLayout(&m_jpegTypeGroupBox);
  if(0 == m_jpegTypeLayout)
    return -1;

  m_jpegSamplingLayout = new QVBoxLayout(&m_jpegSamplingGroupBox);
  if(0 == m_jpegSamplingLayout)
    return -1;

  m_jpegTopLayout = new QHBoxLayout();
  if(0 == m_jpegTopLayout)
    return -1;

  m_jpegQualityLayout = new QHBoxLayout(&m_jpegQualityGroupBox);
  if(0 == m_jpegQualityLayout)
    return -1;

  m_jpegMainLayout = new QVBoxLayout(&m_jpegOptionsWidget);
  if(0 == m_jpegMainLayout)
    return -1;

  m_jpeg2000ModeLayout = new QVBoxLayout(&m_jpeg2000ModeGroupBox);
  if(0 == m_jpeg2000ModeLayout)
    return -1;

  m_jpeg2000wtLayout = new QVBoxLayout(&m_jpeg2000wtGroupBox);
  if(0 == m_jpeg2000wtLayout)
    return -1;

  m_jpeg2000TopLayout = new QHBoxLayout();
  if(0 == m_jpeg2000TopLayout)
    return -1;

  m_jpeg2000RatioLayout = new QHBoxLayout(&m_jpeg2000RatioGroupBox);
  if(0 == m_jpeg2000RatioLayout)
    return -1;

  m_jpeg2000MainLayout = new QVBoxLayout(&m_jpeg2000OptionsWidget);
  if(0 == m_jpeg2000MainLayout)
    return -1;

// ---------- PNG ---------------------

  m_pngFilterGroupBox.setTitle(tr("Filters"));
  m_pngFilter0CheckBox.setText(tr("Sub"));
  m_pngFilter0CheckBox.setChecked(true);
  m_pngFilter1CheckBox.setText(tr("Up"));
  m_pngFilter1CheckBox.setChecked(true);
  m_pngFilter2CheckBox.setText(tr("Average"));
  m_pngFilter2CheckBox.setChecked(true);
  m_pngFilter3CheckBox.setText(tr("Paeth"));
  m_pngFilter3CheckBox.setChecked(true);

  m_pngFilterLayout->addWidget(&m_pngFilter0CheckBox);
  m_pngFilterLayout->addWidget(&m_pngFilter1CheckBox);
  m_pngFilterLayout->addWidget(&m_pngFilter2CheckBox);
  m_pngFilterLayout->addWidget(&m_pngFilter3CheckBox);
  m_pngMainLayout->addWidget(&m_pngFilterGroupBox);
  m_pngMainLayout->addStretch();

// ---------- JPEGXR ---------------------

  m_jpegxrOverlapGroupBox.setTitle(tr("Filters"));
  m_jpegxrOverlap0RadioButton.setText(tr("No"));
  m_jpegxrOverlap1RadioButton.setText(tr("One"));
  m_jpegxrOverlap2RadioButton.setText(tr("Two"));
  m_jpegxrOverlap0RadioButton.setChecked(true);

  m_jpegxrOverlapLayout->addWidget(&m_jpegxrOverlap0RadioButton);
  m_jpegxrOverlapLayout->addWidget(&m_jpegxrOverlap1RadioButton);
  m_jpegxrOverlapLayout->addWidget(&m_jpegxrOverlap2RadioButton);
  m_jpegxrTFLayout->addWidget(&m_jpegxrOverlapGroupBox);
  m_jpegxrFBTrimGroupBox.setTitle(tr("FB trim"));
  m_jpegxrFBTrimSpinBox.setRange(0, 15);
  m_jpegxrFBTrimSpinBox.setValue(0);
  m_jpegxrFBTrimLayout->addWidget(&m_jpegxrFBTrimSpinBox);
  m_jpegxrTFLayout->addWidget(&m_jpegxrFBTrimGroupBox);
  m_jpegxrMainLayout->addLayout(m_jpegxrTFLayout);

  m_jpegxrQualityGroupBox.setTitle(tr("Quality"));
  m_jpegxrQualitySlider.setOrientation(Qt::Horizontal);
  m_jpegxrQualitySlider.setTickInterval(20);
  m_jpegxrQualitySlider.setRange(1, 255);
  m_jpegxrQualitySlider.setTickPosition(QSlider::TicksBelow);
  m_jpegxrQualitySlider.setValue(1);
  m_jpegxrQualitySpinBox.setRange(1, 255);
  m_jpegxrQualitySpinBox.setValue(1);
  m_jpegxrQualityLayout->addWidget(&m_jpegxrQualitySlider);
  m_jpegxrQualityLayout->addWidget(&m_jpegxrQualitySpinBox);

  connect(&m_jpegxrQualitySpinBox, SIGNAL(valueChanged(int)), &m_jpegxrQualitySlider,  SLOT(setValue(int)));
  connect(&m_jpegxrQualitySlider,  SIGNAL(valueChanged(int)), &m_jpegxrQualitySpinBox, SLOT(setValue(int)));
  m_jpegxrMainLayout->addWidget(&m_jpegxrQualityGroupBox);

  m_jpegxrAlphaCheckBox.setText(tr("Planar alpha"));
  m_jpegxrAlphaCheckBox.setChecked(false);
  m_jpegxrMainLayout->addWidget(&m_jpegxrAlphaCheckBox);

  switch(m_image->Color())
  {
  case RGBA:
  case BGRA:
  case RGBAP:
  case BGRAP:
  case CMYKA:
    m_jpegxrAlphaCheckBox.setDisabled(false);
    break;
  default:
    m_jpegxrAlphaCheckBox.setDisabled(true);
    break;
  }

  connect(&m_jpegxrAlphaCheckBox, SIGNAL(clicked()), this, SLOT(updateJpegxrButtons()));

  m_jpegxrAQualityGroupBox.setTitle(tr("Alpha quality"));
  m_jpegxrAQualitySlider.setOrientation(Qt::Horizontal);
  m_jpegxrAQualitySlider.setTickInterval(20);
  m_jpegxrAQualitySlider.setRange(1, 255);
  m_jpegxrAQualitySlider.setTickPosition(QSlider::TicksBelow);
  m_jpegxrAQualitySlider.setValue(1);
  m_jpegxrAQualitySpinBox.setRange(1, 255);
  m_jpegxrAQualitySpinBox.setValue(1);
  m_jpegxrAQualityLayout->addWidget(&m_jpegxrAQualitySlider);
  m_jpegxrAQualityLayout->addWidget(&m_jpegxrAQualitySpinBox);

  if(!m_jpegxrAlphaCheckBox.isChecked())
  {
    m_jpegxrAQualitySlider.setDisabled(true);
    m_jpegxrAQualitySpinBox.setDisabled(true);
  }

  connect(&m_jpegxrAQualitySpinBox, SIGNAL(valueChanged(int)), &m_jpegxrAQualitySlider,  SLOT(setValue(int)));
  connect(&m_jpegxrAQualitySlider,  SIGNAL(valueChanged(int)), &m_jpegxrAQualitySpinBox, SLOT(setValue(int)));
  m_jpegxrMainLayout->addWidget(&m_jpegxrAQualityGroupBox);


  m_jpegxrTilingGroupBox.setTitle(tr("Tiling"));
  m_jpegxrTilesXGroupBox.setTitle(tr("Horizontal"));
  m_jpegxrTilesXSpinBox.setRange(0, 4096);
  m_jpegxrTilesXSpinBox.setValue(0);
  m_jpegxrTilesXLayout->addWidget(&m_jpegxrTilesXSpinBox);
  m_jpegxrTilesLayout->addWidget(&m_jpegxrTilesXGroupBox);

  m_jpegxrTilesYGroupBox.setTitle(tr("Vertical"));
  m_jpegxrTilesYSpinBox.setRange(0, 4096);
  m_jpegxrTilesYSpinBox.setValue(0);
  m_jpegxrTilesYLayout->addWidget(&m_jpegxrTilesYSpinBox);
  m_jpegxrTilesLayout->addWidget(&m_jpegxrTilesYGroupBox);
  m_jpegxrTilingLayout->addLayout(m_jpegxrTilesLayout);

  m_jpegxrTiling0RadioButton.setText(tr("Amount"));
  m_jpegxrTiling1RadioButton.setText(tr("Size (1=16px)"));
  m_jpegxrTiling0RadioButton.setChecked(true);
  m_jpegxrTilingModeLayout->addWidget(&m_jpegxrTiling0RadioButton);
  m_jpegxrTilingModeLayout->addWidget(&m_jpegxrTiling1RadioButton);
  m_jpegxrTilingLayout->addLayout(m_jpegxrTilingModeLayout);
  m_jpegxrMainLayout->addWidget(&m_jpegxrTilingGroupBox);

  m_jpegxrMainLayout->addStretch();

// ---------- JPEG ---------------------

  m_jpegTypeGroupBox.setTitle(tr("JPEG"));
  m_jpegBASRadioButton.setText(tr("BAS"));
  m_jpegEXTRadioButton.setText(tr("EXT"));
  m_jpegPRGRadioButton.setText(tr("PRG"));
  m_jpegLSLRadioButton.setText(tr("LSL"));
  m_jpegTypeLayout->addWidget(&m_jpegBASRadioButton);
  m_jpegTypeLayout->addWidget(&m_jpegEXTRadioButton);
  m_jpegTypeLayout->addWidget(&m_jpegPRGRadioButton);
  m_jpegTypeLayout->addWidget(&m_jpegLSLRadioButton);

  m_jpegSamplingGroupBox.setTitle(tr("Sampling"));

  m_jpeg411RadioButton.setText(tr("411"));
  m_jpeg422RadioButton.setText(tr("422"));
  m_jpeg444RadioButton.setText(tr("444"));
  m_jpegSamplingLayout->addWidget(&m_jpeg411RadioButton);
  m_jpegSamplingLayout->addWidget(&m_jpeg422RadioButton);
  m_jpegSamplingLayout->addWidget(&m_jpeg444RadioButton);

  m_jpegTopLayout->addWidget(&m_jpegTypeGroupBox);
  m_jpegTopLayout->addWidget(&m_jpegSamplingGroupBox);

  connect(&m_jpegBASRadioButton, SIGNAL(clicked()), this, SLOT(updateJpegButtons()));
  connect(&m_jpegEXTRadioButton, SIGNAL(clicked()), this, SLOT(updateJpegButtons()));
  connect(&m_jpegPRGRadioButton, SIGNAL(clicked()), this, SLOT(updateJpegButtons()));
  connect(&m_jpegLSLRadioButton, SIGNAL(clicked()), this, SLOT(updateJpegButtons()));

  m_jpegRestartIntervalCheckBox.setText(tr("Restart interval"));
  m_jpegRestartIntervalCheckBox.setChecked(false);

  m_jpegOtimalHuffmanCheckBox.setText(tr("Use optimal Huffman table"));
  m_jpegOtimalHuffmanCheckBox.setChecked(false);

  if(m_image->NChannels() == 1)
  {
    m_jpegColorComboBox.addItem(tr("Gray"));
    m_jpeg444RadioButton.setChecked(true);
    m_jpeg422RadioButton.setDisabled(true);
    m_jpeg411RadioButton.setDisabled(true);
  }
  else if(m_image->NChannels() == 3)
  {
    if(m_image->Precision() != 12)
    {
      m_jpegColorComboBox.addItem(tr("YCbCr"));
      m_jpegColorComboBox.addItem(tr("RGB"));
    }
    else
    {
      m_jpegColorComboBox.addItem(tr("UNK"));
    }
  }
  else if(m_image->NChannels() == 4)
  {
    m_jpegColorComboBox.addItem(tr("YCCK"));
    m_jpegColorComboBox.addItem(tr("CMYK"));
    m_jpegColorComboBox.addItem(tr("UNK"));
  }

  if(m_image->Precision() <= 8)
  {
    m_jpegBASRadioButton.setChecked(true);
    m_jpegEXTRadioButton.setDisabled(true);
    m_jpeg411RadioButton.setChecked(true);
  }
  else
  {
    if(m_image->Precision() != 12)
    {
      m_jpegEXTRadioButton.setDisabled(true);
      m_jpegBASRadioButton.setDisabled(true);
      m_jpegPRGRadioButton.setDisabled(true);
      m_jpegLSLRadioButton.setChecked (true);
    }
    else
    {
      m_jpegEXTRadioButton.setChecked(true);;
      m_jpegBASRadioButton.setDisabled(true);
      m_jpegPRGRadioButton.setDisabled(true);
    }

    m_jpeg444RadioButton.setChecked(true);
    m_jpeg422RadioButton.setDisabled(true);
    m_jpeg411RadioButton.setDisabled(true);
  }

  m_jpegQualityGroupBox.setTitle(tr("Quality"));
  m_jpegQualitySlider.setOrientation(Qt::Horizontal);
  m_jpegQualitySlider.setTickInterval(10);
  m_jpegQualitySlider.setRange(0, 100);
  m_jpegQualitySlider.setTickPosition(QSlider::TicksBelow);
  m_jpegQualitySpinBox.setRange(0, 100);
  m_jpegQualitySlider.setValue(75);
  m_jpegQualityLayout->addWidget(&m_jpegQualitySlider);
  m_jpegQualityLayout->addWidget(&m_jpegQualitySpinBox);
  m_jpegQualitySpinBox.setValue(75);

  connect(&m_jpegQualitySpinBox, SIGNAL(valueChanged(int)), &m_jpegQualitySlider, SLOT(setValue(int)));
  connect(&m_jpegQualitySlider, SIGNAL(valueChanged(int)), &m_jpegQualitySpinBox, SLOT(setValue(int)));

  m_jpegMainLayout->addLayout(m_jpegTopLayout);
  m_jpegMainLayout->addWidget(&m_jpegRestartIntervalCheckBox);
  m_jpegMainLayout->addWidget(&m_jpegOtimalHuffmanCheckBox);
  m_jpegMainLayout->addWidget(&m_jpegColorComboBox);
  m_jpegMainLayout->addWidget(&m_jpegQualityGroupBox);
  m_jpegMainLayout->addStretch();

// ---------- JPEG2000 ---------------------

  m_jpeg2000ModeGroupBox.setTitle(tr("Mode"));
  m_jpeg2000LossyRadioButton.setText(tr("Lossy"));
  m_jpeg2000LosslessRadioButton.setText(tr("Lossless"));
  m_jpeg2000LosslessRadioButton.setChecked(true);
  m_jpeg2000ModeLayout->addWidget(&m_jpeg2000LosslessRadioButton);
  m_jpeg2000ModeLayout->addWidget(&m_jpeg2000LossyRadioButton);
  m_jpeg2000wtGroupBox.setTitle(tr("WT"));
  m_jpeg2000wt53RadioButton.setText(tr("WT53"));
  m_jpeg2000wt97RadioButton.setText(tr("WT97"));
  m_jpeg2000wt53RadioButton.setChecked(true);
  m_jpeg2000wtLayout->addWidget(&m_jpeg2000wt53RadioButton);
  m_jpeg2000wtLayout->addWidget(&m_jpeg2000wt97RadioButton);
  m_jpeg2000TopLayout->addWidget(&m_jpeg2000ModeGroupBox);
  m_jpeg2000TopLayout->addWidget(&m_jpeg2000wtGroupBox);

  connect(&m_jpeg2000LosslessRadioButton, SIGNAL(clicked()), this, SLOT(updateJpeg2000Buttons()));
  connect(&m_jpeg2000LossyRadioButton, SIGNAL(clicked()), this, SLOT(updateJpeg2000Buttons()));

  m_jpeg2000MCTCheckBox.setChecked(true);
  m_jpeg2000MCTCheckBox.setText(tr("Use MCT"));
  m_jpeg2000RatioGroupBox.setTitle(tr("Quality"));
  m_jpeg2000RatioSlider.setOrientation(Qt::Horizontal);
  m_jpeg2000RatioSlider.setTickInterval(10);
  m_jpeg2000RatioSlider.setRange(0, 100);
  m_jpeg2000RatioSlider.setTickPosition(QSlider::TicksBelow);
  m_jpeg2000RatioSpinBox.setRange(0, 100);
  m_jpeg2000RatioSlider.setValue(0);
  m_jpeg2000RatioLayout->addWidget(&m_jpeg2000RatioSlider);
  m_jpeg2000RatioLayout->addWidget(&m_jpeg2000RatioSpinBox);

  connect(&m_jpeg2000RatioSpinBox, SIGNAL(valueChanged(int)), &m_jpeg2000RatioSlider, SLOT(setValue(int)));
  connect(&m_jpeg2000RatioSlider, SIGNAL(valueChanged(int)), &m_jpeg2000RatioSpinBox, SLOT(setValue(int)));

  m_jpeg2000MainLayout->addLayout(m_jpeg2000TopLayout);
  m_jpeg2000MainLayout->addWidget(&m_jpeg2000MCTCheckBox);
  m_jpeg2000MainLayout->addWidget(&m_jpeg2000RatioGroupBox);
  m_jpeg2000MainLayout->addStretch();

  m_optionsLayout->addWidget(&m_bmpOptionsWidget);
  m_optionsLayout->addWidget(&m_jpegOptionsWidget);
  m_optionsLayout->addWidget(&m_jpeg2000OptionsWidget);
  //m_optionsLayout->addWidget(&m_rawOptionsWidget);
  m_optionsLayout->addWidget(&m_pngOptionsWidget);
  m_optionsLayout->addWidget(&m_jpegxrOptionsWidget);

  m_mainLayout = dynamic_cast<QGridLayout*>(layout());
  if(0 != m_mainLayout)
  {
    int numCols = m_mainLayout->columnCount();
    m_mainLayout->addLayout(m_optionsLayout, 0, numCols, 5, 1);

    m_imageCommentLabel.setText(tr("Comment:"));
    m_mainLayout->addWidget(&m_imageCommentLabel,4,0);

    m_mainLayout->addWidget(&m_imageCommentEdit, 4, 1);
  }

  adjustSize();

  updateJpegButtons();
  updateJpeg2000Buttons();

  connect(this, SIGNAL(rejected()), this, SLOT(OnCancel()));
  connect(this, SIGNAL(accepted()), this, SLOT(OnOk()));
  connect(this, SIGNAL(filterSelected(const QString&)), this, SLOT(filterSelected(const QString&)));

  return 0;
} // FileSaveDialog::Init()
ExportDissectionDialog::ExportDissectionDialog(QWidget *parent, capture_file *cap_file, export_type_e export_type):
    QFileDialog(parent),
    export_type_(export_type),
    cap_file_(cap_file)
#if !defined(Q_OS_WIN)
    , save_bt_(NULL)
#endif /* Q_OS_WIN */
{

    switch (prefs.gui_fileopen_style) {

    case FO_STYLE_LAST_OPENED:
        /* The user has specified that we should start out in the last directory
         * we looked in.  If we've already opened a file, use its containing
         * directory, if we could determine it, as the directory, otherwise
         * use the "last opened" directory saved in the preferences file if
         * there was one.
         */
        setDirectory(wsApp->lastOpenDir());
        break;

    case FO_STYLE_SPECIFIED:
        /* The user has specified that we should always start out in a
         * specified directory; if they've specified that directory,
         * start out by showing the files in that dir.
         */
        if (prefs.gui_fileopen_dir[0] != '\0')
            setDirectory(prefs.gui_fileopen_dir);
        break;
    }

#if !defined(Q_OS_WIN)
    QDialogButtonBox *button_box = findChild<QDialogButtonBox *>();
    // Add extra widgets
    // https://wiki.qt.io/Qt_project_org_faq#How_can_I_add_widgets_to_my_QFileDialog_instance.3F
    setOption(QFileDialog::DontUseNativeDialog, true);
    QGridLayout *fd_grid = qobject_cast<QGridLayout*>(layout());
    QHBoxLayout *h_box = new QHBoxLayout();
    QStringList name_filters;
    int last_row;

    setWindowTitle(wsApp->windowTitleString(tr("Export Packet Dissections")));
    setAcceptMode(QFileDialog::AcceptSave);
    setLabelText(FileType, tr("Export As:"));

    // export_type_map_keys() sorts alphabetically. We don't want that.
    name_filters
            << tr("Plain text (*.txt)")
            << tr("Comma Separated Values - summary (*.csv)")
            << tr("PSML - summary (*.psml, *.xml)")
            << tr("PDML - details (*.pdml, *.xml)")
            << tr("JSON (*.json)")
            << tr("C Arrays - bytes (*.c, *.h)");
    export_type_map_[name_filters[0]] = export_type_text;
    export_type_map_[name_filters[1]] = export_type_csv;
    export_type_map_[name_filters[2]] = export_type_psml;
    export_type_map_[name_filters[3]] = export_type_pdml;
    export_type_map_[name_filters[4]] = export_type_json;
    export_type_map_[name_filters[5]] = export_type_carrays;
    setNameFilters(name_filters);
    selectNameFilter(export_type_map_.key(export_type));
    exportTypeChanged(export_type_map_.key(export_type));

    last_row = fd_grid->rowCount();
    fd_grid->addItem(new QSpacerItem(1, 1), last_row, 0);
    fd_grid->addLayout(h_box, last_row, 1);

    print_args_.file = NULL;
    /* Init the export range */
    packet_range_init(&print_args_.range, cap_file_);
    /* Default to displayed packets */
    print_args_.range.process_filtered = TRUE;

    packet_range_group_box_.initRange(&print_args_.range);
    h_box->addWidget(&packet_range_group_box_);

    h_box->addWidget(&packet_format_group_box_, 0, Qt::AlignTop);

    if (button_box) {
        button_box->addButton(QDialogButtonBox::Help);
        connect(button_box, SIGNAL(helpRequested()), this, SLOT(on_buttonBox_helpRequested()));

        save_bt_ = button_box->button(QDialogButtonBox::Save);
    }

    if (save_bt_) {
        connect(&packet_range_group_box_, SIGNAL(validityChanged(bool)),
                this, SLOT(checkValidity()));
        connect(&packet_format_group_box_, SIGNAL(formatChanged()),
                this, SLOT(checkValidity()));
    }
    connect(this, SIGNAL(filterSelected(QString)), this, SLOT(exportTypeChanged(QString)));

    // Grow the dialog to account for the extra widgets.
    resize(width(), height() + (packet_range_group_box_.height() * 2 / 3));

#else // Q_OS_WIN
#endif // Q_OS_WIN
}