fix: filter based on MIME type instead of plaintext suffix

Suffixes are unreliable in different locales, while MIME types are more
standarized.
This commit is contained in:
flow 2022-05-07 20:16:55 -03:00
parent f7f39854f8
commit 2fbb7be23b
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 4 additions and 2 deletions

View File

@ -100,7 +100,8 @@ void SkinUploadDialog::on_buttonBox_accepted()
void SkinUploadDialog::on_skinBrowseBtn_clicked()
{
QString raw_path = QFileDialog::getOpenFileName(this, tr("Select Skin Texture"), QString(), "*.png");
auto filter = QMimeDatabase().mimeTypeForName("image/png").filterString();
QString raw_path = QFileDialog::getOpenFileName(this, tr("Select Skin Texture"), QString(), filter);
if (raw_path.isEmpty() || !QFileInfo::exists(raw_path))
{
return;

View File

@ -143,7 +143,8 @@ void ImportPage::setUrl(const QString& url)
void ImportPage::on_modpackBtn_clicked()
{
const QUrl url = QFileDialog::getOpenFileUrl(this, tr("Choose modpack"), modpackUrl(), tr("Zip (*.zip)"));
auto filter = QMimeDatabase().mimeTypeForName("application/zip").filterString();
const QUrl url = QFileDialog::getOpenFileUrl(this, tr("Choose modpack"), modpackUrl(), filter);
if (url.isValid())
{
if (url.isLocalFile())