Showing the changes to interface/src/ImportDialog.cpp (1 of 1 file). Show all
Unified · Split
| @@ -25,6 +25,8 @@ const QString INFO_LABEL_TEXT = QObject::tr("<div style='line-height:20px;'>" · 24 unmodified lines | ||
| 25 | 25 | "add mode (S or V keys will toggle mode) to place.</div>"); |
| 26 | 26 | |
| 27 | 27 | const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
| 28 | +const int SHORT_FILE_EXTENSION = 4; | |
| 29 | +const int SECOND_INDEX_LETTER = 1; | |
| 28 | 30 | |
| 29 | 31 | QIcon HiFiIconProvider::icon(QFileIconProvider::IconType type) const { |
| 30 | 32 | |
| @@ -83,8 +85,9 @@ QIcon HiFiIconProvider::icon(const QFileInfo &info) const { · 52 unmodified lines | ||
| 83 | 85 | |
| 84 | 86 | QString HiFiIconProvider::type(const QFileInfo &info) const { |
| 85 | 87 | if (info.isFile()) { |
| 86 | − if (info.suffix().size() > 4) { | |
| 87 | − return info.suffix().at(0).toUpper() + info.suffix().mid(1); | |
| 88 | + if (info.suffix().size() > SHORT_FILE_EXTENSION) { | |
| 89 | + // Capitalize extension | |
| 90 | + return info.suffix().left(SECOND_INDEX_LETTER).toUpper() + info.suffix().mid(SECOND_INDEX_LETTER); | |
| 88 | 91 | } |
| 89 | 92 | return info.suffix().toUpper(); |
| 90 | 93 | } |
| @@ -92,10 +95,10 @@ QString HiFiIconProvider::type(const QFileInfo &info) const { · 1 unmodified line | ||
| 92 | 95 | return QFileIconProvider::type(info); |
| 93 | 96 | } |
| 94 | 97 | |
| 95 | −ImportDialog::ImportDialog(QWidget *parent) : | |
| 96 | −QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, NULL), | |
| 97 | −_importButton(IMPORT_BUTTON_NAME, this), | |
| 98 | −_cancelButton(CANCEL_BUTTON_NAME, this) { | |
| 98 | +ImportDialog::ImportDialog(QWidget* parent) : | |
| 99 | + QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, NULL), | |
| 100 | + _importButton(IMPORT_BUTTON_NAME, this), | |
| 101 | + _cancelButton(CANCEL_BUTTON_NAME, this) { | |
| 99 | 102 | |
| 100 | 103 | setOption(QFileDialog::DontUseNativeDialog, true); |
| 101 | 104 | setFileMode(QFileDialog::ExistingFile); |
| @@ -106,7 +109,7 @@ _cancelButton(CANCEL_BUTTON_NAME, this) { · 4 unmodified lines | ||
| 106 | 109 | #else |
| 107 | 110 | QString cmdString = ("Control"); |
| 108 | 111 | #endif |
| 109 | − QLabel *infoLabel = new QLabel(QString(INFO_LABEL_TEXT).arg(cmdString)); | |
| 112 | + QLabel* infoLabel = new QLabel(QString(INFO_LABEL_TEXT).arg(cmdString)); | |
| 110 | 113 | infoLabel->setObjectName("infoLabel"); |
| 111 | 114 | |
| 112 | 115 | QGridLayout* gridLayout = (QGridLayout*) layout(); |
| @@ -206,7 +209,7 @@ void ImportDialog::setLayout() { · 93 unmodified lines | ||
| 206 | 209 | widget = findChild<QWidget*>("buttonBox"); |
| 207 | 210 | widget->hide(); |
| 208 | 211 | |
| 209 | − QSplitter *splitter = findChild<QSplitter*>("splitter"); | |
| 212 | + QSplitter* splitter = findChild<QSplitter*>("splitter"); | |
| 210 | 213 | splitter->setHandleWidth(0); |
| 211 | 214 | |
| 212 | 215 | // remove blue outline on Mac |
| @@ -243,7 +246,7 @@ void ImportDialog::setImportTypes() { · 30 unmodified lines | ||
| 243 | 246 | QJsonObject configObject = document.object(); |
| 244 | 247 | if (!configObject.isEmpty()) { |
| 245 | 248 | QJsonArray fileFormats = configObject["importFormats"].toArray(); |
| 246 | − int ff = 0; | |
| 249 | + int formatsCounter = 0; | |
| 247 | 250 | foreach (const QJsonValue& fileFormat, fileFormats) { |
| 248 | 251 | QJsonObject fileFormatObject = fileFormat.toObject(); |
| 249 | 252 | |
| @@ -251,19 +254,19 @@ void ImportDialog::setImportTypes() { · 1 unmodified line | ||
| 251 | 254 | QString description(fileFormatObject.value("description").toString()); |
| 252 | 255 | QString icon(fileFormatObject.value("icon").toString()); |
| 253 | 256 | |
| 254 | − if (ff > 0) { | |
| 257 | + if (formatsCounter > 0) { | |
| 255 | 258 | importFormatsInfo.append(","); |
| 256 | 259 | } |
| 257 | 260 | |
| 258 | 261 | // set ' or' on last import type text |
| 259 | − if (ff == fileFormats.count() - 1) { | |
| 262 | + if (formatsCounter == fileFormats.count() - 1) { | |
| 260 | 263 | importFormatsInfo.append(" or"); |
| 261 | 264 | } |
| 262 | 265 | |
| 263 | 266 | importFormatsFilterList.append(QString("*.%1 ").arg(ext)); |
| 264 | 267 | importFormatsInfo.append(" .").append(ext); |
| 265 | 268 | iconsMap[ext] = icon; |
| 266 | − ff++; | |
| 269 | + formatsCounter++; | |
| 267 | 270 | } |
| 268 | 271 | } |
| 269 | 272 | |