src/main.cpp

changeset 296
38f6fad61bad
parent 293
9f85a54ead29
child 299
cf9a854b56a9
equal deleted inserted replaced
295:4241d948af28 296:38f6fad61bad
142 parent, 142 parent,
143 QObject::tr("Open model"), 143 QObject::tr("Open model"),
144 "", 144 "",
145 QObject::tr("LDraw models (*.ldr *.dat)")); 145 QObject::tr("LDraw models (*.ldr *.dat)"));
146 } 146 }
147
148 #if 0
149 static const QString localeCode(const QString& locale)
150 {
151 if (locale == "system") {
152 return QLocale::system().name();
153 }
154 else {
155 return locale;
156 }
157 }
158
159 /**
160 * @brief Changes the application language to the specified language
161 */
162 static void changeLanguage(const QString& locale, QTranslator* translator)
163 {
164 if (not locale.isEmpty()) {
165 const QString localeCode = ::localeCode(locale);
166 QLocale::setDefault(QLocale{localeCode});
167 qApp->removeTranslator(translator);
168 const QString path = LOCALE_DIR.filePath(localeCode + ".qm");
169 const bool loadSuccessful = translator->load(path);
170 if (loadSuccessful)
171 {
172 qApp->installTranslator(translator);
173 }
174 }
175 }
176 #endif
177 147
178 static ModelData* findModelData(const DocumentManager* documents, ModelId modelId) 148 static ModelData* findModelData(const DocumentManager* documents, ModelId modelId)
179 { 149 {
180 return documents->findPayload<ModelData>(modelId); 150 return documents->findPayload<ModelData>(modelId);
181 } 151 }
493 }, action); 463 }, action);
494 }; 464 };
495 const auto restoreSettings = [&]{ 465 const auto restoreSettings = [&]{
496 recentlyOpenedFiles = setting<Setting::RecentFiles>(); 466 recentlyOpenedFiles = setting<Setting::RecentFiles>();
497 renderPreferences = loadRenderPreferences(); 467 renderPreferences = loadRenderPreferences();
498 //changeLanguage(setting<Setting::Locale>(), &translator);
499 libraries.restoreFromSettings(); 468 libraries.restoreFromSettings();
500 updateRecentlyOpenedDocumentsMenu(); 469 updateRecentlyOpenedDocumentsMenu();
501 colorTable = loadColors(&libraries); 470 colorTable = loadColors(&libraries);
502 updateRenderPreferences(&ui, &renderPreferences, &documents); 471 updateRenderPreferences(&ui, &renderPreferences, &documents);
503 ui.mdiArea->setViewMode(setting<Setting::ViewMode>()); 472 ui.mdiArea->setViewMode(setting<Setting::ViewMode>());

mercurial