Showing the changes to interface/src/ImportDialog.cpp (1 of 4 files). Show all
Unified · Split
| @@ -72,17 +72,28 @@ QIcon HiFiIconProvider::icon(const QFileInfo &info) const { · 71 unmodified lines | ||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | QFileInfo iconFile("resources/icons/" + iconsMap[ext]); |
| 75 | − if (iconFile.exists()) { | |
| 75 | + if (iconFile.exists() && iconFile.isFile()) { | |
| 76 | 76 | return QIcon(iconFile.filePath()); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | return QIcon("resources/icons/file.svg"); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | +QString HiFiIconProvider::type(const QFileInfo &info) const { | |
| 83 | + if (info.isFile()) { | |
| 84 | + if (info.suffix().size() > 4) { | |
| 85 | + return info.suffix().at(0).toUpper() + info.suffix().mid(1); | |
| 86 | + } | |
| 87 | + return info.suffix().toUpper(); | |
| 88 | + } | |
| 89 | + | |
| 90 | + return QFileIconProvider::type(info); | |
| 91 | +} | |
| 92 | + | |
| 82 | 93 | ImportDialog::ImportDialog(QWidget *parent) : |
| 83 | − QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, NULL), | |
| 84 | − _importButton(IMPORT_BUTTON_NAME, this), | |
| 85 | − _cancelButton(CANCEL_BUTTON_NAME, this) { | |
| 94 | +QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, NULL), | |
| 95 | +_importButton(IMPORT_BUTTON_NAME, this), | |
| 96 | +_cancelButton(CANCEL_BUTTON_NAME, this) { | |
| 86 | 97 | |
| 87 | 98 | setOption(QFileDialog::DontUseNativeDialog, true); |
| 88 | 99 | setFileMode(QFileDialog::ExistingFile); |
| @@ -96,8 +107,8 @@ ImportDialog::ImportDialog(QWidget *parent) : · 7 unmodified lines | ||
| 96 | 107 | gridLayout->addWidget(&_importButton, 2, 2); |
| 97 | 108 | |
| 98 | 109 | connect(&_importButton, SIGNAL(pressed()), SLOT(import())); |
| 99 | − connect(this, SIGNAL(currentChanged(QString)), SLOT(saveCurrentFile(QString))); | |
| 100 | 110 | connect(&_cancelButton, SIGNAL(pressed()), SLOT(close())); |
| 111 | + connect(this, SIGNAL(currentChanged(QString)), SLOT(saveCurrentFile(QString))); | |
| 101 | 112 | } |
| 102 | 113 | |
| 103 | 114 | ImportDialog::~ImportDialog() { |
| @@ -210,7 +221,7 @@ void ImportDialog::setImportTypes() { · 106 unmodified lines | ||
| 210 | 221 | if (!document.isNull() && !document.isEmpty()) { |
| 211 | 222 | |
| 212 | 223 | QString importFormatsInfo; |
| 213 | − QStringList importFormatsFilterList; | |
| 224 | + QString importFormatsFilterList; | |
| 214 | 225 | QHash<QString, QString> iconsMap; |
| 215 | 226 | |
| 216 | 227 | QJsonObject configObject = document.object(); |
| @@ -233,7 +244,7 @@ void ImportDialog::setImportTypes() { · 16 unmodified lines | ||
| 233 | 244 | importFormatsInfo.append(" or"); |
| 234 | 245 | } |
| 235 | 246 | |
| 236 | − importFormatsFilterList.append(QString("%1 (*.%2)").arg(description, ext)); | |
| 247 | + importFormatsFilterList.append(QString("*.%1 ").arg(ext)); | |
| 237 | 248 | importFormatsInfo.append(" .").append(ext); |
| 238 | 249 | iconsMap[ext] = icon; |
| 239 | 250 | ff++; |
| @@ -242,8 +253,7 @@ void ImportDialog::setImportTypes() { · 2 unmodified lines | ||
| 242 | 253 | |
| 243 | 254 | // set custom file icons |
| 244 | 255 | setIconProvider(new HiFiIconProvider(iconsMap)); |
| 245 | − | |
| 246 | − setNameFilters(importFormatsFilterList); | |
| 256 | + setNameFilter(importFormatsFilterList); | |
| 247 | 257 | |
| 248 | 258 | setLabelText(QFileDialog::LookIn, QString(IMPORT_INFO).arg(importFormatsInfo)); |
| 249 | 259 | setLabelText(QFileDialog::FileName, INFO_LABEL_TEXT); |