diff --git a/src/EditDialog.cpp b/src/EditDialog.cpp index 9e21732d..2ca8bbbb 100644 --- a/src/EditDialog.cpp +++ b/src/EditDialog.cpp @@ -289,48 +289,37 @@ void EditDialog::importData() QList image_formats_list = QImageReader::supportedImageFormats(); for(int i=0;icomboMode->currentIndex(); - // Order the filters according to the mode. First the appropriate for the current mode, - // and then the others in similarity order. + // Set as selected filter the appropriate for the current mode. switch (mode) { case TextEditor: - filters << tr("Text files (*.txt)") << - tr("JSON files (*.json)") << - tr("XML files (*.xml)") << - tr("Image files (%1)").arg(image_formats) << - tr("Binary files (*.bin)") << tr("All files (*)"); + selectedFilter = tr("Text files (*.txt)"); break; case HexEditor: - filters << tr("Binary files (*.bin)") << - tr("Image files (%1)").arg(image_formats) << - tr("Text files (*.txt)") << - tr("JSON files (*.json)") << - tr("XML files (*.xml)") << - tr("All files (*)"); + selectedFilter = tr("Binary files (*.bin)"); break; case ImageViewer: - filters << tr("Image files (%1)").arg(image_formats) << - tr("Binary files (*.bin)") << - tr("Text files (*.txt)") << - tr("JSON files (*.json)") << - tr("XML files (*.xml)") << - tr("All files (*)"); + selectedFilter = tr("Image files (%1)").arg(image_formats); break; case JsonEditor: - filters << tr("JSON files (*.json)") << - tr("Text files (*.txt)") << - tr("XML files (*.xml)") << - tr("Image files (%1)").arg(image_formats) << - tr("Binary files (*.bin)") << - tr("All files (*)"); + selectedFilter = tr("JSON files (*.json)"); break; case XmlEditor: - sciEdit->setFocus(); + selectedFilter = tr("XML files (*.xml)"); break; } QString fileName = FileDialog::getOpenFileName( @@ -338,6 +327,7 @@ void EditDialog::importData() tr("Choose a file to import") #ifndef Q_OS_MAC // Filters on OS X are buggy , filters.join(";;") + , &selectedFilter #endif ); if(QFile::exists(fileName)) @@ -403,7 +393,7 @@ void EditDialog::exportData() case HexBuffer: // Data source is the hex buffer // If text option has been selected, the readable representation of the content is saved to file. - if (fileName.endsWith(".txt")) + if (fileName.endsWith(".txt", Qt::CaseInsensitive)) file.write(hexEdit->toReadableString().toUtf8()); else file.write(hexEdit->data());