1 files changed, 15 insertions, 18 deletions
diff --git a/src/TextInputWidget.cc b/src/TextInputWidget.cc
index 829784fd..c4d01357 100644
--- a/src/TextInputWidget.cc
+++ b/src/TextInputWidget.cc
@@ -276,30 +276,27 @@ TextInputWidget::command(QString command, QString args)
void
TextInputWidget::openFileSelection()
{
- QStringList supportedFiles;
- supportedFiles << "jpeg"
- << "gif"
- << "png"
- << "bmp"
- << "tiff"
- << "webp";
+ QStringList imageExtensions;
+ imageExtensions << "jpeg"
+ << "gif"
+ << "png"
+ << "bmp"
+ << "tiff"
+ << "webp";
- auto fileName = QFileDialog::getOpenFileName(
- this,
- tr("Select an image"),
- "",
- tr("Image Files (*.bmp *.gif *.jpg *.jpeg *.png *.tiff *.webp)"));
+ auto fileName =
+ QFileDialog::getOpenFileName(this, tr("Select an file"), "", tr("All Files (*)"));
if (fileName.isEmpty())
return;
- auto imageFormat = QString(QImageReader::imageFormat(fileName));
- if (!supportedFiles.contains(imageFormat)) {
- qDebug() << "Unsupported image format for" << fileName;
- return;
- }
+ auto format = QString(QImageReader::imageFormat(fileName));
+
+ if (imageExtensions.contains(format))
+ emit uploadImage(fileName);
+ else
+ emit uploadFile(fileName);
- emit uploadImage(fileName);
showUploadSpinner();
}
|