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